@athenaintel/react 0.21.0 → 0.21.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/README.md +13 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +6 -6
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +6 -6
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-index.cjs +19 -10
- package/dist/packages/agent-runtime/src/conversation-index.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-index.js +19 -10
- package/dist/packages/agent-runtime/src/conversation-index.js.map +1 -1
- package/dist/packages/react/package.json.cjs +1 -1
- package/dist/packages/react/package.json.js +1 -1
- package/dist/threads/api.cjs +29 -0
- package/dist/threads/api.cjs.map +1 -1
- package/dist/threads/api.d.ts +15 -0
- package/dist/threads/api.js +29 -0
- package/dist/threads/api.js.map +1 -1
- package/dist/threads/credential-shape.cjs +15 -0
- package/dist/threads/credential-shape.cjs.map +1 -0
- package/dist/threads/credential-shape.d.ts +17 -0
- package/dist/threads/credential-shape.js +15 -0
- package/dist/threads/credential-shape.js.map +1 -0
- package/dist/threads/statewire-thread-list.cjs +35 -3
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.js +36 -4
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +3 -1
- package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +3 -1
- package/dist/threads/use-statewire-conversation-history.js +3 -1
- package/dist/threads/use-statewire-conversation-history.js.map +1 -1
- package/dist/toolkits/index.cjs +0 -7
- package/dist/toolkits/index.cjs.map +1 -1
- package/dist/toolkits/index.d.ts +0 -2
- package/dist/toolkits/index.js +0 -7
- package/dist/toolkits/index.js.map +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/voice/use-athena-voice-session.cjs.map +1 -1
- package/dist/voice/use-athena-voice-session.d.ts +37 -2
- package/dist/voice/use-athena-voice-session.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,6 +3,8 @@ import { type RestConversationAuth } from "./use-rest-conversation-history";
|
|
|
3
3
|
export interface UseStatewireConversationHistoryOptions {
|
|
4
4
|
backendUrl: string;
|
|
5
5
|
conversationIndexBaseUrl: string;
|
|
6
|
+
/** The workspace being viewed; the index is one instance per (workspace, user). */
|
|
7
|
+
workspaceId: string;
|
|
6
8
|
principalId: string;
|
|
7
9
|
getAuth: () => RestConversationAuth | Promise<RestConversationAuth>;
|
|
8
10
|
headers: UseConversationIndexOptions["headers"];
|
|
@@ -31,7 +33,7 @@ export declare function shouldUseRestConversationHistory({ hasSearch, indexEntri
|
|
|
31
33
|
* that same channel. A non-empty search deliberately uses the authorized REST
|
|
32
34
|
* list endpoint so matches are not limited to the replicated newest window.
|
|
33
35
|
*/
|
|
34
|
-
export declare function useStatewireConversationHistory({ backendUrl, conversationIndexBaseUrl, principalId, getAuth, headers, search, enabled, sse, }: UseStatewireConversationHistoryOptions): {
|
|
36
|
+
export declare function useStatewireConversationHistory({ backendUrl, conversationIndexBaseUrl, workspaceId, principalId, getAuth, headers, search, enabled, sse, }: UseStatewireConversationHistoryOptions): {
|
|
35
37
|
conversations: {
|
|
36
38
|
threadId: string;
|
|
37
39
|
title: string;
|
|
@@ -68,6 +68,7 @@ function shouldUseRestConversationHistory({
|
|
|
68
68
|
function useStatewireConversationHistory({
|
|
69
69
|
backendUrl,
|
|
70
70
|
conversationIndexBaseUrl,
|
|
71
|
+
workspaceId,
|
|
71
72
|
principalId,
|
|
72
73
|
getAuth,
|
|
73
74
|
headers,
|
|
@@ -77,9 +78,10 @@ function useStatewireConversationHistory({
|
|
|
77
78
|
}) {
|
|
78
79
|
const index = useConversationIndex({
|
|
79
80
|
baseUrl: conversationIndexBaseUrl,
|
|
81
|
+
workspaceId: workspaceId || "pending-workspace",
|
|
80
82
|
userId: principalId || "pending-user",
|
|
81
83
|
headers,
|
|
82
|
-
enabled: enabled && principalId.length > 0,
|
|
84
|
+
enabled: enabled && workspaceId.length > 0 && principalId.length > 0,
|
|
83
85
|
sse
|
|
84
86
|
});
|
|
85
87
|
const supportsStatewirePaging = index.totalCount !== null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-statewire-conversation-history.js","sources":["../../src/threads/use-statewire-conversation-history.ts"],"sourcesContent":["import {\n\ttype ConversationIndexEntry,\n\ttype ConversationSummary,\n\ttype UseConversationIndexOptions,\n\tuseConversationIndex,\n} from \"@athenaintel/agent-runtime\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { archiveThread, setThreadReadState } from \"./api\";\nimport {\n\ttype RestConversationAuth,\n\tuseRestConversationHistory,\n} from \"./use-rest-conversation-history\";\n\nexport interface UseStatewireConversationHistoryOptions {\n\tbackendUrl: string;\n\tconversationIndexBaseUrl: string;\n\tprincipalId: string;\n\tgetAuth: () => RestConversationAuth | Promise<RestConversationAuth>;\n\theaders: UseConversationIndexOptions[\"headers\"];\n\tsearch?: string;\n\tenabled?: boolean;\n\tsse?: boolean;\n}\n\n/** Convert the replicated wire row into the shared cross-surface contract. */\nexport function conversationSummaryFromIndexEntry(\n\tentry: ConversationIndexEntry,\n): ConversationSummary {\n\treturn {\n\t\tthreadId: entry.thread_id,\n\t\ttitle: entry.title,\n\t\tupdatedAt: entry.updated_at,\n\t\tcreatedAt: null,\n\t\tstate: entry.state,\n\t\truntime: entry.runtime,\n\t\tsourceChannel: entry.start_channel,\n\t\tassetType: entry.asset_type,\n\t\tassetId: entry.asset_id ?? null,\n\t\tappId: entry.app_id ?? null,\n\t\ttriggerType: entry.trigger_type ?? null,\n\t\tpreview: entry.last_message_preview ?? null,\n\t\tmessageCount: entry.message_count ?? null,\n\t\tisUnread: entry.is_unread ?? false,\n\t\tsessionStatus: entry.session_status ?? null,\n\t\trunStatus: entry.run_status ?? null,\n\t};\n}\n\nexport function conversationHistorySource({\n\tindexEntries,\n\trestConversations,\n\tsupportsStatewirePaging,\n\thasSearch,\n}: {\n\tindexEntries: readonly ConversationIndexEntry[] | null;\n\trestConversations: readonly ConversationSummary[];\n\tsupportsStatewirePaging: boolean;\n\thasSearch: boolean;\n}): ConversationSummary[] {\n\t// Search is server-backed so it covers the user's entire authorized history,\n\t// including rows older than the Statewire live window. An empty query uses\n\t// Statewire as the render source; REST only supplements rolling old hosts.\n\tif (hasSearch) return [...restConversations];\n\tconst statewireItems = (indexEntries ?? []).map(\n\t\tconversationSummaryFromIndexEntry,\n\t);\n\tif (supportsStatewirePaging) return statewireItems;\n\tconst statewireIds = new Set(statewireItems.map((item) => item.threadId));\n\treturn [\n\t\t...statewireItems,\n\t\t...restConversations.filter(\n\t\t\t(conversation) => !statewireIds.has(conversation.threadId),\n\t\t),\n\t];\n}\n\nexport function shouldUseRestConversationHistory({\n\thasSearch,\n\tindexEntries,\n\tsupportsStatewirePaging,\n\tconnectionStatus,\n}: {\n\thasSearch: boolean;\n\tindexEntries: readonly ConversationIndexEntry[] | null;\n\tsupportsStatewirePaging: boolean;\n\tconnectionStatus: string;\n}): boolean {\n\tif (hasSearch) return true;\n\tif (supportsStatewirePaging) return false;\n\t// An old host is identifiable once its snapshot arrives. A transport that\n\t// fails or is parked before any snapshot also needs the independent REST\n\t// path; otherwise entries stays null and the history panel loads forever.\n\treturn (\n\t\tindexEntries !== null ||\n\t\tconnectionStatus === \"reconnecting\" ||\n\t\tconnectionStatus === \"gone\"\n\t);\n}\n\n/**\n * Inclusive satellite conversation history backed by the user's Pinned\n * Statewire instance. The replicated window is the render source; refreshes,\n * pagination, thread creation, lifecycle changes, and title changes arrive on\n * that same channel. A non-empty search deliberately uses the authorized REST\n * list endpoint so matches are not limited to the replicated newest window.\n */\nexport function useStatewireConversationHistory({\n\tbackendUrl,\n\tconversationIndexBaseUrl,\n\tprincipalId,\n\tgetAuth,\n\theaders,\n\tsearch,\n\tenabled = true,\n\tsse = false,\n}: UseStatewireConversationHistoryOptions) {\n\tconst index = useConversationIndex({\n\t\tbaseUrl: conversationIndexBaseUrl,\n\t\tuserId: principalId || \"pending-user\",\n\t\theaders,\n\t\tenabled: enabled && principalId.length > 0,\n\t\tsse,\n\t});\n\t// Rolling deploy compatibility: the pre-paging index snapshot has no\n\t// total_count. It still renders live rows immediately, while the old REST\n\t// pager remains available only until the upgraded host activates.\n\tconst supportsStatewirePaging = index.totalCount !== null;\n\tconst normalizedSearch = search?.trim().toLowerCase() ?? \"\";\n\tconst hasSearch = normalizedSearch.length > 0;\n\tconst usesRestHistory = shouldUseRestConversationHistory({\n\t\thasSearch,\n\t\tindexEntries: index.entries,\n\t\tsupportsStatewirePaging,\n\t\tconnectionStatus: index.connection.status,\n\t});\n\tconst legacyHistory = useRestConversationHistory({\n\t\tbackendUrl,\n\t\tprincipalId,\n\t\tgetAuth,\n\t\tsearch,\n\t\tenabled: enabled && principalId.length > 0 && usesRestHistory,\n\t});\n\tconst [readOverrides, setReadOverrides] = useState<Record<string, boolean>>(\n\t\t{},\n\t);\n\tconst [archivedThreadIds, setArchivedThreadIds] = useState<\n\t\tReadonlySet<string>\n\t>(() => new Set());\n\n\tuseEffect(() => {\n\t\tif (index.entries === null || archivedThreadIds.size === 0) return;\n\t\tconst visibleIds = new Set(index.entries.map((entry) => entry.thread_id));\n\t\tsetArchivedThreadIds((current) => {\n\t\t\tconst next = new Set(\n\t\t\t\t[...current].filter((threadId) => visibleIds.has(threadId)),\n\t\t\t);\n\t\t\treturn next.size === current.size ? current : next;\n\t\t});\n\t}, [archivedThreadIds.size, index.entries]);\n\n\tconst conversations = useMemo(() => {\n\t\treturn conversationHistorySource({\n\t\t\tindexEntries: index.entries,\n\t\t\trestConversations: legacyHistory.conversations,\n\t\t\tsupportsStatewirePaging,\n\t\t\thasSearch,\n\t\t})\n\t\t\t.filter((conversation) => !archivedThreadIds.has(conversation.threadId))\n\t\t\t.map((conversation) => ({\n\t\t\t\t...conversation,\n\t\t\t\tisUnread: readOverrides[conversation.threadId] ?? conversation.isUnread,\n\t\t\t}));\n\t}, [\n\t\tarchivedThreadIds,\n\t\tindex.entries,\n\t\tlegacyHistory.conversations,\n\t\thasSearch,\n\t\treadOverrides,\n\t\tsupportsStatewirePaging,\n\t]);\n\n\tconst refreshMutation = useMutation({\n\t\tmutationKey: [\n\t\t\t\"conversation-index\",\n\t\t\t\"refresh\",\n\t\t\tconversationIndexBaseUrl,\n\t\t\tprincipalId,\n\t\t],\n\t\tmutationFn: () =>\n\t\t\tusesRestHistory ? legacyHistory.refresh() : index.refresh(),\n\t});\n\tconst loadMoreMutation = useMutation({\n\t\tmutationKey: [\n\t\t\t\"conversation-index\",\n\t\t\t\"load-more\",\n\t\t\tconversationIndexBaseUrl,\n\t\t\tprincipalId,\n\t\t],\n\t\tmutationFn: () =>\n\t\t\tusesRestHistory ? legacyHistory.fetchNextPage() : index.loadMore(),\n\t});\n\tconst archive = useMutation({\n\t\tmutationKey: [\"conversation-history\", \"archive\", backendUrl, principalId],\n\t\tmutationFn: async (threadId: string) => {\n\t\t\tawait archiveThread(backendUrl, await getAuth(), threadId);\n\t\t\treturn threadId;\n\t\t},\n\t\tonMutate: (threadId) => {\n\t\t\tsetArchivedThreadIds((current) => new Set(current).add(threadId));\n\t\t},\n\t\tonError: (_error, threadId) => {\n\t\t\tsetArchivedThreadIds((current) => {\n\t\t\t\tconst next = new Set(current);\n\t\t\t\tnext.delete(threadId);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\tonSuccess: () => {\n\t\t\trefreshMutation.mutate();\n\t\t},\n\t});\n\tconst readState = useMutation({\n\t\tmutationKey: [\n\t\t\t\"conversation-history\",\n\t\t\t\"read-state\",\n\t\t\tbackendUrl,\n\t\t\tprincipalId,\n\t\t],\n\t\tmutationFn: async ({\n\t\t\tthreadId,\n\t\t\tisUnread,\n\t\t}: {\n\t\t\tthreadId: string;\n\t\t\tisUnread: boolean;\n\t\t}) =>\n\t\t\tsetThreadReadState(backendUrl, await getAuth(), { threadId, isUnread }),\n\t\tonMutate: ({ threadId, isUnread }) => {\n\t\t\tconst previous = readOverrides[threadId];\n\t\t\tsetReadOverrides((current) => ({ ...current, [threadId]: isUnread }));\n\t\t\treturn { previous, threadId };\n\t\t},\n\t\tonError: (_error, _variables, context) => {\n\t\t\tif (!context) return;\n\t\t\tsetReadOverrides((current) => {\n\t\t\t\tconst next = { ...current };\n\t\t\t\tif (context.previous === undefined) delete next[context.threadId];\n\t\t\t\telse next[context.threadId] = context.previous;\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\tonSuccess: (result) => {\n\t\t\tsetReadOverrides((current) => ({\n\t\t\t\t...current,\n\t\t\t\t[result.thread_id]: result.is_unread,\n\t\t\t}));\n\t\t\trefreshMutation.mutate(undefined, {\n\t\t\t\tonSettled: () => {\n\t\t\t\t\tsetReadOverrides((current) => {\n\t\t\t\t\t\tconst next = { ...current };\n\t\t\t\t\t\tdelete next[result.thread_id];\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t});\n\n\tconst refresh = useCallback(\n\t\t() => refreshMutation.mutateAsync(),\n\t\t[refreshMutation.mutateAsync],\n\t);\n\tconst fetchNextPage = useCallback(\n\t\t() => loadMoreMutation.mutateAsync(),\n\t\t[loadMoreMutation.mutateAsync],\n\t);\n\n\treturn {\n\t\tconversations,\n\t\ttotalCount: usesRestHistory ? legacyHistory.totalCount : index.totalCount,\n\t\tisLoading:\n\t\t\tenabled &&\n\t\t\t(usesRestHistory\n\t\t\t\t? !legacyHistory.hasResolvedFirstPage\n\t\t\t\t: index.entries === null),\n\t\tisFetching:\n\t\t\trefreshMutation.isPending ||\n\t\t\tloadMoreMutation.isPending ||\n\t\t\tlegacyHistory.isFetching,\n\t\tisRefreshing: refreshMutation.isPending,\n\t\thasResolvedFirstPage: usesRestHistory\n\t\t\t? legacyHistory.hasResolvedFirstPage\n\t\t\t: index.entries !== null,\n\t\thasNextPage: usesRestHistory\n\t\t\t? legacyHistory.hasNextPage\n\t\t\t: index.hasNextPage,\n\t\tisFetchingNextPage: loadMoreMutation.isPending,\n\t\tfetchNextPage,\n\t\trefresh,\n\t\tarchiveConversation: archive.mutate,\n\t\tarchivePending: archive.isPending,\n\t\tsetConversationReadState: readState.mutate,\n\t\treadStatePending: readState.isPending,\n\t\tconnection: index.connection,\n\t};\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA0BO,SAAS,kCACf,OACsB;AACtB,SAAO;AAAA,IACN,UAAU,MAAM;AAAA,IAChB,OAAO,MAAM;AAAA,IACb,WAAW,MAAM;AAAA,IACjB,WAAW;AAAA,IACX,OAAO,MAAM;AAAA,IACb,SAAS,MAAM;AAAA,IACf,eAAe,MAAM;AAAA,IACrB,WAAW,MAAM;AAAA,IACjB,SAAS,MAAM,YAAY;AAAA,IAC3B,OAAO,MAAM,UAAU;AAAA,IACvB,aAAa,MAAM,gBAAgB;AAAA,IACnC,SAAS,MAAM,wBAAwB;AAAA,IACvC,cAAc,MAAM,iBAAiB;AAAA,IACrC,UAAU,MAAM,aAAa;AAAA,IAC7B,eAAe,MAAM,kBAAkB;AAAA,IACvC,WAAW,MAAM,cAAc;AAAA,EAAA;AAEjC;AAEO,SAAS,0BAA0B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAK0B;AAIzB,MAAI,UAAW,QAAO,CAAC,GAAG,iBAAiB;AAC3C,QAAM,kBAAkB,gBAAgB,CAAA,GAAI;AAAA,IAC3C;AAAA,EAAA;AAED,MAAI,wBAAyB,QAAO;AACpC,QAAM,eAAe,IAAI,IAAI,eAAe,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC;AACxE,SAAO;AAAA,IACN,GAAG;AAAA,IACH,GAAG,kBAAkB;AAAA,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A;AAClB,mBAAO,KAAK,OAAO,SAAS;AAC5B,mBAAO;AAAA,UACR,CAAC;AAAA,QACF;AAAA,MAAA,CACA;AAAA,IACF;AAAA,EAAA,CACA;AAED,QAAM,UAAU;AAAA,IACf,MAAM,gBAAgB,YAAA;AAAA,IACtB,CAAC,gBAAgB,WAAW;AAAA,EAAA;AAE7B,QAAM,gBAAgB;AAAA,IACrB,MAAM,iBAAiB,YAAA;AAAA,IACvB,CAAC,iBAAiB,WAAW;AAAA,EAAA;AAG9B,SAAO;AAAA,IACN;AAAA,IACA,YAAY,kBAAkB,cAAc,aAAa,MAAM;AAAA,IAC/D,WACC,YACC,kBACE,CAAC,cAAc,uBACf,MAAM,YAAY;AAAA,IACtB,YACC,gBAAgB,aAChB,iBAAiB,aACjB,cAAc;AAAA,IACf,cAAc,gBAAgB;AAAA,IAC9B,sBAAsB,kBACnB,cAAc,uBACd,MAAM,YAAY;AAAA,IACrB,aAAa,kBACV,cAAc,cACd,MAAM;AAAA,IACT,oBAAoB,iBAAiB;AAAA,IACrC;AAAA,IACA;AAAA,IACA,qBAAqB,QAAQ;AAAA,IAC7B,gBAAgB,QAAQ;AAAA,IACxB,0BAA0B,UAAU;AAAA,IACpC,kBAAkB,UAAU;AAAA,IAC5B,YAAY,MAAM;AAAA,EAAA;AAEpB;"}
|
|
1
|
+
{"version":3,"file":"use-statewire-conversation-history.js","sources":["../../src/threads/use-statewire-conversation-history.ts"],"sourcesContent":["import {\n\ttype ConversationIndexEntry,\n\ttype ConversationSummary,\n\ttype UseConversationIndexOptions,\n\tuseConversationIndex,\n} from \"@athenaintel/agent-runtime\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { archiveThread, setThreadReadState } from \"./api\";\nimport {\n\ttype RestConversationAuth,\n\tuseRestConversationHistory,\n} from \"./use-rest-conversation-history\";\n\nexport interface UseStatewireConversationHistoryOptions {\n\tbackendUrl: string;\n\tconversationIndexBaseUrl: string;\n\t/** The workspace being viewed; the index is one instance per (workspace, user). */\n\tworkspaceId: string;\n\tprincipalId: string;\n\tgetAuth: () => RestConversationAuth | Promise<RestConversationAuth>;\n\theaders: UseConversationIndexOptions[\"headers\"];\n\tsearch?: string;\n\tenabled?: boolean;\n\tsse?: boolean;\n}\n\n/** Convert the replicated wire row into the shared cross-surface contract. */\nexport function conversationSummaryFromIndexEntry(\n\tentry: ConversationIndexEntry,\n): ConversationSummary {\n\treturn {\n\t\tthreadId: entry.thread_id,\n\t\ttitle: entry.title,\n\t\tupdatedAt: entry.updated_at,\n\t\tcreatedAt: null,\n\t\tstate: entry.state,\n\t\truntime: entry.runtime,\n\t\tsourceChannel: entry.start_channel,\n\t\tassetType: entry.asset_type,\n\t\tassetId: entry.asset_id ?? null,\n\t\tappId: entry.app_id ?? null,\n\t\ttriggerType: entry.trigger_type ?? null,\n\t\tpreview: entry.last_message_preview ?? null,\n\t\tmessageCount: entry.message_count ?? null,\n\t\tisUnread: entry.is_unread ?? false,\n\t\tsessionStatus: entry.session_status ?? null,\n\t\trunStatus: entry.run_status ?? null,\n\t};\n}\n\nexport function conversationHistorySource({\n\tindexEntries,\n\trestConversations,\n\tsupportsStatewirePaging,\n\thasSearch,\n}: {\n\tindexEntries: readonly ConversationIndexEntry[] | null;\n\trestConversations: readonly ConversationSummary[];\n\tsupportsStatewirePaging: boolean;\n\thasSearch: boolean;\n}): ConversationSummary[] {\n\t// Search is server-backed so it covers the user's entire authorized history,\n\t// including rows older than the Statewire live window. An empty query uses\n\t// Statewire as the render source; REST only supplements rolling old hosts.\n\tif (hasSearch) return [...restConversations];\n\tconst statewireItems = (indexEntries ?? []).map(\n\t\tconversationSummaryFromIndexEntry,\n\t);\n\tif (supportsStatewirePaging) return statewireItems;\n\tconst statewireIds = new Set(statewireItems.map((item) => item.threadId));\n\treturn [\n\t\t...statewireItems,\n\t\t...restConversations.filter(\n\t\t\t(conversation) => !statewireIds.has(conversation.threadId),\n\t\t),\n\t];\n}\n\nexport function shouldUseRestConversationHistory({\n\thasSearch,\n\tindexEntries,\n\tsupportsStatewirePaging,\n\tconnectionStatus,\n}: {\n\thasSearch: boolean;\n\tindexEntries: readonly ConversationIndexEntry[] | null;\n\tsupportsStatewirePaging: boolean;\n\tconnectionStatus: string;\n}): boolean {\n\tif (hasSearch) return true;\n\tif (supportsStatewirePaging) return false;\n\t// An old host is identifiable once its snapshot arrives. A transport that\n\t// fails or is parked before any snapshot also needs the independent REST\n\t// path; otherwise entries stays null and the history panel loads forever.\n\treturn (\n\t\tindexEntries !== null ||\n\t\tconnectionStatus === \"reconnecting\" ||\n\t\tconnectionStatus === \"gone\"\n\t);\n}\n\n/**\n * Inclusive satellite conversation history backed by the user's Pinned\n * Statewire instance. The replicated window is the render source; refreshes,\n * pagination, thread creation, lifecycle changes, and title changes arrive on\n * that same channel. A non-empty search deliberately uses the authorized REST\n * list endpoint so matches are not limited to the replicated newest window.\n */\nexport function useStatewireConversationHistory({\n\tbackendUrl,\n\tconversationIndexBaseUrl,\n\tworkspaceId,\n\tprincipalId,\n\tgetAuth,\n\theaders,\n\tsearch,\n\tenabled = true,\n\tsse = false,\n}: UseStatewireConversationHistoryOptions) {\n\tconst index = useConversationIndex({\n\t\tbaseUrl: conversationIndexBaseUrl,\n\t\tworkspaceId: workspaceId || \"pending-workspace\",\n\t\tuserId: principalId || \"pending-user\",\n\t\theaders,\n\t\tenabled: enabled && workspaceId.length > 0 && principalId.length > 0,\n\t\tsse,\n\t});\n\t// Rolling deploy compatibility: the pre-paging index snapshot has no\n\t// total_count. It still renders live rows immediately, while the old REST\n\t// pager remains available only until the upgraded host activates.\n\tconst supportsStatewirePaging = index.totalCount !== null;\n\tconst normalizedSearch = search?.trim().toLowerCase() ?? \"\";\n\tconst hasSearch = normalizedSearch.length > 0;\n\tconst usesRestHistory = shouldUseRestConversationHistory({\n\t\thasSearch,\n\t\tindexEntries: index.entries,\n\t\tsupportsStatewirePaging,\n\t\tconnectionStatus: index.connection.status,\n\t});\n\tconst legacyHistory = useRestConversationHistory({\n\t\tbackendUrl,\n\t\tprincipalId,\n\t\tgetAuth,\n\t\tsearch,\n\t\tenabled: enabled && principalId.length > 0 && usesRestHistory,\n\t});\n\tconst [readOverrides, setReadOverrides] = useState<Record<string, boolean>>(\n\t\t{},\n\t);\n\tconst [archivedThreadIds, setArchivedThreadIds] = useState<\n\t\tReadonlySet<string>\n\t>(() => new Set());\n\n\tuseEffect(() => {\n\t\tif (index.entries === null || archivedThreadIds.size === 0) return;\n\t\tconst visibleIds = new Set(index.entries.map((entry) => entry.thread_id));\n\t\tsetArchivedThreadIds((current) => {\n\t\t\tconst next = new Set(\n\t\t\t\t[...current].filter((threadId) => visibleIds.has(threadId)),\n\t\t\t);\n\t\t\treturn next.size === current.size ? current : next;\n\t\t});\n\t}, [archivedThreadIds.size, index.entries]);\n\n\tconst conversations = useMemo(() => {\n\t\treturn conversationHistorySource({\n\t\t\tindexEntries: index.entries,\n\t\t\trestConversations: legacyHistory.conversations,\n\t\t\tsupportsStatewirePaging,\n\t\t\thasSearch,\n\t\t})\n\t\t\t.filter((conversation) => !archivedThreadIds.has(conversation.threadId))\n\t\t\t.map((conversation) => ({\n\t\t\t\t...conversation,\n\t\t\t\tisUnread: readOverrides[conversation.threadId] ?? conversation.isUnread,\n\t\t\t}));\n\t}, [\n\t\tarchivedThreadIds,\n\t\tindex.entries,\n\t\tlegacyHistory.conversations,\n\t\thasSearch,\n\t\treadOverrides,\n\t\tsupportsStatewirePaging,\n\t]);\n\n\tconst refreshMutation = useMutation({\n\t\tmutationKey: [\n\t\t\t\"conversation-index\",\n\t\t\t\"refresh\",\n\t\t\tconversationIndexBaseUrl,\n\t\t\tprincipalId,\n\t\t],\n\t\tmutationFn: () =>\n\t\t\tusesRestHistory ? legacyHistory.refresh() : index.refresh(),\n\t});\n\tconst loadMoreMutation = useMutation({\n\t\tmutationKey: [\n\t\t\t\"conversation-index\",\n\t\t\t\"load-more\",\n\t\t\tconversationIndexBaseUrl,\n\t\t\tprincipalId,\n\t\t],\n\t\tmutationFn: () =>\n\t\t\tusesRestHistory ? legacyHistory.fetchNextPage() : index.loadMore(),\n\t});\n\tconst archive = useMutation({\n\t\tmutationKey: [\"conversation-history\", \"archive\", backendUrl, principalId],\n\t\tmutationFn: async (threadId: string) => {\n\t\t\tawait archiveThread(backendUrl, await getAuth(), threadId);\n\t\t\treturn threadId;\n\t\t},\n\t\tonMutate: (threadId) => {\n\t\t\tsetArchivedThreadIds((current) => new Set(current).add(threadId));\n\t\t},\n\t\tonError: (_error, threadId) => {\n\t\t\tsetArchivedThreadIds((current) => {\n\t\t\t\tconst next = new Set(current);\n\t\t\t\tnext.delete(threadId);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\tonSuccess: () => {\n\t\t\trefreshMutation.mutate();\n\t\t},\n\t});\n\tconst readState = useMutation({\n\t\tmutationKey: [\n\t\t\t\"conversation-history\",\n\t\t\t\"read-state\",\n\t\t\tbackendUrl,\n\t\t\tprincipalId,\n\t\t],\n\t\tmutationFn: async ({\n\t\t\tthreadId,\n\t\t\tisUnread,\n\t\t}: {\n\t\t\tthreadId: string;\n\t\t\tisUnread: boolean;\n\t\t}) =>\n\t\t\tsetThreadReadState(backendUrl, await getAuth(), { threadId, isUnread }),\n\t\tonMutate: ({ threadId, isUnread }) => {\n\t\t\tconst previous = readOverrides[threadId];\n\t\t\tsetReadOverrides((current) => ({ ...current, [threadId]: isUnread }));\n\t\t\treturn { previous, threadId };\n\t\t},\n\t\tonError: (_error, _variables, context) => {\n\t\t\tif (!context) return;\n\t\t\tsetReadOverrides((current) => {\n\t\t\t\tconst next = { ...current };\n\t\t\t\tif (context.previous === undefined) delete next[context.threadId];\n\t\t\t\telse next[context.threadId] = context.previous;\n\t\t\t\treturn next;\n\t\t\t});\n\t\t},\n\t\tonSuccess: (result) => {\n\t\t\tsetReadOverrides((current) => ({\n\t\t\t\t...current,\n\t\t\t\t[result.thread_id]: result.is_unread,\n\t\t\t}));\n\t\t\trefreshMutation.mutate(undefined, {\n\t\t\t\tonSettled: () => {\n\t\t\t\t\tsetReadOverrides((current) => {\n\t\t\t\t\t\tconst next = { ...current };\n\t\t\t\t\t\tdelete next[result.thread_id];\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t});\n\n\tconst refresh = useCallback(\n\t\t() => refreshMutation.mutateAsync(),\n\t\t[refreshMutation.mutateAsync],\n\t);\n\tconst fetchNextPage = useCallback(\n\t\t() => loadMoreMutation.mutateAsync(),\n\t\t[loadMoreMutation.mutateAsync],\n\t);\n\n\treturn {\n\t\tconversations,\n\t\ttotalCount: usesRestHistory ? legacyHistory.totalCount : index.totalCount,\n\t\tisLoading:\n\t\t\tenabled &&\n\t\t\t(usesRestHistory\n\t\t\t\t? !legacyHistory.hasResolvedFirstPage\n\t\t\t\t: index.entries === null),\n\t\tisFetching:\n\t\t\trefreshMutation.isPending ||\n\t\t\tloadMoreMutation.isPending ||\n\t\t\tlegacyHistory.isFetching,\n\t\tisRefreshing: refreshMutation.isPending,\n\t\thasResolvedFirstPage: usesRestHistory\n\t\t\t? legacyHistory.hasResolvedFirstPage\n\t\t\t: index.entries !== null,\n\t\thasNextPage: usesRestHistory\n\t\t\t? legacyHistory.hasNextPage\n\t\t\t: index.hasNextPage,\n\t\tisFetchingNextPage: loadMoreMutation.isPending,\n\t\tfetchNextPage,\n\t\trefresh,\n\t\tarchiveConversation: archive.mutate,\n\t\tarchivePending: archive.isPending,\n\t\tsetConversationReadState: readState.mutate,\n\t\treadStatePending: readState.isPending,\n\t\tconnection: index.connection,\n\t};\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA4BO,SAAS,kCACf,OACsB;AACtB,SAAO;AAAA,IACN,UAAU,MAAM;AAAA,IAChB,OAAO,MAAM;AAAA,IACb,WAAW,MAAM;AAAA,IACjB,WAAW;AAAA,IACX,OAAO,MAAM;AAAA,IACb,SAAS,MAAM;AAAA,IACf,eA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C9B,sBAAsB,kBACnB,cAAc,uBACd,MAAM,YAAY;AAAA,IACrB,aAAa,kBACV,cAAc,cACd,MAAM;AAAA,IACT,oBAAoB,iBAAiB;AAAA,IACrC;AAAA,IACA;AAAA,IACA,qBAAqB,QAAQ;AAAA,IAC7B,gBAAgB,QAAQ;AAAA,IACxB,0BAA0B,UAAU;AAAA,IACpC,kBAAkB,UAAU;AAAA,IAC5B,YAAY,MAAM;AAAA,EAAA;AAEpB;"}
|
package/dist/toolkits/index.cjs
CHANGED
|
@@ -31,8 +31,6 @@ const Toolkits = {
|
|
|
31
31
|
NOTEBOOK: "notebook_toolkit",
|
|
32
32
|
/** Presentation slide editing. */
|
|
33
33
|
PRESENTATION: "presentation_toolkit",
|
|
34
|
-
/** Presentation slide editing (OnlyOffice, deprecated). */
|
|
35
|
-
PRESENTATION_ONLYOFFICE: "presentation_onlyoffice_toolkit",
|
|
36
34
|
/** PowerPoint presentation creation from templates. */
|
|
37
35
|
POWERPOINT: "powerpoint_deck_toolkit",
|
|
38
36
|
/** PowerPoint presentation creation from templates (pptx-studio). */
|
|
@@ -146,11 +144,6 @@ const TOOLKIT_DISPLAY_INFO = {
|
|
|
146
144
|
description: "Edit presentation slides.",
|
|
147
145
|
icon: "Presentation"
|
|
148
146
|
},
|
|
149
|
-
[Toolkits.PRESENTATION_ONLYOFFICE]: {
|
|
150
|
-
name: "Presentation v0 (deprecated)",
|
|
151
|
-
description: "Edit presentation slides (OnlyOffice, deprecated).",
|
|
152
|
-
icon: "Presentation"
|
|
153
|
-
},
|
|
154
147
|
[Toolkits.POWERPOINT]: {
|
|
155
148
|
name: "PowerPoint",
|
|
156
149
|
description: "Create PowerPoint decks from templates.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/toolkits/index.ts"],"sourcesContent":["/**\n * Backend toolkit IDs.\n *\n * Pass these to the `tools` prop on `<AthenaProvider>` to enable backend toolkits.\n *\n * @example\n * import { Toolkits } from '@athenaintel/react';\n *\n * <AthenaProvider tools={[Toolkits.DOCUMENT, Toolkits.SPREADSHEET, Toolkits.WEB_SEARCH]}>\n */\nexport const Toolkits = {\n /** Web search and page browsing. */\n WEB_SEARCH: 'web_search_browse_toolkit',\n /** SQL query execution. */\n SQL: 'sql_toolkit',\n /** Azure Blob Storage catalog file operations. */\n AZURE_BLOB_STORAGE: 'azure_blob_storage_toolkit',\n /** Document comments and collaboration. */\n COMMENTS: 'comments_toolkit',\n /** Visual canvas creation. */\n CANVAS: 'canvas_toolkit',\n /** PostgreSQL database management. */\n DATABASE: 'database_toolkit',\n /** Asset collections management. */\n COLLECTIONS: 'collections_toolkit',\n /** Charts, dashboards, and figures. */\n VISUALIZATIONS: 'visualizations_toolkit',\n /** Custom UI creation. */\n USER_INTERFACE: 'user_interface_toolkit',\n /** Agent Operating Procedures. */\n AOP: 'aop_toolkit',\n /** Ephemeral compute environments. */\n COMPUTER_ASSET: 'computer_asset_toolkit',\n /** Web browser automation. */\n BROWSER: 'browser_toolkit',\n /** Virtual machine management. */\n VM: 'vm_toolkit',\n /** Jupyter notebook execution. */\n NOTEBOOK: 'notebook_toolkit',\n /** Presentation slide editing. */\n PRESENTATION: 'presentation_toolkit',\n /** Presentation slide editing (OnlyOffice, deprecated). */\n PRESENTATION_ONLYOFFICE: 'presentation_onlyoffice_toolkit',\n /** PowerPoint presentation creation from templates. */\n POWERPOINT: 'powerpoint_deck_toolkit',\n /** PowerPoint presentation creation from templates (pptx-studio). */\n PRESENTATION_PPTX_STUDIO: 'presentation_pptx_studio_toolkit',\n /** Workspace file management (Olympus Drive). */\n DRIVE: 'olympus_drive_toolkit',\n /** Python code execution. */\n PYTHON: 'python_toolkit',\n /** Multi-account email and calendar (Gmail + Outlook). */\n EMAIL: 'unified_email_toolkit',\n /** Legacy email and calendar operations. */\n EMAIL_CALENDAR: 'email_calendar_toolkit',\n /** Spreadsheet operations. */\n SPREADSHEET: 'spreadsheet_toolkit',\n /** Athena document editing. */\n DOCUMENT: 'document_toolkit',\n /** Word document backend operations. */\n WORD_DOCUMENT: 'word_document_be_toolkit',\n /** Go-To-Market management. */\n GTM: 'gtm_toolkit',\n /** Marketing campaign management. */\n MARKETING: 'marketing_toolkit',\n /** FDE implementations and workflows. */\n FDE: 'fde_toolkit',\n /** SharePoint / Google Drive / workspace file access. */\n EXTERNAL_DRIVE: 'external_drive_toolkit',\n /** Reusable playbooks and prompts. */\n PLAYBOOK: 'playbook_toolkit',\n /** Local Chrome browser control via tunnel. */\n DEVICE_TUNNEL: 'device_tunnel_toolkit',\n /** Project management. */\n PROJECTS: 'projects_toolkit',\n /** Task Studio script execution. */\n TASK_STUDIO: 'task_studio_toolkit',\n /** User memory and preferences. */\n PREFERENCES: 'preferences_toolkit',\n} as const;\n\n/** A toolkit ID string. */\nexport type ToolkitId = (typeof Toolkits)[keyof typeof Toolkits];\n\nexport interface ToolkitDisplayInfo {\n id: string;\n name: string;\n description?: string;\n icon?: string;\n}\n\nconst TOOLKIT_DISPLAY_INFO: Record<string, Omit<ToolkitDisplayInfo, 'id'>> = {\n [Toolkits.WEB_SEARCH]: {\n name: 'Web Search',\n description: 'Search the web and inspect pages.',\n icon: 'Globe',\n },\n [Toolkits.SQL]: {\n name: 'SQL',\n description: 'Run structured SQL queries.',\n icon: 'Database',\n },\n [Toolkits.AZURE_BLOB_STORAGE]: {\n name: 'Azure Blob Storage',\n description: 'List, read, and upload Azure Blob Storage catalog files.',\n icon: 'Cloud',\n },\n [Toolkits.COMMENTS]: {\n name: 'Comments',\n description: 'Work with document comments and reviews.',\n icon: 'MessageSquare',\n },\n [Toolkits.CANVAS]: {\n name: 'Canvas',\n description: 'Create and edit visual canvases.',\n icon: 'LayoutGrid',\n },\n [Toolkits.DATABASE]: {\n name: 'Database',\n description: 'Inspect and manage database assets.',\n icon: 'Database',\n },\n [Toolkits.COLLECTIONS]: {\n name: 'Collections',\n description: 'Manage asset collections.',\n icon: 'Boxes',\n },\n [Toolkits.VISUALIZATIONS]: {\n name: 'Visualizations',\n description: 'Create charts, dashboards, and figures.',\n icon: 'ChartBar',\n },\n [Toolkits.USER_INTERFACE]: {\n name: 'User Interface',\n description: 'Build custom user interfaces.',\n icon: 'PanelTop',\n },\n [Toolkits.AOP]: {\n name: 'AOP',\n description: 'Run Agent Operating Procedures.',\n icon: 'Workflow',\n },\n [Toolkits.COMPUTER_ASSET]: {\n name: 'Computer Asset',\n description: 'Provision and operate computer assets.',\n icon: 'Monitor',\n },\n [Toolkits.BROWSER]: {\n name: 'Browser',\n description: 'Control a web browser.',\n icon: 'Globe',\n },\n [Toolkits.VM]: {\n name: 'Virtual Machine',\n description: 'Manage virtual machine environments.',\n icon: 'Server',\n },\n [Toolkits.NOTEBOOK]: {\n name: 'Notebook',\n description: 'Run Jupyter notebook workflows.',\n icon: 'BookOpen',\n },\n [Toolkits.PRESENTATION]: {\n name: 'Presentation',\n description: 'Edit presentation slides.',\n icon: 'Presentation',\n },\n [Toolkits.PRESENTATION_ONLYOFFICE]: {\n name: 'Presentation v0 (deprecated)',\n description: 'Edit presentation slides (OnlyOffice, deprecated).',\n icon: 'Presentation',\n },\n [Toolkits.POWERPOINT]: {\n name: 'PowerPoint',\n description: 'Create PowerPoint decks from templates.',\n icon: 'Presentation',\n },\n [Toolkits.PRESENTATION_PPTX_STUDIO]: {\n name: 'Presentation',\n description: 'Create PowerPoint presentations from templates (pptx-studio).',\n icon: 'Presentation',\n },\n [Toolkits.DRIVE]: {\n name: 'Olympus Drive',\n description: 'Find and manage workspace files.',\n icon: 'Folder',\n },\n [Toolkits.PYTHON]: {\n name: 'Python',\n description: 'Run Python analysis and automation.',\n icon: 'Code2',\n },\n [Toolkits.EMAIL]: {\n name: 'Email',\n description: 'Work across connected email and calendar accounts.',\n icon: 'Mail',\n },\n [Toolkits.EMAIL_CALENDAR]: {\n name: 'Email & Calendar',\n description: 'Use email and calendar operations.',\n icon: 'Calendar',\n },\n [Toolkits.SPREADSHEET]: {\n name: 'Spreadsheet',\n description: 'Create and edit spreadsheets.',\n icon: 'Table2',\n },\n [Toolkits.DOCUMENT]: {\n name: 'Document',\n description: 'Create and edit Athena documents.',\n icon: 'FileText',\n },\n [Toolkits.WORD_DOCUMENT]: {\n name: 'Word Document',\n description: 'Create and edit Word documents.',\n icon: 'FileText',\n },\n [Toolkits.GTM]: {\n name: 'Go-To-Market',\n description: 'Manage go-to-market workflows.',\n icon: 'BriefcaseBusiness',\n },\n [Toolkits.MARKETING]: {\n name: 'Marketing',\n description: 'Manage marketing campaigns.',\n icon: 'Megaphone',\n },\n [Toolkits.FDE]: {\n name: 'FDE',\n description: 'Build FDE implementations and workflows.',\n icon: 'Workflow',\n },\n [Toolkits.EXTERNAL_DRIVE]: {\n name: 'External Drive',\n description: 'Access SharePoint, Google Drive, and other files.',\n icon: 'HardDrive',\n },\n [Toolkits.PLAYBOOK]: {\n name: 'Playbook',\n description: 'Use reusable playbooks and prompts.',\n icon: 'BookOpen',\n },\n [Toolkits.DEVICE_TUNNEL]: {\n name: 'Device Tunnel',\n description: 'Control a local browser through a tunnel.',\n icon: 'Cable',\n },\n [Toolkits.PROJECTS]: {\n name: 'Projects',\n description: 'Manage project work.',\n icon: 'FolderKanban',\n },\n [Toolkits.TASK_STUDIO]: {\n name: 'Task Studio',\n description: 'Run Task Studio scripts.',\n icon: 'Terminal',\n },\n [Toolkits.PREFERENCES]: {\n name: 'Preferences',\n description: 'Use memory and preference tools.',\n icon: 'Settings',\n },\n semantic_model_toolkit: {\n name: 'Semantic Model',\n description: 'Query semantic models and generate analytics.',\n icon: 'ChartBar',\n },\n semantic_model_dev_toolkit: {\n name: 'Semantic Model Development',\n description: 'Create, validate, and deploy semantic model YAML.',\n icon: 'Database',\n },\n};\n\nconst humanizeToolkitId = (id: string): string => {\n const trimmed = id.trim();\n if (!trimmed) {\n return 'Toolkit';\n }\n\n const withoutSuffix = trimmed.replace(/_toolkit$/, '');\n return withoutSuffix\n .split(/[_-]+/)\n .filter(Boolean)\n .map((word) => {\n if (word.length <= 3) {\n return word.toUpperCase();\n }\n return `${word.charAt(0).toUpperCase()}${word.slice(1)}`;\n })\n .join(' ');\n};\n\nexport const getToolkitDisplayInfo = (id: string): ToolkitDisplayInfo => {\n const info = TOOLKIT_DISPLAY_INFO[id];\n\n return {\n id,\n name: info?.name ?? humanizeToolkitId(id),\n description: info?.description,\n icon: info?.icon ?? 'Package',\n };\n};\n"],"names":[],"mappings":";;AAUO,MAAM,WAAW;AAAA;AAAA,EAEtB,YAAY;AAAA;AAAA,EAEZ,KAAK;AAAA;AAAA,EAEL,oBAAoB;AAAA;AAAA,EAEpB,UAAU;AAAA;AAAA,EAEV,QAAQ;AAAA;AAAA,EAER,UAAU;AAAA;AAAA,EAEV,aAAa;AAAA;AAAA,EAEb,gBAAgB;AAAA;AAAA,EAEhB,gBAAgB;AAAA;AAAA,EAEhB,KAAK;AAAA;AAAA,EAEL,gBAAgB;AAAA;AAAA,EAEhB,SAAS;AAAA;AAAA,EAET,IAAI;AAAA;AAAA,EAEJ,UAAU;AAAA;AAAA,EAEV,cAAc;AAAA;AAAA,EAEd,yBAAyB;AAAA;AAAA,EAEzB,YAAY;AAAA;AAAA,EAEZ,0BAA0B;AAAA;AAAA,EAE1B,OAAO;AAAA;AAAA,EAEP,QAAQ;AAAA;AAAA,EAER,OAAO;AAAA;AAAA,EAEP,gBAAgB;AAAA;AAAA,EAEhB,aAAa;AAAA;AAAA,EAEb,UAAU;AAAA;AAAA,EAEV,eAAe;AAAA;AAAA,EAEf,KAAK;AAAA;AAAA,EAEL,WAAW;AAAA;AAAA,EAEX,KAAK;AAAA;AAAA,EAEL,gBAAgB;AAAA;AAAA,EAEhB,UAAU;AAAA;AAAA,EAEV,eAAe;AAAA;AAAA,EAEf,UAAU;AAAA;AAAA,EAEV,aAAa;AAAA;AAAA,EAEb,aAAa;AACf;AAYA,MAAM,uBAAuE;AAAA,EAC3E,CAAC,SAAS,UAAU,GAAG;AAAA,IACrB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,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AAK,UAAU,GAAG;AACpB,aAAO,KAAK,YAAA;AAAA,IACd;AACA,WAAO,GAAG,KAAK,OAAO,CAAC,EAAE,YAAA,CAAa,GAAG,KAAK,MAAM,CAAC,CAAC;AAAA,EACxD,CAAC,EACA,KAAK,GAAG;AACb;AAEO,MAAM,wBAAwB,CAAC,OAAmC;AACvE,QAAM,OAAO,qBAAqB,EAAE;AAEpC,SAAO;AAAA,IACL;AAAA,IACA,OAAM,6BAAM,SAAQ,kBAAkB,EAAE;AAAA,IACxC,aAAa,6BAAM;AAAA,IACnB,OAAM,6BAAM,SAAQ;AAAA,EAAA;AAExB;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/toolkits/index.ts"],"sourcesContent":["/**\n * Backend toolkit IDs.\n *\n * Pass these to the `tools` prop on `<AthenaProvider>` to enable backend toolkits.\n *\n * @example\n * import { Toolkits } from '@athenaintel/react';\n *\n * <AthenaProvider tools={[Toolkits.DOCUMENT, Toolkits.SPREADSHEET, Toolkits.WEB_SEARCH]}>\n */\nexport const Toolkits = {\n /** Web search and page browsing. */\n WEB_SEARCH: 'web_search_browse_toolkit',\n /** SQL query execution. */\n SQL: 'sql_toolkit',\n /** Azure Blob Storage catalog file operations. */\n AZURE_BLOB_STORAGE: 'azure_blob_storage_toolkit',\n /** Document comments and collaboration. */\n COMMENTS: 'comments_toolkit',\n /** Visual canvas creation. */\n CANVAS: 'canvas_toolkit',\n /** PostgreSQL database management. */\n DATABASE: 'database_toolkit',\n /** Asset collections management. */\n COLLECTIONS: 'collections_toolkit',\n /** Charts, dashboards, and figures. */\n VISUALIZATIONS: 'visualizations_toolkit',\n /** Custom UI creation. */\n USER_INTERFACE: 'user_interface_toolkit',\n /** Agent Operating Procedures. */\n AOP: 'aop_toolkit',\n /** Ephemeral compute environments. */\n COMPUTER_ASSET: 'computer_asset_toolkit',\n /** Web browser automation. */\n BROWSER: 'browser_toolkit',\n /** Virtual machine management. */\n VM: 'vm_toolkit',\n /** Jupyter notebook execution. */\n NOTEBOOK: 'notebook_toolkit',\n /** Presentation slide editing. */\n PRESENTATION: 'presentation_toolkit',\n /** PowerPoint presentation creation from templates. */\n POWERPOINT: 'powerpoint_deck_toolkit',\n /** PowerPoint presentation creation from templates (pptx-studio). */\n PRESENTATION_PPTX_STUDIO: 'presentation_pptx_studio_toolkit',\n /** Workspace file management (Olympus Drive). */\n DRIVE: 'olympus_drive_toolkit',\n /** Python code execution. */\n PYTHON: 'python_toolkit',\n /** Multi-account email and calendar (Gmail + Outlook). */\n EMAIL: 'unified_email_toolkit',\n /** Legacy email and calendar operations. */\n EMAIL_CALENDAR: 'email_calendar_toolkit',\n /** Spreadsheet operations. */\n SPREADSHEET: 'spreadsheet_toolkit',\n /** Athena document editing. */\n DOCUMENT: 'document_toolkit',\n /** Word document backend operations. */\n WORD_DOCUMENT: 'word_document_be_toolkit',\n /** Go-To-Market management. */\n GTM: 'gtm_toolkit',\n /** Marketing campaign management. */\n MARKETING: 'marketing_toolkit',\n /** FDE implementations and workflows. */\n FDE: 'fde_toolkit',\n /** SharePoint / Google Drive / workspace file access. */\n EXTERNAL_DRIVE: 'external_drive_toolkit',\n /** Reusable playbooks and prompts. */\n PLAYBOOK: 'playbook_toolkit',\n /** Local Chrome browser control via tunnel. */\n DEVICE_TUNNEL: 'device_tunnel_toolkit',\n /** Project management. */\n PROJECTS: 'projects_toolkit',\n /** Task Studio script execution. */\n TASK_STUDIO: 'task_studio_toolkit',\n /** User memory and preferences. */\n PREFERENCES: 'preferences_toolkit',\n} as const;\n\n/** A toolkit ID string. */\nexport type ToolkitId = (typeof Toolkits)[keyof typeof Toolkits];\n\nexport interface ToolkitDisplayInfo {\n id: string;\n name: string;\n description?: string;\n icon?: string;\n}\n\nconst TOOLKIT_DISPLAY_INFO: Record<string, Omit<ToolkitDisplayInfo, 'id'>> = {\n [Toolkits.WEB_SEARCH]: {\n name: 'Web Search',\n description: 'Search the web and inspect pages.',\n icon: 'Globe',\n },\n [Toolkits.SQL]: {\n name: 'SQL',\n description: 'Run structured SQL queries.',\n icon: 'Database',\n },\n [Toolkits.AZURE_BLOB_STORAGE]: {\n name: 'Azure Blob Storage',\n description: 'List, read, and upload Azure Blob Storage catalog files.',\n icon: 'Cloud',\n },\n [Toolkits.COMMENTS]: {\n name: 'Comments',\n description: 'Work with document comments and reviews.',\n icon: 'MessageSquare',\n },\n [Toolkits.CANVAS]: {\n name: 'Canvas',\n description: 'Create and edit visual canvases.',\n icon: 'LayoutGrid',\n },\n [Toolkits.DATABASE]: {\n name: 'Database',\n description: 'Inspect and manage database assets.',\n icon: 'Database',\n },\n [Toolkits.COLLECTIONS]: {\n name: 'Collections',\n description: 'Manage asset collections.',\n icon: 'Boxes',\n },\n [Toolkits.VISUALIZATIONS]: {\n name: 'Visualizations',\n description: 'Create charts, dashboards, and figures.',\n icon: 'ChartBar',\n },\n [Toolkits.USER_INTERFACE]: {\n name: 'User Interface',\n description: 'Build custom user interfaces.',\n icon: 'PanelTop',\n },\n [Toolkits.AOP]: {\n name: 'AOP',\n description: 'Run Agent Operating Procedures.',\n icon: 'Workflow',\n },\n [Toolkits.COMPUTER_ASSET]: {\n name: 'Computer Asset',\n description: 'Provision and operate computer assets.',\n icon: 'Monitor',\n },\n [Toolkits.BROWSER]: {\n name: 'Browser',\n description: 'Control a web browser.',\n icon: 'Globe',\n },\n [Toolkits.VM]: {\n name: 'Virtual Machine',\n description: 'Manage virtual machine environments.',\n icon: 'Server',\n },\n [Toolkits.NOTEBOOK]: {\n name: 'Notebook',\n description: 'Run Jupyter notebook workflows.',\n icon: 'BookOpen',\n },\n [Toolkits.PRESENTATION]: {\n name: 'Presentation',\n description: 'Edit presentation slides.',\n icon: 'Presentation',\n },\n [Toolkits.POWERPOINT]: {\n name: 'PowerPoint',\n description: 'Create PowerPoint decks from templates.',\n icon: 'Presentation',\n },\n [Toolkits.PRESENTATION_PPTX_STUDIO]: {\n name: 'Presentation',\n description: 'Create PowerPoint presentations from templates (pptx-studio).',\n icon: 'Presentation',\n },\n [Toolkits.DRIVE]: {\n name: 'Olympus Drive',\n description: 'Find and manage workspace files.',\n icon: 'Folder',\n },\n [Toolkits.PYTHON]: {\n name: 'Python',\n description: 'Run Python analysis and automation.',\n icon: 'Code2',\n },\n [Toolkits.EMAIL]: {\n name: 'Email',\n description: 'Work across connected email and calendar accounts.',\n icon: 'Mail',\n },\n [Toolkits.EMAIL_CALENDAR]: {\n name: 'Email & Calendar',\n description: 'Use email and calendar operations.',\n icon: 'Calendar',\n },\n [Toolkits.SPREADSHEET]: {\n name: 'Spreadsheet',\n description: 'Create and edit spreadsheets.',\n icon: 'Table2',\n },\n [Toolkits.DOCUMENT]: {\n name: 'Document',\n description: 'Create and edit Athena documents.',\n icon: 'FileText',\n },\n [Toolkits.WORD_DOCUMENT]: {\n name: 'Word Document',\n description: 'Create and edit Word documents.',\n icon: 'FileText',\n },\n [Toolkits.GTM]: {\n name: 'Go-To-Market',\n description: 'Manage go-to-market workflows.',\n icon: 'BriefcaseBusiness',\n },\n [Toolkits.MARKETING]: {\n name: 'Marketing',\n description: 'Manage marketing campaigns.',\n icon: 'Megaphone',\n },\n [Toolkits.FDE]: {\n name: 'FDE',\n description: 'Build FDE implementations and workflows.',\n icon: 'Workflow',\n },\n [Toolkits.EXTERNAL_DRIVE]: {\n name: 'External Drive',\n description: 'Access SharePoint, Google Drive, and other files.',\n icon: 'HardDrive',\n },\n [Toolkits.PLAYBOOK]: {\n name: 'Playbook',\n description: 'Use reusable playbooks and prompts.',\n icon: 'BookOpen',\n },\n [Toolkits.DEVICE_TUNNEL]: {\n name: 'Device Tunnel',\n description: 'Control a local browser through a tunnel.',\n icon: 'Cable',\n },\n [Toolkits.PROJECTS]: {\n name: 'Projects',\n description: 'Manage project work.',\n icon: 'FolderKanban',\n },\n [Toolkits.TASK_STUDIO]: {\n name: 'Task Studio',\n description: 'Run Task Studio scripts.',\n icon: 'Terminal',\n },\n [Toolkits.PREFERENCES]: {\n name: 'Preferences',\n description: 'Use memory and preference tools.',\n icon: 'Settings',\n },\n semantic_model_toolkit: {\n name: 'Semantic Model',\n description: 'Query semantic models and generate analytics.',\n icon: 'ChartBar',\n },\n semantic_model_dev_toolkit: {\n name: 'Semantic Model Development',\n description: 'Create, validate, and deploy semantic model YAML.',\n icon: 'Database',\n },\n};\n\nconst humanizeToolkitId = (id: string): string => {\n const trimmed = id.trim();\n if (!trimmed) {\n return 'Toolkit';\n }\n\n const withoutSuffix = trimmed.replace(/_toolkit$/, '');\n return withoutSuffix\n .split(/[_-]+/)\n .filter(Boolean)\n .map((word) => {\n if (word.length <= 3) {\n return word.toUpperCase();\n }\n return `${word.charAt(0).toUpperCase()}${word.slice(1)}`;\n })\n .join(' ');\n};\n\nexport const getToolkitDisplayInfo = (id: string): ToolkitDisplayInfo => {\n const info = TOOLKIT_DISPLAY_INFO[id];\n\n return {\n id,\n name: info?.name ?? humanizeToolkitId(id),\n description: info?.description,\n icon: info?.icon ?? 'Package',\n };\n};\n"],"names":[],"mappings":";;AAUO,MAAM,WAAW;AAAA;AAAA,EAEtB,YAAY;AAAA;AAAA,EAEZ,KAAK;AAAA;AAAA,EAEL,oBAAoB;AAAA;AAAA,EAEpB,UAAU;AAAA;AAAA,EAEV,QAAQ;AAAA;AAAA,EAER,UAAU;AAAA;AAAA,EAEV,aAAa;AAAA;AAAA,EAEb,gBAAgB;AAAA;AAAA,EAEhB,gBAAgB;AAAA;AAAA,EAEhB,KAAK;AAAA;AAAA,EAEL,gBAAgB;AAAA;AAAA,EAEhB,SAAS;AAAA;AAAA,EAET,IAAI;AAAA;AAAA,EAEJ,UAAU;AAAA;AAAA,EAEV,cAAc;AAAA;AAAA,EAEd,YAAY;AAAA;AAAA,EAEZ,0BAA0B;AAAA;AAAA,EAE1B,OAAO;AAAA;AAAA,EAEP,QAAQ;AAAA;AAAA,EAER,OAAO;AAAA;AAAA,EAEP,gBAAgB;AAAA;AAAA,EAEhB,aAAa;AAAA;AAAA,EAEb,UAAU;AAAA;AAAA,EAEV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,MAAM,oBAAoB,CAAC,OAAuB;AAChD,QAAM,UAAU,GAAG,KAAA;AACnB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,QAAQ,QAAQ,aAAa,EAAE;AACrD,SAAO,cACJ,MAAM,OAAO,EACb,OAAO,OAAO,EACd,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,UAAU,GAAG;AACpB,aAAO,KAAK,YAAA;AAAA,IACd;AACA,WAAO,GAAG,KAAK,OAAO,CAAC,EAAE,YAAA,CAAa,GAAG,KAAK,MAAM,CAAC,CAAC;AAAA,EACxD,CAAC,EACA,KAAK,GAAG;AACb;AAEO,MAAM,wBAAwB,CAAC,OAAmC;AACvE,QAAM,OAAO,qBAAqB,EAAE;AAEpC,SAAO;AAAA,IACL;AAAA,IACA,OAAM,6BAAM,SAAQ,kBAAkB,EAAE;AAAA,IACxC,aAAa,6BAAM;AAAA,IACnB,OAAM,6BAAM,SAAQ;AAAA,EAAA;AAExB;;;"}
|
package/dist/toolkits/index.d.ts
CHANGED
|
@@ -39,8 +39,6 @@ export declare const Toolkits: {
|
|
|
39
39
|
readonly NOTEBOOK: 'notebook_toolkit';
|
|
40
40
|
/** Presentation slide editing. */
|
|
41
41
|
readonly PRESENTATION: 'presentation_toolkit';
|
|
42
|
-
/** Presentation slide editing (OnlyOffice, deprecated). */
|
|
43
|
-
readonly PRESENTATION_ONLYOFFICE: 'presentation_onlyoffice_toolkit';
|
|
44
42
|
/** PowerPoint presentation creation from templates. */
|
|
45
43
|
readonly POWERPOINT: 'powerpoint_deck_toolkit';
|
|
46
44
|
/** PowerPoint presentation creation from templates (pptx-studio). */
|
package/dist/toolkits/index.js
CHANGED
|
@@ -29,8 +29,6 @@ const Toolkits = {
|
|
|
29
29
|
NOTEBOOK: "notebook_toolkit",
|
|
30
30
|
/** Presentation slide editing. */
|
|
31
31
|
PRESENTATION: "presentation_toolkit",
|
|
32
|
-
/** Presentation slide editing (OnlyOffice, deprecated). */
|
|
33
|
-
PRESENTATION_ONLYOFFICE: "presentation_onlyoffice_toolkit",
|
|
34
32
|
/** PowerPoint presentation creation from templates. */
|
|
35
33
|
POWERPOINT: "powerpoint_deck_toolkit",
|
|
36
34
|
/** PowerPoint presentation creation from templates (pptx-studio). */
|
|
@@ -144,11 +142,6 @@ const TOOLKIT_DISPLAY_INFO = {
|
|
|
144
142
|
description: "Edit presentation slides.",
|
|
145
143
|
icon: "Presentation"
|
|
146
144
|
},
|
|
147
|
-
[Toolkits.PRESENTATION_ONLYOFFICE]: {
|
|
148
|
-
name: "Presentation v0 (deprecated)",
|
|
149
|
-
description: "Edit presentation slides (OnlyOffice, deprecated).",
|
|
150
|
-
icon: "Presentation"
|
|
151
|
-
},
|
|
152
145
|
[Toolkits.POWERPOINT]: {
|
|
153
146
|
name: "PowerPoint",
|
|
154
147
|
description: "Create PowerPoint decks from templates.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/toolkits/index.ts"],"sourcesContent":["/**\n * Backend toolkit IDs.\n *\n * Pass these to the `tools` prop on `<AthenaProvider>` to enable backend toolkits.\n *\n * @example\n * import { Toolkits } from '@athenaintel/react';\n *\n * <AthenaProvider tools={[Toolkits.DOCUMENT, Toolkits.SPREADSHEET, Toolkits.WEB_SEARCH]}>\n */\nexport const Toolkits = {\n /** Web search and page browsing. */\n WEB_SEARCH: 'web_search_browse_toolkit',\n /** SQL query execution. */\n SQL: 'sql_toolkit',\n /** Azure Blob Storage catalog file operations. */\n AZURE_BLOB_STORAGE: 'azure_blob_storage_toolkit',\n /** Document comments and collaboration. */\n COMMENTS: 'comments_toolkit',\n /** Visual canvas creation. */\n CANVAS: 'canvas_toolkit',\n /** PostgreSQL database management. */\n DATABASE: 'database_toolkit',\n /** Asset collections management. */\n COLLECTIONS: 'collections_toolkit',\n /** Charts, dashboards, and figures. */\n VISUALIZATIONS: 'visualizations_toolkit',\n /** Custom UI creation. */\n USER_INTERFACE: 'user_interface_toolkit',\n /** Agent Operating Procedures. */\n AOP: 'aop_toolkit',\n /** Ephemeral compute environments. */\n COMPUTER_ASSET: 'computer_asset_toolkit',\n /** Web browser automation. */\n BROWSER: 'browser_toolkit',\n /** Virtual machine management. */\n VM: 'vm_toolkit',\n /** Jupyter notebook execution. */\n NOTEBOOK: 'notebook_toolkit',\n /** Presentation slide editing. */\n PRESENTATION: 'presentation_toolkit',\n /** Presentation slide editing (OnlyOffice, deprecated). */\n PRESENTATION_ONLYOFFICE: 'presentation_onlyoffice_toolkit',\n /** PowerPoint presentation creation from templates. */\n POWERPOINT: 'powerpoint_deck_toolkit',\n /** PowerPoint presentation creation from templates (pptx-studio). */\n PRESENTATION_PPTX_STUDIO: 'presentation_pptx_studio_toolkit',\n /** Workspace file management (Olympus Drive). */\n DRIVE: 'olympus_drive_toolkit',\n /** Python code execution. */\n PYTHON: 'python_toolkit',\n /** Multi-account email and calendar (Gmail + Outlook). */\n EMAIL: 'unified_email_toolkit',\n /** Legacy email and calendar operations. */\n EMAIL_CALENDAR: 'email_calendar_toolkit',\n /** Spreadsheet operations. */\n SPREADSHEET: 'spreadsheet_toolkit',\n /** Athena document editing. */\n DOCUMENT: 'document_toolkit',\n /** Word document backend operations. */\n WORD_DOCUMENT: 'word_document_be_toolkit',\n /** Go-To-Market management. */\n GTM: 'gtm_toolkit',\n /** Marketing campaign management. */\n MARKETING: 'marketing_toolkit',\n /** FDE implementations and workflows. */\n FDE: 'fde_toolkit',\n /** SharePoint / Google Drive / workspace file access. */\n EXTERNAL_DRIVE: 'external_drive_toolkit',\n /** Reusable playbooks and prompts. */\n PLAYBOOK: 'playbook_toolkit',\n /** Local Chrome browser control via tunnel. */\n DEVICE_TUNNEL: 'device_tunnel_toolkit',\n /** Project management. */\n PROJECTS: 'projects_toolkit',\n /** Task Studio script execution. */\n TASK_STUDIO: 'task_studio_toolkit',\n /** User memory and preferences. */\n PREFERENCES: 'preferences_toolkit',\n} as const;\n\n/** A toolkit ID string. */\nexport type ToolkitId = (typeof Toolkits)[keyof typeof Toolkits];\n\nexport interface ToolkitDisplayInfo {\n id: string;\n name: string;\n description?: string;\n icon?: string;\n}\n\nconst TOOLKIT_DISPLAY_INFO: Record<string, Omit<ToolkitDisplayInfo, 'id'>> = {\n [Toolkits.WEB_SEARCH]: {\n name: 'Web Search',\n description: 'Search the web and inspect pages.',\n icon: 'Globe',\n },\n [Toolkits.SQL]: {\n name: 'SQL',\n description: 'Run structured SQL queries.',\n icon: 'Database',\n },\n [Toolkits.AZURE_BLOB_STORAGE]: {\n name: 'Azure Blob Storage',\n description: 'List, read, and upload Azure Blob Storage catalog files.',\n icon: 'Cloud',\n },\n [Toolkits.COMMENTS]: {\n name: 'Comments',\n description: 'Work with document comments and reviews.',\n icon: 'MessageSquare',\n },\n [Toolkits.CANVAS]: {\n name: 'Canvas',\n description: 'Create and edit visual canvases.',\n icon: 'LayoutGrid',\n },\n [Toolkits.DATABASE]: {\n name: 'Database',\n description: 'Inspect and manage database assets.',\n icon: 'Database',\n },\n [Toolkits.COLLECTIONS]: {\n name: 'Collections',\n description: 'Manage asset collections.',\n icon: 'Boxes',\n },\n [Toolkits.VISUALIZATIONS]: {\n name: 'Visualizations',\n description: 'Create charts, dashboards, and figures.',\n icon: 'ChartBar',\n },\n [Toolkits.USER_INTERFACE]: {\n name: 'User Interface',\n description: 'Build custom user interfaces.',\n icon: 'PanelTop',\n },\n [Toolkits.AOP]: {\n name: 'AOP',\n description: 'Run Agent Operating Procedures.',\n icon: 'Workflow',\n },\n [Toolkits.COMPUTER_ASSET]: {\n name: 'Computer Asset',\n description: 'Provision and operate computer assets.',\n icon: 'Monitor',\n },\n [Toolkits.BROWSER]: {\n name: 'Browser',\n description: 'Control a web browser.',\n icon: 'Globe',\n },\n [Toolkits.VM]: {\n name: 'Virtual Machine',\n description: 'Manage virtual machine environments.',\n icon: 'Server',\n },\n [Toolkits.NOTEBOOK]: {\n name: 'Notebook',\n description: 'Run Jupyter notebook workflows.',\n icon: 'BookOpen',\n },\n [Toolkits.PRESENTATION]: {\n name: 'Presentation',\n description: 'Edit presentation slides.',\n icon: 'Presentation',\n },\n [Toolkits.PRESENTATION_ONLYOFFICE]: {\n name: 'Presentation v0 (deprecated)',\n description: 'Edit presentation slides (OnlyOffice, deprecated).',\n icon: 'Presentation',\n },\n [Toolkits.POWERPOINT]: {\n name: 'PowerPoint',\n description: 'Create PowerPoint decks from templates.',\n icon: 'Presentation',\n },\n [Toolkits.PRESENTATION_PPTX_STUDIO]: {\n name: 'Presentation',\n description: 'Create PowerPoint presentations from templates (pptx-studio).',\n icon: 'Presentation',\n },\n [Toolkits.DRIVE]: {\n name: 'Olympus Drive',\n description: 'Find and manage workspace files.',\n icon: 'Folder',\n },\n [Toolkits.PYTHON]: {\n name: 'Python',\n description: 'Run Python analysis and automation.',\n icon: 'Code2',\n },\n [Toolkits.EMAIL]: {\n name: 'Email',\n description: 'Work across connected email and calendar accounts.',\n icon: 'Mail',\n },\n [Toolkits.EMAIL_CALENDAR]: {\n name: 'Email & Calendar',\n description: 'Use email and calendar operations.',\n icon: 'Calendar',\n },\n [Toolkits.SPREADSHEET]: {\n name: 'Spreadsheet',\n description: 'Create and edit spreadsheets.',\n icon: 'Table2',\n },\n [Toolkits.DOCUMENT]: {\n name: 'Document',\n description: 'Create and edit Athena documents.',\n icon: 'FileText',\n },\n [Toolkits.WORD_DOCUMENT]: {\n name: 'Word Document',\n description: 'Create and edit Word documents.',\n icon: 'FileText',\n },\n [Toolkits.GTM]: {\n name: 'Go-To-Market',\n description: 'Manage go-to-market workflows.',\n icon: 'BriefcaseBusiness',\n },\n [Toolkits.MARKETING]: {\n name: 'Marketing',\n description: 'Manage marketing campaigns.',\n icon: 'Megaphone',\n },\n [Toolkits.FDE]: {\n name: 'FDE',\n description: 'Build FDE implementations and workflows.',\n icon: 'Workflow',\n },\n [Toolkits.EXTERNAL_DRIVE]: {\n name: 'External Drive',\n description: 'Access SharePoint, Google Drive, and other files.',\n icon: 'HardDrive',\n },\n [Toolkits.PLAYBOOK]: {\n name: 'Playbook',\n description: 'Use reusable playbooks and prompts.',\n icon: 'BookOpen',\n },\n [Toolkits.DEVICE_TUNNEL]: {\n name: 'Device Tunnel',\n description: 'Control a local browser through a tunnel.',\n icon: 'Cable',\n },\n [Toolkits.PROJECTS]: {\n name: 'Projects',\n description: 'Manage project work.',\n icon: 'FolderKanban',\n },\n [Toolkits.TASK_STUDIO]: {\n name: 'Task Studio',\n description: 'Run Task Studio scripts.',\n icon: 'Terminal',\n },\n [Toolkits.PREFERENCES]: {\n name: 'Preferences',\n description: 'Use memory and preference tools.',\n icon: 'Settings',\n },\n semantic_model_toolkit: {\n name: 'Semantic Model',\n description: 'Query semantic models and generate analytics.',\n icon: 'ChartBar',\n },\n semantic_model_dev_toolkit: {\n name: 'Semantic Model Development',\n description: 'Create, validate, and deploy semantic model YAML.',\n icon: 'Database',\n },\n};\n\nconst humanizeToolkitId = (id: string): string => {\n const trimmed = id.trim();\n if (!trimmed) {\n return 'Toolkit';\n }\n\n const withoutSuffix = trimmed.replace(/_toolkit$/, '');\n return withoutSuffix\n .split(/[_-]+/)\n .filter(Boolean)\n .map((word) => {\n if (word.length <= 3) {\n return word.toUpperCase();\n }\n return `${word.charAt(0).toUpperCase()}${word.slice(1)}`;\n })\n .join(' ');\n};\n\nexport const getToolkitDisplayInfo = (id: string): ToolkitDisplayInfo => {\n const info = TOOLKIT_DISPLAY_INFO[id];\n\n return {\n id,\n name: info?.name ?? humanizeToolkitId(id),\n description: info?.description,\n icon: info?.icon ?? 'Package',\n };\n};\n"],"names":[],"mappings":"AAUO,MAAM,WAAW;AAAA;AAAA,EAEtB,YAAY;AAAA;AAAA,EAEZ,KAAK;AAAA;AAAA,EAEL,oBAAoB;AAAA;AAAA,EAEpB,UAAU;AAAA;AAAA,EAEV,QAAQ;AAAA;AAAA,EAER,UAAU;AAAA;AAAA,EAEV,aAAa;AAAA;AAAA,EAEb,gBAAgB;AAAA;AAAA,EAEhB,gBAAg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IACb,MAAM;AAAA,EAAA;AAAA,EAER,CAAC,SAAS,QAAQ,GAAG;AAAA,IACnB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,EAAA;AAAA,EAER,CAAC,SAAS,WAAW,GAAG;AAAA,IACtB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,EAAA;AAAA,EAER,CAAC,SAAS,WAAW,GAAG;AAAA,IACtB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,EAAA;AAAA,EAER,wBAAwB;AAAA,IACtB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,EAAA;AAAA,EAER,4BAA4B;AAAA,IAC1B,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,EAAA;AAEV;AAEA,MAAM,oBAAoB,CAAC,OAAuB;AAChD,QAAM,UAAU,GAAG,KAAA;AACnB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,QAAQ,QAAQ,aAAa,EAAE;AACrD,SAAO,cACJ,MAAM,OAAO,EACb,OAAO,OAAO,EACd,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,UAAU,GAAG;AACpB,aAAO,KAAK,YAAA;AAAA,IACd;AACA,WAAO,GAAG,KAAK,OAAO,CAAC,EAAE,YAAA,CAAa,GAAG,KAAK,MAAM,CAAC,CAAC;AAAA,EACxD,CAAC,EACA,KAAK,GAAG;AACb;AAEO,MAAM,wBAAwB,CAAC,OAAmC;AACvE,QAAM,OAAO,qBAAqB,EAAE;AAEpC,SAAO;AAAA,IACL;AAAA,IACA,OAAM,6BAAM,SAAQ,kBAAkB,EAAE;AAAA,IACxC,aAAa,6BAAM;AAAA,IACnB,OAAM,6BAAM,SAAQ;AAAA,EAAA;AAExB;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/toolkits/index.ts"],"sourcesContent":["/**\n * Backend toolkit IDs.\n *\n * Pass these to the `tools` prop on `<AthenaProvider>` to enable backend toolkits.\n *\n * @example\n * import { Toolkits } from '@athenaintel/react';\n *\n * <AthenaProvider tools={[Toolkits.DOCUMENT, Toolkits.SPREADSHEET, Toolkits.WEB_SEARCH]}>\n */\nexport const Toolkits = {\n /** Web search and page browsing. */\n WEB_SEARCH: 'web_search_browse_toolkit',\n /** SQL query execution. */\n SQL: 'sql_toolkit',\n /** Azure Blob Storage catalog file operations. */\n AZURE_BLOB_STORAGE: 'azure_blob_storage_toolkit',\n /** Document comments and collaboration. */\n COMMENTS: 'comments_toolkit',\n /** Visual canvas creation. */\n CANVAS: 'canvas_toolkit',\n /** PostgreSQL database management. */\n DATABASE: 'database_toolkit',\n /** Asset collections management. */\n COLLECTIONS: 'collections_toolkit',\n /** Charts, dashboards, and figures. */\n VISUALIZATIONS: 'visualizations_toolkit',\n /** Custom UI creation. */\n USER_INTERFACE: 'user_interface_toolkit',\n /** Agent Operating Procedures. */\n AOP: 'aop_toolkit',\n /** Ephemeral compute environments. */\n COMPUTER_ASSET: 'computer_asset_toolkit',\n /** Web browser automation. */\n BROWSER: 'browser_toolkit',\n /** Virtual machine management. */\n VM: 'vm_toolkit',\n /** Jupyter notebook execution. */\n NOTEBOOK: 'notebook_toolkit',\n /** Presentation slide editing. */\n PRESENTATION: 'presentation_toolkit',\n /** PowerPoint presentation creation from templates. */\n POWERPOINT: 'powerpoint_deck_toolkit',\n /** PowerPoint presentation creation from templates (pptx-studio). */\n PRESENTATION_PPTX_STUDIO: 'presentation_pptx_studio_toolkit',\n /** Workspace file management (Olympus Drive). */\n DRIVE: 'olympus_drive_toolkit',\n /** Python code execution. */\n PYTHON: 'python_toolkit',\n /** Multi-account email and calendar (Gmail + Outlook). */\n EMAIL: 'unified_email_toolkit',\n /** Legacy email and calendar operations. */\n EMAIL_CALENDAR: 'email_calendar_toolkit',\n /** Spreadsheet operations. */\n SPREADSHEET: 'spreadsheet_toolkit',\n /** Athena document editing. */\n DOCUMENT: 'document_toolkit',\n /** Word document backend operations. */\n WORD_DOCUMENT: 'word_document_be_toolkit',\n /** Go-To-Market management. */\n GTM: 'gtm_toolkit',\n /** Marketing campaign management. */\n MARKETING: 'marketing_toolkit',\n /** FDE implementations and workflows. */\n FDE: 'fde_toolkit',\n /** SharePoint / Google Drive / workspace file access. */\n EXTERNAL_DRIVE: 'external_drive_toolkit',\n /** Reusable playbooks and prompts. */\n PLAYBOOK: 'playbook_toolkit',\n /** Local Chrome browser control via tunnel. */\n DEVICE_TUNNEL: 'device_tunnel_toolkit',\n /** Project management. */\n PROJECTS: 'projects_toolkit',\n /** Task Studio script execution. */\n TASK_STUDIO: 'task_studio_toolkit',\n /** User memory and preferences. */\n PREFERENCES: 'preferences_toolkit',\n} as const;\n\n/** A toolkit ID string. */\nexport type ToolkitId = (typeof Toolkits)[keyof typeof Toolkits];\n\nexport interface ToolkitDisplayInfo {\n id: string;\n name: string;\n description?: string;\n icon?: string;\n}\n\nconst TOOLKIT_DISPLAY_INFO: Record<string, Omit<ToolkitDisplayInfo, 'id'>> = {\n [Toolkits.WEB_SEARCH]: {\n name: 'Web Search',\n description: 'Search the web and inspect pages.',\n icon: 'Globe',\n },\n [Toolkits.SQL]: {\n name: 'SQL',\n description: 'Run structured SQL queries.',\n icon: 'Database',\n },\n [Toolkits.AZURE_BLOB_STORAGE]: {\n name: 'Azure Blob Storage',\n description: 'List, read, and upload Azure Blob Storage catalog files.',\n icon: 'Cloud',\n },\n [Toolkits.COMMENTS]: {\n name: 'Comments',\n description: 'Work with document comments and reviews.',\n icon: 'MessageSquare',\n },\n [Toolkits.CANVAS]: {\n name: 'Canvas',\n description: 'Create and edit visual canvases.',\n icon: 'LayoutGrid',\n },\n [Toolkits.DATABASE]: {\n name: 'Database',\n description: 'Inspect and manage database assets.',\n icon: 'Database',\n },\n [Toolkits.COLLECTIONS]: {\n name: 'Collections',\n description: 'Manage asset collections.',\n icon: 'Boxes',\n },\n [Toolkits.VISUALIZATIONS]: {\n name: 'Visualizations',\n description: 'Create charts, dashboards, and figures.',\n icon: 'ChartBar',\n },\n [Toolkits.USER_INTERFACE]: {\n name: 'User Interface',\n description: 'Build custom user interfaces.',\n icon: 'PanelTop',\n },\n [Toolkits.AOP]: {\n name: 'AOP',\n description: 'Run Agent Operating Procedures.',\n icon: 'Workflow',\n },\n [Toolkits.COMPUTER_ASSET]: {\n name: 'Computer Asset',\n description: 'Provision and operate computer assets.',\n icon: 'Monitor',\n },\n [Toolkits.BROWSER]: {\n name: 'Browser',\n description: 'Control a web browser.',\n icon: 'Globe',\n },\n [Toolkits.VM]: {\n name: 'Virtual Machine',\n description: 'Manage virtual machine environments.',\n icon: 'Server',\n },\n [Toolkits.NOTEBOOK]: {\n name: 'Notebook',\n description: 'Run Jupyter notebook workflows.',\n icon: 'BookOpen',\n },\n [Toolkits.PRESENTATION]: {\n name: 'Presentation',\n description: 'Edit presentation slides.',\n icon: 'Presentation',\n },\n [Toolkits.POWERPOINT]: {\n name: 'PowerPoint',\n description: 'Create PowerPoint decks from templates.',\n icon: 'Presentation',\n },\n [Toolkits.PRESENTATION_PPTX_STUDIO]: {\n name: 'Presentation',\n description: 'Create PowerPoint presentations from templates (pptx-studio).',\n icon: 'Presentation',\n },\n [Toolkits.DRIVE]: {\n name: 'Olympus Drive',\n description: 'Find and manage workspace files.',\n icon: 'Folder',\n },\n [Toolkits.PYTHON]: {\n name: 'Python',\n description: 'Run Python analysis and automation.',\n icon: 'Code2',\n },\n [Toolkits.EMAIL]: {\n name: 'Email',\n description: 'Work across connected email and calendar accounts.',\n icon: 'Mail',\n },\n [Toolkits.EMAIL_CALENDAR]: {\n name: 'Email & Calendar',\n description: 'Use email and calendar operations.',\n icon: 'Calendar',\n },\n [Toolkits.SPREADSHEET]: {\n name: 'Spreadsheet',\n description: 'Create and edit spreadsheets.',\n icon: 'Table2',\n },\n [Toolkits.DOCUMENT]: {\n name: 'Document',\n description: 'Create and edit Athena documents.',\n icon: 'FileText',\n },\n [Toolkits.WORD_DOCUMENT]: {\n name: 'Word Document',\n description: 'Create and edit Word documents.',\n icon: 'FileText',\n },\n [Toolkits.GTM]: {\n name: 'Go-To-Market',\n description: 'Manage go-to-market workflows.',\n icon: 'BriefcaseBusiness',\n },\n [Toolkits.MARKETING]: {\n name: 'Marketing',\n description: 'Manage marketing campaigns.',\n icon: 'Megaphone',\n },\n [Toolkits.FDE]: {\n name: 'FDE',\n description: 'Build FDE implementations and workflows.',\n icon: 'Workflow',\n },\n [Toolkits.EXTERNAL_DRIVE]: {\n name: 'External Drive',\n description: 'Access SharePoint, Google Drive, and other files.',\n icon: 'HardDrive',\n },\n [Toolkits.PLAYBOOK]: {\n name: 'Playbook',\n description: 'Use reusable playbooks and prompts.',\n icon: 'BookOpen',\n },\n [Toolkits.DEVICE_TUNNEL]: {\n name: 'Device Tunnel',\n description: 'Control a local browser through a tunnel.',\n icon: 'Cable',\n },\n [Toolkits.PROJECTS]: {\n name: 'Projects',\n description: 'Manage project work.',\n icon: 'FolderKanban',\n },\n [Toolkits.TASK_STUDIO]: {\n name: 'Task Studio',\n description: 'Run Task Studio scripts.',\n icon: 'Terminal',\n },\n [Toolkits.PREFERENCES]: {\n name: 'Preferences',\n description: 'Use memory and preference tools.',\n icon: 'Settings',\n },\n semantic_model_toolkit: {\n name: 'Semantic Model',\n description: 'Query semantic models and generate analytics.',\n icon: 'ChartBar',\n },\n semantic_model_dev_toolkit: {\n name: 'Semantic Model Development',\n description: 'Create, validate, and deploy semantic model YAML.',\n icon: 'Database',\n },\n};\n\nconst humanizeToolkitId = (id: string): string => {\n const trimmed = id.trim();\n if (!trimmed) {\n return 'Toolkit';\n }\n\n const withoutSuffix = trimmed.replace(/_toolkit$/, '');\n return withoutSuffix\n .split(/[_-]+/)\n .filter(Boolean)\n .map((word) => {\n if (word.length <= 3) {\n return word.toUpperCase();\n }\n return `${word.charAt(0).toUpperCase()}${word.slice(1)}`;\n })\n .join(' ');\n};\n\nexport const getToolkitDisplayInfo = (id: string): ToolkitDisplayInfo => {\n const info = TOOLKIT_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IACA,OAAM,6BAAM,SAAQ,kBAAkB,EAAE;AAAA,IACxC,aAAa,6BAAM;AAAA,IACnB,OAAM,6BAAM,SAAQ;AAAA,EAAA;AAExB;"}
|
package/dist/voice/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createAthenaVoiceSession, useAthenaVoiceSession, } from './use-athena-voice-session';
|
|
2
|
-
export type { AthenaVoiceSessionConfig, AthenaVoiceSessionCredentials, AthenaVoiceSessionStatus, AthenaVoiceSpeaker, AthenaVoiceTranscriptTurn, UseAthenaVoiceSessionOptions, UseAthenaVoiceSessionReturn, } from './use-athena-voice-session';
|
|
2
|
+
export type { AthenaVoiceSessionConfig, AthenaVoiceSessionCredentials, AthenaVoiceSessionStatus, AthenaVoiceSpeaker, AthenaVoiceToolId, AthenaVoiceTranscriptTurn, UseAthenaVoiceSessionOptions, UseAthenaVoiceSessionReturn, } from './use-athena-voice-session';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-athena-voice-session.cjs","sources":["../../src/voice/use-athena-voice-session.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n Room,\n RoomEvent,\n Track,\n type Participant,\n type RemoteTrack,\n type TranscriptionSegment,\n} from 'livekit-client';\nimport { useParentBridge, type ParentBridgeState } from '../runtime/auth';\n\n/**\n * LiveKit connection details for one Athena voice session. This is the shape\n * Orpheus returns from `POST /api/orpheus/create-session`; the hook only reads\n * these fields, so any server that proxies that call can hand it straight back.\n */\nexport interface AthenaVoiceSessionCredentials {\n /** LiveKit signalling URL (`wss://…`). */\n server_url: string;\n /** Short-lived LiveKit participant JWT scoped to `room_name`. */\n token: string;\n room_name?: string;\n /**\n * Athena session asset the voice run is persisted into. Use it with\n * `GET /api/v0/sessions/{asset_id}/download` to retrieve the transcript\n * after the call.\n */\n asset_id?: string;\n}\n\nexport type AthenaVoiceSessionStatus =\n | 'idle'\n | 'connecting'\n | 'connected'\n | 'reconnecting'\n | 'ended'\n | 'error';\n\nexport type AthenaVoiceSpeaker = 'user' | 'agent';\n\n/** One committed (final) transcription segment from either side of the call. */\nexport interface AthenaVoiceTranscriptTurn {\n id: string;\n speaker: AthenaVoiceSpeaker;\n text: string;\n /** Segment start, in ms since the LiveKit room's epoch. */\n startTime: number;\n endTime: number;\n language: string;\n}\n\n/**\n * Orpheus agent configuration for a session the hook creates itself (see\n * `UseAthenaVoiceSessionOptions.session`). Mirrors the body of\n * `POST /api/orpheus/create-session`; every field is optional and falls back\n * to the server default.\n */\nexport interface AthenaVoiceSessionConfig {\n /** Persona / instructions for the voice agent. */\n system_prompt?: string;\n /** Realtime provider, e.g. `'openai'` or `'google'`. */\n provider?: string;\n /** Provider model id, e.g. `'gpt-realtime-2'`. */\n model?: string;\n /** Provider voice id, e.g. `'marin'` (OpenAI) or `'Aoede'` (Google). */\n voice?: string;\n temperature?: number;\n /** BCP-47 language tag; default `'en'`. */\n language?: string;\n /** Athena tool ids the agent may call; default none. */\n enabled_tools?: string[];\n /** IANA timezone of the speaker, e.g. `'America/New_York'`. */\n timezone?: string;\n}\n\nexport interface UseAthenaVoiceSessionOptions {\n /**\n * Creates the LiveKit session. Omit it when the app is served from a\n * Marathon computer-asset URL: the hook then calls\n * `POST {backendBaseUrl}/api/orpheus/create-session` itself with the\n * viewer's bearer token from `/_athena/auth`, so the session is created as\n * — and shows up in the sessions of — whoever is using the app.\n *\n * Works for workspace members and external SSO viewers alike: the scoped\n * `athview_` viewer credential is authorized for the Orpheus route and\n * `agents/general/invoke` the same way it is for `/api/v0/sessions`.\n *\n * Supply it when the app runs anywhere else (standalone, custom auth): it\n * should run on the caller's own server so the Athena API key never reaches\n * the browser. The hook only reads the returned credentials.\n *\n * Decide once: switching between supplying and omitting it across renders\n * of the same component is not supported.\n */\n createSession?: (\n signal: AbortSignal,\n ) => Promise<AthenaVoiceSessionCredentials>;\n /**\n * Agent configuration for sessions the hook creates itself. Ignored when\n * `createSession` is supplied.\n */\n session?: AthenaVoiceSessionConfig;\n /** Called once per committed transcript turn, in arrival order. */\n onTranscript?: (turn: AthenaVoiceTranscriptTurn) => void;\n /** Called with interim (non-final) transcript text as it streams in. */\n onInterimTranscript?: (speaker: AthenaVoiceSpeaker, text: string) => void;\n onError?: (error: Error) => void;\n /**\n * Where to play the agent's audio. Defaults to a detached `<audio>` element\n * the hook creates and removes itself.\n */\n audioElement?: HTMLMediaElement | null;\n /** Enable the microphone as soon as the room connects. Default `true`. */\n autoEnableMicrophone?: boolean;\n /** @internal Overrides `new Room()`; used by tests. */\n createRoom?: () => Room;\n /** @internal Overrides `useParentBridge()`; used by tests. */\n useBridge?: () => ParentBridgeState;\n}\n\nexport interface UseAthenaVoiceSessionReturn {\n status: AthenaVoiceSessionStatus;\n /** True between `start()` resolving the session and the room connecting. */\n isConnecting: boolean;\n isConnected: boolean;\n /** Who is speaking right now, or `null` when the room is quiet. */\n activeSpeaker: AthenaVoiceSpeaker | null;\n isMuted: boolean;\n /** Committed transcript turns so far, in arrival order. */\n transcript: AthenaVoiceTranscriptTurn[];\n /** Athena session asset id, once the session has been created. */\n sessionId: string | null;\n roomName: string | null;\n error: Error | null;\n /** Creates a session and joins the room. No-op while a session is live. */\n start: () => Promise<void>;\n /** Leaves the room and stops local tracks. Safe to call at any time. */\n stop: () => Promise<void>;\n mute: () => Promise<void>;\n unmute: () => Promise<void>;\n /** Clears `transcript`; does not affect the live session. */\n clearTranscript: () => void;\n}\n\nconst toError = (value: unknown): Error =>\n value instanceof Error ? value : new Error(String(value));\n\nconst NO_BRIDGE: ParentBridgeState = {\n token: null,\n statewireSyncUrl: null,\n backendBaseUrl: null,\n appUrl: null,\n hostAnswered: false,\n ready: true,\n};\n// Stands in for `useParentBridge` when the caller creates sessions itself, so\n// the hook never fetches `/_athena/auth` it would not use.\nconst useNoBridge = (): ParentBridgeState => NO_BRIDGE;\n\nconst NO_VIEWER_TOKEN_MESSAGE =\n 'useAthenaVoiceSession: no Athena viewer token. Either serve the app from ' +\n 'a Marathon computer-asset URL (which mints one via /_athena/auth) or pass ' +\n '`createSession` to create the session through your own server.';\n\n/**\n * `POST /api/orpheus/create-session` as the current viewer. Exported so apps\n * with their own bridge state (or a server proxy holding a user bearer) can\n * reuse the exact request the hook makes.\n */\nexport const createAthenaVoiceSession = async ({\n backendBaseUrl,\n token,\n session = {},\n signal,\n}: {\n /** Bare Agora API base, e.g. `https://api.athenaintel.com`. */\n backendBaseUrl: string;\n /** Bearer token for the user the session belongs to. */\n token: string;\n session?: AthenaVoiceSessionConfig;\n signal?: AbortSignal;\n}): Promise<AthenaVoiceSessionCredentials> => {\n const url: string = `${backendBaseUrl.replace(/\\/+$/, '')}/api/orpheus/create-session`;\n const response: Response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify(session),\n signal,\n });\n if (!response.ok) {\n const detail: string = await response.text().catch(() => '');\n throw new Error(\n `Orpheus create-session failed (${response.status})${detail ? `: ${detail}` : ''}`,\n );\n }\n return (await response.json()) as AthenaVoiceSessionCredentials;\n};\n\nconst speakerOf = (\n participant: Participant | undefined,\n room: Room,\n): AthenaVoiceSpeaker =>\n participant !== undefined &&\n participant.identity === room.localParticipant.identity\n ? 'user'\n : 'agent';\n\n/**\n * Runs one Athena voice session (Orpheus agent over LiveKit) from React.\n *\n * Owns the whole browser-side lifecycle the Orpheus API leaves to the caller:\n * creating the session through the app's own server, joining the LiveKit room,\n * publishing the microphone, playing the agent's audio, tracking who is\n * speaking, committing transcript turns from LiveKit transcription events, and\n * tearing everything down on `stop()` or unmount. A second `start()` while a\n * session is live (or still connecting) is ignored, so React StrictMode's\n * double-invoked effects cannot dispatch two agents into one room.\n */\nexport const useAthenaVoiceSession = (\n options: UseAthenaVoiceSessionOptions = {},\n): UseAthenaVoiceSessionReturn => {\n const {\n createSession,\n session,\n onTranscript,\n onInterimTranscript,\n onError,\n audioElement,\n autoEnableMicrophone = true,\n createRoom,\n useBridge = createSession ? useNoBridge : useParentBridge,\n } = options;\n\n // Viewer identity minted by Marathon (`/_athena/auth`) or the Olympus iframe\n // bridge. Only consulted when the caller did not supply `createSession`.\n const bridge: ParentBridgeState = useBridge();\n const bridgeRef = useRef<ParentBridgeState>(bridge);\n bridgeRef.current = bridge;\n const bridgeReadyWaitersRef = useRef<Array<() => void>>([]);\n useEffect(() => {\n if (!bridge.ready) return;\n const waiters: Array<() => void> = bridgeReadyWaitersRef.current;\n bridgeReadyWaitersRef.current = [];\n for (const resolve of waiters) resolve();\n }, [bridge.ready]);\n\n const sessionRef = useRef<AthenaVoiceSessionConfig | undefined>(session);\n sessionRef.current = session;\n\n const createSessionAsViewer = useCallback(\n async (signal: AbortSignal): Promise<AthenaVoiceSessionCredentials> => {\n if (!bridgeRef.current.ready) {\n await new Promise<void>((resolve) => {\n bridgeReadyWaitersRef.current.push(resolve);\n signal.addEventListener('abort', () => resolve(), { once: true });\n });\n if (signal.aborted) throw new Error('aborted');\n }\n const { token, backendBaseUrl } = bridgeRef.current;\n if (!token || !backendBaseUrl) throw new Error(NO_VIEWER_TOKEN_MESSAGE);\n return createAthenaVoiceSession({\n backendBaseUrl,\n token,\n session: sessionRef.current,\n signal,\n });\n },\n [],\n );\n\n const [status, setStatus] = useState<AthenaVoiceSessionStatus>('idle');\n const [activeSpeaker, setActiveSpeaker] = useState<AthenaVoiceSpeaker | null>(\n null,\n );\n const [isMuted, setIsMuted] = useState<boolean>(false);\n const [transcript, setTranscript] = useState<AthenaVoiceTranscriptTurn[]>([]);\n const [sessionId, setSessionId] = useState<string | null>(null);\n const [roomName, setRoomName] = useState<string | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n // Latest callbacks without re-subscribing room listeners on every render.\n const callbacksRef = useRef({\n createSession: createSession ?? createSessionAsViewer,\n onTranscript,\n onInterimTranscript,\n onError,\n });\n callbacksRef.current = {\n createSession: createSession ?? createSessionAsViewer,\n onTranscript,\n onInterimTranscript,\n onError,\n };\n\n const roomRef = useRef<Room | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const attachedElementsRef = useRef<HTMLMediaElement[]>([]);\n const ownedAudioRef = useRef<HTMLMediaElement | null>(null);\n const committedSegmentIdsRef = useRef<Set<string>>(new Set());\n // Guards `start()` against re-entry from the moment it is called, before any\n // state update lands — a StrictMode double effect fires both calls\n // synchronously in the same tick.\n const startingRef = useRef<boolean>(false);\n\n const fail = useCallback((cause: unknown) => {\n const err: Error = toError(cause);\n setError(err);\n setStatus('error');\n callbacksRef.current.onError?.(err);\n }, []);\n\n const detachAudio = useCallback(() => {\n for (const element of attachedElementsRef.current) {\n element.srcObject = null;\n if (element === ownedAudioRef.current) element.remove();\n }\n attachedElementsRef.current = [];\n ownedAudioRef.current = null;\n }, []);\n\n const teardown = useCallback(async () => {\n abortRef.current?.abort();\n abortRef.current = null;\n const room: Room | null = roomRef.current;\n roomRef.current = null;\n startingRef.current = false;\n detachAudio();\n if (room) {\n room.removeAllListeners();\n await room.disconnect(true);\n }\n }, [detachAudio]);\n\n const stop = useCallback(async () => {\n const hadRoom: boolean =\n roomRef.current !== null || abortRef.current !== null;\n await teardown();\n setActiveSpeaker(null);\n if (hadRoom) setStatus('ended');\n }, [teardown]);\n\n const attachTrack = useCallback(\n (track: RemoteTrack) => {\n if (track.kind !== Track.Kind.Audio) return;\n if (audioElement) {\n track.attach(audioElement);\n attachedElementsRef.current.push(audioElement);\n return;\n }\n const element: HTMLMediaElement = track.attach();\n element.setAttribute('data-athena-voice-audio', '');\n document.body.appendChild(element);\n ownedAudioRef.current = element;\n attachedElementsRef.current.push(element);\n },\n [audioElement],\n );\n\n const handleTranscription = useCallback(\n (\n segments: TranscriptionSegment[],\n participant: Participant | undefined,\n room: Room,\n ) => {\n const speaker: AthenaVoiceSpeaker = speakerOf(participant, room);\n const committed: AthenaVoiceTranscriptTurn[] = [];\n for (const segment of segments) {\n if (!segment.final) {\n callbacksRef.current.onInterimTranscript?.(speaker, segment.text);\n continue;\n }\n if (committedSegmentIdsRef.current.has(segment.id)) continue;\n committedSegmentIdsRef.current.add(segment.id);\n committed.push({\n id: segment.id,\n speaker,\n text: segment.text,\n startTime: segment.startTime,\n endTime: segment.endTime,\n language: segment.language,\n });\n }\n if (committed.length === 0) return;\n setTranscript((previous) => [...previous, ...committed]);\n for (const turn of committed) callbacksRef.current.onTranscript?.(turn);\n },\n [],\n );\n\n const start = useCallback(async () => {\n if (startingRef.current || roomRef.current) return;\n startingRef.current = true;\n setError(null);\n setSessionId(null);\n setRoomName(null);\n setStatus('connecting');\n\n const controller = new AbortController();\n abortRef.current = controller;\n\n let credentials: AthenaVoiceSessionCredentials;\n try {\n credentials = await callbacksRef.current.createSession(controller.signal);\n } catch (cause) {\n if (controller.signal.aborted) return;\n abortRef.current = null;\n startingRef.current = false;\n fail(cause);\n return;\n }\n if (controller.signal.aborted) return;\n\n setSessionId(credentials.asset_id ?? null);\n setRoomName(credentials.room_name ?? null);\n\n const room: Room = createRoom ? createRoom() : new Room();\n roomRef.current = room;\n\n room\n .on(RoomEvent.TrackSubscribed, attachTrack)\n .on(RoomEvent.ActiveSpeakersChanged, (speakers: Participant[]) => {\n const first: Participant | undefined = speakers[0];\n setActiveSpeaker(first ? speakerOf(first, room) : null);\n })\n .on(RoomEvent.TranscriptionReceived, (segments, participant) =>\n handleTranscription(segments, participant, room),\n )\n .on(RoomEvent.Reconnecting, () => setStatus('reconnecting'))\n .on(RoomEvent.Reconnected, () => setStatus('connected'))\n .on(RoomEvent.Disconnected, () => {\n if (roomRef.current !== room) return;\n roomRef.current = null;\n startingRef.current = false;\n detachAudio();\n setActiveSpeaker(null);\n setStatus('ended');\n })\n .on(RoomEvent.MediaDevicesError, fail);\n\n try {\n await room.connect(credentials.server_url, credentials.token);\n if (controller.signal.aborted) return;\n if (autoEnableMicrophone) {\n await room.localParticipant.setMicrophoneEnabled(true);\n setIsMuted(false);\n } else {\n setIsMuted(true);\n }\n if (controller.signal.aborted) return;\n abortRef.current = null;\n startingRef.current = false;\n setStatus('connected');\n } catch (cause) {\n if (controller.signal.aborted) return;\n await teardown();\n fail(cause);\n }\n }, [\n attachTrack,\n autoEnableMicrophone,\n createRoom,\n detachAudio,\n fail,\n handleTranscription,\n teardown,\n ]);\n\n const setMicrophone = useCallback(async (enabled: boolean) => {\n const room: Room | null = roomRef.current;\n if (!room) return;\n await room.localParticipant.setMicrophoneEnabled(enabled);\n setIsMuted(!enabled);\n }, []);\n const mute = useCallback(() => setMicrophone(false), [setMicrophone]);\n const unmute = useCallback(() => setMicrophone(true), [setMicrophone]);\n\n const clearTranscript = useCallback(() => {\n committedSegmentIdsRef.current.clear();\n setTranscript([]);\n }, []);\n\n // Unmount teardown is deferred one tick so StrictMode's synchronous\n // unmount/remount of the same instance does not abort an in-flight\n // `createSession` (which would dispatch a second Orpheus agent on remount).\n const unmountTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => {\n if (unmountTimerRef.current !== null) {\n clearTimeout(unmountTimerRef.current);\n unmountTimerRef.current = null;\n }\n return () => {\n unmountTimerRef.current = setTimeout(() => {\n unmountTimerRef.current = null;\n void teardown();\n }, 0);\n };\n }, [teardown]);\n\n return useMemo<UseAthenaVoiceSessionReturn>(\n () => ({\n status,\n isConnecting: status === 'connecting',\n isConnected: status === 'connected' || status === 'reconnecting',\n activeSpeaker,\n isMuted,\n transcript,\n sessionId,\n roomName,\n error,\n start,\n stop,\n mute,\n unmute,\n clearTranscript,\n }),\n [\n status,\n activeSpeaker,\n isMuted,\n transcript,\n sessionId,\n roomName,\n error,\n start,\n stop,\n mute,\n unmute,\n clearTranscript,\n ],\n );\n};\n"],"names":["useParentBridge","useRef","useEffect","useCallback","useState","Track","Room","RoomEvent","useMemo"],"mappings":";;;;;AAgJA,MAAM,UAAU,CAAC,UACf,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAE1D,MAAM,YAA+B;AAAA,EACnC,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,gBAAg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,MAClD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;;;"}
|
|
1
|
+
{"version":3,"file":"use-athena-voice-session.cjs","sources":["../../src/voice/use-athena-voice-session.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n Room,\n RoomEvent,\n Track,\n type Participant,\n type RemoteTrack,\n type TranscriptionSegment,\n} from 'livekit-client';\nimport { useParentBridge, type ParentBridgeState } from '../runtime/auth';\n\n/**\n * LiveKit connection details for one Athena voice session. This is the shape\n * Orpheus returns from `POST /api/orpheus/create-session`; the hook only reads\n * these fields, so any server that proxies that call can hand it straight back.\n */\nexport interface AthenaVoiceSessionCredentials {\n /** LiveKit signalling URL (`wss://…`). */\n server_url: string;\n /** Short-lived LiveKit participant JWT scoped to `room_name`. */\n token: string;\n room_name?: string;\n /**\n * Athena session asset the voice run is persisted into. Use it with\n * `GET /api/v0/sessions/{asset_id}/download` to retrieve the transcript\n * after the call.\n */\n asset_id?: string;\n}\n\nexport type AthenaVoiceSessionStatus =\n | 'idle'\n | 'connecting'\n | 'connected'\n | 'reconnecting'\n | 'ended'\n | 'error';\n\nexport type AthenaVoiceSpeaker = 'user' | 'agent';\n\n/** One committed (final) transcription segment from either side of the call. */\nexport interface AthenaVoiceTranscriptTurn {\n id: string;\n speaker: AthenaVoiceSpeaker;\n text: string;\n /** Segment start, in ms since the LiveKit room's epoch. */\n startTime: number;\n endTime: number;\n language: string;\n}\n\n/**\n * A voice tool the Orpheus worker can run for the agent. These are voice tool\n * names, not the chat `Toolkits` ids: `'web_search_browse_toolkit'` is not a\n * voice tool, `'web_search'` is. Only these names are accepted.\n *\n * The worker also has tools that call back into the client over LiveKit RPC\n * (`write_to_clipboard`, `replace_current_selection`, `open_in_olympus`,\n * `open_asset`, `get_screen_contents`). This hook registers no RPC handlers,\n * so they are not part of its contract.\n */\nexport type AthenaVoiceToolId =\n /** Web search (Exa). */\n | 'web_search'\n /** Legacy alias of `web_search`; prefer `web_search`. */\n | 'search_web'\n /** Fetch and read one URL. */\n | 'browse'\n /** The workspace knowledge base (Ragie), where configured. */\n | 'search_knowledge_base'\n /** Same knowledge base, thorough long-running retrieval. */\n | 'search_knowledge_base_lr'\n /** Read Athena assets by id, as the viewer. */\n | 'read_full_asset'\n /** Search the viewer's Athena assets. */\n | 'search_assets'\n /** Hand a question to the general agent and speak its answer. */\n | 'ask_agent'\n /** Save a note for the user (a stub on the worker today). */\n | 'save_note'\n /** Current date and time, Eastern. */\n | 'get_current_time_est';\n\n/**\n * Orpheus agent configuration for a session the hook creates itself (see\n * `UseAthenaVoiceSessionOptions.session`). Mirrors the body of\n * `POST /api/orpheus/create-session`; every field is optional and falls back\n * to the server default.\n */\nexport interface AthenaVoiceSessionConfig {\n /** Persona / instructions for the voice agent. */\n system_prompt?: string;\n /** Realtime provider, e.g. `'openai'` or `'google'`. */\n provider?: string;\n /** Provider model id, e.g. `'gpt-realtime-2'`. */\n model?: string;\n /** Provider voice id, e.g. `'marin'` (OpenAI) or `'Aoede'` (Google). */\n voice?: string;\n temperature?: number;\n /** BCP-47 language tag; default `'en'`. */\n language?: string;\n /**\n * Voice tools the agent may call. Omit it for the server's default set\n * (`web_search`, `search_knowledge_base`, `ask_agent`, …); pass `[]` for a\n * pure conversation with no tool calls.\n */\n enabled_tools?: AthenaVoiceToolId[];\n /** IANA timezone of the speaker, e.g. `'America/New_York'`. */\n timezone?: string;\n}\n\nexport interface UseAthenaVoiceSessionOptions {\n /**\n * Creates the LiveKit session. Omit it when the app is served from a\n * Marathon computer-asset URL: the hook then calls\n * `POST {backendBaseUrl}/api/orpheus/create-session` itself with the\n * viewer's bearer token from `/_athena/auth`, so the session is created as\n * — and shows up in the sessions of — whoever is using the app.\n *\n * Works for workspace members and external SSO viewers alike: the scoped\n * `athview_` viewer credential is authorized for the Orpheus route and\n * `agents/general/invoke` the same way it is for `/api/v0/sessions`.\n *\n * Supply it when the app runs anywhere else (standalone, custom auth): it\n * should run on the caller's own server so the Athena API key never reaches\n * the browser. The hook only reads the returned credentials.\n *\n * Decide once: switching between supplying and omitting it across renders\n * of the same component is not supported.\n */\n createSession?: (\n signal: AbortSignal,\n ) => Promise<AthenaVoiceSessionCredentials>;\n /**\n * Agent configuration for sessions the hook creates itself. Ignored when\n * `createSession` is supplied.\n */\n session?: AthenaVoiceSessionConfig;\n /** Called once per committed transcript turn, in arrival order. */\n onTranscript?: (turn: AthenaVoiceTranscriptTurn) => void;\n /** Called with interim (non-final) transcript text as it streams in. */\n onInterimTranscript?: (speaker: AthenaVoiceSpeaker, text: string) => void;\n onError?: (error: Error) => void;\n /**\n * Where to play the agent's audio. Defaults to a detached `<audio>` element\n * the hook creates and removes itself.\n */\n audioElement?: HTMLMediaElement | null;\n /** Enable the microphone as soon as the room connects. Default `true`. */\n autoEnableMicrophone?: boolean;\n /** @internal Overrides `new Room()`; used by tests. */\n createRoom?: () => Room;\n /** @internal Overrides `useParentBridge()`; used by tests. */\n useBridge?: () => ParentBridgeState;\n}\n\nexport interface UseAthenaVoiceSessionReturn {\n status: AthenaVoiceSessionStatus;\n /** True between `start()` resolving the session and the room connecting. */\n isConnecting: boolean;\n isConnected: boolean;\n /** Who is speaking right now, or `null` when the room is quiet. */\n activeSpeaker: AthenaVoiceSpeaker | null;\n isMuted: boolean;\n /** Committed transcript turns so far, in arrival order. */\n transcript: AthenaVoiceTranscriptTurn[];\n /** Athena session asset id, once the session has been created. */\n sessionId: string | null;\n roomName: string | null;\n error: Error | null;\n /** Creates a session and joins the room. No-op while a session is live. */\n start: () => Promise<void>;\n /** Leaves the room and stops local tracks. Safe to call at any time. */\n stop: () => Promise<void>;\n mute: () => Promise<void>;\n unmute: () => Promise<void>;\n /** Clears `transcript`; does not affect the live session. */\n clearTranscript: () => void;\n}\n\nconst toError = (value: unknown): Error =>\n value instanceof Error ? value : new Error(String(value));\n\nconst NO_BRIDGE: ParentBridgeState = {\n token: null,\n statewireSyncUrl: null,\n backendBaseUrl: null,\n appUrl: null,\n hostAnswered: false,\n ready: true,\n};\n// Stands in for `useParentBridge` when the caller creates sessions itself, so\n// the hook never fetches `/_athena/auth` it would not use.\nconst useNoBridge = (): ParentBridgeState => NO_BRIDGE;\n\nconst NO_VIEWER_TOKEN_MESSAGE =\n 'useAthenaVoiceSession: no Athena viewer token. Either serve the app from ' +\n 'a Marathon computer-asset URL (which mints one via /_athena/auth) or pass ' +\n '`createSession` to create the session through your own server.';\n\n/**\n * `POST /api/orpheus/create-session` as the current viewer. Exported so apps\n * with their own bridge state (or a server proxy holding a user bearer) can\n * reuse the exact request the hook makes.\n */\nexport const createAthenaVoiceSession = async ({\n backendBaseUrl,\n token,\n session = {},\n signal,\n}: {\n /** Bare Agora API base, e.g. `https://api.athenaintel.com`. */\n backendBaseUrl: string;\n /** Bearer token for the user the session belongs to. */\n token: string;\n session?: AthenaVoiceSessionConfig;\n signal?: AbortSignal;\n}): Promise<AthenaVoiceSessionCredentials> => {\n const url: string = `${backendBaseUrl.replace(/\\/+$/, '')}/api/orpheus/create-session`;\n const response: Response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify(session),\n signal,\n });\n if (!response.ok) {\n const detail: string = await response.text().catch(() => '');\n throw new Error(\n `Orpheus create-session failed (${response.status})${detail ? `: ${detail}` : ''}`,\n );\n }\n return (await response.json()) as AthenaVoiceSessionCredentials;\n};\n\nconst speakerOf = (\n participant: Participant | undefined,\n room: Room,\n): AthenaVoiceSpeaker =>\n participant !== undefined &&\n participant.identity === room.localParticipant.identity\n ? 'user'\n : 'agent';\n\n/**\n * Runs one Athena voice session (Orpheus agent over LiveKit) from React.\n *\n * Owns the whole browser-side lifecycle the Orpheus API leaves to the caller:\n * creating the session through the app's own server, joining the LiveKit room,\n * publishing the microphone, playing the agent's audio, tracking who is\n * speaking, committing transcript turns from LiveKit transcription events, and\n * tearing everything down on `stop()` or unmount. A second `start()` while a\n * session is live (or still connecting) is ignored, so React StrictMode's\n * double-invoked effects cannot dispatch two agents into one room.\n */\nexport const useAthenaVoiceSession = (\n options: UseAthenaVoiceSessionOptions = {},\n): UseAthenaVoiceSessionReturn => {\n const {\n createSession,\n session,\n onTranscript,\n onInterimTranscript,\n onError,\n audioElement,\n autoEnableMicrophone = true,\n createRoom,\n useBridge = createSession ? useNoBridge : useParentBridge,\n } = options;\n\n // Viewer identity minted by Marathon (`/_athena/auth`) or the Olympus iframe\n // bridge. Only consulted when the caller did not supply `createSession`.\n const bridge: ParentBridgeState = useBridge();\n const bridgeRef = useRef<ParentBridgeState>(bridge);\n bridgeRef.current = bridge;\n const bridgeReadyWaitersRef = useRef<Array<() => void>>([]);\n useEffect(() => {\n if (!bridge.ready) return;\n const waiters: Array<() => void> = bridgeReadyWaitersRef.current;\n bridgeReadyWaitersRef.current = [];\n for (const resolve of waiters) resolve();\n }, [bridge.ready]);\n\n const sessionRef = useRef<AthenaVoiceSessionConfig | undefined>(session);\n sessionRef.current = session;\n\n const createSessionAsViewer = useCallback(\n async (signal: AbortSignal): Promise<AthenaVoiceSessionCredentials> => {\n if (!bridgeRef.current.ready) {\n await new Promise<void>((resolve) => {\n bridgeReadyWaitersRef.current.push(resolve);\n signal.addEventListener('abort', () => resolve(), { once: true });\n });\n if (signal.aborted) throw new Error('aborted');\n }\n const { token, backendBaseUrl } = bridgeRef.current;\n if (!token || !backendBaseUrl) throw new Error(NO_VIEWER_TOKEN_MESSAGE);\n return createAthenaVoiceSession({\n backendBaseUrl,\n token,\n session: sessionRef.current,\n signal,\n });\n },\n [],\n );\n\n const [status, setStatus] = useState<AthenaVoiceSessionStatus>('idle');\n const [activeSpeaker, setActiveSpeaker] = useState<AthenaVoiceSpeaker | null>(\n null,\n );\n const [isMuted, setIsMuted] = useState<boolean>(false);\n const [transcript, setTranscript] = useState<AthenaVoiceTranscriptTurn[]>([]);\n const [sessionId, setSessionId] = useState<string | null>(null);\n const [roomName, setRoomName] = useState<string | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n // Latest callbacks without re-subscribing room listeners on every render.\n const callbacksRef = useRef({\n createSession: createSession ?? createSessionAsViewer,\n onTranscript,\n onInterimTranscript,\n onError,\n });\n callbacksRef.current = {\n createSession: createSession ?? createSessionAsViewer,\n onTranscript,\n onInterimTranscript,\n onError,\n };\n\n const roomRef = useRef<Room | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const attachedElementsRef = useRef<HTMLMediaElement[]>([]);\n const ownedAudioRef = useRef<HTMLMediaElement | null>(null);\n const committedSegmentIdsRef = useRef<Set<string>>(new Set());\n // Guards `start()` against re-entry from the moment it is called, before any\n // state update lands — a StrictMode double effect fires both calls\n // synchronously in the same tick.\n const startingRef = useRef<boolean>(false);\n\n const fail = useCallback((cause: unknown) => {\n const err: Error = toError(cause);\n setError(err);\n setStatus('error');\n callbacksRef.current.onError?.(err);\n }, []);\n\n const detachAudio = useCallback(() => {\n for (const element of attachedElementsRef.current) {\n element.srcObject = null;\n if (element === ownedAudioRef.current) element.remove();\n }\n attachedElementsRef.current = [];\n ownedAudioRef.current = null;\n }, []);\n\n const teardown = useCallback(async () => {\n abortRef.current?.abort();\n abortRef.current = null;\n const room: Room | null = roomRef.current;\n roomRef.current = null;\n startingRef.current = false;\n detachAudio();\n if (room) {\n room.removeAllListeners();\n await room.disconnect(true);\n }\n }, [detachAudio]);\n\n const stop = useCallback(async () => {\n const hadRoom: boolean =\n roomRef.current !== null || abortRef.current !== null;\n await teardown();\n setActiveSpeaker(null);\n if (hadRoom) setStatus('ended');\n }, [teardown]);\n\n const attachTrack = useCallback(\n (track: RemoteTrack) => {\n if (track.kind !== Track.Kind.Audio) return;\n if (audioElement) {\n track.attach(audioElement);\n attachedElementsRef.current.push(audioElement);\n return;\n }\n const element: HTMLMediaElement = track.attach();\n element.setAttribute('data-athena-voice-audio', '');\n document.body.appendChild(element);\n ownedAudioRef.current = element;\n attachedElementsRef.current.push(element);\n },\n [audioElement],\n );\n\n const handleTranscription = useCallback(\n (\n segments: TranscriptionSegment[],\n participant: Participant | undefined,\n room: Room,\n ) => {\n const speaker: AthenaVoiceSpeaker = speakerOf(participant, room);\n const committed: AthenaVoiceTranscriptTurn[] = [];\n for (const segment of segments) {\n if (!segment.final) {\n callbacksRef.current.onInterimTranscript?.(speaker, segment.text);\n continue;\n }\n if (committedSegmentIdsRef.current.has(segment.id)) continue;\n committedSegmentIdsRef.current.add(segment.id);\n committed.push({\n id: segment.id,\n speaker,\n text: segment.text,\n startTime: segment.startTime,\n endTime: segment.endTime,\n language: segment.language,\n });\n }\n if (committed.length === 0) return;\n setTranscript((previous) => [...previous, ...committed]);\n for (const turn of committed) callbacksRef.current.onTranscript?.(turn);\n },\n [],\n );\n\n const start = useCallback(async () => {\n if (startingRef.current || roomRef.current) return;\n startingRef.current = true;\n setError(null);\n setSessionId(null);\n setRoomName(null);\n setStatus('connecting');\n\n const controller = new AbortController();\n abortRef.current = controller;\n\n let credentials: AthenaVoiceSessionCredentials;\n try {\n credentials = await callbacksRef.current.createSession(controller.signal);\n } catch (cause) {\n if (controller.signal.aborted) return;\n abortRef.current = null;\n startingRef.current = false;\n fail(cause);\n return;\n }\n if (controller.signal.aborted) return;\n\n setSessionId(credentials.asset_id ?? null);\n setRoomName(credentials.room_name ?? null);\n\n const room: Room = createRoom ? createRoom() : new Room();\n roomRef.current = room;\n\n room\n .on(RoomEvent.TrackSubscribed, attachTrack)\n .on(RoomEvent.ActiveSpeakersChanged, (speakers: Participant[]) => {\n const first: Participant | undefined = speakers[0];\n setActiveSpeaker(first ? speakerOf(first, room) : null);\n })\n .on(RoomEvent.TranscriptionReceived, (segments, participant) =>\n handleTranscription(segments, participant, room),\n )\n .on(RoomEvent.Reconnecting, () => setStatus('reconnecting'))\n .on(RoomEvent.Reconnected, () => setStatus('connected'))\n .on(RoomEvent.Disconnected, () => {\n if (roomRef.current !== room) return;\n roomRef.current = null;\n startingRef.current = false;\n detachAudio();\n setActiveSpeaker(null);\n setStatus('ended');\n })\n .on(RoomEvent.MediaDevicesError, fail);\n\n try {\n await room.connect(credentials.server_url, credentials.token);\n if (controller.signal.aborted) return;\n if (autoEnableMicrophone) {\n await room.localParticipant.setMicrophoneEnabled(true);\n setIsMuted(false);\n } else {\n setIsMuted(true);\n }\n if (controller.signal.aborted) return;\n abortRef.current = null;\n startingRef.current = false;\n setStatus('connected');\n } catch (cause) {\n if (controller.signal.aborted) return;\n await teardown();\n fail(cause);\n }\n }, [\n attachTrack,\n autoEnableMicrophone,\n createRoom,\n detachAudio,\n fail,\n handleTranscription,\n teardown,\n ]);\n\n const setMicrophone = useCallback(async (enabled: boolean) => {\n const room: Room | null = roomRef.current;\n if (!room) return;\n await room.localParticipant.setMicrophoneEnabled(enabled);\n setIsMuted(!enabled);\n }, []);\n const mute = useCallback(() => setMicrophone(false), [setMicrophone]);\n const unmute = useCallback(() => setMicrophone(true), [setMicrophone]);\n\n const clearTranscript = useCallback(() => {\n committedSegmentIdsRef.current.clear();\n setTranscript([]);\n }, []);\n\n // Unmount teardown is deferred one tick so StrictMode's synchronous\n // unmount/remount of the same instance does not abort an in-flight\n // `createSession` (which would dispatch a second Orpheus agent on remount).\n const unmountTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => {\n if (unmountTimerRef.current !== null) {\n clearTimeout(unmountTimerRef.current);\n unmountTimerRef.current = null;\n }\n return () => {\n unmountTimerRef.current = setTimeout(() => {\n unmountTimerRef.current = null;\n void teardown();\n }, 0);\n };\n }, [teardown]);\n\n return useMemo<UseAthenaVoiceSessionReturn>(\n () => ({\n status,\n isConnecting: status === 'connecting',\n isConnected: status === 'connected' || status === 'reconnecting',\n activeSpeaker,\n isMuted,\n transcript,\n sessionId,\n roomName,\n error,\n start,\n stop,\n mute,\n unmute,\n clearTranscript,\n }),\n [\n status,\n activeSpeaker,\n isMuted,\n transcript,\n sessionId,\n roomName,\n error,\n start,\n stop,\n mute,\n unmute,\n clearTranscript,\n ],\n );\n};\n"],"names":["useParentBridge","useRef","useEffect","useCallback","useState","Track","Room","RoomEvent","useMemo"],"mappings":";;;;;AAoLA,MAAM,UAAU,CAAC,UACf,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAE1D,MAAM,YAA+B;AAAA,EACnC,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,OAAO;AACT;AAGA,MAAM,cAAc,MAAyB;AAE7C,MAAM,0BACJ;AASK,MAAM,2BAA2B,OAAO;AAAA,EAC7C;AAAA,EACA;AAAA,EACA,UAAU,CAAA;AAAA,EACV;AACF,MAO8C;AAC5C,QAAM,MAAc,GAAG,eAAe,QAAQ,QAAQ,EAAE,CAAC;AACzD,QAAM,WAAqB,MAAM,MAAM,KAAK;AAAA,IAC1C,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,eAAe,UAAU,KAAK;AAAA,IAAA;AAAA,IAEhC,MAAM,KAAK,UAAU,OAAO;AAAA,IAC5B;AAAA,EAAA,CACD;AACD,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,SAAiB,MAAM,SAAS,OAAO,MAAM,MAAM,EAAE;AAC3D,UAAM,IAAI;AAAA,MACR,kCAAkC,SAAS,MAAM,IAAI,SAAS,KAAK,MAAM,KAAK,EAAE;AAAA,IAAA;AAAA,EAEpF;AACA,SAAQ,MAAM,SAAS,KAAA;AACzB;AAEA,MAAM,YAAY,CAChB,aACA,SAEA,gBAAgB,UAChB,YAAY,aAAa,KAAK,iBAAiB,WAC3C,SACA;AAa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G,CAAA,CAAE;AAKL,QAAM,kBAAkBF,MAAAA,OAA6C,IAAI;AACzEC,QAAAA,UAAU,MAAM;AACd,QAAI,gBAAgB,YAAY,MAAM;AACpC,mBAAa,gBAAgB,OAAO;AACpC,sBAAgB,UAAU;AAAA,IAC5B;AACA,WAAO,MAAM;AACX,sBAAgB,UAAU,WAAW,MAAM;AACzC,wBAAgB,UAAU;AAC1B,aAAK,SAAA;AAAA,MACP,GAAG,CAAC;AAAA,IACN;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAOM,MAAAA;AAAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA,cAAc,WAAW;AAAA,MACzB,aAAa,WAAW,eAAe,WAAW;AAAA,MAClD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;;;"}
|
|
@@ -30,6 +30,37 @@ export interface AthenaVoiceTranscriptTurn {
|
|
|
30
30
|
endTime: number;
|
|
31
31
|
language: string;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* A voice tool the Orpheus worker can run for the agent. These are voice tool
|
|
35
|
+
* names, not the chat `Toolkits` ids: `'web_search_browse_toolkit'` is not a
|
|
36
|
+
* voice tool, `'web_search'` is. Only these names are accepted.
|
|
37
|
+
*
|
|
38
|
+
* The worker also has tools that call back into the client over LiveKit RPC
|
|
39
|
+
* (`write_to_clipboard`, `replace_current_selection`, `open_in_olympus`,
|
|
40
|
+
* `open_asset`, `get_screen_contents`). This hook registers no RPC handlers,
|
|
41
|
+
* so they are not part of its contract.
|
|
42
|
+
*/
|
|
43
|
+
export type AthenaVoiceToolId =
|
|
44
|
+
/** Web search (Exa). */
|
|
45
|
+
'web_search'
|
|
46
|
+
/** Legacy alias of `web_search`; prefer `web_search`. */
|
|
47
|
+
| 'search_web'
|
|
48
|
+
/** Fetch and read one URL. */
|
|
49
|
+
| 'browse'
|
|
50
|
+
/** The workspace knowledge base (Ragie), where configured. */
|
|
51
|
+
| 'search_knowledge_base'
|
|
52
|
+
/** Same knowledge base, thorough long-running retrieval. */
|
|
53
|
+
| 'search_knowledge_base_lr'
|
|
54
|
+
/** Read Athena assets by id, as the viewer. */
|
|
55
|
+
| 'read_full_asset'
|
|
56
|
+
/** Search the viewer's Athena assets. */
|
|
57
|
+
| 'search_assets'
|
|
58
|
+
/** Hand a question to the general agent and speak its answer. */
|
|
59
|
+
| 'ask_agent'
|
|
60
|
+
/** Save a note for the user (a stub on the worker today). */
|
|
61
|
+
| 'save_note'
|
|
62
|
+
/** Current date and time, Eastern. */
|
|
63
|
+
| 'get_current_time_est';
|
|
33
64
|
/**
|
|
34
65
|
* Orpheus agent configuration for a session the hook creates itself (see
|
|
35
66
|
* `UseAthenaVoiceSessionOptions.session`). Mirrors the body of
|
|
@@ -48,8 +79,12 @@ export interface AthenaVoiceSessionConfig {
|
|
|
48
79
|
temperature?: number;
|
|
49
80
|
/** BCP-47 language tag; default `'en'`. */
|
|
50
81
|
language?: string;
|
|
51
|
-
/**
|
|
52
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Voice tools the agent may call. Omit it for the server's default set
|
|
84
|
+
* (`web_search`, `search_knowledge_base`, `ask_agent`, …); pass `[]` for a
|
|
85
|
+
* pure conversation with no tool calls.
|
|
86
|
+
*/
|
|
87
|
+
enabled_tools?: AthenaVoiceToolId[];
|
|
53
88
|
/** IANA timezone of the speaker, e.g. `'America/New_York'`. */
|
|
54
89
|
timezone?: string;
|
|
55
90
|
}
|