Skip to content

wasm_call: call one function of a .wasm file from the command line (ADR 0014) - #455

Merged
ymote merged 1 commit into
mainfrom
feat/wasm-call
Oct 10, 2026
Merged

ymote merged 1 commit into
mainfrom
feat/wasm-call

Conversation

@ymote

@ymote ymote commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

This is part of the developer path for ADR 0014: checking an app's component or core module without a shell or a device. It is stacked on #454, which is stacked on #452. The three merge as a train on one local CI run.

crates/wasm-host/examples/wasm_call.rs loads the file with the wasm service's runtime and limits:

  • A component takes the JSON a script would pass to wasm.<function> (a bare value, an object by name, or an array in order), and its answer prints as JSON.
  • A core module takes the input as text and prints its output.
  • --storage DIR gives a component a storage folder.
  • A component's octosense:host calls fail with no host services in wasm_call: <service> needs a shell.
  • Each call gets a fresh instance.

Run (macOS):

  • wasm_call crates/wasm-host/tests/fixtures/notes.component.wasm to-html '"# Hi"' → "<h1>Hi</h1>\n"
  • … analyze '["# One\n\ntwo words"]' → {"headings": ["One"], "lines": 3, "words": 4}
  • … to_html 'not json' → the arguments are not JSON: …, exit 1
  • hostcall.component.wasm call '["notes.get", "{}"]' → no host services in wasm_call: notes.get needs a shell, exit 1
  • apps/wasmlab/bundle/fns/wasmlab.wasm md_to_html '# Hello *core*' → <h1>Hello <em>core</em></h1>
  • … fuzzy_rank '{"query":"oct","items":["octos","sense","octopus"]}' → {"ranked":[{"item":"octos","score":0.99},{"item":"octopus","score":0.98}]}

Docs: docs/wasm.md and docs/wasm.zh-CN.md, section "Calling a function from the command line".

🤖 Generated with Claude Code

A developer can now check a component or core module without a shell or a
device: the example loads the file with the wasm service's runtime and
limits, takes the JSON a script would pass (components) or the input text
(core modules), and prints the answer. --storage DIR gives a component a
storage folder; its octosense:host calls fail without a shell. Docs in
docs/wasm.md (English and Chinese), with the commands run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymote
ymote force-pushed the feat/wasm-shared-components branch from 740e1f6 to 5dc972b Compare October 10, 2026 05:24
@ymote
ymote changed the base branch from feat/wasm-shared-components to main October 10, 2026 05:39
@ymote
ymote merged commit cb24135 into main Oct 10, 2026
1 of 7 checks passed
@ymote

ymote commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Merged as part of a train (#452 → #454 → #455) on one local CI pass at the train's top head ddc3bd3. The run was tools/ci-local.sh --only apps,desktop,phone --linux-host --offload: ci-local: PASSED in 14m00s, every step passed and none was skipped. Main's tree after the three merges (cb24135) is 1ecabd25, the tested tree exactly.

🤖 Generated with Claude Code

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