@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.
Files changed (241) hide show
  1. package/README.md +43 -17
  2. package/dist/authoring/types.d.ts +64 -3
  3. package/dist/authoring/wit.d.ts +6 -0
  4. package/dist/bridge/commands.d.ts +1190 -0
  5. package/dist/bridge/identifiers.d.ts +2 -0
  6. package/dist/bridge/kernel.d.ts +18 -107
  7. package/dist/bridge/protocol.d.ts +3 -138
  8. package/dist/browser.d.ts +14 -1
  9. package/dist/browser.js +141 -3332
  10. package/dist/chunks/browser-b8jamxw2.js +3399 -0
  11. package/dist/chunks/execution-nsqc6nrt.js +1419 -0
  12. package/dist/chunks/index-01zk0xqx.js +160 -0
  13. package/dist/chunks/index-3fjdfdfd.js +152 -0
  14. package/dist/chunks/index-aaymjn7v.js +787 -0
  15. package/dist/chunks/index-c1w7z9hx.js +356 -0
  16. package/dist/chunks/index-h8t0n42q.js +738 -0
  17. package/dist/chunks/index-hfds9mzp.js +308 -0
  18. package/dist/chunks/index-kr4x67wt.js +177 -0
  19. package/dist/chunks/index-kr6bnh34.js +117 -0
  20. package/dist/chunks/index-kyt9dj0a.js +1421 -0
  21. package/dist/chunks/index-n1wxzc9w.js +830 -0
  22. package/dist/chunks/index-pvac426d.js +74 -0
  23. package/dist/chunks/index-smyds5ce.js +3234 -0
  24. package/dist/chunks/index-sse8aapb.js +121 -0
  25. package/dist/chunks/index-v6heph77.js +643 -0
  26. package/dist/chunks/index-xrdvnv37.js +3448 -0
  27. package/dist/chunks/index-za4mg94e.js +26 -0
  28. package/dist/chunks/index-zkqmnjj8.js +167 -0
  29. package/dist/coordinator.js +9 -500
  30. package/dist/error.d.ts +2 -0
  31. package/dist/errors.d.ts +3 -0
  32. package/dist/guest.d.ts +173 -0
  33. package/dist/guest.js +26 -0
  34. package/dist/host.d.ts +36 -30
  35. package/dist/host.js +37 -3310
  36. package/dist/http/bytes.d.ts +8 -0
  37. package/dist/http/events.d.ts +7 -0
  38. package/dist/http.d.ts +45 -0
  39. package/dist/http.js +291 -0
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +49 -862
  42. package/dist/infrastructure/rpc/client.d.ts +2 -1
  43. package/dist/infrastructure/rpc/resources.d.ts +28 -0
  44. package/dist/interpreter/abi.d.ts +54 -0
  45. package/dist/interpreter/acquire.d.ts +18 -0
  46. package/dist/interpreter/browser-network.d.ts +52 -0
  47. package/dist/interpreter/browser-port.d.ts +55 -0
  48. package/dist/interpreter/browser.d.ts +79 -0
  49. package/dist/interpreter/cli.d.ts +5 -0
  50. package/dist/interpreter/codec.d.ts +42 -0
  51. package/dist/interpreter/component/execution.d.ts +42 -0
  52. package/dist/interpreter/component/host.d.ts +69 -0
  53. package/dist/interpreter/component/instance.d.ts +40 -0
  54. package/dist/interpreter/component/kernel.d.ts +120 -0
  55. package/dist/interpreter/component/names.d.ts +5 -0
  56. package/dist/interpreter/component/port.d.ts +85 -0
  57. package/dist/interpreter/component/prepared.d.ts +97 -0
  58. package/dist/interpreter/component/resources.d.ts +45 -0
  59. package/dist/interpreter/component/revision.d.ts +87 -0
  60. package/dist/interpreter/component/scope.d.ts +116 -0
  61. package/dist/interpreter/component/streams.d.ts +28 -0
  62. package/dist/interpreter/component/values.d.ts +79 -0
  63. package/dist/interpreter/component/wasi-filesystem.d.ts +21 -0
  64. package/dist/interpreter/component/wasi-host.d.ts +64 -0
  65. package/dist/interpreter/component/wasi-http.d.ts +33 -0
  66. package/dist/interpreter/component/wasi-sockets.d.ts +183 -0
  67. package/dist/interpreter/component/wasi.d.ts +41 -0
  68. package/dist/interpreter/core.d.ts +64 -0
  69. package/dist/interpreter/fetch-http-provider.d.ts +17 -0
  70. package/dist/interpreter/filesystem/contract.d.ts +85 -0
  71. package/dist/interpreter/filesystem/memory.d.ts +3 -0
  72. package/dist/interpreter/filesystem/opfs.d.ts +3 -0
  73. package/dist/interpreter/filesystem/scope.d.ts +35 -0
  74. package/dist/interpreter/filesystem.d.ts +8 -0
  75. package/dist/interpreter/gate.d.ts +6 -0
  76. package/dist/interpreter/host-protocol.d.ts +100 -0
  77. package/dist/interpreter/http-ingress-fetch.d.ts +7 -0
  78. package/dist/interpreter/http-ingress.d.ts +96 -0
  79. package/dist/interpreter/http-provider.d.ts +85 -0
  80. package/dist/interpreter/io.d.ts +20 -0
  81. package/dist/interpreter/mobile.d.ts +149 -0
  82. package/dist/interpreter/native-ingress.d.ts +95 -0
  83. package/dist/interpreter/node-port.d.ts +25 -0
  84. package/dist/interpreter/node.d.ts +36 -0
  85. package/dist/interpreter/revision.d.ts +64 -0
  86. package/dist/interpreter/scope.d.ts +89 -0
  87. package/dist/interpreter/socket-addresses.d.ts +50 -0
  88. package/dist/interpreter/socket-provider.d.ts +110 -0
  89. package/dist/interpreter/standard-cli.d.ts +34 -0
  90. package/dist/interpreter/standard-codec.d.ts +96 -0
  91. package/dist/interpreter/standard-filesystem.d.ts +47 -0
  92. package/dist/interpreter/standard-host.d.ts +71 -0
  93. package/dist/interpreter/standard-http-values.d.ts +159 -0
  94. package/dist/interpreter/standard-http.d.ts +9 -0
  95. package/dist/interpreter/standard-ingress.d.ts +63 -0
  96. package/dist/interpreter/standard-sockets.d.ts +177 -0
  97. package/dist/interpreter/standard-streams.d.ts +218 -0
  98. package/dist/interpreter/standard-system.d.ts +35 -0
  99. package/dist/interpreter/standard-utf8.d.ts +4 -0
  100. package/dist/interpreter/standard.d.ts +18 -0
  101. package/dist/interpreter/types.d.ts +152 -0
  102. package/dist/interpreter/wit-shape.d.ts +92 -0
  103. package/dist/manager.js +5 -332
  104. package/dist/msgpack.js +9 -615
  105. package/dist/node.d.ts +8 -1
  106. package/dist/node.js +248 -3321
  107. package/dist/rpc.js +196 -699
  108. package/dist/runtime/adapters.d.ts +120 -0
  109. package/dist/runtime/adapters.js +38 -0
  110. package/dist/runtime/calls.d.ts +7 -6
  111. package/dist/runtime/lifecycle.d.ts +3 -1
  112. package/dist/runtime/orbs.d.ts +5 -4
  113. package/dist/runtime/references.d.ts +27 -1
  114. package/dist/runtime/reload.d.ts +5 -3
  115. package/dist/runtime/scopes.d.ts +1 -1
  116. package/dist/runtime/signals.d.ts +4 -0
  117. package/dist/runtime/wit-client.d.ts +38 -0
  118. package/dist/telemetry.js +4 -25
  119. package/dist/tooling/build.d.ts +2 -2
  120. package/dist/tooling/client-resources.d.ts +23 -0
  121. package/dist/tooling/client.d.ts +10 -0
  122. package/dist/tooling/component-glue.d.ts +17 -0
  123. package/dist/tooling/component.d.ts +11 -0
  124. package/dist/tooling/index.d.ts +3 -1
  125. package/dist/tooling/index.js +1155 -102
  126. package/dist/tooling/resolver.d.ts +4 -4
  127. package/dist/tooling/typecheck.d.ts +2 -1
  128. package/dist/tooling/types.d.ts +27 -12
  129. package/dist/tooling/wit.d.ts +9 -0
  130. package/dist/wasi/wasi-clocks-types.d.ts +2 -0
  131. package/dist/wasi/wasi-http-client.d.ts +5 -0
  132. package/dist/wasi/wasi-http-types.d.ts +285 -0
  133. package/dist/wasi/wasi-sockets-ip-name-lookup.d.ts +23 -0
  134. package/dist/wasi/wasi-sockets-types.d.ts +146 -0
  135. package/package.json +62 -35
  136. package/src/authoring/declaration.ts +1 -1
  137. package/src/authoring/types.ts +53 -3
  138. package/src/authoring/wit.ts +15 -0
  139. package/src/bridge/commands.ts +1105 -0
  140. package/src/bridge/identifiers.ts +2 -0
  141. package/src/bridge/kernel.ts +56 -98
  142. package/src/bridge/protocol.ts +3 -142
  143. package/src/browser.ts +90 -6
  144. package/src/context-key.ts +4 -7
  145. package/src/error.ts +1 -1
  146. package/src/errors.ts +7 -0
  147. package/src/guest.ts +327 -0
  148. package/src/host.ts +128 -23
  149. package/src/http/bytes.ts +87 -0
  150. package/src/http/events.ts +34 -0
  151. package/src/http.ts +272 -0
  152. package/src/index.ts +3 -0
  153. package/src/infrastructure/rpc/client.ts +136 -17
  154. package/src/infrastructure/rpc/resources.ts +123 -0
  155. package/src/interpreter/abi.ts +69 -0
  156. package/src/interpreter/acquire.ts +58 -0
  157. package/src/interpreter/browser-network.ts +170 -0
  158. package/src/interpreter/browser-port.ts +425 -0
  159. package/src/interpreter/browser.ts +340 -0
  160. package/src/interpreter/cli.ts +30 -0
  161. package/src/interpreter/codec.ts +298 -0
  162. package/src/interpreter/component/execution.ts +264 -0
  163. package/src/interpreter/component/host.ts +409 -0
  164. package/src/interpreter/component/instance.ts +138 -0
  165. package/src/interpreter/component/kernel.ts +611 -0
  166. package/src/interpreter/component/names.ts +13 -0
  167. package/src/interpreter/component/port.ts +598 -0
  168. package/src/interpreter/component/prepared.ts +194 -0
  169. package/src/interpreter/component/resources.ts +345 -0
  170. package/src/interpreter/component/revision.ts +702 -0
  171. package/src/interpreter/component/scope.ts +447 -0
  172. package/src/interpreter/component/streams.ts +180 -0
  173. package/src/interpreter/component/values.ts +254 -0
  174. package/src/interpreter/component/wasi-filesystem.ts +472 -0
  175. package/src/interpreter/component/wasi-host.ts +197 -0
  176. package/src/interpreter/component/wasi-http.ts +939 -0
  177. package/src/interpreter/component/wasi-sockets.ts +958 -0
  178. package/src/interpreter/component/wasi.ts +238 -0
  179. package/src/interpreter/core.ts +386 -0
  180. package/src/interpreter/fetch-http-provider.ts +98 -0
  181. package/src/interpreter/filesystem/contract.ts +138 -0
  182. package/src/interpreter/filesystem/memory.ts +180 -0
  183. package/src/interpreter/filesystem/opfs.ts +294 -0
  184. package/src/interpreter/filesystem/scope.ts +390 -0
  185. package/src/interpreter/filesystem.ts +20 -0
  186. package/src/interpreter/gate.ts +55 -0
  187. package/src/interpreter/host-protocol.ts +242 -0
  188. package/src/interpreter/http-ingress-fetch.ts +133 -0
  189. package/src/interpreter/http-ingress.ts +203 -0
  190. package/src/interpreter/http-provider.ts +105 -0
  191. package/src/interpreter/io.ts +66 -0
  192. package/src/interpreter/mobile.ts +385 -0
  193. package/src/interpreter/native-ingress.ts +550 -0
  194. package/src/interpreter/node-port.ts +218 -0
  195. package/src/interpreter/node.ts +114 -0
  196. package/src/interpreter/revision.ts +450 -0
  197. package/src/interpreter/scope.ts +453 -0
  198. package/src/interpreter/socket-addresses.ts +246 -0
  199. package/src/interpreter/socket-provider.ts +126 -0
  200. package/src/interpreter/standard-cli.ts +184 -0
  201. package/src/interpreter/standard-codec.ts +403 -0
  202. package/src/interpreter/standard-filesystem.ts +545 -0
  203. package/src/interpreter/standard-host.ts +840 -0
  204. package/src/interpreter/standard-http-values.ts +624 -0
  205. package/src/interpreter/standard-http.ts +622 -0
  206. package/src/interpreter/standard-ingress.ts +344 -0
  207. package/src/interpreter/standard-sockets.ts +847 -0
  208. package/src/interpreter/standard-streams.ts +710 -0
  209. package/src/interpreter/standard-system.ts +182 -0
  210. package/src/interpreter/standard-utf8.ts +72 -0
  211. package/src/interpreter/standard.ts +283 -0
  212. package/src/interpreter/types.ts +163 -0
  213. package/src/interpreter/wit-shape.ts +175 -0
  214. package/src/node.ts +43 -14
  215. package/src/runtime/activities.ts +6 -6
  216. package/src/runtime/adapters.ts +314 -0
  217. package/src/runtime/calls.ts +213 -90
  218. package/src/runtime/context.ts +7 -7
  219. package/src/runtime/lifecycle.ts +36 -17
  220. package/src/runtime/orbs.ts +81 -39
  221. package/src/runtime/programs.ts +16 -8
  222. package/src/runtime/references.ts +128 -11
  223. package/src/runtime/reload.ts +71 -30
  224. package/src/runtime/resources.ts +2 -2
  225. package/src/runtime/scopes.ts +17 -17
  226. package/src/runtime/session.ts +3 -1
  227. package/src/runtime/signals.ts +31 -0
  228. package/src/runtime/wit-client.ts +228 -0
  229. package/src/tooling/build.ts +152 -54
  230. package/src/tooling/client-resources.ts +74 -0
  231. package/src/tooling/client.ts +531 -0
  232. package/src/tooling/component-glue.ts +288 -0
  233. package/src/tooling/component.ts +225 -0
  234. package/src/tooling/index.ts +3 -7
  235. package/src/tooling/resolver.ts +42 -25
  236. package/src/tooling/typecheck.ts +59 -4
  237. package/src/tooling/types.ts +27 -12
  238. package/src/tooling/wit.ts +188 -0
  239. package/dist/embedded.d.ts +0 -1
  240. package/dist/embedded.js +0 -1
  241. package/src/embedded.ts +0 -301
@@ -0,0 +1,182 @@
1
+ /** Browser providers for the standard clock and random interfaces. */
2
+ import { abortable, cancelled, type Implementation } from "./standard-streams.ts";
3
+
4
+ /** Signed seconds since the epoch plus a nonnegative fractional nanosecond part. */
5
+ export interface ClockInstant {
6
+ readonly seconds: bigint;
7
+ readonly nanoseconds: number;
8
+ }
9
+
10
+ /** Host clocks shared by WASI functions and the source VM's time imports. */
11
+ export interface ClockProvider {
12
+ systemNow(): ClockInstant;
13
+ systemResolution(): bigint;
14
+ monotonicNow(): bigint;
15
+ monotonicResolution(): bigint;
16
+ waitUntil(when: bigint, signal?: AbortSignal): Promise<void>;
17
+ }
18
+
19
+ /** Secure bytes must come from a cryptographic source; insecure methods make no such claim. */
20
+ export interface RandomProvider {
21
+ secure(length: number): Uint8Array;
22
+ insecure(length: number): Uint8Array;
23
+ insecureSeed(): readonly [bigint, bigint];
24
+ }
25
+
26
+ export interface SystemProviders {
27
+ readonly clocks?: ClockProvider | undefined;
28
+ readonly random?: RandomProvider | undefined;
29
+ }
30
+
31
+ const U64 = (1n << 64n) - 1n;
32
+ function duration(value: bigint): bigint {
33
+ if (typeof value !== "bigint" || value < 0n || value > U64)
34
+ throw new RangeError("clock provider requires a u64 nanosecond value");
35
+ return value;
36
+ }
37
+
38
+ /** Validate host clocks identically for standard calls and the interpreter's libc imports. */
39
+ export function checkedClocks(source: ClockProvider): ClockProvider {
40
+ return {
41
+ systemNow() {
42
+ const value = source.systemNow();
43
+ if (
44
+ typeof value.seconds !== "bigint" ||
45
+ value.seconds < -(1n << 63n) ||
46
+ value.seconds >= 1n << 63n ||
47
+ !Number.isInteger(value.nanoseconds) ||
48
+ value.nanoseconds < 0 ||
49
+ value.nanoseconds >= 1e9
50
+ )
51
+ throw new RangeError(
52
+ "clock provider requires s64 seconds and fractional nanoseconds in [0, 1000000000)",
53
+ );
54
+ return value;
55
+ },
56
+ systemResolution: () => duration(source.systemResolution()),
57
+ monotonicNow: () => duration(source.monotonicNow()),
58
+ monotonicResolution: () => duration(source.monotonicResolution()),
59
+ waitUntil: (when, signal) => source.waitUntil(when, signal),
60
+ };
61
+ }
62
+
63
+ /** Cache seed identity per revision, including when an injected provider generates fresh seeds. */
64
+ export function revisionRandom(source: RandomProvider): RandomProvider {
65
+ let seed: readonly [bigint, bigint] | undefined;
66
+ return {
67
+ secure: (length) => source.secure(length),
68
+ insecure: (length) => source.insecure(length),
69
+ insecureSeed() {
70
+ if (seed) return seed;
71
+ const value = source.insecureSeed();
72
+ if (
73
+ value.length !== 2 ||
74
+ value.some((word) => typeof word !== "bigint" || word < 0n || word >= 1n << 64n)
75
+ )
76
+ throw new Error("random provider seed requires two u64 values");
77
+ return (seed = [value[0], value[1]]);
78
+ },
79
+ };
80
+ }
81
+
82
+ /** Largest single timer wait accepted by setTimeout. */
83
+ const TIMER_LIMIT = 2 ** 31 - 1;
84
+
85
+ /** A fresh provider; its clock uses the browser's monotonic performance timeline. */
86
+ export function browserClocks(): ClockProvider {
87
+ const now = () => BigInt(Math.floor(performance.now() * 1000)) * 1000n;
88
+ return {
89
+ systemNow() {
90
+ const milliseconds = Date.now();
91
+ const seconds = Math.floor(milliseconds / 1000);
92
+ return { seconds: BigInt(seconds), nanoseconds: (milliseconds - seconds * 1000) * 1_000_000 };
93
+ },
94
+ // Browser privacy settings can coarsen these clocks further; embedders can supply their
95
+ // actual resolution through a provider. No sub-millisecond precision is promised here.
96
+ systemResolution: () => 1_000_000n,
97
+ monotonicNow: now,
98
+ monotonicResolution: () => 1_000_000n,
99
+ async waitUntil(deadline, signal) {
100
+ if (signal?.aborted) throw cancelled();
101
+ for (let left = deadline - now(); left > 0n; left = deadline - now()) {
102
+ const milliseconds = Math.min(TIMER_LIMIT, Math.ceil(Number(left) / 1e6));
103
+ await new Promise<void>((resolve, reject) => {
104
+ if (signal?.aborted) return reject(cancelled());
105
+ const abort = () => {
106
+ clearTimeout(timer);
107
+ reject(cancelled());
108
+ };
109
+ const timer = setTimeout(() => {
110
+ signal?.removeEventListener("abort", abort);
111
+ resolve();
112
+ }, milliseconds);
113
+ signal?.addEventListener("abort", abort, { once: true });
114
+ });
115
+ }
116
+ },
117
+ };
118
+ }
119
+
120
+ /** The default never substitutes Math.random when cryptographic randomness is unavailable. */
121
+ export function browserRandom(): RandomProvider {
122
+ const secure = (length: number) => {
123
+ const bytes = new Uint8Array(length);
124
+ for (let offset = 0; offset < length; offset += 65536)
125
+ globalThis.crypto.getRandomValues(bytes.subarray(offset, offset + 65536));
126
+ return bytes;
127
+ };
128
+ const insecureSeed = () => {
129
+ const view = new DataView(secure(16).buffer);
130
+ return [view.getBigUint64(0, true), view.getBigUint64(8, true)] as const;
131
+ };
132
+ return { secure, insecure: secure, insecureSeed };
133
+ }
134
+
135
+ /** Require exact provider output before a value can be encoded or seed the VM. */
136
+ function bytes(provider: (length: number) => Uint8Array, length: number): Uint8Array {
137
+ const result = provider(length);
138
+ if (!(result instanceof Uint8Array) || result.length !== length)
139
+ throw new Error("random provider returned the wrong byte length");
140
+ return result;
141
+ }
142
+
143
+ /** One method set per revision: in particular, get-insecure-seed stays stable for that Store. */
144
+ export function systemMethods(
145
+ clocks: ClockProvider,
146
+ random: RandomProvider,
147
+ ): Record<string, Implementation> {
148
+ const randomBytes =
149
+ (secure: boolean): Implementation =>
150
+ (call, [length]: [bigint]) => {
151
+ const bound = BigInt(Math.max(0, call.host.packetBytes - 4));
152
+ return bytes(
153
+ (size) => (secure ? random.secure(size) : random.insecure(size)),
154
+ Number(length > bound ? bound : length),
155
+ );
156
+ };
157
+ const randomU64 = (secure: boolean) => () => {
158
+ const result = bytes((size) => (secure ? random.secure(size) : random.insecure(size)), 8);
159
+ return new DataView(result.buffer, result.byteOffset, result.byteLength).getBigUint64(0, true);
160
+ };
161
+ return {
162
+ "wasi:random/random@0.3.0#getRandomBytes": randomBytes(true),
163
+ "wasi:random/random@0.3.0#getRandomU64": randomU64(true),
164
+ "wasi:random/insecure@0.3.0#getInsecureRandomBytes": randomBytes(false),
165
+ "wasi:random/insecure@0.3.0#getInsecureRandomU64": randomU64(false),
166
+ "wasi:random/insecure-seed@0.3.0#getInsecureSeed": () => random.insecureSeed(),
167
+ "wasi:clocks/system-clock@0.3.0#now": () => clocks.systemNow(),
168
+ "wasi:clocks/system-clock@0.3.0#getResolution": () => clocks.systemResolution(),
169
+ "wasi:clocks/monotonic-clock@0.3.0#now": () => clocks.monotonicNow(),
170
+ "wasi:clocks/monotonic-clock@0.3.0#getResolution": () => clocks.monotonicResolution(),
171
+ "wasi:clocks/monotonic-clock@0.3.0#waitUntil": ({ signal, host }, [when]: [bigint]) =>
172
+ abortable(
173
+ host.physical(signal, () => clocks.waitUntil(when, signal)),
174
+ signal,
175
+ ),
176
+ "wasi:clocks/monotonic-clock@0.3.0#waitFor": ({ signal, host }, [duration]: [bigint]) =>
177
+ abortable(
178
+ host.physical(signal, () => clocks.waitUntil(clocks.monotonicNow() + duration, signal)),
179
+ signal,
180
+ ),
181
+ };
182
+ }
@@ -0,0 +1,72 @@
1
+ // Portable UTF-8 for the guest bindings, the browser host and author helpers.
2
+ //
3
+ // The embedded guest engine may omit TextEncoder/TextDecoder, so this module never assumes them.
4
+ // Encoding follows TextEncoder: a lone surrogate becomes U+FFFD. Decoding is strict: overlong
5
+ // forms, surrogate code points, values above U+10FFFF and truncated sequences are refused.
6
+
7
+ /** Code units converted per `String.fromCharCode` call, below every engine's argument limit. */
8
+ const BATCH = 8192;
9
+
10
+ /** Encode `text` as UTF-8 into one exact Uint8Array. */
11
+ export function utf8Encode(text: string): Uint8Array {
12
+ const out = new Uint8Array(text.length * 3);
13
+ let length = 0;
14
+ for (let index = 0; index < text.length; index++) {
15
+ let code = text.charCodeAt(index);
16
+ if (code >= 0xd800 && code <= 0xdfff) {
17
+ const next = text.charCodeAt(index + 1);
18
+ if (code <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
19
+ code = 0x10000 + ((code - 0xd800) << 10) + (next - 0xdc00);
20
+ index++;
21
+ } else code = 0xfffd;
22
+ }
23
+ if (code < 0x80) out[length++] = code;
24
+ else if (code < 0x800) {
25
+ out[length++] = 0xc0 | (code >> 6);
26
+ out[length++] = 0x80 | (code & 63);
27
+ } else if (code < 0x10000) {
28
+ out[length++] = 0xe0 | (code >> 12);
29
+ out[length++] = 0x80 | ((code >> 6) & 63);
30
+ out[length++] = 0x80 | (code & 63);
31
+ } else {
32
+ out[length++] = 0xf0 | (code >> 18);
33
+ out[length++] = 0x80 | ((code >> 12) & 63);
34
+ out[length++] = 0x80 | ((code >> 6) & 63);
35
+ out[length++] = 0x80 | (code & 63);
36
+ }
37
+ }
38
+ return out.slice(0, length);
39
+ }
40
+
41
+ /** Decode strict UTF-8; any invalid sequence throws `RangeError`. */
42
+ export function utf8Decode(bytes: Uint8Array): string {
43
+ let text = "";
44
+ const units: number[] = [];
45
+ for (let index = 0; index < bytes.length;) {
46
+ const first = bytes[index++]!;
47
+ let code: number;
48
+ if (first < 0x80) code = first;
49
+ else {
50
+ let extra: number;
51
+ let minimum: number;
52
+ if (first >= 0xc2 && first <= 0xdf) [code, extra, minimum] = [first & 31, 1, 0x80];
53
+ else if (first >= 0xe0 && first <= 0xef) [code, extra, minimum] = [first & 15, 2, 0x800];
54
+ else if (first >= 0xf0 && first <= 0xf4) [code, extra, minimum] = [first & 7, 3, 0x10000];
55
+ else throw new RangeError("invalid UTF-8");
56
+ for (; extra > 0; extra--) {
57
+ const next = bytes[index++];
58
+ if (next === undefined || (next & 0xc0) !== 0x80) throw new RangeError("invalid UTF-8");
59
+ code = (code << 6) | (next & 63);
60
+ }
61
+ if (code < minimum || code > 0x10ffff || (code >= 0xd800 && code <= 0xdfff))
62
+ throw new RangeError("invalid UTF-8");
63
+ }
64
+ if (code < 0x10000) units.push(code);
65
+ else units.push(0xd800 + ((code - 0x10000) >> 10), 0xdc00 + ((code - 0x10000) & 0x3ff));
66
+ if (units.length >= BATCH) {
67
+ text += String.fromCharCode.apply(null, units);
68
+ units.length = 0;
69
+ }
70
+ }
71
+ return text + String.fromCharCode.apply(null, units);
72
+ }
@@ -0,0 +1,283 @@
1
+ // Generated by crates/executor-wasm/build.rs from the bundled WASI WIT. Do not edit.
2
+ // Regenerate with: TEMBRA_BLESS=1 cargo test -p tembra-executor-wasm --lib standard
3
+
4
+ /** One WIT type: a kind followed by indices into `TYPES` or names. */
5
+ export type WasiType = readonly [string, ...unknown[]];
6
+
7
+ /** One generated method; its index is the binary method number. */
8
+ export interface WasiMethod {
9
+ readonly interface: string;
10
+ readonly name: string;
11
+ readonly resource?: number;
12
+ /** Set for `[static]` functions and constructors, which have no `self` parameter. */
13
+ readonly kind?: "static" | "constructor";
14
+ readonly asynchronous: boolean;
15
+ readonly params: readonly number[];
16
+ readonly result?: number;
17
+ }
18
+
19
+ export const TYPES: readonly WasiType[] = [
20
+ ["u64"],
21
+ ["s64"],
22
+ ["u32"],
23
+ ["record", [["seconds", 1], ["nanoseconds", 2]]],
24
+ ["bytes"],
25
+ ["tuple", [0, 0]],
26
+ ["own", 0],
27
+ ["string"],
28
+ ["tuple", [6, 7]],
29
+ ["list", 8],
30
+ ["borrow", 0],
31
+ ["stream", "u8"],
32
+ ["option", 7],
33
+ ["variant", [["access", -1], ["already", -1], ["bad-descriptor", -1], ["busy", -1], ["deadlock", -1], ["quota", -1], ["exist", -1], ["file-too-large", -1], ["illegal-byte-sequence", -1], ["in-progress", -1], ["interrupted", -1], ["invalid", -1], ["io", -1], ["is-directory", -1], ["loop", -1], ["too-many-links", -1], ["message-size", -1], ["name-too-long", -1], ["no-device", -1], ["no-entry", -1], ["no-lock", -1], ["insufficient-memory", -1], ["insufficient-space", -1], ["not-directory", -1], ["not-empty", -1], ["not-recoverable", -1], ["unsupported", -1], ["no-tty", -1], ["no-such-device", -1], ["overflow", -1], ["not-permitted", -1], ["pipe", -1], ["read-only", -1], ["invalid-seek", -1], ["text-file-busy", -1], ["cross-device", -1], ["other", 12]]],
34
+ ["result", -1, 13],
35
+ ["future", 14],
36
+ ["tuple", [11, 15]],
37
+ ["enum", ["normal", "sequential", "random", "will-need", "dont-need", "no-reuse"]],
38
+ ["flags", ["read", "write", "fileIntegritySync", "dataIntegritySync", "requestedWriteSync", "mutateDirectory"]],
39
+ ["result", 18, 13],
40
+ ["variant", [["block-device", -1], ["character-device", -1], ["directory", -1], ["fifo", -1], ["symbolic-link", -1], ["regular-file", -1], ["socket", -1], ["other", 12]]],
41
+ ["result", 20, 13],
42
+ ["variant", [["no-change", -1], ["now", -1], ["timestamp", 3]]],
43
+ ["record", [["type", 20], ["name", 7]]],
44
+ ["stream", 23],
45
+ ["tuple", [24, 15]],
46
+ ["option", 3],
47
+ ["record", [["type", 20], ["linkCount", 0], ["size", 0], ["dataAccessTimestamp", 26], ["dataModificationTimestamp", 26], ["statusChangeTimestamp", 26]]],
48
+ ["result", 27, 13],
49
+ ["flags", ["symlinkFollow"]],
50
+ ["flags", ["create", "directory", "exclusive", "truncate"]],
51
+ ["result", 6, 13],
52
+ ["result", 7, 13],
53
+ ["bool"],
54
+ ["record", [["lower", 0], ["upper", 0]]],
55
+ ["result", 34, 13],
56
+ ["tuple", [7, 7]],
57
+ ["list", 36],
58
+ ["list", 7],
59
+ ["result", -1, -1],
60
+ ["u8"],
61
+ ["enum", ["io", "illegal-byte-sequence", "pipe"]],
62
+ ["result", -1, 41],
63
+ ["future", 42],
64
+ ["tuple", [11, 43]],
65
+ ["own", 1],
66
+ ["option", 45],
67
+ ["own", 2],
68
+ ["option", 47],
69
+ ["own", 3],
70
+ ["tuple", [7, 4]],
71
+ ["list", 50],
72
+ ["variant", [["invalid-syntax", -1], ["forbidden", -1], ["immutable", -1], ["size-exceeded", -1], ["other", 12]]],
73
+ ["result", 49, 52],
74
+ ["borrow", 3],
75
+ ["list", 4],
76
+ ["result", -1, 52],
77
+ ["result", 55, 52],
78
+ ["option", 49],
79
+ ["u16"],
80
+ ["option", 59],
81
+ ["record", [["rcode", 12], ["infoCode", 60]]],
82
+ ["option", 40],
83
+ ["record", [["alertId", 62], ["alertMessage", 12]]],
84
+ ["option", 0],
85
+ ["option", 2],
86
+ ["record", [["fieldName", 12], ["fieldSize", 65]]],
87
+ ["option", 66],
88
+ ["variant", [["DNS-timeout", -1], ["DNS-error", 61], ["destination-not-found", -1], ["destination-unavailable", -1], ["destination-IP-prohibited", -1], ["destination-IP-unroutable", -1], ["connection-refused", -1], ["connection-terminated", -1], ["connection-timeout", -1], ["connection-read-timeout", -1], ["connection-write-timeout", -1], ["connection-limit-reached", -1], ["TLS-protocol-error", -1], ["TLS-certificate-error", -1], ["TLS-alert-received", 63], ["HTTP-request-denied", -1], ["HTTP-request-length-required", -1], ["HTTP-request-body-size", 64], ["HTTP-request-method-invalid", -1], ["HTTP-request-URI-invalid", -1], ["HTTP-request-URI-too-long", -1], ["HTTP-request-header-section-size", 65], ["HTTP-request-header-size", 67], ["HTTP-request-trailer-section-size", 65], ["HTTP-request-trailer-size", 66], ["HTTP-response-incomplete", -1], ["HTTP-response-header-section-size", 65], ["HTTP-response-header-size", 66], ["HTTP-response-body-size", 64], ["HTTP-response-trailer-section-size", 65], ["HTTP-response-trailer-size", 66], ["HTTP-response-transfer-coding", 12], ["HTTP-response-content-coding", 12], ["HTTP-response-timeout", -1], ["HTTP-upgrade-failed", -1], ["HTTP-protocol-error", -1], ["loop-detected", -1], ["configuration-error", -1], ["internal-error", 12]]],
89
+ ["result", 58, 68],
90
+ ["future", 69],
91
+ ["option", 11],
92
+ ["own", 4],
93
+ ["option", 72],
94
+ ["own", 5],
95
+ ["result", -1, 68],
96
+ ["future", 75],
97
+ ["tuple", [74, 76]],
98
+ ["borrow", 5],
99
+ ["variant", [["get", -1], ["head", -1], ["post", -1], ["put", -1], ["delete", -1], ["connect", -1], ["options", -1], ["trace", -1], ["patch", -1], ["other", 7]]],
100
+ ["variant", [["HTTP", -1], ["HTTPS", -1], ["other", 7]]],
101
+ ["option", 80],
102
+ ["tuple", [11, 70]],
103
+ ["borrow", 4],
104
+ ["variant", [["not-supported", -1], ["immutable", -1], ["other", 12]]],
105
+ ["result", -1, 84],
106
+ ["own", 6],
107
+ ["tuple", [86, 76]],
108
+ ["borrow", 6],
109
+ ["result", 86, 68],
110
+ ["enum", ["ipv4", "ipv6"]],
111
+ ["own", 7],
112
+ ["variant", [["access-denied", -1], ["not-supported", -1], ["invalid-argument", -1], ["out-of-memory", -1], ["timeout", -1], ["invalid-state", -1], ["address-not-bindable", -1], ["address-in-use", -1], ["remote-unreachable", -1], ["connection-refused", -1], ["connection-broken", -1], ["connection-reset", -1], ["connection-aborted", -1], ["datagram-too-large", -1], ["other", 12]]],
113
+ ["result", 91, 92],
114
+ ["borrow", 7],
115
+ ["tuple", [40, 40, 40, 40]],
116
+ ["record", [["port", 59], ["address", 95]]],
117
+ ["tuple", [59, 59, 59, 59, 59, 59, 59, 59]],
118
+ ["record", [["port", 59], ["flowInfo", 2], ["address", 97], ["scopeId", 2]]],
119
+ ["variant", [["ipv4", 96], ["ipv6", 98]]],
120
+ ["result", -1, 92],
121
+ ["stream", 91],
122
+ ["result", 101, 92],
123
+ ["future", 100],
124
+ ["tuple", [11, 103]],
125
+ ["result", 99, 92],
126
+ ["result", 33, 92],
127
+ ["result", 0, 92],
128
+ ["result", 2, 92],
129
+ ["result", 40, 92],
130
+ ["own", 8],
131
+ ["result", 110, 92],
132
+ ["borrow", 8],
133
+ ["option", 99],
134
+ ["tuple", [4, 99]],
135
+ ["result", 114, 92],
136
+ ["variant", [["ipv4", 95], ["ipv6", 97]]],
137
+ ["list", 116],
138
+ ["variant", [["access-denied", -1], ["invalid-argument", -1], ["name-unresolvable", -1], ["temporary-resolver-failure", -1], ["permanent-resolver-failure", -1], ["other", 12]]],
139
+ ["result", 117, 118],
140
+ ];
141
+
142
+ export const RESOURCES: readonly string[] = [
143
+ "wasi:filesystem/types@0.3.0#descriptor",
144
+ "wasi:cli/terminal-input@0.3.0#terminal-input",
145
+ "wasi:cli/terminal-output@0.3.0#terminal-output",
146
+ "wasi:http/types@0.3.0#fields",
147
+ "wasi:http/types@0.3.0#request-options",
148
+ "wasi:http/types@0.3.0#request",
149
+ "wasi:http/types@0.3.0#response",
150
+ "wasi:sockets/types@0.3.0#tcp-socket",
151
+ "wasi:sockets/types@0.3.0#udp-socket",
152
+ ];
153
+
154
+ export const METHODS: readonly WasiMethod[] = [
155
+ { interface: "wasi:clocks/monotonic-clock@0.3.0", name: "now", asynchronous: false, params: [], result: 0 },
156
+ { interface: "wasi:clocks/monotonic-clock@0.3.0", name: "getResolution", asynchronous: false, params: [], result: 0 },
157
+ { interface: "wasi:clocks/monotonic-clock@0.3.0", name: "waitUntil", asynchronous: true, params: [0] },
158
+ { interface: "wasi:clocks/monotonic-clock@0.3.0", name: "waitFor", asynchronous: true, params: [0] },
159
+ { interface: "wasi:clocks/system-clock@0.3.0", name: "now", asynchronous: false, params: [], result: 3 },
160
+ { interface: "wasi:clocks/system-clock@0.3.0", name: "getResolution", asynchronous: false, params: [], result: 0 },
161
+ { interface: "wasi:random/random@0.3.0", name: "getRandomBytes", asynchronous: false, params: [0], result: 4 },
162
+ { interface: "wasi:random/random@0.3.0", name: "getRandomU64", asynchronous: false, params: [], result: 0 },
163
+ { interface: "wasi:random/insecure@0.3.0", name: "getInsecureRandomBytes", asynchronous: false, params: [0], result: 4 },
164
+ { interface: "wasi:random/insecure@0.3.0", name: "getInsecureRandomU64", asynchronous: false, params: [], result: 0 },
165
+ { interface: "wasi:random/insecure-seed@0.3.0", name: "getInsecureSeed", asynchronous: false, params: [], result: 5 },
166
+ { interface: "wasi:filesystem/preopens@0.3.0", name: "getDirectories", asynchronous: false, params: [], result: 9 },
167
+ { interface: "wasi:filesystem/types@0.3.0", name: "readViaStream", resource: 0, asynchronous: false, params: [10, 0], result: 16 },
168
+ { interface: "wasi:filesystem/types@0.3.0", name: "writeViaStream", resource: 0, asynchronous: false, params: [10, 11, 0], result: 15 },
169
+ { interface: "wasi:filesystem/types@0.3.0", name: "appendViaStream", resource: 0, asynchronous: false, params: [10, 11], result: 15 },
170
+ { interface: "wasi:filesystem/types@0.3.0", name: "advise", resource: 0, asynchronous: true, params: [10, 0, 0, 17], result: 14 },
171
+ { interface: "wasi:filesystem/types@0.3.0", name: "syncData", resource: 0, asynchronous: true, params: [10], result: 14 },
172
+ { interface: "wasi:filesystem/types@0.3.0", name: "getFlags", resource: 0, asynchronous: true, params: [10], result: 19 },
173
+ { interface: "wasi:filesystem/types@0.3.0", name: "getType", resource: 0, asynchronous: true, params: [10], result: 21 },
174
+ { interface: "wasi:filesystem/types@0.3.0", name: "setSize", resource: 0, asynchronous: true, params: [10, 0], result: 14 },
175
+ { interface: "wasi:filesystem/types@0.3.0", name: "setTimes", resource: 0, asynchronous: true, params: [10, 22, 22], result: 14 },
176
+ { interface: "wasi:filesystem/types@0.3.0", name: "readDirectory", resource: 0, asynchronous: false, params: [10], result: 25 },
177
+ { interface: "wasi:filesystem/types@0.3.0", name: "sync", resource: 0, asynchronous: true, params: [10], result: 14 },
178
+ { interface: "wasi:filesystem/types@0.3.0", name: "createDirectoryAt", resource: 0, asynchronous: true, params: [10, 7], result: 14 },
179
+ { interface: "wasi:filesystem/types@0.3.0", name: "stat", resource: 0, asynchronous: true, params: [10], result: 28 },
180
+ { interface: "wasi:filesystem/types@0.3.0", name: "statAt", resource: 0, asynchronous: true, params: [10, 29, 7], result: 28 },
181
+ { interface: "wasi:filesystem/types@0.3.0", name: "setTimesAt", resource: 0, asynchronous: true, params: [10, 29, 7, 22, 22], result: 14 },
182
+ { interface: "wasi:filesystem/types@0.3.0", name: "linkAt", resource: 0, asynchronous: true, params: [10, 29, 7, 10, 7], result: 14 },
183
+ { interface: "wasi:filesystem/types@0.3.0", name: "openAt", resource: 0, asynchronous: true, params: [10, 29, 7, 30, 18], result: 31 },
184
+ { interface: "wasi:filesystem/types@0.3.0", name: "readlinkAt", resource: 0, asynchronous: true, params: [10, 7], result: 32 },
185
+ { interface: "wasi:filesystem/types@0.3.0", name: "removeDirectoryAt", resource: 0, asynchronous: true, params: [10, 7], result: 14 },
186
+ { interface: "wasi:filesystem/types@0.3.0", name: "renameAt", resource: 0, asynchronous: true, params: [10, 7, 10, 7], result: 14 },
187
+ { interface: "wasi:filesystem/types@0.3.0", name: "symlinkAt", resource: 0, asynchronous: true, params: [10, 7, 7], result: 14 },
188
+ { interface: "wasi:filesystem/types@0.3.0", name: "unlinkFileAt", resource: 0, asynchronous: true, params: [10, 7], result: 14 },
189
+ { interface: "wasi:filesystem/types@0.3.0", name: "isSameObject", resource: 0, asynchronous: true, params: [10, 10], result: 33 },
190
+ { interface: "wasi:filesystem/types@0.3.0", name: "metadataHash", resource: 0, asynchronous: true, params: [10], result: 35 },
191
+ { interface: "wasi:filesystem/types@0.3.0", name: "metadataHashAt", resource: 0, asynchronous: true, params: [10, 29, 7], result: 35 },
192
+ { interface: "wasi:cli/environment@0.3.0", name: "getEnvironment", asynchronous: false, params: [], result: 37 },
193
+ { interface: "wasi:cli/environment@0.3.0", name: "getArguments", asynchronous: false, params: [], result: 38 },
194
+ { interface: "wasi:cli/environment@0.3.0", name: "getInitialCwd", asynchronous: false, params: [], result: 12 },
195
+ { interface: "wasi:cli/exit@0.3.0", name: "exit", asynchronous: false, params: [39] },
196
+ { interface: "wasi:cli/exit@0.3.0", name: "exitWithCode", asynchronous: false, params: [40] },
197
+ { interface: "wasi:cli/stdin@0.3.0", name: "readViaStream", asynchronous: false, params: [], result: 44 },
198
+ { interface: "wasi:cli/stdout@0.3.0", name: "writeViaStream", asynchronous: false, params: [11], result: 43 },
199
+ { interface: "wasi:cli/stderr@0.3.0", name: "writeViaStream", asynchronous: false, params: [11], result: 43 },
200
+ { interface: "wasi:cli/terminal-stdin@0.3.0", name: "getTerminalStdin", asynchronous: false, params: [], result: 46 },
201
+ { interface: "wasi:cli/terminal-stdout@0.3.0", name: "getTerminalStdout", asynchronous: false, params: [], result: 48 },
202
+ { interface: "wasi:cli/terminal-stderr@0.3.0", name: "getTerminalStderr", asynchronous: false, params: [], result: 48 },
203
+ { interface: "wasi:http/types@0.3.0", name: "constructor", resource: 3, kind: "constructor", asynchronous: false, params: [], result: 49 },
204
+ { interface: "wasi:http/types@0.3.0", name: "fromList", resource: 3, kind: "static", asynchronous: false, params: [51], result: 53 },
205
+ { interface: "wasi:http/types@0.3.0", name: "get", resource: 3, asynchronous: false, params: [54, 7], result: 55 },
206
+ { interface: "wasi:http/types@0.3.0", name: "has", resource: 3, asynchronous: false, params: [54, 7], result: 33 },
207
+ { interface: "wasi:http/types@0.3.0", name: "set", resource: 3, asynchronous: false, params: [54, 7, 55], result: 56 },
208
+ { interface: "wasi:http/types@0.3.0", name: "delete", resource: 3, asynchronous: false, params: [54, 7], result: 56 },
209
+ { interface: "wasi:http/types@0.3.0", name: "getAndDelete", resource: 3, asynchronous: false, params: [54, 7], result: 57 },
210
+ { interface: "wasi:http/types@0.3.0", name: "append", resource: 3, asynchronous: false, params: [54, 7, 4], result: 56 },
211
+ { interface: "wasi:http/types@0.3.0", name: "copyAll", resource: 3, asynchronous: false, params: [54], result: 51 },
212
+ { interface: "wasi:http/types@0.3.0", name: "clone", resource: 3, asynchronous: false, params: [54], result: 49 },
213
+ { interface: "wasi:http/types@0.3.0", name: "new", resource: 5, kind: "static", asynchronous: false, params: [49, 71, 70, 73], result: 77 },
214
+ { interface: "wasi:http/types@0.3.0", name: "getMethod", resource: 5, asynchronous: false, params: [78], result: 79 },
215
+ { interface: "wasi:http/types@0.3.0", name: "setMethod", resource: 5, asynchronous: false, params: [78, 79], result: 39 },
216
+ { interface: "wasi:http/types@0.3.0", name: "getPathWithQuery", resource: 5, asynchronous: false, params: [78], result: 12 },
217
+ { interface: "wasi:http/types@0.3.0", name: "setPathWithQuery", resource: 5, asynchronous: false, params: [78, 12], result: 39 },
218
+ { interface: "wasi:http/types@0.3.0", name: "getScheme", resource: 5, asynchronous: false, params: [78], result: 81 },
219
+ { interface: "wasi:http/types@0.3.0", name: "setScheme", resource: 5, asynchronous: false, params: [78, 81], result: 39 },
220
+ { interface: "wasi:http/types@0.3.0", name: "getAuthority", resource: 5, asynchronous: false, params: [78], result: 12 },
221
+ { interface: "wasi:http/types@0.3.0", name: "setAuthority", resource: 5, asynchronous: false, params: [78, 12], result: 39 },
222
+ { interface: "wasi:http/types@0.3.0", name: "getOptions", resource: 5, asynchronous: false, params: [78], result: 73 },
223
+ { interface: "wasi:http/types@0.3.0", name: "getHeaders", resource: 5, asynchronous: false, params: [78], result: 49 },
224
+ { interface: "wasi:http/types@0.3.0", name: "consumeBody", resource: 5, kind: "static", asynchronous: false, params: [74, 76], result: 82 },
225
+ { interface: "wasi:http/types@0.3.0", name: "constructor", resource: 4, kind: "constructor", asynchronous: false, params: [], result: 72 },
226
+ { interface: "wasi:http/types@0.3.0", name: "getConnectTimeout", resource: 4, asynchronous: false, params: [83], result: 64 },
227
+ { interface: "wasi:http/types@0.3.0", name: "setConnectTimeout", resource: 4, asynchronous: false, params: [83, 64], result: 85 },
228
+ { interface: "wasi:http/types@0.3.0", name: "getFirstByteTimeout", resource: 4, asynchronous: false, params: [83], result: 64 },
229
+ { interface: "wasi:http/types@0.3.0", name: "setFirstByteTimeout", resource: 4, asynchronous: false, params: [83, 64], result: 85 },
230
+ { interface: "wasi:http/types@0.3.0", name: "getBetweenBytesTimeout", resource: 4, asynchronous: false, params: [83], result: 64 },
231
+ { interface: "wasi:http/types@0.3.0", name: "setBetweenBytesTimeout", resource: 4, asynchronous: false, params: [83, 64], result: 85 },
232
+ { interface: "wasi:http/types@0.3.0", name: "clone", resource: 4, asynchronous: false, params: [83], result: 72 },
233
+ { interface: "wasi:http/types@0.3.0", name: "new", resource: 6, kind: "static", asynchronous: false, params: [49, 71, 70], result: 87 },
234
+ { interface: "wasi:http/types@0.3.0", name: "getStatusCode", resource: 6, asynchronous: false, params: [88], result: 59 },
235
+ { interface: "wasi:http/types@0.3.0", name: "setStatusCode", resource: 6, asynchronous: false, params: [88, 59], result: 39 },
236
+ { interface: "wasi:http/types@0.3.0", name: "getHeaders", resource: 6, asynchronous: false, params: [88], result: 49 },
237
+ { interface: "wasi:http/types@0.3.0", name: "consumeBody", resource: 6, kind: "static", asynchronous: false, params: [86, 76], result: 82 },
238
+ { interface: "wasi:http/client@0.3.0", name: "send", asynchronous: true, params: [74], result: 89 },
239
+ { interface: "wasi:sockets/types@0.3.0", name: "create", resource: 7, kind: "static", asynchronous: false, params: [90], result: 93 },
240
+ { interface: "wasi:sockets/types@0.3.0", name: "bind", resource: 7, asynchronous: false, params: [94, 99], result: 100 },
241
+ { interface: "wasi:sockets/types@0.3.0", name: "connect", resource: 7, asynchronous: true, params: [94, 99], result: 100 },
242
+ { interface: "wasi:sockets/types@0.3.0", name: "listen", resource: 7, asynchronous: false, params: [94], result: 102 },
243
+ { interface: "wasi:sockets/types@0.3.0", name: "send", resource: 7, asynchronous: false, params: [94, 11], result: 103 },
244
+ { interface: "wasi:sockets/types@0.3.0", name: "receive", resource: 7, asynchronous: false, params: [94], result: 104 },
245
+ { interface: "wasi:sockets/types@0.3.0", name: "getLocalAddress", resource: 7, asynchronous: false, params: [94], result: 105 },
246
+ { interface: "wasi:sockets/types@0.3.0", name: "getRemoteAddress", resource: 7, asynchronous: false, params: [94], result: 105 },
247
+ { interface: "wasi:sockets/types@0.3.0", name: "getIsListening", resource: 7, asynchronous: false, params: [94], result: 33 },
248
+ { interface: "wasi:sockets/types@0.3.0", name: "getAddressFamily", resource: 7, asynchronous: false, params: [94], result: 90 },
249
+ { interface: "wasi:sockets/types@0.3.0", name: "setListenBacklogSize", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
250
+ { interface: "wasi:sockets/types@0.3.0", name: "getKeepAliveEnabled", resource: 7, asynchronous: false, params: [94], result: 106 },
251
+ { interface: "wasi:sockets/types@0.3.0", name: "setKeepAliveEnabled", resource: 7, asynchronous: false, params: [94, 33], result: 100 },
252
+ { interface: "wasi:sockets/types@0.3.0", name: "getKeepAliveIdleTime", resource: 7, asynchronous: false, params: [94], result: 107 },
253
+ { interface: "wasi:sockets/types@0.3.0", name: "setKeepAliveIdleTime", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
254
+ { interface: "wasi:sockets/types@0.3.0", name: "getKeepAliveInterval", resource: 7, asynchronous: false, params: [94], result: 107 },
255
+ { interface: "wasi:sockets/types@0.3.0", name: "setKeepAliveInterval", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
256
+ { interface: "wasi:sockets/types@0.3.0", name: "getKeepAliveCount", resource: 7, asynchronous: false, params: [94], result: 108 },
257
+ { interface: "wasi:sockets/types@0.3.0", name: "setKeepAliveCount", resource: 7, asynchronous: false, params: [94, 2], result: 100 },
258
+ { interface: "wasi:sockets/types@0.3.0", name: "getHopLimit", resource: 7, asynchronous: false, params: [94], result: 109 },
259
+ { interface: "wasi:sockets/types@0.3.0", name: "setHopLimit", resource: 7, asynchronous: false, params: [94, 40], result: 100 },
260
+ { interface: "wasi:sockets/types@0.3.0", name: "getReceiveBufferSize", resource: 7, asynchronous: false, params: [94], result: 107 },
261
+ { interface: "wasi:sockets/types@0.3.0", name: "setReceiveBufferSize", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
262
+ { interface: "wasi:sockets/types@0.3.0", name: "getSendBufferSize", resource: 7, asynchronous: false, params: [94], result: 107 },
263
+ { interface: "wasi:sockets/types@0.3.0", name: "setSendBufferSize", resource: 7, asynchronous: false, params: [94, 0], result: 100 },
264
+ { interface: "wasi:sockets/types@0.3.0", name: "create", resource: 8, kind: "static", asynchronous: false, params: [90], result: 111 },
265
+ { interface: "wasi:sockets/types@0.3.0", name: "bind", resource: 8, asynchronous: false, params: [112, 99], result: 100 },
266
+ { interface: "wasi:sockets/types@0.3.0", name: "connect", resource: 8, asynchronous: false, params: [112, 99], result: 100 },
267
+ { interface: "wasi:sockets/types@0.3.0", name: "disconnect", resource: 8, asynchronous: false, params: [112], result: 100 },
268
+ { interface: "wasi:sockets/types@0.3.0", name: "send", resource: 8, asynchronous: true, params: [112, 4, 113], result: 100 },
269
+ { interface: "wasi:sockets/types@0.3.0", name: "receive", resource: 8, asynchronous: true, params: [112], result: 115 },
270
+ { interface: "wasi:sockets/types@0.3.0", name: "getLocalAddress", resource: 8, asynchronous: false, params: [112], result: 105 },
271
+ { interface: "wasi:sockets/types@0.3.0", name: "getRemoteAddress", resource: 8, asynchronous: false, params: [112], result: 105 },
272
+ { interface: "wasi:sockets/types@0.3.0", name: "getAddressFamily", resource: 8, asynchronous: false, params: [112], result: 90 },
273
+ { interface: "wasi:sockets/types@0.3.0", name: "getUnicastHopLimit", resource: 8, asynchronous: false, params: [112], result: 109 },
274
+ { interface: "wasi:sockets/types@0.3.0", name: "setUnicastHopLimit", resource: 8, asynchronous: false, params: [112, 40], result: 100 },
275
+ { interface: "wasi:sockets/types@0.3.0", name: "getReceiveBufferSize", resource: 8, asynchronous: false, params: [112], result: 107 },
276
+ { interface: "wasi:sockets/types@0.3.0", name: "setReceiveBufferSize", resource: 8, asynchronous: false, params: [112, 0], result: 100 },
277
+ { interface: "wasi:sockets/types@0.3.0", name: "getSendBufferSize", resource: 8, asynchronous: false, params: [112], result: 107 },
278
+ { interface: "wasi:sockets/types@0.3.0", name: "setSendBufferSize", resource: 8, asynchronous: false, params: [112, 0], result: 100 },
279
+ { interface: "wasi:sockets/ip-name-lookup@0.3.0", name: "resolveAddresses", asynchronous: true, params: [7], result: 119 },
280
+ ];
281
+
282
+ /** `TYPES` indices of the futures a guest may create (FUTURE_NEW) and write once. */
283
+ export const WRITABLE_FUTURES: readonly number[] = [70, 76];