feat: add authorized Plugin Ticket data capabilities
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package yoi:host@2.1.0;
|
||||
|
||||
/// Handles are invocation-local selectors, not durable authorization.
|
||||
interface objects {
|
||||
use yoi:host/errors@2.0.0.{host-error};
|
||||
enum access { read, extension-write }
|
||||
resource ticket;
|
||||
resolve-ticket: func(ticket-ref: string, requested: access) -> result<ticket, host-error>;
|
||||
}
|
||||
|
||||
interface ticket-read {
|
||||
use yoi:host/errors@2.0.0.{host-error};
|
||||
use objects.{ticket};
|
||||
enum case-state { open, closed }
|
||||
record snapshot {
|
||||
title: string,
|
||||
state: case-state,
|
||||
content-digest: string,
|
||||
body: string,
|
||||
truncated: bool,
|
||||
}
|
||||
read: func(target: borrow<ticket>) -> result<snapshot, host-error>;
|
||||
}
|
||||
|
||||
interface extension-data {
|
||||
use yoi:host/errors@2.0.0.{host-error};
|
||||
use objects.{ticket};
|
||||
record collection {
|
||||
collection: string,
|
||||
schema-id: string,
|
||||
schema-version: string,
|
||||
}
|
||||
record address { namespace: collection, key: string }
|
||||
variant expectation { never-written, last-write(string) }
|
||||
record present-cell { value-json: string, last-write: string }
|
||||
variant cell { never-written, present(present-cell), deleted(string) }
|
||||
record receipt { mutation-id: string, result-digest: string }
|
||||
variant mutation-lookup { not-recorded, committed(receipt), expired }
|
||||
record entry { key: string, value: cell }
|
||||
record page { entries: list<entry>, next-cursor: option<string> }
|
||||
get: func(target: borrow<ticket>, cell-address: address) -> result<cell, host-error>;
|
||||
put: func(target: borrow<ticket>, cell-address: address, expected: expectation, operation-key: string, value-json: string) -> result<receipt, host-error>;
|
||||
delete: func(target: borrow<ticket>, cell-address: address, expected-last-write: string, operation-key: string) -> result<receipt, host-error>;
|
||||
%list: func(target: borrow<ticket>, namespace: collection, cursor: option<string>, limit: u32) -> result<page, host-error>;
|
||||
lookup-mutation: func(target: borrow<ticket>, cell-address: address, operation-key: string) -> result<mutation-lookup, host-error>;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package yoi:host@2.0.0;
|
||||
|
||||
interface errors {
|
||||
enum code {
|
||||
invalid-input, denied, not-found, conflict, unsupported,
|
||||
quota-exceeded, deadline-exceeded, cancelled, unavailable,
|
||||
indeterminate, receipt-expired,
|
||||
}
|
||||
enum effect-observation { not-dispatched, response-observed, indeterminate }
|
||||
record host-error {
|
||||
code: code,
|
||||
message: string,
|
||||
diagnostic-id: string,
|
||||
effect: effect-observation,
|
||||
}
|
||||
}
|
||||
|
||||
interface connections {
|
||||
use errors.{host-error};
|
||||
/// Call-local resource. No serialization, persistence or cross-Worker transfer.
|
||||
resource connection;
|
||||
open: func(slot: string) -> result<connection, host-error>;
|
||||
}
|
||||
|
||||
interface http {
|
||||
use connections.{connection};
|
||||
use errors.{host-error};
|
||||
enum method { get, head, post, put, patch, delete, options }
|
||||
record pair { name: string, value: string }
|
||||
record request {
|
||||
method: method,
|
||||
path: string,
|
||||
query: list<pair>,
|
||||
headers: list<pair>,
|
||||
body: list<u8>,
|
||||
timeout-ms: u32,
|
||||
effect-key: string,
|
||||
}
|
||||
record response {
|
||||
status: u16,
|
||||
headers: list<pair>,
|
||||
body: list<u8>,
|
||||
}
|
||||
/// Host authorizes each operation and does not automatically retry or follow redirects.
|
||||
send: func(target: borrow<connection>, input: request) -> result<response, host-error>;
|
||||
}
|
||||
|
||||
interface logging {
|
||||
use errors.{host-error};
|
||||
enum level { trace, debug, info, warn, error }
|
||||
variant scalar { text(string), boolean(bool), signed(s64), unsigned(u64), number(f64) }
|
||||
record field { name: string, value: scalar }
|
||||
record entry {
|
||||
level: level,
|
||||
event-code: string,
|
||||
message: string,
|
||||
fields: list<field>,
|
||||
}
|
||||
/// Bounded diagnostic data, not model context. Never include secrets or raw payloads.
|
||||
log: func(input: entry) -> result<_, host-error>;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package yoi:plugin@2.0.0;
|
||||
|
||||
/// Only plugin-specific payloads use schema-validated JSON. Context is not authority.
|
||||
interface tool {
|
||||
record invocation {
|
||||
invocation-id: string,
|
||||
tool-name: string,
|
||||
input-json: string,
|
||||
config-json: string,
|
||||
remaining-ms: u32,
|
||||
}
|
||||
record output {
|
||||
summary: string,
|
||||
content: option<string>,
|
||||
structured-json: option<string>,
|
||||
}
|
||||
record tool-error {
|
||||
code: string,
|
||||
message: string,
|
||||
}
|
||||
invoke: func(input: invocation) -> result<output, tool-error>;
|
||||
}
|
||||
|
||||
/// Pure computation: no ambient WASI or unused Host capabilities.
|
||||
world tool-plugin {
|
||||
export tool;
|
||||
}
|
||||
|
||||
world https-tool-plugin {
|
||||
import yoi:host/errors@2.0.0;
|
||||
import yoi:host/connections@2.0.0;
|
||||
import yoi:host/http@2.0.0;
|
||||
export tool;
|
||||
}
|
||||
|
||||
/// Logging is an explicit capability, never an ambient console.
|
||||
world logged-tool-plugin {
|
||||
import yoi:host/errors@2.0.0;
|
||||
import yoi:host/logging@2.0.0;
|
||||
export tool;
|
||||
}
|
||||
|
||||
world https-logged-tool-plugin {
|
||||
import yoi:host/errors@2.0.0;
|
||||
import yoi:host/connections@2.0.0;
|
||||
import yoi:host/http@2.0.0;
|
||||
import yoi:host/logging@2.0.0;
|
||||
export tool;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package yoi:plugin@2.1.0;
|
||||
|
||||
/// Additive exact world: never augment an old @2.0.0 pin's imports or grants.
|
||||
world ticket-tool-plugin {
|
||||
include yoi:plugin/tool-plugin@2.0.0;
|
||||
import yoi:host/errors@2.0.0;
|
||||
import yoi:host/objects@2.1.0;
|
||||
import yoi:host/ticket-read@2.1.0;
|
||||
import yoi:host/extension-data@2.1.0;
|
||||
}
|
||||
Reference in New Issue
Block a user