@downcity/plugins 1.0.64 → 1.0.71
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/BuiltinPlugins.d.ts +0 -5
- package/bin/BuiltinPlugins.d.ts.map +1 -1
- package/bin/BuiltinPlugins.js +1 -5
- package/bin/BuiltinPlugins.js.map +1 -1
- package/bin/index.d.ts +0 -2
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +0 -1
- package/bin/index.js.map +1 -1
- package/bin/task/runtime/TaskRunnerRound.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerRound.js +7 -2
- package/bin/task/runtime/TaskRunnerRound.js.map +1 -1
- package/bin/task/runtime/TaskRunnerSession.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerSession.js +10 -3
- package/bin/task/runtime/TaskRunnerSession.js.map +1 -1
- package/package.json +4 -3
- package/scripts/unrestricted-sandbox-approval.test.mjs +184 -5
- package/src/BuiltinPlugins.ts +0 -9
- package/src/index.ts +0 -5
- package/src/task/runtime/TaskRunnerRound.ts +15 -5
- package/src/task/runtime/TaskRunnerSession.ts +11 -4
- package/bin/shell/Index.d.ts +0 -9
- package/bin/shell/Index.d.ts.map +0 -1
- package/bin/shell/Index.js +0 -9
- package/bin/shell/Index.js.map +0 -1
- package/bin/shell/ShellPlugin.d.ts +0 -65
- package/bin/shell/ShellPlugin.d.ts.map +0 -1
- package/bin/shell/ShellPlugin.js +0 -175
- package/bin/shell/ShellPlugin.js.map +0 -1
- package/bin/shell/ShellRuntimeTypes.d.ts +0 -145
- package/bin/shell/ShellRuntimeTypes.d.ts.map +0 -1
- package/bin/shell/ShellRuntimeTypes.js +0 -10
- package/bin/shell/ShellRuntimeTypes.js.map +0 -1
- package/bin/shell/runtime/Paths.d.ts +0 -12
- package/bin/shell/runtime/Paths.d.ts.map +0 -1
- package/bin/shell/runtime/Paths.js +0 -21
- package/bin/shell/runtime/Paths.js.map +0 -1
- package/bin/shell/runtime/ShellActionResponse.d.ts +0 -52
- package/bin/shell/runtime/ShellActionResponse.d.ts.map +0 -1
- package/bin/shell/runtime/ShellActionResponse.js +0 -73
- package/bin/shell/runtime/ShellActionResponse.js.map +0 -1
- package/bin/shell/runtime/ShellActionRuntime.d.ts +0 -70
- package/bin/shell/runtime/ShellActionRuntime.d.ts.map +0 -1
- package/bin/shell/runtime/ShellActionRuntime.js +0 -587
- package/bin/shell/runtime/ShellActionRuntime.js.map +0 -1
- package/bin/shell/runtime/ShellActionRuntimeSupport.d.ts +0 -88
- package/bin/shell/runtime/ShellActionRuntimeSupport.d.ts.map +0 -1
- package/bin/shell/runtime/ShellActionRuntimeSupport.js +0 -353
- package/bin/shell/runtime/ShellActionRuntimeSupport.js.map +0 -1
- package/bin/shell/runtime/ShellApprovalRuntime.d.ts +0 -57
- package/bin/shell/runtime/ShellApprovalRuntime.d.ts.map +0 -1
- package/bin/shell/runtime/ShellApprovalRuntime.js +0 -182
- package/bin/shell/runtime/ShellApprovalRuntime.js.map +0 -1
- package/bin/shell/runtime/ShellProcessEvents.d.ts +0 -22
- package/bin/shell/runtime/ShellProcessEvents.d.ts.map +0 -1
- package/bin/shell/runtime/ShellProcessEvents.js +0 -41
- package/bin/shell/runtime/ShellProcessEvents.js.map +0 -1
- package/bin/shell/runtime/ShellRuntimeEnvironment.d.ts +0 -21
- package/bin/shell/runtime/ShellRuntimeEnvironment.d.ts.map +0 -1
- package/bin/shell/runtime/ShellRuntimeEnvironment.js +0 -70
- package/bin/shell/runtime/ShellRuntimeEnvironment.js.map +0 -1
- package/bin/shell/types/ShellPluginOptions.d.ts +0 -103
- package/bin/shell/types/ShellPluginOptions.d.ts.map +0 -1
- package/bin/shell/types/ShellPluginOptions.js +0 -10
- package/bin/shell/types/ShellPluginOptions.js.map +0 -1
- package/src/shell/Index.ts +0 -9
- package/src/shell/ShellPlugin.ts +0 -239
- package/src/shell/ShellRuntimeTypes.ts +0 -152
- package/src/shell/runtime/Paths.ts +0 -28
- package/src/shell/runtime/ShellActionResponse.ts +0 -135
- package/src/shell/runtime/ShellActionRuntime.ts +0 -728
- package/src/shell/runtime/ShellActionRuntimeSupport.ts +0 -477
- package/src/shell/runtime/ShellApprovalRuntime.ts +0 -236
- package/src/shell/runtime/ShellProcessEvents.ts +0 -65
- package/src/shell/runtime/ShellRuntimeEnvironment.ts +0 -71
- package/src/shell/types/ShellPluginOptions.ts +0 -122
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shell action 返回结构辅助。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 集中处理输出游标、token 近似裁剪与标准 action response。
|
|
6
|
-
* - 这里不读取文件、不修改 session,只基于传入文本构造返回对象。
|
|
7
|
-
*/
|
|
8
|
-
const DEFAULT_MAX_OUTPUT_CHARS = 12_000;
|
|
9
|
-
const DEFAULT_MAX_OUTPUT_LINES = 200;
|
|
10
|
-
const APPROX_CHARS_PER_TOKEN = 4;
|
|
11
|
-
function resolveOutputLimits(params) {
|
|
12
|
-
const byTokens = typeof params.maxOutputTokens === "number" &&
|
|
13
|
-
Number.isFinite(params.maxOutputTokens) &&
|
|
14
|
-
params.maxOutputTokens > 0
|
|
15
|
-
? Math.max(200, Math.floor(params.maxOutputTokens * APPROX_CHARS_PER_TOKEN))
|
|
16
|
-
: null;
|
|
17
|
-
return {
|
|
18
|
-
maxChars: byTokens == null
|
|
19
|
-
? DEFAULT_MAX_OUTPUT_CHARS
|
|
20
|
-
: Math.min(DEFAULT_MAX_OUTPUT_CHARS, byTokens),
|
|
21
|
-
maxLines: DEFAULT_MAX_OUTPUT_LINES,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function splitOutputByLimits(text, maxChars, maxLines) {
|
|
25
|
-
const limitedByChars = text.slice(0, Math.min(text.length, maxChars));
|
|
26
|
-
let head = limitedByChars;
|
|
27
|
-
if (maxLines > 0) {
|
|
28
|
-
const lines = limitedByChars.split("\n");
|
|
29
|
-
if (lines.length > maxLines) {
|
|
30
|
-
head = lines.slice(0, maxLines).join("\n");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
head,
|
|
35
|
-
tail: text.slice(head.length),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* 根据游标与 token 限制构造输出块。
|
|
40
|
-
*/
|
|
41
|
-
export function createOutputChunk(params) {
|
|
42
|
-
const fromCursor = typeof params.fromCursor === "number" && params.fromCursor >= 0
|
|
43
|
-
? Math.floor(params.fromCursor)
|
|
44
|
-
: 0;
|
|
45
|
-
const available = params.outputText.slice(fromCursor);
|
|
46
|
-
const originalChars = available.length;
|
|
47
|
-
const originalLines = available ? available.split("\n").length : 0;
|
|
48
|
-
const limits = resolveOutputLimits({
|
|
49
|
-
context: params.context,
|
|
50
|
-
maxOutputTokens: params.maxOutputTokens,
|
|
51
|
-
});
|
|
52
|
-
const { head, tail } = splitOutputByLimits(available, limits.maxChars, limits.maxLines);
|
|
53
|
-
return {
|
|
54
|
-
shellId: params.shellId,
|
|
55
|
-
output: head,
|
|
56
|
-
startCursor: fromCursor,
|
|
57
|
-
endCursor: fromCursor + head.length,
|
|
58
|
-
originalChars,
|
|
59
|
-
originalLines,
|
|
60
|
-
hasMoreOutput: tail.length > 0,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* 构造 shell action 标准返回。
|
|
65
|
-
*/
|
|
66
|
-
export function buildActionResponse(params) {
|
|
67
|
-
return {
|
|
68
|
-
shell: params.shell,
|
|
69
|
-
...(params.chunk ? { chunk: params.chunk } : {}),
|
|
70
|
-
...(params.note ? { note: params.note } : {}),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=ShellActionResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShellActionResponse.js","sourceRoot":"","sources":["../../../src/shell/runtime/ShellActionResponse.ts"],"names":[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AAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shell action 运行时编排入口。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这里只负责编排 shell plugin runtime 的公开动作:start/status/read/write/wait/close/exec。
|
|
6
|
-
* - 持久化、输出裁剪、waiter 协调、session 查找等共享细节拆到 `ShellActionRuntimeSupport.ts`。
|
|
7
|
-
* - 新版本所有状态都通过 ShellPluginState 显式传入,不再使用模块级单例。
|
|
8
|
-
*/
|
|
9
|
-
import type { AgentContext } from "@downcity/agent/internal/types/runtime/agent/AgentContext.js";
|
|
10
|
-
import type { ShellPluginState } from "../../shell/ShellRuntimeTypes.js";
|
|
11
|
-
import type { ShellActionResponse, ShellCloseRequest, ShellExecRequest, ShellQueryRequest, ShellReadRequest, ShellStartRequest, ShellWaitRequest, ShellWriteRequest } from "@downcity/agent/internal/executor/tools/shell/types/ShellPlugin.js";
|
|
12
|
-
export { createShellPluginState } from "./ShellActionRuntimeSupport.js";
|
|
13
|
-
/**
|
|
14
|
-
* 绑定当前 shell plugin runtime 实例的 execution runtime。
|
|
15
|
-
*/
|
|
16
|
-
export declare function bindShellRuntime(state: ShellPluginState, context: AgentContext): void;
|
|
17
|
-
/**
|
|
18
|
-
* 关闭当前实例持有的所有活动 shell。
|
|
19
|
-
*/
|
|
20
|
-
export declare function closeAllShellSessions(state: ShellPluginState, force?: boolean): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* 启动一个 shell session。
|
|
23
|
-
*/
|
|
24
|
-
export declare function startShellSession(state: ShellPluginState, context: AgentContext, request: ShellStartRequest): Promise<ShellActionResponse>;
|
|
25
|
-
/**
|
|
26
|
-
* 查询 shell session 状态。
|
|
27
|
-
*/
|
|
28
|
-
export declare function getShellSessionStatus(state: ShellPluginState, context: AgentContext, request: ShellQueryRequest): Promise<ShellActionResponse>;
|
|
29
|
-
/**
|
|
30
|
-
* 读取 shell session 输出。
|
|
31
|
-
*/
|
|
32
|
-
export declare function readShellSession(state: ShellPluginState, context: AgentContext, request: ShellReadRequest): Promise<ShellActionResponse>;
|
|
33
|
-
/**
|
|
34
|
-
* 向 shell session 写入 stdin。
|
|
35
|
-
*/
|
|
36
|
-
export declare function writeShellSession(state: ShellPluginState, context: AgentContext, request: ShellWriteRequest): Promise<ShellActionResponse>;
|
|
37
|
-
/**
|
|
38
|
-
* 等待 shell session 状态变化。
|
|
39
|
-
*/
|
|
40
|
-
export declare function waitShellSession(state: ShellPluginState, context: AgentContext, request: ShellWaitRequest): Promise<ShellActionResponse>;
|
|
41
|
-
/**
|
|
42
|
-
* 关闭 shell session。
|
|
43
|
-
*/
|
|
44
|
-
export declare function closeShellSession(state: ShellPluginState, context: AgentContext, request: ShellCloseRequest): Promise<ShellActionResponse>;
|
|
45
|
-
/**
|
|
46
|
-
* 以 one-shot 模式执行 shell command。
|
|
47
|
-
*/
|
|
48
|
-
export declare function execShellCommand(state: ShellPluginState, context: AgentContext, request: ShellExecRequest): Promise<ShellActionResponse>;
|
|
49
|
-
/**
|
|
50
|
-
* 列出 pending unrestricted sandbox 审批。
|
|
51
|
-
*/
|
|
52
|
-
export declare function listShellApprovals(state: ShellPluginState): {
|
|
53
|
-
approvalId: string;
|
|
54
|
-
shellId: string;
|
|
55
|
-
ownerContextId?: string;
|
|
56
|
-
toolName: "shell_exec" | "shell_start";
|
|
57
|
-
cmd: string;
|
|
58
|
-
cwd: string;
|
|
59
|
-
reason: string;
|
|
60
|
-
createdAt: number;
|
|
61
|
-
}[];
|
|
62
|
-
/**
|
|
63
|
-
* 批准 pending unrestricted sandbox 审批。
|
|
64
|
-
*/
|
|
65
|
-
export declare function approveShellApproval(state: ShellPluginState, context: AgentContext, approvalId: string): Promise<boolean>;
|
|
66
|
-
/**
|
|
67
|
-
* 拒绝 pending unrestricted sandbox 审批。
|
|
68
|
-
*/
|
|
69
|
-
export declare function denyShellApproval(state: ShellPluginState, context: AgentContext, approvalId: string): Promise<boolean>;
|
|
70
|
-
//# sourceMappingURL=ShellActionRuntime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShellActionRuntime.d.ts","sourceRoot":"","sources":["../../../src/shell/runtime/ShellActionRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAC;AAEjG,OAAO,KAAK,EACV,gBAAgB,EAGjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,EACV,mBAAmB,EAEnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oEAAoE,CAAC;AA2B5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAQxE;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,YAAY,GACpB,IAAI,CAEN;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,gBAAgB,EACvB,KAAK,UAAQ,GACZ,OAAO,CAAC,IAAI,CAAC,CAkCf;AA6DD;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAuK9B;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,iBAAiB,GACzB,OAAO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