@shuind/dsh-codex-harness 0.2.15 → 0.2.17

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/lib/typert.js ADDED
@@ -0,0 +1,117 @@
1
+ import { z } from "zod";
2
+ //#region lib/types/typert.host.js
3
+ const PACKAGE = "@shuind/dsh-codex-harness";
4
+ const SERVICE = "codexPresetEditor";
5
+ const promptSections = z.array(z.object({
6
+ id: z.string(),
7
+ label: z.string(),
8
+ text: z.string().max(1e6),
9
+ editable: z.boolean(),
10
+ suppressed: z.boolean().optional()
11
+ })).max(200);
12
+ const fields = {
13
+ name: z.string().max(200),
14
+ description: z.string().max(4e3),
15
+ systemPrompt: z.string().max(1e6),
16
+ inheritPrompt: z.boolean()
17
+ };
18
+ const codexOptions = z.object({
19
+ promptEnabled: z.boolean(),
20
+ terminalToolsEnabled: z.boolean(),
21
+ patchToolEnabled: z.boolean(),
22
+ planToolEnabled: z.boolean(),
23
+ hostedWebSearchEnabled: z.boolean(),
24
+ remoteCompactionEnabled: z.boolean()
25
+ });
26
+ const document = z.object({
27
+ ...fields,
28
+ id: z.string(),
29
+ revision: z.string(),
30
+ editable: z.boolean(),
31
+ codex: z.boolean(),
32
+ codexOptions,
33
+ promptSections,
34
+ composition: z.string()
35
+ });
36
+ const catalog = z.object({
37
+ presets: z.array(z.object({
38
+ id: z.string(),
39
+ name: z.string(),
40
+ description: z.string(),
41
+ editable: z.boolean(),
42
+ isDefault: z.boolean()
43
+ })),
44
+ authorable: z.boolean(),
45
+ excludedCount: z.number()
46
+ });
47
+ const codexOptionsPatch = codexOptions.partial();
48
+ function descriptor(method, parameter, input, output) {
49
+ const id = `${PACKAGE}#${SERVICE}/${method}`;
50
+ return {
51
+ id,
52
+ service: SERVICE,
53
+ namespace: SERVICE,
54
+ method,
55
+ invocation: { kind: "direct" },
56
+ parameters: parameter === void 0 ? [] : [{
57
+ name: parameter,
58
+ wire: parameter,
59
+ source: "json",
60
+ codec: {
61
+ mode: "strict",
62
+ typeSymbol: `${id}:${parameter}`,
63
+ schema: input
64
+ }
65
+ }],
66
+ result: {
67
+ mode: "strict",
68
+ typeSymbol: `${id}:result`,
69
+ schema: output
70
+ }
71
+ };
72
+ }
73
+ const updateInput = z.object({
74
+ ...fields,
75
+ id: z.string(),
76
+ revision: z.string().optional(),
77
+ composition: z.string().max(1e6).optional(),
78
+ enableCodex: z.boolean().optional(),
79
+ promptSections: promptSections.optional(),
80
+ codexOptions: codexOptionsPatch.optional()
81
+ });
82
+ const createInput = z.object({
83
+ ...fields,
84
+ sourceId: z.string(),
85
+ enableCodex: z.boolean().optional(),
86
+ composition: z.string().max(1e6).optional(),
87
+ promptSections: promptSections.optional(),
88
+ codexOptions: codexOptionsPatch.optional()
89
+ });
90
+ /** Host-side Remote contract consumed by the browser's preset editor. */
91
+ const TYPERT = {
92
+ package: PACKAGE,
93
+ face: "host",
94
+ schemas: [],
95
+ invocations: [
96
+ descriptor("catalog", void 0, z.unknown(), catalog),
97
+ descriptor("read", "id", z.string(), document),
98
+ descriptor("update", "rawInput", updateInput, document),
99
+ descriptor("create", "rawInput", createInput, document)
100
+ ],
101
+ model: {
102
+ services: [{
103
+ description: "Author and inspect DSH agent presets with Codex capabilities.",
104
+ summary: "Codex preset editor.",
105
+ tags: [],
106
+ jsDoc: "",
107
+ key: SERVICE,
108
+ exportName: "CodexPresetEditor",
109
+ members: [],
110
+ types: []
111
+ }],
112
+ events: [],
113
+ objects: []
114
+ }
115
+ };
116
+ //#endregion
117
+ export { TYPERT, TYPERT as default };
@@ -4,6 +4,7 @@ import type { Context } from '@deepseek-ai/cordis';
4
4
  import type { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client';
5
5
  import type { CodexActivity } from '../activity-types.ts';
6
6
  import { modelActivity } from './activity.ts';
7
+ import type { PresetManagerActions } from './preset-manager.tsx';
7
8
  declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
8
9
  interface CodexSettings {
9
10
  fast: boolean;
@@ -32,13 +33,10 @@ declare const en: {
32
33
  readonly contextSizeDescription: "Next request capacity in K tokens.";
33
34
  readonly contextRestore: "Restore model default";
34
35
  readonly promptCardTitle: "Codex Harness";
35
- readonly promptCardDescription: "Choose Codex capabilities and customize the operating prompt.";
36
- readonly codexOnlyCapabilitiesLabel: "Codex mode only";
37
- readonly otherCapabilitiesLabel: "Additional capabilities";
36
+ readonly promptCardDescription: "Edit presets, Codex capabilities, and the operating prompt. Activity status is global.";
37
+ readonly otherCapabilitiesLabel: "Global capabilities";
38
38
  readonly capabilityPrompt: "Codex operating prompt";
39
39
  readonly capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout.";
40
- readonly capabilityFast: "Fast mode control";
41
- readonly capabilityFastHint: "Show the Fast mode switch beside the conversation composer.";
42
40
  readonly compactRemote: "Remote compaction";
43
41
  readonly compactRemoteHint: "Use the provider remote compaction endpoint first.";
44
42
  readonly compactLocal: "Local compaction";
@@ -76,6 +74,44 @@ declare const en: {
76
74
  readonly activityCompacting: "Compacting context...";
77
75
  readonly activityRequestingModel: "Requesting model...";
78
76
  readonly activityModelReply: "Model replying...";
77
+ readonly peConnectionError: "Could not connect to the local service. Retry loading; if the connection still fails, reconnect the page.";
78
+ readonly peReadError: "Could not read this preset. Retry loading or refresh the preset list.";
79
+ readonly peRetryRead: "Retry loading";
80
+ readonly peReconnect: "Reconnect page";
81
+ readonly peSystemPrompt: "System prompt sections";
82
+ readonly peSectionsHint: "These templates contribute to this preset’s system prompt before the tools. Runtime variables, workspace instructions and plugin-provided guidance are assembled when the conversation runs.";
83
+ readonly peDynamicPrompt: "This field is an expression; it is preserved without executing it in the editor.";
84
+ readonly peDshSourcePrompt: "Tells the agent where the DSH source checkout is and keeps it separate from the current workspace. It is used when inspecting or extending DSH itself.";
85
+ readonly peDshWebPrompt: "Tells the agent which Web page it is talking through, what “this page” means, and when Web changes need a rebuild or refresh.";
86
+ readonly peSuppressed: "Not used";
87
+ readonly peCompletePersona: "This preset uses Persona as its entire system prompt, so this section is excluded.";
88
+ readonly peLoading: "Reading preset…";
89
+ readonly peTitle: "Preset editor";
90
+ readonly peHierarchy: "Codex mode and other presets are peers. Choose one to edit, or make an editable copy of a built-in preset first.";
91
+ readonly peSelect: "Preset";
92
+ readonly peSelectPlaceholder: "Choose a preset…";
93
+ readonly peEditable: "This is an editable user preset.";
94
+ readonly peBuiltinEdit: "Built-in presets are read-only. Create a copy to edit it.";
95
+ readonly peCreateCopy: "Create editable copy";
96
+ readonly peCodexSection: "Codex mode capabilities";
97
+ readonly peAddCodex: "Add Codex capabilities to this preset";
98
+ readonly peAddCodexHint: "Adds the Codex prompt, tools, hosted search, and remote compaction to this preset.";
99
+ readonly peActivityGlobal: "Activity status is a global display setting and is shared by all presets.";
100
+ readonly peSaveCopy: "Save new preset";
101
+ readonly peSaved: "Saved. Select this preset in a new conversation.";
102
+ readonly pmGlobalSettings: "Global settings";
103
+ readonly pmRefresh: "Refresh";
104
+ readonly pmBuiltIn: "Built-in";
105
+ readonly pmCustom: "Custom";
106
+ readonly pmDiscard: "Discard your unsaved changes?";
107
+ readonly pmConflict: "This preset changed in another page or on disk. Reopen the latest version before saving.";
108
+ readonly pmYamlError: "The configuration must be valid YAML. Your draft has not been saved.";
109
+ readonly pmErrorDetails: "Technical details";
110
+ readonly pmSaveError: "Could not complete this action. Your draft is still here.";
111
+ readonly pmName: "Name";
112
+ readonly pmDescription: "Description";
113
+ readonly pmCancel: "Cancel";
114
+ readonly pmSave: "Save changes";
79
115
  };
80
116
  type CodexKey = keyof typeof en;
81
117
  declare module '@deepseek-ai/dsh-client-ui-slots' {
@@ -102,8 +138,9 @@ interface InputSettingsControlInjected {
102
138
  };
103
139
  setSetting: (field: string, value: unknown) => Promise<void>;
104
140
  unsetSetting: (field: string) => Promise<void>;
141
+ presetManager: PresetManagerActions;
105
142
  }
106
- /** Full-prompt editor contributed to Settings > Plugins. */
143
+ /** One editor per preset; only display preferences are global. */
107
144
  export declare function PromptSettingsCard(props: PropsRuntime<'settings.plugin.item'> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>): import("react").JSX.Element | null;
108
145
  type LegacyOverlayProps = PropsRuntime<typeof LEGACY_OVERLAY_SLOT> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
109
146
  type ActivityProps = Pick<LegacyOverlayProps, 'sessionId' | 'useSession' | 'useSessions' | 'useProjection' | 'useSettings' | 't'>;
@@ -3,8 +3,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
  import { CODEX_CONTEXT_MAX, CODEX_CONTEXT_UNIT, isCodexPresetId } from "../context.js";
6
- import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from "../prompt.js";
7
6
  import { modelActivity, sameModelActivity } from "./activity.js";
7
+ import presetEditorRemote from "../preset-editor-remote.js";
8
+ import { PresetManagerCard } from "./preset-manager.js";
9
+ import { presetEn, presetZh } from "./preset-copy.js";
8
10
  const NS = 'codex';
9
11
  const SETTINGS_NAMESPACE = 'codex';
10
12
  const FAST_FALLBACK_SLOT = 'conversation.input.right';
@@ -12,6 +14,7 @@ const LEGACY_OVERLAY_SLOT = 'conversation.input.overlay';
12
14
  const PLUGIN_SETTINGS_SLOT = 'settings.plugin.item';
13
15
  const DEFAULT_CONTEXT_WINDOW = 262_144;
14
16
  const en = {
17
+ ...presetEn,
15
18
  fast: 'Fast mode',
16
19
  fastOn: 'Fast mode on (priority tier)',
17
20
  fastOff: 'Fast mode off',
@@ -21,13 +24,10 @@ const en = {
21
24
  contextSizeDescription: 'Next request capacity in K tokens.',
22
25
  contextRestore: 'Restore model default',
23
26
  promptCardTitle: 'Codex Harness',
24
- promptCardDescription: 'Choose Codex capabilities and customize the operating prompt.',
25
- codexOnlyCapabilitiesLabel: 'Codex mode only',
26
- otherCapabilitiesLabel: 'Additional capabilities',
27
+ promptCardDescription: 'Edit presets, Codex capabilities, and the operating prompt. Activity status is global.',
28
+ otherCapabilitiesLabel: 'Global capabilities',
27
29
  capabilityPrompt: 'Codex operating prompt',
28
30
  capabilityPromptHint: 'Inject the editable instructions and persona-first prompt layout.',
29
- capabilityFast: 'Fast mode control',
30
- capabilityFastHint: 'Show the Fast mode switch beside the conversation composer.',
31
31
  compactRemote: 'Remote compaction',
32
32
  compactRemoteHint: 'Use the provider remote compaction endpoint first.',
33
33
  compactLocal: 'Local compaction',
@@ -67,6 +67,7 @@ const en = {
67
67
  activityModelReply: 'Model replying...',
68
68
  };
69
69
  const zh = {
70
+ ...presetZh,
70
71
  fast: 'Fast',
71
72
  fastOn: 'Fast mode on (priority tier)',
72
73
  fastOff: 'Fast mode off',
@@ -76,13 +77,10 @@ const zh = {
76
77
  contextSizeDescription: '\u8bbe\u7f6e\u4e0b\u6b21\u8bf7\u6c42\u7684\u4e0a\u4e0b\u6587\u5bb9\u91cf\uff0c\u5355\u4f4d\u4e3a K tokens\u3002',
77
78
  contextRestore: '\u6062\u590d\u6a21\u578b\u9ed8\u8ba4\u503c',
78
79
  promptCardTitle: 'Codex Harness',
79
- promptCardDescription: '\u9009\u62e9 Codex \u80fd\u529b\u5e76\u81ea\u5b9a\u4e49\u5b8c\u6574\u7684\u64cd\u4f5c\u63d0\u793a\u8bcd\u3002',
80
- codexOnlyCapabilitiesLabel: '\u4ec5\u5728 Codex \u6a21\u5f0f\u4e0b',
81
- otherCapabilitiesLabel: '\u5176\u4ed6\u80fd\u529b',
80
+ promptCardDescription: '\u7f16\u8f91\u9884\u8bbe\u3001Codex \u80fd\u529b\u548c\u64cd\u4f5c\u63d0\u793a\u8bcd\uff0c\u6d3b\u52a8\u72b6\u6001\u662f\u5168\u5c40\u8bbe\u7f6e\u3002',
81
+ otherCapabilitiesLabel: '\u5168\u5c40\u80fd\u529b',
82
82
  capabilityPrompt: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
83
83
  capabilityPromptHint: '\u6ce8\u5165\u53ef\u7f16\u8f91\u6307\u4ee4\uff0c\u5e76\u5c06 Persona \u653e\u5728\u63d0\u793a\u8bcd\u9996\u4f4d\u3002',
84
- capabilityFast: '\u663e\u793a Fast \u6a21\u5f0f',
85
- capabilityFastHint: '\u5728\u5bf9\u8bdd\u8f93\u5165\u533a\u65c1\u663e\u793a Fast \u5f00\u5173\u3002',
86
84
  compactRemote: '\u8fdc\u7a0b\u538b\u7f29',
87
85
  compactRemoteHint: '\u4f18\u5148\u4f7f\u7528\u63d0\u4f9b\u5546\u7684\u8fdc\u7a0b\u538b\u7f29\u7aef\u70b9\u3002',
88
86
  compactLocal: '\u672c\u5730\u538b\u7f29',
@@ -101,19 +99,19 @@ const zh = {
101
99
  capabilityActivityHint: '\u5728\u5bf9\u8bdd\u65c1\u663e\u793a\u8bf7\u6c42\u3001\u56de\u590d\u548c\u538b\u7f29\u72b6\u6001\u3002',
102
100
  promptCustomizationLabel: '\u63d0\u793a\u8bcd\u5b9a\u5236',
103
101
  personaLabel: 'Persona',
104
- personaHint: '\u5b9a\u4e49 Agent \u7684\u8eab\u4efd\u4e0e\u89d2\u8272\uff0c\u652f\u6301 {{model}} \u548c {{cwd}}\u3002',
102
+ personaHint: '\u5b9a\u4e49 Agent \u7684\u8eab\u4efd\u4e0e\u89d2\u8272,\u652f\u6301 {{model}} \u548c {{cwd}}。',
105
103
  sourcePromptLabel: 'DSH Core \u6e90\u7801\u8bf4\u660e',
106
- sourcePromptHint: '\u8bf4\u660e DSH \u6e90\u7801\u68c0\u51fa\u76ee\u5f55\u4e0e\u5de5\u4f5c\u76ee\u5f55\uff0c\u652f\u6301 {{sourceRoot}}\u3002',
104
+ sourcePromptHint: '\u8bf4\u660e DSH \u6e90\u7801\u68c0\u51fa\u76ee\u5f55\u4e0e\u5de5\u4f5c\u76ee\u5f55,\u652f\u6301 {{sourceRoot}}。',
107
105
  webPromptLabel: 'DSH Core Web \u8bf4\u660e',
108
- webPromptHint: '\u8bf4\u660e Web GUI\u3001HMR\u3001\u6784\u5efa\u4e0e\u9a8c\u8bc1\uff0c\u652f\u6301 {{webUrl}}\u3002',
106
+ webPromptHint: '\u8bf4\u660e Web GUI、HMR、\u6784\u5efa\u4e0e\u9a8c\u8bc1,\u652f\u6301 {{webUrl}}。',
109
107
  promptRestoreAll: '\u6062\u590d\u6240\u6709\u63d0\u793a\u8bcd\u9ed8\u8ba4\u503c',
110
108
  promptLabel: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
111
- promptHint: '\u8fd9\u662f Codex \u64cd\u4f5c\u63d0\u793a\u8bcd\u3002Persona \u548c DSH Core \u8bf4\u660e\u5728\u4e0a\u65b9\u5206\u522b\u7f16\u8f91\u3002',
109
+ promptHint: '\u8fd9\u662f Codex \u64cd\u4f5c\u63d0\u793a\u8bcd。Persona \u548c DSH Core \u8bf4\u660e\u5728\u4e0a\u65b9\u5206\u522b\u7f16\u8f91。',
112
110
  promptUnsaved: '\u672a\u4fdd\u5b58',
113
111
  promptDiscard: '\u653e\u5f03',
114
112
  promptSave: '\u4fdd\u5b58',
115
113
  promptSaving: '\u4fdd\u5b58\u4e2d...',
116
- promptSaveFailed: '\u63d0\u793a\u8bcd\u4fdd\u5b58\u5931\u8d25\u3002',
114
+ promptSaveFailed: '\u63d0\u793a\u8bcd\u4fdd\u5b58\u5931\u8d25。',
117
115
  promptExpand: '\u5c55\u5f00\u8bbe\u7f6e',
118
116
  promptCollapse: '\u6536\u8d77\u8bbe\u7f6e',
119
117
  promptReadOnly: '\u5f53\u524d\u8bbe\u7f6e\u6587\u4ef6\u4e3a\u53ea\u8bfb\u3002',
@@ -130,207 +128,14 @@ function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting, }
130
128
  cursor: disabled ? 'default' : 'pointer',
131
129
  }, children: [_jsxs("span", { style: { flex: 1, minWidth: 0, display: 'grid', gap: 2 }, children: [_jsx("strong", { style: { fontSize: 13, fontWeight: 500 }, children: label }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 12, lineHeight: 1.45 }, children: hint })] }), _jsx("input", { type: "checkbox", role: "switch", checked: enabled, disabled: disabled, "aria-label": label, onChange: event => { void setSetting(field, event.target.checked); }, style: { marginTop: 3, accentColor: 'var(--dsw-static-blue-500)' } })] }));
132
130
  }
133
- /** Visually separate capability scope while keeping the host's light settings style. */
134
- function CapabilityGroup({ id, label, children, accent }) {
135
- const [open, setOpen] = useState(false);
136
- const panelId = `${id}-panel`;
137
- return (_jsxs("section", { style: {
138
- display: 'grid',
139
- gap: open ? 4 : 0,
140
- }, children: [_jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": panelId, onClick: () => { setOpen(!open); }, style: {
141
- display: 'flex',
142
- alignItems: 'center',
143
- gap: 7,
144
- width: '100%',
145
- padding: 0,
146
- border: 0,
147
- background: 'none',
148
- color: 'var(--dsw-alias-label-secondary)',
149
- font: 'inherit',
150
- textAlign: 'left',
151
- cursor: 'pointer',
152
- }, children: [_jsx("span", { "aria-hidden": "true", style: {
153
- width: 6,
154
- height: 6,
155
- flex: '0 0 auto',
156
- borderRadius: 999,
157
- background: accent,
158
- } }), _jsx("strong", { style: {
159
- color: 'var(--dsw-alias-label-secondary)',
160
- fontSize: 14,
161
- fontWeight: 600,
162
- letterSpacing: '0.01em',
163
- }, children: label }), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsx("div", { id: panelId, style: {
164
- display: 'grid',
165
- marginLeft: 5,
166
- paddingLeft: 12,
167
- }, children: children }))] }));
168
- }
169
- function PromptEditor({ id, label, hint, value, writable, saving, minHeight, onChange, }) {
170
- const [open, setOpen] = useState(false);
171
- const labelId = `${id}-label`;
172
- const panelId = `${id}-panel`;
173
- return (_jsxs("div", { style: { display: 'grid', gap: open ? 8 : 0 }, children: [_jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": panelId, onClick: () => { setOpen(!open); }, style: {
174
- display: 'flex',
175
- alignItems: 'center',
176
- gap: 8,
177
- width: '100%',
178
- padding: 0,
179
- border: 0,
180
- background: 'none',
181
- color: 'var(--dsw-alias-label-primary)',
182
- font: 'inherit',
183
- fontSize: 13,
184
- fontWeight: 500,
185
- textAlign: 'left',
186
- cursor: 'pointer',
187
- }, children: [_jsx("span", { id: labelId, style: { flex: 1 }, children: label }), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsxs("div", { id: panelId, style: { display: 'grid', gap: 5 }, children: [_jsx("textarea", { id: id, "aria-labelledby": labelId, value: value, disabled: !writable || saving, onChange: event => { onChange(event.target.value); }, spellCheck: false, style: {
188
- boxSizing: 'border-box',
189
- width: '100%',
190
- minHeight,
191
- resize: 'vertical',
192
- padding: 10,
193
- border: '1px solid var(--dsw-alias-border-l2)',
194
- borderRadius: 8,
195
- background: 'var(--dsw-alias-bg-layer-3)',
196
- color: 'var(--dsw-alias-label-primary)',
197
- font: 'inherit',
198
- fontSize: 12,
199
- lineHeight: 1.5,
200
- } }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11, lineHeight: 1.45 }, children: hint })] }))] }));
201
- }
202
- /** Full-prompt editor contributed to Settings > Plugins. */
131
+ /** One editor per preset; only display preferences are global. */
203
132
  export function PromptSettingsCard(props) {
204
- const { useSettings, setSetting, t } = props;
133
+ const { useSettings, setSetting, presetManager, t } = props;
205
134
  const snapshot = useSettings(state => state);
206
- const currentPersona = snapshot.value?.persona ?? DEFAULT_CODEX_PERSONA;
207
- const currentSourcePrompt = snapshot.value?.harnessSourcePrompt ?? DEFAULT_DSH_CORE_SOURCE_PROMPT;
208
- const currentWebPrompt = snapshot.value?.webSurfacePrompt ?? DEFAULT_DSH_CORE_WEB_PROMPT;
209
- const current = snapshot.value?.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
210
- const codexOnlyCapabilities = [
211
- { field: 'fastModeControlEnabled', label: 'capabilityFast', hint: 'capabilityFastHint' },
212
- { field: 'promptEnabled', label: 'capabilityPrompt', hint: 'capabilityPromptHint' },
213
- { field: 'terminalToolsEnabled', label: 'capabilityTerminal', hint: 'capabilityTerminalHint' },
214
- { field: 'patchToolEnabled', label: 'capabilityPatch', hint: 'capabilityPatchHint' },
215
- { field: 'planToolEnabled', label: 'capabilityPlan', hint: 'capabilityPlanHint' },
216
- ];
217
- const otherCapabilities = [
218
- { field: 'hostedWebSearchEnabled', label: 'capabilityWebSearch', hint: 'capabilityWebSearchHint' },
219
- { field: 'remoteCompactionEnabled', label: 'capabilityCompaction', hint: 'capabilityCompactionHint' },
220
- { field: 'activityIndicatorEnabled', label: 'capabilityActivity', hint: 'capabilityActivityHint' },
221
- ];
222
135
  const [open, setOpen] = useState(false);
223
- const [personaDraft, setPersonaDraft] = useState(currentPersona);
224
- const [sourcePromptDraft, setSourcePromptDraft] = useState(currentSourcePrompt);
225
- const [webPromptDraft, setWebPromptDraft] = useState(currentWebPrompt);
226
- const [draft, setDraft] = useState(current);
227
- const [saving, setSaving] = useState(false);
228
- const [failed, setFailed] = useState(false);
229
- useEffect(() => {
230
- setPersonaDraft(currentPersona);
231
- setSourcePromptDraft(currentSourcePrompt);
232
- setWebPromptDraft(currentWebPrompt);
233
- setDraft(current);
234
- }, [current, currentPersona, currentSourcePrompt, currentWebPrompt]);
235
136
  if (snapshot.status === 'unavailable')
236
137
  return null;
237
- const dirty = personaDraft !== currentPersona
238
- || sourcePromptDraft !== currentSourcePrompt
239
- || webPromptDraft !== currentWebPrompt
240
- || draft !== current;
241
- const canRestore = dirty
242
- || currentPersona !== DEFAULT_CODEX_PERSONA
243
- || currentSourcePrompt !== DEFAULT_DSH_CORE_SOURCE_PROMPT
244
- || currentWebPrompt !== DEFAULT_DSH_CORE_WEB_PROMPT
245
- || current !== DEFAULT_CODEX_SYSTEM_PROMPT;
246
- const renderCapability = (capability) => (_jsx(CapabilityToggle, { field: capability.field, label: t(capability.label), hint: t(capability.hint), enabled: snapshot.value?.[capability.field] ?? true, disabled: !snapshot.writable || saving, setSetting: setSetting }, capability.field));
247
- const save = async () => {
248
- setSaving(true);
249
- setFailed(false);
250
- try {
251
- await Promise.all([
252
- setSetting('persona', personaDraft),
253
- setSetting('harnessSourcePrompt', sourcePromptDraft),
254
- setSetting('webSurfacePrompt', webPromptDraft),
255
- setSetting('systemPrompt', draft),
256
- ]);
257
- }
258
- catch {
259
- setFailed(true);
260
- }
261
- finally {
262
- setSaving(false);
263
- }
264
- };
265
- const reset = async () => {
266
- setSaving(true);
267
- setFailed(false);
268
- setPersonaDraft(DEFAULT_CODEX_PERSONA);
269
- setSourcePromptDraft(DEFAULT_DSH_CORE_SOURCE_PROMPT);
270
- setWebPromptDraft(DEFAULT_DSH_CORE_WEB_PROMPT);
271
- setDraft(DEFAULT_CODEX_SYSTEM_PROMPT);
272
- try {
273
- await Promise.all([
274
- setSetting('persona', DEFAULT_CODEX_PERSONA),
275
- setSetting('harnessSourcePrompt', DEFAULT_DSH_CORE_SOURCE_PROMPT),
276
- setSetting('webSurfacePrompt', DEFAULT_DSH_CORE_WEB_PROMPT),
277
- setSetting('systemPrompt', DEFAULT_CODEX_SYSTEM_PROMPT),
278
- ]);
279
- }
280
- catch {
281
- setFailed(true);
282
- setPersonaDraft(currentPersona);
283
- setSourcePromptDraft(currentSourcePrompt);
284
- setWebPromptDraft(currentWebPrompt);
285
- setDraft(current);
286
- }
287
- finally {
288
- setSaving(false);
289
- }
290
- };
291
- return (_jsxs("li", { style: {
292
- listStyle: 'none',
293
- border: '1px solid var(--dsw-alias-border-l2)',
294
- borderRadius: 12,
295
- background: open ? 'var(--dsw-alias-bg-layer-2)' : 'var(--dsw-alias-bg-layer-3)',
296
- overflow: 'hidden',
297
- }, children: [_jsxs("button", { type: "button", "aria-expanded": open, "aria-label": `${t(open ? 'promptCollapse' : 'promptExpand')}: ${t('promptCardTitle')}`, onClick: () => { setOpen(!open); }, style: {
298
- width: '100%',
299
- border: 0,
300
- background: 'none',
301
- color: 'inherit',
302
- padding: '14px 16px',
303
- display: 'flex',
304
- alignItems: 'center',
305
- gap: 12,
306
- textAlign: 'left',
307
- cursor: 'pointer',
308
- font: 'inherit',
309
- }, children: [_jsxs("span", { style: { flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 4 }, children: [_jsx("strong", { style: { fontSize: 15, lineHeight: 1.4 }, children: t('promptCardTitle') }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 13, lineHeight: 1.5 }, children: t('promptCardDescription') })] }), dirty && (_jsx("span", { style: {
310
- borderRadius: 999,
311
- padding: '1px 8px',
312
- background: 'var(--dsw-alias-bg-module-platform)',
313
- color: 'var(--dsw-alias-label-secondary)',
314
- fontSize: 11,
315
- }, children: t('promptUnsaved') })), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsxs("div", { style: { borderTop: '1px solid var(--dsw-alias-border-l2)', margin: '0 16px', padding: '12px 0' }, children: [!snapshot.writable && (_jsx("p", { style: { margin: '0 0 10px', color: 'var(--dsw-alias-label-tertiary)', fontSize: 12 }, children: t('promptReadOnly') })), _jsxs("div", { style: { display: 'grid', gap: 16, marginBottom: 14 }, children: [_jsx(CapabilityGroup, { id: "codex-only-capabilities", label: t('codexOnlyCapabilitiesLabel'), accent: "var(--dsw-static-blue-500)", children: codexOnlyCapabilities.map(renderCapability) }), _jsx(CapabilityGroup, { id: "other-capabilities", label: t('otherCapabilitiesLabel'), accent: "var(--dsw-alias-label-tertiary)", children: otherCapabilities.map(renderCapability) })] }), _jsxs("div", { style: {
316
- display: 'grid',
317
- gap: 14,
318
- paddingTop: 12,
319
- borderTop: '1px solid var(--dsw-alias-border-l2)',
320
- }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8 }, children: [_jsx("strong", { style: { flex: 1, fontSize: 13 }, children: t('promptCustomizationLabel') }), _jsx("button", { type: "button", disabled: !snapshot.writable || saving || !canRestore, onClick: () => { void reset(); }, style: { border: 0, padding: 0, background: 'none', color: 'var(--dsw-alias-label-secondary)', font: 'inherit', fontSize: 11, cursor: 'pointer' }, children: t('promptRestoreAll') })] }), _jsx(PromptEditor, { id: "codex-persona", label: t('personaLabel'), hint: t('personaHint'), value: personaDraft, writable: snapshot.writable, saving: saving, minHeight: 84, onChange: setPersonaDraft }), _jsx(PromptEditor, { id: "codex-harness-source-prompt", label: t('sourcePromptLabel'), hint: t('sourcePromptHint'), value: sourcePromptDraft, writable: snapshot.writable, saving: saving, minHeight: 100, onChange: setSourcePromptDraft }), _jsx(PromptEditor, { id: "codex-web-surface-prompt", label: t('webPromptLabel'), hint: t('webPromptHint'), value: webPromptDraft, writable: snapshot.writable, saving: saving, minHeight: 120, onChange: setWebPromptDraft }), _jsx(PromptEditor, { id: "codex-system-prompt", label: t('promptLabel'), hint: t('promptHint'), value: draft, writable: snapshot.writable, saving: saving, minHeight: 320, onChange: setDraft })] }), _jsxs("div", { style: {
321
- display: 'flex',
322
- justifyContent: 'flex-end',
323
- alignItems: 'center',
324
- gap: 8,
325
- paddingTop: 12,
326
- borderTop: '1px solid var(--dsw-alias-border-l2)',
327
- }, children: [failed && (_jsx("span", { role: "status", style: { flex: 1, color: 'var(--dsw-alias-label-error)', fontSize: 12 }, children: t('promptSaveFailed') })), _jsx("button", { type: "button", disabled: !dirty || saving, onClick: () => {
328
- setPersonaDraft(currentPersona);
329
- setSourcePromptDraft(currentSourcePrompt);
330
- setWebPromptDraft(currentWebPrompt);
331
- setDraft(current);
332
- setFailed(false);
333
- }, style: { border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8, background: 'none', color: 'inherit', padding: '5px 14px', font: 'inherit', cursor: 'pointer' }, children: t('promptDiscard') }), _jsx("button", { type: "button", disabled: !snapshot.writable || !dirty || saving, onClick: () => { void save(); }, style: { border: 0, borderRadius: 8, background: 'var(--dsw-alias-label-primary)', color: 'var(--dsw-alias-bg-layer-3)', padding: '6px 14px', font: 'inherit', cursor: 'pointer' }, children: saving ? t('promptSaving') : t('promptSave') })] })] }))] }));
138
+ return _jsxs("li", { style: { listStyle: 'none', border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 12, overflow: 'hidden' }, children: [_jsxs("button", { type: "button", "aria-expanded": open, onClick: () => setOpen(!open), style: { width: '100%', padding: 16, textAlign: 'left', border: 0, background: 'none', color: 'inherit', cursor: 'pointer' }, children: [_jsx("strong", { children: t('promptCardTitle') }), _jsx("span", { style: { float: 'right' }, children: open ? '−' : '+' }), _jsx("p", { style: { marginBottom: 0 }, children: t('promptCardDescription') })] }), open && _jsxs("div", { style: { padding: 16, borderTop: '1px solid var(--dsw-alias-border-l2)' }, children: [_jsx(PresetManagerCard, { presetManager: presetManager, t: t }), _jsxs("details", { style: { marginTop: 22, borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: 14 }, children: [_jsx("summary", { style: { cursor: 'pointer', fontWeight: 600 }, children: t('pmGlobalSettings') }), _jsx(CapabilityToggle, { field: "activityIndicatorEnabled", label: t('capabilityActivity'), hint: t('capabilityActivityHint'), enabled: snapshot.value?.activityIndicatorEnabled ?? true, disabled: !snapshot.writable, setSetting: setSetting })] })] })] });
334
139
  }
335
140
  /** The legacy composer seat is a compact inline row, not a menu panel. */
336
141
  function FastModeFallback(props) {
@@ -673,7 +478,50 @@ function LegacyOverlay(props) {
673
478
  const contextWindow = contextWindowFromProjection(useProjection);
674
479
  return (_jsxs(_Fragment, { children: [contextDialog !== null && createPortal(_jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }), contextDialog, 'codex-context-size'), turnStatusPosition !== null && typeof document !== 'undefined' && document.body !== null && createPortal(_jsx(ActivityLine, { sessionId: sessionId, useSession: useSession, useSessions: useSessions, useProjection: useProjection, useSettings: useSettings, t: t, position: turnStatusPosition }), document.body, 'codex-activity')] }));
675
480
  }
676
- export const inject = ['commandUi', 'sessions', 'slots', 'locale', 'settingsScope'];
481
+ export const inject = [
482
+ 'commandUi', 'sessions', 'slots', 'locale', 'settingsScope',
483
+ 'remote', 'remote.agentPresets', 'remote.settings',
484
+ ];
485
+ function createPresetManager(ctx) {
486
+ const remote = ctx.remote;
487
+ const ready = remote === undefined
488
+ ? Promise.resolve()
489
+ : remote.$mount(presetEditorRemote).then(dispose => {
490
+ ctx.effect(() => () => { void dispose(); }, 'codex client: preset editor remote');
491
+ });
492
+ // Keep an unavailable optional host remote from becoming an unhandled rejection
493
+ // when the settings card is never opened. The card still awaits the same promise
494
+ // and renders the actual error if the user opens it.
495
+ void ready.catch(() => { });
496
+ return {
497
+ remote: remote,
498
+ ready,
499
+ };
500
+ }
501
+ /**
502
+ * The Codex editor contribution is mounted by this client entry itself. Its
503
+ * namespace therefore cannot be a top-level dependency (that would make the
504
+ * entry wait for the contribution it is responsible for mounting). Wait for
505
+ * the namespace in a child fiber instead, and capture that protected Remote
506
+ * face for the settings card.
507
+ */
508
+ function registerPresetSettingsCard(ctx, settings, presetManager) {
509
+ const settingsPresetManager = {
510
+ ...presetManager,
511
+ remote: ctx.remote,
512
+ };
513
+ return ctx.slots.inject(PLUGIN_SETTINGS_SLOT, () => ctx.slots.register({
514
+ name: PLUGIN_SETTINGS_SLOT,
515
+ key: SETTINGS_NAMESPACE,
516
+ locale: NS,
517
+ inject: () => ({
518
+ hooks: { settings },
519
+ setSetting: (field, value) => settings.set(field, value),
520
+ unsetSetting: (field) => settings.unset(field),
521
+ presetManager: settingsPresetManager,
522
+ }),
523
+ }, PromptSettingsCard));
524
+ }
677
525
  /** Mount request controls and the plugin settings card through shared slots. */
678
526
  export function apply(ctx) {
679
527
  ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'codex client: dictionaries');
@@ -703,10 +551,12 @@ export function apply(ctx) {
703
551
  },
704
552
  }), 'codex client: /compact mode picker');
705
553
  const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
554
+ const presetManager = createPresetManager(ctx);
706
555
  const injected = () => ({
707
556
  hooks: { settings },
708
557
  setSetting: (field, value) => settings.set(field, value),
709
558
  unsetSetting: (field) => settings.unset(field),
559
+ presetManager,
710
560
  });
711
561
  ctx.slots.inject(FAST_FALLBACK_SLOT, () => ctx.slots.register({
712
562
  name: FAST_FALLBACK_SLOT,
@@ -729,12 +579,10 @@ export function apply(ctx) {
729
579
  locale: NS,
730
580
  inject: injected,
731
581
  }, LegacyOverlay));
732
- ctx.slots.inject(PLUGIN_SETTINGS_SLOT, () => ctx.slots.register({
733
- name: PLUGIN_SETTINGS_SLOT,
734
- key: SETTINGS_NAMESPACE,
735
- locale: NS,
736
- inject: injected,
737
- }, PromptSettingsCard));
582
+ // `codexPresetEditor` is mounted by createPresetManager above. Keep its
583
+ // namespace dependency local to the settings card so the main client entry
584
+ // can start and perform that mount first.
585
+ ctx.inject(['remote', 'remote.agentPresets', 'remote.settings', 'remote.codexPresetEditor'], settingsCtx => registerPresetSettingsCard(settingsCtx, settings, presetManager));
738
586
  }
739
587
  export default { inject, apply };
740
588
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,42 @@
1
+ export declare const presetEn: {
2
+ readonly peConnectionError: "Could not connect to the local service. Retry loading; if the connection still fails, reconnect the page.";
3
+ readonly peReadError: "Could not read this preset. Retry loading or refresh the preset list.";
4
+ readonly peRetryRead: "Retry loading";
5
+ readonly peReconnect: "Reconnect page";
6
+ readonly peSystemPrompt: "System prompt sections";
7
+ readonly peSectionsHint: "These templates contribute to this preset’s system prompt before the tools. Runtime variables, workspace instructions and plugin-provided guidance are assembled when the conversation runs.";
8
+ readonly peDynamicPrompt: "This field is an expression; it is preserved without executing it in the editor.";
9
+ readonly peDshSourcePrompt: "Tells the agent where the DSH source checkout is and keeps it separate from the current workspace. It is used when inspecting or extending DSH itself.";
10
+ readonly peDshWebPrompt: "Tells the agent which Web page it is talking through, what “this page” means, and when Web changes need a rebuild or refresh.";
11
+ readonly peSuppressed: "Not used";
12
+ readonly peCompletePersona: "This preset uses Persona as its entire system prompt, so this section is excluded.";
13
+ readonly peLoading: "Reading preset…";
14
+ readonly peTitle: "Preset editor";
15
+ readonly peHierarchy: "Codex mode and other presets are peers. Choose one to edit, or make an editable copy of a built-in preset first.";
16
+ readonly peSelect: "Preset";
17
+ readonly peSelectPlaceholder: "Choose a preset…";
18
+ readonly peEditable: "This is an editable user preset.";
19
+ readonly peBuiltinEdit: "Built-in presets are read-only. Create a copy to edit it.";
20
+ readonly peCreateCopy: "Create editable copy";
21
+ readonly peCodexSection: "Codex mode capabilities";
22
+ readonly peAddCodex: "Add Codex capabilities to this preset";
23
+ readonly peAddCodexHint: "Adds the Codex prompt, tools, hosted search, and remote compaction to this preset.";
24
+ readonly peActivityGlobal: "Activity status is a global display setting and is shared by all presets.";
25
+ readonly peSaveCopy: "Save new preset";
26
+ readonly peSaved: "Saved. Select this preset in a new conversation.";
27
+ readonly pmGlobalSettings: "Global settings";
28
+ readonly pmRefresh: "Refresh";
29
+ readonly pmBuiltIn: "Built-in";
30
+ readonly pmCustom: "Custom";
31
+ readonly pmDiscard: "Discard your unsaved changes?";
32
+ readonly pmConflict: "This preset changed in another page or on disk. Reopen the latest version before saving.";
33
+ readonly pmYamlError: "The configuration must be valid YAML. Your draft has not been saved.";
34
+ readonly pmErrorDetails: "Technical details";
35
+ readonly pmSaveError: "Could not complete this action. Your draft is still here.";
36
+ readonly pmName: "Name";
37
+ readonly pmDescription: "Description";
38
+ readonly pmCancel: "Cancel";
39
+ readonly pmSave: "Save changes";
40
+ };
41
+ export declare const presetZh: Record<keyof typeof presetEn, string>;
42
+ //# sourceMappingURL=preset-copy.d.ts.map