stitchkit 0.76.1 → 0.76.2

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 (41) hide show
  1. package/dist/agent-runtime-coding-tools.js +1 -2
  2. package/dist/agent-runtime-harness.js +4 -5
  3. package/dist/agent-runtime.js +7 -8
  4. package/dist/application/watch-hub.d.ts +1 -1
  5. package/dist/application/watch-hub.d.ts.map +1 -1
  6. package/dist/application.js +3 -4
  7. package/dist/cli.js +6 -7
  8. package/dist/contract/index.js +1 -2
  9. package/dist/{index-v5dm4bwq.js → index-58jzmnn4.js} +1 -1
  10. package/dist/{index-885chjxq.js → index-7qy2ex0m.js} +1 -1
  11. package/dist/index-a916km3r.js +45 -0
  12. package/dist/{index-28jsdwt1.js → index-aczggrty.js} +1 -1
  13. package/dist/{index-65kathdm.js → index-da1aqnhb.js} +4 -6
  14. package/dist/{index-xgahrwdf.js → index-ezmn6ac6.js} +3 -3
  15. package/dist/{index-4kp4fxvp.js → index-f6n5n7nz.js} +18 -4
  16. package/dist/{index-6wr9f6qm.js → index-jqtsc9mj.js} +2 -2
  17. package/dist/{index-9c5dbr5q.js → index-k2zczx1g.js} +1 -1
  18. package/dist/{index-v7xjfy10.js → index-m668wzyc.js} +1 -1
  19. package/dist/{index-e0a57ymn.js → index-nemjkxjp.js} +1 -1
  20. package/dist/{index-9my2n66s.js → index-s2rchahr.js} +4 -4
  21. package/dist/{index-k68e5jz0.js → index-s4c8wy8m.js} +2 -2
  22. package/dist/{index-52400rdd.js → index-t8qyvrvg.js} +3 -3
  23. package/dist/{index-endzd8sj.js → index-vbf2p6me.js} +1 -1
  24. package/dist/{index-hsz2mmk0.js → index-vj3vvpaa.js} +17 -1
  25. package/dist/index.js +1 -2
  26. package/dist/internal/stable-digest.d.ts +40 -6
  27. package/dist/internal/stable-digest.d.ts.map +1 -1
  28. package/dist/live/watch-client.d.ts.map +1 -1
  29. package/dist/live.js +40 -57
  30. package/dist/node.js +4 -5
  31. package/dist/observability/index.js +3 -4
  32. package/dist/primitives.js +1 -2
  33. package/dist/remote.js +2 -3
  34. package/dist/server/index.js +5 -6
  35. package/dist/testing.js +2 -3
  36. package/dist/tool-invoker.js +5 -6
  37. package/dist/tools.js +13 -14
  38. package/llms-full.txt +7 -0
  39. package/package.json +1 -1
  40. package/dist/index-rxfy4cq7.js +0 -17
  41. package/dist/index-vdvmcy7r.js +0 -22
@@ -16,8 +16,7 @@ import {
16
16
  } from "./index-wwst0td5.js";
17
17
  import"./index-22by16v6.js";
18
18
  import"./index-cby4ar3v.js";
19
- import"./index-hsz2mmk0.js";
20
- import"./index-rxfy4cq7.js";
19
+ import"./index-vj3vvpaa.js";
21
20
  import {
22
21
  AppError,
23
22
  conflict,
@@ -3,7 +3,7 @@ import {
3
3
  composeAgentPrompt,
4
4
  createAgentRuntime,
5
5
  createAgentRuntimeEventSink
6
- } from "./index-v7xjfy10.js";
6
+ } from "./index-m668wzyc.js";
7
7
  import {
8
8
  walkContainedFiles
9
9
  } from "./index-rqpdar1e.js";
@@ -16,8 +16,8 @@ import"./index-3xnq72rz.js";
16
16
  import {
17
17
  defineRuntimeTool
18
18
  } from "./index-wwst0td5.js";
19
- import"./index-k68e5jz0.js";
20
- import"./index-e0a57ymn.js";
19
+ import"./index-s4c8wy8m.js";
20
+ import"./index-nemjkxjp.js";
21
21
  import {
22
22
  AgentMessagePartSchema,
23
23
  AgentSnapshotSchema
@@ -25,8 +25,7 @@ import {
25
25
  import"./index-22by16v6.js";
26
26
  import"./index-cby4ar3v.js";
27
27
  import"./index-nt1mp8km.js";
28
- import"./index-hsz2mmk0.js";
29
- import"./index-rxfy4cq7.js";
28
+ import"./index-vj3vvpaa.js";
30
29
  import"./index-0w9abg87.js";
31
30
  import"./index-qyrqwr4c.js";
32
31
  import"./index-6k1937bx.js";
@@ -27,7 +27,7 @@ import {
27
27
  registerDeferredToolRepair,
28
28
  repairedSearchCall,
29
29
  selectAgentHistory
30
- } from "./index-v7xjfy10.js";
30
+ } from "./index-m668wzyc.js";
31
31
  import {
32
32
  AgentModelCapabilitySchema,
33
33
  AgentModelCatalogEntrySchema,
@@ -86,15 +86,15 @@ import {
86
86
  import {
87
87
  buildToolManifest,
88
88
  mountAgent
89
- } from "./index-xgahrwdf.js";
89
+ } from "./index-ezmn6ac6.js";
90
90
  import"./index-3xnq72rz.js";
91
- import"./index-9c5dbr5q.js";
91
+ import"./index-k2zczx1g.js";
92
92
  import {
93
93
  defineRuntimeTool
94
94
  } from "./index-wwst0td5.js";
95
- import"./index-885chjxq.js";
96
- import"./index-k68e5jz0.js";
97
- import"./index-e0a57ymn.js";
95
+ import"./index-7qy2ex0m.js";
96
+ import"./index-s4c8wy8m.js";
97
+ import"./index-nemjkxjp.js";
98
98
  import {
99
99
  AgentAssistantPlaceholderSchema,
100
100
  AgentControlPartSchema,
@@ -134,8 +134,7 @@ import {
134
134
  childSpan,
135
135
  createTraceContext
136
136
  } from "./index-nt1mp8km.js";
137
- import"./index-hsz2mmk0.js";
138
- import"./index-rxfy4cq7.js";
137
+ import"./index-vj3vvpaa.js";
139
138
  import"./index-0w9abg87.js";
140
139
  import {
141
140
  executableAgentRuntimeTools,
@@ -129,6 +129,6 @@ export interface WatchHub {
129
129
  * Exported because the client has to produce exactly this, and two
130
130
  * implementations of one key is the failure the digest exists to prevent.
131
131
  */
132
- export declare function watchKey(operation: WatchOperation, args: unknown): Promise<WatchKey>;
132
+ export declare function watchKey(operation: WatchOperation, args: unknown): WatchKey;
133
133
  export declare function createWatchHub(config: WatchHubConfig): WatchHub;
134
134
  //# sourceMappingURL=watch-hub.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch-hub.d.ts","sourceRoot":"","sources":["../../src/application/watch-hub.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EACL,KAAK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;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,CAU3E;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CA4M/D"}
@@ -27,7 +27,7 @@ import {
27
27
  import {
28
28
  argumentsDigest,
29
29
  stableValue
30
- } from "./index-vdvmcy7r.js";
30
+ } from "./index-a916km3r.js";
31
31
  import {
32
32
  ApplicationAdmissionError,
33
33
  ApplicationShutdownBudgetSchema,
@@ -52,7 +52,6 @@ import {
52
52
  projectApplicationStatus
53
53
  } from "./index-8eywc9zv.js";
54
54
  import"./index-3z73fh2c.js";
55
- import"./index-rxfy4cq7.js";
56
55
  import"./index-0w9abg87.js";
57
56
  import {
58
57
  isRecord
@@ -1535,12 +1534,12 @@ function watchKeyString(key) {
1535
1534
 
1536
1535
  // src/application/watch-hub.ts
1537
1536
  var DEFAULT_BACKOFF = { minDelayMs: 250, maxDelayMs: 30000, jitter: 0.2 };
1538
- async function watchKey(operation, args) {
1537
+ function watchKey(operation, args) {
1539
1538
  const record = typeof args === "object" && args !== null && !Array.isArray(args) ? args : { value: args };
1540
1539
  return {
1541
1540
  service: operation.service,
1542
1541
  action: operation.action,
1543
- digest: await argumentsDigest(record)
1542
+ digest: argumentsDigest(record)
1544
1543
  };
1545
1544
  }
1546
1545
  function createWatchHub(config) {
package/dist/cli.js CHANGED
@@ -5,18 +5,17 @@ import {
5
5
  emitResult,
6
6
  parseCliArgs,
7
7
  pollUntilDone
8
- } from "./index-9my2n66s.js";
9
- import"./index-9c5dbr5q.js";
8
+ } from "./index-s2rchahr.js";
9
+ import"./index-k2zczx1g.js";
10
10
  import"./index-wwst0td5.js";
11
- import"./index-885chjxq.js";
12
- import"./index-k68e5jz0.js";
13
- import"./index-e0a57ymn.js";
11
+ import"./index-7qy2ex0m.js";
12
+ import"./index-s4c8wy8m.js";
13
+ import"./index-nemjkxjp.js";
14
14
  import"./index-sbdmyz75.js";
15
15
  import"./index-22by16v6.js";
16
16
  import"./index-cby4ar3v.js";
17
17
  import"./index-nt1mp8km.js";
18
- import"./index-hsz2mmk0.js";
19
- import"./index-rxfy4cq7.js";
18
+ import"./index-vj3vvpaa.js";
20
19
  import"./index-0w9abg87.js";
21
20
  import"./index-qyrqwr4c.js";
22
21
  import"./index-6k1937bx.js";
@@ -20,8 +20,7 @@ import {
20
20
  paginatedSchema,
21
21
  rateLimited,
22
22
  unauthorized
23
- } from "../index-4kp4fxvp.js";
24
- import"../index-rxfy4cq7.js";
23
+ } from "../index-f6n5n7nz.js";
25
24
  import"../index-ksp6e2ye.js";
26
25
  export {
27
26
  unauthorized,
@@ -8,7 +8,7 @@ import {
8
8
  ContractStreamFrameSchema,
9
9
  DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
10
10
  parseTrailingWildcard
11
- } from "./index-hsz2mmk0.js";
11
+ } from "./index-vj3vvpaa.js";
12
12
  import {
13
13
  isRecord,
14
14
  mapObject,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  executeToolMethod
3
- } from "./index-k68e5jz0.js";
3
+ } from "./index-s4c8wy8m.js";
4
4
  import {
5
5
  assertToolExtensionCompatible,
6
6
  mergeSchemas,
@@ -0,0 +1,45 @@
1
+ // src/internal/stable-digest.ts
2
+ function stableValue(value) {
3
+ if (Array.isArray(value))
4
+ return value.map(stableValue);
5
+ if (value === null || typeof value !== "object")
6
+ return value;
7
+ const result = {};
8
+ for (const key of Object.keys(value).sort()) {
9
+ result[key] = stableValue(Reflect.get(value, key));
10
+ }
11
+ return result;
12
+ }
13
+ function mix128(input) {
14
+ let a = 2654435769;
15
+ let b = 2246822507;
16
+ let c = 3266489909;
17
+ let d = 668265263;
18
+ for (let index = 0;index < input.length; index += 1) {
19
+ const code = input.charCodeAt(index);
20
+ a = Math.imul(a ^ code, 2246822519);
21
+ b = Math.imul(b ^ code, 3266489917);
22
+ c = Math.imul(c ^ code, 668265263);
23
+ d = Math.imul(d ^ code, 374761393);
24
+ a = a << 13 | a >>> 19;
25
+ b = b << 17 | b >>> 15;
26
+ c = c << 7 | c >>> 25;
27
+ d = d << 11 | d >>> 21;
28
+ }
29
+ a ^= b >>> 15;
30
+ b ^= c >>> 13;
31
+ c ^= d >>> 11;
32
+ d ^= a >>> 9;
33
+ return [
34
+ Math.imul(a ^ a >>> 16, 575075507) >>> 0,
35
+ Math.imul(b ^ b >>> 13, 2654435761) >>> 0,
36
+ Math.imul(c ^ c >>> 16, 2246822507) >>> 0,
37
+ Math.imul(d ^ d >>> 15, 3266489909) >>> 0
38
+ ];
39
+ }
40
+ function argumentsDigest(args) {
41
+ const lanes = mix128(JSON.stringify(stableValue(args)) ?? "undefined");
42
+ return lanes.map((lane) => lane.toString(16).padStart(8, "0")).join("");
43
+ }
44
+
45
+ export { stableValue, argumentsDigest };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isUnsafeKey
3
- } from "./index-hsz2mmk0.js";
3
+ } from "./index-vj3vvpaa.js";
4
4
  import {
5
5
  isRecord
6
6
  } from "./index-qyrqwr4c.js";
@@ -2,15 +2,13 @@ import {
2
2
  contextContributionDelta,
3
3
  mergeContextContribution,
4
4
  prepareContextContribution
5
- } from "./index-endzd8sj.js";
5
+ } from "./index-vbf2p6me.js";
6
6
  import {
7
+ base64UrlToBytes,
8
+ bytesToBase64Url,
7
9
  isUnsafeKey,
8
10
  safeJsonParse
9
- } from "./index-hsz2mmk0.js";
10
- import {
11
- base64UrlToBytes,
12
- bytesToBase64Url
13
- } from "./index-rxfy4cq7.js";
11
+ } from "./index-vj3vvpaa.js";
14
12
  import {
15
13
  forbidden,
16
14
  unauthorized
@@ -3,15 +3,15 @@ import {
3
3
  } from "./index-3xnq72rz.js";
4
4
  import {
5
5
  collectToolSurface
6
- } from "./index-9c5dbr5q.js";
6
+ } from "./index-k2zczx1g.js";
7
7
  import {
8
8
  createToolRunner,
9
9
  formatToolError
10
- } from "./index-885chjxq.js";
10
+ } from "./index-7qy2ex0m.js";
11
11
  import {
12
12
  isToolExecutionControlError,
13
13
  toolResultFromError
14
- } from "./index-k68e5jz0.js";
14
+ } from "./index-s4c8wy8m.js";
15
15
  import {
16
16
  isRecord
17
17
  } from "./index-qyrqwr4c.js";
@@ -1,7 +1,3 @@
1
- import {
2
- base64UrlToBytes,
3
- bytesToBase64Url
4
- } from "./index-rxfy4cq7.js";
5
1
  import {
6
2
  mapObjectTypeBoundary
7
3
  } from "./index-ksp6e2ye.js";
@@ -435,6 +431,24 @@ var ManagedFileRefSchema = z3.object({
435
431
  });
436
432
  // src/contract/pagination.ts
437
433
  import { z as z4 } from "zod";
434
+
435
+ // src/internal/base64url.ts
436
+ function bytesToBase64Url(bytes) {
437
+ let binary = "";
438
+ for (const byte of bytes)
439
+ binary += String.fromCharCode(byte);
440
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
441
+ }
442
+ function base64UrlToBytes(segment) {
443
+ if (!/^[A-Za-z0-9_-]*$/.test(segment) || segment.length % 4 === 1) {
444
+ throw new Error("invalid base64url segment");
445
+ }
446
+ const b64 = segment.replace(/-/g, "+").replace(/_/g, "/");
447
+ const padded = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
448
+ return Uint8Array.from(atob(padded), (c) => c.charCodeAt(0));
449
+ }
450
+
451
+ // src/contract/pagination.ts
438
452
  function paginatedSchema(itemSchema) {
439
453
  return z4.object({
440
454
  items: z4.array(itemSchema),
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  collectTools,
3
3
  createToolRunner
4
- } from "./index-885chjxq.js";
4
+ } from "./index-7qy2ex0m.js";
5
5
  import {
6
6
  toolErrorFromResult
7
- } from "./index-k68e5jz0.js";
7
+ } from "./index-s4c8wy8m.js";
8
8
  import {
9
9
  assertUniqueToolName
10
10
  } from "./index-22by16v6.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-wwst0td5.js";
4
4
  import {
5
5
  contractToolMountable
6
- } from "./index-885chjxq.js";
6
+ } from "./index-7qy2ex0m.js";
7
7
  import {
8
8
  projectToolSurface
9
9
  } from "./index-22by16v6.js";
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  ToolExecutionControlError,
17
17
  isToolExecutionControlError
18
- } from "./index-k68e5jz0.js";
18
+ } from "./index-s4c8wy8m.js";
19
19
  import {
20
20
  AgentAssistantPlaceholderSchema,
21
21
  AgentJsonObjectSchema,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-nt1mp8km.js";
4
4
  import {
5
5
  isUnsafeKey
6
- } from "./index-hsz2mmk0.js";
6
+ } from "./index-vj3vvpaa.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./index-qyrqwr4c.js";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  collectToolSurface
3
- } from "./index-9c5dbr5q.js";
3
+ } from "./index-k2zczx1g.js";
4
4
  import {
5
5
  createToolRunner,
6
6
  formatToolError
7
- } from "./index-885chjxq.js";
7
+ } from "./index-7qy2ex0m.js";
8
8
  import {
9
9
  coerceJsonArgs,
10
10
  toolResultFromError
11
- } from "./index-k68e5jz0.js";
11
+ } from "./index-s4c8wy8m.js";
12
12
  import {
13
13
  isWithinDir
14
14
  } from "./index-sbdmyz75.js";
@@ -27,7 +27,7 @@ import {
27
27
  import {
28
28
  isUnsafeKey,
29
29
  safeJsonParse
30
- } from "./index-hsz2mmk0.js";
30
+ } from "./index-vj3vvpaa.js";
31
31
  import {
32
32
  isRecord
33
33
  } from "./index-qyrqwr4c.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getRequestContext,
3
3
  runWithRequestContext
4
- } from "./index-e0a57ymn.js";
4
+ } from "./index-nemjkxjp.js";
5
5
  import {
6
6
  objectShapeKeys
7
7
  } from "./index-22by16v6.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  isUnsafeKey,
15
15
  safeJsonParse
16
- } from "./index-hsz2mmk0.js";
16
+ } from "./index-vj3vvpaa.js";
17
17
  import {
18
18
  AppError,
19
19
  STITCH_ERROR_STATUS,
@@ -7,7 +7,7 @@ import {
7
7
  defaultSignalSource,
8
8
  guardSignalCallback,
9
9
  reportSignalError
10
- } from "./index-endzd8sj.js";
10
+ } from "./index-vbf2p6me.js";
11
11
  import {
12
12
  extractIp,
13
13
  getClientInfo,
@@ -18,7 +18,7 @@ import {
18
18
  runWithRequestContext,
19
19
  setRequestEndpoint,
20
20
  setRequestError
21
- } from "./index-e0a57ymn.js";
21
+ } from "./index-nemjkxjp.js";
22
22
  import {
23
23
  ShutdownOptionsSchema,
24
24
  isStreamCancellation,
@@ -39,7 +39,7 @@ import {
39
39
  joinRoutePath,
40
40
  parseTrailingWildcard,
41
41
  safeJsonParse
42
- } from "./index-hsz2mmk0.js";
42
+ } from "./index-vj3vvpaa.js";
43
43
  import {
44
44
  AppError,
45
45
  badRequest
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isUnsafeKey,
3
3
  mergeMeta
4
- } from "./index-hsz2mmk0.js";
4
+ } from "./index-vj3vvpaa.js";
5
5
  import {
6
6
  callRuntimeHandler,
7
7
  isRecord,
@@ -272,6 +272,22 @@ function mergeMeta(contractMeta, endpointMeta) {
272
272
  import { z as z2 } from "zod";
273
273
  // src/contract/pagination.ts
274
274
  import { z as z3 } from "zod";
275
+
276
+ // src/internal/base64url.ts
277
+ function bytesToBase64Url(bytes) {
278
+ let binary = "";
279
+ for (const byte of bytes)
280
+ binary += String.fromCharCode(byte);
281
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
282
+ }
283
+ function base64UrlToBytes(segment) {
284
+ if (!/^[A-Za-z0-9_-]*$/.test(segment) || segment.length % 4 === 1) {
285
+ throw new Error("invalid base64url segment");
286
+ }
287
+ const b64 = segment.replace(/-/g, "+").replace(/_/g, "/");
288
+ const padded = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
289
+ return Uint8Array.from(atob(padded), (c) => c.charCodeAt(0));
290
+ }
275
291
  // src/contract/stream.ts
276
292
  import { z as z4 } from "zod";
277
293
  var DEFAULT_CONTRACT_STREAM_FRAME_BYTES = 256 * 1024;
@@ -288,4 +304,4 @@ var ContractStreamFrameSchema = z4.discriminatedUnion("type", [
288
304
  }).strict(),
289
305
  z4.object({ type: z4.literal("end") }).strict()
290
306
  ]);
291
- export { joinRoutePath, parseTrailingWildcard, isUnsafeKey, safeJsonParse, defineContract, mergeMeta, DEFAULT_CONTRACT_STREAM_FRAME_BYTES, ContractStreamFrameSchema };
307
+ export { joinRoutePath, parseTrailingWildcard, isUnsafeKey, safeJsonParse, defineContract, mergeMeta, bytesToBase64Url, base64UrlToBytes, DEFAULT_CONTRACT_STREAM_FRAME_BYTES, ContractStreamFrameSchema };
package/dist/index.js CHANGED
@@ -27,8 +27,7 @@ import {
27
27
  parseTrailingWildcard,
28
28
  rateLimited,
29
29
  unauthorized
30
- } from "./index-4kp4fxvp.js";
31
- import"./index-rxfy4cq7.js";
30
+ } from "./index-f6n5n7nz.js";
32
31
  import {
33
32
  isRecord,
34
33
  mapObject,
@@ -1,3 +1,38 @@
1
+ /**
2
+ * A stable identity for a call's arguments — one implementation, two callers.
3
+ *
4
+ * Two callers need the same thing for different reasons. The MCP round keys a
5
+ * tool invocation by `(operation, arguments)` so a retry is recognised as the
6
+ * same round; a watched read keys its shared source by `(operation, arguments)`
7
+ * so two browsers asking the same question are one read on the server. If those
8
+ * two computed the key differently, the same arguments would be the same round
9
+ * and two different watches — and nothing would say so.
10
+ *
11
+ * The stability that matters is key order: `{a:1,b:2}` and `{b:2,a:1}` are the
12
+ * same arguments and `JSON.stringify` disagrees, so a naive key silently splits
13
+ * one shared source into two whenever a caller builds its object in a different
14
+ * order. That is not a hypothetical: object literal order follows the source
15
+ * that wrote it, and two components asking the same question rarely share one.
16
+ *
17
+ * ## Why this is not SHA-256
18
+ *
19
+ * It was, and that made every watched read fail on an ordinary intranet. Web
20
+ * Crypto — `crypto.subtle` — exists only in a **secure context**, so a page
21
+ * served over plain HTTP from a LAN name has no `crypto.subtle` at all and the
22
+ * first digest throws `Cannot read properties of undefined`. `localhost` is
23
+ * secure by definition, which is exactly why nothing caught it until a browser
24
+ * opened the app by its name.
25
+ *
26
+ * The fix is not a fallback, it is admitting what this is for: **identity, not
27
+ * secrecy**. Nothing here resists an adversary — an attacker who can choose your
28
+ * watch arguments can already ask the question directly. So the requirement is
29
+ * distribution and determinism, both ends agreeing, and no ambient capability;
30
+ * a cryptographic hash bought none of that and cost the entire non-secure web.
31
+ *
32
+ * Being synchronous is the second thing it buys. A promise for a key made the
33
+ * first subscription of a question asynchronous, which meant a component could
34
+ * not be handed a retained value in the same turn it subscribed.
35
+ */
1
36
  /**
2
37
  * The value with every object's keys sorted, recursively — arrays keep their
3
38
  * order, because in an array order *is* the value.
@@ -7,12 +42,11 @@
7
42
  */
8
43
  export declare function stableValue(value: unknown): unknown;
9
44
  /**
10
- * A bounded, order-independent digest of a call's arguments.
45
+ * A bounded, order-independent identity for a call's arguments.
11
46
  *
12
- * SHA-256 over the key-sorted JSON, base64url without padding. Bounded because
13
- * the key travels on the wire and arguments do not have a bounded size; a hash
14
- * rather than the JSON itself so a large argument object does not become a
15
- * large subscription key repeated in every frame.
47
+ * 128 bits as 32 lowercase hex characters. Deterministic across runtimes and
48
+ * across both ends of a socket, synchronous, and dependent on no ambient
49
+ * capability see the module header for why that last one is the whole point.
16
50
  *
17
51
  * What it cannot do, stated because the limit is easy to walk into: values
18
52
  * `JSON.stringify` drops or transforms — `undefined` members, a `Date`, a `Map`,
@@ -20,5 +54,5 @@ export declare function stableValue(value: unknown): unknown;
20
54
  * Contract arguments are parsed JSON, so this is the argument shape by
21
55
  * construction; a caller digesting something else has to say what it means.
22
56
  */
23
- export declare function argumentsDigest(args: Record<string, unknown>): Promise<string>;
57
+ export declare function argumentsDigest(args: Record<string, unknown>): string;
24
58
  //# sourceMappingURL=stable-digest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stable-digest.d.ts","sourceRoot":"","sources":["../../src/internal/stable-digest.ts"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQnD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAGpF"}
1
+ {"version":3,"file":"stable-digest.d.ts","sourceRoot":"","sources":["../../src/internal/stable-digest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQnD;AAyCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAGrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"watch-client.d.ts","sourceRoot":"","sources":["../../src/live/watch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,eAAe,EAErB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,cAAc,CAAC,MAAM;IACpC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,kEAAkE;IAClE,KAAK,CAAC,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,WAAW,CAAC,MAAM;IACjC,sFAAsF;IACtF,SAAS,CAAC,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAA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
2
2
  LiveStatePhaseSchema,
3
3
  LiveStateStopReasonSchema
4
4
  } from "./index-35z5h2ty.js";
5
- import {
6
- bytesToBase64Url
7
- } from "./index-rxfy4cq7.js";
8
5
 
9
6
  // src/live/events.ts
10
7
  import { z } from "zod";
@@ -68,9 +65,36 @@ function stableValue(value) {
68
65
  }
69
66
  return result;
70
67
  }
71
- async function argumentsDigest(args) {
72
- const bytes = new TextEncoder().encode(JSON.stringify(stableValue(args)));
73
- return bytesToBase64Url(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)));
68
+ function mix128(input) {
69
+ let a = 2654435769;
70
+ let b = 2246822507;
71
+ let c = 3266489909;
72
+ let d = 668265263;
73
+ for (let index = 0;index < input.length; index += 1) {
74
+ const code = input.charCodeAt(index);
75
+ a = Math.imul(a ^ code, 2246822519);
76
+ b = Math.imul(b ^ code, 3266489917);
77
+ c = Math.imul(c ^ code, 668265263);
78
+ d = Math.imul(d ^ code, 374761393);
79
+ a = a << 13 | a >>> 19;
80
+ b = b << 17 | b >>> 15;
81
+ c = c << 7 | c >>> 25;
82
+ d = d << 11 | d >>> 21;
83
+ }
84
+ a ^= b >>> 15;
85
+ b ^= c >>> 13;
86
+ c ^= d >>> 11;
87
+ d ^= a >>> 9;
88
+ return [
89
+ Math.imul(a ^ a >>> 16, 575075507) >>> 0,
90
+ Math.imul(b ^ b >>> 13, 2654435761) >>> 0,
91
+ Math.imul(c ^ c >>> 16, 2246822507) >>> 0,
92
+ Math.imul(d ^ d >>> 15, 3266489909) >>> 0
93
+ ];
94
+ }
95
+ function argumentsDigest(args) {
96
+ const lanes = mix128(JSON.stringify(stableValue(args)) ?? "undefined");
97
+ return lanes.map((lane) => lane.toString(16).padStart(8, "0")).join("");
74
98
  }
75
99
 
76
100
  // src/live/watch-contract.ts
@@ -121,7 +145,6 @@ function watchTransport(client) {
121
145
  }
122
146
  function createWatchClient(contract, config) {
123
147
  const entries = new Map;
124
- const digests = new Map;
125
148
  const holdMs = config.holdMs ?? 0;
126
149
  const openTimeoutMs = config.openTimeoutMs ?? 1e4;
127
150
  const service = contract.meta.prefix;
@@ -168,18 +191,6 @@ function createWatchClient(contract, config) {
168
191
  open(entry);
169
192
  }
170
193
  });
171
- function cachedDigest(action, args) {
172
- return digests.get(`${service}/${action}/${JSON.stringify(stableValue(args))}`);
173
- }
174
- async function resolveDigest(action, args) {
175
- const cacheKey = `${service}/${action}/${JSON.stringify(stableValue(args))}`;
176
- const cached = digests.get(cacheKey);
177
- if (cached !== undefined)
178
- return cached;
179
- const digest = await argumentsDigest(args);
180
- digests.set(cacheKey, digest);
181
- return digest;
182
- }
183
194
  function entryFor(key, args) {
184
195
  const id = watchKeyString(key);
185
196
  const existing = entries.get(id);
@@ -246,55 +257,27 @@ function createWatchClient(contract, config) {
246
257
  }
247
258
  function handleFor(action, args) {
248
259
  const mine = new Set;
249
- let entry;
250
- const known = cachedDigest(action, args);
251
- if (known !== undefined)
252
- entry = entryFor({ service, action, digest: known }, args);
253
- const ready = (async () => {
254
- if (entry)
255
- return entry;
256
- const digest = await resolveDigest(action, args);
257
- entry = entryFor({ service, action, digest }, args);
258
- return entry;
259
- })();
260
+ const entry = entryFor({ service, action, digest: argumentsDigest(args) }, args);
260
261
  return {
261
262
  subscribe(listeners) {
262
263
  const registered = listeners;
263
264
  mine.add(registered);
264
- if (entry) {
265
- entry.listeners.add(registered);
266
- if (entry.hasValue)
267
- registered.value(entry.value);
268
- registered.state?.(entry.state);
269
- }
270
- ready.then((target) => {
271
- if (!mine.has(registered))
272
- return;
273
- if (!target.listeners.has(registered)) {
274
- target.listeners.add(registered);
275
- if (target.hasValue)
276
- registered.value(target.value);
277
- registered.state?.(target.state);
278
- }
279
- open(target);
280
- });
265
+ entry.listeners.add(registered);
266
+ if (entry.hasValue)
267
+ registered.value(entry.value);
268
+ registered.state?.(entry.state);
269
+ open(entry);
281
270
  return () => {
282
271
  mine.delete(registered);
283
- const target = entry;
284
- if (!target)
285
- return;
286
- target.listeners.delete(registered);
287
- releaseEntry(target);
272
+ entry.listeners.delete(registered);
273
+ releaseEntry(entry);
288
274
  };
289
275
  },
290
276
  close() {
291
- const target = entry;
292
- if (!target)
293
- return;
294
277
  for (const listener of mine)
295
- target.listeners.delete(listener);
278
+ entry.listeners.delete(listener);
296
279
  mine.clear();
297
- releaseEntry(target);
280
+ releaseEntry(entry);
298
281
  }
299
282
  };
300
283
  }
package/dist/node.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createHandler,
6
6
  createSocketIOServer,
7
7
  createUnixClientTransport
8
- } from "./index-52400rdd.js";
8
+ } from "./index-t8qyvrvg.js";
9
9
  import {
10
10
  createImplement,
11
11
  createImplementRegistry,
@@ -14,8 +14,8 @@ import {
14
14
  createScopedImplementRegistry,
15
15
  implement,
16
16
  implementRegistry
17
- } from "./index-endzd8sj.js";
18
- import"./index-e0a57ymn.js";
17
+ } from "./index-vbf2p6me.js";
18
+ import"./index-nemjkxjp.js";
19
19
  import"./index-7b188kmz.js";
20
20
  import {
21
21
  ShutdownOptionsSchema,
@@ -25,8 +25,7 @@ import {
25
25
  createServerLifecycle
26
26
  } from "./index-3z73fh2c.js";
27
27
  import"./index-nt1mp8km.js";
28
- import"./index-hsz2mmk0.js";
29
- import"./index-rxfy4cq7.js";
28
+ import"./index-vj3vvpaa.js";
30
29
  import {
31
30
  AppError,
32
31
  appError,
@@ -10,7 +10,7 @@ import {
10
10
  redact,
11
11
  sanitizePayload,
12
12
  truncatePreview
13
- } from "../index-28jsdwt1.js";
13
+ } from "../index-aczggrty.js";
14
14
  import {
15
15
  getRequestContext,
16
16
  getTraceId,
@@ -21,7 +21,7 @@ import {
21
21
  setRequestError,
22
22
  setRequestUser,
23
23
  wrapInRequestContext
24
- } from "../index-e0a57ymn.js";
24
+ } from "../index-nemjkxjp.js";
25
25
  import {
26
26
  childSpan,
27
27
  createTraceContext,
@@ -31,8 +31,7 @@ import {
31
31
  resolvePropagationContext,
32
32
  resolveTraceContext
33
33
  } from "../index-nt1mp8km.js";
34
- import"../index-hsz2mmk0.js";
35
- import"../index-rxfy4cq7.js";
34
+ import"../index-vj3vvpaa.js";
36
35
  import"../index-0w9abg87.js";
37
36
  import {
38
37
  isRecord
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  ManagedFileRefSchema
3
- } from "./index-4kp4fxvp.js";
4
- import"./index-rxfy4cq7.js";
3
+ } from "./index-f6n5n7nz.js";
5
4
  import"./index-ksp6e2ye.js";
6
5
 
7
6
  // src/primitives/audit.ts
package/dist/remote.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  ApiError,
3
3
  createClient
4
- } from "./index-v5dm4bwq.js";
4
+ } from "./index-58jzmnn4.js";
5
5
  import"./index-1rxswfbv.js";
6
6
  import"./index-nt1mp8km.js";
7
7
  import {
8
8
  mergeMeta
9
- } from "./index-hsz2mmk0.js";
10
- import"./index-rxfy4cq7.js";
9
+ } from "./index-vj3vvpaa.js";
11
10
  import {
12
11
  AppError
13
12
  } from "./index-0w9abg87.js";
@@ -13,7 +13,7 @@ import {
13
13
  sseRoute,
14
14
  streamingRoute,
15
15
  webSocketLane
16
- } from "../index-52400rdd.js";
16
+ } from "../index-t8qyvrvg.js";
17
17
  import {
18
18
  composeAuthHooks,
19
19
  createAuthHook,
@@ -26,7 +26,7 @@ import {
26
26
  signJwt,
27
27
  verifyJwt,
28
28
  verifyPkce
29
- } from "../index-65kathdm.js";
29
+ } from "../index-da1aqnhb.js";
30
30
  import {
31
31
  DEFAULT_CORS_ALLOW_HEADERS,
32
32
  DEFAULT_CORS_EXPOSE_HEADERS,
@@ -40,7 +40,7 @@ import {
40
40
  defineMultipartStream,
41
41
  implement,
42
42
  implementRegistry
43
- } from "../index-endzd8sj.js";
43
+ } from "../index-vbf2p6me.js";
44
44
  import {
45
45
  extractIp,
46
46
  generateTraceId,
@@ -49,7 +49,7 @@ import {
49
49
  isPublicIp,
50
50
  resolveSocketIp,
51
51
  resolveTraceId
52
- } from "../index-e0a57ymn.js";
52
+ } from "../index-nemjkxjp.js";
53
53
  import {
54
54
  isWithinDir,
55
55
  realPathWithinDir
@@ -81,8 +81,7 @@ import {
81
81
  DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
82
82
  joinRoutePath,
83
83
  parseTrailingWildcard
84
- } from "../index-hsz2mmk0.js";
85
- import"../index-rxfy4cq7.js";
84
+ } from "../index-vj3vvpaa.js";
86
85
  import {
87
86
  AppError,
88
87
  STITCH_ERROR_STATUS,
package/dist/testing.js CHANGED
@@ -24,13 +24,12 @@ import {
24
24
  import {
25
25
  createClient,
26
26
  createClients
27
- } from "./index-v5dm4bwq.js";
27
+ } from "./index-58jzmnn4.js";
28
28
  import"./index-1rxswfbv.js";
29
29
  import"./index-nt1mp8km.js";
30
30
  import {
31
31
  joinRoutePath
32
- } from "./index-hsz2mmk0.js";
33
- import"./index-rxfy4cq7.js";
32
+ } from "./index-vj3vvpaa.js";
34
33
  import"./index-0w9abg87.js";
35
34
  import {
36
35
  isRecord
@@ -1,14 +1,13 @@
1
1
  import {
2
2
  createToolInvoker
3
- } from "./index-6wr9f6qm.js";
4
- import"./index-885chjxq.js";
5
- import"./index-k68e5jz0.js";
6
- import"./index-e0a57ymn.js";
3
+ } from "./index-jqtsc9mj.js";
4
+ import"./index-7qy2ex0m.js";
5
+ import"./index-s4c8wy8m.js";
6
+ import"./index-nemjkxjp.js";
7
7
  import"./index-22by16v6.js";
8
8
  import"./index-cby4ar3v.js";
9
9
  import"./index-nt1mp8km.js";
10
- import"./index-hsz2mmk0.js";
11
- import"./index-rxfy4cq7.js";
10
+ import"./index-vj3vvpaa.js";
12
11
  import"./index-0w9abg87.js";
13
12
  import"./index-qyrqwr4c.js";
14
13
  import"./index-6k1937bx.js";
package/dist/tools.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  redact
3
- } from "./index-28jsdwt1.js";
3
+ } from "./index-aczggrty.js";
4
4
  import {
5
5
  buildToolManifest,
6
6
  mountAgent
7
- } from "./index-xgahrwdf.js";
7
+ } from "./index-ezmn6ac6.js";
8
8
  import"./index-3xnq72rz.js";
9
9
  import {
10
10
  argumentsDigest
11
- } from "./index-vdvmcy7r.js";
11
+ } from "./index-a916km3r.js";
12
12
  import {
13
13
  signJwt,
14
14
  verifyPkce
15
- } from "./index-65kathdm.js";
15
+ } from "./index-da1aqnhb.js";
16
16
  import {
17
17
  DEFAULT_CORS_ALLOW_HEADERS,
18
18
  DEFAULT_PROCESS_SIGNALS,
@@ -20,10 +20,10 @@ import {
20
20
  defaultSignalSource,
21
21
  guardSignalCallback,
22
22
  reportSignalError
23
- } from "./index-endzd8sj.js";
23
+ } from "./index-vbf2p6me.js";
24
24
  import {
25
25
  createToolInvoker
26
- } from "./index-6wr9f6qm.js";
26
+ } from "./index-jqtsc9mj.js";
27
27
  import {
28
28
  WaitTimeoutError,
29
29
  createCli,
@@ -32,10 +32,10 @@ import {
32
32
  fetchPinnedDocument,
33
33
  readCapped,
34
34
  runWaitOperation
35
- } from "./index-9my2n66s.js";
35
+ } from "./index-s2rchahr.js";
36
36
  import {
37
37
  collectToolSurface
38
- } from "./index-9c5dbr5q.js";
38
+ } from "./index-k2zczx1g.js";
39
39
  import {
40
40
  createRuntimeToolFactory,
41
41
  defineRuntimeTool
@@ -44,19 +44,19 @@ import {
44
44
  collectTools,
45
45
  createToolRunner,
46
46
  formatToolError
47
- } from "./index-885chjxq.js";
47
+ } from "./index-7qy2ex0m.js";
48
48
  import {
49
49
  ToolExecutionControlError,
50
50
  coerceJsonArgs,
51
51
  executeToolMethod,
52
52
  isToolExecutionControlError,
53
53
  toolResultFromError
54
- } from "./index-k68e5jz0.js";
54
+ } from "./index-s4c8wy8m.js";
55
55
  import {
56
56
  getRequestContext,
57
57
  getTraceId,
58
58
  runWithRequestContext
59
- } from "./index-e0a57ymn.js";
59
+ } from "./index-nemjkxjp.js";
60
60
  import {
61
61
  ManagedFileError
62
62
  } from "./index-bfcpjw20.js";
@@ -79,8 +79,7 @@ import {
79
79
  } from "./index-nt1mp8km.js";
80
80
  import {
81
81
  defineContract
82
- } from "./index-hsz2mmk0.js";
83
- import"./index-rxfy4cq7.js";
82
+ } from "./index-vj3vvpaa.js";
84
83
  import {
85
84
  AppError,
86
85
  STITCH_ERROR_STATUS
@@ -1146,7 +1145,7 @@ async function resolveMcpRound(options) {
1146
1145
  });
1147
1146
  const requests = policy.inputRequired;
1148
1147
  const state = options.context.mcpReq.requestState();
1149
- const digest = await argumentsDigest(options.rawArgs);
1148
+ const digest = argumentsDigest(options.rawArgs);
1150
1149
  if (!state) {
1151
1150
  if (isRecord(options.context.mcpReq.inputResponses)) {
1152
1151
  return failedResolution({
package/llms-full.txt CHANGED
@@ -7657,6 +7657,13 @@ Without that, one address changing wakes every watcher of the operation. Twenty
7657
7657
  conversations open means twenty reads for one change — nineteen of them publish
7658
7658
  nothing, because nothing changed, and the read is paid anyway.
7659
7659
 
7660
+ The digest is a plain 128-bit hash computed in JavaScript, on purpose. It used
7661
+ to be SHA-256 through Web Crypto, which exists **only in a secure context** — so
7662
+ every watched read threw on a page served over plain HTTP from a LAN name, while
7663
+ `localhost` (secure by definition) and every test kept saying the code was fine.
7664
+ The key identifies a question; it does not protect one, and an attacker who can
7665
+ choose your watch arguments can already ask the question directly.
7666
+
7660
7667
  ### Who shares with whom
7661
7668
 
7662
7669
  A key is `(service, action, digest of arguments)`, and everyone on that key gets
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.76.1",
3
+ "version": "0.76.2",
4
4
  "description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
5
5
  "keywords": [
6
6
  "bun",
@@ -1,17 +0,0 @@
1
- // src/internal/base64url.ts
2
- function bytesToBase64Url(bytes) {
3
- let binary = "";
4
- for (const byte of bytes)
5
- binary += String.fromCharCode(byte);
6
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
7
- }
8
- function base64UrlToBytes(segment) {
9
- if (!/^[A-Za-z0-9_-]*$/.test(segment) || segment.length % 4 === 1) {
10
- throw new Error("invalid base64url segment");
11
- }
12
- const b64 = segment.replace(/-/g, "+").replace(/_/g, "/");
13
- const padded = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
14
- return Uint8Array.from(atob(padded), (c) => c.charCodeAt(0));
15
- }
16
-
17
- export { bytesToBase64Url, base64UrlToBytes };
@@ -1,22 +0,0 @@
1
- import {
2
- bytesToBase64Url
3
- } from "./index-rxfy4cq7.js";
4
-
5
- // src/internal/stable-digest.ts
6
- function stableValue(value) {
7
- if (Array.isArray(value))
8
- return value.map(stableValue);
9
- if (value === null || typeof value !== "object")
10
- return value;
11
- const result = {};
12
- for (const key of Object.keys(value).sort()) {
13
- result[key] = stableValue(Reflect.get(value, key));
14
- }
15
- return result;
16
- }
17
- async function argumentsDigest(args) {
18
- const bytes = new TextEncoder().encode(JSON.stringify(stableValue(args)));
19
- return bytesToBase64Url(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)));
20
- }
21
-
22
- export { stableValue, argumentsDigest };