@oneharness/sdk 0.26.1 → 0.27.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ const checked: RunReport = RunReportSchema.parse(report);
11
11
  console.log(checked.results[0]?.text, checked.results[0]?.usage.input_tokens);
12
12
  ```
13
13
 
14
- The client covers every verb the CLI exposes, so nothing needs a hand-built command line: `run`, `runMock`, `runStream`, `list`, `detect`, `config`, `sync`, `init`, `usage`, `gate`, `mock`, `interrupt`, `history`, `historyList`, `historyWatch`, `historyClear`, `historyMigrate`, `historyReindex`, and `historyPointers`. That coverage is gated, not asserted here. `runMock` uses the deterministic responder shipped in the CLI; see [Testing patterns](../../docs/testing-patterns.md). Both streaming methods return async iterators:
14
+ The client covers every verb the CLI exposes, so nothing needs a hand-built command line: `run`, `runMock`, `runStream`, `list`, `detect`, `config`, `sync`, `init`, `usage`, `gate`, `mock`, `interrupt`, `compact`, `history`, `historyList`, `historyWatch`, `historyClear`, `historyMigrate`, `historyReindex`, and `historyPointers`. That coverage is gated, not asserted here, and this list is held to the same capability manifest by `every_capability_is_named_in_each_sdk_readme` in [`crates/sdk-conformance/tests/sdk_conformance.rs`](../../crates/sdk-conformance/tests/sdk_conformance.rs). `runMock` uses the deterministic responder shipped in the CLI; see [Testing patterns](../../docs/testing-patterns.md). Both streaming methods return async iterators:
15
15
 
16
16
  ```ts
17
17
  for await (const envelope of oneharness.runStream({
@@ -187,6 +187,31 @@ export declare const CAPABILITIES: {
187
187
  readonly flag: "--timeout";
188
188
  readonly kind: "value";
189
189
  readonly unless: null;
190
+ }, {
191
+ readonly option: "autoCompactTokens";
192
+ readonly flag: "--auto-compact-tokens";
193
+ readonly kind: "value";
194
+ readonly unless: null;
195
+ }, {
196
+ readonly option: "toolSet";
197
+ readonly flag: "--tool-set";
198
+ readonly kind: "repeated";
199
+ readonly unless: null;
200
+ }, {
201
+ readonly option: "noSkills";
202
+ readonly flag: "--no-skills";
203
+ readonly kind: "switch";
204
+ readonly unless: null;
205
+ }, {
206
+ readonly option: "noMcp";
207
+ readonly flag: "--no-mcp";
208
+ readonly kind: "switch";
209
+ readonly unless: null;
210
+ }, {
211
+ readonly option: "images";
212
+ readonly flag: "--image";
213
+ readonly kind: "repeated";
214
+ readonly unless: null;
190
215
  }, {
191
216
  readonly option: "cwd";
192
217
  readonly flag: "--cwd";
@@ -432,6 +457,31 @@ export declare const CAPABILITIES: {
432
457
  readonly flag: "--timeout";
433
458
  readonly kind: "value";
434
459
  readonly unless: null;
460
+ }, {
461
+ readonly option: "autoCompactTokens";
462
+ readonly flag: "--auto-compact-tokens";
463
+ readonly kind: "value";
464
+ readonly unless: null;
465
+ }, {
466
+ readonly option: "toolSet";
467
+ readonly flag: "--tool-set";
468
+ readonly kind: "repeated";
469
+ readonly unless: null;
470
+ }, {
471
+ readonly option: "noSkills";
472
+ readonly flag: "--no-skills";
473
+ readonly kind: "switch";
474
+ readonly unless: null;
475
+ }, {
476
+ readonly option: "noMcp";
477
+ readonly flag: "--no-mcp";
478
+ readonly kind: "switch";
479
+ readonly unless: null;
480
+ }, {
481
+ readonly option: "images";
482
+ readonly flag: "--image";
483
+ readonly kind: "repeated";
484
+ readonly unless: null;
435
485
  }, {
436
486
  readonly option: "cwd";
437
487
  readonly flag: "--cwd";
@@ -840,6 +890,69 @@ export declare const CAPABILITIES: {
840
890
  }];
841
891
  readonly uncovered: readonly [];
842
892
  };
893
+ readonly compact: {
894
+ readonly method: "compact";
895
+ readonly argv: readonly ["compact"];
896
+ readonly options: "compact_options";
897
+ readonly output: "compact_outcome";
898
+ readonly stdout: "json";
899
+ readonly stdin: false;
900
+ readonly rust: "oneharness_core::io::compact::compact_session";
901
+ readonly always: readonly ["--compact", "--format", "json"];
902
+ readonly bindings: readonly [{
903
+ readonly option: "session";
904
+ readonly flag: "--session";
905
+ readonly kind: "value";
906
+ readonly unless: null;
907
+ }, {
908
+ readonly option: "sessionDir";
909
+ readonly flag: "--session-dir";
910
+ readonly kind: "value";
911
+ readonly unless: null;
912
+ }, {
913
+ readonly option: "harness";
914
+ readonly flag: "--harness";
915
+ readonly kind: "value";
916
+ readonly unless: null;
917
+ }, {
918
+ readonly option: "cwd";
919
+ readonly flag: "--cwd";
920
+ readonly kind: "value";
921
+ readonly unless: null;
922
+ }, {
923
+ readonly option: "model";
924
+ readonly flag: "--model";
925
+ readonly kind: "value";
926
+ readonly unless: null;
927
+ }, {
928
+ readonly option: "timeoutSeconds";
929
+ readonly flag: "--timeout";
930
+ readonly kind: "value";
931
+ readonly unless: null;
932
+ }, {
933
+ readonly option: "env";
934
+ readonly flag: "--env";
935
+ readonly kind: "key-value";
936
+ readonly unless: null;
937
+ }, {
938
+ readonly option: "bins";
939
+ readonly flag: "--bin";
940
+ readonly kind: "key-value";
941
+ readonly unless: null;
942
+ }, {
943
+ readonly option: "config";
944
+ readonly flag: "--config";
945
+ readonly kind: "repeated";
946
+ readonly unless: "noConfig";
947
+ readonly unless_resolution: "refuse";
948
+ }, {
949
+ readonly option: "noConfig";
950
+ readonly flag: "--no-config";
951
+ readonly kind: "switch";
952
+ readonly unless: null;
953
+ }];
954
+ readonly uncovered: readonly [];
955
+ };
843
956
  readonly history: {
844
957
  readonly method: "history";
845
958
  readonly argv: readonly ["history", "show"];
@@ -167,6 +167,36 @@ export const CAPABILITIES = {
167
167
  kind: "value",
168
168
  unless: null,
169
169
  },
170
+ {
171
+ option: "autoCompactTokens",
172
+ flag: "--auto-compact-tokens",
173
+ kind: "value",
174
+ unless: null,
175
+ },
176
+ {
177
+ option: "toolSet",
178
+ flag: "--tool-set",
179
+ kind: "repeated",
180
+ unless: null,
181
+ },
182
+ {
183
+ option: "noSkills",
184
+ flag: "--no-skills",
185
+ kind: "switch",
186
+ unless: null,
187
+ },
188
+ {
189
+ option: "noMcp",
190
+ flag: "--no-mcp",
191
+ kind: "switch",
192
+ unless: null,
193
+ },
194
+ {
195
+ option: "images",
196
+ flag: "--image",
197
+ kind: "repeated",
198
+ unless: null,
199
+ },
170
200
  {
171
201
  option: "cwd",
172
202
  flag: "--cwd",
@@ -461,6 +491,36 @@ export const CAPABILITIES = {
461
491
  kind: "value",
462
492
  unless: null,
463
493
  },
494
+ {
495
+ option: "autoCompactTokens",
496
+ flag: "--auto-compact-tokens",
497
+ kind: "value",
498
+ unless: null,
499
+ },
500
+ {
501
+ option: "toolSet",
502
+ flag: "--tool-set",
503
+ kind: "repeated",
504
+ unless: null,
505
+ },
506
+ {
507
+ option: "noSkills",
508
+ flag: "--no-skills",
509
+ kind: "switch",
510
+ unless: null,
511
+ },
512
+ {
513
+ option: "noMcp",
514
+ flag: "--no-mcp",
515
+ kind: "switch",
516
+ unless: null,
517
+ },
518
+ {
519
+ option: "images",
520
+ flag: "--image",
521
+ kind: "repeated",
522
+ unless: null,
523
+ },
464
524
  {
465
525
  option: "cwd",
466
526
  flag: "--cwd",
@@ -937,6 +997,80 @@ export const CAPABILITIES = {
937
997
  ],
938
998
  uncovered: [],
939
999
  },
1000
+ compact: {
1001
+ method: "compact",
1002
+ argv: ["compact"],
1003
+ options: "compact_options",
1004
+ output: "compact_outcome",
1005
+ stdout: "json",
1006
+ stdin: false,
1007
+ rust: "oneharness_core::io::compact::compact_session",
1008
+ always: ["--compact", "--format", "json"],
1009
+ bindings: [
1010
+ {
1011
+ option: "session",
1012
+ flag: "--session",
1013
+ kind: "value",
1014
+ unless: null,
1015
+ },
1016
+ {
1017
+ option: "sessionDir",
1018
+ flag: "--session-dir",
1019
+ kind: "value",
1020
+ unless: null,
1021
+ },
1022
+ {
1023
+ option: "harness",
1024
+ flag: "--harness",
1025
+ kind: "value",
1026
+ unless: null,
1027
+ },
1028
+ {
1029
+ option: "cwd",
1030
+ flag: "--cwd",
1031
+ kind: "value",
1032
+ unless: null,
1033
+ },
1034
+ {
1035
+ option: "model",
1036
+ flag: "--model",
1037
+ kind: "value",
1038
+ unless: null,
1039
+ },
1040
+ {
1041
+ option: "timeoutSeconds",
1042
+ flag: "--timeout",
1043
+ kind: "value",
1044
+ unless: null,
1045
+ },
1046
+ {
1047
+ option: "env",
1048
+ flag: "--env",
1049
+ kind: "key-value",
1050
+ unless: null,
1051
+ },
1052
+ {
1053
+ option: "bins",
1054
+ flag: "--bin",
1055
+ kind: "key-value",
1056
+ unless: null,
1057
+ },
1058
+ {
1059
+ option: "config",
1060
+ flag: "--config",
1061
+ kind: "repeated",
1062
+ unless: "noConfig",
1063
+ unless_resolution: "refuse",
1064
+ },
1065
+ {
1066
+ option: "noConfig",
1067
+ flag: "--no-config",
1068
+ kind: "switch",
1069
+ unless: null,
1070
+ },
1071
+ ],
1072
+ uncovered: [],
1073
+ },
940
1074
  history: {
941
1075
  method: "history",
942
1076
  argv: ["history", "show"],
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Options accepted by the language SDKs' `compact()`: compact a named
3
+ * session now (`oneharness compact`).
4
+ */
5
+ export interface CompactOptions {
6
+ bins?: {
7
+ [k: string]: string;
8
+ } | undefined;
9
+ config?: string[] | undefined;
10
+ cwd?: string | undefined;
11
+ env?: {
12
+ [k: string]: string;
13
+ } | undefined;
14
+ /**
15
+ * The harness identity the session is expected to be bound to.
16
+ */
17
+ harness?: string | undefined;
18
+ model?: string | undefined;
19
+ noConfig?: boolean | undefined;
20
+ /**
21
+ * The caller-owned session name (`run`'s `session`).
22
+ */
23
+ session: string;
24
+ sessionDir?: string | undefined;
25
+ timeoutSeconds?: number | undefined;
26
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from oneharness-core. Do not edit. */
2
+ export {};
@@ -0,0 +1,72 @@
1
+ /**
2
+ * How a compaction ended.
3
+ */
4
+ export type CompactStatus = "completed" | "cancelled" | "unsupported" | "failed";
5
+ /**
6
+ * The `oneharness compact` report.
7
+ */
8
+ export interface CompactOutcome {
9
+ /**
10
+ * The context size after compaction, where the harness reports it
11
+ * (claude-code's `compact_boundary.post_tokens`); `null` otherwise.
12
+ */
13
+ context_tokens_after: number | null;
14
+ /**
15
+ * The context size before compaction, where the harness reports it
16
+ * (claude-code's `compact_boundary.pre_tokens`); `null` otherwise.
17
+ */
18
+ context_tokens_before: number | null;
19
+ /**
20
+ * Why the compaction is `unsupported` or `failed`; absent otherwise.
21
+ */
22
+ error?: string | null | undefined;
23
+ /**
24
+ * The harness identity the session is bound to.
25
+ */
26
+ harness: string;
27
+ schema_version: string;
28
+ /**
29
+ * The session name compacted.
30
+ */
31
+ session: string;
32
+ status: CompactStatus;
33
+ /**
34
+ * The native session token the name continues after this call: the
35
+ * compacted fork's on `completed`, the untouched original's otherwise.
36
+ * `null` when the request was refused before a session was resolved.
37
+ */
38
+ token?: string | null | undefined;
39
+ usage: Usage;
40
+ [k: string]: unknown;
41
+ }
42
+ /**
43
+ * The compaction's own usage, every field `null` where the harness
44
+ * reports none.
45
+ */
46
+ export interface Usage {
47
+ /**
48
+ * Prompt tokens served from the provider's prompt cache (a cheap read of a
49
+ * previously-written prefix), when the harness reports them. `None` when the
50
+ * harness does not surface cache counts — never `0` as a guess.
51
+ */
52
+ cache_read_tokens: number | null;
53
+ /**
54
+ * Prompt tokens written to the provider's prompt cache (a.k.a. cache
55
+ * creation), when the harness reports them. `None` when not surfaced.
56
+ */
57
+ cache_write_tokens: number | null;
58
+ /**
59
+ * Total cost in USD, when the harness reports it (often absent on
60
+ * subscription auth, where there is no per-call dollar figure).
61
+ */
62
+ cost_usd: number | null;
63
+ /**
64
+ * Prompt/input tokens billed, when the harness reports them.
65
+ */
66
+ input_tokens: number | null;
67
+ /**
68
+ * Completion/output tokens billed, when the harness reports them.
69
+ */
70
+ output_tokens: number | null;
71
+ [k: string]: unknown;
72
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from oneharness-core. Do not edit. */
2
+ export {};
@@ -29,6 +29,10 @@ export type OutputFormat = "text" | "json" | "stream-json";
29
29
  * free of `clap`.
30
30
  */
31
31
  export type RunMode = "parallel" | "fallback";
32
+ /**
33
+ * A harness-agnostic class of built-in tool a turn may load (`tool_set`).
34
+ */
35
+ export type ToolClass = "shell" | "read";
32
36
  /**
33
37
  * The `oneharness config` report: the fully layered configuration with the
34
38
  * provenance of every value, so a consumer can see exactly which file (or
@@ -37,6 +41,7 @@ export type RunMode = "parallel" | "fallback";
37
41
  export interface ConfigReport {
38
42
  all: Field;
39
43
  allowed_tools: Field2;
44
+ auto_compact_tokens: Field5;
40
45
  bypass: Field;
41
46
  /**
42
47
  * The files consulted, in layering order (user first, project last).
@@ -66,22 +71,25 @@ export interface ConfigReport {
66
71
  [k: string]: Field3;
67
72
  };
68
73
  history_pointer_file: Field3;
69
- hooks: Field10;
70
- max_parallel: Field8;
74
+ hooks: Field11;
75
+ load_mcp: Field;
76
+ load_skills: Field;
77
+ max_parallel: Field9;
71
78
  mode: Field4;
72
79
  model: Field3;
73
80
  models: Field21;
74
- output_format: Field6;
81
+ output_format: Field7;
75
82
  reasoning: Field31;
76
83
  require_available: Field;
77
- run_mode: Field9;
84
+ run_mode: Field10;
78
85
  schema_file: Field3;
79
- schema_max_retries: Field7;
86
+ schema_max_retries: Field8;
80
87
  schema_version: string;
81
- server_overloaded_max_retries: Field7;
88
+ server_overloaded_max_retries: Field8;
82
89
  stream: Field1;
83
90
  system: Field3;
84
91
  timeout: Field5;
92
+ tool_set: Field6;
85
93
  [k: string]: unknown;
86
94
  }
87
95
  /**
@@ -104,6 +112,16 @@ export interface Field2 {
104
112
  value: string[] | null;
105
113
  [k: string]: unknown;
106
114
  }
115
+ /**
116
+ * One resolved field in the `oneharness config` report: the effective value
117
+ * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
118
+ * are `null` when the field is unset everywhere and has no built-in default.
119
+ */
120
+ export interface Field5 {
121
+ source: string | null;
122
+ value: number | null;
123
+ [k: string]: unknown;
124
+ }
107
125
  /**
108
126
  * One resolved field in the `oneharness config` report: the effective value
109
127
  * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
@@ -127,7 +145,7 @@ export interface HarnessReport {
127
145
  * The resolved `app_server` (`"shared"` by default), present only for
128
146
  * `codex`.
129
147
  */
130
- app_server?: Field11 | null | undefined;
148
+ app_server?: Field12 | null | undefined;
131
149
  /**
132
150
  * The resolved `apps` opt-in (`false` by default), present only for
133
151
  * `codex`.
@@ -172,21 +190,11 @@ export interface HarnessReport {
172
190
  * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
173
191
  * are `null` when the field is unset everywhere and has no built-in default.
174
192
  */
175
- export interface Field11 {
193
+ export interface Field12 {
176
194
  source: string | null;
177
195
  value: AppServerMode | null;
178
196
  [k: string]: unknown;
179
197
  }
180
- /**
181
- * One resolved field in the `oneharness config` report: the effective value
182
- * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
183
- * are `null` when the field is unset everywhere and has no built-in default.
184
- */
185
- export interface Field5 {
186
- source: string | null;
187
- value: number | null;
188
- [k: string]: unknown;
189
- }
190
198
  export interface VariantReport {
191
199
  allowed_tools: Field2;
192
200
  /**
@@ -198,7 +206,7 @@ export interface VariantReport {
198
206
  * The `app_server` a launch of this variant resolves to: the variant's
199
207
  * own, else its harness's, else `"shared"`. Present only for `codex`.
200
208
  */
201
- app_server?: Field11 | null | undefined;
209
+ app_server?: Field12 | null | undefined;
202
210
  /**
203
211
  * The apps opt-in a launch of this variant resolves to: the variant's
204
212
  * own, else its harness's, else `false`. Present only for `codex`.
@@ -247,7 +255,7 @@ export interface VariantReport {
247
255
  * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
248
256
  * are `null` when the field is unset everywhere and has no built-in default.
249
257
  */
250
- export interface Field10 {
258
+ export interface Field11 {
251
259
  source: string | null;
252
260
  value: HookEntry[] | null;
253
261
  [k: string]: unknown;
@@ -290,7 +298,7 @@ export interface HookEntry {
290
298
  * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
291
299
  * are `null` when the field is unset everywhere and has no built-in default.
292
300
  */
293
- export interface Field8 {
301
+ export interface Field9 {
294
302
  source: string | null;
295
303
  value: number | null;
296
304
  [k: string]: unknown;
@@ -319,7 +327,7 @@ export interface Field21 {
319
327
  * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
320
328
  * are `null` when the field is unset everywhere and has no built-in default.
321
329
  */
322
- export interface Field6 {
330
+ export interface Field7 {
323
331
  source: string | null;
324
332
  value: OutputFormat | null;
325
333
  [k: string]: unknown;
@@ -339,7 +347,7 @@ export interface Field31 {
339
347
  * built-in default, attributed to [`DEFAULT_SOURCE`]) — the report says what
340
348
  * a run would do, so an unset mode is never shown as `null`.
341
349
  */
342
- export interface Field9 {
350
+ export interface Field10 {
343
351
  source: string | null;
344
352
  value: RunMode | null;
345
353
  [k: string]: unknown;
@@ -349,7 +357,7 @@ export interface Field9 {
349
357
  * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
350
358
  * are `null` when the field is unset everywhere and has no built-in default.
351
359
  */
352
- export interface Field7 {
360
+ export interface Field8 {
353
361
  source: string | null;
354
362
  value: number | null;
355
363
  [k: string]: unknown;
@@ -364,3 +372,13 @@ export interface Field1 {
364
372
  value: boolean | null;
365
373
  [k: string]: unknown;
366
374
  }
375
+ /**
376
+ * One resolved field in the `oneharness config` report: the effective value
377
+ * plus where it came from (a config file path, or [`DEFAULT_SOURCE`]). Both
378
+ * are `null` when the field is unset everywhere and has no built-in default.
379
+ */
380
+ export interface Field6 {
381
+ source: string | null;
382
+ value: ToolClass[] | null;
383
+ [k: string]: unknown;
384
+ }