feat(examples): add Tenki Cloud sandbox TypeScript example - #3476
Open
camcalaquian wants to merge 2 commits into
Open
feat(examples): add Tenki Cloud sandbox TypeScript example#3476camcalaquian wants to merge 2 commits into
camcalaquian wants to merge 2 commits into
Conversation
Boot the headless OpenWork server inside a Tenki sandbox with the @tenkicloud/sandbox SDK, expose it on a public preview URL, and run the same smoke checks as the microsandbox Rust example (health, 401/200 token auth, OpenCode session create/read). Ephemeral by default with guaranteed termination on success, failure, and Ctrl+C; optional keep-alive mode for connecting the desktop app via Connect remote.
- Enforce the provisioning deadline locally: @tenkicloud/sandbox 0.5.4 declares ExecOptions.timeoutMs but does not apply it. - Fail fast (instead of hanging) when the server process exits early, including during keep-alive. - Install signal handlers before sandbox creation and terminate the live session carried by WaitReadyFailedError. - Memoize shutdown so signal handlers and finally cannot double-terminate. - Buffer partial log lines and decode UTF-8 across chunk boundaries. - Validate OPENWORK_PORT; drop the misleading arm64 branch (the npm package ships a single x86_64 binary); document the auto-approval trust model in the README.
Contributor
|
@camcalaquian is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
examples/tenki-openwork-ts: a small standalone TypeScript example that boots the headless OpenWork server inside a Tenki Cloud sandbox using the@tenkicloud/sandboxSDK, exposes it on a public preview URL, and verifies it end to end.It mirrors the smoke flow of
examples/microsandbox-openwork-rust:openwork-servernpm package (compiled Linux binary — no in-sandbox build) and the OpenCode release pinned in the repo-rootconstants.json(v1.17.11).OPENWORK_MANAGE_OPENCODE=1, same contract aspackaging/docker/microsandbox-entrypoint.sh./health, unauthenticated/workspaces→ 401, authenticated → 200,POST /w/:id/opencode/session, session + message reads.OPENWORK_TENKI_KEEP_ALIVE=1keeps it running for the desktop app's Add a worker → Connect remote flow; Ctrl+C terminates the sandbox.Sandbox lifecycle
Ephemeral by default. Termination is guaranteed via a memoized shutdown shared by
finallyand SIGINT/SIGTERM handlers (installed before sandbox creation), withmaxDurationMs/idleTimeoutMinutesbackstops if the process is killed outright. Verified after all test runs below by listing sessions by tag: 6 sessions total, 0 alive (including failed and interrupted runs).Tests run
pnpm typecheck— clean (strict, noany/as).pnpm starte2e against real Tenki sandboxes — 3 clean runs, all checks passed. Representative run: sandbox ready 2043 ms, provisioning 7000 ms, server ready 3385 ms, total 23133 ms (server ready= server spawn →/health200 through the public preview URL; total includes the ~9 s firstPOST .../opencode/session).The branch also went through an adversarial review pass before submission (second commit): a provisioning deadline enforced locally (the Tenki SDK's declared
ExecOptions.timeoutMsis a no-op in 0.5.4 — reported to Tenki as a bug), fail-fast when the server process exits early instead of hanging on health polls, signal handlers installed before sandbox creation, UTF-8-safe log line buffering, port validation, and a documentedOPENWORK_APPROVAL_MODE=autotrust model in the README.Testkit evidence tape: not applicable — this is a standalone example outside the pnpm workspace (like the Rust microsandbox example); it does not touch app/server runtime code. The example itself is the executable end-to-end check; validation needs a
TENKI_API_KEY, so it cannot run in CI. Repro steps are in the example README.Note: packaging bug found while testing
openwork-server@0.18.13on npm shipsdist/bin/openwork-serverwithout the executable bit, so thebin/openwork-server.mjswrapper fails withEACCESon Linux after a plainnpm install— the README quick start (npm install -g openwork-server && openwork-server ...) hits this too. The example works around it with achmod +xafter install (commented in the provision script). Happy to file/fix separately — likely a publish-pipeline fix (chmodbeforenpm publishor an install script).