@oneharness/sdk 0.5.8 → 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.
@@ -83,6 +83,7 @@ export type HistoryRecord = {
83
83
  * every record so a reader can resolve a session by name from any line.
84
84
  */
85
85
  name: string;
86
+ observed_tool_ms?: never | undefined;
86
87
  /**
87
88
  * The normalized approval mode requested for the run.
88
89
  */
@@ -97,7 +98,7 @@ export type HistoryRecord = {
97
98
  * run's single prompt).
98
99
  */
99
100
  prompt: string;
100
- schema_version: "1.1";
101
+ schema_version: "1.2";
101
102
  /**
102
103
  * The oneharness session id this run belongs to (the history file's stem).
103
104
  */
@@ -131,7 +132,7 @@ export type HistoryRecord = {
131
132
  * Best-effort normalized tool-call events; `null` when the harness exposes
132
133
  * no machine-readable trace.
133
134
  */
134
- events: ((ActionEvent & {
135
+ events: (((ActionEvent & {
135
136
  duration_ms: number;
136
137
  finished_at: string;
137
138
  kind: "tool_call";
@@ -162,7 +163,10 @@ export type HistoryRecord = {
162
163
  }) | (ActionEvent & {
163
164
  kind?: "tool_result" | undefined;
164
165
  [k: string]: unknown;
165
- }))[] | null;
166
+ })) & {
167
+ timing_source?: never | undefined;
168
+ [k: string]: unknown;
169
+ })[] | null;
166
170
  exit_code: number | null;
167
171
  /**
168
172
  * Best-effort classified failure reason (see [`FailureKind`]); `null` when
@@ -191,6 +195,7 @@ export type HistoryRecord = {
191
195
  * every record so a reader can resolve a session by name from any line.
192
196
  */
193
197
  name: string;
198
+ observed_tool_ms?: never | undefined;
194
199
  /**
195
200
  * The normalized approval mode requested for the run.
196
201
  */
@@ -205,7 +210,7 @@ export type HistoryRecord = {
205
210
  * run's single prompt).
206
211
  */
207
212
  prompt: string;
208
- schema_version: "1.0";
213
+ schema_version: "1.1";
209
214
  /**
210
215
  * The oneharness session id this run belongs to (the history file's stem).
211
216
  */
@@ -233,6 +238,118 @@ export type HistoryRecord = {
233
238
  usage: Usage1;
234
239
  variant?: string | null | undefined;
235
240
  [k: string]: unknown;
241
+ } | {
242
+ duration_ms: number;
243
+ /**
244
+ * Best-effort normalized tool-call events; `null` when the harness exposes
245
+ * no machine-readable trace.
246
+ */
247
+ events: (((ActionEvent & {
248
+ duration_ms: number;
249
+ finished_at: string;
250
+ kind: "tool_call";
251
+ started_at: string;
252
+ status: "completed";
253
+ tool_call_id: string;
254
+ [k: string]: unknown;
255
+ }) | (ActionEvent & {
256
+ duration_ms: number;
257
+ finished_at: string;
258
+ kind: "tool_call";
259
+ started_at: string;
260
+ status: "failed";
261
+ tool_call_id: string;
262
+ [k: string]: unknown;
263
+ }) | (ActionEvent & {
264
+ kind: "tool_call";
265
+ started_at: string;
266
+ status: "timeout";
267
+ tool_call_id: string;
268
+ [k: string]: unknown;
269
+ }) | (ActionEvent & {
270
+ kind: "tool_call";
271
+ started_at: string;
272
+ status: "interrupted";
273
+ tool_call_id: string;
274
+ [k: string]: unknown;
275
+ }) | (ActionEvent & {
276
+ kind?: "tool_result" | undefined;
277
+ [k: string]: unknown;
278
+ })) & {
279
+ timing_source?: never | undefined;
280
+ [k: string]: unknown;
281
+ })[] | null;
282
+ exit_code: number | null;
283
+ /**
284
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
285
+ * unclassified.
286
+ */
287
+ failure_kind: FailureKind | null;
288
+ finished_at: string | null;
289
+ /**
290
+ * Canonical harness id (e.g. `claude-code`).
291
+ */
292
+ harness: string;
293
+ harness_id?: string | undefined;
294
+ /**
295
+ * Globally unique, time-ordered record id. This is also the cursor accepted
296
+ * by `history watch --after` and the exact id accepted by history lookup.
297
+ */
298
+ history_id: string;
299
+ labels?: HistoryLabels2 | undefined;
300
+ /**
301
+ * The effective top-level model for the run, if any.
302
+ */
303
+ model: string | null;
304
+ model_ms: number;
305
+ /**
306
+ * The human-meaningful session name (see [`session_name`]); repeated on
307
+ * every record so a reader can resolve a session by name from any line.
308
+ */
309
+ name: string;
310
+ observed_tool_ms?: never | undefined;
311
+ /**
312
+ * The normalized approval mode requested for the run.
313
+ */
314
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
315
+ /**
316
+ * The project directory the run operated in (the real path, not the
317
+ * on-disk slug), so the list view can show where a session ran.
318
+ */
319
+ project: string;
320
+ /**
321
+ * The prompt this harness run received (its own, on a batch run; else the
322
+ * run's single prompt).
323
+ */
324
+ prompt: string;
325
+ schema_version: "1.0";
326
+ /**
327
+ * The oneharness session id this run belongs to (the history file's stem).
328
+ */
329
+ session: string;
330
+ /**
331
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
332
+ */
333
+ session_id: string | null;
334
+ started_at: string;
335
+ status: Status;
336
+ /**
337
+ * Best-effort final assistant text; `null` when extraction was impossible.
338
+ */
339
+ text: string | null;
340
+ /**
341
+ * How `text` was extracted; `null` when absent.
342
+ */
343
+ text_source: string | null;
344
+ time_to_first_token_ms?: number | null | undefined;
345
+ /**
346
+ * RFC3339 UTC instant the record was written (append time).
347
+ */
348
+ timestamp: string;
349
+ tool_ms: number;
350
+ usage: Usage2;
351
+ variant?: string | null | undefined;
352
+ [k: string]: unknown;
236
353
  } | {
237
354
  duration_ms: number | null;
238
355
  /**
@@ -269,7 +386,178 @@ export type HistoryRecord = {
269
386
  * by `history watch --after` and the exact id accepted by history lookup.
270
387
  */
271
388
  history_id: string;
272
- labels?: HistoryLabels2 | undefined;
389
+ labels?: HistoryLabels3 | undefined;
390
+ /**
391
+ * The effective top-level model for the run, if any.
392
+ */
393
+ model: string | null;
394
+ model_ms?: never | undefined;
395
+ /**
396
+ * The human-meaningful session name (see [`session_name`]); repeated on
397
+ * every record so a reader can resolve a session by name from any line.
398
+ */
399
+ name: string;
400
+ observed_tool_ms?: never | undefined;
401
+ /**
402
+ * The normalized approval mode requested for the run.
403
+ */
404
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
405
+ /**
406
+ * The project directory the run operated in (the real path, not the
407
+ * on-disk slug), so the list view can show where a session ran.
408
+ */
409
+ project: string;
410
+ /**
411
+ * The prompt this harness run received (its own, on a batch run; else the
412
+ * run's single prompt).
413
+ */
414
+ prompt: string;
415
+ schema_version: "1.2";
416
+ /**
417
+ * The oneharness session id this run belongs to (the history file's stem).
418
+ */
419
+ session: string;
420
+ /**
421
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
422
+ */
423
+ session_id: string | null;
424
+ started_at?: never | undefined;
425
+ status: Status;
426
+ /**
427
+ * Best-effort final assistant text; `null` when extraction was impossible.
428
+ */
429
+ text: string | null;
430
+ /**
431
+ * How `text` was extracted; `null` when absent.
432
+ */
433
+ text_source: string | null;
434
+ time_to_first_token_ms?: never | undefined;
435
+ /**
436
+ * RFC3339 UTC instant the record was written (append time).
437
+ */
438
+ timestamp: string;
439
+ tool_ms?: never | undefined;
440
+ usage: Usage3;
441
+ variant?: string | null | undefined;
442
+ [k: string]: unknown;
443
+ } | {
444
+ duration_ms: number;
445
+ /**
446
+ * Best-effort normalized tool-call events; `null` when the harness exposes
447
+ * no machine-readable trace.
448
+ */
449
+ events: ActionEvent[] | null;
450
+ exit_code: number | null;
451
+ /**
452
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
453
+ * unclassified.
454
+ */
455
+ failure_kind: FailureKind | null;
456
+ finished_at: null;
457
+ /**
458
+ * Canonical harness id (e.g. `claude-code`).
459
+ */
460
+ harness: string;
461
+ harness_id: string;
462
+ /**
463
+ * Globally unique, time-ordered record id. This is also the cursor accepted
464
+ * by `history watch --after` and the exact id accepted by history lookup.
465
+ */
466
+ history_id: string;
467
+ labels?: HistoryLabels4 | undefined;
468
+ /**
469
+ * The effective top-level model for the run, if any.
470
+ */
471
+ model: string | null;
472
+ model_ms?: never | undefined;
473
+ /**
474
+ * The human-meaningful session name (see [`session_name`]); repeated on
475
+ * every record so a reader can resolve a session by name from any line.
476
+ */
477
+ name: string;
478
+ observed_tool_ms: number;
479
+ /**
480
+ * The normalized approval mode requested for the run.
481
+ */
482
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
483
+ /**
484
+ * The project directory the run operated in (the real path, not the
485
+ * on-disk slug), so the list view can show where a session ran.
486
+ */
487
+ project: string;
488
+ /**
489
+ * The prompt this harness run received (its own, on a batch run; else the
490
+ * run's single prompt).
491
+ */
492
+ prompt: string;
493
+ schema_version: "1.2";
494
+ /**
495
+ * The oneharness session id this run belongs to (the history file's stem).
496
+ */
497
+ session: string;
498
+ /**
499
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
500
+ */
501
+ session_id: string | null;
502
+ started_at?: never | undefined;
503
+ status: Status;
504
+ /**
505
+ * Best-effort final assistant text; `null` when extraction was impossible.
506
+ */
507
+ text: string | null;
508
+ /**
509
+ * How `text` was extracted; `null` when absent.
510
+ */
511
+ text_source: string | null;
512
+ time_to_first_token_ms?: never | undefined;
513
+ /**
514
+ * RFC3339 UTC instant the record was written (append time).
515
+ */
516
+ timestamp: string;
517
+ tool_ms?: never | undefined;
518
+ usage: Usage4;
519
+ variant?: string | null | undefined;
520
+ [k: string]: unknown;
521
+ } | {
522
+ duration_ms: number | null;
523
+ /**
524
+ * Best-effort normalized tool-call events; `null` when the harness exposes
525
+ * no machine-readable trace.
526
+ */
527
+ events: ({
528
+ duration_ms?: null | undefined;
529
+ finished_at?: null | undefined;
530
+ index: number;
531
+ input: unknown;
532
+ kind: string;
533
+ name: string | null;
534
+ output: string | null;
535
+ started_at?: null | undefined;
536
+ status?: null | undefined;
537
+ tool_call_id?: string | null | undefined;
538
+ [k: string]: unknown;
539
+ } & {
540
+ timing_source?: never | undefined;
541
+ [k: string]: unknown;
542
+ })[] | null;
543
+ exit_code: number | null;
544
+ /**
545
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
546
+ * unclassified.
547
+ */
548
+ failure_kind: FailureKind | null;
549
+ finished_at: null;
550
+ /**
551
+ * Canonical harness id (e.g. `claude-code`).
552
+ */
553
+ harness: string;
554
+ harness_id?: string | undefined;
555
+ /**
556
+ * Globally unique, time-ordered record id. This is also the cursor accepted
557
+ * by `history watch --after` and the exact id accepted by history lookup.
558
+ */
559
+ history_id: string;
560
+ labels?: HistoryLabels5 | undefined;
273
561
  /**
274
562
  * The effective top-level model for the run, if any.
275
563
  */
@@ -280,6 +568,7 @@ export type HistoryRecord = {
280
568
  * every record so a reader can resolve a session by name from any line.
281
569
  */
282
570
  name: string;
571
+ observed_tool_ms?: never | undefined;
283
572
  /**
284
573
  * The normalized approval mode requested for the run.
285
574
  */
@@ -319,7 +608,7 @@ export type HistoryRecord = {
319
608
  */
320
609
  timestamp: string;
321
610
  tool_ms?: never | undefined;
322
- usage: Usage2;
611
+ usage: Usage5;
323
612
  variant?: string | null | undefined;
324
613
  [k: string]: unknown;
325
614
  } | {
@@ -328,7 +617,7 @@ export type HistoryRecord = {
328
617
  * Best-effort normalized tool-call events; `null` when the harness exposes
329
618
  * no machine-readable trace.
330
619
  */
331
- events: {
620
+ events: ({
332
621
  duration_ms?: null | undefined;
333
622
  finished_at?: null | undefined;
334
623
  index: number;
@@ -340,7 +629,10 @@ export type HistoryRecord = {
340
629
  status?: null | undefined;
341
630
  tool_call_id?: string | null | undefined;
342
631
  [k: string]: unknown;
343
- }[] | null;
632
+ } & {
633
+ timing_source?: never | undefined;
634
+ [k: string]: unknown;
635
+ })[] | null;
344
636
  exit_code: number | null;
345
637
  /**
346
638
  * Best-effort classified failure reason (see [`FailureKind`]); `null` when
@@ -358,7 +650,7 @@ export type HistoryRecord = {
358
650
  * by `history watch --after` and the exact id accepted by history lookup.
359
651
  */
360
652
  history_id: string;
361
- labels?: HistoryLabels3 | undefined;
653
+ labels?: HistoryLabels6 | undefined;
362
654
  /**
363
655
  * The effective top-level model for the run, if any.
364
656
  */
@@ -369,6 +661,7 @@ export type HistoryRecord = {
369
661
  * every record so a reader can resolve a session by name from any line.
370
662
  */
371
663
  name: string;
664
+ observed_tool_ms?: never | undefined;
372
665
  /**
373
666
  * The normalized approval mode requested for the run.
374
667
  */
@@ -408,7 +701,7 @@ export type HistoryRecord = {
408
701
  */
409
702
  timestamp: string;
410
703
  tool_ms?: never | undefined;
411
- usage: Usage3;
704
+ usage: Usage6;
412
705
  variant?: string | null | undefined;
413
706
  [k: string]: unknown;
414
707
  } | {
@@ -438,7 +731,7 @@ export type HistoryRecord = {
438
731
  * by `history watch --after` and the exact id accepted by history lookup.
439
732
  */
440
733
  history_id: string;
441
- labels?: HistoryLabels4 | undefined;
734
+ labels?: HistoryLabels7 | undefined;
442
735
  /**
443
736
  * The effective top-level model for the run, if any.
444
737
  */
@@ -449,6 +742,11 @@ export type HistoryRecord = {
449
742
  * every record so a reader can resolve a session by name from any line.
450
743
  */
451
744
  name: string;
745
+ /**
746
+ * Union of tool intervals observed at the stdout pipe. Unlike `tool_ms`,
747
+ * this is not provider-measured and has no model-latency counterpart.
748
+ */
749
+ observed_tool_ms?: number | null | undefined;
452
750
  /**
453
751
  * The normalized approval mode requested for the run.
454
752
  */
@@ -494,11 +792,15 @@ export type HistoryRecord = {
494
792
  */
495
793
  timestamp: string;
496
794
  tool_ms?: number | null | undefined;
497
- usage: Usage4;
795
+ usage: Usage7;
498
796
  variant?: string | null | undefined;
499
797
  [k: string]: unknown;
500
798
  };
501
799
  export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
800
+ /**
801
+ * How a normalized tool interval was obtained.
802
+ */
803
+ export type TimingSource = "provider_measured" | "stdout_observed";
502
804
  /**
503
805
  * The normalized, closed set of failure reasons oneharness can classify from a
504
806
  * harness's output. It is the single source for the `failure_kind` contract
@@ -514,6 +816,26 @@ export type FailureKind = "auth" | "rate_limit" | "model_not_found" | "quota" |
514
816
  * The outcome of attempting to run one harness.
515
817
  */
516
818
  export type Status = "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned";
819
+ export type HistoryEventLine = {
820
+ event: ActionEvent;
821
+ harness: string;
822
+ harness_id?: string | null | undefined;
823
+ run_id: string;
824
+ schema_version: "1.2";
825
+ variant?: string | null | undefined;
826
+ [k: string]: unknown;
827
+ } | {
828
+ event: ActionEvent & {
829
+ timing_source?: never | undefined;
830
+ [k: string]: unknown;
831
+ };
832
+ harness: string;
833
+ harness_id?: string | null | undefined;
834
+ run_id: string;
835
+ schema_version: "1.0" | "1.1";
836
+ variant?: string | null | undefined;
837
+ [k: string]: unknown;
838
+ };
517
839
  /**
518
840
  * One normalized action a harness took, harness-agnostic so a single consumer
519
841
  * assertion works across harnesses. Every field is always serialized (null when
@@ -559,6 +881,10 @@ export interface ActionEvent {
559
881
  * Terminal tool state, populated on history tool-call events.
560
882
  */
561
883
  status: ToolCallStatus | null;
884
+ /**
885
+ * Provenance for the tool interval. Omitted when timing is unavailable.
886
+ */
887
+ timing_source?: TimingSource | null | undefined;
562
888
  /**
563
889
  * Stable call identity within the session. Present on tool calls and their
564
890
  * matching results when the provider exposes an identity; history fills a
@@ -753,14 +1079,113 @@ export interface Usage4 {
753
1079
  [k: string]: unknown;
754
1080
  }
755
1081
  /**
756
- * One normalized action observed during a run.
1082
+ * Caller-supplied metadata used to select related task-graph records.
1083
+ * Omitted on the wire when empty for additive compatibility.
757
1084
  */
758
- export interface HistoryEventLine {
759
- event: ActionEvent;
760
- harness: string;
761
- harness_id?: string | null | undefined;
762
- run_id: string;
763
- schema_version: "1.0" | "1.1";
764
- variant?: string | null | undefined;
1085
+ export interface HistoryLabels5 {
1086
+ [k: string]: string;
1087
+ }
1088
+ /**
1089
+ * Best-effort token/cost accounting (every field `null` when unreported).
1090
+ */
1091
+ export interface Usage5 {
1092
+ /**
1093
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
1094
+ * previously-written prefix), when the harness reports them. `None` when the
1095
+ * harness does not surface cache counts — never `0` as a guess.
1096
+ */
1097
+ cache_read_tokens: number | null;
1098
+ /**
1099
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
1100
+ * creation), when the harness reports them. `None` when not surfaced.
1101
+ */
1102
+ cache_write_tokens: number | null;
1103
+ /**
1104
+ * Total cost in USD, when the harness reports it (often absent on
1105
+ * subscription auth, where there is no per-call dollar figure).
1106
+ */
1107
+ cost_usd: number | null;
1108
+ /**
1109
+ * Prompt/input tokens billed, when the harness reports them.
1110
+ */
1111
+ input_tokens: number | null;
1112
+ /**
1113
+ * Completion/output tokens billed, when the harness reports them.
1114
+ */
1115
+ output_tokens: number | null;
1116
+ [k: string]: unknown;
1117
+ }
1118
+ /**
1119
+ * Caller-supplied metadata used to select related task-graph records.
1120
+ * Omitted on the wire when empty for additive compatibility.
1121
+ */
1122
+ export interface HistoryLabels6 {
1123
+ [k: string]: string;
1124
+ }
1125
+ /**
1126
+ * Best-effort token/cost accounting (every field `null` when unreported).
1127
+ */
1128
+ export interface Usage6 {
1129
+ /**
1130
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
1131
+ * previously-written prefix), when the harness reports them. `None` when the
1132
+ * harness does not surface cache counts — never `0` as a guess.
1133
+ */
1134
+ cache_read_tokens: number | null;
1135
+ /**
1136
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
1137
+ * creation), when the harness reports them. `None` when not surfaced.
1138
+ */
1139
+ cache_write_tokens: number | null;
1140
+ /**
1141
+ * Total cost in USD, when the harness reports it (often absent on
1142
+ * subscription auth, where there is no per-call dollar figure).
1143
+ */
1144
+ cost_usd: number | null;
1145
+ /**
1146
+ * Prompt/input tokens billed, when the harness reports them.
1147
+ */
1148
+ input_tokens: number | null;
1149
+ /**
1150
+ * Completion/output tokens billed, when the harness reports them.
1151
+ */
1152
+ output_tokens: number | null;
1153
+ [k: string]: unknown;
1154
+ }
1155
+ /**
1156
+ * Caller-supplied metadata used to select related task-graph records.
1157
+ * Omitted on the wire when empty for additive compatibility.
1158
+ */
1159
+ export interface HistoryLabels7 {
1160
+ [k: string]: string;
1161
+ }
1162
+ /**
1163
+ * Best-effort token/cost accounting (every field `null` when unreported).
1164
+ */
1165
+ export interface Usage7 {
1166
+ /**
1167
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
1168
+ * previously-written prefix), when the harness reports them. `None` when the
1169
+ * harness does not surface cache counts — never `0` as a guess.
1170
+ */
1171
+ cache_read_tokens: number | null;
1172
+ /**
1173
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
1174
+ * creation), when the harness reports them. `None` when not surfaced.
1175
+ */
1176
+ cache_write_tokens: number | null;
1177
+ /**
1178
+ * Total cost in USD, when the harness reports it (often absent on
1179
+ * subscription auth, where there is no per-call dollar figure).
1180
+ */
1181
+ cost_usd: number | null;
1182
+ /**
1183
+ * Prompt/input tokens billed, when the harness reports them.
1184
+ */
1185
+ input_tokens: number | null;
1186
+ /**
1187
+ * Completion/output tokens billed, when the harness reports them.
1188
+ */
1189
+ output_tokens: number | null;
765
1190
  [k: string]: unknown;
766
1191
  }