@zgeoff/imp-client 0.17.0 → 0.19.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/dist/index.d.ts CHANGED
@@ -363,6 +363,20 @@ declare const ImpEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
363
363
  reserveMib: z.ZodOptional<z.ZodInt>;
364
364
  neededMib: z.ZodOptional<z.ZodInt>;
365
365
  protectedCount: z.ZodOptional<z.ZodInt>;
366
+ }, z.core.$strip>, z.ZodObject<{
367
+ v: z.ZodLiteral<1>;
368
+ at: z.ZodDate;
369
+ ev: z.ZodLiteral<"AgentExec">;
370
+ name: z.ZodString;
371
+ actor: z.ZodEnum<{
372
+ dashboard: "dashboard";
373
+ ssh: "ssh";
374
+ tailnet: "tailnet";
375
+ token: "token";
376
+ }>;
377
+ actorName: z.ZodString;
378
+ tty: z.ZodBoolean;
379
+ command: z.ZodString;
366
380
  }, z.core.$strip>], "ev">;
367
381
  type ImpEvent = z.infer<typeof ImpEventSchema>;
368
382
  //#endregion
@@ -4600,9 +4614,208 @@ declare const impContract: {
4600
4614
  xfs: "xfs";
4601
4615
  zfs: "zfs";
4602
4616
  }>>;
4617
+ target: z.ZodOptional<z.ZodObject<{
4618
+ firecrackerVersion: z.ZodString;
4619
+ snapshotVersion: z.ZodString;
4620
+ hostKernel: z.ZodString;
4621
+ cpuModel: z.ZodString;
4622
+ cpuFlags: z.ZodString;
4623
+ dataDir: z.ZodString;
4624
+ storage: z.ZodEnum<{
4625
+ xfs: "xfs";
4626
+ zfs: "zfs";
4627
+ }>;
4628
+ subnet: z.ZodString;
4629
+ slotCount: z.ZodInt;
4630
+ brokerPort: z.ZodInt;
4631
+ dns: z.ZodReadonly<z.ZodArray<z.ZodString>>;
4632
+ }, z.core.$strip>>;
4603
4633
  }, z.core.$strip>, z.ZodObject<{
4604
4634
  bytes: z.ZodInt;
4605
4635
  checkpoints: z.ZodInt;
4636
+ warm: z.ZodNullable<z.ZodObject<{
4637
+ slot: z.ZodInt;
4638
+ egressMode: z.ZodString;
4639
+ snapshot: z.ZodObject<{
4640
+ firecrackerVersion: z.ZodString;
4641
+ snapshotVersion: z.ZodString;
4642
+ hostKernel: z.ZodString;
4643
+ cpuModel: z.ZodNullable<z.ZodString>;
4644
+ cpuFlags: z.ZodNullable<z.ZodString>;
4645
+ ipv6Prefix: z.ZodNullable<z.ZodString>;
4646
+ }, z.core.$strip>;
4647
+ host: z.ZodObject<{
4648
+ dataDir: z.ZodString;
4649
+ storage: z.ZodEnum<{
4650
+ xfs: "xfs";
4651
+ zfs: "zfs";
4652
+ }>;
4653
+ subnet: z.ZodString;
4654
+ brokerPort: z.ZodInt;
4655
+ dns: z.ZodReadonly<z.ZodArray<z.ZodString>>;
4656
+ }, z.core.$strip>;
4657
+ }, z.core.$strip>>;
4658
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
4659
+ NOT_FOUND: {
4660
+ readonly message: "Not found";
4661
+ readonly data: z.ZodObject<{
4662
+ kind: z.ZodEnum<{
4663
+ backup: "backup";
4664
+ checkpoint: "checkpoint";
4665
+ grant: "grant";
4666
+ image: "image";
4667
+ imp: "imp";
4668
+ network: "network";
4669
+ secret: "secret";
4670
+ service: "service";
4671
+ session: "session";
4672
+ "ssh-key": "ssh-key";
4673
+ token: "token";
4674
+ }>;
4675
+ name: z.ZodString;
4676
+ }, z.core.$strip>;
4677
+ };
4678
+ CONFLICT: {
4679
+ readonly message: "Already exists";
4680
+ readonly data: z.ZodObject<{
4681
+ kind: z.ZodEnum<{
4682
+ backup: "backup";
4683
+ checkpoint: "checkpoint";
4684
+ grant: "grant";
4685
+ image: "image";
4686
+ imp: "imp";
4687
+ network: "network";
4688
+ secret: "secret";
4689
+ service: "service";
4690
+ session: "session";
4691
+ "ssh-key": "ssh-key";
4692
+ token: "token";
4693
+ }>;
4694
+ name: z.ZodString;
4695
+ }, z.core.$strip>;
4696
+ };
4697
+ FORBIDDEN: {
4698
+ readonly message: "Not allowed";
4699
+ };
4700
+ PRECONDITION_FAILED: {
4701
+ readonly message: "Not possible on this host";
4702
+ };
4703
+ RAM_BUDGET_EXCEEDED: {
4704
+ readonly message: "Not enough RAM budget, even after sleeping idle imps";
4705
+ readonly status: 503;
4706
+ readonly data: z.ZodObject<{
4707
+ budgetMib: z.ZodInt;
4708
+ usedMib: z.ZodInt;
4709
+ requestedMib: z.ZodInt;
4710
+ neededMib: z.ZodOptional<z.ZodInt>;
4711
+ protected: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
4712
+ name: z.ZodString;
4713
+ ramMib: z.ZodInt;
4714
+ leased: z.ZodBoolean;
4715
+ busy: z.ZodBoolean;
4716
+ }, z.core.$strip>>>>;
4717
+ protectedHidden: z.ZodOptional<z.ZodInt>;
4718
+ }, z.core.$strip>;
4719
+ };
4720
+ SERVICE_UNAVAILABLE: {
4721
+ readonly message: "impd is stopping";
4722
+ };
4723
+ INVALID_STATE: {
4724
+ readonly message: "The imp is not in a state that allows this";
4725
+ readonly status: 409;
4726
+ readonly data: z.ZodObject<{
4727
+ state: z.ZodEnum<{
4728
+ creating: "creating";
4729
+ error: "error";
4730
+ running: "running";
4731
+ sleeping: "sleeping";
4732
+ stopped: "stopped";
4733
+ }>;
4734
+ allowed: z.ZodArray<z.ZodEnum<{
4735
+ creating: "creating";
4736
+ error: "error";
4737
+ running: "running";
4738
+ sleeping: "sleeping";
4739
+ stopped: "stopped";
4740
+ }>>;
4741
+ coldBoots: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
4742
+ bootId: z.ZodString;
4743
+ cause: z.ZodEnum<{
4744
+ recovery: "recovery";
4745
+ restore: "restore";
4746
+ start: "start";
4747
+ unknown: "unknown";
4748
+ wake_fallback: "wake_fallback";
4749
+ watchdog: "watchdog";
4750
+ }>;
4751
+ at: z.ZodISODateTime;
4752
+ }, z.core.$strip>>>>>;
4753
+ }, z.core.$strip>;
4754
+ };
4755
+ INVALID_RESUME: {
4756
+ readonly message: "The resume offset is past the end of the output";
4757
+ readonly status: 409;
4758
+ readonly data: z.ZodReadonly<z.ZodObject<{
4759
+ end: z.ZodInt;
4760
+ bufferStart: z.ZodInt;
4761
+ }, z.core.$strip>>;
4762
+ };
4763
+ DISK_FULL: {
4764
+ readonly message: "Not enough free disk on the host";
4765
+ readonly status: 507;
4766
+ readonly data: z.ZodObject<{
4767
+ availableBytes: z.ZodInt;
4768
+ reserveBytes: z.ZodInt;
4769
+ requestedBytes: z.ZodInt;
4770
+ }, z.core.$strip>;
4771
+ };
4772
+ LEASED: {
4773
+ readonly message: "The imp is leased";
4774
+ readonly status: 409;
4775
+ readonly data: z.ZodObject<{
4776
+ leases: z.ZodReadonly<z.ZodArray<z.ZodObject<{
4777
+ name: z.ZodString;
4778
+ owner: z.ZodObject<{
4779
+ principal: z.ZodString;
4780
+ display: z.ZodString;
4781
+ label: z.ZodString;
4782
+ }, z.core.$strip>;
4783
+ until: z.ZodNullable<z.ZodDate>;
4784
+ }, z.core.$strip>>>;
4785
+ otherCount: z.ZodInt;
4786
+ }, z.core.$strip>;
4787
+ };
4788
+ LEASE_NOT_HELD: {
4789
+ readonly message: "The caller holds no such lease";
4790
+ readonly status: 409;
4791
+ };
4792
+ AGENT_OUTDATED: {
4793
+ readonly message: "The imp's agent is too old for this";
4794
+ readonly status: 409;
4795
+ };
4796
+ MOVING: {
4797
+ readonly message: "The imp is moving between hosts";
4798
+ readonly status: 409;
4799
+ readonly data: z.ZodObject<{
4800
+ retryAfterS: z.ZodInt;
4801
+ }, z.core.$strip>;
4802
+ };
4803
+ }>, Record<never, never>>;
4804
+ facts: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
4805
+ firecrackerVersion: z.ZodString;
4806
+ snapshotVersion: z.ZodString;
4807
+ hostKernel: z.ZodString;
4808
+ cpuModel: z.ZodString;
4809
+ cpuFlags: z.ZodString;
4810
+ dataDir: z.ZodString;
4811
+ storage: z.ZodEnum<{
4812
+ xfs: "xfs";
4813
+ zfs: "zfs";
4814
+ }>;
4815
+ subnet: z.ZodString;
4816
+ slotCount: z.ZodInt;
4817
+ brokerPort: z.ZodInt;
4818
+ dns: z.ZodReadonly<z.ZodArray<z.ZodString>>;
4606
4819
  }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
4607
4820
  NOT_FOUND: {
4608
4821
  readonly message: "Not found";
@@ -4752,6 +4965,28 @@ declare const impContract: {
4752
4965
  receive: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
4753
4966
  name: z.ZodString;
4754
4967
  bytes: z.ZodInt;
4968
+ warm: z.ZodOptional<z.ZodObject<{
4969
+ slot: z.ZodInt;
4970
+ egressMode: z.ZodString;
4971
+ snapshot: z.ZodObject<{
4972
+ firecrackerVersion: z.ZodString;
4973
+ snapshotVersion: z.ZodString;
4974
+ hostKernel: z.ZodString;
4975
+ cpuModel: z.ZodNullable<z.ZodString>;
4976
+ cpuFlags: z.ZodNullable<z.ZodString>;
4977
+ ipv6Prefix: z.ZodNullable<z.ZodString>;
4978
+ }, z.core.$strip>;
4979
+ host: z.ZodObject<{
4980
+ dataDir: z.ZodString;
4981
+ storage: z.ZodEnum<{
4982
+ xfs: "xfs";
4983
+ zfs: "zfs";
4984
+ }>;
4985
+ subnet: z.ZodString;
4986
+ brokerPort: z.ZodInt;
4987
+ dns: z.ZodReadonly<z.ZodArray<z.ZodString>>;
4988
+ }, z.core.$strip>;
4989
+ }, z.core.$strip>>;
4755
4990
  }, z.core.$strip>, z.ZodObject<{
4756
4991
  ticket: z.ZodString;
4757
4992
  expiresAt: z.ZodDate;
@@ -11443,6 +11678,15 @@ declare const impContract: {
11443
11678
  reserveMib?: number | undefined;
11444
11679
  neededMib?: number | undefined;
11445
11680
  protectedCount?: number | undefined;
11681
+ } | {
11682
+ v: 1;
11683
+ at: Date;
11684
+ ev: "AgentExec";
11685
+ name: string;
11686
+ actor: "dashboard" | "ssh" | "tailnet" | "token";
11687
+ actorName: string;
11688
+ tty: boolean;
11689
+ command: string;
11446
11690
  }, unknown, void>, import("@orpc/client").AsyncIteratorClass<{
11447
11691
  v: 1;
11448
11692
  at: Date;
@@ -11692,6 +11936,15 @@ declare const impContract: {
11692
11936
  reserveMib?: number | undefined;
11693
11937
  neededMib?: number | undefined;
11694
11938
  protectedCount?: number | undefined;
11939
+ } | {
11940
+ v: 1;
11941
+ at: Date;
11942
+ ev: "AgentExec";
11943
+ name: string;
11944
+ actor: "dashboard" | "ssh" | "tailnet" | "token";
11945
+ actorName: string;
11946
+ tty: boolean;
11947
+ command: string;
11695
11948
  }, unknown, void>>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
11696
11949
  NOT_FOUND: {
11697
11950
  readonly message: "Not found";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { RPCLink } from "@orpc/client/fetch";
3
3
  import * as z from "zod";
4
4
  //#endregion
5
5
  //#region src/check-server.ts
6
- const CLIENT_VERSION = "0.17.0";
6
+ const CLIENT_VERSION = "0.19.0";
7
7
  async function checkServer(rpc) {
8
8
  const info = await rpc.system.info();
9
9
  return {
@@ -74,9 +74,42 @@ const MoveStateSchema = z.enum([
74
74
  "receiving"
75
75
  ]);
76
76
  const PeerUrlSchema = z.url({ protocol: /^https?$/ });
77
+ const WarmHostSchema = z.object({
78
+ firecrackerVersion: z.string(),
79
+ snapshotVersion: z.string(),
80
+ hostKernel: z.string(),
81
+ cpuModel: z.string(),
82
+ cpuFlags: z.string(),
83
+ dataDir: z.string(),
84
+ storage: z.enum(["xfs", "zfs"]),
85
+ subnet: z.string(),
86
+ slotCount: z.int().positive(),
87
+ brokerPort: z.int().positive(),
88
+ dns: z.array(z.string()).readonly()
89
+ });
90
+ const WarmMoveSchema = z.object({
91
+ slot: z.int().nonnegative(),
92
+ egressMode: z.string(),
93
+ snapshot: z.object({
94
+ firecrackerVersion: z.string(),
95
+ snapshotVersion: z.string(),
96
+ hostKernel: z.string(),
97
+ cpuModel: z.string().nullable(),
98
+ cpuFlags: z.string().nullable(),
99
+ ipv6Prefix: z.string().nullable()
100
+ }),
101
+ host: WarmHostSchema.pick({
102
+ dataDir: true,
103
+ storage: true,
104
+ subnet: true,
105
+ brokerPort: true,
106
+ dns: true
107
+ })
108
+ });
77
109
  z.object({
78
110
  bytes: z.int().nonnegative(),
79
- checkpoints: z.int().nonnegative()
111
+ checkpoints: z.int().nonnegative(),
112
+ warm: WarmMoveSchema.nullable()
80
113
  });
81
114
  z.object({
82
115
  ticket: z.string(),
@@ -289,6 +322,7 @@ const ExecStartMessageSchema = z.object({
289
322
  rows: DimensionSchema.optional(),
290
323
  session: SessionNameSchema.optional(),
291
324
  tool: z.enum(["tar"]).optional(),
325
+ outer: z.boolean().optional(),
292
326
  killGraceMs: z.int().min(1).max(6e4).optional(),
293
327
  resumeFrom: ResumeFromSchema.optional()
294
328
  }).refine((start) => start.session === void 0 || start.tty, {
@@ -303,6 +337,9 @@ const ExecStartMessageSchema = z.object({
303
337
  }).refine((start) => start.tool === void 0 || !start.tty && start.session === void 0 && start.env === void 0 && start.cwd === void 0, {
304
338
  message: "a tool takes no tty, session, env or cwd",
305
339
  path: ["tool"]
340
+ }).refine((start) => start.outer !== true || start.tool === void 0 && start.session === void 0, {
341
+ message: "an outer exec takes no tool or session",
342
+ path: ["outer"]
306
343
  });
307
344
  const ExecAttachMessageSchema = z.object({
308
345
  type: z.literal("attach"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgeoff/imp-client",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "Typed client for impd, the imp host daemon: imps, checkpoints, images and exec",
5
5
  "license": "MIT",
6
6
  "repository": {