stitchkit 0.78.0 → 0.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/agent-runtime-browser.js +53 -581
  2. package/dist/agent-runtime-coding-tools.js +6 -5
  3. package/dist/agent-runtime-harness.js +21 -94
  4. package/dist/agent-runtime-openrouter.js +1 -1
  5. package/dist/agent-runtime.js +68 -64
  6. package/dist/application/kernel.d.ts.map +1 -1
  7. package/dist/application/schemas.d.ts +2 -0
  8. package/dist/application/schemas.d.ts.map +1 -1
  9. package/dist/application/watch-hub.d.ts.map +1 -1
  10. package/dist/application-diagnostic-journal.js +14 -96
  11. package/dist/application-opentelemetry.js +6 -92
  12. package/dist/application-schemas.js +2 -1
  13. package/dist/application.js +158 -1802
  14. package/dist/cli.js +13 -11
  15. package/dist/contract/index.js +7 -4
  16. package/dist/index-2qzskm8h.js +63 -0
  17. package/dist/{index-93xp5tgg.js → index-2rwwmr7v.js} +3 -3
  18. package/dist/{index-kw12fsbc.js → index-3gye9wzb.js} +7 -3
  19. package/dist/{index-1ckavx4h.js → index-3z73fh2c.js} +1 -49
  20. package/dist/index-4fpa9dy2.js +51 -0
  21. package/dist/{index-cwp38wxn.js → index-5mtc969c.js} +2 -2
  22. package/dist/index-5s3zajp8.js +192 -0
  23. package/dist/index-6s7n2v50.js +583 -0
  24. package/dist/{index-qaajjfp6.js → index-758zx2ha.js} +15 -94
  25. package/dist/{index-qyrqwr4c.js → index-77fekveh.js} +4 -1
  26. package/dist/{index-k45qqrdh.js → index-7ag81v2f.js} +13 -166
  27. package/dist/{index-n1g2xm6a.js → index-7gnkny4z.js} +124 -1
  28. package/dist/index-7zbps32p.js +89 -0
  29. package/dist/index-85vfqd7m.js +135 -0
  30. package/dist/{index-4ntp63ps.js → index-9s6z8vgf.js} +18 -142
  31. package/dist/index-a916km3r.js +45 -0
  32. package/dist/index-b9aefrqd.js +20 -0
  33. package/dist/index-dre2ywck.js +48 -0
  34. package/dist/{index-s5tn4kdv.js → index-dwf1f2ap.js} +3 -3
  35. package/dist/{index-wwst0td5.js → index-dx9xehwt.js} +1 -1
  36. package/dist/{index-5r0ak8fr.js → index-dxesg10d.js} +4 -4
  37. package/dist/{index-aczggrty.js → index-dxjjv399.js} +2 -2
  38. package/dist/{index-j6mfaw26.js → index-egaabxkz.js} +3 -3
  39. package/dist/index-evcnmsc3.js +866 -0
  40. package/dist/{index-efm026pw.js → index-fxz0v7vg.js} +86 -86
  41. package/dist/{index-56fm73re.js → index-hb5pf3s4.js} +1 -1
  42. package/dist/{index-n7apa6sy.js → index-k9ay6v6d.js} +24 -275
  43. package/dist/index-kzfs85xp.js +9 -0
  44. package/dist/{index-vbf2p6me.js → index-m9kzax52.js} +91 -89
  45. package/dist/{index-22by16v6.js → index-mgtxfe6b.js} +1 -1
  46. package/dist/index-p7hgdyhb.js +22 -0
  47. package/dist/index-pq95qkbf.js +0 -0
  48. package/dist/index-t0z5p5w6.js +318 -0
  49. package/dist/{index-31k1ns1s.js → index-vwp69871.js} +13 -11
  50. package/dist/index-wc4x00bn.js +103 -0
  51. package/dist/{index-aewy3x5j.js → index-xcetq6j3.js} +10 -8
  52. package/dist/{index-7z69kyrh.js → index-y01f4223.js} +24 -40
  53. package/dist/{index-dmfn9m4x.js → index-ywd0y6m1.js} +20 -341
  54. package/dist/index.js +46 -407
  55. package/dist/live.js +6 -3
  56. package/dist/node.js +17 -14
  57. package/dist/observability/index.js +8 -7
  58. package/dist/primitives.js +4 -2
  59. package/dist/react.js +1 -1
  60. package/dist/remote.js +7 -3
  61. package/dist/server/index.js +32 -45
  62. package/dist/telegram.js +1 -1
  63. package/dist/testing.js +90 -1576
  64. package/dist/tool-invoker.js +11 -9
  65. package/dist/tools/async-operation-contract.d.ts +93 -0
  66. package/dist/tools/async-operation-contract.d.ts.map +1 -0
  67. package/dist/tools/async-operation.d.ts +2 -47
  68. package/dist/tools/async-operation.d.ts.map +1 -1
  69. package/dist/tools/view-file-contract.d.ts +98 -0
  70. package/dist/tools/view-file-contract.d.ts.map +1 -0
  71. package/dist/tools/view-file.d.ts +4 -83
  72. package/dist/tools/view-file.d.ts.map +1 -1
  73. package/dist/tools-contract.d.ts +29 -0
  74. package/dist/tools-contract.d.ts.map +1 -0
  75. package/dist/tools-contract.js +24 -0
  76. package/dist/tools.d.ts +3 -3
  77. package/dist/tools.d.ts.map +1 -1
  78. package/dist/tools.js +61 -140
  79. package/llms-full.txt +86 -3
  80. package/package.json +9 -6
  81. package/dist/index-anyqnqcv.js +0 -79
  82. package/dist/index-ksp6e2ye.js +0 -24
  83. package/dist/index-vj3vvpaa.js +0 -307
  84. package/dist/index-wfq8zerm.js +0 -92
@@ -7,36 +7,33 @@ import {
7
7
  isCompleteAgentHistoryTurn
8
8
  } from "./index-y2s6h5bf.js";
9
9
  import {
10
- isAgentToolError
11
- } from "./index-3xnq72rz.js";
10
+ createBoundedSinkManager
11
+ } from "./index-a59da114.js";
12
12
  import {
13
- ToolExecutionControlError,
14
- isToolExecutionControlError
15
- } from "./index-qaajjfp6.js";
13
+ AgentRuntimeEventSchema,
14
+ agentDurableEventId
15
+ } from "./index-85vfqd7m.js";
16
16
  import {
17
17
  AgentAssistantPlaceholderSchema,
18
18
  AgentJsonObjectSchema,
19
19
  AgentMessagePartSchema,
20
20
  AgentMessageSchema,
21
21
  AgentProvenanceSchema,
22
- AgentProviderEnvelopeSchema,
23
- AgentRecordIdSchema,
24
- AgentRecordVersionSchema,
25
- AgentRunMetricsSchema,
26
22
  AgentRunSchema,
27
- AgentRunStateSchema,
28
23
  AgentSnapshotSchema,
29
- AgentTerminalReasonSchema,
30
- AgentTimestampSchema,
31
24
  runStateForTerminalReason
32
25
  } from "./index-x1th9s8c.js";
33
26
  import {
34
- createBoundedSinkManager
35
- } from "./index-a59da114.js";
27
+ isAgentToolError
28
+ } from "./index-3xnq72rz.js";
29
+ import {
30
+ ToolExecutionControlError,
31
+ isToolExecutionControlError
32
+ } from "./index-758zx2ha.js";
36
33
  import {
37
34
  isRecord,
38
35
  transportResult
39
- } from "./index-qyrqwr4c.js";
36
+ } from "./index-77fekveh.js";
40
37
 
41
38
  // src/agent-runtime/context-refusal.ts
42
39
  class AgentContextOverflowError extends Error {
@@ -189,127 +186,6 @@ function createAgentSessionCoordinator() {
189
186
  };
190
187
  }
191
188
 
192
- // src/agent-runtime/event-schema.ts
193
- import { z } from "zod";
194
- var AgentAdmissionEventSchema = z.object({
195
- type: z.literal("admission"),
196
- eventId: AgentRecordIdSchema,
197
- conversationId: AgentRecordIdSchema,
198
- runId: AgentRecordIdSchema,
199
- snapshotVersion: AgentRecordVersionSchema,
200
- input: AgentMessageSchema,
201
- run: AgentRunSchema,
202
- assistant: z.union([AgentAssistantPlaceholderSchema, AgentMessageSchema]),
203
- emittedAt: AgentTimestampSchema
204
- });
205
- var EventIdentitySchema = z.object({
206
- conversationId: AgentRecordIdSchema,
207
- runId: AgentRecordIdSchema,
208
- emittedAt: AgentTimestampSchema
209
- });
210
- var AgentTransientDeltaEventSchema = EventIdentitySchema.extend({
211
- type: z.literal("assistant-delta"),
212
- runtimeEpoch: z.string().min(1),
213
- sequence: z.int().nonnegative(),
214
- textDelta: z.string()
215
- });
216
- var AgentTransientReasoningIdentitySchema = EventIdentitySchema.extend({
217
- runtimeEpoch: z.string().min(1),
218
- sequence: z.int().nonnegative(),
219
- provider: AgentProviderEnvelopeSchema.optional()
220
- });
221
- var AgentReasoningStartEventSchema = AgentTransientReasoningIdentitySchema.extend({
222
- type: z.literal("reasoning-start")
223
- });
224
- var AgentReasoningDeltaEventSchema = AgentTransientReasoningIdentitySchema.extend({
225
- type: z.literal("reasoning-delta"),
226
- textDelta: z.string()
227
- });
228
- var AgentReasoningEndEventSchema = AgentTransientReasoningIdentitySchema.extend({
229
- type: z.literal("reasoning-end")
230
- });
231
- var AgentCheckpointEventSchema = EventIdentitySchema.extend({
232
- type: z.literal("assistant-checkpoint"),
233
- eventId: AgentRecordIdSchema,
234
- snapshotVersion: AgentRecordVersionSchema,
235
- message: AgentMessageSchema,
236
- metrics: AgentRunMetricsSchema.optional()
237
- });
238
- var AgentRunStateEventSchema = EventIdentitySchema.extend({
239
- type: z.literal("run-state"),
240
- eventId: AgentRecordIdSchema,
241
- snapshotVersion: AgentRecordVersionSchema,
242
- state: AgentRunStateSchema
243
- });
244
- var AgentToolStatusEventSchema = EventIdentitySchema.extend({
245
- type: z.literal("tool-status"),
246
- runtimeEpoch: z.string().min(1),
247
- sequence: z.int().nonnegative(),
248
- callId: AgentRecordIdSchema,
249
- toolName: z.string().min(1),
250
- status: z.enum(["started", "completed", "failed", "interrupted"]),
251
- input: z.json().optional(),
252
- output: z.json().optional()
253
- });
254
- var AgentTerminalEventSchema = EventIdentitySchema.extend({
255
- type: z.literal("terminal"),
256
- eventId: AgentRecordIdSchema,
257
- snapshotVersion: AgentRecordVersionSchema,
258
- reason: AgentTerminalReasonSchema,
259
- policyName: z.string().min(1).optional(),
260
- message: AgentMessageSchema,
261
- metrics: AgentRunMetricsSchema.optional()
262
- });
263
- var AgentRuntimeEventSchema = z.discriminatedUnion("type", [
264
- AgentAdmissionEventSchema,
265
- AgentTransientDeltaEventSchema,
266
- AgentReasoningStartEventSchema,
267
- AgentReasoningDeltaEventSchema,
268
- AgentReasoningEndEventSchema,
269
- AgentCheckpointEventSchema,
270
- AgentRunStateEventSchema,
271
- AgentToolStatusEventSchema,
272
- AgentTerminalEventSchema
273
- ]);
274
- var AgentRuntimeEventCursorSchema = z.object({
275
- snapshotVersion: AgentRecordVersionSchema.optional(),
276
- durableEventIds: z.array(AgentRecordIdSchema).optional(),
277
- runtimeEpoch: z.string().min(1).optional(),
278
- sequence: z.int().nonnegative().optional()
279
- });
280
- function isDurableEvent(event) {
281
- return event.type === "admission" || event.type === "assistant-checkpoint" || event.type === "run-state" || event.type === "terminal";
282
- }
283
- function advanceAgentRuntimeEventCursor(rawCursor, event) {
284
- const cursor = AgentRuntimeEventCursorSchema.parse(rawCursor);
285
- if (isDurableEvent(event)) {
286
- const previous = cursor.snapshotVersion;
287
- const durableEventIds = previous === event.snapshotVersion ? cursor.durableEventIds ?? [] : [];
288
- if (previous !== undefined && event.snapshotVersion < previous || durableEventIds.includes(event.eventId)) {
289
- return { status: "duplicate", cursor };
290
- }
291
- return {
292
- status: "accepted",
293
- cursor: {
294
- ...cursor,
295
- snapshotVersion: event.snapshotVersion,
296
- durableEventIds: [...durableEventIds, event.eventId]
297
- }
298
- };
299
- }
300
- const previousSequence = cursor.runtimeEpoch === event.runtimeEpoch ? cursor.sequence : undefined;
301
- if (previousSequence !== undefined && event.sequence <= previousSequence) {
302
- return { status: "duplicate", cursor };
303
- }
304
- return {
305
- status: previousSequence !== undefined && event.sequence > previousSequence + 1 ? "gap" : "accepted",
306
- cursor: { ...cursor, runtimeEpoch: event.runtimeEpoch, sequence: event.sequence }
307
- };
308
- }
309
- function agentDurableEventId(type, runId, snapshotVersion) {
310
- return `${runId}:${type}:${snapshotVersion}`;
311
- }
312
-
313
189
  // src/agent-runtime/events.ts
314
190
  function createAgentRuntimeEventSink(config) {
315
191
  const manager = createBoundedSinkManager({
@@ -625,9 +501,9 @@ function createAgentToolFenceLifecycle(config) {
625
501
  }
626
502
 
627
503
  // src/agent-runtime/prompt.ts
628
- import { z as z2 } from "zod";
629
- var AgentTokenCountSchema = z2.object({
630
- value: z2.int().nonnegative().optional(),
504
+ import { z } from "zod";
505
+ var AgentTokenCountSchema = z.object({
506
+ value: z.int().nonnegative().optional(),
631
507
  provenance: AgentProvenanceSchema.extract([
632
508
  "measured",
633
509
  "computed",
@@ -1058,7 +934,7 @@ function repairedSearchCall(toolCall, searchName) {
1058
934
  }
1059
935
 
1060
936
  // src/agent-runtime/runtime-internals.ts
1061
- import { z as z3 } from "zod";
937
+ import { z as z2 } from "zod";
1062
938
  function findRun(runs, runId) {
1063
939
  const run = runs.find((candidate) => candidate.id === runId);
1064
940
  if (!run)
@@ -1066,7 +942,7 @@ function findRun(runs, runId) {
1066
942
  return run;
1067
943
  }
1068
944
  function jsonValue(value) {
1069
- const parsed = z3.json().safeParse(value);
945
+ const parsed = z2.json().safeParse(value);
1070
946
  return parsed.success ? parsed.data : { message: "Non-JSON tool output omitted" };
1071
947
  }
1072
948
  function providerEnvelope(value) {
@@ -2567,4 +2443,4 @@ function createAgentRuntime(config) {
2567
2443
  };
2568
2444
  }
2569
2445
 
2570
- export { AgentContextOverflowError, createAgentSessionCoordinator, registerDeferredToolRepair, registerDeferredToolCatalog, deferredToolCatalog, repairedSearchCall, AgentAdmissionEventSchema, AgentTransientDeltaEventSchema, AgentReasoningStartEventSchema, AgentReasoningDeltaEventSchema, AgentReasoningEndEventSchema, AgentCheckpointEventSchema, AgentRunStateEventSchema, AgentToolStatusEventSchema, AgentTerminalEventSchema, AgentRuntimeEventSchema, AgentRuntimeEventCursorSchema, advanceAgentRuntimeEventCursor, agentDurableEventId, createAgentRuntimeEventSink, projectAgentHistoryDetailed, projectAgentHistory, createAgentToolFenceLifecycle, AgentTokenCountSchema, selectAgentHistory, composeAgentPrompt, AgentRuntimeConflictError, createAgentRuntime };
2446
+ export { AgentContextOverflowError, createAgentSessionCoordinator, registerDeferredToolRepair, registerDeferredToolCatalog, deferredToolCatalog, repairedSearchCall, createAgentRuntimeEventSink, projectAgentHistoryDetailed, projectAgentHistory, createAgentToolFenceLifecycle, AgentTokenCountSchema, selectAgentHistory, composeAgentPrompt, AgentRuntimeConflictError, createAgentRuntime };
@@ -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 };
@@ -0,0 +1,20 @@
1
+ // src/internal/deadline.ts
2
+ async function withDeadline(value, timeoutMs) {
3
+ if (!(value instanceof Promise))
4
+ return { settled: true, value };
5
+ let timer;
6
+ const expiry = new Promise((resolve) => {
7
+ timer = setTimeout(() => resolve({ settled: false }), timeoutMs);
8
+ });
9
+ try {
10
+ return await Promise.race([
11
+ value.then((settledValue) => ({ settled: true, value: settledValue })),
12
+ expiry
13
+ ]);
14
+ } finally {
15
+ if (timer !== undefined)
16
+ clearTimeout(timer);
17
+ }
18
+ }
19
+
20
+ export { withDeadline };
@@ -0,0 +1,48 @@
1
+ import {
2
+ LiveStatePhaseSchema,
3
+ LiveStateStopReasonSchema
4
+ } from "./index-ywd0y6m1.js";
5
+
6
+ // src/live/watch-contract.ts
7
+ import { z } from "zod";
8
+ var WatchKeySchema = z.object({
9
+ service: z.string().min(1),
10
+ action: z.string().min(1),
11
+ digest: z.string().min(1)
12
+ }).strict().readonly();
13
+ var WatchOpenSchema = z.object({ key: WatchKeySchema, args: z.unknown() }).readonly();
14
+ var WatchAcceptedSchema = z.object({
15
+ accepted: z.boolean(),
16
+ reason: z.string().optional()
17
+ }).strict().readonly();
18
+ var WatchValueSchema = z.object({
19
+ key: WatchKeySchema,
20
+ revision: z.number().int().nonnegative(),
21
+ value: z.unknown()
22
+ }).readonly();
23
+ var WatchStateSchema = z.object({
24
+ key: WatchKeySchema,
25
+ phase: LiveStatePhaseSchema,
26
+ reason: LiveStateStopReasonSchema.optional(),
27
+ code: z.string().optional(),
28
+ message: z.string().optional()
29
+ }).readonly();
30
+ var WATCH_OPEN = "stitchkit.watch.open";
31
+ var WATCH_CLOSE = "stitchkit.watch.close";
32
+ var WATCH_VALUE = "stitchkit.watch.value";
33
+ var WATCH_STATE = "stitchkit.watch.state";
34
+ var watchContract = {
35
+ serverToClient: {
36
+ [WATCH_VALUE]: { args: z.tuple([WatchValueSchema]) },
37
+ [WATCH_STATE]: { args: z.tuple([WatchStateSchema]) }
38
+ },
39
+ clientToServer: {
40
+ [WATCH_OPEN]: { args: z.tuple([WatchOpenSchema]), ack: WatchAcceptedSchema },
41
+ [WATCH_CLOSE]: { args: z.tuple([z.object({ key: WatchKeySchema }).readonly()]) }
42
+ }
43
+ };
44
+ function watchKeyString(key) {
45
+ return `${key.service}/${key.action}/${key.digest}`;
46
+ }
47
+
48
+ export { WatchKeySchema, WatchValueSchema, WatchStateSchema, WATCH_OPEN, WATCH_CLOSE, WATCH_VALUE, WATCH_STATE, watchContract, watchKeyString };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  resolveTraceContext
3
- } from "./index-efm026pw.js";
3
+ } from "./index-fxz0v7vg.js";
4
4
  import {
5
5
  isUnsafeKey
6
- } from "./index-vj3vvpaa.js";
6
+ } from "./index-kzfs85xp.js";
7
7
  import {
8
8
  isRecord
9
- } from "./index-qyrqwr4c.js";
9
+ } from "./index-77fekveh.js";
10
10
 
11
11
  // src/server/request.ts
12
12
  function generateTraceId() {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  projectRuntimeTool
3
- } from "./index-22by16v6.js";
3
+ } from "./index-mgtxfe6b.js";
4
4
 
5
5
  // src/tools/runtime-tool.ts
6
6
  function defineRuntimeTool(definition) {
@@ -3,18 +3,18 @@ import {
3
3
  } from "./index-3xnq72rz.js";
4
4
  import {
5
5
  collectToolSurface
6
- } from "./index-93xp5tgg.js";
6
+ } from "./index-2rwwmr7v.js";
7
7
  import {
8
8
  createToolRunner,
9
9
  formatToolError
10
- } from "./index-cwp38wxn.js";
10
+ } from "./index-5mtc969c.js";
11
11
  import {
12
12
  isToolExecutionControlError,
13
13
  toolResultFromError
14
- } from "./index-qaajjfp6.js";
14
+ } from "./index-758zx2ha.js";
15
15
  import {
16
16
  isRecord
17
- } from "./index-qyrqwr4c.js";
17
+ } from "./index-77fekveh.js";
18
18
 
19
19
  // src/tools/agent.ts
20
20
  import { jsonSchema, tool } from "ai";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isUnsafeKey
3
- } from "./index-vj3vvpaa.js";
3
+ } from "./index-kzfs85xp.js";
4
4
  import {
5
5
  isRecord
6
- } from "./index-qyrqwr4c.js";
6
+ } from "./index-77fekveh.js";
7
7
 
8
8
  // src/observability/sanitize.ts
9
9
  var SENSITIVE_WORDS = new Set([
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  collectTools,
3
3
  createToolRunner
4
- } from "./index-cwp38wxn.js";
4
+ } from "./index-5mtc969c.js";
5
5
  import {
6
6
  toolErrorFromResult
7
- } from "./index-qaajjfp6.js";
7
+ } from "./index-758zx2ha.js";
8
8
  import {
9
9
  assertUniqueToolName
10
- } from "./index-22by16v6.js";
10
+ } from "./index-mgtxfe6b.js";
11
11
  import {
12
12
  AppError
13
13
  } from "./index-0w9abg87.js";