@athenaintel/react 0.16.3 → 0.18.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 (56) hide show
  1. package/README.md +89 -51
  2. package/dist/AthenaContext-B1QMhIP-.cjs.map +1 -1
  3. package/dist/AthenaContext-MOslgOmE.js.map +1 -1
  4. package/dist/chat/statewire-banners.d.ts +5 -9
  5. package/dist/chat-ui/index.d.ts +3 -0
  6. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +24 -0
  7. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +5 -0
  8. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +1 -1
  9. package/dist/chat-ui/messages/continue-pill.d.ts +13 -0
  10. package/dist/chat-ui/messages/message-components.d.ts +7 -2
  11. package/dist/chat-ui/messages/runtime-message.d.ts +22 -0
  12. package/dist/chat-ui/messages/statewire-continue-run.d.ts +41 -0
  13. package/dist/chat-ui/thread/chat-composer-dock.d.ts +1 -1
  14. package/dist/chat-ui.cjs +279 -56
  15. package/dist/chat-ui.cjs.map +1 -1
  16. package/dist/chat-ui.js +312 -89
  17. package/dist/chat-ui.js.map +1 -1
  18. package/dist/diagnostics/athena-diagnostics.d.ts +1 -1
  19. package/dist/diagnostics/errors.d.ts +0 -4
  20. package/dist/index.cjs +18866 -21879
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +4 -8
  23. package/dist/index.js +18884 -21897
  24. package/dist/index.js.map +1 -1
  25. package/dist/lib/athena-urls.d.ts +0 -2
  26. package/dist/lib/posthog/wrap-posthog-client.d.ts +3 -1
  27. package/dist/provider/AthenaContext.d.ts +0 -7
  28. package/dist/provider/AthenaProvider.d.ts +25 -51
  29. package/dist/provider/config.d.ts +13 -12
  30. package/dist/provider/statewire-lifecycle-context.d.ts +3 -4
  31. package/dist/provider/types.d.ts +0 -1
  32. package/dist/runtime/auth.d.ts +37 -4
  33. package/dist/runtime/statewire-lifecycle.d.ts +0 -1
  34. package/dist/runtime/statewire-run-config.d.ts +18 -5
  35. package/dist/runtime/useAthenaStatewireRuntime.d.ts +6 -11
  36. package/dist/styles.css +1 -1
  37. package/dist/threads/ThreadList.d.ts +6 -1
  38. package/dist/threads/statewire-thread-list.d.ts +6 -5
  39. package/dist/threads/thread-id-context.d.ts +9 -0
  40. package/dist/threads/use-statewire-conversation-history.d.ts +2 -0
  41. package/dist/threads/useAthenaThreadManager.d.ts +24 -12
  42. package/dist/{use-rest-conversation-history-BgG4VyZQ.js → use-rest-conversation-history-Bs5qn5G3.js} +7500 -6959
  43. package/dist/use-rest-conversation-history-Bs5qn5G3.js.map +1 -0
  44. package/dist/{use-rest-conversation-history-CMuTZmsp.cjs → use-rest-conversation-history-Dm0rdQgT.cjs} +7311 -6770
  45. package/dist/use-rest-conversation-history-Dm0rdQgT.cjs.map +1 -0
  46. package/package.json +3 -3
  47. package/dist/runtime/converter.d.ts +0 -5
  48. package/dist/runtime/external-message-converter.d.ts +0 -21
  49. package/dist/runtime/schemas.d.ts +0 -24
  50. package/dist/runtime/transport.d.ts +0 -37
  51. package/dist/runtime/useAthenaRuntime.d.ts +0 -47
  52. package/dist/threads/adapter.d.ts +0 -42
  53. package/dist/threads/useActiveThreadStateHydration.d.ts +0 -12
  54. package/dist/threads/useThreadTitlePolling.d.ts +0 -14
  55. package/dist/use-rest-conversation-history-BgG4VyZQ.js.map +0 -1
  56. package/dist/use-rest-conversation-history-CMuTZmsp.cjs.map +0 -1
package/dist/chat-ui.cjs CHANGED
@@ -3,14 +3,15 @@ var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const useRestConversationHistory = require("./use-rest-conversation-history-CMuTZmsp.cjs");
6
+ const useRestConversationHistory = require("./use-rest-conversation-history-Dm0rdQgT.cjs");
7
7
  const jsxRuntime = require("react/jsx-runtime");
8
8
  const React = require("react");
9
9
  const react = require("@assistant-ui/react");
10
10
  require("@assistant-ui/tap");
11
11
  require("statewire");
12
12
  require("@assistant-ui/store");
13
- require("@assistant-ui/react-statewire");
13
+ const reactStatewire = require("@assistant-ui/react-statewire");
14
+ require("@assistant-ui/core");
14
15
  const mentionHandlersByThread = /* @__PURE__ */ new Map();
15
16
  function registerChatAssetMentionHandler(threadId, handler) {
16
17
  mentionHandlersByThread.set(threadId, handler);
@@ -20,6 +21,18 @@ function registerChatAssetMentionHandler(threadId, handler) {
20
21
  }
21
22
  };
22
23
  }
24
+ /**
25
+ * @license lucide-react v0.575.0 - ISC
26
+ *
27
+ * This source code is licensed under the ISC license.
28
+ * See the LICENSE file in the root directory of this source tree.
29
+ */
30
+ const __iconNode$m = [
31
+ ["rect", { width: "20", height: "5", x: "2", y: "3", rx: "1", key: "1wp1u1" }],
32
+ ["path", { d: "M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8", key: "1s80jp" }],
33
+ ["path", { d: "M10 12h4", key: "a56b0p" }]
34
+ ];
35
+ const Archive = useRestConversationHistory.createLucideIcon("archive", __iconNode$m);
23
36
  /**
24
37
  * @license lucide-react v0.575.0 - ISC
25
38
  *
@@ -665,7 +678,7 @@ function ConversationHistoryPanel({
665
678
  title: "Archive conversation",
666
679
  onClick: () => onArchive(conversation.threadId),
667
680
  className: "invisible rounded p-1 text-muted-foreground hover:bg-background hover:text-foreground group-hover:visible focus:visible",
668
- children: /* @__PURE__ */ jsxRuntime.jsx(useRestConversationHistory.Archive, { className: "size-3.5" })
681
+ children: /* @__PURE__ */ jsxRuntime.jsx(Archive, { className: "size-3.5" })
669
682
  }
670
683
  )
671
684
  ]
@@ -690,8 +703,8 @@ function ConversationHistoryPanel({
690
703
  );
691
704
  }
692
705
  function makeMentionUrl(attrs) {
693
- if (attrs.type === "tool") {
694
- return `mention://tool?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? "")}`;
706
+ if (attrs.type === "tool" || attrs.type === "toolkit") {
707
+ return `mention://${attrs.type}?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? "")}`;
695
708
  }
696
709
  if (attrs.type === "asset") {
697
710
  const params2 = new URLSearchParams({ asset_ids: attrs.id });
@@ -1148,6 +1161,13 @@ const ICON_MAP = {
1148
1161
  presentation: useRestConversationHistory.FileText
1149
1162
  // Fallback for presentation type
1150
1163
  };
1164
+ function toKebabIconName(name) {
1165
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").toLowerCase();
1166
+ }
1167
+ function resolveIcon(name) {
1168
+ return ICON_MAP[name] ?? ICON_MAP[toKebabIconName(name)];
1169
+ }
1170
+ const ICON_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9-]*$/;
1151
1171
  function MentionIcon({
1152
1172
  fallbackIcon,
1153
1173
  thumbnailUrl,
@@ -1157,9 +1177,11 @@ function MentionIcon({
1157
1177
  if (thumbnailUrl) {
1158
1178
  return /* @__PURE__ */ jsxRuntime.jsx("img", { src: thumbnailUrl, alt: alt ?? "", className });
1159
1179
  }
1160
- const Icon = fallbackIcon ? ICON_MAP[fallbackIcon] : void 0;
1180
+ const Icon = fallbackIcon ? resolveIcon(fallbackIcon) : void 0;
1161
1181
  if (Icon) return /* @__PURE__ */ jsxRuntime.jsx(Icon, { className });
1162
- if (fallbackIcon) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm flex-shrink-0", children: fallbackIcon });
1182
+ if (fallbackIcon && !ICON_NAME_PATTERN.test(fallbackIcon)) {
1183
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm flex-shrink-0", children: fallbackIcon });
1184
+ }
1163
1185
  return /* @__PURE__ */ jsxRuntime.jsx(useRestConversationHistory.File, { className });
1164
1186
  }
1165
1187
  function MenuItemRow({
@@ -1169,7 +1191,7 @@ function MenuItemRow({
1169
1191
  onClick,
1170
1192
  showArrow
1171
1193
  }) {
1172
- var _a, _b;
1194
+ var _a, _b, _c, _d;
1173
1195
  const hasTwoLines = item.type === "tool" && item.description || item.type === "user" && item.email || item.type === "workspace_item" && item.description || item.type === "tab" && item.description;
1174
1196
  return /* @__PURE__ */ jsxRuntime.jsxs(
1175
1197
  "div",
@@ -1185,23 +1207,31 @@ function MenuItemRow({
1185
1207
  isSelected && "bg-gray-100 is-selected"
1186
1208
  ),
1187
1209
  children: [
1188
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: `flex items-center flex-shrink-0 ${hasTwoLines ? "self-start mt-0.5" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
1189
- MentionIcon,
1210
+ /* @__PURE__ */ jsxRuntime.jsx(
1211
+ "span",
1190
1212
  {
1191
- fallbackIcon: item.fallbackIcon,
1192
- thumbnailUrl: item.thumbnailUrl,
1193
- alt: item.name
1213
+ className: `flex items-center flex-shrink-0 ${hasTwoLines ? "self-start mt-0.5" : ""}`,
1214
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1215
+ MentionIcon,
1216
+ {
1217
+ fallbackIcon: item.fallbackIcon,
1218
+ thumbnailUrl: item.thumbnailUrl,
1219
+ alt: item.name
1220
+ }
1221
+ )
1194
1222
  }
1195
- ) }),
1223
+ ),
1196
1224
  hasTwoLines ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col gap-0 min-w-0 -mt-0.5", children: [
1197
1225
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm leading-tight flex items-center gap-1.5", children: [
1198
1226
  item.name,
1199
- ((_a = item.extra) == null ? void 0 : _a.isAdminOnly) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0" })
1227
+ ((_a = item.extra) == null ? void 0 : _a.isAdminOnly) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0" }),
1228
+ ((_b = item.extra) == null ? void 0 : _b.isExperimental) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-full bg-blue-50 px-1.5 py-0.5 text-[9px] font-medium text-blue-700", children: "Experimental" })
1200
1229
  ] }),
1201
1230
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-500 leading-tight mt-0.5 truncate", children: item.type === "user" ? item.email : item.description })
1202
1231
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex-1 text-sm truncate min-w-0 flex items-center gap-1.5", children: [
1203
1232
  item.name,
1204
- ((_b = item.extra) == null ? void 0 : _b.isAdminOnly) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0" })
1233
+ ((_c = item.extra) == null ? void 0 : _c.isAdminOnly) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0" }),
1234
+ ((_d = item.extra) == null ? void 0 : _d.isExperimental) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-full bg-blue-50 px-1.5 py-0.5 text-[9px] font-medium text-blue-700", children: "Experimental" })
1205
1235
  ] }),
1206
1236
  showArrow && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1 flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 text-sm px-1 rounded transition-all cursor-pointer hover:text-gray-600 hover:bg-gray-200", children: "→" }) })
1207
1237
  ]
@@ -1560,17 +1590,19 @@ const MentionSuggestionList = React.forwardRef(({ store, editor, query, command,
1560
1590
  MentionSuggestionList.displayName = "MentionSuggestionList";
1561
1591
  function assetToMenuItem(asset) {
1562
1592
  const isFolder = asset.athenaOriginalType === "folder";
1593
+ const displayType = asset.athenaConvertedType || asset.athenaOriginalType;
1563
1594
  return {
1564
1595
  id: asset.id,
1565
1596
  name: asset.title || "Untitled",
1566
1597
  type: isFolder ? "folder" : "asset",
1567
- thumbnailUrl: useRestConversationHistory.assetTypeToThumb(asset.athenaOriginalType),
1568
- fallbackIcon: useRestConversationHistory.assetTypeToIcon(asset.athenaOriginalType),
1598
+ thumbnailUrl: useRestConversationHistory.assetTypeToThumb(displayType),
1599
+ fallbackIcon: useRestConversationHistory.assetTypeToIcon(displayType),
1569
1600
  navigatesToScope: isFolder ? asset.id : void 0,
1570
1601
  visibleInScopes: /* @__PURE__ */ new Set(),
1571
1602
  updatedAt: asset.updatedAt ?? void 0,
1572
1603
  extra: {
1573
1604
  athenaOriginalType: asset.athenaOriginalType,
1605
+ athenaConvertedType: asset.athenaConvertedType,
1574
1606
  parentFolderId: asset.parentFolderId
1575
1607
  }
1576
1608
  };
@@ -1591,11 +1623,7 @@ async function querySimpleSearch(auth, opts) {
1591
1623
  sort: { field: "UPDATED_AT", direction: "DESC" },
1592
1624
  filterColumns: { isArchived: false, isHidden: false }
1593
1625
  };
1594
- const data = await useRestConversationHistory.fetchGraphQL(
1595
- auth,
1596
- useRestConversationHistory.SIMPLE_SEARCH_QUERY,
1597
- { input }
1598
- );
1626
+ const data = await useRestConversationHistory.fetchGraphQL(auth, useRestConversationHistory.SIMPLE_SEARCH_QUERY, { input });
1599
1627
  const assets = ((_b = data.simpleSearch) == null ? void 0 : _b.assets) || [];
1600
1628
  return {
1601
1629
  items: assets.map(assetToMenuItem),
@@ -1605,9 +1633,19 @@ async function querySimpleSearch(auth, opts) {
1605
1633
  const CATEGORY_DEFS = {
1606
1634
  favorites: { name: "Favorites", icon: "star", scope: "favorites" },
1607
1635
  assets: { name: "Assets", icon: "file-text", scope: "athena_assets" },
1608
- projects: { name: "Projects", icon: "folder-kanban", scope: "athena_projects" },
1609
- browse_profiles: { name: "Browse Profiles", icon: "globe", scope: "athena_browse_profiles" },
1636
+ projects: {
1637
+ name: "Projects",
1638
+ icon: "folder-kanban",
1639
+ scope: "athena_projects"
1640
+ },
1641
+ browse_profiles: {
1642
+ name: "Browse Profiles",
1643
+ icon: "globe",
1644
+ scope: "athena_browse_profiles"
1645
+ },
1610
1646
  folders: { name: "Folders", icon: "folder", scope: "athena_folders" },
1647
+ tools: { name: "Tools", icon: "wrench", scope: "tools" },
1648
+ toolkits: { name: "Toolkits", icon: "package", scope: "toolkits" },
1611
1649
  team: { name: "Team", icon: "users", scope: "team" },
1612
1650
  drives: { name: "Drives", icon: "hard-drive", scope: "drive_catalogs" }
1613
1651
  };
@@ -1674,7 +1712,14 @@ const fetchAssets = async (context) => {
1674
1712
  query,
1675
1713
  limit,
1676
1714
  offset,
1677
- excludeTypes: ["folder", "catalog", "spaces", "session", "table", "task_item"]
1715
+ excludeTypes: [
1716
+ "folder",
1717
+ "catalog",
1718
+ "spaces",
1719
+ "session",
1720
+ "table",
1721
+ "task_item"
1722
+ ]
1678
1723
  });
1679
1724
  return {
1680
1725
  items: result.items,
@@ -1686,21 +1731,17 @@ const fetchFavorites = async (context) => {
1686
1731
  const limit = sourceConfig.limit ?? 50;
1687
1732
  const meta = fetchState.meta || {};
1688
1733
  const offset = meta.validatedCount || 0;
1689
- const data = await useRestConversationHistory.fetchGraphQL(
1690
- sourceConfig.auth,
1691
- useRestConversationHistory.PAGINATED_ASSETS_QUERY,
1692
- {
1693
- limit,
1694
- offset,
1695
- parentFolderId: null,
1696
- filterTypes: null,
1697
- filterColumns: {
1698
- isFavorited: true,
1699
- isArchived: false,
1700
- isHidden: false
1701
- }
1734
+ const data = await useRestConversationHistory.fetchGraphQL(sourceConfig.auth, useRestConversationHistory.PAGINATED_ASSETS_QUERY, {
1735
+ limit,
1736
+ offset,
1737
+ parentFolderId: null,
1738
+ filterTypes: null,
1739
+ filterColumns: {
1740
+ isFavorited: true,
1741
+ isArchived: false,
1742
+ isHidden: false
1702
1743
  }
1703
- );
1744
+ });
1704
1745
  const assets = data.getPaginatedAssetsForWorkspace || [];
1705
1746
  const items = assets.map(assetToMenuItem);
1706
1747
  return {
@@ -1730,21 +1771,17 @@ const fetchFolderContents = async (context) => {
1730
1771
  const meta = fetchState.meta || {};
1731
1772
  const offset = meta.validatedCount || 0;
1732
1773
  const parentFolderId = scope === "internal_drive" ? null : scope;
1733
- const data = await useRestConversationHistory.fetchGraphQL(
1734
- sourceConfig.auth,
1735
- useRestConversationHistory.PAGINATED_ASSETS_QUERY,
1736
- {
1737
- limit,
1738
- offset,
1739
- parentFolderId,
1740
- filterTypes: null,
1741
- filterColumns: {
1742
- isArchived: false,
1743
- isHidden: false,
1744
- ...query ? { title: [{ op: "LIKE", value: `%${query}%` }] } : {}
1745
- }
1774
+ const data = await useRestConversationHistory.fetchGraphQL(sourceConfig.auth, useRestConversationHistory.PAGINATED_ASSETS_QUERY, {
1775
+ limit,
1776
+ offset,
1777
+ parentFolderId,
1778
+ filterTypes: null,
1779
+ filterColumns: {
1780
+ isArchived: false,
1781
+ isHidden: false,
1782
+ ...query ? { title: [{ op: "LIKE", value: `%${query}%` }] } : {}
1746
1783
  }
1747
- );
1784
+ });
1748
1785
  const rawAssets = data.getPaginatedAssetsForWorkspace || [];
1749
1786
  const assets = rawAssets.filter(
1750
1787
  (a) => a.athenaConvertedType !== "catalog" && a.athenaOriginalType !== "catalog"
@@ -1800,6 +1837,36 @@ const fetchTeam = async (context) => {
1800
1837
  });
1801
1838
  return { items, pagination: { hasMore: false } };
1802
1839
  };
1840
+ async function queryToolCatalog(auth) {
1841
+ const data = await useRestConversationHistory.fetchGraphQL(auth, useRestConversationHistory.TOOL_CATALOG_QUERY);
1842
+ return data.getToolkitToToolsMapping;
1843
+ }
1844
+ const fetchTools = async (context) => {
1845
+ const catalog = await queryToolCatalog(context.sourceConfig.auth);
1846
+ const items = catalog.tools.filter((tool) => tool.isMentionable).map((tool) => ({
1847
+ id: tool.id,
1848
+ name: tool.name,
1849
+ type: "tool",
1850
+ fallbackIcon: tool.icon,
1851
+ description: tool.description ?? void 0,
1852
+ visibleInScopes: /* @__PURE__ */ new Set(),
1853
+ ...tool.adminOnly ? { extra: { isAdminOnly: true } } : {}
1854
+ }));
1855
+ return { items, pagination: { hasMore: false } };
1856
+ };
1857
+ const fetchToolkits = async (context) => {
1858
+ const catalog = await queryToolCatalog(context.sourceConfig.auth);
1859
+ const items = catalog.toolkits.filter((toolkit) => toolkit.isMentionable && !toolkit.hideFromMenu).map((toolkit) => ({
1860
+ id: toolkit.name,
1861
+ name: toolkit.displayName,
1862
+ type: "toolkit",
1863
+ fallbackIcon: toolkit.icon,
1864
+ description: toolkit.description || void 0,
1865
+ visibleInScopes: /* @__PURE__ */ new Set(),
1866
+ ...toolkit.onlyAdmin ? { extra: { isAdminOnly: true } } : {}
1867
+ }));
1868
+ return { items, pagination: { hasMore: false } };
1869
+ };
1803
1870
  const fetchDrives = async (context) => {
1804
1871
  const { fetchState, sourceConfig } = context;
1805
1872
  const meta = fetchState.meta || {};
@@ -1859,6 +1926,8 @@ const ROOT_MENTION_CATEGORIES = [
1859
1926
  "projects",
1860
1927
  "browse_profiles",
1861
1928
  "folders",
1929
+ "tools",
1930
+ "toolkits",
1862
1931
  "team",
1863
1932
  "drives"
1864
1933
  ];
@@ -1883,9 +1952,11 @@ function buildStore({
1883
1952
  fetchFolders,
1884
1953
  { auth, limit: 50 },
1885
1954
  true
1886
- /* isFlat */
1887
1955
  );
1888
- useRestConversationHistory.registerSource(registry, "internal_drive", fetchFolderContents, { auth, limit: 50 });
1956
+ useRestConversationHistory.registerSource(registry, "internal_drive", fetchFolderContents, {
1957
+ auth,
1958
+ limit: 50
1959
+ });
1889
1960
  useRestConversationHistory.registerSource(registry, "athena_projects", fetchTypedAssets, {
1890
1961
  auth,
1891
1962
  includeOnlyTypes: ["project"],
@@ -1896,6 +1967,8 @@ function buildStore({
1896
1967
  includeOnlyTypes: ["browse_profile"],
1897
1968
  limit: 50
1898
1969
  });
1970
+ useRestConversationHistory.registerSource(registry, "tools", fetchTools, { auth });
1971
+ useRestConversationHistory.registerSource(registry, "toolkits", fetchToolkits, { auth });
1899
1972
  useRestConversationHistory.registerSource(registry, "team", fetchTeam, { auth });
1900
1973
  useRestConversationHistory.registerSource(registry, "drive_catalogs", fetchDrives, { auth });
1901
1974
  return new useRestConversationHistory.Store({ registry, cache });
@@ -2374,6 +2447,151 @@ const SignInConsent = ({ checked, onChange, children }) => /* @__PURE__ */ jsxRu
2374
2447
  ),
2375
2448
  /* @__PURE__ */ jsxRuntime.jsx("span", { children })
2376
2449
  ] });
2450
+ const EXIT_ANIMATION_MS = 200;
2451
+ const EXIT_RESET_MS = 2500;
2452
+ const ContinuePill = ({ onClick, ariaLabel, dataTestId }) => {
2453
+ const [isExiting, setIsExiting] = React.useState(false);
2454
+ const onClickRef = React.useRef(onClick);
2455
+ const pendingOnClickRef = React.useRef(onClick);
2456
+ onClickRef.current = onClick;
2457
+ React.useEffect(() => {
2458
+ if (!isExiting) return;
2459
+ const dispatchTimer = setTimeout(
2460
+ () => pendingOnClickRef.current(),
2461
+ EXIT_ANIMATION_MS
2462
+ );
2463
+ const resetTimer = setTimeout(() => setIsExiting(false), EXIT_RESET_MS);
2464
+ return () => {
2465
+ clearTimeout(dispatchTimer);
2466
+ clearTimeout(resetTimer);
2467
+ };
2468
+ }, [isExiting]);
2469
+ const handleClick = () => {
2470
+ if (isExiting) return;
2471
+ pendingOnClickRef.current = onClickRef.current;
2472
+ setIsExiting(true);
2473
+ };
2474
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2475
+ "button",
2476
+ {
2477
+ type: "button",
2478
+ onClick: handleClick,
2479
+ disabled: isExiting,
2480
+ className: useRestConversationHistory.cn(
2481
+ "group inline-flex items-center gap-1.5 rounded-full bg-primary px-3.5 py-1 text-xs font-medium text-primary-foreground shadow-sm",
2482
+ "transition-all duration-200 ease-out",
2483
+ "hover:bg-primary/90 hover:shadow-md active:scale-95",
2484
+ "animate-in fade-in slide-in-from-bottom-1",
2485
+ isExiting && "pointer-events-none scale-90 opacity-0"
2486
+ ),
2487
+ "aria-label": ariaLabel,
2488
+ "data-testid": dataTestId,
2489
+ children: [
2490
+ /* @__PURE__ */ jsxRuntime.jsx(useRestConversationHistory.Play, { className: "size-3 fill-current transition-transform duration-200 ease-out group-hover:translate-x-0.5" }),
2491
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Continue" })
2492
+ ]
2493
+ }
2494
+ );
2495
+ };
2496
+ function StatewireContinueRunButton({
2497
+ allowReadyFallback = false
2498
+ } = {}) {
2499
+ const status = useRestConversationHistory.useDeepAgentThreadStatus();
2500
+ const { runId } = reactStatewire.useStatewireRuns();
2501
+ const sendCommand = reactStatewire.useStatewireSendCommand();
2502
+ const isSettled = status === "stopped" || status === "error";
2503
+ if (!isSettled && !(allowReadyFallback && status === "ready")) return null;
2504
+ return /* @__PURE__ */ jsxRuntime.jsx(
2505
+ ContinuePill,
2506
+ {
2507
+ ariaLabel: "Continue this run from where it stopped",
2508
+ dataTestId: "statewire-continue-run",
2509
+ onClick: () => {
2510
+ sendCommand({
2511
+ type: "run/continue",
2512
+ ...runId !== null && { runId }
2513
+ });
2514
+ }
2515
+ }
2516
+ );
2517
+ }
2518
+ function StatewireContinueRunAffordance() {
2519
+ const messageId = react.useAuiState((state) => state.message.id);
2520
+ const lastMessageId = react.useAuiState(
2521
+ (state) => {
2522
+ var _a;
2523
+ return (_a = state.thread.messages.at(-1)) == null ? void 0 : _a.id;
2524
+ }
2525
+ );
2526
+ const runMarker = react.useAuiState(
2527
+ (state) => {
2528
+ var _a;
2529
+ return (_a = useRestConversationHistory.readRunMarkerFromSourceMessages(state.message)) == null ? void 0 : _a.marker;
2530
+ }
2531
+ );
2532
+ const threadExtras = react.useAuiState((state) => state.thread.extras);
2533
+ const isContinuableMarker = runMarker === useRestConversationHistory.ATHENA_RUN_MARKER_CANCELLED || runMarker === useRestConversationHistory.ATHENA_RUN_MARKER_FAILED;
2534
+ if (messageId !== lastMessageId || !isContinuableMarker) return null;
2535
+ if (!useRestConversationHistory.hasStatewireThreadExtras(threadExtras)) return null;
2536
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full justify-center py-1", children: /* @__PURE__ */ jsxRuntime.jsx(StatewireContinueRunButton, { allowReadyFallback: true }) });
2537
+ }
2538
+ function StatewireRunEndedFooter({
2539
+ className
2540
+ } = {}) {
2541
+ const threadExtras = react.useAuiState((state) => state.thread.extras);
2542
+ if (!useRestConversationHistory.hasStatewireThreadExtras(threadExtras)) return null;
2543
+ return /* @__PURE__ */ jsxRuntime.jsx(StatewireRunEndedFooterContent, { className });
2544
+ }
2545
+ function StatewireRunEndedFooterContent({
2546
+ className
2547
+ }) {
2548
+ const status = useRestConversationHistory.useDeepAgentThreadStatus();
2549
+ const { error } = reactStatewire.useStatewireRuns();
2550
+ const tailEndingKind = react.useAuiState((state) => {
2551
+ var _a;
2552
+ const last = state.thread.messages.at(-1);
2553
+ return last ? ((_a = useRestConversationHistory.readRuntimeMessageFromSourceMessages(last)) == null ? void 0 : _a.kind) ?? null : null;
2554
+ });
2555
+ const tailEndingSilent = react.useAuiState((state) => {
2556
+ var _a;
2557
+ const last = state.thread.messages.at(-1);
2558
+ return last ? ((_a = useRestConversationHistory.readRuntimeMessageFromSourceMessages(last)) == null ? void 0 : _a.silent) ?? false : false;
2559
+ });
2560
+ if (status !== "stopped" && status !== "error") return null;
2561
+ if (status === "stopped" && tailEndingSilent) return null;
2562
+ const tailRendersEnding = tailEndingKind !== null && !tailEndingSilent;
2563
+ const tailMatchesStatus = status === "error" ? tailEndingKind === "failed" : tailEndingKind === "stopped" || tailEndingKind === "paused";
2564
+ if (tailRendersEnding && tailMatchesStatus) return null;
2565
+ const tailOwnsContinue = tailRendersEnding && (tailEndingKind === "stopped" || tailEndingKind === "paused" || tailEndingKind === "failed");
2566
+ const action = tailOwnsContinue ? void 0 : /* @__PURE__ */ jsxRuntime.jsx(StatewireContinueRunButton, {});
2567
+ const message = status === "error" ? {
2568
+ kind: "failed",
2569
+ reason: "error",
2570
+ severity: "error",
2571
+ title: "Run failed",
2572
+ detail: void 0,
2573
+ text: (error == null ? void 0 : error.message) ? `⚠️ The run failed: ${error.message}` : void 0,
2574
+ silent: false,
2575
+ isSoleSourceMessage: true
2576
+ } : {
2577
+ kind: "stopped",
2578
+ reason: void 0,
2579
+ severity: "info",
2580
+ title: "Conversation stopped",
2581
+ detail: void 0,
2582
+ text: void 0,
2583
+ silent: false,
2584
+ isSoleSourceMessage: true
2585
+ };
2586
+ return /* @__PURE__ */ jsxRuntime.jsx(
2587
+ useRestConversationHistory.RuntimeMessageCard,
2588
+ {
2589
+ message,
2590
+ action,
2591
+ className: useRestConversationHistory.cn("mx-auto max-w-[95%]", className)
2592
+ }
2593
+ );
2594
+ }
2377
2595
  exports.BranchPicker = useRestConversationHistory.BranchPicker;
2378
2596
  exports.COMPOSER_DOCK_CLASS = useRestConversationHistory.COMPOSER_DOCK_CLASS;
2379
2597
  exports.COMPOSER_EDITOR_ROW_CLASS = useRestConversationHistory.COMPOSER_EDITOR_ROW_CLASS;
@@ -2390,6 +2608,7 @@ exports.MentionAuthCtx = useRestConversationHistory.MentionAuthCtx;
2390
2608
  exports.MentionChip = useRestConversationHistory.MentionChip;
2391
2609
  exports.MentionLink = useRestConversationHistory.MentionLink;
2392
2610
  exports.MessageActionsReadOnlyProvider = useRestConversationHistory.MessageActionsReadOnlyProvider;
2611
+ exports.RuntimeMessageCard = useRestConversationHistory.RuntimeMessageCard;
2393
2612
  exports.SIMPLE_SEARCH_QUERY = useRestConversationHistory.SIMPLE_SEARCH_QUERY;
2394
2613
  exports.SmallIconButton = useRestConversationHistory.SmallIconButton;
2395
2614
  exports.THREAD_HEADER_ACTIONS_CLASS = useRestConversationHistory.THREAD_HEADER_ACTIONS_CLASS;
@@ -2418,6 +2637,7 @@ exports.ChatHeader = ChatHeader;
2418
2637
  exports.ChatHeaderActions = ChatHeaderActions;
2419
2638
  exports.ChatHeaderIdentity = ChatHeaderIdentity;
2420
2639
  exports.ChatHeaderRoot = ChatHeaderRoot;
2640
+ exports.ContinuePill = ContinuePill;
2421
2641
  exports.ConversationHistoryPanel = ConversationHistoryPanel;
2422
2642
  exports.MentionExtension = MentionExtension;
2423
2643
  exports.MentionIcon = MentionIcon;
@@ -2434,6 +2654,9 @@ exports.SignInFallbackSection = SignInFallbackSection;
2434
2654
  exports.SignInSecondaryButton = SignInSecondaryButton;
2435
2655
  exports.SignInSelect = SignInSelect;
2436
2656
  exports.SignInTextField = SignInTextField;
2657
+ exports.StatewireContinueRunAffordance = StatewireContinueRunAffordance;
2658
+ exports.StatewireContinueRunButton = StatewireContinueRunButton;
2659
+ exports.StatewireRunEndedFooter = StatewireRunEndedFooter;
2437
2660
  exports.TiptapComposer = TiptapComposer;
2438
2661
  exports.buildRootMenuItems = buildRootMenuItems;
2439
2662
  exports.makeMentionUrl = makeMentionUrl;