@shuind/dsh-codex-harness 0.3.1 → 0.3.3

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 (86) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +21 -43
  3. package/docs/preset-library.md +2 -2
  4. package/docs/tool-policy.md +1 -1
  5. package/lib/client.js +1738 -327
  6. package/lib/compact-command.js +7 -1
  7. package/lib/compaction.js +7 -1
  8. package/lib/hybrid-executor.js +23 -12
  9. package/lib/index.js +1266 -36
  10. package/lib/preferences.js +21 -2
  11. package/lib/tool-policy.js +11 -2
  12. package/lib/typert.js +42 -1
  13. package/lib/types/client/desktop.d.ts +20 -42
  14. package/lib/types/client/desktop.js +191 -126
  15. package/lib/types/client/index.d.ts +104 -28
  16. package/lib/types/client/index.js +97 -15
  17. package/lib/types/client/policy-drafts.d.ts +18 -0
  18. package/lib/types/client/policy-drafts.js +27 -0
  19. package/lib/types/client/policy-locale.d.ts +80 -20
  20. package/lib/types/client/policy-locale.js +197 -80
  21. package/lib/types/client/preset-manager.d.ts +25 -2
  22. package/lib/types/client/preset-manager.js +89 -5
  23. package/lib/types/client/preset-requests.d.ts +44 -1
  24. package/lib/types/client/preset-requests.js +150 -0
  25. package/lib/types/client/tool-policy.d.ts +7 -2
  26. package/lib/types/client/tool-policy.js +48 -6
  27. package/lib/types/contracts/preset-editor-schema.d.ts +35 -0
  28. package/lib/types/contracts/preset-editor-schema.js +39 -0
  29. package/lib/types/contracts/settings.d.ts +12 -0
  30. package/lib/types/contracts/settings.js +10 -1
  31. package/lib/types/contracts/ui-contracts.d.ts +52 -0
  32. package/lib/types/contracts/ui-contracts.js +58 -0
  33. package/lib/types/contracts/update.d.ts +73 -0
  34. package/lib/types/contracts/update.js +291 -0
  35. package/lib/types/entries/index.js +20 -2
  36. package/lib/types/entries/preferences.d.ts +2 -0
  37. package/lib/types/entries/preferences.js +9 -0
  38. package/lib/types/hybrid/hybrid-sdk.d.ts +1 -1
  39. package/lib/types/hybrid/hybrid-sdk.js +27 -13
  40. package/lib/types/presets/preset-editor.d.ts +13 -1
  41. package/lib/types/presets/preset-editor.js +24 -1
  42. package/lib/types/presets/pro-mode-store.d.ts +13 -0
  43. package/lib/types/presets/pro-mode-store.js +69 -0
  44. package/lib/types/responses/background-sse-codec.d.ts +23 -0
  45. package/lib/types/responses/background-sse-codec.js +230 -0
  46. package/lib/types/responses/background-stream.d.ts +28 -0
  47. package/lib/types/responses/background-stream.js +351 -0
  48. package/lib/types/responses/compact-checkpoint.js +3 -10
  49. package/lib/types/responses/fetch-transport.js +24 -9
  50. package/lib/types/responses/remote-compact.js +39 -11
  51. package/lib/types/responses/wire-rewrite.d.ts +4 -0
  52. package/lib/types/responses/wire-rewrite.js +30 -4
  53. package/lib/types/tools/codex-subagent.d.ts +14 -0
  54. package/lib/types/tools/codex-subagent.js +269 -0
  55. package/lib/types/update/checker.d.ts +14 -0
  56. package/lib/types/update/checker.js +166 -0
  57. package/locale/en.json +1 -1
  58. package/locale/hybrid-executor/en.json +1 -1
  59. package/locale/hybrid-executor/zh.json +1 -1
  60. package/locale/zh.json +1 -1
  61. package/package.json +6 -2
  62. package/src/client/desktop.tsx +370 -153
  63. package/src/client/index.tsx +122 -22
  64. package/src/client/policy-drafts.ts +45 -0
  65. package/src/client/policy-locale.ts +197 -80
  66. package/src/client/preset-manager.tsx +125 -4
  67. package/src/client/preset-requests.ts +185 -1
  68. package/src/client/tool-policy.tsx +63 -9
  69. package/src/contracts/preset-editor-schema.ts +44 -0
  70. package/src/contracts/settings.ts +20 -1
  71. package/src/contracts/ui-contracts.ts +91 -0
  72. package/src/contracts/update.ts +307 -0
  73. package/src/entries/index.ts +25 -2
  74. package/src/entries/preferences.ts +9 -0
  75. package/src/hybrid/hybrid-sdk.ts +28 -12
  76. package/src/presets/preset-editor.ts +31 -3
  77. package/src/presets/pro-mode-store.ts +80 -0
  78. package/src/responses/background-sse-codec.ts +237 -0
  79. package/src/responses/background-stream.ts +371 -0
  80. package/src/responses/compact-checkpoint.ts +2 -8
  81. package/src/responses/fetch-transport.ts +28 -9
  82. package/src/responses/remote-compact.ts +41 -11
  83. package/src/responses/wire-rewrite.ts +34 -3
  84. package/src/tools/codex-subagent.ts +290 -0
  85. package/src/update/checker.ts +193 -0
  86. package/tsdown.config.ts +4 -0
@@ -1,15 +1,18 @@
1
1
  /** Browser controls, /compact decorator, and live activity line for Codex Harness. */
2
2
  import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
3
3
  import type { Context } from '@deepseek-ai/cordis';
4
- import type { CodexActivity, CodexConnectScope, CodexConnectSnapshot, ModelDirectorySnapshot, ModelDirectoryStore } from '../contracts/ui-contracts.ts';
4
+ import type { CodexActivity, CodexConnectScope, CodexConnectSnapshot, LlmProvidersScope, ModelDirectorySnapshot, ModelDirectoryStore } from '../contracts/ui-contracts.ts';
5
+ import { HarnessUpdateStore } from '../contracts/update.ts';
6
+ import type { HarnessUpdateSnapshot } from '../contracts/update.ts';
5
7
  import { modelActivity } from './activity.ts';
6
- import { ContextWindowControl } from './preset-manager.tsx';
8
+ import { ContextWindowControl, isProModeEligible, ProModeControl } from './preset-manager.tsx';
7
9
  import type { PresetManagerActions } from './preset-manager.tsx';
8
- export { ContextWindowControl };
9
- export type { CodexConnectScope, CodexConnectSnapshot, ModelDirectorySnapshot, ModelDirectoryStore };
10
+ export { ContextWindowControl, isProModeEligible, ProModeControl };
11
+ export type { CodexConnectScope, CodexConnectSnapshot, HarnessUpdateSnapshot, ModelDirectorySnapshot, ModelDirectoryStore };
10
12
  export interface CodexSettings {
11
13
  fast: boolean;
12
14
  fastModeControlEnabled: boolean;
15
+ proModeControlEnabled: boolean;
13
16
  contextWindowControlEnabled: boolean;
14
17
  contextWindow?: number;
15
18
  persona?: string;
@@ -23,6 +26,10 @@ export interface CodexSettings {
23
26
  hostedWebSearchEnabled: boolean;
24
27
  remoteCompactionEnabled: boolean;
25
28
  activityIndicatorEnabled: boolean;
29
+ codexSubagentEnabled?: boolean;
30
+ codexSubagentModel?: string;
31
+ codexSubagentEffort?: string;
32
+ codexSubagentPreset?: string;
26
33
  }
27
34
  /** Observable ConfigForms settings snapshot shared with the desktop adapter. */
28
35
  export interface CodexSettingsSnapshot {
@@ -40,41 +47,95 @@ export interface CodexScope extends HostObservable<CodexSettingsSnapshot> {
40
47
  declare const en: {
41
48
  readonly fast: "Fast mode";
42
49
  readonly fastModeControl: "Show fast mode control";
50
+ readonly proModeControl: "Show API Pro mode control";
43
51
  readonly contextWindowControl: "Show context window control";
44
52
  readonly fastOn: "Fast mode on (priority tier)";
45
53
  readonly fastOff: "Fast mode off";
46
54
  readonly fastStateOn: "On";
47
55
  readonly fastStateOff: "Off";
56
+ readonly pro: "Pro";
57
+ readonly proOn: "Pro mode on";
58
+ readonly proOff: "Pro mode off";
48
59
  readonly contextSize: "Context size";
49
60
  readonly contextShortDefault: "Ctx";
50
61
  readonly contextDefaultOption: "Default";
51
62
  readonly contextCustomPlaceholder: "≥16k (e.g. 64)";
52
63
  readonly contextApply: "Set";
53
64
  readonly compactRemote: "Remote compaction";
54
- readonly compactRemoteHint: "Use the provider remote compaction endpoint first.";
55
- readonly compactLocal: "Local compaction";
56
- readonly compactLocalHint: "Use the DSH text-summary compaction engine directly.";
65
+ readonly compactRemoteHint: "Use provider remote compaction first.";
66
+ readonly compactLocal: "Model summary";
67
+ readonly compactLocalHint: "Compact context with a model summary.";
57
68
  readonly capabilityActivity: "Activity indicator";
58
69
  readonly promptDiscard: "Discard";
59
70
  readonly promptSaving: "Saving...";
60
- readonly promptReadOnly: "This settings document is read-only.";
71
+ readonly promptReadOnly: "Settings are read-only.";
61
72
  readonly activityCompacting: "Compacting context...";
62
73
  readonly activityRequestingModel: "Requesting model...";
63
74
  readonly activityModelReply: "Model replying...";
64
75
  readonly settingsTabLabel: "Codex Harness";
65
76
  readonly settingsToolsPage: "Preset plans";
66
- readonly settingsRuntimePage: "Runtime preferences";
77
+ readonly settingsRuntimePage: "Global settings";
78
+ readonly settingsHelpPage: "Guide";
79
+ readonly helpFaqHeading: "Quick answers";
80
+ readonly helpDeferDisabledTitle: "Why is Defer greyed out on some tools?";
81
+ readonly helpDeferDisabledDesc: "Already deferred; hide it if you’re sure you won’t use it.";
82
+ readonly helpDeferLifecycleTitle: "What is Defer for?";
83
+ readonly helpDeferLifecycleDesc: "Saves context—loaded on demand and reclaimed after context compaction.";
84
+ readonly helpNativeSearchTitle: "Prefer native search?";
85
+ readonly helpNativeSearchDesc: "On uses OpenAI built-in search (billed per search on API); off reuses subscription search.";
86
+ readonly helpConnectHeading: "Works with Codex Connect";
87
+ readonly helpRegistrationScopeTitle: "Global subscription search, images & subagent";
88
+ readonly helpRegistrationScopeDesc: "Turn on in Global settings to share Codex Connect search, image generation, and codex_subagent across all tool-capable models; override per preset.";
89
+ readonly helpProComboTitle: "API Pro + subscription subagents + subscription search";
90
+ readonly helpProComboDesc: "Use Pro plan API credits on GPT-5.6/6+ with the composer Pro toggle (only shown on API-key GPT-5.6/6+, current chat only); route subagents and web search to Codex subscription (saves API)—taste Pro freed from the web cage.";
91
+ readonly helpConnectContextTitle: "Context window & compaction sync";
92
+ readonly helpConnectContextDesc: "The composer context button syncs Codex Connect model limits; Prefer remote compaction stays in sync too.";
93
+ readonly helpConnectLinkLabel: "Companion plugin";
94
+ readonly helpUpdateHeading: "Version & updates";
95
+ readonly updateHeading: "Codex Harness update";
96
+ readonly updateBadge: "Update";
97
+ readonly updateAvailable: "Update available";
98
+ readonly updateUpToDate: "Up to date";
99
+ readonly updateChecking: "Checking…";
100
+ readonly updateUnavailable: "Check failed";
101
+ readonly updateCheckNow: "Check updates";
102
+ readonly updateOpenRelease: "View release";
103
+ readonly updateDismiss: "Dismiss update notice";
104
+ readonly updateHowTo: "Update from the DSH Plugin Market, or reinstall @shuind/dsh-codex-harness@latest.";
67
105
  readonly settingsSubTools: "Tools";
68
106
  readonly settingsPresetPrompts: "Prompts";
69
107
  readonly settingsDefinition: "YAML";
70
- readonly settingsPreferHostedSearch: "Prefer model-hosted search";
108
+ readonly settingsPreferHostedSearch: "Prefer native search";
71
109
  readonly settingsPreferRemoteCompaction: "Prefer remote compaction";
72
- readonly settingsSharedFailed: "Not saved; this page’s draft is kept. Shared settings may have changed—discard this page’s draft to reload.";
73
- readonly settingsRuntimeScope: "Shared in this environment";
74
- readonly settingsSaveRuntime: "Save runtime preferences";
110
+ readonly settingsSharedFailed: "Save failed. Settings may have changed—please try again.";
111
+ readonly settingsRuntimeScope: "Shared across all presets in this environment.";
112
+ readonly capabilitiesConnectHeading: "Subscription global registrations";
113
+ readonly capabilitiesConnectCollapsedTitle: "Codex Connect subscription features";
114
+ readonly capabilitiesConnectInstallHint: "Install Codex Connect to share subscription web search, image generation, and subagents across all models.";
115
+ readonly capabilitiesConnectNote: "Registered live via Codex Connect for all models. Adjust per preset in Preset plans.";
116
+ readonly capabilitySearchTitle: "Subscription web search";
117
+ readonly capabilitySearchNoteAll: "Reused by all models.";
118
+ readonly capabilitySearchNoteFallback: "GPT sessions prefer native search; other models reuse this.";
119
+ readonly capabilityImageTitle: "Subscription image generation";
120
+ readonly capabilityImageNote: "Registered globally for all tool-capable models.";
121
+ readonly capabilitySubagentTitle: "Subscription subagent";
122
+ readonly capabilitySubagentNote: "Registered globally so any tool-capable model can delegate tasks to a Codex subscription subagent.";
123
+ readonly capabilitySubagentModel: "Model";
124
+ readonly capabilitySubagentNoModels: "No enabled models";
125
+ readonly capabilitySubagentRestart: "Restart DSH required";
126
+ readonly capabilitySubagentEffort: "Effort";
127
+ readonly capabilitySubagentEffortDefault: "Default";
128
+ readonly capabilitySubagentPreset: "Preset";
129
+ readonly capabilitySubagentPresetHybrid: "Codex hybrid";
130
+ readonly capabilitySubagentPresetInherit: "Follow current chat";
131
+ readonly capabilityRegistered: "Registered";
132
+ readonly capabilityNotRegistered: "Not registered";
133
+ readonly capabilityUnavailable: "Codex Connect unavailable";
134
+ readonly capabilityLoading: "Loading registration status…";
135
+ readonly capabilityWriteFailed: "Failed to update registration.";
75
136
  readonly settingsBundleSummary: "Configure Codex Harness in its dedicated Settings tab.";
76
137
  readonly settingsBundlePath: "Settings → Plugins → Codex Harness";
77
- readonly settingsDefinitionAbsent: "Choose a preset on Preset plans first.";
138
+ readonly settingsDefinitionAbsent: "Choose a preset first.";
78
139
  readonly globalGroupRequest: "Model requests";
79
140
  readonly globalGroupDisplay: "Display";
80
141
  readonly globalPending: "Unsaved";
@@ -104,14 +165,22 @@ declare const en: {
104
165
  readonly toolPolicyAction: "Tool action";
105
166
  readonly toolPolicyKeep: "Enable";
106
167
  readonly toolPolicyDefer: "Defer";
107
- readonly toolPolicyDeferHint: "Defer loading until activated via activate_tools";
168
+ readonly toolPolicyDeferHint: "Load on demand via activate_tools";
108
169
  readonly toolPolicyHide: "Hide";
109
170
  readonly toolPolicyReplaceShort: "Replace";
110
- readonly toolPolicyRestoreChoice: "Restore default choice";
171
+ readonly toolPolicyRestoreChoice: "Restore default";
111
172
  readonly toolPolicyUnsupported: "Saved replacement unavailable";
112
173
  readonly toolPolicyConditional: "Conditional";
113
174
  readonly toolPolicyTargetExists: "Replacement target already exists";
114
175
  readonly toolPolicyPresetDisabled: "Disabled by original preset";
176
+ readonly toolPolicyGptHostedSearch: "GPT native search";
177
+ readonly toolPolicyGptHostedSearchTitle: "GPT sessions prefer OpenAI native search (set in Global settings).";
178
+ readonly toolPolicyGptCodexSearch: "Codex Connect";
179
+ readonly toolPolicyGptCodexSearchTitle: "Registered globally by Codex Connect (manage in Global settings).";
180
+ readonly toolPolicyGptDualSearch: "GPT native / Codex Connect";
181
+ readonly toolPolicyGptDualSearchTitle: "GPT sessions prefer native search; other models reuse Codex Connect search.";
182
+ readonly toolPolicyGptImageTitle: "Registered globally by Codex Connect (manage in Global settings).";
183
+ readonly toolPolicyGptSubagentTitle: "Registered globally using Codex Connect subscription model (manage in Global settings).";
115
184
  readonly toolPolicyCommandGroup: "Commands & runtime";
116
185
  readonly toolPolicyFileGroup: "Files & search";
117
186
  readonly toolPolicyPlanGroup: "Planning & interaction";
@@ -153,6 +222,7 @@ declare const en: {
153
222
  readonly toolLabelSubagent: "Spawn isolated subagent for a subtask";
154
223
  readonly toolLabelSubagentFork: "Fork subagent from current context";
155
224
  readonly toolLabelSubagentCodex: "Delegate task to Codex subagent";
225
+ readonly toolLabelCodexSubagent: "Delegate task to Codex subscription subagent";
156
226
  readonly toolLabelSubagentClaude: "Delegate task to Claude Code subagent";
157
227
  readonly toolLabelSubagentOar: "Run experimental OAR subagent";
158
228
  readonly toolLabelSubagentModels: "List available models for subagents";
@@ -171,8 +241,8 @@ declare const en: {
171
241
  readonly toolLabelTeamGet: "Read latest shared Team task state";
172
242
  readonly toolLabelTeamList: "List shared Team tasks and blockers";
173
243
  readonly toolLabelTeamUpdate: "Update shared Team task with revision check";
174
- readonly toolLabelWebSearch: "Search the web for current information";
175
- readonly toolLabelWebFetch: "Fetch decoded text from HTTP(S) URL";
244
+ readonly toolLabelWebSearch: "Search the web";
245
+ readonly toolLabelWebFetch: "Fetch text from HTTP(S) URL";
176
246
  readonly toolLabelSkill: "Load full instructions for a skill";
177
247
  readonly toolLabelActivateTools: "Activate deferred (deferLoading) tools";
178
248
  readonly toolLabelSchedule: "Manage scheduled tasks";
@@ -199,30 +269,30 @@ declare const en: {
199
269
  readonly toolLabelStagehandObserve: "Observe interactive page elements (Stagehand)";
200
270
  readonly toolLabelStagehandShot: "Capture browser screenshot (Stagehand)";
201
271
  readonly toolLabelStagehandTabs: "Manage browser tabs (Stagehand)";
202
- readonly toolLabelViewImage: "View local or HTTP(S) image (Codex Connect)";
203
- readonly toolLabelCodexImageGen: "Generate or edit images via GPT Image (Codex Connect)";
204
- readonly toolLabelCodexQuota: "Query shared Codex account quota (Codex Connect)";
272
+ readonly toolLabelViewImage: "View local or HTTP(S) image";
273
+ readonly toolLabelCodexImageGen: "Generate or edit images";
274
+ readonly toolLabelCodexQuota: "Query Codex account quota";
205
275
  readonly toolLabelMcpDynamic: "MCP server tool";
206
276
  readonly toolLabelOther: "Other tool";
207
277
  readonly toolPolicyToolsLoading: "Loading tools…";
208
278
  readonly toolPolicyToolsEmpty: "No registered tools.";
209
279
  readonly toolPolicyNoMatches: "No matching tools.";
210
- readonly toolPolicyToolsFailed: "Tool list unavailable. Saved rules are kept.";
280
+ readonly toolPolicyToolsFailed: "Could not load tools; saved rules are kept.";
211
281
  readonly toolPolicyToolsRefresh: "Refresh tools";
212
282
  readonly toolPolicyCatalogLoading: "Loading presets…";
213
283
  readonly toolPolicyCatalogEmpty: "No presets found.";
214
- readonly toolPolicyCatalogFailed: "Preset list unavailable. Saved IDs remain selectable.";
284
+ readonly toolPolicyCatalogFailed: "Could not load presets; saved IDs remain selectable.";
215
285
  readonly toolPolicyCatalogRetry: "Reload presets";
216
286
  readonly toolPolicyEmpty: "Choose a preset";
217
- readonly toolPolicySave: "Save preset";
287
+ readonly toolPolicySave: "Save";
218
288
  readonly toolPolicySaving: "Saving…";
219
289
  readonly toolPolicyDiscard: "Discard draft";
220
- readonly toolPolicySaved: "Preset saved.";
290
+ readonly toolPolicySaved: "Saved.";
221
291
  readonly toolPolicyInvalidPreset: "An empty preset ID cannot be saved.";
222
292
  readonly toolPolicyDuplicatePreset: "Duplicate preset IDs cannot be saved.";
223
- readonly toolPolicyRefused: "Not saved. Draft started from older settings; discard draft to reload.";
293
+ readonly toolPolicyRefused: "Save conflict. Discard draft to reload.";
224
294
  readonly toolPolicyFailed: "Save failed. Draft is kept.";
225
- readonly toolPolicyReadOnly: "These settings are read-only.";
295
+ readonly toolPolicyReadOnly: "Settings are read-only.";
226
296
  readonly pmRefresh: "Refresh";
227
297
  readonly peLoading: "Loading preset…";
228
298
  readonly peReadError: "Preset definition unavailable.";
@@ -242,8 +312,10 @@ export interface InputSettingsControlInjected {
242
312
  setSetting: (field: string, value: unknown) => Promise<void>;
243
313
  unsetSetting: (field: string) => Promise<void>;
244
314
  presetManager: PresetManagerActions;
315
+ injectedSessionId?: string | undefined;
245
316
  modelDirectory?: ModelDirectoryStore | undefined;
246
317
  getCodexConnectScope?: (() => CodexConnectScope | undefined) | undefined;
318
+ getLlmProvidersScope?: (() => LlmProvidersScope | undefined) | undefined;
247
319
  }
248
320
  type InputRightProps = Pick<PropsRuntime<'conversation.input.right'>, 'sessionId' | 'useSessions'> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
249
321
  export declare function FastModeFallback(props: InputRightProps): import("react").JSX.Element | null;
@@ -253,11 +325,15 @@ type ActivityFallback = ReturnType<typeof modelActivity>;
253
325
  /** Prefer the session snapshot when a projection has not emitted an open phase yet. */
254
326
  export declare function resolveActivity(projectedActivity: CodexActivity | null | undefined, fallbackActivity: ActivityFallback): CodexActivity | null;
255
327
  export declare function ActivityLine({ sessionId: _sessionId, useSession, useSessions: _useSessions, useProjection, useSettings, t, }: ActivityProps): import("react").JSX.Element | null;
328
+ export declare function HarnessUpdateOverlay({ updater, t }: {
329
+ updater: HarnessUpdateStore;
330
+ } & PropsLocale<'codex'>): import("react").JSX.Element | null;
256
331
  /** Mount request controls and the plugin settings card through shared slots. */
257
332
  export interface ClientSettingsApi {
258
333
  bind(ctx: Context): CodexScope;
259
334
  getCodexConnectScope?: () => CodexConnectScope | undefined;
260
- register(ctx: Context, settings: CodexScope, manager: PresetManagerActions): () => void;
335
+ getLlmProvidersScope?: () => LlmProvidersScope | undefined;
336
+ register(ctx: Context, settings: CodexScope, manager: PresetManagerActions, updateStore: HarnessUpdateStore): () => void;
261
337
  }
262
338
  export declare function applyWithSettingsApi(ctx: Context, api: ClientSettingsApi): void;
263
339
  //# sourceMappingURL=index.d.ts.map
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /** Browser controls, /compact decorator, and live activity line for Codex Harness. */
3
- import { useEffect, useState } from 'react';
3
+ import { useEffect, useState, useSyncExternalStore } from 'react';
4
4
  import { OPENAI_CODEX_PROVIDER } from "../contracts/ui-contracts.js";
5
+ import { HarnessUpdateStore, harnessUpdateNoticeKey } from "../contracts/update.js";
5
6
  import { modelActivity, sameModelActivity } from "./activity.js";
6
7
  import presetEditorRemote from "../contracts/preset-editor-schema.js";
7
8
  import { toolPolicyEn, toolPolicyZh } from "./tool-policy.js";
8
- import { ContextWindowControl, isGptModelName, pillStyle, useModelDirectory } from "./preset-manager.js";
9
- export { ContextWindowControl };
9
+ import { ContextWindowControl, isGptModelName, isProModeEligible, pillStyle, ProModeControl, useModelDirectory } from "./preset-manager.js";
10
+ export { ContextWindowControl, isProModeEligible, ProModeControl };
10
11
  function notifyCompactError(sessions, sessionId, text) {
11
12
  const actx = sessions.scope?.(sessionId);
12
13
  actx?.get?.('conversation')?.input?.for?.(actx)?.notify?.('error', text);
@@ -17,24 +18,28 @@ const en = {
17
18
  ...toolPolicyEn,
18
19
  fast: 'Fast mode',
19
20
  fastModeControl: 'Show fast mode control',
21
+ proModeControl: 'Show API Pro mode control',
20
22
  contextWindowControl: 'Show context window control',
21
23
  fastOn: 'Fast mode on (priority tier)',
22
24
  fastOff: 'Fast mode off',
23
25
  fastStateOn: 'On',
24
26
  fastStateOff: 'Off',
27
+ pro: 'Pro',
28
+ proOn: 'Pro mode on',
29
+ proOff: 'Pro mode off',
25
30
  contextSize: 'Context size',
26
31
  contextShortDefault: 'Ctx',
27
32
  contextDefaultOption: 'Default',
28
33
  contextCustomPlaceholder: '≥16k (e.g. 64)',
29
34
  contextApply: 'Set',
30
35
  compactRemote: 'Remote compaction',
31
- compactRemoteHint: 'Use the provider remote compaction endpoint first.',
32
- compactLocal: 'Local compaction',
33
- compactLocalHint: 'Use the DSH text-summary compaction engine directly.',
36
+ compactRemoteHint: 'Use provider remote compaction first.',
37
+ compactLocal: 'Model summary',
38
+ compactLocalHint: 'Compact context with a model summary.',
34
39
  capabilityActivity: 'Activity indicator',
35
40
  promptDiscard: 'Discard',
36
41
  promptSaving: 'Saving...',
37
- promptReadOnly: 'This settings document is read-only.',
42
+ promptReadOnly: 'Settings are read-only.',
38
43
  activityCompacting: 'Compacting context...',
39
44
  activityRequestingModel: 'Requesting model...',
40
45
  activityModelReply: 'Model replying...',
@@ -42,25 +47,29 @@ const en = {
42
47
  const zh = {
43
48
  ...toolPolicyZh,
44
49
  fastModeControl: '显示快速模式开关',
50
+ proModeControl: '显示 API Pro 模式开关',
45
51
  contextWindowControl: '显示上下文大小快捷按钮',
46
52
  fast: '快速模式',
47
53
  fastOn: '快速模式已开启(优先通道)',
48
54
  fastOff: '快速模式已关闭',
49
55
  fastStateOn: '开',
50
56
  fastStateOff: '关',
57
+ pro: 'Pro',
58
+ proOn: 'Pro 模式已开启',
59
+ proOff: 'Pro 模式已关闭',
51
60
  contextSize: '上下文大小',
52
61
  contextShortDefault: '上下文',
53
62
  contextDefaultOption: '默认',
54
63
  contextCustomPlaceholder: '≥16k (如 64)',
55
64
  contextApply: '确定',
56
65
  compactRemote: '远程压缩',
57
- compactRemoteHint: '优先使用提供商的远程压缩端点。',
58
- compactLocal: '本地压缩',
59
- compactLocalHint: '直接使用 DSH 文本摘要压缩引擎。',
66
+ compactRemoteHint: '优先使用服务端远程压缩。',
67
+ compactLocal: '模型摘要',
68
+ compactLocalHint: '使用模型摘要压缩上下文。',
60
69
  capabilityActivity: '活动状态',
61
70
  promptDiscard: '放弃',
62
71
  promptSaving: '保存中...',
63
- promptReadOnly: '当前设置文件为只读。',
72
+ promptReadOnly: '当前设置为只读。',
64
73
  activityCompacting: '正在压缩上下文...',
65
74
  activityRequestingModel: '请求中...',
66
75
  activityModelReply: '回复中...',
@@ -81,10 +90,10 @@ export function FastModeFallback(props) {
81
90
  const fast = snapshot.value?.fast ?? false;
82
91
  if (!visible || !isFallbackFastEligible(dirSnapshot, modelDirectory !== undefined))
83
92
  return null;
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') })] }));
93
+ 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: 12 }, children: fast ? t('fastStateOn') : t('fastStateOff') })] }));
85
94
  }
86
95
  export function ComposerControls(props) {
87
- return _jsxs(_Fragment, { children: [_jsx(ContextWindowControl, { ...props }), _jsx(FastModeFallback, { ...props })] });
96
+ return _jsxs(_Fragment, { children: [_jsx(ContextWindowControl, { ...props }), _jsx(ProModeControl, { ...props }), _jsx(FastModeFallback, { ...props })] });
88
97
  }
89
98
  function elapsedSeconds(startedAt, now) {
90
99
  return Math.max(0, Math.floor((now - startedAt) / 1_000));
@@ -150,11 +159,55 @@ function createPresetManager(ctx) {
150
159
  ctx.effect(() => () => { void dispose(); }, 'codex client: preset editor remote');
151
160
  });
152
161
  void ready.catch(() => { });
162
+ let boundRemote;
163
+ ctx.inject(['remote', 'remote.codexPresetEditor'], remoteCtx => {
164
+ boundRemote = remoteCtx.remote;
165
+ return () => { boundRemote = undefined; };
166
+ });
167
+ const resolveCodexPresetEditor = () => {
168
+ if (boundRemote !== undefined)
169
+ return boundRemote.codexPresetEditor;
170
+ const fromCtx = ctx.get?.('remote.codexPresetEditor');
171
+ if (fromCtx !== undefined)
172
+ return fromCtx;
173
+ try {
174
+ return remote?.codexPresetEditor;
175
+ }
176
+ catch {
177
+ return undefined;
178
+ }
179
+ };
180
+ const safeRemote = new Proxy((remote ?? {}), {
181
+ get(target, prop, receiver) {
182
+ if (prop === 'codexPresetEditor')
183
+ return resolveCodexPresetEditor();
184
+ return Reflect.get(target, prop, receiver);
185
+ },
186
+ });
153
187
  return {
154
- remote: remote,
188
+ remote: safeRemote,
155
189
  ready,
156
190
  };
157
191
  }
192
+ export function HarnessUpdateOverlay({ updater, t }) {
193
+ const snapshot = useSyncExternalStore(updater.subscribe, updater.getSnapshot, updater.getSnapshot);
194
+ const noticeKey = harnessUpdateNoticeKey(snapshot);
195
+ const visible = snapshot.status === 'update-available' && noticeKey !== undefined && snapshot.dismissedNotice !== noticeKey && snapshot.latestVersion !== undefined;
196
+ useEffect(() => {
197
+ if (visible && noticeKey !== undefined)
198
+ updater.markShown(noticeKey);
199
+ }, [visible, noticeKey, updater]);
200
+ if (!visible || noticeKey === undefined || snapshot.latestVersion === undefined)
201
+ return null;
202
+ return (_jsxs("div", { role: "status", "aria-label": t('updateHeading'), "data-codex-update-overlay": true, style: {
203
+ position: 'absolute', top: 52, right: 18, zIndex: 30, display: 'inline-flex', alignItems: 'center', gap: 10,
204
+ maxWidth: 'calc(100vw - 36px)', padding: '6px 10px 6px 12px', border: '0.5px solid var(--dsw-alias-border-l2)',
205
+ borderRadius: 8, background: 'var(--dsw-alias-bg-module-platform, var(--dsw-alias-bg-layer-1))',
206
+ color: 'var(--dsw-alias-label-primary)', boxShadow: '0 4px 16px rgba(0, 0, 0, 0.14)',
207
+ fontSize: 12, lineHeight: '18px', whiteSpace: 'nowrap', boxSizing: 'border-box',
208
+ }, children: [_jsxs("span", { style: { overflow: 'hidden', textOverflow: 'ellipsis' }, children: ["Codex Harness ", t('updateAvailable'), " v", snapshot.latestVersion] }), snapshot.releaseUrl && (_jsx("a", { href: snapshot.releaseUrl, target: "_blank", rel: "noopener noreferrer", style: { color: 'var(--dsw-alias-brand-primary)', textDecoration: 'underline', textUnderlineOffset: 2, flexShrink: 0 }, children: t('updateOpenRelease') })), _jsx("button", { type: "button", "aria-label": t('updateDismiss'), title: t('updateDismiss'), onClick: () => updater.dismiss(noticeKey), style: { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 20, height: 20, padding: 0, border: 0,
209
+ borderRadius: 4, background: 'transparent', color: 'var(--dsw-alias-label-secondary)', font: 'inherit', fontSize: 14, lineHeight: 1, cursor: 'pointer', flexShrink: 0 }, children: "\u00D7" })] }));
210
+ }
158
211
  export function applyWithSettingsApi(ctx, api) {
159
212
  ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'codex client: dictionaries');
160
213
  const commandUi = ctx.get('commandUi');
@@ -190,6 +243,23 @@ export function applyWithSettingsApi(ctx, api) {
190
243
  }), 'codex client: /compact mode picker');
191
244
  const settings = api.bind(ctx);
192
245
  const presetManager = createPresetManager(ctx);
246
+ const updateStore = new HarnessUpdateStore(async () => {
247
+ await presetManager.ready;
248
+ const check = presetManager.remote.codexPresetEditor?.updateCheck;
249
+ if (typeof check !== 'function')
250
+ return undefined;
251
+ const result = await check();
252
+ return result.ok ? result.value : undefined;
253
+ });
254
+ ctx.effect(() => {
255
+ let active = true;
256
+ void presetManager.ready.then(() => {
257
+ if (active && typeof presetManager.remote.codexPresetEditor?.updateCheck === 'function') {
258
+ void updateStore.refresh();
259
+ }
260
+ }).catch(() => { });
261
+ return () => { active = false; updateStore.dispose(); };
262
+ }, 'codex client: update checker');
193
263
  const injected = () => ({
194
264
  hooks: { settings },
195
265
  setSetting: (field, value) => settings.set(field, value),
@@ -203,7 +273,9 @@ export function applyWithSettingsApi(ctx, api) {
203
273
  locale: NS,
204
274
  inject: (sessionId) => ({
205
275
  ...injected(),
276
+ injectedSessionId: typeof sessionId === 'string' ? sessionId : sessionId !== undefined && sessionId !== null ? String(sessionId) : undefined,
206
277
  getCodexConnectScope: api.getCodexConnectScope,
278
+ getLlmProvidersScope: api.getLlmProvidersScope,
207
279
  modelDirectory: sessionId === undefined
208
280
  ? undefined
209
281
  : (ctx.get('modelDirectories'))?.directoryFor(sessionId)?.store,
@@ -216,6 +288,16 @@ export function applyWithSettingsApi(ctx, api) {
216
288
  locale: NS,
217
289
  inject: injected,
218
290
  }, ActivityLine));
219
- ctx.inject(['remote', 'remote.codexPresetEditor'], settingsCtx => api.register(settingsCtx, settings, presetManager));
291
+ if (typeof ctx.slots.spec !== 'function'
292
+ || ctx.slots.spec('shell.overlay') !== undefined) {
293
+ ctx.slots.inject('shell.overlay', () => ctx.slots.register({
294
+ name: 'shell.overlay',
295
+ id: 'codex-harness-update',
296
+ order: 45,
297
+ locale: NS,
298
+ inject: () => ({ updater: updateStore }),
299
+ }, HarnessUpdateOverlay));
300
+ }
301
+ ctx.inject(['remote', 'remote.codexPresetEditor'], settingsCtx => api.register(settingsCtx, settings, presetManager, updateStore));
220
302
  }
221
303
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,22 @@
1
1
  import type { ToolPolicyRule } from '../contracts/tool-policy-contract.ts';
2
+ import type { CodexConnectSnapshot } from '../contracts/ui-contracts.ts';
3
+ export interface GptCapabilitiesState {
4
+ readonly hostedWebSearch: boolean;
5
+ readonly codexSearch: boolean;
6
+ readonly codexSearchModel?: string | undefined;
7
+ readonly remoteCompaction: boolean;
8
+ readonly imageGeneration: boolean;
9
+ readonly imageModelHint?: string | undefined;
10
+ readonly codexSubagent?: boolean | undefined;
11
+ readonly codexSubagentModel?: string | undefined;
12
+ }
13
+ export declare function resolveGptCapabilities(codexSettings?: {
14
+ readonly hostedWebSearchEnabled?: boolean;
15
+ readonly remoteCompactionEnabled?: boolean;
16
+ readonly codexSubagentEnabled?: boolean;
17
+ readonly codexSubagentModel?: string;
18
+ } | undefined, codexConnect?: CodexConnectSnapshot | undefined): GptCapabilitiesState | undefined;
19
+ export declare function formatGptImageBadge(hint: string | undefined): string;
2
20
  /** Ephemeral UI drafts only; accepted ConfigForms values remain authoritative. */
3
21
  export interface PresetDraft {
4
22
  readonly preset: string;
@@ -1,3 +1,30 @@
1
+ export function resolveGptCapabilities(codexSettings, codexConnect) {
2
+ const connectReady = codexConnect?.status === 'ready';
3
+ if (codexSettings === undefined && !connectReady)
4
+ return undefined;
5
+ const subagentModel = codexSettings?.codexSubagentModel?.trim() || undefined;
6
+ return {
7
+ hostedWebSearch: codexSettings !== undefined ? (codexSettings.hostedWebSearchEnabled ?? true) : false,
8
+ codexSearch: connectReady && codexConnect.searchEnabled === true,
9
+ codexSearchModel: connectReady ? codexConnect.searchModel : undefined,
10
+ remoteCompaction: (codexSettings !== undefined && (codexSettings.remoteCompactionEnabled ?? true))
11
+ || (connectReady && codexConnect.nativeCompaction === true),
12
+ imageGeneration: connectReady && codexConnect.imageGenerationEnabled === true,
13
+ imageModelHint: connectReady ? codexConnect.imageModelHint : undefined,
14
+ ...(codexSettings?.codexSubagentEnabled === true ? { codexSubagent: true } : {}),
15
+ ...(subagentModel !== undefined ? { codexSubagentModel: subagentModel } : {}),
16
+ };
17
+ }
18
+ export function formatGptImageBadge(hint) {
19
+ const value = hint?.trim() ?? '';
20
+ if (!value || value === 'gpt-image-2.6-sunburst')
21
+ return 'GPT-Image-2.6 Sunburst';
22
+ if (value === 'gpt-image-2.6-flare')
23
+ return 'GPT-Image-2.6 Flare';
24
+ if (value === 'gpt-image-2')
25
+ return 'GPT-Image-2';
26
+ return value;
27
+ }
1
28
  function canonical(value) {
2
29
  if (Array.isArray(value))
3
30
  return value.map(canonical);