@athenaintel/react 0.10.41-rc.2 → 0.10.41
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/index.cjs +79 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +79 -37
- package/dist/index.js.map +1 -1
- package/dist/provider/AthenaContext.d.ts +3 -3
- package/dist/provider/AthenaProvider.d.ts +4 -2
- package/dist/provider/config.d.ts +6 -0
- package/dist/runtime/transport.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export { DEFAULT_STATEWIRE_MODEL, useAthenaStatewireRuntime, } from './runtime/u
|
|
|
82
82
|
export type { AthenaStatewireRuntimeConfig } from './runtime/useAthenaStatewireRuntime';
|
|
83
83
|
export { buildStatewireRunConfig } from './runtime/statewire-run-config';
|
|
84
84
|
export type { StatewireRunConfigOptions } from './runtime/statewire-run-config';
|
|
85
|
-
export { ATHENA_TRANSPORTS, DEFAULT_ATHENA_TRANSPORT, resolveAthenaTransport, } from './runtime/transport';
|
|
85
|
+
export { allowsMidRunSend, ATHENA_TRANSPORTS, DEFAULT_ATHENA_TRANSPORT, resolveAthenaTransport, } from './runtime/transport';
|
|
86
86
|
export type { AthenaTransport, ResolvedAthenaTransport } from './runtime/transport';
|
|
87
87
|
export { useParentAuth, useParentBridge } from './runtime/auth';
|
|
88
88
|
export type { ParentBridgeState } from './runtime/auth';
|
package/dist/index.js
CHANGED
|
@@ -11354,7 +11354,9 @@ function athenaStatewireErrorNotice(error2) {
|
|
|
11354
11354
|
return {
|
|
11355
11355
|
kind: "command",
|
|
11356
11356
|
title: "Message was not sent",
|
|
11357
|
-
|
|
11357
|
+
// The server's own detail names the actionable reason; the Error message is
|
|
11358
|
+
// generic client-side text like `command rejected (500)`.
|
|
11359
|
+
message: readDetailMessage(rejection == null ? void 0 : rejection.detail) ?? (error2 instanceof Error && error2.message.length > 0 ? error2.message : "The chat runtime rejected the command. Please try again.")
|
|
11358
11360
|
};
|
|
11359
11361
|
}
|
|
11360
11362
|
const AthenaStatewireLifecycleContext = createContext(null);
|
|
@@ -11382,6 +11384,20 @@ function StatewireClientToolBridge({
|
|
|
11382
11384
|
const toolsRef = useRef(tools);
|
|
11383
11385
|
toolsRef.current = tools;
|
|
11384
11386
|
const pendingRequest = inputRequests == null ? void 0 : inputRequests.find(isPendingClientToolRequest);
|
|
11387
|
+
const ownedClaimsRef = useRef(/* @__PURE__ */ new Set());
|
|
11388
|
+
const activeRef = useRef(true);
|
|
11389
|
+
const releaseClaim = useCallback((claim) => {
|
|
11390
|
+
ownedClaimsRef.current.delete(claim);
|
|
11391
|
+
clientToolRequests.release(claim);
|
|
11392
|
+
}, []);
|
|
11393
|
+
useEffect(() => {
|
|
11394
|
+
activeRef.current = true;
|
|
11395
|
+
return () => {
|
|
11396
|
+
activeRef.current = false;
|
|
11397
|
+
for (const claim of ownedClaimsRef.current) clientToolRequests.release(claim);
|
|
11398
|
+
ownedClaimsRef.current.clear();
|
|
11399
|
+
};
|
|
11400
|
+
}, []);
|
|
11385
11401
|
const liveRequestIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
11386
11402
|
liveRequestIdsRef.current = new Set((inputRequests ?? []).map((request) => request.id));
|
|
11387
11403
|
const executeRequest = useCallback(
|
|
@@ -11392,8 +11408,8 @@ function StatewireClientToolBridge({
|
|
|
11392
11408
|
const registry2 = new Map(toolsRef.current.map((tool) => [tool.name, tool]));
|
|
11393
11409
|
const results = {};
|
|
11394
11410
|
for (const call of calls) {
|
|
11395
|
-
if (!liveRequestIdsRef.current.has(request.id)) {
|
|
11396
|
-
|
|
11411
|
+
if (!activeRef.current || !liveRequestIdsRef.current.has(request.id)) {
|
|
11412
|
+
releaseClaim(requestKey(threadId, request.id));
|
|
11397
11413
|
return;
|
|
11398
11414
|
}
|
|
11399
11415
|
const tool = registry2.get(call.tool_name);
|
|
@@ -11415,8 +11431,8 @@ function StatewireClientToolBridge({
|
|
|
11415
11431
|
results[call.interrupt_id] = clientToolErrorEnvelope(error2);
|
|
11416
11432
|
}
|
|
11417
11433
|
}
|
|
11418
|
-
if (!liveRequestIdsRef.current.has(request.id)) {
|
|
11419
|
-
|
|
11434
|
+
if (!activeRef.current || !liveRequestIdsRef.current.has(request.id)) {
|
|
11435
|
+
releaseClaim(requestKey(threadId, request.id));
|
|
11420
11436
|
return;
|
|
11421
11437
|
}
|
|
11422
11438
|
try {
|
|
@@ -11426,16 +11442,19 @@ function StatewireClientToolBridge({
|
|
|
11426
11442
|
requestId: request.id,
|
|
11427
11443
|
response: { type: "resume", value: wireValue }
|
|
11428
11444
|
});
|
|
11445
|
+
ownedClaimsRef.current.delete(requestKey(threadId, request.id));
|
|
11429
11446
|
} catch (error2) {
|
|
11430
|
-
|
|
11447
|
+
releaseClaim(requestKey(threadId, request.id));
|
|
11431
11448
|
console.error("[AthenaSDK] failed to resume client tool results:", error2);
|
|
11432
11449
|
}
|
|
11433
11450
|
},
|
|
11434
|
-
[sendCommand, threadId]
|
|
11451
|
+
[releaseClaim, sendCommand, threadId]
|
|
11435
11452
|
);
|
|
11436
11453
|
useEffect(() => {
|
|
11437
11454
|
if (!pendingRequest) return;
|
|
11438
|
-
|
|
11455
|
+
const claim = requestKey(threadId, pendingRequest.id);
|
|
11456
|
+
if (!clientToolRequests.claim(claim)) return;
|
|
11457
|
+
ownedClaimsRef.current.add(claim);
|
|
11439
11458
|
void executeRequest(pendingRequest);
|
|
11440
11459
|
}, [executeRequest, pendingRequest, threadId]);
|
|
11441
11460
|
return null;
|
|
@@ -11450,6 +11469,9 @@ function resolveAthenaTransport({
|
|
|
11450
11469
|
}) {
|
|
11451
11470
|
return { transport: transport ?? DEFAULT_ATHENA_TRANSPORT, fallbackReason: null };
|
|
11452
11471
|
}
|
|
11472
|
+
function allowsMidRunSend(transport) {
|
|
11473
|
+
return transport === ATHENA_TRANSPORTS.statewire;
|
|
11474
|
+
}
|
|
11453
11475
|
var __defProp$i = Object.defineProperty;
|
|
11454
11476
|
var __name$h = (target, value) => __defProp$i(target, "name", { value, configurable: true });
|
|
11455
11477
|
function setRef$1(ref, value) {
|
|
@@ -18785,16 +18807,19 @@ function StatewireThreadListState({
|
|
|
18785
18807
|
initialThreadId,
|
|
18786
18808
|
children
|
|
18787
18809
|
}) {
|
|
18810
|
+
var _a3;
|
|
18788
18811
|
const [active, setActive] = useState(
|
|
18789
18812
|
() => initialThreadId ? { id: initialThreadId, isNew: false } : { id: mintThreadId(), isNew: true }
|
|
18790
18813
|
);
|
|
18791
18814
|
const tokenRef = useRef(token);
|
|
18792
18815
|
tokenRef.current = token;
|
|
18816
|
+
const authContext = useContext(AthenaAuthContext);
|
|
18817
|
+
const principal = ((_a3 = authContext == null ? void 0 : authContext.user) == null ? void 0 : _a3.userId) ?? "";
|
|
18793
18818
|
const hasAuth = !!(apiKey || token);
|
|
18794
18819
|
const { data, isLoading, refetch } = useQuery({
|
|
18795
|
-
|
|
18796
|
-
//
|
|
18797
|
-
|
|
18820
|
+
queryKey: [THREADS_QUERY_KEY, backendUrl, appId ?? "", principal, hasAuth],
|
|
18821
|
+
// Never serve another principal's list while the new one loads.
|
|
18822
|
+
placeholderData: void 0,
|
|
18798
18823
|
queryFn: async () => {
|
|
18799
18824
|
const { threads } = await listThreads(
|
|
18800
18825
|
backendUrl,
|
|
@@ -18812,6 +18837,7 @@ function StatewireThreadListState({
|
|
|
18812
18837
|
void refetch();
|
|
18813
18838
|
}, [refetch]);
|
|
18814
18839
|
const selectThread = useCallback((threadId) => {
|
|
18840
|
+
if (!threadId) return;
|
|
18815
18841
|
setActive(
|
|
18816
18842
|
(current) => current.id === threadId ? current : { id: threadId, isNew: false }
|
|
18817
18843
|
);
|
|
@@ -18819,6 +18845,12 @@ function StatewireThreadListState({
|
|
|
18819
18845
|
const newThread = useCallback(() => {
|
|
18820
18846
|
setActive({ id: mintThreadId(), isNew: true });
|
|
18821
18847
|
}, []);
|
|
18848
|
+
const isPersisted = !!(data == null ? void 0 : data.some((thread) => thread.id === active.id));
|
|
18849
|
+
useEffect(() => {
|
|
18850
|
+
if (isPersisted) {
|
|
18851
|
+
setActive((current) => current.isNew ? { ...current, isNew: false } : current);
|
|
18852
|
+
}
|
|
18853
|
+
}, [isPersisted]);
|
|
18822
18854
|
const value = useMemo(
|
|
18823
18855
|
() => ({
|
|
18824
18856
|
threads: data ?? [],
|
|
@@ -18988,8 +19020,6 @@ function useAthenaThreadManager() {
|
|
|
18988
19020
|
const statewireManager = useMemo(() => {
|
|
18989
19021
|
if (!statewireList) return null;
|
|
18990
19022
|
return {
|
|
18991
|
-
// A never-started local chat stays out of the URL, mirroring the
|
|
18992
|
-
// legacy manager's local-placeholder handling.
|
|
18993
19023
|
activeThreadId: statewireList.isNewChat ? null : statewireList.activeThreadId,
|
|
18994
19024
|
isListLoading: statewireList.isLoading,
|
|
18995
19025
|
isThreadLoading: statewireIsThreadLoading,
|
|
@@ -19819,9 +19849,16 @@ const initialStatewireLifecycle = {
|
|
|
19819
19849
|
reconnect: null
|
|
19820
19850
|
};
|
|
19821
19851
|
function statewireLifecycleReducer(state, action) {
|
|
19852
|
+
var _a3, _b2;
|
|
19822
19853
|
switch (action.type) {
|
|
19823
|
-
case "connection":
|
|
19824
|
-
|
|
19854
|
+
case "connection": {
|
|
19855
|
+
const healthy = ((_a3 = action.connection) == null ? void 0 : _a3.status) === "live" || ((_b2 = action.connection) == null ? void 0 : _b2.status) === "idle";
|
|
19856
|
+
return {
|
|
19857
|
+
...state,
|
|
19858
|
+
connection: action.connection,
|
|
19859
|
+
error: healthy ? null : state.error
|
|
19860
|
+
};
|
|
19861
|
+
}
|
|
19825
19862
|
case "error":
|
|
19826
19863
|
return { ...state, error: action.error };
|
|
19827
19864
|
case "legacy-read-only":
|
|
@@ -20187,6 +20224,8 @@ function AthenaProvider({
|
|
|
20187
20224
|
const configuredAppUrl = (config2 == null ? void 0 : config2.appUrl) ?? appUrl;
|
|
20188
20225
|
const configuredTransport = (config2 == null ? void 0 : config2.transport) ?? transport;
|
|
20189
20226
|
const configuredStatewireSyncUrl = (config2 == null ? void 0 : config2.statewireSyncUrl) ?? statewireSyncUrl;
|
|
20227
|
+
const configuredGetToken = (config2 == null ? void 0 : config2.getToken) ?? getToken;
|
|
20228
|
+
const configuredExtraRunConfig = (config2 == null ? void 0 : config2.extraRunConfig) ?? extraRunConfig;
|
|
20190
20229
|
const configuredTrustedParentOrigins = config2 == null ? void 0 : config2.trustedParentOrigins;
|
|
20191
20230
|
const posthogConfig = (config2 == null ? void 0 : config2.posthog) ?? posthogProp;
|
|
20192
20231
|
const { transport: effectiveTransport, fallbackReason: transportFallbackReason } = resolveAthenaTransport({
|
|
@@ -20221,7 +20260,7 @@ function AthenaProvider({
|
|
|
20221
20260
|
appUrl: effectiveAppUrl,
|
|
20222
20261
|
apiKey: configuredApiKey,
|
|
20223
20262
|
token: effectiveToken,
|
|
20224
|
-
getToken,
|
|
20263
|
+
getToken: configuredGetToken,
|
|
20225
20264
|
model,
|
|
20226
20265
|
tools,
|
|
20227
20266
|
frontendToolIds: frontendToolNames,
|
|
@@ -20231,7 +20270,7 @@ function AthenaProvider({
|
|
|
20231
20270
|
systemPrompt,
|
|
20232
20271
|
customToolConfigs,
|
|
20233
20272
|
appId,
|
|
20234
|
-
extraRunConfig,
|
|
20273
|
+
extraRunConfig: configuredExtraRunConfig,
|
|
20235
20274
|
linkClicks,
|
|
20236
20275
|
citationLinks
|
|
20237
20276
|
};
|
|
@@ -55284,7 +55323,7 @@ const TiptapComposer = ({ tools = [], rootCategories }) => {
|
|
|
55284
55323
|
const isUploadingRef = useRef(isUploading);
|
|
55285
55324
|
isUploadingRef.current = isUploading;
|
|
55286
55325
|
const isRunningThread = useAuiState((s) => s.thread.isRunning);
|
|
55287
|
-
const isThreadRunning = transport
|
|
55326
|
+
const isThreadRunning = allowsMidRunSend(transport) ? false : isRunningThread;
|
|
55288
55327
|
const isThreadRunningRef = useRef(isThreadRunning);
|
|
55289
55328
|
isThreadRunningRef.current = isThreadRunning;
|
|
55290
55329
|
const handleSubmit = useCallback(() => {
|
|
@@ -55306,10 +55345,8 @@ const TiptapComposer = ({ tools = [], rootCategories }) => {
|
|
|
55306
55345
|
appUrl
|
|
55307
55346
|
});
|
|
55308
55347
|
if (fullMessage) {
|
|
55309
|
-
aui.
|
|
55310
|
-
|
|
55311
|
-
content: [{ type: "text", text: fullMessage }]
|
|
55312
|
-
});
|
|
55348
|
+
aui.composer.setText(fullMessage);
|
|
55349
|
+
aui.composer.send();
|
|
55313
55350
|
clearAttachments();
|
|
55314
55351
|
clearQuote();
|
|
55315
55352
|
}
|
|
@@ -55558,14 +55595,20 @@ const StatewireApprovalCardInner = () => {
|
|
|
55558
55595
|
}
|
|
55559
55596
|
const isRunning = useAuiState((s) => s.thread.isRunning);
|
|
55560
55597
|
const sawResumeRunRef = useRef(false);
|
|
55561
|
-
|
|
55562
|
-
|
|
55563
|
-
|
|
55564
|
-
|
|
55565
|
-
|
|
55566
|
-
|
|
55567
|
-
|
|
55568
|
-
|
|
55598
|
+
useEffect(() => {
|
|
55599
|
+
if (!pending) {
|
|
55600
|
+
sawResumeRunRef.current = false;
|
|
55601
|
+
return;
|
|
55602
|
+
}
|
|
55603
|
+
if (isRunning) {
|
|
55604
|
+
sawResumeRunRef.current = true;
|
|
55605
|
+
return;
|
|
55606
|
+
}
|
|
55607
|
+
if (sawResumeRunRef.current) {
|
|
55608
|
+
sawResumeRunRef.current = false;
|
|
55609
|
+
setPending(false);
|
|
55610
|
+
}
|
|
55611
|
+
}, [pending, isRunning]);
|
|
55569
55612
|
useEffect(() => {
|
|
55570
55613
|
if (!pending) return;
|
|
55571
55614
|
const timer = setTimeout(() => {
|
|
@@ -55856,7 +55899,7 @@ const StatewireLegacyReadOnlyBanner = () => {
|
|
|
55856
55899
|
/* @__PURE__ */ jsx(Archive, { className: "mt-0.5 size-4 shrink-0" }),
|
|
55857
55900
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
55858
55901
|
/* @__PURE__ */ jsx("p", { className: "font-semibold text-xs", children: "Read-only conversation" }),
|
|
55859
|
-
/* @__PURE__ */ jsx("p", { className: "pt-0.5 text-xs leading-snug text-amber-800", children: "
|
|
55902
|
+
/* @__PURE__ */ jsx("p", { className: "pt-0.5 text-xs leading-snug text-amber-800", children: "This conversation’s history remains available, but new messages cannot be added. Start a new chat to continue." })
|
|
55860
55903
|
] })
|
|
55861
55904
|
] });
|
|
55862
55905
|
};
|
|
@@ -61095,7 +61138,7 @@ const ThreadScrollToBottom = () => /* @__PURE__ */ jsx(ThreadPrimitive.ScrollToB
|
|
|
61095
61138
|
) });
|
|
61096
61139
|
const ComposerAction = () => {
|
|
61097
61140
|
const { transport } = useAthenaConfig();
|
|
61098
|
-
const queuesWhileRunning = transport
|
|
61141
|
+
const queuesWhileRunning = allowsMidRunSend(transport);
|
|
61099
61142
|
return /* @__PURE__ */ jsxs("div", { className: "aui-composer-action-wrapper relative mx-2 mb-2 flex items-center justify-between", children: [
|
|
61100
61143
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsx(FileUploadButton, {}) }),
|
|
61101
61144
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
@@ -61122,7 +61165,7 @@ const ComposerSendWithQuote = () => {
|
|
|
61122
61165
|
const editorRef = useComposerEditorRef();
|
|
61123
61166
|
const editorEmpty = useComposerEditorEmpty();
|
|
61124
61167
|
const isRunningThread = useAuiState((s) => s.thread.isRunning);
|
|
61125
|
-
const isThreadRunning = transport
|
|
61168
|
+
const isThreadRunning = allowsMidRunSend(transport) ? false : isRunningThread;
|
|
61126
61169
|
const hasExtras = !!quote || attachments.length > 0;
|
|
61127
61170
|
const handleSend = useCallback(() => {
|
|
61128
61171
|
var _a3;
|
|
@@ -61138,10 +61181,8 @@ const ComposerSendWithQuote = () => {
|
|
|
61138
61181
|
appUrl
|
|
61139
61182
|
});
|
|
61140
61183
|
if (!fullMessage) return;
|
|
61141
|
-
aui.
|
|
61142
|
-
|
|
61143
|
-
content: [{ type: "text", text: fullMessage }]
|
|
61144
|
-
});
|
|
61184
|
+
aui.composer.setText(fullMessage);
|
|
61185
|
+
aui.composer.send();
|
|
61145
61186
|
clearQuote();
|
|
61146
61187
|
clearAttachments();
|
|
61147
61188
|
} else {
|
|
@@ -62448,6 +62489,7 @@ export {
|
|
|
62448
62489
|
TooltipTrigger,
|
|
62449
62490
|
UpdateSheetRangeToolUI,
|
|
62450
62491
|
WebSearchToolUI,
|
|
62492
|
+
allowsMidRunSend,
|
|
62451
62493
|
archiveThread,
|
|
62452
62494
|
asHitlApproval,
|
|
62453
62495
|
athenaStatewireErrorNotice,
|