@blade-hq/agent-react 2612.0.0-beta.6 → 2612.0.0-beta.7
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 +1 -1
- package/dist/chat/LiteMessageList.d.ts +1 -1
- package/dist/chat/customization.d.ts +1 -1
- package/dist/chat/index.d.ts +1 -4
- package/dist/chat/lib/citations.d.ts +2 -23
- package/dist/chat/runtime/actions.d.ts +0 -1
- package/dist/chat/runtime/input-services.d.ts +0 -6
- package/dist/{chunk-XJLFFRQP.js → chunk-67GHJQK5.js} +443 -410
- package/dist/chunk-67GHJQK5.js.map +1 -0
- package/dist/{chunk-IRBOKMF5.js → chunk-DPDXGYGM.js} +2 -2
- package/dist/{chunk-UKQFSXGC.js → chunk-MERN5XEM.js} +506 -686
- package/dist/chunk-MERN5XEM.js.map +1 -0
- package/dist/host.d.ts +0 -4
- package/dist/index.js +2 -2
- package/dist/internal.js +3 -3
- package/dist/rich-input/FileCompletionMenu.d.ts +4 -9
- package/dist/rich-input/index.d.ts +0 -2
- package/dist/rich-input/lib/composer-content.d.ts +2 -21
- package/dist/rich-input/lib/reference-candidates.d.ts +0 -3
- package/dist/rich-input/services.d.ts +2 -3
- package/dist/rich-input.js +37 -254
- package/dist/rich-input.js.map +1 -1
- package/dist/style.full.css +1 -1
- package/package.json +2 -2
- package/public-api.md +0 -1
- package/dist/chat/tool-renderers/KbSearchRenderer.d.ts +0 -2
- package/dist/chat/tool-renderers/kb-search-result.d.ts +0 -19
- package/dist/chunk-UKQFSXGC.js.map +0 -1
- package/dist/chunk-XJLFFRQP.js.map +0 -1
- package/dist/rich-input/extensions/kb-mention.d.ts +0 -18
- package/dist/rich-input/lib/kb-suggestions.d.ts +0 -37
- /package/dist/{chunk-IRBOKMF5.js.map → chunk-DPDXGYGM.js.map} +0 -0
package/dist/rich-input.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
PluginTriggerStack,
|
|
4
4
|
selectionFromItem,
|
|
5
5
|
triggerSummary
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DPDXGYGM.js";
|
|
7
7
|
import {
|
|
8
8
|
Archive,
|
|
9
9
|
BookOpen,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
usePortalContainer,
|
|
63
63
|
useSessionHandle,
|
|
64
64
|
useSessionState
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-MERN5XEM.js";
|
|
66
66
|
import {
|
|
67
67
|
__commonJS,
|
|
68
68
|
__require,
|
|
@@ -291,6 +291,9 @@ function useRichInputServices() {
|
|
|
291
291
|
return useContext(RichInputServicesContext);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
// src/rich-input/lib/session-data.ts
|
|
295
|
+
import { useEffect as useEffect2, useRef } from "react";
|
|
296
|
+
|
|
294
297
|
// src/rich-input/lib/client-query.ts
|
|
295
298
|
import { useCallback, useEffect, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
296
299
|
var EMPTY = { data: void 0, error: null, isLoading: false, isFetching: false };
|
|
@@ -405,7 +408,6 @@ function refreshClientQuery(client, key) {
|
|
|
405
408
|
}
|
|
406
409
|
|
|
407
410
|
// src/rich-input/lib/session-data.ts
|
|
408
|
-
import { useEffect as useEffect2, useRef } from "react";
|
|
409
411
|
var sessionPath = (sessionId, rest) => `/api/sessions/${encodeURIComponent(sessionId)}/${rest}`;
|
|
410
412
|
function useRefreshWhenRunEnds(sessionId, keys3) {
|
|
411
413
|
const client = useBladeClient();
|
|
@@ -540,22 +542,6 @@ function useModelPreferences() {
|
|
|
540
542
|
const use = useRichInputServices().useModelPreferences ?? useClientModelPreferences;
|
|
541
543
|
return use();
|
|
542
544
|
}
|
|
543
|
-
function loadKnowledgeBases(client) {
|
|
544
|
-
return client.json("GET", "/api/registry/kb").then(
|
|
545
|
-
(response) => (Array.isArray(response) ? response : response?.items ?? []).filter((item) => typeof item?.id === "number")
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
function useClientKnowledgeBaseLoader() {
|
|
549
|
-
const client = useBladeClient();
|
|
550
|
-
return useMemo(
|
|
551
|
-
() => () => fetchClientQuery(client, "knowledge-bases", loadKnowledgeBases, { staleMs: 6e4 }),
|
|
552
|
-
[client]
|
|
553
|
-
);
|
|
554
|
-
}
|
|
555
|
-
function useKnowledgeBaseLoader() {
|
|
556
|
-
const use = useRichInputServices().useKnowledgeBaseLoader ?? useClientKnowledgeBaseLoader;
|
|
557
|
-
return use();
|
|
558
|
-
}
|
|
559
545
|
function useSessionConnection(sessionId) {
|
|
560
546
|
const connection = useSessionState(sessionId, (state3) => state3.connection);
|
|
561
547
|
const status = sessionId ? connection : "connected";
|
|
@@ -18988,10 +18974,6 @@ function serializeEditorContent(node) {
|
|
|
18988
18974
|
const path = typeof node.attrs?.path === "string" ? node.attrs.path : "";
|
|
18989
18975
|
return path ? `@${path}` : "";
|
|
18990
18976
|
}
|
|
18991
|
-
if (node.type === "kbMention") {
|
|
18992
|
-
const name = kbMentionName(node);
|
|
18993
|
-
return name ? `@${name}` : "";
|
|
18994
|
-
}
|
|
18995
18977
|
const children = (node.content ?? []).map((child) => serializeEditorContent(child));
|
|
18996
18978
|
if (node.type === "doc") {
|
|
18997
18979
|
return children.join("\n");
|
|
@@ -19010,9 +18992,6 @@ function scanLeadingSkillMention(node, seenContent) {
|
|
|
19010
18992
|
}
|
|
19011
18993
|
if (node.type === "pluginMention") return { skill: null, seenContent };
|
|
19012
18994
|
if (node.type === "topicAssetMention") return { skill: null, seenContent };
|
|
19013
|
-
if (node.type === "kbMention") {
|
|
19014
|
-
return { skill: null, seenContent };
|
|
19015
|
-
}
|
|
19016
18995
|
if (node.type === "skillMention") {
|
|
19017
18996
|
const skillId = typeof node.attrs?.skillId === "string" ? node.attrs.skillId : null;
|
|
19018
18997
|
return {
|
|
@@ -19037,70 +19016,6 @@ function scanLeadingSkillMention(node, seenContent) {
|
|
|
19037
19016
|
function findLeadingSkillMention(node) {
|
|
19038
19017
|
return scanLeadingSkillMention(node, false).skill;
|
|
19039
19018
|
}
|
|
19040
|
-
function kbMentionName(node) {
|
|
19041
|
-
const name = typeof node.attrs?.name === "string" ? node.attrs.name.trim() : "";
|
|
19042
|
-
if (name) return name;
|
|
19043
|
-
const kbId = node.attrs?.kbId;
|
|
19044
|
-
return typeof kbId === "number" && kbId > 0 ? `\u77E5\u8BC6\u5E93 #${kbId}` : "";
|
|
19045
|
-
}
|
|
19046
|
-
function collectKbMentions(node) {
|
|
19047
|
-
const result = [];
|
|
19048
|
-
const seen = /* @__PURE__ */ new Set();
|
|
19049
|
-
const visit = (current) => {
|
|
19050
|
-
if (!current) return;
|
|
19051
|
-
if (current.type === "kbMention") {
|
|
19052
|
-
const kbId = current.attrs?.kbId;
|
|
19053
|
-
if (typeof kbId === "number" && Number.isInteger(kbId) && kbId > 0 && !seen.has(kbId)) {
|
|
19054
|
-
seen.add(kbId);
|
|
19055
|
-
result.push({ kbId, name: kbMentionName(current) });
|
|
19056
|
-
}
|
|
19057
|
-
return;
|
|
19058
|
-
}
|
|
19059
|
-
for (const child of current.content ?? []) visit(child);
|
|
19060
|
-
};
|
|
19061
|
-
visit(node);
|
|
19062
|
-
return result;
|
|
19063
|
-
}
|
|
19064
|
-
function buildEditorDocumentWithKbMentions(text, kbMentions) {
|
|
19065
|
-
return {
|
|
19066
|
-
type: "doc",
|
|
19067
|
-
content: text.split("\n").map((line) => ({
|
|
19068
|
-
type: "paragraph",
|
|
19069
|
-
content: line ? buildLineContentWithKbMentions(line, kbMentions) : []
|
|
19070
|
-
}))
|
|
19071
|
-
};
|
|
19072
|
-
}
|
|
19073
|
-
function buildLineContentWithKbMentions(line, kbMentions) {
|
|
19074
|
-
if (kbMentions.length === 0) {
|
|
19075
|
-
return [{ type: "text", text: line }];
|
|
19076
|
-
}
|
|
19077
|
-
const matches2 = [];
|
|
19078
|
-
for (const mention of kbMentions) {
|
|
19079
|
-
if (!mention.name) continue;
|
|
19080
|
-
const marker = `@${mention.name}`;
|
|
19081
|
-
const index = line.indexOf(marker);
|
|
19082
|
-
if (index === -1) continue;
|
|
19083
|
-
if (matches2.some((m) => index < m.end && index + marker.length > m.start)) continue;
|
|
19084
|
-
matches2.push({ start: index, end: index + marker.length, kbId: mention.kbId, name: mention.name });
|
|
19085
|
-
}
|
|
19086
|
-
if (matches2.length === 0) {
|
|
19087
|
-
return [{ type: "text", text: line }];
|
|
19088
|
-
}
|
|
19089
|
-
matches2.sort((a, b) => a.start - b.start);
|
|
19090
|
-
const content = [];
|
|
19091
|
-
let cursor = 0;
|
|
19092
|
-
for (const match of matches2) {
|
|
19093
|
-
if (match.start > cursor) {
|
|
19094
|
-
content.push({ type: "text", text: line.slice(cursor, match.start) });
|
|
19095
|
-
}
|
|
19096
|
-
content.push({ type: "kbMention", attrs: { kbId: match.kbId, name: match.name } });
|
|
19097
|
-
cursor = match.end;
|
|
19098
|
-
}
|
|
19099
|
-
if (cursor < line.length) {
|
|
19100
|
-
content.push({ type: "text", text: line.slice(cursor) });
|
|
19101
|
-
}
|
|
19102
|
-
return content;
|
|
19103
|
-
}
|
|
19104
19019
|
function collectTopicAssetMentions(node) {
|
|
19105
19020
|
const refs = [];
|
|
19106
19021
|
const visit = (current) => {
|
|
@@ -19111,8 +19026,8 @@ function collectTopicAssetMentions(node) {
|
|
|
19111
19026
|
visit(node);
|
|
19112
19027
|
return normalizeTopicAssetRefs(refs);
|
|
19113
19028
|
}
|
|
19114
|
-
function buildEditorDocumentWithMentions(text,
|
|
19115
|
-
const doc3 =
|
|
19029
|
+
function buildEditorDocumentWithMentions(text, topicAssetRefs = []) {
|
|
19030
|
+
const doc3 = buildEditorDocument(text);
|
|
19116
19031
|
const replace2 = (node) => {
|
|
19117
19032
|
if (node.type !== "text") return [{ ...node, ...node.content ? { content: node.content.flatMap(replace2) } : {} }];
|
|
19118
19033
|
let nodes = [node];
|
|
@@ -19151,6 +19066,9 @@ function collectPluginMentions(node) {
|
|
|
19151
19066
|
visit(node);
|
|
19152
19067
|
return normalizePluginRefs(refs);
|
|
19153
19068
|
}
|
|
19069
|
+
function buildEditorDocument(text) {
|
|
19070
|
+
return { type: "doc", content: text.split("\n").map((line) => ({ type: "paragraph", content: line ? [{ type: "text", text: line }] : [] })) };
|
|
19071
|
+
}
|
|
19154
19072
|
|
|
19155
19073
|
// src/rich-input/extensions/topic-asset-mention.ts
|
|
19156
19074
|
function isTopicAssetSuggestionItem(value) {
|
|
@@ -26556,39 +26474,6 @@ function ConnectButton({
|
|
|
26556
26474
|
] });
|
|
26557
26475
|
}
|
|
26558
26476
|
|
|
26559
|
-
// src/rich-input/lib/kb-suggestions.ts
|
|
26560
|
-
function toKbSuggestionItems(knowledgeBases) {
|
|
26561
|
-
return knowledgeBases.map((kb) => ({
|
|
26562
|
-
kind: "kb",
|
|
26563
|
-
kbId: kb.id,
|
|
26564
|
-
name: kb.name,
|
|
26565
|
-
description: kb.description ?? ""
|
|
26566
|
-
}));
|
|
26567
|
-
}
|
|
26568
|
-
var KB_SUGGESTION_TIMEOUT_MS = 300;
|
|
26569
|
-
function withKbSuggestionTimeout(promise, timeoutMs = KB_SUGGESTION_TIMEOUT_MS) {
|
|
26570
|
-
return Promise.race([
|
|
26571
|
-
promise,
|
|
26572
|
-
new Promise((resolve) => {
|
|
26573
|
-
setTimeout(() => resolve([]), timeoutMs);
|
|
26574
|
-
})
|
|
26575
|
-
]);
|
|
26576
|
-
}
|
|
26577
|
-
function notifyWhenKbSuggestionsArriveLate(kbPromise, raced, onLate) {
|
|
26578
|
-
if (raced.length > 0) return;
|
|
26579
|
-
void kbPromise.then((lateItems) => {
|
|
26580
|
-
if (lateItems.length > 0) onLate(lateItems);
|
|
26581
|
-
});
|
|
26582
|
-
}
|
|
26583
|
-
function filterKbSuggestions(items, query) {
|
|
26584
|
-
if (query.includes("/") || query.includes("\\")) return [];
|
|
26585
|
-
const normalized = query.trim().toLowerCase();
|
|
26586
|
-
if (!normalized) return [...items];
|
|
26587
|
-
return items.filter(
|
|
26588
|
-
(item) => item.name.toLowerCase().includes(normalized) || item.description.toLowerCase().includes(normalized)
|
|
26589
|
-
);
|
|
26590
|
-
}
|
|
26591
|
-
|
|
26592
26477
|
// src/rich-input/voice/use-voice-input.ts
|
|
26593
26478
|
import { useCallback as useCallback3, useEffect as useEffect7, useRef as useRef7, useState as useState7 } from "react";
|
|
26594
26479
|
|
|
@@ -26923,7 +26808,7 @@ function useVoiceInput(options) {
|
|
|
26923
26808
|
import { useLayoutEffect as useLayoutEffect2, useRef as useRef8 } from "react";
|
|
26924
26809
|
|
|
26925
26810
|
// src/rich-input/lib/reference-candidates.ts
|
|
26926
|
-
function createReferenceCandidateController(getScope, sources, timeoutMs =
|
|
26811
|
+
function createReferenceCandidateController(getScope, sources, timeoutMs = 300) {
|
|
26927
26812
|
const requests = /* @__PURE__ */ new WeakMap();
|
|
26928
26813
|
let current;
|
|
26929
26814
|
const isCurrent = (request) => {
|
|
@@ -26935,9 +26820,9 @@ function createReferenceCandidateController(getScope, sources, timeoutMs = KB_SU
|
|
|
26935
26820
|
current = void 0;
|
|
26936
26821
|
previous?.finish();
|
|
26937
26822
|
previous?.listener?.({
|
|
26938
|
-
groups: { plugins: [],
|
|
26823
|
+
groups: { plugins: [], topics: [], files: [] },
|
|
26939
26824
|
items: [],
|
|
26940
|
-
loading: { plugins: false,
|
|
26825
|
+
loading: { plugins: false, topics: false, files: false },
|
|
26941
26826
|
errors: {}
|
|
26942
26827
|
});
|
|
26943
26828
|
if (previous) previous.listener = void 0;
|
|
@@ -26947,9 +26832,9 @@ function createReferenceCandidateController(getScope, sources, timeoutMs = KB_SU
|
|
|
26947
26832
|
query(query) {
|
|
26948
26833
|
cancel();
|
|
26949
26834
|
const snapshot = {
|
|
26950
|
-
groups: { plugins: [],
|
|
26835
|
+
groups: { plugins: [], topics: [], files: [] },
|
|
26951
26836
|
items: [],
|
|
26952
|
-
loading: { plugins: Boolean(sources.plugins),
|
|
26837
|
+
loading: { plugins: Boolean(sources.plugins), topics: true, files: true },
|
|
26953
26838
|
errors: {}
|
|
26954
26839
|
};
|
|
26955
26840
|
let resolve;
|
|
@@ -26973,11 +26858,11 @@ function createReferenceCandidateController(getScope, sources, timeoutMs = KB_SU
|
|
|
26973
26858
|
const timer = setTimeout(request.finish, timeoutMs);
|
|
26974
26859
|
const publish = () => {
|
|
26975
26860
|
if (!isCurrent(request)) return;
|
|
26976
|
-
snapshot.items = [...snapshot.groups.plugins, ...snapshot.groups.
|
|
26861
|
+
snapshot.items = [...snapshot.groups.plugins, ...snapshot.groups.topics, ...snapshot.groups.files];
|
|
26977
26862
|
request.listener?.(snapshot);
|
|
26978
26863
|
if (!Object.values(snapshot.loading).some(Boolean)) request.finish();
|
|
26979
26864
|
};
|
|
26980
|
-
for (const key of ["plugins", "
|
|
26865
|
+
for (const key of ["plugins", "topics", "files"]) {
|
|
26981
26866
|
void Promise.resolve().then(async () => {
|
|
26982
26867
|
if (key === "plugins") await new Promise((done) => setTimeout(done, 150));
|
|
26983
26868
|
return isCurrent(request) ? sources[key]?.(query) ?? [] : [];
|
|
@@ -27000,9 +26885,9 @@ function createReferenceCandidateController(getScope, sources, timeoutMs = KB_SU
|
|
|
27000
26885
|
const request = requests.get(items);
|
|
27001
26886
|
if (!request || !isCurrent(request)) {
|
|
27002
26887
|
listener({
|
|
27003
|
-
groups: { plugins: [],
|
|
26888
|
+
groups: { plugins: [], topics: [], files: [] },
|
|
27004
26889
|
items: [],
|
|
27005
|
-
loading: { plugins: false,
|
|
26890
|
+
loading: { plugins: false, topics: false, files: false },
|
|
27006
26891
|
errors: {}
|
|
27007
26892
|
});
|
|
27008
26893
|
return;
|
|
@@ -27017,11 +26902,10 @@ function createReferenceCandidateController(getScope, sources, timeoutMs = KB_SU
|
|
|
27017
26902
|
function useReferenceCandidates(getScope, sources) {
|
|
27018
26903
|
const readScope = useEffectEvent(getScope);
|
|
27019
26904
|
const plugins = useEffectEvent((query) => sources.plugins?.(query) ?? Promise.resolve([]));
|
|
27020
|
-
const kbs = useEffectEvent(sources.kbs);
|
|
27021
26905
|
const topics = useEffectEvent(sources.topics);
|
|
27022
26906
|
const files = useEffectEvent(sources.files);
|
|
27023
26907
|
const ref = useRef8(null);
|
|
27024
|
-
if (!ref.current) ref.current = createReferenceCandidateController(readScope, { plugins,
|
|
26908
|
+
if (!ref.current) ref.current = createReferenceCandidateController(readScope, { plugins, topics, files });
|
|
27025
26909
|
const controller = ref.current;
|
|
27026
26910
|
const [client, identity, session, topic] = getScope();
|
|
27027
26911
|
useLayoutEffect2(() => onInputCachesReset(client, controller.cancel), [client, controller]);
|
|
@@ -27038,7 +26922,6 @@ function copyEditorDocument(value) {
|
|
|
27038
26922
|
const attributes = {
|
|
27039
26923
|
pluginMention: { provider: "string", plugin: "string", server: "string", id: "string", label: "string" },
|
|
27040
26924
|
fileMention: { path: "string", name: "string" },
|
|
27041
|
-
kbMention: { kbId: "number", name: "string" },
|
|
27042
26925
|
topicAssetMention: { topic_id: "string", path: "string" },
|
|
27043
26926
|
skillMention: { skillId: "string", displayName: "string", description: "string", local: "boolean", installed: "boolean" },
|
|
27044
26927
|
workflowMention: { name: "string" }
|
|
@@ -27073,7 +26956,6 @@ function copyEditorDocument(value) {
|
|
|
27073
26956
|
if (expected === "string" && typeof attr !== "string" || expected === "number" && typeof attr !== "number" || expected === "boolean" && typeof attr !== "boolean") return null;
|
|
27074
26957
|
attrs[key] = attr;
|
|
27075
26958
|
}
|
|
27076
|
-
if (type === "kbMention" && !(Number.isInteger(attrs.kbId) && attrs.kbId > 0)) return null;
|
|
27077
26959
|
if (type === "topicAssetMention" && normalizeTopicAssetRefs3([attrs]).length !== 1) return null;
|
|
27078
26960
|
return { type, attrs };
|
|
27079
26961
|
};
|
|
@@ -27321,59 +27203,6 @@ function listUserHomeDir(client, dirPath) {
|
|
|
27321
27203
|
return entries;
|
|
27322
27204
|
}
|
|
27323
27205
|
|
|
27324
|
-
// src/rich-input/extensions/kb-mention.ts
|
|
27325
|
-
function isKbSuggestionItem(value) {
|
|
27326
|
-
return typeof value === "object" && value !== null && value.kind === "kb" && typeof value.kbId === "number";
|
|
27327
|
-
}
|
|
27328
|
-
function getKbMentionName(attrs) {
|
|
27329
|
-
return attrs.name || (attrs.kbId != null ? `\u77E5\u8BC6\u5E93 #${attrs.kbId}` : "");
|
|
27330
|
-
}
|
|
27331
|
-
var KbMention = index_default.extend({
|
|
27332
|
-
name: "kbMention",
|
|
27333
|
-
addOptions() {
|
|
27334
|
-
const parentOptions = this.parent?.();
|
|
27335
|
-
return {
|
|
27336
|
-
...parentOptions,
|
|
27337
|
-
HTMLAttributes: {
|
|
27338
|
-
...parentOptions?.HTMLAttributes ?? {},
|
|
27339
|
-
class: "kb-mention-pill"
|
|
27340
|
-
},
|
|
27341
|
-
deleteTriggerWithBackspace: true,
|
|
27342
|
-
// 只为满足 Mention 的选项类型;下面 addProseMirrorPlugins 返回空,不会真的装上。
|
|
27343
|
-
suggestion: { ...parentOptions?.suggestion ?? {}, char: "@" },
|
|
27344
|
-
suggestions: parentOptions?.suggestions ?? [],
|
|
27345
|
-
renderText: ({ node }) => `@${getKbMentionName(node.attrs)}`,
|
|
27346
|
-
renderHTML: ({ options, node }) => [
|
|
27347
|
-
"span",
|
|
27348
|
-
{
|
|
27349
|
-
...options.HTMLAttributes ?? {},
|
|
27350
|
-
class: "kb-mention-pill",
|
|
27351
|
-
"data-kb-id": String(node.attrs.kbId ?? ""),
|
|
27352
|
-
"data-name": node.attrs.name
|
|
27353
|
-
},
|
|
27354
|
-
`@${getKbMentionName(node.attrs)}`
|
|
27355
|
-
]
|
|
27356
|
-
};
|
|
27357
|
-
},
|
|
27358
|
-
addAttributes() {
|
|
27359
|
-
return {
|
|
27360
|
-
kbId: {
|
|
27361
|
-
default: 0,
|
|
27362
|
-
parseHTML: (element) => Number(element.getAttribute("data-kb-id") || 0),
|
|
27363
|
-
renderHTML: (attributes) => ({ "data-kb-id": String(attributes.kbId) })
|
|
27364
|
-
},
|
|
27365
|
-
name: {
|
|
27366
|
-
default: "",
|
|
27367
|
-
parseHTML: (element) => element.getAttribute("data-name") || "",
|
|
27368
|
-
renderHTML: (attributes) => ({ "data-name": attributes.name })
|
|
27369
|
-
}
|
|
27370
|
-
};
|
|
27371
|
-
},
|
|
27372
|
-
addProseMirrorPlugins() {
|
|
27373
|
-
return [];
|
|
27374
|
-
}
|
|
27375
|
-
});
|
|
27376
|
-
|
|
27377
27206
|
// src/rich-input/FileCompletionMenu.tsx
|
|
27378
27207
|
import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
27379
27208
|
var ROOT_DIR = ".";
|
|
@@ -27506,10 +27335,9 @@ var FileCompletionMenu = forwardRef2(
|
|
|
27506
27335
|
() => scope === "userHome" ? { dirPath: query, filterQuery: "" } : parseSuggestionQuery(query),
|
|
27507
27336
|
[query, scope]
|
|
27508
27337
|
);
|
|
27509
|
-
const { pluginItems, pluginError,
|
|
27338
|
+
const { pluginItems, pluginError, fileItems, topicItems, topicError } = useMemo8(() => {
|
|
27510
27339
|
let pluginError2;
|
|
27511
27340
|
const pluginItems2 = [];
|
|
27512
|
-
const kbs = [];
|
|
27513
27341
|
const files = [];
|
|
27514
27342
|
const topicItems2 = [];
|
|
27515
27343
|
let topicError2;
|
|
@@ -27518,11 +27346,10 @@ var FileCompletionMenu = forwardRef2(
|
|
|
27518
27346
|
else if (isPluginSuggestionItem(item)) pluginItems2.push(item);
|
|
27519
27347
|
else if (isTopicAssetSuggestionItem(item)) topicItems2.push(item);
|
|
27520
27348
|
else if (isTopicAssetSuggestionError(item)) topicError2 = item.message;
|
|
27521
|
-
else if (isKbSuggestionItem(item)) kbs.push(item);
|
|
27522
27349
|
else files.push(item);
|
|
27523
27350
|
}
|
|
27524
|
-
return { pluginItems: pluginItems2, pluginError: pluginError2,
|
|
27525
|
-
}, [items
|
|
27351
|
+
return { pluginItems: pluginItems2, pluginError: pluginError2, fileItems: files, topicItems: topicItems2, topicError: topicError2 };
|
|
27352
|
+
}, [items]);
|
|
27526
27353
|
return /* @__PURE__ */ jsx16(
|
|
27527
27354
|
FileCompletionMenuContent,
|
|
27528
27355
|
{
|
|
@@ -27533,7 +27360,6 @@ var FileCompletionMenu = forwardRef2(
|
|
|
27533
27360
|
items: fileItems,
|
|
27534
27361
|
pluginError,
|
|
27535
27362
|
pluginItems,
|
|
27536
|
-
kbItems,
|
|
27537
27363
|
topicItems,
|
|
27538
27364
|
topicError,
|
|
27539
27365
|
onExit,
|
|
@@ -27541,21 +27367,21 @@ var FileCompletionMenu = forwardRef2(
|
|
|
27541
27367
|
scope,
|
|
27542
27368
|
sessionId
|
|
27543
27369
|
},
|
|
27544
|
-
`${scope}:${sessionId ?? "none"}:${dirPath}:${filterQuery}
|
|
27370
|
+
`${scope}:${sessionId ?? "none"}:${dirPath}:${filterQuery}`
|
|
27545
27371
|
);
|
|
27546
27372
|
}
|
|
27547
27373
|
);
|
|
27548
|
-
var FileCompletionMenuContent = forwardRef2(function FileCompletionMenuContent2({ command: command2, editor, filterQuery, items, pluginItems, pluginError,
|
|
27374
|
+
var FileCompletionMenuContent = forwardRef2(function FileCompletionMenuContent2({ command: command2, editor, filterQuery, items, pluginItems, pluginError, topicItems, topicError, onExit, range, scope, sessionId }, ref) {
|
|
27549
27375
|
const [rawSelectedIndex, setRawSelectedIndex] = useState9(0);
|
|
27550
27376
|
const filteredEntries = useMemo8(() => filterEntries(items, filterQuery), [filterQuery, items]);
|
|
27551
27377
|
const navigableItems = useMemo8(
|
|
27552
|
-
() => [...pluginItems, ...
|
|
27553
|
-
[filteredEntries, pluginItems,
|
|
27378
|
+
() => [...pluginItems, ...topicItems, ...filteredEntries],
|
|
27379
|
+
[filteredEntries, pluginItems, topicItems]
|
|
27554
27380
|
);
|
|
27555
27381
|
const selectedIndex = navigableItems.length === 0 ? 0 : Math.min(rawSelectedIndex, navigableItems.length - 1);
|
|
27556
27382
|
const handleSelect = useCallback5(
|
|
27557
27383
|
(entry) => {
|
|
27558
|
-
if (isPluginSuggestionItem(entry) ||
|
|
27384
|
+
if (isPluginSuggestionItem(entry) || isTopicAssetSuggestionItem(entry)) {
|
|
27559
27385
|
command2(entry);
|
|
27560
27386
|
return;
|
|
27561
27387
|
}
|
|
@@ -27617,7 +27443,7 @@ var FileCompletionMenuContent = forwardRef2(function FileCompletionMenuContent2(
|
|
|
27617
27443
|
element.scrollIntoView({ block: "nearest" });
|
|
27618
27444
|
}
|
|
27619
27445
|
};
|
|
27620
|
-
const showGroupLabels = pluginItems.length > 0 ||
|
|
27446
|
+
const showGroupLabels = pluginItems.length > 0 || topicItems.length > 0 || Boolean(topicError);
|
|
27621
27447
|
const fileEmptyLabel = scope === "session" && !sessionId ? "\u6682\u65E0\u4F1A\u8BDD" : filteredEntries.length === 0 ? "\u6CA1\u6709\u6587\u4EF6" : null;
|
|
27622
27448
|
return /* @__PURE__ */ jsxs7("div", { className: "max-h-64 overflow-y-auto rounded-xl border border-[hsl(var(--border))] bg-[hsl(var(--popover))] py-1 shadow-[var(--swf-shadow-overlay)]", children: [
|
|
27623
27449
|
pluginError ? /* @__PURE__ */ jsx16("output", { className: "block px-3 py-2 text-xs text-muted-foreground", children: pluginError }) : null,
|
|
@@ -27639,32 +27465,11 @@ var FileCompletionMenuContent = forwardRef2(function FileCompletionMenuContent2(
|
|
|
27639
27465
|
},
|
|
27640
27466
|
`${item.plugin}:${item.server}:${item.id}`
|
|
27641
27467
|
)),
|
|
27642
|
-
kbItems.length > 0 ? /* @__PURE__ */ jsxs7(Fragment4, { children: [
|
|
27643
|
-
/* @__PURE__ */ jsx16("div", { className: "px-3 pt-1 pb-0.5 text-[10px] font-medium uppercase tracking-wider text-[hsl(var(--muted-foreground))]", children: "\u77E5\u8BC6\u5E93" }),
|
|
27644
|
-
kbItems.map((item, index) => /* @__PURE__ */ jsxs7(
|
|
27645
|
-
"button",
|
|
27646
|
-
{
|
|
27647
|
-
ref: selectedRef(pluginItems.length + index),
|
|
27648
|
-
type: "button",
|
|
27649
|
-
onMouseDown: (event) => {
|
|
27650
|
-
event.preventDefault();
|
|
27651
|
-
handleSelect(item);
|
|
27652
|
-
},
|
|
27653
|
-
className: rowClassName(pluginItems.length + index),
|
|
27654
|
-
children: [
|
|
27655
|
-
/* @__PURE__ */ jsx16(BookOpen, { size: 14, className: "shrink-0 text-[hsl(var(--primary))]" }),
|
|
27656
|
-
/* @__PURE__ */ jsx16("span", { className: "truncate", children: item.name }),
|
|
27657
|
-
item.description ? /* @__PURE__ */ jsx16("span", { className: "ml-auto max-w-[50%] truncate text-xs text-[hsl(var(--muted-foreground))]", children: item.description }) : null
|
|
27658
|
-
]
|
|
27659
|
-
},
|
|
27660
|
-
`kb-${item.kbId}`
|
|
27661
|
-
))
|
|
27662
|
-
] }) : null,
|
|
27663
27468
|
topicItems.length > 0 || topicError ? /* @__PURE__ */ jsxs7(Fragment4, { children: [
|
|
27664
27469
|
/* @__PURE__ */ jsx16("div", { className: "px-3 pt-1 pb-0.5 text-xs font-medium text-muted-foreground", children: "\u4E3B\u9898\u8D44\u4EA7" }),
|
|
27665
27470
|
topicError ? /* @__PURE__ */ jsx16("output", { className: "block px-3 py-2 text-xs text-muted-foreground", children: topicError }) : null,
|
|
27666
27471
|
topicItems.map((item, topicIndex) => {
|
|
27667
|
-
const index = pluginItems.length +
|
|
27472
|
+
const index = pluginItems.length + topicIndex;
|
|
27668
27473
|
return /* @__PURE__ */ jsxs7("button", { ref: selectedRef(index), type: "button", title: item.path, className: rowClassName(index), onMouseDown: (event) => {
|
|
27669
27474
|
event.preventDefault();
|
|
27670
27475
|
handleSelect(item);
|
|
@@ -27676,7 +27481,7 @@ var FileCompletionMenuContent = forwardRef2(function FileCompletionMenuContent2(
|
|
|
27676
27481
|
] }) : null,
|
|
27677
27482
|
showGroupLabels ? /* @__PURE__ */ jsx16("div", { className: "px-3 pt-1 pb-0.5 text-[10px] font-medium uppercase tracking-wider text-[hsl(var(--muted-foreground))]", children: "\u6587\u4EF6" }) : null,
|
|
27678
27483
|
fileEmptyLabel ? /* @__PURE__ */ jsx16("div", { className: "px-3 py-2 text-xs text-[hsl(var(--muted-foreground))]", children: fileEmptyLabel }) : filteredEntries.map((entry, fileIndex) => {
|
|
27679
|
-
const index = pluginItems.length +
|
|
27484
|
+
const index = pluginItems.length + topicItems.length + fileIndex;
|
|
27680
27485
|
return /* @__PURE__ */ jsxs7(
|
|
27681
27486
|
"button",
|
|
27682
27487
|
{
|
|
@@ -28102,7 +27907,7 @@ function replaceEditorText(editor, text) {
|
|
|
28102
27907
|
editor.commands.focus("end");
|
|
28103
27908
|
return;
|
|
28104
27909
|
}
|
|
28105
|
-
editor.commands.setContent(
|
|
27910
|
+
editor.commands.setContent(buildEditorDocument(text));
|
|
28106
27911
|
editor.commands.focus("end");
|
|
28107
27912
|
}
|
|
28108
27913
|
function getFileCardIcon(attachment) {
|
|
@@ -28789,7 +28594,6 @@ function ChatInput({
|
|
|
28789
28594
|
(state3) => activeSessionId ? state3.sendRequests[activeSessionId] : void 0
|
|
28790
28595
|
);
|
|
28791
28596
|
const connectionStatus = useComposerConnection(activeSessionId);
|
|
28792
|
-
const loadKnowledgeBases2 = useKnowledgeBaseLoader();
|
|
28793
28597
|
const inputHistory = useInputHistory(activeSessionId, client);
|
|
28794
28598
|
const queuedTopicRefs = useComposerChannels((state3) => activeSessionId ? state3.topicAssetReferences[activeSessionId] : void 0);
|
|
28795
28599
|
const getTopicSuggestions = useEffectEvent(async (query) => {
|
|
@@ -28803,18 +28607,10 @@ function ChatInput({
|
|
|
28803
28607
|
});
|
|
28804
28608
|
const getSessionId = useEffectEvent(() => activeSessionId);
|
|
28805
28609
|
const handleSlashCommand = useEffectEvent((commandId) => onCommand?.(commandId));
|
|
28806
|
-
const getKbSuggestionItems = useEffectEvent(async () => {
|
|
28807
|
-
try {
|
|
28808
|
-
return toKbSuggestionItems(await loadKnowledgeBases2());
|
|
28809
|
-
} catch {
|
|
28810
|
-
return [];
|
|
28811
|
-
}
|
|
28812
|
-
});
|
|
28813
28610
|
const referenceCandidates = useReferenceCandidates(
|
|
28814
28611
|
() => [client, client.token, activeSessionId, currentSession?.chat_group_id],
|
|
28815
28612
|
{
|
|
28816
28613
|
plugins: (query) => getPluginSuggestionItems(client, getSessionId(), query),
|
|
28817
|
-
kbs: getKbSuggestionItems,
|
|
28818
28614
|
topics: getTopicSuggestions,
|
|
28819
28615
|
files: (query) => getFileSuggestionItems(client, getSessionId(), query)
|
|
28820
28616
|
}
|
|
@@ -28902,7 +28698,7 @@ function ChatInput({
|
|
|
28902
28698
|
command: ({ editor: suggestionEditor, props, range }) => {
|
|
28903
28699
|
const item = props;
|
|
28904
28700
|
suggestionEditor.chain().focus().insertContentAt(range, [
|
|
28905
|
-
isPluginSuggestionItem(item) ? { type: "pluginMention", attrs: { provider: item.provider, plugin: item.plugin, server: item.server, id: item.id, label: item.label } } : isTopicAssetSuggestionItem(item) ? { type: "topicAssetMention", attrs: { topic_id: item.topic_id, path: item.path } } :
|
|
28701
|
+
isPluginSuggestionItem(item) ? { type: "pluginMention", attrs: { provider: item.provider, plugin: item.plugin, server: item.server, id: item.id, label: item.label } } : isTopicAssetSuggestionItem(item) ? { type: "topicAssetMention", attrs: { topic_id: item.topic_id, path: item.path } } : { type: "fileMention", attrs: { name: item.name, path: item.path } },
|
|
28906
28702
|
{
|
|
28907
28703
|
type: "text",
|
|
28908
28704
|
text: " "
|
|
@@ -28979,7 +28775,6 @@ function ChatInput({
|
|
|
28979
28775
|
}
|
|
28980
28776
|
}),
|
|
28981
28777
|
WorkflowMention,
|
|
28982
|
-
KbMention,
|
|
28983
28778
|
PluginMention,
|
|
28984
28779
|
TopicAssetMention,
|
|
28985
28780
|
SkillMention.configure({
|
|
@@ -29068,7 +28863,7 @@ function ChatInput({
|
|
|
29068
28863
|
}
|
|
29069
28864
|
})
|
|
29070
28865
|
],
|
|
29071
|
-
content:
|
|
28866
|
+
content: buildEditorDocument(initialInput),
|
|
29072
28867
|
onCreate: ({ editor: editorInstance }) => {
|
|
29073
28868
|
editorRef.current = editorInstance;
|
|
29074
28869
|
syncEditorState(editorInstance);
|
|
@@ -29085,7 +28880,7 @@ function ChatInput({
|
|
|
29085
28880
|
"aria-label": resolvedInputLabel,
|
|
29086
28881
|
"data-testid": "chat-message-input",
|
|
29087
28882
|
"data-blade-input-label": resolvedInputLabel,
|
|
29088
|
-
class: "min-h-[34px] max-h-[240px] overflow-y-auto px-5 py-3 text-sm leading-relaxed text-[hsl(var(--foreground))] focus:outline-none [&_.file-mention-pill]:inline-flex [&_.file-mention-pill]:items-center [&_.file-mention-pill]:rounded-full [&_.file-mention-pill]:bg-[hsl(var(--accent))] [&_.file-mention-pill]:px-2 [&_.file-mention-pill]:py-0.5 [&_.file-mention-pill]:font-medium [&_.file-mention-pill]:text-[hsl(var(--primary))] [&_.file-mention-pill]:select-none [&_.file-mention-pill]:whitespace-nowrap [&_.skill-mention-pill]:inline-flex [&_.skill-mention-pill]:items-center [&_.skill-mention-pill]:rounded-full [&_.skill-mention-pill]:bg-[hsl(var(--primary)/0.15)] [&_.skill-mention-pill]:px-2 [&_.skill-mention-pill]:py-0.5 [&_.skill-mention-pill]:font-medium [&_.skill-mention-pill]:text-[hsl(var(--primary))] [&_.skill-mention-pill]:select-none [&_.skill-mention-pill]:whitespace-nowrap [&
|
|
28883
|
+
class: "min-h-[34px] max-h-[240px] overflow-y-auto px-5 py-3 text-sm leading-relaxed text-[hsl(var(--foreground))] focus:outline-none [&_.file-mention-pill]:inline-flex [&_.file-mention-pill]:items-center [&_.file-mention-pill]:rounded-full [&_.file-mention-pill]:bg-[hsl(var(--accent))] [&_.file-mention-pill]:px-2 [&_.file-mention-pill]:py-0.5 [&_.file-mention-pill]:font-medium [&_.file-mention-pill]:text-[hsl(var(--primary))] [&_.file-mention-pill]:select-none [&_.file-mention-pill]:whitespace-nowrap [&_.skill-mention-pill]:inline-flex [&_.skill-mention-pill]:items-center [&_.skill-mention-pill]:rounded-full [&_.skill-mention-pill]:bg-[hsl(var(--primary)/0.15)] [&_.skill-mention-pill]:px-2 [&_.skill-mention-pill]:py-0.5 [&_.skill-mention-pill]:font-medium [&_.skill-mention-pill]:text-[hsl(var(--primary))] [&_.skill-mention-pill]:select-none [&_.skill-mention-pill]:whitespace-nowrap [&_p:first-child]:mt-0 [&_p:last-child]:mb-0"
|
|
29089
28884
|
},
|
|
29090
28885
|
handleDOMEvents: {
|
|
29091
28886
|
focus: () => {
|
|
@@ -29324,7 +29119,7 @@ ${append2.text}` : append2.text;
|
|
|
29324
29119
|
}
|
|
29325
29120
|
if (isStreaming) {
|
|
29326
29121
|
const json = editor?.getJSON();
|
|
29327
|
-
if (composerAttachments.length > 0 || collectPluginMentions(json).length > 0 ||
|
|
29122
|
+
if (composerAttachments.length > 0 || collectPluginMentions(json).length > 0 || collectTopicAssetMentions(json).length > 0) {
|
|
29328
29123
|
notifyChat(environment, "info", "\u5F53\u524D\u56DE\u590D\u5C1A\u672A\u7ED3\u675F\uFF0C\u5E26\u9644\u4EF6\u6216\u5F15\u7528\u7684\u6D88\u606F\u8BF7\u7B49\u5F85\u672C\u8F6E\u7ED3\u675F\u540E\u518D\u53D1\u9001");
|
|
29329
29124
|
return;
|
|
29330
29125
|
}
|
|
@@ -29357,8 +29152,6 @@ ${append2.text}` : append2.text;
|
|
|
29357
29152
|
let submittedSessionId = activeSessionId;
|
|
29358
29153
|
const submittedAttachmentIds = composerAttachments.map((attachment) => attachment.id);
|
|
29359
29154
|
const skill = findLeadingSkillMention(json);
|
|
29360
|
-
const kbMentions = collectKbMentions(json);
|
|
29361
|
-
const kbIds = kbMentions.map((item) => item.kbId);
|
|
29362
29155
|
const refs = collectPluginMentions(json);
|
|
29363
29156
|
if (refs.length > 20) {
|
|
29364
29157
|
notifyChat(environment, "error", "\u6BCF\u6761\u6D88\u606F\u6700\u591A\u9009\u62E9 20 \u4E2A\u63D2\u4EF6\u6761\u76EE");
|
|
@@ -29509,7 +29302,6 @@ ${append2.text}` : append2.text;
|
|
|
29509
29302
|
reasoningLevel: thinkingAvailable ? selectedReasoningLevel || void 0 : void 0,
|
|
29510
29303
|
// 只有用户显式 @ 知识库才传选择;纯文本不附加知识库指令。
|
|
29511
29304
|
refs: pluginRefsForSend(refs, sessionHandle?.getState().turns),
|
|
29512
|
-
kbIds: kbIds.length > 0 ? kbIds : void 0,
|
|
29513
29305
|
topicAssetRefs: topicAssetRefs.length > 0 ? topicAssetRefs : void 0
|
|
29514
29306
|
});
|
|
29515
29307
|
} catch (error) {
|
|
@@ -30112,8 +29904,6 @@ export {
|
|
|
30112
29904
|
FileMention,
|
|
30113
29905
|
FileSizeLimitDialog,
|
|
30114
29906
|
IMAGE_INPUT_UNSUPPORTED_MESSAGE,
|
|
30115
|
-
KB_SUGGESTION_TIMEOUT_MS,
|
|
30116
|
-
KbMention,
|
|
30117
29907
|
LIVE_STATUSES,
|
|
30118
29908
|
MODEL_LOADING_SEND_HINT,
|
|
30119
29909
|
MODEL_REASONING_LEVELS_KEY,
|
|
@@ -30132,18 +29922,16 @@ export {
|
|
|
30132
29922
|
TopicAssetMention,
|
|
30133
29923
|
VoiceWaveform,
|
|
30134
29924
|
WorkflowMention,
|
|
30135
|
-
|
|
29925
|
+
buildEditorDocument,
|
|
30136
29926
|
buildEditorDocumentWithMentions,
|
|
30137
29927
|
buildSubmitPayload,
|
|
30138
29928
|
buildVoiceInputUnavailableError,
|
|
30139
|
-
collectKbMentions,
|
|
30140
29929
|
collectPluginMentions,
|
|
30141
29930
|
collectTopicAssetMentions,
|
|
30142
29931
|
entryLabel,
|
|
30143
29932
|
estimateTokenCount,
|
|
30144
29933
|
fetchClientQuery,
|
|
30145
29934
|
fileMentionSuggestionKey,
|
|
30146
|
-
filterKbSuggestions,
|
|
30147
29935
|
findLeadingSkillMention,
|
|
30148
29936
|
formatFileSize,
|
|
30149
29937
|
formatStartedAt,
|
|
@@ -30162,14 +29950,12 @@ export {
|
|
|
30162
29950
|
invalidateSlashSuggestions,
|
|
30163
29951
|
isImageFile,
|
|
30164
29952
|
isImeCompositionKey,
|
|
30165
|
-
isKbSuggestionItem,
|
|
30166
29953
|
isPluginSuggestionItem,
|
|
30167
29954
|
isSubmittedComposerStillCurrent,
|
|
30168
29955
|
isTopicAssetSuggestionError,
|
|
30169
29956
|
isTopicAssetSuggestionItem,
|
|
30170
29957
|
listUserHomeDir,
|
|
30171
29958
|
mergeSubmittedAttachmentUpdates,
|
|
30172
|
-
notifyWhenKbSuggestionsArriveLate,
|
|
30173
29959
|
parseUserHomeQuery,
|
|
30174
29960
|
queueTopicAssetReference,
|
|
30175
29961
|
reasoningLevelLabel,
|
|
@@ -30187,7 +29973,6 @@ export {
|
|
|
30187
29973
|
splitTasks,
|
|
30188
29974
|
statusClass,
|
|
30189
29975
|
statusLabel,
|
|
30190
|
-
toKbSuggestionItems,
|
|
30191
29976
|
tokenPressureOf,
|
|
30192
29977
|
uploadedPathsById,
|
|
30193
29978
|
useBackgroundTaskList,
|
|
@@ -30205,7 +29990,6 @@ export {
|
|
|
30205
29990
|
useContextStats,
|
|
30206
29991
|
useDismissSkillSuggestionsOnModeChange,
|
|
30207
29992
|
useInputHistory,
|
|
30208
|
-
useKnowledgeBaseLoader,
|
|
30209
29993
|
useModelCatalog,
|
|
30210
29994
|
useModelPreferences,
|
|
30211
29995
|
useReasoningLevelPreference,
|
|
@@ -30218,7 +30002,6 @@ export {
|
|
|
30218
30002
|
useSkillStats,
|
|
30219
30003
|
useTiptapVoiceInput,
|
|
30220
30004
|
useVoiceInput,
|
|
30221
|
-
withKbSuggestionTimeout,
|
|
30222
30005
|
workflowParamsTail,
|
|
30223
30006
|
workflowRunText
|
|
30224
30007
|
};
|