@tutti-os/agent-gui 0.0.94 → 0.0.95
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.
- package/README.md +48 -32
- package/dist/AgentGUI-CwBLYtv-.d.ts +992 -0
- package/dist/agent-conversation/index.d.ts +5 -7
- package/dist/agent-conversation/index.js +12 -8
- package/dist/agent-conversation/index.js.map +1 -1
- package/dist/agent-env/index.d.ts +10 -36
- package/dist/agent-env/index.js +1 -56
- package/dist/agent-env/index.js.map +1 -1
- package/dist/agent-gui.d.ts +21 -0
- package/dist/agent-gui.js +39 -0
- package/dist/agent-message-center/index.d.ts +145 -124
- package/dist/agent-message-center/index.js +1374 -1316
- package/dist/agent-message-center/index.js.map +1 -1
- package/dist/{agentConversationVM-Cl4G0Lln.d.ts → agentConversationVM-C335TR6S.d.ts} +112 -7
- package/dist/agentFileMentionContracts-Czvz6YMI.d.ts +107 -0
- package/dist/{agentGuiNodeTypes-CAioPXK9.d.ts → agentGuiNodeTypes-DppADPHW.d.ts} +96 -148
- package/dist/agentPlanPromptDispatch-C7cCMjve.d.ts +37 -0
- package/dist/agents.d.ts +13 -0
- package/dist/agents.js +13 -0
- package/dist/app/renderer/agentactivity.css +126 -80
- package/dist/app/renderer/assets/icons/agent-vinyls/tutti-vinyl.png +0 -0
- package/dist/app/renderer/assets/icons/open-link-lined.svg +4 -0
- package/dist/{chunk-P72YLKC6.js → chunk-3R2D4E57.js} +3127 -3398
- package/dist/chunk-3R2D4E57.js.map +1 -0
- package/dist/chunk-4YG7YK7S.js +23 -0
- package/dist/chunk-4YG7YK7S.js.map +1 -0
- package/dist/chunk-5X7YDOC6.js +42 -0
- package/dist/chunk-5X7YDOC6.js.map +1 -0
- package/dist/{chunk-IBIMGLCD.js → chunk-7J4K6WKB.js} +1 -1
- package/dist/chunk-7J4K6WKB.js.map +1 -0
- package/dist/{chunk-BXVPOGYK.js → chunk-7PFDA2HQ.js} +505 -504
- package/dist/chunk-7PFDA2HQ.js.map +1 -0
- package/dist/{chunk-AWAIUYG4.js → chunk-7RDD3EWP.js} +513 -555
- package/dist/chunk-7RDD3EWP.js.map +1 -0
- package/dist/{chunk-UBDPV34P.js → chunk-AOS2VWU6.js} +1355 -1305
- package/dist/chunk-AOS2VWU6.js.map +1 -0
- package/dist/{chunk-E5FOXRUM.js → chunk-BFNJKTDV.js} +295 -255
- package/dist/chunk-BFNJKTDV.js.map +1 -0
- package/dist/{chunk-5FE7M42A.js → chunk-BIHBXWK5.js} +2 -2
- package/dist/{chunk-7BUYFVRI.js → chunk-C5FV4UGI.js} +2921 -2944
- package/dist/chunk-C5FV4UGI.js.map +1 -0
- package/dist/{chunk-SCLLP5DO.js → chunk-CRO2MV2Y.js} +36 -46
- package/dist/chunk-CRO2MV2Y.js.map +1 -0
- package/dist/chunk-FGLQZ6I4.js +9 -0
- package/dist/chunk-FGLQZ6I4.js.map +1 -0
- package/dist/chunk-H6IQ63DQ.js +14 -0
- package/dist/chunk-H6IQ63DQ.js.map +1 -0
- package/dist/{chunk-IGY4ASUF.js → chunk-JX2SIXNL.js} +1293 -1702
- package/dist/chunk-JX2SIXNL.js.map +1 -0
- package/dist/chunk-KAL4XZMA.js +231 -0
- package/dist/chunk-KAL4XZMA.js.map +1 -0
- package/dist/chunk-KJQERFKX.js +259 -0
- package/dist/chunk-KJQERFKX.js.map +1 -0
- package/dist/chunk-LQVXBT65.js +491 -0
- package/dist/chunk-LQVXBT65.js.map +1 -0
- package/dist/{chunk-554VG7ZW.js → chunk-NITOD7WF.js} +2 -2
- package/dist/{chunk-7LMJXF4R.js → chunk-NJAZ7LQM.js} +20 -16
- package/dist/chunk-NJAZ7LQM.js.map +1 -0
- package/dist/chunk-NX3CZJXW.js +25 -0
- package/dist/chunk-NX3CZJXW.js.map +1 -0
- package/dist/chunk-O6W72SEP.js +93 -0
- package/dist/chunk-O6W72SEP.js.map +1 -0
- package/dist/chunk-RY6GIO3K.js +31700 -0
- package/dist/chunk-RY6GIO3K.js.map +1 -0
- package/dist/{chunk-XDV4ZRVK.js → chunk-UGVI47X6.js} +98 -37
- package/dist/chunk-UGVI47X6.js.map +1 -0
- package/dist/{chunk-XW4CVBUH.js → chunk-UQJPV6HP.js} +18 -11
- package/dist/chunk-UQJPV6HP.js.map +1 -0
- package/dist/{chunk-GAPTLVII.js → chunk-VF22EG3F.js} +1 -1
- package/dist/{chunk-GAPTLVII.js.map → chunk-VF22EG3F.js.map} +1 -1
- package/dist/{chunk-45FF4DQU.js → chunk-WEDMAVX2.js} +22 -24
- package/dist/chunk-WEDMAVX2.js.map +1 -0
- package/dist/{chunk-MATIJPGF.js → chunk-XMO45GKA.js} +531 -401
- package/dist/chunk-XMO45GKA.js.map +1 -0
- package/dist/{chunk-ZUW4B5AT.js → chunk-YE25HN6T.js} +6 -9
- package/dist/chunk-YE25HN6T.js.map +1 -0
- package/dist/context-mention-palette/index.d.ts +3 -2
- package/dist/context-mention-palette/index.js +19 -14
- package/dist/custom-mention.d.ts +44 -0
- package/dist/custom-mention.js +17 -0
- package/dist/custom-mention.js.map +1 -0
- package/dist/dock-icons.d.ts +6 -0
- package/dist/dock-icons.js +11 -0
- package/dist/dock-icons.js.map +1 -0
- package/dist/i18n/index.d.ts +850 -841
- package/dist/i18n/index.js +2 -2
- package/dist/index.d.ts +52 -1061
- package/dist/index.js +72 -35530
- package/dist/index.js.map +1 -1
- package/dist/mention-search.d.ts +226 -0
- package/dist/mention-search.js +29 -0
- package/dist/mention-search.js.map +1 -0
- package/dist/open-link-lined-JWEKUKME.svg +4 -0
- package/dist/provider-icons.d.ts +6 -0
- package/dist/provider-icons.js +12 -0
- package/dist/provider-icons.js.map +1 -0
- package/dist/provider-identity.d.ts +9 -0
- package/dist/provider-identity.js +21 -0
- package/dist/provider-identity.js.map +1 -0
- package/dist/runtime-BBNdWgDU.d.ts +10 -0
- package/dist/{types-PLFZ8SBX.d.ts → types-DX2bxgB8.d.ts} +28 -83
- package/dist/workbench/contribution.d.ts +32 -40
- package/dist/workbench/contribution.js +10 -6
- package/dist/workbench/index.d.ts +3 -2
- package/dist/workbench/index.js +24 -20
- package/dist/workbench/launch.d.ts +2 -5
- package/dist/workbench/launch.js +4 -3
- package/dist/workbench/providerCatalog.js +2 -1
- package/dist/workbench/sessionTitle.d.ts +4 -3
- package/dist/workbench/sessionTitle.js +4 -3
- package/dist/workbench/state.d.ts +1 -1
- package/dist/workbench/state.js +3 -2
- package/dist/workbench/types.d.ts +0 -3
- package/dist/workbench/types.js +1 -1
- package/dist/workspace-agent-generated-files.d.ts +20 -2
- package/dist/workspace-agent-generated-files.js +7 -6
- package/dist/workspaceAgentActivityListTypes-C7gPWYiA.d.ts +71 -0
- package/package.json +63 -26
- package/dist/AgentMentionSearchController-DD_WOred.d.ts +0 -241
- package/dist/AgentMessageMarkdown-DeYPURtF.d.ts +0 -7
- package/dist/chunk-45FF4DQU.js.map +0 -1
- package/dist/chunk-4HP6V2YA.js +0 -207
- package/dist/chunk-4HP6V2YA.js.map +0 -1
- package/dist/chunk-7BUYFVRI.js.map +0 -1
- package/dist/chunk-7LMJXF4R.js.map +0 -1
- package/dist/chunk-AWAIUYG4.js.map +0 -1
- package/dist/chunk-BXVPOGYK.js.map +0 -1
- package/dist/chunk-E5FOXRUM.js.map +0 -1
- package/dist/chunk-IBIMGLCD.js.map +0 -1
- package/dist/chunk-IGY4ASUF.js.map +0 -1
- package/dist/chunk-LR4FA5X6.js +0 -368
- package/dist/chunk-LR4FA5X6.js.map +0 -1
- package/dist/chunk-MATIJPGF.js.map +0 -1
- package/dist/chunk-MKHDRIGN.js +0 -71
- package/dist/chunk-MKHDRIGN.js.map +0 -1
- package/dist/chunk-P72YLKC6.js.map +0 -1
- package/dist/chunk-SCLLP5DO.js.map +0 -1
- package/dist/chunk-UBDPV34P.js.map +0 -1
- package/dist/chunk-VAKFNNKT.js +0 -410
- package/dist/chunk-VAKFNNKT.js.map +0 -1
- package/dist/chunk-XDV4ZRVK.js.map +0 -1
- package/dist/chunk-XW4CVBUH.js.map +0 -1
- package/dist/chunk-ZUW4B5AT.js.map +0 -1
- package/dist/plan-decision-ops.d.ts +0 -70
- package/dist/plan-decision-ops.js +0 -19
- package/dist/queued-prompt-runtime.d.ts +0 -115
- package/dist/queued-prompt-runtime.js +0 -9
- package/dist/workspaceAgentActivityListViewModel-BzV-cf0D.d.ts +0 -340
- package/dist/workspaceLinkActions-DS9LWqzI.d.ts +0 -74
- /package/dist/{plan-decision-ops.js.map → agent-gui.js.map} +0 -0
- /package/dist/{queued-prompt-runtime.js.map → agents.js.map} +0 -0
- /package/dist/{chunk-5FE7M42A.js.map → chunk-BIHBXWK5.js.map} +0 -0
- /package/dist/{chunk-554VG7ZW.js.map → chunk-NITOD7WF.js.map} +0 -0
|
@@ -3,13 +3,15 @@ import {
|
|
|
3
3
|
resolveAgentMentionFileVisualKind
|
|
4
4
|
} from "./chunk-LUGELG5V.js";
|
|
5
5
|
import {
|
|
6
|
-
getAgentCustomMentionKind,
|
|
7
6
|
managedAgentRoundedIconUrl
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KAL4XZMA.js";
|
|
9
8
|
import {
|
|
10
9
|
translate,
|
|
11
10
|
useTranslation
|
|
12
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BIHBXWK5.js";
|
|
12
|
+
import {
|
|
13
|
+
getAgentCustomMentionKind
|
|
14
|
+
} from "./chunk-5X7YDOC6.js";
|
|
13
15
|
|
|
14
16
|
// agent-gui/agentGuiNode/agentRichText/agentFileMentionExtension.ts
|
|
15
17
|
import { mergeAttributes, Node } from "@tiptap/core";
|
|
@@ -17,14 +19,6 @@ import { PluginKey } from "@tiptap/pm/state";
|
|
|
17
19
|
import { ReactNodeViewRenderer } from "@tiptap/react";
|
|
18
20
|
import Suggestion, { exitSuggestion } from "@tiptap/suggestion";
|
|
19
21
|
import { isRichTextTriggerPrefixBoundary } from "@tutti-os/ui-rich-text/editor";
|
|
20
|
-
import {
|
|
21
|
-
createRichTextLinkMarkdown,
|
|
22
|
-
createRichTextMarkdownLink,
|
|
23
|
-
createRichTextMentionHref,
|
|
24
|
-
createRichTextMentionMarkdown,
|
|
25
|
-
isRichTextMentionHref,
|
|
26
|
-
parseRichTextMentionHref
|
|
27
|
-
} from "@tutti-os/ui-rich-text/core";
|
|
28
22
|
|
|
29
23
|
// agent-gui/agentGuiNode/agentRichText/AgentMentionNodeView.tsx
|
|
30
24
|
import {
|
|
@@ -50,12 +44,6 @@ function parseFileCountAttr(value) {
|
|
|
50
44
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
51
45
|
}
|
|
52
46
|
var AgentMentionTooltipProviderContext = createContext(true);
|
|
53
|
-
function AgentMentionTooltipProviderScope({
|
|
54
|
-
children,
|
|
55
|
-
withTooltipProvider
|
|
56
|
-
}) {
|
|
57
|
-
return /* @__PURE__ */ jsx(AgentMentionTooltipProviderContext, { value: withTooltipProvider, children });
|
|
58
|
-
}
|
|
59
47
|
function attrString(attrs, key) {
|
|
60
48
|
const value = attrs[key];
|
|
61
49
|
return typeof value === "string" ? value : "";
|
|
@@ -569,494 +557,190 @@ function AgentMentionNodeView(props) {
|
|
|
569
557
|
);
|
|
570
558
|
}
|
|
571
559
|
|
|
572
|
-
// agent-gui/agentGuiNode/agentRichText/
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
560
|
+
// agent-gui/agentGuiNode/agentRichText/agentMentionMarkdown.ts
|
|
561
|
+
import {
|
|
562
|
+
createRichTextLinkMarkdown,
|
|
563
|
+
createRichTextMarkdownLink,
|
|
564
|
+
createRichTextMentionHref,
|
|
565
|
+
createRichTextMentionMarkdown,
|
|
566
|
+
isRichTextMentionHref,
|
|
567
|
+
parseRichTextMentionHref
|
|
568
|
+
} from "@tutti-os/ui-rich-text/core";
|
|
569
|
+
function dirnameFromPath2(path) {
|
|
570
|
+
const parts = path.split("/").filter(Boolean);
|
|
571
|
+
if (parts.length <= 1) {
|
|
572
|
+
return path.startsWith("/") ? "/" : "";
|
|
573
|
+
}
|
|
574
|
+
return `/${parts.slice(0, -1).join("/")}`;
|
|
578
575
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
let open = -1;
|
|
595
|
-
for (let index = fromOffset - 1; index >= 0; index -= 1) {
|
|
596
|
-
const char = blockText[index];
|
|
597
|
-
if (char === "}") {
|
|
598
|
-
return range;
|
|
576
|
+
function normalizeAgentSessionMentionTitle(value) {
|
|
577
|
+
const trimmed = value.trim();
|
|
578
|
+
const withoutMentionPrefix = trimmed.replace(/^@+/, "").trim();
|
|
579
|
+
return withoutMentionPrefix || trimmed;
|
|
580
|
+
}
|
|
581
|
+
function createAgentSessionMentionHref(input) {
|
|
582
|
+
const label = normalizeAgentSessionMarkdownLabel(input.label);
|
|
583
|
+
const agentTargetId = input.agentTargetId?.trim() ?? "";
|
|
584
|
+
return createRichTextMentionHref({
|
|
585
|
+
providerId: "agent-session",
|
|
586
|
+
entityId: input.agentSessionId,
|
|
587
|
+
label,
|
|
588
|
+
scope: {
|
|
589
|
+
...agentTargetId ? { agentTargetId } : {},
|
|
590
|
+
workspaceId: input.workspaceId
|
|
599
591
|
}
|
|
600
|
-
|
|
601
|
-
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
function createAgentSessionMarkdownLink(input) {
|
|
595
|
+
const label = normalizeAgentSessionMarkdownLabel(input.label);
|
|
596
|
+
const href = createAgentSessionMentionHref({
|
|
597
|
+
agentSessionId: input.agentSessionId,
|
|
598
|
+
agentTargetId: input.agentTargetId,
|
|
599
|
+
label,
|
|
600
|
+
workspaceId: input.workspaceId
|
|
601
|
+
});
|
|
602
|
+
return createRichTextMarkdownLink({
|
|
603
|
+
href,
|
|
604
|
+
label: input.withAtPrefix ? `@${label}` : label
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function formatAgentMentionMarkdown(item) {
|
|
608
|
+
if (item.kind === "file") {
|
|
609
|
+
const label = item.name.trim().startsWith("@") ? item.name : `@${item.name}`;
|
|
610
|
+
return createRichTextLinkMarkdown({
|
|
611
|
+
kind: "file",
|
|
612
|
+
name: label,
|
|
613
|
+
path: item.href
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
if (item.kind === "workspace-reference") {
|
|
617
|
+
return createRichTextMentionMarkdown({
|
|
618
|
+
providerId: "workspace-reference",
|
|
619
|
+
entityId: item.targetId,
|
|
620
|
+
label: item.name,
|
|
621
|
+
scope: {
|
|
622
|
+
workspaceId: item.workspaceId,
|
|
623
|
+
source: item.source,
|
|
624
|
+
...item.groupId?.trim() ? { groupId: item.groupId.trim() } : {},
|
|
625
|
+
...item.fileCount > 0 ? { count: String(item.fileCount) } : {}
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
if (item.kind === "session") {
|
|
630
|
+
return createAgentSessionMarkdownLink({
|
|
631
|
+
agentSessionId: item.targetId,
|
|
632
|
+
agentTargetId: item.agentTargetId ?? agentSessionTargetIdFromHref(item.href),
|
|
633
|
+
label: item.name,
|
|
634
|
+
workspaceId: item.workspaceId,
|
|
635
|
+
withAtPrefix: true
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
if (item.kind === "agent-target") {
|
|
639
|
+
return createRichTextMentionMarkdown({
|
|
640
|
+
providerId: "agent-target",
|
|
641
|
+
entityId: item.targetId,
|
|
642
|
+
label: item.name,
|
|
643
|
+
scope: { workspaceId: item.workspaceId }
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
const identity = parseRichTextMentionHref(item.href, item.name);
|
|
647
|
+
return identity ? createRichTextMentionMarkdown(identity) : "";
|
|
648
|
+
}
|
|
649
|
+
function normalizeAgentSessionMarkdownLabel(value) {
|
|
650
|
+
return value.trim().replace(/^@+/, "").trim();
|
|
651
|
+
}
|
|
652
|
+
function agentSessionTargetIdFromHref(href) {
|
|
653
|
+
const mention = parseRichTextMentionHref(href, "");
|
|
654
|
+
const agentTargetId = mention?.scope?.agentTargetId?.trim() ?? "";
|
|
655
|
+
return agentTargetId || void 0;
|
|
656
|
+
}
|
|
657
|
+
function parseMentionFileCount(value) {
|
|
658
|
+
const parsed = typeof value === "number" ? value : typeof value === "string" ? Number.parseInt(value.trim(), 10) : Number.NaN;
|
|
659
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
660
|
+
}
|
|
661
|
+
function parseAgentMentionMarkdown(value, start = 0) {
|
|
662
|
+
if (!value.startsWith("[", start)) {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
let index = start + 1;
|
|
666
|
+
const prefixedMention = value[index] === "@";
|
|
667
|
+
if (prefixedMention) {
|
|
668
|
+
index += 1;
|
|
669
|
+
}
|
|
670
|
+
let name = "";
|
|
671
|
+
while (index < value.length) {
|
|
672
|
+
const current = value[index];
|
|
673
|
+
if (current === "\\") {
|
|
674
|
+
const escaped = value[index + 1];
|
|
675
|
+
if (escaped === "\\" || escaped === "[" || escaped === "]") {
|
|
676
|
+
name += escaped;
|
|
677
|
+
index += 2;
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
name += current;
|
|
681
|
+
index += 1;
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
if (current === "]") {
|
|
602
685
|
break;
|
|
603
686
|
}
|
|
687
|
+
name += current;
|
|
688
|
+
index += 1;
|
|
604
689
|
}
|
|
605
|
-
if (
|
|
606
|
-
return
|
|
690
|
+
if (value[index] !== "]" || value[index + 1] !== "(") {
|
|
691
|
+
return null;
|
|
607
692
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
693
|
+
index += 2;
|
|
694
|
+
let href = "";
|
|
695
|
+
while (index < value.length) {
|
|
696
|
+
const current = value[index];
|
|
697
|
+
if (current === "\\") {
|
|
698
|
+
const escaped = value[index + 1];
|
|
699
|
+
if (escaped === "\\" || escaped === ")") {
|
|
700
|
+
href += escaped;
|
|
701
|
+
index += 2;
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
href += current;
|
|
705
|
+
index += 1;
|
|
706
|
+
continue;
|
|
613
707
|
}
|
|
614
|
-
if (
|
|
615
|
-
|
|
616
|
-
|
|
708
|
+
if (current === ")") {
|
|
709
|
+
const item = parseMentionItemFromHref({ name, href });
|
|
710
|
+
if (!item) {
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
if (item.kind !== "file" && !prefixedMention && !isRichTextMentionHref(href)) {
|
|
714
|
+
return null;
|
|
715
|
+
}
|
|
716
|
+
return {
|
|
717
|
+
item,
|
|
718
|
+
end: index + 1
|
|
719
|
+
};
|
|
617
720
|
}
|
|
721
|
+
href += current;
|
|
722
|
+
index += 1;
|
|
618
723
|
}
|
|
619
|
-
|
|
620
|
-
|
|
724
|
+
return null;
|
|
725
|
+
}
|
|
726
|
+
function parseMentionItemFromHref(input) {
|
|
727
|
+
const href = input.href.trim();
|
|
728
|
+
if (!href) {
|
|
729
|
+
return null;
|
|
621
730
|
}
|
|
622
|
-
const
|
|
623
|
-
if (
|
|
624
|
-
return
|
|
731
|
+
const mention = parseRichTextMentionHref(href, input.name);
|
|
732
|
+
if (!mention && !isRichTextMentionHref(href)) {
|
|
733
|
+
return {
|
|
734
|
+
kind: "file",
|
|
735
|
+
href,
|
|
736
|
+
path: href,
|
|
737
|
+
name: input.name,
|
|
738
|
+
entryKind: isLocalDirectoryMentionHref(href) ? "directory" : "unknown",
|
|
739
|
+
directoryPath: dirnameFromPath2(href)
|
|
740
|
+
};
|
|
625
741
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
end += 1;
|
|
629
|
-
}
|
|
630
|
-
return { from: blockStart + open, to: blockStart + end };
|
|
631
|
-
}
|
|
632
|
-
function createAgentFileMentionExtension(options = {}) {
|
|
633
|
-
return Node.create({
|
|
634
|
-
name: "agentFileMention",
|
|
635
|
-
group: "inline",
|
|
636
|
-
inline: true,
|
|
637
|
-
atom: true,
|
|
638
|
-
selectable: false,
|
|
639
|
-
addOptions() {
|
|
640
|
-
return options;
|
|
641
|
-
},
|
|
642
|
-
addAttributes() {
|
|
643
|
-
return {
|
|
644
|
-
name: { default: "" },
|
|
645
|
-
kind: { default: "file" },
|
|
646
|
-
href: { default: "" },
|
|
647
|
-
path: { default: "" },
|
|
648
|
-
entryKind: { default: "unknown" },
|
|
649
|
-
directoryPath: { default: "" },
|
|
650
|
-
workspaceId: { default: "" },
|
|
651
|
-
targetId: { default: "" },
|
|
652
|
-
agentTargetId: { default: "" },
|
|
653
|
-
scope: { default: "" },
|
|
654
|
-
title: { default: "" },
|
|
655
|
-
initiatorName: { default: "" },
|
|
656
|
-
agentName: { default: "" },
|
|
657
|
-
status: { default: "" },
|
|
658
|
-
inputPreview: { default: "" },
|
|
659
|
-
summaryPreview: { default: "" },
|
|
660
|
-
creatorName: { default: "" },
|
|
661
|
-
topicId: { default: "" },
|
|
662
|
-
appId: { default: "" },
|
|
663
|
-
agentProviderId: { default: "" },
|
|
664
|
-
jobId: { default: "" },
|
|
665
|
-
action: { default: "" },
|
|
666
|
-
contextPath: { default: "" },
|
|
667
|
-
description: { default: "" },
|
|
668
|
-
iconUrl: { default: "" },
|
|
669
|
-
contentPreview: { default: "" },
|
|
670
|
-
thumbnailUrl: { default: "" },
|
|
671
|
-
source: { default: "" },
|
|
672
|
-
groupId: { default: "" },
|
|
673
|
-
fileCount: { default: "" },
|
|
674
|
-
customKind: { default: "" },
|
|
675
|
-
preview: { default: "" }
|
|
676
|
-
};
|
|
677
|
-
},
|
|
678
|
-
parseHTML() {
|
|
679
|
-
return [
|
|
680
|
-
{
|
|
681
|
-
tag: "span[data-agent-file-mention]",
|
|
682
|
-
getAttrs: parseAgentMentionHTMLElementAttrs
|
|
683
|
-
},
|
|
684
|
-
{
|
|
685
|
-
tag: "a[data-agent-file-mention]",
|
|
686
|
-
getAttrs: parseAgentMentionHTMLElementAttrs
|
|
687
|
-
}
|
|
688
|
-
];
|
|
689
|
-
},
|
|
690
|
-
renderHTML({ HTMLAttributes }) {
|
|
691
|
-
const item = attrsToMentionItem(HTMLAttributes);
|
|
692
|
-
const fileThumbnailUrl = item.kind === "file" ? resolveAgentMentionFileThumbnailUrl(item) : void 0;
|
|
693
|
-
const href = item.href;
|
|
694
|
-
const tagName = options.renderAsLink ? "a" : "span";
|
|
695
|
-
const visual = mentionVisual(item);
|
|
696
|
-
const sessionVisual = item.kind === "session" ? sessionMentionVisual(item) : null;
|
|
697
|
-
const sharedAttributes = {
|
|
698
|
-
"data-agent-file-mention": "true",
|
|
699
|
-
"data-agent-mention-href": href,
|
|
700
|
-
"data-agent-mention-kind": item.kind,
|
|
701
|
-
"aria-label": item.kind === "file" ? visual.primary : `${visual.kindLabel} ${visual.primary}`.trim()
|
|
702
|
-
};
|
|
703
|
-
return [
|
|
704
|
-
tagName,
|
|
705
|
-
mergeAttributes(HTMLAttributes, {
|
|
706
|
-
...sharedAttributes,
|
|
707
|
-
...item.kind === "file" ? {
|
|
708
|
-
"data-agent-file-entry-kind": item.entryKind,
|
|
709
|
-
"data-agent-file-directory-path": item.directoryPath,
|
|
710
|
-
"data-agent-file-visual-kind": resolveAgentMentionFileVisualKind(item)
|
|
711
|
-
} : {},
|
|
712
|
-
...options.renderAsLink ? { href } : {},
|
|
713
|
-
...(item.kind === "workspace-app" || item.kind === "agent-target" || item.kind === "workspace-reference") && item.iconUrl ? { "data-agent-mention-icon-url": item.iconUrl } : {},
|
|
714
|
-
...item.kind === "workspace-reference" ? { "data-agent-mention-file-count": String(item.fileCount) } : {},
|
|
715
|
-
...fileThumbnailUrl ? { "data-agent-mention-thumbnail-url": fileThumbnailUrl } : {},
|
|
716
|
-
class: item.kind === "file" ? "tsh-agent-object-token tsh-agent-object-token--file" : "tsh-agent-object-token tsh-agent-object-token--entity"
|
|
717
|
-
}),
|
|
718
|
-
...item.kind === "file" ? [
|
|
719
|
-
fileThumbnailUrl ? [
|
|
720
|
-
"span",
|
|
721
|
-
{
|
|
722
|
-
class: "agent-gui-node__mention-file-thumb",
|
|
723
|
-
"data-agent-mention-file-thumb": "true",
|
|
724
|
-
"aria-hidden": "true"
|
|
725
|
-
},
|
|
726
|
-
[
|
|
727
|
-
"img",
|
|
728
|
-
{
|
|
729
|
-
src: fileThumbnailUrl,
|
|
730
|
-
alt: "",
|
|
731
|
-
decoding: "async",
|
|
732
|
-
loading: "lazy",
|
|
733
|
-
draggable: "false"
|
|
734
|
-
}
|
|
735
|
-
]
|
|
736
|
-
] : [
|
|
737
|
-
"span",
|
|
738
|
-
{
|
|
739
|
-
class: "tsh-agent-object-token__icon",
|
|
740
|
-
"aria-hidden": "true"
|
|
741
|
-
},
|
|
742
|
-
""
|
|
743
|
-
],
|
|
744
|
-
[
|
|
745
|
-
"span",
|
|
746
|
-
{ class: "tsh-agent-object-token__main" },
|
|
747
|
-
visual.primary
|
|
748
|
-
]
|
|
749
|
-
] : item.kind === "session" ? [
|
|
750
|
-
[
|
|
751
|
-
"span",
|
|
752
|
-
{
|
|
753
|
-
class: "tsh-agent-object-token__kind",
|
|
754
|
-
"aria-hidden": "true"
|
|
755
|
-
},
|
|
756
|
-
[
|
|
757
|
-
"span",
|
|
758
|
-
{
|
|
759
|
-
class: "tsh-agent-object-token__kind-icon",
|
|
760
|
-
"aria-hidden": "true"
|
|
761
|
-
},
|
|
762
|
-
""
|
|
763
|
-
]
|
|
764
|
-
],
|
|
765
|
-
[
|
|
766
|
-
"span",
|
|
767
|
-
{ class: "tsh-agent-object-token__main" },
|
|
768
|
-
[
|
|
769
|
-
"span",
|
|
770
|
-
{ class: "tsh-agent-object-token__participant" },
|
|
771
|
-
sessionVisual?.participant ?? ""
|
|
772
|
-
],
|
|
773
|
-
[
|
|
774
|
-
"span",
|
|
775
|
-
{ class: "tsh-agent-object-token__summary" },
|
|
776
|
-
sessionVisual?.summary ? ` ${sessionVisual.summary}` : ""
|
|
777
|
-
]
|
|
778
|
-
]
|
|
779
|
-
] : [
|
|
780
|
-
[
|
|
781
|
-
"span",
|
|
782
|
-
{
|
|
783
|
-
class: "tsh-agent-object-token__kind",
|
|
784
|
-
"aria-hidden": "true"
|
|
785
|
-
},
|
|
786
|
-
[
|
|
787
|
-
"span",
|
|
788
|
-
{
|
|
789
|
-
class: "tsh-agent-object-token__kind-icon",
|
|
790
|
-
"aria-hidden": "true"
|
|
791
|
-
},
|
|
792
|
-
""
|
|
793
|
-
]
|
|
794
|
-
],
|
|
795
|
-
[
|
|
796
|
-
"span",
|
|
797
|
-
{ class: "tsh-agent-object-token__main" },
|
|
798
|
-
visual.primary
|
|
799
|
-
]
|
|
800
|
-
]
|
|
801
|
-
];
|
|
802
|
-
},
|
|
803
|
-
renderText({ node }) {
|
|
804
|
-
return formatAgentMentionMarkdown(attrsToMentionItem(node.attrs ?? {}));
|
|
805
|
-
},
|
|
806
|
-
addNodeView() {
|
|
807
|
-
return ReactNodeViewRenderer(AgentMentionNodeView);
|
|
808
|
-
},
|
|
809
|
-
addProseMirrorPlugins() {
|
|
810
|
-
if (options.enableSuggestions === false) {
|
|
811
|
-
return [];
|
|
812
|
-
}
|
|
813
|
-
return [
|
|
814
|
-
Suggestion({
|
|
815
|
-
editor: this.editor,
|
|
816
|
-
pluginKey: agentFileMentionPluginKey,
|
|
817
|
-
char: "@",
|
|
818
|
-
allowedPrefixes: [" ", "\n", " "],
|
|
819
|
-
allowSpaces: true,
|
|
820
|
-
items: () => [],
|
|
821
|
-
allow: ({ state, range }) => {
|
|
822
|
-
if (options.shouldSuppressSuggestion?.()) {
|
|
823
|
-
return false;
|
|
824
|
-
}
|
|
825
|
-
if (range.from <= 1) {
|
|
826
|
-
return true;
|
|
827
|
-
}
|
|
828
|
-
const previous = state.doc.textBetween(
|
|
829
|
-
range.from - 1,
|
|
830
|
-
range.from,
|
|
831
|
-
"\n",
|
|
832
|
-
"\n"
|
|
833
|
-
);
|
|
834
|
-
return isRichTextTriggerPrefixBoundary(previous, "whitespace");
|
|
835
|
-
},
|
|
836
|
-
command: ({ editor, range, props }) => {
|
|
837
|
-
const insertRange = expandRangeOverMentionPlaceholder(
|
|
838
|
-
editor,
|
|
839
|
-
range
|
|
840
|
-
);
|
|
841
|
-
const prefixCaretAnchor = insertRange.from <= 1 || editor.state.doc.textBetween(
|
|
842
|
-
Math.max(1, insertRange.from - 1),
|
|
843
|
-
insertRange.from,
|
|
844
|
-
"\n",
|
|
845
|
-
"\n"
|
|
846
|
-
) === "\n";
|
|
847
|
-
editor.chain().focus().insertContentAt(insertRange, [
|
|
848
|
-
...prefixCaretAnchor ? [
|
|
849
|
-
{
|
|
850
|
-
type: "text",
|
|
851
|
-
text: AGENT_RICH_TEXT_CARET_ANCHOR
|
|
852
|
-
}
|
|
853
|
-
] : [],
|
|
854
|
-
{
|
|
855
|
-
type: this.name,
|
|
856
|
-
attrs: mentionItemToAttrs(props)
|
|
857
|
-
},
|
|
858
|
-
{ type: "text", text: " " }
|
|
859
|
-
]).run();
|
|
860
|
-
},
|
|
861
|
-
render: () => ({
|
|
862
|
-
onStart: (props) => {
|
|
863
|
-
options.onSuggestionChange?.({
|
|
864
|
-
editor: props.editor,
|
|
865
|
-
range: props.range,
|
|
866
|
-
query: props.query,
|
|
867
|
-
text: props.text,
|
|
868
|
-
command: props.command,
|
|
869
|
-
clientRect: props.clientRect
|
|
870
|
-
});
|
|
871
|
-
},
|
|
872
|
-
onUpdate: (props) => {
|
|
873
|
-
options.onSuggestionChange?.({
|
|
874
|
-
editor: props.editor,
|
|
875
|
-
range: props.range,
|
|
876
|
-
query: props.query,
|
|
877
|
-
text: props.text,
|
|
878
|
-
command: props.command,
|
|
879
|
-
clientRect: props.clientRect
|
|
880
|
-
});
|
|
881
|
-
},
|
|
882
|
-
onExit: () => {
|
|
883
|
-
options.onSuggestionChange?.(null);
|
|
884
|
-
},
|
|
885
|
-
onKeyDown: (props) => options.onSuggestionKeyDown?.(props.event) ?? false
|
|
886
|
-
})
|
|
887
|
-
})
|
|
888
|
-
];
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
function normalizeAgentSessionMentionTitle(value) {
|
|
893
|
-
const trimmed = value.trim();
|
|
894
|
-
const withoutMentionPrefix = trimmed.replace(/^@+/, "").trim();
|
|
895
|
-
return withoutMentionPrefix || trimmed;
|
|
896
|
-
}
|
|
897
|
-
function createAgentSessionMentionHref(input) {
|
|
898
|
-
const label = normalizeAgentSessionMarkdownLabel(input.label);
|
|
899
|
-
const agentTargetId = input.agentTargetId?.trim() ?? "";
|
|
900
|
-
return createRichTextMentionHref({
|
|
901
|
-
providerId: "agent-session",
|
|
902
|
-
entityId: input.agentSessionId,
|
|
903
|
-
label,
|
|
904
|
-
scope: {
|
|
905
|
-
...agentTargetId ? { agentTargetId } : {},
|
|
906
|
-
workspaceId: input.workspaceId
|
|
907
|
-
}
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
function createAgentSessionMarkdownLink(input) {
|
|
911
|
-
const label = normalizeAgentSessionMarkdownLabel(input.label);
|
|
912
|
-
const href = createAgentSessionMentionHref({
|
|
913
|
-
agentSessionId: input.agentSessionId,
|
|
914
|
-
agentTargetId: input.agentTargetId,
|
|
915
|
-
label,
|
|
916
|
-
workspaceId: input.workspaceId
|
|
917
|
-
});
|
|
918
|
-
return createRichTextMarkdownLink({
|
|
919
|
-
href,
|
|
920
|
-
label: input.withAtPrefix ? `@${label}` : label
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
function formatAgentMentionMarkdown(item) {
|
|
924
|
-
if (item.kind === "file") {
|
|
925
|
-
const label = item.name.trim().startsWith("@") ? item.name : `@${item.name}`;
|
|
926
|
-
return createRichTextLinkMarkdown({
|
|
927
|
-
kind: "file",
|
|
928
|
-
name: label,
|
|
929
|
-
path: item.href
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
if (item.kind === "workspace-reference") {
|
|
933
|
-
return createRichTextMentionMarkdown({
|
|
934
|
-
providerId: "workspace-reference",
|
|
935
|
-
entityId: item.targetId,
|
|
936
|
-
label: item.name,
|
|
937
|
-
scope: {
|
|
938
|
-
workspaceId: item.workspaceId,
|
|
939
|
-
source: item.source,
|
|
940
|
-
...item.groupId?.trim() ? { groupId: item.groupId.trim() } : {},
|
|
941
|
-
...item.fileCount > 0 ? { count: String(item.fileCount) } : {}
|
|
942
|
-
}
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
if (item.kind === "session") {
|
|
946
|
-
return createAgentSessionMarkdownLink({
|
|
947
|
-
agentSessionId: item.targetId,
|
|
948
|
-
agentTargetId: item.agentTargetId ?? agentSessionTargetIdFromHref(item.href),
|
|
949
|
-
label: item.name,
|
|
950
|
-
workspaceId: item.workspaceId,
|
|
951
|
-
withAtPrefix: true
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
if (item.kind === "agent-target") {
|
|
955
|
-
return createRichTextMentionMarkdown({
|
|
956
|
-
providerId: "agent-target",
|
|
957
|
-
entityId: item.targetId,
|
|
958
|
-
label: item.name,
|
|
959
|
-
scope: { workspaceId: item.workspaceId }
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
const identity = parseRichTextMentionHref(item.href, item.name);
|
|
963
|
-
return identity ? createRichTextMentionMarkdown(identity) : "";
|
|
964
|
-
}
|
|
965
|
-
function normalizeAgentSessionMarkdownLabel(value) {
|
|
966
|
-
return value.trim().replace(/^@+/, "").trim();
|
|
967
|
-
}
|
|
968
|
-
function agentSessionTargetIdFromHref(href) {
|
|
969
|
-
const mention = parseRichTextMentionHref(href, "");
|
|
970
|
-
const agentTargetId = mention?.scope?.agentTargetId?.trim() ?? "";
|
|
971
|
-
return agentTargetId || void 0;
|
|
972
|
-
}
|
|
973
|
-
function parseMentionFileCount(value) {
|
|
974
|
-
const parsed = typeof value === "number" ? value : typeof value === "string" ? Number.parseInt(value.trim(), 10) : Number.NaN;
|
|
975
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
976
|
-
}
|
|
977
|
-
function parseAgentMentionMarkdown(value, start = 0) {
|
|
978
|
-
if (!value.startsWith("[", start)) {
|
|
979
|
-
return null;
|
|
980
|
-
}
|
|
981
|
-
let index = start + 1;
|
|
982
|
-
const prefixedMention = value[index] === "@";
|
|
983
|
-
if (prefixedMention) {
|
|
984
|
-
index += 1;
|
|
985
|
-
}
|
|
986
|
-
let name = "";
|
|
987
|
-
while (index < value.length) {
|
|
988
|
-
const current = value[index];
|
|
989
|
-
if (current === "\\") {
|
|
990
|
-
const escaped = value[index + 1];
|
|
991
|
-
if (escaped === "\\" || escaped === "[" || escaped === "]") {
|
|
992
|
-
name += escaped;
|
|
993
|
-
index += 2;
|
|
994
|
-
continue;
|
|
995
|
-
}
|
|
996
|
-
name += current;
|
|
997
|
-
index += 1;
|
|
998
|
-
continue;
|
|
999
|
-
}
|
|
1000
|
-
if (current === "]") {
|
|
1001
|
-
break;
|
|
1002
|
-
}
|
|
1003
|
-
name += current;
|
|
1004
|
-
index += 1;
|
|
1005
|
-
}
|
|
1006
|
-
if (value[index] !== "]" || value[index + 1] !== "(") {
|
|
1007
|
-
return null;
|
|
1008
|
-
}
|
|
1009
|
-
index += 2;
|
|
1010
|
-
let href = "";
|
|
1011
|
-
while (index < value.length) {
|
|
1012
|
-
const current = value[index];
|
|
1013
|
-
if (current === "\\") {
|
|
1014
|
-
const escaped = value[index + 1];
|
|
1015
|
-
if (escaped === "\\" || escaped === ")") {
|
|
1016
|
-
href += escaped;
|
|
1017
|
-
index += 2;
|
|
1018
|
-
continue;
|
|
1019
|
-
}
|
|
1020
|
-
href += current;
|
|
1021
|
-
index += 1;
|
|
1022
|
-
continue;
|
|
1023
|
-
}
|
|
1024
|
-
if (current === ")") {
|
|
1025
|
-
const item = parseMentionItemFromHref({ name, href });
|
|
1026
|
-
if (!item) {
|
|
1027
|
-
return null;
|
|
1028
|
-
}
|
|
1029
|
-
if (item.kind !== "file" && !prefixedMention && !isRichTextMentionHref(href)) {
|
|
1030
|
-
return null;
|
|
1031
|
-
}
|
|
1032
|
-
return {
|
|
1033
|
-
item,
|
|
1034
|
-
end: index + 1
|
|
1035
|
-
};
|
|
1036
|
-
}
|
|
1037
|
-
href += current;
|
|
1038
|
-
index += 1;
|
|
1039
|
-
}
|
|
1040
|
-
return null;
|
|
1041
|
-
}
|
|
1042
|
-
function parseMentionItemFromHref(input) {
|
|
1043
|
-
const href = input.href.trim();
|
|
1044
|
-
if (!href) {
|
|
1045
|
-
return null;
|
|
1046
|
-
}
|
|
1047
|
-
const mention = parseRichTextMentionHref(href, input.name);
|
|
1048
|
-
if (!mention && !isRichTextMentionHref(href)) {
|
|
1049
|
-
return {
|
|
1050
|
-
kind: "file",
|
|
1051
|
-
href,
|
|
1052
|
-
path: href,
|
|
1053
|
-
name: input.name,
|
|
1054
|
-
entryKind: isLocalDirectoryMentionHref(href) ? "directory" : "unknown",
|
|
1055
|
-
directoryPath: dirnameFromPath2(href)
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
if (!mention) {
|
|
1059
|
-
return null;
|
|
742
|
+
if (!mention) {
|
|
743
|
+
return null;
|
|
1060
744
|
}
|
|
1061
745
|
const resource = mention.providerId.trim().toLowerCase();
|
|
1062
746
|
const targetId = mention.entityId.trim();
|
|
@@ -1172,6 +856,8 @@ function parseMentionItemFromHref(input) {
|
|
|
1172
856
|
function isLocalDirectoryMentionHref(href) {
|
|
1173
857
|
return href.endsWith("/") && !/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(href);
|
|
1174
858
|
}
|
|
859
|
+
|
|
860
|
+
// agent-gui/agentGuiNode/agentRichText/agentMentionAttrs.ts
|
|
1175
861
|
function mentionItemToAttrs(item) {
|
|
1176
862
|
if (item.kind === "file") {
|
|
1177
863
|
return {
|
|
@@ -1464,6 +1150,8 @@ function normalizeMentionKind(value) {
|
|
|
1464
1150
|
function normalizeEntryKind(value) {
|
|
1465
1151
|
return value === "directory" || value === "file" ? value : "unknown";
|
|
1466
1152
|
}
|
|
1153
|
+
|
|
1154
|
+
// agent-gui/agentGuiNode/agentRichText/agentMentionPresentation.ts
|
|
1467
1155
|
function mentionVisual(item) {
|
|
1468
1156
|
if (item.kind === "file") {
|
|
1469
1157
|
return {
|
|
@@ -1546,19 +1234,330 @@ function parseDottedSessionMentionText(value) {
|
|
|
1546
1234
|
summary: normalizeAgentSessionMentionTitle(parts.slice(2).join(" "))
|
|
1547
1235
|
};
|
|
1548
1236
|
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1237
|
+
|
|
1238
|
+
// agent-gui/agentGuiNode/agentRichText/agentFileMentionExtension.ts
|
|
1239
|
+
var agentFileMentionPluginKey = new PluginKey(
|
|
1240
|
+
"agentFileMentionSuggestion"
|
|
1241
|
+
);
|
|
1242
|
+
function exitAgentFileMentionSuggestion(editor) {
|
|
1243
|
+
exitSuggestion(editor.view, agentFileMentionPluginKey);
|
|
1244
|
+
}
|
|
1245
|
+
var MENTION_PLACEHOLDER_LEAF_SENTINEL = "\uFFFC";
|
|
1246
|
+
var MENTION_PLACEHOLDER_MAX_LENGTH = 40;
|
|
1247
|
+
function expandRangeOverMentionPlaceholder(editor, range) {
|
|
1248
|
+
const { doc } = editor.state;
|
|
1249
|
+
const $from = doc.resolve(range.from);
|
|
1250
|
+
const blockStart = $from.start();
|
|
1251
|
+
const blockEnd = $from.end();
|
|
1252
|
+
const blockText = doc.textBetween(
|
|
1253
|
+
blockStart,
|
|
1254
|
+
blockEnd,
|
|
1255
|
+
"\n",
|
|
1256
|
+
MENTION_PLACEHOLDER_LEAF_SENTINEL
|
|
1257
|
+
);
|
|
1258
|
+
const fromOffset = range.from - blockStart;
|
|
1259
|
+
const toOffset = Math.min(range.to, blockEnd) - blockStart;
|
|
1260
|
+
let open = -1;
|
|
1261
|
+
for (let index = fromOffset - 1; index >= 0; index -= 1) {
|
|
1262
|
+
const char = blockText[index];
|
|
1263
|
+
if (char === "}") {
|
|
1264
|
+
return range;
|
|
1265
|
+
}
|
|
1266
|
+
if (char === "{") {
|
|
1267
|
+
open = index;
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1553
1270
|
}
|
|
1554
|
-
|
|
1271
|
+
if (open < 0) {
|
|
1272
|
+
return range;
|
|
1273
|
+
}
|
|
1274
|
+
let close = -1;
|
|
1275
|
+
for (let index = toOffset; index < blockText.length; index += 1) {
|
|
1276
|
+
const char = blockText[index];
|
|
1277
|
+
if (char === "{") {
|
|
1278
|
+
return range;
|
|
1279
|
+
}
|
|
1280
|
+
if (char === "}") {
|
|
1281
|
+
close = index;
|
|
1282
|
+
break;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
if (close < 0) {
|
|
1286
|
+
return range;
|
|
1287
|
+
}
|
|
1288
|
+
const group = blockText.slice(open, close + 1);
|
|
1289
|
+
if (close - open > MENTION_PLACEHOLDER_MAX_LENGTH || group.includes("\n") || group.includes(MENTION_PLACEHOLDER_LEAF_SENTINEL)) {
|
|
1290
|
+
return range;
|
|
1291
|
+
}
|
|
1292
|
+
let end = close + 1;
|
|
1293
|
+
if (blockText[end] === " " || blockText[end] === " ") {
|
|
1294
|
+
end += 1;
|
|
1295
|
+
}
|
|
1296
|
+
return { from: blockStart + open, to: blockStart + end };
|
|
1297
|
+
}
|
|
1298
|
+
function createAgentFileMentionExtension(options = {}) {
|
|
1299
|
+
return Node.create({
|
|
1300
|
+
name: "agentFileMention",
|
|
1301
|
+
group: "inline",
|
|
1302
|
+
inline: true,
|
|
1303
|
+
atom: true,
|
|
1304
|
+
selectable: false,
|
|
1305
|
+
addOptions() {
|
|
1306
|
+
return options;
|
|
1307
|
+
},
|
|
1308
|
+
addAttributes() {
|
|
1309
|
+
return {
|
|
1310
|
+
name: { default: "" },
|
|
1311
|
+
kind: { default: "file" },
|
|
1312
|
+
href: { default: "" },
|
|
1313
|
+
path: { default: "" },
|
|
1314
|
+
entryKind: { default: "unknown" },
|
|
1315
|
+
directoryPath: { default: "" },
|
|
1316
|
+
workspaceId: { default: "" },
|
|
1317
|
+
targetId: { default: "" },
|
|
1318
|
+
agentTargetId: { default: "" },
|
|
1319
|
+
scope: { default: "" },
|
|
1320
|
+
title: { default: "" },
|
|
1321
|
+
initiatorName: { default: "" },
|
|
1322
|
+
agentName: { default: "" },
|
|
1323
|
+
status: { default: "" },
|
|
1324
|
+
inputPreview: { default: "" },
|
|
1325
|
+
summaryPreview: { default: "" },
|
|
1326
|
+
creatorName: { default: "" },
|
|
1327
|
+
topicId: { default: "" },
|
|
1328
|
+
appId: { default: "" },
|
|
1329
|
+
agentProviderId: { default: "" },
|
|
1330
|
+
jobId: { default: "" },
|
|
1331
|
+
action: { default: "" },
|
|
1332
|
+
contextPath: { default: "" },
|
|
1333
|
+
description: { default: "" },
|
|
1334
|
+
iconUrl: { default: "" },
|
|
1335
|
+
contentPreview: { default: "" },
|
|
1336
|
+
thumbnailUrl: { default: "" },
|
|
1337
|
+
source: { default: "" },
|
|
1338
|
+
groupId: { default: "" },
|
|
1339
|
+
fileCount: { default: "" },
|
|
1340
|
+
customKind: { default: "" },
|
|
1341
|
+
preview: { default: "" }
|
|
1342
|
+
};
|
|
1343
|
+
},
|
|
1344
|
+
parseHTML() {
|
|
1345
|
+
return [
|
|
1346
|
+
{
|
|
1347
|
+
tag: "span[data-agent-file-mention]",
|
|
1348
|
+
getAttrs: parseAgentMentionHTMLElementAttrs
|
|
1349
|
+
},
|
|
1350
|
+
{
|
|
1351
|
+
tag: "a[data-agent-file-mention]",
|
|
1352
|
+
getAttrs: parseAgentMentionHTMLElementAttrs
|
|
1353
|
+
}
|
|
1354
|
+
];
|
|
1355
|
+
},
|
|
1356
|
+
renderHTML({ HTMLAttributes }) {
|
|
1357
|
+
const item = attrsToMentionItem(HTMLAttributes);
|
|
1358
|
+
const fileThumbnailUrl = item.kind === "file" ? resolveAgentMentionFileThumbnailUrl(item) : void 0;
|
|
1359
|
+
const href = item.href;
|
|
1360
|
+
const tagName = options.renderAsLink ? "a" : "span";
|
|
1361
|
+
const visual = mentionVisual(item);
|
|
1362
|
+
const sessionVisual = item.kind === "session" ? sessionMentionVisual(item) : null;
|
|
1363
|
+
const sharedAttributes = {
|
|
1364
|
+
"data-agent-file-mention": "true",
|
|
1365
|
+
"data-agent-mention-href": href,
|
|
1366
|
+
"data-agent-mention-kind": item.kind,
|
|
1367
|
+
"aria-label": item.kind === "file" ? visual.primary : `${visual.kindLabel} ${visual.primary}`.trim()
|
|
1368
|
+
};
|
|
1369
|
+
return [
|
|
1370
|
+
tagName,
|
|
1371
|
+
mergeAttributes(HTMLAttributes, {
|
|
1372
|
+
...sharedAttributes,
|
|
1373
|
+
...item.kind === "file" ? {
|
|
1374
|
+
"data-agent-file-entry-kind": item.entryKind,
|
|
1375
|
+
"data-agent-file-directory-path": item.directoryPath,
|
|
1376
|
+
"data-agent-file-visual-kind": resolveAgentMentionFileVisualKind(item)
|
|
1377
|
+
} : {},
|
|
1378
|
+
...options.renderAsLink ? { href } : {},
|
|
1379
|
+
...(item.kind === "workspace-app" || item.kind === "agent-target" || item.kind === "workspace-reference") && item.iconUrl ? { "data-agent-mention-icon-url": item.iconUrl } : {},
|
|
1380
|
+
...item.kind === "workspace-reference" ? { "data-agent-mention-file-count": String(item.fileCount) } : {},
|
|
1381
|
+
...fileThumbnailUrl ? { "data-agent-mention-thumbnail-url": fileThumbnailUrl } : {},
|
|
1382
|
+
class: item.kind === "file" ? "tsh-agent-object-token tsh-agent-object-token--file" : "tsh-agent-object-token tsh-agent-object-token--entity"
|
|
1383
|
+
}),
|
|
1384
|
+
...item.kind === "file" ? [
|
|
1385
|
+
fileThumbnailUrl ? [
|
|
1386
|
+
"span",
|
|
1387
|
+
{
|
|
1388
|
+
class: "agent-gui-node__mention-file-thumb",
|
|
1389
|
+
"data-agent-mention-file-thumb": "true",
|
|
1390
|
+
"aria-hidden": "true"
|
|
1391
|
+
},
|
|
1392
|
+
[
|
|
1393
|
+
"img",
|
|
1394
|
+
{
|
|
1395
|
+
src: fileThumbnailUrl,
|
|
1396
|
+
alt: "",
|
|
1397
|
+
decoding: "async",
|
|
1398
|
+
loading: "lazy",
|
|
1399
|
+
draggable: "false"
|
|
1400
|
+
}
|
|
1401
|
+
]
|
|
1402
|
+
] : [
|
|
1403
|
+
"span",
|
|
1404
|
+
{
|
|
1405
|
+
class: "tsh-agent-object-token__icon",
|
|
1406
|
+
"aria-hidden": "true"
|
|
1407
|
+
},
|
|
1408
|
+
""
|
|
1409
|
+
],
|
|
1410
|
+
[
|
|
1411
|
+
"span",
|
|
1412
|
+
{ class: "tsh-agent-object-token__main" },
|
|
1413
|
+
visual.primary
|
|
1414
|
+
]
|
|
1415
|
+
] : item.kind === "session" ? [
|
|
1416
|
+
[
|
|
1417
|
+
"span",
|
|
1418
|
+
{
|
|
1419
|
+
class: "tsh-agent-object-token__kind",
|
|
1420
|
+
"aria-hidden": "true"
|
|
1421
|
+
},
|
|
1422
|
+
[
|
|
1423
|
+
"span",
|
|
1424
|
+
{
|
|
1425
|
+
class: "tsh-agent-object-token__kind-icon",
|
|
1426
|
+
"aria-hidden": "true"
|
|
1427
|
+
},
|
|
1428
|
+
""
|
|
1429
|
+
]
|
|
1430
|
+
],
|
|
1431
|
+
[
|
|
1432
|
+
"span",
|
|
1433
|
+
{ class: "tsh-agent-object-token__main" },
|
|
1434
|
+
[
|
|
1435
|
+
"span",
|
|
1436
|
+
{ class: "tsh-agent-object-token__participant" },
|
|
1437
|
+
sessionVisual?.participant ?? ""
|
|
1438
|
+
],
|
|
1439
|
+
[
|
|
1440
|
+
"span",
|
|
1441
|
+
{ class: "tsh-agent-object-token__summary" },
|
|
1442
|
+
sessionVisual?.summary ? ` ${sessionVisual.summary}` : ""
|
|
1443
|
+
]
|
|
1444
|
+
]
|
|
1445
|
+
] : [
|
|
1446
|
+
[
|
|
1447
|
+
"span",
|
|
1448
|
+
{
|
|
1449
|
+
class: "tsh-agent-object-token__kind",
|
|
1450
|
+
"aria-hidden": "true"
|
|
1451
|
+
},
|
|
1452
|
+
[
|
|
1453
|
+
"span",
|
|
1454
|
+
{
|
|
1455
|
+
class: "tsh-agent-object-token__kind-icon",
|
|
1456
|
+
"aria-hidden": "true"
|
|
1457
|
+
},
|
|
1458
|
+
""
|
|
1459
|
+
]
|
|
1460
|
+
],
|
|
1461
|
+
[
|
|
1462
|
+
"span",
|
|
1463
|
+
{ class: "tsh-agent-object-token__main" },
|
|
1464
|
+
visual.primary
|
|
1465
|
+
]
|
|
1466
|
+
]
|
|
1467
|
+
];
|
|
1468
|
+
},
|
|
1469
|
+
renderText({ node }) {
|
|
1470
|
+
return formatAgentMentionMarkdown(attrsToMentionItem(node.attrs ?? {}));
|
|
1471
|
+
},
|
|
1472
|
+
addNodeView() {
|
|
1473
|
+
return ReactNodeViewRenderer(AgentMentionNodeView);
|
|
1474
|
+
},
|
|
1475
|
+
addProseMirrorPlugins() {
|
|
1476
|
+
if (options.enableSuggestions === false) {
|
|
1477
|
+
return [];
|
|
1478
|
+
}
|
|
1479
|
+
return [
|
|
1480
|
+
Suggestion({
|
|
1481
|
+
editor: this.editor,
|
|
1482
|
+
pluginKey: agentFileMentionPluginKey,
|
|
1483
|
+
char: "@",
|
|
1484
|
+
allowedPrefixes: [" ", "\n", " "],
|
|
1485
|
+
allowSpaces: true,
|
|
1486
|
+
items: () => [],
|
|
1487
|
+
allow: ({ state, range }) => {
|
|
1488
|
+
if (options.shouldSuppressSuggestion?.()) {
|
|
1489
|
+
return false;
|
|
1490
|
+
}
|
|
1491
|
+
if (range.from <= 1) {
|
|
1492
|
+
return true;
|
|
1493
|
+
}
|
|
1494
|
+
const previous = state.doc.textBetween(
|
|
1495
|
+
range.from - 1,
|
|
1496
|
+
range.from,
|
|
1497
|
+
"\n",
|
|
1498
|
+
"\n"
|
|
1499
|
+
);
|
|
1500
|
+
return isRichTextTriggerPrefixBoundary(previous, "whitespace");
|
|
1501
|
+
},
|
|
1502
|
+
command: ({ editor, range, props }) => {
|
|
1503
|
+
const insertRange = expandRangeOverMentionPlaceholder(
|
|
1504
|
+
editor,
|
|
1505
|
+
range
|
|
1506
|
+
);
|
|
1507
|
+
const prefixCaretAnchor = insertRange.from <= 1 || editor.state.doc.textBetween(
|
|
1508
|
+
Math.max(1, insertRange.from - 1),
|
|
1509
|
+
insertRange.from,
|
|
1510
|
+
"\n",
|
|
1511
|
+
"\n"
|
|
1512
|
+
) === "\n";
|
|
1513
|
+
editor.chain().focus().insertContentAt(insertRange, [
|
|
1514
|
+
...prefixCaretAnchor ? [
|
|
1515
|
+
{
|
|
1516
|
+
type: "text",
|
|
1517
|
+
text: AGENT_RICH_TEXT_CARET_ANCHOR
|
|
1518
|
+
}
|
|
1519
|
+
] : [],
|
|
1520
|
+
{
|
|
1521
|
+
type: this.name,
|
|
1522
|
+
attrs: mentionItemToAttrs(props)
|
|
1523
|
+
},
|
|
1524
|
+
{ type: "text", text: " " }
|
|
1525
|
+
]).run();
|
|
1526
|
+
},
|
|
1527
|
+
render: () => ({
|
|
1528
|
+
onStart: (props) => {
|
|
1529
|
+
options.onSuggestionChange?.({
|
|
1530
|
+
editor: props.editor,
|
|
1531
|
+
range: props.range,
|
|
1532
|
+
query: props.query,
|
|
1533
|
+
text: props.text,
|
|
1534
|
+
command: props.command,
|
|
1535
|
+
clientRect: props.clientRect
|
|
1536
|
+
});
|
|
1537
|
+
},
|
|
1538
|
+
onUpdate: (props) => {
|
|
1539
|
+
options.onSuggestionChange?.({
|
|
1540
|
+
editor: props.editor,
|
|
1541
|
+
range: props.range,
|
|
1542
|
+
query: props.query,
|
|
1543
|
+
text: props.text,
|
|
1544
|
+
command: props.command,
|
|
1545
|
+
clientRect: props.clientRect
|
|
1546
|
+
});
|
|
1547
|
+
},
|
|
1548
|
+
onExit: () => {
|
|
1549
|
+
options.onSuggestionChange?.(null);
|
|
1550
|
+
},
|
|
1551
|
+
onKeyDown: (props) => options.onSuggestionKeyDown?.(props.event) ?? false
|
|
1552
|
+
})
|
|
1553
|
+
})
|
|
1554
|
+
];
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1555
1557
|
}
|
|
1556
1558
|
|
|
1557
1559
|
export {
|
|
1558
1560
|
AGENT_RICH_TEXT_CARET_ANCHOR,
|
|
1559
|
-
AgentMentionTooltipProviderScope,
|
|
1560
|
-
exitAgentFileMentionSuggestion,
|
|
1561
|
-
createAgentFileMentionExtension,
|
|
1562
1561
|
normalizeAgentSessionMentionTitle,
|
|
1563
1562
|
createAgentSessionMentionHref,
|
|
1564
1563
|
createAgentSessionMarkdownLink,
|
|
@@ -1566,6 +1565,8 @@ export {
|
|
|
1566
1565
|
parseAgentMentionMarkdown,
|
|
1567
1566
|
parseMentionItemFromHref,
|
|
1568
1567
|
mentionItemToAttrs,
|
|
1569
|
-
attrsToMentionItem
|
|
1568
|
+
attrsToMentionItem,
|
|
1569
|
+
exitAgentFileMentionSuggestion,
|
|
1570
|
+
createAgentFileMentionExtension
|
|
1570
1571
|
};
|
|
1571
|
-
//# sourceMappingURL=chunk-
|
|
1572
|
+
//# sourceMappingURL=chunk-7PFDA2HQ.js.map
|