@athenaintel/react 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +182 -112
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +182 -112
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1378,7 +1378,7 @@ const createStoreImpl = (createState) => {
|
|
|
1378
1378
|
};
|
|
1379
1379
|
const createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
1380
1380
|
const identity = (arg) => arg;
|
|
1381
|
-
function useStore(api, selector = identity) {
|
|
1381
|
+
function useStore$1(api, selector = identity) {
|
|
1382
1382
|
const slice2 = React.useSyncExternalStore(
|
|
1383
1383
|
api.subscribe,
|
|
1384
1384
|
React.useCallback(() => selector(api.getState()), [api, selector]),
|
|
@@ -1389,7 +1389,7 @@ function useStore(api, selector = identity) {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
const createImpl = (createState) => {
|
|
1391
1391
|
const api = createStore(createState);
|
|
1392
|
-
const useBoundStore = (selector) => useStore(api, selector);
|
|
1392
|
+
const useBoundStore = (selector) => useStore$1(api, selector);
|
|
1393
1393
|
Object.assign(useBoundStore, api);
|
|
1394
1394
|
return useBoundStore;
|
|
1395
1395
|
};
|
|
@@ -20749,7 +20749,11 @@ const useAthenaRuntime = (config2) => {
|
|
|
20749
20749
|
systemPrompt,
|
|
20750
20750
|
threadId: threadIdProp
|
|
20751
20751
|
} = config2;
|
|
20752
|
-
const
|
|
20752
|
+
const generatedIdRef = React.useRef(null);
|
|
20753
|
+
if (generatedIdRef.current === null) {
|
|
20754
|
+
generatedIdRef.current = crypto.randomUUID();
|
|
20755
|
+
}
|
|
20756
|
+
const threadId = threadIdProp ?? generatedIdRef.current;
|
|
20753
20757
|
const enabledTools = React.useMemo(
|
|
20754
20758
|
() => Array.from(/* @__PURE__ */ new Set([...tools, ...frontendToolIds])),
|
|
20755
20759
|
[tools, frontendToolIds]
|
|
@@ -24118,8 +24122,9 @@ function AthenaProvider({
|
|
|
24118
24122
|
threadId
|
|
24119
24123
|
}) {
|
|
24120
24124
|
const frontendToolNames = React.useMemo(() => Object.keys(frontendTools), [frontendTools]);
|
|
24125
|
+
const auiTools = React.useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
|
|
24121
24126
|
const aui = useAui({
|
|
24122
|
-
tools:
|
|
24127
|
+
tools: auiTools
|
|
24123
24128
|
});
|
|
24124
24129
|
const parentAuthToken = useParentAuth();
|
|
24125
24130
|
const effectiveToken = tokenProp ?? parentAuthToken;
|
|
@@ -59526,6 +59531,31 @@ class Store {
|
|
|
59526
59531
|
return this.atom.subscribe(toObserver(observerOrFn));
|
|
59527
59532
|
}
|
|
59528
59533
|
}
|
|
59534
|
+
function defaultCompare(a, b) {
|
|
59535
|
+
return a === b;
|
|
59536
|
+
}
|
|
59537
|
+
function useStore(atom, selector, compare = defaultCompare) {
|
|
59538
|
+
const subscribe = React.useCallback(
|
|
59539
|
+
(handleStoreChange) => {
|
|
59540
|
+
if (!atom) {
|
|
59541
|
+
return () => {
|
|
59542
|
+
};
|
|
59543
|
+
}
|
|
59544
|
+
const { unsubscribe } = atom.subscribe(handleStoreChange);
|
|
59545
|
+
return unsubscribe;
|
|
59546
|
+
},
|
|
59547
|
+
[atom]
|
|
59548
|
+
);
|
|
59549
|
+
const boundGetSnapshot = React.useCallback(() => atom == null ? void 0 : atom.get(), [atom]);
|
|
59550
|
+
const selectedSnapshot = withSelectorExports.useSyncExternalStoreWithSelector(
|
|
59551
|
+
subscribe,
|
|
59552
|
+
boundGetSnapshot,
|
|
59553
|
+
boundGetSnapshot,
|
|
59554
|
+
selector,
|
|
59555
|
+
compare
|
|
59556
|
+
);
|
|
59557
|
+
return selectedSnapshot;
|
|
59558
|
+
}
|
|
59529
59559
|
function createScopeRegistry() {
|
|
59530
59560
|
return { entries: /* @__PURE__ */ new Map() };
|
|
59531
59561
|
}
|
|
@@ -59561,52 +59591,13 @@ function getFilteredItems(cache, scope, query) {
|
|
|
59561
59591
|
}
|
|
59562
59592
|
return results;
|
|
59563
59593
|
}
|
|
59564
|
-
function toolsToMenuItems(tools) {
|
|
59565
|
-
return tools.map((t) => ({
|
|
59566
|
-
id: t.id,
|
|
59567
|
-
name: t.name,
|
|
59568
|
-
type: t.type,
|
|
59569
|
-
fallbackIcon: t.icon ?? (t.type === "toolkit" ? "🧰" : "🔧"),
|
|
59570
|
-
description: t.description,
|
|
59571
|
-
visibleInScopes: /* @__PURE__ */ new Set(["root"])
|
|
59572
|
-
}));
|
|
59573
|
-
}
|
|
59574
|
-
function useMentionSuggestions(tools) {
|
|
59575
|
-
const store = React.useMemo(() => {
|
|
59576
|
-
const registry = createScopeRegistry();
|
|
59577
|
-
const cache = createItemCache();
|
|
59578
|
-
registerSource(registry, "root", async () => ({
|
|
59579
|
-
items: [],
|
|
59580
|
-
pagination: { hasMore: false }
|
|
59581
|
-
}));
|
|
59582
|
-
const items = toolsToMenuItems(tools);
|
|
59583
|
-
addItems(cache, items, "root");
|
|
59584
|
-
return new Store({ registry, cache });
|
|
59585
|
-
}, []);
|
|
59586
|
-
React.useEffect(() => {
|
|
59587
|
-
const { cache } = store.state;
|
|
59588
|
-
for (const item of cache.items.values()) {
|
|
59589
|
-
item.visibleInScopes.delete("root");
|
|
59590
|
-
}
|
|
59591
|
-
for (const [id, item] of cache.items) {
|
|
59592
|
-
if (item.visibleInScopes.size === 0) {
|
|
59593
|
-
cache.items.delete(id);
|
|
59594
|
-
}
|
|
59595
|
-
}
|
|
59596
|
-
const items = toolsToMenuItems(tools);
|
|
59597
|
-
addItems(cache, items, "root");
|
|
59598
|
-
}, [tools, store]);
|
|
59599
|
-
return store;
|
|
59600
|
-
}
|
|
59601
|
-
function selectItems(store, scope, query) {
|
|
59602
|
-
const { cache } = store.state;
|
|
59603
|
-
const items = getFilteredItems(cache, scope, query);
|
|
59604
|
-
return { items, isFetching: false, hasMore: false };
|
|
59605
|
-
}
|
|
59606
59594
|
const MentionSuggestionList = React.forwardRef(({ store, query, command: command2, closeMenu }, ref) => {
|
|
59607
59595
|
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
59608
59596
|
const scrollContainerRef = React.useRef(null);
|
|
59609
|
-
const { items, isFetching } =
|
|
59597
|
+
const { items, isFetching } = useStore(store, (state) => ({
|
|
59598
|
+
items: getFilteredItems(state.cache, "root", query),
|
|
59599
|
+
isFetching: false
|
|
59600
|
+
}));
|
|
59610
59601
|
React.useEffect(() => {
|
|
59611
59602
|
setSelectedIndex(0);
|
|
59612
59603
|
}, [query]);
|
|
@@ -59669,7 +59660,10 @@ const MentionSuggestionList = React.forwardRef(({ store, query, command: command
|
|
|
59669
59660
|
},
|
|
59670
59661
|
item.id
|
|
59671
59662
|
)),
|
|
59672
|
-
isFetching
|
|
59663
|
+
isFetching && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-2 py-1.5 text-sm text-muted-foreground", children: [
|
|
59664
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
59665
|
+
"Loading..."
|
|
59666
|
+
] })
|
|
59673
59667
|
] }) });
|
|
59674
59668
|
});
|
|
59675
59669
|
MentionSuggestionList.displayName = "MentionSuggestionList";
|
|
@@ -59859,6 +59853,45 @@ const MentionSuggestionsExtension = Extension.create({
|
|
|
59859
59853
|
];
|
|
59860
59854
|
}
|
|
59861
59855
|
});
|
|
59856
|
+
function toolsToMenuItems(tools) {
|
|
59857
|
+
return tools.map((t) => ({
|
|
59858
|
+
id: t.id,
|
|
59859
|
+
name: t.name,
|
|
59860
|
+
type: t.type,
|
|
59861
|
+
fallbackIcon: t.icon ?? (t.type === "toolkit" ? "🧰" : "🔧"),
|
|
59862
|
+
description: t.description,
|
|
59863
|
+
visibleInScopes: /* @__PURE__ */ new Set(["root"])
|
|
59864
|
+
}));
|
|
59865
|
+
}
|
|
59866
|
+
function useMentionSuggestions(tools) {
|
|
59867
|
+
const storeRef = React.useRef(null);
|
|
59868
|
+
if (!storeRef.current) {
|
|
59869
|
+
const registry = createScopeRegistry();
|
|
59870
|
+
const cache = createItemCache();
|
|
59871
|
+
registerSource(registry, "root", async () => ({
|
|
59872
|
+
items: [],
|
|
59873
|
+
pagination: { hasMore: false }
|
|
59874
|
+
}));
|
|
59875
|
+
const items = toolsToMenuItems(tools);
|
|
59876
|
+
addItems(cache, items, "root");
|
|
59877
|
+
storeRef.current = new Store({ registry, cache });
|
|
59878
|
+
}
|
|
59879
|
+
const store = storeRef.current;
|
|
59880
|
+
React.useEffect(() => {
|
|
59881
|
+
store.setState((prev) => {
|
|
59882
|
+
const newCache = createItemCache();
|
|
59883
|
+
for (const [id, item] of prev.cache.items) {
|
|
59884
|
+
if (item.visibleInScopes.size > 0 && !item.visibleInScopes.has("root")) {
|
|
59885
|
+
newCache.items.set(id, { ...item, visibleInScopes: new Set(item.visibleInScopes) });
|
|
59886
|
+
}
|
|
59887
|
+
}
|
|
59888
|
+
const items = toolsToMenuItems(tools);
|
|
59889
|
+
addItems(newCache, items, "root");
|
|
59890
|
+
return { ...prev, cache: newCache };
|
|
59891
|
+
});
|
|
59892
|
+
}, [tools, store]);
|
|
59893
|
+
return store;
|
|
59894
|
+
}
|
|
59862
59895
|
const TiptapComposer = ({ tools = [] }) => {
|
|
59863
59896
|
const composerRuntime = useComposerRuntime();
|
|
59864
59897
|
const editorRef = React.useRef(null);
|
|
@@ -60574,12 +60607,14 @@ function CollapsibleTrigger({ ...props }) {
|
|
|
60574
60607
|
function CollapsibleContent({ ...props }) {
|
|
60575
60608
|
return /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent$1, { "data-slot": "collapsible-content", ...props });
|
|
60576
60609
|
}
|
|
60577
|
-
const useAssetPanelStore = create((set2) => ({
|
|
60610
|
+
const useAssetPanelStore = create((set2, get2) => ({
|
|
60578
60611
|
isOpen: false,
|
|
60579
60612
|
tabs: [],
|
|
60580
60613
|
activeTabId: null,
|
|
60581
60614
|
viewMode: "tabs",
|
|
60582
60615
|
isFullscreen: false,
|
|
60616
|
+
autoOpenGeneration: 0,
|
|
60617
|
+
autoOpenedAssets: /* @__PURE__ */ new Map(),
|
|
60583
60618
|
openAsset: (assetId, meta) => set2((s) => {
|
|
60584
60619
|
const existing = s.tabs.find((t) => t.id === assetId);
|
|
60585
60620
|
if (existing) {
|
|
@@ -60607,39 +60642,59 @@ const useAssetPanelStore = create((set2) => ({
|
|
|
60607
60642
|
setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
|
|
60608
60643
|
setViewMode: (mode) => set2({ viewMode: mode }),
|
|
60609
60644
|
closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
|
|
60610
|
-
toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen }))
|
|
60645
|
+
toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen })),
|
|
60646
|
+
resetAutoOpen: () => set2((s) => ({ autoOpenGeneration: s.autoOpenGeneration + 1 })),
|
|
60647
|
+
markAutoOpened: (assetId) => {
|
|
60648
|
+
const state = get2();
|
|
60649
|
+
if (state.autoOpenedAssets.get(assetId) === state.autoOpenGeneration) {
|
|
60650
|
+
return false;
|
|
60651
|
+
}
|
|
60652
|
+
state.autoOpenedAssets.set(assetId, state.autoOpenGeneration);
|
|
60653
|
+
return true;
|
|
60654
|
+
}
|
|
60611
60655
|
}));
|
|
60612
60656
|
const ANIMATION_DURATION = 200;
|
|
60613
60657
|
const TOOL_META = {
|
|
60614
|
-
|
|
60615
|
-
|
|
60616
|
-
|
|
60617
|
-
|
|
60618
|
-
|
|
60619
|
-
|
|
60620
|
-
|
|
60621
|
-
|
|
60622
|
-
|
|
60623
|
-
|
|
60624
|
-
|
|
60625
|
-
|
|
60626
|
-
|
|
60627
|
-
|
|
60628
|
-
|
|
60629
|
-
|
|
60630
|
-
|
|
60631
|
-
|
|
60632
|
-
|
|
60633
|
-
|
|
60634
|
-
|
|
60635
|
-
|
|
60636
|
-
|
|
60637
|
-
|
|
60638
|
-
|
|
60639
|
-
|
|
60640
|
-
|
|
60641
|
-
|
|
60642
|
-
|
|
60658
|
+
// Search & Browse
|
|
60659
|
+
search: { displayName: "Searching the web", icon: Search, describer: (a) => a.query ? `"${a.query}"` : "" },
|
|
60660
|
+
browse: { displayName: "Reading webpage", icon: Globe, describer: (a) => a.url ?? "" },
|
|
60661
|
+
search_email: { displayName: "Searching emails", icon: Mail, describer: (a) => a.query ? `"${a.query}"` : "" },
|
|
60662
|
+
unified_email_search: { displayName: "Searching emails", icon: Mail, describer: (a) => a.query ? `"${a.query}"` : "" },
|
|
60663
|
+
search_contacts: { displayName: "Looking up contacts", icon: Search },
|
|
60664
|
+
search_calendar_events: { displayName: "Checking calendar", icon: Search },
|
|
60665
|
+
search_assets: { displayName: "Searching files", icon: Search },
|
|
60666
|
+
list_contents: { displayName: "Browsing files", icon: Search },
|
|
60667
|
+
// Email
|
|
60668
|
+
create_email_draft: { displayName: "Drafting email", icon: Mail },
|
|
60669
|
+
unified_email_create_draft: { displayName: "Drafting email", icon: Mail },
|
|
60670
|
+
edit_email_draft: { displayName: "Editing email draft", icon: Mail },
|
|
60671
|
+
unified_edit_email_draft: { displayName: "Editing email draft", icon: Mail },
|
|
60672
|
+
// Documents
|
|
60673
|
+
read_full_asset: { displayName: "Reading document", icon: BookOpen },
|
|
60674
|
+
create_new_document: { displayName: "Creating document", icon: FileText },
|
|
60675
|
+
create_document_from_markdown: { displayName: "Creating document", icon: FileText },
|
|
60676
|
+
append_markdown_to_athena_document: { displayName: "Updating document", icon: PenLine },
|
|
60677
|
+
replace_markdown_in_athena_document: { displayName: "Updating document", icon: PenLine },
|
|
60678
|
+
// Spreadsheets
|
|
60679
|
+
create_new_sheet: { displayName: "Creating spreadsheet", icon: ChartColumn },
|
|
60680
|
+
update_sheet_range: { displayName: "Updating spreadsheet", icon: ChartColumn },
|
|
60681
|
+
// Presentations
|
|
60682
|
+
create_powerpoint_deck: { displayName: "Building presentation", icon: Monitor },
|
|
60683
|
+
execute_presentation_code: { displayName: "Generating slides", icon: Monitor },
|
|
60684
|
+
// Code & Data
|
|
60685
|
+
run_python_code: { displayName: "Running analysis", icon: Code },
|
|
60686
|
+
run_sql_query_tool: { displayName: "Querying data", icon: Database },
|
|
60687
|
+
create_database: { displayName: "Setting up database", icon: Database },
|
|
60688
|
+
run_database_sql: { displayName: "Querying database", icon: Database },
|
|
60689
|
+
computer_asset_exec: { displayName: "Running command", icon: Monitor },
|
|
60690
|
+
// Notebooks
|
|
60691
|
+
create_new_notebook: { displayName: "Creating notebook", icon: BookOpen },
|
|
60692
|
+
execute_cell: { displayName: "Running notebook cell", icon: Code },
|
|
60693
|
+
// Workflows
|
|
60694
|
+
create_new_aop: { displayName: "Creating workflow", icon: Brain },
|
|
60695
|
+
execute_aop: { displayName: "Running workflow", icon: Brain },
|
|
60696
|
+
// Preferences
|
|
60697
|
+
save_preference_as_memory: { displayName: "Saving preference", icon: Settings }
|
|
60643
60698
|
};
|
|
60644
60699
|
function getToolMeta(toolName) {
|
|
60645
60700
|
if (TOOL_META[toolName]) return TOOL_META[toolName];
|
|
@@ -60726,10 +60781,8 @@ function extractTitle(argsText, result) {
|
|
|
60726
60781
|
}
|
|
60727
60782
|
return null;
|
|
60728
60783
|
}
|
|
60729
|
-
let assetGeneration$1 = 0;
|
|
60730
|
-
const autoOpenedAssets$1 = /* @__PURE__ */ new Map();
|
|
60731
60784
|
function clearAutoOpenedAssets() {
|
|
60732
|
-
|
|
60785
|
+
useAssetPanelStore.getState().resetAutoOpen();
|
|
60733
60786
|
}
|
|
60734
60787
|
function ToolFallbackRoot({
|
|
60735
60788
|
className,
|
|
@@ -60764,7 +60817,7 @@ function ToolFallbackRoot({
|
|
|
60764
60817
|
open: isOpen,
|
|
60765
60818
|
onOpenChange: handleOpenChange,
|
|
60766
60819
|
className: cn(
|
|
60767
|
-
"aui-tool-fallback-root group/tool-fallback-root w-full rounded-xl border border-border/60 bg-background py-2.5 shadow-sm",
|
|
60820
|
+
"aui-tool-fallback-root group/tool-fallback-root my-3 w-full rounded-xl border border-border/60 bg-background py-2.5 shadow-sm",
|
|
60768
60821
|
className
|
|
60769
60822
|
),
|
|
60770
60823
|
style: {
|
|
@@ -60835,16 +60888,16 @@ function ToolFallbackTrigger({
|
|
|
60835
60888
|
),
|
|
60836
60889
|
children: [
|
|
60837
60890
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: isRunning ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
60838
|
-
|
|
60891
|
+
meta.displayName,
|
|
60839
60892
|
"..."
|
|
60840
|
-
] }) :
|
|
60893
|
+
] }) : meta.displayName }),
|
|
60841
60894
|
isRunning && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
60842
60895
|
"span",
|
|
60843
60896
|
{
|
|
60844
60897
|
"aria-hidden": true,
|
|
60845
60898
|
className: "shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",
|
|
60846
60899
|
children: [
|
|
60847
|
-
|
|
60900
|
+
meta.displayName,
|
|
60848
60901
|
"..."
|
|
60849
60902
|
]
|
|
60850
60903
|
}
|
|
@@ -60978,17 +61031,19 @@ function AssetToolCard({
|
|
|
60978
61031
|
const assetType = toolMetaToAssetType(toolName);
|
|
60979
61032
|
const wasCompleteAtMount = React.useRef(isComplete);
|
|
60980
61033
|
React.useEffect(() => {
|
|
60981
|
-
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current
|
|
60982
|
-
|
|
60983
|
-
|
|
60984
|
-
|
|
60985
|
-
|
|
60986
|
-
|
|
61034
|
+
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
|
|
61035
|
+
const store = useAssetPanelStore.getState();
|
|
61036
|
+
if (store.markAutoOpened(assetId)) {
|
|
61037
|
+
store.openAsset(assetId, {
|
|
61038
|
+
name: title ?? void 0,
|
|
61039
|
+
type: assetType
|
|
61040
|
+
});
|
|
61041
|
+
}
|
|
60987
61042
|
}
|
|
60988
61043
|
}, [isComplete, isCancelled, assetId, title, assetType]);
|
|
60989
61044
|
const success = isComplete && isResultSuccess(result);
|
|
60990
61045
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(
|
|
60991
|
-
"aui-tool-fallback-root w-full rounded-xl border border-border/60 bg-background py-2.5 shadow-sm",
|
|
61046
|
+
"aui-tool-fallback-root my-3 w-full rounded-xl border border-border/60 bg-background py-2.5 shadow-sm",
|
|
60992
61047
|
isCancelled && "border-muted-foreground/30 bg-muted/30"
|
|
60993
61048
|
), children: [
|
|
60994
61049
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5 px-3 text-sm", children: [
|
|
@@ -61005,13 +61060,13 @@ function AssetToolCard({
|
|
|
61005
61060
|
}
|
|
61006
61061
|
),
|
|
61007
61062
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 grow flex-col items-start gap-0.5 text-left", children: [
|
|
61008
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "leading-tight", children: [
|
|
61009
|
-
|
|
61063
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "leading-tight font-medium", children: [
|
|
61064
|
+
meta.displayName,
|
|
61010
61065
|
isRunning && "..."
|
|
61011
61066
|
] }),
|
|
61012
61067
|
!isRunning && title && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-w-full truncate text-xs leading-snug text-muted-foreground", children: title })
|
|
61013
61068
|
] }),
|
|
61014
|
-
assetId && isComplete && !isCancelled && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
61069
|
+
assetId && isComplete && !isCancelled && CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
61015
61070
|
"button",
|
|
61016
61071
|
{
|
|
61017
61072
|
onClick: () => openAsset(assetId, { name: title ?? void 0, type: assetType }),
|
|
@@ -61433,11 +61488,15 @@ function normalizeResult(result) {
|
|
|
61433
61488
|
function truncate(text2, max2) {
|
|
61434
61489
|
return text2.length > max2 ? `${text2.slice(0, max2)}...` : text2;
|
|
61435
61490
|
}
|
|
61491
|
+
function formatToolName(name) {
|
|
61492
|
+
return name.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
61493
|
+
}
|
|
61436
61494
|
function ToolCard({
|
|
61437
61495
|
icon: Icon2,
|
|
61438
61496
|
status,
|
|
61439
61497
|
title,
|
|
61440
61498
|
subtitle,
|
|
61499
|
+
toolName,
|
|
61441
61500
|
badge,
|
|
61442
61501
|
error: error2,
|
|
61443
61502
|
children
|
|
@@ -61445,7 +61504,7 @@ function ToolCard({
|
|
|
61445
61504
|
const isRunning = status === "running";
|
|
61446
61505
|
const isComplete = status === "complete";
|
|
61447
61506
|
const isError = status === "incomplete";
|
|
61448
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-
|
|
61507
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-3 w-full overflow-hidden rounded-xl border border-border/60 bg-background shadow-sm", children: [
|
|
61449
61508
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
|
|
61450
61509
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
61451
61510
|
"div",
|
|
@@ -61461,11 +61520,12 @@ function ToolCard({
|
|
|
61461
61520
|
),
|
|
61462
61521
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
61463
61522
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
61464
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] font-
|
|
61523
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] font-medium text-foreground", children: title }),
|
|
61465
61524
|
isComplete && !error2 && /* @__PURE__ */ jsxRuntime.jsx(CircleCheck, { className: "size-3.5 text-emerald-500" })
|
|
61466
61525
|
] }),
|
|
61467
61526
|
subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-[12px] text-muted-foreground", children: subtitle })
|
|
61468
61527
|
] }),
|
|
61528
|
+
toolName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 rounded-md bg-muted/60 px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground", children: formatToolName(toolName) }),
|
|
61469
61529
|
badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground", children: badge }),
|
|
61470
61530
|
isRunning && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
61471
61531
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-1.5 w-10 animate-pulse rounded-full bg-blue-100" }),
|
|
@@ -61519,6 +61579,7 @@ function parseSearchResults(data) {
|
|
|
61519
61579
|
});
|
|
61520
61580
|
}
|
|
61521
61581
|
const WebSearchToolUIImpl = ({
|
|
61582
|
+
toolName,
|
|
61522
61583
|
args,
|
|
61523
61584
|
result,
|
|
61524
61585
|
status
|
|
@@ -61537,11 +61598,12 @@ const WebSearchToolUIImpl = ({
|
|
|
61537
61598
|
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
61538
61599
|
title: isRunning ? "Searching the web..." : "Web search",
|
|
61539
61600
|
subtitle: query ? truncate(query, 80) : void 0,
|
|
61601
|
+
toolName,
|
|
61540
61602
|
badge: isComplete && results.length > 0 ? `${results.length} results` : void 0,
|
|
61541
61603
|
error: errorMsg,
|
|
61542
61604
|
children: isComplete && results.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ExpandableSection, { label: "Show search results", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2.5", children: results.map((r2, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
61543
61605
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
61544
|
-
r2.url ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
61606
|
+
r2.url && /^https?:\/\//i.test(r2.url) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
61545
61607
|
"a",
|
|
61546
61608
|
{
|
|
61547
61609
|
href: r2.url,
|
|
@@ -61550,7 +61612,7 @@ const WebSearchToolUIImpl = ({
|
|
|
61550
61612
|
className: "text-[12px] font-medium text-blue-600 hover:underline",
|
|
61551
61613
|
children: r2.title || r2.url
|
|
61552
61614
|
}
|
|
61553
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[12px] font-medium text-foreground", children: r2.title || "Result" }),
|
|
61615
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[12px] font-medium text-foreground", children: r2.title || r2.url || "Result" }),
|
|
61554
61616
|
r2.url && /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-3 shrink-0 text-muted-foreground" })
|
|
61555
61617
|
] }),
|
|
61556
61618
|
r2.url && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: truncate(r2.url, 60) }),
|
|
@@ -61564,6 +61626,7 @@ const WebSearchToolUI = React.memo(
|
|
|
61564
61626
|
);
|
|
61565
61627
|
WebSearchToolUI.displayName = "WebSearchToolUI";
|
|
61566
61628
|
const BrowseToolUIImpl = ({
|
|
61629
|
+
toolName,
|
|
61567
61630
|
args,
|
|
61568
61631
|
result,
|
|
61569
61632
|
status
|
|
@@ -61592,6 +61655,7 @@ const BrowseToolUIImpl = ({
|
|
|
61592
61655
|
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
61593
61656
|
title: isRunning ? "Browsing page..." : pageTitle ? truncate(pageTitle, 50) : "Browsed page",
|
|
61594
61657
|
subtitle: displayUrl,
|
|
61658
|
+
toolName,
|
|
61595
61659
|
error: errorMsg,
|
|
61596
61660
|
children: isComplete && pageContent && /* @__PURE__ */ jsxRuntime.jsx(ExpandableSection, { label: "Show page content", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap break-words text-[11px] leading-relaxed text-muted-foreground", children: truncate(pageContent, 3e3) }) })
|
|
61597
61661
|
}
|
|
@@ -61615,6 +61679,7 @@ function parseEmailResults(data) {
|
|
|
61615
61679
|
});
|
|
61616
61680
|
}
|
|
61617
61681
|
const EmailSearchToolUIImpl = ({
|
|
61682
|
+
toolName,
|
|
61618
61683
|
args,
|
|
61619
61684
|
result,
|
|
61620
61685
|
status
|
|
@@ -61633,6 +61698,7 @@ const EmailSearchToolUIImpl = ({
|
|
|
61633
61698
|
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
61634
61699
|
title: isRunning ? "Searching emails..." : "Email search",
|
|
61635
61700
|
subtitle: query ? truncate(query, 80) : void 0,
|
|
61701
|
+
toolName,
|
|
61636
61702
|
badge: isComplete && emails.length > 0 ? `${emails.length} emails` : void 0,
|
|
61637
61703
|
error: errorMsg,
|
|
61638
61704
|
children: isComplete && emails.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ExpandableSection, { label: "Show email results", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col divide-y divide-border/30", children: emails.map((email, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-0.5 py-2", i === 0 && "pt-0"), children: [
|
|
@@ -61657,16 +61723,15 @@ function extractAssetId(result) {
|
|
|
61657
61723
|
if (typeof id === "string" && id.startsWith("asset_")) return id;
|
|
61658
61724
|
return null;
|
|
61659
61725
|
}
|
|
61660
|
-
let assetGeneration = 0;
|
|
61661
|
-
const autoOpenedAssets = /* @__PURE__ */ new Map();
|
|
61662
61726
|
function resetAssetAutoOpen() {
|
|
61663
|
-
|
|
61727
|
+
useAssetPanelStore.getState().resetAutoOpen();
|
|
61664
61728
|
}
|
|
61665
61729
|
function CreateAssetToolUIImpl({
|
|
61666
61730
|
icon: Icon2,
|
|
61667
61731
|
assetType,
|
|
61668
61732
|
runningLabel,
|
|
61669
61733
|
doneLabel,
|
|
61734
|
+
toolName,
|
|
61670
61735
|
args,
|
|
61671
61736
|
result,
|
|
61672
61737
|
status
|
|
@@ -61683,12 +61748,14 @@ function CreateAssetToolUIImpl({
|
|
|
61683
61748
|
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
61684
61749
|
const wasCompleteAtMount = React.useRef(isComplete);
|
|
61685
61750
|
React.useEffect(() => {
|
|
61686
|
-
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current
|
|
61687
|
-
|
|
61688
|
-
|
|
61689
|
-
|
|
61690
|
-
|
|
61691
|
-
|
|
61751
|
+
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
|
|
61752
|
+
const store = useAssetPanelStore.getState();
|
|
61753
|
+
if (store.markAutoOpened(assetId)) {
|
|
61754
|
+
store.openAsset(assetId, {
|
|
61755
|
+
name: createdName || name || void 0,
|
|
61756
|
+
type: assetType
|
|
61757
|
+
});
|
|
61758
|
+
}
|
|
61692
61759
|
}
|
|
61693
61760
|
}, [isComplete, isCancelled, assetId, createdName, name, assetType]);
|
|
61694
61761
|
const handleOpen = () => {
|
|
@@ -61706,6 +61773,7 @@ function CreateAssetToolUIImpl({
|
|
|
61706
61773
|
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
61707
61774
|
title: isRunning ? runningLabel : doneLabel,
|
|
61708
61775
|
subtitle: createdName || name || void 0,
|
|
61776
|
+
toolName,
|
|
61709
61777
|
error: errorMsg,
|
|
61710
61778
|
children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
61711
61779
|
"button",
|
|
@@ -61765,6 +61833,7 @@ const CreatePresentationToolUI = React.memo(
|
|
|
61765
61833
|
);
|
|
61766
61834
|
CreatePresentationToolUI.displayName = "CreatePresentationToolUI";
|
|
61767
61835
|
const CreateEmailDraftToolUIImpl = ({
|
|
61836
|
+
toolName,
|
|
61768
61837
|
args,
|
|
61769
61838
|
result,
|
|
61770
61839
|
status
|
|
@@ -61780,6 +61849,7 @@ const CreateEmailDraftToolUIImpl = ({
|
|
|
61780
61849
|
icon: Mail,
|
|
61781
61850
|
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
61782
61851
|
title: isRunning ? "Creating email draft..." : "Email draft created",
|
|
61852
|
+
toolName,
|
|
61783
61853
|
subtitle: subject ? truncate(subject, 60) : to ? `To: ${truncate(to, 40)}` : void 0,
|
|
61784
61854
|
error: errorMsg
|
|
61785
61855
|
}
|
|
@@ -61799,7 +61869,6 @@ const TOOL_UI_REGISTRY = {
|
|
|
61799
61869
|
create_new_document: CreateDocumentToolUI,
|
|
61800
61870
|
create_document_from_markdown: CreateDocumentToolUI,
|
|
61801
61871
|
create_new_sheet: CreateSheetToolUI,
|
|
61802
|
-
update_sheet_range: CreateSheetToolUI,
|
|
61803
61872
|
create_powerpoint_deck: CreatePresentationToolUI
|
|
61804
61873
|
};
|
|
61805
61874
|
const falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
@@ -62098,7 +62167,8 @@ function useAssetEmbed(assetId, options = {
|
|
|
62098
62167
|
setError(null);
|
|
62099
62168
|
return;
|
|
62100
62169
|
}
|
|
62101
|
-
const
|
|
62170
|
+
const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}`;
|
|
62171
|
+
const cached = embedCache.get(cacheKey);
|
|
62102
62172
|
if (cached && cached.expiresAt > Date.now() / 1e3) {
|
|
62103
62173
|
setEmbedUrl(cached.url);
|
|
62104
62174
|
setIsLoading(false);
|
|
@@ -62134,7 +62204,7 @@ function useAssetEmbed(assetId, options = {
|
|
|
62134
62204
|
}
|
|
62135
62205
|
return res.json();
|
|
62136
62206
|
}).then((data) => {
|
|
62137
|
-
embedCache.set(assetId
|
|
62207
|
+
embedCache.set(`${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}`, { url: data.embed_url, expiresAt: data.expires_at });
|
|
62138
62208
|
setEmbedUrl(data.embed_url);
|
|
62139
62209
|
setIsLoading(false);
|
|
62140
62210
|
}).catch((err) => {
|