@mastra/playground-ui 6.6.2 → 6.7.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/CHANGELOG.md +15 -0
- package/dist/index.cjs.js +229 -70
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +229 -70
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/tools/badges/agent-badge-wrapper.d.ts +3 -2
- package/dist/src/components/assistant-ui/tools/badges/agent-badge.d.ts +3 -2
- package/dist/src/components/assistant-ui/tools/badges/tool-approval-buttons.d.ts +10 -0
- package/dist/src/components/assistant-ui/tools/badges/tool-badge.d.ts +3 -2
- package/dist/src/components/assistant-ui/tools/badges/workflow-badge.d.ts +4 -3
- package/dist/src/components/assistant-ui/tools/tool-approval.d.ts +8 -0
- package/dist/src/services/tool-call-provider.d.ts +25 -0
- package/dist/src/types.d.ts +1 -0
- package/package.json +14 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/playground-ui
|
|
2
2
|
|
|
3
|
+
## 6.7.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Update peer dependencies to match core package version bump (0.22.1) ([#8649](https://github.com/mastra-ai/mastra/pull/8649))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Add tool call approval ([#8649](https://github.com/mastra-ai/mastra/pull/8649))
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`2060766`](https://github.com/mastra-ai/mastra/commit/20607667bf78ea104cca3e15dfb93ae0b62c9d18), [`2c4438b`](https://github.com/mastra-ai/mastra/commit/2c4438b87817ab7eed818c7990fef010475af1a3)]:
|
|
14
|
+
- @mastra/core@0.23.0-alpha.0
|
|
15
|
+
- @mastra/client-js@0.16.5-alpha.0
|
|
16
|
+
- @mastra/react@0.0.11-alpha.0
|
|
17
|
+
|
|
3
18
|
## 6.6.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -4432,6 +4432,9 @@ const BadgeWrapper = ({
|
|
|
4432
4432
|
"data-testid": dataTestId
|
|
4433
4433
|
}) => {
|
|
4434
4434
|
const [isCollapsed, setIsCollapsed] = React.useState(initialCollapsed);
|
|
4435
|
+
React.useEffect(() => {
|
|
4436
|
+
setIsCollapsed(initialCollapsed);
|
|
4437
|
+
}, [initialCollapsed]);
|
|
4435
4438
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", "data-testid": dataTestId, children: [
|
|
4436
4439
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-2 items-center justify-between", children: [
|
|
4437
4440
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -4548,17 +4551,114 @@ const NetworkChoiceMetadataDialogTrigger = ({
|
|
|
4548
4551
|
] });
|
|
4549
4552
|
};
|
|
4550
4553
|
|
|
4551
|
-
const
|
|
4554
|
+
const sizeClasses = {
|
|
4555
|
+
md: "h-button-md gap-md",
|
|
4556
|
+
lg: "h-button-lg gap-lg"
|
|
4557
|
+
};
|
|
4558
|
+
const variantClasses$1 = {
|
|
4559
|
+
default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6 disabled:opacity-50",
|
|
4560
|
+
light: "bg-surface3 hover:bg-surface5 text-icon6 disabled:opacity-50"
|
|
4561
|
+
};
|
|
4562
|
+
const Button$1 = ({ className, as, size = "md", variant = "default", ...props }) => {
|
|
4563
|
+
const Component = as || "button";
|
|
4564
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4565
|
+
Component,
|
|
4566
|
+
{
|
|
4567
|
+
className: clsx(
|
|
4568
|
+
"bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
|
|
4569
|
+
variantClasses$1[variant],
|
|
4570
|
+
sizeClasses[size],
|
|
4571
|
+
className,
|
|
4572
|
+
{
|
|
4573
|
+
"cursor-not-allowed": props.disabled
|
|
4574
|
+
}
|
|
4575
|
+
),
|
|
4576
|
+
...props
|
|
4577
|
+
}
|
|
4578
|
+
);
|
|
4579
|
+
};
|
|
4580
|
+
|
|
4581
|
+
const ToolCallContext = React.createContext(void 0);
|
|
4582
|
+
function ToolCallProvider({
|
|
4583
|
+
children,
|
|
4584
|
+
approveToolcall,
|
|
4585
|
+
declineToolcall,
|
|
4586
|
+
isRunning,
|
|
4587
|
+
toolCallApprovals
|
|
4588
|
+
}) {
|
|
4589
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ToolCallContext.Provider, { value: { approveToolcall, declineToolcall, isRunning, toolCallApprovals }, children });
|
|
4590
|
+
}
|
|
4591
|
+
function useToolCall() {
|
|
4592
|
+
const context = React.useContext(ToolCallContext);
|
|
4593
|
+
if (!context) {
|
|
4594
|
+
throw new Error("useToolCall must be used within a ToolCallProvider");
|
|
4595
|
+
}
|
|
4596
|
+
return context;
|
|
4597
|
+
}
|
|
4598
|
+
|
|
4599
|
+
const ToolApprovalButtons = ({ toolCalled, toolCallId, toolApprovalMetadata }) => {
|
|
4600
|
+
const { approveToolcall, declineToolcall, isRunning, toolCallApprovals } = useToolCall();
|
|
4601
|
+
const handleApprove = () => {
|
|
4602
|
+
approveToolcall(toolCallId);
|
|
4603
|
+
};
|
|
4604
|
+
const handleDecline = () => {
|
|
4605
|
+
declineToolcall(toolCallId);
|
|
4606
|
+
};
|
|
4607
|
+
const toolCallApprovalStatus = toolCallApprovals?.[toolCallId]?.status;
|
|
4608
|
+
if (toolApprovalMetadata && !toolCalled) {
|
|
4609
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4610
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium pb-2", children: "Approval required" }),
|
|
4611
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
4612
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4613
|
+
Button$1,
|
|
4614
|
+
{
|
|
4615
|
+
onClick: handleApprove,
|
|
4616
|
+
disabled: isRunning || !!toolCallApprovalStatus,
|
|
4617
|
+
className: toolCallApprovalStatus === "approved" ? "!text-accent1" : "",
|
|
4618
|
+
children: [
|
|
4619
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, {}) }),
|
|
4620
|
+
"Approve"
|
|
4621
|
+
]
|
|
4622
|
+
}
|
|
4623
|
+
),
|
|
4624
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4625
|
+
Button$1,
|
|
4626
|
+
{
|
|
4627
|
+
onClick: handleDecline,
|
|
4628
|
+
disabled: isRunning || !!toolCallApprovalStatus,
|
|
4629
|
+
className: toolCallApprovalStatus === "declined" ? "!text-accent2" : "",
|
|
4630
|
+
children: [
|
|
4631
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}) }),
|
|
4632
|
+
"Decline"
|
|
4633
|
+
]
|
|
4634
|
+
}
|
|
4635
|
+
)
|
|
4636
|
+
] })
|
|
4637
|
+
] });
|
|
4638
|
+
}
|
|
4639
|
+
return null;
|
|
4640
|
+
};
|
|
4641
|
+
|
|
4642
|
+
const ToolBadge = ({
|
|
4643
|
+
toolName,
|
|
4644
|
+
args,
|
|
4645
|
+
result,
|
|
4646
|
+
metadata,
|
|
4647
|
+
toolOutput,
|
|
4648
|
+
toolCallId,
|
|
4649
|
+
toolApprovalMetadata
|
|
4650
|
+
}) => {
|
|
4552
4651
|
let argSlot = null;
|
|
4553
4652
|
try {
|
|
4554
4653
|
const { __mastraMetadata: _, ...formattedArgs } = typeof args === "object" ? args : JSON.parse(args);
|
|
4555
4654
|
argSlot = /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: formattedArgs, "data-testid": "tool-args" });
|
|
4556
4655
|
} catch {
|
|
4557
|
-
argSlot = /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-
|
|
4656
|
+
argSlot = /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre bg-surface4 p-4 rounded-md overflow-x-auto", children: args });
|
|
4558
4657
|
}
|
|
4559
|
-
let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre
|
|
4658
|
+
let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre bg-surface4 p-4 rounded-md overflow-x-auto", children: result }) : /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: result, "data-testid": "tool-result" });
|
|
4560
4659
|
const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
|
|
4561
4660
|
const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
|
|
4661
|
+
const toolCalled = result || toolOutput.length > 0;
|
|
4562
4662
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4563
4663
|
BadgeWrapper,
|
|
4564
4664
|
{
|
|
@@ -4572,19 +4672,28 @@ const ToolBadge = ({ toolName, args, result, metadata, toolOutput }) => {
|
|
|
4572
4672
|
input: agentNetworkInput
|
|
4573
4673
|
}
|
|
4574
4674
|
),
|
|
4675
|
+
initialCollapsed: !!!toolApprovalMetadata,
|
|
4575
4676
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
4576
4677
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4577
4678
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium pb-2", children: "Tool arguments" }),
|
|
4578
4679
|
argSlot
|
|
4579
4680
|
] }),
|
|
4580
|
-
resultSlot !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4681
|
+
resultSlot !== void 0 && result && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4581
4682
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium pb-2", children: "Tool result" }),
|
|
4582
4683
|
resultSlot
|
|
4583
4684
|
] }),
|
|
4584
4685
|
toolOutput.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4585
4686
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium pb-2", children: "Tool output" }),
|
|
4586
4687
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-40 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: toolOutput, "data-testid": "tool-output" }) })
|
|
4587
|
-
] })
|
|
4688
|
+
] }),
|
|
4689
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4690
|
+
ToolApprovalButtons,
|
|
4691
|
+
{
|
|
4692
|
+
toolCalled,
|
|
4693
|
+
toolCallId,
|
|
4694
|
+
toolApprovalMetadata
|
|
4695
|
+
}
|
|
4696
|
+
)
|
|
4588
4697
|
] })
|
|
4589
4698
|
}
|
|
4590
4699
|
);
|
|
@@ -5171,33 +5280,6 @@ const useCurrentRun = () => {
|
|
|
5171
5280
|
return { steps, runId: context.runId };
|
|
5172
5281
|
};
|
|
5173
5282
|
|
|
5174
|
-
const sizeClasses = {
|
|
5175
|
-
md: "h-button-md gap-md",
|
|
5176
|
-
lg: "h-button-lg gap-lg"
|
|
5177
|
-
};
|
|
5178
|
-
const variantClasses$1 = {
|
|
5179
|
-
default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6",
|
|
5180
|
-
light: "bg-surface3 hover:bg-surface5 text-icon6"
|
|
5181
|
-
};
|
|
5182
|
-
const Button$1 = ({ className, as, size = "md", variant = "default", ...props }) => {
|
|
5183
|
-
const Component = as || "button";
|
|
5184
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5185
|
-
Component,
|
|
5186
|
-
{
|
|
5187
|
-
className: clsx(
|
|
5188
|
-
"bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
|
|
5189
|
-
variantClasses$1[variant],
|
|
5190
|
-
sizeClasses[size],
|
|
5191
|
-
className,
|
|
5192
|
-
{
|
|
5193
|
-
"cursor-not-allowed": props.disabled
|
|
5194
|
-
}
|
|
5195
|
-
),
|
|
5196
|
-
...props
|
|
5197
|
-
}
|
|
5198
|
-
);
|
|
5199
|
-
};
|
|
5200
|
-
|
|
5201
5283
|
const useCodemirrorTheme$1 = () => {
|
|
5202
5284
|
return React.useMemo(
|
|
5203
5285
|
() => codemirrorThemeDracula.draculaInit({
|
|
@@ -8164,7 +8246,15 @@ const useWorkflow = (workflowId) => {
|
|
|
8164
8246
|
});
|
|
8165
8247
|
};
|
|
8166
8248
|
|
|
8167
|
-
const WorkflowBadge = ({
|
|
8249
|
+
const WorkflowBadge = ({
|
|
8250
|
+
result,
|
|
8251
|
+
workflowId,
|
|
8252
|
+
isStreaming,
|
|
8253
|
+
metadata,
|
|
8254
|
+
toolCallId,
|
|
8255
|
+
toolApprovalMetadata
|
|
8256
|
+
}) => {
|
|
8257
|
+
const { runId, status } = result || {};
|
|
8168
8258
|
const { data: workflow, isLoading: isWorkflowLoading } = useWorkflow(workflowId);
|
|
8169
8259
|
const { data: runs, isLoading: isRunsLoading } = useWorkflowRuns(workflowId, {
|
|
8170
8260
|
enabled: Boolean(runId) && !isStreaming
|
|
@@ -8191,7 +8281,8 @@ const WorkflowBadge = ({ runId, workflowId, isStreaming, metadata }) => {
|
|
|
8191
8281
|
),
|
|
8192
8282
|
children: [
|
|
8193
8283
|
!isStreaming && !isLoading && /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunProvider, { snapshot, children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowBadgeExtended, { workflowId, workflow, runId }) }),
|
|
8194
|
-
isStreaming && /* @__PURE__ */ jsxRuntime.jsx(WorkflowBadgeExtended, { workflowId, workflow, runId })
|
|
8284
|
+
isStreaming && /* @__PURE__ */ jsxRuntime.jsx(WorkflowBadgeExtended, { workflowId, workflow, runId }),
|
|
8285
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolApprovalButtons, { toolCalled: !!status, toolCallId, toolApprovalMetadata })
|
|
8195
8286
|
]
|
|
8196
8287
|
}
|
|
8197
8288
|
);
|
|
@@ -8214,10 +8305,10 @@ const useWorkflowStream = (workflowFullState) => {
|
|
|
8214
8305
|
}, [workflowFullState]);
|
|
8215
8306
|
};
|
|
8216
8307
|
|
|
8217
|
-
const AgentBadge = ({ agentId, messages = [], metadata }) => {
|
|
8308
|
+
const AgentBadge = ({ agentId, messages = [], metadata, toolCallId, toolApprovalMetadata }) => {
|
|
8218
8309
|
const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
|
|
8219
8310
|
const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
|
|
8220
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
8311
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8221
8312
|
BadgeWrapper,
|
|
8222
8313
|
{
|
|
8223
8314
|
"data-testid": "agent-badge",
|
|
@@ -8231,29 +8322,39 @@ const AgentBadge = ({ agentId, messages = [], metadata }) => {
|
|
|
8231
8322
|
input: agentNetworkInput
|
|
8232
8323
|
}
|
|
8233
8324
|
),
|
|
8234
|
-
children:
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8325
|
+
children: [
|
|
8326
|
+
messages.map((message, index) => {
|
|
8327
|
+
if (message.type === "text") {
|
|
8328
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: message.content }, index);
|
|
8329
|
+
}
|
|
8330
|
+
const result = typeof message.toolOutput === "string" ? JSON.parse(message.toolOutput) : message.toolOutput;
|
|
8331
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8332
|
+
ToolFallback,
|
|
8333
|
+
{
|
|
8334
|
+
toolName: message.toolName,
|
|
8335
|
+
argsText: typeof message.args === "string" ? message.args : JSON.stringify(message.args),
|
|
8336
|
+
result,
|
|
8337
|
+
args: message.args,
|
|
8338
|
+
status: { type: "complete" },
|
|
8339
|
+
type: "tool-call",
|
|
8340
|
+
toolCallId: message.toolCallId,
|
|
8341
|
+
addResult: () => {
|
|
8342
|
+
},
|
|
8343
|
+
metadata: {
|
|
8344
|
+
mode: "stream"
|
|
8345
|
+
}
|
|
8253
8346
|
}
|
|
8347
|
+
) }, index);
|
|
8348
|
+
}),
|
|
8349
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8350
|
+
ToolApprovalButtons,
|
|
8351
|
+
{
|
|
8352
|
+
toolCalled: messages?.length > 0,
|
|
8353
|
+
toolCallId,
|
|
8354
|
+
toolApprovalMetadata
|
|
8254
8355
|
}
|
|
8255
|
-
)
|
|
8256
|
-
|
|
8356
|
+
)
|
|
8357
|
+
]
|
|
8257
8358
|
}
|
|
8258
8359
|
);
|
|
8259
8360
|
};
|
|
@@ -8275,27 +8376,53 @@ const useAgentMessages = ({
|
|
|
8275
8376
|
});
|
|
8276
8377
|
};
|
|
8277
8378
|
|
|
8278
|
-
const AgentBadgeWrapper = ({
|
|
8379
|
+
const AgentBadgeWrapper = ({
|
|
8380
|
+
agentId,
|
|
8381
|
+
result,
|
|
8382
|
+
metadata,
|
|
8383
|
+
toolCallId,
|
|
8384
|
+
toolApprovalMetadata
|
|
8385
|
+
}) => {
|
|
8279
8386
|
const { data: memoryMessages } = useAgentMessages({
|
|
8280
8387
|
threadId: result?.subAgentThreadId ?? "",
|
|
8281
8388
|
agentId,
|
|
8282
8389
|
memory: true
|
|
8283
8390
|
});
|
|
8284
8391
|
const childMessages = result?.childMessages ?? react$3.resolveToChildMessages(memoryMessages?.uiMessages ?? []);
|
|
8285
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8392
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8393
|
+
AgentBadge,
|
|
8394
|
+
{
|
|
8395
|
+
agentId,
|
|
8396
|
+
messages: childMessages,
|
|
8397
|
+
metadata,
|
|
8398
|
+
toolCallId,
|
|
8399
|
+
toolApprovalMetadata
|
|
8400
|
+
}
|
|
8401
|
+
);
|
|
8286
8402
|
};
|
|
8287
8403
|
|
|
8288
8404
|
const ToolFallback = ({ toolName, result, args, ...props }) => {
|
|
8289
8405
|
return /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackInner, { toolName, result, args, ...props }) });
|
|
8290
8406
|
};
|
|
8291
|
-
const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
|
|
8407
|
+
const ToolFallbackInner = ({ toolName, result, args, metadata, toolCallId, ...props }) => {
|
|
8292
8408
|
const isAgent = metadata?.mode === "network" && metadata.from === "AGENT" || toolName.startsWith("agent-");
|
|
8293
8409
|
const isWorkflow = metadata?.mode === "network" && metadata.from === "WORKFLOW" || toolName.startsWith("workflow-");
|
|
8294
8410
|
const agentToolName = toolName.startsWith("agent-") ? toolName.substring("agent-".length) : toolName;
|
|
8295
8411
|
const workflowToolName = toolName.startsWith("workflow-") ? toolName.substring("workflow-".length) : toolName;
|
|
8412
|
+
const requireApprovalMetadata = metadata?.mode === "stream" && metadata?.requireApprovalMetadata;
|
|
8413
|
+
const toolApprovalMetadata = requireApprovalMetadata ? requireApprovalMetadata?.[toolCallId] : void 0;
|
|
8296
8414
|
useWorkflowStream(result);
|
|
8297
8415
|
if (isAgent) {
|
|
8298
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8416
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8417
|
+
AgentBadgeWrapper,
|
|
8418
|
+
{
|
|
8419
|
+
agentId: agentToolName,
|
|
8420
|
+
result,
|
|
8421
|
+
metadata,
|
|
8422
|
+
toolCallId,
|
|
8423
|
+
toolApprovalMetadata
|
|
8424
|
+
}
|
|
8425
|
+
);
|
|
8299
8426
|
}
|
|
8300
8427
|
if (isWorkflow) {
|
|
8301
8428
|
const isStreaming = metadata?.mode === "stream" || metadata?.mode === "network";
|
|
@@ -8304,8 +8431,10 @@ const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
|
|
|
8304
8431
|
{
|
|
8305
8432
|
workflowId: workflowToolName,
|
|
8306
8433
|
isStreaming,
|
|
8307
|
-
|
|
8308
|
-
metadata
|
|
8434
|
+
result,
|
|
8435
|
+
metadata,
|
|
8436
|
+
toolCallId,
|
|
8437
|
+
toolApprovalMetadata
|
|
8309
8438
|
}
|
|
8310
8439
|
);
|
|
8311
8440
|
}
|
|
@@ -8316,7 +8445,9 @@ const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
|
|
|
8316
8445
|
args,
|
|
8317
8446
|
result,
|
|
8318
8447
|
toolOutput: result?.toolOutput || [],
|
|
8319
|
-
metadata
|
|
8448
|
+
metadata,
|
|
8449
|
+
toolCallId,
|
|
8450
|
+
toolApprovalMetadata
|
|
8320
8451
|
}
|
|
8321
8452
|
);
|
|
8322
8453
|
};
|
|
@@ -9984,7 +10115,10 @@ function MastraRuntimeProvider({
|
|
|
9984
10115
|
sendMessage,
|
|
9985
10116
|
cancelRun,
|
|
9986
10117
|
isRunning: isRunningStream,
|
|
9987
|
-
setMessages
|
|
10118
|
+
setMessages,
|
|
10119
|
+
approveToolCall,
|
|
10120
|
+
declineToolCall,
|
|
10121
|
+
toolCallApprovals
|
|
9988
10122
|
} = react$3.useChat({
|
|
9989
10123
|
agentId,
|
|
9990
10124
|
initializeMessages: () => initialMessages || []
|
|
@@ -10004,7 +10138,8 @@ function MastraRuntimeProvider({
|
|
|
10004
10138
|
chatWithGenerateLegacy,
|
|
10005
10139
|
chatWithGenerate,
|
|
10006
10140
|
chatWithNetwork,
|
|
10007
|
-
providerOptions
|
|
10141
|
+
providerOptions,
|
|
10142
|
+
requireToolApproval
|
|
10008
10143
|
} = settings?.modelSettings ?? {};
|
|
10009
10144
|
const toolCallIdToName = React.useRef({});
|
|
10010
10145
|
const runtimeContextInstance = new di.RuntimeContext();
|
|
@@ -10021,7 +10156,8 @@ function MastraRuntimeProvider({
|
|
|
10021
10156
|
maxTokens,
|
|
10022
10157
|
instructions,
|
|
10023
10158
|
providerOptions,
|
|
10024
|
-
maxSteps
|
|
10159
|
+
maxSteps,
|
|
10160
|
+
requireToolApproval
|
|
10025
10161
|
};
|
|
10026
10162
|
const baseClient = react$3.useMastraClient();
|
|
10027
10163
|
const isVNext = modelVersion === "v2";
|
|
@@ -10409,10 +10545,23 @@ function MastraRuntimeProvider({
|
|
|
10409
10545
|
convertMessage: (x) => x,
|
|
10410
10546
|
onNew,
|
|
10411
10547
|
onCancel,
|
|
10412
|
-
adapters: isReady ? adapters : void 0
|
|
10548
|
+
adapters: isReady ? adapters : void 0,
|
|
10549
|
+
extras: {
|
|
10550
|
+
approveToolCall,
|
|
10551
|
+
declineToolCall
|
|
10552
|
+
}
|
|
10413
10553
|
});
|
|
10414
10554
|
if (!isReady) return null;
|
|
10415
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.AssistantRuntimeProvider, { runtime, children
|
|
10555
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.AssistantRuntimeProvider, { runtime, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10556
|
+
ToolCallProvider,
|
|
10557
|
+
{
|
|
10558
|
+
approveToolcall: approveToolCall,
|
|
10559
|
+
declineToolcall: declineToolCall,
|
|
10560
|
+
isRunning: isRunningStream,
|
|
10561
|
+
toolCallApprovals,
|
|
10562
|
+
children
|
|
10563
|
+
}
|
|
10564
|
+
) });
|
|
10416
10565
|
}
|
|
10417
10566
|
|
|
10418
10567
|
const defaultSettings = {
|
|
@@ -11233,6 +11382,16 @@ const AgentSettings = ({ modelVersion, hasMemory = false, hasSubAgents = false }
|
|
|
11233
11382
|
]
|
|
11234
11383
|
}
|
|
11235
11384
|
) }),
|
|
11385
|
+
/* @__PURE__ */ jsxRuntime.jsx(Entry, { label: "Require Tool Approval", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11386
|
+
Checkbox,
|
|
11387
|
+
{
|
|
11388
|
+
checked: settings?.modelSettings?.requireToolApproval,
|
|
11389
|
+
onCheckedChange: (value) => setSettings({
|
|
11390
|
+
...settings,
|
|
11391
|
+
modelSettings: { ...settings?.modelSettings, requireToolApproval: value }
|
|
11392
|
+
})
|
|
11393
|
+
}
|
|
11394
|
+
) }),
|
|
11236
11395
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-8", children: [
|
|
11237
11396
|
/* @__PURE__ */ jsxRuntime.jsx(Entry, { label: "Temperature", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row justify-between items-center gap-2", children: [
|
|
11238
11397
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -16593,7 +16752,7 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
|
|
|
16593
16752
|
console.warn("Only one of traceUsage or spanUsage should be provided");
|
|
16594
16753
|
return null;
|
|
16595
16754
|
}
|
|
16596
|
-
const generationSpans = traceSpans.filter((span) => span.spanType === "
|
|
16755
|
+
const generationSpans = traceSpans.filter((span) => span.spanType === "model_generation");
|
|
16597
16756
|
const hasV5Format = generationSpans.some(
|
|
16598
16757
|
(span) => span.attributes?.usage?.inputTokens !== void 0 || span.attributes?.usage?.outputTokens !== void 0
|
|
16599
16758
|
);
|