@oneharness/sdk 0.5.9 → 0.5.10

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.
@@ -69,6 +69,7 @@ export type HistoryRecord = {
69
69
  * every record so a reader can resolve a session by name from any line.
70
70
  */
71
71
  name: string;
72
+ observed_tool_ms?: never | undefined;
72
73
  /**
73
74
  * The normalized approval mode requested for the run.
74
75
  */
@@ -83,7 +84,7 @@ export type HistoryRecord = {
83
84
  * run's single prompt).
84
85
  */
85
86
  prompt: string;
86
- schema_version: "1.1";
87
+ schema_version: "1.2";
87
88
  /**
88
89
  * The oneharness session id this run belongs to (the history file's stem).
89
90
  */
@@ -117,7 +118,7 @@ export type HistoryRecord = {
117
118
  * Best-effort normalized tool-call events; `null` when the harness exposes
118
119
  * no machine-readable trace.
119
120
  */
120
- events: ((ActionEvent & {
121
+ events: (((ActionEvent & {
121
122
  duration_ms: number;
122
123
  finished_at: string;
123
124
  kind: "tool_call";
@@ -148,7 +149,10 @@ export type HistoryRecord = {
148
149
  }) | (ActionEvent & {
149
150
  kind?: "tool_result" | undefined;
150
151
  [k: string]: unknown;
151
- }))[] | null;
152
+ })) & {
153
+ timing_source?: never | undefined;
154
+ [k: string]: unknown;
155
+ })[] | null;
152
156
  exit_code: number | null;
153
157
  /**
154
158
  * Best-effort classified failure reason (see [`FailureKind`]); `null` when
@@ -177,6 +181,7 @@ export type HistoryRecord = {
177
181
  * every record so a reader can resolve a session by name from any line.
178
182
  */
179
183
  name: string;
184
+ observed_tool_ms?: never | undefined;
180
185
  /**
181
186
  * The normalized approval mode requested for the run.
182
187
  */
@@ -191,7 +196,7 @@ export type HistoryRecord = {
191
196
  * run's single prompt).
192
197
  */
193
198
  prompt: string;
194
- schema_version: "1.0";
199
+ schema_version: "1.1";
195
200
  /**
196
201
  * The oneharness session id this run belongs to (the history file's stem).
197
202
  */
@@ -219,6 +224,118 @@ export type HistoryRecord = {
219
224
  usage: Usage1;
220
225
  variant?: string | null | undefined;
221
226
  [k: string]: unknown;
227
+ } | {
228
+ duration_ms: number;
229
+ /**
230
+ * Best-effort normalized tool-call events; `null` when the harness exposes
231
+ * no machine-readable trace.
232
+ */
233
+ events: (((ActionEvent & {
234
+ duration_ms: number;
235
+ finished_at: string;
236
+ kind: "tool_call";
237
+ started_at: string;
238
+ status: "completed";
239
+ tool_call_id: string;
240
+ [k: string]: unknown;
241
+ }) | (ActionEvent & {
242
+ duration_ms: number;
243
+ finished_at: string;
244
+ kind: "tool_call";
245
+ started_at: string;
246
+ status: "failed";
247
+ tool_call_id: string;
248
+ [k: string]: unknown;
249
+ }) | (ActionEvent & {
250
+ kind: "tool_call";
251
+ started_at: string;
252
+ status: "timeout";
253
+ tool_call_id: string;
254
+ [k: string]: unknown;
255
+ }) | (ActionEvent & {
256
+ kind: "tool_call";
257
+ started_at: string;
258
+ status: "interrupted";
259
+ tool_call_id: string;
260
+ [k: string]: unknown;
261
+ }) | (ActionEvent & {
262
+ kind?: "tool_result" | undefined;
263
+ [k: string]: unknown;
264
+ })) & {
265
+ timing_source?: never | undefined;
266
+ [k: string]: unknown;
267
+ })[] | null;
268
+ exit_code: number | null;
269
+ /**
270
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
271
+ * unclassified.
272
+ */
273
+ failure_kind: FailureKind | null;
274
+ finished_at: string | null;
275
+ /**
276
+ * Canonical harness id (e.g. `claude-code`).
277
+ */
278
+ harness: string;
279
+ harness_id?: string | undefined;
280
+ /**
281
+ * Globally unique, time-ordered record id. This is also the cursor accepted
282
+ * by `history watch --after` and the exact id accepted by history lookup.
283
+ */
284
+ history_id: string;
285
+ labels?: HistoryLabels2 | undefined;
286
+ /**
287
+ * The effective top-level model for the run, if any.
288
+ */
289
+ model: string | null;
290
+ model_ms: number;
291
+ /**
292
+ * The human-meaningful session name (see [`session_name`]); repeated on
293
+ * every record so a reader can resolve a session by name from any line.
294
+ */
295
+ name: string;
296
+ observed_tool_ms?: never | undefined;
297
+ /**
298
+ * The normalized approval mode requested for the run.
299
+ */
300
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
301
+ /**
302
+ * The project directory the run operated in (the real path, not the
303
+ * on-disk slug), so the list view can show where a session ran.
304
+ */
305
+ project: string;
306
+ /**
307
+ * The prompt this harness run received (its own, on a batch run; else the
308
+ * run's single prompt).
309
+ */
310
+ prompt: string;
311
+ schema_version: "1.0";
312
+ /**
313
+ * The oneharness session id this run belongs to (the history file's stem).
314
+ */
315
+ session: string;
316
+ /**
317
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
318
+ */
319
+ session_id: string | null;
320
+ started_at: string;
321
+ status: Status;
322
+ /**
323
+ * Best-effort final assistant text; `null` when extraction was impossible.
324
+ */
325
+ text: string | null;
326
+ /**
327
+ * How `text` was extracted; `null` when absent.
328
+ */
329
+ text_source: string | null;
330
+ time_to_first_token_ms?: number | null | undefined;
331
+ /**
332
+ * RFC3339 UTC instant the record was written (append time).
333
+ */
334
+ timestamp: string;
335
+ tool_ms: number;
336
+ usage: Usage2;
337
+ variant?: string | null | undefined;
338
+ [k: string]: unknown;
222
339
  } | {
223
340
  duration_ms: number | null;
224
341
  /**
@@ -255,7 +372,7 @@ export type HistoryRecord = {
255
372
  * by `history watch --after` and the exact id accepted by history lookup.
256
373
  */
257
374
  history_id: string;
258
- labels?: HistoryLabels2 | undefined;
375
+ labels?: HistoryLabels3 | undefined;
259
376
  /**
260
377
  * The effective top-level model for the run, if any.
261
378
  */
@@ -266,6 +383,178 @@ export type HistoryRecord = {
266
383
  * every record so a reader can resolve a session by name from any line.
267
384
  */
268
385
  name: string;
386
+ observed_tool_ms?: never | undefined;
387
+ /**
388
+ * The normalized approval mode requested for the run.
389
+ */
390
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
391
+ /**
392
+ * The project directory the run operated in (the real path, not the
393
+ * on-disk slug), so the list view can show where a session ran.
394
+ */
395
+ project: string;
396
+ /**
397
+ * The prompt this harness run received (its own, on a batch run; else the
398
+ * run's single prompt).
399
+ */
400
+ prompt: string;
401
+ schema_version: "1.2";
402
+ /**
403
+ * The oneharness session id this run belongs to (the history file's stem).
404
+ */
405
+ session: string;
406
+ /**
407
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
408
+ */
409
+ session_id: string | null;
410
+ started_at?: never | undefined;
411
+ status: Status;
412
+ /**
413
+ * Best-effort final assistant text; `null` when extraction was impossible.
414
+ */
415
+ text: string | null;
416
+ /**
417
+ * How `text` was extracted; `null` when absent.
418
+ */
419
+ text_source: string | null;
420
+ time_to_first_token_ms?: never | undefined;
421
+ /**
422
+ * RFC3339 UTC instant the record was written (append time).
423
+ */
424
+ timestamp: string;
425
+ tool_ms?: never | undefined;
426
+ usage: Usage3;
427
+ variant?: string | null | undefined;
428
+ [k: string]: unknown;
429
+ } | {
430
+ duration_ms: number;
431
+ /**
432
+ * Best-effort normalized tool-call events; `null` when the harness exposes
433
+ * no machine-readable trace.
434
+ */
435
+ events: ActionEvent[] | null;
436
+ exit_code: number | null;
437
+ /**
438
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
439
+ * unclassified.
440
+ */
441
+ failure_kind: FailureKind | null;
442
+ finished_at: null;
443
+ /**
444
+ * Canonical harness id (e.g. `claude-code`).
445
+ */
446
+ harness: string;
447
+ harness_id: string;
448
+ /**
449
+ * Globally unique, time-ordered record id. This is also the cursor accepted
450
+ * by `history watch --after` and the exact id accepted by history lookup.
451
+ */
452
+ history_id: string;
453
+ labels?: HistoryLabels4 | undefined;
454
+ /**
455
+ * The effective top-level model for the run, if any.
456
+ */
457
+ model: string | null;
458
+ model_ms?: never | undefined;
459
+ /**
460
+ * The human-meaningful session name (see [`session_name`]); repeated on
461
+ * every record so a reader can resolve a session by name from any line.
462
+ */
463
+ name: string;
464
+ observed_tool_ms: number;
465
+ /**
466
+ * The normalized approval mode requested for the run.
467
+ */
468
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
469
+ /**
470
+ * The project directory the run operated in (the real path, not the
471
+ * on-disk slug), so the list view can show where a session ran.
472
+ */
473
+ project: string;
474
+ /**
475
+ * The prompt this harness run received (its own, on a batch run; else the
476
+ * run's single prompt).
477
+ */
478
+ prompt: string;
479
+ schema_version: "1.2";
480
+ /**
481
+ * The oneharness session id this run belongs to (the history file's stem).
482
+ */
483
+ session: string;
484
+ /**
485
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
486
+ */
487
+ session_id: string | null;
488
+ started_at?: never | undefined;
489
+ status: Status;
490
+ /**
491
+ * Best-effort final assistant text; `null` when extraction was impossible.
492
+ */
493
+ text: string | null;
494
+ /**
495
+ * How `text` was extracted; `null` when absent.
496
+ */
497
+ text_source: string | null;
498
+ time_to_first_token_ms?: never | undefined;
499
+ /**
500
+ * RFC3339 UTC instant the record was written (append time).
501
+ */
502
+ timestamp: string;
503
+ tool_ms?: never | undefined;
504
+ usage: Usage4;
505
+ variant?: string | null | undefined;
506
+ [k: string]: unknown;
507
+ } | {
508
+ duration_ms: number | null;
509
+ /**
510
+ * Best-effort normalized tool-call events; `null` when the harness exposes
511
+ * no machine-readable trace.
512
+ */
513
+ events: ({
514
+ duration_ms?: null | undefined;
515
+ finished_at?: null | undefined;
516
+ index: number;
517
+ input: unknown;
518
+ kind: string;
519
+ name: string | null;
520
+ output: string | null;
521
+ started_at?: null | undefined;
522
+ status?: null | undefined;
523
+ tool_call_id?: string | null | undefined;
524
+ [k: string]: unknown;
525
+ } & {
526
+ timing_source?: never | undefined;
527
+ [k: string]: unknown;
528
+ })[] | null;
529
+ exit_code: number | null;
530
+ /**
531
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
532
+ * unclassified.
533
+ */
534
+ failure_kind: FailureKind | null;
535
+ finished_at: null;
536
+ /**
537
+ * Canonical harness id (e.g. `claude-code`).
538
+ */
539
+ harness: string;
540
+ harness_id?: string | undefined;
541
+ /**
542
+ * Globally unique, time-ordered record id. This is also the cursor accepted
543
+ * by `history watch --after` and the exact id accepted by history lookup.
544
+ */
545
+ history_id: string;
546
+ labels?: HistoryLabels5 | undefined;
547
+ /**
548
+ * The effective top-level model for the run, if any.
549
+ */
550
+ model: string | null;
551
+ model_ms?: never | undefined;
552
+ /**
553
+ * The human-meaningful session name (see [`session_name`]); repeated on
554
+ * every record so a reader can resolve a session by name from any line.
555
+ */
556
+ name: string;
557
+ observed_tool_ms?: never | undefined;
269
558
  /**
270
559
  * The normalized approval mode requested for the run.
271
560
  */
@@ -305,7 +594,7 @@ export type HistoryRecord = {
305
594
  */
306
595
  timestamp: string;
307
596
  tool_ms?: never | undefined;
308
- usage: Usage2;
597
+ usage: Usage5;
309
598
  variant?: string | null | undefined;
310
599
  [k: string]: unknown;
311
600
  } | {
@@ -314,7 +603,7 @@ export type HistoryRecord = {
314
603
  * Best-effort normalized tool-call events; `null` when the harness exposes
315
604
  * no machine-readable trace.
316
605
  */
317
- events: {
606
+ events: ({
318
607
  duration_ms?: null | undefined;
319
608
  finished_at?: null | undefined;
320
609
  index: number;
@@ -326,7 +615,10 @@ export type HistoryRecord = {
326
615
  status?: null | undefined;
327
616
  tool_call_id?: string | null | undefined;
328
617
  [k: string]: unknown;
329
- }[] | null;
618
+ } & {
619
+ timing_source?: never | undefined;
620
+ [k: string]: unknown;
621
+ })[] | null;
330
622
  exit_code: number | null;
331
623
  /**
332
624
  * Best-effort classified failure reason (see [`FailureKind`]); `null` when
@@ -344,7 +636,7 @@ export type HistoryRecord = {
344
636
  * by `history watch --after` and the exact id accepted by history lookup.
345
637
  */
346
638
  history_id: string;
347
- labels?: HistoryLabels3 | undefined;
639
+ labels?: HistoryLabels6 | undefined;
348
640
  /**
349
641
  * The effective top-level model for the run, if any.
350
642
  */
@@ -355,6 +647,7 @@ export type HistoryRecord = {
355
647
  * every record so a reader can resolve a session by name from any line.
356
648
  */
357
649
  name: string;
650
+ observed_tool_ms?: never | undefined;
358
651
  /**
359
652
  * The normalized approval mode requested for the run.
360
653
  */
@@ -394,7 +687,7 @@ export type HistoryRecord = {
394
687
  */
395
688
  timestamp: string;
396
689
  tool_ms?: never | undefined;
397
- usage: Usage3;
690
+ usage: Usage6;
398
691
  variant?: string | null | undefined;
399
692
  [k: string]: unknown;
400
693
  } | {
@@ -424,7 +717,7 @@ export type HistoryRecord = {
424
717
  * by `history watch --after` and the exact id accepted by history lookup.
425
718
  */
426
719
  history_id: string;
427
- labels?: HistoryLabels4 | undefined;
720
+ labels?: HistoryLabels7 | undefined;
428
721
  /**
429
722
  * The effective top-level model for the run, if any.
430
723
  */
@@ -435,6 +728,11 @@ export type HistoryRecord = {
435
728
  * every record so a reader can resolve a session by name from any line.
436
729
  */
437
730
  name: string;
731
+ /**
732
+ * Union of tool intervals observed at the stdout pipe. Unlike `tool_ms`,
733
+ * this is not provider-measured and has no model-latency counterpart.
734
+ */
735
+ observed_tool_ms?: number | null | undefined;
438
736
  /**
439
737
  * The normalized approval mode requested for the run.
440
738
  */
@@ -480,11 +778,15 @@ export type HistoryRecord = {
480
778
  */
481
779
  timestamp: string;
482
780
  tool_ms?: number | null | undefined;
483
- usage: Usage4;
781
+ usage: Usage7;
484
782
  variant?: string | null | undefined;
485
783
  [k: string]: unknown;
486
784
  };
487
785
  export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
786
+ /**
787
+ * How a normalized tool interval was obtained.
788
+ */
789
+ export type TimingSource = "provider_measured" | "stdout_observed";
488
790
  /**
489
791
  * The normalized, closed set of failure reasons oneharness can classify from a
490
792
  * harness's output. It is the single source for the `failure_kind` contract
@@ -545,6 +847,10 @@ export interface ActionEvent {
545
847
  * Terminal tool state, populated on history tool-call events.
546
848
  */
547
849
  status: ToolCallStatus | null;
850
+ /**
851
+ * Provenance for the tool interval. Omitted when timing is unavailable.
852
+ */
853
+ timing_source?: TimingSource | null | undefined;
548
854
  /**
549
855
  * Stable call identity within the session. Present on tool calls and their
550
856
  * matching results when the provider exposes an identity; history fills a
@@ -738,3 +1044,114 @@ export interface Usage4 {
738
1044
  output_tokens: number | null;
739
1045
  [k: string]: unknown;
740
1046
  }
1047
+ /**
1048
+ * Caller-supplied metadata used to select related task-graph records.
1049
+ * Omitted on the wire when empty for additive compatibility.
1050
+ */
1051
+ export interface HistoryLabels5 {
1052
+ [k: string]: string;
1053
+ }
1054
+ /**
1055
+ * Best-effort token/cost accounting (every field `null` when unreported).
1056
+ */
1057
+ export interface Usage5 {
1058
+ /**
1059
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
1060
+ * previously-written prefix), when the harness reports them. `None` when the
1061
+ * harness does not surface cache counts — never `0` as a guess.
1062
+ */
1063
+ cache_read_tokens: number | null;
1064
+ /**
1065
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
1066
+ * creation), when the harness reports them. `None` when not surfaced.
1067
+ */
1068
+ cache_write_tokens: number | null;
1069
+ /**
1070
+ * Total cost in USD, when the harness reports it (often absent on
1071
+ * subscription auth, where there is no per-call dollar figure).
1072
+ */
1073
+ cost_usd: number | null;
1074
+ /**
1075
+ * Prompt/input tokens billed, when the harness reports them.
1076
+ */
1077
+ input_tokens: number | null;
1078
+ /**
1079
+ * Completion/output tokens billed, when the harness reports them.
1080
+ */
1081
+ output_tokens: number | null;
1082
+ [k: string]: unknown;
1083
+ }
1084
+ /**
1085
+ * Caller-supplied metadata used to select related task-graph records.
1086
+ * Omitted on the wire when empty for additive compatibility.
1087
+ */
1088
+ export interface HistoryLabels6 {
1089
+ [k: string]: string;
1090
+ }
1091
+ /**
1092
+ * Best-effort token/cost accounting (every field `null` when unreported).
1093
+ */
1094
+ export interface Usage6 {
1095
+ /**
1096
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
1097
+ * previously-written prefix), when the harness reports them. `None` when the
1098
+ * harness does not surface cache counts — never `0` as a guess.
1099
+ */
1100
+ cache_read_tokens: number | null;
1101
+ /**
1102
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
1103
+ * creation), when the harness reports them. `None` when not surfaced.
1104
+ */
1105
+ cache_write_tokens: number | null;
1106
+ /**
1107
+ * Total cost in USD, when the harness reports it (often absent on
1108
+ * subscription auth, where there is no per-call dollar figure).
1109
+ */
1110
+ cost_usd: number | null;
1111
+ /**
1112
+ * Prompt/input tokens billed, when the harness reports them.
1113
+ */
1114
+ input_tokens: number | null;
1115
+ /**
1116
+ * Completion/output tokens billed, when the harness reports them.
1117
+ */
1118
+ output_tokens: number | null;
1119
+ [k: string]: unknown;
1120
+ }
1121
+ /**
1122
+ * Caller-supplied metadata used to select related task-graph records.
1123
+ * Omitted on the wire when empty for additive compatibility.
1124
+ */
1125
+ export interface HistoryLabels7 {
1126
+ [k: string]: string;
1127
+ }
1128
+ /**
1129
+ * Best-effort token/cost accounting (every field `null` when unreported).
1130
+ */
1131
+ export interface Usage7 {
1132
+ /**
1133
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
1134
+ * previously-written prefix), when the harness reports them. `None` when the
1135
+ * harness does not surface cache counts — never `0` as a guess.
1136
+ */
1137
+ cache_read_tokens: number | null;
1138
+ /**
1139
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
1140
+ * creation), when the harness reports them. `None` when not surfaced.
1141
+ */
1142
+ cache_write_tokens: number | null;
1143
+ /**
1144
+ * Total cost in USD, when the harness reports it (often absent on
1145
+ * subscription auth, where there is no per-call dollar figure).
1146
+ */
1147
+ cost_usd: number | null;
1148
+ /**
1149
+ * Prompt/input tokens billed, when the harness reports them.
1150
+ */
1151
+ input_tokens: number | null;
1152
+ /**
1153
+ * Completion/output tokens billed, when the harness reports them.
1154
+ */
1155
+ output_tokens: number | null;
1156
+ [k: string]: unknown;
1157
+ }
@@ -16,6 +16,10 @@ export type RunStreamEnvelope = {
16
16
  [k: string]: unknown;
17
17
  };
18
18
  export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
19
+ /**
20
+ * How a normalized tool interval was obtained.
21
+ */
22
+ export type TimingSource = "provider_measured" | "stdout_observed";
19
23
  /**
20
24
  * The normalized, closed set of failure reasons oneharness can classify from a
21
25
  * harness's output. It is the single source for the `failure_kind` contract
@@ -84,6 +88,10 @@ export interface ActionEvent {
84
88
  * Terminal tool state, populated on history tool-call events.
85
89
  */
86
90
  status: ToolCallStatus | null;
91
+ /**
92
+ * Provenance for the tool interval. Omitted when timing is unavailable.
93
+ */
94
+ timing_source?: TimingSource | null | undefined;
87
95
  /**
88
96
  * Stable call identity within the session. Present on tool calls and their
89
97
  * matching results when the provider exposes an identity; history fills a