@blade-hq/agent-react 2612.0.0-beta.98 → 2612.0.0-beta.99
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 +3 -2
- package/dist/McpAppCard-ADVDKC2C.js +171 -0
- package/dist/McpAppCard-ADVDKC2C.js.map +1 -0
- package/dist/McpAppFrame-VEOUJL5E.js +9 -0
- package/dist/PlanGraph-3D5PCSIJ.js +189 -0
- package/dist/PlanGraph-3D5PCSIJ.js.map +1 -0
- package/dist/{chunk-FTBMG7TK.js → SessionPluginConfigForm-DWVDFK6A.js} +2 -3
- package/dist/chat/AskUserQuestionBlock.d.ts +2 -1
- package/dist/chat/ChatPanel.d.ts +3 -1
- package/dist/chat/CurrentPlanPanel.d.ts +2 -1
- package/dist/chat/LightComposer.d.ts +1 -1
- package/dist/chat/LiteMessageList.d.ts +9 -0
- package/dist/chat/RelatedWork.d.ts +24 -0
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/plan/PlanGraph.d.ts +26 -0
- package/dist/chat/plan/PlanSurface.d.ts +9 -0
- package/dist/chat/plan/presentation.d.ts +18 -0
- package/dist/chat/runtime/actions.d.ts +1 -0
- package/dist/chat/runtime/environment.d.ts +5 -0
- package/dist/chat/runtime/session-source.d.ts +2 -0
- package/dist/chat.css +181 -0
- package/dist/{chunk-CJQINCIP.js → chunk-3RFYXI6V.js} +51 -71
- package/dist/chunk-3RFYXI6V.js.map +1 -0
- package/dist/chunk-5JAFIDDP.js +1386 -0
- package/dist/chunk-5JAFIDDP.js.map +1 -0
- package/dist/{chunk-RULD2XDA.js → chunk-67JW6ASD.js} +1561 -1199
- package/dist/chunk-67JW6ASD.js.map +1 -0
- package/dist/chunk-7WR2KG5O.js +50 -0
- package/dist/chunk-7WR2KG5O.js.map +1 -0
- package/dist/chunk-FR3ON5R4.js +30 -0
- package/dist/chunk-FR3ON5R4.js.map +1 -0
- package/dist/chunk-GRUDJLWG.js +8 -0
- package/dist/chunk-GRUDJLWG.js.map +1 -0
- package/dist/{chunk-Q5NLUZAK.js → chunk-GZHQQXYI.js} +8 -9
- package/dist/chunk-GZHQQXYI.js.map +1 -0
- package/dist/{chunk-RHUJ77ZZ.js → chunk-IOIKCFRO.js} +36 -1566
- package/dist/chunk-IOIKCFRO.js.map +1 -0
- package/dist/{chunk-IOKIQSWP.js → chunk-J6BSKVVK.js} +37 -19
- package/dist/chunk-J6BSKVVK.js.map +1 -0
- package/dist/{chunk-AGCHJFE7.js → chunk-MG4RF573.js} +4 -4
- package/dist/{chunk-AGCHJFE7.js.map → chunk-MG4RF573.js.map} +1 -1
- package/dist/{chunk-KJDDAZZY.js → chunk-SVCTJ4VS.js} +145 -25
- package/dist/chunk-SVCTJ4VS.js.map +1 -0
- package/dist/{chunk-FXTAY3LE.js → chunk-WEOW475M.js} +17 -17
- package/dist/{chunk-FXTAY3LE.js.map → chunk-WEOW475M.js.map} +1 -1
- package/dist/{chunk-6Z7T6BOB.js → chunk-YBTELD7P.js} +7 -5
- package/dist/{chunk-6Z7T6BOB.js.map → chunk-YBTELD7P.js.map} +1 -1
- package/dist/components/AgentChat.d.ts +3 -0
- package/dist/components/McpAppCard.d.ts +1 -7
- package/dist/components/ReplayBar.d.ts +7 -1
- package/dist/components/lazy-mcp-app-card.d.ts +1 -0
- package/dist/components/lazy-mcp-app-frame.d.ts +1 -0
- package/dist/components/lazy-session-plugin-config-form.d.ts +1 -0
- package/dist/components/mcp-app-context.d.ts +7 -0
- package/dist/connectors.js +3 -3
- package/dist/embed/entry.d.ts +4 -0
- package/dist/embed/load-plan-graph.d.ts +2 -0
- package/dist/embed/plan-graph-chunk.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -9
- package/dist/internal.d.ts +4 -4
- package/dist/internal.js +29 -17
- package/dist/internal.js.map +1 -1
- package/dist/questions.js +5 -4
- package/dist/questions.js.map +1 -1
- package/dist/rich-input/ChatInput.d.ts +3 -1
- package/dist/rich-input/ComposerControls.d.ts +21 -0
- package/dist/rich-input/index.d.ts +1 -0
- package/dist/rich-input.js +315 -258
- package/dist/rich-input.js.map +1 -1
- package/dist/style.full.css +182 -1
- package/dist/tool-details.js +6 -5
- package/dist/tool-details.js.map +1 -1
- package/package.json +2 -2
- package/public-api.md +31 -2
- package/dist/SessionPluginConfigForm-DWLJEYBY.js +0 -9
- package/dist/chunk-CJQINCIP.js.map +0 -1
- package/dist/chunk-IOKIQSWP.js.map +0 -1
- package/dist/chunk-KJDDAZZY.js.map +0 -1
- package/dist/chunk-Q5NLUZAK.js.map +0 -1
- package/dist/chunk-RHUJ77ZZ.js.map +0 -1
- package/dist/chunk-RULD2XDA.js.map +0 -1
- /package/dist/{SessionPluginConfigForm-DWLJEYBY.js.map → McpAppFrame-VEOUJL5E.js.map} +0 -0
- /package/dist/{chunk-FTBMG7TK.js.map → SessionPluginConfigForm-DWVDFK6A.js.map} +0 -0
|
@@ -1,35 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
MarkdownContent
|
|
3
|
-
} from "./chunk-6Z7T6BOB.js";
|
|
4
|
-
import {
|
|
5
|
-
cn,
|
|
6
|
-
extractToolFilePath,
|
|
7
|
-
formatToolFileName,
|
|
8
|
-
formatToolName,
|
|
9
|
-
useBladeClient,
|
|
10
|
-
useHighlightedCode,
|
|
11
|
-
useOptionalBladeClient
|
|
12
|
-
} from "./chunk-CJQINCIP.js";
|
|
13
|
-
import {
|
|
14
|
-
dist_exports2 as dist_exports
|
|
15
|
-
} from "./chunk-FXTAY3LE.js";
|
|
16
|
-
import {
|
|
17
|
-
ChevronLeft,
|
|
18
|
-
ChevronRight,
|
|
19
|
-
CircleAlert,
|
|
20
|
-
CircleCheck,
|
|
21
|
-
Download,
|
|
22
|
-
Earth,
|
|
23
|
-
ExternalLink,
|
|
24
|
-
FileText,
|
|
25
|
-
Folder,
|
|
26
2
|
Maximize2,
|
|
27
|
-
Minimize2
|
|
28
|
-
|
|
29
|
-
Plus,
|
|
30
|
-
RotateCcw,
|
|
31
|
-
X
|
|
32
|
-
} from "./chunk-IOKIQSWP.js";
|
|
3
|
+
Minimize2
|
|
4
|
+
} from "./chunk-J6BSKVVK.js";
|
|
33
5
|
import {
|
|
34
6
|
__export
|
|
35
7
|
} from "./chunk-PR4QN5HX.js";
|
|
@@ -25255,14 +25227,14 @@ var D = class {
|
|
|
25255
25227
|
removeEventListener(G, Q) {
|
|
25256
25228
|
let W = this._eventSlots.get(G);
|
|
25257
25229
|
if (!W) return;
|
|
25258
|
-
let
|
|
25259
|
-
if (
|
|
25230
|
+
let X = W.listeners.indexOf(Q);
|
|
25231
|
+
if (X !== -1) W.listeners.splice(X, 1);
|
|
25260
25232
|
}
|
|
25261
25233
|
dispatch(G, Q) {
|
|
25262
25234
|
let W = this._eventSlots.get(G);
|
|
25263
25235
|
if (!W) return;
|
|
25264
25236
|
W.onHandler?.(Q);
|
|
25265
|
-
for (let
|
|
25237
|
+
for (let X of [...W.listeners]) X(Q);
|
|
25266
25238
|
}
|
|
25267
25239
|
_ensureEventSlot(G) {
|
|
25268
25240
|
let Q = this._eventSlots.get(G);
|
|
@@ -25288,11 +25260,11 @@ var O = class {
|
|
|
25288
25260
|
};
|
|
25289
25261
|
var b = /* @__PURE__ */ new Set();
|
|
25290
25262
|
function E(G, Q) {
|
|
25291
|
-
let [W,
|
|
25263
|
+
let [W, X] = Q, Y = W?.shape;
|
|
25292
25264
|
if (typeof Y?.method?.value !== "string") return;
|
|
25293
25265
|
let Z = Y.method.value, z2 = G === "request" ? "setRequestHandler" : "setNotificationHandler";
|
|
25294
25266
|
if (!b.has(z2)) b.add(z2), console.warn(`[ext-apps] ${z2}(Schema, handler) is deprecated; use ${z2}("${Z}", { params: Schema.shape.params }, handler).`);
|
|
25295
|
-
let k =
|
|
25267
|
+
let k = X;
|
|
25296
25268
|
return [Z, { params: Y.params }, G === "request" ? (B, o) => k({ method: Z, params: B }, l(o)) : (B) => k({ method: Z, params: B })];
|
|
25297
25269
|
}
|
|
25298
25270
|
function l(G) {
|
|
@@ -25389,10 +25361,10 @@ var c = class {
|
|
|
25389
25361
|
console.debug("Ignoring message from unknown source", W);
|
|
25390
25362
|
return;
|
|
25391
25363
|
}
|
|
25392
|
-
let
|
|
25393
|
-
if (
|
|
25394
|
-
else if (W.data?.jsonrpc !== "2.0") console.debug("Ignoring non-JSON-RPC message",
|
|
25395
|
-
else console.error("Failed to parse message",
|
|
25364
|
+
let X = JSONRPCMessageSchema.safeParse(W.data);
|
|
25365
|
+
if (X.success) console.debug("Parsed message", X.data), this.onmessage?.(X.data);
|
|
25366
|
+
else if (W.data?.jsonrpc !== "2.0") console.debug("Ignoring non-JSON-RPC message", X.error.message, W);
|
|
25367
|
+
else console.error("Failed to parse message", X.error.message, W), this.onerror?.(Error("Invalid JSON-RPC message received: " + X.error.message));
|
|
25396
25368
|
};
|
|
25397
25369
|
}
|
|
25398
25370
|
async start() {
|
|
@@ -25443,9 +25415,9 @@ var MF = class extends Protocol {
|
|
|
25443
25415
|
_wrapHandler(G, Q) {
|
|
25444
25416
|
let W = super._wrapHandler(G, Q);
|
|
25445
25417
|
if (G === "ui/initialize" || G === "ping") return W;
|
|
25446
|
-
return async (
|
|
25418
|
+
return async (X, Y) => {
|
|
25447
25419
|
if (!this._initializedReceived) console.warn(`[ext-apps] AppBridge received '${G}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`);
|
|
25448
|
-
return W(
|
|
25420
|
+
return W(X, Y);
|
|
25449
25421
|
};
|
|
25450
25422
|
}
|
|
25451
25423
|
eventSchemas = { sizechange: w, sandboxready: T, initialized: U, requestteardown: f, loggingmessage: LoggingMessageNotificationSchema };
|
|
@@ -25465,25 +25437,25 @@ var MF = class extends Protocol {
|
|
|
25465
25437
|
if (this._registeredEvents.has(G)) return;
|
|
25466
25438
|
let Q = this.eventSchemas[G];
|
|
25467
25439
|
if (!Q) throw Error(`Unknown event: ${String(G)}`);
|
|
25468
|
-
let W = (
|
|
25440
|
+
let W = (X) => {
|
|
25469
25441
|
if (G === "initialized") this._initializedReceived = true;
|
|
25470
|
-
this._events.dispatch(G,
|
|
25442
|
+
this._events.dispatch(G, X);
|
|
25471
25443
|
};
|
|
25472
|
-
if (G === "loggingmessage") this.setNotificationHandler("notifications/message", (
|
|
25473
|
-
W(
|
|
25444
|
+
if (G === "loggingmessage") this.setNotificationHandler("notifications/message", (X) => {
|
|
25445
|
+
W(X.params);
|
|
25474
25446
|
});
|
|
25475
|
-
else this.setNotificationHandler(Q.shape.method.value, { params: Q.shape.params }, (
|
|
25447
|
+
else this.setNotificationHandler(Q.shape.method.value, { params: Q.shape.params }, (X) => W(X));
|
|
25476
25448
|
this._registeredEvents.add(G);
|
|
25477
25449
|
}
|
|
25478
25450
|
warnIfRequestHandlerReplaced(G, Q, W) {
|
|
25479
25451
|
if (Q && W) console.warn(`[MCP Apps] ${G} handler replaced. Previous handler will no longer be called.`);
|
|
25480
25452
|
}
|
|
25481
|
-
constructor(G, Q, W,
|
|
25482
|
-
super(
|
|
25453
|
+
constructor(G, Q, W, X) {
|
|
25454
|
+
super(X);
|
|
25483
25455
|
this._client = G;
|
|
25484
25456
|
this._hostInfo = Q;
|
|
25485
25457
|
this._hostCapabilities = W;
|
|
25486
|
-
this._methods.replace("notifications/cancelled"), this._methods.replace("notifications/progress"), this._ensureEventSlot("initialized"), this._hostContext =
|
|
25458
|
+
this._methods.replace("notifications/cancelled"), this._methods.replace("notifications/progress"), this._ensureEventSlot("initialized"), this._hostContext = X?.hostContext || {}, this.replaceRequestHandler("ui/initialize", { params: S.shape.params, result: g }, (Y) => this._onAppsInitialize(Y)), this.replaceRequestHandler("ping", (Y, Z) => {
|
|
25487
25459
|
return this.onping?.(Y.params, Z), {};
|
|
25488
25460
|
}), this.replaceRequestHandler("ui/request-display-mode", { params: j.shape.params, result: _ }, () => {
|
|
25489
25461
|
return { mode: this._hostContext.displayMode ?? "inline" };
|
|
@@ -25664,10 +25636,10 @@ var MF = class extends Protocol {
|
|
|
25664
25636
|
}
|
|
25665
25637
|
setHostContext(G) {
|
|
25666
25638
|
let Q = {}, W = false;
|
|
25667
|
-
for (let
|
|
25668
|
-
let Y = this._hostContext[
|
|
25639
|
+
for (let X of Object.keys(G)) {
|
|
25640
|
+
let Y = this._hostContext[X], Z = G[X];
|
|
25669
25641
|
if (SF(Y, Z)) continue;
|
|
25670
|
-
Q[
|
|
25642
|
+
Q[X] = Z, W = true;
|
|
25671
25643
|
}
|
|
25672
25644
|
if (W) this._hostContext = G, this.sendHostContextChange(Q);
|
|
25673
25645
|
}
|
|
@@ -25705,22 +25677,22 @@ var MF = class extends Protocol {
|
|
|
25705
25677
|
let Q = this._client.getServerCapabilities();
|
|
25706
25678
|
if (!Q) throw Error("Client server capabilities not available");
|
|
25707
25679
|
if (Q.tools) {
|
|
25708
|
-
if (this.oncalltool = async (W,
|
|
25709
|
-
return this._client.request({ method: "tools/call", params: W }, { signal:
|
|
25680
|
+
if (this.oncalltool = async (W, X) => {
|
|
25681
|
+
return this._client.request({ method: "tools/call", params: W }, { signal: X.mcpReq.signal });
|
|
25710
25682
|
}, Q.tools.listChanged) this._client.setNotificationHandler("notifications/tools/list_changed", (W) => this.sendToolListChanged(W.params));
|
|
25711
25683
|
}
|
|
25712
25684
|
if (Q.resources) {
|
|
25713
|
-
if (this.onlistresources = async (W,
|
|
25714
|
-
return this._client.request({ method: "resources/list", params: W }, { signal:
|
|
25715
|
-
}, this.onlistresourcetemplates = async (W,
|
|
25716
|
-
return this._client.request({ method: "resources/templates/list", params: W }, { signal:
|
|
25717
|
-
}, this.onreadresource = async (W,
|
|
25718
|
-
return this._client.request({ method: "resources/read", params: W }, { signal:
|
|
25685
|
+
if (this.onlistresources = async (W, X) => {
|
|
25686
|
+
return this._client.request({ method: "resources/list", params: W }, { signal: X.mcpReq.signal });
|
|
25687
|
+
}, this.onlistresourcetemplates = async (W, X) => {
|
|
25688
|
+
return this._client.request({ method: "resources/templates/list", params: W }, { signal: X.mcpReq.signal });
|
|
25689
|
+
}, this.onreadresource = async (W, X) => {
|
|
25690
|
+
return this._client.request({ method: "resources/read", params: W }, { signal: X.mcpReq.signal });
|
|
25719
25691
|
}, Q.resources.listChanged) this._client.setNotificationHandler("notifications/resources/list_changed", (W) => this.sendResourceListChanged(W.params));
|
|
25720
25692
|
}
|
|
25721
25693
|
if (Q.prompts) {
|
|
25722
|
-
if (this.onlistprompts = async (W,
|
|
25723
|
-
return this._client.request({ method: "prompts/list", params: W }, { signal:
|
|
25694
|
+
if (this.onlistprompts = async (W, X) => {
|
|
25695
|
+
return this._client.request({ method: "prompts/list", params: W }, { signal: X.mcpReq.signal });
|
|
25724
25696
|
}, Q.prompts.listChanged) this._client.setNotificationHandler("notifications/prompts/list_changed", (W) => this.sendPromptListChanged(W.params));
|
|
25725
25697
|
}
|
|
25726
25698
|
}
|
|
@@ -25926,1510 +25898,8 @@ function McpAppFrame(props) {
|
|
|
25926
25898
|
);
|
|
25927
25899
|
}
|
|
25928
25900
|
|
|
25929
|
-
// src/components/McpAppCard.tsx
|
|
25930
|
-
import { BladeApiError } from "@blade-hq/agent-client";
|
|
25931
|
-
import { createContext, useContext, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
25932
|
-
|
|
25933
|
-
// src/lib/random-id.ts
|
|
25934
|
-
function randomId() {
|
|
25935
|
-
const webCrypto = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
|
|
25936
|
-
if (webCrypto && typeof webCrypto.randomUUID === "function") {
|
|
25937
|
-
return webCrypto.randomUUID();
|
|
25938
|
-
}
|
|
25939
|
-
if (webCrypto && typeof webCrypto.getRandomValues === "function") {
|
|
25940
|
-
const bytes = webCrypto.getRandomValues(new Uint8Array(16));
|
|
25941
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
25942
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
25943
|
-
const hex3 = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
25944
|
-
return `${hex3.slice(0, 8)}-${hex3.slice(8, 12)}-${hex3.slice(12, 16)}-${hex3.slice(16, 20)}-${hex3.slice(20)}`;
|
|
25945
|
-
}
|
|
25946
|
-
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
25947
|
-
}
|
|
25948
|
-
|
|
25949
|
-
// src/components/McpAppCard.tsx
|
|
25950
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
25951
|
-
var McpAppMessageContext = createContext(null);
|
|
25952
|
-
function McpAppCard({ sessionId, sourceId, client: suppliedClient, onMessage: suppliedOnMessage }) {
|
|
25953
|
-
const contextClient = useOptionalBladeClient();
|
|
25954
|
-
const contextMessage = useContext(McpAppMessageContext);
|
|
25955
|
-
const client = suppliedClient ?? contextClient;
|
|
25956
|
-
const onMessage = suppliedOnMessage ?? contextMessage;
|
|
25957
|
-
const onMessageRef = useRef2(onMessage);
|
|
25958
|
-
onMessageRef.current = onMessage;
|
|
25959
|
-
const [surface, setSurface] = useState2({ resourceMeta: {} });
|
|
25960
|
-
const [error62, setError] = useState2(null);
|
|
25961
|
-
useEffect2(() => {
|
|
25962
|
-
const controller = new AbortController();
|
|
25963
|
-
let disposed = false;
|
|
25964
|
-
let offChanged;
|
|
25965
|
-
let refreshRevision = 0;
|
|
25966
|
-
setError(null);
|
|
25967
|
-
setSurface({ resourceMeta: {} });
|
|
25968
|
-
const timer = window.setTimeout(() => {
|
|
25969
|
-
if (!disposed) setError("\u5E94\u7528\u8FDE\u63A5\u8D85\u65F6");
|
|
25970
|
-
}, 2e4);
|
|
25971
|
-
const start = async () => {
|
|
25972
|
-
if (!client) throw new Error("\u5E94\u7528\u4F1A\u8BDD\u4E0D\u53EF\u7528");
|
|
25973
|
-
const archive = await client.sessions.getMcpApp(sessionId, sourceId, { signal: controller.signal });
|
|
25974
|
-
if (disposed) return;
|
|
25975
|
-
const handlers = { html: archive.html, resourceMeta: archive.resourceMeta, title: archive.plugin };
|
|
25976
|
-
handlers.onReady = (bridge) => {
|
|
25977
|
-
offChanged?.();
|
|
25978
|
-
setError(null);
|
|
25979
|
-
const refresh = (restoreView = false) => {
|
|
25980
|
-
const revision = ++refreshRevision;
|
|
25981
|
-
void client.sessions.getMcpApp(sessionId, sourceId, { signal: controller.signal }).then(async (latest) => {
|
|
25982
|
-
if (!disposed && revision === refreshRevision) {
|
|
25983
|
-
setError(null);
|
|
25984
|
-
if (restoreView && latest.previousToolResult) {
|
|
25985
|
-
await bridge?.sendToolInput({ arguments: latest.previousToolInput ?? {} });
|
|
25986
|
-
await bridge?.sendToolResult(latest.previousToolResult);
|
|
25987
|
-
}
|
|
25988
|
-
await bridge?.sendToolInput({ arguments: latest.toolInput });
|
|
25989
|
-
await bridge?.sendToolResult(latest.toolResult);
|
|
25990
|
-
}
|
|
25991
|
-
}).catch(() => {
|
|
25992
|
-
if (!disposed) setError("\u5E94\u7528\u7ED3\u679C\u5237\u65B0\u5931\u8D25");
|
|
25993
|
-
});
|
|
25994
|
-
};
|
|
25995
|
-
offChanged = client.sessions.onMcpAppChanged(sessionId, sourceId, () => refresh());
|
|
25996
|
-
refresh(true);
|
|
25997
|
-
};
|
|
25998
|
-
const instance = randomId();
|
|
25999
|
-
const deliveredMessages = /* @__PURE__ */ new Set();
|
|
26000
|
-
handlers.callTool = async (params, extra) => {
|
|
26001
|
-
if (disposed) throw new Error("\u5E94\u7528\u5DF2\u5173\u95ED");
|
|
26002
|
-
const requestId = `${instance}:${String(extra.mcpReq.id)}`;
|
|
26003
|
-
const callController = new AbortController();
|
|
26004
|
-
const abort = () => callController.abort();
|
|
26005
|
-
const signals = [controller.signal, extra.mcpReq.signal];
|
|
26006
|
-
for (const signal of signals) {
|
|
26007
|
-
if (signal.aborted) abort();
|
|
26008
|
-
else signal.addEventListener("abort", abort, { once: true });
|
|
26009
|
-
}
|
|
26010
|
-
try {
|
|
26011
|
-
const result = await client.sessions.callMcpApp(sessionId, sourceId, {
|
|
26012
|
-
request_id: requestId,
|
|
26013
|
-
name: params.name,
|
|
26014
|
-
arguments: params.arguments ?? {}
|
|
26015
|
-
}, { signal: callController.signal });
|
|
26016
|
-
return result.response;
|
|
26017
|
-
} finally {
|
|
26018
|
-
for (const signal of signals) signal.removeEventListener("abort", abort);
|
|
26019
|
-
}
|
|
26020
|
-
};
|
|
26021
|
-
handlers.sendMessage = async ({ content }, extra) => {
|
|
26022
|
-
if (disposed || !onMessageRef.current) throw new Error("\u5F53\u524D\u4F1A\u8BDD\u4E0D\u80FD\u63A5\u6536\u5E94\u7528\u6D88\u606F");
|
|
26023
|
-
const requestId = String(extra.mcpReq.id);
|
|
26024
|
-
if (deliveredMessages.has(requestId)) return {};
|
|
26025
|
-
if (JSON.stringify(content).length > 65536 || content.some((part) => part.type !== "text")) {
|
|
26026
|
-
throw new Error("\u5E94\u7528\u6D88\u606F\u4EC5\u652F\u6301\u4E0D\u8D85\u8FC7 64 KiB \u7684\u6587\u672C");
|
|
26027
|
-
}
|
|
26028
|
-
const text = content.map((part) => part.type === "text" ? part.text : "").join("\n");
|
|
26029
|
-
if (!text.trim()) throw new Error("\u5E94\u7528\u6D88\u606F\u4E3A\u7A7A");
|
|
26030
|
-
onMessageRef.current({ sessionId, sourceId, label: archive.plugin, content: text });
|
|
26031
|
-
deliveredMessages.add(requestId);
|
|
26032
|
-
return {};
|
|
26033
|
-
};
|
|
26034
|
-
const deliveredContextUpdates = /* @__PURE__ */ new Set();
|
|
26035
|
-
let contextUpdates = Promise.resolve();
|
|
26036
|
-
handlers.updateModelContext = async ({ content, structuredContent }, extra) => {
|
|
26037
|
-
if (disposed) throw new Error("\u5E94\u7528\u5DF2\u5173\u95ED");
|
|
26038
|
-
const requestId = `${instance}:${String(extra.mcpReq.id)}`;
|
|
26039
|
-
if (deliveredContextUpdates.has(requestId)) return {};
|
|
26040
|
-
const parts = content ?? [];
|
|
26041
|
-
if (parts.some((part) => part.type !== "text")) throw new Error("\u5E94\u7528\u4E0A\u4E0B\u6587\u4EC5\u652F\u6301\u6587\u672C");
|
|
26042
|
-
const text = parts.map((part) => part.type === "text" ? part.text : "").join("\n").trim();
|
|
26043
|
-
const body = [text, structuredContent ? JSON.stringify(structuredContent) : ""].filter(Boolean).join("\n\n");
|
|
26044
|
-
if (!body.trim()) throw new Error("\u5E94\u7528\u4E0A\u4E0B\u6587\u4E3A\u7A7A");
|
|
26045
|
-
if (new TextEncoder().encode(body).length > 65536) throw new Error("\u5E94\u7528\u4E0A\u4E0B\u6587\u4EC5\u652F\u6301\u4E0D\u8D85\u8FC7 64 KiB \u7684\u6587\u672C");
|
|
26046
|
-
const submit = async () => {
|
|
26047
|
-
const current = await client.sessions.getMcpAppContext(sessionId, sourceId, { signal: controller.signal }).catch(() => null);
|
|
26048
|
-
return client.sessions.updateMcpAppContext(sessionId, sourceId, {
|
|
26049
|
-
request_id: requestId,
|
|
26050
|
-
expected_revision: current?.revision ?? null,
|
|
26051
|
-
content: body
|
|
26052
|
-
}, { signal: controller.signal });
|
|
26053
|
-
};
|
|
26054
|
-
const update = contextUpdates.then(async () => {
|
|
26055
|
-
if (disposed) throw new Error("\u5E94\u7528\u5DF2\u5173\u95ED");
|
|
26056
|
-
if (deliveredContextUpdates.has(requestId)) return {};
|
|
26057
|
-
try {
|
|
26058
|
-
await submit();
|
|
26059
|
-
} catch (error63) {
|
|
26060
|
-
if (!(error63 instanceof BladeApiError) || error63.status !== 409) throw error63;
|
|
26061
|
-
await submit();
|
|
26062
|
-
}
|
|
26063
|
-
deliveredContextUpdates.add(requestId);
|
|
26064
|
-
return {};
|
|
26065
|
-
});
|
|
26066
|
-
contextUpdates = update.catch(() => void 0);
|
|
26067
|
-
return update;
|
|
26068
|
-
};
|
|
26069
|
-
window.clearTimeout(timer);
|
|
26070
|
-
setSurface(handlers);
|
|
26071
|
-
};
|
|
26072
|
-
void start().catch((failure2) => {
|
|
26073
|
-
window.clearTimeout(timer);
|
|
26074
|
-
if (!disposed) setError(failure2 instanceof Error ? failure2.message : "\u5E94\u7528\u52A0\u8F7D\u5931\u8D25");
|
|
26075
|
-
});
|
|
26076
|
-
return () => {
|
|
26077
|
-
disposed = true;
|
|
26078
|
-
window.clearTimeout(timer);
|
|
26079
|
-
controller.abort();
|
|
26080
|
-
offChanged?.();
|
|
26081
|
-
};
|
|
26082
|
-
}, [client, sessionId, sourceId]);
|
|
26083
|
-
return /* @__PURE__ */ jsx2(McpAppFrame, { ...surface, error: error62 });
|
|
26084
|
-
}
|
|
26085
|
-
|
|
26086
|
-
// src/components/MessageImage.tsx
|
|
26087
|
-
import { forwardRef, useEffect as useEffect3, useImperativeHandle, useRef as useRef3, useState as useState3 } from "react";
|
|
26088
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
26089
|
-
var assetPattern = /^\/api\/(sessions|share)\/([^/]+)\/media\/([a-f0-9]{64})$/;
|
|
26090
|
-
var MessageImage = forwardRef(function MessageImage2({ client: suppliedClient, src, original = false, alt, style, ...props }, ref) {
|
|
26091
|
-
const contextClient = useOptionalBladeClient();
|
|
26092
|
-
const client = suppliedClient ?? contextClient;
|
|
26093
|
-
const element = useRef3(null);
|
|
26094
|
-
useImperativeHandle(ref, () => element.current);
|
|
26095
|
-
const [visible, setVisible] = useState3(false);
|
|
26096
|
-
const [result, setResult] = useState3(null);
|
|
26097
|
-
const match = src?.match(assetPattern);
|
|
26098
|
-
const scope = match?.[1];
|
|
26099
|
-
const sessionId = match?.[2];
|
|
26100
|
-
const assetId = match?.[3];
|
|
26101
|
-
const identity = assetId && client ? client.buildAuthedUrl(src) : "";
|
|
26102
|
-
const source = `${src}:${original}:${identity}`;
|
|
26103
|
-
useEffect3(() => {
|
|
26104
|
-
const node2 = element.current;
|
|
26105
|
-
if (!node2 || !assetId) return;
|
|
26106
|
-
if (original || typeof IntersectionObserver === "undefined") {
|
|
26107
|
-
setVisible(true);
|
|
26108
|
-
return;
|
|
26109
|
-
}
|
|
26110
|
-
const observer = new IntersectionObserver((entries) => {
|
|
26111
|
-
if (entries.some((entry) => entry.isIntersecting)) {
|
|
26112
|
-
setVisible(true);
|
|
26113
|
-
observer.disconnect();
|
|
26114
|
-
}
|
|
26115
|
-
}, { rootMargin: "200px" });
|
|
26116
|
-
observer.observe(node2);
|
|
26117
|
-
return () => observer.disconnect();
|
|
26118
|
-
}, [assetId, original]);
|
|
26119
|
-
useEffect3(() => {
|
|
26120
|
-
if (!visible || !client || !sessionId || !assetId) return;
|
|
26121
|
-
let alive = true;
|
|
26122
|
-
let objectUrl = null;
|
|
26123
|
-
const pending = scope === "share" ? client.sessions.fetchSharedImage(sessionId, assetId, !original) : client.sessions.fetchImage(sessionId, assetId, !original);
|
|
26124
|
-
void pending.then((blob) => {
|
|
26125
|
-
if (!alive) return;
|
|
26126
|
-
objectUrl = URL.createObjectURL(blob);
|
|
26127
|
-
setResult({ source, client, url: objectUrl });
|
|
26128
|
-
}).catch(() => {
|
|
26129
|
-
if (alive) setResult({ source, client, url: null });
|
|
26130
|
-
});
|
|
26131
|
-
return () => {
|
|
26132
|
-
alive = false;
|
|
26133
|
-
if (objectUrl) URL.revokeObjectURL(objectUrl);
|
|
26134
|
-
};
|
|
26135
|
-
}, [visible, client, scope, sessionId, assetId, original, source]);
|
|
26136
|
-
const current = result?.source === source && result.client === client ? result : null;
|
|
26137
|
-
const imageStyle = { aspectRatio: props.width && props.height ? `${props.width}/${props.height}` : void 0, ...style };
|
|
26138
|
-
return /* @__PURE__ */ jsx3(
|
|
26139
|
-
"img",
|
|
26140
|
-
{
|
|
26141
|
-
...props,
|
|
26142
|
-
ref: element,
|
|
26143
|
-
src: assetId ? current?.url ?? void 0 : src,
|
|
26144
|
-
alt: assetId && current?.url === null ? "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25" : alt,
|
|
26145
|
-
loading: original ? "eager" : "lazy",
|
|
26146
|
-
style: assetId && !current?.url && !props.height ? { minHeight: 64, ...imageStyle } : imageStyle
|
|
26147
|
-
}
|
|
26148
|
-
);
|
|
26149
|
-
});
|
|
26150
|
-
|
|
26151
|
-
// src/components/ToolUiCardView.tsx
|
|
26152
|
-
import { resolveToolUiCardContent } from "@blade-hq/agent-client/internal";
|
|
26153
|
-
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
26154
|
-
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
26155
|
-
function ToolUiCardView({ card, sessionId }) {
|
|
26156
|
-
if (card.mcpApp) return sessionId ? /* @__PURE__ */ jsx4(McpAppCard, { sessionId, sourceId: card.mcpApp.sourceId }) : null;
|
|
26157
|
-
const resolved = resolveToolUiCardContent(card);
|
|
26158
|
-
if (!resolved) return null;
|
|
26159
|
-
if (resolved.type === "resource-file") {
|
|
26160
|
-
return sessionId ? /* @__PURE__ */ jsx4(FileCard, { card, sessionId, path: resolved.content }, `${sessionId}:${resolved.content}`) : null;
|
|
26161
|
-
}
|
|
26162
|
-
const sandbox = resolved.type === "resource-uri" ? "allow-scripts allow-same-origin" : "allow-scripts";
|
|
26163
|
-
return /* @__PURE__ */ jsx4(
|
|
26164
|
-
"iframe",
|
|
26165
|
-
{
|
|
26166
|
-
title: card.title ?? "\u5DE5\u5177\u754C\u9762",
|
|
26167
|
-
src: resolved.type === "resource-uri" ? resolved.content : void 0,
|
|
26168
|
-
srcDoc: resolved.type === "resource-html" ? injectBaseTag(resolved.content) : void 0,
|
|
26169
|
-
sandbox,
|
|
26170
|
-
loading: "lazy",
|
|
26171
|
-
scrolling: "no",
|
|
26172
|
-
className: "w-full rounded-xl border border-[hsl(var(--border))] bg-white",
|
|
26173
|
-
referrerPolicy: "no-referrer",
|
|
26174
|
-
style: { height: card.height }
|
|
26175
|
-
}
|
|
26176
|
-
);
|
|
26177
|
-
}
|
|
26178
|
-
function FileCard({ card, sessionId, path }) {
|
|
26179
|
-
const client = useBladeClient();
|
|
26180
|
-
const [html, setHtml] = useState4(null);
|
|
26181
|
-
const [failed, setFailed] = useState4(false);
|
|
26182
|
-
const [refreshVersion, setRefreshVersion] = useState4(0);
|
|
26183
|
-
useEffect4(() => {
|
|
26184
|
-
const abort = new AbortController();
|
|
26185
|
-
setHtml(null);
|
|
26186
|
-
setFailed(false);
|
|
26187
|
-
void client.textFromInit(
|
|
26188
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/files/${encodeURIComponent(path)}`,
|
|
26189
|
-
{ signal: abort.signal }
|
|
26190
|
-
).then((content) => {
|
|
26191
|
-
if (!abort.signal.aborted) setHtml(content);
|
|
26192
|
-
}).catch(() => {
|
|
26193
|
-
if (!abort.signal.aborted) setFailed(true);
|
|
26194
|
-
});
|
|
26195
|
-
return () => abort.abort();
|
|
26196
|
-
}, [client, sessionId, path, refreshVersion]);
|
|
26197
|
-
const filePath = path.split("/").map(encodeURIComponent).join("/").replace(/^\//, "%2F");
|
|
26198
|
-
const baseUrl = new URL(
|
|
26199
|
-
`api/sessions/${encodeURIComponent(sessionId)}/serve/${filePath}`,
|
|
26200
|
-
`${client.options.baseUrl.replace(/\/$/, "")}/`
|
|
26201
|
-
).href;
|
|
26202
|
-
return /* @__PURE__ */ jsxs2("div", { children: [
|
|
26203
|
-
/* @__PURE__ */ jsx4("div", { className: "flex justify-end py-2", children: /* @__PURE__ */ jsx4(
|
|
26204
|
-
"button",
|
|
26205
|
-
{
|
|
26206
|
-
type: "button",
|
|
26207
|
-
disabled: html === null && !failed,
|
|
26208
|
-
onClick: () => setRefreshVersion((value) => value + 1),
|
|
26209
|
-
className: "rounded-md bg-[hsl(var(--primary))] px-3 py-1 text-sm text-[hsl(var(--primary-foreground))]",
|
|
26210
|
-
children: "\u5237\u65B0"
|
|
26211
|
-
}
|
|
26212
|
-
) }),
|
|
26213
|
-
failed ? /* @__PURE__ */ jsx4("p", { role: "alert", children: "\u65E0\u6CD5\u6253\u5F00\u6587\u4EF6\uFF0C\u6587\u4EF6\u53EF\u80FD\u5DF2\u79FB\u52A8\u6216\u5220\u9664\u3002" }) : html === null ? /* @__PURE__ */ jsx4("p", { children: "\u6B63\u5728\u6253\u5F00\u6587\u4EF6\u2026" }) : /* @__PURE__ */ jsx4(
|
|
26214
|
-
"iframe",
|
|
26215
|
-
{
|
|
26216
|
-
title: card.title ?? "\u6587\u4EF6\u9884\u89C8",
|
|
26217
|
-
srcDoc: injectBaseTag(html, baseUrl),
|
|
26218
|
-
sandbox: "allow-scripts",
|
|
26219
|
-
loading: "lazy",
|
|
26220
|
-
referrerPolicy: "no-referrer",
|
|
26221
|
-
className: "w-full rounded-xl border border-[hsl(var(--border))] bg-white",
|
|
26222
|
-
style: { height: card.height }
|
|
26223
|
-
}
|
|
26224
|
-
)
|
|
26225
|
-
] });
|
|
26226
|
-
}
|
|
26227
|
-
function injectBaseTag(html, baseUrl = `${window.location.origin}/`) {
|
|
26228
|
-
const base = `<base href="${baseUrl.replaceAll("&", "&").replaceAll('"', """)}">`;
|
|
26229
|
-
const headIdx = html.toLowerCase().indexOf("<head");
|
|
26230
|
-
if (headIdx >= 0) {
|
|
26231
|
-
const closeIdx = html.indexOf(">", headIdx);
|
|
26232
|
-
if (closeIdx >= 0) {
|
|
26233
|
-
return `${html.slice(0, closeIdx + 1)}
|
|
26234
|
-
${base}
|
|
26235
|
-
${html.slice(closeIdx + 1)}`;
|
|
26236
|
-
}
|
|
26237
|
-
}
|
|
26238
|
-
return `${base}
|
|
26239
|
-
${html}`;
|
|
26240
|
-
}
|
|
26241
|
-
|
|
26242
|
-
// src/chat/lib/code-language.ts
|
|
26243
|
-
var SUPPORTED_LANGUAGES = [
|
|
26244
|
-
"python",
|
|
26245
|
-
"javascript",
|
|
26246
|
-
"typescript",
|
|
26247
|
-
"tsx",
|
|
26248
|
-
"jsx",
|
|
26249
|
-
"yaml",
|
|
26250
|
-
"markdown",
|
|
26251
|
-
"bash",
|
|
26252
|
-
"json",
|
|
26253
|
-
"go",
|
|
26254
|
-
"rust",
|
|
26255
|
-
"css",
|
|
26256
|
-
"html"
|
|
26257
|
-
];
|
|
26258
|
-
var LANGUAGE_ALIASES = {
|
|
26259
|
-
bash: "bash",
|
|
26260
|
-
css: "css",
|
|
26261
|
-
go: "go",
|
|
26262
|
-
golang: "go",
|
|
26263
|
-
htm: "html",
|
|
26264
|
-
html: "html",
|
|
26265
|
-
javascript: "javascript",
|
|
26266
|
-
js: "javascript",
|
|
26267
|
-
json: "json",
|
|
26268
|
-
jsonc: "json",
|
|
26269
|
-
jsx: "jsx",
|
|
26270
|
-
markdown: "markdown",
|
|
26271
|
-
md: "markdown",
|
|
26272
|
-
py: "python",
|
|
26273
|
-
python: "python",
|
|
26274
|
-
rs: "rust",
|
|
26275
|
-
rust: "rust",
|
|
26276
|
-
scss: "css",
|
|
26277
|
-
sh: "bash",
|
|
26278
|
-
shell: "bash",
|
|
26279
|
-
ts: "typescript",
|
|
26280
|
-
tsx: "tsx",
|
|
26281
|
-
typescript: "typescript",
|
|
26282
|
-
yaml: "yaml",
|
|
26283
|
-
yml: "yaml",
|
|
26284
|
-
zsh: "bash"
|
|
26285
|
-
};
|
|
26286
|
-
var FILE_EXTENSION_ALIASES = {
|
|
26287
|
-
".bash": "bash",
|
|
26288
|
-
".css": "css",
|
|
26289
|
-
".go": "go",
|
|
26290
|
-
".htm": "html",
|
|
26291
|
-
".html": "html",
|
|
26292
|
-
".js": "javascript",
|
|
26293
|
-
".json": "json",
|
|
26294
|
-
".jsonc": "json",
|
|
26295
|
-
".jsx": "jsx",
|
|
26296
|
-
".md": "markdown",
|
|
26297
|
-
".mdx": "markdown",
|
|
26298
|
-
".py": "python",
|
|
26299
|
-
".rs": "rust",
|
|
26300
|
-
".scss": "css",
|
|
26301
|
-
".sh": "bash",
|
|
26302
|
-
".ts": "typescript",
|
|
26303
|
-
".tsx": "tsx",
|
|
26304
|
-
".yaml": "yaml",
|
|
26305
|
-
".yml": "yaml",
|
|
26306
|
-
".zsh": "bash"
|
|
26307
|
-
};
|
|
26308
|
-
function normalizeCodeLanguage(language) {
|
|
26309
|
-
if (!language) return null;
|
|
26310
|
-
return LANGUAGE_ALIASES[language.trim().toLowerCase()] ?? null;
|
|
26311
|
-
}
|
|
26312
|
-
function getCodeLanguageFromFilename(filePath) {
|
|
26313
|
-
if (!filePath) return null;
|
|
26314
|
-
const dotIndex = filePath.lastIndexOf(".");
|
|
26315
|
-
if (dotIndex < 0) return null;
|
|
26316
|
-
return FILE_EXTENSION_ALIASES[filePath.slice(dotIndex).toLowerCase()] ?? null;
|
|
26317
|
-
}
|
|
26318
|
-
|
|
26319
|
-
// src/chat/tool-renderers/shared.tsx
|
|
26320
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
26321
|
-
function getResultText(result) {
|
|
26322
|
-
if (typeof result === "string") return result;
|
|
26323
|
-
if (Array.isArray(result)) {
|
|
26324
|
-
const texts = result.filter(
|
|
26325
|
-
(p2) => typeof p2 === "object" && p2 !== null && p2.type === "text" && typeof p2.text === "string"
|
|
26326
|
-
).map((p2) => p2.text);
|
|
26327
|
-
return texts.length > 0 ? texts.join("\n") : null;
|
|
26328
|
-
}
|
|
26329
|
-
return result != null ? String(result) : null;
|
|
26330
|
-
}
|
|
26331
|
-
function getResultImages(result) {
|
|
26332
|
-
if (!Array.isArray(result)) return [];
|
|
26333
|
-
return result.filter(
|
|
26334
|
-
(p2) => typeof p2 === "object" && p2 !== null && p2.type === "image_url" && typeof p2.image_url?.url === "string"
|
|
26335
|
-
).map((p2) => p2.image_url);
|
|
26336
|
-
}
|
|
26337
|
-
function parseJsonValue(value) {
|
|
26338
|
-
if (!value) return null;
|
|
26339
|
-
try {
|
|
26340
|
-
return JSON.parse(value);
|
|
26341
|
-
} catch {
|
|
26342
|
-
return null;
|
|
26343
|
-
}
|
|
26344
|
-
}
|
|
26345
|
-
function isPlainObject3(value) {
|
|
26346
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
26347
|
-
}
|
|
26348
|
-
function getStringValue(data, key) {
|
|
26349
|
-
const value = data?.[key];
|
|
26350
|
-
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
26351
|
-
}
|
|
26352
|
-
function getNumberValue(data, key) {
|
|
26353
|
-
const value = data?.[key];
|
|
26354
|
-
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
26355
|
-
}
|
|
26356
|
-
function getBooleanValue(data, key) {
|
|
26357
|
-
return data?.[key] === true;
|
|
26358
|
-
}
|
|
26359
|
-
function extractErrorMessage(value) {
|
|
26360
|
-
const text = typeof value === "string" ? value : getResultText(value);
|
|
26361
|
-
if (!text?.trim()) return null;
|
|
26362
|
-
const parsed = parseJsonValue(text);
|
|
26363
|
-
if (!isPlainObject3(parsed)) return null;
|
|
26364
|
-
return typeof parsed.error === "string" && parsed.error.trim() ? parsed.error.trim() : null;
|
|
26365
|
-
}
|
|
26366
|
-
function getFileName(filePath) {
|
|
26367
|
-
if (!filePath) return "\u672A\u547D\u540D\u6587\u4EF6";
|
|
26368
|
-
return filePath.split(/[\\/]/).pop() ?? filePath;
|
|
26369
|
-
}
|
|
26370
|
-
function getCodeLanguage(filePath) {
|
|
26371
|
-
return getCodeLanguageFromFilename(filePath);
|
|
26372
|
-
}
|
|
26373
|
-
function formatBytes(size) {
|
|
26374
|
-
if (typeof size !== "number" || !Number.isFinite(size) || size < 0) return null;
|
|
26375
|
-
if (size < 1024) return `${size} B`;
|
|
26376
|
-
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
|
|
26377
|
-
return `${(size / (1024 * 1024)).toFixed(1)} MB`;
|
|
26378
|
-
}
|
|
26379
|
-
function CodePreview({
|
|
26380
|
-
content,
|
|
26381
|
-
filePath,
|
|
26382
|
-
emptyLabel = "\uFF08\u6682\u65E0\u5185\u5BB9\uFF09",
|
|
26383
|
-
className
|
|
26384
|
-
}) {
|
|
26385
|
-
const { highlightedHtml } = useHighlightedCode(content, getCodeLanguage(filePath));
|
|
26386
|
-
if (!content.trim()) {
|
|
26387
|
-
return /* @__PURE__ */ jsx5(
|
|
26388
|
-
"pre",
|
|
26389
|
-
{
|
|
26390
|
-
className: cn(
|
|
26391
|
-
"overflow-auto rounded-lg border border-[hsl(var(--border))]",
|
|
26392
|
-
"bg-[hsl(var(--muted))]/35 p-3 font-mono text-[11px] text-[hsl(var(--muted-foreground))]",
|
|
26393
|
-
className
|
|
26394
|
-
),
|
|
26395
|
-
children: /* @__PURE__ */ jsx5("code", { children: emptyLabel })
|
|
26396
|
-
}
|
|
26397
|
-
);
|
|
26398
|
-
}
|
|
26399
|
-
return /* @__PURE__ */ jsx5(
|
|
26400
|
-
"pre",
|
|
26401
|
-
{
|
|
26402
|
-
className: cn(
|
|
26403
|
-
"overflow-auto rounded-lg border border-[hsl(var(--border))]",
|
|
26404
|
-
"bg-[hsl(var(--muted))]/35 p-3 text-[11px]",
|
|
26405
|
-
className
|
|
26406
|
-
),
|
|
26407
|
-
children: highlightedHtml ? /* @__PURE__ */ jsx5(
|
|
26408
|
-
"code",
|
|
26409
|
-
{
|
|
26410
|
-
className: "font-mono",
|
|
26411
|
-
dangerouslySetInnerHTML: { __html: highlightedHtml }
|
|
26412
|
-
}
|
|
26413
|
-
) : /* @__PURE__ */ jsx5("code", { className: "whitespace-pre-wrap break-words font-mono text-[hsl(var(--foreground))]", children: content })
|
|
26414
|
-
}
|
|
26415
|
-
);
|
|
26416
|
-
}
|
|
26417
|
-
|
|
26418
|
-
// src/chat/tool-renderers/BashRenderer.tsx
|
|
26419
|
-
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
26420
|
-
function pickOutputField(data) {
|
|
26421
|
-
if (!data) return null;
|
|
26422
|
-
for (const key of ["output", "stdout", "stderr"]) {
|
|
26423
|
-
const value = data[key];
|
|
26424
|
-
if (typeof value === "string") return value;
|
|
26425
|
-
}
|
|
26426
|
-
return null;
|
|
26427
|
-
}
|
|
26428
|
-
function MetaPill({ label }) {
|
|
26429
|
-
return /* @__PURE__ */ jsx6("span", { className: "rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-secondary-foreground", children: label });
|
|
26430
|
-
}
|
|
26431
|
-
function BashRenderer({ toolCall }) {
|
|
26432
|
-
const argsValue = parseJsonValue(toolCall.arguments);
|
|
26433
|
-
const rawText = getResultText(toolCall.result);
|
|
26434
|
-
const resultStr = typeof rawText === "string" && rawText.trim().length > 0 ? rawText : null;
|
|
26435
|
-
const resultValue = parseJsonValue(resultStr);
|
|
26436
|
-
const args = isPlainObject3(argsValue) ? argsValue : null;
|
|
26437
|
-
const result = isPlainObject3(resultValue) ? resultValue : null;
|
|
26438
|
-
const normalizedName = formatToolName(toolCall.name);
|
|
26439
|
-
const command = getStringValue(result, "command") ?? getStringValue(args, "command") ?? "";
|
|
26440
|
-
const taskId = getStringValue(result, "task_id");
|
|
26441
|
-
const exitCode = getNumberValue(result, "exit_code");
|
|
26442
|
-
const timedOut = getBooleanValue(result, "timed_out");
|
|
26443
|
-
const truncated = getBooleanValue(result, "truncated");
|
|
26444
|
-
const cwdResetNote = getStringValue(result, "cwd_reset_note");
|
|
26445
|
-
const errorMessage = extractErrorMessage(toolCall.result) ?? (toolCall.status === "error" ? resultStr?.trim() ?? null : null);
|
|
26446
|
-
const structuredOutput = pickOutputField(result);
|
|
26447
|
-
const rawFallbackOutput = result === null && typeof resultStr === "string" && resultStr.trim().length > 0 ? resultStr : null;
|
|
26448
|
-
const output2 = structuredOutput !== null ? structuredOutput : errorMessage ?? rawFallbackOutput ?? (normalizedName === "BgBash" ? "" : null);
|
|
26449
|
-
const hasFailure = toolCall.status === "error" || timedOut || exitCode !== null && exitCode !== 0;
|
|
26450
|
-
return /* @__PURE__ */ jsxs3("div", { className: "space-y-3", children: [
|
|
26451
|
-
/* @__PURE__ */ jsxs3("div", { className: "overflow-hidden rounded-lg border border-border bg-card", children: [
|
|
26452
|
-
/* @__PURE__ */ jsx6("div", { className: "border-b border-border px-3 py-2 text-[10px] uppercase tracking-[0.16em] text-muted-foreground", children: "\u547D\u4EE4" }),
|
|
26453
|
-
/* @__PURE__ */ jsx6("pre", { className: "overflow-x-auto px-3 py-3 font-mono text-[11px] leading-5 text-foreground", children: /* @__PURE__ */ jsx6("code", { children: `$ ${command || "\uFF08\u672A\u63D0\u4F9B\u547D\u4EE4\uFF09"}` }) })
|
|
26454
|
-
] }),
|
|
26455
|
-
/* @__PURE__ */ jsxs3(
|
|
26456
|
-
"div",
|
|
26457
|
-
{
|
|
26458
|
-
className: cn(
|
|
26459
|
-
"overflow-hidden rounded-lg border bg-muted/50",
|
|
26460
|
-
hasFailure ? "border-[hsl(var(--swf-danger)/0.5)]" : "border-border"
|
|
26461
|
-
),
|
|
26462
|
-
children: [
|
|
26463
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2", children: [
|
|
26464
|
-
/* @__PURE__ */ jsx6("div", { className: "text-[10px] uppercase tracking-[0.16em] text-muted-foreground", children: "\u8F93\u51FA" }),
|
|
26465
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
26466
|
-
taskId ? /* @__PURE__ */ jsx6(MetaPill, { label: `\u4EFB\u52A1 ${taskId}` }) : null,
|
|
26467
|
-
exitCode !== null ? /* @__PURE__ */ jsx6(MetaPill, { label: `\u9000\u51FA\u7801 ${exitCode}` }) : null,
|
|
26468
|
-
timedOut ? /* @__PURE__ */ jsx6(MetaPill, { label: "\u5DF2\u8D85\u65F6" }) : null,
|
|
26469
|
-
truncated ? /* @__PURE__ */ jsx6(MetaPill, { label: "\u8F93\u51FA\u5DF2\u622A\u65AD" }) : null,
|
|
26470
|
-
normalizedName === "BgBash" && !taskId ? /* @__PURE__ */ jsx6(MetaPill, { label: "\u540E\u53F0\u4EFB\u52A1" }) : null
|
|
26471
|
-
] })
|
|
26472
|
-
] }),
|
|
26473
|
-
/* @__PURE__ */ jsx6("pre", { className: "max-h-[280px] overflow-auto px-3 py-3 font-mono text-[11px] leading-5 text-foreground", children: /* @__PURE__ */ jsx6("code", { className: "whitespace-pre-wrap break-words", children: output2 !== null && output2.trim().length > 0 ? output2 : normalizedName === "BgBash" ? "\u4EFB\u52A1\u5DF2\u8FDB\u5165\u540E\u53F0\u6267\u884C\uFF0C\u8F93\u51FA\u4F1A\u5728\u540E\u53F0\u4EFB\u52A1\u9762\u677F\u4E2D\u7EE7\u7EED\u66F4\u65B0\u3002" : output2 !== null && output2.trim().length === 0 && hasFailure ? "\u547D\u4EE4\u5DF2\u7ED3\u675F\uFF0C\u4F46\u672A\u6355\u83B7\u5230\u7EC8\u7AEF\u8F93\u51FA\uFF08\u8BF7\u67E5\u770B\u9000\u51FA\u7801\uFF09\u3002" : "\u547D\u4EE4\u672A\u8FD4\u56DE\u8F93\u51FA\u3002" }) })
|
|
26474
|
-
]
|
|
26475
|
-
}
|
|
26476
|
-
),
|
|
26477
|
-
cwdResetNote ? /* @__PURE__ */ jsx6("div", { className: "rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/35 px-3 py-2 text-[11px] text-[hsl(var(--muted-foreground))]", children: cwdResetNote }) : null
|
|
26478
|
-
] });
|
|
26479
|
-
}
|
|
26480
|
-
|
|
26481
|
-
// src/chat/tool-renderers/write-preview-scroll.ts
|
|
26482
|
-
function shouldFollowWritePreview(toolName, status) {
|
|
26483
|
-
return toolName === "Write" && status === "pending";
|
|
26484
|
-
}
|
|
26485
|
-
function scrollWritePreviewToLatest(preview) {
|
|
26486
|
-
preview.scrollTop = preview.scrollHeight;
|
|
26487
|
-
}
|
|
26488
|
-
|
|
26489
|
-
// src/chat/tool-renderers/FileEditRenderer.tsx
|
|
26490
|
-
import { useLayoutEffect as useLayoutEffect2, useRef as useRef4 } from "react";
|
|
26491
|
-
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
26492
|
-
var MAX_DIFF_LINES = 200;
|
|
26493
|
-
var FILE_PATH_FIELDS = ["file_path", "path"];
|
|
26494
|
-
function computeDiff(oldText, newText) {
|
|
26495
|
-
const oldLines = oldText.split("\n");
|
|
26496
|
-
const newLines = newText.split("\n");
|
|
26497
|
-
if (oldLines.length > MAX_DIFF_LINES || newLines.length > MAX_DIFF_LINES) {
|
|
26498
|
-
return [
|
|
26499
|
-
...oldLines.slice(0, MAX_DIFF_LINES).map((line) => ({
|
|
26500
|
-
type: "removed",
|
|
26501
|
-
value: line,
|
|
26502
|
-
line: null
|
|
26503
|
-
})),
|
|
26504
|
-
...newLines.slice(0, MAX_DIFF_LINES).map((line, i2) => ({
|
|
26505
|
-
type: "added",
|
|
26506
|
-
value: line,
|
|
26507
|
-
line: i2 + 1
|
|
26508
|
-
}))
|
|
26509
|
-
];
|
|
26510
|
-
}
|
|
26511
|
-
const rows = oldLines.length;
|
|
26512
|
-
const cols = newLines.length;
|
|
26513
|
-
const lcs = Array.from({ length: rows + 1 }, () => Array(cols + 1).fill(0));
|
|
26514
|
-
for (let row2 = 1; row2 <= rows; row2 += 1) {
|
|
26515
|
-
for (let col2 = 1; col2 <= cols; col2 += 1) {
|
|
26516
|
-
lcs[row2][col2] = oldLines[row2 - 1] === newLines[col2 - 1] ? lcs[row2 - 1][col2 - 1] + 1 : Math.max(lcs[row2 - 1][col2], lcs[row2][col2 - 1]);
|
|
26517
|
-
}
|
|
26518
|
-
}
|
|
26519
|
-
const diff = [];
|
|
26520
|
-
let row = rows;
|
|
26521
|
-
let col = cols;
|
|
26522
|
-
while (row > 0 || col > 0) {
|
|
26523
|
-
if (row > 0 && col > 0 && oldLines[row - 1] === newLines[col - 1]) {
|
|
26524
|
-
diff.push({ type: "unchanged", value: oldLines[row - 1] });
|
|
26525
|
-
row -= 1;
|
|
26526
|
-
col -= 1;
|
|
26527
|
-
continue;
|
|
26528
|
-
}
|
|
26529
|
-
if (col > 0 && (row === 0 || lcs[row][col - 1] >= lcs[row - 1][col])) {
|
|
26530
|
-
diff.push({ type: "added", value: newLines[col - 1] });
|
|
26531
|
-
col -= 1;
|
|
26532
|
-
continue;
|
|
26533
|
-
}
|
|
26534
|
-
if (row > 0) {
|
|
26535
|
-
diff.push({ type: "removed", value: oldLines[row - 1] });
|
|
26536
|
-
row -= 1;
|
|
26537
|
-
}
|
|
26538
|
-
}
|
|
26539
|
-
const numbered = [];
|
|
26540
|
-
let lineNumber = 0;
|
|
26541
|
-
for (const line of diff.reverse()) {
|
|
26542
|
-
if (line.type === "removed") {
|
|
26543
|
-
numbered.push({ ...line, line: null });
|
|
26544
|
-
continue;
|
|
26545
|
-
}
|
|
26546
|
-
lineNumber += 1;
|
|
26547
|
-
numbered.push({ ...line, line: lineNumber });
|
|
26548
|
-
}
|
|
26549
|
-
return numbered;
|
|
26550
|
-
}
|
|
26551
|
-
function buildWritePreview(content) {
|
|
26552
|
-
return content.split("\n").map((line, index) => ({
|
|
26553
|
-
type: "added",
|
|
26554
|
-
value: line,
|
|
26555
|
-
line: index + 1
|
|
26556
|
-
}));
|
|
26557
|
-
}
|
|
26558
|
-
function buildEditPreview(args, rawArguments) {
|
|
26559
|
-
const edits = Array.isArray(args?.edits) ? args.edits : null;
|
|
26560
|
-
if (edits) {
|
|
26561
|
-
return edits.flatMap((rawEdit, index) => {
|
|
26562
|
-
if (!isPlainObject3(rawEdit)) {
|
|
26563
|
-
return [];
|
|
26564
|
-
}
|
|
26565
|
-
const oldText = getStringValue(rawEdit, "old_text") ?? "";
|
|
26566
|
-
const newText = getStringValue(rawEdit, "new_text") ?? "";
|
|
26567
|
-
const lines = computeDiff(oldText, newText);
|
|
26568
|
-
return index === 0 ? lines : [
|
|
26569
|
-
{ type: "unchanged", value: "", line: null },
|
|
26570
|
-
...lines
|
|
26571
|
-
];
|
|
26572
|
-
});
|
|
26573
|
-
}
|
|
26574
|
-
const oldString = getStringValue(args, "old_string") ?? "";
|
|
26575
|
-
const newString = getStringValue(args, "new_string") ?? "";
|
|
26576
|
-
if (!oldString && !newString && !args) {
|
|
26577
|
-
return buildPartialEditPreview(rawArguments);
|
|
26578
|
-
}
|
|
26579
|
-
return computeDiff(oldString, newString);
|
|
26580
|
-
}
|
|
26581
|
-
function buildPartialEditPreview(rawArguments) {
|
|
26582
|
-
const oldValues = extractAllJsonStringFieldPartials(rawArguments, "old_text");
|
|
26583
|
-
const newValues = extractAllJsonStringFieldPartials(rawArguments, "new_text");
|
|
26584
|
-
if (!oldValues.length && !newValues.length) return [];
|
|
26585
|
-
const rows = [];
|
|
26586
|
-
for (let index = 0; index < Math.max(oldValues.length, newValues.length); index += 1) {
|
|
26587
|
-
if (index > 0) {
|
|
26588
|
-
rows.push({ type: "unchanged", value: "", line: null });
|
|
26589
|
-
}
|
|
26590
|
-
const oldText = oldValues[index] ?? "";
|
|
26591
|
-
const newText = newValues[index] ?? "";
|
|
26592
|
-
rows.push(...computeDiff(oldText, newText));
|
|
26593
|
-
}
|
|
26594
|
-
return rows;
|
|
26595
|
-
}
|
|
26596
|
-
function extractChecksum(result) {
|
|
26597
|
-
const text = typeof result === "string" ? result : null;
|
|
26598
|
-
const match = text?.match(/\[checksum:\s*([^\]]+)\]/);
|
|
26599
|
-
return match?.[1]?.trim() ?? null;
|
|
26600
|
-
}
|
|
26601
|
-
function getRawStringValue(data, key) {
|
|
26602
|
-
const value = data?.[key];
|
|
26603
|
-
return typeof value === "string" ? value : null;
|
|
26604
|
-
}
|
|
26605
|
-
function extractJsonStringFieldPartial(raw, names) {
|
|
26606
|
-
for (const name of names) {
|
|
26607
|
-
const values = extractAllJsonStringFieldPartials(raw, name);
|
|
26608
|
-
if (values.length > 0) return values[values.length - 1] ?? "";
|
|
26609
|
-
}
|
|
26610
|
-
return "";
|
|
26611
|
-
}
|
|
26612
|
-
function extractAllJsonStringFieldPartials(raw, name) {
|
|
26613
|
-
return extractAllJsonStringFields(raw, name, false);
|
|
26614
|
-
}
|
|
26615
|
-
function extractAllJsonStringFields(raw, name, requireClosed) {
|
|
26616
|
-
const marker = `"${name}"`;
|
|
26617
|
-
const values = [];
|
|
26618
|
-
let searchFrom = 0;
|
|
26619
|
-
while (true) {
|
|
26620
|
-
const markerIndex = raw.indexOf(marker, searchFrom);
|
|
26621
|
-
if (markerIndex < 0) return values;
|
|
26622
|
-
const colonIndex = raw.indexOf(":", markerIndex + marker.length);
|
|
26623
|
-
if (colonIndex < 0) return values;
|
|
26624
|
-
const quoteIndex = raw.indexOf('"', colonIndex + 1);
|
|
26625
|
-
if (quoteIndex < 0) return values;
|
|
26626
|
-
const { value, closed } = readJsonString(raw, quoteIndex + 1);
|
|
26627
|
-
if (closed || !requireClosed) {
|
|
26628
|
-
values.push(value);
|
|
26629
|
-
}
|
|
26630
|
-
searchFrom = quoteIndex + 1;
|
|
26631
|
-
}
|
|
26632
|
-
}
|
|
26633
|
-
function readJsonString(raw, start) {
|
|
26634
|
-
const chars = [];
|
|
26635
|
-
let index = start;
|
|
26636
|
-
while (index < raw.length) {
|
|
26637
|
-
const char = raw[index];
|
|
26638
|
-
if (char === '"') {
|
|
26639
|
-
return { value: chars.join(""), closed: true };
|
|
26640
|
-
}
|
|
26641
|
-
if (char !== "\\") {
|
|
26642
|
-
chars.push(char);
|
|
26643
|
-
index += 1;
|
|
26644
|
-
continue;
|
|
26645
|
-
}
|
|
26646
|
-
if (index + 1 >= raw.length) {
|
|
26647
|
-
return { value: chars.join(""), closed: false };
|
|
26648
|
-
}
|
|
26649
|
-
const escaped = raw[index + 1];
|
|
26650
|
-
if (escaped === "n") {
|
|
26651
|
-
chars.push("\n");
|
|
26652
|
-
} else if (escaped === "r") {
|
|
26653
|
-
chars.push("\r");
|
|
26654
|
-
} else if (escaped === "t") {
|
|
26655
|
-
chars.push(" ");
|
|
26656
|
-
} else if (escaped === '"' || escaped === "\\" || escaped === "/") {
|
|
26657
|
-
chars.push(escaped);
|
|
26658
|
-
} else if (escaped === "u" && index + 5 < raw.length) {
|
|
26659
|
-
const code = raw.slice(index + 2, index + 6);
|
|
26660
|
-
const parsed = Number.parseInt(code, 16);
|
|
26661
|
-
if (Number.isFinite(parsed)) {
|
|
26662
|
-
chars.push(String.fromCharCode(parsed));
|
|
26663
|
-
}
|
|
26664
|
-
index += 4;
|
|
26665
|
-
} else {
|
|
26666
|
-
chars.push(escaped ?? "");
|
|
26667
|
-
}
|
|
26668
|
-
index += 2;
|
|
26669
|
-
}
|
|
26670
|
-
return { value: chars.join(""), closed: false };
|
|
26671
|
-
}
|
|
26672
|
-
function FileEditRenderer({ toolCall }) {
|
|
26673
|
-
const previewRef = useRef4(null);
|
|
26674
|
-
const rawArguments = toolCall.arguments ?? "";
|
|
26675
|
-
const argsValue = parseJsonValue(toolCall.arguments);
|
|
26676
|
-
const args = isPlainObject3(argsValue) ? argsValue : null;
|
|
26677
|
-
const normalizedName = formatToolName(toolCall.name);
|
|
26678
|
-
const partialFilePath = extractJsonStringFieldPartial(rawArguments, FILE_PATH_FIELDS);
|
|
26679
|
-
const filePath = extractToolFilePath(toolCall) ?? partialFilePath;
|
|
26680
|
-
const fileName = getFileName(filePath);
|
|
26681
|
-
const errorMessage = extractErrorMessage(toolCall.result);
|
|
26682
|
-
const displayErrorMessage = errorMessage ? "\u6587\u4EF6\u64CD\u4F5C\u5931\u8D25" : null;
|
|
26683
|
-
const checksum = extractChecksum(toolCall.result);
|
|
26684
|
-
const description = getStringValue(args, "description") ?? extractJsonStringFieldPartial(rawArguments, ["description"]);
|
|
26685
|
-
const writeContent = getRawStringValue(args, "content") ?? extractJsonStringFieldPartial(rawArguments, ["content"]);
|
|
26686
|
-
const diffLines = normalizedName === "Write" ? buildWritePreview(writeContent) : buildEditPreview(args, rawArguments);
|
|
26687
|
-
const resultStr = typeof toolCall.result === "string" ? toolCall.result : null;
|
|
26688
|
-
const summaryText = resultStr?.trim() && !errorMessage ? resultStr.trim() : null;
|
|
26689
|
-
const displaySummaryText = summaryText && toolCall.status !== "error" && toolCall.status !== "cancelled" ? normalizedName === "Write" ? "\u6587\u4EF6\u5DF2\u5199\u5165" : "\u6587\u4EF6\u5DF2\u66F4\u65B0" : null;
|
|
26690
|
-
const followLatest = shouldFollowWritePreview(normalizedName, toolCall.status);
|
|
26691
|
-
useLayoutEffect2(() => {
|
|
26692
|
-
const preview = previewRef.current;
|
|
26693
|
-
if (!preview || !followLatest || writeContent.length === 0) return;
|
|
26694
|
-
scrollWritePreviewToLatest(preview);
|
|
26695
|
-
}, [followLatest, writeContent]);
|
|
26696
|
-
return /* @__PURE__ */ jsxs4("div", { className: "space-y-3", children: [
|
|
26697
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex items-start justify-between gap-3", children: [
|
|
26698
|
-
/* @__PURE__ */ jsxs4("div", { className: "min-w-0", children: [
|
|
26699
|
-
/* @__PURE__ */ jsx7("div", { className: "text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--muted-foreground))]", children: normalizedName === "Write" ? "\u5199\u5165\u6587\u4EF6" : "\u7F16\u8F91\u6587\u4EF6" }),
|
|
26700
|
-
/* @__PURE__ */ jsx7("div", { className: "truncate font-mono text-[11px] text-[hsl(var(--foreground))]", children: fileName })
|
|
26701
|
-
] }),
|
|
26702
|
-
checksum ? /* @__PURE__ */ jsx7("span", { className: "rounded-full border border-[hsl(var(--border))] bg-[hsl(var(--muted))] px-2 py-0.5 font-mono text-[10px] text-[hsl(var(--muted-foreground))]", children: checksum }) : null
|
|
26703
|
-
] }),
|
|
26704
|
-
description ? /* @__PURE__ */ jsx7("div", { className: "rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/35 px-3 py-2 text-[11px] text-[hsl(var(--muted-foreground))]", children: description }) : null,
|
|
26705
|
-
displayErrorMessage ? /* @__PURE__ */ jsx7("div", { className: "rounded-lg border border-[hsl(var(--swf-danger)/0.3)] bg-[hsl(var(--swf-danger-soft))] px-3 py-2 text-[11px] text-[hsl(var(--swf-danger))]", children: displayErrorMessage }) : null,
|
|
26706
|
-
/* @__PURE__ */ jsxs4("div", { className: "file-edit-preview overflow-hidden rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/20", children: [
|
|
26707
|
-
/* @__PURE__ */ jsx7("div", { className: "border-b border-[hsl(var(--border))] px-3 py-2 text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--muted-foreground))]", children: normalizedName === "Write" ? "\u5185\u5BB9\u9884\u89C8" : "\u53D8\u66F4\u9884\u89C8" }),
|
|
26708
|
-
/* @__PURE__ */ jsx7(
|
|
26709
|
-
"pre",
|
|
26710
|
-
{
|
|
26711
|
-
ref: previewRef,
|
|
26712
|
-
className: "max-h-[320px] overflow-auto p-0 font-mono text-[11px] leading-5",
|
|
26713
|
-
children: diffLines.length > 0 ? diffLines.map((line, index) => {
|
|
26714
|
-
const prefix = line.type === "added" ? "+ " : line.type === "removed" ? "- " : " ";
|
|
26715
|
-
return /* @__PURE__ */ jsxs4(
|
|
26716
|
-
"div",
|
|
26717
|
-
{
|
|
26718
|
-
className: cn(
|
|
26719
|
-
"grid grid-cols-[2.25rem_minmax(0,1fr)] gap-0 px-2",
|
|
26720
|
-
line.type === "added" && "bg-[hsl(var(--swf-success-soft))] text-[hsl(var(--swf-success))]",
|
|
26721
|
-
line.type === "removed" && "bg-[hsl(var(--swf-danger-soft))] text-[hsl(var(--swf-danger))]",
|
|
26722
|
-
line.type === "unchanged" && "text-[hsl(var(--foreground))]"
|
|
26723
|
-
),
|
|
26724
|
-
children: [
|
|
26725
|
-
/* @__PURE__ */ jsx7("span", { className: "select-none py-0.5 text-right text-[10px] text-[hsl(var(--muted-foreground))]", children: line.line ?? "" }),
|
|
26726
|
-
/* @__PURE__ */ jsxs4("span", { className: "min-w-0 whitespace-pre-wrap break-words py-0.5", children: [
|
|
26727
|
-
prefix,
|
|
26728
|
-
line.value
|
|
26729
|
-
] })
|
|
26730
|
-
]
|
|
26731
|
-
},
|
|
26732
|
-
`${line.type}-${line.line}-${index}`
|
|
26733
|
-
);
|
|
26734
|
-
}) : /* @__PURE__ */ jsx7("div", { className: "px-3 py-4 text-[11px] text-[hsl(var(--muted-foreground))]", children: "\u672A\u68C0\u6D4B\u5230\u53EF\u9884\u89C8\u7684\u53D8\u66F4\u3002" })
|
|
26735
|
-
}
|
|
26736
|
-
)
|
|
26737
|
-
] }),
|
|
26738
|
-
displaySummaryText ? /* @__PURE__ */ jsx7("div", { className: "rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/35 px-3 py-2 text-[11px] text-[hsl(var(--muted-foreground))]", children: displaySummaryText }) : null
|
|
26739
|
-
] });
|
|
26740
|
-
}
|
|
26741
|
-
|
|
26742
|
-
// src/chat/ImageLightbox.tsx
|
|
26743
|
-
import { useCallback, useEffect as useEffect5, useRef as useRef5, useState as useState5 } from "react";
|
|
26744
|
-
import { Fragment, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
26745
|
-
function ImageLightbox({ open: open2, onOpenChange, images, initialIndex = 0 }) {
|
|
26746
|
-
const [currentIndex, setCurrentIndex] = useState5(initialIndex);
|
|
26747
|
-
const [scale, setScale] = useState5(1);
|
|
26748
|
-
const [translate, setTranslate] = useState5({ x: 0, y: 0 });
|
|
26749
|
-
const dragging = useRef5(false);
|
|
26750
|
-
const dragStart = useRef5({ x: 0, y: 0 });
|
|
26751
|
-
const translateStart = useRef5({ x: 0, y: 0 });
|
|
26752
|
-
const imgRef = useRef5(null);
|
|
26753
|
-
const [loadedSource, setLoadedSource] = useState5(null);
|
|
26754
|
-
const reset = useCallback(() => {
|
|
26755
|
-
setScale(1);
|
|
26756
|
-
setTranslate({ x: 0, y: 0 });
|
|
26757
|
-
}, []);
|
|
26758
|
-
const close = useCallback(() => {
|
|
26759
|
-
reset();
|
|
26760
|
-
onOpenChange(false);
|
|
26761
|
-
}, [onOpenChange, reset]);
|
|
26762
|
-
const zoomIn = useCallback(() => setScale((s) => Math.min(s + 0.5, 5)), []);
|
|
26763
|
-
const zoomOut = useCallback(() => setScale((s) => Math.max(s - 0.5, 0.5)), []);
|
|
26764
|
-
const goPrev = useCallback(() => {
|
|
26765
|
-
setLoadedSource(null);
|
|
26766
|
-
setCurrentIndex((i2) => Math.max(0, i2 - 1));
|
|
26767
|
-
reset();
|
|
26768
|
-
}, [reset]);
|
|
26769
|
-
const goNext = useCallback(() => {
|
|
26770
|
-
setLoadedSource(null);
|
|
26771
|
-
setCurrentIndex((i2) => Math.min(images.length - 1, i2 + 1));
|
|
26772
|
-
reset();
|
|
26773
|
-
}, [images.length, reset]);
|
|
26774
|
-
const prevOpenRef = useRef5(false);
|
|
26775
|
-
useEffect5(() => {
|
|
26776
|
-
if (open2 && !prevOpenRef.current) {
|
|
26777
|
-
setLoadedSource(null);
|
|
26778
|
-
setCurrentIndex(initialIndex);
|
|
26779
|
-
reset();
|
|
26780
|
-
}
|
|
26781
|
-
prevOpenRef.current = open2;
|
|
26782
|
-
}, [open2, initialIndex, reset]);
|
|
26783
|
-
const handleWheel = useCallback((e) => {
|
|
26784
|
-
e.preventDefault();
|
|
26785
|
-
setScale((s) => {
|
|
26786
|
-
const delta = e.deltaY > 0 ? -0.2 : 0.2;
|
|
26787
|
-
return Math.min(Math.max(s + delta, 0.5), 5);
|
|
26788
|
-
});
|
|
26789
|
-
}, []);
|
|
26790
|
-
const handleMouseDown = useCallback(
|
|
26791
|
-
(e) => {
|
|
26792
|
-
if (scale <= 1) return;
|
|
26793
|
-
e.preventDefault();
|
|
26794
|
-
dragging.current = true;
|
|
26795
|
-
dragStart.current = { x: e.clientX, y: e.clientY };
|
|
26796
|
-
translateStart.current = { ...translate };
|
|
26797
|
-
},
|
|
26798
|
-
[scale, translate]
|
|
26799
|
-
);
|
|
26800
|
-
const handleMouseMove = useCallback((e) => {
|
|
26801
|
-
if (!dragging.current) return;
|
|
26802
|
-
setTranslate({
|
|
26803
|
-
x: translateStart.current.x + e.clientX - dragStart.current.x,
|
|
26804
|
-
y: translateStart.current.y + e.clientY - dragStart.current.y
|
|
26805
|
-
});
|
|
26806
|
-
}, []);
|
|
26807
|
-
const handleMouseUp = useCallback(() => {
|
|
26808
|
-
dragging.current = false;
|
|
26809
|
-
}, []);
|
|
26810
|
-
const handleDoubleClick = useCallback(() => {
|
|
26811
|
-
reset();
|
|
26812
|
-
}, [reset]);
|
|
26813
|
-
const handleAreaClick = useCallback(
|
|
26814
|
-
(e) => {
|
|
26815
|
-
if (imgRef.current && !imgRef.current.contains(e.target)) {
|
|
26816
|
-
close();
|
|
26817
|
-
}
|
|
26818
|
-
},
|
|
26819
|
-
[close]
|
|
26820
|
-
);
|
|
26821
|
-
const handleDownload = useCallback(() => {
|
|
26822
|
-
const img = images[currentIndex] ?? images[0];
|
|
26823
|
-
const source = imgRef.current?.getAttribute("src");
|
|
26824
|
-
if (!img || !source) return;
|
|
26825
|
-
const a = document.createElement("a");
|
|
26826
|
-
a.href = source;
|
|
26827
|
-
a.download = img.alt || "image.png";
|
|
26828
|
-
a.click();
|
|
26829
|
-
}, [images, currentIndex]);
|
|
26830
|
-
const handleOpenInNewTab = useCallback(() => {
|
|
26831
|
-
const source = imgRef.current?.getAttribute("src");
|
|
26832
|
-
if (source) window.open(source, "_blank", "noopener,noreferrer");
|
|
26833
|
-
}, []);
|
|
26834
|
-
if (!open2) return null;
|
|
26835
|
-
if (images.length === 0) {
|
|
26836
|
-
return /* @__PURE__ */ jsxs5(
|
|
26837
|
-
LightboxDialog,
|
|
26838
|
-
{
|
|
26839
|
-
onClose: close,
|
|
26840
|
-
className: "fixed inset-0 z-50 flex animate-in items-center justify-center bg-black/80 fade-in-0 duration-(--motion-duration-fast)",
|
|
26841
|
-
onClick: close,
|
|
26842
|
-
children: [
|
|
26843
|
-
/* @__PURE__ */ jsx8(
|
|
26844
|
-
"button",
|
|
26845
|
-
{
|
|
26846
|
-
type: "button",
|
|
26847
|
-
onClick: close,
|
|
26848
|
-
"aria-label": "\u5173\u95ED\u56FE\u7247\u9884\u89C8",
|
|
26849
|
-
className: "absolute right-4 top-4 z-10 rounded-full bg-black/50 p-2 text-white/80 transition-colors hover:bg-black/70 hover:text-white",
|
|
26850
|
-
children: /* @__PURE__ */ jsx8(X, { size: 20 })
|
|
26851
|
-
}
|
|
26852
|
-
),
|
|
26853
|
-
/* @__PURE__ */ jsx8("span", { className: "text-sm text-white/60", children: "\u52A0\u8F7D\u4E2D..." })
|
|
26854
|
-
]
|
|
26855
|
-
}
|
|
26856
|
-
);
|
|
26857
|
-
}
|
|
26858
|
-
const current = images[currentIndex] ?? images[0];
|
|
26859
|
-
const showNav = images.length > 1;
|
|
26860
|
-
return /* @__PURE__ */ jsxs5(
|
|
26861
|
-
LightboxDialog,
|
|
26862
|
-
{
|
|
26863
|
-
onClose: close,
|
|
26864
|
-
onKeyDown: (event) => {
|
|
26865
|
-
if (images.length > 1) {
|
|
26866
|
-
if (event.key === "ArrowLeft") goPrev();
|
|
26867
|
-
if (event.key === "ArrowRight") goNext();
|
|
26868
|
-
}
|
|
26869
|
-
},
|
|
26870
|
-
className: "fixed inset-0 z-50 animate-in bg-black/80 fade-in-0 duration-(--motion-duration-fast)",
|
|
26871
|
-
onClick: handleAreaClick,
|
|
26872
|
-
children: [
|
|
26873
|
-
/* @__PURE__ */ jsxs5(
|
|
26874
|
-
"div",
|
|
26875
|
-
{
|
|
26876
|
-
className: "absolute right-4 top-4 z-10 flex items-center gap-1.5",
|
|
26877
|
-
onClick: (e) => e.stopPropagation(),
|
|
26878
|
-
children: [
|
|
26879
|
-
/* @__PURE__ */ jsx8(
|
|
26880
|
-
"button",
|
|
26881
|
-
{
|
|
26882
|
-
type: "button",
|
|
26883
|
-
onClick: handleDownload,
|
|
26884
|
-
disabled: loadedSource !== current.src,
|
|
26885
|
-
title: loadedSource === current.src ? "\u4E0B\u8F7D\u56FE\u7247" : "\u539F\u56FE\u52A0\u8F7D\u4E2D",
|
|
26886
|
-
className: "rounded-full bg-black/50 p-2 text-white/80 transition-colors hover:bg-black/70 hover:text-white",
|
|
26887
|
-
children: /* @__PURE__ */ jsx8(Download, { size: 18 })
|
|
26888
|
-
}
|
|
26889
|
-
),
|
|
26890
|
-
/* @__PURE__ */ jsx8(
|
|
26891
|
-
"button",
|
|
26892
|
-
{
|
|
26893
|
-
type: "button",
|
|
26894
|
-
onClick: handleOpenInNewTab,
|
|
26895
|
-
disabled: loadedSource !== current.src,
|
|
26896
|
-
title: loadedSource === current.src ? "\u65B0\u6807\u7B7E\u9875\u6253\u5F00" : "\u539F\u56FE\u52A0\u8F7D\u4E2D",
|
|
26897
|
-
className: "rounded-full bg-black/50 p-2 text-white/80 transition-colors hover:bg-black/70 hover:text-white",
|
|
26898
|
-
children: /* @__PURE__ */ jsx8(ExternalLink, { size: 18 })
|
|
26899
|
-
}
|
|
26900
|
-
),
|
|
26901
|
-
/* @__PURE__ */ jsx8(
|
|
26902
|
-
"button",
|
|
26903
|
-
{
|
|
26904
|
-
type: "button",
|
|
26905
|
-
onClick: close,
|
|
26906
|
-
"aria-label": "\u5173\u95ED\u56FE\u7247\u9884\u89C8",
|
|
26907
|
-
className: "rounded-full bg-black/50 p-2 text-white/80 transition-colors hover:bg-black/70 hover:text-white",
|
|
26908
|
-
children: /* @__PURE__ */ jsx8(X, { size: 20 })
|
|
26909
|
-
}
|
|
26910
|
-
)
|
|
26911
|
-
]
|
|
26912
|
-
}
|
|
26913
|
-
),
|
|
26914
|
-
showNav && currentIndex > 0 && /* @__PURE__ */ jsx8(
|
|
26915
|
-
"button",
|
|
26916
|
-
{
|
|
26917
|
-
type: "button",
|
|
26918
|
-
onClick: (e) => {
|
|
26919
|
-
e.stopPropagation();
|
|
26920
|
-
goPrev();
|
|
26921
|
-
},
|
|
26922
|
-
className: "absolute left-4 top-1/2 z-10 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white/80 transition-colors hover:bg-black/70 hover:text-white",
|
|
26923
|
-
children: /* @__PURE__ */ jsx8(ChevronLeft, { size: 24 })
|
|
26924
|
-
}
|
|
26925
|
-
),
|
|
26926
|
-
showNav && currentIndex < images.length - 1 && /* @__PURE__ */ jsx8(
|
|
26927
|
-
"button",
|
|
26928
|
-
{
|
|
26929
|
-
type: "button",
|
|
26930
|
-
onClick: (e) => {
|
|
26931
|
-
e.stopPropagation();
|
|
26932
|
-
goNext();
|
|
26933
|
-
},
|
|
26934
|
-
className: "absolute right-4 top-1/2 z-10 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white/80 transition-colors hover:bg-black/70 hover:text-white",
|
|
26935
|
-
children: /* @__PURE__ */ jsx8(ChevronRight, { size: 24 })
|
|
26936
|
-
}
|
|
26937
|
-
),
|
|
26938
|
-
/* @__PURE__ */ jsxs5("div", { className: "absolute bottom-6 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1 rounded-full bg-black/50 px-2 py-1", onClick: (event) => event.stopPropagation(), children: [
|
|
26939
|
-
/* @__PURE__ */ jsx8(
|
|
26940
|
-
"button",
|
|
26941
|
-
{
|
|
26942
|
-
type: "button",
|
|
26943
|
-
onClick: zoomOut,
|
|
26944
|
-
"aria-label": "\u7F29\u5C0F\u56FE\u7247",
|
|
26945
|
-
className: "rounded-full p-1.5 text-white/80 transition-colors hover:bg-white/10 hover:text-white",
|
|
26946
|
-
children: /* @__PURE__ */ jsx8(Minus, { size: 16 })
|
|
26947
|
-
}
|
|
26948
|
-
),
|
|
26949
|
-
/* @__PURE__ */ jsxs5("span", { className: "min-w-[3rem] text-center text-xs text-white/80", children: [
|
|
26950
|
-
Math.round(scale * 100),
|
|
26951
|
-
"%"
|
|
26952
|
-
] }),
|
|
26953
|
-
/* @__PURE__ */ jsx8(
|
|
26954
|
-
"button",
|
|
26955
|
-
{
|
|
26956
|
-
type: "button",
|
|
26957
|
-
onClick: zoomIn,
|
|
26958
|
-
"aria-label": "\u653E\u5927\u56FE\u7247",
|
|
26959
|
-
className: "rounded-full p-1.5 text-white/80 transition-colors hover:bg-white/10 hover:text-white",
|
|
26960
|
-
children: /* @__PURE__ */ jsx8(Plus, { size: 16 })
|
|
26961
|
-
}
|
|
26962
|
-
),
|
|
26963
|
-
/* @__PURE__ */ jsx8(
|
|
26964
|
-
"button",
|
|
26965
|
-
{
|
|
26966
|
-
type: "button",
|
|
26967
|
-
onClick: reset,
|
|
26968
|
-
"aria-label": "\u6062\u590D\u56FE\u7247\u5927\u5C0F",
|
|
26969
|
-
className: "rounded-full p-1.5 text-white/80 transition-colors hover:bg-white/10 hover:text-white",
|
|
26970
|
-
children: /* @__PURE__ */ jsx8(RotateCcw, { size: 16 })
|
|
26971
|
-
}
|
|
26972
|
-
),
|
|
26973
|
-
showNav && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
26974
|
-
/* @__PURE__ */ jsx8("div", { className: "mx-1 h-4 w-px bg-white/20" }),
|
|
26975
|
-
/* @__PURE__ */ jsxs5("span", { className: "min-w-[3rem] text-center text-xs text-white/80", children: [
|
|
26976
|
-
currentIndex + 1,
|
|
26977
|
-
" / ",
|
|
26978
|
-
images.length
|
|
26979
|
-
] })
|
|
26980
|
-
] })
|
|
26981
|
-
] }),
|
|
26982
|
-
/* @__PURE__ */ jsx8(
|
|
26983
|
-
"div",
|
|
26984
|
-
{
|
|
26985
|
-
className: "flex h-full w-full items-center justify-center overflow-hidden p-12",
|
|
26986
|
-
style: { cursor: scale > 1 ? "grab" : "default" },
|
|
26987
|
-
onWheel: handleWheel,
|
|
26988
|
-
onMouseDown: handleMouseDown,
|
|
26989
|
-
onMouseMove: handleMouseMove,
|
|
26990
|
-
onMouseUp: handleMouseUp,
|
|
26991
|
-
onMouseLeave: handleMouseUp,
|
|
26992
|
-
onDoubleClick: handleDoubleClick,
|
|
26993
|
-
children: /* @__PURE__ */ jsx8(
|
|
26994
|
-
MessageImage,
|
|
26995
|
-
{
|
|
26996
|
-
original: true,
|
|
26997
|
-
ref: imgRef,
|
|
26998
|
-
src: current.src,
|
|
26999
|
-
onLoad: () => setLoadedSource(current.src),
|
|
27000
|
-
alt: current.alt,
|
|
27001
|
-
draggable: false,
|
|
27002
|
-
className: "max-h-full max-w-full select-none object-contain",
|
|
27003
|
-
style: {
|
|
27004
|
-
transform: `scale(${scale}) translate(${translate.x / scale}px, ${translate.y / scale}px)`,
|
|
27005
|
-
transition: dragging.current ? "none" : "transform 0.2s ease"
|
|
27006
|
-
}
|
|
27007
|
-
}
|
|
27008
|
-
)
|
|
27009
|
-
}
|
|
27010
|
-
)
|
|
27011
|
-
]
|
|
27012
|
-
}
|
|
27013
|
-
);
|
|
27014
|
-
}
|
|
27015
|
-
function LightboxDialog({ children, className, onClose, onClick, onKeyDown }) {
|
|
27016
|
-
const [opener] = useState5(() => document.activeElement);
|
|
27017
|
-
return /* @__PURE__ */ jsx8(dist_exports.Root, { open: true, onOpenChange: (open2) => {
|
|
27018
|
-
if (!open2) onClose();
|
|
27019
|
-
}, children: /* @__PURE__ */ jsxs5(dist_exports.Portal, { children: [
|
|
27020
|
-
/* @__PURE__ */ jsx8(dist_exports.Overlay, { className: "fixed inset-0 z-50" }),
|
|
27021
|
-
/* @__PURE__ */ jsxs5(
|
|
27022
|
-
dist_exports.Content,
|
|
27023
|
-
{
|
|
27024
|
-
className,
|
|
27025
|
-
"aria-describedby": void 0,
|
|
27026
|
-
onClick,
|
|
27027
|
-
onKeyDown,
|
|
27028
|
-
onCloseAutoFocus: (event) => {
|
|
27029
|
-
event.preventDefault();
|
|
27030
|
-
if (opener?.isConnected) opener.focus({ preventScroll: true });
|
|
27031
|
-
},
|
|
27032
|
-
children: [
|
|
27033
|
-
/* @__PURE__ */ jsx8(dist_exports.Title, { className: "sr-only", children: "\u56FE\u7247\u9884\u89C8" }),
|
|
27034
|
-
children
|
|
27035
|
-
]
|
|
27036
|
-
}
|
|
27037
|
-
)
|
|
27038
|
-
] }) });
|
|
27039
|
-
}
|
|
27040
|
-
|
|
27041
|
-
// src/chat/tool-renderers/FileReadRenderer.tsx
|
|
27042
|
-
import { useState as useState6 } from "react";
|
|
27043
|
-
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
27044
|
-
var NUMBERED_LINE_RE = /^(\s*\d+)\t([\s\S]*)$/;
|
|
27045
|
-
function parseReadResult(result) {
|
|
27046
|
-
if (!result) {
|
|
27047
|
-
return {
|
|
27048
|
-
checksum: null,
|
|
27049
|
-
content: "",
|
|
27050
|
-
endLine: null,
|
|
27051
|
-
note: null,
|
|
27052
|
-
startLine: null
|
|
27053
|
-
};
|
|
27054
|
-
}
|
|
27055
|
-
let body = result.trimEnd();
|
|
27056
|
-
const checksumMatch = body.match(/\n\n\[checksum:\s*([^\]]+)\]\s*$/);
|
|
27057
|
-
const checksum = checksumMatch?.[1]?.trim() ?? null;
|
|
27058
|
-
if (checksumMatch?.index !== void 0) {
|
|
27059
|
-
body = body.slice(0, checksumMatch.index).trimEnd();
|
|
27060
|
-
}
|
|
27061
|
-
const noteMatch = body.match(/\n\n(文件共[\s\S]*?)\s*$/);
|
|
27062
|
-
const note = noteMatch?.[0]?.trim() ?? null;
|
|
27063
|
-
if (noteMatch?.index !== void 0) {
|
|
27064
|
-
body = body.slice(0, noteMatch.index).trimEnd();
|
|
27065
|
-
}
|
|
27066
|
-
const numberedLines = body.split("\n").map((line) => {
|
|
27067
|
-
const match = line.match(NUMBERED_LINE_RE);
|
|
27068
|
-
if (!match) return null;
|
|
27069
|
-
return {
|
|
27070
|
-
number: Number(match[1].trim()),
|
|
27071
|
-
text: match[2]
|
|
27072
|
-
};
|
|
27073
|
-
}).filter((line) => Boolean(line));
|
|
27074
|
-
return {
|
|
27075
|
-
checksum,
|
|
27076
|
-
content: numberedLines.length > 0 ? numberedLines.map((line) => line.text).join("\n") : body,
|
|
27077
|
-
endLine: numberedLines.length > 0 ? numberedLines[numberedLines.length - 1].number : null,
|
|
27078
|
-
note,
|
|
27079
|
-
startLine: numberedLines.length > 0 ? numberedLines[0].number : null
|
|
27080
|
-
};
|
|
27081
|
-
}
|
|
27082
|
-
function formatLineRange(startLine, endLine) {
|
|
27083
|
-
if (startLine === null || endLine === null) return null;
|
|
27084
|
-
return startLine === endLine ? `\u7B2C ${startLine} \u884C` : `\u7B2C ${startLine}-${endLine} \u884C`;
|
|
27085
|
-
}
|
|
27086
|
-
function FileReadRenderer({ toolCall }) {
|
|
27087
|
-
const [lightboxIndex, setLightboxIndex] = useState6(null);
|
|
27088
|
-
const argsValue = parseJsonValue(toolCall.arguments);
|
|
27089
|
-
const args = isPlainObject3(argsValue) ? argsValue : null;
|
|
27090
|
-
const filePath = extractToolFilePath(toolCall);
|
|
27091
|
-
const fileName = getFileName(filePath);
|
|
27092
|
-
const displayName = filePath ? formatToolFileName(filePath) : fileName;
|
|
27093
|
-
const description = getStringValue(args, "description");
|
|
27094
|
-
const resultText = getResultText(toolCall.result);
|
|
27095
|
-
const images = getResultImages(toolCall.result);
|
|
27096
|
-
const imageUrls = images.map((image) => image.url);
|
|
27097
|
-
const isImageResult = imageUrls.length > 0;
|
|
27098
|
-
const errorMessage = extractErrorMessage(resultText);
|
|
27099
|
-
const { checksum, content, note, startLine, endLine } = parseReadResult(resultText);
|
|
27100
|
-
const fallbackStart = getNumberValue(args, "offset") ?? 1;
|
|
27101
|
-
const lineCount = content ? content.split("\n").length : 0;
|
|
27102
|
-
const resolvedStartLine = startLine ?? (lineCount > 0 ? fallbackStart : null);
|
|
27103
|
-
const resolvedEndLine = endLine ?? (resolvedStartLine !== null && lineCount > 0 ? resolvedStartLine + lineCount - 1 : null);
|
|
27104
|
-
const lineRange = formatLineRange(resolvedStartLine, resolvedEndLine);
|
|
27105
|
-
return /* @__PURE__ */ jsxs6("div", { className: "space-y-3", children: [
|
|
27106
|
-
/* @__PURE__ */ jsxs6("div", { className: "flex items-start justify-between gap-3", children: [
|
|
27107
|
-
/* @__PURE__ */ jsxs6("div", { className: "min-w-0", children: [
|
|
27108
|
-
/* @__PURE__ */ jsx9("div", { className: "truncate font-mono text-[11px] text-[hsl(var(--foreground))]", children: displayName }),
|
|
27109
|
-
filePath ? /* @__PURE__ */ jsx9("div", { className: "truncate text-[10px] text-[hsl(var(--muted-foreground))]", children: filePath }) : null
|
|
27110
|
-
] }),
|
|
27111
|
-
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center justify-end gap-1.5", children: [
|
|
27112
|
-
lineRange ? /* @__PURE__ */ jsx9("span", { className: "rounded-full border border-[hsl(var(--border))] bg-[hsl(var(--muted))] px-2 py-0.5 text-[10px] text-[hsl(var(--muted-foreground))]", children: lineRange }) : null,
|
|
27113
|
-
checksum ? /* @__PURE__ */ jsx9("span", { className: "rounded-full border border-[hsl(var(--border))] bg-[hsl(var(--muted))] px-2 py-0.5 font-mono text-[10px] text-[hsl(var(--muted-foreground))]", children: checksum }) : null
|
|
27114
|
-
] })
|
|
27115
|
-
] }),
|
|
27116
|
-
description ? /* @__PURE__ */ jsx9("div", { className: "rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/35 px-3 py-2 text-[11px] text-[hsl(var(--muted-foreground))]", children: description }) : null,
|
|
27117
|
-
errorMessage ? /* @__PURE__ */ jsx9("div", { className: "rounded-lg border border-[hsl(var(--swf-danger)/0.3)] bg-[hsl(var(--swf-danger-soft))] px-3 py-2 text-[11px] text-[hsl(var(--swf-danger))]", children: errorMessage }) : null,
|
|
27118
|
-
isImageResult ? /* @__PURE__ */ jsxs6("div", { className: "grid gap-2", children: [
|
|
27119
|
-
imageUrls.map((url2, idx) => /* @__PURE__ */ jsx9(
|
|
27120
|
-
"button",
|
|
27121
|
-
{
|
|
27122
|
-
type: "button",
|
|
27123
|
-
onClick: () => setLightboxIndex(idx),
|
|
27124
|
-
className: "cursor-zoom-in",
|
|
27125
|
-
title: "\u67E5\u770B\u5927\u56FE",
|
|
27126
|
-
children: /* @__PURE__ */ jsx9(
|
|
27127
|
-
MessageImage,
|
|
27128
|
-
{
|
|
27129
|
-
src: url2,
|
|
27130
|
-
width: images[idx].width,
|
|
27131
|
-
height: images[idx].height,
|
|
27132
|
-
alt: fileName,
|
|
27133
|
-
className: "max-h-64 rounded-lg border border-[hsl(var(--border))] object-contain"
|
|
27134
|
-
}
|
|
27135
|
-
)
|
|
27136
|
-
},
|
|
27137
|
-
url2.slice(0, 64)
|
|
27138
|
-
)),
|
|
27139
|
-
/* @__PURE__ */ jsx9(
|
|
27140
|
-
ImageLightbox,
|
|
27141
|
-
{
|
|
27142
|
-
open: lightboxIndex != null,
|
|
27143
|
-
onOpenChange: (open2) => {
|
|
27144
|
-
if (!open2) setLightboxIndex(null);
|
|
27145
|
-
},
|
|
27146
|
-
images: imageUrls.map((url2) => ({ src: url2, alt: fileName })),
|
|
27147
|
-
initialIndex: lightboxIndex ?? 0
|
|
27148
|
-
}
|
|
27149
|
-
),
|
|
27150
|
-
content ? /* @__PURE__ */ jsx9("div", { className: "text-[11px] text-[hsl(var(--muted-foreground))]", children: content }) : null
|
|
27151
|
-
] }) : !errorMessage ? /* @__PURE__ */ jsx9(CodePreview, { content, filePath, className: "max-h-[360px]" }) : null,
|
|
27152
|
-
note ? /* @__PURE__ */ jsx9("div", { className: "rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/35 px-3 py-2 text-[11px] text-[hsl(var(--muted-foreground))]", children: note }) : null
|
|
27153
|
-
] });
|
|
27154
|
-
}
|
|
27155
|
-
|
|
27156
|
-
// src/chat/tool-renderers/SearchRenderer.tsx
|
|
27157
|
-
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
27158
|
-
function toRecordArray(value) {
|
|
27159
|
-
return Array.isArray(value) ? value.filter(isPlainObject3) : [];
|
|
27160
|
-
}
|
|
27161
|
-
function parseDirectoryItems(result) {
|
|
27162
|
-
const value = parseJsonValue(result);
|
|
27163
|
-
if (!Array.isArray(value)) {
|
|
27164
|
-
return [];
|
|
27165
|
-
}
|
|
27166
|
-
return value.map((item) => {
|
|
27167
|
-
if (typeof item === "string") {
|
|
27168
|
-
return {
|
|
27169
|
-
isDir: item.endsWith("/"),
|
|
27170
|
-
name: item,
|
|
27171
|
-
size: null
|
|
27172
|
-
};
|
|
27173
|
-
}
|
|
27174
|
-
if (!isPlainObject3(item)) {
|
|
27175
|
-
return null;
|
|
27176
|
-
}
|
|
27177
|
-
return {
|
|
27178
|
-
isDir: item.is_dir === true,
|
|
27179
|
-
name: typeof item.name === "string" ? item.name : "\u672A\u547D\u540D",
|
|
27180
|
-
size: typeof item.size === "number" ? item.size : null
|
|
27181
|
-
};
|
|
27182
|
-
}).filter((item) => Boolean(item));
|
|
27183
|
-
}
|
|
27184
|
-
function parseGrepResult(result) {
|
|
27185
|
-
if (!result?.trim()) {
|
|
27186
|
-
return { matches: [], searchPath: null };
|
|
27187
|
-
}
|
|
27188
|
-
const [header, ...rest] = result.split("\n");
|
|
27189
|
-
const searchPath = header.startsWith("\u641C\u7D22\u8DEF\u5F84:") ? header.replace("\u641C\u7D22\u8DEF\u5F84:", "").trim() : null;
|
|
27190
|
-
const matches = toRecordArray(parseJsonValue(rest.join("\n"))).map((item) => ({
|
|
27191
|
-
line: typeof item.line === "string" ? item.line : "",
|
|
27192
|
-
lineNumber: typeof item.line_number === "number" ? item.line_number : null,
|
|
27193
|
-
path: typeof item.path === "string" ? item.path : "\u672A\u77E5\u8DEF\u5F84"
|
|
27194
|
-
}));
|
|
27195
|
-
return { matches, searchPath };
|
|
27196
|
-
}
|
|
27197
|
-
function parseWebResults(result) {
|
|
27198
|
-
const value = parseJsonValue(result);
|
|
27199
|
-
const items = isPlainObject3(value) ? toRecordArray(value.results) : toRecordArray(value);
|
|
27200
|
-
return items.map((item) => ({
|
|
27201
|
-
description: typeof item.text === "string" ? item.text : typeof item.description === "string" ? item.description : null,
|
|
27202
|
-
publishedDate: typeof item.published_date === "string" ? item.published_date : null,
|
|
27203
|
-
title: typeof item.title === "string" ? item.title : null,
|
|
27204
|
-
url: typeof item.url === "string" ? item.url : null
|
|
27205
|
-
}));
|
|
27206
|
-
}
|
|
27207
|
-
function renderEmptyState(label) {
|
|
27208
|
-
return /* @__PURE__ */ jsx10("div", { className: "rounded-lg border border-dashed border-[hsl(var(--border))] bg-[hsl(var(--muted))]/20 px-3 py-4 text-[11px] text-[hsl(var(--muted-foreground))]", children: label });
|
|
27209
|
-
}
|
|
27210
|
-
function SearchRenderer({ toolCall }) {
|
|
27211
|
-
const normalizedName = formatToolName(toolCall.name);
|
|
27212
|
-
const argsValue = parseJsonValue(toolCall.arguments);
|
|
27213
|
-
const args = isPlainObject3(argsValue) ? argsValue : null;
|
|
27214
|
-
const resultStr = getResultText(toolCall.result);
|
|
27215
|
-
const errorMessage = extractErrorMessage(resultStr);
|
|
27216
|
-
if (errorMessage) {
|
|
27217
|
-
return /* @__PURE__ */ jsx10("div", { className: "rounded-lg border border-[hsl(var(--swf-danger)/0.3)] bg-[hsl(var(--swf-danger-soft))] px-3 py-2 text-[11px] text-[hsl(var(--swf-danger))]", children: errorMessage });
|
|
27218
|
-
}
|
|
27219
|
-
if (normalizedName === "Ls" || normalizedName === "Glob") {
|
|
27220
|
-
const items = parseDirectoryItems(resultStr);
|
|
27221
|
-
const path = getStringValue(args, "path");
|
|
27222
|
-
return /* @__PURE__ */ jsxs7("div", { className: "space-y-3", children: [
|
|
27223
|
-
path ? /* @__PURE__ */ jsxs7("div", { className: "text-[11px] text-[hsl(var(--muted-foreground))]", children: [
|
|
27224
|
-
"\u76EE\u5F55\uFF1A",
|
|
27225
|
-
path
|
|
27226
|
-
] }) : null,
|
|
27227
|
-
items.length > 0 ? /* @__PURE__ */ jsx10("div", { className: "grid gap-2", children: items.map((item) => /* @__PURE__ */ jsxs7(
|
|
27228
|
-
"div",
|
|
27229
|
-
{
|
|
27230
|
-
className: "flex items-center justify-between gap-3 rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/20 px-3 py-2",
|
|
27231
|
-
children: [
|
|
27232
|
-
/* @__PURE__ */ jsxs7("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
27233
|
-
item.isDir ? /* @__PURE__ */ jsx10(Folder, { size: 14, className: "shrink-0 text-[hsl(var(--muted-foreground))]" }) : /* @__PURE__ */ jsx10(FileText, { size: 14, className: "shrink-0 text-[hsl(var(--muted-foreground))]" }),
|
|
27234
|
-
/* @__PURE__ */ jsx10("span", { className: "truncate font-mono text-[11px] text-[hsl(var(--foreground))]", children: item.name })
|
|
27235
|
-
] }),
|
|
27236
|
-
/* @__PURE__ */ jsx10("span", { className: "shrink-0 text-[10px] text-[hsl(var(--muted-foreground))]", children: item.isDir ? "\u76EE\u5F55" : formatBytes(item.size) ?? "\u6587\u4EF6" })
|
|
27237
|
-
]
|
|
27238
|
-
},
|
|
27239
|
-
`${item.name}-${item.size}-${item.isDir}`
|
|
27240
|
-
)) }) : renderEmptyState("\u6CA1\u6709\u53EF\u5C55\u793A\u7684\u6587\u4EF6\u7ED3\u679C\u3002")
|
|
27241
|
-
] });
|
|
27242
|
-
}
|
|
27243
|
-
if (normalizedName === "Grep") {
|
|
27244
|
-
const { matches, searchPath } = parseGrepResult(resultStr);
|
|
27245
|
-
const pattern = getStringValue(args, "pattern");
|
|
27246
|
-
return /* @__PURE__ */ jsxs7("div", { className: "space-y-3", children: [
|
|
27247
|
-
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-2 text-[11px] text-[hsl(var(--muted-foreground))]", children: [
|
|
27248
|
-
pattern ? /* @__PURE__ */ jsx10("span", { className: "rounded-full bg-[hsl(var(--muted))] px-2 py-0.5 font-mono", children: pattern }) : null,
|
|
27249
|
-
searchPath ? /* @__PURE__ */ jsxs7("span", { children: [
|
|
27250
|
-
"\u8303\u56F4\uFF1A",
|
|
27251
|
-
searchPath
|
|
27252
|
-
] }) : null
|
|
27253
|
-
] }),
|
|
27254
|
-
matches.length > 0 ? /* @__PURE__ */ jsx10("div", { className: "grid gap-2", children: matches.map((match) => /* @__PURE__ */ jsxs7(
|
|
27255
|
-
"div",
|
|
27256
|
-
{
|
|
27257
|
-
className: "rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/20 px-3 py-2",
|
|
27258
|
-
children: [
|
|
27259
|
-
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between gap-3", children: [
|
|
27260
|
-
/* @__PURE__ */ jsx10("span", { className: "truncate font-mono text-[11px] text-[hsl(var(--foreground))]", children: match.path }),
|
|
27261
|
-
match.lineNumber !== null ? /* @__PURE__ */ jsxs7("span", { className: "shrink-0 text-[10px] text-[hsl(var(--muted-foreground))]", children: [
|
|
27262
|
-
"\u7B2C ",
|
|
27263
|
-
match.lineNumber,
|
|
27264
|
-
" \u884C"
|
|
27265
|
-
] }) : null
|
|
27266
|
-
] }),
|
|
27267
|
-
/* @__PURE__ */ jsx10("pre", { className: "mt-2 overflow-x-auto whitespace-pre-wrap font-mono text-[11px] text-[hsl(var(--muted-foreground))]", children: /* @__PURE__ */ jsx10("code", { children: match.line }) })
|
|
27268
|
-
]
|
|
27269
|
-
},
|
|
27270
|
-
`${match.path}-${match.lineNumber}-${match.line}`
|
|
27271
|
-
)) }) : renderEmptyState("\u6CA1\u6709\u627E\u5230\u5339\u914D\u7ED3\u679C\u3002")
|
|
27272
|
-
] });
|
|
27273
|
-
}
|
|
27274
|
-
if (normalizedName === "WebFetch") {
|
|
27275
|
-
const url2 = getStringValue(args, "url");
|
|
27276
|
-
const text = resultStr?.trim();
|
|
27277
|
-
return /* @__PURE__ */ jsxs7("div", { className: "space-y-3", children: [
|
|
27278
|
-
url2 ? /* @__PURE__ */ jsxs7(
|
|
27279
|
-
"a",
|
|
27280
|
-
{
|
|
27281
|
-
href: url2,
|
|
27282
|
-
target: "_blank",
|
|
27283
|
-
rel: "noreferrer",
|
|
27284
|
-
className: "flex items-center gap-2 truncate font-mono text-[10px] text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))]",
|
|
27285
|
-
children: [
|
|
27286
|
-
/* @__PURE__ */ jsx10(Earth, { size: 12, className: "shrink-0" }),
|
|
27287
|
-
/* @__PURE__ */ jsx10("span", { className: "truncate", children: url2 }),
|
|
27288
|
-
/* @__PURE__ */ jsx10(ExternalLink, { size: 11, className: "shrink-0" })
|
|
27289
|
-
]
|
|
27290
|
-
}
|
|
27291
|
-
) : null,
|
|
27292
|
-
text ? /* @__PURE__ */ jsx10("div", { className: "max-h-80 overflow-y-auto rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/20 px-3 py-3", children: /* @__PURE__ */ jsx10("p", { className: "whitespace-pre-wrap text-[11px] leading-5 text-[hsl(var(--foreground))]", children: text }) }) : renderEmptyState("\u8FD9\u4E2A\u7F51\u9875\u6CA1\u6709\u53EF\u5C55\u793A\u7684\u6B63\u6587\u3002")
|
|
27293
|
-
] });
|
|
27294
|
-
}
|
|
27295
|
-
const results = parseWebResults(resultStr);
|
|
27296
|
-
const query = getStringValue(args, "query");
|
|
27297
|
-
return /* @__PURE__ */ jsxs7("div", { className: "space-y-3", children: [
|
|
27298
|
-
query ? /* @__PURE__ */ jsxs7("div", { className: "text-[11px] text-[hsl(var(--muted-foreground))]", children: [
|
|
27299
|
-
"\u67E5\u8BE2\uFF1A",
|
|
27300
|
-
query
|
|
27301
|
-
] }) : null,
|
|
27302
|
-
results.length > 0 ? /* @__PURE__ */ jsx10("div", { className: "grid gap-2", children: results.map((item, index) => /* @__PURE__ */ jsx10(
|
|
27303
|
-
"a",
|
|
27304
|
-
{
|
|
27305
|
-
href: item.url ?? void 0,
|
|
27306
|
-
target: "_blank",
|
|
27307
|
-
rel: "noreferrer",
|
|
27308
|
-
className: cn(
|
|
27309
|
-
"rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--muted))]/20 px-3 py-3 transition-colors",
|
|
27310
|
-
item.url && "hover:border-[hsl(var(--ring))] hover:bg-[hsl(var(--muted))]/35"
|
|
27311
|
-
),
|
|
27312
|
-
children: /* @__PURE__ */ jsxs7("div", { className: "flex items-start gap-3", children: [
|
|
27313
|
-
/* @__PURE__ */ jsx10(Earth, { size: 16, className: "mt-0.5 shrink-0 text-[hsl(var(--muted-foreground))]" }),
|
|
27314
|
-
/* @__PURE__ */ jsxs7("div", { className: "min-w-0 flex-1", children: [
|
|
27315
|
-
/* @__PURE__ */ jsxs7("div", { className: "flex items-start justify-between gap-3", children: [
|
|
27316
|
-
/* @__PURE__ */ jsx10("span", { className: "line-clamp-2 text-[11px] font-medium text-[hsl(var(--foreground))]", children: item.title ?? item.url ?? "\u672A\u547D\u540D\u7ED3\u679C" }),
|
|
27317
|
-
item.url ? /* @__PURE__ */ jsx10(
|
|
27318
|
-
ExternalLink,
|
|
27319
|
-
{
|
|
27320
|
-
size: 12,
|
|
27321
|
-
className: "mt-0.5 shrink-0 text-[hsl(var(--muted-foreground))]"
|
|
27322
|
-
}
|
|
27323
|
-
) : null
|
|
27324
|
-
] }),
|
|
27325
|
-
item.url ? /* @__PURE__ */ jsx10("div", { className: "mt-1 truncate font-mono text-[10px] text-[hsl(var(--muted-foreground))]", children: item.url }) : null,
|
|
27326
|
-
item.publishedDate ? /* @__PURE__ */ jsxs7("div", { className: "mt-1 text-[10px] text-[hsl(var(--muted-foreground))]", children: [
|
|
27327
|
-
"\u53D1\u5E03\u4E8E ",
|
|
27328
|
-
item.publishedDate.slice(0, 10)
|
|
27329
|
-
] }) : null,
|
|
27330
|
-
item.description ? /* @__PURE__ */ jsx10("p", { className: "mt-2 line-clamp-3 text-[11px] leading-5 text-[hsl(var(--muted-foreground))]", children: item.description }) : null
|
|
27331
|
-
] })
|
|
27332
|
-
] })
|
|
27333
|
-
},
|
|
27334
|
-
`${item.url ?? item.title ?? "result"}-${index}`
|
|
27335
|
-
)) }) : renderEmptyState("\u6CA1\u6709\u53EF\u5C55\u793A\u7684\u641C\u7D22\u7ED3\u679C\u3002")
|
|
27336
|
-
] });
|
|
27337
|
-
}
|
|
27338
|
-
|
|
27339
|
-
// src/chat/tool-renderers/SubmitResultRenderer.tsx
|
|
27340
|
-
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
27341
|
-
function extractText(value, key) {
|
|
27342
|
-
if (!isPlainObject3(value)) return null;
|
|
27343
|
-
const field = value[key];
|
|
27344
|
-
return typeof field === "string" && field.trim() ? field.trim() : null;
|
|
27345
|
-
}
|
|
27346
|
-
function parsePayload(toolCall) {
|
|
27347
|
-
const resultText = getResultText(toolCall.result);
|
|
27348
|
-
const parsedResult = parseJsonValue(resultText);
|
|
27349
|
-
const parsedArgs = parseJsonValue(toolCall.arguments);
|
|
27350
|
-
const description = extractText(parsedArgs, "description") ?? extractText(parsedResult, "description");
|
|
27351
|
-
const result = extractText(parsedArgs, "result") ?? extractText(parsedResult, "result") ?? (!isPlainObject3(parsedResult) ? resultText?.trim() ?? null : null);
|
|
27352
|
-
const error62 = extractText(parsedArgs, "err_msg") ?? extractText(parsedResult, "err_msg") ?? extractText(parsedResult, "error");
|
|
27353
|
-
const rawStatus = extractText(parsedResult, "status");
|
|
27354
|
-
const status = rawStatus === "submitted" ? null : rawStatus;
|
|
27355
|
-
return { description, result, error: error62, status };
|
|
27356
|
-
}
|
|
27357
|
-
function SubmitResultRenderer({ toolCall }) {
|
|
27358
|
-
const { description, result, error: error62, status } = parsePayload(toolCall);
|
|
27359
|
-
const isError = toolCall.status === "error" || Boolean(error62);
|
|
27360
|
-
const Icon = isError ? CircleAlert : CircleCheck;
|
|
27361
|
-
return /* @__PURE__ */ jsxs8("div", { className: "overflow-hidden rounded-2xl border border-[hsl(var(--border))] bg-[hsl(var(--card))]", children: [
|
|
27362
|
-
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-3 border-b border-[hsl(var(--border))] bg-[hsl(var(--muted))]/25 px-4 py-3", children: [
|
|
27363
|
-
/* @__PURE__ */ jsx11("div", { className: isError ? "text-[hsl(var(--swf-danger))]" : "text-[hsl(var(--swf-success))]", children: /* @__PURE__ */ jsx11(Icon, { size: 18 }) }),
|
|
27364
|
-
/* @__PURE__ */ jsxs8("div", { className: "min-w-0 flex-1", children: [
|
|
27365
|
-
/* @__PURE__ */ jsx11("div", { className: "font-medium text-[hsl(var(--foreground))]", children: description || (isError ? "\u4EFB\u52A1\u672A\u5B8C\u6210" : "\u4EFB\u52A1\u7ED3\u679C\u5DF2\u63D0\u4EA4") }),
|
|
27366
|
-
description ? /* @__PURE__ */ jsx11("div", { className: "mt-0.5 text-xs text-[hsl(var(--muted-foreground))]", children: isError ? "\u4EFB\u52A1\u672A\u5B8C\u6210" : "\u4EFB\u52A1\u7ED3\u679C\u5DF2\u63D0\u4EA4" }) : null,
|
|
27367
|
-
status ? /* @__PURE__ */ jsxs8("div", { className: "mt-0.5 text-xs text-[hsl(var(--muted-foreground))]", children: [
|
|
27368
|
-
"\u72B6\u6001\uFF1A",
|
|
27369
|
-
status
|
|
27370
|
-
] }) : null
|
|
27371
|
-
] })
|
|
27372
|
-
] }),
|
|
27373
|
-
/* @__PURE__ */ jsxs8("div", { className: "space-y-3 px-4 py-4 text-sm leading-6 text-[hsl(var(--foreground))]", children: [
|
|
27374
|
-
result ? /* @__PURE__ */ jsx11(MarkdownContent, { mode: "static", children: result }) : null,
|
|
27375
|
-
error62 ? /* @__PURE__ */ jsxs8("div", { className: "rounded-xl border border-[hsl(var(--swf-danger)/0.3)] bg-[hsl(var(--swf-danger-soft))] px-3 py-2 text-sm text-[hsl(var(--swf-danger))]", children: [
|
|
27376
|
-
/* @__PURE__ */ jsx11("div", { className: "mb-1 font-medium", children: "\u672A\u5B8C\u6210\u539F\u56E0" }),
|
|
27377
|
-
/* @__PURE__ */ jsx11("div", { className: "whitespace-pre-wrap", children: error62 })
|
|
27378
|
-
] }) : null,
|
|
27379
|
-
!result && !error62 ? /* @__PURE__ */ jsx11("p", { className: "text-[hsl(var(--muted-foreground))]", children: "\u667A\u80FD\u4F53\u5DF2\u7ED3\u675F\u672C\u8F6E\u4EFB\u52A1\u3002" }) : null
|
|
27380
|
-
] })
|
|
27381
|
-
] });
|
|
27382
|
-
}
|
|
27383
|
-
|
|
27384
|
-
// src/chat/tool-renderers/registry.ts
|
|
27385
|
-
var RENDERERS = /* @__PURE__ */ new Map([
|
|
27386
|
-
["Bash", BashRenderer],
|
|
27387
|
-
["BgBash", BashRenderer],
|
|
27388
|
-
["Edit", FileEditRenderer],
|
|
27389
|
-
["MultiEdit", FileEditRenderer],
|
|
27390
|
-
["Grep", SearchRenderer],
|
|
27391
|
-
["Glob", SearchRenderer],
|
|
27392
|
-
["Ls", SearchRenderer],
|
|
27393
|
-
["Read", FileReadRenderer],
|
|
27394
|
-
["WebFetch", SearchRenderer],
|
|
27395
|
-
["WebSearch", SearchRenderer],
|
|
27396
|
-
["Write", FileEditRenderer],
|
|
27397
|
-
["submit_result", SubmitResultRenderer]
|
|
27398
|
-
]);
|
|
27399
|
-
function getRenderer(toolName) {
|
|
27400
|
-
return RENDERERS.get(formatToolName(toolName)) ?? null;
|
|
27401
|
-
}
|
|
27402
|
-
|
|
27403
25901
|
export {
|
|
27404
|
-
McpAppFrame
|
|
27405
|
-
McpAppMessageContext,
|
|
27406
|
-
McpAppCard,
|
|
27407
|
-
MessageImage,
|
|
27408
|
-
ToolUiCardView,
|
|
27409
|
-
SUPPORTED_LANGUAGES,
|
|
27410
|
-
normalizeCodeLanguage,
|
|
27411
|
-
getCodeLanguageFromFilename,
|
|
27412
|
-
getResultText,
|
|
27413
|
-
getResultImages,
|
|
27414
|
-
parseJsonValue,
|
|
27415
|
-
isPlainObject3 as isPlainObject,
|
|
27416
|
-
getStringValue,
|
|
27417
|
-
getNumberValue,
|
|
27418
|
-
getBooleanValue,
|
|
27419
|
-
extractErrorMessage,
|
|
27420
|
-
getFileName,
|
|
27421
|
-
getCodeLanguage,
|
|
27422
|
-
formatBytes,
|
|
27423
|
-
CodePreview,
|
|
27424
|
-
BashRenderer,
|
|
27425
|
-
shouldFollowWritePreview,
|
|
27426
|
-
scrollWritePreviewToLatest,
|
|
27427
|
-
FileEditRenderer,
|
|
27428
|
-
ImageLightbox,
|
|
27429
|
-
FileReadRenderer,
|
|
27430
|
-
SearchRenderer,
|
|
27431
|
-
SubmitResultRenderer,
|
|
27432
|
-
getRenderer
|
|
25902
|
+
McpAppFrame
|
|
27433
25903
|
};
|
|
27434
25904
|
/*! Bundled license information:
|
|
27435
25905
|
|
|
@@ -27440,4 +25910,4 @@ export {
|
|
|
27440
25910
|
* MIT Licensed
|
|
27441
25911
|
*)
|
|
27442
25912
|
*/
|
|
27443
|
-
//# sourceMappingURL=chunk-
|
|
25913
|
+
//# sourceMappingURL=chunk-IOIKCFRO.js.map
|