@shuind/dsh-codex-harness 0.2.2 → 0.2.4
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/cordis.patch.yml +6 -5
- package/lib/client.js +150 -23
- package/lib/index.js +217 -53
- package/lib/installer.js +18 -3
- package/lib/types/client/index.d.ts +26 -4
- package/lib/types/client/index.js +70 -25
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.js +92 -43
- package/lib/types/installer.js +1 -0
- package/lib/types/remote.d.ts +11 -2
- package/lib/types/remote.js +160 -21
- package/lib/types/settings.d.ts +14 -0
- package/lib/types/settings.js +14 -0
- package/package.json +1 -1
- package/presets/codex-collaboration/agent.cordis.yml +8 -4
package/cordis.patch.yml
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
- insert:
|
|
2
|
-
#
|
|
3
|
-
# lives in the bundled agent preset, so other presets stay unchanged.
|
|
2
|
+
# Keep preset installation and settings registration on the host plane.
|
|
4
3
|
- id: codex-preset-installer
|
|
5
4
|
name: '@shuind/dsh-codex-harness/installer'
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# receives Fast/context controls.
|
|
5
|
+
# This row owns the global capability layer and also advertises the
|
|
6
|
+
# browser face. Codex prompt/tools remain agent-preset scoped.
|
|
9
7
|
- id: codex-client
|
|
10
8
|
name: '@shuind/dsh-codex-harness'
|
|
9
|
+
config:
|
|
10
|
+
globalEnhancements: true
|
|
11
|
+
codexCore: false
|
package/lib/client.js
CHANGED
|
@@ -14,11 +14,6 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
/** User-selectable Codex context controls use whole K-token units. */
|
|
15
15
|
const CODEX_CONTEXT_UNIT = 1e3;
|
|
16
16
|
const CODEX_CONTEXT_MAX = 1e6;
|
|
17
|
-
const CODEX_PRESET_IDS = /* @__PURE__ */ new Set(["codex", "codex-collaboration"]);
|
|
18
|
-
/** The bundled preset and legacy Codex sessions share the same Web controls. */
|
|
19
|
-
function isCodexPresetId(value) {
|
|
20
|
-
return value !== void 0 && CODEX_PRESET_IDS.has(value);
|
|
21
|
-
}
|
|
22
17
|
//#endregion
|
|
23
18
|
//#region lib/types/prompt.js
|
|
24
19
|
/** Default plugin-owned Codex operating prompt. */
|
|
@@ -126,7 +121,22 @@ window.__ModuleLoader__.load({
|
|
|
126
121
|
contextSizeDescription: "Next request capacity in K tokens.",
|
|
127
122
|
contextRestore: "Restore model default",
|
|
128
123
|
promptCardTitle: "Codex Harness",
|
|
129
|
-
promptCardDescription: "
|
|
124
|
+
promptCardDescription: "Choose Codex capabilities and customize the operating prompt.",
|
|
125
|
+
capabilitiesLabel: "Codex mode capabilities",
|
|
126
|
+
capabilityPrompt: "Codex operating prompt",
|
|
127
|
+
capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout in Codex mode.",
|
|
128
|
+
capabilityTerminal: "Terminal tools",
|
|
129
|
+
capabilityTerminalHint: "Expose exec_command and write_stdin in Codex mode.",
|
|
130
|
+
capabilityPatch: "Patch tool",
|
|
131
|
+
capabilityPatchHint: "Expose apply_patch in Codex mode, using the native Responses grammar when supported.",
|
|
132
|
+
capabilityPlan: "Plan tool",
|
|
133
|
+
capabilityPlanHint: "Expose update_plan for implementation task tracking in Codex mode.",
|
|
134
|
+
capabilityWebSearch: "Hosted web search",
|
|
135
|
+
capabilityWebSearchHint: "Use the provider-native Responses web_search tool when available.",
|
|
136
|
+
capabilityCompaction: "Remote compaction",
|
|
137
|
+
capabilityCompactionHint: "Prefer the provider Responses compact endpoint before local compaction.",
|
|
138
|
+
capabilityActivity: "Activity indicator",
|
|
139
|
+
capabilityActivityHint: "Show request, reply, and compaction status beside the conversation.",
|
|
130
140
|
promptLabel: "System prompt",
|
|
131
141
|
promptHint: "This is the full prompt owned by this plugin. Persona and DSH tool guidance stay dynamic.",
|
|
132
142
|
promptOverridden: "Overridden",
|
|
@@ -153,7 +163,22 @@ window.__ModuleLoader__.load({
|
|
|
153
163
|
contextSizeDescription: "设置下次请求的上下文容量,单位为 K tokens。",
|
|
154
164
|
contextRestore: "恢复模型默认值",
|
|
155
165
|
promptCardTitle: "Codex Harness",
|
|
156
|
-
promptCardDescription: "
|
|
166
|
+
promptCardDescription: "选择 Codex 能力并自定义完整的操作提示词。",
|
|
167
|
+
capabilitiesLabel: "Codex 模式能力",
|
|
168
|
+
capabilityPrompt: "Codex 操作提示词",
|
|
169
|
+
capabilityPromptHint: "仅在 Codex 模式注入可编辑指令,并将 Persona 放在提示词首位。",
|
|
170
|
+
capabilityTerminal: "终端工具",
|
|
171
|
+
capabilityTerminalHint: "仅在 Codex 模式提供 exec_command 和 write_stdin。",
|
|
172
|
+
capabilityPatch: "补丁工具",
|
|
173
|
+
capabilityPatchHint: "仅在 Codex 模式提供 apply_patch,并在支持时使用 Responses 原生语法。",
|
|
174
|
+
capabilityPlan: "计划工具",
|
|
175
|
+
capabilityPlanHint: "仅在 Codex 模式提供 update_plan,用于跟踪实施任务。",
|
|
176
|
+
capabilityWebSearch: "托管网络搜索",
|
|
177
|
+
capabilityWebSearchHint: "可用时使用提供商原生的 Responses web_search 工具。",
|
|
178
|
+
capabilityCompaction: "远程上下文压缩",
|
|
179
|
+
capabilityCompactionHint: "优先调用提供商的 Responses compact 端点,失败时回退本地压缩。",
|
|
180
|
+
capabilityActivity: "活动状态",
|
|
181
|
+
capabilityActivityHint: "在对话旁显示请求、回复和压缩状态。",
|
|
157
182
|
promptLabel: "系统提示词",
|
|
158
183
|
promptHint: "这是本插件负责的全部提示词;Persona 和 DSH 工具指导仍会动态注入。",
|
|
159
184
|
promptOverridden: "已覆盖",
|
|
@@ -178,6 +203,52 @@ window.__ModuleLoader__.load({
|
|
|
178
203
|
function hasPromptOverride(layer) {
|
|
179
204
|
return typeof layer === "object" && layer !== null && !Array.isArray(layer) && Object.hasOwn(layer, "systemPrompt");
|
|
180
205
|
}
|
|
206
|
+
function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting }) {
|
|
207
|
+
return (0, react_jsx_runtime.jsxs)("label", {
|
|
208
|
+
style: {
|
|
209
|
+
display: "flex",
|
|
210
|
+
alignItems: "flex-start",
|
|
211
|
+
gap: 12,
|
|
212
|
+
padding: "9px 0",
|
|
213
|
+
cursor: disabled ? "default" : "pointer"
|
|
214
|
+
},
|
|
215
|
+
children: [(0, react_jsx_runtime.jsxs)("span", {
|
|
216
|
+
style: {
|
|
217
|
+
flex: 1,
|
|
218
|
+
minWidth: 0,
|
|
219
|
+
display: "grid",
|
|
220
|
+
gap: 2
|
|
221
|
+
},
|
|
222
|
+
children: [(0, react_jsx_runtime.jsx)("strong", {
|
|
223
|
+
style: {
|
|
224
|
+
fontSize: 13,
|
|
225
|
+
fontWeight: 500
|
|
226
|
+
},
|
|
227
|
+
children: label
|
|
228
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
229
|
+
style: {
|
|
230
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
231
|
+
fontSize: 12,
|
|
232
|
+
lineHeight: 1.45
|
|
233
|
+
},
|
|
234
|
+
children: hint
|
|
235
|
+
})]
|
|
236
|
+
}), (0, react_jsx_runtime.jsx)("input", {
|
|
237
|
+
type: "checkbox",
|
|
238
|
+
role: "switch",
|
|
239
|
+
checked: enabled,
|
|
240
|
+
disabled,
|
|
241
|
+
"aria-label": label,
|
|
242
|
+
onChange: (event) => {
|
|
243
|
+
setSetting(field, event.target.checked);
|
|
244
|
+
},
|
|
245
|
+
style: {
|
|
246
|
+
marginTop: 3,
|
|
247
|
+
accentColor: "var(--dsw-static-blue-500)"
|
|
248
|
+
}
|
|
249
|
+
})]
|
|
250
|
+
});
|
|
251
|
+
}
|
|
181
252
|
/** Full-prompt editor contributed to Settings > Plugins. */
|
|
182
253
|
function PromptSettingsCard(props) {
|
|
183
254
|
const { useSettings, setSetting, unsetSetting, t } = props;
|
|
@@ -185,6 +256,43 @@ window.__ModuleLoader__.load({
|
|
|
185
256
|
const current = snapshot.value?.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
|
|
186
257
|
const inherited = promptFromLayer(snapshot.base) ?? DEFAULT_CODEX_SYSTEM_PROMPT;
|
|
187
258
|
const overridden = hasPromptOverride(snapshot.user);
|
|
259
|
+
const capabilities = [
|
|
260
|
+
{
|
|
261
|
+
field: "promptEnabled",
|
|
262
|
+
label: "capabilityPrompt",
|
|
263
|
+
hint: "capabilityPromptHint"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
field: "terminalToolsEnabled",
|
|
267
|
+
label: "capabilityTerminal",
|
|
268
|
+
hint: "capabilityTerminalHint"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
field: "patchToolEnabled",
|
|
272
|
+
label: "capabilityPatch",
|
|
273
|
+
hint: "capabilityPatchHint"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
field: "planToolEnabled",
|
|
277
|
+
label: "capabilityPlan",
|
|
278
|
+
hint: "capabilityPlanHint"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
field: "hostedWebSearchEnabled",
|
|
282
|
+
label: "capabilityWebSearch",
|
|
283
|
+
hint: "capabilityWebSearchHint"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
field: "remoteCompactionEnabled",
|
|
287
|
+
label: "capabilityCompaction",
|
|
288
|
+
hint: "capabilityCompactionHint"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
field: "activityIndicatorEnabled",
|
|
292
|
+
label: "capabilityActivity",
|
|
293
|
+
hint: "capabilityActivityHint"
|
|
294
|
+
}
|
|
295
|
+
];
|
|
188
296
|
const [open, setOpen] = (0, react.useState)(false);
|
|
189
297
|
const [draft, setDraft] = (0, react.useState)(current);
|
|
190
298
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
@@ -304,12 +412,36 @@ window.__ModuleLoader__.load({
|
|
|
304
412
|
},
|
|
305
413
|
children: t("promptReadOnly")
|
|
306
414
|
}),
|
|
415
|
+
(0, react_jsx_runtime.jsx)("strong", {
|
|
416
|
+
style: {
|
|
417
|
+
display: "block",
|
|
418
|
+
marginBottom: 4,
|
|
419
|
+
fontSize: 13
|
|
420
|
+
},
|
|
421
|
+
children: t("capabilitiesLabel")
|
|
422
|
+
}),
|
|
423
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
424
|
+
style: {
|
|
425
|
+
display: "grid",
|
|
426
|
+
marginBottom: 14
|
|
427
|
+
},
|
|
428
|
+
children: capabilities.map((capability) => (0, react_jsx_runtime.jsx)(CapabilityToggle, {
|
|
429
|
+
field: capability.field,
|
|
430
|
+
label: t(capability.label),
|
|
431
|
+
hint: t(capability.hint),
|
|
432
|
+
enabled: snapshot.value?.[capability.field] ?? true,
|
|
433
|
+
disabled: !snapshot.writable || saving,
|
|
434
|
+
setSetting
|
|
435
|
+
}, capability.field))
|
|
436
|
+
}),
|
|
307
437
|
(0, react_jsx_runtime.jsxs)("div", {
|
|
308
438
|
style: {
|
|
309
439
|
display: "flex",
|
|
310
440
|
alignItems: "center",
|
|
311
441
|
gap: 8,
|
|
312
|
-
marginBottom: 7
|
|
442
|
+
marginBottom: 7,
|
|
443
|
+
paddingTop: 12,
|
|
444
|
+
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
313
445
|
},
|
|
314
446
|
children: [(0, react_jsx_runtime.jsx)("label", {
|
|
315
447
|
htmlFor: "codex-system-prompt",
|
|
@@ -439,11 +571,9 @@ window.__ModuleLoader__.load({
|
|
|
439
571
|
}
|
|
440
572
|
/** The legacy composer seat is a compact inline row, not a menu panel. */
|
|
441
573
|
function FastModeFallback(props) {
|
|
442
|
-
const {
|
|
443
|
-
const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
|
|
574
|
+
const { useSettings, setSetting, t } = props;
|
|
444
575
|
const snapshot = useSettings((state) => state);
|
|
445
576
|
const fast = snapshot.value?.fast ?? false;
|
|
446
|
-
if (!isCodexPresetId(agentPreset)) return null;
|
|
447
577
|
return (0, react_jsx_runtime.jsxs)("button", {
|
|
448
578
|
type: "button",
|
|
449
579
|
role: "switch",
|
|
@@ -486,10 +616,8 @@ window.__ModuleLoader__.load({
|
|
|
486
616
|
return pressure?.contextWindow !== void 0 && pressure.contextWindow > 0 ? pressure.contextWindow : DEFAULT_CONTEXT_WINDOW;
|
|
487
617
|
}
|
|
488
618
|
/** Settings form appended to the old host's context meter panel. */
|
|
489
|
-
function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings, setSetting, unsetSetting, t }) {
|
|
490
|
-
const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
|
|
619
|
+
function ContextSizeControl({ contextWindow, sessionId: _sessionId, useSessions: _useSessions, useSettings, setSetting, unsetSetting, t }) {
|
|
491
620
|
const snapshot = useSettings((state) => state);
|
|
492
|
-
if (!isCodexPresetId(agentPreset)) return null;
|
|
493
621
|
const configured = snapshot.value?.contextWindow;
|
|
494
622
|
const maxK = CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT;
|
|
495
623
|
const valueK = Math.min(maxK, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
|
|
@@ -620,8 +748,7 @@ window.__ModuleLoader__.load({
|
|
|
620
748
|
return Math.max(0, Math.floor((now - startedAt) / 1e3));
|
|
621
749
|
}
|
|
622
750
|
/** Prefer the session snapshot when an older projection host only exposes null. */
|
|
623
|
-
function resolveActivity(
|
|
624
|
-
if (!isCodexPresetId(agentPreset)) return null;
|
|
751
|
+
function resolveActivity(projectedActivity, fallbackActivity) {
|
|
625
752
|
if (projectedActivity?.activity === "awaiting-model") return {
|
|
626
753
|
activity: fallbackActivity?.activity ?? "requesting-model",
|
|
627
754
|
startedAt: fallbackActivity?.startedAt ?? projectedActivity.startedAt
|
|
@@ -629,23 +756,23 @@ window.__ModuleLoader__.load({
|
|
|
629
756
|
if (projectedActivity === null) return fallbackActivity ?? null;
|
|
630
757
|
return projectedActivity ?? fallbackActivity ?? null;
|
|
631
758
|
}
|
|
632
|
-
function ActivityLine({ sessionId, useSession, useSessions, useProjection, t, position }) {
|
|
633
|
-
const
|
|
634
|
-
const activity = resolveActivity(
|
|
759
|
+
function ActivityLine({ sessionId: _sessionId, useSession, useSessions: _useSessions, useProjection, useSettings, t, position }) {
|
|
760
|
+
const enabled = useSettings((state) => state).value?.activityIndicatorEnabled ?? true;
|
|
761
|
+
const activity = resolveActivity(useProjection("codexActivity"), useSession(modelActivity, sameModelActivity));
|
|
635
762
|
const [now, setNow] = (0, react.useState)(() => Date.now());
|
|
636
763
|
(0, react.useEffect)(() => {
|
|
637
|
-
if (!
|
|
764
|
+
if (!enabled || activity === void 0 || activity === null) return void 0;
|
|
638
765
|
setNow(Date.now());
|
|
639
766
|
const timer = setInterval(() => {
|
|
640
767
|
setNow(Date.now());
|
|
641
768
|
}, 1e3);
|
|
642
769
|
return () => clearInterval(timer);
|
|
643
770
|
}, [
|
|
644
|
-
|
|
771
|
+
enabled,
|
|
645
772
|
activity?.activity,
|
|
646
773
|
activity?.startedAt
|
|
647
774
|
]);
|
|
648
|
-
if (!
|
|
775
|
+
if (!enabled || activity === void 0 || activity === null) return null;
|
|
649
776
|
const label = activity.activity === "compaction" ? t("activityCompacting") : activity.activity === "model-reply" ? t("activityModelReply") : t("activityRequestingModel");
|
|
650
777
|
return (0, react_jsx_runtime.jsxs)("span", {
|
|
651
778
|
"data-codex-activity": true,
|
|
@@ -782,7 +909,6 @@ window.__ModuleLoader__.load({
|
|
|
782
909
|
const { contextDialog, turnStatus } = useLegacyHostTargets();
|
|
783
910
|
const turnStatusPosition = useTurnStatusPosition(turnStatus);
|
|
784
911
|
const contextWindow = contextWindowFromProjection(useProjection);
|
|
785
|
-
if (!isCodexPresetId(useSessions((state) => state.byId[sessionId]?.agentPreset))) return null;
|
|
786
912
|
return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [contextDialog !== null && (0, react_dom.createPortal)((0, react_jsx_runtime.jsx)(ContextSizeControl, {
|
|
787
913
|
contextWindow,
|
|
788
914
|
sessionId,
|
|
@@ -796,6 +922,7 @@ window.__ModuleLoader__.load({
|
|
|
796
922
|
useSession,
|
|
797
923
|
useSessions,
|
|
798
924
|
useProjection,
|
|
925
|
+
useSettings,
|
|
799
926
|
t,
|
|
800
927
|
position: turnStatusPosition
|
|
801
928
|
}), document.body, "codex-activity")] });
|