@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
@@ -1,337 +1,104 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /** Browser controls for Codex requests and the editable operating prompt. */
3
- import { useEffect, useLayoutEffect, useRef, useState } from 'react';
4
- import { createPortal } from 'react-dom';
5
- import { CODEX_CONTEXT_MAX, CODEX_CONTEXT_UNIT, isCodexPresetId } from "../context.js";
2
+ /** Browser controls, /compact decorator, and live activity line for Codex Harness. */
3
+ import { useEffect, useState } from 'react';
4
+ import { OPENAI_CODEX_PROVIDER } from "../contracts/ui-contracts.js";
6
5
  import { modelActivity, sameModelActivity } from "./activity.js";
7
- import presetEditorRemote from "../preset-editor-remote.js";
8
- import { PresetManagerCard } from "./preset-manager.js";
9
- import { presetEn, presetZh } from "./preset-copy.js";
6
+ import presetEditorRemote from "../contracts/preset-editor-schema.js";
7
+ import { toolPolicyEn, toolPolicyZh } from "./tool-policy.js";
8
+ import { ContextWindowControl, isGptModelName, pillStyle, useModelDirectory } from "./preset-manager.js";
9
+ export { ContextWindowControl };
10
+ function notifyCompactError(sessions, sessionId, text) {
11
+ const actx = sessions.scope?.(sessionId);
12
+ actx?.get?.('conversation')?.input?.for?.(actx)?.notify?.('error', text);
13
+ }
10
14
  const NS = 'codex';
11
- const SETTINGS_NAMESPACE = 'codex';
12
15
  const FAST_FALLBACK_SLOT = 'conversation.input.right';
13
- const LEGACY_OVERLAY_SLOT = 'conversation.input.overlay';
14
- const PLUGIN_SETTINGS_SLOT = 'settings.plugin.item';
15
- const DEFAULT_CONTEXT_WINDOW = 262_144;
16
16
  const en = {
17
- ...presetEn,
17
+ ...toolPolicyEn,
18
18
  fast: 'Fast mode',
19
+ fastModeControl: 'Show fast mode control',
20
+ contextWindowControl: 'Show context window control',
19
21
  fastOn: 'Fast mode on (priority tier)',
20
22
  fastOff: 'Fast mode off',
21
23
  fastStateOn: 'On',
22
24
  fastStateOff: 'Off',
23
25
  contextSize: 'Context size',
24
- contextSizeDescription: 'Next request capacity in K tokens.',
25
- contextRestore: 'Restore model default',
26
- promptCardTitle: 'Codex Harness',
27
- promptCardDescription: 'Edit presets, Codex capabilities, and the operating prompt. Activity status is global.',
28
- otherCapabilitiesLabel: 'Global capabilities',
29
- capabilityPrompt: 'Codex operating prompt',
30
- capabilityPromptHint: 'Inject the editable instructions and persona-first prompt layout.',
26
+ contextShortDefault: 'Ctx',
27
+ contextDefaultOption: 'Default',
28
+ contextCustomPlaceholder: '≥16k (e.g. 64)',
29
+ contextApply: 'Set',
31
30
  compactRemote: 'Remote compaction',
32
31
  compactRemoteHint: 'Use the provider remote compaction endpoint first.',
33
32
  compactLocal: 'Local compaction',
34
33
  compactLocalHint: 'Use the DSH text-summary compaction engine directly.',
35
- capabilityTerminal: 'Terminal tools',
36
- capabilityTerminalHint: 'Expose exec_command and write_stdin.',
37
- capabilityPatch: 'Patch tool',
38
- capabilityPatchHint: 'Expose apply_patch, using the native Responses grammar when supported.',
39
- capabilityPlan: 'Plan tool',
40
- capabilityPlanHint: 'Expose update_plan for implementation task tracking.',
41
- capabilityWebSearch: 'Hosted web search',
42
- capabilityWebSearchHint: 'Use the provider-native Responses web_search tool when available.',
43
- capabilityCompaction: 'Remote compaction',
44
- capabilityCompactionHint: 'Prefer the provider Responses compact endpoint before local compaction.',
45
34
  capabilityActivity: 'Activity indicator',
46
- capabilityActivityHint: 'Show request, reply, and compaction status beside the conversation.',
47
- promptCustomizationLabel: 'Prompt customization',
48
- personaLabel: 'Persona',
49
- personaHint: 'Deployment identity and role. Supports {{model}} and {{cwd}}.',
50
- sourcePromptLabel: 'DSH Core source instructions',
51
- sourcePromptHint: 'Guidance about the DSH checkout and working directory. Supports {{sourceRoot}}.',
52
- webPromptLabel: 'DSH Core Web instructions',
53
- webPromptHint: 'Guidance about this Web GUI, HMR, builds, and verification. Supports {{webUrl}}.',
54
- promptRestoreAll: 'Restore all prompt defaults',
55
- promptLabel: 'Codex operating prompt',
56
- promptHint: 'This is the Codex operating prompt. Persona and DSH Core instructions are edited separately above.',
57
- promptUnsaved: 'Unsaved',
58
35
  promptDiscard: 'Discard',
59
- promptSave: 'Save',
60
36
  promptSaving: 'Saving...',
61
- promptSaveFailed: 'Could not save the prompt.',
62
- promptExpand: 'Expand settings',
63
- promptCollapse: 'Collapse settings',
64
37
  promptReadOnly: 'This settings document is read-only.',
65
38
  activityCompacting: 'Compacting context...',
66
39
  activityRequestingModel: 'Requesting model...',
67
40
  activityModelReply: 'Model replying...',
68
41
  };
69
42
  const zh = {
70
- ...presetZh,
71
- fast: 'Fast',
72
- fastOn: 'Fast mode on (priority tier)',
73
- fastOff: 'Fast mode off',
74
- fastStateOn: '\u5f00',
75
- fastStateOff: '\u5173',
76
- contextSize: '\u4e0a\u4e0b\u6587\u5927\u5c0f',
77
- contextSizeDescription: '\u8bbe\u7f6e\u4e0b\u6b21\u8bf7\u6c42\u7684\u4e0a\u4e0b\u6587\u5bb9\u91cf\uff0c\u5355\u4f4d\u4e3a K tokens\u3002',
78
- contextRestore: '\u6062\u590d\u6a21\u578b\u9ed8\u8ba4\u503c',
79
- promptCardTitle: 'Codex Harness',
80
- promptCardDescription: '\u7f16\u8f91\u9884\u8bbe\u3001Codex \u80fd\u529b\u548c\u64cd\u4f5c\u63d0\u793a\u8bcd\uff0c\u6d3b\u52a8\u72b6\u6001\u662f\u5168\u5c40\u8bbe\u7f6e\u3002',
81
- otherCapabilitiesLabel: '\u5168\u5c40\u80fd\u529b',
82
- capabilityPrompt: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
83
- capabilityPromptHint: '\u6ce8\u5165\u53ef\u7f16\u8f91\u6307\u4ee4\uff0c\u5e76\u5c06 Persona \u653e\u5728\u63d0\u793a\u8bcd\u9996\u4f4d\u3002',
84
- compactRemote: '\u8fdc\u7a0b\u538b\u7f29',
85
- compactRemoteHint: '\u4f18\u5148\u4f7f\u7528\u63d0\u4f9b\u5546\u7684\u8fdc\u7a0b\u538b\u7f29\u7aef\u70b9\u3002',
86
- compactLocal: '\u672c\u5730\u538b\u7f29',
87
- compactLocalHint: '\u76f4\u63a5\u4f7f\u7528 DSH \u6587\u672c\u6458\u8981\u538b\u7f29\u5f15\u64ce\u3002',
88
- capabilityTerminal: '\u7ec8\u7aef\u5de5\u5177',
89
- capabilityTerminalHint: '\u63d0\u4f9b exec_command \u548c write_stdin\u3002',
90
- capabilityPatch: '\u8865\u4e01\u5de5\u5177',
91
- capabilityPatchHint: '\u63d0\u4f9b apply_patch\uff0c\u5e76\u5728\u652f\u6301\u65f6\u4f7f\u7528 Responses \u539f\u751f\u8bed\u6cd5\u3002',
92
- capabilityPlan: '\u8ba1\u5212\u5de5\u5177',
93
- capabilityPlanHint: '\u63d0\u4f9b update_plan\uff0c\u7528\u4e8e\u8ddf\u8e2a\u5b9e\u65bd\u4efb\u52a1\u3002',
94
- capabilityWebSearch: '\u6258\u7ba1\u7f51\u7edc\u641c\u7d22',
95
- capabilityWebSearchHint: '\u53ef\u7528\u65f6\u4f7f\u7528\u63d0\u4f9b\u5546\u539f\u751f\u7684 Responses web_search \u5de5\u5177\u3002',
96
- capabilityCompaction: '\u8fdc\u7a0b\u4e0a\u4e0b\u6587\u538b\u7f29',
97
- capabilityCompactionHint: '\u4f18\u5148\u8c03\u7528\u63d0\u4f9b\u5546\u7684 Responses compact \u7aef\u70b9\uff0c\u5931\u8d25\u65f6\u56de\u9000\u672c\u5730\u538b\u7f29\u3002',
98
- capabilityActivity: '\u6d3b\u52a8\u72b6\u6001',
99
- capabilityActivityHint: '\u5728\u5bf9\u8bdd\u65c1\u663e\u793a\u8bf7\u6c42\u3001\u56de\u590d\u548c\u538b\u7f29\u72b6\u6001\u3002',
100
- promptCustomizationLabel: '\u63d0\u793a\u8bcd\u5b9a\u5236',
101
- personaLabel: 'Persona',
102
- personaHint: '\u5b9a\u4e49 Agent \u7684\u8eab\u4efd\u4e0e\u89d2\u8272,\u652f\u6301 {{model}} \u548c {{cwd}}。',
103
- sourcePromptLabel: 'DSH Core \u6e90\u7801\u8bf4\u660e',
104
- sourcePromptHint: '\u8bf4\u660e DSH \u6e90\u7801\u68c0\u51fa\u76ee\u5f55\u4e0e\u5de5\u4f5c\u76ee\u5f55,\u652f\u6301 {{sourceRoot}}。',
105
- webPromptLabel: 'DSH Core Web \u8bf4\u660e',
106
- webPromptHint: '\u8bf4\u660e Web GUI、HMR、\u6784\u5efa\u4e0e\u9a8c\u8bc1,\u652f\u6301 {{webUrl}}。',
107
- promptRestoreAll: '\u6062\u590d\u6240\u6709\u63d0\u793a\u8bcd\u9ed8\u8ba4\u503c',
108
- promptLabel: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
109
- promptHint: '\u8fd9\u662f Codex \u64cd\u4f5c\u63d0\u793a\u8bcd。Persona \u548c DSH Core \u8bf4\u660e\u5728\u4e0a\u65b9\u5206\u522b\u7f16\u8f91。',
110
- promptUnsaved: '\u672a\u4fdd\u5b58',
111
- promptDiscard: '\u653e\u5f03',
112
- promptSave: '\u4fdd\u5b58',
113
- promptSaving: '\u4fdd\u5b58\u4e2d...',
114
- promptSaveFailed: '\u63d0\u793a\u8bcd\u4fdd\u5b58\u5931\u8d25。',
115
- promptExpand: '\u5c55\u5f00\u8bbe\u7f6e',
116
- promptCollapse: '\u6536\u8d77\u8bbe\u7f6e',
117
- promptReadOnly: '\u5f53\u524d\u8bbe\u7f6e\u6587\u4ef6\u4e3a\u53ea\u8bfb\u3002',
118
- activityCompacting: '\u6b63\u5728\u538b\u7f29\u4e0a\u4e0b\u6587...',
119
- activityRequestingModel: '\u8bf7\u6c42\u4e2d...',
120
- activityModelReply: '\u56de\u590d\u4e2d...',
43
+ ...toolPolicyZh,
44
+ fastModeControl: '显示快速模式开关',
45
+ contextWindowControl: '显示上下文大小快捷按钮',
46
+ fast: '快速模式',
47
+ fastOn: '快速模式已开启(优先通道)',
48
+ fastOff: '快速模式已关闭',
49
+ fastStateOn: '开',
50
+ fastStateOff: '关',
51
+ contextSize: '上下文大小',
52
+ contextShortDefault: '上下文',
53
+ contextDefaultOption: '默认',
54
+ contextCustomPlaceholder: '≥16k (如 64)',
55
+ contextApply: '确定',
56
+ compactRemote: '远程压缩',
57
+ compactRemoteHint: '优先使用提供商的远程压缩端点。',
58
+ compactLocal: '本地压缩',
59
+ compactLocalHint: '直接使用 DSH 文本摘要压缩引擎。',
60
+ capabilityActivity: '活动状态',
61
+ promptDiscard: '放弃',
62
+ promptSaving: '保存中...',
63
+ promptReadOnly: '当前设置文件为只读。',
64
+ activityCompacting: '正在压缩上下文...',
65
+ activityRequestingModel: '请求中...',
66
+ activityModelReply: '回复中...',
121
67
  };
122
- function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting, }) {
123
- return (_jsxs("label", { style: {
124
- display: 'flex',
125
- alignItems: 'flex-start',
126
- gap: 12,
127
- padding: '9px 0',
128
- cursor: disabled ? 'default' : 'pointer',
129
- }, children: [_jsxs("span", { style: { flex: 1, minWidth: 0, display: 'grid', gap: 2 }, children: [_jsx("strong", { style: { fontSize: 13, fontWeight: 500 }, children: label }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 12, lineHeight: 1.45 }, children: hint })] }), _jsx("input", { type: "checkbox", role: "switch", checked: enabled, disabled: disabled, "aria-label": label, onChange: event => { void setSetting(field, event.target.checked); }, style: { marginTop: 3, accentColor: 'var(--dsw-static-blue-500)' } })] }));
130
- }
131
- /** One editor per preset; only display preferences are global. */
132
- export function PromptSettingsCard(props) {
133
- const { useSettings, setSetting, presetManager, t } = props;
134
- const snapshot = useSettings(state => state);
135
- const [open, setOpen] = useState(false);
136
- if (snapshot.status === 'unavailable')
137
- return null;
138
- return _jsxs("li", { style: { listStyle: 'none', border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 12, overflow: 'hidden' }, children: [_jsxs("button", { type: "button", "aria-expanded": open, onClick: () => setOpen(!open), style: { width: '100%', padding: 16, textAlign: 'left', border: 0, background: 'none', color: 'inherit', cursor: 'pointer' }, children: [_jsx("strong", { children: t('promptCardTitle') }), _jsx("span", { style: { float: 'right' }, children: open ? '−' : '+' }), _jsx("p", { style: { marginBottom: 0 }, children: t('promptCardDescription') })] }), open && _jsxs("div", { style: { padding: 16, borderTop: '1px solid var(--dsw-alias-border-l2)' }, children: [_jsx(PresetManagerCard, { presetManager: presetManager, t: t }), _jsxs("details", { style: { marginTop: 22, borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: 14 }, children: [_jsx("summary", { style: { cursor: 'pointer', fontWeight: 600 }, children: t('pmGlobalSettings') }), _jsx(CapabilityToggle, { field: "activityIndicatorEnabled", label: t('capabilityActivity'), hint: t('capabilityActivityHint'), enabled: snapshot.value?.activityIndicatorEnabled ?? true, disabled: !snapshot.writable, setSetting: setSetting })] })] })] });
68
+ /** Show the fallback Fast toggle only when the session uses a non-Codex-Connect GPT model. */
69
+ export function isFallbackFastEligible(snapshot, hasDirectory) {
70
+ if (!hasDirectory)
71
+ return true;
72
+ if (snapshot?.status !== 'ready' || snapshot.current === undefined)
73
+ return false;
74
+ return snapshot.current.provider !== OPENAI_CODEX_PROVIDER && isGptModelName(snapshot.current.model);
139
75
  }
140
- /** The legacy composer seat is a compact inline row, not a menu panel. */
141
- function FastModeFallback(props) {
142
- const { useSettings, setSetting, t } = props;
76
+ export function FastModeFallback(props) {
77
+ const { useSettings, setSetting, modelDirectory, t } = props;
78
+ const dirSnapshot = useModelDirectory(modelDirectory);
143
79
  const snapshot = useSettings(state => state);
144
80
  const visible = snapshot.value?.fastModeControlEnabled ?? true;
145
81
  const fast = snapshot.value?.fast ?? false;
146
- if (!visible)
82
+ if (!visible || !isFallbackFastEligible(dirSnapshot, modelDirectory !== undefined))
147
83
  return null;
148
- return (_jsxs("button", { type: "button", role: "switch", disabled: snapshot.writable === false, "aria-checked": fast, "aria-label": fast ? t('fastOn') : t('fastOff'), title: fast ? t('fastOn') : t('fastOff'), onClick: () => { void setSetting('fast', !fast); }, style: {
149
- boxSizing: 'border-box',
150
- display: 'inline-flex',
151
- alignItems: 'center',
152
- gap: 5,
153
- height: 28,
154
- border: 0,
155
- borderRadius: 7,
156
- padding: '0 6px',
157
- color: fast ? 'var(--dsw-static-blue-500)' : 'var(--dsw-alias-label-secondary)',
158
- background: fast ? 'var(--dsw-alias-interactive-bg-selected)' : 'transparent',
159
- cursor: snapshot.writable === false ? 'default' : 'pointer',
160
- font: 'inherit',
161
- fontSize: 12,
162
- lineHeight: '20px',
163
- fontWeight: fast ? 600 : 400,
164
- whiteSpace: 'nowrap',
165
- }, children: [_jsx("span", { children: t('fast') }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11 }, children: fast ? t('fastStateOn') : t('fastStateOff') })] }));
84
+ return (_jsxs("button", { type: "button", role: "switch", disabled: snapshot.writable === false, "aria-checked": fast, "aria-label": fast ? t('fastOn') : t('fastOff'), title: fast ? t('fastOn') : t('fastOff'), onClick: () => { void setSetting('fast', !fast); }, style: pillStyle(fast, snapshot.writable !== false), children: [_jsx("span", { children: t('fast') }), _jsx("span", { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 11 }, children: fast ? t('fastStateOn') : t('fastStateOff') })] }));
166
85
  }
167
- function contextWindowFromProjection(useProjection) {
168
- const pressure = useProjection('contextPressure');
169
- return pressure?.contextWindow !== undefined && pressure.contextWindow > 0
170
- ? pressure.contextWindow
171
- : DEFAULT_CONTEXT_WINDOW;
172
- }
173
- /** Settings form appended to the old host's context meter panel. */
174
- function ContextSizeControl({ contextWindow, sessionId: _sessionId, useSessions: _useSessions, useSettings, setSetting, unsetSetting, t, }) {
175
- const snapshot = useSettings(state => state);
176
- const configured = snapshot.value?.contextWindow;
177
- const maxK = CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT;
178
- const valueK = Math.min(maxK, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
179
- const setValueK = (nextK) => {
180
- if (!Number.isFinite(nextK))
181
- return;
182
- const normalizedK = Math.min(maxK, Math.max(1, Math.trunc(nextK)));
183
- const normalized = normalizedK * CODEX_CONTEXT_UNIT;
184
- if (normalized === contextWindow)
185
- void unsetSetting('contextWindow');
186
- else
187
- void setSetting('contextWindow', normalized);
188
- };
189
- return (_jsxs("div", { style: {
190
- display: 'grid',
191
- gap: 8,
192
- marginTop: 10,
193
- paddingTop: 10,
194
- borderTop: '1px solid var(--dsw-alias-border-l2)',
195
- }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [_jsx("strong", { style: { color: 'var(--dsw-alias-label-primary)', fontSize: 13 }, children: t('contextSize') }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 12, fontVariantNumeric: 'tabular-nums' }, children: [valueK, "K"] })] }), _jsx("input", { type: "range", min: 1, max: maxK, step: 1, value: valueK, disabled: snapshot.writable === false, "aria-label": t('contextSize'), onChange: event => { setValueK(Number(event.target.value)); }, style: {
196
- display: 'block',
197
- width: '100%',
198
- accentColor: 'var(--dsw-static-blue-500)',
199
- } }), _jsxs("div", { style: { display: 'grid', gap: 4 }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 6 }, children: [_jsx("input", { type: "number", min: 1, max: maxK, step: 1, value: valueK, disabled: snapshot.writable === false, "aria-label": t('contextSize'), onChange: event => { setValueK(Number(event.target.value)); }, style: {
200
- width: 68,
201
- border: '1px solid var(--dsw-alias-border-primary)',
202
- borderRadius: 6,
203
- padding: '4px 6px',
204
- color: 'var(--dsw-alias-label-primary)',
205
- background: 'var(--dsw-alias-fill-primary)',
206
- font: 'inherit',
207
- fontSize: 12,
208
- fontVariantNumeric: 'tabular-nums',
209
- } }), _jsx("span", { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 11 }, children: "K" })] }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11, lineHeight: '16px' }, children: t('contextSizeDescription') })] }), configured !== undefined && (_jsx("button", { type: "button", onClick: () => { void unsetSetting('contextWindow'); }, style: {
210
- justifySelf: 'start',
211
- border: 0,
212
- padding: 0,
213
- color: 'var(--dsw-static-blue-500)',
214
- background: 'transparent',
215
- cursor: 'pointer',
216
- font: 'inherit',
217
- fontSize: 11,
218
- }, children: t('contextRestore') }))] }));
219
- }
220
- /** Detect the host meter so the fallback does not duplicate its ring button. */
221
- function hasHostContextMeter() {
222
- if (typeof document === 'undefined')
223
- return false;
224
- return [...document.querySelectorAll('button[aria-haspopup="dialog"]')]
225
- .some(button => button.querySelectorAll('circle').length >= 2);
226
- }
227
- function useHostContextMeter() {
228
- const [available, setAvailable] = useState(false);
229
- useEffect(() => {
230
- if (typeof document === 'undefined' || document.body === null)
231
- return undefined;
232
- const refresh = () => { setAvailable(hasHostContextMeter()); };
233
- refresh();
234
- const observer = new MutationObserver(refresh);
235
- observer.observe(document.body, {
236
- subtree: true,
237
- childList: true,
238
- attributes: true,
239
- attributeFilter: ['aria-expanded'],
240
- });
241
- return () => observer.disconnect();
242
- }, []);
243
- return available;
244
- }
245
- /** Keep context configuration reachable before the host has a pressure meter. */
246
- function ContextSizeFallback({ sessionId, useSessions, useProjection, useSettings, setSetting, unsetSetting, t, }) {
247
- const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
248
- const hostMeter = useHostContextMeter();
249
- const contextWindow = contextWindowFromProjection(useProjection);
250
- const snapshot = useSettings(state => state);
251
- const configured = snapshot.value?.contextWindow;
252
- const valueK = Math.min(CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
253
- const [open, setOpen] = useState(false);
254
- const rootRef = useRef(null);
255
- useEffect(() => {
256
- if (!open)
257
- return undefined;
258
- const onPointerDown = (event) => {
259
- if (event.target instanceof Node && rootRef.current?.contains(event.target) === true)
260
- return;
261
- setOpen(false);
262
- };
263
- const onKeyDown = (event) => {
264
- if (event.key === 'Escape')
265
- setOpen(false);
266
- };
267
- document.addEventListener('pointerdown', onPointerDown);
268
- document.addEventListener('keydown', onKeyDown);
269
- return () => {
270
- document.removeEventListener('pointerdown', onPointerDown);
271
- document.removeEventListener('keydown', onKeyDown);
272
- };
273
- }, [open]);
274
- if (!isCodexPresetId(agentPreset) || hostMeter)
275
- return null;
276
- return (_jsxs("span", { ref: rootRef, style: { position: 'relative', display: 'inline-flex', alignItems: 'center' }, children: [_jsxs("button", { type: "button", "aria-label": `${t('contextSize')}: ${valueK}K`, "aria-haspopup": "dialog", "aria-expanded": open, disabled: snapshot.writable === false, title: t('contextSize'), onMouseDown: event => { event.preventDefault(); }, onClick: () => { setOpen(value => !value); }, style: {
277
- boxSizing: 'border-box',
278
- display: 'inline-flex',
279
- alignItems: 'center',
280
- gap: 3,
281
- height: 28,
282
- border: 0,
283
- borderRadius: 7,
284
- padding: '0 6px',
285
- color: configured === undefined
286
- ? 'var(--dsw-alias-label-secondary)'
287
- : 'var(--dsw-static-blue-500)',
288
- background: open ? 'var(--dsw-alias-interactive-bg-hover)' : 'transparent',
289
- cursor: snapshot.writable === false ? 'default' : 'pointer',
290
- font: 'inherit',
291
- fontSize: 12,
292
- lineHeight: '20px',
293
- fontWeight: configured === undefined ? 400 : 600,
294
- whiteSpace: 'nowrap',
295
- }, children: [_jsxs("span", { children: [valueK, "K"] }), _jsx("svg", { viewBox: "0 0 12 12", width: "12", height: "12", "aria-hidden": true, children: _jsx("path", { d: "M3 4.5 6 7.5 9 4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round" }) })] }), open && (_jsx("div", { role: "dialog", "aria-label": t('contextSize'), style: {
296
- position: 'absolute',
297
- right: 0,
298
- bottom: 'calc(100% + 8px)',
299
- zIndex: 20,
300
- boxSizing: 'border-box',
301
- width: 300,
302
- maxWidth: 'calc(100vw - 24px)',
303
- padding: '10px 12px 12px',
304
- border: '1px solid var(--dsw-alias-border-l2)',
305
- borderRadius: 10,
306
- color: 'var(--dsw-alias-label-primary)',
307
- background: 'var(--dsw-alias-bg-base)',
308
- boxShadow: 'var(--dsw-shadow-lv2)',
309
- }, children: _jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }) }))] }));
86
+ export function ComposerControls(props) {
87
+ return _jsxs(_Fragment, { children: [_jsx(ContextWindowControl, { ...props }), _jsx(FastModeFallback, { ...props })] });
310
88
  }
311
89
  function elapsedSeconds(startedAt, now) {
312
90
  return Math.max(0, Math.floor((now - startedAt) / 1_000));
313
91
  }
314
- /** Prefer the session snapshot when an older projection host only exposes null. */
92
+ /** Prefer the session snapshot when a projection has not emitted an open phase yet. */
315
93
  export function resolveActivity(projectedActivity, fallbackActivity) {
316
- if (projectedActivity?.activity === 'awaiting-model') {
317
- return {
318
- activity: fallbackActivity?.activity ?? 'requesting-model',
319
- startedAt: fallbackActivity?.startedAt ?? projectedActivity.startedAt,
320
- };
321
- }
322
94
  if (projectedActivity === null)
323
95
  return fallbackActivity ?? null;
324
96
  return projectedActivity ?? fallbackActivity ?? null;
325
97
  }
326
- export function ActivityLine({ sessionId: _sessionId, useSession, useSessions: _useSessions, useProjection, useSettings, t, position, }) {
98
+ export function ActivityLine({ sessionId: _sessionId, useSession, useSessions: _useSessions, useProjection, useSettings, t, }) {
327
99
  const settings = useSettings(state => state);
328
100
  const enabled = settings.value?.activityIndicatorEnabled ?? true;
329
- // Keep the projection seam optional: this package must still load when the
330
- // host has no session-projection registry or has not carried this key.
331
101
  const projectedActivity = useProjection('codexActivity');
332
- // The projection is the authoritative phase and clock. The session snapshot
333
- // fallback only covers the short wire gap before the next projection frame;
334
- // tool calls intentionally remain silent because their cards own the status.
335
102
  const fallbackActivity = useSession(modelActivity, sameModelActivity);
336
103
  const activity = resolveActivity(projectedActivity, fallbackActivity);
337
104
  const [now, setNow] = useState(() => Date.now());
@@ -350,164 +117,31 @@ export function ActivityLine({ sessionId: _sessionId, useSession, useSessions: _
350
117
  ? t('activityModelReply')
351
118
  : t('activityRequestingModel');
352
119
  return (_jsxs("span", { "data-codex-activity": true, "aria-live": "polite", style: {
353
- display: 'inline-flex',
120
+ boxSizing: 'border-box',
121
+ display: 'flex',
354
122
  alignItems: 'center',
355
- gap: 7,
356
- minHeight: 26,
357
- marginLeft: position === undefined ? 10 : 0,
123
+ flex: 'none',
124
+ gap: 6,
125
+ width: 'calc(100% - 2 * var(--dsh-composer-side-clearance, 16px) - 4 * var(--dsh-composer-dock-inset, 8px))',
126
+ maxWidth: 'calc(var(--dsh-composer-card-max-width, 952px) - 4 * var(--dsh-composer-dock-inset, 8px))',
127
+ minWidth: 0,
128
+ minHeight: 22,
129
+ margin: '0 auto',
130
+ padding: '0 4px',
358
131
  color: 'var(--dsw-alias-label-secondary)',
359
132
  fontSize: 12,
360
133
  lineHeight: '20px',
361
134
  whiteSpace: 'nowrap',
362
- WebkitTextFillColor: 'currentColor',
363
- ...(position === undefined ? {} : {
364
- position: 'fixed',
365
- left: position.left,
366
- top: position.top,
367
- // Keep the overlay in the conversation layer. The host composer is
368
- // sticky at z-index 7, so this follows the same occlusion rule as
369
- // the native Deep diving status instead of floating above the input.
370
- zIndex: 0,
371
- pointerEvents: 'none',
372
- }),
135
+ pointerEvents: 'none',
373
136
  }, children: [_jsx("span", { "aria-hidden": "true", style: {
374
137
  width: 5,
375
138
  height: 5,
376
139
  flex: '0 0 auto',
377
140
  borderRadius: '50%',
378
- background: 'var(--dsw-static-blue-500)',
141
+ background: 'var(--dsw-alias-brand-primary)',
379
142
  opacity: 0.55,
380
- } }), _jsx("span", { children: label }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-tertiary)' }, children: ['\u00b7', " ", elapsedSeconds(activity.startedAt, now), "s"] })] }));
381
- }
382
- function findContextMeterDialog() {
383
- const buttons = document.querySelectorAll('button[aria-haspopup="dialog"][aria-expanded="true"]');
384
- for (const button of buttons) {
385
- if (button.querySelectorAll('circle').length < 2)
386
- continue;
387
- let ancestor = button;
388
- for (let depth = 0; ancestor !== null && depth < 5; depth += 1, ancestor = ancestor.parentElement) {
389
- const dialog = ancestor.querySelector('[role="dialog"]');
390
- if (dialog !== null)
391
- return dialog;
392
- }
393
- }
394
- return null;
395
- }
396
- function isTurnStatus(status) {
397
- return status.textContent?.includes('Deep diving...') === true
398
- || status.className.toString().includes('turnStatus');
399
- }
400
- function hasLayout(status) {
401
- const rect = status.getBoundingClientRect();
402
- return rect.width > 0 && rect.height > 0;
403
- }
404
- /** Prefer the actual Core turn status over unrelated global status nodes. */
405
- export function selectTurnStatus(statuses) {
406
- const preferred = statuses.filter(isTurnStatus);
407
- return preferred.findLast(hasLayout)
408
- ?? preferred.at(-1)
409
- ?? statuses.filter(status => status.closest('[data-chat-flow]') !== null).findLast(hasLayout)
410
- ?? statuses.filter(status => status.closest('[data-chat-flow]') !== null).at(-1)
411
- ?? null;
412
- }
413
- function findTurnStatus() {
414
- return selectTurnStatus([...document.querySelectorAll('[role="status"]')]);
415
- }
416
- function useTurnStatusPosition(target) {
417
- const [position, setPosition] = useState(null);
418
- useLayoutEffect(() => {
419
- if (target === null) {
420
- setPosition(null);
421
- return undefined;
422
- }
423
- let frame;
424
- let previous = null;
425
- const update = () => {
426
- if (!target.isConnected) {
427
- return;
428
- }
429
- const rect = target.getBoundingClientRect();
430
- if (rect.width === 0 && rect.height === 0) {
431
- if (previous !== null) {
432
- previous = null;
433
- setPosition(null);
434
- }
435
- return;
436
- }
437
- const next = {
438
- left: Math.round(rect.right + 10),
439
- top: Math.round(rect.top + (rect.height - 26) / 2),
440
- };
441
- if (previous?.left === next.left && previous.top === next.top)
442
- return;
443
- previous = next;
444
- setPosition(next);
445
- };
446
- const track = () => {
447
- if (!target.isConnected) {
448
- previous = null;
449
- setPosition(null);
450
- return;
451
- }
452
- // Streaming rows can be inserted above the status without resizing the
453
- // status element itself; a ResizeObserver alone would leave the overlay
454
- // at its first position.
455
- update();
456
- frame = window.requestAnimationFrame(track);
457
- };
458
- update();
459
- frame = window.requestAnimationFrame(track);
460
- window.addEventListener('resize', update);
461
- window.addEventListener('scroll', update, true);
462
- const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(update);
463
- observer?.observe(target);
464
- return () => {
465
- if (frame !== undefined)
466
- window.cancelAnimationFrame(frame);
467
- window.removeEventListener('resize', update);
468
- window.removeEventListener('scroll', update, true);
469
- observer?.disconnect();
470
- };
471
- }, [target]);
472
- return position;
473
- }
474
- function useLegacyHostTargets() {
475
- const [targets, setTargets] = useState({ contextDialog: null, turnStatus: null });
476
- useEffect(() => {
477
- if (typeof document === 'undefined' || document.body === null)
478
- return undefined;
479
- const refresh = () => {
480
- const next = {
481
- contextDialog: findContextMeterDialog(),
482
- turnStatus: findTurnStatus(),
483
- };
484
- setTargets(current => current.contextDialog === next.contextDialog
485
- && current.turnStatus === next.turnStatus ? current : next);
486
- };
487
- refresh();
488
- const observer = new MutationObserver(refresh);
489
- observer.observe(document.body, {
490
- subtree: true,
491
- childList: true,
492
- attributes: true,
493
- attributeFilter: ['aria-expanded'],
494
- });
495
- return () => observer.disconnect();
496
- }, []);
497
- return targets;
498
- }
499
- /** Bridges plugin UI into DOM sites rendered by the legacy conversation host. */
500
- function LegacyOverlay(props) {
501
- const { sessionId, useSession, useSessions, useProjection, useSettings, setSetting, unsetSetting, t, } = props;
502
- const { contextDialog, turnStatus } = useLegacyHostTargets();
503
- const turnStatusPosition = useTurnStatusPosition(turnStatus);
504
- const contextWindow = contextWindowFromProjection(useProjection);
505
- return (_jsxs(_Fragment, { children: [contextDialog !== null && createPortal(_jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }), contextDialog, 'codex-context-size'), turnStatusPosition !== null && typeof document !== 'undefined' && document.body !== null && createPortal(_jsx(ActivityLine, { sessionId: sessionId, useSession: useSession, useSessions: useSessions, useProjection: useProjection, useSettings: useSettings, t: t, position: turnStatusPosition }), document.body, 'codex-activity')] }));
143
+ } }), _jsx("span", { style: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis' }, children: label }), _jsxs("span", { "aria-hidden": "true", style: { flex: '0 0 auto', fontVariantNumeric: 'tabular-nums' }, children: ['\u00b7', " ", elapsedSeconds(activity.startedAt, now), "s"] })] }));
506
144
  }
507
- export const inject = [
508
- 'commandUi', 'sessions', 'slots', 'locale', 'settingsScope',
509
- 'remote', 'remote.agentPresets', 'remote.settings',
510
- ];
511
145
  function createPresetManager(ctx) {
512
146
  const remote = ctx.remote;
513
147
  const ready = remote === undefined
@@ -515,41 +149,13 @@ function createPresetManager(ctx) {
515
149
  : remote.$mount(presetEditorRemote).then(dispose => {
516
150
  ctx.effect(() => () => { void dispose(); }, 'codex client: preset editor remote');
517
151
  });
518
- // Keep an unavailable optional host remote from becoming an unhandled rejection
519
- // when the settings card is never opened. The card still awaits the same promise
520
- // and renders the actual error if the user opens it.
521
152
  void ready.catch(() => { });
522
153
  return {
523
154
  remote: remote,
524
155
  ready,
525
156
  };
526
157
  }
527
- /**
528
- * The Codex editor contribution is mounted by this client entry itself. Its
529
- * namespace therefore cannot be a top-level dependency (that would make the
530
- * entry wait for the contribution it is responsible for mounting). Wait for
531
- * the namespace in a child fiber instead, and capture that protected Remote
532
- * face for the settings card.
533
- */
534
- function registerPresetSettingsCard(ctx, settings, presetManager) {
535
- const settingsPresetManager = {
536
- ...presetManager,
537
- remote: ctx.remote,
538
- };
539
- return ctx.slots.inject(PLUGIN_SETTINGS_SLOT, () => ctx.slots.register({
540
- name: PLUGIN_SETTINGS_SLOT,
541
- key: SETTINGS_NAMESPACE,
542
- locale: NS,
543
- inject: () => ({
544
- hooks: { settings },
545
- setSetting: (field, value) => settings.set(field, value),
546
- unsetSetting: (field) => settings.unset(field),
547
- presetManager: settingsPresetManager,
548
- }),
549
- }, PromptSettingsCard));
550
- }
551
- /** Mount request controls and the plugin settings card through shared slots. */
552
- export function apply(ctx) {
158
+ export function applyWithSettingsApi(ctx, api) {
553
159
  ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'codex client: dictionaries');
554
160
  const commandUi = ctx.get('commandUi');
555
161
  const sessions = ctx.get('sessions');
@@ -564,19 +170,25 @@ export function apply(ctx) {
564
170
  { id: 'remote', label: t('compactRemote'), detail: t('compactRemoteHint') },
565
171
  { id: 'local', label: t('compactLocal'), detail: t('compactLocalHint') },
566
172
  ],
567
- onSelect: async (option, session) => {
173
+ onSelect: (option, session) => {
568
174
  const live = sessionFor(session);
569
175
  if (live === undefined)
570
176
  throw new Error('this session is not materialized yet');
571
- const result = await live.command(`/compact ${option.id}`);
572
- if (!result.ok)
573
- throw new Error(`compact mode switch failed: ${result.error.code}: ${result.error.message}`);
574
- if (!result.value.matched)
575
- throw new Error('the host offers no /compact command');
177
+ void live.command(`/compact ${option.id}`).then(result => {
178
+ if (!result.ok) {
179
+ notifyCompactError(sessions, session.sessionId, `compact failed: ${result.error.code}: ${result.error.message}`);
180
+ return;
181
+ }
182
+ if (!result.value.matched) {
183
+ notifyCompactError(sessions, session.sessionId, 'the host offers no /compact command');
184
+ }
185
+ }, error => {
186
+ notifyCompactError(sessions, session.sessionId, error instanceof Error ? error.message : String(error));
187
+ });
576
188
  },
577
189
  },
578
190
  }), 'codex client: /compact mode picker');
579
- const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
191
+ const settings = api.bind(ctx);
580
192
  const presetManager = createPresetManager(ctx);
581
193
  const injected = () => ({
582
194
  hooks: { settings },
@@ -589,26 +201,21 @@ export function apply(ctx) {
589
201
  id: 'codex-fast',
590
202
  order: 0,
591
203
  locale: NS,
592
- inject: injected,
593
- }, FastModeFallback));
594
- ctx.slots.inject(FAST_FALLBACK_SLOT, () => ctx.slots.register({
595
- name: FAST_FALLBACK_SLOT,
596
- id: 'codex-context-size-fallback',
597
- order: 1,
598
- locale: NS,
599
- inject: injected,
600
- }, ContextSizeFallback));
601
- ctx.slots.inject(LEGACY_OVERLAY_SLOT, () => ctx.slots.register({
602
- name: LEGACY_OVERLAY_SLOT,
603
- id: 'codex-legacy-overlay',
604
- order: 0,
204
+ inject: (sessionId) => ({
205
+ ...injected(),
206
+ getCodexConnectScope: api.getCodexConnectScope,
207
+ modelDirectory: sessionId === undefined
208
+ ? undefined
209
+ : (ctx.get('modelDirectories'))?.directoryFor(sessionId)?.store,
210
+ }),
211
+ }, ComposerControls));
212
+ ctx.slots.inject('conversation.input.dock', () => ctx.slots.register({
213
+ name: 'conversation.input.dock',
214
+ id: 'codex-activity',
215
+ order: -100,
605
216
  locale: NS,
606
217
  inject: injected,
607
- }, LegacyOverlay));
608
- // `codexPresetEditor` is mounted by createPresetManager above. Keep its
609
- // namespace dependency local to the settings card so the main client entry
610
- // can start and perform that mount first.
611
- ctx.inject(['remote', 'remote.agentPresets', 'remote.settings', 'remote.codexPresetEditor'], settingsCtx => registerPresetSettingsCard(settingsCtx, settings, presetManager));
218
+ }, ActivityLine));
219
+ ctx.inject(['remote', 'remote.codexPresetEditor'], settingsCtx => api.register(settingsCtx, settings, presetManager));
612
220
  }
613
- export default { inject, apply };
614
221
  //# sourceMappingURL=index.js.map