@shuind/dsh-codex-harness 0.3.1 → 0.3.3

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 (86) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +21 -43
  3. package/docs/preset-library.md +2 -2
  4. package/docs/tool-policy.md +1 -1
  5. package/lib/client.js +1738 -327
  6. package/lib/compact-command.js +7 -1
  7. package/lib/compaction.js +7 -1
  8. package/lib/hybrid-executor.js +23 -12
  9. package/lib/index.js +1266 -36
  10. package/lib/preferences.js +21 -2
  11. package/lib/tool-policy.js +11 -2
  12. package/lib/typert.js +42 -1
  13. package/lib/types/client/desktop.d.ts +20 -42
  14. package/lib/types/client/desktop.js +191 -126
  15. package/lib/types/client/index.d.ts +104 -28
  16. package/lib/types/client/index.js +97 -15
  17. package/lib/types/client/policy-drafts.d.ts +18 -0
  18. package/lib/types/client/policy-drafts.js +27 -0
  19. package/lib/types/client/policy-locale.d.ts +80 -20
  20. package/lib/types/client/policy-locale.js +197 -80
  21. package/lib/types/client/preset-manager.d.ts +25 -2
  22. package/lib/types/client/preset-manager.js +89 -5
  23. package/lib/types/client/preset-requests.d.ts +44 -1
  24. package/lib/types/client/preset-requests.js +150 -0
  25. package/lib/types/client/tool-policy.d.ts +7 -2
  26. package/lib/types/client/tool-policy.js +48 -6
  27. package/lib/types/contracts/preset-editor-schema.d.ts +35 -0
  28. package/lib/types/contracts/preset-editor-schema.js +39 -0
  29. package/lib/types/contracts/settings.d.ts +12 -0
  30. package/lib/types/contracts/settings.js +10 -1
  31. package/lib/types/contracts/ui-contracts.d.ts +52 -0
  32. package/lib/types/contracts/ui-contracts.js +58 -0
  33. package/lib/types/contracts/update.d.ts +73 -0
  34. package/lib/types/contracts/update.js +291 -0
  35. package/lib/types/entries/index.js +20 -2
  36. package/lib/types/entries/preferences.d.ts +2 -0
  37. package/lib/types/entries/preferences.js +9 -0
  38. package/lib/types/hybrid/hybrid-sdk.d.ts +1 -1
  39. package/lib/types/hybrid/hybrid-sdk.js +27 -13
  40. package/lib/types/presets/preset-editor.d.ts +13 -1
  41. package/lib/types/presets/preset-editor.js +24 -1
  42. package/lib/types/presets/pro-mode-store.d.ts +13 -0
  43. package/lib/types/presets/pro-mode-store.js +69 -0
  44. package/lib/types/responses/background-sse-codec.d.ts +23 -0
  45. package/lib/types/responses/background-sse-codec.js +230 -0
  46. package/lib/types/responses/background-stream.d.ts +28 -0
  47. package/lib/types/responses/background-stream.js +351 -0
  48. package/lib/types/responses/compact-checkpoint.js +3 -10
  49. package/lib/types/responses/fetch-transport.js +24 -9
  50. package/lib/types/responses/remote-compact.js +39 -11
  51. package/lib/types/responses/wire-rewrite.d.ts +4 -0
  52. package/lib/types/responses/wire-rewrite.js +30 -4
  53. package/lib/types/tools/codex-subagent.d.ts +14 -0
  54. package/lib/types/tools/codex-subagent.js +269 -0
  55. package/lib/types/update/checker.d.ts +14 -0
  56. package/lib/types/update/checker.js +166 -0
  57. package/locale/en.json +1 -1
  58. package/locale/hybrid-executor/en.json +1 -1
  59. package/locale/hybrid-executor/zh.json +1 -1
  60. package/locale/zh.json +1 -1
  61. package/package.json +6 -2
  62. package/src/client/desktop.tsx +370 -153
  63. package/src/client/index.tsx +122 -22
  64. package/src/client/policy-drafts.ts +45 -0
  65. package/src/client/policy-locale.ts +197 -80
  66. package/src/client/preset-manager.tsx +125 -4
  67. package/src/client/preset-requests.ts +185 -1
  68. package/src/client/tool-policy.tsx +63 -9
  69. package/src/contracts/preset-editor-schema.ts +44 -0
  70. package/src/contracts/settings.ts +20 -1
  71. package/src/contracts/ui-contracts.ts +91 -0
  72. package/src/contracts/update.ts +307 -0
  73. package/src/entries/index.ts +25 -2
  74. package/src/entries/preferences.ts +9 -0
  75. package/src/hybrid/hybrid-sdk.ts +28 -12
  76. package/src/presets/preset-editor.ts +31 -3
  77. package/src/presets/pro-mode-store.ts +80 -0
  78. package/src/responses/background-sse-codec.ts +237 -0
  79. package/src/responses/background-stream.ts +371 -0
  80. package/src/responses/compact-checkpoint.ts +2 -8
  81. package/src/responses/fetch-transport.ts +28 -9
  82. package/src/responses/remote-compact.ts +41 -11
  83. package/src/responses/wire-rewrite.ts +34 -3
  84. package/src/tools/codex-subagent.ts +290 -0
  85. package/src/update/checker.ts +193 -0
  86. package/tsdown.config.ts +4 -0
@@ -5,6 +5,7 @@ import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
5
5
  //#region lib/types/contracts/ui-contracts.js
6
6
  const CODEX_CONTEXT_MAX = 1e6;
7
7
  const OPENAI_CODEX_SETTINGS_NAMESPACE = "llm-openai-codex";
8
+ const CODEX_SUBAGENT_DEFAULT_PRESET = "codex-hybrid";
8
9
  //#endregion
9
10
  //#region lib/types/contracts/prompt.js
10
11
  /** Default plugin-owned Codex operating prompt. */
@@ -73,6 +74,7 @@ const CODEX_SETTINGS_NAMESPACE = "codex";
73
74
  z.object({
74
75
  fast: z.boolean().default(false),
75
76
  fastModeControlEnabled: z.boolean().default(true),
77
+ proModeControlEnabled: z.boolean().default(true),
76
78
  contextWindowControlEnabled: z.boolean().default(true),
77
79
  contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX).hidden(),
78
80
  persona: z.string().default(DEFAULT_CODEX_PERSONA),
@@ -85,7 +87,11 @@ z.object({
85
87
  planToolEnabled: z.boolean().default(true).hidden(),
86
88
  hostedWebSearchEnabled: z.boolean().default(true),
87
89
  remoteCompactionEnabled: z.boolean().default(true),
88
- activityIndicatorEnabled: z.boolean().default(true)
90
+ activityIndicatorEnabled: z.boolean().default(true),
91
+ codexSubagentEnabled: z.boolean().default(false),
92
+ codexSubagentModel: z.string(),
93
+ codexSubagentEffort: z.string(),
94
+ codexSubagentPreset: z.string().default(CODEX_SUBAGENT_DEFAULT_PRESET)
89
95
  });
90
96
  /** Host-only reads: never expose the unredacted provider configuration to clients. */
91
97
  function readHostSettings(ctx, namespace) {
package/lib/compaction.js CHANGED
@@ -3,6 +3,7 @@ import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
3
3
  import z from "@deepseek-ai/schemastery";
4
4
  //#region lib/types/contracts/ui-contracts.js
5
5
  const CODEX_CONTEXT_MAX = 1e6;
6
+ const CODEX_SUBAGENT_DEFAULT_PRESET = "codex-hybrid";
6
7
  //#endregion
7
8
  //#region lib/types/contracts/prompt.js
8
9
  /** Default plugin-owned Codex operating prompt. */
@@ -71,6 +72,7 @@ const CODEX_SETTINGS_NAMESPACE = "codex";
71
72
  z.object({
72
73
  fast: z.boolean().default(false),
73
74
  fastModeControlEnabled: z.boolean().default(true),
75
+ proModeControlEnabled: z.boolean().default(true),
74
76
  contextWindowControlEnabled: z.boolean().default(true),
75
77
  contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX).hidden(),
76
78
  persona: z.string().default(DEFAULT_CODEX_PERSONA),
@@ -83,7 +85,11 @@ z.object({
83
85
  planToolEnabled: z.boolean().default(true).hidden(),
84
86
  hostedWebSearchEnabled: z.boolean().default(true),
85
87
  remoteCompactionEnabled: z.boolean().default(true),
86
- activityIndicatorEnabled: z.boolean().default(true)
88
+ activityIndicatorEnabled: z.boolean().default(true),
89
+ codexSubagentEnabled: z.boolean().default(false),
90
+ codexSubagentModel: z.string(),
91
+ codexSubagentEffort: z.string(),
92
+ codexSubagentPreset: z.string().default(CODEX_SUBAGENT_DEFAULT_PRESET)
87
93
  });
88
94
  /** Host-only reads: never expose the unredacted provider configuration to clients. */
89
95
  function readHostSettings(ctx, namespace) {
@@ -13,11 +13,22 @@ function renderKey(name) {
13
13
  function pad(indent) {
14
14
  return " ".repeat(indent);
15
15
  }
16
- function docLines(description, indent) {
17
- if (typeof description !== "string" || description.length === 0) return [];
18
- const collapsed = description.replace(/\s+/gu, " ").trim();
19
- if (collapsed.length === 0) return [];
20
- return [`${pad(indent)}/** ${collapsed.replaceAll("*/", String.raw`*\/`)} */`];
16
+ const READ_DEFAULT_LIMIT_PATTERN = /\bDefaults to (\d+)\b/i;
17
+ const ALREADY_HAS_UPPER_BOUND = /<=|≤|at most|less than or equal|hard max/i;
18
+ function propertyConstraintHint(node, toolName, propName) {
19
+ if (toolName === "read" && propName === "limit") {
20
+ const desc = typeof node.description === "string" ? node.description : "";
21
+ if (!ALREADY_HAS_UPPER_BOUND.test(desc)) {
22
+ const match = READ_DEFAULT_LIMIT_PATTERN.exec(desc);
23
+ if (match?.[1] !== void 0) return `Hard max: <= ${match[1]} (paginate with offset)`;
24
+ }
25
+ }
26
+ }
27
+ function docLines(description, indent, hint) {
28
+ const base = typeof description === "string" ? description.replace(/\s+/gu, " ").trim() : "";
29
+ const combined = base && hint ? `${base.endsWith(".") ? base : `${base}.`} ${hint}.` : base || (hint ? `${hint}.` : "");
30
+ if (combined.length === 0) return [];
31
+ return [`${pad(indent)}/** ${combined.replaceAll("*/", String.raw`*\/`)} */`];
21
32
  }
22
33
  function renderScalar(node, type) {
23
34
  const broad = type === "integer" ? "number" : type;
@@ -28,7 +39,7 @@ function renderScalar(node, type) {
28
39
  function containsUnion(text) {
29
40
  return text.includes(" | ");
30
41
  }
31
- function renderObjectNode(node, indent) {
42
+ function renderObjectNode(node, indent, toolName) {
32
43
  const properties = node.properties ?? {};
33
44
  const required = new Set(node.required ?? []);
34
45
  const keys = Object.keys(properties).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
@@ -36,7 +47,7 @@ function renderObjectNode(node, indent) {
36
47
  for (const key of keys) {
37
48
  const child = properties[key];
38
49
  if (child === void 0) continue;
39
- lines.push(...docLines(child.description, indent + 1));
50
+ lines.push(...docLines(child.description, indent + 1, propertyConstraintHint(child, toolName, key)));
40
51
  const optional = required.has(key) ? "" : "?";
41
52
  lines.push(`${pad(indent + 1)}${renderKey(key)}${optional}: ${renderNode(child, indent + 1)};`);
42
53
  }
@@ -44,11 +55,11 @@ function renderObjectNode(node, indent) {
44
55
  if (lines.length === 0) return "{}";
45
56
  return `{\n${lines.join("\n")}\n${pad(indent)}}`;
46
57
  }
47
- function renderNode(node, indent) {
58
+ function renderNode(node, indent, toolName) {
48
59
  if (Array.isArray(node.oneOf) && node.oneOf.length > 0) return node.oneOf.map((branch) => renderNode(branch, indent)).join(" | ");
49
60
  switch (node.type) {
50
61
  case void 0: return "JsonValue";
51
- case "object": return renderObjectNode(node, indent);
62
+ case "object": return renderObjectNode(node, indent, toolName);
52
63
  case "array": {
53
64
  const itemText = node.items === void 0 ? "JsonValue" : renderNode(node.items, indent);
54
65
  return containsUnion(itemText) ? `(${itemText})[]` : `${itemText}[]`;
@@ -62,10 +73,10 @@ function renderNode(node, indent) {
62
73
  }
63
74
  }
64
75
  /** Render one supported JSON Schema node to TypeScript, degrading invalid schemas safely. */
65
- function jsonSchemaToTs(schema, indent = 0) {
76
+ function jsonSchemaToTs(schema, indent = 0, toolName) {
66
77
  try {
67
78
  assertSupportedJsonSchema(schema);
68
- return renderNode(schema, indent);
79
+ return renderNode(schema, indent, toolName);
69
80
  } catch {
70
81
  return "unknown";
71
82
  }
@@ -136,7 +147,7 @@ function renderHybridToolsSdk(schemas, language = "typescript", programFormat =
136
147
  const outputMembers = [];
137
148
  for (const schema of sorted) {
138
149
  argsMembers.push(...docLines(schema.description, 1));
139
- argsMembers.push(`${pad(1)}${renderKey(schema.name)}: ${jsonSchemaToTs(schema.parameters, 1)};`);
150
+ argsMembers.push(`${pad(1)}${renderKey(schema.name)}: ${jsonSchemaToTs(schema.parameters, 1, schema.name)};`);
140
151
  outputMembers.push(`${pad(1)}${renderKey(schema.name)}: ${jsonSchemaToTs(schema.output, 1)};`);
141
152
  }
142
153
  const declaration = [