@namzu/sdk 60.2.1 → 61.1.0

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 (185) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +4 -4
  3. package/dist/account/registry.js +1 -1
  4. package/dist/account/registry.js.map +1 -1
  5. package/dist/config/registry.d.ts +2 -2
  6. package/dist/config/registry.d.ts.map +1 -1
  7. package/dist/config/runtime.d.ts +50 -644
  8. package/dist/config/runtime.d.ts.map +1 -1
  9. package/dist/config/runtime.js +1 -1
  10. package/dist/config/runtime.js.map +1 -1
  11. package/dist/connector/BaseConnector.d.ts +1 -1
  12. package/dist/connector/BaseConnector.d.ts.map +1 -1
  13. package/dist/connector/builtins/http.d.ts +2 -12
  14. package/dist/connector/builtins/http.d.ts.map +1 -1
  15. package/dist/connector/builtins/http.js +3 -3
  16. package/dist/connector/builtins/http.js.map +1 -1
  17. package/dist/connector/builtins/webhook.d.ts +2 -14
  18. package/dist/connector/builtins/webhook.d.ts.map +1 -1
  19. package/dist/connector/builtins/webhook.js +3 -3
  20. package/dist/connector/builtins/webhook.js.map +1 -1
  21. package/dist/connector/mcp/adapter.d.ts +2 -2
  22. package/dist/connector/mcp/adapter.d.ts.map +1 -1
  23. package/dist/connector/mcp/adapter.js +6 -4
  24. package/dist/connector/mcp/adapter.js.map +1 -1
  25. package/dist/connector/mcp/reconnect.d.ts +1 -11
  26. package/dist/connector/mcp/reconnect.d.ts.map +1 -1
  27. package/dist/connector/tools/adapter.d.ts +1 -11
  28. package/dist/connector/tools/adapter.d.ts.map +1 -1
  29. package/dist/connector/tools/adapter.js +1 -1
  30. package/dist/connector/tools/adapter.js.map +1 -1
  31. package/dist/connector/tools/definitions.js +1 -1
  32. package/dist/connector/tools/definitions.js.map +1 -1
  33. package/dist/contracts/a2a.d.ts +137 -1136
  34. package/dist/contracts/a2a.d.ts.map +1 -1
  35. package/dist/contracts/a2a.js +8 -8
  36. package/dist/contracts/a2a.js.map +1 -1
  37. package/dist/contracts/schemas.d.ts +7 -22
  38. package/dist/contracts/schemas.d.ts.map +1 -1
  39. package/dist/contracts/schemas.js +1 -1
  40. package/dist/contracts/schemas.js.map +1 -1
  41. package/dist/contracts/session/schemas.d.ts +35 -130
  42. package/dist/contracts/session/schemas.d.ts.map +1 -1
  43. package/dist/contracts/session/schemas.js +2 -2
  44. package/dist/contracts/session/schemas.js.map +1 -1
  45. package/dist/learning/cycle.d.ts +1 -12
  46. package/dist/learning/cycle.d.ts.map +1 -1
  47. package/dist/learning/experience.d.ts +15 -56
  48. package/dist/learning/experience.d.ts.map +1 -1
  49. package/dist/learning/observation.d.ts +13 -59
  50. package/dist/learning/observation.d.ts.map +1 -1
  51. package/dist/learning/skill.d.ts +41 -556
  52. package/dist/learning/skill.d.ts.map +1 -1
  53. package/dist/learning/store.js +1 -1
  54. package/dist/learning/store.js.map +1 -1
  55. package/dist/manager/resident/consumption.d.ts +12 -46
  56. package/dist/manager/resident/consumption.d.ts.map +1 -1
  57. package/dist/manager/resident/initiative.d.ts +3 -54
  58. package/dist/manager/resident/initiative.d.ts.map +1 -1
  59. package/dist/manager/resident/outbox.d.ts +14 -104
  60. package/dist/manager/resident/outbox.d.ts.map +1 -1
  61. package/dist/manager/resident/proposal.d.ts +6 -46
  62. package/dist/manager/resident/proposal.d.ts.map +1 -1
  63. package/dist/manager/resident/store.d.ts +14 -110
  64. package/dist/manager/resident/store.d.ts.map +1 -1
  65. package/dist/pals/activity/subscription-schema.d.ts +46 -295
  66. package/dist/pals/activity/subscription-schema.d.ts.map +1 -1
  67. package/dist/pals/channels/routing.d.ts +8 -8
  68. package/dist/pals/channels/schema.d.ts +38 -202
  69. package/dist/pals/channels/schema.d.ts.map +1 -1
  70. package/dist/pals/communication/ingress-schema.d.ts +721 -7198
  71. package/dist/pals/communication/ingress-schema.d.ts.map +1 -1
  72. package/dist/pals/communication/ingress-schema.js.map +1 -1
  73. package/dist/pals/communication/schema.d.ts +171 -1819
  74. package/dist/pals/communication/schema.d.ts.map +1 -1
  75. package/dist/peers/index.d.ts +2 -2
  76. package/dist/peers/index.d.ts.map +1 -1
  77. package/dist/peers/index.js +1 -1
  78. package/dist/peers/index.js.map +1 -1
  79. package/dist/peers/protocol.d.ts +136 -481
  80. package/dist/peers/protocol.d.ts.map +1 -1
  81. package/dist/peers/record.d.ts +56 -106
  82. package/dist/peers/record.d.ts.map +1 -1
  83. package/dist/peers/record.js +16 -0
  84. package/dist/peers/record.js.map +1 -1
  85. package/dist/public-runtime.d.ts +1 -1
  86. package/dist/public-runtime.d.ts.map +1 -1
  87. package/dist/public-runtime.js +1 -1
  88. package/dist/public-runtime.js.map +1 -1
  89. package/dist/public-types.d.ts +1 -1
  90. package/dist/public-types.d.ts.map +1 -1
  91. package/dist/registry/tool/dialect.d.ts +4 -4
  92. package/dist/registry/tool/dialect.js +4 -4
  93. package/dist/registry/tool/json-schema.d.ts +35 -0
  94. package/dist/registry/tool/json-schema.d.ts.map +1 -0
  95. package/dist/registry/tool/json-schema.js +40 -0
  96. package/dist/registry/tool/json-schema.js.map +1 -0
  97. package/dist/registry/tool/portable.js +2 -2
  98. package/dist/registry/tool/portable.js.map +1 -1
  99. package/dist/registry/tool/schema.d.ts.map +1 -1
  100. package/dist/registry/tool/schema.js +3 -6
  101. package/dist/registry/tool/schema.js.map +1 -1
  102. package/dist/store/evidence/index-page.d.ts +11 -42
  103. package/dist/store/evidence/index-page.d.ts.map +1 -1
  104. package/dist/store/evidence/search-input.d.ts +1 -1
  105. package/dist/store/evidence/search-input.d.ts.map +1 -1
  106. package/dist/store/evidence/selection.d.ts +1 -1
  107. package/dist/store/evidence/selection.d.ts.map +1 -1
  108. package/dist/store/evidence/source-text.d.ts +4 -25
  109. package/dist/store/evidence/source-text.d.ts.map +1 -1
  110. package/dist/tools/builtins/browser.d.ts +43 -267
  111. package/dist/tools/builtins/browser.d.ts.map +1 -1
  112. package/dist/tools/builtins/code-analysis.d.ts +7 -7
  113. package/dist/tools/builtins/computer-use.d.ts +138 -647
  114. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  115. package/dist/tools/builtins/edit.d.ts +5 -117
  116. package/dist/tools/builtins/edit.d.ts.map +1 -1
  117. package/dist/tools/builtins/grep.d.ts +4 -4
  118. package/dist/tools/builtins/lsp.d.ts +1 -1
  119. package/dist/tools/builtins/read-file.d.ts +2 -2
  120. package/dist/tools/builtins/skill.d.ts +2 -2
  121. package/dist/tools/builtins/view-image.d.ts +1 -5
  122. package/dist/tools/builtins/view-image.d.ts.map +1 -1
  123. package/dist/tools/builtins/wait-for-job.d.ts +2 -2
  124. package/dist/tools/builtins/web.d.ts +1 -1
  125. package/dist/tools/coordinator/index.d.ts.map +1 -1
  126. package/dist/tools/coordinator/index.js +1 -3
  127. package/dist/tools/coordinator/index.js.map +1 -1
  128. package/dist/tools/defineTool.js.map +1 -1
  129. package/dist/tools/memory/fields.d.ts +6 -1
  130. package/dist/tools/memory/fields.d.ts.map +1 -1
  131. package/dist/types/authorization/index.d.ts +82 -294
  132. package/dist/types/authorization/index.d.ts.map +1 -1
  133. package/dist/types/connector/core.d.ts +2 -2
  134. package/dist/types/connector/core.d.ts.map +1 -1
  135. package/dist/types/connector/definition.d.ts +1 -1
  136. package/dist/types/connector/definition.d.ts.map +1 -1
  137. package/dist/types/decision/index.d.ts +1 -9
  138. package/dist/types/decision/index.d.ts.map +1 -1
  139. package/dist/types/harness/schema.d.ts +121 -321
  140. package/dist/types/harness/schema.d.ts.map +1 -1
  141. package/dist/types/plugin/index.d.ts +14 -92
  142. package/dist/types/plugin/index.d.ts.map +1 -1
  143. package/dist/types/plugin/index.js +1 -1
  144. package/dist/types/plugin/index.js.map +1 -1
  145. package/dist/types/sandbox/index.d.ts +13 -47
  146. package/dist/types/sandbox/index.d.ts.map +1 -1
  147. package/dist/types/session/checkpoint.d.ts +22 -256
  148. package/dist/types/session/checkpoint.d.ts.map +1 -1
  149. package/dist/types/session/records.d.ts +889 -6072
  150. package/dist/types/session/records.d.ts.map +1 -1
  151. package/dist/types/session/records.js +2 -2
  152. package/dist/types/session/records.js.map +1 -1
  153. package/dist/types/tool/index.d.ts +1 -1
  154. package/dist/types/tool/index.d.ts.map +1 -1
  155. package/package.json +3 -5
  156. package/src/account/registry.ts +1 -1
  157. package/src/config/registry.ts +2 -2
  158. package/src/config/runtime.ts +1 -1
  159. package/src/connector/BaseConnector.ts +1 -1
  160. package/src/connector/builtins/http.ts +3 -3
  161. package/src/connector/builtins/webhook.ts +3 -3
  162. package/src/connector/mcp/adapter.ts +14 -9
  163. package/src/connector/tools/adapter.ts +1 -1
  164. package/src/connector/tools/definitions.ts +1 -1
  165. package/src/contracts/a2a.ts +8 -8
  166. package/src/contracts/schemas.ts +1 -1
  167. package/src/contracts/session/schemas.ts +2 -2
  168. package/src/learning/store.ts +1 -1
  169. package/src/pals/communication/ingress-schema.ts +1 -1
  170. package/src/peers/index.ts +2 -2
  171. package/src/peers/record.ts +20 -0
  172. package/src/public-runtime.ts +1 -0
  173. package/src/public-types.ts +1 -1
  174. package/src/registry/tool/dialect.ts +4 -4
  175. package/src/registry/tool/json-schema.ts +76 -0
  176. package/src/registry/tool/portable.ts +2 -2
  177. package/src/registry/tool/schema.ts +3 -6
  178. package/src/tools/coordinator/index.ts +2 -4
  179. package/src/tools/defineTool.ts +1 -1
  180. package/src/types/connector/core.ts +2 -2
  181. package/src/types/connector/definition.ts +1 -1
  182. package/src/types/plugin/index.ts +1 -1
  183. package/src/types/session/checkpoint.ts +1 -1
  184. package/src/types/session/records.ts +4 -8
  185. package/src/types/tool/index.ts +1 -1
@@ -23,6 +23,24 @@ import {
23
23
  /** Bumped only if the on-disk record shape changes incompatibly. */
24
24
  export const PEER_RECORD_VERSION = 1
25
25
 
26
+ /**
27
+ * One exchange this terminal took part in: who with (their short reference), which way
28
+ * it went, and when. Never the text, never a size: a host that draws who is talking to
29
+ * whom needs nothing more, and a record is readable by every process of the user.
30
+ */
31
+ export const PeerExchangeSchema = z
32
+ .object({
33
+ with: PeerRefSchema,
34
+ dir: z.enum(['in', 'out']),
35
+ at: z.number().int().nonnegative(),
36
+ })
37
+ .strict()
38
+
39
+ export type PeerExchange = z.infer<typeof PeerExchangeSchema>
40
+
41
+ /** The most recent exchanges a record keeps, newest last. A burst between two reads of a record is not lost for four or fewer. */
42
+ export const PEER_TRAIL_MAX = 4
43
+
26
44
  export const PeerRecordSchema = z
27
45
  .object({
28
46
  v: z.literal(PEER_RECORD_VERSION),
@@ -53,6 +71,8 @@ export const PeerRecordSchema = z
53
71
  limited: z.boolean().optional(),
54
72
  /** When the allowance is expected back (epoch ms); absent when the provider did not say. */
55
73
  limitedUntil: z.number().int().positive().optional(),
74
+ /** The latest exchanges with other terminals, newest last; absent for a terminal that has had none or does not report them. */
75
+ trail: z.array(PeerExchangeSchema).max(PEER_TRAIL_MAX).optional(),
56
76
  })
57
77
  .strict()
58
78
 
@@ -1865,6 +1865,7 @@ export {
1865
1865
  OUTSTANDING_EXPIRY_MS,
1866
1866
  PEER_PROTOCOL_VERSION,
1867
1867
  PEER_RECORD_VERSION,
1868
+ PEER_TRAIL_MAX,
1868
1869
  PeerAddressError,
1869
1870
  PeerClient,
1870
1871
  PeerClientError,
@@ -800,7 +800,7 @@ export type {
800
800
  PeerRuntimeDir,
801
801
  ResolvePeerRuntimeDirOptions,
802
802
  } from './peers/dir.js'
803
- export type { PeerRecord } from './peers/record.js'
803
+ export type { PeerExchange, PeerRecord } from './peers/record.js'
804
804
  export type { AccountBoundRecord } from './types/session/records.js'
805
805
  export type {
806
806
  Account,
@@ -7,9 +7,9 @@
7
7
  * at the boundary where it knows which wire it is about to talk to.
8
8
  *
9
9
  * This exists because that layering was missing and it cost a production
10
- * outage. `renderToolSchema` emits draft-07 (zod-to-json-schema's
11
- * `jsonSchema7` target), every driver forwarded it verbatim, and one of the
12
- * wires namzu speaks requires draft 2020-12. Measured against that live
10
+ * outage. `renderToolSchema` emits draft-07 (Zod's `draft-7` target), every
11
+ * driver forwarded it verbatim, and one of the wires namzu speaks requires
12
+ * draft 2020-12. Measured against that live
13
13
  * endpoint:
14
14
  *
15
15
  * | tool schema | result |
@@ -27,7 +27,7 @@
27
27
  * lives here.
28
28
  *
29
29
  * Only the conversions namzu can actually emit are implemented. The renderer
30
- * runs with `$refStrategy: 'none'`, so there are no `$ref`/`definitions` to
30
+ * inlines every reused schema, so there are no `$ref`/`definitions` to
31
31
  * rewrite; a construct that cannot appear is not worth code that cannot be
32
32
  * tested.
33
33
  */
@@ -0,0 +1,76 @@
1
+ import { z } from 'zod'
2
+
3
+ /**
4
+ * The one place a Zod schema becomes a JSON Schema document.
5
+ *
6
+ * Zod renders its own JSON Schema (`z.toJSONSchema`), and it is the only
7
+ * converter that reads a Zod 4 schema: the standalone converters walk the
8
+ * Zod 3 internals and return an empty document (`{ "$schema": ... }`) for a
9
+ * Zod 4 tree, which would put every tool on the wire as "takes anything".
10
+ *
11
+ * The raw output differs from what a model has always been shown in three
12
+ * ways that carry no information, and each would change the bytes of the
13
+ * tools block — which sits at the head of the prompt-cache prefix — for
14
+ * nothing. They are normalised here, once, so the wire stays what it was:
15
+ *
16
+ * 1. **A plain object is closed.** An object that neither allows extra keys
17
+ * nor declares a catch-all renders `additionalProperties: false`. Zod
18
+ * parses such an object by dropping unknown keys, so "closed" is the
19
+ * contract the model should be told. Rendering in the input direction
20
+ * (needed so a field with a default stays optional) omits the keyword for
21
+ * these; it is put back. An open object (`looseObject`, `.passthrough()`)
22
+ * renders `true`, not the equivalent empty schema.
23
+ *
24
+ * 2. **An integer is not bounded by the safe-integer range.** `.int()` adds
25
+ * `minimum`/`maximum` at +/- 2^53 - 1 to every integer. They restate what
26
+ * "integer" already means to a model and are removed. A bound the author
27
+ * wrote differently is kept.
28
+ *
29
+ * 3. **A named string format is not also a pattern.** A format such as
30
+ * `uuid` or `date-time` is rendered together with the very long regular
31
+ * expression that implements it. The format says it; the pattern is
32
+ * noise, and the open-API-3.0-shaped wires do not read it anyway.
33
+ */
34
+ export type JsonSchemaTarget = 'draft-7' | 'openapi-3.0'
35
+
36
+ const MAX_SAFE = Number.MAX_SAFE_INTEGER
37
+
38
+ export function zodToJsonSchema(
39
+ schema: z.ZodType,
40
+ target: JsonSchemaTarget = 'draft-7',
41
+ ): Record<string, unknown> {
42
+ // A Zod 3 schema has `safeParse` and `_def`, so it passes every shape check
43
+ // a registration makes, and then fails here with a `TypeError` about an
44
+ // internal nobody wrote. Say what is actually wrong.
45
+ if (typeof (schema as { _zod?: unknown })._zod !== 'object') {
46
+ throw new TypeError(
47
+ 'This input schema was not built with Zod 4. The kernel renders and validates tool input with Zod 4 (`zod` 4 or newer); a schema from Zod 3 cannot be described to a model.',
48
+ )
49
+ }
50
+ return z.toJSONSchema(schema, {
51
+ target,
52
+ // What a caller may send, so a field with a default stays optional.
53
+ io: 'input',
54
+ // A transform, a date or a bigint has no JSON form; it renders as
55
+ // "anything" rather than failing the whole tool.
56
+ unrepresentable: 'any',
57
+ override: ({ zodSchema, jsonSchema }) => {
58
+ const node = jsonSchema as Record<string, unknown>
59
+ if (zodSchema._zod.def.type === 'object') {
60
+ if (node.additionalProperties === undefined) node.additionalProperties = false
61
+ else if (isEmptyObject(node.additionalProperties)) node.additionalProperties = true
62
+ }
63
+ if (node.type === 'integer') {
64
+ if (node.minimum === -MAX_SAFE) delete node.minimum
65
+ if (node.maximum === MAX_SAFE) delete node.maximum
66
+ }
67
+ if (typeof node.format === 'string' && typeof node.pattern === 'string') {
68
+ delete node.pattern
69
+ }
70
+ },
71
+ }) as Record<string, unknown>
72
+ }
73
+
74
+ function isEmptyObject(value: unknown): boolean {
75
+ return typeof value === 'object' && value !== null && Object.keys(value).length === 0
76
+ }
@@ -67,8 +67,8 @@ const OUTSIDE_THE_INTERSECTION: ReadonlyMap<string, string> = new Map([
67
67
  // the function-declaration schema on one of these wires is an OpenAPI 3.0
68
68
  // subset that has never documented it.
69
69
  ['prefixItems', NO_TUPLES],
70
- // A rendered tool schema has to stand alone. The renderer already runs with
71
- // `$refStrategy: 'none'`, and the MCP bridge inlines refs before handing a
70
+ // A rendered tool schema has to stand alone. The renderer already inlines
71
+ // every reused schema, and the MCP bridge inlines refs before handing a
72
72
  // schema out, because a wire that does not resolve them sees an empty
73
73
  // constraint or refuses the document.
74
74
  ['$ref', 'inline the referenced schema; a tool schema has to stand alone'],
@@ -1,5 +1,5 @@
1
1
  import type { z } from 'zod'
2
- import { zodToJsonSchema } from 'zod-to-json-schema'
2
+ import { zodToJsonSchema } from './json-schema.js'
3
3
  import { toPortableToolSchema } from './portable.js'
4
4
 
5
5
  /**
@@ -8,7 +8,7 @@ import { toPortableToolSchema } from './portable.js'
8
8
  *
9
9
  * Two things were wrong with converting at each call site:
10
10
  *
11
- * 1. **`$schema` leaked into every request.** `zodToJsonSchema` stamps
11
+ * 1. **`$schema` leaked into every request.** the converter stamps
12
12
  * `"$schema": "http://json-schema.org/draft-07/schema#"` on the root.
13
13
  * No provider reads it, and it rides in the tools block — which renders
14
14
  * at position 0, inside the cached prefix — once per tool, per request,
@@ -40,10 +40,7 @@ export function renderToolSchema(schema: z.ZodType): Record<string, unknown> {
40
40
  const cached = CACHE.get(schema)
41
41
  if (cached) return cached
42
42
 
43
- const json = zodToJsonSchema(schema, {
44
- target: 'jsonSchema7',
45
- $refStrategy: 'none',
46
- }) as Record<string, unknown>
43
+ const json = zodToJsonSchema(schema, 'draft-7')
47
44
 
48
45
  const normalized = deepFreeze(normalizeToolSchema(json))
49
46
  CACHE.set(schema, normalized)
@@ -320,10 +320,8 @@ const approvePlanModelInputSchema: Record<string, unknown> = {
320
320
  function delegateSchema(agentIds: readonly string[]): z.ZodType<string> {
321
321
  if (agentIds.length === 0) {
322
322
  return z.never({
323
- errorMap: () => ({
324
- message:
325
- 'This turn has no delegates configured, so it cannot launch a task. That is the configured state, not a missing argument.',
326
- }),
323
+ error: () =>
324
+ 'This turn has no delegates configured, so it cannot launch a task. That is the configured state, not a missing argument.',
327
325
  }) as unknown as z.ZodType<string>
328
326
  }
329
327
  return z.enum(agentIds as [string, ...string[]])
@@ -129,7 +129,7 @@ export function defineTool<S extends z.ZodType>(
129
129
  return {
130
130
  name: options.name,
131
131
  description: options.description,
132
- inputSchema: options.inputSchema,
132
+ inputSchema: options.inputSchema as z.ZodType<TInput, unknown>,
133
133
  modelInputSchema: options.modelInputSchema,
134
134
  enforceModelInput: options.enforceModelInput,
135
135
  validationErrorHint: options.validationErrorHint,
@@ -27,13 +27,13 @@ export type ConnectorCategory =
27
27
  export interface ConnectorMethod<TInput = unknown, TOutput = unknown> {
28
28
  name: string
29
29
  description: string
30
- inputSchema: z.ZodType<TInput, z.ZodTypeDef, unknown>
30
+ inputSchema: z.ZodType<TInput, unknown>
31
31
  /**
32
32
  * Canonical output contract for this method. ConnectorManager validates a
33
33
  * successful implementation result before publishing it and exposes the
34
34
  * rendered schema to tool and MCP consumers.
35
35
  */
36
- outputSchema?: z.ZodType<TOutput, z.ZodTypeDef, unknown>
36
+ outputSchema?: z.ZodType<TOutput, unknown>
37
37
  }
38
38
 
39
39
  /**
@@ -24,7 +24,7 @@ export interface ConnectorDefinition<TConfig = unknown> {
24
24
  * Omit only when a custom connector intentionally accepts every scheme.
25
25
  */
26
26
  supportedAuth?: readonly AuthType[]
27
- configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>
27
+ configSchema: z.ZodType<TConfig, unknown>
28
28
  methods: ConnectorMethod[]
29
29
  /**
30
30
  * Declared, not implemented — see {@link ConnectorTrigger}.
@@ -560,7 +560,7 @@ export const PluginMCPServerConfigSchema = z
560
560
  name: z.string().min(1),
561
561
  command: z.string().min(1),
562
562
  args: z.array(z.string()).optional(),
563
- env: z.record(z.string()).optional(),
563
+ env: z.record(z.string(), z.string()).optional(),
564
564
  connectTimeoutMs: z.number().int().positive().max(3_600_000).optional(),
565
565
  })
566
566
  .strict()
@@ -65,7 +65,7 @@ const count = z.number().int().nonnegative().safe()
65
65
  const sha256 = z.string().regex(/^[a-f0-9]{64}$/)
66
66
  const iso = z.string().datetime({ offset: false })
67
67
  /** Annotated with the id's own alias, so declarations name it rather than expanding its brand. */
68
- function id<T extends string>(kind: EntityIdKind): z.ZodType<T, z.ZodTypeDef, unknown> {
68
+ function id<T extends string>(kind: EntityIdKind): z.ZodType<T, unknown> {
69
69
  return z.custom<T>((value) => isEntityId(value, kind), {
70
70
  message: `expected a ${kind} id (UUID)`,
71
71
  })
@@ -49,7 +49,7 @@ const isoUtc = z.string().datetime({ offset: false })
49
49
  const text = z.string()
50
50
 
51
51
  /** Annotated with the id's own alias, so declarations name `SessionId` rather than expanding its brand. */
52
- function idSchema<T extends string>(kind: EntityIdKind): z.ZodType<T, z.ZodTypeDef, unknown> {
52
+ function idSchema<T extends string>(kind: EntityIdKind): z.ZodType<T, unknown> {
53
53
  return z.custom<T>((value) => isEntityId(value, kind), {
54
54
  message: `expected a ${kind} id (UUID)`,
55
55
  })
@@ -199,7 +199,7 @@ const platformError = z
199
199
  .object({
200
200
  code: text,
201
201
  message: text,
202
- details: z.record(z.unknown()).optional(),
202
+ details: z.record(z.string(), z.unknown()).optional(),
203
203
  retryable: z.boolean(),
204
204
  })
205
205
  .strict()
@@ -219,7 +219,7 @@ const toolHandoff = z
219
219
  .object({
220
220
  kind: z.literal('human-required'),
221
221
  reason: text,
222
- detail: z.record(text).optional(),
222
+ detail: z.record(z.string(), text).optional(),
223
223
  })
224
224
  .strict()
225
225
 
@@ -799,11 +799,7 @@ const RECORD_OPTIONS = [
799
799
  ...Object.values(SPECIFIED_EVENT_SCHEMAS),
800
800
  ...Object.values(RECORD_ONLY_SCHEMAS),
801
801
  OtherEventRecordSchema,
802
- ] as unknown as [
803
- z.ZodDiscriminatedUnionOption<'type'>,
804
- z.ZodDiscriminatedUnionOption<'type'>,
805
- ...z.ZodDiscriminatedUnionOption<'type'>[],
806
- ]
802
+ ] as unknown as [z.ZodObject, z.ZodObject, ...z.ZodObject[]]
807
803
 
808
804
  /**
809
805
  * A record of a type this reader does not know, written by a newer writer
@@ -1024,7 +1024,7 @@ export type ShellDialect = 'bash' | 'sh' | 'cmd'
1024
1024
  export interface ToolDefinition<TInput = unknown> extends ToolPresentation<TInput> {
1025
1025
  name: string
1026
1026
  description: string
1027
- inputSchema: z.ZodType<TInput, z.ZodTypeDef, unknown>
1027
+ inputSchema: z.ZodType<TInput, unknown>
1028
1028
  /**
1029
1029
  * Optional canonical JSON Schema shown to models instead of the runtime
1030
1030
  * Zod schema. Use this when runtime compatibility accepts aliases or