stitchkit 0.122.2 → 0.123.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 (202) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/dist/browser/client.d.ts.map +1 -1
  3. package/dist/browser/contract-identity.d.ts +21 -0
  4. package/dist/browser/contract-identity.d.ts.map +1 -0
  5. package/dist/browser/unknown-operation.d.ts +3 -0
  6. package/dist/browser/unknown-operation.d.ts.map +1 -0
  7. package/dist/contract/define.d.ts +6 -2
  8. package/dist/contract/define.d.ts.map +1 -1
  9. package/dist/contract/endpoint-capabilities.d.ts.map +1 -1
  10. package/dist/contract/errors.d.ts +4 -0
  11. package/dist/contract/errors.d.ts.map +1 -1
  12. package/dist/contract/fingerprint.d.ts +51 -0
  13. package/dist/contract/fingerprint.d.ts.map +1 -0
  14. package/dist/contract/identity.d.ts +21 -0
  15. package/dist/contract/identity.d.ts.map +1 -0
  16. package/dist/contract/stream.d.ts +32 -0
  17. package/dist/contract/stream.d.ts.map +1 -1
  18. package/dist/entrypoints/agent-runtime/browser.js +2 -2
  19. package/dist/entrypoints/agent-runtime/coding-tools.js +11 -11
  20. package/dist/entrypoints/agent-runtime/harness.js +12 -12
  21. package/dist/entrypoints/agent-runtime/openrouter.js +1 -1
  22. package/dist/entrypoints/agent-runtime/realtime.js +2 -2
  23. package/dist/entrypoints/agent-runtime/sandbox.js +11 -11
  24. package/dist/entrypoints/agent-runtime/sqlite/bun.js +15 -15
  25. package/dist/entrypoints/agent-runtime/sqlite/node.js +15 -15
  26. package/dist/entrypoints/agent-runtime/testing.js +15 -15
  27. package/dist/entrypoints/agent-runtime.js +22 -22
  28. package/dist/entrypoints/application/diagnostic-journal.js +5 -5
  29. package/dist/entrypoints/application/directory-inbox.js +5 -5
  30. package/dist/entrypoints/application/grammy.js +1 -1
  31. package/dist/entrypoints/application.js +7 -7
  32. package/dist/entrypoints/cli/publish.js +5 -5
  33. package/dist/entrypoints/cli.d.ts +1 -1
  34. package/dist/entrypoints/cli.d.ts.map +1 -1
  35. package/dist/entrypoints/cli.js +20 -17
  36. package/dist/entrypoints/contract.d.ts +2 -0
  37. package/dist/entrypoints/contract.d.ts.map +1 -1
  38. package/dist/entrypoints/contract.js +11 -5
  39. package/dist/entrypoints/files/packaging.d.ts +1 -0
  40. package/dist/entrypoints/files/packaging.d.ts.map +1 -1
  41. package/dist/entrypoints/files/packaging.js +230 -61
  42. package/dist/entrypoints/files.js +5 -5
  43. package/dist/entrypoints/geo.js +3 -3
  44. package/dist/entrypoints/http.js +3 -3
  45. package/dist/entrypoints/index.d.ts +1 -0
  46. package/dist/entrypoints/index.d.ts.map +1 -1
  47. package/dist/entrypoints/index.js +45 -24
  48. package/dist/entrypoints/live.js +2 -2
  49. package/dist/entrypoints/node.js +11 -11
  50. package/dist/entrypoints/observability.js +4 -4
  51. package/dist/entrypoints/primitives.js +1 -1
  52. package/dist/entrypoints/process/owner-loss.js +2 -2
  53. package/dist/entrypoints/process.d.ts +6 -1
  54. package/dist/entrypoints/process.d.ts.map +1 -1
  55. package/dist/entrypoints/process.js +370 -9
  56. package/dist/entrypoints/react.js +2 -2
  57. package/dist/entrypoints/realtime.js +3 -3
  58. package/dist/entrypoints/remote.js +20 -10
  59. package/dist/entrypoints/server.d.ts +1 -0
  60. package/dist/entrypoints/server.d.ts.map +1 -1
  61. package/dist/entrypoints/server.js +56 -20
  62. package/dist/entrypoints/telegram/screens.js +4 -4
  63. package/dist/entrypoints/telegram.js +6 -6
  64. package/dist/entrypoints/testing.js +10 -10
  65. package/dist/entrypoints/tools/agent.js +9 -9
  66. package/dist/entrypoints/tools/connections.js +7 -7
  67. package/dist/entrypoints/tools/contract.js +1 -1
  68. package/dist/entrypoints/tools/invoker.js +7 -7
  69. package/dist/entrypoints/tools/mcp.js +9 -9
  70. package/dist/entrypoints/tools/toolkit.js +15 -14
  71. package/dist/entrypoints/tools.js +17 -17
  72. package/dist/entrypoints/tracking/contract.js +2 -2
  73. package/dist/entrypoints/tracking.js +1 -1
  74. package/dist/files/client-artifact.d.ts +75 -0
  75. package/dist/files/client-artifact.d.ts.map +1 -0
  76. package/dist/{index-am1h8c9v.js → index-0d3sm0m9.js} +5 -5
  77. package/dist/{index-72xtvcvr.js → index-0ndz5r8z.js} +1 -1
  78. package/dist/index-0v9xb8pz.js +66 -0
  79. package/dist/{index-qcn84byh.js → index-0w0hxp7n.js} +4 -0
  80. package/dist/{index-3za04re9.js → index-1c945ten.js} +1 -1
  81. package/dist/{index-r6v4mc67.js → index-1d7s7da0.js} +1 -1
  82. package/dist/{index-zsvzhjtk.js → index-20hn8pbh.js} +1 -1
  83. package/dist/{index-f6pw75e1.js → index-2x2ch0bt.js} +2 -2
  84. package/dist/{index-61hve0ez.js → index-303qne11.js} +1 -1
  85. package/dist/{index-g149e9pk.js → index-3bzk2645.js} +1 -1
  86. package/dist/index-45dyex0j.js +119 -0
  87. package/dist/{index-aqwg2dm5.js → index-6k47xdtt.js} +2 -2
  88. package/dist/{index-nwm3ww60.js → index-73dappvg.js} +1 -1
  89. package/dist/index-7q05ag0z.js +10 -0
  90. package/dist/{index-kz9734jc.js → index-96yjwwgf.js} +6 -5
  91. package/dist/{index-ff39f9dr.js → index-993vtv1w.js} +3 -3
  92. package/dist/{index-4jpykzvw.js → index-99nnsz39.js} +2 -2
  93. package/dist/{index-pfvde2fz.js → index-9ypczvpj.js} +1 -1
  94. package/dist/{index-qch1vcaa.js → index-a7ebd769.js} +2 -2
  95. package/dist/{index-98hv3sba.js → index-aw6kx2e6.js} +1 -1
  96. package/dist/{index-gq3fnq3f.js → index-bqzgaj57.js} +103 -16
  97. package/dist/{index-yj6saztf.js → index-bz9cmnqq.js} +96 -14
  98. package/dist/{index-gtx3eknx.js → index-chz7c830.js} +13 -9
  99. package/dist/{index-mtwh9hyp.js → index-cjzaj7ev.js} +1 -1
  100. package/dist/{index-6j15ktag.js → index-d9cg0gen.js} +1 -1
  101. package/dist/{index-sa99p98w.js → index-eabx6qjh.js} +3 -3
  102. package/dist/{index-8yxgcyt6.js → index-egg0yp2j.js} +1 -1
  103. package/dist/{index-h1j71dr1.js → index-enkc9pem.js} +1 -1
  104. package/dist/{index-aqmadanx.js → index-fa53vygr.js} +2 -2
  105. package/dist/{index-e6c2spsd.js → index-fpwbskp2.js} +1 -1
  106. package/dist/{index-m8a44e64.js → index-ftk3838x.js} +1 -1
  107. package/dist/{index-j95jp7ee.js → index-gdqawggb.js} +1 -1
  108. package/dist/{index-9dyd8xzf.js → index-hkw233vx.js} +2 -2
  109. package/dist/{index-9jfdm5tg.js → index-hkxgennw.js} +7 -1
  110. package/dist/{index-qaqxdbxf.js → index-j8rda9n6.js} +7 -7
  111. package/dist/{index-4tyt1qya.js → index-jc5xgkpk.js} +2 -2
  112. package/dist/{index-s9a0fjh3.js → index-kffm4r8w.js} +1 -1
  113. package/dist/{index-5w6t91ze.js → index-m8ddk770.js} +1 -1
  114. package/dist/{index-2fc1k9k2.js → index-mdyhr36s.js} +32 -122
  115. package/dist/{index-r7a7r7ha.js → index-mfntvj58.js} +6 -3
  116. package/dist/{index-k42ckyzx.js → index-ndjzbt2v.js} +2 -2
  117. package/dist/{index-ycqhyars.js → index-qc7tq0za.js} +3 -3
  118. package/dist/{index-9frf01t9.js → index-r0xr7y4m.js} +1 -1
  119. package/dist/{index-s3yxw6kt.js → index-s512scra.js} +9 -7
  120. package/dist/{index-1h2zv8rx.js → index-sqc6ezrb.js} +41 -1
  121. package/dist/{index-2bqf0a74.js → index-sqkttz7z.js} +1 -1
  122. package/dist/{index-rbzq0q16.js → index-t8jz0e20.js} +1 -1
  123. package/dist/{index-8ryydawp.js → index-tt3ej8r3.js} +1 -1
  124. package/dist/{index-x4p3kw1p.js → index-tynna0n4.js} +6 -6
  125. package/dist/{index-72r9k0av.js → index-v62cpkx3.js} +1 -1
  126. package/dist/{index-10rg78vf.js → index-v8xm2s9v.js} +2 -2
  127. package/dist/{index-y6ye582c.js → index-w0wy05gr.js} +10 -10
  128. package/dist/{index-kw1ws0cs.js → index-w3nv6kr8.js} +1 -1
  129. package/dist/{index-eeahxwvg.js → index-ww3gss55.js} +1 -1
  130. package/dist/{index-aswegq1r.js → index-xjb131sc.js} +367 -131
  131. package/dist/{index-1fyea34p.js → index-yebkpytc.js} +5 -5
  132. package/dist/{index-bgcwxhxh.js → index-yfpt7sxr.js} +24 -46
  133. package/dist/{index-69t14s4a.js → index-yt1gg11x.js} +3 -2
  134. package/dist/{index-jk29rwkr.js → index-zfncctjp.js} +1 -1
  135. package/dist/internal/bun-command.d.ts +14 -0
  136. package/dist/internal/bun-command.d.ts.map +1 -0
  137. package/dist/internal/exclusive-lock-owner.d.ts +1 -1
  138. package/dist/internal/exclusive-lock-owner.d.ts.map +1 -1
  139. package/dist/internal/exclusive-lock.d.ts +1 -1
  140. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  141. package/dist/internal/process-identity.d.ts +24 -5
  142. package/dist/internal/process-identity.d.ts.map +1 -1
  143. package/dist/internal/stable-digest.d.ts +5 -0
  144. package/dist/internal/stable-digest.d.ts.map +1 -1
  145. package/dist/internal/typed.d.ts +2 -0
  146. package/dist/internal/typed.d.ts.map +1 -1
  147. package/dist/process/operation-child.d.ts +38 -0
  148. package/dist/process/operation-child.d.ts.map +1 -0
  149. package/dist/process/operation-wire.d.ts +68 -0
  150. package/dist/process/operation-wire.d.ts.map +1 -0
  151. package/dist/process/operation.d.ts +74 -0
  152. package/dist/process/operation.d.ts.map +1 -0
  153. package/dist/server/contract-identity.d.ts +10 -0
  154. package/dist/server/contract-identity.d.ts.map +1 -0
  155. package/dist/server/contract-stream.d.ts.map +1 -1
  156. package/dist/server/endpoint-response.d.ts.map +1 -1
  157. package/dist/server/error-hook.d.ts +1 -0
  158. package/dist/server/error-hook.d.ts.map +1 -1
  159. package/dist/tools/cli/args-route.d.ts.map +1 -1
  160. package/dist/tools/cli/args-tokens.d.ts.map +1 -1
  161. package/dist/tools/cli/command.d.ts +39 -18
  162. package/dist/tools/cli/command.d.ts.map +1 -1
  163. package/dist/tools/cli/format.d.ts.map +1 -1
  164. package/dist/tools/cli/help.d.ts.map +1 -1
  165. package/dist/tools/cli/invoke.d.ts +3 -1
  166. package/dist/tools/cli/invoke.d.ts.map +1 -1
  167. package/dist/tools/cli/io.d.ts +6 -0
  168. package/dist/tools/cli/io.d.ts.map +1 -1
  169. package/dist/tools/cli/managed-surface.d.ts +2 -0
  170. package/dist/tools/cli/managed-surface.d.ts.map +1 -1
  171. package/dist/tools/cli/policy.d.ts +14 -0
  172. package/dist/tools/cli/policy.d.ts.map +1 -1
  173. package/dist/tools/cli/run-managed.d.ts.map +1 -1
  174. package/dist/tools/cli/run-native.d.ts.map +1 -1
  175. package/dist/tools/cli/run-stream.d.ts +23 -0
  176. package/dist/tools/cli/run-stream.d.ts.map +1 -0
  177. package/dist/tools/cli/session.d.ts +8 -0
  178. package/dist/tools/cli/session.d.ts.map +1 -1
  179. package/dist/tools/cli/stream-surface.d.ts +17 -0
  180. package/dist/tools/cli/stream-surface.d.ts.map +1 -0
  181. package/dist/tools/execute.d.ts +7 -1
  182. package/dist/tools/execute.d.ts.map +1 -1
  183. package/dist/tools/invoker.d.ts.map +1 -1
  184. package/dist/tools/remote.d.ts.map +1 -1
  185. package/llms/cli.2.txt +56 -1
  186. package/llms/cli.txt +68 -1
  187. package/llms/contract.txt +4 -1
  188. package/llms/files-packaging.txt +10 -0
  189. package/llms/process.2.txt +75 -1
  190. package/llms/process.txt +59 -25
  191. package/llms/server.4.txt +8 -4
  192. package/llms/server.5.txt +1 -0
  193. package/llms/stitchkit.2.txt +74 -0
  194. package/llms/stitchkit.txt +5 -5
  195. package/llms/tools.txt +1 -1
  196. package/llms/{upgrading-0.106.0-0.122.0.txt → upgrading-0.106.0-0.123.0.txt} +50 -3
  197. package/llms/upgrading.txt +1 -1
  198. package/llms-full.txt +379 -13
  199. package/llms.txt +7 -7
  200. package/package.json +1 -1
  201. package/dist/index-h2fhjqy7.js +0 -19
  202. package/dist/index-m5m9rmvt.js +0 -44
@@ -1,10 +1,16 @@
1
+ import {
2
+ resolveRouteParamsSchema
3
+ } from "./index-m38ej7e5.js";
1
4
  import {
2
5
  ExposureSchema,
3
6
  isHttpOnlyEndpoint
4
- } from "./index-69t14s4a.js";
7
+ } from "./index-yt1gg11x.js";
5
8
  import {
6
9
  defineContract2
7
- } from "./index-4jpykzvw.js";
10
+ } from "./index-99nnsz39.js";
11
+ import {
12
+ canonicalDigest
13
+ } from "./index-mfntvj58.js";
8
14
  import {
9
15
  bytesToBase64Url,
10
16
  base64UrlToBytes
@@ -13,16 +19,92 @@ import {
13
19
  AppError2,
14
20
  STITCH_ERROR_STATUS2,
15
21
  isStitchErrorCode2
16
- } from "./index-qcn84byh.js";
22
+ } from "./index-0w0hxp7n.js";
17
23
  import {
18
24
  typedEntries,
25
+ isRecord,
19
26
  transportResult,
20
27
  mapObjectTypeBoundary
21
- } from "./index-9jfdm5tg.js";
22
- // src/contract/errors-factory.ts
28
+ } from "./index-hkxgennw.js";
29
+
30
+ // src/contract/fingerprint.ts
23
31
  import { z } from "zod";
32
+ var ContractFingerprintSchema2 = z.strictObject({
33
+ fingerprint: z.string(),
34
+ operations: z.record(z.string(), z.string())
35
+ });
36
+ var ANNOTATIONS = new Set(["description", "title", "examples", "deprecated", "$comment"]);
37
+ function constraintsOf(schema) {
38
+ if (Array.isArray(schema))
39
+ return schema.map(constraintsOf);
40
+ if (!isRecord(schema))
41
+ return schema;
42
+ const constraints = {};
43
+ for (const [key, value] of Object.entries(schema)) {
44
+ if (ANNOTATIONS.has(key))
45
+ continue;
46
+ constraints[key] = key === "required" && Array.isArray(value) ? [...value].sort() : key === "properties" && isRecord(value) ? Object.fromEntries(Object.entries(value).map(([name, property]) => [name, constraintsOf(property)])) : constraintsOf(value);
47
+ }
48
+ return constraints;
49
+ }
50
+ function schemaIdentity(schema, io) {
51
+ if (schema === undefined)
52
+ return null;
53
+ return constraintsOf(z.toJSONSchema(schema, { io, unrepresentable: "any", cycles: "ref" }));
54
+ }
55
+ function fingerprintOperations(operations) {
56
+ const digests = {};
57
+ for (const operation of operations) {
58
+ if (Object.hasOwn(digests, operation.name)) {
59
+ throw new Error(`[stitchkit] contract fingerprint: duplicate operation "${operation.name}"`);
60
+ }
61
+ digests[operation.name] = canonicalDigest({
62
+ method: operation.method,
63
+ path: operation.path,
64
+ params: schemaIdentity(operation.params, "input"),
65
+ input: schemaIdentity(operation.input, "input"),
66
+ output: schemaIdentity(operation.output, "output"),
67
+ item: schemaIdentity(operation.item, "output")
68
+ });
69
+ }
70
+ return { fingerprint: canonicalDigest(digests), operations: digests };
71
+ }
72
+ function contractFingerprint2(contracts) {
73
+ const list = Array.isArray(contracts) ? contracts : [contracts];
74
+ return fingerprintOperations(list.flatMap(contractOperations));
75
+ }
76
+ function contractOperations(contract) {
77
+ const operations = [];
78
+ for (const [key, endpoint] of typedEntries(contract.endpoints)) {
79
+ if (endpoint.expose && !endpoint.expose.includes("HTTP"))
80
+ continue;
81
+ operations.push({
82
+ name: `${contract.meta.prefix}.${key}`,
83
+ method: endpoint.method,
84
+ path: endpoint.path,
85
+ params: resolveRouteParamsSchema(endpoint.path, endpoint.params),
86
+ input: endpoint.input,
87
+ output: endpoint.output,
88
+ item: "stream" in endpoint ? endpoint.stream?.item : undefined
89
+ });
90
+ }
91
+ return operations;
92
+ }
93
+
94
+ // src/contract/identity.ts
95
+ var contractIdentityContract2 = defineContract2({ prefix: "contract-identity", scope: "public" }, {
96
+ read: {
97
+ method: "GET",
98
+ path: "/",
99
+ desc: "The fingerprint of the contract operations this server answers",
100
+ expose: ["HTTP"],
101
+ output: ContractFingerprintSchema2
102
+ }
103
+ });
104
+ // src/contract/errors-factory.ts
105
+ import { z as z2 } from "zod";
24
106
  function isErrorDetailsSchema(value) {
25
- return value instanceof z.ZodObject || value instanceof z.ZodOptional && value.unwrap() instanceof z.ZodObject;
107
+ return value instanceof z2.ZodObject || value instanceof z2.ZodOptional && value.unwrap() instanceof z2.ZodObject;
26
108
  }
27
109
  function validateDefinition(code, definition) {
28
110
  if (!Number.isInteger(definition.status) || definition.status < 400 || definition.status > 599) {
@@ -123,9 +205,9 @@ function defineErrors2(source, mapping) {
123
205
  });
124
206
  }
125
207
  // src/contract/factory.ts
126
- import { z as z2 } from "zod";
127
- var ContractFactoryToolExposureSchema = z2.strictObject({ default: ExposureSchema });
128
- var ContractFactoryConfigSchema = z2.strictObject({
208
+ import { z as z3 } from "zod";
209
+ var ContractFactoryToolExposureSchema = z3.strictObject({ default: ExposureSchema });
210
+ var ContractFactoryConfigSchema = z3.strictObject({
129
211
  toolExposure: ContractFactoryToolExposureSchema
130
212
  });
131
213
  function createContractFactory2(...args) {
@@ -154,11 +236,11 @@ function createContractFactory2(...args) {
154
236
  return { defineContract: scoped, configure };
155
237
  }
156
238
  // src/contract/pagination.ts
157
- import { z as z3 } from "zod";
239
+ import { z as z4 } from "zod";
158
240
  function paginatedSchema2(itemSchema) {
159
- return z3.object({
160
- items: z3.array(itemSchema),
161
- nextCursor: z3.string().nullable()
241
+ return z4.object({
242
+ items: z4.array(itemSchema),
243
+ nextCursor: z4.string().nullable()
162
244
  });
163
245
  }
164
246
  function toBase64Url(str) {
@@ -180,4 +262,4 @@ function decodeCursor2(cursor, schema) {
180
262
  return null;
181
263
  }
182
264
  }
183
- export { defineErrors2, createContractFactory2, paginatedSchema2, encodeCursor2, decodeCursor2 };
265
+ export { ContractFingerprintSchema2, fingerprintOperations, contractFingerprint2, contractIdentityContract2, defineErrors2, createContractFactory2, paginatedSchema2, encodeCursor2, decodeCursor2 };
@@ -3,7 +3,7 @@ import {
3
3
  ProcessInstanceSchema2,
4
4
  readProcessInstance,
5
5
  probeProcessOwner2
6
- } from "./index-gq3fnq3f.js";
6
+ } from "./index-bqzgaj57.js";
7
7
  import {
8
8
  BoundedFileReadError,
9
9
  readBoundedFile
@@ -14,7 +14,7 @@ import {
14
14
  } from "./index-b56nnscm.js";
15
15
  import {
16
16
  isRecord
17
- } from "./index-9jfdm5tg.js";
17
+ } from "./index-hkxgennw.js";
18
18
 
19
19
  // src/internal/exclusive-lock.ts
20
20
  import { randomUUID } from "node:crypto";
@@ -92,11 +92,11 @@ function attribute(owner, identity) {
92
92
  }
93
93
  return owner.host === hostname() ? "this-machine" : "unattributable";
94
94
  }
95
- async function diagnose(lock, declaredIdentity) {
95
+ async function diagnose(lock, declaredIdentity, signal) {
96
96
  const owner = lock?.owner;
97
97
  if (!lock || !owner)
98
98
  return { attribution: "unattributable", liveness: "not-probed", owner: null };
99
- const attribution = attribute(owner, await machineIdentity(declaredIdentity));
99
+ const attribution = attribute(owner, await machineIdentity(declaredIdentity, signal));
100
100
  if (attribution !== "this-machine")
101
101
  return { attribution, liveness: "not-probed", owner };
102
102
  const evidence = await probeProcessOwner2(owner.pid, owner.process);
@@ -199,7 +199,7 @@ async function sweepStagedLocks(directory, machine, signal) {
199
199
  const state = await readLockFile(candidate, undefined, signal);
200
200
  if (!state?.owner)
201
201
  continue;
202
- if ((await diagnose(state, machine)).liveness !== "gone")
202
+ if ((await diagnose(state, machine, signal)).liveness !== "gone")
203
203
  continue;
204
204
  await unlinkIfSame(candidate, state.ino, state.dev, state.stagedName === undefined ? 1 : 2);
205
205
  }
@@ -216,7 +216,9 @@ async function unlinkIfSame(path, ino, dev, links = 1) {
216
216
  }
217
217
  }
218
218
  async function createOwned(path, options, reclaimed) {
219
- const identity = await machineIdentity(options.machineIdentity);
219
+ const identity = await machineIdentity(options.machineIdentity, options.signal);
220
+ if (options.signal?.aborted)
221
+ throw options.signal.reason;
220
222
  const instance = await readProcessInstance(process.pid);
221
223
  const owner = {
222
224
  pid: process.pid,
@@ -320,7 +322,7 @@ async function reclaimUnderGuard(path, options, depth) {
320
322
  if (readFailure !== undefined)
321
323
  return { refused: true, cause: readFailure };
322
324
  if (state) {
323
- const diagnosis = await diagnose(state, options.machineIdentity);
325
+ const diagnosis = await diagnose(state, options.machineIdentity, options.signal);
324
326
  if (options.signal?.aborted)
325
327
  return { refused: true };
326
328
  if (!reclaimable(state, diagnosis, options.ownerlessGraceMs))
@@ -334,7 +336,7 @@ async function reclaimUnderGuard(path, options, depth) {
334
336
  }
335
337
  await sweepStagedLocks(dirname(path), options.machineIdentity, options.signal);
336
338
  return await createOwned(path, options, state !== undefined).catch((error) => {
337
- if (isCode(error, "EEXIST"))
339
+ if (isCode(error, "EEXIST") || options.signal?.aborted)
338
340
  return { refused: true, cause: error };
339
341
  throw error;
340
342
  });
@@ -348,6 +350,8 @@ async function attemptExclusiveLock(path, options, depth = 0) {
348
350
  try {
349
351
  return { held: await createOwned(path, options, false) };
350
352
  } catch (error) {
353
+ if (options.signal?.aborted)
354
+ return { error };
351
355
  if (!isCode(error, "EEXIST"))
352
356
  throw error;
353
357
  if (!options.reclaim)
@@ -357,7 +361,7 @@ async function attemptExclusiveLock(path, options, depth = 0) {
357
361
  readFailure = cause;
358
362
  }, options.signal);
359
363
  const diagnosis = {
360
- ...await diagnose(state, options.machineIdentity),
364
+ ...await diagnose(state, options.machineIdentity, options.signal),
361
365
  ...readFailure !== undefined && { cause: readFailure }
362
366
  };
363
367
  if (options.signal?.aborted)
@@ -11,7 +11,7 @@ import {
11
11
  } from "./index-50ejfz75.js";
12
12
  import {
13
13
  AppError2
14
- } from "./index-qcn84byh.js";
14
+ } from "./index-0w0hxp7n.js";
15
15
 
16
16
  // src/application/kernel-contract.ts
17
17
  import { z } from "zod";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withExclusiveLock2
3
- } from "./index-nwm3ww60.js";
3
+ } from "./index-73dappvg.js";
4
4
  import {
5
5
  readBoundedFile
6
6
  } from "./index-m616f0yz.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  contractMethodFields
3
- } from "./index-pfvde2fz.js";
3
+ } from "./index-9ypczvpj.js";
4
4
  import {
5
5
  AppError2
6
- } from "./index-qcn84byh.js";
6
+ } from "./index-0w0hxp7n.js";
7
7
  import {
8
8
  typedEntries,
9
9
  callRuntimeHandler
10
- } from "./index-9jfdm5tg.js";
10
+ } from "./index-hkxgennw.js";
11
11
 
12
12
  // src/server/implement.ts
13
13
  function isStreamingImplementation(value) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  canonicalZodJson
3
- } from "./index-5w6t91ze.js";
3
+ } from "./index-m8ddk770.js";
4
4
  import {
5
5
  AgentRecordIdSchema2,
6
6
  AgentRecordVersionSchema2,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  collectToolSurface
3
- } from "./index-ff39f9dr.js";
3
+ } from "./index-993vtv1w.js";
4
4
 
5
5
  // src/tools/manifest.ts
6
6
  function utf8Length(value) {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  loadDarwinBinding
3
- } from "./index-m5m9rmvt.js";
3
+ } from "./index-sqc6ezrb.js";
4
4
  import {
5
5
  descriptorPath,
6
6
  NumericFileHandle
7
- } from "./index-eeahxwvg.js";
7
+ } from "./index-ww3gss55.js";
8
8
  import {
9
9
  stagingName
10
10
  } from "./index-tt30h7mr.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-zsarb5xp.js";
7
7
  import {
8
8
  isRecord
9
- } from "./index-9jfdm5tg.js";
9
+ } from "./index-hkxgennw.js";
10
10
 
11
11
  // src/observability/sanitize.ts
12
12
  var SENSITIVE_WORDS = new Set([
@@ -6,7 +6,7 @@ import {
6
6
  realtimeRequestTraces,
7
7
  createRequestTracer,
8
8
  bindRealtimeClient2
9
- } from "./index-jk29rwkr.js";
9
+ } from "./index-zfncctjp.js";
10
10
  import {
11
11
  isModuleNotFound
12
12
  } from "./index-srs8hj9c.js";
@@ -11,7 +11,7 @@ import {
11
11
  spawnBunChild,
12
12
  spawnBunInheritedChild,
13
13
  ownerLossGuardEntry
14
- } from "./index-72xtvcvr.js";
14
+ } from "./index-0ndz5r8z.js";
15
15
  import {
16
16
  errnoOf
17
17
  } from "./index-jj9228tt.js";
@@ -10,10 +10,10 @@ import {
10
10
  } from "./index-zsarb5xp.js";
11
11
  import {
12
12
  unauthorized2
13
- } from "./index-qcn84byh.js";
13
+ } from "./index-0w0hxp7n.js";
14
14
  import {
15
15
  isRecord
16
- } from "./index-9jfdm5tg.js";
16
+ } from "./index-hkxgennw.js";
17
17
 
18
18
  // src/server/middleware/jwt.ts
19
19
  var MAX_TOKEN_BYTES = 8192;
@@ -5,6 +5,12 @@ function typedEntries(value) {
5
5
  function isRecord(value) {
6
6
  return typeof value === "object" && value !== null && !Array.isArray(value);
7
7
  }
8
+ function isAsyncIterable(value) {
9
+ if (typeof value !== "object" && typeof value !== "function" || value === null) {
10
+ return false;
11
+ }
12
+ return typeof Reflect.get(value, Symbol.asyncIterator) === "function";
13
+ }
8
14
  function callRuntimeHandler(handler, context) {
9
15
  if (typeof handler !== "function") {
10
16
  throw new TypeError("Runtime handler must be a function");
@@ -27,4 +33,4 @@ function mapObjectTypeBoundary(source, mapper) {
27
33
  return mapObject(source, (key, value) => mapper(key, value));
28
34
  }
29
35
 
30
- export { typedEntries, isRecord, callRuntimeHandler, transportResult, mapObject, mapObjectTypeBoundary };
36
+ export { typedEntries, isRecord, isAsyncIterable, callRuntimeHandler, transportResult, mapObject, mapObjectTypeBoundary };
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  NativeCommandError2
3
- } from "./index-72xtvcvr.js";
3
+ } from "./index-0ndz5r8z.js";
4
4
  import {
5
5
  CommandStopped,
6
6
  startNativeCommand
7
- } from "./index-j95jp7ee.js";
7
+ } from "./index-gdqawggb.js";
8
8
  import {
9
9
  ScanStopped,
10
10
  ContainedScanBudget,
11
11
  readContainedUtf8Handle,
12
12
  scanContainedFiles
13
- } from "./index-s9a0fjh3.js";
13
+ } from "./index-kffm4r8w.js";
14
14
  import {
15
15
  writeContainedFile
16
- } from "./index-aqmadanx.js";
16
+ } from "./index-fa53vygr.js";
17
17
  import {
18
18
  openPinnedDirectory,
19
19
  openContainedDirectory,
@@ -27,13 +27,13 @@ import {
27
27
  assertContainedParentCurrent,
28
28
  containedEntryMetadata,
29
29
  openContainedParentFile
30
- } from "./index-eeahxwvg.js";
30
+ } from "./index-ww3gss55.js";
31
31
  import {
32
32
  withSignalDeadline
33
33
  } from "./index-9tqbxv5p.js";
34
34
  import {
35
35
  defineRuntimeTool2
36
- } from "./index-aqwg2dm5.js";
36
+ } from "./index-6k47xdtt.js";
37
37
  import {
38
38
  errnoOf
39
39
  } from "./index-jj9228tt.js";
@@ -45,7 +45,7 @@ import {
45
45
  forbidden2,
46
46
  conflict2,
47
47
  STITCH_ERROR_STATUS2
48
- } from "./index-qcn84byh.js";
48
+ } from "./index-0w0hxp7n.js";
49
49
 
50
50
  // src/agent-runtime/coding-tool-contract.ts
51
51
  import { z as z2 } from "zod";
@@ -10,12 +10,12 @@ import {
10
10
  AgentAdmissionReceiptSchema2,
11
11
  AgentSeedReceiptSchema2,
12
12
  AgentHistoryMutationSchema2
13
- } from "./index-8yxgcyt6.js";
13
+ } from "./index-egg0yp2j.js";
14
14
  import {
15
15
  appendEventIn,
16
16
  ArchiveProjectionSchema,
17
17
  createAgentRuntimeStore2
18
- } from "./index-10rg78vf.js";
18
+ } from "./index-v8xm2s9v.js";
19
19
  import {
20
20
  AgentMessageSchema2,
21
21
  AgentRunSchema2
@@ -3,7 +3,7 @@ import {
3
3
  openPinnedDirectory,
4
4
  openFileAt,
5
5
  listAt
6
- } from "./index-eeahxwvg.js";
6
+ } from "./index-ww3gss55.js";
7
7
  import {
8
8
  errnoOf
9
9
  } from "./index-jj9228tt.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-m6w6jtda.js";
4
4
  import {
5
5
  serializeCanonicalJson
6
- } from "./index-zsvzhjtk.js";
6
+ } from "./index-20hn8pbh.js";
7
7
 
8
8
  // src/primitives/canonical-json.ts
9
9
  import { z } from "zod";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  DEFAULT_CONTRACT_STREAM_FRAME_BYTES2,
6
6
  ContractStreamFrameSchema2
7
- } from "./index-h2fhjqy7.js";
7
+ } from "./index-0v9xb8pz.js";
8
8
  import {
9
9
  RequestCancellationError,
10
10
  createRequestCancellation,
@@ -13,7 +13,12 @@ import {
13
13
  uploadProgressRoute,
14
14
  withUploadProgress,
15
15
  parseApiErrorBody
16
- } from "./index-9frf01t9.js";
16
+ } from "./index-r0xr7y4m.js";
17
+ import {
18
+ DEFAULT_STREAM_LINE_BYTES,
19
+ createBoundedLineDecoder,
20
+ readBoundedUtf8Lines
21
+ } from "./index-45dyex0j.js";
17
22
  import {
18
23
  inputIsQuery
19
24
  } from "./index-xhzq2qvj.js";
@@ -21,17 +26,11 @@ import {
21
26
  ApiError2,
22
27
  refuseLocally
23
28
  } from "./index-kfjkb396.js";
24
- import {
25
- chunksOf
26
- } from "./index-cjbn98zt.js";
27
- import {
28
- assertPositiveSafeInteger
29
- } from "./index-0s4xebbg.js";
30
29
  import {
31
30
  typedEntries,
32
31
  isRecord,
33
32
  mapObject
34
- } from "./index-9jfdm5tg.js";
33
+ } from "./index-hkxgennw.js";
35
34
 
36
35
  // src/browser/client-arguments.ts
37
36
  function endpointHasArguments(endpoint) {
@@ -259,117 +258,6 @@ function joinClientBaseUrl(baseUrl, relativeUrl) {
259
258
  return `${base}${path}`;
260
259
  }
261
260
 
262
- // src/internal/bounded-lines.ts
263
- var DEFAULT_STREAM_LINE_BYTES = 1024 * 1024;
264
-
265
- class StreamLineLimitError2 extends RangeError {
266
- limitBytes;
267
- lineBytes;
268
- name = "StreamLineLimitError";
269
- constructor(limitBytes, lineBytes) {
270
- super(`Stream line exceeds the ${limitBytes} byte limit (${lineBytes} bytes so far)`);
271
- this.limitBytes = limitBytes;
272
- this.lineBytes = lineBytes;
273
- }
274
- }
275
-
276
- class StreamTruncatedLineError2 extends SyntaxError {
277
- lineBytes;
278
- name = "StreamTruncatedLineError";
279
- constructor(lineBytes) {
280
- super(`Stream ended with an unterminated final line (${lineBytes} bytes)`);
281
- this.lineBytes = lineBytes;
282
- }
283
- }
284
- function lineLimit(value) {
285
- const resolved = value ?? DEFAULT_STREAM_LINE_BYTES;
286
- assertPositiveSafeInteger("maxLineBytes", resolved);
287
- return resolved;
288
- }
289
- function createLineSplitter(maxLineBytes, requireFinalNewline = false) {
290
- const limit = lineLimit(maxLineBytes);
291
- const decoder = new TextDecoder("utf-8", { fatal: true });
292
- let parts = [];
293
- let pendingBytes = 0;
294
- let ended = false;
295
- let failed = false;
296
- const drop = () => {
297
- parts = [];
298
- pendingBytes = 0;
299
- };
300
- const retain = (bytes) => {
301
- if (bytes.byteLength === 0)
302
- return;
303
- pendingBytes += bytes.byteLength;
304
- if (pendingBytes > limit) {
305
- const seen = pendingBytes;
306
- drop();
307
- throw new StreamLineLimitError2(limit, seen);
308
- }
309
- parts.push(new Uint8Array(bytes));
310
- };
311
- const take = () => {
312
- const line = new Uint8Array(pendingBytes);
313
- let at = 0;
314
- for (const part of parts) {
315
- line.set(part, at);
316
- at += part.byteLength;
317
- }
318
- drop();
319
- return decoder.decode(line);
320
- };
321
- function* lines(chunk) {
322
- if (ended)
323
- throw new Error("Line decoder received bytes after end()");
324
- if (failed)
325
- throw new Error("Line decoder stopped at an earlier error; read the source again");
326
- try {
327
- let start = 0;
328
- for (let index = chunk.indexOf(10);index !== -1; index = chunk.indexOf(10, start)) {
329
- retain(chunk.subarray(start, index));
330
- yield take();
331
- start = index + 1;
332
- }
333
- retain(chunk.subarray(start));
334
- } catch (error) {
335
- failed = true;
336
- throw error;
337
- }
338
- }
339
- return {
340
- lines,
341
- push: (chunk) => [...lines(chunk)],
342
- end() {
343
- ended = true;
344
- if (pendingBytes === 0)
345
- return [];
346
- if (requireFinalNewline) {
347
- const seen = pendingBytes;
348
- drop();
349
- throw new StreamTruncatedLineError2(seen);
350
- }
351
- return [take()];
352
- }
353
- };
354
- }
355
- function createBoundedLineDecoder(maxLineBytes, requireFinalNewline = false) {
356
- const { push, end } = createLineSplitter(maxLineBytes, requireFinalNewline);
357
- return { push, end };
358
- }
359
- async function* readBoundedUtf8Lines(source, maxLineBytes, requireFinalNewline = false, signal) {
360
- const splitter = createLineSplitter(maxLineBytes, requireFinalNewline);
361
- for await (const chunk of chunksOf(source, signal)) {
362
- for (const line of splitter.lines(chunk)) {
363
- signal?.throwIfAborted();
364
- yield line;
365
- }
366
- }
367
- for (const line of splitter.end()) {
368
- signal?.throwIfAborted();
369
- yield line;
370
- }
371
- }
372
-
373
261
  // src/browser/stream.ts
374
262
  function ndjsonLine(rawLine) {
375
263
  return (rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine).trim();
@@ -765,6 +653,28 @@ async function throwForErrorResponse(res, config, fallbackBody) {
765
653
  });
766
654
  }
767
655
 
656
+ // src/browser/unknown-operation.ts
657
+ function isRoutingRefusal(error) {
658
+ if (error.code === "UNKNOWN_OPERATION")
659
+ return true;
660
+ return error.code === "METHOD_NOT_ALLOWED" && isRecord(error.details) && Array.isArray(error.details.allow);
661
+ }
662
+ function namedOperation(execute, operation) {
663
+ return (requestArgs, options) => execute(requestArgs, options).catch((error) => {
664
+ if (!(error instanceof ApiError2) || !isRoutingRefusal(error))
665
+ throw error;
666
+ throw new ApiError2("UNKNOWN_OPERATION", {
667
+ status: error.status,
668
+ message: error.message,
669
+ details: { ...isRecord(error.details) ? error.details : {}, operation },
670
+ hint: error.hint,
671
+ traceId: error.traceId,
672
+ retryable: error.retryable,
673
+ cause: error
674
+ });
675
+ });
676
+ }
677
+
768
678
  // src/browser/client.ts
769
679
  function contractEndpointMatchers2(contract, endpointNames, contractConfig) {
770
680
  const selected = endpointNames ? new Set(endpointNames) : null;
@@ -791,7 +701,7 @@ function createClient2(contract, configOrClient, contractConfig) {
791
701
  for (const [key, endpoint] of typedEntries(contract.endpoints)) {
792
702
  if (endpoint.expose && !endpoint.expose.includes("HTTP"))
793
703
  continue;
794
- setClientMethod(client, key, createEndpointMethod(endpoint, makeExecutor(endpoint), contractConfig));
704
+ setClientMethod(client, key, createEndpointMethod(endpoint, namedOperation(makeExecutor(endpoint), `${contract.meta.prefix}.${String(key)}`), contractConfig));
795
705
  }
796
706
  return client;
797
707
  }
@@ -921,4 +831,4 @@ function createScopedUrlBuilders2(contracts, source, scopeConfigs) {
921
831
  return buildScopedRegistry(contracts, scopeConfigs, "URL builder", (contract, config) => createUrlBuilder2(contract, source, config));
922
832
  }
923
833
 
924
- export { endpointHasArguments, StreamLineLimitError2, StreamTruncatedLineError2, parseNDJSON2, createNDJSONDecoder2, parseSSE2, contractEndpointMatchers2, createClient2, createClients2, createScopedClients2, createUrlBuilder2, createUrlBuilders2, createScopedUrlBuilders2 };
834
+ export { endpointHasArguments, parseNDJSON2, createNDJSONDecoder2, parseSSE2, contractEndpointMatchers2, createClient2, createClients2, createScopedClients2, createUrlBuilder2, createUrlBuilders2, createScopedUrlBuilders2 };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serializeCanonicalJson
3
- } from "./index-zsvzhjtk.js";
3
+ } from "./index-20hn8pbh.js";
4
4
 
5
5
  // src/internal/stable-digest.ts
6
6
  function mix128(input) {
@@ -31,8 +31,11 @@ function mix128(input) {
31
31
  ];
32
32
  }
33
33
  function argumentsDigest(args) {
34
- const lanes = mix128(serializeCanonicalJson(args));
34
+ return canonicalDigest(args);
35
+ }
36
+ function canonicalDigest(value) {
37
+ const lanes = mix128(serializeCanonicalJson(value));
35
38
  return lanes.map((lane) => lane.toString(16).padStart(8, "0")).join("");
36
39
  }
37
40
 
38
- export { argumentsDigest };
41
+ export { argumentsDigest, canonicalDigest };