@zgeoff/imp-client 0.1.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -84,8 +84,8 @@ try {
84
84
  }
85
85
  ```
86
86
 
87
- `imp.openConsole` opens the root user's login shell with a tty, as `imp console` does. With
88
- [xterm.js](https://xtermjs.org):
87
+ `imp.openConsole` opens a login shell with a tty, the shell of the image's user, as `imp console`
88
+ does. With [xterm.js](https://xtermjs.org):
89
89
 
90
90
  ```ts
91
91
  const shell = await imp.openConsole('dev', { cols: term.cols, rows: term.rows });
package/dist/index.d.ts CHANGED
@@ -3089,6 +3089,14 @@ declare const impContract: {
3089
3089
  awakeCount: z.ZodInt;
3090
3090
  impCount: z.ZodInt;
3091
3091
  sessionCount: z.ZodInt;
3092
+ bootStatus: z.ZodObject<{
3093
+ coldBoots: z.ZodInt;
3094
+ outdated: z.ZodObject<{
3095
+ firecracker: z.ZodInt;
3096
+ kernel: z.ZodInt;
3097
+ agent: z.ZodInt;
3098
+ }, z.core.$strip>;
3099
+ }, z.core.$strip>;
3092
3100
  firecrackerVersion: z.ZodNullable<z.ZodString>;
3093
3101
  guestKernel: z.ZodObject<{
3094
3102
  version: z.ZodNullable<z.ZodString>;
@@ -3234,6 +3242,9 @@ declare const ImpSchema: z.ZodObject<{
3234
3242
  }, z.core.$strip>;
3235
3243
  type Imp = z.infer<typeof ImpSchema>;
3236
3244
  //#endregion
3245
+ //#region ../api/src/login-shell.d.ts
3246
+ export declare const CONSOLE_SHELL: string;
3247
+ //#endregion
3237
3248
  //#region ../api/src/session-schema.d.ts
3238
3249
  declare const SessionSchema: z.ZodObject<{
3239
3250
  name: z.ZodString;
@@ -3264,6 +3275,14 @@ declare const SystemInfoSchema: z.ZodObject<{
3264
3275
  awakeCount: z.ZodInt;
3265
3276
  impCount: z.ZodInt;
3266
3277
  sessionCount: z.ZodInt;
3278
+ bootStatus: z.ZodObject<{
3279
+ coldBoots: z.ZodInt;
3280
+ outdated: z.ZodObject<{
3281
+ firecracker: z.ZodInt;
3282
+ kernel: z.ZodInt;
3283
+ agent: z.ZodInt;
3284
+ }, z.core.$strip>;
3285
+ }, z.core.$strip>;
3267
3286
  firecrackerVersion: z.ZodNullable<z.ZodString>;
3268
3287
  guestKernel: z.ZodObject<{
3269
3288
  version: z.ZodNullable<z.ZodString>;
@@ -3396,7 +3415,6 @@ interface ExecHandle {
3396
3415
  readonly sendSignal: (signal: string) => void;
3397
3416
  readonly close: () => void;
3398
3417
  }
3399
- export declare const CONSOLE_SHELL: string;
3400
3418
  type AttachOptions = Pick<ExecOptions, 'cols' | 'rows' | 'signal' | 'maxUnreadBytes'>;
3401
3419
  type ConsoleOptions = Omit<ExecOptions, 'tty'>;
3402
3420
  interface RunResult extends ExecExit {
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.1.1";
6
+ const CLIENT_VERSION = "0.2.2";
7
7
  async function checkServer(rpc) {
8
8
  const info = await rpc.system.info();
9
9
  return {
@@ -136,6 +136,18 @@ function isExecChannel(value) {
136
136
  return value === EXEC_CHANNELS.stdin || value === EXEC_CHANNELS.stdout || value === EXEC_CHANNELS.stderr;
137
137
  }
138
138
  //#endregion
139
+ //#region ../api/src/login-shell.ts
140
+ const CONSOLE_SHELL = [
141
+ "uid=$(id -u 2>/dev/null) || uid=0",
142
+ "shell=",
143
+ "while IFS=: read -r _ _ id _ _ _ login; do",
144
+ " if [ \"$id\" = \"$uid\" ]; then shell=$login; break; fi",
145
+ "done < /etc/passwd",
146
+ "[ -x \"$shell\" ] || shell=/bin/bash",
147
+ "[ -x \"$shell\" ] || shell=/bin/sh",
148
+ "exec \"$shell\" -l"
149
+ ].join("\n");
150
+ //#endregion
139
151
  //#region src/exec/exec-error.ts
140
152
  var ExecError = class extends Error {
141
153
  code;
@@ -367,15 +379,6 @@ const TTY_SIGNAL_KEYS = {
367
379
  SIGINT: "",
368
380
  SIGQUIT: ""
369
381
  };
370
- const CONSOLE_SHELL = [
371
- "shell=",
372
- "while IFS=: read -r user _ _ _ _ _ login; do",
373
- " if [ \"$user\" = root ]; then shell=$login; break; fi",
374
- "done < /etc/passwd",
375
- "[ -x \"$shell\" ] || shell=/bin/bash",
376
- "[ -x \"$shell\" ] || shell=/bin/sh",
377
- "exec \"$shell\" -l"
378
- ].join("\n");
379
382
  function openExec(deps, name, argv, options = {}) {
380
383
  const tty = options.tty ?? false;
381
384
  return openHandle(deps, options, tty, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgeoff/imp-client",
3
- "version": "0.1.1",
3
+ "version": "0.2.2",
4
4
  "description": "Typed client for impd, the imp host daemon: imps, checkpoints, images and exec",
5
5
  "license": "MIT",
6
6
  "repository": {