@blade-hq/agent-kit 1.0.21 → 1.0.23

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  apiFetchResponse,
3
3
  getAuthedUrl
4
- } from "./chunk-YVAP7QQ7.js";
4
+ } from "./chunk-IMMRWXI7.js";
5
5
 
6
6
  // src/react/lib/session-file-preview.ts
7
7
  var IMAGE_EXTS = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "svg", "webp", "ico", "bmp"]);
@@ -117,4 +117,4 @@ export {
117
117
  resolveTextPreviewType,
118
118
  resolveSessionFilePreviewTarget
119
119
  };
120
- //# sourceMappingURL=chunk-MPGRAWLS.js.map
120
+ //# sourceMappingURL=chunk-2QYV43YP.js.map
@@ -5,12 +5,12 @@ import {
5
5
  import {
6
6
  getSessionFilePath,
7
7
  resolveSessionFilePreviewTarget
8
- } from "./chunk-MPGRAWLS.js";
8
+ } from "./chunk-2QYV43YP.js";
9
9
  import {
10
10
  formatToolName,
11
11
  getAuthedUrl,
12
12
  useUiStore
13
- } from "./chunk-YVAP7QQ7.js";
13
+ } from "./chunk-IMMRWXI7.js";
14
14
  import {
15
15
  cn,
16
16
  copyToClipboard
@@ -1937,4 +1937,4 @@ export {
1937
1937
  PlanSummaryCard,
1938
1938
  extractLatestPlanMessages
1939
1939
  };
1940
- //# sourceMappingURL=chunk-O4TRZMGD.js.map
1940
+ //# sourceMappingURL=chunk-BQKF6HJH.js.map
@@ -8,7 +8,7 @@ import {
8
8
  getCodeLanguageFromFilename,
9
9
  parseAskUserQuestion,
10
10
  useHighlightedCodeHtml
11
- } from "./chunk-O4TRZMGD.js";
11
+ } from "./chunk-BQKF6HJH.js";
12
12
  import {
13
13
  Collapsible,
14
14
  CollapsibleContent,
@@ -16,7 +16,7 @@ import {
16
16
  } from "./chunk-H62LH2AG.js";
17
17
  import {
18
18
  resolveSessionFilePreviewTarget
19
- } from "./chunk-MPGRAWLS.js";
19
+ } from "./chunk-2QYV43YP.js";
20
20
  import {
21
21
  apiFetchResponse,
22
22
  buildMessageContent,
@@ -60,7 +60,7 @@ import {
60
60
  useUiBridgeStore,
61
61
  useUiStore,
62
62
  writeFile
63
- } from "./chunk-YVAP7QQ7.js";
63
+ } from "./chunk-IMMRWXI7.js";
64
64
  import {
65
65
  registerBridgeIframe,
66
66
  tapBridgeEvent
@@ -4025,7 +4025,7 @@ function ConnectionBanner() {
4025
4025
  import { ChevronDown as ChevronDown3, Lightbulb as Lightbulb2, MessageSquare } from "lucide-react";
4026
4026
  import {
4027
4027
  useCallback as useCallback12,
4028
- useEffect as useEffect17,
4028
+ useEffect as useEffect18,
4029
4029
  useEffectEvent as useEffectEvent4,
4030
4030
  useMemo as useMemo18,
4031
4031
  useRef as useRef13,
@@ -4458,7 +4458,7 @@ function useStickToBottomContext() {
4458
4458
 
4459
4459
  // src/react/components/chat/AssistantTurnBlock.tsx
4460
4460
  import { AlertCircle, BookOpen, Check as Check5, ChevronRight as ChevronRight5 } from "lucide-react";
4461
- import { memo as memo3, useCallback as useCallback11, useEffect as useEffect15, useMemo as useMemo16, useRef as useRef12, useState as useState18 } from "react";
4461
+ import { memo as memo3, useCallback as useCallback11, useEffect as useEffect16, useMemo as useMemo16, useRef as useRef12, useState as useState18 } from "react";
4462
4462
 
4463
4463
  // src/react/routes.ts
4464
4464
  var MEMORIES_ROUTE = "/memories";
@@ -4740,7 +4740,7 @@ ReasoningContent.displayName = "ReasoningContent";
4740
4740
 
4741
4741
  // src/react/components/chat/AgentLoopBlock.tsx
4742
4742
  import { Bot, Check as Check4, ChevronRight as ChevronRight4, FileText as FileText6, Loader2 as Loader25, MessageSquareMore as MessageSquareMore2 } from "lucide-react";
4743
- import { useEffect as useEffect14, useMemo as useMemo15, useState as useState17 } from "react";
4743
+ import { useEffect as useEffect15, useMemo as useMemo15, useState as useState17 } from "react";
4744
4744
 
4745
4745
  // src/react/components/chat/ResourceIframe.tsx
4746
4746
  import { useEffect as useEffect10, useEffectEvent as useEffectEvent3, useRef as useRef9, useState as useState11 } from "react";
@@ -4887,7 +4887,7 @@ ${html}`;
4887
4887
 
4888
4888
  // src/react/components/chat/ToolCallBlock.tsx
4889
4889
  import { Check as Check2, ChevronRight as ChevronRight3, Loader2 as Loader23, MessageSquareMore, PanelRightOpen, X as X4 } from "lucide-react";
4890
- import { useMemo as useMemo13, useState as useState14 } from "react";
4890
+ import { useEffect as useEffect12, useMemo as useMemo13, useState as useState14 } from "react";
4891
4891
 
4892
4892
  // src/react/components/chat/tool-renderers/shared.tsx
4893
4893
  import { jsx as jsx15 } from "react/jsx-runtime";
@@ -5060,6 +5060,7 @@ function BashRenderer({ toolCall }) {
5060
5060
  // src/react/components/chat/tool-renderers/FileEditRenderer.tsx
5061
5061
  import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
5062
5062
  var MAX_DIFF_LINES = 200;
5063
+ var FILE_PATH_FIELDS = ["file_path", "path"];
5063
5064
  function computeDiff(oldText, newText) {
5064
5065
  const oldLines = oldText.split("\n");
5065
5066
  const newLines = newText.split("\n");
@@ -5135,7 +5136,7 @@ function buildWritePreview(content) {
5135
5136
  newLine: index + 1
5136
5137
  }));
5137
5138
  }
5138
- function buildEditPreview(args) {
5139
+ function buildEditPreview(args, rawArguments) {
5139
5140
  const edits = Array.isArray(args?.edits) ? args.edits : null;
5140
5141
  if (edits) {
5141
5142
  return edits.flatMap((rawEdit, index) => {
@@ -5153,24 +5154,115 @@ function buildEditPreview(args) {
5153
5154
  }
5154
5155
  const oldString = getStringValue(args, "old_string") ?? "";
5155
5156
  const newString = getStringValue(args, "new_string") ?? "";
5157
+ if (!oldString && !newString && !args) {
5158
+ return buildPartialEditPreview(rawArguments);
5159
+ }
5156
5160
  return computeDiff(oldString, newString);
5157
5161
  }
5162
+ function buildPartialEditPreview(rawArguments) {
5163
+ const oldValues = extractAllJsonStringFieldPartials(rawArguments, "old_text");
5164
+ const newValues = extractAllJsonStringFieldPartials(rawArguments, "new_text");
5165
+ if (!oldValues.length && !newValues.length) return [];
5166
+ const rows = [];
5167
+ for (let index = 0; index < Math.max(oldValues.length, newValues.length); index += 1) {
5168
+ if (index > 0) {
5169
+ rows.push({ type: "unchanged", value: "", oldLine: null, newLine: null });
5170
+ }
5171
+ const oldText = oldValues[index] ?? "";
5172
+ const newText = newValues[index] ?? "";
5173
+ rows.push(...computeDiff(oldText, newText));
5174
+ }
5175
+ return rows;
5176
+ }
5158
5177
  function extractChecksum(result) {
5159
5178
  const text = typeof result === "string" ? result : null;
5160
5179
  const match = text?.match(/\[checksum:\s*([^\]]+)\]/);
5161
5180
  return match?.[1]?.trim() ?? null;
5162
5181
  }
5182
+ function getRawStringValue(data, key) {
5183
+ const value = data?.[key];
5184
+ return typeof value === "string" ? value : null;
5185
+ }
5186
+ function extractJsonStringFieldPartial(raw, names) {
5187
+ for (const name of names) {
5188
+ const values = extractAllJsonStringFieldPartials(raw, name);
5189
+ if (values.length > 0) return values[values.length - 1] ?? "";
5190
+ }
5191
+ return "";
5192
+ }
5193
+ function extractAllJsonStringFieldPartials(raw, name) {
5194
+ return extractAllJsonStringFields(raw, name, false);
5195
+ }
5196
+ function extractAllJsonStringFields(raw, name, requireClosed) {
5197
+ const marker = `"${name}"`;
5198
+ const values = [];
5199
+ let searchFrom = 0;
5200
+ while (true) {
5201
+ const markerIndex = raw.indexOf(marker, searchFrom);
5202
+ if (markerIndex < 0) return values;
5203
+ const colonIndex = raw.indexOf(":", markerIndex + marker.length);
5204
+ if (colonIndex < 0) return values;
5205
+ const quoteIndex = raw.indexOf('"', colonIndex + 1);
5206
+ if (quoteIndex < 0) return values;
5207
+ const { value, closed } = readJsonString(raw, quoteIndex + 1);
5208
+ if (closed || !requireClosed) {
5209
+ values.push(value);
5210
+ }
5211
+ searchFrom = quoteIndex + 1;
5212
+ }
5213
+ }
5214
+ function readJsonString(raw, start) {
5215
+ const chars = [];
5216
+ let index = start;
5217
+ while (index < raw.length) {
5218
+ const char = raw[index];
5219
+ if (char === '"') {
5220
+ return { value: chars.join(""), closed: true };
5221
+ }
5222
+ if (char !== "\\") {
5223
+ chars.push(char);
5224
+ index += 1;
5225
+ continue;
5226
+ }
5227
+ if (index + 1 >= raw.length) {
5228
+ return { value: chars.join(""), closed: false };
5229
+ }
5230
+ const escaped = raw[index + 1];
5231
+ if (escaped === "n") {
5232
+ chars.push("\n");
5233
+ } else if (escaped === "r") {
5234
+ chars.push("\r");
5235
+ } else if (escaped === "t") {
5236
+ chars.push(" ");
5237
+ } else if (escaped === '"' || escaped === "\\" || escaped === "/") {
5238
+ chars.push(escaped);
5239
+ } else if (escaped === "u" && index + 5 < raw.length) {
5240
+ const code = raw.slice(index + 2, index + 6);
5241
+ const parsed = Number.parseInt(code, 16);
5242
+ if (Number.isFinite(parsed)) {
5243
+ chars.push(String.fromCharCode(parsed));
5244
+ }
5245
+ index += 4;
5246
+ } else {
5247
+ chars.push(escaped ?? "");
5248
+ }
5249
+ index += 2;
5250
+ }
5251
+ return { value: chars.join(""), closed: false };
5252
+ }
5163
5253
  function FileEditRenderer({ toolCall }) {
5254
+ const rawArguments = toolCall.arguments ?? "";
5164
5255
  const argsValue = parseJsonValue(toolCall.arguments);
5165
5256
  const args = isPlainObject(argsValue) ? argsValue : null;
5166
5257
  const normalizedName = formatToolName(toolCall.name);
5167
- const filePath = extractToolFilePath(toolCall);
5258
+ const partialFilePath = extractJsonStringFieldPartial(rawArguments, FILE_PATH_FIELDS);
5259
+ const filePath = extractToolFilePath(toolCall) ?? partialFilePath;
5168
5260
  const fileName = getFileName(filePath);
5169
5261
  const errorMessage = extractErrorMessage(toolCall.result);
5170
5262
  const checksum = extractChecksum(toolCall.result);
5171
- const description = getStringValue(args, "description");
5172
- const writeContent = getStringValue(args, "content") ?? "";
5173
- const diffLines = normalizedName === "Write" ? buildWritePreview(writeContent) : buildEditPreview(args);
5263
+ const description = getStringValue(args, "description") ?? extractJsonStringFieldPartial(rawArguments, ["description"]);
5264
+ const writeContent = getRawStringValue(args, "content") ?? extractJsonStringFieldPartial(rawArguments, ["content"]);
5265
+ const diffLines = normalizedName === "Write" ? buildWritePreview(writeContent) : buildEditPreview(args, rawArguments);
5174
5266
  const resultStr = typeof toolCall.result === "string" ? toolCall.result : null;
5175
5267
  const summaryText = resultStr?.trim() && !errorMessage ? resultStr.trim() : null;
5176
5268
  return /* @__PURE__ */ jsxs13("div", { className: "space-y-3", children: [
@@ -5870,6 +5962,9 @@ function FilePathLink({ filePath, sessionId }) {
5870
5962
  }
5871
5963
  );
5872
5964
  }
5965
+ function isLivePreviewTool(toolName) {
5966
+ return toolName === "Write" || toolName === "Edit" || toolName === "MultiEdit";
5967
+ }
5873
5968
  function ToolCallBlock({
5874
5969
  toolCall,
5875
5970
  onAnswer,
@@ -5882,7 +5977,9 @@ function ToolCallBlock({
5882
5977
  reasoning,
5883
5978
  customization
5884
5979
  }) {
5885
- const [expanded, setExpanded] = useState14(false);
5980
+ const normalizedName = formatToolName(toolCall.name);
5981
+ const shouldAutoExpandWhileStreaming = toolCall.status === "pending" && isLivePreviewTool(normalizedName);
5982
+ const [expanded, setExpanded] = useState14(shouldAutoExpandWhileStreaming);
5886
5983
  const activeSessionId = useSessionStore((s) => s.activeSessionId);
5887
5984
  const sessions = useSessionStore((s) => s.sessions);
5888
5985
  const pushArtifact = useUiStore((s) => s.pushArtifact);
@@ -5893,7 +5990,11 @@ function ToolCallBlock({
5893
5990
  const answerCallback = useAnswerCallbackStore(
5894
5991
  (s) => resolvedSessionId ? s.callbacks[resolvedSessionId] : void 0
5895
5992
  );
5896
- const normalizedName = formatToolName(toolCall.name);
5993
+ useEffect12(() => {
5994
+ if (shouldAutoExpandWhileStreaming) {
5995
+ setExpanded(true);
5996
+ }
5997
+ }, [shouldAutoExpandWhileStreaming]);
5897
5998
  const resolvedSessionStatus = sessionStatus ?? sessions.find((session) => session.id === resolvedSessionId)?.status;
5898
5999
  const resolvedAnswerData = answerData ?? storedAnswerData;
5899
6000
  const resolvedAnswered = answered ?? (!!resolvedAnswerData && resolvedSessionStatus !== "waiting_for_input");
@@ -6050,7 +6151,7 @@ function buildAskUserPayload(argumentsJson) {
6050
6151
  // src/react/components/chat/UserMessageBubble.tsx
6051
6152
  import { useQueries } from "@tanstack/react-query";
6052
6153
  import { Loader2 as Loader24 } from "lucide-react";
6053
- import { useEffect as useEffect13, useRef as useRef11, useState as useState16 } from "react";
6154
+ import { useEffect as useEffect14, useRef as useRef11, useState as useState16 } from "react";
6054
6155
 
6055
6156
  // src/react/lib/preview-dispatch.ts
6056
6157
  var IMAGE_EXTS = [
@@ -6192,12 +6293,12 @@ function parseWhatIfPrompt(text) {
6192
6293
 
6193
6294
  // src/react/components/chat/AttachmentPreviewDialog.tsx
6194
6295
  import { Download as Download3, X as X5 } from "lucide-react";
6195
- import { useEffect as useEffect12 } from "react";
6296
+ import { useEffect as useEffect13 } from "react";
6196
6297
  import { createPortal as createPortal4 } from "react-dom";
6197
6298
  import { useQuery as useQuery6 } from "@tanstack/react-query";
6198
6299
  import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
6199
6300
  function AttachmentPreviewDialog({ open, onOpenChange, filename, url, mode }) {
6200
- useEffect12(() => {
6301
+ useEffect13(() => {
6201
6302
  if (!open) return;
6202
6303
  const handleKey = (e) => {
6203
6304
  if (e.key === "Escape") onOpenChange(false);
@@ -6580,7 +6681,7 @@ function UserMessageBubble({ message, className }) {
6580
6681
  if (prev && url && prev !== url) URL.revokeObjectURL(prev);
6581
6682
  if (url) blobUrlMapRef.current.set(key, url);
6582
6683
  }
6583
- useEffect13(() => {
6684
+ useEffect14(() => {
6584
6685
  const urls = blobUrlMapRef.current;
6585
6686
  return () => {
6586
6687
  for (const u of urls.values()) URL.revokeObjectURL(u);
@@ -6821,7 +6922,7 @@ function AgentLoopBlock({ toolCall, sessionId, reasoning }) {
6821
6922
  ),
6822
6923
  [childMessages]
6823
6924
  );
6824
- useEffect14(() => {
6925
+ useEffect15(() => {
6825
6926
  if (hasAwaitingAnswer) {
6826
6927
  setExpanded(true);
6827
6928
  }
@@ -7291,7 +7392,7 @@ function AssistantTurnBlockBase({
7291
7392
  defaultTurnDisplayMode({ forceExpanded, hasActionableToolCall })
7292
7393
  );
7293
7394
  const wasStreamingRef = useRef12(isStreaming);
7294
- useEffect15(() => {
7395
+ useEffect16(() => {
7295
7396
  if (wasStreamingRef.current && !isStreaming && !forceExpanded) {
7296
7397
  setDisplayMode(defaultTurnDisplayMode({ forceExpanded, hasActionableToolCall }));
7297
7398
  }
@@ -7939,7 +8040,7 @@ import {
7939
8040
  TerminalSquare,
7940
8041
  WandSparkles
7941
8042
  } from "lucide-react";
7942
- import { useEffect as useEffect16, useMemo as useMemo17, useState as useState20 } from "react";
8043
+ import { useEffect as useEffect17, useMemo as useMemo17, useState as useState20 } from "react";
7943
8044
  import { jsx as jsx35, jsxs as jsxs30 } from "react/jsx-runtime";
7944
8045
  var EMPTY_EVENTS = [];
7945
8046
  function formatElapsedDuration(durationMs) {
@@ -8019,7 +8120,7 @@ function getTurnStartedAt(events) {
8019
8120
  }
8020
8121
  function useElapsedDuration(startedAt, active) {
8021
8122
  const [now, setNow] = useState20(() => Date.now());
8022
- useEffect16(() => {
8123
+ useEffect17(() => {
8023
8124
  if (!active || startedAt == null) {
8024
8125
  return;
8025
8126
  }
@@ -8372,7 +8473,7 @@ function MessageList({
8372
8473
  measureActiveTurn();
8373
8474
  });
8374
8475
  });
8375
- useEffect17(() => {
8476
+ useEffect18(() => {
8376
8477
  scrollContainerRef.current = stickContextRef.current?.scrollRef.current ?? findScrollContainer(containerRef.current);
8377
8478
  const sc = scrollContainerRef.current;
8378
8479
  if (!sc) return;
@@ -8388,7 +8489,7 @@ function MessageList({
8388
8489
  }
8389
8490
  };
8390
8491
  }, [scheduleMeasure]);
8391
- useEffect17(() => {
8492
+ useEffect18(() => {
8392
8493
  scheduleMeasure();
8393
8494
  }, [lastTurnId, layoutSignature, scheduleMeasure]);
8394
8495
  const handleSelectTurn = useCallback12((turnId) => {
@@ -8777,4 +8878,4 @@ use-stick-to-bottom/dist/StickToBottom.js:
8777
8878
  * Licensed under the MIT License. See License.txt in the project root for license information.
8778
8879
  *--------------------------------------------------------------------------------------------*)
8779
8880
  */
8780
- //# sourceMappingURL=chunk-XEKYDE2R.js.map
8881
+ //# sourceMappingURL=chunk-ICV7OTGX.js.map