@adhdev/daemon-standalone 0.8.97 → 0.8.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/dist/index.js +269 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-OS2tw3XG.js +77 -0
- package/public/assets/{terminal-2SYILvaH.js → terminal-Dawba88C.js} +17 -15
- package/public/index.html +1 -1
- package/vendor/session-host-daemon/index.js +4 -4
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +13 -6
- package/vendor/session-host-daemon/index.mjs.map +1 -1
- package/public/assets/index-BAKxsqur.js +0 -79
package/dist/index.js
CHANGED
|
@@ -9162,6 +9162,8 @@ var require_dist = __commonJS({
|
|
|
9162
9162
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
9163
9163
|
var index_exports = {};
|
|
9164
9164
|
__export2(index_exports, {
|
|
9165
|
+
DEFAULT_SESSION_HOST_COLS: () => DEFAULT_SESSION_HOST_COLS,
|
|
9166
|
+
DEFAULT_SESSION_HOST_ROWS: () => DEFAULT_SESSION_HOST_ROWS,
|
|
9165
9167
|
SessionHostClient: () => SessionHostClient2,
|
|
9166
9168
|
SessionHostRegistry: () => SessionHostRegistry,
|
|
9167
9169
|
SessionRingBuffer: () => SessionRingBuffer,
|
|
@@ -9180,6 +9182,8 @@ var require_dist = __commonJS({
|
|
|
9180
9182
|
isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot,
|
|
9181
9183
|
resolveAttachableRuntimeRecord: () => resolveAttachableRuntimeRecord,
|
|
9182
9184
|
resolveRuntimeRecord: () => resolveRuntimeRecord,
|
|
9185
|
+
resolveSessionHostCols: () => resolveSessionHostCols,
|
|
9186
|
+
resolveSessionHostRows: () => resolveSessionHostRows,
|
|
9183
9187
|
sanitizeSpawnEnv: () => sanitizeSpawnEnv,
|
|
9184
9188
|
writeEnvelope: () => writeEnvelope
|
|
9185
9189
|
});
|
|
@@ -9245,6 +9249,19 @@ var require_dist = __commonJS({
|
|
|
9245
9249
|
}
|
|
9246
9250
|
};
|
|
9247
9251
|
var import_crypto3 = require("crypto");
|
|
9252
|
+
var DEFAULT_SESSION_HOST_COLS = 80;
|
|
9253
|
+
var DEFAULT_SESSION_HOST_ROWS = 48;
|
|
9254
|
+
function normalizeSessionHostDimension(value, fallback) {
|
|
9255
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
|
|
9256
|
+
const rounded = Math.floor(value);
|
|
9257
|
+
return rounded > 0 ? rounded : fallback;
|
|
9258
|
+
}
|
|
9259
|
+
function resolveSessionHostCols(value) {
|
|
9260
|
+
return normalizeSessionHostDimension(value, DEFAULT_SESSION_HOST_COLS);
|
|
9261
|
+
}
|
|
9262
|
+
function resolveSessionHostRows(value) {
|
|
9263
|
+
return normalizeSessionHostDimension(value, DEFAULT_SESSION_HOST_ROWS);
|
|
9264
|
+
}
|
|
9248
9265
|
var path5 = __toESM2(require("path"));
|
|
9249
9266
|
function normalizeSlug(input) {
|
|
9250
9267
|
return input.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
|
|
@@ -9397,8 +9414,8 @@ var require_dist = __commonJS({
|
|
|
9397
9414
|
meta: payload.meta || {}
|
|
9398
9415
|
};
|
|
9399
9416
|
record2.meta = {
|
|
9400
|
-
sessionHostCols: payload.cols
|
|
9401
|
-
sessionHostRows: payload.rows
|
|
9417
|
+
sessionHostCols: resolveSessionHostCols(payload.cols),
|
|
9418
|
+
sessionHostRows: resolveSessionHostRows(payload.rows),
|
|
9402
9419
|
...record2.meta
|
|
9403
9420
|
};
|
|
9404
9421
|
this.sessions.set(sessionId, {
|
|
@@ -29635,8 +29652,8 @@ var require_dist2 = __commonJS({
|
|
|
29635
29652
|
isWin,
|
|
29636
29653
|
useShell,
|
|
29637
29654
|
ptyOptions: {
|
|
29638
|
-
cols:
|
|
29639
|
-
rows:
|
|
29655
|
+
cols: import_session_host_core22.DEFAULT_SESSION_HOST_COLS,
|
|
29656
|
+
rows: import_session_host_core22.DEFAULT_SESSION_HOST_ROWS,
|
|
29640
29657
|
cwd: workingDir,
|
|
29641
29658
|
env: buildCliSpawnEnv(process.env, spawnConfig.env)
|
|
29642
29659
|
}
|
|
@@ -29689,11 +29706,13 @@ var require_dist2 = __commonJS({
|
|
|
29689
29706
|
}
|
|
29690
29707
|
var os9;
|
|
29691
29708
|
var path10;
|
|
29709
|
+
var import_session_host_core22;
|
|
29692
29710
|
var init_provider_cli_runtime = __esm2({
|
|
29693
29711
|
"src/cli-adapters/provider-cli-runtime.ts"() {
|
|
29694
29712
|
"use strict";
|
|
29695
29713
|
os9 = __toESM2(require("os"));
|
|
29696
29714
|
path10 = __toESM2(require("path"));
|
|
29715
|
+
import_session_host_core22 = require_dist();
|
|
29697
29716
|
init_provider_cli_shared();
|
|
29698
29717
|
}
|
|
29699
29718
|
});
|
|
@@ -32411,6 +32430,7 @@ ${data.message || ""}`.trim();
|
|
|
32411
32430
|
var import_path22 = require("path");
|
|
32412
32431
|
init_config();
|
|
32413
32432
|
var HERMES_SESSION_ID_RE = /^\d{8}_\d{6}_[a-z0-9]+$/i;
|
|
32433
|
+
var CLAUDE_SESSION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
32414
32434
|
function normalizeProviderSessionId(providerType, providerSessionId) {
|
|
32415
32435
|
const normalizedProviderType = typeof providerType === "string" ? providerType.trim() : "";
|
|
32416
32436
|
const normalizedId = typeof providerSessionId === "string" ? providerSessionId.trim() : "";
|
|
@@ -32420,6 +32440,9 @@ ${data.message || ""}`.trim();
|
|
|
32420
32440
|
if (normalizedProviderType === "hermes-cli" && !HERMES_SESSION_ID_RE.test(normalizedId)) {
|
|
32421
32441
|
return "";
|
|
32422
32442
|
}
|
|
32443
|
+
if (normalizedProviderType === "claude-cli" && !CLAUDE_SESSION_ID_RE.test(normalizedId)) {
|
|
32444
|
+
return "";
|
|
32445
|
+
}
|
|
32423
32446
|
return normalizedId;
|
|
32424
32447
|
}
|
|
32425
32448
|
function isLegacyVolatileSessionReadKey(key) {
|
|
@@ -35515,9 +35538,16 @@ ${cleanBody}`;
|
|
|
35515
35538
|
if (Number.isFinite(stringTimestamp) && stringTimestamp > 0) return stringTimestamp;
|
|
35516
35539
|
return fallbackTs;
|
|
35517
35540
|
}
|
|
35518
|
-
function
|
|
35541
|
+
function extractTimestampValue(value) {
|
|
35542
|
+
const numericTimestamp = Number(value || 0);
|
|
35543
|
+
if (Number.isFinite(numericTimestamp) && numericTimestamp > 0) return numericTimestamp;
|
|
35544
|
+
const stringTimestamp = typeof value === "string" ? Date.parse(value) : NaN;
|
|
35545
|
+
if (Number.isFinite(stringTimestamp) && stringTimestamp > 0) return stringTimestamp;
|
|
35546
|
+
return 0;
|
|
35547
|
+
}
|
|
35548
|
+
function readExistingSessionStartRecord(agentType, historySessionId) {
|
|
35519
35549
|
try {
|
|
35520
|
-
const dir = path7.join(HISTORY_DIR,
|
|
35550
|
+
const dir = path7.join(HISTORY_DIR, agentType);
|
|
35521
35551
|
if (!fs32.existsSync(dir)) return null;
|
|
35522
35552
|
const files = listHistoryFiles(dir, historySessionId).sort();
|
|
35523
35553
|
for (const file2 of files) {
|
|
@@ -35538,6 +35568,28 @@ ${cleanBody}`;
|
|
|
35538
35568
|
return null;
|
|
35539
35569
|
}
|
|
35540
35570
|
}
|
|
35571
|
+
function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
|
|
35572
|
+
if (records.length === 0) return false;
|
|
35573
|
+
try {
|
|
35574
|
+
const dir = path7.join(HISTORY_DIR, agentType);
|
|
35575
|
+
fs32.mkdirSync(dir, { recursive: true });
|
|
35576
|
+
const prefix = `${historySessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
|
|
35577
|
+
for (const file2 of fs32.readdirSync(dir)) {
|
|
35578
|
+
if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
|
|
35579
|
+
fs32.unlinkSync(path7.join(dir, file2));
|
|
35580
|
+
}
|
|
35581
|
+
}
|
|
35582
|
+
const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
|
|
35583
|
+
const filePath = path7.join(dir, `${prefix}${targetDate}.jsonl`);
|
|
35584
|
+
fs32.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
|
|
35585
|
+
`, "utf-8");
|
|
35586
|
+
invalidatePersistedSavedHistoryIndex(agentType, dir);
|
|
35587
|
+
savedHistorySessionCache.delete(agentType.replace(/[^a-zA-Z0-9_-]/g, "_"));
|
|
35588
|
+
return true;
|
|
35589
|
+
} catch {
|
|
35590
|
+
return false;
|
|
35591
|
+
}
|
|
35592
|
+
}
|
|
35541
35593
|
function rebuildHermesSavedHistoryFromCanonicalSession(historySessionId) {
|
|
35542
35594
|
const normalizedSessionId = normalizeSavedHistorySessionId("hermes-cli", historySessionId);
|
|
35543
35595
|
if (!normalizedSessionId) return false;
|
|
@@ -35548,7 +35600,7 @@ ${cleanBody}`;
|
|
|
35548
35600
|
const canonicalMessages = Array.isArray(raw.messages) ? raw.messages : [];
|
|
35549
35601
|
const dir = path7.join(HISTORY_DIR, "hermes-cli");
|
|
35550
35602
|
fs32.mkdirSync(dir, { recursive: true });
|
|
35551
|
-
const existingSessionStart =
|
|
35603
|
+
const existingSessionStart = readExistingSessionStartRecord("hermes-cli", normalizedSessionId);
|
|
35552
35604
|
const records = [];
|
|
35553
35605
|
if (existingSessionStart) {
|
|
35554
35606
|
records.push({
|
|
@@ -35600,20 +35652,167 @@ ${cleanBody}`;
|
|
|
35600
35652
|
});
|
|
35601
35653
|
}
|
|
35602
35654
|
}
|
|
35603
|
-
|
|
35604
|
-
|
|
35605
|
-
|
|
35606
|
-
|
|
35607
|
-
|
|
35655
|
+
return rewriteCanonicalSavedHistory("hermes-cli", normalizedSessionId, records);
|
|
35656
|
+
} catch {
|
|
35657
|
+
return false;
|
|
35658
|
+
}
|
|
35659
|
+
}
|
|
35660
|
+
function resolveClaudeProjectTranscriptPath(historySessionId, workspace) {
|
|
35661
|
+
const claudeProjectsDir = path7.join(os52.homedir(), ".claude", "projects");
|
|
35662
|
+
if (!fs32.existsSync(claudeProjectsDir)) return null;
|
|
35663
|
+
const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
|
|
35664
|
+
if (normalizedWorkspace) {
|
|
35665
|
+
const directPath = path7.join(claudeProjectsDir, normalizedWorkspace.replace(/[\\/]/g, "-"), `${historySessionId}.jsonl`);
|
|
35666
|
+
if (fs32.existsSync(directPath)) return directPath;
|
|
35667
|
+
}
|
|
35668
|
+
const stack = [claudeProjectsDir];
|
|
35669
|
+
while (stack.length > 0) {
|
|
35670
|
+
const current = stack.pop();
|
|
35671
|
+
if (!current) continue;
|
|
35672
|
+
for (const entry of fs32.readdirSync(current, { withFileTypes: true })) {
|
|
35673
|
+
const entryPath = path7.join(current, entry.name);
|
|
35674
|
+
if (entry.isDirectory()) {
|
|
35675
|
+
stack.push(entryPath);
|
|
35676
|
+
continue;
|
|
35677
|
+
}
|
|
35678
|
+
if (entry.isFile() && entry.name === `${historySessionId}.jsonl`) {
|
|
35679
|
+
return entryPath;
|
|
35608
35680
|
}
|
|
35609
35681
|
}
|
|
35610
|
-
|
|
35611
|
-
|
|
35612
|
-
|
|
35613
|
-
|
|
35614
|
-
|
|
35615
|
-
|
|
35616
|
-
return
|
|
35682
|
+
}
|
|
35683
|
+
return null;
|
|
35684
|
+
}
|
|
35685
|
+
function extractClaudeAssistantContentParts(content) {
|
|
35686
|
+
if (typeof content === "string") {
|
|
35687
|
+
const trimmed = content.trim();
|
|
35688
|
+
return trimmed ? [{ content: trimmed, kind: "standard", role: "assistant" }] : [];
|
|
35689
|
+
}
|
|
35690
|
+
if (!Array.isArray(content)) return [];
|
|
35691
|
+
const parts = [];
|
|
35692
|
+
for (const block of content) {
|
|
35693
|
+
if (!block || typeof block !== "object") continue;
|
|
35694
|
+
const record2 = block;
|
|
35695
|
+
const type = String(record2.type || "").trim();
|
|
35696
|
+
if (type === "text") {
|
|
35697
|
+
const text = String(record2.text || "").trim();
|
|
35698
|
+
if (text) parts.push({ content: text, kind: "standard", role: "assistant" });
|
|
35699
|
+
continue;
|
|
35700
|
+
}
|
|
35701
|
+
if (type === "tool_use") {
|
|
35702
|
+
const name = String(record2.name || "").trim() || "Tool";
|
|
35703
|
+
const input = record2.input && typeof record2.input === "object" ? record2.input : null;
|
|
35704
|
+
const command = input ? String(input.command || "").trim() : "";
|
|
35705
|
+
const summary = command ? `${name}: ${command}` : name;
|
|
35706
|
+
if (summary) parts.push({ content: summary, kind: "tool", senderName: "Tool", role: "assistant" });
|
|
35707
|
+
}
|
|
35708
|
+
}
|
|
35709
|
+
return parts;
|
|
35710
|
+
}
|
|
35711
|
+
function extractClaudeUserContentParts(content) {
|
|
35712
|
+
if (typeof content === "string") {
|
|
35713
|
+
const trimmed = content.trim();
|
|
35714
|
+
return trimmed ? [{ role: "user", content: trimmed, kind: "standard" }] : [];
|
|
35715
|
+
}
|
|
35716
|
+
if (!Array.isArray(content)) return [];
|
|
35717
|
+
const parts = [];
|
|
35718
|
+
for (const block of content) {
|
|
35719
|
+
if (!block || typeof block !== "object") continue;
|
|
35720
|
+
const record2 = block;
|
|
35721
|
+
const type = String(record2.type || "").trim();
|
|
35722
|
+
if (type === "text") {
|
|
35723
|
+
const text = String(record2.text || "").trim();
|
|
35724
|
+
if (text) parts.push({ role: "user", content: text, kind: "standard" });
|
|
35725
|
+
continue;
|
|
35726
|
+
}
|
|
35727
|
+
if (type === "tool_result") {
|
|
35728
|
+
const rawContent = record2.content;
|
|
35729
|
+
const text = typeof rawContent === "string" ? rawContent.trim() : Array.isArray(rawContent) ? rawContent.map((entry) => {
|
|
35730
|
+
if (typeof entry === "string") return entry.trim();
|
|
35731
|
+
if (!entry || typeof entry !== "object") return "";
|
|
35732
|
+
const nested = entry;
|
|
35733
|
+
if (typeof nested.text === "string") return nested.text.trim();
|
|
35734
|
+
if (typeof nested.content === "string") return nested.content.trim();
|
|
35735
|
+
return "";
|
|
35736
|
+
}).filter(Boolean).join("\n") : "";
|
|
35737
|
+
if (text) parts.push({ role: "assistant", content: text, kind: "tool", senderName: "Tool" });
|
|
35738
|
+
}
|
|
35739
|
+
}
|
|
35740
|
+
return parts;
|
|
35741
|
+
}
|
|
35742
|
+
function rebuildClaudeSavedHistoryFromNativeProject(historySessionId, workspace) {
|
|
35743
|
+
const normalizedSessionId = normalizeSavedHistorySessionId("claude-cli", historySessionId);
|
|
35744
|
+
if (!normalizedSessionId) return false;
|
|
35745
|
+
try {
|
|
35746
|
+
const transcriptPath = resolveClaudeProjectTranscriptPath(normalizedSessionId, workspace);
|
|
35747
|
+
if (!transcriptPath) return false;
|
|
35748
|
+
const lines = fs32.readFileSync(transcriptPath, "utf-8").split("\n").filter(Boolean);
|
|
35749
|
+
const records = [];
|
|
35750
|
+
const existingSessionStart = readExistingSessionStartRecord("claude-cli", normalizedSessionId);
|
|
35751
|
+
if (existingSessionStart) {
|
|
35752
|
+
records.push({
|
|
35753
|
+
...existingSessionStart,
|
|
35754
|
+
historySessionId: normalizedSessionId
|
|
35755
|
+
});
|
|
35756
|
+
}
|
|
35757
|
+
let fallbackTs = Date.now();
|
|
35758
|
+
for (const line of lines) {
|
|
35759
|
+
let parsed = null;
|
|
35760
|
+
try {
|
|
35761
|
+
parsed = JSON.parse(line);
|
|
35762
|
+
} catch {
|
|
35763
|
+
parsed = null;
|
|
35764
|
+
}
|
|
35765
|
+
if (!parsed) continue;
|
|
35766
|
+
const parsedSessionId = String(parsed.sessionId || "").trim();
|
|
35767
|
+
if (parsedSessionId && parsedSessionId !== normalizedSessionId) continue;
|
|
35768
|
+
const receivedAt = extractTimestampValue(parsed.timestamp) || fallbackTs;
|
|
35769
|
+
fallbackTs = receivedAt + 1;
|
|
35770
|
+
const parsedWorkspace = String(parsed.cwd || workspace || "").trim();
|
|
35771
|
+
if (records.length === 0 && parsedWorkspace) {
|
|
35772
|
+
records.push({
|
|
35773
|
+
ts: new Date(receivedAt).toISOString(),
|
|
35774
|
+
receivedAt,
|
|
35775
|
+
role: "system",
|
|
35776
|
+
kind: "session_start",
|
|
35777
|
+
content: parsedWorkspace,
|
|
35778
|
+
agent: "claude-cli",
|
|
35779
|
+
historySessionId: normalizedSessionId,
|
|
35780
|
+
workspace: parsedWorkspace
|
|
35781
|
+
});
|
|
35782
|
+
}
|
|
35783
|
+
const type = String(parsed.type || "").trim();
|
|
35784
|
+
const message = parsed.message && typeof parsed.message === "object" ? parsed.message : null;
|
|
35785
|
+
if (type === "user" && message) {
|
|
35786
|
+
for (const part of extractClaudeUserContentParts(message.content)) {
|
|
35787
|
+
records.push({
|
|
35788
|
+
ts: new Date(receivedAt).toISOString(),
|
|
35789
|
+
receivedAt,
|
|
35790
|
+
role: part.role,
|
|
35791
|
+
content: part.content,
|
|
35792
|
+
kind: part.kind,
|
|
35793
|
+
senderName: part.senderName,
|
|
35794
|
+
agent: "claude-cli",
|
|
35795
|
+
historySessionId: normalizedSessionId
|
|
35796
|
+
});
|
|
35797
|
+
}
|
|
35798
|
+
continue;
|
|
35799
|
+
}
|
|
35800
|
+
if (type === "assistant" && message) {
|
|
35801
|
+
for (const part of extractClaudeAssistantContentParts(message.content)) {
|
|
35802
|
+
records.push({
|
|
35803
|
+
ts: new Date(receivedAt).toISOString(),
|
|
35804
|
+
receivedAt,
|
|
35805
|
+
role: "assistant",
|
|
35806
|
+
content: part.content,
|
|
35807
|
+
kind: part.kind,
|
|
35808
|
+
senderName: part.senderName,
|
|
35809
|
+
agent: "claude-cli",
|
|
35810
|
+
historySessionId: normalizedSessionId
|
|
35811
|
+
});
|
|
35812
|
+
}
|
|
35813
|
+
}
|
|
35814
|
+
}
|
|
35815
|
+
return rewriteCanonicalSavedHistory("claude-cli", normalizedSessionId, records);
|
|
35617
35816
|
} catch {
|
|
35618
35817
|
return false;
|
|
35619
35818
|
}
|
|
@@ -40608,7 +40807,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40608
40807
|
parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
|
|
40609
40808
|
}
|
|
40610
40809
|
const mergedMessages = this.mergeConversationMessages(parsedMessages);
|
|
40611
|
-
const
|
|
40810
|
+
const canonicalBackedHistory = this.syncCanonicalSavedHistoryIfNeeded();
|
|
40612
40811
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
40613
40812
|
if (parsedMessages.length > 0) {
|
|
40614
40813
|
const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
|
|
@@ -40626,7 +40825,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40626
40825
|
senderName: typeof message.senderName === "string" ? message.senderName : void 0,
|
|
40627
40826
|
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
40628
40827
|
}));
|
|
40629
|
-
if (!
|
|
40828
|
+
if (!canonicalBackedHistory && !shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
|
|
40630
40829
|
const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
|
|
40631
40830
|
this.historyWriter.appendNewMessages(
|
|
40632
40831
|
this.type,
|
|
@@ -40636,7 +40835,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40636
40835
|
this.providerSessionId
|
|
40637
40836
|
);
|
|
40638
40837
|
}
|
|
40639
|
-
if (!
|
|
40838
|
+
if (!canonicalBackedHistory) {
|
|
40640
40839
|
this.lastPersistedHistoryMessages = normalizedMessagesToSave;
|
|
40641
40840
|
}
|
|
40642
40841
|
}
|
|
@@ -41113,32 +41312,52 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41113
41312
|
});
|
|
41114
41313
|
LOG2.info("CLI", `[${this.type}] discovered provider session id: ${nextSessionId}`);
|
|
41115
41314
|
}
|
|
41116
|
-
|
|
41117
|
-
if (
|
|
41118
|
-
|
|
41119
|
-
|
|
41120
|
-
|
|
41121
|
-
|
|
41122
|
-
|
|
41123
|
-
|
|
41124
|
-
|
|
41125
|
-
|
|
41126
|
-
|
|
41127
|
-
|
|
41128
|
-
|
|
41129
|
-
|
|
41130
|
-
|
|
41131
|
-
|
|
41132
|
-
|
|
41133
|
-
|
|
41134
|
-
|
|
41135
|
-
|
|
41136
|
-
|
|
41315
|
+
syncCanonicalSavedHistoryIfNeeded() {
|
|
41316
|
+
if (!this.providerSessionId) return false;
|
|
41317
|
+
if (this.type === "hermes-cli") {
|
|
41318
|
+
try {
|
|
41319
|
+
const canonicalPath = path11.join(os11.homedir(), ".hermes", "sessions", `session_${this.providerSessionId}.json`);
|
|
41320
|
+
if (!fs52.existsSync(canonicalPath)) return false;
|
|
41321
|
+
const stat4 = fs52.statSync(canonicalPath);
|
|
41322
|
+
if (stat4.mtimeMs <= this.lastCanonicalHermesSyncMtimeMs) return true;
|
|
41323
|
+
const rebuilt = rebuildHermesSavedHistoryFromCanonicalSession(this.providerSessionId);
|
|
41324
|
+
if (!rebuilt) return false;
|
|
41325
|
+
this.lastCanonicalHermesSyncMtimeMs = stat4.mtimeMs;
|
|
41326
|
+
const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
|
|
41327
|
+
this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
|
|
41328
|
+
role: message.role,
|
|
41329
|
+
content: message.content,
|
|
41330
|
+
kind: message.kind,
|
|
41331
|
+
senderName: message.senderName,
|
|
41332
|
+
receivedAt: message.receivedAt
|
|
41333
|
+
}));
|
|
41334
|
+
return true;
|
|
41335
|
+
} catch {
|
|
41336
|
+
return false;
|
|
41337
|
+
}
|
|
41338
|
+
}
|
|
41339
|
+
if (this.type === "claude-cli") {
|
|
41340
|
+
try {
|
|
41341
|
+
const rebuilt = rebuildClaudeSavedHistoryFromNativeProject(this.providerSessionId, this.workingDir);
|
|
41342
|
+
if (!rebuilt) return false;
|
|
41343
|
+
const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
|
|
41344
|
+
this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
|
|
41345
|
+
role: message.role,
|
|
41346
|
+
content: message.content,
|
|
41347
|
+
kind: message.kind,
|
|
41348
|
+
senderName: message.senderName,
|
|
41349
|
+
receivedAt: message.receivedAt
|
|
41350
|
+
}));
|
|
41351
|
+
return true;
|
|
41352
|
+
} catch {
|
|
41353
|
+
return false;
|
|
41354
|
+
}
|
|
41137
41355
|
}
|
|
41356
|
+
return false;
|
|
41138
41357
|
}
|
|
41139
41358
|
restorePersistedHistoryFromCurrentSession() {
|
|
41140
41359
|
if (!this.providerSessionId) return;
|
|
41141
|
-
this.
|
|
41360
|
+
this.syncCanonicalSavedHistoryIfNeeded();
|
|
41142
41361
|
this.historyWriter.compactHistorySession(this.type, this.providerSessionId);
|
|
41143
41362
|
const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
|
|
41144
41363
|
this.historyWriter.seedSessionHistory(
|
|
@@ -53162,7 +53381,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53162
53381
|
};
|
|
53163
53382
|
init_provider_cli_adapter();
|
|
53164
53383
|
init_pty_transport();
|
|
53165
|
-
var
|
|
53384
|
+
var import_session_host_core32 = require_dist();
|
|
53166
53385
|
init_logger();
|
|
53167
53386
|
function shouldResumeAttachedSession(record2) {
|
|
53168
53387
|
if (!record2) return false;
|
|
@@ -53174,7 +53393,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53174
53393
|
var SessionHostRuntimeTransport = class {
|
|
53175
53394
|
constructor(options) {
|
|
53176
53395
|
this.options = options;
|
|
53177
|
-
this.client = new
|
|
53396
|
+
this.client = new import_session_host_core32.SessionHostClient({
|
|
53178
53397
|
endpoint: options.endpoint,
|
|
53179
53398
|
appName: options.appName
|
|
53180
53399
|
});
|
|
@@ -53576,11 +53795,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53576
53795
|
function resolveSessionHostAppName(options = {}) {
|
|
53577
53796
|
return resolveSessionHostAppNameResolution2(options).appName;
|
|
53578
53797
|
}
|
|
53579
|
-
var
|
|
53798
|
+
var import_session_host_core4 = require_dist();
|
|
53580
53799
|
var STARTUP_TIMEOUT_MS = DEFAULT_SESSION_HOST_READY_TIMEOUT_MS2;
|
|
53581
53800
|
var STARTUP_POLL_MS = 200;
|
|
53582
53801
|
async function canConnect(endpoint) {
|
|
53583
|
-
const client = new
|
|
53802
|
+
const client = new import_session_host_core4.SessionHostClient({ endpoint });
|
|
53584
53803
|
try {
|
|
53585
53804
|
await client.connect();
|
|
53586
53805
|
await client.close();
|
|
@@ -53598,14 +53817,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53598
53817
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
53599
53818
|
}
|
|
53600
53819
|
async function ensureSessionHostReady2(options) {
|
|
53601
|
-
const endpoint = (0,
|
|
53820
|
+
const endpoint = (0, import_session_host_core4.getDefaultSessionHostEndpoint)(options.appName || "adhdev");
|
|
53602
53821
|
if (await canConnect(endpoint)) return endpoint;
|
|
53603
53822
|
options.spawnHost();
|
|
53604
53823
|
await waitForReady(endpoint, options.timeoutMs);
|
|
53605
53824
|
return endpoint;
|
|
53606
53825
|
}
|
|
53607
53826
|
async function listHostedCliRuntimes2(endpoint) {
|
|
53608
|
-
const client = new
|
|
53827
|
+
const client = new import_session_host_core4.SessionHostClient({ endpoint });
|
|
53609
53828
|
try {
|
|
53610
53829
|
const response = await client.request({
|
|
53611
53830
|
type: "list_sessions",
|