core/abi/proto/v1/http.proto
Alex Dunmow 704b046727 feat(abi): wasm plugin ABI protobuf schema v1 (WO-WZ-001)
Defines the host<->guest wire contract for the .so -> wazero migration as a
repo-local buf module (abi/proto/v1, generated Go in abi/v1):

- manifest.proto: PluginManifest mirroring every static field of
  plugin.PluginRegistration (abi_version, deps, block/template registrations,
  admin pages, settings schema, theme presets, fonts, master pages, AI
  actions, RBAC method roles, CSS manifest, icon packs, directory
  extensions, job types, RAG fetcher types, settings panel, hook flags,
  core service bindings)
- invoke.proto: bn_invoke envelope, Hook catalog (RENDER_BLOCK,
  RENDER_TEMPLATE, HANDLE_HTTP, JOB, LOAD, UNLOAD, RAG_FETCH, MEDIA_HOOK,
  DESCRIBE), AbiError, and job/lifecycle/rag/media/describe payloads
- render.proto: RenderBlock/RenderTemplate payloads + RenderContext
  enumerating every ctx value from blocks/context.go (incl. BlockContext 1:1)
- http.proto: buffered HttpRequest/HttpResponse for HANDLE_HTTP
- db.proto: guest sql-driver messages (DbValue oneof over pgx-mappable
  types, query/exec/tx with host-side tx handles, SQLSTATE-carrying DbError)
- capability.proto: HostCall envelope + one request/response pair per
  CoreServices interface method (content, settings+update, gating, crypto,
  menus, datasources, users, subscriptions, media.deposit, email.send,
  ai.text_call, ai.tools.register, bridge, jobs.submit, embeddings, rag,
  reviews, badges.refresh)

The abi/ buf module is deliberately separate from the repo-root config:
proto/ is the shared block/proto submodule (service API contracts); the ABI
is SDK-internal and versions in lockstep with the guest shim. New `make abi`
target runs buf lint + generate. docs/wasm-abi.md documents the ptr+len
calling convention (bn_alloc, bn_invoke, packed u64), hook catalog, error
semantics, abi_version evolution rules, and the full registration/
CoreServices coverage tables.

Verified: `cd abi && buf lint` exit 0; `go build ./...` exit 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 12:47:00 +08:00

38 lines
1.0 KiB
Protocol Buffer

// http.proto — buffered HTTP request/response payloads for the HANDLE_HTTP
// hook (WO-WZ-001).
//
// v1 buffers full bodies: no streaming, SSE, or WebSockets inside plugins
// (per the wasm migration design spec §5). The guest runs its real
// chi/connect mux internally and answers one HttpRequest with one
// HttpResponse.
syntax = "proto3";
package abi.v1;
option go_package = "git.dev.alexdunmow.com/block/core/abi/v1;abiv1";
// HttpRequest is a fully buffered HTTP request forwarded to the guest mux.
message HttpRequest {
string method = 1;
// Request path (no scheme/host/query).
string path = 2;
// Raw query string (without the leading '?').
string raw_query = 3;
// Canonical header name → values.
map<string, HeaderValues> headers = 4;
bytes body = 5;
}
// HeaderValues holds the values of one multi-valued HTTP header.
message HeaderValues {
repeated string values = 1;
}
// HttpResponse is the guest's fully buffered response.
message HttpResponse {
int32 status = 1;
map<string, HeaderValues> headers = 2;
bytes body = 3;
}