@tbox.cn/tboxcode-dsh-bundle 0.0.0-stage → 0.1.0-rc.1
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 +105 -0
- package/lib/convergence-BfoAE48C.js +105 -0
- package/lib/convergence-CvqBcQv2.d.ts +8 -0
- package/lib/convergence-core-C1ZtU17g.d.ts +43 -0
- package/lib/convergence-core-CbS-hTjK.js +70 -0
- package/lib/convergence-core.d.ts +2 -0
- package/lib/convergence-core.js +3 -0
- package/lib/convergence.d.ts +2 -0
- package/lib/convergence.js +4 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +15 -0
- package/lib/logger-BGwLHZXY.js +36 -0
- package/lib/logger-DcHqQwUI.d.ts +33 -0
- package/lib/logger.d.ts +2 -0
- package/lib/logger.js +3 -0
- package/lib/prompts.d.ts +22 -0
- package/lib/prompts.js +295 -0
- package/lib/remote-Ci33eojc.d.ts +197 -0
- package/lib/remote-DjawPq5z.js +353 -0
- package/lib/remote.d.ts +4 -0
- package/lib/remote.js +5 -0
- package/lib/retention-B2V8Plpx.d.ts +58 -0
- package/lib/retention-DNEdnIxC.js +162 -0
- package/lib/retention.d.ts +2 -0
- package/lib/retention.js +3 -0
- package/package.json +68 -3
- package/README.md +0 -3
package/lib/prompts.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
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";
|
|
6
|
+
|
|
7
|
+
//#region src/prompts.ts
|
|
8
|
+
const name = "tboxcode-prompts";
|
|
9
|
+
const inject = [];
|
|
10
|
+
const ConfigSchema = z.object({
|
|
11
|
+
systemPrompt: z.string().optional(),
|
|
12
|
+
rules: z.array(z.string()).optional()
|
|
13
|
+
});
|
|
14
|
+
function scratchDirFor(sessionId) {
|
|
15
|
+
return join(tmpdir(), "tboxcode-scratch", sessionId);
|
|
16
|
+
}
|
|
17
|
+
const TONE_OBJECTIVITY = `# 语气与风格
|
|
18
|
+
|
|
19
|
+
- 除非你确信 URL 是用于帮助用户编程的,否则绝不要为用户生成或猜测 URL。可以使用用户消息或本地文件中提供的 URL
|
|
20
|
+
- 保持简洁、直接、切中要点。执行复杂或会对系统产生影响的 bash 命令时,应解释命令的作用和运行原因
|
|
21
|
+
- 输出将显示在命令行界面,可使用 GitHub 风格的 Markdown 进行格式化,以等宽字体显示
|
|
22
|
+
- 仅使用文本来与用户沟通;工具之外的所有输出都会显示给用户。仅使用工具完成任务,不要在会话期间使用 bash 或代码注释来与用户沟通
|
|
23
|
+
- 如果无法或不愿帮助用户完成某件事,请不要解释原因,因为这会显得说教和烦人。请提供有用的替代方案,否则保持回复在 1-2 句话
|
|
24
|
+
- 仅在用户明确要求时使用 emoji,除非被要求,否则避免在所有沟通中使用 emoji
|
|
25
|
+
- 不要添加不必要的开场白或结尾(如解释代码或总结操作),除非用户要求
|
|
26
|
+
|
|
27
|
+
# 客观专业
|
|
28
|
+
|
|
29
|
+
优先考虑技术准确性和真实性,而不是迎合用户的观点。专注于事实和问题解决,提供直接、客观的技术信息,不带不必要的赞美或情感认同。百宝箱应该对所有观点都应用同样严格的标准,必要时敢于提出异议。客观的指导和礼貌的纠正比虚假的认同更有价值。当存在不确定性时,最好先调查寻找真相,而不是下意识地迎合用户的想法。`;
|
|
30
|
+
const TASK_EXECUTION = `# 执行任务
|
|
31
|
+
|
|
32
|
+
用户主要会要求你执行软件工程任务,包括解决 bug、添加新功能、重构代码、解释代码等。对于这些任务,建议遵循以下步骤:
|
|
33
|
+
|
|
34
|
+
- 使用可用的搜索工具理解代码库和用户查询。建议灵活地并行或顺序使用搜索工具
|
|
35
|
+
- 使用 todowrite tool 规划任务(如需要)
|
|
36
|
+
- 使用所有可用工具实现解决方案
|
|
37
|
+
- 尽可能通过测试验证解决方案。不要假设特定的测试框架或脚本。检查 README 或搜索代码库确定测试方法
|
|
38
|
+
- 完成任务后,必须运行 lint 和类型检查命令(如 npm run lint、npm run typecheck、ruff 等)确保代码正确。如果找不到正确的命令,询问用户提供命令,如果他们提供了,建议将其写入 AGENTS.md 以便下次知道要运行什么
|
|
39
|
+
- 除非用户明确要求,否则绝不要提交更改。只有在明确要求时才提交,否则用户会认为你过于自作主张
|
|
40
|
+
|
|
41
|
+
工具结果和用户消息可能包含 <system-reminder> 标签。这些标签包含有用的信息和提醒,由系统自动添加,不代表特定的工具结果或用户消息的内容。
|
|
42
|
+
|
|
43
|
+
# 主动性
|
|
44
|
+
|
|
45
|
+
你可以主动采取行动,但仅在用户要求你做某事时。你应该努力在以下之间取得平衡:
|
|
46
|
+
|
|
47
|
+
1. 被要求时做正确的事,包括采取行动和后续行动
|
|
48
|
+
2. 不要在用户未询问的情况下做出令其惊讶的行动
|
|
49
|
+
例如,如果用户问你如何处理某事,你应该先尽力回答他们的问题,而不是立即跳入采取行动
|
|
50
|
+
3. 除非用户要求,否则不要添加额外的代码解释总结。处理完文件后直接停止即可,不要额外解释你做了什么
|
|
51
|
+
|
|
52
|
+
# 遵循约定
|
|
53
|
+
|
|
54
|
+
修改文件前,先了解该文件的代码规范。模仿代码风格,使用现有库和工具,遵循现有模式。
|
|
55
|
+
|
|
56
|
+
- 编写使用某个库或框架的代码时,首先检查代码库是否已使用该库。例如,查看相邻文件或检查 package.json(或 cargo.toml 等,取决于语言)
|
|
57
|
+
- 创建新组件时,首先查看现有组件的写法;然后考虑框架选择、命名约定、类型等
|
|
58
|
+
- 编辑代码时,首先查看代码的周围上下文(特别是导入)以了解代码使用的框架和库。然后考虑如何以最符合项目风格的方式进行更改
|
|
59
|
+
- 始终遵循安全最佳实践。绝不要编写会泄露或记录密钥和凭据的代码。绝不要将密钥或凭据提交到仓库`;
|
|
60
|
+
const TOOL_DISCIPLINE = `# 工具使用纪律
|
|
61
|
+
|
|
62
|
+
- 尽可能使用专用工具替代 bash 命令,因为这提供更好的用户体验。对于文件操作,使用专用工具:read 读取文件而不是 cat/head/tail,edit 编辑而不是 sed/awk,write 创建文件而不是 cat 加 heredoc 或 echo 重定向。仅在需要 shell 执行的系统命令和终端操作时才使用 bash 工具。绝不要使用 bash echo 或其他命令行工具向用户输出想法、解释或指令。直接在回复文本中输出所有沟通内容
|
|
63
|
+
- 你可以在单次响应中调用多个工具。如果你打算调用多个工具且它们之间没有依赖关系,应同时发起所有独立的工具调用。尽量并行调用工具以提高效率。但是,如果某些工具调用需要前一个调用的结果作为参数,不要并行调用,而是顺序调用。例如,如果一个操作必须在另一个操作之前完成,请顺序运行这些操作。绝不要在工具调用中使用占位符或猜测缺失参数
|
|
64
|
+
- 如果用户指定他们希望你"并行"运行工具,你必须在单条消息中发送包含多个工具调用的请求
|
|
65
|
+
- webfetch 会自动跟随 HTTP 重定向和 JS 页面跳转(最多 3 跳)
|
|
66
|
+
- 用户消息以斜杠命令开头时,先使用 skill 工具加载对应技能(若尚未加载);如需读取 skill 目录内其他文件,以 \`<skill_location>\` 中 SKILL.md 所在目录为基础目录`;
|
|
67
|
+
const DELEGATION = `# 委派纪律
|
|
68
|
+
|
|
69
|
+
- 对明确文件、函数、类或关键词的精确查询,直接使用 read、glob、grep 等专用工具;需要跨文件或跨模块的开放式查找与信息收集时,再使用 subagent 委派
|
|
70
|
+
- subagent 工具用于创建子代理执行委派任务。子代理上下文独立,看不到当前对话和你已掌握的信息,执行中也无法与你或用户交互,且不可再创建子代理(委派深度已到上限,收到深度提示后亲自完成)。委派前用一个统一标准判断:拿到返回结果后,你能否不重做这项任务就核实其正确性与完整性
|
|
71
|
+
- 能核实的可以委派:信息收集(查找文件、定位符号与调用点、收集指定事实)与方案已定的变更(你已写明改哪里、怎么改、怎么算完成)
|
|
72
|
+
- 核实即重做的必须亲自完成:判断、结论与设计类产出(哪里有问题、原因是什么、方案怎么定),逐条检查只能验证其报出的内容,确认没有遗漏唯有自己重做,委派它等于放弃质量控制
|
|
73
|
+
- 你对交付的每个结论和改动负全责。子代理的输出是供你使用的工作材料,不是可直接转交的成品:采信其发现前对照实际代码核实,接受其改动前按既定规格核查
|
|
74
|
+
- 任务规模与上下文压力不改变上述划分:大任务拆小后产出若仍是判断(如按模块拆分的评审、排查),依然不可委派;正确做法是你分轮亲自完成判断部分,把其中可核实的查找、收集与照规格执行环节剥离出来委派
|
|
75
|
+
- 每次委派只包含一个目标明确、范围有限的子任务,说明目标、范围和期望输出,要求达成后立即返回、不自行扩展范围;互不依赖的委派并行执行,汇总并核实结果后再推进下一轮
|
|
76
|
+
|
|
77
|
+
<example>
|
|
78
|
+
user: 客户端的错误在哪里处理?
|
|
79
|
+
assistant: [这是跨模块的开放式探索,委派 subagent 调查]
|
|
80
|
+
</example>
|
|
81
|
+
<example>
|
|
82
|
+
user: getUserById 函数定义在哪里?
|
|
83
|
+
assistant: [明确的函数名查询,直接使用 grep 搜索定义即可]
|
|
84
|
+
</example>
|
|
85
|
+
<example>
|
|
86
|
+
user: 深入评审 commit abc1234 以来的所有变更
|
|
87
|
+
assistant: [评审的产出是判断:不重做评审就无法确认子代理的结论没有遗漏,必须亲自完成——运行 git log/diff 查看变更、read 相关文件并逐一分析,变更量大时分轮进行;其中可核实的子任务剥离出来委派,如"列出 FooService.create 的所有调用点"]
|
|
88
|
+
</example>`;
|
|
89
|
+
const CODE_REFERENCES = `# 代码引用
|
|
90
|
+
|
|
91
|
+
引用特定函数或代码片段时,使用 \`file_path:line_number\` 格式,以便用户轻松导航到源代码位置。
|
|
92
|
+
|
|
93
|
+
<example>
|
|
94
|
+
user: 客户端的错误在哪里处理?
|
|
95
|
+
assistant: 客户端连接在 \`connectToServer\` 函数中被标记为失败,位于 src/services/process.ts:712。
|
|
96
|
+
</example>`;
|
|
97
|
+
const TODO_SECTION = `# 任务管理
|
|
98
|
+
|
|
99
|
+
你可以使用 todowrite tool 来管理和规划任务。经常使用这些工具来跟踪任务进度,并让用户了解你的进展。
|
|
100
|
+
|
|
101
|
+
这些工具对于规划任务和将复杂的大型任务分解为更小的步骤也非常有用。如果在规划时不使用这个工具,你可能会忘记做重要的任务——这是不可接受的。
|
|
102
|
+
|
|
103
|
+
关键的是,完成任务后应立即将 todo 标记为已完成。不要攒着多个任务一起标记完成。
|
|
104
|
+
|
|
105
|
+
示例:
|
|
106
|
+
|
|
107
|
+
<example>
|
|
108
|
+
user: 运行构建并修复所有类型错误
|
|
109
|
+
assistant: 我将使用 todowrite tool 写入以下 todo 列表:
|
|
110
|
+
- 运行构建
|
|
111
|
+
- 修复所有类型错误
|
|
112
|
+
|
|
113
|
+
现在我将使用 bash 运行构建。
|
|
114
|
+
|
|
115
|
+
看起来我发现了 10 个类型错误。我将使用 todowrite tool 写入 10 个 todo。
|
|
116
|
+
|
|
117
|
+
将第一个 todo 标记为 in_progress
|
|
118
|
+
|
|
119
|
+
让我从修复第一个开始...
|
|
120
|
+
|
|
121
|
+
第一个已修复,将其标记为 completed,然后继续第二个...
|
|
122
|
+
</example>
|
|
123
|
+
在上面的示例中,助手完成了所有任务,包括 10 个错误修复以及运行构建。
|
|
124
|
+
|
|
125
|
+
重要:在对话中始终使用 todowrite tool 来规划和跟踪任务。`;
|
|
126
|
+
const SECTION_ORDERS_TBOX = {
|
|
127
|
+
TONE_OBJECTIVITY: 100,
|
|
128
|
+
TASK_EXECUTION: 150,
|
|
129
|
+
TOOL_DISCIPLINE: 200,
|
|
130
|
+
DELEGATION: 250,
|
|
131
|
+
CODE_REFERENCES: 300,
|
|
132
|
+
TODO_MANAGEMENT: 350,
|
|
133
|
+
USER_RULES: 400
|
|
134
|
+
};
|
|
135
|
+
/** 白名单二值(reminders-plugin-dissolution 定案):真实用户输入语义。 */
|
|
136
|
+
const USER_VOICE_KINDS = new Set(["user", "user-question-reply"]);
|
|
137
|
+
/** plan 档权限说明文案(composition note 引导三层①;build 档空串不渲染)。 */
|
|
138
|
+
function renderPermissionContext(mode, scratchDir) {
|
|
139
|
+
if (mode !== "read-only") return "";
|
|
140
|
+
return [
|
|
141
|
+
"# 权限模式:plan(只读)",
|
|
142
|
+
"",
|
|
143
|
+
`- 当前处于只读模式:文件写入与变更类 bash 命令会被内核拒绝(含系统临时目录)。`,
|
|
144
|
+
`- 需要临时验证(运行脚本、检查依赖、生成一次性产物)时,使用 scratch_bash / scratch_write / scratch_edit 三件工具——它们在会话私有的临时目录 \`${scratchDir}\` 中放行。产物的绝对路径即可直接引用。`,
|
|
145
|
+
`- 临时验证限于环境已有的依赖;不要尝试安装依赖(缓存目录写入会被拒绝)。`,
|
|
146
|
+
`- webfetch 与 curl 不得发起对目标系统有写入效果的调用。`,
|
|
147
|
+
`- 对项目的一切修改请写入计划,切回 build 模式后执行。`
|
|
148
|
+
].join("\n");
|
|
149
|
+
}
|
|
150
|
+
/** environment 三行(基线 env-static + env-git 精确并集;现算不 memoize)。
|
|
151
|
+
* Working directory 行退役——dsh 0.2.1 原生 working-directory 服务注入
|
|
152
|
+
* `Current working directory: "<path>".`(同信息超集 + 工具联动,subagent-native-adoption)。 */
|
|
153
|
+
function renderEnvironmentContext(cwd) {
|
|
154
|
+
const gitState = existsSync(join(cwd, ".git")) ? "yes" : "no";
|
|
155
|
+
return [
|
|
156
|
+
`Platform: ${platform()}`,
|
|
157
|
+
`Workspace root folder: ${cwd}`,
|
|
158
|
+
`Is directory a git repo: ${gitState}`
|
|
159
|
+
].join("\n");
|
|
160
|
+
}
|
|
161
|
+
function apply(ctx, config = {}) {
|
|
162
|
+
const parsed = ConfigSchema.parse(config);
|
|
163
|
+
const rulesCache = /* @__PURE__ */ new Map();
|
|
164
|
+
const userRulesText = (scopeKey) => {
|
|
165
|
+
const cacheKey = String(scopeKey ?? "global");
|
|
166
|
+
if (rulesCache.has(cacheKey)) return rulesCache.get(cacheKey);
|
|
167
|
+
const lines = [];
|
|
168
|
+
for (const rule of parsed.rules ?? []) lines.push(`- ${rule}`);
|
|
169
|
+
try {
|
|
170
|
+
const rulesDir = join(resolveConfigDir(), "rules");
|
|
171
|
+
if (existsSync(rulesDir)) for (const entry of readdirSync(rulesDir).sort()) {
|
|
172
|
+
const fp = join(rulesDir, entry);
|
|
173
|
+
if (statSync(fp).isFile()) lines.push(`- ${stripJsonc(readFileSync(fp, "utf-8")).trim()}`);
|
|
174
|
+
}
|
|
175
|
+
} catch {}
|
|
176
|
+
const text = lines.length > 0 ? `# 用户规则\n\n${lines.join("\n")}` : "";
|
|
177
|
+
rulesCache.set(cacheKey, text);
|
|
178
|
+
return text;
|
|
179
|
+
};
|
|
180
|
+
const completeText = () => {
|
|
181
|
+
const raw = parsed.systemPrompt;
|
|
182
|
+
if (raw === void 0) return void 0;
|
|
183
|
+
if (raw.startsWith("file://")) {
|
|
184
|
+
const fp = raw.slice(7).replace(/^~(?=\/|$)/, homedir());
|
|
185
|
+
return existsSync(fp) ? readFileSync(fp, "utf-8") : void 0;
|
|
186
|
+
}
|
|
187
|
+
return raw;
|
|
188
|
+
};
|
|
189
|
+
const preStepHandler = async (payload, next) => {
|
|
190
|
+
const decision = await next();
|
|
191
|
+
if (decision.kind !== "enter") return decision;
|
|
192
|
+
const messages = decision.messages ?? [];
|
|
193
|
+
if (messages.some((m) => typeof m?.source?.kind !== "string")) return decision;
|
|
194
|
+
if (!messages.some((m) => USER_VOICE_KINDS.has(m.source.kind))) return decision;
|
|
195
|
+
const users = messages.filter((m) => USER_VOICE_KINDS.has(m.source.kind));
|
|
196
|
+
return {
|
|
197
|
+
kind: "enter",
|
|
198
|
+
messages: [...messages.filter((m) => !USER_VOICE_KINDS.has(m.source.kind)), ...users],
|
|
199
|
+
...decision.startsRequestSeries !== void 0 ? { startsRequestSeries: decision.startsRequestSeries } : {}
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
ctx.on("agent/pre-step", preStepHandler, { prepend: true });
|
|
203
|
+
ctx.inject(["systemPrompt"], (scope) => {
|
|
204
|
+
const sp = scope.systemPrompt;
|
|
205
|
+
const scopeGet = scope.get;
|
|
206
|
+
const tools = scopeGet?.call(scope, "tools") ?? void 0;
|
|
207
|
+
const projections = scopeGet?.call(scope, "sessionProjections") ?? void 0;
|
|
208
|
+
const sandboxModeOf = (c) => {
|
|
209
|
+
const session = c.agent?.session;
|
|
210
|
+
if (projections === void 0 || session === void 0) return void 0;
|
|
211
|
+
try {
|
|
212
|
+
return projections.stateOf(session, "sandboxMode");
|
|
213
|
+
} catch {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
for (const s of [
|
|
218
|
+
{
|
|
219
|
+
name: "tboxcode:tone-objectivity",
|
|
220
|
+
order: SECTION_ORDERS_TBOX.TONE_OBJECTIVITY,
|
|
221
|
+
text: TONE_OBJECTIVITY
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "tboxcode:task-execution",
|
|
225
|
+
order: SECTION_ORDERS_TBOX.TASK_EXECUTION,
|
|
226
|
+
text: TASK_EXECUTION
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "tboxcode:tool-discipline",
|
|
230
|
+
order: SECTION_ORDERS_TBOX.TOOL_DISCIPLINE,
|
|
231
|
+
text: TOOL_DISCIPLINE
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "tboxcode:delegation",
|
|
235
|
+
order: SECTION_ORDERS_TBOX.DELEGATION,
|
|
236
|
+
text: DELEGATION
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "tboxcode:code-references",
|
|
240
|
+
order: SECTION_ORDERS_TBOX.CODE_REFERENCES,
|
|
241
|
+
text: CODE_REFERENCES
|
|
242
|
+
}
|
|
243
|
+
]) sp.section(s);
|
|
244
|
+
sp.section({
|
|
245
|
+
name: "tboxcode:todo-management",
|
|
246
|
+
order: SECTION_ORDERS_TBOX.TODO_MANAGEMENT,
|
|
247
|
+
text: (c) => tools !== void 0 && tools.schemas(c.scope).some((t) => t.name === "todo_write") ? TODO_SECTION : ""
|
|
248
|
+
});
|
|
249
|
+
sp.section({
|
|
250
|
+
name: "tboxcode:user-rules",
|
|
251
|
+
order: SECTION_ORDERS_TBOX.USER_RULES,
|
|
252
|
+
text: (c) => userRulesText(c.scope)
|
|
253
|
+
});
|
|
254
|
+
const complete = completeText();
|
|
255
|
+
if (complete !== void 0) sp.section({
|
|
256
|
+
name: "tboxcode:complete",
|
|
257
|
+
order: SECTION_ORDERS_TBOX.USER_RULES + 50,
|
|
258
|
+
text: complete,
|
|
259
|
+
complete: true
|
|
260
|
+
});
|
|
261
|
+
const sandboxOrder = sp.getContextOrder("SANDBOX_POLICY");
|
|
262
|
+
sp.context({
|
|
263
|
+
name: "tboxcode:permission",
|
|
264
|
+
order: sandboxOrder,
|
|
265
|
+
text: (c) => {
|
|
266
|
+
const mode = sandboxModeOf(c);
|
|
267
|
+
if (mode === void 0) return "";
|
|
268
|
+
return renderPermissionContext(mode, scratchDirFor(c.agent?.session?.header?.id ?? "adhoc"));
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
sp.context({
|
|
272
|
+
name: "tboxcode:model",
|
|
273
|
+
order: sandboxOrder - 5,
|
|
274
|
+
text: (c) => {
|
|
275
|
+
if (c.agent === void 0) return "";
|
|
276
|
+
const sel = (scope.get?.("agentDefaultModel"))?.currentSelection?.();
|
|
277
|
+
if (sel?.provider === void 0 || sel?.model === void 0) return "";
|
|
278
|
+
return `Current model: ${sel.provider}/${sel.model}`;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
sp.context({
|
|
282
|
+
name: "tboxcode:environment",
|
|
283
|
+
order: sandboxOrder - 10,
|
|
284
|
+
text: (c) => {
|
|
285
|
+
const cwd = c.agent?.session?.header?.cwd;
|
|
286
|
+
if (c.agent === void 0 || cwd === void 0) return "";
|
|
287
|
+
return renderEnvironmentContext(cwd);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
return () => {};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
//#endregion
|
|
295
|
+
export { USER_VOICE_KINDS, apply, inject, name, renderEnvironmentContext, renderPermissionContext };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { t as ConvergenceCore } from "./convergence-core-C1ZtU17g.js";
|
|
2
|
+
import { a as SweepResult, r as RetentionScheduler } from "./retention-B2V8Plpx.js";
|
|
3
|
+
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
4
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
5
|
+
|
|
6
|
+
//#region src/remote.d.ts
|
|
7
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
8
|
+
interface RemoteErrorDetailsMap {
|
|
9
|
+
'tboxcode/agent-not-found': {
|
|
10
|
+
readonly agentId?: string;
|
|
11
|
+
readonly sessionId?: string;
|
|
12
|
+
};
|
|
13
|
+
'tboxcode/reload-unavailable': Record<string, never>;
|
|
14
|
+
'tboxcode/retention-unavailable': Record<string, never>;
|
|
15
|
+
'tboxcode/mode-unknown': {
|
|
16
|
+
readonly mode: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
interface RemoteAgentLike {
|
|
21
|
+
readonly session: {
|
|
22
|
+
readonly header: {
|
|
23
|
+
readonly cwd?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
interface DefaultModelSelection {
|
|
28
|
+
provider?: unknown;
|
|
29
|
+
model?: unknown;
|
|
30
|
+
reasoningEffort?: unknown;
|
|
31
|
+
}
|
|
32
|
+
interface TboxcodeRemoteServices {
|
|
33
|
+
agents: {
|
|
34
|
+
get(sessionId: string): (RemoteAgentLike & Record<string, unknown>) | undefined;
|
|
35
|
+
};
|
|
36
|
+
commands: {
|
|
37
|
+
list(agent: unknown): ReadonlyArray<Record<string, unknown>>;
|
|
38
|
+
execute(agent: unknown, line: string, args: readonly string[], signal: AbortSignal): Promise<{
|
|
39
|
+
commandId?: string;
|
|
40
|
+
} | undefined>;
|
|
41
|
+
};
|
|
42
|
+
skills: {
|
|
43
|
+
snapshot(options: {
|
|
44
|
+
cwd?: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
skills: ReadonlyArray<Record<string, unknown>>;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
approval: {
|
|
50
|
+
setPolicy(agent: unknown, policy: unknown): unknown;
|
|
51
|
+
};
|
|
52
|
+
agentDefaultModel: {
|
|
53
|
+
currentSelection(): DefaultModelSelection;
|
|
54
|
+
};
|
|
55
|
+
sessions: {
|
|
56
|
+
get(sessionId: string): unknown;
|
|
57
|
+
flush(session: unknown): Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
/** 持久头 stat(resume cwd 匹配面——冷会话 undefined 不抛)。 */
|
|
60
|
+
persistence: {
|
|
61
|
+
stat(sessionId: string): Promise<{
|
|
62
|
+
header: Record<string, unknown>;
|
|
63
|
+
} | undefined>;
|
|
64
|
+
};
|
|
65
|
+
/** 进程事件订阅(watch 流源——skills/change / agent/inbox/claimed / agent/error)。 */
|
|
66
|
+
on: (event: string, listener: (payload: unknown) => void) => () => void;
|
|
67
|
+
sandbox: {
|
|
68
|
+
setSandboxMode(session: unknown, mode: unknown): unknown;
|
|
69
|
+
};
|
|
70
|
+
convergence?: ConvergenceCore;
|
|
71
|
+
retention?: RetentionScheduler;
|
|
72
|
+
memoryUsage?: () => NodeJS.MemoryUsage;
|
|
73
|
+
uptime?: () => number;
|
|
74
|
+
now?: () => number;
|
|
75
|
+
}
|
|
76
|
+
declare function handleCommandsList(services: TboxcodeRemoteServices, request: {
|
|
77
|
+
agentId: string;
|
|
78
|
+
}): ReadonlyArray<Record<string, unknown>>;
|
|
79
|
+
declare function handleCommandsExecute(services: TboxcodeRemoteServices, request: {
|
|
80
|
+
agentId: string;
|
|
81
|
+
line: string;
|
|
82
|
+
}, signal: AbortSignal): Promise<{
|
|
83
|
+
commandId?: string;
|
|
84
|
+
} | undefined>;
|
|
85
|
+
/** mode 通道(载体二):translateMode(bridge-core 语义映射单源)→ 双 knob 落地。 */
|
|
86
|
+
declare function handleMode(services: TboxcodeRemoteServices, request: {
|
|
87
|
+
agentId: string;
|
|
88
|
+
mode: string;
|
|
89
|
+
}): {
|
|
90
|
+
sandbox: unknown;
|
|
91
|
+
approval: unknown;
|
|
92
|
+
};
|
|
93
|
+
/** 部署默认行(configOptions model 项 initialValue 面——未配置返回 undefined)。 */
|
|
94
|
+
declare function handleDefaultSelection(services: TboxcodeRemoteServices): {
|
|
95
|
+
provider?: string;
|
|
96
|
+
model?: string;
|
|
97
|
+
reasoningEffort?: string;
|
|
98
|
+
};
|
|
99
|
+
declare function handleSkillsUserInvocable(services: TboxcodeRemoteServices, request: {
|
|
100
|
+
agentId: string;
|
|
101
|
+
}): Promise<ReadonlyArray<Record<string, unknown>>>;
|
|
102
|
+
declare function handleSessionsFlush(services: TboxcodeRemoteServices, request: {
|
|
103
|
+
sessionId: string;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
/** 会话头 stat(resume cwd 匹配面——冷会话返 null 不抛;网关 persistence.stat 对位)。 */
|
|
106
|
+
declare function handleSessionsStat(services: TboxcodeRemoteServices, request: {
|
|
107
|
+
sessionId: string;
|
|
108
|
+
}): Promise<{
|
|
109
|
+
header: Record<string, unknown>;
|
|
110
|
+
} | null>;
|
|
111
|
+
/**
|
|
112
|
+
* skills/change 转发流(P5-3 定案:skills/change 不在 $events allowlist——
|
|
113
|
+
* 零上游变更的进程内桥接;payload-free seq 递增,消费方重取 commands.list)。
|
|
114
|
+
*/
|
|
115
|
+
declare function handleSkillsWatch(services: TboxcodeRemoteServices, signal: AbortSignal): AsyncIterable<{
|
|
116
|
+
seq: number;
|
|
117
|
+
}>;
|
|
118
|
+
/** watch 流载荷(agentWatch——claim 关联 + 失败分支两类)。 */
|
|
119
|
+
type AgentWatchItem = {
|
|
120
|
+
kind: 'inboxClaimed';
|
|
121
|
+
sessionId: string;
|
|
122
|
+
messageId?: string;
|
|
123
|
+
turn: number;
|
|
124
|
+
} | {
|
|
125
|
+
kind: 'error';
|
|
126
|
+
sessionId: string;
|
|
127
|
+
error: string;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* agent/inbox/claimed + agent/error 转发流(P5-3 定案:journal turn/start 仅
|
|
131
|
+
* {turn} 无 messageId——prompt 完成相关性与失败分支必须走进程事件;两类聚合
|
|
132
|
+
* 单流,sessionId 经 agent 句柄防御性提取)。
|
|
133
|
+
*/
|
|
134
|
+
declare function handleAgentWatch(services: TboxcodeRemoteServices, signal: AbortSignal): AsyncIterable<AgentWatchItem>;
|
|
135
|
+
/** 热载触发(convergence reloadNow 包装——忙时 RETRY_AFTER_TURN 拒绝语义透传)。 */
|
|
136
|
+
declare function handleReload(services: TboxcodeRemoteServices): Promise<void>;
|
|
137
|
+
/** health(内存观测指标源——doctor --server 画像;会话/冷热分布经 api session/list 面)。 */
|
|
138
|
+
declare function handleHealth(services: TboxcodeRemoteServices): {
|
|
139
|
+
memory: {
|
|
140
|
+
rss: number;
|
|
141
|
+
heapUsed: number;
|
|
142
|
+
heapTotal: number;
|
|
143
|
+
external: number;
|
|
144
|
+
};
|
|
145
|
+
uptimeMs: number;
|
|
146
|
+
retentionLast?: SweepResult;
|
|
147
|
+
};
|
|
148
|
+
/** retention.run(手动触发——调度面之外的运维通道)。 */
|
|
149
|
+
declare function handleRetentionRun(services: TboxcodeRemoteServices): Promise<SweepResult>;
|
|
150
|
+
declare const name = "tboxcode-remote";
|
|
151
|
+
declare const inject: readonly ["agents", "commands", "skills", "approval", "agentDefaultModel", "sessions", "sessionPersistence", "tboxcodeConvergence"];
|
|
152
|
+
/** 宿主服务行(结构行——四链恒挂;sandbox 写函数经 ctx 进程内直调)。 */
|
|
153
|
+
declare class TboxcodeRemoteGateway extends TypertRemoteService {
|
|
154
|
+
static inject: readonly ["agents", "commands", "skills", "approval", "agentDefaultModel", "sessions", "sessionPersistence", "tboxcodeConvergence"];
|
|
155
|
+
constructor(ctx: Context);
|
|
156
|
+
commandsList(request: {
|
|
157
|
+
agentId: string;
|
|
158
|
+
}): ReadonlyArray<Record<string, unknown>>;
|
|
159
|
+
commandsExecute(request: {
|
|
160
|
+
agentId: string;
|
|
161
|
+
line: string;
|
|
162
|
+
}, signal: AbortSignal): Promise<{
|
|
163
|
+
commandId?: string;
|
|
164
|
+
} | undefined>;
|
|
165
|
+
mode(request: {
|
|
166
|
+
agentId: string;
|
|
167
|
+
mode: string;
|
|
168
|
+
}): {
|
|
169
|
+
sandbox: unknown;
|
|
170
|
+
approval: unknown;
|
|
171
|
+
};
|
|
172
|
+
defaultSelection(): {
|
|
173
|
+
provider?: string;
|
|
174
|
+
model?: string;
|
|
175
|
+
reasoningEffort?: string;
|
|
176
|
+
};
|
|
177
|
+
skillsUserInvocable(request: {
|
|
178
|
+
agentId: string;
|
|
179
|
+
}): Promise<ReadonlyArray<Record<string, unknown>>>;
|
|
180
|
+
sessionsFlush(request: {
|
|
181
|
+
sessionId: string;
|
|
182
|
+
}): Promise<void>;
|
|
183
|
+
sessionsStat(request: {
|
|
184
|
+
sessionId: string;
|
|
185
|
+
}): Promise<{
|
|
186
|
+
header: Record<string, unknown>;
|
|
187
|
+
} | null>;
|
|
188
|
+
skillsWatch(signal: AbortSignal): AsyncIterable<{
|
|
189
|
+
seq: number;
|
|
190
|
+
}>;
|
|
191
|
+
agentWatch(signal: AbortSignal): AsyncIterable<AgentWatchItem>;
|
|
192
|
+
reload(): Promise<void>;
|
|
193
|
+
health(): ReturnType<typeof handleHealth>;
|
|
194
|
+
retentionRun(): Promise<SweepResult>;
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
export { handleSkillsWatch as _, TboxcodeRemoteServices as a, handleCommandsList as c, handleMode as d, handleReload as f, handleSkillsUserInvocable as g, handleSessionsStat as h, TboxcodeRemoteGateway as i, handleDefaultSelection as l, handleSessionsFlush as m, DefaultModelSelection as n, handleAgentWatch as o, handleRetentionRun as p, RemoteAgentLike as r, handleCommandsExecute as s, AgentWatchItem as t, handleHealth as u, inject as v, name as y };
|