@blade-hq/agent-kit 1.0.15 → 1.0.17

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.
@@ -5,12 +5,12 @@ import {
5
5
  import {
6
6
  getSessionFilePath,
7
7
  resolveSessionFilePreviewTarget
8
- } from "./chunk-U4KVB5OB.js";
8
+ } from "./chunk-CDOBBZKQ.js";
9
9
  import {
10
10
  formatToolName,
11
11
  getAuthedUrl,
12
12
  useUiStore
13
- } from "./chunk-QEYZZDLM.js";
13
+ } from "./chunk-5TKSNSAW.js";
14
14
  import {
15
15
  cn,
16
16
  copyToClipboard
@@ -1933,4 +1933,4 @@ export {
1933
1933
  PlanSummaryCard,
1934
1934
  extractLatestPlanMessages
1935
1935
  };
1936
- //# sourceMappingURL=chunk-J3PQU7BQ.js.map
1936
+ //# sourceMappingURL=chunk-2LKBNP7B.js.map
@@ -3389,6 +3389,21 @@ function isGisGoalListPayload(value) {
3389
3389
  function isGisResourceListPayload(value) {
3390
3390
  return isRecord4(value) && Array.isArray(value.resources);
3391
3391
  }
3392
+ function sessionStatusFromChatEnd(status) {
3393
+ if (status === "paused") return "waiting_for_input";
3394
+ if (status === "interrupted") return "interrupted";
3395
+ if (status === "failed") return "failed";
3396
+ return "completed";
3397
+ }
3398
+ function extractTerminalChatEndStatus(events) {
3399
+ for (let i = events.length - 1; i >= 0; i--) {
3400
+ const event = events[i];
3401
+ if (event?.type !== "chat:end") continue;
3402
+ const status = event.payload?.status;
3403
+ return typeof status === "string" ? status : "completed";
3404
+ }
3405
+ return null;
3406
+ }
3392
3407
  function isGisTargetListPayload(value) {
3393
3408
  return isRecord4(value) && Array.isArray(value.targets);
3394
3409
  }
@@ -3552,7 +3567,8 @@ var AgentSocket = class {
3552
3567
  s.on("turn:events", (data) => {
3553
3568
  const sessionId = this._resolveSessionId(data);
3554
3569
  if (!sessionId || !data.events?.length) return;
3555
- if (!useChatStore.getState().isStreaming[sessionId]) {
3570
+ const terminalChatEndStatus = extractTerminalChatEndStatus(data.events);
3571
+ if (!terminalChatEndStatus && !useChatStore.getState().isStreaming[sessionId]) {
3556
3572
  useSessionStore.getState().updateSessionStatus(sessionId, "running");
3557
3573
  useChatStore.getState().setStreaming(sessionId, true);
3558
3574
  }
@@ -3575,6 +3591,16 @@ var AgentSocket = class {
3575
3591
  notifyWorkspaceFilesChanged(sessionId);
3576
3592
  }
3577
3593
  }
3594
+ if (terminalChatEndStatus) {
3595
+ useSessionStore.getState().updateSessionStatus(sessionId, sessionStatusFromChatEnd(terminalChatEndStatus));
3596
+ if (terminalChatEndStatus === "interrupted") {
3597
+ useChatStore.getState().markInterrupted(sessionId);
3598
+ } else if (terminalChatEndStatus === "failed") {
3599
+ useChatStore.getState().markFailed(sessionId);
3600
+ }
3601
+ useChatStore.getState().setStreaming(sessionId, false);
3602
+ invalidateContextStats(sessionId);
3603
+ }
3578
3604
  });
3579
3605
  s.on("chat:start", (data) => {
3580
3606
  const sessionId = this._resolveSessionId(data);
@@ -3588,10 +3614,7 @@ var AgentSocket = class {
3588
3614
  if (sessionId) {
3589
3615
  this._flushPendingTurnPatches(sessionId);
3590
3616
  const status = data?.status ?? "completed";
3591
- useSessionStore.getState().updateSessionStatus(
3592
- sessionId,
3593
- status === "paused" ? "waiting_for_input" : status === "interrupted" ? "interrupted" : status === "failed" ? "failed" : "completed"
3594
- );
3617
+ useSessionStore.getState().updateSessionStatus(sessionId, sessionStatusFromChatEnd(status));
3595
3618
  if (status === "interrupted") {
3596
3619
  useChatStore.getState().markInterrupted(sessionId);
3597
3620
  } else if (status === "failed") {
@@ -4482,4 +4505,4 @@ export {
4482
4505
  bootstrapBladeClient,
4483
4506
  getBootstrappedClient
4484
4507
  };
4485
- //# sourceMappingURL=chunk-QEYZZDLM.js.map
4508
+ //# sourceMappingURL=chunk-5TKSNSAW.js.map