Skip to content

Add SciLaxy account device access to lab CLI - #16

Merged
Mile-Away merged 3 commits into
mainfrom
codex/remote-device-api
Sep 22, 2026
Merged

Mile-Away merged 3 commits into
mainfrom
codex/remote-device-api

Conversation

@Mile-Away

@Mile-Away Mile-Away commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add lab api login, lab api devices, and lab api logout for SciLaxy account access.
  • Verify account tokens before saving them; store credentials in a private local file.
  • Document the Lab Server and hardware configuration required before devices appear.
  • Retry transient registry readiness errors in Ubuntu CI.

Verification

  • cargo fmt --all --check
  • CARGO_INCREMENTAL=0 cargo test -p lab-cli --locked --bin lab --test cli_surface
  • Ubuntu OCI integration tests, macOS tests, and Windows tests passed in CI.

The SciLaxy API routes are added in the companion Liyan PR #10.

@sourcery-ai

sourcery-ai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

审查者指南

此 PR 为 lab api CLI 引入了新的命令界面,用于安全地向 SciLaxy 账户 API 进行身份验证、列出在线运行器和设备,以及退出登录。它会验证服务器 URL 和令牌,在以原子方式存储私有凭据之前验证令牌,支持人类可读和 JSON 输出,并记录使设备可见所需的配置。

SciLaxy API 登录和设备列表的时序图

sequenceDiagram
    actor User
    participant LabCLI
    participant SciLaxyAPI
    participant CredentialFile

    User->>LabCLI: lab api login --server SERVER
    LabCLI->>LabCLI: parse_server()
    LabCLI->>User: prompt_password()
    User-->>LabCLI: OpenSDL API token
    LabCLI->>LabCLI: http_client()
    LabCLI->>SciLaxyAPI: 使用 bearer token 获取 GET /liyanlabs/api/v1/osdl/me
    SciLaxyAPI-->>LabCLI: 成功响应
    LabCLI->>CredentialFile: save_credentials()
    LabCLI-->>User: 已完成身份验证

    User->>LabCLI: lab api devices
    LabCLI->>CredentialFile: read_credentials()
    CredentialFile-->>LabCLI: 服务器和令牌
    LabCLI->>SciLaxyAPI: 使用 bearer token 获取 GET /liyanlabs/api/v1/osdl/devices
    SciLaxyAPI-->>LabCLI: 运行器和设备
    LabCLI-->>User: 在线设备
Loading

文件级变更

变更 详细信息 文件
为 lab CLI 添加经过身份验证的 SciLaxy 账户设备命令。
  • 注册包含 login、devices 和 logout 子命令的 api 命令。
  • 安全地提示输入令牌或从 stdin 读取令牌,验证令牌格式,通过账户 API 验证凭据,并以人类可读或 JSON 格式查询设备数据。
  • 添加有界 HTTP 客户端、安全的服务器来源验证和 API 错误处理。
crates/lab-cli/src/main.rs
crates/lab-cli/src/commands/mod.rs
crates/lab-cli/src/commands/api.rs
crates/lab-cli/Cargo.toml
Cargo.lock
将账户凭据作为带原子替换功能的本地私有文件持久化。
  • 将服务器和令牌存储在发现的配置目录中。
  • 通过临时文件写入并同步文件,在持久化之前应用严格的 Unix 权限。
  • 支持删除凭据,并在凭据缺失或无效时报告可采取行动的错误。
crates/lab-cli/src/commands/api.rs
记录账户设备访问方式以及使设备显示所需的基础设施。
  • 添加登录、设备列表、JSON 和退出登录示例。
  • 说明令牌作用域、隐藏输入、撤销操作,以及所需的运行器、Lab Server、传输层和注册表配置。
README.md
添加针对服务器解析和凭据存储的专项验证。
  • 测试安全来源限制,以及对路径、凭据和查询字符串的拒绝。
  • 测试凭据往返读写和 Unix 文件模式 0600。
crates/lab-cli/src/commands/api.rs

提示和命令

与 Sourcery 交互

  • 触发新的审查: 在 pull request 中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以使用 @sourcery-ai issue 回复审查评论,以根据该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title,以随时生成或重新生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中你希望插入摘要的位置写入 @sourcery-ai summary,即可随时生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary,以随时生成或重新生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时生成或重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此功能非常有用。
  • 忽略所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从新的审查开始,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的审查!

自定义你的使用体验

访问你的控制面板:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

This PR introduces a new lab api CLI surface for securely authenticating to the SciLaxy account API, listing online runners and devices, and logging out. It validates server URLs and tokens, verifies tokens before atomically storing private credentials, supports human-readable and JSON output, and documents the setup required for devices to become visible.

Sequence diagram for SciLaxy API login and device listing

sequenceDiagram
    actor User
    participant LabCLI
    participant SciLaxyAPI
    participant CredentialFile

    User->>LabCLI: lab api login --server SERVER
    LabCLI->>LabCLI: parse_server()
    LabCLI->>User: prompt_password()
    User-->>LabCLI: OpenSDL API token
    LabCLI->>LabCLI: http_client()
    LabCLI->>SciLaxyAPI: GET /liyanlabs/api/v1/osdl/me with bearer token
    SciLaxyAPI-->>LabCLI: successful response
    LabCLI->>CredentialFile: save_credentials()
    LabCLI-->>User: Authenticated

    User->>LabCLI: lab api devices
    LabCLI->>CredentialFile: read_credentials()
    CredentialFile-->>LabCLI: server and token
    LabCLI->>SciLaxyAPI: GET /liyanlabs/api/v1/osdl/devices with bearer token
    SciLaxyAPI-->>LabCLI: runners and devices
    LabCLI-->>User: online devices
Loading

File-Level Changes

Change Details Files
Add authenticated SciLaxy account device commands to the lab CLI.
  • Register an api command with login, devices, and logout subcommands.
  • Prompt for tokens securely or read them from stdin, validate token format, verify credentials via the account API, and query device data with human-readable or JSON output.
  • Add bounded HTTP clients, secure server-origin validation, and API error handling.
crates/lab-cli/src/main.rs
crates/lab-cli/src/commands/mod.rs
crates/lab-cli/src/commands/api.rs
crates/lab-cli/Cargo.toml
Cargo.lock
Persist account credentials as a private local file with atomic replacement.
  • Store the server and token under the discovered configuration directory.
  • Write through a temporary file, sync it, and apply restrictive Unix permissions before persisting.
  • Support removing credentials and report actionable errors when credentials are absent or invalid.
crates/lab-cli/src/commands/api.rs
Document account device access and the infrastructure required for devices to appear.
  • Add login, device-listing, JSON, and logout examples.
  • Explain token scope, hidden input, revocation, and required runner, Lab Server, transport, and registry configuration.
README.md
Add focused validation for server parsing and credential storage.
  • Test secure-origin restrictions and rejection of paths, credentials, and query strings.
  • Test credential round-tripping and Unix file mode 0600.
crates/lab-cli/src/commands/api.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗨——我已经审阅了你的更改,看起来很棒!


Sourcery 对开源项目免费——如果你喜欢我们的评审,请考虑分享它们 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@Mile-Away
Mile-Away merged commit b3dcf1a into main Sep 22, 2026
14 checks passed
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.

1 participant