@downcity/agent 1.1.113 → 1.1.119
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/bin/agent/local/Agent.d.ts +39 -0
- package/bin/agent/local/Agent.d.ts.map +1 -1
- package/bin/agent/local/Agent.js +53 -0
- package/bin/agent/local/Agent.js.map +1 -1
- package/bin/agent/local/services/AgentAssemblyService.d.ts +4 -0
- package/bin/agent/local/services/AgentAssemblyService.d.ts.map +1 -1
- package/bin/agent/local/services/AgentAssemblyService.js +18 -2
- package/bin/agent/local/services/AgentAssemblyService.js.map +1 -1
- package/bin/agent/local/services/AgentLifecycleService.d.ts +6 -0
- package/bin/agent/local/services/AgentLifecycleService.d.ts.map +1 -1
- package/bin/agent/local/services/AgentLifecycleService.js +4 -0
- package/bin/agent/local/services/AgentLifecycleService.js.map +1 -1
- package/bin/agent/remote/RemoteAgent.d.ts +35 -1
- package/bin/agent/remote/RemoteAgent.d.ts.map +1 -1
- package/bin/agent/remote/RemoteAgent.js +37 -1
- package/bin/agent/remote/RemoteAgent.js.map +1 -1
- package/bin/agent/remote/RemoteTransport.d.ts +22 -0
- package/bin/agent/remote/RemoteTransport.d.ts.map +1 -1
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +17 -0
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -1
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +63 -0
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.js.map +1 -1
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +16 -0
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -1
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +18 -0
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.js.map +1 -1
- package/bin/executor/Executor.d.ts.map +1 -1
- package/bin/executor/Executor.js +7 -1
- package/bin/executor/Executor.js.map +1 -1
- package/bin/index.d.ts +0 -1
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +0 -1
- package/bin/index.js.map +1 -1
- package/bin/rpc/Client.d.ts +28 -0
- package/bin/rpc/Client.d.ts.map +1 -1
- package/bin/rpc/Client.js +63 -0
- package/bin/rpc/Client.js.map +1 -1
- package/bin/rpc/server/InternalHandlers.d.ts.map +1 -1
- package/bin/rpc/server/InternalHandlers.js +54 -0
- package/bin/rpc/server/InternalHandlers.js.map +1 -1
- package/bin/rpc/server/ServerTypes.d.ts +5 -0
- package/bin/rpc/server/ServerTypes.d.ts.map +1 -1
- package/bin/types/agent/AgentOptions.d.ts +9 -0
- package/bin/types/agent/AgentOptions.d.ts.map +1 -1
- package/bin/types/config/DowncityConfig.d.ts +2 -2
- package/bin/types/config/DowncityConfig.d.ts.map +1 -1
- package/bin/types/rpc/RpcProtocol.d.ts +53 -0
- package/bin/types/rpc/RpcProtocol.d.ts.map +1 -1
- package/package.json +4 -3
- package/scripts/linux-bubblewrap-sandbox.test.mjs +1 -1
- package/scripts/shell-sandbox-preflight.test.mjs +1 -1
- package/src/agent/local/Agent.ts +68 -0
- package/src/agent/local/services/AgentAssemblyService.ts +23 -2
- package/src/agent/local/services/AgentLifecycleService.ts +11 -0
- package/src/agent/remote/RemoteAgent.ts +54 -1
- package/src/agent/remote/RemoteTransport.ts +23 -0
- package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +101 -0
- package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +35 -0
- package/src/executor/Executor.ts +12 -2
- package/src/index.ts +0 -1
- package/src/rpc/Client.ts +80 -0
- package/src/rpc/server/InternalHandlers.ts +55 -0
- package/src/rpc/server/ServerTypes.ts +5 -0
- package/src/types/agent/AgentOptions.ts +10 -0
- package/src/types/config/DowncityConfig.ts +2 -2
- package/src/types/rpc/RpcProtocol.ts +59 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/executor/tools/shell/ShellToolBridge.d.ts +0 -79
- package/bin/executor/tools/shell/ShellToolBridge.d.ts.map +0 -1
- package/bin/executor/tools/shell/ShellToolBridge.js +0 -320
- package/bin/executor/tools/shell/ShellToolBridge.js.map +0 -1
- package/bin/executor/tools/shell/ShellToolDefinition.d.ts +0 -116
- package/bin/executor/tools/shell/ShellToolDefinition.d.ts.map +0 -1
- package/bin/executor/tools/shell/ShellToolDefinition.js +0 -369
- package/bin/executor/tools/shell/ShellToolDefinition.js.map +0 -1
- package/bin/executor/tools/shell/ShellToolFormatting.d.ts +0 -17
- package/bin/executor/tools/shell/ShellToolFormatting.d.ts.map +0 -1
- package/bin/executor/tools/shell/ShellToolFormatting.js +0 -36
- package/bin/executor/tools/shell/ShellToolFormatting.js.map +0 -1
- package/bin/executor/tools/shell/ShellToolSchemas.d.ts +0 -61
- package/bin/executor/tools/shell/ShellToolSchemas.d.ts.map +0 -1
- package/bin/executor/tools/shell/ShellToolSchemas.js +0 -130
- package/bin/executor/tools/shell/ShellToolSchemas.js.map +0 -1
- package/bin/executor/tools/shell/types/Shell.d.ts +0 -115
- package/bin/executor/tools/shell/types/Shell.d.ts.map +0 -1
- package/bin/executor/tools/shell/types/Shell.js +0 -9
- package/bin/executor/tools/shell/types/Shell.js.map +0 -1
- package/bin/executor/tools/shell/types/ShellPlugin.d.ts +0 -258
- package/bin/executor/tools/shell/types/ShellPlugin.d.ts.map +0 -1
- package/bin/executor/tools/shell/types/ShellPlugin.js +0 -9
- package/bin/executor/tools/shell/types/ShellPlugin.js.map +0 -1
- package/bin/sandbox/LinuxBubblewrapSandbox.d.ts +0 -19
- package/bin/sandbox/LinuxBubblewrapSandbox.d.ts.map +0 -1
- package/bin/sandbox/LinuxBubblewrapSandbox.js +0 -186
- package/bin/sandbox/LinuxBubblewrapSandbox.js.map +0 -1
- package/bin/sandbox/MacOsSeatbeltSandbox.d.ts +0 -16
- package/bin/sandbox/MacOsSeatbeltSandbox.d.ts.map +0 -1
- package/bin/sandbox/MacOsSeatbeltSandbox.js +0 -154
- package/bin/sandbox/MacOsSeatbeltSandbox.js.map +0 -1
- package/bin/sandbox/SandboxConfigResolver.d.ts +0 -37
- package/bin/sandbox/SandboxConfigResolver.d.ts.map +0 -1
- package/bin/sandbox/SandboxConfigResolver.js +0 -130
- package/bin/sandbox/SandboxConfigResolver.js.map +0 -1
- package/bin/sandbox/SandboxPreflight.d.ts +0 -73
- package/bin/sandbox/SandboxPreflight.d.ts.map +0 -1
- package/bin/sandbox/SandboxPreflight.js +0 -122
- package/bin/sandbox/SandboxPreflight.js.map +0 -1
- package/bin/sandbox/SandboxRunner.d.ts +0 -61
- package/bin/sandbox/SandboxRunner.d.ts.map +0 -1
- package/bin/sandbox/SandboxRunner.js +0 -107
- package/bin/sandbox/SandboxRunner.js.map +0 -1
- package/bin/sandbox/UnrestrictedSandbox.d.ts +0 -16
- package/bin/sandbox/UnrestrictedSandbox.d.ts.map +0 -1
- package/bin/sandbox/UnrestrictedSandbox.js +0 -39
- package/bin/sandbox/UnrestrictedSandbox.js.map +0 -1
- package/bin/sandbox/types/Sandbox.d.ts +0 -130
- package/bin/sandbox/types/Sandbox.d.ts.map +0 -1
- package/bin/sandbox/types/Sandbox.js +0 -10
- package/bin/sandbox/types/Sandbox.js.map +0 -1
- package/bin/sandbox/types/SandboxRuntime.d.ts +0 -370
- package/bin/sandbox/types/SandboxRuntime.d.ts.map +0 -1
- package/bin/sandbox/types/SandboxRuntime.js +0 -10
- package/bin/sandbox/types/SandboxRuntime.js.map +0 -1
- package/src/executor/tools/shell/ShellToolBridge.ts +0 -412
- package/src/executor/tools/shell/ShellToolDefinition.ts +0 -524
- package/src/executor/tools/shell/ShellToolFormatting.ts +0 -34
- package/src/executor/tools/shell/ShellToolSchemas.ts +0 -139
- package/src/executor/tools/shell/types/Shell.ts +0 -123
- package/src/executor/tools/shell/types/ShellPlugin.ts +0 -278
- package/src/sandbox/LinuxBubblewrapSandbox.ts +0 -222
- package/src/sandbox/MacOsSeatbeltSandbox.ts +0 -191
- package/src/sandbox/SandboxConfigResolver.ts +0 -152
- package/src/sandbox/SandboxPreflight.ts +0 -205
- package/src/sandbox/SandboxRunner.ts +0 -151
- package/src/sandbox/UnrestrictedSandbox.ts +0 -53
- package/src/sandbox/types/Sandbox.ts +0 -144
- package/src/sandbox/types/SandboxRuntime.ts +0 -440
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shell tool 运行时桥接与响应整理。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - tool 层只负责协议适配,不直接持有 shell plugin runtime 具体实现。
|
|
6
|
-
* - runtime 注入、桥接协议解析、输出扁平化都收敛在这里,避免 `Tool.ts` 继续膨胀。
|
|
7
|
-
*/
|
|
8
|
-
import type { JsonObject, JsonValue } from "../../../types/common/Json.js";
|
|
9
|
-
import type { InvokePluginPort } from "../../../types/runtime/agent/AgentContext.js";
|
|
10
|
-
import type { ShellActionResponse } from "../../../executor/tools/shell/types/ShellPlugin.js";
|
|
11
|
-
export declare function setShellToolRuntime(next: InvokePluginPort): void;
|
|
12
|
-
/**
|
|
13
|
-
* 为可能触发桥接协议的命令建立状态缓存。
|
|
14
|
-
*/
|
|
15
|
-
export declare function trackShellCommandBridge(command: string, shellId: string): void;
|
|
16
|
-
/**
|
|
17
|
-
* 清理指定 shell 的桥接状态。
|
|
18
|
-
*/
|
|
19
|
-
export declare function clearShellCommandBridge(shellId: string): void;
|
|
20
|
-
/**
|
|
21
|
-
* 将 shell plugin runtime 响应整理为通用工具输出。
|
|
22
|
-
*/
|
|
23
|
-
export declare function flattenShellActionResponse(params: {
|
|
24
|
-
/**
|
|
25
|
-
* plugin runtime 返回的 shell 响应。
|
|
26
|
-
*/
|
|
27
|
-
response: ShellActionResponse;
|
|
28
|
-
/**
|
|
29
|
-
* tool 调用开始时间。
|
|
30
|
-
*/
|
|
31
|
-
startedAt: number;
|
|
32
|
-
}): JsonObject;
|
|
33
|
-
/**
|
|
34
|
-
* 将一次性执行响应整理为简化输出。
|
|
35
|
-
*/
|
|
36
|
-
export declare function flattenShellExecResponse(params: {
|
|
37
|
-
/**
|
|
38
|
-
* plugin runtime 返回的 shell 响应。
|
|
39
|
-
*/
|
|
40
|
-
response: ShellActionResponse;
|
|
41
|
-
/**
|
|
42
|
-
* tool 调用开始时间。
|
|
43
|
-
*/
|
|
44
|
-
startedAt: number;
|
|
45
|
-
}): JsonObject;
|
|
46
|
-
/**
|
|
47
|
-
* 尝试解析 shell 输出中的 runtime bridge 指令。
|
|
48
|
-
*/
|
|
49
|
-
export declare function bridgeCommandResponse(params: {
|
|
50
|
-
/**
|
|
51
|
-
* shell 唯一标识。
|
|
52
|
-
*/
|
|
53
|
-
shellId: string;
|
|
54
|
-
/**
|
|
55
|
-
* 已经扁平化后的 tool 输出。
|
|
56
|
-
*/
|
|
57
|
-
response: JsonObject;
|
|
58
|
-
}): Promise<JsonObject>;
|
|
59
|
-
/**
|
|
60
|
-
* 调用 shell plugin runtime action。
|
|
61
|
-
*/
|
|
62
|
-
export declare function invokeShellAction<TPayload extends JsonValue = JsonValue>(params: {
|
|
63
|
-
/**
|
|
64
|
-
* action 名称。
|
|
65
|
-
*/
|
|
66
|
-
action: string;
|
|
67
|
-
/**
|
|
68
|
-
* action 载荷。
|
|
69
|
-
*/
|
|
70
|
-
payload: TPayload;
|
|
71
|
-
}): Promise<ShellActionResponse>;
|
|
72
|
-
/**
|
|
73
|
-
* 统一格式化 tool 错误。
|
|
74
|
-
*/
|
|
75
|
-
export declare function formatToolError(prefix: string, error: unknown): {
|
|
76
|
-
success: false;
|
|
77
|
-
error: string;
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=ShellToolBridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShellToolBridge.d.ts","sourceRoot":"","sources":["../../../../src/executor/tools/shell/ShellToolBridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KA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A;CAAE,CAKnC"}
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shell tool 运行时桥接与响应整理。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - tool 层只负责协议适配,不直接持有 shell plugin runtime 具体实现。
|
|
6
|
-
* - runtime 注入、桥接协议解析、输出扁平化都收敛在这里,避免 `Tool.ts` 继续膨胀。
|
|
7
|
-
*/
|
|
8
|
-
import { generateId } from "../../../utils/Id.js";
|
|
9
|
-
import { enqueueDeferredPersistedUserMessage, enqueueInjectedUserMessage, getSessionRunContext, } from "../../SessionRunScope.js";
|
|
10
|
-
let shellToolRuntime = null;
|
|
11
|
-
/**
|
|
12
|
-
* 通用命令桥接状态表(按 shell_id)。
|
|
13
|
-
*/
|
|
14
|
-
const commandBridgeStates = new Map();
|
|
15
|
-
export function setShellToolRuntime(next) {
|
|
16
|
-
shellToolRuntime = next;
|
|
17
|
-
}
|
|
18
|
-
function requireShellToolRuntime() {
|
|
19
|
-
if (shellToolRuntime)
|
|
20
|
-
return shellToolRuntime;
|
|
21
|
-
throw new Error("Shell tool runtime is not initialized. Ensure runtime startup has completed before using shell tools.");
|
|
22
|
-
}
|
|
23
|
-
function toJsonObject(value) {
|
|
24
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
25
|
-
return null;
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
function tryParseJsonObject(raw) {
|
|
29
|
-
const text = String(raw || "").trim();
|
|
30
|
-
if (!text)
|
|
31
|
-
return null;
|
|
32
|
-
try {
|
|
33
|
-
const parsed = JSON.parse(text);
|
|
34
|
-
return toJsonObject(parsed);
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
const firstBrace = text.indexOf("{");
|
|
38
|
-
const lastBrace = text.lastIndexOf("}");
|
|
39
|
-
if (firstBrace < 0 || lastBrace <= firstBrace)
|
|
40
|
-
return null;
|
|
41
|
-
const candidate = text.slice(firstBrace, lastBrace + 1);
|
|
42
|
-
try {
|
|
43
|
-
const parsed = JSON.parse(candidate);
|
|
44
|
-
return toJsonObject(parsed);
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function shouldEnableCommandBridge(command) {
|
|
52
|
-
const raw = String(command || "").trim();
|
|
53
|
-
if (!raw)
|
|
54
|
-
return false;
|
|
55
|
-
return /(?:^|\s)(?:city|town)(?:\s|$)/i.test(raw);
|
|
56
|
-
}
|
|
57
|
-
async function injectUserTextMessage(params) {
|
|
58
|
-
const run_context = getSessionRunContext();
|
|
59
|
-
const sessionId = String(run_context?.sessionId || "").trim();
|
|
60
|
-
const text = String(params.text || "").trim();
|
|
61
|
-
if (!sessionId || !text)
|
|
62
|
-
return false;
|
|
63
|
-
const note = String(params.note || "runtime_injected_user_message");
|
|
64
|
-
enqueueInjectedUserMessage({
|
|
65
|
-
id: `u:${sessionId}:${generateId()}`,
|
|
66
|
-
role: "user",
|
|
67
|
-
metadata: {
|
|
68
|
-
v: 1,
|
|
69
|
-
ts: Date.now(),
|
|
70
|
-
sessionId,
|
|
71
|
-
source: "ingress",
|
|
72
|
-
kind: "normal",
|
|
73
|
-
extra: {
|
|
74
|
-
note,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
parts: [{ type: "text", text }],
|
|
78
|
-
});
|
|
79
|
-
enqueueDeferredPersistedUserMessage(sessionId, {
|
|
80
|
-
id: `u:${sessionId}:${generateId()}`,
|
|
81
|
-
role: "user",
|
|
82
|
-
metadata: {
|
|
83
|
-
v: 1,
|
|
84
|
-
ts: Date.now(),
|
|
85
|
-
sessionId,
|
|
86
|
-
source: "ingress",
|
|
87
|
-
kind: "normal",
|
|
88
|
-
extra: {
|
|
89
|
-
note,
|
|
90
|
-
injectedBy: "shell_runtime_bridge",
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
parts: [{ type: "text", text }],
|
|
94
|
-
});
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
function extractRuntimeBridgeBlock(payload) {
|
|
98
|
-
const data = toJsonObject(payload.data);
|
|
99
|
-
const bridge = toJsonObject((data?.__ship ?? payload.__ship));
|
|
100
|
-
if (!bridge)
|
|
101
|
-
return null;
|
|
102
|
-
const rawMessages = Array.isArray(bridge.injectUserMessages)
|
|
103
|
-
? bridge.injectUserMessages
|
|
104
|
-
: [];
|
|
105
|
-
const injectUserMessages = [];
|
|
106
|
-
for (const item of rawMessages) {
|
|
107
|
-
const obj = toJsonObject(item);
|
|
108
|
-
if (!obj)
|
|
109
|
-
continue;
|
|
110
|
-
const text = typeof obj.text === "string" ? obj.text.trim() : "";
|
|
111
|
-
if (!text)
|
|
112
|
-
continue;
|
|
113
|
-
const note = typeof obj.note === "string" && obj.note.trim() ? obj.note.trim() : undefined;
|
|
114
|
-
injectUserMessages.push({ text, ...(note ? { note } : {}) });
|
|
115
|
-
}
|
|
116
|
-
const suppressToolOutput = bridge.suppressToolOutput !== false;
|
|
117
|
-
const toolOutputMessage = typeof bridge.toolOutputMessage === "string" && bridge.toolOutputMessage.trim()
|
|
118
|
-
? bridge.toolOutputMessage.trim()
|
|
119
|
-
: "runtime bridge applied";
|
|
120
|
-
return {
|
|
121
|
-
injectUserMessages,
|
|
122
|
-
suppressToolOutput,
|
|
123
|
-
toolOutputMessage,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function sanitizeBridgeMarkers(payload) {
|
|
127
|
-
const cloned = JSON.parse(JSON.stringify(payload));
|
|
128
|
-
if ("__ship" in cloned)
|
|
129
|
-
delete cloned.__ship;
|
|
130
|
-
const data = toJsonObject(cloned.data);
|
|
131
|
-
if (data && "__ship" in data) {
|
|
132
|
-
delete data.__ship;
|
|
133
|
-
}
|
|
134
|
-
return cloned;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* 为可能触发桥接协议的命令建立状态缓存。
|
|
138
|
-
*/
|
|
139
|
-
export function trackShellCommandBridge(command, shellId) {
|
|
140
|
-
if (!shouldEnableCommandBridge(command))
|
|
141
|
-
return;
|
|
142
|
-
commandBridgeStates.set(shellId, { bufferedOutput: "" });
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* 清理指定 shell 的桥接状态。
|
|
146
|
-
*/
|
|
147
|
-
export function clearShellCommandBridge(shellId) {
|
|
148
|
-
commandBridgeStates.delete(shellId);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* 将 shell plugin runtime 响应整理为通用工具输出。
|
|
152
|
-
*/
|
|
153
|
-
export function flattenShellActionResponse(params) {
|
|
154
|
-
const shell = params.response.shell;
|
|
155
|
-
const chunk = params.response.chunk;
|
|
156
|
-
const exitCode = typeof shell.exitCode === "number" ? shell.exitCode : null;
|
|
157
|
-
const success = shell.approvalStatus !== "denied" &&
|
|
158
|
-
shell.approvalStatus !== "expired" &&
|
|
159
|
-
(exitCode === null || exitCode === 0);
|
|
160
|
-
return {
|
|
161
|
-
success,
|
|
162
|
-
shell_id: shell.shellId,
|
|
163
|
-
status: shell.status,
|
|
164
|
-
cmd: shell.cmd,
|
|
165
|
-
cwd: shell.cwd,
|
|
166
|
-
sandboxed: shell.sandboxed === true,
|
|
167
|
-
sandbox: shell.sandboxMode || (shell.sandboxed === false ? "unrestricted" : "safe"),
|
|
168
|
-
approval_status: shell.approvalStatus || null,
|
|
169
|
-
approval_id: shell.approvalId || null,
|
|
170
|
-
approval_reason: shell.approvalReason || null,
|
|
171
|
-
stdin_writable: shell.stdinWritable !== false,
|
|
172
|
-
sandbox_backend: shell.sandboxBackend || null,
|
|
173
|
-
sandbox_network_mode: shell.sandboxNetworkMode || null,
|
|
174
|
-
sandbox_dir: shell.sandboxDir || null,
|
|
175
|
-
sandbox_home_dir: shell.sandboxHomeDir || null,
|
|
176
|
-
sandbox_tmp_dir: shell.sandboxTmpDir || null,
|
|
177
|
-
sandbox_cache_dir: shell.sandboxCacheDir || null,
|
|
178
|
-
pid: typeof shell.pid === "number" ? shell.pid : null,
|
|
179
|
-
version: shell.version,
|
|
180
|
-
started_at: shell.startedAt,
|
|
181
|
-
updated_at: shell.updatedAt,
|
|
182
|
-
ended_at: typeof shell.endedAt === "number" ? shell.endedAt : null,
|
|
183
|
-
exit_code: exitCode,
|
|
184
|
-
output: chunk?.output || "",
|
|
185
|
-
start_cursor: typeof chunk?.startCursor === "number" ? chunk.startCursor : null,
|
|
186
|
-
end_cursor: typeof chunk?.endCursor === "number" ? chunk.endCursor : null,
|
|
187
|
-
original_chars: chunk?.originalChars ?? 0,
|
|
188
|
-
original_lines: chunk?.originalLines ?? 0,
|
|
189
|
-
has_more_output: chunk?.hasMoreOutput === true,
|
|
190
|
-
last_output_preview: shell.lastOutputPreview || "",
|
|
191
|
-
output_chars: shell.outputChars,
|
|
192
|
-
dropped_chars: shell.droppedChars,
|
|
193
|
-
auto_notify_on_exit: shell.autoNotifyOnExit,
|
|
194
|
-
notification_sent: shell.notificationSent,
|
|
195
|
-
owner_context_id: shell.ownerContextId || null,
|
|
196
|
-
external_refs: shell.externalRefs,
|
|
197
|
-
wall_time_seconds: Math.max(0, (Date.now() - params.startedAt) / 1000),
|
|
198
|
-
...(params.response.note ? { note: params.response.note } : {}),
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* 将一次性执行响应整理为简化输出。
|
|
203
|
-
*/
|
|
204
|
-
export function flattenShellExecResponse(params) {
|
|
205
|
-
const shell = params.response.shell;
|
|
206
|
-
const chunk = params.response.chunk;
|
|
207
|
-
const exitCode = typeof shell.exitCode === "number" ? shell.exitCode : null;
|
|
208
|
-
const success = shell.approvalStatus !== "denied" &&
|
|
209
|
-
shell.approvalStatus !== "expired" &&
|
|
210
|
-
(exitCode === null || exitCode === 0);
|
|
211
|
-
return {
|
|
212
|
-
success,
|
|
213
|
-
status: shell.status,
|
|
214
|
-
cmd: shell.cmd,
|
|
215
|
-
cwd: shell.cwd,
|
|
216
|
-
sandboxed: shell.sandboxed === true,
|
|
217
|
-
sandbox: shell.sandboxMode || (shell.sandboxed === false ? "unrestricted" : "safe"),
|
|
218
|
-
approval_status: shell.approvalStatus || null,
|
|
219
|
-
approval_id: shell.approvalId || null,
|
|
220
|
-
approval_reason: shell.approvalReason || null,
|
|
221
|
-
stdin_writable: shell.stdinWritable !== false,
|
|
222
|
-
sandbox_backend: shell.sandboxBackend || null,
|
|
223
|
-
sandbox_network_mode: shell.sandboxNetworkMode || null,
|
|
224
|
-
sandbox_dir: shell.sandboxDir || null,
|
|
225
|
-
sandbox_home_dir: shell.sandboxHomeDir || null,
|
|
226
|
-
sandbox_tmp_dir: shell.sandboxTmpDir || null,
|
|
227
|
-
sandbox_cache_dir: shell.sandboxCacheDir || null,
|
|
228
|
-
exit_code: exitCode,
|
|
229
|
-
output: chunk?.output || "",
|
|
230
|
-
original_chars: chunk?.originalChars ?? 0,
|
|
231
|
-
original_lines: chunk?.originalLines ?? 0,
|
|
232
|
-
external_refs: shell.externalRefs,
|
|
233
|
-
wall_time_seconds: Math.max(0, (Date.now() - params.startedAt) / 1000),
|
|
234
|
-
...(params.response.note ? { note: params.response.note } : {}),
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* 尝试解析 shell 输出中的 runtime bridge 指令。
|
|
239
|
-
*/
|
|
240
|
-
export async function bridgeCommandResponse(params) {
|
|
241
|
-
const state = commandBridgeStates.get(params.shellId);
|
|
242
|
-
if (!state)
|
|
243
|
-
return params.response;
|
|
244
|
-
const rawOutput = typeof params.response.output === "string" ? params.response.output : "";
|
|
245
|
-
if (rawOutput) {
|
|
246
|
-
state.bufferedOutput += rawOutput;
|
|
247
|
-
}
|
|
248
|
-
const hasMoreOutput = params.response.has_more_output === true;
|
|
249
|
-
const exitCode = typeof params.response.exit_code === "number"
|
|
250
|
-
? params.response.exit_code
|
|
251
|
-
: null;
|
|
252
|
-
const status = String(params.response.status || "").trim();
|
|
253
|
-
const completed = !hasMoreOutput &&
|
|
254
|
-
exitCode !== null &&
|
|
255
|
-
status !== "running" &&
|
|
256
|
-
status !== "starting";
|
|
257
|
-
if (!completed)
|
|
258
|
-
return params.response;
|
|
259
|
-
commandBridgeStates.delete(params.shellId);
|
|
260
|
-
const payload = tryParseJsonObject(state.bufferedOutput);
|
|
261
|
-
if (!payload)
|
|
262
|
-
return params.response;
|
|
263
|
-
const bridge = extractRuntimeBridgeBlock(payload);
|
|
264
|
-
if (!bridge)
|
|
265
|
-
return params.response;
|
|
266
|
-
let injectedCount = 0;
|
|
267
|
-
for (const item of bridge.injectUserMessages) {
|
|
268
|
-
if (await injectUserTextMessage(item)) {
|
|
269
|
-
injectedCount += 1;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (!bridge.suppressToolOutput) {
|
|
273
|
-
const sanitized = sanitizeBridgeMarkers(payload);
|
|
274
|
-
return {
|
|
275
|
-
...params.response,
|
|
276
|
-
output: JSON.stringify(sanitized, null, 2),
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
...params.response,
|
|
281
|
-
output: JSON.stringify({
|
|
282
|
-
success: true,
|
|
283
|
-
message: bridge.toolOutputMessage,
|
|
284
|
-
injected_user_messages: injectedCount,
|
|
285
|
-
}),
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* 调用 shell plugin runtime action。
|
|
290
|
-
*/
|
|
291
|
-
export async function invokeShellAction(params) {
|
|
292
|
-
const runtime = requireShellToolRuntime();
|
|
293
|
-
const result = await runtime.invoke({
|
|
294
|
-
plugin: "shell",
|
|
295
|
-
action: params.action,
|
|
296
|
-
payload: params.payload,
|
|
297
|
-
});
|
|
298
|
-
if (!result.success) {
|
|
299
|
-
throw new Error(result.error || `shell.${params.action} failed`);
|
|
300
|
-
}
|
|
301
|
-
const data = toJsonObject(result.data);
|
|
302
|
-
if (!data) {
|
|
303
|
-
throw new Error(`shell.${params.action} returned invalid data`);
|
|
304
|
-
}
|
|
305
|
-
const response = data;
|
|
306
|
-
if (!response.shell || typeof response.shell.shellId !== "string") {
|
|
307
|
-
throw new Error(`shell.${params.action} returned invalid shell payload`);
|
|
308
|
-
}
|
|
309
|
-
return response;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* 统一格式化 tool 错误。
|
|
313
|
-
*/
|
|
314
|
-
export function formatToolError(prefix, error) {
|
|
315
|
-
return {
|
|
316
|
-
success: false,
|
|
317
|
-
error: `${prefix}: ${String(error)}`,
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
//# sourceMappingURL=ShellToolBridge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShellToolBridge.js","sourceRoot":"","sources":["../../../../src/executor/tools/shell/ShellToolBridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C,OAAO,EACL,mCAAmC,EACnC,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAYtC,IAAI,gBAAgB,GAA4B,IAAI,CAAC;AAErD;;GAEG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAElE,MAAM,UAAU,mBAAmB,CAAC,IAAsB;IACxD,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAED,SAAS,uBAAuB;IAC9B,IAAI,gBAAgB;QAAE,OAAO,gBAAgB,CAAC;IAC9C,MAAM,IAAI,KAAK,CACb,uGAAuG,CACxG,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7E,OAAO,KAAmB,CAAC;AAC7B,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACrC,MAAM,IAAI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M,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,MAAM,CAAC,MAAM,SAAS,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,SAAS,MAAM,CAAC,MAAM,wBAAwB,CAAC,CAAC;IAClE,CAAC;IACD,MAAM,QAAQ,GAAG,IAAsC,CAAC;IACxD,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,SAAS,MAAM,CAAC,MAAM,iCAAiC,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAc,EACd,KAAc;IAEd,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,GAAG,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shell tools。
|
|
3
|
-
*
|
|
4
|
-
* 设计目标(中文)
|
|
5
|
-
* - shell 子进程生命周期统一由 shell plugin runtime 承担。
|
|
6
|
-
* - tool 只负责 Session/tool 协议适配、参数校验与日志语义。
|
|
7
|
-
* - 复杂桥接和 schema 已拆到旁路模块,当前文件只保留公开 tool 定义。
|
|
8
|
-
*/
|
|
9
|
-
import type { ShellCloseInput, ShellExecInput, ShellStartInput, ShellWaitInput } from "../../../executor/tools/shell/types/Shell.js";
|
|
10
|
-
import type { JsonObject } from "../../../types/common/Json.js";
|
|
11
|
-
export { setShellToolRuntime } from "./ShellToolBridge.js";
|
|
12
|
-
/**
|
|
13
|
-
* `shell_start`:启动 shell 会话。
|
|
14
|
-
*/
|
|
15
|
-
export declare const shell_start: import("ai").Tool<ShellStartInput, JsonObject | {
|
|
16
|
-
success: false;
|
|
17
|
-
error: string;
|
|
18
|
-
}>;
|
|
19
|
-
/**
|
|
20
|
-
* `shell_exec`:一次性执行并等待完成。
|
|
21
|
-
*/
|
|
22
|
-
export declare const shell_exec: import("ai").Tool<ShellExecInput, JsonObject | {
|
|
23
|
-
success: false;
|
|
24
|
-
error: string;
|
|
25
|
-
}>;
|
|
26
|
-
/**
|
|
27
|
-
* `shell_status`:查询 shell 当前状态。
|
|
28
|
-
*/
|
|
29
|
-
export declare const shell_status: import("ai").Tool<{
|
|
30
|
-
shell_id?: string | undefined;
|
|
31
|
-
cmd?: string | undefined;
|
|
32
|
-
}, JsonObject | {
|
|
33
|
-
success: false;
|
|
34
|
-
error: string;
|
|
35
|
-
}>;
|
|
36
|
-
/**
|
|
37
|
-
* `shell_read`:读取 shell 输出增量。
|
|
38
|
-
*/
|
|
39
|
-
export declare const shell_read: import("ai").Tool<{
|
|
40
|
-
shell_id: string;
|
|
41
|
-
from_cursor?: number | undefined;
|
|
42
|
-
max_output_tokens?: number | undefined;
|
|
43
|
-
}, JsonObject | {
|
|
44
|
-
success: false;
|
|
45
|
-
error: string;
|
|
46
|
-
}>;
|
|
47
|
-
/**
|
|
48
|
-
* `shell_write`:向 shell stdin 写入内容。
|
|
49
|
-
*/
|
|
50
|
-
export declare const shell_write: import("ai").Tool<{
|
|
51
|
-
shell_id: string;
|
|
52
|
-
chars: string;
|
|
53
|
-
reason?: string | undefined;
|
|
54
|
-
}, JsonObject | {
|
|
55
|
-
success: false;
|
|
56
|
-
error: string;
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* `shell_wait`:等待 shell 状态或输出变化。
|
|
60
|
-
*/
|
|
61
|
-
export declare const shell_wait: import("ai").Tool<ShellWaitInput, JsonObject | {
|
|
62
|
-
success: false;
|
|
63
|
-
error: string;
|
|
64
|
-
}>;
|
|
65
|
-
/**
|
|
66
|
-
* `shell_close`:关闭 shell 会话。
|
|
67
|
-
*/
|
|
68
|
-
export declare const shell_close: import("ai").Tool<ShellCloseInput, JsonObject | {
|
|
69
|
-
success: false;
|
|
70
|
-
error: string;
|
|
71
|
-
}>;
|
|
72
|
-
/**
|
|
73
|
-
* Shell 工具导出集合。
|
|
74
|
-
*/
|
|
75
|
-
export declare const shellTools: {
|
|
76
|
-
shell_exec: import("ai").Tool<ShellExecInput, JsonObject | {
|
|
77
|
-
success: false;
|
|
78
|
-
error: string;
|
|
79
|
-
}>;
|
|
80
|
-
shell_start: import("ai").Tool<ShellStartInput, JsonObject | {
|
|
81
|
-
success: false;
|
|
82
|
-
error: string;
|
|
83
|
-
}>;
|
|
84
|
-
shell_status: import("ai").Tool<{
|
|
85
|
-
shell_id?: string | undefined;
|
|
86
|
-
cmd?: string | undefined;
|
|
87
|
-
}, JsonObject | {
|
|
88
|
-
success: false;
|
|
89
|
-
error: string;
|
|
90
|
-
}>;
|
|
91
|
-
shell_read: import("ai").Tool<{
|
|
92
|
-
shell_id: string;
|
|
93
|
-
from_cursor?: number | undefined;
|
|
94
|
-
max_output_tokens?: number | undefined;
|
|
95
|
-
}, JsonObject | {
|
|
96
|
-
success: false;
|
|
97
|
-
error: string;
|
|
98
|
-
}>;
|
|
99
|
-
shell_write: import("ai").Tool<{
|
|
100
|
-
shell_id: string;
|
|
101
|
-
chars: string;
|
|
102
|
-
reason?: string | undefined;
|
|
103
|
-
}, JsonObject | {
|
|
104
|
-
success: false;
|
|
105
|
-
error: string;
|
|
106
|
-
}>;
|
|
107
|
-
shell_wait: import("ai").Tool<ShellWaitInput, JsonObject | {
|
|
108
|
-
success: false;
|
|
109
|
-
error: string;
|
|
110
|
-
}>;
|
|
111
|
-
shell_close: import("ai").Tool<ShellCloseInput, JsonObject | {
|
|
112
|
-
success: false;
|
|
113
|
-
error: string;
|
|
114
|
-
}>;
|
|
115
|
-
};
|
|
116
|
-
//# sourceMappingURL=ShellToolDefinition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShellToolDefinition.d.ts","sourceRoot":"","sources":["../../../../src/executor/tools/shell/ShellToolDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAEd,eAAe,EAEf,cAAc,EAEf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAsBzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AA+B3D;;GAEG;AACH,eAAO,MAAM,WAAW;;;EA0FtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;;EAoFrB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;EAsCvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;EAsDrB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;EAyCtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;;EA6DrB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;EAqCtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQtB,CAAC"}
|