@tangle-network/harness-sessions 0.2.1 → 0.4.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.
- package/README.md +7 -3
- package/dist/capture.js +5 -3
- package/dist/catalog.d.ts +118 -101
- package/dist/catalog.js +28 -85
- package/dist/cli.js +1 -1
- package/dist/formats/kimi.js +111 -48
- package/dist/schema.d.ts +12 -7
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npm install @tangle-network/harness-sessions
|
|
|
12
12
|
|
|
13
13
|
## Where this fits
|
|
14
14
|
|
|
15
|
-
- The sidecar's harness session contract (agent-container `packages/cli-agent-registry`)
|
|
15
|
+
- The catalog serves `STORES` and `SessionFormatId` for capture consumers. The sidecar's harness session contract (agent-container `packages/cli-agent-registry`) currently mirrors these declarations; its native-version adoption remains a separate consumer change.
|
|
16
16
|
- The capture path reads captures through `listCapture` / `readCapture`.
|
|
17
17
|
- Discovery's trace gate, agent-eval, agent-record and the blog read sessions only through this package.
|
|
18
18
|
- Its dependencies are `@tangle-network/agent-core`, `@tangle-network/agent-trace-contract` and Node built-ins (`node:sqlite` for OpenCode).
|
|
@@ -25,7 +25,7 @@ npm install @tangle-network/harness-sessions
|
|
|
25
25
|
| `codex` | `codex.rollout-jsonl` | `rollout-*-{id}.jsonl` under `sessions/` and `archived_sessions/` of every Codex home (below) | turn context (the configured model) | per response (`last_token_usage`); session total from `total_token_usage` |
|
|
26
26
|
| `opencode` | `opencode.sqlite` | `.local/share/opencode/opencode.db` (shared by every session) | session record (`providerID/modelID`) | per step (`step-finish`) |
|
|
27
27
|
| `pi` | `pi.session-jsonl` | `.pi/agent/sessions/**/*_{id}.jsonl` | session record (`provider/model`) | per assistant message |
|
|
28
|
-
| `kimi-code` | `kimi.session-dir` | `.kimi/sessions
|
|
28
|
+
| `kimi-code` | `kimi.session-dir` | `.kimi-code/sessions/wd_<hash>/{id}/agents/main/wire.jsonl`; retained `.kimi/sessions/*/{id}/wire.jsonl` and child wires | requested model recorded separately; served identity unknown | per step, excluding mirrored and wrapped child events |
|
|
29
29
|
| `factory-droids` | `factory.session-jsonl` | `.factory/sessions/*/{id}.jsonl` plus settings | configured model in settings (`turn-context`) | session total in settings |
|
|
30
30
|
|
|
31
31
|
A HOME can hold several Codex homes, and `codexReader.locate` reads all of them (`codexHomes(home)` lists them):
|
|
@@ -39,6 +39,10 @@ Homes that resolve to one directory count once. A session copied into several ho
|
|
|
39
39
|
|
|
40
40
|
`listReaders()` and the exported catalog own the complete installed format inventory.
|
|
41
41
|
|
|
42
|
+
Kimi uses the full `session_<uuid>` directory as its native ID, not the agent directory `main`. `kimiReader.stores` (also `KIMI_STORES` from the catalog entry) declares both layouts; the existing `STORES['kimi.session-dir']` remains the legacy declaration for consumers that still run that producer. A store's optional `globs` overrides the reader's default file globs, including when reading a v2 capture whose payload names are flat. No state or configuration sidecar is needed to read the current wire.
|
|
43
|
+
|
|
44
|
+
The current flat wire records prompts and loop steps alongside appended message snapshots, usage mirrors and a token-counting context summary. The fold takes prompt input and loop content/tools/step usage once; it preserves separately recorded injected user context. `llm.request` supplies `requestedModel`, without promoting configured or usage labels into served identity. Explicit native endings map completed to completed, cancelled/prompt-aborted to aborted, and failed/blocked to error; an assistant-looking prefix stays open. A later matching prompt ending preserves the turn's structured error. Unknown ending reasons stay open with an integrity gap. Recorded step counters of zero remain zero, while absent usage remains unknown. The retained fixture proves the completed and prefix cases; failure/abort mappings follow the official producer schema and await real failure captures. Nonzero accounting and new-format child-agent discovery remain unproved.
|
|
45
|
+
|
|
42
46
|
## Child execution evidence
|
|
43
47
|
|
|
44
48
|
Kimi records a child `agent_id` and `parent_tool_call_id` on each wrapped `SubagentEvent`, and writes the child's own wire under the parent's `subagents/<agent_id>/` directory. `kimiReader.locate(home, { nativeSessionId: parentId })` returns the parent and these child refs. A child-ID lookup selects that child. The reader keeps wrapped child events out of the parent's messages and usage; read each returned child ref for its own recorded work. `kimiRefForFile` preserves the same parent binding when a child wire is read directly. A missing child wire remains missing execution evidence, even when its ID appears in the parent.
|
|
@@ -87,5 +91,5 @@ harness-sessions read <file|home|capture> [--harness h] [--session id] [--summar
|
|
|
87
91
|
|
|
88
92
|
## Tests
|
|
89
93
|
|
|
90
|
-
The baseline fixtures are sessions that the real harness CLIs wrote while talking to the trace-proof scripted model; the tests assert that script. The Kimi child fixture retains complete existing parent and child wire records with all content removed, IDs pseudonymized, and source hashes, record counts, redaction version and token counters recorded in `test/fixtures/kimi/provenance.json`. Its integration test exercises discovery, full/summary reads, in-memory input and contract-span projection, preserving parent and child usage separately.
|
|
94
|
+
The baseline fixtures are sessions that the real harness CLIs wrote while talking to the trace-proof scripted model; the tests assert that script. The Kimi child fixture retains complete existing parent and child wire records with all content removed, IDs pseudonymized, and source hashes, record counts, redaction version and token counters recorded in `test/fixtures/kimi/provenance.json`. Its integration test exercises discovery, full/summary reads, in-memory input and contract-span projection, preserving parent and child usage separately. The current Kimi fixture in `test/fixtures/kimi2/` retains all 33 actual records through agent-eval's share pipeline and content minimization, with provenance alongside it. Its real-file integration covers both store layouts, direct-file CLI identity, v2 capture joins, projections, and incomplete prefixes without invoking a native harness or model.
|
|
91
95
|
The proof against the readers this package replaces is a comparison over stored sessions, recorded with each release.
|
package/dist/capture.js
CHANGED
|
@@ -47,7 +47,8 @@ async function fromV2(archiveDir, manifest, listing) {
|
|
|
47
47
|
listing.missing.push({ sandboxSessionId: null, harness: copy.harness, reason: 'no_reader_for_harness', nativeSessionId: copy.nativeSessionId });
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const stores = reader.stores.filter((s) => s.format === copy.format);
|
|
51
|
+
const store = stores.find((s) => copy.files.some((f) => storePathOf(f).includes(`${s.root}/`))) ?? stores[0] ?? reader.stores[0];
|
|
51
52
|
const inStore = (path) => {
|
|
52
53
|
const marker = `${store.root}/`;
|
|
53
54
|
const index = path.indexOf(marker);
|
|
@@ -75,8 +76,9 @@ async function fromV2(archiveDir, manifest, listing) {
|
|
|
75
76
|
}
|
|
76
77
|
continue;
|
|
77
78
|
}
|
|
78
|
-
const
|
|
79
|
-
const
|
|
79
|
+
const globs = store.globs ?? reader.globs;
|
|
80
|
+
const main = storeGlob(globs.session, copy.nativeSessionId);
|
|
81
|
+
const nested = globs.children ? [storeGlob(globs.children, copy.nativeSessionId)] : [];
|
|
80
82
|
const mainFile = copy.files.find((f) => { const rel = inStore(storePathOf(f)); return rel !== null && main.test(rel); });
|
|
81
83
|
if (!mainFile) {
|
|
82
84
|
listing.missing.push({ sandboxSessionId: null, harness: copy.harness, reason: 'native_session_file_missing', nativeSessionId: copy.nativeSessionId });
|
package/dist/catalog.d.ts
CHANGED
|
@@ -2,155 +2,172 @@ export declare const SESSION_FORMAT_IDS: readonly ["claude-code.projects-jsonl",
|
|
|
2
2
|
/** Store layouts, relative to the HOME a harness ran with. */
|
|
3
3
|
export declare const STORES: {
|
|
4
4
|
readonly 'claude-code.projects-jsonl': {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
format: "claude-code.projects-jsonl";
|
|
6
|
+
root: string;
|
|
7
|
+
files: readonly ["*/{id}.jsonl", "*/{id}/subagents/**/*.jsonl"];
|
|
8
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
9
|
+
shared: boolean;
|
|
10
10
|
};
|
|
11
11
|
readonly 'codex.rollout-jsonl': {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
format: "codex.rollout-jsonl";
|
|
13
|
+
root: string;
|
|
14
|
+
files: readonly ["*/*/*/rollout-*-{id}.jsonl"];
|
|
15
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
16
|
+
shared: boolean;
|
|
17
17
|
};
|
|
18
18
|
readonly 'opencode.sqlite': {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
format: "opencode.sqlite";
|
|
20
|
+
root: string;
|
|
21
|
+
files: readonly ["opencode.db", "opencode.db-wal", "opencode.db-shm"];
|
|
22
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
23
|
+
shared: boolean;
|
|
24
24
|
};
|
|
25
25
|
readonly 'pi.session-jsonl': {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
readonly
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
format: "pi.session-jsonl";
|
|
27
|
+
root: string;
|
|
28
|
+
files: readonly ["**/*_{id}.jsonl"];
|
|
29
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
30
|
+
shared: boolean;
|
|
31
31
|
};
|
|
32
32
|
readonly 'kimi.session-dir': {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
readonly
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
format: "kimi.session-dir";
|
|
34
|
+
root: string;
|
|
35
|
+
files: readonly ["*/{id}/**", "*/{id}.jsonl"];
|
|
36
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
37
|
+
shared: boolean;
|
|
38
38
|
};
|
|
39
39
|
readonly 'factory.session-jsonl': {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
readonly
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
format: "factory.session-jsonl";
|
|
41
|
+
root: string;
|
|
42
|
+
files: readonly ["*/{id}.jsonl", "*/{id}.settings.json"];
|
|
43
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
44
|
+
shared: boolean;
|
|
45
45
|
};
|
|
46
46
|
readonly 'gemini.chat-json': {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
readonly
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
format: "gemini.chat-json";
|
|
48
|
+
root: string;
|
|
49
|
+
files: readonly ["*/chats/session-*{id}*.json"];
|
|
50
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
51
|
+
shared: boolean;
|
|
52
52
|
};
|
|
53
53
|
readonly 'amp.thread-json': {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
readonly
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
format: "amp.thread-json";
|
|
55
|
+
root: string;
|
|
56
|
+
files: readonly ["{id}.json"];
|
|
57
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
58
|
+
shared: boolean;
|
|
59
59
|
};
|
|
60
60
|
readonly 'forge.sqlite': {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
readonly
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
format: "forge.sqlite";
|
|
62
|
+
root: string;
|
|
63
|
+
files: readonly [".forge.db", ".forge.db-wal", ".forge.db-shm"];
|
|
64
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
65
|
+
shared: boolean;
|
|
66
66
|
};
|
|
67
67
|
readonly 'hermes.state-sqlite': {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
readonly
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
format: "hermes.state-sqlite";
|
|
69
|
+
root: string;
|
|
70
|
+
files: readonly ["state.db", "state.db-wal", "state.db-shm"];
|
|
71
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
72
|
+
shared: boolean;
|
|
73
73
|
};
|
|
74
74
|
readonly 'prime.session-jsonl': {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
readonly
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
format: "prime.session-jsonl";
|
|
76
|
+
root: string;
|
|
77
|
+
files: readonly ["**/*_{id}.jsonl"];
|
|
78
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
79
|
+
shared: boolean;
|
|
80
80
|
};
|
|
81
81
|
readonly 'openclaw.session-jsonl': {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
readonly
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
format: "openclaw.session-jsonl";
|
|
83
|
+
root: string;
|
|
84
|
+
files: readonly ["**/{id}.jsonl"];
|
|
85
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
86
|
+
shared: boolean;
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
+
/** Kimi Code's current and retained legacy layouts; the legacy catalog entry stays stable. */
|
|
90
|
+
export declare const KIMI_STORES: readonly [{
|
|
91
|
+
readonly root: ".kimi-code/sessions";
|
|
92
|
+
readonly files: readonly ["wd_*/{id}/**"];
|
|
93
|
+
readonly globs: {
|
|
94
|
+
readonly session: "wd_*/{id}/agents/main/wire.jsonl";
|
|
95
|
+
};
|
|
96
|
+
readonly format: "kimi.session-dir";
|
|
97
|
+
readonly write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
98
|
+
readonly shared: boolean;
|
|
99
|
+
}, {
|
|
100
|
+
format: "kimi.session-dir";
|
|
101
|
+
root: string;
|
|
102
|
+
files: readonly ["*/{id}/**", "*/{id}.jsonl"];
|
|
103
|
+
write: "jsonl-append" | "json-rewrite" | "sqlite-wal";
|
|
104
|
+
shared: boolean;
|
|
105
|
+
}];
|
|
89
106
|
/**
|
|
90
107
|
* Where each format's served model, usage and ending error come from. `turn-context` means the
|
|
91
108
|
* model the harness was configured or asked for (Codex `turn_context`, OpenCode's message
|
|
92
|
-
* `modelID`, Factory's settings); `none` means
|
|
109
|
+
* `modelID`, Factory's settings); `none` means no served identity is proven by the records.
|
|
93
110
|
*/
|
|
94
111
|
export declare const EVIDENCE: {
|
|
95
112
|
readonly 'claude-code.projects-jsonl': {
|
|
96
|
-
readonly servedModel:
|
|
97
|
-
readonly usage:
|
|
98
|
-
readonly endingError:
|
|
113
|
+
readonly servedModel: "provider-response";
|
|
114
|
+
readonly usage: "per-response";
|
|
115
|
+
readonly endingError: "session-record";
|
|
99
116
|
};
|
|
100
117
|
readonly 'codex.rollout-jsonl': {
|
|
101
|
-
readonly servedModel:
|
|
102
|
-
readonly usage:
|
|
103
|
-
readonly endingError:
|
|
118
|
+
readonly servedModel: "turn-context";
|
|
119
|
+
readonly usage: "cumulative";
|
|
120
|
+
readonly endingError: "session-record";
|
|
104
121
|
};
|
|
105
122
|
readonly 'opencode.sqlite': {
|
|
106
|
-
readonly servedModel:
|
|
107
|
-
readonly usage:
|
|
108
|
-
readonly endingError:
|
|
123
|
+
readonly servedModel: "turn-context";
|
|
124
|
+
readonly usage: "per-response";
|
|
125
|
+
readonly endingError: "session-record";
|
|
109
126
|
};
|
|
110
127
|
readonly 'pi.session-jsonl': {
|
|
111
|
-
readonly servedModel:
|
|
112
|
-
readonly usage:
|
|
113
|
-
readonly endingError:
|
|
128
|
+
readonly servedModel: "session-record";
|
|
129
|
+
readonly usage: "per-response";
|
|
130
|
+
readonly endingError: "session-record";
|
|
114
131
|
};
|
|
115
132
|
readonly 'kimi.session-dir': {
|
|
116
|
-
readonly servedModel:
|
|
117
|
-
readonly usage:
|
|
118
|
-
readonly endingError:
|
|
133
|
+
readonly servedModel: "none";
|
|
134
|
+
readonly usage: "per-response";
|
|
135
|
+
readonly endingError: "session-record";
|
|
119
136
|
};
|
|
120
137
|
readonly 'factory.session-jsonl': {
|
|
121
|
-
readonly servedModel:
|
|
122
|
-
readonly usage:
|
|
123
|
-
readonly endingError:
|
|
138
|
+
readonly servedModel: "turn-context";
|
|
139
|
+
readonly usage: "session-total";
|
|
140
|
+
readonly endingError: "none";
|
|
124
141
|
};
|
|
125
142
|
readonly 'gemini.chat-json': {
|
|
126
|
-
readonly servedModel:
|
|
127
|
-
readonly usage:
|
|
128
|
-
readonly endingError:
|
|
143
|
+
readonly servedModel: "session-record";
|
|
144
|
+
readonly usage: "per-response";
|
|
145
|
+
readonly endingError: "none";
|
|
129
146
|
};
|
|
130
147
|
readonly 'amp.thread-json': {
|
|
131
|
-
readonly servedModel:
|
|
132
|
-
readonly usage:
|
|
133
|
-
readonly endingError:
|
|
148
|
+
readonly servedModel: "session-record";
|
|
149
|
+
readonly usage: "per-response";
|
|
150
|
+
readonly endingError: "none";
|
|
134
151
|
};
|
|
135
152
|
readonly 'forge.sqlite': {
|
|
136
|
-
readonly servedModel:
|
|
137
|
-
readonly usage:
|
|
138
|
-
readonly endingError:
|
|
153
|
+
readonly servedModel: "session-record";
|
|
154
|
+
readonly usage: "per-response";
|
|
155
|
+
readonly endingError: "none";
|
|
139
156
|
};
|
|
140
157
|
readonly 'hermes.state-sqlite': {
|
|
141
|
-
readonly servedModel:
|
|
142
|
-
readonly usage:
|
|
143
|
-
readonly endingError:
|
|
158
|
+
readonly servedModel: "session-record";
|
|
159
|
+
readonly usage: "session-total";
|
|
160
|
+
readonly endingError: "none";
|
|
144
161
|
};
|
|
145
162
|
readonly 'prime.session-jsonl': {
|
|
146
|
-
readonly servedModel:
|
|
147
|
-
readonly usage:
|
|
148
|
-
readonly endingError:
|
|
163
|
+
readonly servedModel: "session-record";
|
|
164
|
+
readonly usage: "per-response";
|
|
165
|
+
readonly endingError: "session-record";
|
|
149
166
|
};
|
|
150
167
|
readonly 'openclaw.session-jsonl': {
|
|
151
|
-
readonly servedModel:
|
|
152
|
-
readonly usage:
|
|
153
|
-
readonly endingError:
|
|
168
|
+
readonly servedModel: "session-record";
|
|
169
|
+
readonly usage: "per-response";
|
|
170
|
+
readonly endingError: "none";
|
|
154
171
|
};
|
|
155
172
|
};
|
|
156
173
|
/**
|
|
@@ -166,12 +183,12 @@ export declare const CODEX_HOME_RULE: {
|
|
|
166
183
|
/** Directory names directly under HOME that are Codex homes: `.codex` and `.codex-<name>`. */
|
|
167
184
|
readonly siblings: RegExp;
|
|
168
185
|
/** Under HOME, unless `$ACCT_CONFIG` names it: each child is one account's Codex home. */
|
|
169
|
-
readonly accounts:
|
|
170
|
-
readonly sessionDirs: readonly [
|
|
186
|
+
readonly accounts: ".config/agent-accounts/codex";
|
|
187
|
+
readonly sessionDirs: readonly ["sessions", "archived_sessions"];
|
|
171
188
|
/** A rollout's file name, at any depth under a session dir (`sessions/` nests by date). */
|
|
172
|
-
readonly rollout:
|
|
189
|
+
readonly rollout: "rollout-*.jsonl";
|
|
173
190
|
/** The name Codex gives a rollout, ending in its thread id. */
|
|
174
|
-
readonly named:
|
|
191
|
+
readonly named: "rollout-*-{id}.jsonl";
|
|
175
192
|
};
|
|
176
193
|
/**
|
|
177
194
|
* True when `dir` is itself a Codex home by its path: `.codex`, `.codex-<name>`, an acct account
|
package/dist/catalog.js
CHANGED
|
@@ -12,99 +12,42 @@ export const SESSION_FORMAT_IDS = [
|
|
|
12
12
|
'prime.session-jsonl',
|
|
13
13
|
'openclaw.session-jsonl',
|
|
14
14
|
];
|
|
15
|
+
/** One catalog declaration owns append-only defaults and shared SQLite copy semantics. */
|
|
16
|
+
function store(format, root, files, write = 'jsonl-append') {
|
|
17
|
+
return { format, root, files, write, shared: write === 'sqlite-wal' };
|
|
18
|
+
}
|
|
15
19
|
/** Store layouts, relative to the HOME a harness ran with. */
|
|
16
20
|
export const STORES = {
|
|
17
|
-
'claude-code.projects-jsonl':
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
'
|
|
25
|
-
root: '.codex/sessions',
|
|
26
|
-
files: ['*/*/*/rollout-*-{id}.jsonl'],
|
|
27
|
-
write: 'jsonl-append',
|
|
28
|
-
shared: false,
|
|
29
|
-
format: 'codex.rollout-jsonl',
|
|
30
|
-
},
|
|
31
|
-
'opencode.sqlite': {
|
|
32
|
-
root: '.local/share/opencode',
|
|
33
|
-
files: ['opencode.db', 'opencode.db-wal', 'opencode.db-shm'],
|
|
34
|
-
write: 'sqlite-wal',
|
|
35
|
-
shared: true,
|
|
36
|
-
format: 'opencode.sqlite',
|
|
37
|
-
},
|
|
38
|
-
'pi.session-jsonl': {
|
|
39
|
-
root: '.pi/agent/sessions',
|
|
40
|
-
files: ['**/*_{id}.jsonl'],
|
|
41
|
-
write: 'jsonl-append',
|
|
42
|
-
shared: false,
|
|
43
|
-
format: 'pi.session-jsonl',
|
|
44
|
-
},
|
|
21
|
+
'claude-code.projects-jsonl': store('claude-code.projects-jsonl', '.claude/projects', [
|
|
22
|
+
'*/{id}.jsonl', '*/{id}/subagents/**/*.jsonl',
|
|
23
|
+
]),
|
|
24
|
+
'codex.rollout-jsonl': store('codex.rollout-jsonl', '.codex/sessions', ['*/*/*/rollout-*-{id}.jsonl']),
|
|
25
|
+
'opencode.sqlite': store('opencode.sqlite', '.local/share/opencode', [
|
|
26
|
+
'opencode.db', 'opencode.db-wal', 'opencode.db-shm',
|
|
27
|
+
], 'sqlite-wal'),
|
|
28
|
+
'pi.session-jsonl': store('pi.session-jsonl', '.pi/agent/sessions', ['**/*_{id}.jsonl']),
|
|
45
29
|
// A session directory: wire.jsonl (the event stream read here), context.jsonl and its rotated
|
|
46
30
|
// context_N.jsonl copies, and state.json.
|
|
47
|
-
'kimi.session-dir': {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
'
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
write: 'jsonl-append',
|
|
58
|
-
shared: false,
|
|
59
|
-
format: 'factory.session-jsonl',
|
|
60
|
-
},
|
|
61
|
-
'gemini.chat-json': {
|
|
62
|
-
root: '.gemini/tmp',
|
|
63
|
-
files: ['*/chats/session-*{id}*.json'],
|
|
64
|
-
write: 'json-rewrite',
|
|
65
|
-
shared: false,
|
|
66
|
-
format: 'gemini.chat-json',
|
|
67
|
-
},
|
|
68
|
-
'amp.thread-json': {
|
|
69
|
-
root: '.local/share/amp/threads',
|
|
70
|
-
files: ['{id}.json'],
|
|
71
|
-
write: 'json-rewrite',
|
|
72
|
-
shared: false,
|
|
73
|
-
format: 'amp.thread-json',
|
|
74
|
-
},
|
|
75
|
-
'forge.sqlite': {
|
|
76
|
-
root: '.forge',
|
|
77
|
-
files: ['.forge.db', '.forge.db-wal', '.forge.db-shm'],
|
|
78
|
-
write: 'sqlite-wal',
|
|
79
|
-
shared: true,
|
|
80
|
-
format: 'forge.sqlite',
|
|
81
|
-
},
|
|
82
|
-
'hermes.state-sqlite': {
|
|
83
|
-
root: '.hermes',
|
|
84
|
-
files: ['state.db', 'state.db-wal', 'state.db-shm'],
|
|
85
|
-
write: 'sqlite-wal',
|
|
86
|
-
shared: true,
|
|
87
|
-
format: 'hermes.state-sqlite',
|
|
88
|
-
},
|
|
89
|
-
'prime.session-jsonl': {
|
|
90
|
-
root: '.prime-provider/prime-agent-dirs',
|
|
91
|
-
files: ['**/*_{id}.jsonl'],
|
|
92
|
-
write: 'jsonl-append',
|
|
93
|
-
shared: false,
|
|
94
|
-
format: 'prime.session-jsonl',
|
|
95
|
-
},
|
|
96
|
-
'openclaw.session-jsonl': {
|
|
97
|
-
root: '.openclaw/agents',
|
|
98
|
-
files: ['**/{id}.jsonl'],
|
|
99
|
-
write: 'jsonl-append',
|
|
100
|
-
shared: false,
|
|
101
|
-
format: 'openclaw.session-jsonl',
|
|
102
|
-
},
|
|
31
|
+
'kimi.session-dir': store('kimi.session-dir', '.kimi/sessions', ['*/{id}/**', '*/{id}.jsonl']),
|
|
32
|
+
'factory.session-jsonl': store('factory.session-jsonl', '.factory/sessions', [
|
|
33
|
+
'*/{id}.jsonl', '*/{id}.settings.json',
|
|
34
|
+
]),
|
|
35
|
+
'gemini.chat-json': store('gemini.chat-json', '.gemini/tmp', ['*/chats/session-*{id}*.json'], 'json-rewrite'),
|
|
36
|
+
'amp.thread-json': store('amp.thread-json', '.local/share/amp/threads', ['{id}.json'], 'json-rewrite'),
|
|
37
|
+
'forge.sqlite': store('forge.sqlite', '.forge', ['.forge.db', '.forge.db-wal', '.forge.db-shm'], 'sqlite-wal'),
|
|
38
|
+
'hermes.state-sqlite': store('hermes.state-sqlite', '.hermes', ['state.db', 'state.db-wal', 'state.db-shm'], 'sqlite-wal'),
|
|
39
|
+
'prime.session-jsonl': store('prime.session-jsonl', '.prime-provider/prime-agent-dirs', ['**/*_{id}.jsonl']),
|
|
40
|
+
'openclaw.session-jsonl': store('openclaw.session-jsonl', '.openclaw/agents', ['**/{id}.jsonl']),
|
|
103
41
|
};
|
|
42
|
+
/** Kimi Code's current and retained legacy layouts; the legacy catalog entry stays stable. */
|
|
43
|
+
export const KIMI_STORES = [
|
|
44
|
+
{ ...STORES['kimi.session-dir'], root: '.kimi-code/sessions', files: ['wd_*/{id}/**'], globs: { session: 'wd_*/{id}/agents/main/wire.jsonl' } },
|
|
45
|
+
STORES['kimi.session-dir'],
|
|
46
|
+
];
|
|
104
47
|
/**
|
|
105
48
|
* Where each format's served model, usage and ending error come from. `turn-context` means the
|
|
106
49
|
* model the harness was configured or asked for (Codex `turn_context`, OpenCode's message
|
|
107
|
-
* `modelID`, Factory's settings); `none` means
|
|
50
|
+
* `modelID`, Factory's settings); `none` means no served identity is proven by the records.
|
|
108
51
|
*/
|
|
109
52
|
export const EVIDENCE = {
|
|
110
53
|
'claude-code.projects-jsonl': { servedModel: 'provider-response', usage: 'per-response', endingError: 'session-record' },
|
package/dist/cli.js
CHANGED
|
@@ -38,7 +38,7 @@ function harnessOfFile(path) {
|
|
|
38
38
|
return 'codex';
|
|
39
39
|
if (/(^|\/)\.pi\/agent\/sessions\//u.test(path))
|
|
40
40
|
return 'pi';
|
|
41
|
-
if (/(^|\/)\.kimi
|
|
41
|
+
if (/(^|\/)\.kimi(?:-code)?\/sessions\/.+\/wire\.jsonl$/u.test(path))
|
|
42
42
|
return 'kimi-code';
|
|
43
43
|
if (/(^|\/)\.factory\/sessions\//u.test(path))
|
|
44
44
|
return 'factory-droids';
|
package/dist/formats/kimi.js
CHANGED
|
@@ -9,34 +9,40 @@ import { isRecord } from '@tangle-network/agent-core';
|
|
|
9
9
|
* (`token_usage`: `input_other`, `output`, `input_cache_read`, `input_cache_creation`, disjoint,
|
|
10
10
|
* and the provider's `message_id`) follow. `ToolResult` answers a call. `StepRetry` is a failed
|
|
11
11
|
* attempt with the provider's status code; `StepInterrupted` ends a step without an answer. A
|
|
12
|
-
* subagent's events arrive wrapped in `SubagentEvent`. The wire records no model.
|
|
12
|
+
* subagent's events arrive wrapped in `SubagentEvent`. The legacy wire records no model.
|
|
13
|
+
* Current `.kimi-code/sessions/wd_<hash>/session_<uuid>/agents/main/wire.jsonl` records are flat:
|
|
14
|
+
* turn prompts and loop events own messages, tools and step usage. Appended message snapshots,
|
|
15
|
+
* usage records and token-counting totals mirror that work, so are not counted again. Request
|
|
16
|
+
* metadata names the requested model; a completed native turn is required to prove completion.
|
|
13
17
|
*/
|
|
14
18
|
import { basename, dirname, join } from 'node:path';
|
|
15
19
|
import { SessionBuilder, count, sessionError, str, textOf, usageOrNull } from '../builder.js';
|
|
16
20
|
import { fileRecords } from '../source.js';
|
|
17
|
-
import {
|
|
21
|
+
import { KIMI_STORES } from '../catalog.js';
|
|
22
|
+
import { EVIDENCE, mtimeMs, storeGlob, walkFiles, withinPath } from '../stores.js';
|
|
18
23
|
import { runFold } from './fold.js';
|
|
19
24
|
const FORMAT = 'kimi.session-dir';
|
|
20
|
-
const STORE = STORES[FORMAT];
|
|
21
25
|
const HARNESS = 'kimi-code';
|
|
22
26
|
/** The event stream this reader folds; the store also holds context.jsonl and state.json. */
|
|
23
27
|
const WIRE = '*/{id}/wire.jsonl';
|
|
24
28
|
const CHILD_WIRE = '*/*/subagents/{id}/wire.jsonl';
|
|
25
|
-
/**
|
|
29
|
+
/** Current main agents belong to session_<uuid>; legacy child wires retain their own agent IDs. */
|
|
26
30
|
function sessionIdentity(path) {
|
|
27
31
|
const directory = dirname(path);
|
|
28
32
|
const container = dirname(directory);
|
|
33
|
+
if (basename(container) === 'agents' && basename(directory) === 'main')
|
|
34
|
+
return { id: basename(dirname(container)), parent: null };
|
|
29
35
|
return { id: basename(directory), parent: basename(container) === 'subagents' ? basename(dirname(container)) : null };
|
|
30
36
|
}
|
|
31
37
|
function usageOf(value) {
|
|
32
38
|
if (!isRecord(value))
|
|
33
39
|
return null;
|
|
34
40
|
return usageOrNull({
|
|
35
|
-
input: count(value.input_other),
|
|
41
|
+
input: count(value.input_other ?? value.inputOther),
|
|
36
42
|
output: count(value.output),
|
|
37
43
|
reasoning: null,
|
|
38
|
-
cacheRead: count(value.input_cache_read),
|
|
39
|
-
cacheWrite: count(value.input_cache_creation),
|
|
44
|
+
cacheRead: count(value.input_cache_read ?? value.inputCacheRead),
|
|
45
|
+
cacheWrite: count(value.input_cache_creation ?? value.inputCacheCreation),
|
|
40
46
|
});
|
|
41
47
|
}
|
|
42
48
|
export function createFold(ref, mode, stats) {
|
|
@@ -48,6 +54,10 @@ export function createFold(ref, mode, stats) {
|
|
|
48
54
|
let aborted = null;
|
|
49
55
|
let compactions = 0;
|
|
50
56
|
let subagentEvents = 0;
|
|
57
|
+
let flat = false;
|
|
58
|
+
let promptId = null;
|
|
59
|
+
let nativeEnding = { status: 'open', error: null, at: null };
|
|
60
|
+
let nativeReason = null;
|
|
51
61
|
const openStep = (at) => {
|
|
52
62
|
if (step)
|
|
53
63
|
return step;
|
|
@@ -64,42 +74,68 @@ export function createFold(ref, mode, stats) {
|
|
|
64
74
|
lastToolCall = null;
|
|
65
75
|
};
|
|
66
76
|
const observe = (record) => {
|
|
67
|
-
const message = isRecord(record.message) ? record.message :
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const payload = isRecord(message.payload) ? message.payload : {};
|
|
72
|
-
const
|
|
77
|
+
const message = isRecord(record.message) ? record.message : {};
|
|
78
|
+
const outer = str(record.type);
|
|
79
|
+
// Both protocols have metadata; only flat payload events use namespaced discriminators.
|
|
80
|
+
flat ||= outer?.includes('.') === true;
|
|
81
|
+
const payload = outer === 'context.append_loop_event' && isRecord(record.event) ? record.event : outer ? record : isRecord(message.payload) ? message.payload : {};
|
|
82
|
+
const type = outer === 'context.append_loop_event' ? str(payload.type) : outer ?? str(message.type);
|
|
83
|
+
const at = builder.seen(record.time ?? record.timestamp ?? record.created_at);
|
|
73
84
|
if (type !== 'ToolCallPart')
|
|
74
85
|
flushToolArguments();
|
|
75
86
|
switch (type) {
|
|
87
|
+
case 'profile.bind':
|
|
88
|
+
if (isRecord(payload.environmentDisclosure))
|
|
89
|
+
builder.cwd = str(payload.environmentDisclosure.cwd);
|
|
90
|
+
break;
|
|
91
|
+
case 'turn.prompt':
|
|
76
92
|
case 'TurnBegin': {
|
|
77
93
|
turn += 1;
|
|
78
94
|
step = null;
|
|
79
95
|
aborted = null;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
96
|
+
promptId = str(payload.promptId);
|
|
97
|
+
nativeEnding = { status: 'open', error: null, at: null };
|
|
98
|
+
nativeReason = null;
|
|
99
|
+
const text = textOf(payload.user_input ?? payload.input);
|
|
100
|
+
const parts = text === null ? [] : [{ type: 'text', text }];
|
|
84
101
|
builder.message({ id: `${builder.nativeSessionId}:turn:${turn}:input`, role: 'user', actor: ref.parentNativeSessionId ? 'subagent-spawn' : 'human', at, modelCallId: null, parts });
|
|
85
102
|
break;
|
|
86
103
|
}
|
|
104
|
+
case 'context.append_message': {
|
|
105
|
+
const value = isRecord(payload.message) ? payload.message : {};
|
|
106
|
+
if (value.role !== 'user' || (promptId !== null && value.id === promptId))
|
|
107
|
+
break;
|
|
108
|
+
const origin = isRecord(value.origin) ? value.origin : {};
|
|
109
|
+
const text = textOf(value.content);
|
|
110
|
+
builder.message({ id: str(value.id) ?? `${builder.nativeSessionId}:context:${stats.line}`, role: 'user', actor: origin.kind === 'user' ? 'human' : 'injected', at, modelCallId: null, parts: text === null ? [] : [{ type: 'text', text }] });
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case 'llm.request': {
|
|
114
|
+
const current = openStep(at);
|
|
115
|
+
current.call.requestedModel = str(payload.model);
|
|
116
|
+
current.call.provider = str(payload.provider);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case 'step.begin':
|
|
87
120
|
case 'StepBegin':
|
|
88
121
|
step = null;
|
|
89
122
|
openStep(at);
|
|
90
123
|
break;
|
|
124
|
+
case 'content.part':
|
|
91
125
|
case 'ContentPart': {
|
|
92
126
|
const current = openStep(at);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
127
|
+
const part = isRecord(payload.part) ? payload.part : payload;
|
|
128
|
+
if (part.type === 'think')
|
|
129
|
+
builder.appendParts(current.messageId, [{ type: 'reasoning', text: str(part.think) ?? '', redacted: part.encrypted != null && !part.think }]);
|
|
130
|
+
else if (typeof part.text === 'string')
|
|
131
|
+
builder.appendParts(current.messageId, [{ type: 'text', text: part.text }]);
|
|
97
132
|
break;
|
|
98
133
|
}
|
|
134
|
+
case 'tool.call':
|
|
99
135
|
case 'ToolCall': {
|
|
100
136
|
const current = openStep(at);
|
|
101
|
-
const fn = isRecord(payload.function) ? payload.function : {};
|
|
102
|
-
const id = str(payload.id) ?? `${builder.nativeSessionId}:call:${stats.line}`;
|
|
137
|
+
const fn = isRecord(payload.function) ? payload.function : { name: payload.name, arguments: payload.args };
|
|
138
|
+
const id = str(payload.id) ?? str(payload.toolCallId) ?? `${builder.nativeSessionId}:call:${stats.line}`;
|
|
103
139
|
const text = typeof fn.arguments === 'string' ? fn.arguments : JSON.stringify(fn.arguments ?? {});
|
|
104
140
|
builder.appendParts(current.messageId, [{ type: 'tool-call', toolCallId: id }]);
|
|
105
141
|
builder.toolCall({ id, name: str(fn.name) ?? 'unknown', input: null, inputText: text, at, messageId: current.messageId });
|
|
@@ -110,20 +146,24 @@ export function createFold(ref, mode, stats) {
|
|
|
110
146
|
if (lastToolCall && typeof payload.arguments_part === 'string')
|
|
111
147
|
lastToolCall.text += payload.arguments_part;
|
|
112
148
|
break;
|
|
149
|
+
case 'tool.result':
|
|
113
150
|
case 'ToolResult': {
|
|
114
|
-
const id = str(payload.tool_call_id) ?? '';
|
|
115
|
-
const value = isRecord(payload.return_value) ? payload.return_value : {};
|
|
151
|
+
const id = str(payload.tool_call_id) ?? str(payload.toolCallId) ?? '';
|
|
152
|
+
const value = isRecord(payload.return_value) ? payload.return_value : isRecord(payload.result) ? payload.result : {};
|
|
116
153
|
const resultId = `${id}:result`;
|
|
117
154
|
builder.message({ id: resultId, role: 'tool', actor: 'tool-result', at, modelCallId: null, parts: [{ type: 'tool-result', toolCallId: id }] });
|
|
118
155
|
builder.toolResult(id, { output: value.output ?? null, text: typeof value.output === 'string' ? value.output : textOf(value.output), isError: value.is_error === true, at, messageId: resultId, details: value });
|
|
119
156
|
break;
|
|
120
157
|
}
|
|
158
|
+
case 'step.end':
|
|
121
159
|
case 'StatusUpdate': {
|
|
122
|
-
const usage = usageOf(payload.token_usage);
|
|
160
|
+
const usage = usageOf(payload.token_usage ?? payload.usage);
|
|
123
161
|
if (usage === null)
|
|
124
162
|
break;
|
|
125
163
|
const current = openStep(at);
|
|
126
164
|
current.call.usage = usage;
|
|
165
|
+
if (type === 'step.end')
|
|
166
|
+
current.call.stopReason = str(payload.finishReason);
|
|
127
167
|
break;
|
|
128
168
|
}
|
|
129
169
|
case 'StepRetry': {
|
|
@@ -142,6 +182,19 @@ export function createFold(ref, mode, stats) {
|
|
|
142
182
|
case 'TurnEnd':
|
|
143
183
|
step = null;
|
|
144
184
|
break;
|
|
185
|
+
case 'turn.ended':
|
|
186
|
+
case 'prompt.completed':
|
|
187
|
+
case 'prompt.aborted': {
|
|
188
|
+
const reason = type === 'prompt.aborted' ? 'cancelled' : str(payload.reason);
|
|
189
|
+
const status = reason === 'completed' ? 'completed' : reason === 'cancelled' ? 'aborted' : reason === 'failed' || reason === 'blocked' ? 'error' : 'open';
|
|
190
|
+
const endedAt = builder.seen(payload.abortedAt ?? payload.finishedAt) ?? at;
|
|
191
|
+
const error = isRecord(payload.error) && typeof payload.error.code === 'string' && typeof payload.error.message === 'string' ? { kind: payload.error.code, message: payload.error.message, httpStatus: null, at: endedAt } : reason === nativeReason ? nativeEnding.error : null;
|
|
192
|
+
nativeEnding = { status, error, at: status === 'open' ? null : endedAt };
|
|
193
|
+
nativeReason = reason;
|
|
194
|
+
if (status === 'open')
|
|
195
|
+
builder.gap('Native ending reason is unknown');
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
145
198
|
case 'CompactionBegin':
|
|
146
199
|
compactions += 1;
|
|
147
200
|
break;
|
|
@@ -159,11 +212,16 @@ export function createFold(ref, mode, stats) {
|
|
|
159
212
|
const finish = () => {
|
|
160
213
|
flushToolArguments();
|
|
161
214
|
builder.source(stats);
|
|
215
|
+
if (ref.truncated)
|
|
216
|
+
builder.markTruncated(`${ref.path}: the session copy was cut short`);
|
|
162
217
|
if (compactions > 0)
|
|
163
218
|
builder.gap(`${compactions} compactions replaced earlier context`);
|
|
164
219
|
if (subagentEvents > 0)
|
|
165
220
|
builder.gap(`${subagentEvents} wrapped subagent events were excluded from this session's own messages and usage; separate child wires must be read for child execution`);
|
|
166
|
-
|
|
221
|
+
if (flat)
|
|
222
|
+
builder.end(nativeEnding);
|
|
223
|
+
else
|
|
224
|
+
builder.inferEnding(aborted ? { at: aborted.at, error: null } : undefined);
|
|
167
225
|
return builder;
|
|
168
226
|
};
|
|
169
227
|
return { builder, observe, finish };
|
|
@@ -172,27 +230,32 @@ export async function fold(ref, mode, options, source = fileRecords(ref.path, {
|
|
|
172
230
|
return runFold(createFold(ref, mode, source.stats), source);
|
|
173
231
|
}
|
|
174
232
|
async function locate(home, opts) {
|
|
175
|
-
const root = join(home, STORE.root);
|
|
176
|
-
const pattern = storeGlob(WIRE);
|
|
177
|
-
const children = storeGlob(CHILD_WIRE);
|
|
178
233
|
const refs = [];
|
|
179
|
-
for (const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
234
|
+
for (const store of KIMI_STORES) {
|
|
235
|
+
const root = join(home, store.root);
|
|
236
|
+
const pattern = storeGlob('globs' in store ? store.globs.session : WIRE);
|
|
237
|
+
const children = storeGlob(CHILD_WIRE);
|
|
238
|
+
for (const rel of await walkFiles(root)) {
|
|
239
|
+
if (!pattern.test(rel) && !children.test(rel))
|
|
240
|
+
continue;
|
|
241
|
+
const { id, parent } = sessionIdentity(rel);
|
|
242
|
+
// A parent lookup includes its recorded child wires; a child lookup selects that agent.
|
|
243
|
+
if (opts.nativeSessionId && id !== opts.nativeSessionId && parent !== opts.nativeSessionId)
|
|
244
|
+
continue;
|
|
245
|
+
const path = join(root, rel);
|
|
246
|
+
const mtime = await mtimeMs(path);
|
|
247
|
+
if (opts.sinceMs && mtime < opts.sinceMs)
|
|
248
|
+
continue;
|
|
249
|
+
const context = join(dirname(path), 'context.jsonl');
|
|
250
|
+
const files = (await mtimeMs(context)) > 0 ? [path, context] : [path];
|
|
251
|
+
const ref = { harness: HARNESS, format: FORMAT, nativeSessionId: id, path, files, home, cwd: null, mtimeMs: mtime, parentNativeSessionId: parent };
|
|
252
|
+
if (opts.cwd) {
|
|
253
|
+
ref.cwd = (await fold(ref, 'summary', {})).cwd;
|
|
254
|
+
if (ref.cwd === null || !withinPath(ref.cwd, opts.cwd))
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
refs.push(ref);
|
|
258
|
+
}
|
|
196
259
|
}
|
|
197
260
|
return refs.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
198
261
|
}
|
|
@@ -200,7 +263,7 @@ export const kimiReader = {
|
|
|
200
263
|
harness: HARNESS,
|
|
201
264
|
aliases: ['kimi', 'kimi-cli'],
|
|
202
265
|
formats: [FORMAT],
|
|
203
|
-
stores:
|
|
266
|
+
stores: KIMI_STORES,
|
|
204
267
|
globs: { session: WIRE, children: CHILD_WIRE },
|
|
205
268
|
evidence: EVIDENCE[FORMAT],
|
|
206
269
|
locate: (home, opts = {}) => locate(home, opts),
|
package/dist/schema.d.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* blog.
|
|
9
9
|
*/
|
|
10
10
|
/** One native session format. The id names the harness family and the on-disk layout. */
|
|
11
|
-
export type SessionFormatId =
|
|
11
|
+
export type SessionFormatId = (typeof import('./catalog.js').SESSION_FORMAT_IDS)[number];
|
|
12
12
|
/**
|
|
13
|
-
* Where a harness keeps its sessions, relative to the HOME it ran with.
|
|
14
|
-
*
|
|
13
|
+
* Where a harness keeps its sessions, relative to the HOME it ran with. Capture consumers can
|
|
14
|
+
* share these declarations; consumer adoption of a producer layout is a separate change.
|
|
15
15
|
*/
|
|
16
16
|
export interface NativeSessionStore {
|
|
17
17
|
/** Relative to the execution's private runtime HOME. Normalized, never absolute, never `..`. */
|
|
@@ -23,10 +23,15 @@ export interface NativeSessionStore {
|
|
|
23
23
|
/** True when one store holds every session in the HOME (opencode.db). Readers select by id. */
|
|
24
24
|
shared: boolean;
|
|
25
25
|
format: SessionFormatId;
|
|
26
|
+
/** Reader files when this layout differs from the harness's default globs. */
|
|
27
|
+
globs?: {
|
|
28
|
+
session: string;
|
|
29
|
+
children?: string;
|
|
30
|
+
};
|
|
26
31
|
}
|
|
27
32
|
/** Where a format's served-model, usage and ending-error evidence comes from. */
|
|
28
33
|
export interface SessionEvidenceSources {
|
|
29
|
-
/** `none`:
|
|
34
|
+
/** `none`: no proven served identity (including Kimi request labels); served models stay empty. */
|
|
30
35
|
servedModel: 'provider-response' | 'session-record' | 'turn-context' | 'none';
|
|
31
36
|
usage: 'per-response' | 'cumulative' | 'session-total';
|
|
32
37
|
endingError: 'session-record' | 'none';
|
|
@@ -217,8 +222,8 @@ export interface HarnessSessionReader {
|
|
|
217
222
|
formats: readonly SessionFormatId[];
|
|
218
223
|
stores: readonly NativeSessionStore[];
|
|
219
224
|
/**
|
|
220
|
-
*
|
|
221
|
-
* harness
|
|
225
|
+
* Default globs under each store's root, unless that store supplies its own globs: the session
|
|
226
|
+
* file and, when the harness writes subagent transcripts separately, those files.
|
|
222
227
|
*/
|
|
223
228
|
globs: {
|
|
224
229
|
session: string;
|
|
@@ -267,4 +272,4 @@ export interface RawEvidenceArchiveManifestV2 {
|
|
|
267
272
|
schema: 'tangle.raw-evidence-archive.v2';
|
|
268
273
|
nativeSessions: NativeSessionCopy[];
|
|
269
274
|
}
|
|
270
|
-
export declare const HARNESS_SESSION_SCHEMA:
|
|
275
|
+
export declare const HARNESS_SESSION_SCHEMA: "tangle.harness-session.v1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/harness-sessions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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,
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"LICENSE"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@tangle-network/agent-core": "^0.
|
|
44
|
-
"@tangle-network/agent-trace-contract": "^2.
|
|
43
|
+
"@tangle-network/agent-core": "^0.15.0",
|
|
44
|
+
"@tangle-network/agent-trace-contract": "^2.1.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/node": "26.6.
|
|
48
|
-
"typescript": "
|
|
49
|
-
"vitest": "5.0.
|
|
47
|
+
"@types/node": "26.6.5",
|
|
48
|
+
"typescript": "6.0.3",
|
|
49
|
+
"vitest": "5.0.5"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsc -p tsconfig.json && chmod +x dist/cli.js",
|