@athenaintel/react 0.17.0 → 0.19.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.
Files changed (128) hide show
  1. package/README.md +179 -43
  2. package/dist/AthenaContext-B1QMhIP-.cjs.map +1 -1
  3. package/dist/AthenaContext-MOslgOmE.js.map +1 -1
  4. package/dist/SuperGroupingCard-BsWbHyV_.js +795 -0
  5. package/dist/SuperGroupingCard-BsWbHyV_.js.map +1 -0
  6. package/dist/SuperGroupingCard-CRRFUgjN.cjs +794 -0
  7. package/dist/SuperGroupingCard-CRRFUgjN.cjs.map +1 -0
  8. package/dist/chat/StatewireApprovalCard.d.ts +59 -2
  9. package/dist/chat/StatewireClientToolBridge.d.ts +3 -3
  10. package/dist/chat/StatewireQueuedMessages.d.ts +105 -6
  11. package/dist/chat/statewire-approval.d.ts +1 -1
  12. package/dist/chat/statewire-banners.d.ts +5 -9
  13. package/dist/chat/statewire-client-tools.d.ts +15 -21
  14. package/dist/chat/super-grouping/CollapsibleGroup.d.ts +52 -11
  15. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +78 -21
  16. package/dist/chat/super-grouping/activity-timeline.d.ts +91 -0
  17. package/dist/chat/super-grouping/grouping-function.d.ts +13 -10
  18. package/dist/chat/super-grouping/index.d.ts +12 -0
  19. package/dist/chat/super-grouping/toolkit-map.d.ts +8 -1
  20. package/dist/chat/use-statewire-approval-request.d.ts +44 -0
  21. package/dist/chat-ui/header/conversation-history-panel.d.ts +11 -1
  22. package/dist/chat-ui/index.d.ts +9 -0
  23. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +24 -0
  24. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +5 -0
  25. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +1 -1
  26. package/dist/chat-ui/mentions/suggestions/shims.d.ts +0 -4
  27. package/dist/chat-ui/messages/continue-pill.d.ts +13 -0
  28. package/dist/chat-ui/messages/message-components.d.ts +7 -2
  29. package/dist/chat-ui/messages/runtime-message.d.ts +21 -0
  30. package/dist/chat-ui/messages/statewire-continue-run.d.ts +82 -0
  31. package/dist/chat-ui/messages/user-edit-composer.d.ts +5 -2
  32. package/dist/chat-ui/statewire.d.ts +19 -0
  33. package/dist/chat-ui/thread/chat-composer-dock.d.ts +1 -1
  34. package/dist/chat-ui/thread/chat-thread-shell.d.ts +7 -1
  35. package/dist/chat-ui/thread/statewire-history-edge.d.ts +52 -0
  36. package/dist/chat-ui-statewire.cjs +25 -0
  37. package/dist/chat-ui-statewire.cjs.map +1 -0
  38. package/dist/chat-ui-statewire.js +25 -0
  39. package/dist/chat-ui-statewire.js.map +1 -0
  40. package/dist/chat-ui.cjs +292 -252
  41. package/dist/chat-ui.cjs.map +1 -1
  42. package/dist/chat-ui.js +289 -248
  43. package/dist/chat-ui.js.map +1 -1
  44. package/dist/diagnostics/athena-diagnostics.d.ts +1 -1
  45. package/dist/diagnostics/errors.d.ts +4 -4
  46. package/dist/index.cjs +20237 -26233
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.ts +25 -14
  49. package/dist/index.js +18465 -24458
  50. package/dist/index.js.map +1 -1
  51. package/dist/lib/athena-urls.d.ts +0 -2
  52. package/dist/lib/posthog/wrap-posthog-client.d.ts +3 -1
  53. package/dist/misc-tool-uis-B2e0Okkn.cjs +43 -0
  54. package/dist/misc-tool-uis-B2e0Okkn.cjs.map +1 -0
  55. package/dist/misc-tool-uis-gAiQw0Yl.js +44 -0
  56. package/dist/misc-tool-uis-gAiQw0Yl.js.map +1 -0
  57. package/dist/provider/AthenaContext.d.ts +0 -7
  58. package/dist/provider/AthenaProvider.d.ts +28 -52
  59. package/dist/provider/config.d.ts +19 -15
  60. package/dist/provider/statewire-lifecycle-context.d.ts +3 -4
  61. package/dist/provider/statewire-window-context.d.ts +12 -0
  62. package/dist/provider/types.d.ts +0 -1
  63. package/dist/runtime/statewire-auth-headers.d.ts +38 -0
  64. package/dist/runtime/statewire-lifecycle.d.ts +25 -1
  65. package/dist/runtime/statewire-run-config.d.ts +18 -5
  66. package/dist/runtime/statewire-session-key.d.ts +13 -0
  67. package/dist/runtime/useAthenaStatewireRuntime.d.ts +42 -16
  68. package/dist/statewire-continue-run-D34gS7_1.js +132 -0
  69. package/dist/statewire-continue-run-D34gS7_1.js.map +1 -0
  70. package/dist/statewire-continue-run-nE9VCKUh.cjs +131 -0
  71. package/dist/statewire-continue-run-nE9VCKUh.cjs.map +1 -0
  72. package/dist/statewire-history-edge-C8uyTEjX.cjs +1711 -0
  73. package/dist/statewire-history-edge-C8uyTEjX.cjs.map +1 -0
  74. package/dist/statewire-history-edge-CPohUKMt.js +1712 -0
  75. package/dist/statewire-history-edge-CPohUKMt.js.map +1 -0
  76. package/dist/styles.css +1 -1
  77. package/dist/super-grouping.cjs +22 -0
  78. package/dist/super-grouping.cjs.map +1 -0
  79. package/dist/super-grouping.js +22 -0
  80. package/dist/super-grouping.js.map +1 -0
  81. package/dist/threads/ThreadList.d.ts +6 -1
  82. package/dist/threads/mint-thread-id.d.ts +8 -0
  83. package/dist/threads/statewire-thread-list.d.ts +26 -9
  84. package/dist/threads/thread-id-context.d.ts +9 -0
  85. package/dist/threads/use-statewire-conversation-history.d.ts +2 -0
  86. package/dist/threads/useAthenaThreadManager.d.ts +24 -12
  87. package/dist/tool-fallback-DkQ3DLkn.js +4281 -0
  88. package/dist/tool-fallback-DkQ3DLkn.js.map +1 -0
  89. package/dist/tool-fallback-kfhpJQZa.cjs +4297 -0
  90. package/dist/tool-fallback-kfhpJQZa.cjs.map +1 -0
  91. package/dist/tools/index.d.ts +14 -0
  92. package/dist/tools/misc-tool-uis.d.ts +2 -0
  93. package/dist/tools/primitives.d.ts +41 -0
  94. package/dist/tools/tool-fallback.d.ts +78 -6
  95. package/dist/tools/tool-icons.d.ts +10 -0
  96. package/dist/tools/tool-uis.d.ts +1 -23
  97. package/dist/tools.cjs +41 -0
  98. package/dist/tools.cjs.map +1 -0
  99. package/dist/tools.js +41 -0
  100. package/dist/tools.js.map +1 -0
  101. package/dist/trash-2-B5OaNAL7.cjs +5096 -0
  102. package/dist/trash-2-B5OaNAL7.cjs.map +1 -0
  103. package/dist/trash-2-CCwSURL-.js +5081 -0
  104. package/dist/trash-2-CCwSURL-.js.map +1 -0
  105. package/dist/{use-rest-conversation-history-BdnG8jEP.cjs → use-rest-conversation-history-Cm8qMRxp.cjs} +985 -5405
  106. package/dist/use-rest-conversation-history-Cm8qMRxp.cjs.map +1 -0
  107. package/dist/{use-rest-conversation-history-DpEswBqQ.js → use-rest-conversation-history-veDZS-oL.js} +1035 -5455
  108. package/dist/use-rest-conversation-history-veDZS-oL.js.map +1 -0
  109. package/dist/wrench-BEf72cyP.cjs +417 -0
  110. package/dist/wrench-BEf72cyP.cjs.map +1 -0
  111. package/dist/wrench-CbrOlVYm.js +418 -0
  112. package/dist/wrench-CbrOlVYm.js.map +1 -0
  113. package/dist/x-Dfd2NzK0.cjs +42 -0
  114. package/dist/x-Dfd2NzK0.cjs.map +1 -0
  115. package/dist/x-_DntAa_a.js +43 -0
  116. package/dist/x-_DntAa_a.js.map +1 -0
  117. package/package.json +29 -11
  118. package/dist/chat/super-grouping/tool-status-labels.d.ts +0 -1
  119. package/dist/runtime/converter.d.ts +0 -5
  120. package/dist/runtime/external-message-converter.d.ts +0 -21
  121. package/dist/runtime/schemas.d.ts +0 -24
  122. package/dist/runtime/transport.d.ts +0 -39
  123. package/dist/runtime/useAthenaRuntime.d.ts +0 -47
  124. package/dist/threads/adapter.d.ts +0 -42
  125. package/dist/threads/useActiveThreadStateHydration.d.ts +0 -12
  126. package/dist/threads/useThreadTitlePolling.d.ts +0 -14
  127. package/dist/use-rest-conversation-history-BdnG8jEP.cjs.map +0 -1
  128. package/dist/use-rest-conversation-history-DpEswBqQ.js.map +0 -1
@@ -0,0 +1,4281 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import React__default, { useRef, useMemo, useContext, createContext, useState, useCallback, memo } from "react";
4
+ import { MessagePartPrimitive, MessagePrimitive, useScrollLock } from "@assistant-ui/react";
5
+ import { w as createSlot, x as useComposedRefs, b as createLucideIcon, c as cn, C as ChevronDown, d as CircleAlert, T as Trash2, v as Play, P as Pause } from "./trash-2-CCwSURL-.js";
6
+ import "@assistant-ui/tap";
7
+ import "statewire";
8
+ import "@assistant-ui/react-statewire";
9
+ import "@assistant-ui/store";
10
+ import "@assistant-ui/core";
11
+ import * as ReactDOM from "react-dom";
12
+ import { W as Workflow, L as LayoutDashboard, U as Users, V as Video, d as Phone, a as Sparkles, j as Star, P as Package, B as Bot, H as HardDrive, M as MessageSquare, c as Palette, h as Camera, I as Image, i as Wrench, k as Folder, b as BookOpen, D as Database, g as Code, f as Monitor, T as Table, F as FileText, C as Calendar, e as Mail, G as Globe, S as Search } from "./wrench-CbrOlVYm.js";
13
+ const CATEGORY_EMOJI = {
14
+ Web: "🌐",
15
+ Email: "📧",
16
+ Document: "📄",
17
+ Spreadsheet: "📊",
18
+ SQL: "🗄️",
19
+ Database: "🗄️",
20
+ Python: "🐍",
21
+ Spaces: "📂",
22
+ Visualization: "📊",
23
+ Canvas: "🎨",
24
+ Presentation: "📽️",
25
+ UI: "🖥️",
26
+ Notebook: "📓",
27
+ AOP: "📋",
28
+ Browser: "🌐",
29
+ Computer: "💻",
30
+ Drive: "💾",
31
+ Comments: "💬",
32
+ Meetings: "📅",
33
+ Analysis: "🔬",
34
+ Memory: "💾",
35
+ Brand: "🎨",
36
+ Playbook: "📘",
37
+ GitHub: "🔀",
38
+ Ontology: "🗂️",
39
+ "Task Studio": "📜",
40
+ "Project Manager": "📋",
41
+ VM: "🖥️",
42
+ Agent: "🤖",
43
+ Files: "📁",
44
+ Media: "📸",
45
+ Integrations: "🔌",
46
+ Tool: "🔧"
47
+ };
48
+ const DEFAULT_EMOJI = CATEGORY_EMOJI.Tool;
49
+ function nonBlank(value) {
50
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
51
+ }
52
+ function quoted(value) {
53
+ return value === void 0 ? void 0 : `"${value}"`;
54
+ }
55
+ function truncateLine(text, max = 70) {
56
+ const oneLine = text.replace(/\s+/g, " ").trim();
57
+ return oneLine.length > max ? `${oneLine.slice(0, max)}...` : oneLine;
58
+ }
59
+ const describeQuery = (args) => quoted(nonBlank(args.query) ?? nonBlank(args.search_query) ?? nonBlank(args.term));
60
+ const describeUrl = (args) => nonBlank(args.url);
61
+ function describeNamed(field = "name") {
62
+ return (args) => quoted(nonBlank(args[field]) ?? nonBlank(args.title));
63
+ }
64
+ const describeSql = (args) => {
65
+ const sql = nonBlank(args.sql_query) ?? nonBlank(args.query) ?? nonBlank(args.sql);
66
+ return sql === void 0 ? void 0 : quoted(truncateLine(sql));
67
+ };
68
+ const describeRange = (args) => {
69
+ const range = nonBlank(args.range);
70
+ const explanation = nonBlank(args.explanation);
71
+ if (range && explanation) return `${range}: ${truncateLine(explanation)}`;
72
+ return range ?? (explanation ? truncateLine(explanation) : void 0);
73
+ };
74
+ const describeTable = (args) => nonBlank(args.table_name);
75
+ const describePackage = (args) => nonBlank(args.package_name) ?? nonBlank(args.package);
76
+ const describePath = (args) => nonBlank(args.file_path) ?? nonBlank(args.path);
77
+ const describeDelegation = (args) => {
78
+ const subagent = nonBlank(args.subagent_type);
79
+ const description = nonBlank(args.description);
80
+ if (subagent && description) return `${subagent}: ${truncateLine(description)}`;
81
+ return subagent ?? (description ? truncateLine(description) : void 0);
82
+ };
83
+ const TOOL_DISPLAY_META = {
84
+ // ── Web search & browse ──
85
+ search: {
86
+ displayName: "Web Search",
87
+ activeLabel: "Searching the web",
88
+ completedLabel: "Web search complete",
89
+ category: "Web",
90
+ icon: "search",
91
+ emoji: "🔍",
92
+ describe: describeQuery
93
+ },
94
+ exa_search: {
95
+ displayName: "Web Search",
96
+ activeLabel: "Searching the web",
97
+ category: "Web",
98
+ icon: "search",
99
+ emoji: "🔍",
100
+ describe: describeQuery
101
+ },
102
+ perplexity_search: {
103
+ displayName: "Web Search",
104
+ activeLabel: "Searching the web",
105
+ category: "Web",
106
+ icon: "search",
107
+ emoji: "🔍",
108
+ describe: describeQuery
109
+ },
110
+ grounded_search: {
111
+ displayName: "Grounded Search",
112
+ activeLabel: "Searching",
113
+ category: "Web",
114
+ icon: "search",
115
+ emoji: "🔍",
116
+ describe: describeQuery
117
+ },
118
+ semantic_search: {
119
+ displayName: "Semantic Search",
120
+ activeLabel: "Searching your sources",
121
+ category: "Web",
122
+ icon: "search",
123
+ emoji: "🔍",
124
+ describe: describeQuery
125
+ },
126
+ deep_research: {
127
+ displayName: "Deep Research",
128
+ activeLabel: "Researching",
129
+ category: "Web",
130
+ icon: "microscope",
131
+ emoji: "🔬",
132
+ describe: describeQuery
133
+ },
134
+ browse: {
135
+ displayName: "Browse Web Page",
136
+ activeLabel: "Reading webpage",
137
+ completedLabel: "Read webpage",
138
+ category: "Web",
139
+ icon: "globe",
140
+ describe: describeUrl
141
+ },
142
+ open_browser: {
143
+ displayName: "Open Browser",
144
+ activeLabel: "Opening browser",
145
+ category: "Web",
146
+ icon: "globe",
147
+ describe: describeUrl
148
+ },
149
+ map_urls_in_website: {
150
+ displayName: "Map Website",
151
+ activeLabel: "Mapping website",
152
+ category: "Web",
153
+ icon: "globe",
154
+ describe: describeUrl
155
+ },
156
+ track_website_changes: {
157
+ displayName: "Track Website Changes",
158
+ activeLabel: "Tracking website changes",
159
+ category: "Web",
160
+ icon: "globe",
161
+ describe: describeUrl
162
+ },
163
+ get_youtube_transcript: {
164
+ displayName: "YouTube Transcript",
165
+ activeLabel: "Fetching transcript",
166
+ category: "Web",
167
+ icon: "video",
168
+ emoji: "🎬",
169
+ describe: describeUrl
170
+ },
171
+ // ── Email & calendar ──
172
+ search_email: {
173
+ displayName: "Search Email",
174
+ activeLabel: "Searching email",
175
+ completedLabel: "Email search complete",
176
+ category: "Email",
177
+ icon: "mail",
178
+ describe: describeQuery
179
+ },
180
+ unified_email_search: {
181
+ displayName: "Search Email",
182
+ activeLabel: "Searching email",
183
+ completedLabel: "Email search complete",
184
+ category: "Email",
185
+ icon: "mail",
186
+ describe: describeQuery
187
+ },
188
+ search_gmail: {
189
+ displayName: "Search Email",
190
+ activeLabel: "Searching emails",
191
+ category: "Email",
192
+ icon: "mail",
193
+ describe: describeQuery
194
+ },
195
+ send_direct_email: {
196
+ displayName: "Send Email",
197
+ activeLabel: "Sending email",
198
+ category: "Email",
199
+ icon: "mail",
200
+ emoji: "📤"
201
+ },
202
+ unified_email_send: {
203
+ displayName: "Send Email",
204
+ activeLabel: "Sending email",
205
+ completedLabel: "Email sent",
206
+ rejectedLabel: "Email not sent (rejected)",
207
+ category: "Email",
208
+ icon: "mail",
209
+ emoji: "📤"
210
+ },
211
+ send_email_from_athena: {
212
+ displayName: "Send Email",
213
+ activeLabel: "Sending email",
214
+ category: "Email",
215
+ icon: "mail",
216
+ emoji: "📤"
217
+ },
218
+ create_email_draft: {
219
+ displayName: "Create Draft",
220
+ activeLabel: "Drafting email",
221
+ completedLabel: "Email drafted",
222
+ category: "Email",
223
+ icon: "mail",
224
+ emoji: "✉️"
225
+ },
226
+ unified_email_create_draft: {
227
+ displayName: "Create Draft",
228
+ activeLabel: "Drafting email",
229
+ completedLabel: "Email drafted",
230
+ category: "Email",
231
+ icon: "mail",
232
+ emoji: "✉️"
233
+ },
234
+ edit_email_draft: {
235
+ displayName: "Edit Draft",
236
+ activeLabel: "Editing email draft",
237
+ completedLabel: "Draft updated",
238
+ category: "Email",
239
+ icon: "pen-line",
240
+ emoji: "✏️"
241
+ },
242
+ unified_email_edit_draft: {
243
+ displayName: "Edit Draft",
244
+ activeLabel: "Editing email draft",
245
+ completedLabel: "Draft updated",
246
+ category: "Email",
247
+ icon: "pen-line",
248
+ emoji: "✏️"
249
+ },
250
+ unified_email_get_thread: {
251
+ displayName: "Get Email Thread",
252
+ activeLabel: "Loading email thread",
253
+ category: "Email",
254
+ icon: "mail"
255
+ },
256
+ unified_email_get_message: {
257
+ displayName: "Get Email",
258
+ activeLabel: "Loading email",
259
+ category: "Email",
260
+ icon: "mail"
261
+ },
262
+ unified_email_list_accounts: {
263
+ displayName: "List Email Accounts",
264
+ activeLabel: "Checking email accounts",
265
+ category: "Email",
266
+ icon: "mail"
267
+ },
268
+ email_list_accounts: {
269
+ displayName: "List Email Accounts",
270
+ activeLabel: "Checking email accounts",
271
+ category: "Email",
272
+ icon: "mail"
273
+ },
274
+ unified_email_set_default: {
275
+ displayName: "Set Default Account",
276
+ activeLabel: "Setting default email account",
277
+ category: "Email",
278
+ icon: "mail"
279
+ },
280
+ fetch_email_attachments: {
281
+ displayName: "Fetch Attachments",
282
+ activeLabel: "Fetching email attachments",
283
+ category: "Email",
284
+ icon: "mail",
285
+ emoji: "📎"
286
+ },
287
+ unified_email_fetch_attachments: {
288
+ displayName: "Fetch Attachments",
289
+ activeLabel: "Fetching email attachments",
290
+ category: "Email",
291
+ icon: "mail",
292
+ emoji: "📎"
293
+ },
294
+ forward_email: {
295
+ displayName: "Forward Email",
296
+ activeLabel: "Forwarding email",
297
+ category: "Email",
298
+ icon: "mail",
299
+ emoji: "📤"
300
+ },
301
+ unified_email_forward: {
302
+ displayName: "Forward Email",
303
+ activeLabel: "Forwarding email",
304
+ completedLabel: "Email forwarded",
305
+ rejectedLabel: "Email not forwarded (rejected)",
306
+ category: "Email",
307
+ icon: "mail",
308
+ emoji: "📤"
309
+ },
310
+ search_calendar_events: {
311
+ displayName: "Search Calendar",
312
+ activeLabel: "Checking calendar",
313
+ category: "Email",
314
+ icon: "calendar",
315
+ emoji: "📅",
316
+ describe: describeQuery
317
+ },
318
+ unified_search_calendar_events: {
319
+ displayName: "Search Calendar",
320
+ activeLabel: "Searching calendar",
321
+ category: "Email",
322
+ icon: "calendar",
323
+ emoji: "📅",
324
+ describe: describeQuery
325
+ },
326
+ create_calendar_event_draft: {
327
+ displayName: "Create Calendar Event Draft",
328
+ activeLabel: "Creating calendar event",
329
+ completedLabel: "Calendar event created",
330
+ rejectedLabel: "Calendar event not created (rejected)",
331
+ category: "Email",
332
+ icon: "calendar",
333
+ emoji: "📅"
334
+ },
335
+ unified_create_calendar_event_draft: {
336
+ displayName: "Create Calendar Event Draft",
337
+ activeLabel: "Creating calendar event",
338
+ completedLabel: "Calendar event created",
339
+ rejectedLabel: "Calendar event not created (rejected)",
340
+ category: "Email",
341
+ icon: "calendar",
342
+ emoji: "📅"
343
+ },
344
+ create_google_calendar_event: {
345
+ displayName: "Create Calendar Event",
346
+ activeLabel: "Creating calendar event",
347
+ category: "Email",
348
+ icon: "calendar",
349
+ emoji: "📅"
350
+ },
351
+ unified_create_calendar_event: {
352
+ displayName: "Create Calendar Event",
353
+ activeLabel: "Creating calendar event",
354
+ completedLabel: "Calendar event created",
355
+ rejectedLabel: "Calendar event not created (rejected)",
356
+ category: "Email",
357
+ icon: "calendar",
358
+ emoji: "📅"
359
+ },
360
+ unified_update_calendar_event: {
361
+ displayName: "Update Calendar Event",
362
+ activeLabel: "Updating calendar event",
363
+ category: "Email",
364
+ icon: "calendar",
365
+ emoji: "📅"
366
+ },
367
+ unified_calendar_get_event: {
368
+ displayName: "Get Calendar Event",
369
+ activeLabel: "Loading calendar event",
370
+ category: "Email",
371
+ icon: "calendar",
372
+ emoji: "📅"
373
+ },
374
+ unified_get_free_busy: {
375
+ displayName: "Check Availability",
376
+ activeLabel: "Checking availability",
377
+ category: "Email",
378
+ icon: "calendar",
379
+ emoji: "📅"
380
+ },
381
+ // ── Messaging & meetings ──
382
+ send_slack_message: {
383
+ displayName: "Send Slack Message",
384
+ activeLabel: "Sending Slack message",
385
+ category: "Integrations",
386
+ icon: "message-square",
387
+ emoji: "💬"
388
+ },
389
+ read_slack_channel: {
390
+ displayName: "Read Slack Channel",
391
+ activeLabel: "Reading Slack channel",
392
+ category: "Integrations",
393
+ icon: "message-square",
394
+ emoji: "💬"
395
+ },
396
+ send_teams_message: {
397
+ displayName: "Send Teams Message",
398
+ activeLabel: "Sending Teams message",
399
+ category: "Integrations",
400
+ icon: "message-square",
401
+ emoji: "💬"
402
+ },
403
+ query_meetings: {
404
+ displayName: "Query Meetings",
405
+ activeLabel: "Searching meetings",
406
+ category: "Meetings",
407
+ icon: "calendar",
408
+ describe: describeQuery
409
+ },
410
+ // ── Documents ──
411
+ create_new_document: {
412
+ displayName: "Create Document",
413
+ activeLabel: "Creating document",
414
+ completedLabel: "Created document",
415
+ category: "Document",
416
+ icon: "file-text",
417
+ describe: describeNamed()
418
+ },
419
+ create_document_from_markdown: {
420
+ displayName: "Create Document from Markdown",
421
+ activeLabel: "Creating document",
422
+ completedLabel: "Created document",
423
+ category: "Document",
424
+ icon: "file-text",
425
+ describe: describeNamed()
426
+ },
427
+ append_markdown_to_athena_document: {
428
+ displayName: "Append to Document",
429
+ activeLabel: "Updating document",
430
+ completedLabel: "Updated document",
431
+ category: "Document",
432
+ icon: "pen-line",
433
+ emoji: "📝"
434
+ },
435
+ replace_markdown_in_athena_document: {
436
+ displayName: "Replace in Document",
437
+ activeLabel: "Updating document",
438
+ completedLabel: "Updated document",
439
+ category: "Document",
440
+ icon: "pen-line",
441
+ emoji: "📝"
442
+ },
443
+ insert_markdown_before_block: {
444
+ displayName: "Insert Before Block",
445
+ activeLabel: "Inserting content",
446
+ category: "Document",
447
+ icon: "pen-line",
448
+ emoji: "📝"
449
+ },
450
+ insert_markdown_after_block: {
451
+ displayName: "Insert After Block",
452
+ activeLabel: "Inserting content",
453
+ category: "Document",
454
+ icon: "pen-line",
455
+ emoji: "📝"
456
+ },
457
+ delete_blocks_from_athena_document: {
458
+ displayName: "Delete Blocks",
459
+ activeLabel: "Deleting blocks",
460
+ category: "Document",
461
+ icon: "trash",
462
+ emoji: "🗑️"
463
+ },
464
+ clear_athena_document: {
465
+ displayName: "Clear Document",
466
+ activeLabel: "Clearing document",
467
+ category: "Document",
468
+ icon: "trash",
469
+ emoji: "🗑️"
470
+ },
471
+ execute_word_document_code: {
472
+ displayName: "Edit Word Document",
473
+ activeLabel: "Editing Word document",
474
+ category: "Document",
475
+ icon: "file-text"
476
+ },
477
+ read_full_asset: {
478
+ displayName: "Read Asset",
479
+ activeLabel: "Reviewing asset content",
480
+ completedLabel: "Asset content reviewed",
481
+ category: "Spaces",
482
+ icon: "book-open",
483
+ emoji: "📖"
484
+ },
485
+ read_asset: {
486
+ displayName: "Read Asset",
487
+ activeLabel: "Reviewing asset content",
488
+ completedLabel: "Asset content reviewed",
489
+ category: "Spaces",
490
+ icon: "book-open",
491
+ emoji: "📖"
492
+ },
493
+ convert_athena_doc_to_pdf: {
494
+ displayName: "Convert to PDF",
495
+ activeLabel: "Converting to PDF",
496
+ completedLabel: "Converted to PDF",
497
+ category: "Document",
498
+ icon: "file-text"
499
+ },
500
+ convert_to_pdf: {
501
+ displayName: "Convert to PDF",
502
+ activeLabel: "Converting to PDF",
503
+ completedLabel: "Converted to PDF",
504
+ category: "Document",
505
+ icon: "file-text"
506
+ },
507
+ // ── Spreadsheets ──
508
+ create_new_sheet: {
509
+ displayName: "Create Spreadsheet",
510
+ activeLabel: "Creating spreadsheet",
511
+ completedLabel: "Created spreadsheet",
512
+ category: "Spreadsheet",
513
+ icon: "bar-chart",
514
+ describe: describeNamed()
515
+ },
516
+ update_sheet_range: {
517
+ displayName: "Update Cells",
518
+ activeLabel: "Updating spreadsheet",
519
+ completedLabel: "Updated spreadsheet",
520
+ category: "Spreadsheet",
521
+ icon: "bar-chart",
522
+ describe: describeRange
523
+ },
524
+ bulk_format_sheet_range: {
525
+ displayName: "Format Cells",
526
+ activeLabel: "Formatting spreadsheet ranges",
527
+ completedLabel: "Formatted spreadsheet ranges",
528
+ category: "Spreadsheet",
529
+ icon: "bar-chart",
530
+ emoji: "🎨",
531
+ describe: describeRange
532
+ },
533
+ format_sheet_range: {
534
+ displayName: "Format Cells",
535
+ activeLabel: "Formatting spreadsheet",
536
+ completedLabel: "Formatted spreadsheet",
537
+ category: "Spreadsheet",
538
+ icon: "bar-chart",
539
+ emoji: "🎨",
540
+ describe: describeRange
541
+ },
542
+ set_row_column_dimensions: {
543
+ displayName: "Resize Rows and Columns",
544
+ activeLabel: "Resizing rows and columns",
545
+ category: "Spreadsheet",
546
+ icon: "table"
547
+ },
548
+ query_sheet_range: {
549
+ displayName: "Query Sheet",
550
+ activeLabel: "Querying spreadsheet",
551
+ category: "Spreadsheet",
552
+ icon: "search",
553
+ emoji: "🔍",
554
+ describe: describeRange
555
+ },
556
+ create_chart: {
557
+ displayName: "Create Chart",
558
+ activeLabel: "Creating chart",
559
+ completedLabel: "Created chart",
560
+ category: "Spreadsheet",
561
+ icon: "trending-up",
562
+ emoji: "📈"
563
+ },
564
+ execute_spreadsheet_code: {
565
+ displayName: "Execute Spreadsheet Code",
566
+ activeLabel: "Editing spreadsheet",
567
+ category: "Spreadsheet",
568
+ icon: "bar-chart"
569
+ },
570
+ execute_spreadsheet_commands: {
571
+ displayName: "Edit Spreadsheet",
572
+ activeLabel: "Editing spreadsheet",
573
+ category: "Spreadsheet",
574
+ icon: "bar-chart"
575
+ },
576
+ capture_sheet_screenshot: {
577
+ displayName: "Capture Sheet",
578
+ activeLabel: "Capturing sheet screenshot",
579
+ category: "Spreadsheet",
580
+ icon: "camera",
581
+ emoji: "📸"
582
+ },
583
+ create_table: {
584
+ displayName: "Create Table",
585
+ activeLabel: "Creating table",
586
+ completedLabel: "Created table",
587
+ category: "Spreadsheet",
588
+ icon: "table"
589
+ },
590
+ update_table: {
591
+ displayName: "Update Table",
592
+ activeLabel: "Updating table",
593
+ completedLabel: "Updated table",
594
+ category: "Spreadsheet",
595
+ icon: "table"
596
+ },
597
+ table: {
598
+ displayName: "Table",
599
+ activeLabel: "Updating table",
600
+ completedLabel: "Updated table",
601
+ category: "Spreadsheet",
602
+ icon: "table"
603
+ },
604
+ update_sheet_cell: {
605
+ displayName: "Update Cells",
606
+ activeLabel: "Updating cells",
607
+ completedLabel: "Updated cells",
608
+ category: "Spreadsheet",
609
+ icon: "bar-chart"
610
+ },
611
+ // ── SQL & databases ──
612
+ create_new_query_snippet: {
613
+ displayName: "Create Query",
614
+ activeLabel: "Creating query",
615
+ category: "SQL",
616
+ icon: "database",
617
+ describe: describeNamed()
618
+ },
619
+ execute_query_snippet: {
620
+ displayName: "Execute Query",
621
+ activeLabel: "Executing query",
622
+ category: "SQL",
623
+ icon: "play",
624
+ emoji: "▶️"
625
+ },
626
+ update_query_snippet: {
627
+ displayName: "Update Query",
628
+ activeLabel: "Updating query",
629
+ category: "SQL",
630
+ icon: "pen-line",
631
+ emoji: "✏️"
632
+ },
633
+ get_database_connection_details: {
634
+ displayName: "Get DB Connection",
635
+ activeLabel: "Loading connection details",
636
+ category: "SQL",
637
+ icon: "database",
638
+ emoji: "🔌"
639
+ },
640
+ run_sql: {
641
+ displayName: "Run SQL Query",
642
+ activeLabel: "Running database query",
643
+ completedLabel: "Query complete",
644
+ category: "Database",
645
+ icon: "database",
646
+ describe: describeSql
647
+ },
648
+ run_database_sql: {
649
+ displayName: "Run SQL Query",
650
+ activeLabel: "Running database query",
651
+ completedLabel: "Query complete",
652
+ category: "Database",
653
+ icon: "database",
654
+ describe: describeSql
655
+ },
656
+ run_sql_query_tool: {
657
+ displayName: "Run SQL Query",
658
+ activeLabel: "Running database query",
659
+ completedLabel: "Query complete",
660
+ category: "Database",
661
+ icon: "database",
662
+ describe: describeSql
663
+ },
664
+ create_database: {
665
+ displayName: "Create Database",
666
+ activeLabel: "Setting up database",
667
+ category: "Database",
668
+ icon: "database",
669
+ describe: describeNamed()
670
+ },
671
+ create_database_table: {
672
+ displayName: "Create Table",
673
+ activeLabel: "Creating table",
674
+ category: "Database",
675
+ icon: "table",
676
+ describe: describeTable
677
+ },
678
+ describe_database: {
679
+ displayName: "Describe Database",
680
+ activeLabel: "Inspecting database",
681
+ category: "Database",
682
+ icon: "database"
683
+ },
684
+ list_database_schemas: {
685
+ displayName: "List Schemas",
686
+ activeLabel: "Loading schemas",
687
+ category: "Database",
688
+ icon: "database"
689
+ },
690
+ list_database_tables: {
691
+ displayName: "List Tables",
692
+ activeLabel: "Listing database tables",
693
+ category: "Database",
694
+ icon: "database"
695
+ },
696
+ get_database_table_schema: {
697
+ displayName: "Get Table Schema",
698
+ activeLabel: "Reading table schema",
699
+ category: "Database",
700
+ icon: "database",
701
+ describe: describeTable
702
+ },
703
+ load_tool_result_to_database: {
704
+ displayName: "Load Result to Database",
705
+ activeLabel: "Loading result into database",
706
+ category: "Database",
707
+ icon: "database"
708
+ },
709
+ list_databricks_tables: {
710
+ displayName: "List Databricks Tables",
711
+ activeLabel: "Listing Databricks tables",
712
+ category: "Database",
713
+ icon: "database"
714
+ },
715
+ describe_databricks_table: {
716
+ displayName: "Describe Databricks Table",
717
+ activeLabel: "Inspecting Databricks table",
718
+ category: "Database",
719
+ icon: "database",
720
+ describe: describeTable
721
+ },
722
+ execute_databricks_query: {
723
+ displayName: "Run Databricks Query",
724
+ activeLabel: "Running Databricks query",
725
+ category: "Database",
726
+ icon: "database",
727
+ describe: describeSql
728
+ },
729
+ // ── Python ──
730
+ run_python_code: {
731
+ displayName: "Run Python",
732
+ activeLabel: "Running Python code",
733
+ completedLabel: "Python execution complete",
734
+ category: "Python",
735
+ icon: "code"
736
+ },
737
+ install_pip_package: {
738
+ displayName: "Install Package",
739
+ activeLabel: "Installing package",
740
+ category: "Python",
741
+ icon: "package",
742
+ emoji: "📦",
743
+ describe: describePackage
744
+ },
745
+ get_installed_packages: {
746
+ displayName: "List Packages",
747
+ activeLabel: "Loading installed packages",
748
+ category: "Python",
749
+ icon: "package",
750
+ emoji: "📦"
751
+ },
752
+ create_new_python_script: {
753
+ displayName: "Create Script",
754
+ activeLabel: "Creating Python script",
755
+ category: "Python",
756
+ icon: "code",
757
+ describe: describeNamed()
758
+ },
759
+ update_python_script: {
760
+ displayName: "Update Script",
761
+ activeLabel: "Updating Python script",
762
+ category: "Python",
763
+ icon: "code"
764
+ },
765
+ run_python_script: {
766
+ displayName: "Run Script",
767
+ activeLabel: "Running Python script",
768
+ category: "Python",
769
+ icon: "play",
770
+ emoji: "▶️"
771
+ },
772
+ // ── Spaces & assets ──
773
+ open_asset_in_workspace: {
774
+ displayName: "Open Asset",
775
+ activeLabel: "Opening in workspace",
776
+ completedLabel: "Opened in workspace",
777
+ category: "Spaces",
778
+ icon: "folder-open"
779
+ },
780
+ list_contents: {
781
+ displayName: "List Contents",
782
+ activeLabel: "Browsing files",
783
+ category: "Spaces",
784
+ icon: "folder",
785
+ emoji: "📁"
786
+ },
787
+ create_new_folder: {
788
+ displayName: "Create Folder",
789
+ activeLabel: "Creating folder",
790
+ category: "Spaces",
791
+ icon: "folder",
792
+ emoji: "📁",
793
+ describe: describeNamed()
794
+ },
795
+ create_new_project: {
796
+ displayName: "Create Project",
797
+ activeLabel: "Creating project",
798
+ category: "Spaces",
799
+ icon: "clipboard-list",
800
+ emoji: "📋",
801
+ describe: describeNamed()
802
+ },
803
+ update_project: {
804
+ displayName: "Update Project",
805
+ activeLabel: "Updating project",
806
+ category: "Spaces",
807
+ icon: "clipboard-list",
808
+ emoji: "📋"
809
+ },
810
+ project_links: {
811
+ displayName: "Project Links",
812
+ activeLabel: "Managing project links",
813
+ category: "Spaces",
814
+ icon: "link",
815
+ emoji: "🔗"
816
+ },
817
+ search_assets: {
818
+ displayName: "Search Assets",
819
+ activeLabel: "Searching files",
820
+ category: "Spaces",
821
+ icon: "search",
822
+ emoji: "🔍",
823
+ describe: describeQuery
824
+ },
825
+ rename_assets: {
826
+ displayName: "Rename Assets",
827
+ activeLabel: "Renaming assets",
828
+ category: "Spaces",
829
+ icon: "pen-line",
830
+ emoji: "✏️"
831
+ },
832
+ duplicate_asset: {
833
+ displayName: "Duplicate Asset",
834
+ activeLabel: "Duplicating asset",
835
+ category: "Spaces",
836
+ icon: "folder-open",
837
+ emoji: "📋"
838
+ },
839
+ move_assets_to_folder: {
840
+ displayName: "Move Assets",
841
+ activeLabel: "Moving assets",
842
+ category: "Spaces",
843
+ icon: "folder-open"
844
+ },
845
+ create_collection: {
846
+ displayName: "Create Collection",
847
+ activeLabel: "Creating collection",
848
+ completedLabel: "Created collection",
849
+ category: "Spaces",
850
+ icon: "book-open",
851
+ emoji: "📚",
852
+ describe: describeNamed()
853
+ },
854
+ update_collection: {
855
+ displayName: "Update Collection",
856
+ activeLabel: "Updating collection",
857
+ completedLabel: "Updated collection",
858
+ category: "Spaces",
859
+ icon: "book-open",
860
+ emoji: "📚"
861
+ },
862
+ add_assets_to_collection: {
863
+ displayName: "Add to Collection",
864
+ activeLabel: "Organizing assets",
865
+ completedLabel: "Assets organized",
866
+ category: "Spaces",
867
+ icon: "book-open",
868
+ emoji: "📚"
869
+ },
870
+ remove_assets_from_collection: {
871
+ displayName: "Remove from Collection",
872
+ activeLabel: "Removing assets",
873
+ category: "Spaces",
874
+ icon: "book-open",
875
+ emoji: "📚"
876
+ },
877
+ add_assets_to_favorites: {
878
+ displayName: "Add to Favorites",
879
+ activeLabel: "Adding to favorites",
880
+ category: "Spaces",
881
+ icon: "star",
882
+ emoji: "⭐"
883
+ },
884
+ // ── Visualizations & canvas ──
885
+ create_new_figure: {
886
+ displayName: "Create Figure",
887
+ activeLabel: "Creating figure",
888
+ category: "Visualization",
889
+ icon: "trending-up",
890
+ describe: describeNamed()
891
+ },
892
+ create_new_dashboard: {
893
+ displayName: "Create Dashboard",
894
+ activeLabel: "Creating dashboard",
895
+ category: "Visualization",
896
+ icon: "layout-dashboard",
897
+ describe: describeNamed()
898
+ },
899
+ update_figure_asset: {
900
+ displayName: "Update Figure",
901
+ activeLabel: "Updating figure",
902
+ category: "Visualization",
903
+ icon: "trending-up"
904
+ },
905
+ update_dashboard_asset: {
906
+ displayName: "Update Dashboard",
907
+ activeLabel: "Updating dashboard",
908
+ category: "Visualization",
909
+ icon: "layout-dashboard"
910
+ },
911
+ CreateNewCanvas: {
912
+ displayName: "Create Canvas",
913
+ activeLabel: "Creating canvas",
914
+ category: "Canvas",
915
+ icon: "palette",
916
+ describe: describeNamed()
917
+ },
918
+ UpdateCanvasAsset: {
919
+ displayName: "Update Canvas",
920
+ activeLabel: "Updating canvas",
921
+ category: "Canvas",
922
+ icon: "palette"
923
+ },
924
+ generate_image: {
925
+ displayName: "Generate Image",
926
+ activeLabel: "Generating image",
927
+ category: "Media",
928
+ icon: "image",
929
+ emoji: "🖼️"
930
+ },
931
+ query_single_image: {
932
+ displayName: "Analyze Image",
933
+ activeLabel: "Analyzing image",
934
+ category: "Media",
935
+ icon: "image",
936
+ emoji: "🖼️"
937
+ },
938
+ capture_moment: {
939
+ displayName: "Capture Moment",
940
+ activeLabel: "Capturing moment",
941
+ completedLabel: "Moment captured",
942
+ category: "Media",
943
+ icon: "camera"
944
+ },
945
+ // ── Presentations ──
946
+ create_powerpoint_deck: {
947
+ displayName: "Create Presentation",
948
+ activeLabel: "Creating presentation",
949
+ completedLabel: "Created presentation",
950
+ category: "Presentation",
951
+ icon: "presentation",
952
+ describe: describeNamed()
953
+ },
954
+ create_presentation_pptx_studio: {
955
+ displayName: "Create Presentation",
956
+ activeLabel: "Creating presentation",
957
+ completedLabel: "Created presentation",
958
+ category: "Presentation",
959
+ icon: "presentation",
960
+ describe: describeNamed()
961
+ },
962
+ capture_slide_screenshot: {
963
+ displayName: "Capture Slide",
964
+ activeLabel: "Capturing slide",
965
+ completedLabel: "Slide captured",
966
+ category: "Presentation",
967
+ icon: "camera",
968
+ emoji: "📸"
969
+ },
970
+ execute_presentation_code: {
971
+ displayName: "Execute Presentation Code",
972
+ activeLabel: "Updating presentation",
973
+ completedLabel: "Updated presentation",
974
+ category: "Presentation",
975
+ icon: "presentation",
976
+ emoji: "▶️"
977
+ },
978
+ get_template_placeholders: {
979
+ displayName: "Get Placeholders",
980
+ activeLabel: "Loading template placeholders",
981
+ category: "Presentation",
982
+ icon: "presentation"
983
+ },
984
+ // ── User interfaces ──
985
+ create_new_user_interface: {
986
+ displayName: "Create UI",
987
+ activeLabel: "Creating user interface",
988
+ category: "UI",
989
+ icon: "monitor",
990
+ describe: describeNamed()
991
+ },
992
+ update_user_interface_code: {
993
+ displayName: "Update UI Code",
994
+ activeLabel: "Updating UI code",
995
+ category: "UI",
996
+ icon: "monitor"
997
+ },
998
+ patch_user_interface_code: {
999
+ displayName: "Patch UI Code",
1000
+ activeLabel: "Patching UI code",
1001
+ category: "UI",
1002
+ icon: "monitor"
1003
+ },
1004
+ // ── Notebooks ──
1005
+ create_new_notebook: {
1006
+ displayName: "Create Notebook",
1007
+ activeLabel: "Creating notebook",
1008
+ completedLabel: "Created notebook",
1009
+ category: "Notebook",
1010
+ icon: "book-open",
1011
+ describe: describeNamed()
1012
+ },
1013
+ execute_cell: {
1014
+ displayName: "Execute Cell",
1015
+ activeLabel: "Running notebook cell",
1016
+ category: "Notebook",
1017
+ icon: "code",
1018
+ emoji: "▶️"
1019
+ },
1020
+ add_cell_content: {
1021
+ displayName: "Add Cell",
1022
+ activeLabel: "Adding cell",
1023
+ category: "Notebook",
1024
+ icon: "book-open"
1025
+ },
1026
+ replace_cell_content: {
1027
+ displayName: "Replace Cell",
1028
+ activeLabel: "Replacing cell content",
1029
+ category: "Notebook",
1030
+ icon: "book-open"
1031
+ },
1032
+ // ── Workflows (AOP) ──
1033
+ create_new_aop: {
1034
+ displayName: "Create AOP",
1035
+ activeLabel: "Creating workflow",
1036
+ category: "AOP",
1037
+ icon: "brain",
1038
+ describe: describeNamed()
1039
+ },
1040
+ update_aop: {
1041
+ displayName: "Update AOP",
1042
+ activeLabel: "Updating workflow",
1043
+ category: "AOP",
1044
+ icon: "brain"
1045
+ },
1046
+ execute_aop: {
1047
+ displayName: "Execute AOP",
1048
+ activeLabel: "Running workflow",
1049
+ category: "AOP",
1050
+ icon: "brain",
1051
+ emoji: "▶️"
1052
+ },
1053
+ // ── Browser & computer ──
1054
+ create_new_browse_session: {
1055
+ displayName: "Open Browser",
1056
+ activeLabel: "Opening browser session",
1057
+ category: "Browser",
1058
+ icon: "globe"
1059
+ },
1060
+ go_to_url: {
1061
+ displayName: "Navigate",
1062
+ activeLabel: "Navigating",
1063
+ category: "Browser",
1064
+ icon: "globe",
1065
+ describe: describeUrl
1066
+ },
1067
+ get_page_text: {
1068
+ displayName: "Read Page",
1069
+ activeLabel: "Reading page content",
1070
+ category: "Browser",
1071
+ icon: "file-text",
1072
+ emoji: "📖"
1073
+ },
1074
+ computer: {
1075
+ displayName: "Computer Action",
1076
+ activeLabel: "Using computer",
1077
+ completedLabel: "Computer action complete",
1078
+ category: "Browser",
1079
+ icon: "mouse-pointer",
1080
+ emoji: "🖱️"
1081
+ },
1082
+ computer_asset_create: {
1083
+ displayName: "Create Computer",
1084
+ activeLabel: "Creating computer asset",
1085
+ category: "Computer",
1086
+ icon: "monitor"
1087
+ },
1088
+ create_virtual_machine_session: {
1089
+ displayName: "Create VM",
1090
+ activeLabel: "Creating virtual machine",
1091
+ category: "VM",
1092
+ icon: "cpu"
1093
+ },
1094
+ vm_use_agent: {
1095
+ displayName: "VM Agent",
1096
+ activeLabel: "Running VM agent",
1097
+ category: "VM",
1098
+ icon: "bot",
1099
+ emoji: "🤖"
1100
+ },
1101
+ // ── External drives ──
1102
+ search_sharepoint: {
1103
+ displayName: "Search SharePoint",
1104
+ activeLabel: "Searching SharePoint",
1105
+ category: "Drive",
1106
+ icon: "search",
1107
+ emoji: "🔍",
1108
+ describe: describeQuery
1109
+ },
1110
+ search_onedrive: {
1111
+ displayName: "Search OneDrive",
1112
+ activeLabel: "Searching OneDrive",
1113
+ category: "Drive",
1114
+ icon: "search",
1115
+ emoji: "🔍",
1116
+ describe: describeQuery
1117
+ },
1118
+ fetch_onedrive_url: {
1119
+ displayName: "Fetch OneDrive File",
1120
+ activeLabel: "Fetching OneDrive file",
1121
+ category: "Drive",
1122
+ icon: "file-text",
1123
+ emoji: "📄",
1124
+ describe: describeUrl
1125
+ },
1126
+ search_google_drive: {
1127
+ displayName: "Search Google Drive",
1128
+ activeLabel: "Searching Google Drive",
1129
+ category: "Drive",
1130
+ icon: "search",
1131
+ emoji: "🔍",
1132
+ describe: describeQuery
1133
+ },
1134
+ // ── Comments ──
1135
+ list_comment_threads: {
1136
+ displayName: "List Comments",
1137
+ activeLabel: "Loading comments",
1138
+ category: "Comments",
1139
+ icon: "message-square"
1140
+ },
1141
+ add_comment: {
1142
+ displayName: "Add Comment",
1143
+ activeLabel: "Adding comment",
1144
+ category: "Comments",
1145
+ icon: "message-square"
1146
+ },
1147
+ reply_to_comment: {
1148
+ displayName: "Reply to Comment",
1149
+ activeLabel: "Replying to comment",
1150
+ category: "Comments",
1151
+ icon: "message-square"
1152
+ },
1153
+ // ── Analysis & memory ──
1154
+ in_depth_analysis: {
1155
+ displayName: "In-Depth Analysis",
1156
+ activeLabel: "Analyzing",
1157
+ category: "Analysis",
1158
+ icon: "microscope",
1159
+ describe: describeQuery
1160
+ },
1161
+ save_preference_as_memory: {
1162
+ displayName: "Save Preference",
1163
+ activeLabel: "Saving preference",
1164
+ category: "Memory",
1165
+ icon: "save"
1166
+ },
1167
+ search_memory_preferences: {
1168
+ displayName: "Search Preferences",
1169
+ activeLabel: "Searching preferences",
1170
+ category: "Memory",
1171
+ icon: "search",
1172
+ emoji: "🔍",
1173
+ describe: describeQuery
1174
+ },
1175
+ edit_preference_memory: {
1176
+ displayName: "Edit Preference",
1177
+ activeLabel: "Editing preference",
1178
+ category: "Memory",
1179
+ icon: "pen-line",
1180
+ emoji: "✏️"
1181
+ },
1182
+ // ── Playbooks, GitHub, ontology, scripts, project manager ──
1183
+ create_new_playbook: {
1184
+ displayName: "Create Playbook",
1185
+ activeLabel: "Creating playbook",
1186
+ category: "Playbook",
1187
+ icon: "book-open",
1188
+ describe: describeNamed()
1189
+ },
1190
+ update_playbook: {
1191
+ displayName: "Update Playbook",
1192
+ activeLabel: "Updating playbook",
1193
+ category: "Playbook",
1194
+ icon: "book-open"
1195
+ },
1196
+ github_fetch_file: {
1197
+ displayName: "Fetch File",
1198
+ activeLabel: "Fetching file from GitHub",
1199
+ category: "GitHub",
1200
+ icon: "file-text",
1201
+ emoji: "📄",
1202
+ describe: describePath
1203
+ },
1204
+ github_list_directory: {
1205
+ displayName: "List Directory",
1206
+ activeLabel: "Listing GitHub directory",
1207
+ category: "GitHub",
1208
+ icon: "folder",
1209
+ emoji: "📁",
1210
+ describe: describePath
1211
+ },
1212
+ github_get_pull_request: {
1213
+ displayName: "Get Pull Request",
1214
+ activeLabel: "Loading pull request",
1215
+ category: "GitHub",
1216
+ icon: "git-pull-request"
1217
+ },
1218
+ github_list_pull_requests: {
1219
+ displayName: "List Pull Requests",
1220
+ activeLabel: "Loading pull requests",
1221
+ category: "GitHub",
1222
+ icon: "git-pull-request"
1223
+ },
1224
+ list_object_types: {
1225
+ displayName: "List Object Types",
1226
+ activeLabel: "Reading object types",
1227
+ category: "Ontology",
1228
+ icon: "boxes"
1229
+ },
1230
+ create_object_type: {
1231
+ displayName: "Create Object Type",
1232
+ activeLabel: "Creating object type",
1233
+ category: "Ontology",
1234
+ icon: "boxes",
1235
+ emoji: "🧩",
1236
+ describe: describeNamed()
1237
+ },
1238
+ update_object_type: {
1239
+ displayName: "Update Object Type",
1240
+ activeLabel: "Updating object type",
1241
+ category: "Ontology",
1242
+ icon: "boxes",
1243
+ emoji: "🧩"
1244
+ },
1245
+ search_objects: {
1246
+ displayName: "Search Objects",
1247
+ activeLabel: "Searching objects",
1248
+ category: "Ontology",
1249
+ icon: "search",
1250
+ emoji: "🔎",
1251
+ describe: describeQuery
1252
+ },
1253
+ create_object: {
1254
+ displayName: "Create Object",
1255
+ activeLabel: "Creating object",
1256
+ category: "Ontology",
1257
+ icon: "package",
1258
+ emoji: "📦",
1259
+ describe: describeNamed()
1260
+ },
1261
+ create_objects: {
1262
+ displayName: "Create Objects",
1263
+ activeLabel: "Creating objects",
1264
+ category: "Ontology",
1265
+ icon: "package",
1266
+ emoji: "📦"
1267
+ },
1268
+ update_object: {
1269
+ displayName: "Update Object",
1270
+ activeLabel: "Updating object",
1271
+ category: "Ontology",
1272
+ icon: "package",
1273
+ emoji: "📦"
1274
+ },
1275
+ archive_object: {
1276
+ displayName: "Archive Object",
1277
+ activeLabel: "Archiving object",
1278
+ category: "Ontology",
1279
+ icon: "package"
1280
+ },
1281
+ get_object_links: {
1282
+ displayName: "Get Object Links",
1283
+ activeLabel: "Reading links",
1284
+ category: "Ontology",
1285
+ icon: "link",
1286
+ emoji: "🔗"
1287
+ },
1288
+ link_objects: {
1289
+ displayName: "Link Objects",
1290
+ activeLabel: "Linking objects",
1291
+ category: "Ontology",
1292
+ icon: "link",
1293
+ emoji: "🔗"
1294
+ },
1295
+ unlink_objects: {
1296
+ displayName: "Unlink Objects",
1297
+ activeLabel: "Removing link",
1298
+ category: "Ontology",
1299
+ icon: "link",
1300
+ emoji: "🔗"
1301
+ },
1302
+ create_wm_script: {
1303
+ displayName: "Create Script",
1304
+ activeLabel: "Creating script",
1305
+ category: "Task Studio",
1306
+ icon: "scroll-text",
1307
+ describe: describeNamed()
1308
+ },
1309
+ execute_wm_script: {
1310
+ displayName: "Execute Script",
1311
+ activeLabel: "Executing script",
1312
+ category: "Task Studio",
1313
+ icon: "play",
1314
+ emoji: "▶️"
1315
+ },
1316
+ create_project_with_manager: {
1317
+ displayName: "Create Managed Project",
1318
+ activeLabel: "Creating managed project",
1319
+ category: "Project Manager",
1320
+ icon: "clipboard-list",
1321
+ describe: describeNamed()
1322
+ },
1323
+ get_pm_roadmap: {
1324
+ displayName: "Get Roadmap",
1325
+ activeLabel: "Loading roadmap",
1326
+ category: "Project Manager",
1327
+ icon: "clipboard-list",
1328
+ emoji: "🗺️"
1329
+ },
1330
+ // ── Agent runtime & workspace files (deepagents built-ins) ──
1331
+ task: {
1332
+ displayName: "Delegate to Subagent",
1333
+ activeLabel: "Delegating to a subagent",
1334
+ category: "Agent",
1335
+ internal: true,
1336
+ icon: "bot",
1337
+ describe: describeDelegation
1338
+ },
1339
+ start_async_task: {
1340
+ displayName: "Start Background Task",
1341
+ activeLabel: "Starting background task",
1342
+ category: "Agent",
1343
+ internal: true,
1344
+ icon: "bot",
1345
+ describe: describeDelegation
1346
+ },
1347
+ check_async_task: {
1348
+ displayName: "Check Background Task",
1349
+ activeLabel: "Checking background task",
1350
+ category: "Agent",
1351
+ internal: true,
1352
+ icon: "bot"
1353
+ },
1354
+ update_async_task: {
1355
+ displayName: "Update Background Task",
1356
+ activeLabel: "Updating background task",
1357
+ category: "Agent",
1358
+ internal: true,
1359
+ icon: "bot"
1360
+ },
1361
+ cancel_async_task: {
1362
+ displayName: "Cancel Background Task",
1363
+ activeLabel: "Cancelling background task",
1364
+ category: "Agent",
1365
+ internal: true,
1366
+ icon: "bot"
1367
+ },
1368
+ list_async_tasks: {
1369
+ displayName: "List Background Tasks",
1370
+ activeLabel: "Listing background tasks",
1371
+ category: "Agent",
1372
+ internal: true,
1373
+ icon: "bot"
1374
+ },
1375
+ write_todos: {
1376
+ displayName: "Plan",
1377
+ activeLabel: "Planning",
1378
+ category: "Agent",
1379
+ internal: true,
1380
+ icon: "list-checks",
1381
+ emoji: "📝"
1382
+ },
1383
+ ask: {
1384
+ displayName: "Ask a Question",
1385
+ activeLabel: "Waiting for your input",
1386
+ completedLabel: "Input received",
1387
+ category: "Agent",
1388
+ internal: true,
1389
+ icon: "circle-help",
1390
+ emoji: "❓"
1391
+ },
1392
+ final_response: {
1393
+ displayName: "Final Response",
1394
+ activeLabel: "Finishing up",
1395
+ category: "Agent",
1396
+ internal: true,
1397
+ icon: "flag",
1398
+ emoji: "🏁"
1399
+ },
1400
+ execute: {
1401
+ displayName: "Run Command",
1402
+ activeLabel: "Running a command",
1403
+ category: "Files",
1404
+ internal: true,
1405
+ icon: "terminal",
1406
+ emoji: "⌨️"
1407
+ },
1408
+ eval: {
1409
+ displayName: "Evaluate Code",
1410
+ activeLabel: "Evaluating code",
1411
+ category: "Files",
1412
+ internal: true,
1413
+ icon: "code"
1414
+ },
1415
+ read_file: {
1416
+ displayName: "Review Working Files",
1417
+ activeLabel: "Reviewing working files",
1418
+ category: "Files",
1419
+ internal: true,
1420
+ icon: "scan-search",
1421
+ describe: describePath
1422
+ },
1423
+ ls: {
1424
+ displayName: "Check Workspace",
1425
+ activeLabel: "Checking the workspace",
1426
+ category: "Files",
1427
+ internal: true,
1428
+ icon: "folder-open",
1429
+ describe: describePath
1430
+ },
1431
+ write_file: {
1432
+ displayName: "Save Working Files",
1433
+ activeLabel: "Saving working files",
1434
+ category: "Files",
1435
+ internal: true,
1436
+ icon: "file-text",
1437
+ describe: describePath
1438
+ },
1439
+ edit_file: {
1440
+ displayName: "Update Working Files",
1441
+ activeLabel: "Updating working files",
1442
+ category: "Files",
1443
+ internal: true,
1444
+ icon: "pen-line",
1445
+ describe: describePath
1446
+ },
1447
+ glob: {
1448
+ displayName: "Search Working Files",
1449
+ activeLabel: "Searching working files",
1450
+ category: "Files",
1451
+ internal: true,
1452
+ icon: "search",
1453
+ describe: (args) => nonBlank(args.pattern) ?? nonBlank(args.query) ?? nonBlank(args.path)
1454
+ },
1455
+ grep: {
1456
+ displayName: "Search Working Files",
1457
+ activeLabel: "Searching working files",
1458
+ category: "Files",
1459
+ internal: true,
1460
+ icon: "search",
1461
+ describe: (args) => nonBlank(args.pattern) ?? nonBlank(args.query) ?? nonBlank(args.path)
1462
+ },
1463
+ // ── Athena Studio SDK sub-calls (programmatic tool calling) ──
1464
+ CreateWorkbook: {
1465
+ displayName: "Create Workbook",
1466
+ activeLabel: "Creating workbook",
1467
+ category: "Spreadsheet",
1468
+ internal: true,
1469
+ icon: "bar-chart",
1470
+ describe: describeNamed()
1471
+ },
1472
+ AddSheet: {
1473
+ displayName: "Add Sheet",
1474
+ activeLabel: "Adding sheet",
1475
+ category: "Spreadsheet",
1476
+ internal: true,
1477
+ icon: "table",
1478
+ describe: describeNamed()
1479
+ },
1480
+ OpenWorkbook: {
1481
+ displayName: "Open Workbook",
1482
+ activeLabel: "Opening workbook",
1483
+ category: "Spreadsheet",
1484
+ internal: true,
1485
+ icon: "folder-open"
1486
+ },
1487
+ WriteCells: {
1488
+ displayName: "Write Cells",
1489
+ activeLabel: "Writing cells",
1490
+ category: "Spreadsheet",
1491
+ internal: true,
1492
+ icon: "bar-chart",
1493
+ describe: describeRange
1494
+ },
1495
+ CreatePresentation: {
1496
+ displayName: "Create Presentation",
1497
+ activeLabel: "Creating presentation",
1498
+ category: "Presentation",
1499
+ internal: true,
1500
+ icon: "presentation",
1501
+ describe: describeNamed()
1502
+ },
1503
+ OpenPresentation: {
1504
+ displayName: "Open Presentation",
1505
+ activeLabel: "Opening presentation",
1506
+ category: "Presentation",
1507
+ internal: true,
1508
+ icon: "folder-open"
1509
+ },
1510
+ AddSlide: {
1511
+ displayName: "Add Slide",
1512
+ activeLabel: "Adding slide",
1513
+ category: "Presentation",
1514
+ internal: true,
1515
+ icon: "presentation"
1516
+ },
1517
+ CreateDocument: {
1518
+ displayName: "Create Document",
1519
+ activeLabel: "Creating document",
1520
+ category: "Document",
1521
+ internal: true,
1522
+ icon: "file-text",
1523
+ describe: describeNamed()
1524
+ },
1525
+ OpenDocument: {
1526
+ displayName: "Open Document",
1527
+ activeLabel: "Opening document",
1528
+ category: "Document",
1529
+ internal: true,
1530
+ icon: "folder-open"
1531
+ },
1532
+ CreateParagraph: {
1533
+ displayName: "Write Paragraph",
1534
+ activeLabel: "Writing paragraph",
1535
+ category: "Document",
1536
+ internal: true,
1537
+ icon: "pen-line"
1538
+ },
1539
+ CreateHeading: {
1540
+ displayName: "Write Heading",
1541
+ activeLabel: "Writing heading",
1542
+ category: "Document",
1543
+ internal: true,
1544
+ icon: "pen-line"
1545
+ },
1546
+ CreateTable: {
1547
+ displayName: "Insert Table",
1548
+ activeLabel: "Inserting table",
1549
+ category: "Document",
1550
+ internal: true,
1551
+ icon: "table"
1552
+ },
1553
+ AddCitation: {
1554
+ displayName: "Add Citation",
1555
+ activeLabel: "Adding citation",
1556
+ category: "Document",
1557
+ internal: true,
1558
+ icon: "link"
1559
+ },
1560
+ // ── Chrome extension (device tools) ──
1561
+ chrome_tabs_context: {
1562
+ displayName: "Open Tabs",
1563
+ activeLabel: "Checking open tabs",
1564
+ completedLabel: "Checked open tabs",
1565
+ category: "Browser",
1566
+ icon: "globe"
1567
+ },
1568
+ chrome_tabs_create: {
1569
+ displayName: "New Tab",
1570
+ activeLabel: "Opening a new tab",
1571
+ completedLabel: "Opened a new tab",
1572
+ category: "Browser",
1573
+ icon: "globe"
1574
+ },
1575
+ chrome_batch: {
1576
+ displayName: "Chrome Actions",
1577
+ activeLabel: "Working in Chrome",
1578
+ completedLabel: "Chrome actions complete",
1579
+ category: "Browser",
1580
+ icon: "list-checks"
1581
+ },
1582
+ chrome_computer: {
1583
+ displayName: "Page Interaction",
1584
+ activeLabel: "Interacting with the page",
1585
+ completedLabel: "Page interaction complete",
1586
+ category: "Browser",
1587
+ icon: "mouse-pointer",
1588
+ emoji: "🖱️"
1589
+ },
1590
+ chrome_navigate: {
1591
+ displayName: "Navigate Page",
1592
+ activeLabel: "Navigating the page",
1593
+ completedLabel: "Page navigation complete",
1594
+ category: "Browser",
1595
+ icon: "globe"
1596
+ },
1597
+ chrome_read_page: {
1598
+ displayName: "Read Page",
1599
+ activeLabel: "Reading the page",
1600
+ completedLabel: "Read the page",
1601
+ category: "Browser",
1602
+ icon: "file-text",
1603
+ emoji: "📖"
1604
+ },
1605
+ chrome_find: {
1606
+ displayName: "Find on Page",
1607
+ activeLabel: "Finding page content",
1608
+ completedLabel: "Found page content",
1609
+ category: "Browser",
1610
+ icon: "scan-search",
1611
+ emoji: "🔍"
1612
+ },
1613
+ chrome_form_input: {
1614
+ displayName: "Fill Form",
1615
+ activeLabel: "Filling in the page",
1616
+ completedLabel: "Updated the page",
1617
+ category: "Browser",
1618
+ icon: "pen-line"
1619
+ },
1620
+ chrome_get_page_text: {
1621
+ displayName: "Page Text",
1622
+ activeLabel: "Reading page text",
1623
+ completedLabel: "Read page text",
1624
+ category: "Browser",
1625
+ icon: "file-text",
1626
+ emoji: "📖"
1627
+ },
1628
+ chrome_javascript: {
1629
+ displayName: "Page JavaScript",
1630
+ activeLabel: "Running page JavaScript",
1631
+ completedLabel: "Page JavaScript complete",
1632
+ category: "Browser",
1633
+ icon: "code"
1634
+ },
1635
+ chrome_read_console: {
1636
+ displayName: "Browser Console",
1637
+ activeLabel: "Checking the console",
1638
+ completedLabel: "Checked the console",
1639
+ category: "Browser",
1640
+ icon: "terminal"
1641
+ },
1642
+ chrome_read_network: {
1643
+ displayName: "Network Activity",
1644
+ activeLabel: "Checking network activity",
1645
+ completedLabel: "Checked network activity",
1646
+ category: "Browser",
1647
+ icon: "link"
1648
+ },
1649
+ chrome_wait_for: {
1650
+ displayName: "Wait for Page",
1651
+ activeLabel: "Waiting for the page",
1652
+ completedLabel: "Page is ready",
1653
+ category: "Browser",
1654
+ icon: "play"
1655
+ },
1656
+ chrome_gif_creator: {
1657
+ displayName: "Create GIF",
1658
+ activeLabel: "Creating a GIF",
1659
+ completedLabel: "Created a GIF",
1660
+ category: "Browser",
1661
+ icon: "image",
1662
+ emoji: "🎞️"
1663
+ },
1664
+ chrome_shortcuts_list: {
1665
+ displayName: "Browser Shortcuts",
1666
+ activeLabel: "Checking browser shortcuts",
1667
+ completedLabel: "Checked browser shortcuts",
1668
+ category: "Browser",
1669
+ icon: "list-checks"
1670
+ },
1671
+ chrome_shortcuts_execute: {
1672
+ displayName: "Run Browser Shortcut",
1673
+ activeLabel: "Using a browser shortcut",
1674
+ completedLabel: "Browser shortcut complete",
1675
+ category: "Browser",
1676
+ icon: "play"
1677
+ },
1678
+ chrome_handle_dialog: {
1679
+ displayName: "Browser Dialog",
1680
+ activeLabel: "Handling the browser dialog",
1681
+ completedLabel: "Handled the browser dialog",
1682
+ category: "Browser",
1683
+ icon: "message-square"
1684
+ },
1685
+ // ── Tool management ──
1686
+ toggle_toolkit: {
1687
+ displayName: "Toggle Toolkit",
1688
+ activeLabel: "Toggling toolkit",
1689
+ category: "Tool",
1690
+ icon: "settings",
1691
+ emoji: "🧰"
1692
+ },
1693
+ enable_tool_by_id: {
1694
+ displayName: "Enable Tool",
1695
+ activeLabel: "Enabling tool",
1696
+ category: "Tool",
1697
+ icon: "settings",
1698
+ emoji: "🧰"
1699
+ }
1700
+ };
1701
+ function formatToolName(toolName) {
1702
+ return toolName.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char) => char.toUpperCase()).trim();
1703
+ }
1704
+ function defaultToolDisplayMeta(toolName) {
1705
+ const displayName = formatToolName(toolName);
1706
+ return {
1707
+ displayName,
1708
+ activeLabel: `Running ${displayName}`,
1709
+ category: "Tool",
1710
+ icon: "wrench",
1711
+ emoji: DEFAULT_EMOJI
1712
+ };
1713
+ }
1714
+ function hasToolDisplayMeta(toolName) {
1715
+ return Object.hasOwn(TOOL_DISPLAY_META, toolName);
1716
+ }
1717
+ function getToolDisplayMeta(toolName) {
1718
+ const entry = TOOL_DISPLAY_META[toolName];
1719
+ if (!entry) return defaultToolDisplayMeta(toolName);
1720
+ return { ...entry, emoji: entry.emoji ?? CATEGORY_EMOJI[entry.category] };
1721
+ }
1722
+ function describeToolArgs({
1723
+ toolName,
1724
+ args
1725
+ }) {
1726
+ const describe = getToolDisplayMeta(toolName).describe;
1727
+ if (!describe || !args) return void 0;
1728
+ const summary = describe(args);
1729
+ return (summary == null ? void 0 : summary.trim()) ? summary : void 0;
1730
+ }
1731
+ function toolActiveLabel({
1732
+ toolName,
1733
+ args
1734
+ }) {
1735
+ const meta = getToolDisplayMeta(toolName);
1736
+ const summary = describeToolArgs({ toolName, args });
1737
+ return summary ? `${meta.activeLabel}: ${summary}` : meta.activeLabel;
1738
+ }
1739
+ const PAST_TENSE_IRREGULARS = [
1740
+ [/^Taking\b/, "Took"],
1741
+ [/^Getting\b/, "Got"],
1742
+ [/^Running\b/, "Ran"],
1743
+ [/^Reading\b/, "Read"],
1744
+ [/^Finding\b/, "Found"],
1745
+ [/^Writing\b/, "Wrote"],
1746
+ [/^Building\b/, "Built"],
1747
+ [/^Setting\b/, "Set"],
1748
+ [/^Sending\b/, "Sent"]
1749
+ ];
1750
+ function toolCompletedLabel(activeLabel) {
1751
+ for (const [pattern, replacement] of PAST_TENSE_IRREGULARS) {
1752
+ if (pattern.test(activeLabel)) return activeLabel.replace(pattern, replacement);
1753
+ }
1754
+ return activeLabel.replace(
1755
+ /^(\w+)ing\b/,
1756
+ (_match, base) => /[^aeiou]y$/.test(base) ? `${base.slice(0, -1)}ied` : `${base}ed`
1757
+ );
1758
+ }
1759
+ function toolStatusLabel(toolName, state, displayName) {
1760
+ const known = hasToolDisplayMeta(toolName);
1761
+ const meta = getToolDisplayMeta(toolName);
1762
+ const name = known ? meta.displayName : displayName ?? meta.displayName;
1763
+ switch (state) {
1764
+ case "running":
1765
+ return known || !displayName ? meta.activeLabel : `Running ${displayName}`;
1766
+ case "complete":
1767
+ if (meta.completedLabel) return meta.completedLabel;
1768
+ return known ? toolCompletedLabel(meta.activeLabel) : name;
1769
+ case "rejected":
1770
+ return meta.rejectedLabel ?? `${name} — rejected`;
1771
+ case "cancelled":
1772
+ return `${name} — cancelled`;
1773
+ case "paused":
1774
+ return `${name} — paused`;
1775
+ case "error":
1776
+ return `${name} failed`;
1777
+ case "waiting":
1778
+ return "Waiting for your input";
1779
+ }
1780
+ }
1781
+ function isRecord(value) {
1782
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1783
+ }
1784
+ function parseJsonRecord(value) {
1785
+ try {
1786
+ const parsed = JSON.parse(value);
1787
+ return isRecord(parsed) ? parsed : null;
1788
+ } catch {
1789
+ return null;
1790
+ }
1791
+ }
1792
+ function resultRecord(result) {
1793
+ if (typeof result === "string") return parseJsonRecord(result);
1794
+ return isRecord(result) ? result : null;
1795
+ }
1796
+ function stringField(record, keys) {
1797
+ if (!record) return null;
1798
+ for (const key of keys) {
1799
+ const value = record[key];
1800
+ if (typeof value === "string" && value.trim()) return value;
1801
+ }
1802
+ return null;
1803
+ }
1804
+ function resultMessage(result) {
1805
+ return stringField(resultRecord(result), ["message"]);
1806
+ }
1807
+ const FAILURE_DETAIL_KEYS = ["error", "errorCode", "error_code"];
1808
+ const INTERVENTION_DETAIL_KEYS = ["message", "reason", "errorCode", "error_code"];
1809
+ const FAILURE_CODE_KEYS = ["errorCode", "error_code", "code"];
1810
+ const FAILURE_MESSAGE_KEYS = ["error", "message", "reason"];
1811
+ function batchReportFailure(trimmed) {
1812
+ var _a;
1813
+ const lines = trimmed.split("\n");
1814
+ const header = ((_a = lines[0]) == null ? void 0 : _a.trim()) ?? "";
1815
+ if (!/^[\w.-]*batch: \d+\/\d+ ok — STOPPED at step \d+/.test(header)) {
1816
+ return null;
1817
+ }
1818
+ const stepError = lines.map((line) => line.trim()).find(
1819
+ (line) => /^\d+\.\s/.test(line) && (line.includes(" ERROR — ") || line.endsWith(" ERROR"))
1820
+ );
1821
+ return stepError ? `${header}
1822
+ ${stepError}` : header;
1823
+ }
1824
+ const STRING_ERROR_PREFIX = /^(?:Error:|Tool execution failed\b|Failed to route tool call\b)\s*/;
1825
+ function plainStringError(result) {
1826
+ if (typeof result !== "string") return null;
1827
+ const trimmed = result.trim();
1828
+ if (!trimmed || parseJsonRecord(trimmed)) return null;
1829
+ if (STRING_ERROR_PREFIX.test(trimmed)) {
1830
+ return trimmed.replace(STRING_ERROR_PREFIX, "").trim() || trimmed;
1831
+ }
1832
+ return batchReportFailure(trimmed);
1833
+ }
1834
+ function pausedNotice(result) {
1835
+ if (typeof result !== "string") return null;
1836
+ const trimmed = result.trim();
1837
+ return /^⏸️?\s*Interrupted —/.test(trimmed) ? trimmed : null;
1838
+ }
1839
+ function stringifyUnknown(value) {
1840
+ if (value == null) return null;
1841
+ if (typeof value === "string") return value;
1842
+ if (value instanceof Error) return value.message;
1843
+ try {
1844
+ return JSON.stringify(value);
1845
+ } catch {
1846
+ return String(value);
1847
+ }
1848
+ }
1849
+ function toolFailure({
1850
+ status,
1851
+ result,
1852
+ isError,
1853
+ passThroughPayload = false
1854
+ }) {
1855
+ if ((status == null ? void 0 : status.type) === "incomplete") {
1856
+ const errorText = stringifyUnknown(status.error);
1857
+ return {
1858
+ message: errorText ?? (status.reason === "cancelled" ? "Cancelled" : `Tool stopped: ${status.reason}`)
1859
+ };
1860
+ }
1861
+ const record = resultRecord(result);
1862
+ const data = isRecord(record == null ? void 0 : record.data) ? record.data : null;
1863
+ const humanIntervention = isRecord(data == null ? void 0 : data.humanIntervention) ? data.humanIntervention : null;
1864
+ const failureDetail = stringField(record, FAILURE_DETAIL_KEYS) ?? stringField(humanIntervention, INTERVENTION_DETAIL_KEYS);
1865
+ const flagged = (record == null ? void 0 : record.success) === false || (record == null ? void 0 : record.ok) === false;
1866
+ const flaggedFailure = flagged && (!passThroughPayload || failureDetail !== null);
1867
+ const errorField = stringField(record, ["error"]) !== null;
1868
+ const stringError = plainStringError(result);
1869
+ if (!isError && !flaggedFailure && !errorField && !stringError) return null;
1870
+ const code = stringField(record, FAILURE_CODE_KEYS) ?? stringField(humanIntervention, FAILURE_CODE_KEYS) ?? void 0;
1871
+ const message = stringField(record, FAILURE_MESSAGE_KEYS) ?? stringField(humanIntervention, FAILURE_MESSAGE_KEYS) ?? stringError ?? (typeof result === "string" && !parseJsonRecord(result) ? result : null) ?? "Tool execution failed";
1872
+ return { message, code };
1873
+ }
1874
+ function classifyToolResult({
1875
+ status,
1876
+ result,
1877
+ isError,
1878
+ passThroughPayload
1879
+ }) {
1880
+ const notice = pausedNotice(result);
1881
+ if (notice) return { state: "paused", notice };
1882
+ const rejection = passThroughPayload ? null : readRejectedToolResult(result);
1883
+ if (rejection) return { state: "rejected", rejection };
1884
+ const failure = toolFailure({ status, result, isError, passThroughPayload });
1885
+ if (failure) return { state: "error", failure };
1886
+ if ((status == null ? void 0 : status.type) === "requires-action") return { state: "requires-action" };
1887
+ if (result === void 0 && (status == null ? void 0 : status.type) !== "complete") {
1888
+ return { state: "running" };
1889
+ }
1890
+ return { state: "complete" };
1891
+ }
1892
+ function isToolResultSuccess(result) {
1893
+ return classifyToolResult({ status: { type: "complete" }, result }).state === "complete";
1894
+ }
1895
+ const USER_REJECTION_PATTERNS = [/rejected by (?:the )?user/i, /user rejected/i];
1896
+ const USER_REJECTION_LEAD_CHARS = 100;
1897
+ function opensWithUserRejection(result) {
1898
+ const firstLine = result.trimStart().split("\n", 1)[0] ?? "";
1899
+ return USER_REJECTION_PATTERNS.some((pattern) => {
1900
+ const index = firstLine.search(pattern);
1901
+ return index !== -1 && index < USER_REJECTION_LEAD_CHARS;
1902
+ });
1903
+ }
1904
+ const NO_REASON = "no reason provided";
1905
+ const TRAILING_GUIDANCE = /\s*Acknowledge in one short sentence\..*$/i;
1906
+ function readRejectedToolResult(result) {
1907
+ var _a, _b;
1908
+ if (typeof result === "string") {
1909
+ if (!opensWithUserRejection(result)) return null;
1910
+ const reason = (_b = (_a = result.match(/Reason:\s*(.+)/i)) == null ? void 0 : _a[1]) == null ? void 0 : _b.replace(TRAILING_GUIDANCE, "").trim();
1911
+ if (!reason || reason.toLowerCase() === NO_REASON) return { reason: null };
1912
+ return { reason };
1913
+ }
1914
+ if (!isRecord(result)) return null;
1915
+ if (result.status === "rejected" || result.action === "reject" || result.decision === "rejected") {
1916
+ return { reason: stringField(result, ["reason"]) };
1917
+ }
1918
+ return null;
1919
+ }
1920
+ var __defProp$7 = Object.defineProperty;
1921
+ var __name$7 = (target, value) => __defProp$7(target, "name", { value, configurable: true });
1922
+ var NODES = [
1923
+ "a",
1924
+ "button",
1925
+ "div",
1926
+ "form",
1927
+ "h2",
1928
+ "h3",
1929
+ "img",
1930
+ "input",
1931
+ "label",
1932
+ "li",
1933
+ "nav",
1934
+ "ol",
1935
+ "p",
1936
+ "select",
1937
+ "span",
1938
+ "svg",
1939
+ "ul"
1940
+ ];
1941
+ var Primitive = NODES.reduce((primitive, node) => {
1942
+ const Slot = createSlot(`Primitive.${node}`);
1943
+ const Node = React.forwardRef((props, forwardedRef) => {
1944
+ const { asChild, ...primitiveProps } = props;
1945
+ const Comp = asChild ? Slot : node;
1946
+ if (typeof window !== "undefined") {
1947
+ window[Symbol.for("radix-ui")] = true;
1948
+ }
1949
+ return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
1950
+ });
1951
+ Node.displayName = `Primitive.${node}`;
1952
+ return { ...primitive, [node]: Node };
1953
+ }, {});
1954
+ function dispatchDiscreteCustomEvent(target, event) {
1955
+ if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
1956
+ }
1957
+ __name$7(dispatchDiscreteCustomEvent, "dispatchDiscreteCustomEvent");
1958
+ var __defProp$6 = Object.defineProperty;
1959
+ var __name$6 = (target, value) => __defProp$6(target, "name", { value, configurable: true });
1960
+ // @__NO_SIDE_EFFECTS__
1961
+ function createContext2(rootComponentName, defaultContext) {
1962
+ const Context = React.createContext(defaultContext);
1963
+ Context.displayName = rootComponentName + "Context";
1964
+ const Provider = /* @__PURE__ */ __name$6((props) => {
1965
+ const { children, ...context } = props;
1966
+ const value = React.useMemo(() => context, Object.values(context));
1967
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children });
1968
+ }, "Provider");
1969
+ Provider.displayName = rootComponentName + "Provider";
1970
+ function useContext2(consumerName, options = {}) {
1971
+ const { optional = false } = options;
1972
+ const context = React.useContext(Context);
1973
+ if (context) return context;
1974
+ if (defaultContext !== void 0) return defaultContext;
1975
+ if (optional) return void 0;
1976
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
1977
+ }
1978
+ __name$6(useContext2, "useContext");
1979
+ return [Provider, useContext2];
1980
+ }
1981
+ __name$6(createContext2, "createContext");
1982
+ // @__NO_SIDE_EFFECTS__
1983
+ function createContextScope(scopeName, createContextScopeDeps = []) {
1984
+ let defaultContexts = [];
1985
+ function createContext3(rootComponentName, defaultContext) {
1986
+ const BaseContext = React.createContext(defaultContext);
1987
+ BaseContext.displayName = rootComponentName + "Context";
1988
+ const index = defaultContexts.length;
1989
+ defaultContexts = [...defaultContexts, defaultContext];
1990
+ const Provider = /* @__PURE__ */ __name$6((props) => {
1991
+ var _a;
1992
+ const { scope, children, ...context } = props;
1993
+ const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index]) || BaseContext;
1994
+ const value = React.useMemo(() => context, Object.values(context));
1995
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children });
1996
+ }, "Provider");
1997
+ Provider.displayName = rootComponentName + "Provider";
1998
+ function useContext2(consumerName, scope, options = {}) {
1999
+ var _a;
2000
+ const { optional = false } = options;
2001
+ const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index]) || BaseContext;
2002
+ const context = React.useContext(Context);
2003
+ if (context) return context;
2004
+ if (defaultContext !== void 0) return defaultContext;
2005
+ if (optional) return void 0;
2006
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
2007
+ }
2008
+ __name$6(useContext2, "useContext");
2009
+ return [Provider, useContext2];
2010
+ }
2011
+ __name$6(createContext3, "createContext");
2012
+ const createScope = /* @__PURE__ */ __name$6(() => {
2013
+ const scopeContexts = defaultContexts.map((defaultContext) => {
2014
+ return React.createContext(defaultContext);
2015
+ });
2016
+ return /* @__PURE__ */ __name$6(function useScope(scope) {
2017
+ const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
2018
+ return React.useMemo(
2019
+ () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
2020
+ [scope, contexts]
2021
+ );
2022
+ }, "useScope");
2023
+ }, "createScope");
2024
+ createScope.scopeName = scopeName;
2025
+ return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
2026
+ }
2027
+ __name$6(createContextScope, "createContextScope");
2028
+ function composeContextScopes(...scopes) {
2029
+ const baseScope = scopes[0];
2030
+ if (scopes.length === 1) return baseScope;
2031
+ const createScope = /* @__PURE__ */ __name$6(() => {
2032
+ const scopeHooks = scopes.map((createScope2) => ({
2033
+ useScope: createScope2(),
2034
+ scopeName: createScope2.scopeName
2035
+ }));
2036
+ return /* @__PURE__ */ __name$6(function useComposedScopes(overrideScopes) {
2037
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
2038
+ const scopeProps = useScope(overrideScopes);
2039
+ const currentScope = scopeProps[`__scope${scopeName}`];
2040
+ return { ...nextScopes2, ...currentScope };
2041
+ }, {});
2042
+ return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
2043
+ }, "useComposedScopes");
2044
+ }, "createScope");
2045
+ createScope.scopeName = baseScope.scopeName;
2046
+ return createScope;
2047
+ }
2048
+ __name$6(composeContextScopes, "composeContextScopes");
2049
+ var __defProp$5 = Object.defineProperty;
2050
+ var __name$5 = (target, value) => __defProp$5(target, "name", { value, configurable: true });
2051
+ var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
2052
+ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
2053
+ return /* @__PURE__ */ __name$5(function handleEvent(event) {
2054
+ originalEventHandler == null ? void 0 : originalEventHandler(event);
2055
+ if (checkForDefaultPrevented === false || !event || !event.defaultPrevented) {
2056
+ return ourEventHandler == null ? void 0 : ourEventHandler(event);
2057
+ }
2058
+ }, "handleEvent");
2059
+ }
2060
+ __name$5(composeEventHandlers, "composeEventHandlers");
2061
+ function getOwnerWindow(element) {
2062
+ var _a;
2063
+ if (!canUseDOM) {
2064
+ throw new Error("Cannot access window outside of the DOM");
2065
+ }
2066
+ return ((_a = element == null ? void 0 : element.ownerDocument) == null ? void 0 : _a.defaultView) ?? window;
2067
+ }
2068
+ __name$5(getOwnerWindow, "getOwnerWindow");
2069
+ function getOwnerDocument(element) {
2070
+ if (!canUseDOM) {
2071
+ throw new Error("Cannot access document outside of the DOM");
2072
+ }
2073
+ return (element == null ? void 0 : element.ownerDocument) ?? document;
2074
+ }
2075
+ __name$5(getOwnerDocument, "getOwnerDocument");
2076
+ function getActiveElement(node, activeDescendant = false) {
2077
+ const { activeElement } = getOwnerDocument(node);
2078
+ if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
2079
+ return null;
2080
+ }
2081
+ if (isFrame(activeElement) && activeElement.contentDocument) {
2082
+ return getActiveElement(activeElement.contentDocument.body, activeDescendant);
2083
+ }
2084
+ if (activeDescendant) {
2085
+ const id = activeElement.getAttribute("aria-activedescendant");
2086
+ if (id) {
2087
+ const element = getOwnerDocument(activeElement).getElementById(id);
2088
+ if (element) {
2089
+ return element;
2090
+ }
2091
+ }
2092
+ }
2093
+ return activeElement;
2094
+ }
2095
+ __name$5(getActiveElement, "getActiveElement");
2096
+ function isFrame(element) {
2097
+ return element.tagName === "IFRAME";
2098
+ }
2099
+ __name$5(isFrame, "isFrame");
2100
+ var useLayoutEffect2 = (globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : () => {
2101
+ };
2102
+ var __defProp$4 = Object.defineProperty;
2103
+ var __name$4 = (target, value) => __defProp$4(target, "name", { value, configurable: true });
2104
+ var useReactEffectEvent = React[" useEffectEvent ".trim().toString()];
2105
+ var useReactInsertionEffect = React[" useInsertionEffect ".trim().toString()];
2106
+ function useEffectEvent(callback) {
2107
+ if (typeof useReactEffectEvent === "function") {
2108
+ return useReactEffectEvent(callback);
2109
+ }
2110
+ const ref = React.useRef(() => {
2111
+ throw new Error("Cannot call an event handler while rendering.");
2112
+ });
2113
+ if (typeof useReactInsertionEffect === "function") {
2114
+ useReactInsertionEffect(() => {
2115
+ ref.current = callback;
2116
+ });
2117
+ } else {
2118
+ useLayoutEffect2(() => {
2119
+ ref.current = callback;
2120
+ });
2121
+ }
2122
+ return React.useMemo(() => ((...args) => {
2123
+ var _a;
2124
+ return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
2125
+ }), []);
2126
+ }
2127
+ __name$4(useEffectEvent, "useEffectEvent");
2128
+ var __defProp$3 = Object.defineProperty;
2129
+ var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
2130
+ var useInsertionEffect = React[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
2131
+ function useControllableState({
2132
+ prop,
2133
+ defaultProp,
2134
+ onChange = /* @__PURE__ */ __name$3(() => {
2135
+ }, "onChange"),
2136
+ caller
2137
+ }) {
2138
+ const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
2139
+ defaultProp,
2140
+ onChange
2141
+ });
2142
+ const isControlled = prop !== void 0;
2143
+ const value = isControlled ? prop : uncontrolledProp;
2144
+ const setValue = React.useCallback(
2145
+ (nextValue) => {
2146
+ var _a;
2147
+ if (isControlled) {
2148
+ const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
2149
+ if (value2 !== prop) {
2150
+ (_a = onChangeRef.current) == null ? void 0 : _a.call(onChangeRef, value2);
2151
+ }
2152
+ } else {
2153
+ setUncontrolledProp(nextValue);
2154
+ }
2155
+ },
2156
+ [isControlled, prop, setUncontrolledProp, onChangeRef]
2157
+ );
2158
+ return [value, setValue];
2159
+ }
2160
+ __name$3(useControllableState, "useControllableState");
2161
+ function useUncontrolledState({
2162
+ defaultProp,
2163
+ onChange
2164
+ }) {
2165
+ const [value, setValue] = React.useState(defaultProp);
2166
+ const prevValueRef = React.useRef(value);
2167
+ const onChangeRef = React.useRef(onChange);
2168
+ useInsertionEffect(() => {
2169
+ onChangeRef.current = onChange;
2170
+ }, [onChange]);
2171
+ React.useEffect(() => {
2172
+ var _a;
2173
+ if (prevValueRef.current !== value) {
2174
+ (_a = onChangeRef.current) == null ? void 0 : _a.call(onChangeRef, value);
2175
+ prevValueRef.current = value;
2176
+ }
2177
+ }, [value, prevValueRef]);
2178
+ return [value, setValue, onChangeRef];
2179
+ }
2180
+ __name$3(useUncontrolledState, "useUncontrolledState");
2181
+ function isFunction(value) {
2182
+ return typeof value === "function";
2183
+ }
2184
+ __name$3(isFunction, "isFunction");
2185
+ var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
2186
+ function useControllableStateReducer(reducer, userArgs, initialArg, init) {
2187
+ const { prop: controlledState, defaultProp, onChange: onChangeProp, caller } = userArgs;
2188
+ const isControlled = controlledState !== void 0;
2189
+ const onChange = useEffectEvent(onChangeProp);
2190
+ const args = [{ ...initialArg, state: defaultProp }];
2191
+ if (init) {
2192
+ args.push(init);
2193
+ }
2194
+ const [internalState, dispatch] = React.useReducer(
2195
+ (state2, action) => {
2196
+ if (action.type === SYNC_STATE) {
2197
+ return { ...state2, state: action.state };
2198
+ }
2199
+ const next = reducer(state2, action);
2200
+ if (isControlled && !Object.is(next.state, state2.state)) {
2201
+ onChange(next.state);
2202
+ }
2203
+ return next;
2204
+ },
2205
+ ...args
2206
+ );
2207
+ const uncontrolledState = internalState.state;
2208
+ const prevValueRef = React.useRef(uncontrolledState);
2209
+ React.useEffect(() => {
2210
+ if (prevValueRef.current !== uncontrolledState) {
2211
+ prevValueRef.current = uncontrolledState;
2212
+ if (!isControlled) {
2213
+ onChange(uncontrolledState);
2214
+ }
2215
+ }
2216
+ }, [uncontrolledState, prevValueRef, isControlled]);
2217
+ const state = React.useMemo(() => {
2218
+ const isControlled2 = controlledState !== void 0;
2219
+ if (isControlled2) {
2220
+ return { ...internalState, state: controlledState };
2221
+ }
2222
+ return internalState;
2223
+ }, [internalState, controlledState]);
2224
+ React.useEffect(() => {
2225
+ if (isControlled && !Object.is(controlledState, internalState.state)) {
2226
+ dispatch({ type: SYNC_STATE, state: controlledState });
2227
+ }
2228
+ }, [controlledState, internalState.state, isControlled]);
2229
+ return [state, dispatch];
2230
+ }
2231
+ __name$3(useControllableStateReducer, "useControllableStateReducer");
2232
+ var __defProp$2 = Object.defineProperty;
2233
+ var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
2234
+ function useStateMachine(initialState, machine) {
2235
+ return React.useReducer((state, event) => {
2236
+ const nextState = machine[state][event];
2237
+ return nextState ?? state;
2238
+ }, initialState);
2239
+ }
2240
+ __name$2(useStateMachine, "useStateMachine");
2241
+ var Presence = /* @__PURE__ */ __name$2((props) => {
2242
+ const { present, children } = props;
2243
+ const presence = usePresence(present);
2244
+ const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
2245
+ const ref = useStableComposedRefs(presence.ref, getElementRef(child));
2246
+ const forceMount = typeof children === "function";
2247
+ return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
2248
+ }, "Presence");
2249
+ function usePresence(present) {
2250
+ const [node, setNode] = React.useState();
2251
+ const stylesRef = React.useRef(null);
2252
+ const prevPresentRef = React.useRef(present);
2253
+ const prevAnimationNameRef = React.useRef("none");
2254
+ const mountAnimationNameRef = React.useRef(void 0);
2255
+ const initialState = present ? "mounted" : "unmounted";
2256
+ const [state, send] = useStateMachine(initialState, {
2257
+ mounted: {
2258
+ UNMOUNT: "unmounted",
2259
+ ANIMATION_OUT: "unmountSuspended"
2260
+ },
2261
+ unmountSuspended: {
2262
+ MOUNT: "mounted",
2263
+ ANIMATION_END: "unmounted"
2264
+ },
2265
+ unmounted: {
2266
+ MOUNT: "mounted"
2267
+ }
2268
+ });
2269
+ React.useEffect(() => {
2270
+ if (state === "mounted") {
2271
+ prevAnimationNameRef.current = mountAnimationNameRef.current ?? getAnimationName(stylesRef.current);
2272
+ mountAnimationNameRef.current = void 0;
2273
+ } else {
2274
+ prevAnimationNameRef.current = "none";
2275
+ }
2276
+ }, [state]);
2277
+ useLayoutEffect2(() => {
2278
+ const styles = stylesRef.current;
2279
+ const wasPresent = prevPresentRef.current;
2280
+ const hasPresentChanged = wasPresent !== present;
2281
+ if (hasPresentChanged) {
2282
+ const prevAnimationName = prevAnimationNameRef.current;
2283
+ const currentAnimationName = getAnimationName(styles);
2284
+ if (present) {
2285
+ mountAnimationNameRef.current = currentAnimationName;
2286
+ send("MOUNT");
2287
+ } else if (currentAnimationName === "none" || (styles == null ? void 0 : styles.display) === "none") {
2288
+ send("UNMOUNT");
2289
+ } else {
2290
+ const isAnimating = prevAnimationName !== currentAnimationName;
2291
+ if (wasPresent && isAnimating) {
2292
+ send("ANIMATION_OUT");
2293
+ } else {
2294
+ send("UNMOUNT");
2295
+ }
2296
+ }
2297
+ prevPresentRef.current = present;
2298
+ }
2299
+ }, [present, send]);
2300
+ useLayoutEffect2(() => {
2301
+ if (node) {
2302
+ let timeoutId;
2303
+ const ownerWindow = node.ownerDocument.defaultView ?? window;
2304
+ const handleAnimationEnd = /* @__PURE__ */ __name$2((event) => {
2305
+ const currentAnimationName = getAnimationName(stylesRef.current);
2306
+ const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
2307
+ if (event.target === node && isCurrentAnimation) {
2308
+ send("ANIMATION_END");
2309
+ if (!prevPresentRef.current) {
2310
+ const currentFillMode = node.style.animationFillMode;
2311
+ node.style.animationFillMode = "forwards";
2312
+ timeoutId = ownerWindow.setTimeout(() => {
2313
+ if (node.style.animationFillMode === "forwards") {
2314
+ node.style.animationFillMode = currentFillMode;
2315
+ }
2316
+ });
2317
+ }
2318
+ }
2319
+ }, "handleAnimationEnd");
2320
+ const handleAnimationStart = /* @__PURE__ */ __name$2((event) => {
2321
+ if (event.target === node) {
2322
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
2323
+ }
2324
+ }, "handleAnimationStart");
2325
+ node.addEventListener("animationstart", handleAnimationStart);
2326
+ node.addEventListener("animationcancel", handleAnimationEnd);
2327
+ node.addEventListener("animationend", handleAnimationEnd);
2328
+ return () => {
2329
+ ownerWindow.clearTimeout(timeoutId);
2330
+ node.removeEventListener("animationstart", handleAnimationStart);
2331
+ node.removeEventListener("animationcancel", handleAnimationEnd);
2332
+ node.removeEventListener("animationend", handleAnimationEnd);
2333
+ };
2334
+ } else {
2335
+ send("ANIMATION_END");
2336
+ }
2337
+ }, [node, send]);
2338
+ return {
2339
+ isPresent: ["mounted", "unmountSuspended"].includes(state),
2340
+ ref: React.useCallback((node2) => {
2341
+ if (node2) {
2342
+ const styles = getComputedStyle(node2);
2343
+ stylesRef.current = styles;
2344
+ mountAnimationNameRef.current = getAnimationName(styles);
2345
+ } else {
2346
+ stylesRef.current = null;
2347
+ }
2348
+ setNode(node2);
2349
+ }, [])
2350
+ };
2351
+ }
2352
+ __name$2(usePresence, "usePresence");
2353
+ function setRef(ref, value) {
2354
+ if (typeof ref === "function") {
2355
+ return ref(value);
2356
+ } else if (ref !== null && ref !== void 0) {
2357
+ ref.current = value;
2358
+ }
2359
+ }
2360
+ __name$2(setRef, "setRef");
2361
+ function useStableComposedRefs(...refs) {
2362
+ const refsRef = React.useRef(refs);
2363
+ refsRef.current = refs;
2364
+ return React.useCallback((node) => {
2365
+ const currentRefs = refsRef.current;
2366
+ let hasCleanup = false;
2367
+ const cleanups = currentRefs.map((ref) => {
2368
+ const cleanup = setRef(ref, node);
2369
+ if (!hasCleanup && typeof cleanup === "function") {
2370
+ hasCleanup = true;
2371
+ }
2372
+ return cleanup;
2373
+ });
2374
+ if (hasCleanup) {
2375
+ return () => {
2376
+ for (let i = 0; i < cleanups.length; i++) {
2377
+ const cleanup = cleanups[i];
2378
+ if (typeof cleanup === "function") {
2379
+ cleanup();
2380
+ } else {
2381
+ setRef(currentRefs[i], null);
2382
+ }
2383
+ }
2384
+ };
2385
+ }
2386
+ }, []);
2387
+ }
2388
+ __name$2(useStableComposedRefs, "useStableComposedRefs");
2389
+ function getAnimationName(styles) {
2390
+ return (styles == null ? void 0 : styles.animationName) || "none";
2391
+ }
2392
+ __name$2(getAnimationName, "getAnimationName");
2393
+ function getElementRef(element) {
2394
+ var _a, _b;
2395
+ let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
2396
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
2397
+ if (mayWarn) {
2398
+ return element.ref;
2399
+ }
2400
+ getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
2401
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
2402
+ if (mayWarn) {
2403
+ return element.props.ref;
2404
+ }
2405
+ return element.props.ref || element.ref;
2406
+ }
2407
+ __name$2(getElementRef, "getElementRef");
2408
+ var __defProp$1 = Object.defineProperty;
2409
+ var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
2410
+ var useReactId = React[" useId ".trim().toString()] || (() => void 0);
2411
+ var count = 0;
2412
+ function useId(deterministicId) {
2413
+ const [id, setId] = React.useState(useReactId());
2414
+ useLayoutEffect2(() => {
2415
+ if (!deterministicId) setId((reactId) => reactId ?? String(count++));
2416
+ }, [deterministicId]);
2417
+ return deterministicId || (id ? `radix-${id}` : "");
2418
+ }
2419
+ __name$1(useId, "useId");
2420
+ var __defProp = Object.defineProperty;
2421
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
2422
+ var COLLAPSIBLE_NAME = "Collapsible";
2423
+ var [createCollapsibleContext, createCollapsibleScope] = /* @__PURE__ */ createContextScope(COLLAPSIBLE_NAME);
2424
+ var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
2425
+ var Collapsible$1 = /* @__PURE__ */ React.forwardRef(
2426
+ /* @__PURE__ */ __name(function Collapsible2(props, forwardedRef) {
2427
+ const {
2428
+ __scopeCollapsible,
2429
+ open: openProp,
2430
+ defaultOpen,
2431
+ disabled,
2432
+ onOpenChange,
2433
+ ...collapsibleProps
2434
+ } = props;
2435
+ const [open, setOpen] = useControllableState({
2436
+ prop: openProp,
2437
+ defaultProp: defaultOpen ?? false,
2438
+ onChange: onOpenChange,
2439
+ caller: COLLAPSIBLE_NAME
2440
+ });
2441
+ return /* @__PURE__ */ jsx(
2442
+ CollapsibleProvider,
2443
+ {
2444
+ scope: __scopeCollapsible,
2445
+ disabled,
2446
+ contentId: useId(),
2447
+ open,
2448
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
2449
+ children: /* @__PURE__ */ jsx(
2450
+ Primitive.div,
2451
+ {
2452
+ "data-state": getState(open),
2453
+ "data-disabled": disabled ? "" : void 0,
2454
+ ...collapsibleProps,
2455
+ ref: forwardedRef
2456
+ }
2457
+ )
2458
+ }
2459
+ );
2460
+ }, "Collapsible")
2461
+ );
2462
+ var TRIGGER_NAME = "CollapsibleTrigger";
2463
+ var CollapsibleTrigger$1 = /* @__PURE__ */ React.forwardRef(
2464
+ // blank line to reduce diff noise
2465
+ /* @__PURE__ */ __name(function CollapsibleTrigger2(props, forwardedRef) {
2466
+ const { __scopeCollapsible, ...triggerProps } = props;
2467
+ const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
2468
+ return /* @__PURE__ */ jsx(
2469
+ Primitive.button,
2470
+ {
2471
+ type: "button",
2472
+ "aria-controls": context.open ? context.contentId : void 0,
2473
+ "aria-expanded": context.open || false,
2474
+ "data-state": getState(context.open),
2475
+ "data-disabled": context.disabled ? "" : void 0,
2476
+ disabled: context.disabled,
2477
+ ...triggerProps,
2478
+ ref: forwardedRef,
2479
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
2480
+ }
2481
+ );
2482
+ }, "CollapsibleTrigger")
2483
+ );
2484
+ var CONTENT_NAME = "CollapsibleContent";
2485
+ var CollapsibleContent$1 = /* @__PURE__ */ React.forwardRef(
2486
+ // blank line to reduce diff noise
2487
+ /* @__PURE__ */ __name(function CollapsibleContent2(props, forwardedRef) {
2488
+ const { forceMount, ...contentProps } = props;
2489
+ const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
2490
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: ({ present }) => /* @__PURE__ */ jsx(CollapsibleContentImpl, { ...contentProps, ref: forwardedRef, present }) });
2491
+ }, "CollapsibleContent")
2492
+ );
2493
+ var CollapsibleContentImpl = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function CollapsibleContentImpl2(props, forwardedRef) {
2494
+ const { __scopeCollapsible, present, children, ...contentProps } = props;
2495
+ const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
2496
+ const [isPresent, setIsPresent] = React.useState(present);
2497
+ const ref = React.useRef(null);
2498
+ const composedRefs = useComposedRefs(forwardedRef, ref);
2499
+ const heightRef = React.useRef(0);
2500
+ const height = heightRef.current;
2501
+ const widthRef = React.useRef(0);
2502
+ const width = widthRef.current;
2503
+ const isOpen = context.open || isPresent;
2504
+ const isMountAnimationPreventedRef = React.useRef(isOpen);
2505
+ const originalStylesRef = React.useRef(void 0);
2506
+ React.useEffect(() => {
2507
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
2508
+ return () => cancelAnimationFrame(rAF);
2509
+ }, []);
2510
+ useLayoutEffect2(() => {
2511
+ const node = ref.current;
2512
+ if (node) {
2513
+ originalStylesRef.current = originalStylesRef.current || {
2514
+ transitionDuration: node.style.transitionDuration,
2515
+ animationName: node.style.animationName
2516
+ };
2517
+ node.style.transitionDuration = "0s";
2518
+ node.style.animationName = "none";
2519
+ const rect = node.getBoundingClientRect();
2520
+ heightRef.current = rect.height;
2521
+ widthRef.current = rect.width;
2522
+ if (!isMountAnimationPreventedRef.current) {
2523
+ node.style.transitionDuration = originalStylesRef.current.transitionDuration;
2524
+ node.style.animationName = originalStylesRef.current.animationName;
2525
+ }
2526
+ setIsPresent(present);
2527
+ }
2528
+ }, [context.open, present]);
2529
+ return /* @__PURE__ */ jsx(
2530
+ Primitive.div,
2531
+ {
2532
+ "data-state": getState(context.open),
2533
+ "data-disabled": context.disabled ? "" : void 0,
2534
+ id: context.contentId,
2535
+ hidden: !isOpen,
2536
+ ...contentProps,
2537
+ ref: composedRefs,
2538
+ style: {
2539
+ [`--radix-collapsible-content-height`]: height ? `${height}px` : void 0,
2540
+ [`--radix-collapsible-content-width`]: width ? `${width}px` : void 0,
2541
+ ...props.style
2542
+ },
2543
+ children: isOpen && children
2544
+ }
2545
+ );
2546
+ }, "CollapsibleContentImpl"));
2547
+ function getState(open) {
2548
+ return open ? "open" : "closed";
2549
+ }
2550
+ __name(getState, "getState");
2551
+ var Root = Collapsible$1;
2552
+ const createStoreImpl = (createState) => {
2553
+ let state;
2554
+ const listeners = /* @__PURE__ */ new Set();
2555
+ const setState = (partial, replace) => {
2556
+ const nextState = typeof partial === "function" ? partial(state) : partial;
2557
+ if (!Object.is(nextState, state)) {
2558
+ const previousState = state;
2559
+ state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
2560
+ listeners.forEach((listener) => listener(state, previousState));
2561
+ }
2562
+ };
2563
+ const getState2 = () => state;
2564
+ const getInitialState = () => initialState;
2565
+ const subscribe = (listener) => {
2566
+ listeners.add(listener);
2567
+ return () => listeners.delete(listener);
2568
+ };
2569
+ const api = { setState, getState: getState2, getInitialState, subscribe };
2570
+ const initialState = state = createState(setState, getState2, api);
2571
+ return api;
2572
+ };
2573
+ const createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
2574
+ const identity = (arg) => arg;
2575
+ function useStore(api, selector = identity) {
2576
+ const slice = React__default.useSyncExternalStore(
2577
+ api.subscribe,
2578
+ React__default.useCallback(() => selector(api.getState()), [api, selector]),
2579
+ React__default.useCallback(() => selector(api.getInitialState()), [api, selector])
2580
+ );
2581
+ React__default.useDebugValue(slice);
2582
+ return slice;
2583
+ }
2584
+ const createImpl = (createState) => {
2585
+ const api = createStore(createState);
2586
+ const useBoundStore = (selector) => useStore(api, selector);
2587
+ Object.assign(useBoundStore, api);
2588
+ return useBoundStore;
2589
+ };
2590
+ const create = ((createState) => createState ? createImpl(createState) : createImpl);
2591
+ function createJSONStorage(getStorage, options) {
2592
+ let storage;
2593
+ try {
2594
+ storage = getStorage();
2595
+ } catch (e) {
2596
+ return;
2597
+ }
2598
+ const persistStorage = {
2599
+ getItem: (name) => {
2600
+ var _a;
2601
+ const parse = (str2) => {
2602
+ if (str2 === null) {
2603
+ return null;
2604
+ }
2605
+ return JSON.parse(str2, void 0);
2606
+ };
2607
+ const str = (_a = storage.getItem(name)) != null ? _a : null;
2608
+ if (str instanceof Promise) {
2609
+ return str.then(parse);
2610
+ }
2611
+ return parse(str);
2612
+ },
2613
+ setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, void 0)),
2614
+ removeItem: (name) => storage.removeItem(name)
2615
+ };
2616
+ return persistStorage;
2617
+ }
2618
+ const toThenable = (fn) => (input) => {
2619
+ try {
2620
+ const result = fn(input);
2621
+ if (result instanceof Promise) {
2622
+ return result;
2623
+ }
2624
+ return {
2625
+ then(onFulfilled) {
2626
+ return toThenable(onFulfilled)(result);
2627
+ },
2628
+ catch(_onRejected) {
2629
+ return this;
2630
+ }
2631
+ };
2632
+ } catch (e) {
2633
+ return {
2634
+ then(_onFulfilled) {
2635
+ return this;
2636
+ },
2637
+ catch(onRejected) {
2638
+ return toThenable(onRejected)(e);
2639
+ }
2640
+ };
2641
+ }
2642
+ };
2643
+ const persistImpl = (config, baseOptions) => (set, get, api) => {
2644
+ let options = {
2645
+ storage: createJSONStorage(() => window.localStorage),
2646
+ partialize: (state) => state,
2647
+ version: 0,
2648
+ merge: (persistedState, currentState) => ({
2649
+ ...currentState,
2650
+ ...persistedState
2651
+ }),
2652
+ ...baseOptions
2653
+ };
2654
+ let hasHydrated = false;
2655
+ let hydrationVersion = 0;
2656
+ const hydrationListeners = /* @__PURE__ */ new Set();
2657
+ const finishHydrationListeners = /* @__PURE__ */ new Set();
2658
+ let storage = options.storage;
2659
+ if (!storage) {
2660
+ return config(
2661
+ (...args) => {
2662
+ console.warn(
2663
+ `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
2664
+ );
2665
+ set(...args);
2666
+ },
2667
+ get,
2668
+ api
2669
+ );
2670
+ }
2671
+ const setItem = () => {
2672
+ const state = options.partialize({ ...get() });
2673
+ return storage.setItem(options.name, {
2674
+ state,
2675
+ version: options.version
2676
+ });
2677
+ };
2678
+ const savedSetState = api.setState;
2679
+ api.setState = (state, replace) => {
2680
+ savedSetState(state, replace);
2681
+ return setItem();
2682
+ };
2683
+ const configResult = config(
2684
+ (...args) => {
2685
+ set(...args);
2686
+ return setItem();
2687
+ },
2688
+ get,
2689
+ api
2690
+ );
2691
+ api.getInitialState = () => configResult;
2692
+ let stateFromStorage;
2693
+ const hydrate = () => {
2694
+ var _a, _b;
2695
+ if (!storage) return;
2696
+ const currentVersion = ++hydrationVersion;
2697
+ hasHydrated = false;
2698
+ hydrationListeners.forEach((cb) => {
2699
+ var _a2;
2700
+ return cb((_a2 = get()) != null ? _a2 : configResult);
2701
+ });
2702
+ const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;
2703
+ return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
2704
+ if (deserializedStorageValue) {
2705
+ if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
2706
+ if (options.migrate) {
2707
+ const migration = options.migrate(
2708
+ deserializedStorageValue.state,
2709
+ deserializedStorageValue.version
2710
+ );
2711
+ if (migration instanceof Promise) {
2712
+ return migration.then((result) => [true, result]);
2713
+ }
2714
+ return [true, migration];
2715
+ }
2716
+ console.error(
2717
+ `State loaded from storage couldn't be migrated since no migrate function was provided`
2718
+ );
2719
+ } else {
2720
+ return [false, deserializedStorageValue.state];
2721
+ }
2722
+ }
2723
+ return [false, void 0];
2724
+ }).then((migrationResult) => {
2725
+ var _a2;
2726
+ if (currentVersion !== hydrationVersion) {
2727
+ return;
2728
+ }
2729
+ const [migrated, migratedState] = migrationResult;
2730
+ stateFromStorage = options.merge(
2731
+ migratedState,
2732
+ (_a2 = get()) != null ? _a2 : configResult
2733
+ );
2734
+ set(stateFromStorage, true);
2735
+ if (migrated) {
2736
+ return setItem();
2737
+ }
2738
+ }).then(() => {
2739
+ if (currentVersion !== hydrationVersion) {
2740
+ return;
2741
+ }
2742
+ postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);
2743
+ stateFromStorage = get();
2744
+ hasHydrated = true;
2745
+ finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
2746
+ }).catch((e) => {
2747
+ if (currentVersion !== hydrationVersion) {
2748
+ return;
2749
+ }
2750
+ postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
2751
+ });
2752
+ };
2753
+ api.persist = {
2754
+ setOptions: (newOptions) => {
2755
+ options = {
2756
+ ...options,
2757
+ ...newOptions
2758
+ };
2759
+ if (newOptions.storage) {
2760
+ storage = newOptions.storage;
2761
+ }
2762
+ },
2763
+ clearStorage: () => {
2764
+ ++hydrationVersion;
2765
+ storage == null ? void 0 : storage.removeItem(options.name);
2766
+ },
2767
+ getOptions: () => options,
2768
+ rehydrate: () => hydrate(),
2769
+ hasHydrated: () => hasHydrated,
2770
+ onHydrate: (cb) => {
2771
+ hydrationListeners.add(cb);
2772
+ return () => {
2773
+ hydrationListeners.delete(cb);
2774
+ };
2775
+ },
2776
+ onFinishHydration: (cb) => {
2777
+ finishHydrationListeners.add(cb);
2778
+ return () => {
2779
+ finishHydrationListeners.delete(cb);
2780
+ };
2781
+ }
2782
+ };
2783
+ if (!options.skipHydration) {
2784
+ hydrate();
2785
+ }
2786
+ return stateFromStorage || configResult;
2787
+ };
2788
+ const persist = persistImpl;
2789
+ const useAssetPanelStore = create()(
2790
+ persist(
2791
+ (set, get) => ({
2792
+ isOpen: false,
2793
+ tabs: [],
2794
+ activeTabId: null,
2795
+ viewMode: "tabs",
2796
+ isFullscreen: false,
2797
+ currentThreadId: null,
2798
+ threadStates: {},
2799
+ assetPanelHostCount: 0,
2800
+ autoOpenGeneration: 0,
2801
+ autoOpenedAssets: /* @__PURE__ */ new Map(),
2802
+ registerAssetPanelHost: () => set((state) => ({ assetPanelHostCount: state.assetPanelHostCount + 1 })),
2803
+ unregisterAssetPanelHost: () => set((state) => ({ assetPanelHostCount: Math.max(0, state.assetPanelHostCount - 1) })),
2804
+ openAsset: (assetId, meta) => set((s) => {
2805
+ const existing = s.tabs.find((t) => t.id === assetId);
2806
+ if (existing) {
2807
+ const tabs = meta ? s.tabs.map(
2808
+ (t) => t.id === assetId ? {
2809
+ ...t,
2810
+ name: meta.name ?? t.name,
2811
+ type: meta.type ?? t.type,
2812
+ slideNumber: "slideNumber" in meta ? meta.slideNumber : t.slideNumber,
2813
+ // A repeat citation click re-targets the open tab: the new
2814
+ // reference reaches the iframe (src change -> navigation).
2815
+ reference: "reference" in meta ? meta.reference : t.reference
2816
+ } : t
2817
+ ) : s.tabs;
2818
+ return { isOpen: true, tabs, activeTabId: assetId };
2819
+ }
2820
+ const newTab = {
2821
+ id: assetId,
2822
+ name: (meta == null ? void 0 : meta.name) ?? null,
2823
+ type: (meta == null ? void 0 : meta.type) ?? "unknown",
2824
+ slideNumber: meta == null ? void 0 : meta.slideNumber,
2825
+ reference: meta == null ? void 0 : meta.reference
2826
+ };
2827
+ if ((meta == null ? void 0 : meta.replaceActiveTab) && s.activeTabId) {
2828
+ const activeIndex = s.tabs.findIndex((t) => t.id === s.activeTabId);
2829
+ if (activeIndex >= 0) {
2830
+ const tabs = s.tabs.slice();
2831
+ tabs[activeIndex] = newTab;
2832
+ return { isOpen: true, tabs, activeTabId: assetId };
2833
+ }
2834
+ }
2835
+ return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
2836
+ }),
2837
+ closeTab: (assetId) => set((s) => {
2838
+ var _a;
2839
+ const tabs = s.tabs.filter((t) => t.id !== assetId);
2840
+ if (tabs.length === 0) {
2841
+ return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
2842
+ }
2843
+ const activeTabId = s.activeTabId === assetId ? ((_a = tabs[Math.min(s.tabs.findIndex((t) => t.id === assetId), tabs.length - 1)]) == null ? void 0 : _a.id) ?? null : s.activeTabId;
2844
+ return { tabs, activeTabId };
2845
+ }),
2846
+ setActiveTab: (assetId) => set({ activeTabId: assetId, viewMode: "tabs" }),
2847
+ setViewMode: (mode) => set({ viewMode: mode }),
2848
+ closePanel: () => set({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
2849
+ toggleFullscreen: () => set((s) => ({ isFullscreen: !s.isFullscreen })),
2850
+ setCurrentThread: (threadId) => set((s) => {
2851
+ if (s.currentThreadId === threadId) {
2852
+ return s;
2853
+ }
2854
+ const threadStates = { ...s.threadStates };
2855
+ if (s.currentThreadId !== null) {
2856
+ threadStates[s.currentThreadId] = {
2857
+ tabs: s.tabs,
2858
+ activeTabId: s.activeTabId,
2859
+ isOpen: s.isOpen
2860
+ };
2861
+ }
2862
+ const restored = threadId !== null ? threadStates[threadId] : void 0;
2863
+ return {
2864
+ currentThreadId: threadId,
2865
+ threadStates,
2866
+ tabs: (restored == null ? void 0 : restored.tabs) ?? [],
2867
+ activeTabId: (restored == null ? void 0 : restored.activeTabId) ?? null,
2868
+ isOpen: (restored == null ? void 0 : restored.isOpen) ?? false,
2869
+ // Reset transient UI state on thread switch
2870
+ isFullscreen: false,
2871
+ viewMode: "tabs"
2872
+ };
2873
+ }),
2874
+ resetAutoOpen: () => set((s) => ({ autoOpenGeneration: s.autoOpenGeneration + 1 })),
2875
+ markAutoOpened: (assetId) => {
2876
+ const state = get();
2877
+ if (state.autoOpenedAssets.get(assetId) === state.autoOpenGeneration) {
2878
+ return false;
2879
+ }
2880
+ state.autoOpenedAssets.set(assetId, state.autoOpenGeneration);
2881
+ return true;
2882
+ }
2883
+ }),
2884
+ {
2885
+ name: "athena-react-asset-panel",
2886
+ partialize: ({
2887
+ isOpen,
2888
+ tabs,
2889
+ activeTabId,
2890
+ viewMode,
2891
+ isFullscreen,
2892
+ currentThreadId,
2893
+ threadStates
2894
+ }) => ({
2895
+ isOpen,
2896
+ tabs,
2897
+ activeTabId,
2898
+ viewMode,
2899
+ isFullscreen,
2900
+ currentThreadId,
2901
+ threadStates
2902
+ }),
2903
+ storage: createJSONStorage(() => sessionStorage)
2904
+ }
2905
+ )
2906
+ );
2907
+ /**
2908
+ * @license lucide-react v0.575.0 - ISC
2909
+ *
2910
+ * This source code is licensed under the ISC license.
2911
+ * See the LICENSE file in the root directory of this source tree.
2912
+ */
2913
+ const __iconNode$r = [
2914
+ [
2915
+ "path",
2916
+ {
2917
+ d: "M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",
2918
+ key: "lc1i9w"
2919
+ }
2920
+ ],
2921
+ ["path", { d: "m7 16.5-4.74-2.85", key: "1o9zyk" }],
2922
+ ["path", { d: "m7 16.5 5-3", key: "va8pkn" }],
2923
+ ["path", { d: "M7 16.5v5.17", key: "jnp8gn" }],
2924
+ [
2925
+ "path",
2926
+ {
2927
+ d: "M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",
2928
+ key: "8zsnat"
2929
+ }
2930
+ ],
2931
+ ["path", { d: "m17 16.5-5-3", key: "8arw3v" }],
2932
+ ["path", { d: "m17 16.5 4.74-2.85", key: "8rfmw" }],
2933
+ ["path", { d: "M17 16.5v5.17", key: "k6z78m" }],
2934
+ [
2935
+ "path",
2936
+ {
2937
+ d: "M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",
2938
+ key: "1xygjf"
2939
+ }
2940
+ ],
2941
+ ["path", { d: "M12 8 7.26 5.15", key: "1vbdud" }],
2942
+ ["path", { d: "m12 8 4.74-2.85", key: "3rx089" }],
2943
+ ["path", { d: "M12 13.5V8", key: "1io7kd" }]
2944
+ ];
2945
+ const Boxes = createLucideIcon("boxes", __iconNode$r);
2946
+ /**
2947
+ * @license lucide-react v0.575.0 - ISC
2948
+ *
2949
+ * This source code is licensed under the ISC license.
2950
+ * See the LICENSE file in the root directory of this source tree.
2951
+ */
2952
+ const __iconNode$q = [
2953
+ ["path", { d: "M12 18V5", key: "adv99a" }],
2954
+ ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
2955
+ ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
2956
+ ["path", { d: "M17.997 5.125a4 4 0 0 1 2.526 5.77", key: "iwvgf7" }],
2957
+ ["path", { d: "M18 18a4 4 0 0 0 2-7.464", key: "efp6ie" }],
2958
+ ["path", { d: "M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517", key: "1gq6am" }],
2959
+ ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
2960
+ ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
2961
+ ];
2962
+ const Brain = createLucideIcon("brain", __iconNode$q);
2963
+ /**
2964
+ * @license lucide-react v0.575.0 - ISC
2965
+ *
2966
+ * This source code is licensed under the ISC license.
2967
+ * See the LICENSE file in the root directory of this source tree.
2968
+ */
2969
+ const __iconNode$p = [
2970
+ ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
2971
+ ["path", { d: "M18 17V9", key: "2bz60n" }],
2972
+ ["path", { d: "M13 17V5", key: "1frdt8" }],
2973
+ ["path", { d: "M8 17v-3", key: "17ska0" }]
2974
+ ];
2975
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$p);
2976
+ /**
2977
+ * @license lucide-react v0.575.0 - ISC
2978
+ *
2979
+ * This source code is licensed under the ISC license.
2980
+ * See the LICENSE file in the root directory of this source tree.
2981
+ */
2982
+ const __iconNode$o = [
2983
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
2984
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
2985
+ ];
2986
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$o);
2987
+ /**
2988
+ * @license lucide-react v0.575.0 - ISC
2989
+ *
2990
+ * This source code is licensed under the ISC license.
2991
+ * See the LICENSE file in the root directory of this source tree.
2992
+ */
2993
+ const __iconNode$n = [
2994
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
2995
+ ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
2996
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
2997
+ ];
2998
+ const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$n);
2999
+ /**
3000
+ * @license lucide-react v0.575.0 - ISC
3001
+ *
3002
+ * This source code is licensed under the ISC license.
3003
+ * See the LICENSE file in the root directory of this source tree.
3004
+ */
3005
+ const __iconNode$m = [
3006
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
3007
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
3008
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
3009
+ ];
3010
+ const CircleX = createLucideIcon("circle-x", __iconNode$m);
3011
+ /**
3012
+ * @license lucide-react v0.575.0 - ISC
3013
+ *
3014
+ * This source code is licensed under the ISC license.
3015
+ * See the LICENSE file in the root directory of this source tree.
3016
+ */
3017
+ const __iconNode$l = [
3018
+ ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
3019
+ ["path", { d: "M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2", key: "4jdomd" }],
3020
+ ["path", { d: "M16 4h2a2 2 0 0 1 2 2v4", key: "3hqy98" }],
3021
+ ["path", { d: "M21 14H11", key: "1bme5i" }],
3022
+ ["path", { d: "m15 10-4 4 4 4", key: "5dvupr" }]
3023
+ ];
3024
+ const ClipboardCopy = createLucideIcon("clipboard-copy", __iconNode$l);
3025
+ /**
3026
+ * @license lucide-react v0.575.0 - ISC
3027
+ *
3028
+ * This source code is licensed under the ISC license.
3029
+ * See the LICENSE file in the root directory of this source tree.
3030
+ */
3031
+ const __iconNode$k = [
3032
+ ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
3033
+ [
3034
+ "path",
3035
+ {
3036
+ d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",
3037
+ key: "116196"
3038
+ }
3039
+ ],
3040
+ ["path", { d: "M12 11h4", key: "1jrz19" }],
3041
+ ["path", { d: "M12 16h4", key: "n85exb" }],
3042
+ ["path", { d: "M8 11h.01", key: "1dfujw" }],
3043
+ ["path", { d: "M8 16h.01", key: "18s6g9" }]
3044
+ ];
3045
+ const ClipboardList = createLucideIcon("clipboard-list", __iconNode$k);
3046
+ /**
3047
+ * @license lucide-react v0.575.0 - ISC
3048
+ *
3049
+ * This source code is licensed under the ISC license.
3050
+ * See the LICENSE file in the root directory of this source tree.
3051
+ */
3052
+ const __iconNode$j = [
3053
+ ["path", { d: "M12 20v2", key: "1lh1kg" }],
3054
+ ["path", { d: "M12 2v2", key: "tus03m" }],
3055
+ ["path", { d: "M17 20v2", key: "1rnc9c" }],
3056
+ ["path", { d: "M17 2v2", key: "11trls" }],
3057
+ ["path", { d: "M2 12h2", key: "1t8f8n" }],
3058
+ ["path", { d: "M2 17h2", key: "7oei6x" }],
3059
+ ["path", { d: "M2 7h2", key: "asdhe0" }],
3060
+ ["path", { d: "M20 12h2", key: "1q8mjw" }],
3061
+ ["path", { d: "M20 17h2", key: "1fpfkl" }],
3062
+ ["path", { d: "M20 7h2", key: "1o8tra" }],
3063
+ ["path", { d: "M7 20v2", key: "4gnj0m" }],
3064
+ ["path", { d: "M7 2v2", key: "1i4yhu" }],
3065
+ ["rect", { x: "4", y: "4", width: "16", height: "16", rx: "2", key: "1vbyd7" }],
3066
+ ["rect", { x: "8", y: "8", width: "8", height: "8", rx: "1", key: "z9xiuo" }]
3067
+ ];
3068
+ const Cpu = createLucideIcon("cpu", __iconNode$j);
3069
+ /**
3070
+ * @license lucide-react v0.575.0 - ISC
3071
+ *
3072
+ * This source code is licensed under the ISC license.
3073
+ * See the LICENSE file in the root directory of this source tree.
3074
+ */
3075
+ const __iconNode$i = [
3076
+ ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
3077
+ ["path", { d: "M10 14 21 3", key: "gplh6r" }],
3078
+ ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
3079
+ ];
3080
+ const ExternalLink = createLucideIcon("external-link", __iconNode$i);
3081
+ /**
3082
+ * @license lucide-react v0.575.0 - ISC
3083
+ *
3084
+ * This source code is licensed under the ISC license.
3085
+ * See the LICENSE file in the root directory of this source tree.
3086
+ */
3087
+ const __iconNode$h = [
3088
+ [
3089
+ "path",
3090
+ {
3091
+ d: "M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",
3092
+ key: "1jaruq"
3093
+ }
3094
+ ]
3095
+ ];
3096
+ const Flag = createLucideIcon("flag", __iconNode$h);
3097
+ /**
3098
+ * @license lucide-react v0.575.0 - ISC
3099
+ *
3100
+ * This source code is licensed under the ISC license.
3101
+ * See the LICENSE file in the root directory of this source tree.
3102
+ */
3103
+ const __iconNode$g = [
3104
+ [
3105
+ "path",
3106
+ {
3107
+ d: "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",
3108
+ key: "usdka0"
3109
+ }
3110
+ ]
3111
+ ];
3112
+ const FolderOpen = createLucideIcon("folder-open", __iconNode$g);
3113
+ /**
3114
+ * @license lucide-react v0.575.0 - ISC
3115
+ *
3116
+ * This source code is licensed under the ISC license.
3117
+ * See the LICENSE file in the root directory of this source tree.
3118
+ */
3119
+ const __iconNode$f = [
3120
+ ["circle", { cx: "18", cy: "18", r: "3", key: "1xkwt0" }],
3121
+ ["circle", { cx: "6", cy: "6", r: "3", key: "1lh9wr" }],
3122
+ ["path", { d: "M13 6h3a2 2 0 0 1 2 2v7", key: "1yeb86" }],
3123
+ ["line", { x1: "6", x2: "6", y1: "9", y2: "21", key: "rroup" }]
3124
+ ];
3125
+ const GitPullRequest = createLucideIcon("git-pull-request", __iconNode$f);
3126
+ /**
3127
+ * @license lucide-react v0.575.0 - ISC
3128
+ *
3129
+ * This source code is licensed under the ISC license.
3130
+ * See the LICENSE file in the root directory of this source tree.
3131
+ */
3132
+ const __iconNode$e = [
3133
+ ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
3134
+ ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
3135
+ ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
3136
+ ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
3137
+ ];
3138
+ const Hash = createLucideIcon("hash", __iconNode$e);
3139
+ /**
3140
+ * @license lucide-react v0.575.0 - ISC
3141
+ *
3142
+ * This source code is licensed under the ISC license.
3143
+ * See the LICENSE file in the root directory of this source tree.
3144
+ */
3145
+ const __iconNode$d = [
3146
+ ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
3147
+ ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
3148
+ ];
3149
+ const Link = createLucideIcon("link", __iconNode$d);
3150
+ /**
3151
+ * @license lucide-react v0.575.0 - ISC
3152
+ *
3153
+ * This source code is licensed under the ISC license.
3154
+ * See the LICENSE file in the root directory of this source tree.
3155
+ */
3156
+ const __iconNode$c = [
3157
+ ["path", { d: "M13 5h8", key: "a7qcls" }],
3158
+ ["path", { d: "M13 12h8", key: "h98zly" }],
3159
+ ["path", { d: "M13 19h8", key: "c3s6r1" }],
3160
+ ["path", { d: "m3 17 2 2 4-4", key: "1jhpwq" }],
3161
+ ["path", { d: "m3 7 2 2 4-4", key: "1obspn" }]
3162
+ ];
3163
+ const ListChecks = createLucideIcon("list-checks", __iconNode$c);
3164
+ /**
3165
+ * @license lucide-react v0.575.0 - ISC
3166
+ *
3167
+ * This source code is licensed under the ISC license.
3168
+ * See the LICENSE file in the root directory of this source tree.
3169
+ */
3170
+ const __iconNode$b = [
3171
+ ["path", { d: "M12 2v4", key: "3427ic" }],
3172
+ ["path", { d: "m16.2 7.8 2.9-2.9", key: "r700ao" }],
3173
+ ["path", { d: "M18 12h4", key: "wj9ykh" }],
3174
+ ["path", { d: "m16.2 16.2 2.9 2.9", key: "1bxg5t" }],
3175
+ ["path", { d: "M12 18v4", key: "jadmvz" }],
3176
+ ["path", { d: "m4.9 19.1 2.9-2.9", key: "bwix9q" }],
3177
+ ["path", { d: "M2 12h4", key: "j09sii" }],
3178
+ ["path", { d: "m4.9 4.9 2.9 2.9", key: "giyufr" }]
3179
+ ];
3180
+ const Loader = createLucideIcon("loader", __iconNode$b);
3181
+ /**
3182
+ * @license lucide-react v0.575.0 - ISC
3183
+ *
3184
+ * This source code is licensed under the ISC license.
3185
+ * See the LICENSE file in the root directory of this source tree.
3186
+ */
3187
+ const __iconNode$a = [
3188
+ ["path", { d: "M6 18h8", key: "1borvv" }],
3189
+ ["path", { d: "M3 22h18", key: "8prr45" }],
3190
+ ["path", { d: "M14 22a7 7 0 1 0 0-14h-1", key: "1jwaiy" }],
3191
+ ["path", { d: "M9 14h2", key: "197e7h" }],
3192
+ ["path", { d: "M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z", key: "1bmzmy" }],
3193
+ ["path", { d: "M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3", key: "1drr47" }]
3194
+ ];
3195
+ const Microscope = createLucideIcon("microscope", __iconNode$a);
3196
+ /**
3197
+ * @license lucide-react v0.575.0 - ISC
3198
+ *
3199
+ * This source code is licensed under the ISC license.
3200
+ * See the LICENSE file in the root directory of this source tree.
3201
+ */
3202
+ const __iconNode$9 = [
3203
+ ["path", { d: "M14 4.1 12 6", key: "ita8i4" }],
3204
+ ["path", { d: "m5.1 8-2.9-.8", key: "1go3kf" }],
3205
+ ["path", { d: "m6 12-1.9 2", key: "mnht97" }],
3206
+ ["path", { d: "M7.2 2.2 8 5.1", key: "1cfko1" }],
3207
+ [
3208
+ "path",
3209
+ {
3210
+ d: "M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",
3211
+ key: "s0h3yz"
3212
+ }
3213
+ ]
3214
+ ];
3215
+ const MousePointerClick = createLucideIcon("mouse-pointer-click", __iconNode$9);
3216
+ /**
3217
+ * @license lucide-react v0.575.0 - ISC
3218
+ *
3219
+ * This source code is licensed under the ISC license.
3220
+ * See the LICENSE file in the root directory of this source tree.
3221
+ */
3222
+ const __iconNode$8 = [
3223
+ ["path", { d: "M13 21h8", key: "1jsn5i" }],
3224
+ [
3225
+ "path",
3226
+ {
3227
+ d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
3228
+ key: "1a8usu"
3229
+ }
3230
+ ]
3231
+ ];
3232
+ const PenLine = createLucideIcon("pen-line", __iconNode$8);
3233
+ /**
3234
+ * @license lucide-react v0.575.0 - ISC
3235
+ *
3236
+ * This source code is licensed under the ISC license.
3237
+ * See the LICENSE file in the root directory of this source tree.
3238
+ */
3239
+ const __iconNode$7 = [
3240
+ ["path", { d: "M2 3h20", key: "91anmk" }],
3241
+ ["path", { d: "M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3", key: "2k9sn8" }],
3242
+ ["path", { d: "m7 21 5-5 5 5", key: "bip4we" }]
3243
+ ];
3244
+ const Presentation = createLucideIcon("presentation", __iconNode$7);
3245
+ /**
3246
+ * @license lucide-react v0.575.0 - ISC
3247
+ *
3248
+ * This source code is licensed under the ISC license.
3249
+ * See the LICENSE file in the root directory of this source tree.
3250
+ */
3251
+ const __iconNode$6 = [
3252
+ [
3253
+ "path",
3254
+ {
3255
+ d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
3256
+ key: "1c8476"
3257
+ }
3258
+ ],
3259
+ ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
3260
+ ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
3261
+ ];
3262
+ const Save = createLucideIcon("save", __iconNode$6);
3263
+ /**
3264
+ * @license lucide-react v0.575.0 - ISC
3265
+ *
3266
+ * This source code is licensed under the ISC license.
3267
+ * See the LICENSE file in the root directory of this source tree.
3268
+ */
3269
+ const __iconNode$5 = [
3270
+ ["path", { d: "M3 7V5a2 2 0 0 1 2-2h2", key: "aa7l1z" }],
3271
+ ["path", { d: "M17 3h2a2 2 0 0 1 2 2v2", key: "4qcy5o" }],
3272
+ ["path", { d: "M21 17v2a2 2 0 0 1-2 2h-2", key: "6vwrx8" }],
3273
+ ["path", { d: "M7 21H5a2 2 0 0 1-2-2v-2", key: "ioqczr" }],
3274
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }],
3275
+ ["path", { d: "m16 16-1.9-1.9", key: "1dq9hf" }]
3276
+ ];
3277
+ const ScanSearch = createLucideIcon("scan-search", __iconNode$5);
3278
+ /**
3279
+ * @license lucide-react v0.575.0 - ISC
3280
+ *
3281
+ * This source code is licensed under the ISC license.
3282
+ * See the LICENSE file in the root directory of this source tree.
3283
+ */
3284
+ const __iconNode$4 = [
3285
+ ["path", { d: "M15 12h-5", key: "r7krc0" }],
3286
+ ["path", { d: "M15 8h-5", key: "1khuty" }],
3287
+ ["path", { d: "M19 17V5a2 2 0 0 0-2-2H4", key: "zz82l3" }],
3288
+ [
3289
+ "path",
3290
+ {
3291
+ d: "M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",
3292
+ key: "1ph1d7"
3293
+ }
3294
+ ]
3295
+ ];
3296
+ const ScrollText = createLucideIcon("scroll-text", __iconNode$4);
3297
+ /**
3298
+ * @license lucide-react v0.575.0 - ISC
3299
+ *
3300
+ * This source code is licensed under the ISC license.
3301
+ * See the LICENSE file in the root directory of this source tree.
3302
+ */
3303
+ const __iconNode$3 = [
3304
+ [
3305
+ "path",
3306
+ {
3307
+ d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",
3308
+ key: "1i5ecw"
3309
+ }
3310
+ ],
3311
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
3312
+ ];
3313
+ const Settings = createLucideIcon("settings", __iconNode$3);
3314
+ /**
3315
+ * @license lucide-react v0.575.0 - ISC
3316
+ *
3317
+ * This source code is licensed under the ISC license.
3318
+ * See the LICENSE file in the root directory of this source tree.
3319
+ */
3320
+ const __iconNode$2 = [
3321
+ [
3322
+ "path",
3323
+ {
3324
+ d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
3325
+ key: "oel41y"
3326
+ }
3327
+ ],
3328
+ ["path", { d: "M12 8v4", key: "1got3b" }],
3329
+ ["path", { d: "M12 16h.01", key: "1drbdi" }]
3330
+ ];
3331
+ const ShieldAlert = createLucideIcon("shield-alert", __iconNode$2);
3332
+ /**
3333
+ * @license lucide-react v0.575.0 - ISC
3334
+ *
3335
+ * This source code is licensed under the ISC license.
3336
+ * See the LICENSE file in the root directory of this source tree.
3337
+ */
3338
+ const __iconNode$1 = [
3339
+ ["path", { d: "M12 19h8", key: "baeox8" }],
3340
+ ["path", { d: "m4 17 6-6-6-6", key: "1yngyt" }]
3341
+ ];
3342
+ const Terminal = createLucideIcon("terminal", __iconNode$1);
3343
+ /**
3344
+ * @license lucide-react v0.575.0 - ISC
3345
+ *
3346
+ * This source code is licensed under the ISC license.
3347
+ * See the LICENSE file in the root directory of this source tree.
3348
+ */
3349
+ const __iconNode = [
3350
+ ["path", { d: "M16 7h6v6", key: "box55l" }],
3351
+ ["path", { d: "m22 7-8.5 8.5-5-5L2 17", key: "1t1m79" }]
3352
+ ];
3353
+ const TrendingUp = createLucideIcon("trending-up", __iconNode);
3354
+ function Collapsible({ ...props }) {
3355
+ return /* @__PURE__ */ jsx(Root, { "data-slot": "collapsible", ...props });
3356
+ }
3357
+ function CollapsibleTrigger({ ...props }) {
3358
+ return /* @__PURE__ */ jsx(CollapsibleTrigger$1, { "data-slot": "collapsible-trigger", ...props });
3359
+ }
3360
+ function CollapsibleContent({ ...props }) {
3361
+ return /* @__PURE__ */ jsx(CollapsibleContent$1, { "data-slot": "collapsible-content", ...props });
3362
+ }
3363
+ const NestedPtcComponentsContext = createContext(null);
3364
+ const NestedPtcComponentsProvider = ({ components, children }) => /* @__PURE__ */ jsx(NestedPtcComponentsContext.Provider, { value: components, children });
3365
+ const useNestedPtcComponents = (fallback) => {
3366
+ const components = useContext(NestedPtcComponentsContext);
3367
+ return useMemo(() => {
3368
+ const standardComponents = components && "ChainOfThought" in components && components.ChainOfThought ? void 0 : components;
3369
+ return {
3370
+ ...standardComponents ?? {},
3371
+ tools: {
3372
+ ...(standardComponents == null ? void 0 : standardComponents.tools) ?? {},
3373
+ Fallback: fallback
3374
+ }
3375
+ };
3376
+ }, [components, fallback]);
3377
+ };
3378
+ const EmptyComponent = () => null;
3379
+ const NestedPtcMessages = ({
3380
+ components,
3381
+ messageClassName
3382
+ }) => {
3383
+ const propsRef = useRef({ components, messageClassName });
3384
+ propsRef.current = { components, messageClassName };
3385
+ const messageComponents = useMemo(() => {
3386
+ const NestedMessage = () => {
3387
+ const { components: components2, messageClassName: messageClassName2 } = propsRef.current;
3388
+ const parts = /* @__PURE__ */ jsx(
3389
+ MessagePrimitive.Parts,
3390
+ {
3391
+ components: { Empty: EmptyComponent, ...components2 }
3392
+ }
3393
+ );
3394
+ return messageClassName2 ? /* @__PURE__ */ jsx("div", { className: messageClassName2, children: parts }) : parts;
3395
+ };
3396
+ return { Message: NestedMessage };
3397
+ }, []);
3398
+ return /* @__PURE__ */ jsx(MessagePartPrimitive.Messages, { components: messageComponents });
3399
+ };
3400
+ function tryParseJson(text) {
3401
+ try {
3402
+ const parsed = JSON.parse(text);
3403
+ return typeof parsed === "object" && parsed !== null ? parsed : null;
3404
+ } catch {
3405
+ return null;
3406
+ }
3407
+ }
3408
+ function normalizeResult(result) {
3409
+ if (!result) return null;
3410
+ if (typeof result === "string") return tryParseJson(result);
3411
+ if (typeof result === "object") {
3412
+ const obj = result;
3413
+ if (typeof obj.result === "string") return tryParseJson(obj.result) ?? obj;
3414
+ return obj;
3415
+ }
3416
+ return null;
3417
+ }
3418
+ function truncate(text, max) {
3419
+ return text.length > max ? `${text.slice(0, max)}...` : text;
3420
+ }
3421
+ function ToolCard({
3422
+ icon: Icon,
3423
+ status,
3424
+ title,
3425
+ subtitle,
3426
+ toolName,
3427
+ badge,
3428
+ error,
3429
+ children,
3430
+ args,
3431
+ result
3432
+ }) {
3433
+ const isRunning = status === "running";
3434
+ const isComplete = status === "complete";
3435
+ const isError = status === "incomplete";
3436
+ return /* @__PURE__ */ jsxs("div", { className: "my-3 w-full overflow-hidden rounded-xl border border-border/60 bg-background shadow-sm", children: [
3437
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
3438
+ /* @__PURE__ */ jsx(
3439
+ "div",
3440
+ {
3441
+ className: cn(
3442
+ "flex size-8 shrink-0 items-center justify-center rounded-lg",
3443
+ isRunning && "bg-blue-50 text-blue-600",
3444
+ isComplete && "bg-emerald-50 text-emerald-600",
3445
+ isError && "bg-destructive/10 text-destructive"
3446
+ ),
3447
+ children: isRunning ? /* @__PURE__ */ jsx(Loader, { className: "size-4 animate-spin" }) : isError ? /* @__PURE__ */ jsx(CircleAlert, { className: "size-4" }) : /* @__PURE__ */ jsx(Icon, { className: "size-4" })
3448
+ }
3449
+ ),
3450
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
3451
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3452
+ /* @__PURE__ */ jsx("span", { className: "text-[13px] font-medium text-foreground", children: title }),
3453
+ isComplete && !error && /* @__PURE__ */ jsx(CircleCheck, { className: "size-3.5 text-emerald-500" })
3454
+ ] }),
3455
+ subtitle && /* @__PURE__ */ jsx("p", { className: "truncate text-[12px] text-muted-foreground", children: subtitle })
3456
+ ] }),
3457
+ toolName && /* @__PURE__ */ 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) }),
3458
+ badge && /* @__PURE__ */ jsx("span", { className: "shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground", children: badge }),
3459
+ isRunning && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
3460
+ /* @__PURE__ */ jsx("div", { className: "h-1.5 w-10 animate-pulse rounded-full bg-blue-100" }),
3461
+ /* @__PURE__ */ jsx("div", { className: "h-1.5 w-6 animate-pulse rounded-full bg-blue-100" })
3462
+ ] })
3463
+ ] }),
3464
+ error && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 bg-destructive/10 px-4 py-2.5", children: /* @__PURE__ */ jsx("p", { className: "text-[12px] leading-relaxed text-destructive", children: error }) }),
3465
+ children,
3466
+ toolName && isComplete && /* @__PURE__ */ jsx(CopyToolSpecButton, { toolName, args, result })
3467
+ ] });
3468
+ }
3469
+ function CopyToolSpecButton({
3470
+ toolName,
3471
+ args,
3472
+ argsText,
3473
+ result,
3474
+ className
3475
+ }) {
3476
+ const [copied, setCopied] = useState(false);
3477
+ const handleCopy = useCallback(() => {
3478
+ const spec = { tool_name: toolName };
3479
+ if (args) spec.arguments = args;
3480
+ else if (argsText) spec.arguments = tryParseJson(argsText) ?? argsText;
3481
+ if (result !== void 0) {
3482
+ if (typeof result === "string") {
3483
+ const parsed = tryParseJson(result);
3484
+ spec.result = parsed ?? result;
3485
+ } else {
3486
+ spec.result = result;
3487
+ }
3488
+ }
3489
+ navigator.clipboard.writeText(JSON.stringify(spec, null, 2)).then(() => {
3490
+ setCopied(true);
3491
+ setTimeout(() => setCopied(false), 2e3);
3492
+ });
3493
+ }, [toolName, args, argsText, result]);
3494
+ return /* @__PURE__ */ jsx("div", { className: cn("flex justify-end px-3 pb-1.5", className), children: /* @__PURE__ */ jsxs(
3495
+ "button",
3496
+ {
3497
+ type: "button",
3498
+ onClick: handleCopy,
3499
+ className: "flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground/40 transition-colors hover:bg-muted/50 hover:text-muted-foreground",
3500
+ title: "Copy tool name, arguments, and result as JSON",
3501
+ children: [
3502
+ /* @__PURE__ */ jsx(ClipboardCopy, { className: "size-2.5" }),
3503
+ copied ? "Copied!" : toolName
3504
+ ]
3505
+ }
3506
+ ) });
3507
+ }
3508
+ function ExpandableSection({
3509
+ label,
3510
+ children,
3511
+ defaultOpen = false
3512
+ }) {
3513
+ const [expanded, setExpanded] = useState(defaultOpen);
3514
+ return /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40", children: [
3515
+ /* @__PURE__ */ jsxs(
3516
+ "button",
3517
+ {
3518
+ type: "button",
3519
+ onClick: () => setExpanded(!expanded),
3520
+ className: "flex w-full items-center gap-2 px-4 py-2 text-left text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/30",
3521
+ children: [
3522
+ /* @__PURE__ */ jsx(
3523
+ ChevronDown,
3524
+ {
3525
+ className: cn(
3526
+ "size-3.5 shrink-0 transition-transform duration-200",
3527
+ !expanded && "-rotate-90"
3528
+ )
3529
+ }
3530
+ ),
3531
+ /* @__PURE__ */ jsx("span", { children: expanded ? "Hide details" : label ?? "Show details" })
3532
+ ]
3533
+ }
3534
+ ),
3535
+ expanded && /* @__PURE__ */ jsx("div", { className: "max-h-72 overflow-y-auto border-t border-border/40 bg-muted/10 px-4 py-3", children })
3536
+ ] });
3537
+ }
3538
+ const TOOL_ICONS = {
3539
+ search: Search,
3540
+ globe: Globe,
3541
+ mail: Mail,
3542
+ calendar: Calendar,
3543
+ "file-text": FileText,
3544
+ "pen-line": PenLine,
3545
+ "bar-chart": ChartColumn,
3546
+ table: Table,
3547
+ presentation: Presentation,
3548
+ monitor: Monitor,
3549
+ code: Code,
3550
+ terminal: Terminal,
3551
+ database: Database,
3552
+ "book-open": BookOpen,
3553
+ brain: Brain,
3554
+ "folder-open": FolderOpen,
3555
+ folder: Folder,
3556
+ save: Save,
3557
+ wrench: Wrench,
3558
+ image: Image,
3559
+ camera: Camera,
3560
+ "trending-up": TrendingUp,
3561
+ palette: Palette,
3562
+ microscope: Microscope,
3563
+ "message-square": MessageSquare,
3564
+ "hard-drive": HardDrive,
3565
+ "git-pull-request": GitPullRequest,
3566
+ boxes: Boxes,
3567
+ "scroll-text": ScrollText,
3568
+ "clipboard-list": ClipboardList,
3569
+ cpu: Cpu,
3570
+ bot: Bot,
3571
+ link: Link,
3572
+ package: Package,
3573
+ play: Play,
3574
+ trash: Trash2,
3575
+ star: Star,
3576
+ sparkles: Sparkles,
3577
+ "list-checks": ListChecks,
3578
+ "mouse-pointer": MousePointerClick,
3579
+ "scan-search": ScanSearch,
3580
+ settings: Settings,
3581
+ phone: Phone,
3582
+ video: Video,
3583
+ users: Users,
3584
+ "layout-dashboard": LayoutDashboard,
3585
+ workflow: Workflow,
3586
+ "circle-help": CircleQuestionMark,
3587
+ flag: Flag,
3588
+ hash: Hash
3589
+ };
3590
+ function toolIcon(key) {
3591
+ return TOOL_ICONS[key];
3592
+ }
3593
+ const ANIMATION_DURATION = 200;
3594
+ function rejectedOutcome(classification) {
3595
+ return classification.state === "rejected" ? classification.rejection : null;
3596
+ }
3597
+ function extractAssetId(result) {
3598
+ if (!result) return null;
3599
+ try {
3600
+ const obj = typeof result === "string" ? JSON.parse(result) : result;
3601
+ if (typeof obj === "object" && obj !== null) {
3602
+ const record = obj;
3603
+ const id = record.asset_id ?? record.assetId ?? record.id;
3604
+ if (typeof id === "string" && id.startsWith("asset_")) return id;
3605
+ }
3606
+ } catch {
3607
+ }
3608
+ return null;
3609
+ }
3610
+ function extractAssetIdFromArgs(argsText) {
3611
+ if (!argsText) return null;
3612
+ const parsed = tryParseJson(argsText);
3613
+ if (!parsed) return null;
3614
+ const id = parsed.asset_id ?? parsed.assetId;
3615
+ if (typeof id === "string" && id.startsWith("asset_")) return id;
3616
+ return null;
3617
+ }
3618
+ function toolMetaToAssetType(toolName) {
3619
+ const lower = toolName.toLowerCase();
3620
+ if (lower.includes("presentation") || lower.includes("pptx") || lower.includes("slide") || lower.includes("powerpoint"))
3621
+ return "presentation";
3622
+ if (lower.includes("sheet") || lower.includes("spreadsheet"))
3623
+ return "spreadsheet";
3624
+ if (lower.includes("document") || lower.includes("doc") || lower.includes("markdown"))
3625
+ return "document";
3626
+ if (lower.includes("notebook"))
3627
+ return "notebook";
3628
+ return "unknown";
3629
+ }
3630
+ const CREATE_ASSET_TOOLS = [
3631
+ "create_powerpoint_deck",
3632
+ "create_document_from_markdown",
3633
+ "create_new_document",
3634
+ "create_new_sheet",
3635
+ "create_new_notebook"
3636
+ ];
3637
+ function isAssetTool(toolName, result) {
3638
+ return CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) || extractAssetId(result) !== null;
3639
+ }
3640
+ function extractTitle(argsText, result) {
3641
+ if (argsText) {
3642
+ const args = tryParseJson(argsText);
3643
+ if (args) {
3644
+ const t = args.title ?? args.name ?? args.filename ?? args.sheet_name;
3645
+ if (t) return t;
3646
+ }
3647
+ }
3648
+ if (result) {
3649
+ try {
3650
+ const obj = typeof result === "string" ? JSON.parse(result) : result;
3651
+ if (typeof obj === "object" && obj !== null) {
3652
+ return obj.title ?? obj.name;
3653
+ }
3654
+ } catch {
3655
+ }
3656
+ }
3657
+ return null;
3658
+ }
3659
+ function clearAutoOpenedAssets() {
3660
+ useAssetPanelStore.getState().resetAutoOpen();
3661
+ }
3662
+ const HIDDEN_ARG_KEYS = /* @__PURE__ */ new Set(["catalog_id", "asset_id", "workspace_id", "user_id"]);
3663
+ function looksLikeInternalId(value) {
3664
+ if (typeof value !== "string") return false;
3665
+ return /^(asset|catalog|user|workspace)_[a-f0-9-]{8,}$/i.test(value);
3666
+ }
3667
+ function useOpenAsset(onOpenAsset) {
3668
+ const storeOpenAsset = useAssetPanelStore((s) => s.openAsset);
3669
+ return onOpenAsset ?? storeOpenAsset;
3670
+ }
3671
+ function ToolFallbackRoot({
3672
+ className,
3673
+ open: controlledOpen,
3674
+ onOpenChange: controlledOnOpenChange,
3675
+ defaultOpen = false,
3676
+ children,
3677
+ ...props
3678
+ }) {
3679
+ const collapsibleRef = useRef(null);
3680
+ const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
3681
+ const lockScroll = useScrollLock(collapsibleRef, ANIMATION_DURATION);
3682
+ const isControlled = controlledOpen !== void 0;
3683
+ const isOpen = isControlled ? controlledOpen : uncontrolledOpen;
3684
+ const handleOpenChange = useCallback(
3685
+ (open) => {
3686
+ if (!open) {
3687
+ lockScroll();
3688
+ }
3689
+ if (!isControlled) {
3690
+ setUncontrolledOpen(open);
3691
+ }
3692
+ controlledOnOpenChange == null ? void 0 : controlledOnOpenChange(open);
3693
+ },
3694
+ [lockScroll, isControlled, controlledOnOpenChange]
3695
+ );
3696
+ return /* @__PURE__ */ jsx(
3697
+ Collapsible,
3698
+ {
3699
+ ref: collapsibleRef,
3700
+ "data-slot": "tool-fallback-root",
3701
+ open: isOpen,
3702
+ onOpenChange: handleOpenChange,
3703
+ className: cn(
3704
+ "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",
3705
+ className
3706
+ ),
3707
+ style: {
3708
+ "--animation-duration": `${ANIMATION_DURATION}ms`
3709
+ },
3710
+ ...props,
3711
+ children
3712
+ }
3713
+ );
3714
+ }
3715
+ function ToolFallbackTrigger({
3716
+ toolName,
3717
+ argsText,
3718
+ result,
3719
+ status,
3720
+ isError,
3721
+ classification: givenClassification,
3722
+ displayName,
3723
+ activeLabel,
3724
+ icon,
3725
+ className,
3726
+ ...props
3727
+ }) {
3728
+ const classification = givenClassification ?? classifyToolResult({ status, result, isError });
3729
+ const state = classification.state;
3730
+ const isRunning = state === "running";
3731
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
3732
+ const meta = getToolDisplayMeta(toolName);
3733
+ const ToolIcon = icon ?? toolIcon(meta.icon);
3734
+ const title = displayName ?? meta.displayName;
3735
+ const running = activeLabel ?? meta.activeLabel;
3736
+ const summary = useMemo(() => {
3737
+ if (isRunning || !argsText) return null;
3738
+ const parsed = tryParseJson(argsText);
3739
+ return parsed ? describeToolArgs({ toolName, args: parsed }) ?? null : null;
3740
+ }, [toolName, argsText, isRunning]);
3741
+ const message = useMemo(
3742
+ () => state === "complete" ? resultMessage(result) : null,
3743
+ [result, state]
3744
+ );
3745
+ const rejection = rejectedOutcome(classification);
3746
+ const headline = rejection ? toolStatusLabel(toolName, "rejected", displayName) : state === "error" ? `Failed: ${title}` : state === "paused" ? `Paused: ${title}` : title;
3747
+ const secondary = rejection ? rejection.reason : message || summary;
3748
+ return /* @__PURE__ */ jsxs(
3749
+ CollapsibleTrigger,
3750
+ {
3751
+ "data-slot": "tool-fallback-trigger",
3752
+ "data-tool-outcome": state,
3753
+ className: cn(
3754
+ "aui-tool-fallback-trigger group/trigger flex w-full items-center gap-2.5 px-3 text-sm transition-colors",
3755
+ className
3756
+ ),
3757
+ ...props,
3758
+ children: [
3759
+ /* @__PURE__ */ jsx(
3760
+ "div",
3761
+ {
3762
+ className: cn(
3763
+ "flex size-7 shrink-0 items-center justify-center rounded-lg",
3764
+ isRunning && "bg-blue-50 text-blue-600",
3765
+ state === "complete" && "bg-emerald-50 text-emerald-600",
3766
+ state === "error" && "bg-red-50 text-red-500",
3767
+ (state === "requires-action" || state === "paused" || state === "rejected") && "bg-amber-50 text-amber-500"
3768
+ ),
3769
+ children: isRunning ? /* @__PURE__ */ jsx(Loader, { className: "size-3.5 animate-spin" }) : rejection ? /* @__PURE__ */ jsx(CircleX, { className: "size-3.5" }) : state === "error" ? isCancelled ? /* @__PURE__ */ jsx(CircleX, { className: "size-3.5" }) : /* @__PURE__ */ jsx(CircleAlert, { className: "size-3.5" }) : state === "paused" ? /* @__PURE__ */ jsx(Pause, { className: "size-3.5" }) : state === "requires-action" ? /* @__PURE__ */ jsx(ShieldAlert, { className: "size-3.5" }) : /* @__PURE__ */ jsx(ToolIcon, { className: "size-3.5" })
3770
+ }
3771
+ ),
3772
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow flex-col items-start gap-0.5 text-left", children: [
3773
+ /* @__PURE__ */ jsxs(
3774
+ "span",
3775
+ {
3776
+ className: cn(
3777
+ "relative inline-block text-[13px] font-medium leading-tight",
3778
+ isCancelled && "text-muted-foreground line-through"
3779
+ ),
3780
+ children: [
3781
+ /* @__PURE__ */ jsx("span", { children: isRunning ? `${running}...` : headline }),
3782
+ isRunning && /* @__PURE__ */ jsxs(
3783
+ "span",
3784
+ {
3785
+ "aria-hidden": true,
3786
+ className: "shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",
3787
+ children: [
3788
+ running,
3789
+ "..."
3790
+ ]
3791
+ }
3792
+ )
3793
+ ]
3794
+ }
3795
+ ),
3796
+ !isRunning && secondary && /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground leading-snug max-w-full", children: secondary })
3797
+ ] }),
3798
+ state === "complete" && /* @__PURE__ */ jsx(CircleCheck, { className: "size-3.5 shrink-0 text-emerald-500" }),
3799
+ /* @__PURE__ */ jsx(
3800
+ ChevronDown,
3801
+ {
3802
+ className: cn(
3803
+ "size-4 shrink-0 text-muted-foreground",
3804
+ "transition-transform duration-(--animation-duration) ease-out",
3805
+ "group-data-[state=closed]/trigger:-rotate-90",
3806
+ "group-data-[state=open]/trigger:rotate-0"
3807
+ )
3808
+ }
3809
+ )
3810
+ ]
3811
+ }
3812
+ );
3813
+ }
3814
+ function ToolFallbackContent({
3815
+ className,
3816
+ children,
3817
+ ...props
3818
+ }) {
3819
+ return /* @__PURE__ */ jsx(
3820
+ CollapsibleContent,
3821
+ {
3822
+ "data-slot": "tool-fallback-content",
3823
+ className: cn(
3824
+ "aui-tool-fallback-content relative overflow-hidden text-sm outline-none",
3825
+ "group/collapsible-content ease-out",
3826
+ "data-[state=closed]:animate-collapsible-up",
3827
+ "data-[state=open]:animate-collapsible-down",
3828
+ "data-[state=closed]:fill-mode-forwards",
3829
+ "data-[state=closed]:pointer-events-none",
3830
+ "data-[state=open]:duration-(--animation-duration)",
3831
+ "data-[state=closed]:duration-(--animation-duration)",
3832
+ className
3833
+ ),
3834
+ ...props,
3835
+ children: /* @__PURE__ */ jsx("div", { className: "mt-2.5 flex flex-col gap-2 border-t border-border/50 pt-2", children })
3836
+ }
3837
+ );
3838
+ }
3839
+ function ToolFallbackArgs({
3840
+ argsText,
3841
+ hideInternalIdArgs = true,
3842
+ className,
3843
+ ...props
3844
+ }) {
3845
+ if (!argsText) return null;
3846
+ const parsed = tryParseJson(argsText);
3847
+ if (!parsed) {
3848
+ return /* @__PURE__ */ jsxs("div", { className: cn("px-3", className), ...props, children: [
3849
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground", children: "Arguments" }),
3850
+ /* @__PURE__ */ jsx("pre", { className: "mt-1 whitespace-pre-wrap text-xs text-muted-foreground", children: argsText })
3851
+ ] });
3852
+ }
3853
+ const entries = Object.entries(parsed).filter(
3854
+ ([key, value]) => !hideInternalIdArgs || !HIDDEN_ARG_KEYS.has(key) && !looksLikeInternalId(value)
3855
+ );
3856
+ if (entries.length === 0) return null;
3857
+ return /* @__PURE__ */ jsxs(
3858
+ "div",
3859
+ {
3860
+ "data-slot": "tool-fallback-args",
3861
+ className: cn("aui-tool-fallback-args flex flex-col gap-1.5 px-3", className),
3862
+ ...props,
3863
+ children: [
3864
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground", children: "Arguments" }),
3865
+ entries.map(([key, value]) => {
3866
+ const strValue = typeof value === "string" ? value : JSON.stringify(value, null, 2);
3867
+ const isLong = typeof value === "string" && value.length > 80;
3868
+ return /* @__PURE__ */ jsxs("div", { children: [
3869
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: key }),
3870
+ isLong ? /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs leading-relaxed text-foreground/80", children: strValue }) : /* @__PURE__ */ jsx("span", { className: "ml-1.5 text-xs text-foreground/80", children: strValue })
3871
+ ] }, key);
3872
+ })
3873
+ ]
3874
+ }
3875
+ );
3876
+ }
3877
+ function ToolFallbackResult({
3878
+ result,
3879
+ classification,
3880
+ className,
3881
+ ...props
3882
+ }) {
3883
+ const message = resultMessage(result);
3884
+ const succeeded = (classification ?? classifyToolResult({ status: { type: "complete" }, result })).state === "complete";
3885
+ const displayValue = useMemo(() => {
3886
+ if (result === void 0) return "";
3887
+ if (typeof result === "string") {
3888
+ const parsed = tryParseJson(result);
3889
+ return parsed ? JSON.stringify(parsed, null, 2) : result;
3890
+ }
3891
+ return JSON.stringify(result, null, 2);
3892
+ }, [result]);
3893
+ if (result === void 0) return null;
3894
+ if (message && succeeded) return null;
3895
+ return /* @__PURE__ */ jsxs(
3896
+ "div",
3897
+ {
3898
+ "data-slot": "tool-fallback-result",
3899
+ className: cn("border-t border-dashed border-border/50 px-3 pt-2", className),
3900
+ ...props,
3901
+ children: [
3902
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground", children: "Result" }),
3903
+ /* @__PURE__ */ jsx("pre", { className: "mt-1 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/20 p-2 text-[11px] text-foreground/80", children: message ?? displayValue })
3904
+ ]
3905
+ }
3906
+ );
3907
+ }
3908
+ function ToolFallbackError({
3909
+ status,
3910
+ className,
3911
+ ...props
3912
+ }) {
3913
+ if ((status == null ? void 0 : status.type) !== "incomplete") return null;
3914
+ const error = status.error;
3915
+ const errorText = error ? typeof error === "string" ? error : JSON.stringify(error) : null;
3916
+ if (!errorText) return null;
3917
+ const isCancelled = status.reason === "cancelled";
3918
+ const headerText = isCancelled ? "Cancelled" : "Error";
3919
+ return /* @__PURE__ */ jsxs("div", { className: cn("px-3", className), ...props, children: [
3920
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-destructive", children: headerText }),
3921
+ /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-destructive/80", children: errorText })
3922
+ ] });
3923
+ }
3924
+ function ToolFallbackNotice({
3925
+ classification,
3926
+ className,
3927
+ ...props
3928
+ }) {
3929
+ if (classification.state === "error") {
3930
+ const { failure } = classification;
3931
+ return /* @__PURE__ */ jsxs(
3932
+ "div",
3933
+ {
3934
+ "data-slot": "tool-fallback-notice",
3935
+ className: cn(
3936
+ "mt-2 border-t border-red-200/80 px-3 pt-1.5 text-[11px] text-red-700",
3937
+ className
3938
+ ),
3939
+ ...props,
3940
+ children: [
3941
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: failure.code ? `${failure.code}: ` : "Error: " }),
3942
+ failure.message
3943
+ ]
3944
+ }
3945
+ );
3946
+ }
3947
+ if (classification.state === "paused") {
3948
+ return /* @__PURE__ */ jsx(
3949
+ "div",
3950
+ {
3951
+ "data-slot": "tool-fallback-notice",
3952
+ className: cn(
3953
+ "mt-2 border-t border-amber-200/80 px-3 pt-1.5 text-[11px] text-amber-800",
3954
+ className
3955
+ ),
3956
+ ...props,
3957
+ children: classification.notice
3958
+ }
3959
+ );
3960
+ }
3961
+ return null;
3962
+ }
3963
+ function AssetToolCard({
3964
+ toolName,
3965
+ argsText,
3966
+ result,
3967
+ status,
3968
+ classification,
3969
+ context,
3970
+ displayName,
3971
+ activeLabel,
3972
+ icon,
3973
+ hideInternalIdArgs,
3974
+ action,
3975
+ notice,
3976
+ renderResult,
3977
+ onOpenAsset,
3978
+ children,
3979
+ defaultOpen,
3980
+ className,
3981
+ rootProps
3982
+ }) {
3983
+ const [detailsOpen, setDetailsOpen] = useState(defaultOpen ?? false);
3984
+ const openAsset = useOpenAsset(onOpenAsset);
3985
+ const meta = getToolDisplayMeta(toolName);
3986
+ const ToolIcon = icon ?? toolIcon(meta.icon);
3987
+ const title = displayName ?? meta.displayName;
3988
+ const state = classification.state;
3989
+ const isRunning = state === "running";
3990
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
3991
+ const assetId = extractAssetId(result);
3992
+ const assetTitle = extractTitle(argsText, result);
3993
+ const assetType = toolMetaToAssetType(toolName);
3994
+ const rejection = rejectedOutcome(classification);
3995
+ return /* @__PURE__ */ jsxs(
3996
+ "div",
3997
+ {
3998
+ ...rootProps,
3999
+ "data-slot": "tool-fallback-root",
4000
+ "data-tool-outcome": state,
4001
+ className: cn(
4002
+ "aui-tool-fallback-root my-3 w-full rounded-xl border border-border/60 bg-background py-2.5 shadow-sm",
4003
+ isCancelled && "border-muted-foreground/30 bg-muted/30",
4004
+ className
4005
+ ),
4006
+ children: [
4007
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 px-3 text-sm", children: [
4008
+ /* @__PURE__ */ jsx(
4009
+ "div",
4010
+ {
4011
+ className: cn(
4012
+ "flex size-7 shrink-0 items-center justify-center rounded-lg",
4013
+ isRunning && "bg-blue-50 text-blue-600",
4014
+ state === "complete" && "bg-emerald-50 text-emerald-600",
4015
+ state === "error" && "bg-red-50 text-red-500",
4016
+ state === "rejected" && "bg-amber-50 text-amber-500"
4017
+ ),
4018
+ children: isRunning ? /* @__PURE__ */ jsx(Loader, { className: "size-3.5 animate-spin" }) : rejection ? /* @__PURE__ */ jsx(CircleX, { className: "size-3.5" }) : state === "error" ? /* @__PURE__ */ jsx(CircleAlert, { className: "size-3.5" }) : /* @__PURE__ */ jsx(ToolIcon, { className: "size-3.5" })
4019
+ }
4020
+ ),
4021
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow flex-col items-start gap-0.5 text-left", children: [
4022
+ /* @__PURE__ */ jsx("span", { className: "leading-tight font-medium", children: isRunning ? `${activeLabel ?? meta.activeLabel}...` : rejection ? toolStatusLabel(toolName, "rejected", displayName) : state === "error" ? `Failed: ${title}` : title }),
4023
+ !isRunning && assetTitle && /* @__PURE__ */ jsx("span", { className: "max-w-full truncate text-xs leading-snug text-muted-foreground", children: assetTitle })
4024
+ ] }),
4025
+ assetId && state === "complete" && CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) && /* @__PURE__ */ jsxs(
4026
+ "button",
4027
+ {
4028
+ type: "button",
4029
+ onClick: () => openAsset(assetId, { name: assetTitle ?? void 0, type: assetType }),
4030
+ className: "flex shrink-0 items-center gap-1 rounded-md border border-border/60 px-2 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
4031
+ children: [
4032
+ /* @__PURE__ */ jsx(ExternalLink, { className: "size-2.5" }),
4033
+ "Open"
4034
+ ]
4035
+ }
4036
+ ),
4037
+ action,
4038
+ state === "complete" && /* @__PURE__ */ jsx(CircleCheck, { className: "size-3.5 shrink-0 text-emerald-500" }),
4039
+ !isCancelled && /* @__PURE__ */ jsx(
4040
+ "button",
4041
+ {
4042
+ type: "button",
4043
+ onClick: () => setDetailsOpen((o) => !o),
4044
+ className: cn(
4045
+ "flex size-5 shrink-0 items-center justify-center rounded transition-all",
4046
+ detailsOpen ? "bg-primary/5 text-primary" : "text-muted-foreground/40 hover:bg-muted/50 hover:text-muted-foreground"
4047
+ ),
4048
+ title: "Show details",
4049
+ children: /* @__PURE__ */ jsx(
4050
+ ChevronDown,
4051
+ {
4052
+ className: cn(
4053
+ "size-3 transition-transform duration-200",
4054
+ detailsOpen && "rotate-180"
4055
+ )
4056
+ }
4057
+ )
4058
+ }
4059
+ )
4060
+ ] }),
4061
+ notice,
4062
+ /* @__PURE__ */ jsx(ToolFallbackNotice, { classification }),
4063
+ detailsOpen && !isCancelled && /* @__PURE__ */ jsxs("div", { className: "mt-2.5 flex flex-col gap-2 border-t border-border/50 px-3 pt-2", children: [
4064
+ children,
4065
+ /* @__PURE__ */ jsx(ToolFallbackArgs, { argsText, hideInternalIdArgs }),
4066
+ renderResult ? renderResult(context) : /* @__PURE__ */ jsx(ToolFallbackResult, { result, classification }),
4067
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ jsx(CopyToolSpecButton, { toolName, argsText, result, className: "px-0 pb-0" }) })
4068
+ ] })
4069
+ ]
4070
+ }
4071
+ );
4072
+ }
4073
+ function AssetOpenLink({
4074
+ assetId,
4075
+ toolName,
4076
+ onOpenAsset
4077
+ }) {
4078
+ const openAsset = useOpenAsset(onOpenAsset);
4079
+ const assetType = toolMetaToAssetType(toolName);
4080
+ return /* @__PURE__ */ jsx(
4081
+ "button",
4082
+ {
4083
+ type: "button",
4084
+ onClick: (e) => {
4085
+ e.stopPropagation();
4086
+ openAsset(assetId, { type: assetType });
4087
+ },
4088
+ className: "flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-colors hover:bg-muted/50 hover:text-foreground",
4089
+ title: "Open asset",
4090
+ children: /* @__PURE__ */ jsx(Link, { className: "size-3" })
4091
+ }
4092
+ );
4093
+ }
4094
+ const ToolFallbackImpl = ({
4095
+ toolName,
4096
+ args,
4097
+ argsText,
4098
+ result,
4099
+ status,
4100
+ isError,
4101
+ displayName,
4102
+ activeLabel,
4103
+ icon,
4104
+ hideInternalIdArgs = true,
4105
+ extraAction,
4106
+ notice,
4107
+ renderResult,
4108
+ onOpenAsset,
4109
+ children,
4110
+ defaultOpen,
4111
+ className,
4112
+ rootProps
4113
+ }) => {
4114
+ const classification = classifyToolResult({ status, result, isError });
4115
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
4116
+ const nestedComponents = useNestedPtcComponents(ToolFallback);
4117
+ const resultAssetId = extractAssetId(result);
4118
+ const argsAssetId = extractAssetIdFromArgs(argsText);
4119
+ const assetId = resultAssetId ?? argsAssetId;
4120
+ const context = {
4121
+ toolName,
4122
+ args: args ?? void 0,
4123
+ argsText,
4124
+ result,
4125
+ status,
4126
+ classification,
4127
+ assetId
4128
+ };
4129
+ const action = typeof extraAction === "function" ? extraAction(context) : extraAction;
4130
+ if (isAssetTool(toolName, result)) {
4131
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4132
+ /* @__PURE__ */ jsx(
4133
+ AssetToolCard,
4134
+ {
4135
+ toolName,
4136
+ argsText,
4137
+ result,
4138
+ status,
4139
+ classification,
4140
+ context,
4141
+ displayName,
4142
+ activeLabel,
4143
+ icon,
4144
+ hideInternalIdArgs,
4145
+ action,
4146
+ notice,
4147
+ renderResult,
4148
+ onOpenAsset,
4149
+ defaultOpen,
4150
+ className,
4151
+ rootProps,
4152
+ children
4153
+ }
4154
+ ),
4155
+ /* @__PURE__ */ jsx(NestedPtcMessages, { components: nestedComponents })
4156
+ ] });
4157
+ }
4158
+ const isComplete = classification.state === "complete";
4159
+ return /* @__PURE__ */ jsxs(
4160
+ ToolFallbackRoot,
4161
+ {
4162
+ ...rootProps,
4163
+ defaultOpen,
4164
+ className: cn(isCancelled && "border-muted-foreground/30 bg-muted/30", className),
4165
+ children: [
4166
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
4167
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(
4168
+ ToolFallbackTrigger,
4169
+ {
4170
+ toolName,
4171
+ argsText,
4172
+ result,
4173
+ status,
4174
+ classification,
4175
+ displayName,
4176
+ activeLabel,
4177
+ icon
4178
+ }
4179
+ ) }),
4180
+ action ? /* @__PURE__ */ jsx("div", { className: "shrink-0 pr-2", children: action }) : null,
4181
+ assetId && isComplete && !action && /* @__PURE__ */ jsx("div", { className: "shrink-0 pr-2", children: /* @__PURE__ */ jsx(AssetOpenLink, { assetId, toolName, onOpenAsset }) })
4182
+ ] }),
4183
+ notice,
4184
+ /* @__PURE__ */ jsx(ToolFallbackNotice, { classification }),
4185
+ /* @__PURE__ */ jsxs(ToolFallbackContent, { children: [
4186
+ children,
4187
+ /* @__PURE__ */ jsx(ToolFallbackError, { status }),
4188
+ /* @__PURE__ */ jsx(
4189
+ ToolFallbackArgs,
4190
+ {
4191
+ argsText,
4192
+ hideInternalIdArgs,
4193
+ className: cn(isCancelled && "opacity-60")
4194
+ }
4195
+ ),
4196
+ !isCancelled && (renderResult ? renderResult(context) : /* @__PURE__ */ jsx(ToolFallbackResult, { result, classification })),
4197
+ /* @__PURE__ */ jsx(NestedPtcMessages, { components: nestedComponents }),
4198
+ !isCancelled && /* @__PURE__ */ jsx("div", { className: "flex justify-end px-3 pt-1", children: /* @__PURE__ */ jsx(
4199
+ CopyToolSpecButton,
4200
+ {
4201
+ toolName,
4202
+ argsText,
4203
+ result,
4204
+ className: "px-0 pb-0"
4205
+ }
4206
+ ) })
4207
+ ] })
4208
+ ]
4209
+ }
4210
+ );
4211
+ };
4212
+ const ToolFallback = memo(
4213
+ ToolFallbackImpl
4214
+ );
4215
+ ToolFallback.displayName = "ToolFallback";
4216
+ ToolFallback.Root = ToolFallbackRoot;
4217
+ ToolFallback.Trigger = ToolFallbackTrigger;
4218
+ ToolFallback.Content = ToolFallbackContent;
4219
+ ToolFallback.Args = ToolFallbackArgs;
4220
+ ToolFallback.Result = ToolFallbackResult;
4221
+ ToolFallback.Error = ToolFallbackError;
4222
+ ToolFallback.Notice = ToolFallbackNotice;
4223
+ export {
4224
+ Collapsible as $,
4225
+ readRejectedToolResult as A,
4226
+ Brain as B,
4227
+ CopyToolSpecButton as C,
4228
+ composeEventHandlers as D,
4229
+ ExpandableSection as E,
4230
+ dispatchDiscreteCustomEvent as F,
4231
+ useLayoutEffect2 as G,
4232
+ createContextScope as H,
4233
+ useId as I,
4234
+ useControllableState as J,
4235
+ Presence as K,
4236
+ useAssetPanelStore as L,
4237
+ Terminal as M,
4238
+ NestedPtcComponentsProvider as N,
4239
+ Presentation as O,
4240
+ Primitive as P,
4241
+ Boxes as Q,
4242
+ Loader as R,
4243
+ Settings as S,
4244
+ TOOL_ICONS as T,
4245
+ CircleCheck as U,
4246
+ ScanSearch as V,
4247
+ FolderOpen as W,
4248
+ PenLine as X,
4249
+ ListChecks as Y,
4250
+ ChartColumn as Z,
4251
+ ExternalLink as _,
4252
+ NestedPtcMessages as a,
4253
+ CollapsibleTrigger as a0,
4254
+ CollapsibleContent as a1,
4255
+ ToolCard as b,
4256
+ ToolFallback as c,
4257
+ ToolFallbackArgs as d,
4258
+ ToolFallbackContent as e,
4259
+ ToolFallbackError as f,
4260
+ ToolFallbackNotice as g,
4261
+ ToolFallbackResult as h,
4262
+ ToolFallbackRoot as i,
4263
+ ToolFallbackTrigger as j,
4264
+ classifyToolResult as k,
4265
+ clearAutoOpenedAssets as l,
4266
+ describeToolArgs as m,
4267
+ formatToolName as n,
4268
+ getToolDisplayMeta as o,
4269
+ isToolResultSuccess as p,
4270
+ normalizeResult as q,
4271
+ resultMessage as r,
4272
+ toolCompletedLabel as s,
4273
+ toolActiveLabel as t,
4274
+ toolIcon as u,
4275
+ truncate as v,
4276
+ tryParseJson as w,
4277
+ useNestedPtcComponents as x,
4278
+ describePackage as y,
4279
+ toolStatusLabel as z
4280
+ };
4281
+ //# sourceMappingURL=tool-fallback-DkQ3DLkn.js.map