@tangle-network/agent-app 0.45.36 → 0.45.37

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-TB7T7C3X.js";
5
5
  import "../chunk-FBVLEGEG.js";
6
6
  import "../chunk-5MZXWPFN.js";
7
7
  import "../chunk-GEYACSFW.js";
@@ -39,6 +39,7 @@ import {
39
39
 
40
40
  // src/web-react/index.tsx
41
41
  import { useEffect as useEffect11, useMemo as useMemo7, useRef as useRef10, useState as useState14, memo } from "react";
42
+ import { InlineToolItem } from "@tangle-network/ui/run";
42
43
 
43
44
  // src/web-react/smooth-text.ts
44
45
  import { useEffect, useRef, useState } from "react";
@@ -5227,6 +5228,23 @@ function ToolGlyph({ name, className }) {
5227
5228
  function toolOutcomeOf(call) {
5228
5229
  return call.result;
5229
5230
  }
5231
+ function toolCallFailed(call) {
5232
+ return call.status === "error" || toolOutcomeOf(call)?.ok === false;
5233
+ }
5234
+ function chatToolCallPart(call) {
5235
+ const failed = toolCallFailed(call);
5236
+ return {
5237
+ type: "tool",
5238
+ id: call.id,
5239
+ tool: call.name === "sandbox_run_command" ? "bash" : call.name,
5240
+ state: {
5241
+ status: call.status === "running" ? "running" : failed ? "error" : "completed",
5242
+ input: call.args,
5243
+ output: call.result,
5244
+ error: failed ? toolOutcomeOf(call)?.message ?? "Tool failed" : void 0
5245
+ }
5246
+ };
5247
+ }
5230
5248
  function blockKindOf(call) {
5231
5249
  if (call.name === "submit_proposal") return "proposal";
5232
5250
  if (call.name === "schedule_followup") return "followup";
@@ -5390,13 +5408,20 @@ function ProposalCard({
5390
5408
  function FollowupCard({ call }) {
5391
5409
  const a = call.args ?? {};
5392
5410
  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
- ] });
5411
+ 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: [
5412
+ /* @__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" }) }),
5413
+ /* @__PURE__ */ jsx13("span", { className: "shrink-0 whitespace-nowrap text-xs font-medium text-foreground", children: friendlyToolTitle(call) }),
5414
+ when && /* @__PURE__ */ jsx13("span", { className: "hidden min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground sm:inline", children: when })
5415
+ ] }) }) });
5416
+ }
5417
+ function toolRowTitle(call) {
5418
+ if (call.name === "sandbox_run_command") return "Ran command";
5419
+ return friendlyToolTitle(call);
5420
+ }
5421
+ function toolRowDescription(call) {
5422
+ if (call.name !== "sandbox_run_command") return void 0;
5423
+ const command = call.args?.command;
5424
+ return typeof command === "string" && command ? command : void 0;
5400
5425
  }
5401
5426
  function ToolCallCard({
5402
5427
  call,
@@ -5405,11 +5430,9 @@ function ToolCallCard({
5405
5430
  onOpenRun,
5406
5431
  renderers
5407
5432
  }) {
5408
- const [expanded, setExpanded] = useState14(false);
5409
5433
  const pending = call.status === "done" ? pendingApprovalOf(call) : null;
5410
5434
  const kind = blockKindOf(call);
5411
- const failed = call.status === "error" || toolOutcomeOf(call)?.ok === false;
5412
- const custom = renderers?.[call.name]?.(call, message);
5435
+ const failed = toolCallFailed(call);
5413
5436
  if (pending) {
5414
5437
  return /* @__PURE__ */ jsx13(
5415
5438
  ProposalCard,
@@ -5425,64 +5448,23 @@ function ToolCallCard({
5425
5448
  if (kind === "followup" && !failed) {
5426
5449
  return /* @__PURE__ */ jsx13(FollowupCard, { call });
5427
5450
  }
5428
- const isCommand = kind === "command";
5429
- return /* @__PURE__ */ jsxs11(
5430
- "div",
5451
+ const custom = renderers?.[call.name]?.(call, message);
5452
+ return /* @__PURE__ */ jsx13(
5453
+ InlineToolItem,
5431
5454
  {
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
- ]
5455
+ part: chatToolCallPart(call),
5456
+ title: toolRowTitle(call),
5457
+ description: toolRowDescription(call),
5458
+ renderToolDetail: () => custom ?? (call.name === "sandbox_run_command" ? /* @__PURE__ */ jsx13(ShellDetail, { call }) : /* @__PURE__ */ jsx13(DefaultToolDetail, { call })),
5459
+ actions: onOpenRun && call.name.startsWith("sandbox_") ? /* @__PURE__ */ jsx13(
5460
+ "button",
5461
+ {
5462
+ type: "button",
5463
+ onClick: () => onOpenRun(call, message),
5464
+ className: "rounded border border-border bg-card px-2 py-1 text-[11px] font-medium transition hover:bg-accent",
5465
+ children: "Open full transcript \u2192"
5466
+ }
5467
+ ) : void 0
5486
5468
  }
5487
5469
  );
5488
5470
  }
@@ -5512,7 +5494,7 @@ function SegmentText({
5512
5494
  }
5513
5495
  var COLLAPSE_TOOL_RUN_AT = 3;
5514
5496
  function isImportantTool(call) {
5515
- return call.status === "error" || call.status === "running" || toolOutcomeOf(call)?.ok === false || pendingApprovalOf(call) !== null;
5497
+ return call.status === "running" || toolCallFailed(call) || pendingApprovalOf(call) !== null;
5516
5498
  }
5517
5499
  function SegmentedBody({
5518
5500
  segments,
@@ -5566,20 +5548,17 @@ function SegmentedBody({
5566
5548
  messageClassName
5567
5549
  },
5568
5550
  `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}`
5551
+ ) : !streaming && g.calls.length >= COLLAPSE_TOOL_RUN_AT && !g.calls.some(isImportantTool) ? (
5552
+ // The fold is a quiet disclosure line, not a filled box — the
5553
+ // canonical rows inside it carry the row chrome.
5554
+ /* @__PURE__ */ jsxs11("details", { children: [
5555
+ /* @__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: [
5556
+ "Worked through ",
5557
+ g.calls.length,
5558
+ " steps"
5559
+ ] }),
5560
+ /* @__PURE__ */ jsx13("div", { className: "mt-1.5 flex flex-col gap-1.5", children: g.calls.map(renderToolCard) })
5561
+ ] }, `tools-${g.index}`)
5583
5562
  ) : /* @__PURE__ */ jsx13("div", { className: "flex flex-col gap-2", children: g.calls.map(renderToolCard) }, `tools-${g.index}`)
5584
5563
  ),
5585
5564
  leftoverToolCalls.map(renderToolCard),
@@ -5980,7 +5959,8 @@ export {
5980
5959
  RunDrillIn,
5981
5960
  pendingApprovalOf,
5982
5961
  ChatEmptyState,
5962
+ chatToolCallPart,
5983
5963
  useThinkingSeconds,
5984
5964
  ChatMessages
5985
5965
  };
5986
- //# sourceMappingURL=chunk-H3LYJIAQ.js.map
5966
+ //# sourceMappingURL=chunk-TB7T7C3X.js.map