@tangle-network/agent-app 0.45.36 → 0.45.38

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.
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { ToolDetailRenderers, ComposerFile, ChatUiMessage } from '../web-react/index.js';
4
+ import '@tangle-network/ui/types';
4
5
  import '../contract-OxG_jVMx.js';
5
6
  import '@tangle-network/agent-interface';
6
7
  import '../plans/index.js';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ChatComposer,
3
3
  ChatMessages
4
- } from "../chunk-H3LYJIAQ.js";
4
+ } from "../chunk-HNVAASAO.js";
5
5
  import "../chunk-FBVLEGEG.js";
6
6
  import "../chunk-5MZXWPFN.js";
7
7
  import "../chunk-GEYACSFW.js";
@@ -9,7 +9,9 @@ import {
9
9
  ChevronDown,
10
10
  OVERLAY_SHADOW,
11
11
  POPOVER_OPTION_FOCUS,
12
- usePending
12
+ PopoverSurface,
13
+ usePending,
14
+ usePopover
13
15
  } from "./chunk-3AXSERRK.js";
14
16
  import {
15
17
  UNTITLED_SESSION_LABEL,
@@ -39,6 +41,7 @@ import {
39
41
 
40
42
  // src/web-react/index.tsx
41
43
  import { useEffect as useEffect11, useMemo as useMemo7, useRef as useRef10, useState as useState14, memo } from "react";
44
+ import { InlineToolItem } from "@tangle-network/ui/run";
42
45
 
43
46
  // src/web-react/smooth-text.ts
44
47
  import { useEffect, useRef, useState } from "react";
@@ -3119,6 +3122,7 @@ function SeatPaywall({
3119
3122
  import {
3120
3123
  useCallback as useCallback8,
3121
3124
  useEffect as useEffect9,
3125
+ useId as useId2,
3122
3126
  useMemo as useMemo5,
3123
3127
  useRef as useRef8,
3124
3128
  useState as useState12
@@ -3801,6 +3805,8 @@ function SessionRow({
3801
3805
  onSelectedChange
3802
3806
  }) {
3803
3807
  const [menuOpen, setMenuOpen] = useState12(false);
3808
+ const panelId = useId2();
3809
+ const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(menuOpen, setMenuOpen);
3804
3810
  const extras = extraActions?.(session) ?? [];
3805
3811
  const hasMenu = Boolean(onRename) || Boolean(onDelete) || extras.length > 0;
3806
3812
  const showUnread = Boolean(session.unread) && !responding;
@@ -3828,60 +3834,72 @@ function SessionRow({
3828
3834
  )
3829
3835
  ] }),
3830
3836
  /* @__PURE__ */ jsx11("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: timestamp }),
3831
- hasMenu && /* @__PURE__ */ jsxs9("div", { className: "relative shrink-0", children: [
3837
+ hasMenu && /* @__PURE__ */ jsxs9("div", { ref: containerRef, className: "relative shrink-0", children: [
3832
3838
  /* @__PURE__ */ jsx11(
3833
3839
  "button",
3834
3840
  {
3835
3841
  type: "button",
3842
+ ...triggerProps,
3836
3843
  "aria-label": "Session actions",
3837
- "aria-expanded": menuOpen,
3844
+ "aria-controls": menuOpen ? panelId : void 0,
3838
3845
  onClick: () => setMenuOpen((open) => !open),
3839
3846
  className: "flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100 aria-expanded:opacity-100",
3840
3847
  children: /* @__PURE__ */ jsx11("span", { "aria-hidden": true, className: "text-base leading-none", children: "\u22EF" })
3841
3848
  }
3842
3849
  ),
3843
- menuOpen && /* @__PURE__ */ jsxs9(Fragment5, { children: [
3844
- /* @__PURE__ */ jsx11("div", { className: "fixed inset-0 z-20", onClick: () => setMenuOpen(false), "aria-hidden": true }),
3845
- /* @__PURE__ */ jsxs9("div", { className: `absolute right-0 z-30 mt-1 w-36 overflow-hidden rounded-md border border-border bg-popover py-1 ${OVERLAY_SHADOW}`, children: [
3846
- onRename && /* @__PURE__ */ jsx11(
3847
- "button",
3848
- {
3849
- type: "button",
3850
- onClick: () => {
3851
- setMenuOpen(false);
3852
- onRename(session);
3853
- },
3854
- className: "block w-full px-3 py-1.5 text-left text-xs text-foreground transition hover:bg-accent",
3855
- children: renameLabel
3856
- }
3857
- ),
3858
- extras.map((action) => /* @__PURE__ */ jsx11(
3859
- "button",
3860
- {
3861
- type: "button",
3862
- onClick: () => {
3863
- setMenuOpen(false);
3864
- action.onSelect();
3865
- },
3866
- className: `block w-full px-3 py-1.5 text-left text-xs transition ${action.destructive ? "text-destructive hover:bg-destructive/10" : "text-foreground hover:bg-accent"}`,
3867
- children: action.label
3868
- },
3869
- action.id
3870
- )),
3871
- onDelete && /* @__PURE__ */ jsx11(
3872
- "button",
3873
- {
3874
- type: "button",
3875
- onClick: () => {
3876
- setMenuOpen(false);
3877
- onDelete(session);
3850
+ /* @__PURE__ */ jsxs9(
3851
+ PopoverSurface,
3852
+ {
3853
+ open: menuOpen,
3854
+ id: panelId,
3855
+ role: "menu",
3856
+ triggerRef,
3857
+ panelRef,
3858
+ className: `w-36 overflow-hidden rounded-md border border-border bg-popover py-1 ${OVERLAY_SHADOW}`,
3859
+ children: [
3860
+ onRename && /* @__PURE__ */ jsx11(
3861
+ "button",
3862
+ {
3863
+ type: "button",
3864
+ role: "menuitem",
3865
+ onClick: () => {
3866
+ setMenuOpen(false);
3867
+ onRename(session);
3868
+ },
3869
+ className: "block w-full px-3 py-1.5 text-left text-xs text-foreground transition hover:bg-accent",
3870
+ children: renameLabel
3871
+ }
3872
+ ),
3873
+ extras.map((action) => /* @__PURE__ */ jsx11(
3874
+ "button",
3875
+ {
3876
+ type: "button",
3877
+ role: "menuitem",
3878
+ onClick: () => {
3879
+ setMenuOpen(false);
3880
+ action.onSelect();
3881
+ },
3882
+ className: `block w-full px-3 py-1.5 text-left text-xs transition ${action.destructive ? "text-destructive hover:bg-destructive/10" : "text-foreground hover:bg-accent"}`,
3883
+ children: action.label
3878
3884
  },
3879
- className: "block w-full px-3 py-1.5 text-left text-xs text-destructive transition hover:bg-destructive/10",
3880
- children: deleteLabel
3881
- }
3882
- )
3883
- ] })
3884
- ] })
3885
+ action.id
3886
+ )),
3887
+ onDelete && /* @__PURE__ */ jsx11(
3888
+ "button",
3889
+ {
3890
+ type: "button",
3891
+ role: "menuitem",
3892
+ onClick: () => {
3893
+ setMenuOpen(false);
3894
+ onDelete(session);
3895
+ },
3896
+ className: "block w-full px-3 py-1.5 text-left text-xs text-destructive transition hover:bg-destructive/10",
3897
+ children: deleteLabel
3898
+ }
3899
+ )
3900
+ ]
3901
+ }
3902
+ )
3885
3903
  ] })
3886
3904
  ] });
3887
3905
  }
@@ -3892,7 +3910,7 @@ import {
3892
3910
  isValidElement,
3893
3911
  useCallback as useCallback9,
3894
3912
  useEffect as useEffect10,
3895
- useId as useId2,
3913
+ useId as useId3,
3896
3914
  useMemo as useMemo6,
3897
3915
  useRef as useRef9,
3898
3916
  useState as useState13
@@ -4279,7 +4297,7 @@ function RecordGrid({
4279
4297
  loadingRowCount = 3,
4280
4298
  className
4281
4299
  }) {
4282
- const fieldPrefix = useId2();
4300
+ const fieldPrefix = useId3();
4283
4301
  const [overlay, setOverlay] = useState13(EMPTY_RECORD_GRID_OVERLAY);
4284
4302
  const [editing, setEditingState] = useState13(null);
4285
4303
  const [cellErrors, setCellErrors] = useState13({});
@@ -4882,13 +4900,20 @@ function CellEditor({ column, rowLabel, text, invalid, describedBy, onText, onCo
4882
4900
  }
4883
4901
  function SourceMarker({ panelId, columnHeader, rowLabel, source, open, onToggle }) {
4884
4902
  const basis = source.basis ?? "asserted";
4885
- return /* @__PURE__ */ jsxs10("span", { className: "relative inline-flex", children: [
4903
+ const setOpen = useCallback9(
4904
+ (next) => {
4905
+ if (!next) onToggle();
4906
+ },
4907
+ [onToggle]
4908
+ );
4909
+ const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen);
4910
+ return /* @__PURE__ */ jsxs10("span", { ref: containerRef, className: "relative inline-flex", children: [
4886
4911
  /* @__PURE__ */ jsx12(
4887
4912
  "button",
4888
4913
  {
4889
4914
  type: "button",
4915
+ ...triggerProps,
4890
4916
  "aria-label": `Source for ${columnHeader}, ${rowLabel}`,
4891
- "aria-expanded": open,
4892
4917
  "aria-controls": open ? panelId : void 0,
4893
4918
  title: BASIS_TITLES[basis],
4894
4919
  onClick: (event) => {
@@ -4911,12 +4936,15 @@ function SourceMarker({ panelId, columnHeader, rowLabel, source, open, onToggle
4911
4936
  )
4912
4937
  }
4913
4938
  ),
4914
- open && /* @__PURE__ */ jsxs10(
4915
- "span",
4939
+ /* @__PURE__ */ jsxs10(
4940
+ PopoverSurface,
4916
4941
  {
4942
+ open,
4917
4943
  id: panelId,
4918
4944
  role: "note",
4919
- className: `absolute left-0 top-5 z-10 w-64 rounded-lg border border-border bg-popover p-3 text-left ${OVERLAY_SHADOW}`,
4945
+ triggerRef,
4946
+ panelRef,
4947
+ className: `w-64 rounded-lg border border-border bg-popover p-3 text-left ${OVERLAY_SHADOW}`,
4920
4948
  children: [
4921
4949
  source.quote && /* @__PURE__ */ jsxs10("span", { className: "block border-l-2 border-primary/50 pl-2 text-xs italic leading-snug text-foreground", children: [
4922
4950
  "\u201C",
@@ -5227,6 +5255,23 @@ function ToolGlyph({ name, className }) {
5227
5255
  function toolOutcomeOf(call) {
5228
5256
  return call.result;
5229
5257
  }
5258
+ function toolCallFailed(call) {
5259
+ return call.status === "error" || toolOutcomeOf(call)?.ok === false;
5260
+ }
5261
+ function chatToolCallPart(call) {
5262
+ const failed = toolCallFailed(call);
5263
+ return {
5264
+ type: "tool",
5265
+ id: call.id,
5266
+ tool: call.name === "sandbox_run_command" ? "bash" : call.name,
5267
+ state: {
5268
+ status: call.status === "running" ? "running" : failed ? "error" : "completed",
5269
+ input: call.args,
5270
+ output: call.result,
5271
+ error: failed ? toolOutcomeOf(call)?.message ?? "Tool failed" : void 0
5272
+ }
5273
+ };
5274
+ }
5230
5275
  function blockKindOf(call) {
5231
5276
  if (call.name === "submit_proposal") return "proposal";
5232
5277
  if (call.name === "schedule_followup") return "followup";
@@ -5390,13 +5435,20 @@ function ProposalCard({
5390
5435
  function FollowupCard({ call }) {
5391
5436
  const a = call.args ?? {};
5392
5437
  const when = typeof a.when === "string" ? a.when : typeof a.at === "string" ? a.at : typeof a.schedule === "string" ? a.schedule : null;
5393
- return /* @__PURE__ */ jsxs11("div", { className: "w-fit min-w-[260px] max-w-full rounded-lg border border-border/60 border-l-2 border-l-primary/60 bg-secondary px-3 py-2 text-sm", children: [
5394
- /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
5395
- /* @__PURE__ */ jsx13(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-primary/80" }),
5396
- /* @__PURE__ */ jsx13("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", children: friendlyToolTitle(call) })
5397
- ] }),
5398
- when && /* @__PURE__ */ jsx13("p", { className: "mt-0.5 pl-[22px] text-[12px] text-muted-foreground", children: when })
5399
- ] });
5438
+ return /* @__PURE__ */ jsx13("div", { className: "flex items-start gap-2", children: /* @__PURE__ */ jsx13("div", { className: "min-w-0 flex-1 overflow-hidden rounded-[var(--radius-lg)] border border-[var(--border-subtle)] bg-[var(--md3-surface-container)]", children: /* @__PURE__ */ jsxs11("div", { className: "flex w-full items-center gap-2.5 px-3 py-2", children: [
5439
+ /* @__PURE__ */ jsx13("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--radius-sm)] border border-border bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx13(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5" }) }),
5440
+ /* @__PURE__ */ jsx13("span", { className: "shrink-0 whitespace-nowrap text-xs font-medium text-foreground", children: friendlyToolTitle(call) }),
5441
+ when && /* @__PURE__ */ jsx13("span", { className: "hidden min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground sm:inline", children: when })
5442
+ ] }) }) });
5443
+ }
5444
+ function toolRowTitle(call) {
5445
+ if (call.name === "sandbox_run_command") return "Ran command";
5446
+ return friendlyToolTitle(call);
5447
+ }
5448
+ function toolRowDescription(call) {
5449
+ if (call.name !== "sandbox_run_command") return void 0;
5450
+ const command = call.args?.command;
5451
+ return typeof command === "string" && command ? command : void 0;
5400
5452
  }
5401
5453
  function ToolCallCard({
5402
5454
  call,
@@ -5405,11 +5457,9 @@ function ToolCallCard({
5405
5457
  onOpenRun,
5406
5458
  renderers
5407
5459
  }) {
5408
- const [expanded, setExpanded] = useState14(false);
5409
5460
  const pending = call.status === "done" ? pendingApprovalOf(call) : null;
5410
5461
  const kind = blockKindOf(call);
5411
- const failed = call.status === "error" || toolOutcomeOf(call)?.ok === false;
5412
- const custom = renderers?.[call.name]?.(call, message);
5462
+ const failed = toolCallFailed(call);
5413
5463
  if (pending) {
5414
5464
  return /* @__PURE__ */ jsx13(
5415
5465
  ProposalCard,
@@ -5425,64 +5475,23 @@ function ToolCallCard({
5425
5475
  if (kind === "followup" && !failed) {
5426
5476
  return /* @__PURE__ */ jsx13(FollowupCard, { call });
5427
5477
  }
5428
- const isCommand = kind === "command";
5429
- return /* @__PURE__ */ jsxs11(
5430
- "div",
5478
+ const custom = renderers?.[call.name]?.(call, message);
5479
+ return /* @__PURE__ */ jsx13(
5480
+ InlineToolItem,
5431
5481
  {
5432
- className: `w-fit min-w-[280px] max-w-full rounded-lg border text-xs transition ${failed ? "border-destructive/40 bg-destructive/5" : "border-border/60 bg-secondary"}`,
5433
- children: [
5434
- /* @__PURE__ */ jsxs11("div", { className: "flex w-full items-center gap-2 px-3 py-2", children: [
5435
- /* @__PURE__ */ jsxs11(
5436
- "button",
5437
- {
5438
- type: "button",
5439
- onClick: () => setExpanded((v) => !v),
5440
- "aria-expanded": expanded,
5441
- className: "flex min-w-0 flex-1 items-center gap-2 rounded text-left",
5442
- children: [
5443
- /* @__PURE__ */ jsx13(
5444
- "span",
5445
- {
5446
- className: `h-2 w-2 shrink-0 rounded-full ${call.status === "running" ? "animate-pulse bg-warning" : failed ? "bg-destructive" : "bg-success"}`
5447
- }
5448
- ),
5449
- /* @__PURE__ */ jsx13(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
5450
- /* @__PURE__ */ jsx13(
5451
- "span",
5452
- {
5453
- className: `min-w-0 flex-1 truncate ${isCommand ? "font-mono text-[12px] tracking-tight text-foreground/90" : "font-medium"}`,
5454
- children: friendlyToolTitle(call)
5455
- }
5456
- )
5457
- ]
5458
- }
5459
- ),
5460
- /* @__PURE__ */ jsx13("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: call.status === "running" ? "running\u2026" : failed ? "failed" : "done" }),
5461
- /* @__PURE__ */ jsx13(
5462
- "button",
5463
- {
5464
- type: "button",
5465
- onClick: () => setExpanded((v) => !v),
5466
- "aria-label": expanded ? "Collapse details" : "Expand details",
5467
- "aria-expanded": expanded,
5468
- className: "shrink-0 rounded p-0.5",
5469
- children: /* @__PURE__ */ jsx13(ChevronDown, { className: `h-3 w-3 text-muted-foreground transition-transform ${expanded ? "rotate-180" : ""}` })
5470
- }
5471
- )
5472
- ] }),
5473
- expanded && /* @__PURE__ */ jsxs11("div", { className: "border-t border-border/40 px-3 py-2.5", children: [
5474
- custom ?? (call.name === "sandbox_run_command" ? /* @__PURE__ */ jsx13(ShellDetail, { call }) : /* @__PURE__ */ jsx13(DefaultToolDetail, { call })),
5475
- onOpenRun && call.name.startsWith("sandbox_") && /* @__PURE__ */ jsx13(
5476
- "button",
5477
- {
5478
- type: "button",
5479
- onClick: () => onOpenRun(call, message),
5480
- className: "mt-2 rounded border border-border bg-card px-2 py-1 text-[11px] font-medium transition hover:bg-accent",
5481
- children: "Open full transcript \u2192"
5482
- }
5483
- )
5484
- ] })
5485
- ]
5482
+ part: chatToolCallPart(call),
5483
+ title: toolRowTitle(call),
5484
+ description: toolRowDescription(call),
5485
+ renderToolDetail: () => custom ?? (call.name === "sandbox_run_command" ? /* @__PURE__ */ jsx13(ShellDetail, { call }) : /* @__PURE__ */ jsx13(DefaultToolDetail, { call })),
5486
+ actions: onOpenRun && call.name.startsWith("sandbox_") ? /* @__PURE__ */ jsx13(
5487
+ "button",
5488
+ {
5489
+ type: "button",
5490
+ onClick: () => onOpenRun(call, message),
5491
+ className: "rounded border border-border bg-card px-2 py-1 text-[11px] font-medium transition hover:bg-accent",
5492
+ children: "Open full transcript \u2192"
5493
+ }
5494
+ ) : void 0
5486
5495
  }
5487
5496
  );
5488
5497
  }
@@ -5512,7 +5521,7 @@ function SegmentText({
5512
5521
  }
5513
5522
  var COLLAPSE_TOOL_RUN_AT = 3;
5514
5523
  function isImportantTool(call) {
5515
- return call.status === "error" || call.status === "running" || toolOutcomeOf(call)?.ok === false || pendingApprovalOf(call) !== null;
5524
+ return call.status === "running" || toolCallFailed(call) || pendingApprovalOf(call) !== null;
5516
5525
  }
5517
5526
  function SegmentedBody({
5518
5527
  segments,
@@ -5566,20 +5575,17 @@ function SegmentedBody({
5566
5575
  messageClassName
5567
5576
  },
5568
5577
  `text-${g.index}`
5569
- ) : !streaming && g.calls.length >= COLLAPSE_TOOL_RUN_AT && !g.calls.some(isImportantTool) ? /* @__PURE__ */ jsxs11(
5570
- "details",
5571
- {
5572
- className: "rounded-lg border-l-2 border-border/70 bg-secondary px-3 py-2",
5573
- children: [
5574
- /* @__PURE__ */ jsxs11("summary", { className: "cursor-pointer select-none text-xs font-medium text-muted-foreground", children: [
5575
- "Worked through ",
5576
- g.calls.length,
5577
- " steps"
5578
- ] }),
5579
- /* @__PURE__ */ jsx13("div", { className: "mt-2 flex flex-col gap-2", children: g.calls.map(renderToolCard) })
5580
- ]
5581
- },
5582
- `tools-${g.index}`
5578
+ ) : !streaming && g.calls.length >= COLLAPSE_TOOL_RUN_AT && !g.calls.some(isImportantTool) ? (
5579
+ // The fold is a quiet disclosure line, not a filled box — the
5580
+ // canonical rows inside it carry the row chrome.
5581
+ /* @__PURE__ */ jsxs11("details", { children: [
5582
+ /* @__PURE__ */ jsxs11("summary", { className: "cursor-pointer select-none rounded-md px-1 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground", children: [
5583
+ "Worked through ",
5584
+ g.calls.length,
5585
+ " steps"
5586
+ ] }),
5587
+ /* @__PURE__ */ jsx13("div", { className: "mt-1.5 flex flex-col gap-1.5", children: g.calls.map(renderToolCard) })
5588
+ ] }, `tools-${g.index}`)
5583
5589
  ) : /* @__PURE__ */ jsx13("div", { className: "flex flex-col gap-2", children: g.calls.map(renderToolCard) }, `tools-${g.index}`)
5584
5590
  ),
5585
5591
  leftoverToolCalls.map(renderToolCard),
@@ -5980,7 +5986,8 @@ export {
5980
5986
  RunDrillIn,
5981
5987
  pendingApprovalOf,
5982
5988
  ChatEmptyState,
5989
+ chatToolCallPart,
5983
5990
  useThinkingSeconds,
5984
5991
  ChatMessages
5985
5992
  };
5986
- //# sourceMappingURL=chunk-H3LYJIAQ.js.map
5993
+ //# sourceMappingURL=chunk-HNVAASAO.js.map