@mastra/react 1.13.0-alpha.2 → 1.13.0-alpha.4
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/{accumulator-BmD8-x9I.cjs → accumulator-Bjfckb5t.cjs} +5 -9
- package/dist/{accumulator-BmD8-x9I.cjs.map → accumulator-Bjfckb5t.cjs.map} +1 -1
- package/dist/{accumulator-D9jAph99.js → accumulator-DysrPe6U.js} +5 -9
- package/dist/{accumulator-D9jAph99.js.map → accumulator-DysrPe6U.js.map} +1 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/{combine-by-ids-CcaZKGT9.js → combine-by-ids-C-0oe4eH.js} +2 -3
- package/dist/{combine-by-ids-CcaZKGT9.js.map → combine-by-ids-C-0oe4eH.js.map} +1 -1
- package/dist/{combine-by-ids-D_lp6Dvq.cjs → combine-by-ids-ERVPXXBi.cjs} +2 -3
- package/dist/{combine-by-ids-D_lp6Dvq.cjs.map → combine-by-ids-ERVPXXBi.cjs.map} +1 -1
- package/dist/{experiments-CJw1N3FB.cjs → experiments-Duv0RgkM.cjs} +12 -19
- package/dist/{experiments-CJw1N3FB.cjs.map → experiments-Duv0RgkM.cjs.map} +1 -1
- package/dist/{experiments-B7vRMK5T.js → experiments-DyecjEut.js} +12 -19
- package/dist/{experiments-B7vRMK5T.js.map → experiments-DyecjEut.js.map} +1 -1
- package/dist/{feedback-refetch-interval-XD5FVc2k.cjs → feedback-refetch-interval-BBcT9r8s.cjs} +3 -4
- package/dist/{feedback-refetch-interval-XD5FVc2k.cjs.map → feedback-refetch-interval-BBcT9r8s.cjs.map} +1 -1
- package/dist/{feedback-refetch-interval-DLHzQoVV.js → feedback-refetch-interval-C12Nzb2r.js} +3 -4
- package/dist/{feedback-refetch-interval-DLHzQoVV.js.map → feedback-refetch-interval-C12Nzb2r.js.map} +1 -1
- package/dist/hooks/agents/index.cjs +19 -37
- package/dist/hooks/agents/index.cjs.map +1 -1
- package/dist/hooks/agents/index.js +19 -37
- package/dist/hooks/agents/index.js.map +1 -1
- package/dist/hooks/auth/index.cjs +11 -21
- package/dist/hooks/auth/index.cjs.map +1 -1
- package/dist/hooks/auth/index.js +11 -21
- package/dist/hooks/auth/index.js.map +1 -1
- package/dist/hooks/capabilities/index.cjs +11 -21
- package/dist/hooks/capabilities/index.cjs.map +1 -1
- package/dist/hooks/capabilities/index.js +11 -21
- package/dist/hooks/capabilities/index.js.map +1 -1
- package/dist/hooks/configuration/index.cjs +2 -3
- package/dist/hooks/configuration/index.js +2 -3
- package/dist/hooks/datasets/index.cjs +12 -21
- package/dist/hooks/datasets/index.cjs.map +1 -1
- package/dist/hooks/datasets/index.js +12 -21
- package/dist/hooks/datasets/index.js.map +1 -1
- package/dist/hooks/embedders/index.cjs +2 -3
- package/dist/hooks/embedders/index.js +2 -3
- package/dist/hooks/experiments/index.cjs +1 -1
- package/dist/hooks/experiments/index.js +1 -1
- package/dist/hooks/feedback/index.cjs +3 -4
- package/dist/hooks/feedback/index.js +3 -4
- package/dist/hooks/llm/index.cjs +2 -3
- package/dist/hooks/llm/index.js +2 -3
- package/dist/hooks/logs/index.cjs +4 -5
- package/dist/hooks/logs/index.js +4 -5
- package/dist/hooks/mcps/index.cjs +8 -15
- package/dist/hooks/mcps/index.cjs.map +1 -1
- package/dist/hooks/mcps/index.js +8 -15
- package/dist/hooks/mcps/index.js.map +1 -1
- package/dist/hooks/memory/index.cjs +5 -9
- package/dist/hooks/memory/index.cjs.map +1 -1
- package/dist/hooks/memory/index.js +5 -9
- package/dist/hooks/memory/index.js.map +1 -1
- package/dist/hooks/metrics/index.cjs +19 -36
- package/dist/hooks/metrics/index.cjs.map +1 -1
- package/dist/hooks/metrics/index.js +19 -36
- package/dist/hooks/metrics/index.js.map +1 -1
- package/dist/hooks/processors/index.cjs +2 -3
- package/dist/hooks/processors/index.js +2 -3
- package/dist/hooks/prompt-blocks/index.cjs +3 -5
- package/dist/hooks/prompt-blocks/index.cjs.map +1 -1
- package/dist/hooks/prompt-blocks/index.js +3 -5
- package/dist/hooks/prompt-blocks/index.js.map +1 -1
- package/dist/hooks/query/index.cjs +2 -3
- package/dist/hooks/query/index.js +2 -3
- package/dist/hooks/review/index.cjs +4 -6
- package/dist/hooks/review/index.cjs.map +1 -1
- package/dist/hooks/review/index.js +4 -6
- package/dist/hooks/review/index.js.map +1 -1
- package/dist/hooks/schedules/index.cjs +6 -10
- package/dist/hooks/schedules/index.cjs.map +1 -1
- package/dist/hooks/schedules/index.js +6 -10
- package/dist/hooks/schedules/index.js.map +1 -1
- package/dist/hooks/scores/index.cjs +8 -13
- package/dist/hooks/scores/index.cjs.map +1 -1
- package/dist/hooks/scores/index.js +8 -13
- package/dist/hooks/scores/index.js.map +1 -1
- package/dist/hooks/templates/index.cjs +2 -3
- package/dist/hooks/templates/index.js +2 -3
- package/dist/hooks/tool-providers/index.cjs +10 -19
- package/dist/hooks/tool-providers/index.cjs.map +1 -1
- package/dist/hooks/tool-providers/index.js +10 -19
- package/dist/hooks/tool-providers/index.js.map +1 -1
- package/dist/hooks/tools/index.cjs +3 -5
- package/dist/hooks/tools/index.cjs.map +1 -1
- package/dist/hooks/tools/index.js +3 -5
- package/dist/hooks/tools/index.js.map +1 -1
- package/dist/hooks/traces/index.cjs +28 -51
- package/dist/hooks/traces/index.cjs.map +1 -1
- package/dist/hooks/traces/index.js +28 -51
- package/dist/hooks/traces/index.js.map +1 -1
- package/dist/hooks/vectors/index.cjs +2 -3
- package/dist/hooks/vectors/index.js +2 -3
- package/dist/hooks/voice/index.cjs +3 -4
- package/dist/hooks/voice/index.js +3 -4
- package/dist/hooks/workflows/index.cjs +7 -11
- package/dist/hooks/workflows/index.cjs.map +1 -1
- package/dist/hooks/workflows/index.js +7 -11
- package/dist/hooks/workflows/index.js.map +1 -1
- package/dist/hooks/workspace/index.cjs +12 -22
- package/dist/hooks/workspace/index.cjs.map +1 -1
- package/dist/hooks/workspace/index.js +12 -22
- package/dist/hooks/workspace/index.js.map +1 -1
- package/dist/{hooks-XYsmqFCz.cjs → hooks-Bt15IwzP.cjs} +6 -9
- package/dist/{hooks-XYsmqFCz.cjs.map → hooks-Bt15IwzP.cjs.map} +1 -1
- package/dist/{hooks-DG-Y1KFe.js → hooks-Btt7PyI-.js} +6 -9
- package/dist/{hooks-DG-Y1KFe.js.map → hooks-Btt7PyI-.js.map} +1 -1
- package/dist/{hooks-BfysjY_K.js → hooks-CEikbhrN.js} +9 -15
- package/dist/{hooks-BfysjY_K.js.map → hooks-CEikbhrN.js.map} +1 -1
- package/dist/{hooks-BbUMSab8.cjs → hooks-D6LDSEcm.cjs} +9 -15
- package/dist/{hooks-BbUMSab8.cjs.map → hooks-D6LDSEcm.cjs.map} +1 -1
- package/dist/index.cjs +7 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -9
- package/dist/index.js.map +1 -1
- package/dist/{map-CDv4fbu4.js → map-5-4U5rwA.js} +2 -3
- package/dist/{map-CDv4fbu4.js.map → map-5-4U5rwA.js.map} +1 -1
- package/dist/{map-wjmL1y5O.cjs → map-BGoWBTGy.cjs} +2 -3
- package/dist/{map-wjmL1y5O.cjs.map → map-BGoWBTGy.cjs.map} +1 -1
- package/dist/{mastra-client-context-Bx_g84YB.js → mastra-client-context-DQ5z_ze9.js} +2 -3
- package/dist/{mastra-client-context-Bx_g84YB.js.map → mastra-client-context-DQ5z_ze9.js.map} +1 -1
- package/dist/{mastra-client-context-DzX3f0RF.cjs → mastra-client-context-DX8wJM9p.cjs} +2 -3
- package/dist/{mastra-client-context-DzX3f0RF.cjs.map → mastra-client-context-DX8wJM9p.cjs.map} +1 -1
- package/dist/{query-utils-CcrChYgz.cjs → query-utils-BVgE_xxj.cjs} +2 -3
- package/dist/{query-utils-CcrChYgz.cjs.map → query-utils-BVgE_xxj.cjs.map} +1 -1
- package/dist/{query-utils-D1NgFnWU.js → query-utils-DvMERIwf.js} +2 -3
- package/dist/{query-utils-D1NgFnWU.js.map → query-utils-DvMERIwf.js.map} +1 -1
- package/dist/ui/index.cjs +15 -30
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +14 -28
- package/dist/ui/index.js.map +1 -1
- package/dist/{use-in-view-B6eJO9Zi.cjs → use-in-view-BxdrrnCw.cjs} +2 -3
- package/dist/{use-in-view-B6eJO9Zi.cjs.map → use-in-view-BxdrrnCw.cjs.map} +1 -1
- package/dist/{use-in-view-C9sYPGRm.js → use-in-view-CyjKdplM.js} +2 -3
- package/dist/{use-in-view-C9sYPGRm.js.map → use-in-view-CyjKdplM.js.map} +1 -1
- package/dist/{voice-BOtUdMi8.cjs → voice-Didej2E1.cjs} +5 -8
- package/dist/{voice-BOtUdMi8.cjs.map → voice-Didej2E1.cjs.map} +1 -1
- package/dist/{voice-DgirjEyH.js → voice-ugGu7VyA.js} +5 -8
- package/dist/{voice-DgirjEyH.js.map → voice-ugGu7VyA.js.map} +1 -1
- package/package.json +17 -17
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mastra_client_context = require("../../mastra-client-context-
|
|
2
|
+
const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
5
5
|
let _mastra_core_di = require("@mastra/core/di");
|
|
6
|
-
|
|
6
|
+
// src/hooks/agents/use-agent-messages.ts
|
|
7
7
|
const PER_PAGE = 40;
|
|
8
8
|
const NEWEST_PAGE = "";
|
|
9
9
|
const createdAtMs = (message) => new Date(message.createdAt).getTime();
|
|
@@ -54,8 +54,7 @@ const useAgentMessages = ({ threadId, agentId, memory, requestContext, queryOpti
|
|
|
54
54
|
...queryOptions
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
|
-
|
|
58
|
-
//#region src/hooks/agents/use-agent-plan.ts
|
|
57
|
+
// src/hooks/agents/use-agent-plan.ts
|
|
59
58
|
function useAgentPlan({ agentId, path, agentVersionId, requestContext, queryOptions }) {
|
|
60
59
|
const client = require_mastra_client_context.useMastraClient();
|
|
61
60
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -73,8 +72,7 @@ function useAgentPlan({ agentId, path, agentVersionId, requestContext, queryOpti
|
|
|
73
72
|
...queryOptions
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
//#region src/hooks/agents/use-background-tasks.ts
|
|
75
|
+
// src/hooks/agents/use-background-tasks.ts
|
|
78
76
|
const EVENT_STATUS_MAP = {
|
|
79
77
|
"background-task-running": "running",
|
|
80
78
|
"background-task-output": "running",
|
|
@@ -207,8 +205,7 @@ const useGetBackgroundTaskById = ({ backgroundTaskId, queryOptions }) => {
|
|
|
207
205
|
...queryOptions
|
|
208
206
|
});
|
|
209
207
|
};
|
|
210
|
-
|
|
211
|
-
//#region src/hooks/agents/use-browser-session-probe.ts
|
|
208
|
+
// src/hooks/agents/use-browser-session-probe.ts
|
|
212
209
|
const browserSessionProbeQueryKey = (agentId, threadId) => [
|
|
213
210
|
"browser-session-probe",
|
|
214
211
|
agentId,
|
|
@@ -264,8 +261,7 @@ function useBrowserSessionProbe({ agentId, threadId, queryOptions }) {
|
|
|
264
261
|
...queryOptions
|
|
265
262
|
});
|
|
266
263
|
}
|
|
267
|
-
|
|
268
|
-
//#region src/hooks/agents/is-model-not-allowed.ts
|
|
264
|
+
// src/hooks/agents/is-model-not-allowed.ts
|
|
269
265
|
/**
|
|
270
266
|
* The wire-level error code the server emits on a 422 when a model is blocked
|
|
271
267
|
* by the admin's builder policy. Kept as a local literal so the browser bundle
|
|
@@ -290,8 +286,7 @@ function isModelNotAllowedError(err) {
|
|
|
290
286
|
offendingLabel: errorBody.offendingLabel
|
|
291
287
|
};
|
|
292
288
|
}
|
|
293
|
-
|
|
294
|
-
//#region src/hooks/agents/use-stored-agents.ts
|
|
289
|
+
// src/hooks/agents/use-stored-agents.ts
|
|
295
290
|
const useStoredAgents = ({ queryOptions, ...params } = {}) => {
|
|
296
291
|
const client = require_mastra_client_context.useMastraClient();
|
|
297
292
|
const listParams = Object.keys(params).length > 0 ? params : void 0;
|
|
@@ -404,8 +399,7 @@ const useStoredAgentMutations = ({ agentId, requestContext, queryOptions } = {})
|
|
|
404
399
|
})
|
|
405
400
|
};
|
|
406
401
|
};
|
|
407
|
-
|
|
408
|
-
//#region src/hooks/agents/use-agent-skills.ts
|
|
402
|
+
// src/hooks/agents/use-agent-skills.ts
|
|
409
403
|
/**
|
|
410
404
|
* Hook to read and mutate the skills config for a stored agent.
|
|
411
405
|
*
|
|
@@ -448,8 +442,7 @@ function useAgentSkills({ agentId, requestContext, queryOptions } = {}) {
|
|
|
448
442
|
})
|
|
449
443
|
};
|
|
450
444
|
}
|
|
451
|
-
|
|
452
|
-
//#region src/hooks/agents/use-agent-versions.ts
|
|
445
|
+
// src/hooks/agents/use-agent-versions.ts
|
|
453
446
|
/**
|
|
454
447
|
* Hook to list versions of a stored agent
|
|
455
448
|
*
|
|
@@ -564,8 +557,7 @@ const useCompareAgentVersions = ({ agentId, fromVersionId, toVersionId, requestC
|
|
|
564
557
|
...queryOptions
|
|
565
558
|
});
|
|
566
559
|
};
|
|
567
|
-
|
|
568
|
-
//#region src/hooks/agents/use-agent-working-memory.ts
|
|
560
|
+
// src/hooks/agents/use-agent-working-memory.ts
|
|
569
561
|
function parseJsonString(jsonString) {
|
|
570
562
|
try {
|
|
571
563
|
return JSON.stringify(JSON.parse(jsonString), null, 2);
|
|
@@ -661,8 +653,7 @@ function useAgentWorkingMemory(agentId, threadId, resourceId, requestContext) {
|
|
|
661
653
|
updateWorkingMemory
|
|
662
654
|
};
|
|
663
655
|
}
|
|
664
|
-
|
|
665
|
-
//#region src/hooks/agents/use-agent-workspace.ts
|
|
656
|
+
// src/hooks/agents/use-agent-workspace.ts
|
|
666
657
|
/**
|
|
667
658
|
* Hook to read and mutate the workspace reference for a stored agent.
|
|
668
659
|
*
|
|
@@ -702,8 +693,7 @@ function useAgentWorkspace({ agentId, requestContext, queryOptions } = {}) {
|
|
|
702
693
|
})
|
|
703
694
|
};
|
|
704
695
|
}
|
|
705
|
-
|
|
706
|
-
//#region src/hooks/agents/use-agent.ts
|
|
696
|
+
// src/hooks/agents/use-agent.ts
|
|
707
697
|
/**
|
|
708
698
|
* Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
|
|
709
699
|
*/
|
|
@@ -720,8 +710,7 @@ const useAgent = ({ agentId, requestContext, queryOptions } = {}) => {
|
|
|
720
710
|
...queryOptions
|
|
721
711
|
});
|
|
722
712
|
};
|
|
723
|
-
|
|
724
|
-
//#region src/hooks/agents/use-agents-model-providers.ts
|
|
713
|
+
// src/hooks/agents/use-agents-model-providers.ts
|
|
725
714
|
const useAgentsModelProviders = ({ queryOptions } = {}) => {
|
|
726
715
|
const client = require_mastra_client_context.useMastraClient();
|
|
727
716
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -731,8 +720,7 @@ const useAgentsModelProviders = ({ queryOptions } = {}) => {
|
|
|
731
720
|
...queryOptions
|
|
732
721
|
});
|
|
733
722
|
};
|
|
734
|
-
|
|
735
|
-
//#region src/hooks/agents/use-agents.ts
|
|
723
|
+
// src/hooks/agents/use-agents.ts
|
|
736
724
|
const useAgents = ({ requestContext, queryOptions } = {}) => {
|
|
737
725
|
const client = require_mastra_client_context.useMastraClient();
|
|
738
726
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -797,8 +785,7 @@ const useResetAgentModel = ({ agentId, queryOptions }) => {
|
|
|
797
785
|
...queryOptions
|
|
798
786
|
});
|
|
799
787
|
};
|
|
800
|
-
|
|
801
|
-
//#region src/hooks/agents/use-close-browser.ts
|
|
788
|
+
// src/hooks/agents/use-close-browser.ts
|
|
802
789
|
/**
|
|
803
790
|
* Mutation hook for closing an agent's browser session.
|
|
804
791
|
*/
|
|
@@ -812,8 +799,7 @@ function useCloseBrowser({ queryOptions } = {}) {
|
|
|
812
799
|
...queryOptions
|
|
813
800
|
});
|
|
814
801
|
}
|
|
815
|
-
|
|
816
|
-
//#region src/hooks/agents/use-preview-instructions.ts
|
|
802
|
+
// src/hooks/agents/use-preview-instructions.ts
|
|
817
803
|
/**
|
|
818
804
|
* Normalize blocks to API format.
|
|
819
805
|
* Form-format ref blocks have `{ type: 'prompt_block_ref', promptBlockId }`,
|
|
@@ -857,8 +843,7 @@ function usePreviewInstructions({ blocks, requestContext, queryOptions }) {
|
|
|
857
843
|
...queryOptions
|
|
858
844
|
});
|
|
859
845
|
}
|
|
860
|
-
|
|
861
|
-
//#region src/hooks/agents/use-stored-skills.ts
|
|
846
|
+
// src/hooks/agents/use-stored-skills.ts
|
|
862
847
|
function useStoredSkills({ queryOptions } = {}) {
|
|
863
848
|
const client = require_mastra_client_context.useMastraClient();
|
|
864
849
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -867,8 +852,7 @@ function useStoredSkills({ queryOptions } = {}) {
|
|
|
867
852
|
...queryOptions
|
|
868
853
|
});
|
|
869
854
|
}
|
|
870
|
-
|
|
871
|
-
//#region src/hooks/agents/use-channels.ts
|
|
855
|
+
// src/hooks/agents/use-channels.ts
|
|
872
856
|
const useChannelPlatforms = ({ queryOptions } = {}) => {
|
|
873
857
|
const client = require_mastra_client_context.useMastraClient();
|
|
874
858
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -952,8 +936,7 @@ const useDisconnectChannel = ({ platform, queryOptions }) => {
|
|
|
952
936
|
...queryOptions
|
|
953
937
|
});
|
|
954
938
|
};
|
|
955
|
-
|
|
956
|
-
//#region src/hooks/agents/use-execute-agent-tool.ts
|
|
939
|
+
// src/hooks/agents/use-execute-agent-tool.ts
|
|
957
940
|
const useExecuteAgentTool = ({ queryOptions } = {}) => {
|
|
958
941
|
const client = require_mastra_client_context.useMastraClient();
|
|
959
942
|
return (0, _tanstack_react_query.useMutation)({
|
|
@@ -970,7 +953,6 @@ const useExecuteAgentTool = ({ queryOptions } = {}) => {
|
|
|
970
953
|
...queryOptions
|
|
971
954
|
});
|
|
972
955
|
};
|
|
973
|
-
//#endregion
|
|
974
956
|
exports.browserSessionProbeQueryKey = browserSessionProbeQueryKey;
|
|
975
957
|
exports.isModelNotAllowedError = isModelNotAllowedError;
|
|
976
958
|
exports.useActivateAgentVersion = useActivateAgentVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMastraClient","useInfiniteQuery","skipToken","useMastraClient","useQuery","useMastraClient","useState","useRef","useMemo","useCallback","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useQueryClient","useMemo","useMutation","useMastraClient","useQuery","skipToken","useQueryClient","useMutation","useMastraClient","useState","useRef","useCallback","useMastraClient","useQueryClient","useMemo","useMutation","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useMutation","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useMutation","RequestContext"],"sources":["../../../src/hooks/agents/use-agent-messages.ts","../../../src/hooks/agents/use-agent-plan.ts","../../../src/hooks/agents/use-background-tasks.ts","../../../src/hooks/agents/use-browser-session-probe.ts","../../../src/hooks/agents/is-model-not-allowed.ts","../../../src/hooks/agents/use-stored-agents.ts","../../../src/hooks/agents/use-agent-skills.ts","../../../src/hooks/agents/use-agent-versions.ts","../../../src/hooks/agents/use-agent-working-memory.ts","../../../src/hooks/agents/use-agent-workspace.ts","../../../src/hooks/agents/use-agent.ts","../../../src/hooks/agents/use-agents-model-providers.ts","../../../src/hooks/agents/use-agents.ts","../../../src/hooks/agents/use-close-browser.ts","../../../src/hooks/agents/use-preview-instructions.ts","../../../src/hooks/agents/use-stored-skills.ts","../../../src/hooks/agents/use-channels.ts","../../../src/hooks/agents/use-execute-agent-tool.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { MastraDBMessage } from '@mastra/core/agent/message-list';\nimport { skipToken, useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions } from '../shared/query-options';\n\ntype AgentMessagesPage = Awaited<ReturnType<MastraClient['listThreadMessages']>>;\n\ntype AgentMessagesData = InfiniteData<AgentMessagesPage, string> & { messages: MastraDBMessage[] };\n\nexport interface UseAgentMessagesProps<TData = AgentMessagesData> {\n threadId?: string;\n agentId: string;\n memory: boolean;\n requestContext?: Record<string, any>;\n queryOptions?: MastraInfiniteQueryOptions<AgentMessagesPage, TData, QueryKey, string>;\n}\n\nconst PER_PAGE = 40;\n\nconst NEWEST_PAGE = '';\n\nconst createdAtMs = (message: MastraDBMessage) => new Date(message.createdAt).getTime();\n\nconst byCreatedAt = (a: MastraDBMessage, b: MastraDBMessage) => createdAtMs(a) - createdAtMs(b);\n\nexport const useAgentMessages = <TData = AgentMessagesData>({\n threadId,\n agentId,\n memory,\n requestContext,\n queryOptions,\n}: UseAgentMessagesProps<TData>) => {\n const client = useMastraClient();\n\n return useInfiniteQuery({\n queryKey: ['memory', 'messages', threadId, agentId, requestContext],\n initialPageParam: NEWEST_PAGE,\n queryFn:\n memory && threadId\n ? ({ pageParam: olderThan }) =>\n client.listThreadMessages(threadId, {\n agentId,\n requestContext,\n includeSystemReminders: true,\n perPage: PER_PAGE,\n orderBy: { field: 'createdAt', direction: 'DESC' },\n // Inclusive bound: messages sharing the oldest createdAt of the previous page\n // may have been cut off by perPage, so re-ask for them and dedupe by id below.\n filter: olderThan ? { dateRange: { end: new Date(olderThan) } } : undefined,\n })\n : skipToken,\n getNextPageParam: (lastPage, _allPages, lastPageParam) => {\n if (!lastPage.hasMore || lastPage.messages.length === 0) return undefined;\n const next = new Date(Math.min(...lastPage.messages.map(createdAtMs))).toISOString();\n // A full page of same-timestamp messages would re-request itself forever.\n return next === lastPageParam ? undefined : next;\n },\n select: (data): TData => {\n const seen = new Set<string>();\n const messages = data.pages\n .flatMap(page => page.messages)\n .filter(message => {\n if (seen.has(message.id)) return false;\n seen.add(message.id);\n return true;\n })\n .sort(byCreatedAt);\n return { ...data, messages } as AgentMessagesData as TData;\n },\n staleTime: 0,\n gcTime: 0,\n retry: false,\n refetchOnWindowFocus: false,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype AgentPlanResponse = Awaited<ReturnType<ReturnType<MastraClient['getAgent']>['readPlan']>>;\n\ninterface UseAgentPlanOptions<TData> {\n agentId: string;\n path: string;\n agentVersionId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<AgentPlanResponse, TData>;\n}\n\nexport function useAgentPlan<TData = AgentPlanResponse>({\n agentId,\n path,\n agentVersionId,\n requestContext,\n queryOptions,\n}: UseAgentPlanOptions<TData>): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['agent-plan', agentId, agentVersionId, path, requestContext],\n queryFn: () => {\n const agent = agentVersionId ? client.getAgent(agentId, { versionId: agentVersionId }) : client.getAgent(agentId);\n return agent.readPlan(path, requestContext);\n },\n retry: false,\n ...queryOptions,\n });\n}\n","import type { MastraClient, StreamBackgroundTasksParams } from '@mastra/client-js';\nimport type { BackgroundTaskStatus } from '@mastra/core/background-tasks';\nimport type { AgentChunkType } from '@mastra/core/stream';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype BackgroundTaskStreamReader = ReturnType<Awaited<ReturnType<MastraClient['streamBackgroundTasks']>>['getReader']>;\n\nexport interface BackgroundTaskEvent {\n taskId: string;\n toolName: string;\n toolCallId: string;\n agentId: string;\n runId: string;\n result?: unknown;\n error?: { message: string; stack?: string };\n status: BackgroundTaskStatus;\n args: Record<string, unknown>;\n suspendPayload?: unknown;\n}\n\nexport interface UseBackgroundTaskStreamOptions extends StreamBackgroundTasksParams {\n /** Whether the stream is active. Default: true */\n enabled?: boolean;\n}\n\nexport interface UseBackgroundTaskStreamReturn {\n /** Map of taskId → latest event data */\n tasks: Record<string, BackgroundTaskEvent>;\n /** Whether the stream is currently connected */\n isConnected: boolean;\n /** Any connection error */\n error: Error | null;\n /** Manually disconnect the stream */\n disconnect: () => void;\n /** Manually reconnect the stream */\n reconnect: () => void;\n /** List of running tasks */\n runningTasks: BackgroundTaskEvent[];\n /** List of completed tasks */\n completedTasks: BackgroundTaskEvent[];\n /** List of failed tasks */\n failedTasks: BackgroundTaskEvent[];\n /** Clear completed and failed tasks */\n clearCompletedAndFailedTasks: () => void;\n}\n\n/**\n * Streams background task events via SSE and accumulates them in a map keyed by taskId.\n *\n * Each incoming event (task.completed / task.failed) is stored in state so the UI\n * can react to completions — e.g., show a toast, update a badge, or display results.\n *\n * @example\n * ```tsx\n * const { tasks, isConnected, completedTasks } = useBackgroundTaskStream({ agentId: 'crypto-agent' });\n *\n * // Show a badge with completed count\n * const completedCount = completedTasks.length;\n * ```\n */\n\ntype EventType = Extract<\n AgentChunkType,\n {\n type:\n | 'background-task-running'\n | 'background-task-completed'\n | 'background-task-failed'\n | 'background-task-cancelled'\n | 'background-task-output'\n | 'background-task-suspended'\n | 'background-task-resumed';\n }\n>;\n\nconst EVENT_STATUS_MAP: Record<EventType['type'], BackgroundTaskStatus> = {\n 'background-task-running': 'running',\n 'background-task-output': 'running',\n 'background-task-completed': 'completed',\n 'background-task-failed': 'failed',\n 'background-task-cancelled': 'cancelled',\n 'background-task-suspended': 'suspended',\n 'background-task-resumed': 'running',\n};\n\nexport function useBackgroundTaskStream(options: UseBackgroundTaskStreamOptions = {}): UseBackgroundTaskStreamReturn {\n const { enabled = true, agentId, runId, threadId, resourceId, taskId } = options;\n const client = useMastraClient();\n\n const [tasks, setTasks] = useState<Record<string, BackgroundTaskEvent>>({});\n const [isConnected, setIsConnected] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const readerRef = useRef<BackgroundTaskStreamReader | null>(null);\n const connectSeqRef = useRef(0);\n\n const runningTasks = useMemo(() => {\n return Object.values(tasks).filter(task => task.status === 'running');\n }, [tasks]);\n\n const completedTasks = useMemo(() => {\n return Object.values(tasks).filter(task => task.status === 'completed');\n }, [tasks]);\n\n const failedTasks = useMemo(() => {\n return Object.values(tasks).filter(task => task.status === 'failed');\n }, [tasks]);\n\n const cleanup = useCallback(() => {\n readerRef.current?.cancel().catch(() => {});\n readerRef.current = null;\n abortRef.current?.abort();\n abortRef.current = null;\n setIsConnected(false);\n }, []);\n\n const connect = useCallback(async () => {\n const seq = ++connectSeqRef.current;\n cleanup();\n setError(null);\n\n const controller = new AbortController();\n abortRef.current = controller;\n\n try {\n const stream = await client.streamBackgroundTasks({ agentId, runId, threadId, resourceId, taskId });\n\n if (!stream) {\n setError(new Error('Stream connection failed'));\n return;\n }\n\n if (seq === connectSeqRef.current) {\n setIsConnected(true);\n }\n\n // Get a reader from the ReadableStream and store it in ref\n const reader = stream.getReader();\n readerRef.current = reader;\n\n while (!controller.signal.aborted) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const event = value as EventType;\n if (event.type !== 'background-task-output') {\n setTasks(prev => ({\n ...prev,\n [event.payload.taskId]: {\n ...prev[event.payload.taskId],\n ...event.payload,\n status: EVENT_STATUS_MAP[event.type],\n args:\n ('args' in event.payload ? event.payload.args : undefined) ?? prev[event.payload.taskId]?.args ?? {},\n },\n }));\n }\n }\n } catch (err: any) {\n if (err?.name !== 'AbortError') {\n if (seq === connectSeqRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n }\n } finally {\n if (seq === connectSeqRef.current) {\n setIsConnected(false);\n }\n }\n }, [client, agentId, runId, threadId, resourceId, taskId, cleanup]);\n\n useEffect(() => {\n if (!enabled) {\n cleanup();\n return;\n }\n\n void connect();\n return cleanup;\n }, [enabled, connect, cleanup]);\n\n const disconnect = useCallback(() => {\n cleanup();\n }, [cleanup]);\n\n const reconnect = useCallback(() => {\n void connect();\n }, [connect]);\n\n const clearCompletedAndFailedTasks = () => {\n setTasks(prev => {\n const newTasks = { ...prev };\n Object.values(newTasks).forEach(task => {\n if (\n task.status === 'completed' ||\n task.status === 'failed' ||\n task.status === 'cancelled' ||\n task.status === 'timed_out'\n ) {\n delete newTasks[task.taskId];\n }\n });\n return newTasks;\n });\n };\n\n return {\n tasks,\n isConnected,\n error,\n disconnect,\n reconnect,\n runningTasks,\n completedTasks,\n failedTasks,\n clearCompletedAndFailedTasks,\n };\n}\n\ntype BackgroundTaskResponse = Awaited<ReturnType<MastraClient['getBackgroundTask']>>;\n\nexport const useGetBackgroundTaskById = <TData = BackgroundTaskResponse>({\n backgroundTaskId,\n queryOptions,\n}: {\n backgroundTaskId: string;\n queryOptions?: MastraQueryOptions<BackgroundTaskResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['background-task', backgroundTaskId],\n queryFn: () => client.getBackgroundTask(backgroundTaskId),\n ...queryOptions,\n });\n};\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport interface BrowserSessionProbe {\n hasSession: boolean;\n screencastAvailable: boolean;\n}\n\ninterface UseBrowserSessionProbeOptions<TData> {\n agentId?: string;\n threadId?: string;\n /** TanStack overrides spread last, e.g. `{ enabled: false }` for agents without browser tools. */\n queryOptions?: MastraQueryOptions<BrowserSessionProbe, TData>;\n}\n\nexport const browserSessionProbeQueryKey = (agentId?: string, threadId?: string) =>\n ['browser-session-probe', agentId, threadId] as const;\n\nconst LEGACY_FALLBACK: BrowserSessionProbe = { hasSession: true, screencastAvailable: true };\n\nconst isNotFoundError = (error: unknown): boolean => {\n if (!error || typeof error !== 'object') return false;\n if ('status' in error && (error as { status: unknown }).status === 404) return true;\n if ('statusCode' in error && (error as { statusCode: unknown }).statusCode === 404) return true;\n return false;\n};\n\n/**\n * Query hook that probes the server for the agent's browser session state.\n *\n * Used by {@link BrowserSessionProvider} to decide whether to open a screencast\n * WebSocket. The probe avoids two failure modes:\n *\n * 1. `screencastAvailable: false` — the server doesn't have `ws` / `@hono/node-ws`\n * installed (or the route was never registered). Opening a WS would fail and\n * trigger a reconnect loop.\n * 2. `hasSession: false` — no active browser session for this thread yet. Opening\n * a WS would succeed but sit idle, holding resources for no reason.\n *\n * When the endpoint itself returns 404 (older server that predates this probe),\n * the hook assumes screencast is available and a session is active so behavior\n * matches the legacy unconditional connect.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function useBrowserSessionProbe<TData = BrowserSessionProbe>({\n agentId,\n threadId,\n queryOptions,\n}: UseBrowserSessionProbeOptions<TData>): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery<BrowserSessionProbe, Error, TData>({\n queryKey: browserSessionProbeQueryKey(agentId, threadId),\n queryFn: async () => {\n if (!agentId) {\n return { hasSession: false, screencastAvailable: false };\n }\n\n try {\n return await client.getAgent(agentId).browserSession(threadId);\n } catch (error) {\n if (isNotFoundError(error)) {\n // Older server without the probe endpoint — fall back to legacy behavior.\n return LEGACY_FALLBACK;\n }\n throw error;\n }\n },\n // No polling: the probe fires once on mount, on window focus, and is\n // updated via `setQueriesData` from `tool-fallback.tsx` when a browser\n // tool call transitions. This avoids idle 5s polls and lets the probe\n // flip to `hasSession: true` the instant a tool call is seen.\n refetchOnWindowFocus: true,\n staleTime: 0,\n retry: 1,\n ...queryOptions,\n });\n}\n","/**\n * The wire-level error code the server emits on a 422 when a model is blocked\n * by the admin's builder policy. Kept as a local literal so the browser bundle\n * never imports server-only agent-builder EE code.\n */\nconst MODEL_NOT_ALLOWED_CODE = 'MODEL_NOT_ALLOWED';\n\nexport interface ModelNotAllowedDetails {\n message: string;\n attempted?: { provider?: string; modelId?: string };\n offendingLabel?: string;\n}\n\n/**\n * Detects HTTP 422 + MODEL_NOT_ALLOWED responses thrown by `MastraClientError`\n * (or any error carrying `status` + `body.error.code`). Returns the parsed\n * details when matched, or `null` otherwise.\n */\nexport function isModelNotAllowedError(err: unknown): ModelNotAllowedDetails | null {\n if (!err || typeof err !== 'object') return null;\n const candidate = err as { status?: number; body?: unknown; message?: string };\n if (candidate.status !== 422) return null;\n const body = candidate.body as { error?: { code?: unknown } } | undefined;\n const code = body?.error?.code;\n if (code !== MODEL_NOT_ALLOWED_CODE) return null;\n const errorBody = body!.error as {\n message?: string;\n attempted?: { provider?: string; modelId?: string };\n offendingLabel?: string;\n };\n return {\n message: errorBody.message || candidate.message || 'Model not allowed by admin policy',\n attempted: errorBody.attempted,\n offendingLabel: errorBody.offendingLabel,\n };\n}\n","import type {\n CreateStoredAgentParams,\n UpdateStoredAgentParams,\n ListStoredAgentsParams,\n StoredAgentResponse,\n ListStoredAgentsResponse,\n StoredAgentDependentsResponse,\n DeleteStoredAgentResponse,\n} from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\nimport { isModelNotAllowedError } from './is-model-not-allowed';\n\nexport const useStoredAgents = <TData = ListStoredAgentsResponse>({\n queryOptions,\n ...params\n}: ListStoredAgentsParams & {\n queryOptions?: MastraQueryOptions<ListStoredAgentsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n const listParams = Object.keys(params).length > 0 ? params : undefined;\n\n return useQuery({\n queryKey: ['stored-agents', listParams],\n queryFn: () => client.listStoredAgents(listParams),\n ...queryOptions,\n });\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredAgent = <TData = StoredAgentResponse | null>({\n agentId,\n status,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredAgentResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['stored-agent', agentId, status, requestContext],\n queryFn: async () => {\n if (!agentId) return null;\n try {\n return await client.getStoredAgent(agentId).details(requestContext, { status });\n } catch (error) {\n // 404 is expected for code-only agents that haven't been stored yet\n if (error && typeof error === 'object' && 'status' in error && (error as { status: number }).status === 404) {\n return null;\n }\n throw error;\n }\n },\n retry: false,\n ...queryOptions,\n });\n};\n\nexport type StoredAgent = StoredAgentResponse;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredAgentDependents = <TData = StoredAgentDependentsResponse>({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredAgentDependentsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['stored-agent-dependents', agentId, requestContext],\n queryFn: () => client.getStoredAgent(agentId!).dependents(requestContext),\n retry: false,\n ...queryOptions,\n });\n};\n\nexport const useStoredAgentMutations = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredAgent?: MastraMutationOptions<StoredAgentResponse, CreateStoredAgentParams>;\n updateStoredAgent?: MastraMutationOptions<StoredAgentResponse, UpdateStoredAgentParams>;\n deleteStoredAgent?: MastraMutationOptions<DeleteStoredAgentResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n // If the server rejects with HTTP 422 + MODEL_NOT_ALLOWED the admin policy\n // has likely changed under us — refresh the cached settings so the UI\n // re-renders against the latest server truth.\n const invalidateBuilderSettingsOnPolicyReject = (err: unknown) => {\n if (isModelNotAllowedError(err)) {\n void queryClient.invalidateQueries({ queryKey: ['builder-settings'] });\n }\n };\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredAgentParams) => client.createStoredAgent(params),\n onSuccess: created => {\n // Prime the per-agent details cache with the response so the next page\n // (the edit page) can render the agent on first paint without a refetch.\n // The starter relies on this to immediately mount the conversation panel\n // and dispatch the user's initial message.\n queryClient.setQueryData(['stored-agent', created.id, 'draft', requestContext], created);\n queryClient.setQueryData(['stored-agent', created.id, undefined, requestContext], created);\n // Invalidate both stored-agents list and the merged agents list\n void queryClient.invalidateQueries({ queryKey: ['stored-agents'] });\n void queryClient.invalidateQueries({ queryKey: ['agents'] });\n // Invalidate the merged agent details so the freshly-created id resolves\n // instead of staying stuck on the initial `null` from the 404 lookup.\n void queryClient.invalidateQueries({ queryKey: ['agent', created.id] });\n },\n onError: invalidateBuilderSettingsOnPolicyReject,\n ...queryOptions?.createStoredAgent,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredAgentParams) => {\n if (!agentId) throw new Error('agentId is required for update');\n return client.getStoredAgent(agentId).update(params, requestContext);\n },\n onSuccess: () => {\n // Invalidate lists\n void queryClient.invalidateQueries({ queryKey: ['stored-agents'] });\n void queryClient.invalidateQueries({ queryKey: ['agents'] });\n // Invalidate specific agent details\n if (agentId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n }\n },\n onError: invalidateBuilderSettingsOnPolicyReject,\n ...queryOptions?.updateStoredAgent,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!agentId) throw new Error('agentId is required for delete');\n return client.getStoredAgent(agentId).delete(requestContext);\n },\n onSuccess: () => {\n // Invalidate lists so the agents list page refetches without the deleted entry\n void queryClient.invalidateQueries({ queryKey: ['stored-agents'] });\n void queryClient.invalidateQueries({ queryKey: ['agents'] });\n // Drop the deleted entity from the cache so active observers don't refetch a 404\n if (agentId) {\n queryClient.removeQueries({ queryKey: ['stored-agent', agentId] });\n queryClient.removeQueries({ queryKey: ['agent', agentId] });\n }\n },\n ...queryOptions?.deleteStoredAgent,\n });\n\n return {\n createStoredAgent: createMutation,\n updateStoredAgent: updateMutation,\n deleteStoredAgent: deleteMutation,\n };\n};\n","import type { StoredAgentResponse, StoredAgentSkillConfig, UpdateStoredAgentParams } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\nimport { useStoredAgent } from './use-stored-agents';\n\n/**\n * Hook to read and mutate the skills config for a stored agent.\n *\n * The skills field is `Record<string, StoredAgentSkillConfig>` on the agent\n * snapshot. Each key is a stored skill ID and the value holds per-skill\n * overrides (description, instructions, pin, strategy).\n */\nexport function useAgentSkills({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n updateSkills?: MastraMutationOptions<StoredAgentResponse, Record<string, StoredAgentSkillConfig> | undefined>;\n };\n} = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const { data: agent } = useStoredAgent({ agentId, status: 'draft', queryOptions: { enabled: Boolean(agentId) } });\n\n const skills = useMemo((): Record<string, StoredAgentSkillConfig> => {\n if (!agent?.skills) return {};\n // Handle conditional field: if it's an array of variants, merge values\n if (Array.isArray(agent.skills)) {\n const merged: Record<string, StoredAgentSkillConfig> = {};\n for (const variant of agent.skills) {\n Object.assign(merged, variant.value);\n }\n return merged;\n }\n return agent.skills as Record<string, StoredAgentSkillConfig>;\n }, [agent?.skills]);\n\n const updateSkills = useMutation({\n mutationFn: (newSkills: Record<string, StoredAgentSkillConfig> | undefined) => {\n if (!agentId) throw new Error('agentId is required');\n const params: UpdateStoredAgentParams = { skills: newSkills };\n return client.getStoredAgent(agentId).update(params, requestContext);\n },\n onSuccess: () => {\n if (agentId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n }\n },\n ...queryOptions?.updateSkills,\n });\n\n return { skills, updateSkills };\n}\n","import type {\n ListAgentVersionsParams,\n CreateAgentVersionParams,\n ListAgentVersionsResponse,\n AgentVersionResponse,\n CompareVersionsResponse,\n ActivateAgentVersionResponse,\n DeleteAgentVersionResponse,\n} from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery, useMutation, useQueryClient, skipToken } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ListAgentVersionsParams, CreateAgentVersionParams };\n\ntype UseAgentVersionsParams<TData = ListAgentVersionsResponse> = {\n agentId?: string;\n params?: ListAgentVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListAgentVersionsResponse, TData>;\n};\n\n/**\n * Hook to list versions of a stored agent\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useAgentVersions = <TData = ListAgentVersionsResponse>({\n agentId,\n params,\n requestContext,\n queryOptions,\n}: UseAgentVersionsParams<TData>): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListAgentVersionsResponse, Error, TData>({\n queryKey: ['agent-versions', agentId, params, requestContext],\n queryFn: agentId ? () => client.getStoredAgent(agentId).listVersions(params, requestContext) : skipToken,\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored agent\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useAgentVersion = <TData = AgentVersionResponse>({\n agentId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<AgentVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<AgentVersionResponse, Error, TData>({\n queryKey: ['agent-version', agentId, versionId, requestContext],\n queryFn: () => client.getStoredAgent(agentId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored agent\n */\nexport const useCreateAgentVersion = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<AgentVersionResponse, CreateAgentVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<AgentVersionResponse, Error, CreateAgentVersionParams | undefined>({\n mutationFn: (params?: CreateAgentVersionParams) =>\n client.getStoredAgent(agentId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored agent\n */\nexport const useActivateAgentVersion = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivateAgentVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivateAgentVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredAgent(agentId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored agent (creates a new version from an old one)\n */\nexport const useRestoreAgentVersion = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<AgentVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<AgentVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredAgent(agentId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored agent\n */\nexport const useDeleteAgentVersion = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeleteAgentVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeleteAgentVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredAgent(agentId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to compare two versions of a stored agent\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useCompareAgentVersions = <TData = CompareVersionsResponse>({\n agentId,\n fromVersionId,\n toVersionId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n fromVersionId: string;\n toVersionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<CompareVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<CompareVersionsResponse, Error, TData>({\n queryKey: ['agent-versions-compare', agentId, fromVersionId, toVersionId, requestContext],\n queryFn: () => client.getStoredAgent(agentId).compareVersions(fromVersionId, toVersionId, requestContext),\n ...queryOptions,\n });\n};\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\n\nfunction parseJsonString(jsonString: string): any {\n try {\n return JSON.stringify(JSON.parse(jsonString), null, 2);\n } catch {\n return jsonString;\n }\n}\n\nexport function useAgentWorkingMemory(\n agentId: string,\n threadId: string,\n resourceId: string,\n requestContext?: Record<string, any>,\n) {\n const client = useMastraClient();\n const [threadExists, setThreadExists] = useState(false);\n const [workingMemoryData, setWorkingMemoryData] = useState<string | null>(null);\n const [workingMemorySource, setWorkingMemorySource] = useState<'thread' | 'resource'>('thread');\n const [workingMemoryFormat, setWorkingMemoryFormat] = useState<'json' | 'markdown'>('markdown');\n const [isLoading, setIsLoading] = useState(true);\n const [isUpdating, setIsUpdating] = useState(false);\n const latestRequest = useRef(0);\n\n const refetch = useCallback(async () => {\n const requestId = ++latestRequest.current;\n setIsLoading(true);\n try {\n if (!agentId || !threadId) {\n setWorkingMemoryData(null);\n setIsLoading(false);\n return;\n }\n const res = await client.getWorkingMemory({ agentId, threadId, resourceId, requestContext });\n if (requestId !== latestRequest.current) return;\n const { workingMemory, source, workingMemoryTemplate, threadExists } = res as {\n workingMemory: string | null;\n source: 'thread' | 'resource';\n workingMemoryTemplate: { content: string; format: 'json' | 'markdown' };\n threadExists: boolean;\n };\n setThreadExists(threadExists);\n setWorkingMemoryData(workingMemory);\n setWorkingMemorySource(source);\n setWorkingMemoryFormat(workingMemoryTemplate?.format || 'markdown');\n if (workingMemoryTemplate?.format === 'json') {\n let dataToSet = '';\n if (workingMemory) {\n dataToSet = parseJsonString(workingMemory);\n } else if (workingMemoryTemplate?.content) {\n dataToSet = parseJsonString(workingMemoryTemplate.content);\n } else {\n dataToSet = '';\n }\n setWorkingMemoryData(dataToSet);\n } else {\n setWorkingMemoryData(workingMemory || workingMemoryTemplate?.content || '');\n }\n } catch (error) {\n if (requestId !== latestRequest.current) return;\n setWorkingMemoryData(null);\n console.error('Error fetching working memory', error);\n } finally {\n if (requestId === latestRequest.current) setIsLoading(false);\n }\n }, [agentId, threadId, resourceId, client, requestContext]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n const updateWorkingMemory = async (newMemory: string) => {\n setIsUpdating(true);\n try {\n if (workingMemoryFormat === 'json') {\n try {\n JSON.parse(newMemory);\n } catch {\n throw new Error('Invalid JSON working memory');\n }\n }\n await client.updateWorkingMemory({ agentId, threadId, workingMemory: newMemory, resourceId, requestContext });\n void refetch();\n } catch (error) {\n console.error('Error updating working memory', error);\n throw error;\n } finally {\n setIsUpdating(false);\n }\n };\n\n return {\n threadExists,\n workingMemoryData,\n workingMemorySource,\n workingMemoryFormat,\n isLoading,\n isUpdating,\n refetch,\n updateWorkingMemory,\n };\n}\n","import type { StoredAgentResponse, StoredWorkspaceRef, UpdateStoredAgentParams } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\nimport { useStoredAgent } from './use-stored-agents';\n\n/**\n * Hook to read and mutate the workspace reference for a stored agent.\n *\n * The workspace ref is part of the agent snapshot config and can be:\n * - `{ type: 'id', workspaceId }` — references a stored workspace by ID\n * - `{ type: 'inline', config }` — inline workspace config\n * - `undefined` — no workspace assigned\n */\nexport function useAgentWorkspace({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n updateWorkspace?: MastraMutationOptions<StoredAgentResponse, StoredWorkspaceRef | undefined>;\n };\n} = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const { data: agent } = useStoredAgent({ agentId, status: 'draft', queryOptions: { enabled: Boolean(agentId) } });\n\n const workspace = useMemo((): StoredWorkspaceRef | undefined => {\n if (!agent?.workspace) return undefined;\n // Handle conditional field: if it's an array of variants, take the first value\n if (Array.isArray(agent.workspace)) {\n return agent.workspace[0]?.value as StoredWorkspaceRef | undefined;\n }\n return agent.workspace as StoredWorkspaceRef;\n }, [agent?.workspace]);\n\n const updateWorkspace = useMutation({\n mutationFn: (ref: StoredWorkspaceRef | undefined) => {\n if (!agentId) throw new Error('agentId is required');\n const params: UpdateStoredAgentParams = { workspace: ref };\n return client.getStoredAgent(agentId).update(params, requestContext);\n },\n onSuccess: () => {\n if (agentId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n }\n },\n ...queryOptions?.updateWorkspace,\n });\n\n return { workspace, updateWorkspace };\n}\n","import type { GetAgentResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useAgent = <TData = GetAgentResponse | null>({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<GetAgentResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['agent', agentId, requestContext],\n queryFn: () => (agentId ? client.getAgent(agentId).details(requestContext) : null),\n retry: false,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype AgentsModelProvidersResponse = Awaited<ReturnType<MastraClient['listAgentsModelProviders']>>;\n\nexport const useAgentsModelProviders = <TData = AgentsModelProvidersResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<AgentsModelProvidersResponse, TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['agents-model-providers'],\n queryFn: () => client.listAgentsModelProviders(),\n retry: false,\n ...queryOptions,\n });\n};\n","import type {\n MastraClient,\n ReorderModelListParams,\n UpdateModelInModelListParams,\n UpdateModelParams,\n} from '@mastra/client-js';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport type { UseMutationResult, UseQueryResult } from '@tanstack/react-query';\n\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\ntype Agent = ReturnType<MastraClient['getAgent']>;\ntype ListAgentsResponse = Awaited<ReturnType<MastraClient['listAgents']>>;\nexport type ModelUpdateResponse = Awaited<ReturnType<Agent['updateModel']>>;\n\nexport const useAgents = <TData = ListAgentsResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListAgentsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['agents', requestContext],\n queryFn: () => client.listAgents(requestContext),\n ...queryOptions,\n });\n};\n\nexport const useUpdateAgentModel = ({\n agentId,\n queryOptions,\n}: {\n agentId: string;\n queryOptions?: MastraMutationOptions<ModelUpdateResponse, UpdateModelParams>;\n}): UseMutationResult<ModelUpdateResponse, Error, UpdateModelParams> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (payload: UpdateModelParams) => client.getAgent(agentId).updateModel(payload),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n onError: err => {\n console.error('Error updating model', err);\n },\n ...queryOptions,\n });\n};\n\nexport const useReorderModelList = ({\n agentId,\n queryOptions,\n}: {\n agentId: string;\n queryOptions?: MastraMutationOptions<ModelUpdateResponse, ReorderModelListParams>;\n}): UseMutationResult<ModelUpdateResponse, Error, ReorderModelListParams> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (payload: ReorderModelListParams) => client.getAgent(agentId).reorderModelList(payload),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n onError: err => {\n console.error('Error reordering model list', err);\n },\n ...queryOptions,\n });\n};\n\nexport const useUpdateModelInModelList = ({\n agentId,\n queryOptions,\n}: {\n agentId: string;\n queryOptions?: MastraMutationOptions<ModelUpdateResponse, UpdateModelInModelListParams>;\n}): UseMutationResult<ModelUpdateResponse, Error, UpdateModelInModelListParams> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (payload: UpdateModelInModelListParams) =>\n client.getAgent(agentId).updateModelInModelList(payload),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n onError: err => {\n console.error('Error updating model in model list', err);\n },\n ...queryOptions,\n });\n};\n\nexport const useResetAgentModel = ({\n agentId,\n queryOptions,\n}: {\n agentId: string;\n queryOptions?: MastraMutationOptions<ModelUpdateResponse, void>;\n}): UseMutationResult<ModelUpdateResponse, Error, void> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async () => client.getAgent(agentId).resetModel(),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n onError: err => {\n console.error('Error resetting model', err);\n },\n ...queryOptions,\n });\n};\n","import { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ninterface CloseBrowserParams {\n agentId: string;\n threadId?: string;\n}\n\n/**\n * Mutation hook for closing an agent's browser session.\n */\nexport function useCloseBrowser({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<{ success: boolean }, CloseBrowserParams> } = {}) {\n const client = useMastraClient();\n\n return useMutation<{ success: boolean }, Error, CloseBrowserParams>({\n mutationFn: ({ agentId, threadId }) => client.getAgent(agentId).closeBrowser(threadId),\n onError: err => {\n console.error('[useCloseBrowser] Error closing browser:', err);\n },\n ...queryOptions,\n });\n}\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ninterface ApiInstructionBlock {\n type: string;\n content?: string;\n id?: string;\n /** Form-format ref blocks use `promptBlockId` instead of `id` */\n promptBlockId?: string;\n rules?: unknown;\n}\n\n/**\n * Normalize blocks to API format.\n * Form-format ref blocks have `{ type: 'prompt_block_ref', promptBlockId }`,\n * while API-format blocks have `{ type: 'prompt_block_ref', id }`.\n */\nfunction toApiBlocks(blocks: ApiInstructionBlock[]) {\n return blocks.map(block => {\n if (block.type === 'prompt_block_ref') {\n // Form-format blocks have `promptBlockId` (the storage ID) and `id` (form-internal UUID).\n // API-format blocks have `id` (the storage ID). Prefer promptBlockId when present.\n return { type: 'prompt_block_ref' as const, id: block.promptBlockId ?? block.id, rules: block.rules };\n }\n return { type: block.type, content: block.content, rules: block.rules };\n });\n}\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function usePreviewInstructions<TData = string>({\n blocks,\n requestContext,\n queryOptions,\n}: {\n blocks: ApiInstructionBlock[] | undefined;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<string, TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['preview-instructions', blocks, requestContext],\n queryFn: async () => {\n if (!blocks || blocks.length === 0) return '';\n\n const response = await client.request<{ result: string }>('/stored/agents/preview-instructions', {\n method: 'POST',\n body: { blocks: toApiBlocks(blocks), context: requestContext },\n });\n\n return response.result;\n },\n ...queryOptions,\n });\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\n\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport type ListStoredSkillsResponse = Awaited<ReturnType<MastraClient['listStoredSkills']>>;\n\nexport function useStoredSkills<TData = ListStoredSkillsResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ListStoredSkillsResponse, TData> } = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['stored-skills'],\n queryFn: () => client.listStoredSkills(),\n ...queryOptions,\n });\n}\n","import type { ChannelPlatformInfo, ChannelInstallationInfo, ChannelConnectResult } from '@mastra/client-js';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport type { UseMutationResult, UseQueryResult } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ChannelPlatformInfo, ChannelInstallationInfo, ChannelConnectResult };\n\nexport const useChannelPlatforms = <TData = ChannelPlatformInfo[]>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ChannelPlatformInfo[], TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ChannelPlatformInfo[], Error, TData>({\n queryKey: ['channels', 'platforms'],\n queryFn: () => client.channels.listPlatforms(),\n staleTime: 60 * 1000,\n retry: false,\n ...queryOptions,\n });\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useChannelInstallations = <TData = ChannelInstallationInfo[]>({\n platform,\n agentId,\n queryOptions,\n}: {\n platform: string;\n agentId: string;\n queryOptions?: MastraQueryOptions<ChannelInstallationInfo[], TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ChannelInstallationInfo[], Error, TData>({\n queryKey: ['channels', 'installations', platform, agentId],\n queryFn: () => client.channels.listInstallations(platform, agentId),\n staleTime: 10 * 1000,\n retry: false,\n ...queryOptions,\n });\n};\n\n/**\n * Reconcile an agent's installation with platform state — activates a pending\n * installation whose connect flow completed out-of-band (e.g. a Discord bot\n * invite finished in another tab). Resolves null on platforms without\n * reconciliation. Call it deliberately (e.g. on window focus while a connect\n * is in flight) — it is a write, not a read.\n */\nexport const useReconcileChannelInstallation = ({\n platform,\n queryOptions,\n}: {\n platform: string;\n queryOptions?: MastraMutationOptions<ChannelInstallationInfo | null, string>;\n}): UseMutationResult<ChannelInstallationInfo | null, Error, string> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ChannelInstallationInfo | null, Error, string>({\n mutationFn: agentId => client.channels.reconcileInstallation(platform, agentId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['channels', 'installations', platform] });\n },\n ...queryOptions,\n });\n};\n\nexport const useConnectChannel = ({\n platform,\n queryOptions,\n}: {\n platform: string;\n queryOptions?: MastraMutationOptions<ChannelConnectResult, { agentId: string; options?: Record<string, unknown> }>;\n}): UseMutationResult<ChannelConnectResult, Error, { agentId: string; options?: Record<string, unknown> }> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ChannelConnectResult, Error, { agentId: string; options?: Record<string, unknown> }>({\n mutationFn: ({ agentId, options }) =>\n client.channels.connect(platform, agentId, {\n ...options,\n // Tell the server to redirect back here after OAuth\n redirectUrl: window.location.href,\n }),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['channels', 'installations', platform] });\n },\n ...queryOptions,\n });\n};\n\nexport const useDisconnectChannel = ({\n platform,\n queryOptions,\n}: {\n platform: string;\n queryOptions?: MastraMutationOptions<{ success: boolean }, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<{ success: boolean }, Error, string>({\n mutationFn: agentId => client.channels.disconnect(platform, agentId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['channels', 'installations', platform] });\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { RequestContext } from '@mastra/core/di';\nimport { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ntype ExecuteAgentToolResponse = Awaited<ReturnType<ReturnType<MastraClient['getAgent']>['executeTool']>>;\n\nexport interface ExecuteToolInput {\n agentId: string;\n toolId: string;\n input: any;\n playgroundRequestContext?: Record<string, any>;\n}\n\nexport const useExecuteAgentTool = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<ExecuteAgentToolResponse, ExecuteToolInput> } = {}) => {\n const client = useMastraClient();\n return useMutation({\n mutationFn: async ({ agentId, toolId, input, playgroundRequestContext }: ExecuteToolInput) => {\n const requestContext = new RequestContext();\n Object.entries(playgroundRequestContext ?? {}).forEach(([key, value]) => {\n requestContext.set(key, value);\n });\n return client.getAgent(agentId).executeTool(toolId, { data: input, requestContext });\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;AAmBA,MAAM,WAAW;AAEjB,MAAM,cAAc;AAEpB,MAAM,eAAe,YAA6B,IAAI,KAAK,QAAQ,SAAS,CAAC,CAAC,QAAQ;AAEtF,MAAM,eAAe,GAAoB,MAAuB,YAAY,CAAC,IAAI,YAAY,CAAC;AAE9F,MAAa,oBAA+C,EAC1D,UACA,SACA,QACA,gBACA,mBACkC;CAClC,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,iBAAAA,CAAiB;EACtB,UAAU;GAAC;GAAU;GAAY;GAAU;GAAS;EAAc;EAClE,kBAAkB;EAClB,SACE,UAAU,YACL,EAAE,WAAW,gBACZ,OAAO,mBAAmB,UAAU;GAClC;GACA;GACA,wBAAwB;GACxB,SAAS;GACT,SAAS;IAAE,OAAO;IAAa,WAAW;GAAO;GAGjD,QAAQ,YAAY,EAAE,WAAW,EAAE,KAAK,IAAI,KAAK,SAAS,EAAE,EAAE,IAAI,KAAA;EACpE,CAAC,IACHC,sBAAAA;EACN,mBAAmB,UAAU,WAAW,kBAAkB;GACxD,IAAI,CAAC,SAAS,WAAW,SAAS,SAAS,WAAW,GAAG,OAAO,KAAA;GAChE,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,GAAG,SAAS,SAAS,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,YAAY;GAEnF,OAAO,SAAS,gBAAgB,KAAA,IAAY;EAC9C;EACA,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gBAAgB;CAC/B,QAAA,GAAOC,sBAAAA,YAAAA,CAAY;EACjB,YAAY,OAAO,EAAE,SAAS,QAAQ,OAAO,+BAAiD;GAC5F,MAAM,iBAAiB,IAAIC,gBAAAA,eAAe;GAC1C,OAAO,QAAQ,4BAA4B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;IACvE,eAAe,IAAI,KAAK,KAAK;GAC/B,CAAC;GACD,OAAO,OAAO,SAAS,OAAO,CAAC,CAAC,YAAY,QAAQ;IAAE,MAAM;IAAO;GAAe,CAAC;EACrF;EACA,GAAG;CACL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMastraClient","useInfiniteQuery","skipToken","useMastraClient","useQuery","useMastraClient","useState","useRef","useMemo","useCallback","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useQueryClient","useMemo","useMutation","useMastraClient","useQuery","skipToken","useQueryClient","useMutation","useMastraClient","useState","useRef","useCallback","useMastraClient","useQueryClient","useMemo","useMutation","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useMutation","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useMutation","RequestContext"],"sources":["../../../src/hooks/agents/use-agent-messages.ts","../../../src/hooks/agents/use-agent-plan.ts","../../../src/hooks/agents/use-background-tasks.ts","../../../src/hooks/agents/use-browser-session-probe.ts","../../../src/hooks/agents/is-model-not-allowed.ts","../../../src/hooks/agents/use-stored-agents.ts","../../../src/hooks/agents/use-agent-skills.ts","../../../src/hooks/agents/use-agent-versions.ts","../../../src/hooks/agents/use-agent-working-memory.ts","../../../src/hooks/agents/use-agent-workspace.ts","../../../src/hooks/agents/use-agent.ts","../../../src/hooks/agents/use-agents-model-providers.ts","../../../src/hooks/agents/use-agents.ts","../../../src/hooks/agents/use-close-browser.ts","../../../src/hooks/agents/use-preview-instructions.ts","../../../src/hooks/agents/use-stored-skills.ts","../../../src/hooks/agents/use-channels.ts","../../../src/hooks/agents/use-execute-agent-tool.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { MastraDBMessage } from '@mastra/core/agent/message-list';\nimport { skipToken, useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions } from '../shared/query-options';\n\ntype AgentMessagesPage = Awaited<ReturnType<MastraClient['listThreadMessages']>>;\n\ntype AgentMessagesData = InfiniteData<AgentMessagesPage, string> & { messages: MastraDBMessage[] };\n\nexport interface UseAgentMessagesProps<TData = AgentMessagesData> {\n threadId?: string;\n agentId: string;\n memory: boolean;\n requestContext?: Record<string, any>;\n queryOptions?: MastraInfiniteQueryOptions<AgentMessagesPage, TData, QueryKey, string>;\n}\n\nconst PER_PAGE = 40;\n\nconst NEWEST_PAGE = '';\n\nconst createdAtMs = (message: MastraDBMessage) => new Date(message.createdAt).getTime();\n\nconst byCreatedAt = (a: MastraDBMessage, b: MastraDBMessage) => createdAtMs(a) - createdAtMs(b);\n\nexport const useAgentMessages = <TData = AgentMessagesData>({\n threadId,\n agentId,\n memory,\n requestContext,\n queryOptions,\n}: UseAgentMessagesProps<TData>) => {\n const client = useMastraClient();\n\n return useInfiniteQuery({\n queryKey: ['memory', 'messages', threadId, agentId, requestContext],\n initialPageParam: NEWEST_PAGE,\n queryFn:\n memory && threadId\n ? ({ pageParam: olderThan }) =>\n client.listThreadMessages(threadId, {\n agentId,\n requestContext,\n includeSystemReminders: true,\n perPage: PER_PAGE,\n orderBy: { field: 'createdAt', direction: 'DESC' },\n // Inclusive bound: messages sharing the oldest createdAt of the previous page\n // may have been cut off by perPage, so re-ask for them and dedupe by id below.\n filter: olderThan ? { dateRange: { end: new Date(olderThan) } } : undefined,\n })\n : skipToken,\n getNextPageParam: (lastPage, _allPages, lastPageParam) => {\n if (!lastPage.hasMore || lastPage.messages.length === 0) return undefined;\n const next = new Date(Math.min(...lastPage.messages.map(createdAtMs))).toISOString();\n // A full page of same-timestamp messages would re-request itself forever.\n return next === lastPageParam ? undefined : next;\n },\n select: (data): TData => {\n const seen = new Set<string>();\n const messages = data.pages\n .flatMap(page => page.messages)\n .filter(message => {\n if (seen.has(message.id)) return false;\n seen.add(message.id);\n return true;\n })\n .sort(byCreatedAt);\n return { ...data, messages } as AgentMessagesData as TData;\n },\n staleTime: 0,\n gcTime: 0,\n retry: false,\n refetchOnWindowFocus: false,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype AgentPlanResponse = Awaited<ReturnType<ReturnType<MastraClient['getAgent']>['readPlan']>>;\n\ninterface UseAgentPlanOptions<TData> {\n agentId: string;\n path: string;\n agentVersionId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<AgentPlanResponse, TData>;\n}\n\nexport function useAgentPlan<TData = AgentPlanResponse>({\n agentId,\n path,\n agentVersionId,\n requestContext,\n queryOptions,\n}: UseAgentPlanOptions<TData>): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['agent-plan', agentId, agentVersionId, path, requestContext],\n queryFn: () => {\n const agent = agentVersionId ? client.getAgent(agentId, { versionId: agentVersionId }) : client.getAgent(agentId);\n return agent.readPlan(path, requestContext);\n },\n retry: false,\n ...queryOptions,\n });\n}\n","import type { MastraClient, StreamBackgroundTasksParams } from '@mastra/client-js';\nimport type { BackgroundTaskStatus } from '@mastra/core/background-tasks';\nimport type { AgentChunkType } from '@mastra/core/stream';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype BackgroundTaskStreamReader = ReturnType<Awaited<ReturnType<MastraClient['streamBackgroundTasks']>>['getReader']>;\n\nexport interface BackgroundTaskEvent {\n taskId: string;\n toolName: string;\n toolCallId: string;\n agentId: string;\n runId: string;\n result?: unknown;\n error?: { message: string; stack?: string };\n status: BackgroundTaskStatus;\n args: Record<string, unknown>;\n suspendPayload?: unknown;\n}\n\nexport interface UseBackgroundTaskStreamOptions extends StreamBackgroundTasksParams {\n /** Whether the stream is active. Default: true */\n enabled?: boolean;\n}\n\nexport interface UseBackgroundTaskStreamReturn {\n /** Map of taskId → latest event data */\n tasks: Record<string, BackgroundTaskEvent>;\n /** Whether the stream is currently connected */\n isConnected: boolean;\n /** Any connection error */\n error: Error | null;\n /** Manually disconnect the stream */\n disconnect: () => void;\n /** Manually reconnect the stream */\n reconnect: () => void;\n /** List of running tasks */\n runningTasks: BackgroundTaskEvent[];\n /** List of completed tasks */\n completedTasks: BackgroundTaskEvent[];\n /** List of failed tasks */\n failedTasks: BackgroundTaskEvent[];\n /** Clear completed and failed tasks */\n clearCompletedAndFailedTasks: () => void;\n}\n\n/**\n * Streams background task events via SSE and accumulates them in a map keyed by taskId.\n *\n * Each incoming event (task.completed / task.failed) is stored in state so the UI\n * can react to completions — e.g., show a toast, update a badge, or display results.\n *\n * @example\n * ```tsx\n * const { tasks, isConnected, completedTasks } = useBackgroundTaskStream({ agentId: 'crypto-agent' });\n *\n * // Show a badge with completed count\n * const completedCount = completedTasks.length;\n * ```\n */\n\ntype EventType = Extract<\n AgentChunkType,\n {\n type:\n | 'background-task-running'\n | 'background-task-completed'\n | 'background-task-failed'\n | 'background-task-cancelled'\n | 'background-task-output'\n | 'background-task-suspended'\n | 'background-task-resumed';\n }\n>;\n\nconst EVENT_STATUS_MAP: Record<EventType['type'], BackgroundTaskStatus> = {\n 'background-task-running': 'running',\n 'background-task-output': 'running',\n 'background-task-completed': 'completed',\n 'background-task-failed': 'failed',\n 'background-task-cancelled': 'cancelled',\n 'background-task-suspended': 'suspended',\n 'background-task-resumed': 'running',\n};\n\nexport function useBackgroundTaskStream(options: UseBackgroundTaskStreamOptions = {}): UseBackgroundTaskStreamReturn {\n const { enabled = true, agentId, runId, threadId, resourceId, taskId } = options;\n const client = useMastraClient();\n\n const [tasks, setTasks] = useState<Record<string, BackgroundTaskEvent>>({});\n const [isConnected, setIsConnected] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const readerRef = useRef<BackgroundTaskStreamReader | null>(null);\n const connectSeqRef = useRef(0);\n\n const runningTasks = useMemo(() => {\n return Object.values(tasks).filter(task => task.status === 'running');\n }, [tasks]);\n\n const completedTasks = useMemo(() => {\n return Object.values(tasks).filter(task => task.status === 'completed');\n }, [tasks]);\n\n const failedTasks = useMemo(() => {\n return Object.values(tasks).filter(task => task.status === 'failed');\n }, [tasks]);\n\n const cleanup = useCallback(() => {\n readerRef.current?.cancel().catch(() => {});\n readerRef.current = null;\n abortRef.current?.abort();\n abortRef.current = null;\n setIsConnected(false);\n }, []);\n\n const connect = useCallback(async () => {\n const seq = ++connectSeqRef.current;\n cleanup();\n setError(null);\n\n const controller = new AbortController();\n abortRef.current = controller;\n\n try {\n const stream = await client.streamBackgroundTasks({ agentId, runId, threadId, resourceId, taskId });\n\n if (!stream) {\n setError(new Error('Stream connection failed'));\n return;\n }\n\n if (seq === connectSeqRef.current) {\n setIsConnected(true);\n }\n\n // Get a reader from the ReadableStream and store it in ref\n const reader = stream.getReader();\n readerRef.current = reader;\n\n while (!controller.signal.aborted) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const event = value as EventType;\n if (event.type !== 'background-task-output') {\n setTasks(prev => ({\n ...prev,\n [event.payload.taskId]: {\n ...prev[event.payload.taskId],\n ...event.payload,\n status: EVENT_STATUS_MAP[event.type],\n args:\n ('args' in event.payload ? event.payload.args : undefined) ?? prev[event.payload.taskId]?.args ?? {},\n },\n }));\n }\n }\n } catch (err: any) {\n if (err?.name !== 'AbortError') {\n if (seq === connectSeqRef.current) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n }\n } finally {\n if (seq === connectSeqRef.current) {\n setIsConnected(false);\n }\n }\n }, [client, agentId, runId, threadId, resourceId, taskId, cleanup]);\n\n useEffect(() => {\n if (!enabled) {\n cleanup();\n return;\n }\n\n void connect();\n return cleanup;\n }, [enabled, connect, cleanup]);\n\n const disconnect = useCallback(() => {\n cleanup();\n }, [cleanup]);\n\n const reconnect = useCallback(() => {\n void connect();\n }, [connect]);\n\n const clearCompletedAndFailedTasks = () => {\n setTasks(prev => {\n const newTasks = { ...prev };\n Object.values(newTasks).forEach(task => {\n if (\n task.status === 'completed' ||\n task.status === 'failed' ||\n task.status === 'cancelled' ||\n task.status === 'timed_out'\n ) {\n delete newTasks[task.taskId];\n }\n });\n return newTasks;\n });\n };\n\n return {\n tasks,\n isConnected,\n error,\n disconnect,\n reconnect,\n runningTasks,\n completedTasks,\n failedTasks,\n clearCompletedAndFailedTasks,\n };\n}\n\ntype BackgroundTaskResponse = Awaited<ReturnType<MastraClient['getBackgroundTask']>>;\n\nexport const useGetBackgroundTaskById = <TData = BackgroundTaskResponse>({\n backgroundTaskId,\n queryOptions,\n}: {\n backgroundTaskId: string;\n queryOptions?: MastraQueryOptions<BackgroundTaskResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['background-task', backgroundTaskId],\n queryFn: () => client.getBackgroundTask(backgroundTaskId),\n ...queryOptions,\n });\n};\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport interface BrowserSessionProbe {\n hasSession: boolean;\n screencastAvailable: boolean;\n}\n\ninterface UseBrowserSessionProbeOptions<TData> {\n agentId?: string;\n threadId?: string;\n /** TanStack overrides spread last, e.g. `{ enabled: false }` for agents without browser tools. */\n queryOptions?: MastraQueryOptions<BrowserSessionProbe, TData>;\n}\n\nexport const browserSessionProbeQueryKey = (agentId?: string, threadId?: string) =>\n ['browser-session-probe', agentId, threadId] as const;\n\nconst LEGACY_FALLBACK: BrowserSessionProbe = { hasSession: true, screencastAvailable: true };\n\nconst isNotFoundError = (error: unknown): boolean => {\n if (!error || typeof error !== 'object') return false;\n if ('status' in error && (error as { status: unknown }).status === 404) return true;\n if ('statusCode' in error && (error as { statusCode: unknown }).statusCode === 404) return true;\n return false;\n};\n\n/**\n * Query hook that probes the server for the agent's browser session state.\n *\n * Used by {@link BrowserSessionProvider} to decide whether to open a screencast\n * WebSocket. The probe avoids two failure modes:\n *\n * 1. `screencastAvailable: false` — the server doesn't have `ws` / `@hono/node-ws`\n * installed (or the route was never registered). Opening a WS would fail and\n * trigger a reconnect loop.\n * 2. `hasSession: false` — no active browser session for this thread yet. Opening\n * a WS would succeed but sit idle, holding resources for no reason.\n *\n * When the endpoint itself returns 404 (older server that predates this probe),\n * the hook assumes screencast is available and a session is active so behavior\n * matches the legacy unconditional connect.\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function useBrowserSessionProbe<TData = BrowserSessionProbe>({\n agentId,\n threadId,\n queryOptions,\n}: UseBrowserSessionProbeOptions<TData>): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery<BrowserSessionProbe, Error, TData>({\n queryKey: browserSessionProbeQueryKey(agentId, threadId),\n queryFn: async () => {\n if (!agentId) {\n return { hasSession: false, screencastAvailable: false };\n }\n\n try {\n return await client.getAgent(agentId).browserSession(threadId);\n } catch (error) {\n if (isNotFoundError(error)) {\n // Older server without the probe endpoint — fall back to legacy behavior.\n return LEGACY_FALLBACK;\n }\n throw error;\n }\n },\n // No polling: the probe fires once on mount, on window focus, and is\n // updated via `setQueriesData` from `tool-fallback.tsx` when a browser\n // tool call transitions. This avoids idle 5s polls and lets the probe\n // flip to `hasSession: true` the instant a tool call is seen.\n refetchOnWindowFocus: true,\n staleTime: 0,\n retry: 1,\n ...queryOptions,\n });\n}\n","/**\n * The wire-level error code the server emits on a 422 when a model is blocked\n * by the admin's builder policy. Kept as a local literal so the browser bundle\n * never imports server-only agent-builder EE code.\n */\nconst MODEL_NOT_ALLOWED_CODE = 'MODEL_NOT_ALLOWED';\n\nexport interface ModelNotAllowedDetails {\n message: string;\n attempted?: { provider?: string; modelId?: string };\n offendingLabel?: string;\n}\n\n/**\n * Detects HTTP 422 + MODEL_NOT_ALLOWED responses thrown by `MastraClientError`\n * (or any error carrying `status` + `body.error.code`). Returns the parsed\n * details when matched, or `null` otherwise.\n */\nexport function isModelNotAllowedError(err: unknown): ModelNotAllowedDetails | null {\n if (!err || typeof err !== 'object') return null;\n const candidate = err as { status?: number; body?: unknown; message?: string };\n if (candidate.status !== 422) return null;\n const body = candidate.body as { error?: { code?: unknown } } | undefined;\n const code = body?.error?.code;\n if (code !== MODEL_NOT_ALLOWED_CODE) return null;\n const errorBody = body!.error as {\n message?: string;\n attempted?: { provider?: string; modelId?: string };\n offendingLabel?: string;\n };\n return {\n message: errorBody.message || candidate.message || 'Model not allowed by admin policy',\n attempted: errorBody.attempted,\n offendingLabel: errorBody.offendingLabel,\n };\n}\n","import type {\n CreateStoredAgentParams,\n UpdateStoredAgentParams,\n ListStoredAgentsParams,\n StoredAgentResponse,\n ListStoredAgentsResponse,\n StoredAgentDependentsResponse,\n DeleteStoredAgentResponse,\n} from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\nimport { isModelNotAllowedError } from './is-model-not-allowed';\n\nexport const useStoredAgents = <TData = ListStoredAgentsResponse>({\n queryOptions,\n ...params\n}: ListStoredAgentsParams & {\n queryOptions?: MastraQueryOptions<ListStoredAgentsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n const listParams = Object.keys(params).length > 0 ? params : undefined;\n\n return useQuery({\n queryKey: ['stored-agents', listParams],\n queryFn: () => client.listStoredAgents(listParams),\n ...queryOptions,\n });\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredAgent = <TData = StoredAgentResponse | null>({\n agentId,\n status,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredAgentResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['stored-agent', agentId, status, requestContext],\n queryFn: async () => {\n if (!agentId) return null;\n try {\n return await client.getStoredAgent(agentId).details(requestContext, { status });\n } catch (error) {\n // 404 is expected for code-only agents that haven't been stored yet\n if (error && typeof error === 'object' && 'status' in error && (error as { status: number }).status === 404) {\n return null;\n }\n throw error;\n }\n },\n retry: false,\n ...queryOptions,\n });\n};\n\nexport type StoredAgent = StoredAgentResponse;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredAgentDependents = <TData = StoredAgentDependentsResponse>({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredAgentDependentsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['stored-agent-dependents', agentId, requestContext],\n queryFn: () => client.getStoredAgent(agentId!).dependents(requestContext),\n retry: false,\n ...queryOptions,\n });\n};\n\nexport const useStoredAgentMutations = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredAgent?: MastraMutationOptions<StoredAgentResponse, CreateStoredAgentParams>;\n updateStoredAgent?: MastraMutationOptions<StoredAgentResponse, UpdateStoredAgentParams>;\n deleteStoredAgent?: MastraMutationOptions<DeleteStoredAgentResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n // If the server rejects with HTTP 422 + MODEL_NOT_ALLOWED the admin policy\n // has likely changed under us — refresh the cached settings so the UI\n // re-renders against the latest server truth.\n const invalidateBuilderSettingsOnPolicyReject = (err: unknown) => {\n if (isModelNotAllowedError(err)) {\n void queryClient.invalidateQueries({ queryKey: ['builder-settings'] });\n }\n };\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredAgentParams) => client.createStoredAgent(params),\n onSuccess: created => {\n // Prime the per-agent details cache with the response so the next page\n // (the edit page) can render the agent on first paint without a refetch.\n // The starter relies on this to immediately mount the conversation panel\n // and dispatch the user's initial message.\n queryClient.setQueryData(['stored-agent', created.id, 'draft', requestContext], created);\n queryClient.setQueryData(['stored-agent', created.id, undefined, requestContext], created);\n // Invalidate both stored-agents list and the merged agents list\n void queryClient.invalidateQueries({ queryKey: ['stored-agents'] });\n void queryClient.invalidateQueries({ queryKey: ['agents'] });\n // Invalidate the merged agent details so the freshly-created id resolves\n // instead of staying stuck on the initial `null` from the 404 lookup.\n void queryClient.invalidateQueries({ queryKey: ['agent', created.id] });\n },\n onError: invalidateBuilderSettingsOnPolicyReject,\n ...queryOptions?.createStoredAgent,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredAgentParams) => {\n if (!agentId) throw new Error('agentId is required for update');\n return client.getStoredAgent(agentId).update(params, requestContext);\n },\n onSuccess: () => {\n // Invalidate lists\n void queryClient.invalidateQueries({ queryKey: ['stored-agents'] });\n void queryClient.invalidateQueries({ queryKey: ['agents'] });\n // Invalidate specific agent details\n if (agentId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n }\n },\n onError: invalidateBuilderSettingsOnPolicyReject,\n ...queryOptions?.updateStoredAgent,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!agentId) throw new Error('agentId is required for delete');\n return client.getStoredAgent(agentId).delete(requestContext);\n },\n onSuccess: () => {\n // Invalidate lists so the agents list page refetches without the deleted entry\n void queryClient.invalidateQueries({ queryKey: ['stored-agents'] });\n void queryClient.invalidateQueries({ queryKey: ['agents'] });\n // Drop the deleted entity from the cache so active observers don't refetch a 404\n if (agentId) {\n queryClient.removeQueries({ queryKey: ['stored-agent', agentId] });\n queryClient.removeQueries({ queryKey: ['agent', agentId] });\n }\n },\n ...queryOptions?.deleteStoredAgent,\n });\n\n return {\n createStoredAgent: createMutation,\n updateStoredAgent: updateMutation,\n deleteStoredAgent: deleteMutation,\n };\n};\n","import type { StoredAgentResponse, StoredAgentSkillConfig, UpdateStoredAgentParams } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\nimport { useStoredAgent } from './use-stored-agents';\n\n/**\n * Hook to read and mutate the skills config for a stored agent.\n *\n * The skills field is `Record<string, StoredAgentSkillConfig>` on the agent\n * snapshot. Each key is a stored skill ID and the value holds per-skill\n * overrides (description, instructions, pin, strategy).\n */\nexport function useAgentSkills({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n updateSkills?: MastraMutationOptions<StoredAgentResponse, Record<string, StoredAgentSkillConfig> | undefined>;\n };\n} = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const { data: agent } = useStoredAgent({ agentId, status: 'draft', queryOptions: { enabled: Boolean(agentId) } });\n\n const skills = useMemo((): Record<string, StoredAgentSkillConfig> => {\n if (!agent?.skills) return {};\n // Handle conditional field: if it's an array of variants, merge values\n if (Array.isArray(agent.skills)) {\n const merged: Record<string, StoredAgentSkillConfig> = {};\n for (const variant of agent.skills) {\n Object.assign(merged, variant.value);\n }\n return merged;\n }\n return agent.skills as Record<string, StoredAgentSkillConfig>;\n }, [agent?.skills]);\n\n const updateSkills = useMutation({\n mutationFn: (newSkills: Record<string, StoredAgentSkillConfig> | undefined) => {\n if (!agentId) throw new Error('agentId is required');\n const params: UpdateStoredAgentParams = { skills: newSkills };\n return client.getStoredAgent(agentId).update(params, requestContext);\n },\n onSuccess: () => {\n if (agentId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n }\n },\n ...queryOptions?.updateSkills,\n });\n\n return { skills, updateSkills };\n}\n","import type {\n ListAgentVersionsParams,\n CreateAgentVersionParams,\n ListAgentVersionsResponse,\n AgentVersionResponse,\n CompareVersionsResponse,\n ActivateAgentVersionResponse,\n DeleteAgentVersionResponse,\n} from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery, useMutation, useQueryClient, skipToken } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ListAgentVersionsParams, CreateAgentVersionParams };\n\ntype UseAgentVersionsParams<TData = ListAgentVersionsResponse> = {\n agentId?: string;\n params?: ListAgentVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListAgentVersionsResponse, TData>;\n};\n\n/**\n * Hook to list versions of a stored agent\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useAgentVersions = <TData = ListAgentVersionsResponse>({\n agentId,\n params,\n requestContext,\n queryOptions,\n}: UseAgentVersionsParams<TData>): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListAgentVersionsResponse, Error, TData>({\n queryKey: ['agent-versions', agentId, params, requestContext],\n queryFn: agentId ? () => client.getStoredAgent(agentId).listVersions(params, requestContext) : skipToken,\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored agent\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useAgentVersion = <TData = AgentVersionResponse>({\n agentId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<AgentVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<AgentVersionResponse, Error, TData>({\n queryKey: ['agent-version', agentId, versionId, requestContext],\n queryFn: () => client.getStoredAgent(agentId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored agent\n */\nexport const useCreateAgentVersion = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<AgentVersionResponse, CreateAgentVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<AgentVersionResponse, Error, CreateAgentVersionParams | undefined>({\n mutationFn: (params?: CreateAgentVersionParams) =>\n client.getStoredAgent(agentId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored agent\n */\nexport const useActivateAgentVersion = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivateAgentVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivateAgentVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredAgent(agentId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored agent (creates a new version from an old one)\n */\nexport const useRestoreAgentVersion = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<AgentVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<AgentVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredAgent(agentId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored agent\n */\nexport const useDeleteAgentVersion = ({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeleteAgentVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeleteAgentVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredAgent(agentId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to compare two versions of a stored agent\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useCompareAgentVersions = <TData = CompareVersionsResponse>({\n agentId,\n fromVersionId,\n toVersionId,\n requestContext,\n queryOptions,\n}: {\n agentId: string;\n fromVersionId: string;\n toVersionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<CompareVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<CompareVersionsResponse, Error, TData>({\n queryKey: ['agent-versions-compare', agentId, fromVersionId, toVersionId, requestContext],\n queryFn: () => client.getStoredAgent(agentId).compareVersions(fromVersionId, toVersionId, requestContext),\n ...queryOptions,\n });\n};\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\n\nfunction parseJsonString(jsonString: string): any {\n try {\n return JSON.stringify(JSON.parse(jsonString), null, 2);\n } catch {\n return jsonString;\n }\n}\n\nexport function useAgentWorkingMemory(\n agentId: string,\n threadId: string,\n resourceId: string,\n requestContext?: Record<string, any>,\n) {\n const client = useMastraClient();\n const [threadExists, setThreadExists] = useState(false);\n const [workingMemoryData, setWorkingMemoryData] = useState<string | null>(null);\n const [workingMemorySource, setWorkingMemorySource] = useState<'thread' | 'resource'>('thread');\n const [workingMemoryFormat, setWorkingMemoryFormat] = useState<'json' | 'markdown'>('markdown');\n const [isLoading, setIsLoading] = useState(true);\n const [isUpdating, setIsUpdating] = useState(false);\n const latestRequest = useRef(0);\n\n const refetch = useCallback(async () => {\n const requestId = ++latestRequest.current;\n setIsLoading(true);\n try {\n if (!agentId || !threadId) {\n setWorkingMemoryData(null);\n setIsLoading(false);\n return;\n }\n const res = await client.getWorkingMemory({ agentId, threadId, resourceId, requestContext });\n if (requestId !== latestRequest.current) return;\n const { workingMemory, source, workingMemoryTemplate, threadExists } = res as {\n workingMemory: string | null;\n source: 'thread' | 'resource';\n workingMemoryTemplate: { content: string; format: 'json' | 'markdown' };\n threadExists: boolean;\n };\n setThreadExists(threadExists);\n setWorkingMemoryData(workingMemory);\n setWorkingMemorySource(source);\n setWorkingMemoryFormat(workingMemoryTemplate?.format || 'markdown');\n if (workingMemoryTemplate?.format === 'json') {\n let dataToSet = '';\n if (workingMemory) {\n dataToSet = parseJsonString(workingMemory);\n } else if (workingMemoryTemplate?.content) {\n dataToSet = parseJsonString(workingMemoryTemplate.content);\n } else {\n dataToSet = '';\n }\n setWorkingMemoryData(dataToSet);\n } else {\n setWorkingMemoryData(workingMemory || workingMemoryTemplate?.content || '');\n }\n } catch (error) {\n if (requestId !== latestRequest.current) return;\n setWorkingMemoryData(null);\n console.error('Error fetching working memory', error);\n } finally {\n if (requestId === latestRequest.current) setIsLoading(false);\n }\n }, [agentId, threadId, resourceId, client, requestContext]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n const updateWorkingMemory = async (newMemory: string) => {\n setIsUpdating(true);\n try {\n if (workingMemoryFormat === 'json') {\n try {\n JSON.parse(newMemory);\n } catch {\n throw new Error('Invalid JSON working memory');\n }\n }\n await client.updateWorkingMemory({ agentId, threadId, workingMemory: newMemory, resourceId, requestContext });\n void refetch();\n } catch (error) {\n console.error('Error updating working memory', error);\n throw error;\n } finally {\n setIsUpdating(false);\n }\n };\n\n return {\n threadExists,\n workingMemoryData,\n workingMemorySource,\n workingMemoryFormat,\n isLoading,\n isUpdating,\n refetch,\n updateWorkingMemory,\n };\n}\n","import type { StoredAgentResponse, StoredWorkspaceRef, UpdateStoredAgentParams } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\nimport { useStoredAgent } from './use-stored-agents';\n\n/**\n * Hook to read and mutate the workspace reference for a stored agent.\n *\n * The workspace ref is part of the agent snapshot config and can be:\n * - `{ type: 'id', workspaceId }` — references a stored workspace by ID\n * - `{ type: 'inline', config }` — inline workspace config\n * - `undefined` — no workspace assigned\n */\nexport function useAgentWorkspace({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n updateWorkspace?: MastraMutationOptions<StoredAgentResponse, StoredWorkspaceRef | undefined>;\n };\n} = {}) {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const { data: agent } = useStoredAgent({ agentId, status: 'draft', queryOptions: { enabled: Boolean(agentId) } });\n\n const workspace = useMemo((): StoredWorkspaceRef | undefined => {\n if (!agent?.workspace) return undefined;\n // Handle conditional field: if it's an array of variants, take the first value\n if (Array.isArray(agent.workspace)) {\n return agent.workspace[0]?.value as StoredWorkspaceRef | undefined;\n }\n return agent.workspace as StoredWorkspaceRef;\n }, [agent?.workspace]);\n\n const updateWorkspace = useMutation({\n mutationFn: (ref: StoredWorkspaceRef | undefined) => {\n if (!agentId) throw new Error('agentId is required');\n const params: UpdateStoredAgentParams = { workspace: ref };\n return client.getStoredAgent(agentId).update(params, requestContext);\n },\n onSuccess: () => {\n if (agentId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n void queryClient.invalidateQueries({ queryKey: ['agent-versions', agentId] });\n }\n },\n ...queryOptions?.updateWorkspace,\n });\n\n return { workspace, updateWorkspace };\n}\n","import type { GetAgentResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useAgent = <TData = GetAgentResponse | null>({\n agentId,\n requestContext,\n queryOptions,\n}: {\n agentId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<GetAgentResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['agent', agentId, requestContext],\n queryFn: () => (agentId ? client.getAgent(agentId).details(requestContext) : null),\n retry: false,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype AgentsModelProvidersResponse = Awaited<ReturnType<MastraClient['listAgentsModelProviders']>>;\n\nexport const useAgentsModelProviders = <TData = AgentsModelProvidersResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<AgentsModelProvidersResponse, TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['agents-model-providers'],\n queryFn: () => client.listAgentsModelProviders(),\n retry: false,\n ...queryOptions,\n });\n};\n","import type {\n MastraClient,\n ReorderModelListParams,\n UpdateModelInModelListParams,\n UpdateModelParams,\n} from '@mastra/client-js';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport type { UseMutationResult, UseQueryResult } from '@tanstack/react-query';\n\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\ntype Agent = ReturnType<MastraClient['getAgent']>;\ntype ListAgentsResponse = Awaited<ReturnType<MastraClient['listAgents']>>;\nexport type ModelUpdateResponse = Awaited<ReturnType<Agent['updateModel']>>;\n\nexport const useAgents = <TData = ListAgentsResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListAgentsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['agents', requestContext],\n queryFn: () => client.listAgents(requestContext),\n ...queryOptions,\n });\n};\n\nexport const useUpdateAgentModel = ({\n agentId,\n queryOptions,\n}: {\n agentId: string;\n queryOptions?: MastraMutationOptions<ModelUpdateResponse, UpdateModelParams>;\n}): UseMutationResult<ModelUpdateResponse, Error, UpdateModelParams> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (payload: UpdateModelParams) => client.getAgent(agentId).updateModel(payload),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n onError: err => {\n console.error('Error updating model', err);\n },\n ...queryOptions,\n });\n};\n\nexport const useReorderModelList = ({\n agentId,\n queryOptions,\n}: {\n agentId: string;\n queryOptions?: MastraMutationOptions<ModelUpdateResponse, ReorderModelListParams>;\n}): UseMutationResult<ModelUpdateResponse, Error, ReorderModelListParams> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (payload: ReorderModelListParams) => client.getAgent(agentId).reorderModelList(payload),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n onError: err => {\n console.error('Error reordering model list', err);\n },\n ...queryOptions,\n });\n};\n\nexport const useUpdateModelInModelList = ({\n agentId,\n queryOptions,\n}: {\n agentId: string;\n queryOptions?: MastraMutationOptions<ModelUpdateResponse, UpdateModelInModelListParams>;\n}): UseMutationResult<ModelUpdateResponse, Error, UpdateModelInModelListParams> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (payload: UpdateModelInModelListParams) =>\n client.getAgent(agentId).updateModelInModelList(payload),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n onError: err => {\n console.error('Error updating model in model list', err);\n },\n ...queryOptions,\n });\n};\n\nexport const useResetAgentModel = ({\n agentId,\n queryOptions,\n}: {\n agentId: string;\n queryOptions?: MastraMutationOptions<ModelUpdateResponse, void>;\n}): UseMutationResult<ModelUpdateResponse, Error, void> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async () => client.getAgent(agentId).resetModel(),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['agent', agentId] });\n },\n onError: err => {\n console.error('Error resetting model', err);\n },\n ...queryOptions,\n });\n};\n","import { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ninterface CloseBrowserParams {\n agentId: string;\n threadId?: string;\n}\n\n/**\n * Mutation hook for closing an agent's browser session.\n */\nexport function useCloseBrowser({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<{ success: boolean }, CloseBrowserParams> } = {}) {\n const client = useMastraClient();\n\n return useMutation<{ success: boolean }, Error, CloseBrowserParams>({\n mutationFn: ({ agentId, threadId }) => client.getAgent(agentId).closeBrowser(threadId),\n onError: err => {\n console.error('[useCloseBrowser] Error closing browser:', err);\n },\n ...queryOptions,\n });\n}\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ninterface ApiInstructionBlock {\n type: string;\n content?: string;\n id?: string;\n /** Form-format ref blocks use `promptBlockId` instead of `id` */\n promptBlockId?: string;\n rules?: unknown;\n}\n\n/**\n * Normalize blocks to API format.\n * Form-format ref blocks have `{ type: 'prompt_block_ref', promptBlockId }`,\n * while API-format blocks have `{ type: 'prompt_block_ref', id }`.\n */\nfunction toApiBlocks(blocks: ApiInstructionBlock[]) {\n return blocks.map(block => {\n if (block.type === 'prompt_block_ref') {\n // Form-format blocks have `promptBlockId` (the storage ID) and `id` (form-internal UUID).\n // API-format blocks have `id` (the storage ID). Prefer promptBlockId when present.\n return { type: 'prompt_block_ref' as const, id: block.promptBlockId ?? block.id, rules: block.rules };\n }\n return { type: block.type, content: block.content, rules: block.rules };\n });\n}\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function usePreviewInstructions<TData = string>({\n blocks,\n requestContext,\n queryOptions,\n}: {\n blocks: ApiInstructionBlock[] | undefined;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<string, TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['preview-instructions', blocks, requestContext],\n queryFn: async () => {\n if (!blocks || blocks.length === 0) return '';\n\n const response = await client.request<{ result: string }>('/stored/agents/preview-instructions', {\n method: 'POST',\n body: { blocks: toApiBlocks(blocks), context: requestContext },\n });\n\n return response.result;\n },\n ...queryOptions,\n });\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\n\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport type ListStoredSkillsResponse = Awaited<ReturnType<MastraClient['listStoredSkills']>>;\n\nexport function useStoredSkills<TData = ListStoredSkillsResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ListStoredSkillsResponse, TData> } = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['stored-skills'],\n queryFn: () => client.listStoredSkills(),\n ...queryOptions,\n });\n}\n","import type { ChannelPlatformInfo, ChannelInstallationInfo, ChannelConnectResult } from '@mastra/client-js';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport type { UseMutationResult, UseQueryResult } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ChannelPlatformInfo, ChannelInstallationInfo, ChannelConnectResult };\n\nexport const useChannelPlatforms = <TData = ChannelPlatformInfo[]>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ChannelPlatformInfo[], TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ChannelPlatformInfo[], Error, TData>({\n queryKey: ['channels', 'platforms'],\n queryFn: () => client.channels.listPlatforms(),\n staleTime: 60 * 1000,\n retry: false,\n ...queryOptions,\n });\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useChannelInstallations = <TData = ChannelInstallationInfo[]>({\n platform,\n agentId,\n queryOptions,\n}: {\n platform: string;\n agentId: string;\n queryOptions?: MastraQueryOptions<ChannelInstallationInfo[], TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ChannelInstallationInfo[], Error, TData>({\n queryKey: ['channels', 'installations', platform, agentId],\n queryFn: () => client.channels.listInstallations(platform, agentId),\n staleTime: 10 * 1000,\n retry: false,\n ...queryOptions,\n });\n};\n\n/**\n * Reconcile an agent's installation with platform state — activates a pending\n * installation whose connect flow completed out-of-band (e.g. a Discord bot\n * invite finished in another tab). Resolves null on platforms without\n * reconciliation. Call it deliberately (e.g. on window focus while a connect\n * is in flight) — it is a write, not a read.\n */\nexport const useReconcileChannelInstallation = ({\n platform,\n queryOptions,\n}: {\n platform: string;\n queryOptions?: MastraMutationOptions<ChannelInstallationInfo | null, string>;\n}): UseMutationResult<ChannelInstallationInfo | null, Error, string> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ChannelInstallationInfo | null, Error, string>({\n mutationFn: agentId => client.channels.reconcileInstallation(platform, agentId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['channels', 'installations', platform] });\n },\n ...queryOptions,\n });\n};\n\nexport const useConnectChannel = ({\n platform,\n queryOptions,\n}: {\n platform: string;\n queryOptions?: MastraMutationOptions<ChannelConnectResult, { agentId: string; options?: Record<string, unknown> }>;\n}): UseMutationResult<ChannelConnectResult, Error, { agentId: string; options?: Record<string, unknown> }> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ChannelConnectResult, Error, { agentId: string; options?: Record<string, unknown> }>({\n mutationFn: ({ agentId, options }) =>\n client.channels.connect(platform, agentId, {\n ...options,\n // Tell the server to redirect back here after OAuth\n redirectUrl: window.location.href,\n }),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['channels', 'installations', platform] });\n },\n ...queryOptions,\n });\n};\n\nexport const useDisconnectChannel = ({\n platform,\n queryOptions,\n}: {\n platform: string;\n queryOptions?: MastraMutationOptions<{ success: boolean }, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<{ success: boolean }, Error, string>({\n mutationFn: agentId => client.channels.disconnect(platform, agentId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['channels', 'installations', platform] });\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { RequestContext } from '@mastra/core/di';\nimport { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ntype ExecuteAgentToolResponse = Awaited<ReturnType<ReturnType<MastraClient['getAgent']>['executeTool']>>;\n\nexport interface ExecuteToolInput {\n agentId: string;\n toolId: string;\n input: any;\n playgroundRequestContext?: Record<string, any>;\n}\n\nexport const useExecuteAgentTool = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<ExecuteAgentToolResponse, ExecuteToolInput> } = {}) => {\n const client = useMastraClient();\n return useMutation({\n mutationFn: async ({ agentId, toolId, input, playgroundRequestContext }: ExecuteToolInput) => {\n const requestContext = new RequestContext();\n Object.entries(playgroundRequestContext ?? {}).forEach(([key, value]) => {\n requestContext.set(key, value);\n });\n return client.getAgent(agentId).executeTool(toolId, { data: input, requestContext });\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;AAmBA,MAAM,WAAW;AAEjB,MAAM,cAAc;AAEpB,MAAM,eAAe,YAA6B,IAAI,KAAK,QAAQ,SAAS,CAAC,CAAC,QAAQ;AAEtF,MAAM,eAAe,GAAoB,MAAuB,YAAY,CAAC,IAAI,YAAY,CAAC;AAE9F,MAAa,oBAA+C,EAC1D,UACA,SACA,QACA,gBACA,mBACkC;CAClC,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,iBAAAA,CAAiB;EACtB,UAAU;GAAC;GAAU;GAAY;GAAU;GAAS;EAAc;EAClE,kBAAkB;EAClB,SACE,UAAU,YACL,EAAE,WAAW,gBACZ,OAAO,mBAAmB,UAAU;GAClC;GACA;GACA,wBAAwB;GACxB,SAAS;GACT,SAAS;IAAE,OAAO;IAAa,WAAW;GAAO;GAGjD,QAAQ,YAAY,EAAE,WAAW,EAAE,KAAK,IAAI,KAAK,SAAS,EAAE,EAAE,IAAI,KAAA;EACpE,CAAC,IACHC,sBAAAA;EACN,mBAAmB,UAAU,WAAW,kBAAkB;GACxD,IAAI,CAAC,SAAS,WAAW,SAAS,SAAS,WAAW,GAAG,OAAO,KA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