@ycodium-ai/plugin-api 0.2.2936 → 0.2.2942
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/README.md +38 -10
- package/dist/capabilityPorts.d.ts +136 -0
- package/dist/capabilityPorts.d.ts.map +1 -0
- package/dist/capabilityPorts.js +48 -0
- package/dist/capabilityPorts.js.map +1 -0
- package/dist/conversation.d.ts +5 -55
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/conversationPresets.d.ts +13 -0
- package/dist/conversationPresets.d.ts.map +1 -0
- package/dist/conversationPresets.js +2 -0
- package/dist/conversationPresets.js.map +1 -0
- package/dist/conversationWorkEntry.d.ts +71 -0
- package/dist/conversationWorkEntry.d.ts.map +1 -0
- package/dist/conversationWorkEntry.js +2 -0
- package/dist/conversationWorkEntry.js.map +1 -0
- package/dist/executor.d.ts +2 -23
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js.map +1 -1
- package/dist/executorCapabilities.d.ts +21 -0
- package/dist/executorCapabilities.d.ts.map +1 -1
- package/dist/index.d.ts +25 -160
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -17
- package/dist/index.js.map +1 -1
- package/dist/plugin-tools.d.ts +130 -0
- package/dist/plugin-tools.d.ts.map +1 -0
- package/dist/plugin-tools.js +2 -0
- package/dist/plugin-tools.js.map +1 -0
- package/dist/process-socket.d.ts +4 -1
- package/dist/process-socket.d.ts.map +1 -1
- package/dist/slots.d.ts +52 -6
- package/dist/slots.d.ts.map +1 -1
- package/dist/slots.js +50 -4
- package/dist/slots.js.map +1 -1
- package/dist/threadList.d.ts +39 -0
- package/dist/threadList.d.ts.map +1 -0
- package/dist/threadList.js +2 -0
- package/dist/threadList.js.map +1 -0
- package/dist/tool-display.d.ts +16 -4
- package/dist/tool-display.d.ts.map +1 -1
- package/dist/ui.d.ts +29 -3
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
|
56
56
|
|
|
57
57
|
export default definePlugin({
|
|
58
58
|
id: "my-plugin",
|
|
59
|
-
apiVersion:
|
|
59
|
+
apiVersion: 4,
|
|
60
60
|
activate: (ctx) => {
|
|
61
61
|
ctx.log.info("hello");
|
|
62
62
|
|
|
@@ -158,6 +158,14 @@ your tool returns must stand on its own. To show an image your tool wrote into t
|
|
|
158
158
|
call `bridge.useWorkspaceFileUrl({ environmentId, threadId, path })` after checking the
|
|
159
159
|
`workspaceFileUrl` capability. Mobile shows the text result.
|
|
160
160
|
|
|
161
|
+
## Experimental seats
|
|
162
|
+
|
|
163
|
+
`project.workbench.tab` and `sidebar.project.actions` render on Web and Desktop.
|
|
164
|
+
Mobile loads a plugin that registers them and does not draw the seats. The props,
|
|
165
|
+
when the host refreshes them, and what happens when a tab throws are experimental.
|
|
166
|
+
Do not treat that shape as a stable contract. It will be fixed when the first real
|
|
167
|
+
plugin depends on it.
|
|
168
|
+
|
|
161
169
|
## Permissions
|
|
162
170
|
|
|
163
171
|
Anything that reaches outside the plugin is declared in `ycodium.permissions` and shown to
|
|
@@ -179,9 +187,17 @@ A plugin can ship skills for the agents. List directories inside your package un
|
|
|
179
187
|
```
|
|
180
188
|
|
|
181
189
|
While the plugin is enabled, each skill is installed for every supported agent as
|
|
182
|
-
`ycodium-<name>`, and removed again when the plugin is disabled or uninstalled.
|
|
183
|
-
|
|
184
|
-
|
|
190
|
+
`ycodium-<name>`, and removed again when the plugin is disabled or uninstalled. A user's
|
|
191
|
+
own skill with the same name wins. To ship a script or other file next to `SKILL.md`,
|
|
192
|
+
declare that relative subtree:
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
"skills": [{ "dir": "./skills/report-writer", "files": ["scripts/render.sh"] }]
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Those files are copied into the session skill directory. A path with `..`, a file outside
|
|
199
|
+
the skill directory, or a file over the size cap fails the plugin load. A settings skill
|
|
200
|
+
with the same name still wins, and then these extra files are not copied.
|
|
185
201
|
|
|
186
202
|
## File previews
|
|
187
203
|
|
|
@@ -214,12 +230,24 @@ shows up there without anyone registering it.
|
|
|
214
230
|
|
|
215
231
|
## THERE WILL BE COMPATIBILITY-BREAKING CHANGES
|
|
216
232
|
|
|
217
|
-
The definition's `apiVersion` is
|
|
218
|
-
plugin targets as a literal; do not read the host's
|
|
219
|
-
automatically match. The current API is
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
233
|
+
The definition's `apiVersion` is a closed window: the host loads 3 and 4, and refuses every other
|
|
234
|
+
value. Declare the version your plugin targets as a literal; do not read the host's
|
|
235
|
+
`PLUGIN_API_VERSION` to make the declaration automatically match. The current API is 4. Plugins
|
|
236
|
+
that still declare 3 continue to load. Plugins targeting API 1 or 2 are refused before activation;
|
|
237
|
+
the message names the version the plugin declared and the ones this Ycodium loads, and the plugin
|
|
238
|
+
card offers an update. A plugin that declares a version newer than 4 is refused until Ycodium
|
|
239
|
+
itself is updated, with no update button.
|
|
240
|
+
|
|
241
|
+
### API 4
|
|
242
|
+
|
|
243
|
+
API 4 adds types and permission kinds for system-prompt sections, tool guards, presentation
|
|
244
|
+
payloads, extra conversation seats, session projections, agent presets, workspace writes,
|
|
245
|
+
and user-thread commands. The host still loads a plugin that declares 3. The host wires those
|
|
246
|
+
context fields: prompt text is prefixed onto a turn, guards run before a tool executes, seats
|
|
247
|
+
and presentation render, session projections persist, and workspace writes during a tool call
|
|
248
|
+
run when declared. Interactive terminals, directory-period write roots, and installing other
|
|
249
|
+
plugins from a plugin were removed before this API shipped. A host build from before this
|
|
250
|
+
wiring still rejects the new methods with `not-implemented`.
|
|
223
251
|
|
|
224
252
|
### API 3
|
|
225
253
|
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-0036 能力口的类型。
|
|
3
|
+
*
|
|
4
|
+
* 约束:未声明的调用拒绝 `reason: "undeclared"`。
|
|
5
|
+
* 提示注入、守卫、投影落库、预设列表、座位绘制、调用期写盘由宿主接线。
|
|
6
|
+
* 写盘只有工具调用期的 `invocation.workspace`,没有目录期根。
|
|
7
|
+
* 插件不经 `ctx` 安装或卸载别的插件。
|
|
8
|
+
*
|
|
9
|
+
* @module @ycodium-ai/plugin-api/capabilityPorts
|
|
10
|
+
*/
|
|
11
|
+
import type { PluginDisposer } from "./index.ts";
|
|
12
|
+
/** 单份工具展示体上限(ADR-0036)。不进入模型可见的 `text`。 */
|
|
13
|
+
export declare const MAX_PLUGIN_TOOL_PRESENTATION_BYTES: number;
|
|
14
|
+
/** 单份会话投影上限。不是编排事件。 */
|
|
15
|
+
export declare const MAX_PLUGIN_SESSION_PROJECTION_BYTES: number;
|
|
16
|
+
/**
|
|
17
|
+
* 宿主挂在插件命令表上的流名字。客户端用现有 `plugins.subscribe` 订,
|
|
18
|
+
* payload 是 `{ name, threadId }`,每条值是 `{ present, value }`。
|
|
19
|
+
*/
|
|
20
|
+
export declare const PLUGIN_SESSION_PROJECTION_COMMAND = "ycodium.sessionProjection";
|
|
21
|
+
/** 单文件写入上限。本权限不含删除。 */
|
|
22
|
+
export declare const MAX_PLUGIN_WORKSPACE_WRITE_BYTES: number;
|
|
23
|
+
/**
|
|
24
|
+
* 技能伴随文件上限。ADR 要求超限即 resolve 失败,但没给数字。
|
|
25
|
+
* 这是 Phase 1 宿主占位;Phase 2 拷进会话 skill 目录时必须遵守同一对数字。
|
|
26
|
+
*/
|
|
27
|
+
export declare const MAX_PLUGIN_SKILL_COMPANION_FILE_BYTES: number;
|
|
28
|
+
export declare const MAX_PLUGIN_SKILL_COMPANION_TOTAL_BYTES: number;
|
|
29
|
+
/** JSON 值。宿主拒绝函数、bigint、循环引用和 `undefined`。 */
|
|
30
|
+
export type PluginJson = null | boolean | number | string | readonly PluginJson[] | {
|
|
31
|
+
readonly [key: string]: PluginJson | undefined;
|
|
32
|
+
};
|
|
33
|
+
/** UTF-8 字节数。不是 JSON 的值抛 TypeError。 */
|
|
34
|
+
export declare const pluginJsonByteLength: (value: unknown) => number;
|
|
35
|
+
/**
|
|
36
|
+
* 收下工具展示体。缺席、非 JSON、或超过 {@link MAX_PLUGIN_TOOL_PRESENTATION_BYTES} 时返回 null。
|
|
37
|
+
* 调用方仍画文字卡,并且不得把这份值写进模型可见文本。
|
|
38
|
+
*/
|
|
39
|
+
export declare const acceptPluginToolPresentation: (value: unknown) => PluginJson | null;
|
|
40
|
+
/**
|
|
41
|
+
* 工具结果上的展示体。可选,缺席时仍画文字卡。
|
|
42
|
+
* Phase 2 必须按调用 id 回取,并且不得把这份值拼进模型可见文本或活动快照截断。
|
|
43
|
+
*/
|
|
44
|
+
export interface PluginToolPresentation {
|
|
45
|
+
readonly presentation?: PluginJson | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 与 tool view 共用的调用 id。Phase 1 可选,以免旧 fixture 深比较失败。
|
|
49
|
+
* Phase 2 每次工具调用都必须填写。
|
|
50
|
+
*/
|
|
51
|
+
export interface PluginToolInvocationIdentity {
|
|
52
|
+
readonly id?: string | undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* `workspace.write` 的调用期写。没有删除。
|
|
56
|
+
* 只在 handler 返回前可用;根是这次 `invocation.workspace` 的根。
|
|
57
|
+
*/
|
|
58
|
+
export interface PluginInvocationWorkspaceWrite {
|
|
59
|
+
writeFile?(path: string, bytes: Uint8Array): Promise<void>;
|
|
60
|
+
mkdir?(path: string): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export interface PluginSystemPromptSection {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly text: string;
|
|
65
|
+
/** 只在这条会话的 preset 是这个 id 时拼进本轮提示。缺省则每条会话都带。 */
|
|
66
|
+
readonly whenPresetId?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface PluginSystemPromptTurn {
|
|
69
|
+
readonly threadId: string;
|
|
70
|
+
readonly turnId: string | null;
|
|
71
|
+
/** 这条会话当前的 preset。没选时为 null。旧调用方可以不填。 */
|
|
72
|
+
readonly presetId?: string | null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 需要 `systemPrompt`。宿主把正文加在每一家 driver 的本轮用户消息前。
|
|
76
|
+
* 插件不按 driver 各写一条。
|
|
77
|
+
*/
|
|
78
|
+
export interface PluginSystemPrompt {
|
|
79
|
+
section(input: PluginSystemPromptSection): PluginDisposer;
|
|
80
|
+
context(provide: (turn: PluginSystemPromptTurn) => string | null | Promise<string | null>): PluginDisposer;
|
|
81
|
+
}
|
|
82
|
+
export type PluginToolGuardDecision = {
|
|
83
|
+
readonly decision: "allow";
|
|
84
|
+
} | {
|
|
85
|
+
readonly decision: "deny";
|
|
86
|
+
readonly reason: string;
|
|
87
|
+
};
|
|
88
|
+
export interface PluginToolGuardInput {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly args: PluginJson;
|
|
91
|
+
readonly threadId: string | null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 需要 `tools.guard`。没有 `register`。守卫不替换实现,也不改参数。
|
|
95
|
+
* 宿主按注册顺序在工具执行前调用,拒绝优先。
|
|
96
|
+
*/
|
|
97
|
+
export interface PluginTools {
|
|
98
|
+
guard(guard: (input: PluginToolGuardInput) => PluginToolGuardDecision | Promise<PluginToolGuardDecision>): PluginDisposer;
|
|
99
|
+
}
|
|
100
|
+
export interface PluginSessionProjectionName {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
}
|
|
103
|
+
export interface PluginSessionProjectionValue extends PluginSessionProjectionName {
|
|
104
|
+
readonly threadId: string;
|
|
105
|
+
readonly value: PluginJson;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 需要 `sessionProjection`。`register` 返回现有 disposer。
|
|
109
|
+
* `set` 执行 1 MiB 上限,并按(插件,线程,名字)留下最新一份。
|
|
110
|
+
* 客户端用 `PLUGIN_SESSION_PROJECTION_COMMAND` 订阅。
|
|
111
|
+
*/
|
|
112
|
+
export interface PluginSessionProjections {
|
|
113
|
+
register(input: PluginSessionProjectionName): PluginDisposer;
|
|
114
|
+
set(input: PluginSessionProjectionValue): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
export interface PluginAgentPresetRegistration {
|
|
117
|
+
readonly id: string;
|
|
118
|
+
readonly displayName: string;
|
|
119
|
+
readonly description?: string | undefined;
|
|
120
|
+
readonly promptPrefix?: string | undefined;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 需要 `agentPresets`。只在该线程第一轮之前可选。
|
|
124
|
+
* 正文要进模型输入必须另声明 `systemPrompt`,不自建第二条提示通道。
|
|
125
|
+
*/
|
|
126
|
+
export interface PluginAgentPresets {
|
|
127
|
+
register(input: PluginAgentPresetRegistration): PluginDisposer;
|
|
128
|
+
}
|
|
129
|
+
/** `PluginContext` 在 Phase 1 增加的成员。字段名必须出现在插件 API 参考里。 */
|
|
130
|
+
export interface PluginCapabilityContext {
|
|
131
|
+
readonly systemPrompt: PluginSystemPrompt;
|
|
132
|
+
readonly tools: PluginTools;
|
|
133
|
+
readonly sessionProjections: PluginSessionProjections;
|
|
134
|
+
readonly agentPresets: PluginAgentPresets;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=capabilityPorts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilityPorts.d.ts","sourceRoot":"","sources":["../src/capabilityPorts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,2CAA2C;AAC3C,eAAO,MAAM,kCAAkC,QAAc,CAAC;AAE9D,uBAAuB;AACvB,eAAO,MAAM,mCAAmC,QAAc,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,iCAAiC,8BAA8B,CAAC;AAE7E,uBAAuB;AACvB,eAAO,MAAM,gCAAgC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C;CACzD;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5C;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,6BAA6B,GAAG,cAAc,CAAC;CAChE;AAED,0DAA0D;AAC1D,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,kBAAkB,EAAE,wBAAwB,CAAC;IACtD,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;CAC3C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** 单份工具展示体上限(ADR-0036)。不进入模型可见的 `text`。 */
|
|
2
|
+
export const MAX_PLUGIN_TOOL_PRESENTATION_BYTES = 1024 * 1024;
|
|
3
|
+
/** 单份会话投影上限。不是编排事件。 */
|
|
4
|
+
export const MAX_PLUGIN_SESSION_PROJECTION_BYTES = 1024 * 1024;
|
|
5
|
+
/**
|
|
6
|
+
* 宿主挂在插件命令表上的流名字。客户端用现有 `plugins.subscribe` 订,
|
|
7
|
+
* payload 是 `{ name, threadId }`,每条值是 `{ present, value }`。
|
|
8
|
+
*/
|
|
9
|
+
export const PLUGIN_SESSION_PROJECTION_COMMAND = "ycodium.sessionProjection";
|
|
10
|
+
/** 单文件写入上限。本权限不含删除。 */
|
|
11
|
+
export const MAX_PLUGIN_WORKSPACE_WRITE_BYTES = 20 * 1024 * 1024;
|
|
12
|
+
/**
|
|
13
|
+
* 技能伴随文件上限。ADR 要求超限即 resolve 失败,但没给数字。
|
|
14
|
+
* 这是 Phase 1 宿主占位;Phase 2 拷进会话 skill 目录时必须遵守同一对数字。
|
|
15
|
+
*/
|
|
16
|
+
export const MAX_PLUGIN_SKILL_COMPANION_FILE_BYTES = 1024 * 1024;
|
|
17
|
+
export const MAX_PLUGIN_SKILL_COMPANION_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
18
|
+
/** UTF-8 字节数。不是 JSON 的值抛 TypeError。 */
|
|
19
|
+
export const pluginJsonByteLength = (value) => {
|
|
20
|
+
const encoded = JSON.stringify(value);
|
|
21
|
+
if (typeof encoded !== "string") {
|
|
22
|
+
throw new TypeError("value is not JSON");
|
|
23
|
+
}
|
|
24
|
+
return new TextEncoder().encode(encoded).byteLength;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 收下工具展示体。缺席、非 JSON、或超过 {@link MAX_PLUGIN_TOOL_PRESENTATION_BYTES} 时返回 null。
|
|
28
|
+
* 调用方仍画文字卡,并且不得把这份值写进模型可见文本。
|
|
29
|
+
*/
|
|
30
|
+
export const acceptPluginToolPresentation = (value) => {
|
|
31
|
+
if (value === undefined)
|
|
32
|
+
return null;
|
|
33
|
+
let encoded;
|
|
34
|
+
try {
|
|
35
|
+
const json = JSON.stringify(value);
|
|
36
|
+
if (typeof json !== "string")
|
|
37
|
+
return null;
|
|
38
|
+
encoded = json;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (new TextEncoder().encode(encoded).byteLength > MAX_PLUGIN_TOOL_PRESENTATION_BYTES) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return JSON.parse(encoded);
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=capabilityPorts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilityPorts.js","sourceRoot":"","sources":["../src/capabilityPorts.ts"],"names":[],"mappings":"AAYA,2CAA2C;AAC3C,MAAM,CAAC,MAAM,kCAAkC,GAAG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GAAG,kCAAkC,EAAE,CAAC;QACtF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAe,CAAC;AAC3C,CAAC,CAAC"}
|
package/dist/conversation.d.ts
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* @module @ycodium-ai/plugin-api/conversation
|
|
27
27
|
*/
|
|
28
28
|
import type { ConversationComposerAccountUsage } from "./account-usage.ts";
|
|
29
|
+
import type { ConversationPresetApi } from "./conversationPresets.ts";
|
|
29
30
|
import type { ConversationAttachmentDocumentOpen, ConversationAttachmentsApi, ConversationMessageAttachment, ConversationPastedTextSource } from "./conversationAttachments.ts";
|
|
30
31
|
export type * from "./conversationAttachments.ts";
|
|
31
32
|
import type { ConversationAssistantQuoteApi, ConversationMessageLinkText, ConversationThreadReferenceApi } from "./conversationMessageLinks.ts";
|
|
@@ -38,6 +39,8 @@ export type * from "./conversationSkills.ts";
|
|
|
38
39
|
import type { ConversationCommunicationRecord, ConversationTrajectoryRow } from "./conversationTrajectory.ts";
|
|
39
40
|
export type * from "./conversationTrajectory.ts";
|
|
40
41
|
import type { ConversationQueuedMessageEdit, ConversationQueueEntry, ConversationPendingQueueSubmission, ConversationQueueState } from "./conversation-queue.ts";
|
|
42
|
+
import type { ConversationWorkEntry } from "./conversationWorkEntry.ts";
|
|
43
|
+
export type * from "./conversationWorkEntry.ts";
|
|
41
44
|
export type { AccountUsageCapability, AccountUsageCredentialIdentity, AccountUsageMetric, AccountUsageMetricKind, AccountUsageRefreshOutcome, AccountUsageRefreshResult, AccountUsageResetOutcome, AccountUsageScopeKind, AccountUsageSnapshot, AccountUsageUnit, ConversationComposerAccountUsage, } from "./account-usage.ts";
|
|
42
45
|
/** 时间线派生输入。插件只透传,不解读。 */
|
|
43
46
|
export type ConversationTimelineEntry = unknown;
|
|
@@ -96,57 +99,6 @@ export interface ConversationTurnUsage {
|
|
|
96
99
|
*/
|
|
97
100
|
readonly cacheDisjoint?: boolean | undefined;
|
|
98
101
|
}
|
|
99
|
-
/** 工具/过程行的可渲染子集。展开详情走 `renderWorkGroup` 接缝,不在这里。 */
|
|
100
|
-
export interface ConversationWorkEntry {
|
|
101
|
-
readonly id: string;
|
|
102
|
-
readonly createdAt: string;
|
|
103
|
-
readonly label: string;
|
|
104
|
-
readonly tone: "thinking" | "tool" | "info" | "error";
|
|
105
|
-
readonly detail?: string | undefined;
|
|
106
|
-
readonly command?: string | undefined;
|
|
107
|
-
readonly rawCommand?: string | undefined;
|
|
108
|
-
readonly changedFiles?: ReadonlyArray<string> | undefined;
|
|
109
|
-
readonly toolTitle?: string | undefined;
|
|
110
|
-
/** 分段标题(工具名/路径/参数摘要);拿不到时宿主不给。 */
|
|
111
|
-
readonly toolLabel?: {
|
|
112
|
-
readonly name: string;
|
|
113
|
-
readonly path?: string | undefined;
|
|
114
|
-
readonly detail?: string | undefined;
|
|
115
|
-
readonly diffStat?: {
|
|
116
|
-
readonly additions: number;
|
|
117
|
-
readonly deletions: number;
|
|
118
|
-
} | undefined;
|
|
119
|
-
readonly descriptive: boolean;
|
|
120
|
-
} | undefined;
|
|
121
|
-
/** 工具的原始载荷(对插件不透明;折叠摘要的回退标题从里面猜工具名)。 */
|
|
122
|
-
readonly toolData?: unknown;
|
|
123
|
-
/**
|
|
124
|
-
* 出现即表示这是 Ycodium 自己的浏览器工具行;`pageUrl` 只在 agent 真的打开过那个页面时才有。
|
|
125
|
-
* 旧宿主不给这个字段,插件照旧画原来的图标。
|
|
126
|
-
*/
|
|
127
|
-
readonly toolIcon?: {
|
|
128
|
-
readonly kind: "website";
|
|
129
|
-
readonly pageUrl?: string | undefined;
|
|
130
|
-
} | undefined;
|
|
131
|
-
readonly toolCallId?: string | undefined;
|
|
132
|
-
readonly turnId?: string | null | undefined;
|
|
133
|
-
readonly itemType?: string | undefined;
|
|
134
|
-
readonly toolLifecycleStatus?: string | undefined;
|
|
135
|
-
readonly sourceActivityKind?: string | undefined;
|
|
136
|
-
readonly taskId?: string | undefined;
|
|
137
|
-
readonly agentRole?: string | undefined;
|
|
138
|
-
readonly agentSpawn?: {
|
|
139
|
-
readonly workflowId: string | null;
|
|
140
|
-
readonly agentTaskIds: ReadonlyArray<string>;
|
|
141
|
-
} | undefined;
|
|
142
|
-
readonly childThread?: {
|
|
143
|
-
readonly childThreadId: string;
|
|
144
|
-
readonly title: string;
|
|
145
|
-
readonly instanceId: string | null;
|
|
146
|
-
readonly model: string | null;
|
|
147
|
-
} | undefined;
|
|
148
|
-
readonly backgroundTasks?: readonly ConversationWorkEntry[] | undefined;
|
|
149
|
-
}
|
|
150
102
|
/** 建议计划卡片(宿主 `ProposedPlan` 的结构子集)。 */
|
|
151
103
|
export interface ConversationProposedPlan {
|
|
152
104
|
readonly id: string;
|
|
@@ -953,9 +905,7 @@ export interface ConversationComposerApi {
|
|
|
953
905
|
useActiveEnvironmentId(): ConversationEnvironmentId | null;
|
|
954
906
|
};
|
|
955
907
|
/** thread preset 列表(宿主 serverEnvironment 查询封装)。 */
|
|
956
|
-
readonly presets:
|
|
957
|
-
useThreadPresets(environmentId: ConversationEnvironmentId | null): ReadonlyArray<ConversationThreadPreset>;
|
|
958
|
-
};
|
|
908
|
+
readonly presets: ConversationPresetApi;
|
|
959
909
|
/** 同屏会话仲裁(宿主 useChatPaneKeydown / chatPaneVisibility)。 */
|
|
960
910
|
readonly pane: {
|
|
961
911
|
useKeydown(onKeydown: (event: KeyboardEvent) => void, options?: {
|
|
@@ -1671,7 +1621,7 @@ export interface ConversationComposerPlan {
|
|
|
1671
1621
|
readonly status: "pending" | "inProgress" | "completed";
|
|
1672
1622
|
}[] | null;
|
|
1673
1623
|
}
|
|
1674
|
-
export type ConversationViewMode = "chat" | "trajectory";
|
|
1624
|
+
export type ConversationViewMode = "chat" | "trajectory" | "map";
|
|
1675
1625
|
/** 会话身份与多 pane 仲裁。`active` 为 false 的实例不得绑定全局监听。 */
|
|
1676
1626
|
export interface ConversationScopeProps {
|
|
1677
1627
|
readonly environmentId: string;
|