@tangle-network/harness-sessions 1.0.6 → 1.0.8
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/builder.d.ts +0 -13
- package/dist/builder.js +0 -17
- package/dist/capture.d.ts +0 -8
- package/dist/capture.js +3 -14
- package/dist/catalog.d.ts +16 -18
- package/dist/catalog.js +6 -20
- package/dist/cli.js +0 -1
- package/dist/formats/claude-code.d.ts +0 -1
- package/dist/formats/claude-code.js +2 -25
- package/dist/formats/claude-records.d.ts +0 -8
- package/dist/formats/claude-records.js +0 -6
- package/dist/formats/codex.js +2 -45
- package/dist/formats/factory.js +2 -19
- package/dist/formats/fold.d.ts +6 -2
- package/dist/formats/fold.js +16 -0
- package/dist/formats/grok.js +29 -30
- package/dist/formats/head.d.ts +0 -1
- package/dist/formats/head.js +0 -4
- package/dist/formats/hermes.d.ts +3 -0
- package/dist/formats/hermes.js +89 -0
- package/dist/formats/kimi.d.ts +0 -1
- package/dist/formats/kimi.js +2 -22
- package/dist/formats/nanoclaw.js +17 -27
- package/dist/formats/openclaw.d.ts +3 -0
- package/dist/formats/openclaw.js +98 -0
- package/dist/formats/opencode.d.ts +0 -1
- package/dist/formats/opencode.js +12 -31
- package/dist/formats/pi.d.ts +1 -1
- package/dist/formats/pi.js +5 -25
- package/dist/formats/prime.d.ts +2 -0
- package/dist/formats/prime.js +30 -0
- package/dist/formats/sandbox-events.d.ts +12 -0
- package/dist/formats/sandbox-events.js +69 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -0
- package/dist/input.d.ts +0 -6
- package/dist/input.js +0 -2
- package/dist/projections/chat.d.ts +0 -4
- package/dist/projections/chat.js +0 -1
- package/dist/projections/otlp.d.ts +0 -2
- package/dist/projections/otlp.js +0 -1
- package/dist/projections/turns.d.ts +0 -14
- package/dist/projections/turns.js +0 -3
- package/dist/registry.d.ts +0 -5
- package/dist/registry.js +4 -6
- package/dist/schema.d.ts +0 -39
- package/dist/source.d.ts +0 -11
- package/dist/source.js +0 -19
- package/dist/stores.d.ts +0 -4
- package/dist/stores.js +0 -5
- package/package.json +1 -1
package/dist/schema.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** One native session format. The id names the harness family and the on-disk layout. */
|
|
2
1
|
export type SessionFormatId = (typeof import('./catalog.js').SESSION_FORMAT_IDS)[number];
|
|
3
2
|
export interface NativeSessionStore {
|
|
4
3
|
root: string;
|
|
@@ -24,10 +23,8 @@ export interface TokenUsage {
|
|
|
24
23
|
cacheWrite: number | null;
|
|
25
24
|
}
|
|
26
25
|
export interface SessionError {
|
|
27
|
-
/** The harness's own classification: `api-error`, `stream_error`, a provider error name. */
|
|
28
26
|
kind: string;
|
|
29
27
|
message: string;
|
|
30
|
-
/** The provider's HTTP status when the harness recorded it. */
|
|
31
28
|
httpStatus: number | null;
|
|
32
29
|
at: string | null;
|
|
33
30
|
}
|
|
@@ -54,23 +51,19 @@ export interface SessionMessage {
|
|
|
54
51
|
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
55
52
|
actor: 'human' | 'agent' | 'subagent-spawn' | 'injected' | 'tool-result';
|
|
56
53
|
at: string | null;
|
|
57
|
-
/** The model call that produced an assistant message; null for every other message. */
|
|
58
54
|
modelCallId: string | null;
|
|
59
55
|
parts: Part[];
|
|
60
56
|
}
|
|
61
57
|
export interface SessionToolCall {
|
|
62
58
|
id: string;
|
|
63
59
|
name: string;
|
|
64
|
-
/** The arguments as structured data when the harness recorded JSON, otherwise the raw text. */
|
|
65
60
|
input: unknown;
|
|
66
|
-
/** The arguments exactly as the harness recorded them when it recorded text. */
|
|
67
61
|
inputText: string | null;
|
|
68
62
|
result: {
|
|
69
63
|
output: unknown;
|
|
70
64
|
text: string | null;
|
|
71
65
|
isError: boolean;
|
|
72
66
|
at: string | null;
|
|
73
|
-
/** The harness's own structured result (Claude Code `toolUseResult`, Pi `details`, OpenCode `metadata`). */
|
|
74
67
|
details: unknown;
|
|
75
68
|
} | null;
|
|
76
69
|
status: 'completed' | 'error' | 'pending' | 'interrupted';
|
|
@@ -82,12 +75,7 @@ export interface ModelCall {
|
|
|
82
75
|
id: string;
|
|
83
76
|
at: string | null;
|
|
84
77
|
provider: string | null;
|
|
85
|
-
/** The model that answered, from the provider response or the session record. Never the request. */
|
|
86
78
|
servedModel: string | null;
|
|
87
|
-
/**
|
|
88
|
-
* The model the harness sent the request to, when the session records it. A failed request has
|
|
89
|
-
* no served model; this says which model it was meant for. Never counted as served.
|
|
90
|
-
*/
|
|
91
79
|
requestedModel: string | null;
|
|
92
80
|
usage: TokenUsage | null;
|
|
93
81
|
costUsd: number | null;
|
|
@@ -105,9 +93,7 @@ export interface SessionIntegrity {
|
|
|
105
93
|
sha256: string;
|
|
106
94
|
bytes: number;
|
|
107
95
|
}>;
|
|
108
|
-
/** Records the reader could not parse. Never fatal in recover mode. */
|
|
109
96
|
unparsedRecords: number;
|
|
110
|
-
/** True when a source copy was cut short (a bounded capture kept only a prefix). */
|
|
111
97
|
truncated: boolean;
|
|
112
98
|
gaps: string[];
|
|
113
99
|
}
|
|
@@ -123,10 +109,8 @@ export interface HarnessSession {
|
|
|
123
109
|
messages: SessionMessage[];
|
|
124
110
|
toolCalls: SessionToolCall[];
|
|
125
111
|
modelCalls: ModelCall[];
|
|
126
|
-
/** `provider/model` (or the bare model when no provider is recorded) -> calls it answered. */
|
|
127
112
|
servedModels: Record<string, number>;
|
|
128
113
|
modelSource: SessionEvidenceSources['servedModel'];
|
|
129
|
-
/** Null when the harness recorded no usage at all. Never reported as zero. */
|
|
130
114
|
usage: TokenUsage | null;
|
|
131
115
|
ending: SessionEnding;
|
|
132
116
|
children: Array<{
|
|
@@ -135,18 +119,15 @@ export interface HarnessSession {
|
|
|
135
119
|
}>;
|
|
136
120
|
integrity: SessionIntegrity;
|
|
137
121
|
}
|
|
138
|
-
/** What `summarize` keeps: counts and the facts a gate needs, in constant memory. */
|
|
139
122
|
export interface SessionSummary {
|
|
140
123
|
harness: string;
|
|
141
124
|
format: SessionFormatId;
|
|
142
125
|
nativeSessionId: string;
|
|
143
126
|
parentNativeSessionId: string | null;
|
|
144
127
|
modelCalls: number;
|
|
145
|
-
/** Assistant messages the agent produced. */
|
|
146
128
|
replies: number;
|
|
147
129
|
toolCalls: number;
|
|
148
130
|
servedModels: Record<string, number>;
|
|
149
|
-
/** The served-model key (`provider/model`) of the last model call that a model answered. */
|
|
150
131
|
lastServedModel: string | null;
|
|
151
132
|
modelSource: HarnessSession['modelSource'];
|
|
152
133
|
usage: TokenUsage | null;
|
|
@@ -157,33 +138,25 @@ export interface SessionSummary {
|
|
|
157
138
|
startedAt: string | null;
|
|
158
139
|
endedAt: string | null;
|
|
159
140
|
}
|
|
160
|
-
/** One discovered session, before it is read. */
|
|
161
141
|
export interface SessionRef {
|
|
162
142
|
harness: string;
|
|
163
143
|
format: SessionFormatId;
|
|
164
144
|
nativeSessionId: string;
|
|
165
|
-
/** The session's primary file (the JSONL, or the SQLite store for a shared store). */
|
|
166
145
|
path: string;
|
|
167
|
-
/** Every file whose bytes the read depends on, including subagent files and SQLite siblings. */
|
|
168
146
|
files: readonly string[];
|
|
169
|
-
/** The HOME the session was found under, when it was located through a store. */
|
|
170
147
|
home: string | null;
|
|
171
148
|
cwd: string | null;
|
|
172
149
|
mtimeMs: number;
|
|
173
150
|
parentNativeSessionId: string | null;
|
|
174
|
-
/** True when the copy this ref points at is a bounded prefix of the session. */
|
|
175
151
|
truncated?: boolean;
|
|
176
152
|
}
|
|
177
153
|
export interface LocateOptions {
|
|
178
154
|
nativeSessionId?: string;
|
|
179
|
-
/** Sessions whose recorded cwd is this path or lies under it on a path boundary (`/x/agent` excludes `/x/agent-dev-container`). */
|
|
180
155
|
cwd?: string;
|
|
181
|
-
/** Sessions modified at or after this epoch ms. */
|
|
182
156
|
sinceMs?: number;
|
|
183
157
|
}
|
|
184
158
|
export interface ReadOptions {
|
|
185
159
|
signal?: AbortSignal;
|
|
186
|
-
/** `recover` (default) counts unparsable records; `strict` throws on the first one. */
|
|
187
160
|
corruption?: 'recover' | 'strict';
|
|
188
161
|
}
|
|
189
162
|
export interface HarnessSessionReader {
|
|
@@ -191,10 +164,6 @@ export interface HarnessSessionReader {
|
|
|
191
164
|
aliases: readonly string[];
|
|
192
165
|
formats: readonly SessionFormatId[];
|
|
193
166
|
stores: readonly NativeSessionStore[];
|
|
194
|
-
/**
|
|
195
|
-
* Default globs under each store's root, unless that store supplies its own globs: the session
|
|
196
|
-
* file and, when the harness writes subagent transcripts separately, those files.
|
|
197
|
-
*/
|
|
198
167
|
globs: {
|
|
199
168
|
session: string;
|
|
200
169
|
children?: string;
|
|
@@ -202,20 +171,16 @@ export interface HarnessSessionReader {
|
|
|
202
171
|
evidence: SessionEvidenceSources;
|
|
203
172
|
locate(home: string, opts?: LocateOptions): Promise<SessionRef[]>;
|
|
204
173
|
read(ref: SessionRef, opts?: ReadOptions): Promise<HarnessSession>;
|
|
205
|
-
/** Streams the session in constant memory with respect to message and tool-output size. */
|
|
206
174
|
summarize(ref: SessionRef, opts?: Pick<ReadOptions, 'signal'>): Promise<SessionSummary>;
|
|
207
175
|
}
|
|
208
|
-
/** One copy of a native session that the sidecar captured for an execution. */
|
|
209
176
|
export interface NativeSessionCopy {
|
|
210
177
|
harness: string;
|
|
211
178
|
format: SessionFormatId;
|
|
212
179
|
executionId: string;
|
|
213
180
|
attempt: number;
|
|
214
181
|
nativeSessionId: string;
|
|
215
|
-
/** `snapshot`: taken while the harness ran. `settled`: taken after it exited, however it ended. */
|
|
216
182
|
copy: 'snapshot' | 'settled';
|
|
217
183
|
capturedAt: string;
|
|
218
|
-
/** Null where the sidecar did not observe the value at the copy point. */
|
|
219
184
|
process: {
|
|
220
185
|
pid: number | null;
|
|
221
186
|
exitedAt: string | null;
|
|
@@ -223,11 +188,8 @@ export interface NativeSessionCopy {
|
|
|
223
188
|
signal: string | null;
|
|
224
189
|
};
|
|
225
190
|
files: Array<{
|
|
226
|
-
/** Path inside the archive, relative to the archive root. */
|
|
227
191
|
path: string;
|
|
228
|
-
/** The store root the file belongs to, relative to the runtime HOME. */
|
|
229
192
|
store: string;
|
|
230
|
-
/** The file's own path relative to the runtime HOME; the sidecar archive's payload names are flat. */
|
|
231
193
|
storePath?: string;
|
|
232
194
|
sizeBytes: number;
|
|
233
195
|
sha256: string;
|
|
@@ -237,7 +199,6 @@ export interface NativeSessionCopy {
|
|
|
237
199
|
complete: boolean;
|
|
238
200
|
missingReasons: string[];
|
|
239
201
|
}
|
|
240
|
-
/** The part of the sidecar's raw-evidence archive manifest this package reads. */
|
|
241
202
|
export interface RawEvidenceArchiveManifestV2 {
|
|
242
203
|
schema: 'tangle.raw-evidence-archive.v2';
|
|
243
204
|
nativeSessions: NativeSessionCopy[];
|
package/dist/source.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
/** What one source file contributed to a read: its identity and what could not be parsed. */
|
|
3
2
|
export interface SourceStats {
|
|
4
3
|
path: string;
|
|
5
4
|
sha256: string;
|
|
6
5
|
bytes: number;
|
|
7
6
|
unparsed: number;
|
|
8
|
-
/** The file ended without a newline and its last bytes were not a complete record. */
|
|
9
7
|
tornTail: boolean;
|
|
10
|
-
/** The line number (1-based) of the record most recently yielded. */
|
|
11
8
|
line: number;
|
|
12
|
-
/** Line numbers of the first unparsable lines (at most 50), for the gaps a reader reports. */
|
|
13
9
|
unparsedLines?: number[];
|
|
14
10
|
}
|
|
15
|
-
/** Records to fold, with the stats of the bytes they came from. */
|
|
16
11
|
export interface RecordSource {
|
|
17
12
|
stats: SourceStats;
|
|
18
13
|
records: AsyncIterable<Record<string, unknown>>;
|
|
@@ -22,26 +17,20 @@ export declare class SessionParseError extends Error {
|
|
|
22
17
|
readonly line: number;
|
|
23
18
|
constructor(path: string, line: number, reason: string);
|
|
24
19
|
}
|
|
25
|
-
/** 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. */
|
|
26
20
|
export declare function readJsonlRecords(path: string, stats: SourceStats, options?: {
|
|
27
21
|
strict?: boolean;
|
|
28
22
|
signal?: AbortSignal;
|
|
29
23
|
}): AsyncGenerator<Record<string, unknown>>;
|
|
30
24
|
export declare function newSourceStats(path: string): SourceStats;
|
|
31
|
-
/** The records of a JSONL file, streamed. */
|
|
32
25
|
export declare function fileRecords(path: string, options?: {
|
|
33
26
|
strict?: boolean;
|
|
34
27
|
signal?: AbortSignal;
|
|
35
28
|
}): RecordSource;
|
|
36
|
-
/** Stats for bytes already in memory. */
|
|
37
29
|
export declare function memoryStats(label: string, text?: string): SourceStats;
|
|
38
|
-
/** JSONL text already in memory. `firstLine` numbers its first line when the text continues a longer file. */
|
|
39
30
|
export declare function textRecordsSync(text: string, stats: SourceStats, options?: {
|
|
40
31
|
strict?: boolean;
|
|
41
32
|
firstLine?: number;
|
|
42
33
|
}): Generator<Record<string, unknown>>;
|
|
43
|
-
/** Records a caller already parsed (one per line, in order, the first on line `firstLine`). Non-objects count as unparsed. */
|
|
44
34
|
export declare function arrayRecordsSync(values: readonly unknown[], stats: SourceStats, firstLine?: number): Generator<Record<string, unknown>>;
|
|
45
|
-
/** 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. */
|
|
46
35
|
export declare function withSqlite<T>(path: string, use: (db: DatabaseSync) => T): Promise<T>;
|
|
47
36
|
export declare function isMissing(error: unknown): boolean;
|
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,10 +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
|
-
/** Every Codex home under `home`, by `CODEX_HOME_RULE`: `home` itself when it is one (a fleet seat's `codex` passed as a store root), `.codex` and each `.codex-<name>` in it, and each acct account home. `$CODEX_HOME` and `$ACCT_CONFIG` describe this process's own HOME, so they apply only when `home` is that HOME; another HOME (a store root, a capture) is read by its layout alone. Homes that resolve to one directory, such as an account home linked to `~/.codex`, count once. */
|
|
10
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,7 +66,6 @@ async function childDirs(dir) {
|
|
|
70
66
|
throw error;
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
|
-
/** Every Codex home under `home`, by `CODEX_HOME_RULE`: `home` itself when it is one (a fleet seat's `codex` passed as a store root), `.codex` and each `.codex-<name>` in it, and each acct account home. `$CODEX_HOME` and `$ACCT_CONFIG` describe this process's own HOME, so they apply only when `home` is that HOME; another HOME (a store root, a capture) is read by its layout alone. Homes that resolve to one directory, such as an account home linked to `~/.codex`, count once. */
|
|
74
69
|
export async function codexHomes(home) {
|
|
75
70
|
const own = resolve(home) === resolve(process.env.HOME || homedir());
|
|
76
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.
|
|
3
|
+
"version": "1.0.8",
|
|
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,
|