@nucarium/sdk 0.0.0-stage → 0.1.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,1788 @@
1
+ export type paths = {
2
+ "/v1/inbox": {
3
+ parameters: {
4
+ query?: never;
5
+ header?: never;
6
+ path?: never;
7
+ cookie?: never;
8
+ };
9
+ /**
10
+ * Everything across the account, most urgent first
11
+ * @description One item per live session, plus one item per environment that is
12
+ * down, in a restart loop or stale.
13
+ *
14
+ * There is one order, and it is the order of the `Attention` enum:
15
+ *
16
+ * 1. `needs_input`: sessions waiting on their owner;
17
+ * 2. `login_expired`: sessions stopped because the agent is signed out;
18
+ * 3. `failed`: sessions that stopped with an error;
19
+ * 4. `stuck`: sessions that are working with nothing to show for it;
20
+ * 5. `down`: environments whose machine or agent server is down;
21
+ * 6. `restart_loop`: environments whose agent server keeps restarting;
22
+ * 7. `stale`: environments that have missed heartbeats;
23
+ * 8. `usage_limited`: sessions paused on a usage limit;
24
+ * 9. `working`;
25
+ * 10. `idle`.
26
+ *
27
+ * Inside `needs_input`, `stuck`, `down`, `restart_loop` and `stale` the
28
+ * oldest `since` comes first: whatever has been that way longest.
29
+ * Inside the others the newest `since` comes first. Two items with the
30
+ * same `since` are ordered by `id`, ascending.
31
+ *
32
+ * An environment has at most one item, with one attention: `down` when
33
+ * its machine or its agent server is down; otherwise `restart_loop`
34
+ * when `restart_loop_since` is set; otherwise `stale`. A session's item
35
+ * keeps its own attention whatever its environment's is.
36
+ *
37
+ * A snoozed or paused item is listed where it would be anyway. Snooze
38
+ * and the maintenance pause change which alerts are sent, not what the
39
+ * inbox shows; `snoozed_until` and `paused_until` on the item's
40
+ * environment say so.
41
+ *
42
+ * Ended sessions and hidden environments do not appear.
43
+ */
44
+ get: operations["getInbox"];
45
+ put?: never;
46
+ post?: never;
47
+ delete?: never;
48
+ options?: never;
49
+ head?: never;
50
+ patch?: never;
51
+ trace?: never;
52
+ };
53
+ "/v1/sessions": {
54
+ parameters: {
55
+ query?: never;
56
+ header?: never;
57
+ path?: never;
58
+ cookie?: never;
59
+ };
60
+ /**
61
+ * Sessions across the account
62
+ * @description Every session in the account's visible environments, with the
63
+ * machine and environment it runs in. Live sessions only, unless
64
+ * `include_ended` is `true` or `status` names `ended`; ended ones are
65
+ * kept for the tier's `history_days`.
66
+ *
67
+ * Newest `last_event_at` first. Two sessions with the same
68
+ * `last_event_at` are ordered by `id`, ascending. A page that ends
69
+ * before the list does carries a `next_cursor`.
70
+ *
71
+ * The inbox shows the same live sessions, ranked by what needs the
72
+ * owner. This list is for reading them all, ended ones too.
73
+ */
74
+ get: operations["listSessions"];
75
+ put?: never;
76
+ post?: never;
77
+ delete?: never;
78
+ options?: never;
79
+ head?: never;
80
+ patch?: never;
81
+ trace?: never;
82
+ };
83
+ "/v1/machines": {
84
+ parameters: {
85
+ query?: never;
86
+ header?: never;
87
+ path?: never;
88
+ cookie?: never;
89
+ };
90
+ /** List machines */
91
+ get: operations["listMachines"];
92
+ put?: never;
93
+ post?: never;
94
+ delete?: never;
95
+ options?: never;
96
+ head?: never;
97
+ patch?: never;
98
+ trace?: never;
99
+ };
100
+ "/v1/machines/{machine_id}": {
101
+ parameters: {
102
+ query?: never;
103
+ header?: never;
104
+ path?: never;
105
+ cookie?: never;
106
+ };
107
+ /** Read a machine */
108
+ get: operations["getMachine"];
109
+ put?: never;
110
+ post?: never;
111
+ delete?: never;
112
+ options?: never;
113
+ head?: never;
114
+ patch?: never;
115
+ trace?: never;
116
+ };
117
+ "/v1/machines/{machine_id}/history": {
118
+ parameters: {
119
+ query?: never;
120
+ header?: never;
121
+ path?: never;
122
+ cookie?: never;
123
+ };
124
+ /**
125
+ * The machine's health over time
126
+ * @description What the machine's heartbeats said over `range`, cut into steps for
127
+ * a chart: disk, load and memory pressure, each the average of the
128
+ * heartbeats in the step, and the alerts fired about the machine or
129
+ * its environments in it. A step with no heartbeat has `null`
130
+ * readings: the box was dark or not yet reporting.
131
+ *
132
+ * For an account whose plan includes charts (`Entitlements.charts`).
133
+ * Any other is refused with `plan_required`. A range longer than the
134
+ * plan's `history_days` is `validation_failed` on `range`.
135
+ */
136
+ get: operations["getMachineHistory"];
137
+ put?: never;
138
+ post?: never;
139
+ delete?: never;
140
+ options?: never;
141
+ head?: never;
142
+ patch?: never;
143
+ trace?: never;
144
+ };
145
+ "/v1/environments": {
146
+ parameters: {
147
+ query?: never;
148
+ header?: never;
149
+ path?: never;
150
+ cookie?: never;
151
+ };
152
+ /** List environments */
153
+ get: operations["listEnvironments"];
154
+ put?: never;
155
+ post?: never;
156
+ delete?: never;
157
+ options?: never;
158
+ head?: never;
159
+ patch?: never;
160
+ trace?: never;
161
+ };
162
+ "/v1/environments/{environment_id}": {
163
+ parameters: {
164
+ query?: never;
165
+ header?: never;
166
+ path?: never;
167
+ cookie?: never;
168
+ };
169
+ /** Read an environment and its sessions */
170
+ get: operations["getEnvironment"];
171
+ put?: never;
172
+ post?: never;
173
+ delete?: never;
174
+ options?: never;
175
+ head?: never;
176
+ patch?: never;
177
+ trace?: never;
178
+ };
179
+ "/v1/environments/{environment_id}/events": {
180
+ parameters: {
181
+ query?: never;
182
+ header?: never;
183
+ path?: never;
184
+ cookie?: never;
185
+ };
186
+ /**
187
+ * The environment's recent events
188
+ * @description The debug ring: the last 500 event envelopes Watch received for the
189
+ * environment, newest first, each with what Watch did with it.
190
+ */
191
+ get: operations["listEnvironmentEvents"];
192
+ put?: never;
193
+ post?: never;
194
+ delete?: never;
195
+ options?: never;
196
+ head?: never;
197
+ patch?: never;
198
+ trace?: never;
199
+ };
200
+ "/v1/environments/{environment_id}/history": {
201
+ parameters: {
202
+ query?: never;
203
+ header?: never;
204
+ path?: never;
205
+ cookie?: never;
206
+ };
207
+ /**
208
+ * The environment's sessions over time
209
+ * @description The environment's sessions over `range`, cut into steps for a
210
+ * chart: the most working and the most waiting on the owner at once
211
+ * in each step, and the alerts fired about the environment or its
212
+ * sessions in it. A step the box said nothing in has `null` counts.
213
+ *
214
+ * For an account whose plan includes charts (`Entitlements.charts`).
215
+ * Any other is refused with `plan_required`, and a hidden environment
216
+ * with `environment_hidden`. A range longer than the plan's
217
+ * `history_days` is `validation_failed` on `range`.
218
+ */
219
+ get: operations["getEnvironmentHistory"];
220
+ put?: never;
221
+ post?: never;
222
+ delete?: never;
223
+ options?: never;
224
+ head?: never;
225
+ patch?: never;
226
+ trace?: never;
227
+ };
228
+ "/v1/alerts": {
229
+ parameters: {
230
+ query?: never;
231
+ header?: never;
232
+ path?: never;
233
+ cookie?: never;
234
+ };
235
+ /**
236
+ * Alerts that have fired
237
+ * @description Every alert Watch decided on, sent or not. Open alerts first, then
238
+ * newest first: the order is `open` descending, `fired_at` descending,
239
+ * `id` descending.
240
+ *
241
+ * An alert fires once when something changes and never repeats while
242
+ * it stays that way. Most are followed by one notice when the thing
243
+ * moves on, and that notice resolves the alert it answers; `AlertKind`
244
+ * lists the pairs.
245
+ *
246
+ * Firing is not sending. Every alert that fires is written here, and
247
+ * `held` says why one was not sent: its machine or environment was
248
+ * snoozed, the account was in quiet hours, or it is the notice for an
249
+ * alert that was itself held. A held alert is never sent later.
250
+ *
251
+ * An alert is `open` when it was sent, is not a notice, and has been
252
+ * neither acknowledged nor resolved. An open urgent alert goes to the
253
+ * second contact, once, when `second_contact_after_s` passes with
254
+ * nobody acknowledging it.
255
+ *
256
+ * Alerts are kept for the tier's `history_days`, held ones included.
257
+ * Alerts from before `open` existed read `open: false`.
258
+ */
259
+ get: operations["listAlerts"];
260
+ put?: never;
261
+ post?: never;
262
+ delete?: never;
263
+ options?: never;
264
+ head?: never;
265
+ patch?: never;
266
+ trace?: never;
267
+ };
268
+ };
269
+ export type webhooks = Record<string, never>;
270
+ export type components = {
271
+ schemas: {
272
+ /**
273
+ * @description An alert Watch decided on. It is here whether or not it was sent:
274
+ * `held` says why one was not, and `deliveries` what happened to one
275
+ * that was.
276
+ */
277
+ Alert: {
278
+ /** @example alr_5b6n2f9k4m7q1x8z */
279
+ id: string;
280
+ kind: components["schemas"]["AlertKind"];
281
+ /** Format: date-time */
282
+ fired_at: string;
283
+ title: string;
284
+ body: string;
285
+ /**
286
+ * @description Whether the alert is sent with `Priority: high`. Urgent alerts
287
+ * get through quiet hours unless the account holds everything,
288
+ * and are the only ones a second contact hears about. Alerts from
289
+ * before this field existed read `false`.
290
+ */
291
+ urgent: boolean;
292
+ /**
293
+ * @description True while the alert still wants someone: it was sent, it is
294
+ * not a notice, and it has been neither acknowledged nor
295
+ * resolved. Open alerts sort first. False for a held alert, for
296
+ * a notice, and for alerts from before this field existed.
297
+ */
298
+ open: boolean;
299
+ /**
300
+ * @description Where the alert takes the reader: the session's `url` for a
301
+ * session alert when it has one, otherwise the environment's
302
+ * `vendor_url`. `null` for a machine alert, and when neither is
303
+ * set. Sent to a webhook as the `Click` header.
304
+ */
305
+ url: string | null;
306
+ /**
307
+ * @description Why the alert was not sent, or `null` if it was. `snoozed`: its
308
+ * machine or environment was snoozed. `quiet_hours`: it fired in
309
+ * the account's quiet hours. `follows_held`: it is the notice
310
+ * for an alert that was itself held. A held alert has no
311
+ * `deliveries` and is never sent later.
312
+ * @enum {string|null}
313
+ */
314
+ held: "snoozed" | "quiet_hours" | "follows_held" | null;
315
+ /**
316
+ * Format: date-time
317
+ * @description When someone acknowledged the alert.
318
+ */
319
+ acknowledged_at: string | null;
320
+ /**
321
+ * @description The GitHub login of whoever acknowledged it, as it was then.
322
+ * Kept as text: it does not change if they rename themselves or
323
+ * leave.
324
+ */
325
+ acknowledged_by: string | null;
326
+ /**
327
+ * Format: date-time
328
+ * @description When the thing the alert was about moved on: the time the
329
+ * notice that answers it fired, or a newer alert about the same
330
+ * session, or, for `machine_disk_filling`, when the disk
331
+ * cleared.
332
+ */
333
+ resolved_at: string | null;
334
+ /**
335
+ * Format: date-time
336
+ * @description When the alert was sent on to the second contact, unanswered.
337
+ * The attempt is the entry in `deliveries` with
338
+ * `second_contact: true`. `null` when it never was.
339
+ */
340
+ second_contact_at: string | null;
341
+ /** @description As it was named when the alert fired. Kept after the machine is deleted. */
342
+ machine: components["schemas"]["MachineRef"];
343
+ /** @description Set for environment and session alerts. */
344
+ environment: {
345
+ id: string;
346
+ key: string;
347
+ name: string;
348
+ } | null;
349
+ /** @description Set for session alerts. */
350
+ session_id: string | null;
351
+ /**
352
+ * @description One entry per enabled destination that took first alerts at the
353
+ * time. Empty if there were none, and for a held alert. An alert
354
+ * sent on to the second contact gains one more, marked
355
+ * `second_contact: true`.
356
+ */
357
+ deliveries: components["schemas"]["AlertDelivery"][];
358
+ };
359
+ AlertDelivery: {
360
+ destination_id: string;
361
+ destination_name: string;
362
+ ok: boolean;
363
+ /**
364
+ * @description The HTTP status the destination answered with, if it answered.
365
+ * Always `null` for `email`.
366
+ */
367
+ status: number | null;
368
+ /**
369
+ * @description `rejected` is a non-2xx answer, or for `email` an address the
370
+ * mail service refused. `timeout` is no answer in ten seconds,
371
+ * `unreachable` no connection, or for `email` no mail service.
372
+ * @enum {string|null}
373
+ */
374
+ error: "timeout" | "unreachable" | "rejected" | null;
375
+ /** Format: date-time */
376
+ attempted_at: string;
377
+ duration_ms: number;
378
+ /**
379
+ * @description True on the attempt that sent an unacknowledged urgent alert to
380
+ * the second contact. Left out of every other attempt.
381
+ */
382
+ second_contact?: boolean;
383
+ };
384
+ /**
385
+ * @description What an alert is about. Each fires once when the thing happens and
386
+ * does not repeat while it stays that way. Most are answered by one
387
+ * notice when it moves on. Urgent alerts are sent with
388
+ * `Priority: high` and are the ones a second contact can hear about.
389
+ *
390
+ * | Kind | Fires when | Urgent | Notice that answers it |
391
+ * |---|---|---|---|
392
+ * | `machine_down` | A box has gone dark. | Yes | `machine_recovered` |
393
+ * | `environment_down` | An agent server has stopped while its machine stays up. An expired login is a common cause. | Yes | `environment_recovered` |
394
+ * | `environment_restart_loop` | An agent server has restarted three times in ten minutes. | Yes | `environment_settled` |
395
+ * | `session_waiting` | A session has waited on its owner longer than `nag_after_s`. | Yes | `session_resumed` |
396
+ * | `session_login_expired` | A session stopped because the agent is signed out. | Yes | `session_resumed` |
397
+ * | `session_failed` | A session stopped with an error. | Yes | `session_resumed` |
398
+ * | `session_stuck` | A session became `stuck`; the alert says by which rule. | Yes | `session_resumed` |
399
+ * | `session_limited` | A session hit a usage limit. | No | `session_resumed` |
400
+ * | `machine_on_battery` | A box lost mains power and is running from its UPS. | Yes | `machine_on_mains` |
401
+ * | `machine_disk_filling` | The fullest filesystem is at least 95 percent full, or forecast to be full within a day. | Yes | None |
402
+ * | `login_expiring` | An environment's agent login expires within a day. | No | None |
403
+ * | `session_ended_unsaved` | A session ended holding work that exists only on the box. | No | None |
404
+ * | `environment_setup_failed` | An environment's setup script finished with `failed`. | No | `environment_setup_ok`, or none when the script is removed |
405
+ * | `plan_usage_high` | An environment's agent login has used `plan_usage_warn_pct` of a plan limit. | No | None |
406
+ * | `plan_usage_reached` | An environment's agent login has used all of a plan limit. | No | None |
407
+ *
408
+ * The notices (`machine_recovered`, `environment_recovered`,
409
+ * `environment_settled`, `environment_setup_ok`, `session_resumed`,
410
+ * `machine_on_mains`) are never urgent, are never `open`, and resolve
411
+ * the alert they answer.
412
+ *
413
+ * `session_resumed` follows a session that was waiting, failed,
414
+ * limited, login-expired or stuck, when it moves on to `idle`,
415
+ * `working`, `needs_input` or `ended`. When it moves instead into
416
+ * `failed`, `usage_limited` or `login_expired`, no notice is sent: the
417
+ * new alert answers the old one.
418
+ *
419
+ * `environment_setup_failed` fires when Watch first sees a run end
420
+ * `failed`, and not again for later failed runs while it stays
421
+ * failed. `environment_setup_ok` fires when a later run ends `ok`. A
422
+ * run first seen ending `ok` sends nothing, and `running` changes
423
+ * nothing. When the box reports a `setup` with no `script` while it
424
+ * is failed, the script has been removed: the alert is resolved and
425
+ * no notice is sent. A heartbeat without `setup` changes neither. Both name the environment and the machine, and the
426
+ * alert gives the exit code when the box sent one: no output and
427
+ * nothing from the script.
428
+ *
429
+ * `plan_usage_high` and `plan_usage_reached` fire at most once each
430
+ * for each limit in each of its windows: when the window starts
431
+ * again, by its reset time passing or a reading with a later one,
432
+ * they can fire again. A reading that is already at 100 fires
433
+ * `plan_usage_reached` alone. Neither is urgent: the only answer is
434
+ * to wait or to change the plan, and a session that hits the limit
435
+ * has its own `session_limited`. Both name the environment, the
436
+ * machine, the limit and when it resets.
437
+ *
438
+ * Session and environment alerts fire only for environments the
439
+ * account can see. A hidden environment is never alerted on.
440
+ * @enum {string}
441
+ */
442
+ AlertKind: "machine_down" | "machine_recovered" | "environment_down" | "environment_recovered" | "session_waiting" | "session_resumed" | "session_failed" | "session_limited" | "session_login_expired" | "session_stuck" | "login_expiring" | "session_ended_unsaved" | "environment_restart_loop" | "environment_settled" | "machine_on_battery" | "machine_on_mains" | "machine_disk_filling" | "environment_setup_failed" | "environment_setup_ok" | "plan_usage_high" | "plan_usage_reached";
443
+ AlertList: {
444
+ items: components["schemas"]["Alert"][];
445
+ next_cursor: string | null;
446
+ };
447
+ /**
448
+ * @description Why an item is in the inbox, most urgent first. The order of this
449
+ * enum is the order of the inbox, and the one order every client
450
+ * sorts by.
451
+ *
452
+ * A session's attention is its status. An environment's is `down`,
453
+ * `restart_loop` or `stale`. `usage_limited` sits below the
454
+ * environment problems because nothing can be done about it but
455
+ * wait.
456
+ * @enum {string}
457
+ */
458
+ Attention: "needs_input" | "login_expired" | "failed" | "stuck" | "down" | "restart_loop" | "stale" | "usage_limited" | "working" | "idle";
459
+ Deadlines: {
460
+ /** @description How often a machine reports. */
461
+ heartbeat_interval_s: number;
462
+ /** @description Missed heartbeats before a machine or agent server is `stale`. */
463
+ stale_after_missed: number;
464
+ /** @description Seconds of silence before a machine or agent server is `down`. */
465
+ down_after_s: number;
466
+ /** @description Seconds a session waits on its owner before the alert. */
467
+ nag_after_s: number;
468
+ /**
469
+ * @description Seconds a working session goes with no tool activity before it
470
+ * is `stuck`. 1800 unless the account changes it.
471
+ *
472
+ * It needs a daemon that sends `activity_beat_s`. From a box whose
473
+ * daemon does not, this rule never fires. The daemon forwards
474
+ * tool activity at most once a beat, so a tool may have run
475
+ * unsent for up to a beat after the last event Watch heard of.
476
+ * Watch waits that beat out first: the session is called stuck
477
+ * this long, plus one beat, after its last event, when no tool
478
+ * can have run for all of this time. It never fires sooner than
479
+ * twice the beat, whatever is set here.
480
+ */
481
+ stuck_quiet_after_s: number;
482
+ /**
483
+ * @description Seconds a session works without a stop before it is `stuck`,
484
+ * however busy it looks. 21600 unless the account changes it.
485
+ *
486
+ * A box that returns from being dark sends its heartbeat first
487
+ * and the events it kept afterwards, and the stop may be among
488
+ * them. So this rule does not pass until the box and its agent
489
+ * server have been back for as long as it takes to call a
490
+ * machine stale: a few heartbeats.
491
+ */
492
+ stuck_long_after_s: number;
493
+ /**
494
+ * @description How much of a plan limit an environment's agent login uses
495
+ * before `plan_usage_high` fires, in percent. 90 unless the
496
+ * account changes it. Not a deadline, but set with them.
497
+ */
498
+ plan_usage_warn_pct: number;
499
+ };
500
+ /**
501
+ * @description The environment's name on the box, unique within its machine. Lower
502
+ * case letters, digits, `.`, `_` and `-`.
503
+ * @example client-a
504
+ */
505
+ EnvKey: string;
506
+ /**
507
+ * @description One agent login running one agent server on a machine. The machine's
508
+ * last-seen and the agent server's last-seen are separate facts and are
509
+ * never merged.
510
+ *
511
+ * When `hidden` is true the environment is beyond the account's limit:
512
+ * it is listed by name only. Everything Watch learned from the box is
513
+ * `null`: `status`, `machine_status`, `server_status`, the last-seen
514
+ * times, `session_counts`, `oldest_needs_since`, `login_expires_at`,
515
+ * `agent_version`, `unsaved`, `last_snapshot_at`, `restart_loop_since`,
516
+ * `paused_until`, `setup` and `plan_usage`. What its owner set is still there: `name`,
517
+ * `vendor_url`, `session_url_template` and `snoozed_until`.
518
+ */
519
+ Environment: {
520
+ /** @example env_9k4m7q1x8z5b6n2f */
521
+ id: string;
522
+ key: components["schemas"]["EnvKey"];
523
+ /** @description The label the console shows. Starts out equal to `key`. */
524
+ name: string;
525
+ machine: components["schemas"]["MachineRef"];
526
+ /**
527
+ * Format: uri
528
+ * @description The agent vendor's own app for this login, where the owner goes to act.
529
+ */
530
+ vendor_url: string | null;
531
+ /**
532
+ * @description The address of one session in the vendor's app, with `{session}`
533
+ * where the session's id goes, as the owner typed it. `null` when
534
+ * none is set. Each session's `url` is made from it.
535
+ */
536
+ session_url_template: components["schemas"]["SessionUrlTemplate"] | null;
537
+ hidden: boolean;
538
+ /**
539
+ * Format: date-time
540
+ * @description When a heartbeat first named the environment.
541
+ */
542
+ created_at: string;
543
+ status: components["schemas"]["EnvironmentStatus"] | null;
544
+ machine_status: components["schemas"]["LivenessStatus"] | null;
545
+ server_status: components["schemas"]["LivenessStatus"] | null;
546
+ /**
547
+ * Format: date-time
548
+ * @description When Watch last received a heartbeat from the machine that named this environment.
549
+ */
550
+ machine_last_seen_at: string | null;
551
+ /**
552
+ * Format: date-time
553
+ * @description When a heartbeat last reported the agent server alive. `null` if it never has.
554
+ */
555
+ server_last_seen_at: string | null;
556
+ session_counts: components["schemas"]["SessionCounts"] | null;
557
+ /**
558
+ * Format: date-time
559
+ * @description Since when the longest-waiting session has been waiting.
560
+ */
561
+ oldest_needs_since: string | null;
562
+ /**
563
+ * Format: date-time
564
+ * @description When the agent's login for this environment expires, where the
565
+ * box can read it. On Watch's clock. Watch warns once, a day
566
+ * ahead. `null` when the box does not say.
567
+ */
568
+ login_expires_at: string | null;
569
+ /** @description The version of the agent the environment runs, when the box says. */
570
+ agent_version: string | null;
571
+ /**
572
+ * @description How much of the environment's work exists only on the box, as
573
+ * last counted. `null` when the box has not said.
574
+ */
575
+ unsaved: components["schemas"]["Unsaved"] | null;
576
+ /**
577
+ * Format: date-time
578
+ * @description When the snapshot job last finished for the environment's
579
+ * workspace with nothing failed. On Watch's clock.
580
+ */
581
+ last_snapshot_at: string | null;
582
+ /**
583
+ * Format: date-time
584
+ * @description Since when the agent server has been in a restart loop: three
585
+ * restarts inside ten minutes. `null` otherwise. It clears after
586
+ * ten minutes with no restart, counted only while the machine
587
+ * reports, so a box that goes dark mid-loop does not settle.
588
+ */
589
+ restart_loop_since: string | null;
590
+ /**
591
+ * Format: date-time
592
+ * @description Until when the box has announced a maintenance pause: the alerts
593
+ * for this environment going dark are put off. `null` when not
594
+ * paused, and once the time has passed.
595
+ */
596
+ paused_until: string | null;
597
+ /**
598
+ * Format: date-time
599
+ * @description Until when alerts about the environment are snoozed: the later
600
+ * of its own snooze and its machine's. `null` when neither is
601
+ * set, and once the time has passed.
602
+ */
603
+ snoozed_until: string | null;
604
+ /**
605
+ * @description How the environment is set up on the box, as the box last
606
+ * reported it. `null` when the box has never said, and once a
607
+ * heartbeat arrives without it. Set on the box: Watch cannot
608
+ * change it.
609
+ */
610
+ setup: components["schemas"]["EnvironmentSetup"] | null;
611
+ /**
612
+ * @description How much of its plan the environment's agent login has used, as
613
+ * the box last read it. `null` when the box has never said, and
614
+ * once a heartbeat arrives without it.
615
+ */
616
+ plan_usage: components["schemas"]["PlanUsage"] | null;
617
+ };
618
+ /** @description An environment's sessions over a range, one item per step. */
619
+ EnvironmentHistory: {
620
+ range: components["schemas"]["HistoryRange"];
621
+ /**
622
+ * Format: date-time
623
+ * @description The start of the first step.
624
+ */
625
+ from: string;
626
+ /**
627
+ * Format: date-time
628
+ * @description The end of the last step, which can be later than now.
629
+ */
630
+ until: string;
631
+ /** @description How long one step is. */
632
+ step_s: number;
633
+ /** @description The ranges the plan keeps enough history for, shortest first. */
634
+ ranges: components["schemas"]["HistoryRange"][];
635
+ items: components["schemas"]["EnvironmentHistoryStep"][];
636
+ };
637
+ EnvironmentHistoryStep: {
638
+ /**
639
+ * Format: date-time
640
+ * @description The start of the step.
641
+ */
642
+ at: string;
643
+ /** @description The most sessions working at once. `null` when the box said nothing in the step. */
644
+ working: number | null;
645
+ /** @description The most sessions waiting on the owner (`needs_input`) at once. */
646
+ waiting: number | null;
647
+ alerts_fired: number;
648
+ };
649
+ EnvironmentList: {
650
+ items: components["schemas"]["Environment"][];
651
+ };
652
+ /**
653
+ * @description The environment an inbox item belongs to, with the facts a row
654
+ * shows. The fields mean what they mean on `Environment`.
655
+ */
656
+ EnvironmentRef: {
657
+ id: string;
658
+ key: string;
659
+ name: string;
660
+ /** Format: uri */
661
+ vendor_url: string | null;
662
+ session_url_template: components["schemas"]["SessionUrlTemplate"] | null;
663
+ status: components["schemas"]["EnvironmentStatus"];
664
+ machine_status: components["schemas"]["LivenessStatus"];
665
+ server_status: components["schemas"]["LivenessStatus"];
666
+ /** Format: date-time */
667
+ machine_last_seen_at: string | null;
668
+ /** Format: date-time */
669
+ server_last_seen_at: string | null;
670
+ /** Format: date-time */
671
+ login_expires_at: string | null;
672
+ agent_version: string | null;
673
+ unsaved: components["schemas"]["Unsaved"] | null;
674
+ /** Format: date-time */
675
+ last_snapshot_at: string | null;
676
+ /** Format: date-time */
677
+ restart_loop_since: string | null;
678
+ /** Format: date-time */
679
+ paused_until: string | null;
680
+ /**
681
+ * Format: date-time
682
+ * @description The later of the environment's own snooze and its machine's.
683
+ */
684
+ snoozed_until: string | null;
685
+ };
686
+ /**
687
+ * @description How an environment is set up on the box, as the box recipe set it.
688
+ * Counts, names that already travel and times, never a value, a host
689
+ * or a line of the script. Set on the box: Watch shows it and cannot
690
+ * change it.
691
+ */
692
+ EnvironmentSetup: {
693
+ network: components["schemas"]["SetupNetwork"];
694
+ /** @description With `limited`, how many hosts the box adds to the default list. 0 otherwise. */
695
+ allowed_hosts: number;
696
+ /** @description The repositories the environment's sessions work in. */
697
+ repos: string[];
698
+ /** @description How many environment variables the environment sets. */
699
+ variables: number;
700
+ /** @description How many network secrets the environment has. */
701
+ secrets: number;
702
+ /**
703
+ * @description The setup script's last run. `null` when the environment has no
704
+ * setup script, or it has not run yet.
705
+ */
706
+ script: components["schemas"]["EnvironmentSetupScript"] | null;
707
+ /**
708
+ * Format: date-time
709
+ * @description When Watch last received it.
710
+ */
711
+ reported_at: string;
712
+ };
713
+ /**
714
+ * @description One run of an environment's setup script, on Watch's clock. Watch
715
+ * alerts once when a run ends `failed`, and once more when a later
716
+ * run ends `ok`.
717
+ */
718
+ EnvironmentSetupScript: {
719
+ state: components["schemas"]["SetupScriptState"];
720
+ /**
721
+ * Format: date-time
722
+ * @description When the run started.
723
+ */
724
+ started_at: string;
725
+ /**
726
+ * Format: date-time
727
+ * @description When the run ended. `null` while it is `running`.
728
+ */
729
+ finished_at: string | null;
730
+ /**
731
+ * @description How a `failed` run ended: 124 when it ran out of time, 128 and
732
+ * the signal's number when a signal stopped it. `null` for any
733
+ * other run, and for a failed one the box had no code for.
734
+ */
735
+ exit_code: number | null;
736
+ };
737
+ EnvironmentSnapshot: {
738
+ environment: components["schemas"]["Environment"];
739
+ deadlines: components["schemas"]["Deadlines"];
740
+ /**
741
+ * @description Live sessions first, by status: `needs_input`, `login_expired`,
742
+ * `failed`, `stuck`, `usage_limited`, `working`, `idle`. Then
743
+ * `ended` sessions, for as long as the tier keeps history. Inside
744
+ * a status the order is the inbox's: longest first for
745
+ * `needs_input` and `stuck`, newest first for the rest.
746
+ */
747
+ sessions: components["schemas"]["Session"][];
748
+ /** @description The environment's last 20 status changes, newest first. */
749
+ status_changes: components["schemas"]["StatusChange"][];
750
+ };
751
+ /**
752
+ * @description The worse of `machine_status` and `server_status`: `down` when the
753
+ * machine is dark or its agent server is gone.
754
+ * @enum {string}
755
+ */
756
+ EnvironmentStatus: "online" | "stale" | "down";
757
+ EventList: {
758
+ items: components["schemas"]["RecordedEvent"][];
759
+ next_cursor: string | null;
760
+ };
761
+ /**
762
+ * @description What happened to the session, and the status it moves to:
763
+ *
764
+ * | `type` | Session becomes |
765
+ * |---|---|
766
+ * | `session_start` | `idle` (a new session, even if one with this id ended before) |
767
+ * | `user_prompt_submit` | `working` |
768
+ * | `activity` | `working` (the agent moved on by itself, e.g. after a permission was granted; from a session already working, the sign that its tools still run) |
769
+ * | `permission_prompt` | `needs_input` |
770
+ * | `input_prompt` | `needs_input` |
771
+ * | `elicitation_prompt` | `needs_input` |
772
+ * | `stop` | `idle` |
773
+ * | `stop_failure` | `failed`, `usage_limited` or `login_expired`, by `error_kind` (which it keeps) |
774
+ * | `session_end` | `ended` |
775
+ * | `outcome` | unchanged |
776
+ *
777
+ * Nothing but `session_start` brings an ended session back.
778
+ *
779
+ * For every type but `outcome` the table is the whole rule: whatever
780
+ * status the session had, `failed`, `usage_limited`, `login_expired`
781
+ * and `stuck` included, it moves to the one the table gives. There is
782
+ * one exception. `activity` does not move a session that is stuck for
783
+ * working too long without a stop (`stuck_rule: long`): tool activity
784
+ * is what such a session has plenty of. A session called stuck for its
785
+ * silence (`stuck_rule: quiet`) that has since also worked for
786
+ * `stuck_long_after_s` counts as the first kind from then on: an
787
+ * `activity` leaves it stuck, and its `stuck_rule` reads `long`
788
+ * afterwards. No event makes a session `stuck`; only the clock does.
789
+ *
790
+ * Any other event that sets a session stuck for working too long to
791
+ * `working`, a new prompt for one, starts `working_since` again from
792
+ * that event. One that ends a quiet stuck keeps it.
793
+ *
794
+ * `outcome` reports what a session left behind and changes no status,
795
+ * `last_event_at` or ordering. It never creates a session. It applies
796
+ * to the session's current instance in any status, `ended` included,
797
+ * when its `client_ts` is not older than the newest event already
798
+ * applied; otherwise, or when there is no such session, it is kept in
799
+ * the debug ring as `late`. Fields it carries replace what an earlier
800
+ * one said, and fields it leaves out stand.
801
+ * @enum {string}
802
+ */
803
+ EventType: "session_start" | "user_prompt_submit" | "activity" | "permission_prompt" | "input_prompt" | "elicitation_prompt" | "stop" | "stop_failure" | "session_end" | "outcome";
804
+ /** @enum {string} */
805
+ HistoryRange: "24h" | "7d" | "30d" | "90d";
806
+ Inbox: {
807
+ /** Format: date-time */
808
+ generated_at: string;
809
+ /** @description Items per attention level across the account, before the request's filters. */
810
+ counts: {
811
+ needs_input: number;
812
+ login_expired: number;
813
+ failed: number;
814
+ stuck: number;
815
+ down: number;
816
+ restart_loop: number;
817
+ stale: number;
818
+ usage_limited: number;
819
+ working: number;
820
+ idle: number;
821
+ };
822
+ items: components["schemas"]["InboxItem"][];
823
+ };
824
+ InboxItem: {
825
+ /** @description Stable while the item exists. Use it as a list key. */
826
+ id: string;
827
+ /** @enum {string} */
828
+ kind: "session" | "environment";
829
+ attention: components["schemas"]["Attention"];
830
+ /**
831
+ * Format: date-time
832
+ * @description Since when the item has been this way: `needs_since` for a
833
+ * waiting session, `stuck_since` for a stuck one, the last event
834
+ * for any other session; `restart_loop_since` for an environment
835
+ * in a restart loop, and the status change for one that is down
836
+ * or stale.
837
+ */
838
+ since: string;
839
+ machine: components["schemas"]["MachineRef"];
840
+ environment: components["schemas"]["EnvironmentRef"];
841
+ /** @description The session, when `kind` is `session`. */
842
+ session: components["schemas"]["Session"] | null;
843
+ };
844
+ /**
845
+ * @description `online` while reports arrive on time, `stale` after
846
+ * `stale_after_missed` are missed, `down` after `down_after_s` of
847
+ * silence. Only a new report brings it back to `online`.
848
+ * @enum {string}
849
+ */
850
+ LivenessStatus: "online" | "stale" | "down";
851
+ Machine: {
852
+ /** @example mac_7h2k9m4q1x8z5b6n */
853
+ id: string;
854
+ name: string;
855
+ status: components["schemas"]["MachineStatus"];
856
+ /** Format: date-time */
857
+ created_at: string;
858
+ /**
859
+ * Format: date-time
860
+ * @description When Watch last received a heartbeat from the machine.
861
+ */
862
+ last_seen_at: string | null;
863
+ health: components["schemas"]["MachineHealth"] | null;
864
+ /**
865
+ * @description The version of `nucleated` the machine's latest heartbeat
866
+ * reported. `null` until it has said.
867
+ */
868
+ daemon_version: string | null;
869
+ /**
870
+ * @description The release of `nucleated` to update this machine to: the one a
871
+ * box gets by updating its recipe (running the installer again,
872
+ * then the playbook), when `daemon_version` is older than it.
873
+ * `null` when the machine runs that release or a newer one, has
874
+ * not reported a version, or reports one that is not a release
875
+ * like 1.2.3, such as a build of its own.
876
+ *
877
+ * Watch learns of a release when it is deployed from a release
878
+ * that pins it, as the installer does. Shown only: Watch sends no
879
+ * alert about it, and nothing reaches the box.
880
+ * @example 0.4.3
881
+ */
882
+ daemon_update_to: string | null;
883
+ environment_count: number;
884
+ /** @description Tokens that are neither revoked nor expired. */
885
+ live_token_count: number;
886
+ /**
887
+ * Format: date-time
888
+ * @description Until when the box has announced a maintenance pause: Watch puts
889
+ * off the alerts for the machine and its environments going dark.
890
+ * `null` when not paused, and once the time has passed.
891
+ */
892
+ paused_until: string | null;
893
+ /**
894
+ * Format: date-time
895
+ * @description Until when the machine is snoozed: Watch sends no alert about it,
896
+ * its environments or their sessions. `null` when not snoozed, and
897
+ * once the time has passed.
898
+ */
899
+ snoozed_until: string | null;
900
+ /**
901
+ * Format: date-time
902
+ * @description Since when the disk has been filling: the fullest filesystem is
903
+ * at least 95 percent full, or is forecast to be full within a
904
+ * day. One alert fires when this is set. `null` otherwise; it
905
+ * clears when the disk is under 90 percent and not forecast to
906
+ * fill within two days.
907
+ */
908
+ disk_filling_since: string | null;
909
+ /**
910
+ * @description Watch's forecast of the seconds until the fullest filesystem is
911
+ * full, from how `disk_used_pct` has risen over the last hours.
912
+ * `null` when there is no forecast: under an hour of samples, or
913
+ * a disk that is not rising.
914
+ */
915
+ disk_full_in_s: number | null;
916
+ };
917
+ /**
918
+ * @description What the machine's latest heartbeat said about it. A field the
919
+ * heartbeat left out is `null`: Watch does not carry the last value
920
+ * forward.
921
+ */
922
+ MachineHealth: {
923
+ disk_used_pct: number;
924
+ load_1m: number;
925
+ uptime_s: number;
926
+ memory_pressure_pct: number | null;
927
+ /** @description Whether the box is running from its UPS battery. `null` with no UPS. */
928
+ on_battery: boolean | null;
929
+ /** @description Whether the operating system says it needs a reboot. */
930
+ reboot_required: boolean | null;
931
+ /** @description Repos with uncommitted changes across the box, each workspace counted once. */
932
+ uncommitted_repos: number | null;
933
+ /** @description Commits that are on no remote, across the box. */
934
+ unpushed_commits: number | null;
935
+ /**
936
+ * Format: date-time
937
+ * @description Every workspace on the box has had a good snapshot since this
938
+ * time. On Watch's clock.
939
+ */
940
+ last_snapshot_at: string | null;
941
+ };
942
+ /** @description A machine's health over a range, one item per step. */
943
+ MachineHistory: {
944
+ range: components["schemas"]["HistoryRange"];
945
+ /**
946
+ * Format: date-time
947
+ * @description The start of the first step.
948
+ */
949
+ from: string;
950
+ /**
951
+ * Format: date-time
952
+ * @description The end of the last step, which can be later than now.
953
+ */
954
+ until: string;
955
+ /** @description How long one step is. */
956
+ step_s: number;
957
+ /** @description The ranges the plan keeps enough history for, shortest first. */
958
+ ranges: components["schemas"]["HistoryRange"][];
959
+ items: components["schemas"]["MachineHistoryStep"][];
960
+ };
961
+ MachineHistoryStep: {
962
+ /**
963
+ * Format: date-time
964
+ * @description The start of the step.
965
+ */
966
+ at: string;
967
+ /** @description How full the fullest filesystem was. `null` with no heartbeat in the step. */
968
+ disk_used_pct: number | null;
969
+ load_1m: number | null;
970
+ /** @description `null` also when the box's heartbeats leave it out. */
971
+ memory_pressure_pct: number | null;
972
+ alerts_fired: number;
973
+ };
974
+ MachineList: {
975
+ items: components["schemas"]["Machine"][];
976
+ };
977
+ MachineRef: {
978
+ id: string;
979
+ name: string;
980
+ };
981
+ /**
982
+ * @description As `LivenessStatus`, plus `pending` for a machine that has never reported.
983
+ * @enum {string}
984
+ */
985
+ MachineStatus: "pending" | "online" | "stale" | "down";
986
+ /**
987
+ * @description How much of its plan an environment's agent login has used, on
988
+ * Watch's clock. Percentages and reset times, never the login.
989
+ * Environments signed in to the same login show the same figures.
990
+ */
991
+ PlanUsage: {
992
+ /**
993
+ * @description Each limit in force: limits on all use first, by `window`,
994
+ * then the limits on one model.
995
+ */
996
+ limits: components["schemas"]["PlanUsageLimit"][];
997
+ /**
998
+ * Format: date-time
999
+ * @description When the box read the figures from the vendor. The box keeps
1000
+ * the last good reading while it cannot read a newer one, so this
1001
+ * can be older than `reported_at`.
1002
+ */
1003
+ read_at: string;
1004
+ /**
1005
+ * Format: date-time
1006
+ * @description When Watch last received it.
1007
+ */
1008
+ reported_at: string;
1009
+ };
1010
+ /**
1011
+ * @description One limit of a plan. A limit whose reset time has passed since the
1012
+ * reading reads `used_pct` 0 and `resets_at` `null`: its window has
1013
+ * started again, and nothing is used in it yet.
1014
+ */
1015
+ PlanUsageLimit: {
1016
+ window: components["schemas"]["PlanUsageWindow"];
1017
+ /** @description The model the limit applies to, as the vendor names it. `null` for a limit on all use. */
1018
+ scope: string | null;
1019
+ /** @description How much of the limit is used, in percent. */
1020
+ used_pct: number;
1021
+ /**
1022
+ * Format: date-time
1023
+ * @description When the window starts again. `null` when nothing is used in it.
1024
+ */
1025
+ resets_at: string | null;
1026
+ };
1027
+ /**
1028
+ * @description How long a plan limit runs before it starts again. `five_hour` is
1029
+ * the vendor's rolling five-hour limit, `seven_day` its weekly one.
1030
+ * @enum {string}
1031
+ */
1032
+ PlanUsageWindow: "five_hour" | "seven_day";
1033
+ /** @description RFC 7807 problem details, with a stable `code`. */
1034
+ Problem: {
1035
+ /** Format: uri */
1036
+ type: string;
1037
+ title: string;
1038
+ status: number;
1039
+ code: components["schemas"]["ProblemCode"];
1040
+ detail?: string;
1041
+ /** @description Present on `validation_failed`. */
1042
+ errors?: {
1043
+ /** @description Dotted path to the field, e.g. `events.0.branch`. */
1044
+ path: string;
1045
+ message: string;
1046
+ }[];
1047
+ /** @description Present on `limit_reached`. */
1048
+ limit?: {
1049
+ /** @enum {string} */
1050
+ name: "machines" | "alert_destinations" | "machine_tokens" | "members" | "api_keys";
1051
+ max: number;
1052
+ };
1053
+ /** @description Present on `plan_required`. The plan that includes this. */
1054
+ tier?: components["schemas"]["Tier"];
1055
+ };
1056
+ /** @enum {string} */
1057
+ ProblemCode: "malformed_json" | "validation_failed" | "unauthorized" | "forbidden" | "account_unavailable" | "limit_reached" | "environment_hidden" | "not_found" | "method_not_allowed" | "conflict" | "payload_too_large" | "unsupported_media_type" | "rate_limited" | "internal_error" | "billing_failed" | "channel_not_in_plan" | "plan_required";
1058
+ /**
1059
+ * @description The address of a pull request on GitHub: `owner`, `name` and a
1060
+ * number, and nothing else. No query, no fragment, no other host.
1061
+ * @example https://github.com/your-org/web/pull/412
1062
+ */
1063
+ PullRequestUrl: string;
1064
+ /** @description An envelope from the debug ring, with what Watch did with it. */
1065
+ RecordedEvent: {
1066
+ event_id: string;
1067
+ /** Format: date-time */
1068
+ received_at: string;
1069
+ /** Format: date-time */
1070
+ client_ts: string;
1071
+ type: components["schemas"]["EventType"];
1072
+ session_id: string;
1073
+ bridge_session_id: string | null;
1074
+ repos: string[] | null;
1075
+ branch: string | null;
1076
+ error_kind: string | null;
1077
+ /**
1078
+ * Format: date-time
1079
+ * @description The reset time a `stop_failure` carried, when it was in range.
1080
+ * `null` for every other event.
1081
+ */
1082
+ limit_resets_at: string | null;
1083
+ /**
1084
+ * @description `applied` changed the session. `late` arrived after a newer event
1085
+ * for the same session and changed nothing; so did an `outcome`
1086
+ * for a session Watch does not have. `ignored_ended` was for a
1087
+ * session that had already ended. An `outcome` for an ended
1088
+ * session is `applied`: that is when most of them arrive.
1089
+ * @enum {string}
1090
+ */
1091
+ disposition: "applied" | "late" | "ignored_ended";
1092
+ };
1093
+ Session: {
1094
+ session_id: string;
1095
+ /**
1096
+ * @description Counts the sessions that have used this `session_id` in the
1097
+ * environment. `session_id` plus `instance` is unique.
1098
+ */
1099
+ instance: number;
1100
+ /** @description The agent vendor's own id for the session, when the box knows it. */
1101
+ bridge_session_id: string | null;
1102
+ /**
1103
+ * Format: uri
1104
+ * @description The session itself in the vendor's app: the environment's
1105
+ * `session_url_template` with every `{session}` replaced by the
1106
+ * percent-encoded `bridge_session_id`. `null` when the
1107
+ * environment has no template or the session has no such id; link
1108
+ * to the environment's `vendor_url` then.
1109
+ */
1110
+ url: string | null;
1111
+ status: components["schemas"]["SessionStatus"];
1112
+ /**
1113
+ * @description What the session is waiting for. Set while `needs_input`.
1114
+ * @enum {string|null}
1115
+ */
1116
+ needs_kind: "permission" | "input" | "elicitation" | null;
1117
+ /**
1118
+ * Format: date-time
1119
+ * @description When Watch learned the session was waiting. Set while `needs_input`.
1120
+ */
1121
+ needs_since: string | null;
1122
+ /**
1123
+ * Format: date-time
1124
+ * @description When the waiting-too-long alert fired for this wait.
1125
+ */
1126
+ nagged_at: string | null;
1127
+ /**
1128
+ * Format: date-time
1129
+ * @description Since when the session has been working without a stop. Set
1130
+ * while `working` and kept while `stuck`; `null` in any other
1131
+ * status. Waiting on the owner starts it again: it is the time
1132
+ * the session last began to work. So does a new prompt to a
1133
+ * session stuck for working too long, which would otherwise be
1134
+ * stuck again at once. A session that was already working when
1135
+ * Watch began keeping this reads `null` until its next event;
1136
+ * count from `last_event_at` then.
1137
+ */
1138
+ working_since: string | null;
1139
+ /**
1140
+ * @description Why the session is `stuck`. `quiet`: working with no tool
1141
+ * activity for `stuck_quiet_after_s`. `long`: working for
1142
+ * `stuck_long_after_s` without a stop. When both pass at once it
1143
+ * is `long`. Set while `stuck`. A session stuck as `quiet` that
1144
+ * goes on to pass the longer deadline still reads `quiet` until
1145
+ * its next event, and is treated as `long` when that event
1146
+ * arrives.
1147
+ * @enum {string|null}
1148
+ */
1149
+ stuck_rule: "quiet" | "long" | null;
1150
+ /**
1151
+ * Format: date-time
1152
+ * @description When Watch called the session stuck. Set while `stuck`.
1153
+ */
1154
+ stuck_since: string | null;
1155
+ /**
1156
+ * @description The kind the box sent with the failed stop, or `unknown` when it
1157
+ * sent none. Set while `failed`, `usage_limited` or
1158
+ * `login_expired`. Never a message.
1159
+ */
1160
+ error_kind: string | null;
1161
+ /**
1162
+ * Format: date-time
1163
+ * @description When the usage limit resets, if the box said. Set only while
1164
+ * `usage_limited`. `null` means Watch does not know, not that the
1165
+ * limit has reset.
1166
+ */
1167
+ limit_resets_at: string | null;
1168
+ /**
1169
+ * Format: date-time
1170
+ * @description When the alert fired for the state the session is in now:
1171
+ * `session_failed`, `session_limited`, `session_login_expired` or
1172
+ * `session_stuck`. `null` in any other status, and when none
1173
+ * fired. Whether it was sent is on the alert, in `held`.
1174
+ */
1175
+ alerted_at: string | null;
1176
+ repos: string[];
1177
+ branch: string | null;
1178
+ /**
1179
+ * Format: date-time
1180
+ * @description When Watch first heard of the session.
1181
+ */
1182
+ started_at: string;
1183
+ /**
1184
+ * Format: date-time
1185
+ * @description When Watch received the last event that applied to the session.
1186
+ * An `outcome` does not move it.
1187
+ */
1188
+ last_event_at: string;
1189
+ /** Format: date-time */
1190
+ ended_at: string | null;
1191
+ /**
1192
+ * @description What the session left behind, from the box's `outcome` events.
1193
+ * `null` until one applies: the box reports it a few seconds
1194
+ * after a stop or an end, and only from a daemon that sends it.
1195
+ */
1196
+ outcome: components["schemas"]["SessionOutcome"] | null;
1197
+ };
1198
+ /** @description How many of the environment's sessions are in each status. */
1199
+ SessionCounts: {
1200
+ idle: number;
1201
+ working: number;
1202
+ needs_input: number;
1203
+ stuck: number;
1204
+ usage_limited: number;
1205
+ login_expired: number;
1206
+ failed: number;
1207
+ ended: number;
1208
+ };
1209
+ SessionList: {
1210
+ items: components["schemas"]["SessionListItem"][];
1211
+ next_cursor: string | null;
1212
+ };
1213
+ SessionListItem: {
1214
+ /** @description Stable for the life of the session. The same as its inbox item's. */
1215
+ id: string;
1216
+ machine: components["schemas"]["MachineRef"];
1217
+ environment: components["schemas"]["EnvironmentRef"];
1218
+ session: components["schemas"]["Session"];
1219
+ };
1220
+ /**
1221
+ * @description What a session left behind: counts and addresses, never a commit
1222
+ * subject or a pull request title. Each `outcome` event replaces the
1223
+ * fields it carries, so a count the box never sent stays `null`.
1224
+ */
1225
+ SessionOutcome: {
1226
+ /**
1227
+ * Format: date-time
1228
+ * @description When Watch received the latest `outcome` that applied.
1229
+ */
1230
+ reported_at: string;
1231
+ /** @description Commits the session made, across its repos. */
1232
+ commits: number | null;
1233
+ /** @description How many of the session's repos hold changes that are not committed. */
1234
+ uncommitted_repos: number | null;
1235
+ /** @description How many of the session's commits are on no remote. */
1236
+ unpushed_commits: number | null;
1237
+ /** @description The open pull requests whose head was the session's commit when the box last asked. Empty when the box reported none. */
1238
+ pull_requests: components["schemas"]["PullRequestUrl"][];
1239
+ };
1240
+ /**
1241
+ * @description A session has one status at a time.
1242
+ *
1243
+ * | Status | Means |
1244
+ * |---|---|
1245
+ * | `idle` | Finished a turn and is waiting for the next prompt. |
1246
+ * | `working` | Running. |
1247
+ * | `needs_input` | Waiting on its owner: a permission, an answer, information. |
1248
+ * | `stuck` | Working with nothing to show for it; `stuck_rule` says which rule. |
1249
+ * | `usage_limited` | Paused on a usage limit. Not a failure: it carries on when the limit resets. |
1250
+ * | `login_expired` | Stopped because the agent is signed out. Someone has to sign in on the box. |
1251
+ * | `failed` | Stopped with any other error; `error_kind` says which. |
1252
+ * | `ended` | Over. |
1253
+ *
1254
+ * `failed`, `usage_limited` and `login_expired` come only from a
1255
+ * `stop_failure` event, by its `error_kind`. `stuck` comes only from
1256
+ * the clock, only from `working`, and only while the machine and its
1257
+ * agent server are both `online`: a session is not called stuck while
1258
+ * Watch cannot hear from it. A session that is waiting on its owner
1259
+ * is never stuck.
1260
+ *
1261
+ * A client shows each of these as its own state. `usage_limited` and
1262
+ * `login_expired` are never to be worked out from `error_kind`.
1263
+ * @enum {string}
1264
+ */
1265
+ SessionStatus: "idle" | "working" | "needs_input" | "stuck" | "usage_limited" | "login_expired" | "failed" | "ended";
1266
+ /**
1267
+ * @description An `https` address with `{session}` in its path, query or fragment,
1268
+ * standing for the agent vendor's own id for a session
1269
+ * (`bridge_session_id`). `{session}` may appear more than once and is
1270
+ * the only brace allowed. No username or password, and `{session}`
1271
+ * cannot be in the host.
1272
+ *
1273
+ * The owner writes it: they open one session in the vendor's app,
1274
+ * copy its address and put `{session}` where the id is. Watch does
1275
+ * not know or guess any vendor's address format.
1276
+ * @example https://agent.example/sessions/{session}
1277
+ */
1278
+ SessionUrlTemplate: string;
1279
+ /**
1280
+ * @description What commands in the environment's sandbox may reach. `none` is
1281
+ * nothing, `limited` an allowlist of hosts, `full` anywhere.
1282
+ * @enum {string}
1283
+ */
1284
+ SetupNetwork: "none" | "limited" | "full";
1285
+ /**
1286
+ * @description `running` from the start of a run to its end. `ok` when it exited
1287
+ * with 0. `failed` when it exited with anything else, ran out of time
1288
+ * or was stopped by a signal.
1289
+ * @enum {string}
1290
+ */
1291
+ SetupScriptState: "running" | "ok" | "failed";
1292
+ StatusChange: {
1293
+ /** Format: date-time */
1294
+ at: string;
1295
+ /** @enum {string} */
1296
+ subject: "machine" | "server";
1297
+ from: components["schemas"]["LivenessStatus"];
1298
+ to: components["schemas"]["LivenessStatus"];
1299
+ };
1300
+ /** @enum {string} */
1301
+ Tier: "seed" | "grove" | "orchard" | "unlimited";
1302
+ /**
1303
+ * @description How much work exists only on the box: counts and the time they were
1304
+ * taken, never a name or a path. Environments that share a workspace
1305
+ * report the same counts.
1306
+ */
1307
+ Unsaved: {
1308
+ /** @description Repos with changes that are not committed. */
1309
+ uncommitted_repos: number;
1310
+ /** @description Commits that are on no remote. */
1311
+ unpushed_commits: number;
1312
+ /**
1313
+ * Format: date-time
1314
+ * @description When the box counted, on Watch's clock.
1315
+ */
1316
+ counted_at: string;
1317
+ };
1318
+ };
1319
+ responses: {
1320
+ /**
1321
+ * @description The request was malformed (`malformed_json`) or broke the schema
1322
+ * (`validation_failed`, with one entry in `errors` per problem).
1323
+ */
1324
+ BadRequest: {
1325
+ headers: {
1326
+ [name: string]: unknown;
1327
+ };
1328
+ content: {
1329
+ /**
1330
+ * @example {
1331
+ * "type": "https://nucarium.dev/problems/validation-failed",
1332
+ * "title": "The request is not valid",
1333
+ * "status": 400,
1334
+ * "code": "validation_failed",
1335
+ * "detail": "1 field is not allowed or not valid.",
1336
+ * "errors": [
1337
+ * {
1338
+ * "path": "events.0.prompt",
1339
+ * "message": "Unknown field."
1340
+ * }
1341
+ * ]
1342
+ * }
1343
+ */
1344
+ "application/problem+json": components["schemas"]["Problem"];
1345
+ };
1346
+ };
1347
+ /**
1348
+ * @description The account's plan does not include charts (`plan_required`), or,
1349
+ * with an API key, the account is not on Orchard (`plan_required`).
1350
+ */
1351
+ ChartsNotIncluded: {
1352
+ headers: {
1353
+ [name: string]: unknown;
1354
+ };
1355
+ content: {
1356
+ /**
1357
+ * @example {
1358
+ * "type": "https://nucarium.dev/problems/plan-required",
1359
+ * "title": "The account's plan does not include this",
1360
+ * "status": 403,
1361
+ * "code": "plan_required",
1362
+ * "detail": "Charts are part of Grove and Orchard.",
1363
+ * "tier": "grove"
1364
+ * }
1365
+ */
1366
+ "application/problem+json": components["schemas"]["Problem"];
1367
+ };
1368
+ };
1369
+ /**
1370
+ * @description The account's plan does not include charts (`plan_required`), the
1371
+ * environment is beyond the account's limit (`environment_hidden`),
1372
+ * or, with an API key, the account is not on Orchard
1373
+ * (`plan_required`).
1374
+ */
1375
+ ChartsNotIncludedOrHidden: {
1376
+ headers: {
1377
+ [name: string]: unknown;
1378
+ };
1379
+ content: {
1380
+ "application/problem+json": components["schemas"]["Problem"];
1381
+ };
1382
+ };
1383
+ /**
1384
+ * @description The environment is beyond the account's limit
1385
+ * (`environment_hidden`): it is still reporting and nothing is lost,
1386
+ * and it becomes readable when the account upgrades or removes
1387
+ * another environment. Or, with an API key, the account is not on
1388
+ * Orchard (`plan_required`).
1389
+ */
1390
+ EnvironmentHiddenOrKeyForbidden: {
1391
+ headers: {
1392
+ [name: string]: unknown;
1393
+ };
1394
+ content: {
1395
+ "application/problem+json": components["schemas"]["Problem"];
1396
+ };
1397
+ };
1398
+ /** @description With an API key: the account is not on Orchard (`plan_required`). */
1399
+ KeyForbidden: {
1400
+ headers: {
1401
+ [name: string]: unknown;
1402
+ };
1403
+ content: {
1404
+ /**
1405
+ * @example {
1406
+ * "type": "https://nucarium.dev/problems/plan-required",
1407
+ * "title": "The account's plan does not include this",
1408
+ * "status": 403,
1409
+ * "code": "plan_required",
1410
+ * "detail": "The read API is part of Orchard.",
1411
+ * "tier": "orchard"
1412
+ * }
1413
+ */
1414
+ "application/problem+json": components["schemas"]["Problem"];
1415
+ };
1416
+ };
1417
+ /** @description Nothing with that id belongs to the account (`not_found`). */
1418
+ NotFound: {
1419
+ headers: {
1420
+ [name: string]: unknown;
1421
+ };
1422
+ content: {
1423
+ "application/problem+json": components["schemas"]["Problem"];
1424
+ };
1425
+ };
1426
+ /** @description The caller is sending too fast (`rate_limited`). Wait `Retry-After` seconds. */
1427
+ RateLimited: {
1428
+ headers: {
1429
+ "Retry-After"?: number;
1430
+ [name: string]: unknown;
1431
+ };
1432
+ content: {
1433
+ "application/problem+json": components["schemas"]["Problem"];
1434
+ };
1435
+ };
1436
+ /**
1437
+ * @description The credential is missing, wrong, expired or revoked, or the person
1438
+ * is not one Watch knows: they have not signed in, or their account was
1439
+ * deleted (`unauthorized`).
1440
+ */
1441
+ Unauthorized: {
1442
+ headers: {
1443
+ [name: string]: unknown;
1444
+ };
1445
+ content: {
1446
+ "application/problem+json": components["schemas"]["Problem"];
1447
+ };
1448
+ };
1449
+ };
1450
+ parameters: {
1451
+ /** @description The `next_cursor` of the previous page. */
1452
+ Cursor: string;
1453
+ EnvironmentId: string;
1454
+ /** @description Keep only what belongs to this environment. */
1455
+ EnvironmentIdFilter: string;
1456
+ /**
1457
+ * @description How far back to look. Each range has its own step: ten minutes for
1458
+ * `24h`, an hour for `7d`, six hours for `30d` and twelve for `90d`.
1459
+ * The last step is the one now falls in.
1460
+ */
1461
+ HistoryRange: components["schemas"]["HistoryRange"];
1462
+ Limit: number;
1463
+ MachineId: string;
1464
+ /** @description Keep only what belongs to this machine. */
1465
+ MachineIdFilter: string;
1466
+ };
1467
+ requestBodies: never;
1468
+ headers: never;
1469
+ pathItems: never;
1470
+ };
1471
+ export type $defs = Record<string, never>;
1472
+ export interface operations {
1473
+ getInbox: {
1474
+ parameters: {
1475
+ query?: {
1476
+ /** @description Keep only what belongs to this machine. */
1477
+ machine_id?: components["parameters"]["MachineIdFilter"];
1478
+ /** @description Keep only what belongs to this environment. */
1479
+ environment_id?: components["parameters"]["EnvironmentIdFilter"];
1480
+ /** @description Keep only items with one of these attention levels. */
1481
+ attention?: components["schemas"]["Attention"][];
1482
+ };
1483
+ header?: never;
1484
+ path?: never;
1485
+ cookie?: never;
1486
+ };
1487
+ requestBody?: never;
1488
+ responses: {
1489
+ /** @description The inbox. */
1490
+ 200: {
1491
+ headers: {
1492
+ [name: string]: unknown;
1493
+ };
1494
+ content: {
1495
+ "application/json": components["schemas"]["Inbox"];
1496
+ };
1497
+ };
1498
+ 400: components["responses"]["BadRequest"];
1499
+ 401: components["responses"]["Unauthorized"];
1500
+ 403: components["responses"]["KeyForbidden"];
1501
+ 429: components["responses"]["RateLimited"];
1502
+ };
1503
+ };
1504
+ listSessions: {
1505
+ parameters: {
1506
+ query?: {
1507
+ /** @description Keep only what belongs to this machine. */
1508
+ machine_id?: components["parameters"]["MachineIdFilter"];
1509
+ /** @description Keep only what belongs to this environment. */
1510
+ environment_id?: components["parameters"]["EnvironmentIdFilter"];
1511
+ /** @description Keep only sessions with one of these statuses. */
1512
+ status?: components["schemas"]["SessionStatus"][];
1513
+ /** @description Also list sessions that have ended. */
1514
+ include_ended?: boolean;
1515
+ limit?: components["parameters"]["Limit"];
1516
+ /** @description The `next_cursor` of the previous page. */
1517
+ cursor?: components["parameters"]["Cursor"];
1518
+ };
1519
+ header?: never;
1520
+ path?: never;
1521
+ cookie?: never;
1522
+ };
1523
+ requestBody?: never;
1524
+ responses: {
1525
+ /** @description A page of sessions. */
1526
+ 200: {
1527
+ headers: {
1528
+ [name: string]: unknown;
1529
+ };
1530
+ content: {
1531
+ "application/json": components["schemas"]["SessionList"];
1532
+ };
1533
+ };
1534
+ 400: components["responses"]["BadRequest"];
1535
+ 401: components["responses"]["Unauthorized"];
1536
+ 403: components["responses"]["KeyForbidden"];
1537
+ 429: components["responses"]["RateLimited"];
1538
+ };
1539
+ };
1540
+ listMachines: {
1541
+ parameters: {
1542
+ query?: never;
1543
+ header?: never;
1544
+ path?: never;
1545
+ cookie?: never;
1546
+ };
1547
+ requestBody?: never;
1548
+ responses: {
1549
+ /** @description Every machine in the account, oldest first. */
1550
+ 200: {
1551
+ headers: {
1552
+ [name: string]: unknown;
1553
+ };
1554
+ content: {
1555
+ "application/json": components["schemas"]["MachineList"];
1556
+ };
1557
+ };
1558
+ 401: components["responses"]["Unauthorized"];
1559
+ 403: components["responses"]["KeyForbidden"];
1560
+ 429: components["responses"]["RateLimited"];
1561
+ };
1562
+ };
1563
+ getMachine: {
1564
+ parameters: {
1565
+ query?: never;
1566
+ header?: never;
1567
+ path: {
1568
+ machine_id: components["parameters"]["MachineId"];
1569
+ };
1570
+ cookie?: never;
1571
+ };
1572
+ requestBody?: never;
1573
+ responses: {
1574
+ /** @description The machine. */
1575
+ 200: {
1576
+ headers: {
1577
+ [name: string]: unknown;
1578
+ };
1579
+ content: {
1580
+ "application/json": components["schemas"]["Machine"];
1581
+ };
1582
+ };
1583
+ 401: components["responses"]["Unauthorized"];
1584
+ 403: components["responses"]["KeyForbidden"];
1585
+ 404: components["responses"]["NotFound"];
1586
+ 429: components["responses"]["RateLimited"];
1587
+ };
1588
+ };
1589
+ getMachineHistory: {
1590
+ parameters: {
1591
+ query?: {
1592
+ /**
1593
+ * @description How far back to look. Each range has its own step: ten minutes for
1594
+ * `24h`, an hour for `7d`, six hours for `30d` and twelve for `90d`.
1595
+ * The last step is the one now falls in.
1596
+ */
1597
+ range?: components["parameters"]["HistoryRange"];
1598
+ };
1599
+ header?: never;
1600
+ path: {
1601
+ machine_id: components["parameters"]["MachineId"];
1602
+ };
1603
+ cookie?: never;
1604
+ };
1605
+ requestBody?: never;
1606
+ responses: {
1607
+ /** @description One item per step, oldest first. */
1608
+ 200: {
1609
+ headers: {
1610
+ [name: string]: unknown;
1611
+ };
1612
+ content: {
1613
+ "application/json": components["schemas"]["MachineHistory"];
1614
+ };
1615
+ };
1616
+ 400: components["responses"]["BadRequest"];
1617
+ 401: components["responses"]["Unauthorized"];
1618
+ 403: components["responses"]["ChartsNotIncluded"];
1619
+ 404: components["responses"]["NotFound"];
1620
+ 429: components["responses"]["RateLimited"];
1621
+ };
1622
+ };
1623
+ listEnvironments: {
1624
+ parameters: {
1625
+ query?: {
1626
+ /** @description Keep only what belongs to this machine. */
1627
+ machine_id?: components["parameters"]["MachineIdFilter"];
1628
+ /** @description Keep only environments with one of these statuses. */
1629
+ status?: components["schemas"]["EnvironmentStatus"][];
1630
+ /**
1631
+ * @description Also list environments beyond the account's limit. A hidden
1632
+ * environment is listed by name only: everything Watch learned
1633
+ * from the box is `null`, as `Environment` says.
1634
+ */
1635
+ include_hidden?: boolean;
1636
+ };
1637
+ header?: never;
1638
+ path?: never;
1639
+ cookie?: never;
1640
+ };
1641
+ requestBody?: never;
1642
+ responses: {
1643
+ /** @description The account's environments, oldest first. */
1644
+ 200: {
1645
+ headers: {
1646
+ [name: string]: unknown;
1647
+ };
1648
+ content: {
1649
+ "application/json": components["schemas"]["EnvironmentList"];
1650
+ };
1651
+ };
1652
+ 400: components["responses"]["BadRequest"];
1653
+ 401: components["responses"]["Unauthorized"];
1654
+ 403: components["responses"]["KeyForbidden"];
1655
+ 429: components["responses"]["RateLimited"];
1656
+ };
1657
+ };
1658
+ getEnvironment: {
1659
+ parameters: {
1660
+ query?: never;
1661
+ header?: never;
1662
+ path: {
1663
+ environment_id: components["parameters"]["EnvironmentId"];
1664
+ };
1665
+ cookie?: never;
1666
+ };
1667
+ requestBody?: never;
1668
+ responses: {
1669
+ /** @description The environment, its sessions and its recent status changes. */
1670
+ 200: {
1671
+ headers: {
1672
+ [name: string]: unknown;
1673
+ };
1674
+ content: {
1675
+ "application/json": components["schemas"]["EnvironmentSnapshot"];
1676
+ };
1677
+ };
1678
+ 401: components["responses"]["Unauthorized"];
1679
+ 403: components["responses"]["EnvironmentHiddenOrKeyForbidden"];
1680
+ 404: components["responses"]["NotFound"];
1681
+ 429: components["responses"]["RateLimited"];
1682
+ };
1683
+ };
1684
+ listEnvironmentEvents: {
1685
+ parameters: {
1686
+ query?: {
1687
+ limit?: components["parameters"]["Limit"];
1688
+ /** @description The `next_cursor` of the previous page. */
1689
+ cursor?: components["parameters"]["Cursor"];
1690
+ };
1691
+ header?: never;
1692
+ path: {
1693
+ environment_id: components["parameters"]["EnvironmentId"];
1694
+ };
1695
+ cookie?: never;
1696
+ };
1697
+ requestBody?: never;
1698
+ responses: {
1699
+ /** @description A page of the ring. */
1700
+ 200: {
1701
+ headers: {
1702
+ [name: string]: unknown;
1703
+ };
1704
+ content: {
1705
+ "application/json": components["schemas"]["EventList"];
1706
+ };
1707
+ };
1708
+ 400: components["responses"]["BadRequest"];
1709
+ 401: components["responses"]["Unauthorized"];
1710
+ 403: components["responses"]["EnvironmentHiddenOrKeyForbidden"];
1711
+ 404: components["responses"]["NotFound"];
1712
+ 429: components["responses"]["RateLimited"];
1713
+ };
1714
+ };
1715
+ getEnvironmentHistory: {
1716
+ parameters: {
1717
+ query?: {
1718
+ /**
1719
+ * @description How far back to look. Each range has its own step: ten minutes for
1720
+ * `24h`, an hour for `7d`, six hours for `30d` and twelve for `90d`.
1721
+ * The last step is the one now falls in.
1722
+ */
1723
+ range?: components["parameters"]["HistoryRange"];
1724
+ };
1725
+ header?: never;
1726
+ path: {
1727
+ environment_id: components["parameters"]["EnvironmentId"];
1728
+ };
1729
+ cookie?: never;
1730
+ };
1731
+ requestBody?: never;
1732
+ responses: {
1733
+ /** @description One item per step, oldest first. */
1734
+ 200: {
1735
+ headers: {
1736
+ [name: string]: unknown;
1737
+ };
1738
+ content: {
1739
+ "application/json": components["schemas"]["EnvironmentHistory"];
1740
+ };
1741
+ };
1742
+ 400: components["responses"]["BadRequest"];
1743
+ 401: components["responses"]["Unauthorized"];
1744
+ 403: components["responses"]["ChartsNotIncludedOrHidden"];
1745
+ 404: components["responses"]["NotFound"];
1746
+ 429: components["responses"]["RateLimited"];
1747
+ };
1748
+ };
1749
+ listAlerts: {
1750
+ parameters: {
1751
+ query?: {
1752
+ /** @description Keep only what belongs to this machine. */
1753
+ machine_id?: components["parameters"]["MachineIdFilter"];
1754
+ /** @description Keep only what belongs to this environment. */
1755
+ environment_id?: components["parameters"]["EnvironmentIdFilter"];
1756
+ /** @description Keep only alerts of one of these kinds. */
1757
+ kind?: components["schemas"]["AlertKind"][];
1758
+ /**
1759
+ * @description `true` keeps only open alerts: sent, not a notice, and neither
1760
+ * acknowledged nor resolved. `false` keeps only the rest.
1761
+ */
1762
+ open?: boolean;
1763
+ limit?: components["parameters"]["Limit"];
1764
+ /** @description The `next_cursor` of the previous page. */
1765
+ cursor?: components["parameters"]["Cursor"];
1766
+ };
1767
+ header?: never;
1768
+ path?: never;
1769
+ cookie?: never;
1770
+ };
1771
+ requestBody?: never;
1772
+ responses: {
1773
+ /** @description A page of alert history. */
1774
+ 200: {
1775
+ headers: {
1776
+ [name: string]: unknown;
1777
+ };
1778
+ content: {
1779
+ "application/json": components["schemas"]["AlertList"];
1780
+ };
1781
+ };
1782
+ 400: components["responses"]["BadRequest"];
1783
+ 401: components["responses"]["Unauthorized"];
1784
+ 403: components["responses"]["KeyForbidden"];
1785
+ 429: components["responses"]["RateLimited"];
1786
+ };
1787
+ };
1788
+ }