@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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { PresetCatalog } from '../contracts/ui-contracts.ts';
|
|
1
|
+
import type { CodexConnectScope, CodexSubagentModelCatalog, LlmProvidersScope, PresetCatalog } from '../contracts/ui-contracts.ts';
|
|
2
|
+
import type { CodexScope } from './index.tsx';
|
|
2
3
|
import type { PresetManagerActions } from './preset-manager.tsx';
|
|
3
4
|
import type { PresetPromptCatalog, PresetToolCatalog } from '../contracts/tool-policy-contract.ts';
|
|
4
5
|
export declare function cachedPresetCatalog(manager: PresetManagerActions): PresetCatalog | undefined;
|
|
@@ -6,6 +7,7 @@ export declare function cachePresetCatalog(manager: PresetManagerActions, catalo
|
|
|
6
7
|
/** One cache and one in-flight catalog read for every surface using this manager. */
|
|
7
8
|
export declare function requestPresetCatalog(manager: PresetManagerActions, refresh?: boolean): Promise<PresetCatalog>;
|
|
8
9
|
export declare function cachedPresetTools(manager: PresetManagerActions, id: string): PresetToolCatalog | undefined;
|
|
10
|
+
export declare function invalidatePresetTools(manager: PresetManagerActions): void;
|
|
9
11
|
/** The requested preset owns this snapshot; never substitute current-Agent tools. */
|
|
10
12
|
export declare function requestPresetTools(manager: PresetManagerActions, id: string, refresh?: boolean): Promise<PresetToolCatalog>;
|
|
11
13
|
export declare function cachedPresetPrompts(manager: PresetManagerActions, id: string): PresetPromptCatalog | undefined;
|
|
@@ -13,4 +15,45 @@ export declare function requestPresetPrompts(manager: PresetManagerActions, id:
|
|
|
13
15
|
/** Only transport failures from a read can be retried without duplicating writes. */
|
|
14
16
|
export declare function isPresetConnectionError(error: unknown): boolean;
|
|
15
17
|
export declare function readPresetWithRetry<T>(read: () => Promise<T>, active: () => boolean): Promise<T>;
|
|
18
|
+
export declare function requestCodexSubagentModels(manager: PresetManagerActions): Promise<CodexSubagentModelCatalog>;
|
|
19
|
+
export interface DesktopConfigForm extends Pick<CodexScope, 'getSnapshot' | 'subscribe'> {
|
|
20
|
+
set(field: string, value: unknown): Promise<boolean>;
|
|
21
|
+
unset(field: string): Promise<boolean>;
|
|
22
|
+
mutate(ops: Array<{
|
|
23
|
+
op: 'set';
|
|
24
|
+
path: string[];
|
|
25
|
+
value: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
op: 'unset';
|
|
28
|
+
path: string[];
|
|
29
|
+
}>, expectedRevision?: number | string): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
interface MirrorNamespaceRow {
|
|
32
|
+
readonly ns: string;
|
|
33
|
+
readonly value?: unknown;
|
|
34
|
+
readonly base?: unknown;
|
|
35
|
+
}
|
|
36
|
+
interface ConfigMirror {
|
|
37
|
+
getSnapshot(): {
|
|
38
|
+
readonly status?: string;
|
|
39
|
+
readonly view?: {
|
|
40
|
+
readonly writable?: boolean;
|
|
41
|
+
readonly namespaces?: readonly MirrorNamespaceRow[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
subscribe(listener: () => void): () => void;
|
|
45
|
+
ensure?(): unknown;
|
|
46
|
+
}
|
|
47
|
+
export interface DesktopSettingsContext {
|
|
48
|
+
configForms: {
|
|
49
|
+
get(entryId: string): DesktopConfigForm;
|
|
50
|
+
describe?(): ConfigMirror;
|
|
51
|
+
whileServed(namespaces: string[], register: () => () => void): () => void;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export declare function bindCodexConnectScope(configForms: DesktopSettingsContext['configForms']): CodexConnectScope;
|
|
55
|
+
export declare function bindLlmProvidersScope(configForms: DesktopSettingsContext['configForms']): LlmProvidersScope | undefined;
|
|
56
|
+
export declare function adaptConfigForm(form: Pick<DesktopConfigForm, 'getSnapshot' | 'subscribe' | 'set' | 'unset'>): CodexScope;
|
|
57
|
+
export declare function saveDesktopSettings(form: Pick<DesktopConfigForm, 'mutate'>, edits: Record<string, unknown>, expectedRevision?: number | string): Promise<void>;
|
|
58
|
+
export {};
|
|
16
59
|
//# sourceMappingURL=preset-requests.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nextOpenAICodexOverrides, OPENAI_CODEX_SETTINGS_NAMESPACE, } from "../contracts/ui-contracts.js";
|
|
1
2
|
const catalogs = new WeakMap();
|
|
2
3
|
const catalogRequests = new WeakMap();
|
|
3
4
|
export function cachedPresetCatalog(manager) {
|
|
@@ -34,6 +35,9 @@ const toolRequests = new WeakMap();
|
|
|
34
35
|
export function cachedPresetTools(manager, id) {
|
|
35
36
|
return toolCatalogs.get(manager)?.get(id);
|
|
36
37
|
}
|
|
38
|
+
export function invalidatePresetTools(manager) {
|
|
39
|
+
toolCatalogs.delete(manager);
|
|
40
|
+
}
|
|
37
41
|
/** The requested preset owns this snapshot; never substitute current-Agent tools. */
|
|
38
42
|
export function requestPresetTools(manager, id, refresh = false) {
|
|
39
43
|
const pending = toolRequests.get(manager)?.get(id);
|
|
@@ -117,4 +121,150 @@ export async function readPresetWithRetry(read, active) {
|
|
|
117
121
|
return read();
|
|
118
122
|
}
|
|
119
123
|
}
|
|
124
|
+
const subagentModelRequests = new WeakMap();
|
|
125
|
+
export function requestCodexSubagentModels(manager) {
|
|
126
|
+
const pending = subagentModelRequests.get(manager);
|
|
127
|
+
if (pending !== undefined)
|
|
128
|
+
return pending;
|
|
129
|
+
const request = (async () => {
|
|
130
|
+
await manager.ready;
|
|
131
|
+
const remote = manager.remote.codexPresetEditor;
|
|
132
|
+
if (typeof remote.codexSubagentModels !== 'function')
|
|
133
|
+
throw new Error('codex-subagent-models-unavailable');
|
|
134
|
+
const result = await remote.codexSubagentModels();
|
|
135
|
+
if (!result.ok)
|
|
136
|
+
throw new Error(result.error.message ?? 'codex-subagent-models-unavailable');
|
|
137
|
+
return result.value;
|
|
138
|
+
})();
|
|
139
|
+
subagentModelRequests.set(manager, request);
|
|
140
|
+
void request.finally(() => {
|
|
141
|
+
if (subagentModelRequests.get(manager) === request)
|
|
142
|
+
subagentModelRequests.delete(manager);
|
|
143
|
+
}).catch(() => { });
|
|
144
|
+
return request;
|
|
145
|
+
}
|
|
146
|
+
function asRecord(value) {
|
|
147
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
148
|
+
? value
|
|
149
|
+
: undefined;
|
|
150
|
+
}
|
|
151
|
+
function asOverrides(value) {
|
|
152
|
+
const record = asRecord(value);
|
|
153
|
+
if (record === undefined)
|
|
154
|
+
return undefined;
|
|
155
|
+
const out = {};
|
|
156
|
+
for (const [k, v] of Object.entries(record)) {
|
|
157
|
+
if (v === null || (typeof v === 'number' && Number.isSafeInteger(v) && v > 0))
|
|
158
|
+
out[k] = v;
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
function projectCodexConnectRecord(record, baseRecord, writable) {
|
|
163
|
+
const searchModel = typeof record.searchModel === 'string' && record.searchModel.trim() ? record.searchModel.trim() : undefined;
|
|
164
|
+
const imageModelHint = typeof record.imageModelHint === 'string' ? record.imageModelHint.trim() : undefined;
|
|
165
|
+
return {
|
|
166
|
+
status: 'ready',
|
|
167
|
+
writable,
|
|
168
|
+
overrides: asOverrides(record.contextWindowOverrides),
|
|
169
|
+
baseOverrides: asOverrides(baseRecord?.contextWindowOverrides),
|
|
170
|
+
...(typeof record.enableNativeCompaction === 'boolean' ? { nativeCompaction: record.enableNativeCompaction } : {}),
|
|
171
|
+
...(typeof record.enableSearch === 'boolean' ? { searchEnabled: record.enableSearch } : {}),
|
|
172
|
+
...(searchModel !== undefined ? { searchModel } : {}),
|
|
173
|
+
...(typeof record.enableImageGeneration === 'boolean' ? { imageGenerationEnabled: record.enableImageGeneration } : {}),
|
|
174
|
+
...(imageModelHint !== undefined ? { imageModelHint } : {}),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
export function bindCodexConnectScope(configForms) {
|
|
178
|
+
const form = configForms.get(OPENAI_CODEX_SETTINGS_NAMESPACE);
|
|
179
|
+
const mirror = configForms.describe?.();
|
|
180
|
+
void Promise.resolve(mirror?.ensure?.()).catch(() => { });
|
|
181
|
+
let lastFormSnap;
|
|
182
|
+
let lastMirrorSnap;
|
|
183
|
+
let projected = { status: 'loading', writable: false };
|
|
184
|
+
const getSnapshot = () => {
|
|
185
|
+
const formSnap = form.getSnapshot();
|
|
186
|
+
const mirrorSnap = mirror?.getSnapshot();
|
|
187
|
+
if (formSnap === lastFormSnap && mirrorSnap === lastMirrorSnap)
|
|
188
|
+
return projected;
|
|
189
|
+
lastFormSnap = formSnap;
|
|
190
|
+
lastMirrorSnap = mirrorSnap;
|
|
191
|
+
const formRecord = formSnap.status === 'ready' ? asRecord(formSnap.value) : undefined;
|
|
192
|
+
if (formRecord !== undefined) {
|
|
193
|
+
return projected = projectCodexConnectRecord(formRecord, asRecord(formSnap.base), formSnap.writable);
|
|
194
|
+
}
|
|
195
|
+
const view = mirrorSnap?.view;
|
|
196
|
+
if (view !== undefined) {
|
|
197
|
+
const row = view.namespaces?.find(candidate => candidate.ns === OPENAI_CODEX_SETTINGS_NAMESPACE);
|
|
198
|
+
const rowRecord = row === undefined ? undefined : asRecord(row.value);
|
|
199
|
+
if (row === undefined || rowRecord === undefined)
|
|
200
|
+
return projected = { status: 'unavailable', writable: false };
|
|
201
|
+
return projected = projectCodexConnectRecord(rowRecord, asRecord(row.base), view.writable ?? formSnap.writable);
|
|
202
|
+
}
|
|
203
|
+
return projected = { status: formSnap.status, writable: formSnap.writable };
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
getSnapshot,
|
|
207
|
+
subscribe: listener => {
|
|
208
|
+
const stopForm = form.subscribe(listener);
|
|
209
|
+
const stopMirror = mirror?.subscribe(listener);
|
|
210
|
+
return () => { stopForm(); stopMirror?.(); };
|
|
211
|
+
},
|
|
212
|
+
setModelOverride: async (modelId, tokens) => {
|
|
213
|
+
const snap = getSnapshot();
|
|
214
|
+
const next = nextOpenAICodexOverrides(snap.overrides, snap.baseOverrides, modelId, tokens);
|
|
215
|
+
const accepted = next === undefined
|
|
216
|
+
? await form.unset('contextWindowOverrides')
|
|
217
|
+
: await form.set('contextWindowOverrides', next);
|
|
218
|
+
if (!accepted)
|
|
219
|
+
throw new Error('The host did not accept the settings change.');
|
|
220
|
+
},
|
|
221
|
+
setNativeCompaction: async (enabled) => {
|
|
222
|
+
const accepted = await form.set('enableNativeCompaction', enabled);
|
|
223
|
+
if (!accepted)
|
|
224
|
+
throw new Error('The host did not accept the settings change.');
|
|
225
|
+
},
|
|
226
|
+
setSearchEnabled: async (enabled) => {
|
|
227
|
+
const accepted = await form.set('enableSearch', enabled);
|
|
228
|
+
if (!accepted)
|
|
229
|
+
throw new Error('The host did not accept the settings change.');
|
|
230
|
+
},
|
|
231
|
+
setImageGenerationEnabled: async (enabled) => {
|
|
232
|
+
const accepted = await form.set('enableImageGeneration', enabled);
|
|
233
|
+
if (!accepted)
|
|
234
|
+
throw new Error('The host did not accept the settings change.');
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
export function bindLlmProvidersScope(configForms) {
|
|
239
|
+
const mirror = configForms.describe?.();
|
|
240
|
+
if (mirror === undefined)
|
|
241
|
+
return undefined;
|
|
242
|
+
void Promise.resolve(mirror.ensure?.()).catch(() => { });
|
|
243
|
+
let lastMirrorSnap;
|
|
244
|
+
let projected;
|
|
245
|
+
const getSnapshot = () => {
|
|
246
|
+
const mirrorSnap = mirror.getSnapshot();
|
|
247
|
+
if (mirrorSnap === lastMirrorSnap)
|
|
248
|
+
return projected;
|
|
249
|
+
lastMirrorSnap = mirrorSnap;
|
|
250
|
+
const row = mirrorSnap?.view?.namespaces?.find(candidate => candidate.ns === 'llm-pi-ai');
|
|
251
|
+
const providers = asRecord(asRecord(row?.value)?.providers);
|
|
252
|
+
return projected = providers;
|
|
253
|
+
};
|
|
254
|
+
return { getSnapshot, subscribe: listener => mirror.subscribe(listener) };
|
|
255
|
+
}
|
|
256
|
+
export function adaptConfigForm(form) {
|
|
257
|
+
const accepted = async (result) => { if (!await result)
|
|
258
|
+
throw new Error('The host did not accept the settings change.'); };
|
|
259
|
+
return { getSnapshot: () => form.getSnapshot(), subscribe: listener => form.subscribe(listener),
|
|
260
|
+
set: (field, value) => accepted(form.set(field, value)), unset: field => accepted(form.unset(field)) };
|
|
261
|
+
}
|
|
262
|
+
export async function saveDesktopSettings(form, edits, expectedRevision) {
|
|
263
|
+
const ops = Object.entries(edits).map(([field, value]) => value === undefined ? { op: 'unset', path: [field] } : { op: 'set', path: [field], value });
|
|
264
|
+
if (!ops.length)
|
|
265
|
+
return;
|
|
266
|
+
const accepted = expectedRevision === undefined ? await form.mutate(ops) : await form.mutate(ops, expectedRevision);
|
|
267
|
+
if (!accepted)
|
|
268
|
+
throw new Error('The host did not accept the settings change.');
|
|
269
|
+
}
|
|
120
270
|
//# sourceMappingURL=preset-requests.js.map
|
|
@@ -3,10 +3,12 @@ import type { HostObservable, PropsLocale } from '@deepseek-ai/dsh-client-ui-slo
|
|
|
3
3
|
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
4
4
|
import type { PresetManagerActions } from './preset-manager.tsx';
|
|
5
5
|
import type { ToolAction, ToolActionContext, ToolPolicyRule } from '../contracts/tool-policy-contract.ts';
|
|
6
|
-
import
|
|
6
|
+
import { formatGptImageBadge, resolveGptCapabilities } from './policy-drafts.ts';
|
|
7
|
+
import type { GptCapabilitiesState } from './policy-drafts.ts';
|
|
7
8
|
import { toolPolicyEn, toolPolicyZh } from './policy-locale.ts';
|
|
8
9
|
export type { ToolPolicyRule } from '../contracts/tool-policy-contract.ts';
|
|
9
|
-
export {
|
|
10
|
+
export type { GptCapabilitiesState };
|
|
11
|
+
export { formatGptImageBadge, resolveGptCapabilities, toolPolicyEn, toolPolicyZh };
|
|
10
12
|
export declare const TOOL_POLICY_NAMESPACE = "codex-tool-policy";
|
|
11
13
|
export interface ToolPolicySettings {
|
|
12
14
|
readonly rules: readonly ToolPolicyRule[];
|
|
@@ -19,29 +21,18 @@ export declare function bindToolPolicy(ctx: Pick<Context, 'effect'>, forms: Poli
|
|
|
19
21
|
export declare function validateToolPolicyRules(rules: readonly ToolPolicyRule[]): 'toolPolicyInvalidPreset' | 'toolPolicyDuplicatePreset' | undefined;
|
|
20
22
|
export declare function withToolAction(rule: ToolPolicyRule, name: string, action: ToolAction, context?: ToolActionContext): ToolPolicyRule;
|
|
21
23
|
export declare function saveToolPolicy(form: ToolPolicyForm, rules: readonly ToolPolicyRule[], revision: number | undefined): Promise<boolean>;
|
|
22
|
-
export interface GptCapabilitiesState {
|
|
23
|
-
readonly hostedWebSearch: boolean;
|
|
24
|
-
readonly codexSearch: boolean;
|
|
25
|
-
readonly codexSearchModel?: string | undefined;
|
|
26
|
-
readonly remoteCompaction: boolean;
|
|
27
|
-
readonly imageGeneration: boolean;
|
|
28
|
-
readonly imageModelHint?: string | undefined;
|
|
29
|
-
}
|
|
30
|
-
export declare function resolveGptCapabilities(codexSettings?: {
|
|
31
|
-
readonly hostedWebSearchEnabled?: boolean;
|
|
32
|
-
readonly remoteCompactionEnabled?: boolean;
|
|
33
|
-
} | undefined, codexConnect?: CodexConnectSnapshot | undefined): GptCapabilitiesState | undefined;
|
|
34
24
|
export type ToolPolicySubMode = 'tools' | 'prompts' | 'definition';
|
|
35
25
|
export type ToolPolicyMode = ToolPolicySubMode | 'inactive';
|
|
36
26
|
type PolicyProps = PropsLocale<'codex'> & {
|
|
37
27
|
presetManager?: PresetManagerActions | undefined;
|
|
38
28
|
mode?: ToolPolicyMode;
|
|
39
29
|
gptCapabilities?: GptCapabilitiesState | undefined;
|
|
30
|
+
toolsVersion?: number | undefined;
|
|
40
31
|
};
|
|
41
32
|
export declare function ToolPolicySection({ binding, ...props }: {
|
|
42
33
|
binding: ToolPolicyBinding;
|
|
43
34
|
} & PolicyProps): import("react").JSX.Element | null;
|
|
44
|
-
export declare function ToolPolicySettingsCard({ form, presetManager, mode, gptCapabilities, t }: {
|
|
35
|
+
export declare function ToolPolicySettingsCard({ form, presetManager, mode, gptCapabilities, toolsVersion, t }: {
|
|
45
36
|
form: ToolPolicyForm;
|
|
46
37
|
} & PolicyProps): import("react").JSX.Element | null;
|
|
47
38
|
//# sourceMappingURL=tool-policy.d.ts.map
|
|
@@ -5,9 +5,9 @@ import { PresetDefinitionCard } from "./preset-manager.js";
|
|
|
5
5
|
import { cachedPresetCatalog, cachedPresetPrompts, cachedPresetTools, requestPresetCatalog, requestPresetPrompts, requestPresetTools, } from "./preset-requests.js";
|
|
6
6
|
import { effectiveToolAction, legacyToolAction } from "../contracts/tool-policy-contract.js";
|
|
7
7
|
import { PRESET_PROMPT_NAMES } from "../contracts/ui-contracts.js";
|
|
8
|
-
import { acceptPresetSave, editPresetDraft, preparePresetSave, presetRules, sameRules } from "./policy-drafts.js";
|
|
8
|
+
import { acceptPresetSave, editPresetDraft, formatGptImageBadge, preparePresetSave, presetRules, resolveGptCapabilities, sameRules } from "./policy-drafts.js";
|
|
9
9
|
import { groupOf, humanLabels, policyStyles, toolPolicyEn, toolPolicyZh } from "./policy-locale.js";
|
|
10
|
-
export { toolPolicyEn, toolPolicyZh };
|
|
10
|
+
export { formatGptImageBadge, resolveGptCapabilities, toolPolicyEn, toolPolicyZh };
|
|
11
11
|
export const TOOL_POLICY_NAMESPACE = 'codex-tool-policy';
|
|
12
12
|
export function bindToolPolicy(ctx, forms) {
|
|
13
13
|
let form;
|
|
@@ -70,33 +70,8 @@ export function saveToolPolicy(form, rules, revision) {
|
|
|
70
70
|
});
|
|
71
71
|
return form.mutate([{ op: 'set', path: ['rules'], value }], revision);
|
|
72
72
|
}
|
|
73
|
-
export function resolveGptCapabilities(codexSettings, codexConnect) {
|
|
74
|
-
const connectReady = codexConnect?.status === 'ready';
|
|
75
|
-
if (codexSettings === undefined && !connectReady)
|
|
76
|
-
return undefined;
|
|
77
|
-
return {
|
|
78
|
-
hostedWebSearch: codexSettings !== undefined ? (codexSettings.hostedWebSearchEnabled ?? true) : false,
|
|
79
|
-
codexSearch: connectReady && codexConnect.searchEnabled === true,
|
|
80
|
-
codexSearchModel: connectReady ? codexConnect.searchModel : undefined,
|
|
81
|
-
remoteCompaction: (codexSettings !== undefined && (codexSettings.remoteCompactionEnabled ?? true))
|
|
82
|
-
|| (connectReady && codexConnect.nativeCompaction === true),
|
|
83
|
-
imageGeneration: connectReady && codexConnect.imageGenerationEnabled === true,
|
|
84
|
-
imageModelHint: connectReady ? codexConnect.imageModelHint : undefined,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function formatGptImageBadge(hint) {
|
|
88
|
-
const value = hint?.trim() ?? '';
|
|
89
|
-
if (!value || value === 'gpt-image-2.6-sunburst')
|
|
90
|
-
return 'GPT-Image-2.6 Sunburst';
|
|
91
|
-
if (value === 'gpt-image-2.6-flare')
|
|
92
|
-
return 'GPT-Image-2.6 Flare';
|
|
93
|
-
if (value === 'gpt-image-2')
|
|
94
|
-
return 'GPT-Image-2';
|
|
95
|
-
return value;
|
|
96
|
-
}
|
|
97
73
|
const isPromptName = (name) => PRESET_PROMPT_NAMES.includes(name);
|
|
98
74
|
const GROUP_META = [
|
|
99
|
-
{ id: 'gpt', labelKey: 'toolPolicyGptGroup' },
|
|
100
75
|
{ id: 'command', labelKey: 'toolPolicyCommandGroup' },
|
|
101
76
|
{ id: 'file', labelKey: 'toolPolicyFileGroup' },
|
|
102
77
|
{ id: 'plan', labelKey: 'toolPolicyPlanGroup' },
|
|
@@ -107,7 +82,7 @@ export function ToolPolicySection({ binding, ...props }) {
|
|
|
107
82
|
const form = useSyncExternalStore(binding.subscribe, binding.getSnapshot, binding.getSnapshot);
|
|
108
83
|
return form === undefined ? null : _jsx(ToolPolicySettingsCard, { form: form, ...props });
|
|
109
84
|
}
|
|
110
|
-
export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', gptCapabilities, t }) {
|
|
85
|
+
export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', gptCapabilities, toolsVersion = 0, t }) {
|
|
111
86
|
const snapshot = useSyncExternalStore(listener => form.subscribe(listener), () => form.getSnapshot(), () => form.getSnapshot());
|
|
112
87
|
const [subMode, setSubMode] = useState(mode === 'prompts' || mode === 'definition' ? mode : 'tools');
|
|
113
88
|
const prevMode = useRef(mode);
|
|
@@ -172,6 +147,13 @@ export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', gp
|
|
|
172
147
|
setToolsView({ preset: selectedId, status: 'error' }); });
|
|
173
148
|
}
|
|
174
149
|
useEffect(() => { loadTools(); return () => { toolsRequest.current++; }; }, [presetManager, selectedId]);
|
|
150
|
+
const loadedToolsVersion = useRef(toolsVersion);
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (mode !== 'inactive' && loadedToolsVersion.current !== toolsVersion) {
|
|
153
|
+
loadedToolsVersion.current = toolsVersion;
|
|
154
|
+
loadTools(true);
|
|
155
|
+
}
|
|
156
|
+
}, [mode, toolsVersion, presetManager, selectedId]);
|
|
175
157
|
const cached = presetManager && selectedId ? cachedPresetTools(presetManager, selectedId) : undefined;
|
|
176
158
|
const inventory = toolsView?.preset === selectedId && toolsView.status === 'error' ? undefined : toolsView?.preset === selectedId && toolsView.status === 'ready' ? toolsView.value : cached;
|
|
177
159
|
const toolsStatus = inventory ? 'ready' : toolsView?.preset === selectedId ? toolsView.status : selectedId ? 'loading' : 'error';
|
|
@@ -328,8 +310,15 @@ export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', gp
|
|
|
328
310
|
const unavailable = (reason) => t(reason === 'conditional' ? 'toolPolicyConditional' : reason === 'target-exists' ? 'toolPolicyTargetExists' : 'toolPolicyUnsupported');
|
|
329
311
|
const gptSearchActive = gptCapabilities?.hostedWebSearch === true || gptCapabilities?.codexSearch === true;
|
|
330
312
|
const gptBadgeFor = (tool) => {
|
|
313
|
+
if (tool.name === 'codex_subagent') {
|
|
314
|
+
const model = gptCapabilities?.codexSubagentModel;
|
|
315
|
+
return {
|
|
316
|
+
label: model ? `${t('toolPolicyGptCodexSearch')} · ${model}` : t('toolPolicyGptCodexSearch'),
|
|
317
|
+
title: t('toolPolicyGptSubagentTitle'),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
331
320
|
if (tool.name === 'codex_connect_image_generate') {
|
|
332
|
-
return { label: formatGptImageBadge(gptCapabilities?.imageModelHint)
|
|
321
|
+
return { label: `${t('toolPolicyGptCodexSearch')} · ${formatGptImageBadge(gptCapabilities?.imageModelHint)}`, title: t('toolPolicyGptImageTitle') };
|
|
333
322
|
}
|
|
334
323
|
if (tool.name === 'web_search' && gptSearchActive) {
|
|
335
324
|
const model = gptCapabilities?.codexSearchModel;
|
|
@@ -349,7 +338,7 @@ export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', gp
|
|
|
349
338
|
}
|
|
350
339
|
return undefined;
|
|
351
340
|
};
|
|
352
|
-
const renderRows = (tools
|
|
341
|
+
const renderRows = (tools) => _jsxs("div", { className: "codex-tool-policy-table", role: "table", "aria-label": t('toolPolicyTitle'), children: [tools.map(tool => {
|
|
353
342
|
const action = chosen(tool);
|
|
354
343
|
const deferReason = deferUnavailableReason(tool);
|
|
355
344
|
const supported = action === 'keep' || action === 'hide' || action === 'defer' || tool.replacements.some(option => option.action === action);
|
|
@@ -357,7 +346,7 @@ export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', gp
|
|
|
357
346
|
const hasOverride = !!rule?.tools?.some(choice => choice.name === tool.name);
|
|
358
347
|
const gptBadge = gptBadgeFor(tool);
|
|
359
348
|
return _jsxs("div", { role: "row", className: "codex-tool-policy-tool", "data-tool-name": tool.name, "data-tool-action": action, children: [_jsxs("div", { role: "cell", className: "codex-tool-policy-name", children: [_jsx("code", { className: "codex-tool-policy-identifier", children: tool.name }), _jsx("span", { className: "codex-tool-policy-description", title: tool.description, children: human(tool) }), gptBadge && _jsx("span", { className: "codex-badge", "data-tone": "gpt", title: gptBadge.title, children: gptBadge.label }), tool.defaultDeferred && !custom && _jsx("span", { className: "codex-badge", "data-tone": "blue", children: t('toolPolicyDefaultDeferred') }), custom && _jsx("span", { className: "codex-badge", "data-tone": "blue", children: t('toolPolicyModified') }), tool.codexTool?.presetEnabled === false && _jsx("span", { className: "codex-badge", "data-tone": "warn", children: t('toolPolicyPresetDisabled') }), tool.conditional && tool.codexTool === undefined && _jsx("span", { className: "codex-badge", children: t('toolPolicyConditional') })] }), _jsxs("div", { role: "cell", className: "codex-tool-policy-action", children: [_jsxs("div", { className: "codex-seg", role: "group", "aria-label": `${t('toolPolicyAction')} ${tool.name}`, children: [_jsx("button", { type: "button", "data-action": "keep", "aria-pressed": action === 'keep', disabled: duplicate, onClick: () => chooseAction(tool, 'keep'), children: t('toolPolicyKeep') }), tool.replacements.map(option => _jsx("button", { type: "button", "data-action": option.action, "aria-pressed": action === option.action, disabled: duplicate || !option.available, title: option.available ? option.tools.join(' + ') : `${option.tools.join(' + ')} · ${unavailable(option.reason)}`, onClick: () => chooseAction(tool, option.action), children: t('toolPolicyReplaceShort') }, option.action)), _jsx("button", { type: "button", "data-action": "defer", "aria-pressed": action === 'defer', disabled: duplicate || deferReason !== undefined, title: deferReason !== undefined ? unavailable(deferReason) : t('toolPolicyDeferHint'), onClick: () => chooseAction(tool, 'defer'), children: t('toolPolicyDefer') }), _jsx("button", { type: "button", "data-action": "hide", "aria-pressed": action === 'hide', disabled: duplicate, onClick: () => chooseAction(tool, 'hide'), children: t('toolPolicyHide') })] }), !supported && _jsxs("span", { className: "codex-tool-policy-warning", children: [t('toolPolicyUnsupported'), " (", action, ")"] }), hasOverride && _jsx("button", { type: "button", className: "codex-btn", "aria-label": `${t('toolPolicyRestoreChoice')} ${tool.name}`, title: t('toolPolicyRestoreChoice'), onClick: () => removeChoice(tool.name), children: "\u21B6" })] })] }, tool.name);
|
|
360
|
-
}),
|
|
349
|
+
}), tools.length === 0 && _jsx("p", { className: "codex-tool-policy-note", style: { padding: '12px 14px' }, children: t('toolPolicyNoMatches') })] });
|
|
361
350
|
if (snapshot.status !== 'ready' || snapshot.value === undefined || mode === 'inactive')
|
|
362
351
|
return null;
|
|
363
352
|
const text = query.trim().toLowerCase();
|
|
@@ -370,19 +359,15 @@ export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', gp
|
|
|
370
359
|
return (!text || haystack.includes(text))
|
|
371
360
|
&& (filter === 'all' || (filter === 'modified' ? customized(tool) : filter === 'deferred' ? chosen(tool) === 'defer' : tool.replacements.some(option => option.available)));
|
|
372
361
|
});
|
|
373
|
-
|
|
374
|
-
const showCompactionRow = gptCapabilities?.remoteCompaction === true && filter === 'all' && (!text || compactionSearchText.includes(text));
|
|
375
|
-
return _jsxs("section", { className: "codex-tool-policy", "aria-label": t(activeSub === 'prompts' ? 'settingsPresetPrompts' : 'toolPolicyTitle'), children: [_jsx("style", { children: policyStyles }), _jsxs("div", { className: "codex-card codex-preset-bar", children: [_jsxs("label", { className: "codex-preset-select-wrap", children: [_jsx("span", { className: "codex-tool-policy-note", children: t('toolPolicyPresetChoice') }), _jsxs("select", { "aria-label": t('toolPolicyPresetChoice'), value: selectedId, onChange: event => { setSelection(event.target.value); setError(''); setNotice(''); }, children: [!ids.length && _jsx("option", { value: "", children: t('toolPolicyEmpty') }), ids.map(id => _jsxs("option", { value: id, "data-preset-id": id, children: [catalog?.presets.find(preset => preset.id === id)?.name ?? id, drafts.has(id) ? ` · ${t('globalPending')}` : ''] }, id))] })] }), _jsxs("div", { className: "codex-tool-policy-action", children: [_jsx("div", { className: "codex-seg", role: "group", "aria-label": t('settingsTabLabel'), children: [['tools', 'settingsSubTools'], ['prompts', 'settingsPresetPrompts'], ['definition', 'settingsDefinition']].map(([key, labelKey]) => (_jsx("button", { type: "button", "data-submode": key, "aria-pressed": activeSub === key, onClick: () => setSubMode(key), children: t(labelKey) }, key))) }), presetManager && _jsx("button", { type: "button", className: "codex-btn", disabled: catalogState === 'loading', onClick: () => loadCatalog(true), children: t('toolPolicyCatalogRetry') })] })] }), catalogState !== 'ready' && _jsx("p", { className: "codex-tool-policy-note", role: "status", children: t(catalogState === 'loading' ? 'toolPolicyCatalogLoading' : 'toolPolicyCatalogFailed') }), catalogState === 'ready' && !ids.length && _jsx("p", { className: "codex-tool-policy-note", children: t('toolPolicyCatalogEmpty') }), duplicate && _jsx("p", { className: "codex-tool-policy-warning", children: t('toolPolicyDuplicatePreset') }), activeSub === 'definition' && (!selectedId || presetManager === undefined ? _jsx("p", { className: "codex-tool-policy-note", children: t('settingsDefinitionAbsent') }) : _jsx(PresetDefinitionCard, { presetManager: presetManager, id: selectedId, t: t })), activeSub !== 'definition' && _jsx("form", { onSubmit: event => { event.preventDefault(); saveCurrent(); }, children: _jsxs("fieldset", { disabled: !snapshot.writable || saving, children: [activeSub === 'tools' && _jsxs(_Fragment, { children: [toolsStatus !== 'ready' && _jsx("p", { className: "codex-tool-policy-note", role: "status", children: t(toolsStatus === 'loading' ? 'toolPolicyToolsLoading' : 'toolPolicyToolsFailed') }), inventory?.tools.length === 0 && _jsx("p", { className: "codex-tool-policy-note", role: "status", children: t('toolPolicyToolsEmpty') }), inventory && !duplicate && inventory.tools.length > 0 && _jsxs("div", { className: "codex-toolbar", children: [_jsx("input", { type: "text", "aria-label": t('toolPolicySearch'), placeholder: t('toolPolicySearch'), value: query, onChange: event => setQuery(event.target.value) }), _jsx("div", { className: "codex-seg", role: "group", "aria-label": t('toolPolicyFilter'), children: ['all', 'deferred', 'modified', ...(hasReplaceable ? ['replaceable'] : [])].map(item => (_jsx("button", { type: "button", "data-filter": item, "aria-pressed": filter === item, onClick: () => setFilter(item), children: t(item === 'all' ? 'toolPolicyAll' : item === 'modified' ? 'toolPolicyModified' : item === 'deferred' ? 'toolPolicyDeferredFilter' : 'toolPolicyReplaceable') }, item))) }), presetManager && selectedId && _jsx("button", { type: "button", className: "codex-btn", disabled: toolsStatus === 'loading', onClick: () => loadTools(true), children: t('toolPolicyToolsRefresh') })] }), inventory && !duplicate && (isFiltering && shown.length === 0 && !showCompactionRow
|
|
362
|
+
return _jsxs("section", { className: "codex-tool-policy", "aria-label": t(activeSub === 'prompts' ? 'settingsPresetPrompts' : 'toolPolicyTitle'), children: [_jsx("style", { children: policyStyles }), _jsxs("div", { className: "codex-card codex-preset-bar", children: [_jsxs("label", { className: "codex-preset-select-wrap", children: [_jsx("span", { className: "codex-tool-policy-note", children: t('toolPolicyPresetChoice') }), _jsxs("select", { "aria-label": t('toolPolicyPresetChoice'), value: selectedId, onChange: event => { setSelection(event.target.value); setError(''); setNotice(''); }, children: [!ids.length && _jsx("option", { value: "", children: t('toolPolicyEmpty') }), ids.map(id => _jsxs("option", { value: id, "data-preset-id": id, children: [catalog?.presets.find(preset => preset.id === id)?.name ?? id, drafts.has(id) ? ` · ${t('globalPending')}` : ''] }, id))] })] }), _jsxs("div", { className: "codex-tool-policy-action", children: [_jsx("div", { className: "codex-seg", role: "group", "aria-label": t('settingsTabLabel'), children: [['tools', 'settingsSubTools'], ['prompts', 'settingsPresetPrompts'], ['definition', 'settingsDefinition']].map(([key, labelKey]) => (_jsx("button", { type: "button", "data-submode": key, "aria-pressed": activeSub === key, onClick: () => setSubMode(key), children: t(labelKey) }, key))) }), presetManager && _jsx("button", { type: "button", className: "codex-btn", disabled: catalogState === 'loading', onClick: () => loadCatalog(true), children: t('toolPolicyCatalogRetry') })] })] }), catalogState !== 'ready' && _jsx("p", { className: "codex-tool-policy-note", role: "status", children: t(catalogState === 'loading' ? 'toolPolicyCatalogLoading' : 'toolPolicyCatalogFailed') }), catalogState === 'ready' && !ids.length && _jsx("p", { className: "codex-tool-policy-note", children: t('toolPolicyCatalogEmpty') }), duplicate && _jsx("p", { className: "codex-tool-policy-warning", children: t('toolPolicyDuplicatePreset') }), activeSub === 'definition' && (!selectedId || presetManager === undefined ? _jsx("p", { className: "codex-tool-policy-note", children: t('settingsDefinitionAbsent') }) : _jsx(PresetDefinitionCard, { presetManager: presetManager, id: selectedId, t: t })), activeSub !== 'definition' && _jsx("form", { onSubmit: event => { event.preventDefault(); saveCurrent(); }, children: _jsxs("fieldset", { disabled: !snapshot.writable || saving, children: [activeSub === 'tools' && _jsxs(_Fragment, { children: [toolsStatus !== 'ready' && _jsx("p", { className: "codex-tool-policy-note", role: "status", children: t(toolsStatus === 'loading' ? 'toolPolicyToolsLoading' : 'toolPolicyToolsFailed') }), inventory?.tools.length === 0 && _jsx("p", { className: "codex-tool-policy-note", role: "status", children: t('toolPolicyToolsEmpty') }), inventory && !duplicate && inventory.tools.length > 0 && _jsxs("div", { className: "codex-toolbar", children: [_jsx("input", { type: "text", "aria-label": t('toolPolicySearch'), placeholder: t('toolPolicySearch'), value: query, onChange: event => setQuery(event.target.value) }), _jsx("div", { className: "codex-seg", role: "group", "aria-label": t('toolPolicyFilter'), children: ['all', 'deferred', 'modified', ...(hasReplaceable ? ['replaceable'] : [])].map(item => (_jsx("button", { type: "button", "data-filter": item, "aria-pressed": filter === item, onClick: () => setFilter(item), children: t(item === 'all' ? 'toolPolicyAll' : item === 'modified' ? 'toolPolicyModified' : item === 'deferred' ? 'toolPolicyDeferredFilter' : 'toolPolicyReplaceable') }, item))) }), presetManager && selectedId && _jsx("button", { type: "button", className: "codex-btn", disabled: toolsStatus === 'loading', onClick: () => loadTools(true), children: t('toolPolicyToolsRefresh') })] }), inventory && !duplicate && (isFiltering && shown.length === 0
|
|
376
363
|
? _jsx("div", { className: "codex-card", children: renderRows(shown) })
|
|
377
364
|
: GROUP_META.map(group => {
|
|
378
|
-
const tools = shown.filter(tool => groupOf(tool
|
|
379
|
-
|
|
380
|
-
if (!tools.length && !includeCompaction)
|
|
365
|
+
const tools = shown.filter(tool => groupOf(tool) === group.id);
|
|
366
|
+
if (!tools.length)
|
|
381
367
|
return null;
|
|
382
368
|
const changes = tools.filter(customized).length;
|
|
383
369
|
const key = `${selectedId}/${group.id}`;
|
|
384
|
-
const
|
|
385
|
-
return _jsxs("details", { className: "codex-group", "data-tool-group": group.id, open: isFiltering ? true : (groupOpen.get(key) ?? true), onToggle: event => { const open = event.currentTarget.open; setGroupOpen(previous => new Map(previous).set(key, open)); }, children: [_jsxs("summary", { children: [_jsx("span", { children: t(group.labelKey) }), _jsxs("span", { className: "codex-tool-policy-note", children: [count, changes ? ` · ${changes} ${t('toolPolicyCustomized')}` : ''] })] }), renderRows(tools, includeCompaction)] }, group.id);
|
|
370
|
+
return _jsxs("details", { className: "codex-group", "data-tool-group": group.id, open: isFiltering ? true : (groupOpen.get(key) ?? true), onToggle: event => { const open = event.currentTarget.open; setGroupOpen(previous => new Map(previous).set(key, open)); }, children: [_jsxs("summary", { children: [_jsx("span", { children: t(group.labelKey) }), _jsxs("span", { className: "codex-tool-policy-note", children: [tools.length, changes ? ` · ${changes} ${t('toolPolicyCustomized')}` : ''] })] }), renderRows(tools)] }, group.id);
|
|
386
371
|
}))] }), activeSub === 'prompts' && _jsxs(_Fragment, { children: [presetManager && selectedId && _jsx("div", { className: "codex-toolbar", children: _jsx("button", { type: "button", className: "codex-btn", disabled: promptsStatus === 'loading', onClick: () => loadPrompts(true), children: t('presetPromptsReload') }) }), promptsStatus !== 'ready' && _jsx("p", { className: "codex-tool-policy-note", role: "status", children: t(promptsStatus === 'loading' ? 'presetPromptsLoading' : 'presetPromptsFailed') }), promptCatalog?.sections.length === 0 && _jsx("p", { className: "codex-tool-policy-note", children: t('presetPromptsEmpty') }), promptCatalog && _jsx("div", { className: "codex-tool-policy-prompts", children: promptCatalog.sections.map(section => {
|
|
387
372
|
const editable = section.editable && isPromptName(section.name);
|
|
388
373
|
const override = rule?.promptOverrides?.find(entry => entry.name === section.name);
|
|
@@ -4,6 +4,41 @@ import type { InvocationDescriptor } from '@deepseek-ai/dsh-typert-protocol';
|
|
|
4
4
|
export declare const PRESET_EDITOR_PACKAGE = "@shuind/dsh-codex-harness";
|
|
5
5
|
export declare const PRESET_EDITOR_SERVICE = "codexPresetEditor";
|
|
6
6
|
export declare const presetIdSchema: z.ZodString;
|
|
7
|
+
export declare const proModeSessionIdSchema: z.ZodString;
|
|
8
|
+
export declare const proModeSetInputSchema: z.ZodObject<{
|
|
9
|
+
sessionId: z.ZodString;
|
|
10
|
+
enabled: z.ZodBoolean;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare const proModeStateSchema: z.ZodObject<{
|
|
13
|
+
enabled: z.ZodBoolean;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const harnessUpdateResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
16
|
+
status: z.ZodLiteral<"up-to-date">;
|
|
17
|
+
currentVersion: z.ZodString;
|
|
18
|
+
latestVersion: z.ZodString;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
status: z.ZodLiteral<"update-available">;
|
|
21
|
+
currentVersion: z.ZodString;
|
|
22
|
+
latestVersion: z.ZodString;
|
|
23
|
+
releaseUrl: z.ZodString;
|
|
24
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
25
|
+
status: z.ZodLiteral<"unavailable">;
|
|
26
|
+
currentVersion: z.ZodString;
|
|
27
|
+
reason: z.ZodEnum<{
|
|
28
|
+
"invalid-current-version": "invalid-current-version";
|
|
29
|
+
"registry-unavailable": "registry-unavailable";
|
|
30
|
+
"invalid-registry-response": "invalid-registry-response";
|
|
31
|
+
}>;
|
|
32
|
+
}, z.core.$strip>], "status">;
|
|
33
|
+
export declare const codexSubagentModelsSchema: z.ZodObject<{
|
|
34
|
+
available: z.ZodBoolean;
|
|
35
|
+
models: z.ZodArray<z.ZodObject<{
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
efforts: z.ZodArray<z.ZodString>;
|
|
39
|
+
defaultEffort: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
7
42
|
export declare const presetCatalogSchema: z.ZodObject<{
|
|
8
43
|
presets: z.ZodArray<z.ZodObject<{
|
|
9
44
|
id: z.ZodString;
|
|
@@ -3,6 +3,41 @@ import { z } from 'zod';
|
|
|
3
3
|
export const PRESET_EDITOR_PACKAGE = '@shuind/dsh-codex-harness';
|
|
4
4
|
export const PRESET_EDITOR_SERVICE = 'codexPresetEditor';
|
|
5
5
|
export const presetIdSchema = z.string().min(1).max(256);
|
|
6
|
+
export const proModeSessionIdSchema = z.string().min(1).max(256);
|
|
7
|
+
export const proModeSetInputSchema = z.object({
|
|
8
|
+
sessionId: proModeSessionIdSchema,
|
|
9
|
+
enabled: z.boolean(),
|
|
10
|
+
});
|
|
11
|
+
export const proModeStateSchema = z.object({
|
|
12
|
+
enabled: z.boolean(),
|
|
13
|
+
});
|
|
14
|
+
export const harnessUpdateResultSchema = z.discriminatedUnion('status', [
|
|
15
|
+
z.object({
|
|
16
|
+
status: z.literal('up-to-date'),
|
|
17
|
+
currentVersion: z.string(),
|
|
18
|
+
latestVersion: z.string(),
|
|
19
|
+
}),
|
|
20
|
+
z.object({
|
|
21
|
+
status: z.literal('update-available'),
|
|
22
|
+
currentVersion: z.string(),
|
|
23
|
+
latestVersion: z.string(),
|
|
24
|
+
releaseUrl: z.string(),
|
|
25
|
+
}),
|
|
26
|
+
z.object({
|
|
27
|
+
status: z.literal('unavailable'),
|
|
28
|
+
currentVersion: z.string(),
|
|
29
|
+
reason: z.enum(['invalid-current-version', 'registry-unavailable', 'invalid-registry-response']),
|
|
30
|
+
}),
|
|
31
|
+
]);
|
|
32
|
+
export const codexSubagentModelsSchema = z.object({
|
|
33
|
+
available: z.boolean(),
|
|
34
|
+
models: z.array(z.object({
|
|
35
|
+
id: z.string(),
|
|
36
|
+
name: z.string(),
|
|
37
|
+
efforts: z.array(z.string()),
|
|
38
|
+
defaultEffort: z.string().optional(),
|
|
39
|
+
})),
|
|
40
|
+
});
|
|
6
41
|
export const presetCatalogSchema = z.object({
|
|
7
42
|
presets: z.array(z.object({
|
|
8
43
|
id: z.string(),
|
|
@@ -85,6 +120,10 @@ export function buildPresetEditorDescriptors() {
|
|
|
85
120
|
descriptor('tools', 'id', presetIdSchema, presetToolCatalogSchema),
|
|
86
121
|
descriptor('prompts', 'id', presetIdSchema, presetPromptCatalogSchema),
|
|
87
122
|
descriptor('read', 'id', presetIdSchema, presetDefinitionSchema),
|
|
123
|
+
descriptor('proModeGet', 'sessionId', proModeSessionIdSchema, proModeStateSchema),
|
|
124
|
+
descriptor('proModeSet', 'input', proModeSetInputSchema, proModeStateSchema),
|
|
125
|
+
descriptor('updateCheck', undefined, z.unknown(), harnessUpdateResultSchema),
|
|
126
|
+
descriptor('codexSubagentModels', undefined, z.unknown(), codexSubagentModelsSchema),
|
|
88
127
|
];
|
|
89
128
|
}
|
|
90
129
|
export const presetEditorRemote = {
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import type { Context } from '@deepseek-ai/cordis';
|
|
3
3
|
import z from '@deepseek-ai/schemastery';
|
|
4
4
|
import type { SettingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
5
|
+
import { supportsApiProMode } from './ui-contracts.ts';
|
|
6
|
+
export { supportsApiProMode };
|
|
5
7
|
/** Live Codex controls shared by the Web UI and agent layer. */
|
|
6
8
|
export declare const CODEX_SETTINGS_NAMESPACE: SettingsNamespace;
|
|
7
9
|
export interface CodexSettings {
|
|
@@ -9,6 +11,8 @@ export interface CodexSettings {
|
|
|
9
11
|
fast: boolean;
|
|
10
12
|
/** Show the Fast mode switch in the conversation composer. */
|
|
11
13
|
fastModeControlEnabled: boolean;
|
|
14
|
+
/** Show the ephemeral per-session API Pro mode switch in the conversation composer. */
|
|
15
|
+
proModeControlEnabled: boolean;
|
|
12
16
|
/** Show the quick context-window control in the conversation composer. */
|
|
13
17
|
contextWindowControlEnabled: boolean;
|
|
14
18
|
/** Optional context capacity override, in tokens. */
|
|
@@ -35,6 +39,14 @@ export interface CodexSettings {
|
|
|
35
39
|
remoteCompactionEnabled: boolean;
|
|
36
40
|
/** Show the Codex request/compaction activity indicator. */
|
|
37
41
|
activityIndicatorEnabled: boolean;
|
|
42
|
+
/** Globally register codex_subagent backed by the openai-codex subscription provider. */
|
|
43
|
+
codexSubagentEnabled: boolean;
|
|
44
|
+
/** Optional openai-codex model id for codex_subagent (blank uses the first enabled model). */
|
|
45
|
+
codexSubagentModel?: string;
|
|
46
|
+
/** Optional reasoning effort id for codex_subagent (blank uses the model default). */
|
|
47
|
+
codexSubagentEffort?: string;
|
|
48
|
+
/** Preset for codex_subagent children ('codex-hybrid' by default, or 'inherit'). */
|
|
49
|
+
codexSubagentPreset: string;
|
|
38
50
|
}
|
|
39
51
|
/** Default settings exposed even before a Codex session is opened. */
|
|
40
52
|
export declare const CODEX_SETTINGS_ENTRY: CodexSettings;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Shared host-side Codex settings contract, Host reader, and GPT route matcher. */
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
|
-
import { CODEX_CONTEXT_MAX } from "./ui-contracts.js";
|
|
3
|
+
import { CODEX_CONTEXT_MAX, CODEX_SUBAGENT_DEFAULT_PRESET, supportsApiProMode } from "./ui-contracts.js";
|
|
4
|
+
export { supportsApiProMode };
|
|
4
5
|
import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from "./prompt.js";
|
|
5
6
|
/** Live Codex controls shared by the Web UI and agent layer. */
|
|
6
7
|
export const CODEX_SETTINGS_NAMESPACE = 'codex';
|
|
@@ -8,6 +9,7 @@ export const CODEX_SETTINGS_NAMESPACE = 'codex';
|
|
|
8
9
|
export const CODEX_SETTINGS_ENTRY = {
|
|
9
10
|
fast: false,
|
|
10
11
|
fastModeControlEnabled: true,
|
|
12
|
+
proModeControlEnabled: true,
|
|
11
13
|
contextWindowControlEnabled: true,
|
|
12
14
|
persona: DEFAULT_CODEX_PERSONA,
|
|
13
15
|
harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
|
|
@@ -20,10 +22,13 @@ export const CODEX_SETTINGS_ENTRY = {
|
|
|
20
22
|
hostedWebSearchEnabled: true,
|
|
21
23
|
remoteCompactionEnabled: true,
|
|
22
24
|
activityIndicatorEnabled: true,
|
|
25
|
+
codexSubagentEnabled: false,
|
|
26
|
+
codexSubagentPreset: CODEX_SUBAGENT_DEFAULT_PRESET,
|
|
23
27
|
};
|
|
24
28
|
export const CODEX_SETTINGS_SCHEMA = z.object({
|
|
25
29
|
fast: z.boolean().default(false),
|
|
26
30
|
fastModeControlEnabled: z.boolean().default(true),
|
|
31
|
+
proModeControlEnabled: z.boolean().default(true),
|
|
27
32
|
contextWindowControlEnabled: z.boolean().default(true),
|
|
28
33
|
contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX).hidden(),
|
|
29
34
|
persona: z.string().default(DEFAULT_CODEX_PERSONA),
|
|
@@ -37,6 +42,10 @@ export const CODEX_SETTINGS_SCHEMA = z.object({
|
|
|
37
42
|
hostedWebSearchEnabled: z.boolean().default(true),
|
|
38
43
|
remoteCompactionEnabled: z.boolean().default(true),
|
|
39
44
|
activityIndicatorEnabled: z.boolean().default(true),
|
|
45
|
+
codexSubagentEnabled: z.boolean().default(false),
|
|
46
|
+
codexSubagentModel: z.string(),
|
|
47
|
+
codexSubagentEffort: z.string(),
|
|
48
|
+
codexSubagentPreset: z.string().default(CODEX_SUBAGENT_DEFAULT_PRESET),
|
|
40
49
|
});
|
|
41
50
|
/** Host-only reads: never expose the unredacted provider configuration to clients. */
|
|
42
51
|
export function readHostSettings(ctx, namespace) {
|