simple
Version:
sha256:503bead
actor interface
init(state:option<list<u8>>, params:tuple<string>) → result<tuple<option<list<u8>>>, string>
environment interface
get-var(name:string) → option<string>
list-vars() → list<tuple<string, string>>
exists(name:string) → bool
filesystem interface
command-success:record {
stdout: string
stderr: string
exit-code: s32
}command-error:record {
message: string
}read-file(path:string) → result<list<u8>, string>
write-file(path:string, content:string) → result<_, string>
list-files(path:string) → result<list<string>, string>
delete-file(path:string) → result<_, string>
create-dir(path:string) → result<_, string>
delete-dir(path:string) → result<_, string>
path-exists(path:string) → result<bool, string>
execute-command(dir:string, command:string, args:list<string>) → result<command-result, string>
execute-nix-command(dir:string, command:string) → result<command-result, string>
http-types interface
bytes:list<u8>
http-request:record {
method: string
uri: string
headers: list<tuple<string, string>>
}tls-config:record {
cert-path: string
key-path: string
}server-info:record {
id: u64
port: u16
host: string
running: bool
routes-count: u32
middleware-count: u32
websocket-enabled: bool
}http-client interface
send-http(req:http-request) → result<http-response, string>
websocket-types interface
message-type:variant {
text
binary
connect
close
ping
pong
other(string)
}http-framework interface
Imported Types
theater:simple/http-types.{http-request}
theater:simple/http-types.{http-response}
theater:simple/http-types.{server-config}
theater:simple/http-types.{server-info}
theater:simple/http-types.{tls-config}
theater:simple/websocket-types.{websocket-message}
server-id:u64
handler-id:u64
route-id:u64
middleware-id:u64
create-server(config:server-config) → result<server-id, string>
get-server-info(server-id:server-id) → result<server-info, string>
start-server(server-id:server-id) → result<u16, string>
stop-server(server-id:server-id) → result<_, string>
destroy-server(server-id:server-id) → result<_, string>
register-handler(handler-name:string) → result<handler-id, string>
add-route(server-id:server-id, path:string, method:string, handler-id:handler-id) → result<route-id, string>
remove-route(route-id:route-id) → result<_, string>
add-middleware(server-id:server-id, path:string, handler-id:handler-id) → result<middleware-id, string>
remove-middleware(middleware-id:middleware-id) → result<_, string>
enable-websocket(server-id:server-id, path:string, connect-handler-id:option<handler-id>, message-handler-id:handler-id, disconnect-handler-id:option<handler-id>) → result<_, string>
send-websocket-message(server-id:server-id, connection-id:u64, message:websocket-message) → result<_, string>
close-websocket(server-id:server-id, connection-id:u64) → result<_, string>
http-handlers interface
Imported Types
theater:simple/http-types.{http-request}
theater:simple/http-types.{http-response}
theater:simple/websocket-types.{websocket-message}
theater:simple/http-types.{middleware-result}
theater:simple/http-framework.{handler-id}
handle-request(state:option<list<u8>>, params:tuple<handler-id, http-request>) → result<tuple<option<list<u8>>, tuple<http-response>>, string>
handle-middleware(state:option<list<u8>>, params:tuple<handler-id, http-request>) → result<tuple<option<list<u8>>, tuple<middleware-result>>, string>
handle-websocket-connect(state:option<list<u8>>, params:tuple<handler-id, u64, string, option<string>>) → result<tuple<option<list<u8>>>, string>
handle-websocket-message(state:option<list<u8>>, params:tuple<handler-id, u64, websocket-message>) → result<tuple<option<list<u8>>, tuple<list<websocket-message>>>, string>
handle-websocket-disconnect(state:option<list<u8>>, params:tuple<handler-id, u64>) → result<tuple<option<list<u8>>>, string>
process interface
output-mode:variant {
raw
line-by-line
json
chunked
}process-config:record {
program: string
args: list<string>
cwd: option<string>
env: list<tuple<string, string>>
buffer-size: u32
chunk-size: option<u32>
execution-timeout: option<u64>
}process-status:record {
pid: u64
running: bool
exit-code: option<s32>
start-time: u64
}os-write-stdin(pid:u64, data:list<u8>) → result<u32, string>
os-signal(pid:u64, signal:u32) → result<_, string>
os-kill(pid:u64) → result<_, string>
process-handlers interface
handle-stdout(state:option<list<u8>>, params:tuple<u64, list<u8>>) → result<tuple<option<list<u8>>>, string>
handle-stderr(state:option<list<u8>>, params:tuple<u64, list<u8>>) → result<tuple<option<list<u8>>>, string>
handle-exit(state:option<list<u8>>, params:tuple<u64, s32>) → result<tuple<option<list<u8>>>, string>
random interface
random-bytes(length:u32) → result<list<u8>, string>
random-range(min:u64, max:u64) → result<u64, string>
random-float() → result<f64, string>
generate-uuid() → result<string, string>
store interface
content-ref:record {
hash: string
}new() → result<string, string>
remove-label(store-id:string, label:string) → result<_, string>
replace-content-at-label(store-id:string, label:string, content:list<u8>) → result<content-ref, string>
list-labels(store-id:string) → result<list<string>, string>
calculate-total-size(store-id:string) → result<u64, string>
timing interface
now() → u64
sleep(duration:u64) → result<_, string>
deadline(timestamp:u64) → result<_, string>
types interface
actor-id:string
channel-id:string
channel-accept:record {
accepted: bool
message: option<list<u8>>
}event:record {
event-type: string
parent: option<u64>
data: list<u8>
}chain:record {}
chain-event:record {
hash: list<u8>
parent-hash: option<list<u8>>
event-type: string
data: list<u8>
timestamp: u64
}wit-error-type:enum {
operation-timeout
channel-closed
shutting-down
function-not-found
type-mismatch
internal
serialization-error
update-component-error
paused
}message-server-client interface
Imported Types
theater:simple/types.{event}
theater:simple/types.{channel-id}
theater:simple/types.{channel-accept}
handle-send(state:option<list<u8>>, params:tuple<list<u8>>) → result<tuple<option<list<u8>>>, string>
handle-request(state:option<list<u8>>, params:tuple<string, list<u8>>) → result<tuple<option<list<u8>>, tuple<option<list<u8>>>>, string>
handle-channel-open(state:option<list<u8>>, params:tuple<string, list<u8>>) → result<tuple<option<list<u8>>, tuple<channel-accept>>, string>
handle-channel-message(state:option<list<u8>>, params:tuple<channel-id, list<u8>>) → result<tuple<option<list<u8>>>, string>
handle-channel-close(state:option<list<u8>>, params:tuple<channel-id>) → result<tuple<option<list<u8>>>, string>
message-server-host interface
list-outstanding-requests() → list<string>
respond-to-request(request-id:string, response:list<u8>) → result<_, string>
cancel-request(request-id:string) → result<_, string>
runtime interface
supervisor interface
Imported Types
theater:simple/types.{chain-event}
spawn(manifest:string, init-bytes:option<list<u8>>) → result<string, string>
resume(manifest:string, init-state:option<list<u8>>) → result<string, string>
list-children() → list<string>
stop-child(child-id:string) → result<_, string>
restart-child(child-id:string) → result<_, string>
get-child-state(child-id:string) → result<option<list<u8>>, string>
supervisor-handlers interface
Imported Types
theater:simple/types.{wit-actor-error}
handle-child-error(state:option<list<u8>>, params:tuple<string, wit-actor-error>) → result<tuple<option<list<u8>>>, string>
handle-child-exit(state:option<list<u8>>, params:tuple<string, option<list<u8>>>) → result<tuple<option<list<u8>>>, string>
handle-child-external-stop(state:option<list<u8>>, params:tuple<string>) → result<tuple<option<list<u8>>>, string>
websocket-server interface
message-type:variant {
text
binary
connect
close
ping
pong
other(string)
}websocket-response:record {}
handle-message(state:option<list<u8>>, params:tuple<websocket-message>) → result<tuple<option<list<u8>>, tuple<websocket-response>>, string>