@oneharness/sdk 0.6.8 → 0.6.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.
@@ -20,6 +20,49 @@ export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
20
20
  * How a normalized tool interval was obtained.
21
21
  */
22
22
  export type TimingSource = "provider_measured" | "stdout_observed";
23
+ /**
24
+ * One control request the run handled, recorded in the report so a consumer
25
+ * can tell an interrupted turn from one that simply ended.
26
+ *
27
+ * A sum type discriminated by `outcome`, so a record can never say "served,
28
+ * and here is the refusal reason": the reason exists exactly when there was a
29
+ * refusal. Serialized flat — `{"outcome":"served","verb":…,"at":…}` /
30
+ * `{"outcome":"refused","verb":…,"at":…,"reason":…}`.
31
+ */
32
+ export type ControlEvent = {
33
+ /**
34
+ * When the request was handled.
35
+ */
36
+ at: string;
37
+ outcome: "served";
38
+ /**
39
+ * The verb requested.
40
+ */
41
+ verb: "interrupt";
42
+ [k: string]: unknown;
43
+ } | {
44
+ at: UtcInstant;
45
+ outcome: "refused";
46
+ reason: ControlReason;
47
+ verb: ControlVerb;
48
+ [k: string]: unknown;
49
+ };
50
+ /**
51
+ * An RFC 3339 timestamp in UTC (`Z`), in oneharness's canonical spelling.
52
+ */
53
+ export type UtcInstant = string;
54
+ /**
55
+ * Why a control request could not be served. Distinct reasons because a
56
+ * supervisor reacts differently to each: `unsupported` is permanent for the
57
+ * harness, `not_running` means the dispatch is gone, `no_active_turn` means
58
+ * the run is alive but between turns.
59
+ */
60
+ export type ControlReason = "unsupported" | "no_active_turn" | "not_running";
61
+ /**
62
+ * The control verb a supervisor sends. Only `interrupt` exists today; the
63
+ * frame's `v` is what leaves room for `steer` later.
64
+ */
65
+ export type ControlVerb = "interrupt";
23
66
  /**
24
67
  * The normalized, closed set of failure reasons oneharness can classify from a
25
68
  * harness's output. It is the single source for the `failure_kind` contract
@@ -42,7 +85,39 @@ export type OutputFormat = "text" | "json" | "stream-json";
42
85
  /**
43
86
  * The outcome of attempting to run one harness.
44
87
  */
45
- export type Status = "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned";
88
+ export type Status = "ok" | "nonzero" | "timeout" | "cancelled" | "spawn-error" | "skipped" | "planned";
89
+ /**
90
+ * Measured execution telemetry for one harness run: when the invocation ran,
91
+ * and — when the harness's transcript supports it — how its wall clock split
92
+ * between provider latency and tool work.
93
+ *
94
+ * Carried from the runner/parser to the history writer *and*, since report
95
+ * schema `0.5`, serialized on [`RunResult::telemetry`]. Exposing it there is
96
+ * what lets a consumer read the numbers off the run it just made instead of
97
+ * re-opening the history file the same run wrote.
98
+ *
99
+ * Internally tagged by `source`, so the variant is a value a consumer switches
100
+ * on rather than a shape it has to sniff. Every variant states only what was
101
+ * actually measured — there is no variant meaning "no telemetry"; that is a
102
+ * `null` field.
103
+ */
104
+ export type ExecutionTelemetry = {
105
+ finished_at: string | null;
106
+ model_ms: number | null;
107
+ source: "provider_measured";
108
+ started_at: string;
109
+ time_to_first_token_ms: number | null;
110
+ tool_ms: number | null;
111
+ [k: string]: unknown;
112
+ } | {
113
+ source: "partial_invocation";
114
+ started_at: string;
115
+ [k: string]: unknown;
116
+ } | {
117
+ source: "stdout_observed";
118
+ tool_ms: number;
119
+ [k: string]: unknown;
120
+ };
46
121
  /**
47
122
  * One normalized action a harness took, harness-agnostic so a single consumer
48
123
  * assertion works across harnesses. Every field is always serialized (null when
@@ -121,6 +196,14 @@ export interface RunReport {
121
196
  * project last); empty under `--no-config` or when none exist.
122
197
  */
123
198
  config_files: string[];
199
+ /**
200
+ * Out-of-band turn control for this run (`--control`), or `null` when none
201
+ * was requested — which is every ordinary run. It records the socket a
202
+ * separate `oneharness interrupt` process could address, the harness
203
+ * mechanism behind it, and each request served, so a consumer can tell an
204
+ * interrupted turn from one that simply ended.
205
+ */
206
+ control: ControlReport | null;
124
207
  dry_run: boolean;
125
208
  /**
126
209
  * Fallback-mode metadata when this run drove the selected harnesses in
@@ -231,6 +314,25 @@ export interface BatchReport {
231
314
  strategy: "speed" | "min-tokens";
232
315
  [k: string]: unknown;
233
316
  }
317
+ /**
318
+ * The run report's `control` block: where the socket lived, which mechanism
319
+ * backed it, and every request served over the run's lifetime.
320
+ */
321
+ export interface ControlReport {
322
+ /**
323
+ * Every control request served, in order.
324
+ */
325
+ interrupts: ControlEvent[];
326
+ /**
327
+ * The harness mechanism backing it.
328
+ */
329
+ mechanism: "claude-control-request" | "codex-app-server" | "opencode-http" | "acp-cancel" | "crush-http";
330
+ /**
331
+ * Absolute path of the socket this run listened on.
332
+ */
333
+ socket: string;
334
+ [k: string]: unknown;
335
+ }
234
336
  /**
235
337
  * Metadata for a fallback run (harnesses tried in priority order until one
236
338
  * runs). Present on [`RunReport::fallback`] only in that mode. The per-harness
@@ -395,6 +497,14 @@ export interface RunResult {
395
497
  * see what the harness produced.
396
498
  */
397
499
  structured: unknown;
500
+ /**
501
+ * Measured execution telemetry for this run: the invocation bounds and, when
502
+ * the harness's transcript carried a trace to read them from, the
503
+ * model/tool split. `null` when nothing was measured — never estimated.
504
+ * Added in report schema `0.5`; before that a consumer had to re-read the
505
+ * history file for numbers the run itself already had.
506
+ */
507
+ telemetry: ExecutionTelemetry | null;
398
508
  /**
399
509
  * Best-effort final assistant text; `null` when extraction is impossible.
400
510
  */