@vetta-org/plugin-sdk 0.1.1 → 0.3.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.
- package/dist/activity-tab.d.ts +2 -0
- package/dist/activity-tab.d.ts.map +1 -1
- package/dist/activity-tab.js +1 -1
- package/dist/activity-tab.js.map +1 -1
- package/dist/agent.d.ts +148 -4
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +14 -1
- package/dist/agent.js.map +1 -1
- package/dist/ai.d.ts +106 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +2 -0
- package/dist/ai.js.map +1 -0
- package/dist/app-actions.d.ts +9 -1
- package/dist/app-actions.d.ts.map +1 -1
- package/dist/app-actions.js.map +1 -1
- package/dist/artifacts.d.ts +31 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +2 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/browser.d.ts +119 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -0
- package/dist/capture.d.ts +64 -0
- package/dist/capture.d.ts.map +1 -0
- package/dist/capture.js +2 -0
- package/dist/capture.js.map +1 -0
- package/dist/cli-provider.d.ts +18 -0
- package/dist/cli-provider.d.ts.map +1 -0
- package/dist/cli-provider.js +2 -0
- package/dist/cli-provider.js.map +1 -0
- package/dist/context.d.ts +59 -7
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/conversation.d.ts +66 -2
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/gateway.d.ts +37 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +14 -0
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +26 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +34 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +2 -0
- package/dist/jobs.js.map +1 -0
- package/dist/manifest-schema.d.ts +637 -0
- package/dist/manifest-schema.d.ts.map +1 -0
- package/dist/manifest-schema.js +251 -0
- package/dist/manifest-schema.js.map +1 -0
- package/dist/manifest.d.ts +21 -55
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +468 -1
- package/dist/manifest.js.map +1 -1
- package/dist/media.d.ts +193 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +11 -0
- package/dist/media.js.map +1 -0
- package/dist/models.d.ts +35 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +2 -0
- package/dist/models.js.map +1 -0
- package/dist/network.d.ts +2 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js.map +1 -1
- package/dist/npm-package.d.ts +17 -0
- package/dist/npm-package.d.ts.map +1 -0
- package/dist/npm-package.js +38 -0
- package/dist/npm-package.js.map +1 -0
- package/dist/ocr.d.ts +78 -0
- package/dist/ocr.d.ts.map +1 -0
- package/dist/ocr.js +2 -0
- package/dist/ocr.js.map +1 -0
- package/dist/official.d.ts +219 -10
- package/dist/official.d.ts.map +1 -1
- package/dist/official.js.map +1 -1
- package/dist/permissions.d.ts +2 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +62 -1
- package/dist/permissions.js.map +1 -1
- package/dist/prompt-attachment.d.ts +30 -6
- package/dist/prompt-attachment.d.ts.map +1 -1
- package/dist/prompt-attachment.js +35 -1
- package/dist/prompt-attachment.js.map +1 -1
- package/dist/quickjs.d.ts +147 -0
- package/dist/quickjs.d.ts.map +1 -0
- package/dist/quickjs.js +2 -0
- package/dist/quickjs.js.map +1 -0
- package/dist/secrets.d.ts +27 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +2 -0
- package/dist/secrets.js.map +1 -0
- package/dist/service-provider.d.ts +62 -0
- package/dist/service-provider.d.ts.map +1 -0
- package/dist/service-provider.js +2 -0
- package/dist/service-provider.js.map +1 -0
- package/dist/storage.d.ts +46 -6
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +8 -1
- package/dist/storage.js.map +1 -1
- package/dist/ui.d.ts +341 -22
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +22 -2
- package/src/tailwind-theme.css +30 -0
- package/dist/settings.d.ts +0 -13
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js +0 -2
- package/dist/settings.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,k1CA6DrB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC","sourcesContent":["export const PLUGIN_PERMISSIONS = [\n\t\"ui.slot.global\",\n\t\"ui.slot.ability-detail\",\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.slot.new-session-context\",\n\t\"ui.shortcuts.register\",\n\t\"conversation.draft.read\",\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\"models.manage\",\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\"ai.ocr.recognize\",\n\t\"ai.ocr.provider.register\",\n\t\"settings.read\",\n\t\"settings.write\",\n\t\"secrets.read\",\n\t\"secrets.write\",\n\t\"shell.openExternal\",\n] as const;\n\nexport type PluginPermission = (typeof PLUGIN_PERMISSIONS)[number];\n"]}
|
package/dist/permissions.js
CHANGED
|
@@ -1,2 +1,63 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const PLUGIN_PERMISSIONS = [
|
|
2
|
+
"ui.slot.global",
|
|
3
|
+
"ui.slot.ability-detail",
|
|
4
|
+
"ui.slot.file-preview",
|
|
5
|
+
"ui.slot.activity-tab",
|
|
6
|
+
"ui.slot.input-action",
|
|
7
|
+
"ui.slot.message",
|
|
8
|
+
"ui.slot.tool-call",
|
|
9
|
+
"ui.slot.turn-card",
|
|
10
|
+
"ui.slot.workspace-view",
|
|
11
|
+
"ui.slot.new-session-context",
|
|
12
|
+
"ui.shortcuts.register",
|
|
13
|
+
"conversation.draft.read",
|
|
14
|
+
"ui.file-explorer.decorations",
|
|
15
|
+
"ui.file-explorer.context-menu",
|
|
16
|
+
"ui.file-explorer.toolbar",
|
|
17
|
+
"workspace.read",
|
|
18
|
+
"agent.session.read",
|
|
19
|
+
"agent.session.write",
|
|
20
|
+
"agent.command.run",
|
|
21
|
+
"agent.command.spawn",
|
|
22
|
+
"capture.offscreen",
|
|
23
|
+
"browser.read",
|
|
24
|
+
"browser.open",
|
|
25
|
+
"browser.interact",
|
|
26
|
+
"browser.profile.persist",
|
|
27
|
+
"browser.attach",
|
|
28
|
+
"browser.runtime.manage",
|
|
29
|
+
"agent.systemPrompt.read",
|
|
30
|
+
"agent.systemPrompt.write",
|
|
31
|
+
"agent.systemPrompt.fullControl",
|
|
32
|
+
"agent.skills.control",
|
|
33
|
+
"agent.mcp.control",
|
|
34
|
+
"agent.tools.control",
|
|
35
|
+
"agent.tools.register",
|
|
36
|
+
"agent.toolHandler.execute",
|
|
37
|
+
"agent.hooks.register",
|
|
38
|
+
"agent.hookHandler.execute",
|
|
39
|
+
"agent.state.read",
|
|
40
|
+
"agent.state.write",
|
|
41
|
+
"agent.continuation.register",
|
|
42
|
+
"agent.runtime.configure",
|
|
43
|
+
"app.actions.register",
|
|
44
|
+
"app.actionHandler.execute",
|
|
45
|
+
"ai.models.list",
|
|
46
|
+
"ai.complete",
|
|
47
|
+
"models.manage",
|
|
48
|
+
"fs.read",
|
|
49
|
+
"fs.write",
|
|
50
|
+
"network.fetch",
|
|
51
|
+
"storage.read",
|
|
52
|
+
"storage.write",
|
|
53
|
+
"media.generate",
|
|
54
|
+
"media.provider.register",
|
|
55
|
+
"ai.ocr.recognize",
|
|
56
|
+
"ai.ocr.provider.register",
|
|
57
|
+
"settings.read",
|
|
58
|
+
"settings.write",
|
|
59
|
+
"secrets.read",
|
|
60
|
+
"secrets.write",
|
|
61
|
+
"shell.openExternal",
|
|
62
|
+
];
|
|
2
63
|
//# sourceMappingURL=permissions.js.map
|
package/dist/permissions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"","sourcesContent":["export
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,gBAAgB;IAChB,wBAAwB;IACxB,sBAAsB;IACtB,sBAAsB;IACtB,sBAAsB;IACtB,iBAAiB;IACjB,mBAAmB;IACnB,mBAAmB;IACnB,wBAAwB;IACxB,6BAA6B;IAC7B,uBAAuB;IACvB,yBAAyB;IACzB,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,eAAe;IACf,SAAS;IACT,UAAU;IACV,eAAe;IACf,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,yBAAyB;IACzB,kBAAkB;IAClB,0BAA0B;IAC1B,eAAe;IACf,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,oBAAoB;CACX,CAAC","sourcesContent":["export const PLUGIN_PERMISSIONS = [\n\t\"ui.slot.global\",\n\t\"ui.slot.ability-detail\",\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.slot.new-session-context\",\n\t\"ui.shortcuts.register\",\n\t\"conversation.draft.read\",\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\"models.manage\",\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\"ai.ocr.recognize\",\n\t\"ai.ocr.provider.register\",\n\t\"settings.read\",\n\t\"settings.write\",\n\t\"secrets.read\",\n\t\"secrets.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
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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":"
|
|
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
|
-
|
|
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":["
|
|
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,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;IACrD,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACrC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;CACnD,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAkBF;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACxC,OAAsC,EACN;IAChC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,yBAAyB,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvF,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,UAAU,GAAG,+BAA+B,EAAE,CAAC;QACvF,MAAM,IAAI,KAAK,CAAC,iCAAiC,+BAA+B,QAAQ,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,OAAO,CAAC;AAAA,CACf;AAED,SAAS,WAAW,CAAC,KAAc,EAAyC;IAC3E,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3F,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,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,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E,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"]}
|
package/dist/quickjs.js
ADDED
|
@@ -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"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Disposable } from "./disposable.js";
|
|
2
|
+
/**
|
|
3
|
+
* Encrypted, per-plugin secret storage (`secrets.read` / `secrets.write`).
|
|
4
|
+
*
|
|
5
|
+
* Values are kept in the host credential vault rather than the plugin's private
|
|
6
|
+
* JSON storage, so API keys and tokens stay encrypted at rest. Ownership is
|
|
7
|
+
* derived from the calling plugin's capability session: a plugin can only read
|
|
8
|
+
* and write its own secrets, never another plugin's.
|
|
9
|
+
*
|
|
10
|
+
* Use it for credentials only. Ordinary configuration belongs in a plugin file
|
|
11
|
+
* such as `settings.json`, serialized by the plugin and validated in its own
|
|
12
|
+
* workspace view (ADR-0105).
|
|
13
|
+
*/
|
|
14
|
+
export interface PluginSecretsApi {
|
|
15
|
+
/** Resolved secret, or `undefined` when unset or the vault is unavailable. */
|
|
16
|
+
get(key: string): Promise<string | undefined>;
|
|
17
|
+
/** Whether a value is stored, without decrypting it. */
|
|
18
|
+
has(key: string): Promise<boolean>;
|
|
19
|
+
/** Stored key names only — never the values. */
|
|
20
|
+
keys(): Promise<string[]>;
|
|
21
|
+
/** Store a secret. Writing an empty string deletes it. */
|
|
22
|
+
set(key: string, value: string): Promise<void>;
|
|
23
|
+
delete(key: string): Promise<void>;
|
|
24
|
+
/** Fired when this plugin's secrets change, with the affected key names. */
|
|
25
|
+
onChange(listener: (keys: readonly string[]) => void): Disposable;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAChC,8EAA8E;IAC9E,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9C,wDAAwD;IACxD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,kDAAgD;IAChD,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1B,0DAA0D;IAC1D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,GAAG,UAAU,CAAC;CAClE","sourcesContent":["import type { Disposable } from \"./disposable.js\";\n\n/**\n * Encrypted, per-plugin secret storage (`secrets.read` / `secrets.write`).\n *\n * Values are kept in the host credential vault rather than the plugin's private\n * JSON storage, so API keys and tokens stay encrypted at rest. Ownership is\n * derived from the calling plugin's capability session: a plugin can only read\n * and write its own secrets, never another plugin's.\n *\n * Use it for credentials only. Ordinary configuration belongs in a plugin file\n * such as `settings.json`, serialized by the plugin and validated in its own\n * workspace view (ADR-0105).\n */\nexport interface PluginSecretsApi {\n\t/** Resolved secret, or `undefined` when unset or the vault is unavailable. */\n\tget(key: string): Promise<string | undefined>;\n\t/** Whether a value is stored, without decrypting it. */\n\thas(key: string): Promise<boolean>;\n\t/** Stored key names only — never the values. */\n\tkeys(): Promise<string[]>;\n\t/** Store a secret. Writing an empty string deletes it. */\n\tset(key: string, value: string): Promise<void>;\n\tdelete(key: string): Promise<void>;\n\t/** Fired when this plugin's secrets change, with the affected key names. */\n\tonChange(listener: (keys: readonly string[]) => void): Disposable;\n}\n"]}
|
package/dist/secrets.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"","sourcesContent":["import type { Disposable } from \"./disposable.js\";\n\n/**\n * Encrypted, per-plugin secret storage (`secrets.read` / `secrets.write`).\n *\n * Values are kept in the host credential vault rather than the plugin's private\n * JSON storage, so API keys and tokens stay encrypted at rest. Ownership is\n * derived from the calling plugin's capability session: a plugin can only read\n * and write its own secrets, never another plugin's.\n *\n * Use it for credentials only. Ordinary configuration belongs in a plugin file\n * such as `settings.json`, serialized by the plugin and validated in its own\n * workspace view (ADR-0105).\n */\nexport interface PluginSecretsApi {\n\t/** Resolved secret, or `undefined` when unset or the vault is unavailable. */\n\tget(key: string): Promise<string | undefined>;\n\t/** Whether a value is stored, without decrypting it. */\n\thas(key: string): Promise<boolean>;\n\t/** Stored key names only — never the values. */\n\tkeys(): Promise<string[]>;\n\t/** Store a secret. Writing an empty string deletes it. */\n\tset(key: string, value: string): Promise<void>;\n\tdelete(key: string): Promise<void>;\n\t/** Fired when this plugin's secrets change, with the affected key names. */\n\tonChange(listener: (keys: readonly string[]) => void): Disposable;\n}\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Disposable } from "./disposable.js";
|
|
2
|
+
export type PluginServicePhase = "disabled" | "installing" | "starting" | "ready" | "stopping" | "stopped" | "failed";
|
|
3
|
+
export interface PluginServiceStatus {
|
|
4
|
+
serviceId: string;
|
|
5
|
+
phase: PluginServicePhase;
|
|
6
|
+
version: string;
|
|
7
|
+
installed: boolean;
|
|
8
|
+
message?: string;
|
|
9
|
+
recentOutput: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PluginServiceConnection {
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
/** Present only when the caller explicitly names a credential declared by its own service. */
|
|
14
|
+
credential?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PluginServiceHostPlatform {
|
|
17
|
+
tag: `${"win32" | "darwin" | "linux"}-${"x64" | "arm64"}`;
|
|
18
|
+
}
|
|
19
|
+
export interface PluginServiceArtifactPayload {
|
|
20
|
+
/** Must match one destination declared for the current platform in plugin.json. */
|
|
21
|
+
destination: string;
|
|
22
|
+
/** Base64-encoded archive bytes downloaded and verified by the plugin. */
|
|
23
|
+
data: string;
|
|
24
|
+
}
|
|
25
|
+
export interface PluginServiceRequest {
|
|
26
|
+
/** Root-relative path on this plugin-owned loopback service. Absolute URLs are rejected. */
|
|
27
|
+
path: string;
|
|
28
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
29
|
+
credentialId?: string;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
body?: unknown;
|
|
32
|
+
responseType?: "json" | "text";
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface PluginServiceResponse<T = unknown> {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
status: number;
|
|
38
|
+
statusText: string;
|
|
39
|
+
headers: Record<string, string>;
|
|
40
|
+
body: T;
|
|
41
|
+
}
|
|
42
|
+
export type PluginServiceDataEncoding = "utf8" | "base64";
|
|
43
|
+
export interface PluginServiceApi {
|
|
44
|
+
/** Host platform used by the plugin to select its own runtime download. */
|
|
45
|
+
getPlatform(): Promise<PluginServiceHostPlatform>;
|
|
46
|
+
getStatus(serviceId: string): Promise<PluginServiceStatus>;
|
|
47
|
+
/** Atomically deploy plugin-downloaded artifacts after host-side safety verification. */
|
|
48
|
+
install(serviceId: string, artifacts: PluginServiceArtifactPayload[]): Promise<PluginServiceStatus>;
|
|
49
|
+
start(serviceId: string): Promise<PluginServiceStatus>;
|
|
50
|
+
stop(serviceId: string): Promise<PluginServiceStatus>;
|
|
51
|
+
restart(serviceId: string): Promise<PluginServiceStatus>;
|
|
52
|
+
connection(serviceId: string, credentialId?: string): Promise<PluginServiceConnection>;
|
|
53
|
+
request<T = unknown>(serviceId: string, request: PluginServiceRequest): Promise<PluginServiceResponse<T>>;
|
|
54
|
+
/** Read a file from this service's private data directory. Paths are root-relative. */
|
|
55
|
+
readDataFile(serviceId: string, path: string, encoding?: PluginServiceDataEncoding): Promise<string | null>;
|
|
56
|
+
/** Atomically replace a file in this service's private data directory. */
|
|
57
|
+
writeDataFile(serviceId: string, path: string, data: string, encoding?: PluginServiceDataEncoding): Promise<void>;
|
|
58
|
+
/** Report semantic readiness after the service's domain data has finished loading. */
|
|
59
|
+
reportReady(serviceId: string, ready: boolean): Promise<PluginServiceStatus>;
|
|
60
|
+
onStatusChange(listener: (status: PluginServiceStatus) => void): Disposable;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=service-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-provider.d.ts","sourceRoot":"","sources":["../src/service-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAC3B,UAAU,GACV,YAAY,GACZ,UAAU,GACV,OAAO,GACP,UAAU,GACV,SAAS,GACT,QAAQ,CAAC;AAEZ,MAAM,WAAW,mBAAmB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,MAA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EAAE,MAAM,EAAE,SAAS,EAAE,4BAA4B,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpG,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACvD,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACtD,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACzD,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACvF,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1G,uFAAuF;IACvF,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5G,0EAA0E;IAC1E,aAAa,CACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,sFAAsF;IACtF,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC7E,cAAc,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,GAAG,UAAU,CAAC;CAC5E","sourcesContent":["import type { Disposable } from \"./disposable.js\";\n\nexport type PluginServicePhase =\n\t| \"disabled\"\n\t| \"installing\"\n\t| \"starting\"\n\t| \"ready\"\n\t| \"stopping\"\n\t| \"stopped\"\n\t| \"failed\";\n\nexport interface PluginServiceStatus {\n\tserviceId: string;\n\tphase: PluginServicePhase;\n\tversion: string;\n\tinstalled: boolean;\n\tmessage?: string;\n\trecentOutput: string;\n}\n\nexport interface PluginServiceConnection {\n\tbaseUrl: string;\n\t/** Present only when the caller explicitly names a credential declared by its own service. */\n\tcredential?: string;\n}\n\nexport interface PluginServiceHostPlatform {\n\ttag: `${\"win32\" | \"darwin\" | \"linux\"}-${\"x64\" | \"arm64\"}`;\n}\n\nexport interface PluginServiceArtifactPayload {\n\t/** Must match one destination declared for the current platform in plugin.json. */\n\tdestination: string;\n\t/** Base64-encoded archive bytes downloaded and verified by the plugin. */\n\tdata: string;\n}\n\nexport interface PluginServiceRequest {\n\t/** Root-relative path on this plugin-owned loopback service. Absolute URLs are rejected. */\n\tpath: string;\n\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\tcredentialId?: string;\n\theaders?: Record<string, string>;\n\tbody?: unknown;\n\tresponseType?: \"json\" | \"text\";\n\ttimeoutMs?: number;\n}\n\nexport interface PluginServiceResponse<T = unknown> {\n\tok: boolean;\n\tstatus: number;\n\tstatusText: string;\n\theaders: Record<string, string>;\n\tbody: T;\n}\n\nexport type PluginServiceDataEncoding = \"utf8\" | \"base64\";\n\nexport interface PluginServiceApi {\n\t/** Host platform used by the plugin to select its own runtime download. */\n\tgetPlatform(): Promise<PluginServiceHostPlatform>;\n\tgetStatus(serviceId: string): Promise<PluginServiceStatus>;\n\t/** Atomically deploy plugin-downloaded artifacts after host-side safety verification. */\n\tinstall(serviceId: string, artifacts: PluginServiceArtifactPayload[]): Promise<PluginServiceStatus>;\n\tstart(serviceId: string): Promise<PluginServiceStatus>;\n\tstop(serviceId: string): Promise<PluginServiceStatus>;\n\trestart(serviceId: string): Promise<PluginServiceStatus>;\n\tconnection(serviceId: string, credentialId?: string): Promise<PluginServiceConnection>;\n\trequest<T = unknown>(serviceId: string, request: PluginServiceRequest): Promise<PluginServiceResponse<T>>;\n\t/** Read a file from this service's private data directory. Paths are root-relative. */\n\treadDataFile(serviceId: string, path: string, encoding?: PluginServiceDataEncoding): Promise<string | null>;\n\t/** Atomically replace a file in this service's private data directory. */\n\twriteDataFile(\n\t\tserviceId: string,\n\t\tpath: string,\n\t\tdata: string,\n\t\tencoding?: PluginServiceDataEncoding,\n\t): Promise<void>;\n\t/** Report semantic readiness after the service's domain data has finished loading. */\n\treportReady(serviceId: string, ready: boolean): Promise<PluginServiceStatus>;\n\tonStatusChange(listener: (status: PluginServiceStatus) => void): Disposable;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-provider.js","sourceRoot":"","sources":["../src/service-provider.ts"],"names":[],"mappings":"","sourcesContent":["import type { Disposable } from \"./disposable.js\";\n\nexport type PluginServicePhase =\n\t| \"disabled\"\n\t| \"installing\"\n\t| \"starting\"\n\t| \"ready\"\n\t| \"stopping\"\n\t| \"stopped\"\n\t| \"failed\";\n\nexport interface PluginServiceStatus {\n\tserviceId: string;\n\tphase: PluginServicePhase;\n\tversion: string;\n\tinstalled: boolean;\n\tmessage?: string;\n\trecentOutput: string;\n}\n\nexport interface PluginServiceConnection {\n\tbaseUrl: string;\n\t/** Present only when the caller explicitly names a credential declared by its own service. */\n\tcredential?: string;\n}\n\nexport interface PluginServiceHostPlatform {\n\ttag: `${\"win32\" | \"darwin\" | \"linux\"}-${\"x64\" | \"arm64\"}`;\n}\n\nexport interface PluginServiceArtifactPayload {\n\t/** Must match one destination declared for the current platform in plugin.json. */\n\tdestination: string;\n\t/** Base64-encoded archive bytes downloaded and verified by the plugin. */\n\tdata: string;\n}\n\nexport interface PluginServiceRequest {\n\t/** Root-relative path on this plugin-owned loopback service. Absolute URLs are rejected. */\n\tpath: string;\n\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\tcredentialId?: string;\n\theaders?: Record<string, string>;\n\tbody?: unknown;\n\tresponseType?: \"json\" | \"text\";\n\ttimeoutMs?: number;\n}\n\nexport interface PluginServiceResponse<T = unknown> {\n\tok: boolean;\n\tstatus: number;\n\tstatusText: string;\n\theaders: Record<string, string>;\n\tbody: T;\n}\n\nexport type PluginServiceDataEncoding = \"utf8\" | \"base64\";\n\nexport interface PluginServiceApi {\n\t/** Host platform used by the plugin to select its own runtime download. */\n\tgetPlatform(): Promise<PluginServiceHostPlatform>;\n\tgetStatus(serviceId: string): Promise<PluginServiceStatus>;\n\t/** Atomically deploy plugin-downloaded artifacts after host-side safety verification. */\n\tinstall(serviceId: string, artifacts: PluginServiceArtifactPayload[]): Promise<PluginServiceStatus>;\n\tstart(serviceId: string): Promise<PluginServiceStatus>;\n\tstop(serviceId: string): Promise<PluginServiceStatus>;\n\trestart(serviceId: string): Promise<PluginServiceStatus>;\n\tconnection(serviceId: string, credentialId?: string): Promise<PluginServiceConnection>;\n\trequest<T = unknown>(serviceId: string, request: PluginServiceRequest): Promise<PluginServiceResponse<T>>;\n\t/** Read a file from this service's private data directory. Paths are root-relative. */\n\treadDataFile(serviceId: string, path: string, encoding?: PluginServiceDataEncoding): Promise<string | null>;\n\t/** Atomically replace a file in this service's private data directory. */\n\twriteDataFile(\n\t\tserviceId: string,\n\t\tpath: string,\n\t\tdata: string,\n\t\tencoding?: PluginServiceDataEncoding,\n\t): Promise<void>;\n\t/** Report semantic readiness after the service's domain data has finished loading. */\n\treportReady(serviceId: string, ready: boolean): Promise<PluginServiceStatus>;\n\tonStatusChange(listener: (status: PluginServiceStatus) => void): Disposable;\n}\n"]}
|
package/dist/storage.d.ts
CHANGED
|
@@ -12,20 +12,60 @@ 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
|
+
}
|
|
20
|
+
export type PluginStorageEncoding = "utf8" | "base64";
|
|
21
|
+
export interface PluginStorageWrite {
|
|
22
|
+
path: string;
|
|
23
|
+
data: string;
|
|
24
|
+
encoding: PluginStorageEncoding;
|
|
25
|
+
}
|
|
26
|
+
export type PluginStorageChange = ({
|
|
27
|
+
type: "write";
|
|
28
|
+
} & PluginStorageWrite) | {
|
|
29
|
+
type: "remove";
|
|
30
|
+
path: string;
|
|
31
|
+
};
|
|
32
|
+
export interface PluginStorageCommitOptions {
|
|
33
|
+
expectedRevision?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface PluginStorageCommitResult {
|
|
36
|
+
revision: string;
|
|
37
|
+
changedPaths: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface PluginStorageSnapshot {
|
|
40
|
+
revision: string;
|
|
41
|
+
files: Record<string, string | null>;
|
|
42
|
+
}
|
|
15
43
|
/**
|
|
16
44
|
* Private persistent storage scoped to the current plugin.
|
|
17
45
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
46
|
+
* Paths are relative to the plugin namespace and are never given an implicit
|
|
47
|
+
* extension. Text and bytes use an explicit encoding at the bridge boundary;
|
|
48
|
+
* JSON is a plugin-level serialization choice. `commit()` publishes all file
|
|
49
|
+
* changes as one revision, and `readSnapshot()` reads several paths from the
|
|
50
|
+
* same revision. Blob bytes remain a separate media resource API.
|
|
20
51
|
*/
|
|
21
52
|
export interface PluginStorageApi {
|
|
22
|
-
readJson<T>(key: string): Promise<T | null>;
|
|
23
|
-
writeJson(key: string, value: unknown): Promise<void>;
|
|
24
53
|
list(prefix?: string): Promise<string[]>;
|
|
25
|
-
readFile(path: string): Promise<string | null>;
|
|
26
|
-
writeFile(path: string, data: string): Promise<
|
|
54
|
+
readFile(path: string, encoding: PluginStorageEncoding): Promise<string | null>;
|
|
55
|
+
writeFile(path: string, data: string, encoding: PluginStorageEncoding): Promise<PluginStorageCommitResult>;
|
|
56
|
+
/** Atomically publish multiple private-file writes/removals as one plugin-scoped revision. */
|
|
57
|
+
commit(changes: readonly PluginStorageChange[], options?: PluginStorageCommitOptions): Promise<PluginStorageCommitResult>;
|
|
58
|
+
/** Read several private files from one committed revision. */
|
|
59
|
+
readSnapshot(paths: readonly string[], encoding: PluginStorageEncoding): Promise<PluginStorageSnapshot>;
|
|
27
60
|
putBlob(input: PluginPutBlobInput): Promise<PluginStoredBlobRef>;
|
|
61
|
+
/** Copy a user-selected or dropped filesystem file without carrying its bytes through the renderer. */
|
|
62
|
+
putBlobFromFile(input: PluginPutBlobFromFileInput): Promise<PluginStoredBlobRef>;
|
|
28
63
|
readBlob(id: string): Promise<PluginStoredBlob | null>;
|
|
29
64
|
getBlobRef(id: string): Promise<PluginStoredBlobRef | null>;
|
|
65
|
+
/** Permanently delete one blob owned by this plugin namespace. */
|
|
66
|
+
deleteBlob(id: string): Promise<void>;
|
|
30
67
|
}
|
|
68
|
+
/** Optional JSON convenience helpers. The storage contract itself remains file/bytes based. */
|
|
69
|
+
export declare function readJsonFile<T>(storage: PluginStorageApi, path: string): Promise<T | null>;
|
|
70
|
+
export declare function writeJsonFile(storage: PluginStorageApi, path: string, value: unknown): Promise<PluginStorageCommitResult>;
|
|
31
71
|
//# sourceMappingURL=storage.d.ts.map
|