@oneharness/sdk 0.4.1 → 0.4.3

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.
@@ -1,3 +1,4 @@
1
+ export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
1
2
  /**
2
3
  * The normalized, closed set of failure reasons oneharness can classify from a
3
4
  * harness's output. It is the single source for the `failure_kind` contract
@@ -332,6 +333,11 @@ export interface RunResult {
332
333
  * absent) so the shape is stable, mirroring the `usage` contract.
333
334
  */
334
335
  export interface ActionEvent {
336
+ /**
337
+ * Monotonic elapsed tool time. `None` means no terminal boundary was seen.
338
+ */
339
+ duration_ms: number | null;
340
+ finished_at: string | null;
335
341
  /**
336
342
  * Position of this event within the run, so "≤ N tool calls" and "did X
337
343
  * before Y" are expressible from a stable ordering (also array order).
@@ -358,6 +364,20 @@ export interface ActionEvent {
358
364
  * The result/observation text, when the trace exposes it; `null` otherwise.
359
365
  */
360
366
  output: string | null;
367
+ /**
368
+ * UTC interval bounds for tool execution, populated on history records.
369
+ */
370
+ started_at: string | null;
371
+ /**
372
+ * Terminal tool state, populated on history tool-call events.
373
+ */
374
+ status: ToolCallStatus | null;
375
+ /**
376
+ * Stable call identity within the session. Present on tool calls and their
377
+ * matching results when the provider exposes an identity; history fills a
378
+ * deterministic run-local identity for providers that do not.
379
+ */
380
+ tool_call_id: string | null;
361
381
  [k: string]: unknown;
362
382
  }
363
383
  /**
@@ -1,37 +1,53 @@
1
- /**
2
- * The normalized, closed set of failure reasons oneharness can classify from a
3
- * harness's output. It is the single source for the `failure_kind` contract
4
- * value: serialized as the snake_case token a consumer reads in the report
5
- * (`auth`, `rate_limit`, `model_not_found`, `quota`, `tool_deferred`), so the
6
- * wire shape is unchanged — modeling it as an enum keeps a misspelled or
7
- * invalid kind unrepresentable and gives every producer/consumer (classifier,
8
- * `is_failure`, the fallback fall-through rule, the report, history) one
9
- * definition to share instead of scattered string literals.
10
- */
11
- export type FailureKind = "auth" | "rate_limit" | "model_not_found" | "quota" | "tool_deferred";
12
- /**
13
- * The outcome of attempting to run one harness.
14
- */
15
- export type Status = "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned";
16
- export type HistoryRecords = HistoryRecord[];
17
1
  /**
18
2
  * One harness run, normalized and frozen for the history log. Serialized as one
19
3
  * JSONL line per harness run, appended as the run finalizes. Carries only the
20
4
  * normalized cross-harness signals — no raw stdout/stderr.
21
5
  */
22
- export interface HistoryRecord {
23
- duration_ms: number | null;
6
+ export type HistoryRecord = {
7
+ duration_ms: number;
24
8
  /**
25
9
  * Best-effort normalized tool-call events; `null` when the harness exposes
26
10
  * no machine-readable trace.
27
11
  */
28
- events: ActionEvent[] | null;
12
+ events: ((ActionEvent & {
13
+ duration_ms: number;
14
+ finished_at: string;
15
+ kind: "tool_call";
16
+ started_at: string;
17
+ status: "completed";
18
+ tool_call_id: string;
19
+ [k: string]: unknown;
20
+ }) | (ActionEvent & {
21
+ duration_ms: number;
22
+ finished_at: string;
23
+ kind: "tool_call";
24
+ started_at: string;
25
+ status: "failed";
26
+ tool_call_id: string;
27
+ [k: string]: unknown;
28
+ }) | (ActionEvent & {
29
+ kind: "tool_call";
30
+ started_at: string;
31
+ status: "timeout";
32
+ tool_call_id: string;
33
+ [k: string]: unknown;
34
+ }) | (ActionEvent & {
35
+ kind: "tool_call";
36
+ started_at: string;
37
+ status: "interrupted";
38
+ tool_call_id: string;
39
+ [k: string]: unknown;
40
+ }) | (ActionEvent & {
41
+ kind?: "tool_result" | undefined;
42
+ [k: string]: unknown;
43
+ }))[] | null;
29
44
  exit_code: number | null;
30
45
  /**
31
46
  * Best-effort classified failure reason (see [`FailureKind`]); `null` when
32
47
  * unclassified.
33
48
  */
34
49
  failure_kind: FailureKind | null;
50
+ finished_at: string | null;
35
51
  /**
36
52
  * Canonical harness id (e.g. `claude-code`).
37
53
  */
@@ -46,6 +62,7 @@ export interface HistoryRecord {
46
62
  * The effective top-level model for the run, if any.
47
63
  */
48
64
  model: string | null;
65
+ model_ms: number;
49
66
  /**
50
67
  * The human-meaningful session name (see [`session_name`]); repeated on
51
68
  * every record so a reader can resolve a session by name from any line.
@@ -65,7 +82,7 @@ export interface HistoryRecord {
65
82
  * run's single prompt).
66
83
  */
67
84
  prompt: string;
68
- schema_version: string;
85
+ schema_version: "0.3";
69
86
  /**
70
87
  * The oneharness session id this run belongs to (the history file's stem).
71
88
  */
@@ -74,6 +91,7 @@ export interface HistoryRecord {
74
91
  * The harness's own continuation id, when it exposed one; `null` otherwise.
75
92
  */
76
93
  session_id: string | null;
94
+ started_at: string;
77
95
  status: Status;
78
96
  /**
79
97
  * Best-effort final assistant text; `null` when extraction was impossible.
@@ -83,19 +101,127 @@ export interface HistoryRecord {
83
101
  * How `text` was extracted; `null` when absent.
84
102
  */
85
103
  text_source: string | null;
104
+ time_to_first_token_ms?: number | null | undefined;
86
105
  /**
87
106
  * RFC3339 UTC instant the record was written (append time).
88
107
  */
89
108
  timestamp: string;
109
+ tool_ms: number;
90
110
  usage: Usage;
91
111
  [k: string]: unknown;
92
- }
112
+ } | {
113
+ duration_ms: number | null;
114
+ events: {
115
+ index: number;
116
+ input: unknown;
117
+ kind: string;
118
+ name: string | null;
119
+ output: string | null;
120
+ [k: string]: unknown;
121
+ }[] | null;
122
+ exit_code: number | null;
123
+ /**
124
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
125
+ * unclassified.
126
+ */
127
+ failure_kind: FailureKind | null;
128
+ finished_at?: string | null | undefined;
129
+ /**
130
+ * Canonical harness id (e.g. `claude-code`).
131
+ */
132
+ harness: string;
133
+ /**
134
+ * Globally unique, time-ordered record id. This is also the cursor accepted
135
+ * by `history watch --after` and the exact id accepted by history lookup.
136
+ */
137
+ history_id: string;
138
+ labels?: HistoryLabels1 | undefined;
139
+ /**
140
+ * The effective top-level model for the run, if any.
141
+ */
142
+ model: string | null;
143
+ model_ms?: number | null | undefined;
144
+ /**
145
+ * The human-meaningful session name (see [`session_name`]); repeated on
146
+ * every record so a reader can resolve a session by name from any line.
147
+ */
148
+ name: string;
149
+ /**
150
+ * The normalized approval mode requested for the run.
151
+ */
152
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
153
+ /**
154
+ * The project directory the run operated in (the real path, not the
155
+ * on-disk slug), so the list view can show where a session ran.
156
+ */
157
+ project: string;
158
+ /**
159
+ * The prompt this harness run received (its own, on a batch run; else the
160
+ * run's single prompt).
161
+ */
162
+ prompt: string;
163
+ schema_version: "0.1" | "0.2";
164
+ /**
165
+ * The oneharness session id this run belongs to (the history file's stem).
166
+ */
167
+ session: string;
168
+ /**
169
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
170
+ */
171
+ session_id: string | null;
172
+ /**
173
+ * UTC invocation bounds and monotonic time attribution. The provider/tool
174
+ * split is conservative when a transcript has tool calls but lacks native
175
+ * boundaries: the observed invocation interval is attributed to the union
176
+ * of those calls, never double-counted.
177
+ */
178
+ started_at?: string | null | undefined;
179
+ status: Status;
180
+ /**
181
+ * Best-effort final assistant text; `null` when extraction was impossible.
182
+ */
183
+ text: string | null;
184
+ /**
185
+ * How `text` was extracted; `null` when absent.
186
+ */
187
+ text_source: string | null;
188
+ time_to_first_token_ms?: number | null | undefined;
189
+ /**
190
+ * RFC3339 UTC instant the record was written (append time).
191
+ */
192
+ timestamp: string;
193
+ tool_ms?: number | null | undefined;
194
+ usage: Usage1;
195
+ [k: string]: unknown;
196
+ };
197
+ export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
198
+ /**
199
+ * The normalized, closed set of failure reasons oneharness can classify from a
200
+ * harness's output. It is the single source for the `failure_kind` contract
201
+ * value: serialized as the snake_case token a consumer reads in the report
202
+ * (`auth`, `rate_limit`, `model_not_found`, `quota`, `tool_deferred`), so the
203
+ * wire shape is unchanged — modeling it as an enum keeps a misspelled or
204
+ * invalid kind unrepresentable and gives every producer/consumer (classifier,
205
+ * `is_failure`, the fallback fall-through rule, the report, history) one
206
+ * definition to share instead of scattered string literals.
207
+ */
208
+ export type FailureKind = "auth" | "rate_limit" | "model_not_found" | "quota" | "tool_deferred";
209
+ /**
210
+ * The outcome of attempting to run one harness.
211
+ */
212
+ export type Status = "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned";
213
+ export type HistoryRecords = HistoryRecord[];
93
214
  /**
94
215
  * One normalized action a harness took, harness-agnostic so a single consumer
95
216
  * assertion works across harnesses. Every field is always serialized (null when
96
217
  * absent) so the shape is stable, mirroring the `usage` contract.
97
218
  */
98
219
  export interface ActionEvent {
220
+ /**
221
+ * Monotonic elapsed tool time. `None` means no terminal boundary was seen.
222
+ */
223
+ duration_ms: number | null;
224
+ finished_at: string | null;
99
225
  /**
100
226
  * Position of this event within the run, so "≤ N tool calls" and "did X
101
227
  * before Y" are expressible from a stable ordering (also array order).
@@ -122,6 +248,20 @@ export interface ActionEvent {
122
248
  * The result/observation text, when the trace exposes it; `null` otherwise.
123
249
  */
124
250
  output: string | null;
251
+ /**
252
+ * UTC interval bounds for tool execution, populated on history records.
253
+ */
254
+ started_at: string | null;
255
+ /**
256
+ * Terminal tool state, populated on history tool-call events.
257
+ */
258
+ status: ToolCallStatus | null;
259
+ /**
260
+ * Stable call identity within the session. Present on tool calls and their
261
+ * matching results when the provider exposes an identity; history fills a
262
+ * deterministic run-local identity for providers that do not.
263
+ */
264
+ tool_call_id: string | null;
125
265
  [k: string]: unknown;
126
266
  }
127
267
  /**
@@ -161,3 +301,40 @@ export interface Usage {
161
301
  output_tokens: number | null;
162
302
  [k: string]: unknown;
163
303
  }
304
+ /**
305
+ * Caller-supplied metadata used to select related task-graph records.
306
+ * Omitted on the wire when empty for additive compatibility.
307
+ */
308
+ export interface HistoryLabels1 {
309
+ [k: string]: string;
310
+ }
311
+ /**
312
+ * Best-effort token/cost accounting (every field `null` when unreported).
313
+ */
314
+ export interface Usage1 {
315
+ /**
316
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
317
+ * previously-written prefix), when the harness reports them. `None` when the
318
+ * harness does not surface cache counts — never `0` as a guess.
319
+ */
320
+ cache_read_tokens: number | null;
321
+ /**
322
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
323
+ * creation), when the harness reports them. `None` when not surfaced.
324
+ */
325
+ cache_write_tokens: number | null;
326
+ /**
327
+ * Total cost in USD, when the harness reports it (often absent on
328
+ * subscription auth, where there is no per-call dollar figure).
329
+ */
330
+ cost_usd: number | null;
331
+ /**
332
+ * Prompt/input tokens billed, when the harness reports them.
333
+ */
334
+ input_tokens: number | null;
335
+ /**
336
+ * Completion/output tokens billed, when the harness reports them.
337
+ */
338
+ output_tokens: number | null;
339
+ [k: string]: unknown;
340
+ }
@@ -8,39 +8,56 @@ export type HistoryStreamEnvelope = {
8
8
  type: "record";
9
9
  [k: string]: unknown;
10
10
  };
11
- /**
12
- * The normalized, closed set of failure reasons oneharness can classify from a
13
- * harness's output. It is the single source for the `failure_kind` contract
14
- * value: serialized as the snake_case token a consumer reads in the report
15
- * (`auth`, `rate_limit`, `model_not_found`, `quota`, `tool_deferred`), so the
16
- * wire shape is unchanged — modeling it as an enum keeps a misspelled or
17
- * invalid kind unrepresentable and gives every producer/consumer (classifier,
18
- * `is_failure`, the fallback fall-through rule, the report, history) one
19
- * definition to share instead of scattered string literals.
20
- */
21
- export type FailureKind = "auth" | "rate_limit" | "model_not_found" | "quota" | "tool_deferred";
22
- /**
23
- * The outcome of attempting to run one harness.
24
- */
25
- export type Status = "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned";
26
11
  /**
27
12
  * One harness run, normalized and frozen for the history log. Serialized as one
28
13
  * JSONL line per harness run, appended as the run finalizes. Carries only the
29
14
  * normalized cross-harness signals — no raw stdout/stderr.
30
15
  */
31
- export interface HistoryRecord {
32
- duration_ms: number | null;
16
+ export type HistoryRecord = {
17
+ duration_ms: number;
33
18
  /**
34
19
  * Best-effort normalized tool-call events; `null` when the harness exposes
35
20
  * no machine-readable trace.
36
21
  */
37
- events: ActionEvent[] | null;
22
+ events: ((ActionEvent & {
23
+ duration_ms: number;
24
+ finished_at: string;
25
+ kind: "tool_call";
26
+ started_at: string;
27
+ status: "completed";
28
+ tool_call_id: string;
29
+ [k: string]: unknown;
30
+ }) | (ActionEvent & {
31
+ duration_ms: number;
32
+ finished_at: string;
33
+ kind: "tool_call";
34
+ started_at: string;
35
+ status: "failed";
36
+ tool_call_id: string;
37
+ [k: string]: unknown;
38
+ }) | (ActionEvent & {
39
+ kind: "tool_call";
40
+ started_at: string;
41
+ status: "timeout";
42
+ tool_call_id: string;
43
+ [k: string]: unknown;
44
+ }) | (ActionEvent & {
45
+ kind: "tool_call";
46
+ started_at: string;
47
+ status: "interrupted";
48
+ tool_call_id: string;
49
+ [k: string]: unknown;
50
+ }) | (ActionEvent & {
51
+ kind?: "tool_result" | undefined;
52
+ [k: string]: unknown;
53
+ }))[] | null;
38
54
  exit_code: number | null;
39
55
  /**
40
56
  * Best-effort classified failure reason (see [`FailureKind`]); `null` when
41
57
  * unclassified.
42
58
  */
43
59
  failure_kind: FailureKind | null;
60
+ finished_at: string | null;
44
61
  /**
45
62
  * Canonical harness id (e.g. `claude-code`).
46
63
  */
@@ -55,6 +72,7 @@ export interface HistoryRecord {
55
72
  * The effective top-level model for the run, if any.
56
73
  */
57
74
  model: string | null;
75
+ model_ms: number;
58
76
  /**
59
77
  * The human-meaningful session name (see [`session_name`]); repeated on
60
78
  * every record so a reader can resolve a session by name from any line.
@@ -74,7 +92,7 @@ export interface HistoryRecord {
74
92
  * run's single prompt).
75
93
  */
76
94
  prompt: string;
77
- schema_version: string;
95
+ schema_version: "0.3";
78
96
  /**
79
97
  * The oneharness session id this run belongs to (the history file's stem).
80
98
  */
@@ -83,6 +101,7 @@ export interface HistoryRecord {
83
101
  * The harness's own continuation id, when it exposed one; `null` otherwise.
84
102
  */
85
103
  session_id: string | null;
104
+ started_at: string;
86
105
  status: Status;
87
106
  /**
88
107
  * Best-effort final assistant text; `null` when extraction was impossible.
@@ -92,19 +111,126 @@ export interface HistoryRecord {
92
111
  * How `text` was extracted; `null` when absent.
93
112
  */
94
113
  text_source: string | null;
114
+ time_to_first_token_ms?: number | null | undefined;
95
115
  /**
96
116
  * RFC3339 UTC instant the record was written (append time).
97
117
  */
98
118
  timestamp: string;
119
+ tool_ms: number;
99
120
  usage: Usage;
100
121
  [k: string]: unknown;
101
- }
122
+ } | {
123
+ duration_ms: number | null;
124
+ events: {
125
+ index: number;
126
+ input: unknown;
127
+ kind: string;
128
+ name: string | null;
129
+ output: string | null;
130
+ [k: string]: unknown;
131
+ }[] | null;
132
+ exit_code: number | null;
133
+ /**
134
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
135
+ * unclassified.
136
+ */
137
+ failure_kind: FailureKind | null;
138
+ finished_at?: string | null | undefined;
139
+ /**
140
+ * Canonical harness id (e.g. `claude-code`).
141
+ */
142
+ harness: string;
143
+ /**
144
+ * Globally unique, time-ordered record id. This is also the cursor accepted
145
+ * by `history watch --after` and the exact id accepted by history lookup.
146
+ */
147
+ history_id: string;
148
+ labels?: HistoryLabels1 | undefined;
149
+ /**
150
+ * The effective top-level model for the run, if any.
151
+ */
152
+ model: string | null;
153
+ model_ms?: number | null | undefined;
154
+ /**
155
+ * The human-meaningful session name (see [`session_name`]); repeated on
156
+ * every record so a reader can resolve a session by name from any line.
157
+ */
158
+ name: string;
159
+ /**
160
+ * The normalized approval mode requested for the run.
161
+ */
162
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
163
+ /**
164
+ * The project directory the run operated in (the real path, not the
165
+ * on-disk slug), so the list view can show where a session ran.
166
+ */
167
+ project: string;
168
+ /**
169
+ * The prompt this harness run received (its own, on a batch run; else the
170
+ * run's single prompt).
171
+ */
172
+ prompt: string;
173
+ schema_version: "0.1" | "0.2";
174
+ /**
175
+ * The oneharness session id this run belongs to (the history file's stem).
176
+ */
177
+ session: string;
178
+ /**
179
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
180
+ */
181
+ session_id: string | null;
182
+ /**
183
+ * UTC invocation bounds and monotonic time attribution. The provider/tool
184
+ * split is conservative when a transcript has tool calls but lacks native
185
+ * boundaries: the observed invocation interval is attributed to the union
186
+ * of those calls, never double-counted.
187
+ */
188
+ started_at?: string | null | undefined;
189
+ status: Status;
190
+ /**
191
+ * Best-effort final assistant text; `null` when extraction was impossible.
192
+ */
193
+ text: string | null;
194
+ /**
195
+ * How `text` was extracted; `null` when absent.
196
+ */
197
+ text_source: string | null;
198
+ time_to_first_token_ms?: number | null | undefined;
199
+ /**
200
+ * RFC3339 UTC instant the record was written (append time).
201
+ */
202
+ timestamp: string;
203
+ tool_ms?: number | null | undefined;
204
+ usage: Usage1;
205
+ [k: string]: unknown;
206
+ };
207
+ export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
208
+ /**
209
+ * The normalized, closed set of failure reasons oneharness can classify from a
210
+ * harness's output. It is the single source for the `failure_kind` contract
211
+ * value: serialized as the snake_case token a consumer reads in the report
212
+ * (`auth`, `rate_limit`, `model_not_found`, `quota`, `tool_deferred`), so the
213
+ * wire shape is unchanged — modeling it as an enum keeps a misspelled or
214
+ * invalid kind unrepresentable and gives every producer/consumer (classifier,
215
+ * `is_failure`, the fallback fall-through rule, the report, history) one
216
+ * definition to share instead of scattered string literals.
217
+ */
218
+ export type FailureKind = "auth" | "rate_limit" | "model_not_found" | "quota" | "tool_deferred";
219
+ /**
220
+ * The outcome of attempting to run one harness.
221
+ */
222
+ export type Status = "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned";
102
223
  /**
103
224
  * One normalized action a harness took, harness-agnostic so a single consumer
104
225
  * assertion works across harnesses. Every field is always serialized (null when
105
226
  * absent) so the shape is stable, mirroring the `usage` contract.
106
227
  */
107
228
  export interface ActionEvent {
229
+ /**
230
+ * Monotonic elapsed tool time. `None` means no terminal boundary was seen.
231
+ */
232
+ duration_ms: number | null;
233
+ finished_at: string | null;
108
234
  /**
109
235
  * Position of this event within the run, so "≤ N tool calls" and "did X
110
236
  * before Y" are expressible from a stable ordering (also array order).
@@ -131,6 +257,20 @@ export interface ActionEvent {
131
257
  * The result/observation text, when the trace exposes it; `null` otherwise.
132
258
  */
133
259
  output: string | null;
260
+ /**
261
+ * UTC interval bounds for tool execution, populated on history records.
262
+ */
263
+ started_at: string | null;
264
+ /**
265
+ * Terminal tool state, populated on history tool-call events.
266
+ */
267
+ status: ToolCallStatus | null;
268
+ /**
269
+ * Stable call identity within the session. Present on tool calls and their
270
+ * matching results when the provider exposes an identity; history fills a
271
+ * deterministic run-local identity for providers that do not.
272
+ */
273
+ tool_call_id: string | null;
134
274
  [k: string]: unknown;
135
275
  }
136
276
  /**
@@ -170,3 +310,40 @@ export interface Usage {
170
310
  output_tokens: number | null;
171
311
  [k: string]: unknown;
172
312
  }
313
+ /**
314
+ * Caller-supplied metadata used to select related task-graph records.
315
+ * Omitted on the wire when empty for additive compatibility.
316
+ */
317
+ export interface HistoryLabels1 {
318
+ [k: string]: string;
319
+ }
320
+ /**
321
+ * Best-effort token/cost accounting (every field `null` when unreported).
322
+ */
323
+ export interface Usage1 {
324
+ /**
325
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
326
+ * previously-written prefix), when the harness reports them. `None` when the
327
+ * harness does not surface cache counts — never `0` as a guess.
328
+ */
329
+ cache_read_tokens: number | null;
330
+ /**
331
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
332
+ * creation), when the harness reports them. `None` when not surfaced.
333
+ */
334
+ cache_write_tokens: number | null;
335
+ /**
336
+ * Total cost in USD, when the harness reports it (often absent on
337
+ * subscription auth, where there is no per-call dollar figure).
338
+ */
339
+ cost_usd: number | null;
340
+ /**
341
+ * Prompt/input tokens billed, when the harness reports them.
342
+ */
343
+ input_tokens: number | null;
344
+ /**
345
+ * Completion/output tokens billed, when the harness reports them.
346
+ */
347
+ output_tokens: number | null;
348
+ [k: string]: unknown;
349
+ }