@mastra/deployer 0.16.2-alpha.0 → 0.16.3-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.
- package/CHANGELOG.md +21 -0
- package/dist/server/handlers/routes/agents/handlers.d.ts +5 -12
- package/dist/server/handlers/routes/agents/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/agents/router.d.ts.map +1 -1
- package/dist/server/index.cjs +96 -21
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +97 -22
- package/dist/server/index.js.map +1 -1
- package/package.json +7 -7
package/dist/server/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import { getAgentCardByIdHandler as getAgentCardByIdHandler$1, getAgentExecution
|
|
|
21
21
|
import { stream } from 'hono/streaming';
|
|
22
22
|
import { bodyLimit } from 'hono/body-limit';
|
|
23
23
|
import { getAgentBuilderActionsHandler as getAgentBuilderActionsHandler$1, getAgentBuilderActionByIdHandler as getAgentBuilderActionByIdHandler$1, getAgentBuilderActionRunsHandler as getAgentBuilderActionRunsHandler$1, getAgentBuilderActionRunExecutionResultHandler as getAgentBuilderActionRunExecutionResultHandler$1, getAgentBuilderActionRunByIdHandler as getAgentBuilderActionRunByIdHandler$1, resumeAgentBuilderActionHandler as resumeAgentBuilderActionHandler$1, resumeAsyncAgentBuilderActionHandler as resumeAsyncAgentBuilderActionHandler$1, streamAgentBuilderActionHandler as streamAgentBuilderActionHandler$1, streamVNextAgentBuilderActionHandler as streamVNextAgentBuilderActionHandler$1, createAgentBuilderActionRunHandler as createAgentBuilderActionRunHandler$1, startAsyncAgentBuilderActionHandler as startAsyncAgentBuilderActionHandler$1, startAgentBuilderActionRunHandler as startAgentBuilderActionRunHandler$1, watchAgentBuilderActionHandler as watchAgentBuilderActionHandler$1, cancelAgentBuilderActionRunHandler as cancelAgentBuilderActionRunHandler$1, sendAgentBuilderActionRunEventHandler as sendAgentBuilderActionRunEventHandler$1 } from '@mastra/server/handlers/agent-builder';
|
|
24
|
-
import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateLegacyHandler as generateLegacyHandler$1, generateHandler as generateHandler$1, generateVNextHandler as generateVNextHandler$1, streamVNextGenerateHandler as streamVNextGenerateHandler$1, streamGenerateLegacyHandler as streamGenerateLegacyHandler$1, streamGenerateHandler as streamGenerateHandler$1, streamVNextUIMessageHandler as streamVNextUIMessageHandler$1, updateAgentModelHandler as updateAgentModelHandler$1 } from '@mastra/server/handlers/agents';
|
|
24
|
+
import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateLegacyHandler as generateLegacyHandler$1, generateHandler as generateHandler$1, streamNetworkHandler as streamNetworkHandler$1, generateVNextHandler as generateVNextHandler$1, streamVNextGenerateHandler as streamVNextGenerateHandler$1, streamGenerateLegacyHandler as streamGenerateLegacyHandler$1, streamGenerateHandler as streamGenerateHandler$1, streamVNextUIMessageHandler as streamVNextUIMessageHandler$1, updateAgentModelHandler as updateAgentModelHandler$1 } from '@mastra/server/handlers/agents';
|
|
25
25
|
import { Agent } from '@mastra/core/agent';
|
|
26
26
|
import { z } from 'zod';
|
|
27
27
|
import { getAgentToolHandler as getAgentToolHandler$1, executeAgentToolHandler as executeAgentToolHandler$1, getToolsHandler as getToolsHandler$1, getToolByIdHandler as getToolByIdHandler$1, executeToolHandler as executeToolHandler$1 } from '@mastra/server/handlers/tools';
|
|
@@ -2125,39 +2125,21 @@ var AllowedProviderKeys = {
|
|
|
2125
2125
|
};
|
|
2126
2126
|
|
|
2127
2127
|
// src/server/handlers/routes/agents/handlers.ts
|
|
2128
|
-
var
|
|
2128
|
+
var sharedBodyOptions = {
|
|
2129
2129
|
messages: {
|
|
2130
2130
|
type: "array",
|
|
2131
2131
|
items: { type: "object" }
|
|
2132
2132
|
},
|
|
2133
|
-
threadId: { type: "string" },
|
|
2134
|
-
resourceId: { type: "string", description: "The resource ID for the conversation" },
|
|
2135
2133
|
runId: { type: "string" },
|
|
2136
|
-
output: { type: "object" },
|
|
2137
|
-
instructions: { type: "string", description: "Optional instructions to override the agent's default instructions" },
|
|
2138
|
-
context: {
|
|
2139
|
-
type: "array",
|
|
2140
|
-
items: { type: "object" },
|
|
2141
|
-
description: "Additional context messages to include"
|
|
2142
|
-
},
|
|
2143
2134
|
memory: {
|
|
2144
2135
|
type: "object",
|
|
2145
2136
|
properties: {
|
|
2146
|
-
|
|
2147
|
-
|
|
2137
|
+
thread: { type: "string" },
|
|
2138
|
+
resource: { type: "string", description: "The resource ID for the conversation" },
|
|
2148
2139
|
options: { type: "object", description: "Memory configuration options" }
|
|
2149
2140
|
},
|
|
2150
2141
|
description: "Memory options for the conversation"
|
|
2151
2142
|
},
|
|
2152
|
-
savePerStep: { type: "boolean", description: "Whether to save messages incrementally on step finish" },
|
|
2153
|
-
format: { type: "string", enum: ["mastra", "aisdk"], description: "Response format" },
|
|
2154
|
-
toolChoice: {
|
|
2155
|
-
oneOf: [
|
|
2156
|
-
{ type: "string", enum: ["auto", "none", "required"] },
|
|
2157
|
-
{ type: "object", properties: { type: { type: "string" }, toolName: { type: "string" } } }
|
|
2158
|
-
],
|
|
2159
|
-
description: "Controls how tools are selected during generation"
|
|
2160
|
-
},
|
|
2161
2143
|
modelSettings: {
|
|
2162
2144
|
type: "object",
|
|
2163
2145
|
properties: {
|
|
@@ -2175,6 +2157,27 @@ var vNextBodyOptions = {
|
|
|
2175
2157
|
description: "Model settings for generation"
|
|
2176
2158
|
}
|
|
2177
2159
|
};
|
|
2160
|
+
var vNextBodyOptions = {
|
|
2161
|
+
threadId: { type: "string" },
|
|
2162
|
+
resourceId: { type: "string", description: "The resource ID for the conversation" },
|
|
2163
|
+
output: { type: "object" },
|
|
2164
|
+
instructions: { type: "string", description: "Optional instructions to override the agent's default instructions" },
|
|
2165
|
+
context: {
|
|
2166
|
+
type: "array",
|
|
2167
|
+
items: { type: "object" },
|
|
2168
|
+
description: "Additional context messages to include"
|
|
2169
|
+
},
|
|
2170
|
+
savePerStep: { type: "boolean", description: "Whether to save messages incrementally on step finish" },
|
|
2171
|
+
toolChoice: {
|
|
2172
|
+
oneOf: [
|
|
2173
|
+
{ type: "string", enum: ["auto", "none", "required"] },
|
|
2174
|
+
{ type: "object", properties: { type: { type: "string" }, toolName: { type: "string" } } }
|
|
2175
|
+
],
|
|
2176
|
+
description: "Controls how tools are selected during generation"
|
|
2177
|
+
},
|
|
2178
|
+
format: { type: "string", enum: ["mastra", "aisdk"], description: "Response format" },
|
|
2179
|
+
...sharedBodyOptions
|
|
2180
|
+
};
|
|
2178
2181
|
async function getAgentsHandler(c2) {
|
|
2179
2182
|
const serializedAgents = await getAgentsHandler$1({
|
|
2180
2183
|
mastra: c2.get("mastra"),
|
|
@@ -2350,6 +2353,49 @@ async function streamVNextGenerateHandler(c2) {
|
|
|
2350
2353
|
return handleError(error, "Error streaming from agent");
|
|
2351
2354
|
}
|
|
2352
2355
|
}
|
|
2356
|
+
async function streamNetworkHandler(c2) {
|
|
2357
|
+
try {
|
|
2358
|
+
const mastra = c2.get("mastra");
|
|
2359
|
+
const agentId = c2.req.param("agentId");
|
|
2360
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
2361
|
+
const body = await c2.req.json();
|
|
2362
|
+
const logger2 = mastra.getLogger();
|
|
2363
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
2364
|
+
return stream(
|
|
2365
|
+
c2,
|
|
2366
|
+
async (stream7) => {
|
|
2367
|
+
try {
|
|
2368
|
+
const streamResponse = await streamNetworkHandler$1({
|
|
2369
|
+
mastra,
|
|
2370
|
+
agentId,
|
|
2371
|
+
runtimeContext,
|
|
2372
|
+
body
|
|
2373
|
+
// abortSignal: c.req.raw.signal,
|
|
2374
|
+
});
|
|
2375
|
+
const reader = streamResponse.getReader();
|
|
2376
|
+
stream7.onAbort(() => {
|
|
2377
|
+
void reader.cancel("request aborted");
|
|
2378
|
+
});
|
|
2379
|
+
let chunkResult;
|
|
2380
|
+
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
2381
|
+
await stream7.write(`data: ${JSON.stringify(chunkResult.value)}
|
|
2382
|
+
|
|
2383
|
+
`);
|
|
2384
|
+
}
|
|
2385
|
+
await stream7.write("data: [DONE]\n\n");
|
|
2386
|
+
} catch (err) {
|
|
2387
|
+
logger2.error("Error in streamNetwork generate: " + (err?.message ?? "Unknown error"));
|
|
2388
|
+
}
|
|
2389
|
+
await stream7.close();
|
|
2390
|
+
},
|
|
2391
|
+
async (err) => {
|
|
2392
|
+
logger2.error("Error in watch stream: " + err?.message);
|
|
2393
|
+
}
|
|
2394
|
+
);
|
|
2395
|
+
} catch (error) {
|
|
2396
|
+
return handleError(error, "Error streaming from agent in network mode");
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2353
2399
|
async function streamVNextUIMessageHandler(c2) {
|
|
2354
2400
|
try {
|
|
2355
2401
|
const mastra = c2.get("mastra");
|
|
@@ -2881,6 +2927,35 @@ function agentsRouter(bodyLimitOptions) {
|
|
|
2881
2927
|
}),
|
|
2882
2928
|
generateHandler
|
|
2883
2929
|
);
|
|
2930
|
+
router.post(
|
|
2931
|
+
"/:agentId/network",
|
|
2932
|
+
bodyLimit(bodyLimitOptions),
|
|
2933
|
+
w({
|
|
2934
|
+
description: "Execute an agent as a Network",
|
|
2935
|
+
tags: ["agents"],
|
|
2936
|
+
parameters: [
|
|
2937
|
+
{
|
|
2938
|
+
name: "agentId",
|
|
2939
|
+
in: "path",
|
|
2940
|
+
required: true,
|
|
2941
|
+
schema: { type: "string" }
|
|
2942
|
+
}
|
|
2943
|
+
],
|
|
2944
|
+
requestBody: {
|
|
2945
|
+
required: true,
|
|
2946
|
+
content: {
|
|
2947
|
+
"application/json": {
|
|
2948
|
+
schema: {
|
|
2949
|
+
type: "object",
|
|
2950
|
+
properties: sharedBodyOptions,
|
|
2951
|
+
required: ["messages"]
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
}),
|
|
2957
|
+
streamNetworkHandler
|
|
2958
|
+
);
|
|
2884
2959
|
router.post(
|
|
2885
2960
|
"/:agentId/generate/vnext",
|
|
2886
2961
|
bodyLimit(bodyLimitOptions),
|