मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)6.9k · #13721

local-api

यह क्या करती है

यह दिखाती है कि कमांड लाइन की जगह smolvm के लोकल वेब API को कॉल करके मशीनें कैसे बनाएँ, उनमें कमांड चलाएँ, फ़ाइलें अंदर-बाहर कॉपी करें, और उन्हें हटाएँ। यह उन डेवलपर्स के लिए है जो smolvm के ऊपर टूल या एजेंट बना रहे हैं।

कब इस्तेमाल करें

  • ✓जब आप ऐसा टूल या एजेंट बना रहे हों जिसे मशीनें बनानी और नियंत्रित करनी हों।
  • ✓जब मशीन में आपकी अपलोड की फ़ाइल गायब हो गई हो।
  • ✓जब API ने सफलता बताई हो, फिर भी मशीन में कमांड विफल लगे।

Skill का लिंक

https://github.com/smol-machines/smolvm/blob/main/docs/local-api/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/smol-machines/smolvm/blob/main/docs/local-api/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“एक छोटी स्क्रिप्ट लिखिए जो smolvm मशीन बनाए, उसमें एक कमांड चलाए, और काम पूरा होने पर मशीन हटा दे।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

आप smolvm सर्वर शुरू करते हैं और मशीनें बनाने व कमांड चलाने के लिए HTTP अनुरोध भेजते हैं। स्किल बताती है कि 200 जवाब यह साबित नहीं करता कि कमांड सफल हुई, इसलिए exit code जाँचना ज़रूरी है।

तकनीकी सामग्री (मूल 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.

  1. A failing guest command still returns HTTP 200. Assert exitCode from the body.
  2. 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

अक्सर पूछे जाने वाले सवाल

क्या सर्वर पासवर्ड से सुरक्षित है?

नहीं। स्किल कहती है कि सर्वर पर डिफ़ॉल्ट रूप से कोई लॉगिन या टोकन नहीं है, इसलिए आपका जुड़ने का तरीका ही एक्सेस नियंत्रण है।

exit code क्यों जाँचें?

मशीन के अंदर विफल हुई कमांड भी HTTP 200 लौटा सकती है, इसलिए असली नतीजा जवाब के बॉडी से पढ़ना होगा।

फ़ाइल कब अपलोड कर सकते हैं?

केवल workload कंटेनर चलने के बाद, क्योंकि पहले की अपलोड सफल बता सकती है और फिर भी फ़ाइल न पढ़ी जाने वाली रह सकती है।

जानकारी

लेखक का मूल विवरण

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
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

branch-and-checkpoint

6.9k

यह आपके एजेंट को चल रही smolvm वर्चुअल मशीन को चेकपॉइंट के रूप में सहेजने, बाद में वापस लाने, रोकने और फिर चालू करने, और उसे कॉपी में बाँटने में मदद करती है।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

coding-agent

6.9k

यह आपके एजेंट को smolvm की सुरक्षित वर्चुअल मशीन के अंदर Claude Code जैसे कोडिंग एजेंट चलाने में मदद करती है, जिसमें आपका प्रोजेक्ट फ़ोल्डर माउंट होता है।

AI और एजेंटएजेंट

credentials

6.9k

यह आपके एजेंट को आपकी key से API कॉल करने देती है, जबकि key कभी उसकी वर्चुअल मशीन के अंदर नहीं जाती, ताकि भरोसे के बाहर का कोड उसे न पढ़ सके।

कोडिंगसिक्योरिटी

dev-env

6.9k

यह आपके एजेंट को smolvm की डेव मशीन में इंस्टॉल किए टूल बनाए रखना सिखाती है, ताकि वह जल्दी रीस्टार्ट हो और सत्रों के बीच पैकेज बने रहें।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

मिलती-जुलती skills