@mastra/client-js 1.23.2 → 1.24.0-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/dist/index.js CHANGED
@@ -973,25 +973,49 @@ var Agent = class extends BaseResource {
973
973
  type: "tool-result",
974
974
  toolCallId: toolCall.toolCallId,
975
975
  toolName: toolCall.toolName,
976
- result
976
+ args: toolCall.args,
977
+ result,
978
+ ...observability ? { __mastraObservability: observability } : {}
977
979
  };
978
- if (observability) {
979
- toolResultContent.__mastraObservability = observability;
980
- }
981
980
  await onChunk({
982
981
  type: "tool-result",
983
982
  runId,
984
983
  payload: toolResultContent
985
984
  });
985
+ const continuationToolCall = {
986
+ type: "tool-call",
987
+ toolCallId: toolCall.toolCallId,
988
+ toolName: toolCall.toolName,
989
+ input: toolCall.args
990
+ };
991
+ const continuationToolResult = {
992
+ type: "tool-result",
993
+ toolCallId: toolCall.toolCallId,
994
+ toolName: toolCall.toolName,
995
+ output: { type: "json", value: result },
996
+ ...observability ? { __mastraObservability: observability } : {}
997
+ };
986
998
  toolResultMessages.push({
987
- role: "tool",
988
- content: [toolResultContent]
999
+ role: "assistant",
1000
+ content: [continuationToolCall, continuationToolResult]
989
1001
  });
990
1002
  }
991
1003
  if (toolResultMessages.length === 0) {
992
1004
  agent.deleteSignalRuntimeOptions(runId);
993
1005
  return;
994
1006
  }
1007
+ const continuationStreamOptions = {
1008
+ ...activeRuntimeOptions,
1009
+ requestContext: processedRequestContext,
1010
+ memory: threadId ? { thread: threadId, resource: resourceId } : void 0,
1011
+ clientTools: processedClientTools
1012
+ };
1013
+ agent.setSignalRuntimeOptions({
1014
+ resourceId,
1015
+ threadId,
1016
+ streamOptions: continuationStreamOptions
1017
+ });
1018
+ const continuationMessages = threadId ? toolResultMessages : [...finishPayload.payload?.messages?.nonUser ?? [], ...toolResultMessages];
995
1019
  try {
996
1020
  await agent.sendToolApproval({
997
1021
  resourceId: resourceId || agent.agentId,
@@ -999,15 +1023,11 @@ var Agent = class extends BaseResource {
999
1023
  toolCallId: pendingToolCalls[0].toolCallId,
1000
1024
  approved: true,
1001
1025
  requestContext: processedRequestContext,
1002
- messages: threadId ? toolResultMessages : [...finishPayload.payload?.messages?.nonUser ?? [], ...toolResultMessages],
1003
- streamOptions: {
1004
- ...activeRuntimeOptions,
1005
- requestContext: processedRequestContext,
1006
- memory: threadId ? { thread: threadId, resource: resourceId } : void 0,
1007
- clientTools: processedClientTools
1008
- }
1026
+ messages: continuationMessages,
1027
+ streamOptions: continuationStreamOptions
1009
1028
  });
1010
1029
  } catch (error) {
1030
+ agent.deleteLatestSignalRuntimeOptions({ resourceId, threadId });
1011
1031
  console.error("Error running client-tool continuation:", error);
1012
1032
  } finally {
1013
1033
  agent.deleteSignalRuntimeOptions(runId);
@@ -7129,6 +7149,23 @@ var MastraClient = class extends BaseResource {
7129
7149
  getBuilderSettings() {
7130
7150
  return this.request("/editor/builder/settings");
7131
7151
  }
7152
+ /**
7153
+ * Retrieves the AI providers/models available under the active builder model
7154
+ * policy. The server applies the EE allowlist, so the result can be rendered
7155
+ * directly in the model picker.
7156
+ * @returns Promise containing the policy-filtered providers/models
7157
+ */
7158
+ getBuilderAvailableModels() {
7159
+ return this.request("/editor/builder/models/available");
7160
+ }
7161
+ /**
7162
+ * Retrieves the authoritative list of valid permission-pattern strings.
7163
+ * Used by Studio to validate route→permission literals and gate the sidebar.
7164
+ * @returns Promise containing the permission patterns
7165
+ */
7166
+ getPermissionPatterns() {
7167
+ return this.request("/auth/permission-patterns");
7168
+ }
7132
7169
  /**
7133
7170
  * Retrieves Agent Builder infrastructure configuration and resolution status.
7134
7171
  * Requires `infrastructure:read` permission.