@blade-hq/agent-react 2612.0.0-beta.86 → 2612.0.0-beta.88

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.
Files changed (55) hide show
  1. package/README.md +1 -1
  2. package/dist/SessionPluginConfigForm-Y657MKRX.js +9 -0
  3. package/dist/chat/AssistantTurnBlock.d.ts +2 -1
  4. package/dist/chat/ChatLoadingIndicator.d.ts +9 -1
  5. package/dist/chat/ChatPanel.d.ts +3 -1
  6. package/dist/chat/FileDeliveryCards.d.ts +12 -6
  7. package/dist/chat/ai-elements/shimmer.d.ts +4 -0
  8. package/dist/chat/chat-column-width.d.ts +21 -0
  9. package/dist/chat/index.d.ts +3 -1
  10. package/dist/chat/runtime/actions.d.ts +5 -1
  11. package/dist/chat/runtime/environment.d.ts +2 -0
  12. package/dist/chat/runtime/use-chat-actions.d.ts +1 -1
  13. package/dist/chat.css +18 -0
  14. package/dist/{chunk-SK43YNRX.js → chunk-5ESAKOUV.js} +2 -2
  15. package/dist/{chunk-6RQGCCG7.js → chunk-5UGLGKFI.js} +205 -7
  16. package/dist/chunk-5UGLGKFI.js.map +1 -0
  17. package/dist/{chunk-LYDXKR3Q.js → chunk-7LVZQ4LS.js} +95 -70
  18. package/dist/chunk-7LVZQ4LS.js.map +1 -0
  19. package/dist/{chunk-MWILWSPG.js → chunk-GXHHSZSS.js} +2 -2
  20. package/dist/{chunk-C3LBNHVM.js → chunk-LOXIHCL2.js} +13 -7
  21. package/dist/{chunk-C3LBNHVM.js.map → chunk-LOXIHCL2.js.map} +1 -1
  22. package/dist/{chunk-FDB3J5QF.js → chunk-NADWKQYZ.js} +76 -11
  23. package/dist/{chunk-FDB3J5QF.js.map → chunk-NADWKQYZ.js.map} +1 -1
  24. package/dist/{chunk-FH5HA3GW.js → chunk-PWUFWSMN.js} +6 -6
  25. package/dist/chunk-PWUFWSMN.js.map +1 -0
  26. package/dist/{chunk-RGL2XUQR.js → chunk-QKI7OC5D.js} +1803 -1183
  27. package/dist/chunk-QKI7OC5D.js.map +1 -0
  28. package/dist/{chunk-KHJEIHMJ.js → chunk-SEJUZPT5.js} +37 -60
  29. package/dist/chunk-SEJUZPT5.js.map +1 -0
  30. package/dist/{chunk-NRYLAO3X.js → chunk-VTEKA5HD.js} +281 -102
  31. package/dist/{chunk-NRYLAO3X.js.map → chunk-VTEKA5HD.js.map} +1 -1
  32. package/dist/connectors.js +3 -3
  33. package/dist/index.js +9 -9
  34. package/dist/internal.d.ts +2 -2
  35. package/dist/internal.js +620 -46
  36. package/dist/internal.js.map +1 -1
  37. package/dist/questions.js +4 -4
  38. package/dist/rich-input/ChatInput.d.ts +1 -1
  39. package/dist/rich-input/ModelSelector.d.ts +3 -1
  40. package/dist/rich-input/model/resolve-model.d.ts +1 -1
  41. package/dist/rich-input.js +1051 -1185
  42. package/dist/rich-input.js.map +1 -1
  43. package/dist/style.full.css +19 -1
  44. package/dist/tool-details.js +5 -5
  45. package/package.json +2 -2
  46. package/dist/SessionPluginConfigForm-7LJ5SUNY.js +0 -9
  47. package/dist/chat-IHPRU35X.css +0 -162
  48. package/dist/chunk-6RQGCCG7.js.map +0 -1
  49. package/dist/chunk-FH5HA3GW.js.map +0 -1
  50. package/dist/chunk-KHJEIHMJ.js.map +0 -1
  51. package/dist/chunk-LYDXKR3Q.js.map +0 -1
  52. package/dist/chunk-RGL2XUQR.js.map +0 -1
  53. /package/dist/{SessionPluginConfigForm-7LJ5SUNY.js.map → SessionPluginConfigForm-Y657MKRX.js.map} +0 -0
  54. /package/dist/{chunk-SK43YNRX.js.map → chunk-5ESAKOUV.js.map} +0 -0
  55. /package/dist/{chunk-MWILWSPG.js.map → chunk-GXHHSZSS.js.map} +0 -0
@@ -5,7 +5,7 @@ import {
5
5
  DialogContent,
6
6
  DialogTitle,
7
7
  clsx
8
- } from "./chunk-MWILWSPG.js";
8
+ } from "./chunk-GXHHSZSS.js";
9
9
  import {
10
10
  Check,
11
11
  ChevronDown,
@@ -13,7 +13,7 @@ import {
13
13
  CircleDot,
14
14
  ListChecks,
15
15
  LoaderCircle
16
- } from "./chunk-KHJEIHMJ.js";
16
+ } from "./chunk-SEJUZPT5.js";
17
17
 
18
18
  // src/context.tsx
19
19
  import { createContext, useContext } from "react";
@@ -87,6 +87,22 @@ var TOOL_DISPLAY_LABELS = {
87
87
  ListSessions: "\u5217\u51FA\u5386\u53F2\u4F1A\u8BDD",
88
88
  GetSessionHistory: "\u8BFB\u53D6\u4F1A\u8BDD\u5386\u53F2"
89
89
  };
90
+ var TOOL_SUMMARY_TEMPLATES = {
91
+ Bash: (n) => `\u6267\u884C ${n} \u6761\u547D\u4EE4`,
92
+ BgBash: (n) => `\u542F\u52A8 ${n} \u4E2A\u540E\u53F0\u4EFB\u52A1`,
93
+ CodeMode: (n) => `\u6267\u884C ${n} \u6B21\u7A0B\u5E8F`,
94
+ Read: (n) => `\u8BFB\u53D6 ${n} \u4E2A\u6587\u4EF6`,
95
+ Write: (n) => `\u5199\u5165 ${n} \u4E2A\u6587\u4EF6`,
96
+ Edit: (n) => `\u7F16\u8F91 ${n} \u4E2A\u6587\u4EF6`,
97
+ MultiEdit: (n) => `\u7F16\u8F91 ${n} \u4E2A\u6587\u4EF6`,
98
+ Ls: (n) => `\u67E5\u770B ${n} \u4E2A\u76EE\u5F55`,
99
+ Glob: (n) => `\u5339\u914D ${n} \u7EC4\u6587\u4EF6`,
100
+ Grep: (n) => `\u641C\u7D22 ${n} \u6B21\u6587\u672C`,
101
+ WebSearch: (n) => `\u641C\u7D22 ${n} \u6B21\u7F51\u9875`,
102
+ WebFetch: (n) => `\u6574\u7406 ${n} \u6B21\u7F51\u9875`,
103
+ ReadSkill: (n) => `\u8BFB\u53D6 ${n} \u4E2A\u6280\u80FD`,
104
+ Agent: (n) => `\u8C03\u7528 ${n} \u4E2A\u5B50\u667A\u80FD\u4F53`
105
+ };
90
106
  var OUTPUT_TOOL_ICONS = {
91
107
  Write: "\u{1F4C4}",
92
108
  Edit: "\u{1F4DD}",
@@ -105,6 +121,7 @@ var PRIORITY_FILE_KEYS = [
105
121
  "destination",
106
122
  "filename"
107
123
  ];
124
+ var INDIVIDUAL_SUMMARY_TOOL_NAMES = /* @__PURE__ */ new Set(["Bash", "BgBash"]);
108
125
  function safeParseJson(value) {
109
126
  if (!value) return null;
110
127
  try {
@@ -258,6 +275,153 @@ function getToolOutputTag(toolCall) {
258
275
  tone: "file"
259
276
  };
260
277
  }
278
+ function isSuccessfulToolCall(toolCall) {
279
+ if (toolCall.status === "error" || toolCall.status === "cancelled") return false;
280
+ if (toolCall.status === "awaiting_answer") return false;
281
+ if (toolCall.status === "pending") return false;
282
+ return toolCall.status === "done" || toolCall.result != null || toolCall.status == null;
283
+ }
284
+ function countSuccessfulToolCalls(toolCalls) {
285
+ return toolCalls.filter(isSuccessfulToolCall).length;
286
+ }
287
+ function countPendingToolCalls(toolCalls) {
288
+ return toolCalls.filter(
289
+ (toolCall) => toolCall.status === "pending" || toolCall.status === "awaiting_answer"
290
+ ).length;
291
+ }
292
+ function formatToolCallCount(count) {
293
+ return `\u5DF2\u6267\u884C ${count} \u6B21\u5DE5\u5177\u8C03\u7528`;
294
+ }
295
+ function summarizeToolCalls(toolCalls) {
296
+ const outputTagMap = /* @__PURE__ */ new Map();
297
+ const counts = /* @__PURE__ */ new Map();
298
+ const individualTags = [];
299
+ for (const toolCall of toolCalls.filter(isSuccessfulToolCall)) {
300
+ const normalized = formatToolName(toolCall.name);
301
+ const args = safeParseJson(toolCall.arguments);
302
+ if (normalized === "Agent" || normalized === "FinishTask") continue;
303
+ if (INDIVIDUAL_SUMMARY_TOOL_NAMES.has(normalized)) {
304
+ if (normalized === "Bash") {
305
+ individualTags.push({
306
+ key: `${individualTags.length}-${toolCall.id}`,
307
+ label: getCommandDescription(args) || "\u6267\u884C\u547D\u4EE4\u884C\u64CD\u4F5C",
308
+ tone: "action"
309
+ });
310
+ continue;
311
+ }
312
+ if (normalized === "BgBash") {
313
+ individualTags.push({
314
+ key: `${individualTags.length}-${toolCall.id}`,
315
+ label: getCommandDescription(args) || "\u540E\u53F0\u6267\u884C\u547D\u4EE4",
316
+ tone: "action"
317
+ });
318
+ continue;
319
+ }
320
+ }
321
+ const outputTag = getToolOutputTag(toolCall);
322
+ if (outputTag) {
323
+ const fileLabel = outputTag.label.replace(/^[^\s]+\s+/, "");
324
+ const existing = outputTagMap.get(fileLabel);
325
+ if (existing?.label.startsWith("\u{1F4C4}")) {
326
+ continue;
327
+ }
328
+ outputTagMap.set(fileLabel, {
329
+ ...outputTag,
330
+ key: fileLabel,
331
+ label: normalized === "Write" || existing?.label.startsWith("\u{1F4DD}") ? `\u{1F4C4} ${fileLabel}` : outputTag.label
332
+ });
333
+ continue;
334
+ }
335
+ counts.set(normalized, (counts.get(normalized) ?? 0) + 1);
336
+ }
337
+ const aggregatedCountTags = [];
338
+ for (const [normalized, count] of counts.entries()) {
339
+ const template = TOOL_SUMMARY_TEMPLATES[normalized];
340
+ const label = template ? template(count) : `${TOOL_DISPLAY_LABELS[normalized] ?? normalized} \xD7${count}`;
341
+ aggregatedCountTags.push({
342
+ key: `${normalized}-${count}`,
343
+ label,
344
+ tone: "action"
345
+ });
346
+ }
347
+ const outputTags = [...outputTagMap.values()].sort(
348
+ (left, right) => left.label.localeCompare(right.label)
349
+ );
350
+ const sortedCountTags = aggregatedCountTags.sort(
351
+ (left, right) => left.label.localeCompare(right.label)
352
+ );
353
+ const merged = [...individualTags, ...outputTags, ...sortedCountTags];
354
+ if (merged.length <= 5) return merged;
355
+ return [
356
+ ...merged.slice(0, 5),
357
+ {
358
+ key: `overflow-${merged.length - 5}`,
359
+ label: `+${merged.length - 5} \u66F4\u591A`,
360
+ tone: "action"
361
+ }
362
+ ];
363
+ }
364
+ function getMessageText(message) {
365
+ if (typeof message.content === "string") return message.content;
366
+ return message.content.filter((part) => part.type === "text").map((part) => part.text).join("");
367
+ }
368
+ function hasNaturalLanguageText(message) {
369
+ return getMessageText(message).trim().length > 0;
370
+ }
371
+ function findAnchorMessageIndex(messages) {
372
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
373
+ if (hasNaturalLanguageText(messages[index])) {
374
+ return index;
375
+ }
376
+ }
377
+ return Math.max(messages.length - 1, 0);
378
+ }
379
+ function getCollapsedTurnSegments(messages) {
380
+ if (messages.length === 0) {
381
+ return { anchorIndex: 0, summaryMessages: [], visibleMessages: [] };
382
+ }
383
+ const anchorIndex = findAnchorMessageIndex(messages);
384
+ return {
385
+ anchorIndex,
386
+ summaryMessages: messages.slice(0, anchorIndex),
387
+ visibleMessages: messages.slice(anchorIndex)
388
+ };
389
+ }
390
+ function getLatestPendingToolName(toolCalls) {
391
+ for (let index = toolCalls.length - 1; index >= 0; index -= 1) {
392
+ if (toolCalls[index].status === "pending" || toolCalls[index].status === "awaiting_answer") {
393
+ return formatToolName(toolCalls[index].name);
394
+ }
395
+ }
396
+ return null;
397
+ }
398
+ function getFinishTaskTitle(toolCalls) {
399
+ for (let index = toolCalls.length - 1; index >= 0; index -= 1) {
400
+ if (formatToolName(toolCalls[index].name) !== "FinishTask") continue;
401
+ const args = safeParseJson(toolCalls[index].arguments);
402
+ if (!isPlainObject(args)) continue;
403
+ const title = typeof args.title === "string" ? args.title.trim() : "";
404
+ if (title) return title;
405
+ }
406
+ return null;
407
+ }
408
+ function getTextContentSegments(messages) {
409
+ return messages.map((message) => {
410
+ if (typeof message.content === "string") return message.content;
411
+ return message.content.filter((part) => part.type === "text").map((part) => part.text).join("");
412
+ }).map((text) => text.trim()).filter(Boolean);
413
+ }
414
+ function getLastTextSegment(messages) {
415
+ const texts = getTextContentSegments(messages);
416
+ return texts[texts.length - 1] ?? "";
417
+ }
418
+ function countMessageLines(message) {
419
+ const text = typeof message.content === "string" ? message.content : "";
420
+ const reasoningLines = message.reasoning ? message.reasoning.split("\n").length : 0;
421
+ const textLines = text.trim() ? text.trim().split("\n").length : 0;
422
+ const toolLines = message.tool_calls?.length ?? 0;
423
+ return reasoningLines + textLines + toolLines;
424
+ }
261
425
 
262
426
  // src/components/PlanUpdateBlock.tsx
263
427
  import { useEffect, useRef, useState } from "react";
@@ -3629,107 +3793,19 @@ function PlanUpdateBlock({
3629
3793
  ] });
3630
3794
  }
3631
3795
 
3632
- // src/components/AccountConnectorRules.tsx
3633
- import { useCallback } from "react";
3634
- import { jsx as jsx3 } from "react/jsx-runtime";
3635
- function AccountConnectorRules({ client, name, refresh = 0 }) {
3636
- const read = useCallback(() => client.connectors.rules(name), [client, name]);
3637
- const update = useCallback((set) => client.connectors.updateRules(name, set), [client, name]);
3638
- return /* @__PURE__ */ jsx3(ConnectorRulesPanel, { compact: true, read, update, refresh }, name);
3639
- }
3640
-
3641
- // src/components/BrowserConnectionDialog.tsx
3642
- import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
3643
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
3644
- function BrowserConnectionDialog({ client, name, label = "\u4E1A\u52A1\u8D26\u53F7", connector, onClose }) {
3645
- const [connection, setConnection] = useState2(connector?.connection);
3646
- const [editing, setEditing] = useState2(false);
3647
- const [refresh, setRefresh] = useState2(0);
3648
- const [frame, setFrame] = useState2(null);
3649
- const alive = useRef2(false);
3650
- useEffect2(() => {
3651
- alive.current = true;
3652
- return () => {
3653
- alive.current = false;
3654
- };
3655
- }, []);
3656
- const status = connection?.status ?? "disconnected";
3657
- const showLogin = status !== "connected" || editing;
3658
- const url = new URL(client.connectors.browserAuthorizationUrl(name), window.location.href);
3659
- const origin = url.origin;
3660
- useEffect2(() => {
3661
- if (!showLogin || !frame) return;
3662
- return client.connectors.bindBrowserAuthorizationFrame(frame, name);
3663
- }, [client, name, showLogin, frame]);
3664
- useEffect2(() => {
3665
- const receive = (event) => {
3666
- if (event.origin === origin && event.source === frame?.contentWindow && event.data?.type === "blade:connector-auth-close") onClose();
3667
- };
3668
- window.addEventListener("message", receive);
3669
- return () => window.removeEventListener("message", receive);
3670
- }, [origin, onClose, frame]);
3671
- const login = /* @__PURE__ */ jsxs2("div", { className: "space-y-3", children: [
3672
- /* @__PURE__ */ jsx4("p", { className: "text-xs opacity-70", children: "\u5728\u4E0B\u65B9\u9875\u9762\u5B8C\u6210\u767B\u5F55\u6216\u626B\u7801\uFF0C\u7136\u540E\u786E\u8BA4\u767B\u5F55\u3002\u9700\u8981\u9000\u51FA\u65F6\u53EF\u8FD4\u56DE\u8FDE\u63A5\u5668\u3002" }),
3673
- /* @__PURE__ */ jsx4("iframe", { ref: setFrame, title: `${label}\u767B\u5F55\u9875\u9762`, className: "h-[min(560px,60dvh)] w-full border-0" })
3674
- ] });
3675
- return /* @__PURE__ */ jsx4(Dialog, { open: true, onOpenChange: (open) => {
3676
- if (!open) onClose();
3677
- }, children: /* @__PURE__ */ jsxs2(DialogContent, { "aria-describedby": void 0, className: "max-h-[90dvh] overflow-y-auto sm:max-w-[800px]", children: [
3678
- /* @__PURE__ */ jsxs2(DialogTitle, { className: "sr-only", children: [
3679
- "\u8FDE\u63A5 ",
3680
- label
3681
- ] }),
3682
- /* @__PURE__ */ jsx4(
3683
- ConfigConnection,
3684
- {
3685
- editDescription: "\u91CD\u65B0\u767B\u5F55\u4E1A\u52A1\u8D26\u53F7",
3686
- detail: { title: label, rules: /* @__PURE__ */ jsx4(AccountConnectorRules, { client, name, refresh }) },
3687
- status,
3688
- account: connection?.account_label,
3689
- verifiedAt: connection?.verified_at,
3690
- onEdit: () => setEditing(true),
3691
- connection: login,
3692
- onDisconnect: async () => {
3693
- const view = await client.connectors.disconnect(name);
3694
- if (alive.current) {
3695
- setConnection(view.connection);
3696
- setEditing(false);
3697
- setRefresh((value) => value + 1);
3698
- }
3699
- },
3700
- onVerify: async () => {
3701
- const view = await client.connectors.verify(name);
3702
- if (alive.current) {
3703
- setConnection(view.connection);
3704
- setRefresh((value) => value + 1);
3705
- }
3706
- }
3707
- }
3708
- ),
3709
- editing && status === "connected" && /* @__PURE__ */ jsx4(Dialog, { open: true, onOpenChange: (open) => {
3710
- if (!open) setEditing(false);
3711
- }, children: /* @__PURE__ */ jsxs2(DialogContent, { "aria-describedby": void 0, className: "max-h-[90dvh] overflow-y-auto sm:max-w-[800px]", children: [
3712
- /* @__PURE__ */ jsx4(DialogTitle, { children: "\u66F4\u6362\u8D26\u53F7" }),
3713
- /* @__PURE__ */ jsx4("p", { children: "\u5B8C\u6210\u767B\u5F55\u5E76\u9A8C\u8BC1\u540E\u66FF\u6362\u5F53\u524D\u8D26\u53F7\uFF0C\u4F7F\u7528\u89C4\u5219\u4FDD\u7559\u3002" }),
3714
- login
3715
- ] }) }),
3716
- /* @__PURE__ */ jsx4("button", { type: "button", className: "min-h-10 rounded-lg border px-4 text-sm", onClick: onClose, children: "\u8FD4\u56DE\u8FDE\u63A5\u5668" })
3717
- ] }) });
3718
- }
3719
-
3720
3796
  // src/chat/runtime/session-source.tsx
3721
3797
  import { createInitialSessionState } from "@blade-hq/agent-client/internal";
3722
3798
  import {
3723
3799
  createContext as createContext2,
3724
3800
  useContext as useContext2,
3725
- useEffect as useEffect3,
3801
+ useEffect as useEffect2,
3726
3802
  useLayoutEffect,
3727
3803
  useMemo,
3728
- useRef as useRef3,
3729
- useState as useState3,
3804
+ useRef as useRef2,
3805
+ useState as useState2,
3730
3806
  useSyncExternalStore
3731
3807
  } from "react";
3732
- import { jsx as jsx5 } from "react/jsx-runtime";
3808
+ import { jsx as jsx3 } from "react/jsx-runtime";
3733
3809
  var EMPTY_SOURCE = {
3734
3810
  subscribe: () => () => {
3735
3811
  },
@@ -3739,7 +3815,7 @@ var EMPTY_SOURCE = {
3739
3815
  };
3740
3816
  var SessionSourceContext = createContext2(EMPTY_SOURCE);
3741
3817
  function SessionSourceProvider({ source, children }) {
3742
- return /* @__PURE__ */ jsx5(SessionSourceContext.Provider, { value: source, children });
3818
+ return /* @__PURE__ */ jsx3(SessionSourceContext.Provider, { value: source, children });
3743
3819
  }
3744
3820
  function useSessionSource() {
3745
3821
  return useContext2(SessionSourceContext);
@@ -3784,11 +3860,11 @@ var SingleSessionSource = class {
3784
3860
  }
3785
3861
  };
3786
3862
  function useSingleSessionSource(session, loading) {
3787
- const [source] = useState3(() => new SingleSessionSource());
3863
+ const [source] = useState2(() => new SingleSessionSource());
3788
3864
  useLayoutEffect(() => {
3789
3865
  source.update(session, loading);
3790
3866
  }, [source, session, loading]);
3791
- useEffect3(() => session ? source.watchPlan(session) : void 0, [source, session]);
3867
+ useEffect2(() => session ? source.watchPlan(session) : void 0, [source, session]);
3792
3868
  return source;
3793
3869
  }
3794
3870
  var EMPTY_STATE = createInitialSessionState("");
@@ -3804,7 +3880,7 @@ function useSessionHandle(sessionId) {
3804
3880
  }
3805
3881
  function useSessionState(sessionId, selector) {
3806
3882
  const session = useSessionHandle(sessionId);
3807
- const selectorRef = useRef3(selector);
3883
+ const selectorRef = useRef2(selector);
3808
3884
  selectorRef.current = selector;
3809
3885
  const store = useMemo(() => {
3810
3886
  let lastState = null;
@@ -3846,7 +3922,7 @@ function usePlanRevealRevision(sessionId) {
3846
3922
  }
3847
3923
  var CurrentChatSessionContext = createContext2(null);
3848
3924
  function CurrentChatSessionProvider({ sessionId, children }) {
3849
- return /* @__PURE__ */ jsx5(CurrentChatSessionContext.Provider, { value: sessionId, children });
3925
+ return /* @__PURE__ */ jsx3(CurrentChatSessionContext.Provider, { value: sessionId, children });
3850
3926
  }
3851
3927
  function useCurrentChatSessionId() {
3852
3928
  return useContext2(CurrentChatSessionContext);
@@ -3854,11 +3930,11 @@ function useCurrentChatSessionId() {
3854
3930
 
3855
3931
  // src/chat/runtime/environment.tsx
3856
3932
  import { createContext as createContext3, useContext as useContext3, useMemo as useMemo2 } from "react";
3857
- import { jsx as jsx6 } from "react/jsx-runtime";
3933
+ import { jsx as jsx4 } from "react/jsx-runtime";
3858
3934
  var EMPTY_ENVIRONMENT = {};
3859
3935
  var ChatEnvironmentContext = createContext3(EMPTY_ENVIRONMENT);
3860
3936
  function ChatEnvironmentProvider({ value, children }) {
3861
- return /* @__PURE__ */ jsx6(ChatEnvironmentContext.Provider, { value, children });
3937
+ return /* @__PURE__ */ jsx4(ChatEnvironmentContext.Provider, { value, children });
3862
3938
  }
3863
3939
  function useChatEnvironment() {
3864
3940
  return useContext3(ChatEnvironmentContext);
@@ -3933,6 +4009,94 @@ function useChatVirtualizer(options) {
3933
4009
  return { virtualizer, enabled: Boolean(injected) };
3934
4010
  }
3935
4011
 
4012
+ // src/components/AccountConnectorRules.tsx
4013
+ import { useCallback } from "react";
4014
+ import { jsx as jsx5 } from "react/jsx-runtime";
4015
+ function AccountConnectorRules({ client, name, refresh = 0 }) {
4016
+ const read = useCallback(() => client.connectors.rules(name), [client, name]);
4017
+ const update = useCallback((set) => client.connectors.updateRules(name, set), [client, name]);
4018
+ return /* @__PURE__ */ jsx5(ConnectorRulesPanel, { compact: true, read, update, refresh }, name);
4019
+ }
4020
+
4021
+ // src/components/BrowserConnectionDialog.tsx
4022
+ import { useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
4023
+ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
4024
+ function BrowserConnectionDialog({ client, name, label = "\u4E1A\u52A1\u8D26\u53F7", connector, onClose }) {
4025
+ const [connection, setConnection] = useState3(connector?.connection);
4026
+ const [editing, setEditing] = useState3(false);
4027
+ const [refresh, setRefresh] = useState3(0);
4028
+ const [frame, setFrame] = useState3(null);
4029
+ const alive = useRef3(false);
4030
+ useEffect3(() => {
4031
+ alive.current = true;
4032
+ return () => {
4033
+ alive.current = false;
4034
+ };
4035
+ }, []);
4036
+ const status = connection?.status ?? "disconnected";
4037
+ const showLogin = status !== "connected" || editing;
4038
+ const url = new URL(client.connectors.browserAuthorizationUrl(name), window.location.href);
4039
+ const origin = url.origin;
4040
+ useEffect3(() => {
4041
+ if (!showLogin || !frame) return;
4042
+ return client.connectors.bindBrowserAuthorizationFrame(frame, name);
4043
+ }, [client, name, showLogin, frame]);
4044
+ useEffect3(() => {
4045
+ const receive = (event) => {
4046
+ if (event.origin === origin && event.source === frame?.contentWindow && event.data?.type === "blade:connector-auth-close") onClose();
4047
+ };
4048
+ window.addEventListener("message", receive);
4049
+ return () => window.removeEventListener("message", receive);
4050
+ }, [origin, onClose, frame]);
4051
+ const login = /* @__PURE__ */ jsxs2("div", { className: "space-y-3", children: [
4052
+ /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: "\u5728\u4E0B\u65B9\u9875\u9762\u5B8C\u6210\u767B\u5F55\u6216\u626B\u7801\uFF0C\u7136\u540E\u786E\u8BA4\u767B\u5F55\u3002\u9700\u8981\u9000\u51FA\u65F6\u53EF\u8FD4\u56DE\u8FDE\u63A5\u5668\u3002" }),
4053
+ /* @__PURE__ */ jsx6("iframe", { ref: setFrame, title: `${label}\u767B\u5F55\u9875\u9762`, className: "h-[min(560px,60dvh)] w-full border-0" })
4054
+ ] });
4055
+ return /* @__PURE__ */ jsx6(Dialog, { open: true, onOpenChange: (open) => {
4056
+ if (!open) onClose();
4057
+ }, children: /* @__PURE__ */ jsxs2(DialogContent, { "aria-describedby": void 0, className: "max-h-[90dvh] overflow-y-auto sm:max-w-[800px]", children: [
4058
+ /* @__PURE__ */ jsxs2(DialogTitle, { className: "sr-only", children: [
4059
+ "\u8FDE\u63A5 ",
4060
+ label
4061
+ ] }),
4062
+ /* @__PURE__ */ jsx6(
4063
+ ConfigConnection,
4064
+ {
4065
+ editDescription: "\u91CD\u65B0\u767B\u5F55\u4E1A\u52A1\u8D26\u53F7",
4066
+ detail: { title: label, rules: /* @__PURE__ */ jsx6(AccountConnectorRules, { client, name, refresh }) },
4067
+ status,
4068
+ account: connection?.account_label,
4069
+ verifiedAt: connection?.verified_at,
4070
+ onEdit: () => setEditing(true),
4071
+ connection: login,
4072
+ onDisconnect: async () => {
4073
+ const view = await client.connectors.disconnect(name);
4074
+ if (alive.current) {
4075
+ setConnection(view.connection);
4076
+ setEditing(false);
4077
+ setRefresh((value) => value + 1);
4078
+ }
4079
+ },
4080
+ onVerify: async () => {
4081
+ const view = await client.connectors.verify(name);
4082
+ if (alive.current) {
4083
+ setConnection(view.connection);
4084
+ setRefresh((value) => value + 1);
4085
+ }
4086
+ }
4087
+ }
4088
+ ),
4089
+ editing && status === "connected" && /* @__PURE__ */ jsx6(Dialog, { open: true, onOpenChange: (open) => {
4090
+ if (!open) setEditing(false);
4091
+ }, children: /* @__PURE__ */ jsxs2(DialogContent, { "aria-describedby": void 0, className: "max-h-[90dvh] overflow-y-auto sm:max-w-[800px]", children: [
4092
+ /* @__PURE__ */ jsx6(DialogTitle, { children: "\u66F4\u6362\u8D26\u53F7" }),
4093
+ /* @__PURE__ */ jsx6("p", { children: "\u5B8C\u6210\u767B\u5F55\u5E76\u9A8C\u8BC1\u540E\u66FF\u6362\u5F53\u524D\u8D26\u53F7\uFF0C\u4F7F\u7528\u89C4\u5219\u4FDD\u7559\u3002" }),
4094
+ login
4095
+ ] }) }),
4096
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "min-h-10 rounded-lg border px-4 text-sm", onClick: onClose, children: "\u8FD4\u56DE\u8FDE\u63A5\u5668" })
4097
+ ] }) });
4098
+ }
4099
+
3936
4100
  export {
3937
4101
  BladeProvider,
3938
4102
  useBladeClient,
@@ -3941,13 +4105,28 @@ export {
3941
4105
  cn,
3942
4106
  copyToClipboard,
3943
4107
  getToolDescription,
4108
+ getSkillNameFromFilePath,
3944
4109
  formatToolFileName,
3945
4110
  formatToolName,
3946
4111
  getToolDisplayLabel,
3947
4112
  getToolTone,
3948
4113
  getToolStatusLabel,
3949
4114
  extractToolFilePath,
4115
+ extractToolFilePaths,
3950
4116
  getToolOutputTag,
4117
+ isSuccessfulToolCall,
4118
+ countSuccessfulToolCalls,
4119
+ countPendingToolCalls,
4120
+ formatToolCallCount,
4121
+ summarizeToolCalls,
4122
+ hasNaturalLanguageText,
4123
+ findAnchorMessageIndex,
4124
+ getCollapsedTurnSegments,
4125
+ getLatestPendingToolName,
4126
+ getFinishTaskTitle,
4127
+ getTextContentSegments,
4128
+ getLastTextSegment,
4129
+ countMessageLines,
3951
4130
  PLAN_AUTO_COLLAPSE_MS,
3952
4131
  isPlanUpdateTool,
3953
4132
  getPlanUpdateDisplayState,
@@ -3975,4 +4154,4 @@ export {
3975
4154
  AccountConnectorRules,
3976
4155
  BrowserConnectionDialog
3977
4156
  };
3978
- //# sourceMappingURL=chunk-NRYLAO3X.js.map
4157
+ //# sourceMappingURL=chunk-VTEKA5HD.js.map