@blade-hq/agent-kit 0.5.5 → 0.5.7
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/dist/{SkillStatusBar-BtvQmvxZ.d.ts → SkillStatusBar-Dlf-_G5d.d.ts} +2 -2
- package/dist/{blade-client-CqWTKQhP.d.ts → blade-client-7VANnJfr.d.ts} +6 -3
- package/dist/{chunk-Q6CSM5DE.js → chunk-ETHPRRT2.js} +11 -4
- package/dist/chunk-ETHPRRT2.js.map +1 -0
- package/dist/{chunk-557R7QZV.js → chunk-GIE2Q2MB.js} +28 -16
- package/dist/chunk-GIE2Q2MB.js.map +1 -0
- package/dist/{chunk-S6EPGDAL.js → chunk-K5EE7X2D.js} +152 -73
- package/dist/chunk-K5EE7X2D.js.map +1 -0
- package/dist/{chunk-NEI66DW6.js → chunk-STCTXRMJ.js} +2 -2
- package/dist/{chunk-HWOVPFWG.js → chunk-UM7G65GH.js} +116 -20
- package/dist/chunk-UM7G65GH.js.map +1 -0
- package/dist/{chunk-3ZEWA2YM.js → chunk-X3S36RR2.js} +2 -2
- package/dist/client/index.d.ts +111 -4
- package/dist/client/index.js +1 -1
- package/dist/react/api/vibe-coding.d.ts +3 -3
- package/dist/react/api/vibe-coding.js +2 -2
- package/dist/react/components/chat/index.d.ts +6 -5
- package/dist/react/components/chat/index.js +5 -5
- package/dist/react/components/plan/index.js +3 -3
- package/dist/react/components/session/index.d.ts +1 -1
- package/dist/react/components/session/index.js +3 -3
- package/dist/react/components/workspace/index.js +3 -3
- package/dist/react/index.d.ts +177 -9
- package/dist/react/index.js +469 -6
- package/dist/react/index.js.map +1 -1
- package/dist/{session-ADRevzHD.d.ts → session-BuaeCsMC.d.ts} +62 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-557R7QZV.js.map +0 -1
- package/dist/chunk-HWOVPFWG.js.map +0 -1
- package/dist/chunk-Q6CSM5DE.js.map +0 -1
- package/dist/chunk-S6EPGDAL.js.map +0 -1
- /package/dist/{chunk-NEI66DW6.js.map → chunk-STCTXRMJ.js.map} +0 -0
- /package/dist/{chunk-3ZEWA2YM.js.map → chunk-X3S36RR2.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useSessionStore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UM7G65GH.js";
|
|
4
4
|
|
|
5
5
|
// src/react/hooks/use-session.ts
|
|
6
6
|
function useSession() {
|
|
@@ -27,4 +27,4 @@ function useSession() {
|
|
|
27
27
|
export {
|
|
28
28
|
useSession
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-STCTXRMJ.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-J3XVFPOV.js";
|
|
4
4
|
import {
|
|
5
5
|
BladeClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ETHPRRT2.js";
|
|
7
7
|
import {
|
|
8
8
|
createClientActions,
|
|
9
9
|
useCardStateStore
|
|
@@ -103,7 +103,8 @@ var useUiBridgeStore = create()((set, get) => ({
|
|
|
103
103
|
{
|
|
104
104
|
id: buildSignalId(),
|
|
105
105
|
label: context.label,
|
|
106
|
-
content: context.content
|
|
106
|
+
content: context.content,
|
|
107
|
+
imageUrl: context.imageUrl
|
|
107
108
|
}
|
|
108
109
|
]
|
|
109
110
|
}
|
|
@@ -612,6 +613,7 @@ __export(sessions_exports, {
|
|
|
612
613
|
listSessionsWithSkillData: () => listSessionsWithSkillData,
|
|
613
614
|
pinSession: () => pinSession,
|
|
614
615
|
previewImport: () => previewImport,
|
|
616
|
+
probeSessionUrl: () => probeSessionUrl,
|
|
615
617
|
renameFile: () => renameFile,
|
|
616
618
|
revokeShare: () => revokeShare,
|
|
617
619
|
rewindSession: () => rewindSession,
|
|
@@ -658,6 +660,7 @@ var deleteSession = (...args) => r3().deleteSession(...args);
|
|
|
658
660
|
var listBackgroundTasks = (...args) => r3().listBackgroundTasks(...args);
|
|
659
661
|
var getBackgroundTask = (...args) => r3().getBackgroundTask(...args);
|
|
660
662
|
var stopBackgroundTask = (...args) => r3().stopBackgroundTask(...args);
|
|
663
|
+
var probeSessionUrl = (...args) => r3().probeSessionUrl(...args);
|
|
661
664
|
var listDir = (...args) => r3().listDir(...args);
|
|
662
665
|
var uploadFiles = (...args) => r3().uploadFiles(...args);
|
|
663
666
|
var deleteFile = (...args) => r3().deleteFile(...args);
|
|
@@ -1235,8 +1238,16 @@ function projectionToMessage(turn) {
|
|
|
1235
1238
|
...turn.memory_refs?.length ? { memory_refs: turn.memory_refs } : {}
|
|
1236
1239
|
};
|
|
1237
1240
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1241
|
+
var messageProjectionCache = /* @__PURE__ */ new WeakMap();
|
|
1242
|
+
function cachedProjectionToMessage(turn) {
|
|
1243
|
+
if (messageProjectionCache.has(turn)) {
|
|
1244
|
+
return messageProjectionCache.get(turn) ?? null;
|
|
1245
|
+
}
|
|
1246
|
+
const message = projectionToMessage(turn);
|
|
1247
|
+
messageProjectionCache.set(turn, message);
|
|
1248
|
+
return message;
|
|
1249
|
+
}
|
|
1250
|
+
function rebuildAgentLoops(turns, messages) {
|
|
1240
1251
|
const childLoopNames = [...new Set(turns.map((turn) => turn.loop_id).filter((name) => name !== "root"))];
|
|
1241
1252
|
if (childLoopNames.length === 0) return {};
|
|
1242
1253
|
const agentToolCalls = messages.filter((message) => message.role === "assistant" && (message.loop_name ?? "root") === "root").flatMap((message) => message.tool_calls ?? []).filter((toolCall) => formatToolName(toolCall.name) === "Agent");
|
|
@@ -1276,7 +1287,8 @@ function applyPlanningSideEffects(sessionId, turns) {
|
|
|
1276
1287
|
}
|
|
1277
1288
|
}
|
|
1278
1289
|
function materialize(turns) {
|
|
1279
|
-
const
|
|
1290
|
+
const projectedMessages = turns.map(cachedProjectionToMessage).filter((message) => message !== null);
|
|
1291
|
+
const messages = projectedMessages.filter((message, index, allMessages) => {
|
|
1280
1292
|
if (!message.blocks?.some((block) => block.type === "ask_user_answer")) return true;
|
|
1281
1293
|
const next = allMessages[index + 1];
|
|
1282
1294
|
return !(next?.role === "user" && next.content === message.content);
|
|
@@ -1286,7 +1298,7 @@ function materialize(turns) {
|
|
|
1286
1298
|
);
|
|
1287
1299
|
return {
|
|
1288
1300
|
messages,
|
|
1289
|
-
agentLoops: rebuildAgentLoops(turns),
|
|
1301
|
+
agentLoops: rebuildAgentLoops(turns, projectedMessages),
|
|
1290
1302
|
activeCompaction: activeCompaction ? {
|
|
1291
1303
|
turn_id: activeCompaction.turn_id,
|
|
1292
1304
|
status: activeCompaction.status,
|
|
@@ -1306,9 +1318,28 @@ function materialize(turns) {
|
|
|
1306
1318
|
};
|
|
1307
1319
|
}
|
|
1308
1320
|
var ERROR_ANCHOR_PREFIX = "error-anchor:";
|
|
1321
|
+
function orderTurns(turns) {
|
|
1322
|
+
for (let index = 1; index < turns.length; index += 1) {
|
|
1323
|
+
if (turns[index - 1].sequence > turns[index].sequence) {
|
|
1324
|
+
return [...turns].sort((left, right) => left.sequence - right.sequence);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
return turns;
|
|
1328
|
+
}
|
|
1329
|
+
function areAgentLoopsEqual(left, right) {
|
|
1330
|
+
if (!left) return Object.keys(right).length === 0;
|
|
1331
|
+
const leftEntries = Object.entries(left);
|
|
1332
|
+
const rightKeys = Object.keys(right);
|
|
1333
|
+
if (leftEntries.length !== rightKeys.length) return false;
|
|
1334
|
+
return leftEntries.every(([key, value]) => {
|
|
1335
|
+
const next = right[key];
|
|
1336
|
+
return next !== void 0 && value.toolCallId === next.toolCallId && value.description === next.description && value.status === next.status;
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1309
1339
|
function updateSessionState(state, sessionId, turns) {
|
|
1310
|
-
const orderedTurns =
|
|
1340
|
+
const orderedTurns = orderTurns(turns);
|
|
1311
1341
|
const { messages, agentLoops, activeCompaction } = materialize(orderedTurns);
|
|
1342
|
+
const stableAgentLoops = areAgentLoopsEqual(state.agentLoops[sessionId], agentLoops) ? state.agentLoops[sessionId] : agentLoops;
|
|
1312
1343
|
applyPlanningSideEffects(sessionId, orderedTurns);
|
|
1313
1344
|
const lastTurnId = orderedTurns[orderedTurns.length - 1]?.turn_id ?? null;
|
|
1314
1345
|
const preservedErrors = lastTurnId ? (state.messages[sessionId] ?? []).filter(
|
|
@@ -1318,7 +1349,7 @@ function updateSessionState(state, sessionId, turns) {
|
|
|
1318
1349
|
return {
|
|
1319
1350
|
turns: { ...state.turns, [sessionId]: orderedTurns },
|
|
1320
1351
|
messages: { ...state.messages, [sessionId]: mergedMessages },
|
|
1321
|
-
agentLoops: { ...state.agentLoops, [sessionId]: agentLoops },
|
|
1352
|
+
agentLoops: { ...state.agentLoops, [sessionId]: stableAgentLoops ?? agentLoops },
|
|
1322
1353
|
activeCompactions: { ...state.activeCompactions, [sessionId]: activeCompaction }
|
|
1323
1354
|
};
|
|
1324
1355
|
}
|
|
@@ -1917,11 +1948,18 @@ var useAuthStore = create6()(
|
|
|
1917
1948
|
loading: false,
|
|
1918
1949
|
error: null,
|
|
1919
1950
|
logout: () => {
|
|
1920
|
-
void logout().catch(() => {
|
|
1921
|
-
});
|
|
1922
|
-
set({ token: null, socketAuthToken: null, user: null, error: null });
|
|
1923
1951
|
agentSocket?.disconnect();
|
|
1924
1952
|
useSessionStore.getState().reset();
|
|
1953
|
+
void logout().then(({ logout_url }) => {
|
|
1954
|
+
set({ token: null, socketAuthToken: null, user: null, error: null });
|
|
1955
|
+
if (logout_url) {
|
|
1956
|
+
const redirect = encodeURIComponent(window.location.origin);
|
|
1957
|
+
const sep = logout_url.includes("?") ? "&" : "?";
|
|
1958
|
+
window.location.href = `${logout_url}${sep}redirect=${redirect}`;
|
|
1959
|
+
}
|
|
1960
|
+
}).catch(() => {
|
|
1961
|
+
set({ token: null, socketAuthToken: null, user: null, error: null });
|
|
1962
|
+
});
|
|
1925
1963
|
},
|
|
1926
1964
|
checkAuth: async () => {
|
|
1927
1965
|
const token = get().token;
|
|
@@ -2347,6 +2385,9 @@ var AgentSocket = class {
|
|
|
2347
2385
|
pendingReplayMessages = /* @__PURE__ */ new Map();
|
|
2348
2386
|
pendingReplayModes = /* @__PURE__ */ new Map();
|
|
2349
2387
|
oomNotifiedKeys = /* @__PURE__ */ new Set();
|
|
2388
|
+
pendingTurnPatches = /* @__PURE__ */ new Map();
|
|
2389
|
+
patchFlushHandle = null;
|
|
2390
|
+
patchFlushCancel = null;
|
|
2350
2391
|
_ensureConnected() {
|
|
2351
2392
|
if (this.socket.connected || this.socket.active) {
|
|
2352
2393
|
return;
|
|
@@ -2360,9 +2401,65 @@ var AgentSocket = class {
|
|
|
2360
2401
|
_resolveSessionId(data) {
|
|
2361
2402
|
return data?.session_id ?? this.subscribedSession;
|
|
2362
2403
|
}
|
|
2404
|
+
_queueTurnPatch(sessionId, patch) {
|
|
2405
|
+
let sessionPatches = this.pendingTurnPatches.get(sessionId);
|
|
2406
|
+
if (!sessionPatches) {
|
|
2407
|
+
sessionPatches = /* @__PURE__ */ new Map();
|
|
2408
|
+
this.pendingTurnPatches.set(sessionId, sessionPatches);
|
|
2409
|
+
}
|
|
2410
|
+
const current = sessionPatches.get(patch.turn_id);
|
|
2411
|
+
if (!current || patch.sequence >= current.sequence) {
|
|
2412
|
+
sessionPatches.set(patch.turn_id, patch);
|
|
2413
|
+
}
|
|
2414
|
+
this._scheduleTurnPatchFlush();
|
|
2415
|
+
}
|
|
2416
|
+
_scheduleTurnPatchFlush() {
|
|
2417
|
+
if (this.patchFlushHandle != null) return;
|
|
2418
|
+
const flush = () => {
|
|
2419
|
+
this.patchFlushHandle = null;
|
|
2420
|
+
this.patchFlushCancel = null;
|
|
2421
|
+
this._flushPendingTurnPatches();
|
|
2422
|
+
};
|
|
2423
|
+
if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
|
|
2424
|
+
const handle2 = window.requestAnimationFrame(flush);
|
|
2425
|
+
this.patchFlushHandle = handle2;
|
|
2426
|
+
this.patchFlushCancel = () => window.cancelAnimationFrame(handle2);
|
|
2427
|
+
return;
|
|
2428
|
+
}
|
|
2429
|
+
const handle = globalThis.setTimeout(flush, 33);
|
|
2430
|
+
this.patchFlushHandle = handle;
|
|
2431
|
+
this.patchFlushCancel = () => globalThis.clearTimeout(handle);
|
|
2432
|
+
}
|
|
2433
|
+
_flushPendingTurnPatches(sessionId) {
|
|
2434
|
+
const sessions = sessionId === void 0 ? [...this.pendingTurnPatches.entries()] : this.pendingTurnPatches.has(sessionId) ? [[sessionId, this.pendingTurnPatches.get(sessionId)]] : [];
|
|
2435
|
+
if (sessionId === void 0) {
|
|
2436
|
+
this.pendingTurnPatches.clear();
|
|
2437
|
+
} else {
|
|
2438
|
+
this.pendingTurnPatches.delete(sessionId);
|
|
2439
|
+
}
|
|
2440
|
+
for (const [targetSessionId, patchesByTurn] of sessions) {
|
|
2441
|
+
const patches = [...patchesByTurn.values()].sort((left, right) => left.sequence - right.sequence);
|
|
2442
|
+
for (const patch of patches) {
|
|
2443
|
+
useChatStore.getState().applyTurnPatch(targetSessionId, patch);
|
|
2444
|
+
const turn = patch.data.turn;
|
|
2445
|
+
if (!turn) continue;
|
|
2446
|
+
const mode = extractModeFromBlocks3(turn.blocks);
|
|
2447
|
+
if (mode === "planning" || mode === "executing") {
|
|
2448
|
+
useSessionStore.getState().setMode(targetSessionId, mode);
|
|
2449
|
+
}
|
|
2450
|
+
this._applyProjectionSideEffects(targetSessionId, turn);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
if (this.pendingTurnPatches.size === 0 && this.patchFlushCancel) {
|
|
2454
|
+
this.patchFlushCancel();
|
|
2455
|
+
this.patchFlushHandle = null;
|
|
2456
|
+
this.patchFlushCancel = null;
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2363
2459
|
_bindStoreHandlers() {
|
|
2364
2460
|
const s = this.socket;
|
|
2365
2461
|
const applyTurn = (sessionId, turn) => {
|
|
2462
|
+
this._flushPendingTurnPatches(sessionId);
|
|
2366
2463
|
useChatStore.getState().upsertTurn(sessionId, turn);
|
|
2367
2464
|
invalidateContextStats(sessionId);
|
|
2368
2465
|
const mode = extractModeFromBlocks3(turn.blocks);
|
|
@@ -2379,17 +2476,10 @@ var AgentSocket = class {
|
|
|
2379
2476
|
s.on("turn:patch", (data) => {
|
|
2380
2477
|
const sessionId = this._resolveSessionId(data);
|
|
2381
2478
|
if (!sessionId) return;
|
|
2382
|
-
useChatStore.getState().applyTurnPatch(sessionId, data);
|
|
2383
2479
|
if (data.data.workspace_changed) {
|
|
2384
2480
|
notifyWorkspaceFilesChanged(sessionId);
|
|
2385
2481
|
}
|
|
2386
|
-
|
|
2387
|
-
if (!turn) return;
|
|
2388
|
-
const mode = extractModeFromBlocks3(turn.blocks);
|
|
2389
|
-
if (mode === "planning" || mode === "executing") {
|
|
2390
|
-
useSessionStore.getState().setMode(sessionId, mode);
|
|
2391
|
-
}
|
|
2392
|
-
this._applyProjectionSideEffects(sessionId, turn);
|
|
2482
|
+
this._queueTurnPatch(sessionId, data);
|
|
2393
2483
|
});
|
|
2394
2484
|
s.on("turn:end", (data) => {
|
|
2395
2485
|
const sessionId = this._resolveSessionId(data);
|
|
@@ -2405,6 +2495,7 @@ var AgentSocket = class {
|
|
|
2405
2495
|
s.on("chat:end", (data) => {
|
|
2406
2496
|
const sessionId = this._resolveSessionId(data);
|
|
2407
2497
|
if (sessionId) {
|
|
2498
|
+
this._flushPendingTurnPatches(sessionId);
|
|
2408
2499
|
const status = data?.status ?? "completed";
|
|
2409
2500
|
useSessionStore.getState().updateSessionStatus(
|
|
2410
2501
|
sessionId,
|
|
@@ -2434,6 +2525,7 @@ var AgentSocket = class {
|
|
|
2434
2525
|
s.on("system:error", (data) => {
|
|
2435
2526
|
const sessionId = this._resolveSessionId(data);
|
|
2436
2527
|
if (sessionId) {
|
|
2528
|
+
this._flushPendingTurnPatches(sessionId);
|
|
2437
2529
|
const message = isOomText(data.message) ? OOM_MESSAGE : data.message;
|
|
2438
2530
|
useSessionStore.getState().updateSessionStatus(sessionId, "failed");
|
|
2439
2531
|
useChatStore.getState().markFailed(sessionId);
|
|
@@ -2520,6 +2612,7 @@ var AgentSocket = class {
|
|
|
2520
2612
|
invalidateSessionCheckpoints(sessionId);
|
|
2521
2613
|
});
|
|
2522
2614
|
const handleArtifact = (sessionId, data) => {
|
|
2615
|
+
if (_isHiddenPath(data.file_path)) return;
|
|
2523
2616
|
const type2 = resolveArtifactType(data.content_type);
|
|
2524
2617
|
const filePath = `/api/sessions/${sessionId}/files/${encodeURIComponent(data.file_path)}`;
|
|
2525
2618
|
const fileUrl = this.client.buildAuthedUrl(filePath);
|
|
@@ -2894,6 +2987,9 @@ function bridgeSocketEvents(client, _stores) {
|
|
|
2894
2987
|
setAgentSocket(nextSocket);
|
|
2895
2988
|
return nextSocket;
|
|
2896
2989
|
}
|
|
2990
|
+
function _isHiddenPath(filePath) {
|
|
2991
|
+
return filePath.split("/").some((seg) => seg.startsWith("."));
|
|
2992
|
+
}
|
|
2897
2993
|
|
|
2898
2994
|
// src/react/stores/answer-callback-store.ts
|
|
2899
2995
|
import { create as create11 } from "zustand";
|
|
@@ -3093,4 +3189,4 @@ export {
|
|
|
3093
3189
|
bootstrapBladeClient,
|
|
3094
3190
|
getBootstrappedClient
|
|
3095
3191
|
};
|
|
3096
|
-
//# sourceMappingURL=chunk-
|
|
3192
|
+
//# sourceMappingURL=chunk-UM7G65GH.js.map
|