@cchistory/lite 0.8.3 → 0.9.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.
Files changed (149) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/version.d.ts +1 -1
  3. package/apps/lite-cli/dist/version.js +1 -1
  4. package/apps/lite-tui/dist/render.d.ts +1 -1
  5. package/apps/lite-tui/dist/version.d.ts +1 -1
  6. package/apps/lite-tui/dist/version.js +1 -1
  7. package/node_modules/@cchistory/canonical/dist/query.js +1 -1
  8. package/node_modules/@cchistory/canonical/dist/query.js.map +1 -1
  9. package/node_modules/@cchistory/canonical/dist/tool-call-summary.d.ts.map +1 -1
  10. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js +10 -2
  11. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js.map +1 -1
  12. package/node_modules/@cchistory/canonical/dist/usage-anomalies.d.ts.map +1 -1
  13. package/node_modules/@cchistory/canonical/dist/usage-anomalies.js +2 -0
  14. package/node_modules/@cchistory/canonical/dist/usage-anomalies.js.map +1 -1
  15. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.d.ts.map +1 -1
  16. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.js +4 -1
  17. package/node_modules/@cchistory/canonical/dist/usage-call-evaluation.js.map +1 -1
  18. package/node_modules/@cchistory/canonical/dist/usage-trace.d.ts.map +1 -1
  19. package/node_modules/@cchistory/canonical/dist/usage-trace.js +3 -1
  20. package/node_modules/@cchistory/canonical/dist/usage-trace.js.map +1 -1
  21. package/node_modules/@cchistory/canonical/dist/usage-trace.test.js +73 -0
  22. package/node_modules/@cchistory/canonical/dist/usage-trace.test.js.map +1 -1
  23. package/node_modules/@cchistory/canonical/dist/usage.d.ts +1 -0
  24. package/node_modules/@cchistory/canonical/dist/usage.d.ts.map +1 -1
  25. package/node_modules/@cchistory/canonical/dist/usage.js +23 -17
  26. package/node_modules/@cchistory/canonical/dist/usage.js.map +1 -1
  27. package/node_modules/@cchistory/canonical/package.json +1 -1
  28. package/node_modules/@cchistory/domain/dist/index.d.ts +3 -1
  29. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  30. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  31. package/node_modules/@cchistory/domain/dist/index.test.js +10 -1
  32. package/node_modules/@cchistory/domain/dist/index.test.js.map +1 -1
  33. package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -1
  34. package/node_modules/@cchistory/domain/dist/token-evidence.js +3 -1
  35. package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -1
  36. package/node_modules/@cchistory/domain/package.json +1 -1
  37. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +2 -0
  38. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  39. package/node_modules/@cchistory/live-runtime/dist/index.js +1 -0
  40. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  41. package/node_modules/@cchistory/live-runtime/dist/index.test.js +266 -38
  42. package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
  43. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  44. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts +3 -0
  45. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts.map +1 -1
  46. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js.map +1 -1
  47. package/node_modules/@cchistory/source-adapters/dist/core/discovery.d.ts.map +1 -1
  48. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js +60 -4
  49. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js.map +1 -1
  50. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +1 -1
  51. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
  52. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +198 -1
  53. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
  54. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
  55. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +85 -5
  56. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
  57. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js +17 -1
  58. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js.map +1 -1
  59. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
  60. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +44 -0
  61. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
  62. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
  63. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +12 -0
  64. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
  65. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +4 -0
  66. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  67. package/node_modules/@cchistory/source-adapters/dist/index.test.js +4 -0
  68. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  69. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -0
  70. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
  71. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.d.ts +28 -0
  72. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.d.ts.map +1 -0
  73. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.js +443 -0
  74. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/reader.js.map +1 -0
  75. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.d.ts +4 -0
  76. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.d.ts.map +1 -0
  77. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.js +370 -0
  78. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness/runtime.js.map +1 -0
  79. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.d.ts +3 -0
  80. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.d.ts.map +1 -0
  81. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.js +78 -0
  82. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.js.map +1 -0
  83. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.d.ts +2 -0
  84. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.d.ts.map +1 -0
  85. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.js +313 -0
  86. package/node_modules/@cchistory/source-adapters/dist/platforms/deepseek-harness.test.js.map +1 -0
  87. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.d.ts.map +1 -1
  88. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.js +14 -0
  89. package/node_modules/@cchistory/source-adapters/dist/platforms/generic/runtime.js.map +1 -1
  90. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.d.ts +4 -0
  91. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.d.ts.map +1 -0
  92. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.js +306 -0
  93. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/runtime.js.map +1 -0
  94. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.d.ts +8 -0
  95. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.d.ts.map +1 -0
  96. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.js +499 -0
  97. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes/sqlite.js.map +1 -0
  98. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.d.ts +9 -0
  99. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.d.ts.map +1 -0
  100. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.js +53 -0
  101. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.js.map +1 -0
  102. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.d.ts +2 -0
  103. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.d.ts.map +1 -0
  104. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.js +314 -0
  105. package/node_modules/@cchistory/source-adapters/dist/platforms/hermes.test.js.map +1 -0
  106. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.d.ts +9 -0
  107. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.d.ts.map +1 -0
  108. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.js +84 -0
  109. package/node_modules/@cchistory/source-adapters/dist/platforms/oh-my-pi.js.map +1 -0
  110. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.d.ts +50 -0
  111. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.d.ts.map +1 -0
  112. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.js +291 -0
  113. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite-records.js.map +1 -0
  114. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.d.ts +8 -0
  115. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.d.ts.map +1 -0
  116. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.js +321 -0
  117. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode/sqlite.js.map +1 -0
  118. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.d.ts +2 -0
  119. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.d.ts.map +1 -0
  120. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.js +245 -0
  121. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode-sqlite.test.js.map +1 -0
  122. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.d.ts.map +1 -1
  123. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.js +30 -7
  124. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.js.map +1 -1
  125. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.d.ts +44 -0
  126. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.d.ts.map +1 -0
  127. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.js +533 -0
  128. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/reader.js.map +1 -0
  129. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.d.ts +4 -0
  130. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.d.ts.map +1 -0
  131. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.js +375 -0
  132. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family/runtime.js.map +1 -0
  133. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.d.ts +2 -0
  134. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.d.ts.map +1 -0
  135. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.js +346 -0
  136. package/node_modules/@cchistory/source-adapters/dist/platforms/pi-family.test.js.map +1 -0
  137. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.d.ts +8 -0
  138. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.d.ts.map +1 -0
  139. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.js +60 -0
  140. package/node_modules/@cchistory/source-adapters/dist/platforms/pi.js.map +1 -0
  141. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.d.ts.map +1 -1
  142. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js +8 -0
  143. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js.map +1 -1
  144. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts +3 -1
  145. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts.map +1 -1
  146. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js +5 -1
  147. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js.map +1 -1
  148. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  149. package/package.json +5 -5
@@ -0,0 +1,499 @@
1
+ import { DatabaseSync } from "node:sqlite";
2
+ import { readBudgetedSqliteRows, SourceReadBudgetExceededError } from "../../core/read-budget.js";
3
+ import { asNumber, asString, isObject, safeJsonParse } from "../../core/type-guards.js";
4
+ /**
5
+ * Hermes Agent `state.db` reader.
6
+ *
7
+ * Hermes persists one SQLite store per profile (`$HERMES_HOME/state.db`,
8
+ * default `~/.hermes/state.db`, named profiles under
9
+ * `<root>/profiles/<name>/state.db`). Sessions, their full message rows,
10
+ * per-model usage aggregates and lineage markers all live in that store.
11
+ *
12
+ * The store is WAL-mode and may be written by a live gateway, so it is opened
13
+ * read-only inside one read transaction; every read runs under the adapter read
14
+ * budget.
15
+ */
16
+ const HERMES_CONTENT_JSON_PREFIX = "\x00json:";
17
+ const SESSION_LINEAGE_MARKERS = ["_delegate_from", "_branched_from", "_reset_from"];
18
+ const SYNTHETIC_USER_MARKERS = [
19
+ "Continue from the compressed conversation context above.",
20
+ "You've reached the maximum number of tool-calling iterations allowed.",
21
+ "[IMPORTANT: Background process ",
22
+ "[Your active task list was preserved across context compression]",
23
+ "[System:",
24
+ "[PRIOR CONTEXT",
25
+ "[Planning state preserved",
26
+ "[ASYNC DELEGATION",
27
+ "[OUT-OF-BAND",
28
+ "Cronjob Response:",
29
+ "[CONTEXT SUMMARY]:",
30
+ ];
31
+ const DISPLAY_ONLY_KINDS = new Set([
32
+ "failed_turn",
33
+ "internal_notification",
34
+ "process_complete",
35
+ "async_delegation_complete",
36
+ "content_refused",
37
+ ]);
38
+ const MERGED_SUMMARY_DELIMITER = "[END OF PRIOR CONTEXT — COMPACTION SUMMARY BELOW]";
39
+ const SUMMARY_END_MARKER = "--- END OF CONTEXT SUMMARY — respond to the message below, not the summary above ---";
40
+ const MERGED_PRIOR_CONTEXT_HEADER = "[PRIOR CONTEXT — for reference only; not a new message]";
41
+ export function extractHermesSqliteSeeds(dbPath, options = {}) {
42
+ const db = new DatabaseSync(dbPath, { readOnly: true });
43
+ let transactionOpen = false;
44
+ try {
45
+ const tables = new Set(db
46
+ .prepare("SELECT name FROM sqlite_master WHERE type = 'table'")
47
+ .all()
48
+ .map((row) => asString(row.name))
49
+ .filter((name) => name !== undefined));
50
+ if (!tables.has("sessions") || !tables.has("messages")) {
51
+ throw new Error(`Unrecognized Hermes Agent SQLite schema in ${dbPath}: expected sessions and messages tables.`);
52
+ }
53
+ const sessionColumns = tableColumns(db, "sessions");
54
+ const messageColumns = tableColumns(db, "messages");
55
+ requireColumns(sessionColumns, ["id"], "sessions", dbPath);
56
+ requireColumns(messageColumns, ["session_id", "role", "content", "timestamp"], "messages", dbPath);
57
+ const hasUsageTable = tables.has("session_model_usage");
58
+ const usageColumns = hasUsageTable ? tableColumns(db, "session_model_usage") : new Set();
59
+ db.exec("BEGIN");
60
+ transactionOpen = true;
61
+ const seeds = [];
62
+ for (const sessionRow of listSessions(db, sessionColumns, options)) {
63
+ const rawSessionId = asString(sessionRow.id);
64
+ if (!rawSessionId) {
65
+ continue;
66
+ }
67
+ const seed = buildSessionSeed(db, {
68
+ sessionRow,
69
+ rawSessionId,
70
+ sessionColumns,
71
+ messageColumns,
72
+ hasUsageTable,
73
+ usageColumns,
74
+ budget: options.budget,
75
+ });
76
+ if (seed) {
77
+ seeds.push(seed);
78
+ }
79
+ }
80
+ db.exec("COMMIT");
81
+ transactionOpen = false;
82
+ return seeds;
83
+ }
84
+ finally {
85
+ if (transactionOpen) {
86
+ try {
87
+ db.exec("ROLLBACK");
88
+ }
89
+ catch {
90
+ /* the connection is already unusable; close below still runs */
91
+ }
92
+ }
93
+ db.close();
94
+ }
95
+ }
96
+ function requireColumns(columns, required, table, dbPath) {
97
+ const missing = required.filter((column) => !columns.has(column));
98
+ if (missing.length > 0) {
99
+ throw new Error(`Unrecognized Hermes Agent SQLite schema in ${dbPath}: ${table} is missing ${missing.join(", ")}.`);
100
+ }
101
+ }
102
+ function matchesSessionRef(ref, rawSessionId) {
103
+ const canonical = `sess:hermes:${rawSessionId}`;
104
+ if (ref === canonical || ref === rawSessionId) {
105
+ return true;
106
+ }
107
+ // Only a canonical prefix may abbreviate, and it must name this platform.
108
+ return ref.startsWith("sess:hermes:") && canonical.startsWith(ref);
109
+ }
110
+ function tableColumns(db, table) {
111
+ return new Set(db
112
+ .prepare(`PRAGMA table_info(${table})`)
113
+ .all()
114
+ .map((row) => asString(row.name))
115
+ .filter((name) => name !== undefined));
116
+ }
117
+ const SESSION_SELECT_COLUMNS = [
118
+ "id",
119
+ "title",
120
+ "model",
121
+ "cwd",
122
+ "parent_session_id",
123
+ "started_at",
124
+ "ended_at",
125
+ "last_activity_at",
126
+ "message_count",
127
+ "input_tokens",
128
+ "output_tokens",
129
+ "cache_read_tokens",
130
+ "cache_write_tokens",
131
+ "reasoning_tokens",
132
+ "estimated_cost_usd",
133
+ "actual_cost_usd",
134
+ "model_config",
135
+ "source",
136
+ ];
137
+ function listSessions(db, columns, options) {
138
+ const selected = SESSION_SELECT_COLUMNS.filter((column) => columns.has(column));
139
+ const hiddenFilter = columns.has("hidden") ? " WHERE COALESCE(hidden, 0) <> 1" : "";
140
+ const query = `SELECT ${selected.join(", ")} FROM sessions${hiddenFilter} ORDER BY id`;
141
+ const rows = readBudgetedSqliteRows(db, query, selected, [], options.budget, "sessions rows");
142
+ const targetRefs = options.targetSessionRefs?.filter((ref) => ref.trim().length > 0) ?? [];
143
+ if (targetRefs.length === 0) {
144
+ return rows;
145
+ }
146
+ const matchedIds = new Set();
147
+ for (const row of rows) {
148
+ const id = asString(row.id);
149
+ if (id && targetRefs.some((ref) => matchesSessionRef(ref, id))) {
150
+ matchedIds.add(id);
151
+ }
152
+ }
153
+ // A parent target includes descendants linked by parent_session_id or
154
+ // model_config._delegate_from so family/related work stays resolvable.
155
+ let added = true;
156
+ while (added) {
157
+ added = false;
158
+ for (const row of rows) {
159
+ const id = asString(row.id);
160
+ if (!id || matchedIds.has(id)) {
161
+ continue;
162
+ }
163
+ const parentId = asString(row.parent_session_id);
164
+ const lineage = resolveLineage(row.model_config, id);
165
+ if ((parentId && matchedIds.has(parentId)) ||
166
+ (lineage.kind === "delegate" && lineage.parent && matchedIds.has(lineage.parent))) {
167
+ matchedIds.add(id);
168
+ added = true;
169
+ }
170
+ }
171
+ }
172
+ return rows.filter((row) => {
173
+ const id = asString(row.id);
174
+ return id !== undefined && matchedIds.has(id);
175
+ });
176
+ }
177
+ function buildSessionSeed(db, context) {
178
+ const { sessionRow, rawSessionId } = context;
179
+ const diagnostics = [];
180
+ const records = [];
181
+ const startedAt = epochSecondsIso(sessionRow.started_at);
182
+ const updatedAt = epochSecondsIso(sessionRow.last_activity_at) ??
183
+ epochSecondsIso(sessionRow.ended_at) ??
184
+ startedAt;
185
+ const title = asString(sessionRow.title)?.trim() || undefined;
186
+ const model = asString(sessionRow.model)?.trim() || undefined;
187
+ const workingDirectory = normalizeDirectory(asString(sessionRow.cwd));
188
+ const lineage = resolveLineage(sessionRow.model_config, rawSessionId);
189
+ records.push({
190
+ pointer: "sqlite:sessions",
191
+ observedAt: startedAt ?? updatedAt,
192
+ rawJson: JSON.stringify({
193
+ kind: "session",
194
+ id: rawSessionId,
195
+ title,
196
+ model,
197
+ cwd: workingDirectory,
198
+ parent_session_id: asString(sessionRow.parent_session_id),
199
+ lineage_kind: lineage.kind,
200
+ lineage_parent: lineage.parent,
201
+ source: asString(sessionRow.source),
202
+ started_at: startedAt,
203
+ ended_at: epochSecondsIso(sessionRow.ended_at),
204
+ message_count: asNumber(sessionRow.message_count),
205
+ }),
206
+ });
207
+ appendUsageRecords(db, context, records, diagnostics, startedAt ?? updatedAt);
208
+ for (const message of readMessages(db, context, diagnostics)) {
209
+ const messageId = asNumber(message.id);
210
+ const content = decodeContent(message.content, diagnostics, messageId);
211
+ const messageObservedAt = epochSecondsIso(message.timestamp) ?? updatedAt;
212
+ const role = asString(message.role);
213
+ const displayKind = asString(message.display_kind);
214
+ const summary = splitCompressedSummary(message, content, role);
215
+ records.push({
216
+ pointer: `sqlite:messages[${messageId ?? "?"}]`,
217
+ observedAt: messageObservedAt,
218
+ rawJson: JSON.stringify({
219
+ kind: "message",
220
+ id: messageId,
221
+ role,
222
+ content: summary ? summary.userContent : content,
223
+ ...(summary ? { summary_content: summary.summaryContent } : {}),
224
+ hidden: displayKind === "hidden" && !summary,
225
+ tool_call_id: asString(message.tool_call_id),
226
+ tool_name: asString(message.tool_name),
227
+ tool_calls: parseToolCalls(message.tool_calls),
228
+ finish_reason: asString(message.finish_reason),
229
+ reasoning: asString(message.reasoning) ?? asString(message.reasoning_content),
230
+ synthetic_user: summary !== undefined
231
+ ? String(summary.userContent ?? "").trim().length === 0
232
+ : isSyntheticUserMessage(message, content),
233
+ display_only: isDisplayOnlyRow(displayKind),
234
+ display_kind: displayKind,
235
+ timestamp: epochSecondsIso(message.timestamp),
236
+ }),
237
+ });
238
+ }
239
+ return {
240
+ sessionId: `sess:hermes:${rawSessionId}`,
241
+ ...(title ? { title } : {}),
242
+ ...(startedAt ? { createdAt: startedAt } : {}),
243
+ ...(updatedAt ? { updatedAt } : {}),
244
+ ...(model ? { model } : {}),
245
+ ...(workingDirectory ? { workingDirectory } : {}),
246
+ ...(diagnostics.length > 0 ? { diagnostics } : {}),
247
+ records,
248
+ };
249
+ }
250
+ function readMessages(db, context, diagnostics) {
251
+ const columns = context.messageColumns;
252
+ const selected = [
253
+ "id",
254
+ "role",
255
+ "content",
256
+ "tool_call_id",
257
+ "tool_calls",
258
+ "tool_name",
259
+ "timestamp",
260
+ "finish_reason",
261
+ "reasoning",
262
+ "reasoning_content",
263
+ "_compressed_summary",
264
+ "display_kind",
265
+ ].filter((column) => columns.has(column));
266
+ const filters = ["session_id = ?"];
267
+ if (columns.has("active")) {
268
+ filters.push("active = 1");
269
+ }
270
+ // Read `content` as raw UTF-8 bytes via CAST(... AS BLOB) because Node 22's
271
+ // node:sqlite truncates TEXT columns at the first NUL byte, erasing Hermes's
272
+ // `\x00json:` multimodal payloads.
273
+ const selectExprs = selected.map((column) => column === "content" ? "CAST(content AS BLOB) AS content" : column);
274
+ const order = columns.has("id") ? "id ASC" : "timestamp ASC, rowid ASC";
275
+ const query = `SELECT ${selectExprs.join(", ")} FROM messages WHERE ${filters.join(" AND ")} ORDER BY ${order}`;
276
+ try {
277
+ return readBudgetedSqliteRows(db, query, selected, [context.rawSessionId], context.budget, "messages rows");
278
+ }
279
+ catch (error) {
280
+ if (error instanceof SourceReadBudgetExceededError) {
281
+ throw error;
282
+ }
283
+ diagnostics.push({
284
+ code: "hermes_message_read_failed",
285
+ detail: `Could not read messages for session ${context.rawSessionId}: ${error.message}`,
286
+ });
287
+ return [];
288
+ }
289
+ }
290
+ function appendUsageRecords(db, context, records, diagnostics, lastMessageObservedAt) {
291
+ const { sessionRow, rawSessionId, hasUsageTable, usageColumns, budget } = context;
292
+ // Aggregate usage carries no turn identity. Keeping it at the session start
293
+ // places it before every submission group so canonical records turn_id null
294
+ // instead of attributing the whole session to the last reply.
295
+ const usageObservedAt = epochSecondsIso(sessionRow.started_at) ?? lastMessageObservedAt;
296
+ if (hasUsageTable) {
297
+ const selected = [
298
+ "model",
299
+ "billing_provider",
300
+ "task",
301
+ "api_call_count",
302
+ "input_tokens",
303
+ "output_tokens",
304
+ "cache_read_tokens",
305
+ "cache_write_tokens",
306
+ "reasoning_tokens",
307
+ "estimated_cost_usd",
308
+ "actual_cost_usd",
309
+ ].filter((column) => usageColumns.has(column));
310
+ if (selected.length > 0) {
311
+ try {
312
+ const rows = readBudgetedSqliteRows(db, `SELECT ${selected.join(", ")} FROM session_model_usage WHERE session_id = ? ORDER BY rowid ASC`, selected, [rawSessionId], budget, "session_model_usage rows");
313
+ for (const [index, row] of rows.entries()) {
314
+ records.push({
315
+ pointer: `sqlite:session_model_usage[${index}]`,
316
+ observedAt: usageObservedAt,
317
+ rawJson: JSON.stringify({
318
+ kind: "usage",
319
+ model: asString(row.model),
320
+ provider: asString(row.billing_provider),
321
+ task: asString(row.task),
322
+ api_calls: asNumber(row.api_call_count),
323
+ input_tokens: asNumber(row.input_tokens),
324
+ output_tokens: asNumber(row.output_tokens),
325
+ cache_read_tokens: asNumber(row.cache_read_tokens),
326
+ cache_write_tokens: asNumber(row.cache_write_tokens),
327
+ reasoning_tokens: asNumber(row.reasoning_tokens),
328
+ estimated_cost_usd: asNumber(row.estimated_cost_usd),
329
+ actual_cost_usd: asNumber(row.actual_cost_usd),
330
+ }),
331
+ });
332
+ }
333
+ if (rows.length > 0) {
334
+ return;
335
+ }
336
+ }
337
+ catch (error) {
338
+ if (error instanceof SourceReadBudgetExceededError) {
339
+ throw error;
340
+ }
341
+ diagnostics.push({
342
+ code: "hermes_usage_read_failed",
343
+ detail: `Could not read per-model usage for session ${rawSessionId}: ${error.message}`,
344
+ });
345
+ }
346
+ }
347
+ }
348
+ const sessionUsage = {
349
+ input_tokens: asNumber(sessionRow.input_tokens),
350
+ output_tokens: asNumber(sessionRow.output_tokens),
351
+ cache_read_tokens: asNumber(sessionRow.cache_read_tokens),
352
+ cache_write_tokens: asNumber(sessionRow.cache_write_tokens),
353
+ reasoning_tokens: asNumber(sessionRow.reasoning_tokens),
354
+ };
355
+ if (Object.values(sessionUsage).some((value) => value !== undefined && value > 0)) {
356
+ records.push({
357
+ pointer: "sqlite:sessions:usage",
358
+ observedAt: usageObservedAt,
359
+ rawJson: JSON.stringify({
360
+ kind: "usage",
361
+ model: asString(sessionRow.model),
362
+ provider: null,
363
+ task: null,
364
+ api_calls: null,
365
+ estimated_cost_usd: asNumber(sessionRow.estimated_cost_usd),
366
+ actual_cost_usd: asNumber(sessionRow.actual_cost_usd),
367
+ ...sessionUsage,
368
+ }),
369
+ });
370
+ }
371
+ }
372
+ function decodeContent(raw, diagnostics, messageId) {
373
+ const text = raw instanceof Uint8Array
374
+ ? Buffer.from(raw.buffer, raw.byteOffset, raw.byteLength).toString("utf8")
375
+ : typeof raw === "string"
376
+ ? raw
377
+ : undefined;
378
+ if (text === undefined) {
379
+ return raw ?? null;
380
+ }
381
+ if (!text.startsWith(HERMES_CONTENT_JSON_PREFIX)) {
382
+ return text;
383
+ }
384
+ const payload = text.slice(HERMES_CONTENT_JSON_PREFIX.length);
385
+ const parsed = safeJsonParse(payload);
386
+ if (parsed === undefined) {
387
+ diagnostics.push({
388
+ code: "hermes_content_decode_failed",
389
+ detail: `Message ${messageId ?? "?"} has a structured content marker that is not valid JSON; kept as the raw stored text.`,
390
+ });
391
+ // Upstream returns the original string, including the reserved prefix.
392
+ return text;
393
+ }
394
+ return parsed;
395
+ }
396
+ function parseToolCalls(raw) {
397
+ if (raw === null || raw === undefined) {
398
+ return null;
399
+ }
400
+ if (typeof raw !== "string") {
401
+ return raw;
402
+ }
403
+ if (!raw.trim()) {
404
+ return null;
405
+ }
406
+ const parsed = safeJsonParse(raw);
407
+ // Keep malformed non-empty strings so the runtime records hermes_tool_calls_malformed.
408
+ return parsed !== undefined ? parsed : raw;
409
+ }
410
+ function isDisplayOnlyRow(displayKind) {
411
+ return displayKind !== undefined && DISPLAY_ONLY_KINDS.has(displayKind);
412
+ }
413
+ function isSyntheticUserMessage(message, content) {
414
+ if (asString(message.role) !== "user") {
415
+ return false;
416
+ }
417
+ const text = contentToPlainText(content);
418
+ return text.length > 0 && SYNTHETIC_USER_MARKERS.some((marker) => text.startsWith(marker));
419
+ }
420
+ /**
421
+ * A merge-into-tail compaction carrier holds the real user turn followed by
422
+ * the compaction summary. Only the summary is synthetic; the prefix before the
423
+ * delimiter stays a user-authored submission.
424
+ */
425
+ function splitCompressedSummary(message, content, role) {
426
+ if (message._compressed_summary !== 1 && message._compressed_summary !== true) {
427
+ return undefined;
428
+ }
429
+ if (role !== "user") {
430
+ return undefined;
431
+ }
432
+ const text = contentToPlainText(content);
433
+ if (!text) {
434
+ return { userContent: "", summaryContent: "" };
435
+ }
436
+ if (text.includes(MERGED_SUMMARY_DELIMITER)) {
437
+ const [prefix, suffix] = text.split(MERGED_SUMMARY_DELIMITER, 2);
438
+ const userContent = (prefix ?? "").replace(MERGED_PRIOR_CONTEXT_HEADER, "").trim();
439
+ return { userContent, summaryContent: `${MERGED_SUMMARY_DELIMITER}${suffix ?? ""}` };
440
+ }
441
+ if (text.includes(SUMMARY_END_MARKER)) {
442
+ const [before, after] = text.split(SUMMARY_END_MARKER, 2);
443
+ return {
444
+ userContent: (after ?? "").trim(),
445
+ summaryContent: `${before ?? ""}${SUMMARY_END_MARKER}`,
446
+ };
447
+ }
448
+ return { userContent: "", summaryContent: text };
449
+ }
450
+ function contentToPlainText(content) {
451
+ if (typeof content === "string") {
452
+ return content.trim();
453
+ }
454
+ if (!Array.isArray(content)) {
455
+ return "";
456
+ }
457
+ return content
458
+ .map((item) => (isObject(item) && asString(item.type) === "text" ? asString(item.text) ?? "" : ""))
459
+ .join("\n")
460
+ .trim();
461
+ }
462
+ function resolveLineage(modelConfig, sessionId) {
463
+ const config = typeof modelConfig === "string" ? safeJsonParse(modelConfig) : modelConfig;
464
+ if (!isObject(config)) {
465
+ return { kind: undefined, parent: undefined };
466
+ }
467
+ for (const marker of SESSION_LINEAGE_MARKERS) {
468
+ const parent = asString(config[marker]);
469
+ if (parent) {
470
+ return {
471
+ kind: marker === "_delegate_from" ? "delegate" : marker === "_branched_from" ? "branch" : "reset",
472
+ parent,
473
+ };
474
+ }
475
+ }
476
+ return { kind: undefined, parent: undefined };
477
+ }
478
+ function normalizeDirectory(value) {
479
+ const trimmed = value?.trim();
480
+ if (!trimmed) {
481
+ return undefined;
482
+ }
483
+ return trimmed.replace(/\\/gu, "/").replace(/\/+$/u, "") || "/";
484
+ }
485
+ /**
486
+ * Hermes stores `time.time()` floats (seconds). Some imported databases carry
487
+ * milliseconds instead, so values past the 1973-in-milliseconds boundary are
488
+ * read as milliseconds.
489
+ */
490
+ function epochSecondsIso(value) {
491
+ const numeric = asNumber(value);
492
+ if (numeric === undefined || !Number.isFinite(numeric) || numeric <= 0) {
493
+ return undefined;
494
+ }
495
+ const millis = numeric > 1e11 ? numeric : numeric * 1000;
496
+ const date = new Date(millis);
497
+ return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
498
+ }
499
+ //# sourceMappingURL=sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../../../src/platforms/hermes/sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAyB,MAAM,2BAA2B,CAAC;AAEzH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAExF;;;;;;;;;;;GAWG;AAEH,MAAM,0BAA0B,GAAG,WAAW,CAAC;AAC/C,MAAM,uBAAuB,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,CAAU,CAAC;AAC7F,MAAM,sBAAsB,GAAG;IAC7B,0DAA0D;IAC1D,uEAAuE;IACvE,iCAAiC;IACjC,kEAAkE;IAClE,UAAU;IACV,gBAAgB;IAChB,2BAA2B;IAC3B,mBAAmB;IACnB,cAAc;IACd,mBAAmB;IACnB,oBAAoB;CACZ,CAAC;AACX,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,aAAa;IACb,uBAAuB;IACvB,kBAAkB;IAClB,2BAA2B;IAC3B,iBAAiB;CAClB,CAAC,CAAC;AACH,MAAM,wBAAwB,GAAG,mDAAmD,CAAC;AACrF,MAAM,kBAAkB,GAAG,sFAAsF,CAAC;AAClH,MAAM,2BAA2B,GAAG,yDAAyD,CAAC;AAa9F,MAAM,UAAU,wBAAwB,CACtC,MAAc,EACd,UAAmC,EAAE;IAErC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,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAyB;IACnD,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;AAClE,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QACvE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;IACzD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { PlatformAdapter } from "./types.js";
2
+ /**
3
+ * Hermes Agent keeps one SQLite store per profile: `$HERMES_HOME/state.db`
4
+ * (default `~/.hermes/state.db` on macOS/Linux, `%LOCALAPPDATA%/hermes` on
5
+ * Windows). Named profiles live under `<root>/profiles/<name>/state.db`, which
6
+ * the directory walk reaches from the root.
7
+ */
8
+ export declare const hermesAdapter: PlatformAdapter;
9
+ //# sourceMappingURL=hermes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hermes.d.ts","sourceRoot":"","sources":["../../src/platforms/hermes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,eA4C3B,CAAC"}
@@ -0,0 +1,53 @@
1
+ import path from "node:path";
2
+ /**
3
+ * Hermes Agent keeps one SQLite store per profile: `$HERMES_HOME/state.db`
4
+ * (default `~/.hermes/state.db` on macOS/Linux, `%LOCALAPPDATA%/hermes` on
5
+ * Windows). Named profiles live under `<root>/profiles/<name>/state.db`, which
6
+ * the directory walk reaches from the root.
7
+ */
8
+ export const hermesAdapter = {
9
+ platform: "hermes",
10
+ supportTier: "experimental",
11
+ // One store holds every session, so a targeted read filters rows rather than
12
+ // selecting a single native file.
13
+ sessionTargeting: "container",
14
+ projectionBoundary: "source",
15
+ getDefaultBaseDirCandidates: (options) => {
16
+ const env = options.env ?? process.env;
17
+ const candidates = [];
18
+ const hermesHome = env.HERMES_HOME?.trim();
19
+ if (hermesHome) {
20
+ candidates.push(hermesHome);
21
+ }
22
+ if (options.homeDir) {
23
+ candidates.push(path.join(options.homeDir, ".hermes"));
24
+ }
25
+ // Hermes uses %LOCALAPPDATA% on Windows; discovery's generic appDataDir is
26
+ // %APPDATA%/Roaming, so it must not stand in for Local.
27
+ if (options.platform === "win32" || env.LOCALAPPDATA) {
28
+ const localAppData = env.LOCALAPPDATA
29
+ ?? (options.homeDir ? path.join(options.homeDir, "AppData", "Local") : undefined);
30
+ if (localAppData) {
31
+ candidates.push(path.join(localAppData, "hermes"));
32
+ }
33
+ }
34
+ return candidates;
35
+ },
36
+ matchesSourceFile: (filePath) => path.basename(filePath) === "state.db",
37
+ getSourceRoots: (baseDir) => {
38
+ if (path.basename(baseDir) === "state.db") {
39
+ return [path.dirname(baseDir)];
40
+ }
41
+ return [baseDir];
42
+ },
43
+ filterSourceFiles: (files) => {
44
+ const unique = new Set(files.filter((filePath) => path.basename(filePath) === "state.db"));
45
+ return [...unique].sort((left, right) => left.localeCompare(right));
46
+ },
47
+ getSourceFilePriority: (filePath) => {
48
+ // A profile store is a narrower scope than the default profile; scanning
49
+ // the default store first keeps stable ordering for fixtures and reports.
50
+ return path.dirname(filePath).includes(`${path.sep}profiles${path.sep}`) ? 1 : 0;
51
+ },
52
+ };
53
+ //# sourceMappingURL=hermes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../src/platforms/hermes.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC5C,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,cAAc;IAC3B,6EAA6E;IAC7E,kCAAkC;IAClC,gBAAgB,EAAE,WAAW;IAC7B,kBAAkB,EAAE,QAAQ;IAC5B,2BAA2B,EAAE,CAAC,OAAO,EAAE,EAAE;QACvC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;QACvC,MAAM,UAAU,GAAa,EAAE,CAAC;QAChC,MAAM,UAAU,GAAG,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;QAC3C,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;QACzD,CAAC;QACD,2EAA2E;QAC3E,wDAAwD;QACxD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;YACrD,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY;mBAChC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,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