feat: provide v2 Plugin Component contracts and offline validation

Validate exact Component interfaces and static Tool/DCDL schemas without guest execution. Share canonical archive packing and independent package/artifact verification; build real pure and HTTPS PDK fixtures and retire v1/Service authoring stubs.
This commit is contained in:
2026-10-28 13:31:47 +09:00
parent 06883c51b7
commit 2d195f4058
40 changed files with 3056 additions and 1662 deletions
@@ -0,0 +1,25 @@
package yoi:host@1.0.0;
/// Grant-bound one-shot HTTP request host API. Importing this interface does not grant
/// authority; package grants are checked before registration/execution and on
/// every host call.
interface request {
request: func(request-json: string) -> string;
}
/// Grant-bound host-owned WebSocket API. Authority requires a manifest `host_api.websocket`
/// target and an enablement grant; messages are delivered only by explicit bounded recv calls.
/// v1 supports text messages only and rejects guest-supplied handshake headers.
interface websocket {
open: func(request-json: string) -> string;
send-text: func(handle: u32, text: string) -> string;
recv: func(handle: u32, timeout-ms: u32) -> string;
close: func(handle: u32) -> string;
}
/// Grant-bound filesystem host API. No ambient WASI filesystem is exposed.
interface fs {
read: func(request-json: string) -> string;
%list: func(request-json: string) -> string;
write: func(request-json: string) -> string;
}
@@ -0,0 +1,59 @@
package yoi:plugin@1.0.0;
world instance {
import yoi:host/request@1.0.0;
import yoi:host/websocket@1.0.0;
import yoi:host/fs@1.0.0;
/// Start one host-managed Plugin instance. `config-json` is the opaque
/// enablement config copied from the Profile/plugin grant record. The return
/// string is PluginStatus JSON: `{ "state": "ready|running|stopped|...",
/// "data": <json> }`.
export start: func(config-json: string) -> string;
/// Execute a manifest-declared Tool on the shared instance. `input-json` is
/// ordinary Tool input JSON and the return string is ToolOutput JSON.
export handle-tool: func(name: string, input-json: string) -> string;
/// Handle one host-dispatched Service/Ingress event. `event-json` is an
/// ingress event envelope with at least:
///
/// ```json
/// {
/// "kind": "websocket_text|websocket_close|websocket_error|...",
/// "source": "websocket:wss://host/path|...",
/// "ingress_name": "manifest_ingress_name",
/// "payload": { "text": "..." },
/// "created_at": "RFC3339 timestamp",
/// "attempt": 1,
/// "correlation_id": "host event id"
/// }
/// ```
///
/// The return string is ServiceOutput JSON. To request host-mediated side
/// effects, return top-level `output_commands`, for example:
///
/// ```json
/// {
/// "accepted": true,
/// "output_commands": [{
/// "correlation_id": "command correlation id",
/// "source_event_id": "matching ingress correlation_id",
/// "command_id": "guest command id",
/// "kind": "websocket_send",
/// "payload": { "url": "wss://host/path", "text": "reply" },
/// "requested_at": "RFC3339 timestamp"
/// }]
/// }
/// ```
///
/// Output commands are parsed, bounded, grant-checked, and executed by the
/// host. They are not ordinary ToolOutput and do not inject hidden context.
export handle-ingress: func(name: string, event-json: string) -> string;
/// Return PluginStatus JSON for the shared host-managed instance.
export status: func() -> string;
/// Stop the shared instance and return final PluginStatus JSON.
export stop: func() -> string;
}
@@ -0,0 +1,12 @@
package yoi:plugin@1.0.0;
world tool {
import yoi:host/request@1.0.0;
import yoi:host/websocket@1.0.0;
import yoi:host/fs@1.0.0;
/// Execute a manifest-declared Tool. `input-json` is ordinary Tool input JSON
/// and the returned string is ToolOutput JSON accepted by the current
/// Component Model Plugin runtime.
export call: func(tool-name: string, input-json: string) -> string;
}