@tangle-network/agent-app 0.60.29 → 0.60.31

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,6 @@
1
1
  import {
2
2
  chatToolCallPart
3
- } from "../chunk-KIJ64S54.js";
3
+ } from "../chunk-H6MKILMQ.js";
4
4
  import "../chunk-FAU5FIFD.js";
5
5
  import "../chunk-3HUFJ5LO.js";
6
6
  import "../chunk-FBVLEGEG.js";
@@ -312,7 +312,7 @@ var BADGE_VARIANT_CLASSES = {
312
312
  destructive: "border-transparent bg-destructive/15 text-destructive"
313
313
  };
314
314
  function InteractionBadge({ variant, children }) {
315
- return /* @__PURE__ */ jsx2("span", { className: `inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium ${BADGE_VARIANT_CLASSES[variant]}`, children });
315
+ return /* @__PURE__ */ jsx2("span", { className: `inline-flex items-center rounded-md border px-2 py-0.5 text-sm font-medium ${BADGE_VARIANT_CLASSES[variant]}`, children });
316
316
  }
317
317
  function InteractionActionButton({
318
318
  variant = "primary",
@@ -371,7 +371,7 @@ function QuestionOptionList({
371
371
  ),
372
372
  /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
373
373
  /* @__PURE__ */ jsx2("span", { id: `${inputId}-label`, className: "block text-sm font-medium leading-5 text-foreground", children: option.label }),
374
- option.description && /* @__PURE__ */ jsx2("span", { id: `${inputId}-description`, className: "mt-0.5 block text-xs leading-5 text-muted-foreground", children: option.description })
374
+ option.description && /* @__PURE__ */ jsx2("span", { id: `${inputId}-description`, className: "mt-0.5 block text-sm leading-5 text-muted-foreground", children: option.description })
375
375
  ] }),
376
376
  highlighted && /* @__PURE__ */ jsx2(CheckGlyph, { className: "mt-0.5 h-4 w-4 shrink-0 text-primary" })
377
377
  ]
@@ -405,7 +405,8 @@ var STATUS_LABELS = interactionStatusLabels({
405
405
  });
406
406
  var TERMINAL_NOTES = interactionTerminalNotes("question", {
407
407
  expired: "The original run ended. Answer now to send a new message with this context.",
408
- cancelled: "The agent withdrew this question. Answer now to send a new message with this context."
408
+ cancelled: "The agent withdrew this question. Answer now to send a new message with this context.",
409
+ declined: "You declined this question."
409
410
  });
410
411
  function InteractionQuestionCard({
411
412
  interaction,
@@ -416,6 +417,7 @@ function InteractionQuestionCard({
416
417
  kindLabel,
417
418
  timeoutNote,
418
419
  renderMarkdown,
420
+ declinable = true,
419
421
  className
420
422
  }) {
421
423
  const [values, setValues] = useState3(() => fieldValuesFromAnswers(interaction.fields, interaction.answers));
@@ -424,6 +426,7 @@ function InteractionQuestionCard({
424
426
  const [lateAnswerSent, setLateAnswerSent] = useState3(false);
425
427
  const [error, setError] = useState3(null);
426
428
  const submitInFlightRef = useRef2(false);
429
+ const [declining, setDeclining] = useState3(false);
427
430
  const [askId, setAskId] = useState3(interaction.id);
428
431
  if (askId !== interaction.id) {
429
432
  setAskId(interaction.id);
@@ -500,15 +503,43 @@ function InteractionQuestionCard({
500
503
  setSubmitting(false);
501
504
  }
502
505
  }
506
+ async function decline() {
507
+ if (submitInFlightRef.current || disabled || lateAnswerable) return;
508
+ submitInFlightRef.current = true;
509
+ setSubmitting(true);
510
+ setDeclining(true);
511
+ setError(null);
512
+ try {
513
+ const result = await settleInteractionSubmit(
514
+ () => submitAnswer({ id: interaction.id, outcome: "declined" })
515
+ );
516
+ if (result.ok) {
517
+ setLocalStatus("declined");
518
+ onResolved?.(interaction.id, "declined");
519
+ return;
520
+ }
521
+ if (result.expired) {
522
+ setLocalStatus("expired");
523
+ onResolved?.(interaction.id, "expired");
524
+ return;
525
+ }
526
+ setError(result.message);
527
+ } finally {
528
+ submitInFlightRef.current = false;
529
+ setSubmitting(false);
530
+ setDeclining(false);
531
+ }
532
+ }
503
533
  const terminalNote = secretLateAnswerBlocked ? "This question asked for a secret, so it cannot be sent as a new chat message. Ask the agent to request it again." : TERMINAL_NOTES[status];
504
534
  const showSubmitButton = status === "pending" || canWrite && lateAnswerable && !lateAnswerSent;
505
535
  const showTimeoutNote = timeoutNote != null && status === "pending";
506
536
  let submitLabel = "Submit answer";
507
537
  if (lateAnswerable) {
508
538
  submitLabel = submitting ? "Sending\u2026" : "Send as new message";
509
- } else if (submitting) {
539
+ } else if (submitting && !declining) {
510
540
  submitLabel = "Submitting\u2026";
511
541
  }
542
+ const showDeclineButton = declinable && canWrite && status === "pending";
512
543
  return (
513
544
  // The card LANDS. This is the moment the run stopped and handed the turn
514
545
  // back — a surface that blinks into place reads as chrome that was always
@@ -610,17 +641,18 @@ function InteractionQuestionCard({
610
641
  )
611
642
  ] }, field.name);
612
643
  }) }),
613
- error && /* @__PURE__ */ jsx2("p", { role: "alert", className: "mt-3 text-xs text-destructive", children: error }),
614
- terminalNote && /* @__PURE__ */ jsx2("p", { className: "mt-3 text-xs text-muted-foreground", children: terminalNote }),
644
+ error && /* @__PURE__ */ jsx2("p", { role: "alert", className: "mt-3 text-sm text-destructive", children: error }),
645
+ terminalNote && /* @__PURE__ */ jsx2("p", { className: "mt-3 text-sm text-muted-foreground", children: terminalNote }),
615
646
  (showSubmitButton || showTimeoutNote) && /* @__PURE__ */ jsxs("div", { className: "mt-4 flex flex-wrap items-center justify-end gap-2", children: [
616
- showTimeoutNote && /* @__PURE__ */ jsx2("div", { className: "mr-auto text-xs text-muted-foreground", children: timeoutNote }),
647
+ showTimeoutNote && /* @__PURE__ */ jsx2("div", { className: "mr-auto text-sm text-muted-foreground", children: timeoutNote }),
648
+ showDeclineButton && /* @__PURE__ */ jsx2(InteractionActionButton, { variant: "outline", onClick: () => void decline(), disabled, children: declining ? "Declining\u2026" : "Decline" }),
617
649
  showSubmitButton && /* @__PURE__ */ jsx2(InteractionActionButton, { onClick: () => void submit(), disabled: disabled || !answerData, children: submitLabel })
618
650
  ] }),
619
- answered && /* @__PURE__ */ jsx2("div", { className: "mt-4 flex items-center justify-end", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-xs text-muted-foreground", children: [
651
+ answered && /* @__PURE__ */ jsx2("div", { className: "mt-4 flex items-center justify-end", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-sm text-muted-foreground", children: [
620
652
  /* @__PURE__ */ jsx2(CheckGlyph, { className: "h-3 w-3" }),
621
653
  "Answered"
622
654
  ] }) }),
623
- lateAnswerSent && /* @__PURE__ */ jsx2("div", { className: "mt-4 flex items-center justify-end", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-xs text-muted-foreground", children: [
655
+ lateAnswerSent && /* @__PURE__ */ jsx2("div", { className: "mt-4 flex items-center justify-end", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-sm text-muted-foreground", children: [
624
656
  /* @__PURE__ */ jsx2(CheckGlyph, { className: "h-3 w-3" }),
625
657
  "Sent as new message"
626
658
  ] }) })
@@ -7536,11 +7568,16 @@ function ApiAccessPanel({
7536
7568
  limitsDescription,
7537
7569
  expiryDays = defaultExpiryChoices,
7538
7570
  defaultExpiryDays = 7,
7571
+ workspaces,
7572
+ workspaceNoun = { singular: "workspace", plural: "workspaces" },
7539
7573
  onCreate,
7540
7574
  onRevoke,
7541
7575
  onChanged
7542
7576
  }) {
7543
7577
  const [name, setName] = useState23("");
7578
+ const [reach, setReach] = useState23("");
7579
+ const selectedWorkspace = workspaces?.some((workspace) => workspace.id === reach) ? reach : "";
7580
+ const workspaceName = (id) => workspaces?.find((workspace) => workspace.id === id)?.name ?? `A removed ${workspaceNoun.singular}`;
7544
7581
  const allowedDays = [...new Set(expiryDays)].filter((days2) => days2 > 0 && Number.isFinite(new Date(Date.now() + days2 * 864e5).getTime()));
7545
7582
  const fallbackDays = allowedDays.includes(defaultExpiryDays) ? defaultExpiryDays : allowedDays[0];
7546
7583
  const [days, setDays] = useState23(fallbackDays);
@@ -7580,7 +7617,8 @@ function ApiAccessPanel({
7580
7617
  const result = await onCreate({
7581
7618
  name: name.trim(),
7582
7619
  scopes: requestedScopes,
7583
- expiresAt: new Date(Date.now() + selectedDays * 864e5).toISOString()
7620
+ expiresAt: new Date(Date.now() + selectedDays * 864e5).toISOString(),
7621
+ workspaceIds: selectedWorkspace ? [selectedWorkspace] : []
7584
7622
  });
7585
7623
  if (!result.id || !result.key) throw new Error("Could not create key");
7586
7624
  setCreated({ id: result.id, key: result.key });
@@ -7654,6 +7692,20 @@ function ApiAccessPanel({
7654
7692
  ] }, days2)) })
7655
7693
  ] })
7656
7694
  ] }),
7695
+ workspaces && workspaces.length > 0 && /* @__PURE__ */ jsxs21("div", { className: "space-y-1.5", children: [
7696
+ /* @__PURE__ */ jsx23("label", { className: "text-sm font-medium", htmlFor: "key-reach", children: "Reaches" }),
7697
+ /* @__PURE__ */ jsxs21("select", { id: "key-reach", value: selectedWorkspace, onChange: (event) => setReach(event.target.value), className: "h-11 w-full rounded-lg border border-input bg-background px-3 text-sm", children: [
7698
+ /* @__PURE__ */ jsxs21("option", { value: "", children: [
7699
+ "All ",
7700
+ workspaceNoun.plural,
7701
+ ", including new ones"
7702
+ ] }),
7703
+ workspaces.map((workspace) => /* @__PURE__ */ jsxs21("option", { value: workspace.id, children: [
7704
+ "Only ",
7705
+ workspace.name
7706
+ ] }, workspace.id))
7707
+ ] })
7708
+ ] }),
7657
7709
  /* @__PURE__ */ jsxs21("fieldset", { className: "space-y-3", children: [
7658
7710
  /* @__PURE__ */ jsx23("legend", { className: "mb-3 text-sm font-medium", children: "Permissions" }),
7659
7711
  access.map((option) => {
@@ -7677,7 +7729,7 @@ function ApiAccessPanel({
7677
7729
  ] }, option.scope);
7678
7730
  })
7679
7731
  ] }),
7680
- limitsDescription && /* @__PURE__ */ jsx23("p", { className: "text-xs text-muted-foreground", children: limitsDescription }),
7732
+ limitsDescription && /* @__PURE__ */ jsx23("p", { className: "text-sm text-muted-foreground", children: limitsDescription }),
7681
7733
  /* @__PURE__ */ jsx23("button", { className: buttonClass, type: "submit", disabled: creating || !name.trim() || !selectedScopes.length || selectedDays === void 0, children: creating ? "Creating\u2026" : "Create key" })
7682
7734
  ] }),
7683
7735
  /* @__PURE__ */ jsxs21("section", { "aria-labelledby": "existing-keys", className: "space-y-3", children: [
@@ -7685,15 +7737,16 @@ function ApiAccessPanel({
7685
7737
  keys.length === 0 ? /* @__PURE__ */ jsx23("p", { className: "text-sm text-muted-foreground", children: "No keys yet." }) : /* @__PURE__ */ jsx23("ul", { className: "divide-y divide-border rounded-xl border border-border bg-card", children: keys.map((key) => /* @__PURE__ */ jsxs21("li", { className: "flex items-start justify-between gap-3 p-4", children: [
7686
7738
  /* @__PURE__ */ jsxs21("div", { className: "min-w-0 space-y-1", children: [
7687
7739
  /* @__PURE__ */ jsx23("p", { className: "break-words text-sm font-medium", children: key.name }),
7688
- /* @__PURE__ */ jsx23("p", { className: "text-xs text-muted-foreground", children: key.expiresAt ? `${new Date(key.expiresAt).getTime() <= Date.now() ? "Expired" : "Expires"} ${new Date(key.expiresAt).toLocaleDateString()}` : "No expiry" }),
7689
- /* @__PURE__ */ jsx23("p", { className: "text-xs text-muted-foreground", children: key.scopes.map((scope) => access.find((access2) => access2.scope === scope)?.label ?? scope).join(" \xB7 ") })
7740
+ /* @__PURE__ */ jsx23("p", { className: "text-sm text-muted-foreground", children: key.expiresAt ? `${new Date(key.expiresAt).getTime() <= Date.now() ? "Expired" : "Expires"} ${new Date(key.expiresAt).toLocaleDateString()}` : "No expiry" }),
7741
+ /* @__PURE__ */ jsx23("p", { className: "text-sm text-muted-foreground", children: key.scopes.map((scope) => access.find((access2) => access2.scope === scope)?.label ?? scope).join(" \xB7 ") }),
7742
+ workspaces && /* @__PURE__ */ jsx23("p", { className: "text-sm text-muted-foreground", children: key.workspaceIds?.length ? `Only ${key.workspaceIds.map(workspaceName).join(", ")}` : `All ${workspaceNoun.plural}` })
7690
7743
  ] }),
7691
7744
  /* @__PURE__ */ jsx23("button", { className: outlineClass, disabled: revoking !== null, onClick: () => revokeKey(key.id), "aria-label": `Revoke ${key.name}`, children: revoking === key.id ? "Revoking\u2026" : "Revoke" })
7692
7745
  ] }, key.id)) })
7693
7746
  ] }),
7694
7747
  /* @__PURE__ */ jsxs21("p", { className: "text-sm text-muted-foreground", children: [
7695
7748
  "Use ",
7696
- /* @__PURE__ */ jsx23("code", { className: "text-xs", children: baseUrl }),
7749
+ /* @__PURE__ */ jsx23("code", { className: "text-sm", children: baseUrl }),
7697
7750
  " as the API base and send the key as a Bearer credential."
7698
7751
  ] })
7699
7752
  ] }) });
@@ -8850,4 +8903,4 @@ export {
8850
8903
  useThinkingSeconds,
8851
8904
  ChatMessages
8852
8905
  };
8853
- //# sourceMappingURL=chunk-KIJ64S54.js.map
8906
+ //# sourceMappingURL=chunk-H6MKILMQ.js.map