stitchkit 0.56.2 → 0.56.4

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.
@@ -15,10 +15,12 @@ export interface AgentSessionCoordinator {
15
15
  create(signal: AbortSignal): AgentCoordinatedRun<RESULT> | Promise<AgentCoordinatedRun<RESULT>>;
16
16
  }): AgentRunTicket<RESULT>;
17
17
  stop(key: string, reason?: AgentStopReason): boolean;
18
- close(options?: {
19
- drainTimeoutMs?: number;
20
- }): Promise<void>;
18
+ close(options?: AgentSessionCloseOptions): Promise<void>;
21
19
  isRunning(key: string): boolean;
22
20
  }
21
+ export interface AgentSessionCloseOptions {
22
+ drainTimeoutMs?: number;
23
+ forceTimeoutMs?: number;
24
+ }
23
25
  export declare function createAgentSessionCoordinator(): AgentSessionCoordinator;
24
26
  //# sourceMappingURL=coordinator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coordinator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,WAAW,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,SAAS,GAAG,UAAU,CAAC;AAExE,MAAM,WAAW,mBAAmB,CAAC,MAAM;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc,CAAC,MAAM;IACpC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,gBAAgB,CAAC;QACzB,MAAM,CACJ,MAAM,EAAE,WAAW,GAClB,mBAAmB,CAAC,MAAM,CAAC,GAAG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AAe,GAAG,OAAO,CAAC;IACrD,KAAK,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAiBD,wBAAgB,6BAA6B,IAAI,uBAAuB,CAuHvE"}
@@ -2,7 +2,7 @@ import { type GeneratedFile, type ModelMessage, type PrepareStepFunction, type S
2
2
  import { z } from 'zod';
3
3
  import { type ToolLifecycle } from '../tools/execute';
4
4
  import type { AgentCompactionResult } from './compaction';
5
- import { type AgentInputPolicy, type AgentStopReason } from './coordinator';
5
+ import { type AgentInputPolicy, type AgentSessionCloseOptions, type AgentStopReason } from './coordinator';
6
6
  import type { AgentRuntimePublisher } from './events';
7
7
  import { type AgentHistoryProjectionOptions } from './history';
8
8
  import type { AgentResolvedModel } from './models';
@@ -21,6 +21,17 @@ export interface AgentRuntimeInput {
21
21
  context: unknown;
22
22
  parts: readonly AgentMessagePart[];
23
23
  metadata?: unknown;
24
+ recordIds?: AgentRuntimeRecordIds;
25
+ }
26
+ export interface AgentRuntimeRecordIds {
27
+ inputMessageId: string;
28
+ runId: string;
29
+ assistantMessageId: string;
30
+ }
31
+ export interface AgentRuntimeAdmission {
32
+ runId: string;
33
+ assistantMessageId: string;
34
+ snapshotVersion: number;
24
35
  }
25
36
  export interface AgentRuntimeRecoveryInput {
26
37
  conversationId: string;
@@ -104,6 +115,7 @@ export interface AgentRuntimeResult {
104
115
  export interface AgentRuntime {
105
116
  submit(input: AgentRuntimeInput): {
106
117
  accepted: Promise<void>;
118
+ admission: Promise<AgentRuntimeAdmission>;
107
119
  result: Promise<AgentRuntimeResult>;
108
120
  };
109
121
  resume(input: AgentRuntimeRecoveryInput): {
@@ -112,9 +124,7 @@ export interface AgentRuntime {
112
124
  };
113
125
  interrupt(input: AgentRuntimeInterruptInput): Promise<AgentStoreMutationResult>;
114
126
  stop(conversationKey: string, reason?: AgentStopReason): boolean;
115
- close(options?: {
116
- drainTimeoutMs?: number;
117
- }): Promise<void>;
127
+ close(options?: AgentSessionCloseOptions): Promise<void>;
118
128
  }
119
129
  export declare function createAgentRuntime<CONTEXT, TOOLS extends ToolSet>(config: AgentRuntimeConfig<CONTEXT, TOOLS>): AgentRuntime;
120
130
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAGlB,KAAK,OAAO,EACb,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAErB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAqB,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,KAAK,6BAA6B,EAAuB,MAAM,WAAW,CAAC;AAEpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAGrB,KAAK,QAAQ,EAEb,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAEzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EA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AqB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACvF,eAAe,IAAI,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;CACtD;AAsDD,mGAAmG;AACnG,wBAAgB,6BAA6B,IAAI,iBAAiB,CAwTjE"}
@@ -1,5 +1,5 @@
1
1
  export { type AgentCompactionContext, type AgentCompactionResult, type StructuredCompactionConfig, structuredCompaction, } from './agent-runtime/compaction';
2
- export { type AgentCoordinatedRun, type AgentInputPolicy, type AgentRunTicket, type AgentSessionCoordinator, type AgentStopReason, createAgentSessionCoordinator, } from './agent-runtime/coordinator';
2
+ export { type AgentCoordinatedRun, type AgentInputPolicy, type AgentRunTicket, type AgentSessionCloseOptions, type AgentSessionCoordinator, type AgentStopReason, createAgentSessionCoordinator, } from './agent-runtime/coordinator';
3
3
  export { AgentCheckpointEventSchema, AgentRunStateEventSchema, type AgentRuntimeEvent, AgentRuntimeEventSchema, type AgentRuntimePublisher, AgentTerminalEventSchema, AgentToolStatusEventSchema, AgentTransientDeltaEventSchema, } from './agent-runtime/events';
4
4
  export { type AgentHistoryProjectionOptions, projectAgentHistory, } from './agent-runtime/history';
5
5
  export { type AgentToolFenceConfig, type AgentToolFenceContext, createAgentToolFenceLifecycle, } from './agent-runtime/managed-tools';
@@ -7,7 +7,7 @@ export { type AgentLanguageModelProvider, type AgentModelCapability, AgentModelC
7
7
  export { type AgentObservability, type AgentRunEvent, AgentRunEventSchema, type AgentRunSinkConfig, type AgentRunSinkDrop, type AgentRunSinkError, createAgentObservability, } from './agent-runtime/observability';
8
8
  export { type AgentPromptBudget, type AgentPromptSection, type AgentPromptSectionContext, type AgentTokenCount, AgentTokenCountSchema, type ComposeAgentPromptOptions, type ComposedAgentPrompt, composeAgentPrompt, } from './agent-runtime/prompt';
9
9
  export { type AgentProtocol, type AgentProtocolConfig, defineAgentProtocol, } from './agent-runtime/protocol';
10
- export { type AgentRuntime, type AgentRuntimeConfig, type AgentRuntimeInput, type AgentRuntimeInterruptInput, type AgentRuntimePrepareStep, type AgentRuntimeProtocolInput, type AgentRuntimeRecoveryInput, type AgentRuntimeResult, type AgentRuntimeRunContext, type AgentRuntimeStopPolicy, createAgentRuntime, } from './agent-runtime/runtime';
10
+ export { type AgentRuntime, type AgentRuntimeAdmission, type AgentRuntimeConfig, type AgentRuntimeInput, type AgentRuntimeInterruptInput, type AgentRuntimePrepareStep, type AgentRuntimeProtocolInput, type AgentRuntimeRecordIds, type AgentRuntimeRecoveryInput, type AgentRuntimeResult, type AgentRuntimeRunContext, type AgentRuntimeStopPolicy, createAgentRuntime, } from './agent-runtime/runtime';
11
11
  export * from './agent-runtime/schemas';
12
12
  export { type AcceptInputAndAssignRun, AcceptInputAndAssignRunSchema, type AcquireAgentRun, AcquireAgentRunSchema, type AgentRuntimeStore, AgentStoreAppliedSchema, AgentStoreConflictSchema, AgentStoreDuplicateSchema, type AgentStoreMutationResult, AgentStoreMutationResultSchema, AgentStoreNotFoundSchema, type CheckpointRunAssistant, CheckpointRunAssistantSchema, type CommitRunTerminal, CommitRunTerminalSchema, createMemoryAgentRuntimeStore, type RecoverAgentRun, RecoverAgentRunSchema, type ReplaceCompactedRange, ReplaceCompactedRangeSchema, type RequestRunInterrupt, RequestRunInterruptSchema, } from './agent-runtime/store';
13
13
  //# sourceMappingURL=agent-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runtime.d.ts","sourceRoot":"","sources":["../src/agent-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,K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EACrB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC"}
@@ -112,6 +112,19 @@ function structuredCompaction(config) {
112
112
  function createAgentSessionCoordinator() {
113
113
  const lanes = new Map;
114
114
  let closed = false;
115
+ const waitWithin = async (settled, timeoutMs) => {
116
+ if (timeoutMs === 0)
117
+ return false;
118
+ let timer;
119
+ const timeout = new Promise((resolve) => {
120
+ timer = setTimeout(() => resolve(false), timeoutMs);
121
+ });
122
+ const completed = settled.then(() => true);
123
+ const result = await Promise.race([completed, timeout]);
124
+ if (timer !== undefined)
125
+ clearTimeout(timer);
126
+ return result;
127
+ };
115
128
  const laneFor = (key) => {
116
129
  const existing = lanes.get(key);
117
130
  if (existing)
@@ -178,23 +191,34 @@ function createAgentSessionCoordinator() {
178
191
  return true;
179
192
  },
180
193
  async close(options = {}) {
194
+ for (const [name, value] of Object.entries(options)) {
195
+ if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {
196
+ throw new TypeError(`${name} must be a non-negative safe integer`);
197
+ }
198
+ }
181
199
  closed = true;
182
200
  const error = new Error("Agent session coordinator is closed");
183
201
  for (const lane of lanes.values()) {
184
- lane.active?.controller.abort("shutdown");
185
202
  for (const pending of lane.queue.splice(0))
186
203
  pending.reject(error);
187
204
  }
188
- const settlements = [...lanes.values()].map((lane) => lane.active?.settled).filter((settled) => settled !== undefined);
205
+ const active = [...lanes.values()].map((lane) => lane.active).filter((run) => run !== undefined);
206
+ const settlements = active.map((run) => run.settled);
189
207
  const drain = Promise.all(settlements).then(() => {
190
208
  return;
191
209
  });
210
+ if (options.drainTimeoutMs !== undefined) {
211
+ const drained = await waitWithin(drain, options.drainTimeoutMs);
212
+ if (drained)
213
+ return;
214
+ }
215
+ for (const run of active)
216
+ run.controller.abort("shutdown");
192
217
  if (options.drainTimeoutMs === undefined)
193
218
  return drain;
194
- await Promise.race([
195
- drain,
196
- new Promise((resolve) => setTimeout(resolve, options.drainTimeoutMs))
197
- ]);
219
+ if (options.forceTimeoutMs === undefined)
220
+ return;
221
+ await waitWithin(drain, options.forceTimeoutMs);
198
222
  },
199
223
  isRunning(key) {
200
224
  return lanes.get(key)?.active !== undefined;
@@ -1353,16 +1377,16 @@ function createAgentRuntime(config) {
1353
1377
  ...metadata !== undefined && { metadata }
1354
1378
  };
1355
1379
  const context = config.protocol.parseContext(input.context);
1356
- const ticketKey = `${input.conversationId}\x00${input.idempotencyKey}`;
1357
- const existingTicket = tickets.get(ticketKey);
1380
+ const conversationTickets = tickets.get(input.conversationId);
1381
+ const existingTicket = conversationTickets?.get(input.idempotencyKey);
1358
1382
  if (existingTicket)
1359
1383
  return existingTicket;
1360
1384
  const key = config.runs?.key?.(input) ?? input.conversationId;
1361
1385
  const policy = typeof config.runs?.inputPolicy === "function" ? config.runs.inputPolicy(input) : config.runs?.inputPolicy ?? "queue";
1362
1386
  const nowIso = now().toISOString();
1363
- const inputMessageId = generateId();
1364
- const runId = generateId();
1365
- const assistantMessageId = generateId();
1387
+ const inputMessageId = rawInput.recordIds?.inputMessageId ?? generateId();
1388
+ const runId = rawInput.recordIds?.runId ?? generateId();
1389
+ const assistantMessageId = rawInput.recordIds?.assistantMessageId ?? generateId();
1366
1390
  const userMessage2 = AgentMessageSchema.parse({
1367
1391
  schemaVersion: 1,
1368
1392
  id: inputMessageId,
@@ -1386,6 +1410,10 @@ function createAgentRuntime(config) {
1386
1410
  updatedAt: nowIso
1387
1411
  });
1388
1412
  const outerAccepted = Promise.withResolvers();
1413
+ const outerAdmission = Promise.withResolvers();
1414
+ outerAdmission.promise.catch(() => {
1415
+ return;
1416
+ });
1389
1417
  const outerResult = Promise.withResolvers();
1390
1418
  const reservation = config.runs?.coalescePending ? reserveAdmission(key, runId) : undefined;
1391
1419
  const previousAcceptance = reservation?.lane.acceptanceTail ?? Promise.resolve();
@@ -1395,9 +1423,23 @@ function createAgentRuntime(config) {
1395
1423
  return;
1396
1424
  }).then(() => acceptanceDone.promise);
1397
1425
  }
1398
- const publicTicket = { accepted: outerAccepted.promise, result: outerResult.promise };
1399
- tickets.set(ticketKey, publicTicket);
1400
- outerResult.promise.then(() => tickets.delete(ticketKey), () => tickets.delete(ticketKey));
1426
+ const publicTicket = {
1427
+ accepted: outerAccepted.promise,
1428
+ admission: outerAdmission.promise,
1429
+ result: outerResult.promise
1430
+ };
1431
+ const currentConversationTickets = conversationTickets ?? new Map;
1432
+ currentConversationTickets.set(input.idempotencyKey, publicTicket);
1433
+ if (!conversationTickets)
1434
+ tickets.set(input.conversationId, currentConversationTickets);
1435
+ const forgetTicket = () => {
1436
+ if (currentConversationTickets.get(input.idempotencyKey) !== publicTicket)
1437
+ return;
1438
+ currentConversationTickets.delete(input.idempotencyKey);
1439
+ if (currentConversationTickets.size === 0)
1440
+ tickets.delete(input.conversationId);
1441
+ };
1442
+ outerResult.promise.then(forgetTicket, forgetTicket);
1401
1443
  (async () => {
1402
1444
  try {
1403
1445
  await previousAcceptance.catch(() => {
@@ -1414,6 +1456,11 @@ function createAgentRuntime(config) {
1414
1456
  const acceptedSnapshot = appliedSnapshot(acceptance, "input acceptance");
1415
1457
  const assignedRunId = acceptance.outcome === "duplicate" ? acceptance.runId : reservation?.admission.runId ?? runId;
1416
1458
  const acceptedRun = findRun(acceptedSnapshot.runs, assignedRunId);
1459
+ outerAdmission.resolve({
1460
+ runId: acceptedRun.id,
1461
+ assistantMessageId: acceptedRun.assistantMessageId,
1462
+ snapshotVersion: acceptedSnapshot.version
1463
+ });
1417
1464
  await publish({
1418
1465
  type: "run-state",
1419
1466
  eventId: generateId(),
@@ -1489,6 +1536,7 @@ function createAgentRuntime(config) {
1489
1536
  }
1490
1537
  } catch (error) {
1491
1538
  outerAccepted.reject(error);
1539
+ outerAdmission.reject(error);
1492
1540
  outerResult.reject(error);
1493
1541
  if (reservation?.shouldSchedule) {
1494
1542
  reservation.admission.completion.reject(error);
@@ -1700,9 +1748,6 @@ function createMemoryAgentRuntimeStore() {
1700
1748
  snapshot: cloneSnapshot(entry.snapshot)
1701
1749
  };
1702
1750
  }
1703
- if (input.run.conversationId !== input.input.conversationId || input.run.inputMessageIds.length !== 1 || input.run.inputMessageIds[0] !== input.input.id || input.run.state !== "queued" || input.run.revision !== 0 || input.run.ownerId !== undefined || input.run.terminalReason !== undefined || input.run.terminalPolicyName !== undefined || input.input.role !== "user" || input.input.status !== "committed" || input.input.runId !== undefined || entry.snapshot.messages.some((message) => message.id === input.input.id) || entry.snapshot.runs.some((candidate) => candidate.id === input.run.id)) {
1704
- throw new TypeError("Input and queued run do not form one valid assignment");
1705
- }
1706
1751
  if (input.expectedVersion !== undefined && input.expectedVersion !== entry.snapshot.version) {
1707
1752
  return conflict(entry.snapshot.version);
1708
1753
  }
@@ -1710,6 +1755,9 @@ function createMemoryAgentRuntimeStore() {
1710
1755
  if (input.coalesceIntoRunId !== undefined && (!coalescedRun || coalescedRun.conversationId !== input.input.conversationId || coalescedRun.state !== "queued" || coalescedRun.ownerId !== undefined || coalescedRun.terminalReason !== undefined)) {
1711
1756
  return coalescedRun ? conflict(coalescedRun.revision) : { outcome: "not_found" };
1712
1757
  }
1758
+ if (input.run.conversationId !== input.input.conversationId || input.run.inputMessageIds.length !== 1 || input.run.inputMessageIds[0] !== input.input.id || input.run.state !== "queued" || input.run.revision !== 0 || input.run.ownerId !== undefined || input.run.terminalReason !== undefined || input.run.terminalPolicyName !== undefined || input.input.role !== "user" || input.input.status !== "committed" || input.input.runId !== undefined || entry.snapshot.messages.some((message) => message.id === input.input.id) || !coalescedRun && (input.run.assistantMessageId === input.input.id || entry.snapshot.runs.some((candidate) => candidate.id === input.run.id) || entry.snapshot.runs.some((candidate) => candidate.assistantMessageId === input.run.assistantMessageId) || entry.snapshot.messages.some((message) => message.id === input.run.assistantMessageId))) {
1759
+ throw new TypeError("Input and queued run do not form one valid assignment");
1760
+ }
1713
1761
  const assignedRun = coalescedRun ? AgentRunSchema.parse({
1714
1762
  ...coalescedRun,
1715
1763
  inputMessageIds: [...coalescedRun.inputMessageIds, input.input.id],
package/llms-full.txt CHANGED
@@ -3468,12 +3468,27 @@ const ticket = runtime.submit({
3468
3468
  idempotencyKey: 'request-id',
3469
3469
  context: { userId: 'user-id' },
3470
3470
  parts: [{ type: 'text', text: 'Hello' }],
3471
+ recordIds: {
3472
+ inputMessageId: 'user-message-id',
3473
+ runId: 'run-id',
3474
+ assistantMessageId: 'assistant-message-id',
3475
+ },
3471
3476
  })
3472
3477
 
3478
+ const admission = await ticket.admission
3473
3479
  await ticket.accepted
3474
3480
  const terminal = await ticket.result
3475
3481
  ```
3476
3482
 
3483
+ `recordIds` is optional. Supply stable application record IDs when an accepted-response transport must
3484
+ return durable placeholders before the run finishes. `ticket.admission` resolves after the store
3485
+ acceptance CAS and reports the actually assigned `runId`, `assistantMessageId` and snapshot version.
3486
+ Those assigned IDs can differ from the proposal when an input coalesces into an existing queued
3487
+ successor. Reuse the same `inputMessageId` for retries carrying the same idempotency key; input
3488
+ identity is caller-stable, while the receipt reports the run/assistant identities that assignment
3489
+ may change. Await `admission` first on the immediate accepted-response path. `ticket.accepted`
3490
+ remains the signal-only compatibility surface and additionally waits for admission publication.
3491
+
3477
3492
  The in-memory store is a reference adapter and has process-local durability
3478
3493
  only. Production applications implement `AgentRuntimeStore` with their own
3479
3494
  database transaction and, when needed, distributed lease/fencing token.
@@ -3497,6 +3512,20 @@ resolves to the same terminal run. Coalescing never mutates the active run.
3497
3512
  while the predecessor still owns managed callbacks. A hung predecessor blocks
3498
3513
  the lane in the first version.
3499
3514
 
3515
+ Shutdown is two-phase when a drain budget is supplied:
3516
+
3517
+ ```ts
3518
+ await runtime.close({ drainTimeoutMs: 30_000, forceTimeoutMs: 5_000 })
3519
+ ```
3520
+
3521
+ `close` first rejects new process-local admissions and gives active runs the
3522
+ natural drain budget. Only after that budget expires does it abort them with
3523
+ reason `shutdown`; `forceTimeoutMs` bounds the final settlement wait for a
3524
+ non-cooperative model or tool. Calling `close()` without `drainTimeoutMs` keeps
3525
+ the immediate-shutdown form: abort active runs, then wait for their settlement.
3526
+ Durably queued records rejected from the local queue remain recoverable through
3527
+ `scanRecoverable`; close never marks them terminal on its own.
3528
+
3500
3529
  Use `await runtime.interrupt({ conversationId, runId })` when the interruption
3501
3530
  must be durable: it first commits `interrupt_requested`, then aborts the local
3502
3531
  coordinator signal. `runtime.stop(key)` is the process-local signal-only escape
@@ -7922,6 +7951,9 @@ Server-only optional application runtime. See the
7922
7951
  | `createAgentSessionCoordinator` | function | strict process-local queue/interrupt lifecycle |
7923
7952
  | `AgentRuntimeStopPolicy` | _type_ | named custom AI SDK stop condition persisted and published on policy stop |
7924
7953
  | `AgentRuntimePrepareStep` | _type_ | per-run controlled step callback with typed domain context and managed run signal/fence |
7954
+ | `AgentRuntimeRecordIds` | _type_ | optional caller-provided input, run and assistant IDs for stable application records |
7955
+ | `AgentRuntimeAdmission` | _type_ | actual assigned run/assistant identity and snapshot version after durable admission |
7956
+ | `AgentSessionCloseOptions` | _type_ | natural `drainTimeoutMs` followed by shutdown abort and optional bounded `forceTimeoutMs` settlement wait |
7925
7957
  | `AgentHistoryProjectionOptions` | _type_ | storage-neutral file resolver and explicit unresolved-file behavior |
7926
7958
  | `createAgentToolFenceLifecycle` | function | pre-effect and post-effect run ownership fence for `mountAgent` |
7927
7959
  | `AgentRuntimeEventSchema` | schema | transient delta, durable checkpoint/run-state/tool and terminal event union |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.56.2",
3
+ "version": "0.56.4",
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",