@tangle-network/harness-sessions 1.0.17 → 1.0.18
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/formats/opencode.js +5 -2
- package/dist/schema.d.ts +4 -0
- package/package.json +1 -1
package/dist/formats/opencode.js
CHANGED
|
@@ -8,14 +8,17 @@ import { EVIDENCE, STORES, mtimeMs, withinPath } from '../stores.js';
|
|
|
8
8
|
const FORMAT = 'opencode.sqlite';
|
|
9
9
|
const STORE = STORES[FORMAT];
|
|
10
10
|
const HARNESS = 'opencode';
|
|
11
|
+
// OpenCode records reasoning beside its output (its own `total` adds the two), so `output` here is their sum:
|
|
12
|
+
// every completion token, as TokenUsage counts it.
|
|
11
13
|
function usageOf(tokens) {
|
|
12
14
|
if (!isRecord(tokens))
|
|
13
15
|
return null;
|
|
14
16
|
const cache = isRecord(tokens.cache) ? tokens.cache : {};
|
|
17
|
+
const output = count(tokens.output), reasoning = count(tokens.reasoning);
|
|
15
18
|
return usageOrNull({
|
|
16
19
|
input: count(tokens.input),
|
|
17
|
-
output:
|
|
18
|
-
reasoning
|
|
20
|
+
output: output === null && reasoning === null ? null : (output ?? 0) + (reasoning ?? 0),
|
|
21
|
+
reasoning,
|
|
19
22
|
cacheRead: count(cache.read),
|
|
20
23
|
cacheWrite: count(cache.write),
|
|
21
24
|
});
|
package/dist/schema.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export interface SessionEvidenceSources {
|
|
|
15
15
|
usage: 'per-response' | 'cumulative' | 'session-total';
|
|
16
16
|
endingError: 'session-record' | 'none';
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* One response's tokens, or a sum of them. `output` is every completion token, reasoning included; `reasoning` is the
|
|
20
|
+
* part of `output` spent reasoning and is never added to it. A reader whose harness records the two apart adds them.
|
|
21
|
+
*/
|
|
18
22
|
export interface TokenUsage {
|
|
19
23
|
input: number | null;
|
|
20
24
|
output: number | null;
|
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.18",
|
|
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,
|