@tangle-network/agent-app 0.43.16 → 0.43.18

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.
@@ -176,6 +176,27 @@ type ToolOutcome = {
176
176
  message: string;
177
177
  };
178
178
  };
179
+ /**
180
+ * The result of a CONFIRMED mutating tool, retained on the resolving `status`
181
+ * message so a host can render it prominently (e.g. a one-time API-key reveal).
182
+ *
183
+ * SECURITY: `output` may carry a one-time secret (e.g. a freshly minted API
184
+ * key). It lives ONLY in the in-memory transcript for the session — the message
185
+ * transcript is deliberately never cached (see `persistence.ts`) and is never
186
+ * sent back to the model (a turn request carries only the new user text, see
187
+ * {@link ChatRequest}). So the secret is shown once and is gone on reload,
188
+ * matching how a dedicated create-key page reveals a key exactly once. A host
189
+ * renderer must uphold the same contract: reveal-on-demand, never persist it.
190
+ */
191
+ interface ConfirmedResult {
192
+ /** The confirmed tool's name (e.g. "create_api_key"). */
193
+ name: string;
194
+ /** The tool's raw output. May contain a one-time secret — see the type doc. */
195
+ output: unknown;
196
+ /** The arguments the action was confirmed with, for a renderer that needs them
197
+ * (e.g. the key's name). */
198
+ args?: unknown;
199
+ }
179
200
  interface ChatMessage {
180
201
  id: string;
181
202
  role: ChatRole;
@@ -188,6 +209,11 @@ interface ChatMessage {
188
209
  args?: Record<string, unknown>;
189
210
  outcome?: ToolOutcome;
190
211
  };
212
+ /** Present only on a `status` message that resolved a confirmed mutating tool
213
+ * which returned a renderable result — carries that result so the transcript
214
+ * can render a host-supplied card (e.g. a one-time key reveal) next to the
215
+ * status line. See {@link ConfirmedResult} for the one-time-secret contract. */
216
+ result?: ConfirmedResult;
191
217
  }
192
218
  /** A mutating action the assistant proposed, awaiting the user's confirmation. */
193
219
  interface PendingProposal {
@@ -560,12 +586,17 @@ interface AssistantDockProps {
560
586
  renderMarkdown?: (content: string) => ReactNode;
561
587
  /** Per-tool custom detail renderers for expanded tool cards in the transcript. */
562
588
  toolRenderers?: ToolDetailRenderers;
589
+ /** Render a prominent card for a CONFIRMED tool's result (e.g. a one-time
590
+ * API-key reveal for `create_api_key`), shown inline after the action's status
591
+ * line. The result's `output` may carry a one-time secret — see
592
+ * {@link ConfirmedResult} for the never-persist/never-to-model contract. */
593
+ renderConfirmedResult?: (result: ConfirmedResult) => ReactNode;
563
594
  /** Swap the conversation rendering for a host-supplied renderer (see
564
595
  * {@link AssistantPanelProps.renderTranscript}); the dock chrome, composer,
565
596
  * transport, and proposal flow stay owned by the panel. */
566
597
  renderTranscript?: (view: AssistantTranscriptView) => ReactNode;
567
598
  }
568
- declare function AssistantDock({ userId, navigate, balanceUsd, formatMoney, renderGraph, onWorkflowMutation, onConnectRequirement, renderMarkdown, toolRenderers, renderTranscript, }: AssistantDockProps): react.JSX.Element;
599
+ declare function AssistantDock({ userId, navigate, balanceUsd, formatMoney, renderGraph, onWorkflowMutation, onConnectRequirement, renderMarkdown, toolRenderers, renderConfirmedResult, renderTranscript, }: AssistantDockProps): react.JSX.Element;
569
600
 
570
601
  interface AssistantPanelProps {
571
602
  chat: AssistantChat;
@@ -585,6 +616,10 @@ interface AssistantPanelProps {
585
616
  renderMarkdown?: (content: string) => ReactNode;
586
617
  /** Per-tool custom detail renderers for expanded tool cards in the transcript. */
587
618
  toolRenderers?: ToolDetailRenderers;
619
+ /** Render a prominent card for a CONFIRMED tool's result (e.g. a one-time
620
+ * API-key reveal for `create_api_key`), shown inline after the action's status
621
+ * line. Ignored when a host swaps the whole transcript via `renderTranscript`. */
622
+ renderConfirmedResult?: (result: ConfirmedResult) => ReactNode;
588
623
  /** Swap ONLY the conversation rendering for a host-supplied renderer (e.g. a
589
624
  * different chat-message component), while the panel keeps owning the header,
590
625
  * composer, model picker, history, transport, and proposal orchestration.
@@ -593,7 +628,7 @@ interface AssistantPanelProps {
593
628
  * conversation. */
594
629
  renderTranscript?: (view: AssistantTranscriptView) => ReactNode;
595
630
  }
596
- declare function AssistantPanel({ chat, userId, onClose, navigate, balanceUsd, formatMoney, renderGraph, renderMarkdown, toolRenderers, renderTranscript, }: AssistantPanelProps): react.JSX.Element;
631
+ declare function AssistantPanel({ chat, userId, onClose, navigate, balanceUsd, formatMoney, renderGraph, renderMarkdown, toolRenderers, renderConfirmedResult, renderTranscript, }: AssistantPanelProps): react.JSX.Element;
597
632
 
598
633
  /**
599
634
  * True while a turn is streaming but the model hasn't emitted its first answer
@@ -609,6 +644,10 @@ interface AdaptedTranscript {
609
644
  /** The current/most-recent turn's assistant message — where the turn cost line
610
645
  * renders (it carries the turn's metrics), or null when there is none. */
611
646
  metricsHostId: string | null;
647
+ /** Confirmed-tool results to render under their (system) message, keyed by that
648
+ * message's id — carried from a `status` message's retained `result` so a host
649
+ * card (e.g. a one-time API-key reveal) renders inline right after the action. */
650
+ confirmedResults: Map<string, ConfirmedResult>;
612
651
  }
613
652
  /**
614
653
  * Fold the transcript view into web-react `ChatUiMessage[]`: each user message is
@@ -627,6 +666,12 @@ interface AssistantTranscriptProps {
627
666
  renderMarkdown?: (content: string) => ReactNode;
628
667
  /** Per-tool custom detail renderers for expanded tool cards. */
629
668
  toolRenderers?: ToolDetailRenderers;
669
+ /** Render a prominent card for a CONFIRMED tool's result, inline after its
670
+ * status line (e.g. a one-time API-key reveal for `create_api_key`). Return
671
+ * null to fall back to just the status line. Unlike `toolRenderers` (collapsed
672
+ * detail for a read-only tool chip), this is shown expanded, so a one-time
673
+ * secret is visible without a click. See {@link ConfirmedResult}. */
674
+ renderConfirmedResult?: (result: ConfirmedResult) => ReactNode;
630
675
  /** Zero-state shown for a fresh, non-streaming thread. */
631
676
  emptyState?: ReactNode;
632
677
  }
@@ -636,7 +681,7 @@ interface AssistantTranscriptProps {
636
681
  * after the proposing turn through `renderExtras`; the settled turn cost renders
637
682
  * once under its assistant bubble.
638
683
  */
639
- declare function AssistantTranscript({ view, renderMarkdown, toolRenderers, emptyState, }: AssistantTranscriptProps): react.JSX.Element;
684
+ declare function AssistantTranscript({ view, renderMarkdown, toolRenderers, renderConfirmedResult, emptyState, }: AssistantTranscriptProps): react.JSX.Element;
640
685
 
641
686
  interface ProposalCardProps {
642
687
  proposal: PendingProposal;
@@ -674,4 +719,4 @@ declare function AssistantLauncherProvider({ children, }: {
674
719
  }): react.JSX.Element;
675
720
  declare function useAssistantLauncher(): AssistantLauncher;
676
721
 
677
- export { type AssistantChat, type AssistantClient, type AssistantClientConfig, AssistantClientInputError, AssistantClientProvider, type AssistantDeliveryMode, AssistantDock, type AssistantDockProps, type AssistantLauncher, AssistantLauncherProvider, type AssistantModelOption, type AssistantModels, type AssistantModelsResult, AssistantPanel, type AssistantPanelProps, type AssistantSendOptions, type AssistantStreamEvent, type AssistantThreadSummary, type AssistantThreads, AssistantTranscript, type AssistantTranscriptProps, type AssistantTranscriptView, type ChatMessage, type ChatRequest, type ChatRole, type ConfirmResult, type ConnectRequirementResult, type ConnectionRequirement, type ConnectionRequirementKind, type DeltaEventData, type DoneEventData, type ErrorEventData, type PendingProposal, ProposalCard, type ProposalCardProps, type ReasoningEventData, type ThreadEventData, type ThreadHistoryResult, type ToolActivityStatus, type ToolCallEventData, type ToolOutcome, type ToolProposalEventData, type ToolResultEventData, type UsageEventData, type UsageInfo, type UseAssistantChatOptions, adaptTranscript, assistantIsThinking, createAssistantClient, useAssistantChat, useAssistantClient, useAssistantLauncher, useAssistantModels, useAssistantThreads };
722
+ export { type AssistantChat, type AssistantClient, type AssistantClientConfig, AssistantClientInputError, AssistantClientProvider, type AssistantDeliveryMode, AssistantDock, type AssistantDockProps, type AssistantLauncher, AssistantLauncherProvider, type AssistantModelOption, type AssistantModels, type AssistantModelsResult, AssistantPanel, type AssistantPanelProps, type AssistantSendOptions, type AssistantStreamEvent, type AssistantThreadSummary, type AssistantThreads, AssistantTranscript, type AssistantTranscriptProps, type AssistantTranscriptView, type ChatMessage, type ChatRequest, type ChatRole, type ConfirmResult, type ConfirmedResult, type ConnectRequirementResult, type ConnectionRequirement, type ConnectionRequirementKind, type DeltaEventData, type DoneEventData, type ErrorEventData, type PendingProposal, ProposalCard, type ProposalCardProps, type ReasoningEventData, type ThreadEventData, type ThreadHistoryResult, type ToolActivityStatus, type ToolCallEventData, type ToolOutcome, type ToolProposalEventData, type ToolResultEventData, type UsageEventData, type UsageInfo, type UseAssistantChatOptions, adaptTranscript, assistantIsThinking, createAssistantClient, useAssistantChat, useAssistantClient, useAssistantLauncher, useAssistantModels, useAssistantThreads };
@@ -733,7 +733,7 @@ function describeOutcome(name, output) {
733
733
  return wf.enabled ? "Workflow enabled." : "Workflow disabled.";
734
734
  }
735
735
  case "create_api_key":
736
- return o.prefix ? `Created API key (${str(o.prefix)}\u2026). Copy it from the API Keys page.` : "API key created.";
736
+ return o.prefix ? `Created API key (${str(o.prefix)}\u2026).` : "API key created.";
737
737
  case "revoke_api_key":
738
738
  return "API key revoked.";
739
739
  case "invoke_integration":
@@ -1345,10 +1345,19 @@ function useAssistantChat(userId, options) {
1345
1345
  return;
1346
1346
  }
1347
1347
  const { statusText, error } = resolveConfirmation(proposal.name, result);
1348
+ const status = statusText ? statusMessage(statusText) : null;
1349
+ if (status && result.ok && !error) {
1350
+ const confirmed = {
1351
+ name: proposal.name,
1352
+ output: result.output,
1353
+ args: proposal.args
1354
+ };
1355
+ status.result = confirmed;
1356
+ }
1348
1357
  dispatch({
1349
1358
  type: "proposal_resolved",
1350
1359
  callId: proposal.callId,
1351
- status: statusText ? statusMessage(statusText) : null,
1360
+ status,
1352
1361
  error
1353
1362
  });
1354
1363
  if (!error && WORKFLOW_MUTATING_TOOLS.has(proposal.name)) {
@@ -1994,6 +2003,7 @@ function adaptToolResult(outcome) {
1994
2003
  }
1995
2004
  function adaptTranscript(view) {
1996
2005
  const messages = [];
2006
+ const confirmedResults = /* @__PURE__ */ new Map();
1997
2007
  let turn = null;
1998
2008
  let currentTurnAssistant = null;
1999
2009
  const openTurn = (id) => {
@@ -2037,6 +2047,7 @@ ${text}` : text;
2037
2047
  });
2038
2048
  } else {
2039
2049
  messages.push({ id: msg.id, role: "system", content: msg.text });
2050
+ if (msg.result) confirmedResults.set(msg.id, msg.result);
2040
2051
  turn = null;
2041
2052
  }
2042
2053
  }
@@ -2065,7 +2076,8 @@ ${text}` : text;
2065
2076
  return {
2066
2077
  messages: messages.filter((m) => !isEmptyShell(m)),
2067
2078
  proposalHostId,
2068
- metricsHostId: currentTurnAssistant && !isEmptyShell(currentTurnAssistant) ? currentTurnAssistant.id : null
2079
+ metricsHostId: currentTurnAssistant && !isEmptyShell(currentTurnAssistant) ? currentTurnAssistant.id : null,
2080
+ confirmedResults
2069
2081
  };
2070
2082
  }
2071
2083
  function formatTurnCost(costUsd) {
@@ -2081,9 +2093,10 @@ function AssistantTranscript({
2081
2093
  view,
2082
2094
  renderMarkdown,
2083
2095
  toolRenderers,
2096
+ renderConfirmedResult,
2084
2097
  emptyState
2085
2098
  }) {
2086
- const { messages, proposalHostId, metricsHostId } = useMemo2(
2099
+ const { messages, proposalHostId, metricsHostId, confirmedResults } = useMemo2(
2087
2100
  () => adaptTranscript(view),
2088
2101
  [view]
2089
2102
  );
@@ -2112,12 +2125,16 @@ function AssistantTranscript({
2112
2125
  },
2113
2126
  proposal.callId
2114
2127
  )) }) : null;
2128
+ const confirmed = confirmedResults.get(message.id);
2129
+ const confirmedNode = confirmed && renderConfirmedResult ? renderConfirmedResult(confirmed) : null;
2130
+ const confirmedCard = confirmedNode ? /* @__PURE__ */ jsx4("div", { className: "mt-3", children: confirmedNode }) : null;
2115
2131
  const cost = message.id === metricsHostId && !view.isStreaming && view.usage?.costUsd != null && !view.usage.replayed ? /* @__PURE__ */ jsxs3("p", { className: "mt-1 text-[11px] text-muted-foreground", children: [
2116
2132
  formatTurnCost(view.usage.costUsd),
2117
2133
  " this turn"
2118
2134
  ] }) : null;
2119
- if (!proposals && !cost) return null;
2135
+ if (!proposals && !cost && !confirmedCard) return null;
2120
2136
  return /* @__PURE__ */ jsxs3(Fragment2, { children: [
2137
+ confirmedCard,
2121
2138
  proposals,
2122
2139
  cost
2123
2140
  ] });
@@ -2320,6 +2337,7 @@ function AssistantPanel({
2320
2337
  renderGraph,
2321
2338
  renderMarkdown,
2322
2339
  toolRenderers,
2340
+ renderConfirmedResult,
2323
2341
  renderTranscript
2324
2342
  }) {
2325
2343
  const models = useAssistantModels();
@@ -2560,6 +2578,7 @@ function AssistantPanel({
2560
2578
  view: transcriptView,
2561
2579
  renderMarkdown,
2562
2580
  toolRenderers,
2581
+ renderConfirmedResult,
2563
2582
  emptyState: /* @__PURE__ */ jsx5("p", { className: "px-4 py-8 text-center text-muted-foreground text-sm", children: EMPTY_STATE })
2564
2583
  }
2565
2584
  ) })
@@ -2789,6 +2808,7 @@ function AssistantDock({
2789
2808
  onConnectRequirement,
2790
2809
  renderMarkdown,
2791
2810
  toolRenderers,
2811
+ renderConfirmedResult,
2792
2812
  renderTranscript
2793
2813
  }) {
2794
2814
  const { open, openAssistant, closeAssistant } = useAssistantLauncher();
@@ -2899,6 +2919,7 @@ function AssistantDock({
2899
2919
  renderGraph,
2900
2920
  renderMarkdown,
2901
2921
  toolRenderers,
2922
+ renderConfirmedResult,
2902
2923
  renderTranscript
2903
2924
  },
2904
2925
  userId ?? "anon"