@shuind/dsh-codex-harness 0.2.21 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/README.md +38 -50
  3. package/RELEASE.md +61 -0
  4. package/assets/codex.svg +5 -0
  5. package/cordis.patch.yml +181 -6
  6. package/docs/preset-library.md +33 -23
  7. package/docs/tool-policy-benchmark.json +310 -0
  8. package/docs/tool-policy.md +148 -0
  9. package/lib/client.js +4774 -2416
  10. package/lib/compact-command.js +416 -0
  11. package/lib/compaction.js +141 -12
  12. package/lib/hybrid-executor.js +1196 -0
  13. package/lib/index.js +3658 -2334
  14. package/lib/preferences.js +117 -0
  15. package/lib/tool-policy.js +2422 -0
  16. package/lib/typert.js +86 -79
  17. package/lib/types/client/activity.d.ts +33 -9
  18. package/lib/types/client/activity.js +4 -3
  19. package/lib/types/client/desktop.d.ts +67 -0
  20. package/lib/types/client/desktop.js +229 -0
  21. package/lib/types/client/index.d.ts +207 -110
  22. package/lib/types/client/index.js +99 -492
  23. package/lib/types/client/policy-drafts.d.ts +25 -0
  24. package/lib/types/client/policy-drafts.js +47 -0
  25. package/lib/types/client/policy-locale.d.ts +260 -0
  26. package/lib/types/client/policy-locale.js +357 -0
  27. package/lib/types/client/preset-manager.d.ts +38 -10
  28. package/lib/types/client/preset-manager.js +235 -185
  29. package/lib/types/client/preset-requests.d.ts +12 -0
  30. package/lib/types/client/preset-requests.js +101 -0
  31. package/lib/types/client/tool-policy.d.ts +33 -0
  32. package/lib/types/client/tool-policy.js +336 -0
  33. package/lib/types/contracts/preset-editor-schema.d.ts +78 -0
  34. package/lib/types/contracts/preset-editor-schema.js +95 -0
  35. package/lib/types/{prompt.js → contracts/prompt.js} +13 -7
  36. package/lib/types/{settings.d.ts → contracts/settings.d.ts} +11 -4
  37. package/lib/types/{settings.js → contracts/settings.js} +22 -6
  38. package/lib/types/contracts/tool-policy-contract.d.ts +63 -0
  39. package/lib/types/contracts/tool-policy-contract.js +33 -0
  40. package/lib/types/contracts/ui-contracts.d.ts +92 -0
  41. package/lib/types/contracts/ui-contracts.js +83 -0
  42. package/lib/types/entries/client.d.ts +10 -0
  43. package/lib/types/entries/client.js +10 -0
  44. package/lib/types/{compact-command.d.ts → entries/compact-command.d.ts} +2 -0
  45. package/lib/types/entries/compact-command.js +176 -0
  46. package/lib/types/{compaction.d.ts → entries/compaction.d.ts} +15 -3
  47. package/lib/types/{compaction.js → entries/compaction.js} +47 -11
  48. package/lib/types/entries/hybrid-executor.d.ts +19 -0
  49. package/lib/types/entries/hybrid-executor.js +57 -0
  50. package/lib/types/entries/index.d.ts +66 -0
  51. package/lib/types/entries/index.js +192 -0
  52. package/lib/types/entries/preferences.d.ts +11 -0
  53. package/lib/types/entries/preferences.js +16 -0
  54. package/lib/types/entries/tool-policy.d.ts +97 -0
  55. package/lib/types/entries/tool-policy.js +158 -0
  56. package/lib/types/entries/typert.host.d.ts +23 -0
  57. package/lib/types/entries/typert.host.js +24 -0
  58. package/lib/types/hybrid/codex-hybrid-executor.d.ts +44 -0
  59. package/lib/types/hybrid/codex-hybrid-executor.js +257 -0
  60. package/lib/types/hybrid/hybrid-sdk.d.ts +13 -0
  61. package/lib/types/hybrid/hybrid-sdk.js +196 -0
  62. package/lib/types/hybrid/program-calls.d.ts +28 -0
  63. package/lib/types/hybrid/program-calls.js +193 -0
  64. package/lib/types/hybrid/subcall-scheduler.d.ts +90 -0
  65. package/lib/types/hybrid/subcall-scheduler.js +343 -0
  66. package/lib/types/policy/deferred-tools.d.ts +42 -0
  67. package/lib/types/policy/deferred-tools.js +264 -0
  68. package/lib/types/policy/overlay-installer.d.ts +12 -0
  69. package/lib/types/policy/overlay-installer.js +179 -0
  70. package/lib/types/policy/rule-resolver.d.ts +94 -0
  71. package/lib/types/policy/rule-resolver.js +114 -0
  72. package/lib/types/policy/tool-capabilities.d.ts +33 -0
  73. package/lib/types/policy/tool-capabilities.js +46 -0
  74. package/lib/types/{activity.d.ts → presets/activity.d.ts} +3 -5
  75. package/lib/types/{activity.js → presets/activity.js} +51 -27
  76. package/lib/types/presets/desktop-preset.d.ts +22 -0
  77. package/lib/types/presets/desktop-preset.js +43 -0
  78. package/lib/types/presets/preset-editor.d.ts +47 -0
  79. package/lib/types/presets/preset-editor.js +81 -0
  80. package/lib/types/presets/preset-prompt-catalog.d.ts +23 -0
  81. package/lib/types/presets/preset-prompt-catalog.js +215 -0
  82. package/lib/types/presets/preset-tool-catalog.d.ts +5 -0
  83. package/lib/types/presets/preset-tool-catalog.js +58 -0
  84. package/lib/types/presets/runtime-enhancements.d.ts +45 -0
  85. package/lib/types/presets/runtime-enhancements.js +349 -0
  86. package/lib/types/presets/small-window-compaction.d.ts +15 -0
  87. package/lib/types/presets/small-window-compaction.js +121 -0
  88. package/lib/types/responses/compact-checkpoint.d.ts +27 -0
  89. package/lib/types/responses/compact-checkpoint.js +257 -0
  90. package/lib/types/responses/fetch-transport.d.ts +16 -0
  91. package/lib/types/responses/fetch-transport.js +257 -0
  92. package/lib/types/responses/remote-compact.d.ts +13 -0
  93. package/lib/types/responses/remote-compact.js +319 -0
  94. package/lib/types/responses/sse-diagnostics.d.ts +9 -0
  95. package/lib/types/responses/sse-diagnostics.js +157 -0
  96. package/lib/types/responses/wire-rewrite.d.ts +35 -0
  97. package/lib/types/responses/wire-rewrite.js +237 -0
  98. package/lib/types/tools/exec-output.d.ts +58 -0
  99. package/lib/types/tools/exec-output.js +173 -0
  100. package/lib/types/tools/exec-plan-tools.d.ts +37 -0
  101. package/lib/types/tools/exec-plan-tools.js +265 -0
  102. package/lib/types/tools/exec-runner.d.ts +21 -0
  103. package/lib/types/tools/exec-runner.js +385 -0
  104. package/lib/types/tools/patch-tool.d.ts +16 -0
  105. package/lib/types/tools/patch-tool.js +258 -0
  106. package/lib/types/{patch.d.ts → tools/patch.d.ts} +1 -1
  107. package/lib/types/{patch.js → tools/patch.js} +96 -21
  108. package/locale/en.json +6 -0
  109. package/locale/hybrid-executor/en.json +6 -0
  110. package/locale/hybrid-executor/zh.json +6 -0
  111. package/locale/tool-policy/en.json +6 -0
  112. package/locale/tool-policy/zh.json +6 -0
  113. package/locale/zh.json +6 -0
  114. package/package.json +297 -299
  115. package/presets/{codex-collaboration → codex-hybrid}/agent.cordis.yml +45 -48
  116. package/presets/codex-hybrid/preset.yml +3 -0
  117. package/scripts/benchmark-tool-policy.mjs +186 -0
  118. package/scripts/build-preset.mjs +19 -0
  119. package/scripts/clean-build.mjs +11 -0
  120. package/src/client/activity.ts +83 -0
  121. package/src/client/desktop.tsx +276 -0
  122. package/src/client/index.tsx +391 -0
  123. package/src/client/policy-drafts.ts +56 -0
  124. package/src/client/policy-locale.ts +362 -0
  125. package/src/client/preset-manager.tsx +376 -0
  126. package/src/client/preset-requests.ts +113 -0
  127. package/src/client/tool-policy.tsx +402 -0
  128. package/src/contracts/preset-editor-schema.ts +110 -0
  129. package/src/contracts/prompt.ts +66 -0
  130. package/src/contracts/settings.ts +103 -0
  131. package/src/contracts/tool-policy-contract.ts +93 -0
  132. package/src/contracts/ui-contracts.ts +173 -0
  133. package/src/entries/client.tsx +14 -0
  134. package/src/entries/compact-command.ts +256 -0
  135. package/src/entries/compaction.ts +218 -0
  136. package/src/entries/hybrid-executor.ts +76 -0
  137. package/src/entries/index.ts +298 -0
  138. package/src/entries/preferences.ts +17 -0
  139. package/src/entries/tool-policy.ts +162 -0
  140. package/src/entries/typert.host.ts +29 -0
  141. package/src/hybrid/codex-hybrid-executor.ts +310 -0
  142. package/src/hybrid/hybrid-sdk.ts +217 -0
  143. package/src/hybrid/program-calls.ts +202 -0
  144. package/src/hybrid/subcall-scheduler.ts +446 -0
  145. package/src/policy/deferred-tools.ts +331 -0
  146. package/src/policy/overlay-installer.ts +191 -0
  147. package/src/policy/rule-resolver.ts +128 -0
  148. package/src/policy/tool-capabilities.ts +88 -0
  149. package/src/presets/activity.ts +146 -0
  150. package/src/presets/desktop-preset.ts +60 -0
  151. package/src/presets/preset-editor.ts +101 -0
  152. package/src/presets/preset-prompt-catalog.ts +221 -0
  153. package/src/presets/preset-tool-catalog.ts +58 -0
  154. package/src/presets/runtime-enhancements.ts +415 -0
  155. package/src/presets/small-window-compaction.ts +166 -0
  156. package/src/responses/compact-checkpoint.ts +264 -0
  157. package/src/responses/fetch-transport.ts +290 -0
  158. package/src/responses/remote-compact.ts +393 -0
  159. package/src/responses/sse-diagnostics.ts +156 -0
  160. package/src/responses/wire-rewrite.ts +261 -0
  161. package/src/tools/exec-output.ts +211 -0
  162. package/src/tools/exec-plan-tools.ts +307 -0
  163. package/src/tools/exec-runner.ts +445 -0
  164. package/src/tools/patch-tool.ts +331 -0
  165. package/src/tools/patch.ts +328 -0
  166. package/tsconfig.json +29 -0
  167. package/tsdown.config.ts +110 -0
  168. package/lib/installer.js +0 -237
  169. package/lib/invariant.js +0 -23
  170. package/lib/types/activity-types.d.ts +0 -6
  171. package/lib/types/activity-types.js +0 -3
  172. package/lib/types/client/preset-copy.d.ts +0 -42
  173. package/lib/types/client/preset-copy.js +0 -81
  174. package/lib/types/compact-command.js +0 -79
  175. package/lib/types/context.d.ts +0 -8
  176. package/lib/types/context.js +0 -14
  177. package/lib/types/exec.d.ts +0 -46
  178. package/lib/types/exec.js +0 -365
  179. package/lib/types/index.d.ts +0 -95
  180. package/lib/types/index.js +0 -738
  181. package/lib/types/installer.d.ts +0 -27
  182. package/lib/types/installer.js +0 -146
  183. package/lib/types/invariant.d.ts +0 -16
  184. package/lib/types/invariant.js +0 -22
  185. package/lib/types/preset-contract.d.ts +0 -69
  186. package/lib/types/preset-contract.js +0 -22
  187. package/lib/types/preset-editor-remote.d.ts +0 -30
  188. package/lib/types/preset-editor-remote.js +0 -37
  189. package/lib/types/preset-editor.d.ts +0 -69
  190. package/lib/types/preset-editor.js +0 -557
  191. package/lib/types/preset-templates.d.ts +0 -36
  192. package/lib/types/preset-templates.js +0 -12
  193. package/lib/types/prompt-sections.d.ts +0 -15
  194. package/lib/types/prompt-sections.js +0 -23
  195. package/lib/types/remote.d.ts +0 -40
  196. package/lib/types/remote.js +0 -683
  197. package/lib/types/typert.host.d.ts +0 -47
  198. package/lib/types/typert.host.js +0 -99
  199. package/presets/codex-collaboration/preset.yml +0 -3
  200. /package/lib/types/{prompt.d.ts → contracts/prompt.d.ts} +0 -0
@@ -0,0 +1,310 @@
1
+ {
2
+ "generatedAt": "2026-11-17T04:35:30.142Z",
3
+ "runtimeVersion": "0.2.2-rc.1",
4
+ "node": "v24.19.0",
5
+ "platform": "win32",
6
+ "arch": "x64",
7
+ "cpu": "AMD Ryzen 9 5900HX with Radeon Graphics ",
8
+ "samples": 1200,
9
+ "methodology": {
10
+ "setup": "Real Cordis scopes, ToolsService, native executor, official FS/search/pwsh/todo tool registrations and the actual tool-policy plugin; lightweight Agent owners and preset identity table, no AgentLoop/model/OS or file I/O.",
11
+ "baseline": "Eight native capabilities: read/write/edit/apply_patch/glob/grep/pwsh/todo_write. read_image excluded because no attachment store is mounted. All other Harness tools are held outside this subset.",
12
+ "probe": "Every timing case also carries the same constant-time probe, excluded from reported model schema totals. Dispatch is unlogged outside a model step; not a full AgentLoop/logging benchmark.",
13
+ "timing": "80 warm-ups; cases interleaved per sample; performance.now microseconds. Attach: 10 warm-ups + 50 samples. Assembly capped at 600 samples.",
14
+ "tokens": "JSON schema/body and assembled section text counted with js-tiktoken o200k_base. Not a claim about gpt-6.1-sol billing, TTFT, cache hits, or task success rate.",
15
+ "wire": "Illustrative Responses function-tool mapping plus actual plugin rewrite with 16 correlated apply_patch call/results; no HTTP request.",
16
+ "limits": "No React rendering, model latency, filesystem/OS process timing, permission interaction latency or process-memory savings measured."
17
+ },
18
+ "profiles": [
19
+ {
20
+ "id": "native",
21
+ "label": "原生工具",
22
+ "tools": [
23
+ "apply_patch",
24
+ "edit",
25
+ "glob",
26
+ "grep",
27
+ "pwsh",
28
+ "read",
29
+ "todo_write",
30
+ "write"
31
+ ],
32
+ "schema": {
33
+ "utf8Bytes": 9234,
34
+ "o200kBaseTokens": 1971
35
+ },
36
+ "promptSections": {
37
+ "utf8Bytes": 1281,
38
+ "o200kBaseTokens": 261
39
+ },
40
+ "illustrativeWire": {
41
+ "utf8Bytes": 12643,
42
+ "o200kBaseTokens": 2932
43
+ },
44
+ "timings": {
45
+ "resolveAndSchemas": {
46
+ "samples": 1200,
47
+ "medianUs": 130.6000000000722,
48
+ "p95Us": 161.3000000000966,
49
+ "meanUs": 136.49433333333042
50
+ },
51
+ "assemble": {
52
+ "samples": 600,
53
+ "medianUs": 292.40000000027067,
54
+ "p95Us": 348.700000000008,
55
+ "meanUs": 299.1345000000008
56
+ },
57
+ "nativeNoIoDispatch": {
58
+ "samples": 1200,
59
+ "medianUs": 129.90000000036162,
60
+ "p95Us": 184.49999999984357,
61
+ "meanUs": 140.313000000002
62
+ },
63
+ "rewrite16PatchHistoryCalls": {
64
+ "samples": 1200,
65
+ "medianUs": 17.899999999826832,
66
+ "p95Us": 36.50000000016007,
67
+ "meanUs": 20.67441666666961
68
+ },
69
+ "agentCreatedListener": {
70
+ "samples": 50,
71
+ "medianUs": 171.8999999998232,
72
+ "p95Us": 306.999999999789,
73
+ "meanUs": 194.28600000002007
74
+ }
75
+ }
76
+ },
77
+ {
78
+ "id": "stacked",
79
+ "label": "原生与 Codex 直接叠加",
80
+ "tools": [
81
+ "apply_patch",
82
+ "edit",
83
+ "exec_command",
84
+ "glob",
85
+ "grep",
86
+ "pwsh",
87
+ "read",
88
+ "todo_write",
89
+ "update_plan",
90
+ "write",
91
+ "write_stdin"
92
+ ],
93
+ "schema": {
94
+ "utf8Bytes": 12431,
95
+ "o200kBaseTokens": 2649
96
+ },
97
+ "promptSections": {
98
+ "utf8Bytes": 1281,
99
+ "o200kBaseTokens": 261
100
+ },
101
+ "illustrativeWire": {
102
+ "utf8Bytes": 15894,
103
+ "o200kBaseTokens": 3622
104
+ },
105
+ "timings": {
106
+ "resolveAndSchemas": {
107
+ "samples": 1200,
108
+ "medianUs": 224.19999999999618,
109
+ "p95Us": 290.8999999999651,
110
+ "meanUs": 234.36800000000247
111
+ },
112
+ "assemble": {
113
+ "samples": 600,
114
+ "medianUs": 314.7000000001299,
115
+ "p95Us": 388.30000000007203,
116
+ "meanUs": 322.90416666667164
117
+ },
118
+ "nativeNoIoDispatch": {
119
+ "samples": 1200,
120
+ "medianUs": 130.40000000000873,
121
+ "p95Us": 186.40000000004875,
122
+ "meanUs": 141.40566666667334
123
+ },
124
+ "rewrite16PatchHistoryCalls": {
125
+ "samples": 1200,
126
+ "medianUs": 17.90000000028158,
127
+ "p95Us": 36.90000000005966,
128
+ "meanUs": 21.09700000001112
129
+ },
130
+ "agentCreatedListener": {
131
+ "samples": 50,
132
+ "medianUs": 170.20000000002256,
133
+ "p95Us": 298.4999999998763,
134
+ "meanUs": 194.15799999996125
135
+ }
136
+ }
137
+ },
138
+ {
139
+ "id": "balanced",
140
+ "label": "保留文件工具,替换执行与计划",
141
+ "tools": [
142
+ "apply_patch",
143
+ "edit",
144
+ "exec_command",
145
+ "glob",
146
+ "grep",
147
+ "read",
148
+ "update_plan",
149
+ "write",
150
+ "write_stdin"
151
+ ],
152
+ "schema": {
153
+ "utf8Bytes": 8287,
154
+ "o200kBaseTokens": 1750
155
+ },
156
+ "promptSections": {
157
+ "utf8Bytes": 1608,
158
+ "o200kBaseTokens": 331
159
+ },
160
+ "illustrativeWire": {
161
+ "utf8Bytes": 11714,
162
+ "o200kBaseTokens": 2715
163
+ },
164
+ "timings": {
165
+ "resolveAndSchemas": {
166
+ "samples": 1200,
167
+ "medianUs": 150.10000000006585,
168
+ "p95Us": 188.70000000003984,
169
+ "meanUs": 156.98575000000096
170
+ },
171
+ "assemble": {
172
+ "samples": 600,
173
+ "medianUs": 302.7999999999338,
174
+ "p95Us": 375.2999999999247,
175
+ "meanUs": 309.8166666666611
176
+ },
177
+ "nativeNoIoDispatch": {
178
+ "samples": 1200,
179
+ "medianUs": 131.1000000000604,
180
+ "p95Us": 193.99999999995998,
181
+ "meanUs": 143.01783333332614
182
+ },
183
+ "rewrite16PatchHistoryCalls": {
184
+ "samples": 1200,
185
+ "medianUs": 17.899999999826832,
186
+ "p95Us": 35.600000000158616,
187
+ "meanUs": 20.390166666659677
188
+ },
189
+ "agentCreatedListener": {
190
+ "samples": 50,
191
+ "medianUs": 1655.999999999949,
192
+ "p95Us": 2804.5999999999367,
193
+ "meanUs": 1893.4619999999998
194
+ }
195
+ }
196
+ },
197
+ {
198
+ "id": "minimal",
199
+ "label": "极简对照(非推荐)",
200
+ "tools": [
201
+ "apply_patch",
202
+ "exec_command",
203
+ "update_plan",
204
+ "write_stdin"
205
+ ],
206
+ "schema": {
207
+ "utf8Bytes": 4383,
208
+ "o200kBaseTokens": 928
209
+ },
210
+ "promptSections": {
211
+ "utf8Bytes": 1095,
212
+ "o200kBaseTokens": 228
213
+ },
214
+ "illustrativeWire": {
215
+ "utf8Bytes": 7720,
216
+ "o200kBaseTokens": 1873
217
+ },
218
+ "timings": {
219
+ "resolveAndSchemas": {
220
+ "samples": 1200,
221
+ "medianUs": 90.30000000007021,
222
+ "p95Us": 115.0000000000091,
223
+ "meanUs": 95.22991666666775
224
+ },
225
+ "assemble": {
226
+ "samples": 600,
227
+ "medianUs": 225.6999999999607,
228
+ "p95Us": 278.00000000002,
229
+ "meanUs": 230.8479999999969
230
+ },
231
+ "nativeNoIoDispatch": {
232
+ "samples": 1200,
233
+ "medianUs": 129.60000000020955,
234
+ "p95Us": 187.20000000030268,
235
+ "meanUs": 139.95641666666566
236
+ },
237
+ "rewrite16PatchHistoryCalls": {
238
+ "samples": 1200,
239
+ "medianUs": 17.79999999962456,
240
+ "p95Us": 36.10000000026048,
241
+ "meanUs": 20.38699999999987
242
+ },
243
+ "agentCreatedListener": {
244
+ "samples": 50,
245
+ "medianUs": 1856.0999999999694,
246
+ "p95Us": 3093.5999999996966,
247
+ "meanUs": 2075.076000000017
248
+ }
249
+ }
250
+ },
251
+ {
252
+ "id": "shadow",
253
+ "label": "同名实现替换对照",
254
+ "tools": [
255
+ "apply_patch",
256
+ "edit",
257
+ "glob",
258
+ "grep",
259
+ "pwsh",
260
+ "read",
261
+ "todo_write",
262
+ "write"
263
+ ],
264
+ "schema": {
265
+ "utf8Bytes": 9234,
266
+ "o200kBaseTokens": 1971
267
+ },
268
+ "promptSections": {
269
+ "utf8Bytes": 1281,
270
+ "o200kBaseTokens": 261
271
+ },
272
+ "illustrativeWire": {
273
+ "utf8Bytes": 12643,
274
+ "o200kBaseTokens": 2932
275
+ },
276
+ "timings": {
277
+ "resolveAndSchemas": {
278
+ "samples": 1200,
279
+ "medianUs": 131.1000000000604,
280
+ "p95Us": 165.300000000002,
281
+ "meanUs": 137.56549999999967
282
+ },
283
+ "assemble": {
284
+ "samples": 600,
285
+ "medianUs": 294.1000000000713,
286
+ "p95Us": 367.60000000003856,
287
+ "meanUs": 301.1400000000026
288
+ },
289
+ "nativeNoIoDispatch": {
290
+ "samples": 1200,
291
+ "medianUs": 130.79999999990832,
292
+ "p95Us": 186.20000000009895,
293
+ "meanUs": 141.48541666665827
294
+ },
295
+ "rewrite16PatchHistoryCalls": {
296
+ "samples": 1200,
297
+ "medianUs": 17.899999999826832,
298
+ "p95Us": 36.3999999999578,
299
+ "meanUs": 20.6273333333354
300
+ },
301
+ "agentCreatedListener": {
302
+ "samples": 50,
303
+ "medianUs": 177.70000000018626,
304
+ "p95Us": 326.0000000000218,
305
+ "meanUs": 220.47199999999066
306
+ }
307
+ }
308
+ }
309
+ ]
310
+ }
@@ -0,0 +1,148 @@
1
+ # 跨预设工具覆盖
2
+
3
+ 版本 `0.3.0`,目标运行时 DeepSeek Harness `>=0.2.2-rc.1 <=0.2.2-rc.4`。工具覆盖是独立 Host 插件,行 id 为 `codex-tool-policy`,默认 `rules: []`,不会自动改变任何预设。
4
+
5
+ ## 改什么,不改什么
6
+
7
+ 为选中的预设创建 Agent 时,插件在该 Agent 的子作用域中限制继承工具,并按配置注册 Codex 执行、计划与可选补丁工具。原预设的 Persona 和插件声明保持不变,不编辑其它预设的 YAML。调用继续走宿主的工具执行器、审批、沙箱和日志机制,真实失败仍保留。
8
+
9
+ 默认及可选替换规则:
10
+
11
+ | 原能力 | 替换后 |
12
+ | --- | --- |
13
+ | 存在且允许调用的原生 `bash` / `pwsh` | `exec_command` + `write_stdin`(默认启用) |
14
+ | 存在且允许调用的原生 `todo_write` | `update_plan`(默认启用) |
15
+ | 存在且允许调用的原生 `edit` / `write` | 可选共用 `apply_patch`(`codex-patch`,`replacePatch` 默认 `false`) |
16
+ | 任意无条件源工具 | `defer`(按需延迟加载:第 1 步隐藏并注入 `activate_tools`,激活后于下一步通过 DSH `tool-addition` + `deferLoading: true` 生效) |
17
+ | `read` / `read_image` / `apply_patch` / `glob` / `grep` | 保留原定义 |
18
+
19
+ 不存在的源能力不会凭空补上;同名目标工具冲突和无法安全保留激活条件的源工具明确拒绝,不用无条件包装掩盖问题。此适配针对当前版本原生执行与计划工具;第三方同名工具或按工具名实施的额外策略,需要单独审计。
20
+
21
+ `update_plan` 采用至多一个 `in_progress` 的计划语义,不等同于允许多个任务并行的 `todo_write`。需要并行任务列表的预设可以关闭计划替换。
22
+
23
+ 执行替换复用宿主的单次审批与沙箱策略;仅沙箱执行器展示 `sandbox_permissions` / `justification`,授权只覆盖本次原命令。拒绝、取消或缺少审批通道时不启动命令。沙箱执行器下 `tty=true` 因无法承载单次策略而明确拒绝;交互终端需求应保留原终端工具或关闭执行替换。`write_stdin` 不能给已经启动的进程升级权限。底层执行器失败和沙箱拒绝标记不会被当成成功吞掉。
24
+
25
+ ## 设置
26
+
27
+ 打开 **设置 → 内置插件 → Codex Harness**:
28
+
29
+ 1. 在“工具方案”页选择预设;目录来自该预设,不拿当前聊天的 Agent 工具表冒充。
30
+ 2. 按命令、计划、文件及其它分组选择具体工具的“不改动”“隐藏”或已支持的替代方案。分组不提供联动总开关。
31
+ 3. 检查变更摘要,点击“保存此预设”;新建或重载 Agent 后生效。
32
+
33
+ `exec_command + write_stdin` 是启动与续读的一组配套能力,作为同一个适配方案提供;其它工具没有适配器时只提供不改动/隐藏。
34
+
35
+ 切换预设会保留各自草稿,但保存只把当前预设合并入已接受的服务器规则,不顺便提交其它草稿。自己的成功提交仅在完整接受值与预期一致、其它目标基线未变时更新其它草稿版本;外部并发修改仍拒绝并保留草稿。
36
+
37
+ “运行偏好”页没有预设选择器,只管理本环境共享的请求和显示选项,没有另一组执行/计划/文件工具总闸。
38
+
39
+ “高级”提供逐工具详情、当前预设提示词和原始定义;共用所选预设,原始定义仍只读。诊断模式、入口、专用修复/旧名单编辑代码与文案已删除,不迁移到其它位置;后台仍读取旧格式,并保持正常保存校验。插件详情只保留摘要和设置路径,不再复制完整编辑器。运行组件清单保持真实,不需要逐个打开后台卡片。
40
+
41
+ - 不启用 allowlist:不增加 allow 限制。
42
+ - 启用 allowlist 且留空:显式禁止全部继承工具,不等同于省略。
43
+ - deny:额外移除名单中的继承工具。
44
+ - 合并明确的逐工具选择后,先应用有效 allow / deny,再替换仍被允许的源能力。没有单项覆盖时,仅允许 `read` 不会又补出命令或计划工具。
45
+ - 名单使用源工具名;本覆盖层新注册的工具成组出现,不能用同一条继承掩码裁掉自身新工具。未知名称、保留名称和不可裁的自身工具会报错,不静默忽略拼写问题。
46
+ - 文件工具默认原样保留,但用户显式写入 allow / deny 时仍可裁剪。工具掩码不是文件系统或进程权限隔离:允许命令工具时,不能把隐藏 `write` 当作禁止所有文件写入。
47
+
48
+ 需要独立配置 bundle 时,可覆盖已存在的插件行;以下只是配置示例,不应直接写入活动 profile 文件:
49
+
50
+ ```yaml
51
+ - id: codex-tool-policy
52
+ name: '@shuind/dsh-codex-harness/tool-policy'
53
+ config:
54
+ rules:
55
+ - preset: standard
56
+ replaceShell: false
57
+ replacePlan: false
58
+ tools:
59
+ - name: pwsh
60
+ action: codex-exec
61
+ - name: todo_write
62
+ action: keep
63
+ ```
64
+
65
+ `tools` 中每个 `{ name, action }` 是明确的逐工具选择,优先于本规则的旧 allow / deny 和大类默认;它不能解除其它插件的限制。动作包括 `keep`、`hide`、`defer`、`codex-exec`、`codex-plan`、`codex-patch`。执行适配仅接受 `bash/pwsh`,计划适配仅接受 `todo_write`,补丁适配仅接受 `edit/write`(任一或两者均映射到同一个 `apply_patch` 注册);`defer` 接受任意非条件、非 `activate_tools` 的继承源工具,并在第 1 步通过 `when` 准入与 `activate_tools` 实现与 DSH `0.2.2` `tool-addition` / `deferLoading: true` 兼容的渐进激活;未知工具、重复名称和不匹配的适配会拒绝。`replacePatch` 默认为 `false`以保留原生文件工具,如需通过大类开关替换可显式设为 `true`。
66
+
67
+ 在实验性的 `codex-hybrid` 预设中,`hybrid-executor` 默认将 `create_goal`、`get_goal`、`ralph`、`subagent_fork`、`todo_write`、`update_goal`、`workflow` 设为 `defaultDeferred`;若未显式覆写,策略层与设置界面都会将其默认显示为 `defer`,且可随时按需改为 `keep` 或 `hide`。已激活的延迟工具会在压缩完成(`compaction/end`,包含本地摘要压缩与远程加密压缩)时结算压缩前轮次热度:若连续超过 `2` 轮(`DEFERRED_RECENT_TURN_WINDOW`)未再激活或实际执行,则在压缩完成后自动收起以节省下半场 Token(压缩进行期间保持原工具集以复用前缀缓存,静态目录 `codex:deferred-tools` 保持不变)。
68
+
69
+ 新界面创建规则时显式设置两个旧类别开关为 `false`,只记录被编辑工具的选择。旧规则没有迁移,未编辑部分仍保留旧默认语义;手写逐工具规则时也应像示例一样关闭旧类别默认。示例中的工具名必须确实在所选预设的目录中。
70
+
71
+ 目录是注册快照,不是某个 Agent/model step 的准入结果。读取会暂借预设 revision 并建立只读子作用域,完成后释放;不创建 Agent,不运行工具、条件函数或模型请求。条件工具标记为条件项,禁止自动替换;会话后续动态加入的工具可能不在该快照中。
72
+
73
+ ## 当前预设的提示词
74
+
75
+ 同一预设规则可保存 `promptOverrides`,每项只包含 `{ name, text }`。目标白名单为 `deployment:persona-prefix`、`deployment:persona-suffix` 和 `codex:base`;只有当前预设实际注册且语义可核验的段才允许编辑。目录不为非 Codex 预设伪造 Codex 操作指南,也不把动态表达式当正文。
76
+
77
+ 提示词与工具属于同一预设草稿,“保存此预设”一起提交当前目标,不改其它预设或旧共享模板。移除某条覆盖恢复该段原始内容;显式空字符串与移除覆盖不同。原始声明仍只读。
78
+
79
+ 加载通过 Agent 上下文的同名提示词段注册完成,保留原段的完整模式、插值和位置。Host 卸载与 Agent 清理都拥有 disposer;不通过全局 presentation 重写抢其它插件的内容,不替换工具 schema 或宿主运行约束。无覆盖时不增加模型文本。
80
+
81
+ ## 统一作用范围与旧数据
82
+
83
+ 普通界面不再暴露共享执行/计划/patch 可用性开关。旧字段仅作为内部兼容基线读取,不自动写回 profile:旧关闭默认保持;明确的逐预设选择可覆盖该旧基线,但不能突破原预设局部禁用、其它插件限制、沙箱或审批。
84
+
85
+ Codex 自有工具通过内部元数据辨认,不把第三方同名工具误当作 Codex 能力。旧局部预设配置显式 `true` 原先优先于共享关闭,这种既有有效行为也保留。策略与旧基线一起在新 Agent 创建时抓取,后续旧共享字段变化不会突然击穿已加载的替换。
86
+
87
+ “不改动”描述本方案不改变原能力,不保证某个条件工具在所有模型和会话中均可调用。目录提供原预设启用状态及兼容上下文,界面与 Host 使用同一策略解析;未满足依赖的替换不能留下半套原生/替代状态。供应商 wire 格式仍保留旧选择,不用协议偏好二次控制工具准入。
88
+
89
+ ## 生效与撤销
90
+
91
+ Config 使用 live / volatile 更新。每个新创建的 Agent 捕获当时的规则快照;保存规则不重启插件,不改已经加载的 Agent。空白会话在开始第一轮前切换预设时,按该 Agent 捕获的快照同步撤销旧覆盖并匹配新预设。
92
+
93
+ 这里的边界是 Agent,而不只是会话文件:重启应用、恢复或重新载入会话会创建新的 Agent,因此会使用当时已保存的规则。安装插件前已经运行的 Agent 不会被追溯改造。
94
+
95
+ 禁用、卸载或实际重载插件会清理它拥有的覆盖,恢复原工具。请先让相关会话停止执行或退出,再进行此类操作;不能保证已准备但未开始的工具调用在中途卸载后继续有效。
96
+
97
+ ## 为什么不用 UI Slot 代替
98
+
99
+ 当前页面有 `tool.call.toolview`(按工具名)和 `conversation.chat.node`(整条消息)等 Slot,可以换工具卡片。它们不改变模型可见 schema、参数验证或实际执行,隐藏红色卡片也不等于修复失败。
100
+
101
+ 真正裁剪由作用域中的 `tools.restrict()` 完成,替换由工具注册完成;不篡改 `system-prompt/assemble` 中已由工具提供者管理的列表,也不在失败后静默执行另一工具。当前层的 own 注册不受继承掩码限制;对预设祖先层的裁剪必须放在 Agent 子作用域,不能把规则塞进被裁剪预设自身。
102
+
103
+ 截图里的猜错文件路径、查询未注册 Service、Client 超时以及外层测试沙箱限制,也不会因换个工具名自动消失。应分别检查路径发现、接口目录、连接状态与权限,不抹去原错误。
104
+
105
+ ## 性能测量
106
+
107
+ 运行:
108
+
109
+ ```sh
110
+ pnpm run build
111
+ pnpm run bench:tools
112
+ ```
113
+
114
+ [基准脚本](../scripts/benchmark-tool-policy.mjs) 使用当前 Cordis 作用域、工具注册表、标准 Native 执行器、官方文件/搜索/PowerShell/Todo 工具和真实覆盖插件;不发送模型请求,不执行 OS 命令,不进行文件修改。Agent owner 与预设身份表是轻量测试装配,不是完整 AgentLoop。
115
+
116
+ 基线保留 `read/write/edit/apply_patch/glob/grep/pwsh/todo_write` 八项,比较直接叠加、保留文件工具的执行/计划替换,以及仅供对照的极简方案。所有其它 Harness 工具不在这个受影响子集内,不能把该子集的节省比例当成整次请求节省比例。
117
+
118
+ 指标包括 registry schema 的 JSON 字节和 `o200k_base` 参考编码 token、带 16 对历史补丁调用的 Responses 示例 wire、提示词段,以及 `resolve + schemas`、提示词组装、无 I/O Native 调度和新 Agent 监听器的中位数 / P95。示例 wire 使用真实重写函数,但不是远端 provider 实际请求或计费记录。
119
+
120
+ [机器可读结果](tool-policy-benchmark.json) 由脚本产生。离线微基准不能证明模型首 token 延迟、任务成功率、缓存命中率或真实读写/命令速度改善。裁剪不卸载底层服务,也不等于减少整个 Host 的内存或冷启动成本。
121
+
122
+ ### 本次实测结果
123
+
124
+ 以下表格保留 `0.2.24` 的历史基准;`0.2.25`–`0.2.26` 仅调整界面,`0.2.27` 新增逐工具规则与目录,`0.2.28` 统一预设策略与界面保存范围。未重测浏览器渲染或真实模型任务,不把旧微基准直接当作新版端到端提速证据。
125
+
126
+ 2026-11-10,Windows x64,Node `v24.21.0`,Ryzen 9 5900HX;每项 1,200 次交错采样,组装 600 次,Agent 监听器 50 次,均有预热。统计仅限上述受影响工具子集,参考编码为 `o200k_base`,不是当前模型的计费 token。
127
+
128
+ | 方案 | 工具数 | schema 字节 | schema 参考 token | 工具说明段 token | 两项合计 |
129
+ | --- | ---: | ---: | ---: | ---: | ---: |
130
+ | 原生基线 | 8 | 9,234 | 1,971 | 261 | 2,232 |
131
+ | 两套直接叠加 | 11 | 12,378 | 2,632 | 261 | 2,893 |
132
+ | 保留文件工具、替换执行/计划 | 9 | 8,234 | 1,733 | 331 | 2,064 |
133
+ | 极简对照,不推荐 | 4 | 4,330 | 911 | 228 | 1,139 |
134
+
135
+ 推荐方案的 schema token 比原生基线少 **12.1%**,但加上必要的新工具说明后,净减少是该子集的 **7.5%**;相对两套直接叠加,净减少 **28.7%**。这不是整次模型请求减少的比例,未计入的其它工具、对话历史和运行时上下文仍会占用 token。工具数从 8 变 9 也能降低 schema 成本,因此不能只比较工具数量。
136
+
137
+ | 本地操作 | 原生中位数 / P95 | 推荐方案中位数 / P95 |
138
+ | --- | ---: | ---: |
139
+ | 本步准入解析 + schema | 0.128 / 0.151 ms | 0.224 / 0.257 ms |
140
+ | 提示词组装 | 0.304 / 0.372 ms | 0.314 / 0.372 ms |
141
+ | 无 I/O Native 调度 | 0.134 / 0.282 ms | 0.135 / 0.281 ms |
142
+ | 新 Agent 监听器 | 0.082 / 0.151 ms | 1.239 / 2.199 ms |
143
+
144
+ 推荐方案比基线多约 **0.096 ms / step** 的准入与 schema 开销,一次 Agent 覆盖约增加 **1.16 ms**;无 I/O 调度中位数只差约 1 微秒,本次结果不足以推断有意义的执行速度变化。现阶段主要价值是工具协议适配和上下文预算,不是本地调度提速。
145
+
146
+ 带 16 对历史补丁调用、双方使用相同 Responses 重写条件的示例 wire,基线 2,932、推荐方案 2,698 参考 token;这是确定性重写样本,不是在线请求计费或首 token 延迟。只换同名实现但 schema 不变的对照,schema 仍为 1,971 token,也未观察到明显调度差异。
147
+
148
+ 极简方案虽然更短,却失去结构化读取、搜索和直接文件编辑能力,更依赖 shell 引用、平台语法及输出处理;本插件没有默认选择它。真实模型效果仍需在相同模型、任务、缓存与权限设置下对照工具选择错误、参数错误、重试轮数、总 token 和任务成功率。