@blade-hq/agent-react 2610.0.0-beta.11 → 2610.0.0-beta.13
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 -0
- package/dist/embed/entry.d.ts +3 -0
- package/dist/index.js +41 -68
- package/dist/index.js.map +1 -1
- package/dist/style.full.css +1 -1
- package/package.json +2 -2
- package/public-api.md +39 -1
package/README.md
CHANGED
|
@@ -151,6 +151,7 @@ await replay.exitToAutonomous() // 退出回放,之后真的运
|
|
|
151
151
|
全部 props 见 `ChatViewProps`。样式说明:
|
|
152
152
|
|
|
153
153
|
`onFollowupInteraction` 使用 `FollowupInteractionEvent`,覆盖下一步建议展示/采纳、成果展示/打开/下载以及结果评分。SDK 不内置 PostHog 等分析厂商;宿主回调抛错也不会中断用户点击或下载。
|
|
154
|
+
文件成果以文件名为文本的标准下载链接展示;Vue / 纯 HTML 使用的 `<blade-chat>` 与 `ChatView` 行为一致。
|
|
154
155
|
|
|
155
156
|
- 必须引入一份样式,按宿主有没有 Tailwind 二选一:
|
|
156
157
|
- **`style.full.css`**(默认选它):布局兜底 + 编译好的 Tailwind 产物,自包含,宿主没装 Tailwind 也是完整视觉。
|
package/dist/embed/entry.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ 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;
|
|
21
24
|
SDK_NAME: "agent-client";
|
|
22
25
|
SDK_VERSION: string;
|
|
23
26
|
AgentSession: typeof AgentSession;
|
package/dist/index.js
CHANGED
|
@@ -697,13 +697,6 @@ 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
|
-
|
|
707
700
|
// ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/file-text.js
|
|
708
701
|
var FileText = createLucideIcon("FileText", [
|
|
709
702
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
|
|
@@ -713,24 +706,6 @@ var FileText = createLucideIcon("FileText", [
|
|
|
713
706
|
["path", { d: "M16 17H8", key: "z1uh3a" }]
|
|
714
707
|
]);
|
|
715
708
|
|
|
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
|
-
|
|
734
709
|
// ../../node_modules/.pnpm/lucide-react@0.468.0_react@19.2.4/node_modules/lucide-react/dist/esm/icons/globe.js
|
|
735
710
|
var Globe = createLucideIcon("Globe", [
|
|
736
711
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
@@ -2447,9 +2422,6 @@ function emitInteraction(callback, event) {
|
|
|
2447
2422
|
function basename(path) {
|
|
2448
2423
|
return path.split(/[\\/]/).filter(Boolean).pop() || path;
|
|
2449
2424
|
}
|
|
2450
|
-
function isVideo(path) {
|
|
2451
|
-
return /\.(?:mp4|mov|webm|mkv|avi|m4v)$/i.test(path);
|
|
2452
|
-
}
|
|
2453
2425
|
function ArtifactCard({
|
|
2454
2426
|
artifact,
|
|
2455
2427
|
sessionId,
|
|
@@ -2480,44 +2452,48 @@ ${artifact.target}`,
|
|
|
2480
2452
|
}
|
|
2481
2453
|
);
|
|
2482
2454
|
}
|
|
2483
|
-
const
|
|
2484
|
-
|
|
2485
|
-
|
|
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",
|
|
2486
2487
|
{
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
onClick:
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
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
|
-
]
|
|
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
|
|
2521
2497
|
}
|
|
2522
2498
|
);
|
|
2523
2499
|
}
|
|
@@ -3696,10 +3672,7 @@ lucide-react/dist/esm/icons/chevron-down.js:
|
|
|
3696
3672
|
lucide-react/dist/esm/icons/chevron-right.js:
|
|
3697
3673
|
lucide-react/dist/esm/icons/circle-alert.js:
|
|
3698
3674
|
lucide-react/dist/esm/icons/copy.js:
|
|
3699
|
-
lucide-react/dist/esm/icons/download.js:
|
|
3700
3675
|
lucide-react/dist/esm/icons/file-text.js:
|
|
3701
|
-
lucide-react/dist/esm/icons/file.js:
|
|
3702
|
-
lucide-react/dist/esm/icons/film.js:
|
|
3703
3676
|
lucide-react/dist/esm/icons/globe.js:
|
|
3704
3677
|
lucide-react/dist/esm/icons/layers.js:
|
|
3705
3678
|
lucide-react/dist/esm/icons/lightbulb.js:
|