@hugesb/dsh-stream-agent 0.0.0-stage → 0.3.2

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.
Files changed (161) hide show
  1. package/CHANGELOG.md +622 -0
  2. package/CONTRIBUTING.md +72 -0
  3. package/LICENSE +202 -0
  4. package/README.en.md +349 -0
  5. package/README.md +300 -3
  6. package/cordis.patch.yml +77 -0
  7. package/dist/entry/action-gate.js +206 -0
  8. package/dist/entry/adapter-kit.js +192 -0
  9. package/dist/entry/context-render.js +119 -0
  10. package/dist/entry/control-bar-cli.js +289 -0
  11. package/dist/entry/control-bar.js +123 -0
  12. package/dist/entry/control-session.js +115 -0
  13. package/dist/entry/control-state.js +125 -0
  14. package/dist/entry/cordis-compat.js +95 -0
  15. package/dist/entry/eval-probe.js +112 -0
  16. package/dist/entry/intent-log.js +121 -0
  17. package/dist/entry/json-persistence.js +306 -0
  18. package/dist/entry/loop.js +4163 -0
  19. package/dist/entry/mock-provider.js +549 -0
  20. package/dist/entry/obs-broker.js +178 -0
  21. package/dist/entry/ptc-bridge.js +405 -0
  22. package/dist/entry/state-handle.js +217 -0
  23. package/dist/entry/takeover-registry.js +60 -0
  24. package/dist/kernel/control-bar.js +559 -0
  25. package/dist/kernel/final.js +62 -0
  26. package/dist/kernel/gate.js +464 -0
  27. package/dist/kernel/modes.js +253 -0
  28. package/dist/kernel/obs.js +517 -0
  29. package/dist/kernel/parser.js +1081 -0
  30. package/dist/kernel/render.js +466 -0
  31. package/dist/kernel/state.js +416 -0
  32. package/dist/version.js +9 -0
  33. package/docs/TEST-PROPOSITIONS.md +139 -0
  34. package/docs/adr-001-segment-boundary.md +61 -0
  35. package/docs/architecture.md +104 -0
  36. package/docs/desktop-ui-feasibility.md +277 -0
  37. package/docs/disabled-lines-audit.md +53 -0
  38. package/docs/limitations.md +181 -0
  39. package/docs/protocol.md +99 -0
  40. package/docs/v0.4.0-plan.md +50 -0
  41. package/eval/METRICS.md +128 -0
  42. package/eval/RESULTS.md +246 -0
  43. package/eval/tasks/fixtures/big-report.md +298 -0
  44. package/eval/tasks/fixtures/build-manifest.txt +5 -0
  45. package/eval/tasks/fixtures/deploy.yaml +4 -0
  46. package/eval/tasks/fixtures/error.log +200 -0
  47. package/eval/tasks/fixtures/features.yaml +4 -0
  48. package/eval/tasks/fixtures/pipeline.yaml +4 -0
  49. package/eval/tasks/fixtures/sales-q1.csv +61 -0
  50. package/eval/tasks/fixtures/settings.yaml +4 -0
  51. package/eval/tasks/fixtures/users-roster.json +304 -0
  52. package/eval/tasks/fixtures/users-scores.json +20 -0
  53. package/eval/tasks/gen-fixtures.cjs +80 -0
  54. package/eval/tasks/tasks.json +150 -0
  55. package/eval/tools/f6-kill-drill.cjs +176 -0
  56. package/eval/tools/f6-kill-drill.worker.cjs +131 -0
  57. package/eval/tools/gen-results.cjs +191 -0
  58. package/eval/tools/machine-test.cjs +200 -0
  59. package/eval/tools/manual-code-scenarios.md +59 -0
  60. package/eval/tools/replay-check.cjs +311 -0
  61. package/eval/tools/runner.cjs +219 -0
  62. package/eval/tools/session-log.cjs +106 -0
  63. package/eval/tools/summarize.cjs +185 -0
  64. package/eval/tools/t3-cells.cjs +173 -0
  65. package/package.json +73 -6
  66. package/patches/adapters-smoke.yml +41 -0
  67. package/patches/eval-account.yml +36 -0
  68. package/patches/eval-baseline.yml +33 -0
  69. package/patches/eval-stream-code-off.yml +46 -0
  70. package/patches/eval-stream-code-on.yml +47 -0
  71. package/patches/eval-stream.yml +54 -0
  72. package/patches/takeover.yml +42 -0
  73. package/patches/test-preset.yml +23 -0
  74. package/preset/stream/cordis.patch.yml +39 -0
  75. package/preset/stream/package.json +13 -0
  76. package/preset.yml +56 -0
  77. package/profiles/stream/README.md +66 -0
  78. package/profiles/stream/cordis.patch.yml +12 -0
  79. package/profiles/stream/package.json +17 -0
  80. package/profiles/stream-headless/package.json +16 -0
  81. package/scripts/build.mjs +103 -0
  82. package/scripts/check-consistency.mjs +146 -0
  83. package/scripts/gate.mjs +138 -0
  84. package/scripts/install-check.mjs +116 -0
  85. package/scripts/install-cycle.mjs +88 -0
  86. package/scripts/release.mjs +428 -0
  87. package/scripts/repair-session-logs.mjs +498 -0
  88. package/src/entry/action-gate.ts +206 -0
  89. package/src/entry/adapter-kit.ts +192 -0
  90. package/src/entry/context-render.ts +119 -0
  91. package/src/entry/control-bar-cli.ts +289 -0
  92. package/src/entry/control-bar.ts +123 -0
  93. package/src/entry/control-session.ts +115 -0
  94. package/src/entry/control-state.ts +125 -0
  95. package/src/entry/cordis-compat.ts +95 -0
  96. package/src/entry/eval-probe.ts +112 -0
  97. package/src/entry/intent-log.ts +121 -0
  98. package/src/entry/json-persistence.ts +306 -0
  99. package/src/entry/loop.ts +4163 -0
  100. package/src/entry/mock-provider.ts +549 -0
  101. package/src/entry/obs-broker.ts +178 -0
  102. package/src/entry/ptc-bridge.ts +405 -0
  103. package/src/entry/state-handle.ts +217 -0
  104. package/src/entry/takeover-registry.ts +60 -0
  105. package/src/kernel/control-bar.ts +559 -0
  106. package/src/kernel/final.ts +62 -0
  107. package/src/kernel/gate.ts +464 -0
  108. package/src/kernel/modes.ts +253 -0
  109. package/src/kernel/obs.ts +517 -0
  110. package/src/kernel/parser.ts +1081 -0
  111. package/src/kernel/render.ts +466 -0
  112. package/src/kernel/state.ts +416 -0
  113. package/src/version.ts +9 -0
  114. package/test/activation.test.ts +187 -0
  115. package/test/adapters.test.ts +676 -0
  116. package/test/control-bar.test.ts +486 -0
  117. package/test/desktop-ui.test.ts +359 -0
  118. package/test/eval-probe.test.ts +139 -0
  119. package/test/f5-plan.test.ts +221 -0
  120. package/test/f6-intent.test.ts +168 -0
  121. package/test/f7-segment.test.ts +190 -0
  122. package/test/fix-limits.test.ts +599 -0
  123. package/test/gate.test.ts +380 -0
  124. package/test/helpers/stub-loop.ts +240 -0
  125. package/test/host-conformance.test.ts +418 -0
  126. package/test/kernel/obs.test.ts +329 -0
  127. package/test/kernel/parser.test.ts +451 -0
  128. package/test/loop.test.ts +1393 -0
  129. package/test/mock-provider.test.ts +386 -0
  130. package/test/ptc-bridge.test.ts +356 -0
  131. package/test/render.test.ts +418 -0
  132. package/test/s2-install-check.test.ts +46 -0
  133. package/test/scenarios/3-file-basic.json +13 -0
  134. package/test/scenarios/5-file-basic.json +22 -0
  135. package/test/scenarios/burn-more.json +9 -0
  136. package/test/scenarios/degraded-final.json +10 -0
  137. package/test/scenarios/fault-abort-xml.json +11 -0
  138. package/test/scenarios/fault-malformed-command.json +12 -0
  139. package/test/scenarios/fault-midstream-abort.json +11 -0
  140. package/test/scenarios/fault-saturating-output.json +9 -0
  141. package/test/scenarios/fault-timeout.json +9 -0
  142. package/test/scenarios/peek-first.json +11 -0
  143. package/test/scenarios/peek-second.json +11 -0
  144. package/test/scenarios/peek-third.json +10 -0
  145. package/test/scenarios/recover-final.json +10 -0
  146. package/test/scenarios/reroute-first.json +17 -0
  147. package/test/scenarios/reroute-second.json +16 -0
  148. package/test/scenarios/starvation-final.json +10 -0
  149. package/test/scenarios/starvation-promote.json +11 -0
  150. package/test/scenarios/wait-tools-continue.json +10 -0
  151. package/test/scenarios/wait-tools-xml.json +22 -0
  152. package/test/scenarios/wait-tools.json +15 -0
  153. package/test/session-format.test.ts +234 -0
  154. package/test/state.test.ts +335 -0
  155. package/test/stream-v02.test.ts +264 -0
  156. package/test/v031-display.test.ts +333 -0
  157. package/test/v032-conflict.test.ts +191 -0
  158. package/test/v032-truncation.test.ts +291 -0
  159. package/ui/client.js +576 -0
  160. package/ui/index.js +282 -0
  161. package/ui/package.json +26 -0
@@ -0,0 +1,173 @@
1
+ // eval/tools/t3-cells.cjs —— M2 T3 三格基线(B / A-1a / A-1b 首请求拆分与归因)
2
+ //
3
+ // 用法:
4
+ // node eval/tools/t3-cells.cjs --stamp <2026-11-15> [--cell-b baseline] [--cell-a1a stream] [--cell-a1b <目录>]
5
+ //
6
+ // 三格定义(升级方案 §3.2 / upgrade-plan v0.3.0-beta.1):
7
+ // B = 既有 profile + 0.2.0 bundle(tf-code 现状开启) —— eval/runs/<stamp>/baseline/
8
+ // A-1a = stream profile + 显式开启 tf-code(复现 0.2.0 现状) —— eval/runs/<stamp>/stream/
9
+ // A-1b = stream profile + 关闭 tf-code(K1 后的默认装配) —— 需单独跑(--cell-a1b 指定目录)
10
+ //
11
+ // 判定规则:
12
+ // 1. A-1a 与 B 的首请求 messages 必须逐字节相等(装配没有引入额外提示面);
13
+ // 不等 → 先定位差异来源(宿主注入/preset 行/配置覆盖),定位不了不得进入 K1。
14
+ // 2. A-1b 与 A-1a 的差值必须等于 tf-code 协议段的实测长度(字符 + token)。
15
+ // 3. 只有当 tf-code 段占 B 的 T3 ≥10% 时,才允许对外主张 "≤0.9×B";否则如实写"持平"。
16
+ //
17
+ // 拆分口径:system 消息 = [系统提示 | 协议段(含 tf-code 段) | 工具 schema 文本 | 任务不变量],
18
+ // 四部分之和 = 首请求 system 字符数;任务文本 = 首条 user 消息。
19
+
20
+ const fs = require('node:fs');
21
+ const path = require('node:path');
22
+
23
+ const PKG_ROOT = path.resolve(__dirname, '..', '..');
24
+
25
+ function arg(name, def) {
26
+ const i = process.argv.indexOf(`--${name}`);
27
+ return i >= 0 && i + 1 < process.argv.length ? process.argv[i + 1] : def;
28
+ }
29
+
30
+ /** 从 probe.jsonl 取首请求(跳过标题旁路)的 options 原文 + 首个 usage。 */
31
+ function firstRequest(probePath) {
32
+ if (!fs.existsSync(probePath)) return null;
33
+ const lines = fs.readFileSync(probePath, 'utf8').split('\n').filter(Boolean);
34
+ let firstOptions = null;
35
+ let firstUsage = null;
36
+ for (const line of lines) {
37
+ let rec;
38
+ try { rec = JSON.parse(line); } catch { continue; }
39
+ if (rec.kind === 'request' && firstOptions === null) {
40
+ let opts;
41
+ try { opts = JSON.parse(rec.options); } catch { continue; }
42
+ // 标题旁路剔除(E5)
43
+ const msgs = opts.messages || [];
44
+ if (opts.maxTokens === 64 && msgs.length <= 2) continue;
45
+ if (JSON.stringify(msgs).includes('Generate the session title')) continue;
46
+ firstOptions = opts;
47
+ }
48
+ if (rec.kind === 'chunk' && firstUsage === null) {
49
+ try {
50
+ const c = JSON.parse(rec.chunk);
51
+ if (c.type === 'usage') firstUsage = c.usage;
52
+ } catch { /* 忽略 */ }
53
+ }
54
+ if (firstOptions !== null && firstUsage !== null) break;
55
+ }
56
+ return firstOptions === null ? null : { options: firstOptions, usage: firstUsage };
57
+ }
58
+
59
+ /** system 消息四段拆分:用内核常量做边界定位(导出自 dist/entry/loop.js)。 */
60
+ function splitSystem(systemText, constants) {
61
+ const parts = {};
62
+ const { DEFAULT_SYSTEM_PROMPT, DEFAULT_PROTOCOL_TEXT, DEFAULT_CODE_PROTOCOL_SECTION, DEFAULT_INVARIANTS } = constants;
63
+ parts.systemPrompt = systemText.includes(DEFAULT_SYSTEM_PROMPT) ? DEFAULT_SYSTEM_PROMPT.length : 0;
64
+ const codeLen = systemText.includes(DEFAULT_CODE_PROTOCOL_SECTION) ? DEFAULT_CODE_PROTOCOL_SECTION.length : 0;
65
+ const protocolLen = systemText.includes(DEFAULT_PROTOCOL_TEXT) ? DEFAULT_PROTOCOL_TEXT.length : 0;
66
+ parts.protocolWithoutCode = protocolLen;
67
+ parts.codeSection = codeLen;
68
+ parts.invariants = systemText.includes(DEFAULT_INVARIANTS) ? DEFAULT_INVARIANTS.length : 0;
69
+ const known = parts.systemPrompt + protocolLen + (codeLen > 0 ? 2 : 0) + codeLen + 2 + parts.invariants;
70
+ parts.toolSchemasAndGlue = Math.max(0, systemText.length - known);
71
+ parts.totalChars = systemText.length;
72
+ return parts;
73
+ }
74
+
75
+ function main() {
76
+ const stamp = arg('stamp');
77
+ if (stamp === undefined) { console.error('用法:node eval/tools/t3-cells.cjs --stamp <2026-11-15> [--cell-a1b <目录名>]'); process.exit(2); }
78
+ const runDir = path.join(PKG_ROOT, 'eval', 'runs', stamp);
79
+ // 内核常量(协议段边界);从 dist 取(构建产物与真机装配一致)
80
+ const loopDist = path.join(PKG_ROOT, 'dist', 'entry', 'loop.js');
81
+ // 动态 import(CJS 里用 createRequire);这些常量是协议文本的权威形态
82
+ const { pathToFileURL } = require('node:url');
83
+ const imported = awaitImport(loopDist);
84
+ const constants = {
85
+ DEFAULT_SYSTEM_PROMPT: imported.DEFAULT_SYSTEM_PROMPT,
86
+ DEFAULT_PROTOCOL_TEXT: imported.DEFAULT_PROTOCOL_TEXT,
87
+ DEFAULT_CODE_PROTOCOL_SECTION: imported.DEFAULT_CODE_PROTOCOL_SECTION,
88
+ DEFAULT_INVARIANTS: imported.DEFAULT_INVARIANTS,
89
+ };
90
+
91
+ const tasks = JSON.parse(fs.readFileSync(path.join(PKG_ROOT, 'eval', 'tasks', 'tasks.json'), 'utf8')).tasks;
92
+ const cells = {};
93
+ const cellDefs = [
94
+ ['B', arg('cell-b', 'baseline')],
95
+ ['A-1a', arg('cell-a1a', 'stream')],
96
+ ];
97
+ const a1bDir = arg('cell-a1b');
98
+ if (a1bDir !== undefined) cellDefs.push(['A-1b', a1bDir]);
99
+
100
+ for (const [cell, dir] of cellDefs) {
101
+ const rows = {};
102
+ let equalCount = 0;
103
+ let compared = 0;
104
+ for (const task of tasks) {
105
+ const probePath = path.join(runDir, dir, task.id, 'probe', 'probe.jsonl');
106
+ const first = firstRequest(probePath);
107
+ if (first === null) { rows[task.id] = { missing: true }; continue; }
108
+ const systemText = first.options.messages.find((m) => m.role === 'system')?.content?.map((b) => b.text ?? '').join('') ?? '';
109
+ const userText = first.options.messages.filter((m) => m.role === 'user').map((m) => m.content.map((b) => b.text ?? '').join('')).join('\n');
110
+ rows[task.id] = {
111
+ systemChars: systemText.length,
112
+ split: splitSystem(systemText, constants),
113
+ userChars: userText.length,
114
+ usage: first.usage,
115
+ messagesHash: require('node:crypto').createHash('sha256').update(JSON.stringify(first.options.messages)).digest('hex').slice(0, 16),
116
+ };
117
+ }
118
+ cells[cell] = { dir, tasks: rows };
119
+ void equalCount; void compared;
120
+ }
121
+
122
+ // 逐任务对账:A-1a vs B 首请求逐字节相等
123
+ console.log(`# T3 三格(stamp=${stamp})\n`);
124
+ console.log('| 任务 | B system | A-1a system | A-1b system | A-1a==B | B usage(全量) |');
125
+ console.log('|---|---|---|---|---|---|');
126
+ let byteEqual = 0;
127
+ let compared = 0;
128
+ for (const task of tasks) {
129
+ const b = cells['B'].tasks[task.id];
130
+ const a = cells['A-1a'].tasks[task.id];
131
+ const ab = cells['A-1b']?.tasks[task.id];
132
+ if (b?.missing || a?.missing) { console.log(`| ${task.id} | - | - | - | - | - |`); continue; }
133
+ compared += 1;
134
+ const equal = a.messagesHash === b.messagesHash;
135
+ if (equal) byteEqual += 1;
136
+ const usage = b.usage;
137
+ const total = usage ? (usage.inputTokens ?? 0) + (usage.cacheReadTokens ?? 0) + (usage.cacheWriteTokens ?? 0) + (usage.outputTokens ?? 0) : null;
138
+ console.log(`| ${task.id} | ${b.systemChars} | ${a.systemChars} | ${ab ? ab.systemChars : '未跑'} | ${equal ? '✓' : '✗ ' + a.messagesHash + '/' + b.messagesHash} | ${total ?? '?'} |`);
139
+ }
140
+ console.log(`\nA-1a == B(首请求逐字节):${byteEqual}/${compared}`);
141
+ const a1bDef = cells['A-1b'];
142
+ if (a1bDef !== undefined) {
143
+ let diffs = [];
144
+ for (const task of tasks) {
145
+ const a = cells['A-1a'].tasks[task.id];
146
+ const ab = a1bDef.tasks[task.id];
147
+ if (a?.missing || ab?.missing || ab === undefined) continue;
148
+ diffs.push(ab.systemChars - a.systemChars);
149
+ }
150
+ const codeLen = constants.DEFAULT_CODE_PROTOCOL_SECTION.length;
151
+ console.log(`A-1b − A-1a 差值:${diffs.join(', ')} 字符(tf-code 协议段实测 ${codeLen} 字符)`);
152
+ console.log(`判定:${diffs.every((d) => d === -codeLen - 2) ? '差值 = code 段长度 ✓' : '差值与 code 段不符 → 先定位差异来源'}`);
153
+ } else {
154
+ console.log('A-1b:未提供(K1 切换后的装配跑一遍并传 --cell-a1b);tf-code 段长度(代码事实)= ' + constants.DEFAULT_CODE_PROTOCOL_SECTION.length + ' 字符');
155
+ }
156
+ console.log('\nK1 门槛(升级方案 M2 判定规则):tf-code 段占 B 的 T3 比例 = code 段 token / B 首请求 token;');
157
+ console.log('≥10% 才可主张 "A-1b ≤ 0.9×B",否则如实写"持平"。以本表逐任务值与同批 usage 复算。');
158
+ }
159
+
160
+ // CJS 里加载 ESM 构建产物
161
+ function awaitImport(absPath) {
162
+ const req = require('node:module').createRequire(__filename);
163
+ let mod = null;
164
+ // Node 22+ 支持 require(esm)(构建产物是零依赖 ESM)
165
+ try {
166
+ mod = req(absPath);
167
+ } catch {
168
+ throw new Error(`无法加载 ${absPath}(请先 npm run build)`);
169
+ }
170
+ return mod;
171
+ }
172
+
173
+ main();
package/package.json CHANGED
@@ -1,6 +1,73 @@
1
- {
2
- "name": "@hugesb/dsh-stream-agent",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@hugesb/dsh-stream-agent",
3
+ "version": "0.3.2",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "description": "单流协议 DSH 插件(独立模式):专用 profile + 计量治理 + tf-code 收口 + 编辑/搜索/计划/恢复/段边界(含会话日志 v4 工具生命周期与 model source 修复)",
7
+ "keywords": [
8
+ "dsh",
9
+ "dsh-plugin",
10
+ "deepseek-harness",
11
+ "cordis",
12
+ "ai-agent",
13
+ "token-optimization",
14
+ "single-stream"
15
+ ],
16
+ "author": "54dsb1",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/54dsb1/dsh-stream-agent.git"
20
+ },
21
+ "homepage": "https://github.com/54dsb1/dsh-stream-agent#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/54dsb1/dsh-stream-agent/issues"
24
+ },
25
+ "main": "./dist/entry/loop.js",
26
+ "exports": {
27
+ ".": "./dist/entry/loop.js",
28
+ "./cordis.patch.yml": "./cordis.patch.yml"
29
+ },
30
+ "scripts": {
31
+ "test": "node --test \"test/*.test.ts\" \"test/kernel/*.test.ts\"",
32
+ "build": "node scripts/build.mjs",
33
+ "check": "node scripts/check-consistency.mjs",
34
+ "gate": "node scripts/gate.mjs",
35
+ "release": "node scripts/release.mjs",
36
+ "release:dry": "node scripts/release.mjs --dry-run"
37
+ },
38
+ "engines": {
39
+ "node": ">=22.18",
40
+ "dsh": ">=0.2.2-rc.1"
41
+ },
42
+ "dsh": {
43
+ "manifestVersion": 1,
44
+ "bundle": {
45
+ "patch": "./cordis.patch.yml"
46
+ }
47
+ },
48
+ "files": [
49
+ "LICENSE",
50
+ "README.md",
51
+ "README.en.md",
52
+ "CHANGELOG.md",
53
+ "CONTRIBUTING.md",
54
+ "dist/",
55
+ "ui/",
56
+ "src/",
57
+ "test/",
58
+ "scripts/",
59
+ "docs/",
60
+ "eval/METRICS.md",
61
+ "eval/RESULTS.md",
62
+ "eval/tasks/",
63
+ "eval/tools/",
64
+ "profiles/",
65
+ "preset/",
66
+ "preset.yml",
67
+ "cordis.patch.yml",
68
+ "patches/"
69
+ ],
70
+ "bin": {
71
+ "dsh-stream-agent": "./dist/entry/control-bar-cli.js"
72
+ }
73
+ }
@@ -0,0 +1,41 @@
1
+ # 四个 sidecar entry 的宿主装载冒烟(开发用,不进生产装配)
2
+ #
3
+ # 验证 state-handle 的 ctx.provide('state')、obs-broker / context-render 的 ctx.on 挂载、
4
+ # action-gate 的 ctx.tools.guard 注册是否在真实宿主上生效。
5
+ # 不需要 API Key:装载与接线先于任何 LLM 调用完成,任务会在 MISSING_CREDENTIAL 处终止,
6
+ # 那正是本冒烟要的观测点。
7
+
8
+ - id: agent-loop
9
+ name: '@deepseek-ai/dsh-agent-loop'
10
+ config:
11
+ agents: []
12
+ maxParallelToolCalls: 10
13
+ disabled: true
14
+ - insert:
15
+ - id: stream-agent
16
+ name: ../dist/entry/loop.js
17
+ inject: [llm, tools, agents, sessions]
18
+ config:
19
+ announceTakeover: true
20
+ streamIdleTimeoutMs: 30000
21
+ - id: stream-agent-state
22
+ name: ../dist/entry/state-handle.js
23
+ inject: [storage]
24
+ config:
25
+ unit: tfAgentState
26
+ announce: true
27
+ - id: stream-agent-obs-broker
28
+ name: ../dist/entry/obs-broker.js
29
+ inject: [tools, state]
30
+ config:
31
+ announce: true
32
+ - id: stream-agent-action-gate
33
+ name: ../dist/entry/action-gate.js
34
+ inject: [tools, storage]
35
+ config:
36
+ announce: true
37
+ - id: stream-agent-context-render
38
+ name: ../dist/entry/context-render.js
39
+ inject: []
40
+ config:
41
+ announce: true
@@ -0,0 +1,36 @@
1
+ # 评测期模型路由覆盖:改走 DeepSeek 账号通道
2
+ #
3
+ # 背景:评测机没有 DEEPSEEK_API_KEY,而是用 DSH 的账号登录态。凭据在
4
+ # ~/.dsh/.credentials.yaml 的 deepseek-account-platform/* 条目下,provider 路由为
5
+ # deepseek-account;headless 默认模型走 deepseek-official(API key 通道),故需本覆盖行。
6
+ #
7
+ # dsh --profile headless --patch <两臂 patch> --patch <本文件> headless "<任务>"
8
+ #
9
+ # 控制变量红线:两臂必须同时叠加本文件,保证 provider/model 完全一致。
10
+ #
11
+ # 下面三行解禁是必需的:headless 出厂把本地凭据库、authorization、账号 provider 都设为
12
+ # disabled,不解禁则 resolveToken 拿不到 grant(ACCOUNT_SIGN_IN_REQUIRED);
13
+ # authorization 是 deepseek-account 的注入依赖,缺了它会一直挂在 "waiting for service"。
14
+
15
+ - id: agent-default-model
16
+ name: '@deepseek-ai/dsh-agent-default-model'
17
+ config:
18
+ provider: deepseek-account
19
+ model: deepseek-flash
20
+ searchProvider: deepseek-official
21
+
22
+ # headless 出厂把本地凭据库与账号服务禁用(dump-config 实证:两行 disabled: true),
23
+ # 不解禁则 resolveToken 拿不到 grant → ACCOUNT_SIGN_IN_REQUIRED
24
+ # (dsh-llm-deepseek-account/lib/index.js:82-83;dsh-deepseek-account-platform
25
+ # /lib/index.js:804-822 经 KEY=deepseek-account-platform/default 读 ~/.dsh/.credentials.yaml)。
26
+ # authorization 是 deepseek-account 的注入依赖(static inject = ["credentials","authorization"],
27
+ # headless 同样 disabled),须一并解禁(实测 pending "waiting for service: authorization")。
28
+ - id: credentials
29
+ name: '@deepseek-ai/dsh-credentials-local'
30
+ disabled: false
31
+ - id: authorization
32
+ name: '@deepseek-ai/dsh-authorization'
33
+ disabled: false
34
+ - id: deepseek-account
35
+ name: '@deepseek-ai/dsh-deepseek-account-platform'
36
+ disabled: false
@@ -0,0 +1,33 @@
1
+ # 评测基线臂:内建 loop 原样运行 + 中立探针
2
+ #
3
+ # 基线 = 内建 agent-loop 不做任何行为调参(minimal),唯一附加是 eval-probe
4
+ # (两臂同装的测量仪器,只读透传)。对照臂见 patches/eval-stream.yml;
5
+ # 任务集、seed、探针在两臂间逐字节相同——控制变量红线。
6
+ #
7
+ # dsh --profile headless --patch <本文件> headless "<任务文本>"
8
+ # env DSH_EVAL_PROBE_DIR=<每任务每臂独立目录>,由 runner 设置
9
+ #
10
+ # 注意:本包经 dsh plugin add 安装后,bundle 层已经停用内建 agent-loop 并插入五个生产
11
+ # entry,基线臂必须先覆盖回来,否则基线会被对照臂实现劫持。--patch 层优先级最高,
12
+ # 下面用同 id 覆盖行逐行恢复原生形态。
13
+
14
+ - id: agent-loop
15
+ name: '@deepseek-ai/dsh-agent-loop'
16
+ disabled: false
17
+ - id: stream-agent
18
+ disabled: true
19
+ - id: stream-agent-state
20
+ disabled: true
21
+ - id: stream-agent-obs-broker
22
+ disabled: true
23
+ - id: stream-agent-action-gate
24
+ disabled: true
25
+ - id: stream-agent-context-render
26
+ disabled: true
27
+
28
+ - insert:
29
+ - id: stream-agent-eval-probe
30
+ name: ../dist/entry/eval-probe.js
31
+ inject: []
32
+ config:
33
+ announce: true
@@ -0,0 +1,46 @@
1
+ # M2 三格对照 · A-1b 臂:0.3.0 装配 + tf-code 关闭(K1 默认装配形态)
2
+ #
3
+ # dsh --profile headless --patch <本文件> headless "<任务文本>"
4
+ # env DSH_EVAL_PROBE_DIR=<每任务目录>(runner 设置)
5
+ #
6
+ # 与 eval-stream-code-on.yml 的唯一差异:enableCode: false(协议段 0 字符)。
7
+ # A-1b 与 A-1a 的首请求差值必须等于 tf-code 协议段实测长度(t3-cells.cjs 判定)。
8
+
9
+ - id: agent-loop
10
+ name: '@deepseek-ai/dsh-agent-loop'
11
+ config:
12
+ agents: []
13
+ maxParallelToolCalls: 10
14
+ disabled: true
15
+ - insert:
16
+ - id: stream-agent-eval-probe
17
+ name: ../dist/entry/eval-probe.js
18
+ inject: []
19
+ config:
20
+ announce: true
21
+ - id: stream-agent-state
22
+ name: ../dist/entry/state-handle.js
23
+ inject: [storage]
24
+ config:
25
+ unit: tfAgentState
26
+ - id: stream-agent-obs-broker
27
+ name: ../dist/entry/obs-broker.js
28
+ inject: [tools, state]
29
+ config: {}
30
+ - id: stream-agent-action-gate
31
+ name: ../dist/entry/action-gate.js
32
+ inject: [tools, storage]
33
+ config: {}
34
+ - id: stream-agent-context-render
35
+ name: ../dist/entry/context-render.js
36
+ inject: []
37
+ config: {}
38
+ - id: stream-agent
39
+ name: ../dist/entry/loop.js
40
+ inject: [llm, tools, agents, sessions, sessionProjections]
41
+ config:
42
+ announceTakeover: true
43
+ maxParallelToolCalls: 3
44
+ maxReentries: 8
45
+ streamIdleTimeoutMs: 60000
46
+ enableCode: false
@@ -0,0 +1,47 @@
1
+ # M2 三格对照 · A-1a 臂:0.3.0 装配 + 显式开启 tf-code(复现 0.2.x 的 code 现状)
2
+ #
3
+ # dsh --profile headless --patch <本文件> headless "<任务文本>"
4
+ # env DSH_EVAL_PROBE_DIR=<每任务目录>(runner 设置)
5
+ #
6
+ # 与 eval-stream.yml 的唯一差异:enableCode: true(K2-K6 收口后的显式开启路径)。
7
+ # A-1b 臂见 patches/eval-stream-code-off.yml;B 格用 v0.2.1 tag 产物 + eval-stream.yml。
8
+ # 三格必须同批跑(同模型/同任务/同参数),禁止拿历史数字拼表(beta.1 M2 约束)。
9
+
10
+ - id: agent-loop
11
+ name: '@deepseek-ai/dsh-agent-loop'
12
+ config:
13
+ agents: []
14
+ maxParallelToolCalls: 10
15
+ disabled: true
16
+ - insert:
17
+ - id: stream-agent-eval-probe
18
+ name: ../dist/entry/eval-probe.js
19
+ inject: []
20
+ config:
21
+ announce: true
22
+ - id: stream-agent-state
23
+ name: ../dist/entry/state-handle.js
24
+ inject: [storage]
25
+ config:
26
+ unit: tfAgentState
27
+ - id: stream-agent-obs-broker
28
+ name: ../dist/entry/obs-broker.js
29
+ inject: [tools, state]
30
+ config: {}
31
+ - id: stream-agent-action-gate
32
+ name: ../dist/entry/action-gate.js
33
+ inject: [tools, storage]
34
+ config: {}
35
+ - id: stream-agent-context-render
36
+ name: ../dist/entry/context-render.js
37
+ inject: []
38
+ config: {}
39
+ - id: stream-agent
40
+ name: ../dist/entry/loop.js
41
+ inject: [llm, tools, agents, sessions, sessionProjections]
42
+ config:
43
+ announceTakeover: true
44
+ maxParallelToolCalls: 3
45
+ maxReentries: 8
46
+ streamIdleTimeoutMs: 60000
47
+ enableCode: true
@@ -0,0 +1,54 @@
1
+ # 评测对照臂:本插件全量接管 + 中立探针
2
+ #
3
+ # 对照 = patches/takeover.yml 的接管 + 四个 sidecar entry(生产形态)+ eval-probe
4
+ # (两臂同装的测量仪器,只读透传)。基线臂见 patches/eval-baseline.yml;
5
+ # 任务集、seed、探针两臂逐字节相同——控制变量红线。
6
+ #
7
+ # dsh --profile headless --patch <本文件> headless "<任务文本>"
8
+ # env DSH_EVAL_PROBE_DIR=<每任务每臂独立目录> (runner 设置)
9
+ # env STREAM_LOOP_EVAL_DUMP=<dir>/driver- (驱动器 turn-end snapshot,M3 权威口径)
10
+
11
+ - id: agent-loop
12
+ name: '@deepseek-ai/dsh-agent-loop'
13
+ config:
14
+ agents: []
15
+ maxParallelToolCalls: 10
16
+ disabled: true
17
+ - insert:
18
+ - id: stream-agent
19
+ name: ../dist/entry/loop.js
20
+ inject: [llm, tools, agents, sessions, sessionProjections]
21
+ config:
22
+ announceTakeover: true
23
+ maxParallelToolCalls: 3
24
+ maxReentries: 8
25
+ streamIdleTimeoutMs: 60000
26
+ # K1(0.3.0):评测对照臂随默认装配(tf-code 关闭)。三格对照另用
27
+ # eval-stream-code-on.yml(A-1a)/ eval-stream-code-off.yml(A-1b)。
28
+ enableCode: false
29
+ - id: stream-agent-state
30
+ name: ../dist/entry/state-handle.js
31
+ inject: [storage]
32
+ config:
33
+ unit: tfAgentState
34
+ announce: true
35
+ - id: stream-agent-obs-broker
36
+ name: ../dist/entry/obs-broker.js
37
+ inject: [tools, state]
38
+ config:
39
+ announce: true
40
+ - id: stream-agent-action-gate
41
+ name: ../dist/entry/action-gate.js
42
+ inject: [tools, storage]
43
+ config:
44
+ announce: true
45
+ - id: stream-agent-context-render
46
+ name: ../dist/entry/context-render.js
47
+ inject: []
48
+ config:
49
+ announce: true
50
+ - id: stream-agent-eval-probe
51
+ name: ../dist/entry/eval-probe.js
52
+ inject: []
53
+ config:
54
+ announce: true
@@ -0,0 +1,42 @@
1
+ # 开发/调试形态入口:--patch 顶层叠加,接管内建 loop
2
+ #
3
+ # dsh --profile headless --patch <本文件绝对路径> headless "<任务>"
4
+ #
5
+ # 与根目录 cordis.patch.yml 语义一致(停内建 agent-loop + 挂本插件 loop),
6
+ # 差别只在挂载方式:本文件随命令叠加,不进 profile、不改用户配置,验证完即失效。
7
+ # 相对路径以本文件所在目录为 baseUrl,因此这里写 ../dist/。
8
+ #
9
+ # announceTakeover: true 在 stderr 打一行接管横幅——patch 激活对 CLI 是静默的,
10
+ # 接管与否只能靠插件自证或 session log 对账。
11
+
12
+ - id: agent-loop
13
+ name: '@deepseek-ai/dsh-agent-loop'
14
+ config:
15
+ agents: []
16
+ maxParallelToolCalls: 10
17
+ disabled: true
18
+ - insert:
19
+ # 控制栏先挂载(横幅由 takeover 事件触发,不依赖装载顺序);loop 最后。
20
+ # 本文件是最小接管形态:不带四个 sidecar(工具守卫 / 上下文回验 / state 句柄缺席),
21
+ # 但 loop 与控制页照常工作——control.json 与模式预设是同一份事实源。
22
+ - id: stream-agent-control-bar
23
+ name: ../dist/entry/control-bar.js
24
+ inject: []
25
+ config:
26
+ announce: true
27
+ # 桌面控制页:独立子包(dsh.client 只能由单一包源声明);webServer 由内部可选等待。
28
+ - id: stream-agent-ui
29
+ name: ../ui/index.js
30
+ inject: []
31
+ - id: stream-agent
32
+ name: ../dist/entry/loop.js
33
+ # inject 在 patch 行必须显式声明(loader 读 entry.options.inject,
34
+ # cordis-plugin-loader/lib/index.js:768——模块导出的 inject 不进 patch 行)
35
+ # 可选服务(ptcRuntime / loader / sessionProjections)不进 inject 数组:
36
+ # 数组在 Cordis 里是"必需",缺席会把 entry 挂起(v0.2.1 修复)。
37
+ inject: [llm, tools, agents, sessions, sessionProjections]
38
+ config:
39
+ announceTakeover: true
40
+ maxParallelToolCalls: 3
41
+ maxReentries: 8
42
+ streamIdleTimeoutMs: 30000
@@ -0,0 +1,23 @@
1
+ # 测试专用组合:用离线假模型驱动单流,跑 mock E2E(开发用)
2
+ #
3
+ # 生产 preset.yml 绝不引用 mock-provider;这里把桩 loop 与假模型单独装起来,
4
+ # 全链路(driver / parser / gate / blob / ledger)零 API 调用可测。
5
+ # 场景数据在 test/scenarios/*.json,代码与数据分离。
6
+ #
7
+ # 方言与其它 patch 相同:新增行必须写在 insert: 下;停用既有行用裸 "- id: X"。
8
+ # 相对路径以本文件所在目录为 baseUrl,因此写 ../dist/。
9
+
10
+ - id: agent-loop
11
+ name: '@deepseek-ai/dsh-agent-loop'
12
+ config:
13
+ agents: []
14
+ maxParallelToolCalls: 10
15
+ disabled: true
16
+
17
+ # 新增行:离线假模型适配器(provider 路由 'mock',注册 registerAdapter + F10 目录条目)
18
+ - insert:
19
+ - id: mock-provider
20
+ name: ../dist/entry/mock-provider.js
21
+ config:
22
+ provider: mock
23
+ scenarios: []
@@ -0,0 +1,39 @@
1
+ # preset-stream 独立 bundle(S4)——随包交付,profile 组合中列在主 bundle 之后。
2
+ #
3
+ # 只列映射工具(会话可见工具 = 映射清单;未列工具 0 调用):
4
+ # tf-write/tf-read/tf-edit/tf-append → dsh-tool-fs 的 write/read/edit(applyPatch 开启给 tf-append 的 EOF 追加)
5
+ # tf-bash → dsh-tool-pwsh(Windows)/ dsh-tool-bash(POSIX,二选一)
6
+ # tf-grep/tf-glob → dsh-tool-fs-search 的 grep/glob
7
+ #
8
+ # 不列 persona / agent-instructions / time-context / plan-mode / compaction 等行:
9
+ # 它们由宿主或主 bundle 处理,preset 重复声明只会增加装配面(S4 约束)。
10
+ # 本 bundle 不碰 agent-loop、不接管 loop——那只在主 bundle 的 cordis.patch.yml。
11
+ #
12
+ # registry 默认值不在这里改:那是 profile patch 层的覆盖声明(见 profiles/stream/cordis.patch.yml),
13
+ # 这样 headless 组合(无 registry)不引入本行也不会悬空。
14
+
15
+ - insert:
16
+ - id: preset-stream
17
+ name: '@deepseek-ai/dsh-agent-preset'
18
+ inject: [agentPresets]
19
+ config:
20
+ id: stream
21
+ name: Stream
22
+ description: dsh-stream-agent 单流协议专用工具面(write/read/edit/append + shell + grep/glob)
23
+ order: 99
24
+ plugins:
25
+ - id: tool-fs
26
+ name: '@deepseek-ai/dsh-tool-fs'
27
+ config:
28
+ # tf-append(无 anchor)的 EOF 追加走宿主 apply_patch(*** End of File 锚)
29
+ applyPatch: true
30
+ - id: tool-fs-search
31
+ name: '@deepseek-ai/dsh-tool-fs-search'
32
+ config:
33
+ sampleOverCapGlobResults: false
34
+ - id: tool-bash
35
+ name: '@deepseek-ai/dsh-tool-bash'
36
+ disabled: !!js process.platform === 'win32'
37
+ - id: tool-pwsh
38
+ name: '@deepseek-ai/dsh-tool-pwsh'
39
+ disabled: !!js process.platform !== 'win32'
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@hugesb/dsh-stream-agent-preset-stream",
3
+ "version": "0.3.1",
4
+ "private": true,
5
+ "description": "S4 preset-stream 独立 bundle:只声明 stream preset 的映射工具面(write/read/edit/pwsh/bash/grep/glob)。不进主 bundle patch——B 形态安装(装进既有 profile)不得污染其 preset 列表。",
6
+ "type": "module",
7
+ "dsh": {
8
+ "manifestVersion": 1,
9
+ "bundle": {
10
+ "patch": "./cordis.patch.yml"
11
+ }
12
+ }
13
+ }