@impz/client 6.10.0 → 6.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,8 +53,13 @@ never retried.
53
53
 
54
54
  `watchEvents(imp, { onEvent })` follows `events.stream`: every imp first, then each change. `name`
55
55
  keeps one imp's events, and `reconnect: { delayMs }` opens a fresh stream whenever one ends, until
56
- impd refuses the call or `signal` aborts. `onOpen` runs as each stream opens, so a caller can catch
57
- up on what changed while it was away.
56
+ impd refuses the call or `signal` aborts. A reconnect resumes after the last event the watch read,
57
+ across impd restarts, so `onEvent` misses nothing. On a resumed stream, the watch also reads impd's
58
+ `Position` events, which move its cursor past the events of imps the token may not see, and passes
59
+ none of them on. It passes over an event kind it does not know, which a newer impd may send. When
60
+ impd no longer holds the events since then, `onEvent` gets `Reset` and then every imp again.
61
+ `onOpen` runs as each stream opens, with the cursor it opens at: a stream with no `after` starts
62
+ with every imp, and the caller may have missed what changed while it was away.
58
63
 
59
64
  `openForwardTunnel` relays one connection to a port in the imp over `/tunnel`, and
60
65
  `openReverseForward` listens in the imp and relays each client back. `openToolExec` runs an agent
package/dist/index.d.ts CHANGED
@@ -95,6 +95,8 @@ type DetachReason = (typeof DETACH_REASONS)[number];
95
95
  declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
96
96
  v: z.ZodLiteral<1>;
97
97
  at: z.ZodDate;
98
+ seq: z.ZodInt;
99
+ logId: z.ZodString;
98
100
  ev: z.ZodLiteral<"ImpAdded">;
99
101
  reason: z.ZodEnum<{
100
102
  created: "created";
@@ -200,6 +202,8 @@ declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
200
202
  }, z.core.$strip>, z.ZodObject<{
201
203
  v: z.ZodLiteral<1>;
202
204
  at: z.ZodDate;
205
+ seq: z.ZodInt;
206
+ logId: z.ZodString;
203
207
  ev: z.ZodLiteral<"ImpChanged">;
204
208
  reason: z.ZodEnum<{
205
209
  adopted: "adopted";
@@ -325,6 +329,8 @@ declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
325
329
  }, z.core.$strip>, z.ZodObject<{
326
330
  v: z.ZodLiteral<1>;
327
331
  at: z.ZodDate;
332
+ seq: z.ZodInt;
333
+ logId: z.ZodString;
328
334
  ev: z.ZodLiteral<"ImpRemoved">;
329
335
  imp: z.ZodObject<{
330
336
  id: z.ZodString;
@@ -426,6 +432,8 @@ declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
426
432
  }, z.core.$strip>, z.ZodObject<{
427
433
  v: z.ZodLiteral<1>;
428
434
  at: z.ZodDate;
435
+ seq: z.ZodInt;
436
+ logId: z.ZodString;
429
437
  ev: z.ZodLiteral<"CheckpointAdded">;
430
438
  name: z.ZodString;
431
439
  checkpoint: z.ZodObject<{
@@ -438,6 +446,8 @@ declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
438
446
  }, z.core.$strip>, z.ZodObject<{
439
447
  v: z.ZodLiteral<1>;
440
448
  at: z.ZodDate;
449
+ seq: z.ZodInt;
450
+ logId: z.ZodString;
441
451
  ev: z.ZodLiteral<"CheckpointRemoved">;
442
452
  name: z.ZodString;
443
453
  checkpoint: z.ZodObject<{
@@ -450,6 +460,8 @@ declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
450
460
  }, z.core.$strip>, z.ZodObject<{
451
461
  v: z.ZodLiteral<1>;
452
462
  at: z.ZodDate;
463
+ seq: z.ZodInt;
464
+ logId: z.ZodString;
453
465
  ev: z.ZodLiteral<"GovernorDecision">;
454
466
  decision: z.ZodEnum<{
455
467
  admitted: "admitted";
@@ -466,6 +478,8 @@ declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
466
478
  }, z.core.$strip>, z.ZodObject<{
467
479
  v: z.ZodLiteral<1>;
468
480
  at: z.ZodDate;
481
+ seq: z.ZodInt;
482
+ logId: z.ZodString;
469
483
  ev: z.ZodLiteral<"AgentExec">;
470
484
  name: z.ZodString;
471
485
  actor: z.ZodEnum<{
@@ -478,8 +492,25 @@ declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
478
492
  actorName: z.ZodString;
479
493
  tty: z.ZodBoolean;
480
494
  command: z.ZodString;
495
+ }, z.core.$strip>, z.ZodObject<{
496
+ v: z.ZodLiteral<1>;
497
+ at: z.ZodDate;
498
+ seq: z.ZodInt;
499
+ logId: z.ZodString;
500
+ ev: z.ZodLiteral<"Reset">;
501
+ }, z.core.$strip>, z.ZodObject<{
502
+ v: z.ZodLiteral<1>;
503
+ at: z.ZodDate;
504
+ seq: z.ZodInt;
505
+ logId: z.ZodString;
506
+ ev: z.ZodLiteral<"Position">;
481
507
  }, z.core.$strip>], "ev">;
482
508
  type ImpEvent = z.infer<typeof ImpEventSchema>;
509
+ declare const EventCursorSchema: z.ZodObject<{
510
+ after: z.ZodOptional<z.ZodInt>;
511
+ logId: z.ZodOptional<z.ZodString>;
512
+ }, z.core.$strip>;
513
+ type EventCursor = z.infer<typeof EventCursorSchema>;
483
514
  declare const TunnelListenSchema: z.ZodObject<{
484
515
  type: z.ZodLiteral<"listen">;
485
516
  name: z.ZodString;
@@ -16378,9 +16409,14 @@ declare const impContract: {
16378
16409
  }>, ProcedureMeta & Record<never, never>>;
16379
16410
  };
16380
16411
  events: {
16381
- stream: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").Schema<AsyncIteratorObject<{
16412
+ stream: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodOptional<import("zod").ZodObject<{
16413
+ after: import("zod").ZodOptional<import("zod").ZodInt>;
16414
+ logId: import("zod").ZodOptional<import("zod").ZodString>;
16415
+ }, import("zod/v4/core").$strip>>, import("@orpc/contract").Schema<AsyncIteratorObject<{
16382
16416
  v: 1;
16383
16417
  at: Date;
16418
+ seq: number;
16419
+ logId: string;
16384
16420
  ev: "ImpAdded";
16385
16421
  reason: "created" | "snapshot";
16386
16422
  imp: {
@@ -16460,6 +16496,8 @@ declare const impContract: {
16460
16496
  } | {
16461
16497
  v: 1;
16462
16498
  at: Date;
16499
+ seq: number;
16500
+ logId: string;
16463
16501
  ev: "ImpChanged";
16464
16502
  reason: "adopted" | "booted" | "exposed" | "failed" | "held" | "released" | "repaired" | "resized" | "restored" | "slept" | "stopped" | "updated" | "woke";
16465
16503
  imp: {
@@ -16548,6 +16586,8 @@ declare const impContract: {
16548
16586
  } | {
16549
16587
  v: 1;
16550
16588
  at: Date;
16589
+ seq: number;
16590
+ logId: string;
16551
16591
  ev: "ImpRemoved";
16552
16592
  imp: {
16553
16593
  id: string;
@@ -16626,6 +16666,8 @@ declare const impContract: {
16626
16666
  } | {
16627
16667
  v: 1;
16628
16668
  at: Date;
16669
+ seq: number;
16670
+ logId: string;
16629
16671
  ev: "CheckpointAdded";
16630
16672
  name: string;
16631
16673
  checkpoint: {
@@ -16638,6 +16680,8 @@ declare const impContract: {
16638
16680
  } | {
16639
16681
  v: 1;
16640
16682
  at: Date;
16683
+ seq: number;
16684
+ logId: string;
16641
16685
  ev: "CheckpointRemoved";
16642
16686
  name: string;
16643
16687
  checkpoint: {
@@ -16650,6 +16694,8 @@ declare const impContract: {
16650
16694
  } | {
16651
16695
  v: 1;
16652
16696
  at: Date;
16697
+ seq: number;
16698
+ logId: string;
16653
16699
  ev: "GovernorDecision";
16654
16700
  decision: "admitted" | "refused" | "slept";
16655
16701
  name: string;
@@ -16662,15 +16708,31 @@ declare const impContract: {
16662
16708
  } | {
16663
16709
  v: 1;
16664
16710
  at: Date;
16711
+ seq: number;
16712
+ logId: string;
16665
16713
  ev: "AgentExec";
16666
16714
  name: string;
16667
16715
  actor: "dashboard" | "oauth" | "ssh" | "tailnet" | "token";
16668
16716
  actorName: string;
16669
16717
  tty: boolean;
16670
16718
  command: string;
16719
+ } | {
16720
+ v: 1;
16721
+ at: Date;
16722
+ seq: number;
16723
+ logId: string;
16724
+ ev: "Reset";
16725
+ } | {
16726
+ v: 1;
16727
+ at: Date;
16728
+ seq: number;
16729
+ logId: string;
16730
+ ev: "Position";
16671
16731
  }, unknown, void>, import("@orpc/client").AsyncIteratorClass<{
16672
16732
  v: 1;
16673
16733
  at: Date;
16734
+ seq: number;
16735
+ logId: string;
16674
16736
  ev: "ImpAdded";
16675
16737
  reason: "created" | "snapshot";
16676
16738
  imp: {
@@ -16750,6 +16812,8 @@ declare const impContract: {
16750
16812
  } | {
16751
16813
  v: 1;
16752
16814
  at: Date;
16815
+ seq: number;
16816
+ logId: string;
16753
16817
  ev: "ImpChanged";
16754
16818
  reason: "adopted" | "booted" | "exposed" | "failed" | "held" | "released" | "repaired" | "resized" | "restored" | "slept" | "stopped" | "updated" | "woke";
16755
16819
  imp: {
@@ -16838,6 +16902,8 @@ declare const impContract: {
16838
16902
  } | {
16839
16903
  v: 1;
16840
16904
  at: Date;
16905
+ seq: number;
16906
+ logId: string;
16841
16907
  ev: "ImpRemoved";
16842
16908
  imp: {
16843
16909
  id: string;
@@ -16916,6 +16982,8 @@ declare const impContract: {
16916
16982
  } | {
16917
16983
  v: 1;
16918
16984
  at: Date;
16985
+ seq: number;
16986
+ logId: string;
16919
16987
  ev: "CheckpointAdded";
16920
16988
  name: string;
16921
16989
  checkpoint: {
@@ -16928,6 +16996,8 @@ declare const impContract: {
16928
16996
  } | {
16929
16997
  v: 1;
16930
16998
  at: Date;
16999
+ seq: number;
17000
+ logId: string;
16931
17001
  ev: "CheckpointRemoved";
16932
17002
  name: string;
16933
17003
  checkpoint: {
@@ -16940,6 +17010,8 @@ declare const impContract: {
16940
17010
  } | {
16941
17011
  v: 1;
16942
17012
  at: Date;
17013
+ seq: number;
17014
+ logId: string;
16943
17015
  ev: "GovernorDecision";
16944
17016
  decision: "admitted" | "refused" | "slept";
16945
17017
  name: string;
@@ -16952,12 +17024,26 @@ declare const impContract: {
16952
17024
  } | {
16953
17025
  v: 1;
16954
17026
  at: Date;
17027
+ seq: number;
17028
+ logId: string;
16955
17029
  ev: "AgentExec";
16956
17030
  name: string;
16957
17031
  actor: "dashboard" | "oauth" | "ssh" | "tailnet" | "token";
16958
17032
  actorName: string;
16959
17033
  tty: boolean;
16960
17034
  command: string;
17035
+ } | {
17036
+ v: 1;
17037
+ at: Date;
17038
+ seq: number;
17039
+ logId: string;
17040
+ ev: "Reset";
17041
+ } | {
17042
+ v: 1;
17043
+ at: Date;
17044
+ seq: number;
17045
+ logId: string;
17046
+ ev: "Position";
16961
17047
  }, unknown, void>>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
16962
17048
  NOT_FOUND: {
16963
17049
  readonly message: "Not found";
@@ -17134,6 +17220,603 @@ declare const impContract: {
17134
17220
  }, import("zod/v4/core").$strip>;
17135
17221
  };
17136
17222
  }>, ProcedureMeta & Record<never, never>>;
17223
+ list: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
17224
+ after: import("zod").ZodOptional<import("zod").ZodInt>;
17225
+ logId: import("zod").ZodOptional<import("zod").ZodString>;
17226
+ limit: import("zod").ZodOptional<import("zod").ZodInt>;
17227
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17228
+ events: import("zod").ZodArray<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
17229
+ v: import("zod").ZodLiteral<1>;
17230
+ at: import("zod").ZodDate;
17231
+ seq: import("zod").ZodInt;
17232
+ logId: import("zod").ZodString;
17233
+ ev: import("zod").ZodLiteral<"ImpAdded">;
17234
+ reason: import("zod").ZodEnum<{
17235
+ created: "created";
17236
+ snapshot: "snapshot";
17237
+ }>;
17238
+ imp: import("zod").ZodObject<{
17239
+ id: import("zod").ZodString;
17240
+ name: import("zod").ZodString;
17241
+ image: import("zod").ZodString;
17242
+ state: import("zod").ZodEnum<{
17243
+ creating: "creating";
17244
+ error: "error";
17245
+ running: "running";
17246
+ sleeping: "sleeping";
17247
+ stopped: "stopped";
17248
+ }>;
17249
+ kind: import("zod").ZodOptional<import("zod").ZodEnum<{
17250
+ builder: "builder";
17251
+ user: "user";
17252
+ }>>;
17253
+ vcpus: import("zod").ZodInt;
17254
+ memoryMib: import("zod").ZodInt;
17255
+ maxMemoryMib: import("zod").ZodOptional<import("zod").ZodInt>;
17256
+ pluggedMib: import("zod").ZodOptional<import("zod").ZodInt>;
17257
+ backup: import("zod").ZodOptional<import("zod").ZodBoolean>;
17258
+ diskMib: import("zod").ZodInt;
17259
+ diskUsage: import("zod").ZodOptional<import("zod").ZodObject<{
17260
+ exclusiveBytes: import("zod").ZodInt;
17261
+ sharedBytes: import("zod").ZodInt;
17262
+ measuredAt: import("zod").ZodDate;
17263
+ isPartial: import("zod").ZodBoolean;
17264
+ isUpperBound: import("zod").ZodBoolean;
17265
+ }, import("zod/v4/core").$strip>>;
17266
+ ip: import("zod").ZodIPv4;
17267
+ slot: import("zod").ZodInt;
17268
+ port: import("zod").ZodInt;
17269
+ httpPort: import("zod").ZodInt;
17270
+ url: import("zod").ZodURL;
17271
+ public: import("zod").ZodOptional<import("zod").ZodObject<{
17272
+ auth: import("zod").ZodEnum<{
17273
+ basic: "basic";
17274
+ none: "none";
17275
+ token: "token";
17276
+ }>;
17277
+ }, import("zod/v4/core").$strip>>;
17278
+ createdAt: import("zod").ZodDate;
17279
+ lastActiveAt: import("zod").ZodDate;
17280
+ lastRequestAt: import("zod").ZodOptional<import("zod").ZodDate>;
17281
+ ramMib: import("zod").ZodOptional<import("zod").ZodInt>;
17282
+ rssMib: import("zod").ZodOptional<import("zod").ZodInt>;
17283
+ sleptAt: import("zod").ZodOptional<import("zod").ZodDate>;
17284
+ holdUntil: import("zod").ZodOptional<import("zod").ZodDate>;
17285
+ leases: import("zod").ZodOptional<import("zod").ZodObject<{
17286
+ leases: import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodObject<{
17287
+ name: import("zod").ZodString;
17288
+ owner: import("zod").ZodObject<{
17289
+ principal: import("zod").ZodString;
17290
+ display: import("zod").ZodString;
17291
+ label: import("zod").ZodString;
17292
+ }, import("zod/v4/core").$strip>;
17293
+ until: import("zod").ZodNullable<import("zod").ZodDate>;
17294
+ }, import("zod/v4/core").$strip>>>;
17295
+ otherCount: import("zod").ZodInt;
17296
+ }, import("zod/v4/core").$strip>>;
17297
+ error: import("zod").ZodOptional<import("zod").ZodString>;
17298
+ sessions: import("zod").ZodOptional<import("zod").ZodInt>;
17299
+ coldBootReason: import("zod").ZodOptional<import("zod").ZodString>;
17300
+ agentSilentSince: import("zod").ZodOptional<import("zod").ZodDate>;
17301
+ inner: import("zod").ZodOptional<import("zod").ZodObject<{
17302
+ up: import("zod").ZodBoolean;
17303
+ restarts: import("zod").ZodInt;
17304
+ lastError: import("zod").ZodOptional<import("zod").ZodString>;
17305
+ }, import("zod/v4/core").$strip>>;
17306
+ outdated: import("zod").ZodOptional<import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodEnum<{
17307
+ agent: "agent";
17308
+ firecracker: "firecracker";
17309
+ impd: "impd";
17310
+ ipv6: "ipv6";
17311
+ kernel: "kernel";
17312
+ }>>>>;
17313
+ cpu: import("zod").ZodOptional<import("zod").ZodObject<{
17314
+ limit: import("zod").ZodNullable<import("zod").ZodNumber>;
17315
+ weight: import("zod").ZodInt;
17316
+ }, import("zod/v4/core").$strip>>;
17317
+ resources: import("zod").ZodOptional<import("zod").ZodObject<{
17318
+ wakeCount: import("zod").ZodInt;
17319
+ awakeMs: import("zod").ZodInt;
17320
+ sample: import("zod").ZodOptional<import("zod").ZodObject<{
17321
+ measuredAt: import("zod").ZodDate;
17322
+ since: import("zod").ZodDate;
17323
+ cpuPercent: import("zod").ZodOptional<import("zod").ZodNumber>;
17324
+ cpuThrottledMs: import("zod").ZodInt;
17325
+ netRxBytes: import("zod").ZodInt;
17326
+ netTxBytes: import("zod").ZodInt;
17327
+ }, import("zod/v4/core").$strip>>;
17328
+ }, import("zod/v4/core").$strip>>;
17329
+ move: import("zod").ZodOptional<import("zod").ZodEnum<{
17330
+ moved: "moved";
17331
+ receiving: "receiving";
17332
+ sending: "sending";
17333
+ }>>;
17334
+ }, import("zod/v4/core").$strip>;
17335
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17336
+ v: import("zod").ZodLiteral<1>;
17337
+ at: import("zod").ZodDate;
17338
+ seq: import("zod").ZodInt;
17339
+ logId: import("zod").ZodString;
17340
+ ev: import("zod").ZodLiteral<"ImpChanged">;
17341
+ reason: import("zod").ZodEnum<{
17342
+ adopted: "adopted";
17343
+ booted: "booted";
17344
+ exposed: "exposed";
17345
+ failed: "failed";
17346
+ held: "held";
17347
+ released: "released";
17348
+ repaired: "repaired";
17349
+ resized: "resized";
17350
+ restored: "restored";
17351
+ slept: "slept";
17352
+ stopped: "stopped";
17353
+ updated: "updated";
17354
+ woke: "woke";
17355
+ }>;
17356
+ imp: import("zod").ZodObject<{
17357
+ id: import("zod").ZodString;
17358
+ name: import("zod").ZodString;
17359
+ image: import("zod").ZodString;
17360
+ state: import("zod").ZodEnum<{
17361
+ creating: "creating";
17362
+ error: "error";
17363
+ running: "running";
17364
+ sleeping: "sleeping";
17365
+ stopped: "stopped";
17366
+ }>;
17367
+ kind: import("zod").ZodOptional<import("zod").ZodEnum<{
17368
+ builder: "builder";
17369
+ user: "user";
17370
+ }>>;
17371
+ vcpus: import("zod").ZodInt;
17372
+ memoryMib: import("zod").ZodInt;
17373
+ maxMemoryMib: import("zod").ZodOptional<import("zod").ZodInt>;
17374
+ pluggedMib: import("zod").ZodOptional<import("zod").ZodInt>;
17375
+ backup: import("zod").ZodOptional<import("zod").ZodBoolean>;
17376
+ diskMib: import("zod").ZodInt;
17377
+ diskUsage: import("zod").ZodOptional<import("zod").ZodObject<{
17378
+ exclusiveBytes: import("zod").ZodInt;
17379
+ sharedBytes: import("zod").ZodInt;
17380
+ measuredAt: import("zod").ZodDate;
17381
+ isPartial: import("zod").ZodBoolean;
17382
+ isUpperBound: import("zod").ZodBoolean;
17383
+ }, import("zod/v4/core").$strip>>;
17384
+ ip: import("zod").ZodIPv4;
17385
+ slot: import("zod").ZodInt;
17386
+ port: import("zod").ZodInt;
17387
+ httpPort: import("zod").ZodInt;
17388
+ url: import("zod").ZodURL;
17389
+ public: import("zod").ZodOptional<import("zod").ZodObject<{
17390
+ auth: import("zod").ZodEnum<{
17391
+ basic: "basic";
17392
+ none: "none";
17393
+ token: "token";
17394
+ }>;
17395
+ }, import("zod/v4/core").$strip>>;
17396
+ createdAt: import("zod").ZodDate;
17397
+ lastActiveAt: import("zod").ZodDate;
17398
+ lastRequestAt: import("zod").ZodOptional<import("zod").ZodDate>;
17399
+ ramMib: import("zod").ZodOptional<import("zod").ZodInt>;
17400
+ rssMib: import("zod").ZodOptional<import("zod").ZodInt>;
17401
+ sleptAt: import("zod").ZodOptional<import("zod").ZodDate>;
17402
+ holdUntil: import("zod").ZodOptional<import("zod").ZodDate>;
17403
+ leases: import("zod").ZodOptional<import("zod").ZodObject<{
17404
+ leases: import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodObject<{
17405
+ name: import("zod").ZodString;
17406
+ owner: import("zod").ZodObject<{
17407
+ principal: import("zod").ZodString;
17408
+ display: import("zod").ZodString;
17409
+ label: import("zod").ZodString;
17410
+ }, import("zod/v4/core").$strip>;
17411
+ until: import("zod").ZodNullable<import("zod").ZodDate>;
17412
+ }, import("zod/v4/core").$strip>>>;
17413
+ otherCount: import("zod").ZodInt;
17414
+ }, import("zod/v4/core").$strip>>;
17415
+ error: import("zod").ZodOptional<import("zod").ZodString>;
17416
+ sessions: import("zod").ZodOptional<import("zod").ZodInt>;
17417
+ coldBootReason: import("zod").ZodOptional<import("zod").ZodString>;
17418
+ agentSilentSince: import("zod").ZodOptional<import("zod").ZodDate>;
17419
+ inner: import("zod").ZodOptional<import("zod").ZodObject<{
17420
+ up: import("zod").ZodBoolean;
17421
+ restarts: import("zod").ZodInt;
17422
+ lastError: import("zod").ZodOptional<import("zod").ZodString>;
17423
+ }, import("zod/v4/core").$strip>>;
17424
+ outdated: import("zod").ZodOptional<import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodEnum<{
17425
+ agent: "agent";
17426
+ firecracker: "firecracker";
17427
+ impd: "impd";
17428
+ ipv6: "ipv6";
17429
+ kernel: "kernel";
17430
+ }>>>>;
17431
+ cpu: import("zod").ZodOptional<import("zod").ZodObject<{
17432
+ limit: import("zod").ZodNullable<import("zod").ZodNumber>;
17433
+ weight: import("zod").ZodInt;
17434
+ }, import("zod/v4/core").$strip>>;
17435
+ resources: import("zod").ZodOptional<import("zod").ZodObject<{
17436
+ wakeCount: import("zod").ZodInt;
17437
+ awakeMs: import("zod").ZodInt;
17438
+ sample: import("zod").ZodOptional<import("zod").ZodObject<{
17439
+ measuredAt: import("zod").ZodDate;
17440
+ since: import("zod").ZodDate;
17441
+ cpuPercent: import("zod").ZodOptional<import("zod").ZodNumber>;
17442
+ cpuThrottledMs: import("zod").ZodInt;
17443
+ netRxBytes: import("zod").ZodInt;
17444
+ netTxBytes: import("zod").ZodInt;
17445
+ }, import("zod/v4/core").$strip>>;
17446
+ }, import("zod/v4/core").$strip>>;
17447
+ move: import("zod").ZodOptional<import("zod").ZodEnum<{
17448
+ moved: "moved";
17449
+ receiving: "receiving";
17450
+ sending: "sending";
17451
+ }>>;
17452
+ }, import("zod/v4/core").$strip>;
17453
+ detail: import("zod").ZodOptional<import("zod").ZodReadonly<import("zod").ZodObject<{
17454
+ durationMs: import("zod").ZodOptional<import("zod").ZodInt>;
17455
+ prepareMs: import("zod").ZodOptional<import("zod").ZodInt>;
17456
+ trigger: import("zod").ZodOptional<import("zod").ZodString>;
17457
+ coldBootReason: import("zod").ZodOptional<import("zod").ZodString>;
17458
+ steps: import("zod").ZodOptional<import("zod").ZodReadonly<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodInt>>>;
17459
+ released: import("zod").ZodOptional<import("zod").ZodInt>;
17460
+ memFileMib: import("zod").ZodOptional<import("zod").ZodInt>;
17461
+ }, import("zod/v4/core").$strip>>>;
17462
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17463
+ v: import("zod").ZodLiteral<1>;
17464
+ at: import("zod").ZodDate;
17465
+ seq: import("zod").ZodInt;
17466
+ logId: import("zod").ZodString;
17467
+ ev: import("zod").ZodLiteral<"ImpRemoved">;
17468
+ imp: import("zod").ZodObject<{
17469
+ id: import("zod").ZodString;
17470
+ name: import("zod").ZodString;
17471
+ image: import("zod").ZodString;
17472
+ state: import("zod").ZodEnum<{
17473
+ creating: "creating";
17474
+ error: "error";
17475
+ running: "running";
17476
+ sleeping: "sleeping";
17477
+ stopped: "stopped";
17478
+ }>;
17479
+ kind: import("zod").ZodOptional<import("zod").ZodEnum<{
17480
+ builder: "builder";
17481
+ user: "user";
17482
+ }>>;
17483
+ vcpus: import("zod").ZodInt;
17484
+ memoryMib: import("zod").ZodInt;
17485
+ maxMemoryMib: import("zod").ZodOptional<import("zod").ZodInt>;
17486
+ pluggedMib: import("zod").ZodOptional<import("zod").ZodInt>;
17487
+ backup: import("zod").ZodOptional<import("zod").ZodBoolean>;
17488
+ diskMib: import("zod").ZodInt;
17489
+ diskUsage: import("zod").ZodOptional<import("zod").ZodObject<{
17490
+ exclusiveBytes: import("zod").ZodInt;
17491
+ sharedBytes: import("zod").ZodInt;
17492
+ measuredAt: import("zod").ZodDate;
17493
+ isPartial: import("zod").ZodBoolean;
17494
+ isUpperBound: import("zod").ZodBoolean;
17495
+ }, import("zod/v4/core").$strip>>;
17496
+ ip: import("zod").ZodIPv4;
17497
+ slot: import("zod").ZodInt;
17498
+ port: import("zod").ZodInt;
17499
+ httpPort: import("zod").ZodInt;
17500
+ url: import("zod").ZodURL;
17501
+ public: import("zod").ZodOptional<import("zod").ZodObject<{
17502
+ auth: import("zod").ZodEnum<{
17503
+ basic: "basic";
17504
+ none: "none";
17505
+ token: "token";
17506
+ }>;
17507
+ }, import("zod/v4/core").$strip>>;
17508
+ createdAt: import("zod").ZodDate;
17509
+ lastActiveAt: import("zod").ZodDate;
17510
+ lastRequestAt: import("zod").ZodOptional<import("zod").ZodDate>;
17511
+ ramMib: import("zod").ZodOptional<import("zod").ZodInt>;
17512
+ rssMib: import("zod").ZodOptional<import("zod").ZodInt>;
17513
+ sleptAt: import("zod").ZodOptional<import("zod").ZodDate>;
17514
+ holdUntil: import("zod").ZodOptional<import("zod").ZodDate>;
17515
+ leases: import("zod").ZodOptional<import("zod").ZodObject<{
17516
+ leases: import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodObject<{
17517
+ name: import("zod").ZodString;
17518
+ owner: import("zod").ZodObject<{
17519
+ principal: import("zod").ZodString;
17520
+ display: import("zod").ZodString;
17521
+ label: import("zod").ZodString;
17522
+ }, import("zod/v4/core").$strip>;
17523
+ until: import("zod").ZodNullable<import("zod").ZodDate>;
17524
+ }, import("zod/v4/core").$strip>>>;
17525
+ otherCount: import("zod").ZodInt;
17526
+ }, import("zod/v4/core").$strip>>;
17527
+ error: import("zod").ZodOptional<import("zod").ZodString>;
17528
+ sessions: import("zod").ZodOptional<import("zod").ZodInt>;
17529
+ coldBootReason: import("zod").ZodOptional<import("zod").ZodString>;
17530
+ agentSilentSince: import("zod").ZodOptional<import("zod").ZodDate>;
17531
+ inner: import("zod").ZodOptional<import("zod").ZodObject<{
17532
+ up: import("zod").ZodBoolean;
17533
+ restarts: import("zod").ZodInt;
17534
+ lastError: import("zod").ZodOptional<import("zod").ZodString>;
17535
+ }, import("zod/v4/core").$strip>>;
17536
+ outdated: import("zod").ZodOptional<import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodEnum<{
17537
+ agent: "agent";
17538
+ firecracker: "firecracker";
17539
+ impd: "impd";
17540
+ ipv6: "ipv6";
17541
+ kernel: "kernel";
17542
+ }>>>>;
17543
+ cpu: import("zod").ZodOptional<import("zod").ZodObject<{
17544
+ limit: import("zod").ZodNullable<import("zod").ZodNumber>;
17545
+ weight: import("zod").ZodInt;
17546
+ }, import("zod/v4/core").$strip>>;
17547
+ resources: import("zod").ZodOptional<import("zod").ZodObject<{
17548
+ wakeCount: import("zod").ZodInt;
17549
+ awakeMs: import("zod").ZodInt;
17550
+ sample: import("zod").ZodOptional<import("zod").ZodObject<{
17551
+ measuredAt: import("zod").ZodDate;
17552
+ since: import("zod").ZodDate;
17553
+ cpuPercent: import("zod").ZodOptional<import("zod").ZodNumber>;
17554
+ cpuThrottledMs: import("zod").ZodInt;
17555
+ netRxBytes: import("zod").ZodInt;
17556
+ netTxBytes: import("zod").ZodInt;
17557
+ }, import("zod/v4/core").$strip>>;
17558
+ }, import("zod/v4/core").$strip>>;
17559
+ move: import("zod").ZodOptional<import("zod").ZodEnum<{
17560
+ moved: "moved";
17561
+ receiving: "receiving";
17562
+ sending: "sending";
17563
+ }>>;
17564
+ }, import("zod/v4/core").$strip>;
17565
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17566
+ v: import("zod").ZodLiteral<1>;
17567
+ at: import("zod").ZodDate;
17568
+ seq: import("zod").ZodInt;
17569
+ logId: import("zod").ZodString;
17570
+ ev: import("zod").ZodLiteral<"CheckpointAdded">;
17571
+ name: import("zod").ZodString;
17572
+ checkpoint: import("zod").ZodObject<{
17573
+ id: import("zod").ZodString;
17574
+ label: import("zod").ZodOptional<import("zod").ZodString>;
17575
+ createdAt: import("zod").ZodDate;
17576
+ sizeBytes: import("zod").ZodOptional<import("zod").ZodInt>;
17577
+ diskMib: import("zod").ZodInt;
17578
+ }, import("zod/v4/core").$strip>;
17579
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17580
+ v: import("zod").ZodLiteral<1>;
17581
+ at: import("zod").ZodDate;
17582
+ seq: import("zod").ZodInt;
17583
+ logId: import("zod").ZodString;
17584
+ ev: import("zod").ZodLiteral<"CheckpointRemoved">;
17585
+ name: import("zod").ZodString;
17586
+ checkpoint: import("zod").ZodObject<{
17587
+ id: import("zod").ZodString;
17588
+ label: import("zod").ZodOptional<import("zod").ZodString>;
17589
+ createdAt: import("zod").ZodDate;
17590
+ sizeBytes: import("zod").ZodOptional<import("zod").ZodInt>;
17591
+ diskMib: import("zod").ZodInt;
17592
+ }, import("zod/v4/core").$strip>;
17593
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17594
+ v: import("zod").ZodLiteral<1>;
17595
+ at: import("zod").ZodDate;
17596
+ seq: import("zod").ZodInt;
17597
+ logId: import("zod").ZodString;
17598
+ ev: import("zod").ZodLiteral<"GovernorDecision">;
17599
+ decision: import("zod").ZodEnum<{
17600
+ admitted: "admitted";
17601
+ refused: "refused";
17602
+ slept: "slept";
17603
+ }>;
17604
+ name: import("zod").ZodString;
17605
+ trigger: import("zod").ZodString;
17606
+ usedMib: import("zod").ZodInt;
17607
+ budgetMib: import("zod").ZodInt;
17608
+ reserveMib: import("zod").ZodOptional<import("zod").ZodInt>;
17609
+ neededMib: import("zod").ZodOptional<import("zod").ZodInt>;
17610
+ protectedCount: import("zod").ZodOptional<import("zod").ZodInt>;
17611
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17612
+ v: import("zod").ZodLiteral<1>;
17613
+ at: import("zod").ZodDate;
17614
+ seq: import("zod").ZodInt;
17615
+ logId: import("zod").ZodString;
17616
+ ev: import("zod").ZodLiteral<"AgentExec">;
17617
+ name: import("zod").ZodString;
17618
+ actor: import("zod").ZodEnum<{
17619
+ dashboard: "dashboard";
17620
+ oauth: "oauth";
17621
+ ssh: "ssh";
17622
+ tailnet: "tailnet";
17623
+ token: "token";
17624
+ }>;
17625
+ actorName: import("zod").ZodString;
17626
+ tty: import("zod").ZodBoolean;
17627
+ command: import("zod").ZodString;
17628
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17629
+ v: import("zod").ZodLiteral<1>;
17630
+ at: import("zod").ZodDate;
17631
+ seq: import("zod").ZodInt;
17632
+ logId: import("zod").ZodString;
17633
+ ev: import("zod").ZodLiteral<"Reset">;
17634
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17635
+ v: import("zod").ZodLiteral<1>;
17636
+ at: import("zod").ZodDate;
17637
+ seq: import("zod").ZodInt;
17638
+ logId: import("zod").ZodString;
17639
+ ev: import("zod").ZodLiteral<"Position">;
17640
+ }, import("zod/v4/core").$strip>], "ev">>;
17641
+ after: import("zod").ZodInt;
17642
+ logId: import("zod").ZodString;
17643
+ hasMore: import("zod").ZodBoolean;
17644
+ }, import("zod/v4/core").$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
17645
+ NOT_FOUND: {
17646
+ readonly message: "Not found";
17647
+ readonly data: import("zod").ZodObject<{
17648
+ kind: import("zod").ZodEnum<{
17649
+ backup: "backup";
17650
+ checkpoint: "checkpoint";
17651
+ "database-copy": "database-copy";
17652
+ grant: "grant";
17653
+ image: "image";
17654
+ imp: "imp";
17655
+ network: "network";
17656
+ "oauth-approval": "oauth-approval";
17657
+ "oauth-client": "oauth-client";
17658
+ "oauth-grant": "oauth-grant";
17659
+ secret: "secret";
17660
+ service: "service";
17661
+ session: "session";
17662
+ "ssh-key": "ssh-key";
17663
+ token: "token";
17664
+ }>;
17665
+ name: import("zod").ZodString;
17666
+ reason: import("zod").ZodOptional<import("zod").ZodEnum<{
17667
+ binding_changed: "binding_changed";
17668
+ id_changed: "id_changed";
17669
+ }>>;
17670
+ }, import("zod/v4/core").$strip>;
17671
+ };
17672
+ CONFLICT: {
17673
+ readonly message: "Already exists";
17674
+ readonly data: import("zod").ZodObject<{
17675
+ kind: import("zod").ZodEnum<{
17676
+ backup: "backup";
17677
+ checkpoint: "checkpoint";
17678
+ "database-copy": "database-copy";
17679
+ grant: "grant";
17680
+ image: "image";
17681
+ imp: "imp";
17682
+ network: "network";
17683
+ "oauth-approval": "oauth-approval";
17684
+ "oauth-client": "oauth-client";
17685
+ "oauth-grant": "oauth-grant";
17686
+ secret: "secret";
17687
+ service: "service";
17688
+ session: "session";
17689
+ "ssh-key": "ssh-key";
17690
+ token: "token";
17691
+ }>;
17692
+ name: import("zod").ZodString;
17693
+ reason: import("zod").ZodOptional<import("zod").ZodEnum<{
17694
+ binding_changed: "binding_changed";
17695
+ id_changed: "id_changed";
17696
+ }>>;
17697
+ }, import("zod/v4/core").$strip>;
17698
+ };
17699
+ FORBIDDEN: {
17700
+ readonly message: "Not allowed";
17701
+ readonly data: import("zod").ZodOptional<import("zod").ZodObject<{
17702
+ reason: import("zod").ZodEnum<{
17703
+ imp_out_of_scope: "imp_out_of_scope";
17704
+ not_grantable: "not_grantable";
17705
+ scope: "scope";
17706
+ }>;
17707
+ }, import("zod/v4/core").$strip>>;
17708
+ };
17709
+ PRECONDITION_FAILED: {
17710
+ readonly message: "Not possible on this host";
17711
+ readonly data: import("zod").ZodOptional<import("zod").ZodObject<{
17712
+ reason: import("zod").ZodEnum<{
17713
+ broker_not_ready: "broker_not_ready";
17714
+ impd_outdated: "impd_outdated";
17715
+ }>;
17716
+ detail: import("zod").ZodString;
17717
+ }, import("zod/v4/core").$strip>>;
17718
+ };
17719
+ RAM_BUDGET_EXCEEDED: {
17720
+ readonly message: "Not enough RAM budget, even after sleeping idle imps";
17721
+ readonly status: 503;
17722
+ readonly data: import("zod").ZodObject<{
17723
+ budgetMib: import("zod").ZodInt;
17724
+ usedMib: import("zod").ZodInt;
17725
+ requestedMib: import("zod").ZodInt;
17726
+ neededMib: import("zod").ZodOptional<import("zod").ZodInt>;
17727
+ protected: import("zod").ZodOptional<import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodObject<{
17728
+ name: import("zod").ZodString;
17729
+ ramMib: import("zod").ZodInt;
17730
+ leased: import("zod").ZodBoolean;
17731
+ busy: import("zod").ZodBoolean;
17732
+ }, import("zod/v4/core").$strip>>>>;
17733
+ protectedHidden: import("zod").ZodOptional<import("zod").ZodInt>;
17734
+ }, import("zod/v4/core").$strip>;
17735
+ };
17736
+ SERVICE_UNAVAILABLE: {
17737
+ readonly message: "impd is stopping";
17738
+ };
17739
+ INVALID_STATE: {
17740
+ readonly message: "The imp is not in a state that allows this";
17741
+ readonly status: 409;
17742
+ readonly data: import("zod").ZodObject<{
17743
+ state: import("zod").ZodEnum<{
17744
+ creating: "creating";
17745
+ error: "error";
17746
+ running: "running";
17747
+ sleeping: "sleeping";
17748
+ stopped: "stopped";
17749
+ }>;
17750
+ allowed: import("zod").ZodArray<import("zod").ZodEnum<{
17751
+ creating: "creating";
17752
+ error: "error";
17753
+ running: "running";
17754
+ sleeping: "sleeping";
17755
+ stopped: "stopped";
17756
+ }>>;
17757
+ coldBoots: import("zod").ZodOptional<import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodReadonly<import("zod").ZodObject<{
17758
+ bootId: import("zod").ZodString;
17759
+ cause: import("zod").ZodEnum<{
17760
+ recovery: "recovery";
17761
+ restore: "restore";
17762
+ start: "start";
17763
+ unknown: "unknown";
17764
+ wake_fallback: "wake_fallback";
17765
+ watchdog: "watchdog";
17766
+ }>;
17767
+ at: import("zod").ZodISODateTime;
17768
+ }, import("zod/v4/core").$strip>>>>>;
17769
+ }, import("zod/v4/core").$strip>;
17770
+ };
17771
+ INVALID_RESUME: {
17772
+ readonly message: "The resume offset is past the end of the output";
17773
+ readonly status: 409;
17774
+ readonly data: import("zod").ZodReadonly<import("zod").ZodObject<{
17775
+ end: import("zod").ZodInt;
17776
+ bufferStart: import("zod").ZodInt;
17777
+ }, import("zod/v4/core").$strip>>;
17778
+ };
17779
+ DISK_FULL: {
17780
+ readonly message: "Not enough free disk on the host";
17781
+ readonly status: 507;
17782
+ readonly data: import("zod").ZodObject<{
17783
+ availableBytes: import("zod").ZodInt;
17784
+ reserveBytes: import("zod").ZodInt;
17785
+ requestedBytes: import("zod").ZodInt;
17786
+ }, import("zod/v4/core").$strip>;
17787
+ };
17788
+ LEASED: {
17789
+ readonly message: "The imp is leased";
17790
+ readonly status: 409;
17791
+ readonly data: import("zod").ZodObject<{
17792
+ leases: import("zod").ZodReadonly<import("zod").ZodArray<import("zod").ZodObject<{
17793
+ name: import("zod").ZodString;
17794
+ owner: import("zod").ZodObject<{
17795
+ principal: import("zod").ZodString;
17796
+ display: import("zod").ZodString;
17797
+ label: import("zod").ZodString;
17798
+ }, import("zod/v4/core").$strip>;
17799
+ until: import("zod").ZodNullable<import("zod").ZodDate>;
17800
+ }, import("zod/v4/core").$strip>>>;
17801
+ otherCount: import("zod").ZodInt;
17802
+ }, import("zod/v4/core").$strip>;
17803
+ };
17804
+ LEASE_NOT_HELD: {
17805
+ readonly message: "The caller holds no such lease";
17806
+ readonly status: 409;
17807
+ };
17808
+ AGENT_OUTDATED: {
17809
+ readonly message: "The imp's agent is too old for this";
17810
+ readonly status: 409;
17811
+ };
17812
+ MOVING: {
17813
+ readonly message: "The imp is moving between hosts";
17814
+ readonly status: 409;
17815
+ readonly data: import("zod").ZodObject<{
17816
+ retryAfterS: import("zod").ZodInt;
17817
+ }, import("zod/v4/core").$strip>;
17818
+ };
17819
+ }>, ProcedureMeta & Record<never, never>>;
17137
17820
  };
17138
17821
  system: {
17139
17822
  info: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, import("zod").ZodObject<{
@@ -17258,6 +17941,7 @@ declare const impContract: {
17258
17941
  imagePins: import("zod").ZodOptional<import("zod").ZodBoolean>;
17259
17942
  buildContextUpload: import("zod").ZodOptional<import("zod").ZodBoolean>;
17260
17943
  destroyIdCheck: import("zod").ZodOptional<import("zod").ZodBoolean>;
17944
+ eventCursor: import("zod").ZodOptional<import("zod").ZodBoolean>;
17261
17945
  }, import("zod/v4/core").$strip>>;
17262
17946
  host: import("zod").ZodOptional<import("zod").ZodObject<{
17263
17947
  kernel: import("zod").ZodString;
@@ -17478,6 +18162,7 @@ declare const impContract: {
17478
18162
  imagePins: import("zod").ZodOptional<import("zod").ZodBoolean>;
17479
18163
  buildContextUpload: import("zod").ZodOptional<import("zod").ZodBoolean>;
17480
18164
  destroyIdCheck: import("zod").ZodOptional<import("zod").ZodBoolean>;
18165
+ eventCursor: import("zod").ZodOptional<import("zod").ZodBoolean>;
17481
18166
  }, import("zod/v4/core").$strip>;
17482
18167
  }, import("zod/v4/core").$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
17483
18168
  NOT_FOUND: {
@@ -21812,6 +22497,7 @@ declare const SystemInfoSchema: z.ZodObject<{
21812
22497
  imagePins: z.ZodOptional<z.ZodBoolean>;
21813
22498
  buildContextUpload: z.ZodOptional<z.ZodBoolean>;
21814
22499
  destroyIdCheck: z.ZodOptional<z.ZodBoolean>;
22500
+ eventCursor: z.ZodOptional<z.ZodBoolean>;
21815
22501
  }, z.core.$strip>>;
21816
22502
  host: z.ZodOptional<z.ZodObject<{
21817
22503
  kernel: z.ZodString;
@@ -21858,6 +22544,7 @@ declare const SystemFeaturesInfoSchema: z.ZodObject<{
21858
22544
  imagePins: z.ZodOptional<z.ZodBoolean>;
21859
22545
  buildContextUpload: z.ZodOptional<z.ZodBoolean>;
21860
22546
  destroyIdCheck: z.ZodOptional<z.ZodBoolean>;
22547
+ eventCursor: z.ZodOptional<z.ZodBoolean>;
21861
22548
  }, z.core.$strip>;
21862
22549
  }, z.core.$strip>;
21863
22550
  type SystemFeaturesInfo = z.infer<typeof SystemFeaturesInfoSchema>;
@@ -22088,7 +22775,7 @@ interface CallOptions {
22088
22775
  }
22089
22776
  interface EventSource {
22090
22777
  readonly events: {
22091
- readonly stream: (input?: undefined, options?: CallOptions) => Promise<AsyncIterable<ImpEvent>>;
22778
+ readonly stream: (input?: EventCursor, options?: CallOptions) => Promise<AsyncIterable<ImpEvent>>;
22092
22779
  };
22093
22780
  }
22094
22781
  interface WatchReconnect {
@@ -22099,7 +22786,7 @@ interface WatchEventsOptions {
22099
22786
  readonly onEvent: (event: ImpEvent) => Promise<void> | void;
22100
22787
  readonly name?: string;
22101
22788
  readonly signal?: AbortSignal;
22102
- readonly onOpen?: (attempt: number) => Promise<void> | void;
22789
+ readonly onOpen?: (attempt: number, cursor: Readonly<EventCursor>) => Promise<void> | void;
22103
22790
  readonly reconnect?: WatchReconnect;
22104
22791
  }
22105
22792
  export declare function watchEvents(client: EventSource, options: Readonly<WatchEventsOptions>): Promise<void>;
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import * as z from "zod";
4
4
  import { P, match } from "ts-pattern";
5
5
  import pRetry, { AbortError } from "p-retry";
6
6
  // src/check-server.ts
7
- const CLIENT_VERSION = "6.10.0";
7
+ const CLIENT_VERSION = "6.11.0";
8
8
  async function checkServer(rpc, options = {}) {
9
9
  const signal = options.signal;
10
10
  const callOptions = signal === void 0 ? {} : { signal };
@@ -861,7 +861,8 @@ const FEATURE_GAPS = {
861
861
  guestScratch: "does not name the guest scratch folder",
862
862
  imagePins: "has no image pins",
863
863
  buildContextUpload: "has no build context upload",
864
- destroyIdCheck: "has no id check on destroy"
864
+ destroyIdCheck: "has no id check on destroy",
865
+ eventCursor: "has no event cursor"
865
866
  };
866
867
  var MissingFeatureError = class extends Error {
867
868
  name = "MissingFeatureError";
@@ -1785,18 +1786,30 @@ function parseServerMessage(text) {
1785
1786
  return null;
1786
1787
  }
1787
1788
  }
1789
+ // src/events/pick-next-cursor.ts
1790
+ function pickNextCursor(cursor, event) {
1791
+ return match(event).with({ ev: "Reset" }, () => ({})).with({
1792
+ ev: "ImpAdded",
1793
+ reason: "snapshot"
1794
+ }, () => cursor).with({ ev: P.union("ImpAdded", "ImpChanged", "ImpRemoved", "CheckpointAdded", "CheckpointRemoved", "GovernorDecision", "AgentExec", "Position") }, (logged) => ({
1795
+ after: logged.seq,
1796
+ logId: logged.logId
1797
+ })).otherwise(() => cursor);
1798
+ }
1788
1799
  // src/events/watch-events.ts
1789
1800
  async function watchEvents(client, options) {
1790
1801
  const signal = options.signal;
1791
1802
  const reconnect = options.reconnect;
1792
1803
  const callOptions = signal === void 0 ? {} : { signal };
1804
+ const position = { cursor: {} };
1793
1805
  const readStream = async (attempt) => {
1794
- const events = (await client.events.stream(void 0, callOptions).catch((error) => {
1806
+ const input = position.cursor.after === void 0 ? void 0 : position.cursor;
1807
+ const events = (await client.events.stream(input, callOptions).catch((error) => {
1795
1808
  throw new StreamEndError(error);
1796
1809
  }))[Symbol.asyncIterator]();
1797
1810
  const reading = { done: false };
1798
1811
  try {
1799
- await runCallback(() => options.onOpen?.(attempt));
1812
+ await runCallback(() => options.onOpen?.(attempt, input ?? {}));
1800
1813
  for (;;) {
1801
1814
  const next = await events.next().catch((error) => {
1802
1815
  throw new StreamEndError(error);
@@ -1805,7 +1818,8 @@ async function watchEvents(client, options) {
1805
1818
  reading.done = true;
1806
1819
  throw new StreamEndError(null);
1807
1820
  }
1808
- if (options.name === void 0 || readEventImpName(next.value) === options.name) await runCallback(() => options.onEvent(next.value));
1821
+ if (isDeliveredEvent(next.value, options.name)) await runCallback(() => options.onEvent(next.value));
1822
+ position.cursor = pickNextCursor(position.cursor, next.value);
1809
1823
  }
1810
1824
  } finally {
1811
1825
  if (!reading.done) await disposeEvents(events);
@@ -1845,8 +1859,8 @@ async function runCallback(run) {
1845
1859
  throw new AbortError(failure);
1846
1860
  }
1847
1861
  }
1848
- function readEventImpName(event) {
1849
- return match(event).with({ ev: P.union("ImpAdded", "ImpChanged", "ImpRemoved") }, (changed) => changed.imp.name).with({ ev: P.union("CheckpointAdded", "CheckpointRemoved", "GovernorDecision", "AgentExec") }, (named) => named.name).exhaustive();
1862
+ function isDeliveredEvent(event, name) {
1863
+ return match(event).with({ ev: "Position" }, () => false).with({ ev: "Reset" }, () => true).with({ ev: P.union("ImpAdded", "ImpChanged", "ImpRemoved") }, (changed) => name === void 0 || changed.imp.name === name).with({ ev: P.union("CheckpointAdded", "CheckpointRemoved", "GovernorDecision", "AgentExec") }, (named) => name === void 0 || named.name === name).otherwise(() => false);
1850
1864
  }
1851
1865
  async function disposeEvents(events) {
1852
1866
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impz/client",
3
- "version": "6.10.0",
3
+ "version": "6.11.0",
4
4
  "description": "Typed client for impd, the imp host daemon: imps, checkpoints, images and exec",
5
5
  "license": "MIT",
6
6
  "repository": {