@ccpocket/bridge 1.45.1 → 1.45.3
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/git-operations.d.ts +2 -0
- package/dist/git-operations.js +16 -0
- package/dist/git-operations.js.map +1 -1
- package/dist/sessions-index.d.ts +15 -7
- package/dist/sessions-index.js +60 -1
- package/dist/sessions-index.js.map +1 -1
- package/dist/websocket.d.ts +1 -0
- package/dist/websocket.js +78 -20
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -1
package/dist/websocket.js
CHANGED
|
@@ -13,7 +13,7 @@ import { getAllRecentSessions, getCodexSessionHistory, getSessionHistory, findSe
|
|
|
13
13
|
import { ArchiveStore } from "./archive-store.js";
|
|
14
14
|
import { WorktreeStore } from "./worktree-store.js";
|
|
15
15
|
import { listWorktrees, removeWorktree, worktreeExists, getMainBranch, } from "./worktree.js";
|
|
16
|
-
import { stageFiles, stageHunks, unstageFiles, unstageHunks, gitCommit, gitPush, listBranches, createBranch, checkoutBranch, revertFiles, revertHunks, gitFetch, gitPull, gitRemoteStatus, } from "./git-operations.js";
|
|
16
|
+
import { stageFiles, stageHunks, unstageFiles, unstageHunks, gitCommit, gitPush, listGitFiles, listBranches, createBranch, checkoutBranch, revertFiles, revertHunks, gitFetch, gitPull, gitRemoteStatus, } from "./git-operations.js";
|
|
17
17
|
import { generateCommitMessage } from "./git-assist.js";
|
|
18
18
|
import { listWindows, takeScreenshot } from "./screenshot.js";
|
|
19
19
|
import { DebugTraceStore } from "./debug-trace-store.js";
|
|
@@ -392,6 +392,61 @@ export class BridgeWebSocketServer {
|
|
|
392
392
|
session?.history.push(tipMsg);
|
|
393
393
|
this.send(ws, tipMsg);
|
|
394
394
|
}
|
|
395
|
+
async splitPastHistoryMessages(session) {
|
|
396
|
+
const messages = session.pastMessages ?? [];
|
|
397
|
+
const pastMessages = [];
|
|
398
|
+
const historyMessages = [];
|
|
399
|
+
for (const raw of messages) {
|
|
400
|
+
const msg = raw;
|
|
401
|
+
if (msg.role !== "tool_result") {
|
|
402
|
+
pastMessages.push(raw);
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
const paths = new Set();
|
|
406
|
+
if (Array.isArray(msg.imagePaths)) {
|
|
407
|
+
for (const path of msg.imagePaths) {
|
|
408
|
+
if (typeof path === "string" && path.length > 0)
|
|
409
|
+
paths.add(path);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const content = typeof msg.content === "string" ? msg.content : "";
|
|
413
|
+
if (this.imageStore && content) {
|
|
414
|
+
for (const path of this.imageStore.extractImagePaths(content)) {
|
|
415
|
+
paths.add(path);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
const images = this.imageStore && paths.size > 0
|
|
419
|
+
? await this.imageStore.registerImages([...paths], session.projectPath)
|
|
420
|
+
: [];
|
|
421
|
+
if (this.imageStore && Array.isArray(msg.imageBase64)) {
|
|
422
|
+
for (const image of msg.imageBase64) {
|
|
423
|
+
const rawImage = image;
|
|
424
|
+
if (typeof rawImage.data !== "string"
|
|
425
|
+
|| typeof rawImage.mimeType !== "string") {
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
const ref = this.imageStore.registerFromBase64(rawImage.data, rawImage.mimeType);
|
|
429
|
+
if (ref)
|
|
430
|
+
images.push(ref);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
const existingImages = Array.isArray(msg.images)
|
|
434
|
+
? msg.images
|
|
435
|
+
: [];
|
|
436
|
+
historyMessages.push({
|
|
437
|
+
type: "tool_result",
|
|
438
|
+
toolUseId: typeof msg.toolUseId === "string"
|
|
439
|
+
? msg.toolUseId
|
|
440
|
+
: `past-tool-result-${historyMessages.length}`,
|
|
441
|
+
content,
|
|
442
|
+
...(typeof msg.toolName === "string" ? { toolName: msg.toolName } : {}),
|
|
443
|
+
...(existingImages.length > 0 || images.length > 0
|
|
444
|
+
? { images: [...existingImages, ...images] }
|
|
445
|
+
: {}),
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
return { pastMessages, historyMessages };
|
|
449
|
+
}
|
|
395
450
|
createClaudeSessionWithFallback(params) {
|
|
396
451
|
const initialMode = params.options?.permissionMode ?? "default";
|
|
397
452
|
try {
|
|
@@ -1571,18 +1626,21 @@ export class BridgeWebSocketServer {
|
|
|
1571
1626
|
case "get_history": {
|
|
1572
1627
|
const session = this.sessionManager.get(msg.sessionId);
|
|
1573
1628
|
if (session) {
|
|
1629
|
+
const splitPastHistory = session.pastMessages && session.pastMessages.length > 0
|
|
1630
|
+
? await this.splitPastHistoryMessages(session)
|
|
1631
|
+
: { pastMessages: [], historyMessages: [] };
|
|
1574
1632
|
// Send past conversation from disk (resume) before in-memory history
|
|
1575
|
-
if (
|
|
1633
|
+
if (splitPastHistory.pastMessages.length > 0) {
|
|
1576
1634
|
this.send(ws, {
|
|
1577
1635
|
type: "past_history",
|
|
1578
1636
|
claudeSessionId: session.claudeSessionId ?? msg.sessionId,
|
|
1579
1637
|
sessionId: msg.sessionId,
|
|
1580
|
-
messages:
|
|
1638
|
+
messages: splitPastHistory.pastMessages,
|
|
1581
1639
|
});
|
|
1582
1640
|
}
|
|
1583
1641
|
this.send(ws, {
|
|
1584
1642
|
type: "history",
|
|
1585
|
-
messages: session.history,
|
|
1643
|
+
messages: [...splitPastHistory.historyMessages, ...session.history],
|
|
1586
1644
|
sessionId: msg.sessionId,
|
|
1587
1645
|
});
|
|
1588
1646
|
this.send(ws, {
|
|
@@ -2202,23 +2260,23 @@ export class BridgeWebSocketServer {
|
|
|
2202
2260
|
this.send(ws, this.buildPathNotAllowedError(msg.projectPath));
|
|
2203
2261
|
break;
|
|
2204
2262
|
}
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
if (/not a git repository/i.test(err.message)) {
|
|
2208
|
-
// Non-git project: silently return empty list (file listing is auxiliary)
|
|
2209
|
-
this.send(ws, { type: "file_list", files: [] });
|
|
2210
|
-
}
|
|
2211
|
-
else {
|
|
2212
|
-
this.send(ws, {
|
|
2213
|
-
type: "error",
|
|
2214
|
-
message: `Failed to list files: ${err.message}`,
|
|
2215
|
-
});
|
|
2216
|
-
}
|
|
2217
|
-
return;
|
|
2218
|
-
}
|
|
2219
|
-
const files = stdout.trim().split("\n").filter(Boolean);
|
|
2263
|
+
try {
|
|
2264
|
+
const files = listGitFiles(msg.projectPath);
|
|
2220
2265
|
this.send(ws, { type: "file_list", files });
|
|
2221
|
-
}
|
|
2266
|
+
}
|
|
2267
|
+
catch (err) {
|
|
2268
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2269
|
+
if (/not a git repository/i.test(message)) {
|
|
2270
|
+
// Non-git project: silently return empty list (file listing is auxiliary)
|
|
2271
|
+
this.send(ws, { type: "file_list", files: [] });
|
|
2272
|
+
}
|
|
2273
|
+
else {
|
|
2274
|
+
this.send(ws, {
|
|
2275
|
+
type: "error",
|
|
2276
|
+
message: `Failed to list files: ${message}`,
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2222
2280
|
break;
|
|
2223
2281
|
}
|
|
2224
2282
|
case "list_recordings": {
|