@oneharness/sdk 0.5.0 → 0.5.2

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.
@@ -2,38 +2,7 @@
2
2
  * One event-sourced history JSONL line.
3
3
  */
4
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
- });
5
+ event: ActionEvent;
37
6
  harness: string;
38
7
  run_id: string;
39
8
  schema_version: "1.0";
@@ -84,7 +53,7 @@ export type HistoryLine = {
84
53
  session: string;
85
54
  session_id: string | null;
86
55
  started_at: string;
87
- status: "timeout" | "spawn_error" | "skipped" | "planned";
56
+ status: "timeout" | "spawn-error" | "skipped" | "planned";
88
57
  text: string | null;
89
58
  text_source: string | null;
90
59
  time_to_first_token_ms?: number | null | undefined;
@@ -7,6 +7,10 @@ export type HistoryStreamEnvelope = {
7
7
  record: HistoryRecord;
8
8
  type: "record";
9
9
  [k: string]: unknown;
10
+ } | {
11
+ line: HistoryEventLine;
12
+ type: "event";
13
+ [k: string]: unknown;
10
14
  };
11
15
  /**
12
16
  * One harness run, normalized and frozen for the history log. Serialized as one
@@ -471,3 +475,13 @@ export interface Usage2 {
471
475
  output_tokens: number | null;
472
476
  [k: string]: unknown;
473
477
  }
478
+ /**
479
+ * One normalized action observed during a run.
480
+ */
481
+ export interface HistoryEventLine {
482
+ event: ActionEvent;
483
+ harness: string;
484
+ run_id: string;
485
+ schema_version: string;
486
+ [k: string]: unknown;
487
+ }
@@ -8,6 +8,7 @@
8
8
  export interface HistoryWatchOptions {
9
9
  after?: string | undefined;
10
10
  allProjects?: boolean | undefined;
11
+ events?: boolean | undefined;
11
12
  historyDir?: string | undefined;
12
13
  labels?: HistoryLabels | undefined;
13
14
  project?: string | undefined;
@@ -1794,6 +1794,9 @@
1794
1794
  "allProjects": {
1795
1795
  "type": "boolean"
1796
1796
  },
1797
+ "events": {
1798
+ "type": "boolean"
1799
+ },
1797
1800
  "historyDir": {
1798
1801
  "type": "string"
1799
1802
  },
@@ -1839,176 +1842,7 @@
1839
1842
  "type": "object",
1840
1843
  "properties": {
1841
1844
  "event": {
1842
- "oneOf": [
1843
- {
1844
- "allOf": [
1845
- {
1846
- "$ref": "#/$defs/ActionEvent"
1847
- },
1848
- {
1849
- "type": "object",
1850
- "properties": {
1851
- "duration_ms": {
1852
- "type": "integer",
1853
- "minimum": 0
1854
- },
1855
- "finished_at": {
1856
- "type": "string"
1857
- },
1858
- "kind": {
1859
- "type": "string",
1860
- "const": "tool_call"
1861
- },
1862
- "started_at": {
1863
- "type": "string"
1864
- },
1865
- "status": {
1866
- "type": "string",
1867
- "const": "completed"
1868
- },
1869
- "tool_call_id": {
1870
- "type": "string",
1871
- "minLength": 1
1872
- }
1873
- },
1874
- "required": [
1875
- "kind",
1876
- "tool_call_id",
1877
- "started_at",
1878
- "status",
1879
- "finished_at",
1880
- "duration_ms"
1881
- ]
1882
- }
1883
- ]
1884
- },
1885
- {
1886
- "allOf": [
1887
- {
1888
- "$ref": "#/$defs/ActionEvent"
1889
- },
1890
- {
1891
- "type": "object",
1892
- "properties": {
1893
- "duration_ms": {
1894
- "type": "integer",
1895
- "minimum": 0
1896
- },
1897
- "finished_at": {
1898
- "type": "string"
1899
- },
1900
- "kind": {
1901
- "type": "string",
1902
- "const": "tool_call"
1903
- },
1904
- "started_at": {
1905
- "type": "string"
1906
- },
1907
- "status": {
1908
- "type": "string",
1909
- "const": "failed"
1910
- },
1911
- "tool_call_id": {
1912
- "type": "string",
1913
- "minLength": 1
1914
- }
1915
- },
1916
- "required": [
1917
- "kind",
1918
- "tool_call_id",
1919
- "started_at",
1920
- "status",
1921
- "finished_at",
1922
- "duration_ms"
1923
- ]
1924
- }
1925
- ]
1926
- },
1927
- {
1928
- "allOf": [
1929
- {
1930
- "$ref": "#/$defs/ActionEvent"
1931
- },
1932
- {
1933
- "type": "object",
1934
- "properties": {
1935
- "kind": {
1936
- "type": "string",
1937
- "const": "tool_call"
1938
- },
1939
- "started_at": {
1940
- "type": "string"
1941
- },
1942
- "status": {
1943
- "type": "string",
1944
- "const": "timeout"
1945
- },
1946
- "tool_call_id": {
1947
- "type": "string",
1948
- "minLength": 1
1949
- }
1950
- },
1951
- "required": [
1952
- "kind",
1953
- "tool_call_id",
1954
- "started_at",
1955
- "status"
1956
- ]
1957
- }
1958
- ]
1959
- },
1960
- {
1961
- "allOf": [
1962
- {
1963
- "$ref": "#/$defs/ActionEvent"
1964
- },
1965
- {
1966
- "type": "object",
1967
- "properties": {
1968
- "kind": {
1969
- "type": "string",
1970
- "const": "tool_call"
1971
- },
1972
- "started_at": {
1973
- "type": "string"
1974
- },
1975
- "status": {
1976
- "type": "string",
1977
- "const": "interrupted"
1978
- },
1979
- "tool_call_id": {
1980
- "type": "string",
1981
- "minLength": 1
1982
- }
1983
- },
1984
- "required": [
1985
- "kind",
1986
- "tool_call_id",
1987
- "started_at",
1988
- "status"
1989
- ]
1990
- }
1991
- ]
1992
- },
1993
- {
1994
- "allOf": [
1995
- {
1996
- "$ref": "#/$defs/ActionEvent"
1997
- },
1998
- {
1999
- "type": "object",
2000
- "properties": {
2001
- "kind": {
2002
- "type": "string",
2003
- "not": {
2004
- "pattern": "^tool_call$"
2005
- }
2006
- }
2007
- }
2008
- }
2009
- ]
2010
- }
2011
- ]
1845
+ "$ref": "#/$defs/ActionEvent"
2012
1846
  },
2013
1847
  "harness": {
2014
1848
  "type": "string"
@@ -2281,7 +2115,7 @@
2281
2115
  "type": "string",
2282
2116
  "enum": [
2283
2117
  "timeout",
2284
- "spawn_error",
2118
+ "spawn-error",
2285
2119
  "skipped",
2286
2120
  "planned"
2287
2121
  ]
@@ -3795,6 +3629,23 @@
3795
3629
  "type",
3796
3630
  "record"
3797
3631
  ]
3632
+ },
3633
+ {
3634
+ "description": "A normalized action event observed before its run closes.",
3635
+ "type": "object",
3636
+ "properties": {
3637
+ "line": {
3638
+ "$ref": "#/$defs/HistoryEventLine"
3639
+ },
3640
+ "type": {
3641
+ "type": "string",
3642
+ "const": "event"
3643
+ }
3644
+ },
3645
+ "required": [
3646
+ "type",
3647
+ "line"
3648
+ ]
3798
3649
  }
3799
3650
  ],
3800
3651
  "$defs": {
@@ -3913,6 +3764,33 @@
3913
3764
  }
3914
3765
  ]
3915
3766
  },
3767
+ "HistoryEventLine": {
3768
+ "description": "One normalized action observed during a run.",
3769
+ "type": "object",
3770
+ "properties": {
3771
+ "event": {
3772
+ "$ref": "#/$defs/ActionEvent"
3773
+ },
3774
+ "harness": {
3775
+ "type": "string"
3776
+ },
3777
+ "run_id": {
3778
+ "type": "string",
3779
+ "maxLength": 36,
3780
+ "minLength": 36,
3781
+ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
3782
+ },
3783
+ "schema_version": {
3784
+ "type": "string"
3785
+ }
3786
+ },
3787
+ "required": [
3788
+ "schema_version",
3789
+ "run_id",
3790
+ "harness",
3791
+ "event"
3792
+ ]
3793
+ },
3916
3794
  "HistoryLabels": {
3917
3795
  "type": "object",
3918
3796
  "additionalProperties": {
@@ -7,7 +7,7 @@ import type { HistoryList, HistorySessionSummary } from "./history-list.js";
7
7
  import type { HistoryListOptions } from "./history-list-options.js";
8
8
  import type { HistoryLookup, HistoryLookupByLast, HistoryLookupBySession } from "./history-lookup.js";
9
9
  import type { HistoryRecords } from "./history-records.js";
10
- import type { HistoryStreamEnvelope } from "./history-stream-envelope.js";
10
+ import type { HistoryEventLine, HistoryStreamEnvelope } from "./history-stream-envelope.js";
11
11
  import type { HistoryWatchOptions } from "./history-watch-options.js";
12
12
  import type { HistoryLabels, PermissionMode, RunOptions } from "./options.js";
13
13
  import type { HarnessInfo, ListReport, ModeInfo } from "./registry.js";
@@ -24,6 +24,7 @@ export declare const FailureKindSchema: z.ZodType<FailureKind>;
24
24
  export declare const FallThroughSchema: z.ZodType<FallThrough>;
25
25
  export declare const FallbackReportSchema: z.ZodType<FallbackReport>;
26
26
  export declare const HarnessInfoSchema: z.ZodType<HarnessInfo>;
27
+ export declare const HistoryEventLineSchema: z.ZodType<HistoryEventLine>;
27
28
  export declare const HistoryLabelsSchema: z.ZodType<HistoryLabels>;
28
29
  export declare const HistoryLineSchema: z.ZodType<HistoryLine>;
29
30
  export declare const HistoryListSchema: z.ZodType<HistoryList>;
@@ -77,6 +77,17 @@ export const HarnessInfoSchema = z.looseObject({
77
77
  supports_system_file: z.boolean().refine((value) => value !== undefined, { message: "Required" }),
78
78
  sync_file: z.union([z.string(), z.null()]).refine((value) => value !== undefined, { message: "Required" }),
79
79
  });
80
+ export const HistoryEventLineSchema = z.looseObject({
81
+ event: z.lazy(() => ActionEventSchema).refine((value) => value !== undefined, { message: "Required" }),
82
+ harness: z.string().refine((value) => value !== undefined, { message: "Required" }),
83
+ run_id: z
84
+ .string()
85
+ .min(36)
86
+ .regex(new RegExp("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", "u"))
87
+ .refine((value) => [...value].length <= 36, { message: "Too long: expected at most 36 characters" })
88
+ .refine((value) => value !== undefined, { message: "Required" }),
89
+ schema_version: z.string().refine((value) => value !== undefined, { message: "Required" }),
90
+ });
80
91
  export const HistoryLabelsSchema = z.record(z
81
92
  .string()
82
93
  .regex(new RegExp("^[A-Za-z0-9]", "u"))
@@ -92,64 +103,7 @@ export const HistoryLabelsSchema = z.record(z
92
103
  }));
93
104
  export const HistoryLineSchema = z.union([
94
105
  z.looseObject({
95
- event: z
96
- .union([
97
- z.intersection(z.lazy(() => ActionEventSchema), z.looseObject({
98
- duration_ms: z
99
- .int()
100
- .gte(0)
101
- .refine((value) => value !== undefined, { message: "Required" }),
102
- finished_at: z.string().refine((value) => value !== undefined, { message: "Required" }),
103
- kind: z.literal("tool_call").refine((value) => value !== undefined, { message: "Required" }),
104
- started_at: z.string().refine((value) => value !== undefined, { message: "Required" }),
105
- status: z.literal("completed").refine((value) => value !== undefined, { message: "Required" }),
106
- tool_call_id: z
107
- .string()
108
- .min(1)
109
- .refine((value) => value !== undefined, { message: "Required" }),
110
- })),
111
- z.intersection(z.lazy(() => ActionEventSchema), z.looseObject({
112
- duration_ms: z
113
- .int()
114
- .gte(0)
115
- .refine((value) => value !== undefined, { message: "Required" }),
116
- finished_at: z.string().refine((value) => value !== undefined, { message: "Required" }),
117
- kind: z.literal("tool_call").refine((value) => value !== undefined, { message: "Required" }),
118
- started_at: z.string().refine((value) => value !== undefined, { message: "Required" }),
119
- status: z.literal("failed").refine((value) => value !== undefined, { message: "Required" }),
120
- tool_call_id: z
121
- .string()
122
- .min(1)
123
- .refine((value) => value !== undefined, { message: "Required" }),
124
- })),
125
- z.intersection(z.lazy(() => ActionEventSchema), z.looseObject({
126
- kind: z.literal("tool_call").refine((value) => value !== undefined, { message: "Required" }),
127
- started_at: z.string().refine((value) => value !== undefined, { message: "Required" }),
128
- status: z.literal("timeout").refine((value) => value !== undefined, { message: "Required" }),
129
- tool_call_id: z
130
- .string()
131
- .min(1)
132
- .refine((value) => value !== undefined, { message: "Required" }),
133
- })),
134
- z.intersection(z.lazy(() => ActionEventSchema), z.looseObject({
135
- kind: z.literal("tool_call").refine((value) => value !== undefined, { message: "Required" }),
136
- started_at: z.string().refine((value) => value !== undefined, { message: "Required" }),
137
- status: z.literal("interrupted").refine((value) => value !== undefined, { message: "Required" }),
138
- tool_call_id: z
139
- .string()
140
- .min(1)
141
- .refine((value) => value !== undefined, { message: "Required" }),
142
- })),
143
- z.intersection(z.lazy(() => ActionEventSchema), z.looseObject({
144
- kind: z
145
- .string()
146
- .refine((value) => !new RegExp("^tool_call$", "u").test(value), {
147
- message: "Invalid string: must not contain ^tool_call$",
148
- })
149
- .optional(),
150
- })),
151
- ])
152
- .refine((value) => value !== undefined, { message: "Required" }),
106
+ event: z.lazy(() => ActionEventSchema).refine((value) => value !== undefined, { message: "Required" }),
153
107
  harness: z.string().refine((value) => value !== undefined, { message: "Required" }),
154
108
  run_id: z
155
109
  .string()
@@ -248,7 +202,7 @@ export const HistoryLineSchema = z.union([
248
202
  .min(1)
249
203
  .refine((value) => value !== undefined, { message: "Required" }),
250
204
  status: z
251
- .union([z.literal("timeout"), z.literal("spawn_error"), z.literal("skipped"), z.literal("planned")])
205
+ .union([z.literal("timeout"), z.literal("spawn-error"), z.literal("skipped"), z.literal("planned")])
252
206
  .refine((value) => value !== undefined, { message: "Required" }),
253
207
  text: z.union([z.string(), z.null()]).refine((value) => value !== undefined, { message: "Required" }),
254
208
  text_source: z.union([z.string(), z.null()]).refine((value) => value !== undefined, { message: "Required" }),
@@ -546,10 +500,16 @@ export const HistorySessionSummarySchema = z.looseObject({
546
500
  .refine((value) => value !== undefined, { message: "Required" }),
547
501
  started: z.string().refine((value) => value !== undefined, { message: "Required" }),
548
502
  });
549
- export const HistoryStreamEnvelopeSchema = z.looseObject({
550
- record: z.lazy(() => HistoryRecordSchema).refine((value) => value !== undefined, { message: "Required" }),
551
- type: z.literal("record").refine((value) => value !== undefined, { message: "Required" }),
552
- });
503
+ export const HistoryStreamEnvelopeSchema = z.union([
504
+ z.looseObject({
505
+ record: z.lazy(() => HistoryRecordSchema).refine((value) => value !== undefined, { message: "Required" }),
506
+ type: z.literal("record").refine((value) => value !== undefined, { message: "Required" }),
507
+ }),
508
+ z.looseObject({
509
+ line: z.lazy(() => HistoryEventLineSchema).refine((value) => value !== undefined, { message: "Required" }),
510
+ type: z.literal("event").refine((value) => value !== undefined, { message: "Required" }),
511
+ }),
512
+ ]);
553
513
  export const HistoryWatchOptionsSchema = z.strictObject({
554
514
  after: z
555
515
  .string()
@@ -558,6 +518,7 @@ export const HistoryWatchOptionsSchema = z.strictObject({
558
518
  .refine((value) => [...value].length <= 36, { message: "Too long: expected at most 36 characters" })
559
519
  .optional(),
560
520
  allProjects: z.boolean().optional(),
521
+ events: z.boolean().optional(),
561
522
  historyDir: z.string().optional(),
562
523
  labels: z.lazy(() => HistoryLabelsSchema).optional(),
563
524
  project: z.string().optional(),
package/dist/index.js CHANGED
@@ -281,6 +281,8 @@ export class OneHarness {
281
281
  args.push("--all-projects");
282
282
  if (input.historyDir)
283
283
  args.push("--history-dir", input.historyDir);
284
+ if (input.events)
285
+ args.push("--events");
284
286
  return invokeStreamWith(this.options, args, HistoryStreamEnvelopeSchema, "invalid oneharness history watch contract", undefined, true);
285
287
  }
286
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneharness/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Typed Node.js SDK for oneharness",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "node": ">=20"
20
20
  },
21
21
  "dependencies": {
22
- "oneharness-cli": "0.5.0",
22
+ "oneharness-cli": "0.5.2",
23
23
  "zod": "^4.4.3"
24
24
  }
25
25
  }