@mastra/react 1.12.0 → 1.13.0-alpha.1
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-CgLQ_3q3.cjs → accumulator-BmD8-x9I.cjs} +52 -3
- package/dist/accumulator-BmD8-x9I.cjs.map +1 -0
- package/dist/{accumulator-BfvVnXJr.js → accumulator-D9jAph99.js} +52 -3
- package/dist/accumulator-D9jAph99.js.map +1 -0
- package/dist/agent/hooks.d.ts +1 -1
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/hooks/capabilities/index.cjs +42 -0
- package/dist/hooks/capabilities/index.cjs.map +1 -1
- package/dist/hooks/capabilities/index.d.ts +3 -0
- package/dist/hooks/capabilities/index.d.ts.map +1 -1
- package/dist/hooks/capabilities/index.js +40 -1
- package/dist/hooks/capabilities/index.js.map +1 -1
- package/dist/hooks/capabilities/use-span-aggregate-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-span-aggregate-available.d.ts.map +1 -0
- package/dist/hooks/capabilities/use-span-query-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-span-query-available.d.ts.map +1 -0
- package/dist/hooks/capabilities/use-thread-query-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-thread-query-available.d.ts.map +1 -0
- package/dist/hooks/templates/index.cjs.map +1 -1
- package/dist/hooks/templates/index.js.map +1 -1
- package/dist/hooks/templates/use-templates.d.ts.map +1 -1
- package/dist/hooks/traces/index.cjs +109 -1
- package/dist/hooks/traces/index.cjs.map +1 -1
- package/dist/hooks/traces/index.d.ts +2 -0
- package/dist/hooks/traces/index.d.ts.map +1 -1
- package/dist/hooks/traces/index.js +106 -2
- package/dist/hooks/traces/index.js.map +1 -1
- package/dist/hooks/traces/use-query-spans.d.ts +27 -0
- package/dist/hooks/traces/use-query-spans.d.ts.map +1 -0
- package/dist/hooks/traces/use-query-threads.d.ts +30 -0
- package/dist/hooks/traces/use-query-threads.d.ts.map +1 -0
- package/dist/hooks/traces/use-traces.d.ts +37 -37
- package/dist/hooks/workflows/index.cjs +1 -1
- package/dist/hooks/workflows/index.js +1 -1
- package/dist/{hooks-B1i-oHae.cjs → hooks-BbUMSab8.cjs} +29 -6
- package/dist/{hooks-B1i-oHae.cjs.map → hooks-BbUMSab8.cjs.map} +1 -1
- package/dist/{hooks-CLfMO5cH.js → hooks-BfysjY_K.js} +29 -6
- package/dist/{hooks-CLfMO5cH.js.map → hooks-BfysjY_K.js.map} +1 -1
- package/dist/{hooks-NaZLZreZ.js → hooks-DG-Y1KFe.js} +2 -2
- package/dist/{hooks-NaZLZreZ.js.map → hooks-DG-Y1KFe.js.map} +1 -1
- package/dist/{hooks-D8nOYPUd.cjs → hooks-XYsmqFCz.cjs} +2 -2
- package/dist/{hooks-D8nOYPUd.cjs.map → hooks-XYsmqFCz.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/lib/mastra-db/accumulator.d.ts +0 -6
- package/dist/lib/mastra-db/accumulator.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/accumulator-BfvVnXJr.js.map +0 -1
- package/dist/accumulator-CgLQ_3q3.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-query-threads.d.ts","sourceRoot":"","sources":["../../../src/hooks/traces/use-query-threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG1E,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAC/D,KAAK,iBAAiB,GAAG,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;AACrE,MAAM,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,0BAA0B,CAAC,iBAAiB,EAAE,SAAS,EAAE,EAAE,SAAS,OAAO,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACnH;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,yFAAyF;IACzF,mBAAmB,EAAE,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAID,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,KAA6B,EAC7B,OAAc,EACd,YAAY,GACb,EAAE,mBAAmB,GAAG,qBAAqB,CA+C7C"}
|
|
@@ -58,6 +58,43 @@ type FetchTracesFnArgs = TracesFilters & {
|
|
|
58
58
|
perPage: number;
|
|
59
59
|
});
|
|
60
60
|
declare const fetchTracesFn: (args: FetchTracesFnArgs) => Promise<{
|
|
61
|
+
pagination?: {
|
|
62
|
+
total: number;
|
|
63
|
+
page: number;
|
|
64
|
+
perPage: number | false;
|
|
65
|
+
hasMore: boolean;
|
|
66
|
+
} | undefined;
|
|
67
|
+
delta?: {
|
|
68
|
+
limit: number;
|
|
69
|
+
hasMore: boolean;
|
|
70
|
+
} | undefined;
|
|
71
|
+
deltaCursor?: string | undefined;
|
|
72
|
+
spans: {
|
|
73
|
+
traceId: string;
|
|
74
|
+
spanId: string;
|
|
75
|
+
name: string;
|
|
76
|
+
spanType: "agent_run" | "agent_signal" | "classifier_evaluation" | "client_tool_call" | "generic" | "graph_action" | "mapping" | "mcp_server_request" | "mcp_tool_call" | "memory_operation" | "model_chunk" | "model_generation" | "model_inference" | "model_step" | "processor_run" | "provider_tool_call" | "rag_action" | "rag_embedding" | "rag_ingestion" | "rag_vector_operation" | "scorer_run" | "scorer_step" | "skill_action" | "skill_resolution" | "tool_call" | "workflow_conditional" | "workflow_conditional_eval" | "workflow_loop" | "workflow_parallel" | "workflow_run" | "workflow_sleep" | "workflow_step" | "workflow_wait_event" | "workspace_action";
|
|
77
|
+
isEvent: boolean;
|
|
78
|
+
startedAt: string;
|
|
79
|
+
parentSpanId?: (string | null) | undefined;
|
|
80
|
+
endedAt?: string | null | undefined;
|
|
81
|
+
error?: (unknown | null) | undefined;
|
|
82
|
+
status?: (('success' | 'error' | 'running') | null) | undefined;
|
|
83
|
+
entityType?: (("agent" | "classifier" | "input_processor" | "input_step_processor" | "mcp_server" | "memory" | "output_processor" | "output_step_processor" | "rag_ingestion" | "scorer" | "tool" | "tool_result_processor" | "trajectory" | "workflow_run" | "workflow_step") | null) | undefined;
|
|
84
|
+
entityId?: (string | null) | undefined;
|
|
85
|
+
entityName?: (string | null) | undefined;
|
|
86
|
+
threadId?: ((string | null) | undefined) | null;
|
|
87
|
+
resourceId?: ((string | null) | undefined) | null;
|
|
88
|
+
metadata?: ({
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
} | null) | undefined;
|
|
91
|
+
inputPreview?: (string | null) | undefined;
|
|
92
|
+
outputPreview?: (string | null) | undefined;
|
|
93
|
+
errorPreview?: (string | null) | undefined;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
updatedAt: string | null;
|
|
96
|
+
}[];
|
|
97
|
+
} | {
|
|
61
98
|
pagination?: {
|
|
62
99
|
total: number;
|
|
63
100
|
page: number;
|
|
@@ -126,43 +163,6 @@ declare const fetchTracesFn: (args: FetchTracesFnArgs) => Promise<{
|
|
|
126
163
|
updatedAt: string | null;
|
|
127
164
|
status: 'success' | 'error' | 'running';
|
|
128
165
|
}[];
|
|
129
|
-
} | {
|
|
130
|
-
pagination?: {
|
|
131
|
-
total: number;
|
|
132
|
-
page: number;
|
|
133
|
-
perPage: number | false;
|
|
134
|
-
hasMore: boolean;
|
|
135
|
-
} | undefined;
|
|
136
|
-
delta?: {
|
|
137
|
-
limit: number;
|
|
138
|
-
hasMore: boolean;
|
|
139
|
-
} | undefined;
|
|
140
|
-
deltaCursor?: string | undefined;
|
|
141
|
-
spans: {
|
|
142
|
-
traceId: string;
|
|
143
|
-
spanId: string;
|
|
144
|
-
name: string;
|
|
145
|
-
spanType: "agent_run" | "agent_signal" | "classifier_evaluation" | "client_tool_call" | "generic" | "graph_action" | "mapping" | "mcp_server_request" | "mcp_tool_call" | "memory_operation" | "model_chunk" | "model_generation" | "model_inference" | "model_step" | "processor_run" | "provider_tool_call" | "rag_action" | "rag_embedding" | "rag_ingestion" | "rag_vector_operation" | "scorer_run" | "scorer_step" | "skill_action" | "skill_resolution" | "tool_call" | "workflow_conditional" | "workflow_conditional_eval" | "workflow_loop" | "workflow_parallel" | "workflow_run" | "workflow_sleep" | "workflow_step" | "workflow_wait_event" | "workspace_action";
|
|
146
|
-
isEvent: boolean;
|
|
147
|
-
startedAt: string;
|
|
148
|
-
parentSpanId?: (string | null) | undefined;
|
|
149
|
-
endedAt?: string | null | undefined;
|
|
150
|
-
error?: (unknown | null) | undefined;
|
|
151
|
-
status?: (('success' | 'error' | 'running') | null) | undefined;
|
|
152
|
-
entityType?: (("agent" | "classifier" | "input_processor" | "input_step_processor" | "mcp_server" | "memory" | "output_processor" | "output_step_processor" | "rag_ingestion" | "scorer" | "tool" | "tool_result_processor" | "trajectory" | "workflow_run" | "workflow_step") | null) | undefined;
|
|
153
|
-
entityId?: (string | null) | undefined;
|
|
154
|
-
entityName?: (string | null) | undefined;
|
|
155
|
-
threadId?: ((string | null) | undefined) | null;
|
|
156
|
-
resourceId?: ((string | null) | undefined) | null;
|
|
157
|
-
metadata?: ({
|
|
158
|
-
[key: string]: unknown;
|
|
159
|
-
} | null) | undefined;
|
|
160
|
-
inputPreview?: (string | null) | undefined;
|
|
161
|
-
outputPreview?: (string | null) | undefined;
|
|
162
|
-
errorPreview?: (string | null) | undefined;
|
|
163
|
-
createdAt: string;
|
|
164
|
-
updatedAt: string | null;
|
|
165
|
-
}[];
|
|
166
166
|
}>;
|
|
167
167
|
export declare const TRACES_PER_PAGE = 25;
|
|
168
168
|
export interface TracesFilters {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_mastra_client_context = require("../../mastra-client-context-DzX3f0RF.cjs");
|
|
3
|
-
const require_hooks = require("../../hooks-
|
|
3
|
+
const require_hooks = require("../../hooks-XYsmqFCz.cjs");
|
|
4
4
|
const require_use_in_view = require("../../use-in-view-B6eJO9Zi.cjs");
|
|
5
5
|
let _mastra_client_js = require("@mastra/client-js");
|
|
6
6
|
let react = require("react");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as useMastraClient } from "../../mastra-client-context-Bx_g84YB.js";
|
|
2
|
-
import { n as useCreateWorkflowRun, r as useStreamWorkflow, t as useCancelWorkflowRun } from "../../hooks-
|
|
2
|
+
import { n as useCreateWorkflowRun, r as useStreamWorkflow, t as useCancelWorkflowRun } from "../../hooks-DG-Y1KFe.js";
|
|
3
3
|
import { t as useInView } from "../../use-in-view-C9sYPGRm.js";
|
|
4
4
|
import { MastraClientError } from "@mastra/client-js";
|
|
5
5
|
import { useEffect } from "react";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_mastra_client_context = require("./mastra-client-context-DzX3f0RF.cjs");
|
|
2
|
-
const require_accumulator = require("./accumulator-
|
|
2
|
+
const require_accumulator = require("./accumulator-BmD8-x9I.cjs");
|
|
3
3
|
let _mastra_client_js = require("@mastra/client-js");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let _lukeed_uuid = require("@lukeed/uuid");
|
|
@@ -789,6 +789,7 @@ const useChat = ({ agentId, resourceId, threadId, initialMessages, requestContex
|
|
|
789
789
|
}).getAgent(agentId, void 0, { stream: streamPath });
|
|
790
790
|
const streamWithLegacyRoute = async () => {
|
|
791
791
|
const runId = (0, _lukeed_uuid.v4)();
|
|
792
|
+
_currentRunId.current = runId;
|
|
792
793
|
const response = await agent.stream(coreUserMessages, {
|
|
793
794
|
model,
|
|
794
795
|
runId,
|
|
@@ -960,12 +961,33 @@ const useChat = ({ agentId, resourceId, threadId, initialMessages, requestContex
|
|
|
960
961
|
setIsRunning(false);
|
|
961
962
|
};
|
|
962
963
|
const handleCancelRun = () => {
|
|
963
|
-
|
|
964
|
-
|
|
964
|
+
const runId = _currentRunId.current;
|
|
965
|
+
const agent = baseClient?.getAgent(agentId);
|
|
965
966
|
const threadSubscription = _threadSubscriptionRef.current;
|
|
966
|
-
|
|
967
|
-
|
|
967
|
+
const streamAbort = _streamAbortRef.current;
|
|
968
|
+
const cancellationAbort = new AbortController();
|
|
969
|
+
const timeout = setTimeout(() => cancellationAbort.abort(/* @__PURE__ */ new Error("Agent run cancellation was not acknowledged")), 1e4);
|
|
970
|
+
const cancellation = (async () => {
|
|
971
|
+
if (agent && runId) while (true) {
|
|
972
|
+
cancellationAbort.signal.throwIfAborted();
|
|
973
|
+
const options = { signal: cancellationAbort.signal };
|
|
974
|
+
if ((threadId ? await agent.abortThread({
|
|
975
|
+
threadId,
|
|
976
|
+
resourceId: resourceId || agentId,
|
|
977
|
+
expectedRunId: runId
|
|
978
|
+
}, options) : await agent.abortRun(runId, options)).aborted) return;
|
|
979
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
980
|
+
}
|
|
981
|
+
await threadSubscription?.abort?.();
|
|
982
|
+
})().catch((error) => {
|
|
983
|
+
if (isObject(error) && (error.status === 404 || error.status === 501)) return;
|
|
984
|
+
throw error;
|
|
985
|
+
}).finally(() => {
|
|
986
|
+
clearTimeout(timeout);
|
|
987
|
+
streamAbort?.abort();
|
|
988
|
+
if (_streamAbortRef.current === streamAbort) _streamAbortRef.current = null;
|
|
968
989
|
});
|
|
990
|
+
cancellation.catch((error) => console.error("[useChat] Failed to abort agent run", error));
|
|
969
991
|
closeThreadSubscription();
|
|
970
992
|
setMessages((prev) => require_accumulator.finishStreamingAssistantMessage(prev));
|
|
971
993
|
liveRunFinished.current = true;
|
|
@@ -977,6 +999,7 @@ const useChat = ({ agentId, resourceId, threadId, initialMessages, requestContex
|
|
|
977
999
|
_networkRunId.current = void 0;
|
|
978
1000
|
_onNetworkChunk.current = void 0;
|
|
979
1001
|
_activeContinuation.current = {};
|
|
1002
|
+
return cancellation;
|
|
980
1003
|
};
|
|
981
1004
|
const approveToolCall = async (toolCallId, resumeData) => {
|
|
982
1005
|
const onChunk = _onChunk.current;
|
|
@@ -1283,4 +1306,4 @@ Object.defineProperty(exports, "useChat", {
|
|
|
1283
1306
|
}
|
|
1284
1307
|
});
|
|
1285
1308
|
|
|
1286
|
-
//# sourceMappingURL=hooks-
|
|
1309
|
+
//# sourceMappingURL=hooks-BbUMSab8.cjs.map
|