@meistrari/chat-nuxt 4.13.0-rc.8 → 4.13.0
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/dist/module.json +1 -1
- package/dist/runtime/embed/components/mobile/chat-mobile-shell.d.vue.ts +2 -2
- package/dist/runtime/embed/components/mobile/chat-mobile-shell.vue.d.ts +2 -2
- package/dist/runtime/files/components/chat-file-reference.vue +5 -2
- package/dist/runtime/files/components/chat-vault-link.vue +1 -1
- package/dist/runtime/files/file-reference.d.ts +7 -0
- package/dist/runtime/files/file-reference.js +8 -0
- package/dist/runtime/messages/components/chat-debug-widget-gallery.vue +13 -3
- package/dist/runtime/messages/tool-registry.js +7 -0
- package/dist/runtime/rendering/debug/widget-gallery.d.ts +2 -0
- package/dist/runtime/rendering/debug/widget-gallery.js +4 -0
- package/dist/runtime/types/schemas/chat/v3-mentions.d.ts +33 -0
- package/dist/runtime/types/schemas/chat/v3-mentions.js +96 -0
- package/dist/runtime/types/schemas/chat/v3.d.ts +494 -6
- package/dist/runtime/types/schemas/chat/v3.js +271 -13
- package/dist/runtime/types/schemas/integrations/agent-events.d.ts +246 -45
- package/dist/runtime/types/schemas/integrations/agent-events.js +101 -5
- package/package.json +2 -2
package/dist/module.json
CHANGED
|
@@ -72,8 +72,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
72
72
|
copyLink: () => any;
|
|
73
73
|
debug: () => any;
|
|
74
74
|
selectConversation: (id: string) => any;
|
|
75
|
-
settings: () => any;
|
|
76
75
|
send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
|
|
76
|
+
settings: () => any;
|
|
77
77
|
newConversation: (groupId?: string | null | undefined) => any;
|
|
78
78
|
selectExecutionProfile: (profile: ChatExecutionProfile) => any;
|
|
79
79
|
tabChange: (tab: TopbarTab) => any;
|
|
@@ -94,8 +94,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
94
94
|
onCopyLink?: (() => any) | undefined;
|
|
95
95
|
onDebug?: (() => any) | undefined;
|
|
96
96
|
onSelectConversation?: ((id: string) => any) | undefined;
|
|
97
|
-
onSettings?: (() => any) | undefined;
|
|
98
97
|
onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
|
|
98
|
+
onSettings?: (() => any) | undefined;
|
|
99
99
|
onNewConversation?: ((groupId?: string | null | undefined) => any) | undefined;
|
|
100
100
|
onSelectExecutionProfile?: ((profile: ChatExecutionProfile) => any) | undefined;
|
|
101
101
|
"onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
|
|
@@ -72,8 +72,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
72
72
|
copyLink: () => any;
|
|
73
73
|
debug: () => any;
|
|
74
74
|
selectConversation: (id: string) => any;
|
|
75
|
-
settings: () => any;
|
|
76
75
|
send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
|
|
76
|
+
settings: () => any;
|
|
77
77
|
newConversation: (groupId?: string | null | undefined) => any;
|
|
78
78
|
selectExecutionProfile: (profile: ChatExecutionProfile) => any;
|
|
79
79
|
tabChange: (tab: TopbarTab) => any;
|
|
@@ -94,8 +94,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
94
94
|
onCopyLink?: (() => any) | undefined;
|
|
95
95
|
onDebug?: (() => any) | undefined;
|
|
96
96
|
onSelectConversation?: ((id: string) => any) | undefined;
|
|
97
|
-
onSettings?: (() => any) | undefined;
|
|
98
97
|
onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
|
|
98
|
+
onSettings?: (() => any) | undefined;
|
|
99
99
|
onNewConversation?: ((groupId?: string | null | undefined) => any) | undefined;
|
|
100
100
|
onSelectExecutionProfile?: ((profile: ChatExecutionProfile) => any) | undefined;
|
|
101
101
|
"onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useFilePreviewPanel } from "../composables/file-preview-panel";
|
|
3
3
|
import { useVault } from "../composables/vault";
|
|
4
|
+
import { fileReferenceMimeType } from "../file-reference";
|
|
4
5
|
import { getFileIcon } from "../icons";
|
|
5
|
-
import { normalizeMimeType } from "../mime";
|
|
6
6
|
import { isVaultPermalink } from "../vault-links";
|
|
7
7
|
const props = defineProps({
|
|
8
8
|
file: { type: Object, required: true },
|
|
@@ -11,7 +11,10 @@ const props = defineProps({
|
|
|
11
11
|
const { openPreview, updatePreview, setError, currentFile } = useFilePreviewPanel();
|
|
12
12
|
const { getFileInfo, isVaultReference } = useVault();
|
|
13
13
|
const fileName = computed(() => props.file.hashParams?.filename ?? props.file.name);
|
|
14
|
-
const iconSrc = computed(() =>
|
|
14
|
+
const iconSrc = computed(() => {
|
|
15
|
+
const mimeType = fileReferenceMimeType(props.file);
|
|
16
|
+
return mimeType ? getFileIcon(mimeType) : null;
|
|
17
|
+
});
|
|
15
18
|
const open = ref(false);
|
|
16
19
|
async function resolveFile() {
|
|
17
20
|
const reference = props.file.reference;
|
|
@@ -27,7 +27,7 @@ const aloneInBlock = ref(false);
|
|
|
27
27
|
const standalone = computed(() => aloneInBlock.value && !message?.streaming.value);
|
|
28
28
|
function measureBlock() {
|
|
29
29
|
const element = root.value;
|
|
30
|
-
const block = element?.closest(".paragraph-node, p");
|
|
30
|
+
const block = element?.closest(".paragraph-node, p, td, th");
|
|
31
31
|
aloneInBlock.value = Boolean(element && block && !hasTextOutside(block, element));
|
|
32
32
|
}
|
|
33
33
|
onMounted(measureBlock);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DetectedFile } from './content-detection.js';
|
|
1
2
|
/** A markdown link whose text the author wrote, as opposed to an autolink that shows its own address. */
|
|
2
3
|
export declare function isLabelledFileLink(label: string, href: string): boolean;
|
|
3
4
|
type TextTreeNode = {
|
|
@@ -11,4 +12,10 @@ type TextTreeNode = {
|
|
|
11
12
|
* out on purpose, so the answer does not change while a file card swaps in or still loads.
|
|
12
13
|
*/
|
|
13
14
|
export declare function hasTextOutside(block: TextTreeNode, inner: TextTreeNode): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The type a file reference can show before anything is fetched. A permalink is detected with
|
|
17
|
+
* an unknown type, since its address says nothing about the file; the name the link was
|
|
18
|
+
* written with usually does.
|
|
19
|
+
*/
|
|
20
|
+
export declare function fileReferenceMimeType(file: Pick<DetectedFile, 'mimeType' | 'name' | 'hashParams'>): string | null;
|
|
14
21
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getMimeTypeFromExtension, normalizeMimeType } from "./mime.js";
|
|
1
2
|
export function isLabelledFileLink(label, href) {
|
|
2
3
|
const text = label.trim();
|
|
3
4
|
return text !== "" && text !== href.trim();
|
|
@@ -12,3 +13,10 @@ export function hasTextOutside(block, inner) {
|
|
|
12
13
|
}
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
16
|
+
export function fileReferenceMimeType(file) {
|
|
17
|
+
if (file.mimeType !== "unknown")
|
|
18
|
+
return normalizeMimeType(file.mimeType);
|
|
19
|
+
const extension = /\.([a-z0-9]+)$/i.exec(file.hashParams?.filename ?? file.name)?.[1]?.toLowerCase();
|
|
20
|
+
const mimeType = extension ? getMimeTypeFromExtension(extension) : "unknown";
|
|
21
|
+
return mimeType === "unknown" ? null : mimeType;
|
|
22
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { provideEmbedConfig } from "../../embed/composables/embed-config";
|
|
3
3
|
import ChatVaultLink from "../../files/components/chat-vault-link.vue";
|
|
4
4
|
import OpenuiBlock from "../../rendering/components/openui-block.vue";
|
|
5
|
-
import {
|
|
5
|
+
import { UI_LANG_FENCE } from "@meistrari/chat-ui-lang";
|
|
6
|
+
import { buildSlackPreview, groupWidgetStories, widgetAnswer } from "../../rendering/debug/widget-gallery";
|
|
6
7
|
import { OPENUI_ERROR_REPORTER_KEY, OPENUI_MARKDOWN_COMPONENTS_KEY } from "../../rendering/openui/context";
|
|
7
8
|
import { CHAT_MESSAGE_CONTEXT_KEY, CHAT_MESSAGE_SEND_KEY } from "../../types/messages";
|
|
8
9
|
import { createChatDebugCitationsConfig } from "../debug/chat-debug-citations";
|
|
@@ -24,6 +25,8 @@ const viewportOptions = [
|
|
|
24
25
|
const streamedCharacters = ref(null);
|
|
25
26
|
const streaming = computed(() => streamedCharacters.value !== null);
|
|
26
27
|
const visibleCode = computed(() => streamedCharacters.value === null ? code.value : code.value.slice(0, streamedCharacters.value));
|
|
28
|
+
const answer = computed(() => widgetAnswer(visibleCode.value, streaming.value));
|
|
29
|
+
const markdownComponents = { link: ChatVaultLink, [UI_LANG_FENCE]: OpenuiBlock };
|
|
27
30
|
let streamTimer = null;
|
|
28
31
|
const mountRevision = ref(0);
|
|
29
32
|
const sentMessages = ref([]);
|
|
@@ -48,7 +51,7 @@ provide(CHAT_MESSAGE_SEND_KEY, async (content) => {
|
|
|
48
51
|
provide(OPENUI_ERROR_REPORTER_KEY, (errors) => {
|
|
49
52
|
widgetErrors.value = errors.map((error) => `${error.code}: ${error.message}`);
|
|
50
53
|
});
|
|
51
|
-
provide(OPENUI_MARKDOWN_COMPONENTS_KEY, ref(
|
|
54
|
+
provide(OPENUI_MARKDOWN_COMPONENTS_KEY, ref(markdownComponents));
|
|
52
55
|
function stopStream() {
|
|
53
56
|
if (streamTimer)
|
|
54
57
|
clearInterval(streamTimer);
|
|
@@ -156,7 +159,14 @@ onBeforeUnmount(stopStream);
|
|
|
156
159
|
|
|
157
160
|
<div min-h-0 grow overflow-y-auto px-24px pb-24px>
|
|
158
161
|
<div class="widget-under-test" :class="`widget-under-test--${viewportWidth}`" data-gallery="web">
|
|
159
|
-
<
|
|
162
|
+
<AppMarkdownRender
|
|
163
|
+
:key="mountRevision"
|
|
164
|
+
:content="answer"
|
|
165
|
+
:custom-components="markdownComponents"
|
|
166
|
+
:final="!streaming"
|
|
167
|
+
:typewriter="false"
|
|
168
|
+
mode="chat"
|
|
169
|
+
/>
|
|
160
170
|
</div>
|
|
161
171
|
|
|
162
172
|
<div class="widget-under-test" :class="`widget-under-test--${viewportWidth}`" mt-24px>
|
|
@@ -19,6 +19,11 @@ const TOOL_REGISTRY = {
|
|
|
19
19
|
widgetId: "generic",
|
|
20
20
|
labels: { active: "Acessando site", executed: "Acessou site" }
|
|
21
21
|
},
|
|
22
|
+
"HTTP": {
|
|
23
|
+
icon: "i-ph-plugs-connected",
|
|
24
|
+
widgetId: "generic",
|
|
25
|
+
labels: { active: "Consultando servi\xE7o", executed: "Consultou servi\xE7o" }
|
|
26
|
+
},
|
|
22
27
|
"Skill:doc-sdk": {
|
|
23
28
|
icon: "i-ph-file-text",
|
|
24
29
|
widgetId: "doc-sdk",
|
|
@@ -186,6 +191,8 @@ export function resolveToolMeta(toolUse) {
|
|
|
186
191
|
return stringInput(toolUse, "query", "url");
|
|
187
192
|
if (toolUse.name === "super_search_tool")
|
|
188
193
|
return stringInput(toolUse, "query") ?? batchedQueries(toolUse);
|
|
194
|
+
if (toolUse.name === "HTTP")
|
|
195
|
+
return stringInput(toolUse, "service", "path");
|
|
189
196
|
if (toolUse.name === "Bash" || toolUse.name === "Execute")
|
|
190
197
|
return stringInput(toolUse, "description", "command");
|
|
191
198
|
if (toolUse.name === "Skill")
|
|
@@ -11,6 +11,8 @@ export type WidgetGalleryGroup = {
|
|
|
11
11
|
stories: WidgetGalleryStory[];
|
|
12
12
|
};
|
|
13
13
|
export declare function groupWidgetStories(stories: readonly WidgetGalleryStory[]): WidgetGalleryGroup[];
|
|
14
|
+
/** The program as the answer of a message carries it: inside its fence, which stays open while the block streams. */
|
|
15
|
+
export declare function widgetAnswer(code: string, streaming: boolean): string;
|
|
14
16
|
export type SlackPreview = {
|
|
15
17
|
blocks: SlackBlock[];
|
|
16
18
|
/** The answer written out, which Slack uses for notifications. */
|
|
@@ -5,6 +5,10 @@ export function groupWidgetStories(stories) {
|
|
|
5
5
|
groups.set(story.group, [...groups.get(story.group) ?? [], story]);
|
|
6
6
|
return [...groups].map(([name, grouped]) => ({ name, stories: grouped }));
|
|
7
7
|
}
|
|
8
|
+
export function widgetAnswer(code, streaming) {
|
|
9
|
+
return `\`\`\`${UI_LANG_FENCE}
|
|
10
|
+
${code}${streaming ? "" : "\n```"}`;
|
|
11
|
+
}
|
|
8
12
|
const BLOCK_KIT_BUILDER_URL = "https://app.slack.com/block-kit-builder/";
|
|
9
13
|
const PREVIEW_THREAD_TS = "1700000000.000100";
|
|
10
14
|
const PREVIEW_MAX_BLOCKS = 40;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ChatV3Mention, ChatV3Message } from './v3';
|
|
2
|
+
/**
|
|
3
|
+
* How the mentions of a message reach the agent. agent-api has no field for them: a message is
|
|
4
|
+
* text, which the harness hands to the model as it is (Claude Code still runs a leading `/skill`
|
|
5
|
+
* natively). So the text keeps the tokens the user picked (`/name`, `@name`) and ends with a block
|
|
6
|
+
* that says what each one is, where the agent finds the file, and that a skill is to be used.
|
|
7
|
+
* chat-api writes the block and takes it off again when it reads the message back.
|
|
8
|
+
*/
|
|
9
|
+
export type ChatV3MessageMention = ChatV3Message['mentions'][number];
|
|
10
|
+
/**
|
|
11
|
+
* The name agent-api gives a file sent with a message in `attachments/` (`safeName` of its
|
|
12
|
+
* sandbox-worker): the basename, NFC, anything but letters, digits, `_`, `.` and `-` as `_`, no
|
|
13
|
+
* leading dots, at most 200 characters.
|
|
14
|
+
*/
|
|
15
|
+
export declare function attachmentFileName(name: string): string;
|
|
16
|
+
/** Where the agent finds a mentioned file, relative to the root of its working tree. */
|
|
17
|
+
export declare function mentionPath(mention: ChatV3Mention): string | null;
|
|
18
|
+
/** Each mention once: the same skill, path or Vault file picked twice is said once. */
|
|
19
|
+
export declare function uniqueMentions(mentions: readonly ChatV3Mention[]): ChatV3Mention[];
|
|
20
|
+
/**
|
|
21
|
+
* The text the agent gets: the user's, then the block of its mentions. Without mentions, the text
|
|
22
|
+
* as it is, unless the user wrote what reads as such a block at its end: then it gets one more line
|
|
23
|
+
* break, which `splitChatV3MessageText` takes back, so the user's text survives the round trip.
|
|
24
|
+
*/
|
|
25
|
+
export declare function composeChatV3MessageText(text: string, mentions: readonly ChatV3Mention[]): string;
|
|
26
|
+
/**
|
|
27
|
+
* The user's text and its mentions, from the text the agent got. Only a block that closes the
|
|
28
|
+
* text and reads entry by entry is taken off: anything else is the user's own text.
|
|
29
|
+
*/
|
|
30
|
+
export declare function splitChatV3MessageText(text: string): {
|
|
31
|
+
text: string;
|
|
32
|
+
mentions: ChatV3MessageMention[];
|
|
33
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const BLOCK_OPEN = '<chat-mentions>';
|
|
2
|
+
const BLOCK_CLOSE = '</chat-mentions>';
|
|
3
|
+
const SEPARATOR = '\n\n';
|
|
4
|
+
const INSTRUCTIONS = {
|
|
5
|
+
skill: (name) => `O usuário acionou a skill ${name} (/${name}). Use essa skill para atender a mensagem.`,
|
|
6
|
+
file: 'O usuário mencionou este arquivo do seu repositório de trabalho. Leia-o pelo caminho, relativo à raiz do repositório, e foque nele na resposta.',
|
|
7
|
+
attachment: 'O usuário mencionou este arquivo, anexado a esta mensagem. Leia-o e foque nele na resposta.',
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The name agent-api gives a file sent with a message in `attachments/` (`safeName` of its
|
|
11
|
+
* sandbox-worker): the basename, NFC, anything but letters, digits, `_`, `.` and `-` as `_`, no
|
|
12
|
+
* leading dots, at most 200 characters.
|
|
13
|
+
*/
|
|
14
|
+
export function attachmentFileName(name) {
|
|
15
|
+
const base = name.split(/[/\\]/u).at(-1) ?? '';
|
|
16
|
+
const safe = base.normalize('NFC').replace(/[^\p{L}\p{N}_.-]/gu, '_').replace(/^\.+/u, '').slice(0, 200);
|
|
17
|
+
return safe || 'attachment';
|
|
18
|
+
}
|
|
19
|
+
/** Where the agent finds a mentioned file, relative to the root of its working tree. */
|
|
20
|
+
export function mentionPath(mention) {
|
|
21
|
+
if (mention.type === 'file')
|
|
22
|
+
return mention.path;
|
|
23
|
+
if (mention.type === 'attachment')
|
|
24
|
+
return `attachments/${attachmentFileName(mention.name)}`;
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/** Each mention once: the same skill, path or Vault file picked twice is said once. */
|
|
28
|
+
export function uniqueMentions(mentions) {
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
return mentions.filter((mention) => {
|
|
31
|
+
const key = mention.type === 'skill' ? `skill:${mention.name}` : mention.type === 'file' ? `file:${mention.path}` : `attachment:${mention.vaultReference}`;
|
|
32
|
+
if (seen.has(key))
|
|
33
|
+
return false;
|
|
34
|
+
seen.add(key);
|
|
35
|
+
return true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** Keeps a value on its entry's line: the block is read line by line, so line breaks are encoded too. */
|
|
39
|
+
function escapeAttribute(value) {
|
|
40
|
+
return value.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>').replaceAll('\n', ' ').replaceAll('\r', ' ');
|
|
41
|
+
}
|
|
42
|
+
function unescapeAttribute(value) {
|
|
43
|
+
return value.replaceAll(' ', '\r').replaceAll(' ', '\n').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>').replaceAll('&', '&');
|
|
44
|
+
}
|
|
45
|
+
/** Whether the text, line breaks after it aside, closes with what reads as a block of mentions. */
|
|
46
|
+
function endsWithBlock(text) {
|
|
47
|
+
return splitChatV3MessageText(text.replace(/\n+$/u, '')).mentions.length > 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The text the agent gets: the user's, then the block of its mentions. Without mentions, the text
|
|
51
|
+
* as it is, unless the user wrote what reads as such a block at its end: then it gets one more line
|
|
52
|
+
* break, which `splitChatV3MessageText` takes back, so the user's text survives the round trip.
|
|
53
|
+
*/
|
|
54
|
+
export function composeChatV3MessageText(text, mentions) {
|
|
55
|
+
const unique = uniqueMentions(mentions);
|
|
56
|
+
if (unique.length === 0)
|
|
57
|
+
return endsWithBlock(text) ? `${text}\n` : text;
|
|
58
|
+
const lines = unique.map((mention) => {
|
|
59
|
+
const name = `name="${escapeAttribute(mention.name)}"`;
|
|
60
|
+
if (mention.type === 'skill')
|
|
61
|
+
return `<skill ${name}>${INSTRUCTIONS.skill(escapeAttribute(mention.name))}</skill>`;
|
|
62
|
+
return `<${mention.type} ${name} path="${escapeAttribute(mentionPath(mention))}">${INSTRUCTIONS[mention.type]}</${mention.type}>`;
|
|
63
|
+
});
|
|
64
|
+
return `${text}${SEPARATOR}${BLOCK_OPEN}\n${lines.join('\n')}\n${BLOCK_CLOSE}`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* One entry of the block. The closing tag is compared in code, not with a `\1` backreference:
|
|
68
|
+
* Bun 1.3.9 (what CI runs) fails that backreference under the `u` flag on text with accents.
|
|
69
|
+
*/
|
|
70
|
+
const ENTRY = /^<(skill|file|attachment) name="([^"]*)"(?: path="([^"]*)")?>[^<]*<\/(skill|file|attachment)>$/;
|
|
71
|
+
/**
|
|
72
|
+
* The user's text and its mentions, from the text the agent got. Only a block that closes the
|
|
73
|
+
* text and reads entry by entry is taken off: anything else is the user's own text.
|
|
74
|
+
*/
|
|
75
|
+
export function splitChatV3MessageText(text) {
|
|
76
|
+
// A block the user wrote went with one more line break (`composeChatV3MessageText`).
|
|
77
|
+
if (text.endsWith('\n') && endsWithBlock(text))
|
|
78
|
+
return { text: text.slice(0, -1), mentions: [] };
|
|
79
|
+
if (!text.endsWith(BLOCK_CLOSE))
|
|
80
|
+
return { text, mentions: [] };
|
|
81
|
+
const start = text.lastIndexOf(`${SEPARATOR}${BLOCK_OPEN}\n`);
|
|
82
|
+
if (start === -1)
|
|
83
|
+
return { text, mentions: [] };
|
|
84
|
+
const body = text.slice(start + SEPARATOR.length + BLOCK_OPEN.length + 1, -BLOCK_CLOSE.length - 1);
|
|
85
|
+
const mentions = [];
|
|
86
|
+
for (const line of body.split('\n')) {
|
|
87
|
+
const match = ENTRY.exec(line);
|
|
88
|
+
if (!match)
|
|
89
|
+
return { text, mentions: [] };
|
|
90
|
+
const [, type, name, path, closing] = match;
|
|
91
|
+
if (closing !== type || (type === 'skill') !== (path === undefined))
|
|
92
|
+
return { text, mentions: [] };
|
|
93
|
+
mentions.push({ type, name: unescapeAttribute(name), path: path === undefined ? null : unescapeAttribute(path) });
|
|
94
|
+
}
|
|
95
|
+
return { text: text.slice(0, start), mentions };
|
|
96
|
+
}
|