@oneharness/sdk 0.4.6 → 0.5.0

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.
@@ -0,0 +1,234 @@
1
+ /**
2
+ * One event-sourced history JSONL line.
3
+ */
4
+ export type HistoryLine = {
5
+ event: (ActionEvent & {
6
+ duration_ms: number;
7
+ finished_at: string;
8
+ kind: "tool_call";
9
+ started_at: string;
10
+ status: "completed";
11
+ tool_call_id: string;
12
+ [k: string]: unknown;
13
+ }) | (ActionEvent & {
14
+ duration_ms: number;
15
+ finished_at: string;
16
+ kind: "tool_call";
17
+ started_at: string;
18
+ status: "failed";
19
+ tool_call_id: string;
20
+ [k: string]: unknown;
21
+ }) | (ActionEvent & {
22
+ kind: "tool_call";
23
+ started_at: string;
24
+ status: "timeout";
25
+ tool_call_id: string;
26
+ [k: string]: unknown;
27
+ }) | (ActionEvent & {
28
+ kind: "tool_call";
29
+ started_at: string;
30
+ status: "interrupted";
31
+ tool_call_id: string;
32
+ [k: string]: unknown;
33
+ }) | (ActionEvent & {
34
+ kind?: string | undefined;
35
+ [k: string]: unknown;
36
+ });
37
+ harness: string;
38
+ run_id: string;
39
+ schema_version: "1.0";
40
+ type: "event";
41
+ [k: string]: unknown;
42
+ } | ({
43
+ duration_ms: number;
44
+ exit_code: number | null;
45
+ failure_kind: FailureKind | null;
46
+ finished_at: string;
47
+ harness: string;
48
+ history_id: string;
49
+ labels?: HistoryLabels | undefined;
50
+ model: string | null;
51
+ model_ms: number;
52
+ name: string;
53
+ permission_mode: PermissionMode;
54
+ project: string;
55
+ prompt: string;
56
+ schema_version: "1.0";
57
+ session: string;
58
+ session_id: string | null;
59
+ started_at: string;
60
+ status: "ok" | "nonzero";
61
+ text: string | null;
62
+ text_source: string | null;
63
+ time_to_first_token_ms?: number | null | undefined;
64
+ timestamp: string;
65
+ tool_ms: number;
66
+ type: "run";
67
+ usage: Usage;
68
+ [k: string]: unknown;
69
+ } | {
70
+ duration_ms: number;
71
+ exit_code: number | null;
72
+ failure_kind: FailureKind | null;
73
+ finished_at: string | null;
74
+ harness: string;
75
+ history_id: string;
76
+ labels?: HistoryLabels | undefined;
77
+ model: string | null;
78
+ model_ms: number;
79
+ name: string;
80
+ permission_mode: PermissionMode;
81
+ project: string;
82
+ prompt: string;
83
+ schema_version: "1.0";
84
+ session: string;
85
+ session_id: string | null;
86
+ started_at: string;
87
+ status: "timeout" | "spawn_error" | "skipped" | "planned";
88
+ text: string | null;
89
+ text_source: string | null;
90
+ time_to_first_token_ms?: number | null | undefined;
91
+ timestamp: string;
92
+ tool_ms: number;
93
+ type: "run";
94
+ usage: Usage;
95
+ [k: string]: unknown;
96
+ } | {
97
+ duration_ms: number | null;
98
+ exit_code: number | null;
99
+ failure_kind: FailureKind | null;
100
+ finished_at: null;
101
+ harness: string;
102
+ history_id: string;
103
+ labels?: HistoryLabels | undefined;
104
+ model: string | null;
105
+ model_ms?: never | undefined;
106
+ name: string;
107
+ permission_mode: PermissionMode;
108
+ project: string;
109
+ prompt: string;
110
+ schema_version: "1.0";
111
+ session: string;
112
+ session_id: string | null;
113
+ started_at?: never | undefined;
114
+ status: Status;
115
+ text: string | null;
116
+ text_source: string | null;
117
+ time_to_first_token_ms?: never | undefined;
118
+ timestamp: string;
119
+ tool_ms?: never | undefined;
120
+ type: "run";
121
+ usage: Usage;
122
+ [k: string]: unknown;
123
+ });
124
+ export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
125
+ /**
126
+ * The normalized, closed set of failure reasons oneharness can classify from a
127
+ * harness's output. It is the single source for the `failure_kind` contract
128
+ * value: serialized as the snake_case token a consumer reads in the report
129
+ * (`auth`, `rate_limit`, `model_not_found`, `quota`, `tool_deferred`), so the
130
+ * wire shape is unchanged — modeling it as an enum keeps a misspelled or
131
+ * invalid kind unrepresentable and gives every producer/consumer (classifier,
132
+ * `is_failure`, the fallback fall-through rule, the report, history) one
133
+ * definition to share instead of scattered string literals.
134
+ */
135
+ export type FailureKind = "auth" | "rate_limit" | "model_not_found" | "quota" | "tool_deferred";
136
+ /**
137
+ * The unified approval mode, from least to most autonomy. A harness may not
138
+ * support every value (see [`crate::domain::harness::HarnessSpec::mode`]); the
139
+ * command layer refuses an unsupported one before spawning, never silently
140
+ * downgrading it.
141
+ */
142
+ export type PermissionMode = "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
143
+ /**
144
+ * The outcome of attempting to run one harness.
145
+ */
146
+ export type Status = "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned";
147
+ /**
148
+ * One normalized action a harness took, harness-agnostic so a single consumer
149
+ * assertion works across harnesses. Every field is always serialized (null when
150
+ * absent) so the shape is stable, mirroring the `usage` contract.
151
+ */
152
+ export interface ActionEvent {
153
+ /**
154
+ * Monotonic elapsed tool time. `None` means no terminal boundary was seen.
155
+ */
156
+ duration_ms: number | null;
157
+ finished_at: string | null;
158
+ /**
159
+ * Position of this event within the run, so "≤ N tool calls" and "did X
160
+ * before Y" are expressible from a stable ordering (also array order).
161
+ */
162
+ index: number;
163
+ /**
164
+ * Structured, tool-shaped arguments (the command string, the file path),
165
+ * so a consumer asserts on specific args without re-parsing; `null` when the
166
+ * event carries none (e.g. a `tool_result`).
167
+ */
168
+ input: unknown;
169
+ /**
170
+ * The kind of event: `tool_call` (the model invoked a tool) or
171
+ * `tool_result` (the observation returned to the model). Left open for
172
+ * future kinds rather than an enum, so a new shape never breaks the field.
173
+ */
174
+ kind: string;
175
+ /**
176
+ * Normalized tool name where knowable (e.g. `bash`, `Edit`); `null` for a
177
+ * `tool_result`, or when the harness did not name the tool.
178
+ */
179
+ name: string | null;
180
+ /**
181
+ * The result/observation text, when the trace exposes it; `null` otherwise.
182
+ */
183
+ output: string | null;
184
+ /**
185
+ * UTC interval bounds for tool execution, populated on history records.
186
+ */
187
+ started_at: string | null;
188
+ /**
189
+ * Terminal tool state, populated on history tool-call events.
190
+ */
191
+ status: ToolCallStatus | null;
192
+ /**
193
+ * Stable call identity within the session. Present on tool calls and their
194
+ * matching results when the provider exposes an identity; history fills a
195
+ * deterministic run-local identity for providers that do not.
196
+ */
197
+ tool_call_id: string | null;
198
+ [k: string]: unknown;
199
+ }
200
+ export interface HistoryLabels {
201
+ [k: string]: string;
202
+ }
203
+ /**
204
+ * Normalized token/cost accounting. Every field is best-effort and independently
205
+ * nullable: a harness may report tokens but not dollar cost (cost is commonly
206
+ * absent on subscription auth), or report nothing at all (plain-text harnesses).
207
+ */
208
+ export interface Usage {
209
+ /**
210
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
211
+ * previously-written prefix), when the harness reports them. `None` when the
212
+ * harness does not surface cache counts — never `0` as a guess.
213
+ */
214
+ cache_read_tokens: number | null;
215
+ /**
216
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
217
+ * creation), when the harness reports them. `None` when not surfaced.
218
+ */
219
+ cache_write_tokens: number | null;
220
+ /**
221
+ * Total cost in USD, when the harness reports it (often absent on
222
+ * subscription auth, where there is no per-call dollar figure).
223
+ */
224
+ cost_usd: number | null;
225
+ /**
226
+ * Prompt/input tokens billed, when the harness reports them.
227
+ */
228
+ input_tokens: number | null;
229
+ /**
230
+ * Completion/output tokens billed, when the harness reports them.
231
+ */
232
+ output_tokens: number | null;
233
+ [k: string]: unknown;
234
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from oneharness-core. Do not edit. */
2
+ export {};
@@ -82,7 +82,7 @@ export type HistoryRecord = {
82
82
  * run's single prompt).
83
83
  */
84
84
  prompt: string;
85
- schema_version: "0.3";
85
+ schema_version: "1.0";
86
86
  /**
87
87
  * The oneharness session id this run belongs to (the history file's stem).
88
88
  */
@@ -169,7 +169,7 @@ export type HistoryRecord = {
169
169
  * run's single prompt).
170
170
  */
171
171
  prompt: string;
172
- schema_version: "0.3";
172
+ schema_version: "1.0";
173
173
  /**
174
174
  * The oneharness session id this run belongs to (the history file's stem).
175
175
  */
@@ -92,7 +92,7 @@ export type HistoryRecord = {
92
92
  * run's single prompt).
93
93
  */
94
94
  prompt: string;
95
- schema_version: "0.3";
95
+ schema_version: "1.0";
96
96
  /**
97
97
  * The oneharness session id this run belongs to (the history file's stem).
98
98
  */
@@ -179,7 +179,7 @@ export type HistoryRecord = {
179
179
  * run's single prompt).
180
180
  */
181
181
  prompt: string;
182
- schema_version: "0.3";
182
+ schema_version: "1.0";
183
183
  /**
184
184
  * The oneharness session id this run belongs to (the history file's stem).
185
185
  */
@@ -82,7 +82,7 @@ export type HistoryRecord = {
82
82
  * run's single prompt).
83
83
  */
84
84
  prompt: string;
85
- schema_version: "0.3";
85
+ schema_version: "1.0";
86
86
  /**
87
87
  * The oneharness session id this run belongs to (the history file's stem).
88
88
  */
@@ -169,7 +169,7 @@ export type HistoryRecord = {
169
169
  * run's single prompt).
170
170
  */
171
171
  prompt: string;
172
- schema_version: "0.3";
172
+ schema_version: "1.0";
173
173
  /**
174
174
  * The oneharness session id this run belongs to (the history file's stem).
175
175
  */