@blade-hq/agent-react 2610.0.0-beta.12 → 2610.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.
package/README.md CHANGED
@@ -151,7 +151,6 @@ await replay.exitToAutonomous() // 退出回放,之后真的运
151
151
  全部 props 见 `ChatViewProps`。样式说明:
152
152
 
153
153
  `onFollowupInteraction` 使用 `FollowupInteractionEvent`,覆盖下一步建议展示/采纳、成果展示/打开/下载以及结果评分。SDK 不内置 PostHog 等分析厂商;宿主回调抛错也不会中断用户点击或下载。
154
- 文件成果以文件名为文本的标准下载链接展示;Vue / 纯 HTML 使用的 `<blade-chat>` 与 `ChatView` 行为一致。
155
154
 
156
155
  - 必须引入一份样式,按宿主有没有 Tailwind 二选一:
157
156
  - **`style.full.css`**(默认选它):布局兜底 + 编译好的 Tailwind 产物,自包含,宿主没装 Tailwind 也是完整视觉。
@@ -18,9 +18,6 @@ declare function getChat(element: Element | null): Promise<AgentSession>;
18
18
  declare const BladeAgent: {
19
19
  BladeClient: typeof agentClient.BladeClient;
20
20
  BladeApiError: typeof agentClient.BladeApiError;
21
- EMPTY_PLATFORM_ENDPOINTS: agentClient.PlatformEndpoints;
22
- loadPlatformEndpoints: typeof agentClient.loadPlatformEndpoints;
23
- resolveServiceUrl: typeof agentClient.resolveServiceUrl;
24
21
  SDK_NAME: "agent-client";
25
22
  SDK_VERSION: string;
26
23
  AgentSession: typeof AgentSession;
package/dist/index.js CHANGED
@@ -697,6 +697,13 @@ var Copy = createLucideIcon("Copy", [
697
697
  ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
698
698
  ]);
699
699
 
700
+ // ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/download.js
701
+ var Download = createLucideIcon("Download", [
702
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
703
+ ["polyline", { points: "7 10 12 15 17 10", key: "2ggqvy" }],
704
+ ["line", { x1: "12", x2: "12", y1: "15", y2: "3", key: "1vk2je" }]
705
+ ]);
706
+
700
707
  // ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/file-text.js
701
708
  var FileText = createLucideIcon("FileText", [
702
709
  ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
@@ -706,6 +713,24 @@ var FileText = createLucideIcon("FileText", [
706
713
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
707
714
  ]);
708
715
 
716
+ // ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/file.js
717
+ var File = createLucideIcon("File", [
718
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
719
+ ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }]
720
+ ]);
721
+
722
+ // ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/film.js
723
+ var Film = createLucideIcon("Film", [
724
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
725
+ ["path", { d: "M7 3v18", key: "bbkbws" }],
726
+ ["path", { d: "M3 7.5h4", key: "zfgn84" }],
727
+ ["path", { d: "M3 12h18", key: "1i2n21" }],
728
+ ["path", { d: "M3 16.5h4", key: "1230mu" }],
729
+ ["path", { d: "M17 3v18", key: "in4fa5" }],
730
+ ["path", { d: "M17 7.5h4", key: "myr1c1" }],
731
+ ["path", { d: "M17 16.5h4", key: "go4c1d" }]
732
+ ]);
733
+
709
734
  // ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/globe.js
710
735
  var Globe = createLucideIcon("Globe", [
711
736
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
@@ -2422,6 +2447,9 @@ function emitInteraction(callback, event) {
2422
2447
  function basename(path) {
2423
2448
  return path.split(/[\\/]/).filter(Boolean).pop() || path;
2424
2449
  }
2450
+ function isVideo(path) {
2451
+ return /\.(?:mp4|mov|webm|mkv|avi|m4v)$/i.test(path);
2452
+ }
2425
2453
  function ArtifactCard({
2426
2454
  artifact,
2427
2455
  sessionId,
@@ -2452,48 +2480,44 @@ ${artifact.target}`,
2452
2480
  }
2453
2481
  );
2454
2482
  }
2455
- const fileName = basename(artifact.target);
2456
- const downloadUrl = sessionId ? client.buildAuthedUrl(
2457
- `/api/sessions/${encodeURIComponent(sessionId)}/files/${encodeURIComponent(artifact.target)}`
2458
- ) : void 0;
2459
- const handleDownload = async (event) => {
2460
- if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
2461
- event.preventDefault();
2462
- if (!sessionId || downloading) return;
2463
- setDownloading(true);
2464
- emitInteraction(onInteraction, {
2465
- type: "artifact_download_started",
2466
- sessionId,
2467
- assistantEntryId,
2468
- artifactIndex,
2469
- artifactKind: "file"
2470
- });
2471
- try {
2472
- await client.sessions.downloadFile(sessionId, artifact.target, fileName);
2473
- emitInteraction(onInteraction, {
2474
- type: "artifact_download_succeeded",
2475
- sessionId,
2476
- assistantEntryId,
2477
- artifactIndex,
2478
- artifactKind: "file"
2479
- });
2480
- } catch {
2481
- } finally {
2482
- setDownloading(false);
2483
- }
2484
- };
2485
- return /* @__PURE__ */ jsx13(
2486
- "a",
2483
+ const Icon2 = isVideo(artifact.target) ? Film : File;
2484
+ return /* @__PURE__ */ jsxs11(
2485
+ "button",
2487
2486
  {
2488
- href: downloadUrl,
2489
- download: fileName,
2490
- onClick: handleDownload,
2491
- title: fileName,
2492
- "aria-label": `\u4E0B\u8F7D\u6587\u4EF6\uFF1A${fileName}`,
2493
- "aria-disabled": !sessionId || void 0,
2494
- "aria-busy": downloading || void 0,
2495
- className: "min-w-0 cursor-pointer break-all text-xs text-[hsl(var(--primary))] underline aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-busy:cursor-wait",
2496
- children: fileName
2487
+ type: "button",
2488
+ disabled: !sessionId || downloading,
2489
+ onClick: async () => {
2490
+ if (!sessionId || downloading) return;
2491
+ setDownloading(true);
2492
+ emitInteraction(onInteraction, {
2493
+ type: "artifact_download_started",
2494
+ sessionId,
2495
+ assistantEntryId,
2496
+ artifactIndex,
2497
+ artifactKind: "file"
2498
+ });
2499
+ try {
2500
+ await client.sessions.downloadFile(sessionId, artifact.target, basename(artifact.target));
2501
+ emitInteraction(onInteraction, {
2502
+ type: "artifact_download_succeeded",
2503
+ sessionId,
2504
+ assistantEntryId,
2505
+ artifactIndex,
2506
+ artifactKind: "file"
2507
+ });
2508
+ } catch {
2509
+ } finally {
2510
+ setDownloading(false);
2511
+ }
2512
+ },
2513
+ title: name,
2514
+ "aria-label": `\u4E0B\u8F7D ${name}`,
2515
+ className: "group relative flex min-w-0 items-center gap-1.5 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))] px-2 py-1.5 text-left text-xs text-[hsl(var(--card-foreground))] hover:bg-[hsl(var(--accent))] disabled:opacity-60",
2516
+ children: [
2517
+ /* @__PURE__ */ jsx13(Icon2, { size: 15, className: "shrink-0 text-[hsl(var(--primary))]" }),
2518
+ /* @__PURE__ */ jsx13("span", { className: "min-w-0 flex-1 truncate font-medium", children: name }),
2519
+ /* @__PURE__ */ jsx13(Download, { size: 13, className: "absolute right-2 opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100" })
2520
+ ]
2497
2521
  }
2498
2522
  );
2499
2523
  }
@@ -3672,7 +3696,10 @@ lucide-react/dist/esm/icons/chevron-down.js:
3672
3696
  lucide-react/dist/esm/icons/chevron-right.js:
3673
3697
  lucide-react/dist/esm/icons/circle-alert.js:
3674
3698
  lucide-react/dist/esm/icons/copy.js:
3699
+ lucide-react/dist/esm/icons/download.js:
3675
3700
  lucide-react/dist/esm/icons/file-text.js:
3701
+ lucide-react/dist/esm/icons/file.js:
3702
+ lucide-react/dist/esm/icons/film.js:
3676
3703
  lucide-react/dist/esm/icons/globe.js:
3677
3704
  lucide-react/dist/esm/icons/layers.js:
3678
3705
  lucide-react/dist/esm/icons/lightbulb.js: