@mastra/client-js 1.28.0-alpha.5 → 1.28.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 +157 -0
- package/dist/client.d.ts +9 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +123 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +123 -127
- package/dist/index.js.map +1 -1
- package/dist/resources/{harness.d.ts → agent-controller.d.ts} +75 -71
- package/dist/resources/agent-controller.d.ts.map +1 -0
- package/dist/resources/agent.d.ts +1 -0
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +535 -534
- package/dist/route-types.generated.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/resources/harness.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export * from './types.js';
|
|
|
3
3
|
export * from './tools.js';
|
|
4
4
|
export type { ChannelPlatformInfo, ChannelInstallationInfo, ChannelConnectOAuth, ChannelConnectDeepLink, ChannelConnectImmediate, ChannelConnectResult, } from './resources/channels.js';
|
|
5
5
|
export type { AgentCardSignatureKeyProviderInput, AgentCardVerificationKey, GetAgentCardOptions, VerifyAgentCardSignatureOptions, } from './resources/a2a.js';
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
6
|
+
export { agentControllerMessageText } from './resources/agent-controller.js';
|
|
7
|
+
export type { AgentControllerInfo, AgentControllerMessage, AgentControllerMessageContent, AgentControllerEvent, KnownAgentControllerEvent, OtherAgentControllerEvent, CreateAgentControllerSessionResponse, SubscribeAgentControllerSessionOptions, AgentControllerSubscription, AgentControllerSessionState, AgentControllerSessionSettings, AgentControllerOMProgress, AgentControllerModeInfo, AgentControllerThreadInfo, AgentControllerTaskSnapshot, AgentControllerAvailableModel, AgentControllerWorkspaceStatus, AgentControllerGoalRecord, SendNotificationInput, SendNotificationResult, PlanResume, PermissionPolicy, PermissionRules, ToolCategory, } from './resources/agent-controller.js';
|
|
8
8
|
export { RequestContext } from '@mastra/core/request-context';
|
|
9
9
|
export type { ObservabilityCollector } from './observability/types.js';
|
|
10
10
|
export type { UIMessageWithMetadata } from '@mastra/core/agent';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,oCAAoC,EACpC,sCAAsC,EACtC,2BAA2B,EAC3B,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAC3B,6BAA6B,EAC7B,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,YAAY,EACV,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1964,7 +1964,6 @@ var Agent = class extends BaseResource {
|
|
|
1964
1964
|
throw new Error("No response body");
|
|
1965
1965
|
}
|
|
1966
1966
|
try {
|
|
1967
|
-
let toolCalls = [];
|
|
1968
1967
|
let messages = [];
|
|
1969
1968
|
let streamRunId = processedParams.runId;
|
|
1970
1969
|
const [streamForController, streamForProcessing] = response.body.tee();
|
|
@@ -2004,23 +2003,39 @@ var Agent = class extends BaseResource {
|
|
|
2004
2003
|
},
|
|
2005
2004
|
onFinish: async ({ finishReason, message }) => {
|
|
2006
2005
|
if (finishReason === "tool-calls") {
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2006
|
+
const toolInvocationsById = /* @__PURE__ */ new Map();
|
|
2007
|
+
for (const part of message?.parts ?? []) {
|
|
2008
|
+
if (part.type !== "tool-invocation" || !part.toolInvocation?.toolCallId) {
|
|
2009
|
+
continue;
|
|
2010
|
+
}
|
|
2009
2011
|
const toolInvocationWithMetadata = message?.toolInvocations?.find(
|
|
2010
|
-
(invocation) => invocation.toolCallId ===
|
|
2012
|
+
(invocation) => invocation.toolCallId === part.toolInvocation.toolCallId
|
|
2011
2013
|
);
|
|
2012
|
-
|
|
2014
|
+
toolInvocationsById.set(part.toolInvocation.toolCallId, {
|
|
2013
2015
|
...toolInvocationWithMetadata,
|
|
2014
|
-
...
|
|
2015
|
-
...!getClientToolObservabilityContext(
|
|
2016
|
+
...part.toolInvocation,
|
|
2017
|
+
...!getClientToolObservabilityContext(part.toolInvocation) && toolInvocationWithMetadata ? { observability: getClientToolObservabilityContext(toolInvocationWithMetadata) } : {}
|
|
2016
2018
|
});
|
|
2017
2019
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2020
|
+
for (const toolInvocation of message?.toolInvocations ?? []) {
|
|
2021
|
+
if (!toolInvocation.toolCallId) {
|
|
2022
|
+
continue;
|
|
2023
|
+
}
|
|
2024
|
+
toolInvocationsById.set(toolInvocation.toolCallId, {
|
|
2025
|
+
...toolInvocationsById.get(toolInvocation.toolCallId),
|
|
2026
|
+
...toolInvocation
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
const executableToolCalls = [...toolInvocationsById.values()].filter((toolCall) => {
|
|
2030
|
+
const clientTool = processedParams.clientTools?.[toolCall.toolName];
|
|
2031
|
+
return Boolean(clientTool?.execute);
|
|
2032
|
+
});
|
|
2033
|
+
if (executableToolCalls.length > 0) {
|
|
2034
|
+
const syntheticChunks = [];
|
|
2035
|
+
const toolResultContents = [];
|
|
2036
|
+
for (const toolCall of executableToolCalls) {
|
|
2037
|
+
const clientTool = processedParams.clientTools?.[toolCall.toolName];
|
|
2038
|
+
const runId = streamRunId ?? toolCall.toolCallId;
|
|
2024
2039
|
let result;
|
|
2025
2040
|
let modelOutput;
|
|
2026
2041
|
let observability;
|
|
@@ -2028,16 +2043,16 @@ var Agent = class extends BaseResource {
|
|
|
2028
2043
|
try {
|
|
2029
2044
|
({ result, observability } = await executeClientToolWithObservability({
|
|
2030
2045
|
clientTool,
|
|
2031
|
-
args:
|
|
2032
|
-
toolName:
|
|
2033
|
-
parentContext: getClientToolObservabilityContext(
|
|
2046
|
+
args: toolCall?.args,
|
|
2047
|
+
toolName: toolCall.toolName,
|
|
2048
|
+
parentContext: getClientToolObservabilityContext(toolCall),
|
|
2034
2049
|
executeContext: {
|
|
2035
2050
|
requestContext: processedParams.requestContext,
|
|
2036
2051
|
tracingContext: { currentSpan: void 0 },
|
|
2037
2052
|
agent: {
|
|
2038
2053
|
agentId: this.agentId,
|
|
2039
2054
|
messages: response.messages,
|
|
2040
|
-
toolCallId:
|
|
2055
|
+
toolCallId: toolCall?.toolCallId,
|
|
2041
2056
|
suspend: async () => {
|
|
2042
2057
|
},
|
|
2043
2058
|
threadId,
|
|
@@ -2051,8 +2066,8 @@ var Agent = class extends BaseResource {
|
|
|
2051
2066
|
runId,
|
|
2052
2067
|
from: "AGENT",
|
|
2053
2068
|
payload: {
|
|
2054
|
-
toolCallId:
|
|
2055
|
-
toolName:
|
|
2069
|
+
toolCallId: toolCall.toolCallId,
|
|
2070
|
+
toolName: toolCall.toolName,
|
|
2056
2071
|
result,
|
|
2057
2072
|
isError: false,
|
|
2058
2073
|
providerExecuted: false
|
|
@@ -2064,19 +2079,31 @@ var Agent = class extends BaseResource {
|
|
|
2064
2079
|
runId,
|
|
2065
2080
|
from: "AGENT",
|
|
2066
2081
|
payload: {
|
|
2067
|
-
toolCallId:
|
|
2068
|
-
toolName:
|
|
2082
|
+
toolCallId: toolCall.toolCallId,
|
|
2083
|
+
toolName: toolCall.toolName,
|
|
2069
2084
|
error,
|
|
2070
|
-
args:
|
|
2085
|
+
args: toolCall?.args,
|
|
2071
2086
|
providerExecuted: false
|
|
2072
2087
|
}
|
|
2073
2088
|
};
|
|
2074
2089
|
result = { error: error instanceof Error ? error.message : String(error) };
|
|
2075
2090
|
}
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2091
|
+
syntheticChunks.push(synthetic);
|
|
2092
|
+
toolResultContents.push({
|
|
2093
|
+
type: "tool-result",
|
|
2094
|
+
toolCallId: toolCall.toolCallId,
|
|
2095
|
+
toolName: toolCall.toolName,
|
|
2096
|
+
input: toolCall.args,
|
|
2097
|
+
result,
|
|
2098
|
+
...modelOutput != null ? { providerOptions: { mastra: { modelOutput } } } : {},
|
|
2099
|
+
...observability ? { __mastraObservability: observability } : {}
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
try {
|
|
2103
|
+
await pipePromise;
|
|
2104
|
+
} catch {
|
|
2105
|
+
}
|
|
2106
|
+
for (const synthetic of syntheticChunks) {
|
|
2080
2107
|
try {
|
|
2081
2108
|
const errorForSerialization = synthetic.type === "tool-error" ? synthetic.payload.error : void 0;
|
|
2082
2109
|
const serializedError = errorForSerialization instanceof Error ? {
|
|
@@ -2092,55 +2119,30 @@ var Agent = class extends BaseResource {
|
|
|
2092
2119
|
} catch (enqueueErr) {
|
|
2093
2120
|
console.error("Failed to enqueue synthetic tool-result chunk:", enqueueErr);
|
|
2094
2121
|
}
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
const toolInvocation = lastMessage?.toolInvocations?.find(
|
|
2117
|
-
(toolInvocation2) => toolInvocation2.toolCallId === toolCall2.toolCallId
|
|
2122
|
+
}
|
|
2123
|
+
const toolResultMessage = {
|
|
2124
|
+
role: "tool",
|
|
2125
|
+
content: toolResultContents
|
|
2126
|
+
};
|
|
2127
|
+
const updatedMessages = threadId ? [toolResultMessage] : [
|
|
2128
|
+
...Array.isArray(processedParams.messages) ? processedParams.messages : [],
|
|
2129
|
+
...messages,
|
|
2130
|
+
toolResultMessage
|
|
2131
|
+
];
|
|
2132
|
+
const recursionRoute = route === "resume-stream" ? "stream" : route === "resume-stream-until-idle" ? "stream-until-idle" : route;
|
|
2133
|
+
try {
|
|
2134
|
+
await this.processStreamResponse(
|
|
2135
|
+
{
|
|
2136
|
+
...processedParams,
|
|
2137
|
+
messages: updatedMessages
|
|
2138
|
+
},
|
|
2139
|
+
controller,
|
|
2140
|
+
recursionRoute
|
|
2118
2141
|
);
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
toolInvocation.result = result;
|
|
2122
|
-
if (observability) {
|
|
2123
|
-
toolInvocation.__mastraObservability = observability;
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
const newMessages = lastMessage != null ? [...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messages];
|
|
2127
|
-
const updatedMessages = threadId ? newMessages : [...Array.isArray(processedParams.messages) ? processedParams.messages : [], ...newMessages];
|
|
2128
|
-
const recursionRoute = route === "resume-stream" ? "stream" : route === "resume-stream-until-idle" ? "stream-until-idle" : route;
|
|
2129
|
-
try {
|
|
2130
|
-
await this.processStreamResponse(
|
|
2131
|
-
{
|
|
2132
|
-
...processedParams,
|
|
2133
|
-
messages: updatedMessages
|
|
2134
|
-
},
|
|
2135
|
-
controller,
|
|
2136
|
-
recursionRoute
|
|
2137
|
-
);
|
|
2138
|
-
} catch (error) {
|
|
2139
|
-
console.error("Error processing recursive stream response:", error);
|
|
2140
|
-
}
|
|
2142
|
+
} catch (error) {
|
|
2143
|
+
console.error("Error processing recursive stream response:", error);
|
|
2141
2144
|
}
|
|
2142
|
-
}
|
|
2143
|
-
if (!shouldExecuteClientTool) {
|
|
2145
|
+
} else {
|
|
2144
2146
|
await pipePromise;
|
|
2145
2147
|
controller.close();
|
|
2146
2148
|
}
|
|
@@ -2604,28 +2606,6 @@ var Agent = class extends BaseResource {
|
|
|
2604
2606
|
}
|
|
2605
2607
|
}
|
|
2606
2608
|
});
|
|
2607
|
-
const lastMessage = JSON.parse(JSON.stringify(messages[messages.length - 1]));
|
|
2608
|
-
const toolInvocationPart = lastMessage?.parts?.find(
|
|
2609
|
-
(part) => part.type === "tool-invocation" && part.toolInvocation?.toolCallId === toolCall2.toolCallId
|
|
2610
|
-
);
|
|
2611
|
-
if (toolInvocationPart) {
|
|
2612
|
-
toolInvocationPart.toolInvocation = {
|
|
2613
|
-
...toolInvocationPart.toolInvocation,
|
|
2614
|
-
state: "result",
|
|
2615
|
-
result,
|
|
2616
|
-
...observability ? { __mastraObservability: observability } : {}
|
|
2617
|
-
};
|
|
2618
|
-
}
|
|
2619
|
-
const toolInvocation = lastMessage?.toolInvocations?.find(
|
|
2620
|
-
(toolInvocation2) => toolInvocation2.toolCallId === toolCall2.toolCallId
|
|
2621
|
-
);
|
|
2622
|
-
if (toolInvocation) {
|
|
2623
|
-
toolInvocation.state = "result";
|
|
2624
|
-
toolInvocation.result = result;
|
|
2625
|
-
if (observability) {
|
|
2626
|
-
toolInvocation.__mastraObservability = observability;
|
|
2627
|
-
}
|
|
2628
|
-
}
|
|
2629
2609
|
const writer = writable.getWriter();
|
|
2630
2610
|
try {
|
|
2631
2611
|
await writer.write(
|
|
@@ -2639,8 +2619,24 @@ var Agent = class extends BaseResource {
|
|
|
2639
2619
|
} finally {
|
|
2640
2620
|
writer.releaseLock();
|
|
2641
2621
|
}
|
|
2642
|
-
const
|
|
2643
|
-
|
|
2622
|
+
const toolResultMessage = {
|
|
2623
|
+
role: "tool",
|
|
2624
|
+
content: [
|
|
2625
|
+
{
|
|
2626
|
+
type: "tool-result",
|
|
2627
|
+
toolCallId: toolCall2.toolCallId,
|
|
2628
|
+
toolName: toolCall2.toolName,
|
|
2629
|
+
input: toolCall2.args,
|
|
2630
|
+
result,
|
|
2631
|
+
...observability ? { __mastraObservability: observability } : {}
|
|
2632
|
+
}
|
|
2633
|
+
]
|
|
2634
|
+
};
|
|
2635
|
+
const updatedMessages = threadId ? [toolResultMessage] : [
|
|
2636
|
+
...Array.isArray(processedParams.messages) ? processedParams.messages : [],
|
|
2637
|
+
...messages,
|
|
2638
|
+
toolResultMessage
|
|
2639
|
+
];
|
|
2644
2640
|
this.processStreamResponseLegacy(
|
|
2645
2641
|
{
|
|
2646
2642
|
...processedParams,
|
|
@@ -6082,17 +6078,17 @@ var Channels = class extends BaseResource {
|
|
|
6082
6078
|
}
|
|
6083
6079
|
};
|
|
6084
6080
|
|
|
6085
|
-
// src/resources/
|
|
6086
|
-
var
|
|
6087
|
-
constructor(options,
|
|
6081
|
+
// src/resources/agent-controller.ts
|
|
6082
|
+
var AgentControllerSession = class extends BaseResource {
|
|
6083
|
+
constructor(options, controllerId, resourceId) {
|
|
6088
6084
|
super(options);
|
|
6089
|
-
this.
|
|
6085
|
+
this.controllerId = controllerId;
|
|
6090
6086
|
this.resourceId = resourceId;
|
|
6091
6087
|
}
|
|
6092
|
-
|
|
6088
|
+
controllerId;
|
|
6093
6089
|
resourceId;
|
|
6094
6090
|
base() {
|
|
6095
|
-
return `/
|
|
6091
|
+
return `/agent-controller/${encodeURIComponent(this.controllerId)}/sessions/${encodeURIComponent(this.resourceId)}`;
|
|
6096
6092
|
}
|
|
6097
6093
|
/**
|
|
6098
6094
|
* Create or resume this session. Pass `tags` to scope initial thread
|
|
@@ -6102,7 +6098,7 @@ var HarnessSession = class extends BaseResource {
|
|
|
6102
6098
|
* most recent thread across the whole resource.
|
|
6103
6099
|
*/
|
|
6104
6100
|
create(options) {
|
|
6105
|
-
return this.request(`/
|
|
6101
|
+
return this.request(`/agent-controller/${encodeURIComponent(this.controllerId)}/sessions`, {
|
|
6106
6102
|
method: "POST",
|
|
6107
6103
|
body: { resourceId: this.resourceId, tags: options?.tags }
|
|
6108
6104
|
});
|
|
@@ -6114,7 +6110,7 @@ var HarnessSession = class extends BaseResource {
|
|
|
6114
6110
|
async subscribe(options) {
|
|
6115
6111
|
const response = await this.request(`${this.base()}/stream`, { stream: true });
|
|
6116
6112
|
if (!response.body) {
|
|
6117
|
-
throw new Error("No response body for
|
|
6113
|
+
throw new Error("No response body for agent controller session stream");
|
|
6118
6114
|
}
|
|
6119
6115
|
const reader = response.body.getReader();
|
|
6120
6116
|
const decoder = new TextDecoder();
|
|
@@ -6341,35 +6337,35 @@ var HarnessSession = class extends BaseResource {
|
|
|
6341
6337
|
});
|
|
6342
6338
|
}
|
|
6343
6339
|
};
|
|
6344
|
-
var
|
|
6345
|
-
constructor(options,
|
|
6340
|
+
var AgentController = class extends BaseResource {
|
|
6341
|
+
constructor(options, controllerId) {
|
|
6346
6342
|
super(options);
|
|
6347
|
-
this.
|
|
6343
|
+
this.controllerId = controllerId;
|
|
6348
6344
|
}
|
|
6349
|
-
|
|
6345
|
+
controllerId;
|
|
6350
6346
|
basePath() {
|
|
6351
|
-
return `/
|
|
6347
|
+
return `/agent-controller/${encodeURIComponent(this.controllerId)}`;
|
|
6352
6348
|
}
|
|
6353
|
-
/** List the modes configured on this
|
|
6349
|
+
/** List the modes configured on this agent controller (e.g. build, plan). */
|
|
6354
6350
|
async listModes() {
|
|
6355
6351
|
const body = await this.request(`${this.basePath()}/modes`);
|
|
6356
6352
|
return body.modes;
|
|
6357
6353
|
}
|
|
6358
|
-
/** List available models on this
|
|
6354
|
+
/** List available models on this agent controller (with auth status and use counts). */
|
|
6359
6355
|
async listModels() {
|
|
6360
6356
|
const body = await this.request(`${this.basePath()}/models`);
|
|
6361
6357
|
return body.models;
|
|
6362
6358
|
}
|
|
6363
|
-
/** Get workspace status for this
|
|
6359
|
+
/** Get workspace status for this agent controller. */
|
|
6364
6360
|
async workspaceStatus() {
|
|
6365
6361
|
return this.request(`${this.basePath()}/workspace`);
|
|
6366
6362
|
}
|
|
6367
6363
|
/** Scope to a session bound to `resourceId` (e.g. a user or conversation id). */
|
|
6368
6364
|
session(resourceId) {
|
|
6369
|
-
return new
|
|
6365
|
+
return new AgentControllerSession(this.options, this.controllerId, resourceId);
|
|
6370
6366
|
}
|
|
6371
6367
|
};
|
|
6372
|
-
function
|
|
6368
|
+
function agentControllerMessageText(message) {
|
|
6373
6369
|
return message.content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("");
|
|
6374
6370
|
}
|
|
6375
6371
|
|
|
@@ -6416,21 +6412,21 @@ var MastraClient = class extends BaseResource {
|
|
|
6416
6412
|
return new Agent(this.options, agentId, version);
|
|
6417
6413
|
}
|
|
6418
6414
|
/**
|
|
6419
|
-
* Lists the
|
|
6420
|
-
* @returns Promise containing an array of
|
|
6415
|
+
* Lists the agent controllers hosted on the connected Mastra instance.
|
|
6416
|
+
* @returns Promise containing an array of agent controller identifiers
|
|
6421
6417
|
*/
|
|
6422
|
-
async
|
|
6423
|
-
const body = await this.request("/
|
|
6424
|
-
return body.
|
|
6418
|
+
async listAgentControllers() {
|
|
6419
|
+
const body = await this.request("/agent-controller");
|
|
6420
|
+
return body.agentControllers;
|
|
6425
6421
|
}
|
|
6426
6422
|
/**
|
|
6427
|
-
* Scopes to
|
|
6428
|
-
* `
|
|
6429
|
-
* events, and send messages.
|
|
6430
|
-
* @param
|
|
6423
|
+
* Scopes to an agent controller hosted on the connected Mastra instance. Use
|
|
6424
|
+
* `getAgentController(id).session(resourceId)` to create/resume a session,
|
|
6425
|
+
* stream its events, and send messages.
|
|
6426
|
+
* @param controllerId - The id the agent controller is registered under on Mastra
|
|
6431
6427
|
*/
|
|
6432
|
-
|
|
6433
|
-
return new
|
|
6428
|
+
getAgentController(controllerId) {
|
|
6429
|
+
return new AgentController(this.options, controllerId);
|
|
6434
6430
|
}
|
|
6435
6431
|
/**
|
|
6436
6432
|
* Lists memory threads with optional filtering by resourceId and/or metadata
|
|
@@ -8061,6 +8057,6 @@ function createTool(opts) {
|
|
|
8061
8057
|
return new ClientTool(opts);
|
|
8062
8058
|
}
|
|
8063
8059
|
|
|
8064
|
-
export { ClientTool, MastraClient, MastraClientError,
|
|
8060
|
+
export { ClientTool, MastraClient, MastraClientError, agentControllerMessageText, createTool };
|
|
8065
8061
|
//# sourceMappingURL=index.js.map
|
|
8066
8062
|
//# sourceMappingURL=index.js.map
|