@downcity/agent 1.1.108 → 1.1.113

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.
Files changed (101) hide show
  1. package/bin/agent/remote/RemoteAgent.d.ts +9 -1
  2. package/bin/agent/remote/RemoteAgent.d.ts.map +1 -1
  3. package/bin/agent/remote/RemoteAgent.js +22 -0
  4. package/bin/agent/remote/RemoteAgent.js.map +1 -1
  5. package/bin/agent/remote/RemoteTransport.d.ts +3 -1
  6. package/bin/agent/remote/RemoteTransport.d.ts.map +1 -1
  7. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +2 -1
  8. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -1
  9. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +26 -0
  10. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js.map +1 -1
  11. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +2 -1
  12. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -1
  13. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +7 -0
  14. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js.map +1 -1
  15. package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
  16. package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
  17. package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
  18. package/bin/executor/composer/system/default/assets/core.prompt.js.map +1 -1
  19. package/bin/executor/tools/shell/ShellToolBridge.d.ts.map +1 -1
  20. package/bin/executor/tools/shell/ShellToolBridge.js +22 -4
  21. package/bin/executor/tools/shell/ShellToolBridge.js.map +1 -1
  22. package/bin/executor/tools/shell/ShellToolDefinition.d.ts +2 -0
  23. package/bin/executor/tools/shell/ShellToolDefinition.d.ts.map +1 -1
  24. package/bin/executor/tools/shell/ShellToolDefinition.js +14 -4
  25. package/bin/executor/tools/shell/ShellToolDefinition.js.map +1 -1
  26. package/bin/executor/tools/shell/ShellToolSchemas.d.ts +11 -0
  27. package/bin/executor/tools/shell/ShellToolSchemas.d.ts.map +1 -1
  28. package/bin/executor/tools/shell/ShellToolSchemas.js +17 -0
  29. package/bin/executor/tools/shell/ShellToolSchemas.js.map +1 -1
  30. package/bin/executor/tools/shell/types/Shell.d.ts +18 -0
  31. package/bin/executor/tools/shell/types/Shell.d.ts.map +1 -1
  32. package/bin/executor/tools/shell/types/ShellPlugin.d.ts +34 -0
  33. package/bin/executor/tools/shell/types/ShellPlugin.d.ts.map +1 -1
  34. package/bin/index.d.ts +1 -1
  35. package/bin/index.d.ts.map +1 -1
  36. package/bin/index.js.map +1 -1
  37. package/bin/sandbox/LinuxBubblewrapSandbox.d.ts.map +1 -1
  38. package/bin/sandbox/LinuxBubblewrapSandbox.js +1 -0
  39. package/bin/sandbox/LinuxBubblewrapSandbox.js.map +1 -1
  40. package/bin/sandbox/MacOsSeatbeltSandbox.d.ts.map +1 -1
  41. package/bin/sandbox/MacOsSeatbeltSandbox.js +1 -0
  42. package/bin/sandbox/MacOsSeatbeltSandbox.js.map +1 -1
  43. package/bin/sandbox/SandboxRunner.d.ts +2 -0
  44. package/bin/sandbox/SandboxRunner.d.ts.map +1 -1
  45. package/bin/sandbox/SandboxRunner.js +14 -0
  46. package/bin/sandbox/SandboxRunner.js.map +1 -1
  47. package/bin/sandbox/UnrestrictedSandbox.d.ts +16 -0
  48. package/bin/sandbox/UnrestrictedSandbox.d.ts.map +1 -0
  49. package/bin/sandbox/UnrestrictedSandbox.js +39 -0
  50. package/bin/sandbox/UnrestrictedSandbox.js.map +1 -0
  51. package/bin/sandbox/types/SandboxRuntime.d.ts +9 -1
  52. package/bin/sandbox/types/SandboxRuntime.d.ts.map +1 -1
  53. package/bin/session/Session.d.ts.map +1 -1
  54. package/bin/session/Session.js +3 -0
  55. package/bin/session/Session.js.map +1 -1
  56. package/bin/session/services/SessionTurnService.d.ts.map +1 -1
  57. package/bin/session/services/SessionTurnService.js +1 -0
  58. package/bin/session/services/SessionTurnService.js.map +1 -1
  59. package/bin/session/storage/RuntimeSessionPort.d.ts +5 -1
  60. package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
  61. package/bin/session/storage/RuntimeSessionPort.js +3 -0
  62. package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
  63. package/bin/types/agent/AgentTypes.d.ts +1 -0
  64. package/bin/types/agent/AgentTypes.d.ts.map +1 -1
  65. package/bin/types/agent/RemoteAgentPluginAction.d.ts +46 -0
  66. package/bin/types/agent/RemoteAgentPluginAction.d.ts.map +1 -0
  67. package/bin/types/agent/RemoteAgentPluginAction.js +9 -0
  68. package/bin/types/agent/RemoteAgentPluginAction.js.map +1 -0
  69. package/bin/types/executor/SessionRunContext.d.ts +8 -0
  70. package/bin/types/executor/SessionRunContext.d.ts.map +1 -1
  71. package/bin/types/runtime/agent/AgentContext.d.ts +9 -1
  72. package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
  73. package/bin/types/sdk/AgentSessionEvent.d.ts +97 -3
  74. package/bin/types/sdk/AgentSessionEvent.d.ts.map +1 -1
  75. package/package.json +2 -2
  76. package/src/agent/remote/RemoteAgent.ts +27 -0
  77. package/src/agent/remote/RemoteTransport.ts +6 -0
  78. package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +38 -0
  79. package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +12 -0
  80. package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
  81. package/src/executor/composer/system/default/assets/core.prompt.ts.txt +5 -2
  82. package/src/executor/tools/shell/ShellToolBridge.ts +24 -4
  83. package/src/executor/tools/shell/ShellToolDefinition.ts +17 -2
  84. package/src/executor/tools/shell/ShellToolSchemas.ts +19 -0
  85. package/src/executor/tools/shell/types/Shell.ts +20 -0
  86. package/src/executor/tools/shell/types/ShellPlugin.ts +37 -0
  87. package/src/index.ts +2 -0
  88. package/src/sandbox/LinuxBubblewrapSandbox.ts +1 -0
  89. package/src/sandbox/MacOsSeatbeltSandbox.ts +1 -0
  90. package/src/sandbox/SandboxRunner.ts +17 -0
  91. package/src/sandbox/UnrestrictedSandbox.ts +53 -0
  92. package/src/sandbox/types/SandboxRuntime.ts +11 -1
  93. package/src/session/Session.ts +3 -0
  94. package/src/session/services/SessionTurnService.ts +1 -0
  95. package/src/session/storage/RuntimeSessionPort.ts +8 -0
  96. package/src/types/agent/AgentTypes.ts +4 -0
  97. package/src/types/agent/RemoteAgentPluginAction.ts +52 -0
  98. package/src/types/executor/SessionRunContext.ts +9 -0
  99. package/src/types/runtime/agent/AgentContext.ts +9 -0
  100. package/src/types/sdk/AgentSessionEvent.ts +118 -2
  101. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,52 @@
1
+ /**
2
+ * RemoteAgent plugin action 类型。
3
+ *
4
+ * 关键点(中文)
5
+ * - RemoteAgent 是远程 runtime 的瘦客户端,因此这里只描述远程调用协议。
6
+ * - 业务 action 的具体 payload 与 data 由目标 plugin 自己定义。
7
+ */
8
+
9
+ import type { JsonValue } from "@/types/common/Json.js";
10
+ import type { PluginActionResult } from "@/types/plugin/PluginAction.js";
11
+
12
+ /**
13
+ * RemoteAgent 远程 plugin action 调用输入。
14
+ */
15
+ export interface RemoteAgentPluginActionInput {
16
+ /**
17
+ * 目标 plugin 名称。
18
+ *
19
+ * 示例:`shell`、`chat`、`task`。
20
+ */
21
+ plugin: string;
22
+
23
+ /**
24
+ * 目标 action 名称。
25
+ *
26
+ * 示例:`approve`、`deny`、`send`。
27
+ */
28
+ action: string;
29
+
30
+ /**
31
+ * 传给目标 action 的 JSON payload。
32
+ *
33
+ * shell approval 示例:`{ "approvalId": "ap_xxx" }`。
34
+ */
35
+ payload?: JsonValue;
36
+ }
37
+
38
+ /**
39
+ * RemoteAgent 远程 plugin action 调用结果。
40
+ */
41
+ export type RemoteAgentPluginActionResult =
42
+ PluginActionResult<JsonValue> & {
43
+ /**
44
+ * Runtime 回传的 plugin 名称。
45
+ */
46
+ pluginName?: string;
47
+
48
+ /**
49
+ * Runtime 回传的 action 名称。
50
+ */
51
+ actionName?: string;
52
+ };
@@ -18,6 +18,15 @@ import type { FileUIPart } from "ai";
18
18
  * 单次 session run 的运行上下文。
19
19
  */
20
20
  export interface SessionRunContext {
21
+ /**
22
+ * 当前执行所属的 turn 标识。
23
+ *
24
+ * 关键点(中文)
25
+ * - session 是长期对话容器,turn 是单次用户输入触发的执行轮次。
26
+ * - 工具运行时发布 session event 时应优先使用该字段,避免把 sessionId 误当 turnId。
27
+ */
28
+ turnId?: string;
29
+
21
30
  /**
22
31
  * 当前执行所属的 session 标识。
23
32
  */
@@ -31,6 +31,7 @@ import type {
31
31
  import type { SessionHistoryStore } from "@/executor/store/history/SessionHistoryStore.js";
32
32
  import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
33
33
  import type {
34
+ AgentSessionEvent,
34
35
  AgentSessionSubscriber,
35
36
  AgentSessionUnsubscribe,
36
37
  } from "@/types/sdk/AgentSessionEvent.js";
@@ -132,6 +133,14 @@ export interface SessionPort {
132
133
  * - 历史消息仍通过 `getHistoryStore()` / SDK `history()` 读取。
133
134
  */
134
135
  subscribe(subscriber: AgentSessionSubscriber): AgentSessionUnsubscribe;
136
+ /**
137
+ * 发布一条 session runtime 事件。
138
+ *
139
+ * 关键点(中文)
140
+ * - plugin runtime 用它把审批、外部进度等非模型 chunk 事件推送给订阅方。
141
+ * - 历史消息持久化仍由 appendUserMessage / appendAssistantMessage 负责。
142
+ */
143
+ publishEvent(event: AgentSessionEvent): void;
135
144
  /**
136
145
  * 清理当前 session 的 executor 缓存。
137
146
  */
@@ -90,7 +90,7 @@ export interface AgentSessionToolCallEvent {
90
90
  /**
91
91
  * 当前工具名称。
92
92
  */
93
- toolName: string;
93
+ toolName: "shell_exec" | "shell_start" | "shell_write" | string;
94
94
 
95
95
  /**
96
96
  * 当前工具输入参数。
@@ -120,7 +120,7 @@ export interface AgentSessionToolResultEvent {
120
120
  /**
121
121
  * 当前工具名称。
122
122
  */
123
- toolName: string;
123
+ toolName: "shell_exec" | "shell_start" | "shell_write" | string;
124
124
 
125
125
  /**
126
126
  * 当前工具输出结果。
@@ -128,6 +128,120 @@ export interface AgentSessionToolResultEvent {
128
128
  result: JsonValue;
129
129
  }
130
130
 
131
+ /**
132
+ * 工具审批请求事件。
133
+ */
134
+ export interface AgentSessionToolApprovalRequestEvent {
135
+ /**
136
+ * 当前事件类型。
137
+ */
138
+ type: "tool-approval-request";
139
+
140
+ /**
141
+ * 当前审批所属 turn。
142
+ */
143
+ turnId: string;
144
+
145
+ /**
146
+ * 当前工具调用唯一标识。
147
+ */
148
+ toolCallId: string;
149
+
150
+ /**
151
+ * 当前工具名称。
152
+ */
153
+ toolName: "shell_exec" | "shell_start" | "shell_write" | string;
154
+
155
+ /**
156
+ * 当前审批请求唯一标识。
157
+ */
158
+ approvalId: string;
159
+
160
+ /**
161
+ * 请求执行的 sandbox 模式。
162
+ */
163
+ sandbox: "unrestricted";
164
+
165
+ /**
166
+ * 请求执行的命令文本。
167
+ *
168
+ * 说明(中文)
169
+ * - `shell_exec` / `shell_start` 中是命令文本。
170
+ * - `shell_write` 中是 stdin 写入内容,用于兼容旧 UI 展示。
171
+ */
172
+ cmd: string;
173
+
174
+ /**
175
+ * 当前审批动作类型。
176
+ */
177
+ operation?: "exec" | "start" | "write";
178
+
179
+ /**
180
+ * 关联 shell_id;`shell_write` 审批时用于标识目标会话。
181
+ */
182
+ shellId?: string;
183
+
184
+ /**
185
+ * stdin 写入内容预览;仅 `shell_write` 审批存在。
186
+ */
187
+ inputPreview?: string;
188
+
189
+ /**
190
+ * stdin 写入字符数;仅 `shell_write` 审批存在。
191
+ */
192
+ inputChars?: number;
193
+
194
+ /**
195
+ * 命令执行目录。
196
+ */
197
+ cwd: string;
198
+
199
+ /**
200
+ * Agent 给用户展示的申请原因。
201
+ */
202
+ reason: string;
203
+
204
+ /**
205
+ * 当前审批状态。
206
+ */
207
+ status: "pending";
208
+ }
209
+
210
+ /**
211
+ * 工具审批结果事件。
212
+ */
213
+ export interface AgentSessionToolApprovalResultEvent {
214
+ /**
215
+ * 当前事件类型。
216
+ */
217
+ type: "tool-approval-result";
218
+
219
+ /**
220
+ * 当前审批所属 turn。
221
+ */
222
+ turnId: string;
223
+
224
+ /**
225
+ * 当前工具调用唯一标识。
226
+ */
227
+ toolCallId: string;
228
+
229
+ /**
230
+ * 当前工具名称。
231
+ */
232
+ toolName: "shell_exec" | "shell_start" | "shell_write" | string;
233
+
234
+ /**
235
+ * 当前审批请求唯一标识。
236
+ */
237
+ approvalId: string;
238
+
239
+ /**
240
+ * 用户最终决策。
241
+ */
242
+ decision: "approved" | "denied" | "expired";
243
+ }
244
+
131
245
  /**
132
246
  * assistant step 完成事件。
133
247
  */
@@ -236,6 +350,8 @@ export type AgentSessionEvent =
236
350
  | AgentSessionReasoningDeltaEvent
237
351
  | AgentSessionToolCallEvent
238
352
  | AgentSessionToolResultEvent
353
+ | AgentSessionToolApprovalRequestEvent
354
+ | AgentSessionToolApprovalResultEvent
239
355
  | AgentSessionAssistantStepEvent
240
356
  | AgentSessionTitleEvent
241
357
  | AgentSessionTurnFinishEvent