@songtonyli/dsh-cli 0.1.73 → 0.1.74

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 CHANGED
@@ -26,7 +26,7 @@ workspace and no build step. Native packages that ship one build per platform
26
26
  ripgrep, the PTY backend's addons, sharp, koffi, and the Landlock launcher — are
27
27
  ordinary optional dependencies, so npm resolves the right one for your machine.
28
28
 
29
- Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.73; `dsh --version`
29
+ Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.74; `dsh --version`
30
30
  also reports the harness build the package was assembled from.
31
31
 
32
32
  ## License
package/bin/dsh.mjs CHANGED
@@ -18,7 +18,7 @@ const argv = process.argv.slice(2)
18
18
  // version this package publishes. Reporting only one of the two would make an
19
19
  // ordinary `npm install @songtonyli/dsh-cli@x` look like it installed something else.
20
20
  if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-V')) {
21
- console.log('@songtonyli/dsh-cli 0.1.73 (deepseek-harness 0.2.1-alpha.2)')
21
+ console.log('@songtonyli/dsh-cli 0.1.74 (deepseek-harness 0.2.1-alpha.2)')
22
22
  process.exit(0)
23
23
  }
24
24
 
@@ -167,7 +167,7 @@ window.__ModuleLoader__.load({
167
167
  const SCROLLBAR_LINGER_MS = 2e3;
168
168
  /** Format complete-build metadata for the local brand badge. */
169
169
  function localBuildVersion() {
170
- return `0.2.1-alpha.2-6f85e41` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
170
+ return `0.2.1-alpha.2-6bbe5c1` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
171
171
  }
172
172
  /** Each panel row subscribes only to its own selection state. */
173
173
  function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
@@ -18,8 +18,8 @@
18
18
  en: 192bbbb187278f91
19
19
  zh: 1f7e5632c15bdcf7
20
20
  /deepseek-ai-dsh-tui-app/use-this-package/starting-and-resuming:
21
- en: 19374746e69c8ca0
22
- zh: 211dac2851029319
21
+ en: 58a8cf392bd6a90b
22
+ zh: ff147492c5baf643
23
23
  /deepseek-ai-dsh-tui-app/use-this-package/the-screen:
24
24
  en: 7c7e0622465bd9dd
25
25
  zh: 4bada28f846ad050
@@ -36,7 +36,7 @@ dsh tui --resume <session-id> # continue an earlier session
36
36
  dsh tui --no-open # print sign-in URLs without opening a browser
37
37
  ```
38
38
 
39
- On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>` on stderr for the session bound at that moment. A resumed session redraws its persisted history before accepting input and continues with that session's last model, or the launch default when the log has no request header; inside the terminal, `/resume` and `/sessions` open the same picker over every persisted root session and resume the selected previous session, `/new` starts a fresh empty session with the launch default model, while `/clear` starts a fresh empty session that retains the current model and reasoning effort; the previous session stays on disk for `/resume`, and `/fork` copies the current session up to its last completed turn into a new one, the same cut the browser's fork takes. Switching releases the previous Agent and redraws the transcript of the next.
39
+ On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>` on stderr for the session bound at that moment. A resumed session redraws its persisted history before accepting input and continues with that session's last model, or the launch default when the log has no request header; inside the terminal, `/resume` and `/sessions` open the same picker over persisted root sessions other than the current session, newest first, and resume the selected previous session, `/new` starts a fresh empty session with the launch default model, while `/clear` starts a fresh empty session that retains the current model and reasoning effort; the previous session stays on disk for `/resume`, and `/fork` copies the current session up to its last completed turn into a new one, the same cut the browser's fork takes. Switching releases the previous Agent and redraws the transcript of the next.
40
40
 
41
41
  ### The screen
42
42
 
@@ -36,7 +36,7 @@ dsh tui --resume <session-id> # continue an earlier session
36
36
  dsh tui --no-open # print sign-in URLs without opening a browser
37
37
  ```
38
38
 
39
- 退出时应用在 stderr 为当时绑定的会话打印 `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>`。恢复的会话会在接受输入前先重绘其持久化历史,并沿用该会话上次使用的模型;日志里还没有请求头时则使用启动默认模型。在终端内,`/resume` 与 `/sessions` 打开覆盖所有持久化根会话的同一个选择器,并恢复选中的先前会话,`/new` 使用启动默认模型开始新的空会话,而 `/clear` 开始新的空会话并保留当前模型和推理强度;先前会话仍留在磁盘上可用 `/resume` 恢复,`/fork` 把当前会话复制到其最后一个完成轮次并作为新会话,切割点与浏览器的 fork 相同。切换会释放先前的 Agent 并重绘下一个会话的对话记录。
39
+ 退出时应用在 stderr 为当时绑定的会话打印 `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>`。恢复的会话会在接受输入前先重绘其持久化历史,并沿用该会话上次使用的模型;日志里还没有请求头时则使用启动默认模型。在终端内,`/resume` 与 `/sessions` 打开同一个选择器,按从新到旧列出当前会话以外的持久化根会话,并恢复选中的先前会话,`/new` 使用启动默认模型开始新的空会话,而 `/clear` 开始新的空会话并保留当前模型和推理强度;先前会话仍留在磁盘上可用 `/resume` 恢复,`/fork` 把当前会话复制到其最后一个完成轮次并作为新会话,切割点与浏览器的 fork 相同。切换会释放先前的 Agent 并重绘下一个会话的对话记录。
40
40
 
41
41
  ### 屏幕布局
42
42
 
@@ -12531,7 +12531,7 @@ var GuardedMainScreen = class extends TuiMainScreen {
12531
12531
  * @module @deepseek-ai/dsh-tui-app/sessions
12532
12532
  */
12533
12533
  /**
12534
- * List persisted sessions newest first, with their titles; subagent sessions are excluded.
12534
+ * List persisted sessions newest first, with their titles; the current session and subagents are excluded.
12535
12535
  *
12536
12536
  * Titles come from the live `title` projection or the durable projection
12537
12537
  * cache, the same values the browser list uses. The picker does not load
@@ -12540,19 +12540,18 @@ var GuardedMainScreen = class extends TuiMainScreen {
12540
12540
  * listing after the cache has the row.
12541
12541
  *
12542
12542
  * @param ctx - plugin context carrying the session query engine.
12543
- * @param currentId - the session the terminal drives, marked in the result.
12543
+ * @param currentId - the session the terminal drives, excluded from the result.
12544
12544
  * @param signal - cancels the listing.
12545
12545
  * @returns the choices, or an empty list when no query engine is composed.
12546
12546
  */
12547
12547
  async function listSessionChoices(ctx, currentId, signal) {
12548
12548
  const query = ctx.get("sessionQuery");
12549
12549
  if (query === void 0) return [];
12550
- return (await query.listSessions(signal)).filter((record) => record.header.origin === void 0).sort((left, right) => right.header.createdAt - left.header.createdAt).map((record) => ({
12550
+ return (await query.listSessions(signal)).filter((record) => record.header.origin === void 0 && record.header.id !== currentId).sort((left, right) => right.header.createdAt - left.header.createdAt).map((record) => ({
12551
12551
  id: record.header.id,
12552
12552
  title: sessionListTitle(ctx, record.header),
12553
12553
  cwd: record.header.cwd,
12554
- createdAt: record.header.createdAt,
12555
- current: record.header.id === currentId
12554
+ createdAt: record.header.createdAt
12556
12555
  }));
12557
12556
  }
12558
12557
  /**
@@ -12563,7 +12562,6 @@ async function listSessionChoices(ctx, currentId, signal) {
12563
12562
  function describeSession(choice) {
12564
12563
  const parts = [formatTimestamp(choice.createdAt)];
12565
12564
  if (choice.cwd !== void 0) parts.push(choice.cwd);
12566
- if (choice.current) parts.push("current");
12567
12565
  return {
12568
12566
  label: choice.title ?? choice.id,
12569
12567
  description: parts.join(" · ")
@@ -16994,7 +16992,7 @@ var TuiApp = class {
16994
16992
  const picked = await this.showModal(new PickPrompt(this.deps.palette, "Switch to a session", items), signal);
16995
16993
  if (picked === void 0 || this.operationAbandoned(bound, signal)) return;
16996
16994
  const target = choices.find((choice) => choice.id === picked.value);
16997
- if (target === void 0 || target.current) return;
16995
+ if (target === void 0) return;
16998
16996
  await this.switchSession(() => this.deps.host.resume(target.id), "resumed");
16999
16997
  }
17000
16998
  renameSession(title) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.6.5",
3
+ "version": "4.6.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -140,6 +140,33 @@ test("continue parsing despite array size error", () => {
140
140
  `);
141
141
  });
142
142
 
143
+ test("an upper size bound fails before any element is parsed", () => {
144
+ let parsed = 0;
145
+ const el = z.string().refine(() => ++parsed);
146
+ let refined = 0;
147
+ const schema = z
148
+ .array(el)
149
+ .max(2, "too many")
150
+ .refine(() => ++refined);
151
+ expect(schema.safeParse([1, 2, 3]).error!.issues).toMatchObject([{ code: "too_big", path: [], message: "too many" }]);
152
+ expect(z.array(el).length(2).safeParse(["a", "b", "c"]).error!.issues).toMatchObject([
153
+ { code: "too_big", exact: true },
154
+ ]);
155
+ expect(z.object({ a: z.array(el).max(1) }).safeParse({ a: [1, 2] }).error!.issues).toMatchObject([
156
+ { code: "too_big", path: ["a"] },
157
+ ]);
158
+ expect([parsed, refined]).toEqual([0, 0]);
159
+
160
+ // a check that may rewrite the value ends the gate
161
+ expect(
162
+ z
163
+ .array(z.number())
164
+ .overwrite((a) => a.slice(0, 2))
165
+ .max(2)
166
+ .parse([1, 2, 3])
167
+ ).toEqual([1, 2]);
168
+ });
169
+
143
170
  test("parse should fail given sparse array", () => {
144
171
  const schema = z.array(z.string()).nonempty().min(1).max(3);
145
172
  const result = schema.safeParse(new Array(3));
@@ -97,6 +97,13 @@ test("failing when map is bigger than max() ", () => {
97
97
  expect(result.success).toEqual(false);
98
98
  expect(result.error!.issues.length).toEqual(1);
99
99
  expect(result.error!.issues[0].code).toEqual("too_big");
100
+ const bad = new Map([
101
+ [1, 1],
102
+ [2, 2],
103
+ ]);
104
+ const capped = z.map(z.string(), z.string()).max(1);
105
+ expect(capped.safeParse(bad).error!.issues).toMatchObject([{ code: "too_big" }]);
106
+ expect(capped.safeParse(new Set([1, 2])).error!.issues[0]).toMatchObject({ code: "invalid_type", expected: "map" });
100
107
  });
101
108
 
102
109
  test("failing when map does not match size() ", () => {
@@ -83,6 +83,12 @@ test("failing when set is bigger than max() ", () => {
83
83
  expect(result.success).toEqual(false);
84
84
  expect(result.error!.issues.length).toEqual(1);
85
85
  expect(result.error!.issues[0].code).toEqual("too_big");
86
+ expect(
87
+ z
88
+ .set(z.string())
89
+ .max(1)
90
+ .safeParse(new Set([1, 2])).error!.issues
91
+ ).toMatchObject([{ code: "too_big" }]);
86
92
  });
87
93
 
88
94
  test("failing when set does not match size() ", () => {
@@ -1551,6 +1551,12 @@ function generateNullableCheck(
1551
1551
  return outputVar;
1552
1552
  }
1553
1553
 
1554
+ function generateSizeGate(doc: Doc, schema: SomeType, size: string): void {
1555
+ for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
1556
+ doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
1557
+ }
1558
+ }
1559
+
1554
1560
  function generateArrayCheck(
1555
1561
  doc: Doc,
1556
1562
  ctx: CompileContext,
@@ -1560,6 +1566,7 @@ function generateArrayCheck(
1560
1566
  ): string | null {
1561
1567
  const def = schema._zod.def as unknown as { element: SomeType };
1562
1568
  doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
1569
+ generateSizeGate(doc, schema, `${accessor}.length`);
1563
1570
 
1564
1571
  // Build a new array with validated/transformed elements.
1565
1572
  const outputVar = buildsValue ? newVar(ctx) : null;
@@ -2094,6 +2101,7 @@ function generateMapCheck(doc: Doc, ctx: CompileContext, schema: SomeType, acces
2094
2101
  const def = schema._zod.def as unknown as { keyType: SomeType; valueType: SomeType };
2095
2102
 
2096
2103
  doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
2104
+ generateSizeGate(doc, schema, `${accessor}.size`);
2097
2105
 
2098
2106
  const outputVar = newVar(ctx);
2099
2107
  const kVar = newVar(ctx);
@@ -2115,6 +2123,7 @@ function generateSetCheck(doc: Doc, ctx: CompileContext, schema: SomeType, acces
2115
2123
  const def = schema._zod.def as unknown as { valueType: SomeType };
2116
2124
 
2117
2125
  doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
2126
+ generateSizeGate(doc, schema, `${accessor}.size`);
2118
2127
 
2119
2128
  const outputVar = newVar(ctx);
2120
2129
  const valVar = newVar(ctx);
@@ -1844,6 +1844,34 @@ export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$Zod
1844
1844
 
1845
1845
  export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {}
1846
1846
 
1847
+ // an oversized container fails its leading size checks before any element is parsed
1848
+ function capSize(inst: $ZodType, size: (input: any) => number): void {
1849
+ const caps = util.sizeCaps(inst._zod.def.checks);
1850
+ if (!caps.length) return;
1851
+ const cap = Math.min(...caps.map((c) => c[0]));
1852
+ const parse = inst._zod.parse;
1853
+ inst._zod.parse = (payload, ctx) => {
1854
+ const n = size(payload.value);
1855
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
1856
+ for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
1857
+ if (n > max && ch._zod.def.when!(payload)) {
1858
+ const start = payload.issues.length;
1859
+ ch._zod.check(payload as ParsePayload<never>);
1860
+ // the value is still the raw input, so no later check may read it
1861
+ (payload.issues[start] as { continue?: boolean }).continue = false;
1862
+ util.attachSchema(payload.issues, start, inst);
1863
+ return payload;
1864
+ }
1865
+ }
1866
+ }
1867
+ return parse(payload, ctx);
1868
+ };
1869
+ }
1870
+
1871
+ const arraySize = (input: unknown): number => (Array.isArray(input) ? input.length : -1);
1872
+ const mapSize = (input: unknown): number => (input instanceof Map ? input.size : -1);
1873
+ const setSize = (input: unknown): number => (input instanceof Set ? input.size : -1);
1874
+
1847
1875
  function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>, index: number) {
1848
1876
  if (result.issues.length) {
1849
1877
  final.issues.push(...util.prefixIssues(index, result.issues));
@@ -1899,6 +1927,7 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
1899
1927
 
1900
1928
  return payload; //handleArrayResultsAsync(parseResults, final);
1901
1929
  };
1930
+ capSize(inst, arraySize);
1902
1931
  });
1903
1932
 
1904
1933
  //////////////////////////////////////////
@@ -3218,8 +3247,11 @@ export type $InferZodRecordInput<
3218
3247
  : Record<core.input<Key> & PropertyKey, core.input<Value>>;
3219
3248
 
3220
3249
  export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
3221
- extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
3250
+ extends $ZodTypeInternals {
3222
3251
  def: $ZodRecordDef<Key, Value>;
3252
+ // members rather than base type arguments, which TypeScript 7.1 reports as circular for `z.json()`
3253
+ output: $InferZodRecordOutput<Key, Value>;
3254
+ input: $InferZodRecordInput<Key, Value>;
3223
3255
  isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
3224
3256
  optin?: "optional" | undefined;
3225
3257
  optout?: "optional" | undefined;
@@ -3480,6 +3512,7 @@ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$construct
3480
3512
  if (proms.length) return Promise.all(proms).then(() => payload);
3481
3513
  return payload;
3482
3514
  };
3515
+ capSize(inst, mapSize);
3483
3516
  });
3484
3517
 
3485
3518
  function handleMapResult(
@@ -3582,6 +3615,7 @@ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$construct
3582
3615
  if (proms.length) return Promise.all(proms).then(() => payload);
3583
3616
  return payload;
3584
3617
  };
3618
+ capSize(inst, setSize);
3585
3619
  });
3586
3620
 
3587
3621
  function handleSetResult(result: ParsePayload, final: ParsePayload<Set<any>>) {
@@ -935,6 +935,19 @@ export function unwrapMessage(message: string | { message: string } | undefined
935
935
  }
936
936
 
937
937
  /* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
938
+ /** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
939
+ export function sizeCaps(defChecks: checks.$ZodCheck<never>[] | undefined): [number, checks.$ZodCheck<never>][] {
940
+ const caps: [number, checks.$ZodCheck<never>][] = [];
941
+ for (const ch of defChecks ?? []) {
942
+ const d = ch._zod.def as any;
943
+ // a later check may rewrite the value
944
+ if (!/_(length|size)$|_equals$/.test(d.check)) break;
945
+ const max = d.maximum ?? d.length ?? d.size;
946
+ if (max >= 0) caps.push([max, ch]);
947
+ }
948
+ return caps;
949
+ }
950
+
938
951
  export function attachSchema(issues: errors.$ZodRawIssue[], start: number, inst: schemas.$ZodType): void {
939
952
  for (let i = start; i < issues.length; i++) {
940
953
  (issues[i] as any).schema ??= inst;
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 6,
4
- patch: 5 as number,
4
+ patch: 6 as number,
5
5
  } as const;
@@ -1241,9 +1241,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
1241
1241
  doc.write(`}`);
1242
1242
  return outputVar;
1243
1243
  }
1244
+ function generateSizeGate(doc, schema, size) {
1245
+ for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
1246
+ doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
1247
+ }
1248
+ }
1244
1249
  function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
1245
1250
  const def = schema._zod.def;
1246
1251
  doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
1252
+ generateSizeGate(doc, schema, `${accessor}.length`);
1247
1253
  // Build a new array with validated/transformed elements.
1248
1254
  const outputVar = buildsValue ? newVar(ctx) : null;
1249
1255
  const iVar = newVar(ctx);
@@ -1707,6 +1713,7 @@ function literalPropertyKey(ctx, key) {
1707
1713
  function generateMapCheck(doc, ctx, schema, accessor) {
1708
1714
  const def = schema._zod.def;
1709
1715
  doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
1716
+ generateSizeGate(doc, schema, `${accessor}.size`);
1710
1717
  const outputVar = newVar(ctx);
1711
1718
  const kVar = newVar(ctx);
1712
1719
  const valVar = newVar(ctx);
@@ -1723,6 +1730,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
1723
1730
  function generateSetCheck(doc, ctx, schema, accessor) {
1724
1731
  const def = schema._zod.def;
1725
1732
  doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
1733
+ generateSizeGate(doc, schema, `${accessor}.size`);
1726
1734
  const outputVar = newVar(ctx);
1727
1735
  const valVar = newVar(ctx);
1728
1736
  doc.write(`const ${outputVar} = new Set();`);
@@ -1210,9 +1210,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
1210
1210
  doc.write(`}`);
1211
1211
  return outputVar;
1212
1212
  }
1213
+ function generateSizeGate(doc, schema, size) {
1214
+ for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
1215
+ doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
1216
+ }
1217
+ }
1213
1218
  function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
1214
1219
  const def = schema._zod.def;
1215
1220
  doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
1221
+ generateSizeGate(doc, schema, `${accessor}.length`);
1216
1222
  // Build a new array with validated/transformed elements.
1217
1223
  const outputVar = buildsValue ? newVar(ctx) : null;
1218
1224
  const iVar = newVar(ctx);
@@ -1676,6 +1682,7 @@ function literalPropertyKey(ctx, key) {
1676
1682
  function generateMapCheck(doc, ctx, schema, accessor) {
1677
1683
  const def = schema._zod.def;
1678
1684
  doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
1685
+ generateSizeGate(doc, schema, `${accessor}.size`);
1679
1686
  const outputVar = newVar(ctx);
1680
1687
  const kVar = newVar(ctx);
1681
1688
  const valVar = newVar(ctx);
@@ -1692,6 +1699,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
1692
1699
  function generateSetCheck(doc, ctx, schema, accessor) {
1693
1700
  const def = schema._zod.def;
1694
1701
  doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
1702
+ generateSizeGate(doc, schema, `${accessor}.size`);
1695
1703
  const outputVar = newVar(ctx);
1696
1704
  const valVar = newVar(ctx);
1697
1705
  doc.write(`const ${outputVar} = new Set();`);
@@ -860,6 +860,33 @@ exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
860
860
  return payload;
861
861
  };
862
862
  });
863
+ // an oversized container fails its leading size checks before any element is parsed
864
+ function capSize(inst, size) {
865
+ const caps = util.sizeCaps(inst._zod.def.checks);
866
+ if (!caps.length)
867
+ return;
868
+ const cap = Math.min(...caps.map((c) => c[0]));
869
+ const parse = inst._zod.parse;
870
+ inst._zod.parse = (payload, ctx) => {
871
+ const n = size(payload.value);
872
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
873
+ for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
874
+ if (n > max && ch._zod.def.when(payload)) {
875
+ const start = payload.issues.length;
876
+ ch._zod.check(payload);
877
+ // the value is still the raw input, so no later check may read it
878
+ payload.issues[start].continue = false;
879
+ util.attachSchema(payload.issues, start, inst);
880
+ return payload;
881
+ }
882
+ }
883
+ }
884
+ return parse(payload, ctx);
885
+ };
886
+ }
887
+ const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
888
+ const mapSize = (input) => (input instanceof Map ? input.size : -1);
889
+ const setSize = (input) => (input instanceof Set ? input.size : -1);
863
890
  function handleArrayResult(result, final, index) {
864
891
  if (result.issues.length) {
865
892
  final.issues.push(...util.prefixIssues(index, result.issues));
@@ -905,6 +932,7 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
905
932
  }
906
933
  return payload; //handleArrayResultsAsync(parseResults, final);
907
934
  };
935
+ capSize(inst, arraySize);
908
936
  });
909
937
  function handlePropertyResult(result, final, key, input, optin, optout) {
910
938
  const isPresent = key in input;
@@ -1942,6 +1970,7 @@ exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
1942
1970
  return Promise.all(proms).then(() => payload);
1943
1971
  return payload;
1944
1972
  };
1973
+ capSize(inst, mapSize);
1945
1974
  });
1946
1975
  function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1947
1976
  if (keyResult.issues.length) {
@@ -2011,6 +2040,7 @@ exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
2011
2040
  return Promise.all(proms).then(() => payload);
2012
2041
  return payload;
2013
2042
  };
2043
+ capSize(inst, setSize);
2014
2044
  });
2015
2045
  function handleSetResult(result, final) {
2016
2046
  if (result.issues.length) {
@@ -816,6 +816,33 @@ export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def)
816
816
  return payload;
817
817
  };
818
818
  });
819
+ // an oversized container fails its leading size checks before any element is parsed
820
+ function capSize(inst, size) {
821
+ const caps = util.sizeCaps(inst._zod.def.checks);
822
+ if (!caps.length)
823
+ return;
824
+ const cap = Math.min(...caps.map((c) => c[0]));
825
+ const parse = inst._zod.parse;
826
+ inst._zod.parse = (payload, ctx) => {
827
+ const n = size(payload.value);
828
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
829
+ for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
830
+ if (n > max && ch._zod.def.when(payload)) {
831
+ const start = payload.issues.length;
832
+ ch._zod.check(payload);
833
+ // the value is still the raw input, so no later check may read it
834
+ payload.issues[start].continue = false;
835
+ util.attachSchema(payload.issues, start, inst);
836
+ return payload;
837
+ }
838
+ }
839
+ }
840
+ return parse(payload, ctx);
841
+ };
842
+ }
843
+ const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
844
+ const mapSize = (input) => (input instanceof Map ? input.size : -1);
845
+ const setSize = (input) => (input instanceof Set ? input.size : -1);
819
846
  function handleArrayResult(result, final, index) {
820
847
  if (result.issues.length) {
821
848
  final.issues.push(...util.prefixIssues(index, result.issues));
@@ -861,6 +888,7 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
861
888
  }
862
889
  return payload; //handleArrayResultsAsync(parseResults, final);
863
890
  };
891
+ capSize(inst, arraySize);
864
892
  });
865
893
  function handlePropertyResult(result, final, key, input, optin, optout) {
866
894
  const isPresent = key in input;
@@ -1898,6 +1926,7 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
1898
1926
  return Promise.all(proms).then(() => payload);
1899
1927
  return payload;
1900
1928
  };
1929
+ capSize(inst, mapSize);
1901
1930
  });
1902
1931
  function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1903
1932
  if (keyResult.issues.length) {
@@ -1967,6 +1996,7 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
1967
1996
  return Promise.all(proms).then(() => payload);
1968
1997
  return payload;
1969
1998
  };
1999
+ capSize(inst, setSize);
1970
2000
  });
1971
2001
  function handleSetResult(result, final) {
1972
2002
  if (result.issues.length) {
@@ -46,6 +46,7 @@ exports.aborted = aborted;
46
46
  exports.explicitlyAborted = explicitlyAborted;
47
47
  exports.prefixIssues = prefixIssues;
48
48
  exports.unwrapMessage = unwrapMessage;
49
+ exports.sizeCaps = sizeCaps;
49
50
  exports.attachSchema = attachSchema;
50
51
  exports.finalizeIssue = finalizeIssue;
51
52
  exports.getSizableOrigin = getSizableOrigin;
@@ -620,6 +621,20 @@ function unwrapMessage(message) {
620
621
  return typeof message === "string" ? message : message?.message;
621
622
  }
622
623
  /* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
624
+ /** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
625
+ function sizeCaps(defChecks) {
626
+ const caps = [];
627
+ for (const ch of defChecks ?? []) {
628
+ const d = ch._zod.def;
629
+ // a later check may rewrite the value
630
+ if (!/_(length|size)$|_equals$/.test(d.check))
631
+ break;
632
+ const max = d.maximum ?? d.length ?? d.size;
633
+ if (max >= 0)
634
+ caps.push([max, ch]);
635
+ }
636
+ return caps;
637
+ }
623
638
  function attachSchema(issues, start, inst) {
624
639
  var _a;
625
640
  for (let i = start; i < issues.length; i++) {
@@ -550,6 +550,20 @@ export function unwrapMessage(message) {
550
550
  return typeof message === "string" ? message : message?.message;
551
551
  }
552
552
  /* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
553
+ /** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
554
+ export function sizeCaps(defChecks) {
555
+ const caps = [];
556
+ for (const ch of defChecks ?? []) {
557
+ const d = ch._zod.def;
558
+ // a later check may rewrite the value
559
+ if (!/_(length|size)$|_equals$/.test(d.check))
560
+ break;
561
+ const max = d.maximum ?? d.length ?? d.size;
562
+ if (max >= 0)
563
+ caps.push([max, ch]);
564
+ }
565
+ return caps;
566
+ }
553
567
  export function attachSchema(issues, start, inst) {
554
568
  var _a;
555
569
  for (let i = start; i < issues.length; i++) {
@@ -4,7 +4,7 @@ exports.version = void 0;
4
4
  exports.version = {
5
5
  major: 4,
6
6
  minor: 6,
7
- patch: 5,
7
+ patch: 6,
8
8
  };
9
9
 
10
10
  // seal-cjs-exports
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 6,
4
- patch: 5,
4
+ patch: 6,
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.73",
3
+ "version": "0.1.74",
4
4
  "description": "The dsh terminal agent: an interactive TUI over the DeepSeek Harness, with its whole Node runtime bundled in one install.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -602,7 +602,7 @@
602
602
  "xmlchars": "2.2.0",
603
603
  "yaml": "2.9.1",
604
604
  "yoctocolors": "2.2.0",
605
- "zod": "4.6.5",
605
+ "zod": "4.6.6",
606
606
  "zwitch": "2.0.4"
607
607
  },
608
608
  "optionalDependencies": {