@vetta-org/plugin-sdk 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activity-tab.d.ts +2 -0
- package/dist/activity-tab.d.ts.map +1 -1
- package/dist/activity-tab.js +1 -1
- package/dist/activity-tab.js.map +1 -1
- package/dist/agent.d.ts +148 -4
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +14 -1
- package/dist/agent.js.map +1 -1
- package/dist/ai.d.ts +106 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +2 -0
- package/dist/ai.js.map +1 -0
- package/dist/app-actions.d.ts +9 -1
- package/dist/app-actions.d.ts.map +1 -1
- package/dist/app-actions.js.map +1 -1
- package/dist/artifacts.d.ts +31 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +2 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/browser.d.ts +119 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -0
- package/dist/capture.d.ts +64 -0
- package/dist/capture.d.ts.map +1 -0
- package/dist/capture.js +2 -0
- package/dist/capture.js.map +1 -0
- package/dist/cli-provider.d.ts +18 -0
- package/dist/cli-provider.d.ts.map +1 -0
- package/dist/cli-provider.js +2 -0
- package/dist/cli-provider.js.map +1 -0
- package/dist/context.d.ts +59 -7
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/conversation.d.ts +66 -2
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/gateway.d.ts +37 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +14 -0
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +26 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +34 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +2 -0
- package/dist/jobs.js.map +1 -0
- package/dist/manifest-schema.d.ts +637 -0
- package/dist/manifest-schema.d.ts.map +1 -0
- package/dist/manifest-schema.js +251 -0
- package/dist/manifest-schema.js.map +1 -0
- package/dist/manifest.d.ts +21 -55
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +468 -1
- package/dist/manifest.js.map +1 -1
- package/dist/media.d.ts +193 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +11 -0
- package/dist/media.js.map +1 -0
- package/dist/models.d.ts +35 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +2 -0
- package/dist/models.js.map +1 -0
- package/dist/network.d.ts +2 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js.map +1 -1
- package/dist/npm-package.d.ts +17 -0
- package/dist/npm-package.d.ts.map +1 -0
- package/dist/npm-package.js +38 -0
- package/dist/npm-package.js.map +1 -0
- package/dist/ocr.d.ts +78 -0
- package/dist/ocr.d.ts.map +1 -0
- package/dist/ocr.js +2 -0
- package/dist/ocr.js.map +1 -0
- package/dist/official.d.ts +219 -10
- package/dist/official.d.ts.map +1 -1
- package/dist/official.js.map +1 -1
- package/dist/permissions.d.ts +2 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +62 -1
- package/dist/permissions.js.map +1 -1
- package/dist/prompt-attachment.d.ts +30 -6
- package/dist/prompt-attachment.d.ts.map +1 -1
- package/dist/prompt-attachment.js +35 -1
- package/dist/prompt-attachment.js.map +1 -1
- package/dist/quickjs.d.ts +147 -0
- package/dist/quickjs.d.ts.map +1 -0
- package/dist/quickjs.js +2 -0
- package/dist/quickjs.js.map +1 -0
- package/dist/secrets.d.ts +27 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +2 -0
- package/dist/secrets.js.map +1 -0
- package/dist/service-provider.d.ts +62 -0
- package/dist/service-provider.d.ts.map +1 -0
- package/dist/service-provider.js +2 -0
- package/dist/service-provider.js.map +1 -0
- package/dist/storage.d.ts +46 -6
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +8 -1
- package/dist/storage.js.map +1 -1
- package/dist/ui.d.ts +341 -22
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +22 -2
- package/src/tailwind-theme.css +30 -0
- package/dist/settings.d.ts +0 -13
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js +0 -2
- package/dist/settings.js.map +0 -1
package/dist/activity-tab.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface ActivityTabContextValue {
|
|
|
6
6
|
* active conversation may belong to another project (or be null).
|
|
7
7
|
*/
|
|
8
8
|
cwd: string | null;
|
|
9
|
+
/** Whether this tab is the selected docked tab or a visible floating tab. */
|
|
10
|
+
active: boolean;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Internal: the host wraps attached activity-tab components in this context's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-tab.d.ts","sourceRoot":"","sources":["../src/activity-tab.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,uBAAuB;IACvC;;;;;OAKG;IACH,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"activity-tab.d.ts","sourceRoot":"","sources":["../src/activity-tab.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,uBAAuB;IACvC;;;;;OAKG;IACH,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,6EAA6E;IAC7E,MAAM,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,kDAAuE,CAAC;AAEzG,yEAAyE;AACzE,wBAAgB,cAAc,IAAI,uBAAuB,CAExD","sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport interface ActivityTabContextValue {\n\t/**\n\t * The cwd scope of the activity panel this tab is rendered in — the same\n\t * key the attach record uses. Do NOT substitute useActiveConversation().cwd:\n\t * on the project detail page the panel cwd is the project's, while the\n\t * active conversation may belong to another project (or be null).\n\t */\n\tcwd: string | null;\n\t/** Whether this tab is the selected docked tab or a visible floating tab. */\n\tactive: boolean;\n}\n\n/**\n * Internal: the host wraps attached activity-tab components in this context's\n * Provider. Module Federation shares this single SDK instance, so the value\n * the host provides is visible to plugin components.\n */\nexport const __ActivityTabContext = createContext<ActivityTabContextValue>({ cwd: null, active: false });\n\n/** The panel scope of the activity tab this component is rendered in. */\nexport function useActivityTab(): ActivityTabContextValue {\n\treturn useContext(__ActivityTabContext);\n}\n"]}
|
package/dist/activity-tab.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createContext, useContext } from "react";
|
|
|
4
4
|
* Provider. Module Federation shares this single SDK instance, so the value
|
|
5
5
|
* the host provides is visible to plugin components.
|
|
6
6
|
*/
|
|
7
|
-
export const __ActivityTabContext = createContext({ cwd: null });
|
|
7
|
+
export const __ActivityTabContext = createContext({ cwd: null, active: false });
|
|
8
8
|
/** The panel scope of the activity tab this component is rendered in. */
|
|
9
9
|
export function useActivityTab() {
|
|
10
10
|
return useContext(__ActivityTabContext);
|
package/dist/activity-tab.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-tab.js","sourceRoot":"","sources":["../src/activity-tab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"activity-tab.js","sourceRoot":"","sources":["../src/activity-tab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAclD;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAA0B,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AAEzG,yEAAyE;AACzE,MAAM,UAAU,cAAc,GAA4B;IACzD,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAAA,CACxC","sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport interface ActivityTabContextValue {\n\t/**\n\t * The cwd scope of the activity panel this tab is rendered in — the same\n\t * key the attach record uses. Do NOT substitute useActiveConversation().cwd:\n\t * on the project detail page the panel cwd is the project's, while the\n\t * active conversation may belong to another project (or be null).\n\t */\n\tcwd: string | null;\n\t/** Whether this tab is the selected docked tab or a visible floating tab. */\n\tactive: boolean;\n}\n\n/**\n * Internal: the host wraps attached activity-tab components in this context's\n * Provider. Module Federation shares this single SDK instance, so the value\n * the host provides is visible to plugin components.\n */\nexport const __ActivityTabContext = createContext<ActivityTabContextValue>({ cwd: null, active: false });\n\n/** The panel scope of the activity tab this component is rendered in. */\nexport function useActivityTab(): ActivityTabContextValue {\n\treturn useContext(__ActivityTabContext);\n}\n"]}
|
package/dist/agent.d.ts
CHANGED
|
@@ -26,7 +26,10 @@ export interface PluginAgentToolRegistration<TInput = unknown> {
|
|
|
26
26
|
scope_use?: readonly ConversationScenario[];
|
|
27
27
|
/** 需要的会话能力 slug(如 "knowledge");全满足才激活。一般插件无需设置。 */
|
|
28
28
|
requires?: string[];
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated 工作模式不再影响工具的可用性与顺序(ADR-0071)。字段容忍传入但被宿主忽略;
|
|
31
|
+
* 需要限定使用场景请写进 description 的反向触发段(Do NOT / Only for)。
|
|
32
|
+
*/
|
|
30
33
|
agent_mode?: readonly string[];
|
|
31
34
|
context?: {
|
|
32
35
|
conversation?: "summary" | "messages";
|
|
@@ -75,7 +78,6 @@ export interface PluginSystemPromptProviderContext {
|
|
|
75
78
|
plugin: {
|
|
76
79
|
id: string;
|
|
77
80
|
providerId: string;
|
|
78
|
-
settings: Readonly<Record<string, unknown>>;
|
|
79
81
|
};
|
|
80
82
|
session: {
|
|
81
83
|
id: string;
|
|
@@ -132,8 +134,11 @@ export interface PluginAgentActions {
|
|
|
132
134
|
setBlockEnabled(blockId: string, enabled: boolean): void;
|
|
133
135
|
};
|
|
134
136
|
tools: {
|
|
137
|
+
/** Emit a Turn-local tool effect. It applies after this handler succeeds. */
|
|
135
138
|
setEnabled(toolName: string, enabled: boolean): void;
|
|
139
|
+
/** Enable an already registered tool for subsequent model calls in this Turn. */
|
|
136
140
|
enable(toolName: string): void;
|
|
141
|
+
/** Disable an already registered tool for subsequent model calls in this Turn. */
|
|
137
142
|
disable(toolName: string): void;
|
|
138
143
|
};
|
|
139
144
|
continuation: {
|
|
@@ -145,7 +150,6 @@ export interface PluginAgentHandlerContext<TTrigger> {
|
|
|
145
150
|
plugin: {
|
|
146
151
|
id: string;
|
|
147
152
|
contributionId: string;
|
|
148
|
-
settings: Readonly<Record<string, unknown>>;
|
|
149
153
|
};
|
|
150
154
|
session: PluginSystemPromptProviderContext["session"];
|
|
151
155
|
model: PluginSystemPromptProviderContext["model"];
|
|
@@ -198,14 +202,154 @@ export interface PluginContinuationRegistration {
|
|
|
198
202
|
};
|
|
199
203
|
handler: PluginContinuationHandler;
|
|
200
204
|
}
|
|
205
|
+
export declare const PLUGIN_CODING_AGENT_HOOK_EVENT_NAMES: readonly ["SessionStart", "SessionEnd", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "PostToolUse", "PostToolUseFailure", "PreCompact", "PostCompact", "SubagentStart", "SubagentStop", "Stop"];
|
|
206
|
+
export type PluginCodingAgentHookEventName = (typeof PLUGIN_CODING_AGENT_HOOK_EVENT_NAMES)[number];
|
|
207
|
+
export type PluginCodingAgentPermissionMode = "default" | "acceptEdits" | "plan" | "dontAsk" | "bypassPermissions";
|
|
208
|
+
export interface PluginCodingAgentHookTool {
|
|
209
|
+
hostName: string;
|
|
210
|
+
kind: "function" | "shell" | "mcp" | "file-edit" | "agent" | "custom";
|
|
211
|
+
source?: {
|
|
212
|
+
ecosystem?: string;
|
|
213
|
+
serverName?: string;
|
|
214
|
+
originalName?: string;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
interface PluginCodingAgentHookEventBase {
|
|
218
|
+
sessionId: string;
|
|
219
|
+
cwd: string;
|
|
220
|
+
model: string;
|
|
221
|
+
permissionMode: PluginCodingAgentPermissionMode;
|
|
222
|
+
subagent?: {
|
|
223
|
+
agentId: string;
|
|
224
|
+
agentType: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
export type PluginCodingAgentHookEvent = (PluginCodingAgentHookEventBase & {
|
|
228
|
+
eventName: "SessionStart";
|
|
229
|
+
source: "startup" | "resume" | "clear" | "compact";
|
|
230
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
231
|
+
eventName: "SessionEnd";
|
|
232
|
+
cause: "new_session" | "switch_session" | "fork_session" | "dispose";
|
|
233
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
234
|
+
eventName: "UserPromptSubmit";
|
|
235
|
+
turnId: string;
|
|
236
|
+
prompt: string;
|
|
237
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
238
|
+
eventName: "PreToolUse";
|
|
239
|
+
turnId: string;
|
|
240
|
+
tool: PluginCodingAgentHookTool;
|
|
241
|
+
toolUseId: string;
|
|
242
|
+
toolInput: unknown;
|
|
243
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
244
|
+
eventName: "PermissionRequest";
|
|
245
|
+
turnId: string;
|
|
246
|
+
tool: PluginCodingAgentHookTool;
|
|
247
|
+
toolInput: unknown;
|
|
248
|
+
runIdSuffix: string;
|
|
249
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
250
|
+
eventName: "PostToolUse";
|
|
251
|
+
turnId: string;
|
|
252
|
+
tool: PluginCodingAgentHookTool;
|
|
253
|
+
toolUseId: string;
|
|
254
|
+
toolInput: unknown;
|
|
255
|
+
toolResponse: unknown;
|
|
256
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
257
|
+
eventName: "PostToolUseFailure";
|
|
258
|
+
turnId: string;
|
|
259
|
+
tool: PluginCodingAgentHookTool;
|
|
260
|
+
toolUseId: string;
|
|
261
|
+
toolInput: unknown;
|
|
262
|
+
error: string;
|
|
263
|
+
isInterrupt?: boolean;
|
|
264
|
+
durationMs?: number;
|
|
265
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
266
|
+
eventName: "PreCompact" | "PostCompact";
|
|
267
|
+
turnId: string;
|
|
268
|
+
trigger: "manual" | "auto";
|
|
269
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
270
|
+
eventName: "SubagentStart";
|
|
271
|
+
turnId: string;
|
|
272
|
+
agentId: string;
|
|
273
|
+
agentType: string;
|
|
274
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
275
|
+
eventName: "SubagentStop";
|
|
276
|
+
turnId: string;
|
|
277
|
+
agentId: string;
|
|
278
|
+
agentType: string;
|
|
279
|
+
stopHookActive: boolean;
|
|
280
|
+
lastAssistantMessage: string | null;
|
|
281
|
+
}) | (PluginCodingAgentHookEventBase & {
|
|
282
|
+
eventName: "Stop";
|
|
283
|
+
turnId: string;
|
|
284
|
+
stopHookActive: boolean;
|
|
285
|
+
lastAssistantMessage: string | null;
|
|
286
|
+
});
|
|
287
|
+
export type PluginCodingAgentHookEventOf<E extends PluginCodingAgentHookEventName> = Extract<PluginCodingAgentHookEvent, {
|
|
288
|
+
eventName: E;
|
|
289
|
+
}>;
|
|
290
|
+
interface PluginCodingAgentHookContinueResult {
|
|
291
|
+
action: "continue";
|
|
292
|
+
additionalContexts?: readonly string[];
|
|
293
|
+
feedbackMessage?: string;
|
|
294
|
+
}
|
|
295
|
+
type PluginCodingAgentHookTerminalResult = {
|
|
296
|
+
action: "block";
|
|
297
|
+
reason: string;
|
|
298
|
+
} | {
|
|
299
|
+
action: "stop";
|
|
300
|
+
reason?: string;
|
|
301
|
+
};
|
|
302
|
+
export type PluginCodingAgentHookResult<E extends PluginCodingAgentHookEventName> = PluginCodingAgentHookTerminalResult | (PluginCodingAgentHookContinueResult & (E extends "PreToolUse" ? {
|
|
303
|
+
updatedToolInput?: Record<string, unknown>;
|
|
304
|
+
} : object) & (E extends "PermissionRequest" ? {
|
|
305
|
+
permissionDecision?: "allow" | "deny";
|
|
306
|
+
permissionMessage?: string;
|
|
307
|
+
} : object)) | (E extends "Stop" | "SubagentStop" ? {
|
|
308
|
+
action: "continue-agent";
|
|
309
|
+
continuationFragments: readonly string[];
|
|
310
|
+
} : never);
|
|
311
|
+
export interface PluginCodingAgentHookHandlerContext<E extends PluginCodingAgentHookEventName> {
|
|
312
|
+
invocationId: string;
|
|
313
|
+
plugin: {
|
|
314
|
+
id: string;
|
|
315
|
+
contributionId: string;
|
|
316
|
+
};
|
|
317
|
+
session: {
|
|
318
|
+
id: string;
|
|
319
|
+
cwd: string;
|
|
320
|
+
scenario: ConversationScenario;
|
|
321
|
+
};
|
|
322
|
+
event: PluginCodingAgentHookEventOf<E>;
|
|
323
|
+
host: PluginAgentToolApi;
|
|
324
|
+
}
|
|
325
|
+
export type PluginCodingAgentHookHandler<E extends PluginCodingAgentHookEventName> = (context: PluginCodingAgentHookHandlerContext<E>) => void | PluginCodingAgentHookResult<E> | Promise<void | PluginCodingAgentHookResult<E>>;
|
|
326
|
+
export interface PluginCodingAgentHookRegistration<E extends PluginCodingAgentHookEventName = PluginCodingAgentHookEventName> {
|
|
327
|
+
id: string;
|
|
328
|
+
eventName: E;
|
|
329
|
+
/** Hook 是可执行贡献,必须显式声明允许出现的会话场景。 */
|
|
330
|
+
scope_use: readonly ConversationScenario[];
|
|
331
|
+
/** @deprecated 工作模式不参与 hook 触发(ADR-0071)。字段容忍传入但被宿主忽略。 */
|
|
332
|
+
agent_mode?: readonly string[];
|
|
333
|
+
/** 工具事件只匹配列出的宿主工具名;缺省/空数组表示所有工具。 */
|
|
334
|
+
toolNames?: readonly string[];
|
|
335
|
+
timeoutMs?: number;
|
|
336
|
+
handler: PluginCodingAgentHookHandler<E>;
|
|
337
|
+
}
|
|
201
338
|
export interface PluginAgentApi {
|
|
202
339
|
registerTool<TInput = unknown>(registration: PluginAgentToolRegistration<TInput>): Disposable;
|
|
203
|
-
/**
|
|
340
|
+
/**
|
|
341
|
+
* Register a provider evaluated once at the beginning of each Agent Turn.
|
|
342
|
+
* Its effects are replayed across later model calls in that Turn; changing plugin
|
|
343
|
+
* state does not re-run the provider before the next Turn.
|
|
344
|
+
*/
|
|
204
345
|
registerSystemPromptProvider(registration: PluginSystemPromptProviderRegistration): Disposable;
|
|
205
346
|
/**
|
|
206
347
|
* Register a policy consulted when the agent reaches a natural stopping point.
|
|
207
348
|
* Return null to allow the agent to stop, or a message to continue with another turn.
|
|
208
349
|
*/
|
|
209
350
|
registerContinuationProvider(registration: PluginContinuationRegistration): Disposable;
|
|
351
|
+
/** Register a typed, dynamically removable Coding Agent lifecycle hook. */
|
|
352
|
+
registerHook<E extends PluginCodingAgentHookEventName>(registration: PluginCodingAgentHookRegistration<E>): Disposable;
|
|
210
353
|
}
|
|
354
|
+
export {};
|
|
211
355
|
//# sourceMappingURL=agent.d.ts.map
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,WAAW,CAAC;IAChB,YAAY,EAAE,qBAAqB,CAAC;CACpC;AAED,MAAM,WAAW,2BAA2B,CAAC,MAAM,GAAG,OAAO;IAC5D,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAA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EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;QACvD,YAAY,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;KACtC,CAAC;IACF,OAAO,EAAE,iCAAiC,CAAC;CAC3C;AAED,MAAM,WAAW,wBAAwB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,CACvC,OAAO,EAAE,yBAAyB,CAAC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,KAC3E,wBAAwB,GAAG,IAAI,GAAG,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAC;AAEhF,MAAM,WAAW,8BAA8B;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;KAAE,CAAC;IACpD,OAAO,EAAE,yBAAyB,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC9B,YAAY,CAAC,MAAM,GAAG,OAAO,EAAE,YAAY,EAAE,2BAA2B,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;IAC9F,4DAA4D;IAC5D,4BAA4B,CAAC,YAAY,EAAE,sCAAsC,GAAG,UAAU,CAAC;IAC/F;;;OAGG;IACH,4BAA4B,CAAC,YAAY,EAAE,8BAA8B,GAAG,UAAU,CAAC;CACvF","sourcesContent":["import type { PluginConversationApi } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginFsApi } from \"./fs.js\";\nimport type { ConversationScenario } from \"./scenario.js\";\n\nexport type PluginJsonSchema = object;\n\nexport interface PluginAgentToolApi {\n\tfs: PluginFsApi;\n\tconversation: PluginConversationApi;\n}\n\nexport interface PluginAgentToolRegistration<TInput = unknown> {\n\tid: string;\n\tname?: string;\n\t/**\n\t * Host UI display name for this tool (e.g. Work-mode tool headers).\n\t * Supports `%catalogKey%` resolved against the plugin's locales; bare strings\n\t * are used as literals. Not sent to the model — use {@link description} for that.\n\t */\n\tlabel?: string;\n\tdescription: string;\n\tparameters: PluginJsonSchema;\n\ttimeoutMs?: number;\n\t/**\n\t * 允许该工具出现的对话场景 slug 列表。**fail-closed**:未声明/空数组 = 所有场景都不激活。\n\t * 插件须显式声明。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/** 需要的会话能力 slug(如 \"knowledge\");全满足才激活。一般插件无需设置。 */\n\trequires?: string[];\n\t/** 允许该工具出现的工作模式 slug(agent_mode 轴,如 \"work\"/\"coding\")。缺省/空 = 通用。见 ADR-0046。 */\n\tagent_mode?: readonly string[];\n\tcontext?: { conversation?: \"summary\" | \"messages\" };\n\thandler: PluginAgentToolHandler<TInput>;\n}\n\nexport interface PluginSystemPromptBlock {\n\tid: string;\n\tcontent: string;\n\tpriority?: number;\n\tenabled?: boolean;\n}\n\nexport type PluginDynamicSystemPromptOperation =\n\t| { type: \"addBlock\"; block: PluginSystemPromptBlock }\n\t| { type: \"replaceBlock\"; blockId: string; block: Omit<PluginSystemPromptBlock, \"id\"> }\n\t| {\n\t\t\ttype: \"updateBlock\";\n\t\t\tblockId: string;\n\t\t\tpatch: Partial<Pick<PluginSystemPromptBlock, \"content\" | \"priority\" | \"enabled\">>;\n\t }\n\t| { type: \"removeBlock\"; blockId: string }\n\t| { type: \"setBlockEnabled\"; blockId: string; enabled: boolean }\n\t| { type: \"setToolEnabled\"; toolName: string; enabled: boolean }\n\t| { type: \"requestContinuation\"; result: PluginContinuationResult };\n\nexport interface PluginSystemPromptMessage {\n\trole: string;\n\ttext: string;\n\ttimestamp?: number;\n\ttoolName?: string;\n}\n\nexport interface PluginSystemPromptProviderContext {\n\tplugin: {\n\t\tid: string;\n\t\tproviderId: string;\n\t\tsettings: Readonly<Record<string, unknown>>;\n\t};\n\tsession: {\n\t\tid: string;\n\t\tcwd: string;\n\t\tscenario: ConversationScenario;\n\t};\n\tmodel: {\n\t\tprovider: string;\n\t\tid: string;\n\t\tapi: string;\n\t\tinput: readonly string[];\n\t\tcontextWindow?: number;\n\t\tmaxTokens?: number;\n\t};\n\tconversation: {\n\t\tmessages: readonly PluginSystemPromptMessage[];\n\t\tmessageCount: number;\n\t};\n\truntime: {\n\t\tactiveToolNames: readonly string[];\n\t\tavailableToolNames: readonly string[];\n\t\trunIndex: number;\n\t};\n\ttrigger: {\n\t\tkind: \"agent-run\";\n\t\ttimestamp: number;\n\t};\n\tsystemPrompt?: {\n\t\tbase: {\n\t\t\tblocks?: readonly PluginSystemPromptBlockView[];\n\t\t\trendered?: string;\n\t\t};\n\t\tcurrent: {\n\t\t\tblocks?: readonly PluginSystemPromptBlockView[];\n\t\t\trendered?: string;\n\t\t};\n\t};\n}\n\nexport interface PluginSystemPromptBlockView extends PluginSystemPromptBlock {\n\ttype: string;\n\tsource: {\n\t\tkind: \"core\" | \"plugin\";\n\t\tpluginId?: string;\n\t};\n\tpriority: number;\n\tenabled: boolean;\n}\n\nexport interface PluginAgentActions {\n\tsystemPrompt: {\n\t\taddBlock(block: PluginSystemPromptBlock): void;\n\t\treplaceBlock(blockId: string, block: Omit<PluginSystemPromptBlock, \"id\">): void;\n\t\tupdateBlock(\n\t\t\tblockId: string,\n\t\t\tpatch: Partial<Pick<PluginSystemPromptBlock, \"content\" | \"priority\" | \"enabled\">>,\n\t\t): void;\n\t\tremoveBlock(blockId: string): void;\n\t\tsetBlockEnabled(blockId: string, enabled: boolean): void;\n\t};\n\ttools: {\n\t\tsetEnabled(toolName: string, enabled: boolean): void;\n\t\tenable(toolName: string): void;\n\t\tdisable(toolName: string): void;\n\t};\n\tcontinuation: {\n\t\trequest(result: PluginContinuationResult): void;\n\t};\n}\n\nexport interface PluginAgentHandlerContext<TTrigger> {\n\tinvocationId: string;\n\tplugin: {\n\t\tid: string;\n\t\tcontributionId: string;\n\t\tsettings: Readonly<Record<string, unknown>>;\n\t};\n\tsession: PluginSystemPromptProviderContext[\"session\"];\n\tmodel: PluginSystemPromptProviderContext[\"model\"];\n\tconversation: PluginSystemPromptProviderContext[\"conversation\"];\n\truntime: PluginSystemPromptProviderContext[\"runtime\"];\n\ttrigger: TTrigger;\n\tsystemPrompt?: PluginSystemPromptProviderContext[\"systemPrompt\"];\n\tactions: PluginAgentActions;\n\thost: PluginAgentToolApi;\n}\n\nexport type PluginAgentToolHandler<TInput = unknown> = (\n\tcontext: PluginAgentHandlerContext<{\n\t\tkind: \"tool-call\";\n\t\ttimestamp: number;\n\t\ttoolCallId: string;\n\t\ttoolId: string;\n\t\ttoolName: string;\n\t\tinput: TInput;\n\t}>,\n) => unknown | Promise<unknown>;\n\nexport type PluginSystemPromptProviderHandler = (\n\tcontext: PluginAgentHandlerContext<{ kind: \"agent-run\"; timestamp: number }>,\n) => void | PluginDynamicSystemPromptOperation[] | Promise<void | PluginDynamicSystemPromptOperation[]>;\n\nexport interface PluginSystemPromptProviderRegistration {\n\tid: string;\n\ttimeoutMs?: number;\n\t/**\n\t * Large context is opt-in. Omitted fields are not serialized across the\n\t * host/renderer boundary.\n\t */\n\tcontext?: {\n\t\tsystemPrompt?: \"none\" | \"blocks\" | \"rendered\" | \"full\";\n\t\tconversation?: \"summary\" | \"messages\";\n\t};\n\thandler: PluginSystemPromptProviderHandler;\n}\n\nexport interface PluginContinuationResult {\n\ttext: string;\n\t/** Stable key used by the host to suppress duplicate continuations in a session. */\n\tidempotencyKey?: string;\n}\n\nexport type PluginContinuationHandler = (\n\tcontext: PluginAgentHandlerContext<{ kind: \"continuation\"; timestamp: number }>,\n) => PluginContinuationResult | null | Promise<PluginContinuationResult | null>;\n\nexport interface PluginContinuationRegistration {\n\tid: string;\n\ttimeoutMs?: number;\n\tcontext?: { conversation?: \"summary\" | \"messages\" };\n\thandler: PluginContinuationHandler;\n}\n\nexport interface PluginAgentApi {\n\tregisterTool<TInput = unknown>(registration: PluginAgentToolRegistration<TInput>): Disposable;\n\t/** Register a provider evaluated before every Agent run. */\n\tregisterSystemPromptProvider(registration: PluginSystemPromptProviderRegistration): Disposable;\n\t/**\n\t * Register a policy consulted when the agent reaches a natural stopping point.\n\t * Return null to allow the agent to stop, or a message to continue with another turn.\n\t */\n\tregisterContinuationProvider(registration: PluginContinuationRegistration): Disposable;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,WAAW,CAAC;IAChB,YAAY,EAAE,qBAAqB,CAAC;CACpC;AAED,MAAM,WAAW,2BAA2B,CAAC,MAAM,GAAG,OAAO;IAC5D,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC5C,yGAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IA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IACb,iFAAmC;IACnC,SAAS,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC3C,4GAA0D;IAC1D,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,4FAAoC;IACpC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,4BAA4B,CAAC,CAAC,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,cAAc;IAC9B,YAAY,CAAC,MAAM,GAAG,OAAO,EAAE,YAAY,EAAE,2BAA2B,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;IAC9F;;;;OAIG;IACH,4BAA4B,CAAC,YAAY,EAAE,sCAAsC,GAAG,UAAU,CAAC;IAC/F;;;OAGG;IACH,4BAA4B,CAAC,YAAY,EAAE,8BAA8B,GAAG,UAAU,CAAC;IACvF,2EAA2E;IAC3E,YAAY,CAAC,CAAC,SAAS,8BAA8B,EACpD,YAAY,EAAE,iCAAiC,CAAC,CAAC,CAAC,GAChD,UAAU,CAAC;CACd","sourcesContent":["import type { PluginConversationApi } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginFsApi } from \"./fs.js\";\nimport type { ConversationScenario } from \"./scenario.js\";\n\nexport type PluginJsonSchema = object;\n\nexport interface PluginAgentToolApi {\n\tfs: PluginFsApi;\n\tconversation: PluginConversationApi;\n}\n\nexport interface PluginAgentToolRegistration<TInput = unknown> {\n\tid: string;\n\tname?: string;\n\t/**\n\t * Host UI display name for this tool (e.g. Work-mode tool headers).\n\t * Supports `%catalogKey%` resolved against the plugin's locales; bare strings\n\t * are used as literals. Not sent to the model — use {@link description} for that.\n\t */\n\tlabel?: string;\n\tdescription: string;\n\tparameters: PluginJsonSchema;\n\ttimeoutMs?: number;\n\t/**\n\t * 允许该工具出现的对话场景 slug 列表。**fail-closed**:未声明/空数组 = 所有场景都不激活。\n\t * 插件须显式声明。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/** 需要的会话能力 slug(如 \"knowledge\");全满足才激活。一般插件无需设置。 */\n\trequires?: string[];\n\t/**\n\t * @deprecated 工作模式不再影响工具的可用性与顺序(ADR-0071)。字段容忍传入但被宿主忽略;\n\t * 需要限定使用场景请写进 description 的反向触发段(Do NOT / Only for)。\n\t */\n\tagent_mode?: readonly string[];\n\tcontext?: { conversation?: \"summary\" | \"messages\" };\n\thandler: PluginAgentToolHandler<TInput>;\n}\n\nexport interface PluginSystemPromptBlock {\n\tid: string;\n\tcontent: string;\n\tpriority?: number;\n\tenabled?: boolean;\n}\n\nexport type PluginDynamicSystemPromptOperation =\n\t| { type: \"addBlock\"; block: PluginSystemPromptBlock }\n\t| { type: \"replaceBlock\"; blockId: string; block: Omit<PluginSystemPromptBlock, \"id\"> }\n\t| {\n\t\t\ttype: \"updateBlock\";\n\t\t\tblockId: string;\n\t\t\tpatch: Partial<Pick<PluginSystemPromptBlock, \"content\" | \"priority\" | \"enabled\">>;\n\t }\n\t| { type: \"removeBlock\"; blockId: string }\n\t| { type: \"setBlockEnabled\"; blockId: string; enabled: boolean }\n\t| { type: \"setToolEnabled\"; toolName: string; enabled: boolean }\n\t| { type: \"requestContinuation\"; result: PluginContinuationResult };\n\nexport interface PluginSystemPromptMessage {\n\trole: string;\n\ttext: string;\n\ttimestamp?: number;\n\ttoolName?: string;\n}\n\nexport interface PluginSystemPromptProviderContext {\n\tplugin: {\n\t\tid: string;\n\t\tproviderId: string;\n\t};\n\tsession: {\n\t\tid: string;\n\t\tcwd: string;\n\t\tscenario: ConversationScenario;\n\t};\n\tmodel: {\n\t\tprovider: string;\n\t\tid: string;\n\t\tapi: string;\n\t\tinput: readonly string[];\n\t\tcontextWindow?: number;\n\t\tmaxTokens?: number;\n\t};\n\tconversation: {\n\t\tmessages: readonly PluginSystemPromptMessage[];\n\t\tmessageCount: number;\n\t};\n\truntime: {\n\t\tactiveToolNames: readonly string[];\n\t\tavailableToolNames: readonly string[];\n\t\trunIndex: number;\n\t};\n\ttrigger: {\n\t\tkind: \"agent-run\";\n\t\ttimestamp: number;\n\t};\n\tsystemPrompt?: {\n\t\tbase: {\n\t\t\tblocks?: readonly PluginSystemPromptBlockView[];\n\t\t\trendered?: string;\n\t\t};\n\t\tcurrent: {\n\t\t\tblocks?: readonly PluginSystemPromptBlockView[];\n\t\t\trendered?: string;\n\t\t};\n\t};\n}\n\nexport interface PluginSystemPromptBlockView extends PluginSystemPromptBlock {\n\ttype: string;\n\tsource: {\n\t\tkind: \"core\" | \"plugin\";\n\t\tpluginId?: string;\n\t};\n\tpriority: number;\n\tenabled: boolean;\n}\n\nexport interface PluginAgentActions {\n\tsystemPrompt: {\n\t\taddBlock(block: PluginSystemPromptBlock): void;\n\t\treplaceBlock(blockId: string, block: Omit<PluginSystemPromptBlock, \"id\">): void;\n\t\tupdateBlock(\n\t\t\tblockId: string,\n\t\t\tpatch: Partial<Pick<PluginSystemPromptBlock, \"content\" | \"priority\" | \"enabled\">>,\n\t\t): void;\n\t\tremoveBlock(blockId: string): void;\n\t\tsetBlockEnabled(blockId: string, enabled: boolean): void;\n\t};\n\ttools: {\n\t\t/** Emit a Turn-local tool effect. It applies after this handler succeeds. */\n\t\tsetEnabled(toolName: string, enabled: boolean): void;\n\t\t/** Enable an already registered tool for subsequent model calls in this Turn. */\n\t\tenable(toolName: string): void;\n\t\t/** Disable an already registered tool for subsequent model calls in this Turn. */\n\t\tdisable(toolName: string): void;\n\t};\n\tcontinuation: {\n\t\trequest(result: PluginContinuationResult): void;\n\t};\n}\n\nexport interface PluginAgentHandlerContext<TTrigger> {\n\tinvocationId: string;\n\tplugin: {\n\t\tid: string;\n\t\tcontributionId: string;\n\t};\n\tsession: PluginSystemPromptProviderContext[\"session\"];\n\tmodel: PluginSystemPromptProviderContext[\"model\"];\n\tconversation: PluginSystemPromptProviderContext[\"conversation\"];\n\truntime: PluginSystemPromptProviderContext[\"runtime\"];\n\ttrigger: TTrigger;\n\tsystemPrompt?: PluginSystemPromptProviderContext[\"systemPrompt\"];\n\tactions: PluginAgentActions;\n\thost: PluginAgentToolApi;\n}\n\nexport type PluginAgentToolHandler<TInput = unknown> = (\n\tcontext: PluginAgentHandlerContext<{\n\t\tkind: \"tool-call\";\n\t\ttimestamp: number;\n\t\ttoolCallId: string;\n\t\ttoolId: string;\n\t\ttoolName: string;\n\t\tinput: TInput;\n\t}>,\n) => unknown | Promise<unknown>;\n\nexport type PluginSystemPromptProviderHandler = (\n\tcontext: PluginAgentHandlerContext<{ kind: \"agent-run\"; timestamp: number }>,\n) => void | PluginDynamicSystemPromptOperation[] | Promise<void | PluginDynamicSystemPromptOperation[]>;\n\nexport interface PluginSystemPromptProviderRegistration {\n\tid: string;\n\ttimeoutMs?: number;\n\t/**\n\t * Large context is opt-in. Omitted fields are not serialized across the\n\t * host/renderer boundary.\n\t */\n\tcontext?: {\n\t\tsystemPrompt?: \"none\" | \"blocks\" | \"rendered\" | \"full\";\n\t\tconversation?: \"summary\" | \"messages\";\n\t};\n\thandler: PluginSystemPromptProviderHandler;\n}\n\nexport interface PluginContinuationResult {\n\ttext: string;\n\t/** Stable key used by the host to suppress duplicate continuations in a session. */\n\tidempotencyKey?: string;\n}\n\nexport type PluginContinuationHandler = (\n\tcontext: PluginAgentHandlerContext<{ kind: \"continuation\"; timestamp: number }>,\n) => PluginContinuationResult | null | Promise<PluginContinuationResult | null>;\n\nexport interface PluginContinuationRegistration {\n\tid: string;\n\ttimeoutMs?: number;\n\tcontext?: { conversation?: \"summary\" | \"messages\" };\n\thandler: PluginContinuationHandler;\n}\n\nexport const PLUGIN_CODING_AGENT_HOOK_EVENT_NAMES = [\n\t\"SessionStart\",\n\t\"SessionEnd\",\n\t\"UserPromptSubmit\",\n\t\"PreToolUse\",\n\t\"PermissionRequest\",\n\t\"PostToolUse\",\n\t\"PostToolUseFailure\",\n\t\"PreCompact\",\n\t\"PostCompact\",\n\t\"SubagentStart\",\n\t\"SubagentStop\",\n\t\"Stop\",\n] as const;\n\nexport type PluginCodingAgentHookEventName = (typeof PLUGIN_CODING_AGENT_HOOK_EVENT_NAMES)[number];\nexport type PluginCodingAgentPermissionMode =\n\t| \"default\"\n\t| \"acceptEdits\"\n\t| \"plan\"\n\t| \"dontAsk\"\n\t| \"bypassPermissions\";\n\nexport interface PluginCodingAgentHookTool {\n\thostName: string;\n\tkind: \"function\" | \"shell\" | \"mcp\" | \"file-edit\" | \"agent\" | \"custom\";\n\tsource?: { ecosystem?: string; serverName?: string; originalName?: string };\n}\n\ninterface PluginCodingAgentHookEventBase {\n\tsessionId: string;\n\tcwd: string;\n\tmodel: string;\n\tpermissionMode: PluginCodingAgentPermissionMode;\n\tsubagent?: { agentId: string; agentType: string };\n}\n\nexport type PluginCodingAgentHookEvent =\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"SessionStart\";\n\t\t\tsource: \"startup\" | \"resume\" | \"clear\" | \"compact\";\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"SessionEnd\";\n\t\t\tcause: \"new_session\" | \"switch_session\" | \"fork_session\" | \"dispose\";\n\t\t})\n\t| (PluginCodingAgentHookEventBase & { eventName: \"UserPromptSubmit\"; turnId: string; prompt: string })\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PreToolUse\";\n\t\t\tturnId: string;\n\t\t\ttool: PluginCodingAgentHookTool;\n\t\t\ttoolUseId: string;\n\t\t\ttoolInput: unknown;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PermissionRequest\";\n\t\t\tturnId: string;\n\t\t\ttool: PluginCodingAgentHookTool;\n\t\t\ttoolInput: unknown;\n\t\t\trunIdSuffix: string;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PostToolUse\";\n\t\t\tturnId: string;\n\t\t\ttool: PluginCodingAgentHookTool;\n\t\t\ttoolUseId: string;\n\t\t\ttoolInput: unknown;\n\t\t\ttoolResponse: unknown;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PostToolUseFailure\";\n\t\t\tturnId: string;\n\t\t\ttool: PluginCodingAgentHookTool;\n\t\t\ttoolUseId: string;\n\t\t\ttoolInput: unknown;\n\t\t\terror: string;\n\t\t\tisInterrupt?: boolean;\n\t\t\tdurationMs?: number;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PreCompact\" | \"PostCompact\";\n\t\t\tturnId: string;\n\t\t\ttrigger: \"manual\" | \"auto\";\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"SubagentStart\";\n\t\t\tturnId: string;\n\t\t\tagentId: string;\n\t\t\tagentType: string;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"SubagentStop\";\n\t\t\tturnId: string;\n\t\t\tagentId: string;\n\t\t\tagentType: string;\n\t\t\tstopHookActive: boolean;\n\t\t\tlastAssistantMessage: string | null;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"Stop\";\n\t\t\tturnId: string;\n\t\t\tstopHookActive: boolean;\n\t\t\tlastAssistantMessage: string | null;\n\t\t});\n\nexport type PluginCodingAgentHookEventOf<E extends PluginCodingAgentHookEventName> = Extract<\n\tPluginCodingAgentHookEvent,\n\t{ eventName: E }\n>;\n\ninterface PluginCodingAgentHookContinueResult {\n\taction: \"continue\";\n\tadditionalContexts?: readonly string[];\n\tfeedbackMessage?: string;\n}\n\ntype PluginCodingAgentHookTerminalResult =\n\t| { action: \"block\"; reason: string }\n\t| { action: \"stop\"; reason?: string };\n\nexport type PluginCodingAgentHookResult<E extends PluginCodingAgentHookEventName> =\n\t| PluginCodingAgentHookTerminalResult\n\t| (PluginCodingAgentHookContinueResult &\n\t\t\t(E extends \"PreToolUse\" ? { updatedToolInput?: Record<string, unknown> } : object) &\n\t\t\t(E extends \"PermissionRequest\"\n\t\t\t\t? { permissionDecision?: \"allow\" | \"deny\"; permissionMessage?: string }\n\t\t\t\t: object))\n\t| (E extends \"Stop\" | \"SubagentStop\"\n\t\t\t? { action: \"continue-agent\"; continuationFragments: readonly string[] }\n\t\t\t: never);\n\nexport interface PluginCodingAgentHookHandlerContext<E extends PluginCodingAgentHookEventName> {\n\tinvocationId: string;\n\tplugin: {\n\t\tid: string;\n\t\tcontributionId: string;\n\t};\n\tsession: { id: string; cwd: string; scenario: ConversationScenario };\n\tevent: PluginCodingAgentHookEventOf<E>;\n\thost: PluginAgentToolApi;\n}\n\nexport type PluginCodingAgentHookHandler<E extends PluginCodingAgentHookEventName> = (\n\tcontext: PluginCodingAgentHookHandlerContext<E>,\n) => void | PluginCodingAgentHookResult<E> | Promise<void | PluginCodingAgentHookResult<E>>;\n\nexport interface PluginCodingAgentHookRegistration<\n\tE extends PluginCodingAgentHookEventName = PluginCodingAgentHookEventName,\n> {\n\tid: string;\n\teventName: E;\n\t/** Hook 是可执行贡献,必须显式声明允许出现的会话场景。 */\n\tscope_use: readonly ConversationScenario[];\n\t/** @deprecated 工作模式不参与 hook 触发(ADR-0071)。字段容忍传入但被宿主忽略。 */\n\tagent_mode?: readonly string[];\n\t/** 工具事件只匹配列出的宿主工具名;缺省/空数组表示所有工具。 */\n\ttoolNames?: readonly string[];\n\ttimeoutMs?: number;\n\thandler: PluginCodingAgentHookHandler<E>;\n}\n\nexport interface PluginAgentApi {\n\tregisterTool<TInput = unknown>(registration: PluginAgentToolRegistration<TInput>): Disposable;\n\t/**\n\t * Register a provider evaluated once at the beginning of each Agent Turn.\n\t * Its effects are replayed across later model calls in that Turn; changing plugin\n\t * state does not re-run the provider before the next Turn.\n\t */\n\tregisterSystemPromptProvider(registration: PluginSystemPromptProviderRegistration): Disposable;\n\t/**\n\t * Register a policy consulted when the agent reaches a natural stopping point.\n\t * Return null to allow the agent to stop, or a message to continue with another turn.\n\t */\n\tregisterContinuationProvider(registration: PluginContinuationRegistration): Disposable;\n\t/** Register a typed, dynamically removable Coding Agent lifecycle hook. */\n\tregisterHook<E extends PluginCodingAgentHookEventName>(\n\t\tregistration: PluginCodingAgentHookRegistration<E>,\n\t): Disposable;\n}\n"]}
|
package/dist/agent.js
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const PLUGIN_CODING_AGENT_HOOK_EVENT_NAMES = [
|
|
2
|
+
"SessionStart",
|
|
3
|
+
"SessionEnd",
|
|
4
|
+
"UserPromptSubmit",
|
|
5
|
+
"PreToolUse",
|
|
6
|
+
"PermissionRequest",
|
|
7
|
+
"PostToolUse",
|
|
8
|
+
"PostToolUseFailure",
|
|
9
|
+
"PreCompact",
|
|
10
|
+
"PostCompact",
|
|
11
|
+
"SubagentStart",
|
|
12
|
+
"SubagentStop",
|
|
13
|
+
"Stop",
|
|
14
|
+
];
|
|
2
15
|
//# sourceMappingURL=agent.js.map
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginConversationApi } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginFsApi } from \"./fs.js\";\nimport type { ConversationScenario } from \"./scenario.js\";\n\nexport type PluginJsonSchema = object;\n\nexport interface PluginAgentToolApi {\n\tfs: PluginFsApi;\n\tconversation: PluginConversationApi;\n}\n\nexport interface PluginAgentToolRegistration<TInput = unknown> {\n\tid: string;\n\tname?: string;\n\t/**\n\t * Host UI display name for this tool (e.g. Work-mode tool headers).\n\t * Supports `%catalogKey%` resolved against the plugin's locales; bare strings\n\t * are used as literals. Not sent to the model — use {@link description} for that.\n\t */\n\tlabel?: string;\n\tdescription: string;\n\tparameters: PluginJsonSchema;\n\ttimeoutMs?: number;\n\t/**\n\t * 允许该工具出现的对话场景 slug 列表。**fail-closed**:未声明/空数组 = 所有场景都不激活。\n\t * 插件须显式声明。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/** 需要的会话能力 slug(如 \"knowledge\");全满足才激活。一般插件无需设置。 */\n\trequires?: string[];\n\t/** 允许该工具出现的工作模式 slug(agent_mode 轴,如 \"work\"/\"coding\")。缺省/空 = 通用。见 ADR-0046。 */\n\tagent_mode?: readonly string[];\n\tcontext?: { conversation?: \"summary\" | \"messages\" };\n\thandler: PluginAgentToolHandler<TInput>;\n}\n\nexport interface PluginSystemPromptBlock {\n\tid: string;\n\tcontent: string;\n\tpriority?: number;\n\tenabled?: boolean;\n}\n\nexport type PluginDynamicSystemPromptOperation =\n\t| { type: \"addBlock\"; block: PluginSystemPromptBlock }\n\t| { type: \"replaceBlock\"; blockId: string; block: Omit<PluginSystemPromptBlock, \"id\"> }\n\t| {\n\t\t\ttype: \"updateBlock\";\n\t\t\tblockId: string;\n\t\t\tpatch: Partial<Pick<PluginSystemPromptBlock, \"content\" | \"priority\" | \"enabled\">>;\n\t }\n\t| { type: \"removeBlock\"; blockId: string }\n\t| { type: \"setBlockEnabled\"; blockId: string; enabled: boolean }\n\t| { type: \"setToolEnabled\"; toolName: string; enabled: boolean }\n\t| { type: \"requestContinuation\"; result: PluginContinuationResult };\n\nexport interface PluginSystemPromptMessage {\n\trole: string;\n\ttext: string;\n\ttimestamp?: number;\n\ttoolName?: string;\n}\n\nexport interface PluginSystemPromptProviderContext {\n\tplugin: {\n\t\tid: string;\n\t\tproviderId: string;\n\t\tsettings: Readonly<Record<string, unknown>>;\n\t};\n\tsession: {\n\t\tid: string;\n\t\tcwd: string;\n\t\tscenario: ConversationScenario;\n\t};\n\tmodel: {\n\t\tprovider: string;\n\t\tid: string;\n\t\tapi: string;\n\t\tinput: readonly string[];\n\t\tcontextWindow?: number;\n\t\tmaxTokens?: number;\n\t};\n\tconversation: {\n\t\tmessages: readonly PluginSystemPromptMessage[];\n\t\tmessageCount: number;\n\t};\n\truntime: {\n\t\tactiveToolNames: readonly string[];\n\t\tavailableToolNames: readonly string[];\n\t\trunIndex: number;\n\t};\n\ttrigger: {\n\t\tkind: \"agent-run\";\n\t\ttimestamp: number;\n\t};\n\tsystemPrompt?: {\n\t\tbase: {\n\t\t\tblocks?: readonly PluginSystemPromptBlockView[];\n\t\t\trendered?: string;\n\t\t};\n\t\tcurrent: {\n\t\t\tblocks?: readonly PluginSystemPromptBlockView[];\n\t\t\trendered?: string;\n\t\t};\n\t};\n}\n\nexport interface PluginSystemPromptBlockView extends PluginSystemPromptBlock {\n\ttype: string;\n\tsource: {\n\t\tkind: \"core\" | \"plugin\";\n\t\tpluginId?: string;\n\t};\n\tpriority: number;\n\tenabled: boolean;\n}\n\nexport interface PluginAgentActions {\n\tsystemPrompt: {\n\t\taddBlock(block: PluginSystemPromptBlock): void;\n\t\treplaceBlock(blockId: string, block: Omit<PluginSystemPromptBlock, \"id\">): void;\n\t\tupdateBlock(\n\t\t\tblockId: string,\n\t\t\tpatch: Partial<Pick<PluginSystemPromptBlock, \"content\" | \"priority\" | \"enabled\">>,\n\t\t): void;\n\t\tremoveBlock(blockId: string): void;\n\t\tsetBlockEnabled(blockId: string, enabled: boolean): void;\n\t};\n\ttools: {\n\t\tsetEnabled(toolName: string, enabled: boolean): void;\n\t\tenable(toolName: string): void;\n\t\tdisable(toolName: string): void;\n\t};\n\tcontinuation: {\n\t\trequest(result: PluginContinuationResult): void;\n\t};\n}\n\nexport interface PluginAgentHandlerContext<TTrigger> {\n\tinvocationId: string;\n\tplugin: {\n\t\tid: string;\n\t\tcontributionId: string;\n\t\tsettings: Readonly<Record<string, unknown>>;\n\t};\n\tsession: PluginSystemPromptProviderContext[\"session\"];\n\tmodel: PluginSystemPromptProviderContext[\"model\"];\n\tconversation: PluginSystemPromptProviderContext[\"conversation\"];\n\truntime: PluginSystemPromptProviderContext[\"runtime\"];\n\ttrigger: TTrigger;\n\tsystemPrompt?: PluginSystemPromptProviderContext[\"systemPrompt\"];\n\tactions: PluginAgentActions;\n\thost: PluginAgentToolApi;\n}\n\nexport type PluginAgentToolHandler<TInput = unknown> = (\n\tcontext: PluginAgentHandlerContext<{\n\t\tkind: \"tool-call\";\n\t\ttimestamp: number;\n\t\ttoolCallId: string;\n\t\ttoolId: string;\n\t\ttoolName: string;\n\t\tinput: TInput;\n\t}>,\n) => unknown | Promise<unknown>;\n\nexport type PluginSystemPromptProviderHandler = (\n\tcontext: PluginAgentHandlerContext<{ kind: \"agent-run\"; timestamp: number }>,\n) => void | PluginDynamicSystemPromptOperation[] | Promise<void | PluginDynamicSystemPromptOperation[]>;\n\nexport interface PluginSystemPromptProviderRegistration {\n\tid: string;\n\ttimeoutMs?: number;\n\t/**\n\t * Large context is opt-in. Omitted fields are not serialized across the\n\t * host/renderer boundary.\n\t */\n\tcontext?: {\n\t\tsystemPrompt?: \"none\" | \"blocks\" | \"rendered\" | \"full\";\n\t\tconversation?: \"summary\" | \"messages\";\n\t};\n\thandler: PluginSystemPromptProviderHandler;\n}\n\nexport interface PluginContinuationResult {\n\ttext: string;\n\t/** Stable key used by the host to suppress duplicate continuations in a session. */\n\tidempotencyKey?: string;\n}\n\nexport type PluginContinuationHandler = (\n\tcontext: PluginAgentHandlerContext<{ kind: \"continuation\"; timestamp: number }>,\n) => PluginContinuationResult | null | Promise<PluginContinuationResult | null>;\n\nexport interface PluginContinuationRegistration {\n\tid: string;\n\ttimeoutMs?: number;\n\tcontext?: { conversation?: \"summary\" | \"messages\" };\n\thandler: PluginContinuationHandler;\n}\n\nexport interface PluginAgentApi {\n\tregisterTool<TInput = unknown>(registration: PluginAgentToolRegistration<TInput>): Disposable;\n\t/** Register a provider evaluated before every Agent run. */\n\tregisterSystemPromptProvider(registration: PluginSystemPromptProviderRegistration): Disposable;\n\t/**\n\t * Register a policy consulted when the agent reaches a natural stopping point.\n\t * Return null to allow the agent to stop, or a message to continue with another turn.\n\t */\n\tregisterContinuationProvider(registration: PluginContinuationRegistration): Disposable;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AA8MA,MAAM,CAAC,MAAM,oCAAoC,GAAG;IACnD,cAAc;IACd,YAAY;IACZ,kBAAkB;IAClB,YAAY;IACZ,mBAAmB;IACnB,aAAa;IACb,oBAAoB;IACpB,YAAY;IACZ,aAAa;IACb,eAAe;IACf,cAAc;IACd,MAAM;CACG,CAAC","sourcesContent":["import type { PluginConversationApi } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginFsApi } from \"./fs.js\";\nimport type { ConversationScenario } from \"./scenario.js\";\n\nexport type PluginJsonSchema = object;\n\nexport interface PluginAgentToolApi {\n\tfs: PluginFsApi;\n\tconversation: PluginConversationApi;\n}\n\nexport interface PluginAgentToolRegistration<TInput = unknown> {\n\tid: string;\n\tname?: string;\n\t/**\n\t * Host UI display name for this tool (e.g. Work-mode tool headers).\n\t * Supports `%catalogKey%` resolved against the plugin's locales; bare strings\n\t * are used as literals. Not sent to the model — use {@link description} for that.\n\t */\n\tlabel?: string;\n\tdescription: string;\n\tparameters: PluginJsonSchema;\n\ttimeoutMs?: number;\n\t/**\n\t * 允许该工具出现的对话场景 slug 列表。**fail-closed**:未声明/空数组 = 所有场景都不激活。\n\t * 插件须显式声明。\n\t */\n\tscope_use?: readonly ConversationScenario[];\n\t/** 需要的会话能力 slug(如 \"knowledge\");全满足才激活。一般插件无需设置。 */\n\trequires?: string[];\n\t/**\n\t * @deprecated 工作模式不再影响工具的可用性与顺序(ADR-0071)。字段容忍传入但被宿主忽略;\n\t * 需要限定使用场景请写进 description 的反向触发段(Do NOT / Only for)。\n\t */\n\tagent_mode?: readonly string[];\n\tcontext?: { conversation?: \"summary\" | \"messages\" };\n\thandler: PluginAgentToolHandler<TInput>;\n}\n\nexport interface PluginSystemPromptBlock {\n\tid: string;\n\tcontent: string;\n\tpriority?: number;\n\tenabled?: boolean;\n}\n\nexport type PluginDynamicSystemPromptOperation =\n\t| { type: \"addBlock\"; block: PluginSystemPromptBlock }\n\t| { type: \"replaceBlock\"; blockId: string; block: Omit<PluginSystemPromptBlock, \"id\"> }\n\t| {\n\t\t\ttype: \"updateBlock\";\n\t\t\tblockId: string;\n\t\t\tpatch: Partial<Pick<PluginSystemPromptBlock, \"content\" | \"priority\" | \"enabled\">>;\n\t }\n\t| { type: \"removeBlock\"; blockId: string }\n\t| { type: \"setBlockEnabled\"; blockId: string; enabled: boolean }\n\t| { type: \"setToolEnabled\"; toolName: string; enabled: boolean }\n\t| { type: \"requestContinuation\"; result: PluginContinuationResult };\n\nexport interface PluginSystemPromptMessage {\n\trole: string;\n\ttext: string;\n\ttimestamp?: number;\n\ttoolName?: string;\n}\n\nexport interface PluginSystemPromptProviderContext {\n\tplugin: {\n\t\tid: string;\n\t\tproviderId: string;\n\t};\n\tsession: {\n\t\tid: string;\n\t\tcwd: string;\n\t\tscenario: ConversationScenario;\n\t};\n\tmodel: {\n\t\tprovider: string;\n\t\tid: string;\n\t\tapi: string;\n\t\tinput: readonly string[];\n\t\tcontextWindow?: number;\n\t\tmaxTokens?: number;\n\t};\n\tconversation: {\n\t\tmessages: readonly PluginSystemPromptMessage[];\n\t\tmessageCount: number;\n\t};\n\truntime: {\n\t\tactiveToolNames: readonly string[];\n\t\tavailableToolNames: readonly string[];\n\t\trunIndex: number;\n\t};\n\ttrigger: {\n\t\tkind: \"agent-run\";\n\t\ttimestamp: number;\n\t};\n\tsystemPrompt?: {\n\t\tbase: {\n\t\t\tblocks?: readonly PluginSystemPromptBlockView[];\n\t\t\trendered?: string;\n\t\t};\n\t\tcurrent: {\n\t\t\tblocks?: readonly PluginSystemPromptBlockView[];\n\t\t\trendered?: string;\n\t\t};\n\t};\n}\n\nexport interface PluginSystemPromptBlockView extends PluginSystemPromptBlock {\n\ttype: string;\n\tsource: {\n\t\tkind: \"core\" | \"plugin\";\n\t\tpluginId?: string;\n\t};\n\tpriority: number;\n\tenabled: boolean;\n}\n\nexport interface PluginAgentActions {\n\tsystemPrompt: {\n\t\taddBlock(block: PluginSystemPromptBlock): void;\n\t\treplaceBlock(blockId: string, block: Omit<PluginSystemPromptBlock, \"id\">): void;\n\t\tupdateBlock(\n\t\t\tblockId: string,\n\t\t\tpatch: Partial<Pick<PluginSystemPromptBlock, \"content\" | \"priority\" | \"enabled\">>,\n\t\t): void;\n\t\tremoveBlock(blockId: string): void;\n\t\tsetBlockEnabled(blockId: string, enabled: boolean): void;\n\t};\n\ttools: {\n\t\t/** Emit a Turn-local tool effect. It applies after this handler succeeds. */\n\t\tsetEnabled(toolName: string, enabled: boolean): void;\n\t\t/** Enable an already registered tool for subsequent model calls in this Turn. */\n\t\tenable(toolName: string): void;\n\t\t/** Disable an already registered tool for subsequent model calls in this Turn. */\n\t\tdisable(toolName: string): void;\n\t};\n\tcontinuation: {\n\t\trequest(result: PluginContinuationResult): void;\n\t};\n}\n\nexport interface PluginAgentHandlerContext<TTrigger> {\n\tinvocationId: string;\n\tplugin: {\n\t\tid: string;\n\t\tcontributionId: string;\n\t};\n\tsession: PluginSystemPromptProviderContext[\"session\"];\n\tmodel: PluginSystemPromptProviderContext[\"model\"];\n\tconversation: PluginSystemPromptProviderContext[\"conversation\"];\n\truntime: PluginSystemPromptProviderContext[\"runtime\"];\n\ttrigger: TTrigger;\n\tsystemPrompt?: PluginSystemPromptProviderContext[\"systemPrompt\"];\n\tactions: PluginAgentActions;\n\thost: PluginAgentToolApi;\n}\n\nexport type PluginAgentToolHandler<TInput = unknown> = (\n\tcontext: PluginAgentHandlerContext<{\n\t\tkind: \"tool-call\";\n\t\ttimestamp: number;\n\t\ttoolCallId: string;\n\t\ttoolId: string;\n\t\ttoolName: string;\n\t\tinput: TInput;\n\t}>,\n) => unknown | Promise<unknown>;\n\nexport type PluginSystemPromptProviderHandler = (\n\tcontext: PluginAgentHandlerContext<{ kind: \"agent-run\"; timestamp: number }>,\n) => void | PluginDynamicSystemPromptOperation[] | Promise<void | PluginDynamicSystemPromptOperation[]>;\n\nexport interface PluginSystemPromptProviderRegistration {\n\tid: string;\n\ttimeoutMs?: number;\n\t/**\n\t * Large context is opt-in. Omitted fields are not serialized across the\n\t * host/renderer boundary.\n\t */\n\tcontext?: {\n\t\tsystemPrompt?: \"none\" | \"blocks\" | \"rendered\" | \"full\";\n\t\tconversation?: \"summary\" | \"messages\";\n\t};\n\thandler: PluginSystemPromptProviderHandler;\n}\n\nexport interface PluginContinuationResult {\n\ttext: string;\n\t/** Stable key used by the host to suppress duplicate continuations in a session. */\n\tidempotencyKey?: string;\n}\n\nexport type PluginContinuationHandler = (\n\tcontext: PluginAgentHandlerContext<{ kind: \"continuation\"; timestamp: number }>,\n) => PluginContinuationResult | null | Promise<PluginContinuationResult | null>;\n\nexport interface PluginContinuationRegistration {\n\tid: string;\n\ttimeoutMs?: number;\n\tcontext?: { conversation?: \"summary\" | \"messages\" };\n\thandler: PluginContinuationHandler;\n}\n\nexport const PLUGIN_CODING_AGENT_HOOK_EVENT_NAMES = [\n\t\"SessionStart\",\n\t\"SessionEnd\",\n\t\"UserPromptSubmit\",\n\t\"PreToolUse\",\n\t\"PermissionRequest\",\n\t\"PostToolUse\",\n\t\"PostToolUseFailure\",\n\t\"PreCompact\",\n\t\"PostCompact\",\n\t\"SubagentStart\",\n\t\"SubagentStop\",\n\t\"Stop\",\n] as const;\n\nexport type PluginCodingAgentHookEventName = (typeof PLUGIN_CODING_AGENT_HOOK_EVENT_NAMES)[number];\nexport type PluginCodingAgentPermissionMode =\n\t| \"default\"\n\t| \"acceptEdits\"\n\t| \"plan\"\n\t| \"dontAsk\"\n\t| \"bypassPermissions\";\n\nexport interface PluginCodingAgentHookTool {\n\thostName: string;\n\tkind: \"function\" | \"shell\" | \"mcp\" | \"file-edit\" | \"agent\" | \"custom\";\n\tsource?: { ecosystem?: string; serverName?: string; originalName?: string };\n}\n\ninterface PluginCodingAgentHookEventBase {\n\tsessionId: string;\n\tcwd: string;\n\tmodel: string;\n\tpermissionMode: PluginCodingAgentPermissionMode;\n\tsubagent?: { agentId: string; agentType: string };\n}\n\nexport type PluginCodingAgentHookEvent =\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"SessionStart\";\n\t\t\tsource: \"startup\" | \"resume\" | \"clear\" | \"compact\";\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"SessionEnd\";\n\t\t\tcause: \"new_session\" | \"switch_session\" | \"fork_session\" | \"dispose\";\n\t\t})\n\t| (PluginCodingAgentHookEventBase & { eventName: \"UserPromptSubmit\"; turnId: string; prompt: string })\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PreToolUse\";\n\t\t\tturnId: string;\n\t\t\ttool: PluginCodingAgentHookTool;\n\t\t\ttoolUseId: string;\n\t\t\ttoolInput: unknown;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PermissionRequest\";\n\t\t\tturnId: string;\n\t\t\ttool: PluginCodingAgentHookTool;\n\t\t\ttoolInput: unknown;\n\t\t\trunIdSuffix: string;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PostToolUse\";\n\t\t\tturnId: string;\n\t\t\ttool: PluginCodingAgentHookTool;\n\t\t\ttoolUseId: string;\n\t\t\ttoolInput: unknown;\n\t\t\ttoolResponse: unknown;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PostToolUseFailure\";\n\t\t\tturnId: string;\n\t\t\ttool: PluginCodingAgentHookTool;\n\t\t\ttoolUseId: string;\n\t\t\ttoolInput: unknown;\n\t\t\terror: string;\n\t\t\tisInterrupt?: boolean;\n\t\t\tdurationMs?: number;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"PreCompact\" | \"PostCompact\";\n\t\t\tturnId: string;\n\t\t\ttrigger: \"manual\" | \"auto\";\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"SubagentStart\";\n\t\t\tturnId: string;\n\t\t\tagentId: string;\n\t\t\tagentType: string;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"SubagentStop\";\n\t\t\tturnId: string;\n\t\t\tagentId: string;\n\t\t\tagentType: string;\n\t\t\tstopHookActive: boolean;\n\t\t\tlastAssistantMessage: string | null;\n\t\t})\n\t| (PluginCodingAgentHookEventBase & {\n\t\t\teventName: \"Stop\";\n\t\t\tturnId: string;\n\t\t\tstopHookActive: boolean;\n\t\t\tlastAssistantMessage: string | null;\n\t\t});\n\nexport type PluginCodingAgentHookEventOf<E extends PluginCodingAgentHookEventName> = Extract<\n\tPluginCodingAgentHookEvent,\n\t{ eventName: E }\n>;\n\ninterface PluginCodingAgentHookContinueResult {\n\taction: \"continue\";\n\tadditionalContexts?: readonly string[];\n\tfeedbackMessage?: string;\n}\n\ntype PluginCodingAgentHookTerminalResult =\n\t| { action: \"block\"; reason: string }\n\t| { action: \"stop\"; reason?: string };\n\nexport type PluginCodingAgentHookResult<E extends PluginCodingAgentHookEventName> =\n\t| PluginCodingAgentHookTerminalResult\n\t| (PluginCodingAgentHookContinueResult &\n\t\t\t(E extends \"PreToolUse\" ? { updatedToolInput?: Record<string, unknown> } : object) &\n\t\t\t(E extends \"PermissionRequest\"\n\t\t\t\t? { permissionDecision?: \"allow\" | \"deny\"; permissionMessage?: string }\n\t\t\t\t: object))\n\t| (E extends \"Stop\" | \"SubagentStop\"\n\t\t\t? { action: \"continue-agent\"; continuationFragments: readonly string[] }\n\t\t\t: never);\n\nexport interface PluginCodingAgentHookHandlerContext<E extends PluginCodingAgentHookEventName> {\n\tinvocationId: string;\n\tplugin: {\n\t\tid: string;\n\t\tcontributionId: string;\n\t};\n\tsession: { id: string; cwd: string; scenario: ConversationScenario };\n\tevent: PluginCodingAgentHookEventOf<E>;\n\thost: PluginAgentToolApi;\n}\n\nexport type PluginCodingAgentHookHandler<E extends PluginCodingAgentHookEventName> = (\n\tcontext: PluginCodingAgentHookHandlerContext<E>,\n) => void | PluginCodingAgentHookResult<E> | Promise<void | PluginCodingAgentHookResult<E>>;\n\nexport interface PluginCodingAgentHookRegistration<\n\tE extends PluginCodingAgentHookEventName = PluginCodingAgentHookEventName,\n> {\n\tid: string;\n\teventName: E;\n\t/** Hook 是可执行贡献,必须显式声明允许出现的会话场景。 */\n\tscope_use: readonly ConversationScenario[];\n\t/** @deprecated 工作模式不参与 hook 触发(ADR-0071)。字段容忍传入但被宿主忽略。 */\n\tagent_mode?: readonly string[];\n\t/** 工具事件只匹配列出的宿主工具名;缺省/空数组表示所有工具。 */\n\ttoolNames?: readonly string[];\n\ttimeoutMs?: number;\n\thandler: PluginCodingAgentHookHandler<E>;\n}\n\nexport interface PluginAgentApi {\n\tregisterTool<TInput = unknown>(registration: PluginAgentToolRegistration<TInput>): Disposable;\n\t/**\n\t * Register a provider evaluated once at the beginning of each Agent Turn.\n\t * Its effects are replayed across later model calls in that Turn; changing plugin\n\t * state does not re-run the provider before the next Turn.\n\t */\n\tregisterSystemPromptProvider(registration: PluginSystemPromptProviderRegistration): Disposable;\n\t/**\n\t * Register a policy consulted when the agent reaches a natural stopping point.\n\t * Return null to allow the agent to stop, or a message to continue with another turn.\n\t */\n\tregisterContinuationProvider(registration: PluginContinuationRegistration): Disposable;\n\t/** Register a typed, dynamically removable Coding Agent lifecycle hook. */\n\tregisterHook<E extends PluginCodingAgentHookEventName>(\n\t\tregistration: PluginCodingAgentHookRegistration<E>,\n\t): Disposable;\n}\n"]}
|
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export interface PluginAiModel {
|
|
2
|
+
modelKey: string;
|
|
3
|
+
provider: string;
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
api: string;
|
|
7
|
+
reasoning: boolean;
|
|
8
|
+
input: Array<"text" | "image">;
|
|
9
|
+
contextWindow: number;
|
|
10
|
+
maxTokens?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface PluginAiModelListResult {
|
|
13
|
+
defaultModel: string | null;
|
|
14
|
+
models: PluginAiModel[];
|
|
15
|
+
}
|
|
16
|
+
export interface PluginAiCompleteRequest {
|
|
17
|
+
modelKey?: string;
|
|
18
|
+
systemPrompt?: string;
|
|
19
|
+
prompt: string;
|
|
20
|
+
temperature?: number;
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
reasoning?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface PluginAiUsage {
|
|
25
|
+
inputTokens: number;
|
|
26
|
+
outputTokens: number;
|
|
27
|
+
totalTokens: number;
|
|
28
|
+
}
|
|
29
|
+
export interface PluginAiToolCall {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
arguments: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface PluginAiChatUserMessage {
|
|
35
|
+
role: "user";
|
|
36
|
+
content: string;
|
|
37
|
+
}
|
|
38
|
+
export interface PluginAiChatAssistantMessage {
|
|
39
|
+
role: "assistant";
|
|
40
|
+
content: string;
|
|
41
|
+
toolCalls?: PluginAiToolCall[];
|
|
42
|
+
}
|
|
43
|
+
export interface PluginAiChatToolResultMessage {
|
|
44
|
+
role: "toolResult";
|
|
45
|
+
toolCallId: string;
|
|
46
|
+
toolName: string;
|
|
47
|
+
content: string;
|
|
48
|
+
isError?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export type PluginAiChatMessage = PluginAiChatUserMessage | PluginAiChatAssistantMessage | PluginAiChatToolResultMessage;
|
|
51
|
+
/** Tool visible only to this chat request. The plugin executes matching tool calls itself. */
|
|
52
|
+
export interface PluginAiChatTool {
|
|
53
|
+
name: string;
|
|
54
|
+
description: string;
|
|
55
|
+
/** JSON Schema object describing the tool arguments. */
|
|
56
|
+
parameters: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
export interface PluginAiChatRequest {
|
|
59
|
+
modelKey?: string;
|
|
60
|
+
systemPrompt?: string;
|
|
61
|
+
/** Full conversation transcript, oldest first. The host keeps no chat state between calls. */
|
|
62
|
+
messages: PluginAiChatMessage[];
|
|
63
|
+
tools?: PluginAiChatTool[];
|
|
64
|
+
temperature?: number;
|
|
65
|
+
maxTokens?: number;
|
|
66
|
+
reasoning?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface PluginAiChatResult {
|
|
69
|
+
modelKey: string;
|
|
70
|
+
text: string;
|
|
71
|
+
/** Pending tool calls the plugin must execute and answer via `toolResult` messages. */
|
|
72
|
+
toolCalls: PluginAiToolCall[];
|
|
73
|
+
stopReason: "stop" | "length" | "toolUse";
|
|
74
|
+
usage: PluginAiUsage;
|
|
75
|
+
}
|
|
76
|
+
export interface PluginAiCompleteResult {
|
|
77
|
+
modelKey: string;
|
|
78
|
+
text: string;
|
|
79
|
+
stopReason: "stop" | "length";
|
|
80
|
+
usage: PluginAiUsage;
|
|
81
|
+
}
|
|
82
|
+
export interface PluginAiTextDeltaEvent {
|
|
83
|
+
/** Newly generated text in this event. */
|
|
84
|
+
delta: string;
|
|
85
|
+
/** Complete text generated by this request so far. */
|
|
86
|
+
text: string;
|
|
87
|
+
}
|
|
88
|
+
export interface PluginAiStreamOptions {
|
|
89
|
+
/** Cancels the provider request and rejects the returned promise when aborted. */
|
|
90
|
+
signal?: AbortSignal;
|
|
91
|
+
onTextDelta?(event: PluginAiTextDeltaEvent): void;
|
|
92
|
+
}
|
|
93
|
+
/** Host-managed text inference. Provider credentials never enter the plugin runtime. */
|
|
94
|
+
export interface PluginAiApi {
|
|
95
|
+
listModels(): Promise<PluginAiModelListResult>;
|
|
96
|
+
complete(request: PluginAiCompleteRequest): Promise<PluginAiCompleteResult>;
|
|
97
|
+
/** Streams one assistant response while resolving to the same final contract as complete(). */
|
|
98
|
+
stream(request: PluginAiCompleteRequest, options?: PluginAiStreamOptions): Promise<PluginAiCompleteResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Stateless multi-turn completion. The plugin owns and persists the transcript;
|
|
101
|
+
* each call sends the full message history (optionally with plugin-internal tools)
|
|
102
|
+
* and receives the next assistant turn. Requires the `ai.complete` permission.
|
|
103
|
+
*/
|
|
104
|
+
chat(request: PluginAiChatRequest): Promise<PluginAiChatResult>;
|
|
105
|
+
}
|
|
106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AAC;IAC9B,KAAK,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACtC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,qBAAqB;IACrC,kFAAkF;IAClF,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,WAAW,CAAC,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAClD;AAED,wFAAwF;AACxF,MAAM,WAAW,WAAW;IAC3B,UAAU,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC5E,+FAA+F;IAC/F,MAAM,CAAC,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC3G;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChE","sourcesContent":["export interface PluginAiModel {\n\tmodelKey: string;\n\tprovider: string;\n\tid: string;\n\tname: string;\n\tapi: string;\n\treasoning: boolean;\n\tinput: Array<\"text\" | \"image\">;\n\tcontextWindow: number;\n\tmaxTokens?: number;\n}\n\nexport interface PluginAiModelListResult {\n\tdefaultModel: string | null;\n\tmodels: PluginAiModel[];\n}\n\nexport interface PluginAiCompleteRequest {\n\tmodelKey?: string;\n\tsystemPrompt?: string;\n\tprompt: string;\n\ttemperature?: number;\n\tmaxTokens?: number;\n\treasoning?: string;\n}\n\nexport interface PluginAiUsage {\n\tinputTokens: number;\n\toutputTokens: number;\n\ttotalTokens: number;\n}\n\nexport interface PluginAiToolCall {\n\tid: string;\n\tname: string;\n\targuments: Record<string, unknown>;\n}\n\nexport interface PluginAiChatUserMessage {\n\trole: \"user\";\n\tcontent: string;\n}\n\nexport interface PluginAiChatAssistantMessage {\n\trole: \"assistant\";\n\tcontent: string;\n\ttoolCalls?: PluginAiToolCall[];\n}\n\nexport interface PluginAiChatToolResultMessage {\n\trole: \"toolResult\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tcontent: string;\n\tisError?: boolean;\n}\n\nexport type PluginAiChatMessage =\n\t| PluginAiChatUserMessage\n\t| PluginAiChatAssistantMessage\n\t| PluginAiChatToolResultMessage;\n\n/** Tool visible only to this chat request. The plugin executes matching tool calls itself. */\nexport interface PluginAiChatTool {\n\tname: string;\n\tdescription: string;\n\t/** JSON Schema object describing the tool arguments. */\n\tparameters: Record<string, unknown>;\n}\n\nexport interface PluginAiChatRequest {\n\tmodelKey?: string;\n\tsystemPrompt?: string;\n\t/** Full conversation transcript, oldest first. The host keeps no chat state between calls. */\n\tmessages: PluginAiChatMessage[];\n\ttools?: PluginAiChatTool[];\n\ttemperature?: number;\n\tmaxTokens?: number;\n\treasoning?: string;\n}\n\nexport interface PluginAiChatResult {\n\tmodelKey: string;\n\ttext: string;\n\t/** Pending tool calls the plugin must execute and answer via `toolResult` messages. */\n\ttoolCalls: PluginAiToolCall[];\n\tstopReason: \"stop\" | \"length\" | \"toolUse\";\n\tusage: PluginAiUsage;\n}\n\nexport interface PluginAiCompleteResult {\n\tmodelKey: string;\n\ttext: string;\n\tstopReason: \"stop\" | \"length\";\n\tusage: PluginAiUsage;\n}\n\nexport interface PluginAiTextDeltaEvent {\n\t/** Newly generated text in this event. */\n\tdelta: string;\n\t/** Complete text generated by this request so far. */\n\ttext: string;\n}\n\nexport interface PluginAiStreamOptions {\n\t/** Cancels the provider request and rejects the returned promise when aborted. */\n\tsignal?: AbortSignal;\n\tonTextDelta?(event: PluginAiTextDeltaEvent): void;\n}\n\n/** Host-managed text inference. Provider credentials never enter the plugin runtime. */\nexport interface PluginAiApi {\n\tlistModels(): Promise<PluginAiModelListResult>;\n\tcomplete(request: PluginAiCompleteRequest): Promise<PluginAiCompleteResult>;\n\t/** Streams one assistant response while resolving to the same final contract as complete(). */\n\tstream(request: PluginAiCompleteRequest, options?: PluginAiStreamOptions): Promise<PluginAiCompleteResult>;\n\t/**\n\t * Stateless multi-turn completion. The plugin owns and persists the transcript;\n\t * each call sends the full message history (optionally with plugin-internal tools)\n\t * and receives the next assistant turn. Requires the `ai.complete` permission.\n\t */\n\tchat(request: PluginAiChatRequest): Promise<PluginAiChatResult>;\n}\n"]}
|
package/dist/ai.js
ADDED
package/dist/ai.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"","sourcesContent":["export interface PluginAiModel {\n\tmodelKey: string;\n\tprovider: string;\n\tid: string;\n\tname: string;\n\tapi: string;\n\treasoning: boolean;\n\tinput: Array<\"text\" | \"image\">;\n\tcontextWindow: number;\n\tmaxTokens?: number;\n}\n\nexport interface PluginAiModelListResult {\n\tdefaultModel: string | null;\n\tmodels: PluginAiModel[];\n}\n\nexport interface PluginAiCompleteRequest {\n\tmodelKey?: string;\n\tsystemPrompt?: string;\n\tprompt: string;\n\ttemperature?: number;\n\tmaxTokens?: number;\n\treasoning?: string;\n}\n\nexport interface PluginAiUsage {\n\tinputTokens: number;\n\toutputTokens: number;\n\ttotalTokens: number;\n}\n\nexport interface PluginAiToolCall {\n\tid: string;\n\tname: string;\n\targuments: Record<string, unknown>;\n}\n\nexport interface PluginAiChatUserMessage {\n\trole: \"user\";\n\tcontent: string;\n}\n\nexport interface PluginAiChatAssistantMessage {\n\trole: \"assistant\";\n\tcontent: string;\n\ttoolCalls?: PluginAiToolCall[];\n}\n\nexport interface PluginAiChatToolResultMessage {\n\trole: \"toolResult\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tcontent: string;\n\tisError?: boolean;\n}\n\nexport type PluginAiChatMessage =\n\t| PluginAiChatUserMessage\n\t| PluginAiChatAssistantMessage\n\t| PluginAiChatToolResultMessage;\n\n/** Tool visible only to this chat request. The plugin executes matching tool calls itself. */\nexport interface PluginAiChatTool {\n\tname: string;\n\tdescription: string;\n\t/** JSON Schema object describing the tool arguments. */\n\tparameters: Record<string, unknown>;\n}\n\nexport interface PluginAiChatRequest {\n\tmodelKey?: string;\n\tsystemPrompt?: string;\n\t/** Full conversation transcript, oldest first. The host keeps no chat state between calls. */\n\tmessages: PluginAiChatMessage[];\n\ttools?: PluginAiChatTool[];\n\ttemperature?: number;\n\tmaxTokens?: number;\n\treasoning?: string;\n}\n\nexport interface PluginAiChatResult {\n\tmodelKey: string;\n\ttext: string;\n\t/** Pending tool calls the plugin must execute and answer via `toolResult` messages. */\n\ttoolCalls: PluginAiToolCall[];\n\tstopReason: \"stop\" | \"length\" | \"toolUse\";\n\tusage: PluginAiUsage;\n}\n\nexport interface PluginAiCompleteResult {\n\tmodelKey: string;\n\ttext: string;\n\tstopReason: \"stop\" | \"length\";\n\tusage: PluginAiUsage;\n}\n\nexport interface PluginAiTextDeltaEvent {\n\t/** Newly generated text in this event. */\n\tdelta: string;\n\t/** Complete text generated by this request so far. */\n\ttext: string;\n}\n\nexport interface PluginAiStreamOptions {\n\t/** Cancels the provider request and rejects the returned promise when aborted. */\n\tsignal?: AbortSignal;\n\tonTextDelta?(event: PluginAiTextDeltaEvent): void;\n}\n\n/** Host-managed text inference. Provider credentials never enter the plugin runtime. */\nexport interface PluginAiApi {\n\tlistModels(): Promise<PluginAiModelListResult>;\n\tcomplete(request: PluginAiCompleteRequest): Promise<PluginAiCompleteResult>;\n\t/** Streams one assistant response while resolving to the same final contract as complete(). */\n\tstream(request: PluginAiCompleteRequest, options?: PluginAiStreamOptions): Promise<PluginAiCompleteResult>;\n\t/**\n\t * Stateless multi-turn completion. The plugin owns and persists the transcript;\n\t * each call sends the full message history (optionally with plugin-internal tools)\n\t * and receives the next assistant turn. Requires the `ai.complete` permission.\n\t */\n\tchat(request: PluginAiChatRequest): Promise<PluginAiChatResult>;\n}\n"]}
|
package/dist/app-actions.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { PluginJsonSchema } from "./agent.js";
|
|
2
2
|
import type { Disposable } from "./disposable.js";
|
|
3
3
|
export type PluginAppActionEffect = "read" | "write" | "execute";
|
|
4
|
+
/** Model-facing routing guidance, not authorization or an execution policy. */
|
|
5
|
+
export interface PluginAppActionUsage {
|
|
6
|
+
target: string;
|
|
7
|
+
useWhen: string;
|
|
8
|
+
avoidWhen: string;
|
|
9
|
+
alternatives: string;
|
|
10
|
+
}
|
|
4
11
|
export interface PluginAppActionExample<TInput = unknown> {
|
|
5
12
|
description: string;
|
|
6
13
|
input: TInput;
|
|
@@ -10,7 +17,6 @@ export interface PluginAppActionHandlerContext<TInput = unknown> {
|
|
|
10
17
|
plugin: {
|
|
11
18
|
id: string;
|
|
12
19
|
actionId: string;
|
|
13
|
-
settings: Readonly<Record<string, unknown>>;
|
|
14
20
|
};
|
|
15
21
|
input: TInput;
|
|
16
22
|
signal: AbortSignal;
|
|
@@ -46,6 +52,8 @@ export interface PluginAppActionRegistration<TInput = unknown> {
|
|
|
46
52
|
title: string;
|
|
47
53
|
summary: string;
|
|
48
54
|
description?: string;
|
|
55
|
+
/** Returned by search and describe; exclusions are never positive search terms. */
|
|
56
|
+
usage?: PluginAppActionUsage;
|
|
49
57
|
keywords?: string[];
|
|
50
58
|
effect: PluginAppActionEffect;
|
|
51
59
|
/** 官方插件可引用宿主已有审批界面;不能关闭 effect 对应的审批。 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-actions.d.ts","sourceRoot":"","sources":["../src/app-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEjE,MAAM,WAAW,sBAAsB,CAAC,MAAM,GAAG,OAAO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AAsB,CAAC,MAAM,CAAC,EAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA8B;IAC9B,WAAW,CAAC,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,MAAM,GAAG,OAAO,EAAE,YAAY,EAAE,2BAA2B,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;CAC1F","sourcesContent":["import type { PluginJsonSchema } from \"./agent.js\";\nimport type { Disposable } from \"./disposable.js\";\n\nexport type PluginAppActionEffect = \"read\" | \"write\" | \"execute\";\n\n/** Model-facing routing guidance, not authorization or an execution policy. */\nexport interface PluginAppActionUsage {\n\ttarget: string;\n\tuseWhen: string;\n\tavoidWhen: string;\n\talternatives: string;\n}\n\nexport interface PluginAppActionExample<TInput = unknown> {\n\tdescription: string;\n\tinput: TInput;\n}\n\nexport interface PluginAppActionHandlerContext<TInput = unknown> {\n\tinvocationId: string;\n\tplugin: {\n\t\tid: string;\n\t\tactionId: string;\n\t};\n\tinput: TInput;\n\tsignal: AbortSignal;\n}\n\nexport type PluginAppActionHandler<TInput = unknown> = (\n\tcontext: PluginAppActionHandlerContext<TInput>,\n) => unknown | Promise<unknown>;\n\nexport type PluginAppActionReadyHandler<TInput = unknown> = (\n\tcontext: PluginAppActionHandlerContext<TInput>,\n) => void | Promise<void>;\n\n/** 插件 Action 向宿主返回稳定错误码与可序列化详情。 */\nexport class PluginAppActionError extends Error {\n\treadonly code: string;\n\treadonly details?: unknown;\n\n\tconstructor(code: string, message: string, details?: unknown) {\n\t\tsuper(message);\n\t\tthis.name = \"PluginAppActionError\";\n\t\tthis.code = code;\n\t\tthis.details = details;\n\t}\n}\n\nexport interface PluginAppActionApprovalPresentation {\n\tid: string;\n\ttitle: string;\n\tdescription: string;\n}\n\nexport interface PluginAppActionApproval {\n\t/** 默认使用的宿主审批界面。 */\n\tdefaultPresentation: string;\n\t/** 可用的宿主审批界面;仅官方插件可以声明。 */\n\tpresentations: PluginAppActionApprovalPresentation[];\n\t/** 根据 input.operation 自动选择审批界面,不要求 Agent 传 approvalUi。 */\n\tpresentationByOperation?: Record<string, string>;\n\t/** 某 operation 明确允许的附加审批界面;宿主仍会拒绝未列出的调用方选择。 */\n\talternativePresentationsByOperation?: Record<string, string[]>;\n}\n\nexport interface PluginAppActionRegistration<TInput = unknown> {\n\t/** 插件内局部 id;宿主公开为 `plugin.<pluginId>.<id>`。 */\n\tid: string;\n\t/** 可信官方插件可指定稳定公共 id;若 id 已被占用则后到者忽略(先注册为准)。 */\n\tpublicId?: string;\n\ttitle: string;\n\tsummary: string;\n\tdescription?: string;\n\t/** Returned by search and describe; exclusions are never positive search terms. */\n\tusage?: PluginAppActionUsage;\n\tkeywords?: string[];\n\teffect: PluginAppActionEffect;\n\t/** 官方插件可引用宿主已有审批界面;不能关闭 effect 对应的审批。 */\n\tapproval?: PluginAppActionApproval;\n\tinputSchema: PluginJsonSchema;\n\texamples?: PluginAppActionExample<TInput>[];\n\ttimeoutMs?: number;\n\t/** 审批前业务就绪校验;失败时不会向用户弹出审批。 */\n\tassertReady?: PluginAppActionReadyHandler<TInput>;\n\thandler: PluginAppActionHandler<TInput>;\n}\n\nexport interface PluginAppActionsApi {\n\tregister<TInput = unknown>(registration: PluginAppActionRegistration<TInput>): Disposable;\n}\n"]}
|
package/dist/app-actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-actions.js","sourceRoot":"","sources":["../src/app-actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-actions.js","sourceRoot":"","sources":["../src/app-actions.ts"],"names":[],"mappings":"AAoCA,2EAAmC;AACnC,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACrC,IAAI,CAAS;IACb,OAAO,CAAW;IAE3B,YAAY,IAAY,EAAE,OAAe,EAAE,OAAiB,EAAE;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAAA,CACvB;CACD","sourcesContent":["import type { PluginJsonSchema } from \"./agent.js\";\nimport type { Disposable } from \"./disposable.js\";\n\nexport type PluginAppActionEffect = \"read\" | \"write\" | \"execute\";\n\n/** Model-facing routing guidance, not authorization or an execution policy. */\nexport interface PluginAppActionUsage {\n\ttarget: string;\n\tuseWhen: string;\n\tavoidWhen: string;\n\talternatives: string;\n}\n\nexport interface PluginAppActionExample<TInput = unknown> {\n\tdescription: string;\n\tinput: TInput;\n}\n\nexport interface PluginAppActionHandlerContext<TInput = unknown> {\n\tinvocationId: string;\n\tplugin: {\n\t\tid: string;\n\t\tactionId: string;\n\t};\n\tinput: TInput;\n\tsignal: AbortSignal;\n}\n\nexport type PluginAppActionHandler<TInput = unknown> = (\n\tcontext: PluginAppActionHandlerContext<TInput>,\n) => unknown | Promise<unknown>;\n\nexport type PluginAppActionReadyHandler<TInput = unknown> = (\n\tcontext: PluginAppActionHandlerContext<TInput>,\n) => void | Promise<void>;\n\n/** 插件 Action 向宿主返回稳定错误码与可序列化详情。 */\nexport class PluginAppActionError extends Error {\n\treadonly code: string;\n\treadonly details?: unknown;\n\n\tconstructor(code: string, message: string, details?: unknown) {\n\t\tsuper(message);\n\t\tthis.name = \"PluginAppActionError\";\n\t\tthis.code = code;\n\t\tthis.details = details;\n\t}\n}\n\nexport interface PluginAppActionApprovalPresentation {\n\tid: string;\n\ttitle: string;\n\tdescription: string;\n}\n\nexport interface PluginAppActionApproval {\n\t/** 默认使用的宿主审批界面。 */\n\tdefaultPresentation: string;\n\t/** 可用的宿主审批界面;仅官方插件可以声明。 */\n\tpresentations: PluginAppActionApprovalPresentation[];\n\t/** 根据 input.operation 自动选择审批界面,不要求 Agent 传 approvalUi。 */\n\tpresentationByOperation?: Record<string, string>;\n\t/** 某 operation 明确允许的附加审批界面;宿主仍会拒绝未列出的调用方选择。 */\n\talternativePresentationsByOperation?: Record<string, string[]>;\n}\n\nexport interface PluginAppActionRegistration<TInput = unknown> {\n\t/** 插件内局部 id;宿主公开为 `plugin.<pluginId>.<id>`。 */\n\tid: string;\n\t/** 可信官方插件可指定稳定公共 id;若 id 已被占用则后到者忽略(先注册为准)。 */\n\tpublicId?: string;\n\ttitle: string;\n\tsummary: string;\n\tdescription?: string;\n\t/** Returned by search and describe; exclusions are never positive search terms. */\n\tusage?: PluginAppActionUsage;\n\tkeywords?: string[];\n\teffect: PluginAppActionEffect;\n\t/** 官方插件可引用宿主已有审批界面;不能关闭 effect 对应的审批。 */\n\tapproval?: PluginAppActionApproval;\n\tinputSchema: PluginJsonSchema;\n\texamples?: PluginAppActionExample<TInput>[];\n\ttimeoutMs?: number;\n\t/** 审批前业务就绪校验;失败时不会向用户弹出审批。 */\n\tassertReady?: PluginAppActionReadyHandler<TInput>;\n\thandler: PluginAppActionHandler<TInput>;\n}\n\nexport interface PluginAppActionsApi {\n\tregister<TInput = unknown>(registration: PluginAppActionRegistration<TInput>): Disposable;\n}\n"]}
|