@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/README.md +9 -3
- package/docs/preset-library.md +23 -0
- package/lib/client.js +4748 -557
- package/lib/index.js +624 -5
- package/lib/typert.js +117 -0
- package/lib/types/client/index.d.ts +43 -6
- package/lib/types/client/index.js +67 -219
- package/lib/types/client/preset-copy.d.ts +42 -0
- package/lib/types/client/preset-copy.js +81 -0
- package/lib/types/client/preset-manager.d.ts +22 -0
- package/lib/types/client/preset-manager.js +217 -0
- package/lib/types/client/preset-requests.d.ts +4 -0
- package/lib/types/client/preset-requests.js +19 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.js +47 -2
- package/lib/types/preset-contract.d.ts +69 -0
- package/lib/types/preset-contract.js +22 -0
- package/lib/types/preset-editor-remote.d.ts +30 -0
- package/lib/types/preset-editor-remote.js +37 -0
- package/lib/types/preset-editor.d.ts +69 -0
- package/lib/types/preset-editor.js +546 -0
- package/lib/types/preset-templates.d.ts +36 -0
- package/lib/types/preset-templates.js +12 -0
- package/lib/types/prompt-sections.d.ts +15 -0
- package/lib/types/prompt-sections.js +23 -0
- package/lib/types/typert.host.d.ts +47 -0
- package/lib/types/typert.host.js +99 -0
- package/package.json +296 -266
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const presetEn = {
|
|
2
|
+
peConnectionError: 'Could not connect to the local service. Retry loading; if the connection still fails, reconnect the page.',
|
|
3
|
+
peReadError: 'Could not read this preset. Retry loading or refresh the preset list.',
|
|
4
|
+
peRetryRead: 'Retry loading',
|
|
5
|
+
peReconnect: 'Reconnect page',
|
|
6
|
+
peSystemPrompt: 'System prompt sections',
|
|
7
|
+
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
|
+
peDynamicPrompt: 'This field is an expression; it is preserved without executing it in the editor.',
|
|
9
|
+
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
|
+
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
|
+
peSuppressed: 'Not used',
|
|
12
|
+
peCompletePersona: 'This preset uses Persona as its entire system prompt, so this section is excluded.',
|
|
13
|
+
peLoading: 'Reading preset…',
|
|
14
|
+
peTitle: 'Preset editor',
|
|
15
|
+
peHierarchy: 'Codex mode and other presets are peers. Choose one to edit, or make an editable copy of a built-in preset first.',
|
|
16
|
+
peSelect: 'Preset',
|
|
17
|
+
peSelectPlaceholder: 'Choose a preset…',
|
|
18
|
+
peEditable: 'This is an editable user preset.',
|
|
19
|
+
peBuiltinEdit: 'Built-in presets are read-only. Create a copy to edit it.',
|
|
20
|
+
peCreateCopy: 'Create editable copy',
|
|
21
|
+
peCodexSection: 'Codex mode capabilities',
|
|
22
|
+
peAddCodex: 'Add Codex capabilities to this preset',
|
|
23
|
+
peAddCodexHint: 'Adds the Codex prompt, tools, hosted search, and remote compaction to this preset.',
|
|
24
|
+
peActivityGlobal: 'Activity status is a global display setting and is shared by all presets.',
|
|
25
|
+
peSaveCopy: 'Save new preset',
|
|
26
|
+
peSaved: 'Saved. Select this preset in a new conversation.',
|
|
27
|
+
pmGlobalSettings: 'Global settings',
|
|
28
|
+
pmRefresh: 'Refresh',
|
|
29
|
+
pmBuiltIn: 'Built-in',
|
|
30
|
+
pmCustom: 'Custom',
|
|
31
|
+
pmDiscard: 'Discard your unsaved changes?',
|
|
32
|
+
pmConflict: 'This preset changed in another page or on disk. Reopen the latest version before saving.',
|
|
33
|
+
pmYamlError: 'The configuration must be valid YAML. Your draft has not been saved.',
|
|
34
|
+
pmErrorDetails: 'Technical details',
|
|
35
|
+
pmSaveError: 'Could not complete this action. Your draft is still here.',
|
|
36
|
+
pmName: 'Name',
|
|
37
|
+
pmDescription: 'Description',
|
|
38
|
+
pmCancel: 'Cancel',
|
|
39
|
+
pmSave: 'Save changes',
|
|
40
|
+
};
|
|
41
|
+
export const presetZh = {
|
|
42
|
+
peConnectionError: '未能连接本地服务。请重试读取;如果仍然失败,请重新连接页面。',
|
|
43
|
+
peReadError: '无法读取这个预设,请重试读取或刷新预设列表。',
|
|
44
|
+
peRetryRead: '重试读取',
|
|
45
|
+
peReconnect: '重新连接页面',
|
|
46
|
+
peSystemPrompt: '系统提示词',
|
|
47
|
+
peSectionsHint: '这些模板共同组成当前预设在工具之前的系统提示词。运行时变量、工作区指令和插件提供的说明会在会话中组装。',
|
|
48
|
+
peDynamicPrompt: '此字段是动态表达式,编辑器保留原值,不执行表达式。',
|
|
49
|
+
peDshSourcePrompt: '告诉 Agent DSH 源码检出目录在哪里,并与当前工作区区分开;用于检查或扩展 DSH 本身。',
|
|
50
|
+
peDshWebPrompt: '告诉 Agent 当前通过哪个 Web 页面交互、“这个页面”指什么,以及 Web 修改何时需要重建或刷新。',
|
|
51
|
+
peSuppressed: '未使用',
|
|
52
|
+
peCompletePersona: '此预设将 Persona 作为完整系统提示词,因此不使用这一段。',
|
|
53
|
+
peLoading: '正在读取预设…',
|
|
54
|
+
peTitle: '预设编辑',
|
|
55
|
+
peHierarchy: 'Codex 模式和其它预设处于同一级。选择一个预设编辑;内置预设先创建可编辑副本。',
|
|
56
|
+
peSelect: '选择预设',
|
|
57
|
+
peSelectPlaceholder: '选择一个预设…',
|
|
58
|
+
peEditable: '这是可编辑的用户预设。',
|
|
59
|
+
peBuiltinEdit: '内置预设只读,需要先创建副本。',
|
|
60
|
+
peCreateCopy: '创建可编辑副本',
|
|
61
|
+
peCodexSection: 'Codex 模式能力',
|
|
62
|
+
peAddCodex: '为这个预设加入 Codex 能力',
|
|
63
|
+
peAddCodexHint: '加入 Codex 提示词、工具、托管搜索和远程上下文压缩。',
|
|
64
|
+
peActivityGlobal: '活动状态是全局显示设置,由所有预设共享。',
|
|
65
|
+
peSaveCopy: '保存新预设',
|
|
66
|
+
peSaved: '已保存,在新会话中选择此预设即可使用。',
|
|
67
|
+
pmGlobalSettings: '全局设置',
|
|
68
|
+
pmRefresh: '刷新',
|
|
69
|
+
pmBuiltIn: '内置',
|
|
70
|
+
pmCustom: '自定义',
|
|
71
|
+
pmDiscard: '放弃尚未保存的修改?',
|
|
72
|
+
pmConflict: '此预设已被其他页面或文件修改,请重新打开最新版本后再保存。',
|
|
73
|
+
pmYamlError: '配置必须是有效 YAML,草稿尚未保存。',
|
|
74
|
+
pmErrorDetails: '技术详情',
|
|
75
|
+
pmSaveError: '操作未完成,填写的内容仍然保留。',
|
|
76
|
+
pmName: '名称',
|
|
77
|
+
pmDescription: '用途说明',
|
|
78
|
+
pmCancel: '取消',
|
|
79
|
+
pmSave: '保存修改',
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=preset-copy.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
2
|
+
import type { RemoteResult, TypertClientRemote } from '@deepseek-ai/dsh-typert-protocol';
|
|
3
|
+
import type { PresetCatalog, PresetCreateInput, PresetEditorDocument, PresetEditorInput } from '../preset-contract.ts';
|
|
4
|
+
export interface PresetClientRemote extends TypertClientRemote {
|
|
5
|
+
codexPresetEditor: {
|
|
6
|
+
catalog(): Promise<RemoteResult<PresetCatalog>>;
|
|
7
|
+
read(id: string): Promise<RemoteResult<PresetEditorDocument>>;
|
|
8
|
+
update(input: PresetEditorInput): Promise<RemoteResult<PresetEditorDocument>>;
|
|
9
|
+
create(input: PresetCreateInput): Promise<RemoteResult<PresetEditorDocument>>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface PresetManagerActions {
|
|
13
|
+
remote: PresetClientRemote;
|
|
14
|
+
ready: Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
type Props = InjectFace<{
|
|
17
|
+
presetManager: PresetManagerActions;
|
|
18
|
+
}> & PropsLocale<'codex'>;
|
|
19
|
+
/** Presets are peers: choose one to edit, or make an editable copy first. */
|
|
20
|
+
export declare function PresetManagerCard({ presetManager, t }: Props): import("react").JSX.Element;
|
|
21
|
+
export default PresetManagerCard;
|
|
22
|
+
//# sourceMappingURL=preset-manager.d.ts.map
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { DEFAULT_CODEX_SYSTEM_PROMPT } from "../prompt.js";
|
|
4
|
+
import { isPresetConnectionError, readPresetWithRetry } from "./preset-requests.js";
|
|
5
|
+
const catalogCache = new WeakMap();
|
|
6
|
+
const documentCache = new WeakMap();
|
|
7
|
+
const CODEX_DEFAULT_ID = 'codex-collaboration';
|
|
8
|
+
function unwrap(result) {
|
|
9
|
+
if (result.ok)
|
|
10
|
+
return result.value;
|
|
11
|
+
throw new Error(result.error.message ?? 'remote-request-failed');
|
|
12
|
+
}
|
|
13
|
+
function equalEditorState(a, b) {
|
|
14
|
+
if (!a || !b)
|
|
15
|
+
return a === b;
|
|
16
|
+
return a.name === b.name && a.description === b.description && a.systemPrompt === b.systemPrompt
|
|
17
|
+
&& a.inheritPrompt === b.inheritPrompt && a.codex === b.codex
|
|
18
|
+
&& JSON.stringify(a.codexOptions) === JSON.stringify(b.codexOptions)
|
|
19
|
+
&& JSON.stringify(a.promptSections) === JSON.stringify(b.promptSections);
|
|
20
|
+
}
|
|
21
|
+
const styles = `
|
|
22
|
+
.codex-preset-editor { display:grid; gap:12px; min-width:0; font-size:13px; }
|
|
23
|
+
.codex-preset-editor label { display:grid; gap:6px; }
|
|
24
|
+
.codex-preset-editor .pe-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
|
|
25
|
+
.codex-preset-editor input:not([type=checkbox]), .codex-preset-editor textarea, .codex-preset-editor select { box-sizing:border-box; width:100%; padding:8px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; background:var(--dsw-alias-bg-layer-3); color:inherit; font:inherit; }
|
|
26
|
+
.codex-preset-editor textarea { resize:vertical; line-height:1.5; }
|
|
27
|
+
.codex-preset-editor button { font:inherit; padding:6px 12px; border:1px solid var(--dsw-alias-border-l2); border-radius:6px; background:var(--dsw-alias-bg-layer-3); color:inherit; cursor:pointer; }
|
|
28
|
+
.codex-preset-editor button:disabled { opacity:.5; cursor:default; }
|
|
29
|
+
.codex-preset-editor .pe-primary { background:#425ce5; border-color:#425ce5; color:white; }
|
|
30
|
+
.codex-preset-editor .pe-block { display:grid; gap:9px; padding-top:12px; border-top:1px solid var(--dsw-alias-border-l2); }
|
|
31
|
+
.codex-preset-editor .pe-toggle { display:flex; align-items:flex-start; gap:9px; }
|
|
32
|
+
.codex-preset-editor .pe-toggle span { display:grid; gap:2px; }
|
|
33
|
+
.codex-preset-editor p { margin:0; font-size:12px; line-height:1.55; color:var(--dsw-alias-label-tertiary); }
|
|
34
|
+
`;
|
|
35
|
+
function optionToggle(key, label, hint, options, setOptions, disabled) {
|
|
36
|
+
return _jsxs("label", { className: "pe-toggle", children: [_jsx("input", { type: "checkbox", checked: options[key], disabled: disabled, onChange: event => setOptions({ ...options, [key]: event.target.checked }) }), _jsxs("span", { children: [_jsx("strong", { children: label }), _jsx("small", { children: hint })] })] }, key);
|
|
37
|
+
}
|
|
38
|
+
/** Presets are peers: choose one to edit, or make an editable copy first. */
|
|
39
|
+
export function PresetManagerCard({ presetManager, t }) {
|
|
40
|
+
const [catalog, setCatalog] = useState(() => catalogCache.get(presetManager));
|
|
41
|
+
const [selectedId, setSelectedId] = useState('');
|
|
42
|
+
const [original, setOriginal] = useState();
|
|
43
|
+
const [draft, setDraft] = useState();
|
|
44
|
+
const [sourceId, setSourceId] = useState('');
|
|
45
|
+
const [copyMode, setCopyMode] = useState(false);
|
|
46
|
+
const [codexEnabled, setCodexEnabled] = useState(false);
|
|
47
|
+
const [busy, setBusy] = useState(false);
|
|
48
|
+
const [error, setError] = useState('');
|
|
49
|
+
const [errorAction, setErrorAction] = useState('read');
|
|
50
|
+
const [notice, setNotice] = useState('');
|
|
51
|
+
const alive = useRef(true);
|
|
52
|
+
const request = useRef(0);
|
|
53
|
+
if (!documentCache.has(presetManager))
|
|
54
|
+
documentCache.set(presetManager, new Map());
|
|
55
|
+
const cache = documentCache.get(presetManager);
|
|
56
|
+
const remote = presetManager.remote.codexPresetEditor;
|
|
57
|
+
const dirty = !!draft && (!original || !equalEditorState(draft, original) || codexEnabled !== draft.codex);
|
|
58
|
+
async function run(work) {
|
|
59
|
+
setBusy(true);
|
|
60
|
+
setError('');
|
|
61
|
+
setNotice('');
|
|
62
|
+
try {
|
|
63
|
+
await presetManager.ready;
|
|
64
|
+
if (alive.current)
|
|
65
|
+
await work();
|
|
66
|
+
}
|
|
67
|
+
catch (cause) {
|
|
68
|
+
if (alive.current)
|
|
69
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
if (alive.current)
|
|
73
|
+
setBusy(false);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function load(id, confirmDirty = true) {
|
|
77
|
+
if (!id)
|
|
78
|
+
return;
|
|
79
|
+
if (confirmDirty && dirty && !window.confirm(t('pmDiscard')))
|
|
80
|
+
return;
|
|
81
|
+
const ticket = ++request.current;
|
|
82
|
+
setSelectedId(id);
|
|
83
|
+
setError('');
|
|
84
|
+
setNotice('');
|
|
85
|
+
setErrorAction('read');
|
|
86
|
+
const accept = (value) => {
|
|
87
|
+
if (!alive.current || ticket !== request.current)
|
|
88
|
+
return;
|
|
89
|
+
setSelectedId(id);
|
|
90
|
+
setSourceId(id);
|
|
91
|
+
setOriginal(value);
|
|
92
|
+
setDraft(value);
|
|
93
|
+
setCopyMode(false);
|
|
94
|
+
setCodexEnabled(value.codex);
|
|
95
|
+
};
|
|
96
|
+
const cached = cache.get(id);
|
|
97
|
+
if (cached && Date.now() - cached.time < 60_000) {
|
|
98
|
+
accept(cached.value);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
setDraft(undefined);
|
|
102
|
+
setOriginal(undefined);
|
|
103
|
+
setBusy(true);
|
|
104
|
+
try {
|
|
105
|
+
await presetManager.ready;
|
|
106
|
+
const value = await readPresetWithRetry(() => remote.read(id).then(unwrap), () => alive.current && ticket === request.current);
|
|
107
|
+
cache.set(id, { value, time: Date.now() });
|
|
108
|
+
accept(value);
|
|
109
|
+
}
|
|
110
|
+
catch (cause) {
|
|
111
|
+
if (alive.current && ticket === request.current)
|
|
112
|
+
setError(String(cause));
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
if (alive.current && ticket === request.current)
|
|
116
|
+
setBusy(false);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function refresh() {
|
|
120
|
+
setErrorAction('read');
|
|
121
|
+
const value = await readPresetWithRetry(() => remote.catalog().then(unwrap), () => alive.current);
|
|
122
|
+
if (!alive.current)
|
|
123
|
+
return;
|
|
124
|
+
catalogCache.set(presetManager, value);
|
|
125
|
+
setCatalog(value);
|
|
126
|
+
const current = selectedId || (value.presets.some(row => row.id === CODEX_DEFAULT_ID) ? CODEX_DEFAULT_ID : value.presets[0]?.id ?? '');
|
|
127
|
+
if (current && current !== selectedId)
|
|
128
|
+
await load(current, false);
|
|
129
|
+
}
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
alive.current = true;
|
|
132
|
+
if (!catalogCache.has(presetManager))
|
|
133
|
+
void run(refresh);
|
|
134
|
+
else if (!selectedId)
|
|
135
|
+
void load(catalogCache.get(presetManager)?.presets.some(row => row.id === CODEX_DEFAULT_ID) ? CODEX_DEFAULT_ID : catalogCache.get(presetManager)?.presets[0]?.id ?? '', false);
|
|
136
|
+
return () => { alive.current = false; };
|
|
137
|
+
}, [presetManager]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!dirty)
|
|
140
|
+
return;
|
|
141
|
+
const guard = (event) => { event.preventDefault(); event.returnValue = ''; };
|
|
142
|
+
window.addEventListener('beforeunload', guard);
|
|
143
|
+
return () => window.removeEventListener('beforeunload', guard);
|
|
144
|
+
}, [dirty]);
|
|
145
|
+
function patch(value) { if (draft)
|
|
146
|
+
setDraft({ ...draft, ...value }); }
|
|
147
|
+
function beginCopy() {
|
|
148
|
+
if (!draft || !sourceId)
|
|
149
|
+
return;
|
|
150
|
+
setCopyMode(true);
|
|
151
|
+
setCodexEnabled(draft.codex);
|
|
152
|
+
setOriginal({ ...draft });
|
|
153
|
+
setDraft({ ...draft, id: '', revision: '', editable: true, name: `${draft.name} · ${t('pmCustom')}` });
|
|
154
|
+
}
|
|
155
|
+
function save() {
|
|
156
|
+
if (!draft || busy || !draft.name.trim())
|
|
157
|
+
return;
|
|
158
|
+
setErrorAction('save');
|
|
159
|
+
void run(async () => {
|
|
160
|
+
const options = codexEnabled ? draft.codexOptions : undefined;
|
|
161
|
+
const payload = { name: draft.name, description: draft.description, systemPrompt: draft.systemPrompt,
|
|
162
|
+
promptSections: draft.promptSections.filter(section => section.editable && (codexEnabled || section.id !== 'codex:base')),
|
|
163
|
+
inheritPrompt: draft.inheritPrompt, enableCodex: codexEnabled, ...(options === undefined ? {} : { codexOptions: options }) };
|
|
164
|
+
const value = unwrap(await (copyMode
|
|
165
|
+
? remote.create({ ...payload, sourceId })
|
|
166
|
+
: remote.update({ ...payload, id: draft.id, revision: draft.revision })));
|
|
167
|
+
if (!alive.current)
|
|
168
|
+
return;
|
|
169
|
+
setSelectedId(value.id);
|
|
170
|
+
setSourceId(value.id);
|
|
171
|
+
setOriginal(value);
|
|
172
|
+
setDraft(value);
|
|
173
|
+
cache.set(value.id, { value, time: Date.now() });
|
|
174
|
+
setCopyMode(false);
|
|
175
|
+
setCodexEnabled(value.codex);
|
|
176
|
+
setNotice(t('peSaved'));
|
|
177
|
+
if (catalog) {
|
|
178
|
+
const row = { id: value.id, name: value.name, description: value.description, editable: value.editable,
|
|
179
|
+
isDefault: catalog.presets.find(item => item.id === value.id)?.isDefault ?? false };
|
|
180
|
+
const presets = catalog.presets.some(item => item.id === value.id)
|
|
181
|
+
? catalog.presets.map(item => item.id === value.id ? row : item) : [...catalog.presets, row];
|
|
182
|
+
catalogCache.set(presetManager, { ...catalog, presets });
|
|
183
|
+
setCatalog({ ...catalog, presets });
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const selectedRow = catalog?.presets.find(row => row.id === selectedId);
|
|
188
|
+
const readOnly = !!draft && !draft.editable && !copyMode;
|
|
189
|
+
const options = draft?.codexOptions;
|
|
190
|
+
return _jsxs("section", { className: "codex-preset-editor", "aria-label": t('peTitle'), "aria-busy": busy, children: [_jsx("style", { children: styles }), _jsxs("div", { className: "pe-row", style: { justifyContent: 'space-between' }, children: [_jsx("strong", { children: t('peTitle') }), _jsx("button", { type: "button", disabled: busy, onClick: () => { if (dirty && !window.confirm(t('pmDiscard')))
|
|
191
|
+
return; cache.clear(); void run(async () => { await refresh(); if (selectedId)
|
|
192
|
+
await load(selectedId, false); }); }, children: t('pmRefresh') })] }), _jsx("p", { children: t('peHierarchy') }), _jsxs("label", { children: [t('peSelect'), _jsxs("select", { value: selectedId, disabled: busy || !catalog, onChange: event => { void load(event.target.value); }, children: [_jsx("option", { value: "", children: t('peSelectPlaceholder') }), catalog?.presets.map(row => _jsxs("option", { value: row.id, children: [row.name, row.editable ? '' : ` · ${t('pmBuiltIn')}`] }, row.id))] })] }), selectedRow && _jsx("p", { children: selectedRow.editable ? t('peEditable') : t('peBuiltinEdit') }), error && _jsxs("div", { role: "alert", children: [_jsx("p", { children: errorAction === 'read'
|
|
193
|
+
? t(isPresetConnectionError(error) ? 'peConnectionError' : 'peReadError')
|
|
194
|
+
: error.includes('preset-conflict') ? t('pmConflict') : error.includes('invalid-preset-yaml') ? t('pmYamlError') : t('pmSaveError') }), errorAction === 'read' && _jsxs("div", { className: "pe-row", children: [_jsx("button", { type: "button", disabled: busy, onClick: () => { if (selectedId) {
|
|
195
|
+
cache.delete(selectedId);
|
|
196
|
+
void load(selectedId, false);
|
|
197
|
+
}
|
|
198
|
+
else
|
|
199
|
+
void run(refresh); }, children: t('peRetryRead') }), !draft && isPresetConnectionError(error) && _jsx("button", { type: "button", onClick: () => window.location.reload(), children: t('peReconnect') })] }), _jsxs("details", { children: [_jsx("summary", { children: t('pmErrorDetails') }), _jsx("pre", { style: { whiteSpace: 'pre-wrap' }, children: error })] })] }), notice && _jsx("p", { role: "status", children: notice }), busy && !draft && _jsx("p", { role: "status", children: t('peLoading') }), draft && _jsxs(_Fragment, { children: [_jsxs("label", { children: [t('pmName'), _jsx("input", { value: draft.name, maxLength: 200, disabled: busy || readOnly, onChange: event => patch({ name: event.target.value }) })] }), _jsxs("label", { children: [t('pmDescription'), _jsx("input", { value: draft.description, maxLength: 4000, disabled: busy || readOnly, onChange: event => patch({ description: event.target.value }) })] }), !copyMode && _jsx("button", { type: "button", disabled: busy || !catalog?.authorable, onClick: beginCopy, children: t('peCreateCopy') }), _jsxs("div", { className: "pe-block", children: [_jsx("strong", { children: t('peSystemPrompt') }), _jsx("p", { children: t('peSectionsHint') }), draft.promptSections.map(section => _jsxs("details", { children: [_jsxs("summary", { style: { cursor: 'pointer', padding: '6px 0' }, children: [section.label, section.suppressed ? ` · ${t('peSuppressed')}` : ''] }), section.id === 'harness:source' && _jsx("p", { children: t('peDshSourcePrompt') }), section.id === 'app:web-surface' && _jsx("p", { children: t('peDshWebPrompt') }), _jsx("textarea", { "aria-label": section.label, rows: section.id === 'codex:base' ? 12 : 5, value: section.text, disabled: busy || readOnly || !section.editable, onChange: event => patch({ promptSections: draft.promptSections.map(item => item.id === section.id ? { ...item, text: event.target.value } : item),
|
|
200
|
+
...(section.id === 'codex:base' ? { systemPrompt: event.target.value, inheritPrompt: false } : {}) }) }), section.suppressed ? _jsx("p", { children: t('peCompletePersona') }) : !section.editable && _jsx("p", { children: t('peDynamicPrompt') })] }, section.id))] }), !readOnly && _jsxs(_Fragment, { children: [_jsxs("div", { className: "pe-block", children: [_jsx("strong", { children: t('peCodexSection') }), !draft.codex && _jsxs("label", { className: "pe-toggle", children: [_jsx("input", { type: "checkbox", checked: codexEnabled, disabled: busy, onChange: event => {
|
|
201
|
+
const enabled = event.target.checked;
|
|
202
|
+
setCodexEnabled(enabled);
|
|
203
|
+
if (enabled) {
|
|
204
|
+
const extras = [
|
|
205
|
+
{ id: 'codex:base', label: 'Codex 操作提示词', text: DEFAULT_CODEX_SYSTEM_PROMPT, editable: true },
|
|
206
|
+
];
|
|
207
|
+
patch({ promptSections: [...draft.promptSections.map(s => s.suppressed ? { ...s, suppressed: undefined, editable: true } : s), ...extras.filter(item => !draft.promptSections.some(s => s.id === item.id))] });
|
|
208
|
+
}
|
|
209
|
+
else
|
|
210
|
+
patch({ promptSections: draft.promptSections.filter(s => original?.promptSections.some(item => item.id === s.id)).map(s => {
|
|
211
|
+
const source = original?.promptSections.find(item => item.id === s.id);
|
|
212
|
+
return source?.suppressed ? { ...s, suppressed: true, editable: false } : s;
|
|
213
|
+
}) });
|
|
214
|
+
} }), _jsxs("span", { children: [_jsx("strong", { children: t('peAddCodex') }), _jsx("small", { children: t('peAddCodexHint') })] })] }), codexEnabled && options && _jsxs(_Fragment, { children: [optionToggle('hostedWebSearchEnabled', t('capabilityWebSearch'), t('capabilityWebSearchHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('remoteCompactionEnabled', t('capabilityCompaction'), t('capabilityCompactionHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('terminalToolsEnabled', t('capabilityTerminal'), t('capabilityTerminalHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('patchToolEnabled', t('capabilityPatch'), t('capabilityPatchHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('planToolEnabled', t('capabilityPlan'), t('capabilityPlanHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('promptEnabled', t('capabilityPrompt'), t('capabilityPromptHint'), options, next => patch({ codexOptions: next }), busy), _jsx("p", { children: t('peActivityGlobal') })] })] }), _jsxs("div", { className: "pe-row", children: [_jsx("button", { type: "button", className: "pe-primary", disabled: busy || !catalog?.authorable || !draft.name.trim() || !dirty, onClick: save, children: copyMode ? t('peSaveCopy') : t('pmSave') }), copyMode && _jsx("button", { type: "button", disabled: busy, onClick: () => { void load(sourceId, false); }, children: t('pmCancel') }), !copyMode && _jsx("button", { type: "button", disabled: busy, onClick: () => { void load(draft.id, false); }, children: t('pmCancel') })] })] })] })] });
|
|
215
|
+
}
|
|
216
|
+
export default PresetManagerCard;
|
|
217
|
+
//# sourceMappingURL=preset-manager.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Only transport failures from a read can be retried without duplicating writes. */
|
|
2
|
+
export declare function isPresetConnectionError(error: unknown): boolean;
|
|
3
|
+
export declare function readPresetWithRetry<T>(read: () => Promise<T>, active: () => boolean): Promise<T>;
|
|
4
|
+
//# sourceMappingURL=preset-requests.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Only transport failures from a read can be retried without duplicating writes. */
|
|
2
|
+
export function isPresetConnectionError(error) {
|
|
3
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4
|
+
return /Failed to fetch|NetworkError|Load failed|network request failed|no active Connection|connection.*(?:closed|offline)/i.test(message);
|
|
5
|
+
}
|
|
6
|
+
export async function readPresetWithRetry(read, active) {
|
|
7
|
+
try {
|
|
8
|
+
return await read();
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (!isPresetConnectionError(error) || !active())
|
|
12
|
+
throw error;
|
|
13
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
14
|
+
if (!active())
|
|
15
|
+
throw error;
|
|
16
|
+
return read();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=preset-requests.js.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -30,6 +30,16 @@ export interface Config {
|
|
|
30
30
|
remoteCompact?: boolean;
|
|
31
31
|
/** Complete plugin-owned Codex operating prompt. */
|
|
32
32
|
systemPrompt?: string;
|
|
33
|
+
/** Explicit per-preset operating prompt; overrides the shared prompt only. */
|
|
34
|
+
presetPrompt?: string;
|
|
35
|
+
presetSections?: import('./prompt-sections.ts').Config;
|
|
36
|
+
/** Per-preset Codex capability overrides. Omitted values follow shared settings. */
|
|
37
|
+
promptEnabled?: boolean;
|
|
38
|
+
terminalToolsEnabled?: boolean;
|
|
39
|
+
patchToolEnabled?: boolean;
|
|
40
|
+
planToolEnabled?: boolean;
|
|
41
|
+
hostedWebSearchEnabled?: boolean;
|
|
42
|
+
remoteCompactionEnabled?: boolean;
|
|
33
43
|
/** Deployment Persona template. */
|
|
34
44
|
persona?: string;
|
|
35
45
|
/** DSH Core source-checkout guidance template. */
|
|
@@ -71,6 +81,8 @@ export declare function normalizeCodexPromptAssembly(assembly: PromptAssembly):
|
|
|
71
81
|
export declare function applyCodexCapabilitySettings(assembly: PromptAssembly, settings: CodexSettings): PromptAssembly;
|
|
72
82
|
/** Build the complete plugin-owned prompt, preserving an intentional empty value. */
|
|
73
83
|
export declare function buildCodexSystemPrompt(config?: Pick<Config, 'systemPrompt'>): string;
|
|
84
|
+
/** Explicit preset instructions win without changing shared tools or permissions. */
|
|
85
|
+
export declare function withPresetPrompt(settings: CodexSettings, presetPrompt: string | undefined): CodexSettings;
|
|
74
86
|
/** Mount the Codex prompt/tool layer inside one fixed agent preset. */
|
|
75
87
|
export declare function apply(ctx: Context, config?: Config): void;
|
|
76
88
|
declare const _default: {
|
package/lib/types/index.js
CHANGED
|
@@ -8,11 +8,31 @@ import { registerCodexActivityProjection } from "./activity.js";
|
|
|
8
8
|
import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, resolveCodexSystemPrompt, } from "./prompt.js";
|
|
9
9
|
import { CODEX_SETTINGS_ENTRY, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, } from "./settings.js";
|
|
10
10
|
import { codexCompactionMode } from "./compaction.js";
|
|
11
|
+
import { CodexPresetEditor } from "./preset-editor.js";
|
|
12
|
+
import { applyPromptSections, Config as PromptSectionsConfig } from "./prompt-sections.js";
|
|
11
13
|
export { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from "./prompt.js";
|
|
12
14
|
export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA } from "./settings.js";
|
|
13
15
|
export const name = 'codex';
|
|
14
16
|
export const inject = ['tools', 'systemPrompt', 'shell', 'fs', 'llm', 'credentials', 'settings'];
|
|
15
17
|
const DEFAULT_MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
18
|
+
/** Add the preset editor when DSH's optional user-preset service is available. */
|
|
19
|
+
function installPresetEditor(ctx) {
|
|
20
|
+
// `agentPresets` is supplied by dsh-agent-presets and may be installed after
|
|
21
|
+
// this plugin. Waiting through inject keeps the Codex core usable on hosts
|
|
22
|
+
// without that optional service while still mounting the Remote as soon as
|
|
23
|
+
// the Web preset catalog becomes available.
|
|
24
|
+
ctx.inject(['agentPresets'], presetCtx => {
|
|
25
|
+
void (async () => {
|
|
26
|
+
try {
|
|
27
|
+
await presetCtx.plugin(CodexPresetEditor);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
ctx.logger.warn('codex: preset editor is unavailable on this host');
|
|
31
|
+
ctx.logger.warn(error);
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
16
36
|
/** Runtime configuration schema for the Codex tool bridge. */
|
|
17
37
|
export const Config = z.object({
|
|
18
38
|
globalEnhancements: z.boolean().default(true),
|
|
@@ -24,6 +44,14 @@ export const Config = z.object({
|
|
|
24
44
|
hostedWebSearch: z.boolean().default(true),
|
|
25
45
|
remoteCompact: z.boolean().default(true),
|
|
26
46
|
systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
|
|
47
|
+
presetPrompt: z.string(),
|
|
48
|
+
presetSections: PromptSectionsConfig,
|
|
49
|
+
promptEnabled: z.boolean(),
|
|
50
|
+
terminalToolsEnabled: z.boolean(),
|
|
51
|
+
patchToolEnabled: z.boolean(),
|
|
52
|
+
planToolEnabled: z.boolean(),
|
|
53
|
+
hostedWebSearchEnabled: z.boolean(),
|
|
54
|
+
remoteCompactionEnabled: z.boolean(),
|
|
27
55
|
persona: z.string().default(DEFAULT_CODEX_PERSONA),
|
|
28
56
|
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
29
57
|
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
|
|
@@ -612,8 +640,13 @@ function registerPlanTool(ctx, currentSettings) {
|
|
|
612
640
|
},
|
|
613
641
|
}));
|
|
614
642
|
}
|
|
643
|
+
/** Explicit preset instructions win without changing shared tools or permissions. */
|
|
644
|
+
export function withPresetPrompt(settings, presetPrompt) {
|
|
645
|
+
return presetPrompt === undefined ? settings : { ...settings, systemPrompt: presetPrompt };
|
|
646
|
+
}
|
|
615
647
|
/** Mount the Codex prompt/tool layer inside one fixed agent preset. */
|
|
616
648
|
export function apply(ctx, config = {}) {
|
|
649
|
+
installPresetEditor(ctx);
|
|
617
650
|
const resolved = {
|
|
618
651
|
globalEnhancements: config.globalEnhancements ?? true,
|
|
619
652
|
codexCore: config.codexCore ?? true,
|
|
@@ -633,7 +666,19 @@ export function apply(ctx, config = {}) {
|
|
|
633
666
|
&& ctx.get('sandboxPolicy') === undefined) {
|
|
634
667
|
throw new Error('codex: a sandboxing filesystem requires ctx.sandboxPolicy');
|
|
635
668
|
}
|
|
636
|
-
const
|
|
669
|
+
const sharedSettings = installCodexSettings(ctx, resolved.systemPrompt, resolved.persona, resolved.harnessSourcePrompt, resolved.webSurfacePrompt);
|
|
670
|
+
const codexSettings = { current: () => {
|
|
671
|
+
const shared = withPresetPrompt(sharedSettings.current(), config.presetPrompt);
|
|
672
|
+
return {
|
|
673
|
+
...shared,
|
|
674
|
+
...(config.promptEnabled === undefined ? {} : { promptEnabled: config.promptEnabled }),
|
|
675
|
+
...(config.terminalToolsEnabled === undefined ? {} : { terminalToolsEnabled: config.terminalToolsEnabled }),
|
|
676
|
+
...(config.patchToolEnabled === undefined ? {} : { patchToolEnabled: config.patchToolEnabled }),
|
|
677
|
+
...(config.planToolEnabled === undefined ? {} : { planToolEnabled: config.planToolEnabled }),
|
|
678
|
+
...(config.hostedWebSearchEnabled === undefined ? {} : { hostedWebSearchEnabled: config.hostedWebSearchEnabled }),
|
|
679
|
+
...(config.remoteCompactionEnabled === undefined ? {} : { remoteCompactionEnabled: config.remoteCompactionEnabled }),
|
|
680
|
+
};
|
|
681
|
+
} };
|
|
637
682
|
const execConfig = { ...resolved, currentSettings: codexSettings.current };
|
|
638
683
|
if (resolved.globalEnhancements) {
|
|
639
684
|
// The generic pi-ai plugin remains the owner of provider routes. This
|
|
@@ -676,7 +721,7 @@ export function apply(ctx, config = {}) {
|
|
|
676
721
|
}));
|
|
677
722
|
}
|
|
678
723
|
if (resolved.codexCore) {
|
|
679
|
-
ctx.on('system-prompt/assemble', async (_assembly, _context, next) => applyCodexCapabilitySettings(await next(), codexSettings.current()));
|
|
724
|
+
ctx.on('system-prompt/assemble', async (_assembly, _context, next) => applyPromptSections(applyCodexCapabilitySettings(await next(), codexSettings.current()), config.presetSections ?? {}));
|
|
680
725
|
ctx.systemPrompt.section({
|
|
681
726
|
name: 'codex:base',
|
|
682
727
|
order: 10,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Client-safe, versioned preset authoring contract. No filesystem or runtime imports. */
|
|
2
|
+
export interface PresetFields {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
systemPrompt: string;
|
|
6
|
+
inheritPrompt: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PresetPromptSection {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
text: string;
|
|
12
|
+
editable: boolean;
|
|
13
|
+
/** Excluded by a complete Persona; shown for inspection, never saved as an active section. */
|
|
14
|
+
suppressed?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Codex capabilities stored with a preset. Activity status stays global. */
|
|
17
|
+
export interface CodexPresetOptions {
|
|
18
|
+
promptEnabled: boolean;
|
|
19
|
+
terminalToolsEnabled: boolean;
|
|
20
|
+
patchToolEnabled: boolean;
|
|
21
|
+
planToolEnabled: boolean;
|
|
22
|
+
hostedWebSearchEnabled: boolean;
|
|
23
|
+
remoteCompactionEnabled: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface PresetEditorDocument extends PresetFields {
|
|
26
|
+
id: string;
|
|
27
|
+
revision: string;
|
|
28
|
+
editable: boolean;
|
|
29
|
+
codex: boolean;
|
|
30
|
+
codexOptions: CodexPresetOptions;
|
|
31
|
+
composition: string;
|
|
32
|
+
promptSections: PresetPromptSection[];
|
|
33
|
+
}
|
|
34
|
+
export interface PresetEditorInput extends PresetFields {
|
|
35
|
+
id: string;
|
|
36
|
+
revision?: string;
|
|
37
|
+
composition?: string;
|
|
38
|
+
enableCodex?: boolean;
|
|
39
|
+
promptSections?: PresetPromptSection[];
|
|
40
|
+
codexOptions?: Partial<CodexPresetOptions>;
|
|
41
|
+
}
|
|
42
|
+
export interface PresetCreateInput extends PresetFields {
|
|
43
|
+
sourceId: string;
|
|
44
|
+
enableCodex?: boolean;
|
|
45
|
+
promptSections?: PresetPromptSection[];
|
|
46
|
+
composition?: string;
|
|
47
|
+
codexOptions?: Partial<CodexPresetOptions>;
|
|
48
|
+
}
|
|
49
|
+
export interface PresetCatalogRow {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
editable: boolean;
|
|
54
|
+
isDefault: boolean;
|
|
55
|
+
codex?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface PresetCatalog {
|
|
58
|
+
presets: PresetCatalogRow[];
|
|
59
|
+
authorable: boolean;
|
|
60
|
+
excludedCount: number;
|
|
61
|
+
}
|
|
62
|
+
/** A portable instruction card, deliberately not executable YAML or a tool bundle. */
|
|
63
|
+
export interface PromptCard extends PresetFields {
|
|
64
|
+
format: 'codex-harness/prompt-card';
|
|
65
|
+
version: 1;
|
|
66
|
+
}
|
|
67
|
+
export declare function parsePromptCard(text: string): PromptCard;
|
|
68
|
+
export declare function exportPromptCard(fields: PresetFields): string;
|
|
69
|
+
//# sourceMappingURL=preset-contract.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function parsePromptCard(text) {
|
|
2
|
+
if (text.length > 1_100_000)
|
|
3
|
+
throw new Error('invalid-prompt-card');
|
|
4
|
+
const value = JSON.parse(text);
|
|
5
|
+
if (!value || typeof value !== 'object')
|
|
6
|
+
throw new Error('invalid-prompt-card');
|
|
7
|
+
const card = value;
|
|
8
|
+
if (card.format !== 'codex-harness/prompt-card' || card.version !== 1
|
|
9
|
+
|| typeof card.name !== 'string' || !card.name.trim() || card.name.length > 200
|
|
10
|
+
|| typeof card.description !== 'string' || card.description.length > 4000
|
|
11
|
+
|| typeof card.systemPrompt !== 'string' || card.systemPrompt.length > 1_000_000
|
|
12
|
+
|| typeof card.inheritPrompt !== 'boolean')
|
|
13
|
+
throw new Error('invalid-prompt-card');
|
|
14
|
+
return { format: card.format, version: 1, name: card.name, description: card.description,
|
|
15
|
+
systemPrompt: card.systemPrompt, inheritPrompt: card.inheritPrompt };
|
|
16
|
+
}
|
|
17
|
+
export function exportPromptCard(fields) {
|
|
18
|
+
return JSON.stringify({ format: 'codex-harness/prompt-card', version: 1,
|
|
19
|
+
name: fields.name, description: fields.description, systemPrompt: fields.systemPrompt,
|
|
20
|
+
inheritPrompt: fields.inheritPrompt }, null, 2);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=preset-contract.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
package: string;
|
|
4
|
+
descriptors: {
|
|
5
|
+
id: string;
|
|
6
|
+
service: string;
|
|
7
|
+
namespace: string;
|
|
8
|
+
method: string;
|
|
9
|
+
invocation: {
|
|
10
|
+
kind: "direct";
|
|
11
|
+
};
|
|
12
|
+
parameters: {
|
|
13
|
+
name: string;
|
|
14
|
+
wire: string;
|
|
15
|
+
source: "json";
|
|
16
|
+
codec: {
|
|
17
|
+
mode: "strict";
|
|
18
|
+
typeSymbol: string;
|
|
19
|
+
schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
20
|
+
};
|
|
21
|
+
}[];
|
|
22
|
+
result: {
|
|
23
|
+
mode: "strict";
|
|
24
|
+
typeSymbol: string;
|
|
25
|
+
schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
26
|
+
};
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
export default _default;
|
|
30
|
+
//# sourceMappingURL=preset-editor-remote.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const promptSections = z.array(z.object({ id: z.string(), label: z.string(), text: z.string().max(1_000_000), editable: z.boolean(), suppressed: z.boolean().optional() })).max(200);
|
|
3
|
+
const fields = {
|
|
4
|
+
name: z.string().max(200), description: z.string().max(4000),
|
|
5
|
+
systemPrompt: z.string().max(1_000_000), inheritPrompt: z.boolean(),
|
|
6
|
+
};
|
|
7
|
+
const codexOptions = z.object({
|
|
8
|
+
promptEnabled: z.boolean(), terminalToolsEnabled: z.boolean(), patchToolEnabled: z.boolean(),
|
|
9
|
+
planToolEnabled: z.boolean(), hostedWebSearchEnabled: z.boolean(), remoteCompactionEnabled: z.boolean(),
|
|
10
|
+
});
|
|
11
|
+
const codexOptionsPatch = codexOptions.partial();
|
|
12
|
+
const document = z.object({ ...fields, id: z.string(), revision: z.string(), editable: z.boolean(), codex: z.boolean(), codexOptions, promptSections, composition: z.string() });
|
|
13
|
+
const catalog = z.object({
|
|
14
|
+
presets: z.array(z.object({ id: z.string(), name: z.string(), description: z.string(),
|
|
15
|
+
editable: z.boolean(), isDefault: z.boolean() })),
|
|
16
|
+
authorable: z.boolean(), excludedCount: z.number(),
|
|
17
|
+
});
|
|
18
|
+
function descriptor(method, parameter, input, output) {
|
|
19
|
+
const id = `@shuind/dsh-codex-harness#codexPresetEditor/${method}`;
|
|
20
|
+
return {
|
|
21
|
+
id, service: 'codexPresetEditor', namespace: 'codexPresetEditor', method,
|
|
22
|
+
invocation: { kind: 'direct' },
|
|
23
|
+
parameters: parameter ? [{ name: parameter, wire: parameter, source: 'json',
|
|
24
|
+
codec: { mode: 'strict', typeSymbol: `${id}:${parameter}`, schema: input } }] : [],
|
|
25
|
+
result: { mode: 'strict', typeSymbol: `${id}:result`, schema: output },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export default {
|
|
29
|
+
package: '@shuind/dsh-codex-harness',
|
|
30
|
+
descriptors: [
|
|
31
|
+
descriptor('catalog', undefined, z.unknown(), catalog),
|
|
32
|
+
descriptor('read', 'id', z.string(), document),
|
|
33
|
+
descriptor('update', 'rawInput', z.object({ ...fields, id: z.string(), revision: z.string().optional(), composition: z.string().max(1_000_000).optional(), enableCodex: z.boolean().optional(), promptSections: promptSections.optional(), codexOptions: codexOptionsPatch.optional() }), document),
|
|
34
|
+
descriptor('create', 'rawInput', z.object({ ...fields, sourceId: z.string(), enableCodex: z.boolean().optional(), composition: z.string().max(1_000_000).optional(), promptSections: promptSections.optional(), codexOptions: codexOptionsPatch.optional() }), document),
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=preset-editor-remote.js.map
|