@armadra/agent 0.15.1 → 0.16.0
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/CHANGELOG.md +30 -0
- package/CHANGELOG.zh-CN.md +30 -0
- package/dist/agent/recovery-reminder.d.ts +23 -0
- package/dist/agent/recovery-reminder.js +42 -0
- package/dist/agent/reminders.d.ts +10 -4
- package/dist/agent/reminders.js +59 -19
- package/dist/agent/session-plan.js +3 -4
- package/dist/agent/session-settings.d.ts +5 -0
- package/dist/agent/session-settings.js +15 -2
- package/dist/agent/session-subagent.d.ts +5 -0
- package/dist/agent/session-subagent.js +65 -12
- package/dist/agent/session-tools.d.ts +3 -1
- package/dist/agent/session-tools.js +47 -3
- package/dist/agent/subagent-background.js +1 -0
- package/dist/agent/subagent-fork.js +3 -1
- package/dist/agent/subagent-handle.d.ts +22 -0
- package/dist/agent/subagent-handle.js +55 -0
- package/dist/agent/subagent-lifetime.d.ts +35 -0
- package/dist/agent/subagent-lifetime.js +112 -0
- package/dist/agent/subagent-registry.d.ts +23 -15
- package/dist/agent/subagent-registry.js +68 -81
- package/dist/agent/system-prompt.d.ts +8 -0
- package/dist/agent/system-prompt.js +4 -0
- package/dist/agent/types-w5.d.ts +8 -3
- package/dist/agent/types.d.ts +7 -0
- package/dist/agents/builtin.d.ts +1 -1
- package/dist/agents/builtin.js +3 -2
- package/dist/agents/report.d.ts +25 -0
- package/dist/agents/report.js +51 -0
- package/dist/agents/result.d.ts +9 -1
- package/dist/agents/result.js +16 -0
- package/dist/agents/task-control.d.ts +12 -0
- package/dist/agents/task-record.d.ts +24 -1
- package/dist/agents/task-record.js +24 -0
- package/dist/bundle/ama.cjs +3144 -1771
- package/dist/cli/bootstrap.js +14 -7
- package/dist/cli/compose-agents.d.ts +2 -1
- package/dist/cli/compose-agents.js +4 -1
- package/dist/cli/compose-events.d.ts +18 -3
- package/dist/cli/compose-events.js +17 -2
- package/dist/cli/compose-session.d.ts +1 -1
- package/dist/cli/compose-session.js +8 -16
- package/dist/cli/compose.d.ts +8 -0
- package/dist/cli/compose.js +25 -1
- package/dist/cli/deps.d.ts +12 -0
- package/dist/config/json-schema.js +4 -0
- package/dist/config/key-docs.js +3 -1
- package/dist/config/schema-w5.js +3 -0
- package/dist/config/schema.js +12 -1
- package/dist/config/settings-registry.js +4 -0
- package/dist/config/types-w5.d.ts +2 -0
- package/dist/config/types.d.ts +7 -0
- package/dist/drivers/acp/types.d.ts +4 -0
- package/dist/drivers/runner.js +5 -0
- package/dist/drivers/turn.d.ts +7 -0
- package/dist/drivers/turn.js +21 -0
- package/dist/drivers/types.d.ts +6 -0
- package/dist/hooks/dispatcher.d.ts +7 -1
- package/dist/hooks/dispatcher.js +28 -1
- package/dist/hooks/matcher.d.ts +4 -0
- package/dist/hooks/matcher.js +19 -2
- package/dist/host/api-impl.d.ts +8 -0
- package/dist/host/api-impl.js +10 -0
- package/dist/host/resources.d.ts +25 -0
- package/dist/host/resources.js +63 -0
- package/dist/host/types.d.ts +24 -2
- package/dist/host/types.js +9 -2
- package/dist/host.d.ts +1 -0
- package/dist/host.js +2 -0
- package/dist/i18n/catalog.d.ts +26 -0
- package/dist/i18n/messages/approval.d.ts +9 -0
- package/dist/i18n/messages/approval.js +9 -0
- package/dist/i18n/messages/config-keys.d.ts +8 -0
- package/dist/i18n/messages/config-keys.js +8 -0
- package/dist/i18n/messages/config.d.ts +8 -0
- package/dist/i18n/messages/drivers.d.ts +16 -0
- package/dist/i18n/messages/drivers.js +16 -0
- package/dist/i18n/messages/panels.d.ts +15 -0
- package/dist/i18n/messages/panels.js +5 -0
- package/dist/i18n/messages/settings.d.ts +6 -0
- package/dist/i18n/messages/settings.js +6 -0
- package/dist/modes/acp/acp-events.d.ts +3 -0
- package/dist/modes/acp/acp-events.js +21 -0
- package/dist/modes/interactive/agent-bar.d.ts +7 -2
- package/dist/modes/interactive/agent-bar.js +16 -6
- package/dist/modes/interactive/approval-ui.d.ts +2 -0
- package/dist/modes/interactive/approval-ui.js +4 -1
- package/dist/modes/interactive/interactive-mode.js +6 -1
- package/dist/modes/interactive/key-dispatch.d.ts +5 -0
- package/dist/modes/interactive/key-dispatch.js +28 -4
- package/dist/modes/interactive/program-status-ui.d.ts +1 -0
- package/dist/modes/interactive/program-status-ui.js +38 -5
- package/dist/modes/interactive/session-events.js +13 -1
- package/dist/modes/interactive/subagent-view.d.ts +4 -1
- package/dist/modes/interactive/subagent-view.js +26 -6
- package/dist/modes/interactive/tasks-report.d.ts +4 -1
- package/dist/modes/interactive/tasks-report.js +12 -0
- package/dist/modes/rpc/commands.d.ts +10 -1
- package/dist/modes/rpc/commands.js +19 -1
- package/dist/permissions/broker.d.ts +38 -3
- package/dist/permissions/broker.js +118 -7
- package/dist/permissions/pipeline.d.ts +11 -10
- package/dist/permissions/pipeline.js +18 -46
- package/dist/permissions/rules.d.ts +21 -4
- package/dist/permissions/rules.js +43 -9
- package/dist/permissions/session-grants.d.ts +14 -0
- package/dist/permissions/session-grants.js +47 -0
- package/dist/permissions/types.d.ts +18 -0
- package/dist/session/unclean-end.d.ts +47 -0
- package/dist/session/unclean-end.js +153 -0
- package/dist/tools/background-jobs.d.ts +50 -3
- package/dist/tools/background-jobs.js +70 -6
- package/dist/tools/bash-jobs.d.ts +26 -0
- package/dist/tools/bash-jobs.js +165 -0
- package/dist/tools/bash.d.ts +22 -5
- package/dist/tools/bash.js +76 -103
- package/dist/tools/output-accumulator.d.ts +5 -0
- package/dist/tools/output-accumulator.js +9 -0
- package/dist/tools/read-lines.d.ts +2 -0
- package/dist/tools/read-lines.js +4 -0
- package/dist/tools/read-resource.d.ts +24 -0
- package/dist/tools/read-resource.js +129 -0
- package/dist/tools/read.d.ts +7 -2
- package/dist/tools/read.js +16 -5
- package/dist/tools/registry.d.ts +5 -2
- package/dist/tools/registry.js +8 -3
- package/dist/tools/report.d.ts +24 -0
- package/dist/tools/report.js +81 -0
- package/dist/tools/resource-ref.d.ts +90 -0
- package/dist/tools/resource-ref.js +90 -0
- package/dist/tools/task-ctl.d.ts +8 -1
- package/dist/tools/task-ctl.js +31 -5
- package/dist/tools/task.d.ts +2 -0
- package/dist/tools/task.js +3 -0
- package/dist/tools/timers.d.ts +18 -0
- package/dist/tools/timers.js +26 -0
- package/dist/tools/types.d.ts +30 -0
- package/dist/tools/types.js +2 -0
- package/docs/en/guides/permissions.md +14 -0
- package/docs/en/guides/tui.md +21 -21
- package/docs/en/reference/acp.md +15 -14
- package/docs/en/reference/host-api.md +48 -20
- package/docs/en/reference/rpc.md +12 -9
- package/docs/guides/agents.md +83 -22
- package/docs/guides/hooks.md +12 -9
- package/docs/guides/permissions.md +14 -0
- package/docs/guides/tui.md +21 -21
- package/docs/reference/acp.md +15 -14
- package/docs/reference/host-api.md +69 -41
- package/docs/reference/rpc.md +15 -9
- package/docs/reference/session-format.md +29 -11
- package/package.json +1 -1
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* cwd、model、permissionMode、depth、host…)由构造时给的 `context()` 每次现取,再由第 4 参数
|
|
6
6
|
* 按次覆盖(子 Agent 的 depth / sessionId / sessionFile)。每条 Hook 执行后回调
|
|
7
7
|
* `onExecuted`(bootstrap 把它接到宿主事件 `hook_executed`)。matcher 只在 Pre/PostToolUse 生效。
|
|
8
|
+
*
|
|
9
|
+
* [#277] `read` 调用的 `toolInput.path` 先经组装根注入的 `normalizePath` 规范化(已注册的宿主资源引用 →
|
|
10
|
+
* `小写scheme://path`,其它原文),matcher 与交给 Hook 脚本的 stdin 用同一个值——与权限规则看到的一致,
|
|
11
|
+
* `DEMO://x` 绕不过 `read(demo://*)`。hooks 模块不 import tools,规范化函数由 bootstrap 提供。
|
|
8
12
|
*/
|
|
9
13
|
import type { LoadedHook } from "./config.js";
|
|
10
14
|
import { type RunHookOptions } from "./runner.js";
|
|
@@ -22,6 +26,8 @@ export interface HookDispatcherOptions {
|
|
|
22
26
|
executor?: HookExecutor;
|
|
23
27
|
/** 额外环境变量。 */
|
|
24
28
|
env?: Readonly<Record<string, string | undefined>>;
|
|
29
|
+
/** [#277] `read` 的 `path` 规范化(已注册资源引用 → 小写 scheme;其它原文);缺省不改。 */
|
|
30
|
+
normalizePath?: (path: string) => string;
|
|
25
31
|
}
|
|
26
32
|
export declare class HookDispatcher implements HookDispatcherApi {
|
|
27
33
|
private readonly byEvent;
|
|
@@ -29,7 +35,7 @@ export declare class HookDispatcher implements HookDispatcherApi {
|
|
|
29
35
|
constructor(options: HookDispatcherOptions);
|
|
30
36
|
private matching;
|
|
31
37
|
has(event: HookEvent, toolName?: string): boolean;
|
|
32
|
-
run(event: HookEvent,
|
|
38
|
+
run(event: HookEvent, rawPayload: HookEventPayload, signal?: AbortSignal, context?: HookContextOverrides): Promise<HookOutcome>;
|
|
33
39
|
/** Notification 投递:纯通知,不等待结果、不抛错。 */
|
|
34
40
|
notify(notification: HookNotification): void;
|
|
35
41
|
list(): readonly {
|
package/dist/hooks/dispatcher.js
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* cwd、model、permissionMode、depth、host…)由构造时给的 `context()` 每次现取,再由第 4 参数
|
|
6
6
|
* 按次覆盖(子 Agent 的 depth / sessionId / sessionFile)。每条 Hook 执行后回调
|
|
7
7
|
* `onExecuted`(bootstrap 把它接到宿主事件 `hook_executed`)。matcher 只在 Pre/PostToolUse 生效。
|
|
8
|
+
*
|
|
9
|
+
* [#277] `read` 调用的 `toolInput.path` 先经组装根注入的 `normalizePath` 规范化(已注册的宿主资源引用 →
|
|
10
|
+
* `小写scheme://path`,其它原文),matcher 与交给 Hook 脚本的 stdin 用同一个值——与权限规则看到的一致,
|
|
11
|
+
* `DEMO://x` 绕不过 `read(demo://*)`。hooks 模块不 import tools,规范化函数由 bootstrap 提供。
|
|
8
12
|
*/
|
|
9
13
|
import { compileMatcher } from "./matcher.js";
|
|
10
14
|
import { emptyOutcome, mergeResults } from "./protocol.js";
|
|
@@ -21,6 +25,28 @@ function withOverrides(base, overrides) {
|
|
|
21
25
|
return merged;
|
|
22
26
|
}
|
|
23
27
|
const TOOL_EVENTS = new Set(["PreToolUse", "PostToolUse"]);
|
|
28
|
+
/** 只有内置 `read` 读宿主资源;write / edit 的 `scheme://x` 是普通文件名,保持原文。 */
|
|
29
|
+
const RESOURCE_TOOL = "read";
|
|
30
|
+
/**
|
|
31
|
+
* [#277] Pre/PostToolUse 且工具为 `read`、`path` 为字符串时返回带规范化 `path` 的浅拷贝;其它情况原样返回。
|
|
32
|
+
* 不改动调用方的输入对象。
|
|
33
|
+
*/
|
|
34
|
+
function normalizePayload(event, payload, normalize) {
|
|
35
|
+
if (normalize === undefined || !TOOL_EVENTS.has(event))
|
|
36
|
+
return payload;
|
|
37
|
+
if (payload.toolName !== RESOURCE_TOOL)
|
|
38
|
+
return payload;
|
|
39
|
+
const input = payload.toolInput;
|
|
40
|
+
if (typeof input !== "object" || input === null)
|
|
41
|
+
return payload;
|
|
42
|
+
const path = input["path"];
|
|
43
|
+
if (typeof path !== "string")
|
|
44
|
+
return payload;
|
|
45
|
+
const normalized = normalize(path);
|
|
46
|
+
if (normalized === path)
|
|
47
|
+
return payload;
|
|
48
|
+
return { ...payload, toolInput: { ...input, path: normalized } };
|
|
49
|
+
}
|
|
24
50
|
export class HookDispatcher {
|
|
25
51
|
byEvent = new Map();
|
|
26
52
|
options;
|
|
@@ -54,7 +80,8 @@ export class HookDispatcher {
|
|
|
54
80
|
// 不知道输入时只按工具名判断(括号参数视为可能匹配)。
|
|
55
81
|
return list.some((c) => c.nameMatcher(toolName, undefined));
|
|
56
82
|
}
|
|
57
|
-
async run(event,
|
|
83
|
+
async run(event, rawPayload, signal, context) {
|
|
84
|
+
const payload = normalizePayload(event, rawPayload, this.options.normalizePath);
|
|
58
85
|
const hooks = this.matching(event, payload.toolName, payload.toolInput);
|
|
59
86
|
if (hooks.length === 0)
|
|
60
87
|
return emptyOutcome();
|
package/dist/hooks/matcher.d.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* `bash(git push*)` 先匹配工具名,再对参数文本做 glob;`/regex/flags` 对工具名做正则。
|
|
6
6
|
* 括号内的文本:bash → `input.command`;文件类工具 → `input.path`(或 `file_path` / `pattern`);
|
|
7
7
|
* web_fetch → `input.url`(整个 URL,与权限规则的 `host/path` 语义不同);其它工具 → 输入 JSON 文本。`|` 只在括号外分隔候选。只在 Pre/PostToolUse 生效。
|
|
8
|
+
*
|
|
9
|
+
* [#277] `read` 的括号文本若以 `scheme://` 开头,scheme 先转小写再 glob:dispatcher 已把已注册资源引用的
|
|
10
|
+
* `path` 规范成小写 scheme,`read(DEMO://*)` 与 `read(demo://*)` 都命中 `DEMO://x` / `demo://x`(与权限规则
|
|
11
|
+
* 对 pattern 的处理一致)。只动 scheme 部分,路径部分与普通路径 glob 仍区分大小写;其它工具不做此处理。
|
|
8
12
|
*/
|
|
9
13
|
export type ToolMatcher = (toolName: string, input: unknown) => boolean;
|
|
10
14
|
/** glob → 正则:`*` 任意字符串(含 `/`),`?` 单个字符,其余字面量。 */
|
package/dist/hooks/matcher.js
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* `bash(git push*)` 先匹配工具名,再对参数文本做 glob;`/regex/flags` 对工具名做正则。
|
|
6
6
|
* 括号内的文本:bash → `input.command`;文件类工具 → `input.path`(或 `file_path` / `pattern`);
|
|
7
7
|
* web_fetch → `input.url`(整个 URL,与权限规则的 `host/path` 语义不同);其它工具 → 输入 JSON 文本。`|` 只在括号外分隔候选。只在 Pre/PostToolUse 生效。
|
|
8
|
+
*
|
|
9
|
+
* [#277] `read` 的括号文本若以 `scheme://` 开头,scheme 先转小写再 glob:dispatcher 已把已注册资源引用的
|
|
10
|
+
* `path` 规范成小写 scheme,`read(DEMO://*)` 与 `read(demo://*)` 都命中 `DEMO://x` / `demo://x`(与权限规则
|
|
11
|
+
* 对 pattern 的处理一致)。只动 scheme 部分,路径部分与普通路径 glob 仍区分大小写;其它工具不做此处理。
|
|
8
12
|
*/
|
|
9
13
|
/** glob → 正则:`*` 任意字符串(含 `/`),`?` 单个字符,其余字面量。 */
|
|
10
14
|
export function globToRegExp(glob) {
|
|
@@ -63,6 +67,14 @@ export function argumentText(toolName, input) {
|
|
|
63
67
|
}
|
|
64
68
|
const REGEX_FORM = /^\/(.+)\/([a-z]*)$/s;
|
|
65
69
|
const CALL_FORM = /^([^()]+)\((.*)\)$/s;
|
|
70
|
+
/** 资源引用形状的前缀(与 tools/resource-ref.ts 一致;hooks 不 import tools)。 */
|
|
71
|
+
const SCHEME_PREFIX_RE = /^([A-Za-z][A-Za-z0-9+.-]{1,31}):\/\//;
|
|
72
|
+
/** 只有内置 `read` 读宿主资源。 */
|
|
73
|
+
const RESOURCE_TOOL = "read";
|
|
74
|
+
/** [#277] 括号文本以 `scheme://` 开头时把 scheme 转小写,其余原样。 */
|
|
75
|
+
function lowerSchemePrefix(text) {
|
|
76
|
+
return text.replace(SCHEME_PREFIX_RE, (_m, scheme) => `${scheme.toLowerCase()}://`);
|
|
77
|
+
}
|
|
66
78
|
function compileAlternative(alt, nameOnly = false) {
|
|
67
79
|
const regex = REGEX_FORM.exec(alt);
|
|
68
80
|
if (regex !== null) {
|
|
@@ -72,10 +84,15 @@ function compileAlternative(alt, nameOnly = false) {
|
|
|
72
84
|
const call = CALL_FORM.exec(alt);
|
|
73
85
|
if (call !== null) {
|
|
74
86
|
const name = globToRegExp((call[1] ?? "").trim());
|
|
75
|
-
const
|
|
87
|
+
const argText = (call[2] ?? "").trim();
|
|
88
|
+
const arg = globToRegExp(argText);
|
|
89
|
+
const loweredText = lowerSchemePrefix(argText);
|
|
90
|
+
// read 用 scheme 小写化后的 pattern(已注册资源的 path 已被规范成小写 scheme)
|
|
91
|
+
const argForRead = loweredText === argText ? arg : globToRegExp(loweredText);
|
|
76
92
|
if (nameOnly)
|
|
77
93
|
return (toolName) => name.test(toolName);
|
|
78
|
-
return (toolName, input) => name.test(toolName) &&
|
|
94
|
+
return (toolName, input) => name.test(toolName) &&
|
|
95
|
+
(toolName === RESOURCE_TOOL ? argForRead : arg).test(argumentText(toolName, input));
|
|
79
96
|
}
|
|
80
97
|
const name = globToRegExp(alt);
|
|
81
98
|
return (toolName) => name.test(toolName);
|
package/dist/host/api-impl.d.ts
CHANGED
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
*
|
|
13
13
|
* [#226] `runners.onDone` 与 `minor`(host-api 1.1):每轮结束的事件由 registry 的观察包装发出,
|
|
14
14
|
* 处理器异常走本适配器的 `log`。
|
|
15
|
+
*
|
|
16
|
+
* [#270] `resources`(host-api 1.2):注册进 bootstrap 注入的 {@link HostResourceRegistry}(read 工具
|
|
17
|
+
* 持同一个实例);未注入时本地新建一个(SDK / 测试),宿主激活后由 bootstrap 冻结。
|
|
15
18
|
*/
|
|
16
19
|
import { HostRunnerRegistry } from "../drivers/host-runners.js";
|
|
17
20
|
import type { AgentEventName, AgentEvents, ApprovalBroker, HostAdapter, HostAdapterHandle, HostApi, HostMode, InstructionSource } from "./types.js";
|
|
21
|
+
import { HostResourceRegistry } from "./resources.js";
|
|
18
22
|
import type { ToolRegistryApi } from "../tools/types.js";
|
|
19
23
|
import type { WarmingDecisionHandler } from "../ai/cache/types.js";
|
|
20
24
|
export type HostNotify = (message: string, level: "info" | "warn" | "error") => void;
|
|
@@ -56,6 +60,8 @@ export interface HostApiDeps {
|
|
|
56
60
|
log?: HostLogger;
|
|
57
61
|
/** stderr 写入(测试注入)。 */
|
|
58
62
|
stderr?: (text: string) => void;
|
|
63
|
+
/** [#270] 宿主资源注册表(与 read 工具共用同一实例);缺省新建。 */
|
|
64
|
+
resources?: HostResourceRegistry;
|
|
59
65
|
}
|
|
60
66
|
/** createHostApi 的产物:api 交给适配器,其余给 bootstrap / AgentSession。 */
|
|
61
67
|
export interface HostApiBinding {
|
|
@@ -78,6 +84,8 @@ export interface HostApiBinding {
|
|
|
78
84
|
setNotify(fn?: HostNotify): void;
|
|
79
85
|
/** [W3-C0] 宿主经 `cache.onWarmingDecision` 注册的否决钩子(最后注册且未注销的那个)。 */
|
|
80
86
|
warmingDecider(): WarmingDecisionHandler | undefined;
|
|
87
|
+
/** [#270] 宿主资源注册表(系统提示资源行与 read 工具都读它)。 */
|
|
88
|
+
readonly resources: HostResourceRegistry;
|
|
81
89
|
}
|
|
82
90
|
/** [W5-EG] 宿主经 `runners.provide` 注入的 runner(HostApi 不是本模块创建的返回 undefined)。 */
|
|
83
91
|
export declare function hostRunnersOf(api: HostApi): HostRunnerRegistry | undefined;
|
package/dist/host/api-impl.js
CHANGED
|
@@ -12,11 +12,15 @@
|
|
|
12
12
|
*
|
|
13
13
|
* [#226] `runners.onDone` 与 `minor`(host-api 1.1):每轮结束的事件由 registry 的观察包装发出,
|
|
14
14
|
* 处理器异常走本适配器的 `log`。
|
|
15
|
+
*
|
|
16
|
+
* [#270] `resources`(host-api 1.2):注册进 bootstrap 注入的 {@link HostResourceRegistry}(read 工具
|
|
17
|
+
* 持同一个实例);未注入时本地新建一个(SDK / 测试),宿主激活后由 bootstrap 冻结。
|
|
15
18
|
*/
|
|
16
19
|
import { HostRunnerRegistry } from "../drivers/host-runners.js";
|
|
17
20
|
import { AmaError } from "../errors.js";
|
|
18
21
|
import { AMA_VERSION } from "../version.js";
|
|
19
22
|
import { HOST_API_MINOR, HOST_API_VERSION } from "./types.js";
|
|
23
|
+
import { HostResourceRegistry } from "./resources.js";
|
|
20
24
|
import { msg } from "../i18n/index.js";
|
|
21
25
|
/** 进程内事件总线(宿主观察 AgentEvents)。 */
|
|
22
26
|
export class AgentEventBus {
|
|
@@ -86,6 +90,7 @@ export function createHostApi(deps) {
|
|
|
86
90
|
writeErr(`ama: [host] ${message}\n`);
|
|
87
91
|
});
|
|
88
92
|
const runners = new HostRunnerRegistry({ log: (message, error) => log("error", message, error) });
|
|
93
|
+
const resources = deps.resources ?? new HostResourceRegistry();
|
|
89
94
|
const api = Object.freeze({
|
|
90
95
|
version: HOST_API_VERSION,
|
|
91
96
|
minor: HOST_API_MINOR,
|
|
@@ -174,6 +179,10 @@ export function createHostApi(deps) {
|
|
|
174
179
|
provide: (runner) => runners.provide(runner),
|
|
175
180
|
onDone: (handler) => runners.onDone(handler),
|
|
176
181
|
}),
|
|
182
|
+
resources: Object.freeze({
|
|
183
|
+
register: (resource) => resources.register(resource),
|
|
184
|
+
list: () => resources.schemes(),
|
|
185
|
+
}),
|
|
177
186
|
});
|
|
178
187
|
hostRunnerRegistries.set(api, runners);
|
|
179
188
|
return {
|
|
@@ -190,5 +199,6 @@ export function createHostApi(deps) {
|
|
|
190
199
|
notify = fn ?? deps.notify;
|
|
191
200
|
},
|
|
192
201
|
warmingDecider: () => warmingHandlers.at(-1),
|
|
202
|
+
resources,
|
|
193
203
|
};
|
|
194
204
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 宿主资源注册表(#270,host-api 1.2 `api.resources`):`create()` 期间注册,宿主激活后冻结——
|
|
3
|
+
* 系统提示工具节的资源行在会话开始时固定,之后 `register` 抛错。
|
|
4
|
+
*
|
|
5
|
+
* 校验:scheme `^[a-z][a-z0-9+.-]{1,31}$` 且不在保留字里(`http(s)` 归 web_fetch、`file` 归文件 read),
|
|
6
|
+
* `describe` 单行 ≤ 120 字符,`read` 是函数,同名已存在抛 `tool_exists`,数量 ≤ 12。
|
|
7
|
+
* 本注册表实现 `read` 工具查资源用的 {@link HostResourceLookup};bootstrap 在第 12 步前创建它,
|
|
8
|
+
* 既交给 read 工具也交给 HostApi。
|
|
9
|
+
*/
|
|
10
|
+
import { type HostResource, type HostResourceLookup } from "../tools/resource-ref.js";
|
|
11
|
+
export declare class HostResourceRegistry implements HostResourceLookup {
|
|
12
|
+
private readonly entries;
|
|
13
|
+
private frozen;
|
|
14
|
+
register(resource: HostResource): void;
|
|
15
|
+
/** 宿主激活后调用:之后不再接受注册。 */
|
|
16
|
+
freeze(): void;
|
|
17
|
+
get isFrozen(): boolean;
|
|
18
|
+
get(scheme: string): HostResource | undefined;
|
|
19
|
+
schemes(): readonly string[];
|
|
20
|
+
/** 系统提示资源行的材料:按 scheme 排序的 `{ scheme, describe }`。 */
|
|
21
|
+
list(): readonly {
|
|
22
|
+
scheme: string;
|
|
23
|
+
describe: string;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 宿主资源注册表(#270,host-api 1.2 `api.resources`):`create()` 期间注册,宿主激活后冻结——
|
|
3
|
+
* 系统提示工具节的资源行在会话开始时固定,之后 `register` 抛错。
|
|
4
|
+
*
|
|
5
|
+
* 校验:scheme `^[a-z][a-z0-9+.-]{1,31}$` 且不在保留字里(`http(s)` 归 web_fetch、`file` 归文件 read),
|
|
6
|
+
* `describe` 单行 ≤ 120 字符,`read` 是函数,同名已存在抛 `tool_exists`,数量 ≤ 12。
|
|
7
|
+
* 本注册表实现 `read` 工具查资源用的 {@link HostResourceLookup};bootstrap 在第 12 步前创建它,
|
|
8
|
+
* 既交给 read 工具也交给 HostApi。
|
|
9
|
+
*/
|
|
10
|
+
import { AmaError } from "../errors.js";
|
|
11
|
+
import { msg } from "../i18n/index.js";
|
|
12
|
+
import { MAX_HOST_RESOURCES, RESERVED_RESOURCE_SCHEMES, RESOURCE_SCHEME_RE, validResourceDescribe, } from "../tools/resource-ref.js";
|
|
13
|
+
export class HostResourceRegistry {
|
|
14
|
+
entries = new Map();
|
|
15
|
+
frozen = false;
|
|
16
|
+
register(resource) {
|
|
17
|
+
if (this.frozen)
|
|
18
|
+
throw new AmaError("invalid_arguments", msg().drivers.host.resourceFrozen);
|
|
19
|
+
if (typeof resource !== "object" || resource === null) {
|
|
20
|
+
throw new AmaError("invalid_arguments", msg().drivers.host.resourceNotObject);
|
|
21
|
+
}
|
|
22
|
+
const scheme = resource.scheme;
|
|
23
|
+
if (typeof scheme !== "string" || !RESOURCE_SCHEME_RE.test(scheme)) {
|
|
24
|
+
throw new AmaError("invalid_arguments", msg().drivers.host.resourceBadScheme(String(scheme)));
|
|
25
|
+
}
|
|
26
|
+
if (RESERVED_RESOURCE_SCHEMES.has(scheme)) {
|
|
27
|
+
throw new AmaError("invalid_arguments", msg().drivers.host.resourceReserved(scheme));
|
|
28
|
+
}
|
|
29
|
+
if (!validResourceDescribe(resource.describe)) {
|
|
30
|
+
throw new AmaError("invalid_arguments", msg().drivers.host.resourceBadDescribe(scheme));
|
|
31
|
+
}
|
|
32
|
+
if (typeof resource.read !== "function") {
|
|
33
|
+
throw new AmaError("invalid_arguments", msg().drivers.host.resourceNoRead(scheme));
|
|
34
|
+
}
|
|
35
|
+
if (this.entries.has(scheme)) {
|
|
36
|
+
throw new AmaError("tool_exists", msg().drivers.host.resourceExists(scheme));
|
|
37
|
+
}
|
|
38
|
+
if (this.entries.size >= MAX_HOST_RESOURCES) {
|
|
39
|
+
throw new AmaError("invalid_arguments", msg().drivers.host.resourceTooMany(MAX_HOST_RESOURCES));
|
|
40
|
+
}
|
|
41
|
+
this.entries.set(scheme, resource);
|
|
42
|
+
}
|
|
43
|
+
/** 宿主激活后调用:之后不再接受注册。 */
|
|
44
|
+
freeze() {
|
|
45
|
+
this.frozen = true;
|
|
46
|
+
}
|
|
47
|
+
get isFrozen() {
|
|
48
|
+
return this.frozen;
|
|
49
|
+
}
|
|
50
|
+
get(scheme) {
|
|
51
|
+
return this.entries.get(scheme);
|
|
52
|
+
}
|
|
53
|
+
schemes() {
|
|
54
|
+
return [...this.entries.keys()].sort();
|
|
55
|
+
}
|
|
56
|
+
/** 系统提示资源行的材料:按 scheme 排序的 `{ scheme, describe }`。 */
|
|
57
|
+
list() {
|
|
58
|
+
return this.schemes().map((scheme) => ({
|
|
59
|
+
scheme,
|
|
60
|
+
describe: this.entries.get(scheme).describe,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
}
|
package/dist/host/types.d.ts
CHANGED
|
@@ -17,21 +17,30 @@
|
|
|
17
17
|
* - (#226)host-api 1.1:可选面 `HostApi.runners.onDone`(宿主 runner 每轮结束的 {@link RunnerDoneEvent})
|
|
18
18
|
* 与 `HostApi.minor`。主版本 `HOST_API_VERSION` 要求宿主严格相等,只在破坏性变化时改;只加不改的
|
|
19
19
|
* 增量递增 {@link HOST_API_MINOR},宿主按成员是否存在做特性探测。
|
|
20
|
+
* - (#270)host-api 1.2:可选面 `HostApi.resources`(宿主资源命名空间,内置 `read` 读 `scheme://path`;
|
|
21
|
+
* 类型在 tools/resource-ref.ts,此处再导出)。
|
|
22
|
+
* - (#268)host-api 1.3:`session_start` 在 `reason: "resume"` 时带 `uncleanEnd`(上一轮没有正常结束,
|
|
23
|
+
* 判定见 session/unclean-end.ts)。只加不改,主版本不变。
|
|
20
24
|
*/
|
|
21
25
|
import type { CacheMiss, WarmingDecisionHandler } from "../ai/cache/types.js";
|
|
22
26
|
import type { HookEvent } from "../hooks/types.js";
|
|
23
27
|
import type { ApprovalBroker, ApprovalDecision } from "../permissions/types.js";
|
|
24
28
|
import type { SubagentRunner, SubagentStatus, ToolDefinition } from "../tools/types.js";
|
|
29
|
+
import type { HostResource } from "../tools/resource-ref.js";
|
|
25
30
|
import type { QuotaUpdateEvent } from "../agent/types-w6.js";
|
|
26
31
|
import type { PlanProposedEvent, PlanResolvedEvent, SubagentEndEvent, SubagentStartEvent } from "../agent/types-w5.js";
|
|
27
32
|
export type { ActionPreview, ActionPreviewTarget, ApprovalBroker, ApprovalDecision, ApprovalReason, ApprovalRequest, ApprovalRequestContext, } from "../permissions/types.js";
|
|
28
33
|
export type { RunnerHandle, SubagentEvent, SubagentRunRequest, SubagentRunner, ToolAnnotations, ToolContext, ToolDefinition, ToolExecutionMode, ToolPermission, ToolResult, } from "../tools/types.js";
|
|
29
34
|
export type { JsonSchema } from "../ai/types.js";
|
|
35
|
+
export type { HostResource, HostResourceContent, HostResourceReadOptions, } from "../tools/resource-ref.js";
|
|
30
36
|
export type { CacheMiss, WarmDecision, WarmingDecisionHandler } from "../ai/cache/types.js";
|
|
31
37
|
export declare const HOST_API_VERSION: 1;
|
|
32
38
|
export type HostApiVersion = typeof HOST_API_VERSION;
|
|
33
|
-
/**
|
|
34
|
-
|
|
39
|
+
/**
|
|
40
|
+
* host-api 小版本:只加不改的可选面每加一批递增(1 = `runners.onDone`,2 = `resources`,3 = `session_start.uncleanEnd`);
|
|
41
|
+
* 旧运行时没有 `api.minor`,按 0 算。
|
|
42
|
+
*/
|
|
43
|
+
export declare const HOST_API_MINOR: 3;
|
|
35
44
|
export type HostMode = "interactive" | "line" | "print" | "rpc";
|
|
36
45
|
export type InstructionSource = {
|
|
37
46
|
kind: "file";
|
|
@@ -57,6 +66,8 @@ export interface AgentEvents {
|
|
|
57
66
|
sessionFile?: string;
|
|
58
67
|
cwd: string;
|
|
59
68
|
reason: "startup" | "resume" | "new" | "fork";
|
|
69
|
+
/** [#268] 只在 `reason: "resume"` 时出现:上一轮没有正常结束(host-api 1.3)。 */
|
|
70
|
+
uncleanEnd?: boolean;
|
|
60
71
|
};
|
|
61
72
|
before_agent_start: {
|
|
62
73
|
prompt: string;
|
|
@@ -218,6 +229,17 @@ export interface HostApi {
|
|
|
218
229
|
*/
|
|
219
230
|
onDone?(handler: (event: RunnerDoneEvent) => void | Promise<void>): () => void;
|
|
220
231
|
};
|
|
232
|
+
/**
|
|
233
|
+
* [#270] 宿主资源命名空间(host-api 1.2):注册后内置 `read` 认 `<scheme>://<path>`,按 `read` 的分页与
|
|
234
|
+
* 截断规则返回宿主给的文本(首行标注不可信),权限类 read、从不询问;系统提示工具节多一行列出全部
|
|
235
|
+
* scheme 与 `describe`。只能在 `create()` 里注册(会话开始后列表固定,再注册抛错)。
|
|
236
|
+
* 可选面:旧版本运行时没有它,用前判断 `api.resources !== undefined`。
|
|
237
|
+
*/
|
|
238
|
+
readonly resources?: {
|
|
239
|
+
register(resource: HostResource): void;
|
|
240
|
+
/** 已注册的 scheme,按名排序。 */
|
|
241
|
+
list(): readonly string[];
|
|
242
|
+
};
|
|
221
243
|
}
|
|
222
244
|
/** Runtime 持有的已激活适配器。 */
|
|
223
245
|
export interface HostAdapterHandle {
|
package/dist/host/types.js
CHANGED
|
@@ -17,7 +17,14 @@
|
|
|
17
17
|
* - (#226)host-api 1.1:可选面 `HostApi.runners.onDone`(宿主 runner 每轮结束的 {@link RunnerDoneEvent})
|
|
18
18
|
* 与 `HostApi.minor`。主版本 `HOST_API_VERSION` 要求宿主严格相等,只在破坏性变化时改;只加不改的
|
|
19
19
|
* 增量递增 {@link HOST_API_MINOR},宿主按成员是否存在做特性探测。
|
|
20
|
+
* - (#270)host-api 1.2:可选面 `HostApi.resources`(宿主资源命名空间,内置 `read` 读 `scheme://path`;
|
|
21
|
+
* 类型在 tools/resource-ref.ts,此处再导出)。
|
|
22
|
+
* - (#268)host-api 1.3:`session_start` 在 `reason: "resume"` 时带 `uncleanEnd`(上一轮没有正常结束,
|
|
23
|
+
* 判定见 session/unclean-end.ts)。只加不改,主版本不变。
|
|
20
24
|
*/
|
|
21
25
|
export const HOST_API_VERSION = 1;
|
|
22
|
-
/**
|
|
23
|
-
|
|
26
|
+
/**
|
|
27
|
+
* host-api 小版本:只加不改的可选面每加一批递增(1 = `runners.onDone`,2 = `resources`,3 = `session_start.uncleanEnd`);
|
|
28
|
+
* 旧运行时没有 `api.minor`,按 0 算。
|
|
29
|
+
*/
|
|
30
|
+
export const HOST_API_MINOR = 3;
|
package/dist/host.d.ts
CHANGED
package/dist/host.js
CHANGED
|
@@ -2,3 +2,5 @@
|
|
|
2
2
|
* `@armadra/agent/host` 子路径:宿主适配器类型 + HOST_API_VERSION(设计 §6.2、D7)。[B0] 所有。
|
|
3
3
|
*/
|
|
4
4
|
export { HOST_API_MINOR, HOST_API_VERSION } from "./host/types.js";
|
|
5
|
+
// [#270] 宿主资源:分页辅助与上限常量
|
|
6
|
+
export { HOST_RESOURCE_TIMEOUT_MS, MAX_HOST_RESOURCES, RESOURCE_DESCRIBE_MAX, pageResourceText, } from "./tools/resource-ref.js";
|
package/dist/i18n/catalog.d.ts
CHANGED
|
@@ -756,6 +756,10 @@ declare const en: {
|
|
|
756
756
|
cancelled: (what: string) => string;
|
|
757
757
|
};
|
|
758
758
|
choiceHint: (arrows: string, n: number) => string;
|
|
759
|
+
reevaluated: {
|
|
760
|
+
allowed: (n: number, mode: string) => string;
|
|
761
|
+
denied: (n: number, mode: string) => string;
|
|
762
|
+
};
|
|
759
763
|
};
|
|
760
764
|
plan: {
|
|
761
765
|
usage: string;
|
|
@@ -1016,6 +1020,13 @@ declare const en: {
|
|
|
1016
1020
|
fullOutput: (path: string) => string;
|
|
1017
1021
|
noOutput: string;
|
|
1018
1022
|
title: (id: string) => string;
|
|
1023
|
+
report: {
|
|
1024
|
+
ready: string;
|
|
1025
|
+
blocked: string;
|
|
1026
|
+
failed: string;
|
|
1027
|
+
waiting: string;
|
|
1028
|
+
};
|
|
1029
|
+
needsPerson: (question: string) => string;
|
|
1019
1030
|
};
|
|
1020
1031
|
};
|
|
1021
1032
|
permissions: {
|
|
@@ -1374,6 +1385,8 @@ declare const en: {
|
|
|
1374
1385
|
"tools.default": string;
|
|
1375
1386
|
"tools.maxToolResultChars": string;
|
|
1376
1387
|
"tools.bashTimeoutMs": string;
|
|
1388
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
1389
|
+
"tools.bashBackgroundMaxMs": string;
|
|
1377
1390
|
"tools.disabled": string;
|
|
1378
1391
|
codemode: string;
|
|
1379
1392
|
"codemode.mode": string;
|
|
@@ -1454,6 +1467,7 @@ declare const en: {
|
|
|
1454
1467
|
"subagents.forkMaxContextRatio": string;
|
|
1455
1468
|
"subagents.background": string;
|
|
1456
1469
|
"subagents.autoBackgroundAfterMs": string;
|
|
1470
|
+
"subagents.backgroundMaxMs": string;
|
|
1457
1471
|
models: string;
|
|
1458
1472
|
"models.aliases": string;
|
|
1459
1473
|
"models.aliases.fast": string;
|
|
@@ -1478,6 +1492,7 @@ declare const en: {
|
|
|
1478
1492
|
"codemode.mode": string;
|
|
1479
1493
|
"ui.ascii": string;
|
|
1480
1494
|
"ui.statusLine": string;
|
|
1495
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
1481
1496
|
"plan.directory": string;
|
|
1482
1497
|
"plan.model": string;
|
|
1483
1498
|
"plan.thinkingLevel": string;
|
|
@@ -1650,6 +1665,14 @@ declare const en: {
|
|
|
1650
1665
|
warmingNeedsFunction: string;
|
|
1651
1666
|
runnerNeedsIdStart: string;
|
|
1652
1667
|
runnerDoneNeedsFunction: string;
|
|
1668
|
+
resourceFrozen: string;
|
|
1669
|
+
resourceNotObject: string;
|
|
1670
|
+
resourceBadScheme: (scheme: string) => string;
|
|
1671
|
+
resourceReserved: (scheme: string) => string;
|
|
1672
|
+
resourceBadDescribe: (scheme: string) => string;
|
|
1673
|
+
resourceNoRead: (scheme: string) => string;
|
|
1674
|
+
resourceExists: (scheme: string) => string;
|
|
1675
|
+
resourceTooMany: (max: number) => string;
|
|
1653
1676
|
notAdapter: (label: string) => string;
|
|
1654
1677
|
versionMismatch: (label: string, found: string, needed: number) => string;
|
|
1655
1678
|
noCreate: (label: string) => string;
|
|
@@ -2186,6 +2209,8 @@ declare const en: {
|
|
|
2186
2209
|
"codemode.requireStrict": string;
|
|
2187
2210
|
"tools.maxToolResultChars": string;
|
|
2188
2211
|
"tools.bashTimeoutMs": string;
|
|
2212
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
2213
|
+
"tools.bashBackgroundMaxMs": string;
|
|
2189
2214
|
"images.resize": string;
|
|
2190
2215
|
"hooks.timeoutMs": string;
|
|
2191
2216
|
"compaction.enabled": string;
|
|
@@ -2224,6 +2249,7 @@ declare const en: {
|
|
|
2224
2249
|
"subagents.maxPending": string;
|
|
2225
2250
|
"subagents.background": string;
|
|
2226
2251
|
"subagents.autoBackgroundAfterMs": string;
|
|
2252
|
+
"subagents.backgroundMaxMs": string;
|
|
2227
2253
|
"memory.enabled": string;
|
|
2228
2254
|
"memory.subagents": string;
|
|
2229
2255
|
};
|
|
@@ -56,6 +56,11 @@ export declare const en: {
|
|
|
56
56
|
};
|
|
57
57
|
/** 通用确认框的按键行。 */
|
|
58
58
|
choiceHint: (arrows: string, n: number) => string;
|
|
59
|
+
/** [#271] 切换权限模式时按新模式自动作答的待审批(消息区一行)。 */
|
|
60
|
+
reevaluated: {
|
|
61
|
+
allowed: (n: number, mode: string) => string;
|
|
62
|
+
denied: (n: number, mode: string) => string;
|
|
63
|
+
};
|
|
59
64
|
};
|
|
60
65
|
export declare const zh: {
|
|
61
66
|
originLabel: (agent: string, sessionId: string) => string;
|
|
@@ -101,4 +106,8 @@ export declare const zh: {
|
|
|
101
106
|
cancelled: (what: string) => string;
|
|
102
107
|
};
|
|
103
108
|
choiceHint: (arrows: string, n: number) => string;
|
|
109
|
+
reevaluated: {
|
|
110
|
+
allowed: (n: number, mode: string) => string;
|
|
111
|
+
denied: (n: number, mode: string) => string;
|
|
112
|
+
};
|
|
104
113
|
};
|
|
@@ -57,6 +57,11 @@ export const en = {
|
|
|
57
57
|
},
|
|
58
58
|
/** 通用确认框的按键行。 */
|
|
59
59
|
choiceHint: (arrows, n) => `${arrows} select · Enter confirm · 1-${n} pick · Esc cancel`,
|
|
60
|
+
/** [#271] 切换权限模式时按新模式自动作答的待审批(消息区一行)。 */
|
|
61
|
+
reevaluated: {
|
|
62
|
+
allowed: (n, mode) => `Auto-allowed ${plural(n, "pending approval")} under ${mode}`,
|
|
63
|
+
denied: (n, mode) => `Auto-denied ${plural(n, "pending approval")} under ${mode}`,
|
|
64
|
+
},
|
|
60
65
|
};
|
|
61
66
|
export const zh = {
|
|
62
67
|
originLabel: (agent, sessionId) => `[${agent} · 会话 ${sessionId}]`,
|
|
@@ -102,4 +107,8 @@ export const zh = {
|
|
|
102
107
|
cancelled: (what) => `审批已取消(超时或中断):${what}`,
|
|
103
108
|
},
|
|
104
109
|
choiceHint: (arrows, n) => `${arrows} 选择 · Enter 确认 · 1-${n} 直接选 · Esc 取消`,
|
|
110
|
+
reevaluated: {
|
|
111
|
+
allowed: (n, mode) => `已按 ${mode} 自动允许 ${n} 个待审批`,
|
|
112
|
+
denied: (n, mode) => `已按 ${mode} 自动拒绝 ${n} 个待审批`,
|
|
113
|
+
},
|
|
105
114
|
};
|
|
@@ -38,6 +38,8 @@ export declare const en: {
|
|
|
38
38
|
"tools.default": string;
|
|
39
39
|
"tools.maxToolResultChars": string;
|
|
40
40
|
"tools.bashTimeoutMs": string;
|
|
41
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
42
|
+
"tools.bashBackgroundMaxMs": string;
|
|
41
43
|
"tools.disabled": string;
|
|
42
44
|
codemode: string;
|
|
43
45
|
"codemode.mode": string;
|
|
@@ -118,6 +120,7 @@ export declare const en: {
|
|
|
118
120
|
"subagents.forkMaxContextRatio": string;
|
|
119
121
|
"subagents.background": string;
|
|
120
122
|
"subagents.autoBackgroundAfterMs": string;
|
|
123
|
+
"subagents.backgroundMaxMs": string;
|
|
121
124
|
models: string;
|
|
122
125
|
"models.aliases": string;
|
|
123
126
|
"models.aliases.fast": string;
|
|
@@ -142,6 +145,7 @@ export declare const en: {
|
|
|
142
145
|
"codemode.mode": string;
|
|
143
146
|
"ui.ascii": string;
|
|
144
147
|
"ui.statusLine": string;
|
|
148
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
145
149
|
"plan.directory": string;
|
|
146
150
|
"plan.model": string;
|
|
147
151
|
"plan.thinkingLevel": string;
|
|
@@ -193,6 +197,8 @@ export declare const zh: {
|
|
|
193
197
|
"tools.default": string;
|
|
194
198
|
"tools.maxToolResultChars": string;
|
|
195
199
|
"tools.bashTimeoutMs": string;
|
|
200
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
201
|
+
"tools.bashBackgroundMaxMs": string;
|
|
196
202
|
"tools.disabled": string;
|
|
197
203
|
codemode: string;
|
|
198
204
|
"codemode.mode": string;
|
|
@@ -273,6 +279,7 @@ export declare const zh: {
|
|
|
273
279
|
"subagents.forkMaxContextRatio": string;
|
|
274
280
|
"subagents.background": string;
|
|
275
281
|
"subagents.autoBackgroundAfterMs": string;
|
|
282
|
+
"subagents.backgroundMaxMs": string;
|
|
276
283
|
models: string;
|
|
277
284
|
"models.aliases": string;
|
|
278
285
|
"models.aliases.fast": string;
|
|
@@ -297,6 +304,7 @@ export declare const zh: {
|
|
|
297
304
|
"codemode.mode": string;
|
|
298
305
|
"ui.ascii": string;
|
|
299
306
|
"ui.statusLine": string;
|
|
307
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
300
308
|
"plan.directory": string;
|
|
301
309
|
"plan.model": string;
|
|
302
310
|
"plan.thinkingLevel": string;
|
|
@@ -13,6 +13,7 @@ const dynamicDefaultsEn = {
|
|
|
13
13
|
"codemode.mode": "follows the tool preset",
|
|
14
14
|
"ui.ascii": "auto-detected",
|
|
15
15
|
"ui.statusLine": "full in a standalone terminal, compact in an embedding host (with a profile)",
|
|
16
|
+
"tools.bashAutoBackgroundAfterMs": "15000 under --mode rpc / acp, in an embedding host (with a profile) or with the coordinator preset; 0 (off) in a standalone terminal and with -p",
|
|
16
17
|
"plan.directory": "<data dir>/plans",
|
|
17
18
|
"plan.model": "unset: keep the current model",
|
|
18
19
|
"plan.thinkingLevel": "unset: keep the current thinking level",
|
|
@@ -37,6 +38,7 @@ const dynamicDefaultsZh = {
|
|
|
37
38
|
"codemode.mode": "跟随预设",
|
|
38
39
|
"ui.ascii": "自动检测",
|
|
39
40
|
"ui.statusLine": "独立终端 full,嵌入宿主(有 profile)compact",
|
|
41
|
+
"tools.bashAutoBackgroundAfterMs": "--mode rpc / acp、嵌入宿主(有 profile)或 coordinator 预设下 15000;独立终端与 -p 下 0(关)",
|
|
40
42
|
"plan.directory": "<数据目录>/plans",
|
|
41
43
|
"plan.model": "不设:沿用当前模型",
|
|
42
44
|
"plan.thinkingLevel": "不设:沿用当前思考强度",
|
|
@@ -87,6 +89,8 @@ const keysEn = {
|
|
|
87
89
|
"tools.default": "Tweak the preset: +name adds, -name removes, bare names replace the preset's built-in tools as a whole; user level only",
|
|
88
90
|
"tools.maxToolResultChars": "Character limit for one tool result in the context; beyond it head and tail are kept",
|
|
89
91
|
"tools.bashTimeoutMs": "Default bash timeout (ms; overridable per call, max 600000)",
|
|
92
|
+
"tools.bashAutoBackgroundAfterMs": "Move a foreground bash command that is still running after this many ms to a background job without restarting it (the tool returns the output so far); 0 disables; must be below the timeout; user level only",
|
|
93
|
+
"tools.bashBackgroundMaxMs": "Lifetime cap for background bash jobs (ms); the process tree is killed when it is reached and the model is told; a job moved from the foreground counts from the move; 0 = unlimited; one extension via bash {job, action: extend}; user level only",
|
|
90
94
|
"tools.disabled": "Disabled tool names; accumulated across levels",
|
|
91
95
|
codemode: "codemode: the model writes scripts that call tools in batches (docs/guides/codemode.md)",
|
|
92
96
|
"codemode.mode": "off | on | only; when unset it follows the preset: default → on (Node ≥ 25; Node 22 / 24 → off), codemode-only → only, minimal / coordinator → off; project level only accepts off",
|
|
@@ -167,6 +171,7 @@ const keysEn = {
|
|
|
167
171
|
"subagents.forkMaxContextRatio": "Fork sub-agents fall back to fresh when the parent's last request used more than this share of (window − compaction.reserveTokens); 0.05–0.95, default 0.5",
|
|
168
172
|
"subagents.background": "Whether task runs in the background by default: auto = background in the TUI / RPC / ACP and foreground with -p; always / never are fixed. The call argument and the agent type's background: override it; user, project and host level",
|
|
169
173
|
"subagents.autoBackgroundAfterMs": "Move a foreground task to the background after it has run this many milliseconds; 0 disables; user and project level",
|
|
174
|
+
"subagents.backgroundMaxMs": "Lifetime cap for background sub-agent tasks (ms): stopped when reached and the model is told; a task moved from the foreground counts from the move; 0 = unlimited; one extension via task_ctl extend; user level only",
|
|
170
175
|
models: "Model aliases and the model picker list; user level only (effective from wave 5 W5-G)",
|
|
171
176
|
"models.aliases": "Models that model: fast / strong in sub-agent definitions point to",
|
|
172
177
|
"models.aliases.fast": "Model for the fast alias provider/model[@channel]",
|
|
@@ -216,6 +221,8 @@ const keysZh = {
|
|
|
216
221
|
"tools.default": "在预设上微调:+name 加、-name 去,不带前缀的名字整组替换预设的内置工具;只认用户级",
|
|
217
222
|
"tools.maxToolResultChars": "单条工具结果进上下文的字符上限,超出保留首尾",
|
|
218
223
|
"tools.bashTimeoutMs": "bash 缺省超时(毫秒,单次调用可覆盖,最大 600000)",
|
|
224
|
+
"tools.bashAutoBackgroundAfterMs": "前台 bash 运行超过该毫秒数仍未结束时原地转为后台任务,不重启进程(工具返回到此刻的输出);0 关闭;须小于超时;只认用户级",
|
|
225
|
+
"tools.bashBackgroundMaxMs": "后台 bash 任务的寿命上限(毫秒):到点杀掉进程树并告诉模型;从前台转来的从转换时刻起算;0 不限;可用 bash {job, action: extend} 续命一次;只认用户级",
|
|
219
226
|
"tools.disabled": "禁用的工具名;各层累加",
|
|
220
227
|
codemode: "codemode:模型写脚本批量调用工具(docs/guides/codemode.md)",
|
|
221
228
|
"codemode.mode": "off | on | only;不写时跟随预设:default → on(Node ≥ 25;Node 22 / 24 → off)、codemode-only → only、minimal / coordinator → off;项目级只接受 off",
|
|
@@ -296,6 +303,7 @@ const keysZh = {
|
|
|
296
303
|
"subagents.forkMaxContextRatio": "fork 子 Agent 的回落比例:父上一次请求超过(窗口 − compaction.reserveTokens)的这一比例时改为 fresh;0.05–0.95,缺省 0.5",
|
|
297
304
|
"subagents.background": "task 缺省是否后台:auto = TUI / RPC / ACP 下后台、-p 下前台;always / never 固定。调用参数与类型定义的 background: 优先;用户、项目、宿主级都认",
|
|
298
305
|
"subagents.autoBackgroundAfterMs": "前台任务运行超过该毫秒数自动转后台;0 关闭;用户、项目级都认",
|
|
306
|
+
"subagents.backgroundMaxMs": "后台子 Agent 任务的寿命上限(毫秒):到点停止并告诉模型;从前台转来的从转换时刻起算;0 不限;可用 task_ctl extend 续命一次;只认用户级",
|
|
299
307
|
models: "模型别名与模型选择器清单;只认用户级(第五波 W5-G 起生效)",
|
|
300
308
|
"models.aliases": "子 Agent 定义里 model: fast / strong 指向的模型",
|
|
301
309
|
"models.aliases.fast": "fast 别名的模型 provider/model[@channel]",
|