@downcity/shell 0.1.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/bin/Shell.d.ts +55 -0
- package/bin/Shell.d.ts.map +1 -0
- package/bin/Shell.js +171 -0
- package/bin/Shell.js.map +1 -0
- package/bin/approval/ShellApprovalRuntime.d.ts +62 -0
- package/bin/approval/ShellApprovalRuntime.d.ts.map +1 -0
- package/bin/approval/ShellApprovalRuntime.js +214 -0
- package/bin/approval/ShellApprovalRuntime.js.map +1 -0
- package/bin/index.d.ts +27 -0
- package/bin/index.d.ts.map +1 -0
- package/bin/index.js +26 -0
- package/bin/index.js.map +1 -0
- package/bin/sandbox/LinuxBubblewrapSandbox.d.ts +19 -0
- package/bin/sandbox/LinuxBubblewrapSandbox.d.ts.map +1 -0
- package/bin/sandbox/LinuxBubblewrapSandbox.js +186 -0
- package/bin/sandbox/LinuxBubblewrapSandbox.js.map +1 -0
- package/bin/sandbox/MacOsSeatbeltSandbox.d.ts +16 -0
- package/bin/sandbox/MacOsSeatbeltSandbox.d.ts.map +1 -0
- package/bin/sandbox/MacOsSeatbeltSandbox.js +154 -0
- package/bin/sandbox/MacOsSeatbeltSandbox.js.map +1 -0
- package/bin/sandbox/SandboxConfigResolver.d.ts +37 -0
- package/bin/sandbox/SandboxConfigResolver.d.ts.map +1 -0
- package/bin/sandbox/SandboxConfigResolver.js +130 -0
- package/bin/sandbox/SandboxConfigResolver.js.map +1 -0
- package/bin/sandbox/SandboxPreflight.d.ts +73 -0
- package/bin/sandbox/SandboxPreflight.d.ts.map +1 -0
- package/bin/sandbox/SandboxPreflight.js +122 -0
- package/bin/sandbox/SandboxPreflight.js.map +1 -0
- package/bin/sandbox/SandboxRunner.d.ts +61 -0
- package/bin/sandbox/SandboxRunner.d.ts.map +1 -0
- package/bin/sandbox/SandboxRunner.js +107 -0
- package/bin/sandbox/SandboxRunner.js.map +1 -0
- package/bin/sandbox/UnrestrictedSandbox.d.ts +16 -0
- package/bin/sandbox/UnrestrictedSandbox.d.ts.map +1 -0
- package/bin/sandbox/UnrestrictedSandbox.js +39 -0
- package/bin/sandbox/UnrestrictedSandbox.js.map +1 -0
- package/bin/sandbox/types/Sandbox.d.ts +130 -0
- package/bin/sandbox/types/Sandbox.d.ts.map +1 -0
- package/bin/sandbox/types/Sandbox.js +10 -0
- package/bin/sandbox/types/Sandbox.js.map +1 -0
- package/bin/sandbox/types/SandboxRuntime.d.ts +370 -0
- package/bin/sandbox/types/SandboxRuntime.d.ts.map +1 -0
- package/bin/sandbox/types/SandboxRuntime.js +10 -0
- package/bin/sandbox/types/SandboxRuntime.js.map +1 -0
- package/bin/session/Paths.d.ts +12 -0
- package/bin/session/Paths.d.ts.map +1 -0
- package/bin/session/Paths.js +21 -0
- package/bin/session/Paths.js.map +1 -0
- package/bin/session/ShellActionResponse.d.ts +52 -0
- package/bin/session/ShellActionResponse.d.ts.map +1 -0
- package/bin/session/ShellActionResponse.js +73 -0
- package/bin/session/ShellActionResponse.js.map +1 -0
- package/bin/session/ShellActionRuntime.d.ts +15 -0
- package/bin/session/ShellActionRuntime.d.ts.map +1 -0
- package/bin/session/ShellActionRuntime.js +15 -0
- package/bin/session/ShellActionRuntime.js.map +1 -0
- package/bin/session/ShellActionRuntimeSupport.d.ts +88 -0
- package/bin/session/ShellActionRuntimeSupport.d.ts.map +1 -0
- package/bin/session/ShellActionRuntimeSupport.js +305 -0
- package/bin/session/ShellActionRuntimeSupport.js.map +1 -0
- package/bin/session/ShellProcessEvents.d.ts +22 -0
- package/bin/session/ShellProcessEvents.d.ts.map +1 -0
- package/bin/session/ShellProcessEvents.js +41 -0
- package/bin/session/ShellProcessEvents.js.map +1 -0
- package/bin/session/ShellRunScope.d.ts +43 -0
- package/bin/session/ShellRunScope.d.ts.map +1 -0
- package/bin/session/ShellRunScope.js +29 -0
- package/bin/session/ShellRunScope.js.map +1 -0
- package/bin/session/ShellRuntimeEnvironment.d.ts +21 -0
- package/bin/session/ShellRuntimeEnvironment.d.ts.map +1 -0
- package/bin/session/ShellRuntimeEnvironment.js +69 -0
- package/bin/session/ShellRuntimeEnvironment.js.map +1 -0
- package/bin/session/ShellRuntimeTypes.d.ts +160 -0
- package/bin/session/ShellRuntimeTypes.d.ts.map +1 -0
- package/bin/session/ShellRuntimeTypes.js +10 -0
- package/bin/session/ShellRuntimeTypes.js.map +1 -0
- package/bin/session/actions/ShellActionShared.d.ts +76 -0
- package/bin/session/actions/ShellActionShared.d.ts.map +1 -0
- package/bin/session/actions/ShellActionShared.js +100 -0
- package/bin/session/actions/ShellActionShared.js.map +1 -0
- package/bin/session/actions/ShellApprovalActions.d.ts +34 -0
- package/bin/session/actions/ShellApprovalActions.d.ts.map +1 -0
- package/bin/session/actions/ShellApprovalActions.js +37 -0
- package/bin/session/actions/ShellApprovalActions.js.map +1 -0
- package/bin/session/actions/ShellExecActions.d.ts +15 -0
- package/bin/session/actions/ShellExecActions.d.ts.map +1 -0
- package/bin/session/actions/ShellExecActions.js +117 -0
- package/bin/session/actions/ShellExecActions.js.map +1 -0
- package/bin/session/actions/ShellLifecycleActions.d.ts +18 -0
- package/bin/session/actions/ShellLifecycleActions.d.ts.map +1 -0
- package/bin/session/actions/ShellLifecycleActions.js +53 -0
- package/bin/session/actions/ShellLifecycleActions.js.map +1 -0
- package/bin/session/actions/ShellQueryActions.d.ts +27 -0
- package/bin/session/actions/ShellQueryActions.d.ts.map +1 -0
- package/bin/session/actions/ShellQueryActions.js +151 -0
- package/bin/session/actions/ShellQueryActions.js.map +1 -0
- package/bin/session/actions/ShellStartActions.d.ts +15 -0
- package/bin/session/actions/ShellStartActions.d.ts.map +1 -0
- package/bin/session/actions/ShellStartActions.js +167 -0
- package/bin/session/actions/ShellStartActions.js.map +1 -0
- package/bin/session/actions/ShellWriteActions.d.ts +15 -0
- package/bin/session/actions/ShellWriteActions.d.ts.map +1 -0
- package/bin/session/actions/ShellWriteActions.js +85 -0
- package/bin/session/actions/ShellWriteActions.js.map +1 -0
- package/bin/tool/ShellToolFormatting.d.ts +12 -0
- package/bin/tool/ShellToolFormatting.d.ts.map +1 -0
- package/bin/tool/ShellToolFormatting.js +31 -0
- package/bin/tool/ShellToolFormatting.js.map +1 -0
- package/bin/tool/ShellToolSchemas.d.ts +61 -0
- package/bin/tool/ShellToolSchemas.d.ts.map +1 -0
- package/bin/tool/ShellToolSchemas.js +130 -0
- package/bin/tool/ShellToolSchemas.js.map +1 -0
- package/bin/tool/ShellTools.d.ts +32 -0
- package/bin/tool/ShellTools.d.ts.map +1 -0
- package/bin/tool/ShellTools.js +296 -0
- package/bin/tool/ShellTools.js.map +1 -0
- package/bin/types/Shell.d.ts +115 -0
- package/bin/types/Shell.d.ts.map +1 -0
- package/bin/types/Shell.js +9 -0
- package/bin/types/Shell.js.map +1 -0
- package/bin/types/ShellAction.d.ts +258 -0
- package/bin/types/ShellAction.d.ts.map +1 -0
- package/bin/types/ShellAction.js +9 -0
- package/bin/types/ShellAction.js.map +1 -0
- package/bin/types/ShellHostContext.d.ts +78 -0
- package/bin/types/ShellHostContext.d.ts.map +1 -0
- package/bin/types/ShellHostContext.js +9 -0
- package/bin/types/ShellHostContext.js.map +1 -0
- package/bin/types/ShellRuntime.d.ts +128 -0
- package/bin/types/ShellRuntime.d.ts.map +1 -0
- package/bin/types/ShellRuntime.js +9 -0
- package/bin/types/ShellRuntime.js.map +1 -0
- package/bin/types/ShellRuntimeOptions.d.ts +103 -0
- package/bin/types/ShellRuntimeOptions.d.ts.map +1 -0
- package/bin/types/ShellRuntimeOptions.js +10 -0
- package/bin/types/ShellRuntimeOptions.js.map +1 -0
- package/bin/utils/Id.d.ts +11 -0
- package/bin/utils/Id.d.ts.map +1 -0
- package/bin/utils/Id.js +14 -0
- package/bin/utils/Id.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell tool 输入 schema。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - 所有 schema 统一集中,避免 `Tool.ts` 里同时混杂协议定义与执行逻辑。
|
|
6
|
+
* - 这里保持纯声明,不放任何运行时桥接细节。
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
export declare const shellStartInputSchema: z.ZodObject<{
|
|
10
|
+
cmd: z.ZodString;
|
|
11
|
+
workdir: z.ZodOptional<z.ZodString>;
|
|
12
|
+
shell: z.ZodOptional<z.ZodString>;
|
|
13
|
+
login: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
14
|
+
inline_wait_ms: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
+
max_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
auto_notify_on_exit: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
sandbox: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
18
|
+
safe: "safe";
|
|
19
|
+
unrestricted: "unrestricted";
|
|
20
|
+
}>>>;
|
|
21
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const shellExecInputSchema: z.ZodObject<{
|
|
24
|
+
cmd: z.ZodString;
|
|
25
|
+
workdir: z.ZodOptional<z.ZodString>;
|
|
26
|
+
shell: z.ZodOptional<z.ZodString>;
|
|
27
|
+
login: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
28
|
+
timeout_ms: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
29
|
+
max_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
sandbox: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
safe: "safe";
|
|
32
|
+
unrestricted: "unrestricted";
|
|
33
|
+
}>>>;
|
|
34
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export declare const shellStatusInputSchema: z.ZodObject<{
|
|
37
|
+
shell_id: z.ZodOptional<z.ZodString>;
|
|
38
|
+
cmd: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const shellReadInputSchema: z.ZodObject<{
|
|
41
|
+
shell_id: z.ZodString;
|
|
42
|
+
from_cursor: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
max_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export declare const shellWriteInputSchema: z.ZodObject<{
|
|
46
|
+
shell_id: z.ZodString;
|
|
47
|
+
chars: z.ZodString;
|
|
48
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export declare const shellWaitInputSchema: z.ZodObject<{
|
|
51
|
+
shell_id: z.ZodString;
|
|
52
|
+
after_version: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
from_cursor: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
timeout_ms: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
55
|
+
max_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export declare const shellCloseInputSchema: z.ZodObject<{
|
|
58
|
+
shell_id: z.ZodString;
|
|
59
|
+
force: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
//# sourceMappingURL=ShellToolSchemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellToolSchemas.d.ts","sourceRoot":"","sources":["../../src/tool/ShellToolSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;iBA8BhC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;iBA0B/B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;iBAMjC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;iBAU/B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;iBAOhC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;iBAmB/B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;iBAOhC,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell tool 输入 schema。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - 所有 schema 统一集中,避免 `Tool.ts` 里同时混杂协议定义与执行逻辑。
|
|
6
|
+
* - 这里保持纯声明,不放任何运行时桥接细节。
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
const shellSandboxModeSchema = z
|
|
10
|
+
.enum(["safe", "unrestricted"])
|
|
11
|
+
.optional()
|
|
12
|
+
.default("safe")
|
|
13
|
+
.describe("Sandbox mode. safe is the default; unrestricted requires user approval.");
|
|
14
|
+
const shellUnrestrictedReasonSchema = z
|
|
15
|
+
.string()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Required when sandbox is unrestricted. Explain why host-level execution is needed.");
|
|
18
|
+
export const shellStartInputSchema = z.object({
|
|
19
|
+
cmd: z.string().describe("Shell command to execute."),
|
|
20
|
+
workdir: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Optional working directory. Relative path is resolved from project root."),
|
|
24
|
+
shell: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Optional shell executable path. Example: /bin/zsh"),
|
|
28
|
+
login: z
|
|
29
|
+
.boolean()
|
|
30
|
+
.optional()
|
|
31
|
+
.default(true)
|
|
32
|
+
.describe("Whether to run shell as login shell (-lc). false uses -c."),
|
|
33
|
+
inline_wait_ms: z
|
|
34
|
+
.number()
|
|
35
|
+
.optional()
|
|
36
|
+
.default(1200)
|
|
37
|
+
.describe("How long to inline-wait for initial output before returning."),
|
|
38
|
+
max_output_tokens: z
|
|
39
|
+
.number()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Maximum output tokens returned in a single read chunk."),
|
|
42
|
+
auto_notify_on_exit: z
|
|
43
|
+
.boolean()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Whether the shell runtime should emit a completion notification when the command exits."),
|
|
46
|
+
sandbox: shellSandboxModeSchema,
|
|
47
|
+
reason: shellUnrestrictedReasonSchema,
|
|
48
|
+
});
|
|
49
|
+
export const shellExecInputSchema = z.object({
|
|
50
|
+
cmd: z.string().describe("Shell command to execute once and wait until completion."),
|
|
51
|
+
workdir: z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("Optional working directory. Relative path is resolved from project root."),
|
|
55
|
+
shell: z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Optional shell executable path. Example: /bin/zsh"),
|
|
59
|
+
login: z
|
|
60
|
+
.boolean()
|
|
61
|
+
.optional()
|
|
62
|
+
.default(true)
|
|
63
|
+
.describe("Whether to run shell as login shell (-lc). false uses -c."),
|
|
64
|
+
timeout_ms: z
|
|
65
|
+
.number()
|
|
66
|
+
.optional()
|
|
67
|
+
.default(60000)
|
|
68
|
+
.describe("Total timeout for one-shot execution. Use shell_start for long-running commands."),
|
|
69
|
+
max_output_tokens: z
|
|
70
|
+
.number()
|
|
71
|
+
.optional()
|
|
72
|
+
.describe("Maximum output tokens returned in the final result."),
|
|
73
|
+
sandbox: shellSandboxModeSchema,
|
|
74
|
+
reason: shellUnrestrictedReasonSchema,
|
|
75
|
+
});
|
|
76
|
+
export const shellStatusInputSchema = z.object({
|
|
77
|
+
shell_id: z.string().optional().describe("Existing shell identifier."),
|
|
78
|
+
cmd: z
|
|
79
|
+
.string()
|
|
80
|
+
.optional()
|
|
81
|
+
.describe("Optional command substring to resolve the latest shell in the current chat."),
|
|
82
|
+
});
|
|
83
|
+
export const shellReadInputSchema = z.object({
|
|
84
|
+
shell_id: z.string().describe("Existing shell identifier."),
|
|
85
|
+
from_cursor: z
|
|
86
|
+
.number()
|
|
87
|
+
.optional()
|
|
88
|
+
.describe("Character cursor to continue reading from."),
|
|
89
|
+
max_output_tokens: z
|
|
90
|
+
.number()
|
|
91
|
+
.optional()
|
|
92
|
+
.describe("Maximum output tokens returned in this chunk."),
|
|
93
|
+
});
|
|
94
|
+
export const shellWriteInputSchema = z.object({
|
|
95
|
+
shell_id: z.string().describe("Existing shell identifier."),
|
|
96
|
+
chars: z.string().describe("Bytes to write to stdin."),
|
|
97
|
+
reason: z
|
|
98
|
+
.string()
|
|
99
|
+
.optional()
|
|
100
|
+
.describe("Required when writing to an unrestricted shell session. Explain why this stdin input is needed."),
|
|
101
|
+
});
|
|
102
|
+
export const shellWaitInputSchema = z.object({
|
|
103
|
+
shell_id: z.string().describe("Existing shell identifier."),
|
|
104
|
+
after_version: z
|
|
105
|
+
.number()
|
|
106
|
+
.optional()
|
|
107
|
+
.describe("Only return once the shell version is greater than this value."),
|
|
108
|
+
from_cursor: z
|
|
109
|
+
.number()
|
|
110
|
+
.optional()
|
|
111
|
+
.describe("Character cursor to continue reading from after the wait."),
|
|
112
|
+
timeout_ms: z
|
|
113
|
+
.number()
|
|
114
|
+
.optional()
|
|
115
|
+
.default(10000)
|
|
116
|
+
.describe("Maximum time to wait for state/output changes."),
|
|
117
|
+
max_output_tokens: z
|
|
118
|
+
.number()
|
|
119
|
+
.optional()
|
|
120
|
+
.describe("Maximum output tokens returned in this chunk."),
|
|
121
|
+
});
|
|
122
|
+
export const shellCloseInputSchema = z.object({
|
|
123
|
+
shell_id: z.string().describe("Existing shell identifier."),
|
|
124
|
+
force: z
|
|
125
|
+
.boolean()
|
|
126
|
+
.optional()
|
|
127
|
+
.default(false)
|
|
128
|
+
.describe("Whether to force-kill the shell with SIGKILL."),
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=ShellToolSchemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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,CAAC,KAAK,CAAC;SACd,QAAQ,CAAC,+CAA+C,CAAC;CAC7D,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell tool 定义。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - `@downcity/shell` 自己拥有 shell tool 的 schema、执行逻辑与响应整理。
|
|
6
|
+
* - Agent 只把 Shell 实例的 tools 合并到模型可调用工具集合中。
|
|
7
|
+
*/
|
|
8
|
+
import type { ShellActionResponse } from "../types/ShellAction.js";
|
|
9
|
+
import type { ShellToolSet } from "../types/ShellRuntime.js";
|
|
10
|
+
type JsonObject = Record<string, unknown>;
|
|
11
|
+
export type ShellToolAction = "start" | "exec" | "status" | "read" | "write" | "wait" | "close";
|
|
12
|
+
export interface ShellToolRunner {
|
|
13
|
+
/**
|
|
14
|
+
* 执行 shell action。
|
|
15
|
+
*/
|
|
16
|
+
run_action(params: {
|
|
17
|
+
/**
|
|
18
|
+
* action 名称。
|
|
19
|
+
*/
|
|
20
|
+
action: ShellToolAction;
|
|
21
|
+
/**
|
|
22
|
+
* action payload。
|
|
23
|
+
*/
|
|
24
|
+
payload: JsonObject;
|
|
25
|
+
}): Promise<ShellActionResponse>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 创建 shell tools。
|
|
29
|
+
*/
|
|
30
|
+
export declare function createShellTools(runner: ShellToolRunner): ShellToolSet;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=ShellTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellTools.d.ts","sourceRoot":"","sources":["../../src/tool/ShellTools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAWlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,CAAC;AAEZ,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE;QACjB;;WAEG;QACH,MAAM,EAAE,eAAe,CAAC;QACxB;;WAEG;QACH,OAAO,EAAE,UAAU,CAAC;KACrB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAClC;AAmHD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,CAwOtE"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell tool 定义。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - `@downcity/shell` 自己拥有 shell tool 的 schema、执行逻辑与响应整理。
|
|
6
|
+
* - Agent 只把 Shell 实例的 tools 合并到模型可调用工具集合中。
|
|
7
|
+
*/
|
|
8
|
+
import { tool } from "ai";
|
|
9
|
+
import { shellCloseInputSchema, shellExecInputSchema, shellReadInputSchema, shellStartInputSchema, shellStatusInputSchema, shellWaitInputSchema, shellWriteInputSchema, } from "../tool/ShellToolSchemas.js";
|
|
10
|
+
import { validateChatSendCommand } from "../tool/ShellToolFormatting.js";
|
|
11
|
+
function flattenShellActionResponse(params) {
|
|
12
|
+
const shell_snapshot = params.response.shell;
|
|
13
|
+
const chunk = params.response.chunk;
|
|
14
|
+
const exit_code = typeof shell_snapshot.exitCode === "number" ? shell_snapshot.exitCode : null;
|
|
15
|
+
const success = shell_snapshot.approvalStatus !== "denied" &&
|
|
16
|
+
shell_snapshot.approvalStatus !== "expired" &&
|
|
17
|
+
(exit_code === null || exit_code === 0);
|
|
18
|
+
return {
|
|
19
|
+
success,
|
|
20
|
+
shell_id: shell_snapshot.shellId,
|
|
21
|
+
status: shell_snapshot.status,
|
|
22
|
+
cmd: shell_snapshot.cmd,
|
|
23
|
+
cwd: shell_snapshot.cwd,
|
|
24
|
+
sandboxed: shell_snapshot.sandboxed === true,
|
|
25
|
+
sandbox: shell_snapshot.sandboxMode || (shell_snapshot.sandboxed === false ? "unrestricted" : "safe"),
|
|
26
|
+
approval_status: shell_snapshot.approvalStatus || null,
|
|
27
|
+
approval_id: shell_snapshot.approvalId || null,
|
|
28
|
+
approval_reason: shell_snapshot.approvalReason || null,
|
|
29
|
+
stdin_writable: shell_snapshot.stdinWritable !== false,
|
|
30
|
+
sandbox_backend: shell_snapshot.sandboxBackend || null,
|
|
31
|
+
sandbox_network_mode: shell_snapshot.sandboxNetworkMode || null,
|
|
32
|
+
sandbox_dir: shell_snapshot.sandboxDir || null,
|
|
33
|
+
sandbox_home_dir: shell_snapshot.sandboxHomeDir || null,
|
|
34
|
+
sandbox_tmp_dir: shell_snapshot.sandboxTmpDir || null,
|
|
35
|
+
sandbox_cache_dir: shell_snapshot.sandboxCacheDir || null,
|
|
36
|
+
pid: typeof shell_snapshot.pid === "number" ? shell_snapshot.pid : null,
|
|
37
|
+
version: shell_snapshot.version,
|
|
38
|
+
started_at: shell_snapshot.startedAt,
|
|
39
|
+
updated_at: shell_snapshot.updatedAt,
|
|
40
|
+
ended_at: typeof shell_snapshot.endedAt === "number" ? shell_snapshot.endedAt : null,
|
|
41
|
+
exit_code,
|
|
42
|
+
output: chunk?.output || "",
|
|
43
|
+
start_cursor: typeof chunk?.startCursor === "number" ? chunk.startCursor : null,
|
|
44
|
+
end_cursor: typeof chunk?.endCursor === "number" ? chunk.endCursor : null,
|
|
45
|
+
original_chars: chunk?.originalChars ?? 0,
|
|
46
|
+
original_lines: chunk?.originalLines ?? 0,
|
|
47
|
+
has_more_output: chunk?.hasMoreOutput === true,
|
|
48
|
+
last_output_preview: shell_snapshot.lastOutputPreview || "",
|
|
49
|
+
output_chars: shell_snapshot.outputChars,
|
|
50
|
+
dropped_chars: shell_snapshot.droppedChars,
|
|
51
|
+
auto_notify_on_exit: shell_snapshot.autoNotifyOnExit,
|
|
52
|
+
notification_sent: shell_snapshot.notificationSent,
|
|
53
|
+
owner_context_id: shell_snapshot.ownerContextId || null,
|
|
54
|
+
external_refs: shell_snapshot.externalRefs,
|
|
55
|
+
wall_time_seconds: Math.max(0, (Date.now() - params.started_at) / 1000),
|
|
56
|
+
...(params.response.note ? { note: params.response.note } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function flattenShellExecResponse(params) {
|
|
60
|
+
const shell_snapshot = params.response.shell;
|
|
61
|
+
const chunk = params.response.chunk;
|
|
62
|
+
const exit_code = typeof shell_snapshot.exitCode === "number" ? shell_snapshot.exitCode : null;
|
|
63
|
+
const success = shell_snapshot.approvalStatus !== "denied" &&
|
|
64
|
+
shell_snapshot.approvalStatus !== "expired" &&
|
|
65
|
+
(exit_code === null || exit_code === 0);
|
|
66
|
+
return {
|
|
67
|
+
success,
|
|
68
|
+
status: shell_snapshot.status,
|
|
69
|
+
cmd: shell_snapshot.cmd,
|
|
70
|
+
cwd: shell_snapshot.cwd,
|
|
71
|
+
sandboxed: shell_snapshot.sandboxed === true,
|
|
72
|
+
sandbox: shell_snapshot.sandboxMode || (shell_snapshot.sandboxed === false ? "unrestricted" : "safe"),
|
|
73
|
+
approval_status: shell_snapshot.approvalStatus || null,
|
|
74
|
+
approval_id: shell_snapshot.approvalId || null,
|
|
75
|
+
approval_reason: shell_snapshot.approvalReason || null,
|
|
76
|
+
stdin_writable: shell_snapshot.stdinWritable !== false,
|
|
77
|
+
sandbox_backend: shell_snapshot.sandboxBackend || null,
|
|
78
|
+
sandbox_network_mode: shell_snapshot.sandboxNetworkMode || null,
|
|
79
|
+
sandbox_dir: shell_snapshot.sandboxDir || null,
|
|
80
|
+
sandbox_home_dir: shell_snapshot.sandboxHomeDir || null,
|
|
81
|
+
sandbox_tmp_dir: shell_snapshot.sandboxTmpDir || null,
|
|
82
|
+
sandbox_cache_dir: shell_snapshot.sandboxCacheDir || null,
|
|
83
|
+
exit_code,
|
|
84
|
+
output: chunk?.output || "",
|
|
85
|
+
original_chars: chunk?.originalChars ?? 0,
|
|
86
|
+
original_lines: chunk?.originalLines ?? 0,
|
|
87
|
+
external_refs: shell_snapshot.externalRefs,
|
|
88
|
+
wall_time_seconds: Math.max(0, (Date.now() - params.started_at) / 1000),
|
|
89
|
+
...(params.response.note ? { note: params.response.note } : {}),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function formatToolError(prefix, error) {
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
error: `${prefix}: ${String(error)}`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 创建 shell tools。
|
|
100
|
+
*/
|
|
101
|
+
export function createShellTools(runner) {
|
|
102
|
+
const shell_start = tool({
|
|
103
|
+
description: "Start a shell session. Returns shell_id plus initial status/output. Long-running commands should usually be checked later with shell_status or shell_wait instead of repeated polling.",
|
|
104
|
+
inputSchema: shellStartInputSchema,
|
|
105
|
+
execute: async ({ cmd, workdir, shell, login = true, inline_wait_ms = 1200, max_output_tokens, auto_notify_on_exit, sandbox = "safe", reason, }) => {
|
|
106
|
+
const started_at = Date.now();
|
|
107
|
+
try {
|
|
108
|
+
const validation_error = validateChatSendCommand(cmd);
|
|
109
|
+
if (validation_error) {
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
error: `shell_start rejected: ${validation_error}`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const response = await runner.run_action({
|
|
116
|
+
action: "start",
|
|
117
|
+
payload: {
|
|
118
|
+
cmd,
|
|
119
|
+
...(workdir ? { cwd: workdir } : {}),
|
|
120
|
+
...(shell ? { shell } : {}),
|
|
121
|
+
login,
|
|
122
|
+
inlineWaitMs: inline_wait_ms,
|
|
123
|
+
...(typeof max_output_tokens === "number"
|
|
124
|
+
? { maxOutputTokens: max_output_tokens }
|
|
125
|
+
: {}),
|
|
126
|
+
...(typeof auto_notify_on_exit === "boolean"
|
|
127
|
+
? { autoNotifyOnExit: auto_notify_on_exit }
|
|
128
|
+
: {}),
|
|
129
|
+
sandbox,
|
|
130
|
+
...(reason ? { reason } : {}),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
return flattenShellActionResponse({ response, started_at });
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return formatToolError("shell_start failed", error);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
const shell_exec = tool({
|
|
141
|
+
description: "Execute a short shell command in one-shot mode and wait for completion. Prefer shell_start for long-running or interactive commands.",
|
|
142
|
+
inputSchema: shellExecInputSchema,
|
|
143
|
+
execute: async ({ cmd, workdir, shell, login = true, timeout_ms = 60000, max_output_tokens, sandbox = "safe", reason, }) => {
|
|
144
|
+
const started_at = Date.now();
|
|
145
|
+
try {
|
|
146
|
+
const validation_error = validateChatSendCommand(cmd);
|
|
147
|
+
if (validation_error) {
|
|
148
|
+
return {
|
|
149
|
+
success: false,
|
|
150
|
+
error: `shell_exec rejected: ${validation_error}`,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const response = await runner.run_action({
|
|
154
|
+
action: "exec",
|
|
155
|
+
payload: {
|
|
156
|
+
cmd,
|
|
157
|
+
...(workdir ? { cwd: workdir } : {}),
|
|
158
|
+
...(shell ? { shell } : {}),
|
|
159
|
+
login,
|
|
160
|
+
timeoutMs: timeout_ms,
|
|
161
|
+
...(typeof max_output_tokens === "number"
|
|
162
|
+
? { maxOutputTokens: max_output_tokens }
|
|
163
|
+
: {}),
|
|
164
|
+
sandbox,
|
|
165
|
+
...(reason ? { reason } : {}),
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
return flattenShellExecResponse({ response, started_at });
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
return formatToolError("shell_exec failed", error);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
const shell_status = tool({
|
|
176
|
+
description: "Query the current status of a shell session. Prefer this to ask for progress during long-running commands.",
|
|
177
|
+
inputSchema: shellStatusInputSchema,
|
|
178
|
+
execute: async ({ shell_id, cmd }) => {
|
|
179
|
+
const started_at = Date.now();
|
|
180
|
+
try {
|
|
181
|
+
const response = await runner.run_action({
|
|
182
|
+
action: "status",
|
|
183
|
+
payload: {
|
|
184
|
+
...(shell_id ? { shellId: shell_id } : {}),
|
|
185
|
+
...(cmd ? { cmd } : {}),
|
|
186
|
+
includeCompleted: true,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
return flattenShellActionResponse({ response, started_at });
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
return formatToolError("shell_status failed", error);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
const shell_read = tool({
|
|
197
|
+
description: "Read output from a shell session starting at a character cursor. Use this only when you truly need the raw incremental output.",
|
|
198
|
+
inputSchema: shellReadInputSchema,
|
|
199
|
+
execute: async ({ shell_id, from_cursor, max_output_tokens, }) => {
|
|
200
|
+
const started_at = Date.now();
|
|
201
|
+
try {
|
|
202
|
+
const response = await runner.run_action({
|
|
203
|
+
action: "read",
|
|
204
|
+
payload: {
|
|
205
|
+
shellId: shell_id,
|
|
206
|
+
...(typeof from_cursor === "number" ? { fromCursor: from_cursor } : {}),
|
|
207
|
+
...(typeof max_output_tokens === "number"
|
|
208
|
+
? { maxOutputTokens: max_output_tokens }
|
|
209
|
+
: {}),
|
|
210
|
+
includeCompleted: true,
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
return flattenShellActionResponse({ response, started_at });
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
return formatToolError("shell_read failed", error);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
const shell_write = tool({
|
|
221
|
+
description: "Write text to the stdin of an existing shell session. When the target session runs in unrestricted sandbox mode, provide reason; every write requires user approval.",
|
|
222
|
+
inputSchema: shellWriteInputSchema,
|
|
223
|
+
execute: async ({ shell_id, chars, reason }) => {
|
|
224
|
+
const started_at = Date.now();
|
|
225
|
+
try {
|
|
226
|
+
const response = await runner.run_action({
|
|
227
|
+
action: "write",
|
|
228
|
+
payload: {
|
|
229
|
+
shellId: shell_id,
|
|
230
|
+
chars,
|
|
231
|
+
...(reason ? { reason } : {}),
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
return flattenShellActionResponse({ response, started_at });
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
return formatToolError("shell_write failed", error);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
const shell_wait = tool({
|
|
242
|
+
description: "Wait for a shell session to change state or produce more output. Prefer this over manual high-frequency polling loops.",
|
|
243
|
+
inputSchema: shellWaitInputSchema,
|
|
244
|
+
execute: async ({ shell_id, after_version, from_cursor, timeout_ms = 10000, max_output_tokens, }) => {
|
|
245
|
+
const started_at = Date.now();
|
|
246
|
+
try {
|
|
247
|
+
const response = await runner.run_action({
|
|
248
|
+
action: "wait",
|
|
249
|
+
payload: {
|
|
250
|
+
shellId: shell_id,
|
|
251
|
+
...(typeof after_version === "number" ? { afterVersion: after_version } : {}),
|
|
252
|
+
...(typeof from_cursor === "number" ? { fromCursor: from_cursor } : {}),
|
|
253
|
+
timeoutMs: timeout_ms,
|
|
254
|
+
...(typeof max_output_tokens === "number"
|
|
255
|
+
? { maxOutputTokens: max_output_tokens }
|
|
256
|
+
: {}),
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
return flattenShellActionResponse({ response, started_at });
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
return formatToolError("shell_wait failed", error);
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
const shell_close = tool({
|
|
267
|
+
description: "Close a shell session and release runtime resources. Use force only when a process will not exit normally.",
|
|
268
|
+
inputSchema: shellCloseInputSchema,
|
|
269
|
+
execute: async ({ shell_id, force = false }) => {
|
|
270
|
+
const started_at = Date.now();
|
|
271
|
+
try {
|
|
272
|
+
const response = await runner.run_action({
|
|
273
|
+
action: "close",
|
|
274
|
+
payload: {
|
|
275
|
+
shellId: shell_id,
|
|
276
|
+
force,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
return flattenShellActionResponse({ response, started_at });
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
return formatToolError("shell_close failed", error);
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
return {
|
|
287
|
+
shell_exec,
|
|
288
|
+
shell_start,
|
|
289
|
+
shell_status,
|
|
290
|
+
shell_read,
|
|
291
|
+
shell_write,
|
|
292
|
+
shell_wait,
|
|
293
|
+
shell_close,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=ShellTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellTools.js","sourceRoot":"","sources":["../../src/tool/ShellTools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAW1B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AA8BxE,SAAS,0BAA0B,CAAC,MASnC;IACC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;IACpC,MAAM,SAAS,GAAG,OAAO,cAAc,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC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,CAAC,CAAC;gBACH,OAAO,0BAA0B,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;YAC9D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,eAAe,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,UAAU;QACV,WAAW;QACX,YAAY;QACZ,UAAU;QACV,WAAW;QACX,UAAU;QACV,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell 工具类型定义。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - 统一沉淀 `shell_start/shell_status/shell_read/shell_write/shell_wait/shell_close` 类型。
|
|
6
|
+
* - `shell_id` 与 chat `sessionId` 严格分离,避免语义混淆。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* shell 执行 sandbox 模式。
|
|
10
|
+
*/
|
|
11
|
+
export type ShellSandboxMode = "safe" | "unrestricted";
|
|
12
|
+
/**
|
|
13
|
+
* shell unrestricted sandbox 申请原因。
|
|
14
|
+
*/
|
|
15
|
+
export type ShellUnrestrictedReason = string;
|
|
16
|
+
/**
|
|
17
|
+
* 启动一个交互式 shell session 的输入。
|
|
18
|
+
*/
|
|
19
|
+
export type ShellStartInput = {
|
|
20
|
+
/** 要启动的命令文本。 */
|
|
21
|
+
cmd: string;
|
|
22
|
+
/** shell 进程的工作目录。 */
|
|
23
|
+
workdir?: string;
|
|
24
|
+
/** 显式指定 shell 可执行文件。 */
|
|
25
|
+
shell?: string;
|
|
26
|
+
/** 是否使用 login shell 语义启动。 */
|
|
27
|
+
login?: boolean;
|
|
28
|
+
/** 启动后内联等待输出的毫秒数。 */
|
|
29
|
+
inline_wait_ms?: number;
|
|
30
|
+
/** 最多返回多少输出 token。 */
|
|
31
|
+
max_output_tokens?: number;
|
|
32
|
+
/** 进程退出时是否自动通知调用方。 */
|
|
33
|
+
auto_notify_on_exit?: boolean;
|
|
34
|
+
/** 命令执行 sandbox 模式;默认 safe。 */
|
|
35
|
+
sandbox?: ShellSandboxMode;
|
|
36
|
+
/** 请求 unrestricted sandbox 时展示给用户的原因。 */
|
|
37
|
+
reason?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 执行一次非持久 shell 命令的输入。
|
|
41
|
+
*/
|
|
42
|
+
export type ShellExecInput = {
|
|
43
|
+
/** 要执行的命令文本。 */
|
|
44
|
+
cmd: string;
|
|
45
|
+
/** 命令执行工作目录。 */
|
|
46
|
+
workdir?: string;
|
|
47
|
+
/** 显式指定 shell 可执行文件。 */
|
|
48
|
+
shell?: string;
|
|
49
|
+
/** 是否使用 login shell 语义启动。 */
|
|
50
|
+
login?: boolean;
|
|
51
|
+
/** 本次命令执行超时时间。 */
|
|
52
|
+
timeout_ms?: number;
|
|
53
|
+
/** 最多返回多少输出 token。 */
|
|
54
|
+
max_output_tokens?: number;
|
|
55
|
+
/** 命令执行 sandbox 模式;默认 safe。 */
|
|
56
|
+
sandbox?: ShellSandboxMode;
|
|
57
|
+
/** 请求 unrestricted sandbox 时展示给用户的原因。 */
|
|
58
|
+
reason?: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* 查询 shell 运行状态的输入。
|
|
62
|
+
*/
|
|
63
|
+
export type ShellStatusInput = {
|
|
64
|
+
/** 要查询的 shell session ID。 */
|
|
65
|
+
shell_id?: string;
|
|
66
|
+
/** 可选的原始命令文本,用于宽松筛选。 */
|
|
67
|
+
cmd?: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* 读取 shell 输出流的输入。
|
|
71
|
+
*/
|
|
72
|
+
export type ShellReadInput = {
|
|
73
|
+
/** 要读取的 shell session ID。 */
|
|
74
|
+
shell_id: string;
|
|
75
|
+
/** 从哪个游标开始增量读取。 */
|
|
76
|
+
from_cursor?: number;
|
|
77
|
+
/** 最多返回多少输出 token。 */
|
|
78
|
+
max_output_tokens?: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* 向 shell session 写入输入字符。
|
|
82
|
+
*/
|
|
83
|
+
export type ShellWriteInput = {
|
|
84
|
+
/** 要写入的 shell session ID。 */
|
|
85
|
+
shell_id: string;
|
|
86
|
+
/** 要发送到 stdin 的字符内容。 */
|
|
87
|
+
chars: string;
|
|
88
|
+
/** 向 unrestricted shell session 写入 stdin 时展示给用户的原因。 */
|
|
89
|
+
reason?: ShellUnrestrictedReason;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* 等待 shell 新输出的输入。
|
|
93
|
+
*/
|
|
94
|
+
export type ShellWaitInput = {
|
|
95
|
+
/** 要等待的 shell session ID。 */
|
|
96
|
+
shell_id: string;
|
|
97
|
+
/** 从哪个版本号之后开始等待变更。 */
|
|
98
|
+
after_version?: number;
|
|
99
|
+
/** 从哪个输出游标开始读取。 */
|
|
100
|
+
from_cursor?: number;
|
|
101
|
+
/** 最长等待时间。 */
|
|
102
|
+
timeout_ms?: number;
|
|
103
|
+
/** 最多返回多少输出 token。 */
|
|
104
|
+
max_output_tokens?: number;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* 关闭 shell session 的输入。
|
|
108
|
+
*/
|
|
109
|
+
export type ShellCloseInput = {
|
|
110
|
+
/** 要关闭的 shell session ID。 */
|
|
111
|
+
shell_id: string;
|
|
112
|
+
/** 是否强制结束子进程。 */
|
|
113
|
+
force?: boolean;
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=Shell.d.ts.map
|