@mastra/client-js 0.11.3-alpha.2 → 0.11.3-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/client.d.ts +12 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +398 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +398 -4
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-builder.d.ts +148 -0
- package/dist/resources/agent-builder.d.ts.map +1 -0
- package/dist/resources/agent.d.ts +25 -0
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -6
- package/.turbo/turbo-build.log +0 -18
- package/eslint.config.js +0 -11
- package/integration-tests/agui-adapter.test.ts +0 -122
- package/integration-tests/package.json +0 -18
- package/integration-tests/src/mastra/index.ts +0 -35
- package/integration-tests/vitest.config.ts +0 -9
- package/src/adapters/agui.test.ts +0 -293
- package/src/adapters/agui.ts +0 -257
- package/src/client.ts +0 -644
- package/src/example.ts +0 -95
- package/src/index.test.ts +0 -1253
- package/src/index.ts +0 -3
- package/src/resources/a2a.ts +0 -98
- package/src/resources/agent.ts +0 -1460
- package/src/resources/base.ts +0 -77
- package/src/resources/index.ts +0 -11
- package/src/resources/legacy-workflow.ts +0 -242
- package/src/resources/mcp-tool.ts +0 -48
- package/src/resources/memory-thread.test.ts +0 -285
- package/src/resources/memory-thread.ts +0 -99
- package/src/resources/network-memory-thread.test.ts +0 -269
- package/src/resources/network-memory-thread.ts +0 -81
- package/src/resources/network.ts +0 -86
- package/src/resources/observability.ts +0 -53
- package/src/resources/tool.ts +0 -45
- package/src/resources/vNextNetwork.ts +0 -194
- package/src/resources/vector.ts +0 -83
- package/src/resources/workflow.ts +0 -410
- package/src/types.ts +0 -534
- package/src/utils/index.ts +0 -11
- package/src/utils/process-client-tools.ts +0 -32
- package/src/utils/process-mastra-stream.test.ts +0 -353
- package/src/utils/process-mastra-stream.ts +0 -49
- package/src/utils/zod-to-json-schema.ts +0 -30
- package/src/v2-messages.test.ts +0 -180
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -17
- package/vitest.config.js +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 0.11.3-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5816](https://github.com/mastra-ai/mastra/pull/5816) [`ab48c97`](https://github.com/mastra-ai/mastra/commit/ab48c979098ea571faf998a55d3a00e7acd7a715) Thanks [@dane-ai-mastra](https://github.com/apps/dane-ai-mastra)! - dependencies updates:
|
|
8
|
+
- Updated dependency [`zod-to-json-schema@^3.24.6` ↗︎](https://www.npmjs.com/package/zod-to-json-schema/v/3.24.6) (from `^3.24.5`, in `dependencies`)
|
|
9
|
+
|
|
10
|
+
- [#7269](https://github.com/mastra-ai/mastra/pull/7269) [`ff89505`](https://github.com/mastra-ai/mastra/commit/ff895057c8c7e91a5535faef46c5e5391085ddfa) Thanks [@wardpeet](https://github.com/wardpeet)! - Add deprecation warnings and add legacy routes
|
|
11
|
+
|
|
12
|
+
- [#7329](https://github.com/mastra-ai/mastra/pull/7329) [`26b0d7c`](https://github.com/mastra-ai/mastra/commit/26b0d7c7cba46469351d453714e119ac7aae9da2) Thanks [@wardpeet](https://github.com/wardpeet)! - Cleanup pkg output
|
|
13
|
+
|
|
14
|
+
- [#7136](https://github.com/mastra-ai/mastra/pull/7136) [`48f0742`](https://github.com/mastra-ai/mastra/commit/48f0742662414610dc9a7a99d45902d059ee123d) Thanks [@NikAiyer](https://github.com/NikAiyer)! - add deployer, server and clientjs handlers for agent builder template
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`ab48c97`](https://github.com/mastra-ai/mastra/commit/ab48c979098ea571faf998a55d3a00e7acd7a715), [`ff89505`](https://github.com/mastra-ai/mastra/commit/ff895057c8c7e91a5535faef46c5e5391085ddfa), [`183dc95`](https://github.com/mastra-ai/mastra/commit/183dc95596f391b977bd1a2c050b8498dac74891), [`a1111e2`](https://github.com/mastra-ai/mastra/commit/a1111e24e705488adfe5e0a6f20c53bddf26cb22), [`61debef`](https://github.com/mastra-ai/mastra/commit/61debefd80ad3a7ed5737e19df6a23d40091689a), [`9beaeff`](https://github.com/mastra-ai/mastra/commit/9beaeffa4a97b1d5fd01a7f8af8708b16067f67c), [`9eee594`](https://github.com/mastra-ai/mastra/commit/9eee594e35e0ca2a650fcc33fa82009a142b9ed0), [`979912c`](https://github.com/mastra-ai/mastra/commit/979912cfd180aad53287cda08af771df26454e2c), [`7dcf4c0`](https://github.com/mastra-ai/mastra/commit/7dcf4c04f44d9345b1f8bc5d41eae3f11ac61611), [`ad78bfc`](https://github.com/mastra-ai/mastra/commit/ad78bfc4ea6a1fff140432bf4f638e01af7af668), [`0ce418a`](https://github.com/mastra-ai/mastra/commit/0ce418a1ccaa5e125d4483a9651b635046152569), [`8387952`](https://github.com/mastra-ai/mastra/commit/838795227b4edf758c84a2adf6f7fba206c27719), [`5eca5d2`](https://github.com/mastra-ai/mastra/commit/5eca5d2655788863ea0442a46c9ef5d3c6dbe0a8)]:
|
|
17
|
+
- @mastra/core@0.15.3-alpha.4
|
|
18
|
+
|
|
19
|
+
## 0.11.3-alpha.3
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`aedbbfa`](https://github.com/mastra-ai/mastra/commit/aedbbfa064124ddde039111f12629daebfea7e48), [`f643c65`](https://github.com/mastra-ai/mastra/commit/f643c651bdaf57c2343cf9dbfc499010495701fb), [`fef7375`](https://github.com/mastra-ai/mastra/commit/fef737534574f41b432a7361a285f776c3bac42b), [`e3d8fea`](https://github.com/mastra-ai/mastra/commit/e3d8feaacfb8b5c5c03c13604cc06ea2873d45fe), [`3412597`](https://github.com/mastra-ai/mastra/commit/3412597a6644c0b6bf3236d6e319ed1450c5bae8)]:
|
|
24
|
+
- @mastra/core@0.15.3-alpha.3
|
|
25
|
+
|
|
3
26
|
## 0.11.3-alpha.2
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AbstractAgent } from '@ag-ui/client';
|
|
2
|
-
import type { AITraceRecord, AITracesPaginatedArg } from '@mastra/core';
|
|
2
|
+
import type { AITraceRecord, AITracesPaginatedArg, WorkflowInfo } from '@mastra/core';
|
|
3
3
|
import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
4
|
-
import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network, A2A, MCPTool, LegacyWorkflow } from './resources/index.js';
|
|
4
|
+
import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network, A2A, MCPTool, LegacyWorkflow, AgentBuilder } from './resources/index.js';
|
|
5
5
|
import { NetworkMemoryThread } from './resources/network-memory-thread.js';
|
|
6
6
|
import { VNextNetwork } from './resources/vNextNetwork.js';
|
|
7
7
|
import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetMemoryThreadParams, GetMemoryThreadResponse, GetNetworkResponse, GetTelemetryParams, GetTelemetryResponse, GetToolResponse, GetWorkflowResponse, SaveMessageToMemoryParams, SaveMessageToMemoryResponse, McpServerListResponse, McpServerToolListResponse, GetLegacyWorkflowResponse, GetVNextNetworkResponse, GetNetworkMemoryThreadParams, CreateNetworkMemoryThreadParams, SaveNetworkMessageToMemoryParams, GetScorerResponse, GetScoresByScorerIdParams, GetScoresResponse, GetScoresByRunIdParams, GetScoresByEntityIdParams, SaveScoreParams, SaveScoreResponse, GetAITracesResponse } from './types.js';
|
|
@@ -117,6 +117,16 @@ export declare class MastraClient extends BaseResource {
|
|
|
117
117
|
* @returns Workflow instance
|
|
118
118
|
*/
|
|
119
119
|
getWorkflow(workflowId: string): Workflow;
|
|
120
|
+
/**
|
|
121
|
+
* Gets all available agent builder actions
|
|
122
|
+
* @returns Promise containing map of action IDs to action details
|
|
123
|
+
*/
|
|
124
|
+
getAgentBuilderActions(): Promise<Record<string, WorkflowInfo>>;
|
|
125
|
+
/**
|
|
126
|
+
* Gets an agent builder instance for executing agent-builder workflows
|
|
127
|
+
* @returns AgentBuilder instance
|
|
128
|
+
*/
|
|
129
|
+
getAgentBuilderAction(actionId: string): AgentBuilder;
|
|
120
130
|
/**
|
|
121
131
|
* Gets a vector instance by name
|
|
122
132
|
* @param vectorName - Name of the vector to retrieve
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,GAAG,EACH,OAAO,EACP,cAAc,EACd,YAAY,EAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0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jB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAID;;;;;;OAMG;IACI,mBAAmB,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,aAAa,EACb,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAUD;;;OAGG;IACI,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAI/D;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIvD,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqBzF;;;;OAIG;IACI,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAenF;;;;OAIG;IACI,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAezF;;;;OAIG;IACI,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOrE;;;OAGG;IACH,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAInD,WAAW,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAGxE"}
|
package/dist/index.cjs
CHANGED
|
@@ -489,6 +489,12 @@ var Agent = class extends BaseResource {
|
|
|
489
489
|
return this.request(`/api/agents/${this.agentId}`);
|
|
490
490
|
}
|
|
491
491
|
async generate(params) {
|
|
492
|
+
console.warn(
|
|
493
|
+
"Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 16th. Please use generateLegacy if you don't want to upgrade just yet."
|
|
494
|
+
);
|
|
495
|
+
return this.generateLegacy(params);
|
|
496
|
+
}
|
|
497
|
+
async generateLegacy(params) {
|
|
492
498
|
const processedParams = {
|
|
493
499
|
...params,
|
|
494
500
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
@@ -498,7 +504,7 @@ var Agent = class extends BaseResource {
|
|
|
498
504
|
};
|
|
499
505
|
const { runId, resourceId, threadId, runtimeContext } = processedParams;
|
|
500
506
|
const response = await this.request(
|
|
501
|
-
`/api/agents/${this.agentId}/generate`,
|
|
507
|
+
`/api/agents/${this.agentId}/generate-legacy`,
|
|
502
508
|
{
|
|
503
509
|
method: "POST",
|
|
504
510
|
body: processedParams
|
|
@@ -849,6 +855,17 @@ var Agent = class extends BaseResource {
|
|
|
849
855
|
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
850
856
|
*/
|
|
851
857
|
async stream(params) {
|
|
858
|
+
console.warn(
|
|
859
|
+
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 16th. Please use streamLegacy if you don't want to upgrade just yet."
|
|
860
|
+
);
|
|
861
|
+
return this.streamLegacy(params);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Streams a response from the agent
|
|
865
|
+
* @param params - Stream parameters including prompt
|
|
866
|
+
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
867
|
+
*/
|
|
868
|
+
async streamLegacy(params) {
|
|
852
869
|
const processedParams = {
|
|
853
870
|
...params,
|
|
854
871
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
@@ -1263,7 +1280,7 @@ var Agent = class extends BaseResource {
|
|
|
1263
1280
|
* Processes the stream response and handles tool calls
|
|
1264
1281
|
*/
|
|
1265
1282
|
async processStreamResponse(processedParams, writable) {
|
|
1266
|
-
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
1283
|
+
const response = await this.request(`/api/agents/${this.agentId}/stream-legacy`, {
|
|
1267
1284
|
method: "POST",
|
|
1268
1285
|
body: processedParams,
|
|
1269
1286
|
stream: true
|
|
@@ -2259,6 +2276,369 @@ var MCPTool = class extends BaseResource {
|
|
|
2259
2276
|
}
|
|
2260
2277
|
};
|
|
2261
2278
|
|
|
2279
|
+
// src/resources/agent-builder.ts
|
|
2280
|
+
var RECORD_SEPARATOR3 = "";
|
|
2281
|
+
var AgentBuilder = class extends BaseResource {
|
|
2282
|
+
constructor(options, actionId) {
|
|
2283
|
+
super(options);
|
|
2284
|
+
this.actionId = actionId;
|
|
2285
|
+
}
|
|
2286
|
+
// Helper function to transform workflow result to action result
|
|
2287
|
+
transformWorkflowResult(result) {
|
|
2288
|
+
if (result.status === "success") {
|
|
2289
|
+
return {
|
|
2290
|
+
success: result.result.success || false,
|
|
2291
|
+
applied: result.result.applied || false,
|
|
2292
|
+
branchName: result.result.branchName,
|
|
2293
|
+
message: result.result.message || "Agent builder action completed",
|
|
2294
|
+
validationResults: result.result.validationResults,
|
|
2295
|
+
error: result.result.error,
|
|
2296
|
+
errors: result.result.errors,
|
|
2297
|
+
stepResults: result.result.stepResults
|
|
2298
|
+
};
|
|
2299
|
+
} else if (result.status === "failed") {
|
|
2300
|
+
return {
|
|
2301
|
+
success: false,
|
|
2302
|
+
applied: false,
|
|
2303
|
+
message: `Agent builder action failed: ${result.error.message}`,
|
|
2304
|
+
error: result.error.message
|
|
2305
|
+
};
|
|
2306
|
+
} else {
|
|
2307
|
+
return {
|
|
2308
|
+
success: false,
|
|
2309
|
+
applied: false,
|
|
2310
|
+
message: "Agent builder action was suspended",
|
|
2311
|
+
error: "Workflow suspended - manual intervention required"
|
|
2312
|
+
};
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
/**
|
|
2316
|
+
* Creates a new agent builder action run and returns the runId.
|
|
2317
|
+
* This calls `/api/agent-builder/:actionId/create-run`.
|
|
2318
|
+
*/
|
|
2319
|
+
async createRun(params, runId) {
|
|
2320
|
+
const searchParams = new URLSearchParams();
|
|
2321
|
+
if (runId) {
|
|
2322
|
+
searchParams.set("runId", runId);
|
|
2323
|
+
}
|
|
2324
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2325
|
+
const { runtimeContext: _, ...actionParams } = params;
|
|
2326
|
+
const url = `/api/agent-builder/${this.actionId}/create-run${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2327
|
+
return this.request(url, {
|
|
2328
|
+
method: "POST",
|
|
2329
|
+
body: { ...actionParams, runtimeContext }
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* Starts agent builder action asynchronously and waits for completion.
|
|
2334
|
+
* This calls `/api/agent-builder/:actionId/start-async`.
|
|
2335
|
+
*/
|
|
2336
|
+
async startAsync(params, runId) {
|
|
2337
|
+
const searchParams = new URLSearchParams();
|
|
2338
|
+
if (runId) {
|
|
2339
|
+
searchParams.set("runId", runId);
|
|
2340
|
+
}
|
|
2341
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2342
|
+
const { runtimeContext: _, ...actionParams } = params;
|
|
2343
|
+
const url = `/api/agent-builder/${this.actionId}/start-async${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2344
|
+
const result = await this.request(url, {
|
|
2345
|
+
method: "POST",
|
|
2346
|
+
body: { ...actionParams, runtimeContext }
|
|
2347
|
+
});
|
|
2348
|
+
return this.transformWorkflowResult(result);
|
|
2349
|
+
}
|
|
2350
|
+
/**
|
|
2351
|
+
* Starts an existing agent builder action run.
|
|
2352
|
+
* This calls `/api/agent-builder/:actionId/start`.
|
|
2353
|
+
*/
|
|
2354
|
+
async startActionRun(params, runId) {
|
|
2355
|
+
const searchParams = new URLSearchParams();
|
|
2356
|
+
searchParams.set("runId", runId);
|
|
2357
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2358
|
+
const { runtimeContext: _, ...actionParams } = params;
|
|
2359
|
+
const url = `/api/agent-builder/${this.actionId}/start?${searchParams.toString()}`;
|
|
2360
|
+
return this.request(url, {
|
|
2361
|
+
method: "POST",
|
|
2362
|
+
body: { ...actionParams, runtimeContext }
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Resumes a suspended agent builder action step.
|
|
2367
|
+
* This calls `/api/agent-builder/:actionId/resume`.
|
|
2368
|
+
*/
|
|
2369
|
+
async resume(params, runId) {
|
|
2370
|
+
const searchParams = new URLSearchParams();
|
|
2371
|
+
searchParams.set("runId", runId);
|
|
2372
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2373
|
+
const { runtimeContext: _, ...resumeParams } = params;
|
|
2374
|
+
const url = `/api/agent-builder/${this.actionId}/resume?${searchParams.toString()}`;
|
|
2375
|
+
return this.request(url, {
|
|
2376
|
+
method: "POST",
|
|
2377
|
+
body: { ...resumeParams, runtimeContext }
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Resumes a suspended agent builder action step asynchronously.
|
|
2382
|
+
* This calls `/api/agent-builder/:actionId/resume-async`.
|
|
2383
|
+
*/
|
|
2384
|
+
async resumeAsync(params, runId) {
|
|
2385
|
+
const searchParams = new URLSearchParams();
|
|
2386
|
+
searchParams.set("runId", runId);
|
|
2387
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2388
|
+
const { runtimeContext: _, ...resumeParams } = params;
|
|
2389
|
+
const url = `/api/agent-builder/${this.actionId}/resume-async?${searchParams.toString()}`;
|
|
2390
|
+
const result = await this.request(url, {
|
|
2391
|
+
method: "POST",
|
|
2392
|
+
body: { ...resumeParams, runtimeContext }
|
|
2393
|
+
});
|
|
2394
|
+
return this.transformWorkflowResult(result);
|
|
2395
|
+
}
|
|
2396
|
+
/**
|
|
2397
|
+
* Creates an async generator that processes a readable stream and yields action records
|
|
2398
|
+
* separated by the Record Separator character (\x1E)
|
|
2399
|
+
*
|
|
2400
|
+
* @param stream - The readable stream to process
|
|
2401
|
+
* @returns An async generator that yields parsed records
|
|
2402
|
+
*/
|
|
2403
|
+
async *streamProcessor(stream) {
|
|
2404
|
+
const reader = stream.getReader();
|
|
2405
|
+
let doneReading = false;
|
|
2406
|
+
let buffer = "";
|
|
2407
|
+
try {
|
|
2408
|
+
while (!doneReading) {
|
|
2409
|
+
const { done, value } = await reader.read();
|
|
2410
|
+
doneReading = done;
|
|
2411
|
+
if (done && !value) continue;
|
|
2412
|
+
try {
|
|
2413
|
+
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2414
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
|
|
2415
|
+
buffer = chunks.pop() || "";
|
|
2416
|
+
for (const chunk of chunks) {
|
|
2417
|
+
if (chunk) {
|
|
2418
|
+
if (typeof chunk === "string") {
|
|
2419
|
+
try {
|
|
2420
|
+
const parsedChunk = JSON.parse(chunk);
|
|
2421
|
+
yield parsedChunk;
|
|
2422
|
+
} catch {
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
} catch {
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
if (buffer) {
|
|
2431
|
+
try {
|
|
2432
|
+
yield JSON.parse(buffer);
|
|
2433
|
+
} catch {
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
} finally {
|
|
2437
|
+
reader.cancel().catch(() => {
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
/**
|
|
2442
|
+
* Streams agent builder action progress in real-time.
|
|
2443
|
+
* This calls `/api/agent-builder/:actionId/stream`.
|
|
2444
|
+
*/
|
|
2445
|
+
async stream(params, runId) {
|
|
2446
|
+
const searchParams = new URLSearchParams();
|
|
2447
|
+
if (runId) {
|
|
2448
|
+
searchParams.set("runId", runId);
|
|
2449
|
+
}
|
|
2450
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2451
|
+
const { runtimeContext: _, ...actionParams } = params;
|
|
2452
|
+
const url = `/api/agent-builder/${this.actionId}/stream${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2453
|
+
const response = await this.request(url, {
|
|
2454
|
+
method: "POST",
|
|
2455
|
+
body: { ...actionParams, runtimeContext },
|
|
2456
|
+
stream: true
|
|
2457
|
+
});
|
|
2458
|
+
if (!response.ok) {
|
|
2459
|
+
throw new Error(`Failed to stream agent builder action: ${response.statusText}`);
|
|
2460
|
+
}
|
|
2461
|
+
if (!response.body) {
|
|
2462
|
+
throw new Error("Response body is null");
|
|
2463
|
+
}
|
|
2464
|
+
let failedChunk = void 0;
|
|
2465
|
+
const transformStream = new TransformStream({
|
|
2466
|
+
start() {
|
|
2467
|
+
},
|
|
2468
|
+
async transform(chunk, controller) {
|
|
2469
|
+
try {
|
|
2470
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2471
|
+
const chunks = decoded.split(RECORD_SEPARATOR3);
|
|
2472
|
+
for (const chunk2 of chunks) {
|
|
2473
|
+
if (chunk2) {
|
|
2474
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2475
|
+
try {
|
|
2476
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2477
|
+
controller.enqueue(parsedChunk);
|
|
2478
|
+
failedChunk = void 0;
|
|
2479
|
+
} catch {
|
|
2480
|
+
failedChunk = newChunk;
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
} catch {
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
});
|
|
2488
|
+
return response.body.pipeThrough(transformStream);
|
|
2489
|
+
}
|
|
2490
|
+
/**
|
|
2491
|
+
* Streams agent builder action progress in real-time using VNext streaming.
|
|
2492
|
+
* This calls `/api/agent-builder/:actionId/streamVNext`.
|
|
2493
|
+
*/
|
|
2494
|
+
async streamVNext(params, runId) {
|
|
2495
|
+
const searchParams = new URLSearchParams();
|
|
2496
|
+
if (runId) {
|
|
2497
|
+
searchParams.set("runId", runId);
|
|
2498
|
+
}
|
|
2499
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2500
|
+
const { runtimeContext: _, ...actionParams } = params;
|
|
2501
|
+
const url = `/api/agent-builder/${this.actionId}/streamVNext${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2502
|
+
const response = await this.request(url, {
|
|
2503
|
+
method: "POST",
|
|
2504
|
+
body: { ...actionParams, runtimeContext },
|
|
2505
|
+
stream: true
|
|
2506
|
+
});
|
|
2507
|
+
if (!response.ok) {
|
|
2508
|
+
throw new Error(`Failed to stream agent builder action VNext: ${response.statusText}`);
|
|
2509
|
+
}
|
|
2510
|
+
if (!response.body) {
|
|
2511
|
+
throw new Error("Response body is null");
|
|
2512
|
+
}
|
|
2513
|
+
let failedChunk = void 0;
|
|
2514
|
+
const transformStream = new TransformStream({
|
|
2515
|
+
start() {
|
|
2516
|
+
},
|
|
2517
|
+
async transform(chunk, controller) {
|
|
2518
|
+
try {
|
|
2519
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2520
|
+
const chunks = decoded.split(RECORD_SEPARATOR3);
|
|
2521
|
+
for (const chunk2 of chunks) {
|
|
2522
|
+
if (chunk2) {
|
|
2523
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2524
|
+
try {
|
|
2525
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2526
|
+
controller.enqueue(parsedChunk);
|
|
2527
|
+
failedChunk = void 0;
|
|
2528
|
+
} catch {
|
|
2529
|
+
failedChunk = newChunk;
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
} catch {
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
});
|
|
2537
|
+
return response.body.pipeThrough(transformStream);
|
|
2538
|
+
}
|
|
2539
|
+
/**
|
|
2540
|
+
* Watches an existing agent builder action run by runId.
|
|
2541
|
+
* This is used for hot reload recovery - it loads the existing run state
|
|
2542
|
+
* and streams any remaining progress.
|
|
2543
|
+
* This calls `/api/agent-builder/:actionId/watch`.
|
|
2544
|
+
*/
|
|
2545
|
+
async watch({ runId }, onRecord) {
|
|
2546
|
+
const url = `/api/agent-builder/${this.actionId}/watch?runId=${runId}`;
|
|
2547
|
+
const response = await this.request(url, {
|
|
2548
|
+
method: "GET",
|
|
2549
|
+
stream: true
|
|
2550
|
+
});
|
|
2551
|
+
if (!response.ok) {
|
|
2552
|
+
throw new Error(`Failed to watch agent builder action: ${response.statusText}`);
|
|
2553
|
+
}
|
|
2554
|
+
if (!response.body) {
|
|
2555
|
+
throw new Error("Response body is null");
|
|
2556
|
+
}
|
|
2557
|
+
for await (const record of this.streamProcessor(response.body)) {
|
|
2558
|
+
if (typeof record === "string") {
|
|
2559
|
+
onRecord(JSON.parse(record));
|
|
2560
|
+
} else {
|
|
2561
|
+
onRecord(record);
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* Gets a specific action run by its ID.
|
|
2567
|
+
* This calls `/api/agent-builder/:actionId/runs/:runId`.
|
|
2568
|
+
*/
|
|
2569
|
+
async runById(runId) {
|
|
2570
|
+
const url = `/api/agent-builder/${this.actionId}/runs/${runId}`;
|
|
2571
|
+
return this.request(url, {
|
|
2572
|
+
method: "GET"
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
/**
|
|
2576
|
+
* Gets details about this agent builder action.
|
|
2577
|
+
* This calls `/api/agent-builder/:actionId`.
|
|
2578
|
+
*/
|
|
2579
|
+
async details() {
|
|
2580
|
+
const result = await this.request(`/api/agent-builder/${this.actionId}`);
|
|
2581
|
+
return result;
|
|
2582
|
+
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Gets all runs for this agent builder action.
|
|
2585
|
+
* This calls `/api/agent-builder/:actionId/runs`.
|
|
2586
|
+
*/
|
|
2587
|
+
async runs(params) {
|
|
2588
|
+
const searchParams = new URLSearchParams();
|
|
2589
|
+
if (params?.fromDate) {
|
|
2590
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
2591
|
+
}
|
|
2592
|
+
if (params?.toDate) {
|
|
2593
|
+
searchParams.set("toDate", params.toDate.toISOString());
|
|
2594
|
+
}
|
|
2595
|
+
if (params?.limit !== void 0) {
|
|
2596
|
+
searchParams.set("limit", String(params.limit));
|
|
2597
|
+
}
|
|
2598
|
+
if (params?.offset !== void 0) {
|
|
2599
|
+
searchParams.set("offset", String(params.offset));
|
|
2600
|
+
}
|
|
2601
|
+
if (params?.resourceId) {
|
|
2602
|
+
searchParams.set("resourceId", params.resourceId);
|
|
2603
|
+
}
|
|
2604
|
+
const url = `/api/agent-builder/${this.actionId}/runs${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2605
|
+
return this.request(url, {
|
|
2606
|
+
method: "GET"
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* Gets the execution result of an agent builder action run.
|
|
2611
|
+
* This calls `/api/agent-builder/:actionId/runs/:runId/execution-result`.
|
|
2612
|
+
*/
|
|
2613
|
+
async runExecutionResult(runId) {
|
|
2614
|
+
const url = `/api/agent-builder/${this.actionId}/runs/${runId}/execution-result`;
|
|
2615
|
+
return this.request(url, {
|
|
2616
|
+
method: "GET"
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* Cancels an agent builder action run.
|
|
2621
|
+
* This calls `/api/agent-builder/:actionId/runs/:runId/cancel`.
|
|
2622
|
+
*/
|
|
2623
|
+
async cancelRun(runId) {
|
|
2624
|
+
const url = `/api/agent-builder/${this.actionId}/runs/${runId}/cancel`;
|
|
2625
|
+
return this.request(url, {
|
|
2626
|
+
method: "POST"
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
/**
|
|
2630
|
+
* Sends an event to an agent builder action run.
|
|
2631
|
+
* This calls `/api/agent-builder/:actionId/runs/:runId/send-event`.
|
|
2632
|
+
*/
|
|
2633
|
+
async sendRunEvent(params) {
|
|
2634
|
+
const url = `/api/agent-builder/${this.actionId}/runs/${params.runId}/send-event`;
|
|
2635
|
+
return this.request(url, {
|
|
2636
|
+
method: "POST",
|
|
2637
|
+
body: { event: params.event, data: params.data }
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
};
|
|
2641
|
+
|
|
2262
2642
|
// src/resources/observability.ts
|
|
2263
2643
|
var Observability = class extends BaseResource {
|
|
2264
2644
|
constructor(options) {
|
|
@@ -2370,7 +2750,7 @@ var NetworkMemoryThread = class extends BaseResource {
|
|
|
2370
2750
|
};
|
|
2371
2751
|
|
|
2372
2752
|
// src/resources/vNextNetwork.ts
|
|
2373
|
-
var
|
|
2753
|
+
var RECORD_SEPARATOR4 = "";
|
|
2374
2754
|
var VNextNetwork = class extends BaseResource {
|
|
2375
2755
|
constructor(options, networkId) {
|
|
2376
2756
|
super(options);
|
|
@@ -2422,7 +2802,7 @@ var VNextNetwork = class extends BaseResource {
|
|
|
2422
2802
|
if (done && !value) continue;
|
|
2423
2803
|
try {
|
|
2424
2804
|
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2425
|
-
const chunks = (buffer + decoded).split(
|
|
2805
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR4);
|
|
2426
2806
|
buffer = chunks.pop() || "";
|
|
2427
2807
|
for (const chunk of chunks) {
|
|
2428
2808
|
if (chunk) {
|
|
@@ -2673,6 +3053,20 @@ var MastraClient = class extends BaseResource {
|
|
|
2673
3053
|
getWorkflow(workflowId) {
|
|
2674
3054
|
return new Workflow(this.options, workflowId);
|
|
2675
3055
|
}
|
|
3056
|
+
/**
|
|
3057
|
+
* Gets all available agent builder actions
|
|
3058
|
+
* @returns Promise containing map of action IDs to action details
|
|
3059
|
+
*/
|
|
3060
|
+
getAgentBuilderActions() {
|
|
3061
|
+
return this.request("/api/agent-builder/");
|
|
3062
|
+
}
|
|
3063
|
+
/**
|
|
3064
|
+
* Gets an agent builder instance for executing agent-builder workflows
|
|
3065
|
+
* @returns AgentBuilder instance
|
|
3066
|
+
*/
|
|
3067
|
+
getAgentBuilderAction(actionId) {
|
|
3068
|
+
return new AgentBuilder(this.options, actionId);
|
|
3069
|
+
}
|
|
2676
3070
|
/**
|
|
2677
3071
|
* Gets a vector instance by name
|
|
2678
3072
|
* @param vectorName - Name of the vector to retrieve
|