Skip to content

Add computer port publish commands - #16

Merged
aniketmaurya merged 3 commits into
mainfrom
codex/published-sandbox-ports-sdk
Jun 7, 2026
Merged

Add computer port publish commands#16
aniketmaurya merged 3 commits into
mainfrom
codex/published-sandbox-ports-sdk

Conversation

@aniketmaurya

@aniketmaurya aniketmaurya commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add SDK methods for publishing, listing, and unpublishing computer ports
  • add celesto computer port publish/list/unpublish CLI commands with JSON support
  • add published-port typed response shape and focused SDK/CLI tests

Tests

  • uv run pytest tests/test_sdk.py tests/test_computer_cli.py

Summary by CodeRabbit

  • New Features

    • Added CLI commands under celesto computer port to publish, list, and unpublish computer ports.
    • Publish and unpublish operations default to port 8000.
    • All port operations support JSON output format.
  • Tests

    • Added comprehensive test coverage for port management commands and SDK client functionality.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@aniketmaurya, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 20 minutes and 28 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22cf3f3e-c96e-4191-9988-8c1d3b62d042

📥 Commits

Reviewing files that changed from the base of the PR and between 569e0d6 and 63b9ca4.

📒 Files selected for processing (2)
  • src/celesto/sdk/client.py
  • tests/test_computer_cli.py
📝 Walkthrough

Walkthrough

Right then, listen carefully. We've added port publishing to the system—three operations, clean and organised. You've got types defining the port metadata, SDK methods handling the HTTP work, CLI commands for the users, and proper test coverage throughout. Everything flows from contracts downward.

Changes

Computer Port Publishing

Layer / File(s) Summary
Published port type contracts
src/celesto/sdk/types.py
Introduces PublishedPortStatus as a Literal of port states and ComputerPublishedPortInfo as a TypedDict with port metadata; extends ComputerInfo with optional published_ports field and exports the new types.
SDK client port management methods
src/celesto/sdk/client.py
Adds three methods to Computers: publish_port (POST), list_published_ports (GET), and unpublish_port (DELETE) to the published-ports endpoint; each uses the standard _request mechanism.
CLI port subcommands
src/celesto/computer.py
Creates port_app Typer subgroup with three commands (publish_port, list_ports, unpublish_port); resolves the client, invokes SDK methods, and renders output as JSON or formatted text (table, URL, or status message).
SDK and CLI tests
tests/test_sdk.py, tests/test_computer_cli.py
Adds endpoint validation tests for SDK methods and CLI command tests using fake client infrastructure; verifies HTTP operations, JSON payloads, response parsing, and command output formatting.

Sequence Diagram

sequenceDiagram
  participant User
  participant CLI
  participant Computers as SDK Computers
  participant Backend
  User->>CLI: computer port publish curie --port 8000
  CLI->>Computers: publish_port("curie", 8000)
  Computers->>Backend: POST /published-ports {port: 8000}
  Backend-->>Computers: {url, port, status, id}
  Computers-->>CLI: result dict
  CLI-->>User: print URL or JSON
  User->>CLI: computer port list curie --json
  CLI->>Computers: list_published_ports("curie")
  Computers->>Backend: GET /published-ports
  Backend-->>Computers: [port_info, ...]
  Computers-->>CLI: result list
  CLI-->>User: JSON array or Rich table
  User->>CLI: computer port unpublish curie --port 8000
  CLI->>Computers: unpublish_port("curie", 8000)
  Computers->>Backend: DELETE /published-ports/8000
  Backend-->>Computers: {status}
  Computers-->>CLI: result dict
  CLI-->>User: confirmation or JSON
Loading

🎯 3 (Moderate) | ⏱️ ~20 minutes

By order of the Peaky Blinders,
Ports are published, listed, unpublished clear,
Types and methods, three of a kind,
Tests ensure the whole affair's designed,
Strategic, organised, with proper mind.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add computer port publish commands' directly aligns with the primary changes: new SDK methods and CLI commands for publishing, listing, and unpublishing computer ports.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/published-sandbox-ports-sdk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread tests/test_computer_cli.py Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/celesto/sdk/client.py (1)

876-876: ⚠️ Potential issue | 🔴 Critical

Fix import-time crash in Computers.list_published_ports by avoiding list[...] annotation
Your class’s list() method at ~876 shadows the builtin list, so the -> list[dict[str, Any]] return type at ~911 gets evaluated during import and blows up with 'function' object is not subscriptable—use typing.List[...] instead.

💡 Suggested fix
-    def list_published_ports(self, computer_id: str) -> list[dict[str, Any]]:
+    def list_published_ports(self, computer_id: str) -> List[dict[str, Any]]:

Also applies to: 911-911

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/celesto/sdk/client.py` at line 876, The import-time crash is caused by
using the builtin shadowed name `list[...]` in return annotations inside the
Computers class (notably the `list` method and `list_published_ports`), which is
evaluated at import and fails; update those annotations to use typing.List
(e.g., `List[dict[str, Any]]`) and add the corresponding import (`from typing
import List`) so the annotations no longer attempt to subscript the shadowed
builtin `list`; keep the method names (`Computers.list`,
`Computers.list_published_ports`) unchanged.

Sources: Linters/SAST tools, Pipeline failures

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/celesto/sdk/client.py`:
- Line 876: The import-time crash is caused by using the builtin shadowed name
`list[...]` in return annotations inside the Computers class (notably the `list`
method and `list_published_ports`), which is evaluated at import and fails;
update those annotations to use typing.List (e.g., `List[dict[str, Any]]`) and
add the corresponding import (`from typing import List`) so the annotations no
longer attempt to subscript the shadowed builtin `list`; keep the method names
(`Computers.list`, `Computers.list_published_ports`) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3746aa34-6d19-4925-ad2d-468f669f9b79

📥 Commits

Reviewing files that changed from the base of the PR and between 895de29 and 569e0d6.

📒 Files selected for processing (5)
  • src/celesto/computer.py
  • src/celesto/sdk/client.py
  • src/celesto/sdk/types.py
  • tests/test_computer_cli.py
  • tests/test_sdk.py

aniketmaurya and others added 2 commits June 7, 2026 18:03
…ring sanitization'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@aniketmaurya
aniketmaurya merged commit 222f57f into main Jun 7, 2026
7 checks passed
@aniketmaurya
aniketmaurya deleted the codex/published-sandbox-ports-sdk branch June 7, 2026 17:29
@mintlify

mintlify Bot commented Jun 7, 2026

Copy link
Copy Markdown

Docs PR opened: CelestoAI/mintlify-docs#103

Added documentation for publishing, listing, and unpublishing computer ports via the Python SDK and CLI.

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