@hermespilot/link 0.5.9 → 0.6.0
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.
|
@@ -4502,7 +4502,7 @@ import os2 from "os";
|
|
|
4502
4502
|
import path5 from "path";
|
|
4503
4503
|
|
|
4504
4504
|
// src/constants.ts
|
|
4505
|
-
var LINK_VERSION = "0.
|
|
4505
|
+
var LINK_VERSION = "0.6.0";
|
|
4506
4506
|
var LINK_COMMAND = "hermeslink";
|
|
4507
4507
|
var LINK_DEFAULT_PORT = 52379;
|
|
4508
4508
|
var LINK_RUNTIME_DIR_NAME = ".hermeslink";
|
|
@@ -13353,6 +13353,17 @@ async function buildConversationHistory(input) {
|
|
|
13353
13353
|
)
|
|
13354
13354
|
};
|
|
13355
13355
|
}
|
|
13356
|
+
if (snapshotHistory.length > 0) {
|
|
13357
|
+
return {
|
|
13358
|
+
messages: snapshotHistory,
|
|
13359
|
+
source: "link_snapshot",
|
|
13360
|
+
diagnostics: createHistoryDiagnostics(
|
|
13361
|
+
snapshotHistory,
|
|
13362
|
+
"link_snapshot_authoritative",
|
|
13363
|
+
{ snapshot_message_count: snapshotHistory.length }
|
|
13364
|
+
)
|
|
13365
|
+
};
|
|
13366
|
+
}
|
|
13356
13367
|
const hermesHistory = await readHermesTranscriptHistory(
|
|
13357
13368
|
input.hermesSessionId,
|
|
13358
13369
|
input.profileName
|
|
@@ -13396,11 +13407,16 @@ async function readHermesTranscriptHistory(sessionId, profileName) {
|
|
|
13396
13407
|
}));
|
|
13397
13408
|
const [dbHistory, jsonlHistory] = await Promise.all([
|
|
13398
13409
|
readHermesStateDbHistory(dbPath, normalizedSessionId),
|
|
13399
|
-
|
|
13410
|
+
readHermesTranscriptFilesHistory(
|
|
13411
|
+
sessionsDirConfig.sessionsDir,
|
|
13412
|
+
normalizedSessionId
|
|
13413
|
+
)
|
|
13400
13414
|
]);
|
|
13401
13415
|
const diagnosticCounts = {
|
|
13402
13416
|
state_db_message_count: dbHistory.length,
|
|
13403
|
-
|
|
13417
|
+
transcript_message_count: jsonlHistory.messages.length,
|
|
13418
|
+
session_json_message_count: jsonlHistory.sessionJsonMessageCount,
|
|
13419
|
+
jsonl_message_count: jsonlHistory.jsonlMessageCount,
|
|
13404
13420
|
jsonl_byte_count: jsonlHistory.byteCount,
|
|
13405
13421
|
jsonl_line_count: jsonlHistory.lineCount,
|
|
13406
13422
|
jsonl_skipped_line_count: jsonlHistory.skippedLineCount,
|
|
@@ -13413,7 +13429,7 @@ async function readHermesTranscriptHistory(sessionId, profileName) {
|
|
|
13413
13429
|
source: "hermes_transcript",
|
|
13414
13430
|
diagnostics: createHistoryDiagnostics(
|
|
13415
13431
|
jsonlHistory.messages,
|
|
13416
|
-
"
|
|
13432
|
+
"transcript_has_more_messages",
|
|
13417
13433
|
diagnosticCounts
|
|
13418
13434
|
)
|
|
13419
13435
|
};
|
|
@@ -13448,13 +13464,9 @@ async function readHermesJsonlHistory(sessionsDir, sessionId) {
|
|
|
13448
13464
|
if (!isValidSessionFileStem(sessionId)) {
|
|
13449
13465
|
return empty;
|
|
13450
13466
|
}
|
|
13451
|
-
const
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
return "";
|
|
13455
|
-
}
|
|
13456
|
-
throw error;
|
|
13457
|
-
});
|
|
13467
|
+
const raw = await readFirstExistingFile(
|
|
13468
|
+
candidateTranscriptPaths(sessionsDir, sessionId, "jsonl")
|
|
13469
|
+
);
|
|
13458
13470
|
if (!raw.trim()) {
|
|
13459
13471
|
return empty;
|
|
13460
13472
|
}
|
|
@@ -13482,6 +13494,93 @@ async function readHermesJsonlHistory(sessionsDir, sessionId) {
|
|
|
13482
13494
|
skippedLineCount
|
|
13483
13495
|
};
|
|
13484
13496
|
}
|
|
13497
|
+
async function readHermesSessionJsonHistory(sessionsDir, sessionId) {
|
|
13498
|
+
const empty = {
|
|
13499
|
+
messages: [],
|
|
13500
|
+
byteCount: 0,
|
|
13501
|
+
skippedMessageCount: 0
|
|
13502
|
+
};
|
|
13503
|
+
if (!isValidSessionFileStem(sessionId)) {
|
|
13504
|
+
return empty;
|
|
13505
|
+
}
|
|
13506
|
+
const raw = await readFirstExistingFile(
|
|
13507
|
+
candidateTranscriptPaths(sessionsDir, sessionId, "json")
|
|
13508
|
+
);
|
|
13509
|
+
if (!raw.trim()) {
|
|
13510
|
+
return empty;
|
|
13511
|
+
}
|
|
13512
|
+
let payload;
|
|
13513
|
+
try {
|
|
13514
|
+
payload = JSON.parse(raw);
|
|
13515
|
+
} catch {
|
|
13516
|
+
return {
|
|
13517
|
+
messages: [],
|
|
13518
|
+
byteCount: Buffer.byteLength(raw, "utf8"),
|
|
13519
|
+
skippedMessageCount: 1
|
|
13520
|
+
};
|
|
13521
|
+
}
|
|
13522
|
+
const records = Array.isArray(payload) ? payload : isRecord2(payload) && Array.isArray(payload.messages) ? payload.messages : [];
|
|
13523
|
+
const messages = [];
|
|
13524
|
+
let skippedMessageCount = 0;
|
|
13525
|
+
for (const record of records) {
|
|
13526
|
+
if (!isRecord2(record)) {
|
|
13527
|
+
skippedMessageCount += 1;
|
|
13528
|
+
continue;
|
|
13529
|
+
}
|
|
13530
|
+
const message = normalizeHistoryRecord(record);
|
|
13531
|
+
if (message) {
|
|
13532
|
+
messages.push(message);
|
|
13533
|
+
} else {
|
|
13534
|
+
skippedMessageCount += 1;
|
|
13535
|
+
}
|
|
13536
|
+
}
|
|
13537
|
+
return {
|
|
13538
|
+
messages,
|
|
13539
|
+
byteCount: Buffer.byteLength(raw, "utf8"),
|
|
13540
|
+
skippedMessageCount
|
|
13541
|
+
};
|
|
13542
|
+
}
|
|
13543
|
+
async function readHermesTranscriptFilesHistory(sessionsDir, sessionId) {
|
|
13544
|
+
const [jsonHistory, jsonlHistory] = await Promise.all([
|
|
13545
|
+
readHermesSessionJsonHistory(sessionsDir, sessionId),
|
|
13546
|
+
readHermesJsonlHistory(sessionsDir, sessionId)
|
|
13547
|
+
]);
|
|
13548
|
+
if (jsonHistory.messages.length > jsonlHistory.messages.length) {
|
|
13549
|
+
return {
|
|
13550
|
+
messages: jsonHistory.messages,
|
|
13551
|
+
byteCount: jsonHistory.byteCount,
|
|
13552
|
+
lineCount: 0,
|
|
13553
|
+
skippedLineCount: jsonHistory.skippedMessageCount,
|
|
13554
|
+
sessionJsonMessageCount: jsonHistory.messages.length,
|
|
13555
|
+
jsonlMessageCount: jsonlHistory.messages.length
|
|
13556
|
+
};
|
|
13557
|
+
}
|
|
13558
|
+
return {
|
|
13559
|
+
...jsonlHistory,
|
|
13560
|
+
sessionJsonMessageCount: jsonHistory.messages.length,
|
|
13561
|
+
jsonlMessageCount: jsonlHistory.messages.length
|
|
13562
|
+
};
|
|
13563
|
+
}
|
|
13564
|
+
async function readFirstExistingFile(paths) {
|
|
13565
|
+
for (const filePath of paths) {
|
|
13566
|
+
const raw = await readFile10(filePath, "utf8").catch((error) => {
|
|
13567
|
+
if (isNodeError12(error, "ENOENT")) {
|
|
13568
|
+
return null;
|
|
13569
|
+
}
|
|
13570
|
+
throw error;
|
|
13571
|
+
});
|
|
13572
|
+
if (raw !== null) {
|
|
13573
|
+
return raw;
|
|
13574
|
+
}
|
|
13575
|
+
}
|
|
13576
|
+
return "";
|
|
13577
|
+
}
|
|
13578
|
+
function candidateTranscriptPaths(sessionsDir, sessionId, extension) {
|
|
13579
|
+
return [
|
|
13580
|
+
path17.join(sessionsDir, `session_${sessionId}.${extension}`),
|
|
13581
|
+
path17.join(sessionsDir, `${sessionId}.${extension}`)
|
|
13582
|
+
];
|
|
13583
|
+
}
|
|
13485
13584
|
function readHistoryRows(dbPath, sessionId) {
|
|
13486
13585
|
let db = null;
|
|
13487
13586
|
try {
|
|
@@ -13534,6 +13633,8 @@ function createHistoryDiagnostics(messages, sourceReason, counts = {}) {
|
|
|
13534
13633
|
return {
|
|
13535
13634
|
source_reason: sourceReason,
|
|
13536
13635
|
state_db_message_count: counts.state_db_message_count ?? 0,
|
|
13636
|
+
transcript_message_count: counts.transcript_message_count ?? 0,
|
|
13637
|
+
session_json_message_count: counts.session_json_message_count ?? 0,
|
|
13537
13638
|
jsonl_message_count: counts.jsonl_message_count ?? 0,
|
|
13538
13639
|
snapshot_message_count: counts.snapshot_message_count ?? 0,
|
|
13539
13640
|
selected_message_count: messages.length,
|
|
@@ -13550,6 +13651,8 @@ function createHistoryDiagnostics(messages, sourceReason, counts = {}) {
|
|
|
13550
13651
|
function pickHermesDiagnosticCounts(diagnostics) {
|
|
13551
13652
|
return {
|
|
13552
13653
|
state_db_message_count: diagnostics.state_db_message_count,
|
|
13654
|
+
transcript_message_count: diagnostics.transcript_message_count,
|
|
13655
|
+
session_json_message_count: diagnostics.session_json_message_count,
|
|
13553
13656
|
jsonl_message_count: diagnostics.jsonl_message_count,
|
|
13554
13657
|
jsonl_byte_count: diagnostics.jsonl_byte_count,
|
|
13555
13658
|
jsonl_line_count: diagnostics.jsonl_line_count,
|
|
@@ -13558,6 +13661,9 @@ function pickHermesDiagnosticCounts(diagnostics) {
|
|
|
13558
13661
|
jsonl_sessions_dir_config_error: diagnostics.jsonl_sessions_dir_config_error
|
|
13559
13662
|
};
|
|
13560
13663
|
}
|
|
13664
|
+
function isRecord2(value) {
|
|
13665
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13666
|
+
}
|
|
13561
13667
|
function countReplayMetadata(messages) {
|
|
13562
13668
|
let toolMessageCount = 0;
|
|
13563
13669
|
let toolCallMessageCount = 0;
|
package/dist/cli/index.js
CHANGED
package/dist/http/app.js
CHANGED