stitchkit 0.88.0 → 0.90.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 (184) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/dist/agent-runtime/child-blocking.d.ts +17 -0
  3. package/dist/agent-runtime/child-blocking.d.ts.map +1 -0
  4. package/dist/agent-runtime/child-budget-policy.d.ts +23 -0
  5. package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -0
  6. package/dist/agent-runtime/children-contract.d.ts +155 -0
  7. package/dist/agent-runtime/children-contract.d.ts.map +1 -0
  8. package/dist/agent-runtime/children.d.ts +4 -99
  9. package/dist/agent-runtime/children.d.ts.map +1 -1
  10. package/dist/agent-runtime/coding-shell-process.d.ts +33 -0
  11. package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -0
  12. package/dist/agent-runtime/coding-tool-contract.d.ts +18 -0
  13. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
  14. package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
  15. package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
  16. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  17. package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
  18. package/dist/agent-runtime/coding-tool-utf8.d.ts +28 -0
  19. package/dist/agent-runtime/coding-tool-utf8.d.ts.map +1 -0
  20. package/dist/agent-runtime/contained-files.d.ts +20 -0
  21. package/dist/agent-runtime/contained-files.d.ts.map +1 -1
  22. package/dist/agent-runtime/durability-contract.d.ts +176 -0
  23. package/dist/agent-runtime/durability-contract.d.ts.map +1 -0
  24. package/dist/agent-runtime/durability-json.d.ts +3 -0
  25. package/dist/agent-runtime/durability-json.d.ts.map +1 -0
  26. package/dist/agent-runtime/durability-ledger.d.ts +16 -0
  27. package/dist/agent-runtime/durability-ledger.d.ts.map +1 -0
  28. package/dist/agent-runtime/durability-scheduler.d.ts +29 -0
  29. package/dist/agent-runtime/durability-scheduler.d.ts.map +1 -0
  30. package/dist/agent-runtime/durability.d.ts +14 -0
  31. package/dist/agent-runtime/durability.d.ts.map +1 -0
  32. package/dist/agent-runtime/event-search.d.ts.map +1 -1
  33. package/dist/agent-runtime/harness-contract.d.ts +37 -0
  34. package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
  35. package/dist/agent-runtime/harness.d.ts +8 -0
  36. package/dist/agent-runtime/harness.d.ts.map +1 -1
  37. package/dist/agent-runtime/prompt.d.ts +23 -0
  38. package/dist/agent-runtime/prompt.d.ts.map +1 -1
  39. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  40. package/dist/agent-runtime/runtime-internals.d.ts +4 -0
  41. package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
  42. package/dist/agent-runtime/runtime.d.ts +13 -0
  43. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  44. package/dist/agent-runtime/sandbox-broker.d.ts +7 -0
  45. package/dist/agent-runtime/sandbox-broker.d.ts.map +1 -0
  46. package/dist/agent-runtime/sandbox-bubblewrap-args.d.ts +9 -0
  47. package/dist/agent-runtime/sandbox-bubblewrap-args.d.ts.map +1 -0
  48. package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts +22 -0
  49. package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +1 -0
  50. package/dist/agent-runtime/sandbox-bubblewrap.d.ts +14 -0
  51. package/dist/agent-runtime/sandbox-bubblewrap.d.ts.map +1 -0
  52. package/dist/agent-runtime/sandbox-coding-adapter.d.ts +15 -0
  53. package/dist/agent-runtime/sandbox-coding-adapter.d.ts.map +1 -0
  54. package/dist/agent-runtime/sandbox-coding.d.ts +15 -0
  55. package/dist/agent-runtime/sandbox-coding.d.ts.map +1 -0
  56. package/dist/agent-runtime/sandbox-contract.d.ts +93 -0
  57. package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -0
  58. package/dist/agent-runtime/sandbox-process-owner.d.ts +11 -0
  59. package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -0
  60. package/dist/agent-runtime/sandbox-process.d.ts +8 -0
  61. package/dist/agent-runtime/sandbox-process.d.ts.map +1 -0
  62. package/dist/agent-runtime/sandbox-session.d.ts +5 -0
  63. package/dist/agent-runtime/sandbox-session.d.ts.map +1 -0
  64. package/dist/agent-runtime/sandbox.d.ts +19 -0
  65. package/dist/agent-runtime/sandbox.d.ts.map +1 -1
  66. package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
  67. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  68. package/dist/agent-runtime/store-driver.d.ts +127 -0
  69. package/dist/agent-runtime/store-driver.d.ts.map +1 -1
  70. package/dist/agent-runtime/store-events.d.ts +104 -0
  71. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  72. package/dist/agent-runtime/store-migrations/v2-to-v3.d.ts +14 -0
  73. package/dist/agent-runtime/store-migrations/v2-to-v3.d.ts.map +1 -0
  74. package/dist/agent-runtime/store.d.ts +115 -0
  75. package/dist/agent-runtime/store.d.ts.map +1 -1
  76. package/dist/agent-runtime-coding-tools.js +11 -1247
  77. package/dist/agent-runtime-harness.d.ts +1 -1
  78. package/dist/agent-runtime-harness.d.ts.map +1 -1
  79. package/dist/agent-runtime-harness.js +65 -15
  80. package/dist/agent-runtime-openrouter.d.ts +3 -12
  81. package/dist/agent-runtime-openrouter.d.ts.map +1 -1
  82. package/dist/agent-runtime-openrouter.js +10 -7
  83. package/dist/agent-runtime-sandbox.d.ts +5 -0
  84. package/dist/agent-runtime-sandbox.d.ts.map +1 -0
  85. package/dist/agent-runtime-sandbox.js +797 -0
  86. package/dist/agent-runtime-sqlite-bun.js +3 -3
  87. package/dist/agent-runtime-sqlite-node.js +3 -3
  88. package/dist/agent-runtime.d.ts +5 -4
  89. package/dist/agent-runtime.d.ts.map +1 -1
  90. package/dist/agent-runtime.js +259 -65
  91. package/dist/application/watch-hub.d.ts +24 -2
  92. package/dist/application/watch-hub.d.ts.map +1 -1
  93. package/dist/application.js +127 -37
  94. package/dist/cli.js +8 -8
  95. package/dist/index-2na0qrfn.js +214 -0
  96. package/dist/{index-rcgsnrr6.js → index-31jw8fjq.js} +3 -3
  97. package/dist/{index-9hw9eq48.js → index-7601qfg1.js} +14 -14
  98. package/dist/{index-3xnq72rz.js → index-7rkhw9ec.js} +14 -1
  99. package/dist/{index-0vfdh685.js → index-8c3a7m4g.js} +1 -1
  100. package/dist/{index-t7gh5w3v.js → index-bn2cjajt.js} +27 -6
  101. package/dist/index-cp20z0n6.js +1351 -0
  102. package/dist/{index-qp3vshvc.js → index-fadnxwna.js} +87 -5
  103. package/dist/{index-v1qk37y9.js → index-hrbajay7.js} +106 -4
  104. package/dist/{index-p86mxmpp.js → index-hw2chdvy.js} +646 -43
  105. package/dist/{index-0ydchz76.js → index-mnm4qp0p.js} +5 -5
  106. package/dist/{index-1szetq6f.js → index-q3ve2d1k.js} +30 -8
  107. package/dist/{index-6krwcdcf.js → index-zwkgfq1s.js} +95 -85
  108. package/dist/{index-wn9cb82y.js → index-zyvby92n.js} +12 -9
  109. package/dist/index.js +13 -13
  110. package/dist/live/watch-client.d.ts +2 -1
  111. package/dist/live/watch-client.d.ts.map +1 -1
  112. package/dist/live/watch-contract.d.ts +70 -4
  113. package/dist/live/watch-contract.d.ts.map +1 -1
  114. package/dist/live/watch-delta.d.ts +110 -0
  115. package/dist/live/watch-delta.d.ts.map +1 -0
  116. package/dist/live.d.ts +2 -1
  117. package/dist/live.d.ts.map +1 -1
  118. package/dist/live.js +56 -4
  119. package/dist/observability/changes.d.ts +55 -0
  120. package/dist/observability/changes.d.ts.map +1 -0
  121. package/dist/observability/index.d.ts +2 -0
  122. package/dist/observability/index.d.ts.map +1 -1
  123. package/dist/observability/index.js +127 -0
  124. package/dist/observability/spool.d.ts +53 -0
  125. package/dist/observability/spool.d.ts.map +1 -0
  126. package/dist/server/index.js +9 -9
  127. package/dist/testing/agent-store-conformance.d.ts.map +1 -1
  128. package/dist/testing.js +57 -23
  129. package/dist/tool-invoker.js +6 -6
  130. package/dist/tools/agent.d.ts +6 -0
  131. package/dist/tools/agent.d.ts.map +1 -1
  132. package/dist/tools/connections/define.d.ts +6 -0
  133. package/dist/tools/connections/define.d.ts.map +1 -0
  134. package/dist/tools/connections/errors.d.ts +50 -0
  135. package/dist/tools/connections/errors.d.ts.map +1 -0
  136. package/dist/tools/connections/http.d.ts +3 -0
  137. package/dist/tools/connections/http.d.ts.map +1 -0
  138. package/dist/tools/connections/index.d.ts +19 -0
  139. package/dist/tools/connections/index.d.ts.map +1 -0
  140. package/dist/tools/connections/index.js +1047 -0
  141. package/dist/tools/connections/instance.d.ts +3 -0
  142. package/dist/tools/connections/instance.d.ts.map +1 -0
  143. package/dist/tools/connections/json-rpc.d.ts +8 -0
  144. package/dist/tools/connections/json-rpc.d.ts.map +1 -0
  145. package/dist/tools/connections/limits.d.ts +36 -0
  146. package/dist/tools/connections/limits.d.ts.map +1 -0
  147. package/dist/tools/connections/mcp-client.d.ts +44 -0
  148. package/dist/tools/connections/mcp-client.d.ts.map +1 -0
  149. package/dist/tools/connections/mcp.d.ts +5 -0
  150. package/dist/tools/connections/mcp.d.ts.map +1 -0
  151. package/dist/tools/connections/mount.d.ts +12 -0
  152. package/dist/tools/connections/mount.d.ts.map +1 -0
  153. package/dist/tools/connections/openapi-document.d.ts +4 -0
  154. package/dist/tools/connections/openapi-document.d.ts.map +1 -0
  155. package/dist/tools/connections/openapi.d.ts +5 -0
  156. package/dist/tools/connections/openapi.d.ts.map +1 -0
  157. package/dist/tools/connections/runtime.d.ts +29 -0
  158. package/dist/tools/connections/runtime.d.ts.map +1 -0
  159. package/dist/tools/connections/schema-budget.d.ts +8 -0
  160. package/dist/tools/connections/schema-budget.d.ts.map +1 -0
  161. package/dist/tools/connections/sse-frames.d.ts +7 -0
  162. package/dist/tools/connections/sse-frames.d.ts.map +1 -0
  163. package/dist/tools/connections/sse-session.d.ts +26 -0
  164. package/dist/tools/connections/sse-session.d.ts.map +1 -0
  165. package/dist/tools/connections/ssrf.d.ts +15 -0
  166. package/dist/tools/connections/ssrf.d.ts.map +1 -0
  167. package/dist/tools/connections/types.d.ts +60 -0
  168. package/dist/tools/connections/types.d.ts.map +1 -0
  169. package/dist/tools/durability-context.d.ts +7 -0
  170. package/dist/tools/durability-context.d.ts.map +1 -0
  171. package/dist/tools/execute.d.ts +2 -0
  172. package/dist/tools/execute.d.ts.map +1 -1
  173. package/dist/tools/registry.d.ts +38 -0
  174. package/dist/tools/registry.d.ts.map +1 -0
  175. package/dist/tools/runtime-tool.d.ts +4 -0
  176. package/dist/tools/runtime-tool.d.ts.map +1 -1
  177. package/dist/tools.d.ts +1 -0
  178. package/dist/tools.d.ts.map +1 -1
  179. package/dist/tools.js +83 -26
  180. package/llms-full.txt +386 -16
  181. package/llms.txt +1 -0
  182. package/package.json +9 -1
  183. package/dist/index-dre2ywck.js +0 -48
  184. package/dist/{index-evcnmsc3.js → index-t7fkyxcr.js} +3 -3
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  collectTools,
3
3
  createToolRunner
4
- } from "./index-0vfdh685.js";
4
+ } from "./index-8c3a7m4g.js";
5
5
  import {
6
6
  toolErrorFromResult
7
- } from "./index-wn9cb82y.js";
8
- import {
9
- assertUniqueToolName
10
- } from "./index-r159gjwy.js";
7
+ } from "./index-zyvby92n.js";
11
8
  import {
12
9
  AppError
13
10
  } from "./index-0w9abg87.js";
11
+ import {
12
+ assertUniqueToolName
13
+ } from "./index-r159gjwy.js";
14
14
 
15
15
  // src/tools/invoker.ts
16
16
  function createToolInvoker(services, config) {
@@ -1,17 +1,19 @@
1
1
  import {
2
- AgentToolError
3
- } from "./index-3xnq72rz.js";
2
+ AgentToolError,
3
+ resolveToolDurability
4
+ } from "./index-7rkhw9ec.js";
4
5
  import {
5
6
  collectToolSurface
6
- } from "./index-rcgsnrr6.js";
7
+ } from "./index-31jw8fjq.js";
7
8
  import {
8
9
  createToolRunner,
9
10
  formatToolError
10
- } from "./index-0vfdh685.js";
11
+ } from "./index-8c3a7m4g.js";
11
12
  import {
12
13
  isToolExecutionControlError,
14
+ toolCauseFromResult,
13
15
  toolResultFromError
14
- } from "./index-wn9cb82y.js";
16
+ } from "./index-zyvby92n.js";
15
17
  import {
16
18
  isRecord
17
19
  } from "./index-77fekveh.js";
@@ -20,6 +22,10 @@ import {
20
22
  import { jsonSchema, tool } from "ai";
21
23
  function mountAgent(services, config = {}) {
22
24
  const serviceList = Array.isArray(services) ? services : [services];
25
+ if (config.registry && config.runtimeTools) {
26
+ throw new Error("mountAgent accepts either runtimeTools or a registry, not both");
27
+ }
28
+ const runtimeTools = config.registry ? config.registry.tools : config.runtimeTools;
23
29
  const tools = {};
24
30
  const runTool = createToolRunner({
25
31
  source: "agent",
@@ -32,7 +38,7 @@ function mountAgent(services, config = {}) {
32
38
  onOutputStrip: config.onOutputStrip
33
39
  });
34
40
  for (const entry of collectToolSurface({
35
- surface: { services: serviceList, runtimeTools: config.runtimeTools },
41
+ surface: { services: serviceList, runtimeTools },
36
42
  transport: "AGENT",
37
43
  extend: config.extend,
38
44
  flattenUnionInput: config.flattenUnionInput
@@ -43,7 +49,23 @@ function mountAgent(services, config = {}) {
43
49
  });
44
50
  const execute = async (rawArgs, options) => {
45
51
  const args = isRecord(rawArgs) ? rawArgs : {};
46
- const result = await runTool(mountable, args, {
52
+ const durability = resolveToolDurability(options.context, options.toolCallId, options.abortSignal);
53
+ const executeTool = durability ? createToolRunner({
54
+ source: "agent",
55
+ extend: config.extend,
56
+ context: {
57
+ ...config.context,
58
+ step: durability.step,
59
+ sleep: durability.sleep,
60
+ waitFor: durability.waitFor
61
+ },
62
+ hooks: config.hooks,
63
+ lifecycle: config.lifecycle,
64
+ errorHint: config.errorHint,
65
+ coerceJsonArgs: config.coerceJsonArgs,
66
+ onOutputStrip: config.onOutputStrip
67
+ }) : runTool;
68
+ const result = await executeTool(mountable, args, {
47
69
  signal: options.abortSignal
48
70
  }).catch((err) => {
49
71
  if (isToolExecutionControlError(err))
@@ -52,7 +74,7 @@ function mountAgent(services, config = {}) {
52
74
  });
53
75
  if (result.ok)
54
76
  return result.data;
55
- throw new AgentToolError(formatToolError(result, mountable.name, config.errorHint));
77
+ throw new AgentToolError(formatToolError(result, mountable.name, config.errorHint), toolCauseFromResult(result));
56
78
  };
57
79
  const presenter = entry.kind === "runtime" ? entry.definition.present?.agent : undefined;
58
80
  if (entry.kind === "runtime" && presenter) {
@@ -9,88 +9,6 @@ import {
9
9
  AgentUsageSchema
10
10
  } from "./index-gtj3zc53.js";
11
11
 
12
- // src/agent-runtime/history-chronology.ts
13
- function createToolChronology() {
14
- return { calls: new Map, approvals: new Map, pending: 0, resultsStarted: false };
15
- }
16
- function advanceToolChronology(previous, parts) {
17
- const calls = new Map(previous.calls);
18
- const approvals = new Map(previous.approvals);
19
- let { pending, resultsStarted } = previous;
20
- for (const part of parts) {
21
- if (part.type === "tool-call") {
22
- if (calls.has(part.callId) || resultsStarted && pending > 0)
23
- return;
24
- if (pending === 0)
25
- resultsStarted = false;
26
- calls.set(part.callId, { toolName: part.toolName, phase: "called" });
27
- pending += 1;
28
- } else if (part.type === "tool-approval-request") {
29
- const call = calls.get(part.callId);
30
- if (call?.phase !== "called" || approvals.has(part.approvalId))
31
- return;
32
- approvals.set(part.approvalId, part.callId);
33
- calls.set(part.callId, { ...call, phase: "requested" });
34
- } else if (part.type === "tool-approval-response") {
35
- const callId = approvals.get(part.approvalId);
36
- const call = callId === undefined ? undefined : calls.get(callId);
37
- if (callId === undefined || !call || call.phase !== "requested")
38
- return;
39
- calls.set(callId, { ...call, phase: part.approved ? "approved" : "denied" });
40
- } else if (part.type === "tool-result") {
41
- const call = calls.get(part.callId);
42
- if (!call || call.toolName !== part.toolName || call.phase === "result" || call.phase === "requested" || call.phase === "denied" && part.outcome === "success")
43
- return;
44
- calls.set(part.callId, { ...call, phase: "result" });
45
- pending -= 1;
46
- resultsStarted = true;
47
- }
48
- }
49
- return { calls, approvals, pending, resultsStarted };
50
- }
51
- function canProjectToolChronology(state) {
52
- return [...state.calls.values()].every(({ phase }) => phase !== "called");
53
- }
54
-
55
- // src/agent-runtime/terminal-status.ts
56
- function isSpeakableAssistantStatus(status) {
57
- return status === "completed" || status === "interrupted" || status === "committed";
58
- }
59
- function isAssistantHistoryEvidence(status, policy) {
60
- return isSpeakableAssistantStatus(status) || status === "failed" && policy?.failedAssistant === "assistant-marked";
61
- }
62
- function isCompleteAgentHistoryTurn(messages, policy) {
63
- if (messages[0]?.role !== "user")
64
- return false;
65
- let chronology = createToolChronology();
66
- let assistantCount = 0;
67
- for (const message of messages) {
68
- if (message.role === "assistant") {
69
- if (!isAssistantHistoryEvidence(message.status, policy))
70
- return false;
71
- assistantCount += 1;
72
- }
73
- const next = advanceToolChronology(chronology, message.parts);
74
- if (!next)
75
- return false;
76
- chronology = next;
77
- }
78
- return assistantCount > 0 && chronology.pending === 0;
79
- }
80
- function assistantStatus(reason) {
81
- if (reason === "success" || reason === "policy_stop" || reason === "provider_stop") {
82
- return "completed";
83
- }
84
- if (reason === "superseded")
85
- return "superseded";
86
- if (reason === "absorbed")
87
- return "superseded";
88
- if (reason === "interrupted" || reason === "cancelled" || reason === "shutdown") {
89
- return "interrupted";
90
- }
91
- return "failed";
92
- }
93
-
94
12
  // src/agent-runtime/store.ts
95
13
  import { z } from "zod";
96
14
  var AgentStoreConflictSchema = z.object({
@@ -186,6 +104,11 @@ var ReplaceCompactedRangeSchema = z.object({
186
104
  replacedMessageIds: z.array(AgentRecordIdSchema).min(1),
187
105
  summary: AgentMessageSchema
188
106
  });
107
+ var SeedConversationInputSchema = z.object({
108
+ conversationId: AgentRecordIdSchema,
109
+ seedKey: z.string().min(1),
110
+ inputs: z.array(AgentMessageSchema).min(1)
111
+ });
189
112
  var AgentRecoverableDescriptorSchema = z.object({
190
113
  conversationId: AgentRecordIdSchema,
191
114
  run: AgentRunSchema
@@ -216,7 +139,11 @@ var AgentStoreEventKindSchema = z2.enum([
216
139
  "child/state",
217
140
  "retry/scheduled",
218
141
  "retry/started",
219
- "sandbox/probed"
142
+ "sandbox/probed",
143
+ "approval/response-rejected",
144
+ "durability/step",
145
+ "durability/park",
146
+ "durability/event"
220
147
  ]);
221
148
  var AgentStoreTransitionSchema = z2.discriminatedUnion("type", [
222
149
  z2.object({ type: z2.literal("accept"), input: AcceptInputAndAssignRunSchema }).strict(),
@@ -226,7 +153,8 @@ var AgentStoreTransitionSchema = z2.discriminatedUnion("type", [
226
153
  z2.object({ type: z2.literal("interrupt"), input: RequestRunInterruptSchema }).strict(),
227
154
  z2.object({ type: z2.literal("recover"), input: RecoverAgentRunSchema }).strict(),
228
155
  z2.object({ type: z2.literal("terminal"), input: CommitRunTerminalSchema }).strict(),
229
- z2.object({ type: z2.literal("compact"), input: ReplaceCompactedRangeSchema }).strict()
156
+ z2.object({ type: z2.literal("compact"), input: ReplaceCompactedRangeSchema }).strict(),
157
+ z2.object({ type: z2.literal("seed"), input: SeedConversationInputSchema }).strict()
230
158
  ]);
231
159
  var AgentStoreEventEnvelopeSchema = z2.object({
232
160
  schemaVersion: z2.int().positive(),
@@ -332,4 +260,86 @@ function decodeAgentConversationArchive(bytes) {
332
260
  return archive;
333
261
  }
334
262
 
335
- export { createToolChronology, advanceToolChronology, canProjectToolChronology, isAssistantHistoryEvidence, isCompleteAgentHistoryTurn, assistantStatus, AgentStoreConflictSchema, AgentStoreNotFoundSchema, AgentStoreAppliedSchema, AgentStoreDuplicateSchema, AgentStoreMutationResultSchema, AgentRunViewSchema, AcceptInputAndAssignRunSchema, AcquireAgentRunSchema, CheckpointRunAssistantSchema, RecordRunOperationSchema, CommitRunTerminalSchema, RequestRunInterruptSchema, RecoverAgentRunSchema, ReplaceCompactedRangeSchema, AgentRecoverableDescriptorSchema, AgentRecoverablePageSchema, AgentStoreEventKindSchema, AgentStoreTransitionSchema, AgentStoreEventEnvelopeSchema, AppendAgentStoreEventSchema, ReadAgentStoreEventsSchema, AgentStoreEventPageSchema, decodeAgentStoreEvent, agentStoreEventDraft, canonicalAgentJson, AgentConversationArchiveSchema, encodeAgentConversationArchive, decodeAgentConversationArchive };
263
+ // src/agent-runtime/history-chronology.ts
264
+ function createToolChronology() {
265
+ return { calls: new Map, approvals: new Map, pending: 0, resultsStarted: false };
266
+ }
267
+ function advanceToolChronology(previous, parts) {
268
+ const calls = new Map(previous.calls);
269
+ const approvals = new Map(previous.approvals);
270
+ let { pending, resultsStarted } = previous;
271
+ for (const part of parts) {
272
+ if (part.type === "tool-call") {
273
+ if (calls.has(part.callId) || resultsStarted && pending > 0)
274
+ return;
275
+ if (pending === 0)
276
+ resultsStarted = false;
277
+ calls.set(part.callId, { toolName: part.toolName, phase: "called" });
278
+ pending += 1;
279
+ } else if (part.type === "tool-approval-request") {
280
+ const call = calls.get(part.callId);
281
+ if (call?.phase !== "called" || approvals.has(part.approvalId))
282
+ return;
283
+ approvals.set(part.approvalId, part.callId);
284
+ calls.set(part.callId, { ...call, phase: "requested" });
285
+ } else if (part.type === "tool-approval-response") {
286
+ const callId = approvals.get(part.approvalId);
287
+ const call = callId === undefined ? undefined : calls.get(callId);
288
+ if (callId === undefined || !call || call.phase !== "requested")
289
+ return;
290
+ calls.set(callId, { ...call, phase: part.approved ? "approved" : "denied" });
291
+ } else if (part.type === "tool-result") {
292
+ const call = calls.get(part.callId);
293
+ if (!call || call.toolName !== part.toolName || call.phase === "result" || call.phase === "requested" || call.phase === "denied" && part.outcome === "success")
294
+ return;
295
+ calls.set(part.callId, { ...call, phase: "result" });
296
+ pending -= 1;
297
+ resultsStarted = true;
298
+ }
299
+ }
300
+ return { calls, approvals, pending, resultsStarted };
301
+ }
302
+ function canProjectToolChronology(state) {
303
+ return [...state.calls.values()].every(({ phase }) => phase !== "called");
304
+ }
305
+
306
+ // src/agent-runtime/terminal-status.ts
307
+ function isSpeakableAssistantStatus(status) {
308
+ return status === "completed" || status === "interrupted" || status === "committed";
309
+ }
310
+ function isAssistantHistoryEvidence(status, policy) {
311
+ return isSpeakableAssistantStatus(status) || status === "failed" && policy?.failedAssistant === "assistant-marked";
312
+ }
313
+ function isCompleteAgentHistoryTurn(messages, policy) {
314
+ if (messages[0]?.role !== "user")
315
+ return false;
316
+ let chronology = createToolChronology();
317
+ let assistantCount = 0;
318
+ for (const message of messages) {
319
+ if (message.role === "assistant") {
320
+ if (!isAssistantHistoryEvidence(message.status, policy))
321
+ return false;
322
+ assistantCount += 1;
323
+ }
324
+ const next = advanceToolChronology(chronology, message.parts);
325
+ if (!next)
326
+ return false;
327
+ chronology = next;
328
+ }
329
+ return assistantCount > 0 && chronology.pending === 0;
330
+ }
331
+ function assistantStatus(reason) {
332
+ if (reason === "success" || reason === "policy_stop" || reason === "provider_stop") {
333
+ return "completed";
334
+ }
335
+ if (reason === "superseded")
336
+ return "superseded";
337
+ if (reason === "absorbed")
338
+ return "superseded";
339
+ if (reason === "interrupted" || reason === "cancelled" || reason === "shutdown") {
340
+ return "interrupted";
341
+ }
342
+ return "failed";
343
+ }
344
+
345
+ export { AgentStoreConflictSchema, AgentStoreNotFoundSchema, AgentStoreAppliedSchema, AgentStoreDuplicateSchema, AgentStoreMutationResultSchema, AgentRunViewSchema, AcceptInputAndAssignRunSchema, AcquireAgentRunSchema, CheckpointRunAssistantSchema, RecordRunOperationSchema, CommitRunTerminalSchema, RequestRunInterruptSchema, RecoverAgentRunSchema, ReplaceCompactedRangeSchema, SeedConversationInputSchema, AgentRecoverableDescriptorSchema, AgentRecoverablePageSchema, AgentStoreEventKindSchema, AgentStoreTransitionSchema, AgentStoreEventEnvelopeSchema, AppendAgentStoreEventSchema, ReadAgentStoreEventsSchema, AgentStoreEventPageSchema, decodeAgentStoreEvent, agentStoreEventDraft, canonicalAgentJson, AgentConversationArchiveSchema, encodeAgentConversationArchive, decodeAgentConversationArchive, createToolChronology, advanceToolChronology, canProjectToolChronology, isAssistantHistoryEvidence, isCompleteAgentHistoryTurn, assistantStatus };
@@ -2,12 +2,6 @@ import {
2
2
  getRequestContext,
3
3
  runWithRequestContext
4
4
  } from "./index-vsbzgd7b.js";
5
- import {
6
- objectShapeKeys
7
- } from "./index-r159gjwy.js";
8
- import {
9
- coerceJsonArgs
10
- } from "./index-7zbps32p.js";
11
5
  import {
12
6
  formatZodError,
13
7
  normalizeError,
@@ -18,9 +12,15 @@ import {
18
12
  STITCH_ERROR_STATUS,
19
13
  isStitchErrorCode
20
14
  } from "./index-0w9abg87.js";
15
+ import {
16
+ coerceJsonArgs
17
+ } from "./index-7zbps32p.js";
21
18
  import {
22
19
  isUnsafeKey
23
20
  } from "./index-kzfs85xp.js";
21
+ import {
22
+ objectShapeKeys
23
+ } from "./index-r159gjwy.js";
24
24
  import {
25
25
  isRecord
26
26
  } from "./index-77fekveh.js";
@@ -46,18 +46,21 @@ function toolResultFromError(err) {
46
46
  details: appErr.details ?? { message: appErr.message },
47
47
  ...appErr.hint && { hint: appErr.hint }
48
48
  };
49
- normalizedToolErrors.set(result, appErr);
49
+ normalizedToolErrors.set(result, { normalized: appErr, cause: err });
50
50
  return result;
51
51
  }
52
52
  function toolErrorFromResult(result) {
53
53
  const retained = normalizedToolErrors.get(result);
54
54
  if (retained)
55
- return retained;
55
+ return retained.normalized;
56
56
  const details = isRecord(result.details) ? result.details : undefined;
57
57
  const message = typeof details?.message === "string" ? details.message : result.code;
58
58
  const status = isStitchErrorCode(result.code) ? STITCH_ERROR_STATUS[result.code] : 500;
59
59
  return new AppError(result.code, message, status, details, result.hint);
60
60
  }
61
+ function toolCauseFromResult(result) {
62
+ return normalizedToolErrors.get(result)?.cause;
63
+ }
61
64
  async function executeToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson = false, onOutputStrip, extension, finalizeOutput) {
62
65
  return inToolCallContext({ source: context.source, toolName, method }, () => runToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson, onOutputStrip, extension, finalizeOutput));
63
66
  }
@@ -258,4 +261,4 @@ async function runToolMethod(method, toolName, rawArgs, context, hooks, lifecycl
258
261
  }
259
262
  }
260
263
 
261
- export { ToolExecutionControlError, isToolExecutionControlError, toolResultFromError, toolErrorFromResult, executeToolMethod };
264
+ export { ToolExecutionControlError, isToolExecutionControlError, toolResultFromError, toolErrorFromResult, toolCauseFromResult, executeToolMethod };
package/dist/index.js CHANGED
@@ -6,6 +6,16 @@ import {
6
6
  createBackoff,
7
7
  resumableIterator
8
8
  } from "./index-s8cnx02s.js";
9
+ import {
10
+ contractEndpointMatchers,
11
+ createClient,
12
+ createClients,
13
+ createScopedClients,
14
+ createScopedUrlBuilders,
15
+ createUrlBuilder,
16
+ createUrlBuilders,
17
+ parseNDJSON
18
+ } from "./index-27gm3d6g.js";
9
19
  import {
10
20
  REALTIME_REJECTION_KEY,
11
21
  asRealtimeRejection,
@@ -22,6 +32,9 @@ import {
22
32
  RealtimeRequestRejectedError,
23
33
  RealtimeRequestTimeoutError
24
34
  } from "./index-2qzskm8h.js";
35
+ import {
36
+ parseSSE
37
+ } from "./index-qmgs7y68.js";
25
38
  import {
26
39
  LiveStateControllerStatusSchema,
27
40
  LiveStatePhaseSchema,
@@ -29,19 +42,6 @@ import {
29
42
  createLiveStateController
30
43
  } from "./index-ywd0y6m1.js";
31
44
  import"./index-7gnkny4z.js";
32
- import {
33
- contractEndpointMatchers,
34
- createClient,
35
- createClients,
36
- createScopedClients,
37
- createScopedUrlBuilders,
38
- createUrlBuilder,
39
- createUrlBuilders,
40
- parseNDJSON
41
- } from "./index-27gm3d6g.js";
42
- import {
43
- parseSSE
44
- } from "./index-qmgs7y68.js";
45
45
  import {
46
46
  ApiError,
47
47
  createHttpClient
@@ -44,7 +44,7 @@
44
44
  * sense a rendering component can use.
45
45
  */
46
46
  import type { ContractDef, EndpointDef } from '../contract/define.js';
47
- import { WATCH_CLOSE, WATCH_OPEN, WATCH_STATE, WATCH_VALUE, type WatchKey, type WatchStateFrame, type WatchValueFrame } from './watch-contract.js';
47
+ import { WATCH_CLOSE, WATCH_OPEN, WATCH_STATE, WATCH_VALUE, type WatchHave, type WatchKey, type WatchStateFrame, type WatchValueFrame } from './watch-contract.js';
48
48
  export interface WatchListeners<TValue> {
49
49
  value(value: TValue): void;
50
50
  /** Phase and, when unhealthy, the read's own code and message. */
@@ -107,6 +107,7 @@ export interface WatchTransport {
107
107
  request(event: typeof WATCH_OPEN, payload: {
108
108
  key: WatchKey;
109
109
  args: unknown;
110
+ have?: WatchHave;
110
111
  }, options: {
111
112
  timeoutMs: number;
112
113
  }): Promise<{
@@ -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,CAAC;IACzD,wEAAwE;IACxE,KAAK,IAAI,IAAI,CAAC;CACf;AAED,sDAAsD;AACtD,MAAM,WAAW,kBAAkB;IACjC,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC/B,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;IAClC,IAAI,EAAE,C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AM,CAAA;KAAE,CAAC,CAAC;IACnD;;;;;;;OAOG;IACH,kBAAkB,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACzF;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,wEAAwE;IACxE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D;AAiCD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI;KACnE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC;CACzE,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrE,QAAQ,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,EAChC,MAAM,EAAE,iBAAiB,GACxB,gBAAgB,CAAC,CAAC,CAAC,CAyPrB"}
@@ -26,6 +26,20 @@ export declare const WatchKeySchema: z.ZodReadonly<z.ZodObject<{
26
26
  digest: z.ZodString;
27
27
  }, z.core.$strict>>;
28
28
  export type WatchKey = z.infer<typeof WatchKeySchema>;
29
+ /**
30
+ * What a subscriber already holds, offered when it opens a key.
31
+ *
32
+ * Both halves are needed and neither is redundant. The revision says *which*
33
+ * answer it has; the fingerprint proves it is that answer and not a different
34
+ * one wearing the same number — revisions restart at zero when a hub restarts or
35
+ * a key is released and re-acquired, so a bare revision would let a client keep
36
+ * a value from a previous life of the source and be told it was current.
37
+ */
38
+ export declare const WatchHaveSchema: z.ZodReadonly<z.ZodObject<{
39
+ revision: z.ZodNumber;
40
+ fingerprint: z.ZodString;
41
+ }, z.core.$strict>>;
42
+ export type WatchHave = z.infer<typeof WatchHaveSchema>;
29
43
  export declare const WatchOpenSchema: z.ZodReadonly<z.ZodObject<{
30
44
  key: z.ZodReadonly<z.ZodObject<{
31
45
  service: z.ZodString;
@@ -33,20 +47,46 @@ export declare const WatchOpenSchema: z.ZodReadonly<z.ZodObject<{
33
47
  digest: z.ZodString;
34
48
  }, z.core.$strict>>;
35
49
  args: z.ZodUnknown;
50
+ have: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
51
+ revision: z.ZodNumber;
52
+ fingerprint: z.ZodString;
53
+ }, z.core.$strict>>>;
36
54
  }, z.core.$strip>>;
37
55
  export declare const WatchAcceptedSchema: z.ZodReadonly<z.ZodObject<{
38
56
  accepted: z.ZodBoolean;
39
57
  reason: z.ZodOptional<z.ZodString>;
40
58
  }, z.core.$strict>>;
41
- export declare const WatchValueSchema: z.ZodReadonly<z.ZodObject<{
59
+ export declare const WatchValueSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
42
60
  key: z.ZodReadonly<z.ZodObject<{
43
61
  service: z.ZodString;
44
62
  action: z.ZodString;
45
63
  digest: z.ZodString;
46
64
  }, z.core.$strict>>;
47
65
  revision: z.ZodNumber;
66
+ fingerprint: z.ZodString;
67
+ kind: z.ZodLiteral<"full">;
48
68
  value: z.ZodUnknown;
49
- }, z.core.$strip>>;
69
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
70
+ key: z.ZodReadonly<z.ZodObject<{
71
+ service: z.ZodString;
72
+ action: z.ZodString;
73
+ digest: z.ZodString;
74
+ }, z.core.$strict>>;
75
+ revision: z.ZodNumber;
76
+ fingerprint: z.ZodString;
77
+ kind: z.ZodLiteral<"delta">;
78
+ base: z.ZodNumber;
79
+ delta: z.ZodType<import("./watch-delta.js").WatchDelta, unknown, z.core.$ZodTypeInternals<import("./watch-delta.js").WatchDelta, unknown>>;
80
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
81
+ key: z.ZodReadonly<z.ZodObject<{
82
+ service: z.ZodString;
83
+ action: z.ZodString;
84
+ digest: z.ZodString;
85
+ }, z.core.$strict>>;
86
+ revision: z.ZodNumber;
87
+ fingerprint: z.ZodString;
88
+ kind: z.ZodLiteral<"unchanged">;
89
+ }, z.core.$strip>>], "kind">;
50
90
  export declare const WatchStateSchema: z.ZodReadonly<z.ZodObject<{
51
91
  key: z.ZodReadonly<z.ZodObject<{
52
92
  service: z.ZodString;
@@ -88,15 +128,37 @@ export declare const WATCH_STATE = "stitchkit.watch.state";
88
128
  export declare const watchContract: {
89
129
  readonly serverToClient: {
90
130
  readonly "stitchkit.watch.value": {
91
- readonly args: z.ZodTuple<[z.ZodReadonly<z.ZodObject<{
131
+ readonly args: z.ZodTuple<[z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
92
132
  key: z.ZodReadonly<z.ZodObject<{
93
133
  service: z.ZodString;
94
134
  action: z.ZodString;
95
135
  digest: z.ZodString;
96
136
  }, z.core.$strict>>;
97
137
  revision: z.ZodNumber;
138
+ fingerprint: z.ZodString;
139
+ kind: z.ZodLiteral<"full">;
98
140
  value: z.ZodUnknown;
99
- }, z.core.$strip>>], null>;
141
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
142
+ key: z.ZodReadonly<z.ZodObject<{
143
+ service: z.ZodString;
144
+ action: z.ZodString;
145
+ digest: z.ZodString;
146
+ }, z.core.$strict>>;
147
+ revision: z.ZodNumber;
148
+ fingerprint: z.ZodString;
149
+ kind: z.ZodLiteral<"delta">;
150
+ base: z.ZodNumber;
151
+ delta: z.ZodType<import("./watch-delta.js").WatchDelta, unknown, z.core.$ZodTypeInternals<import("./watch-delta.js").WatchDelta, unknown>>;
152
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
153
+ key: z.ZodReadonly<z.ZodObject<{
154
+ service: z.ZodString;
155
+ action: z.ZodString;
156
+ digest: z.ZodString;
157
+ }, z.core.$strict>>;
158
+ revision: z.ZodNumber;
159
+ fingerprint: z.ZodString;
160
+ kind: z.ZodLiteral<"unchanged">;
161
+ }, z.core.$strip>>], "kind">], null>;
100
162
  };
101
163
  readonly "stitchkit.watch.state": {
102
164
  readonly args: z.ZodTuple<[z.ZodReadonly<z.ZodObject<{
@@ -135,6 +197,10 @@ export declare const watchContract: {
135
197
  digest: z.ZodString;
136
198
  }, z.core.$strict>>;
137
199
  args: z.ZodUnknown;
200
+ have: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
201
+ revision: z.ZodNumber;
202
+ fingerprint: z.ZodString;
203
+ }, z.core.$strict>>>;
138
204
  }, z.core.$strip>>], null>;
139
205
  readonly ack: z.ZodReadonly<z.ZodObject<{
140
206
  accepted: z.ZodBoolean;
@@ -1 +1 @@
1
- {"version":3,"file":"watch-contract.d.ts","sourceRoot":"","sources":["../../src/live/watch-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,2FAA2F;AAC3F,eAAO,MAAM,cAAc;;;;mBAkBd,CAAC;AACd,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,eAAe;;;;;;;kBAAkE,CAAC;AAE/F,eAAO,MAAM,mBAAmB;;;mBAOnB,CAAC;AAEd,eAAO,MAAM,gBAAgB;;;;;;;;kBAUhB,CAAC;AAEd,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;kBAShB,CAAC;AAEd,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC/D,MAAM,MAAM,eAAe,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