@vetta-org/plugin-sdk 0.1.0 → 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.
- 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 +158 -2
- 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 +93 -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 -0
- 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/command.d.ts +43 -0
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js.map +1 -1
- package/dist/context.d.ts +48 -5
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/conversation.d.ts +67 -2
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/file-explorer.d.ts +87 -0
- package/dist/file-explorer.d.ts.map +1 -0
- package/dist/file-explorer.js +2 -0
- package/dist/file-explorer.js.map +1 -0
- package/dist/fs.d.ts +16 -0
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.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 +24 -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 +234 -0
- package/dist/manifest-schema.d.ts.map +1 -0
- package/dist/manifest-schema.js +145 -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 +342 -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/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/official.d.ts +218 -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 +54 -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/shortcuts.d.ts +60 -0
- package/dist/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts.js +34 -0
- package/dist/shortcuts.js.map +1 -0
- package/dist/storage.d.ts +7 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/ui.d.ts +246 -13
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +21 -2
- package/src/tailwind-theme.css +30 -0
package/dist/official.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"official.js","sourceRoot":"","sources":["../src/official.ts"],"names":[],"mappings":"","sourcesContent":["export interface PluginOfficialGeneralSettings {\n\tworkspacePath: string;\n\tdefaultExecutionMode?: \"sandbox\" | \"full-access\";\n\tnotificationsEnabled: boolean;\n\tdebugMode: boolean;\n\tsandbox: unknown;\n}\n\nexport type PluginOfficialGeneralSettingsUpdate =\n\t| { operation: \"set-notifications\"; enabled: boolean }\n\t| { operation: \"set-execution-mode\"; mode: \"sandbox\" | \"full-access\" }\n\t| { operation: \"set-workspace\"; path: string };\n\nexport interface PluginOfficialExperimentalSettings {\n\tvettaCli: boolean;\n\tpromptPrediction: boolean;\n\tagentSkills: boolean;\n}\n\nexport interface PluginOfficialDownloadItem {\n\tid: string;\n\turl: string;\n\tfilename: string;\n\tpath: string;\n\ttotalBytes: number;\n\treceivedBytes: number;\n\tstatus: \"queued\" | \"downloading\" | \"paused\" | \"completed\" | \"failed\" | \"canceled\";\n\terror?: string;\n\tcreatedAt: number;\n\tcompletedAt?: number;\n\tspeedBytesPerSec?: number;\n}\n\nexport interface PluginOfficialUpdaterState {\n\tphase: \"idle\" | \"checking\" | \"available\" | \"downloading\" | \"ready\" | \"installing\" | \"error\";\n\tcurrentVersion: string;\n\tlatestVersion?: string;\n\treleaseNote?: string;\n\tprogress?: number;\n\tdownloadedBytes?: number;\n\ttotalBytes?: number;\n\tassetFileName?: string;\n\terror?: string;\n}\n\nexport type PluginOfficialWebhookKind = \"feishu\" | \"dingtalk\";\n\nexport interface PluginOfficialWebhookEndpoint {\n\tid: string;\n\tkind: PluginOfficialWebhookKind;\n\tname: string;\n\tenabled: boolean;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\turlMask?: string;\n\thasSignSecret?: boolean;\n}\n\nexport interface PluginOfficialWebhookProvider {\n\tkind: PluginOfficialWebhookKind;\n\tdisplayName: string;\n\ticonClass?: string;\n}\n\nexport interface PluginOfficialWebhookCreateInput {\n\tkind: PluginOfficialWebhookKind;\n\tname: string;\n\twebhookUrl: string;\n\tsignSecret?: string;\n\tenabled?: boolean;\n}\n\nexport interface PluginOfficialWebhookUpdateInput {\n\tname?: string;\n\tenabled?: boolean;\n\twebhookUrl?: string;\n\tsignSecret?: string;\n}\n\nexport interface PluginOfficialWebhookMessage {\n\ttitle?: string;\n\ttext: string;\n\tlevel?: \"info\" | \"warn\" | \"error\" | \"success\";\n}\n\nexport interface PluginOfficialWebhookSendResult {\n\tok: boolean;\n\terror?: string;\n}\n\nexport interface PluginOfficialSkillInfo {\n\tname: string;\n\talias?: string;\n\tdescription: string;\n\tsource: string;\n\ttype: \"skill\" | \"scene\";\n}\n\nexport type PluginOfficialInstalledSkill = {\n\tname: string;\n\tversion: string;\n\tinstalledAt: string;\n\tsource: \"market\" | \"custom\";\n\tenabled: boolean;\n\ttype?: \"skill\" | \"scene\";\n\talias?: string;\n\tmarketDescription?: string;\n\tdescription?: string;\n};\n\nexport interface PluginOfficialShortcutBinding {\n\tid: string;\n\tdefaultShortcut: string;\n\tshortcut: string;\n\tisDefault: boolean;\n}\n\nexport interface PluginOfficialQuickPanelSettings {\n\ttrigger: \"none\" | \"mod\" | \"alt\" | \"shift\";\n\tpostSendBehavior: \"foreground\" | \"background\";\n}\n\nexport interface PluginOfficialImStatus {\n\tenabled: boolean;\n\ttransport: string;\n\tagentModel: { provider: string; model: string; reasoningLevel?: string } | null;\n\twechatBound: boolean;\n\tfeishuAppId: string | null;\n\truntime: unknown;\n}\n\nexport interface PluginOfficialImLog {\n\tlevel: string;\n\tmsg: string;\n\ttime: string;\n\tfields?: Record<string, unknown>;\n}\n\nexport interface PluginOfficialMcpServerSummary {\n\tname: string;\n\ttype: \"http\" | \"stdio\";\n\tdisabled: boolean;\n\tcommand?: string;\n\turl?: string;\n}\n\nexport interface PluginOfficialMcpServerDetail {\n\tname: string;\n\ttype?: \"http\" | \"stdio\";\n\tcommand?: string;\n\targs?: string[];\n\tenv?: Record<string, string>;\n\tcwd?: string;\n\turl?: string;\n\theaders?: Record<string, string>;\n\tdisabled?: boolean;\n\tautoApprove?: string[];\n\tstartupTimeout?: number;\n\tdebug?: boolean;\n}\n\nexport type PluginOfficialMcpUpsertData =\n\t| {\n\t\t\ttype?: \"stdio\";\n\t\t\tcommand?: string;\n\t\t\targs?: string[];\n\t\t\tenv?: Record<string, string>;\n\t\t\tcwd?: string;\n\t\t\tdisabled?: boolean;\n\t\t\tautoApprove?: string[];\n\t\t\tstartupTimeout?: number;\n\t\t\tdebug?: boolean;\n\t }\n\t| {\n\t\t\ttype: \"http\";\n\t\t\turl?: string;\n\t\t\theaders?: Record<string, string>;\n\t\t\tdisabled?: boolean;\n\t\t\tautoApprove?: string[];\n\t\t\tstartupTimeout?: number;\n\t\t\tdebug?: boolean;\n\t };\n\nexport type PluginOfficialExecutionMode = \"inherit\" | \"sandbox\" | \"full-access\";\n\nexport interface PluginOfficialSelectedSkill {\n\tname: string;\n\talias?: string;\n\ttype: \"skill\" | \"scene\";\n}\n\nexport interface PluginOfficialBatchProjectCreateData {\n\tname: string;\n\tprompt: string;\n\tmodelKey?: string;\n\tfolders: string[];\n\tconcurrency: number;\n\texecutionMode?: PluginOfficialExecutionMode;\n\tartifactPatterns?: string[];\n\tnotifyEnabled?: boolean;\n\ttimeoutMinutes?: number;\n\tskill?: PluginOfficialSelectedSkill;\n}\n\nexport interface PluginOfficialBatchProjectUpdateData {\n\tname?: string;\n\tprompt?: string;\n\tmodelKey?: string;\n\tconcurrency?: number;\n\texecutionMode?: PluginOfficialExecutionMode;\n\tartifactPatterns?: string[];\n\tnotifyEnabled?: boolean;\n\ttimeoutMinutes?: number;\n\tnewFolders?: string[];\n\tskill?: PluginOfficialSelectedSkill | null;\n}\n\nexport interface PluginOfficialSchedulerTaskCreateData {\n\tname: string;\n\tprompt: string;\n\tcron: string;\n\tisOnce: boolean;\n\tenabled?: boolean;\n\tcwd: string;\n\tmodelKey?: string;\n\texecutionMode?: PluginOfficialExecutionMode;\n\tskill?: PluginOfficialSelectedSkill;\n}\n\nexport interface PluginOfficialSchedulerTaskUpdateData {\n\tname?: string;\n\tprompt?: string;\n\tcron?: string;\n\tisOnce?: boolean;\n\tenabled?: boolean;\n\tcwd?: string;\n\tmodelKey?: string | null;\n\texecutionMode?: PluginOfficialExecutionMode;\n\tskill?: PluginOfficialSelectedSkill | null;\n}\n\nexport interface PluginOfficialModelSummary {\n\tid: string;\n\tname?: string;\n\tapi?: string;\n\treasoning?: boolean;\n}\n\nexport interface PluginOfficialProviderSummary {\n\tid: string;\n\tdisplayName: string;\n\tbaseUrl?: string;\n\tapi?: string;\n\thasApiKey: boolean;\n\tmodelCount: number;\n\tmodels: PluginOfficialModelSummary[];\n}\n\nexport interface PluginOfficialProviderDetail {\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: string;\n\tdisplayName?: string;\n\tauthHeader?: boolean;\n\theaders?: Record<string, string>;\n\tmodels?: Array<{\n\t\tid: string;\n\t\tname?: string;\n\t\tapi?: string;\n\t\treasoning?: boolean;\n\t\tcontextWindow?: number;\n\t\tmaxTokens?: number;\n\t}>;\n}\n\nexport interface PluginOfficialProviderUpsertData {\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: string;\n\tdisplayName?: string;\n\tauthHeader?: boolean;\n\theaders?: Record<string, string>;\n\tmodels?: Array<{\n\t\tid: string;\n\t\tname?: string;\n\t\tapi?: string;\n\t\treasoning?: boolean;\n\t\tcontextWindow?: number;\n\t\tmaxTokens?: number;\n\t}>;\n}\n\nexport interface PluginOfficialProjectEntry {\n\tpath: string;\n\tname?: string;\n}\n\nexport interface PluginOfficialPluginSummary {\n\tid: string;\n\tname: string;\n\tversion: string;\n\tenabled: boolean;\n\trequired: boolean;\n\tsource: string;\n\tpermissions: string[];\n\tdescription?: string;\n\tdevWatch?: unknown;\n}\n\nexport interface PluginOfficialKnowledgeBase {\n\tid: string;\n\tname: string;\n\tupdatedAt: number;\n\tisDefault: boolean;\n\tnodes: unknown[];\n}\n\nexport interface PluginOfficialKnowledgeProcessingSettings {\n\tenabled?: boolean;\n\tpollIntervalMinutes?: number;\n\tprocessingModelKey?: string;\n\tprocessingModelReasoningLevel?: string;\n\tagentConcurrency?: number;\n\tocrConcurrency?: number;\n}\n\n/** 仅宿主验证为官方来源的插件可以调用;普通插件调用时由宿主拒绝。 */\nexport interface PluginOfficialApi {\n\tgeneral: {\n\t\tgetSettings(): Promise<PluginOfficialGeneralSettings>;\n\t\tsetSettings(input: PluginOfficialGeneralSettingsUpdate): Promise<PluginOfficialGeneralSettingsUpdate>;\n\t};\n\tagent: {\n\t\tgetExperimental(): Promise<PluginOfficialExperimentalSettings>;\n\t\tsetExperimental(input: Partial<PluginOfficialExperimentalSettings>): Promise<PluginOfficialExperimentalSettings>;\n\t};\n\tdownloads: {\n\t\tlist(): Promise<PluginOfficialDownloadItem[]>;\n\t\tcancel(id: string): Promise<void>;\n\t};\n\tupdater: {\n\t\tgetState(): Promise<PluginOfficialUpdaterState>;\n\t\tgetCurrentVersion(): Promise<string>;\n\t\tcheck(): Promise<PluginOfficialUpdaterState>;\n\t\tdownload(): Promise<PluginOfficialUpdaterState>;\n\t\tinstall(): Promise<void>;\n\t\tdismiss(): Promise<void>;\n\t\tcancel(): Promise<void>;\n\t};\n\twebhook: {\n\t\tlist(): Promise<PluginOfficialWebhookEndpoint[]>;\n\t\tlistProviders(): Promise<PluginOfficialWebhookProvider[]>;\n\t\tcreate(input: PluginOfficialWebhookCreateInput): Promise<PluginOfficialWebhookEndpoint>;\n\t\tupdate(id: string, input: PluginOfficialWebhookUpdateInput): Promise<PluginOfficialWebhookEndpoint>;\n\t\tsetEnabled(id: string, enabled: boolean): Promise<PluginOfficialWebhookEndpoint>;\n\t\tdelete(id: string): Promise<void>;\n\t\ttest(id: string): Promise<PluginOfficialWebhookSendResult>;\n\t\tsend(id: string, message: PluginOfficialWebhookMessage): Promise<PluginOfficialWebhookSendResult>;\n\t};\n\tskills: {\n\t\tlist(cwd?: string): Promise<PluginOfficialSkillInfo[]>;\n\t\tgetManifest(): Promise<Record<string, PluginOfficialInstalledSkill>>;\n\t\tsetEnabled(name: string, enabled: boolean): Promise<{ name: string; enabled: boolean }>;\n\t\tuninstall(name: string, type?: \"skill\" | \"scene\"): Promise<void>;\n\t};\n\tshortcuts: {\n\t\tlistAvailableActions(): Array<{ id: string; defaultShortcut: string }>;\n\t\tget(): Promise<{ bindings: PluginOfficialShortcutBinding[]; quickPanel: PluginOfficialQuickPanelSettings }>;\n\t\tsetBinding(id: string, shortcut: string): Promise<{ bindings: PluginOfficialShortcutBinding[] }>;\n\t\tresetBinding(id: string): Promise<{ bindings: PluginOfficialShortcutBinding[]; shortcut: string }>;\n\t\tresetAllBindings(): Promise<{ bindings: PluginOfficialShortcutBinding[] }>;\n\t\tsetQuickPanelTrigger(trigger: PluginOfficialQuickPanelSettings[\"trigger\"]): Promise<PluginOfficialQuickPanelSettings>;\n\t\tsetQuickPanelBehavior(\n\t\t\tbehavior: PluginOfficialQuickPanelSettings[\"postSendBehavior\"],\n\t\t): Promise<PluginOfficialQuickPanelSettings>;\n\t};\n\tim: {\n\t\tgetStatus(): Promise<PluginOfficialImStatus>;\n\t\tgetLogs(limit?: number): Promise<PluginOfficialImLog[]>;\n\t\tsetEnabled(enabled: boolean): Promise<{ status: unknown }>;\n\t\trestart(): Promise<{ status: unknown }>;\n\t\tsetAgentModel(\n\t\t\tmodelKey: string | null,\n\t\t\treasoningLevel?: string,\n\t\t): Promise<{ status: unknown }>;\n\t\tassertModelKeyExists(modelKey: string): Promise<void>;\n\t};\n\tmcp: {\n\t\tlist(): Promise<PluginOfficialMcpServerSummary[]>;\n\t\tget(name: string): Promise<PluginOfficialMcpServerDetail>;\n\t\tlistNames(): Promise<string[]>;\n\t\tupsert(name: string, data: PluginOfficialMcpUpsertData): Promise<PluginOfficialMcpServerDetail>;\n\t\tsetEnabled(name: string, enabled: boolean): Promise<void>;\n\t\tremove(name: string): Promise<void>;\n\t};\n\tmodels: {\n\t\tlist(): Promise<{ defaultModel: string | null; providers: PluginOfficialProviderSummary[] }>;\n\t\tget(provider?: string): Promise<unknown>;\n\t\tprobe(provider: string, model: string): Promise<{ ok: boolean; message?: string; error?: string }>;\n\t\tlistProviderIds(): Promise<string[]>;\n\t\tassertModelKeyExists(modelKey: string, operation?: string): Promise<void>;\n\t\tsetDefault(modelKey: string): Promise<{ defaultModel: string }>;\n\t\tupsertProvider(provider: string, data: PluginOfficialProviderUpsertData): Promise<PluginOfficialProviderDetail>;\n\t\tremoveProvider(provider: string): Promise<void>;\n\t};\n\tprojects: {\n\t\tlist(): Promise<{\n\t\t\tworkspacePath: string;\n\t\t\tprojects: PluginOfficialProjectEntry[];\n\t\t\tarchivedProjects: PluginOfficialProjectEntry[];\n\t\t}>;\n\t\tlistSessions(cwd: string): Promise<unknown[]>;\n\t\tlistRuntimeProjects(): Promise<unknown[]>;\n\t\tcreate(name: string, path?: string): Promise<PluginOfficialProjectEntry>;\n\t\topen(path: string, name?: string): Promise<PluginOfficialProjectEntry>;\n\t\trename(path: string, name: string): Promise<PluginOfficialProjectEntry>;\n\t\tarchive(path: string): Promise<void>;\n\t\tunarchive(path: string): Promise<void>;\n\t\tremove(path: string): Promise<void>;\n\t};\n\tplugins: {\n\t\tlist(): Promise<PluginOfficialPluginSummary[]>;\n\t\tget(id: string): Promise<PluginOfficialPluginSummary>;\n\t\tsetEnabled(id: string, enabled: boolean): Promise<PluginOfficialPluginSummary>;\n\t\tinstallFromUrl(url: string): Promise<PluginOfficialPluginSummary>;\n\t\tinstallFromPath(\n\t\t\tpath: string,\n\t\t\toptions?: { grantedPermissions?: string[]; enable?: boolean },\n\t\t): Promise<PluginOfficialPluginSummary>;\n\t\tuninstall(id: string): Promise<void>;\n\t\treload(id: string): Promise<PluginOfficialPluginSummary>;\n\t};\n\tknowledge: {\n\t\tlist(): Promise<PluginOfficialKnowledgeBase[]>;\n\t\tfileStatuses(): Promise<Record<string, unknown>>;\n\t\tisProcessing(): Promise<boolean>;\n\t\tgetProcessing(): Promise<PluginOfficialKnowledgeProcessingSettings>;\n\t\tcreate(name: string): Promise<void>;\n\t\trename(name: string, newName: string): Promise<void>;\n\t\tdelete(name: string): Promise<void>;\n\t\taddFiles(kbId: string, paths: string[], move?: boolean): Promise<void>;\n\t\tdeleteEntry(kbId: string, relPath: string): Promise<void>;\n\t\tscanNow(): Promise<{ skipped: boolean; reason?: string }>;\n\t\tretryFailed(): Promise<{ skipped: boolean; reason?: string }>;\n\t\tsetProcessing(\n\t\t\tdata: Partial<{\n\t\t\t\tenabled: boolean;\n\t\t\t\tpollIntervalMinutes: 3 | 5 | 10 | 30;\n\t\t\t\tprocessingModelKey: string | null;\n\t\t\t\tprocessingModelReasoningLevel: string | null;\n\t\t\t\tagentConcurrency: number;\n\t\t\t\tocrConcurrency: number;\n\t\t\t}>,\n\t\t): Promise<PluginOfficialKnowledgeProcessingSettings>;\n\t};\n\tbatchTasks: {\n\t\tlistProjects(): Promise<unknown[]>;\n\t\tgetProject(projectId: string): Promise<unknown>;\n\t\tlistProjectIds(): Promise<string[]>;\n\t\tcreateProject(data: PluginOfficialBatchProjectCreateData): Promise<unknown>;\n\t\tupdateProject(projectId: string, data: PluginOfficialBatchProjectUpdateData): Promise<unknown>;\n\t\tdeleteProject(projectId: string): Promise<unknown>;\n\t\trunTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tretryTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tstopTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tdeleteTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tresumeTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tresumeTaskWithText(projectId: string, taskId: string, text: string): Promise<unknown>;\n\t\tdeleteTaskSession(projectId: string, taskId: string): Promise<unknown>;\n\t\tbatchDelete(projectId: string): Promise<unknown>;\n\t\tbatchStart(projectId: string): Promise<unknown>;\n\t\tbatchStop(projectId: string): Promise<unknown>;\n\t\tbatchReset(projectId: string): Promise<unknown>;\n\t\tbatchResetFailed(projectId: string, taskIds: string[]): Promise<unknown>;\n\t};\n\tscheduler: {\n\t\tlistTasks(): Promise<unknown[]>;\n\t\tgetTask(taskId: string): Promise<unknown>;\n\t\tlistTaskIds(): Promise<string[]>;\n\t\tgetHistory(taskId: string): Promise<unknown[]>;\n\t\tcreateTask(data: PluginOfficialSchedulerTaskCreateData): Promise<unknown>;\n\t\tupdateTask(taskId: string, data: PluginOfficialSchedulerTaskUpdateData): Promise<unknown>;\n\t\tdeleteTask(taskId: string): Promise<unknown>;\n\t\tsetEnabled(taskId: string, enabled: boolean): Promise<unknown>;\n\t\trunNow(taskId: string): Promise<unknown>;\n\t\tabort(taskId: string): Promise<unknown>;\n\t};\n\tappearance: {\n\t\thelp(): Promise<unknown>;\n\t\tget(): Promise<unknown>;\n\t\tset(input: {\n\t\t\tmode?: \"light\" | \"dark\" | \"auto\";\n\t\t\tthemeId?: string;\n\t\t\tcursorStyle?: \"default\" | \"stoat\";\n\t\t}): Promise<unknown>;\n\t\tsetLanguage(language: \"zh\" | \"en\"): Promise<unknown>;\n\t\tlistThemeIds(): string[];\n\t};\n\tnavigation: {\n\t\thelp(): unknown;\n\t\tresolveOpen(input: { target: string; tab?: string; section?: string }): {\n\t\t\thashPath: string;\n\t\t\tresolved: unknown;\n\t\t};\n\t\topen(input: { target: string; tab?: string; section?: string }): Promise<unknown>;\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"official.js","sourceRoot":"","sources":["../src/official.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginPermission } from \"./permissions.js\";\n\nexport interface PluginOfficialGeneralSettings {\n\tworkspacePath: string;\n\tdefaultExecutionMode?: \"sandbox\" | \"full-access\";\n\tnotificationsEnabled: boolean;\n\tdebugMode: boolean;\n\tsandbox: unknown;\n}\n\nexport type PluginOfficialGeneralSettingsUpdate =\n\t| { operation: \"set-notifications\"; enabled: boolean }\n\t| { operation: \"set-execution-mode\"; mode: \"sandbox\" | \"full-access\" }\n\t| { operation: \"set-workspace\"; path: string };\n\nexport interface PluginOfficialExperimentalSettings {\n\tvettaCli: boolean;\n\tpromptPrediction: boolean;\n\tagentSkills: boolean;\n}\n\nexport interface PluginOfficialDownloadItem {\n\tid: string;\n\turl: string;\n\tfilename: string;\n\tpath: string;\n\ttotalBytes: number;\n\treceivedBytes: number;\n\tstatus: \"queued\" | \"downloading\" | \"paused\" | \"completed\" | \"failed\" | \"canceled\";\n\terror?: string;\n\tcreatedAt: number;\n\tcompletedAt?: number;\n\tspeedBytesPerSec?: number;\n}\n\nexport interface PluginOfficialUpdaterState {\n\tphase: \"idle\" | \"checking\" | \"available\" | \"downloading\" | \"ready\" | \"installing\" | \"error\";\n\tcurrentVersion: string;\n\tlatestVersion?: string;\n\treleaseNote?: string;\n\tprogress?: number;\n\tdownloadedBytes?: number;\n\ttotalBytes?: number;\n\tassetFileName?: string;\n\terror?: string;\n}\n\nexport type PluginOfficialWebhookKind = \"feishu\" | \"dingtalk\";\n\nexport interface PluginOfficialWebhookEndpoint {\n\tid: string;\n\tkind: PluginOfficialWebhookKind;\n\tname: string;\n\tenabled: boolean;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\turlMask?: string;\n\thasSignSecret?: boolean;\n}\n\nexport interface PluginOfficialWebhookProvider {\n\tkind: PluginOfficialWebhookKind;\n\tdisplayName: string;\n\ticonClass?: string;\n}\n\nexport interface PluginOfficialWebhookCreateInput {\n\tkind: PluginOfficialWebhookKind;\n\tname: string;\n\twebhookUrl: string;\n\tsignSecret?: string;\n\tenabled?: boolean;\n}\n\nexport interface PluginOfficialWebhookUpdateInput {\n\tname?: string;\n\tenabled?: boolean;\n\twebhookUrl?: string;\n\tsignSecret?: string;\n}\n\nexport interface PluginOfficialWebhookMessage {\n\ttitle?: string;\n\ttext: string;\n\tlevel?: \"info\" | \"warn\" | \"error\" | \"success\";\n}\n\nexport interface PluginOfficialWebhookSendResult {\n\tok: boolean;\n\terror?: string;\n}\n\nexport interface PluginOfficialSkillInfo {\n\tname: string;\n\talias?: string;\n\tdescription: string;\n\tsource: string;\n\ttype: \"skill\" | \"scene\";\n}\n\nexport type PluginOfficialInstalledSkill = {\n\tname: string;\n\tversion: string;\n\tinstalledAt: string;\n\tsource: \"market\" | \"custom\";\n\tenabled: boolean;\n\ttype?: \"skill\" | \"scene\";\n\talias?: string;\n\tmarketDescription?: string;\n\tdescription?: string;\n};\n\nexport interface PluginOfficialShortcutBinding {\n\tid: string;\n\tdefaultShortcut: string;\n\tshortcut: string;\n\tisDefault: boolean;\n}\n\nexport interface PluginOfficialQuickPanelSettings {\n\ttrigger: \"none\" | \"mod\" | \"alt\" | \"shift\";\n\tpostSendBehavior: \"foreground\" | \"background\";\n}\n\nexport interface PluginOfficialImStatus {\n\tenabled: boolean;\n\ttransport: string;\n\tagentModel: { provider: string; model: string; reasoningLevel?: string } | null;\n\twechatBound: boolean;\n\tfeishuAppId: string | null;\n\truntime: unknown;\n}\n\nexport interface PluginOfficialImLog {\n\tlevel: string;\n\tmsg: string;\n\ttime: string;\n\tfields?: Record<string, unknown>;\n}\n\nexport interface PluginOfficialMcpServerSummary {\n\tname: string;\n\ttype: \"http\" | \"stdio\";\n\tdisabled: boolean;\n\tcommand?: string;\n\turl?: string;\n}\n\nexport interface PluginOfficialMcpServerDetail {\n\tname: string;\n\ttype?: \"http\" | \"stdio\";\n\tcommand?: string;\n\targs?: string[];\n\tenv?: Record<string, string>;\n\tcwd?: string;\n\turl?: string;\n\theaders?: Record<string, string>;\n\tdisabled?: boolean;\n\tautoApprove?: string[];\n\tstartupTimeout?: number;\n\tdebug?: boolean;\n}\n\nexport type PluginOfficialMcpUpsertData =\n\t| {\n\t\t\ttype?: \"stdio\";\n\t\t\tcommand?: string;\n\t\t\targs?: string[];\n\t\t\tenv?: Record<string, string>;\n\t\t\tcwd?: string;\n\t\t\tdisabled?: boolean;\n\t\t\tautoApprove?: string[];\n\t\t\tstartupTimeout?: number;\n\t\t\tdebug?: boolean;\n\t }\n\t| {\n\t\t\ttype: \"http\";\n\t\t\turl?: string;\n\t\t\theaders?: Record<string, string>;\n\t\t\tdisabled?: boolean;\n\t\t\tautoApprove?: string[];\n\t\t\tstartupTimeout?: number;\n\t\t\tdebug?: boolean;\n\t };\n\nexport type PluginOfficialExecutionMode = \"inherit\" | \"sandbox\" | \"full-access\";\n\nexport interface PluginOfficialSelectedSkill {\n\tname: string;\n\talias?: string;\n\ttype: \"skill\" | \"scene\";\n}\n\nexport interface PluginOfficialBatchProjectCreateData {\n\tname: string;\n\tprompt: string;\n\tmodelKey?: string;\n\tfolders: string[];\n\tconcurrency: number;\n\texecutionMode?: PluginOfficialExecutionMode;\n\tartifactPatterns?: string[];\n\tnotifyEnabled?: boolean;\n\ttimeoutMinutes?: number;\n\tskill?: PluginOfficialSelectedSkill;\n}\n\nexport interface PluginOfficialBatchProjectUpdateData {\n\tname?: string;\n\tprompt?: string;\n\tmodelKey?: string;\n\tconcurrency?: number;\n\texecutionMode?: PluginOfficialExecutionMode;\n\tartifactPatterns?: string[];\n\tnotifyEnabled?: boolean;\n\ttimeoutMinutes?: number;\n\tnewFolders?: string[];\n\tskill?: PluginOfficialSelectedSkill | null;\n}\n\nexport interface PluginOfficialSchedulerTaskCreateData {\n\tname: string;\n\tprompt: string;\n\tcron: string;\n\tisOnce: boolean;\n\tenabled?: boolean;\n\tcwd: string;\n\tmodelKey?: string;\n\texecutionMode?: PluginOfficialExecutionMode;\n\tskill?: PluginOfficialSelectedSkill;\n}\n\nexport interface PluginOfficialSchedulerTaskUpdateData {\n\tname?: string;\n\tprompt?: string;\n\tcron?: string;\n\tisOnce?: boolean;\n\tenabled?: boolean;\n\tcwd?: string;\n\tmodelKey?: string | null;\n\texecutionMode?: PluginOfficialExecutionMode;\n\tskill?: PluginOfficialSelectedSkill | null;\n}\n\nexport interface PluginOfficialModelSummary {\n\tid: string;\n\tname?: string;\n\tapi?: string;\n\treasoning?: boolean;\n}\n\nexport interface PluginOfficialProviderSummary {\n\tid: string;\n\tdisplayName: string;\n\tbaseUrl?: string;\n\tapi?: string;\n\thasApiKey: boolean;\n\t/** 图标 symbol;配合 `ProviderIcon` 解析为内置图标,无则不画图标。 */\n\ticon?: string;\n\t/**\n\t * true = 来自登录后服务端下发的远程目录(如 Vetta Go),凭据是账号登录态而非本地\n\t * API Key,因此不会出现在本地模型配置里,也不可用 `upsertProvider` / `removeProvider` 改。\n\t */\n\tremote?: boolean;\n\tmodelCount: number;\n\tmodels: PluginOfficialModelSummary[];\n}\n\nexport interface PluginOfficialProviderDetail {\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: string;\n\tdisplayName?: string;\n\tauthHeader?: boolean;\n\theaders?: Record<string, string>;\n\tmodels?: Array<{\n\t\tid: string;\n\t\tname?: string;\n\t\tapi?: string;\n\t\treasoning?: boolean;\n\t\tcontextWindow?: number;\n\t\tmaxTokens?: number;\n\t}>;\n}\n\nexport interface PluginOfficialProviderUpsertData {\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: string;\n\tdisplayName?: string;\n\tauthHeader?: boolean;\n\theaders?: Record<string, string>;\n\tmodels?: Array<{\n\t\tid: string;\n\t\tname?: string;\n\t\tapi?: string;\n\t\treasoning?: boolean;\n\t\tcontextWindow?: number;\n\t\tmaxTokens?: number;\n\t}>;\n}\n\nexport interface PluginOfficialProjectEntry {\n\tpath: string;\n\tname?: string;\n}\n\nexport interface PluginOfficialPluginSummary {\n\tid: string;\n\tname: string;\n\tversion: string;\n\tactiveVersion: string;\n\tpendingVersion?: string;\n\tenabled: boolean;\n\trequired: boolean;\n\tsource: string;\n\tpermissions: string[];\n\tdescription?: string;\n\trootPath?: string;\n\tdevWatch?: unknown;\n}\n\nexport interface PluginOfficialPluginChangedEvent {\n\treason?: string;\n\tpluginId?: string;\n}\n\nexport interface PluginOfficialSaveCopyOptions {\n\tdefaultFileName?: string;\n\ttitle?: string;\n\tfilters?: Array<{ name: string; extensions: string[] }>;\n}\n\n/** `official.dialog.openFiles` 的选项。 */\nexport interface PluginOfficialOpenFilesOptions {\n\ttitle?: string;\n\tfilters?: Array<{ name: string; extensions: string[] }>;\n\t/** 允许多选,默认单选。 */\n\tmultiple?: boolean;\n\t/** 单个文件的字节上限,超过则抛错。默认 64MB。 */\n\tmaxBytes?: number;\n}\n\n/** 用户在文件对话框里选中的一个文件,内容随选择一起回传。 */\nexport interface PluginOfficialOpenedFile {\n\tpath: string;\n\tname: string;\n\t/** base64 编码的文件内容。 */\n\tdata: string;\n}\n\nexport interface PluginOfficialKnowledgeBase {\n\tid: string;\n\tname: string;\n\tupdatedAt: number;\n\tisDefault: boolean;\n\tnodes: unknown[];\n}\n\nexport interface PluginOfficialKnowledgeProcessingSettings {\n\tenabled?: boolean;\n\tpollIntervalMinutes?: number;\n\tprocessingModelKey?: string;\n\tprocessingModelReasoningLevel?: string;\n\tagentConcurrency?: number;\n\tocrConcurrency?: number;\n}\n\n/** 由 `official.sessions.create` 新建的后台会话句柄。 */\nexport interface PluginOfficialSessionHandle {\n\t/** 进程内 runtime id,用于 prompt / abort / subscribe。重启后失效。 */\n\tsessionId: string;\n\t/** 会话文件绝对路径,跨重启稳定,用于持久化与跳转。 */\n\tsessionPath: string;\n\t/** 实际运行目录(「对话」项目会落到 per-session 子目录,见 ADR-0007)。 */\n\tcwd?: string;\n}\n\n/** 会话运行态变化广播(按 sessionPath 标识,跨重启稳定)。 */\nexport interface PluginOfficialSessionRunningEvent {\n\tsessionPath: string;\n\trunning: boolean;\n\tsessionId?: string;\n}\n\n/**\n * 会话文件此刻允许做什么。\n *\n * 同一份会话文件可能正被另一个运行时占用、或已不可读,宿主自己点会话时就是按这几\n * 位分流的(可续聊 / 只读查看 / 完全打不开)。插件在跳转前必须先看它,否则会把用户\n * 送进一个打不开的会话,且失败发生在导航之后、很难解释。\n */\nexport interface PluginOfficialSessionAccess {\n\t/** 能否读取历史。为 false 时连只读查看都不行。 */\n\treadHistory: boolean;\n\t/** 能否在对话页续聊。 */\n\tinteractiveResume: boolean;\n\trename: boolean;\n\tdelete: boolean;\n}\n\n/** 会话历史条目(`official.sessions.list` 返回),按 `modifiedAt` 倒序。 */\nexport interface PluginOfficialSessionSummary {\n\tpath: string;\n\tcwd?: string;\n\tfirstMessage?: string;\n\tmodifiedAt?: number;\n\taccess: PluginOfficialSessionAccess;\n}\n\n/**\n * 导航目标。多数目标只要 `target`;`target: \"new-session\"` 这类带参数的目标另需\n * `cwd`(项目绝对路径),缺了会被宿主拒绝而不是跳到一个空页面。\n */\nexport interface PluginOfficialNavigationOpenInput {\n\ttarget: string;\n\ttab?: string;\n\tsection?: string;\n\t/** 仅 `target: \"new-session\"` 使用:要新建会话的项目目录。 */\n\tcwd?: string;\n\t/**\n\t * 仅 `target: \"new-session\"` 使用:预置到输入框的草稿文本,不发送,用户可继续编辑。\n\t *\n\t * 用输入框的文本形态书写行内 token(`@skill:名字` / `@mcp:名字` / `@/abs/path`),\n\t * 宿主会把它们渲染成对应的 badge。在导航发生**之前**写入该 cwd 的新会话草稿位,\n\t * 所以不会被新会话页自己的草稿恢复覆盖;该 cwd 上已有的未发送草稿会被替换。\n\t */\n\tdraft?: string;\n}\n\n/** 仅宿主验证为官方来源的插件可以调用;普通插件调用时由宿主拒绝。 */\nexport interface PluginOfficialApi {\n\tgeneral: {\n\t\tgetSettings(): Promise<PluginOfficialGeneralSettings>;\n\t\tsetSettings(input: PluginOfficialGeneralSettingsUpdate): Promise<PluginOfficialGeneralSettingsUpdate>;\n\t};\n\tagent: {\n\t\tgetExperimental(): Promise<PluginOfficialExperimentalSettings>;\n\t\tsetExperimental(input: Partial<PluginOfficialExperimentalSettings>): Promise<PluginOfficialExperimentalSettings>;\n\t};\n\tdownloads: {\n\t\tlist(): Promise<PluginOfficialDownloadItem[]>;\n\t\tcancel(id: string): Promise<void>;\n\t};\n\tupdater: {\n\t\tgetState(): Promise<PluginOfficialUpdaterState>;\n\t\tgetCurrentVersion(): Promise<string>;\n\t\tcheck(): Promise<PluginOfficialUpdaterState>;\n\t\tdownload(): Promise<PluginOfficialUpdaterState>;\n\t\tinstall(): Promise<void>;\n\t\tdismiss(): Promise<void>;\n\t\tcancel(): Promise<void>;\n\t};\n\twebhook: {\n\t\tlist(): Promise<PluginOfficialWebhookEndpoint[]>;\n\t\tlistProviders(): Promise<PluginOfficialWebhookProvider[]>;\n\t\tcreate(input: PluginOfficialWebhookCreateInput): Promise<PluginOfficialWebhookEndpoint>;\n\t\tupdate(id: string, input: PluginOfficialWebhookUpdateInput): Promise<PluginOfficialWebhookEndpoint>;\n\t\tsetEnabled(id: string, enabled: boolean): Promise<PluginOfficialWebhookEndpoint>;\n\t\tdelete(id: string): Promise<void>;\n\t\ttest(id: string): Promise<PluginOfficialWebhookSendResult>;\n\t\tsend(id: string, message: PluginOfficialWebhookMessage): Promise<PluginOfficialWebhookSendResult>;\n\t};\n\tskills: {\n\t\tlist(cwd?: string): Promise<PluginOfficialSkillInfo[]>;\n\t\tgetManifest(): Promise<Record<string, PluginOfficialInstalledSkill>>;\n\t\tsetEnabled(name: string, enabled: boolean): Promise<{ name: string; enabled: boolean }>;\n\t\tuninstall(name: string, type?: \"skill\" | \"scene\"): Promise<void>;\n\t\t/**\n\t\t * 从能力市场按 slug 安装 skill/scene(产品文案:能力)。\n\t\t * 下载在主进程完成;密钥类凭证不经过此 API。\n\t\t */\n\t\tinstallFromMarket(\n\t\t\ttype: \"skill\" | \"scene\",\n\t\t\tslug: string,\n\t\t): Promise<{ name: string; type: \"skill\" | \"scene\"; version: string; updated: boolean }>;\n\t};\n\tshortcuts: {\n\t\tlistAvailableActions(): Array<{ id: string; defaultShortcut: string }>;\n\t\tget(): Promise<{ bindings: PluginOfficialShortcutBinding[]; quickPanel: PluginOfficialQuickPanelSettings }>;\n\t\tsetBinding(id: string, shortcut: string): Promise<{ bindings: PluginOfficialShortcutBinding[] }>;\n\t\tresetBinding(id: string): Promise<{ bindings: PluginOfficialShortcutBinding[]; shortcut: string }>;\n\t\tresetAllBindings(): Promise<{ bindings: PluginOfficialShortcutBinding[] }>;\n\t\tsetQuickPanelTrigger(trigger: PluginOfficialQuickPanelSettings[\"trigger\"]): Promise<PluginOfficialQuickPanelSettings>;\n\t\tsetQuickPanelBehavior(\n\t\t\tbehavior: PluginOfficialQuickPanelSettings[\"postSendBehavior\"],\n\t\t): Promise<PluginOfficialQuickPanelSettings>;\n\t};\n\tim: {\n\t\tgetStatus(): Promise<PluginOfficialImStatus>;\n\t\tgetLogs(limit?: number): Promise<PluginOfficialImLog[]>;\n\t\tsetEnabled(enabled: boolean): Promise<{ status: unknown }>;\n\t\trestart(): Promise<{ status: unknown }>;\n\t\tsetAgentModel(\n\t\t\tmodelKey: string | null,\n\t\t\treasoningLevel?: string,\n\t\t): Promise<{ status: unknown }>;\n\t\tassertModelKeyExists(modelKey: string): Promise<void>;\n\t\t/**\n\t\t * 写入飞书凭证。Agent 应省略 appSecret 等密钥,由审批弹窗让用户手填。\n\t\t * 空字符串密钥字段表示保持现有值不改。\n\t\t */\n\t\tsetFeishuConfig(input: {\n\t\t\tenabled?: boolean;\n\t\t\tappId?: string;\n\t\t\tappSecret?: string;\n\t\t\tverificationToken?: string;\n\t\t\tencryptKey?: string;\n\t\t\tbaseUrl?: string;\n\t\t}): Promise<{ ok: boolean; error?: string }>;\n\t};\n\tmcp: {\n\t\tlist(): Promise<PluginOfficialMcpServerSummary[]>;\n\t\tget(name: string): Promise<PluginOfficialMcpServerDetail>;\n\t\tlistNames(): Promise<string[]>;\n\t\tupsert(name: string, data: PluginOfficialMcpUpsertData): Promise<PluginOfficialMcpServerDetail>;\n\t\tsetEnabled(name: string, enabled: boolean): Promise<void>;\n\t\tremove(name: string): Promise<void>;\n\t};\n\tmodels: {\n\t\t/**\n\t\t * 用户当前可选的全部模型:本地配置的 provider **加上**登录后服务端下发的远程目录\n\t\t * (Vetta Go 等,`remote: true`)。同一个 `provider/modelId` 以本地为准。\n\t\t * 与宿主输入栏模型选择器同一口径。\n\t\t */\n\t\tlist(): Promise<{ defaultModel: string | null; providers: PluginOfficialProviderSummary[] }>;\n\t\tget(provider?: string): Promise<unknown>;\n\t\tprobe(provider: string, model: string): Promise<{ ok: boolean; message?: string; error?: string }>;\n\t\tlistProviderIds(): Promise<string[]>;\n\t\tassertModelKeyExists(modelKey: string, operation?: string): Promise<void>;\n\t\tsetDefault(modelKey: string): Promise<{ defaultModel: string }>;\n\t\tupsertProvider(provider: string, data: PluginOfficialProviderUpsertData): Promise<PluginOfficialProviderDetail>;\n\t\tremoveProvider(provider: string): Promise<void>;\n\t};\n\tprojects: {\n\t\tlist(): Promise<{\n\t\t\tworkspacePath: string;\n\t\t\tprojects: PluginOfficialProjectEntry[];\n\t\t\tarchivedProjects: PluginOfficialProjectEntry[];\n\t\t}>;\n\t\tlistSessions(cwd: string): Promise<unknown[]>;\n\t\tlistRuntimeProjects(): Promise<unknown[]>;\n\t\tcreate(name: string, path?: string): Promise<PluginOfficialProjectEntry>;\n\t\topen(path: string, name?: string): Promise<PluginOfficialProjectEntry>;\n\t\trename(path: string, name: string): Promise<PluginOfficialProjectEntry>;\n\t\tarchive(path: string): Promise<void>;\n\t\tunarchive(path: string): Promise<void>;\n\t\tremove(path: string): Promise<void>;\n\t};\n\tplugins: {\n\t\tlist(): Promise<PluginOfficialPluginSummary[]>;\n\t\tget(id: string): Promise<PluginOfficialPluginSummary>;\n\t\tsetEnabled(id: string, enabled: boolean): Promise<PluginOfficialPluginSummary>;\n\t\tinstallFromUrl(url: string): Promise<PluginOfficialPluginSummary>;\n\t\tinstallFromPath(\n\t\t\tpath: string,\n\t\t\toptions?: {\n\t\t\t\tgrantedPermissions?: string[];\n\t\t\t\tenable?: boolean;\n\t\t\t\tsource?: \"archive\" | \"npm\";\n\t\t\t\texpectedSha256?: string;\n\t\t\t\texpectedId?: string;\n\t\t\t\texpectedVersion?: string;\n\t\t\t\tnpm?: {\n\t\t\t\t\tpackageName: string;\n\t\t\t\t\trequestedSpec: string;\n\t\t\t\t\tresolvedVersion: string;\n\t\t\t\t\tintegrity?: string;\n\t\t\t\t};\n\t\t\t},\n\t\t): Promise<PluginOfficialPluginSummary>;\n\t\tuninstall(id: string): Promise<void>;\n\t\treload(id: string): Promise<PluginOfficialPluginSummary>;\n\t\tgrantPermissions(id: string, permissions: PluginPermission[]): Promise<PluginOfficialPluginSummary>;\n\t\tstartDevWatch(id: string, projectDir: string): Promise<PluginOfficialPluginSummary>;\n\t\tstopDevWatch(id: string): Promise<void>;\n\t\tonChanged(handler: (event?: PluginOfficialPluginChangedEvent) => void): () => void;\n\t};\n\tdialog: {\n\t\tsaveCopy(sourcePath: string, options?: PluginOfficialSaveCopyOptions): Promise<string | null>;\n\t\t/**\n\t\t * 打开原生文件选择框,并把选中文件的**内容**一起返回。\n\t\t *\n\t\t * 插件的 `ctx.fs` 只能读已授权的项目根,因此「选个文件再自己去读」这条路走不通;\n\t\t * 这个接口不放宽任何目录授权,插件能看到的只有用户这次亲手选中的文件。\n\t\t * 用户取消时返回空数组。\n\t\t */\n\t\topenFiles(options?: PluginOfficialOpenFilesOptions): Promise<PluginOfficialOpenedFile[]>;\n\t};\n\tshell: {\n\t\t/**\n\t\t * 在系统文件管理器里定位并选中这个路径。\n\t\t *\n\t\t * 与 `ui.openExternal` 分工:那个只放行 http/https,用来把链接交给浏览器;\n\t\t * 这个只做「显示这个本地路径」,不能用来拉起任意协议。\n\t\t */\n\t\tshowItemInFolder(path: string): Promise<void>;\n\t};\n\tknowledge: {\n\t\tlist(): Promise<PluginOfficialKnowledgeBase[]>;\n\t\tfileStatuses(): Promise<Record<string, unknown>>;\n\t\tisProcessing(): Promise<boolean>;\n\t\tgetProcessing(): Promise<PluginOfficialKnowledgeProcessingSettings>;\n\t\tcreate(name: string): Promise<void>;\n\t\trename(name: string, newName: string): Promise<void>;\n\t\tdelete(name: string): Promise<void>;\n\t\taddFiles(kbId: string, paths: string[], move?: boolean): Promise<void>;\n\t\tdeleteEntry(kbId: string, relPath: string): Promise<void>;\n\t\tscanNow(): Promise<{ skipped: boolean; reason?: string }>;\n\t\tretryFailed(): Promise<{ skipped: boolean; reason?: string }>;\n\t\tsetProcessing(\n\t\t\tdata: Partial<{\n\t\t\t\tenabled: boolean;\n\t\t\t\tpollIntervalMinutes: 3 | 5 | 10 | 30;\n\t\t\t\tprocessingModelKey: string | null;\n\t\t\t\tprocessingModelReasoningLevel: string | null;\n\t\t\t\tagentConcurrency: number;\n\t\t\t\tocrConcurrency: number;\n\t\t\t}>,\n\t\t): Promise<PluginOfficialKnowledgeProcessingSettings>;\n\t};\n\tbatchTasks: {\n\t\tlistProjects(): Promise<unknown[]>;\n\t\tgetProject(projectId: string): Promise<unknown>;\n\t\tlistProjectIds(): Promise<string[]>;\n\t\tcreateProject(data: PluginOfficialBatchProjectCreateData): Promise<unknown>;\n\t\tupdateProject(projectId: string, data: PluginOfficialBatchProjectUpdateData): Promise<unknown>;\n\t\tdeleteProject(projectId: string): Promise<unknown>;\n\t\trunTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tretryTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tstopTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tdeleteTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tresumeTask(projectId: string, taskId: string): Promise<unknown>;\n\t\tresumeTaskWithText(projectId: string, taskId: string, text: string): Promise<unknown>;\n\t\tdeleteTaskSession(projectId: string, taskId: string): Promise<unknown>;\n\t\tbatchDelete(projectId: string): Promise<unknown>;\n\t\tbatchStart(projectId: string): Promise<unknown>;\n\t\tbatchStop(projectId: string): Promise<unknown>;\n\t\tbatchReset(projectId: string): Promise<unknown>;\n\t\tbatchResetFailed(projectId: string, taskIds: string[]): Promise<unknown>;\n\t};\n\tscheduler: {\n\t\tlistTasks(): Promise<unknown[]>;\n\t\tgetTask(taskId: string): Promise<unknown>;\n\t\tlistTaskIds(): Promise<string[]>;\n\t\tgetHistory(taskId: string): Promise<unknown[]>;\n\t\tcreateTask(data: PluginOfficialSchedulerTaskCreateData): Promise<unknown>;\n\t\tupdateTask(taskId: string, data: PluginOfficialSchedulerTaskUpdateData): Promise<unknown>;\n\t\tdeleteTask(taskId: string): Promise<unknown>;\n\t\tsetEnabled(taskId: string, enabled: boolean): Promise<unknown>;\n\t\trunNow(taskId: string): Promise<unknown>;\n\t\tabort(taskId: string): Promise<unknown>;\n\t};\n\tappearance: {\n\t\thelp(): Promise<unknown>;\n\t\tget(): Promise<unknown>;\n\t\tset(input: {\n\t\t\tmode?: \"light\" | \"dark\" | \"auto\";\n\t\t\tthemeId?: string;\n\t\t\tcursorStyle?: \"default\" | \"stoat\";\n\t\t}): Promise<unknown>;\n\t\tsetLanguage(language: \"zh\" | \"en\"): Promise<unknown>;\n\t\tlistThemeIds(): string[];\n\t};\n\t/**\n\t * 后台会话编排。会话本体跑在主进程,创建后即使宿主停留在别的页面也会继续执行,\n\t * 因此系统插件可以据此做「多任务并发派单」类工作台(如看板)。\n\t */\n\tsessions: {\n\t\t/**\n\t\t * 在 `cwd` 下新建一个会话;不发送任何 prompt。\n\t\t *\n\t\t * 传 `modelKey`(`provider/modelId`)时写入该会话的模型设置,后续无论是插件\n\t\t * 继续 `prompt`、还是用户在对话页手动接着聊,都用这个模型;不传则跟随宿主全局默认。\n\t\t */\n\t\tcreate(input: { cwd: string; title?: string; modelKey?: string }): Promise<PluginOfficialSessionHandle>;\n\t\t/**\n\t\t * 向会话发起一轮对话。streaming 中会进入该会话的输入队列(ADR-0060)。\n\t\t *\n\t\t * `options.modelKey` 只钉住**这一轮**用哪个模型(不改会话设置);要让整个会话\n\t\t * 都用某个模型,在 `create` 时传 `modelKey`。\n\t\t */\n\t\tprompt(\n\t\t\tsessionId: string,\n\t\t\ttext: string,\n\t\t\toptions?: { modelKey?: string },\n\t\t): Promise<{ status: \"sent\" | \"queued\" | \"failed\"; error?: { message: string } }>;\n\t\t/** 中止会话当前回合。 */\n\t\tabort(sessionId: string): Promise<void>;\n\t\t/** 重命名会话(写入会话文件标题),用于把看板卡片标题同步到会话列表。 */\n\t\trename(sessionPath: string, name: string): Promise<void>;\n\t\t/** 列出某目录下的历史会话。 */\n\t\tlist(cwd: string): Promise<PluginOfficialSessionSummary[]>;\n\t\t/** 当前处于 agent loop 中的会话文件路径快照。 */\n\t\tlistRunning(): Promise<string[]>;\n\t\t/**\n\t\t * 当前有会话在跑的项目 cwd(去重)。\n\t\t *\n\t\t * 需要「这个项目忙不忙」时用它,不要拿 `listRunning()` 的路径去比对 cwd:会话文件\n\t\t * 默认落在按 cwd 编码的分片目录里,那个编码不可逆且会让不同项目撞进同一分片。\n\t\t */\n\t\tlistRunningCwds(): Promise<string[]>;\n\t\t/** 订阅运行态翻转;返回取消订阅函数。 */\n\t\tonRunningChanged(handler: (event: PluginOfficialSessionRunningEvent) => void): () => void;\n\t\t/** 把宿主导航到该会话的对话页。 */\n\t\topen(input: { cwd: string; sessionPath: string }): Promise<void>;\n\t};\n\tnavigation: {\n\t\thelp(): unknown;\n\t\tresolveOpen(input: PluginOfficialNavigationOpenInput): {\n\t\t\thashPath: string;\n\t\t\tresolved: unknown;\n\t\t};\n\t\topen(input: PluginOfficialNavigationOpenInput): Promise<unknown>;\n\t};\n}\n"]}
|
package/dist/permissions.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const PLUGIN_PERMISSIONS: readonly ["ui.slot.global", "ui.slot.file-preview", "ui.slot.activity-tab", "ui.slot.input-action", "ui.slot.message", "ui.slot.tool-call", "ui.slot.turn-card", "ui.slot.workspace-view", "ui.shortcuts.register", "ui.file-explorer.decorations", "ui.file-explorer.context-menu", "ui.file-explorer.toolbar", "workspace.read", "agent.session.read", "agent.session.write", "agent.command.run", "agent.command.spawn", "capture.offscreen", "browser.read", "browser.open", "browser.interact", "browser.profile.persist", "browser.attach", "browser.runtime.manage", "agent.systemPrompt.read", "agent.systemPrompt.write", "agent.systemPrompt.fullControl", "agent.skills.control", "agent.mcp.control", "agent.tools.control", "agent.tools.register", "agent.toolHandler.execute", "agent.hooks.register", "agent.hookHandler.execute", "agent.state.read", "agent.state.write", "agent.continuation.register", "agent.runtime.configure", "app.actions.register", "app.actionHandler.execute", "ai.models.list", "ai.complete", "fs.read", "fs.write", "network.fetch", "storage.read", "storage.write", "media.generate", "media.provider.register", "settings.read", "settings.write", "shell.openExternal"];
|
|
2
|
+
export type PluginPermission = (typeof PLUGIN_PERMISSIONS)[number];
|
|
2
3
|
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -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,4pCAqDrB,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.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"]}
|
package/dist/permissions.js
CHANGED
|
@@ -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
|
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,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
|
-
*
|
|
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,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,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,CAAC;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACzC,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,6BAA6B;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,6BAA6B,EAAE,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACxC,IAAI,EAAE,SAAS,CAAC;CAChB;AAED,uEAAuE;AACvE,MAAM,MAAM,qBAAqB,GAC9B,sBAAsB,GACtB,wBAAwB,GACxB,qBAAqB,GACrB,uBAAuB,GACvB,sBAAsB,GACtB,yBAAyB,GACzB,uBAAuB,GACvB,uBAAuB,GACvB,wBAAwB,CAAC;AAE5B,MAAM,WAAW,wBAAwB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,+DAA+D;IAC/D,SAAS,CAAC,EAAE,0BAA0B,CAAC;CACvC;AAED,MAAM,WAAW,4BAA4B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,GAAG,IAAI,CAAC;IACjE,UAAU,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,WAAW,EAAE;QAAE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAClD,EAAE,EAAE;QACH,mBAAmB,CAAC,YAAY,EAAE,wBAAwB,GAAG,IAAI,CAAC;QAClE,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;QACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACvG,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAC;QACzF,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAC;QACzF,MAAM,CAAC,OAAO,EAAE;YACf,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;YACnD,UAAU,CAAC,EAAE,MAAM,CAAC;SACpB,GAAG,IAAI,CAAC;KACT,CAAC;IACF,OAAO,EAAE;QACR,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;KACvF,CAAC;IACF,OAAO,EAAE;QACR,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QACtD,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,QAAQ,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"]}
|
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,60 @@
|
|
|
1
|
+
import type { Disposable } from "./disposable.js";
|
|
2
|
+
/**
|
|
3
|
+
* Keyboard shortcut scopes (priority high → low), mirroring the host stack:
|
|
4
|
+
* - modal: dialogs (often exclusive)
|
|
5
|
+
* - overlay: pickers / floating UI
|
|
6
|
+
* - surface: previews, panels, editors
|
|
7
|
+
*
|
|
8
|
+
* Plugins cannot register `app` — that layer is reserved for host-configurable
|
|
9
|
+
* global actions (settings → shortcuts).
|
|
10
|
+
*/
|
|
11
|
+
export type PluginShortcutScopeKind = "surface" | "overlay" | "modal";
|
|
12
|
+
export type PluginShortcutWhen = "always" | "editable" | "not-editable";
|
|
13
|
+
export interface PluginShortcutBinding {
|
|
14
|
+
/**
|
|
15
|
+
* Serialized combo matching the host `eventToShortcut` format, e.g.
|
|
16
|
+
* `"mod+s"`, `"escape"`, `"arrowleft"`, `"="`, `"-"`.
|
|
17
|
+
*/
|
|
18
|
+
key: string;
|
|
19
|
+
run: (event: KeyboardEvent) => void;
|
|
20
|
+
/** Default `"always"`. Restrict to / out of editable targets. */
|
|
21
|
+
when?: PluginShortcutWhen;
|
|
22
|
+
/** Default true. */
|
|
23
|
+
preventDefault?: boolean;
|
|
24
|
+
/** Default true. */
|
|
25
|
+
stopPropagation?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface PluginShortcutScopeContribution {
|
|
28
|
+
/** Local id; host namespaces as `pluginId:id`. */
|
|
29
|
+
id: string;
|
|
30
|
+
kind: PluginShortcutScopeKind;
|
|
31
|
+
/** When true, unmatched keys do not fall through to lower scopes. */
|
|
32
|
+
exclusive?: boolean;
|
|
33
|
+
/** Dynamic gate; re-checked on every keydown. */
|
|
34
|
+
enabled?: () => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Static list or factory. Factories are read each keydown so handlers can
|
|
37
|
+
* close over the latest component state without re-registering.
|
|
38
|
+
*/
|
|
39
|
+
bindings: readonly PluginShortcutBinding[] | (() => readonly PluginShortcutBinding[]);
|
|
40
|
+
}
|
|
41
|
+
export type PluginRegisterShortcutScope = (contribution: PluginShortcutScopeContribution) => Disposable;
|
|
42
|
+
export interface UsePluginShortcutScopeOptions {
|
|
43
|
+
/** Stable local id (host namespaces with plugin id). */
|
|
44
|
+
id: string;
|
|
45
|
+
kind: PluginShortcutScopeKind;
|
|
46
|
+
/** When false, scope is not registered. Default true. */
|
|
47
|
+
active?: boolean;
|
|
48
|
+
exclusive?: boolean;
|
|
49
|
+
enabled?: () => boolean;
|
|
50
|
+
bindings: readonly PluginShortcutBinding[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Component-scoped shortcut registration for plugins.
|
|
54
|
+
*
|
|
55
|
+
* Pass `ctx.ui.registerShortcutScope` captured in `activate` (module-level),
|
|
56
|
+
* same pattern as `notify`. While `active` is true, bindings participate in the
|
|
57
|
+
* host ShortcutScopeStack — do not add ad-hoc `document` keydown listeners.
|
|
58
|
+
*/
|
|
59
|
+
export declare function usePluginShortcutScope(register: PluginRegisterShortcutScope | null | undefined, options: UsePluginShortcutScopeOptions): void;
|
|
60
|
+
//# sourceMappingURL=shortcuts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortcuts.d.ts","sourceRoot":"","sources":["../src/shortcuts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,cAAc,CAAC;AAExE,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACpC,iEAAiE;IACjE,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,+BAA+B;IAC/C,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,uBAAuB,CAAC;IAC9B,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,SAAS,qBAAqB,EAAE,GAAG,CAAC,MAAM,SAAS,qBAAqB,EAAE,CAAC,CAAC;CACtF;AAED,MAAM,MAAM,2BAA2B,GAAG,CAAC,YAAY,EAAE,+BAA+B,KAAK,UAAU,CAAC;AAExG,MAAM,WAAW,6BAA6B;IAC7C,wDAAwD;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,uBAAuB,CAAC;IAC9B,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;IACxB,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAC3C;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,2BAA2B,GAAG,IAAI,GAAG,SAAS,EACxD,OAAO,EAAE,6BAA6B,GACpC,IAAI,CAyBN","sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { Disposable } from \"./disposable.js\";\n\n/**\n * Keyboard shortcut scopes (priority high → low), mirroring the host stack:\n * - modal: dialogs (often exclusive)\n * - overlay: pickers / floating UI\n * - surface: previews, panels, editors\n *\n * Plugins cannot register `app` — that layer is reserved for host-configurable\n * global actions (settings → shortcuts).\n */\nexport type PluginShortcutScopeKind = \"surface\" | \"overlay\" | \"modal\";\n\nexport type PluginShortcutWhen = \"always\" | \"editable\" | \"not-editable\";\n\nexport interface PluginShortcutBinding {\n\t/**\n\t * Serialized combo matching the host `eventToShortcut` format, e.g.\n\t * `\"mod+s\"`, `\"escape\"`, `\"arrowleft\"`, `\"=\"`, `\"-\"`.\n\t */\n\tkey: string;\n\trun: (event: KeyboardEvent) => void;\n\t/** Default `\"always\"`. Restrict to / out of editable targets. */\n\twhen?: PluginShortcutWhen;\n\t/** Default true. */\n\tpreventDefault?: boolean;\n\t/** Default true. */\n\tstopPropagation?: boolean;\n}\n\nexport interface PluginShortcutScopeContribution {\n\t/** Local id; host namespaces as `pluginId:id`. */\n\tid: string;\n\tkind: PluginShortcutScopeKind;\n\t/** When true, unmatched keys do not fall through to lower scopes. */\n\texclusive?: boolean;\n\t/** Dynamic gate; re-checked on every keydown. */\n\tenabled?: () => boolean;\n\t/**\n\t * Static list or factory. Factories are read each keydown so handlers can\n\t * close over the latest component state without re-registering.\n\t */\n\tbindings: readonly PluginShortcutBinding[] | (() => readonly PluginShortcutBinding[]);\n}\n\nexport type PluginRegisterShortcutScope = (contribution: PluginShortcutScopeContribution) => Disposable;\n\nexport interface UsePluginShortcutScopeOptions {\n\t/** Stable local id (host namespaces with plugin id). */\n\tid: string;\n\tkind: PluginShortcutScopeKind;\n\t/** When false, scope is not registered. Default true. */\n\tactive?: boolean;\n\texclusive?: boolean;\n\tenabled?: () => boolean;\n\tbindings: readonly PluginShortcutBinding[];\n}\n\n/**\n * Component-scoped shortcut registration for plugins.\n *\n * Pass `ctx.ui.registerShortcutScope` captured in `activate` (module-level),\n * same pattern as `notify`. While `active` is true, bindings participate in the\n * host ShortcutScopeStack — do not add ad-hoc `document` keydown listeners.\n */\nexport function usePluginShortcutScope(\n\tregister: PluginRegisterShortcutScope | null | undefined,\n\toptions: UsePluginShortcutScopeOptions,\n): void {\n\tconst bindingsRef = useRef(options.bindings);\n\tbindingsRef.current = options.bindings;\n\tconst enabledRef = useRef(options.enabled);\n\tenabledRef.current = options.enabled;\n\n\tconst keySignature = options.bindings.map((b) => `${b.key}:${b.when ?? \"always\"}`).join(\"|\");\n\tconst active = options.active !== false;\n\n\tuseEffect(() => {\n\t\tif (!register || !active) return;\n\t\tconst handle = register({\n\t\t\tid: options.id,\n\t\t\tkind: options.kind,\n\t\t\texclusive: options.exclusive,\n\t\t\tenabled: enabledRef.current\n\t\t\t\t? () => {\n\t\t\t\t\t\tconst gate = enabledRef.current;\n\t\t\t\t\t\treturn gate ? gate() : true;\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t\tbindings: () => bindingsRef.current,\n\t\t});\n\t\treturn () => handle.dispose();\n\t}, [register, options.id, options.kind, options.exclusive, active, keySignature]);\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Component-scoped shortcut registration for plugins.
|
|
4
|
+
*
|
|
5
|
+
* Pass `ctx.ui.registerShortcutScope` captured in `activate` (module-level),
|
|
6
|
+
* same pattern as `notify`. While `active` is true, bindings participate in the
|
|
7
|
+
* host ShortcutScopeStack — do not add ad-hoc `document` keydown listeners.
|
|
8
|
+
*/
|
|
9
|
+
export function usePluginShortcutScope(register, options) {
|
|
10
|
+
const bindingsRef = useRef(options.bindings);
|
|
11
|
+
bindingsRef.current = options.bindings;
|
|
12
|
+
const enabledRef = useRef(options.enabled);
|
|
13
|
+
enabledRef.current = options.enabled;
|
|
14
|
+
const keySignature = options.bindings.map((b) => `${b.key}:${b.when ?? "always"}`).join("|");
|
|
15
|
+
const active = options.active !== false;
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!register || !active)
|
|
18
|
+
return;
|
|
19
|
+
const handle = register({
|
|
20
|
+
id: options.id,
|
|
21
|
+
kind: options.kind,
|
|
22
|
+
exclusive: options.exclusive,
|
|
23
|
+
enabled: enabledRef.current
|
|
24
|
+
? () => {
|
|
25
|
+
const gate = enabledRef.current;
|
|
26
|
+
return gate ? gate() : true;
|
|
27
|
+
}
|
|
28
|
+
: undefined,
|
|
29
|
+
bindings: () => bindingsRef.current,
|
|
30
|
+
});
|
|
31
|
+
return () => handle.dispose();
|
|
32
|
+
}, [register, options.id, options.kind, options.exclusive, active, keySignature]);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=shortcuts.js.map
|