@meistrari/chat-nuxt 3.9.0 → 3.9.2
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/module.mjs +69 -8
- 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/messages/message-reasoning.js +4 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -125,6 +125,35 @@ function resolveRuntimeAliases(telaBuildPath) {
|
|
|
125
125
|
return resolvedAliases;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
const QUADRATIC_GUARDS = [
|
|
129
|
+
{ from: "/[^~]*~{2,}[^~]+/", to: "/~{2,}[^~]/" },
|
|
130
|
+
{ from: "/[^*]*\\*[^*]+/", to: "/\\*[^*]/" }
|
|
131
|
+
];
|
|
132
|
+
const STREAM_MARKDOWN_PARSER_GUARD_COUNT = QUADRATIC_GUARDS.length;
|
|
133
|
+
function patchStreamMarkdownParserSource(source) {
|
|
134
|
+
let patched = source;
|
|
135
|
+
let applied = 0;
|
|
136
|
+
for (const { from, to } of QUADRATIC_GUARDS) {
|
|
137
|
+
if (!patched.includes(from)) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
patched = patched.replaceAll(from, to);
|
|
141
|
+
applied++;
|
|
142
|
+
}
|
|
143
|
+
patched = patched.replace(/\n?\/\/# sourceMappingURL=.*\n?$/, "\n");
|
|
144
|
+
return { source: patched, applied };
|
|
145
|
+
}
|
|
146
|
+
function resolvePatchedStreamMarkdownParser(from) {
|
|
147
|
+
try {
|
|
148
|
+
const markstreamEntry = createRequire(from).resolve("markstream-vue");
|
|
149
|
+
const entry = createRequire(markstreamEntry).resolve("stream-markdown-parser");
|
|
150
|
+
const { source, applied } = patchStreamMarkdownParserSource(readFileSync(entry, "utf8"));
|
|
151
|
+
return { entry, source, applied };
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
128
157
|
const workspaceSettingsResolverCandidates = [
|
|
129
158
|
"server/chat/resolve-workspace-settings.ts",
|
|
130
159
|
"server/chat/resolve-workspace-settings.js"
|
|
@@ -254,15 +283,18 @@ function ensureIconifyPackages(consumerRoot) {
|
|
|
254
283
|
}
|
|
255
284
|
}
|
|
256
285
|
}
|
|
286
|
+
function pushIconSafelist(safelist) {
|
|
287
|
+
for (const icon of [...DYNAMIC_ICON_SAFELIST, ...TOOL_ICON_SAFELIST]) {
|
|
288
|
+
if (!safelist.includes(icon)) {
|
|
289
|
+
safelist.push(icon);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
257
293
|
function ensureDynamicIconSafelist(nuxtOptions) {
|
|
258
294
|
const options = nuxtOptions;
|
|
259
295
|
const unocssOptions = options.unocss ||= {};
|
|
260
296
|
const currentSafelist = Array.isArray(unocssOptions.safelist) ? unocssOptions.safelist : unocssOptions.safelist ? [unocssOptions.safelist] : [];
|
|
261
|
-
|
|
262
|
-
if (!currentSafelist.includes(icon)) {
|
|
263
|
-
currentSafelist.push(icon);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
297
|
+
pushIconSafelist(currentSafelist);
|
|
266
298
|
unocssOptions.safelist = currentSafelist;
|
|
267
299
|
}
|
|
268
300
|
function validateRuntimeConfig(runtimeConfig, mode) {
|
|
@@ -309,6 +341,11 @@ const module$1 = defineNuxtModule({
|
|
|
309
341
|
}
|
|
310
342
|
ensureIconifyPackages(nuxt.options.rootDir);
|
|
311
343
|
ensureDynamicIconSafelist(nuxt.options);
|
|
344
|
+
const unocssHookNuxt = nuxt;
|
|
345
|
+
unocssHookNuxt.hook("unocss:config", (config) => {
|
|
346
|
+
const safelist = Array.isArray(config.safelist) ? config.safelist : config.safelist = [];
|
|
347
|
+
pushIconSafelist(safelist);
|
|
348
|
+
});
|
|
312
349
|
const resolver = createResolver(import.meta.url);
|
|
313
350
|
const builtRuntimeDir = resolver.resolve("./runtime");
|
|
314
351
|
const sourceRuntimeDir = resolver.resolve("../src/runtime");
|
|
@@ -339,12 +376,25 @@ const module$1 = defineNuxtModule({
|
|
|
339
376
|
nuxt.options.extends = nuxt.options.extends ? [nuxt.options.extends] : [];
|
|
340
377
|
}
|
|
341
378
|
nuxt.options.extends.unshift(telaBuildPath);
|
|
379
|
+
const patchedStreamMarkdownParser = resolvePatchedStreamMarkdownParser(import.meta.url);
|
|
380
|
+
if (patchedStreamMarkdownParser?.applied !== STREAM_MARKDOWN_PARSER_GUARD_COUNT) {
|
|
381
|
+
const cause = patchedStreamMarkdownParser ? `${patchedStreamMarkdownParser.entry}: expected ${STREAM_MARKDOWN_PARSER_GUARD_COUNT} guards, found ${patchedStreamMarkdownParser.applied}` : "not resolvable through markstream-vue";
|
|
382
|
+
console.error(
|
|
383
|
+
`[@meistrari/chat-nuxt] Could not rewrite the quadratic guards in stream-markdown-parser (${cause}). Long unbroken Markdown paragraphs will parse quadratically and can freeze the chat UI. Update QUADRATIC_GUARDS in @meistrari/chat-nuxt, or drop the rewrite if upstream fixed the backtracking.`
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
const streamMarkdownParserAlias = patchedStreamMarkdownParser?.applied === STREAM_MARKDOWN_PARSER_GUARD_COUNT ? addTemplate({
|
|
387
|
+
filename: "chat-nuxt/stream-markdown-parser.mjs",
|
|
388
|
+
write: true,
|
|
389
|
+
getContents: () => patchedStreamMarkdownParser.source
|
|
390
|
+
}).dst : void 0;
|
|
342
391
|
nuxt.options.alias = {
|
|
343
392
|
...nuxt.options.alias,
|
|
344
393
|
"#chat-auth": chatAuthTemplate.dst,
|
|
345
394
|
"#chat-workspace-settings-resolver": workspaceSettingsResolverEntry,
|
|
346
395
|
"#chat-runtime": runtimeDir,
|
|
347
|
-
"@iconify-json/ph": resolvePackageRoot("@iconify-json/ph")
|
|
396
|
+
"@iconify-json/ph": resolvePackageRoot("@iconify-json/ph"),
|
|
397
|
+
...streamMarkdownParserAlias ? { "stream-markdown-parser": streamMarkdownParserAlias } : {}
|
|
348
398
|
};
|
|
349
399
|
const importsOptions = nuxt.options.imports;
|
|
350
400
|
if (importsOptions !== false) {
|
|
@@ -396,10 +446,20 @@ const module$1 = defineNuxtModule({
|
|
|
396
446
|
});
|
|
397
447
|
}
|
|
398
448
|
nuxt.hook("vite:extendConfig", (config, { isServer }) => {
|
|
449
|
+
config.resolve = config.resolve || {};
|
|
450
|
+
if (streamMarkdownParserAlias) {
|
|
451
|
+
if (Array.isArray(config.resolve.alias)) {
|
|
452
|
+
config.resolve.alias.push({ find: "stream-markdown-parser", replacement: streamMarkdownParserAlias });
|
|
453
|
+
} else {
|
|
454
|
+
config.resolve.alias = {
|
|
455
|
+
...config.resolve.alias || {},
|
|
456
|
+
"stream-markdown-parser": streamMarkdownParserAlias
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
}
|
|
399
460
|
if (isServer) {
|
|
400
461
|
return;
|
|
401
462
|
}
|
|
402
|
-
config.resolve = config.resolve || {};
|
|
403
463
|
config.plugins = config.plugins || [];
|
|
404
464
|
if (Array.isArray(config.resolve.alias)) {
|
|
405
465
|
config.resolve.alias.push(...Object.entries(runtimeAliases).map(([find, replacement]) => ({ find, replacement })));
|
|
@@ -443,7 +503,8 @@ export default globalThis.ELK;
|
|
|
443
503
|
...nitroConfig.alias,
|
|
444
504
|
"#chat-auth": chatAuthTemplate.dst,
|
|
445
505
|
"#chat-runtime": runtimeDir,
|
|
446
|
-
"#chat-workspace-settings-resolver": workspaceSettingsResolverEntry
|
|
506
|
+
"#chat-workspace-settings-resolver": workspaceSettingsResolverEntry,
|
|
507
|
+
...streamMarkdownParserAlias ? { "stream-markdown-parser": streamMarkdownParserAlias } : {}
|
|
447
508
|
};
|
|
448
509
|
nitroConfig.publicAssets = nitroConfig.publicAssets || [];
|
|
449
510
|
nitroConfig.publicAssets.push({
|
|
@@ -57,12 +57,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
57
57
|
"update:selectedModel": (value: string | null) => any;
|
|
58
58
|
} & {
|
|
59
59
|
delete: () => any;
|
|
60
|
-
cancel: () => any;
|
|
61
60
|
rename: () => any;
|
|
62
61
|
duplicate: () => any;
|
|
63
62
|
export: () => any;
|
|
64
63
|
copyLink: () => any;
|
|
65
64
|
selectConversation: (id: string) => any;
|
|
65
|
+
cancel: () => any;
|
|
66
66
|
settings: () => any;
|
|
67
67
|
send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
|
|
68
68
|
debug: () => any;
|
|
@@ -78,12 +78,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
78
78
|
"update:workspaceSheetOpen": (value: boolean) => any;
|
|
79
79
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
80
80
|
onDelete?: (() => any) | undefined;
|
|
81
|
-
onCancel?: (() => any) | undefined;
|
|
82
81
|
onRename?: (() => any) | undefined;
|
|
83
82
|
onDuplicate?: (() => any) | undefined;
|
|
84
83
|
onExport?: (() => any) | undefined;
|
|
85
84
|
onCopyLink?: (() => any) | undefined;
|
|
86
85
|
onSelectConversation?: ((id: string) => any) | undefined;
|
|
86
|
+
onCancel?: (() => any) | undefined;
|
|
87
87
|
onSettings?: (() => any) | undefined;
|
|
88
88
|
onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
|
|
89
89
|
"onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
|
|
@@ -57,12 +57,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
57
57
|
"update:selectedModel": (value: string | null) => any;
|
|
58
58
|
} & {
|
|
59
59
|
delete: () => any;
|
|
60
|
-
cancel: () => any;
|
|
61
60
|
rename: () => any;
|
|
62
61
|
duplicate: () => any;
|
|
63
62
|
export: () => any;
|
|
64
63
|
copyLink: () => any;
|
|
65
64
|
selectConversation: (id: string) => any;
|
|
65
|
+
cancel: () => any;
|
|
66
66
|
settings: () => any;
|
|
67
67
|
send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
|
|
68
68
|
debug: () => any;
|
|
@@ -78,12 +78,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
78
78
|
"update:workspaceSheetOpen": (value: boolean) => any;
|
|
79
79
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
80
80
|
onDelete?: (() => any) | undefined;
|
|
81
|
-
onCancel?: (() => any) | undefined;
|
|
82
81
|
onRename?: (() => any) | undefined;
|
|
83
82
|
onDuplicate?: (() => any) | undefined;
|
|
84
83
|
onExport?: (() => any) | undefined;
|
|
85
84
|
onCopyLink?: (() => any) | undefined;
|
|
86
85
|
onSelectConversation?: ((id: string) => any) | undefined;
|
|
86
|
+
onCancel?: (() => any) | undefined;
|
|
87
87
|
onSettings?: (() => any) | undefined;
|
|
88
88
|
onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
|
|
89
89
|
"onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
|
|
@@ -54,6 +54,10 @@ function getParsedReasoningSteps(cache, messageId, reasoningData) {
|
|
|
54
54
|
let parsedSteps = cache.bySignature.get(cacheKey);
|
|
55
55
|
if (!parsedSteps) {
|
|
56
56
|
parsedSteps = parseReasoningFromPolling(reasoningData);
|
|
57
|
+
for (const staleKey of cache.bySignature.keys()) {
|
|
58
|
+
if (staleKey.startsWith(`${messageId}:`))
|
|
59
|
+
cache.bySignature.delete(staleKey);
|
|
60
|
+
}
|
|
57
61
|
cache.bySignature.set(cacheKey, parsedSteps);
|
|
58
62
|
}
|
|
59
63
|
cache.byReference.set(reasoningData, { messageId, parsedSteps });
|