@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.
- package/CHANGELOG.md +29 -0
- package/README.md +21 -43
- package/docs/preset-library.md +2 -2
- package/docs/tool-policy.md +1 -1
- package/lib/client.js +1738 -327
- package/lib/compact-command.js +7 -1
- package/lib/compaction.js +7 -1
- package/lib/hybrid-executor.js +23 -12
- package/lib/index.js +1266 -36
- 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 +191 -126
- package/lib/types/client/index.d.ts +104 -28
- 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 +80 -20
- package/lib/types/client/policy-locale.js +197 -80
- 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 +7 -2
- package/lib/types/client/tool-policy.js +48 -6
- 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 +52 -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/compact-checkpoint.js +3 -10
- package/lib/types/responses/fetch-transport.js +24 -9
- package/lib/types/responses/remote-compact.js +39 -11
- 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 +370 -153
- package/src/client/index.tsx +122 -22
- package/src/client/policy-drafts.ts +45 -0
- package/src/client/policy-locale.ts +197 -80
- package/src/client/preset-manager.tsx +125 -4
- package/src/client/preset-requests.ts +185 -1
- package/src/client/tool-policy.tsx +63 -9
- package/src/contracts/preset-editor-schema.ts +44 -0
- package/src/contracts/settings.ts +20 -1
- package/src/contracts/ui-contracts.ts +91 -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/compact-checkpoint.ts +2 -8
- package/src/responses/fetch-transport.ts +28 -9
- package/src/responses/remote-compact.ts +41 -11
- 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
package/src/client/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Browser controls, /compact decorator, and live activity line for Codex Harness. */
|
|
2
2
|
|
|
3
|
-
import { useEffect, useState } from 'react'
|
|
3
|
+
import { useEffect, useState, useSyncExternalStore } from 'react'
|
|
4
4
|
import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
5
5
|
import type { Context } from '@deepseek-ai/cordis'
|
|
6
6
|
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
@@ -12,19 +12,17 @@ import type {} from '@deepseek-ai/dsh-api-remotes/client'
|
|
|
12
12
|
import type { TypertClientRemote } from '@deepseek-ai/dsh-typert-protocol'
|
|
13
13
|
import { OPENAI_CODEX_PROVIDER } from '../contracts/ui-contracts.ts'
|
|
14
14
|
import type {
|
|
15
|
-
CodexActivity,
|
|
16
|
-
CodexConnectScope,
|
|
17
|
-
CodexConnectSnapshot,
|
|
18
|
-
ModelDirectorySnapshot,
|
|
19
|
-
ModelDirectoryStore,
|
|
15
|
+
CodexActivity, CodexConnectScope, CodexConnectSnapshot, LlmProvidersScope, ModelDirectorySnapshot, ModelDirectoryStore,
|
|
20
16
|
} from '../contracts/ui-contracts.ts'
|
|
17
|
+
import { HarnessUpdateStore, harnessUpdateNoticeKey } from '../contracts/update.ts'
|
|
18
|
+
import type { HarnessUpdateSnapshot } from '../contracts/update.ts'
|
|
21
19
|
import { modelActivity, sameModelActivity } from './activity.ts'
|
|
22
20
|
import presetEditorRemote from '../contracts/preset-editor-schema.ts'
|
|
23
21
|
import { toolPolicyEn, toolPolicyZh } from './tool-policy.tsx'
|
|
24
|
-
import { ContextWindowControl, isGptModelName, pillStyle, useModelDirectory } from './preset-manager.tsx'
|
|
22
|
+
import { ContextWindowControl, isGptModelName, isProModeEligible, pillStyle, ProModeControl, useModelDirectory } from './preset-manager.tsx'
|
|
25
23
|
import type { PresetClientRemote, PresetManagerActions } from './preset-manager.tsx'
|
|
26
|
-
export { ContextWindowControl }
|
|
27
|
-
export type { CodexConnectScope, CodexConnectSnapshot, ModelDirectorySnapshot, ModelDirectoryStore }
|
|
24
|
+
export { ContextWindowControl, isProModeEligible, ProModeControl }
|
|
25
|
+
export type { CodexConnectScope, CodexConnectSnapshot, HarnessUpdateSnapshot, ModelDirectorySnapshot, ModelDirectoryStore }
|
|
28
26
|
|
|
29
27
|
interface CompactCommandOption {
|
|
30
28
|
id: string
|
|
@@ -76,6 +74,7 @@ const FAST_FALLBACK_SLOT = 'conversation.input.right' as const
|
|
|
76
74
|
export interface CodexSettings {
|
|
77
75
|
fast: boolean
|
|
78
76
|
fastModeControlEnabled: boolean
|
|
77
|
+
proModeControlEnabled: boolean
|
|
79
78
|
contextWindowControlEnabled: boolean
|
|
80
79
|
contextWindow?: number
|
|
81
80
|
persona?: string
|
|
@@ -89,6 +88,10 @@ export interface CodexSettings {
|
|
|
89
88
|
hostedWebSearchEnabled: boolean
|
|
90
89
|
remoteCompactionEnabled: boolean
|
|
91
90
|
activityIndicatorEnabled: boolean
|
|
91
|
+
codexSubagentEnabled?: boolean
|
|
92
|
+
codexSubagentModel?: string
|
|
93
|
+
codexSubagentEffort?: string
|
|
94
|
+
codexSubagentPreset?: string
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
/** Observable ConfigForms settings snapshot shared with the desktop adapter. */
|
|
@@ -110,24 +113,28 @@ const en = {
|
|
|
110
113
|
...toolPolicyEn,
|
|
111
114
|
fast: 'Fast mode',
|
|
112
115
|
fastModeControl: 'Show fast mode control',
|
|
116
|
+
proModeControl: 'Show API Pro mode control',
|
|
113
117
|
contextWindowControl: 'Show context window control',
|
|
114
118
|
fastOn: 'Fast mode on (priority tier)',
|
|
115
119
|
fastOff: 'Fast mode off',
|
|
116
120
|
fastStateOn: 'On',
|
|
117
121
|
fastStateOff: 'Off',
|
|
122
|
+
pro: 'Pro',
|
|
123
|
+
proOn: 'Pro mode on',
|
|
124
|
+
proOff: 'Pro mode off',
|
|
118
125
|
contextSize: 'Context size',
|
|
119
126
|
contextShortDefault: 'Ctx',
|
|
120
127
|
contextDefaultOption: 'Default',
|
|
121
128
|
contextCustomPlaceholder: '≥16k (e.g. 64)',
|
|
122
129
|
contextApply: 'Set',
|
|
123
130
|
compactRemote: 'Remote compaction',
|
|
124
|
-
compactRemoteHint: 'Use
|
|
125
|
-
compactLocal: '
|
|
126
|
-
compactLocalHint: '
|
|
131
|
+
compactRemoteHint: 'Use provider remote compaction first.',
|
|
132
|
+
compactLocal: 'Model summary',
|
|
133
|
+
compactLocalHint: 'Compact context with a model summary.',
|
|
127
134
|
capabilityActivity: 'Activity indicator',
|
|
128
135
|
promptDiscard: 'Discard',
|
|
129
136
|
promptSaving: 'Saving...',
|
|
130
|
-
promptReadOnly: '
|
|
137
|
+
promptReadOnly: 'Settings are read-only.',
|
|
131
138
|
activityCompacting: 'Compacting context...',
|
|
132
139
|
activityRequestingModel: 'Requesting model...',
|
|
133
140
|
activityModelReply: 'Model replying...',
|
|
@@ -136,25 +143,29 @@ const en = {
|
|
|
136
143
|
const zh: Record<keyof typeof en, string> = {
|
|
137
144
|
...toolPolicyZh,
|
|
138
145
|
fastModeControl: '显示快速模式开关',
|
|
146
|
+
proModeControl: '显示 API Pro 模式开关',
|
|
139
147
|
contextWindowControl: '显示上下文大小快捷按钮',
|
|
140
148
|
fast: '快速模式',
|
|
141
149
|
fastOn: '快速模式已开启(优先通道)',
|
|
142
150
|
fastOff: '快速模式已关闭',
|
|
143
151
|
fastStateOn: '开',
|
|
144
152
|
fastStateOff: '关',
|
|
153
|
+
pro: 'Pro',
|
|
154
|
+
proOn: 'Pro 模式已开启',
|
|
155
|
+
proOff: 'Pro 模式已关闭',
|
|
145
156
|
contextSize: '上下文大小',
|
|
146
157
|
contextShortDefault: '上下文',
|
|
147
158
|
contextDefaultOption: '默认',
|
|
148
159
|
contextCustomPlaceholder: '≥16k (如 64)',
|
|
149
160
|
contextApply: '确定',
|
|
150
161
|
compactRemote: '远程压缩',
|
|
151
|
-
compactRemoteHint: '
|
|
152
|
-
compactLocal: '
|
|
153
|
-
compactLocalHint: '
|
|
162
|
+
compactRemoteHint: '优先使用服务端远程压缩。',
|
|
163
|
+
compactLocal: '模型摘要',
|
|
164
|
+
compactLocalHint: '使用模型摘要压缩上下文。',
|
|
154
165
|
capabilityActivity: '活动状态',
|
|
155
166
|
promptDiscard: '放弃',
|
|
156
167
|
promptSaving: '保存中...',
|
|
157
|
-
promptReadOnly: '
|
|
168
|
+
promptReadOnly: '当前设置为只读。',
|
|
158
169
|
activityCompacting: '正在压缩上下文...',
|
|
159
170
|
activityRequestingModel: '请求中...',
|
|
160
171
|
activityModelReply: '回复中...',
|
|
@@ -184,8 +195,10 @@ export interface InputSettingsControlInjected {
|
|
|
184
195
|
setSetting: (field: string, value: unknown) => Promise<void>
|
|
185
196
|
unsetSetting: (field: string) => Promise<void>
|
|
186
197
|
presetManager: PresetManagerActions
|
|
198
|
+
injectedSessionId?: string | undefined
|
|
187
199
|
modelDirectory?: ModelDirectoryStore | undefined
|
|
188
200
|
getCodexConnectScope?: (() => CodexConnectScope | undefined) | undefined
|
|
201
|
+
getLlmProvidersScope?: (() => LlmProvidersScope | undefined) | undefined
|
|
189
202
|
}
|
|
190
203
|
|
|
191
204
|
type InputRightProps = Pick<PropsRuntime<'conversation.input.right'>, 'sessionId' | 'useSessions'>
|
|
@@ -207,13 +220,13 @@ export function FastModeFallback(props: InputRightProps) {
|
|
|
207
220
|
style={pillStyle(fast, snapshot.writable !== false)}
|
|
208
221
|
>
|
|
209
222
|
<span>{t('fast')}</span>
|
|
210
|
-
<span style={{ color: 'var(--dsw-alias-label-secondary)', fontSize:
|
|
223
|
+
<span style={{ color: 'var(--dsw-alias-label-secondary)', fontSize: 12 }}>{fast ? t('fastStateOn') : t('fastStateOff')}</span>
|
|
211
224
|
</button>
|
|
212
225
|
)
|
|
213
226
|
}
|
|
214
227
|
|
|
215
228
|
export function ComposerControls(props: InputRightProps) {
|
|
216
|
-
return <><ContextWindowControl {...props} /><FastModeFallback {...props} /></>
|
|
229
|
+
return <><ContextWindowControl {...props} /><ProModeControl {...props} /><FastModeFallback {...props} /></>
|
|
217
230
|
}
|
|
218
231
|
|
|
219
232
|
type ActivityProps = PropsRuntime<'conversation.input.dock'>
|
|
@@ -310,17 +323,76 @@ function createPresetManager(ctx: Context): PresetManagerActions {
|
|
|
310
323
|
ctx.effect(() => () => { void dispose() }, 'codex client: preset editor remote')
|
|
311
324
|
})
|
|
312
325
|
void ready.catch(() => {})
|
|
326
|
+
let boundRemote: PresetClientRemote | undefined
|
|
327
|
+
ctx.inject(['remote', 'remote.codexPresetEditor'], remoteCtx => {
|
|
328
|
+
boundRemote = (remoteCtx as unknown as { remote?: PresetClientRemote }).remote
|
|
329
|
+
return () => { boundRemote = undefined }
|
|
330
|
+
})
|
|
331
|
+
const resolveCodexPresetEditor = (): PresetClientRemote['codexPresetEditor'] | undefined => {
|
|
332
|
+
if (boundRemote !== undefined) return boundRemote.codexPresetEditor
|
|
333
|
+
const fromCtx = (ctx as unknown as { get?(key: string): unknown }).get?.('remote.codexPresetEditor')
|
|
334
|
+
if (fromCtx !== undefined) return fromCtx as PresetClientRemote['codexPresetEditor']
|
|
335
|
+
try {
|
|
336
|
+
return (remote as unknown as PresetClientRemote | undefined)?.codexPresetEditor
|
|
337
|
+
} catch {
|
|
338
|
+
return undefined
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const safeRemote = new Proxy((remote ?? {}) as PresetClientRemote, {
|
|
342
|
+
get(target, prop, receiver) {
|
|
343
|
+
if (prop === 'codexPresetEditor') return resolveCodexPresetEditor()
|
|
344
|
+
return Reflect.get(target, prop, receiver)
|
|
345
|
+
},
|
|
346
|
+
})
|
|
313
347
|
return {
|
|
314
|
-
remote:
|
|
348
|
+
remote: safeRemote,
|
|
315
349
|
ready,
|
|
316
350
|
}
|
|
317
351
|
}
|
|
318
352
|
|
|
353
|
+
export function HarnessUpdateOverlay({ updater, t }: { updater: HarnessUpdateStore } & PropsLocale<'codex'>) {
|
|
354
|
+
const snapshot = useSyncExternalStore(updater.subscribe, updater.getSnapshot, updater.getSnapshot)
|
|
355
|
+
const noticeKey = harnessUpdateNoticeKey(snapshot)
|
|
356
|
+
const visible = snapshot.status === 'update-available' && noticeKey !== undefined && snapshot.dismissedNotice !== noticeKey && snapshot.latestVersion !== undefined
|
|
357
|
+
useEffect(() => {
|
|
358
|
+
if (visible && noticeKey !== undefined) updater.markShown(noticeKey)
|
|
359
|
+
}, [visible, noticeKey, updater])
|
|
360
|
+
if (!visible || noticeKey === undefined || snapshot.latestVersion === undefined) return null
|
|
361
|
+
return (
|
|
362
|
+
<div
|
|
363
|
+
role="status"
|
|
364
|
+
aria-label={t('updateHeading')}
|
|
365
|
+
data-codex-update-overlay
|
|
366
|
+
style={{
|
|
367
|
+
position: 'absolute', top: 52, right: 18, zIndex: 30, display: 'inline-flex', alignItems: 'center', gap: 10,
|
|
368
|
+
maxWidth: 'calc(100vw - 36px)', padding: '6px 10px 6px 12px', border: '0.5px solid var(--dsw-alias-border-l2)',
|
|
369
|
+
borderRadius: 8, background: 'var(--dsw-alias-bg-module-platform, var(--dsw-alias-bg-layer-1))',
|
|
370
|
+
color: 'var(--dsw-alias-label-primary)', boxShadow: '0 4px 16px rgba(0, 0, 0, 0.14)',
|
|
371
|
+
fontSize: 12, lineHeight: '18px', whiteSpace: 'nowrap', boxSizing: 'border-box',
|
|
372
|
+
}}
|
|
373
|
+
>
|
|
374
|
+
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>Codex Harness {t('updateAvailable')} v{snapshot.latestVersion}</span>
|
|
375
|
+
{snapshot.releaseUrl && (
|
|
376
|
+
<a href={snapshot.releaseUrl} target="_blank" rel="noopener noreferrer"
|
|
377
|
+
style={{ color: 'var(--dsw-alias-brand-primary)', textDecoration: 'underline', textUnderlineOffset: 2, flexShrink: 0 }}>
|
|
378
|
+
{t('updateOpenRelease')}
|
|
379
|
+
</a>
|
|
380
|
+
)}
|
|
381
|
+
<button type="button" aria-label={t('updateDismiss')} title={t('updateDismiss')} onClick={() => updater.dismiss(noticeKey)}
|
|
382
|
+
style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 20, height: 20, padding: 0, border: 0,
|
|
383
|
+
borderRadius: 4, background: 'transparent', color: 'var(--dsw-alias-label-secondary)', font: 'inherit', fontSize: 14, lineHeight: 1, cursor: 'pointer', flexShrink: 0 }}>
|
|
384
|
+
×
|
|
385
|
+
</button>
|
|
386
|
+
</div>
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
|
|
319
390
|
/** Mount request controls and the plugin settings card through shared slots. */
|
|
320
391
|
export interface ClientSettingsApi {
|
|
321
392
|
bind(ctx: Context): CodexScope
|
|
322
393
|
getCodexConnectScope?: () => CodexConnectScope | undefined
|
|
323
|
-
|
|
394
|
+
getLlmProvidersScope?: () => LlmProvidersScope | undefined
|
|
395
|
+
register(ctx: Context, settings: CodexScope, manager: PresetManagerActions, updateStore: HarnessUpdateStore): () => void
|
|
324
396
|
}
|
|
325
397
|
|
|
326
398
|
export function applyWithSettingsApi(ctx: Context, api: ClientSettingsApi): void {
|
|
@@ -358,6 +430,22 @@ export function applyWithSettingsApi(ctx: Context, api: ClientSettingsApi): void
|
|
|
358
430
|
}), 'codex client: /compact mode picker')
|
|
359
431
|
const settings = api.bind(ctx)
|
|
360
432
|
const presetManager = createPresetManager(ctx)
|
|
433
|
+
const updateStore = new HarnessUpdateStore(async () => {
|
|
434
|
+
await presetManager.ready
|
|
435
|
+
const check = presetManager.remote.codexPresetEditor?.updateCheck
|
|
436
|
+
if (typeof check !== 'function') return undefined
|
|
437
|
+
const result = await check()
|
|
438
|
+
return result.ok ? result.value : undefined
|
|
439
|
+
})
|
|
440
|
+
ctx.effect(() => {
|
|
441
|
+
let active = true
|
|
442
|
+
void presetManager.ready.then(() => {
|
|
443
|
+
if (active && typeof presetManager.remote.codexPresetEditor?.updateCheck === 'function') {
|
|
444
|
+
void updateStore.refresh()
|
|
445
|
+
}
|
|
446
|
+
}).catch(() => {})
|
|
447
|
+
return () => { active = false; updateStore.dispose() }
|
|
448
|
+
}, 'codex client: update checker')
|
|
361
449
|
const injected = () => ({
|
|
362
450
|
hooks: { settings },
|
|
363
451
|
setSetting: (field: string, value: unknown) => settings.set(field, value),
|
|
@@ -371,7 +459,9 @@ export function applyWithSettingsApi(ctx: Context, api: ClientSettingsApi): void
|
|
|
371
459
|
locale: NS,
|
|
372
460
|
inject: (sessionId?: unknown) => ({
|
|
373
461
|
...injected(),
|
|
462
|
+
injectedSessionId: typeof sessionId === 'string' ? sessionId : sessionId !== undefined && sessionId !== null ? String(sessionId) : undefined,
|
|
374
463
|
getCodexConnectScope: api.getCodexConnectScope,
|
|
464
|
+
getLlmProvidersScope: api.getLlmProvidersScope,
|
|
375
465
|
modelDirectory: sessionId === undefined
|
|
376
466
|
? undefined
|
|
377
467
|
: ((ctx as unknown as { get(key: string): ModelDirectoriesService | undefined }).get('modelDirectories'))?.directoryFor(sessionId)?.store,
|
|
@@ -384,8 +474,18 @@ export function applyWithSettingsApi(ctx: Context, api: ClientSettingsApi): void
|
|
|
384
474
|
locale: NS,
|
|
385
475
|
inject: injected,
|
|
386
476
|
}, ActivityLine))
|
|
477
|
+
if (typeof (ctx.slots as { spec?(name: string): unknown }).spec !== 'function'
|
|
478
|
+
|| (ctx.slots as { spec(name: string): unknown }).spec('shell.overlay') !== undefined) {
|
|
479
|
+
ctx.slots.inject('shell.overlay' as never, () => ctx.slots.register({
|
|
480
|
+
name: 'shell.overlay' as never,
|
|
481
|
+
id: 'codex-harness-update',
|
|
482
|
+
order: 45,
|
|
483
|
+
locale: NS,
|
|
484
|
+
inject: () => ({ updater: updateStore }),
|
|
485
|
+
} as never, HarnessUpdateOverlay as never))
|
|
486
|
+
}
|
|
387
487
|
ctx.inject(
|
|
388
488
|
['remote', 'remote.codexPresetEditor'],
|
|
389
|
-
settingsCtx => api.register(settingsCtx, settings, presetManager),
|
|
489
|
+
settingsCtx => api.register(settingsCtx, settings, presetManager, updateStore),
|
|
390
490
|
)
|
|
391
491
|
}
|
|
@@ -1,4 +1,49 @@
|
|
|
1
1
|
import type { ToolPolicyRule } from '../contracts/tool-policy-contract.ts'
|
|
2
|
+
import type { CodexConnectSnapshot } from '../contracts/ui-contracts.ts'
|
|
3
|
+
|
|
4
|
+
export interface GptCapabilitiesState {
|
|
5
|
+
readonly hostedWebSearch: boolean
|
|
6
|
+
readonly codexSearch: boolean
|
|
7
|
+
readonly codexSearchModel?: string | undefined
|
|
8
|
+
readonly remoteCompaction: boolean
|
|
9
|
+
readonly imageGeneration: boolean
|
|
10
|
+
readonly imageModelHint?: string | undefined
|
|
11
|
+
readonly codexSubagent?: boolean | undefined
|
|
12
|
+
readonly codexSubagentModel?: string | undefined
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function resolveGptCapabilities(
|
|
16
|
+
codexSettings?: {
|
|
17
|
+
readonly hostedWebSearchEnabled?: boolean
|
|
18
|
+
readonly remoteCompactionEnabled?: boolean
|
|
19
|
+
readonly codexSubagentEnabled?: boolean
|
|
20
|
+
readonly codexSubagentModel?: string
|
|
21
|
+
} | undefined,
|
|
22
|
+
codexConnect?: CodexConnectSnapshot | undefined,
|
|
23
|
+
): GptCapabilitiesState | undefined {
|
|
24
|
+
const connectReady = codexConnect?.status === 'ready'
|
|
25
|
+
if (codexSettings === undefined && !connectReady) return undefined
|
|
26
|
+
const subagentModel = codexSettings?.codexSubagentModel?.trim() || undefined
|
|
27
|
+
return {
|
|
28
|
+
hostedWebSearch: codexSettings !== undefined ? (codexSettings.hostedWebSearchEnabled ?? true) : false,
|
|
29
|
+
codexSearch: connectReady && codexConnect.searchEnabled === true,
|
|
30
|
+
codexSearchModel: connectReady ? codexConnect.searchModel : undefined,
|
|
31
|
+
remoteCompaction: (codexSettings !== undefined && (codexSettings.remoteCompactionEnabled ?? true))
|
|
32
|
+
|| (connectReady && codexConnect.nativeCompaction === true),
|
|
33
|
+
imageGeneration: connectReady && codexConnect.imageGenerationEnabled === true,
|
|
34
|
+
imageModelHint: connectReady ? codexConnect.imageModelHint : undefined,
|
|
35
|
+
...(codexSettings?.codexSubagentEnabled === true ? { codexSubagent: true } : {}),
|
|
36
|
+
...(subagentModel !== undefined ? { codexSubagentModel: subagentModel } : {}),
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function formatGptImageBadge(hint: string | undefined): string {
|
|
41
|
+
const value = hint?.trim() ?? ''
|
|
42
|
+
if (!value || value === 'gpt-image-2.6-sunburst') return 'GPT-Image-2.6 Sunburst'
|
|
43
|
+
if (value === 'gpt-image-2.6-flare') return 'GPT-Image-2.6 Flare'
|
|
44
|
+
if (value === 'gpt-image-2') return 'GPT-Image-2'
|
|
45
|
+
return value
|
|
46
|
+
}
|
|
2
47
|
|
|
3
48
|
/** Ephemeral UI drafts only; accepted ConfigForms values remain authoritative. */
|
|
4
49
|
export interface PresetDraft {
|