@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,179 @@
1
+ /** Atomic per-Agent tool mask, Codex adapter replacement, prompt override, and defer overlay installer. */
2
+ import { scopeOf, scopeParentOf } from '@deepseek-ai/dsh-scope';
3
+ import { effectiveToolAction, legacyToolAction } from "../contracts/tool-policy-contract.js";
4
+ import { matchesPromptRevision } from "../presets/preset-prompt-catalog.js";
5
+ import { registerCodexExecAndPlan } from "../tools/exec-plan-tools.js";
6
+ import { ACTIVATE_TOOLS_NAME, readDefaultDeferredTools, readDefaultHiddenTools, yieldDeferredToolsOverlay } from "./deferred-tools.js";
7
+ import { codexToolMetadata } from "./tool-capabilities.js";
8
+ /**
9
+ * Install only through an exact Agent scope. Replacement is deliberately limited
10
+ * to builtin source names: arbitrary tools, argument adapters, and third-party
11
+ * name-specific tools/pre-execute policy are not made equivalent by this overlay.
12
+ */
13
+ export function installOverlay(agent, rule, legacyCapabilities, preparedPrompts, onDispose) {
14
+ if (scopeOf(agent.ctx) !== agent) {
15
+ throw new Error('codex-tool-policy: an exact Agent scope is required');
16
+ }
17
+ if (preparedPrompts !== undefined && (scopeParentOf(agent) !== preparedPrompts.scope
18
+ || !matchesPromptRevision(agent.ctx, rule.preset, preparedPrompts)))
19
+ throw new Error('preset-prompt-revision-mismatch');
20
+ const tools = agent.ctx.get('tools');
21
+ if (tools === undefined)
22
+ throw new Error('codex-tool-policy: the Agent has no tools service');
23
+ const upstream = scopeParentOf(agent);
24
+ for (const choice of rule.tools ?? []) {
25
+ if (tools.get(choice.name, agent) === undefined) {
26
+ throw new Error(`codex-tool-policy: unknown or unavailable source tool ${JSON.stringify(choice.name)} in explicit choice`);
27
+ }
28
+ }
29
+ for (const tool of [...rule.allow ?? [], ...rule.deny ?? [], ...rule.tools?.map(choice => choice.name) ?? []]) {
30
+ const visible = tools.get(tool, agent);
31
+ if (visible !== undefined && tools.get(tool, upstream) !== visible) {
32
+ throw new Error(`codex-tool-policy: cannot restrict Agent-local tool ${JSON.stringify(tool)}`);
33
+ }
34
+ }
35
+ // Explicit source choices override both legacy masks and category defaults.
36
+ // They can widen this rule's own allowlist, never another owner's restriction.
37
+ const allow = rule.allow === undefined ? undefined : new Set(rule.allow);
38
+ const deny = new Set(rule.deny);
39
+ let hasDeny = rule.deny !== undefined;
40
+ for (const choice of rule.tools ?? []) {
41
+ if (choice.action === 'hide') {
42
+ deny.add(choice.name);
43
+ hasDeny = true;
44
+ allow?.delete(choice.name);
45
+ }
46
+ else {
47
+ deny.delete(choice.name);
48
+ allow?.add(choice.name);
49
+ }
50
+ }
51
+ const defaultHiddenSet = readDefaultHiddenTools(agent.ctx, agent);
52
+ for (const hiddenName of defaultHiddenSet ?? []) {
53
+ const visible = tools.get(hiddenName, agent);
54
+ if (visible !== undefined && tools.get(hiddenName, upstream) === visible
55
+ && !rule.tools?.some(choice => choice.name === hiddenName)) {
56
+ deny.add(hiddenName);
57
+ hasDeny = true;
58
+ allow?.delete(hiddenName);
59
+ }
60
+ }
61
+ const defaultDeferredSet = readDefaultDeferredTools(agent.ctx, agent);
62
+ const actionFor = (name) => {
63
+ const definition = tools.get(name, agent);
64
+ const codexTool = definition === undefined ? undefined : codexToolMetadata(definition);
65
+ return effectiveToolAction(rule, name, {
66
+ legacyCapabilities,
67
+ ...(codexTool === undefined ? {} : { codexTool }),
68
+ ...(defaultDeferredSet?.has(name) ? { defaultDeferred: true } : {}),
69
+ });
70
+ };
71
+ // Preserve an old replacement whose shared Codex capability was off: its
72
+ // source stays hidden, but no unavailable adapter is installed. Explicit
73
+ // per-source replacements bypass that compatibility baseline as one plan.
74
+ for (const name of ['bash', 'pwsh', 'todo_write', 'edit', 'write']) {
75
+ const oldAction = legacyToolAction(rule, name);
76
+ if (tools.get(name, agent) !== undefined
77
+ && (oldAction === 'codex-exec' || oldAction === 'codex-plan' || oldAction === 'codex-patch')
78
+ && actionFor(name) === 'hide') {
79
+ deny.add(name);
80
+ hasDeny = true;
81
+ allow?.delete(name);
82
+ }
83
+ }
84
+ const mask = {
85
+ ...(allow === undefined ? {} : { allow: [...allow] }),
86
+ ...(!hasDeny ? {} : { deny: [...deny] }),
87
+ };
88
+ const permitted = (tool) => (allow === undefined || allow.has(tool)) && !deny.has(tool);
89
+ const shells = ['bash', 'pwsh'].filter(tool => actionFor(tool) === 'codex-exec'
90
+ && permitted(tool) && tools.get(tool, agent) !== undefined);
91
+ const plan = actionFor('todo_write') === 'codex-plan'
92
+ && permitted('todo_write') && tools.get('todo_write', agent) !== undefined;
93
+ const patches = ['edit', 'write'].filter(tool => actionFor(tool) === 'codex-patch'
94
+ && permitted(tool) && tools.get(tool, agent) !== undefined);
95
+ const sources = [...shells, ...(plan ? ['todo_write'] : []), ...patches];
96
+ const deferredDefinitions = tools.definitions(upstream).filter(definition => definition.name !== ACTIVATE_TOOLS_NAME
97
+ && actionFor(definition.name) === 'defer'
98
+ && permitted(definition.name)
99
+ && !sources.includes(definition.name)
100
+ && tools.get(definition.name, agent) !== undefined);
101
+ for (const tool of sources) {
102
+ const definition = tools.get(tool, agent);
103
+ // `when` is registration-owned and cannot be copied from a ToolDefinition.
104
+ // Without a step toolSet, executable() rejects every conditional registration.
105
+ if (tools.executable(tool, agent) !== definition) {
106
+ throw new Error(`codex-tool-policy: cannot replace conditional source tool ${JSON.stringify(tool)}; its activation condition must not be discarded`);
107
+ }
108
+ if (tools.get(tool, upstream) !== definition) {
109
+ throw new Error(`codex-tool-policy: cannot replace Agent-local source tool ${JSON.stringify(tool)}`);
110
+ }
111
+ }
112
+ for (const definition of deferredDefinitions) {
113
+ if (tools.executable(definition.name, agent) !== definition) {
114
+ throw new Error(`codex-tool-policy: cannot defer conditional source tool ${JSON.stringify(definition.name)}; its activation condition must not be discarded`);
115
+ }
116
+ if (tools.get(definition.name, upstream) !== definition) {
117
+ throw new Error(`codex-tool-policy: cannot defer Agent-local source tool ${JSON.stringify(definition.name)}`);
118
+ }
119
+ }
120
+ const additions = [
121
+ ...(shells.length > 0 ? ['exec_command', 'write_stdin'] : []),
122
+ ...(plan ? ['update_plan'] : []),
123
+ ...(patches.length > 0 ? ['apply_patch'] : []),
124
+ ...(deferredDefinitions.length > 0 ? [ACTIVATE_TOOLS_NAME] : []),
125
+ ];
126
+ for (const tool of additions) {
127
+ if (tools.get(tool, agent) !== undefined) {
128
+ throw new Error(`codex-tool-policy: replacement tool ${JSON.stringify(tool)} already exists; refusing to shadow another implementation`);
129
+ }
130
+ }
131
+ if (shells.length > 0 && agent.ctx.get('shell') === undefined) {
132
+ throw new Error('codex-tool-policy: builtin shell replacement requires the mounted shell capability');
133
+ }
134
+ if (patches.length > 0 && agent.ctx.get('fs') === undefined) {
135
+ throw new Error('codex-tool-policy: builtin file-edit replacement requires the mounted fs capability');
136
+ }
137
+ const needsPrompt = sources.length > 0 || deferredDefinitions.length > 0 || (preparedPrompts?.sections.length ?? 0) > 0;
138
+ const systemPrompt = needsPrompt ? agent.ctx.get('systemPrompt') : undefined;
139
+ if (needsPrompt && systemPrompt === undefined) {
140
+ throw new Error('codex-tool-policy: replacements require the mounted systemPrompt service');
141
+ }
142
+ const guidance = [
143
+ ...(shells.length === 0 ? [] : [`For this Agent, ${shells.join('/')} is replaced by exec_command and write_stdin. Follow their current schemas; command status uses exit_code (rendered as Process exited with code N), not the old shell status markers.`]),
144
+ ...(plan ? ['For this Agent, todo_write is replaced by update_plan. Follow its current schema; at most one plan item may be in_progress.'] : []),
145
+ ...(patches.length === 0 ? [] : [`For this Agent, ${patches.join('/')} is replaced by apply_patch. Edit or create files with Codex Begin/End Patch hunks instead of calling ${patches.join('/')}.`]),
146
+ ].join('\n');
147
+ // These registrations and the helper have synchronous disposers. Yield exact
148
+ // effects so a later refusal rolls back every earlier mask before it escapes.
149
+ const dispose = agent.ctx.effect(function* () {
150
+ yield onDispose;
151
+ for (const section of preparedPrompts?.sections ?? [])
152
+ yield systemPrompt.section(section);
153
+ if (mask.allow !== undefined || mask.deny !== undefined)
154
+ yield tools.restrict(mask);
155
+ // Own registrations are exempt from restrict(). Never leave an unhidden
156
+ // Agent-local source alongside a newly granted Codex capability.
157
+ for (const tool of mask.deny ?? []) {
158
+ if (tools.get(tool, agent) !== undefined) {
159
+ throw new Error(`codex-tool-policy: cannot hide Agent-local tool ${JSON.stringify(tool)}`);
160
+ }
161
+ }
162
+ if (sources.length > 0) {
163
+ yield tools.restrict({ deny: sources });
164
+ for (const tool of sources) {
165
+ if (tools.get(tool, agent) !== undefined) {
166
+ throw new Error(`codex-tool-policy: cannot hide Agent-local source tool ${JSON.stringify(tool)}`);
167
+ }
168
+ }
169
+ yield registerCodexExecAndPlan(agent.ctx, { terminal: shells.length > 0, plan, patch: patches.length > 0,
170
+ capabilityAuthority: { terminalToolsEnabled: shells.length > 0, planToolEnabled: plan, patchToolEnabled: patches.length > 0 } });
171
+ yield systemPrompt.section({ name: 'codex:tool-policy', order: 1015, text: guidance });
172
+ }
173
+ if (deferredDefinitions.length > 0) {
174
+ yield* yieldDeferredToolsOverlay(tools, systemPrompt, deferredDefinitions, agent);
175
+ }
176
+ }, `codex-tool-policy:${rule.preset}`);
177
+ return () => { void dispose(); };
178
+ }
179
+ //# sourceMappingURL=overlay-installer.js.map
@@ -0,0 +1,94 @@
1
+ /** Schema, choice validation, and rule detaching for `codex-tool-policy`. */
2
+ import z from '@deepseek-ai/schemastery';
3
+ import type { ToolPolicyRule } from '../contracts/tool-policy-contract.ts';
4
+ export interface Config {
5
+ /** Empty by default: no preset or existing Agent is changed implicitly. */
6
+ rules?: readonly ToolPolicyRule[];
7
+ }
8
+ export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
9
+ rules: z<({
10
+ preset?: string | null;
11
+ allow?: string[] | null;
12
+ deny?: string[] | null;
13
+ replaceShell?: boolean | null;
14
+ replacePlan?: boolean | null;
15
+ replacePatch?: boolean | null;
16
+ tools?: ({
17
+ name?: string | null;
18
+ action?: "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer" | null;
19
+ } & import("@deepseek-ai/cosmokit").Dict)[] | null;
20
+ promptOverrides?: ({
21
+ name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
22
+ text?: string | null;
23
+ } & import("@deepseek-ai/cosmokit").Dict)[] | null;
24
+ } & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
25
+ preset: z<string, string, "defined">;
26
+ allow: z<string[], string[], "plain">;
27
+ deny: z<string[], string[], "plain">;
28
+ replaceShell: z<boolean, boolean, "defined">;
29
+ replacePlan: z<boolean, boolean, "defined">;
30
+ replacePatch: z<boolean, boolean, "defined">;
31
+ tools: z<({
32
+ name?: string | null;
33
+ action?: "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer" | null;
34
+ } & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
35
+ name: z<string, string, "defined">;
36
+ action: z<"codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer", "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer", "defined">;
37
+ }>>[], "plain">;
38
+ promptOverrides: z<({
39
+ name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
40
+ text?: string | null;
41
+ } & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
42
+ name: z<"deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "defined">;
43
+ text: z<string, string, "defined">;
44
+ }>>[], "plain">;
45
+ }>>[], "defined">;
46
+ }>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
47
+ rules: z<({
48
+ preset?: string | null;
49
+ allow?: string[] | null;
50
+ deny?: string[] | null;
51
+ replaceShell?: boolean | null;
52
+ replacePlan?: boolean | null;
53
+ replacePatch?: boolean | null;
54
+ tools?: ({
55
+ name?: string | null;
56
+ action?: "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer" | null;
57
+ } & import("@deepseek-ai/cosmokit").Dict)[] | null;
58
+ promptOverrides?: ({
59
+ name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
60
+ text?: string | null;
61
+ } & import("@deepseek-ai/cosmokit").Dict)[] | null;
62
+ } & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
63
+ preset: z<string, string, "defined">;
64
+ allow: z<string[], string[], "plain">;
65
+ deny: z<string[], string[], "plain">;
66
+ replaceShell: z<boolean, boolean, "defined">;
67
+ replacePlan: z<boolean, boolean, "defined">;
68
+ replacePatch: z<boolean, boolean, "defined">;
69
+ tools: z<({
70
+ name?: string | null;
71
+ action?: "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer" | null;
72
+ } & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
73
+ name: z<string, string, "defined">;
74
+ action: z<"codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer", "codex-exec" | "codex-plan" | "codex-patch" | "keep" | "hide" | "defer", "defined">;
75
+ }>>[], "plain">;
76
+ promptOverrides: z<({
77
+ name?: "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base" | null;
78
+ text?: string | null;
79
+ } & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
80
+ name: z<"deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "deployment:persona-prefix" | "deployment:persona-suffix" | "codex:base", "defined">;
81
+ text: z<string, string, "defined">;
82
+ }>>[], "plain">;
83
+ }>>[], "defined">;
84
+ }>>>, "volatile">;
85
+ /** Loader activations receive a volatile reference; direct callers may pass plain rules. */
86
+ export type ToolPolicyConfigSource = Config | ReturnType<typeof Config>;
87
+ export interface ResolvedRule extends ToolPolicyRule {
88
+ readonly replaceShell: boolean;
89
+ readonly replacePlan: boolean;
90
+ readonly replacePatch: boolean;
91
+ }
92
+ /** Validate direct callers too, and detach configuration from later form mutations. */
93
+ export declare function resolveRules(config: Config): ReadonlyMap<string, ResolvedRule>;
94
+ //# sourceMappingURL=rule-resolver.d.ts.map
@@ -0,0 +1,114 @@
1
+ /** Schema, choice validation, and rule detaching for `codex-tool-policy`. */
2
+ import z from '@deepseek-ai/schemastery';
3
+ import { PRESET_PROMPT_NAMES } from "../contracts/ui-contracts.js";
4
+ import { ACTIVATE_TOOLS_NAME } from "./deferred-tools.js";
5
+ // Root volatility keeps saving future-Agent rules from unloading live overlays.
6
+ export const Config = z.object({
7
+ rules: z.array(z.object({
8
+ preset: z.string().required().description('Exact preset id; only Agents created after this plugin loads are affected.'),
9
+ // Bare Schemastery arrays default to []; a union preserves omitted masks.
10
+ allow: z.union([z.array(z.string())]).description('Inherited source names to keep. Omit for no allowlist; [] removes all inherited tools, including file tools.'),
11
+ deny: z.union([z.array(z.string())]).description('Inherited source names to remove; unknown and Agent-local names are rejected.'),
12
+ replaceShell: z.boolean().default(true).description('Legacy default: replace permitted builtin bash/pwsh with exec_command/write_stdin. Explicit source choices override it; third-party name-specific policy is not transferred.'),
13
+ replacePlan: z.boolean().default(true).description('Legacy default: replace permitted builtin todo_write with update_plan; explicit source choices override it.'),
14
+ replacePatch: z.boolean().default(false).description('Legacy default: replace permitted builtin edit/write with apply_patch; explicit source choices override it.'),
15
+ tools: z.union([z.array(z.object({
16
+ name: z.string().required().description('Exact inherited source tool name.'),
17
+ action: z.union([z.const('keep'), z.const('hide'), z.const('defer'), z.const('codex-exec'), z.const('codex-plan'), z.const('codex-patch')]).required()
18
+ .description('Per-tool override: keep/hide/defer any inherited tool; codex-exec only for bash/pwsh, codex-plan only for todo_write, and codex-patch only for edit/write.'),
19
+ }))]).description('Individual source choices, overriding allow/deny and legacy replacement defaults. Omission preserves legacy behavior.'),
20
+ promptOverrides: z.union([z.array(z.object({
21
+ name: z.union(PRESET_PROMPT_NAMES.map(name => z.const(name))).required(),
22
+ text: z.string().max(1_000_000).required(),
23
+ }))]).description('Exact current-preset prompt replacements. Order, interpolation and complete semantics remain Host-owned.'),
24
+ })).default([]),
25
+ }).volatile();
26
+ /** Reject ambiguous/unsupported overrides before any Agent registrations change. */
27
+ function resolveToolChoices(input) {
28
+ if (input === undefined)
29
+ return undefined;
30
+ if (!Array.isArray(input))
31
+ throw new TypeError('codex-tool-policy: tools must be an array of source choices');
32
+ const seen = new Set();
33
+ const choices = [];
34
+ for (const choice of input) {
35
+ if (choice === null || typeof choice !== 'object'
36
+ || typeof choice.name !== 'string' || choice.name.trim().length === 0) {
37
+ throw new TypeError('codex-tool-policy: every tool choice requires a non-empty source name');
38
+ }
39
+ if (seen.has(choice.name)) {
40
+ throw new Error(`codex-tool-policy: duplicate tool choice ${JSON.stringify(choice.name)}`);
41
+ }
42
+ seen.add(choice.name);
43
+ if (!['keep', 'hide', 'defer', 'codex-exec', 'codex-plan', 'codex-patch'].includes(choice.action)) {
44
+ throw new TypeError(`codex-tool-policy: invalid action for source tool ${JSON.stringify(choice.name)}`);
45
+ }
46
+ if (choice.action === 'defer' && choice.name === ACTIVATE_TOOLS_NAME) {
47
+ throw new Error(`codex-tool-policy: cannot defer reserved tool ${JSON.stringify(ACTIVATE_TOOLS_NAME)}`);
48
+ }
49
+ if (choice.action === 'codex-exec' && choice.name !== 'bash' && choice.name !== 'pwsh'
50
+ || choice.action === 'codex-plan' && choice.name !== 'todo_write'
51
+ || choice.action === 'codex-patch' && choice.name !== 'edit' && choice.name !== 'write') {
52
+ throw new Error(`codex-tool-policy: unsupported replacement ${JSON.stringify(choice.action)} for source tool ${JSON.stringify(choice.name)}`);
53
+ }
54
+ choices.push({ name: choice.name, action: choice.action });
55
+ }
56
+ return choices;
57
+ }
58
+ function resolvePromptChoices(input) {
59
+ if (input === undefined)
60
+ return undefined;
61
+ if (!Array.isArray(input) || input.length > PRESET_PROMPT_NAMES.length)
62
+ throw new Error('invalid-preset-prompt-overrides');
63
+ const seen = new Set();
64
+ return input.map(value => {
65
+ if (value === null || typeof value !== 'object' || !PRESET_PROMPT_NAMES.includes(value.name)
66
+ || typeof value.text !== 'string' || value.text.length > 1_000_000
67
+ || Object.keys(value).some(key => key !== 'name' && key !== 'text') || seen.has(value.name)) {
68
+ throw new Error('invalid-preset-prompt-override');
69
+ }
70
+ seen.add(value.name);
71
+ return { name: value.name, text: value.text };
72
+ });
73
+ }
74
+ /** Validate direct callers too, and detach configuration from later form mutations. */
75
+ export function resolveRules(config) {
76
+ const input = config.rules ?? [];
77
+ if (!Array.isArray(input))
78
+ throw new TypeError('codex-tool-policy: rules must be an array');
79
+ const rules = new Map();
80
+ for (const rule of input) {
81
+ if (rule === null || typeof rule !== 'object'
82
+ || typeof rule.preset !== 'string' || rule.preset.trim().length === 0) {
83
+ throw new TypeError('codex-tool-policy: every rule requires a non-empty preset id');
84
+ }
85
+ if (rules.has(rule.preset))
86
+ throw new Error(`codex-tool-policy: duplicate preset rule ${JSON.stringify(rule.preset)}`);
87
+ for (const key of ['allow', 'deny']) {
88
+ const names = rule[key];
89
+ if (names !== undefined && (!Array.isArray(names)
90
+ || names.some(tool => typeof tool !== 'string' || tool.trim().length === 0))) {
91
+ throw new TypeError(`codex-tool-policy: ${key} must be an array of non-empty tool names`);
92
+ }
93
+ }
94
+ for (const key of ['replaceShell', 'replacePlan', 'replacePatch']) {
95
+ if (rule[key] !== undefined && typeof rule[key] !== 'boolean') {
96
+ throw new TypeError(`codex-tool-policy: ${key} must be a boolean`);
97
+ }
98
+ }
99
+ const choices = resolveToolChoices(rule.tools);
100
+ const prompts = resolvePromptChoices(rule.promptOverrides);
101
+ rules.set(rule.preset, {
102
+ preset: rule.preset,
103
+ ...(rule.allow === undefined ? {} : { allow: [...rule.allow] }),
104
+ ...(rule.deny === undefined ? {} : { deny: [...rule.deny] }),
105
+ replaceShell: rule.replaceShell !== false,
106
+ replacePlan: rule.replacePlan !== false,
107
+ replacePatch: rule.replacePatch === true,
108
+ ...(choices === undefined ? {} : { tools: choices }),
109
+ ...(prompts === undefined ? {} : { promptOverrides: prompts }),
110
+ });
111
+ }
112
+ return rules;
113
+ }
114
+ //# sourceMappingURL=rule-resolver.js.map
@@ -0,0 +1,33 @@
1
+ /** Host-only ownership marks and the optional Agent-snapshot availability seam. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import type { Agent } from '@deepseek-ai/dsh-agent';
4
+ import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
5
+ import type { ScopeKey } from '@deepseek-ai/dsh-scope';
6
+ import type { AssembleContext } from '@deepseek-ai/dsh-system-prompt';
7
+ import type { CodexSettings } from '../contracts/settings.ts';
8
+ import type { CodexToolMetadata, LegacyCapabilities } from '../contracts/tool-policy-contract.ts';
9
+ export interface CodexToolPolicyResolver {
10
+ /** Undefined means an older, unsnapshotted Agent retains the compatibility path. */
11
+ enabled(agent: Agent, name: string, metadata: CodexToolMetadata): boolean | undefined;
12
+ hasPromptOverride?(scope: ScopeKey, name: string): boolean;
13
+ }
14
+ declare module '@deepseek-ai/dsh-system-prompt' {
15
+ interface AssembleContext {
16
+ /** Read-only own-plugin probe: do not reapply obsolete Codex prompt preferences. */
17
+ codexPresetPromptProbe?: true;
18
+ }
19
+ }
20
+ /** Only our old presentation hooks consume this; registrations remain provider-owned. */
21
+ export declare function hasPresetPromptOverride(ctx: Context, context: AssembleContext, name: string): boolean;
22
+ declare module '@deepseek-ai/cordis' {
23
+ interface Context {
24
+ codexToolPolicy: CodexToolPolicyResolver;
25
+ }
26
+ }
27
+ export declare function markCodexTool<T extends ToolDefinition>(definition: T, metadata: CodexToolMetadata): T;
28
+ export declare function codexToolMetadata(definition: ToolDefinition): CodexToolMetadata | undefined;
29
+ /** Read once for a new Agent or catalog. No caller keeps the live preference object. */
30
+ export declare function readLegacyCapabilities(ctx: Context): Readonly<Required<LegacyCapabilities>>;
31
+ export declare function codexToolEnabled(ctx: Context, agent: Agent | undefined, name: string, metadata: CodexToolMetadata, fallback: () => CodexSettings, authority?: boolean): boolean;
32
+ export declare function assertCapabilityEnabled(ctx: Context, current: () => CodexSettings, toolName: string, agent: Agent | undefined, metadata: CodexToolMetadata, authority?: boolean): void;
33
+ //# sourceMappingURL=tool-capabilities.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { CODEX_SETTINGS_ENTRY, CODEX_SETTINGS_NAMESPACE, readHostSettings } from "../contracts/settings.js";
2
+ // Core and policy are bundled separately. A global symbol survives that boundary;
3
+ // matching an unmarked third-party tool by name would not establish ownership.
4
+ const OWNED_TOOL = Symbol.for('@shuind/dsh-codex-harness:tool-capability:v1');
5
+ const CAPABILITIES = ['terminalToolsEnabled', 'planToolEnabled', 'patchToolEnabled'];
6
+ /** Only our old presentation hooks consume this; registrations remain provider-owned. */
7
+ export function hasPresetPromptOverride(ctx, context, name) {
8
+ if (context.codexPresetPromptProbe === true)
9
+ return ['deployment:persona-prefix', 'deployment:persona-suffix', 'codex:base'].includes(name);
10
+ return context.scope !== undefined && ctx.get('codexToolPolicy')?.hasPromptOverride?.(context.scope, name) === true;
11
+ }
12
+ export function markCodexTool(definition, metadata) {
13
+ Object.defineProperty(definition, OWNED_TOOL, { value: Object.freeze({ ...metadata }) });
14
+ return definition;
15
+ }
16
+ export function codexToolMetadata(definition) {
17
+ const value = definition[OWNED_TOOL];
18
+ if (value === null || typeof value !== 'object')
19
+ return undefined;
20
+ const data = value;
21
+ if (!CAPABILITIES.includes(data.capability) || typeof data.presetEnabled !== 'boolean'
22
+ || data.presetOverridesLegacy !== undefined && typeof data.presetOverridesLegacy !== 'boolean')
23
+ return undefined;
24
+ return { capability: data.capability, presetEnabled: data.presetEnabled,
25
+ ...(data.presetOverridesLegacy === undefined ? {} : { presetOverridesLegacy: data.presetOverridesLegacy }) };
26
+ }
27
+ /** Read once for a new Agent or catalog. No caller keeps the live preference object. */
28
+ export function readLegacyCapabilities(ctx) {
29
+ const current = readHostSettings(ctx, CODEX_SETTINGS_NAMESPACE);
30
+ return Object.freeze(Object.fromEntries(CAPABILITIES.map(key => [key, current?.[key] ?? CODEX_SETTINGS_ENTRY[key]])));
31
+ }
32
+ export function codexToolEnabled(ctx, agent, name, metadata, fallback, authority) {
33
+ if (!metadata.presetEnabled)
34
+ return false;
35
+ // Only a successfully compiled adapter plan supplies this authority.
36
+ if (authority !== undefined)
37
+ return authority;
38
+ const decision = agent === undefined ? undefined : ctx.get('codexToolPolicy')?.enabled(agent, name, metadata);
39
+ return decision ?? fallback()[metadata.capability] !== false;
40
+ }
41
+ export function assertCapabilityEnabled(ctx, current, toolName, agent, metadata, authority) {
42
+ if (!codexToolEnabled(ctx, agent, toolName, metadata, current, authority)) {
43
+ throw new Error(`${toolName}: disabled in Codex Harness plugin settings`);
44
+ }
45
+ }
46
+ //# sourceMappingURL=tool-capabilities.js.map
@@ -1,8 +1,8 @@
1
1
  /** Host-side activity projection for the Codex status line. */
2
2
  import type { Context } from '@deepseek-ai/cordis';
3
3
  import { z, type ZodType } from 'zod';
4
- import type { CodexActivity } from './activity-types.ts';
5
- export type { CodexActivity } from './activity-types.ts';
4
+ import type { CodexActivity } from '../contracts/ui-contracts.ts';
5
+ export type { CodexActivity } from '../contracts/ui-contracts.ts';
6
6
  /** Long-running Codex activities currently surfaced to the client. */
7
7
  export type CodexActivityState = CodexActivity | null;
8
8
  /** Minimal event shape needed by this projection; no compaction package import is required. */
@@ -24,9 +24,7 @@ export declare const codexActivityProjection: {
24
24
  readonly viewSchema: z.ZodType<CodexActivityState, unknown, z.core.$ZodTypeInternals<CodexActivityState, unknown>>;
25
25
  readonly view: (state: CodexActivityState) => CodexActivityState;
26
26
  };
27
- readonly schema: z.ZodType<CodexActivityState, unknown, z.core.$ZodTypeInternals<CodexActivityState, unknown>>;
28
- readonly view: (state: CodexActivityState) => CodexActivityState;
29
- readonly stateVersion: 2;
27
+ readonly stateVersion: 3;
30
28
  };
31
29
  /** Register the optional activity unit without requiring the projection seam in every assembly. */
32
30
  export declare function registerCodexActivityProjection(ctx: Context): void;
@@ -18,14 +18,48 @@ function isTokenDelta(chunk) {
18
18
  return false;
19
19
  }
20
20
  }
21
- /** Only a non-empty model delta starts the reply phase; usage and finish frames do not. */
22
- function startsModelReply(event) {
23
- if (event.type === 'assistant/message')
24
- return true;
25
- if (event.type !== 'assistant/chunk' || typeof event.data !== 'object' || event.data === null)
26
- return false;
27
- const chunk = event.data.chunk;
28
- return chunk !== undefined && isTokenDelta(chunk);
21
+ /** Read packed v2 streams without importing a helper absent from older DSH packages. */
22
+ function streamReplyTime(stream) {
23
+ for (const value of stream) {
24
+ if (typeof value !== 'object' || value === null)
25
+ continue;
26
+ const record = value;
27
+ if (record.type === 'chunk') {
28
+ if (record.chunk !== undefined && isTokenDelta(record.chunk))
29
+ return record.time;
30
+ continue;
31
+ }
32
+ if (record.type !== 'text-chunks' && record.type !== 'reasoning-chunks' && record.type !== 'tool-call-chunks')
33
+ continue;
34
+ const fragments = record.type === 'tool-call-chunks' ? record.args : record.texts;
35
+ if (fragments === undefined || record.time0 === undefined)
36
+ continue;
37
+ let time = record.time0;
38
+ for (const [index, text] of fragments.entries()) {
39
+ if (index > 0)
40
+ time += record.dt?.[index - 1] ?? 0;
41
+ if (text !== '' || (record.type === 'tool-call-chunks' && record.name !== undefined))
42
+ return time;
43
+ }
44
+ }
45
+ return undefined;
46
+ }
47
+ /** Only a non-empty delta starts the reply phase; preserve its original stream time. */
48
+ function modelReplyTime(event) {
49
+ const data = typeof event.data === 'object' && event.data !== null
50
+ ? event.data
51
+ : undefined;
52
+ if (event.type === 'assistant/chunk') {
53
+ return data?.chunk !== undefined && isTokenDelta(data.chunk) ? event.time : undefined;
54
+ }
55
+ if (event.type === 'assistant/message' || event.type === 'assistant/attempt') {
56
+ if (data?.stream !== undefined)
57
+ return streamReplyTime(data.stream);
58
+ // Legacy/non-streaming adapters did not carry a packed stream on settlement.
59
+ if (event.type === 'assistant/message')
60
+ return event.time;
61
+ }
62
+ return undefined;
29
63
  }
30
64
  /** Persisted and wire shape of the Codex activity value. */
31
65
  export const codexActivitySchema = z.union([
@@ -41,12 +75,6 @@ export const codexActivitySchema = z.union([
41
75
  activity: z.literal('model-reply'),
42
76
  startedAt: z.number().int().nonnegative(),
43
77
  }),
44
- // Accepted for rolling upgrades: an older Codex host may still send this
45
- // ambiguous state until its projection definition is refreshed.
46
- z.object({
47
- activity: z.literal('awaiting-model'),
48
- startedAt: z.number().int().nonnegative(),
49
- }),
50
78
  z.null(),
51
79
  ]);
52
80
  /** Pure event fold, exported so its reset and reference-stability rules can be tested directly. */
@@ -56,18 +84,17 @@ export function applyCodexActivity(state, event) {
56
84
  if (event.type === 'step/start' || event.type === 'llm/retry-started') {
57
85
  return { activity: 'requesting-model', startedAt: event.time };
58
86
  }
59
- if (startsModelReply(event)
60
- && (state?.activity === 'requesting-model' || state?.activity === 'awaiting-model')) {
61
- return { activity: 'model-reply', startedAt: event.time };
87
+ if (state?.activity === 'requesting-model') {
88
+ const startedAt = modelReplyTime(event);
89
+ if (startedAt !== undefined)
90
+ return { activity: 'model-reply', startedAt };
62
91
  }
63
92
  if (event.type === 'turn/start' || event.type === 'turn/end' || event.type === 'compaction/end')
64
93
  return null;
65
94
  // Keep the line through reasoning and streamed output. It is the only
66
95
  // visible indication that the model is still progressing; tool cards have
67
96
  // their own status, so a tool dispatch retires this ambient line.
68
- if ((state?.activity === 'requesting-model'
69
- || state?.activity === 'model-reply'
70
- || state?.activity === 'awaiting-model')
97
+ if ((state?.activity === 'requesting-model' || state?.activity === 'model-reply')
71
98
  && (event.type === 'llm/retry'
72
99
  || event.type === 'tool/call'
73
100
  || event.type === 'step/end'))
@@ -83,16 +110,13 @@ export const codexActivityProjection = {
83
110
  viewSchema: codexActivitySchema,
84
111
  view: (state) => state,
85
112
  },
86
- // Keep the old projection contract working for DSH bundles that predate
87
- // the `stateSchema`/`wire` split.
88
- schema: codexActivitySchema,
89
- view: (state) => state,
90
- stateVersion: 2,
113
+ stateVersion: 3,
91
114
  };
92
115
  /** Register the optional activity unit without requiring the projection seam in every assembly. */
93
116
  export function registerCodexActivityProjection(ctx) {
94
- ctx.inject(['sessionProjections'], (projectionCtx) => {
95
- projectionCtx.sessionProjections.register(codexActivityProjection);
117
+ ctx.inject(['sessionProjections'], async (projectionCtx) => {
118
+ // Await readiness, but do not return the new ProjectionHandle as a Cordis effect.
119
+ await projectionCtx.sessionProjections.register(codexActivityProjection);
96
120
  });
97
121
  }
98
122
  //# sourceMappingURL=activity.js.map
@@ -0,0 +1,22 @@
1
+ export interface DesktopPresetRow {
2
+ id: string;
3
+ name: string;
4
+ group?: boolean;
5
+ disabled?: boolean | {
6
+ __jsExpr: string;
7
+ };
8
+ config?: Record<string, unknown> | DesktopPresetRow[];
9
+ isolate?: Record<string, boolean>;
10
+ }
11
+ export interface DesktopPresetDefinition {
12
+ id: string;
13
+ name?: string;
14
+ description?: string;
15
+ order?: number;
16
+ plugins: DesktopPresetRow[];
17
+ }
18
+ /** Convert the legacy file composition to Harness 0.2.2's declarative preset APIs. */
19
+ export declare function desktopCodexPreset(sourceDirectory: string, id?: string): DesktopPresetDefinition;
20
+ /** Build the experimental asymmetric hybrid Codex preset declaration. */
21
+ export declare function desktopCodexHybridPreset(sourceDirectory: string): DesktopPresetDefinition;
22
+ //# sourceMappingURL=desktop-preset.d.ts.map