@tangle-network/harness-sessions 1.0.5 → 1.0.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.
Files changed (49) hide show
  1. package/dist/builder.d.ts +0 -24
  2. package/dist/builder.js +0 -28
  3. package/dist/capture.d.ts +0 -11
  4. package/dist/capture.js +3 -21
  5. package/dist/catalog.d.ts +16 -22
  6. package/dist/catalog.js +8 -26
  7. package/dist/cli.js +0 -8
  8. package/dist/formats/claude-code.d.ts +0 -1
  9. package/dist/formats/claude-code.js +0 -9
  10. package/dist/formats/claude-records.d.ts +0 -12
  11. package/dist/formats/claude-records.js +0 -10
  12. package/dist/formats/codex.js +0 -34
  13. package/dist/formats/factory.js +0 -3
  14. package/dist/formats/fold.d.ts +0 -5
  15. package/dist/formats/grok.js +12 -3
  16. package/dist/formats/head.d.ts +0 -7
  17. package/dist/formats/head.js +0 -10
  18. package/dist/formats/hermes.d.ts +3 -0
  19. package/dist/formats/hermes.js +93 -0
  20. package/dist/formats/kimi.d.ts +0 -1
  21. package/dist/formats/kimi.js +0 -6
  22. package/dist/formats/nanoclaw.d.ts +3 -0
  23. package/dist/formats/nanoclaw.js +65 -0
  24. package/dist/formats/openclaw.d.ts +3 -0
  25. package/dist/formats/openclaw.js +102 -0
  26. package/dist/formats/opencode.d.ts +0 -1
  27. package/dist/formats/opencode.js +0 -6
  28. package/dist/formats/pi.d.ts +1 -1
  29. package/dist/formats/pi.js +3 -9
  30. package/dist/formats/prime.d.ts +2 -0
  31. package/dist/formats/prime.js +35 -0
  32. package/dist/index.d.ts +4 -1
  33. package/dist/index.js +4 -0
  34. package/dist/input.d.ts +0 -10
  35. package/dist/input.js +0 -2
  36. package/dist/projections/chat.d.ts +0 -8
  37. package/dist/projections/chat.js +0 -5
  38. package/dist/projections/otlp.d.ts +0 -6
  39. package/dist/projections/otlp.js +0 -5
  40. package/dist/projections/turns.d.ts +0 -18
  41. package/dist/projections/turns.js +0 -7
  42. package/dist/registry.d.ts +0 -5
  43. package/dist/registry.js +5 -6
  44. package/dist/schema.d.ts +0 -39
  45. package/dist/source.d.ts +0 -11
  46. package/dist/source.js +0 -19
  47. package/dist/stores.d.ts +0 -10
  48. package/dist/stores.js +0 -11
  49. package/package.json +1 -1
package/dist/source.js CHANGED
@@ -23,7 +23,6 @@ export class SessionParseError extends Error {
23
23
  }
24
24
  }
25
25
  const NEWLINE = 0x0a;
26
- /** Stream one JSONL file in order and hash it. Unparsable lines count, or throw in strict mode. A torn tail is an unfinished last line, not corruption. */
27
26
  export async function* readJsonlRecords(path, stats, options = {}) {
28
27
  const hash = createHash('sha256');
29
28
  let pending = [];
@@ -109,19 +108,16 @@ export async function* readJsonlRecords(path, stats, options = {}) {
109
108
  export function newSourceStats(path) {
110
109
  return { path, sha256: '', bytes: 0, unparsed: 0, tornTail: false, line: 0 };
111
110
  }
112
- /** The records of a JSONL file, streamed. */
113
111
  export function fileRecords(path, options = {}) {
114
112
  const stats = newSourceStats(path);
115
113
  return { stats, records: readJsonlRecords(path, stats, options) };
116
114
  }
117
- /** Stats for bytes already in memory. */
118
115
  export function memoryStats(label, text) {
119
116
  if (text === undefined)
120
117
  return { path: label, sha256: '', bytes: 0, unparsed: 0, tornTail: false, line: 0 };
121
118
  const bytes = Buffer.from(text, 'utf8');
122
119
  return { path: label, sha256: `sha256:${createHash('sha256').update(bytes).digest('hex')}`, bytes: bytes.length, unparsed: 0, tornTail: false, line: 0 };
123
120
  }
124
- /** JSONL text already in memory. `firstLine` numbers its first line when the text continues a longer file. */
125
121
  export function* textRecordsSync(text, stats, options = {}) {
126
122
  const lines = text.split('\n');
127
123
  const first = options.firstLine ?? 1;
@@ -154,7 +150,6 @@ export function* textRecordsSync(text, stats, options = {}) {
154
150
  yield value;
155
151
  }
156
152
  }
157
- /** Records a caller already parsed (one per line, in order, the first on line `firstLine`). Non-objects count as unparsed. */
158
153
  export function* arrayRecordsSync(values, stats, firstLine = 1) {
159
154
  for (const [position, value] of values.entries()) {
160
155
  const index = firstLine - 1 + position;
@@ -166,8 +161,6 @@ export function* arrayRecordsSync(values, stats, firstLine = 1) {
166
161
  yield value;
167
162
  }
168
163
  }
169
- // `node:sqlite` is loaded through `createRequire`: bundlers rewrite a dynamic `import()` of a
170
- // `node:` builtin under some targets, and a require obtained this way is not analyzable by them.
171
164
  function loadSqlite() {
172
165
  const nodeRequire = createRequire(import.meta.url);
173
166
  return nodeRequire('node:sqlite');
@@ -183,15 +176,12 @@ async function exists(path) {
183
176
  throw error;
184
177
  }
185
178
  }
186
- /** Open a SQLite store read-only in place. A WAL uses `mode=ro` (committed tail, coordinates through `-shm`, never writes or checkpoints). No log uses `immutable=1` (no live connection, no new `-wal`/`-shm`). Throws when SQLite cannot read it there. */
187
179
  async function openSqlite(path) {
188
180
  const mode = (await exists(`${path}-wal`)) ? 'mode=ro' : 'immutable=1';
189
181
  const { DatabaseSync } = loadSqlite();
190
- // `readOnly` as well: a Node that treated the URI as a file name would fail to open, not create it.
191
182
  const db = new DatabaseSync(`${pathToFileURL(path).href}?${mode}`, { readOnly: true });
192
183
  try {
193
184
  db.exec('PRAGMA busy_timeout = 5000');
194
- // The first read opens the log and its index, so a store SQLite cannot read in place fails here.
195
185
  db.prepare('PRAGMA schema_version').get();
196
186
  return db;
197
187
  }
@@ -200,15 +190,11 @@ async function openSqlite(path) {
200
190
  throw error;
201
191
  }
202
192
  }
203
- /** SQLite's primary result code `SQLITE_CANTOPEN`, which `node:sqlite` errors carry in `errcode`. */
204
193
  function cannotOpen(error) {
205
194
  const code = error?.errcode;
206
195
  return typeof code === 'number' && (code & 0xff) === 14;
207
196
  }
208
- /** Run `use` on a store opened read-only in place. If SQLite cannot, read a private copy: a WAL with no `-shm` on read-only storage, or Node before 22.15 without URI file names. */
209
197
  export async function withSqlite(path, use) {
210
- // SQLite follows a symlinked store to its target and keeps the log there, so the log is looked
211
- // for there too. A missing store throws ENOENT here, which callers read as "no sessions".
212
198
  const store = await realpath(path);
213
199
  const db = await openSqlite(store).catch((error) => {
214
200
  if (cannotOpen(error))
@@ -224,9 +210,6 @@ export async function withSqlite(path, use) {
224
210
  db.close();
225
211
  }
226
212
  }
227
- // One private copy is kept per process: reading every session of a store SQLite cannot open in
228
- // place copies it once, not once per session. It is replaced when a different store, or a store
229
- // that changed, is read, and removed when the process exits.
230
213
  let current = null;
231
214
  function dropCopy() {
232
215
  if (current === null)
@@ -235,7 +218,6 @@ function dropCopy() {
235
218
  current.db.close();
236
219
  }
237
220
  catch {
238
- // already closed
239
221
  }
240
222
  rmSync(current.dir, { recursive: true, force: true });
241
223
  current = null;
@@ -256,7 +238,6 @@ async function storeKey(path) {
256
238
  }
257
239
  return `${path}|${parts.join('|')}`;
258
240
  }
259
- /** Run `use` on a private copy of the store and its `-wal`/`-shm`, opened writable so SQLite replays the log. `use` is synchronous. */
260
241
  async function withSqliteCopy(path, use) {
261
242
  const key = await storeKey(path);
262
243
  if (current?.key !== key) {
package/dist/stores.d.ts CHANGED
@@ -1,16 +1,6 @@
1
1
  export { assertStoreRoot, CODEX_HOME_RULE, EVIDENCE, isCodexHome, SESSION_FORMAT_IDS, STORES, storeGlob, withinPath } from './catalog.js';
2
- /** Regular files under `dir`; an optional matcher refuses selected unsafe entries before descent. */
3
2
  export declare function walkFiles(dir: string, signal?: AbortSignal, matches?: (path: string) => boolean): Promise<string[]>;
4
- /** Session files a locate reads at once: a store holds thousands, and each read waits on the disk. */
5
3
  export declare const LOCATE_READS = 32;
6
- /** `fn` over `items`, at most `limit` at a time, with the results in the order of `items`. */
7
4
  export declare function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]>;
8
5
  export declare function mtimeMs(path: string): Promise<number>;
9
- /**
10
- * Every Codex home under `home`, by `CODEX_HOME_RULE`: `home` itself when it is one (a fleet seat's
11
- * `codex` passed as a store root), `.codex` and each `.codex-<name>` in it, and each acct account
12
- * home. `$CODEX_HOME` and `$ACCT_CONFIG` describe this process's own HOME, so they apply only when
13
- * `home` is that HOME; another HOME (a store root, a capture) is read by its layout alone. Homes
14
- * that resolve to one directory, such as an account home linked to `~/.codex`, count once.
15
- */
16
6
  export declare function codexHomes(home: string): Promise<string[]>;
package/dist/stores.js CHANGED
@@ -4,7 +4,6 @@ import { join, relative, resolve, sep } from 'node:path';
4
4
  import { CODEX_HOME_RULE, isCodexHome } from './catalog.js';
5
5
  import { isMissing } from './source.js';
6
6
  export { assertStoreRoot, CODEX_HOME_RULE, EVIDENCE, isCodexHome, SESSION_FORMAT_IDS, STORES, storeGlob, withinPath } from './catalog.js';
7
- /** Regular files under `dir`; an optional matcher refuses selected unsafe entries before descent. */
8
7
  export async function walkFiles(dir, signal, matches) {
9
8
  const out = [];
10
9
  const visit = async (current) => {
@@ -33,9 +32,7 @@ export async function walkFiles(dir, signal, matches) {
33
32
  await visit(dir);
34
33
  return out.sort();
35
34
  }
36
- /** Session files a locate reads at once: a store holds thousands, and each read waits on the disk. */
37
35
  export const LOCATE_READS = 32;
38
- /** `fn` over `items`, at most `limit` at a time, with the results in the order of `items`. */
39
36
  export async function mapLimit(items, limit, fn) {
40
37
  const results = new Array(items.length);
41
38
  let next = 0;
@@ -59,7 +56,6 @@ export async function mtimeMs(path) {
59
56
  throw error;
60
57
  }
61
58
  }
62
- /** Names of the directories (or links to them) directly in `dir`. A missing dir has none. */
63
59
  async function childDirs(dir) {
64
60
  try {
65
61
  return (await readdir(dir, { withFileTypes: true })).filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => e.name).sort();
@@ -70,13 +66,6 @@ async function childDirs(dir) {
70
66
  throw error;
71
67
  }
72
68
  }
73
- /**
74
- * Every Codex home under `home`, by `CODEX_HOME_RULE`: `home` itself when it is one (a fleet seat's
75
- * `codex` passed as a store root), `.codex` and each `.codex-<name>` in it, and each acct account
76
- * home. `$CODEX_HOME` and `$ACCT_CONFIG` describe this process's own HOME, so they apply only when
77
- * `home` is that HOME; another HOME (a store root, a capture) is read by its layout alone. Homes
78
- * that resolve to one directory, such as an account home linked to `~/.codex`, count once.
79
- */
80
69
  export async function codexHomes(home) {
81
70
  const own = resolve(home) === resolve(process.env.HOME || homedir());
82
71
  const candidates = isCodexHome(home) ? [home] : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/harness-sessions",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "One reader for every coding-agent harness's native session (Claude Code, Codex, OpenCode, Pi): store layouts, a normalized session with messages, tool calls, served models, usage and ending errors, and projections to chat messages, OTLP spans and turns",
5
5
  "type": "module",
6
6
  "sideEffects": false,