@tbox.cn/tboxcode-dsh-bundle 0.1.0-rc.16 → 0.1.0-rc.17

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/cordis.patch.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  # tboxcode-bundle 结构行集(四 profile 链恒挂)。
2
2
  # 行组规格见 .agents/designs/implemented/2026-10-01-overview.md「bundle patch 行清单」(行组级)。
3
- # 禁用行组 = repo-bootstrap 落位;llm / tools / subagent 宿主行 / persona-identity /
4
- # 补挂 行组随 llm-stack C4/C5 落位(prompts / remote 行组随 C6 / serve-gateway)。
3
+ # 禁用行组 = repo-bootstrap 落位;llm / tools / subagent 宿主行 / 补挂 行组随
4
+ # llm-stack C4/C5 落位(prompts / remote 行组随 C6 / serve-gateway)。
5
5
  #
6
6
  # 行位规则(overview「行投放分类」真源):自有插件行 → bundle host 行(agent 平面行,
7
7
  # 四链恒挂;explore 面差异靠 subagent toolFilter 不靠行差分);同 id 覆盖行携带 name
@@ -9,7 +9,8 @@
9
9
  #
10
10
  # 禁用行组(同 id 覆盖,disabled 字段替换;未命中目标 warn + skip——acp / headless 链上
11
11
  # tool-web 等行缺席属预期,冗余禁用 = 两形态一致纪律,决策:web-tools-layered-disable):
12
- # plan-mode(guidance 单源 = 权限说明 section——plan-mode-mount-exclusion,两形态统一禁用)
12
+ # plan-mode(host 行统一禁用;官方 web/server standard/ptc/cordis preset 子行仍挂载
13
+ # ——P1 full 接受,见 plan-mode-mount-exclusion Revisions)
13
14
  # DeepSeek 专有行族:deepseek-llm-api-extensions / deepseek-account / session-log-deepseek /
14
15
  # session-telemetry-otel(数据外发)/ web-search-deepseek / web-deepseek-api
15
16
  # (0.2.1 新增 DeepSeek Search/Fetch API 行——专有族同纪律禁用)
@@ -18,10 +19,10 @@
18
19
  # 服务行 id;官方 adapter 占用 deepseek-official 路由锁死 id + catalog 双源 + 凭据三
19
20
  # 故事,禁后 LLM 栈单源 tboxcode-llm、id 释放,决策:llm-deepseek-rows-disable)
20
21
  # + 专有服务的消费者行:plugin-package-inventory-deepseek(官方请求附 dsh_plugin_packages
21
- # 插件包清单遥测,注入通道 deepseekLlmApiExtensions 已禁)/ account-controller(账号页
22
- # RPC,依赖 deepseekAccount 已禁;行住 web-app 层——acp/headless 链无此行 skip 属预期,
23
- # tool-web 同形态)——服务方禁用后消费者永久 pending,一并收编消启动告警(决策:
24
- # pending-consumer-rows-disable)
22
+ # 插件包清单遥测,注入通道 deepseekLlmApiExtensions 已禁)——服务方禁用后消费者永久
23
+ # pending,一并收编消启动告警(决策:pending-consumer-rows-disable)。
24
+ # 注:account-controller 消费者行上游 0.2.2-rc.3 已整体移除(账号面改 ui-settings-account /
25
+ # ui-account-notifications 客户端行,不注入 deepseekAccount),对应禁用行随之删除。
25
26
  # tool-web 整行(tboxcode 层唯一 web 工具 = 本仓 webfetch 移植版,双工具与提示词段落随行消失
26
27
  # ——宿主层面;preset 会话经官方树内 tool-web 行不受此禁影响,default 组合后果见
27
28
  # preset-mode-decoupling)
@@ -38,8 +39,7 @@
38
39
  # 注:agent-instructions 不在禁用组(原生采纳——agent-instructions-native-adoption;web/server
39
40
  # 链由 presets 树重建行接管,acp/headless 走 base 挂载行)。
40
41
  # 注:persona 无禁用行——persona 无 host 行(base / web-app 均无),只活 preset 树内;
41
- # identity 单点化 = 双树删行 + system-prompt 覆盖行(上方),dsh 内建 preset 树的
42
- # persona 行属 dsh 内建面不动(reminders-plugin-dissolution 实施校准)。
42
+ # 默认身份 = DSH app bundle 部署 persona;本 bundle 不覆盖 system-prompt。
43
43
  - id: plan-mode
44
44
  disabled: true
45
45
  - id: deepseek-llm-api-extensions
@@ -52,8 +52,6 @@
52
52
  disabled: true
53
53
  - id: plugin-package-inventory-deepseek
54
54
  disabled: true
55
- - id: account-controller
56
- disabled: true
57
55
  - id: session-log-deepseek
58
56
  disabled: true
59
57
  - id: session-telemetry-otel
@@ -73,7 +71,7 @@
73
71
  disabled: false
74
72
 
75
73
  # ── 新增行组(insert 语义——裸行 = 覆盖语义会 not found,新增行必须包 insert 块;
76
- # persona-identity 与 skill-filesystem 是覆盖行保持裸行)──
74
+ # skill-filesystem 是覆盖行保持裸行)──
77
75
  - insert:
78
76
  # ── llm 行组(host 服务行;零 config——插件零 Config 导出纪律,C2)──
79
77
  - id: tboxcode-llm
@@ -99,11 +97,16 @@
99
97
  - id: tboxcode-auto-commit
100
98
  name: '@tbox.cn/tboxcode-dsh-tools/auto-commit'
101
99
 
102
- # ── prompts 行组(C6:七 section + 三 context + 重排器 + complete 整接管;
103
- # systemPrompt / rules 翻译域经行 config 注入)──
100
+ # ── prompts 行组(native-prompt-reset:只保留 permission + scratch 两条
101
+ # 产品 context;七 section / complete / 重排器已退役)──
104
102
  - id: tboxcode-prompts
105
103
  name: '@tbox.cn/tboxcode-dsh-bundle/prompts'
106
104
 
105
+ # ── identity 行组(自读 config.jsonc 的 identity 域;agent-scoped 覆盖
106
+ # preset/deployment persona;默认不配置即 no-op)──
107
+ - id: tboxcode-identity
108
+ name: '@tbox.cn/tboxcode-dsh-bundle/identity'
109
+
107
110
  # ── 收敛环(C8:config 结构级热载——watcher 触发翻译比对、session/event
108
111
  # open-turn 门、profileContext.overlays 原位更新 + reconcile;零 config——
109
112
  # configDir 走 env 探测点)──
@@ -115,16 +118,6 @@
115
118
  - id: tboxcode-image-source
116
119
  name: '@tbox.cn/tboxcode-dsh-bundle/image-source'
117
120
 
118
- # ── persona-identity 单点化(同 id 覆盖 dsh-base system-prompt 服务行;
119
- # decisions:reminders-plugin-dissolution——品牌串纯静态零插值,{{model}} 退出 prompt
120
- # 改由 tboxcode:model context 承载〔C6〕;includeHarnessIdentity 关闭 harness 身份段;
121
- # personaSuffix 键不出现 → schema 默认空串生效)──
122
- - id: system-prompt
123
- name: '@deepseek-ai/dsh-system-prompt'
124
- config:
125
- personaPrefix: You are a coding agent, running inside tboxcode.
126
- includeHarnessIdentity: false
127
-
128
121
  # ── 补挂行组:host skill-filesystem 启用行(server 形态生态融合义务——web 基座
129
122
  # host 层禁用〔provider 注册进 preset 层〕,本行重开 global 层挂载;skill-filesystem
130
123
  # 为分层 provider 设计〔host global 层 + preset 层共存〕,与 presets 树行不冲突;
@@ -0,0 +1,9 @@
1
+ import { Context } from "@deepseek-ai/cordis";
2
+
3
+ //#region src/identity.d.ts
4
+
5
+ declare const name = "tboxcode-identity";
6
+ declare const inject: never[];
7
+ declare function apply(ctx: Context): void;
8
+ //#endregion
9
+ export { apply, inject, name };
@@ -0,0 +1,113 @@
1
+ import { loadConfig, resolveConfigDir } from "@tbox.cn/tboxcode-dsh-runtime";
2
+
3
+ //#region src/identity.ts
4
+ const name = "tboxcode-identity";
5
+ const inject = [];
6
+ const PERSONA_SECTION = "deployment:persona-prefix";
7
+ const HARNESS_SECTION = "harness:identity";
8
+ const MAX_PERSONA_CHARS = 16384;
9
+ function loggerOf(ctx) {
10
+ const logger = ctx.logger;
11
+ if (logger !== void 0) return logger;
12
+ return { warn: (message, ...args) => console.warn(message, ...args) };
13
+ }
14
+ function parseIdentity(raw, warn) {
15
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
16
+ warn("[tboxcode-identity] config.identity 必须是对象;已忽略");
17
+ return;
18
+ }
19
+ const obj = raw;
20
+ const unknownKeys = Object.keys(obj).filter((k) => k !== "persona" && k !== "suppress_harness" && k !== "interpolate");
21
+ if (unknownKeys.length > 0) warn(`[tboxcode-identity] config.identity 未知键被忽略:${unknownKeys.join(", ")}`);
22
+ const rawPersona = obj["persona"];
23
+ if (rawPersona !== void 0 && typeof rawPersona !== "string") {
24
+ warn("[tboxcode-identity] config.identity.persona 必须是字符串;已忽略");
25
+ return;
26
+ }
27
+ if (typeof rawPersona === "string" && rawPersona.length > MAX_PERSONA_CHARS) {
28
+ warn(`[tboxcode-identity] config.identity.persona 超过 ${MAX_PERSONA_CHARS} 字符;已忽略`);
29
+ return;
30
+ }
31
+ const rawSuppress = obj["suppress_harness"];
32
+ if (rawSuppress !== void 0 && typeof rawSuppress !== "boolean") {
33
+ warn("[tboxcode-identity] config.identity.suppress_harness 必须是布尔值;已忽略");
34
+ return;
35
+ }
36
+ const rawInterpolate = obj["interpolate"];
37
+ if (rawInterpolate !== void 0 && typeof rawInterpolate !== "boolean") {
38
+ warn("[tboxcode-identity] config.identity.interpolate 必须是布尔值;已忽略");
39
+ return;
40
+ }
41
+ return {
42
+ persona: typeof rawPersona === "string" ? rawPersona : void 0,
43
+ suppressHarness: rawSuppress === true,
44
+ interpolate: rawInterpolate === true
45
+ };
46
+ }
47
+ function readIdentity(warn) {
48
+ let config;
49
+ try {
50
+ config = loadConfig(resolveConfigDir()).config;
51
+ } catch (error) {
52
+ warn(`[tboxcode-identity] config.jsonc 读取失败;身份覆盖已忽略:${error instanceof Error ? error.message : String(error)}`);
53
+ return;
54
+ }
55
+ const raw = config["identity"];
56
+ if (raw === void 0) return void 0;
57
+ return parseIdentity(raw, warn);
58
+ }
59
+ function isSubagent(agent) {
60
+ const header = agent.session?.header;
61
+ return header?.origin === "subagent" || header?.parentSession !== void 0;
62
+ }
63
+ function apply(ctx) {
64
+ const logger = loggerOf(ctx);
65
+ let warned = false;
66
+ const warnOnce = (message) => {
67
+ if (warned) return;
68
+ warned = true;
69
+ logger.warn(message);
70
+ };
71
+ const onAgentCreated = ({ agent }) => {
72
+ if (isSubagent(agent)) return;
73
+ const identity = readIdentity(warnOnce);
74
+ if (identity === void 0) return;
75
+ const hasPersona = identity.persona !== void 0 && identity.persona.length > 0;
76
+ if (!hasPersona && !identity.suppressHarness) return;
77
+ const agentCtx = agent.ctx;
78
+ const sp = agentCtx?.get?.("systemPrompt");
79
+ if (sp === void 0 || agentCtx?.effect === void 0) return;
80
+ try {
81
+ agentCtx.effect(() => {
82
+ const disposers = [];
83
+ const cleanup = () => {
84
+ for (const dispose of disposers.reverse()) dispose();
85
+ };
86
+ try {
87
+ if (hasPersona) disposers.push(sp.section({
88
+ name: PERSONA_SECTION,
89
+ order: sp.getSectionOrder("DEPLOYMENT_PERSONA_PREFIX"),
90
+ text: identity.persona,
91
+ ...identity.interpolate ? {} : { interpolate: false }
92
+ }));
93
+ if (identity.suppressHarness) disposers.push(sp.section({
94
+ name: HARNESS_SECTION,
95
+ order: sp.getSectionOrder("HARNESS_IDENTITY"),
96
+ text: "",
97
+ interpolate: false
98
+ }));
99
+ return cleanup;
100
+ } catch (error) {
101
+ cleanup();
102
+ throw error;
103
+ }
104
+ }, "tboxcode-identity.sections");
105
+ } catch (error) {
106
+ warnOnce(`[tboxcode-identity] 身份注册失败:${error instanceof Error ? error.message : String(error)}`);
107
+ }
108
+ };
109
+ ctx.on?.call(ctx, "agent/created", onAgentCreated);
110
+ }
111
+
112
+ //#endregion
113
+ export { apply, inject, name };
package/lib/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { a as createConvergenceCore, i as ConvergenceState, n as ConvergenceIO, o as rowsEqual, r as ConvergenceRow, t as ConvergenceCore } from "./convergence-core-B81Z55Bq.js";
2
2
  import { r as name, t as apply } from "./convergence-Bb__S8RE.js";
3
3
  import { a as SweepResult, l as sweepSessions, n as RetentionKnobs, o as isOwnedHome, r as RetentionScheduler, s as startRetentionScheduler, t as DEFAULT_KNOBS } from "./retention-f1rAWNdl.js";
4
- import { S as handleSkillsUserInvocable, T as name$1, _ as handleMode, a as TboxcodeRemoteGateway, b as handleSessionsFlush, d as handleCommit, f as handleDefaultSelection, l as handleCommandsExecute, m as handleHealth, o as TboxcodeRemoteServices, p as handleGitPushWatch, r as GitPushEvent, u as handleCommandsList, v as handleReload, y as handleRetentionRun } from "./remote--pQj9xul.js";
5
- import { a as redactTokens, i as createLogger, n as Logger, t as LogLevel } from "./logger-BIhqLW5C.js";
4
+ import { a as redactTokens, i as createLogger, n as Logger, t as LogLevel } from "./logger-DcHqQwUI.js";
5
+ import { O as name$1, S as handleSessionsFlush, T as handleSkillsUserInvocable, b as handleRetentionRun, d as handleCommandsList, f as handleCommit, h as handleHealth, m as handleGitPushWatch, o as TboxcodeRemoteGateway, p as handleDefaultSelection, r as GitPushEvent, s as TboxcodeRemoteServices, u as handleCommandsExecute, v as handleMode, y as handleReload } from "./remote-Cw_L6bz7.js";
6
6
 
7
7
  //#region src/index.d.ts
8
8
  /**
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { n as rowsEqual, t as createConvergenceCore } from "./convergence-core-C
2
2
  import { r as name, t as apply } from "./convergence-BnrNjcuS.js";
3
3
  import { a as sweepSessions, n as isOwnedHome, r as startRetentionScheduler, t as DEFAULT_KNOBS } from "./retention-CVHXhi92.js";
4
4
  import { n as redactTokens, t as createLogger } from "./logger-Dnz11jWP.js";
5
- import { _ as handleSkillsUserInvocable, a as handleCommandsList, b as name$1, c as handleGitPushWatch, f as handleMode, h as handleSessionsFlush, i as handleCommandsExecute, l as handleHealth, m as handleRetentionRun, o as handleCommit, p as handleReload, s as handleDefaultSelection, t as TboxcodeRemoteGateway } from "./remote-Cr46ZKbO.js";
5
+ import { S as name$1, a as handleCommandsList, c as handleGitPushWatch, f as handleMode, g as handleSessionsFlush, i as handleCommandsExecute, l as handleHealth, m as handleRetentionRun, o as handleCommit, p as handleReload, s as handleDefaultSelection, t as TboxcodeRemoteGateway, y as handleSkillsUserInvocable } from "./remote-BocZwlS-.js";
6
6
 
7
7
  //#region src/index.ts
8
8
  /**
package/lib/logger.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as redactTokens, i as createLogger, n as Logger, r as LoggerOptions, t as LogLevel } from "./logger-BIhqLW5C.js";
1
+ import { a as redactTokens, i as createLogger, n as Logger, r as LoggerOptions, t as LogLevel } from "./logger-DcHqQwUI.js";
2
2
  export { LogLevel, Logger, LoggerOptions, createLogger, redactTokens };
package/lib/prompts.d.ts CHANGED
@@ -3,27 +3,10 @@ import { Context } from "@deepseek-ai/cordis";
3
3
  //#region src/prompts.d.ts
4
4
  declare const name = "tboxcode-prompts";
5
5
  declare const inject: never[];
6
- interface Config {
7
- /** `system_prompt` 翻译域:字面文本或 `file://` 路径——在场即 complete 整接管。 */
8
- systemPrompt?: string;
9
- /** `rules` 翻译域:用户规则条目(追加用户规则 section)。 */
10
- rules?: string[];
11
- }
12
- /** 白名单二值(reminders-plugin-dissolution 定案):真实用户输入语义。 */
13
- declare const USER_VOICE_KINDS: ReadonlySet<string>;
14
- /** plan 档权限说明文案(composition note 引导层;build 档空串不渲染)。 */
6
+ /** plan 档权限说明文案(build 档空串不渲染)。 */
15
7
  declare function renderPermissionContext(mode: string, scratchDir: string): string;
16
- /**
17
- * scratch 根声明 context(model-context design 清单新增行;紧贴
18
- * WORKING_DIRECTORY(100) 与 SANDBOX_POLICY(110) 之间形成 cwd 对照)。
19
- * scratch_* 相对路径与 workdir 都解析到该目录——`working_directory` / cd
20
- * 只影响常规工具(模型 cwd 认知第二层信号)。
21
- */
8
+ /** scratch 根声明 context:只补会话动态根路径;创建/路径规则归工具描述。 */
22
9
  declare function renderScratchContext(scratchDir: string): string;
23
- /** environment 三行(基线 env-static + env-git 精确并集;现算不 memoize)。
24
- * Working directory 行退役——dsh 0.2.1 原生 working-directory 服务注入
25
- * `Current working directory: "<path>".`(同信息超集 + 工具联动,subagent-native-adoption)。 */
26
- declare function renderEnvironmentContext(cwd: string): string;
27
- declare function apply(ctx: Context, config?: Config): () => void;
10
+ declare function apply(ctx: Context): void;
28
11
  //#endregion
29
- export { Config, USER_VOICE_KINDS, apply, inject, name, renderEnvironmentContext, renderPermissionContext, renderScratchContext };
12
+ export { apply, inject, name, renderPermissionContext, renderScratchContext };
package/lib/prompts.js CHANGED
@@ -1,227 +1,36 @@
1
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
1
+ import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { resolveConfigDir, stripJsonc } from "@tbox.cn/tboxcode-dsh-runtime";
4
- import { homedir, platform, tmpdir } from "node:os";
5
- import { z } from "zod";
3
+ import { resolveConfigDir } from "@tbox.cn/tboxcode-dsh-runtime";
4
+ import { tmpdir } from "node:os";
6
5
 
7
6
  //#region src/prompts.ts
8
7
  const name = "tboxcode-prompts";
9
8
  const inject = [];
10
- const ConfigSchema = z.object({
11
- systemPrompt: z.string().optional(),
12
- rules: z.array(z.string()).optional()
13
- });
14
9
  const SCRATCH_ROOT = join(tmpdir(), "tboxcode-scratch");
15
10
  function scratchDirFor(sessionId) {
16
11
  return join(SCRATCH_ROOT, sessionId);
17
12
  }
18
- const TONE_OBJECTIVITY = `# 语气与风格
19
-
20
- - 除非你确信 URL 是用于帮助用户编程的,否则绝不要为用户生成或猜测 URL。可以使用用户消息或本地文件中提供的 URL
21
- - 保持简洁、直接、切中要点。执行复杂或会对系统产生影响的 bash 命令时,应解释命令的作用和运行原因
22
- - 输出将显示在命令行界面,可使用 GitHub 风格的 Markdown 进行格式化,以等宽字体显示
23
- - 仅使用文本来与用户沟通;工具之外的所有输出都会显示给用户。仅使用工具完成任务,不要在会话期间使用 bash 或代码注释来与用户沟通
24
- - 如果无法或不愿帮助用户完成某件事,请不要解释原因,因为这会显得说教和烦人。请提供有用的替代方案,否则保持回复在 1-2 句话
25
- - 仅在用户明确要求时使用 emoji,除非被要求,否则避免在所有沟通中使用 emoji
26
- - 不要添加不必要的开场白或结尾(如解释代码或总结操作),除非用户要求
27
-
28
- # 客观专业
29
-
30
- 优先考虑技术准确性和真实性,而不是迎合用户的观点。专注于事实和问题解决,提供直接、客观的技术信息,不带不必要的赞美或情感认同。百宝箱应该对所有观点都应用同样严格的标准,必要时敢于提出异议。客观的指导和礼貌的纠正比虚假的认同更有价值。当存在不确定性时,最好先调查寻找真相,而不是下意识地迎合用户的想法。`;
31
- const TASK_EXECUTION = `# 执行任务
32
-
33
- 用户主要会要求你执行软件工程任务,包括解决 bug、添加新功能、重构代码、解释代码等。对于这些任务,建议遵循以下步骤:
34
-
35
- - 使用可用的搜索工具理解代码库和用户查询。建议灵活地并行或顺序使用搜索工具
36
- - 使用 todowrite tool 规划任务(如需要)
37
- - 使用所有可用工具实现解决方案
38
- - 尽可能通过测试验证解决方案。不要假设特定的测试框架或脚本。检查 README 或搜索代码库确定测试方法
39
- - 完成任务后,必须运行 lint 和类型检查命令(如 npm run lint、npm run typecheck、ruff 等)确保代码正确。如果找不到正确的命令,询问用户提供命令,如果他们提供了,建议将其写入 AGENTS.md 以便下次知道要运行什么
40
- - 除非用户明确要求,否则绝不要提交更改。只有在明确要求时才提交,否则用户会认为你过于自作主张
41
-
42
- 工具结果和用户消息可能包含 <system-reminder> 标签。这些标签包含有用的信息和提醒,由系统自动添加,不代表特定的工具结果或用户消息的内容。
43
-
44
- # 主动性
45
-
46
- 你可以主动采取行动,但仅在用户要求你做某事时。你应该努力在以下之间取得平衡:
47
-
48
- 1. 被要求时做正确的事,包括采取行动和后续行动
49
- 2. 不要在用户未询问的情况下做出令其惊讶的行动
50
- 例如,如果用户问你如何处理某事,你应该先尽力回答他们的问题,而不是立即跳入采取行动
51
- 3. 除非用户要求,否则不要添加额外的代码解释总结。处理完文件后直接停止即可,不要额外解释你做了什么
52
-
53
- # 遵循约定
54
-
55
- 修改文件前,先了解该文件的代码规范。模仿代码风格,使用现有库和工具,遵循现有模式。
56
-
57
- - 编写使用某个库或框架的代码时,首先检查代码库是否已使用该库。例如,查看相邻文件或检查 package.json(或 cargo.toml 等,取决于语言)
58
- - 创建新组件时,首先查看现有组件的写法;然后考虑框架选择、命名约定、类型等
59
- - 编辑代码时,首先查看代码的周围上下文(特别是导入)以了解代码使用的框架和库。然后考虑如何以最符合项目风格的方式进行更改
60
- - 始终遵循安全最佳实践。绝不要编写会泄露或记录密钥和凭据的代码。绝不要将密钥或凭据提交到仓库`;
61
- const TOOL_DISCIPLINE = `# 工具使用纪律
62
-
63
- - 尽可能使用专用工具替代 bash 命令,因为这提供更好的用户体验。对于文件操作,使用专用工具:read 读取文件而不是 cat/head/tail,edit 编辑而不是 sed/awk,write 创建文件而不是 cat 加 heredoc 或 echo 重定向。仅在需要 shell 执行的系统命令和终端操作时才使用 bash 工具。绝不要使用 bash echo 或其他命令行工具向用户输出想法、解释或指令。直接在回复文本中输出所有沟通内容
64
- - 你可以在单次响应中调用多个工具。如果你打算调用多个工具且它们之间没有依赖关系,应同时发起所有独立的工具调用。尽量并行调用工具以提高效率。但是,如果某些工具调用需要前一个调用的结果作为参数,不要并行调用,而是顺序调用。例如,如果一个操作必须在另一个操作之前完成,请顺序运行这些操作。绝不要在工具调用中使用占位符或猜测缺失参数
65
- - 如果用户指定他们希望你"并行"运行工具,你必须在单条消息中发送包含多个工具调用的请求
66
- - webfetch 会自动跟随 HTTP 重定向和 JS 页面跳转(最多 3 跳)
67
- - 临时验证与一次性产物使用 scratch_bash / scratch_write / scratch_edit:它们以系统临时目录为根(相对路径与 scratch_bash 的工作目录都解析到那里);其他工具以当前工作目录为根;不要在工作区内创建临时目录
68
- - 用户消息以斜杠命令开头时,先使用 skill 工具加载对应技能(若尚未加载);如需读取 skill 目录内其他文件,以 \`<skill_location>\` 中 SKILL.md 所在目录为基础目录`;
69
- const DELEGATION = `# 委派纪律
70
-
71
- - 对明确文件、函数、类或关键词的精确查询,直接使用 read、glob、grep 等专用工具;需要跨文件或跨模块的开放式查找与信息收集时,再使用 subagent 委派
72
- - subagent 工具用于创建子代理执行委派任务。子代理上下文独立,看不到当前对话和你已掌握的信息,执行中也无法与你或用户交互,且不可再创建子代理(委派深度已到上限,收到深度提示后亲自完成)。委派前用一个统一标准判断:拿到返回结果后,你能否不重做这项任务就核实其正确性与完整性
73
- - 能核实的可以委派:信息收集(查找文件、定位符号与调用点、收集指定事实)与方案已定的变更(你已写明改哪里、怎么改、怎么算完成)
74
- - 核实即重做的必须亲自完成:判断、结论与设计类产出(哪里有问题、原因是什么、方案怎么定),逐条检查只能验证其报出的内容,确认没有遗漏唯有自己重做,委派它等于放弃质量控制
75
- - 你对交付的每个结论和改动负全责。子代理的输出是供你使用的工作材料,不是可直接转交的成品:采信其发现前对照实际代码核实,接受其改动前按既定规格核查
76
- - 任务规模与上下文压力不改变上述划分:大任务拆小后产出若仍是判断(如按模块拆分的评审、排查),依然不可委派;正确做法是你分轮亲自完成判断部分,把其中可核实的查找、收集与照规格执行环节剥离出来委派
77
- - 每次委派只包含一个目标明确、范围有限的子任务,说明目标、范围和期望输出,要求达成后立即返回、不自行扩展范围;互不依赖的委派并行执行,汇总并核实结果后再推进下一轮
78
-
79
- <example>
80
- user: 客户端的错误在哪里处理?
81
- assistant: [这是跨模块的开放式探索,委派 subagent 调查]
82
- </example>
83
- <example>
84
- user: getUserById 函数定义在哪里?
85
- assistant: [明确的函数名查询,直接使用 grep 搜索定义即可]
86
- </example>
87
- <example>
88
- user: 深入评审 commit abc1234 以来的所有变更
89
- assistant: [评审的产出是判断:不重做评审就无法确认子代理的结论没有遗漏,必须亲自完成——运行 git log/diff 查看变更、read 相关文件并逐一分析,变更量大时分轮进行;其中可核实的子任务剥离出来委派,如"列出 FooService.create 的所有调用点"]
90
- </example>`;
91
- const CODE_REFERENCES = `# 代码引用
92
-
93
- 引用特定函数或代码片段时,使用 \`file_path:line_number\` 格式,以便用户轻松导航到源代码位置。
94
-
95
- <example>
96
- user: 客户端的错误在哪里处理?
97
- assistant: 客户端连接在 \`connectToServer\` 函数中被标记为失败,位于 src/services/process.ts:712。
98
- </example>`;
99
- const TODO_SECTION = `# 任务管理
100
-
101
- 你可以使用 todowrite tool 来管理和规划任务。经常使用这些工具来跟踪任务进度,并让用户了解你的进展。
102
-
103
- 这些工具对于规划任务和将复杂的大型任务分解为更小的步骤也非常有用。如果在规划时不使用这个工具,你可能会忘记做重要的任务——这是不可接受的。
104
-
105
- 关键的是,完成任务后应立即将 todo 标记为已完成。不要攒着多个任务一起标记完成。
106
-
107
- 示例:
108
-
109
- <example>
110
- user: 运行构建并修复所有类型错误
111
- assistant: 我将使用 todowrite tool 写入以下 todo 列表:
112
- - 运行构建
113
- - 修复所有类型错误
114
-
115
- 现在我将使用 bash 运行构建。
116
-
117
- 看起来我发现了 10 个类型错误。我将使用 todowrite tool 写入 10 个 todo。
118
-
119
- 将第一个 todo 标记为 in_progress
120
-
121
- 让我从修复第一个开始...
122
-
123
- 第一个已修复,将其标记为 completed,然后继续第二个...
124
- </example>
125
- 在上面的示例中,助手完成了所有任务,包括 10 个错误修复以及运行构建。
126
-
127
- 重要:在对话中始终使用 todowrite tool 来规划和跟踪任务。`;
128
- const SECTION_ORDERS_TBOX = {
129
- TONE_OBJECTIVITY: 100,
130
- TASK_EXECUTION: 150,
131
- TOOL_DISCIPLINE: 200,
132
- DELEGATION: 250,
133
- CODE_REFERENCES: 300,
134
- TODO_MANAGEMENT: 350,
135
- USER_RULES: 400
136
- };
137
- /** 白名单二值(reminders-plugin-dissolution 定案):真实用户输入语义。 */
138
- const USER_VOICE_KINDS = new Set(["user", "user-question-reply"]);
139
- /** plan 档权限说明文案(composition note 引导层;build 档空串不渲染)。 */
13
+ /** plan 档权限说明文案(build 档空串不渲染)。 */
140
14
  function renderPermissionContext(mode, scratchDir) {
141
15
  if (mode !== "read-only") return "";
142
16
  return [
143
17
  "# 权限模式:plan(只读)",
144
18
  "",
145
- `- 当前处于只读模式:文件写入与变更类 bash 命令会被内核拒绝(含系统临时目录)。`,
146
- `- 需要临时验证(运行脚本、检查依赖、生成一次性产物)时,使用 scratch_bash / scratch_write / scratch_edit 三件工具——它们在会话私有的临时目录 \`${scratchDir}\` 中放行,相对路径也按该目录解析。产物的绝对路径即可直接引用。`,
147
- `- 临时验证限于环境已有的依赖;不要尝试安装依赖(缓存目录写入会被拒绝)。`,
148
- `- webfetch 与 curl 不得发起对目标系统有写入效果的调用。`,
149
- `- 对项目的一切修改请写入计划,切回 build 模式后执行。`
19
+ "- 当前处于只读模式:文件写入与变更类 bash 命令会被内核拒绝(含系统临时目录)。",
20
+ `- 临时验证使用 scratch_bash / scratch_write / scratch_edit;它们在 \`${scratchDir}\` 放行,相对路径按该目录解析。`,
21
+ "- 对项目的一切修改请写入计划,切回 build 模式后执行。"
150
22
  ].join("\n");
151
23
  }
152
- /**
153
- * scratch 根声明 context(model-context design 清单新增行;紧贴
154
- * WORKING_DIRECTORY(100) 与 SANDBOX_POLICY(110) 之间形成 cwd 对照)。
155
- * scratch_* 相对路径与 workdir 都解析到该目录——`working_directory` / cd
156
- * 只影响常规工具(模型 cwd 认知第二层信号)。
157
- */
24
+ /** scratch 根声明 context:只补会话动态根路径;创建/路径规则归工具描述。 */
158
25
  function renderScratchContext(scratchDir) {
159
- return [
160
- `Scratch directory (system temp; the root for scratch_bash / scratch_write / scratch_edit): "${scratchDir}"`,
161
- `- scratch_* tools create this directory on first use; never pass it as an output file target,`,
162
- ` even from regular bash — write to a file path inside it.`,
163
- `- scratch_* tools resolve relative paths and run with this directory as their working directory.`,
164
- `- Regular tools (bash, read, write, edit, glob, grep) use the current working directory; working_directory / cd changes it for regular tools only, never for the scratch root.`,
165
- `- Use scratch_* for throwaway scripts and one-off artifacts; do not create temporary directories inside the workspace.`
166
- ].join("\n");
26
+ return `Scratch directory (session-private; scratch_* relative paths resolve here): "${scratchDir}".`;
167
27
  }
168
- /** environment 三行(基线 env-static + env-git 精确并集;现算不 memoize)。
169
- * Working directory 行退役——dsh 0.2.1 原生 working-directory 服务注入
170
- * `Current working directory: "<path>".`(同信息超集 + 工具联动,subagent-native-adoption)。 */
171
- function renderEnvironmentContext(cwd) {
172
- const gitState = existsSync(join(cwd, ".git")) ? "yes" : "no";
173
- return [
174
- `Platform: ${platform()}`,
175
- `Workspace root folder: ${cwd}`,
176
- `Is directory a git repo: ${gitState}`
177
- ].join("\n");
178
- }
179
- function apply(ctx, config = {}) {
180
- const parsed = ConfigSchema.parse(config);
181
- const rulesCache = /* @__PURE__ */ new Map();
182
- const userRulesText = (scopeKey) => {
183
- const cacheKey = String(scopeKey ?? "global");
184
- if (rulesCache.has(cacheKey)) return rulesCache.get(cacheKey);
185
- const lines = [];
186
- for (const rule of parsed.rules ?? []) lines.push(`- ${rule}`);
187
- try {
188
- const rulesDir = join(resolveConfigDir(), "rules");
189
- if (existsSync(rulesDir)) for (const entry of readdirSync(rulesDir).sort()) {
190
- const fp = join(rulesDir, entry);
191
- if (statSync(fp).isFile()) lines.push(`- ${stripJsonc(readFileSync(fp, "utf-8")).trim()}`);
192
- }
193
- } catch {}
194
- const text = lines.length > 0 ? `# 用户规则\n\n${lines.join("\n")}` : "";
195
- rulesCache.set(cacheKey, text);
196
- return text;
197
- };
198
- const completeText = () => {
199
- const raw = parsed.systemPrompt;
200
- if (raw === void 0) return void 0;
201
- if (raw.startsWith("file://")) {
202
- const fp = raw.slice(7).replace(/^~(?=\/|$)/, homedir());
203
- return existsSync(fp) ? readFileSync(fp, "utf-8") : void 0;
204
- }
205
- return raw;
206
- };
207
- const preStepHandler = async (payload, next) => {
208
- const decision = await next();
209
- if (decision.kind !== "enter") return decision;
210
- const messages = decision.messages ?? [];
211
- if (messages.some((m) => typeof m?.source?.kind !== "string")) return decision;
212
- if (!messages.some((m) => USER_VOICE_KINDS.has(m.source.kind))) return decision;
213
- const users = messages.filter((m) => USER_VOICE_KINDS.has(m.source.kind));
214
- return {
215
- kind: "enter",
216
- messages: [...messages.filter((m) => !USER_VOICE_KINDS.has(m.source.kind)), ...users],
217
- ...decision.startsRequestSeries !== void 0 ? { startsRequestSeries: decision.startsRequestSeries } : {}
218
- };
219
- };
220
- ctx.on("agent/pre-step", preStepHandler, { prepend: true });
28
+ function apply(ctx) {
29
+ const rulesDir = join(resolveConfigDir(), "rules");
30
+ if (existsSync(rulesDir)) console.warn(`[tboxcode-prompts] ${rulesDir} 已不再读取(用户规则迁移到 $DSH_HOME/AGENTS.md 或项目 AGENTS.md)`);
221
31
  ctx.inject(["systemPrompt"], (scope) => {
222
32
  const sp = scope.systemPrompt;
223
33
  const scopeGet = scope.get;
224
- const tools = scopeGet?.call(scope, "tools") ?? void 0;
225
34
  const sandboxModeOf = (c) => {
226
35
  const session = c.agent?.session;
227
36
  if (session === void 0) return void 0;
@@ -233,50 +42,6 @@ function apply(ctx, config = {}) {
233
42
  return;
234
43
  }
235
44
  };
236
- for (const s of [
237
- {
238
- name: "tboxcode:tone-objectivity",
239
- order: SECTION_ORDERS_TBOX.TONE_OBJECTIVITY,
240
- text: TONE_OBJECTIVITY
241
- },
242
- {
243
- name: "tboxcode:task-execution",
244
- order: SECTION_ORDERS_TBOX.TASK_EXECUTION,
245
- text: TASK_EXECUTION
246
- },
247
- {
248
- name: "tboxcode:tool-discipline",
249
- order: SECTION_ORDERS_TBOX.TOOL_DISCIPLINE,
250
- text: TOOL_DISCIPLINE
251
- },
252
- {
253
- name: "tboxcode:delegation",
254
- order: SECTION_ORDERS_TBOX.DELEGATION,
255
- text: DELEGATION
256
- },
257
- {
258
- name: "tboxcode:code-references",
259
- order: SECTION_ORDERS_TBOX.CODE_REFERENCES,
260
- text: CODE_REFERENCES
261
- }
262
- ]) sp.section(s);
263
- sp.section({
264
- name: "tboxcode:todo-management",
265
- order: SECTION_ORDERS_TBOX.TODO_MANAGEMENT,
266
- text: (c) => tools !== void 0 && tools.schemas(c.scope).some((t) => t.name === "todo_write") ? TODO_SECTION : ""
267
- });
268
- sp.section({
269
- name: "tboxcode:user-rules",
270
- order: SECTION_ORDERS_TBOX.USER_RULES,
271
- text: (c) => userRulesText(c.scope)
272
- });
273
- const complete = completeText();
274
- if (complete !== void 0) sp.section({
275
- name: "tboxcode:complete",
276
- order: SECTION_ORDERS_TBOX.USER_RULES + 50,
277
- text: complete,
278
- complete: true
279
- });
280
45
  const sandboxOrder = sp.getContextOrder("SANDBOX_POLICY");
281
46
  sp.context({
282
47
  name: "tboxcode:permission",
@@ -296,28 +61,8 @@ function apply(ctx, config = {}) {
296
61
  return renderScratchContext(scratchDirFor(sessionId));
297
62
  }
298
63
  });
299
- sp.context({
300
- name: "tboxcode:model",
301
- order: sandboxOrder - 5,
302
- text: (c) => {
303
- if (c.agent === void 0) return "";
304
- const sel = (scope.get?.("agentDefaultModel"))?.currentSelection?.();
305
- if (sel?.provider === void 0 || sel?.model === void 0) return "";
306
- return `Current model: ${sel.provider}/${sel.model}`;
307
- }
308
- });
309
- sp.context({
310
- name: "tboxcode:environment",
311
- order: sandboxOrder - 10,
312
- text: (c) => {
313
- const cwd = c.agent?.session?.header?.cwd;
314
- if (c.agent === void 0 || cwd === void 0) return "";
315
- return renderEnvironmentContext(cwd);
316
- }
317
- });
318
64
  });
319
- return () => {};
320
65
  }
321
66
 
322
67
  //#endregion
323
- export { USER_VOICE_KINDS, apply, inject, name, renderEnvironmentContext, renderPermissionContext, renderScratchContext };
68
+ export { apply, inject, name, renderPermissionContext, renderScratchContext };
@@ -100,6 +100,68 @@ async function handleSessionsStat(services, request) {
100
100
  const found = await services.persistence.stat(request.sessionId);
101
101
  return found === void 0 ? null : { header: found.header };
102
102
  }
103
+ /** Stop 枚举预算:目录读是异步 Session 读,Stop 不该无界等待。 */
104
+ const STOP_ENUM_TIMEOUT_MS = 1e4;
105
+ /**
106
+ * 枚举一棵树的全部后代并逐个 user-authority 软停。
107
+ * 单目标失败记日志后继续(resident 缺席/已结束本身是 no-op);枚举失败上抛,
108
+ * 由调用方决定是否整体失败。
109
+ */
110
+ async function stopDescendants(subagents, sessionId, log) {
111
+ const signal = AbortSignal.timeout(STOP_ENUM_TIMEOUT_MS);
112
+ const seen = /* @__PURE__ */ new Set();
113
+ for (let pass = 0; pass < 2; pass++) {
114
+ const fresh = (await subagents.listDescendants(sessionId, signal)).filter((row) => !seen.has(row.id));
115
+ if (fresh.length === 0) return;
116
+ for (const row of fresh) {
117
+ seen.add(row.id);
118
+ try {
119
+ subagents.interrupt(row.id, { kind: "user" });
120
+ } catch (error) {
121
+ log?.warn(`stop subagent ${row.id} failed for ${sessionId}: ${String(error)}`);
122
+ }
123
+ }
124
+ }
125
+ }
126
+ /**
127
+ * Stop 级联(网关 close/cancel 的 server 侧实现):软停该会话的全部后代,
128
+ * 本地子代理保留驻留与收件箱,外部执行永久停止。
129
+ */
130
+ async function handleSessionsStopSubagents(services, request) {
131
+ const subagents = services.subagents;
132
+ if (subagents === void 0) return {};
133
+ try {
134
+ await stopDescendants(subagents, request.sessionId, services.log);
135
+ } catch (error) {
136
+ services.log?.warn(`enumerate subagents for stop failed (${request.sessionId}): ${String(error)}`);
137
+ throw new RemoteError("tboxcode/stop-failed", `枚举会话 ${request.sessionId} 的 subagent 后代失败:${error instanceof Error ? error.message : String(error)}`, { sessionId: request.sessionId });
138
+ }
139
+ return {};
140
+ }
141
+ /**
142
+ * Close 级联(网关 session/close 的 server 侧实现):释放该会话的全部后代。
143
+ *
144
+ * 冷根(无 live agent)没有可释放的句柄,退化为软停:目录仍可读,running 的后代
145
+ * 至少不会继续耗额度;释放留给下次激活或进程退出。
146
+ */
147
+ async function handleSessionsDrainSubagents(services, request) {
148
+ const subagents = services.subagents;
149
+ if (subagents === void 0) return {};
150
+ const agent = services.agents.get(request.sessionId);
151
+ if (agent === void 0) {
152
+ await stopDescendants(subagents, request.sessionId, services.log).catch((error) => {
153
+ services.log?.warn(`cold-root drain fallback failed (${request.sessionId}): ${String(error)}`);
154
+ });
155
+ return {};
156
+ }
157
+ try {
158
+ await subagents.drainDescendants([agent]);
159
+ } catch (error) {
160
+ services.log?.warn(`drain subagents failed (${request.sessionId}): ${String(error)}`);
161
+ throw new RemoteError("tboxcode/drain-failed", `释放会话 ${request.sessionId} 的 subagent 后代失败:${error instanceof Error ? error.message : String(error)}`, { sessionId: request.sessionId });
162
+ }
163
+ return {};
164
+ }
103
165
  /**
104
166
  * skills/change 转发流(P5-3 定案:skills/change 不在 $events allowlist——
105
167
  * 零上游变更的进程内桥接;payload-free seq 递增,消费方重取 commands.list)。
@@ -315,6 +377,7 @@ var TboxcodeRemoteGateway = class extends TypertRemoteService {
315
377
  });
316
378
  stateOf(this).services = {
317
379
  agents: remoteCtx.agents,
380
+ log: stateOf(this).log,
318
381
  commands: remoteCtx.commands,
319
382
  skills: remoteCtx.skills,
320
383
  approval: remoteCtx.approval,
@@ -322,6 +385,9 @@ var TboxcodeRemoteGateway = class extends TypertRemoteService {
322
385
  sessions: remoteCtx.sessions,
323
386
  ...remoteCtx.get?.("attachments") === void 0 ? {} : { attachments: remoteCtx.get("attachments") },
324
387
  ...remoteCtx.get?.("imageSources") === void 0 ? {} : { imageSources: remoteCtx.get("imageSources") },
388
+ get subagents() {
389
+ return remoteCtx.get?.("subagents");
390
+ },
325
391
  persistence: remoteCtx.sessionPersistence ?? { stat: async () => void 0 },
326
392
  on: (event, listener) => remoteCtx.on(event, listener),
327
393
  sandbox: { setSandboxMode: (session, mode) => setSandboxMode(session, mode) },
@@ -366,6 +432,12 @@ var TboxcodeRemoteGateway = class extends TypertRemoteService {
366
432
  sessionsStat(request) {
367
433
  return handleSessionsStat(stateOf(this).services, request);
368
434
  }
435
+ sessionsStopSubagents(request) {
436
+ return handleSessionsStopSubagents(stateOf(this).services, request);
437
+ }
438
+ sessionsDrainSubagents(request) {
439
+ return handleSessionsDrainSubagents(stateOf(this).services, request);
440
+ }
369
441
  skillsWatch(signal) {
370
442
  return handleSkillsWatch(stateOf(this).services, signal);
371
443
  }
@@ -448,6 +520,16 @@ const REMOTE_METHODS = [
448
520
  method: "sessionsStat",
449
521
  exportName: "sessions.stat"
450
522
  },
523
+ {
524
+ method: "sessionsStopSubagents",
525
+ exportName: "sessions.stopSubagents",
526
+ resources: { session: (request) => request.sessionId }
527
+ },
528
+ {
529
+ method: "sessionsDrainSubagents",
530
+ exportName: "sessions.drainSubagents",
531
+ resources: { session: (request) => request.sessionId }
532
+ },
451
533
  {
452
534
  method: "reload",
453
535
  exportName: "reload"
@@ -465,10 +547,11 @@ Object.defineProperty(TboxcodeRemoteGateway.prototype, REMOTE_METHOD_DESCRIPTOR,
465
547
  configurable: true,
466
548
  value: Object.freeze({
467
549
  version: 1,
468
- methods: Object.freeze(REMOTE_METHODS.map(({ method, exportName, mode }) => Object.freeze({
550
+ methods: Object.freeze(REMOTE_METHODS.map(({ method, exportName, mode, resources }) => Object.freeze({
469
551
  method,
470
552
  ...exportName === method ? {} : { exportName },
471
553
  ...mode === void 0 ? {} : { mode },
554
+ ...resources === void 0 ? {} : { resources },
472
555
  invocation: Object.freeze({ kind: "direct" })
473
556
  })))
474
557
  })
@@ -478,4 +561,4 @@ if (markers.length !== REMOTE_METHODS.length || REMOTE_METHODS.some(({ exportNam
478
561
  var remote_default = TboxcodeRemoteGateway;
479
562
 
480
563
  //#endregion
481
- export { handleSkillsUserInvocable as _, handleCommandsList as a, name as b, handleGitPushWatch as c, handleImagesRead as d, handleMode as f, handleSessionsStat as g, handleSessionsFlush as h, handleCommandsExecute as i, handleHealth as l, handleRetentionRun as m, handleAgentWatch as n, handleCommit as o, handleReload as p, handleAttachmentsAdmit as r, handleDefaultSelection as s, TboxcodeRemoteGateway as t, handleImagesAdmit as u, handleSkillsWatch as v, remote_default as x, inject as y };
564
+ export { remote_default as C, name as S, handleSessionsStat as _, handleCommandsList as a, handleSkillsWatch as b, handleGitPushWatch as c, handleImagesRead as d, handleMode as f, handleSessionsFlush as g, handleSessionsDrainSubagents as h, handleCommandsExecute as i, handleHealth as l, handleRetentionRun as m, handleAgentWatch as n, handleCommit as o, handleReload as p, handleAttachmentsAdmit as r, handleDefaultSelection as s, TboxcodeRemoteGateway as t, handleImagesAdmit as u, handleSessionsStopSubagents as v, inject as x, handleSkillsUserInvocable as y };
@@ -1,5 +1,6 @@
1
1
  import { t as ConvergenceCore } from "./convergence-core-B81Z55Bq.js";
2
2
  import { a as SweepResult, r as RetentionScheduler } from "./retention-f1rAWNdl.js";
3
+ import { n as Logger } from "./logger-DcHqQwUI.js";
3
4
  import { Context } from "@deepseek-ai/cordis";
4
5
  import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
5
6
  import { AutoCommitConfig, AutoCommitOutcome } from "@tbox.cn/tboxcode-dsh-tools";
@@ -21,6 +22,12 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
21
22
  'tboxcode/image-unavailable': {
22
23
  readonly reason?: string;
23
24
  };
25
+ 'tboxcode/stop-failed': {
26
+ readonly sessionId: string;
27
+ };
28
+ 'tboxcode/drain-failed': {
29
+ readonly sessionId: string;
30
+ };
24
31
  }
25
32
  }
26
33
  interface RemoteAgentLike {
@@ -35,6 +42,17 @@ interface DefaultModelSelection {
35
42
  model?: unknown;
36
43
  reasoningEffort?: unknown;
37
44
  }
45
+ /** subagent 服务的最小结构面(不依赖 dsh-subagent 编译域——与载体一同纪律)。 */
46
+ interface SubagentTreeLifecycle {
47
+ listDescendants(rootSessionId: string, signal?: AbortSignal): Promise<ReadonlyArray<{
48
+ readonly kind: 'child' | 'diagnostic';
49
+ readonly id: string;
50
+ }>>;
51
+ interrupt(id: string, authority: {
52
+ readonly kind: 'user';
53
+ }): void;
54
+ drainDescendants(parents: readonly unknown[]): Promise<void>;
55
+ }
38
56
  interface TboxcodeRemoteServices {
39
57
  agents: {
40
58
  get(sessionId: string): (RemoteAgentLike & Record<string, unknown>) | undefined;
@@ -90,6 +108,10 @@ interface TboxcodeRemoteServices {
90
108
  sandbox: {
91
109
  setSandboxMode(session: unknown, mode: unknown): unknown;
92
110
  };
111
+ /** 诊断出口(Stop/Drain 失败观测——services 无 logger 时静默降级)。 */
112
+ log?: Logger;
113
+ /** subagent 树收敛面(Stop 软停 / Close 释放;组合未挂服务时缺席)。 */
114
+ subagents?: SubagentTreeLifecycle;
93
115
  convergence?: ConvergenceCore;
94
116
  retention?: RetentionScheduler;
95
117
  memoryUsage?: () => NodeJS.MemoryUsage;
@@ -157,6 +179,22 @@ declare function handleSessionsStat(services: TboxcodeRemoteServices, request: {
157
179
  }): Promise<{
158
180
  header: Record<string, unknown>;
159
181
  } | null>;
182
+ /**
183
+ * Stop 级联(网关 close/cancel 的 server 侧实现):软停该会话的全部后代,
184
+ * 本地子代理保留驻留与收件箱,外部执行永久停止。
185
+ */
186
+ declare function handleSessionsStopSubagents(services: TboxcodeRemoteServices, request: {
187
+ sessionId: string;
188
+ }): Promise<Record<string, never>>;
189
+ /**
190
+ * Close 级联(网关 session/close 的 server 侧实现):释放该会话的全部后代。
191
+ *
192
+ * 冷根(无 live agent)没有可释放的句柄,退化为软停:目录仍可读,running 的后代
193
+ * 至少不会继续耗额度;释放留给下次激活或进程退出。
194
+ */
195
+ declare function handleSessionsDrainSubagents(services: TboxcodeRemoteServices, request: {
196
+ sessionId: string;
197
+ }): Promise<Record<string, never>>;
160
198
  /**
161
199
  * skills/change 转发流(P5-3 定案:skills/change 不在 $events allowlist——
162
200
  * 零上游变更的进程内桥接;payload-free seq 递增,消费方重取 commands.list)。
@@ -270,6 +308,12 @@ declare class TboxcodeRemoteGateway extends TypertRemoteService {
270
308
  }): Promise<{
271
309
  header: Record<string, unknown>;
272
310
  } | null>;
311
+ sessionsStopSubagents(request: {
312
+ sessionId: string;
313
+ }): Promise<Record<string, never>>;
314
+ sessionsDrainSubagents(request: {
315
+ sessionId: string;
316
+ }): Promise<Record<string, never>>;
273
317
  skillsWatch(signal: AbortSignal): AsyncIterable<{
274
318
  seq: number;
275
319
  }>;
@@ -286,4 +330,4 @@ declare class TboxcodeRemoteGateway extends TypertRemoteService {
286
330
  retentionRun(): Promise<SweepResult>;
287
331
  }
288
332
  //#endregion
289
- export { handleSkillsWatch as C, handleSkillsUserInvocable as S, name as T, handleMode as _, TboxcodeRemoteGateway as a, handleSessionsFlush as b, handleAttachmentsAdmit as c, handleCommit as d, handleDefaultSelection as f, handleImagesRead as g, handleImagesAdmit as h, RemoteAgentLike as i, handleCommandsExecute as l, handleHealth as m, DefaultModelSelection as n, TboxcodeRemoteServices as o, handleGitPushWatch as p, GitPushEvent as r, handleAgentWatch as s, AgentWatchItem as t, handleCommandsList as u, handleReload as v, inject as w, handleSessionsStat as x, handleRetentionRun as y };
333
+ export { handleSessionsStat as C, inject as D, handleSkillsWatch as E, name as O, handleSessionsFlush as S, handleSkillsUserInvocable as T, handleImagesRead as _, SubagentTreeLifecycle as a, handleRetentionRun as b, handleAgentWatch as c, handleCommandsList as d, handleCommit as f, handleImagesAdmit as g, handleHealth as h, RemoteAgentLike as i, handleAttachmentsAdmit as l, handleGitPushWatch as m, DefaultModelSelection as n, TboxcodeRemoteGateway as o, handleDefaultSelection as p, GitPushEvent as r, TboxcodeRemoteServices as s, AgentWatchItem as t, handleCommandsExecute as u, handleMode as v, handleSessionsStopSubagents as w, handleSessionsDrainSubagents as x, handleReload as y };
package/lib/remote.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import "./convergence-core-B81Z55Bq.js";
2
2
  import "./retention-f1rAWNdl.js";
3
- import { C as handleSkillsWatch, S as handleSkillsUserInvocable, T as name, _ as handleMode, a as TboxcodeRemoteGateway, b as handleSessionsFlush, c as handleAttachmentsAdmit, d as handleCommit, f as handleDefaultSelection, g as handleImagesRead, h as handleImagesAdmit, i as RemoteAgentLike, l as handleCommandsExecute, m as handleHealth, n as DefaultModelSelection, o as TboxcodeRemoteServices, p as handleGitPushWatch, r as GitPushEvent, s as handleAgentWatch, t as AgentWatchItem, u as handleCommandsList, v as handleReload, w as inject, x as handleSessionsStat, y as handleRetentionRun } from "./remote--pQj9xul.js";
4
- export { AgentWatchItem, DefaultModelSelection, GitPushEvent, RemoteAgentLike, TboxcodeRemoteGateway, TboxcodeRemoteGateway as default, TboxcodeRemoteServices, handleAgentWatch, handleAttachmentsAdmit, handleCommandsExecute, handleCommandsList, handleCommit, handleDefaultSelection, handleGitPushWatch, handleHealth, handleImagesAdmit, handleImagesRead, handleMode, handleReload, handleRetentionRun, handleSessionsFlush, handleSessionsStat, handleSkillsUserInvocable, handleSkillsWatch, inject, name };
3
+ import "./logger-DcHqQwUI.js";
4
+ import { C as handleSessionsStat, D as inject, E as handleSkillsWatch, O as name, S as handleSessionsFlush, T as handleSkillsUserInvocable, _ as handleImagesRead, a as SubagentTreeLifecycle, b as handleRetentionRun, c as handleAgentWatch, d as handleCommandsList, f as handleCommit, g as handleImagesAdmit, h as handleHealth, i as RemoteAgentLike, l as handleAttachmentsAdmit, m as handleGitPushWatch, n as DefaultModelSelection, o as TboxcodeRemoteGateway, p as handleDefaultSelection, r as GitPushEvent, s as TboxcodeRemoteServices, t as AgentWatchItem, u as handleCommandsExecute, v as handleMode, w as handleSessionsStopSubagents, x as handleSessionsDrainSubagents, y as handleReload } from "./remote-Cw_L6bz7.js";
5
+ export { AgentWatchItem, DefaultModelSelection, GitPushEvent, RemoteAgentLike, SubagentTreeLifecycle, TboxcodeRemoteGateway, TboxcodeRemoteGateway as default, TboxcodeRemoteServices, handleAgentWatch, handleAttachmentsAdmit, handleCommandsExecute, handleCommandsList, handleCommit, handleDefaultSelection, handleGitPushWatch, handleHealth, handleImagesAdmit, handleImagesRead, handleMode, handleReload, handleRetentionRun, handleSessionsDrainSubagents, handleSessionsFlush, handleSessionsStat, handleSessionsStopSubagents, handleSkillsUserInvocable, handleSkillsWatch, inject, name };
package/lib/remote.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./retention-CVHXhi92.js";
2
2
  import "./logger-Dnz11jWP.js";
3
- import { _ as handleSkillsUserInvocable, a as handleCommandsList, b as name, c as handleGitPushWatch, d as handleImagesRead, f as handleMode, g as handleSessionsStat, h as handleSessionsFlush, i as handleCommandsExecute, l as handleHealth, m as handleRetentionRun, n as handleAgentWatch, o as handleCommit, p as handleReload, r as handleAttachmentsAdmit, s as handleDefaultSelection, t as TboxcodeRemoteGateway, u as handleImagesAdmit, v as handleSkillsWatch, x as remote_default, y as inject } from "./remote-Cr46ZKbO.js";
3
+ import { C as remote_default, S as name, _ as handleSessionsStat, a as handleCommandsList, b as handleSkillsWatch, c as handleGitPushWatch, d as handleImagesRead, f as handleMode, g as handleSessionsFlush, h as handleSessionsDrainSubagents, i as handleCommandsExecute, l as handleHealth, m as handleRetentionRun, n as handleAgentWatch, o as handleCommit, p as handleReload, r as handleAttachmentsAdmit, s as handleDefaultSelection, t as TboxcodeRemoteGateway, u as handleImagesAdmit, v as handleSessionsStopSubagents, x as inject, y as handleSkillsUserInvocable } from "./remote-BocZwlS-.js";
4
4
 
5
- export { TboxcodeRemoteGateway, remote_default as default, handleAgentWatch, handleAttachmentsAdmit, handleCommandsExecute, handleCommandsList, handleCommit, handleDefaultSelection, handleGitPushWatch, handleHealth, handleImagesAdmit, handleImagesRead, handleMode, handleReload, handleRetentionRun, handleSessionsFlush, handleSessionsStat, handleSkillsUserInvocable, handleSkillsWatch, inject, name };
5
+ export { TboxcodeRemoteGateway, remote_default as default, handleAgentWatch, handleAttachmentsAdmit, handleCommandsExecute, handleCommandsList, handleCommit, handleDefaultSelection, handleGitPushWatch, handleHealth, handleImagesAdmit, handleImagesRead, handleMode, handleReload, handleRetentionRun, handleSessionsDrainSubagents, handleSessionsFlush, handleSessionsStat, handleSessionsStopSubagents, handleSkillsUserInvocable, handleSkillsWatch, inject, name };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tbox.cn/tboxcode-dsh-bundle",
3
- "version": "0.1.0-rc.16",
3
+ "version": "0.1.0-rc.17",
4
4
  "type": "module",
5
- "description": "tboxcode 组合点(host 服务行 + agent 平面 host 行 + profile 模板三件):patch + prompts / reminders 插件 + tboxcode Remote 服务",
5
+ "description": "tboxcode 组合点(host 服务行 + agent 平面 host 行 + profile 模板三件):patch + prompts / identity 插件 + tboxcode Remote 服务",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
8
8
  "exports": {
@@ -15,6 +15,10 @@
15
15
  "types": "./lib/prompts.d.ts",
16
16
  "default": "./lib/prompts.js"
17
17
  },
18
+ "./identity": {
19
+ "types": "./lib/identity.d.ts",
20
+ "default": "./lib/identity.js"
21
+ },
18
22
  "./convergence": {
19
23
  "types": "./lib/convergence.d.ts",
20
24
  "default": "./lib/convergence.js"
@@ -51,24 +55,24 @@
51
55
  },
52
56
  "dependencies": {
53
57
  "zod": "4.6.7",
54
- "@tbox.cn/tboxcode-dsh-tools": "0.1.0-rc.16",
55
- "@tbox.cn/tboxcode-dsh-runtime": "0.1.0-rc.16",
56
- "@tbox.cn/dsh-acp-bridge-core": "0.1.0-rc.16",
57
- "@tbox.cn/tboxcode-dsh-llm": "0.1.0-rc.16"
58
+ "@tbox.cn/tboxcode-dsh-runtime": "0.1.0-rc.17",
59
+ "@tbox.cn/dsh-acp-bridge-core": "0.1.0-rc.17",
60
+ "@tbox.cn/tboxcode-dsh-llm": "0.1.0-rc.17",
61
+ "@tbox.cn/tboxcode-dsh-tools": "0.1.0-rc.17"
58
62
  },
59
63
  "peerDependencies": {
60
64
  "@deepseek-ai/cordis": "4.1.0",
61
- "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.1",
62
- "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.1",
63
- "@deepseek-ai/dsh-session": "0.2.2-rc.1"
65
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.5",
66
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.5",
67
+ "@deepseek-ai/dsh-session": "0.2.2-rc.5"
64
68
  },
65
69
  "devDependencies": {
66
- "@deepseek-ai/dsh-session": "0.2.2-rc.1",
70
+ "@deepseek-ai/dsh-session": "0.2.2-rc.5",
67
71
  "@deepseek-ai/cordis": "4.1.0",
68
72
  "yaml": "^2.8.0",
69
- "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.1",
70
- "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.1",
71
- "@deepseek-ai/dsh-commands": "0.2.2-rc.1"
73
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.5",
74
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.5",
75
+ "@deepseek-ai/dsh-commands": "0.2.2-rc.5"
72
76
  },
73
77
  "scripts": {
74
78
  "build": "tsdown",