@oneharness/sdk 0.19.1 → 0.21.1
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 +2 -2
- package/dist/generated/capabilities.d.ts +72 -8
- package/dist/generated/capabilities.js +70 -8
- package/dist/generated/history-list-options.d.ts +25 -0
- package/dist/generated/history-lookup.d.ts +31 -0
- package/dist/generated/history-reindex-options.d.ts +16 -0
- package/dist/generated/history-reindex-report.d.ts +54 -0
- package/dist/generated/history-reindex-report.js +2 -0
- package/dist/generated/{history-records.d.ts → history-show-entries.d.ts} +89 -61
- package/dist/generated/history-show-entries.js +2 -0
- package/dist/generated/history-watch-options.d.ts +26 -0
- package/dist/generated/run-stream-envelope.d.ts +2 -1
- package/dist/generated/schemas.json +444 -12
- package/dist/generated/zod.d.ts +14 -3
- package/dist/generated/zod.js +78 -1
- package/dist/index.d.ts +44 -3
- package/dist/index.js +57 -2
- package/package.json +2 -2
- /package/dist/generated/{history-records.js → history-reindex-options.js} +0 -0
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`, 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`, `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:
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
17
|
for await (const envelope of oneharness.runStream({
|
|
@@ -35,7 +35,7 @@ Breaking or returning from either iterator terminates its oneharness subprocess.
|
|
|
35
35
|
|
|
36
36
|
`null` usage fields mean the harness did not report the value; zero remains a real measured zero. String-valued harness/model/event identifiers should be treated as open sets for forward compatibility. `history` and `historyWatch` raise the exported `HistoryNotFoundError` when a session, record, or watch cursor cannot be resolved.
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Every contract the CLI reads or prints is exported as a Zod schema named after its generated TypeScript type plus `Schema` (`RunReport` → `RunReportSchema`), generated from the same Rust wire types. Each schema's `z.infer` type is compile-time checked against its generated TypeScript type.
|
|
39
39
|
|
|
40
40
|
Output objects accept and preserve unknown fields. That deliberate loose-object behavior lets an older SDK validate a newer additive CLI response without erasing fields before an application can inspect them. Known fields are still validated recursively. The input schemas `RunOptionsSchema`, `HistoryLookupSchema`, `HistoryListOptionsSchema`, and `HistoryWatchOptionsSchema` are deliberately strict instead: unknown input keys are rejected because this SDK version cannot forward an option it does not understand, which also catches misspellings. Every method validates its input before spawning the CLI.
|
|
41
41
|
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export type FlagKind = "positional" | "value" | "repeated" | "switch" | "key-value" | "trailing";
|
|
1
|
+
export type FlagKind = "positional" | "value" | "repeated" | "switch" | "key-value" | "trailing" | "window";
|
|
2
|
+
/** The three spellings a `window` binding renders exactly one of. */
|
|
3
|
+
export type WindowFlags = {
|
|
4
|
+
readonly days: string;
|
|
5
|
+
readonly since: string;
|
|
6
|
+
readonly allTime: string;
|
|
7
|
+
};
|
|
2
8
|
/**
|
|
3
9
|
* What both members of a suppressed pair rendering an argument means.
|
|
4
10
|
*
|
|
@@ -17,6 +23,8 @@ export type OptionBinding = {
|
|
|
17
23
|
readonly unless: string | null;
|
|
18
24
|
/** Only present beside an `unless`, which it says how to resolve. */
|
|
19
25
|
readonly unless_resolution?: UnlessResolution;
|
|
26
|
+
/** Only present on a `window` binding: the flag each window renders. */
|
|
27
|
+
readonly window?: WindowFlags;
|
|
20
28
|
};
|
|
21
29
|
/** How a verb's stdout reaches a caller. */
|
|
22
30
|
export type StdoutShape = "json" | "jsonl" | "text";
|
|
@@ -296,7 +304,7 @@ export declare const CAPABILITIES: {
|
|
|
296
304
|
readonly stdout: "jsonl";
|
|
297
305
|
readonly stdin: false;
|
|
298
306
|
readonly rust: "oneharness_core::io::run::run";
|
|
299
|
-
readonly always: readonly ["--compact", "--stream"];
|
|
307
|
+
readonly always: readonly ["--compact", "--format", "json", "--stream"];
|
|
300
308
|
readonly bindings: readonly [{
|
|
301
309
|
readonly option: "prompt";
|
|
302
310
|
readonly flag: "--prompt";
|
|
@@ -531,9 +539,6 @@ export declare const CAPABILITIES: {
|
|
|
531
539
|
}, {
|
|
532
540
|
readonly flag: "--no-stream";
|
|
533
541
|
readonly reason: "this method streams by definition, so the negative half cannot apply";
|
|
534
|
-
}, {
|
|
535
|
-
readonly flag: "--format";
|
|
536
|
-
readonly reason: "a stream is its own NDJSON protocol (event lines, then the result envelope), which `--format` never changes";
|
|
537
542
|
}];
|
|
538
543
|
};
|
|
539
544
|
readonly list: {
|
|
@@ -839,10 +844,10 @@ export declare const CAPABILITIES: {
|
|
|
839
844
|
readonly method: "history";
|
|
840
845
|
readonly argv: readonly ["history", "show"];
|
|
841
846
|
readonly options: "history_lookup";
|
|
842
|
-
readonly output: "
|
|
847
|
+
readonly output: "history_show_entries";
|
|
843
848
|
readonly stdout: "json";
|
|
844
849
|
readonly stdin: false;
|
|
845
|
-
readonly rust: "oneharness_core::io::history::
|
|
850
|
+
readonly rust: "oneharness_core::io::history::read_session_display";
|
|
846
851
|
readonly always: readonly ["--compact", "--format", "json"];
|
|
847
852
|
readonly bindings: readonly [{
|
|
848
853
|
readonly option: "session";
|
|
@@ -871,6 +876,16 @@ export declare const CAPABILITIES: {
|
|
|
871
876
|
readonly flag: "--all-projects";
|
|
872
877
|
readonly kind: "switch";
|
|
873
878
|
readonly unless: null;
|
|
879
|
+
}, {
|
|
880
|
+
readonly option: "window";
|
|
881
|
+
readonly flag: "";
|
|
882
|
+
readonly kind: "window";
|
|
883
|
+
readonly unless: null;
|
|
884
|
+
readonly window: {
|
|
885
|
+
readonly days: "--days";
|
|
886
|
+
readonly since: "--since";
|
|
887
|
+
readonly allTime: "--all-time";
|
|
888
|
+
};
|
|
874
889
|
}, {
|
|
875
890
|
readonly option: "historyDir";
|
|
876
891
|
readonly flag: "--history-dir";
|
|
@@ -915,6 +930,16 @@ export declare const CAPABILITIES: {
|
|
|
915
930
|
readonly flag: "--all-projects";
|
|
916
931
|
readonly kind: "switch";
|
|
917
932
|
readonly unless: null;
|
|
933
|
+
}, {
|
|
934
|
+
readonly option: "window";
|
|
935
|
+
readonly flag: "";
|
|
936
|
+
readonly kind: "window";
|
|
937
|
+
readonly unless: null;
|
|
938
|
+
readonly window: {
|
|
939
|
+
readonly days: "--days";
|
|
940
|
+
readonly since: "--since";
|
|
941
|
+
readonly allTime: "--all-time";
|
|
942
|
+
};
|
|
918
943
|
}, {
|
|
919
944
|
readonly option: "historyDir";
|
|
920
945
|
readonly flag: "--history-dir";
|
|
@@ -947,7 +972,8 @@ export declare const CAPABILITIES: {
|
|
|
947
972
|
readonly option: "after";
|
|
948
973
|
readonly flag: "--after";
|
|
949
974
|
readonly kind: "value";
|
|
950
|
-
readonly unless:
|
|
975
|
+
readonly unless: "window";
|
|
976
|
+
readonly unless_resolution: "refuse";
|
|
951
977
|
}, {
|
|
952
978
|
readonly option: "labels";
|
|
953
979
|
readonly flag: "--label";
|
|
@@ -984,6 +1010,16 @@ export declare const CAPABILITIES: {
|
|
|
984
1010
|
readonly flag: "--events";
|
|
985
1011
|
readonly kind: "switch";
|
|
986
1012
|
readonly unless: null;
|
|
1013
|
+
}, {
|
|
1014
|
+
readonly option: "window";
|
|
1015
|
+
readonly flag: "";
|
|
1016
|
+
readonly kind: "window";
|
|
1017
|
+
readonly unless: null;
|
|
1018
|
+
readonly window: {
|
|
1019
|
+
readonly days: "--days";
|
|
1020
|
+
readonly since: "--since";
|
|
1021
|
+
readonly allTime: "--all-time";
|
|
1022
|
+
};
|
|
987
1023
|
}, {
|
|
988
1024
|
readonly option: "config";
|
|
989
1025
|
readonly flag: "--config";
|
|
@@ -1070,6 +1106,34 @@ export declare const CAPABILITIES: {
|
|
|
1070
1106
|
}];
|
|
1071
1107
|
readonly uncovered: readonly [];
|
|
1072
1108
|
};
|
|
1109
|
+
readonly historyReindex: {
|
|
1110
|
+
readonly method: "historyReindex";
|
|
1111
|
+
readonly argv: readonly ["history", "reindex"];
|
|
1112
|
+
readonly options: "history_reindex_options";
|
|
1113
|
+
readonly output: "history_reindex_report";
|
|
1114
|
+
readonly stdout: "json";
|
|
1115
|
+
readonly stdin: false;
|
|
1116
|
+
readonly rust: "oneharness_core::io::history::reindex";
|
|
1117
|
+
readonly always: readonly ["--compact", "--format", "json"];
|
|
1118
|
+
readonly bindings: readonly [{
|
|
1119
|
+
readonly option: "historyDir";
|
|
1120
|
+
readonly flag: "--history-dir";
|
|
1121
|
+
readonly kind: "value";
|
|
1122
|
+
readonly unless: null;
|
|
1123
|
+
}, {
|
|
1124
|
+
readonly option: "config";
|
|
1125
|
+
readonly flag: "--config";
|
|
1126
|
+
readonly kind: "repeated";
|
|
1127
|
+
readonly unless: "noConfig";
|
|
1128
|
+
readonly unless_resolution: "refuse";
|
|
1129
|
+
}, {
|
|
1130
|
+
readonly option: "noConfig";
|
|
1131
|
+
readonly flag: "--no-config";
|
|
1132
|
+
readonly kind: "switch";
|
|
1133
|
+
readonly unless: null;
|
|
1134
|
+
}];
|
|
1135
|
+
readonly uncovered: readonly [];
|
|
1136
|
+
};
|
|
1073
1137
|
readonly historyPointers: {
|
|
1074
1138
|
readonly method: "historyPointers";
|
|
1075
1139
|
readonly argv: readonly ["history", "pointers"];
|
|
@@ -307,7 +307,7 @@ export const CAPABILITIES = {
|
|
|
307
307
|
stdout: "jsonl",
|
|
308
308
|
stdin: false,
|
|
309
309
|
rust: "oneharness_core::io::run::run",
|
|
310
|
-
always: ["--compact", "--stream"],
|
|
310
|
+
always: ["--compact", "--format", "json", "--stream"],
|
|
311
311
|
bindings: [
|
|
312
312
|
{
|
|
313
313
|
option: "prompt",
|
|
@@ -591,10 +591,6 @@ export const CAPABILITIES = {
|
|
|
591
591
|
flag: "--no-stream",
|
|
592
592
|
reason: "this method streams by definition, so the negative half cannot apply",
|
|
593
593
|
},
|
|
594
|
-
{
|
|
595
|
-
flag: "--format",
|
|
596
|
-
reason: "a stream is its own NDJSON protocol (event lines, then the result envelope), which `--format` never changes",
|
|
597
|
-
},
|
|
598
594
|
],
|
|
599
595
|
},
|
|
600
596
|
list: {
|
|
@@ -945,10 +941,10 @@ export const CAPABILITIES = {
|
|
|
945
941
|
method: "history",
|
|
946
942
|
argv: ["history", "show"],
|
|
947
943
|
options: "history_lookup",
|
|
948
|
-
output: "
|
|
944
|
+
output: "history_show_entries",
|
|
949
945
|
stdout: "json",
|
|
950
946
|
stdin: false,
|
|
951
|
-
rust: "oneharness_core::io::history::
|
|
947
|
+
rust: "oneharness_core::io::history::read_session_display",
|
|
952
948
|
always: ["--compact", "--format", "json"],
|
|
953
949
|
bindings: [
|
|
954
950
|
{
|
|
@@ -983,6 +979,17 @@ export const CAPABILITIES = {
|
|
|
983
979
|
kind: "switch",
|
|
984
980
|
unless: null,
|
|
985
981
|
},
|
|
982
|
+
{
|
|
983
|
+
option: "window",
|
|
984
|
+
flag: "",
|
|
985
|
+
kind: "window",
|
|
986
|
+
unless: null,
|
|
987
|
+
window: {
|
|
988
|
+
days: "--days",
|
|
989
|
+
since: "--since",
|
|
990
|
+
allTime: "--all-time",
|
|
991
|
+
},
|
|
992
|
+
},
|
|
986
993
|
{
|
|
987
994
|
option: "historyDir",
|
|
988
995
|
flag: "--history-dir",
|
|
@@ -1034,6 +1041,17 @@ export const CAPABILITIES = {
|
|
|
1034
1041
|
kind: "switch",
|
|
1035
1042
|
unless: null,
|
|
1036
1043
|
},
|
|
1044
|
+
{
|
|
1045
|
+
option: "window",
|
|
1046
|
+
flag: "",
|
|
1047
|
+
kind: "window",
|
|
1048
|
+
unless: null,
|
|
1049
|
+
window: {
|
|
1050
|
+
days: "--days",
|
|
1051
|
+
since: "--since",
|
|
1052
|
+
allTime: "--all-time",
|
|
1053
|
+
},
|
|
1054
|
+
},
|
|
1037
1055
|
{
|
|
1038
1056
|
option: "historyDir",
|
|
1039
1057
|
flag: "--history-dir",
|
|
@@ -1070,7 +1088,8 @@ export const CAPABILITIES = {
|
|
|
1070
1088
|
option: "after",
|
|
1071
1089
|
flag: "--after",
|
|
1072
1090
|
kind: "value",
|
|
1073
|
-
unless:
|
|
1091
|
+
unless: "window",
|
|
1092
|
+
unless_resolution: "refuse",
|
|
1074
1093
|
},
|
|
1075
1094
|
{
|
|
1076
1095
|
option: "labels",
|
|
@@ -1115,6 +1134,17 @@ export const CAPABILITIES = {
|
|
|
1115
1134
|
kind: "switch",
|
|
1116
1135
|
unless: null,
|
|
1117
1136
|
},
|
|
1137
|
+
{
|
|
1138
|
+
option: "window",
|
|
1139
|
+
flag: "",
|
|
1140
|
+
kind: "window",
|
|
1141
|
+
unless: null,
|
|
1142
|
+
window: {
|
|
1143
|
+
days: "--days",
|
|
1144
|
+
since: "--since",
|
|
1145
|
+
allTime: "--all-time",
|
|
1146
|
+
},
|
|
1147
|
+
},
|
|
1118
1148
|
{
|
|
1119
1149
|
option: "config",
|
|
1120
1150
|
flag: "--config",
|
|
@@ -1214,6 +1244,38 @@ export const CAPABILITIES = {
|
|
|
1214
1244
|
],
|
|
1215
1245
|
uncovered: [],
|
|
1216
1246
|
},
|
|
1247
|
+
historyReindex: {
|
|
1248
|
+
method: "historyReindex",
|
|
1249
|
+
argv: ["history", "reindex"],
|
|
1250
|
+
options: "history_reindex_options",
|
|
1251
|
+
output: "history_reindex_report",
|
|
1252
|
+
stdout: "json",
|
|
1253
|
+
stdin: false,
|
|
1254
|
+
rust: "oneharness_core::io::history::reindex",
|
|
1255
|
+
always: ["--compact", "--format", "json"],
|
|
1256
|
+
bindings: [
|
|
1257
|
+
{
|
|
1258
|
+
option: "historyDir",
|
|
1259
|
+
flag: "--history-dir",
|
|
1260
|
+
kind: "value",
|
|
1261
|
+
unless: null,
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
option: "config",
|
|
1265
|
+
flag: "--config",
|
|
1266
|
+
kind: "repeated",
|
|
1267
|
+
unless: "noConfig",
|
|
1268
|
+
unless_resolution: "refuse",
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
option: "noConfig",
|
|
1272
|
+
flag: "--no-config",
|
|
1273
|
+
kind: "switch",
|
|
1274
|
+
unless: null,
|
|
1275
|
+
},
|
|
1276
|
+
],
|
|
1277
|
+
uncovered: [],
|
|
1278
|
+
},
|
|
1217
1279
|
historyPointers: {
|
|
1218
1280
|
method: "historyPointers",
|
|
1219
1281
|
argv: ["history", "pointers"],
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which dates of the index a listing reads.
|
|
3
|
+
*
|
|
4
|
+
* It is also the one value an SDK history lookup, listing or watch takes as
|
|
5
|
+
* its `window`, so "from this date" and "from the beginning" cannot both be
|
|
6
|
+
* stated. On the wire it is externally tagged in camelCase —
|
|
7
|
+
* `{"recent": {"days": 3}}`, `{"since": "2026-01-05"}`, or `"allTime"` — and
|
|
8
|
+
* renders to the CLI's `--days`, `--since` or `--all-time`.
|
|
9
|
+
*/
|
|
10
|
+
export type HistoryWindow = {
|
|
11
|
+
recent: {
|
|
12
|
+
/**
|
|
13
|
+
* How many UTC days, today included; at least one.
|
|
14
|
+
*/
|
|
15
|
+
days: number;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
since: string;
|
|
19
|
+
} | "allTime";
|
|
1
20
|
/**
|
|
2
21
|
* Options accepted by `OneHarness.historyList()` in the published Node SDK.
|
|
3
22
|
*/
|
|
@@ -19,4 +38,10 @@ export interface HistoryListOptions {
|
|
|
19
38
|
* Narrow to one configured harness identity (`claude-code:work`).
|
|
20
39
|
*/
|
|
21
40
|
variant?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Which dates of the index to read: the last `days` UTC days, from a
|
|
43
|
+
* UTC date on, or all time (every dated segment plus the legacy index an
|
|
44
|
+
* older oneharness kept). Omitted, the last 7 UTC days.
|
|
45
|
+
*/
|
|
46
|
+
window?: HistoryWindow | null | undefined;
|
|
22
47
|
}
|
|
@@ -24,6 +24,25 @@
|
|
|
24
24
|
* non-empty.
|
|
25
25
|
*/
|
|
26
26
|
export type HistoryLookup = HistoryLookupByLast | HistoryLookupBySession;
|
|
27
|
+
/**
|
|
28
|
+
* Which dates of the index a listing reads.
|
|
29
|
+
*
|
|
30
|
+
* It is also the one value an SDK history lookup, listing or watch takes as
|
|
31
|
+
* its `window`, so "from this date" and "from the beginning" cannot both be
|
|
32
|
+
* stated. On the wire it is externally tagged in camelCase —
|
|
33
|
+
* `{"recent": {"days": 3}}`, `{"since": "2026-01-05"}`, or `"allTime"` — and
|
|
34
|
+
* renders to the CLI's `--days`, `--since` or `--all-time`.
|
|
35
|
+
*/
|
|
36
|
+
export type HistoryWindow = {
|
|
37
|
+
recent: {
|
|
38
|
+
/**
|
|
39
|
+
* How many UTC days, today included; at least one.
|
|
40
|
+
*/
|
|
41
|
+
days: number;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
since: string;
|
|
45
|
+
} | "allTime";
|
|
27
46
|
/**
|
|
28
47
|
* Select the most recent session.
|
|
29
48
|
*/
|
|
@@ -57,6 +76,12 @@ export interface HistoryLookupByLast {
|
|
|
57
76
|
* than invalid, so `{"session": "", "last": true}` stays accepted.
|
|
58
77
|
*/
|
|
59
78
|
session?: string | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Which dates of the index to read: the last `days` UTC days, from a
|
|
81
|
+
* UTC date on, or all time (every dated segment plus the legacy index an
|
|
82
|
+
* older oneharness kept). Omitted, the last 7 UTC days.
|
|
83
|
+
*/
|
|
84
|
+
window?: HistoryWindow | null | undefined;
|
|
60
85
|
}
|
|
61
86
|
/**
|
|
62
87
|
* Select the session named by `session`.
|
|
@@ -91,4 +116,10 @@ export interface HistoryLookupBySession {
|
|
|
91
116
|
* the name that selects, so it must be non-empty.
|
|
92
117
|
*/
|
|
93
118
|
session: string;
|
|
119
|
+
/**
|
|
120
|
+
* Which dates of the index to read: the last `days` UTC days, from a
|
|
121
|
+
* UTC date on, or all time (every dated segment plus the legacy index an
|
|
122
|
+
* older oneharness kept). Omitted, the last 7 UTC days.
|
|
123
|
+
*/
|
|
124
|
+
window?: HistoryWindow | null | undefined;
|
|
94
125
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options accepted by the language SDKs' `historyReindex()`.
|
|
3
|
+
*/
|
|
4
|
+
export interface HistoryReindexOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Load configuration from exactly these files, in order, skipping
|
|
7
|
+
* user/project discovery; each later file overrides the earlier ones.
|
|
8
|
+
*/
|
|
9
|
+
config?: string[] | undefined;
|
|
10
|
+
historyDir?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Ignore every configuration file and `ONEHARNESS_*` override. `true`
|
|
13
|
+
* beside a non-empty `config` is refused before anything runs.
|
|
14
|
+
*/
|
|
15
|
+
noConfig?: boolean | undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `oneharness history reindex` output contract.
|
|
3
|
+
*/
|
|
4
|
+
export interface HistoryReindexReport {
|
|
5
|
+
/**
|
|
6
|
+
* The sum of `segments[].added`.
|
|
7
|
+
*/
|
|
8
|
+
entries_added: number;
|
|
9
|
+
/**
|
|
10
|
+
* How many session files were read.
|
|
11
|
+
*/
|
|
12
|
+
files_read: number;
|
|
13
|
+
/**
|
|
14
|
+
* One row per segment this run appended to, in file-name order; a
|
|
15
|
+
* segment that already held every entry is not listed.
|
|
16
|
+
*/
|
|
17
|
+
segments: SegmentReindexSummary[];
|
|
18
|
+
/**
|
|
19
|
+
* Every session file (or project directory) that could not be read,
|
|
20
|
+
* with why. The rest are indexed regardless.
|
|
21
|
+
*/
|
|
22
|
+
unreadable: UnreadableSessionFile[];
|
|
23
|
+
[k: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What [`reindex`] appended to one segment.
|
|
27
|
+
*/
|
|
28
|
+
export interface SegmentReindexSummary {
|
|
29
|
+
/**
|
|
30
|
+
* How many entries this run appended to it.
|
|
31
|
+
*/
|
|
32
|
+
added: number;
|
|
33
|
+
/**
|
|
34
|
+
* The segment's path, as a display string.
|
|
35
|
+
*/
|
|
36
|
+
path: string;
|
|
37
|
+
/**
|
|
38
|
+
* The segment's file name (`runs-YYYY-MM-DD.ndjson` or
|
|
39
|
+
* `events-YYYY-MM-DD.ndjson`).
|
|
40
|
+
*/
|
|
41
|
+
segment: string;
|
|
42
|
+
[k: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A session file [`reindex`] could not read.
|
|
46
|
+
*/
|
|
47
|
+
export interface UnreadableSessionFile {
|
|
48
|
+
/**
|
|
49
|
+
* Why it could not be read, as the operating system said it.
|
|
50
|
+
*/
|
|
51
|
+
error: string;
|
|
52
|
+
path: string;
|
|
53
|
+
[k: string]: unknown;
|
|
54
|
+
}
|
|
@@ -1,4 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* One entry of `history show`'s answer: a finished run's record, or a run still
|
|
3
|
+
* in flight.
|
|
4
|
+
*/
|
|
5
|
+
export type HistoryShowEntry = (({
|
|
6
|
+
error?: null | undefined;
|
|
7
|
+
[k: string]: unknown;
|
|
8
|
+
} | ({
|
|
9
|
+
error: string;
|
|
10
|
+
schema_version?: "1.3" | "1.4" | "1.5" | "1.6" | "1.7" | "1.8" | "1.9" | undefined;
|
|
11
|
+
[k: string]: unknown;
|
|
12
|
+
} & ({
|
|
13
|
+
status?: "nonzero" | "timeout" | "cancelled" | "spawn-error" | "skipped" | undefined;
|
|
14
|
+
[k: string]: unknown;
|
|
15
|
+
} | {
|
|
16
|
+
failure_kind: "tool_deferred";
|
|
17
|
+
[k: string]: unknown;
|
|
18
|
+
}))) & ({
|
|
19
|
+
work?: null | undefined;
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
} | {
|
|
22
|
+
schema_version?: "1.7" | "1.8" | "1.9" | undefined;
|
|
23
|
+
status?: "nonzero" | "timeout" | "cancelled" | undefined;
|
|
24
|
+
work: "done" | "none";
|
|
25
|
+
[k: string]: unknown;
|
|
26
|
+
}) & ({
|
|
27
|
+
observed_model?: null | undefined;
|
|
28
|
+
[k: string]: unknown;
|
|
29
|
+
} | {
|
|
30
|
+
observed_model: string;
|
|
31
|
+
schema_version?: "1.8" | "1.9" | undefined;
|
|
32
|
+
[k: string]: unknown;
|
|
33
|
+
}) & ({
|
|
34
|
+
status?: "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned" | undefined;
|
|
35
|
+
[k: string]: unknown;
|
|
36
|
+
} | {
|
|
37
|
+
schema_version?: "1.4" | "1.5" | "1.6" | "1.7" | "1.8" | "1.9" | undefined;
|
|
38
|
+
[k: string]: unknown;
|
|
39
|
+
}) & (({
|
|
40
|
+
failure_kind?: "auth" | "rate_limit" | "model_not_found" | "quota" | "tool_deferred" | "untrusted_directory" | "input_too_large" | "model_mismatch" | "server_overloaded" | null;
|
|
41
|
+
[k: string]: unknown;
|
|
42
|
+
} | {
|
|
43
|
+
schema_version?: "1.5" | "1.6" | "1.7" | "1.8" | "1.9" | undefined;
|
|
44
|
+
[k: string]: unknown;
|
|
45
|
+
}) & ({
|
|
46
|
+
failure_kind?: "auth" | "rate_limit" | "model_not_found" | "quota" | "session_not_found" | "tool_deferred" | "model_mismatch" | "server_overloaded" | null;
|
|
47
|
+
[k: string]: unknown;
|
|
48
|
+
} | {
|
|
49
|
+
schema_version?: "1.6" | "1.7" | "1.8" | "1.9" | undefined;
|
|
50
|
+
[k: string]: unknown;
|
|
51
|
+
}) & ({
|
|
52
|
+
failure_kind?: "auth" | "rate_limit" | "model_not_found" | "quota" | "session_not_found" | "tool_deferred" | "untrusted_directory" | "input_too_large" | "server_overloaded" | null;
|
|
53
|
+
[k: string]: unknown;
|
|
54
|
+
} | {
|
|
55
|
+
schema_version?: "1.8" | "1.9" | undefined;
|
|
56
|
+
[k: string]: unknown;
|
|
57
|
+
}) & ({
|
|
58
|
+
failure_kind?: "auth" | "rate_limit" | "model_not_found" | "quota" | "session_not_found" | "tool_deferred" | "untrusted_directory" | "input_too_large" | "model_mismatch" | null;
|
|
59
|
+
[k: string]: unknown;
|
|
60
|
+
} | {
|
|
61
|
+
schema_version?: "1.9" | undefined;
|
|
62
|
+
[k: string]: unknown;
|
|
63
|
+
})) & ({
|
|
2
64
|
duration_ms: number;
|
|
3
65
|
/**
|
|
4
66
|
* Best-effort normalized failure text for a run that did not succeed: the
|
|
@@ -1255,7 +1317,7 @@ export type HistoryRecord = {
|
|
|
1255
1317
|
*/
|
|
1256
1318
|
work?: RunWork | null | undefined;
|
|
1257
1319
|
[k: string]: unknown;
|
|
1258
|
-
};
|
|
1320
|
+
})) | IncompleteHistoryRun;
|
|
1259
1321
|
export type ToolCallStatus = "completed" | "failed" | "timeout" | "interrupted";
|
|
1260
1322
|
/**
|
|
1261
1323
|
* How a normalized tool interval was obtained.
|
|
@@ -1298,65 +1360,7 @@ export type Status = "ok" | "nonzero" | "timeout" | "cancelled" | "spawn-error"
|
|
|
1298
1360
|
* [billed]: crate::domain::signals::Usage::reports_billed_work
|
|
1299
1361
|
*/
|
|
1300
1362
|
export type RunWork = "done" | "none";
|
|
1301
|
-
export type
|
|
1302
|
-
error?: null | undefined;
|
|
1303
|
-
[k: string]: unknown;
|
|
1304
|
-
} | ({
|
|
1305
|
-
error: string;
|
|
1306
|
-
schema_version?: "1.3" | "1.4" | "1.5" | "1.6" | "1.7" | "1.8" | "1.9" | undefined;
|
|
1307
|
-
[k: string]: unknown;
|
|
1308
|
-
} & ({
|
|
1309
|
-
status?: "nonzero" | "timeout" | "cancelled" | "spawn-error" | "skipped" | undefined;
|
|
1310
|
-
[k: string]: unknown;
|
|
1311
|
-
} | {
|
|
1312
|
-
failure_kind: "tool_deferred";
|
|
1313
|
-
[k: string]: unknown;
|
|
1314
|
-
}))) & ({
|
|
1315
|
-
work?: null | undefined;
|
|
1316
|
-
[k: string]: unknown;
|
|
1317
|
-
} | {
|
|
1318
|
-
schema_version?: "1.7" | "1.8" | "1.9" | undefined;
|
|
1319
|
-
status?: "nonzero" | "timeout" | "cancelled" | undefined;
|
|
1320
|
-
work: "done" | "none";
|
|
1321
|
-
[k: string]: unknown;
|
|
1322
|
-
}) & ({
|
|
1323
|
-
observed_model?: null | undefined;
|
|
1324
|
-
[k: string]: unknown;
|
|
1325
|
-
} | {
|
|
1326
|
-
observed_model: string;
|
|
1327
|
-
schema_version?: "1.8" | "1.9" | undefined;
|
|
1328
|
-
[k: string]: unknown;
|
|
1329
|
-
}) & ({
|
|
1330
|
-
status?: "ok" | "nonzero" | "timeout" | "spawn-error" | "skipped" | "planned" | undefined;
|
|
1331
|
-
[k: string]: unknown;
|
|
1332
|
-
} | {
|
|
1333
|
-
schema_version?: "1.4" | "1.5" | "1.6" | "1.7" | "1.8" | "1.9" | undefined;
|
|
1334
|
-
[k: string]: unknown;
|
|
1335
|
-
}) & (({
|
|
1336
|
-
failure_kind?: "auth" | "rate_limit" | "model_not_found" | "quota" | "tool_deferred" | "untrusted_directory" | "input_too_large" | "model_mismatch" | "server_overloaded" | null;
|
|
1337
|
-
[k: string]: unknown;
|
|
1338
|
-
} | {
|
|
1339
|
-
schema_version?: "1.5" | "1.6" | "1.7" | "1.8" | "1.9" | undefined;
|
|
1340
|
-
[k: string]: unknown;
|
|
1341
|
-
}) & ({
|
|
1342
|
-
failure_kind?: "auth" | "rate_limit" | "model_not_found" | "quota" | "session_not_found" | "tool_deferred" | "model_mismatch" | "server_overloaded" | null;
|
|
1343
|
-
[k: string]: unknown;
|
|
1344
|
-
} | {
|
|
1345
|
-
schema_version?: "1.6" | "1.7" | "1.8" | "1.9" | undefined;
|
|
1346
|
-
[k: string]: unknown;
|
|
1347
|
-
}) & ({
|
|
1348
|
-
failure_kind?: "auth" | "rate_limit" | "model_not_found" | "quota" | "session_not_found" | "tool_deferred" | "untrusted_directory" | "input_too_large" | "server_overloaded" | null;
|
|
1349
|
-
[k: string]: unknown;
|
|
1350
|
-
} | {
|
|
1351
|
-
schema_version?: "1.8" | "1.9" | undefined;
|
|
1352
|
-
[k: string]: unknown;
|
|
1353
|
-
}) & ({
|
|
1354
|
-
failure_kind?: "auth" | "rate_limit" | "model_not_found" | "quota" | "session_not_found" | "tool_deferred" | "untrusted_directory" | "input_too_large" | "model_mismatch" | null;
|
|
1355
|
-
[k: string]: unknown;
|
|
1356
|
-
} | {
|
|
1357
|
-
schema_version?: "1.9" | undefined;
|
|
1358
|
-
[k: string]: unknown;
|
|
1359
|
-
})) & HistoryRecord)[];
|
|
1363
|
+
export type HistoryShowEntries = HistoryShowEntry[];
|
|
1360
1364
|
/**
|
|
1361
1365
|
* One normalized action a harness took, harness-agnostic so a single consumer
|
|
1362
1366
|
* assertion works across harnesses. Every field is always serialized (null when
|
|
@@ -1753,3 +1757,27 @@ export interface Usage8 {
|
|
|
1753
1757
|
output_tokens: number | null;
|
|
1754
1758
|
[k: string]: unknown;
|
|
1755
1759
|
}
|
|
1760
|
+
/**
|
|
1761
|
+
* A run that has published events but no closing record yet.
|
|
1762
|
+
*/
|
|
1763
|
+
export interface IncompleteHistoryRun {
|
|
1764
|
+
/**
|
|
1765
|
+
* The events published so far, in `index` order; never empty.
|
|
1766
|
+
*
|
|
1767
|
+
* @minItems 1
|
|
1768
|
+
*/
|
|
1769
|
+
events: ActionEvent[];
|
|
1770
|
+
/**
|
|
1771
|
+
* The harness the event lines name.
|
|
1772
|
+
*/
|
|
1773
|
+
harness: string;
|
|
1774
|
+
/**
|
|
1775
|
+
* The id the run's closing record will carry as its `history_id`.
|
|
1776
|
+
*/
|
|
1777
|
+
run_id: string;
|
|
1778
|
+
/**
|
|
1779
|
+
* Always `incomplete`: what tells this entry apart from a record.
|
|
1780
|
+
*/
|
|
1781
|
+
type: "incomplete";
|
|
1782
|
+
[k: string]: unknown;
|
|
1783
|
+
}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which dates of the index a listing reads.
|
|
3
|
+
*
|
|
4
|
+
* It is also the one value an SDK history lookup, listing or watch takes as
|
|
5
|
+
* its `window`, so "from this date" and "from the beginning" cannot both be
|
|
6
|
+
* stated. On the wire it is externally tagged in camelCase —
|
|
7
|
+
* `{"recent": {"days": 3}}`, `{"since": "2026-01-05"}`, or `"allTime"` — and
|
|
8
|
+
* renders to the CLI's `--days`, `--since` or `--all-time`.
|
|
9
|
+
*/
|
|
10
|
+
export type HistoryWindow = {
|
|
11
|
+
recent: {
|
|
12
|
+
/**
|
|
13
|
+
* How many UTC days, today included; at least one.
|
|
14
|
+
*/
|
|
15
|
+
days: number;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
since: string;
|
|
19
|
+
} | "allTime";
|
|
1
20
|
/**
|
|
2
21
|
* Options accepted by the language SDKs' continuous history iterators.
|
|
3
22
|
*
|
|
@@ -32,6 +51,13 @@ export interface HistoryWatchOptions {
|
|
|
32
51
|
* Narrow to one configured harness identity (`claude-code:work`).
|
|
33
52
|
*/
|
|
34
53
|
variant?: string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Where the watch starts when no `after` cursor is given: the beginning
|
|
56
|
+
* of the last `days` UTC days, of a UTC date, or of all time (the legacy
|
|
57
|
+
* index an older oneharness kept included). Omitted, the current UTC
|
|
58
|
+
* day. Refused beside `after`, the other answer to where a watch begins.
|
|
59
|
+
*/
|
|
60
|
+
window?: HistoryWindow | null | undefined;
|
|
35
61
|
}
|
|
36
62
|
export interface HistoryLabels {
|
|
37
63
|
[k: string]: string;
|