@shuind/dsh-codex-harness 0.3.2 → 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.
- package/CHANGELOG.md +17 -0
- package/README.md +21 -41
- package/docs/preset-library.md +2 -2
- package/docs/tool-policy.md +1 -1
- package/lib/client.js +1826 -545
- package/lib/compact-command.js +7 -1
- package/lib/compaction.js +7 -1
- package/lib/hybrid-executor.js +23 -12
- package/lib/index.js +1229 -17
- package/lib/preferences.js +21 -2
- package/lib/tool-policy.js +11 -2
- package/lib/typert.js +42 -1
- package/lib/types/client/desktop.d.ts +20 -42
- package/lib/types/client/desktop.js +184 -127
- package/lib/types/client/index.d.ts +104 -39
- package/lib/types/client/index.js +97 -15
- package/lib/types/client/policy-drafts.d.ts +18 -0
- package/lib/types/client/policy-drafts.js +27 -0
- package/lib/types/client/policy-locale.d.ts +81 -32
- package/lib/types/client/policy-locale.js +197 -107
- package/lib/types/client/preset-manager.d.ts +25 -2
- package/lib/types/client/preset-manager.js +89 -5
- package/lib/types/client/preset-requests.d.ts +44 -1
- package/lib/types/client/preset-requests.js +150 -0
- package/lib/types/client/tool-policy.d.ts +6 -15
- package/lib/types/client/tool-policy.js +24 -39
- package/lib/types/contracts/preset-editor-schema.d.ts +35 -0
- package/lib/types/contracts/preset-editor-schema.js +39 -0
- package/lib/types/contracts/settings.d.ts +12 -0
- package/lib/types/contracts/settings.js +10 -1
- package/lib/types/contracts/ui-contracts.d.ts +48 -0
- package/lib/types/contracts/ui-contracts.js +58 -0
- package/lib/types/contracts/update.d.ts +73 -0
- package/lib/types/contracts/update.js +291 -0
- package/lib/types/entries/index.js +20 -2
- package/lib/types/entries/preferences.d.ts +2 -0
- package/lib/types/entries/preferences.js +9 -0
- package/lib/types/hybrid/hybrid-sdk.d.ts +1 -1
- package/lib/types/hybrid/hybrid-sdk.js +27 -13
- package/lib/types/presets/preset-editor.d.ts +13 -1
- package/lib/types/presets/preset-editor.js +24 -1
- package/lib/types/presets/pro-mode-store.d.ts +13 -0
- package/lib/types/presets/pro-mode-store.js +69 -0
- package/lib/types/responses/background-sse-codec.d.ts +23 -0
- package/lib/types/responses/background-sse-codec.js +230 -0
- package/lib/types/responses/background-stream.d.ts +28 -0
- package/lib/types/responses/background-stream.js +351 -0
- package/lib/types/responses/fetch-transport.js +24 -9
- package/lib/types/responses/wire-rewrite.d.ts +4 -0
- package/lib/types/responses/wire-rewrite.js +30 -4
- package/lib/types/tools/codex-subagent.d.ts +14 -0
- package/lib/types/tools/codex-subagent.js +269 -0
- package/lib/types/update/checker.d.ts +14 -0
- package/lib/types/update/checker.js +166 -0
- package/locale/en.json +1 -1
- package/locale/hybrid-executor/en.json +1 -1
- package/locale/hybrid-executor/zh.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +6 -2
- package/src/client/desktop.tsx +359 -160
- package/src/client/index.tsx +122 -22
- package/src/client/policy-drafts.ts +45 -0
- package/src/client/policy-locale.ts +198 -106
- package/src/client/preset-manager.tsx +125 -4
- package/src/client/preset-requests.ts +185 -1
- package/src/client/tool-policy.tsx +29 -63
- package/src/contracts/preset-editor-schema.ts +44 -0
- package/src/contracts/settings.ts +20 -1
- package/src/contracts/ui-contracts.ts +87 -0
- package/src/contracts/update.ts +307 -0
- package/src/entries/index.ts +25 -2
- package/src/entries/preferences.ts +9 -0
- package/src/hybrid/hybrid-sdk.ts +28 -12
- package/src/presets/preset-editor.ts +31 -3
- package/src/presets/pro-mode-store.ts +80 -0
- package/src/responses/background-sse-codec.ts +237 -0
- package/src/responses/background-stream.ts +371 -0
- package/src/responses/fetch-transport.ts +28 -9
- package/src/responses/wire-rewrite.ts +34 -3
- package/src/tools/codex-subagent.ts +290 -0
- package/src/update/checker.ts +193 -0
- package/tsdown.config.ts +4 -0
|
@@ -4,18 +4,68 @@ import type { PresetToolEntry } from '../contracts/tool-policy-contract.ts'
|
|
|
4
4
|
export const toolPolicyEn = {
|
|
5
5
|
settingsTabLabel: 'Codex Harness',
|
|
6
6
|
settingsToolsPage: 'Preset plans',
|
|
7
|
-
settingsRuntimePage: '
|
|
7
|
+
settingsRuntimePage: 'Global settings',
|
|
8
|
+
settingsHelpPage: 'Guide',
|
|
9
|
+
helpFaqHeading: 'Quick answers',
|
|
10
|
+
helpDeferDisabledTitle: 'Why is Defer greyed out on some tools?',
|
|
11
|
+
helpDeferDisabledDesc: 'Already deferred; hide it if you’re sure you won’t use it.',
|
|
12
|
+
helpDeferLifecycleTitle: 'What is Defer for?',
|
|
13
|
+
helpDeferLifecycleDesc: 'Saves context—loaded on demand and reclaimed after context compaction.',
|
|
14
|
+
helpNativeSearchTitle: 'Prefer native search?',
|
|
15
|
+
helpNativeSearchDesc: 'On uses OpenAI built-in search (billed per search on API); off reuses subscription search.',
|
|
16
|
+
helpConnectHeading: 'Works with Codex Connect',
|
|
17
|
+
helpRegistrationScopeTitle: 'Global subscription search, images & subagent',
|
|
18
|
+
helpRegistrationScopeDesc: 'Turn on in Global settings to share Codex Connect search, image generation, and codex_subagent across all tool-capable models; override per preset.',
|
|
19
|
+
helpProComboTitle: 'API Pro + subscription subagents + subscription search',
|
|
20
|
+
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.',
|
|
21
|
+
helpConnectContextTitle: 'Context window & compaction sync',
|
|
22
|
+
helpConnectContextDesc: 'The composer context button syncs Codex Connect model limits; Prefer remote compaction stays in sync too.',
|
|
23
|
+
helpConnectLinkLabel: 'Companion plugin',
|
|
24
|
+
helpUpdateHeading: 'Version & updates',
|
|
25
|
+
updateHeading: 'Codex Harness update',
|
|
26
|
+
updateBadge: 'Update',
|
|
27
|
+
updateAvailable: 'Update available',
|
|
28
|
+
updateUpToDate: 'Up to date',
|
|
29
|
+
updateChecking: 'Checking…',
|
|
30
|
+
updateUnavailable: 'Check failed',
|
|
31
|
+
updateCheckNow: 'Check updates',
|
|
32
|
+
updateOpenRelease: 'View release',
|
|
33
|
+
updateDismiss: 'Dismiss update notice',
|
|
34
|
+
updateHowTo: 'Update from the DSH Plugin Market, or reinstall @shuind/dsh-codex-harness@latest.',
|
|
8
35
|
settingsSubTools: 'Tools',
|
|
9
36
|
settingsPresetPrompts: 'Prompts',
|
|
10
37
|
settingsDefinition: 'YAML',
|
|
11
|
-
settingsPreferHostedSearch: 'Prefer
|
|
38
|
+
settingsPreferHostedSearch: 'Prefer native search',
|
|
12
39
|
settingsPreferRemoteCompaction: 'Prefer remote compaction',
|
|
13
|
-
settingsSharedFailed: '
|
|
14
|
-
settingsRuntimeScope: 'Shared in this environment',
|
|
15
|
-
|
|
40
|
+
settingsSharedFailed: 'Save failed. Settings may have changed—please try again.',
|
|
41
|
+
settingsRuntimeScope: 'Shared across all presets in this environment.',
|
|
42
|
+
capabilitiesConnectHeading: 'Subscription global registrations',
|
|
43
|
+
capabilitiesConnectCollapsedTitle: 'Codex Connect subscription features',
|
|
44
|
+
capabilitiesConnectInstallHint: 'Install Codex Connect to share subscription web search, image generation, and subagents across all models.',
|
|
45
|
+
capabilitiesConnectNote: 'Registered live via Codex Connect for all models. Adjust per preset in Preset plans.',
|
|
46
|
+
capabilitySearchTitle: 'Subscription web search',
|
|
47
|
+
capabilitySearchNoteAll: 'Reused by all models.',
|
|
48
|
+
capabilitySearchNoteFallback: 'GPT sessions prefer native search; other models reuse this.',
|
|
49
|
+
capabilityImageTitle: 'Subscription image generation',
|
|
50
|
+
capabilityImageNote: 'Registered globally for all tool-capable models.',
|
|
51
|
+
capabilitySubagentTitle: 'Subscription subagent',
|
|
52
|
+
capabilitySubagentNote: 'Registered globally so any tool-capable model can delegate tasks to a Codex subscription subagent.',
|
|
53
|
+
capabilitySubagentModel: 'Model',
|
|
54
|
+
capabilitySubagentNoModels: 'No enabled models',
|
|
55
|
+
capabilitySubagentRestart: 'Restart DSH required',
|
|
56
|
+
capabilitySubagentEffort: 'Effort',
|
|
57
|
+
capabilitySubagentEffortDefault: 'Default',
|
|
58
|
+
capabilitySubagentPreset: 'Preset',
|
|
59
|
+
capabilitySubagentPresetHybrid: 'Codex hybrid',
|
|
60
|
+
capabilitySubagentPresetInherit: 'Follow current chat',
|
|
61
|
+
capabilityRegistered: 'Registered',
|
|
62
|
+
capabilityNotRegistered: 'Not registered',
|
|
63
|
+
capabilityUnavailable: 'Codex Connect unavailable',
|
|
64
|
+
capabilityLoading: 'Loading registration status…',
|
|
65
|
+
capabilityWriteFailed: 'Failed to update registration.',
|
|
16
66
|
settingsBundleSummary: 'Configure Codex Harness in its dedicated Settings tab.',
|
|
17
67
|
settingsBundlePath: 'Settings → Plugins → Codex Harness',
|
|
18
|
-
settingsDefinitionAbsent: 'Choose a preset
|
|
68
|
+
settingsDefinitionAbsent: 'Choose a preset first.',
|
|
19
69
|
globalGroupRequest: 'Model requests',
|
|
20
70
|
globalGroupDisplay: 'Display',
|
|
21
71
|
globalPending: 'Unsaved',
|
|
@@ -45,25 +95,22 @@ export const toolPolicyEn = {
|
|
|
45
95
|
toolPolicyAction: 'Tool action',
|
|
46
96
|
toolPolicyKeep: 'Enable',
|
|
47
97
|
toolPolicyDefer: 'Defer',
|
|
48
|
-
toolPolicyDeferHint: '
|
|
98
|
+
toolPolicyDeferHint: 'Load on demand via activate_tools',
|
|
49
99
|
toolPolicyHide: 'Hide',
|
|
50
100
|
toolPolicyReplaceShort: 'Replace',
|
|
51
|
-
toolPolicyRestoreChoice: 'Restore default
|
|
101
|
+
toolPolicyRestoreChoice: 'Restore default',
|
|
52
102
|
toolPolicyUnsupported: 'Saved replacement unavailable',
|
|
53
103
|
toolPolicyConditional: 'Conditional',
|
|
54
104
|
toolPolicyTargetExists: 'Replacement target already exists',
|
|
55
105
|
toolPolicyPresetDisabled: 'Disabled by original preset',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
toolPolicyGptCompactionDesc: 'Server-side native context compaction (GPT sessions only; falls back to local summary on failure)',
|
|
65
|
-
toolPolicyGptCompactionBadge: 'GPT native compaction',
|
|
66
|
-
toolPolicyGptCompactionReadOnly: 'Non-tool · Runtime preference',
|
|
106
|
+
toolPolicyGptHostedSearch: 'GPT native search',
|
|
107
|
+
toolPolicyGptHostedSearchTitle: 'GPT sessions prefer OpenAI native search (set in Global settings).',
|
|
108
|
+
toolPolicyGptCodexSearch: 'Codex Connect',
|
|
109
|
+
toolPolicyGptCodexSearchTitle: 'Registered globally by Codex Connect (manage in Global settings).',
|
|
110
|
+
toolPolicyGptDualSearch: 'GPT native / Codex Connect',
|
|
111
|
+
toolPolicyGptDualSearchTitle: 'GPT sessions prefer native search; other models reuse Codex Connect search.',
|
|
112
|
+
toolPolicyGptImageTitle: 'Registered globally by Codex Connect (manage in Global settings).',
|
|
113
|
+
toolPolicyGptSubagentTitle: 'Registered globally using Codex Connect subscription model (manage in Global settings).',
|
|
67
114
|
toolPolicyCommandGroup: 'Commands & runtime',
|
|
68
115
|
toolPolicyFileGroup: 'Files & search',
|
|
69
116
|
toolPolicyPlanGroup: 'Planning & interaction',
|
|
@@ -87,7 +134,7 @@ export const toolPolicyEn = {
|
|
|
87
134
|
toolLabelAskUser: 'Ask structured questions to the user', toolLabelPresent: 'Present deliverable files to the user',
|
|
88
135
|
toolLabelProposeAction: 'Propose action card for user approval', toolLabelApprove: 'Approve action denied by Codex Auto-review',
|
|
89
136
|
toolLabelSubagent: 'Spawn isolated subagent for a subtask', toolLabelSubagentFork: 'Fork subagent from current context',
|
|
90
|
-
toolLabelSubagentCodex: 'Delegate task to Codex subagent', toolLabelSubagentClaude: 'Delegate task to Claude Code subagent',
|
|
137
|
+
toolLabelSubagentCodex: 'Delegate task to Codex subagent', toolLabelCodexSubagent: 'Delegate task to Codex subscription subagent', toolLabelSubagentClaude: 'Delegate task to Claude Code subagent',
|
|
91
138
|
toolLabelSubagentOar: 'Run experimental OAR subagent', toolLabelSubagentModels: 'List available models for subagents',
|
|
92
139
|
toolLabelSendMessage: 'Send message to subagent or teammate', toolLabelListAgents: 'List started subagents and statuses',
|
|
93
140
|
toolLabelInterruptAgent: 'Interrupt a running subagent', toolLabelWaitAgent: 'Wait for subagent or teammate updates',
|
|
@@ -96,8 +143,8 @@ export const toolPolicyEn = {
|
|
|
96
143
|
toolLabelUpdateGoal: 'Update current session goal', toolLabelGoal: 'Manage current session goal',
|
|
97
144
|
toolLabelSpawnTeammate: 'Spawn durable Team teammate', toolLabelTeamCreate: 'Create task on shared Team board',
|
|
98
145
|
toolLabelTeamGet: 'Read latest shared Team task state', toolLabelTeamList: 'List shared Team tasks and blockers',
|
|
99
|
-
toolLabelTeamUpdate: 'Update shared Team task with revision check', toolLabelWebSearch: 'Search the web
|
|
100
|
-
toolLabelWebFetch: 'Fetch
|
|
146
|
+
toolLabelTeamUpdate: 'Update shared Team task with revision check', toolLabelWebSearch: 'Search the web',
|
|
147
|
+
toolLabelWebFetch: 'Fetch text from HTTP(S) URL', toolLabelSkill: 'Load full instructions for a skill',
|
|
101
148
|
toolLabelActivateTools: 'Activate deferred (deferLoading) tools', toolLabelSchedule: 'Manage scheduled tasks',
|
|
102
149
|
toolLabelScheduleCreate: 'Create one-shot or cron schedule', toolLabelScheduleEdit: 'Edit or toggle an existing schedule',
|
|
103
150
|
toolLabelScheduleList: 'List configured schedules', toolLabelScheduleView: 'View schedule details and history',
|
|
@@ -111,29 +158,29 @@ export const toolPolicyEn = {
|
|
|
111
158
|
toolLabelStagehandAct: 'Perform page interaction (Stagehand)', toolLabelStagehandExtract: 'Extract structured page data (Stagehand)',
|
|
112
159
|
toolLabelStagehandObserve: 'Observe interactive page elements (Stagehand)', toolLabelStagehandShot: 'Capture browser screenshot (Stagehand)',
|
|
113
160
|
toolLabelStagehandTabs: 'Manage browser tabs (Stagehand)',
|
|
114
|
-
toolLabelViewImage: 'View local or HTTP(S) image
|
|
115
|
-
toolLabelCodexImageGen: 'Generate or edit images
|
|
116
|
-
toolLabelCodexQuota: 'Query
|
|
161
|
+
toolLabelViewImage: 'View local or HTTP(S) image',
|
|
162
|
+
toolLabelCodexImageGen: 'Generate or edit images',
|
|
163
|
+
toolLabelCodexQuota: 'Query Codex account quota',
|
|
117
164
|
toolLabelMcpDynamic: 'MCP server tool', toolLabelOther: 'Other tool',
|
|
118
165
|
toolPolicyToolsLoading: 'Loading tools…',
|
|
119
166
|
toolPolicyToolsEmpty: 'No registered tools.',
|
|
120
167
|
toolPolicyNoMatches: 'No matching tools.',
|
|
121
|
-
toolPolicyToolsFailed: '
|
|
168
|
+
toolPolicyToolsFailed: 'Could not load tools; saved rules are kept.',
|
|
122
169
|
toolPolicyToolsRefresh: 'Refresh tools',
|
|
123
170
|
toolPolicyCatalogLoading: 'Loading presets…',
|
|
124
171
|
toolPolicyCatalogEmpty: 'No presets found.',
|
|
125
|
-
toolPolicyCatalogFailed: '
|
|
172
|
+
toolPolicyCatalogFailed: 'Could not load presets; saved IDs remain selectable.',
|
|
126
173
|
toolPolicyCatalogRetry: 'Reload presets',
|
|
127
174
|
toolPolicyEmpty: 'Choose a preset',
|
|
128
|
-
toolPolicySave: 'Save
|
|
175
|
+
toolPolicySave: 'Save',
|
|
129
176
|
toolPolicySaving: 'Saving…',
|
|
130
177
|
toolPolicyDiscard: 'Discard draft',
|
|
131
|
-
toolPolicySaved: '
|
|
178
|
+
toolPolicySaved: 'Saved.',
|
|
132
179
|
toolPolicyInvalidPreset: 'An empty preset ID cannot be saved.',
|
|
133
180
|
toolPolicyDuplicatePreset: 'Duplicate preset IDs cannot be saved.',
|
|
134
|
-
toolPolicyRefused: '
|
|
181
|
+
toolPolicyRefused: 'Save conflict. Discard draft to reload.',
|
|
135
182
|
toolPolicyFailed: 'Save failed. Draft is kept.',
|
|
136
|
-
toolPolicyReadOnly: '
|
|
183
|
+
toolPolicyReadOnly: 'Settings are read-only.',
|
|
137
184
|
pmRefresh: 'Refresh',
|
|
138
185
|
peLoading: 'Loading preset…',
|
|
139
186
|
peReadError: 'Preset definition unavailable.',
|
|
@@ -142,18 +189,68 @@ export const toolPolicyEn = {
|
|
|
142
189
|
export const toolPolicyZh: Record<keyof typeof toolPolicyEn, string> = {
|
|
143
190
|
settingsTabLabel: 'Codex Harness',
|
|
144
191
|
settingsToolsPage: '预设方案',
|
|
145
|
-
settingsRuntimePage: '
|
|
192
|
+
settingsRuntimePage: '全局设置',
|
|
193
|
+
settingsHelpPage: '说明',
|
|
194
|
+
helpFaqHeading: '常见问题',
|
|
195
|
+
helpDeferDisabledTitle: '为什么有的工具点不了「延迟」?',
|
|
196
|
+
helpDeferDisabledDesc: '因为它已经延迟了,确定不用可隐藏。',
|
|
197
|
+
helpDeferLifecycleTitle: '「延迟」干嘛的?',
|
|
198
|
+
helpDeferLifecycleDesc: '省上下文,模型需要时再调出来;经过上下文压缩后,不常用的会自动收回。',
|
|
199
|
+
helpNativeSearchTitle: '「优先使用原生搜索」开不开?',
|
|
200
|
+
helpNativeSearchDesc: '开了 GPT 走 OpenAI 原生搜索(API 按次收费);关了统一用订阅搜索。',
|
|
201
|
+
helpConnectHeading: '与 Codex Connect 联动',
|
|
202
|
+
helpRegistrationScopeTitle: '全局复用订阅搜索、生图与子代理',
|
|
203
|
+
helpRegistrationScopeDesc: '在「全局设置」打开后,所有能调工具的模型都能直接用订阅搜索、生图和 codex_subagent;预设方案只管单个模式用不用。',
|
|
204
|
+
helpProComboTitle: 'API Pro + 订阅子代理 + 订阅搜索',
|
|
205
|
+
helpProComboDesc: '用 Pro 订阅送的 API 额度接 GPT-5.6 / 6+,开输入框右侧 Pro(只有官 key 接 GPT-5.6 / 6+ 才会显示,仅当前对话有效);子代理和联网搜索走 Codex 订阅(省 API),品尝脱离网页牢笼的 Pro。',
|
|
206
|
+
helpConnectContextTitle: '上下文与压缩联动',
|
|
207
|
+
helpConnectContextDesc: '输入框上下文按钮直接同步 Codex Connect 模型上限;「优先使用远程压缩」也会自动同步。',
|
|
208
|
+
helpConnectLinkLabel: '配套插件',
|
|
209
|
+
helpUpdateHeading: '版本与更新',
|
|
210
|
+
updateHeading: 'Codex Harness 更新',
|
|
211
|
+
updateBadge: '有更新',
|
|
212
|
+
updateAvailable: '发现新版本',
|
|
213
|
+
updateUpToDate: '已是最新',
|
|
214
|
+
updateChecking: '正在检查…',
|
|
215
|
+
updateUnavailable: '检查失败',
|
|
216
|
+
updateCheckNow: '检查更新',
|
|
217
|
+
updateOpenRelease: '查看更新',
|
|
218
|
+
updateDismiss: '关闭更新提醒',
|
|
219
|
+
updateHowTo: '在 DSH 插件市场直接更新,或重新安装 @shuind/dsh-codex-harness@latest。',
|
|
146
220
|
settingsSubTools: '工具',
|
|
147
221
|
settingsPresetPrompts: '提示词',
|
|
148
222
|
settingsDefinition: '原始定义',
|
|
149
|
-
settingsPreferHostedSearch: '
|
|
223
|
+
settingsPreferHostedSearch: '优先使用原生搜索',
|
|
150
224
|
settingsPreferRemoteCompaction: '优先使用远程压缩',
|
|
151
|
-
settingsSharedFailed: '
|
|
152
|
-
settingsRuntimeScope: '
|
|
153
|
-
|
|
225
|
+
settingsSharedFailed: '保存失败,设置可能已在别处更新,请重试。',
|
|
226
|
+
settingsRuntimeScope: '本环境共享,对所有预设生效。',
|
|
227
|
+
capabilitiesConnectHeading: '订阅能力全局注册',
|
|
228
|
+
capabilitiesConnectCollapsedTitle: 'Codex Connect 订阅能力',
|
|
229
|
+
capabilitiesConnectInstallHint: '安装 Codex Connect 后,可在此全局共享订阅搜索、生图与子代理。',
|
|
230
|
+
capabilitiesConnectNote: '通过 Codex Connect 即时注册到全环境,所有模型可复用;单预设开关请在「预设方案 → 工具」调整。',
|
|
231
|
+
capabilitySearchTitle: '订阅联网搜索',
|
|
232
|
+
capabilitySearchNoteAll: '所有模型统一复用此搜索。',
|
|
233
|
+
capabilitySearchNoteFallback: 'GPT 会话优先用原生搜索,其他模型复用此搜索。',
|
|
234
|
+
capabilityImageTitle: '订阅图片生成 / 编辑',
|
|
235
|
+
capabilityImageNote: '注册为全局工具,所有支持工具调用的模型均可调用。',
|
|
236
|
+
capabilitySubagentTitle: '订阅子代理',
|
|
237
|
+
capabilitySubagentNote: '注册为全局工具,所有支持工具调用的模型均可把任务交给 Codex 订阅子代理。',
|
|
238
|
+
capabilitySubagentModel: '模型',
|
|
239
|
+
capabilitySubagentNoModels: '无可用模型',
|
|
240
|
+
capabilitySubagentRestart: '需重启 DSH',
|
|
241
|
+
capabilitySubagentEffort: '推理',
|
|
242
|
+
capabilitySubagentEffortDefault: '默认',
|
|
243
|
+
capabilitySubagentPreset: '预设',
|
|
244
|
+
capabilitySubagentPresetHybrid: 'Codex 混合模式',
|
|
245
|
+
capabilitySubagentPresetInherit: '跟随当前对话',
|
|
246
|
+
capabilityRegistered: '已注册',
|
|
247
|
+
capabilityNotRegistered: '未注册',
|
|
248
|
+
capabilityUnavailable: '未安装 Codex Connect',
|
|
249
|
+
capabilityLoading: '正在读取注册状态…',
|
|
250
|
+
capabilityWriteFailed: '更新注册状态失败。',
|
|
154
251
|
settingsBundleSummary: '请在独立的 Codex Harness 设置页配置。',
|
|
155
252
|
settingsBundlePath: '设置 → 内置插件 → Codex Harness',
|
|
156
|
-
settingsDefinitionAbsent: '
|
|
253
|
+
settingsDefinitionAbsent: '请先选择一个预设。',
|
|
157
254
|
globalGroupRequest: '模型请求',
|
|
158
255
|
globalGroupDisplay: '界面',
|
|
159
256
|
globalPending: '未保存',
|
|
@@ -172,105 +269,102 @@ export const toolPolicyZh: Record<keyof typeof toolPolicyEn, string> = {
|
|
|
172
269
|
presetSummaryPrompts: '提示词',
|
|
173
270
|
toolPolicyDraftSummary: '本次修改',
|
|
174
271
|
toolPolicyRuleChanged: '预设方案调整',
|
|
175
|
-
toolPolicyNoToolDelta: '
|
|
272
|
+
toolPolicyNoToolDelta: '无待保存修改',
|
|
176
273
|
toolPolicySearch: '搜索工具',
|
|
177
274
|
toolPolicyFilter: '工具筛选',
|
|
178
275
|
toolPolicyAll: '全部',
|
|
179
276
|
toolPolicyModified: '已修改',
|
|
180
|
-
toolPolicyDeferredFilter: '
|
|
277
|
+
toolPolicyDeferredFilter: '已延迟',
|
|
181
278
|
toolPolicyReplaceable: '可替换',
|
|
182
279
|
toolPolicyDefaultDeferred: '默认延迟',
|
|
183
280
|
toolPolicyAction: '工具操作',
|
|
184
281
|
toolPolicyKeep: '启用',
|
|
185
282
|
toolPolicyDefer: '延迟',
|
|
186
|
-
toolPolicyDeferHint: '
|
|
283
|
+
toolPolicyDeferHint: '按需加载(调用时再激活)',
|
|
187
284
|
toolPolicyHide: '隐藏',
|
|
188
285
|
toolPolicyReplaceShort: '替换',
|
|
189
|
-
toolPolicyRestoreChoice: '
|
|
286
|
+
toolPolicyRestoreChoice: '恢复默认',
|
|
190
287
|
toolPolicyUnsupported: '已保存的替换当前不可用',
|
|
191
288
|
toolPolicyConditional: '按条件可用',
|
|
192
289
|
toolPolicyTargetExists: '替换目标已存在',
|
|
193
290
|
toolPolicyPresetDisabled: '原预设未启用',
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
toolPolicyGptCompactionDesc: '使用 OpenAI 服务端原生压缩替代默认文本摘要(仅 GPT 会话,失败自动回退)',
|
|
203
|
-
toolPolicyGptCompactionBadge: 'GPT 原生压缩',
|
|
204
|
-
toolPolicyGptCompactionReadOnly: '非工具 · 运行偏好控制',
|
|
291
|
+
toolPolicyGptHostedSearch: 'GPT 原生搜索',
|
|
292
|
+
toolPolicyGptHostedSearchTitle: 'GPT 会话优先用原生搜索(在「全局设置」调整)。',
|
|
293
|
+
toolPolicyGptCodexSearch: 'Codex Connect',
|
|
294
|
+
toolPolicyGptCodexSearchTitle: '由 Codex Connect 全局注册(在「全局设置」管理)。',
|
|
295
|
+
toolPolicyGptDualSearch: 'GPT 原生 / Codex Connect',
|
|
296
|
+
toolPolicyGptDualSearchTitle: 'GPT 会话优先用原生搜索,其他模型复用订阅搜索。',
|
|
297
|
+
toolPolicyGptImageTitle: '由 Codex Connect 全局注册的生图工具(在「全局设置」管理)。',
|
|
298
|
+
toolPolicyGptSubagentTitle: '通过 Codex Connect 订阅模型全局注册的子代理工具(在「全局设置」管理)。',
|
|
205
299
|
toolPolicyCommandGroup: '命令与执行',
|
|
206
300
|
toolPolicyFileGroup: '文件与检索',
|
|
207
301
|
toolPolicyPlanGroup: '规划与交互',
|
|
208
302
|
toolPolicyCollabGroup: '子代理与工作流',
|
|
209
303
|
toolPolicyOtherGroup: '网络与扩展',
|
|
210
304
|
toolPolicyCustomized: '项修改',
|
|
211
|
-
toolLabelExec: '
|
|
305
|
+
toolLabelExec: '运行终端命令(Shell / PTY)', toolLabelStdin: '读写交互式终端(PTY)',
|
|
212
306
|
toolLabelPwsh: '执行 PowerShell 命令', toolLabelBash: '执行 Bash 命令',
|
|
213
|
-
toolLabelRunCode: '
|
|
214
|
-
toolLabelJobOutput: '
|
|
215
|
-
toolLabelTermOpen: '
|
|
216
|
-
toolLabelTermRead: '
|
|
217
|
-
toolLabelTermSignal: '
|
|
218
|
-
toolLabelWorkdir: '
|
|
219
|
-
toolLabelPatch: '
|
|
220
|
-
toolLabelWrite: '
|
|
221
|
-
toolLabelStrReplace: '
|
|
222
|
-
toolLabelGrep: '
|
|
223
|
-
toolLabelLsp: '
|
|
224
|
-
toolLabelTodo: '
|
|
225
|
-
toolLabelAskUser: '
|
|
226
|
-
toolLabelProposeAction: '
|
|
227
|
-
toolLabelSubagent: '
|
|
228
|
-
toolLabelSubagentCodex: '
|
|
229
|
-
toolLabelSubagentOar: '
|
|
230
|
-
toolLabelSendMessage: '
|
|
231
|
-
toolLabelInterruptAgent: '
|
|
232
|
-
toolLabelWorkflow: '运行多阶段 /
|
|
233
|
-
toolLabelCreateGoal: '
|
|
234
|
-
toolLabelUpdateGoal: '
|
|
235
|
-
toolLabelSpawnTeammate: '
|
|
236
|
-
toolLabelTeamGet: '
|
|
237
|
-
toolLabelTeamUpdate: '
|
|
238
|
-
toolLabelWebFetch: '
|
|
239
|
-
toolLabelActivateTools: '
|
|
240
|
-
toolLabelScheduleCreate: '
|
|
241
|
-
toolLabelScheduleList: '
|
|
242
|
-
toolLabelPluginManager: '
|
|
243
|
-
toolLabelCordisList: '
|
|
244
|
-
toolLabelSessionSearch: '
|
|
245
|
-
toolLabelSessionEventRead: '
|
|
246
|
-
toolLabelSessionEventTrace: '
|
|
247
|
-
toolLabelMcpTemplates: '列出 MCP
|
|
248
|
-
toolLabelWorkspaceDeps: '获取内置 Python
|
|
249
|
-
toolLabelStagehandAct: '
|
|
250
|
-
toolLabelStagehandObserve: '
|
|
307
|
+
toolLabelRunCode: '沙箱运行代码并批量调用工具', toolLabelJobList: '列出后台任务及状态',
|
|
308
|
+
toolLabelJobOutput: '读取后台任务输出', toolLabelJobKill: '终止后台任务',
|
|
309
|
+
toolLabelTermOpen: '打开持久终端', toolLabelTermList: '列出持久终端',
|
|
310
|
+
toolLabelTermRead: '读取持久终端输出', toolLabelTermSend: '向持久终端发送输入',
|
|
311
|
+
toolLabelTermSignal: '向持久终端发送信号', toolLabelTermClose: '关闭持久终端',
|
|
312
|
+
toolLabelWorkdir: '查看或切换工作目录(cd)', toolLabelWorktree: '新建 Git 分支与工作树',
|
|
313
|
+
toolLabelPatch: '应用补丁修改文件', toolLabelRead: '读取文本文件',
|
|
314
|
+
toolLabelWrite: '新建或覆盖文件', toolLabelEdit: '按文本替换编辑文件',
|
|
315
|
+
toolLabelStrReplace: '按文本替换查看或编辑文件', toolLabelGlob: '按通配符查找文件',
|
|
316
|
+
toolLabelGrep: '正则搜索文件内容', toolLabelImage: '读取图片',
|
|
317
|
+
toolLabelLsp: 'LSP 代码符号与引用查询', toolLabelPlan: '更新任务计划',
|
|
318
|
+
toolLabelTodo: '更新待办列表', toolLabelExitPlan: '提交方案并退出规划模式',
|
|
319
|
+
toolLabelAskUser: '向用户提问', toolLabelPresent: '向用户展示交付文件',
|
|
320
|
+
toolLabelProposeAction: '请求用户确认操作', toolLabelApprove: '批准自动审查拦截的操作',
|
|
321
|
+
toolLabelSubagent: '启动独立子代理', toolLabelSubagentFork: '派生子代理(继承上下文)',
|
|
322
|
+
toolLabelSubagentCodex: '委托 Codex 子代理', toolLabelCodexSubagent: '委托 Codex 订阅子代理', toolLabelSubagentClaude: '委托 Claude Code 子代理',
|
|
323
|
+
toolLabelSubagentOar: '启动 OAR 子代理', toolLabelSubagentModels: '列出子代理可用模型',
|
|
324
|
+
toolLabelSendMessage: '向子代理发消息', toolLabelListAgents: '列出子代理及状态',
|
|
325
|
+
toolLabelInterruptAgent: '中断子代理任务', toolLabelWaitAgent: '等待子代理状态更新',
|
|
326
|
+
toolLabelWorkflow: '运行多阶段 / 并行工作流', toolLabelRalph: '运行自动迭代循环代理',
|
|
327
|
+
toolLabelCreateGoal: '创建会话目标', toolLabelGetGoal: '读取会话目标',
|
|
328
|
+
toolLabelUpdateGoal: '更新会话目标进度', toolLabelGoal: '管理会话目标',
|
|
329
|
+
toolLabelSpawnTeammate: '创建团队协作代理', toolLabelTeamCreate: '新建团队任务',
|
|
330
|
+
toolLabelTeamGet: '读取团队任务状态', toolLabelTeamList: '列出团队任务与阻塞',
|
|
331
|
+
toolLabelTeamUpdate: '更新团队任务', toolLabelWebSearch: '搜索网页信息',
|
|
332
|
+
toolLabelWebFetch: '抓取网页文本', toolLabelSkill: '加载技能说明',
|
|
333
|
+
toolLabelActivateTools: '激活延迟加载的工具', toolLabelSchedule: '管理定时任务',
|
|
334
|
+
toolLabelScheduleCreate: '新建定时任务', toolLabelScheduleEdit: '修改或启停定时任务',
|
|
335
|
+
toolLabelScheduleList: '列出定时任务', toolLabelScheduleView: '查看定时任务详情',
|
|
336
|
+
toolLabelPluginManager: '管理当前配置插件', toolLabelPluginMarket: '浏览插件市场',
|
|
337
|
+
toolLabelCordisList: '列出宿主诊断接口', toolLabelCordisQuery: '查询宿主诊断信息',
|
|
338
|
+
toolLabelSessionSearch: '跨历史会话搜索事件', toolLabelSessionTrace: '追踪会话链路',
|
|
339
|
+
toolLabelSessionEventRead: '读取单条会话事件', toolLabelSessionEventSearch: '搜索当前会话事件',
|
|
340
|
+
toolLabelSessionEventTrace: '追踪会话事件引用链', toolLabelMcpList: '列出 MCP 资源',
|
|
341
|
+
toolLabelMcpTemplates: '列出 MCP 资源模板', toolLabelMcpRead: '读取 MCP 资源',
|
|
342
|
+
toolLabelWorkspaceDeps: '获取内置 Python 与依赖路径', toolLabelStagehandNav: '浏览器打开网页(Stagehand)',
|
|
343
|
+
toolLabelStagehandAct: '执行页面交互(Stagehand)', toolLabelStagehandExtract: '提取页面数据(Stagehand)',
|
|
344
|
+
toolLabelStagehandObserve: '识别页面可交互元素(Stagehand)', toolLabelStagehandShot: '截取浏览器页面(Stagehand)',
|
|
251
345
|
toolLabelStagehandTabs: '管理浏览器标签页(Stagehand)',
|
|
252
|
-
toolLabelViewImage: '
|
|
253
|
-
toolLabelCodexImageGen: '
|
|
254
|
-
toolLabelCodexQuota: '
|
|
346
|
+
toolLabelViewImage: '查看本地或网络图片',
|
|
347
|
+
toolLabelCodexImageGen: '生成或编辑图片',
|
|
348
|
+
toolLabelCodexQuota: '查询 Codex 账号额度',
|
|
255
349
|
toolLabelMcpDynamic: 'MCP 扩展工具', toolLabelOther: '其它工具',
|
|
256
350
|
toolPolicyToolsLoading: '正在读取工具…',
|
|
257
351
|
toolPolicyToolsEmpty: '没有已注册工具。',
|
|
258
352
|
toolPolicyNoMatches: '没有匹配工具。',
|
|
259
|
-
toolPolicyToolsFailed: '
|
|
353
|
+
toolPolicyToolsFailed: '无法加载工具列表,已保存规则不受影响。',
|
|
260
354
|
toolPolicyToolsRefresh: '刷新工具',
|
|
261
355
|
toolPolicyCatalogLoading: '正在读取预设…',
|
|
262
356
|
toolPolicyCatalogEmpty: '没有可选预设。',
|
|
263
|
-
toolPolicyCatalogFailed: '
|
|
357
|
+
toolPolicyCatalogFailed: '无法加载预设列表,仍可选择已保存项。',
|
|
264
358
|
toolPolicyCatalogRetry: '重新读取预设',
|
|
265
359
|
toolPolicyEmpty: '请选择预设',
|
|
266
|
-
toolPolicySave: '
|
|
360
|
+
toolPolicySave: '保存',
|
|
267
361
|
toolPolicySaving: '正在保存…',
|
|
268
362
|
toolPolicyDiscard: '放弃草稿',
|
|
269
|
-
toolPolicySaved: '
|
|
363
|
+
toolPolicySaved: '已保存。',
|
|
270
364
|
toolPolicyInvalidPreset: '预设 ID 为空,无法保存。',
|
|
271
365
|
toolPolicyDuplicatePreset: '预设 ID 重复,无法保存。',
|
|
272
|
-
toolPolicyRefused: '
|
|
273
|
-
toolPolicyFailed: '
|
|
366
|
+
toolPolicyRefused: '保存冲突,请放弃草稿后重试。',
|
|
367
|
+
toolPolicyFailed: '保存失败,草稿已保留。',
|
|
274
368
|
toolPolicyReadOnly: '当前设置为只读。',
|
|
275
369
|
pmRefresh: '刷新',
|
|
276
370
|
peLoading: '正在读取预设…',
|
|
@@ -285,17 +379,15 @@ const commandNames = new Set([
|
|
|
285
379
|
const fileNames = new Set(['read', 'write', 'edit', 'str_replace_editor', 'apply_patch', 'glob', 'grep', 'read_image', 'view_image', 'lsp'])
|
|
286
380
|
const planNames = new Set(['todo_write', 'update_plan', 'exit_plan_mode', 'ask_user_question', 'present', 'propose_action', 'approve'])
|
|
287
381
|
const collabNames = new Set([
|
|
288
|
-
'subagent', 'subagent_fork', 'subagent_codex', 'subagent_claude_code', 'subagent_oar', 'list_subagent_models',
|
|
382
|
+
'subagent', 'subagent_fork', 'subagent_codex', 'codex_subagent', 'subagent_claude_code', 'subagent_oar', 'list_subagent_models',
|
|
289
383
|
'send_message', 'list_agents', 'interrupt_agent', 'wait_agent', 'workflow', 'ralph',
|
|
290
384
|
'create_goal', 'get_goal', 'update_goal', 'goal', 'spawn_teammate', 'team_task_create', 'team_task_get',
|
|
291
385
|
'team_task_list', 'team_task_update',
|
|
292
386
|
])
|
|
293
387
|
|
|
294
|
-
export type ToolGroupId = '
|
|
388
|
+
export type ToolGroupId = 'command' | 'file' | 'plan' | 'collab' | 'other'
|
|
295
389
|
|
|
296
|
-
export function groupOf(tool: PresetToolEntry
|
|
297
|
-
if (tool.name === 'codex_connect_image_generate') return 'gpt'
|
|
298
|
-
if (tool.name === 'web_search' && gptSearchActive) return 'gpt'
|
|
390
|
+
export function groupOf(tool: PresetToolEntry): ToolGroupId {
|
|
299
391
|
if (commandNames.has(tool.name) || tool.replacements.some(item => item.action === 'codex-exec')) return 'command'
|
|
300
392
|
if (fileNames.has(tool.name) || tool.replacements.some(item => item.action === 'codex-patch')) return 'file'
|
|
301
393
|
if (planNames.has(tool.name) || tool.replacements.some(item => item.action === 'codex-plan')) return 'plan'
|
|
@@ -313,7 +405,7 @@ export const humanLabels = {
|
|
|
313
405
|
glob: 'toolLabelGlob', grep: 'toolLabelGrep', read_image: 'toolLabelImage', lsp: 'toolLabelLsp',
|
|
314
406
|
update_plan: 'toolLabelPlan', todo_write: 'toolLabelTodo', exit_plan_mode: 'toolLabelExitPlan',
|
|
315
407
|
ask_user_question: 'toolLabelAskUser', present: 'toolLabelPresent', propose_action: 'toolLabelProposeAction', approve: 'toolLabelApprove',
|
|
316
|
-
subagent: 'toolLabelSubagent', subagent_fork: 'toolLabelSubagentFork', subagent_codex: 'toolLabelSubagentCodex',
|
|
408
|
+
subagent: 'toolLabelSubagent', subagent_fork: 'toolLabelSubagentFork', subagent_codex: 'toolLabelSubagentCodex', codex_subagent: 'toolLabelCodexSubagent',
|
|
317
409
|
subagent_claude_code: 'toolLabelSubagentClaude', subagent_oar: 'toolLabelSubagentOar', list_subagent_models: 'toolLabelSubagentModels',
|
|
318
410
|
send_message: 'toolLabelSendMessage', list_agents: 'toolLabelListAgents', interrupt_agent: 'toolLabelInterruptAgent',
|
|
319
411
|
wait_agent: 'toolLabelWaitAgent', workflow: 'toolLabelWorkflow', ralph: 'toolLabelRalph',
|
|
@@ -6,20 +6,26 @@ import type { RemoteResult, TypertClientRemote } from '@deepseek-ai/dsh-typert-p
|
|
|
6
6
|
import {
|
|
7
7
|
contextPresetsForBounds,
|
|
8
8
|
formatCompactTokens,
|
|
9
|
+
isOfficialOpenAiApiRoute,
|
|
9
10
|
OPENAI_CODEX_MODEL_CATALOG_PATH,
|
|
10
11
|
OPENAI_CODEX_MODEL_LIMITS,
|
|
11
12
|
OPENAI_CODEX_PROVIDER,
|
|
12
13
|
parseCustomContextInput,
|
|
13
14
|
resolveContextWindowBounds,
|
|
15
|
+
supportsApiProMode,
|
|
14
16
|
} from '../contracts/ui-contracts.ts'
|
|
15
17
|
import type {
|
|
16
18
|
CodexConnectScope,
|
|
19
|
+
CodexSubagentModelCatalog,
|
|
20
|
+
LlmProvidersMap,
|
|
21
|
+
LlmProvidersScope,
|
|
17
22
|
ModelDirectorySnapshot,
|
|
18
23
|
ModelDirectoryStore,
|
|
19
24
|
PresetCatalog,
|
|
20
25
|
PresetDefinitionDocument,
|
|
21
26
|
} from '../contracts/ui-contracts.ts'
|
|
22
27
|
import type { PresetPromptCatalog, PresetToolCatalog } from '../contracts/tool-policy-contract.ts'
|
|
28
|
+
import type { HarnessUpdateResult } from '../contracts/update.ts'
|
|
23
29
|
import { readPresetWithRetry } from './preset-requests.ts'
|
|
24
30
|
|
|
25
31
|
export interface PresetClientRemote extends TypertClientRemote {
|
|
@@ -28,6 +34,10 @@ export interface PresetClientRemote extends TypertClientRemote {
|
|
|
28
34
|
tools?(id: string): Promise<RemoteResult<PresetToolCatalog>>
|
|
29
35
|
prompts?(id: string): Promise<RemoteResult<PresetPromptCatalog>>
|
|
30
36
|
read(id: string): Promise<RemoteResult<PresetDefinitionDocument>>
|
|
37
|
+
proModeGet?(sessionId: string): Promise<RemoteResult<{ enabled: boolean }>>
|
|
38
|
+
proModeSet?(input: { sessionId: string; enabled: boolean }): Promise<RemoteResult<{ enabled: boolean }>>
|
|
39
|
+
updateCheck?(): Promise<RemoteResult<HarnessUpdateResult>>
|
|
40
|
+
codexSubagentModels?(): Promise<RemoteResult<CodexSubagentModelCatalog>>
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -132,15 +142,15 @@ export function useModelDirectory(modelDirectory: ModelDirectoryStore | undefine
|
|
|
132
142
|
export function pillStyle(active: boolean, writable: boolean) {
|
|
133
143
|
return {
|
|
134
144
|
boxSizing: 'border-box' as const,
|
|
135
|
-
display: '
|
|
145
|
+
display: 'flex',
|
|
136
146
|
alignItems: 'center',
|
|
137
147
|
gap: 5,
|
|
138
148
|
height: 28,
|
|
139
149
|
border: 0,
|
|
140
|
-
borderRadius:
|
|
141
|
-
padding: '
|
|
150
|
+
borderRadius: 'var(--dsw-radius-sm, 7px)',
|
|
151
|
+
padding: '3px 6px 0',
|
|
142
152
|
font: 'inherit',
|
|
143
|
-
fontSize:
|
|
153
|
+
fontSize: 13,
|
|
144
154
|
lineHeight: '20px',
|
|
145
155
|
whiteSpace: 'nowrap' as const,
|
|
146
156
|
color: active ? 'var(--dsw-static-blue-500)' : 'var(--dsw-alias-label-secondary)',
|
|
@@ -374,3 +384,114 @@ export function ContextWindowControl(props: ContextControlProps) {
|
|
|
374
384
|
) : null}
|
|
375
385
|
</>
|
|
376
386
|
}
|
|
387
|
+
|
|
388
|
+
/** Show the ephemeral API Pro toggle only for official OpenAI API GPT-5.6/6+ models. */
|
|
389
|
+
export function isProModeEligible(
|
|
390
|
+
snapshot: ModelDirectorySnapshot | undefined,
|
|
391
|
+
hasDirectory: boolean,
|
|
392
|
+
llmProviders?: LlmProvidersMap | undefined,
|
|
393
|
+
): boolean {
|
|
394
|
+
if (!hasDirectory || snapshot?.status !== 'ready' || snapshot.current === undefined) return false
|
|
395
|
+
return isOfficialOpenAiApiRoute(snapshot.current.provider, snapshot.current.model, llmProviders)
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export interface ProModeControlProps extends PropsLocale<'codex'> {
|
|
399
|
+
sessionId?: unknown
|
|
400
|
+
injectedSessionId?: string | undefined
|
|
401
|
+
useSettings: (select: (state: unknown) => unknown) => unknown
|
|
402
|
+
presetManager?: PresetManagerActions | undefined
|
|
403
|
+
modelDirectory?: ModelDirectoryStore | undefined
|
|
404
|
+
getLlmProvidersScope?: (() => LlmProvidersScope | undefined) | undefined
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export function ProModeControl(props: ProModeControlProps) {
|
|
408
|
+
const { sessionId, injectedSessionId, useSettings, presetManager, modelDirectory, getLlmProvidersScope, t } = props
|
|
409
|
+
const dirSnapshot = useModelDirectory(modelDirectory)
|
|
410
|
+
const snapshot = useSettings(state => state) as { value?: { proModeControlEnabled?: boolean } }
|
|
411
|
+
const visible = snapshot.value?.proModeControlEnabled ?? true
|
|
412
|
+
const maybeOfficial = modelDirectory !== undefined && dirSnapshot?.status === 'ready'
|
|
413
|
+
&& dirSnapshot.current?.provider !== OPENAI_CODEX_PROVIDER && supportsApiProMode(dirSnapshot.current?.model)
|
|
414
|
+
const providersScope = maybeOfficial ? getLlmProvidersScope?.() : undefined
|
|
415
|
+
const subscribeProviders = useCallback((listener: () => void) => providersScope ? providersScope.subscribe(listener) : NOOP_SUBSCRIBE(), [providersScope])
|
|
416
|
+
const getProvidersSnap = useCallback(() => providersScope?.getSnapshot(), [providersScope])
|
|
417
|
+
const llmProviders = useSyncExternalStore(subscribeProviders, getProvidersSnap, getProvidersSnap)
|
|
418
|
+
const eligible = isProModeEligible(dirSnapshot, modelDirectory !== undefined, llmProviders)
|
|
419
|
+
const rawSessionId = sessionId ?? injectedSessionId
|
|
420
|
+
const normalizedSessionId = typeof rawSessionId === 'string'
|
|
421
|
+
? rawSessionId.trim()
|
|
422
|
+
: rawSessionId !== undefined && rawSessionId !== null
|
|
423
|
+
? String(rawSessionId).trim()
|
|
424
|
+
: ''
|
|
425
|
+
const [enabled, setEnabled] = useState(false)
|
|
426
|
+
const [pending, setPending] = useState(false)
|
|
427
|
+
const activeSessionRef = useRef(normalizedSessionId)
|
|
428
|
+
const mountedRef = useRef(true)
|
|
429
|
+
activeSessionRef.current = normalizedSessionId
|
|
430
|
+
|
|
431
|
+
useEffect(() => {
|
|
432
|
+
mountedRef.current = true
|
|
433
|
+
return () => { mountedRef.current = false }
|
|
434
|
+
}, [])
|
|
435
|
+
|
|
436
|
+
useEffect(() => {
|
|
437
|
+
setEnabled(false)
|
|
438
|
+
setPending(false)
|
|
439
|
+
if (!visible || !eligible || normalizedSessionId.length === 0) return undefined
|
|
440
|
+
let active = true
|
|
441
|
+
void Promise.resolve(presetManager?.ready).then(async () => {
|
|
442
|
+
const api = presetManager?.remote?.codexPresetEditor
|
|
443
|
+
if (!active || typeof api?.proModeGet !== 'function') return
|
|
444
|
+
const result = await api.proModeGet(normalizedSessionId)
|
|
445
|
+
if (active && result.ok) setEnabled(result.value.enabled)
|
|
446
|
+
}).catch(() => {})
|
|
447
|
+
return () => { active = false }
|
|
448
|
+
}, [visible, eligible, normalizedSessionId, presetManager])
|
|
449
|
+
|
|
450
|
+
if (!visible || !eligible) return null
|
|
451
|
+
const interactive = !pending && normalizedSessionId.length > 0
|
|
452
|
+
const label = enabled ? t('proOn') : t('proOff')
|
|
453
|
+
const toggle = (): void => {
|
|
454
|
+
if (!interactive) return
|
|
455
|
+
const targetSessionId = normalizedSessionId
|
|
456
|
+
const next = !enabled
|
|
457
|
+
setPending(true)
|
|
458
|
+
setEnabled(next)
|
|
459
|
+
void Promise.resolve(presetManager?.ready).then(async () => {
|
|
460
|
+
const api = presetManager?.remote?.codexPresetEditor
|
|
461
|
+
if (typeof api?.proModeSet !== 'function') {
|
|
462
|
+
if (mountedRef.current && activeSessionRef.current === targetSessionId) setEnabled(!next)
|
|
463
|
+
return
|
|
464
|
+
}
|
|
465
|
+
const result = await api.proModeSet({ sessionId: targetSessionId, enabled: next })
|
|
466
|
+
if (mountedRef.current && activeSessionRef.current === targetSessionId) {
|
|
467
|
+
setEnabled(result.ok ? result.value.enabled : !next)
|
|
468
|
+
}
|
|
469
|
+
}).catch(() => {
|
|
470
|
+
if (mountedRef.current && activeSessionRef.current === targetSessionId) setEnabled(!next)
|
|
471
|
+
}).finally(() => {
|
|
472
|
+
if (mountedRef.current && activeSessionRef.current === targetSessionId) setPending(false)
|
|
473
|
+
})
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return (
|
|
477
|
+
<button
|
|
478
|
+
type="button"
|
|
479
|
+
role="switch"
|
|
480
|
+
disabled={!interactive}
|
|
481
|
+
aria-checked={enabled}
|
|
482
|
+
data-codex-pro-control={enabled ? 'on' : 'off'}
|
|
483
|
+
aria-label={label}
|
|
484
|
+
title={label}
|
|
485
|
+
onClick={toggle}
|
|
486
|
+
style={{
|
|
487
|
+
...pillStyle(enabled, interactive),
|
|
488
|
+
...(enabled ? { boxShadow: 'inset 0 0 0 1px var(--dsw-static-blue-500)' } : {}),
|
|
489
|
+
}}
|
|
490
|
+
>
|
|
491
|
+
<span>{t('pro')}</span>
|
|
492
|
+
<span style={{ color: enabled ? 'var(--dsw-static-blue-500)' : 'var(--dsw-alias-label-secondary)', fontSize: 12 }}>
|
|
493
|
+
{enabled ? t('fastStateOn') : t('fastStateOff')}
|
|
494
|
+
</span>
|
|
495
|
+
</button>
|
|
496
|
+
)
|
|
497
|
+
}
|