local-api
できること
コマンドラインの代わりに、smolvmのローカルWeb APIを呼び出して、マシンの作成、コマンドの実行、ファイルのコピーの出し入れ、マシンの削除を行う方法を示します。smolvmの上にツールやエージェントを作る開発者向けです。
使う場面
- ✓マシンを作成して操作するツールやエージェントを作っているとき。
- ✓マシンにアップロードしたファイルが消えたとき。
- ✓APIが成功を返したのに、マシン内のコマンドが失敗しているように見えるとき。
スキルのリンク
https://github.com/smol-machines/smolvm/blob/main/docs/local-api/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“smolvmのマシンを作成し、その中でコマンドを実行し、終わったらマシンを削除する小さなスクリプトを書いてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
smolvmサーバーを起動し、HTTPリクエストを送ってマシンを作成し、コマンドを実行します。スキルは、200の応答がコマンドの成功を証明するわけではないと注意しており、終了コードを確認する必要があるとしています。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Driving smolvm over HTTP
Verified on smolvm v1.29.0 on macOS arm64, 2026-10-15, and on v1.18.2 on Linux aarch64, 2026-09-24. Done means a machine went through
its whole lifecycle over HTTP and GET /api/v1/machines/<name> answers NOT_FOUND at the end.
The Linux runs used the scripts of their date; this version's preflight and cleanup scripts ran
on Linux aarch64 on v1.22.2 on 2026-10-03.
Two rules run through everything here, and both are the same shape: a 200 is not a result.
- A failing guest command still returns HTTP 200. Assert
exitCodefrom the body. - Upload files only after the workload container is running. An upload before that returns 200 with the resolved path and byte count for a file that is then unreadable.
Procedure
1. Preflight.
scripts/preflight.sh
It reports auth=none_unless_mtls, which is not a warning about your setup: a server started the
way this packet starts it has no TLS, token or auth of any kind, so the transport you pick is the
access control. Mutual TLS exists, configured from the environment rather than by a flag;
references/traps.md has what it does and the plain listener it opens beside itself.
2. Start the server. A Unix socket is the default here, as it is smolvm's.
scripts/serve-start.sh
scripts/serve-start.sh --listen 127.0.0.1:8899
It waits for "status":"ok" from /health rather than for the process to exist, records the
listen address and pid for cleanup, and reports any Reclaimed N dangling VM data dir(es) line so
you do not later read those directories as a leak. Run again while the recorded server is up, it
prints result=already_serving with the recorded address and starts nothing, whatever --listen
says.
3. Export the spec before writing a request body. This is the step that saves the most time.
smolvm serve openapi -o ./openapi.json
The field names are the schema's, not the CLI's flags. network not net, memoryMb not
memory, and cmd for the workload you would pass after --. From v1.22.2 an unknown field is
refused with 422 and a message that names it; before that it was accepted with 200 and ignored.
references/api-fields.md has the full list and what each wrong name cost on older releases.
4. Run the lifecycle.
scripts/lifecycle-check.sh
Create, start, wait for the workload container to answer with a value, exec, exec a deliberately
failing command and assert its non-zero exitCode came back on a 200, stream, round-trip a file,
stop, delete, and assert the machine is gone:
created_state=ok (created)
started_state=ok (running)
workload_ready_after_s=0
workload_ready=ok (yes)
exec_exit_code=ok (0)
exec_stdout=ok
failing_exec_exit_code=ok (3)
stream_lines=ok (3)
stream_exit_event=ok
file_roundtrip=ok (PAYLOAD123)
machine_gone=ok (NOT_FOUND)
result=lifecycle_ok
5. Clean up, machines first.
scripts/cleanup.sh --purge
cleanup.sh waits up to 20 seconds, polling the machine list, and prints waiting=up to 20s
first: an ephemeral machine's entry retires after its run returns.
Order matters: stopping the server does not stop machines, which keep running after it exits. The script deletes recorded machines, then stops the server, then removes the socket.
The calls, in short
B=http://127.0.0.1:8899 # or: curl --unix-socket "$SOCK" http://localhost/...
curl $B/health
curl -X POST $B/api/v1/machines -H 'content-type: application/json' \
-d '{"name":"m","image":"python:3.12-alpine","network":true,"memoryMb":2048,
"cmd":["sh","-c","while true; do sleep 3600; done"]}'
curl -X POST $B/api/v1/machines/m/start -H 'content-type: application/json' -d '{}'
curl -X POST $B/api/v1/machines/m/exec -H 'content-type: application/json' \
-d '{"command":["sh","-c","echo hi"]}'
curl -N -X POST $B/api/v1/machines/m/exec/stream -H 'content-type: application/json' \
-d '{"command":["sh","-c","for i in 1 2 3; do echo line$i; sleep 1; done"]}'
curl -X PUT "$B/api/v1/machines/m/files/%2Ftmp%2Fabs.txt" --data-binary 'PAYLOAD'
curl "$B/api/v1/machines/m/files/%2Ftmp%2Fabs.txt"
curl -X POST $B/api/v1/machines/m/stop -H 'content-type: application/json' -d '{}'
curl -X DELETE $B/api/v1/machines/m
Paths in the files route are absolute and URL-encoded. exec returns stdout as text and as
base64; exec/stream emits one event: stdout per line then a terminal event: exit.
Traps
よくある質問
サーバーはパスワードで保護されていますか?
いいえ。スキルによると、サーバーはデフォルトではログインもトークンもありません。そのため、接続方法だけがアクセス制御になります。
なぜ終了コードを確認するのですか?
マシン内で失敗したコマンドでも、HTTPの200が返ることがあるため、本当の結果は応答の本体から読み取る必要があります。
いつファイルをアップロードできますか?
ワークロードのコンテナが実行中になってからだけです。それより前のアップロードは、成功と報告しても読めないファイルを残すことがあるためです。
詳細
作者による元の説明
Drives smolvm programmatically over its local HTTP API (smolvm serve) instead of the CLI: create machines, exec and stream commands, move files in and out, and tear them down. Use when building a client, harness, agent tool or MCP backend over smolvm; when a create call is accepted but the machine behaves as if a field was ignored; when a file uploaded over the API has disappeared; when an exec that failed still returned HTTP 200; or when choosing between the Unix socket and loopback TCP. Do not use it as a substitute for the CLI in a shell script, and do not bind a plain listener beyond loopb
repo: smol-machines/smolvm
人気
- GitHubのスター
- 6.9k
- ランキング
- #13721
- ライセンス
- Apache-2.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
branch-and-checkpoint
6.9kエージェントが、実行中のsmolvm仮想マシンをチェックポイントとして保存し、後で復元し、一時停止と再開をし、コピーとして分岐させられるよう支援します。
coding-agent
6.9kエージェントが、Claude Codeなどのコーディングエージェントを、プロジェクトフォルダをマウントした安全なsmolvm仮想マシンの中で動かせるよう支援します。
credentials
6.9kエージェントが、キーがその仮想マシンの中に入ることなく、あなたのキーでAPIを呼び出せるようにします。信頼できないコードがキーを読むことはできません。
dev-env
6.9kエージェントが、ツールをインストール済みのsmolvm開発マシンを保つ方法を教えます。マシンは素早く再起動し、セッションをまたいでパッケージを保持します。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。