@blade-hq/agent-react 2612.0.0-beta.12 → 2612.0.0-beta.14

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.
@@ -5,6 +5,7 @@ import {
5
5
  ArrowUpRight,
6
6
  Ban,
7
7
  BellRing,
8
+ BladeProvider,
8
9
  BookOpen,
9
10
  Bookmark,
10
11
  Bot,
@@ -147,7 +148,10 @@ function useAgentSession(sessionId, options = {}) {
147
148
  let pendingCleanup = null;
148
149
  const idPromise = targetId ? Promise.resolve(targetId) : (
149
150
  // biome-ignore lint/suspicious/noAssignInExpressions: ??= 挂 ref 是 StrictMode 下"只创建一次"的关键
150
- createdIdPromiseRef.current ??= client.sessions.create(createOptionsRef.current ?? {}).then((created) => {
151
+ createdIdPromiseRef.current ??= createOptionsRef.current?.anonymous ? client.sessions.createSessionWithRequest(createOptionsRef.current).then(({ session_id }) => {
152
+ onCreatedRef.current?.(session_id);
153
+ return session_id;
154
+ }) : client.sessions.create(createOptionsRef.current ?? {}).then((created) => {
151
155
  const id = created.sessionId;
152
156
  created.dispose();
153
157
  onCreatedRef.current?.(id);
@@ -155,7 +159,7 @@ function useAgentSession(sessionId, options = {}) {
155
159
  })
156
160
  );
157
161
  idPromise.then(
158
- (id) => client.hub.connect(id, {
162
+ (id) => (createOptionsRef.current?.anonymous ? client.forAnonymousSession(id) : client).hub.connect(id, {
159
163
  setup: (next) => {
160
164
  pendingCleanup = onConnectedRef.current?.(next) ?? null;
161
165
  }
@@ -48798,6 +48802,7 @@ function ChatSessionView({
48798
48802
  onUnauthorized
48799
48803
  }) {
48800
48804
  const client = useBladeClient();
48805
+ const host = useBladeHost();
48801
48806
  const { session, state, error: error61 } = useAgentSession(sessionId, {
48802
48807
  createOptions,
48803
48808
  onSessionCreated
@@ -48847,7 +48852,8 @@ function ChatSessionView({
48847
48852
  []
48848
48853
  );
48849
48854
  const connectError = error61 && !isUnauthorizedError(error61) ? error61.message || "\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5" : null;
48850
- return /* @__PURE__ */ jsx51(SessionSourceProvider, { source, children: /* @__PURE__ */ jsx51(ChatEnvironmentProvider, { value: environment, children: /* @__PURE__ */ jsx51(
48855
+ const sessionClient = resolvedSessionId && createOptions?.anonymous && !client.options.anonymousSessionId ? client.forAnonymousSession(resolvedSessionId) : client;
48856
+ return /* @__PURE__ */ jsx51(BladeProvider, { client: sessionClient, host, children: /* @__PURE__ */ jsx51(SessionSourceProvider, { source, children: /* @__PURE__ */ jsx51(ChatEnvironmentProvider, { value: environment, children: /* @__PURE__ */ jsx51(
48851
48857
  ChatPanel,
48852
48858
  {
48853
48859
  sessionId: resolvedSessionId ?? "",
@@ -48862,11 +48868,11 @@ function ChatSessionView({
48862
48868
  errorMessage: connectError ?? replay.error?.message ?? notice,
48863
48869
  onExitReplay: () => void replay.exitToAutonomous(),
48864
48870
  banner: /* @__PURE__ */ jsxs44(Fragment19, { children: [
48865
- resolvedSessionId && !isViewer && (sessionPluginControls ? sessionPluginControls(resolvedSessionId) : /* @__PURE__ */ jsx51(SessionPluginSelector, { client, sessionId: resolvedSessionId })),
48871
+ resolvedSessionId && !isViewer && (sessionPluginControls ? sessionPluginControls(resolvedSessionId) : client.options.anonymousSessionId || createOptions?.anonymous ? null : /* @__PURE__ */ jsx51(SessionPluginSelector, { client, sessionId: resolvedSessionId })),
48866
48872
  /* @__PURE__ */ jsx51(ReplayMismatchPrompt, { mismatch: replay.mismatch })
48867
48873
  ] })
48868
48874
  }
48869
- ) }) });
48875
+ ) }) }) });
48870
48876
  }
48871
48877
 
48872
48878
  // src/components/LlmChat.tsx
@@ -49622,4 +49628,4 @@ use-stick-to-bottom/dist/StickToBottom.js:
49622
49628
  js-yaml/dist/js-yaml.mjs:
49623
49629
  (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
49624
49630
  */
49625
- //# sourceMappingURL=chunk-JVM2WTTS.js.map
49631
+ //# sourceMappingURL=chunk-6YMUPKGL.js.map