@dbos-inc/vercel-ai 0.2.5 → 0.3.7

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.
@@ -6,19 +6,18 @@ exports.durableImageCalls = durableImageCalls;
6
6
  const node_crypto_1 = require("node:crypto");
7
7
  const dbos_sdk_1 = require("@dbos-inc/dbos-sdk");
8
8
  const internal_1 = require("./internal");
9
+ const durable_stream_1 = require("./durable-stream");
9
10
  // In-flight durable model calls per workflow; concurrent calls have a nondeterministic DBOS step order on replay, so we reject them.
10
11
  const inflightModelCalls = new Map();
11
- // Consumer abort signals withheld from the provider inside a workflow, keyed by the transformed params wrapStream receives.
12
- const detachedAbortSignals = new WeakMap();
13
- function enterDurableModelCall(operation) {
12
+ // A stream call whose consumer detached (abort/cancel) but whose step is still settling; the next call in that workflow waits for it.
13
+ const settlingModelCalls = new Map();
14
+ async function enterDurableModelCall() {
14
15
  const workflowID = dbos_sdk_1.DBOS.workflowID;
16
+ // Sequence after a detached call's checkpoint, so steps are always recorded in the order they were started.
17
+ await settlingModelCalls.get(workflowID);
15
18
  const inflight = inflightModelCalls.get(workflowID) ?? 0;
16
19
  if (inflight > 0) {
17
- // embedMany parallelizes its batches; maxParallelCalls: 1 serializes them deterministically. Other callers use child workflows.
18
- const remedy = operation === 'embed'
19
- ? 'pass maxParallelCalls: 1 to embedMany, or run each call in its own child workflow with DBOS.startWorkflow'
20
- : 'run each call in its own child workflow with DBOS.startWorkflow';
21
- throw new Error(`Concurrent durable model calls in workflow "${workflowID}" are not supported because their step order is nondeterministic on replay; ${remedy}.`);
20
+ throw new Error(`Concurrent durable model calls in workflow "${workflowID}" are not supported because their step order is nondeterministic on replay; run each call in its own child workflow with DBOS.startWorkflow.`);
22
21
  }
23
22
  inflightModelCalls.set(workflowID, inflight + 1);
24
23
  return workflowID;
@@ -34,32 +33,33 @@ function exitDurableModelCall(workflowID) {
34
33
  }
35
34
  /** AI SDK language-model middleware that runs each model call as a durable, checkpointed DBOS step (replayed on recovery); outside a workflow it calls the model directly. */
36
35
  function durableCalls(options = {}) {
37
- const stepConfig = (0, internal_1.withErrorClassification)(options);
36
+ const { durableStream, ...stepOptions } = options;
37
+ const stepConfig = (0, internal_1.withErrorClassification)(stepOptions);
38
+ const streamConfig = (0, durable_stream_1.resolveDurableStream)(durableStream);
38
39
  return {
39
40
  specificationVersion: 'v4',
40
- // A consumer abort (a stop button, an AI SDK timeout, a shutting-down worker) must not cut a durable stream short:
41
- // the truncated output would be checkpointed as the step's permanent result and replayed on recovery as the whole
42
- // answer. Withhold the signal from the provider so the call records a complete result; keep it here for the guard.
43
- // Generate is left alone: an aborted doGenerate rejects (nothing partial to record), and the AI SDK's tool loop
44
- // relies on that rejection to stop — stripping it there would let the loop keep calling the model after an abort.
45
- transformParams: async ({ params, type }) => {
46
- if (type !== 'stream' || !(0, internal_1.isInWorkflowFunction)() || !params.abortSignal) {
47
- return params;
48
- }
49
- const { abortSignal, ...rest } = params;
50
- detachedAbortSignals.set(rest, abortSignal);
51
- return rest;
52
- },
53
- wrapGenerate: async ({ doGenerate, model }) => {
41
+ wrapGenerate: async ({ doGenerate, params, model }) => {
54
42
  (0, internal_1.assertNotInTransaction)('generate');
55
43
  if (!(0, internal_1.isInWorkflowFunction)()) {
56
44
  return await doGenerate();
57
45
  }
58
- const workflowID = enterDurableModelCall('generate');
46
+ const workflowID = await enterDurableModelCall();
59
47
  try {
60
- return await dbos_sdk_1.DBOS.runStep(async () => ensureResponseMetadata(encodeBinaryContent(await doGenerate())), {
48
+ return await dbos_sdk_1.DBOS.runStep(async () => {
49
+ const result = ensureResponseMetadata(encodeBinaryContent(await doGenerate()));
50
+ // A non-streaming call writes its whole output at once, so the stream holds every call the loop makes, not only streamed ones.
51
+ if (streamConfig) {
52
+ const streamWriter = new durable_stream_1.ModelStreamWriter(streamConfig);
53
+ for (const part of replayParts(result))
54
+ streamWriter.push(part);
55
+ await streamWriter.end({ finishReason: result.finishReason });
56
+ }
57
+ return result;
58
+ }, {
61
59
  ...stepConfig,
62
60
  name: stepConfig.name ?? stepName(model, 'generate'),
61
+ // An aborted call is never retried, whatever the provider's rejection looks like.
62
+ shouldRetry: async (error) => params.abortSignal?.aborted !== true && (await stepConfig.shouldRetry(error)),
63
63
  });
64
64
  }
65
65
  catch (error) {
@@ -75,38 +75,37 @@ function durableCalls(options = {}) {
75
75
  if (!(0, internal_1.isInWorkflowFunction)()) {
76
76
  return await doStream();
77
77
  }
78
- const workflowID = enterDurableModelCall('stream');
79
- // The consumer's signal, detached from the provider call by transformParams (undefined outside a workflow).
80
- const abortSignal = detachedAbortSignals.get(params);
81
- // An aborted consumer is done with this call, like a cancelled one: post-abort failures must checkpoint as a (partial) success, or replay would fail where the live run ended gracefully.
78
+ const workflowID = await enterDurableModelCall();
79
+ // The caller's abortSignal merged with the AI SDK's timeouts; an abort stops the provider call and is recorded as the step's outcome.
80
+ const abortSignal = params.abortSignal;
82
81
  const aborted = () => abortSignal?.aborted === true;
83
- // Free the concurrency guard as soon as the consumer detaches (abort/cancel), not only when the step
84
- // settles: this call's step is already sequenced, so a sequential follow-up in the same workflow is
85
- // deterministic on replay and must not be rejected as concurrent while this step drains in the background.
86
- let guardReleased = false;
87
- const releaseGuard = () => {
88
- if (guardReleased)
89
- return;
90
- guardReleased = true;
91
- abortSignal?.removeEventListener('abort', releaseGuard);
92
- exitDurableModelCall(workflowID);
93
- };
94
- abortSignal?.addEventListener('abort', releaseGuard, { once: true });
95
82
  let executed = false;
96
83
  let cancelled = false;
97
84
  let emittedLive = false;
85
+ let released = false;
98
86
  let controller;
99
87
  let step;
88
+ let settled;
89
+ // A detached consumer (abort/cancel) may issue a sequential follow-up while this step still settles: make that call wait for this checkpoint instead of refusing it as concurrent.
90
+ const detach = () => {
91
+ abortSignal?.removeEventListener('abort', detach);
92
+ if (!released)
93
+ settlingModelCalls.set(workflowID, settled);
94
+ };
95
+ abortSignal?.addEventListener('abort', detach, { once: true });
100
96
  const stream = new ReadableStream({
101
97
  start(c) {
102
98
  controller = c;
103
99
  },
104
- // Await the step so an early cancel still blocks until the model result is checkpointed.
100
+ // Await the step so a direct cancel blocks until the checkpoint; through the AI SDK's pipeline a consumer's early exit returns sooner, hence the rule to drain or abort instead.
105
101
  async cancel() {
106
102
  cancelled = true;
107
- releaseGuard();
103
+ detach();
108
104
  // Post-cancel failures normally checkpoint as a success; anything else (e.g. a failed checkpoint write) is only visible here.
109
- await step.catch((error) => dbos_sdk_1.DBOS.logger.warn(`Durable model call step failed after consumer cancel: ${String(error)}`));
105
+ await step.catch((error) => {
106
+ if (!aborted())
107
+ dbos_sdk_1.DBOS.logger.warn(`Durable model call step failed after consumer cancel: ${String(error)}`);
108
+ });
110
109
  },
111
110
  });
112
111
  const emit = (part) => {
@@ -117,10 +116,10 @@ function durableCalls(options = {}) {
117
116
  emittedLive = true;
118
117
  }
119
118
  };
120
- // Once any output part has streamed live, a retry would re-stream from scratch and duplicate output, so stop retrying.
119
+ // Once any output part has streamed live, a retry would re-stream from scratch and duplicate output; an aborted call is never retried.
121
120
  const streamStepConfig = {
122
121
  ...stepConfig,
123
- shouldRetry: async (error) => !emittedLive && (stepConfig.shouldRetry ? await stepConfig.shouldRetry(error) : true),
122
+ shouldRetry: async (error) => !emittedLive && !aborted() && (stepConfig.shouldRetry ? await stepConfig.shouldRetry(error) : true),
124
123
  };
125
124
  try {
126
125
  step = dbos_sdk_1.DBOS.runStep(async () => {
@@ -133,7 +132,10 @@ function durableCalls(options = {}) {
133
132
  let sawFinish = false;
134
133
  const abandon = () => void reader?.cancel().catch(() => { });
135
134
  timeoutSignal?.addEventListener('abort', abandon, { once: true });
136
- // A consumer abort deliberately does not abandon the drain: the step keeps reading so the checkpoint is complete.
135
+ // A consumer abort tears the provider call down too; the attempt is then recorded as aborted below.
136
+ abortSignal?.addEventListener('abort', abandon, { once: true });
137
+ // Step-scope stream writes: cheap, replay-safe, and never duplicated since a retry is refused once content has streamed.
138
+ const streamWriter = streamConfig ? new durable_stream_1.ModelStreamWriter(streamConfig) : undefined;
137
139
  try {
138
140
  streamResult = await doStream();
139
141
  reader = streamResult.stream.getReader();
@@ -141,11 +143,11 @@ function durableCalls(options = {}) {
141
143
  const { done, value: part } = await reader.read();
142
144
  if (timeoutSignal?.aborted)
143
145
  throw (timeoutSignal.reason ?? new Error('step attempt timed out'));
144
- if (done)
146
+ if (done || aborted())
145
147
  break;
146
148
  if (part.type === 'error') {
147
- // A cancelled or aborted consumer abandoned this call; don't let a late failure become the step outcome, or replay would fail where the live run succeeded.
148
- if (cancelled || aborted())
149
+ // A cancelled consumer abandoned this call; don't let a late failure become the step outcome, or replay would fail where the live run succeeded.
150
+ if (cancelled)
149
151
  break;
150
152
  throw toStepError(part.error);
151
153
  }
@@ -154,6 +156,7 @@ function durableCalls(options = {}) {
154
156
  sawFinish = true;
155
157
  else
156
158
  emit(part);
159
+ streamWriter?.push(part);
157
160
  accumulator.add(part);
158
161
  }
159
162
  // No terminal part and no output: fail (retryably) like the AI SDK's NoOutputGeneratedError, instead of checkpointing a permanent empty success.
@@ -162,34 +165,53 @@ function durableCalls(options = {}) {
162
165
  }
163
166
  }
164
167
  catch (error) {
165
- // Same rule for stream-level failures (doStream or a read rejecting) after a cancel or abort.
166
- if (!cancelled && !aborted())
168
+ // Same rule for stream-level failures (doStream or a read rejecting) after a cancel; after an abort, the abort is the outcome.
169
+ if (!cancelled && !aborted()) {
170
+ await streamWriter?.abandon();
167
171
  throw error;
172
+ }
168
173
  }
169
174
  finally {
170
175
  timeoutSignal?.removeEventListener('abort', abandon);
176
+ abortSignal?.removeEventListener('abort', abandon);
171
177
  // Tear down the provider stream on early exits (error part, post-cancel break); a no-op after a clean drain.
172
178
  void reader?.cancel().catch(() => { });
173
179
  }
180
+ // Record the abort as the step's failure; replay rethrows it, so the workflow must catch aborts it means to survive.
181
+ if (aborted()) {
182
+ await streamWriter?.end({ aborted: true });
183
+ throw toAbortError(abortSignal.reason);
184
+ }
174
185
  // Give the response a durable id/timestamp when the provider sent none, and emit it live (before the
175
186
  // withheld 'finish') so the SDK sees the same values live and on replay instead of a fresh fallback.
176
187
  // Skip the live emit for a timed-out (abandoned) attempt so it can't interleave with its retry.
177
188
  const responseMetadataPart = accumulator.fillResponseMetadata((0, node_crypto_1.randomUUID)(), new Date());
178
189
  if (responseMetadataPart && !timeoutSignal?.aborted)
179
190
  emit(responseMetadataPart);
180
- return encodeBinaryContent(accumulator.result(streamResult?.request, streamResult?.response));
191
+ const recorded = encodeBinaryContent(accumulator.result(streamResult?.request, streamResult?.response));
192
+ // Every stream write lands before the checkpoint, so a reader that sees the next step has seen all of this one.
193
+ await streamWriter?.end({ finishReason: recorded.finishReason });
194
+ return recorded;
181
195
  }, { ...streamStepConfig, name: stepConfig.name ?? stepName(model, 'stream') });
182
196
  }
183
197
  catch (error) {
184
198
  // runStep can throw synchronously (e.g. a shutdown race); don't leak the guard entry.
185
- releaseGuard();
199
+ abortSignal?.removeEventListener('abort', detach);
200
+ exitDurableModelCall(workflowID);
186
201
  throw error;
187
202
  }
203
+ // Hold the guard until the step has settled, so the next call in this workflow always starts after this checkpoint.
204
+ settled = step.then(() => undefined, () => undefined).then(() => {
205
+ released = true;
206
+ abortSignal?.removeEventListener('abort', detach);
207
+ exitDurableModelCall(workflowID);
208
+ if (settlingModelCalls.get(workflowID) === settled)
209
+ settlingModelCalls.delete(workflowID);
210
+ });
188
211
  // Drive the returned stream from the settled step: a live run emits only the withheld 'finish' (deltas already
189
212
  // streamed); a recovered run synthesizes the whole stream from the checkpoint. Either way consumers finish
190
213
  // only after the result is durable.
191
- void step
192
- .then((recorded) => {
214
+ void step.then((recorded) => {
193
215
  if (cancelled)
194
216
  return;
195
217
  if (executed) {
@@ -206,10 +228,11 @@ function durableCalls(options = {}) {
206
228
  }
207
229
  controller.close();
208
230
  }, (error) => {
209
- if (!cancelled)
210
- controller.error((0, internal_1.restoreAISDKErrorIdentity)(error));
211
- })
212
- .finally(releaseGuard);
231
+ if (cancelled)
232
+ return;
233
+ // Live abort: surface the signal's own reason so the AI SDK takes its abort path; a replayed abort is an ordinary error.
234
+ controller.error(executed && aborted() ? (abortSignal?.reason ?? error) : (0, internal_1.restoreAISDKErrorIdentity)(error));
235
+ });
213
236
  return { stream };
214
237
  },
215
238
  };
@@ -219,12 +242,16 @@ function durableEmbeddingCalls(options = {}) {
219
242
  const stepConfig = (0, internal_1.withErrorClassification)(options);
220
243
  return {
221
244
  specificationVersion: 'v4',
245
+ // embedMany awaits this per call: inside a workflow the batches run sequentially (deterministic step order on replay); elsewhere the model's own answer stands.
246
+ overrideSupportsParallelCalls: ({ model }) => ({
247
+ then: (onfulfilled, onrejected) => Promise.resolve((0, internal_1.isInWorkflowFunction)() ? false : model.supportsParallelCalls).then(onfulfilled, onrejected),
248
+ }),
222
249
  wrapEmbed: async ({ doEmbed, model }) => {
223
250
  (0, internal_1.assertNotInTransaction)('embed');
224
251
  if (!(0, internal_1.isInWorkflowFunction)()) {
225
252
  return await doEmbed();
226
253
  }
227
- const workflowID = enterDurableModelCall('embed');
254
+ const workflowID = await enterDurableModelCall();
228
255
  try {
229
256
  return await dbos_sdk_1.DBOS.runStep(async () => doEmbed(), {
230
257
  ...stepConfig,
@@ -266,6 +293,12 @@ function durableImageCalls(options = {}) {
266
293
  },
267
294
  };
268
295
  }
296
+ // The abort reason as a recordable Error (an AbortSignal's reason may be any value); the name is what the AI SDK's abort checks read.
297
+ function toAbortError(reason) {
298
+ if (reason instanceof Error)
299
+ return reason;
300
+ return Object.assign(new Error(String(reason)), { name: 'AbortError' });
301
+ }
269
302
  /** Convert generated image bytes (Uint8Array) to base64 (spec-allowed) to keep checkpoints compact. */
270
303
  function encodeImageResult(result) {
271
304
  const images = result.images;
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":";;AAyDA,oCAoLC;AAGD,sDAsBC;AAOD,8CAmBC;AAhSD,6CAAyC;AACzC,iDAAsD;AAqBtD,yCAA8H;AA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,CAAC,MAAM,GAAG,CAAC;gBAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;YAClF,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC/E,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YACrC,gIAAgI;YAChI,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YACjE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC;YACxF,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;YACjG,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;YACjD,MAAM,IAAI,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC;QACb,CAAC;IACH,CAAC;IACD,MAAM;QACJ,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { StepConfig } from '@dbos-inc/dbos-sdk';
2
+ import type { ToolSet } from 'ai' with { 'resolution-mode': 'import' };
3
+ export interface DurableToolsOptions extends StepConfig {
4
+ /** Per-tool step config overriding the defaults; `false` leaves that tool non-durable. */
5
+ tools?: Record<string, StepConfig | false>;
6
+ /** Write each tool call's output (or error) to this durable stream from inside its step. */
7
+ durableStream?: string;
8
+ }
9
+ /**
10
+ * Wraps each tool's `execute` so that, inside a workflow, every tool call runs as a durable DBOS step named
11
+ * `<tool>.<toolCallId>` and replays from its checkpoint on recovery; outside a workflow tools run unchanged.
12
+ * Retries are off by default (the AI SDK never retries tools); opt in per tool with `retriesAllowed`.
13
+ */
14
+ export declare function durableTools<TOOLS extends ToolSet>(tools: TOOLS, options?: DurableToolsOptions): TOOLS;
15
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,OAAO,iBAAiB,EAAE,QAAQ,EAAE,CAAC;AAKvE,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,CAAC,CAAC;IAC3C,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,SAAS,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,GAAE,mBAAwB,GAAG,KAAK,CA4D1G"}
package/dist/tools.js ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.durableTools = durableTools;
4
+ const dbos_sdk_1 = require("@dbos-inc/dbos-sdk");
5
+ const internal_1 = require("./internal");
6
+ const agent_tool_1 = require("./agent-tool");
7
+ const durable_stream_1 = require("./durable-stream");
8
+ /**
9
+ * Wraps each tool's `execute` so that, inside a workflow, every tool call runs as a durable DBOS step named
10
+ * `<tool>.<toolCallId>` and replays from its checkpoint on recovery; outside a workflow tools run unchanged.
11
+ * Retries are off by default (the AI SDK never retries tools); opt in per tool with `retriesAllowed`.
12
+ */
13
+ function durableTools(tools, options = {}) {
14
+ const { tools: perTool, durableStream, ...defaults } = options;
15
+ const durable = {};
16
+ for (const [name, definition] of Object.entries(tools)) {
17
+ const override = perTool?.[name];
18
+ // An agent tool is a child workflow, not a step: leave it unwrapped, binding this durable stream to it.
19
+ const bindAgentTool = definition[agent_tool_1.AGENT_TOOL];
20
+ if (bindAgentTool) {
21
+ durable[name] = durableStream ? bindAgentTool(durableStream) : definition;
22
+ continue;
23
+ }
24
+ if (typeof definition.execute !== 'function' || override === false) {
25
+ durable[name] = definition;
26
+ continue;
27
+ }
28
+ const execute = definition.execute;
29
+ const merged = { ...defaults, ...override };
30
+ // Default classification (aborts and provider-declared non-retryable errors are terminal), but retries stay opt-in.
31
+ const stepConfig = { ...(0, internal_1.withErrorClassification)(merged), retriesAllowed: merged.retriesAllowed ?? false };
32
+ const prefix = stepConfig.name ?? name;
33
+ durable[name] = {
34
+ ...definition,
35
+ execute: (input, execOptions) => {
36
+ (0, internal_1.assertNotInTransaction)(name);
37
+ if (!(0, internal_1.isInWorkflowFunction)())
38
+ return execute(input, execOptions);
39
+ const signal = execOptions.abortSignal;
40
+ // An aborted call is done whatever the failure looks like; a retry would re-run a cancelled side effect.
41
+ const callConfig = {
42
+ ...stepConfig,
43
+ shouldRetry: async (error) => !signal?.aborted && (await stepConfig.shouldRetry(error)),
44
+ };
45
+ // The tool call id comes from the checkpointed model result, so a reordered parallel step fails replay instead of swapping results.
46
+ return (0, internal_1.runDurableStep)(`${prefix}.${execOptions.toolCallId}`, async () => {
47
+ // A timed-out attempt is abandoned by DBOS but keeps running; forward its signal so the tool stops too.
48
+ const timeoutSignal = dbos_sdk_1.DBOS.stepStatus?.timeoutSignal;
49
+ const abortSignal = timeoutSignal && signal ? AbortSignal.any([signal, timeoutSignal]) : (timeoutSignal ?? signal);
50
+ let output;
51
+ try {
52
+ output = await execute(input, abortSignal === signal ? execOptions : { ...execOptions, abortSignal });
53
+ // A streaming execute can't checkpoint mid-flight; drain it and record the final value (the last yield).
54
+ if ((0, internal_1.isAsyncIterable)(output)) {
55
+ let last;
56
+ for await (last of output)
57
+ ;
58
+ output = last;
59
+ }
60
+ }
61
+ catch (error) {
62
+ if (durableStream)
63
+ await (0, durable_stream_1.writeToolRecord)(durableStream, execOptions.toolCallId, { errorText: errorMessage(error) });
64
+ throw error;
65
+ }
66
+ if (durableStream)
67
+ await (0, durable_stream_1.writeToolRecord)(durableStream, execOptions.toolCallId, { output });
68
+ return output;
69
+ }, callConfig);
70
+ },
71
+ };
72
+ }
73
+ return durable;
74
+ }
75
+ function errorMessage(error) {
76
+ return error instanceof Error ? error.message : String(error);
77
+ }
78
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":";;AAqBA,oCA4DC;AAjFD,iDAAsD;AAEtD,yCAAoI;AACpI,6CAA0C;AAC1C,qDAAmD;AAYnD;;;;GAIG;AACH,SAAgB,YAAY,CAAwB,KAAY,EAAE,UAA+B,EAAE;IACjG,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC/D,MAAM,OAAO,GAAY,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvD,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;QACjC,wGAAwG;QACxG,MAAM,aAAa,GAAI,UAAkE,CAAC,uBAAU,CAAC,CAAC;QACtG,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;YAC1E,SAAS;QACX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/vercel-ai",
3
- "version": "0.2.5",
3
+ "version": "0.3.7",
4
4
  "description": "DBOS durable execution integration for the Vercel AI SDK",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -0,0 +1,122 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { DBOS } from '@dbos-inc/dbos-sdk';
3
+ import type { FlexibleSchema, ModelMessage, Tool } from 'ai' with { 'resolution-mode': 'import' };
4
+ import { writeDurableStream, writeToolRecord } from './durable-stream';
5
+ import { isInWorkflowFunction } from './internal';
6
+
7
+ /** Marks a tool built by agentTool: durableTools leaves it unwrapped (it is a child workflow, not a step) and binds its durable stream. */
8
+ export const AGENT_TOOL: unique symbol = Symbol.for('@dbos-inc/vercel-ai/agentTool');
9
+
10
+ // Captured at module load, outside any workflow: a cancellation triggered by an abort must not claim a function id in the parent's log.
11
+ const outsideWorkflow = AsyncLocalStorage.snapshot();
12
+
13
+ // The child's row appears shortly after the call starts and a cancel of a missing row is a no-op, so wait for it, giving up once the call has settled.
14
+ async function cancelChild(childID: string, settled: () => boolean): Promise<void> {
15
+ for (let i = 0; i < 100 && !settled(); i++) {
16
+ if (await DBOS.getWorkflowStatus(childID)) {
17
+ // The child's own sub-agents are its children; without the cascade they would run on with nobody awaiting them.
18
+ await DBOS.cancelWorkflow(childID, { cancelChildren: true });
19
+ return;
20
+ }
21
+ await new Promise((resolve) => setTimeout(resolve, 50));
22
+ }
23
+ }
24
+
25
+ // What agentTool needs from an agent: the AI SDK's Agent interface, structurally.
26
+ type StreamingAgent = {
27
+ stream(options: { prompt: string } | { messages: ModelMessage[] }): PromiseLike<{ consumeStream(): PromiseLike<void>; readonly text: PromiseLike<string> }>;
28
+ };
29
+
30
+ export interface AgentToolOptions<INPUT, AGENT extends StreamingAgent, OUTPUT> {
31
+ /** Name of the child workflow; must be unique. */
32
+ name: string;
33
+ description: string;
34
+ inputSchema: FlexibleSchema<INPUT>;
35
+ agent: AGENT;
36
+ /** Turns the tool's input into the sub-agent's prompt. */
37
+ prompt: (input: INPUT) => string | ModelMessage[];
38
+ /** Turns the sub-agent's result into the tool's output (default: its final text); must be serializable. */
39
+ output?: (result: Awaited<ReturnType<AGENT['stream']>>) => OUTPUT | Promise<OUTPUT>;
40
+ /** Record the call in this durable stream: a `data-dbos-subagent` part naming the child workflow, then its output. */
41
+ durableStream?: string;
42
+ /** Name of a DBOS queue to run each child on, e.g. to bound how many sub-agents run at once. */
43
+ queue?: string;
44
+ /** Workflow timeout for each child. */
45
+ timeoutMS?: number;
46
+ }
47
+
48
+ export type AgentTool<INPUT, OUTPUT> = Tool<INPUT, OUTPUT> & {
49
+ /** The registered child workflow; call it directly to run the sub-agent without a model in the loop. */
50
+ workflow: (input: INPUT) => Promise<OUTPUT>;
51
+ };
52
+
53
+ /**
54
+ * Wraps an agent as a tool whose every call runs as a child workflow: durable at model-call granularity, with its own
55
+ * concurrency guard, safe to call in parallel, and visible as a child in the parent's step list. Call it at module load,
56
+ * before `DBOS.launch()`, since it registers the child workflow.
57
+ */
58
+ export function agentTool<INPUT, AGENT extends StreamingAgent, OUTPUT = string>(
59
+ options: AgentToolOptions<INPUT, AGENT, OUTPUT>,
60
+ ): AgentTool<INPUT, OUTPUT> {
61
+ const { name, agent, prompt, output } = options;
62
+ const run = async (input: INPUT): Promise<OUTPUT> => {
63
+ const request = prompt(input);
64
+ // stream, not generate: only streamed calls write to a durable stream.
65
+ const result = await agent.stream(typeof request === 'string' ? { prompt: request } : { messages: request });
66
+ await result.consumeStream();
67
+ return output ? await output(result as Awaited<ReturnType<AGENT['stream']>>) : ((await result.text) as OUTPUT);
68
+ };
69
+ const registered = DBOS.registerWorkflow(run, { name });
70
+ // Unbound on purpose: DBOS's registered invoker reads `this`, and as a method `this` would be the tool object.
71
+ const workflow = (input: INPUT): Promise<OUTPUT> => registered(input);
72
+ return build(options, registered, workflow, options.durableStream);
73
+ }
74
+
75
+ function build<INPUT, AGENT extends StreamingAgent, OUTPUT>(
76
+ options: AgentToolOptions<INPUT, AGENT, OUTPUT>,
77
+ registered: (input: INPUT) => Promise<OUTPUT>,
78
+ workflow: (input: INPUT) => Promise<OUTPUT>,
79
+ durableStream: string | undefined,
80
+ ): AgentTool<INPUT, OUTPUT> {
81
+ const { name, description, inputSchema, queue, timeoutMS } = options;
82
+ const execute = async (input: INPUT, execOptions: { toolCallId: string; abortSignal?: AbortSignal }): Promise<OUTPUT> => {
83
+ if (!isInWorkflowFunction()) return workflow(input);
84
+ const { toolCallId } = execOptions;
85
+ // The tool call id comes from the checkpointed model output, so the child id is the same on replay and known for cancellation.
86
+ const childID = `${DBOS.workflowID}-${toolCallId}`;
87
+ // Start and getResult each reserve their function id synchronously here, so parallel calls replay in order.
88
+ const started = DBOS.startWorkflow(registered, { workflowID: childID, queueName: queue, timeoutMS })(input);
89
+ const pending = DBOS.getResult<OUTPUT>(childID);
90
+ started.catch(() => {});
91
+ pending.catch(() => {});
92
+ let settled = false;
93
+ const cancel = () => void outsideWorkflow(() => cancelChild(childID, () => settled)).catch(() => {});
94
+ execOptions.abortSignal?.addEventListener('abort', cancel, { once: true });
95
+ if (execOptions.abortSignal?.aborted) cancel();
96
+ try {
97
+ if (durableStream) {
98
+ await writeDurableStream(durableStream, [
99
+ { type: 'data-dbos-subagent', id: toolCallId, data: { toolCallId, workflowID: childID, name } },
100
+ ]);
101
+ }
102
+ await started;
103
+ const result = (await pending) as OUTPUT;
104
+ // A tool record, not a raw chunk, so the reader masks a sub-agent's error text like any other tool's.
105
+ if (durableStream) await writeToolRecord(durableStream, toolCallId, { output: result });
106
+ return result;
107
+ } catch (error) {
108
+ if (durableStream) await writeToolRecord(durableStream, toolCallId, { errorText: error instanceof Error ? error.message : String(error) });
109
+ throw error;
110
+ } finally {
111
+ settled = true;
112
+ execOptions.abortSignal?.removeEventListener('abort', cancel);
113
+ }
114
+ };
115
+ return {
116
+ description,
117
+ inputSchema,
118
+ execute,
119
+ workflow,
120
+ [AGENT_TOOL]: (key: string) => build(options, registered, workflow, key),
121
+ } as unknown as AgentTool<INPUT, OUTPUT>;
122
+ }