Skip to content

feat(runtime): implement HTTP hostcall for agent API access#24

Merged
simonovic86 merged 1 commit intomainfrom
feat/http-hostcall
Mar 13, 2026
Merged

feat(runtime): implement HTTP hostcall for agent API access#24
simonovic86 merged 1 commit intomainfrom
feat/http-hostcall

Conversation

@simonovic86
Copy link
Owner

Summary

  • Adds http_request hostcall to the capability membrane so WASM agents can make HTTP requests to external APIs (Product Phase 2, Task P2-1)
  • Host-side: allowed_hosts enforcement, timeout/size limits, eventlog recording for replay (CM-4), two-call ABI pattern for variable-length responses
  • SDK: HTTPRequest, HTTPGet, HTTPPost wrappers with auto-retry on buffer-too-small, plus native stubs and mock support for testing

Test plan

  • go test ./internal/hostcall/... — extractAllowedHosts, checkAllowedHost, parseHeaders, extractIntOption
  • go test ./sdk/igor/... — SDK compiles with updated MockBackend interface
  • go test ./... — all 25 packages pass
  • go build ./cmd/igord/ — product binary compiles
  • make check — fmt, vet, lint, tests all pass

🤖 Generated with Claude Code

Add http_request hostcall to the capability membrane so agents can make
HTTP requests to allowed external services. This is the single feature
that makes agents actually useful (Product Phase 2, Task P2-1).

Host-side (internal/hostcall/http.go):
- ABI: http_request(method, url, headers, body, resp_buf) -> i32
- Security: allowed_hosts enforcement from manifest options
- Timeout (10s default), max response size (1MB default)
- Two-call pattern: returns -5 with size hint when buffer too small
- Eventlog recording for deterministic replay (CM-4)

SDK WASM wrapper (sdk/igor/hostcalls_http_wasm.go):
- HTTPRequest, HTTPGet, HTTPPost convenience functions
- Auto-retry with larger buffer on -5 (response too large)

SDK native stubs (sdk/igor/hostcalls_http_stub.go):
- Dispatches to MockBackend for native testing

Mock support (sdk/igor/mock/mock.go):
- HTTPHandler type + SetHTTPHandler for test configuration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simonovic86 simonovic86 merged commit 1ed7cd9 into main Mar 13, 2026
1 check passed
@simonovic86 simonovic86 deleted the feat/http-hostcall branch March 13, 2026 14:36
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