stitchkit 0.137.0 → 0.137.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 (73) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/application/watch-hub-core.d.ts +4 -4
  3. package/dist/application/watch-hub-core.d.ts.map +1 -1
  4. package/dist/application/watch-hub-source.d.ts +11 -6
  5. package/dist/application/watch-hub-source.d.ts.map +1 -1
  6. package/dist/entrypoints/agent-runtime/harness.js +7 -7
  7. package/dist/entrypoints/agent-runtime/postgres.js +4 -4
  8. package/dist/entrypoints/agent-runtime/sqlite/bun.js +5 -5
  9. package/dist/entrypoints/agent-runtime/sqlite/node.js +5 -5
  10. package/dist/entrypoints/agent-runtime/testing.js +4 -4
  11. package/dist/entrypoints/agent-runtime.js +10 -10
  12. package/dist/entrypoints/application.js +43 -24
  13. package/dist/entrypoints/cli/publish.js +1 -1
  14. package/dist/entrypoints/cli.js +6 -6
  15. package/dist/entrypoints/contract.js +1 -1
  16. package/dist/entrypoints/device-relay.js +1 -1
  17. package/dist/entrypoints/files.js +1 -1
  18. package/dist/entrypoints/http.js +2 -2
  19. package/dist/entrypoints/index.js +3 -3
  20. package/dist/entrypoints/live.js +3 -3
  21. package/dist/entrypoints/node.js +1 -1
  22. package/dist/entrypoints/observability.js +1 -1
  23. package/dist/entrypoints/primitives.js +1 -1
  24. package/dist/entrypoints/server.js +1 -1
  25. package/dist/entrypoints/service-host/macos.js +3 -3
  26. package/dist/entrypoints/service-host/work.js +2 -2
  27. package/dist/entrypoints/service-host.js +5 -5
  28. package/dist/entrypoints/sync/postgres.js +1 -1
  29. package/dist/entrypoints/telegram/screens.js +2 -2
  30. package/dist/entrypoints/telegram.js +1 -1
  31. package/dist/entrypoints/testing.js +5 -5
  32. package/dist/entrypoints/tools/agent.js +3 -3
  33. package/dist/entrypoints/tools/connections.js +2 -2
  34. package/dist/entrypoints/tools/invoker.js +2 -2
  35. package/dist/entrypoints/tools/mcp.js +4 -4
  36. package/dist/entrypoints/tools/toolkit.js +7 -7
  37. package/dist/entrypoints/tools.js +6 -6
  38. package/dist/{index-rzc40z6e.js → index-0hg9qn4k.js} +1 -1
  39. package/dist/index-1q3g9tm7.js +42 -0
  40. package/dist/{index-1cfacbe2.js → index-2m40m971.js} +1 -1
  41. package/dist/{index-n74rb1dq.js → index-2x17xa52.js} +1 -1
  42. package/dist/{index-2j0pqxkn.js → index-3es8zyj7.js} +1 -1
  43. package/dist/{index-v64bvwjr.js → index-4ae1ahw7.js} +1 -1
  44. package/dist/{index-1bjwfnnj.js → index-5syxb9dh.js} +2 -2
  45. package/dist/{index-r1qt6zgj.js → index-7qhe3pta.js} +1 -1
  46. package/dist/{index-dp8j2e77.js → index-7tgda0jh.js} +2 -2
  47. package/dist/{index-z72agxdn.js → index-9ky1bh2k.js} +1 -1
  48. package/dist/{index-x2r0ma9t.js → index-9xpmj6rr.js} +1 -1
  49. package/dist/{index-scpcps66.js → index-ancgrcrq.js} +1 -1
  50. package/dist/{index-egpf9dv0.js → index-aw751yg0.js} +2 -2
  51. package/dist/{index-xvydbxmk.js → index-bnv8z91r.js} +2 -2
  52. package/dist/{index-tyyvbarf.js → index-by9bdgsg.js} +114 -39
  53. package/dist/{index-brhhaygm.js → index-e0e6m982.js} +1 -1
  54. package/dist/{index-pyazb8q4.js → index-h0vxzxfs.js} +2 -2
  55. package/dist/{index-frsd2a94.js → index-k9hdafzy.js} +1 -1
  56. package/dist/{index-77w5vx0g.js → index-m5npwse4.js} +1 -1
  57. package/dist/{index-2e4hdh32.js → index-rh6fg0fj.js} +1 -1
  58. package/dist/{index-ezgvsj9w.js → index-s5yrh7ej.js} +1 -1
  59. package/dist/{index-9nax7tkn.js → index-tm0sehb1.js} +3 -3
  60. package/dist/{index-3dq8466w.js → index-tvgwnxdk.js} +7 -4
  61. package/dist/{index-3f79t32b.js → index-vhgaazx9.js} +1 -1
  62. package/dist/{index-kaq9nb7h.js → index-vr5eknjs.js} +1 -1
  63. package/dist/{index-g0gvfzrx.js → index-w2yqhn8d.js} +5 -5
  64. package/dist/{index-8rkdkefj.js → index-xbkcky5q.js} +5 -5
  65. package/dist/{index-z6hq9j8j.js → index-zgkxc19c.js} +1 -1
  66. package/dist/{index-t7efje30.js → index-zpxf4zy7.js} +1 -1
  67. package/dist/internal/canonical-json.d.ts +5 -1
  68. package/dist/internal/canonical-json.d.ts.map +1 -1
  69. package/dist/internal/stable-digest.d.ts +8 -0
  70. package/dist/internal/stable-digest.d.ts.map +1 -1
  71. package/dist/live/watch-delta.d.ts.map +1 -1
  72. package/package.json +1 -1
  73. package/dist/index-fmzg39a8.js +0 -31
@@ -7,7 +7,7 @@ import {
7
7
  } from "./index-3tb82xr7.js";
8
8
  import {
9
9
  serializeCanonicalJson
10
- } from "./index-fmzg39a8.js";
10
+ } from "./index-1q3g9tm7.js";
11
11
  import {
12
12
  isRecord
13
13
  } from "./index-ps3djm8d.js";
@@ -39,73 +39,148 @@ var WatchArrayOpSchema2 = z.lazy(() => z.union([
39
39
  }),
40
40
  z.object({ o: z.literal("put"), v: z.unknown() })
41
41
  ]));
42
- function signature(value) {
43
- return serializeCanonicalJson(value);
42
+ var hasEnumerableOwn = (record, key) => Object.prototype.propertyIsEnumerable.call(record, key);
43
+ function isOmittedInObject(value) {
44
+ if (value === undefined || typeof value === "symbol")
45
+ return true;
46
+ if (typeof value === "function")
47
+ return JSON.stringify(value) === undefined;
48
+ return false;
49
+ }
50
+ function arrayElementSignature(value, cache) {
51
+ if (isOmittedInObject(value))
52
+ return "null";
53
+ return serializeCanonicalJson(value, cache);
44
54
  }
45
55
  function diff(previous, next) {
46
- if (signature(previous) === signature(next))
56
+ if (Object.is(previous, next))
57
+ return;
58
+ return diffValue(previous, next, new WeakMap);
59
+ }
60
+ function diffValue(previous, next, cache) {
61
+ if (Object.is(previous, next))
47
62
  return;
48
- if (isRecord(previous) && isRecord(next))
49
- return objectDiff(previous, next);
50
63
  if (Array.isArray(previous) && Array.isArray(next))
51
- return arrayDiff(previous, next);
64
+ return arrayDiff(previous, next, cache);
65
+ if (isRecord(previous) && isRecord(next))
66
+ return objectDiff(previous, next, cache);
67
+ if (typeof previous === "function" || typeof next === "function") {
68
+ return serializeCanonicalJson(previous, cache) === serializeCanonicalJson(next, cache) ? undefined : { t: "set", v: next };
69
+ }
70
+ if (isRecord(previous) || Array.isArray(previous) || isRecord(next) || Array.isArray(next)) {
71
+ return { t: "set", v: next };
72
+ }
73
+ if (previous === next || JSON.stringify(previous) === JSON.stringify(next)) {
74
+ return;
75
+ }
52
76
  return { t: "set", v: next };
53
77
  }
54
- function objectDiff(previous, next) {
78
+ function objectDiff(previous, next, cache) {
55
79
  const set = {};
56
80
  const drop = [];
57
81
  for (const key of Object.keys(next)) {
58
- if (!Object.hasOwn(previous, key)) {
59
- setOwnMember(set, key, { t: "set", v: next[key] });
82
+ const nextValue = next[key];
83
+ if (isOmittedInObject(nextValue))
84
+ continue;
85
+ if (!hasEnumerableOwn(previous, key) || isOmittedInObject(previous[key])) {
86
+ setOwnMember(set, key, { t: "set", v: nextValue });
60
87
  continue;
61
88
  }
62
- const nested = diff(previous[key], next[key]);
89
+ const nested = diffValue(previous[key], nextValue, cache);
63
90
  if (nested !== undefined)
64
91
  setOwnMember(set, key, nested);
65
92
  }
66
93
  for (const key of Object.keys(previous)) {
67
- if (!Object.hasOwn(next, key))
94
+ if (isOmittedInObject(previous[key]))
95
+ continue;
96
+ if (!hasEnumerableOwn(next, key) || isOmittedInObject(next[key]))
68
97
  drop.push(key);
69
98
  }
99
+ const hasSet = Object.keys(set).length > 0;
100
+ if (!hasSet && drop.length === 0)
101
+ return;
70
102
  return {
71
103
  t: "obj",
72
- ...Object.keys(set).length > 0 && { set },
104
+ ...hasSet && { set },
73
105
  ...drop.length > 0 && { drop }
74
106
  };
75
107
  }
76
- function arrayDiff(previous, next) {
77
- const previousSignatures = previous.map(signature);
78
- const nextSignatures = next.map(signature);
108
+ function arrayDiff(previous, next, cache) {
109
+ const minLength = Math.min(previous.length, next.length);
110
+ let prefix = 0;
111
+ while (prefix < minLength && Object.is(previous[prefix], next[prefix])) {
112
+ prefix += 1;
113
+ }
114
+ if (prefix === previous.length && prefix === next.length)
115
+ return;
116
+ let suffix = 0;
117
+ const maxSuffix = minLength - prefix;
118
+ while (suffix < maxSuffix && Object.is(previous[previous.length - 1 - suffix], next[next.length - 1 - suffix])) {
119
+ suffix += 1;
120
+ }
121
+ const prevEnd = previous.length - suffix;
122
+ const nextEnd = next.length - suffix;
123
+ const prevMidLen = prevEnd - prefix;
124
+ const nextMidLen = nextEnd - prefix;
125
+ const ops = [];
126
+ const appendCopy = (from, count) => {
127
+ if (count <= 0)
128
+ return;
129
+ const last = ops.at(-1);
130
+ if (last?.o === "copy" && last.from + last.count === from) {
131
+ ops[ops.length - 1] = { o: "copy", from: last.from, count: last.count + count };
132
+ return;
133
+ }
134
+ ops.push({ o: "copy", from, count });
135
+ };
136
+ appendCopy(0, prefix);
137
+ if (prevMidLen === 0) {
138
+ for (let index = prefix;index < nextEnd; index += 1)
139
+ ops.push({ o: "put", v: next[index] });
140
+ appendCopy(prevEnd, suffix);
141
+ return { t: "arr", ops };
142
+ }
143
+ if (nextMidLen === 0) {
144
+ appendCopy(prevEnd, suffix);
145
+ return { t: "arr", ops };
146
+ }
147
+ const previousSignatures = [];
148
+ for (let index = prefix;index < prevEnd; index += 1) {
149
+ previousSignatures.push(arrayElementSignature(previous[index], cache));
150
+ }
151
+ const nextSignatures = [];
152
+ let middleEqual = prevMidLen === nextMidLen;
153
+ for (let index = prefix;index < nextEnd; index += 1) {
154
+ const sig = arrayElementSignature(next[index], cache);
155
+ if (middleEqual && sig !== previousSignatures[index - prefix])
156
+ middleEqual = false;
157
+ nextSignatures.push(sig);
158
+ }
159
+ if (middleEqual)
160
+ return;
79
161
  const remaining = new Map;
80
- for (const value of nextSignatures)
81
- remaining.set(value, (remaining.get(value) ?? 0) + 1);
162
+ for (const sig of nextSignatures)
163
+ remaining.set(sig, (remaining.get(sig) ?? 0) + 1);
82
164
  const positions = new Map;
83
- previousSignatures.forEach((value, index) => {
84
- const bucket = positions.get(value);
165
+ previousSignatures.forEach((sig, offsetIndex) => {
166
+ const prevIndex = prefix + offsetIndex;
167
+ const bucket = positions.get(sig);
85
168
  if (bucket)
86
- bucket.push(index);
169
+ bucket.push(prevIndex);
87
170
  else
88
- positions.set(value, [index]);
171
+ positions.set(sig, [prevIndex]);
89
172
  });
90
173
  const offsets = new Map;
91
174
  const taken = new Set;
92
- const ops = [];
93
- let cursor = 0;
94
- const extend = (from) => {
95
- const last = ops.at(-1);
96
- if (last?.o !== "copy" || last.from + last.count !== from)
97
- return false;
98
- ops[ops.length - 1] = { o: "copy", from: last.from, count: last.count + 1 };
99
- return true;
100
- };
101
- for (const [index, wanted] of nextSignatures.entries()) {
102
- const element = next[index];
175
+ let cursor = prefix;
176
+ for (const [offsetIndex, wanted] of nextSignatures.entries()) {
177
+ const element = next[prefix + offsetIndex];
103
178
  remaining.set(wanted, (remaining.get(wanted) ?? 0) - 1);
104
179
  const last = ops.at(-1);
105
180
  const continuation = last?.o === "copy" ? last.from + last.count : undefined;
106
- if (continuation !== undefined && continuation < previous.length && previousSignatures[continuation] === wanted && !taken.has(continuation)) {
181
+ if (continuation !== undefined && continuation >= prefix && continuation < prevEnd && previousSignatures[continuation - prefix] === wanted && !taken.has(continuation)) {
107
182
  taken.add(continuation);
108
- extend(continuation);
183
+ appendCopy(continuation, 1);
109
184
  cursor = continuation + 1;
110
185
  continue;
111
186
  }
@@ -119,14 +194,13 @@ function arrayDiff(previous, next) {
119
194
  offsets.set(wanted, found === undefined ? offset : offset + 1);
120
195
  if (found !== undefined) {
121
196
  taken.add(found);
122
- if (!extend(found))
123
- ops.push({ o: "copy", from: found, count: 1 });
197
+ appendCopy(found, 1);
124
198
  cursor = found + 1;
125
199
  continue;
126
200
  }
127
- const candidate = previousSignatures[cursor];
201
+ const candidate = cursor < prevEnd ? previousSignatures[cursor - prefix] : undefined;
128
202
  const counterpart = candidate !== undefined && !taken.has(cursor) && !remaining.get(candidate) ? cursor : undefined;
129
- const nested = counterpart === undefined ? undefined : diff(previous[counterpart], element);
203
+ const nested = counterpart === undefined ? undefined : diffValue(previous[counterpart], element, cache);
130
204
  if (counterpart !== undefined && nested !== undefined) {
131
205
  taken.add(counterpart);
132
206
  ops.push({ o: "patch", from: counterpart, d: nested });
@@ -135,6 +209,7 @@ function arrayDiff(previous, next) {
135
209
  }
136
210
  ops.push({ o: "put", v: element });
137
211
  }
212
+ appendCopy(prevEnd, suffix);
138
213
  return { t: "arr", ops };
139
214
  }
140
215
  function apply(previous, delta) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-m6w6jtda.js";
4
4
  import {
5
5
  serializeCanonicalJson
6
- } from "./index-fmzg39a8.js";
6
+ } from "./index-1q3g9tm7.js";
7
7
 
8
8
  // src/primitives/canonical-json.ts
9
9
  import { z } from "zod";
@@ -14,13 +14,13 @@ import {
14
14
  flattenToolJsonSchema2,
15
15
  createToolRunner,
16
16
  formatToolError
17
- } from "./index-scpcps66.js";
17
+ } from "./index-ancgrcrq.js";
18
18
  import {
19
19
  AgentToolError2
20
20
  } from "./index-1psbyyhj.js";
21
21
  import {
22
22
  collectToolSurface
23
- } from "./index-rzc40z6e.js";
23
+ } from "./index-0hg9qn4k.js";
24
24
  import {
25
25
  assertErrorCodeMapping
26
26
  } from "./index-fy9mmek1.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./index-3tb82xr7.js";
10
10
  import {
11
11
  serializeCanonicalJson
12
- } from "./index-fmzg39a8.js";
12
+ } from "./index-1q3g9tm7.js";
13
13
  import {
14
14
  isRecord
15
15
  } from "./index-ps3djm8d.js";
@@ -16,7 +16,7 @@ import {
16
16
  } from "./index-jj9228tt.js";
17
17
  import {
18
18
  canonicalDigest
19
- } from "./index-3dq8466w.js";
19
+ } from "./index-tvgwnxdk.js";
20
20
  import {
21
21
  assertPositiveSafeInteger
22
22
  } from "./index-gr0kxymw.js";
@@ -3,7 +3,7 @@ import {
3
3
  isAbsoluteNormalPath,
4
4
  sameHostPath,
5
5
  createBaseServiceHostAdapter
6
- } from "./index-z72agxdn.js";
6
+ } from "./index-9ky1bh2k.js";
7
7
  import {
8
8
  errnoOf
9
9
  } from "./index-jj9228tt.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-yt1gg11x.js";
4
4
  import {
5
5
  projectToolSurface
6
- } from "./index-scpcps66.js";
6
+ } from "./index-ancgrcrq.js";
7
7
  import {
8
8
  contractOnlyService
9
9
  } from "./index-s5axtd56.js";
@@ -9,10 +9,10 @@ import {
9
9
  nextEventSeqByMaximum,
10
10
  agentSqlTables,
11
11
  createAgentRuntimeStore2
12
- } from "./index-v64bvwjr.js";
12
+ } from "./index-4ae1ahw7.js";
13
13
  import {
14
14
  canonicalAgentJson2
15
- } from "./index-kaq9nb7h.js";
15
+ } from "./index-vr5eknjs.js";
16
16
  import {
17
17
  createCompanionHost,
18
18
  conversationTables,
@@ -24,7 +24,7 @@ import {
24
24
  scanSqlRecoverable,
25
25
  listSqlConversations,
26
26
  pageSqlConversationMessages
27
- } from "./index-1bjwfnnj.js";
27
+ } from "./index-5syxb9dh.js";
28
28
  import {
29
29
  rollbackSqliteFailure
30
30
  } from "./index-ttexdtjj.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serializeCanonicalJson
3
- } from "./index-fmzg39a8.js";
3
+ } from "./index-1q3g9tm7.js";
4
4
 
5
5
  // src/internal/stable-digest.ts
6
6
  function mix128(input) {
@@ -33,9 +33,12 @@ function mix128(input) {
33
33
  function argumentsDigest(args) {
34
34
  return canonicalDigest(args);
35
35
  }
36
- function canonicalDigest(value) {
37
- const lanes = mix128(serializeCanonicalJson(value));
36
+ function digestCanonicalText(canonical) {
37
+ const lanes = mix128(canonical);
38
38
  return lanes.map((lane) => lane.toString(16).padStart(8, "0")).join("");
39
39
  }
40
+ function canonicalDigest(value) {
41
+ return digestCanonicalText(serializeCanonicalJson(value));
42
+ }
40
43
 
41
- export { argumentsDigest, canonicalDigest };
44
+ export { argumentsDigest, digestCanonicalText, canonicalDigest };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serializeCanonicalJson
3
- } from "./index-fmzg39a8.js";
3
+ } from "./index-1q3g9tm7.js";
4
4
  import {
5
5
  assertTimerMs
6
6
  } from "./index-e1y74yra.js";
@@ -22,7 +22,7 @@ import {
22
22
  } from "./index-gvv7y0s4.js";
23
23
  import {
24
24
  canonicalZodJson
25
- } from "./index-brhhaygm.js";
25
+ } from "./index-e0e6m982.js";
26
26
 
27
27
  // src/agent-runtime/invocation-schema.ts
28
28
  import { z as z2 } from "zod";
@@ -42,11 +42,11 @@ import {
42
42
  canonicalAgentJson2,
43
43
  issueRunContext,
44
44
  isActiveRunState
45
- } from "./index-kaq9nb7h.js";
45
+ } from "./index-vr5eknjs.js";
46
46
  import {
47
47
  ToolExecutionControlError2,
48
48
  isToolExecutionControlError2
49
- } from "./index-scpcps66.js";
49
+ } from "./index-ancgrcrq.js";
50
50
  import {
51
51
  AGENT_TOOL_PROGRESS_MESSAGE_MAX2,
52
52
  agentDurableEventId2
@@ -88,10 +88,10 @@ import {
88
88
  } from "./index-knqye3gv.js";
89
89
  import {
90
90
  listContractToolNames2
91
- } from "./index-ezgvsj9w.js";
91
+ } from "./index-s5yrh7ej.js";
92
92
  import {
93
93
  finalizeAgentToolOutput
94
- } from "./index-pyazb8q4.js";
94
+ } from "./index-h0vxzxfs.js";
95
95
  import {
96
96
  AgentToolError2,
97
97
  isAgentToolError2
@@ -109,7 +109,7 @@ import {
109
109
  } from "./index-3tb82xr7.js";
110
110
  import {
111
111
  serializeCanonicalJson
112
- } from "./index-fmzg39a8.js";
112
+ } from "./index-1q3g9tm7.js";
113
113
  import {
114
114
  assertTimerMs,
115
115
  withDeadline
@@ -16,7 +16,7 @@ import {
16
16
  collectTools2,
17
17
  createToolRunner,
18
18
  formatToolError
19
- } from "./index-scpcps66.js";
19
+ } from "./index-ancgrcrq.js";
20
20
  import {
21
21
  publishedToolAnnotations
22
22
  } from "./index-8k3y9nd4.js";
@@ -25,7 +25,7 @@ import {
25
25
  validateMcpRoundPolicy,
26
26
  validateResolvedInputRounds,
27
27
  prepareProjectedMcpTools
28
- } from "./index-x2r0ma9t.js";
28
+ } from "./index-9xpmj6rr.js";
29
29
  import {
30
30
  markProtocolOutcome
31
31
  } from "./index-cfnmvcq8.js";
@@ -50,7 +50,7 @@ import {
50
50
  } from "./index-gzqy81tw.js";
51
51
  import {
52
52
  collectToolSurface
53
- } from "./index-rzc40z6e.js";
53
+ } from "./index-0hg9qn4k.js";
54
54
  import {
55
55
  assertErrorCodeMapping
56
56
  } from "./index-fy9mmek1.js";
@@ -66,11 +66,11 @@ import {
66
66
  } from "./index-3pb4ccj2.js";
67
67
  import {
68
68
  argumentsDigest
69
- } from "./index-3dq8466w.js";
69
+ } from "./index-tvgwnxdk.js";
70
70
  import {
71
71
  compareCodeUnits,
72
72
  serializeCanonicalJson
73
- } from "./index-fmzg39a8.js";
73
+ } from "./index-1q3g9tm7.js";
74
74
  import {
75
75
  resolvePropagationContext2
76
76
  } from "./index-y7sy1xdp.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isAbsoluteNormalPath,
3
3
  createBaseServiceHostAdapter
4
- } from "./index-z72agxdn.js";
4
+ } from "./index-9ky1bh2k.js";
5
5
  import {
6
6
  errnoOf
7
7
  } from "./index-jj9228tt.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./index-wdg7bswj.js";
10
10
  import {
11
11
  canonicalDigest
12
- } from "./index-3dq8466w.js";
12
+ } from "./index-tvgwnxdk.js";
13
13
  import {
14
14
  typedEntries,
15
15
  isRecord
@@ -25,6 +25,10 @@ export declare function compareCodeUnits(left: string, right: string): number;
25
25
  * refuse such values validates before calling (the agent store parses with
26
26
  * `z.json()` first). A top-level `undefined` answers `'undefined'`, so the
27
27
  * result is always a string.
28
+ *
29
+ * An optional per-call `cache` memoises container objects within one traversal
30
+ * (for example, shared subtrees across elements of a watched array diff). Never
31
+ * reuse a cache across calls if callers can mutate objects between calls.
28
32
  */
29
- export declare function serializeCanonicalJson(value: unknown): string;
33
+ export declare function serializeCanonicalJson(value: unknown, cache?: WeakMap<object, string>): string;
30
34
  //# sourceMappingURL=canonical-json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"canonical-json.d.ts","sourceRoot":"","sources":["../../src/internal/canonical-json.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpE;AAyBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE7D"}
1
+ {"version":3,"file":"canonical-json.d.ts","sourceRoot":"","sources":["../../src/internal/canonical-json.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpE;AAiCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAGR"}
@@ -12,6 +12,14 @@
12
12
  * construction; a caller digesting something else has to say what it means.
13
13
  */
14
14
  export declare function argumentsDigest(args: Record<string, unknown>): string;
15
+ /**
16
+ * The 128-bit identity over an already-canonicalised JSON string.
17
+ *
18
+ * Callers that already hold the canonical text — such as the watch hub
19
+ * comparing a new reading against its previous signature — hash that text
20
+ * directly instead of traversing the value a second time.
21
+ */
22
+ export declare function digestCanonicalText(canonical: string): string;
15
23
  /**
16
24
  * The same 128-bit identity over any JSON value — a schema, a set of
17
25
  * operations — for callers whose subject is not a call's arguments.
@@ -1 +1 @@
1
- {"version":3,"file":"stable-digest.d.ts","sourceRoot":"","sources":["../../src/internal/stable-digest.ts"],"names":[],"mappings":"AA6EA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAErE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGtD"}
1
+ {"version":3,"file":"stable-digest.d.ts","sourceRoot":"","sources":["../../src/internal/stable-digest.ts"],"names":[],"mappings":"AA6EA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAErE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"watch-delta.d.ts","sourceRoot":"","sources":["../../src/live/watch-delta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,6DAA6D;AAC7D,MAAM,MAAM,YAAY;AACtB,wEAAwE;AACtE;IAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACvE,+DAA+D;GAC7D;IAAE,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAA;CAAE;AACxE,4DAA4D;GAC1D;IAAE,QAAQ,CAAC,CAAC,EAAE,KAAK,C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AAI,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAG7E;AA+MD;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAyCnE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.137.0",
3
+ "version": "0.137.1",
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,31 +0,0 @@
1
- import {
2
- isRecord
3
- } from "./index-ps3djm8d.js";
4
-
5
- // src/internal/canonical-json.ts
6
- function compareCodeUnits(left, right) {
7
- if (left < right)
8
- return -1;
9
- if (left > right)
10
- return 1;
11
- return 0;
12
- }
13
- function canonicalText(value) {
14
- if (Array.isArray(value)) {
15
- return `[${Array.from(value, (item) => canonicalText(item) ?? "null").join(",")}]`;
16
- }
17
- if (!isRecord(value))
18
- return JSON.stringify(value);
19
- const members = [];
20
- for (const key of Object.keys(value).sort(compareCodeUnits)) {
21
- const text = canonicalText(value[key]);
22
- if (text !== undefined)
23
- members.push(`${JSON.stringify(key)}:${text}`);
24
- }
25
- return `{${members.join(",")}}`;
26
- }
27
- function serializeCanonicalJson(value) {
28
- return canonicalText(value) ?? "undefined";
29
- }
30
-
31
- export { compareCodeUnits, serializeCanonicalJson };