@mastra/react 1.0.0-beta.24 → 1.0.0-beta.25
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 +57 -0
- package/dist/{chunk-55VPMN3N-BuLK6rn1.js → chunk-55VPMN3N-Ax1F4Y75.js} +2 -2
- package/dist/{chunk-55VPMN3N-BuLK6rn1.js.map → chunk-55VPMN3N-Ax1F4Y75.js.map} +1 -1
- package/dist/{chunk-55VPMN3N-Dhj5NfGj.cjs → chunk-55VPMN3N-BHqoDkCq.cjs} +2 -2
- package/dist/{chunk-55VPMN3N-Dhj5NfGj.cjs.map → chunk-55VPMN3N-BHqoDkCq.cjs.map} +1 -1
- package/dist/{index-BEw00-Pp.cjs → index-ChvWx-iU.cjs} +75 -6
- package/dist/{index-BEw00-Pp.cjs.map → index-ChvWx-iU.cjs.map} +1 -1
- package/dist/{index-CIU9zuI1.js → index-D3JtF_Zl.js} +75 -6
- package/dist/{index-CIU9zuI1.js.map → index-D3JtF_Zl.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/src/agent/hooks.d.ts +2 -0
- package/dist/src/lib/ai-sdk/types.d.ts +16 -0
- package/dist/{token-6GSAFR2W-SPYPLMBM-DPP_j841.cjs → token-6GSAFR2W-SPYPLMBM-CWoxKwfk.cjs} +3 -3
- package/dist/{token-6GSAFR2W-SPYPLMBM-DPP_j841.cjs.map → token-6GSAFR2W-SPYPLMBM-CWoxKwfk.cjs.map} +1 -1
- package/dist/{token-6GSAFR2W-SPYPLMBM-Bmb7aObX.js → token-6GSAFR2W-SPYPLMBM-ChURikIE.js} +3 -3
- package/dist/{token-6GSAFR2W-SPYPLMBM-Bmb7aObX.js.map → token-6GSAFR2W-SPYPLMBM-ChURikIE.js.map} +1 -1
- package/dist/{token-util-NEHG7TUY-JRJTGTAB-0WkcL_9T.cjs → token-util-NEHG7TUY-JRJTGTAB-BU9ZxL1w.cjs} +2 -2
- package/dist/{token-util-NEHG7TUY-JRJTGTAB-0WkcL_9T.cjs.map → token-util-NEHG7TUY-JRJTGTAB-BU9ZxL1w.cjs.map} +1 -1
- package/dist/{token-util-NEHG7TUY-JRJTGTAB-BLZ0BA54.js → token-util-NEHG7TUY-JRJTGTAB-hEay2AHp.js} +2 -2
- package/dist/{token-util-NEHG7TUY-JRJTGTAB-BLZ0BA54.js.map → token-util-NEHG7TUY-JRJTGTAB-hEay2AHp.js.map} +1 -1
- package/package.json +3 -3
|
@@ -3129,8 +3129,8 @@ var require_get_vercel_oidc_token = __commonJS$2({
|
|
|
3129
3129
|
}
|
|
3130
3130
|
try {
|
|
3131
3131
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
3132
|
-
await import('./token-util-NEHG7TUY-JRJTGTAB-
|
|
3133
|
-
await import('./token-6GSAFR2W-SPYPLMBM-
|
|
3132
|
+
await import('./token-util-NEHG7TUY-JRJTGTAB-hEay2AHp.js'),
|
|
3133
|
+
await import('./token-6GSAFR2W-SPYPLMBM-ChURikIE.js')
|
|
3134
3134
|
]);
|
|
3135
3135
|
if (!token || isExpired(getTokenPayload(token))) {
|
|
3136
3136
|
await refreshToken();
|
|
@@ -19982,7 +19982,8 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
19982
19982
|
topP,
|
|
19983
19983
|
instructions,
|
|
19984
19984
|
providerOptions,
|
|
19985
|
-
maxSteps
|
|
19985
|
+
maxSteps,
|
|
19986
|
+
requireToolApproval
|
|
19986
19987
|
} = modelSettings || {};
|
|
19987
19988
|
setIsRunning(true);
|
|
19988
19989
|
const clientWithAbort = new MastraClient({
|
|
@@ -19990,8 +19991,10 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
19990
19991
|
abortSignal: signal
|
|
19991
19992
|
});
|
|
19992
19993
|
const agent = clientWithAbort.getAgent(agentId);
|
|
19994
|
+
const runId = v4();
|
|
19995
|
+
_currentRunId.current = runId;
|
|
19993
19996
|
const response = await agent.generate(coreUserMessages, {
|
|
19994
|
-
runId
|
|
19997
|
+
runId,
|
|
19995
19998
|
maxSteps,
|
|
19996
19999
|
modelSettings: {
|
|
19997
20000
|
frequencyPenalty,
|
|
@@ -20006,8 +20009,30 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
20006
20009
|
requestContext,
|
|
20007
20010
|
...threadId ? { memory: { thread: threadId, resource: resourceId || agentId } } : {},
|
|
20008
20011
|
providerOptions,
|
|
20009
|
-
tracingOptions
|
|
20012
|
+
tracingOptions,
|
|
20013
|
+
requireToolApproval
|
|
20010
20014
|
});
|
|
20015
|
+
if (response.finishReason === "suspended" && response.suspendPayload) {
|
|
20016
|
+
const { toolCallId, toolName, args } = response.suspendPayload;
|
|
20017
|
+
if (response.response?.uiMessages) {
|
|
20018
|
+
const mastraUIMessages = (response.response.uiMessages || []).map((message) => ({
|
|
20019
|
+
...message,
|
|
20020
|
+
metadata: {
|
|
20021
|
+
mode: "generate",
|
|
20022
|
+
requireApprovalMetadata: {
|
|
20023
|
+
[toolName]: {
|
|
20024
|
+
toolCallId,
|
|
20025
|
+
toolName,
|
|
20026
|
+
args
|
|
20027
|
+
}
|
|
20028
|
+
}
|
|
20029
|
+
}
|
|
20030
|
+
}));
|
|
20031
|
+
setMessages((prev) => [...prev, ...mastraUIMessages]);
|
|
20032
|
+
}
|
|
20033
|
+
setIsRunning(false);
|
|
20034
|
+
return;
|
|
20035
|
+
}
|
|
20011
20036
|
setIsRunning(false);
|
|
20012
20037
|
if (response && "uiMessages" in response.response && response.response.uiMessages) {
|
|
20013
20038
|
onFinish?.(response.response.uiMessages);
|
|
@@ -20163,6 +20188,48 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
20163
20188
|
});
|
|
20164
20189
|
setIsRunning(false);
|
|
20165
20190
|
};
|
|
20191
|
+
const approveToolCallGenerate = async (toolCallId) => {
|
|
20192
|
+
const currentRunId = _currentRunId.current;
|
|
20193
|
+
if (!currentRunId)
|
|
20194
|
+
return console.info(
|
|
20195
|
+
"[approveToolCallGenerate] approveToolCallGenerate can only be called after a generate has started"
|
|
20196
|
+
);
|
|
20197
|
+
setIsRunning(true);
|
|
20198
|
+
setToolCallApprovals((prev) => ({ ...prev, [toolCallId]: { status: "approved" } }));
|
|
20199
|
+
const agent = baseClient.getAgent(agentId);
|
|
20200
|
+
const response = await agent.approveToolCallGenerate({ runId: currentRunId, toolCallId });
|
|
20201
|
+
if (response && "uiMessages" in response.response && response.response.uiMessages) {
|
|
20202
|
+
const mastraUIMessages = (response.response.uiMessages || []).map((message) => ({
|
|
20203
|
+
...message,
|
|
20204
|
+
metadata: {
|
|
20205
|
+
mode: "generate"
|
|
20206
|
+
}
|
|
20207
|
+
}));
|
|
20208
|
+
setMessages((prev) => [...prev, ...mastraUIMessages]);
|
|
20209
|
+
}
|
|
20210
|
+
setIsRunning(false);
|
|
20211
|
+
};
|
|
20212
|
+
const declineToolCallGenerate = async (toolCallId) => {
|
|
20213
|
+
const currentRunId = _currentRunId.current;
|
|
20214
|
+
if (!currentRunId)
|
|
20215
|
+
return console.info(
|
|
20216
|
+
"[declineToolCallGenerate] declineToolCallGenerate can only be called after a generate has started"
|
|
20217
|
+
);
|
|
20218
|
+
setIsRunning(true);
|
|
20219
|
+
setToolCallApprovals((prev) => ({ ...prev, [toolCallId]: { status: "declined" } }));
|
|
20220
|
+
const agent = baseClient.getAgent(agentId);
|
|
20221
|
+
const response = await agent.declineToolCallGenerate({ runId: currentRunId, toolCallId });
|
|
20222
|
+
if (response && "uiMessages" in response.response && response.response.uiMessages) {
|
|
20223
|
+
const mastraUIMessages = (response.response.uiMessages || []).map((message) => ({
|
|
20224
|
+
...message,
|
|
20225
|
+
metadata: {
|
|
20226
|
+
mode: "generate"
|
|
20227
|
+
}
|
|
20228
|
+
}));
|
|
20229
|
+
setMessages((prev) => [...prev, ...mastraUIMessages]);
|
|
20230
|
+
}
|
|
20231
|
+
setIsRunning(false);
|
|
20232
|
+
};
|
|
20166
20233
|
const approveNetworkToolCall = async (toolName, runId) => {
|
|
20167
20234
|
const onNetworkChunk = _onNetworkChunk.current;
|
|
20168
20235
|
const networkRunId = runId || _networkRunId.current;
|
|
@@ -20232,6 +20299,8 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
20232
20299
|
messages,
|
|
20233
20300
|
approveToolCall,
|
|
20234
20301
|
declineToolCall,
|
|
20302
|
+
approveToolCallGenerate,
|
|
20303
|
+
declineToolCallGenerate,
|
|
20235
20304
|
cancelRun: handleCancelRun,
|
|
20236
20305
|
toolCallApprovals,
|
|
20237
20306
|
approveNetworkToolCall,
|
|
@@ -20556,4 +20625,4 @@ const MessageStreaming = ({ className, ...props }) => {
|
|
|
20556
20625
|
};
|
|
20557
20626
|
|
|
20558
20627
|
export { MessageUsages as $, EntryTitleClass as A, EntryTitle as B, CodeBlockClass as C, CodeBlock as D, Entity as E, CodeCopyButton as F, Icon as G, IconButtonClass as H, IconSizes as I, IconButton as J, AgentIcon as K, ToolsIcon as L, MastraReactProvider as M, Tooltip as N, TooltipContentClass as O, TooltipContent as P, TooltipTrigger as Q, MessageClass as R, Message as S, ToolApprovalClass as T, MessageContentClass as U, MessageContent as V, WorkflowIcon as W, MessageActionsClass as X, MessageActions as Y, MessageUsagesClass as Z, __commonJS$2 as _, __require2 as a, MessageUsageClass as a0, MessageUsage as a1, MessageUsageEntryClass as a2, MessageUsageEntry as a3, MessageUsageValueClass as a4, MessageUsageValue as a5, MessageListClass as a6, MessageList as a7, MessageStreamingClass as a8, MessageStreaming as a9, useChat as b, resolveToChildMessages as c, toAssistantUIMessage as d, useEntity as e, EntityTriggerClass as f, EntityTriggerVariantClasses as g, EntityTrigger as h, EntityContentClass as i, EntityContent as j, EntityCaret as k, ToolApproval as l, mapWorkflowStreamChunkToWatchResult as m, ToolApprovalTitleClass as n, ToolApprovalTitle as o, ToolApprovalHeaderClass as p, ToolApprovalHeader as q, require_token_error as r, ToolApprovalContentClass as s, toUIMessage as t, useMastraClient as u, ToolApprovalContent as v, ToolApprovalActionsClass as w, ToolApprovalActions as x, EntryClass as y, Entry as z };
|
|
20559
|
-
//# sourceMappingURL=index-
|
|
20628
|
+
//# sourceMappingURL=index-D3JtF_Zl.js.map
|