stitchkit 0.130.1 → 0.131.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 (152) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/agent-executor/acp/v1-connect.d.ts +40 -26
  3. package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
  4. package/dist/agent-executor/acp/v1-driver.d.ts +10 -4
  5. package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
  6. package/dist/agent-executor/acp/v1-handlers.d.ts +6 -2
  7. package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -1
  8. package/dist/agent-executor/acp/v1-probe.d.ts +38 -0
  9. package/dist/agent-executor/acp/v1-probe.d.ts.map +1 -0
  10. package/dist/agent-executor/acp/v1-protocol.d.ts +15 -0
  11. package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
  12. package/dist/agent-executor/acp/v1-session.d.ts +9 -7
  13. package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
  14. package/dist/agent-executor/claude/cli-driver.d.ts +7 -7
  15. package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
  16. package/dist/agent-executor/claude/limits.d.ts +6 -4
  17. package/dist/agent-executor/claude/limits.d.ts.map +1 -1
  18. package/dist/agent-executor/claude/session.d.ts +3 -3
  19. package/dist/agent-executor/claude/session.d.ts.map +1 -1
  20. package/dist/agent-executor/claude-sdk/controls.d.ts +1 -0
  21. package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -1
  22. package/dist/agent-executor/claude-sdk/driver.d.ts +51 -50
  23. package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
  24. package/dist/agent-executor/claude-sdk/probe.d.ts +3 -3
  25. package/dist/agent-executor/claude-sdk/probe.d.ts.map +1 -1
  26. package/dist/agent-executor/claude-sdk/query-loop.d.ts +2 -1
  27. package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -1
  28. package/dist/agent-executor/codex/classify.d.ts.map +1 -1
  29. package/dist/agent-executor/codex/connect.d.ts +7 -7
  30. package/dist/agent-executor/codex/connect.d.ts.map +1 -1
  31. package/dist/agent-executor/codex/control-client.d.ts +86 -99
  32. package/dist/agent-executor/codex/control-client.d.ts.map +1 -1
  33. package/dist/agent-executor/codex/control-read-methods.d.ts +7 -0
  34. package/dist/agent-executor/codex/control-read-methods.d.ts.map +1 -0
  35. package/dist/agent-executor/codex/driver.d.ts +29 -28
  36. package/dist/agent-executor/codex/driver.d.ts.map +1 -1
  37. package/dist/agent-executor/codex/event-routing.d.ts +14 -0
  38. package/dist/agent-executor/codex/event-routing.d.ts.map +1 -0
  39. package/dist/agent-executor/codex/handlers.d.ts +2 -2
  40. package/dist/agent-executor/codex/handlers.d.ts.map +1 -1
  41. package/dist/agent-executor/codex/limits.d.ts +9 -3
  42. package/dist/agent-executor/codex/limits.d.ts.map +1 -1
  43. package/dist/agent-executor/codex/notifications.d.ts +183 -0
  44. package/dist/agent-executor/codex/notifications.d.ts.map +1 -0
  45. package/dist/agent-executor/codex/pagination.d.ts +54 -0
  46. package/dist/agent-executor/codex/pagination.d.ts.map +1 -0
  47. package/dist/agent-executor/codex/protocol.d.ts +586 -148
  48. package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
  49. package/dist/agent-executor/codex/request-answers.d.ts +4 -2
  50. package/dist/agent-executor/codex/request-answers.d.ts.map +1 -1
  51. package/dist/agent-executor/codex/responses.d.ts +855 -0
  52. package/dist/agent-executor/codex/responses.d.ts.map +1 -0
  53. package/dist/agent-executor/codex/session-bind.d.ts +410 -0
  54. package/dist/agent-executor/codex/session-bind.d.ts.map +1 -0
  55. package/dist/agent-executor/codex/session-controls.d.ts +19 -190
  56. package/dist/agent-executor/codex/session-controls.d.ts.map +1 -1
  57. package/dist/agent-executor/codex/session-types.d.ts +190 -0
  58. package/dist/agent-executor/codex/session-types.d.ts.map +1 -0
  59. package/dist/agent-executor/codex/session.d.ts +1 -1
  60. package/dist/agent-executor/codex/session.d.ts.map +1 -1
  61. package/dist/agent-executor/codex/shared-server.d.ts +4 -4
  62. package/dist/agent-executor/codex/shared-server.d.ts.map +1 -1
  63. package/dist/agent-executor/codex/shared-thread.d.ts +5 -5
  64. package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -1
  65. package/dist/agent-executor/codex/thread-controls.d.ts +45 -36
  66. package/dist/agent-executor/codex/thread-controls.d.ts.map +1 -1
  67. package/dist/agent-executor/codex/thread-list-query.d.ts +5 -0
  68. package/dist/agent-executor/codex/thread-list-query.d.ts.map +1 -0
  69. package/dist/agent-executor/codex/thread-open.d.ts +20 -20
  70. package/dist/agent-executor/codex/thread-open.d.ts.map +1 -1
  71. package/dist/agent-executor/codex/turn-input.d.ts +4 -3
  72. package/dist/agent-executor/codex/turn-input.d.ts.map +1 -1
  73. package/dist/agent-executor/codex/unix-socket-target.d.ts +12 -3
  74. package/dist/agent-executor/codex/unix-socket-target.d.ts.map +1 -1
  75. package/dist/agent-executor/codex/ws-frame.d.ts +4 -1
  76. package/dist/agent-executor/codex/ws-frame.d.ts.map +1 -1
  77. package/dist/agent-executor/contract.d.ts +3 -1
  78. package/dist/agent-executor/contract.d.ts.map +1 -1
  79. package/dist/agent-executor/engine-process.d.ts +4 -4
  80. package/dist/agent-executor/engine-process.d.ts.map +1 -1
  81. package/dist/agent-executor/engine.d.ts +3 -3
  82. package/dist/agent-executor/engine.d.ts.map +1 -1
  83. package/dist/agent-executor/handoff.d.ts.map +1 -1
  84. package/dist/agent-executor/hello.d.ts +7 -0
  85. package/dist/agent-executor/hello.d.ts.map +1 -1
  86. package/dist/agent-executor/json-rpc-peer.d.ts +9 -4
  87. package/dist/agent-executor/json-rpc-peer.d.ts.map +1 -1
  88. package/dist/agent-executor/leases.d.ts +1 -1
  89. package/dist/agent-executor/leases.d.ts.map +1 -1
  90. package/dist/agent-executor/plan-limits.d.ts +12 -1
  91. package/dist/agent-executor/plan-limits.d.ts.map +1 -1
  92. package/dist/agent-executor/profile.d.ts +7 -0
  93. package/dist/agent-executor/profile.d.ts.map +1 -1
  94. package/dist/agent-executor/session-primitives.d.ts +8 -0
  95. package/dist/agent-executor/session-primitives.d.ts.map +1 -1
  96. package/dist/agent-executor/testing/consumer-stubs.d.ts +45 -0
  97. package/dist/agent-executor/testing/consumer-stubs.d.ts.map +1 -0
  98. package/dist/agent-executor/testing/fake-claude-sdk-query.d.ts +88 -0
  99. package/dist/agent-executor/testing/fake-claude-sdk-query.d.ts.map +1 -0
  100. package/dist/agent-executor/testing/fake-codex-app-server.d.ts +56 -0
  101. package/dist/agent-executor/testing/fake-codex-app-server.d.ts.map +1 -0
  102. package/dist/agent-executor/testing/fixtures.d.ts +26 -0
  103. package/dist/agent-executor/testing/fixtures.d.ts.map +1 -0
  104. package/dist/agent-executor/testing/replay-driver.d.ts +8 -8
  105. package/dist/agent-executor/testing/replay-driver.d.ts.map +1 -1
  106. package/dist/agent-executor/testing/replay-runner.d.ts +3 -2
  107. package/dist/agent-executor/testing/replay-runner.d.ts.map +1 -1
  108. package/dist/agent-executor/testing/replay-transcript.d.ts +5 -3
  109. package/dist/agent-executor/testing/replay-transcript.d.ts.map +1 -1
  110. package/dist/agent-runtime/branch-observations.d.ts +19 -19
  111. package/dist/agent-runtime/sql-rows.d.ts +10 -10
  112. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
  113. package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
  114. package/dist/agent-runtime/terminal-commit.d.ts +10 -10
  115. package/dist/entrypoints/agent-executor/acp.d.ts +2 -1
  116. package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
  117. package/dist/entrypoints/agent-executor/acp.js +284 -82
  118. package/dist/entrypoints/agent-executor/claude-sdk.d.ts +4 -0
  119. package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -1
  120. package/dist/entrypoints/agent-executor/claude-sdk.js +58 -32
  121. package/dist/entrypoints/agent-executor/claude.d.ts +2 -2
  122. package/dist/entrypoints/agent-executor/claude.d.ts.map +1 -1
  123. package/dist/entrypoints/agent-executor/claude.js +25 -20
  124. package/dist/entrypoints/agent-executor/codex.d.ts +9 -5
  125. package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
  126. package/dist/entrypoints/agent-executor/codex.js +1724 -1557
  127. package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
  128. package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -1
  129. package/dist/entrypoints/agent-executor/testing.js +880 -18
  130. package/dist/entrypoints/agent-executor.d.ts +3 -3
  131. package/dist/entrypoints/agent-executor.d.ts.map +1 -1
  132. package/dist/entrypoints/agent-executor.js +42 -8
  133. package/dist/entrypoints/process.js +3 -3
  134. package/dist/{index-jrn3prgm.js → index-32vaajec.js} +29 -4
  135. package/dist/{index-p1qmpq0p.js → index-64e9p079.js} +92 -56
  136. package/dist/{index-dbp6xemn.js → index-g2d9kws8.js} +199 -3
  137. package/dist/index-gm9yz82v.js +56 -0
  138. package/dist/index-j15dhkda.js +749 -0
  139. package/dist/{index-1q0n6zek.js → index-kwsr7j5k.js} +84 -44
  140. package/llms/agent-executor-acp.txt +5 -5
  141. package/llms/agent-executor-claude-sdk.txt +3 -1
  142. package/llms/agent-executor-claude.txt +2 -2
  143. package/llms/agent-executor-codex.txt +11 -8
  144. package/llms/agent-executor-testing.txt +5 -1
  145. package/llms/agent-executor.txt +4 -4
  146. package/llms/stitchkit.txt +75 -74
  147. package/llms/{upgrading-0.128.0-0.130.0.txt → upgrading-0.128.0-0.131.0.txt} +56 -3
  148. package/llms/upgrading.txt +1 -1
  149. package/llms-full.txt +158 -95
  150. package/llms.txt +8 -8
  151. package/package.json +3 -3
  152. package/dist/index-2s8sy57y.js +0 -229
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.130.1",
3
+ "version": "0.131.0",
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",
@@ -375,7 +375,7 @@
375
375
  "build:entrypoints": "bun scripts/generate-native-assets.ts && bun scripts/build-entrypoints.mjs"
376
376
  },
377
377
  "peerDependencies": {
378
- "@anthropic-ai/claude-agent-sdk": "^0.3.330",
378
+ "@anthropic-ai/claude-agent-sdk": "^0.3.332",
379
379
  "@modelcontextprotocol/ext-apps": "^1.7.2 || ^2.0.0",
380
380
  "@modelcontextprotocol/server": "^2.0.0",
381
381
  "@openrouter/ai-sdk-provider": "^3.1.0",
@@ -459,7 +459,7 @@
459
459
  "ky": "^2.2.0"
460
460
  },
461
461
  "devDependencies": {
462
- "@anthropic-ai/claude-agent-sdk": "0.3.330",
462
+ "@anthropic-ai/claude-agent-sdk": "0.3.332",
463
463
  "@happy-dom/global-registrator": "^21.0.4",
464
464
  "@modelcontextprotocol/client": "^2.4.0",
465
465
  "@modelcontextprotocol/ext-apps": "^2.0.4",
@@ -1,229 +0,0 @@
1
- import {
2
- createBoundedChannel2
3
- } from "./index-09f7w2qq.js";
4
- import {
5
- ExecutorStartupPhaseSchema2,
6
- engineEnvironment2
7
- } from "./index-dbp6xemn.js";
8
- import {
9
- runNativeCommand2
10
- } from "./index-pzhqydxb.js";
11
- import {
12
- jsonDataRefusal
13
- } from "./index-m6w6jtda.js";
14
- import {
15
- abortReason,
16
- linkAbortSignals
17
- } from "./index-rptj3qnc.js";
18
-
19
- // src/agent-executor/session-primitives.ts
20
- import { createHash } from "node:crypto";
21
- import { z } from "zod";
22
- var TURN_QUEUE = { maxItems: 65536, maxBytes: 64 * 1024 * 1024 };
23
- var MAX_DATE_MS = 8640000000000000;
24
- var SAFE_JSON_LIMITS = {
25
- maxDepth: 100,
26
- maxNodes: 1e5,
27
- omitObjectUndefined: true,
28
- zodJson: true
29
- };
30
- function nonEmptyString(value) {
31
- return typeof value === "string" && value.trim().length > 0 ? value : undefined;
32
- }
33
- function epochSecondsToIso(seconds) {
34
- if (seconds === null || seconds === undefined)
35
- return;
36
- const ms = seconds * 1000;
37
- if (!Number.isFinite(ms) || Math.abs(ms) > MAX_DATE_MS)
38
- return;
39
- return new Date(ms).toISOString();
40
- }
41
- function createTurnDeltaChannel() {
42
- return createBoundedChannel2({
43
- policy: "ordered",
44
- ...TURN_QUEUE,
45
- sizeOf: (delta) => JSON.stringify(delta).length
46
- });
47
- }
48
- function normalizeDeltaIdentifiers(delta) {
49
- if (delta.type === "tool-call" || delta.type === "tool-result") {
50
- const callId = nonEmptyString(delta.callId) ?? delta.itemId;
51
- const toolName = nonEmptyString(delta.toolName) ?? "unknown";
52
- if (callId === delta.callId && toolName === delta.toolName)
53
- return delta;
54
- return { ...delta, callId, toolName };
55
- }
56
- if (delta.type === "request") {
57
- const callId = nonEmptyString(delta.callId);
58
- const toolName = delta.toolName === undefined ? undefined : nonEmptyString(delta.toolName) ?? "tool";
59
- if (callId === delta.callId && toolName === delta.toolName)
60
- return delta;
61
- const { callId: _callId, toolName: _toolName, ...rest } = delta;
62
- return {
63
- ...rest,
64
- ...callId !== undefined && { callId },
65
- ...toolName !== undefined && { toolName }
66
- };
67
- }
68
- return delta;
69
- }
70
- function offerTurnDelta(channel, delta) {
71
- if (channel === undefined)
72
- return;
73
- const result = channel.offer(normalizeDeltaIdentifiers(delta));
74
- if (result.outcome === "refused" && result.reason !== "not-open") {
75
- channel.fail(new Error(`The turn's delta queue refused a delta (${result.reason})`));
76
- }
77
- }
78
- function sessionAbort(caller) {
79
- if (caller?.aborted)
80
- throw abortReason(caller);
81
- const own = new AbortController;
82
- const link = caller ? linkAbortSignals(caller, own.signal) : { signal: own.signal, release: () => {
83
- return;
84
- } };
85
- return { signal: link.signal, abort: () => own.abort(), release: link.release };
86
- }
87
- function runEngineCli(input) {
88
- return runNativeCommand2({
89
- executable: input.executable,
90
- args: [...input.prefix, ...input.args],
91
- env: engineEnvironment2(input.profile, input.ambient),
92
- envPolicy: "declared-only",
93
- capture: true,
94
- maxOutputBytes: 1024 * 1024,
95
- timeoutMs: 30000
96
- });
97
- }
98
- function errorText(error) {
99
- return error instanceof Error ? error.message : String(error);
100
- }
101
- async function stopConnection(connection, primary) {
102
- let stopFailure;
103
- try {
104
- await connection.engine.stop();
105
- } catch (error) {
106
- stopFailure = { error };
107
- }
108
- await connection.reading;
109
- if (stopFailure === undefined)
110
- return;
111
- if (primary === undefined)
112
- throw stopFailure.error;
113
- throw new AggregateError([primary.error, stopFailure.error], `${errorText(primary.error)}; stopping the engine also failed: ${errorText(stopFailure.error)}`, { cause: primary.error });
114
- }
115
- async function withEphemeralConnection(connect, use) {
116
- const stop = new AbortController;
117
- const connection = await connect(stop.signal);
118
- let answer;
119
- try {
120
- answer = await use(connection);
121
- } catch (error) {
122
- stop.abort();
123
- await stopConnection(connection, { error });
124
- throw error;
125
- }
126
- stop.abort();
127
- try {
128
- await stopConnection(connection);
129
- } catch {}
130
- return answer;
131
- }
132
- function safeJsonValue(value) {
133
- const snapshot = {};
134
- const refusal = jsonDataRefusal(value, SAFE_JSON_LIMITS, snapshot);
135
- if (refusal !== undefined) {
136
- throw new TypeError(`Expected bounded JSON data (refused: ${refusal})`);
137
- }
138
- return z.json().parse(snapshot.value);
139
- }
140
- function invokeSafely(invoke) {
141
- try {
142
- const result = invoke();
143
- if (typeof result === "object" && result !== null && "then" in result && typeof result.then === "function") {
144
- Promise.resolve(result).catch(() => {
145
- return;
146
- });
147
- }
148
- } catch {}
149
- }
150
- function emitStartupPhase(callback, phase) {
151
- if (callback === undefined)
152
- return;
153
- const parsed = ExecutorStartupPhaseSchema2.parse(phase);
154
- invokeSafely(() => callback(parsed));
155
- }
156
- function clampUniqueWindowName(prefix, suffix, seenNames, disambiguatorSeed, maxChars = 256) {
157
- const maxPrefix = Math.max(1, maxChars - suffix.length);
158
- let candidate = prefix.length > maxPrefix ? `${prefix.slice(0, maxPrefix)}${suffix}`.slice(0, maxChars) : `${prefix}${suffix}`;
159
- if (!seenNames.has(candidate)) {
160
- seenNames.add(candidate);
161
- return candidate;
162
- }
163
- const digest = createHash("sha256").update(disambiguatorSeed).digest("hex").slice(0, 8);
164
- const tag = `#${digest}${suffix}`;
165
- const room = Math.max(1, maxChars - tag.length);
166
- candidate = `${prefix.slice(0, room)}${tag}`.slice(0, maxChars);
167
- let index = 2;
168
- while (seenNames.has(candidate)) {
169
- const indexedTag = `#${digest}_${index}${suffix}`;
170
- const indexedRoom = Math.max(1, maxChars - indexedTag.length);
171
- candidate = `${prefix.slice(0, indexedRoom)}${indexedTag}`.slice(0, maxChars);
172
- index += 1;
173
- }
174
- seenNames.add(candidate);
175
- return candidate;
176
- }
177
-
178
- // src/agent-executor/engine-requests.ts
179
- function holdEngineRequest(turn, request) {
180
- if (turn.state.interruptRequested) {
181
- request.resolve(request.refusal);
182
- return;
183
- }
184
- const offered = request.delta();
185
- turn.pending.set(request.interactionId, {
186
- detail: request.detail,
187
- answeredBy: request.answeredBy,
188
- resolve: request.resolve
189
- });
190
- offerTurnDelta(turn.channel, offered);
191
- }
192
- function answerEngineRequest(turn, interactionId, answer) {
193
- const waiting = turn.pending.get(interactionId);
194
- if (waiting === undefined)
195
- return false;
196
- waiting.resolve(answer);
197
- turn.pending.delete(interactionId);
198
- offerTurnDelta(turn.channel, {
199
- type: "request-resolved",
200
- turnId: turn.state.turnId,
201
- itemId: `resolved:${interactionId}`,
202
- raw: waiting.answeredBy,
203
- interactionId
204
- });
205
- return true;
206
- }
207
- function drainEngineRequests(turn, answer) {
208
- if (turn === undefined)
209
- return;
210
- for (const [interactionId, waiting] of [...turn.pending]) {
211
- answerEngineRequest(turn, interactionId, answer(waiting));
212
- }
213
- }
214
- function endEngineTurn(turn, answer, deltas) {
215
- if (turn === undefined)
216
- return;
217
- drainEngineRequests(turn, answer);
218
- for (const delta of deltas)
219
- offerTurnDelta(turn.channel, delta);
220
- turn.channel.close();
221
- }
222
- function loseEngineTurn(turn, answer, error) {
223
- if (turn === undefined)
224
- return;
225
- drainEngineRequests(turn, answer);
226
- turn.channel.fail(error);
227
- }
228
-
229
- export { nonEmptyString, epochSecondsToIso, createTurnDeltaChannel, offerTurnDelta, sessionAbort, runEngineCli, stopConnection, withEphemeralConnection, safeJsonValue, invokeSafely, emitStartupPhase, clampUniqueWindowName, holdEngineRequest, answerEngineRequest, drainEngineRequests, endEngineTurn, loseEngineTurn };