@vetta-org/plugin-sdk 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/activity-tab.d.ts +2 -0
  2. package/dist/activity-tab.d.ts.map +1 -1
  3. package/dist/activity-tab.js +1 -1
  4. package/dist/activity-tab.js.map +1 -1
  5. package/dist/agent.d.ts +158 -2
  6. package/dist/agent.d.ts.map +1 -1
  7. package/dist/agent.js +14 -1
  8. package/dist/agent.js.map +1 -1
  9. package/dist/ai.d.ts +93 -0
  10. package/dist/ai.d.ts.map +1 -0
  11. package/dist/ai.js +2 -0
  12. package/dist/ai.js.map +1 -0
  13. package/dist/app-actions.d.ts +9 -0
  14. package/dist/app-actions.d.ts.map +1 -1
  15. package/dist/app-actions.js.map +1 -1
  16. package/dist/artifacts.d.ts +31 -0
  17. package/dist/artifacts.d.ts.map +1 -0
  18. package/dist/artifacts.js +2 -0
  19. package/dist/artifacts.js.map +1 -0
  20. package/dist/browser.d.ts +119 -0
  21. package/dist/browser.d.ts.map +1 -0
  22. package/dist/browser.js +2 -0
  23. package/dist/browser.js.map +1 -0
  24. package/dist/capture.d.ts +64 -0
  25. package/dist/capture.d.ts.map +1 -0
  26. package/dist/capture.js +2 -0
  27. package/dist/capture.js.map +1 -0
  28. package/dist/context.d.ts +46 -5
  29. package/dist/context.d.ts.map +1 -1
  30. package/dist/context.js.map +1 -1
  31. package/dist/conversation.d.ts +66 -2
  32. package/dist/conversation.d.ts.map +1 -1
  33. package/dist/conversation.js.map +1 -1
  34. package/dist/gateway.d.ts +37 -0
  35. package/dist/gateway.d.ts.map +1 -0
  36. package/dist/gateway.js +14 -0
  37. package/dist/gateway.js.map +1 -0
  38. package/dist/index.d.ts +20 -9
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +4 -0
  41. package/dist/index.js.map +1 -1
  42. package/dist/jobs.d.ts +34 -0
  43. package/dist/jobs.d.ts.map +1 -0
  44. package/dist/jobs.js +2 -0
  45. package/dist/jobs.js.map +1 -0
  46. package/dist/manifest-schema.d.ts +234 -0
  47. package/dist/manifest-schema.d.ts.map +1 -0
  48. package/dist/manifest-schema.js +145 -0
  49. package/dist/manifest-schema.js.map +1 -0
  50. package/dist/manifest.d.ts +21 -55
  51. package/dist/manifest.d.ts.map +1 -1
  52. package/dist/manifest.js +342 -1
  53. package/dist/manifest.js.map +1 -1
  54. package/dist/media.d.ts +193 -0
  55. package/dist/media.d.ts.map +1 -0
  56. package/dist/media.js +11 -0
  57. package/dist/media.js.map +1 -0
  58. package/dist/network.d.ts +2 -1
  59. package/dist/network.d.ts.map +1 -1
  60. package/dist/network.js.map +1 -1
  61. package/dist/npm-package.d.ts +17 -0
  62. package/dist/npm-package.d.ts.map +1 -0
  63. package/dist/npm-package.js +38 -0
  64. package/dist/npm-package.js.map +1 -0
  65. package/dist/official.d.ts +218 -10
  66. package/dist/official.d.ts.map +1 -1
  67. package/dist/official.js.map +1 -1
  68. package/dist/permissions.d.ts +2 -1
  69. package/dist/permissions.d.ts.map +1 -1
  70. package/dist/permissions.js +54 -1
  71. package/dist/permissions.js.map +1 -1
  72. package/dist/prompt-attachment.d.ts +30 -6
  73. package/dist/prompt-attachment.d.ts.map +1 -1
  74. package/dist/prompt-attachment.js +35 -1
  75. package/dist/prompt-attachment.js.map +1 -1
  76. package/dist/quickjs.d.ts +147 -0
  77. package/dist/quickjs.d.ts.map +1 -0
  78. package/dist/quickjs.js +2 -0
  79. package/dist/quickjs.js.map +1 -0
  80. package/dist/storage.d.ts +7 -0
  81. package/dist/storage.d.ts.map +1 -1
  82. package/dist/storage.js.map +1 -1
  83. package/dist/ui.d.ts +223 -15
  84. package/dist/ui.d.ts.map +1 -1
  85. package/dist/ui.js.map +1 -1
  86. package/package.json +21 -2
  87. package/src/tailwind-theme.css +30 -0
@@ -1,2 +1,55 @@
1
- export {};
1
+ export const PLUGIN_PERMISSIONS = [
2
+ "ui.slot.global",
3
+ "ui.slot.file-preview",
4
+ "ui.slot.activity-tab",
5
+ "ui.slot.input-action",
6
+ "ui.slot.message",
7
+ "ui.slot.tool-call",
8
+ "ui.slot.turn-card",
9
+ "ui.slot.workspace-view",
10
+ "ui.shortcuts.register",
11
+ "ui.file-explorer.decorations",
12
+ "ui.file-explorer.context-menu",
13
+ "ui.file-explorer.toolbar",
14
+ "workspace.read",
15
+ "agent.session.read",
16
+ "agent.session.write",
17
+ "agent.command.run",
18
+ "agent.command.spawn",
19
+ "capture.offscreen",
20
+ "browser.read",
21
+ "browser.open",
22
+ "browser.interact",
23
+ "browser.profile.persist",
24
+ "browser.attach",
25
+ "browser.runtime.manage",
26
+ "agent.systemPrompt.read",
27
+ "agent.systemPrompt.write",
28
+ "agent.systemPrompt.fullControl",
29
+ "agent.skills.control",
30
+ "agent.mcp.control",
31
+ "agent.tools.control",
32
+ "agent.tools.register",
33
+ "agent.toolHandler.execute",
34
+ "agent.hooks.register",
35
+ "agent.hookHandler.execute",
36
+ "agent.state.read",
37
+ "agent.state.write",
38
+ "agent.continuation.register",
39
+ "agent.runtime.configure",
40
+ "app.actions.register",
41
+ "app.actionHandler.execute",
42
+ "ai.models.list",
43
+ "ai.complete",
44
+ "fs.read",
45
+ "fs.write",
46
+ "network.fetch",
47
+ "storage.read",
48
+ "storage.write",
49
+ "media.generate",
50
+ "media.provider.register",
51
+ "settings.read",
52
+ "settings.write",
53
+ "shell.openExternal",
54
+ ];
2
55
  //# sourceMappingURL=permissions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"","sourcesContent":["export type PluginPermission =\n\t| \"ui.slot.global\"\n\t| \"ui.slot.file-preview\"\n\t| \"ui.slot.activity-tab\"\n\t| \"ui.slot.input-action\"\n\t| \"ui.slot.message\"\n\t| \"ui.slot.tool-call\"\n\t| \"ui.slot.turn-card\"\n\t| \"ui.shortcuts.register\"\n\t| \"ui.file-explorer.decorations\"\n\t| \"ui.file-explorer.context-menu\"\n\t| \"ui.file-explorer.toolbar\"\n\t| \"workspace.read\"\n\t| \"agent.session.read\"\n\t| \"agent.session.write\"\n\t| \"agent.command.run\"\n\t| \"agent.command.spawn\"\n\t| \"agent.systemPrompt.read\"\n\t| \"agent.systemPrompt.write\"\n\t| \"agent.systemPrompt.fullControl\"\n\t| \"agent.skills.control\"\n\t| \"agent.mcp.control\"\n\t| \"agent.tools.control\"\n\t| \"agent.tools.register\"\n\t| \"agent.toolHandler.execute\"\n\t| \"agent.state.read\"\n\t| \"agent.state.write\"\n\t| \"agent.continuation.register\"\n\t| \"agent.runtime.configure\"\n\t| \"app.actions.register\"\n\t| \"app.actionHandler.execute\"\n\t| \"fs.read\"\n\t| \"fs.write\"\n\t| \"network.fetch\"\n\t| \"storage.read\"\n\t| \"storage.write\"\n\t| \"settings.read\"\n\t| \"settings.write\";\n"]}
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;IACtB,sBAAsB;IACtB,iBAAiB;IACjB,mBAAmB;IACnB,mBAAmB;IACnB,wBAAwB;IACxB,uBAAuB;IACvB,8BAA8B;IAC9B,+BAA+B;IAC/B,0BAA0B;IAC1B,gBAAgB;IAChB,oBAAoB;IACpB,qBAAqB;IACrB,mBAAmB;IACnB,qBAAqB;IACrB,mBAAmB;IACnB,cAAc;IACd,cAAc;IACd,kBAAkB;IAClB,yBAAyB;IACzB,gBAAgB;IAChB,wBAAwB;IACxB,yBAAyB;IACzB,0BAA0B;IAC1B,gCAAgC;IAChC,sBAAsB;IACtB,mBAAmB;IACnB,qBAAqB;IACrB,sBAAsB;IACtB,2BAA2B;IAC3B,sBAAsB;IACtB,2BAA2B;IAC3B,kBAAkB;IAClB,mBAAmB;IACnB,6BAA6B;IAC7B,yBAAyB;IACzB,sBAAsB;IACtB,2BAA2B;IAC3B,gBAAgB;IAChB,aAAa;IACb,SAAS;IACT,UAAU;IACV,eAAe;IACf,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,yBAAyB;IACzB,eAAe;IACf,gBAAgB;IAChB,oBAAoB;CACX,CAAC","sourcesContent":["export const PLUGIN_PERMISSIONS = [\n\t\"ui.slot.global\",\n\t\"ui.slot.file-preview\",\n\t\"ui.slot.activity-tab\",\n\t\"ui.slot.input-action\",\n\t\"ui.slot.message\",\n\t\"ui.slot.tool-call\",\n\t\"ui.slot.turn-card\",\n\t\"ui.slot.workspace-view\",\n\t\"ui.shortcuts.register\",\n\t\"ui.file-explorer.decorations\",\n\t\"ui.file-explorer.context-menu\",\n\t\"ui.file-explorer.toolbar\",\n\t\"workspace.read\",\n\t\"agent.session.read\",\n\t\"agent.session.write\",\n\t\"agent.command.run\",\n\t\"agent.command.spawn\",\n\t\"capture.offscreen\",\n\t\"browser.read\",\n\t\"browser.open\",\n\t\"browser.interact\",\n\t\"browser.profile.persist\",\n\t\"browser.attach\",\n\t\"browser.runtime.manage\",\n\t\"agent.systemPrompt.read\",\n\t\"agent.systemPrompt.write\",\n\t\"agent.systemPrompt.fullControl\",\n\t\"agent.skills.control\",\n\t\"agent.mcp.control\",\n\t\"agent.tools.control\",\n\t\"agent.tools.register\",\n\t\"agent.toolHandler.execute\",\n\t\"agent.hooks.register\",\n\t\"agent.hookHandler.execute\",\n\t\"agent.state.read\",\n\t\"agent.state.write\",\n\t\"agent.continuation.register\",\n\t\"agent.runtime.configure\",\n\t\"app.actions.register\",\n\t\"app.actionHandler.execute\",\n\t\"ai.models.list\",\n\t\"ai.complete\",\n\t\"fs.read\",\n\t\"fs.write\",\n\t\"network.fetch\",\n\t\"storage.read\",\n\t\"storage.write\",\n\t\"media.generate\",\n\t\"media.provider.register\",\n\t\"settings.read\",\n\t\"settings.write\",\n\t\"shell.openExternal\",\n] as const;\n\nexport type PluginPermission = (typeof PLUGIN_PERMISSIONS)[number];\n"]}
@@ -1,14 +1,38 @@
1
+ export type PluginPromptContextJsonValue = null | boolean | number | string | PluginPromptContextJsonValue[] | {
2
+ [key: string]: PluginPromptContextJsonValue;
3
+ };
4
+ /** Versioned, JSON-safe application state attached to an outgoing prompt. */
5
+ export interface PluginPromptContext<TPayload extends object = object> {
6
+ /** Namespaced context contract, for example `vetta.content-creation.node-selection`. */
7
+ schema: string;
8
+ version: number;
9
+ payload: TPayload;
10
+ }
11
+ /**
12
+ * Validate a plugin-owned context before handing it to the host. The generic
13
+ * preserves the plugin's domain type while the runtime guard enforces a
14
+ * bounded, serializable cross-plugin contract.
15
+ */
16
+ export declare function definePluginPromptContext<TPayload extends object>(context: PluginPromptContext<TPayload>): PluginPromptContext<TPayload>;
1
17
  /**
2
- * One-shot plugin-owned context attached to the next outgoing prompt.
3
- *
4
- * The host renders only the label/icon, merges metadata and hidden instructions
5
- * at send time, then clears the attachment. Domain payloads stay in plugin
6
- * storage or out-of-band references.
18
+ * Plugin-owned context shown in the input bar and attached to outgoing prompts.
19
+ * Legacy metadata/instructions remain supported; new domain data should use
20
+ * the structured `context` field instead of encoding state in instructions.
7
21
  */
8
- export interface PluginPromptAttachment {
22
+ export interface PluginPromptAttachment<TPayload extends object = object> {
9
23
  id: string;
10
24
  label: string;
25
+ /**
26
+ * 附件里的条目,宿主逐条渲染成一枚名字。省略时就是 `[label]`。
27
+ *
28
+ * 存在的理由是一次附件常常指向多个对象(三个设计画框、两个节点),把它们挤进
29
+ * 一条 label 就只剩「3 个画框」这种数不出是哪几个的说法。
30
+ */
31
+ labels?: string[];
11
32
  icon?: string;
33
+ /** Defaults to `once`; `sticky` remains attached until explicitly cleared. */
34
+ lifecycle?: "once" | "sticky";
35
+ context?: PluginPromptContext<TPayload>;
12
36
  instructions?: string[];
13
37
  metadata?: Record<string, unknown>;
14
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-attachment.d.ts","sourceRoot":"","sources":["../src/prompt-attachment.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC","sourcesContent":["/**\n * One-shot plugin-owned context attached to the next outgoing prompt.\n *\n * The host renders only the label/icon, merges metadata and hidden instructions\n * at send time, then clears the attachment. Domain payloads stay in plugin\n * storage or out-of-band references.\n */\nexport interface PluginPromptAttachment {\n\tid: string;\n\tlabel: string;\n\ticon?: string;\n\tinstructions?: string[];\n\tmetadata?: Record<string, unknown>;\n}\n"]}
1
+ {"version":3,"file":"prompt-attachment.d.ts","sourceRoot":"","sources":["../src/prompt-attachment.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,4BAA4B,GACrC,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,4BAA4B,EAAE,GAC9B;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,4BAA4B,CAAA;CAAE,CAAC;AAEnD,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM;IACpE,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,QAAQ,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,SAAS,MAAM,EAChE,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC,GACpC,mBAAmB,CAAC,QAAQ,CAAC,CAS/B;AAWD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9B,OAAO,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nconst MAX_PLUGIN_PROMPT_CONTEXT_BYTES = 256 * 1024;\n\nconst PluginPromptContextSchema = Type.Object(\n\t{\n\t\tschema: Type.String({ minLength: 1, maxLength: 160 }),\n\t\tversion: Type.Integer({ minimum: 1 }),\n\t\tpayload: Type.Record(Type.String(), Type.Unknown()),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type PluginPromptContextJsonValue =\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| PluginPromptContextJsonValue[]\n\t| { [key: string]: PluginPromptContextJsonValue };\n\n/** Versioned, JSON-safe application state attached to an outgoing prompt. */\nexport interface PluginPromptContext<TPayload extends object = object> {\n\t/** Namespaced context contract, for example `vetta.content-creation.node-selection`. */\n\tschema: string;\n\tversion: number;\n\tpayload: TPayload;\n}\n\n/**\n * Validate a plugin-owned context before handing it to the host. The generic\n * preserves the plugin's domain type while the runtime guard enforces a\n * bounded, serializable cross-plugin contract.\n */\nexport function definePluginPromptContext<TPayload extends object>(\n\tcontext: PluginPromptContext<TPayload>,\n): PluginPromptContext<TPayload> {\n\tif (!Value.Check(PluginPromptContextSchema, context) || !isJsonValue(context.payload)) {\n\t\tthrow new Error(\"Plugin prompt context must be a versioned JSON object\");\n\t}\n\tconst serialized = JSON.stringify(context);\n\tif (new TextEncoder().encode(serialized).byteLength > MAX_PLUGIN_PROMPT_CONTEXT_BYTES) {\n\t\tthrow new Error(`Plugin prompt context exceeds ${MAX_PLUGIN_PROMPT_CONTEXT_BYTES} bytes`);\n\t}\n\treturn context;\n}\n\nfunction isJsonValue(value: unknown): value is PluginPromptContextJsonValue {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every(isJsonValue);\n\tif (typeof value !== \"object\") return false;\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn (prototype === Object.prototype || prototype === null) && Object.values(value).every(isJsonValue);\n}\n\n/**\n * Plugin-owned context shown in the input bar and attached to outgoing prompts.\n * Legacy metadata/instructions remain supported; new domain data should use\n * the structured `context` field instead of encoding state in instructions.\n */\nexport interface PluginPromptAttachment<TPayload extends object = object> {\n\tid: string;\n\tlabel: string;\n\t/**\n\t * 附件里的条目,宿主逐条渲染成一枚名字。省略时就是 `[label]`。\n\t *\n\t * 存在的理由是一次附件常常指向多个对象(三个设计画框、两个节点),把它们挤进\n\t * 一条 label 就只剩「3 个画框」这种数不出是哪几个的说法。\n\t */\n\tlabels?: string[];\n\ticon?: string;\n\t/** Defaults to `once`; `sticky` remains attached until explicitly cleared. */\n\tlifecycle?: \"once\" | \"sticky\";\n\tcontext?: PluginPromptContext<TPayload>;\n\tinstructions?: string[];\n\tmetadata?: Record<string, unknown>;\n}\n"]}
@@ -1,2 +1,36 @@
1
- export {};
1
+ import { Type } from "@sinclair/typebox";
2
+ import { Value } from "@sinclair/typebox/value";
3
+ const MAX_PLUGIN_PROMPT_CONTEXT_BYTES = 256 * 1024;
4
+ const PluginPromptContextSchema = Type.Object({
5
+ schema: Type.String({ minLength: 1, maxLength: 160 }),
6
+ version: Type.Integer({ minimum: 1 }),
7
+ payload: Type.Record(Type.String(), Type.Unknown()),
8
+ }, { additionalProperties: false });
9
+ /**
10
+ * Validate a plugin-owned context before handing it to the host. The generic
11
+ * preserves the plugin's domain type while the runtime guard enforces a
12
+ * bounded, serializable cross-plugin contract.
13
+ */
14
+ export function definePluginPromptContext(context) {
15
+ if (!Value.Check(PluginPromptContextSchema, context) || !isJsonValue(context.payload)) {
16
+ throw new Error("Plugin prompt context must be a versioned JSON object");
17
+ }
18
+ const serialized = JSON.stringify(context);
19
+ if (new TextEncoder().encode(serialized).byteLength > MAX_PLUGIN_PROMPT_CONTEXT_BYTES) {
20
+ throw new Error(`Plugin prompt context exceeds ${MAX_PLUGIN_PROMPT_CONTEXT_BYTES} bytes`);
21
+ }
22
+ return context;
23
+ }
24
+ function isJsonValue(value) {
25
+ if (value === null || typeof value === "string" || typeof value === "boolean")
26
+ return true;
27
+ if (typeof value === "number")
28
+ return Number.isFinite(value);
29
+ if (Array.isArray(value))
30
+ return value.every(isJsonValue);
31
+ if (typeof value !== "object")
32
+ return false;
33
+ const prototype = Object.getPrototypeOf(value);
34
+ return (prototype === Object.prototype || prototype === null) && Object.values(value).every(isJsonValue);
35
+ }
2
36
  //# sourceMappingURL=prompt-attachment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-attachment.js","sourceRoot":"","sources":["../src/prompt-attachment.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * One-shot plugin-owned context attached to the next outgoing prompt.\n *\n * The host renders only the label/icon, merges metadata and hidden instructions\n * at send time, then clears the attachment. Domain payloads stay in plugin\n * storage or out-of-band references.\n */\nexport interface PluginPromptAttachment {\n\tid: string;\n\tlabel: string;\n\ticon?: string;\n\tinstructions?: string[];\n\tmetadata?: Record<string, unknown>;\n}\n"]}
1
+ {"version":3,"file":"prompt-attachment.js","sourceRoot":"","sources":["../src/prompt-attachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,MAAM,+BAA+B,GAAG,GAAG,GAAG,IAAI,CAAC;AAEnD,MAAM,yBAAyB,GAAG,IAAI,CAAC,MAAM,CAC5C;IACC,MAAM,EAAE,IAAI,CAAC,MAAM,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O,KAAK,CAAC;IAC5C,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAAA,CACzG","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nconst MAX_PLUGIN_PROMPT_CONTEXT_BYTES = 256 * 1024;\n\nconst PluginPromptContextSchema = Type.Object(\n\t{\n\t\tschema: Type.String({ minLength: 1, maxLength: 160 }),\n\t\tversion: Type.Integer({ minimum: 1 }),\n\t\tpayload: Type.Record(Type.String(), Type.Unknown()),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type PluginPromptContextJsonValue =\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| PluginPromptContextJsonValue[]\n\t| { [key: string]: PluginPromptContextJsonValue };\n\n/** Versioned, JSON-safe application state attached to an outgoing prompt. */\nexport interface PluginPromptContext<TPayload extends object = object> {\n\t/** Namespaced context contract, for example `vetta.content-creation.node-selection`. */\n\tschema: string;\n\tversion: number;\n\tpayload: TPayload;\n}\n\n/**\n * Validate a plugin-owned context before handing it to the host. The generic\n * preserves the plugin's domain type while the runtime guard enforces a\n * bounded, serializable cross-plugin contract.\n */\nexport function definePluginPromptContext<TPayload extends object>(\n\tcontext: PluginPromptContext<TPayload>,\n): PluginPromptContext<TPayload> {\n\tif (!Value.Check(PluginPromptContextSchema, context) || !isJsonValue(context.payload)) {\n\t\tthrow new Error(\"Plugin prompt context must be a versioned JSON object\");\n\t}\n\tconst serialized = JSON.stringify(context);\n\tif (new TextEncoder().encode(serialized).byteLength > MAX_PLUGIN_PROMPT_CONTEXT_BYTES) {\n\t\tthrow new Error(`Plugin prompt context exceeds ${MAX_PLUGIN_PROMPT_CONTEXT_BYTES} bytes`);\n\t}\n\treturn context;\n}\n\nfunction isJsonValue(value: unknown): value is PluginPromptContextJsonValue {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every(isJsonValue);\n\tif (typeof value !== \"object\") return false;\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn (prototype === Object.prototype || prototype === null) && Object.values(value).every(isJsonValue);\n}\n\n/**\n * Plugin-owned context shown in the input bar and attached to outgoing prompts.\n * Legacy metadata/instructions remain supported; new domain data should use\n * the structured `context` field instead of encoding state in instructions.\n */\nexport interface PluginPromptAttachment<TPayload extends object = object> {\n\tid: string;\n\tlabel: string;\n\t/**\n\t * 附件里的条目,宿主逐条渲染成一枚名字。省略时就是 `[label]`。\n\t *\n\t * 存在的理由是一次附件常常指向多个对象(三个设计画框、两个节点),把它们挤进\n\t * 一条 label 就只剩「3 个画框」这种数不出是哪几个的说法。\n\t */\n\tlabels?: string[];\n\ticon?: string;\n\t/** Defaults to `once`; `sticky` remains attached until explicitly cleared. */\n\tlifecycle?: \"once\" | \"sticky\";\n\tcontext?: PluginPromptContext<TPayload>;\n\tinstructions?: string[];\n\tmetadata?: Record<string, unknown>;\n}\n"]}
@@ -0,0 +1,147 @@
1
+ import type { ConversationScenario } from "./scenario.js";
2
+ import type { PluginNetworkRequest, PluginNetworkResponse } from "./network.js";
3
+ import type { PluginPutBlobInput, PluginStoredBlob, PluginStoredBlobRef } from "./storage.js";
4
+ import type { PluginActivityTabRetention } from "./ui.js";
5
+ export type PluginDeclarativeTextTone = "default" | "muted" | "success" | "warning" | "danger";
6
+ export interface PluginDeclarativeStack {
7
+ type: "stack";
8
+ direction?: "vertical" | "horizontal";
9
+ gap?: "small" | "medium" | "large";
10
+ children: PluginDeclarativeNode[];
11
+ }
12
+ export interface PluginDeclarativeSection {
13
+ type: "section";
14
+ title?: string;
15
+ description?: string;
16
+ children: PluginDeclarativeNode[];
17
+ }
18
+ export interface PluginDeclarativeText {
19
+ type: "text";
20
+ text: string;
21
+ style?: "body" | "heading" | "caption" | "code";
22
+ tone?: PluginDeclarativeTextTone;
23
+ }
24
+ export interface PluginDeclarativeButton {
25
+ type: "button";
26
+ label: string;
27
+ action: string;
28
+ variant?: "primary" | "secondary" | "outline" | "destructive";
29
+ disabled?: boolean;
30
+ }
31
+ export interface PluginDeclarativeInput {
32
+ type: "input";
33
+ action: string;
34
+ label?: string;
35
+ value?: string;
36
+ placeholder?: string;
37
+ inputType?: "text" | "password" | "number";
38
+ disabled?: boolean;
39
+ }
40
+ export interface PluginDeclarativeTextarea {
41
+ type: "textarea";
42
+ action: string;
43
+ label?: string;
44
+ value?: string;
45
+ placeholder?: string;
46
+ disabled?: boolean;
47
+ }
48
+ export interface PluginDeclarativeSelectOption {
49
+ value: string;
50
+ label: string;
51
+ }
52
+ export interface PluginDeclarativeSelect {
53
+ type: "select";
54
+ action: string;
55
+ label?: string;
56
+ value?: string;
57
+ placeholder?: string;
58
+ options: PluginDeclarativeSelectOption[];
59
+ disabled?: boolean;
60
+ }
61
+ export interface PluginDeclarativeSwitch {
62
+ type: "switch";
63
+ action: string;
64
+ label: string;
65
+ checked?: boolean;
66
+ disabled?: boolean;
67
+ }
68
+ export interface PluginDeclarativeDivider {
69
+ type: "divider";
70
+ }
71
+ /** Serializable UI rendered exclusively with host-owned components. */
72
+ export type PluginDeclarativeNode = PluginDeclarativeStack | PluginDeclarativeSection | PluginDeclarativeText | PluginDeclarativeButton | PluginDeclarativeInput | PluginDeclarativeTextarea | PluginDeclarativeSelect | PluginDeclarativeSwitch | PluginDeclarativeDivider;
73
+ export interface PluginQuickJsActivityTab {
74
+ id: string;
75
+ label: string;
76
+ view: PluginDeclarativeNode;
77
+ scope_use?: readonly ConversationScenario[];
78
+ initiallyVisible?: boolean;
79
+ /** Defaults to `"warm"`; see PluginActivityTabContribution. */
80
+ retention?: PluginActivityTabRetention;
81
+ }
82
+ export interface PluginDeclarativeActionEvent {
83
+ tabId: string;
84
+ action: string;
85
+ kind: "press" | "change";
86
+ value?: string | number | boolean;
87
+ }
88
+ /**
89
+ * Public contract exposed as the frozen `vetta` global inside a QuickJS plugin.
90
+ * QuickJS entry scripts are classic scripts and must not import host modules.
91
+ */
92
+ export interface PluginQuickJsApi {
93
+ activate(handler: (context: PluginQuickJsContext) => void): void;
94
+ deactivate(handler: () => void): void;
95
+ }
96
+ export interface PluginQuickJsContext {
97
+ plugin: {
98
+ id: string;
99
+ version: string;
100
+ iconUrl?: string;
101
+ };
102
+ permissions: {
103
+ has(permission: string): boolean;
104
+ };
105
+ ui: {
106
+ registerActivityTab(contribution: PluginQuickJsActivityTab): void;
107
+ updateActivityTab(tabId: string, view: PluginDeclarativeNode): void;
108
+ onAction(action: string, handler: (event: PluginDeclarativeActionEvent) => void | Promise<void>): void;
109
+ openActivityTab(tabId: string, options?: {
110
+ width?: number | "max";
111
+ cwd?: string;
112
+ }): void;
113
+ setActivityTabVisible(tabId: string, visible: boolean, options?: {
114
+ cwd?: string;
115
+ }): void;
116
+ notify(options: {
117
+ message: string;
118
+ title?: string;
119
+ variant?: "info" | "success" | "warning" | "error";
120
+ durationMs?: number;
121
+ }): void;
122
+ };
123
+ network: {
124
+ request<T = unknown>(request: PluginNetworkRequest): Promise<PluginNetworkResponse<T>>;
125
+ };
126
+ storage: {
127
+ readJson<T = unknown>(key: string): Promise<T | null>;
128
+ writeJson(key: string, value: unknown): Promise<void>;
129
+ list(prefix?: string): Promise<string[]>;
130
+ readFile(path: string): Promise<string | null>;
131
+ writeFile(path: string, data: string): Promise<void>;
132
+ putBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;
133
+ readBlob(id: string): Promise<PluginStoredBlob | null>;
134
+ getBlobRef(id: string): Promise<PluginStoredBlobRef | null>;
135
+ };
136
+ settings: {
137
+ get<T = unknown>(key: string): T | undefined;
138
+ getAll(): Record<string, unknown>;
139
+ onChange(handler: (values: Record<string, unknown>) => void): void;
140
+ };
141
+ i18n: {
142
+ locale: string;
143
+ t(key: string, params?: Record<string, string | number>): Promise<string>;
144
+ onChange(handler: (locale: string) => void): void;
145
+ };
146
+ }
147
+ //# sourceMappingURL=quickjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickjs.d.ts","sourceRoot":"","sources":["../src/quickjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/F,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACtC,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnC,QAAQ,EAAE,qBAAqB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACxC,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,qBAAqB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IAChD,IAAI,CAAC,EAAE,yBAAyB,CAAC;CACjC;AAED,MAAM,WAAW,uBAAuB;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf,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AAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QAC/C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;QACvD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;KAC5D,CAAC;IACF,QAAQ,EAAE;QACT,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;QAC7C,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;KACnE,CAAC;IACF,IAAI,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1E,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;KAClD,CAAC;CACF","sourcesContent":["import type { ConversationScenario } from \"./scenario.js\";\nimport type { PluginNetworkRequest, PluginNetworkResponse } from \"./network.js\";\nimport type { PluginPutBlobInput, PluginStoredBlob, PluginStoredBlobRef } from \"./storage.js\";\nimport type { PluginActivityTabRetention } from \"./ui.js\";\n\nexport type PluginDeclarativeTextTone = \"default\" | \"muted\" | \"success\" | \"warning\" | \"danger\";\n\nexport interface PluginDeclarativeStack {\n\ttype: \"stack\";\n\tdirection?: \"vertical\" | \"horizontal\";\n\tgap?: \"small\" | \"medium\" | \"large\";\n\tchildren: PluginDeclarativeNode[];\n}\n\nexport interface PluginDeclarativeSection {\n\ttype: \"section\";\n\ttitle?: string;\n\tdescription?: string;\n\tchildren: PluginDeclarativeNode[];\n}\n\nexport interface PluginDeclarativeText {\n\ttype: \"text\";\n\ttext: string;\n\tstyle?: \"body\" | \"heading\" | \"caption\" | \"code\";\n\ttone?: PluginDeclarativeTextTone;\n}\n\nexport interface PluginDeclarativeButton {\n\ttype: \"button\";\n\tlabel: string;\n\taction: string;\n\tvariant?: \"primary\" | \"secondary\" | \"outline\" | \"destructive\";\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeInput {\n\ttype: \"input\";\n\taction: string;\n\tlabel?: string;\n\tvalue?: string;\n\tplaceholder?: string;\n\tinputType?: \"text\" | \"password\" | \"number\";\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeTextarea {\n\ttype: \"textarea\";\n\taction: string;\n\tlabel?: string;\n\tvalue?: string;\n\tplaceholder?: string;\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeSelectOption {\n\tvalue: string;\n\tlabel: string;\n}\n\nexport interface PluginDeclarativeSelect {\n\ttype: \"select\";\n\taction: string;\n\tlabel?: string;\n\tvalue?: string;\n\tplaceholder?: string;\n\toptions: PluginDeclarativeSelectOption[];\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeSwitch {\n\ttype: \"switch\";\n\taction: string;\n\tlabel: string;\n\tchecked?: boolean;\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeDivider {\n\ttype: \"divider\";\n}\n\n/** Serializable UI rendered exclusively with host-owned components. */\nexport type PluginDeclarativeNode =\n\t| PluginDeclarativeStack\n\t| PluginDeclarativeSection\n\t| PluginDeclarativeText\n\t| PluginDeclarativeButton\n\t| PluginDeclarativeInput\n\t| PluginDeclarativeTextarea\n\t| PluginDeclarativeSelect\n\t| PluginDeclarativeSwitch\n\t| PluginDeclarativeDivider;\n\nexport interface PluginQuickJsActivityTab {\n\tid: string;\n\tlabel: string;\n\tview: PluginDeclarativeNode;\n\tscope_use?: readonly ConversationScenario[];\n\tinitiallyVisible?: boolean;\n\t/** Defaults to `\"warm\"`; see PluginActivityTabContribution. */\n\tretention?: PluginActivityTabRetention;\n}\n\nexport interface PluginDeclarativeActionEvent {\n\ttabId: string;\n\taction: string;\n\tkind: \"press\" | \"change\";\n\tvalue?: string | number | boolean;\n}\n\n/**\n * Public contract exposed as the frozen `vetta` global inside a QuickJS plugin.\n * QuickJS entry scripts are classic scripts and must not import host modules.\n */\nexport interface PluginQuickJsApi {\n\tactivate(handler: (context: PluginQuickJsContext) => void): void;\n\tdeactivate(handler: () => void): void;\n}\n\nexport interface PluginQuickJsContext {\n\tplugin: { id: string; version: string; iconUrl?: string };\n\tpermissions: { has(permission: string): boolean };\n\tui: {\n\t\tregisterActivityTab(contribution: PluginQuickJsActivityTab): void;\n\t\tupdateActivityTab(tabId: string, view: PluginDeclarativeNode): void;\n\t\tonAction(action: string, handler: (event: PluginDeclarativeActionEvent) => void | Promise<void>): void;\n\t\topenActivityTab(tabId: string, options?: { width?: number | \"max\"; cwd?: string }): void;\n\t\tsetActivityTabVisible(tabId: string, visible: boolean, options?: { cwd?: string }): void;\n\t\tnotify(options: {\n\t\t\tmessage: string;\n\t\t\ttitle?: string;\n\t\t\tvariant?: \"info\" | \"success\" | \"warning\" | \"error\";\n\t\t\tdurationMs?: number;\n\t\t}): void;\n\t};\n\tnetwork: {\n\t\trequest<T = unknown>(request: PluginNetworkRequest): Promise<PluginNetworkResponse<T>>;\n\t};\n\tstorage: {\n\t\treadJson<T = unknown>(key: string): Promise<T | null>;\n\t\twriteJson(key: string, value: unknown): Promise<void>;\n\t\tlist(prefix?: string): Promise<string[]>;\n\t\treadFile(path: string): Promise<string | null>;\n\t\twriteFile(path: string, data: string): Promise<void>;\n\t\tputBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;\n\t\treadBlob(id: string): Promise<PluginStoredBlob | null>;\n\t\tgetBlobRef(id: string): Promise<PluginStoredBlobRef | null>;\n\t};\n\tsettings: {\n\t\tget<T = unknown>(key: string): T | undefined;\n\t\tgetAll(): Record<string, unknown>;\n\t\tonChange(handler: (values: Record<string, unknown>) => void): void;\n\t};\n\ti18n: {\n\t\tlocale: string;\n\t\tt(key: string, params?: Record<string, string | number>): Promise<string>;\n\t\tonChange(handler: (locale: string) => void): void;\n\t};\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=quickjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickjs.js","sourceRoot":"","sources":["../src/quickjs.ts"],"names":[],"mappings":"","sourcesContent":["import type { ConversationScenario } from \"./scenario.js\";\nimport type { PluginNetworkRequest, PluginNetworkResponse } from \"./network.js\";\nimport type { PluginPutBlobInput, PluginStoredBlob, PluginStoredBlobRef } from \"./storage.js\";\nimport type { PluginActivityTabRetention } from \"./ui.js\";\n\nexport type PluginDeclarativeTextTone = \"default\" | \"muted\" | \"success\" | \"warning\" | \"danger\";\n\nexport interface PluginDeclarativeStack {\n\ttype: \"stack\";\n\tdirection?: \"vertical\" | \"horizontal\";\n\tgap?: \"small\" | \"medium\" | \"large\";\n\tchildren: PluginDeclarativeNode[];\n}\n\nexport interface PluginDeclarativeSection {\n\ttype: \"section\";\n\ttitle?: string;\n\tdescription?: string;\n\tchildren: PluginDeclarativeNode[];\n}\n\nexport interface PluginDeclarativeText {\n\ttype: \"text\";\n\ttext: string;\n\tstyle?: \"body\" | \"heading\" | \"caption\" | \"code\";\n\ttone?: PluginDeclarativeTextTone;\n}\n\nexport interface PluginDeclarativeButton {\n\ttype: \"button\";\n\tlabel: string;\n\taction: string;\n\tvariant?: \"primary\" | \"secondary\" | \"outline\" | \"destructive\";\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeInput {\n\ttype: \"input\";\n\taction: string;\n\tlabel?: string;\n\tvalue?: string;\n\tplaceholder?: string;\n\tinputType?: \"text\" | \"password\" | \"number\";\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeTextarea {\n\ttype: \"textarea\";\n\taction: string;\n\tlabel?: string;\n\tvalue?: string;\n\tplaceholder?: string;\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeSelectOption {\n\tvalue: string;\n\tlabel: string;\n}\n\nexport interface PluginDeclarativeSelect {\n\ttype: \"select\";\n\taction: string;\n\tlabel?: string;\n\tvalue?: string;\n\tplaceholder?: string;\n\toptions: PluginDeclarativeSelectOption[];\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeSwitch {\n\ttype: \"switch\";\n\taction: string;\n\tlabel: string;\n\tchecked?: boolean;\n\tdisabled?: boolean;\n}\n\nexport interface PluginDeclarativeDivider {\n\ttype: \"divider\";\n}\n\n/** Serializable UI rendered exclusively with host-owned components. */\nexport type PluginDeclarativeNode =\n\t| PluginDeclarativeStack\n\t| PluginDeclarativeSection\n\t| PluginDeclarativeText\n\t| PluginDeclarativeButton\n\t| PluginDeclarativeInput\n\t| PluginDeclarativeTextarea\n\t| PluginDeclarativeSelect\n\t| PluginDeclarativeSwitch\n\t| PluginDeclarativeDivider;\n\nexport interface PluginQuickJsActivityTab {\n\tid: string;\n\tlabel: string;\n\tview: PluginDeclarativeNode;\n\tscope_use?: readonly ConversationScenario[];\n\tinitiallyVisible?: boolean;\n\t/** Defaults to `\"warm\"`; see PluginActivityTabContribution. */\n\tretention?: PluginActivityTabRetention;\n}\n\nexport interface PluginDeclarativeActionEvent {\n\ttabId: string;\n\taction: string;\n\tkind: \"press\" | \"change\";\n\tvalue?: string | number | boolean;\n}\n\n/**\n * Public contract exposed as the frozen `vetta` global inside a QuickJS plugin.\n * QuickJS entry scripts are classic scripts and must not import host modules.\n */\nexport interface PluginQuickJsApi {\n\tactivate(handler: (context: PluginQuickJsContext) => void): void;\n\tdeactivate(handler: () => void): void;\n}\n\nexport interface PluginQuickJsContext {\n\tplugin: { id: string; version: string; iconUrl?: string };\n\tpermissions: { has(permission: string): boolean };\n\tui: {\n\t\tregisterActivityTab(contribution: PluginQuickJsActivityTab): void;\n\t\tupdateActivityTab(tabId: string, view: PluginDeclarativeNode): void;\n\t\tonAction(action: string, handler: (event: PluginDeclarativeActionEvent) => void | Promise<void>): void;\n\t\topenActivityTab(tabId: string, options?: { width?: number | \"max\"; cwd?: string }): void;\n\t\tsetActivityTabVisible(tabId: string, visible: boolean, options?: { cwd?: string }): void;\n\t\tnotify(options: {\n\t\t\tmessage: string;\n\t\t\ttitle?: string;\n\t\t\tvariant?: \"info\" | \"success\" | \"warning\" | \"error\";\n\t\t\tdurationMs?: number;\n\t\t}): void;\n\t};\n\tnetwork: {\n\t\trequest<T = unknown>(request: PluginNetworkRequest): Promise<PluginNetworkResponse<T>>;\n\t};\n\tstorage: {\n\t\treadJson<T = unknown>(key: string): Promise<T | null>;\n\t\twriteJson(key: string, value: unknown): Promise<void>;\n\t\tlist(prefix?: string): Promise<string[]>;\n\t\treadFile(path: string): Promise<string | null>;\n\t\twriteFile(path: string, data: string): Promise<void>;\n\t\tputBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;\n\t\treadBlob(id: string): Promise<PluginStoredBlob | null>;\n\t\tgetBlobRef(id: string): Promise<PluginStoredBlobRef | null>;\n\t};\n\tsettings: {\n\t\tget<T = unknown>(key: string): T | undefined;\n\t\tgetAll(): Record<string, unknown>;\n\t\tonChange(handler: (values: Record<string, unknown>) => void): void;\n\t};\n\ti18n: {\n\t\tlocale: string;\n\t\tt(key: string, params?: Record<string, string | number>): Promise<string>;\n\t\tonChange(handler: (locale: string) => void): void;\n\t};\n}\n"]}
package/dist/storage.d.ts CHANGED
@@ -12,6 +12,11 @@ export interface PluginPutBlobInput {
12
12
  data: string;
13
13
  mimeType: string;
14
14
  }
15
+ export interface PluginPutBlobFromFileInput {
16
+ id?: string;
17
+ file: File;
18
+ mimeType: string;
19
+ }
15
20
  /**
16
21
  * Private persistent storage scoped to the current plugin.
17
22
  *
@@ -25,6 +30,8 @@ export interface PluginStorageApi {
25
30
  readFile(path: string): Promise<string | null>;
26
31
  writeFile(path: string, data: string): Promise<void>;
27
32
  putBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;
33
+ /** Copy a user-selected or dropped filesystem file without carrying its bytes through the renderer. */
34
+ putBlobFromFile(input: PluginPutBlobFromFileInput): Promise<PluginStoredBlobRef>;
28
35
  readBlob(id: string): Promise<PluginStoredBlob | null>;
29
36
  getBlobRef(id: string): Promise<PluginStoredBlobRef | null>;
30
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACvD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CAC5D","sourcesContent":["export interface PluginStoredBlobRef {\n\tid: string;\n\turl: string;\n\tmimeType: string;\n}\n\nexport interface PluginStoredBlob {\n\tdata: string;\n\tmimeType: string;\n}\n\nexport interface PluginPutBlobInput {\n\tid?: string;\n\tdata: string;\n\tmimeType: string;\n}\n\n/**\n * Private persistent storage scoped to the current plugin.\n *\n * JSON keys and file paths are relative to the plugin namespace. Blob bytes are\n * base64 encoded at the bridge boundary and exposed through a host media URL.\n */\nexport interface PluginStorageApi {\n\treadJson<T>(key: string): Promise<T | null>;\n\twriteJson(key: string, value: unknown): Promise<void>;\n\tlist(prefix?: string): Promise<string[]>;\n\treadFile(path: string): Promise<string | null>;\n\twriteFile(path: string, data: string): Promise<void>;\n\tputBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;\n\treadBlob(id: string): Promise<PluginStoredBlob | null>;\n\tgetBlobRef(id: string): Promise<PluginStoredBlobRef | null>;\n}\n"]}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,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ata: string;\n\tmimeType: string;\n}\n\nexport interface PluginPutBlobInput {\n\tid?: string;\n\tdata: string;\n\tmimeType: string;\n}\n\nexport interface PluginPutBlobFromFileInput {\n\tid?: string;\n\tfile: File;\n\tmimeType: string;\n}\n\n/**\n * Private persistent storage scoped to the current plugin.\n *\n * JSON keys and file paths are relative to the plugin namespace. Blob bytes are\n * base64 encoded at the bridge boundary and exposed through a host media URL.\n */\nexport interface PluginStorageApi {\n\treadJson<T>(key: string): Promise<T | null>;\n\twriteJson(key: string, value: unknown): Promise<void>;\n\tlist(prefix?: string): Promise<string[]>;\n\treadFile(path: string): Promise<string | null>;\n\twriteFile(path: string, data: string): Promise<void>;\n\tputBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;\n\t/** Copy a user-selected or dropped filesystem file without carrying its bytes through the renderer. */\n\tputBlobFromFile(input: PluginPutBlobFromFileInput): Promise<PluginStoredBlobRef>;\n\treadBlob(id: string): Promise<PluginStoredBlob | null>;\n\tgetBlobRef(id: string): Promise<PluginStoredBlobRef | null>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"","sourcesContent":["export interface PluginStoredBlobRef {\n\tid: string;\n\turl: string;\n\tmimeType: string;\n}\n\nexport interface PluginStoredBlob {\n\tdata: string;\n\tmimeType: string;\n}\n\nexport interface PluginPutBlobInput {\n\tid?: string;\n\tdata: string;\n\tmimeType: string;\n}\n\n/**\n * Private persistent storage scoped to the current plugin.\n *\n * JSON keys and file paths are relative to the plugin namespace. Blob bytes are\n * base64 encoded at the bridge boundary and exposed through a host media URL.\n */\nexport interface PluginStorageApi {\n\treadJson<T>(key: string): Promise<T | null>;\n\twriteJson(key: string, value: unknown): Promise<void>;\n\tlist(prefix?: string): Promise<string[]>;\n\treadFile(path: string): Promise<string | null>;\n\twriteFile(path: string, data: string): Promise<void>;\n\tputBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;\n\treadBlob(id: string): Promise<PluginStoredBlob | null>;\n\tgetBlobRef(id: string): Promise<PluginStoredBlobRef | null>;\n}\n"]}
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"","sourcesContent":["export interface PluginStoredBlobRef {\n\tid: string;\n\turl: string;\n\tmimeType: string;\n}\n\nexport interface PluginStoredBlob {\n\tdata: string;\n\tmimeType: string;\n}\n\nexport interface PluginPutBlobInput {\n\tid?: string;\n\tdata: string;\n\tmimeType: string;\n}\n\nexport interface PluginPutBlobFromFileInput {\n\tid?: string;\n\tfile: File;\n\tmimeType: string;\n}\n\n/**\n * Private persistent storage scoped to the current plugin.\n *\n * JSON keys and file paths are relative to the plugin namespace. Blob bytes are\n * base64 encoded at the bridge boundary and exposed through a host media URL.\n */\nexport interface PluginStorageApi {\n\treadJson<T>(key: string): Promise<T | null>;\n\twriteJson(key: string, value: unknown): Promise<void>;\n\tlist(prefix?: string): Promise<string[]>;\n\treadFile(path: string): Promise<string | null>;\n\twriteFile(path: string, data: string): Promise<void>;\n\tputBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;\n\t/** Copy a user-selected or dropped filesystem file without carrying its bytes through the renderer. */\n\tputBlobFromFile(input: PluginPutBlobFromFileInput): Promise<PluginStoredBlobRef>;\n\treadBlob(id: string): Promise<PluginStoredBlob | null>;\n\tgetBlobRef(id: string): Promise<PluginStoredBlobRef | null>;\n}\n"]}