@blade-hq/agent-react 2612.0.0-beta.17 → 2612.0.0-beta.18

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.
@@ -70,6 +70,7 @@ declare const BladeAgent: {
70
70
  userFacingErrorText: typeof agentClient.userFacingErrorText;
71
71
  normalizeTopicAssetRefs: typeof agentClient.normalizeTopicAssetRefs;
72
72
  normalizePluginRefs: typeof agentClient.normalizePluginRefs;
73
+ normalizeMessageRefs: typeof agentClient.normalizeMessageRefs;
73
74
  ToolProvider: typeof agentClient.ToolProvider;
74
75
  getChat: typeof getChat;
75
76
  BladeChatElement: typeof BladeChatElement;
package/dist/index.js CHANGED
@@ -7,11 +7,11 @@ import {
7
7
  useAgentSession,
8
8
  useReplay,
9
9
  useTopicAssetSubmissionAccess
10
- } from "./chunk-6YMUPKGL.js";
10
+ } from "./chunk-VVIXFBWF.js";
11
11
  import {
12
12
  BladeProvider,
13
13
  useBladeClient
14
- } from "./chunk-7TQVTNPL.js";
14
+ } from "./chunk-GXJCVUXP.js";
15
15
  import "./chunk-PR4QN5HX.js";
16
16
  export {
17
17
  BladeProvider,
package/dist/internal.js CHANGED
@@ -30,14 +30,14 @@ import {
30
30
  useTopicAssetSubmissionAccess,
31
31
  useTurnNavigation,
32
32
  useTypewriterReveal
33
- } from "./chunk-6YMUPKGL.js";
33
+ } from "./chunk-VVIXFBWF.js";
34
34
  import {
35
35
  ConnectorPanel,
36
36
  PluginTriggerStack,
37
37
  TRIGGER_ICON_LIMIT,
38
38
  selectionFromItem,
39
39
  triggerSummary
40
- } from "./chunk-EYRP6PV3.js";
40
+ } from "./chunk-LC7Q64YI.js";
41
41
  import {
42
42
  BladeProvider,
43
43
  Content2,
@@ -64,7 +64,7 @@ import {
64
64
  useBladeHost,
65
65
  useOptionalBladeClient,
66
66
  useSessionPluginActivation
67
- } from "./chunk-7TQVTNPL.js";
67
+ } from "./chunk-GXJCVUXP.js";
68
68
  import "./chunk-PR4QN5HX.js";
69
69
 
70
70
  // src/internal.ts
@@ -48,4 +48,4 @@ export * from "./lib/topic-asset-suggestions";
48
48
  export * from "./use-reference-candidates";
49
49
  export { PluginMention, isPluginSuggestionItem } from "./extensions/plugin-mention";
50
50
  export { getPluginSuggestionItems } from "./lib/plugin-suggestions";
51
- export { collectPluginMentions } from "./lib/composer-content";
51
+ export { collectPluginMentions, collectMessageMentions } from "./lib/composer-content";
@@ -1,4 +1,4 @@
1
- import { type PluginRef, type TopicAssetRef, type SkillMentionAvailability } from "@blade-hq/agent-client";
1
+ import { type PluginRef, type MessageRef, type TopicAssetRef, type SkillMentionAvailability } from "@blade-hq/agent-client";
2
2
  /**
3
3
  * 输入框(tiptap)文档的最小结构,以及把它翻译成待发送文本的规则。
4
4
  *
@@ -30,3 +30,7 @@ export declare function buildEditorDocumentWithMentions(text: string, topicAsset
30
30
  export declare function retainTopicAssetMentions(node: EditorJSON, topicId: string | null): EditorJSON;
31
31
  export declare function collectPluginMentions(node: EditorJSON | null | undefined): PluginRef[];
32
32
  export declare function buildEditorDocument(text: string): EditorJSON;
33
+ /** Mention identity is separate from user intent; position never implies execution. */
34
+ export declare function collectMessageMentions(node: EditorJSON | null | undefined): MessageRef[];
35
+ /** Only plugin selections persist into the next message. */
36
+ export declare function buildPluginSelectionDocument(refs: readonly MessageRef[]): EditorJSON;
@@ -1,7 +1,7 @@
1
- import type { BladeClient, PluginRef } from "@blade-hq/agent-client";
1
+ import type { BladeClient, MessageRef } from "@blade-hq/agent-client";
2
2
  import type { PluginSuggestionItem, PluginSuggestionError } from "../extensions/plugin-mention";
3
- export declare function pluginRefsForSend(refs: PluginRef[], turns?: readonly {
3
+ export declare function pluginRefsForSend(refs: MessageRef[], turns?: readonly {
4
4
  role: string;
5
- refs?: PluginRef[] | null;
6
- }[]): PluginRef[] | undefined;
5
+ refs?: MessageRef[] | null;
6
+ }[]): MessageRef[] | undefined;
7
7
  export declare function getPluginSuggestionItems(client: BladeClient, session: string | null | undefined, query: string, pendingPlugins?: readonly string[]): Promise<Array<PluginSuggestionItem | PluginSuggestionError>>;
@@ -3,7 +3,7 @@ import {
3
3
  PluginTriggerStack,
4
4
  selectionFromItem,
5
5
  triggerSummary
6
- } from "./chunk-EYRP6PV3.js";
6
+ } from "./chunk-LC7Q64YI.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-7TQVTNPL.js";
65
+ } from "./chunk-GXJCVUXP.js";
66
66
  import {
67
67
  __commonJS,
68
68
  __require,
@@ -18948,7 +18948,7 @@ var PluginMention = index_default.extend({
18948
18948
  });
18949
18949
 
18950
18950
  // src/rich-input/lib/composer-content.ts
18951
- import { normalizePluginRefs, normalizeTopicAssetRefs } from "@blade-hq/agent-client";
18951
+ import { normalizePluginRefs, normalizeMessageRefs, normalizeTopicAssetRefs } from "@blade-hq/agent-client";
18952
18952
  function serializeEditorContent(node) {
18953
18953
  if (!node) return "";
18954
18954
  if (node.type === "text") {
@@ -18963,7 +18963,7 @@ function serializeEditorContent(node) {
18963
18963
  }
18964
18964
  if (node.type === "skillMention") {
18965
18965
  const skillId = typeof node.attrs?.skillId === "string" ? node.attrs.skillId : "";
18966
- return skillId ? `<skill>${skillId}</skill>` : "";
18966
+ return skillId ? `@${node.attrs?.displayName || skillId}` : "";
18967
18967
  }
18968
18968
  if (node.type === "pluginMention") return `@${node.attrs?.label ?? ""}`;
18969
18969
  if (node.type === "topicAssetMention") {
@@ -19065,6 +19065,27 @@ function collectPluginMentions(node) {
19065
19065
  function buildEditorDocument(text) {
19066
19066
  return { type: "doc", content: text.split("\n").map((line) => ({ type: "paragraph", content: line ? [{ type: "text", text: line }] : [] })) };
19067
19067
  }
19068
+ function collectMessageMentions(node) {
19069
+ const refs = [];
19070
+ const visit = (current) => {
19071
+ if (!current) return;
19072
+ if (current.type === "pluginMention") refs.push(current.attrs);
19073
+ if (current.type === "skillMention") refs.push({
19074
+ provider: "skill",
19075
+ id: current.attrs?.skillId,
19076
+ label: current.attrs?.displayName || current.attrs?.skillId
19077
+ });
19078
+ current.content?.forEach(visit);
19079
+ };
19080
+ visit(node);
19081
+ return normalizeMessageRefs(refs);
19082
+ }
19083
+ function buildPluginSelectionDocument(refs) {
19084
+ return { type: "doc", content: [{ type: "paragraph", content: normalizePluginRefs(refs).flatMap((ref) => [
19085
+ { type: "pluginMention", attrs: { ...ref } },
19086
+ { type: "text", text: " " }
19087
+ ]) }] };
19088
+ }
19068
19089
 
19069
19090
  // src/rich-input/extensions/topic-asset-mention.ts
19070
19091
  function isTopicAssetSuggestionItem(value) {
@@ -27062,8 +27083,7 @@ function splitFilesBySize(files, limitBytes = ATTACHMENT_SIZE_LIMIT_BYTES) {
27062
27083
 
27063
27084
  // src/rich-input/ChatInput.tsx
27064
27085
  import {
27065
- buildMessageContent,
27066
- transformSlashCommand
27086
+ buildMessageContent
27067
27087
  } from "@blade-hq/agent-client/internal";
27068
27088
 
27069
27089
  // src/rich-input/lib/upload-results.ts
@@ -28901,7 +28921,7 @@ function ChatInput({
28901
28921
  if (!latest || latest.turn_id.startsWith("local-user-")) return;
28902
28922
  restoredPluginSelection.current = activeSessionId;
28903
28923
  if (!getEditorText(editor).trim() && latest.refs?.length) {
28904
- editor.commands.setContent({ type: "doc", content: [{ type: "paragraph", content: latest.refs.flatMap((ref) => [{ type: "pluginMention", attrs: { ...ref } }, { type: "text", text: " " }]) }] });
28924
+ editor.commands.setContent(buildPluginSelectionDocument(latest.refs));
28905
28925
  }
28906
28926
  };
28907
28927
  restore();
@@ -29001,7 +29021,7 @@ ${append2.text}` : append2.text;
29001
29021
  }
29002
29022
  if (isStreaming) {
29003
29023
  const json = editor?.getJSON();
29004
- if (composerAttachments.length > 0 || collectPluginMentions(json).length > 0 || collectTopicAssetMentions(json).length > 0) {
29024
+ if (composerAttachments.length > 0 || collectMessageMentions(json).length > 0 || collectTopicAssetMentions(json).length > 0) {
29005
29025
  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");
29006
29026
  return;
29007
29027
  }
@@ -29033,10 +29053,9 @@ ${append2.text}` : append2.text;
29033
29053
  const rawText = serializeEditorContent(json);
29034
29054
  let submittedSessionId = activeSessionId;
29035
29055
  const submittedAttachmentIds = composerAttachments.map((attachment) => attachment.id);
29036
- const skill = findLeadingSkillMention(json);
29037
- const refs = collectPluginMentions(json);
29056
+ const refs = collectMessageMentions(json);
29038
29057
  if (refs.length > 20) {
29039
- notifyChat(environment, "error", "\u6BCF\u6761\u6D88\u606F\u6700\u591A\u9009\u62E9 20 \u4E2A\u63D2\u4EF6\u6761\u76EE");
29058
+ notifyChat(environment, "error", "\u6BCF\u6761\u6D88\u606F\u6700\u591A\u9009\u62E9 20 \u4E2A\u5F15\u7528");
29040
29059
  return;
29041
29060
  }
29042
29061
  const topicAssetRefs = collectTopicAssetMentions(json);
@@ -29044,10 +29063,7 @@ ${append2.text}` : append2.text;
29044
29063
  notifyChat(environment, "error", "\u6BCF\u6761\u6D88\u606F\u6700\u591A\u5F15\u7528 20 \u4E2A\u4E3B\u9898\u8D44\u4EA7");
29045
29064
  return;
29046
29065
  }
29047
- const text = skill ? transformSlashCommand(skill.skillId, rawText, {
29048
- local: skill.local,
29049
- installed: skill.installed
29050
- }) : rawText;
29066
+ const text = rawText;
29051
29067
  const pendingFiles = composerAttachments.filter(
29052
29068
  (a) => a.kind === "file" && a.status === "pending" && !!a.file
29053
29069
  );
@@ -29200,7 +29216,7 @@ ${append2.text}` : append2.text;
29200
29216
  return;
29201
29217
  }
29202
29218
  if (refs.length && editor && !getEditorText(editor).trim()) {
29203
- editor.commands.setContent({ type: "doc", content: [{ type: "paragraph", content: refs.flatMap((ref) => [{ type: "pluginMention", attrs: { ...ref } }, { type: "text", text: " " }]) }] });
29219
+ editor.commands.setContent(buildPluginSelectionDocument(refs));
29204
29220
  }
29205
29221
  if (activeSessionId && activePendingContexts.length > 0) {
29206
29222
  composerChannels.consumePendingContexts(activeSessionId);
@@ -29805,8 +29821,10 @@ export {
29805
29821
  VoiceWaveform,
29806
29822
  buildEditorDocument,
29807
29823
  buildEditorDocumentWithMentions,
29824
+ buildPluginSelectionDocument,
29808
29825
  buildSubmitPayload,
29809
29826
  buildVoiceInputUnavailableError,
29827
+ collectMessageMentions,
29810
29828
  collectPluginMentions,
29811
29829
  collectTopicAssetMentions,
29812
29830
  entryLabel,