@mastra/ai-sdk 1.0.0-beta.1 → 1.0.0-beta.10
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.
- package/CHANGELOG.md +316 -0
- package/README.md +60 -0
- package/dist/__tests__/__fixtures__/network.stream.d.ts +2329 -0
- package/dist/__tests__/__fixtures__/network.stream.d.ts.map +1 -0
- package/dist/_types/@ai-sdk_provider/dist/index.d.ts +1719 -0
- package/dist/chat-route.d.ts +90 -3
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/chunk-DES3K4SD.cjs +17 -0
- package/dist/chunk-DES3K4SD.cjs.map +1 -0
- package/dist/chunk-KYQEM4AK.js +294 -0
- package/dist/chunk-KYQEM4AK.js.map +1 -0
- package/dist/chunk-TD7TJ4N5.cjs +297 -0
- package/dist/chunk-TD7TJ4N5.cjs.map +1 -0
- package/dist/chunk-VUNV25KB.js +14 -0
- package/dist/chunk-VUNV25KB.js.map +1 -0
- package/dist/convert-messages.d.ts +83 -3
- package/dist/convert-messages.d.ts.map +1 -1
- package/dist/convert-streams.d.ts +64 -1
- package/dist/convert-streams.d.ts.map +1 -1
- package/dist/helpers.d.ts +9 -3
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +3864 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3840 -117
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts +157 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/network-route.d.ts +63 -2
- package/dist/network-route.d.ts.map +1 -1
- package/dist/token-5ZTQBFQ6.cjs +63 -0
- package/dist/token-5ZTQBFQ6.cjs.map +1 -0
- package/dist/token-UOO4N54I.js +61 -0
- package/dist/token-UOO4N54I.js.map +1 -0
- package/dist/token-util-DUN56AZR.cjs +9 -0
- package/dist/token-util-DUN56AZR.cjs.map +1 -0
- package/dist/token-util-JCUK3SCT.js +7 -0
- package/dist/token-util-JCUK3SCT.js.map +1 -0
- package/dist/transformers.d.ts +136 -10
- package/dist/transformers.d.ts.map +1 -1
- package/dist/ui.cjs +0 -1
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.js +0 -1
- package/dist/ui.js.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/workflow-route.d.ts +68 -1
- package/dist/workflow-route.d.ts.map +1 -1
- package/package.json +9 -7
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { LanguageModelV2, LanguageModelV2Middleware } from './_types/@ai-sdk_provider/dist/index.js';
|
|
2
|
+
import type { MemoryConfig, SemanticRecall as SemanticRecallConfig } from '@mastra/core/memory';
|
|
3
|
+
import type { InputProcessor, OutputProcessor } from '@mastra/core/processors';
|
|
4
|
+
import type { MemoryStorage } from '@mastra/core/storage';
|
|
5
|
+
import type { MastraEmbeddingModel, MastraVector } from '@mastra/core/vector';
|
|
6
|
+
/**
|
|
7
|
+
* Memory context for processors that need thread/resource info
|
|
8
|
+
*/
|
|
9
|
+
export interface ProcessorMemoryContext {
|
|
10
|
+
/** Thread ID for conversation persistence */
|
|
11
|
+
threadId?: string;
|
|
12
|
+
/** Resource ID (user/session identifier) */
|
|
13
|
+
resourceId?: string;
|
|
14
|
+
/** Memory configuration options */
|
|
15
|
+
config?: MemoryConfig;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Options for creating processor middleware
|
|
19
|
+
*/
|
|
20
|
+
export interface ProcessorMiddlewareOptions {
|
|
21
|
+
/** Input processors to run before the LLM call */
|
|
22
|
+
inputProcessors?: InputProcessor[];
|
|
23
|
+
/** Output processors to run on the LLM response */
|
|
24
|
+
outputProcessors?: OutputProcessor[];
|
|
25
|
+
/** Memory context for processors that need thread/resource info */
|
|
26
|
+
memory?: ProcessorMemoryContext;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Semantic recall configuration with required vector and embedder.
|
|
30
|
+
* Inherits JSDoc from SemanticRecall type in memory/types.ts.
|
|
31
|
+
*/
|
|
32
|
+
export type WithMastraSemanticRecallOptions = SemanticRecallConfig & {
|
|
33
|
+
/** Vector store for semantic search (required) */
|
|
34
|
+
vector: MastraVector;
|
|
35
|
+
/** Embedder for generating query embeddings (required) */
|
|
36
|
+
embedder: MastraEmbeddingModel<string>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Memory configuration for withMastra
|
|
40
|
+
*/
|
|
41
|
+
export interface WithMastraMemoryOptions {
|
|
42
|
+
/** Storage adapter for message persistence (required) */
|
|
43
|
+
storage: MemoryStorage;
|
|
44
|
+
/** Thread ID for conversation persistence (required) */
|
|
45
|
+
threadId: string;
|
|
46
|
+
/** Resource ID (user/session identifier) */
|
|
47
|
+
resourceId?: string;
|
|
48
|
+
/** Number of recent messages to retrieve, or false to disable */
|
|
49
|
+
lastMessages?: number | false;
|
|
50
|
+
/** Semantic recall configuration (RAG-based memory retrieval) */
|
|
51
|
+
semanticRecall?: WithMastraSemanticRecallOptions;
|
|
52
|
+
/** Working memory configuration (persistent user data) */
|
|
53
|
+
workingMemory?: MemoryConfig['workingMemory'];
|
|
54
|
+
/** Read-only mode - prevents saving new messages */
|
|
55
|
+
readOnly?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Options for withMastra wrapper
|
|
59
|
+
*/
|
|
60
|
+
export interface WithMastraOptions {
|
|
61
|
+
/** Memory configuration - enables automatic message history persistence */
|
|
62
|
+
memory?: WithMastraMemoryOptions;
|
|
63
|
+
/** Input processors to run before the LLM call */
|
|
64
|
+
inputProcessors?: InputProcessor[];
|
|
65
|
+
/** Output processors to run on the LLM response */
|
|
66
|
+
outputProcessors?: OutputProcessor[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Wraps a language model with Mastra capabilities including memory and processors.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // With message history (auto-creates MessageHistory processor)
|
|
74
|
+
* import { openai } from '@ai-sdk/openai';
|
|
75
|
+
* import { withMastra } from '@mastra/ai-sdk';
|
|
76
|
+
* import { LibSQLStore } from '@mastra/libsql';
|
|
77
|
+
*
|
|
78
|
+
* const storage = new LibSQLStore({ url: 'file:memory.db' });
|
|
79
|
+
* await storage.init();
|
|
80
|
+
*
|
|
81
|
+
* const model = withMastra(openai('gpt-4o'), {
|
|
82
|
+
* memory: {
|
|
83
|
+
* storage,
|
|
84
|
+
* threadId: 'thread-123',
|
|
85
|
+
* resourceId: 'user-456',
|
|
86
|
+
* lastMessages: 10,
|
|
87
|
+
* },
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* const { text } = await generateText({ model, prompt: 'Hello' });
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // With semantic recall (RAG-based memory)
|
|
96
|
+
* const model = withMastra(openai('gpt-4o'), {
|
|
97
|
+
* memory: {
|
|
98
|
+
* storage,
|
|
99
|
+
* threadId: 'thread-123',
|
|
100
|
+
* semanticRecall: {
|
|
101
|
+
* vector: pinecone,
|
|
102
|
+
* embedder: openai.embedding('text-embedding-3-small'),
|
|
103
|
+
* topK: 5,
|
|
104
|
+
* messageRange: 2, // Include 2 messages before/after each match
|
|
105
|
+
* },
|
|
106
|
+
* },
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // With working memory (persistent user data)
|
|
113
|
+
* const model = withMastra(openai('gpt-4o'), {
|
|
114
|
+
* memory: {
|
|
115
|
+
* storage,
|
|
116
|
+
* threadId: 'thread-123',
|
|
117
|
+
* workingMemory: {
|
|
118
|
+
* enabled: true,
|
|
119
|
+
* template: '# User Profile\n- **Name**:\n- **Preferences**:',
|
|
120
|
+
* },
|
|
121
|
+
* },
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* // With custom processors
|
|
128
|
+
* const model = withMastra(openai('gpt-4o'), {
|
|
129
|
+
* inputProcessors: [myInputProcessor],
|
|
130
|
+
* outputProcessors: [myOutputProcessor],
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function withMastra(model: LanguageModelV2, options?: WithMastraOptions): LanguageModelV2;
|
|
135
|
+
/**
|
|
136
|
+
* Creates AI SDK middleware that runs Mastra processors on input/output.
|
|
137
|
+
* For a simpler API, use `withMastra` instead.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* import { wrapLanguageModel, generateText } from 'ai';
|
|
142
|
+
* import { openai } from '@ai-sdk/openai';
|
|
143
|
+
* import { createProcessorMiddleware } from '@mastra/ai-sdk';
|
|
144
|
+
*
|
|
145
|
+
* const model = wrapLanguageModel({
|
|
146
|
+
* model: openai('gpt-4o'),
|
|
147
|
+
* middleware: createProcessorMiddleware({
|
|
148
|
+
* inputProcessors: [myProcessor],
|
|
149
|
+
* outputProcessors: [myProcessor],
|
|
150
|
+
* }),
|
|
151
|
+
* });
|
|
152
|
+
*
|
|
153
|
+
* const { text } = await generateText({ model, prompt: 'Hello' });
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare function createProcessorMiddleware(options: ProcessorMiddlewareOptions): LanguageModelV2Middleware;
|
|
157
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EAG1B,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhG,OAAO,KAAK,EACV,c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AChC,2EAA2E;IAC3E,MAAM,CAAC,EAAE,uBAAuB,CAAC;IACjC,kDAAkD;IAClD,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,iBAAsB,GAAG,eAAe,CA4EnG;AAgBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,yBAAyB,CA4QxG"}
|
package/dist/network-route.d.ts
CHANGED
|
@@ -1,14 +1,75 @@
|
|
|
1
1
|
import type { AgentExecutionOptions } from '@mastra/core/agent';
|
|
2
|
+
import type { MessageListInput } from '@mastra/core/agent/message-list';
|
|
3
|
+
import type { Mastra } from '@mastra/core/mastra';
|
|
2
4
|
import { registerApiRoute } from '@mastra/core/server';
|
|
3
5
|
import type { OutputSchema } from '@mastra/core/stream';
|
|
6
|
+
import type { InferUIMessageChunk, UIMessage } from 'ai';
|
|
7
|
+
export type NetworkStreamHandlerParams<OUTPUT extends OutputSchema = undefined> = AgentExecutionOptions<OUTPUT> & {
|
|
8
|
+
messages: MessageListInput;
|
|
9
|
+
};
|
|
10
|
+
export type NetworkStreamHandlerOptions<OUTPUT extends OutputSchema = undefined> = {
|
|
11
|
+
mastra: Mastra;
|
|
12
|
+
agentId: string;
|
|
13
|
+
params: NetworkStreamHandlerParams<OUTPUT>;
|
|
14
|
+
defaultOptions?: AgentExecutionOptions<OUTPUT>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Framework-agnostic handler for streaming agent network execution in AI SDK-compatible format.
|
|
18
|
+
* Use this function directly when you need to handle network streaming outside of Hono or Mastra's own apiRoutes feature.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // Next.js App Router
|
|
23
|
+
* import { handleNetworkStream } from '@mastra/ai-sdk';
|
|
24
|
+
* import { createUIMessageStreamResponse } from 'ai';
|
|
25
|
+
* import { mastra } from '@/src/mastra';
|
|
26
|
+
*
|
|
27
|
+
* export async function POST(req: Request) {
|
|
28
|
+
* const params = await req.json();
|
|
29
|
+
* const stream = await handleNetworkStream({
|
|
30
|
+
* mastra,
|
|
31
|
+
* agentId: 'routingAgent',
|
|
32
|
+
* params,
|
|
33
|
+
* });
|
|
34
|
+
* return createUIMessageStreamResponse({ stream });
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function handleNetworkStream<UI_MESSAGE extends UIMessage, OUTPUT extends OutputSchema = undefined>({ mastra, agentId, params, defaultOptions, }: NetworkStreamHandlerOptions<OUTPUT>): Promise<ReadableStream<InferUIMessageChunk<UI_MESSAGE>>>;
|
|
4
39
|
export type NetworkRouteOptions<OUTPUT extends OutputSchema = undefined> = {
|
|
5
40
|
path: `${string}:agentId${string}`;
|
|
6
41
|
agent?: never;
|
|
7
|
-
defaultOptions?: AgentExecutionOptions<OUTPUT
|
|
42
|
+
defaultOptions?: AgentExecutionOptions<OUTPUT>;
|
|
8
43
|
} | {
|
|
9
44
|
path: string;
|
|
10
45
|
agent: string;
|
|
11
|
-
defaultOptions?: AgentExecutionOptions<OUTPUT
|
|
46
|
+
defaultOptions?: AgentExecutionOptions<OUTPUT>;
|
|
12
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Creates a network route handler for streaming agent network execution using the AI SDK-compatible format.
|
|
50
|
+
*
|
|
51
|
+
* This function registers an HTTP POST endpoint that accepts messages, executes an agent network, and streams the response back to the client in AI SDK-compatible format. Agent networks allow a routing agent to delegate tasks to other agents.
|
|
52
|
+
*
|
|
53
|
+
* @param {NetworkRouteOptions} options - Configuration options for the network route
|
|
54
|
+
* @param {string} [options.path='/network/:agentId'] - The route path. Include `:agentId` for dynamic routing
|
|
55
|
+
* @param {string} [options.agent] - Fixed agent ID when not using dynamic routing
|
|
56
|
+
* @param {AgentExecutionOptions} [options.defaultOptions] - Default options passed to agent execution
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Dynamic agent routing
|
|
60
|
+
* networkRoute({
|
|
61
|
+
* path: '/network/:agentId',
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Fixed agent with custom path
|
|
66
|
+
* networkRoute({
|
|
67
|
+
* path: '/api/orchestrator',
|
|
68
|
+
* agent: 'router-agent',
|
|
69
|
+
* defaultOptions: {
|
|
70
|
+
* maxSteps: 10,
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
13
74
|
export declare function networkRoute<OUTPUT extends OutputSchema = undefined>({ path, agent, defaultOptions, }: NetworkRouteOptions<OUTPUT>): ReturnType<typeof registerApiRoute>;
|
|
14
75
|
//# sourceMappingURL=network-route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-route.d.ts","sourceRoot":"","sources":["../src/network-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"network-route.d.ts","sourceRoot":"","sources":["../src/network-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,K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AY,GAAG,SAAS,EAAE,EACpE,IAA0B,EAC1B,KAAK,EACL,cAAc,GACf,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAyGnE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTD7TJ4N5_cjs = require('./chunk-TD7TJ4N5.cjs');
|
|
4
|
+
var chunkDES3K4SD_cjs = require('./chunk-DES3K4SD.cjs');
|
|
5
|
+
|
|
6
|
+
// ../../node_modules/.pnpm/@vercel+oidc@3.0.3/node_modules/@vercel/oidc/dist/token.js
|
|
7
|
+
var require_token = chunkDES3K4SD_cjs.__commonJS({
|
|
8
|
+
"../../node_modules/.pnpm/@vercel+oidc@3.0.3/node_modules/@vercel/oidc/dist/token.js"(exports, module) {
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var token_exports = {};
|
|
27
|
+
__export(token_exports, {
|
|
28
|
+
refreshToken: () => refreshToken
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(token_exports);
|
|
31
|
+
var import_token_error = chunkTD7TJ4N5_cjs.require_token_error();
|
|
32
|
+
var import_token_util = chunkTD7TJ4N5_cjs.require_token_util();
|
|
33
|
+
async function refreshToken() {
|
|
34
|
+
const { projectId, teamId } = (0, import_token_util.findProjectInfo)();
|
|
35
|
+
let maybeToken = (0, import_token_util.loadToken)(projectId);
|
|
36
|
+
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token))) {
|
|
37
|
+
const authToken = (0, import_token_util.getVercelCliToken)();
|
|
38
|
+
if (!authToken) {
|
|
39
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
40
|
+
"Failed to refresh OIDC token: login to vercel cli"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if (!projectId) {
|
|
44
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
45
|
+
"Failed to refresh OIDC token: project id not found"
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
|
|
49
|
+
if (!maybeToken) {
|
|
50
|
+
throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
|
|
51
|
+
}
|
|
52
|
+
(0, import_token_util.saveToken)(maybeToken, projectId);
|
|
53
|
+
}
|
|
54
|
+
process.env.VERCEL_OIDC_TOKEN = maybeToken.token;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
var token5ZTQBFQ6 = require_token();
|
|
60
|
+
|
|
61
|
+
module.exports = token5ZTQBFQ6;
|
|
62
|
+
//# sourceMappingURL=token-5ZTQBFQ6.cjs.map
|
|
63
|
+
//# sourceMappingURL=token-5ZTQBFQ6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@vercel+oidc@3.0.3/node_modules/@vercel/oidc/dist/token.js"],"names":["__common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W,KAAA;AAC3C,MAAA;AAAA,IACF;AAAA,EAAA;AAAA,CAAA,CAAA","file":"token-5ZTQBFQ6.cjs","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_exports = {};\n__export(token_exports, {\n refreshToken: () => refreshToken\n});\nmodule.exports = __toCommonJS(token_exports);\nvar import_token_error = require(\"./token-error\");\nvar import_token_util = require(\"./token-util\");\nasync function refreshToken() {\n const { projectId, teamId } = (0, import_token_util.findProjectInfo)();\n let maybeToken = (0, import_token_util.loadToken)(projectId);\n if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token))) {\n const authToken = (0, import_token_util.getVercelCliToken)();\n if (!authToken) {\n throw new import_token_error.VercelOidcTokenError(\n \"Failed to refresh OIDC token: login to vercel cli\"\n );\n }\n if (!projectId) {\n throw new import_token_error.VercelOidcTokenError(\n \"Failed to refresh OIDC token: project id not found\"\n );\n }\n maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);\n if (!maybeToken) {\n throw new import_token_error.VercelOidcTokenError(\"Failed to refresh OIDC token\");\n }\n (0, import_token_util.saveToken)(maybeToken, projectId);\n }\n process.env.VERCEL_OIDC_TOKEN = maybeToken.token;\n return;\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n refreshToken\n});\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { require_token_error, require_token_util } from './chunk-KYQEM4AK.js';
|
|
2
|
+
import { __commonJS } from './chunk-VUNV25KB.js';
|
|
3
|
+
|
|
4
|
+
// ../../node_modules/.pnpm/@vercel+oidc@3.0.3/node_modules/@vercel/oidc/dist/token.js
|
|
5
|
+
var require_token = __commonJS({
|
|
6
|
+
"../../node_modules/.pnpm/@vercel+oidc@3.0.3/node_modules/@vercel/oidc/dist/token.js"(exports, module) {
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var token_exports = {};
|
|
25
|
+
__export(token_exports, {
|
|
26
|
+
refreshToken: () => refreshToken
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(token_exports);
|
|
29
|
+
var import_token_error = require_token_error();
|
|
30
|
+
var import_token_util = require_token_util();
|
|
31
|
+
async function refreshToken() {
|
|
32
|
+
const { projectId, teamId } = (0, import_token_util.findProjectInfo)();
|
|
33
|
+
let maybeToken = (0, import_token_util.loadToken)(projectId);
|
|
34
|
+
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token))) {
|
|
35
|
+
const authToken = (0, import_token_util.getVercelCliToken)();
|
|
36
|
+
if (!authToken) {
|
|
37
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
38
|
+
"Failed to refresh OIDC token: login to vercel cli"
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if (!projectId) {
|
|
42
|
+
throw new import_token_error.VercelOidcTokenError(
|
|
43
|
+
"Failed to refresh OIDC token: project id not found"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
|
|
47
|
+
if (!maybeToken) {
|
|
48
|
+
throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
|
|
49
|
+
}
|
|
50
|
+
(0, import_token_util.saveToken)(maybeToken, projectId);
|
|
51
|
+
}
|
|
52
|
+
process.env.VERCEL_OIDC_TOKEN = maybeToken.token;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
var tokenUOO4N54I = require_token();
|
|
58
|
+
|
|
59
|
+
export { tokenUOO4N54I as default };
|
|
60
|
+
//# sourceMappingURL=token-UOO4N54I.js.map
|
|
61
|
+
//# sourceMappingURL=token-UOO4N54I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@vercel+oidc@3.0.3/node_modules/@vercel/oidc/dist/token.js"],"names":[],"mappings":";;;;AAAA,IAAA,aAAA,GAAA,UAAA,CAAA;AAAA,EAAA,qFAAA,CAAA,OAAA,EAAA,MAAA,EAAA;AACA,IAAA,IAAI,YAAY,MAAA,CAAO,cAAA;AACvB,IAAA,IAAI,mBAAmB,MAAA,CAAO,wBAAA;AAC9B,IAAA,IAAI,oBAAoB,MAAA,CAAO,mBAAA;AAC/B,IAAA,IAAI,YAAA,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Ae,YAAA,GAAe;AAC5B,MAAA,MAAM,EAAE,SAAA,EAAW,MAAA,EAAO,GAAA,IAAQ,kBAAkB,eAAA,GAAiB;AACrE,MAAA,IAAI,UAAA,GAAA,IAAiB,iBAAA,CAAkB,SAAA,EAAW,SAAS,CAAA;AAC3D,MAAA,IAAI,CAAC,UAAA,IAAA,IAAkB,iBAAA,CAAkB,SAAA,EAAA,IAAe,iBAAA,CAAkB,eAAA,EAAiB,UAAA,CAAW,KAAK,CAAC,CAAA,EAAG;AAC7G,QAAA,MAAM,SAAA,GAAA,IAAgB,iBAAA,CAAkB,iBAAA,GAAmB;AAC3D,QAAA,IAAI,CAAC,SAAA,EAAW;AACd,UAAA,MAAM,IAAI,kBAAA,CAAmB,oBAAA;AAAA,YAC3B;AAAA,WACF;AAAA,QACF;AACA,QAAA,IAAI,CAAC,SAAA,EAAW;AACd,UAAA,MAAM,IAAI,kBAAA,CAAmB,oBAAA;AAAA,YAC3B;AAAA,WACF;AAAA,QACF;AACA,QAAA,UAAA,GAAa,UAAU,iBAAA,CAAkB,kBAAA,EAAoB,SAAA,EAAW,WAAW,MAAM,CAAA;AACzF,QAAA,IAAI,CAAC,UAAA,EAAY;AACf,UAAA,MAAM,IAAI,kBAAA,CAAmB,oBAAA,CAAqB,8BAA8B,CAAA;AAAA,QAClF;AACA,QAAA,IAAI,iBAAA,CAAkB,SAAA,EAAW,UAAA,EAAY,SAAS,CAAA;AAAA,MACxD;AACA,MAAA,OAAA,CAAQ,GAAA,CAAI,oBAAoB,UAAA,CAAW,KAAA;AAC3C,MAAA;AAAA,IACF;AAAA,EAAA;AAAA,CAAA,CAAA","file":"token-UOO4N54I.js","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_exports = {};\n__export(token_exports, {\n refreshToken: () => refreshToken\n});\nmodule.exports = __toCommonJS(token_exports);\nvar import_token_error = require(\"./token-error\");\nvar import_token_util = require(\"./token-util\");\nasync function refreshToken() {\n const { projectId, teamId } = (0, import_token_util.findProjectInfo)();\n let maybeToken = (0, import_token_util.loadToken)(projectId);\n if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token))) {\n const authToken = (0, import_token_util.getVercelCliToken)();\n if (!authToken) {\n throw new import_token_error.VercelOidcTokenError(\n \"Failed to refresh OIDC token: login to vercel cli\"\n );\n }\n if (!projectId) {\n throw new import_token_error.VercelOidcTokenError(\n \"Failed to refresh OIDC token: project id not found\"\n );\n }\n maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);\n if (!maybeToken) {\n throw new import_token_error.VercelOidcTokenError(\"Failed to refresh OIDC token\");\n }\n (0, import_token_util.saveToken)(maybeToken, projectId);\n }\n process.env.VERCEL_OIDC_TOKEN = maybeToken.token;\n return;\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n refreshToken\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTD7TJ4N5_cjs = require('./chunk-TD7TJ4N5.cjs');
|
|
4
|
+
|
|
5
|
+
var tokenUtilDUN56AZR = chunkTD7TJ4N5_cjs.require_token_util();
|
|
6
|
+
|
|
7
|
+
module.exports = tokenUtilDUN56AZR;
|
|
8
|
+
//# sourceMappingURL=token-util-DUN56AZR.cjs.map
|
|
9
|
+
//# sourceMappingURL=token-util-DUN56AZR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"token-util-DUN56AZR.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"token-util-JCUK3SCT.js"}
|
package/dist/transformers.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { LLMStepResult } from '@mastra/core/agent';
|
|
2
2
|
import type { ChunkType, DataChunkType, NetworkChunkType } from '@mastra/core/stream';
|
|
3
3
|
import type { WorkflowRunStatus, WorkflowStepStatus } from '@mastra/core/workflows';
|
|
4
|
-
import type { InferUIMessageChunk, UIMessage } from 'ai';
|
|
4
|
+
import type { InferUIMessageChunk, UIMessage, UIMessageStreamOptions } from 'ai';
|
|
5
5
|
import type { ZodType } from 'zod';
|
|
6
|
+
import type { ToolAgentChunkType, ToolWorkflowChunkType, ToolNetworkChunkType } from './helpers.js';
|
|
6
7
|
type LanguageModelV2Usage = {
|
|
7
8
|
/**
|
|
8
9
|
The number of input (prompt) tokens used.
|
|
@@ -67,15 +68,26 @@ export type AgentDataPart = {
|
|
|
67
68
|
id: string;
|
|
68
69
|
data: LLMStepResult;
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
+
declare const PRIMITIVE_CACHE_SYMBOL: unique symbol;
|
|
72
|
+
export declare function WorkflowStreamToAISDKTransformer({ includeTextStreamParts, }?: {
|
|
73
|
+
includeTextStreamParts?: boolean;
|
|
74
|
+
}): import("stream/web").TransformStream<ChunkType, ToolAgentChunkType | ToolWorkflowChunkType | ToolNetworkChunkType | WorkflowDataPart | ChunkType | {
|
|
71
75
|
data?: string;
|
|
72
76
|
type?: "start" | "finish";
|
|
73
|
-
}
|
|
74
|
-
export declare function AgentNetworkToAISDKTransformer(): import("stream/web").TransformStream<NetworkChunkType, DataChunkType | NetworkDataPart | {
|
|
77
|
+
} | InferUIMessageChunk<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>>;
|
|
78
|
+
export declare function AgentNetworkToAISDKTransformer(): import("stream/web").TransformStream<NetworkChunkType, DataChunkType | NetworkDataPart | InferUIMessageChunk<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>> | {
|
|
75
79
|
data?: string;
|
|
76
80
|
type?: "start" | "finish";
|
|
77
|
-
}
|
|
78
|
-
export declare function AgentStreamToAISDKTransformer<TOutput extends ZodType<any>>(lastMessageId
|
|
81
|
+
}>;
|
|
82
|
+
export declare function AgentStreamToAISDKTransformer<TOutput extends ZodType<any>>({ lastMessageId, sendStart, sendFinish, sendReasoning, sendSources, messageMetadata, onError, }: {
|
|
83
|
+
lastMessageId?: string;
|
|
84
|
+
sendStart?: boolean;
|
|
85
|
+
sendFinish?: boolean;
|
|
86
|
+
sendReasoning?: boolean;
|
|
87
|
+
sendSources?: boolean;
|
|
88
|
+
messageMetadata?: UIMessageStreamOptions<UIMessage>['messageMetadata'];
|
|
89
|
+
onError?: UIMessageStreamOptions<UIMessage>['onError'];
|
|
90
|
+
}): import("stream/web").TransformStream<ChunkType<TOutput>, object>;
|
|
79
91
|
export declare function transformAgent<TOutput extends ZodType<any>>(payload: ChunkType<TOutput>, bufferedSteps: Map<string, any>): {
|
|
80
92
|
type: "data-tool-agent";
|
|
81
93
|
id: string;
|
|
@@ -84,12 +96,120 @@ export declare function transformAgent<TOutput extends ZodType<any>>(payload: Ch
|
|
|
84
96
|
export declare function transformWorkflow<TOutput extends ZodType<any>>(payload: ChunkType<TOutput>, bufferedWorkflows: Map<string, {
|
|
85
97
|
name: string;
|
|
86
98
|
steps: Record<string, StepResult>;
|
|
87
|
-
}>, isNested?: boolean): (DataChunkType & {
|
|
99
|
+
}>, isNested?: boolean, includeTextStreamParts?: boolean): (DataChunkType & {
|
|
88
100
|
from: never;
|
|
89
101
|
runId: never;
|
|
90
102
|
metadata?: Record<string, any> | undefined;
|
|
91
103
|
payload: never;
|
|
92
|
-
}) | {
|
|
104
|
+
}) | ToolAgentChunkType | ToolWorkflowChunkType | ToolNetworkChunkType | {
|
|
105
|
+
type: "text-start";
|
|
106
|
+
id: string;
|
|
107
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
108
|
+
} | {
|
|
109
|
+
type: "text-delta";
|
|
110
|
+
delta: string;
|
|
111
|
+
id: string;
|
|
112
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
113
|
+
} | {
|
|
114
|
+
type: "text-end";
|
|
115
|
+
id: string;
|
|
116
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
117
|
+
} | {
|
|
118
|
+
type: "reasoning-start";
|
|
119
|
+
id: string;
|
|
120
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
121
|
+
} | {
|
|
122
|
+
type: "reasoning-delta";
|
|
123
|
+
id: string;
|
|
124
|
+
delta: string;
|
|
125
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
126
|
+
} | {
|
|
127
|
+
type: "reasoning-end";
|
|
128
|
+
id: string;
|
|
129
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
130
|
+
} | {
|
|
131
|
+
type: "error";
|
|
132
|
+
errorText: string;
|
|
133
|
+
} | {
|
|
134
|
+
type: "tool-input-available";
|
|
135
|
+
toolCallId: string;
|
|
136
|
+
toolName: string;
|
|
137
|
+
input: unknown;
|
|
138
|
+
providerExecuted?: boolean;
|
|
139
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
140
|
+
dynamic?: boolean;
|
|
141
|
+
} | {
|
|
142
|
+
type: "tool-input-error";
|
|
143
|
+
toolCallId: string;
|
|
144
|
+
toolName: string;
|
|
145
|
+
input: unknown;
|
|
146
|
+
providerExecuted?: boolean;
|
|
147
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
148
|
+
dynamic?: boolean;
|
|
149
|
+
errorText: string;
|
|
150
|
+
} | {
|
|
151
|
+
type: "tool-output-available";
|
|
152
|
+
toolCallId: string;
|
|
153
|
+
output: unknown;
|
|
154
|
+
providerExecuted?: boolean;
|
|
155
|
+
dynamic?: boolean;
|
|
156
|
+
preliminary?: boolean;
|
|
157
|
+
} | {
|
|
158
|
+
type: "tool-output-error";
|
|
159
|
+
toolCallId: string;
|
|
160
|
+
errorText: string;
|
|
161
|
+
providerExecuted?: boolean;
|
|
162
|
+
dynamic?: boolean;
|
|
163
|
+
} | {
|
|
164
|
+
type: "tool-input-start";
|
|
165
|
+
toolCallId: string;
|
|
166
|
+
toolName: string;
|
|
167
|
+
providerExecuted?: boolean;
|
|
168
|
+
dynamic?: boolean;
|
|
169
|
+
} | {
|
|
170
|
+
type: "tool-input-delta";
|
|
171
|
+
toolCallId: string;
|
|
172
|
+
inputTextDelta: string;
|
|
173
|
+
} | {
|
|
174
|
+
type: "source-url";
|
|
175
|
+
sourceId: string;
|
|
176
|
+
url: string;
|
|
177
|
+
title?: string;
|
|
178
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
179
|
+
} | {
|
|
180
|
+
type: "source-document";
|
|
181
|
+
sourceId: string;
|
|
182
|
+
mediaType: string;
|
|
183
|
+
title: string;
|
|
184
|
+
filename?: string;
|
|
185
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
186
|
+
} | {
|
|
187
|
+
type: "file";
|
|
188
|
+
url: string;
|
|
189
|
+
mediaType: string;
|
|
190
|
+
providerMetadata?: import("ai").ProviderMetadata;
|
|
191
|
+
} | {
|
|
192
|
+
type: "start-step";
|
|
193
|
+
} | {
|
|
194
|
+
type: "finish-step";
|
|
195
|
+
} | {
|
|
196
|
+
type: "abort";
|
|
197
|
+
} | {
|
|
198
|
+
type: `data-${string}`;
|
|
199
|
+
id?: string;
|
|
200
|
+
data: unknown;
|
|
201
|
+
transient?: boolean;
|
|
202
|
+
} | {
|
|
203
|
+
type: "start";
|
|
204
|
+
messageId?: string;
|
|
205
|
+
messageMetadata?: unknown;
|
|
206
|
+
} | {
|
|
207
|
+
type: "finish";
|
|
208
|
+
messageMetadata?: unknown;
|
|
209
|
+
} | {
|
|
210
|
+
type: "message-metadata";
|
|
211
|
+
messageMetadata: unknown;
|
|
212
|
+
} | {
|
|
93
213
|
readonly type: "data-workflow" | "data-tool-workflow";
|
|
94
214
|
readonly id: string;
|
|
95
215
|
readonly data: {
|
|
@@ -122,10 +242,16 @@ export declare function transformWorkflow<TOutput extends ZodType<any>>(payload:
|
|
|
122
242
|
};
|
|
123
243
|
readonly status: WorkflowRunStatus;
|
|
124
244
|
};
|
|
125
|
-
} | null;
|
|
245
|
+
} | null | undefined;
|
|
126
246
|
export declare function transformNetwork(payload: NetworkChunkType, bufferedNetworks: Map<string, {
|
|
127
247
|
name: string;
|
|
128
|
-
steps: StepResult
|
|
248
|
+
steps: (StepResult & {
|
|
249
|
+
id: string;
|
|
250
|
+
iteration: number;
|
|
251
|
+
task: null | Record<string, unknown>;
|
|
252
|
+
input: StepResult['input'];
|
|
253
|
+
[PRIMITIVE_CACHE_SYMBOL]: Map<string, any>;
|
|
254
|
+
})[];
|
|
129
255
|
usage: LanguageModelV2Usage | null;
|
|
130
256
|
output: unknown | null;
|
|
131
257
|
}>, isNested?: boolean): InferUIMessageChunk<UIMessage> | NetworkDataPart | DataChunkType | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE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O,CAAC,CAAC;QAC3B,CAAC,sBAAsB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC5C,CAAC,EAAE,CAAC;IACL,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB,CACF,EACD,QAAQ,CAAC,EAAE,OAAO,GACjB,mBAAmB,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,aAAa,GAAG,IAAI,CAgXzE"}
|
package/dist/ui.cjs
CHANGED
package/dist/ui.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/convert-messages.ts"],"names":["MessageList"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/convert-messages.ts"],"names":["MessageList"],"mappings":";;;;AA4CO,SAAS,kBAAkB,QAAA,EAA4B;AAC5D,EAAA,OAAO,IAAIA,uBAAA,EAAY,CAAE,GAAA,CAAI,QAAA,EAAU,QAAQ,CAAA,CAAE,GAAA,CAAI,GAAA,CAAI,IAAA,CAAK,EAAA,EAAG;AACnE;AA+CO,SAAS,kBAAkB,QAAA,EAA4B;AAC5D,EAAA,OAAO,IAAIA,uBAAA,EAAY,CAAE,GAAA,CAAI,QAAA,EAAU,QAAQ,CAAA,CAAE,GAAA,CAAI,GAAA,CAAI,IAAA,CAAK,EAAA,EAAG;AACnE","file":"ui.cjs","sourcesContent":["import { MessageList } from '@mastra/core/agent/message-list';\nimport type { MessageListInput } from '@mastra/core/agent/message-list';\n\n/**\n * Converts messages from various input formats to AI SDK V5 UI message format.\n *\n * This function accepts messages in multiple formats (strings, AI SDK V4/V5 messages, Mastra DB messages, etc.) and normalizes them to the AI SDK V5 UIMessage format, which is suitable for use with AI SDK V5 UI components like `useChat()`.\n *\n * @param messages - Messages to convert. Accepts:\n * - `string` - A single text message (treated as user role)\n * - `string[]` - Multiple text messages\n * - `MessageInput` - A single message object in any supported format:\n * - AI SDK V5 UIMessage or ModelMessage\n * - AI SDK V4 UIMessage or CoreMessage\n * - MastraDBMessage (internal storage format)\n * - MastraMessageV1 (legacy format)\n * - `MessageInput[]` - Array of message objects\n *\n * @returns An array of AI SDK V5 UIMessage objects with:\n * - `id` - Unique message identifier\n * - `role` - 'user' | 'assistant' | 'system'\n * - `parts` - Array of UI parts (text, tool results, files, reasoning, etc.)\n * - `metadata` - Optional metadata including createdAt, threadId, resourceId\n *\n * @example\n * ```typescript\n * import { toAISdkV5Messages } from '@mastra/ai-sdk';\n *\n * // Convert simple text messages\n * const messages = toAISdkV5Messages(['Hello', 'How can I help?']);\n *\n * // Convert AI SDK V4 messages to V5 format\n * const v4Messages = [\n * { id: '1', role: 'user', content: 'Hello', parts: [{ type: 'text', text: 'Hello' }] },\n * { id: '2', role: 'assistant', content: 'Hi!', parts: [{ type: 'text', text: 'Hi!' }] }\n * ];\n * const v5Messages = toAISdkV5Messages(v4Messages);\n *\n * // Use with useChat or similar AI SDK V5 hooks\n * const { messages: chatMessages } = useChat({\n * initialMessages: toAISdkV5Messages(storedMessages)\n * });\n * ```\n */\nexport function toAISdkV5Messages(messages: MessageListInput) {\n return new MessageList().add(messages, `memory`).get.all.aiV5.ui();\n}\n\n/**\n * Converts messages from various input formats to AI SDK V4 UI message format.\n *\n * This function accepts messages in multiple formats (strings, AI SDK V4/V5 messages, Mastra DB messages, etc.) and normalizes them to the AI SDK V4 UIMessage format, which is suitable for use with AI SDK V4 UI components.\n *\n * @param messages - Messages to convert. Accepts:\n * - `string` - A single text message (treated as user role)\n * - `string[]` - Multiple text messages\n * - `MessageInput` - A single message object in any supported format:\n * - AI SDK V5 UIMessage or ModelMessage\n * - AI SDK V4 UIMessage or CoreMessage\n * - MastraDBMessage (internal storage format)\n * - MastraMessageV1 (legacy format)\n * - `MessageInput[]` - Array of message objects\n *\n * @returns An array of AI SDK V4 UIMessage objects with:\n * - `id` - Unique message identifier\n * - `role` - 'user' | 'assistant' | 'system'\n * - `content` - Text content of the message\n * - `parts` - Array of UI parts (text, tool-invocation, file, reasoning, etc.)\n * - `createdAt` - Message creation timestamp\n * - `toolInvocations` - Optional array of tool invocations (for assistant messages)\n * - `experimental_attachments` - Optional file attachments\n * - `metadata` - Optional custom metadata\n *\n * @example\n * ```typescript\n * import { toAISdkV4Messages } from '@mastra/ai-sdk';\n *\n * // Convert simple text messages\n * const messages = toAISdkV4Messages(['Hello', 'How can I help?']);\n *\n * // Convert AI SDK V5 messages to V4 format for legacy compatibility\n * const v5Messages = [\n * { id: '1', role: 'user', parts: [{ type: 'text', text: 'Hello' }] },\n * { id: '2', role: 'assistant', parts: [{ type: 'text', text: 'Hi!' }] }\n * ];\n * const v4Messages = toAISdkV4Messages(v5Messages);\n *\n * // Use with AI SDK V4 useChat hook\n * const { messages: chatMessages } = useChat({\n * initialMessages: toAISdkV4Messages(storedMessages)\n * });\n * ```\n */\nexport function toAISdkV4Messages(messages: MessageListInput) {\n return new MessageList().add(messages, `memory`).get.all.aiV4.ui();\n}\n"]}
|