@tangle-network/agent-app 0.51.10 → 0.51.11

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.
@@ -10,7 +10,7 @@ import "../chunk-ENLRJYVW.js";
10
10
  import "../chunk-GEYACSFW.js";
11
11
  import {
12
12
  ChatComposer
13
- } from "../chunk-OSZBBLK5.js";
13
+ } from "../chunk-BYAQQPLN.js";
14
14
  import "../chunk-L7MB2LLM.js";
15
15
  import {
16
16
  ModelPicker
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ComposerModeControls,
3
3
  EntryComposer
4
- } from "../chunk-OSZBBLK5.js";
4
+ } from "../chunk-BYAQQPLN.js";
5
5
  import "../chunk-L7MB2LLM.js";
6
6
  import "../chunk-XF6ZRY56.js";
7
7
  import "../chunk-SJWIZT7B.js";
@@ -335,7 +335,7 @@ import {
335
335
  } from "react";
336
336
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
337
337
  function createLazyMentionEditor() {
338
- return lazy(() => import("./mention-editor-I7Q4LF2X.js").then((m) => m.loadMentionEditor()));
338
+ return lazy(() => import("./mention-editor-UIY5HFEZ.js").then((m) => m.loadMentionEditor()));
339
339
  }
340
340
  var IS_APPLE_PLATFORM = typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform);
341
341
  function SendGlyph({ className }) {
@@ -429,6 +429,9 @@ function ChatComposer({
429
429
  trailing,
430
430
  mention,
431
431
  slashCommands,
432
+ eligibleSkills = [],
433
+ selectedSkillId,
434
+ onSelectedSkillChange,
432
435
  onDictate,
433
436
  onDictateError,
434
437
  focusShortcut = true,
@@ -540,7 +543,7 @@ function ChatComposer({
540
543
  return () => document.removeEventListener("keydown", onKeyDown);
541
544
  }, [focusShortcut, disabled, mentionEnabled]);
542
545
  const sendableFiles = canSubmitAttachmentsOnly ? pendingFiles : pendingFiles.filter((f) => f.status === "ready");
543
- const hasSendable = text.trim().length > 0 || sendableFiles.length > 0;
546
+ const hasSendable = text.trim().length > 0 || sendableFiles.length > 0 || Boolean(selectedSkillId);
544
547
  const sendBlockedByStream = isStreaming && !canSubmitWhileBusy;
545
548
  const canSend = hasSendable && !sendBlockedByStream && !disabled;
546
549
  const [failedSend, setFailedSend] = useState2(null);
@@ -590,8 +593,8 @@ function ChatComposer({
590
593
  if (sendBlockedByStream || disabled) return;
591
594
  const readyFiles = pendingFiles.filter((f) => f.status === "ready");
592
595
  const sendable = canSubmitAttachmentsOnly ? pendingFiles : readyFiles;
593
- if (!trimmed && sendable.length === 0) return;
594
- if (!trimmed && readyFiles.length === 0) {
596
+ if (!trimmed && sendable.length === 0 && !selectedSkillId) return;
597
+ if (!trimmed && readyFiles.length === 0 && pendingFiles.length > 0) {
595
598
  const message = attachmentsNotReadyMessage ?? (pendingFiles.some((f) => f.status === "error") ? "Retry or remove the failed attachment before sending." : "Wait for the attachment to finish uploading.");
596
599
  setFailedSend({ message, text: "", trimmed: "", parts: [], restored: true });
597
600
  return;
@@ -611,6 +614,7 @@ function ChatComposer({
611
614
  attachmentsNotReadyMessage,
612
615
  onSendParts,
613
616
  pendingFiles,
617
+ selectedSkillId,
614
618
  setText,
615
619
  dispatchSend
616
620
  ]);
@@ -624,23 +628,42 @@ function ChatComposer({
624
628
  const slashPanelRef = useRef2(null);
625
629
  const cardRef = useRef2(null);
626
630
  const slashListId = useId();
631
+ const [mentionSuggestionOpen, setMentionSuggestionOpen] = useState2(false);
627
632
  const [slashActive, setSlashActive] = useState2(0);
628
633
  const [slashDismissedFor, setSlashDismissedFor] = useState2(null);
629
- const slashToken = !mention && slashCommands && slashCommands.length > 0 ? /^\/(\S*)$/.exec(text)?.[1] : void 0;
630
- const slashOpen = slashToken !== void 0 && text !== slashDismissedFor;
634
+ const hasSkills = Boolean(onSelectedSkillChange && eligibleSkills.length > 0);
635
+ const commandToken = !mention && slashCommands?.length ? /^\/(\S*)$/.exec(text)?.[1] : void 0;
636
+ const skillToken = hasSkills ? /^\/(\S*)$/.exec(text)?.[1] : void 0;
637
+ const skillInvocation = hasSkills ? /^\/skill(?:\s+(.*))?$/i.exec(text) : null;
638
+ const skillQuery = skillInvocation ? skillInvocation[1] ?? "" : void 0;
639
+ const slashToken = skillQuery ?? skillToken ?? commandToken;
640
+ const slashOpen = slashToken !== void 0 && text !== slashDismissedFor && !mentionSuggestionOpen;
631
641
  const slashItems = useMemo(
632
- () => (slashCommands ?? []).map((command) => ({
633
- id: command.name,
634
- group: "Commands",
635
- label: `/${command.name}`,
636
- description: command.description,
637
- keywords: [command.name, command.description]
638
- })),
639
- [slashCommands]
642
+ () => [
643
+ ...(!mention ? slashCommands ?? [] : []).map((command) => ({
644
+ id: `command:${command.name}`,
645
+ group: "Commands",
646
+ label: `/${command.name}`,
647
+ description: command.description,
648
+ keywords: [command.name, command.description]
649
+ })),
650
+ ...(onSelectedSkillChange ? eligibleSkills : []).map((skill) => ({
651
+ id: `skill:${skill.id}`,
652
+ group: "Skills",
653
+ label: `/skill ${skill.name}`,
654
+ description: skill.description,
655
+ keywords: [skill.id, skill.name, skill.description]
656
+ }))
657
+ ],
658
+ [slashCommands, mention, eligibleSkills, onSelectedSkillChange]
640
659
  );
641
660
  const slashFiltered = useMemo(
642
- () => slashToken === void 0 ? [] : filterCommandPaletteItems(slashItems, slashToken),
643
- [slashItems, slashToken]
661
+ () => {
662
+ if (slashToken === void 0) return [];
663
+ const items = skillQuery !== void 0 ? slashItems.filter((item) => item.group === "Skills") : slashItems;
664
+ return filterCommandPaletteItems(items, slashToken);
665
+ },
666
+ [slashItems, slashToken, skillQuery]
644
667
  );
645
668
  const slashActiveIndex = slashFiltered.length === 0 ? 0 : Math.min(slashActive, slashFiltered.length - 1);
646
669
  useEffect3(() => {
@@ -662,42 +685,50 @@ function ChatComposer({
662
685
  return () => document.removeEventListener("mousedown", onMouseDown);
663
686
  }, [slashOpen]);
664
687
  const pickSlash = useCallback2(
665
- (name) => {
666
- const command = slashCommands?.find((c) => c.name === name);
688
+ (id) => {
667
689
  setText("");
668
690
  setSlashDismissedFor(null);
669
- command?.run();
691
+ if (id.startsWith("skill:")) {
692
+ const skill = eligibleSkills.find((item) => item.id === id.slice("skill:".length));
693
+ if (skill) onSelectedSkillChange?.(skill);
694
+ } else if (id.startsWith("command:")) {
695
+ slashCommands?.find((command) => command.name === id.slice("command:".length))?.run();
696
+ }
670
697
  },
671
- [slashCommands, setText]
698
+ [slashCommands, eligibleSkills, onSelectedSkillChange, setText]
672
699
  );
673
- const handleKeyDown = (e) => {
674
- if (e.nativeEvent.isComposing) return;
700
+ const handleSlashKeyDown = (e) => {
675
701
  if (slashOpen) {
676
702
  if (e.key === "ArrowDown") {
677
703
  e.preventDefault();
678
704
  if (slashFiltered.length > 0) setSlashActive((slashActiveIndex + 1) % slashFiltered.length);
679
- return;
705
+ return true;
680
706
  }
681
707
  if (e.key === "ArrowUp") {
682
708
  e.preventDefault();
683
709
  if (slashFiltered.length > 0)
684
710
  setSlashActive((slashActiveIndex - 1 + slashFiltered.length) % slashFiltered.length);
685
- return;
711
+ return true;
686
712
  }
687
713
  if (e.key === "Enter" && !e.shiftKey || e.key === "Tab") {
688
714
  const item = slashFiltered[slashActiveIndex];
689
715
  if (item) {
690
716
  e.preventDefault();
691
717
  pickSlash(item.id);
692
- return;
718
+ return true;
693
719
  }
694
720
  }
695
721
  if (e.key === "Escape") {
696
722
  e.preventDefault();
697
723
  setSlashDismissedFor(text);
698
- return;
724
+ return true;
699
725
  }
700
726
  }
727
+ return false;
728
+ };
729
+ const handleKeyDown = (e) => {
730
+ if (e.nativeEvent.isComposing) return;
731
+ if (handleSlashKeyDown(e)) return;
701
732
  if (e.key === "Enter" && !e.shiftKey) {
702
733
  e.preventDefault();
703
734
  send();
@@ -878,6 +909,22 @@ function ChatComposer({
878
909
  ]
879
910
  }
880
911
  ),
912
+ selectedSkillId && /* @__PURE__ */ jsx2("div", { "aria-label": "Selected skill", className: "mb-2 flex min-w-0 flex-wrap gap-1.5", children: /* @__PURE__ */ jsxs2("span", { className: "inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border border-primary/30 bg-primary/10 px-2.5 py-1 text-xs text-primary", children: [
913
+ /* @__PURE__ */ jsxs2("span", { className: "min-w-0 truncate", children: [
914
+ "Skill: ",
915
+ eligibleSkills.find((skill) => skill.id === selectedSkillId)?.name ?? selectedSkillId
916
+ ] }),
917
+ onSelectedSkillChange && /* @__PURE__ */ jsx2(
918
+ "button",
919
+ {
920
+ type: "button",
921
+ "aria-label": "Remove selected skill",
922
+ onClick: () => onSelectedSkillChange(null),
923
+ className: "shrink-0 rounded p-0.5 text-primary/70 transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
924
+ children: /* @__PURE__ */ jsx2(CloseGlyph, { className: "h-3 w-3" })
925
+ }
926
+ )
927
+ ] }) }),
881
928
  contextItems.length > 0 && /* @__PURE__ */ jsx2("div", { "aria-label": "Message context", className: "mb-2 flex min-w-0 flex-wrap gap-1.5", children: contextItems.map((item) => /* @__PURE__ */ jsxs2(
882
929
  "span",
883
930
  {
@@ -975,6 +1022,10 @@ function ChatComposer({
975
1022
  mention,
976
1023
  fallback: textareaInput,
977
1024
  registerFocus: registerRichFocus,
1025
+ onComposerKeyDown: handleSlashKeyDown,
1026
+ onMentionMenuOpenChange: setMentionSuggestionOpen,
1027
+ slashListId: slashOpen ? slashListId : void 0,
1028
+ slashActiveId: slashFiltered[slashActiveIndex] ? `${slashListId}-${slashActiveIndex}` : void 0,
978
1029
  onPasteFiles: onAttach ? ingestPastedFiles : void 0
979
1030
  }
980
1031
  ) }) })
@@ -1125,11 +1176,11 @@ function ChatComposer({
1125
1176
  open: slashOpen,
1126
1177
  id: slashListId,
1127
1178
  role: "listbox",
1128
- triggerRef: textareaRef,
1179
+ triggerRef: mention ? cardRef : textareaRef,
1129
1180
  panelRef: slashPanelRef,
1130
1181
  className: `w-80 overflow-y-auto rounded-xl border border-card-edge bg-popover p-1 ${OVERLAY_SHADOW}`,
1131
1182
  children: [
1132
- slashFiltered.length === 0 && /* @__PURE__ */ jsx2("div", { className: "px-3 py-4 text-center text-sm text-muted-foreground", children: "No matching commands" }),
1183
+ slashFiltered.length === 0 && /* @__PURE__ */ jsx2("div", { className: "px-3 py-4 text-center text-sm text-muted-foreground", children: skillQuery !== void 0 ? "No matching skills" : hasSkills ? "No matching commands or skills" : "No matching commands" }),
1133
1184
  slashFiltered.map((item, index) => /* @__PURE__ */ jsxs2(
1134
1185
  "button",
1135
1186
  {
@@ -1900,4 +1951,4 @@ export {
1900
1951
  ComposerModeControls,
1901
1952
  EntryComposer
1902
1953
  };
1903
- //# sourceMappingURL=chunk-OSZBBLK5.js.map
1954
+ //# sourceMappingURL=chunk-BYAQQPLN.js.map