@syntropika/tembra-sdk 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -17
- package/dist/authoring/types.d.ts +64 -3
- package/dist/authoring/wit.d.ts +6 -0
- package/dist/bridge/commands.d.ts +1190 -0
- package/dist/bridge/identifiers.d.ts +2 -0
- package/dist/bridge/kernel.d.ts +18 -107
- package/dist/bridge/protocol.d.ts +3 -138
- package/dist/browser.d.ts +14 -1
- package/dist/browser.js +141 -3332
- package/dist/chunks/browser-b8jamxw2.js +3399 -0
- package/dist/chunks/execution-nsqc6nrt.js +1419 -0
- package/dist/chunks/index-01zk0xqx.js +160 -0
- package/dist/chunks/index-3fjdfdfd.js +152 -0
- package/dist/chunks/index-aaymjn7v.js +787 -0
- package/dist/chunks/index-c1w7z9hx.js +356 -0
- package/dist/chunks/index-h8t0n42q.js +738 -0
- package/dist/chunks/index-hfds9mzp.js +308 -0
- package/dist/chunks/index-kr4x67wt.js +177 -0
- package/dist/chunks/index-kr6bnh34.js +117 -0
- package/dist/chunks/index-kyt9dj0a.js +1421 -0
- package/dist/chunks/index-n1wxzc9w.js +830 -0
- package/dist/chunks/index-pvac426d.js +74 -0
- package/dist/chunks/index-smyds5ce.js +3234 -0
- package/dist/chunks/index-sse8aapb.js +121 -0
- package/dist/chunks/index-v6heph77.js +643 -0
- package/dist/chunks/index-xrdvnv37.js +3448 -0
- package/dist/chunks/index-za4mg94e.js +26 -0
- package/dist/chunks/index-zkqmnjj8.js +167 -0
- package/dist/coordinator.js +9 -500
- package/dist/error.d.ts +2 -0
- package/dist/errors.d.ts +3 -0
- package/dist/guest.d.ts +173 -0
- package/dist/guest.js +26 -0
- package/dist/host.d.ts +36 -30
- package/dist/host.js +37 -3310
- package/dist/http/bytes.d.ts +8 -0
- package/dist/http/events.d.ts +7 -0
- package/dist/http.d.ts +45 -0
- package/dist/http.js +291 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -862
- package/dist/infrastructure/rpc/client.d.ts +2 -1
- package/dist/infrastructure/rpc/resources.d.ts +28 -0
- package/dist/interpreter/abi.d.ts +54 -0
- package/dist/interpreter/acquire.d.ts +18 -0
- package/dist/interpreter/browser-network.d.ts +52 -0
- package/dist/interpreter/browser-port.d.ts +55 -0
- package/dist/interpreter/browser.d.ts +79 -0
- package/dist/interpreter/cli.d.ts +5 -0
- package/dist/interpreter/codec.d.ts +42 -0
- package/dist/interpreter/component/execution.d.ts +42 -0
- package/dist/interpreter/component/host.d.ts +69 -0
- package/dist/interpreter/component/instance.d.ts +40 -0
- package/dist/interpreter/component/kernel.d.ts +120 -0
- package/dist/interpreter/component/names.d.ts +5 -0
- package/dist/interpreter/component/port.d.ts +85 -0
- package/dist/interpreter/component/prepared.d.ts +97 -0
- package/dist/interpreter/component/resources.d.ts +45 -0
- package/dist/interpreter/component/revision.d.ts +87 -0
- package/dist/interpreter/component/scope.d.ts +116 -0
- package/dist/interpreter/component/streams.d.ts +28 -0
- package/dist/interpreter/component/values.d.ts +79 -0
- package/dist/interpreter/component/wasi-filesystem.d.ts +21 -0
- package/dist/interpreter/component/wasi-host.d.ts +64 -0
- package/dist/interpreter/component/wasi-http.d.ts +33 -0
- package/dist/interpreter/component/wasi-sockets.d.ts +183 -0
- package/dist/interpreter/component/wasi.d.ts +41 -0
- package/dist/interpreter/core.d.ts +64 -0
- package/dist/interpreter/fetch-http-provider.d.ts +17 -0
- package/dist/interpreter/filesystem/contract.d.ts +85 -0
- package/dist/interpreter/filesystem/memory.d.ts +3 -0
- package/dist/interpreter/filesystem/opfs.d.ts +3 -0
- package/dist/interpreter/filesystem/scope.d.ts +35 -0
- package/dist/interpreter/filesystem.d.ts +8 -0
- package/dist/interpreter/gate.d.ts +6 -0
- package/dist/interpreter/host-protocol.d.ts +100 -0
- package/dist/interpreter/http-ingress-fetch.d.ts +7 -0
- package/dist/interpreter/http-ingress.d.ts +96 -0
- package/dist/interpreter/http-provider.d.ts +85 -0
- package/dist/interpreter/io.d.ts +20 -0
- package/dist/interpreter/mobile.d.ts +149 -0
- package/dist/interpreter/native-ingress.d.ts +95 -0
- package/dist/interpreter/node-port.d.ts +25 -0
- package/dist/interpreter/node.d.ts +36 -0
- package/dist/interpreter/revision.d.ts +64 -0
- package/dist/interpreter/scope.d.ts +89 -0
- package/dist/interpreter/socket-addresses.d.ts +50 -0
- package/dist/interpreter/socket-provider.d.ts +110 -0
- package/dist/interpreter/standard-cli.d.ts +34 -0
- package/dist/interpreter/standard-codec.d.ts +96 -0
- package/dist/interpreter/standard-filesystem.d.ts +47 -0
- package/dist/interpreter/standard-host.d.ts +71 -0
- package/dist/interpreter/standard-http-values.d.ts +159 -0
- package/dist/interpreter/standard-http.d.ts +9 -0
- package/dist/interpreter/standard-ingress.d.ts +63 -0
- package/dist/interpreter/standard-sockets.d.ts +177 -0
- package/dist/interpreter/standard-streams.d.ts +218 -0
- package/dist/interpreter/standard-system.d.ts +35 -0
- package/dist/interpreter/standard-utf8.d.ts +4 -0
- package/dist/interpreter/standard.d.ts +18 -0
- package/dist/interpreter/types.d.ts +152 -0
- package/dist/interpreter/wit-shape.d.ts +92 -0
- package/dist/manager.js +5 -332
- package/dist/msgpack.js +9 -615
- package/dist/node.d.ts +8 -1
- package/dist/node.js +248 -3321
- package/dist/rpc.js +196 -699
- package/dist/runtime/adapters.d.ts +120 -0
- package/dist/runtime/adapters.js +38 -0
- package/dist/runtime/calls.d.ts +7 -6
- package/dist/runtime/lifecycle.d.ts +3 -1
- package/dist/runtime/orbs.d.ts +5 -4
- package/dist/runtime/references.d.ts +27 -1
- package/dist/runtime/reload.d.ts +5 -3
- package/dist/runtime/scopes.d.ts +1 -1
- package/dist/runtime/signals.d.ts +4 -0
- package/dist/runtime/wit-client.d.ts +38 -0
- package/dist/telemetry.js +4 -25
- package/dist/tooling/build.d.ts +2 -2
- package/dist/tooling/client-resources.d.ts +23 -0
- package/dist/tooling/client.d.ts +10 -0
- package/dist/tooling/component-glue.d.ts +17 -0
- package/dist/tooling/component.d.ts +11 -0
- package/dist/tooling/index.d.ts +3 -1
- package/dist/tooling/index.js +1155 -102
- package/dist/tooling/resolver.d.ts +4 -4
- package/dist/tooling/typecheck.d.ts +2 -1
- package/dist/tooling/types.d.ts +27 -12
- package/dist/tooling/wit.d.ts +9 -0
- package/dist/wasi/wasi-clocks-types.d.ts +2 -0
- package/dist/wasi/wasi-http-client.d.ts +5 -0
- package/dist/wasi/wasi-http-types.d.ts +285 -0
- package/dist/wasi/wasi-sockets-ip-name-lookup.d.ts +23 -0
- package/dist/wasi/wasi-sockets-types.d.ts +146 -0
- package/package.json +62 -35
- package/src/authoring/declaration.ts +1 -1
- package/src/authoring/types.ts +53 -3
- package/src/authoring/wit.ts +15 -0
- package/src/bridge/commands.ts +1105 -0
- package/src/bridge/identifiers.ts +2 -0
- package/src/bridge/kernel.ts +56 -98
- package/src/bridge/protocol.ts +3 -142
- package/src/browser.ts +90 -6
- package/src/context-key.ts +4 -7
- package/src/error.ts +1 -1
- package/src/errors.ts +7 -0
- package/src/guest.ts +327 -0
- package/src/host.ts +128 -23
- package/src/http/bytes.ts +87 -0
- package/src/http/events.ts +34 -0
- package/src/http.ts +272 -0
- package/src/index.ts +3 -0
- package/src/infrastructure/rpc/client.ts +136 -17
- package/src/infrastructure/rpc/resources.ts +123 -0
- package/src/interpreter/abi.ts +69 -0
- package/src/interpreter/acquire.ts +58 -0
- package/src/interpreter/browser-network.ts +170 -0
- package/src/interpreter/browser-port.ts +425 -0
- package/src/interpreter/browser.ts +340 -0
- package/src/interpreter/cli.ts +30 -0
- package/src/interpreter/codec.ts +298 -0
- package/src/interpreter/component/execution.ts +264 -0
- package/src/interpreter/component/host.ts +409 -0
- package/src/interpreter/component/instance.ts +138 -0
- package/src/interpreter/component/kernel.ts +611 -0
- package/src/interpreter/component/names.ts +13 -0
- package/src/interpreter/component/port.ts +598 -0
- package/src/interpreter/component/prepared.ts +194 -0
- package/src/interpreter/component/resources.ts +345 -0
- package/src/interpreter/component/revision.ts +702 -0
- package/src/interpreter/component/scope.ts +447 -0
- package/src/interpreter/component/streams.ts +180 -0
- package/src/interpreter/component/values.ts +254 -0
- package/src/interpreter/component/wasi-filesystem.ts +472 -0
- package/src/interpreter/component/wasi-host.ts +197 -0
- package/src/interpreter/component/wasi-http.ts +939 -0
- package/src/interpreter/component/wasi-sockets.ts +958 -0
- package/src/interpreter/component/wasi.ts +238 -0
- package/src/interpreter/core.ts +386 -0
- package/src/interpreter/fetch-http-provider.ts +98 -0
- package/src/interpreter/filesystem/contract.ts +138 -0
- package/src/interpreter/filesystem/memory.ts +180 -0
- package/src/interpreter/filesystem/opfs.ts +294 -0
- package/src/interpreter/filesystem/scope.ts +390 -0
- package/src/interpreter/filesystem.ts +20 -0
- package/src/interpreter/gate.ts +55 -0
- package/src/interpreter/host-protocol.ts +242 -0
- package/src/interpreter/http-ingress-fetch.ts +133 -0
- package/src/interpreter/http-ingress.ts +203 -0
- package/src/interpreter/http-provider.ts +105 -0
- package/src/interpreter/io.ts +66 -0
- package/src/interpreter/mobile.ts +385 -0
- package/src/interpreter/native-ingress.ts +550 -0
- package/src/interpreter/node-port.ts +218 -0
- package/src/interpreter/node.ts +114 -0
- package/src/interpreter/revision.ts +450 -0
- package/src/interpreter/scope.ts +453 -0
- package/src/interpreter/socket-addresses.ts +246 -0
- package/src/interpreter/socket-provider.ts +126 -0
- package/src/interpreter/standard-cli.ts +184 -0
- package/src/interpreter/standard-codec.ts +403 -0
- package/src/interpreter/standard-filesystem.ts +545 -0
- package/src/interpreter/standard-host.ts +840 -0
- package/src/interpreter/standard-http-values.ts +624 -0
- package/src/interpreter/standard-http.ts +622 -0
- package/src/interpreter/standard-ingress.ts +344 -0
- package/src/interpreter/standard-sockets.ts +847 -0
- package/src/interpreter/standard-streams.ts +710 -0
- package/src/interpreter/standard-system.ts +182 -0
- package/src/interpreter/standard-utf8.ts +72 -0
- package/src/interpreter/standard.ts +283 -0
- package/src/interpreter/types.ts +163 -0
- package/src/interpreter/wit-shape.ts +175 -0
- package/src/node.ts +43 -14
- package/src/runtime/activities.ts +6 -6
- package/src/runtime/adapters.ts +314 -0
- package/src/runtime/calls.ts +213 -90
- package/src/runtime/context.ts +7 -7
- package/src/runtime/lifecycle.ts +36 -17
- package/src/runtime/orbs.ts +81 -39
- package/src/runtime/programs.ts +16 -8
- package/src/runtime/references.ts +128 -11
- package/src/runtime/reload.ts +71 -30
- package/src/runtime/resources.ts +2 -2
- package/src/runtime/scopes.ts +17 -17
- package/src/runtime/session.ts +3 -1
- package/src/runtime/signals.ts +31 -0
- package/src/runtime/wit-client.ts +228 -0
- package/src/tooling/build.ts +152 -54
- package/src/tooling/client-resources.ts +74 -0
- package/src/tooling/client.ts +531 -0
- package/src/tooling/component-glue.ts +288 -0
- package/src/tooling/component.ts +225 -0
- package/src/tooling/index.ts +3 -7
- package/src/tooling/resolver.ts +42 -25
- package/src/tooling/typecheck.ts +59 -4
- package/src/tooling/types.ts +27 -12
- package/src/tooling/wit.ts +188 -0
- package/dist/embedded.d.ts +0 -1
- package/dist/embedded.js +0 -1
- package/src/embedded.ts +0 -301
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard `wasi:sockets` (TCP, UDP) and `wasi:sockets/ip-name-lookup` for the browser
|
|
3
|
+
* standard host, over an injected `SocketProvider` (`socket-provider.ts`). Browsers have no
|
|
4
|
+
* ambient sockets.
|
|
5
|
+
*
|
|
6
|
+
* Every call follows one order, so a refusal never reaches the provider:
|
|
7
|
+
* 1. argument and state checks, as pinned upstream `wasmtime-wasi` 51.0.0-rc.1;
|
|
8
|
+
* 2. the exact grant of the provider bound to that WIT import (`access-denied`);
|
|
9
|
+
* 3. provider capability (`not-supported`; name lookup `permanent-resolver-failure`);
|
|
10
|
+
* 4. the provider call.
|
|
11
|
+
*
|
|
12
|
+
* Ownership follows WASI's shared model: a socket handle and each stream derived from it hold
|
|
13
|
+
* one reference to the provider backend. Dropping the handle leaves its streams working; a
|
|
14
|
+
* dropped receive stream shuts down reads; the last reference closes the backend. Accepted
|
|
15
|
+
* sockets are independent. Every closing promise is physical work tracked by the host.
|
|
16
|
+
*/
|
|
17
|
+
import type { ErrorCode, IpAddress, IpAddressFamily, IpSocketAddress } from "../wasi/wasi-sockets-types.js";
|
|
18
|
+
import type { ErrorCode as LookupErrorCode } from "../wasi/wasi-sockets-ip-name-lookup.js";
|
|
19
|
+
import type { SocketAccess } from "./browser-network.ts";
|
|
20
|
+
import { type TcpBackend, type TcpConnection, type UdpBackend } from "./socket-provider.ts";
|
|
21
|
+
import { HostFuture, type Implementation, type InputStream, OutputStream, type StandardCall, type StandardResource, type StandardServices } from "./standard-streams.ts";
|
|
22
|
+
type Result<T, E> = {
|
|
23
|
+
tag: "ok";
|
|
24
|
+
val: T;
|
|
25
|
+
} | {
|
|
26
|
+
tag: "err";
|
|
27
|
+
val: E;
|
|
28
|
+
};
|
|
29
|
+
/** The providers bound to this revision's socket and lookup imports. */
|
|
30
|
+
export interface SocketBindings {
|
|
31
|
+
readonly types?: SocketAccess | undefined;
|
|
32
|
+
readonly lookup?: SocketAccess | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** One provider backend shared by a socket handle and its streams; the last user closes it. */
|
|
35
|
+
declare class Shared<B extends {
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}> {
|
|
38
|
+
#private;
|
|
39
|
+
readonly host: StandardServices;
|
|
40
|
+
readonly backend: B;
|
|
41
|
+
constructor(host: StandardServices, backend: B);
|
|
42
|
+
retain(): void;
|
|
43
|
+
release(): void;
|
|
44
|
+
}
|
|
45
|
+
/** Handle-table reference counting, as for every standard resource. */
|
|
46
|
+
declare abstract class SocketResource implements StandardResource {
|
|
47
|
+
#private;
|
|
48
|
+
borrows: number;
|
|
49
|
+
retain(): void;
|
|
50
|
+
release(): void;
|
|
51
|
+
protected abstract close(): void;
|
|
52
|
+
}
|
|
53
|
+
/** `wasi:sockets/types#tcp-socket`. */
|
|
54
|
+
export declare class TcpSocket extends SocketResource {
|
|
55
|
+
#private;
|
|
56
|
+
readonly access: SocketAccess;
|
|
57
|
+
readonly family: IpAddressFamily;
|
|
58
|
+
readonly shared: Shared<TcpBackend>;
|
|
59
|
+
constructor(access: SocketAccess, family: IpAddressFamily, shared: Shared<TcpBackend>, connection?: TcpConnection);
|
|
60
|
+
protected close(): void;
|
|
61
|
+
bind(local: IpSocketAddress): Result<void, ErrorCode>;
|
|
62
|
+
connect(remote: IpSocketAddress, call: StandardCall): Promise<Result<void, ErrorCode>>;
|
|
63
|
+
listen(call: StandardCall): Result<OutputStream, ErrorCode>;
|
|
64
|
+
send(data: InputStream, call: StandardCall): HostFuture;
|
|
65
|
+
receive(call: StandardCall): [OutputStream, HostFuture];
|
|
66
|
+
getLocalAddress(): Result<IpSocketAddress, ErrorCode>;
|
|
67
|
+
getRemoteAddress(): Result<IpSocketAddress, ErrorCode>;
|
|
68
|
+
getIsListening(): boolean;
|
|
69
|
+
getAddressFamily(): IpAddressFamily;
|
|
70
|
+
setListenBacklogSize(value: bigint): Result<void, ErrorCode>;
|
|
71
|
+
getKeepAliveEnabled(): Result<boolean, ErrorCode>;
|
|
72
|
+
setKeepAliveEnabled(value: boolean): {
|
|
73
|
+
tag: "err";
|
|
74
|
+
val: ErrorCode;
|
|
75
|
+
} | {
|
|
76
|
+
tag: "ok";
|
|
77
|
+
val: void;
|
|
78
|
+
};
|
|
79
|
+
getKeepAliveIdleTime(): Result<bigint, ErrorCode>;
|
|
80
|
+
setKeepAliveIdleTime(value: bigint): {
|
|
81
|
+
tag: "err";
|
|
82
|
+
val: ErrorCode;
|
|
83
|
+
} | {
|
|
84
|
+
tag: "ok";
|
|
85
|
+
val: void;
|
|
86
|
+
};
|
|
87
|
+
getKeepAliveInterval(): Result<bigint, ErrorCode>;
|
|
88
|
+
setKeepAliveInterval(value: bigint): {
|
|
89
|
+
tag: "err";
|
|
90
|
+
val: ErrorCode;
|
|
91
|
+
} | {
|
|
92
|
+
tag: "ok";
|
|
93
|
+
val: void;
|
|
94
|
+
};
|
|
95
|
+
getKeepAliveCount(): Result<number, ErrorCode>;
|
|
96
|
+
setKeepAliveCount(value: number): {
|
|
97
|
+
tag: "err";
|
|
98
|
+
val: ErrorCode;
|
|
99
|
+
} | {
|
|
100
|
+
tag: "ok";
|
|
101
|
+
val: void;
|
|
102
|
+
};
|
|
103
|
+
getHopLimit(): Result<number, ErrorCode>;
|
|
104
|
+
setHopLimit(value: number): {
|
|
105
|
+
tag: "err";
|
|
106
|
+
val: ErrorCode;
|
|
107
|
+
} | {
|
|
108
|
+
tag: "ok";
|
|
109
|
+
val: void;
|
|
110
|
+
};
|
|
111
|
+
getReceiveBufferSize(): Result<bigint, ErrorCode>;
|
|
112
|
+
setReceiveBufferSize(value: bigint): {
|
|
113
|
+
tag: "err";
|
|
114
|
+
val: ErrorCode;
|
|
115
|
+
} | {
|
|
116
|
+
tag: "ok";
|
|
117
|
+
val: void;
|
|
118
|
+
};
|
|
119
|
+
getSendBufferSize(): Result<bigint, ErrorCode>;
|
|
120
|
+
setSendBufferSize(value: bigint): {
|
|
121
|
+
tag: "err";
|
|
122
|
+
val: ErrorCode;
|
|
123
|
+
} | {
|
|
124
|
+
tag: "ok";
|
|
125
|
+
val: void;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** `wasi:sockets/types#udp-socket`. Peer association and receive filtering are host state. */
|
|
129
|
+
export declare class UdpSocket extends SocketResource {
|
|
130
|
+
#private;
|
|
131
|
+
readonly access: SocketAccess;
|
|
132
|
+
readonly family: IpAddressFamily;
|
|
133
|
+
readonly shared: Shared<UdpBackend>;
|
|
134
|
+
constructor(access: SocketAccess, family: IpAddressFamily, shared: Shared<UdpBackend>);
|
|
135
|
+
protected close(): void;
|
|
136
|
+
bind(local: IpSocketAddress): Result<void, ErrorCode>;
|
|
137
|
+
connect(remote: IpSocketAddress): Result<void, ErrorCode>;
|
|
138
|
+
disconnect(): Result<void, ErrorCode>;
|
|
139
|
+
send(data: Uint8Array, remote: IpSocketAddress | undefined, call: StandardCall): Promise<Result<void, ErrorCode>>;
|
|
140
|
+
receive(call: StandardCall): Promise<Result<[Uint8Array, IpSocketAddress], ErrorCode>>;
|
|
141
|
+
getLocalAddress(): Result<IpSocketAddress, ErrorCode>;
|
|
142
|
+
getRemoteAddress(): Result<IpSocketAddress, ErrorCode>;
|
|
143
|
+
getAddressFamily(): IpAddressFamily;
|
|
144
|
+
getUnicastHopLimit(): Result<number, ErrorCode>;
|
|
145
|
+
setUnicastHopLimit(value: number): {
|
|
146
|
+
tag: "err";
|
|
147
|
+
val: ErrorCode;
|
|
148
|
+
} | {
|
|
149
|
+
tag: "ok";
|
|
150
|
+
val: void;
|
|
151
|
+
};
|
|
152
|
+
getReceiveBufferSize(): Result<bigint, ErrorCode>;
|
|
153
|
+
setReceiveBufferSize(value: bigint): {
|
|
154
|
+
tag: "err";
|
|
155
|
+
val: ErrorCode;
|
|
156
|
+
} | {
|
|
157
|
+
tag: "ok";
|
|
158
|
+
val: void;
|
|
159
|
+
};
|
|
160
|
+
getSendBufferSize(): Result<bigint, ErrorCode>;
|
|
161
|
+
setSendBufferSize(value: bigint): {
|
|
162
|
+
tag: "err";
|
|
163
|
+
val: ErrorCode;
|
|
164
|
+
} | {
|
|
165
|
+
tag: "ok";
|
|
166
|
+
val: void;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/** The constructors and free function behind the generated binding, keyed by WIT role. */
|
|
170
|
+
export declare function socketStatics(bindings: SocketBindings): {
|
|
171
|
+
tcpCreate: (call: StandardCall, family: IpAddressFamily) => Result<TcpSocket, ErrorCode>;
|
|
172
|
+
udpCreate: (call: StandardCall, family: IpAddressFamily) => Result<UdpSocket, ErrorCode>;
|
|
173
|
+
resolveAddresses: (call: StandardCall, name: string) => Promise<Result<IpAddress[], LookupErrorCode>>;
|
|
174
|
+
};
|
|
175
|
+
/** Every generated `wasi:sockets` function, keyed for the standard host. */
|
|
176
|
+
export declare function socketMethods(bindings: SocketBindings): Record<string, Implementation>;
|
|
177
|
+
export {};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic ownership pieces of the browser standard WASI host: the services an implementation
|
|
3
|
+
* may use, revision-owned resources, one-shot futures, host-to-guest output streams and
|
|
4
|
+
* guest-to-host input streams. Nothing here knows a WASI interface; method implementations
|
|
5
|
+
* (`standard-filesystem.ts`, `standard-system.ts`) compose these pieces.
|
|
6
|
+
*/
|
|
7
|
+
import { type WasiMethod } from "./standard.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Implementation key of a generated method: resource functions are qualified by their resource
|
|
10
|
+
* (`<package>/<interface>#<resource>.<name>`), so `new`, `clone` or `consume-body` of different
|
|
11
|
+
* resources never collide. Free functions use `<interface>#<name>`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function methodKey(method: WasiMethod): string;
|
|
14
|
+
/** A WIT constructor or static function: the call, then its decoded parameters. */
|
|
15
|
+
export type StaticImplementation = (call: StandardCall, ...args: any[]) => unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Bind every generated function of one resource: constructors and statics to `statics` by
|
|
18
|
+
* generated name, methods to the same-named method of the borrowed `self`, which receives the
|
|
19
|
+
* decoded parameters followed by the call. A generated function without an implementation
|
|
20
|
+
* fails construction instead of a later call.
|
|
21
|
+
*/
|
|
22
|
+
export declare function bindResource(contract: string, resource: string, prototype: object, statics: Readonly<Record<string, StaticImplementation>>): Record<string, Implementation>;
|
|
23
|
+
/** Host services available to a method implementation. */
|
|
24
|
+
export interface StandardServices {
|
|
25
|
+
readonly packetBytes: number;
|
|
26
|
+
/** Whether the revision is retired; physical work is then refused. */
|
|
27
|
+
readonly closed: boolean;
|
|
28
|
+
/** Run an uncancellable provider operation under the revision's physical accounting. */
|
|
29
|
+
physical<T>(signal: AbortSignal | undefined, operation: () => Promise<T>): Promise<T>;
|
|
30
|
+
/** Track a destructor-like operation even while the revision is retiring. */
|
|
31
|
+
cleanup(operation: () => unknown): void;
|
|
32
|
+
}
|
|
33
|
+
/** One decoded call: the host services plus the owning callback's cancellation signal. */
|
|
34
|
+
export interface StandardCall {
|
|
35
|
+
readonly host: StandardServices;
|
|
36
|
+
readonly signal?: AbortSignal | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** One method implementation; it receives decoded jco-convention arguments. */
|
|
39
|
+
export type Implementation = (call: StandardCall, args: any) => unknown;
|
|
40
|
+
/** A host value behind an `own`/`borrow` handle; streams and calls retain it independently. */
|
|
41
|
+
export interface StandardResource {
|
|
42
|
+
/** Pending asynchronous calls that borrowed this resource. */
|
|
43
|
+
borrows: number;
|
|
44
|
+
retain(): void;
|
|
45
|
+
/** Release one user; the last release closes the underlying value. */
|
|
46
|
+
release(): void;
|
|
47
|
+
}
|
|
48
|
+
export declare const cancelled: () => Error;
|
|
49
|
+
/** Reject when `signal` aborts, without abandoning the physical operation's accounting. */
|
|
50
|
+
export declare function abortable<T>(operation: Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
51
|
+
/**
|
|
52
|
+
* A one-shot host-to-guest WIT future. `cancel` runs when the reply that would publish it, or
|
|
53
|
+
* the read that would deliver its value, can never reach the guest. A guest dropping the handle
|
|
54
|
+
* does not cancel the work behind it (as upstream `write-via-stream` results do not); the host
|
|
55
|
+
* only releases the value's owned resources when it arrives.
|
|
56
|
+
*/
|
|
57
|
+
export declare class HostFuture<T = unknown> {
|
|
58
|
+
readonly value: Promise<T>;
|
|
59
|
+
readonly cancel?: (() => void) | undefined;
|
|
60
|
+
constructor(value: Promise<T>, cancel?: (() => void) | undefined);
|
|
61
|
+
/** A future whose payload is already known. */
|
|
62
|
+
static of<T>(value: T): HostFuture<T>;
|
|
63
|
+
}
|
|
64
|
+
/** The readable end of a guest-written future, held by the call it was passed to. */
|
|
65
|
+
export interface FutureReader<T = unknown> {
|
|
66
|
+
/** The value once written; ownership of any resources inside it moves to the caller. */
|
|
67
|
+
take(): Promise<T>;
|
|
68
|
+
/** The consumer stopped: a written or later value is released, never delivered. */
|
|
69
|
+
close(): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A guest-to-host one-shot future created by FUTURE_NEW. One handle names its writer end
|
|
73
|
+
* (FUTURE_WRITE, DROP) and, until it is passed once as a call parameter, its readable end. A
|
|
74
|
+
* writer that ends unwritten (dropped, or its callback ended) resolves to `abandoned`, so a
|
|
75
|
+
* consumer never mistakes a vanished producer for a completed one.
|
|
76
|
+
*/
|
|
77
|
+
export declare class WritableFuture<T = unknown> implements FutureReader<T> {
|
|
78
|
+
#private;
|
|
79
|
+
readonly type: number;
|
|
80
|
+
readonly abandoned: T;
|
|
81
|
+
readonly release: (value: T) => void;
|
|
82
|
+
/** Set once the readable end was passed to a successful call. */
|
|
83
|
+
transferred: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* @param type the generated `TYPES` index of this future
|
|
86
|
+
* @param abandoned the value an unwritten writer resolves to; it carries no resources
|
|
87
|
+
* @param release releases the resources inside a value nobody will take
|
|
88
|
+
*/
|
|
89
|
+
constructor(type: number, abandoned: T, release: (value: T) => void);
|
|
90
|
+
/** Whether the writer end has ended (written or abandoned). */
|
|
91
|
+
get written(): boolean;
|
|
92
|
+
/** Accept the one value; the caller has already claimed every resource inside it. */
|
|
93
|
+
write(value: T): void;
|
|
94
|
+
/** The writer ended without a value. */
|
|
95
|
+
abandon(): void;
|
|
96
|
+
take(): Promise<T>;
|
|
97
|
+
close(): void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* How a host-to-guest stream ended: its producer reached the end (`eof`), the guest or the
|
|
101
|
+
* retiring revision dropped it first (`dropped`), or production failed (`failed`).
|
|
102
|
+
*/
|
|
103
|
+
export type StreamEnd = "eof" | "dropped" | "failed";
|
|
104
|
+
/** Producer of a `stream<u8>` output. `close` runs once, at the end with its reason. */
|
|
105
|
+
export interface ByteProducer {
|
|
106
|
+
/**
|
|
107
|
+
* At most `limit` bytes. `undefined` or an empty chunk is end of stream, so a producer whose
|
|
108
|
+
* source may yield empty chunks must skip them. A failure ends the stream.
|
|
109
|
+
*/
|
|
110
|
+
next(limit: number): Promise<Uint8Array | undefined>;
|
|
111
|
+
close(end?: StreamEnd): void;
|
|
112
|
+
}
|
|
113
|
+
/** Producer of a typed `stream<T>` output, one item at a time. */
|
|
114
|
+
export interface ItemProducer {
|
|
115
|
+
/** The next item, or `undefined` at end of stream. */
|
|
116
|
+
next(): Promise<unknown>;
|
|
117
|
+
close(end?: StreamEnd): void;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A host-to-guest stream. Reads are serialized; a read whose callback was cancelled keeps its
|
|
121
|
+
* produced data for the next read instead of losing it. A pending read fails immediately when
|
|
122
|
+
* the stream is dropped, while the producer's physical call stays tracked by its producer.
|
|
123
|
+
*/
|
|
124
|
+
export declare class OutputStream {
|
|
125
|
+
#private;
|
|
126
|
+
readonly producer: ByteProducer | ItemProducer;
|
|
127
|
+
readonly settle: (failure: unknown, end: StreamEnd) => void;
|
|
128
|
+
readonly release?: ((value: unknown) => void) | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* @param producer a byte producer for `stream<u8>`, an item producer for typed streams
|
|
131
|
+
* @param settle reports how the stream ended, with the producer's failure for `failed`
|
|
132
|
+
* @param release owned-item streams only: releases a produced value no read will deliver
|
|
133
|
+
*/
|
|
134
|
+
constructor(producer: ByteProducer | ItemProducer, settle: (failure: unknown, end: StreamEnd) => void, release?: ((value: unknown) => void) | undefined);
|
|
135
|
+
/** Drop by the guest or revision retirement. */
|
|
136
|
+
close(): void;
|
|
137
|
+
/** Whether the guest dropped the stream or the revision retired it. */
|
|
138
|
+
get closed(): boolean;
|
|
139
|
+
/** A produced read never reached its guest; later reads must not silently skip its data. */
|
|
140
|
+
abandon(): void;
|
|
141
|
+
/**
|
|
142
|
+
* Owned-item mode: serve one STREAM_READ with exactly one produced value, or `undefined` at
|
|
143
|
+
* end of stream. The value is not encoded and owns no handle yet: the host encodes and issues
|
|
144
|
+
* it in the reply. A read cancelled while the producer call runs leaves that call to the
|
|
145
|
+
* stream, and the next read takes its value, so a value is neither lost nor taken twice.
|
|
146
|
+
*/
|
|
147
|
+
take(signal?: AbortSignal): Promise<{
|
|
148
|
+
value: unknown;
|
|
149
|
+
} | undefined>;
|
|
150
|
+
/**
|
|
151
|
+
* Serve one STREAM_READ: the full reply (`u8 0` + chunk or `u8 1`). `limit` is a byte bound
|
|
152
|
+
* for byte streams and an item bound for typed streams; `bound` is the reply byte bound.
|
|
153
|
+
* `encodeItem`, supplied by the host from the stream's generated item type, selects the
|
|
154
|
+
* typed batch layout.
|
|
155
|
+
*/
|
|
156
|
+
read(limit: number, bound: number, signal?: AbortSignal, encodeItem?: (item: unknown) => Uint8Array): Promise<Uint8Array>;
|
|
157
|
+
}
|
|
158
|
+
/** Accepted input bytes per revision across all writers, matching the native budget. */
|
|
159
|
+
export declare const INPUT_BUDGET: number;
|
|
160
|
+
/**
|
|
161
|
+
* The revision's aggregate budget of accepted guest input. A chunk is reserved before it is
|
|
162
|
+
* copied out of its packet and stays reserved while it is buffered or waiting for room in its
|
|
163
|
+
* stream; it is released when its consumer takes it or the stream discards it. Waiters are
|
|
164
|
+
* served in order, so a large chunk is not starved by smaller ones.
|
|
165
|
+
*/
|
|
166
|
+
export declare class InputBudget {
|
|
167
|
+
#private;
|
|
168
|
+
readonly limit: number;
|
|
169
|
+
constructor(limit?: number);
|
|
170
|
+
/** Reserved bytes; never above `limit`. */
|
|
171
|
+
get used(): number;
|
|
172
|
+
/**
|
|
173
|
+
* Reserve `bytes`, waiting for capacity. `signal` (the callback) rejects with a cancellation;
|
|
174
|
+
* `interrupt` (the stream) rejects with its own reason. A rejected wait reserves nothing.
|
|
175
|
+
*/
|
|
176
|
+
reserve(bytes: number, signal?: AbortSignal, interrupt?: AbortSignal): Promise<void>;
|
|
177
|
+
release(bytes: number): void;
|
|
178
|
+
/** Account `stream` until it finished; `discard` reaches it until then. */
|
|
179
|
+
attach(stream: InputStream): void;
|
|
180
|
+
detach(stream: InputStream): void;
|
|
181
|
+
/**
|
|
182
|
+
* Revision retirement, after every consumer had its turn: cancel each stream that still
|
|
183
|
+
* holds bytes for a consumer that will never come, so the budget returns to zero.
|
|
184
|
+
*/
|
|
185
|
+
discard(): void;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* A guest-to-host `stream<u8>`: one bounded buffer of at most `STREAM_CHUNK` bytes, written by
|
|
189
|
+
* the guest through STREAM_WRITE and consumed by the method it was transferred to. Every
|
|
190
|
+
* buffered or pending byte holds a reservation in the revision's `InputBudget`.
|
|
191
|
+
*/
|
|
192
|
+
export declare class InputStream {
|
|
193
|
+
#private;
|
|
194
|
+
readonly type: number;
|
|
195
|
+
readonly budget: InputBudget;
|
|
196
|
+
/** Set once the readable end was passed to a successful call. */
|
|
197
|
+
transferred: boolean;
|
|
198
|
+
/** @param type the generated `TYPES` index of this stream */
|
|
199
|
+
constructor(type: number, budget: InputBudget);
|
|
200
|
+
/** Aborts when the consumer stopped (`cancel`), including revision retirement. */
|
|
201
|
+
get stopped(): AbortSignal;
|
|
202
|
+
/** Bytes accepted but not yet consumed; never above `STREAM_CHUNK`. */
|
|
203
|
+
get buffered(): number;
|
|
204
|
+
/** Whether the consumer stopped. */
|
|
205
|
+
get cancelled(): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Accept one whole chunk of `length` bytes. State is checked first; then the chunk is
|
|
208
|
+
* reserved in the aggregate budget, and only then copied with `copy`. One write may be in
|
|
209
|
+
* progress per stream; it completes once the chunk fits this stream's buffer.
|
|
210
|
+
*/
|
|
211
|
+
write(length: number, copy: () => Uint8Array, signal?: AbortSignal): Promise<void>;
|
|
212
|
+
/** Writer drop: end of stream after buffered bytes; a pending chunk is not delivered. */
|
|
213
|
+
close(): void;
|
|
214
|
+
/** The consumer stopped: later writes fail and buffered bytes are discarded. */
|
|
215
|
+
cancel(): void;
|
|
216
|
+
/** Next buffered bytes (at most `STREAM_CHUNK`), or `undefined` at end of stream. */
|
|
217
|
+
read(): Promise<Uint8Array | undefined>;
|
|
218
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Browser providers for the standard clock and random interfaces. */
|
|
2
|
+
import { type Implementation } from "./standard-streams.ts";
|
|
3
|
+
/** Signed seconds since the epoch plus a nonnegative fractional nanosecond part. */
|
|
4
|
+
export interface ClockInstant {
|
|
5
|
+
readonly seconds: bigint;
|
|
6
|
+
readonly nanoseconds: number;
|
|
7
|
+
}
|
|
8
|
+
/** Host clocks shared by WASI functions and the source VM's time imports. */
|
|
9
|
+
export interface ClockProvider {
|
|
10
|
+
systemNow(): ClockInstant;
|
|
11
|
+
systemResolution(): bigint;
|
|
12
|
+
monotonicNow(): bigint;
|
|
13
|
+
monotonicResolution(): bigint;
|
|
14
|
+
waitUntil(when: bigint, signal?: AbortSignal): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** Secure bytes must come from a cryptographic source; insecure methods make no such claim. */
|
|
17
|
+
export interface RandomProvider {
|
|
18
|
+
secure(length: number): Uint8Array;
|
|
19
|
+
insecure(length: number): Uint8Array;
|
|
20
|
+
insecureSeed(): readonly [bigint, bigint];
|
|
21
|
+
}
|
|
22
|
+
export interface SystemProviders {
|
|
23
|
+
readonly clocks?: ClockProvider | undefined;
|
|
24
|
+
readonly random?: RandomProvider | undefined;
|
|
25
|
+
}
|
|
26
|
+
/** Validate host clocks identically for standard calls and the interpreter's libc imports. */
|
|
27
|
+
export declare function checkedClocks(source: ClockProvider): ClockProvider;
|
|
28
|
+
/** Cache seed identity per revision, including when an injected provider generates fresh seeds. */
|
|
29
|
+
export declare function revisionRandom(source: RandomProvider): RandomProvider;
|
|
30
|
+
/** A fresh provider; its clock uses the browser's monotonic performance timeline. */
|
|
31
|
+
export declare function browserClocks(): ClockProvider;
|
|
32
|
+
/** The default never substitutes Math.random when cryptographic randomness is unavailable. */
|
|
33
|
+
export declare function browserRandom(): RandomProvider;
|
|
34
|
+
/** One method set per revision: in particular, get-insecure-seed stays stable for that Store. */
|
|
35
|
+
export declare function systemMethods(clocks: ClockProvider, random: RandomProvider): Record<string, Implementation>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One WIT type: a kind followed by indices into `TYPES` or names. */
|
|
2
|
+
export type WasiType = readonly [string, ...unknown[]];
|
|
3
|
+
/** One generated method; its index is the binary method number. */
|
|
4
|
+
export interface WasiMethod {
|
|
5
|
+
readonly interface: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly resource?: number;
|
|
8
|
+
/** Set for `[static]` functions and constructors, which have no `self` parameter. */
|
|
9
|
+
readonly kind?: "static" | "constructor";
|
|
10
|
+
readonly asynchronous: boolean;
|
|
11
|
+
readonly params: readonly number[];
|
|
12
|
+
readonly result?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const TYPES: readonly WasiType[];
|
|
15
|
+
export declare const RESOURCES: readonly string[];
|
|
16
|
+
export declare const METHODS: readonly WasiMethod[];
|
|
17
|
+
/** `TYPES` indices of the futures a guest may create (FUTURE_NEW) and write once. */
|
|
18
|
+
export declare const WRITABLE_FUTURES: readonly number[];
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { Lifetime } from "../bridge/identifiers.ts";
|
|
2
|
+
import type { KernelOrb } from "../bridge/kernel.ts";
|
|
3
|
+
/** A host-owned system directory registered as a filesystem provider. */
|
|
4
|
+
export interface DirectoryFilesystem {
|
|
5
|
+
readonly kind: "directory";
|
|
6
|
+
readonly path: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Description {
|
|
9
|
+
name?: string;
|
|
10
|
+
apiVersion?: number;
|
|
11
|
+
services: Record<string, {
|
|
12
|
+
methods: string[];
|
|
13
|
+
lifetime?: Lifetime;
|
|
14
|
+
linger?: number;
|
|
15
|
+
access?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
hooks?: Record<string, "series" | "waterfall" | "bail">;
|
|
18
|
+
contributes?: Record<string, number>;
|
|
19
|
+
}
|
|
20
|
+
export interface HookBinding {
|
|
21
|
+
name: string;
|
|
22
|
+
alias: string;
|
|
23
|
+
method: string;
|
|
24
|
+
slot: number;
|
|
25
|
+
signature: string;
|
|
26
|
+
composition: "series" | "waterfall" | "bail";
|
|
27
|
+
}
|
|
28
|
+
export interface ContributionBinding {
|
|
29
|
+
binding: string;
|
|
30
|
+
target: string;
|
|
31
|
+
name: string;
|
|
32
|
+
alias: string;
|
|
33
|
+
method: string;
|
|
34
|
+
slot: number;
|
|
35
|
+
signature: string;
|
|
36
|
+
priority: number;
|
|
37
|
+
optional: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface CheckedImplementation {
|
|
40
|
+
services: ServiceBinding[];
|
|
41
|
+
hooks: {
|
|
42
|
+
hooks: HookBinding[];
|
|
43
|
+
contributions: ContributionBinding[];
|
|
44
|
+
};
|
|
45
|
+
plan: InstallationPlan["plan"] & {
|
|
46
|
+
/** The incoming HTTP export served through `Host.handleHttp`, absent without one. */
|
|
47
|
+
ingress?: string | null;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What serves one WIT import: another Orb, a host provider, the kernel itself (`tembra:guest`,
|
|
52
|
+
* no provider and no grant), or the plan of a hook the importing Orb declares and also exports.
|
|
53
|
+
*/
|
|
54
|
+
export type ProviderBinding = {
|
|
55
|
+
kind: "orb";
|
|
56
|
+
name: string;
|
|
57
|
+
api_version: number;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "host";
|
|
60
|
+
provider: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: "kernel";
|
|
63
|
+
} | {
|
|
64
|
+
kind: "hook";
|
|
65
|
+
};
|
|
66
|
+
/** Checked install metadata; the kernel's generated types own shared lifecycle records. */
|
|
67
|
+
export interface InstallationPlan {
|
|
68
|
+
bindings: Record<string, ProviderBinding>;
|
|
69
|
+
importServices: Record<string, string>;
|
|
70
|
+
plan: {
|
|
71
|
+
orb: Pick<KernelOrb, "name" | "apiVersion" | "services" | "requires" | "hooks" | "hookSignatures">;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** WIT-checked implementation metadata returned by the Rust contract module. */
|
|
75
|
+
export interface ServiceBinding {
|
|
76
|
+
name: string;
|
|
77
|
+
interface: string;
|
|
78
|
+
alias: string;
|
|
79
|
+
/** Original WIT method names mapped to guest-facing JavaScript names. */
|
|
80
|
+
methods: Record<string, string>;
|
|
81
|
+
lifetime: Lifetime;
|
|
82
|
+
linger: number;
|
|
83
|
+
signature?: string;
|
|
84
|
+
}
|
|
85
|
+
/** One checked reference-view role of a compiled artifact, keyed by its import binding. */
|
|
86
|
+
export interface ReferenceBinding {
|
|
87
|
+
/** Versioned identity of the provider interface the view addresses. */
|
|
88
|
+
readonly interface: string;
|
|
89
|
+
/** Nominal identity of the view resource the importer declares. */
|
|
90
|
+
readonly resource: {
|
|
91
|
+
readonly interface: string;
|
|
92
|
+
readonly name: string;
|
|
93
|
+
};
|
|
94
|
+
/** Original WIT name of the acquisition function. */
|
|
95
|
+
readonly acquire: string;
|
|
96
|
+
/** Original WIT method names (`[method]R.name`) mapped to provider function names. */
|
|
97
|
+
readonly methods: Readonly<Record<string, string>>;
|
|
98
|
+
/** Interface digest of the derived provider service: the requirement signature. */
|
|
99
|
+
readonly signature: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ContractPort {
|
|
102
|
+
bind(binding: string, method: string, exports: boolean): number;
|
|
103
|
+
/** Check exact captured JSON text through a bound slot; answers the `{ ok }`/`{ error }` envelope. */
|
|
104
|
+
validate(slot: number, arguments_: boolean, value: string): string;
|
|
105
|
+
request(packet: string): string;
|
|
106
|
+
}
|
|
107
|
+
/** Host-issued authority stays local while only data crosses the Wasm boundary. */
|
|
108
|
+
export interface ExecutionScope {
|
|
109
|
+
readonly signal?: AbortSignal;
|
|
110
|
+
check(): void;
|
|
111
|
+
cancel(): void;
|
|
112
|
+
sync(request: import("./host-protocol.ts").HostRequest): unknown;
|
|
113
|
+
async(request: import("./host-protocol.ts").AsyncHostRequest): Promise<unknown>;
|
|
114
|
+
/** Publish a reply, rolling back an acquired reference if its observer abandoned it. */
|
|
115
|
+
deliver(request: import("./host-protocol.ts").AsyncHostRequest, value: unknown, publish: (value: unknown) => boolean): void;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* One exported WIT interface in the interpreter Load's function table. Each function is listed
|
|
119
|
+
* as `[id, JavaScript spelling]`, where the id is the export slot `ContractPort.bind` returns;
|
|
120
|
+
* `invoke` and `contribute` commands select functions only by that id. Mirrors
|
|
121
|
+
* `ExportedInterface` in `crates/executor-wasm/src/protocol.rs`.
|
|
122
|
+
*/
|
|
123
|
+
export interface ExportedInterface {
|
|
124
|
+
/** Versioned WIT interface identity; it also keys a contribution callback. */
|
|
125
|
+
readonly interface: string;
|
|
126
|
+
/** JavaScript service alias whose environments may call these functions. */
|
|
127
|
+
readonly service: string;
|
|
128
|
+
readonly functions: readonly (readonly [id: number, method: string])[];
|
|
129
|
+
}
|
|
130
|
+
/** The guest service and method that serve incoming HTTP in one environment. */
|
|
131
|
+
export interface IngressDispatch {
|
|
132
|
+
environment: number;
|
|
133
|
+
/** The guest's JavaScript service name for the `wasi:http/handler` export. */
|
|
134
|
+
service: string;
|
|
135
|
+
method: string;
|
|
136
|
+
}
|
|
137
|
+
export interface InterpreterPort {
|
|
138
|
+
release(environment: number): void | Promise<void>;
|
|
139
|
+
description(): string;
|
|
140
|
+
declare(packet: string, scope: ExecutionScope): unknown | Promise<unknown>;
|
|
141
|
+
execute(packet: string, scope: ExecutionScope): Promise<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Serve one incoming HTTP request; resolves only after the response delivery ended and the
|
|
144
|
+
* callback physically settled. Absent where this host cannot serve incoming HTTP yet.
|
|
145
|
+
*/
|
|
146
|
+
ingress?(dispatch: IngressDispatch, exchange: import("./http-ingress.ts").IngressExchange, scope: ExecutionScope): Promise<void>;
|
|
147
|
+
close(): void | Promise<void>;
|
|
148
|
+
}
|
|
149
|
+
/** Decode a platform result without treating guest error text as host authority. */
|
|
150
|
+
export declare function answer<T>(packet: string): T;
|
|
151
|
+
/** Reuse the prepared contract for installation planning. */
|
|
152
|
+
export declare function query<T>(contract: Pick<ContractPort, "request">, value: unknown): T;
|