@shuind/dsh-codex-harness 0.3.1 → 0.3.2
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 +12 -0
- package/README.md +3 -5
- package/lib/client.js +250 -120
- package/lib/index.js +38 -20
- package/lib/types/client/desktop.js +30 -22
- package/lib/types/client/index.d.ts +11 -0
- package/lib/types/client/policy-locale.d.ts +14 -3
- package/lib/types/client/policy-locale.js +28 -1
- package/lib/types/client/tool-policy.d.ts +15 -1
- package/lib/types/client/tool-policy.js +67 -10
- package/lib/types/contracts/ui-contracts.d.ts +4 -0
- package/lib/types/responses/compact-checkpoint.js +3 -10
- package/lib/types/responses/remote-compact.js +39 -11
- package/package.json +1 -1
- package/src/client/desktop.tsx +40 -22
- package/src/client/policy-locale.ts +27 -2
- package/src/client/tool-policy.tsx +99 -11
- package/src/contracts/ui-contracts.ts +4 -0
- package/src/responses/compact-checkpoint.ts +2 -8
- package/src/responses/remote-compact.ts +41 -11
package/lib/index.js
CHANGED
|
@@ -13,8 +13,8 @@ import { mkdir, readdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
|
13
13
|
import { homedir } from "node:os";
|
|
14
14
|
import { isAbsolute, join, resolve } from "node:path";
|
|
15
15
|
import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
16
|
+
import { HarnessError, offloadedImageText, resolveImageAttachmentAccess } from "@deepseek-ai/dsh-llm";
|
|
16
17
|
import { ESCALATION_TARGETS, approveEscalation, escalationHintMarker, sandboxDenialMarker, sandboxPermissionsDescription, validateEscalationArgs } from "@deepseek-ai/dsh-sandbox";
|
|
17
|
-
import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
18
18
|
import { FsError } from "@deepseek-ai/dsh-fs";
|
|
19
19
|
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
|
20
20
|
//#region lib/types/contracts/prompt.js
|
|
@@ -1335,14 +1335,8 @@ async function parseCompactResponsePayload(response) {
|
|
|
1335
1335
|
const output = Array.isArray(body.output) ? body.output : [];
|
|
1336
1336
|
const compactions = [];
|
|
1337
1337
|
for (const item of output) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
if (encrypted.length === 0) continue;
|
|
1341
|
-
compactions.push({
|
|
1342
|
-
type: "compaction",
|
|
1343
|
-
encrypted_content: encrypted,
|
|
1344
|
-
...typeof item.id === "string" && item.id.length > 0 ? { id: item.id } : {}
|
|
1345
|
-
});
|
|
1338
|
+
const compaction = asCompactionItem(item);
|
|
1339
|
+
if (compaction !== void 0) compactions.push(compaction);
|
|
1346
1340
|
}
|
|
1347
1341
|
return {
|
|
1348
1342
|
compactions,
|
|
@@ -2217,29 +2211,53 @@ async function apiHeaders(ctx, profile, isV2Responses) {
|
|
|
2217
2211
|
}
|
|
2218
2212
|
return headers;
|
|
2219
2213
|
}
|
|
2220
|
-
|
|
2221
|
-
|
|
2214
|
+
const VALID_IMAGE_MEDIA_TYPES = /* @__PURE__ */ new Set([
|
|
2215
|
+
"image/png",
|
|
2216
|
+
"image/jpeg",
|
|
2217
|
+
"image/webp",
|
|
2218
|
+
"image/gif"
|
|
2219
|
+
]);
|
|
2220
|
+
function hasValidImageRef(attachment) {
|
|
2221
|
+
if (typeof attachment !== "object" || attachment === null) return false;
|
|
2222
|
+
const record = attachment;
|
|
2223
|
+
return typeof record.attachmentId === "string" && record.attachmentId.length > 0 && typeof record.mediaType === "string" && VALID_IMAGE_MEDIA_TYPES.has(record.mediaType) && typeof record.width === "number" && typeof record.height === "number";
|
|
2224
|
+
}
|
|
2225
|
+
function formatOffloadedImage(ctx, block) {
|
|
2226
|
+
const attachments = ctx.get("attachments");
|
|
2227
|
+
const fs = ctx.get("fs");
|
|
2228
|
+
const access = typeof attachments?.imageHostPath === "function" && typeof fs?.processPathFromHostPath === "function" ? resolveImageAttachmentAccess(attachments, (hostPath) => fs.processPathFromHostPath(hostPath), block.attachment) : void 0;
|
|
2229
|
+
return offloadedImageText(block.attachment, access);
|
|
2230
|
+
}
|
|
2231
|
+
function textOf(ctx, message) {
|
|
2232
|
+
return message.content.map((block) => {
|
|
2233
|
+
if (block.type === "text") return block.text;
|
|
2234
|
+
if (block.type === "image") {
|
|
2235
|
+
if (block.offloaded !== true || !hasValidImageRef(block.attachment)) throw new Error("Codex remote compaction requires the DSH adapter for image attachments");
|
|
2236
|
+
return formatOffloadedImage(ctx, block);
|
|
2237
|
+
}
|
|
2238
|
+
return "";
|
|
2239
|
+
}).join("");
|
|
2222
2240
|
}
|
|
2223
2241
|
function stripCompactionPrompt(messages) {
|
|
2224
2242
|
const last = messages.at(-1);
|
|
2225
2243
|
if (last !== void 0 && last.role === "user" && !("id" in last && last.id !== void 0)) return messages.slice(0, -1);
|
|
2226
2244
|
return messages;
|
|
2227
2245
|
}
|
|
2228
|
-
function extractInstructions(options, messages) {
|
|
2246
|
+
function extractInstructions(ctx, options, messages) {
|
|
2229
2247
|
if (options.system !== void 0) return options.system;
|
|
2230
2248
|
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
2231
2249
|
const message = messages[index];
|
|
2232
2250
|
if (message.role !== "system") continue;
|
|
2233
|
-
const text = textOf(message);
|
|
2251
|
+
const text = textOf(ctx, message);
|
|
2234
2252
|
return text.length > 0 ? text : void 0;
|
|
2235
2253
|
}
|
|
2236
2254
|
}
|
|
2237
|
-
function responsesInput(messages) {
|
|
2255
|
+
function responsesInput(ctx, messages) {
|
|
2238
2256
|
const result = [];
|
|
2239
2257
|
for (const message of messages) {
|
|
2240
2258
|
if (message.content.some((block) => block.type === "file")) throw new Error("Codex remote compaction requires the DSH adapter for attachments");
|
|
2241
2259
|
if (message.role === "system") continue;
|
|
2242
|
-
const text = textOf(message);
|
|
2260
|
+
const text = textOf(ctx, message);
|
|
2243
2261
|
if (message.role === "tool") {
|
|
2244
2262
|
result.push({
|
|
2245
2263
|
type: "function_call_output",
|
|
@@ -2286,14 +2304,14 @@ function responsesTools(tools) {
|
|
|
2286
2304
|
parameters: tool.parameters
|
|
2287
2305
|
}));
|
|
2288
2306
|
}
|
|
2289
|
-
function compactBody(options, wireOptions, isV2Responses) {
|
|
2307
|
+
function compactBody(ctx, options, wireOptions, isV2Responses) {
|
|
2290
2308
|
const messages = stripCompactionPrompt(options.messages);
|
|
2291
|
-
const instructions = extractInstructions(options, messages);
|
|
2309
|
+
const instructions = extractInstructions(ctx, options, messages);
|
|
2292
2310
|
const tools = responsesTools(options.tools);
|
|
2293
2311
|
const serviceTier = wireOptions.serviceTier ?? serviceTierOf(options);
|
|
2294
2312
|
const rewritten = rewriteCodexResponsesBody(replaceRemoteCompactions(applyRequestWireOptions({
|
|
2295
2313
|
model: options.model,
|
|
2296
|
-
input: responsesInput(messages),
|
|
2314
|
+
input: responsesInput(ctx, messages),
|
|
2297
2315
|
...instructions !== void 0 ? { instructions } : isV2Responses ? { instructions: "" } : {},
|
|
2298
2316
|
...tools === void 0 ? {} : { tools },
|
|
2299
2317
|
...typeof options.sessionId === "string" && options.sessionId.length > 0 ? { prompt_cache_key: options.sessionId.slice(0, 64) } : {},
|
|
@@ -2406,13 +2424,13 @@ async function remoteCompact(ctx, options, wireOptions = {}) {
|
|
|
2406
2424
|
...wireOptions,
|
|
2407
2425
|
trustedCheckpoints: wireOptions.trustedCheckpoints ?? collectTrustedCompactionMarkers(options.messages)
|
|
2408
2426
|
};
|
|
2409
|
-
const initial = compactBody(options, compactWireOptions, isV2Responses);
|
|
2427
|
+
const initial = compactBody(ctx, options, compactWireOptions, isV2Responses);
|
|
2410
2428
|
let preCompactInput = initial.preCompactInput;
|
|
2411
2429
|
let response = await sendWithRetry(endpoint, headers, initial.body, options.signal);
|
|
2412
2430
|
if (!response.ok && (response.status === 400 || response.status === 422) && canRewriteCompactTools(options, wireOptions)) {
|
|
2413
2431
|
const errorText = await response.clone().text().catch(() => "");
|
|
2414
2432
|
if (!CONTEXT_LIMIT_ERROR.test(errorText)) {
|
|
2415
|
-
const reduced = compactBody(options, {
|
|
2433
|
+
const reduced = compactBody(ctx, options, {
|
|
2416
2434
|
...compactWireOptions,
|
|
2417
2435
|
hostedWebSearch: false,
|
|
2418
2436
|
customApplyPatch: false
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/** A single Settings workspace; the bundle page is only a signpost. */
|
|
3
|
-
import { useState } from 'react';
|
|
3
|
+
import { useState, useSyncExternalStore } from 'react';
|
|
4
4
|
import { applyWithSettingsApi } from "./index.js";
|
|
5
5
|
import { nextOpenAICodexOverrides, OPENAI_CODEX_SETTINGS_NAMESPACE, } from "../contracts/ui-contracts.js";
|
|
6
|
-
import { bindToolPolicy, ToolPolicySection } from "./tool-policy.js";
|
|
6
|
+
import { bindToolPolicy, resolveGptCapabilities, ToolPolicySection } from "./tool-policy.js";
|
|
7
7
|
function asRecord(value) {
|
|
8
8
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
9
9
|
? value
|
|
@@ -20,6 +20,21 @@ function asOverrides(value) {
|
|
|
20
20
|
}
|
|
21
21
|
return out;
|
|
22
22
|
}
|
|
23
|
+
function projectCodexConnectRecord(record, baseRecord, writable) {
|
|
24
|
+
const searchModel = typeof record.searchModel === 'string' && record.searchModel.trim() ? record.searchModel.trim() : undefined;
|
|
25
|
+
const imageModelHint = typeof record.imageModelHint === 'string' ? record.imageModelHint.trim() : undefined;
|
|
26
|
+
return {
|
|
27
|
+
status: 'ready',
|
|
28
|
+
writable,
|
|
29
|
+
overrides: asOverrides(record.contextWindowOverrides),
|
|
30
|
+
baseOverrides: asOverrides(baseRecord?.contextWindowOverrides),
|
|
31
|
+
...(typeof record.enableNativeCompaction === 'boolean' ? { nativeCompaction: record.enableNativeCompaction } : {}),
|
|
32
|
+
...(typeof record.enableSearch === 'boolean' ? { searchEnabled: record.enableSearch } : {}),
|
|
33
|
+
...(searchModel !== undefined ? { searchModel } : {}),
|
|
34
|
+
...(typeof record.enableImageGeneration === 'boolean' ? { imageGenerationEnabled: record.enableImageGeneration } : {}),
|
|
35
|
+
...(imageModelHint !== undefined ? { imageModelHint } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
23
38
|
export function bindCodexConnectScope(configForms) {
|
|
24
39
|
const form = configForms.get(OPENAI_CODEX_SETTINGS_NAMESPACE);
|
|
25
40
|
const mirror = configForms.describe?.();
|
|
@@ -36,15 +51,7 @@ export function bindCodexConnectScope(configForms) {
|
|
|
36
51
|
lastMirrorSnap = mirrorSnap;
|
|
37
52
|
const formRecord = formSnap.status === 'ready' ? asRecord(formSnap.value) : undefined;
|
|
38
53
|
if (formRecord !== undefined) {
|
|
39
|
-
return projected =
|
|
40
|
-
status: 'ready',
|
|
41
|
-
writable: formSnap.writable,
|
|
42
|
-
overrides: asOverrides(formRecord.contextWindowOverrides),
|
|
43
|
-
baseOverrides: asOverrides(asRecord(formSnap.base)?.contextWindowOverrides),
|
|
44
|
-
...(typeof formRecord.enableNativeCompaction === 'boolean'
|
|
45
|
-
? { nativeCompaction: formRecord.enableNativeCompaction }
|
|
46
|
-
: {}),
|
|
47
|
-
};
|
|
54
|
+
return projected = projectCodexConnectRecord(formRecord, asRecord(formSnap.base), formSnap.writable);
|
|
48
55
|
}
|
|
49
56
|
const view = mirrorSnap?.view;
|
|
50
57
|
if (view !== undefined) {
|
|
@@ -52,15 +59,7 @@ export function bindCodexConnectScope(configForms) {
|
|
|
52
59
|
const rowRecord = row === undefined ? undefined : asRecord(row.value);
|
|
53
60
|
if (row === undefined || rowRecord === undefined)
|
|
54
61
|
return projected = { status: 'unavailable', writable: false };
|
|
55
|
-
return projected =
|
|
56
|
-
status: 'ready',
|
|
57
|
-
writable: view.writable ?? formSnap.writable,
|
|
58
|
-
overrides: asOverrides(rowRecord.contextWindowOverrides),
|
|
59
|
-
baseOverrides: asOverrides(asRecord(row.base)?.contextWindowOverrides),
|
|
60
|
-
...(typeof rowRecord.enableNativeCompaction === 'boolean'
|
|
61
|
-
? { nativeCompaction: rowRecord.enableNativeCompaction }
|
|
62
|
-
: {}),
|
|
63
|
-
};
|
|
62
|
+
return projected = projectCodexConnectRecord(rowRecord, asRecord(row.base), view.writable ?? formSnap.writable);
|
|
64
63
|
}
|
|
65
64
|
return projected = { status: formSnap.status, writable: formSnap.writable };
|
|
66
65
|
};
|
|
@@ -160,11 +159,19 @@ export function RuntimeSettingsEditor({ active, ...props }) {
|
|
|
160
159
|
.catch(() => setError(t('settingsSharedFailed'))).finally(() => setSaving(false));
|
|
161
160
|
}, children: _jsxs("fieldset", { disabled: !snapshot.writable || snapshot.status !== 'ready' || saving, children: [_jsx("div", { className: "codex-harness-grid", children: groups.map(group => _jsxs("div", { className: "codex-harness-card codex-harness-group", children: [_jsx("h4", { children: t(group.label) }), group.fields.map(([field, label]) => _jsxs("label", { className: "codex-harness-setting-row", children: [_jsx("span", { children: t(label) }), _jsx("input", { type: "checkbox", role: "switch", "aria-label": t(label), "aria-checked": Boolean(value(field) ?? (field !== 'fast')), checked: Boolean(value(field) ?? (field !== 'fast')), onChange: event => edit(field, event.target.checked) })] }, field))] }, group.label)) }), _jsxs("div", { className: "codex-harness-actions", children: [_jsx("button", { className: "codex-harness-btn codex-harness-primary", type: "submit", disabled: !Object.keys(edits).length, children: t(saving ? 'promptSaving' : 'settingsSaveRuntime') }), _jsx("button", { className: "codex-harness-btn", type: "button", disabled: draft === undefined, onClick: () => { setDraft(undefined); setError(''); }, children: t('promptDiscard') })] })] }) }), !snapshot.writable && _jsx("p", { className: "codex-harness-note", children: t('promptReadOnly') }), error && _jsx("p", { role: "alert", children: error })] });
|
|
162
161
|
}
|
|
162
|
+
const EMPTY_CONNECT_SUBSCRIBE = () => () => { };
|
|
163
|
+
const EMPTY_CONNECT_SNAPSHOT = () => undefined;
|
|
163
164
|
export function CodexSettingsTab(props) {
|
|
164
|
-
const { toolPolicy, presetManager, t } = props;
|
|
165
|
+
const { toolPolicy, presetManager, getCodexConnectScope, t } = props;
|
|
165
166
|
const [page, setPage] = useState(props.initialPage ?? 'tools');
|
|
167
|
+
const settingsSnapshot = typeof props.useSettings === 'function'
|
|
168
|
+
? props.useSettings(state => state)
|
|
169
|
+
: undefined;
|
|
170
|
+
const connectScope = getCodexConnectScope?.();
|
|
171
|
+
const connectSnapshot = useSyncExternalStore(connectScope ? connectScope.subscribe : EMPTY_CONNECT_SUBSCRIBE, connectScope ? connectScope.getSnapshot : EMPTY_CONNECT_SNAPSHOT, connectScope ? connectScope.getSnapshot : EMPTY_CONNECT_SNAPSHOT);
|
|
172
|
+
const gptCapabilities = resolveGptCapabilities(settingsSnapshot?.value, connectSnapshot);
|
|
166
173
|
const mode = page === 'tools' ? 'tools' : 'inactive';
|
|
167
|
-
return _jsxs("section", { className: "codex-harness-settings", children: [_jsx("style", { children: desktopStyles }), _jsxs("nav", { className: "codex-harness-nav", "aria-label": t('settingsTabLabel'), children: [_jsx("button", { type: "button", "aria-pressed": page === 'tools', onClick: () => setPage('tools'), children: t('settingsToolsPage') }), _jsx("button", { type: "button", "aria-pressed": page === 'runtime', onClick: () => setPage('runtime'), children: t('settingsRuntimePage') })] }), toolPolicy !== undefined && _jsx(ToolPolicySection, { binding: toolPolicy, presetManager: presetManager, mode: mode, t: t }), _jsx(RuntimeSettingsEditor, { ...props, active: page === 'runtime' })] });
|
|
174
|
+
return _jsxs("section", { className: "codex-harness-settings", children: [_jsx("style", { children: desktopStyles }), _jsxs("nav", { className: "codex-harness-nav", "aria-label": t('settingsTabLabel'), children: [_jsx("button", { type: "button", "aria-pressed": page === 'tools', onClick: () => setPage('tools'), children: t('settingsToolsPage') }), _jsx("button", { type: "button", "aria-pressed": page === 'runtime', onClick: () => setPage('runtime'), children: t('settingsRuntimePage') })] }), toolPolicy !== undefined && _jsx(ToolPolicySection, { binding: toolPolicy, presetManager: presetManager, mode: mode, gptCapabilities: gptCapabilities, t: t }), _jsx(RuntimeSettingsEditor, { ...props, active: page === 'runtime' })] });
|
|
168
175
|
}
|
|
169
176
|
export const inject = ['commandUi', 'sessions', 'slots', 'locale', 'configForms', 'remote'];
|
|
170
177
|
export function apply(ctx) {
|
|
@@ -192,6 +199,7 @@ export function apply(ctx) {
|
|
|
192
199
|
unsetSetting: field => settings.unset(field),
|
|
193
200
|
presetManager,
|
|
194
201
|
toolPolicy,
|
|
202
|
+
getCodexConnectScope,
|
|
195
203
|
saveSettings: async (edits, revision) => {
|
|
196
204
|
await saveDesktopSettings(form, edits, revision);
|
|
197
205
|
if (typeof edits.remoteCompactionEnabled === 'boolean') {
|
|
@@ -112,6 +112,17 @@ declare const en: {
|
|
|
112
112
|
readonly toolPolicyConditional: "Conditional";
|
|
113
113
|
readonly toolPolicyTargetExists: "Replacement target already exists";
|
|
114
114
|
readonly toolPolicyPresetDisabled: "Disabled by original preset";
|
|
115
|
+
readonly toolPolicyGptGroup: "GPT capabilities";
|
|
116
|
+
readonly toolPolicyGptHostedSearch: "GPT hosted search";
|
|
117
|
+
readonly toolPolicyGptHostedSearchTitle: "GPT sessions prefer OpenAI Responses hosted web_search (controlled in Runtime preferences).";
|
|
118
|
+
readonly toolPolicyGptCodexSearch: "Codex search";
|
|
119
|
+
readonly toolPolicyGptCodexSearchTitle: "Profile-wide web search owned by Codex Connect.";
|
|
120
|
+
readonly toolPolicyGptDualSearch: "GPT hosted / Codex search";
|
|
121
|
+
readonly toolPolicyGptDualSearchTitle: "GPT sessions prefer OpenAI hosted web_search; other models use Codex Connect search.";
|
|
122
|
+
readonly toolPolicyGptImageTitle: "Provided by Codex Connect (ChatGPT subscription image endpoint; tested to route to GPT-Image-2.6 Sunburst); callable from any tool-capable model.";
|
|
123
|
+
readonly toolPolicyGptCompactionDesc: "Server-side native context compaction (GPT sessions only; falls back to local summary on failure)";
|
|
124
|
+
readonly toolPolicyGptCompactionBadge: "GPT native compaction";
|
|
125
|
+
readonly toolPolicyGptCompactionReadOnly: "Non-tool · Runtime preference";
|
|
115
126
|
readonly toolPolicyCommandGroup: "Commands & runtime";
|
|
116
127
|
readonly toolPolicyFileGroup: "Files & search";
|
|
117
128
|
readonly toolPolicyPlanGroup: "Planning & interaction";
|
|
@@ -52,6 +52,17 @@ export declare const toolPolicyEn: {
|
|
|
52
52
|
readonly toolPolicyConditional: "Conditional";
|
|
53
53
|
readonly toolPolicyTargetExists: "Replacement target already exists";
|
|
54
54
|
readonly toolPolicyPresetDisabled: "Disabled by original preset";
|
|
55
|
+
readonly toolPolicyGptGroup: "GPT capabilities";
|
|
56
|
+
readonly toolPolicyGptHostedSearch: "GPT hosted search";
|
|
57
|
+
readonly toolPolicyGptHostedSearchTitle: "GPT sessions prefer OpenAI Responses hosted web_search (controlled in Runtime preferences).";
|
|
58
|
+
readonly toolPolicyGptCodexSearch: "Codex search";
|
|
59
|
+
readonly toolPolicyGptCodexSearchTitle: "Profile-wide web search owned by Codex Connect.";
|
|
60
|
+
readonly toolPolicyGptDualSearch: "GPT hosted / Codex search";
|
|
61
|
+
readonly toolPolicyGptDualSearchTitle: "GPT sessions prefer OpenAI hosted web_search; other models use Codex Connect search.";
|
|
62
|
+
readonly toolPolicyGptImageTitle: "Provided by Codex Connect (ChatGPT subscription image endpoint; tested to route to GPT-Image-2.6 Sunburst); callable from any tool-capable model.";
|
|
63
|
+
readonly toolPolicyGptCompactionDesc: "Server-side native context compaction (GPT sessions only; falls back to local summary on failure)";
|
|
64
|
+
readonly toolPolicyGptCompactionBadge: "GPT native compaction";
|
|
65
|
+
readonly toolPolicyGptCompactionReadOnly: "Non-tool · Runtime preference";
|
|
55
66
|
readonly toolPolicyCommandGroup: "Commands & runtime";
|
|
56
67
|
readonly toolPolicyFileGroup: "Files & search";
|
|
57
68
|
readonly toolPolicyPlanGroup: "Planning & interaction";
|
|
@@ -168,8 +179,8 @@ export declare const toolPolicyEn: {
|
|
|
168
179
|
readonly peReadError: "Preset definition unavailable.";
|
|
169
180
|
};
|
|
170
181
|
export declare const toolPolicyZh: Record<keyof typeof toolPolicyEn, string>;
|
|
171
|
-
export type ToolGroupId = 'command' | 'file' | 'plan' | 'collab' | 'other';
|
|
172
|
-
export declare function groupOf(tool: PresetToolEntry): ToolGroupId;
|
|
182
|
+
export type ToolGroupId = 'gpt' | 'command' | 'file' | 'plan' | 'collab' | 'other';
|
|
183
|
+
export declare function groupOf(tool: PresetToolEntry, gptSearchActive?: boolean): ToolGroupId;
|
|
173
184
|
export declare const humanLabels: {
|
|
174
185
|
readonly exec_command: "toolLabelExec";
|
|
175
186
|
readonly write_stdin: "toolLabelStdin";
|
|
@@ -256,5 +267,5 @@ export declare const humanLabels: {
|
|
|
256
267
|
readonly codex_connect_image_generate: "toolLabelCodexImageGen";
|
|
257
268
|
readonly codex_connect_quota: "toolLabelCodexQuota";
|
|
258
269
|
};
|
|
259
|
-
export declare const policyStyles = "\n.codex-tool-policy { display:flex; flex-direction:column; gap:12px; min-width:0; font-size:13px; color:var(--dsw-alias-label-primary); }\n.codex-tool-policy p, .codex-tool-policy h3, .codex-tool-policy h4 { margin:0; }\n.codex-tool-policy .codex-tool-policy-note { color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); font-size:12px; line-height:1.45; }\n.codex-tool-policy form, .codex-tool-policy fieldset { min-width:0; margin:0; padding:0; border:0; display:flex; flex-direction:column; gap:10px; }\n.codex-tool-policy .codex-card { border:0.5px solid var(--dsw-alias-settings-card-stroke, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-xl, 12px); background:var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-1)); padding:12px 14px; }\n.codex-tool-policy .codex-preset-bar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:10px; }\n.codex-tool-policy .codex-preset-select-wrap { display:flex; align-items:center; gap:8px; min-width:0; flex:1 1 260px; }\n.codex-tool-policy .codex-preset-select-wrap select { min-width:0; flex:1; height:32px; padding:0 10px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); color:inherit; font:inherit; }\n.codex-tool-policy .codex-btn { box-sizing:border-box; height:32px; padding:0 11px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); color:inherit; font:inherit; font-size:12px; cursor:pointer; white-space:nowrap; }\n.codex-tool-policy .codex-btn:disabled { opacity:.48; cursor:default; }\n.codex-tool-policy .codex-btn-primary { background:var(--dsw-alias-label-primary); color:var(--dsw-alias-bg-base); border-color:transparent; font-weight:500; }\n.codex-tool-policy .codex-seg { display:inline-flex; align-items:center; gap:2px; padding:2px; border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); border:0.5px solid var(--dsw-alias-border-l2); flex-shrink:0; }\n.codex-tool-policy .codex-seg button { border:0; border-radius:6px; padding:4px 9px; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:12px; line-height:18px; cursor:pointer; white-space:nowrap; transition:background .12s, color .12s; }\n.codex-tool-policy .codex-seg button:hover:not(:disabled) { color:var(--dsw-alias-label-primary); }\n.codex-tool-policy .codex-seg button:disabled { opacity:.38; cursor:default; }\n.codex-tool-policy .codex-seg button[aria-pressed=true] { background:var(--dsw-alias-label-primary); color:var(--dsw-alias-bg-base); font-weight:500; }\n.codex-tool-policy .codex-seg button[data-action=defer][aria-pressed=true] { background:var(--dsw-alias-interactive-bg-selected, rgba(59,130,246,0.14)); color:var(--dsw-static-blue-500, var(--dsw-alias-brand-primary)); font-weight:600; }\n.codex-tool-policy .codex-seg button[data-action=hide][aria-pressed=true] { background:var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); color:var(--dsw-alias-label-primary); }\n.codex-tool-policy :is(input,select,button,summary,textarea):focus-visible { outline:2px solid var(--dsw-focus-ring-color, var(--dsw-alias-brand-primary)); outline-offset:2px; }\n.codex-tool-policy .codex-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }\n.codex-tool-policy .codex-toolbar input[type=text] { flex:1 1 180px; min-width:0; height:32px; padding:0 10px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-1, var(--dsw-alias-bg-layer-2)); color:inherit; font:inherit; font-size:13px; }\n.codex-tool-policy details.codex-group { border:0.5px solid var(--dsw-alias-settings-card-stroke, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-xl, 12px); background:var(--dsw-alias-settings-card-fill, transparent); overflow:hidden; }\n.codex-tool-policy details.codex-group > summary { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:10px 14px; font-weight:600; font-size:13px; cursor:pointer; list-style:none; user-select:none; }\n.codex-tool-policy details.codex-group[open] > summary { border-bottom:0.5px solid var(--dsw-alias-border-l1); }\n.codex-tool-policy .codex-tool-policy-table { display:flex; flex-direction:column; }\n.codex-tool-policy .codex-tool-policy-tool { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px 12px; padding:8px 14px; border-bottom:0.5px solid var(--dsw-alias-border-l1); }\n.codex-tool-policy .codex-tool-policy-tool:last-child { border-bottom:0; }\n.codex-tool-policy .codex-tool-policy-tool[data-tool-action=hide] .codex-tool-policy-name { opacity:.52; }\n.codex-tool-policy .codex-tool-policy-name { min-width:0; flex:1 1 220px; display:flex; flex-wrap:wrap; align-items:center; gap:4px 8px; overflow-wrap:anywhere; }\n.codex-tool-policy .codex-tool-policy-identifier { font-size:13px; font-weight:600; color:var(--dsw-alias-label-primary); }\n.codex-tool-policy .codex-tool-policy-description { font-size:12px; color:var(--dsw-alias-label-secondary); }\n.codex-tool-policy .codex-badge { font-size:11px; line-height:16px; padding:1px 6px; border-radius:999px; background:var(--dsw-alias-bg-layer-2); color:var(--dsw-alias-label-secondary); border:0.5px solid var(--dsw-alias-border-l2); }\n.codex-tool-policy .codex-badge[data-tone=blue] { background:var(--dsw-alias-interactive-bg-selected, rgba(59,130,246,0.12)); color:var(--dsw-static-blue-500, var(--dsw-alias-brand-primary)); border-color:transparent; }\n.codex-tool-policy .codex-badge[data-tone=warn] { color:var(--dsw-alias-state-warn-primary); }\n.codex-tool-policy .codex-tool-policy-action { display:flex; align-items:center; gap:6px; flex-shrink:0; }\n.codex-tool-policy .codex-tool-policy-prompts { display:flex; flex-direction:column; gap:10px; }\n.codex-tool-policy .codex-tool-policy-prompt { display:grid; gap:8px; }\n.codex-tool-policy textarea { box-sizing:border-box; width:100%; min-width:0; resize:vertical; padding:8px 10px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); color:inherit; font:inherit; }\n.codex-tool-policy .codex-tool-policy-prompt pre { margin:0; max-height:240px; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; font-size:12px; }\n.codex-tool-policy .codex-save-bar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; padding:10px 14px; border:0.5px solid var(--dsw-alias-settings-card-stroke, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-xl, 12px); background:var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-1)); }\n.codex-tool-policy .codex-save-bar[data-dirty=true] { position:sticky; bottom:8px; z-index:2; border-color:var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); background:var(--dsw-alias-bg-layer-1, var(--dsw-alias-settings-card-fill)); box-shadow:0 4px 16px rgba(0,0,0,0.12); }\n.codex-tool-policy .codex-save-buttons { display:flex; align-items:center; gap:8px; }\n.codex-tool-policy .codex-tool-policy-warning { color:var(--dsw-alias-state-warn-primary); font-size:12px; }\n.codex-tool-policy .codex-tool-policy-error { color:var(--dsw-alias-state-error-primary); font-size:12px; }\n";
|
|
270
|
+
export declare const policyStyles = "\n.codex-tool-policy { display:flex; flex-direction:column; gap:12px; min-width:0; font-size:13px; color:var(--dsw-alias-label-primary); }\n.codex-tool-policy p, .codex-tool-policy h3, .codex-tool-policy h4 { margin:0; }\n.codex-tool-policy .codex-tool-policy-note { color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); font-size:12px; line-height:1.45; }\n.codex-tool-policy form, .codex-tool-policy fieldset { min-width:0; margin:0; padding:0; border:0; display:flex; flex-direction:column; gap:10px; }\n.codex-tool-policy .codex-card { border:0.5px solid var(--dsw-alias-settings-card-stroke, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-xl, 12px); background:var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-1)); padding:12px 14px; }\n.codex-tool-policy .codex-preset-bar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:10px; }\n.codex-tool-policy .codex-preset-select-wrap { display:flex; align-items:center; gap:8px; min-width:0; flex:1 1 260px; }\n.codex-tool-policy .codex-preset-select-wrap select { min-width:0; flex:1; height:32px; padding:0 10px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); color:inherit; font:inherit; }\n.codex-tool-policy .codex-btn { box-sizing:border-box; height:32px; padding:0 11px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); color:inherit; font:inherit; font-size:12px; cursor:pointer; white-space:nowrap; }\n.codex-tool-policy .codex-btn:disabled { opacity:.48; cursor:default; }\n.codex-tool-policy .codex-btn-primary { background:var(--dsw-alias-label-primary); color:var(--dsw-alias-bg-base); border-color:transparent; font-weight:500; }\n.codex-tool-policy .codex-seg { display:inline-flex; align-items:center; gap:2px; padding:2px; border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); border:0.5px solid var(--dsw-alias-border-l2); flex-shrink:0; }\n.codex-tool-policy .codex-seg button { border:0; border-radius:6px; padding:4px 9px; background:transparent; color:var(--dsw-alias-label-secondary); font:inherit; font-size:12px; line-height:18px; cursor:pointer; white-space:nowrap; transition:background .12s, color .12s; }\n.codex-tool-policy .codex-seg button:hover:not(:disabled) { color:var(--dsw-alias-label-primary); }\n.codex-tool-policy .codex-seg button:disabled { opacity:.38; cursor:default; }\n.codex-tool-policy .codex-seg button[aria-pressed=true] { background:var(--dsw-alias-label-primary); color:var(--dsw-alias-bg-base); font-weight:500; }\n.codex-tool-policy .codex-seg button[data-action=defer][aria-pressed=true] { background:var(--dsw-alias-interactive-bg-selected, rgba(59,130,246,0.14)); color:var(--dsw-static-blue-500, var(--dsw-alias-brand-primary)); font-weight:600; }\n.codex-tool-policy .codex-seg button[data-action=hide][aria-pressed=true] { background:var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); color:var(--dsw-alias-label-primary); }\n.codex-tool-policy :is(input,select,button,summary,textarea):focus-visible { outline:2px solid var(--dsw-focus-ring-color, var(--dsw-alias-brand-primary)); outline-offset:2px; }\n.codex-tool-policy .codex-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }\n.codex-tool-policy .codex-toolbar input[type=text] { flex:1 1 180px; min-width:0; height:32px; padding:0 10px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-1, var(--dsw-alias-bg-layer-2)); color:inherit; font:inherit; font-size:13px; }\n.codex-tool-policy details.codex-group { border:0.5px solid var(--dsw-alias-settings-card-stroke, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-xl, 12px); background:var(--dsw-alias-settings-card-fill, transparent); overflow:hidden; }\n.codex-tool-policy details.codex-group > summary { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:10px 14px; font-weight:600; font-size:13px; cursor:pointer; list-style:none; user-select:none; }\n.codex-tool-policy details.codex-group[open] > summary { border-bottom:0.5px solid var(--dsw-alias-border-l1); }\n.codex-tool-policy .codex-tool-policy-table { display:flex; flex-direction:column; }\n.codex-tool-policy .codex-tool-policy-tool { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px 12px; padding:8px 14px; border-bottom:0.5px solid var(--dsw-alias-border-l1); }\n.codex-tool-policy .codex-tool-policy-tool:last-child { border-bottom:0; }\n.codex-tool-policy .codex-tool-policy-tool[data-tool-action=hide] .codex-tool-policy-name { opacity:.52; }\n.codex-tool-policy .codex-tool-policy-name { min-width:0; flex:1 1 220px; display:flex; flex-wrap:wrap; align-items:center; gap:4px 8px; overflow-wrap:anywhere; }\n.codex-tool-policy .codex-tool-policy-identifier { font-size:13px; font-weight:600; color:var(--dsw-alias-label-primary); }\n.codex-tool-policy .codex-tool-policy-description { font-size:12px; color:var(--dsw-alias-label-secondary); }\n.codex-tool-policy .codex-badge { font-size:11px; line-height:16px; padding:1px 6px; border-radius:999px; background:var(--dsw-alias-bg-layer-2); color:var(--dsw-alias-label-secondary); border:0.5px solid var(--dsw-alias-border-l2); }\n.codex-tool-policy .codex-badge[data-tone=blue] { background:var(--dsw-alias-interactive-bg-selected, rgba(59,130,246,0.12)); color:var(--dsw-static-blue-500, var(--dsw-alias-brand-primary)); border-color:transparent; }\n.codex-tool-policy .codex-badge[data-tone=gpt] { background:var(--dsw-alias-state-success-bg, rgba(16,163,127,0.12)); color:var(--dsw-alias-state-success-primary, #10a37f); border-color:transparent; font-weight:500; }\n.codex-tool-policy .codex-badge[data-tone=warn] { color:var(--dsw-alias-state-warn-primary); }\n.codex-tool-policy .codex-tool-policy-action { display:flex; align-items:center; gap:6px; flex-shrink:0; }\n.codex-tool-policy .codex-tool-policy-prompts { display:flex; flex-direction:column; gap:10px; }\n.codex-tool-policy .codex-tool-policy-prompt { display:grid; gap:8px; }\n.codex-tool-policy textarea { box-sizing:border-box; width:100%; min-width:0; resize:vertical; padding:8px 10px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); color:inherit; font:inherit; }\n.codex-tool-policy .codex-tool-policy-prompt pre { margin:0; max-height:240px; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; font-size:12px; }\n.codex-tool-policy .codex-save-bar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; padding:10px 14px; border:0.5px solid var(--dsw-alias-settings-card-stroke, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-xl, 12px); background:var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-1)); }\n.codex-tool-policy .codex-save-bar[data-dirty=true] { position:sticky; bottom:8px; z-index:2; border-color:var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); background:var(--dsw-alias-bg-layer-1, var(--dsw-alias-settings-card-fill)); box-shadow:0 4px 16px rgba(0,0,0,0.12); }\n.codex-tool-policy .codex-save-buttons { display:flex; align-items:center; gap:8px; }\n.codex-tool-policy .codex-tool-policy-warning { color:var(--dsw-alias-state-warn-primary); font-size:12px; }\n.codex-tool-policy .codex-tool-policy-error { color:var(--dsw-alias-state-error-primary); font-size:12px; }\n";
|
|
260
271
|
//# sourceMappingURL=policy-locale.d.ts.map
|
|
@@ -50,6 +50,17 @@ export const toolPolicyEn = {
|
|
|
50
50
|
toolPolicyConditional: 'Conditional',
|
|
51
51
|
toolPolicyTargetExists: 'Replacement target already exists',
|
|
52
52
|
toolPolicyPresetDisabled: 'Disabled by original preset',
|
|
53
|
+
toolPolicyGptGroup: 'GPT capabilities',
|
|
54
|
+
toolPolicyGptHostedSearch: 'GPT hosted search',
|
|
55
|
+
toolPolicyGptHostedSearchTitle: 'GPT sessions prefer OpenAI Responses hosted web_search (controlled in Runtime preferences).',
|
|
56
|
+
toolPolicyGptCodexSearch: 'Codex search',
|
|
57
|
+
toolPolicyGptCodexSearchTitle: 'Profile-wide web search owned by Codex Connect.',
|
|
58
|
+
toolPolicyGptDualSearch: 'GPT hosted / Codex search',
|
|
59
|
+
toolPolicyGptDualSearchTitle: 'GPT sessions prefer OpenAI hosted web_search; other models use Codex Connect search.',
|
|
60
|
+
toolPolicyGptImageTitle: 'Provided by Codex Connect (ChatGPT subscription image endpoint; tested to route to GPT-Image-2.6 Sunburst); callable from any tool-capable model.',
|
|
61
|
+
toolPolicyGptCompactionDesc: 'Server-side native context compaction (GPT sessions only; falls back to local summary on failure)',
|
|
62
|
+
toolPolicyGptCompactionBadge: 'GPT native compaction',
|
|
63
|
+
toolPolicyGptCompactionReadOnly: 'Non-tool · Runtime preference',
|
|
53
64
|
toolPolicyCommandGroup: 'Commands & runtime',
|
|
54
65
|
toolPolicyFileGroup: 'Files & search',
|
|
55
66
|
toolPolicyPlanGroup: 'Planning & interaction',
|
|
@@ -176,6 +187,17 @@ export const toolPolicyZh = {
|
|
|
176
187
|
toolPolicyConditional: '按条件可用',
|
|
177
188
|
toolPolicyTargetExists: '替换目标已存在',
|
|
178
189
|
toolPolicyPresetDisabled: '原预设未启用',
|
|
190
|
+
toolPolicyGptGroup: 'GPT 能力',
|
|
191
|
+
toolPolicyGptHostedSearch: 'GPT 托管搜索',
|
|
192
|
+
toolPolicyGptHostedSearchTitle: 'GPT 会话优先使用 OpenAI Responses 原生托管搜索(由「运行偏好」控制)。',
|
|
193
|
+
toolPolicyGptCodexSearch: 'Codex 订阅搜索',
|
|
194
|
+
toolPolicyGptCodexSearchTitle: '由 Codex Connect 接管当前配置全局联网搜索。',
|
|
195
|
+
toolPolicyGptDualSearch: 'GPT 托管 / Codex 搜索',
|
|
196
|
+
toolPolicyGptDualSearchTitle: 'GPT 会话优先使用 OpenAI 原生托管搜索;其他模型走 Codex Connect 订阅搜索。',
|
|
197
|
+
toolPolicyGptImageTitle: '来源于 Codex Connect(ChatGPT 订阅生图接口,实测路由至 GPT-Image-2.6 Sunburst),支持工具调用的模型均可调用。',
|
|
198
|
+
toolPolicyGptCompactionDesc: '使用 OpenAI 服务端原生压缩替代默认文本摘要(仅 GPT 会话,失败自动回退)',
|
|
199
|
+
toolPolicyGptCompactionBadge: 'GPT 原生压缩',
|
|
200
|
+
toolPolicyGptCompactionReadOnly: '非工具 · 运行偏好控制',
|
|
179
201
|
toolPolicyCommandGroup: '命令与执行',
|
|
180
202
|
toolPolicyFileGroup: '文件与检索',
|
|
181
203
|
toolPolicyPlanGroup: '规划与交互',
|
|
@@ -263,7 +285,11 @@ const collabNames = new Set([
|
|
|
263
285
|
'create_goal', 'get_goal', 'update_goal', 'goal', 'spawn_teammate', 'team_task_create', 'team_task_get',
|
|
264
286
|
'team_task_list', 'team_task_update',
|
|
265
287
|
]);
|
|
266
|
-
export function groupOf(tool) {
|
|
288
|
+
export function groupOf(tool, gptSearchActive = false) {
|
|
289
|
+
if (tool.name === 'codex_connect_image_generate')
|
|
290
|
+
return 'gpt';
|
|
291
|
+
if (tool.name === 'web_search' && gptSearchActive)
|
|
292
|
+
return 'gpt';
|
|
267
293
|
if (commandNames.has(tool.name) || tool.replacements.some(item => item.action === 'codex-exec'))
|
|
268
294
|
return 'command';
|
|
269
295
|
if (fileNames.has(tool.name) || tool.replacements.some(item => item.action === 'codex-patch'))
|
|
@@ -342,6 +368,7 @@ export const policyStyles = `
|
|
|
342
368
|
.codex-tool-policy .codex-tool-policy-description { font-size:12px; color:var(--dsw-alias-label-secondary); }
|
|
343
369
|
.codex-tool-policy .codex-badge { font-size:11px; line-height:16px; padding:1px 6px; border-radius:999px; background:var(--dsw-alias-bg-layer-2); color:var(--dsw-alias-label-secondary); border:0.5px solid var(--dsw-alias-border-l2); }
|
|
344
370
|
.codex-tool-policy .codex-badge[data-tone=blue] { background:var(--dsw-alias-interactive-bg-selected, rgba(59,130,246,0.12)); color:var(--dsw-static-blue-500, var(--dsw-alias-brand-primary)); border-color:transparent; }
|
|
371
|
+
.codex-tool-policy .codex-badge[data-tone=gpt] { background:var(--dsw-alias-state-success-bg, rgba(16,163,127,0.12)); color:var(--dsw-alias-state-success-primary, #10a37f); border-color:transparent; font-weight:500; }
|
|
345
372
|
.codex-tool-policy .codex-badge[data-tone=warn] { color:var(--dsw-alias-state-warn-primary); }
|
|
346
373
|
.codex-tool-policy .codex-tool-policy-action { display:flex; align-items:center; gap:6px; flex-shrink:0; }
|
|
347
374
|
.codex-tool-policy .codex-tool-policy-prompts { display:flex; flex-direction:column; gap:10px; }
|
|
@@ -3,6 +3,7 @@ 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 type { CodexConnectSnapshot } from '../contracts/ui-contracts.ts';
|
|
6
7
|
import { toolPolicyEn, toolPolicyZh } from './policy-locale.ts';
|
|
7
8
|
export type { ToolPolicyRule } from '../contracts/tool-policy-contract.ts';
|
|
8
9
|
export { toolPolicyEn, toolPolicyZh };
|
|
@@ -18,16 +19,29 @@ export declare function bindToolPolicy(ctx: Pick<Context, 'effect'>, forms: Poli
|
|
|
18
19
|
export declare function validateToolPolicyRules(rules: readonly ToolPolicyRule[]): 'toolPolicyInvalidPreset' | 'toolPolicyDuplicatePreset' | undefined;
|
|
19
20
|
export declare function withToolAction(rule: ToolPolicyRule, name: string, action: ToolAction, context?: ToolActionContext): ToolPolicyRule;
|
|
20
21
|
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;
|
|
21
34
|
export type ToolPolicySubMode = 'tools' | 'prompts' | 'definition';
|
|
22
35
|
export type ToolPolicyMode = ToolPolicySubMode | 'inactive';
|
|
23
36
|
type PolicyProps = PropsLocale<'codex'> & {
|
|
24
37
|
presetManager?: PresetManagerActions | undefined;
|
|
25
38
|
mode?: ToolPolicyMode;
|
|
39
|
+
gptCapabilities?: GptCapabilitiesState | undefined;
|
|
26
40
|
};
|
|
27
41
|
export declare function ToolPolicySection({ binding, ...props }: {
|
|
28
42
|
binding: ToolPolicyBinding;
|
|
29
43
|
} & PolicyProps): import("react").JSX.Element | null;
|
|
30
|
-
export declare function ToolPolicySettingsCard({ form, presetManager, mode, t }: {
|
|
44
|
+
export declare function ToolPolicySettingsCard({ form, presetManager, mode, gptCapabilities, t }: {
|
|
31
45
|
form: ToolPolicyForm;
|
|
32
46
|
} & PolicyProps): import("react").JSX.Element | null;
|
|
33
47
|
//# sourceMappingURL=tool-policy.d.ts.map
|
|
@@ -70,8 +70,33 @@ 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
|
+
}
|
|
73
97
|
const isPromptName = (name) => PRESET_PROMPT_NAMES.includes(name);
|
|
74
98
|
const GROUP_META = [
|
|
99
|
+
{ id: 'gpt', labelKey: 'toolPolicyGptGroup' },
|
|
75
100
|
{ id: 'command', labelKey: 'toolPolicyCommandGroup' },
|
|
76
101
|
{ id: 'file', labelKey: 'toolPolicyFileGroup' },
|
|
77
102
|
{ id: 'plan', labelKey: 'toolPolicyPlanGroup' },
|
|
@@ -82,7 +107,7 @@ export function ToolPolicySection({ binding, ...props }) {
|
|
|
82
107
|
const form = useSyncExternalStore(binding.subscribe, binding.getSnapshot, binding.getSnapshot);
|
|
83
108
|
return form === undefined ? null : _jsx(ToolPolicySettingsCard, { form: form, ...props });
|
|
84
109
|
}
|
|
85
|
-
export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', t }) {
|
|
110
|
+
export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', gptCapabilities, t }) {
|
|
86
111
|
const snapshot = useSyncExternalStore(listener => form.subscribe(listener), () => form.getSnapshot(), () => form.getSnapshot());
|
|
87
112
|
const [subMode, setSubMode] = useState(mode === 'prompts' || mode === 'definition' ? mode : 'tools');
|
|
88
113
|
const prevMode = useRef(mode);
|
|
@@ -301,31 +326,63 @@ export function ToolPolicySettingsCard({ form, presetManager, mode = 'tools', t
|
|
|
301
326
|
];
|
|
302
327
|
const changeSummary = summaryParts.join(' · ') || t(currentDraft && !sameRules(beforeTarget, currentDraft.rules) ? 'toolPolicyRuleChanged' : 'toolPolicyNoToolDelta');
|
|
303
328
|
const unavailable = (reason) => t(reason === 'conditional' ? 'toolPolicyConditional' : reason === 'target-exists' ? 'toolPolicyTargetExists' : 'toolPolicyUnsupported');
|
|
304
|
-
const
|
|
329
|
+
const gptSearchActive = gptCapabilities?.hostedWebSearch === true || gptCapabilities?.codexSearch === true;
|
|
330
|
+
const gptBadgeFor = (tool) => {
|
|
331
|
+
if (tool.name === 'codex_connect_image_generate') {
|
|
332
|
+
return { label: formatGptImageBadge(gptCapabilities?.imageModelHint), title: t('toolPolicyGptImageTitle') };
|
|
333
|
+
}
|
|
334
|
+
if (tool.name === 'web_search' && gptSearchActive) {
|
|
335
|
+
const model = gptCapabilities?.codexSearchModel;
|
|
336
|
+
if (gptCapabilities?.hostedWebSearch && gptCapabilities?.codexSearch) {
|
|
337
|
+
return {
|
|
338
|
+
label: t('toolPolicyGptDualSearch'),
|
|
339
|
+
title: model ? `${t('toolPolicyGptDualSearchTitle')} (${model})` : t('toolPolicyGptDualSearchTitle'),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
if (gptCapabilities?.hostedWebSearch) {
|
|
343
|
+
return { label: t('toolPolicyGptHostedSearch'), title: t('toolPolicyGptHostedSearchTitle') };
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
label: model ? `${t('toolPolicyGptCodexSearch')} · ${model}` : t('toolPolicyGptCodexSearch'),
|
|
347
|
+
title: model ? `${t('toolPolicyGptCodexSearchTitle')} (${model})` : t('toolPolicyGptCodexSearchTitle'),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
return undefined;
|
|
351
|
+
};
|
|
352
|
+
const renderRows = (tools, includeCompaction = false) => _jsxs("div", { className: "codex-tool-policy-table", role: "table", "aria-label": t('toolPolicyTitle'), children: [tools.map(tool => {
|
|
305
353
|
const action = chosen(tool);
|
|
306
354
|
const deferReason = deferUnavailableReason(tool);
|
|
307
355
|
const supported = action === 'keep' || action === 'hide' || action === 'defer' || tool.replacements.some(option => option.action === action);
|
|
308
356
|
const custom = customized(tool);
|
|
309
357
|
const hasOverride = !!rule?.tools?.some(choice => choice.name === tool.name);
|
|
310
|
-
|
|
311
|
-
|
|
358
|
+
const gptBadge = gptBadgeFor(tool);
|
|
359
|
+
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
|
+
}), includeCompaction && _jsxs("div", { role: "row", className: "codex-tool-policy-tool", "data-gpt-capability": "compaction", children: [_jsxs("div", { role: "cell", className: "codex-tool-policy-name", children: [_jsx("code", { className: "codex-tool-policy-identifier", children: "/compact" }), _jsx("span", { className: "codex-tool-policy-description", children: t('toolPolicyGptCompactionDesc') }), _jsx("span", { className: "codex-badge", "data-tone": "gpt", children: t('toolPolicyGptCompactionBadge') })] }), _jsx("div", { role: "cell", className: "codex-tool-policy-action", children: _jsx("span", { className: "codex-badge", children: t('toolPolicyGptCompactionReadOnly') }) })] }, "__gpt_compaction__"), tools.length === 0 && !includeCompaction && _jsx("p", { className: "codex-tool-policy-note", style: { padding: '12px 14px' }, children: t('toolPolicyNoMatches') })] });
|
|
312
361
|
if (snapshot.status !== 'ready' || snapshot.value === undefined || mode === 'inactive')
|
|
313
362
|
return null;
|
|
314
363
|
const text = query.trim().toLowerCase();
|
|
315
364
|
const isFiltering = text.length > 0 || filter !== 'all';
|
|
316
365
|
const allTools = inventory?.tools ?? [];
|
|
317
366
|
const hasReplaceable = allTools.some(tool => tool.replacements.some(option => option.available));
|
|
318
|
-
const shown = allTools.filter(tool =>
|
|
319
|
-
|
|
320
|
-
|
|
367
|
+
const shown = allTools.filter(tool => {
|
|
368
|
+
const gptBadge = gptBadgeFor(tool);
|
|
369
|
+
const haystack = `${human(tool)} ${tool.name} ${tool.description} ${gptBadge?.label ?? ''}`.toLowerCase();
|
|
370
|
+
return (!text || haystack.includes(text))
|
|
371
|
+
&& (filter === 'all' || (filter === 'modified' ? customized(tool) : filter === 'deferred' ? chosen(tool) === 'defer' : tool.replacements.some(option => option.available)));
|
|
372
|
+
});
|
|
373
|
+
const compactionSearchText = `/compact compaction ${t('toolPolicyGptCompactionDesc')} ${t('toolPolicyGptCompactionBadge')} gpt`.toLowerCase();
|
|
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
|
|
321
376
|
? _jsx("div", { className: "codex-card", children: renderRows(shown) })
|
|
322
377
|
: GROUP_META.map(group => {
|
|
323
|
-
const tools = shown.filter(tool => groupOf(tool) === group.id);
|
|
324
|
-
|
|
378
|
+
const tools = shown.filter(tool => groupOf(tool, gptSearchActive) === group.id);
|
|
379
|
+
const includeCompaction = group.id === 'gpt' && showCompactionRow;
|
|
380
|
+
if (!tools.length && !includeCompaction)
|
|
325
381
|
return null;
|
|
326
382
|
const changes = tools.filter(customized).length;
|
|
327
383
|
const key = `${selectedId}/${group.id}`;
|
|
328
|
-
|
|
384
|
+
const count = tools.length + (includeCompaction ? 1 : 0);
|
|
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);
|
|
329
386
|
}))] }), 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 => {
|
|
330
387
|
const editable = section.editable && isPromptName(section.name);
|
|
331
388
|
const override = rule?.promptOverrides?.find(entry => entry.name === section.name);
|
|
@@ -78,6 +78,10 @@ export interface CodexConnectSnapshot {
|
|
|
78
78
|
readonly overrides?: Readonly<Record<string, number | null>> | undefined;
|
|
79
79
|
readonly baseOverrides?: Readonly<Record<string, number | null>> | undefined;
|
|
80
80
|
readonly nativeCompaction?: boolean | undefined;
|
|
81
|
+
readonly searchEnabled?: boolean | undefined;
|
|
82
|
+
readonly searchModel?: string | undefined;
|
|
83
|
+
readonly imageGenerationEnabled?: boolean | undefined;
|
|
84
|
+
readonly imageModelHint?: string | undefined;
|
|
81
85
|
}
|
|
82
86
|
export interface CodexConnectScope {
|
|
83
87
|
getSnapshot(): CodexConnectSnapshot;
|
|
@@ -165,16 +165,9 @@ export async function parseCompactResponsePayload(response) {
|
|
|
165
165
|
const output = Array.isArray(body.output) ? body.output : [];
|
|
166
166
|
const compactions = [];
|
|
167
167
|
for (const item of output) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (encrypted.length === 0)
|
|
172
|
-
continue;
|
|
173
|
-
compactions.push({
|
|
174
|
-
type: 'compaction',
|
|
175
|
-
encrypted_content: encrypted,
|
|
176
|
-
...typeof item.id === 'string' && item.id.length > 0 ? { id: item.id } : {},
|
|
177
|
-
});
|
|
168
|
+
const compaction = asCompactionItem(item);
|
|
169
|
+
if (compaction !== undefined)
|
|
170
|
+
compactions.push(compaction);
|
|
178
171
|
}
|
|
179
172
|
return {
|
|
180
173
|
compactions,
|