@truefoundry/agent-ui-sdk 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -949,19 +949,13 @@ function MessageTimestamp({ className }) {
949
949
  }
950
950
 
951
951
  // src/atoms/UserMessageActionBar.tsx
952
- import { ActionBarPrimitive, useAuiState as useAuiState2 } from "@assistant-ui/react";
952
+ import { ActionBarPrimitive, useAui } from "@assistant-ui/react";
953
953
  import { useActionBarCopy, useActionBarEdit } from "@assistant-ui/core/react";
954
- import { useTrueFoundryResetFromTurn } from "@truefoundry/assistant-ui-runtime";
955
954
  import { jsx as jsx36, jsxs as jsxs13 } from "react/jsx-runtime";
956
- function parseTurnIdFromMessageId(messageId) {
957
- return messageId.replace(/-user$/, "");
958
- }
959
955
  function UserMessageActionBar({ className }) {
960
956
  const IconButton5 = useSlot("IconButton");
961
957
  const MessageTimestamp2 = useSlot("MessageTimestamp");
962
- const messageId = useAuiState2((s) => s.message.id);
963
- const turnId = parseTurnIdFromMessageId(messageId);
964
- const resetFromTurn = useTrueFoundryResetFromTurn();
958
+ const aui = useAui();
965
959
  const { edit, disabled: editDisabled } = useActionBarEdit();
966
960
  const { copy, isCopied } = useActionBarCopy({
967
961
  copyToClipboard: (text) => navigator.clipboard.writeText(text)
@@ -980,7 +974,10 @@ function UserMessageActionBar({ className }) {
980
974
  {
981
975
  icon: "rotate-right",
982
976
  tooltip: "Try again",
983
- onClick: () => void resetFromTurn(turnId)
977
+ onClick: () => {
978
+ aui.message().composer().beginEdit();
979
+ aui.message().composer().send({ startRun: true });
980
+ }
984
981
  }
985
982
  ),
986
983
  /* @__PURE__ */ jsx36(
@@ -1293,7 +1290,7 @@ import { default as default6 } from "tfy-web-components/components/atoms/Skeleto
1293
1290
  // src/containers/ThreadContainer.tsx
1294
1291
  import { useEffect as useEffect6 } from "react";
1295
1292
  import { preloadMarkdownOpenUI } from "tfy-web-components/components/molecules/Markdown";
1296
- import { ThreadPrimitive, useAuiState as useAuiState11 } from "@assistant-ui/react";
1293
+ import { ThreadPrimitive, useAuiState as useAuiState10 } from "@assistant-ui/react";
1297
1294
 
1298
1295
  // src/hooks/useComposerBusyState.ts
1299
1296
  import { useThreadIsRunning } from "@assistant-ui/core/react";
@@ -1339,7 +1336,7 @@ function useComposerBusyState() {
1339
1336
  }
1340
1337
 
1341
1338
  // src/containers/AssistantMessageContainer.tsx
1342
- import { MessagePrimitive as MessagePrimitive2, useAuiState as useAuiState6 } from "@assistant-ui/react";
1339
+ import { MessagePrimitive as MessagePrimitive2, useAuiState as useAuiState5 } from "@assistant-ui/react";
1343
1340
  import { useActionBarCopy as useActionBarCopy2, useMessageError, useThreadIsRunning as useThreadIsRunning2 } from "@assistant-ui/core/react";
1344
1341
 
1345
1342
  // src/utils/computeAgentStepsSplit.ts
@@ -1386,7 +1383,7 @@ function computeAgentStepsSplit(parts, isRunning) {
1386
1383
 
1387
1384
  // src/containers/AssistantTextContainer.tsx
1388
1385
  import { useCallback as useCallback3 } from "react";
1389
- import { useAuiState as useAuiState3 } from "@assistant-ui/react";
1386
+ import { useAuiState as useAuiState2 } from "@assistant-ui/react";
1390
1387
  import { useTrueFoundryDownloadSandboxFile } from "@truefoundry/assistant-ui-runtime";
1391
1388
 
1392
1389
  // src/containers/ErrorToasterContainer.tsx
@@ -1459,10 +1456,10 @@ function AssistantTextContainer() {
1459
1456
  const Markdown2 = useSlot("Markdown");
1460
1457
  const downloadSandboxFile = useTrueFoundryDownloadSandboxFile();
1461
1458
  const errorToaster = useErrorToasterOptional();
1462
- const text = useAuiState3(
1459
+ const text = useAuiState2(
1463
1460
  (s) => s.part.type === "text" || s.part.type === "reasoning" ? s.part.text : ""
1464
1461
  );
1465
- const isStreaming = useAuiState3((s) => {
1462
+ const isStreaming = useAuiState2((s) => {
1466
1463
  if (s.message.status?.type !== "running") return false;
1467
1464
  const lastIndex = s.message.parts.length - 1;
1468
1465
  if (lastIndex < 0) return false;
@@ -1483,13 +1480,13 @@ function AssistantTextContainer() {
1483
1480
  }
1484
1481
 
1485
1482
  // src/containers/MessageImageContainer.tsx
1486
- import { useAuiState as useAuiState4 } from "@assistant-ui/react";
1483
+ import { useAuiState as useAuiState3 } from "@assistant-ui/react";
1487
1484
  import { jsx as jsx43 } from "react/jsx-runtime";
1488
1485
  function MessageImageContainer() {
1489
1486
  const AttachmentCard2 = useSlot("AttachmentCard");
1490
1487
  const AttachmentPreviewDialog2 = useSlot("AttachmentPreviewDialog");
1491
- const image = useAuiState4((s) => s.part.type === "image" ? s.part.image : "");
1492
- const filename = useAuiState4(
1488
+ const image = useAuiState3((s) => s.part.type === "image" ? s.part.image : "");
1489
+ const filename = useAuiState3(
1493
1490
  (s) => s.part.type === "image" ? s.part.filename : void 0
1494
1491
  );
1495
1492
  if (!image) {
@@ -1510,14 +1507,14 @@ function MessageImageContainer() {
1510
1507
 
1511
1508
  // src/containers/ReasoningContainer.tsx
1512
1509
  import { useCallback as useCallback4, useRef, useState as useState4 } from "react";
1513
- import { useAuiState as useAuiState5 } from "@assistant-ui/react";
1510
+ import { useAuiState as useAuiState4 } from "@assistant-ui/react";
1514
1511
  import { jsx as jsx44 } from "react/jsx-runtime";
1515
1512
  function ReasoningContainer({ group }) {
1516
1513
  const ReasoningCard2 = useSlot("ReasoningCard");
1517
- const content = useAuiState5(
1514
+ const content = useAuiState4(
1518
1515
  (s) => group.indices.map((i) => s.message.parts[i]).filter((p) => p != null && p.type === "reasoning").map((p) => p.text ?? "").join("")
1519
1516
  );
1520
- const streaming = useAuiState5((s) => {
1517
+ const streaming = useAuiState4((s) => {
1521
1518
  if (s.message.status?.type !== "running") return false;
1522
1519
  const lastIndex = s.message.parts.length - 1;
1523
1520
  if (lastIndex < 0) return false;
@@ -2218,7 +2215,7 @@ function AssistantMessageContainer() {
2218
2215
  const { copy, isCopied } = useActionBarCopy2({
2219
2216
  copyToClipboard: (text) => navigator.clipboard.writeText(text)
2220
2217
  });
2221
- const parts = useAuiState6((s) => s.message.parts);
2218
+ const parts = useAuiState5((s) => s.message.parts);
2222
2219
  const { cutIndex, hasFinal, toolCount, thinkingCount } = computeAgentStepsSplit(parts, isRunning);
2223
2220
  const groupBy = (part, _context) => {
2224
2221
  const index = parts.findIndex((p) => p === part);
@@ -2324,16 +2321,16 @@ function HistoryLoaderContainer() {
2324
2321
  import {
2325
2322
  ComposerPrimitive as ComposerPrimitive2,
2326
2323
  MessagePrimitive as MessagePrimitive4,
2327
- useAuiState as useAuiState9
2324
+ useAuiState as useAuiState8
2328
2325
  } from "@assistant-ui/react";
2329
2326
  import { useComposerCancel, useComposerSend, useThreadIsRunning as useThreadIsRunning3 } from "@assistant-ui/core/react";
2330
2327
 
2331
2328
  // src/containers/AttachmentsContainer.tsx
2332
- import { ComposerPrimitive, MessagePrimitive as MessagePrimitive3, useAui, useAuiState as useAuiState8 } from "@assistant-ui/react";
2329
+ import { ComposerPrimitive, MessagePrimitive as MessagePrimitive3, useAui as useAui2, useAuiState as useAuiState7 } from "@assistant-ui/react";
2333
2330
 
2334
2331
  // src/containers/useAttachmentPreviewSrc.ts
2335
2332
  import { useEffect as useEffect5, useState as useState11 } from "react";
2336
- import { useAuiState as useAuiState7 } from "@assistant-ui/react";
2333
+ import { useAuiState as useAuiState6 } from "@assistant-ui/react";
2337
2334
  function isImageAttachment(type, contentType) {
2338
2335
  return type === "image" || (contentType?.startsWith("image/") ?? false);
2339
2336
  }
@@ -2351,10 +2348,10 @@ function useFileObjectUrl(file) {
2351
2348
  return src;
2352
2349
  }
2353
2350
  function useAttachmentPreviewSrc() {
2354
- const type = useAuiState7((s) => s.attachment.type);
2355
- const contentType = useAuiState7((s) => s.attachment.contentType);
2356
- const file = useAuiState7((s) => "file" in s.attachment ? s.attachment.file : void 0);
2357
- const contentSrc = useAuiState7((s) => {
2351
+ const type = useAuiState6((s) => s.attachment.type);
2352
+ const contentType = useAuiState6((s) => s.attachment.contentType);
2353
+ const file = useAuiState6((s) => "file" in s.attachment ? s.attachment.file : void 0);
2354
+ const contentSrc = useAuiState6((s) => {
2358
2355
  if (!isImageAttachment(s.attachment.type, s.attachment.contentType)) return void 0;
2359
2356
  const imagePart = s.attachment.content?.find((part) => part.type === "image");
2360
2357
  if (imagePart?.type === "image" && imagePart.image) return imagePart.image;
@@ -2371,10 +2368,10 @@ import { jsx as jsx52 } from "react/jsx-runtime";
2371
2368
  function ComposerAttachmentItem() {
2372
2369
  const AttachmentCard2 = useSlot("AttachmentCard");
2373
2370
  const AttachmentPreviewDialog2 = useSlot("AttachmentPreviewDialog");
2374
- const aui = useAui();
2375
- const name = useAuiState8((s) => s.attachment.name);
2376
- const contentType = useAuiState8((s) => s.attachment.contentType);
2377
- const type = useAuiState8((s) => s.attachment.type);
2371
+ const aui = useAui2();
2372
+ const name = useAuiState7((s) => s.attachment.name);
2373
+ const contentType = useAuiState7((s) => s.attachment.contentType);
2374
+ const type = useAuiState7((s) => s.attachment.type);
2378
2375
  const isImage = isImageAttachment(type, contentType);
2379
2376
  const previewSrc = useAttachmentPreviewSrc();
2380
2377
  return /* @__PURE__ */ jsx52(AttachmentPreviewDialog2, { previewSrc, children: /* @__PURE__ */ jsx52(
@@ -2392,9 +2389,9 @@ function ComposerAttachmentItem() {
2392
2389
  function MessageAttachmentItem() {
2393
2390
  const AttachmentCard2 = useSlot("AttachmentCard");
2394
2391
  const AttachmentPreviewDialog2 = useSlot("AttachmentPreviewDialog");
2395
- const name = useAuiState8((s) => s.attachment.name);
2396
- const contentType = useAuiState8((s) => s.attachment.contentType);
2397
- const type = useAuiState8((s) => s.attachment.type);
2392
+ const name = useAuiState7((s) => s.attachment.name);
2393
+ const contentType = useAuiState7((s) => s.attachment.contentType);
2394
+ const type = useAuiState7((s) => s.attachment.type);
2398
2395
  const isImage = isImageAttachment(type, contentType);
2399
2396
  const previewSrc = useAttachmentPreviewSrc();
2400
2397
  const card = /* @__PURE__ */ jsx52(
@@ -2427,7 +2424,7 @@ function ComposerAttachmentPickerContainer() {
2427
2424
  // src/containers/UserEditComposerContainer.tsx
2428
2425
  import { jsx as jsx53, jsxs as jsxs16 } from "react/jsx-runtime";
2429
2426
  function ReadOnlyMessageAttachments() {
2430
- const hasAttachments = useAuiState9(
2427
+ const hasAttachments = useAuiState8(
2431
2428
  (s) => (s.message.attachments?.length ?? 0) > 0
2432
2429
  );
2433
2430
  if (!hasAttachments) {
@@ -2486,14 +2483,14 @@ function UserEditComposerContainer() {
2486
2483
  }
2487
2484
 
2488
2485
  // src/containers/UserMessageContainer.tsx
2489
- import { MessagePrimitive as MessagePrimitive5, useAuiState as useAuiState10 } from "@assistant-ui/react";
2486
+ import { MessagePrimitive as MessagePrimitive5, useAuiState as useAuiState9 } from "@assistant-ui/react";
2490
2487
  import { useThreadIsRunning as useThreadIsRunning4 } from "@assistant-ui/core/react";
2491
2488
  import { jsx as jsx54 } from "react/jsx-runtime";
2492
2489
  function UserMessageContainer() {
2493
2490
  const UserMessageBubble2 = useSlot("UserMessageBubble");
2494
2491
  const UserMessageActionBar2 = useSlot("UserMessageActionBar");
2495
2492
  const isRunning = useThreadIsRunning4();
2496
- const text = useAuiState10(
2493
+ const text = useAuiState9(
2497
2494
  (s) => s.message.content.filter((part) => part.type === "text").map((part) => part.text).join("\n")
2498
2495
  );
2499
2496
  return /* @__PURE__ */ jsx54(MessagePrimitive5.Root, { "data-role": "user", children: /* @__PURE__ */ jsx54(
@@ -2510,7 +2507,7 @@ function UserMessageContainer() {
2510
2507
  import { Fragment as Fragment3, jsx as jsx55, jsxs as jsxs17 } from "react/jsx-runtime";
2511
2508
  var isNewChatView = (s) => s.thread.messages.length === 0 && (!s.thread.isLoading || s.threads.isLoading);
2512
2509
  function ThreadMessage({ isEditing }) {
2513
- const role = useAuiState11((s) => s.message.role);
2510
+ const role = useAuiState10((s) => s.message.role);
2514
2511
  if (role === "user") {
2515
2512
  if (isEditing) {
2516
2513
  return /* @__PURE__ */ jsx55(UserEditComposerContainer, {});
@@ -2530,8 +2527,8 @@ function ThreadContainer({ composer }) {
2530
2527
  const WelcomeScreen2 = useSlot("WelcomeScreen");
2531
2528
  const MessageListSkeleton2 = useSlot("MessageListSkeleton");
2532
2529
  const ScrollToBottomButton2 = useSlot("ScrollToBottomButton");
2533
- const isEmpty = useAuiState11(isNewChatView);
2534
- const isLoading = useAuiState11((s) => s.thread.isLoading);
2530
+ const isEmpty = useAuiState10(isNewChatView);
2531
+ const isLoading = useAuiState10((s) => s.thread.isLoading);
2535
2532
  return /* @__PURE__ */ jsx55(ComposerBusyProvider, { children: /* @__PURE__ */ jsx55(ThreadPrimitive.Root, { asChild: true, children: /* @__PURE__ */ jsxs17(ThreadRootShell2, { children: [
2536
2533
  /* @__PURE__ */ jsx55(ThreadPrimitive.Viewport, { asChild: true, turnAnchor: "top", autoScroll: true, children: /* @__PURE__ */ jsxs17(ThreadViewportShell2, { isEmpty, children: [
2537
2534
  isEmpty && /* @__PURE__ */ jsx55(WelcomeScreen2, {}),
@@ -2554,7 +2551,7 @@ function ThreadContainer({ composer }) {
2554
2551
 
2555
2552
  // src/containers/ToolGroupContainer.tsx
2556
2553
  import { useState as useState12 } from "react";
2557
- import { useAuiState as useAuiState12 } from "@assistant-ui/react";
2554
+ import { useAuiState as useAuiState11 } from "@assistant-ui/react";
2558
2555
  import { jsx as jsx56 } from "react/jsx-runtime";
2559
2556
  function ToolGroupContainer({
2560
2557
  children,
@@ -2562,7 +2559,7 @@ function ToolGroupContainer({
2562
2559
  }) {
2563
2560
  const ToolGroupCard2 = useSlot("ToolGroupCard");
2564
2561
  const toolCallCount = group.indices.length;
2565
- const active = useAuiState12((s) => {
2562
+ const active = useAuiState11((s) => {
2566
2563
  if (s.message.status?.type !== "running") return false;
2567
2564
  const lastIndex = s.message.parts.length - 1;
2568
2565
  if (lastIndex < 0) return false;
@@ -2590,11 +2587,11 @@ function ToolGroupContainer({
2590
2587
 
2591
2588
  // src/containers/ComposerContainer.tsx
2592
2589
  import { useRef as useRef5 } from "react";
2593
- import { useAui as useAui2, useAuiState as useAuiState14 } from "@assistant-ui/react";
2590
+ import { useAui as useAui3, useAuiState as useAuiState13 } from "@assistant-ui/react";
2594
2591
  import { useTrueFoundryCancel } from "@truefoundry/assistant-ui-runtime";
2595
2592
 
2596
2593
  // src/hooks/useComposerPauseView.ts
2597
- import { useAuiState as useAuiState13 } from "@assistant-ui/react";
2594
+ import { useAuiState as useAuiState12 } from "@assistant-ui/react";
2598
2595
  import { useTrueFoundryToolResponses } from "@truefoundry/assistant-ui-runtime";
2599
2596
  function threadHasPendingMcpAuth(s) {
2600
2597
  const messages = s.thread.messages;
@@ -2604,7 +2601,7 @@ function threadHasPendingMcpAuth(s) {
2604
2601
  return last.metadata?.custom?.pendingMcpAuth === true;
2605
2602
  }
2606
2603
  function useComposerPauseView() {
2607
- const mcpPending = useAuiState13(threadHasPendingMcpAuth);
2604
+ const mcpPending = useAuiState12(threadHasPendingMcpAuth);
2608
2605
  const { pending: toolResponsesPending } = useTrueFoundryToolResponses();
2609
2606
  if (mcpPending) {
2610
2607
  return { kind: "mcp" };
@@ -2739,8 +2736,8 @@ function ComposerContainer({
2739
2736
  placeholder = "Ask anything... (Shift+Enter for new line)"
2740
2737
  }) {
2741
2738
  const ComposerShell2 = useSlot("ComposerShell");
2742
- const aui = useAui2();
2743
- const text = useAuiState14((s) => s.composer.text);
2739
+ const aui = useAui3();
2740
+ const text = useAuiState13((s) => s.composer.text);
2744
2741
  const { isBusy, send, resetBusy } = useComposerBusyState();
2745
2742
  const pauseView = useComposerPauseView();
2746
2743
  const cancel = useTrueFoundryCancel();
@@ -2791,7 +2788,7 @@ function ComposerContainer({
2791
2788
  }
2792
2789
 
2793
2790
  // src/containers/ThreadListContainer.tsx
2794
- import { useAui as useAui3, useAuiState as useAuiState15 } from "@assistant-ui/react";
2791
+ import { useAui as useAui4, useAuiState as useAuiState14 } from "@assistant-ui/react";
2795
2792
  import { useEffect as useEffect8, useRef as useRef6 } from "react";
2796
2793
  import { Fragment as Fragment5, jsx as jsx60, jsxs as jsxs19 } from "react/jsx-runtime";
2797
2794
  function ThreadListContainer() {
@@ -2800,13 +2797,13 @@ function ThreadListContainer() {
2800
2797
  const ThreadListRow2 = useSlot("ThreadListRow");
2801
2798
  const ThreadListRowSkeleton2 = useSlot("ThreadListRowSkeleton");
2802
2799
  const ThreadListEmptyState2 = useSlot("ThreadListEmptyState");
2803
- const aui = useAui3();
2804
- const isLoading = useAuiState15((s) => s.threads.isLoading);
2805
- const isLoadingMore = useAuiState15((s) => s.threads.isLoadingMore);
2806
- const hasMore = useAuiState15((s) => s.threads.hasMore);
2807
- const threadIds = useAuiState15((s) => s.threads.threadIds);
2808
- const threadItems = useAuiState15((s) => s.threads.threadItems);
2809
- const mainThreadId = useAuiState15((s) => s.threads.mainThreadId);
2800
+ const aui = useAui4();
2801
+ const isLoading = useAuiState14((s) => s.threads.isLoading);
2802
+ const isLoadingMore = useAuiState14((s) => s.threads.isLoadingMore);
2803
+ const hasMore = useAuiState14((s) => s.threads.hasMore);
2804
+ const threadIds = useAuiState14((s) => s.threads.threadIds);
2805
+ const threadItems = useAuiState14((s) => s.threads.threadItems);
2806
+ const mainThreadId = useAuiState14((s) => s.threads.mainThreadId);
2810
2807
  const sentinelRef = useRef6(null);
2811
2808
  useEffect8(() => {
2812
2809
  const node = sentinelRef.current;