phala 1.2.8 → 1.2.9-beta.1

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
@@ -42,47 +42,47 @@ By default, `phala deploy` uses the Phala Cloud pre-launch script. Use `--no-pre
42
42
 
43
43
  ### Deploy
44
44
 
45
- | Command | Description |
46
- |---------|-------------|
47
- | [`deploy`](docs/deploy.md) | Deploy new CVM or update existing one |
48
- | [`instance-types`](docs/instance-types.md) | List available instance types |
49
- | [`nodes`](docs/nodes.md) | List TEE worker nodes |
45
+ | Command | Description |
46
+ | ------------------------------------------ | ------------------------------------- |
47
+ | [`deploy`](docs/deploy.md) | Deploy new CVM or update existing one |
48
+ | [`instance-types`](docs/instance-types.md) | List available instance types |
49
+ | [`nodes`](docs/nodes.md) | List TEE worker nodes |
50
50
 
51
51
  ### Manage
52
52
 
53
- | Command | Description |
54
- |---------|-------------|
55
- | [`apps`](docs/apps.md) | List deployed CVMs |
56
- | [`cvms`](docs/cvms.md) | Manage CVMs (start, stop, restart, delete, resize, ...) |
57
- | [`link`](docs/link.md) | Link a local directory to a CVM |
58
- | [`simulator`](docs/simulator.md) | Local TEE simulator for development |
53
+ | Command | Description |
54
+ | -------------------------------- | ------------------------------------------------------- |
55
+ | [`apps`](docs/apps.md) | List deployed CVMs |
56
+ | [`cvms`](docs/cvms.md) | Manage CVMs (start, stop, restart, delete, resize, ...) |
57
+ | [`link`](docs/link.md) | Link a local directory to a CVM |
58
+ | [`simulator`](docs/simulator.md) | Local TEE simulator for development |
59
59
 
60
60
  ### CVM Operations
61
61
 
62
- | Command | Description |
63
- |---------|-------------|
62
+ | Command | Description |
63
+ | ---------------------- | -------------------------------------------------------- |
64
64
  | [`logs`](docs/logs.md) | Fetch logs from a CVM (container, serial, stdout/stderr) |
65
- | [`ps`](docs/ps.md) | List containers of a CVM |
66
- | [`ssh`](docs/ssh.md) | Connect to a CVM via SSH |
67
- | [`cp`](docs/cp.md) | Copy files to/from a CVM via SCP |
65
+ | [`ps`](docs/ps.md) | List containers of a CVM |
66
+ | [`ssh`](docs/ssh.md) | Connect to a CVM via SSH |
67
+ | [`cp`](docs/cp.md) | Copy files to/from a CVM via SCP |
68
68
 
69
69
  ### Profile / Auth
70
70
 
71
- | Command | Description |
72
- |---------|-------------|
73
- | [`login`](docs/login.md) | Authenticate with Phala Cloud |
74
- | [`logout`](docs/logout.md) | Remove stored API key |
75
- | [`status`](docs/status.md) | Check authentication status |
76
- | [`whoami`](docs/whoami.md) | Print the current user |
77
- | [`profiles`](docs/profiles.md) | List auth profiles |
78
- | [`switch`](docs/switch.md) | Switch auth profiles |
71
+ | Command | Description |
72
+ | ------------------------------ | ----------------------------- |
73
+ | [`login`](docs/login.md) | Authenticate with Phala Cloud |
74
+ | [`logout`](docs/logout.md) | Remove stored API key |
75
+ | [`status`](docs/status.md) | Check authentication status |
76
+ | [`whoami`](docs/whoami.md) | Print the current user |
77
+ | [`profiles`](docs/profiles.md) | List auth profiles |
78
+ | [`switch`](docs/switch.md) | Switch auth profiles |
79
79
 
80
80
  ### Advanced
81
81
 
82
- | Command | Description |
83
- |---------|-------------|
84
- | [`api`](docs/api.md) | Make authenticated API requests |
85
- | [`self`](docs/self.md) | CLI self-management (update) |
82
+ | Command | Description |
83
+ | ---------------------------------- | --------------------------------- |
84
+ | [`api`](docs/api.md) | Make authenticated API requests |
85
+ | [`self`](docs/self.md) | CLI self-management (update) |
86
86
  | [`completion`](docs/completion.md) | Generate shell completion scripts |
87
87
 
88
88
  ## Configuration
@@ -103,14 +103,14 @@ When `phala.toml` exists, commands like `deploy`, `logs`, `ssh`, and `cp` automa
103
103
 
104
104
  ### Environment variables
105
105
 
106
- | Variable | Description |
107
- |----------|-------------|
108
- | `PHALA_CLOUD_API_KEY` | Override the stored API key |
109
- | `PHALA_CLOUD_API_PREFIX` | Override the API base URL |
106
+ | Variable | Description |
107
+ | --------------------------------- | ------------------------------------------------------------------------------- |
108
+ | `PHALA_CLOUD_API_KEY` | Override the stored API key |
109
+ | `PHALA_CLOUD_API_PREFIX` | Override the API base URL |
110
110
  | `PHALA_CLOUD_REQUESTS_PER_MINUTE` | Pace request starts per credential (default: `180`; must be a positive integer) |
111
- | `PHALA_CLOUD_PROFILE` | Use this auth profile instead of the current one (same as `--profile`) |
112
- | `PHALA_CLOUD_DIR` | Override the credentials directory (default: `~/.phala-cloud`) |
113
- | `PHALA_UPDATE_CHANNEL` | Release channel for `self update` (e.g., `latest`, `beta`) |
111
+ | `PHALA_CLOUD_PROFILE` | Use this auth profile instead of the current one (same as `--profile`) |
112
+ | `PHALA_CLOUD_DIR` | Override the credentials directory (default: `~/.phala-cloud`) |
113
+ | `PHALA_UPDATE_CHANNEL` | Release channel for `self update` (e.g., `latest`, `beta`) |
114
114
 
115
115
  ### Profiles
116
116
 
@@ -152,6 +152,7 @@ bun run test # Run tests
152
152
 
153
153
  - `phala deploy --cvm-id` (or a CVM ID in `phala.toml`) now fails before sending any request when a create-only flag is passed, instead of ignoring it: `--name`, `--region`, `--node`, `--custom-app-id`, `--nonce`, `--key-provider-mode`, `--ssh-pubkey`, `--secure-time`, `--fs`, `--skip-gateway`, `--kms`, `--kms-id`, `--kms-contract`, `--kms-contract-id` and `--experimental-key-provider-type`. Remove them from update invocations; they only apply when a new CVM is created.
154
154
  - `--dev` (alias `--dev-os`) still applies to an update. On dstack 0.6+ the dev box is saved into your local compose file before it is deployed (a diff is printed, and `--json` reports `compose_file_updated`), and the choice is also recorded per CVM in `~/.phala-cloud/state.json`, keyed by the CVM's `vm_uuid`, and an update without the flag repeats it; `--dev` overrides it and `--no-dev-os` drops the dev box and the record. Records are written only after the API accepts the change. A missing record is never read as "turn SSH off": the CLI checks the deployed compose, keeps a dev box it finds there, and says so when the server does not return the compose.
155
+ - `phala deploy` without `--image` now asks for a production OS image, as the web console does, instead of leaving the choice to the API, which preferred a development image (for example `dstack-dev-0.5.9`). It prints the image it used. Pass `--image <name>` to deploy a development image. An update with `--cvm-id` is unchanged. If the selected node has no production image, the deploy fails with an error that says so instead of falling back to a development image.
155
156
  - `--dev` without `--image` deploys the newest dstack release with dev-box support.
156
157
  - Below dstack 0.6, `--dev` now deploys the dev variant of the release you pinned instead of the production image. The backend ignores `prefer_dev` when a request names an image, so `--dev-os --image dstack-0.5.7` used to deploy a CVM with no sshd; the CLI maps it to the release's dev image and fails when the catalog has none.
157
158
  - Dev-box detection reads the parsed compose (anchors, merge keys, flow mappings, inline comments, YAML 1.1 booleans) instead of the text, and only a dev box on the exact image the CLI injects, with no `command`, `profiles` or `entrypoint` replacing sshd, counts as one. Compose files the CLI cannot parse are refused rather than extended.
@@ -1,7 +1,110 @@
1
- import { CvmLogEntry, CvmLogChannel, CvmInfoDetailV20260522 } from '@phala/cloud';
1
+ import { CvmIdInput, CvmLogEntry, CvmLogChannel, CvmInfoDetailV20260522 } from '@phala/cloud';
2
2
  export { CvmLogChannel, LogAccessError } from '@phala/cloud';
3
3
  import { z } from 'zod';
4
4
 
5
+ declare const ProjectConfigSchema: z.ZodObject<{
6
+ id: z.ZodOptional<z.ZodString>;
7
+ uuid: z.ZodOptional<z.ZodString>;
8
+ app_id: z.ZodOptional<z.ZodString>;
9
+ instance_id: z.ZodOptional<z.ZodString>;
10
+ name: z.ZodOptional<z.ZodString>;
11
+ profile: z.ZodOptional<z.ZodString>;
12
+ api_version: z.ZodOptional<z.ZodEnum<{
13
+ "2026-11-11": "2026-11-11";
14
+ "2025-10-28": "2025-10-28";
15
+ "2026-01-21": "2026-01-21";
16
+ "2026-05-22": "2026-05-22";
17
+ "2026-06-23": "2026-06-23";
18
+ }>>;
19
+ gateway_domain: z.ZodOptional<z.ZodString>;
20
+ gateway_port: z.ZodOptional<z.ZodNumber>;
21
+ compose_file: z.ZodOptional<z.ZodString>;
22
+ env_file: z.ZodOptional<z.ZodString>;
23
+ public_logs: z.ZodOptional<z.ZodBoolean>;
24
+ public_sysinfo: z.ZodOptional<z.ZodBoolean>;
25
+ public_tcbinfo: z.ZodOptional<z.ZodBoolean>;
26
+ secure_time: z.ZodOptional<z.ZodBoolean>;
27
+ listed: z.ZodOptional<z.ZodBoolean>;
28
+ }, z.core.$strip>;
29
+ type ProjectConfig = z.infer<typeof ProjectConfigSchema>;
30
+ type RuntimeProjectConfig = Partial<ProjectConfig> & {
31
+ cvm_id?: string;
32
+ gateway_domain?: string;
33
+ gateway_port?: number;
34
+ compose_file?: string;
35
+ env_file?: string;
36
+ public_logs?: boolean;
37
+ public_sysinfo?: boolean;
38
+ public_tcbinfo?: boolean;
39
+ secure_time?: boolean;
40
+ listed?: boolean;
41
+ };
42
+
43
+ interface CommandGlobalOptions {
44
+ readonly apiToken?: string;
45
+ readonly json: boolean;
46
+ readonly interactive: boolean;
47
+ readonly profile?: string;
48
+ readonly apiVersion?: string;
49
+ /** Request timeout in seconds (overrides SDK default). */
50
+ readonly timeout?: number;
51
+ }
52
+ interface CommandContext {
53
+ readonly argv: readonly string[];
54
+ readonly rawFlags: Record<string, unknown>;
55
+ readonly rawPositionals: readonly string[];
56
+ readonly cwd: string;
57
+ readonly env: NodeJS.ProcessEnv;
58
+ readonly stdout: NodeJS.WriteStream;
59
+ readonly stderr: NodeJS.WriteStream;
60
+ readonly stdin: NodeJS.ReadStream;
61
+ readonly projectConfig: RuntimeProjectConfig;
62
+ readonly globalOptions?: CommandGlobalOptions;
63
+ readonly cli?: {
64
+ readonly executableName: string;
65
+ readonly packageName: string;
66
+ readonly packageVersion: string;
67
+ readonly runtime: "node" | "bun";
68
+ };
69
+ /**
70
+ * Parsed CVM identifier (optional)
71
+ * Automatically parsed from input.cvmId using SDK's CvmIdSchema
72
+ * Populated when:
73
+ * - input.cvmId is provided: parsed as { id: cvmId }
74
+ * - input.cvmId is empty + input.interactive is true: prompts user to select CVM
75
+ * - Otherwise: undefined (command should fail with "No CVM ID provided")
76
+ */
77
+ readonly cvmId?: CvmIdInput;
78
+ /**
79
+ * Output success result. In JSON mode, outputs {success: true, ...data} to stdout.
80
+ * In human mode, outputs success message to stdout.
81
+ */
82
+ success(data: unknown): void;
83
+ /**
84
+ * Output failure result and exit. In JSON mode, outputs {success: false, error: ...} to stdout.
85
+ * In human mode, outputs error message to stderr.
86
+ */
87
+ fail(message: string, details?: unknown): void;
88
+ /**
89
+ * Normalize and present an API/local error exactly once.
90
+ * JSON mode writes one object to stdout; human mode writes one block to stderr.
91
+ * Does not throw; callers should return 1 immediately.
92
+ */
93
+ failWithError(error: unknown, options?: {
94
+ readonly operation?: string;
95
+ readonly debug?: boolean;
96
+ readonly guidance?: string;
97
+ }): void;
98
+ }
99
+
100
+ /**
101
+ * The slice of the command context that decides which credentials, profile and
102
+ * API endpoint a request uses. Every client is built from one of these, so a
103
+ * helper that needs a client must be handed the context of the command that
104
+ * called it; there is no ambient fallback to the default profile.
105
+ */
106
+ type AuthContextLike = Pick<CommandContext, "env" | "projectConfig" | "globalOptions">;
107
+
5
108
  declare const dockerConfigSchema: z.ZodObject<{
6
109
  password: z.ZodString;
7
110
  registry: z.ZodNullable<z.ZodString>;
@@ -298,24 +401,24 @@ interface AvailableNodesResponse {
298
401
  * @param appId App ID (with or without app_ prefix)
299
402
  * @returns CVM details
300
403
  */
301
- declare function getCvmByAppId(appId: string): Promise<CvmInfoDetailV20260522>;
404
+ declare function getCvmByAppId(context: AuthContextLike, appId: string): Promise<CvmInfoDetailV20260522>;
302
405
  /**
303
406
  * Get CVM network information
304
407
  * @param appId App ID (with or without app_ prefix)
305
408
  * @returns Network information
306
409
  */
307
- declare function getCvmNetwork(appId: string): Promise<GetCvmNetworkResponse>;
410
+ declare function getCvmNetwork(context: AuthContextLike, appId: string): Promise<GetCvmNetworkResponse>;
308
411
  /**
309
412
  * Presents a list of CVMs to the user and allows them to select one
310
413
  * @returns The selected CVM app ID or undefined if no CVMs exist
311
414
  */
312
- declare function selectCvm(): Promise<string | undefined>;
415
+ declare function selectCvm(context: AuthContextLike): Promise<string | undefined>;
313
416
  /**
314
417
  * Get attestation information for a CVM
315
418
  * @param appId App ID (with or without app_ prefix)
316
419
  * @returns Attestation information
317
420
  */
318
- declare function getCvmAttestation(appId: string): Promise<CvmAttestationResponse>;
421
+ declare function getCvmAttestation(context: AuthContextLike, appId: string): Promise<CvmAttestationResponse>;
319
422
  /**
320
423
  * Resize payload type
321
424
  */
@@ -333,12 +436,12 @@ interface ResizeCvmPayload {
333
436
  * @param diskSize Disk size in GB (optional)
334
437
  * @returns Success status
335
438
  */
336
- declare function resizeCvm(appId: string, vcpu?: number, memory?: number, diskSize?: number): Promise<boolean>;
439
+ declare function resizeCvm(context: AuthContextLike, appId: string, vcpu?: number, memory?: number, diskSize?: number): Promise<boolean>;
337
440
  /**
338
441
  * Get the CVM create resource graph.
339
442
  * @returns Nodes, KMS resources, gateway resources, and instance types for CVM creation
340
443
  */
341
- declare function getCvmCreateResources(): Promise<CvmCreateResourcesResponse>;
444
+ declare function getCvmCreateResources(context: AuthContextLike): Promise<CvmCreateResourcesResponse>;
342
445
 
343
446
  type LogEntry = CvmLogEntry;
344
447
  interface SerialLogsOptions {
@@ -353,16 +456,17 @@ interface ContainerLogsOptions extends SerialLogsOptions {
353
456
  container?: string;
354
457
  matchContainerIdPrefix?: boolean;
355
458
  }
356
- declare function getCvmLogEndpoint(appId: string, channel: CvmLogChannel): Promise<string>;
357
- declare function fetchSerialLogs(appId: string, options?: SerialLogsOptions): Promise<string>;
358
- declare function fetchContainerLogs(appId: string, options?: ContainerLogsOptions): Promise<string>;
359
- declare function fetchContainerLogsEntries(appId: string, options?: ContainerLogsOptions): Promise<LogEntry[]>;
360
- declare function streamContainerLogsEntries(appId: string, onEntry: (entry: LogEntry) => void, options?: ContainerLogsOptions, signal?: AbortSignal): Promise<void>;
361
- declare function streamSerialLogs(appId: string, onData: (data: string) => void, options?: SerialLogsOptions, signal?: AbortSignal): Promise<void>;
362
- declare function streamContainerLogs(appId: string, onData: (data: string) => void, options?: ContainerLogsOptions, signal?: AbortSignal): Promise<void>;
363
- declare function fetchCvmChannelLogs(appId: string, channel: CvmLogChannel, options?: SerialLogsOptions): Promise<string>;
364
- declare function streamCvmChannelLogs(appId: string, channel: CvmLogChannel, onData: (data: string) => void, options?: SerialLogsOptions, signal?: AbortSignal): Promise<void>;
459
+ declare function getCvmLogEndpoint(context: AuthContextLike, appId: string, channel: CvmLogChannel): Promise<string>;
460
+ declare function fetchSerialLogs(context: AuthContextLike, appId: string, options?: SerialLogsOptions): Promise<string>;
461
+ declare function fetchContainerLogs(context: AuthContextLike, appId: string, options?: ContainerLogsOptions): Promise<string>;
462
+ declare function fetchContainerLogsEntries(context: AuthContextLike, appId: string, options?: ContainerLogsOptions): Promise<LogEntry[]>;
463
+ declare function streamContainerLogsEntries(context: AuthContextLike, appId: string, onEntry: (entry: LogEntry) => void, options?: ContainerLogsOptions, signal?: AbortSignal): Promise<void>;
464
+ declare function streamSerialLogs(context: AuthContextLike, appId: string, onData: (data: string) => void, options?: SerialLogsOptions, signal?: AbortSignal): Promise<void>;
465
+ declare function streamContainerLogs(context: AuthContextLike, appId: string, onData: (data: string) => void, options?: ContainerLogsOptions, signal?: AbortSignal): Promise<void>;
466
+ declare function fetchCvmChannelLogs(context: AuthContextLike, appId: string, channel: CvmLogChannel, options?: SerialLogsOptions): Promise<string>;
467
+ declare function streamCvmChannelLogs(context: AuthContextLike, appId: string, channel: CvmLogChannel, onData: (data: string) => void, options?: SerialLogsOptions, signal?: AbortSignal): Promise<void>;
365
468
  /** Get CVM status string (e.g. "running", "stopped") */
366
- declare function getCvmStatus(appId: string): Promise<string>;
469
+ declare function getCvmStatus(context: AuthContextLike, appId: string): Promise<string>;
367
470
 
368
- export { type AvailableNodesResponse, type CertificateInfo, type CertificateNameInfo, type ComposeFile, type ContainerLogsOptions, type CvmAttestationResponse, type CvmCreateGatewayResource, type CvmCreateInstanceTypeResource, type CvmCreateNodeKmsRelation, type CvmCreateResourcesResponse, type CvmListResponse, type DockerConfig, type EncryptedEnvItem, type GetCvmNetworkResponse, type GpuAvailability, type Image, type KmsListItem, type LogEntry, type ProductGpuAvailability, type ReplicateCvmResponse, type ResizeCvmPayload, type SerialLogsOptions, type TCBEventLogEntry, type TCBInfo, type TEEPod, type UserInfoResponse, composeFileSchema, cvmAttestationResponseSchema, dockerConfigSchema, encryptedEnvItemSchema, fetchContainerLogs, fetchContainerLogsEntries, fetchCvmChannelLogs, fetchSerialLogs, getCvmAttestation, getCvmByAppId, getCvmCreateResources, getCvmLogEndpoint, getCvmNetwork, getCvmNetworkResponseSchema, getCvmStatus, imageSchema, replicateCvmResponseSchema, resizeCvm, selectCvm, streamContainerLogs, streamContainerLogsEntries, streamCvmChannelLogs, streamSerialLogs, teepodSchema };
471
+ export { composeFileSchema, cvmAttestationResponseSchema, dockerConfigSchema, encryptedEnvItemSchema, fetchContainerLogs, fetchContainerLogsEntries, fetchCvmChannelLogs, fetchSerialLogs, getCvmAttestation, getCvmByAppId, getCvmCreateResources, getCvmLogEndpoint, getCvmNetwork, getCvmNetworkResponseSchema, getCvmStatus, imageSchema, replicateCvmResponseSchema, resizeCvm, selectCvm, streamContainerLogs, streamContainerLogsEntries, streamCvmChannelLogs, streamSerialLogs, teepodSchema };
472
+ export type { AvailableNodesResponse, CertificateInfo, CertificateNameInfo, ComposeFile, ContainerLogsOptions, CvmAttestationResponse, CvmCreateGatewayResource, CvmCreateInstanceTypeResource, CvmCreateNodeKmsRelation, CvmCreateResourcesResponse, CvmListResponse, DockerConfig, EncryptedEnvItem, GetCvmNetworkResponse, GpuAvailability, Image, KmsListItem, LogEntry, ProductGpuAvailability, ReplicateCvmResponse, ResizeCvmPayload, SerialLogsOptions, TCBEventLogEntry, TCBInfo, TEEPod, UserInfoResponse };