contract.ts 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * office-runtime 对外契约:内置文档插件(documents / pdf / presentations / spreadsheets)如何声明
  3. * 查看面板,以及在插件根目录运行 `node ../office-runtime/scripts/build.mjs` 后保证产出什么。
  4. * 面板与 MCP 工具的运行时契约见 src/contract.ts 与 src/CONTRACT.md。
  5. */
  6. import type { DocKind } from "#office/contract.ts";
  7. export type { DocKind };
  8. /** 插件包 package.json 的 "office" 字段:面板标题与该插件打开的格式。 */
  9. export interface OfficePluginConfig {
  10. title: { en: string; "zh-CN": string };
  11. kinds: readonly DocKind[];
  12. }
  13. /**
  14. * 构建后在插件根目录下必定存在的产物。官方 seed、SEA、桌面打包与远端资产都把它们当作必需资产,
  15. * 缺任一项即视为残缺插件。
  16. */
  17. export const OFFICE_RUNTIME_OUTPUTS = [
  18. "dist/server.mjs",
  19. "dist/ui/assets.json",
  20. "dist/ui/panel.html",
  21. ] as const;
  22. export interface OfficeRuntimeContract {
  23. /** 插件声明的面板配置;插件名取自其 .zcode-plugin/plugin.json,决定 MCP 服务与 ui:// 资源地址。 */
  24. config: OfficePluginConfig;
  25. /** 构建保证产出的文件,相对插件根目录。 */
  26. outputs: typeof OFFICE_RUNTIME_OUTPUTS;
  27. }