Skip to content

feat(cli): add phala instance-types command and other improvements#161

Merged
Leechael merged 15 commits intomainfrom
fix/cli-logs-cvm-id-resolution
Jan 31, 2026
Merged

feat(cli): add phala instance-types command and other improvements#161
Leechael merged 15 commits intomainfrom
fix/cli-logs-cvm-id-resolution

Conversation

@Leechael
Copy link
Collaborator

@Leechael Leechael commented Jan 31, 2026

Summary

This PR adds several new CLI commands and improves existing functionality:

  • New commands: ps, logs, apps, instance-types
  • Migrate nodes to workspace-scoped API
  • Add workspace nodes and quotas API to JS SDK
  • Fix CVM ID resolution issues in logs commands
  • Apply anti-slop guidelines to command descriptions

New Commands

phala ps - List CVM containers

List all running CVM instances with status and uptime.

phala logs - View CVM logs

Fetch logs from running CVMs with filtering options.

phala apps - List dstack apps

Display all dstack applications with their CVM status.

phala instance-types - List instance types

  • phala instance-types - List all instance type families
  • phala instance-types cpu - List CPU instance types
  • phala instance-types gpu - List GPU instance types
  • Support --json flag for JSON output

Improvements

Workspace API Migration

  • phala nodes now uses workspace-scoped nodes API
  • Better pagination and filtering
  • Consistent output format with other list commands

Bug Fixes

  • Fix normalized CVM ID handling for serial log endpoint lookup
  • Show actual error before public_logs hint in logs commands
  • Default public_logs and public_sysinfo to true in CLI deploy

Refactoring

  • Apply anti-slop guidelines to all command descriptions
  • Align cvms ls output format with other list commands
  • Improve help text consistency

SDK Changes

Added to @phala/cloud JS SDK:

  • getWorkspaceNodes() - List workspace nodes with pagination
  • getWorkspaceQuotas() - Get workspace resource quotas

Test Plan

  • Build passes
  • Type check passes
  • All command help displays correctly
  • Manual testing of new commands
  • Manual testing of nodes command with new API

getSerialLogEndpoint hardcoded an app_ prefix when constructing the
API path, which broke name-based CVM identifiers (e.g. "my-cvm").
Use the already-normalized appId directly, consistent with
getContainerLogEndpoint and other cvms subcommands.
The catch block in logs-handler previously swallowed the real error
(e.g. 404 from syslog server) when public_logs was false, showing
only the misleading "Logs are disabled" message. Now the actual
failure reason is displayed first, followed by the public_logs hint.
Calls the composition API via the JS SDK and displays container
name, image, creation time, status and state in a plain table.
Add two new workspace-level API endpoints:
- getWorkspaceNodes: List nodes accessible by workspace
- getWorkspaceQuotas: Get tier-based resource quotas

Both APIs follow the existing SDK patterns with proper TypeScript
typing, schema validation, and safe variants.
Remove verbose and redundant phrasing from all CLI command help text.

Key changes:
- Remove [DEPRECATED] prefix from deprecated options (redundant)
- Simplify command descriptions:
  - "Manage Phala Confidential Virtual Machines (CVMs)" → "Manage CVMs"
  - "List apps (current CVM status)" → "List dstack apps"
  - "Check Phala Cloud status and authentication" → "Check authentication status"
- Simplify option descriptions:
  - "Number of lines to show from the end of the logs" → "Lines from end"
  - "Follow log output (stream logs in real-time)" → "Stream logs in real-time"
  - "Allow restart of the CVM if needed for resizing" → "Allow CVM restart"
  - "If not provided, X" → "(auto-selected if omitted)" or "(defaults to X)"
- Simplify examples:
  - "List apps (page 1)" → "List apps"
  - "Deploy new CVM with auto-selection (simplest)" → "Deploy new CVM"
  - "Connect to a specific CVM (queries API for gateway)" → "Connect to CVM"

All changes follow anti-slop principles: remove filler words, avoid
hedging language, state facts directly, use concise phrasing.
Replace safeGetAvailableNodes with safeGetWorkspaceNodes to use
workspace-scoped node listing. Changes include:

- Use safeGetCurrentUser to obtain workspace teamSlug
- Call safeGetWorkspaceNodes with pagination support
- Replace detailed multi-line output with table format
- Display columns: ID, NAME, REGION, PPID, DEVICE_ID, VERSION
- Show version number only (strip git info)
- Add pagination info (page/total)
- Support aliases: 'phala nodes', 'phala nodes list', 'phala nodes ls'

Output format:
  ID  NAME     REGION      PPID              DEVICE_ID  VERSION
  1   tdxlab   US-WEST-1   80d4a149124353c7  1234       v0.5.4
  Page 1/1 (total 1)
Add new command to list available instance types. Supports:
- List all instance type families (default)
- Filter by family via positional argument (cpu, gpu)
- JSON output with --json flag
- Table format display with ID, name, vCPU, memory, hourly rate

Command is in deploy category alongside nodes command.

Usage:
  phala instance-types           # all families
  phala instance-types cpu       # CPU family only
  phala instance-types --json    # JSON output
@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2026

📋 Check Results

✨ JS SDK - Code Formatting

Show format check results
✓ No formatting issues found

🔍 JS SDK - TypeScript Type Check

Show type check output
$ tsc --noEmit

🧪 JS SDK - Test Results

Show test output
$ vitest --run --exclude '**/*.e2e.test.ts'

�[7m�[1m�[36m RUN �[39m�[22m�[27m �[36mv1.6.1�[39m �[90m/home/runner/work/phala-cloud/phala-cloud/js�[39m

 �[32m✓�[39m src/client.test.ts �[2m (�[22m�[2m45 tests�[22m�[2m)�[22m�[90m 36�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/blockchains/deploy_app_auth.test.ts �[2m (�[22m�[2m27 tests�[22m�[2m)�[22m�[90m 38�[2mms�[22m�[39m
�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould add compose hash successfully with default parameters�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould handle custom timeout�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould use custom schema when provided�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould return raw data when schema is false�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould throw when custom schema validation fails�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould work with wallet client authentication�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould work with both clients provided�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould skip prerequisite checks when configured�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould use retry mechanism when enabled�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mStandard Version�[2m > �[22m�[2mshould handle progress callbacks�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSafe Version�[2m > �[22m�[2mshould return success result when operation succeeds�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSafe Version�[2m > �[22m�[2mshould work with custom schema�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSafe Version�[2m > �[22m�[2mshould return raw data when schema is false�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSafe Version�[2m > �[22m�[2mshould work without parameters�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSafe Version�[2m > �[22m�[2mshould work with empty parameters object�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSchema Flexibility�[2m > �[22m�[2mshould allow extra fields in transaction receipt for forward compatibility�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSchema Flexibility�[2m > �[22m�[2mshould handle ComposeHashAdded event when present�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mType Inference�[2m > �[22m�[2mshould infer correct types for default schema�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mType Inference�[2m > �[22m�[2mshould infer correct types for custom schema�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mType Inference�[2m > �[22m�[2mshould infer unknown type when schema is false�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSafe Version Type Inference�[2m > �[22m�[2mshould infer correct SafeResult types for default schema�[22m�[39m
[]

�[90mstdout�[2m | src/actions/blockchains/add_compose_hash.test.ts�[2m > �[22m�[2maddComposeHash�[2m > �[22m�[2mSafe Version Type Inference�[2m > �[22m�[2mshould infer correct SafeResult types for custom schema�[22m�[39m
[]

 �[32m✓�[39m src/actions/blockchains/add_compose_hash.test.ts �[2m (�[22m�[2m34 tests�[22m�[2m)�[22m�[90m 138�[2mms�[22m�[39m
 �[32m✓�[39m src/utils/define-action.test.ts �[2m (�[22m�[2m24 tests�[22m�[2m)�[22m�[90m 24�[2mms�[22m�[39m
 �[32m✓�[39m src/utils/define-action.type.test.ts �[2m (�[22m�[2m20 tests�[22m�[2m)�[22m�[90m 25�[2mms�[22m�[39m
 �[32m✓�[39m src/types/cvm_id.test.ts �[2m (�[22m�[2m53 tests�[22m�[2m)�[22m�[90m 30�[2mms�[22m�[39m
 �[32m✓�[39m src/utils/errors.test.ts �[2m (�[22m�[2m28 tests�[22m�[2m)�[22m�[90m 19�[2mms�[22m�[39m
 �[32m✓�[39m src/utils/hostname.test.ts �[2m (�[22m�[2m53 tests�[22m�[2m)�[22m�[90m 22�[2mms�[22m�[39m
 �[32m✓�[39m src/parse_dotenv.test.ts �[2m (�[22m�[2m71 tests�[22m�[2m)�[22m�[90m 22�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/get_current_user.test.ts �[2m (�[22m�[2m14 tests�[22m�[2m)�[22m�[90m 24�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/provision_cvm_compose_file_update.test.ts �[2m (�[22m�[2m29 tests�[22m�[2m)�[22m�[90m 35�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/commit_cvm_compose_file_update.test.ts �[2m (�[22m�[2m12 tests�[22m�[2m)�[22m�[90m 22�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/get_cvm_info.test.ts �[2m (�[22m�[2m11 tests�[22m�[2m)�[22m�[90m 26�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/watch_cvm_state.test.ts �[2m (�[22m�[2m6 tests�[22m�[2m)�[22m�[90m 56�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/get_cvm_compose_file.test.ts �[2m (�[22m�[2m10 tests�[22m�[2m)�[22m�[90m 23�[2mms�[22m�[39m
 �[32m✓�[39m src/version-inference.type.test.ts �[2m (�[22m�[2m17 tests�[22m�[2m)�[22m�[90m 72�[2mms�[22m�[39m
 �[32m✓�[39m src/client.extend.type.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 6�[2mms�[22m�[39m
 �[32m✓�[39m src/version-inference.runtime.test.ts �[2m (�[22m�[2m9 tests�[22m�[2m)�[22m�[90m 13�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/get_cvm_list.test.ts �[2m (�[22m�[2m6 tests�[22m�[2m)�[22m�[90m 20�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/kms/get_app_env_encrypt_pubkey.test.ts �[2m (�[22m�[2m9 tests�[22m�[2m)�[22m�[90m 20�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/provision_cvm.test.ts �[2m (�[22m�[2m10 tests�[22m�[2m)�[22m�[90m 13�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/commit_cvm_provision.test.ts �[2m (�[22m�[2m7 tests�[22m�[2m)�[22m�[90m 19�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/kms/get_kms_list.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 22�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/kms/get_kms_info.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 14�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/get_cvm_stats.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 16�[2mms�[22m�[39m
 �[32m✓�[39m src/client.extend.test.ts �[2m (�[22m�[2m6 tests�[22m�[2m)�[22m�[90m 12�[2mms�[22m�[39m
 �[32m✓�[39m src/utils/validate-parameters.test.ts �[2m (�[22m�[2m9 tests�[22m�[2m)�[22m�[90m 9�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/shutdown_cvm.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 16�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/get_available_nodes.test.ts �[2m (�[22m�[2m6 tests�[22m�[2m)�[22m�[90m 18�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/restart_cvm.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 17�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/stop_cvm.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 15�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/start_cvm.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 15�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/get_cvm_containers_stats.test.ts �[2m (�[22m�[2m6 tests�[22m�[2m)�[22m�[90m 15�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/delete_cvm.test.ts �[2m (�[22m�[2m8 tests�[22m�[2m)�[22m�[90m 15�[2mms�[22m�[39m
 �[32m✓�[39m src/actions/cvms/get_cvm_state.test.ts �[2m (�[22m�[2m4 tests�[22m�[2m)�[22m�[90m 7�[2mms�[22m�[39m
 �[32m✓�[39m src/utils/as-hex.test.ts �[2m (�[22m�[2m9 tests�[22m�[2m)�[22m�[90m 6�[2mms�[22m�[39m

�[2m Test Files �[22m �[1m�[32m36 passed�[39m�[22m�[90m (36)�[39m
�[2m      Tests �[22m �[1m�[32m607 passed�[39m�[22m�[90m (607)�[39m
�[2m   Start at �[22m 04:14:19
�[2m   Duration �[22m 7.27s�[2m (transform 1.16s, setup 7ms, collect 9.87s, tests 900ms, environment 9ms, prepare 4.39s)�[22m

📝 JS SDK - Lint Check

Show lint results
✓ No linting issues found

🌐 JS SDK - Browser Compatibility

Show browser test results

🌐 Browser Compatibility Report

Browser compatibility tests completed across:

  • ✓ Chromium
  • ✓ Firefox
  • ✓ WebKit (Safari)

The SDK has been verified to work in modern browser environments.


Check run: https://github.com/Phala-Network/phala-cloud/actions/runs/21538555238

The nodes list command was using workspace.name instead of workspace.slug
to construct API paths, causing failures for workspaces where name differs
from slug (e.g., "My Company" vs "my-company").

Changes:
- Fix nodes list to use workspace.slug for /workspaces/{teamSlug}/nodes
- Update credentials system to store workspace slug
- Add null check for slug with helpful error message
- Update all login flows to extract and persist workspace slug

This adapts to the backend API change that introduced workspace slugs
as the canonical URL-safe identifier.
@Leechael
Copy link
Collaborator Author

!release sdk minor

@github-actions
Copy link
Contributor

⚠️ @Leechael I couldn't parse the release command.

Expected format: !release <cli|js> <patch|minor|major> [beta|alpha|rc]

Examples:

  • !release cli patch - stable release
  • !release js minor beta - beta release

@Leechael
Copy link
Collaborator Author

!release js minor

@github-actions
Copy link
Contributor

🚀 @Leechael release command accepted: js minor.

Target branch: fix/cli-logs-cvm-id-resolution (open PR). Version commits will be pushed to this branch.
The release workflow is queued; results will be posted here.

@Leechael
Copy link
Collaborator Author

!release cli patch

@github-actions
Copy link
Contributor

🚀 @Leechael release command accepted: cli patch.

Target branch: fix/cli-logs-cvm-id-resolution (open PR). Version commits will be pushed to this branch.
The release workflow is queued; results will be posted here.

@github-actions
Copy link
Contributor

🎉 Release completed: js v0.2.1

📦 Package Info

  • Package size: size: 129.1
  • Unpacked size: size: 1.2
  • Total files: files:
📄 Files included
11.4kB LICENSE
2.7kB README.md
1.2kB dist/actions/apps/get_app_cvms.d.ts
1.2kB dist/actions/apps/get_app_info.d.ts
3.1kB dist/actions/apps/get_app_list.d.ts
1.9kB dist/actions/apps/get_app_revision_detail.d.ts
1.7kB dist/actions/apps/get_app_revisions.d.ts
2.6kB dist/actions/blockchains/add_compose_hash.d.ts
7.5kB dist/actions/blockchains/deploy_app_auth.d.ts
6.4kB dist/actions/cvms/commit_cvm_compose_file_update.d.ts
16.0kB dist/actions/cvms/commit_cvm_provision.d.ts
2.6kB dist/actions/cvms/delete_cvm.d.ts
7.4kB dist/actions/cvms/get_available_os_images.d.ts
13.0kB dist/actions/cvms/get_cvm_attestation.d.ts
11.7kB dist/actions/cvms/get_cvm_compose_file.d.ts

@github-actions
Copy link
Contributor

@Leechael release failed: cli 1.1.6

Branch: fix/cli-logs-cvm-id-resolution
Please review the workflow logs: https://github.com/Phala-Network/phala-cloud/actions/runs/21538441513

The help text format was changed to use specific group labels
(Deploy, Manage, CVM operations, etc.) instead of a generic
"Commands:" header. Update the test to match the current format.

This test was already failing before the workspace slug fix.
@Leechael
Copy link
Collaborator Author

!release cli patch

@github-actions
Copy link
Contributor

🚀 @Leechael release command accepted: cli patch.

Target branch: fix/cli-logs-cvm-id-resolution (open PR). Version commits will be pushed to this branch.
The release workflow is queued; results will be posted here.

@github-actions
Copy link
Contributor

🎉 Release completed: cli v1.1.6

📦 Package Info

  • Package size: size: 215.4
  • Unpacked size: size: 742.7
  • Total files: files:
📄 Files included
11.4kB LICENSE
23.7kB README.md
28.8kB dist/api/index.d.ts
139.4kB dist/api/index.js
20B dist/index.d.ts
537.5kB dist/index.js
2.0kB package.json

@Leechael Leechael merged commit 06172a9 into main Jan 31, 2026
1 check passed
@Leechael Leechael deleted the fix/cli-logs-cvm-id-resolution branch January 31, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants