@mastra/react 0.1.0-beta.23 → 0.1.0-beta.27
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 +85 -1
- package/dist/{chunk-55VPMN3N-C6D-FCqV.js → chunk-55VPMN3N-Ax1F4Y75.js} +2 -2
- package/dist/{chunk-55VPMN3N-C6D-FCqV.js.map → chunk-55VPMN3N-Ax1F4Y75.js.map} +1 -1
- package/dist/{chunk-55VPMN3N-CXxvOk-2.cjs → chunk-55VPMN3N-BHqoDkCq.cjs} +2 -2
- package/dist/{chunk-55VPMN3N-CXxvOk-2.cjs.map → chunk-55VPMN3N-BHqoDkCq.cjs.map} +1 -1
- package/dist/{index-DiwNdkF4.cjs → index-ChvWx-iU.cjs} +78 -12
- package/dist/index-ChvWx-iU.cjs.map +1 -0
- package/dist/{index-DFYpOuhE.js → index-D3JtF_Zl.js} +78 -12
- package/dist/index-D3JtF_Zl.js.map +1 -0
- 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-CKILUODb.cjs → token-6GSAFR2W-SPYPLMBM-CWoxKwfk.cjs} +3 -3
- package/dist/{token-6GSAFR2W-SPYPLMBM-CKILUODb.cjs.map → token-6GSAFR2W-SPYPLMBM-CWoxKwfk.cjs.map} +1 -1
- package/dist/{token-6GSAFR2W-SPYPLMBM-BeIpRVyM.js → token-6GSAFR2W-SPYPLMBM-ChURikIE.js} +3 -3
- package/dist/{token-6GSAFR2W-SPYPLMBM-BeIpRVyM.js.map → token-6GSAFR2W-SPYPLMBM-ChURikIE.js.map} +1 -1
- package/dist/{token-util-NEHG7TUY-JRJTGTAB-DgJBvxO4.cjs → token-util-NEHG7TUY-JRJTGTAB-BU9ZxL1w.cjs} +2 -2
- package/dist/{token-util-NEHG7TUY-JRJTGTAB-DgJBvxO4.cjs.map → token-util-NEHG7TUY-JRJTGTAB-BU9ZxL1w.cjs.map} +1 -1
- package/dist/{token-util-NEHG7TUY-JRJTGTAB-N8sYk0L_.js → token-util-NEHG7TUY-JRJTGTAB-hEay2AHp.js} +2 -2
- package/dist/{token-util-NEHG7TUY-JRJTGTAB-N8sYk0L_.js.map → token-util-NEHG7TUY-JRJTGTAB-hEay2AHp.js.map} +1 -1
- package/package.json +3 -3
- package/dist/index-DFYpOuhE.js.map +0 -1
- package/dist/index-DiwNdkF4.cjs.map +0 -1
|
@@ -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,9 +19991,10 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
19990
19991
|
abortSignal: signal
|
|
19991
19992
|
});
|
|
19992
19993
|
const agent = clientWithAbort.getAgent(agentId);
|
|
19993
|
-
const
|
|
19994
|
-
|
|
19995
|
-
|
|
19994
|
+
const runId = v4();
|
|
19995
|
+
_currentRunId.current = runId;
|
|
19996
|
+
const response = await agent.generate(coreUserMessages, {
|
|
19997
|
+
runId,
|
|
19996
19998
|
maxSteps,
|
|
19997
19999
|
modelSettings: {
|
|
19998
20000
|
frequencyPenalty,
|
|
@@ -20007,8 +20009,30 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
20007
20009
|
requestContext,
|
|
20008
20010
|
...threadId ? { memory: { thread: threadId, resource: resourceId || agentId } } : {},
|
|
20009
20011
|
providerOptions,
|
|
20010
|
-
tracingOptions
|
|
20012
|
+
tracingOptions,
|
|
20013
|
+
requireToolApproval
|
|
20011
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
|
+
}
|
|
20012
20036
|
setIsRunning(false);
|
|
20013
20037
|
if (response && "uiMessages" in response.response && response.response.uiMessages) {
|
|
20014
20038
|
onFinish?.(response.response.uiMessages);
|
|
@@ -20050,8 +20074,7 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
20050
20074
|
});
|
|
20051
20075
|
const agent = clientWithAbort.getAgent(agentId);
|
|
20052
20076
|
const runId = v4();
|
|
20053
|
-
const response = await agent.stream({
|
|
20054
|
-
messages: coreUserMessages,
|
|
20077
|
+
const response = await agent.stream(coreUserMessages, {
|
|
20055
20078
|
runId,
|
|
20056
20079
|
maxSteps,
|
|
20057
20080
|
modelSettings: {
|
|
@@ -20097,8 +20120,7 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
20097
20120
|
});
|
|
20098
20121
|
const agent = clientWithAbort.getAgent(agentId);
|
|
20099
20122
|
const runId = v4();
|
|
20100
|
-
const response = await agent.network({
|
|
20101
|
-
messages: coreUserMessages,
|
|
20123
|
+
const response = await agent.network(coreUserMessages, {
|
|
20102
20124
|
maxSteps,
|
|
20103
20125
|
modelSettings: {
|
|
20104
20126
|
frequencyPenalty,
|
|
@@ -20166,6 +20188,48 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
20166
20188
|
});
|
|
20167
20189
|
setIsRunning(false);
|
|
20168
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
|
+
};
|
|
20169
20233
|
const approveNetworkToolCall = async (toolName, runId) => {
|
|
20170
20234
|
const onNetworkChunk = _onNetworkChunk.current;
|
|
20171
20235
|
const networkRunId = runId || _networkRunId.current;
|
|
@@ -20235,6 +20299,8 @@ const useChat = ({ agentId, resourceId, initializeMessages }) => {
|
|
|
20235
20299
|
messages,
|
|
20236
20300
|
approveToolCall,
|
|
20237
20301
|
declineToolCall,
|
|
20302
|
+
approveToolCallGenerate,
|
|
20303
|
+
declineToolCallGenerate,
|
|
20238
20304
|
cancelRun: handleCancelRun,
|
|
20239
20305
|
toolCallApprovals,
|
|
20240
20306
|
approveNetworkToolCall,
|
|
@@ -20559,4 +20625,4 @@ const MessageStreaming = ({ className, ...props }) => {
|
|
|
20559
20625
|
};
|
|
20560
20626
|
|
|
20561
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 };
|
|
20562
|
-
//# sourceMappingURL=index-
|
|
20628
|
+
//# sourceMappingURL=index-D3JtF_Zl.js.map
|