@oneharness/sdk 0.3.22

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,150 @@
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
+ /**
18
+ * One harness run, normalized and frozen for the history log. Serialized as one
19
+ * JSONL line per harness run, appended as the run finalizes. Carries only the
20
+ * normalized cross-harness signals — no raw stdout/stderr.
21
+ */
22
+ export interface HistoryRecord {
23
+ duration_ms: number | null;
24
+ /**
25
+ * Best-effort normalized tool-call events; `null` when the harness exposes
26
+ * no machine-readable trace.
27
+ */
28
+ events: ActionEvent[] | null;
29
+ exit_code: number | null;
30
+ /**
31
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
32
+ * unclassified.
33
+ */
34
+ failure_kind: FailureKind | null;
35
+ /**
36
+ * Canonical harness id (e.g. `claude-code`).
37
+ */
38
+ harness: string;
39
+ /**
40
+ * The effective top-level model for the run, if any.
41
+ */
42
+ model: string | null;
43
+ /**
44
+ * The human-meaningful session name (see [`session_name`]); repeated on
45
+ * every record so a reader can resolve a session by name from any line.
46
+ */
47
+ name: string;
48
+ /**
49
+ * The normalized approval mode requested for the run.
50
+ */
51
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
52
+ /**
53
+ * The project directory the run operated in (the real path, not the
54
+ * on-disk slug), so the list view can show where a session ran.
55
+ */
56
+ project: string;
57
+ /**
58
+ * The prompt this harness run received (its own, on a batch run; else the
59
+ * run's single prompt).
60
+ */
61
+ prompt: string;
62
+ schema_version: string;
63
+ /**
64
+ * The oneharness session id this run belongs to (the history file's stem).
65
+ */
66
+ session: string;
67
+ /**
68
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
69
+ */
70
+ session_id: string | null;
71
+ status: Status;
72
+ /**
73
+ * Best-effort final assistant text; `null` when extraction was impossible.
74
+ */
75
+ text: string | null;
76
+ /**
77
+ * How `text` was extracted; `null` when absent.
78
+ */
79
+ text_source: string | null;
80
+ /**
81
+ * RFC3339 UTC instant the record was written (append time).
82
+ */
83
+ timestamp: string;
84
+ usage: Usage;
85
+ [k: string]: unknown;
86
+ }
87
+ /**
88
+ * One normalized action a harness took, harness-agnostic so a single consumer
89
+ * assertion works across harnesses. Every field is always serialized (null when
90
+ * absent) so the shape is stable, mirroring the `usage` contract.
91
+ */
92
+ export interface ActionEvent {
93
+ /**
94
+ * Position of this event within the run, so "≤ N tool calls" and "did X
95
+ * before Y" are expressible from a stable ordering (also array order).
96
+ */
97
+ index: number;
98
+ /**
99
+ * Structured, tool-shaped arguments (the command string, the file path),
100
+ * so a consumer asserts on specific args without re-parsing; `null` when the
101
+ * event carries none (e.g. a `tool_result`).
102
+ */
103
+ input: unknown;
104
+ /**
105
+ * The kind of event: `tool_call` (the model invoked a tool) or
106
+ * `tool_result` (the observation returned to the model). Left open for
107
+ * future kinds rather than an enum, so a new shape never breaks the field.
108
+ */
109
+ kind: string;
110
+ /**
111
+ * Normalized tool name where knowable (e.g. `bash`, `Edit`); `null` for a
112
+ * `tool_result`, or when the harness did not name the tool.
113
+ */
114
+ name: string | null;
115
+ /**
116
+ * The result/observation text, when the trace exposes it; `null` otherwise.
117
+ */
118
+ output: string | null;
119
+ [k: string]: unknown;
120
+ }
121
+ /**
122
+ * Best-effort token/cost accounting (every field `null` when unreported).
123
+ */
124
+ export interface Usage {
125
+ /**
126
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
127
+ * previously-written prefix), when the harness reports them. `None` when the
128
+ * harness does not surface cache counts — never `0` as a guess.
129
+ */
130
+ cache_read_tokens: number | null;
131
+ /**
132
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
133
+ * creation), when the harness reports them. `None` when not surfaced.
134
+ */
135
+ cache_write_tokens: number | null;
136
+ /**
137
+ * Total cost in USD, when the harness reports it (often absent on
138
+ * subscription auth, where there is no per-call dollar figure).
139
+ */
140
+ cost_usd: number | null;
141
+ /**
142
+ * Prompt/input tokens billed, when the harness reports them.
143
+ */
144
+ input_tokens: number | null;
145
+ /**
146
+ * Completion/output tokens billed, when the harness reports them.
147
+ */
148
+ output_tokens: number | null;
149
+ [k: string]: unknown;
150
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from oneharness-core. Do not edit. */
2
+ export {};
@@ -0,0 +1,149 @@
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
+ /**
17
+ * One harness run, normalized and frozen for the history log. Serialized as one
18
+ * JSONL line per harness run, appended as the run finalizes. Carries only the
19
+ * normalized cross-harness signals — no raw stdout/stderr.
20
+ */
21
+ export interface HistoryRecord {
22
+ duration_ms: number | null;
23
+ /**
24
+ * Best-effort normalized tool-call events; `null` when the harness exposes
25
+ * no machine-readable trace.
26
+ */
27
+ events: ActionEvent[] | null;
28
+ exit_code: number | null;
29
+ /**
30
+ * Best-effort classified failure reason (see [`FailureKind`]); `null` when
31
+ * unclassified.
32
+ */
33
+ failure_kind: FailureKind | null;
34
+ /**
35
+ * Canonical harness id (e.g. `claude-code`).
36
+ */
37
+ harness: string;
38
+ /**
39
+ * The effective top-level model for the run, if any.
40
+ */
41
+ model: string | null;
42
+ /**
43
+ * The human-meaningful session name (see [`session_name`]); repeated on
44
+ * every record so a reader can resolve a session by name from any line.
45
+ */
46
+ name: string;
47
+ /**
48
+ * The normalized approval mode requested for the run.
49
+ */
50
+ permission_mode: "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
51
+ /**
52
+ * The project directory the run operated in (the real path, not the
53
+ * on-disk slug), so the list view can show where a session ran.
54
+ */
55
+ project: string;
56
+ /**
57
+ * The prompt this harness run received (its own, on a batch run; else the
58
+ * run's single prompt).
59
+ */
60
+ prompt: string;
61
+ schema_version: string;
62
+ /**
63
+ * The oneharness session id this run belongs to (the history file's stem).
64
+ */
65
+ session: string;
66
+ /**
67
+ * The harness's own continuation id, when it exposed one; `null` otherwise.
68
+ */
69
+ session_id: string | null;
70
+ status: Status;
71
+ /**
72
+ * Best-effort final assistant text; `null` when extraction was impossible.
73
+ */
74
+ text: string | null;
75
+ /**
76
+ * How `text` was extracted; `null` when absent.
77
+ */
78
+ text_source: string | null;
79
+ /**
80
+ * RFC3339 UTC instant the record was written (append time).
81
+ */
82
+ timestamp: string;
83
+ usage: Usage;
84
+ [k: string]: unknown;
85
+ }
86
+ /**
87
+ * One normalized action a harness took, harness-agnostic so a single consumer
88
+ * assertion works across harnesses. Every field is always serialized (null when
89
+ * absent) so the shape is stable, mirroring the `usage` contract.
90
+ */
91
+ export interface ActionEvent {
92
+ /**
93
+ * Position of this event within the run, so "≤ N tool calls" and "did X
94
+ * before Y" are expressible from a stable ordering (also array order).
95
+ */
96
+ index: number;
97
+ /**
98
+ * Structured, tool-shaped arguments (the command string, the file path),
99
+ * so a consumer asserts on specific args without re-parsing; `null` when the
100
+ * event carries none (e.g. a `tool_result`).
101
+ */
102
+ input: unknown;
103
+ /**
104
+ * The kind of event: `tool_call` (the model invoked a tool) or
105
+ * `tool_result` (the observation returned to the model). Left open for
106
+ * future kinds rather than an enum, so a new shape never breaks the field.
107
+ */
108
+ kind: string;
109
+ /**
110
+ * Normalized tool name where knowable (e.g. `bash`, `Edit`); `null` for a
111
+ * `tool_result`, or when the harness did not name the tool.
112
+ */
113
+ name: string | null;
114
+ /**
115
+ * The result/observation text, when the trace exposes it; `null` otherwise.
116
+ */
117
+ output: string | null;
118
+ [k: string]: unknown;
119
+ }
120
+ /**
121
+ * Best-effort token/cost accounting (every field `null` when unreported).
122
+ */
123
+ export interface Usage {
124
+ /**
125
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
126
+ * previously-written prefix), when the harness reports them. `None` when the
127
+ * harness does not surface cache counts — never `0` as a guess.
128
+ */
129
+ cache_read_tokens: number | null;
130
+ /**
131
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
132
+ * creation), when the harness reports them. `None` when not surfaced.
133
+ */
134
+ cache_write_tokens: number | null;
135
+ /**
136
+ * Total cost in USD, when the harness reports it (often absent on
137
+ * subscription auth, where there is no per-call dollar figure).
138
+ */
139
+ cost_usd: number | null;
140
+ /**
141
+ * Prompt/input tokens billed, when the harness reports them.
142
+ */
143
+ input_tokens: number | null;
144
+ /**
145
+ * Completion/output tokens billed, when the harness reports them.
146
+ */
147
+ output_tokens: number | null;
148
+ [k: string]: unknown;
149
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from oneharness-core. Do not edit. */
2
+ export {};
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The unified approval mode, from least to most autonomy. A harness may not
3
+ * support every value (see [`crate::domain::harness::HarnessSpec::mode`]); the
4
+ * command layer refuses an unsupported one before spawning, never silently
5
+ * downgrading it.
6
+ */
7
+ export type PermissionMode = "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
8
+ /**
9
+ * Options accepted by `OneHarness.run()` in the published Node SDK.
10
+ *
11
+ * Unknown fields are rejected because the SDK cannot forward an option it does
12
+ * not understand. This differs deliberately from output contracts, whose Zod
13
+ * schemas preserve unknown fields for forward compatibility.
14
+ */
15
+ export interface RunOptions {
16
+ bins?: {
17
+ [k: string]: string;
18
+ } | undefined;
19
+ cwd?: string | undefined;
20
+ env?: {
21
+ [k: string]: string;
22
+ } | undefined;
23
+ events?: boolean | undefined;
24
+ fork?: boolean | undefined;
25
+ harnesses?: readonly string[] | undefined;
26
+ history?: boolean | undefined;
27
+ historyDir?: string | undefined;
28
+ historyName?: string | undefined;
29
+ mode?: PermissionMode | undefined;
30
+ models?: readonly string[] | undefined;
31
+ /**
32
+ * The user message sent to the selected harnesses.
33
+ */
34
+ prompt: string;
35
+ reasoning?: string | undefined;
36
+ resume?: string | undefined;
37
+ session?: string | undefined;
38
+ system?: string | undefined;
39
+ timeoutSeconds?: number | undefined;
40
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from oneharness-core. Do not edit. */
2
+ export {};
@@ -0,0 +1,125 @@
1
+ /**
2
+ * The unified approval mode, from least to most autonomy. A harness may not
3
+ * support every value (see [`crate::domain::harness::HarnessSpec::mode`]); the
4
+ * command layer refuses an unsupported one before spawning, never silently
5
+ * downgrading it.
6
+ */
7
+ export type PermissionMode = "read-only" | "plan" | "default" | "edit" | "auto" | "bypass";
8
+ /**
9
+ * How a harness emits its result, which decides how `text` is extracted.
10
+ *
11
+ * Also accepted as a CLI value (`--output-format`, parsed in the `oneharness`
12
+ * binary) and a config-file value (`output_format`, via `Deserialize`). The
13
+ * CLI parsing lives in the binary so this core crate stays free of `clap`.
14
+ */
15
+ export type OutputFormat = "text" | "json" | "stream-json";
16
+ export interface ListReport {
17
+ harnesses: HarnessInfo[];
18
+ schema_version: string;
19
+ [k: string]: unknown;
20
+ }
21
+ export interface HarnessInfo {
22
+ default_bin: string;
23
+ display: string;
24
+ /**
25
+ * The argv oneharness would build, with placeholders, so the adapter's
26
+ * shape is visible without running anything.
27
+ */
28
+ example_command: string[];
29
+ /**
30
+ * Whether a forked run reuses the parent session's prompt-cache prefix, so a
31
+ * fork-based `--batch-strategy min-tokens` run actually reduces tokens. `true`
32
+ * only for Claude Code today; `false` (incl. OpenCode, whose fork re-sends the
33
+ * prefix cold) means `min-tokens` only orders the calls (no saving).
34
+ */
35
+ fork_reuses_cache: boolean;
36
+ id: string;
37
+ install_hint: string;
38
+ /**
39
+ * The input-rewrite verdict shape `oneharness mock <id>` speaks for this
40
+ * harness (`claude-nested`, `crush-flat`, `opencode-shim`); `null` when
41
+ * the harness has no verified rewrite — a rewrite rule for it is then a
42
+ * loud usage error (see the README mock support matrix).
43
+ */
44
+ mock_rewrite: string | null;
45
+ /**
46
+ * The approval modes (`--mode`) this harness can express, each with its
47
+ * headless behavior. Modes not listed are unsupported for the harness.
48
+ */
49
+ modes: ModeInfo[];
50
+ output_format: OutputFormat;
51
+ /**
52
+ * Whether `run --session <name>` is supported — a uniform, caller-owned
53
+ * handle oneharness maps to the harness's native session id. `true` only for
54
+ * harnesses that expose a session id headlessly; `false` means `--session` is
55
+ * a loud usage error (there is no id to bind a name to).
56
+ */
57
+ session_capable: boolean;
58
+ /**
59
+ * Whether the unified allow/deny rule lists and hooks table can be synced
60
+ * into that file (see the README support matrix).
61
+ */
62
+ supports_allowed_tools: boolean;
63
+ supports_denied_tools: boolean;
64
+ /**
65
+ * Whether `run --resume <session> --fork` is supported — branching a new
66
+ * session from the resumed one. `false` means it resumes linearly only.
67
+ */
68
+ supports_fork: boolean;
69
+ supports_hooks: boolean;
70
+ /**
71
+ * Whether `oneharness mock <id>` can express a pre-tool *deny* for this
72
+ * harness (the same protocol `oneharness gate` speaks).
73
+ */
74
+ supports_mock_deny: boolean;
75
+ /**
76
+ * Whether `run --schema` is delivered through a native structured-output
77
+ * flag for this harness (Claude Code's `--json-schema`). `false` means the
78
+ * portable prompt-based path is used — structured output works either way;
79
+ * oneharness always validates and retries.
80
+ */
81
+ supports_native_schema: boolean;
82
+ /**
83
+ * Whether a large user prompt can be delivered off the argv (piped to the
84
+ * harness's stdin) so it never trips the OS argument ceiling (`E2BIG`).
85
+ */
86
+ supports_prompt_stdin: boolean;
87
+ /**
88
+ * Whether `run --reasoning <effort>` can be delivered on the argv for this
89
+ * harness (Claude Code's `--effort`, Codex's `model_reasoning_effort`).
90
+ * `false` means it has no headless reasoning flag — a reasoning request is
91
+ * then a loud usage error (effort is provider/model config there).
92
+ */
93
+ supports_reasoning: boolean;
94
+ /**
95
+ * Whether `run --resume <session>` is supported for this harness.
96
+ */
97
+ supports_resume: boolean;
98
+ /**
99
+ * Whether a large system prompt can be delivered off the argv via a file
100
+ * flag (Claude Code's `--append-system-prompt-file`). `false` does not mean a
101
+ * large system is unhandled — for a harness whose system rides the prompt it
102
+ * travels on stdin with the prompt; see the README large-prompt matrix.
103
+ */
104
+ supports_system_file: boolean;
105
+ /**
106
+ * The project-scoped config file `oneharness sync` writes for this
107
+ * harness; `null` when it has none (sync settings are then rejected).
108
+ */
109
+ sync_file: string | null;
110
+ [k: string]: unknown;
111
+ }
112
+ /**
113
+ * One supported approval mode for a harness, with its headless behavior, in
114
+ * `oneharness list`. A [`PermissionMode`] absent from a harness's array is
115
+ * unsupported for it (a `--mode` request would be refused).
116
+ */
117
+ export interface ModeInfo {
118
+ /**
119
+ * `"clean"` (never blocks headless) or `"hangs"` (would block on an
120
+ * approval prompt; refused without --permit-prompts).
121
+ */
122
+ headless: "clean" | "hangs";
123
+ mode: PermissionMode;
124
+ [k: string]: unknown;
125
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from oneharness. Do not edit. */
2
+ export {};