stitchkit 0.90.8 → 0.91.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 (75) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/dist/agent-runtime-coding-tools.js +4 -4
  3. package/dist/agent-runtime-harness.js +6 -6
  4. package/dist/agent-runtime-sandbox.js +4 -4
  5. package/dist/agent-runtime.js +18 -17
  6. package/dist/application-grammy.js +1 -1
  7. package/dist/application.js +3 -3
  8. package/dist/cli.js +7 -7
  9. package/dist/contract/errors-factory.d.ts +12 -0
  10. package/dist/contract/errors-factory.d.ts.map +1 -1
  11. package/dist/contract/errors.d.ts +35 -1
  12. package/dist/contract/errors.d.ts.map +1 -1
  13. package/dist/contract/index.d.ts +1 -1
  14. package/dist/contract/index.d.ts.map +1 -1
  15. package/dist/contract/index.js +4 -2
  16. package/dist/{index-nrqg8tks.js → index-0a349c33.js} +3 -3
  17. package/dist/{index-adj0pc9r.js → index-137jjs4v.js} +2 -2
  18. package/dist/{index-42f33bzd.js → index-13cjtmrw.js} +1 -1
  19. package/dist/{index-qd8gs6nf.js → index-13e1k7v9.js} +2 -2
  20. package/dist/{index-dggfq62w.js → index-1qvdwnp2.js} +10 -3
  21. package/dist/{index-scs3f1eg.js → index-2vtcmrj9.js} +8 -2
  22. package/dist/{index-xbppf54a.js → index-6kyksz9y.js} +12 -7
  23. package/dist/{index-aj9geeez.js → index-709nh7z7.js} +37 -17
  24. package/dist/{index-zkcqhxx8.js → index-a11g2kry.js} +1 -1
  25. package/dist/{index-zjze12x8.js → index-b971qjes.js} +1 -1
  26. package/dist/{index-03bvcv7r.js → index-bh70rk41.js} +3 -3
  27. package/dist/{index-bva395we.js → index-bv7mytab.js} +2 -2
  28. package/dist/{index-4yktadec.js → index-bx6yq2m4.js} +23 -495
  29. package/dist/{index-p48nc8g9.js → index-f4p4b8f6.js} +10 -11
  30. package/dist/index-kw9t5ayn.js +507 -0
  31. package/dist/{index-1ft2wrv0.js → index-mqhjmadk.js} +43 -21
  32. package/dist/{index-3yqgj323.js → index-qjeyx5t2.js} +2 -2
  33. package/dist/{index-gte38nbm.js → index-qmy6zq75.js} +1 -1
  34. package/dist/{index-w58rfj2d.js → index-qrbdq8jk.js} +1 -1
  35. package/dist/{index-mthq65vn.js → index-ya611vx3.js} +4 -4
  36. package/dist/{index-xrwgzjw8.js → index-zsqy3xfn.js} +5 -5
  37. package/dist/index.js +8 -6
  38. package/dist/node.js +6 -6
  39. package/dist/observability/bounded-logger.d.ts +2 -0
  40. package/dist/observability/bounded-logger.d.ts.map +1 -1
  41. package/dist/observability/index.js +7 -4
  42. package/dist/observability/sanitize.d.ts +15 -0
  43. package/dist/observability/sanitize.d.ts.map +1 -1
  44. package/dist/primitives.js +2 -2
  45. package/dist/remote.js +5 -5
  46. package/dist/server/implement.d.ts +33 -7
  47. package/dist/server/implement.d.ts.map +1 -1
  48. package/dist/server/index.d.ts +1 -1
  49. package/dist/server/index.d.ts.map +1 -1
  50. package/dist/server/index.js +8 -8
  51. package/dist/testing.js +6 -6
  52. package/dist/tool-invoker.js +6 -6
  53. package/dist/tools/agent.d.ts +12 -0
  54. package/dist/tools/agent.d.ts.map +1 -1
  55. package/dist/tools/cli-format.d.ts +1 -1
  56. package/dist/tools/connections/index.js +2 -2
  57. package/dist/tools/connections/mcp-envelope.d.ts +14 -4
  58. package/dist/tools/connections/mcp-envelope.d.ts.map +1 -1
  59. package/dist/tools/durability-context.d.ts +1 -1
  60. package/dist/tools/durability-context.d.ts.map +1 -1
  61. package/dist/tools/durability-port.d.ts +55 -0
  62. package/dist/tools/durability-port.d.ts.map +1 -0
  63. package/dist/tools/execute.d.ts +59 -1
  64. package/dist/tools/execute.d.ts.map +1 -1
  65. package/dist/tools/mount.d.ts +2 -2
  66. package/dist/tools/mount.d.ts.map +1 -1
  67. package/dist/tools/runtime-tool.d.ts +1 -1
  68. package/dist/tools/runtime-tool.d.ts.map +1 -1
  69. package/dist/tools.d.ts +4 -0
  70. package/dist/tools.d.ts.map +1 -1
  71. package/dist/tools.js +21 -14
  72. package/dist/tracking.js +2 -2
  73. package/llms-full.txt +212 -8
  74. package/package.json +2 -2
  75. package/dist/index-7rkhw9ec.js +0 -34
package/CHANGELOG.md CHANGED
@@ -15,6 +15,99 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
15
15
 
16
16
  ## [Unreleased]
17
17
 
18
+ ## [0.91.1] — 2026-09-22
19
+
20
+ ### Fixed
21
+
22
+ - **A refusal relayed from a discovered MCP tool no longer says "retryable" for
23
+ everything.** `mcpToolFailure` rebuilt the remote's refusal with a constant
24
+ 502 and read neither `retryable` nor `_hint` off the envelope it had just
25
+ parsed. 502 is a retryable class, so the status-derived answer was `true` for
26
+ every relayed failure there has ever been — `NOT_FOUND` included, and a model
27
+ reading it calls the missing thing again. That is the exact opposite of what
28
+ the field was added for in 0.91.0. Both fields are now carried as the remote
29
+ sent them: `retryable` only when it is a boolean, `_hint` only when it is a
30
+ string, so `0` or `'false'` stays undeclared rather than being coerced into a
31
+ decision. The status stays 502 in both branches — the failure did happen
32
+ upstream, and a declared `retryable` wins over it anyway. A remote that
33
+ declares nothing is unchanged, and the unstructured branch
34
+ (`UPSTREAM_TOOL_ERROR`) has nothing to declare and keeps the 502 default.
35
+
36
+ ## [0.91.0] — 2026-09-22
37
+
38
+ ### ⚠️ Breaking changes
39
+
40
+ - **`STITCH_ERROR_STATUS` gained `NOT_IMPLEMENTED` (501).** An exhaustive error
41
+ vocabulary must name it; without the row `defineErrors({ mapping: { exhaustive:
42
+ true } })` stops compiling and then throws at startup. The code is thrown only
43
+ by the new dev-only `onMissingHandler: 'stub'` policy, and it is registered
44
+ rather than thrown ad hoc on purpose: the framework must not emit a code its
45
+ own registry does not know, or the code travels in stitchkit's spelling past
46
+ every consumer `codeMap`.
47
+ `// before: map: { …, WAIT_TIMEOUT: 'timeout' }` →
48
+ `// after: map: { …, NOT_IMPLEMENTED: 'not_implemented', WAIT_TIMEOUT: 'timeout' }`
49
+
50
+ **Who must act:** any consumer declaring an exhaustive error vocabulary. Nobody
51
+ else: every other change in this release is additive.
52
+
53
+ ### Added
54
+
55
+ - **`beforeToolCall` may return replacement arguments.** The pipeline was
56
+ asymmetric: `lifecycle.afterHandle` could already transform the output, while
57
+ the only way to affect the input was to throw — so expanding a reference into a
58
+ value *before* validation had nowhere to stand. A returned record replaces the
59
+ arguments and is validated by the contract schema like any other input. Only a
60
+ plain object is read as a replacement: `undefined`, `null`, a `Map` from a
61
+ one-line `audit.set(...)`, the number a `push` returns — everything an existing
62
+ hook already returns — keeps today's behaviour byte for byte. `afterToolCall` reports
63
+ the caller's arguments as `args` and the replacement as `effectiveArgs`, so a
64
+ rewrite is visible as a rewrite rather than by overwriting the evidence.
65
+ - **The model-facing tool refusal carries `retryable`.** One bit decides the
66
+ model's next move — wait and retry, fix the input, or stop — and until now it
67
+ was read off the code NAME. It is resolved on the failure itself, declared or
68
+ derived from the status of the normalized error, so an application's own
69
+ `status: 429` is retryable exactly like the framework's and the answer survives
70
+ a process hop; `ErrorDefinition` may declare `retryable` where the status class
71
+ is wrong in either direction. The rule is deliberately not "any `5xx`":
72
+ `REALTIME_CONTRACT_VIOLATION` and `STREAM_ITEM_INVALID` are 500 and
73
+ deterministic. `isRetryableStatus` is exported. The field is on **every**
74
+ failed tool envelope — the CLI's JSON error and the MCP error text block gained
75
+ a key; the HTTP envelope did not.
76
+ - **`toolCallId` travels as ordinary tool-call context.** A consumer running its
77
+ own agent loop already received the outcome of every call through
78
+ `afterToolCall` — with no way to say which call it belonged to, so it
79
+ reconstructed the answer from serialized text instead. One consumer measured
80
+ five places asking "did this call fail" and getting five different answers.
81
+ `AgentToolError` and `isAgentToolError` are now exported too, so the failure can
82
+ be brand-checked instead of parsed.
83
+ - **`mountAgent({ durability })` — restartable tool bodies without
84
+ `agent-runtime`, engine included.** `step` / `sleep` / `waitFor` appear in the
85
+ handler context. The `ToolDurability` port is what a body sees; the engine,
86
+ `createLocalStepDurability`, now ships from `stitchkit/tools` beside it, with
87
+ `StepDurabilityLedger` and the ledger's row types — an application supplies two
88
+ methods over storage it already has and gets replay, absolute deadlines,
89
+ park/deliver and decode refusal instead of writing them. The engine is
90
+ self-contained, and a build check over the real chunk graph holds that the
91
+ runtime proper never follows it into `stitchkit/tools`.
92
+ - **`onMissingHandler: 'stub'` for every binding form.** A contract endpoint with
93
+ no handler is mounted as a `501` refusal instead of taking the whole application
94
+ down. For one measured situation: a dev stand under a file watcher, where adding
95
+ an endpoint is two edits by construction and the editor saves one file at a
96
+ time, so the stand is down between them for everyone using it. Both save orders
97
+ are covered — a contract ahead of its handler and a handler ahead of its
98
+ contract. `'throw'` remains the default and the only production answer, and the
99
+ compile-time exactness check is untouched.
100
+
101
+ - **A string bound for one key, wherever it sits.** `redact` / `sanitizePayload`
102
+ take `maxStringLengthByKey` and `createBoundedLogger` takes
103
+ `bounds.stringLengthByKey`. One bound for the whole record cut an error's
104
+ stack from the bottom — where the consumer's own frames are; now the ceiling
105
+ for `stack` alone can be raised. Keyed by name, not path, because the same
106
+ field sits at the top of one record and under `errorDetail` in the next. The
107
+ byte ceiling keeps the last word.
108
+
109
+ → ADR 0187.
110
+
18
111
  ## [0.90.8] — 2026-09-21
19
112
 
20
113
  ### Added
@@ -3,16 +3,16 @@ import {
3
3
  AgentCodingToolLimitsSchema,
4
4
  AgentCodingToolPathAuthorizationSchema,
5
5
  createAgentCodingTools
6
- } from "./index-3yqgj323.js";
6
+ } from "./index-qjeyx5t2.js";
7
7
  import"./index-bn2cjajt.js";
8
- import"./index-gte38nbm.js";
9
- import"./index-nrqg8tks.js";
8
+ import"./index-qmy6zq75.js";
9
+ import"./index-0a349c33.js";
10
10
  import"./index-rxfy4cq7.js";
11
11
  import"./index-6k1937bx.js";
12
12
  import"./index-8z9we758.js";
13
13
  import"./index-fenaekmk.js";
14
14
  import"./index-cby4ar3v.js";
15
- import"./index-scs3f1eg.js";
15
+ import"./index-2vtcmrj9.js";
16
16
  import"./index-kzfs85xp.js";
17
17
  import"./index-77fekveh.js";
18
18
  export {
@@ -6,7 +6,7 @@ import {
6
6
  composeAgentPrompt,
7
7
  createAgentRuntime,
8
8
  createAgentRuntimeEventSink
9
- } from "./index-4yktadec.js";
9
+ } from "./index-bx6yq2m4.js";
10
10
  import"./index-p13mwz16.js";
11
11
  import"./index-y64k3s0h.js";
12
12
  import {
@@ -18,12 +18,12 @@ import"./index-wnfk50r0.js";
18
18
  import {
19
19
  walkContainedFiles
20
20
  } from "./index-bn2cjajt.js";
21
- import"./index-7rkhw9ec.js";
22
- import"./index-1ft2wrv0.js";
21
+ import"./index-kw9t5ayn.js";
22
+ import"./index-mqhjmadk.js";
23
23
  import"./index-vsbzgd7b.js";
24
24
  import"./index-f9mb610r.js";
25
- import"./index-42f33bzd.js";
26
- import"./index-nrqg8tks.js";
25
+ import"./index-13cjtmrw.js";
26
+ import"./index-0a349c33.js";
27
27
  import"./index-rxfy4cq7.js";
28
28
  import"./index-6k1937bx.js";
29
29
  import"./index-zcgf3gqf.js";
@@ -33,7 +33,7 @@ import {
33
33
  } from "./index-8z9we758.js";
34
34
  import"./index-fenaekmk.js";
35
35
  import"./index-cby4ar3v.js";
36
- import"./index-scs3f1eg.js";
36
+ import"./index-2vtcmrj9.js";
37
37
  import"./index-kzfs85xp.js";
38
38
  import"./index-77fekveh.js";
39
39
 
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  createAgentCodingTools
3
- } from "./index-3yqgj323.js";
3
+ } from "./index-qjeyx5t2.js";
4
4
  import"./index-bn2cjajt.js";
5
5
  import {
6
6
  codingRefusal,
7
7
  missingSandboxRestrictions,
8
8
  probeAgentProcessSandbox
9
- } from "./index-gte38nbm.js";
10
- import"./index-nrqg8tks.js";
9
+ } from "./index-qmy6zq75.js";
10
+ import"./index-0a349c33.js";
11
11
  import"./index-rxfy4cq7.js";
12
12
  import"./index-6k1937bx.js";
13
13
  import"./index-8z9we758.js";
14
14
  import"./index-fenaekmk.js";
15
15
  import"./index-cby4ar3v.js";
16
- import"./index-scs3f1eg.js";
16
+ import"./index-2vtcmrj9.js";
17
17
  import"./index-kzfs85xp.js";
18
18
  import"./index-77fekveh.js";
19
19
 
@@ -3,12 +3,6 @@ import {
3
3
  AgentProviderStreamCutError,
4
4
  AgentRuntimeConflictError,
5
5
  AgentTokenCountSchema,
6
- DURABILITY_STEP_EVENT_KIND,
7
- ParkAbortedError,
8
- ParkRecordDecodeError,
9
- StepAbortedError,
10
- StepResultDecodeError,
11
- StepResultNotSerializableError,
12
6
  agentGoalStateSlot,
13
7
  agentTodoStateSlot,
14
8
  classifyProviderFailure,
@@ -18,7 +12,6 @@ import {
18
12
  createAgentSessionCoordinator,
19
13
  createAgentStateSlotStore,
20
14
  createAgentToolFenceLifecycle,
21
- createLocalStepDurability,
22
15
  deferredToolCatalog,
23
16
  defineStateSlot,
24
17
  isToolResultFailure,
@@ -31,7 +24,7 @@ import {
31
24
  renderAgentStateSlots,
32
25
  repairedSearchCall,
33
26
  selectAgentHistory
34
- } from "./index-4yktadec.js";
27
+ } from "./index-bx6yq2m4.js";
35
28
  import"./index-p13mwz16.js";
36
29
  import {
37
30
  AgentAdmissionEventSchema,
@@ -165,19 +158,27 @@ import {
165
158
  probeAgentProcessSandbox,
166
159
  recordAgentSandboxProbe,
167
160
  refuseUnknownSpillReference
168
- } from "./index-gte38nbm.js";
161
+ } from "./index-qmy6zq75.js";
169
162
  import {
170
163
  buildToolManifest,
171
164
  mountAgent
172
- } from "./index-p48nc8g9.js";
173
- import"./index-7rkhw9ec.js";
174
- import"./index-w58rfj2d.js";
175
- import"./index-dggfq62w.js";
176
- import"./index-1ft2wrv0.js";
165
+ } from "./index-f4p4b8f6.js";
166
+ import {
167
+ DURABILITY_STEP_EVENT_KIND,
168
+ ParkAbortedError,
169
+ ParkRecordDecodeError,
170
+ StepAbortedError,
171
+ StepResultDecodeError,
172
+ StepResultNotSerializableError,
173
+ createLocalStepDurability
174
+ } from "./index-kw9t5ayn.js";
175
+ import"./index-qrbdq8jk.js";
176
+ import"./index-1qvdwnp2.js";
177
+ import"./index-mqhjmadk.js";
177
178
  import"./index-vsbzgd7b.js";
178
179
  import"./index-f9mb610r.js";
179
- import"./index-42f33bzd.js";
180
- import"./index-nrqg8tks.js";
180
+ import"./index-13cjtmrw.js";
181
+ import"./index-0a349c33.js";
181
182
  import"./index-rxfy4cq7.js";
182
183
  import"./index-6k1937bx.js";
183
184
  import {
@@ -190,7 +191,7 @@ import {
190
191
  } from "./index-8z9we758.js";
191
192
  import"./index-fenaekmk.js";
192
193
  import"./index-cby4ar3v.js";
193
- import"./index-scs3f1eg.js";
194
+ import"./index-2vtcmrj9.js";
194
195
  import"./index-kzfs85xp.js";
195
196
  import {
196
197
  executableAgentRuntimeTools
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-2k4yrqkc.js";
4
4
  import {
5
5
  AppError
6
- } from "./index-scs3f1eg.js";
6
+ } from "./index-2vtcmrj9.js";
7
7
 
8
8
  // src/application/grammy.ts
9
9
  import { Context } from "grammy";
@@ -36,7 +36,7 @@ import {
36
36
  ApplicationShutdownBudgetSchema,
37
37
  ApplicationShutdownOptionsSchema,
38
38
  createApplication
39
- } from "./index-zkcqhxx8.js";
39
+ } from "./index-a11g2kry.js";
40
40
  import {
41
41
  ApplicationAdmissionSnapshotSchema,
42
42
  ApplicationHealthSchema,
@@ -82,12 +82,12 @@ import {
82
82
  } from "./index-7gnkny4z.js";
83
83
  import {
84
84
  measureSize
85
- } from "./index-xbppf54a.js";
85
+ } from "./index-6kyksz9y.js";
86
86
  import {
87
87
  argumentsDigest,
88
88
  stableValue
89
89
  } from "./index-a916km3r.js";
90
- import"./index-scs3f1eg.js";
90
+ import"./index-2vtcmrj9.js";
91
91
  import"./index-kzfs85xp.js";
92
92
  import"./index-77fekveh.js";
93
93
  // src/application/admission.ts
package/dist/cli.js CHANGED
@@ -11,15 +11,15 @@ import {
11
11
  readCapped,
12
12
  renderCliView,
13
13
  routeCliArgv
14
- } from "./index-mthq65vn.js";
14
+ } from "./index-ya611vx3.js";
15
15
  import"./index-sbdmyz75.js";
16
- import"./index-w58rfj2d.js";
17
- import"./index-dggfq62w.js";
18
- import"./index-1ft2wrv0.js";
16
+ import"./index-qrbdq8jk.js";
17
+ import"./index-1qvdwnp2.js";
18
+ import"./index-mqhjmadk.js";
19
19
  import"./index-vsbzgd7b.js";
20
20
  import"./index-f9mb610r.js";
21
- import"./index-42f33bzd.js";
22
- import"./index-nrqg8tks.js";
21
+ import"./index-13cjtmrw.js";
22
+ import"./index-0a349c33.js";
23
23
  import"./index-rxfy4cq7.js";
24
24
  import"./index-6k1937bx.js";
25
25
  import"./index-zcgf3gqf.js";
@@ -31,7 +31,7 @@ import"./index-fenaekmk.js";
31
31
  import"./index-cby4ar3v.js";
32
32
  import {
33
33
  AppError
34
- } from "./index-scs3f1eg.js";
34
+ } from "./index-2vtcmrj9.js";
35
35
  import {
36
36
  safeJsonParse
37
37
  } from "./index-kzfs85xp.js";
@@ -35,10 +35,22 @@ export type ErrorDetailsSchema = z.ZodObject | z.ZodOptional<z.ZodObject>;
35
35
  export type ErrorDefinition = {
36
36
  readonly status: number;
37
37
  readonly message?: string;
38
+ readonly retryable?: boolean;
38
39
  readonly details?: never;
39
40
  } | {
40
41
  readonly status: number;
41
42
  readonly message?: string;
43
+ /**
44
+ * Whether repeating the call could succeed, when the status class gets it
45
+ * wrong. Omitted, it is derived from `status`.
46
+ *
47
+ * This is where ADR 0077 refused to put `hint`, and the reason does not
48
+ * apply: a hint DECLARED here would concatenate with the surface-wide
49
+ * `ErrorHintFn` and repeat itself on every instance of the code. A
50
+ * boolean has nothing to concatenate with — it is one fact about the
51
+ * code, stated once, in the same place its status is stated.
52
+ */
53
+ readonly retryable?: boolean;
42
54
  readonly details: ErrorDetailsSchema;
43
55
  };
44
56
  export type ErrorDefinitions = Record<string, ErrorDefinition>;
@@ -1 +1 @@
1
- {"version":3,"file":"errors-factory.d.ts","sourceRoot":"","sources":["../../src/contract/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C5B,YAAY,SAAS,gBAAgB,EACrC,QAAQ,SAAS,sBAAsB,CAAC,YAAY,CAAC,GAAG,SAAS,GAAG,SAAS;IAE7E,mFAAmF;IACnF,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC9C,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,KAAK,IAAI,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM;KAAE,CAAC;IAC3E,oFAAoF;IACpF,QAAQ,CAAC,WAAW,EAAE,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAC3D,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC;IAC/E,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;CAC7D;AAsCD,+DAA+D;AAC/D,wBAAgB,YAAY,CAC1B,KAAK,CAAC,YAAY,SAAS,gBAAgB,EAC3C,KAAK,CAAC,QAAQ,SAAS,sBAAsB,CAAC,YAAY,CAAC,GAAG,SAAS,GAAG,SAAS,EACnF,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CA4HjF"}
@@ -32,13 +32,35 @@ export declare class AppError<TCode extends string = string, TDetails extends Re
32
32
  * logs/observability — deliberately NOT part of `toJSON()`'s envelope.
33
33
  */
34
34
  readonly traceId?: string | undefined;
35
+ /**
36
+ * Whether repeating this call could succeed, when the error declares it.
37
+ *
38
+ * Metadata, like `traceId`, and for the same reason: it is not part of
39
+ * `toJSON()`'s HTTP envelope. It exists for the MODEL-facing tool envelope,
40
+ * where the next move — wait and retry, fix the input, or stop — is the
41
+ * whole decision a refusal has to support. Left `undefined`, the class is
42
+ * derived from `status`; declared, it wins, for the domain failure whose
43
+ * status says one thing and whose truth is the other.
44
+ */
45
+ readonly retryable?: boolean | undefined;
35
46
  constructor(code: TCode, message?: string, status?: number, details?: TDetails | undefined, hint?: string | undefined,
36
47
  /**
37
48
  * Transport trace id (`x-request-id`) preserved across the
38
49
  * `ApiError → AppError` conversion in `implementRemote`. Metadata for
39
50
  * logs/observability — deliberately NOT part of `toJSON()`'s envelope.
40
51
  */
41
- traceId?: string | undefined);
52
+ traceId?: string | undefined,
53
+ /**
54
+ * Whether repeating this call could succeed, when the error declares it.
55
+ *
56
+ * Metadata, like `traceId`, and for the same reason: it is not part of
57
+ * `toJSON()`'s HTTP envelope. It exists for the MODEL-facing tool envelope,
58
+ * where the next move — wait and retry, fix the input, or stop — is the
59
+ * whole decision a refusal has to support. Left `undefined`, the class is
60
+ * derived from `status`; declared, it wins, for the domain failure whose
61
+ * status says one thing and whose truth is the other.
62
+ */
63
+ retryable?: boolean | undefined);
42
64
  static is(err: unknown): err is AppError;
43
65
  toJSON(): ErrorEnvelope;
44
66
  }
@@ -83,6 +105,7 @@ export declare const STITCH_ERROR_STATUS: {
83
105
  REALTIME_CONTRACT_VIOLATION: number;
84
106
  APPLICATION_NOT_ACCEPTING: number;
85
107
  GRAMMY_WEBHOOK_NOT_ACCEPTING: number;
108
+ NOT_IMPLEMENTED: number;
86
109
  WAIT_TIMEOUT: number;
87
110
  WAIT_FAILED: number;
88
111
  DOWNLOAD_NOT_FOUND: number;
@@ -97,6 +120,17 @@ export declare const STITCH_ERROR_STATUS: {
97
120
  SPILL_REFERENCE_UNKNOWN: number;
98
121
  INTERNAL_SERVER_ERROR: number;
99
122
  };
123
+ /**
124
+ * Whether a status class means "the same call could work later".
125
+ *
126
+ * Deliberately not "any 5xx". `REALTIME_CONTRACT_VIOLATION`,
127
+ * `STREAM_ITEM_INVALID` and `FRAME_TOO_LARGE` are all 500 and all deterministic
128
+ * — the same call fails the same way every time, and telling a model to retry
129
+ * them buys nothing but billed turns. 408 and 504 are timeouts, 429 is a rate
130
+ * limit, 502 and 503 are an upstream that may return; those are the ones where
131
+ * waiting is a strategy rather than a hope.
132
+ */
133
+ export declare function isRetryableStatus(status: number): boolean;
100
134
  /** A code stitchkit itself emits — derived from `STITCH_ERROR_STATUS` (no dup). */
101
135
  export type StitchErrorCode = keyof typeof STITCH_ERROR_STATUS;
102
136
  /** Type guard — is `code` one of stitchkit's own error codes? */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/contract/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;QACb,8BAA8B;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,gCAAgC;QAChC,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,0BAA0B;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAcD;;;;GAIG;AACH,qBAAa,QAAQ,CACnB,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAC1F,SAAQ,KAAK;aAEK,IAAI,EAAE,KAAK;aAEX,MAAM,EAAE,MAAM;aACd,OAAO,CAAC,EAAE,QAAQ;aAClB,IAAI,CAAC,EAAE,MAAM;IAC7B;;;;OAIG;aACa,OAAO,CAAC,EAAE,MAAM;IAXlC,YACkB,IAAI,EAAE,KAAK,EAC3B,OAAO,CAAC,EAAE,MAAM,EACA,MAAM,GAAE,MAAY,EACpB,OAAO,CAAC,EAAE,QAAQ,YAAA,EAClB,IAAI,CAAC,EAAE,MAAM,YAAA;IAC7B;;;;OAIG;IACa,OAAO,CAAC,EAAE,MAAM,YAAA,EAQjC;IAED,MAAM,CAAC,EAAE,CAAC,GAAG,EAA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AAO,SAAiB,GAAG,KAAK,CAE5D;AAED,qCAAqC;AACrC,wBAAgB,SAAS,CAAC,OAAO,SAAc,GAAG,KAAK,CAEtD;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,OAAO,SAAa,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAEvF;AAED,wCAAwC;AACxC,wBAAgB,WAAW,CAAC,OAAO,SAAsB,GAAG,KAAK,CAEhE;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDE,CAAC;AAEnC;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAIzD;AAED,mFAAmF;AACnF,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAE/D,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAEvE;AAED,+FAA+F;AAC/F,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,KAAK,CAOP"}
@@ -1,5 +1,5 @@
1
1
  export { ALL_TRANSPORTS, type BodyHttpSuccessStatus, type ClientRequestOptions, type ContractDef, type ContractMeta, type ContractStreamCompletion, type ContractStreamFraming, defineContract, type EndpointDef, type EndpointFn, type EndpointMcpInputRequired, type EndpointMcpPolicy, type EndpointResponseMeta, type EndpointStreamDescriptor, type EndpointToolAnnotations, type EndpointUiMeta, type FileDescriptor, type HandlerContext, type HeadEndpointDef, type HttpMethod, type HttpSuccessStatus, type McpCallContext, type McpClientInfo, type McpRoundOutcome, type MultipartBufferedFiles, type MultipartDescriptor, type MultipartFile, type MultipartFilePolicy, type PathParams, type ResponseMetadata, type RuntimeContext, type ScopedEndpointFn, type ScopedHttpClient, type ScopedUrlBuilder, type ScopedUrlFn, type StreamFinalLinePolicy, type Transport, type TransportSource, type TypedClient, type TypedHttpClient, type TypedUrlBuilder, } from './define.js';
2
- export { AppError, appError, badRequest, conflict, type ErrorEnvelope, forbidden, isStitchErrorCode, notFound, rateLimited, STITCH_ERROR_STATUS, type StitchErrorCode, unauthorized, } from './errors.js';
2
+ export { AppError, appError, badRequest, conflict, type ErrorEnvelope, forbidden, isRetryableStatus, isStitchErrorCode, notFound, rateLimited, STITCH_ERROR_STATUS, type StitchErrorCode, unauthorized, } from './errors.js';
3
3
  export { type DefinedAppError, type DefinedErrors, defineErrors, type ErrorDefinition, type ErrorDefinitions, type ErrorDetailsOutput, type ErrorDetailsSchema, type ErrorFactories, type ErrorFactory, type ErrorFactoryArguments, type ErrorVocabularyCode, type ErrorVocabularyMapping, type FrozenErrorDefinitions, type VocabularyCodeMap, } from './errors-factory.js';
4
4
  export { type ContractFactoryConfig, type ContractFactoryToolExposure, createContractFactory, type ExplicitScopedDefineContract, type ExplicitToolExposureEndpoints, type FactoryScopedEndpoint, type ScopedContractDef, type ScopedDefineContract, } from './factory.js';
5
5
  export { type ManagedFilePath, ManagedFilePathSchema, type ManagedFileRef, ManagedFileRefSchema, } from './file-ref.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK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AAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,SAAS,EACd,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,mCAAmC,GACpC,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,KAAK,aAAa,EAClB,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,qBAAqB,EACrB,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,SAAS,EACd,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,mCAAmC,GACpC,MAAM,UAAU,CAAC"}
@@ -8,7 +8,7 @@ import {
8
8
  defineErrors,
9
9
  encodeCursor,
10
10
  paginatedSchema
11
- } from "../index-nrqg8tks.js";
11
+ } from "../index-0a349c33.js";
12
12
  import"../index-rxfy4cq7.js";
13
13
  import {
14
14
  ManagedFilePathSchema,
@@ -21,11 +21,12 @@ import {
21
21
  badRequest,
22
22
  conflict,
23
23
  forbidden,
24
+ isRetryableStatus,
24
25
  isStitchErrorCode,
25
26
  notFound,
26
27
  rateLimited,
27
28
  unauthorized
28
- } from "../index-scs3f1eg.js";
29
+ } from "../index-2vtcmrj9.js";
29
30
  import"../index-kzfs85xp.js";
30
31
  import"../index-77fekveh.js";
31
32
  export {
@@ -34,6 +35,7 @@ export {
34
35
  paginatedSchema,
35
36
  notFound,
36
37
  isStitchErrorCode,
38
+ isRetryableStatus,
37
39
  forbidden,
38
40
  encodeCursor,
39
41
  defineErrors,
@@ -6,7 +6,7 @@ import {
6
6
  AppError,
7
7
  STITCH_ERROR_STATUS,
8
8
  isStitchErrorCode
9
- } from "./index-scs3f1eg.js";
9
+ } from "./index-2vtcmrj9.js";
10
10
  import {
11
11
  isUnsafeKey
12
12
  } from "./index-kzfs85xp.js";
@@ -346,10 +346,10 @@ function defineErrors(source, mapping) {
346
346
  if ("details" in options) {
347
347
  throw new Error(`[stitchkit] Error "${name}" does not declare details`);
348
348
  }
349
- return new AppError(name, message, definition.status, undefined, options.hint);
349
+ return new AppError(name, message, definition.status, undefined, options.hint, undefined, definition.retryable);
350
350
  }
351
351
  const details = definition.details.parse(options.details);
352
- return new AppError(name, message, definition.status, details, options.hint);
352
+ return new AppError(name, message, definition.status, details, options.hint, undefined, definition.retryable);
353
353
  };
354
354
  });
355
355
  Object.freeze(errors);
@@ -3,7 +3,7 @@ import {
3
3
  inputIsQuery,
4
4
  parseSSE,
5
5
  readBoundedUtf8Lines
6
- } from "./index-zjze12x8.js";
6
+ } from "./index-b971qjes.js";
7
7
  import {
8
8
  ApiError,
9
9
  RequestCancellationError,
@@ -16,7 +16,7 @@ import {
16
16
  ContractStreamFrameSchema,
17
17
  DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
18
18
  parseTrailingWildcard
19
- } from "./index-nrqg8tks.js";
19
+ } from "./index-0a349c33.js";
20
20
  import {
21
21
  isRecord,
22
22
  mapObject,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AppError
3
- } from "./index-scs3f1eg.js";
3
+ } from "./index-2vtcmrj9.js";
4
4
  import {
5
5
  isRecord
6
6
  } from "./index-77fekveh.js";
@@ -4,10 +4,10 @@ import {
4
4
  } from "./index-2qzskm8h.js";
5
5
  import {
6
6
  zodIssues
7
- } from "./index-42f33bzd.js";
7
+ } from "./index-13cjtmrw.js";
8
8
  import {
9
9
  AppError
10
- } from "./index-scs3f1eg.js";
10
+ } from "./index-2vtcmrj9.js";
11
11
 
12
12
  // src/realtime/rejected-frame.ts
13
13
  var REALTIME_REJECTION_KEY = "@stitchkit/realtime-rejected";
@@ -1,12 +1,16 @@
1
1
  import {
2
- executeToolMethod
3
- } from "./index-1ft2wrv0.js";
2
+ executeToolMethod,
3
+ toolErrorFromResult
4
+ } from "./index-mqhjmadk.js";
4
5
  import {
5
6
  assertToolExtensionCompatible,
6
7
  mergeSchemas,
7
8
  projectToolSurface,
8
9
  rebuildObject
9
10
  } from "./index-fenaekmk.js";
11
+ import {
12
+ isRetryableStatus
13
+ } from "./index-2vtcmrj9.js";
10
14
 
11
15
  // src/tools/mount.ts
12
16
  import { z } from "zod";
@@ -54,7 +58,10 @@ function createToolRunner(config) {
54
58
  };
55
59
  }
56
60
  function formatToolError(result, toolName, errorHint) {
57
- const err = { error: result.code };
61
+ const err = {
62
+ error: result.code,
63
+ retryable: result.retryable ?? isRetryableStatus(toolErrorFromResult(result).status)
64
+ };
58
65
  if (result.details)
59
66
  err.details = result.details;
60
67
  const hints = [];
@@ -7,13 +7,15 @@ class AppError extends Error {
7
7
  details;
8
8
  hint;
9
9
  traceId;
10
- constructor(code, message, status = 500, details, hint, traceId) {
10
+ retryable;
11
+ constructor(code, message, status = 500, details, hint, traceId, retryable) {
11
12
  super(message ?? code);
12
13
  this.code = code;
13
14
  this.status = status;
14
15
  this.details = details;
15
16
  this.hint = hint;
16
17
  this.traceId = traceId;
18
+ this.retryable = retryable;
17
19
  this.name = "AppError";
18
20
  Object.defineProperty(this, APP_ERROR_BRAND, { value: true });
19
21
  }
@@ -68,6 +70,7 @@ var STITCH_ERROR_STATUS = {
68
70
  REALTIME_CONTRACT_VIOLATION: 500,
69
71
  APPLICATION_NOT_ACCEPTING: 503,
70
72
  GRAMMY_WEBHOOK_NOT_ACCEPTING: 503,
73
+ NOT_IMPLEMENTED: 501,
71
74
  WAIT_TIMEOUT: 408,
72
75
  WAIT_FAILED: 409,
73
76
  DOWNLOAD_NOT_FOUND: 404,
@@ -82,6 +85,9 @@ var STITCH_ERROR_STATUS = {
82
85
  SPILL_REFERENCE_UNKNOWN: 404,
83
86
  INTERNAL_SERVER_ERROR: 500
84
87
  };
88
+ function isRetryableStatus(status) {
89
+ return status === 408 || status === 429 || status === 502 || status === 503 || status === 504;
90
+ }
85
91
  function isStitchErrorCode(code) {
86
92
  return Object.hasOwn(STITCH_ERROR_STATUS, code);
87
93
  }
@@ -89,4 +95,4 @@ function appError(code, message, details) {
89
95
  throw new AppError(code, message, isStitchErrorCode(code) ? STITCH_ERROR_STATUS[code] : 500, details);
90
96
  }
91
97
 
92
- export { AppError, notFound, badRequest, unauthorized, forbidden, conflict, rateLimited, STITCH_ERROR_STATUS, isStitchErrorCode, appError };
98
+ export { AppError, notFound, badRequest, unauthorized, forbidden, conflict, rateLimited, STITCH_ERROR_STATUS, isRetryableStatus, isStitchErrorCode, appError };