@mastra/react 0.2.6-alpha.0 → 0.2.7-alpha.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 (23) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{chunk-REDZDNFN-TfJ4yMVk.js → chunk-REDZDNFN-B3BKm5Q3.js} +2 -2
  3. package/dist/{chunk-REDZDNFN-TfJ4yMVk.js.map → chunk-REDZDNFN-B3BKm5Q3.js.map} +1 -1
  4. package/dist/{chunk-REDZDNFN-C4VwKzrd.cjs → chunk-REDZDNFN-B6_m0Vw5.cjs} +2 -2
  5. package/dist/{chunk-REDZDNFN-C4VwKzrd.cjs.map → chunk-REDZDNFN-B6_m0Vw5.cjs.map} +1 -1
  6. package/dist/{index-CU6GBOIY.cjs → index-0ViTRi6s.cjs} +1449 -1345
  7. package/dist/index-0ViTRi6s.cjs.map +1 -0
  8. package/dist/{index-DKjW1068.js → index-D3vBmpgO.js} +1449 -1345
  9. package/dist/index-D3vBmpgO.js.map +1 -0
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/src/lib/ai-sdk/types.d.ts +9 -0
  13. package/dist/{token-6GSAFR2W-XRCSVUPZ-C2rqLNj8.cjs → token-6GSAFR2W-XRCSVUPZ-DHFPWxwn.cjs} +3 -3
  14. package/dist/{token-6GSAFR2W-XRCSVUPZ-C2rqLNj8.cjs.map → token-6GSAFR2W-XRCSVUPZ-DHFPWxwn.cjs.map} +1 -1
  15. package/dist/{token-6GSAFR2W-XRCSVUPZ-Cgcu7avO.js → token-6GSAFR2W-XRCSVUPZ-PJRK45Cx.js} +3 -3
  16. package/dist/{token-6GSAFR2W-XRCSVUPZ-Cgcu7avO.js.map → token-6GSAFR2W-XRCSVUPZ-PJRK45Cx.js.map} +1 -1
  17. package/dist/{token-util-NEHG7TUY-U7CX7GS4-C59wA2lQ.cjs → token-util-NEHG7TUY-U7CX7GS4-B0wfFQ5e.cjs} +2 -2
  18. package/dist/{token-util-NEHG7TUY-U7CX7GS4-C59wA2lQ.cjs.map → token-util-NEHG7TUY-U7CX7GS4-B0wfFQ5e.cjs.map} +1 -1
  19. package/dist/{token-util-NEHG7TUY-U7CX7GS4-jJSXEovt.js → token-util-NEHG7TUY-U7CX7GS4-C_BDhp1r.js} +2 -2
  20. package/dist/{token-util-NEHG7TUY-U7CX7GS4-jJSXEovt.js.map → token-util-NEHG7TUY-U7CX7GS4-C_BDhp1r.js.map} +1 -1
  21. package/package.json +3 -3
  22. package/dist/index-CU6GBOIY.cjs.map +0 -1
  23. package/dist/index-DKjW1068.js.map +0 -1
@@ -31,1163 +31,347 @@ const MastraReactProvider = ({ children, baseUrl, headers, apiPrefix }) => {
31
31
  return /* @__PURE__ */ jsx(MastraClientProvider, { baseUrl, headers, apiPrefix, children });
32
32
  };
33
33
 
34
- const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
35
- if (chunk.type === "workflow-start") {
36
- return {
37
- input: prev?.input,
38
- status: "running",
39
- steps: prev?.steps || {}
40
- };
34
+ // src/request-context/index.ts
35
+ var RequestContext = class {
36
+ registry = /* @__PURE__ */ new Map();
37
+ constructor(iterable) {
38
+ this.registry = new Map(iterable);
41
39
  }
42
- if (chunk.type === "workflow-canceled") {
43
- return {
44
- ...prev,
45
- status: "canceled"
46
- };
40
+ /**
41
+ * set a value with strict typing if `Values` is a Record and the key exists in it.
42
+ */
43
+ set(key, value) {
44
+ this.registry.set(key, value);
47
45
  }
48
- if (chunk.type === "workflow-finish") {
49
- const finalStatus = chunk.payload.workflowStatus;
50
- const prevSteps = prev?.steps ?? {};
51
- const lastStep = Object.values(prevSteps).pop();
52
- return {
53
- ...prev,
54
- status: chunk.payload.workflowStatus,
55
- ...finalStatus === "success" && lastStep?.status === "success" ? { result: lastStep?.output } : finalStatus === "failed" && lastStep?.status === "failed" ? { error: lastStep?.error } : finalStatus === "tripwire" && chunk.payload.tripwire ? { tripwire: chunk.payload.tripwire } : {}
56
- };
46
+ /**
47
+ * Get a value with its type
48
+ */
49
+ get(key) {
50
+ return this.registry.get(key);
57
51
  }
58
- const { stepCallId, stepName, ...newPayload } = chunk.payload ?? {};
59
- const newSteps = {
60
- ...prev?.steps,
61
- [chunk.payload.id]: {
62
- ...prev?.steps?.[chunk.payload.id],
63
- ...newPayload
64
- }
65
- };
66
- if (chunk.type === "workflow-step-start") {
67
- return {
68
- ...prev,
69
- steps: newSteps
70
- };
52
+ /**
53
+ * Check if a key exists in the container
54
+ */
55
+ has(key) {
56
+ return this.registry.has(key);
71
57
  }
72
- if (chunk.type === "workflow-step-suspended") {
73
- const suspendedStepIds = Object.entries(newSteps).flatMap(
74
- ([stepId, stepResult]) => {
75
- if (stepResult?.status === "suspended") {
76
- const nestedPath = stepResult?.suspendPayload?.__workflow_meta?.path;
77
- return nestedPath ? [[stepId, ...nestedPath]] : [[stepId]];
78
- }
79
- return [];
80
- }
81
- );
82
- return {
83
- ...prev,
84
- status: "suspended",
85
- steps: newSteps,
86
- suspendPayload: chunk.payload.suspendPayload,
87
- suspended: suspendedStepIds
88
- };
58
+ /**
59
+ * Delete a value by key
60
+ */
61
+ delete(key) {
62
+ return this.registry.delete(key);
89
63
  }
90
- if (chunk.type === "workflow-step-waiting") {
91
- return {
92
- ...prev,
93
- status: "waiting",
94
- steps: newSteps
95
- };
64
+ /**
65
+ * Clear all values from the container
66
+ */
67
+ clear() {
68
+ this.registry.clear();
96
69
  }
97
- if (chunk.type === "workflow-step-progress") {
98
- const progressSteps = {
99
- ...prev?.steps,
100
- [chunk.payload.id]: {
101
- ...prev?.steps?.[chunk.payload.id],
102
- foreachProgress: {
103
- completedCount: chunk.payload.completedCount,
104
- totalCount: chunk.payload.totalCount,
105
- currentIndex: chunk.payload.currentIndex,
106
- iterationStatus: chunk.payload.iterationStatus,
107
- iterationOutput: chunk.payload.iterationOutput
108
- }
109
- }
110
- };
111
- return {
112
- ...prev,
113
- steps: progressSteps
114
- };
70
+ /**
71
+ * Get all keys in the container
72
+ */
73
+ keys() {
74
+ return this.registry.keys();
115
75
  }
116
- if (chunk.type === "workflow-step-result") {
117
- return {
118
- ...prev,
119
- steps: newSteps
120
- };
76
+ /**
77
+ * Get all values in the container
78
+ */
79
+ values() {
80
+ return this.registry.values();
121
81
  }
122
- return prev;
123
- };
124
- const toUIMessage = ({ chunk, conversation, metadata }) => {
125
- const result = [...conversation];
126
- if (chunk.type.startsWith("data-")) {
127
- const lastMessage = result[result.length - 1];
128
- if (!lastMessage || lastMessage.role !== "assistant") {
129
- const newMessage = {
130
- id: `data-${chunk.runId}-${Date.now()}`,
131
- role: "assistant",
132
- parts: [
133
- {
134
- type: chunk.type,
135
- data: "data" in chunk ? chunk.data : void 0
136
- }
137
- ],
138
- metadata
139
- };
140
- return [...result, newMessage];
141
- }
142
- const updatedMessage = {
143
- ...lastMessage,
144
- parts: [
145
- ...lastMessage.parts,
146
- {
147
- type: chunk.type,
148
- data: "data" in chunk ? chunk.data : void 0
149
- }
150
- ]
151
- };
152
- return [...result.slice(0, -1), updatedMessage];
82
+ /**
83
+ * Get all entries in the container.
84
+ * Returns a discriminated union of tuples for proper type narrowing when iterating.
85
+ */
86
+ entries() {
87
+ return this.registry.entries();
153
88
  }
154
- switch (chunk.type) {
155
- case "tripwire": {
156
- const newMessage = {
157
- id: `tripwire-${chunk.runId + Date.now()}`,
158
- role: "assistant",
159
- parts: [
160
- {
161
- type: "text",
162
- text: chunk.payload.reason
163
- }
164
- ],
165
- metadata: {
166
- ...metadata,
167
- status: "tripwire",
168
- tripwire: {
169
- retry: chunk.payload.retry,
170
- tripwirePayload: chunk.payload.metadata,
171
- processorId: chunk.payload.processorId
172
- }
173
- }
174
- };
175
- return [...result, newMessage];
176
- }
177
- case "start": {
178
- const newMessage = {
179
- id: typeof chunk.payload.messageId === "string" ? chunk.payload.messageId : `start-${chunk.runId + Date.now()}`,
180
- role: "assistant",
181
- parts: [],
182
- metadata
183
- };
184
- return [...result, newMessage];
89
+ /**
90
+ * Get the size of the container
91
+ */
92
+ size() {
93
+ return this.registry.size;
94
+ }
95
+ /**
96
+ * Execute a function for each entry in the container.
97
+ * The callback receives properly typed key-value pairs.
98
+ */
99
+ forEach(callbackfn) {
100
+ this.registry.forEach(callbackfn);
101
+ }
102
+ /**
103
+ * Custom JSON serialization method.
104
+ * Converts the internal Map to a plain object for proper JSON serialization.
105
+ * Non-serializable values (e.g., RPC proxies, functions, circular references)
106
+ * are skipped to prevent serialization errors when storing to database.
107
+ */
108
+ toJSON() {
109
+ const result = {};
110
+ for (const [key, value] of this.registry.entries()) {
111
+ if (this.isSerializable(value)) {
112
+ result[key] = value;
113
+ }
185
114
  }
186
- case "text-start": {
187
- const lastMessage = result[result.length - 1];
188
- if (!lastMessage || lastMessage.role !== "assistant") return result;
189
- const parts = [...lastMessage.parts];
190
- const textId = chunk.payload.id || `text-${Date.now()}`;
191
- const newTextPart = {
192
- type: "text",
193
- text: "",
194
- state: "streaming",
195
- textId,
196
- providerMetadata: chunk.payload.providerMetadata
197
- };
198
- parts.push(newTextPart);
199
- return [
200
- ...result.slice(0, -1),
201
- {
202
- ...lastMessage,
203
- parts
204
- }
205
- ];
115
+ return result;
116
+ }
117
+ /**
118
+ * Check if a value can be safely serialized to JSON.
119
+ */
120
+ isSerializable(value) {
121
+ if (value === null || value === void 0) return true;
122
+ if (typeof value === "function") return false;
123
+ if (typeof value === "symbol") return false;
124
+ if (typeof value !== "object") return true;
125
+ try {
126
+ JSON.stringify(value);
127
+ return true;
128
+ } catch {
129
+ return false;
206
130
  }
207
- case "text-delta": {
208
- const lastMessage = result[result.length - 1];
209
- if (!lastMessage || lastMessage.role !== "assistant") return result;
210
- const parts = [...lastMessage.parts];
211
- const textId = chunk.payload.id;
212
- let textPartIndex = textId ? parts.findLastIndex((part) => part.type === "text" && part.textId === textId) : -1;
213
- if (textPartIndex === -1) {
214
- textPartIndex = parts.findLastIndex(
215
- (part) => part.type === "text" && part.state === "streaming"
216
- );
217
- }
218
- if (textPartIndex === -1) {
219
- const newTextPart = {
220
- type: "text",
221
- text: chunk.payload.text,
222
- state: "streaming",
223
- textId,
224
- providerMetadata: chunk.payload.providerMetadata
225
- };
226
- parts.push(newTextPart);
227
- } else {
228
- const textPart = parts[textPartIndex];
229
- if (textPart.type === "text") {
230
- const extendedTextPart = textPart;
231
- const updatedTextPart = {
232
- ...extendedTextPart,
233
- text: extendedTextPart.text + chunk.payload.text,
234
- state: "streaming"
235
- };
236
- parts[textPartIndex] = updatedTextPart;
237
- }
238
- }
239
- return [
240
- ...result.slice(0, -1),
241
- {
242
- ...lastMessage,
243
- parts
244
- }
245
- ];
246
- }
247
- case "reasoning-delta": {
248
- const lastMessage = result[result.length - 1];
249
- if (!lastMessage || lastMessage.role !== "assistant") {
250
- const newMessage = {
251
- id: `reasoning-${chunk.runId + Date.now()}`,
252
- role: "assistant",
253
- parts: [
254
- {
255
- type: "reasoning",
256
- text: chunk.payload.text,
257
- state: "streaming",
258
- providerMetadata: chunk.payload.providerMetadata
259
- }
260
- ],
261
- metadata
262
- };
263
- return [...result, newMessage];
131
+ }
132
+ /**
133
+ * Get all values as a typed object for destructuring.
134
+ * Returns Record<string, any> when untyped, or the Values type when typed.
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * const ctx = new RequestContext<{ userId: string; apiKey: string }>();
139
+ * ctx.set('userId', 'user-123');
140
+ * ctx.set('apiKey', 'key-456');
141
+ * const { userId, apiKey } = ctx.all;
142
+ * ```
143
+ */
144
+ get all() {
145
+ return Object.fromEntries(this.registry);
146
+ }
147
+ };
148
+
149
+ function getDefaultExportFromCjs (x) {
150
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
151
+ }
152
+
153
+ var __create$4 = Object.create;
154
+ var __defProp$6 = Object.defineProperty;
155
+ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
156
+ var __getOwnPropNames$4 = Object.getOwnPropertyNames;
157
+ var __getProtoOf$4 = Object.getPrototypeOf;
158
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
159
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
160
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
161
+ }) : x)(function(x) {
162
+ if (typeof require !== "undefined") return require.apply(this, arguments);
163
+ throw Error('Dynamic require of "' + x + '" is not supported');
164
+ });
165
+ var __commonJS$4 = (cb, mod) => function __require2() {
166
+ return mod || (0, cb[__getOwnPropNames$4(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
167
+ };
168
+ var __copyProps$4 = (to, from, except, desc) => {
169
+ if (from && typeof from === "object" || typeof from === "function") {
170
+ for (let key of __getOwnPropNames$4(from))
171
+ if (!__hasOwnProp$4.call(to, key) && key !== except)
172
+ __defProp$6(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc$4(from, key)) || desc.enumerable });
173
+ }
174
+ return to;
175
+ };
176
+ var __toESM$3 = (mod, isNodeMode, target) => (target = mod != null ? __create$4(__getProtoOf$4(mod)) : {}, __copyProps$4(
177
+ // If the importer is in node compatibility mode or this is not an ESM
178
+ // file that has been converted to a CommonJS file using a Babel-
179
+ // compatible transform (i.e. "__esModule" has not been set), then set
180
+ // "default" to the CommonJS "module.exports" for node compatibility.
181
+ __defProp$6(target, "default", { value: mod, enumerable: true }) ,
182
+ mod
183
+ ));
184
+
185
+ // ../_vendored/ai_v5/dist/chunk-7D4SUZUM.js
186
+ var __create$3 = Object.create;
187
+ var __defProp$5 = Object.defineProperty;
188
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
189
+ var __getOwnPropNames$3 = Object.getOwnPropertyNames;
190
+ var __getProtoOf$3 = Object.getPrototypeOf;
191
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
192
+ var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
193
+ get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
194
+ }) : x)(function(x) {
195
+ if (typeof __require !== "undefined") return __require.apply(this, arguments);
196
+ throw Error('Dynamic require of "' + x + '" is not supported');
197
+ });
198
+ var __commonJS$3 = (cb, mod) => function __require22() {
199
+ return mod || (0, cb[__getOwnPropNames$3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
200
+ };
201
+ var __copyProps$3 = (to, from, except, desc) => {
202
+ if (from && typeof from === "object" || typeof from === "function") {
203
+ for (let key of __getOwnPropNames$3(from))
204
+ if (!__hasOwnProp$3.call(to, key) && key !== except)
205
+ __defProp$5(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc$3(from, key)) || desc.enumerable });
206
+ }
207
+ return to;
208
+ };
209
+ var __toESM$2 = (mod, isNodeMode, target) => (target = mod != null ? __create$3(__getProtoOf$3(mod)) : {}, __copyProps$3(
210
+ // If the importer is in node compatibility mode or this is not an ESM
211
+ // file that has been converted to a CommonJS file using a Babel-
212
+ // compatible transform (i.e. "__esModule" has not been set), then set
213
+ // "default" to the CommonJS "module.exports" for node compatibility.
214
+ __defProp$5(target, "default", { value: mod, enumerable: true }) ,
215
+ mod
216
+ ));
217
+
218
+ // ../_vendored/ai_v5/dist/chunk-TLQKI65U.js
219
+ var require_token_error = __commonJS$3({
220
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-error.js"(exports$1, module) {
221
+ var __defProp2 = Object.defineProperty;
222
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
223
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
224
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
225
+ var __export = (target, all) => {
226
+ for (var name in all)
227
+ __defProp2(target, name, { get: all[name], enumerable: true });
228
+ };
229
+ var __copyProps2 = (to, from, except, desc) => {
230
+ if (from && typeof from === "object" || typeof from === "function") {
231
+ for (let key of __getOwnPropNames2(from))
232
+ if (!__hasOwnProp2.call(to, key) && key !== except)
233
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
264
234
  }
265
- const parts = [...lastMessage.parts];
266
- let reasoningPartIndex = parts.findIndex((part) => part.type === "reasoning");
267
- if (reasoningPartIndex === -1) {
268
- parts.push({
269
- type: "reasoning",
270
- text: chunk.payload.text,
271
- state: "streaming",
272
- providerMetadata: chunk.payload.providerMetadata
273
- });
274
- } else {
275
- const reasoningPart = parts[reasoningPartIndex];
276
- if (reasoningPart.type === "reasoning") {
277
- parts[reasoningPartIndex] = {
278
- ...reasoningPart,
279
- text: reasoningPart.text + chunk.payload.text,
280
- state: "streaming"
281
- };
282
- }
235
+ return to;
236
+ };
237
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
238
+ var token_error_exports = {};
239
+ __export(token_error_exports, {
240
+ VercelOidcTokenError: () => VercelOidcTokenError
241
+ });
242
+ module.exports = __toCommonJS(token_error_exports);
243
+ var VercelOidcTokenError = class extends Error {
244
+ constructor(message, cause) {
245
+ super(message);
246
+ this.name = "VercelOidcTokenError";
247
+ this.cause = cause;
283
248
  }
284
- return [
285
- ...result.slice(0, -1),
286
- {
287
- ...lastMessage,
288
- parts
249
+ toString() {
250
+ if (this.cause) {
251
+ return `${this.name}: ${this.message}: ${this.cause}`;
289
252
  }
290
- ];
291
- }
292
- case "tool-call": {
293
- const lastMessage = result[result.length - 1];
294
- if (!lastMessage || lastMessage.role !== "assistant") {
295
- const newMessage = {
296
- id: `tool-call-${chunk.runId + Date.now()}`,
297
- role: "assistant",
298
- parts: [
299
- {
300
- type: "dynamic-tool",
301
- toolName: chunk.payload.toolName,
302
- toolCallId: chunk.payload.toolCallId,
303
- state: "input-available",
304
- input: chunk.payload.args,
305
- callProviderMetadata: chunk.payload.providerMetadata
306
- }
307
- ],
308
- metadata
309
- };
310
- return [...result, newMessage];
311
- }
312
- const parts = [...lastMessage.parts];
313
- parts.push({
314
- type: "dynamic-tool",
315
- toolName: chunk.payload.toolName,
316
- toolCallId: chunk.payload.toolCallId,
317
- state: "input-available",
318
- input: chunk.payload.args,
319
- callProviderMetadata: chunk.payload.providerMetadata
320
- });
321
- return [
322
- ...result.slice(0, -1),
323
- {
324
- ...lastMessage,
325
- parts
326
- }
327
- ];
328
- }
329
- case "tool-error":
330
- case "tool-result": {
331
- const lastMessage = result[result.length - 1];
332
- if (!lastMessage || lastMessage.role !== "assistant") return result;
333
- const parts = [...lastMessage.parts];
334
- const toolPartIndex = parts.findIndex(
335
- (part) => (part.type === "dynamic-tool" || typeof part.type === "string" && part.type.startsWith("tool-")) && "toolCallId" in part && part.toolCallId === chunk.payload.toolCallId
336
- );
337
- if (toolPartIndex !== -1) {
338
- const toolPart = parts[toolPartIndex];
339
- if (toolPart.type === "dynamic-tool" || typeof toolPart.type === "string" && toolPart.type.startsWith("tool-")) {
340
- const toolName = "toolName" in toolPart && typeof toolPart.toolName === "string" ? toolPart.toolName : toolPart.type.startsWith("tool-") ? toolPart.type.substring(5) : "";
341
- const toolCallId = toolPart.toolCallId;
342
- if (chunk.type === "tool-result" && chunk.payload.isError || chunk.type === "tool-error") {
343
- const error = chunk.type === "tool-error" ? chunk.payload.error : chunk.payload.result;
344
- parts[toolPartIndex] = {
345
- type: "dynamic-tool",
346
- toolName,
347
- toolCallId,
348
- state: "output-error",
349
- input: toolPart.input,
350
- errorText: typeof error === "string" ? error : error instanceof Error ? error.message : error?.message ?? String(error),
351
- callProviderMetadata: chunk.payload.providerMetadata
352
- };
353
- } else {
354
- const isWorkflow = Boolean(chunk.payload.result?.result?.steps);
355
- const isAgent = chunk?.from === "AGENT";
356
- let output;
357
- if (isWorkflow) {
358
- output = chunk.payload.result?.result;
359
- } else if (isAgent) {
360
- output = parts[toolPartIndex].output ?? chunk.payload.result;
361
- } else {
362
- output = chunk.payload.result;
363
- }
364
- parts[toolPartIndex] = {
365
- type: "dynamic-tool",
366
- toolName,
367
- toolCallId,
368
- state: "output-available",
369
- input: toolPart.input,
370
- output,
371
- callProviderMetadata: chunk.payload.providerMetadata
372
- };
373
- }
374
- }
375
- }
376
- return [
377
- ...result.slice(0, -1),
378
- {
379
- ...lastMessage,
380
- parts
381
- }
382
- ];
383
- }
384
- case "tool-output": {
385
- const lastMessage = result[result.length - 1];
386
- if (!lastMessage || lastMessage.role !== "assistant") return result;
387
- const parts = [...lastMessage.parts];
388
- const toolPartIndex = parts.findIndex(
389
- (part) => (part.type === "dynamic-tool" || typeof part.type === "string" && part.type.startsWith("tool-")) && "toolCallId" in part && part.toolCallId === chunk.payload.toolCallId
390
- );
391
- if (toolPartIndex !== -1) {
392
- const toolPart = parts[toolPartIndex];
393
- if (toolPart.type === "dynamic-tool" || typeof toolPart.type === "string" && toolPart.type.startsWith("tool-")) {
394
- const toolName = "toolName" in toolPart && typeof toolPart.toolName === "string" ? toolPart.toolName : typeof toolPart.type === "string" && toolPart.type.startsWith("tool-") ? toolPart.type.substring(5) : "";
395
- const toolCallId = toolPart.toolCallId;
396
- const input = toolPart.input;
397
- if (chunk.payload.output?.type?.startsWith("workflow-")) {
398
- const existingWorkflowState = toolPart.output || {};
399
- const updatedWorkflowState = mapWorkflowStreamChunkToWatchResult(
400
- existingWorkflowState,
401
- chunk.payload.output
402
- );
403
- parts[toolPartIndex] = {
404
- type: "dynamic-tool",
405
- toolName,
406
- toolCallId,
407
- state: "input-streaming",
408
- input,
409
- output: updatedWorkflowState
410
- };
411
- } else if (chunk.payload.output?.from === "AGENT" || chunk.payload.output?.from === "USER" && chunk.payload.output?.payload?.output?.type?.startsWith("workflow-")) {
412
- return toUIMessageFromAgent(chunk.payload.output, conversation);
413
- } else {
414
- const currentOutput = toolPart.output || [];
415
- const existingOutput = Array.isArray(currentOutput) ? currentOutput : [];
416
- parts[toolPartIndex] = {
417
- type: "dynamic-tool",
418
- toolName,
419
- toolCallId,
420
- state: "input-streaming",
421
- input,
422
- output: [...existingOutput, chunk.payload.output]
423
- };
424
- }
425
- }
426
- }
427
- return [
428
- ...result.slice(0, -1),
429
- {
430
- ...lastMessage,
431
- parts
432
- }
433
- ];
434
- }
435
- case "source": {
436
- const lastMessage = result[result.length - 1];
437
- if (!lastMessage || lastMessage.role !== "assistant") return result;
438
- const parts = [...lastMessage.parts];
439
- if (chunk.payload.sourceType === "url") {
440
- parts.push({
441
- type: "source-url",
442
- sourceId: chunk.payload.id,
443
- url: chunk.payload.url || "",
444
- title: chunk.payload.title,
445
- providerMetadata: chunk.payload.providerMetadata
446
- });
447
- } else if (chunk.payload.sourceType === "document") {
448
- parts.push({
449
- type: "source-document",
450
- sourceId: chunk.payload.id,
451
- mediaType: chunk.payload.mimeType || "application/octet-stream",
452
- title: chunk.payload.title,
453
- filename: chunk.payload.filename,
454
- providerMetadata: chunk.payload.providerMetadata
455
- });
456
- }
457
- return [
458
- ...result.slice(0, -1),
459
- {
460
- ...lastMessage,
461
- parts
462
- }
463
- ];
464
- }
465
- case "file": {
466
- const lastMessage = result[result.length - 1];
467
- if (!lastMessage || lastMessage.role !== "assistant") return result;
468
- const parts = [...lastMessage.parts];
469
- let url;
470
- if (typeof chunk.payload.data === "string") {
471
- url = chunk.payload.base64 ? `data:${chunk.payload.mimeType};base64,${chunk.payload.data}` : `data:${chunk.payload.mimeType},${encodeURIComponent(chunk.payload.data)}`;
472
- } else {
473
- const base64 = btoa(String.fromCharCode(...chunk.payload.data));
474
- url = `data:${chunk.payload.mimeType};base64,${base64}`;
475
- }
476
- parts.push({
477
- type: "file",
478
- mediaType: chunk.payload.mimeType,
479
- url,
480
- providerMetadata: chunk.payload.providerMetadata
481
- });
482
- return [
483
- ...result.slice(0, -1),
484
- {
485
- ...lastMessage,
486
- parts
487
- }
488
- ];
489
- }
490
- case "tool-call-approval": {
491
- const lastMessage = result[result.length - 1];
492
- if (!lastMessage || lastMessage.role !== "assistant") return result;
493
- const lastRequireApprovalMetadata = lastMessage.metadata?.mode === "stream" ? lastMessage.metadata?.requireApprovalMetadata : {};
494
- return [
495
- ...result.slice(0, -1),
496
- {
497
- ...lastMessage,
498
- metadata: {
499
- ...lastMessage.metadata,
500
- mode: "stream",
501
- requireApprovalMetadata: {
502
- ...lastRequireApprovalMetadata,
503
- [chunk.payload.toolName]: {
504
- toolCallId: chunk.payload.toolCallId,
505
- toolName: chunk.payload.toolName,
506
- args: chunk.payload.args
507
- }
508
- }
509
- }
510
- }
511
- ];
512
- }
513
- case "tool-call-suspended": {
514
- const lastMessage = result[result.length - 1];
515
- if (!lastMessage || lastMessage.role !== "assistant") return result;
516
- const lastSuspendedTools = lastMessage.metadata?.mode === "stream" ? lastMessage.metadata?.suspendedTools : {};
517
- return [
518
- ...result.slice(0, -1),
519
- {
520
- ...lastMessage,
521
- metadata: {
522
- ...lastMessage.metadata,
523
- mode: "stream",
524
- suspendedTools: {
525
- ...lastSuspendedTools,
526
- [chunk.payload.toolName]: {
527
- toolCallId: chunk.payload.toolCallId,
528
- toolName: chunk.payload.toolName,
529
- args: chunk.payload.args,
530
- suspendPayload: chunk.payload.suspendPayload
531
- }
532
- }
533
- }
534
- }
535
- ];
536
- }
537
- case "finish": {
538
- const lastMessage = result[result.length - 1];
539
- if (!lastMessage || lastMessage.role !== "assistant") return result;
540
- const parts = lastMessage.parts.map((part) => {
541
- if (typeof part === "object" && part !== null && "type" in part && "state" in part && part.state === "streaming") {
542
- if (part.type === "text" || part.type === "reasoning") {
543
- return { ...part, state: "done" };
544
- }
545
- }
546
- return part;
547
- });
548
- return [
549
- ...result.slice(0, -1),
550
- {
551
- ...lastMessage,
552
- parts
553
- }
554
- ];
555
- }
556
- case "error": {
557
- const newMessage = {
558
- id: `error-${chunk.runId + Date.now()}`,
559
- role: "assistant",
560
- parts: [
561
- {
562
- type: "text",
563
- text: typeof chunk.payload.error === "string" ? chunk.payload.error : JSON.stringify(chunk.payload.error)
564
- }
565
- ],
566
- metadata: {
567
- ...metadata,
568
- status: "error"
569
- }
570
- };
571
- return [...result, newMessage];
572
- }
573
- // For all other chunk types, return conversation unchanged
574
- default:
575
- return result;
576
- }
577
- };
578
- const toUIMessageFromAgent = (chunk, conversation, metadata) => {
579
- const lastMessage = conversation[conversation.length - 1];
580
- if (!lastMessage || lastMessage.role !== "assistant") return conversation;
581
- const parts = [...lastMessage.parts];
582
- if (chunk.type === "text-delta") {
583
- const agentChunk = chunk.payload;
584
- const toolPartIndex = parts.findIndex((part) => part.type === "dynamic-tool");
585
- if (toolPartIndex === -1) return conversation;
586
- const toolPart = parts[toolPartIndex];
587
- const childMessages = toolPart?.output?.childMessages || [];
588
- const lastChildMessage = childMessages[childMessages.length - 1];
589
- const textMessage = { type: "text", content: (lastChildMessage?.content || "") + agentChunk.text };
590
- const nextMessages = lastChildMessage?.type === "text" ? [...childMessages.slice(0, -1), textMessage] : [...childMessages, textMessage];
591
- parts[toolPartIndex] = {
592
- ...toolPart,
593
- output: {
594
- childMessages: nextMessages
253
+ return `${this.name}: ${this.message}`;
595
254
  }
596
255
  };
597
- } else if (chunk.type === "tool-call") {
598
- const agentChunk = chunk.payload;
599
- const toolPartIndex = parts.findIndex((part) => part.type === "dynamic-tool");
600
- if (toolPartIndex === -1) return conversation;
601
- const toolPart = parts[toolPartIndex];
602
- const childMessages = toolPart?.output?.childMessages || [];
603
- parts[toolPartIndex] = {
604
- ...toolPart,
605
- output: {
606
- ...toolPart?.output,
607
- childMessages: [
608
- ...childMessages,
609
- {
610
- type: "tool",
611
- toolCallId: agentChunk.toolCallId,
612
- toolName: agentChunk.toolName,
613
- args: agentChunk.args
614
- }
615
- ]
616
- }
617
- };
618
- } else if (chunk.type === "tool-output") {
619
- const agentChunk = chunk.payload;
620
- const toolPartIndex = parts.findIndex((part) => part.type === "dynamic-tool");
621
- if (toolPartIndex === -1) return conversation;
622
- const toolPart = parts[toolPartIndex];
623
- if (agentChunk?.output?.type?.startsWith("workflow-")) {
624
- const childMessages = toolPart?.output?.childMessages || [];
625
- const lastToolIndex = childMessages.length - 1;
626
- const currentMessage = childMessages[lastToolIndex];
627
- const actualExistingWorkflowState = currentMessage?.toolOutput || {};
628
- const updatedWorkflowState = mapWorkflowStreamChunkToWatchResult(actualExistingWorkflowState, agentChunk.output);
629
- if (lastToolIndex >= 0 && childMessages[lastToolIndex]?.type === "tool") {
630
- parts[toolPartIndex] = {
631
- ...toolPart,
632
- output: {
633
- ...toolPart?.output,
634
- childMessages: [
635
- ...childMessages.slice(0, -1),
636
- {
637
- ...currentMessage,
638
- toolOutput: { ...updatedWorkflowState, runId: agentChunk.output.runId }
639
- }
640
- ]
641
- }
642
- };
643
- }
644
- }
645
- } else if (chunk.type === "tool-result") {
646
- const agentChunk = chunk.payload;
647
- const toolPartIndex = parts.findIndex((part) => part.type === "dynamic-tool");
648
- if (toolPartIndex === -1) return conversation;
649
- const toolPart = parts[toolPartIndex];
650
- const childMessages = toolPart?.output?.childMessages || [];
651
- const lastToolIndex = childMessages.length - 1;
652
- const isWorkflow = agentChunk?.toolName?.startsWith("workflow-");
653
- if (lastToolIndex >= 0 && childMessages[lastToolIndex]?.type === "tool") {
654
- parts[toolPartIndex] = {
655
- ...toolPart,
656
- output: {
657
- ...toolPart?.output,
658
- childMessages: [
659
- ...childMessages.slice(0, -1),
660
- {
661
- ...childMessages[lastToolIndex],
662
- toolOutput: isWorkflow ? { ...agentChunk.result?.result, runId: agentChunk.result?.runId } : agentChunk.result
663
- }
664
- ]
665
- }
666
- };
667
- }
668
256
  }
669
- return [
670
- ...conversation.slice(0, -1),
671
- {
672
- ...lastMessage,
673
- parts
674
- }
675
- ];
676
- };
257
+ });
677
258
 
678
- const toAssistantUIMessage = (message) => {
679
- const extendedMessage = message;
680
- const content = message.parts.map((part) => {
681
- if (part.type === "text") {
682
- return {
683
- type: "text",
684
- text: part.text,
685
- metadata: message.metadata
686
- };
687
- }
688
- if (part.type === "reasoning") {
689
- return {
690
- type: "reasoning",
691
- text: part.text,
692
- metadata: message.metadata
693
- };
694
- }
695
- if (part.type === "source-url") {
696
- return {
697
- type: "source",
698
- sourceType: "url",
699
- id: part.sourceId,
700
- url: part.url,
701
- title: part.title,
702
- metadata: message.metadata
703
- };
704
- }
705
- if (part.type === "source-document") {
706
- return {
707
- type: "file",
708
- filename: part.filename,
709
- mimeType: part.mediaType,
710
- data: "",
711
- // Source documents don't have inline data
712
- metadata: message.metadata
713
- };
714
- }
715
- if (part.type === "file") {
716
- const type = part.mediaType.includes("image/") ? "image" : "file";
717
- if (type === "file") {
718
- return {
719
- type,
720
- mimeType: part.mediaType,
721
- data: part.url,
722
- // Use URL as data source
723
- metadata: message.metadata
724
- };
725
- }
726
- if (type === "image") {
727
- return {
728
- type,
729
- image: part.url,
730
- metadata: message.metadata
731
- };
732
- }
733
- }
734
- if (part.type === "dynamic-tool") {
735
- const baseToolCall = {
736
- type: "tool-call",
737
- toolCallId: part.toolCallId,
738
- toolName: part.toolName,
739
- argsText: JSON.stringify(part.input),
740
- args: part.input,
741
- metadata: message.metadata
742
- };
743
- if (part.state === "output-error" && "errorText" in part) {
744
- return { ...baseToolCall, result: part.errorText, isError: true };
745
- }
746
- if ("output" in part) {
747
- return { ...baseToolCall, result: part.output };
748
- }
749
- return baseToolCall;
750
- }
751
- if (part.type.startsWith("tool-") && part.state !== "input-available") {
752
- const toolName2 = "toolName" in part && typeof part.toolName === "string" ? part.toolName : part.type.substring(5);
753
- const { suspendedToolRunId, ...cleanInput } = "input" in part ? part.input : {};
754
- const baseToolCall = {
755
- type: "tool-call",
756
- toolCallId: "toolCallId" in part && typeof part.toolCallId === "string" ? part.toolCallId : "",
757
- toolName: toolName2,
758
- argsText: JSON.stringify(cleanInput ?? {}),
759
- args: cleanInput ?? {},
760
- metadata: message.metadata
761
- };
762
- if ("output" in part) {
763
- return { ...baseToolCall, result: part.output };
764
- } else if ("error" in part) {
765
- return { ...baseToolCall, result: part.error, isError: true };
766
- }
767
- return baseToolCall;
768
- }
769
- const toolName = "toolName" in part && typeof part.toolName === "string" ? part.toolName : part.type.startsWith("tool-") ? part.type.substring(5) : "";
770
- const requireApprovalMetadata = extendedMessage.metadata?.requireApprovalMetadata;
771
- const suspendedTools = extendedMessage.metadata?.suspendedTools;
772
- const partToolCallId = "toolCallId" in part && typeof part.toolCallId === "string" ? part.toolCallId : void 0;
773
- const suspensionData = toolName ? requireApprovalMetadata?.[toolName] ?? suspendedTools?.[toolName] : void 0;
774
- if (suspensionData) {
775
- const { suspendedToolRunId, ...cleanInput } = "input" in part ? part.input : {};
776
- return {
777
- type: "tool-call",
778
- toolCallId: partToolCallId,
779
- toolName,
780
- argsText: JSON.stringify(cleanInput ?? {}),
781
- args: cleanInput,
782
- metadata: extendedMessage.metadata
783
- };
784
- }
785
- if (part.type.startsWith("data-")) {
786
- return {
787
- type: "data",
788
- name: part.type.substring(5),
789
- // Extract name from 'data-{name}'
790
- data: part.data,
791
- metadata: message.metadata
792
- };
793
- }
794
- return {
795
- type: "text",
796
- text: "",
797
- metadata: message.metadata
798
- };
799
- });
800
- let status;
801
- if (message.role === "assistant" && content.length > 0) {
802
- const hasStreamingParts = message.parts.some(
803
- (part) => part.type === "text" && "state" in part && part.state === "streaming" || part.type === "reasoning" && "state" in part && part.state === "streaming"
804
- );
805
- const hasToolCalls = message.parts.some((part) => part.type === "dynamic-tool" || part.type.startsWith("tool-"));
806
- const hasInputAvailableTools = message.parts.some(
807
- (part) => part.type === "dynamic-tool" && part.state === "input-available"
808
- );
809
- const hasErrorTools = message.parts.some(
810
- (part) => part.type === "dynamic-tool" && part.state === "output-error" || part.type.startsWith("tool-") && "error" in part
811
- );
812
- if (hasStreamingParts) {
813
- status = { type: "running" };
814
- } else if (hasInputAvailableTools && hasToolCalls) {
815
- status = { type: "requires-action", reason: "tool-calls" };
816
- } else if (hasErrorTools) {
817
- status = { type: "incomplete", reason: "error" };
818
- } else {
819
- status = { type: "complete", reason: "stop" };
820
- }
259
+ // ../_vendored/ai_v5/dist/chunk-VQ35X6XO.js
260
+ var marker$4 = "vercel.ai.error";
261
+ var symbol$4 = Symbol.for(marker$4);
262
+ var _a$4;
263
+ var _AISDKError$2 = class _AISDKError2 extends Error {
264
+ /**
265
+ * Creates an AI SDK Error.
266
+ *
267
+ * @param {Object} params - The parameters for creating the error.
268
+ * @param {string} params.name - The name of the error.
269
+ * @param {string} params.message - The error message.
270
+ * @param {unknown} [params.cause] - The underlying cause of the error.
271
+ */
272
+ constructor({
273
+ name: name14,
274
+ message,
275
+ cause
276
+ }) {
277
+ super(message);
278
+ this[_a$4] = true;
279
+ this.name = name14;
280
+ this.cause = cause;
281
+ }
282
+ /**
283
+ * Checks if the given error is an AI SDK Error.
284
+ * @param {unknown} error - The error to check.
285
+ * @returns {boolean} True if the error is an AI SDK Error, false otherwise.
286
+ */
287
+ static isInstance(error) {
288
+ return _AISDKError2.hasMarker(error, marker$4);
289
+ }
290
+ static hasMarker(error, marker15) {
291
+ const markerSymbol = Symbol.for(marker15);
292
+ return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
821
293
  }
822
- const threadMessage = {
823
- role: message.role,
824
- content,
825
- id: message.id,
826
- createdAt: extendedMessage.createdAt,
827
- status,
828
- attachments: extendedMessage.experimental_attachments
829
- };
830
- return threadMessage;
831
294
  };
832
-
833
- const resolveInitialMessages = (messages) => {
834
- const messagesLength = messages.length;
835
- return messages.map((message, index) => {
836
- const networkPart = message.parts.find(
837
- (part) => typeof part === "object" && part !== null && "type" in part && part.type === "text" && "text" in part && typeof part.text === "string" && part.text.includes('"isNetwork":true')
838
- );
839
- if (networkPart && networkPart.type === "text") {
840
- try {
841
- const json = JSON.parse(networkPart.text);
842
- if (json.isNetwork === true) {
843
- const selectionReason = json.selectionReason || "";
844
- const primitiveType = json.primitiveType || "";
845
- const primitiveId = json.primitiveId || "";
846
- const finalResult = json.finalResult;
847
- const messages2 = finalResult?.messages || [];
848
- const childMessages = [];
849
- const toolResultMap = /* @__PURE__ */ new Map();
850
- for (const msg of messages2) {
851
- if (Array.isArray(msg.content)) {
852
- for (const part of msg.content) {
853
- if (typeof part === "object" && part.type === "tool-result") {
854
- toolResultMap.set(part.toolCallId, part);
855
- }
856
- }
857
- }
858
- }
859
- for (const msg of messages2) {
860
- if (msg.type === "tool-call" && Array.isArray(msg.content)) {
861
- for (const part of msg.content) {
862
- if (typeof part === "object" && part.type === "tool-call") {
863
- const toolCallContent = part;
864
- const toolResult = toolResultMap.get(toolCallContent.toolCallId);
865
- const isWorkflow = Boolean(toolResult?.result?.result?.steps);
866
- childMessages.push({
867
- type: "tool",
868
- toolCallId: toolCallContent.toolCallId,
869
- toolName: toolCallContent.toolName,
870
- args: toolCallContent.args,
871
- toolOutput: isWorkflow ? toolResult?.result?.result : toolResult?.result
872
- });
873
- }
874
- }
875
- }
876
- }
877
- if (finalResult && finalResult.text) {
878
- childMessages.push({
879
- type: "text",
880
- content: finalResult.text
881
- });
882
- }
883
- const result = primitiveType === "tool" ? finalResult?.result : {
884
- childMessages,
885
- result: finalResult?.text || ""
886
- };
887
- const nextMessage = {
888
- role: "assistant",
889
- parts: [
890
- {
891
- type: "dynamic-tool",
892
- toolCallId: primitiveId,
893
- toolName: primitiveId,
894
- state: "output-available",
895
- input: json.input,
896
- output: result
897
- }
898
- ],
899
- id: message.id,
900
- metadata: {
901
- ...message.metadata,
902
- mode: "network",
903
- selectionReason,
904
- agentInput: json.input,
905
- hasMoreMessages: index < messagesLength - 1,
906
- from: primitiveType === "agent" ? "AGENT" : primitiveType === "tool" ? "TOOL" : "WORKFLOW"
907
- }
908
- };
909
- return nextMessage;
910
- }
911
- } catch (error) {
912
- return message;
913
- }
914
- }
915
- const extendedMessage = message;
916
- const pendingToolApprovals = extendedMessage.metadata?.pendingToolApprovals;
917
- if (pendingToolApprovals && typeof pendingToolApprovals === "object") {
918
- return {
919
- ...message,
920
- metadata: {
921
- ...message.metadata,
922
- mode: "stream",
923
- requireApprovalMetadata: pendingToolApprovals
924
- }
925
- };
926
- }
927
- const suspendedTools = extendedMessage.metadata?.suspendedTools;
928
- if (suspendedTools && typeof suspendedTools === "object") {
929
- return {
930
- ...message,
931
- metadata: {
932
- ...message.metadata,
933
- mode: "stream",
934
- suspendedTools
935
- }
936
- };
937
- }
938
- return message;
939
- });
940
- };
941
- const resolveToChildMessages = (messages) => {
942
- const assistantMessage = messages.find((message) => message.role === "assistant");
943
- if (!assistantMessage) return [];
944
- const parts = assistantMessage.parts;
945
- let childMessages = [];
946
- for (const part of parts) {
947
- const toolPart = part;
948
- if (part.type.startsWith("tool-")) {
949
- const toolName = part.type.substring("tool-".length);
950
- const isWorkflow = toolName.startsWith("workflow-");
951
- childMessages.push({
952
- type: "tool",
953
- toolCallId: toolPart.toolCallId,
954
- toolName,
955
- args: toolPart.input,
956
- toolOutput: isWorkflow ? { ...toolPart.output?.result, runId: toolPart.output?.runId } : toolPart.output
957
- });
958
- }
959
- if (part.type === "text") {
960
- childMessages.push({
961
- type: "text",
962
- content: toolPart.text
963
- });
964
- }
295
+ _a$4 = symbol$4;
296
+ var AISDKError$3 = _AISDKError$2;
297
+ var name$1 = "AI_APICallError";
298
+ var marker2$1 = `vercel.ai.error.${name$1}`;
299
+ var symbol2$1 = Symbol.for(marker2$1);
300
+ var _a2$1;
301
+ var APICallError = class extends AISDKError$3 {
302
+ constructor({
303
+ message,
304
+ url,
305
+ requestBodyValues,
306
+ statusCode,
307
+ responseHeaders,
308
+ responseBody,
309
+ cause,
310
+ isRetryable = statusCode != null && (statusCode === 408 || // request timeout
311
+ statusCode === 409 || // conflict
312
+ statusCode === 429 || // too many requests
313
+ statusCode >= 500),
314
+ // server error
315
+ data
316
+ }) {
317
+ super({ name: name$1, message, cause });
318
+ this[_a2$1] = true;
319
+ this.url = url;
320
+ this.requestBodyValues = requestBodyValues;
321
+ this.statusCode = statusCode;
322
+ this.responseHeaders = responseHeaders;
323
+ this.responseBody = responseBody;
324
+ this.isRetryable = isRetryable;
325
+ this.data = data;
965
326
  }
966
- return childMessages;
967
- };
968
-
969
- var __create$4 = Object.create;
970
- var __defProp$6 = Object.defineProperty;
971
- var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
972
- var __getOwnPropNames$4 = Object.getOwnPropertyNames;
973
- var __getProtoOf$4 = Object.getPrototypeOf;
974
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
975
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
976
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
977
- }) : x)(function(x) {
978
- if (typeof require !== "undefined") return require.apply(this, arguments);
979
- throw Error('Dynamic require of "' + x + '" is not supported');
980
- });
981
- var __commonJS$4 = (cb, mod) => function __require2() {
982
- return mod || (0, cb[__getOwnPropNames$4(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
983
- };
984
- var __copyProps$4 = (to, from, except, desc) => {
985
- if (from && typeof from === "object" || typeof from === "function") {
986
- for (let key of __getOwnPropNames$4(from))
987
- if (!__hasOwnProp$4.call(to, key) && key !== except)
988
- __defProp$6(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc$4(from, key)) || desc.enumerable });
327
+ static isInstance(error) {
328
+ return AISDKError$3.hasMarker(error, marker2$1);
989
329
  }
990
- return to;
991
330
  };
992
- var __toESM$3 = (mod, isNodeMode, target) => (target = mod != null ? __create$4(__getProtoOf$4(mod)) : {}, __copyProps$4(
993
- // If the importer is in node compatibility mode or this is not an ESM
994
- // file that has been converted to a CommonJS file using a Babel-
995
- // compatible transform (i.e. "__esModule" has not been set), then set
996
- // "default" to the CommonJS "module.exports" for node compatibility.
997
- __defProp$6(target, "default", { value: mod, enumerable: true }) ,
998
- mod
999
- ));
1000
-
1001
- // ../_vendored/ai_v5/dist/chunk-7D4SUZUM.js
1002
- var __create$3 = Object.create;
1003
- var __defProp$5 = Object.defineProperty;
1004
- var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
1005
- var __getOwnPropNames$3 = Object.getOwnPropertyNames;
1006
- var __getProtoOf$3 = Object.getPrototypeOf;
1007
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1008
- var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
1009
- get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
1010
- }) : x)(function(x) {
1011
- if (typeof __require !== "undefined") return __require.apply(this, arguments);
1012
- throw Error('Dynamic require of "' + x + '" is not supported');
1013
- });
1014
- var __commonJS$3 = (cb, mod) => function __require22() {
1015
- return mod || (0, cb[__getOwnPropNames$3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
331
+ _a2$1 = symbol2$1;
332
+ var name2$1 = "AI_EmptyResponseBodyError";
333
+ var marker3$1 = `vercel.ai.error.${name2$1}`;
334
+ var symbol3$1 = Symbol.for(marker3$1);
335
+ var _a3$1;
336
+ var EmptyResponseBodyError = class extends AISDKError$3 {
337
+ // used in isInstance
338
+ constructor({ message = "Empty response body" } = {}) {
339
+ super({ name: name2$1, message });
340
+ this[_a3$1] = true;
341
+ }
342
+ static isInstance(error) {
343
+ return AISDKError$3.hasMarker(error, marker3$1);
344
+ }
1016
345
  };
1017
- var __copyProps$3 = (to, from, except, desc) => {
1018
- if (from && typeof from === "object" || typeof from === "function") {
1019
- for (let key of __getOwnPropNames$3(from))
1020
- if (!__hasOwnProp$3.call(to, key) && key !== except)
1021
- __defProp$5(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc$3(from, key)) || desc.enumerable });
1022
- }
1023
- return to;
1024
- };
1025
- var __toESM$2 = (mod, isNodeMode, target) => (target = mod != null ? __create$3(__getProtoOf$3(mod)) : {}, __copyProps$3(
1026
- // If the importer is in node compatibility mode or this is not an ESM
1027
- // file that has been converted to a CommonJS file using a Babel-
1028
- // compatible transform (i.e. "__esModule" has not been set), then set
1029
- // "default" to the CommonJS "module.exports" for node compatibility.
1030
- __defProp$5(target, "default", { value: mod, enumerable: true }) ,
1031
- mod
1032
- ));
1033
-
1034
- // ../_vendored/ai_v5/dist/chunk-TLQKI65U.js
1035
- var require_token_error = __commonJS$3({
1036
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-error.js"(exports$1, module) {
1037
- var __defProp2 = Object.defineProperty;
1038
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
1039
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
1040
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
1041
- var __export = (target, all) => {
1042
- for (var name in all)
1043
- __defProp2(target, name, { get: all[name], enumerable: true });
1044
- };
1045
- var __copyProps2 = (to, from, except, desc) => {
1046
- if (from && typeof from === "object" || typeof from === "function") {
1047
- for (let key of __getOwnPropNames2(from))
1048
- if (!__hasOwnProp2.call(to, key) && key !== except)
1049
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
1050
- }
1051
- return to;
1052
- };
1053
- var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
1054
- var token_error_exports = {};
1055
- __export(token_error_exports, {
1056
- VercelOidcTokenError: () => VercelOidcTokenError
1057
- });
1058
- module.exports = __toCommonJS(token_error_exports);
1059
- var VercelOidcTokenError = class extends Error {
1060
- constructor(message, cause) {
1061
- super(message);
1062
- this.name = "VercelOidcTokenError";
1063
- this.cause = cause;
1064
- }
1065
- toString() {
1066
- if (this.cause) {
1067
- return `${this.name}: ${this.message}: ${this.cause}`;
1068
- }
1069
- return `${this.name}: ${this.message}`;
1070
- }
1071
- };
1072
- }
1073
- });
1074
-
1075
- // ../_vendored/ai_v5/dist/chunk-VQ35X6XO.js
1076
- var marker$4 = "vercel.ai.error";
1077
- var symbol$4 = Symbol.for(marker$4);
1078
- var _a$4;
1079
- var _AISDKError$2 = class _AISDKError2 extends Error {
1080
- /**
1081
- * Creates an AI SDK Error.
1082
- *
1083
- * @param {Object} params - The parameters for creating the error.
1084
- * @param {string} params.name - The name of the error.
1085
- * @param {string} params.message - The error message.
1086
- * @param {unknown} [params.cause] - The underlying cause of the error.
1087
- */
1088
- constructor({
1089
- name: name14,
1090
- message,
1091
- cause
1092
- }) {
1093
- super(message);
1094
- this[_a$4] = true;
1095
- this.name = name14;
1096
- this.cause = cause;
1097
- }
1098
- /**
1099
- * Checks if the given error is an AI SDK Error.
1100
- * @param {unknown} error - The error to check.
1101
- * @returns {boolean} True if the error is an AI SDK Error, false otherwise.
1102
- */
1103
- static isInstance(error) {
1104
- return _AISDKError2.hasMarker(error, marker$4);
1105
- }
1106
- static hasMarker(error, marker15) {
1107
- const markerSymbol = Symbol.for(marker15);
1108
- return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
1109
- }
1110
- };
1111
- _a$4 = symbol$4;
1112
- var AISDKError$3 = _AISDKError$2;
1113
- var name$1 = "AI_APICallError";
1114
- var marker2$1 = `vercel.ai.error.${name$1}`;
1115
- var symbol2$1 = Symbol.for(marker2$1);
1116
- var _a2$1;
1117
- var APICallError = class extends AISDKError$3 {
1118
- constructor({
1119
- message,
1120
- url,
1121
- requestBodyValues,
1122
- statusCode,
1123
- responseHeaders,
1124
- responseBody,
1125
- cause,
1126
- isRetryable = statusCode != null && (statusCode === 408 || // request timeout
1127
- statusCode === 409 || // conflict
1128
- statusCode === 429 || // too many requests
1129
- statusCode >= 500),
1130
- // server error
1131
- data
1132
- }) {
1133
- super({ name: name$1, message, cause });
1134
- this[_a2$1] = true;
1135
- this.url = url;
1136
- this.requestBodyValues = requestBodyValues;
1137
- this.statusCode = statusCode;
1138
- this.responseHeaders = responseHeaders;
1139
- this.responseBody = responseBody;
1140
- this.isRetryable = isRetryable;
1141
- this.data = data;
1142
- }
1143
- static isInstance(error) {
1144
- return AISDKError$3.hasMarker(error, marker2$1);
1145
- }
1146
- };
1147
- _a2$1 = symbol2$1;
1148
- var name2$1 = "AI_EmptyResponseBodyError";
1149
- var marker3$1 = `vercel.ai.error.${name2$1}`;
1150
- var symbol3$1 = Symbol.for(marker3$1);
1151
- var _a3$1;
1152
- var EmptyResponseBodyError = class extends AISDKError$3 {
1153
- // used in isInstance
1154
- constructor({ message = "Empty response body" } = {}) {
1155
- super({ name: name2$1, message });
1156
- this[_a3$1] = true;
1157
- }
1158
- static isInstance(error) {
1159
- return AISDKError$3.hasMarker(error, marker3$1);
1160
- }
1161
- };
1162
- _a3$1 = symbol3$1;
1163
- function getErrorMessage$2(error) {
1164
- if (error == null) {
1165
- return "unknown error";
1166
- }
1167
- if (typeof error === "string") {
1168
- return error;
1169
- }
1170
- if (error instanceof Error) {
1171
- return error.message;
1172
- }
1173
- return JSON.stringify(error);
1174
- }
1175
- var name3$4 = "AI_InvalidArgumentError";
1176
- var marker4$4 = `vercel.ai.error.${name3$4}`;
1177
- var symbol4$4 = Symbol.for(marker4$4);
1178
- var _a4$4;
1179
- var InvalidArgumentError$3 = class InvalidArgumentError extends AISDKError$3 {
1180
- constructor({
1181
- message,
1182
- cause,
1183
- argument
1184
- }) {
1185
- super({ name: name3$4, message, cause });
1186
- this[_a4$4] = true;
1187
- this.argument = argument;
1188
- }
1189
- static isInstance(error) {
1190
- return AISDKError$3.hasMarker(error, marker4$4);
346
+ _a3$1 = symbol3$1;
347
+ function getErrorMessage$2(error) {
348
+ if (error == null) {
349
+ return "unknown error";
350
+ }
351
+ if (typeof error === "string") {
352
+ return error;
353
+ }
354
+ if (error instanceof Error) {
355
+ return error.message;
356
+ }
357
+ return JSON.stringify(error);
358
+ }
359
+ var name3$4 = "AI_InvalidArgumentError";
360
+ var marker4$4 = `vercel.ai.error.${name3$4}`;
361
+ var symbol4$4 = Symbol.for(marker4$4);
362
+ var _a4$4;
363
+ var InvalidArgumentError$3 = class InvalidArgumentError extends AISDKError$3 {
364
+ constructor({
365
+ message,
366
+ cause,
367
+ argument
368
+ }) {
369
+ super({ name: name3$4, message, cause });
370
+ this[_a4$4] = true;
371
+ this.argument = argument;
372
+ }
373
+ static isInstance(error) {
374
+ return AISDKError$3.hasMarker(error, marker4$4);
1191
375
  }
1192
376
  };
1193
377
  _a4$4 = symbol4$4;
@@ -3149,8 +2333,8 @@ var require_get_vercel_oidc_token = __commonJS$3({
3149
2333
  }
3150
2334
  try {
3151
2335
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
3152
- await import('./token-util-NEHG7TUY-U7CX7GS4-jJSXEovt.js'),
3153
- await import('./token-6GSAFR2W-XRCSVUPZ-Cgcu7avO.js')
2336
+ await import('./token-util-NEHG7TUY-U7CX7GS4-C_BDhp1r.js'),
2337
+ await import('./token-6GSAFR2W-XRCSVUPZ-PJRK45Cx.js')
3154
2338
  ]);
3155
2339
  if (!token || isExpired(getTokenPayload(token))) {
3156
2340
  await refreshToken();
@@ -5746,140 +4930,21 @@ var MastraBaseError = class extends Error {
5746
4930
  var MastraError = class extends MastraBaseError {
5747
4931
  };
5748
4932
 
5749
- // src/request-context/index.ts
5750
- var RequestContext = class {
5751
- registry = /* @__PURE__ */ new Map();
5752
- constructor(iterable) {
5753
- this.registry = new Map(iterable);
5754
- }
5755
- /**
5756
- * set a value with strict typing if `Values` is a Record and the key exists in it.
5757
- */
5758
- set(key, value) {
5759
- this.registry.set(key, value);
5760
- }
5761
- /**
5762
- * Get a value with its type
5763
- */
5764
- get(key) {
5765
- return this.registry.get(key);
5766
- }
5767
- /**
5768
- * Check if a key exists in the container
5769
- */
5770
- has(key) {
5771
- return this.registry.has(key);
5772
- }
5773
- /**
5774
- * Delete a value by key
5775
- */
5776
- delete(key) {
5777
- return this.registry.delete(key);
5778
- }
5779
- /**
5780
- * Clear all values from the container
5781
- */
5782
- clear() {
5783
- this.registry.clear();
5784
- }
5785
- /**
5786
- * Get all keys in the container
5787
- */
5788
- keys() {
5789
- return this.registry.keys();
5790
- }
5791
- /**
5792
- * Get all values in the container
5793
- */
5794
- values() {
5795
- return this.registry.values();
5796
- }
5797
- /**
5798
- * Get all entries in the container.
5799
- * Returns a discriminated union of tuples for proper type narrowing when iterating.
5800
- */
5801
- entries() {
5802
- return this.registry.entries();
5803
- }
5804
- /**
5805
- * Get the size of the container
5806
- */
5807
- size() {
5808
- return this.registry.size;
5809
- }
5810
- /**
5811
- * Execute a function for each entry in the container.
5812
- * The callback receives properly typed key-value pairs.
5813
- */
5814
- forEach(callbackfn) {
5815
- this.registry.forEach(callbackfn);
5816
- }
5817
- /**
5818
- * Custom JSON serialization method.
5819
- * Converts the internal Map to a plain object for proper JSON serialization.
5820
- * Non-serializable values (e.g., RPC proxies, functions, circular references)
5821
- * are skipped to prevent serialization errors when storing to database.
5822
- */
5823
- toJSON() {
5824
- const result = {};
5825
- for (const [key, value] of this.registry.entries()) {
5826
- if (this.isSerializable(value)) {
5827
- result[key] = value;
5828
- }
5829
- }
5830
- return result;
5831
- }
5832
- /**
5833
- * Check if a value can be safely serialized to JSON.
5834
- */
5835
- isSerializable(value) {
5836
- if (value === null || value === void 0) return true;
5837
- if (typeof value === "function") return false;
5838
- if (typeof value === "symbol") return false;
5839
- if (typeof value !== "object") return true;
5840
- try {
5841
- JSON.stringify(value);
5842
- return true;
5843
- } catch {
5844
- return false;
5845
- }
5846
- }
5847
- /**
5848
- * Get all values as a typed object for destructuring.
5849
- * Returns Record<string, any> when untyped, or the Values type when typed.
5850
- *
5851
- * @example
5852
- * ```typescript
5853
- * const ctx = new RequestContext<{ userId: string; apiKey: string }>();
5854
- * ctx.set('userId', 'user-123');
5855
- * ctx.set('apiKey', 'key-456');
5856
- * const { userId, apiKey } = ctx.all;
5857
- * ```
5858
- */
5859
- get all() {
5860
- return Object.fromEntries(this.registry);
5861
- }
5862
- };
5863
-
5864
- function getDefaultExportFromCjs (x) {
5865
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5866
- }
5867
-
5868
- // ../_vendored/ai_v4/dist/chunk-OPIPXJLE.js
5869
- var __create$2 = Object.create;
5870
- var __defProp$3 = Object.defineProperty;
5871
- var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
5872
- var __getOwnPropNames$2 = Object.getOwnPropertyNames;
5873
- var __getProtoOf$2 = Object.getPrototypeOf;
5874
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
5875
- var __commonJS$2 = (cb, mod) => function __require22() {
5876
- return mod || (0, cb[__getOwnPropNames$2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5877
- };
5878
- var __copyProps$2 = (to, from, except, desc) => {
5879
- if (from && typeof from === "object" || typeof from === "function") {
5880
- for (let key of __getOwnPropNames$2(from))
5881
- if (!__hasOwnProp$2.call(to, key) && key !== except)
5882
- __defProp$3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc$2(from, key)) || desc.enumerable });
4933
+ // ../_vendored/ai_v4/dist/chunk-OPIPXJLE.js
4934
+ var __create$2 = Object.create;
4935
+ var __defProp$3 = Object.defineProperty;
4936
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
4937
+ var __getOwnPropNames$2 = Object.getOwnPropertyNames;
4938
+ var __getProtoOf$2 = Object.getPrototypeOf;
4939
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
4940
+ var __commonJS$2 = (cb, mod) => function __require22() {
4941
+ return mod || (0, cb[__getOwnPropNames$2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4942
+ };
4943
+ var __copyProps$2 = (to, from, except, desc) => {
4944
+ if (from && typeof from === "object" || typeof from === "function") {
4945
+ for (let key of __getOwnPropNames$2(from))
4946
+ if (!__hasOwnProp$2.call(to, key) && key !== except)
4947
+ __defProp$3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc$2(from, key)) || desc.enumerable });
5883
4948
  }
5884
4949
  return to;
5885
4950
  };
@@ -11995,6 +11060,9 @@ var MessageMerger = class _MessageMerger {
11995
11060
  static shouldMerge(latestMessage, incomingMessage, messageSource, isLatestFromMemory, agentNetworkAppend = false) {
11996
11061
  if (!latestMessage) return false;
11997
11062
  if (_MessageMerger.isSealed(latestMessage)) return false;
11063
+ if (incomingMessage.content.metadata?.completionResult || latestMessage.content.metadata?.completionResult || incomingMessage.content.metadata?.isTaskCompleteResult || latestMessage.content.metadata?.isTaskCompleteResult) {
11064
+ return false;
11065
+ }
11998
11066
  const shouldAppendToLastAssistantMessage = latestMessage.role === "assistant" && incomingMessage.role === "assistant" && latestMessage.threadId === incomingMessage.threadId && // If the message is from memory, don't append to the last assistant message
11999
11067
  messageSource !== "memory";
12000
11068
  const appendNetworkMessage = agentNetworkAppend ? !isLatestFromMemory : true;
@@ -13735,6 +12803,20 @@ var MessageList$1 = class MessageList {
13735
12803
  this.messages.push(messageV2);
13736
12804
  }
13737
12805
  } else {
12806
+ const isExistingFromMemory = this.memoryMessages.has(existingMessage);
12807
+ const shouldMergeIntoExisting = MessageMerger.shouldMerge(
12808
+ existingMessage,
12809
+ messageV2,
12810
+ messageSource,
12811
+ isExistingFromMemory,
12812
+ this._agentNetworkAppend
12813
+ );
12814
+ if (shouldMergeIntoExisting) {
12815
+ MessageMerger.merge(existingMessage, messageV2);
12816
+ this.pushMessageToSource(existingMessage, messageSource);
12817
+ this.messages.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
12818
+ return this;
12819
+ }
13738
12820
  this.messages[existingIndex] = messageV2;
13739
12821
  }
13740
12822
  } else if (!exists) {
@@ -24402,7 +23484,9 @@ z10.object({
24402
23484
  }),
24403
23485
  stepResult: llmIterationStepResultSchema,
24404
23486
  processorRetryCount: z10.number().optional(),
24405
- processorRetryFeedback: z10.string().optional()
23487
+ processorRetryFeedback: z10.string().optional(),
23488
+ isTaskCompleteCheckFailed: z10.boolean().optional()
23489
+ //true if the isTaskComplete check failed and LLM has to run again
24406
23490
  });
24407
23491
  var toolCallInputSchema = z10.object({
24408
23492
  toolCallId: z10.string(),
@@ -24425,83 +23509,1102 @@ function formatCompletionFeedback(result, maxIterationReached) {
24425
23509
  if (result.timedOut) {
24426
23510
  lines.push("\u26A0\uFE0F Scoring timed out");
24427
23511
  }
24428
- lines.push("");
24429
- for (const scorer of result.scorers) {
24430
- lines.push(`###### ${scorer.scorerName} (${scorer.scorerId})`);
24431
- lines.push(`Score: ${scorer.score} ${scorer.passed ? "\u2705" : "\u274C"}`);
24432
- if (scorer.reason) {
24433
- lines.push(`Reason: ${scorer.reason}`);
23512
+ lines.push("");
23513
+ for (const scorer of result.scorers) {
23514
+ lines.push(`###### ${scorer.scorerName} (${scorer.scorerId})`);
23515
+ lines.push(`Score: ${scorer.score} ${scorer.passed ? "\u2705" : "\u274C"}`);
23516
+ if (scorer.reason) {
23517
+ lines.push(`Reason: ${scorer.reason}`);
23518
+ }
23519
+ lines.push("");
23520
+ }
23521
+ if (result.complete) {
23522
+ lines.push("\n\n\u2705 The task is complete.");
23523
+ } else if (maxIterationReached) {
23524
+ lines.push("\n\n\u26A0\uFE0F Max iterations reached.");
23525
+ } else {
23526
+ lines.push("\n\n\u{1F504} Will continue working on the task.");
23527
+ }
23528
+ return lines.join("\n");
23529
+ }
23530
+ z$2.object({
23531
+ isComplete: z$2.boolean().describe("Whether the task is complete"),
23532
+ completionReason: z$2.string().describe("Explanation of why the task is or is not complete"),
23533
+ finalResult: z$2.string().optional().describe("The final result text to return to the user. omit if primitive result is sufficient")
23534
+ });
23535
+ z$2.object({
23536
+ finalResult: z$2.string().optional().describe("The final result text to return to the user, omit if primitive result is sufficient")
23537
+ });
23538
+ function formatStreamCompletionFeedback(result, maxIterationReached) {
23539
+ const lines = [];
23540
+ lines.push("#### Completion Check Results");
23541
+ lines.push("");
23542
+ lines.push(`Overall: ${result.complete ? "\u2705 COMPLETE" : "\u274C NOT COMPLETE"}`);
23543
+ lines.push(`Duration: ${result.totalDuration}ms`);
23544
+ if (result.timedOut) {
23545
+ lines.push("\u26A0\uFE0F Scoring timed out");
23546
+ }
23547
+ lines.push("");
23548
+ for (const scorer of result.scorers) {
23549
+ lines.push(`**${scorer.scorerName}** (${scorer.scorerId})`);
23550
+ lines.push(`Score: ${scorer.score} ${scorer.passed ? "\u2705" : "\u274C"}`);
23551
+ if (scorer.reason) {
23552
+ lines.push(`Reason: ${scorer.reason}`);
23553
+ }
23554
+ lines.push("");
23555
+ }
23556
+ if (result.complete) {
23557
+ lines.push("\u2705 The task is complete.");
23558
+ } else if (maxIterationReached) {
23559
+ lines.push("\u26A0\uFE0F Max iterations reached.");
23560
+ } else {
23561
+ lines.push("\u{1F504} The task is not yet complete. Please continue working based on the feedback above.");
23562
+ }
23563
+ return lines.join("\n");
23564
+ }
23565
+ z10.enum(["agent", "workflow", "none", "tool"]);
23566
+
23567
+ // src/agent/agent-legacy.ts
23568
+ __toESM$3(require_fast_deep_equal());
23569
+
23570
+ // src/agent/workflows/prepare-stream/prepare-memory-step.ts
23571
+ __toESM$3(require_fast_deep_equal());
23572
+ var coreToolSchema = z$2.object({
23573
+ id: z$2.string().optional(),
23574
+ description: z$2.string().optional(),
23575
+ parameters: z$2.union([
23576
+ z$2.record(z$2.string(), z$2.any()),
23577
+ // JSON Schema as object
23578
+ z$2.any()
23579
+ // Zod schema or other schema types - validated at tool execution
23580
+ ]),
23581
+ outputSchema: z$2.union([z$2.record(z$2.string(), z$2.any()), z$2.any()]).optional(),
23582
+ execute: z$2.optional(z$2.function(z$2.tuple([z$2.any(), z$2.any()]), z$2.promise(z$2.any()))),
23583
+ toModelOutput: z$2.optional(z$2.function(z$2.tuple([z$2.any()]), z$2.any())),
23584
+ type: z$2.union([z$2.literal("function"), z$2.literal("provider-defined"), z$2.undefined()]).optional(),
23585
+ args: z$2.record(z$2.string(), z$2.any()).optional()
23586
+ });
23587
+ var storageThreadSchema = z$2.object({
23588
+ id: z$2.string(),
23589
+ title: z$2.string().optional(),
23590
+ resourceId: z$2.string(),
23591
+ createdAt: z$2.date(),
23592
+ updatedAt: z$2.date(),
23593
+ metadata: z$2.record(z$2.string(), z$2.any()).optional()
23594
+ });
23595
+ z$2.object({
23596
+ convertedTools: z$2.record(z$2.string(), coreToolSchema)
23597
+ });
23598
+ z$2.object({
23599
+ threadExists: z$2.boolean(),
23600
+ thread: storageThreadSchema.optional(),
23601
+ messageList: z$2.instanceof(MessageList$1),
23602
+ /** Shared processor states map that persists across loop iterations for both input and output processors */
23603
+ processorStates: z$2.instanceof(Map),
23604
+ /** Tripwire data when input processor triggered abort */
23605
+ tripwire: z$2.object({
23606
+ reason: z$2.string(),
23607
+ retry: z$2.boolean().optional(),
23608
+ metadata: z$2.unknown().optional(),
23609
+ processorId: z$2.string().optional()
23610
+ }).optional()
23611
+ });
23612
+ var DEFAULT_CACHE_MAX_SIZE = 1e3;
23613
+ new L({
23614
+ max: DEFAULT_CACHE_MAX_SIZE
23615
+ });
23616
+
23617
+ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
23618
+ if (chunk.type === "workflow-start") {
23619
+ return {
23620
+ input: prev?.input,
23621
+ status: "running",
23622
+ steps: prev?.steps || {}
23623
+ };
23624
+ }
23625
+ if (chunk.type === "workflow-canceled") {
23626
+ return {
23627
+ ...prev,
23628
+ status: "canceled"
23629
+ };
23630
+ }
23631
+ if (chunk.type === "workflow-finish") {
23632
+ const finalStatus = chunk.payload.workflowStatus;
23633
+ const prevSteps = prev?.steps ?? {};
23634
+ const lastStep = Object.values(prevSteps).pop();
23635
+ return {
23636
+ ...prev,
23637
+ status: chunk.payload.workflowStatus,
23638
+ ...finalStatus === "success" && lastStep?.status === "success" ? { result: lastStep?.output } : finalStatus === "failed" && lastStep?.status === "failed" ? { error: lastStep?.error } : finalStatus === "tripwire" && chunk.payload.tripwire ? { tripwire: chunk.payload.tripwire } : {}
23639
+ };
23640
+ }
23641
+ const { stepCallId, stepName, ...newPayload } = chunk.payload ?? {};
23642
+ const newSteps = {
23643
+ ...prev?.steps,
23644
+ [chunk.payload.id]: {
23645
+ ...prev?.steps?.[chunk.payload.id],
23646
+ ...newPayload
23647
+ }
23648
+ };
23649
+ if (chunk.type === "workflow-step-start") {
23650
+ return {
23651
+ ...prev,
23652
+ steps: newSteps
23653
+ };
23654
+ }
23655
+ if (chunk.type === "workflow-step-suspended") {
23656
+ const suspendedStepIds = Object.entries(newSteps).flatMap(
23657
+ ([stepId, stepResult]) => {
23658
+ if (stepResult?.status === "suspended") {
23659
+ const nestedPath = stepResult?.suspendPayload?.__workflow_meta?.path;
23660
+ return nestedPath ? [[stepId, ...nestedPath]] : [[stepId]];
23661
+ }
23662
+ return [];
23663
+ }
23664
+ );
23665
+ return {
23666
+ ...prev,
23667
+ status: "suspended",
23668
+ steps: newSteps,
23669
+ suspendPayload: chunk.payload.suspendPayload,
23670
+ suspended: suspendedStepIds
23671
+ };
23672
+ }
23673
+ if (chunk.type === "workflow-step-waiting") {
23674
+ return {
23675
+ ...prev,
23676
+ status: "waiting",
23677
+ steps: newSteps
23678
+ };
23679
+ }
23680
+ if (chunk.type === "workflow-step-progress") {
23681
+ const progressSteps = {
23682
+ ...prev?.steps,
23683
+ [chunk.payload.id]: {
23684
+ ...prev?.steps?.[chunk.payload.id],
23685
+ foreachProgress: {
23686
+ completedCount: chunk.payload.completedCount,
23687
+ totalCount: chunk.payload.totalCount,
23688
+ currentIndex: chunk.payload.currentIndex,
23689
+ iterationStatus: chunk.payload.iterationStatus,
23690
+ iterationOutput: chunk.payload.iterationOutput
23691
+ }
23692
+ }
23693
+ };
23694
+ return {
23695
+ ...prev,
23696
+ steps: progressSteps
23697
+ };
23698
+ }
23699
+ if (chunk.type === "workflow-step-result") {
23700
+ return {
23701
+ ...prev,
23702
+ steps: newSteps
23703
+ };
23704
+ }
23705
+ return prev;
23706
+ };
23707
+ const toUIMessage = ({ chunk, conversation, metadata }) => {
23708
+ const result = [...conversation];
23709
+ if (chunk.type.startsWith("data-")) {
23710
+ const lastMessage = result[result.length - 1];
23711
+ if (!lastMessage || lastMessage.role !== "assistant") {
23712
+ const newMessage = {
23713
+ id: `data-${chunk.runId}-${Date.now()}`,
23714
+ role: "assistant",
23715
+ parts: [
23716
+ {
23717
+ type: chunk.type,
23718
+ data: "data" in chunk ? chunk.data : void 0
23719
+ }
23720
+ ],
23721
+ metadata
23722
+ };
23723
+ return [...result, newMessage];
23724
+ }
23725
+ const updatedMessage = {
23726
+ ...lastMessage,
23727
+ parts: [
23728
+ ...lastMessage.parts,
23729
+ {
23730
+ type: chunk.type,
23731
+ data: "data" in chunk ? chunk.data : void 0
23732
+ }
23733
+ ]
23734
+ };
23735
+ return [...result.slice(0, -1), updatedMessage];
23736
+ }
23737
+ switch (chunk.type) {
23738
+ case "tripwire": {
23739
+ const newMessage = {
23740
+ id: `tripwire-${chunk.runId + Date.now()}`,
23741
+ role: "assistant",
23742
+ parts: [
23743
+ {
23744
+ type: "text",
23745
+ text: chunk.payload.reason
23746
+ }
23747
+ ],
23748
+ metadata: {
23749
+ ...metadata,
23750
+ status: "tripwire",
23751
+ tripwire: {
23752
+ retry: chunk.payload.retry,
23753
+ tripwirePayload: chunk.payload.metadata,
23754
+ processorId: chunk.payload.processorId
23755
+ }
23756
+ }
23757
+ };
23758
+ return [...result, newMessage];
23759
+ }
23760
+ case "start": {
23761
+ const newMessage = {
23762
+ id: typeof chunk.payload.messageId === "string" ? chunk.payload.messageId : `start-${chunk.runId + Date.now()}`,
23763
+ role: "assistant",
23764
+ parts: [],
23765
+ metadata
23766
+ };
23767
+ return [...result, newMessage];
23768
+ }
23769
+ case "text-start": {
23770
+ const lastMessage = result[result.length - 1];
23771
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
23772
+ const textId = chunk.payload.id || `text-${Date.now()}`;
23773
+ const newTextPart = {
23774
+ type: "text",
23775
+ text: "",
23776
+ state: "streaming",
23777
+ textId,
23778
+ providerMetadata: chunk.payload.providerMetadata
23779
+ };
23780
+ if (lastMessage.metadata?.completionResult) {
23781
+ const newMessage = {
23782
+ id: `start-${chunk.runId}-${Date.now()}`,
23783
+ role: "assistant",
23784
+ parts: [newTextPart],
23785
+ metadata
23786
+ };
23787
+ return [...result, newMessage];
23788
+ }
23789
+ const parts = [...lastMessage.parts];
23790
+ parts.push(newTextPart);
23791
+ return [
23792
+ ...result.slice(0, -1),
23793
+ {
23794
+ ...lastMessage,
23795
+ parts
23796
+ }
23797
+ ];
23798
+ }
23799
+ case "text-delta": {
23800
+ const lastMessage = result[result.length - 1];
23801
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
23802
+ const parts = [...lastMessage.parts];
23803
+ const textId = chunk.payload.id;
23804
+ let textPartIndex = textId ? parts.findLastIndex((part) => part.type === "text" && part.textId === textId) : -1;
23805
+ if (textPartIndex === -1) {
23806
+ textPartIndex = parts.findLastIndex(
23807
+ (part) => part.type === "text" && part.state === "streaming"
23808
+ );
23809
+ }
23810
+ if (textPartIndex === -1) {
23811
+ const newTextPart = {
23812
+ type: "text",
23813
+ text: chunk.payload.text,
23814
+ state: "streaming",
23815
+ textId,
23816
+ providerMetadata: chunk.payload.providerMetadata
23817
+ };
23818
+ parts.push(newTextPart);
23819
+ } else {
23820
+ const textPart = parts[textPartIndex];
23821
+ if (textPart.type === "text") {
23822
+ const extendedTextPart = textPart;
23823
+ const updatedTextPart = {
23824
+ ...extendedTextPart,
23825
+ text: extendedTextPart.text + chunk.payload.text,
23826
+ state: "streaming"
23827
+ };
23828
+ parts[textPartIndex] = updatedTextPart;
23829
+ }
23830
+ }
23831
+ return [
23832
+ ...result.slice(0, -1),
23833
+ {
23834
+ ...lastMessage,
23835
+ parts
23836
+ }
23837
+ ];
23838
+ }
23839
+ case "reasoning-delta": {
23840
+ const lastMessage = result[result.length - 1];
23841
+ if (!lastMessage || lastMessage.role !== "assistant") {
23842
+ const newMessage = {
23843
+ id: `reasoning-${chunk.runId + Date.now()}`,
23844
+ role: "assistant",
23845
+ parts: [
23846
+ {
23847
+ type: "reasoning",
23848
+ text: chunk.payload.text,
23849
+ state: "streaming",
23850
+ providerMetadata: chunk.payload.providerMetadata
23851
+ }
23852
+ ],
23853
+ metadata
23854
+ };
23855
+ return [...result, newMessage];
23856
+ }
23857
+ const parts = [...lastMessage.parts];
23858
+ let reasoningPartIndex = parts.findIndex((part) => part.type === "reasoning");
23859
+ if (reasoningPartIndex === -1) {
23860
+ parts.push({
23861
+ type: "reasoning",
23862
+ text: chunk.payload.text,
23863
+ state: "streaming",
23864
+ providerMetadata: chunk.payload.providerMetadata
23865
+ });
23866
+ } else {
23867
+ const reasoningPart = parts[reasoningPartIndex];
23868
+ if (reasoningPart.type === "reasoning") {
23869
+ parts[reasoningPartIndex] = {
23870
+ ...reasoningPart,
23871
+ text: reasoningPart.text + chunk.payload.text,
23872
+ state: "streaming"
23873
+ };
23874
+ }
23875
+ }
23876
+ return [
23877
+ ...result.slice(0, -1),
23878
+ {
23879
+ ...lastMessage,
23880
+ parts
23881
+ }
23882
+ ];
23883
+ }
23884
+ case "tool-call": {
23885
+ const lastMessage = result[result.length - 1];
23886
+ if (!lastMessage || lastMessage.role !== "assistant") {
23887
+ const newMessage = {
23888
+ id: `tool-call-${chunk.runId + Date.now()}`,
23889
+ role: "assistant",
23890
+ parts: [
23891
+ {
23892
+ type: "dynamic-tool",
23893
+ toolName: chunk.payload.toolName,
23894
+ toolCallId: chunk.payload.toolCallId,
23895
+ state: "input-available",
23896
+ input: chunk.payload.args,
23897
+ callProviderMetadata: chunk.payload.providerMetadata
23898
+ }
23899
+ ],
23900
+ metadata
23901
+ };
23902
+ return [...result, newMessage];
23903
+ }
23904
+ const parts = [...lastMessage.parts];
23905
+ parts.push({
23906
+ type: "dynamic-tool",
23907
+ toolName: chunk.payload.toolName,
23908
+ toolCallId: chunk.payload.toolCallId,
23909
+ state: "input-available",
23910
+ input: chunk.payload.args,
23911
+ callProviderMetadata: chunk.payload.providerMetadata
23912
+ });
23913
+ return [
23914
+ ...result.slice(0, -1),
23915
+ {
23916
+ ...lastMessage,
23917
+ parts
23918
+ }
23919
+ ];
23920
+ }
23921
+ case "tool-error":
23922
+ case "tool-result": {
23923
+ const lastMessage = result[result.length - 1];
23924
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
23925
+ const parts = [...lastMessage.parts];
23926
+ const toolPartIndex = parts.findIndex(
23927
+ (part) => (part.type === "dynamic-tool" || typeof part.type === "string" && part.type.startsWith("tool-")) && "toolCallId" in part && part.toolCallId === chunk.payload.toolCallId
23928
+ );
23929
+ if (toolPartIndex !== -1) {
23930
+ const toolPart = parts[toolPartIndex];
23931
+ if (toolPart.type === "dynamic-tool" || typeof toolPart.type === "string" && toolPart.type.startsWith("tool-")) {
23932
+ const toolName = "toolName" in toolPart && typeof toolPart.toolName === "string" ? toolPart.toolName : toolPart.type.startsWith("tool-") ? toolPart.type.substring(5) : "";
23933
+ const toolCallId = toolPart.toolCallId;
23934
+ if (chunk.type === "tool-result" && chunk.payload.isError || chunk.type === "tool-error") {
23935
+ const error = chunk.type === "tool-error" ? chunk.payload.error : chunk.payload.result;
23936
+ parts[toolPartIndex] = {
23937
+ type: "dynamic-tool",
23938
+ toolName,
23939
+ toolCallId,
23940
+ state: "output-error",
23941
+ input: toolPart.input,
23942
+ errorText: typeof error === "string" ? error : error instanceof Error ? error.message : error?.message ?? String(error),
23943
+ callProviderMetadata: chunk.payload.providerMetadata
23944
+ };
23945
+ } else {
23946
+ const isWorkflow = Boolean(chunk.payload.result?.result?.steps);
23947
+ const isAgent = chunk?.from === "AGENT";
23948
+ let output;
23949
+ if (isWorkflow) {
23950
+ output = chunk.payload.result?.result;
23951
+ } else if (isAgent) {
23952
+ output = parts[toolPartIndex].output ?? chunk.payload.result;
23953
+ } else {
23954
+ output = chunk.payload.result;
23955
+ }
23956
+ parts[toolPartIndex] = {
23957
+ type: "dynamic-tool",
23958
+ toolName,
23959
+ toolCallId,
23960
+ state: "output-available",
23961
+ input: toolPart.input,
23962
+ output,
23963
+ callProviderMetadata: chunk.payload.providerMetadata
23964
+ };
23965
+ }
23966
+ }
23967
+ }
23968
+ return [
23969
+ ...result.slice(0, -1),
23970
+ {
23971
+ ...lastMessage,
23972
+ parts
23973
+ }
23974
+ ];
23975
+ }
23976
+ case "tool-output": {
23977
+ const lastMessage = result[result.length - 1];
23978
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
23979
+ const parts = [...lastMessage.parts];
23980
+ const toolPartIndex = parts.findIndex(
23981
+ (part) => (part.type === "dynamic-tool" || typeof part.type === "string" && part.type.startsWith("tool-")) && "toolCallId" in part && part.toolCallId === chunk.payload.toolCallId
23982
+ );
23983
+ if (toolPartIndex !== -1) {
23984
+ const toolPart = parts[toolPartIndex];
23985
+ if (toolPart.type === "dynamic-tool" || typeof toolPart.type === "string" && toolPart.type.startsWith("tool-")) {
23986
+ const toolName = "toolName" in toolPart && typeof toolPart.toolName === "string" ? toolPart.toolName : typeof toolPart.type === "string" && toolPart.type.startsWith("tool-") ? toolPart.type.substring(5) : "";
23987
+ const toolCallId = toolPart.toolCallId;
23988
+ const input = toolPart.input;
23989
+ if (chunk.payload.output?.type?.startsWith("workflow-")) {
23990
+ const existingWorkflowState = toolPart.output || {};
23991
+ const updatedWorkflowState = mapWorkflowStreamChunkToWatchResult(
23992
+ existingWorkflowState,
23993
+ chunk.payload.output
23994
+ );
23995
+ parts[toolPartIndex] = {
23996
+ type: "dynamic-tool",
23997
+ toolName,
23998
+ toolCallId,
23999
+ state: "input-streaming",
24000
+ input,
24001
+ output: updatedWorkflowState
24002
+ };
24003
+ } else if (chunk.payload.output?.from === "AGENT" || chunk.payload.output?.from === "USER" && chunk.payload.output?.payload?.output?.type?.startsWith("workflow-")) {
24004
+ return toUIMessageFromAgent(chunk.payload.output, conversation, metadata, toolCallId, toolName);
24005
+ } else {
24006
+ const currentOutput = toolPart.output || [];
24007
+ const existingOutput = Array.isArray(currentOutput) ? currentOutput : [];
24008
+ parts[toolPartIndex] = {
24009
+ type: "dynamic-tool",
24010
+ toolName,
24011
+ toolCallId,
24012
+ state: "input-streaming",
24013
+ input,
24014
+ output: [...existingOutput, chunk.payload.output]
24015
+ };
24016
+ }
24017
+ }
24018
+ }
24019
+ return [
24020
+ ...result.slice(0, -1),
24021
+ {
24022
+ ...lastMessage,
24023
+ parts
24024
+ }
24025
+ ];
24026
+ }
24027
+ case "is-task-complete": {
24028
+ if (chunk.payload.suppressFeedback) return result;
24029
+ const feedback = formatStreamCompletionFeedback(
24030
+ {
24031
+ complete: chunk.payload.passed,
24032
+ scorers: chunk.payload.results,
24033
+ totalDuration: chunk.payload.duration,
24034
+ timedOut: chunk.payload.timedOut,
24035
+ completionReason: chunk.payload.reason
24036
+ },
24037
+ chunk.payload.maxIterationReached
24038
+ );
24039
+ const newMessage = {
24040
+ id: `is-task-complete-${chunk.runId + Date.now()}`,
24041
+ role: "assistant",
24042
+ parts: [
24043
+ {
24044
+ type: "text",
24045
+ text: feedback
24046
+ }
24047
+ ],
24048
+ metadata: {
24049
+ ...metadata,
24050
+ completionResult: {
24051
+ passed: chunk.payload.passed
24052
+ }
24053
+ }
24054
+ };
24055
+ return [...result, newMessage];
24056
+ }
24057
+ case "source": {
24058
+ const lastMessage = result[result.length - 1];
24059
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
24060
+ const parts = [...lastMessage.parts];
24061
+ if (chunk.payload.sourceType === "url") {
24062
+ parts.push({
24063
+ type: "source-url",
24064
+ sourceId: chunk.payload.id,
24065
+ url: chunk.payload.url || "",
24066
+ title: chunk.payload.title,
24067
+ providerMetadata: chunk.payload.providerMetadata
24068
+ });
24069
+ } else if (chunk.payload.sourceType === "document") {
24070
+ parts.push({
24071
+ type: "source-document",
24072
+ sourceId: chunk.payload.id,
24073
+ mediaType: chunk.payload.mimeType || "application/octet-stream",
24074
+ title: chunk.payload.title,
24075
+ filename: chunk.payload.filename,
24076
+ providerMetadata: chunk.payload.providerMetadata
24077
+ });
24078
+ }
24079
+ return [
24080
+ ...result.slice(0, -1),
24081
+ {
24082
+ ...lastMessage,
24083
+ parts
24084
+ }
24085
+ ];
24086
+ }
24087
+ case "file": {
24088
+ const lastMessage = result[result.length - 1];
24089
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
24090
+ const parts = [...lastMessage.parts];
24091
+ let url;
24092
+ if (typeof chunk.payload.data === "string") {
24093
+ url = chunk.payload.base64 ? `data:${chunk.payload.mimeType};base64,${chunk.payload.data}` : `data:${chunk.payload.mimeType},${encodeURIComponent(chunk.payload.data)}`;
24094
+ } else {
24095
+ const base64 = btoa(String.fromCharCode(...chunk.payload.data));
24096
+ url = `data:${chunk.payload.mimeType};base64,${base64}`;
24097
+ }
24098
+ parts.push({
24099
+ type: "file",
24100
+ mediaType: chunk.payload.mimeType,
24101
+ url,
24102
+ providerMetadata: chunk.payload.providerMetadata
24103
+ });
24104
+ return [
24105
+ ...result.slice(0, -1),
24106
+ {
24107
+ ...lastMessage,
24108
+ parts
24109
+ }
24110
+ ];
24111
+ }
24112
+ case "tool-call-approval": {
24113
+ const lastMessage = result[result.length - 1];
24114
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
24115
+ const lastRequireApprovalMetadata = lastMessage.metadata?.mode === "stream" ? lastMessage.metadata?.requireApprovalMetadata : {};
24116
+ return [
24117
+ ...result.slice(0, -1),
24118
+ {
24119
+ ...lastMessage,
24120
+ metadata: {
24121
+ ...lastMessage.metadata,
24122
+ mode: "stream",
24123
+ requireApprovalMetadata: {
24124
+ ...lastRequireApprovalMetadata,
24125
+ [chunk.payload.toolName]: {
24126
+ toolCallId: chunk.payload.toolCallId,
24127
+ toolName: chunk.payload.toolName,
24128
+ args: chunk.payload.args
24129
+ }
24130
+ }
24131
+ }
24132
+ }
24133
+ ];
24134
+ }
24135
+ case "tool-call-suspended": {
24136
+ const lastMessage = result[result.length - 1];
24137
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
24138
+ const lastSuspendedTools = lastMessage.metadata?.mode === "stream" ? lastMessage.metadata?.suspendedTools : {};
24139
+ return [
24140
+ ...result.slice(0, -1),
24141
+ {
24142
+ ...lastMessage,
24143
+ metadata: {
24144
+ ...lastMessage.metadata,
24145
+ mode: "stream",
24146
+ suspendedTools: {
24147
+ ...lastSuspendedTools,
24148
+ [chunk.payload.toolName]: {
24149
+ toolCallId: chunk.payload.toolCallId,
24150
+ toolName: chunk.payload.toolName,
24151
+ args: chunk.payload.args,
24152
+ suspendPayload: chunk.payload.suspendPayload
24153
+ }
24154
+ }
24155
+ }
24156
+ }
24157
+ ];
24158
+ }
24159
+ case "finish": {
24160
+ const lastMessage = result[result.length - 1];
24161
+ if (!lastMessage || lastMessage.role !== "assistant") return result;
24162
+ const parts = lastMessage.parts.map((part) => {
24163
+ if (typeof part === "object" && part !== null && "type" in part && "state" in part && part.state === "streaming") {
24164
+ if (part.type === "text" || part.type === "reasoning") {
24165
+ return { ...part, state: "done" };
24166
+ }
24167
+ }
24168
+ return part;
24169
+ });
24170
+ return [
24171
+ ...result.slice(0, -1),
24172
+ {
24173
+ ...lastMessage,
24174
+ parts
24175
+ }
24176
+ ];
24177
+ }
24178
+ case "error": {
24179
+ const newMessage = {
24180
+ id: `error-${chunk.runId + Date.now()}`,
24181
+ role: "assistant",
24182
+ parts: [
24183
+ {
24184
+ type: "text",
24185
+ text: typeof chunk.payload.error === "string" ? chunk.payload.error : JSON.stringify(chunk.payload.error)
24186
+ }
24187
+ ],
24188
+ metadata: {
24189
+ ...metadata,
24190
+ status: "error"
24191
+ }
24192
+ };
24193
+ return [...result, newMessage];
24194
+ }
24195
+ // For all other chunk types, return conversation unchanged
24196
+ default:
24197
+ return result;
24198
+ }
24199
+ };
24200
+ const toUIMessageFromAgent = (chunk, conversation, metadata, parentToolCallId, parentToolName) => {
24201
+ const lastMessage = conversation[conversation.length - 1];
24202
+ if (!lastMessage || lastMessage.role !== "assistant") return conversation;
24203
+ const parts = [...lastMessage.parts];
24204
+ if (chunk.type === "text-delta") {
24205
+ const agentChunk = chunk.payload;
24206
+ const toolPartIndex = parts.findIndex(
24207
+ (part) => part.type === "dynamic-tool" && (parentToolCallId && part.toolCallId === parentToolCallId || parentToolName && part.toolName === parentToolName)
24208
+ );
24209
+ if (toolPartIndex === -1) return conversation;
24210
+ const toolPart = parts[toolPartIndex];
24211
+ const childMessages = toolPart?.output?.childMessages || [];
24212
+ const lastChildMessage = childMessages[childMessages.length - 1];
24213
+ const textMessage = { type: "text", content: (lastChildMessage?.content || "") + agentChunk.text };
24214
+ const nextMessages = lastChildMessage?.type === "text" ? [...childMessages.slice(0, -1), textMessage] : [...childMessages, textMessage];
24215
+ parts[toolPartIndex] = {
24216
+ ...toolPart,
24217
+ output: {
24218
+ childMessages: nextMessages
24219
+ }
24220
+ };
24221
+ } else if (chunk.type === "tool-call") {
24222
+ const agentChunk = chunk.payload;
24223
+ const toolPartIndex = parts.findIndex(
24224
+ (part) => part.type === "dynamic-tool" && (parentToolCallId && part.toolCallId === parentToolCallId || parentToolName && part.toolName === parentToolName)
24225
+ );
24226
+ if (toolPartIndex === -1) return conversation;
24227
+ const toolPart = parts[toolPartIndex];
24228
+ const childMessages = toolPart?.output?.childMessages || [];
24229
+ parts[toolPartIndex] = {
24230
+ ...toolPart,
24231
+ output: {
24232
+ ...toolPart?.output,
24233
+ childMessages: [
24234
+ ...childMessages,
24235
+ {
24236
+ type: "tool",
24237
+ toolCallId: agentChunk.toolCallId,
24238
+ toolName: agentChunk.toolName,
24239
+ args: agentChunk.args
24240
+ }
24241
+ ]
24242
+ }
24243
+ };
24244
+ } else if (chunk.type === "tool-output") {
24245
+ const agentChunk = chunk.payload;
24246
+ const toolPartIndex = parts.findIndex(
24247
+ (part) => part.type === "dynamic-tool" && (parentToolCallId && part.toolCallId === parentToolCallId || parentToolName && part.toolName === parentToolName)
24248
+ );
24249
+ if (toolPartIndex === -1) return conversation;
24250
+ const toolPart = parts[toolPartIndex];
24251
+ if (agentChunk?.output?.type?.startsWith("workflow-")) {
24252
+ const childMessages = toolPart?.output?.childMessages || [];
24253
+ const lastToolIndex = childMessages.length - 1;
24254
+ const currentMessage = childMessages[lastToolIndex];
24255
+ const actualExistingWorkflowState = currentMessage?.toolOutput || {};
24256
+ const updatedWorkflowState = mapWorkflowStreamChunkToWatchResult(actualExistingWorkflowState, agentChunk.output);
24257
+ if (lastToolIndex >= 0 && childMessages[lastToolIndex]?.type === "tool") {
24258
+ parts[toolPartIndex] = {
24259
+ ...toolPart,
24260
+ output: {
24261
+ ...toolPart?.output,
24262
+ childMessages: [
24263
+ ...childMessages.slice(0, -1),
24264
+ {
24265
+ ...currentMessage,
24266
+ toolOutput: { ...updatedWorkflowState, runId: agentChunk.output.runId }
24267
+ }
24268
+ ]
24269
+ }
24270
+ };
24271
+ }
24272
+ }
24273
+ } else if (chunk.type === "tool-result") {
24274
+ const agentChunk = chunk.payload;
24275
+ const toolPartIndex = parts.findIndex(
24276
+ (part) => part.type === "dynamic-tool" && (parentToolCallId && part.toolCallId === parentToolCallId || parentToolName && part.toolName === parentToolName)
24277
+ );
24278
+ if (toolPartIndex === -1) return conversation;
24279
+ const toolPart = parts[toolPartIndex];
24280
+ const childMessages = toolPart?.output?.childMessages || [];
24281
+ const lastToolIndex = childMessages.length - 1;
24282
+ const isWorkflow = agentChunk?.toolName?.startsWith("workflow-");
24283
+ if (lastToolIndex >= 0 && childMessages[lastToolIndex]?.type === "tool") {
24284
+ parts[toolPartIndex] = {
24285
+ ...toolPart,
24286
+ output: {
24287
+ ...toolPart?.output,
24288
+ childMessages: [
24289
+ ...childMessages.slice(0, -1),
24290
+ {
24291
+ ...childMessages[lastToolIndex],
24292
+ toolOutput: isWorkflow ? { ...agentChunk.result?.result, runId: agentChunk.result?.runId } : agentChunk.result
24293
+ }
24294
+ ]
24295
+ }
24296
+ };
24297
+ }
24298
+ }
24299
+ return [
24300
+ ...conversation.slice(0, -1),
24301
+ {
24302
+ ...lastMessage,
24303
+ parts
24304
+ }
24305
+ ];
24306
+ };
24307
+
24308
+ const toAssistantUIMessage = (message) => {
24309
+ const extendedMessage = message;
24310
+ const content = message.parts.map((part) => {
24311
+ if (part.type === "text") {
24312
+ return {
24313
+ type: "text",
24314
+ text: part.text,
24315
+ metadata: message.metadata
24316
+ };
24317
+ }
24318
+ if (part.type === "reasoning") {
24319
+ return {
24320
+ type: "reasoning",
24321
+ text: part.text,
24322
+ metadata: message.metadata
24323
+ };
24324
+ }
24325
+ if (part.type === "source-url") {
24326
+ return {
24327
+ type: "source",
24328
+ sourceType: "url",
24329
+ id: part.sourceId,
24330
+ url: part.url,
24331
+ title: part.title,
24332
+ metadata: message.metadata
24333
+ };
24334
+ }
24335
+ if (part.type === "source-document") {
24336
+ return {
24337
+ type: "file",
24338
+ filename: part.filename,
24339
+ mimeType: part.mediaType,
24340
+ data: "",
24341
+ // Source documents don't have inline data
24342
+ metadata: message.metadata
24343
+ };
24344
+ }
24345
+ if (part.type === "file") {
24346
+ const type = part.mediaType.includes("image/") ? "image" : "file";
24347
+ if (type === "file") {
24348
+ return {
24349
+ type,
24350
+ mimeType: part.mediaType,
24351
+ data: part.url,
24352
+ // Use URL as data source
24353
+ metadata: message.metadata
24354
+ };
24355
+ }
24356
+ if (type === "image") {
24357
+ return {
24358
+ type,
24359
+ image: part.url,
24360
+ metadata: message.metadata
24361
+ };
24362
+ }
24363
+ }
24364
+ if (part.type === "dynamic-tool") {
24365
+ const baseToolCall = {
24366
+ type: "tool-call",
24367
+ toolCallId: part.toolCallId,
24368
+ toolName: part.toolName,
24369
+ argsText: JSON.stringify(part.input),
24370
+ args: part.input,
24371
+ metadata: message.metadata
24372
+ };
24373
+ if (part.state === "output-error" && "errorText" in part) {
24374
+ return { ...baseToolCall, result: part.errorText, isError: true };
24375
+ }
24376
+ if ("output" in part) {
24377
+ return { ...baseToolCall, result: part.output };
24378
+ }
24379
+ return baseToolCall;
24380
+ }
24381
+ if (part.type.startsWith("tool-") && part.state !== "input-available") {
24382
+ const toolName2 = "toolName" in part && typeof part.toolName === "string" ? part.toolName : part.type.substring(5);
24383
+ const { suspendedToolRunId, ...cleanInput } = "input" in part ? part.input : {};
24384
+ const baseToolCall = {
24385
+ type: "tool-call",
24386
+ toolCallId: "toolCallId" in part && typeof part.toolCallId === "string" ? part.toolCallId : "",
24387
+ toolName: toolName2,
24388
+ argsText: JSON.stringify(cleanInput ?? {}),
24389
+ args: cleanInput ?? {},
24390
+ metadata: message.metadata
24391
+ };
24392
+ if ("output" in part) {
24393
+ return { ...baseToolCall, result: part.output };
24394
+ } else if ("error" in part) {
24395
+ return { ...baseToolCall, result: part.error, isError: true };
24396
+ }
24397
+ return baseToolCall;
24398
+ }
24399
+ const toolName = "toolName" in part && typeof part.toolName === "string" ? part.toolName : part.type.startsWith("tool-") ? part.type.substring(5) : "";
24400
+ const requireApprovalMetadata = extendedMessage.metadata?.requireApprovalMetadata;
24401
+ const suspendedTools = extendedMessage.metadata?.suspendedTools;
24402
+ const partToolCallId = "toolCallId" in part && typeof part.toolCallId === "string" ? part.toolCallId : void 0;
24403
+ const suspensionData = toolName ? requireApprovalMetadata?.[toolName] ?? suspendedTools?.[toolName] : void 0;
24404
+ if (suspensionData) {
24405
+ const { suspendedToolRunId, ...cleanInput } = "input" in part ? part.input : {};
24406
+ return {
24407
+ type: "tool-call",
24408
+ toolCallId: partToolCallId,
24409
+ toolName,
24410
+ argsText: JSON.stringify(cleanInput ?? {}),
24411
+ args: cleanInput,
24412
+ metadata: extendedMessage.metadata
24413
+ };
24414
+ }
24415
+ if (part.type.startsWith("data-")) {
24416
+ return {
24417
+ type: "data",
24418
+ name: part.type.substring(5),
24419
+ // Extract name from 'data-{name}'
24420
+ data: part.data,
24421
+ metadata: message.metadata
24422
+ };
24423
+ }
24424
+ return {
24425
+ type: "text",
24426
+ text: "",
24427
+ metadata: message.metadata
24428
+ };
24429
+ });
24430
+ let status;
24431
+ if (message.role === "assistant" && content.length > 0) {
24432
+ const hasStreamingParts = message.parts.some(
24433
+ (part) => part.type === "text" && "state" in part && part.state === "streaming" || part.type === "reasoning" && "state" in part && part.state === "streaming"
24434
+ );
24435
+ const hasToolCalls = message.parts.some((part) => part.type === "dynamic-tool" || part.type.startsWith("tool-"));
24436
+ const hasInputAvailableTools = message.parts.some(
24437
+ (part) => part.type === "dynamic-tool" && part.state === "input-available"
24438
+ );
24439
+ const hasErrorTools = message.parts.some(
24440
+ (part) => part.type === "dynamic-tool" && part.state === "output-error" || part.type.startsWith("tool-") && "error" in part
24441
+ );
24442
+ if (hasStreamingParts) {
24443
+ status = { type: "running" };
24444
+ } else if (hasInputAvailableTools && hasToolCalls) {
24445
+ status = { type: "requires-action", reason: "tool-calls" };
24446
+ } else if (hasErrorTools) {
24447
+ status = { type: "incomplete", reason: "error" };
24448
+ } else {
24449
+ status = { type: "complete", reason: "stop" };
24434
24450
  }
24435
- lines.push("");
24436
- }
24437
- if (result.complete) {
24438
- lines.push("\n\n\u2705 The task is complete.");
24439
- } else if (maxIterationReached) {
24440
- lines.push("\n\n\u26A0\uFE0F Max iterations reached.");
24441
- } else {
24442
- lines.push("\n\n\u{1F504} Will continue working on the task.");
24443
24451
  }
24444
- return lines.join("\n");
24445
- }
24446
- z$2.object({
24447
- isComplete: z$2.boolean().describe("Whether the task is complete"),
24448
- completionReason: z$2.string().describe("Explanation of why the task is or is not complete"),
24449
- finalResult: z$2.string().optional().describe("The final result text to return to the user. omit if primitive result is sufficient")
24450
- });
24451
- z$2.object({
24452
- finalResult: z$2.string().optional().describe("The final result text to return to the user, omit if primitive result is sufficient")
24453
- });
24454
- z10.enum(["agent", "workflow", "none", "tool"]);
24455
-
24456
- // src/agent/agent-legacy.ts
24457
- __toESM$3(require_fast_deep_equal());
24452
+ const threadMessage = {
24453
+ role: message.role,
24454
+ content,
24455
+ id: message.id,
24456
+ createdAt: extendedMessage.createdAt,
24457
+ status,
24458
+ attachments: extendedMessage.experimental_attachments
24459
+ };
24460
+ return threadMessage;
24461
+ };
24458
24462
 
24459
- // src/agent/workflows/prepare-stream/prepare-memory-step.ts
24460
- __toESM$3(require_fast_deep_equal());
24461
- var coreToolSchema = z$2.object({
24462
- id: z$2.string().optional(),
24463
- description: z$2.string().optional(),
24464
- parameters: z$2.union([
24465
- z$2.record(z$2.string(), z$2.any()),
24466
- // JSON Schema as object
24467
- z$2.any()
24468
- // Zod schema or other schema types - validated at tool execution
24469
- ]),
24470
- outputSchema: z$2.union([z$2.record(z$2.string(), z$2.any()), z$2.any()]).optional(),
24471
- execute: z$2.optional(z$2.function(z$2.tuple([z$2.any(), z$2.any()]), z$2.promise(z$2.any()))),
24472
- toModelOutput: z$2.optional(z$2.function(z$2.tuple([z$2.any()]), z$2.any())),
24473
- type: z$2.union([z$2.literal("function"), z$2.literal("provider-defined"), z$2.undefined()]).optional(),
24474
- args: z$2.record(z$2.string(), z$2.any()).optional()
24475
- });
24476
- var storageThreadSchema = z$2.object({
24477
- id: z$2.string(),
24478
- title: z$2.string().optional(),
24479
- resourceId: z$2.string(),
24480
- createdAt: z$2.date(),
24481
- updatedAt: z$2.date(),
24482
- metadata: z$2.record(z$2.string(), z$2.any()).optional()
24483
- });
24484
- z$2.object({
24485
- convertedTools: z$2.record(z$2.string(), coreToolSchema)
24486
- });
24487
- z$2.object({
24488
- threadExists: z$2.boolean(),
24489
- thread: storageThreadSchema.optional(),
24490
- messageList: z$2.instanceof(MessageList$1),
24491
- /** Shared processor states map that persists across loop iterations for both input and output processors */
24492
- processorStates: z$2.instanceof(Map),
24493
- /** Tripwire data when input processor triggered abort */
24494
- tripwire: z$2.object({
24495
- reason: z$2.string(),
24496
- retry: z$2.boolean().optional(),
24497
- metadata: z$2.unknown().optional(),
24498
- processorId: z$2.string().optional()
24499
- }).optional()
24500
- });
24501
- var DEFAULT_CACHE_MAX_SIZE = 1e3;
24502
- new L({
24503
- max: DEFAULT_CACHE_MAX_SIZE
24504
- });
24463
+ const resolveInitialMessages = (messages) => {
24464
+ const messagesLength = messages.length;
24465
+ return messages.map((message, index) => {
24466
+ const networkPart = message.parts.find(
24467
+ (part) => typeof part === "object" && part !== null && "type" in part && part.type === "text" && "text" in part && typeof part.text === "string" && part.text.includes('"isNetwork":true')
24468
+ );
24469
+ if (networkPart && networkPart.type === "text") {
24470
+ try {
24471
+ const json = JSON.parse(networkPart.text);
24472
+ if (json.isNetwork === true) {
24473
+ const selectionReason = json.selectionReason || "";
24474
+ const primitiveType = json.primitiveType || "";
24475
+ const primitiveId = json.primitiveId || "";
24476
+ const finalResult = json.finalResult;
24477
+ const messages2 = finalResult?.messages || [];
24478
+ const childMessages = [];
24479
+ const toolResultMap = /* @__PURE__ */ new Map();
24480
+ for (const msg of messages2) {
24481
+ if (Array.isArray(msg.content)) {
24482
+ for (const part of msg.content) {
24483
+ if (typeof part === "object" && part.type === "tool-result") {
24484
+ toolResultMap.set(part.toolCallId, part);
24485
+ }
24486
+ }
24487
+ }
24488
+ }
24489
+ for (const msg of messages2) {
24490
+ if (msg.type === "tool-call" && Array.isArray(msg.content)) {
24491
+ for (const part of msg.content) {
24492
+ if (typeof part === "object" && part.type === "tool-call") {
24493
+ const toolCallContent = part;
24494
+ const toolResult = toolResultMap.get(toolCallContent.toolCallId);
24495
+ const isWorkflow = Boolean(toolResult?.result?.result?.steps);
24496
+ childMessages.push({
24497
+ type: "tool",
24498
+ toolCallId: toolCallContent.toolCallId,
24499
+ toolName: toolCallContent.toolName,
24500
+ args: toolCallContent.args,
24501
+ toolOutput: isWorkflow ? toolResult?.result?.result : toolResult?.result
24502
+ });
24503
+ }
24504
+ }
24505
+ }
24506
+ }
24507
+ if (finalResult && finalResult.text) {
24508
+ childMessages.push({
24509
+ type: "text",
24510
+ content: finalResult.text
24511
+ });
24512
+ }
24513
+ const result = primitiveType === "tool" ? finalResult?.result : {
24514
+ childMessages,
24515
+ result: finalResult?.text || ""
24516
+ };
24517
+ const nextMessage = {
24518
+ role: "assistant",
24519
+ parts: [
24520
+ {
24521
+ type: "dynamic-tool",
24522
+ toolCallId: primitiveId,
24523
+ toolName: primitiveId,
24524
+ state: "output-available",
24525
+ input: json.input,
24526
+ output: result
24527
+ }
24528
+ ],
24529
+ id: message.id,
24530
+ metadata: {
24531
+ ...message.metadata,
24532
+ mode: "network",
24533
+ selectionReason,
24534
+ agentInput: json.input,
24535
+ hasMoreMessages: index < messagesLength - 1,
24536
+ from: primitiveType === "agent" ? "AGENT" : primitiveType === "tool" ? "TOOL" : "WORKFLOW"
24537
+ }
24538
+ };
24539
+ return nextMessage;
24540
+ }
24541
+ } catch (error) {
24542
+ return message;
24543
+ }
24544
+ }
24545
+ const extendedMessage = message;
24546
+ const pendingToolApprovals = extendedMessage.metadata?.pendingToolApprovals;
24547
+ if (pendingToolApprovals && typeof pendingToolApprovals === "object") {
24548
+ return {
24549
+ ...message,
24550
+ metadata: {
24551
+ ...message.metadata,
24552
+ mode: "stream",
24553
+ requireApprovalMetadata: pendingToolApprovals
24554
+ }
24555
+ };
24556
+ }
24557
+ const suspendedTools = extendedMessage.metadata?.suspendedTools;
24558
+ if (suspendedTools && typeof suspendedTools === "object") {
24559
+ return {
24560
+ ...message,
24561
+ metadata: {
24562
+ ...message.metadata,
24563
+ mode: "stream",
24564
+ suspendedTools
24565
+ }
24566
+ };
24567
+ }
24568
+ return message;
24569
+ })?.filter((message) => {
24570
+ const completionModes = ["generate", "stream", "network"];
24571
+ if (message.role === "assistant" && completionModes.includes(message?.metadata?.mode)) {
24572
+ const meta = message.metadata;
24573
+ if (meta?.isTaskCompleteResult?.suppressFeedback || meta?.completionResult?.suppressFeedback) {
24574
+ return false;
24575
+ }
24576
+ return true;
24577
+ }
24578
+ return true;
24579
+ });
24580
+ };
24581
+ const resolveToChildMessages = (messages) => {
24582
+ const assistantMessage = messages.find((message) => message.role === "assistant");
24583
+ if (!assistantMessage) return [];
24584
+ const parts = assistantMessage.parts;
24585
+ let childMessages = [];
24586
+ for (const part of parts) {
24587
+ const toolPart = part;
24588
+ if (part.type.startsWith("tool-")) {
24589
+ const toolName = part.type.substring("tool-".length);
24590
+ const isWorkflow = toolName.startsWith("workflow-");
24591
+ childMessages.push({
24592
+ type: "tool",
24593
+ toolCallId: toolPart.toolCallId,
24594
+ toolName,
24595
+ args: toolPart.input,
24596
+ toolOutput: isWorkflow ? { ...toolPart.output?.result, runId: toolPart.output?.runId } : toolPart.output
24597
+ });
24598
+ }
24599
+ if (part.type === "text") {
24600
+ childMessages.push({
24601
+ type: "text",
24602
+ content: toolPart.text
24603
+ });
24604
+ }
24605
+ }
24606
+ return childMessages;
24607
+ };
24505
24608
 
24506
24609
  class AISdkNetworkTransformer {
24507
24610
  transform({ chunk, conversation, metadata }) {
@@ -24519,6 +24622,7 @@ class AISdkNetworkTransformer {
24519
24622
  return this.handleToolConversation(chunk, newConversation, metadata);
24520
24623
  }
24521
24624
  if (chunk.type === "network-validation-end") {
24625
+ if (chunk.payload.suppressFeedback) return newConversation;
24522
24626
  const feedback = formatCompletionFeedback(
24523
24627
  {
24524
24628
  complete: chunk.payload.passed,
@@ -26181,4 +26285,4 @@ function useCancelWorkflowRun() {
26181
26285
  }
26182
26286
 
26183
26287
  export { MessageUsages as $, EntryTitleClass as A, EntryTitle as B, CodeBlockClass as C, CodeBlock as D, Entity as E, CodeCopyButton as F, Icon as G, IconButtonClass as H, IconSizes as I, IconButton as J, AgentIcon as K, ToolsIcon as L, MastraReactProvider as M, Tooltip as N, TooltipContentClass as O, TooltipContent as P, TooltipTrigger as Q, MessageClass as R, Message as S, ToolApprovalClass as T, MessageContentClass as U, MessageContent as V, WorkflowIcon as W, MessageActionsClass as X, MessageActions as Y, MessageUsagesClass as Z, __commonJS$3 as _, __require2 as a, MessageUsageClass as a0, MessageUsage as a1, MessageUsageEntryClass as a2, MessageUsageEntry as a3, MessageUsageValueClass as a4, MessageUsageValue as a5, MessageListClass as a6, MessageList as a7, MessageStreamingClass as a8, MessageStreaming as a9, useCreateWorkflowRun as aa, useCancelWorkflowRun as ab, useStreamWorkflow as ac, useChat as b, resolveToChildMessages as c, toAssistantUIMessage as d, useEntity as e, EntityTriggerClass as f, EntityTriggerVariantClasses as g, EntityTrigger as h, EntityContentClass as i, EntityContent as j, EntityCaret as k, ToolApproval as l, mapWorkflowStreamChunkToWatchResult as m, ToolApprovalTitleClass as n, ToolApprovalTitle as o, ToolApprovalHeaderClass as p, ToolApprovalHeader as q, require_token_error as r, ToolApprovalContentClass as s, toUIMessage as t, useMastraClient as u, ToolApprovalContent as v, ToolApprovalActionsClass as w, ToolApprovalActions as x, EntryClass as y, Entry as z };
26184
- //# sourceMappingURL=index-DKjW1068.js.map
26288
+ //# sourceMappingURL=index-D3vBmpgO.js.map