@vetta-org/plugin-sdk 0.0.3 → 0.0.4
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 +18 -0
- package/dist/activity-tab.d.ts.map +1 -0
- package/dist/activity-tab.js +12 -0
- package/dist/activity-tab.js.map +1 -0
- package/dist/agent.d.ts +206 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +2 -0
- package/dist/agent.js.map +1 -0
- package/dist/app-actions.d.ts +63 -0
- package/dist/app-actions.d.ts.map +1 -0
- package/dist/app-actions.js +12 -0
- package/dist/app-actions.js.map +1 -0
- package/dist/command.d.ts +25 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +2 -0
- package/dist/command.js.map +1 -0
- package/dist/context.d.ts +45 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +4 -0
- package/dist/context.js.map +1 -0
- package/dist/conversation.d.ts +50 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/conversation.js +2 -0
- package/dist/conversation.js.map +1 -0
- package/dist/disposable.d.ts +4 -0
- package/dist/disposable.d.ts.map +1 -0
- package/dist/disposable.js +2 -0
- package/dist/disposable.js.map +1 -0
- package/dist/fs.d.ts +34 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +2 -0
- package/dist/fs.js.map +1 -0
- package/dist/hooks.d.ts +39 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +41 -0
- package/dist/hooks.js.map +1 -0
- package/dist/host-bridge.d.ts +14 -0
- package/dist/host-bridge.d.ts.map +1 -0
- package/dist/host-bridge.js +12 -0
- package/dist/host-bridge.js.map +1 -0
- package/dist/i18n.d.ts +35 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +29 -0
- package/dist/i18n.js.map +1 -0
- package/dist/images.d.ts +58 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +2 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +29 -1478
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -99
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +57 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +2 -0
- package/dist/manifest.js.map +1 -0
- package/dist/official.d.ts +520 -0
- package/dist/official.d.ts.map +1 -0
- package/dist/official.js +2 -0
- package/dist/official.js.map +1 -0
- package/dist/permissions.d.ts +2 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +2 -0
- package/dist/permissions.js.map +1 -0
- package/dist/scenario.d.ts +9 -0
- package/dist/scenario.d.ts.map +1 -0
- package/dist/scenario.js +2 -0
- package/dist/scenario.js.map +1 -0
- package/dist/settings.d.ts +13 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +2 -0
- package/dist/settings.js.map +1 -0
- package/dist/ui.d.ts +338 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +2 -0
- package/dist/ui.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ActivityTabContextValue {
|
|
2
|
+
/**
|
|
3
|
+
* The cwd scope of the activity panel this tab is rendered in — the same
|
|
4
|
+
* key the attach record uses. Do NOT substitute useActiveConversation().cwd:
|
|
5
|
+
* on the project detail page the panel cwd is the project's, while the
|
|
6
|
+
* active conversation may belong to another project (or be null).
|
|
7
|
+
*/
|
|
8
|
+
cwd: string | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Internal: the host wraps attached activity-tab components in this context's
|
|
12
|
+
* Provider. Module Federation shares this single SDK instance, so the value
|
|
13
|
+
* the host provides is visible to plugin components.
|
|
14
|
+
*/
|
|
15
|
+
export declare const __ActivityTabContext: import("react").Context<ActivityTabContextValue>;
|
|
16
|
+
/** The panel scope of the activity tab this component is rendered in. */
|
|
17
|
+
export declare function useActivityTab(): ActivityTabContextValue;
|
|
18
|
+
//# sourceMappingURL=activity-tab.d.ts.map
|
|
@@ -0,0 +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;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,kDAAwD,CAAC;AAE1F,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}\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 });\n\n/** The panel scope of the activity tab this component is rendered in. */\nexport function useActivityTab(): ActivityTabContextValue {\n\treturn useContext(__ActivityTabContext);\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Internal: the host wraps attached activity-tab components in this context's
|
|
4
|
+
* Provider. Module Federation shares this single SDK instance, so the value
|
|
5
|
+
* the host provides is visible to plugin components.
|
|
6
|
+
*/
|
|
7
|
+
export const __ActivityTabContext = createContext({ cwd: null });
|
|
8
|
+
/** The panel scope of the activity tab this component is rendered in. */
|
|
9
|
+
export function useActivityTab() {
|
|
10
|
+
return useContext(__ActivityTabContext);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=activity-tab.js.map
|
|
@@ -0,0 +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;AAYlD;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAA0B,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAE1F,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}\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 });\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
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { PluginConversationApi } from "./conversation.js";
|
|
2
|
+
import type { Disposable } from "./disposable.js";
|
|
3
|
+
import type { PluginFsApi } from "./fs.js";
|
|
4
|
+
import type { ConversationScenario } from "./scenario.js";
|
|
5
|
+
export type PluginJsonSchema = object;
|
|
6
|
+
export interface PluginAgentToolApi {
|
|
7
|
+
fs: PluginFsApi;
|
|
8
|
+
conversation: PluginConversationApi;
|
|
9
|
+
}
|
|
10
|
+
export interface PluginAgentToolRegistration<TInput = unknown> {
|
|
11
|
+
id: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
description: string;
|
|
15
|
+
parameters: PluginJsonSchema;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
/**
|
|
18
|
+
* 允许该工具出现的对话场景 slug 列表。**fail-closed**:未声明/空数组 = 所有场景都不激活。
|
|
19
|
+
* 插件须显式声明。
|
|
20
|
+
*/
|
|
21
|
+
scope_use?: readonly ConversationScenario[];
|
|
22
|
+
/** 需要的会话能力 slug(如 "knowledge");全满足才激活。一般插件无需设置。 */
|
|
23
|
+
requires?: string[];
|
|
24
|
+
/** 允许该工具出现的工作模式 slug(agent_mode 轴,如 "work"/"coding")。缺省/空 = 通用。见 ADR-0046。 */
|
|
25
|
+
agent_mode?: readonly string[];
|
|
26
|
+
context?: {
|
|
27
|
+
conversation?: "summary" | "messages";
|
|
28
|
+
};
|
|
29
|
+
handler: PluginAgentToolHandler<TInput>;
|
|
30
|
+
}
|
|
31
|
+
export interface PluginSystemPromptBlock {
|
|
32
|
+
id: string;
|
|
33
|
+
content: string;
|
|
34
|
+
priority?: number;
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export type PluginDynamicSystemPromptOperation = {
|
|
38
|
+
type: "addBlock";
|
|
39
|
+
block: PluginSystemPromptBlock;
|
|
40
|
+
} | {
|
|
41
|
+
type: "replaceBlock";
|
|
42
|
+
blockId: string;
|
|
43
|
+
block: Omit<PluginSystemPromptBlock, "id">;
|
|
44
|
+
} | {
|
|
45
|
+
type: "updateBlock";
|
|
46
|
+
blockId: string;
|
|
47
|
+
patch: Partial<Pick<PluginSystemPromptBlock, "content" | "priority" | "enabled">>;
|
|
48
|
+
} | {
|
|
49
|
+
type: "removeBlock";
|
|
50
|
+
blockId: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: "setBlockEnabled";
|
|
53
|
+
blockId: string;
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
} | {
|
|
56
|
+
type: "setToolEnabled";
|
|
57
|
+
toolName: string;
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
} | {
|
|
60
|
+
type: "requestContinuation";
|
|
61
|
+
result: PluginContinuationResult;
|
|
62
|
+
};
|
|
63
|
+
export interface PluginSystemPromptMessage {
|
|
64
|
+
role: string;
|
|
65
|
+
text: string;
|
|
66
|
+
timestamp?: number;
|
|
67
|
+
toolName?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface PluginSystemPromptProviderContext {
|
|
70
|
+
plugin: {
|
|
71
|
+
id: string;
|
|
72
|
+
providerId: string;
|
|
73
|
+
settings: Readonly<Record<string, unknown>>;
|
|
74
|
+
};
|
|
75
|
+
session: {
|
|
76
|
+
id: string;
|
|
77
|
+
cwd: string;
|
|
78
|
+
scenario: ConversationScenario;
|
|
79
|
+
};
|
|
80
|
+
model: {
|
|
81
|
+
provider: string;
|
|
82
|
+
id: string;
|
|
83
|
+
api: string;
|
|
84
|
+
input: readonly string[];
|
|
85
|
+
contextWindow?: number;
|
|
86
|
+
maxTokens?: number;
|
|
87
|
+
};
|
|
88
|
+
conversation: {
|
|
89
|
+
messages: readonly PluginSystemPromptMessage[];
|
|
90
|
+
messageCount: number;
|
|
91
|
+
};
|
|
92
|
+
runtime: {
|
|
93
|
+
activeToolNames: readonly string[];
|
|
94
|
+
availableToolNames: readonly string[];
|
|
95
|
+
runIndex: number;
|
|
96
|
+
};
|
|
97
|
+
trigger: {
|
|
98
|
+
kind: "agent-run";
|
|
99
|
+
timestamp: number;
|
|
100
|
+
};
|
|
101
|
+
systemPrompt?: {
|
|
102
|
+
base: {
|
|
103
|
+
blocks?: readonly PluginSystemPromptBlockView[];
|
|
104
|
+
rendered?: string;
|
|
105
|
+
};
|
|
106
|
+
current: {
|
|
107
|
+
blocks?: readonly PluginSystemPromptBlockView[];
|
|
108
|
+
rendered?: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export interface PluginSystemPromptBlockView extends PluginSystemPromptBlock {
|
|
113
|
+
type: string;
|
|
114
|
+
source: {
|
|
115
|
+
kind: "core" | "plugin";
|
|
116
|
+
pluginId?: string;
|
|
117
|
+
};
|
|
118
|
+
priority: number;
|
|
119
|
+
enabled: boolean;
|
|
120
|
+
}
|
|
121
|
+
export interface PluginAgentActions {
|
|
122
|
+
systemPrompt: {
|
|
123
|
+
addBlock(block: PluginSystemPromptBlock): void;
|
|
124
|
+
replaceBlock(blockId: string, block: Omit<PluginSystemPromptBlock, "id">): void;
|
|
125
|
+
updateBlock(blockId: string, patch: Partial<Pick<PluginSystemPromptBlock, "content" | "priority" | "enabled">>): void;
|
|
126
|
+
removeBlock(blockId: string): void;
|
|
127
|
+
setBlockEnabled(blockId: string, enabled: boolean): void;
|
|
128
|
+
};
|
|
129
|
+
tools: {
|
|
130
|
+
setEnabled(toolName: string, enabled: boolean): void;
|
|
131
|
+
enable(toolName: string): void;
|
|
132
|
+
disable(toolName: string): void;
|
|
133
|
+
};
|
|
134
|
+
continuation: {
|
|
135
|
+
request(result: PluginContinuationResult): void;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export interface PluginAgentHandlerContext<TTrigger> {
|
|
139
|
+
invocationId: string;
|
|
140
|
+
plugin: {
|
|
141
|
+
id: string;
|
|
142
|
+
contributionId: string;
|
|
143
|
+
settings: Readonly<Record<string, unknown>>;
|
|
144
|
+
};
|
|
145
|
+
session: PluginSystemPromptProviderContext["session"];
|
|
146
|
+
model: PluginSystemPromptProviderContext["model"];
|
|
147
|
+
conversation: PluginSystemPromptProviderContext["conversation"];
|
|
148
|
+
runtime: PluginSystemPromptProviderContext["runtime"];
|
|
149
|
+
trigger: TTrigger;
|
|
150
|
+
systemPrompt?: PluginSystemPromptProviderContext["systemPrompt"];
|
|
151
|
+
actions: PluginAgentActions;
|
|
152
|
+
host: PluginAgentToolApi;
|
|
153
|
+
}
|
|
154
|
+
export type PluginAgentToolHandler<TInput = unknown> = (context: PluginAgentHandlerContext<{
|
|
155
|
+
kind: "tool-call";
|
|
156
|
+
timestamp: number;
|
|
157
|
+
toolCallId: string;
|
|
158
|
+
toolId: string;
|
|
159
|
+
toolName: string;
|
|
160
|
+
input: TInput;
|
|
161
|
+
}>) => unknown | Promise<unknown>;
|
|
162
|
+
export type PluginSystemPromptProviderHandler = (context: PluginAgentHandlerContext<{
|
|
163
|
+
kind: "agent-run";
|
|
164
|
+
timestamp: number;
|
|
165
|
+
}>) => void | PluginDynamicSystemPromptOperation[] | Promise<void | PluginDynamicSystemPromptOperation[]>;
|
|
166
|
+
export interface PluginSystemPromptProviderRegistration {
|
|
167
|
+
id: string;
|
|
168
|
+
timeoutMs?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Large context is opt-in. Omitted fields are not serialized across the
|
|
171
|
+
* host/renderer boundary.
|
|
172
|
+
*/
|
|
173
|
+
context?: {
|
|
174
|
+
systemPrompt?: "none" | "blocks" | "rendered" | "full";
|
|
175
|
+
conversation?: "summary" | "messages";
|
|
176
|
+
};
|
|
177
|
+
handler: PluginSystemPromptProviderHandler;
|
|
178
|
+
}
|
|
179
|
+
export interface PluginContinuationResult {
|
|
180
|
+
text: string;
|
|
181
|
+
/** Stable key used by the host to suppress duplicate continuations in a session. */
|
|
182
|
+
idempotencyKey?: string;
|
|
183
|
+
}
|
|
184
|
+
export type PluginContinuationHandler = (context: PluginAgentHandlerContext<{
|
|
185
|
+
kind: "continuation";
|
|
186
|
+
timestamp: number;
|
|
187
|
+
}>) => PluginContinuationResult | null | Promise<PluginContinuationResult | null>;
|
|
188
|
+
export interface PluginContinuationRegistration {
|
|
189
|
+
id: string;
|
|
190
|
+
timeoutMs?: number;
|
|
191
|
+
context?: {
|
|
192
|
+
conversation?: "summary" | "messages";
|
|
193
|
+
};
|
|
194
|
+
handler: PluginContinuationHandler;
|
|
195
|
+
}
|
|
196
|
+
export interface PluginAgentApi {
|
|
197
|
+
registerTool<TInput = unknown>(registration: PluginAgentToolRegistration<TInput>): Disposable;
|
|
198
|
+
/** Register a provider evaluated before every Agent run. */
|
|
199
|
+
registerSystemPromptProvider(registration: PluginSystemPromptProviderRegistration): Disposable;
|
|
200
|
+
/**
|
|
201
|
+
* Register a policy consulted when the agent reaches a natural stopping point.
|
|
202
|
+
* Return null to allow the agent to stop, or a message to continue with another turn.
|
|
203
|
+
*/
|
|
204
|
+
registerContinuationProvider(registration: PluginContinuationRegistration): Disposable;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +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,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,kIAA8E;IAC9E,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;KAAE,CAAC;IACpD,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,uBAAuB;IAC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,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\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"]}
|
package/dist/agent.js
ADDED
|
@@ -0,0 +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\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"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PluginJsonSchema } from "./agent.js";
|
|
2
|
+
import type { Disposable } from "./disposable.js";
|
|
3
|
+
export type PluginAppActionEffect = "read" | "write" | "execute";
|
|
4
|
+
export interface PluginAppActionExample<TInput = unknown> {
|
|
5
|
+
description: string;
|
|
6
|
+
input: TInput;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginAppActionHandlerContext<TInput = unknown> {
|
|
9
|
+
invocationId: string;
|
|
10
|
+
plugin: {
|
|
11
|
+
id: string;
|
|
12
|
+
actionId: string;
|
|
13
|
+
settings: Readonly<Record<string, unknown>>;
|
|
14
|
+
};
|
|
15
|
+
input: TInput;
|
|
16
|
+
signal: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
export type PluginAppActionHandler<TInput = unknown> = (context: PluginAppActionHandlerContext<TInput>) => unknown | Promise<unknown>;
|
|
19
|
+
export type PluginAppActionReadyHandler<TInput = unknown> = (context: PluginAppActionHandlerContext<TInput>) => void | Promise<void>;
|
|
20
|
+
/** 插件 Action 向宿主返回稳定错误码与可序列化详情。 */
|
|
21
|
+
export declare class PluginAppActionError extends Error {
|
|
22
|
+
readonly code: string;
|
|
23
|
+
readonly details?: unknown;
|
|
24
|
+
constructor(code: string, message: string, details?: unknown);
|
|
25
|
+
}
|
|
26
|
+
export interface PluginAppActionApprovalPresentation {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
}
|
|
31
|
+
export interface PluginAppActionApproval {
|
|
32
|
+
/** 默认使用的宿主审批界面。 */
|
|
33
|
+
defaultPresentation: string;
|
|
34
|
+
/** 可用的宿主审批界面;仅官方插件可以声明。 */
|
|
35
|
+
presentations: PluginAppActionApprovalPresentation[];
|
|
36
|
+
/** 根据 input.operation 自动选择审批界面,不要求 Agent 传 approvalUi。 */
|
|
37
|
+
presentationByOperation?: Record<string, string>;
|
|
38
|
+
/** 某 operation 明确允许的附加审批界面;宿主仍会拒绝未列出的调用方选择。 */
|
|
39
|
+
alternativePresentationsByOperation?: Record<string, string[]>;
|
|
40
|
+
}
|
|
41
|
+
export interface PluginAppActionRegistration<TInput = unknown> {
|
|
42
|
+
/** 插件内局部 id;宿主公开为 `plugin.<pluginId>.<id>`。 */
|
|
43
|
+
id: string;
|
|
44
|
+
/** 可信官方插件可指定稳定公共 id;若 id 已被占用则后到者忽略(先注册为准)。 */
|
|
45
|
+
publicId?: string;
|
|
46
|
+
title: string;
|
|
47
|
+
summary: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
keywords?: string[];
|
|
50
|
+
effect: PluginAppActionEffect;
|
|
51
|
+
/** 官方插件可引用宿主已有审批界面;不能关闭 effect 对应的审批。 */
|
|
52
|
+
approval?: PluginAppActionApproval;
|
|
53
|
+
inputSchema: PluginJsonSchema;
|
|
54
|
+
examples?: PluginAppActionExample<TInput>[];
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
/** 审批前业务就绪校验;失败时不会向用户弹出审批。 */
|
|
57
|
+
assertReady?: PluginAppActionReadyHandler<TInput>;
|
|
58
|
+
handler: PluginAppActionHandler<TInput>;
|
|
59
|
+
}
|
|
60
|
+
export interface PluginAppActionsApi {
|
|
61
|
+
register<TInput = unknown>(registration: PluginAppActionRegistration<TInput>): Disposable;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=app-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-actions.d.ts","sourceRoot":"","sources":["../src/app-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KA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WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACvC,2CAAmB;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mEAA2B;IAC3B,aAAa,EAAE,mCAAmC,EAAE,CAAC;IACrD,0FAA0D;IAC1D,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,yGAA+C;IAC/C,mCAAmC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,2BAA2B,CAAC,MAAM,GAAG,OAAO;IAC5D,uEAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,iHAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,6FAAyC;IACzC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,QAAQ,CAAC,EAAE,sBAAsB,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\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\tsettings: Readonly<Record<string, unknown>>;\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\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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 插件 Action 向宿主返回稳定错误码与可序列化详情。 */
|
|
2
|
+
export class PluginAppActionError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
details;
|
|
5
|
+
constructor(code, message, details) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "PluginAppActionError";
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.details = details;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=app-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-actions.js","sourceRoot":"","sources":["../src/app-actions.ts"],"names":[],"mappings":"AA6BA,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\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\tsettings: Readonly<Record<string, unknown>>;\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\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"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface PluginCommandRunOptions {
|
|
2
|
+
/** Working directory. Must resolve inside a host-allowed root (e.g. a project). */
|
|
3
|
+
cwd?: string;
|
|
4
|
+
/** Extra environment entries, merged over the host process env (PATH preserved). */
|
|
5
|
+
env?: Record<string, string>;
|
|
6
|
+
/** Hard timeout in ms; the host clamps to its own maximum. */
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface PluginCommandRunResult {
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
/** Process exit code; null when the process was killed by a signal/timeout. */
|
|
13
|
+
exitCode: number | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Run an allowed host command (e.g. `git`). execFile semantics — NO shell, args
|
|
17
|
+
* are passed as an array (no string splitting, no injection). The executable
|
|
18
|
+
* must be declared in plugin.json's `commands` and currently enabled by the
|
|
19
|
+
* user; otherwise the call is rejected (and the host notifies the user). Needs
|
|
20
|
+
* the `agent.command.run` permission.
|
|
21
|
+
*/
|
|
22
|
+
export interface PluginCommandApi {
|
|
23
|
+
run(file: string, args?: string[], options?: PluginCommandRunOptions): Promise<PluginCommandRunResult>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACvC,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAChC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACvG","sourcesContent":["export interface PluginCommandRunOptions {\n\t/** Working directory. Must resolve inside a host-allowed root (e.g. a project). */\n\tcwd?: string;\n\t/** Extra environment entries, merged over the host process env (PATH preserved). */\n\tenv?: Record<string, string>;\n\t/** Hard timeout in ms; the host clamps to its own maximum. */\n\ttimeoutMs?: number;\n}\n\nexport interface PluginCommandRunResult {\n\tstdout: string;\n\tstderr: string;\n\t/** Process exit code; null when the process was killed by a signal/timeout. */\n\texitCode: number | null;\n}\n\n/**\n * Run an allowed host command (e.g. `git`). execFile semantics — NO shell, args\n * are passed as an array (no string splitting, no injection). The executable\n * must be declared in plugin.json's `commands` and currently enabled by the\n * user; otherwise the call is rejected (and the host notifies the user). Needs\n * the `agent.command.run` permission.\n */\nexport interface PluginCommandApi {\n\trun(file: string, args?: string[], options?: PluginCommandRunOptions): Promise<PluginCommandRunResult>;\n}\n"]}
|
package/dist/command.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"","sourcesContent":["export interface PluginCommandRunOptions {\n\t/** Working directory. Must resolve inside a host-allowed root (e.g. a project). */\n\tcwd?: string;\n\t/** Extra environment entries, merged over the host process env (PATH preserved). */\n\tenv?: Record<string, string>;\n\t/** Hard timeout in ms; the host clamps to its own maximum. */\n\ttimeoutMs?: number;\n}\n\nexport interface PluginCommandRunResult {\n\tstdout: string;\n\tstderr: string;\n\t/** Process exit code; null when the process was killed by a signal/timeout. */\n\texitCode: number | null;\n}\n\n/**\n * Run an allowed host command (e.g. `git`). execFile semantics — NO shell, args\n * are passed as an array (no string splitting, no injection). The executable\n * must be declared in plugin.json's `commands` and currently enabled by the\n * user; otherwise the call is rejected (and the host notifies the user). Needs\n * the `agent.command.run` permission.\n */\nexport interface PluginCommandApi {\n\trun(file: string, args?: string[], options?: PluginCommandRunOptions): Promise<PluginCommandRunResult>;\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PluginAgentApi } from "./agent.js";
|
|
2
|
+
import type { PluginAppActionsApi } from "./app-actions.js";
|
|
3
|
+
import type { PluginCommandApi } from "./command.js";
|
|
4
|
+
import type { PluginConversationApi } from "./conversation.js";
|
|
5
|
+
import type { Disposable } from "./disposable.js";
|
|
6
|
+
import type { PluginFsApi } from "./fs.js";
|
|
7
|
+
import type { PluginI18nApi } from "./i18n.js";
|
|
8
|
+
import type { PluginImagesApi } from "./images.js";
|
|
9
|
+
import type { PluginOfficialApi } from "./official.js";
|
|
10
|
+
import type { PluginPermission } from "./permissions.js";
|
|
11
|
+
import type { PluginSettingsApi } from "./settings.js";
|
|
12
|
+
import type { PluginUiApi } from "./ui.js";
|
|
13
|
+
export interface PluginPermissionApi {
|
|
14
|
+
has(permission: PluginPermission): boolean;
|
|
15
|
+
require(permission: PluginPermission): void;
|
|
16
|
+
}
|
|
17
|
+
/** 工作模式(agent_mode 轴,见 ADR-0046)。宿主 Work/Coding,未来可能扩展。 */
|
|
18
|
+
export type AgentMode = "work" | "coding";
|
|
19
|
+
export interface PluginContext {
|
|
20
|
+
plugin: {
|
|
21
|
+
id: string;
|
|
22
|
+
version: string;
|
|
23
|
+
};
|
|
24
|
+
permissions: PluginPermissionApi;
|
|
25
|
+
ui: PluginUiApi;
|
|
26
|
+
conversation: PluginConversationApi;
|
|
27
|
+
agent: PluginAgentApi;
|
|
28
|
+
appActions: PluginAppActionsApi;
|
|
29
|
+
official: PluginOfficialApi;
|
|
30
|
+
fs: PluginFsApi;
|
|
31
|
+
command: PluginCommandApi;
|
|
32
|
+
images: PluginImagesApi;
|
|
33
|
+
settings: PluginSettingsApi;
|
|
34
|
+
i18n: PluginI18nApi;
|
|
35
|
+
/** 当前工作模式(agent_mode 轴)。开发者据此做模式定制。见 ADR-0046。 */
|
|
36
|
+
getAgentMode(): AgentMode;
|
|
37
|
+
/** 订阅工作模式变更(纯全局实时切换)。返回 Disposable 取消订阅。 */
|
|
38
|
+
onAgentModeChanged(listener: (mode: AgentMode) => void): Disposable;
|
|
39
|
+
}
|
|
40
|
+
export interface PluginDefinition {
|
|
41
|
+
activate(ctx: PluginContext): void | Promise<void>;
|
|
42
|
+
deactivate?(): void | Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export declare function definePlugin(plugin: PluginDefinition): PluginDefinition;
|
|
45
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,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,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE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AAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAEvE","sourcesContent":["import type { PluginAgentApi } from \"./agent.js\";\nimport type { PluginAppActionsApi } from \"./app-actions.js\";\nimport type { PluginCommandApi } from \"./command.js\";\nimport type { PluginConversationApi } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginFsApi } from \"./fs.js\";\nimport type { PluginI18nApi } from \"./i18n.js\";\nimport type { PluginImagesApi } from \"./images.js\";\nimport type { PluginOfficialApi } from \"./official.js\";\nimport type { PluginPermission } from \"./permissions.js\";\nimport type { PluginSettingsApi } from \"./settings.js\";\nimport type { PluginUiApi } from \"./ui.js\";\n\nexport interface PluginPermissionApi {\n\thas(permission: PluginPermission): boolean;\n\trequire(permission: PluginPermission): void;\n}\n\n/** 工作模式(agent_mode 轴,见 ADR-0046)。宿主 Work/Coding,未来可能扩展。 */\nexport type AgentMode = \"work\" | \"coding\";\n\nexport interface PluginContext {\n\tplugin: {\n\t\tid: string;\n\t\tversion: string;\n\t};\n\tpermissions: PluginPermissionApi;\n\tui: PluginUiApi;\n\tconversation: PluginConversationApi;\n\tagent: PluginAgentApi;\n\tappActions: PluginAppActionsApi;\n\tofficial: PluginOfficialApi;\n\tfs: PluginFsApi;\n\tcommand: PluginCommandApi;\n\timages: PluginImagesApi;\n\tsettings: PluginSettingsApi;\n\ti18n: PluginI18nApi;\n\t/** 当前工作模式(agent_mode 轴)。开发者据此做模式定制。见 ADR-0046。 */\n\tgetAgentMode(): AgentMode;\n\t/** 订阅工作模式变更(纯全局实时切换)。返回 Disposable 取消订阅。 */\n\tonAgentModeChanged(listener: (mode: AgentMode) => void): Disposable;\n}\n\nexport interface PluginDefinition {\n\tactivate(ctx: PluginContext): void | Promise<void>;\n\tdeactivate?(): void | Promise<void>;\n}\n\nexport function definePlugin(plugin: PluginDefinition): PluginDefinition {\n\treturn plugin;\n}\n"]}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAgDA,MAAM,UAAU,YAAY,CAAC,MAAwB,EAAoB;IACxE,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["import type { PluginAgentApi } from \"./agent.js\";\nimport type { PluginAppActionsApi } from \"./app-actions.js\";\nimport type { PluginCommandApi } from \"./command.js\";\nimport type { PluginConversationApi } from \"./conversation.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginFsApi } from \"./fs.js\";\nimport type { PluginI18nApi } from \"./i18n.js\";\nimport type { PluginImagesApi } from \"./images.js\";\nimport type { PluginOfficialApi } from \"./official.js\";\nimport type { PluginPermission } from \"./permissions.js\";\nimport type { PluginSettingsApi } from \"./settings.js\";\nimport type { PluginUiApi } from \"./ui.js\";\n\nexport interface PluginPermissionApi {\n\thas(permission: PluginPermission): boolean;\n\trequire(permission: PluginPermission): void;\n}\n\n/** 工作模式(agent_mode 轴,见 ADR-0046)。宿主 Work/Coding,未来可能扩展。 */\nexport type AgentMode = \"work\" | \"coding\";\n\nexport interface PluginContext {\n\tplugin: {\n\t\tid: string;\n\t\tversion: string;\n\t};\n\tpermissions: PluginPermissionApi;\n\tui: PluginUiApi;\n\tconversation: PluginConversationApi;\n\tagent: PluginAgentApi;\n\tappActions: PluginAppActionsApi;\n\tofficial: PluginOfficialApi;\n\tfs: PluginFsApi;\n\tcommand: PluginCommandApi;\n\timages: PluginImagesApi;\n\tsettings: PluginSettingsApi;\n\ti18n: PluginI18nApi;\n\t/** 当前工作模式(agent_mode 轴)。开发者据此做模式定制。见 ADR-0046。 */\n\tgetAgentMode(): AgentMode;\n\t/** 订阅工作模式变更(纯全局实时切换)。返回 Disposable 取消订阅。 */\n\tonAgentModeChanged(listener: (mode: AgentMode) => void): Disposable;\n}\n\nexport interface PluginDefinition {\n\tactivate(ctx: PluginContext): void | Promise<void>;\n\tdeactivate?(): void | Promise<void>;\n}\n\nexport function definePlugin(plugin: PluginDefinition): PluginDefinition {\n\treturn plugin;\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Disposable } from "./disposable.js";
|
|
2
|
+
export interface ConversationState {
|
|
3
|
+
/** Active session runtimeId, or null when no conversation is active. */
|
|
4
|
+
id: string | null;
|
|
5
|
+
cwd: string | null;
|
|
6
|
+
sessionPath: string | null;
|
|
7
|
+
model: string | null;
|
|
8
|
+
isStreaming: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ConversationMessage {
|
|
11
|
+
id: string;
|
|
12
|
+
role: "user" | "assistant" | "compaction";
|
|
13
|
+
text: string;
|
|
14
|
+
timestamp?: number;
|
|
15
|
+
}
|
|
16
|
+
export type ConversationEvent = {
|
|
17
|
+
type: "turn-start";
|
|
18
|
+
} | {
|
|
19
|
+
type: "turn-end";
|
|
20
|
+
stopReason: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "message-added";
|
|
23
|
+
message: ConversationMessage;
|
|
24
|
+
} | {
|
|
25
|
+
type: "message-updated";
|
|
26
|
+
delta: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: "tool-call-start";
|
|
29
|
+
toolCallId: string;
|
|
30
|
+
toolName: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: "tool-call-end";
|
|
33
|
+
toolCallId: string;
|
|
34
|
+
toolName: string;
|
|
35
|
+
isError: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
type: "conversation-changed";
|
|
38
|
+
conversation: ConversationState;
|
|
39
|
+
};
|
|
40
|
+
export interface PluginConversationApi {
|
|
41
|
+
/** Send a prompt into the active conversation (renders as a user turn). */
|
|
42
|
+
sendPrompt(text: string): Promise<void>;
|
|
43
|
+
/** Fill the input bar without sending; the user can edit and send. */
|
|
44
|
+
insertText(text: string): void;
|
|
45
|
+
/** Abort the active conversation's current turn. */
|
|
46
|
+
abort(): Promise<void>;
|
|
47
|
+
/** Subscribe to real-time conversation events. */
|
|
48
|
+
on(listener: (event: ConversationEvent) => void): Disposable;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,iBAAiB;IACjC,wEAAwE;IACxE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,iBAAiB,GAC1B;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACjF;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,YAAY,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAErE,MAAM,WAAW,qBAAqB;IACrC,2EAA2E;IAC3E,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,sEAAsE;IACtE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,oDAAoD;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,kDAAkD;IAClD,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,UAAU,CAAC;CAC7D","sourcesContent":["import type { Disposable } from \"./disposable.js\";\n\nexport interface ConversationState {\n\t/** Active session runtimeId, or null when no conversation is active. */\n\tid: string | null;\n\tcwd: string | null;\n\tsessionPath: string | null;\n\tmodel: string | null;\n\tisStreaming: boolean;\n}\n\nexport interface ConversationMessage {\n\tid: string;\n\trole: \"user\" | \"assistant\" | \"compaction\";\n\ttext: string;\n\ttimestamp?: number;\n}\n\nexport type ConversationEvent =\n\t| { type: \"turn-start\" }\n\t| { type: \"turn-end\"; stopReason: string }\n\t| { type: \"message-added\"; message: ConversationMessage }\n\t| { type: \"message-updated\"; delta: string }\n\t| { type: \"tool-call-start\"; toolCallId: string; toolName: string }\n\t| { type: \"tool-call-end\"; toolCallId: string; toolName: string; isError: boolean }\n\t| { type: \"conversation-changed\"; conversation: ConversationState };\n\nexport interface PluginConversationApi {\n\t/** Send a prompt into the active conversation (renders as a user turn). */\n\tsendPrompt(text: string): Promise<void>;\n\t/** Fill the input bar without sending; the user can edit and send. */\n\tinsertText(text: string): void;\n\t/** Abort the active conversation's current turn. */\n\tabort(): Promise<void>;\n\t/** Subscribe to real-time conversation events. */\n\ton(listener: (event: ConversationEvent) => void): Disposable;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"","sourcesContent":["import type { Disposable } from \"./disposable.js\";\n\nexport interface ConversationState {\n\t/** Active session runtimeId, or null when no conversation is active. */\n\tid: string | null;\n\tcwd: string | null;\n\tsessionPath: string | null;\n\tmodel: string | null;\n\tisStreaming: boolean;\n}\n\nexport interface ConversationMessage {\n\tid: string;\n\trole: \"user\" | \"assistant\" | \"compaction\";\n\ttext: string;\n\ttimestamp?: number;\n}\n\nexport type ConversationEvent =\n\t| { type: \"turn-start\" }\n\t| { type: \"turn-end\"; stopReason: string }\n\t| { type: \"message-added\"; message: ConversationMessage }\n\t| { type: \"message-updated\"; delta: string }\n\t| { type: \"tool-call-start\"; toolCallId: string; toolName: string }\n\t| { type: \"tool-call-end\"; toolCallId: string; toolName: string; isError: boolean }\n\t| { type: \"conversation-changed\"; conversation: ConversationState };\n\nexport interface PluginConversationApi {\n\t/** Send a prompt into the active conversation (renders as a user turn). */\n\tsendPrompt(text: string): Promise<void>;\n\t/** Fill the input bar without sending; the user can edit and send. */\n\tinsertText(text: string): void;\n\t/** Abort the active conversation's current turn. */\n\tabort(): Promise<void>;\n\t/** Subscribe to real-time conversation events. */\n\ton(listener: (event: ConversationEvent) => void): Disposable;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disposable.d.ts","sourceRoot":"","sources":["../src/disposable.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IAC1B,OAAO,IAAI,IAAI,CAAC;CAChB","sourcesContent":["export interface Disposable {\n\tdispose(): void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disposable.js","sourceRoot":"","sources":["../src/disposable.ts"],"names":[],"mappings":"","sourcesContent":["export interface Disposable {\n\tdispose(): void;\n}\n"]}
|
package/dist/fs.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface PluginFsEntry {
|
|
2
|
+
name: string;
|
|
3
|
+
path: string;
|
|
4
|
+
isDirectory: boolean;
|
|
5
|
+
size: number;
|
|
6
|
+
modifiedAt: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginFsFileRef {
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
relPath: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PluginFsStatResult {
|
|
14
|
+
size: number;
|
|
15
|
+
modifiedAt: number;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
}
|
|
18
|
+
export interface PluginFsReadResult {
|
|
19
|
+
content: string;
|
|
20
|
+
encoding: "utf8" | "base64";
|
|
21
|
+
}
|
|
22
|
+
export interface PluginFsApi {
|
|
23
|
+
readDir(dirPath: string): Promise<PluginFsEntry[]>;
|
|
24
|
+
readFile(filePath: string): Promise<PluginFsReadResult>;
|
|
25
|
+
/** Pass `encoding: "base64"` to write binary payloads (decoded from base64 text). */
|
|
26
|
+
writeFile(filePath: string, content: string, encoding?: "utf8" | "base64"): Promise<void>;
|
|
27
|
+
stat(filePath: string): Promise<PluginFsStatResult | null>;
|
|
28
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
29
|
+
delete(targetPath: string): Promise<void>;
|
|
30
|
+
move(sourcePath: string, destDir: string): Promise<void>;
|
|
31
|
+
createDirectory(dirPath: string): Promise<void>;
|
|
32
|
+
listFilesRecursive(rootPath: string): Promise<PluginFsFileRef[]>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=fs.d.ts.map
|