@shuind/dsh-codex-harness 0.2.21 → 0.2.32-dsh-v0.2.2-rc.1

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.
Files changed (128) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +48 -38
  3. package/RELEASE.md +61 -0
  4. package/assets/codex.svg +5 -0
  5. package/cordis.patch.yml +150 -6
  6. package/docs/preset-library.md +39 -23
  7. package/docs/tool-policy-benchmark.json +310 -0
  8. package/docs/tool-policy.md +144 -0
  9. package/lib/client.js +1639 -111
  10. package/lib/compaction.js +17 -2
  11. package/lib/index.js +799 -188
  12. package/lib/installer.js +50 -6
  13. package/lib/preferences.js +111 -0
  14. package/lib/tool-policy.js +2235 -0
  15. package/lib/typert.js +57 -10
  16. package/lib/types/activity.d.ts +1 -1
  17. package/lib/types/activity.js +50 -14
  18. package/lib/types/client/activity.d.ts +33 -9
  19. package/lib/types/client/desktop.d.ts +43 -0
  20. package/lib/types/client/desktop.js +121 -0
  21. package/lib/types/client/entry.d.ts +10 -0
  22. package/lib/types/client/entry.js +12 -0
  23. package/lib/types/client/index.d.ts +109 -19
  24. package/lib/types/client/index.js +21 -40
  25. package/lib/types/client/policy-drafts.d.ts +25 -0
  26. package/lib/types/client/policy-drafts.js +47 -0
  27. package/lib/types/client/preset-copy.d.ts +1 -0
  28. package/lib/types/client/preset-copy.js +2 -0
  29. package/lib/types/client/preset-manager.d.ts +12 -2
  30. package/lib/types/client/preset-manager.js +70 -25
  31. package/lib/types/client/preset-requests.d.ts +12 -0
  32. package/lib/types/client/preset-requests.js +101 -0
  33. package/lib/types/client/session.d.ts +6 -0
  34. package/lib/types/client/session.js +9 -0
  35. package/lib/types/client/tool-policy.d.ts +120 -0
  36. package/lib/types/client/tool-policy.js +394 -0
  37. package/lib/types/compaction.d.ts +3 -3
  38. package/lib/types/compaction.js +6 -2
  39. package/lib/types/desktop-preset.d.ts +20 -0
  40. package/lib/types/desktop-preset.js +39 -0
  41. package/lib/types/exec.d.ts +4 -0
  42. package/lib/types/exec.js +192 -66
  43. package/lib/types/host-settings.d.ts +4 -0
  44. package/lib/types/host-settings.js +13 -0
  45. package/lib/types/index.d.ts +20 -2
  46. package/lib/types/index.js +181 -68
  47. package/lib/types/installer.js +11 -2
  48. package/lib/types/preferences.d.ts +11 -0
  49. package/lib/types/preferences.js +16 -0
  50. package/lib/types/preset-editor-remote.d.ts +2 -0
  51. package/lib/types/preset-editor-remote.js +6 -2
  52. package/lib/types/preset-editor.d.ts +12 -7
  53. package/lib/types/preset-editor.js +43 -13
  54. package/lib/types/preset-prompt-catalog-schema.d.ts +16 -0
  55. package/lib/types/preset-prompt-catalog-schema.js +11 -0
  56. package/lib/types/preset-prompt-catalog.d.ts +21 -0
  57. package/lib/types/preset-prompt-catalog.js +192 -0
  58. package/lib/types/preset-prompt-contract.d.ts +22 -0
  59. package/lib/types/preset-prompt-contract.js +3 -0
  60. package/lib/types/preset-tool-catalog-schema.d.ts +38 -0
  61. package/lib/types/preset-tool-catalog-schema.js +28 -0
  62. package/lib/types/preset-tool-catalog.d.ts +5 -0
  63. package/lib/types/preset-tool-catalog.js +51 -0
  64. package/lib/types/prompt-sections.d.ts +1 -1
  65. package/lib/types/prompt-sections.js +9 -3
  66. package/lib/types/prompt.js +4 -2
  67. package/lib/types/remote.js +23 -8
  68. package/lib/types/settings.d.ts +3 -3
  69. package/lib/types/settings.js +3 -3
  70. package/lib/types/tool-capabilities.d.ts +32 -0
  71. package/lib/types/tool-capabilities.js +42 -0
  72. package/lib/types/tool-policy-contract.d.ts +60 -0
  73. package/lib/types/tool-policy-contract.js +26 -0
  74. package/lib/types/tool-policy.d.ts +171 -0
  75. package/lib/types/tool-policy.js +367 -0
  76. package/lib/types/typert.host.d.ts +2 -2
  77. package/lib/types/typert.host.js +12 -2
  78. package/locale/en.json +6 -0
  79. package/locale/tool-policy/en.json +6 -0
  80. package/locale/tool-policy/zh.json +6 -0
  81. package/locale/zh.json +6 -0
  82. package/package.json +375 -299
  83. package/scripts/benchmark-tool-policy.mjs +186 -0
  84. package/scripts/build-preset.mjs +19 -0
  85. package/scripts/clean-build.mjs +11 -0
  86. package/src/activity-types.ts +7 -0
  87. package/src/activity.ts +158 -0
  88. package/src/client/activity.ts +82 -0
  89. package/src/client/desktop.tsx +162 -0
  90. package/src/client/entry.tsx +16 -0
  91. package/src/client/index.tsx +972 -0
  92. package/src/client/policy-drafts.ts +56 -0
  93. package/src/client/preset-copy.ts +83 -0
  94. package/src/client/preset-manager.tsx +281 -0
  95. package/src/client/preset-requests.ts +113 -0
  96. package/src/client/session.ts +11 -0
  97. package/src/client/tool-policy.tsx +380 -0
  98. package/src/compact-command.ts +112 -0
  99. package/src/compaction.ts +190 -0
  100. package/src/context.ts +15 -0
  101. package/src/desktop-preset.ts +55 -0
  102. package/src/exec.ts +570 -0
  103. package/src/host-settings.ts +17 -0
  104. package/src/index.ts +1097 -0
  105. package/src/installer.ts +172 -0
  106. package/src/invariant.ts +34 -0
  107. package/src/patch.ts +258 -0
  108. package/src/preferences.ts +17 -0
  109. package/src/preset-contract.ts +85 -0
  110. package/src/preset-editor-remote.ts +41 -0
  111. package/src/preset-editor.ts +502 -0
  112. package/src/preset-prompt-catalog-schema.ts +10 -0
  113. package/src/preset-prompt-catalog.ts +191 -0
  114. package/src/preset-prompt-contract.ts +21 -0
  115. package/src/preset-tool-catalog-schema.ts +28 -0
  116. package/src/preset-tool-catalog.ts +51 -0
  117. package/src/prompt-sections.ts +33 -0
  118. package/src/prompt.ts +62 -0
  119. package/src/remote.ts +748 -0
  120. package/src/settings.ts +79 -0
  121. package/src/tool-capabilities.ts +76 -0
  122. package/src/tool-policy-contract.ts +76 -0
  123. package/src/tool-policy.ts +388 -0
  124. package/src/typert.host.ts +119 -0
  125. package/tsconfig.json +29 -0
  126. package/tsdown.config.ts +110 -0
  127. package/lib/types/preset-templates.d.ts +0 -36
  128. package/lib/types/preset-templates.js +0 -12
package/lib/typert.js CHANGED
@@ -1,4 +1,52 @@
1
1
  import { z } from "zod";
2
+ //#region lib/types/preset-tool-catalog-schema.js
3
+ /** Shared wire codec; no Host service or browser side effects. */
4
+ const presetToolCatalogSchema = z.object({
5
+ preset: z.string(),
6
+ registeredOnly: z.literal(true),
7
+ legacyCapabilities: z.object({
8
+ terminalToolsEnabled: z.boolean().optional(),
9
+ planToolEnabled: z.boolean().optional(),
10
+ patchToolEnabled: z.boolean().optional()
11
+ }).optional(),
12
+ tools: z.array(z.object({
13
+ name: z.string(),
14
+ description: z.string(),
15
+ conditional: z.boolean(),
16
+ codexTool: z.object({
17
+ capability: z.enum([
18
+ "terminalToolsEnabled",
19
+ "planToolEnabled",
20
+ "patchToolEnabled"
21
+ ]),
22
+ presetEnabled: z.boolean(),
23
+ presetOverridesLegacy: z.boolean().optional()
24
+ }).optional(),
25
+ replacements: z.array(z.object({
26
+ action: z.enum(["codex-exec", "codex-plan"]),
27
+ tools: z.array(z.string()),
28
+ available: z.boolean(),
29
+ reason: z.enum(["conditional", "target-exists"]).optional()
30
+ }))
31
+ }))
32
+ });
33
+ //#endregion
34
+ //#region lib/types/preset-prompt-catalog-schema.js
35
+ /** Same strict codec for current and legacy Remote contracts. */
36
+ const presetPromptCatalogSchema = z.object({
37
+ preset: z.string(),
38
+ sections: z.array(z.object({
39
+ name: z.string(),
40
+ label: z.string(),
41
+ text: z.string().max(1e6),
42
+ editable: z.boolean(),
43
+ order: z.number().finite().optional(),
44
+ complete: z.boolean().optional(),
45
+ interpolate: z.boolean().optional(),
46
+ reason: z.string().optional()
47
+ })).max(200)
48
+ });
49
+ //#endregion
2
50
  //#region lib/types/typert.host.js
3
51
  const PACKAGE = "@shuind/dsh-codex-harness";
4
52
  const SERVICE = "codexPresetEditor";
@@ -47,6 +95,11 @@ const catalog = z.object({
47
95
  const codexOptionsPatch = codexOptions.partial();
48
96
  function descriptor(method, parameter, input, output) {
49
97
  const id = `${PACKAGE}#${SERVICE}/${method}`;
98
+ const codec = (typeSymbol, schema) => ({
99
+ mode: "strict",
100
+ typeSymbol,
101
+ create: () => schema
102
+ });
50
103
  return {
51
104
  id,
52
105
  service: SERVICE,
@@ -57,17 +110,9 @@ function descriptor(method, parameter, input, output) {
57
110
  name: parameter,
58
111
  wire: parameter,
59
112
  source: "json",
60
- codec: {
61
- mode: "strict",
62
- typeSymbol: `${id}:${parameter}`,
63
- schema: input
64
- }
113
+ codec: codec(`${id}:${parameter}`, input)
65
114
  }],
66
- result: {
67
- mode: "strict",
68
- typeSymbol: `${id}:result`,
69
- schema: output
70
- }
115
+ result: codec(`${id}:result`, output)
71
116
  };
72
117
  }
73
118
  const updateInput = z.object({
@@ -94,6 +139,8 @@ const TYPERT = {
94
139
  schemas: [],
95
140
  invocations: [
96
141
  descriptor("catalog", void 0, z.unknown(), catalog),
142
+ descriptor("tools", "id", z.string().min(1).max(256), presetToolCatalogSchema),
143
+ descriptor("prompts", "id", z.string().min(1).max(256), presetPromptCatalogSchema),
97
144
  descriptor("read", "id", z.string(), document),
98
145
  descriptor("update", "rawInput", updateInput, document),
99
146
  descriptor("create", "rawInput", createInput, document)
@@ -26,7 +26,7 @@ export declare const codexActivityProjection: {
26
26
  };
27
27
  readonly schema: z.ZodType<CodexActivityState, unknown, z.core.$ZodTypeInternals<CodexActivityState, unknown>>;
28
28
  readonly view: (state: CodexActivityState) => CodexActivityState;
29
- readonly stateVersion: 2;
29
+ readonly stateVersion: 3;
30
30
  };
31
31
  /** Register the optional activity unit without requiring the projection seam in every assembly. */
32
32
  export declare function registerCodexActivityProjection(ctx: Context): void;
@@ -18,14 +18,48 @@ function isTokenDelta(chunk) {
18
18
  return false;
19
19
  }
20
20
  }
21
- /** Only a non-empty model delta starts the reply phase; usage and finish frames do not. */
22
- function startsModelReply(event) {
23
- if (event.type === 'assistant/message')
24
- return true;
25
- if (event.type !== 'assistant/chunk' || typeof event.data !== 'object' || event.data === null)
26
- return false;
27
- const chunk = event.data.chunk;
28
- return chunk !== undefined && isTokenDelta(chunk);
21
+ /** Read packed v2 streams without importing a helper absent from older DSH packages. */
22
+ function streamReplyTime(stream) {
23
+ for (const value of stream) {
24
+ if (typeof value !== 'object' || value === null)
25
+ continue;
26
+ const record = value;
27
+ if (record.type === 'chunk') {
28
+ if (record.chunk !== undefined && isTokenDelta(record.chunk))
29
+ return record.time;
30
+ continue;
31
+ }
32
+ if (record.type !== 'text-chunks' && record.type !== 'reasoning-chunks' && record.type !== 'tool-call-chunks')
33
+ continue;
34
+ const fragments = record.type === 'tool-call-chunks' ? record.args : record.texts;
35
+ if (fragments === undefined || record.time0 === undefined)
36
+ continue;
37
+ let time = record.time0;
38
+ for (const [index, text] of fragments.entries()) {
39
+ if (index > 0)
40
+ time += record.dt?.[index - 1] ?? 0;
41
+ if (text !== '' || (record.type === 'tool-call-chunks' && record.name !== undefined))
42
+ return time;
43
+ }
44
+ }
45
+ return undefined;
46
+ }
47
+ /** Only a non-empty delta starts the reply phase; preserve its original stream time. */
48
+ function modelReplyTime(event) {
49
+ const data = typeof event.data === 'object' && event.data !== null
50
+ ? event.data
51
+ : undefined;
52
+ if (event.type === 'assistant/chunk') {
53
+ return data?.chunk !== undefined && isTokenDelta(data.chunk) ? event.time : undefined;
54
+ }
55
+ if (event.type === 'assistant/message' || event.type === 'assistant/attempt') {
56
+ if (data?.stream !== undefined)
57
+ return streamReplyTime(data.stream);
58
+ // Legacy/non-streaming adapters did not carry a packed stream on settlement.
59
+ if (event.type === 'assistant/message')
60
+ return event.time;
61
+ }
62
+ return undefined;
29
63
  }
30
64
  /** Persisted and wire shape of the Codex activity value. */
31
65
  export const codexActivitySchema = z.union([
@@ -56,9 +90,10 @@ export function applyCodexActivity(state, event) {
56
90
  if (event.type === 'step/start' || event.type === 'llm/retry-started') {
57
91
  return { activity: 'requesting-model', startedAt: event.time };
58
92
  }
59
- if (startsModelReply(event)
60
- && (state?.activity === 'requesting-model' || state?.activity === 'awaiting-model')) {
61
- return { activity: 'model-reply', startedAt: event.time };
93
+ if (state?.activity === 'requesting-model' || state?.activity === 'awaiting-model') {
94
+ const startedAt = modelReplyTime(event);
95
+ if (startedAt !== undefined)
96
+ return { activity: 'model-reply', startedAt };
62
97
  }
63
98
  if (event.type === 'turn/start' || event.type === 'turn/end' || event.type === 'compaction/end')
64
99
  return null;
@@ -87,12 +122,13 @@ export const codexActivityProjection = {
87
122
  // the `stateSchema`/`wire` split.
88
123
  schema: codexActivitySchema,
89
124
  view: (state) => state,
90
- stateVersion: 2,
125
+ stateVersion: 3,
91
126
  };
92
127
  /** Register the optional activity unit without requiring the projection seam in every assembly. */
93
128
  export function registerCodexActivityProjection(ctx) {
94
- ctx.inject(['sessionProjections'], (projectionCtx) => {
95
- projectionCtx.sessionProjections.register(codexActivityProjection);
129
+ ctx.inject(['sessionProjections'], async (projectionCtx) => {
130
+ // Await readiness, but do not return the new ProjectionHandle as a Cordis effect.
131
+ await projectionCtx.sessionProjections.register(codexActivityProjection);
96
132
  });
97
133
  }
98
134
  //# sourceMappingURL=activity.js.map
@@ -1,13 +1,37 @@
1
1
  /** Client-only inference used while the host activity projection frame is in flight. */
2
- import type { ConversationSnapshot } from '@deepseek-ai/dsh-client-runtime/client';
3
- export type ActivitySessionSnapshot = Pick<ConversationSnapshot, 'running'> & {
4
- /** Optional because older/newer hosts can publish the shell snapshot before the chat slice. */
5
- readonly partial?: ConversationSnapshot['partial'];
6
- readonly runningCalls?: ConversationSnapshot['runningCalls'];
7
- readonly turnTimings?: ConversationSnapshot['turnTimings'];
8
- /** Optional for hosts that predate the assembled Chat snapshot. */
9
- readonly chat?: ConversationSnapshot['chat'];
10
- };
2
+ /**
3
+ * The legacy conversation slice is no longer part of the current Session
4
+ * snapshot. Keep this fallback structural so both generations can load without
5
+ * depending on the removed dsh-client-runtime package.
6
+ */
7
+ export interface ActivitySessionSnapshot {
8
+ readonly running: boolean;
9
+ readonly partial?: {
10
+ readonly turn: number;
11
+ readonly replyStartedAt?: number | undefined;
12
+ } | null | undefined;
13
+ readonly runningCalls?: readonly unknown[] | undefined;
14
+ readonly turnTimings?: ReadonlyMap<number, {
15
+ readonly startTime: number;
16
+ readonly endTime?: number | undefined;
17
+ }> | undefined;
18
+ readonly chat?: {
19
+ readonly timeline: {
20
+ readonly turns: ReadonlyMap<number, {
21
+ readonly steps: readonly {
22
+ readonly step: number;
23
+ readonly end?: unknown;
24
+ }[];
25
+ }>;
26
+ };
27
+ readonly nodes: {
28
+ values(): Iterable<{
29
+ readonly kind: string;
30
+ readonly data: unknown;
31
+ }>;
32
+ };
33
+ } | undefined;
34
+ }
11
35
  export type CodexModelActivity = {
12
36
  activity: 'requesting-model' | 'model-reply';
13
37
  startedAt: number;
@@ -0,0 +1,43 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
3
+ import type { CodexScope, InputSettingsControlInjected } from './index.tsx';
4
+ import type { ToolPolicyBinding } from './tool-policy.tsx';
5
+ export interface DesktopConfigForm extends Pick<CodexScope, 'getSnapshot' | 'subscribe'> {
6
+ set(field: string, value: unknown): Promise<boolean>;
7
+ unset(field: string): Promise<boolean>;
8
+ mutate(ops: Array<{
9
+ op: 'set';
10
+ path: string[];
11
+ value: unknown;
12
+ } | {
13
+ op: 'unset';
14
+ path: string[];
15
+ }>, expectedRevision?: number | string): Promise<boolean>;
16
+ }
17
+ interface DesktopSettingsActions extends InputSettingsControlInjected {
18
+ saveSettings(edits: Record<string, unknown>, expectedRevision?: number | string): Promise<void>;
19
+ toolPolicy?: ToolPolicyBinding;
20
+ }
21
+ export declare function adaptConfigForm(form: Pick<DesktopConfigForm, 'getSnapshot' | 'subscribe' | 'set' | 'unset'>): CodexScope;
22
+ export declare function saveDesktopSettings(form: Pick<DesktopConfigForm, 'mutate'>, edits: Record<string, unknown>, expectedRevision?: number | string): Promise<void>;
23
+ type DesktopSettingsProps = InjectFace<DesktopSettingsActions> & PropsLocale<'codex'>;
24
+ type SettingsPage = 'tools' | 'runtime' | 'advanced';
25
+ /** There is intentionally no second editable form on a bundle detail page. */
26
+ export declare function DesktopSettingsCard({ t }: DesktopSettingsProps & {
27
+ view: 'summary' | 'page';
28
+ }): import("react").JSX.Element;
29
+ /** Kept mounted while inactive, so switching pages preserves runtime drafts. */
30
+ export declare function RuntimeSettingsEditor({ active, ...props }: DesktopSettingsProps & {
31
+ active: boolean;
32
+ }): import("react").JSX.Element | null;
33
+ export declare function CodexSettingsTab(props: DesktopSettingsProps & {
34
+ initialPage?: SettingsPage;
35
+ }): import("react").JSX.Element;
36
+ export declare const inject: string[];
37
+ export declare function apply(ctx: Context): void;
38
+ declare const _default: {
39
+ inject: string[];
40
+ apply: typeof apply;
41
+ };
42
+ export default _default;
43
+ //# sourceMappingURL=desktop.d.ts.map
@@ -0,0 +1,121 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /** A single Settings workspace; the bundle page is only a signpost. */
3
+ import { useState } from 'react';
4
+ import { applyWithSettingsApi } from "./index.js";
5
+ import { CODEX_CONTEXT_MAX } from "../context.js";
6
+ import { bindToolPolicy, ToolPolicySection } from "./tool-policy.js";
7
+ export function adaptConfigForm(form) {
8
+ const accepted = async (result) => { if (!await result)
9
+ throw new Error('The host did not accept the settings change.'); };
10
+ return { getSnapshot: () => form.getSnapshot(), subscribe: listener => form.subscribe(listener),
11
+ set: (field, value) => accepted(form.set(field, value)), unset: field => accepted(form.unset(field)) };
12
+ }
13
+ export async function saveDesktopSettings(form, edits, expectedRevision) {
14
+ const ops = Object.entries(edits).map(([field, value]) => value === undefined ? { op: 'unset', path: [field] } : { op: 'set', path: [field], value });
15
+ if (!ops.length)
16
+ return;
17
+ const accepted = expectedRevision === undefined ? await form.mutate(ops) : await form.mutate(ops, expectedRevision);
18
+ if (!accepted)
19
+ throw new Error('The host did not accept the settings change.');
20
+ }
21
+ const desktopStyles = `
22
+ .codex-harness-settings { min-width:0; font-size:14px; color:var(--dsw-alias-label-primary); }
23
+ .codex-harness-settings h3 { font-size:14px; margin:0 0 12px; }
24
+ .codex-harness-settings .codex-harness-nav { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:16px; border-bottom:1px solid var(--dsw-alias-border-l1); padding-bottom:8px; }
25
+ .codex-harness-settings button, .codex-harness-settings input[type=number], .codex-harness-settings textarea { box-sizing:border-box; min-width:0; max-width:100%; font:inherit; color:inherit; background:var(--dsw-alias-bg-layer-2); border:1px solid var(--dsw-alias-border-l2); border-radius:8px; padding:7px 12px; }
26
+ .codex-harness-settings button { cursor:pointer; }
27
+ .codex-harness-settings button:disabled { opacity:.5; cursor:default; }
28
+ .codex-harness-settings .codex-harness-nav button { border:0; background:none; }
29
+ .codex-harness-settings .codex-harness-nav button[aria-pressed=true] { background:var(--dsw-alias-label-primary); color:var(--dsw-alias-bg-base); }
30
+ .codex-harness-settings .codex-harness-quiet { color:var(--dsw-alias-label-secondary); background:none; border:0; }
31
+ .codex-harness-settings .codex-harness-advanced-link { margin-left:auto; }
32
+ .codex-harness-settings :is(input,textarea,button,summary):focus-visible { outline:2px solid var(--dsw-alias-brand-primary); outline-offset:2px; }
33
+ .codex-harness-settings fieldset { min-width:0; border:0; padding:0; margin:0; }
34
+ .codex-harness-settings .codex-harness-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); gap:16px; }
35
+ .codex-harness-settings .codex-harness-group h4 { margin:0 0 8px; font-size:12px; font-weight:500; color:var(--dsw-alias-label-secondary); }
36
+ .codex-harness-settings .codex-harness-setting-row { min-width:0; display:flex; gap:12px; justify-content:space-between; align-items:center; padding:8px 0; }
37
+ .codex-harness-settings input[type=number] { width:140px; }
38
+ .codex-harness-settings textarea { display:block; width:100%; margin-top:8px; resize:vertical; }
39
+ .codex-harness-settings .codex-harness-note { margin:0 0 16px; color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.5; }
40
+ .codex-harness-settings .codex-harness-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:16px; }
41
+ .codex-harness-settings .codex-harness-primary { background:var(--dsw-alias-label-primary); color:var(--dsw-alias-bg-base); }
42
+ .codex-harness-settings input[role=switch] { appearance:none; width:32px; height:20px; border:1px solid var(--dsw-alias-border-l2); border-radius:16px; background:var(--dsw-alias-bg-layer-2); position:relative; cursor:pointer; flex-shrink:0; margin:0; }
43
+ .codex-harness-settings input[role=switch]:before { content:''; position:absolute; width:12px; height:12px; top:3px; left:3px; border-radius:50%; background:var(--dsw-alias-label-secondary); }
44
+ .codex-harness-settings input[role=switch]:checked { background:var(--dsw-alias-label-primary); }
45
+ .codex-harness-settings input[role=switch]:checked:before { left:15px; background:var(--dsw-alias-bg-base); }
46
+ `;
47
+ /** There is intentionally no second editable form on a bundle detail page. */
48
+ export function DesktopSettingsCard({ t }) {
49
+ return _jsxs("section", { children: [_jsx("p", { children: t('settingsBundleSummary') }), _jsx("p", { children: t('settingsBundlePath') })] });
50
+ }
51
+ /** Kept mounted while inactive, so switching pages preserves runtime drafts. */
52
+ export function RuntimeSettingsEditor({ active, ...props }) {
53
+ const { useSettings, saveSettings, t } = props;
54
+ const snapshot = useSettings(state => state);
55
+ const [draft, setDraft] = useState();
56
+ const [saving, setSaving] = useState(false);
57
+ const [error, setError] = useState('');
58
+ const edits = draft?.edits ?? {};
59
+ const value = (field) => Object.hasOwn(edits, field) ? edits[field] === undefined ? snapshot.base?.[field] : edits[field] : snapshot.value?.[field];
60
+ const edit = (field, next) => {
61
+ setError('');
62
+ setDraft(current => ({ edits: { ...current?.edits, [field]: next }, revision: current === undefined ? snapshot.revision : current.revision }));
63
+ };
64
+ const groups = [
65
+ { label: 'globalGroupRequest', fields: [['fast', 'fast'], ['hostedWebSearchEnabled', 'settingsPreferHostedSearch'], ['remoteCompactionEnabled', 'settingsPreferRemoteCompaction']] },
66
+ { label: 'globalGroupDisplay', fields: [['fastModeControlEnabled', 'fastModeControl'], ['activityIndicatorEnabled', 'capabilityActivity']] },
67
+ ];
68
+ if (!active)
69
+ return null;
70
+ return _jsxs("section", { "aria-label": t('settingsRuntimePage'), children: [_jsxs("h3", { children: [t('settingsRuntimePage'), _jsxs("span", { className: "codex-harness-note", children: [" \u00B7 ", t('settingsRuntimeScope')] })] }), _jsx("form", { onSubmit: event => {
71
+ event.preventDefault();
72
+ if (saving || draft === undefined || !snapshot.writable || snapshot.status !== 'ready')
73
+ return;
74
+ setSaving(true);
75
+ setError('');
76
+ const submitted = draft;
77
+ void saveSettings(submitted.edits, submitted.revision).then(() => setDraft(current => current === submitted ? undefined : current))
78
+ .catch(() => setError(t('settingsSharedFailed'))).finally(() => setSaving(false));
79
+ }, children: _jsxs("fieldset", { disabled: !snapshot.writable || snapshot.status !== 'ready' || saving, children: [_jsx("div", { className: "codex-harness-grid", children: groups.map(group => _jsxs("div", { className: "codex-harness-group", children: [_jsx("h4", { children: t(group.label) }), group.fields.map(([field, label]) => _jsxs("label", { className: "codex-harness-setting-row", children: [_jsx("span", { children: t(label) }), _jsx("input", { type: "checkbox", role: "switch", "aria-label": t(label), "aria-checked": Boolean(value(field) ?? (field !== 'fast')), checked: Boolean(value(field) ?? (field !== 'fast')), onChange: event => edit(field, event.target.checked) })] }, field))] }, group.label)) }), _jsxs("label", { className: "codex-harness-setting-row", children: [t('contextSize'), " (tokens)", _jsx("input", { type: "number", min: 1, max: CODEX_CONTEXT_MAX, step: 1, value: String(value('contextWindow') ?? ''), onChange: event => edit('contextWindow', event.target.value === '' ? undefined : Number(event.target.value)) })] }), _jsxs("div", { className: "codex-harness-actions", children: [_jsx("button", { className: "codex-harness-primary", type: "submit", disabled: !Object.keys(edits).length, children: t(saving ? 'promptSaving' : 'settingsSaveRuntime') }), _jsx("button", { type: "button", disabled: draft === undefined, onClick: () => { setDraft(undefined); setError(''); }, children: t('promptDiscard') })] })] }) }), !snapshot.writable && _jsx("p", { className: "codex-harness-note", children: t('promptReadOnly') }), error && _jsx("p", { role: "alert", children: error })] });
80
+ }
81
+ export function CodexSettingsTab(props) {
82
+ const { toolPolicy, presetManager, t } = props;
83
+ const [page, setPage] = useState(props.initialPage ?? 'tools');
84
+ const [advanced, setAdvanced] = useState('details');
85
+ const mode = page === 'tools' ? 'tools' : page === 'advanced' ? advanced : 'inactive';
86
+ return _jsxs("section", { className: "codex-harness-settings", children: [_jsx("style", { children: desktopStyles }), _jsxs("nav", { className: "codex-harness-nav", "aria-label": t('settingsTabLabel'), children: [_jsxs("div", { children: [_jsx("button", { type: "button", "aria-pressed": page === 'tools', onClick: () => setPage('tools'), children: t('settingsToolsPage') }), _jsx("button", { type: "button", "aria-pressed": page === 'runtime', onClick: () => setPage('runtime'), children: t('settingsRuntimePage') })] }), _jsx("button", { className: "codex-harness-quiet codex-harness-advanced-link", type: "button", onClick: () => setPage('advanced'), children: t('settingsAdvanced') })] }), page === 'advanced' && _jsx("nav", { className: "codex-harness-nav", "aria-label": t('settingsAdvanced'), children: ['details', 'prompts', 'definition'].map(section => _jsx("button", { type: "button", "aria-pressed": advanced === section, onClick: () => setAdvanced(section), children: t(section === 'details' ? 'settingsAdvancedTools' : section === 'prompts' ? 'settingsPresetPrompts' : 'settingsDefinition') }, section)) }), toolPolicy !== undefined && _jsx(ToolPolicySection, { binding: toolPolicy, presetManager: presetManager, mode: mode, t: t }), _jsx(RuntimeSettingsEditor, { ...props, active: page === 'runtime' })] });
87
+ }
88
+ export const inject = ['commandUi', 'sessions', 'slots', 'locale', 'configForms', 'remote'];
89
+ export function apply(ctx) {
90
+ let form;
91
+ applyWithSettingsApi(ctx, {
92
+ bind: host => { form = host.configForms.get('codex'); return adaptConfigForm(form); },
93
+ register: (host, settings, manager) => {
94
+ const desktop = host;
95
+ const presetManager = { ...manager, remote: host.remote };
96
+ const t = host.locale.bind('codex');
97
+ const toolPolicy = bindToolPolicy(host, host.configForms);
98
+ const injected = () => ({ hooks: { settings }, setSetting: (field, value) => settings.set(field, value), unsetSetting: field => settings.unset(field),
99
+ presetManager, toolPolicy, saveSettings: (edits, revision) => saveDesktopSettings(form, edits, revision) });
100
+ return desktop.configForms.whileServed(['codex'], () => {
101
+ const disposers = [];
102
+ const dispose = () => { for (const off of disposers.splice(0).reverse())
103
+ off(); };
104
+ try {
105
+ disposers.push(host.slots.inject('settings.plugins.tab', () => host.slots.register({ name: 'settings.plugins.tab', id: 'codex-harness', order: 30,
106
+ label: () => t('settingsTabLabel'), locale: 'codex', inject: injected }, CodexSettingsTab)));
107
+ disposers.push(host.slots.inject('plugins.item', () => host.slots.spec?.('plugins.bundle.config') !== undefined
108
+ ? host.slots.register({ name: 'plugins.bundle.config', key: '@shuind/dsh-codex-harness', locale: 'codex', inject: injected }, DesktopSettingsCard)
109
+ : host.slots.register({ name: 'plugins.item', id: 'codex', order: 30, label: () => t('promptCardTitle'), locale: 'codex', inject: injected }, DesktopSettingsCard)));
110
+ return dispose;
111
+ }
112
+ catch (error) {
113
+ dispose();
114
+ throw error;
115
+ }
116
+ });
117
+ },
118
+ });
119
+ }
120
+ export default { inject, apply };
121
+ //# sourceMappingURL=desktop.js.map
@@ -0,0 +1,10 @@
1
+ /** One bundle for legacy settingsScope and current Web/desktop ConfigForms. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ export declare const inject: string[];
4
+ export declare function apply(ctx: Context): void;
5
+ declare const _default: {
6
+ inject: string[];
7
+ apply: typeof apply;
8
+ };
9
+ export default _default;
10
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { apply as applyWeb } from "./index.js";
2
+ import { apply as applyDesktop } from "./desktop.js";
3
+ export const inject = [
4
+ 'commandUi', 'sessions', 'slots', 'locale',
5
+ 'remote',
6
+ ];
7
+ export function apply(ctx) {
8
+ ctx.inject(['configForms'], host => applyDesktop(host));
9
+ ctx.inject(['settingsScope'], host => applyWeb(host));
10
+ }
11
+ export default { inject, apply };
12
+ //# sourceMappingURL=entry.js.map
@@ -1,12 +1,11 @@
1
1
  /** Browser controls for Codex requests and the editable operating prompt. */
2
2
  import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
3
3
  import type { Context } from '@deepseek-ai/cordis';
4
- import type { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client';
5
4
  import type { CodexActivity } from '../activity-types.ts';
6
5
  import { modelActivity } from './activity.ts';
7
6
  import type { PresetManagerActions } from './preset-manager.tsx';
8
7
  declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
9
- interface CodexSettings {
8
+ export interface CodexSettings {
10
9
  fast: boolean;
11
10
  fastModeControlEnabled: boolean;
12
11
  contextWindow?: number;
@@ -22,9 +21,22 @@ interface CodexSettings {
22
21
  remoteCompactionEnabled: boolean;
23
22
  activityIndicatorEnabled: boolean;
24
23
  }
25
- type CodexScope = SettingsScope<CodexSettings>;
24
+ /** Common observable face of legacy settingsScope and current ConfigForms. */
25
+ export interface CodexSettingsSnapshot {
26
+ readonly status: string;
27
+ readonly value?: CodexSettings | undefined;
28
+ readonly base?: Partial<CodexSettings> | undefined;
29
+ readonly user?: Partial<CodexSettings> | undefined;
30
+ readonly revision?: number | string | undefined;
31
+ readonly writable: boolean;
32
+ }
33
+ export interface CodexScope extends HostObservable<CodexSettingsSnapshot> {
34
+ set(field: string, value: unknown): Promise<void>;
35
+ unset(field: string): Promise<void>;
36
+ }
26
37
  declare const en: {
27
38
  readonly fast: "Fast mode";
39
+ readonly fastModeControl: "Show fast mode control";
28
40
  readonly fastOn: "Fast mode on (priority tier)";
29
41
  readonly fastOff: "Fast mode off";
30
42
  readonly fastStateOn: "On";
@@ -53,27 +65,100 @@ declare const en: {
53
65
  readonly capabilityCompactionHint: "Prefer the provider Responses compact endpoint before local compaction.";
54
66
  readonly capabilityActivity: "Activity indicator";
55
67
  readonly capabilityActivityHint: "Show request, reply, and compaction status beside the conversation.";
56
- readonly promptCustomizationLabel: "Prompt customization";
57
- readonly personaLabel: "Persona";
58
- readonly personaHint: "Deployment identity and role. Supports {{model}} and {{cwd}}.";
59
- readonly sourcePromptLabel: "DSH Core source instructions";
60
- readonly sourcePromptHint: "Guidance about the DSH checkout and working directory. Supports {{sourceRoot}}.";
61
- readonly webPromptLabel: "DSH Core Web instructions";
62
- readonly webPromptHint: "Guidance about this Web GUI, HMR, builds, and verification. Supports {{webUrl}}.";
63
- readonly promptRestoreAll: "Restore all prompt defaults";
64
- readonly promptLabel: "Codex operating prompt";
65
- readonly promptHint: "This is the Codex operating prompt. Persona and DSH Core instructions are edited separately above.";
66
- readonly promptUnsaved: "Unsaved";
67
68
  readonly promptDiscard: "Discard";
68
- readonly promptSave: "Save";
69
69
  readonly promptSaving: "Saving...";
70
- readonly promptSaveFailed: "Could not save the prompt.";
71
- readonly promptExpand: "Expand settings";
72
- readonly promptCollapse: "Collapse settings";
73
70
  readonly promptReadOnly: "This settings document is read-only.";
74
71
  readonly activityCompacting: "Compacting context...";
75
72
  readonly activityRequestingModel: "Requesting model...";
76
73
  readonly activityModelReply: "Model replying...";
74
+ readonly settingsTabLabel: "Codex Harness";
75
+ readonly settingsToolsPage: "Tool plans";
76
+ readonly settingsRuntimePage: "Runtime preferences";
77
+ readonly settingsAdvanced: "Advanced…";
78
+ readonly settingsAdvancedTools: "Individual tools";
79
+ readonly settingsPresetPrompts: "Preset prompts";
80
+ readonly settingsDefinition: "Original preset definition (read-only)";
81
+ readonly settingsPreferHostedSearch: "Prefer model-hosted search";
82
+ readonly settingsPreferRemoteCompaction: "Prefer remote compaction";
83
+ readonly settingsSharedFailed: "Not saved; this page’s draft is kept. Shared settings may have changed—discard this page’s draft to reload.";
84
+ readonly settingsRuntimeScope: "Shared in this environment";
85
+ readonly settingsSaveRuntime: "Save runtime preferences";
86
+ readonly settingsBundleSummary: "Configure Codex Harness in its dedicated Settings tab.";
87
+ readonly settingsBundlePath: "Settings → Plugins → Codex Harness";
88
+ readonly settingsDefinitionAbsent: "Choose a preset on Tool plans first.";
89
+ readonly globalGroupRequest: "Model requests";
90
+ readonly globalGroupTools: "Tools";
91
+ readonly globalGroupDisplay: "Display";
92
+ readonly globalPrompts: "Prompts";
93
+ readonly globalPending: "Unsaved";
94
+ readonly presetSourcesDetails: "Original preset definition (read-only)";
95
+ readonly toolPolicyTitle: "Tool plan";
96
+ readonly toolPolicyPresetChoice: "Preset";
97
+ readonly toolPolicyInvalidEntry: "Empty preset ID";
98
+ readonly toolPolicyTiming: "Applies: new/reloaded session";
99
+ readonly presetPromptsLoading: "Loading prompts…";
100
+ readonly presetPromptsFailed: "Prompts unavailable.";
101
+ readonly presetPromptsEmpty: "No prompt sections.";
102
+ readonly presetPromptsReload: "Reload prompts";
103
+ readonly presetPromptRestore: "Restore original";
104
+ readonly presetPromptReadOnly: "Read-only";
105
+ readonly presetPromptOverride: "Override";
106
+ readonly presetSummaryTools: "Tools";
107
+ readonly presetSummaryPrompts: "Prompts";
108
+ readonly toolPolicyDraftSummary: "Changes for this save";
109
+ readonly toolPolicyRuleChanged: "Preset changes";
110
+ readonly toolPolicyNoToolDelta: "No pending changes";
111
+ readonly toolPolicySearch: "Search all tools";
112
+ readonly toolPolicyFilter: "Tool filter";
113
+ readonly toolPolicyAll: "All";
114
+ readonly toolPolicyModified: "Customized";
115
+ readonly toolPolicyReplaceable: "Replaceable";
116
+ readonly toolPolicyAction: "Tool action";
117
+ readonly toolPolicyKeep: "Do not change";
118
+ readonly toolPolicyHide: "Hide";
119
+ readonly toolPolicyRestoreChoice: "Restore inherited choice";
120
+ readonly toolPolicyUnsupported: "Saved replacement unavailable";
121
+ readonly toolPolicyConditional: "Conditional";
122
+ readonly toolPolicyTargetExists: "Replacement target already exists";
123
+ readonly toolPolicyPresetDisabled: "Not enabled by the original preset";
124
+ readonly toolPolicyCommandGroup: "Commands";
125
+ readonly toolPolicyPlanGroup: "Planning";
126
+ readonly toolPolicyFileGroup: "Files";
127
+ readonly toolPolicyOtherGroup: "Other tools";
128
+ readonly toolPolicyCustomized: "customized";
129
+ readonly toolLabelPwsh: "PowerShell commands";
130
+ readonly toolLabelBash: "Shell commands";
131
+ readonly toolLabelExec: "Run commands";
132
+ readonly toolLabelStdin: "Continue an interactive command";
133
+ readonly toolLabelPlan: "Task planning";
134
+ readonly toolLabelRead: "Read files";
135
+ readonly toolLabelWrite: "Write files";
136
+ readonly toolLabelEdit: "Edit files";
137
+ readonly toolLabelPatch: "Patch files";
138
+ readonly toolLabelGlob: "Find files";
139
+ readonly toolLabelGrep: "Search file contents";
140
+ readonly toolLabelImage: "View images";
141
+ readonly toolLabelOther: "Other tool";
142
+ readonly toolPolicyToolsLoading: "Loading tools…";
143
+ readonly toolPolicyToolsEmpty: "No registered tools.";
144
+ readonly toolPolicyNoMatches: "No matching tools.";
145
+ readonly toolPolicyToolsFailed: "Tool list unavailable. Saved rules are kept.";
146
+ readonly toolPolicyToolsRefresh: "Refresh tools";
147
+ readonly toolPolicyCatalogLoading: "Loading presets…";
148
+ readonly toolPolicyCatalogEmpty: "No presets found.";
149
+ readonly toolPolicyCatalogFailed: "Preset list unavailable. Saved IDs remain selectable.";
150
+ readonly toolPolicyCatalogRetry: "Reload presets";
151
+ readonly toolPolicyEmpty: "Choose a preset";
152
+ readonly toolPolicySave: "Save this preset";
153
+ readonly toolPolicySaving: "Saving…";
154
+ readonly toolPolicyDiscard: "Discard this preset’s draft";
155
+ readonly toolPolicySaved: "This preset was saved.";
156
+ readonly toolPolicyInvalidPreset: "An empty preset ID cannot be saved.";
157
+ readonly toolPolicyDuplicatePreset: "Duplicate preset IDs cannot be saved.";
158
+ readonly toolPolicyRefused: "Not saved. This draft started from older settings; discard only this preset’s draft to reload.";
159
+ readonly toolPolicyFailed: "Save failed. This preset’s draft is kept.";
160
+ readonly toolPolicyReadOnly: "These settings are read-only.";
161
+ readonly pmRegistryReadOnly: "This host exposes read-only preset declarations. Edit global Codex settings below; creating editable preset copies is not supported here.";
77
162
  readonly peConnectionError: "Could not connect to the local service. Retry loading; if the connection still fails, reconnect the page.";
78
163
  readonly peReadError: "Could not read this preset. Retry loading or refresh the preset list.";
79
164
  readonly peRetryRead: "Retry loading";
@@ -132,7 +217,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
132
217
  };
133
218
  }
134
219
  }
135
- interface InputSettingsControlInjected {
220
+ export interface InputSettingsControlInjected {
136
221
  hooks: {
137
222
  settings: HostObservable<ReturnType<CodexScope['getSnapshot']>>;
138
223
  };
@@ -157,6 +242,11 @@ export declare function ActivityLine({ sessionId: _sessionId, useSession, useSes
157
242
  export declare function selectTurnStatus(statuses: readonly HTMLElement[]): HTMLElement | null;
158
243
  export declare const inject: string[];
159
244
  /** Mount request controls and the plugin settings card through shared slots. */
245
+ export interface ClientSettingsApi {
246
+ bind(ctx: Context): CodexScope;
247
+ register(ctx: Context, settings: CodexScope, manager: PresetManagerActions): () => void;
248
+ }
249
+ export declare function applyWithSettingsApi(ctx: Context, api: ClientSettingsApi): void;
160
250
  export declare function apply(ctx: Context): void;
161
251
  declare const _default: {
162
252
  inject: string[];