@struct-ai/sdk 0.2.0 → 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 (194) hide show
  1. package/README.md +46 -3
  2. package/dist/commonjs/core.d.ts +2 -0
  3. package/dist/commonjs/core.js +53 -7
  4. package/dist/esm/core.d.ts +2 -0
  5. package/dist/esm/core.js +54 -8
  6. package/package.json +21 -21
  7. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/content-capture.d.ts +0 -10
  8. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/context.d.ts +0 -30
  9. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/core.d.ts +0 -120
  10. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/events.d.ts +0 -12
  11. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/index.d.ts +0 -6
  12. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/anthropic-content.d.ts +0 -24
  13. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/anthropic.d.ts +0 -34
  14. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/index.d.ts +0 -5
  15. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain-callback.d.ts +0 -134
  16. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain-content.d.ts +0 -35
  17. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain.d.ts +0 -11
  18. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/package.json +0 -3
  19. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/semconv.d.ts +0 -54
  20. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/truncation.d.ts +0 -10
  21. package/dist/node_modules/@struct-ai/sdk/dist/esm/content-capture.d.ts +0 -10
  22. package/dist/node_modules/@struct-ai/sdk/dist/esm/context.d.ts +0 -30
  23. package/dist/node_modules/@struct-ai/sdk/dist/esm/core.d.ts +0 -120
  24. package/dist/node_modules/@struct-ai/sdk/dist/esm/events.d.ts +0 -12
  25. package/dist/node_modules/@struct-ai/sdk/dist/esm/index.d.ts +0 -6
  26. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/anthropic-content.d.ts +0 -24
  27. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/anthropic.d.ts +0 -34
  28. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/index.d.ts +0 -5
  29. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain-callback.d.ts +0 -134
  30. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain-content.d.ts +0 -35
  31. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain.d.ts +0 -11
  32. package/dist/node_modules/@struct-ai/sdk/dist/esm/package.json +0 -3
  33. package/dist/node_modules/@struct-ai/sdk/dist/esm/semconv.d.ts +0 -54
  34. package/dist/node_modules/@struct-ai/sdk/dist/esm/truncation.d.ts +0 -10
  35. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/commonjs/package.json +0 -3
  36. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/esm/package.json +0 -3
  37. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/package.json +0 -103
  38. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/package.json +0 -103
  39. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/package.json +0 -118
  40. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/package.json +0 -916
  41. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/package.json +0 -188
  42. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/openai/package.json +0 -105
  43. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api/package.json +0 -96
  44. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api-logs/package.json +0 -91
  45. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/core/package.json +0 -96
  46. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-logs-otlp-proto/package.json +0 -108
  47. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-trace-otlp-proto/package.json +0 -105
  48. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/resources/package.json +0 -100
  49. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-logs/package.json +0 -109
  50. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-base/package.json +0 -100
  51. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-node/package.json +0 -76
  52. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/package.json +0 -140
  53. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/nock/package.json +0 -89
  54. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/tshy/package.json +0 -81
  55. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/tsx/package.json +0 -68
  56. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/typescript/package.json +0 -120
  57. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/vitest/package.json +0 -239
  58. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/zod/package.json +0 -135
  59. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/package.json +0 -103
  60. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/core.d.ts +0 -244
  61. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/error.d.ts +0 -54
  62. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/index.d.ts +0 -188
  63. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/package.json +0 -103
  64. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/pagination.d.ts +0 -26
  65. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/resource.d.ts +0 -6
  66. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/streaming.d.ts +0 -41
  67. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/uploads.d.ts +0 -75
  68. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/version.d.ts +0 -2
  69. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/experimental.d.ts +0 -1
  70. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/index.d.ts +0 -1
  71. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/package.json +0 -118
  72. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/agents.d.ts +0 -1
  73. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/caches.d.ts +0 -1
  74. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/chat_history.d.ts +0 -1
  75. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/context.d.ts +0 -1
  76. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/documents.d.ts +0 -1
  77. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/embeddings.d.ts +0 -1
  78. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/example_selectors.d.ts +0 -1
  79. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/index.d.ts +0 -1
  80. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/indexing.d.ts +0 -1
  81. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/load.d.ts +0 -1
  82. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/memory.d.ts +0 -1
  83. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/messages.d.ts +0 -1
  84. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/output_parsers.d.ts +0 -1
  85. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/outputs.d.ts +0 -1
  86. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/package.json +0 -916
  87. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/prompt_values.d.ts +0 -1
  88. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/prompts.d.ts +0 -1
  89. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/retrievers.d.ts +0 -1
  90. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/runnables.d.ts +0 -1
  91. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/singletons.d.ts +0 -1
  92. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/stores.d.ts +0 -1
  93. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/structured_query.d.ts +0 -1
  94. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/tools.d.ts +0 -1
  95. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/vectorstores.d.ts +0 -1
  96. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/index.d.ts +0 -1
  97. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/package.json +0 -188
  98. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/prebuilt.d.ts +0 -1
  99. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/pregel.d.ts +0 -1
  100. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/remote.d.ts +0 -1
  101. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/web.d.ts +0 -1
  102. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/zod.d.ts +0 -1
  103. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/openai/index.d.ts +0 -1
  104. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/openai/package.json +0 -105
  105. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api/package.json +0 -96
  106. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api-logs/package.json +0 -91
  107. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/core/package.json +0 -96
  108. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-logs-otlp-proto/package.json +0 -108
  109. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-trace-otlp-proto/package.json +0 -105
  110. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/resources/package.json +0 -100
  111. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-logs/package.json +0 -109
  112. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-base/package.json +0 -100
  113. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-node/package.json +0 -76
  114. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/assert.d.ts +0 -1062
  115. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/async_hooks.d.ts +0 -605
  116. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/buffer.buffer.d.ts +0 -471
  117. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/buffer.d.ts +0 -1936
  118. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/child_process.d.ts +0 -1475
  119. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/cluster.d.ts +0 -577
  120. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/console.d.ts +0 -452
  121. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/constants.d.ts +0 -21
  122. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/crypto.d.ts +0 -4590
  123. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/dgram.d.ts +0 -597
  124. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/diagnostics_channel.d.ts +0 -578
  125. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/dns.d.ts +0 -871
  126. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/domain.d.ts +0 -170
  127. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/events.d.ts +0 -977
  128. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/fs.d.ts +0 -4375
  129. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/globals.d.ts +0 -172
  130. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/globals.typedarray.d.ts +0 -38
  131. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/http.d.ts +0 -2049
  132. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/http2.d.ts +0 -2631
  133. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/https.d.ts +0 -578
  134. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/index.d.ts +0 -93
  135. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/inspector.generated.d.ts +0 -3966
  136. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/module.d.ts +0 -539
  137. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/net.d.ts +0 -1031
  138. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/os.d.ts +0 -506
  139. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/package.json +0 -140
  140. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/path.d.ts +0 -200
  141. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/perf_hooks.d.ts +0 -961
  142. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/process.d.ts +0 -1961
  143. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/punycode.d.ts +0 -117
  144. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/querystring.d.ts +0 -152
  145. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/readline.d.ts +0 -589
  146. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/repl.d.ts +0 -430
  147. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/sea.d.ts +0 -153
  148. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/stream.d.ts +0 -1698
  149. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/string_decoder.d.ts +0 -67
  150. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/test.d.ts +0 -1787
  151. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/timers.d.ts +0 -286
  152. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/tls.d.ts +0 -1259
  153. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/trace_events.d.ts +0 -197
  154. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/tty.d.ts +0 -208
  155. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/url.d.ts +0 -964
  156. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/util.d.ts +0 -2331
  157. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/v8.d.ts +0 -809
  158. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/vm.d.ts +0 -1001
  159. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/wasi.d.ts +0 -181
  160. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/worker_threads.d.ts +0 -715
  161. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/zlib.d.ts +0 -598
  162. package/dist/node_modules/@struct-ai/sdk/node_modules/nock/package.json +0 -89
  163. package/dist/node_modules/@struct-ai/sdk/node_modules/tshy/package.json +0 -81
  164. package/dist/node_modules/@struct-ai/sdk/node_modules/tsx/package.json +0 -68
  165. package/dist/node_modules/@struct-ai/sdk/node_modules/typescript/package.json +0 -120
  166. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/config.d.ts +0 -3
  167. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/coverage.d.ts +0 -1
  168. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/environments.d.ts +0 -1
  169. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/globals.d.ts +0 -22
  170. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/import-meta.d.ts +0 -5
  171. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/importMeta.d.ts +0 -4
  172. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/jsdom.d.ts +0 -6
  173. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/mocker.d.ts +0 -1
  174. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/node.d.ts +0 -1
  175. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/optional-runtime-types.d.ts +0 -6
  176. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/optional-types.d.ts +0 -7
  177. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/package.json +0 -239
  178. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/reporters.d.ts +0 -1
  179. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/runners.d.ts +0 -1
  180. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/snapshot.d.ts +0 -1
  181. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/suite.d.ts +0 -1
  182. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/worker.d.ts +0 -1
  183. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/index.d.ts +0 -4
  184. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/locales/package.json +0 -7
  185. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/mini/package.json +0 -7
  186. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/package.json +0 -135
  187. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v3/package.json +0 -7
  188. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/classic/package.json +0 -7
  189. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/core/package.json +0 -7
  190. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/locales/package.json +0 -7
  191. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/mini/package.json +0 -7
  192. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/package.json +0 -7
  193. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4-mini/package.json +0 -7
  194. package/dist/node_modules/@struct-ai/sdk/package.json +0 -103
@@ -1,181 +0,0 @@
1
- /**
2
- * **The `node:wasi` module does not currently provide the**
3
- * **comprehensive file system security properties provided by some WASI runtimes.**
4
- * **Full support for secure file system sandboxing may or may not be implemented in**
5
- * **future. In the mean time, do not rely on it to run untrusted code.**
6
- *
7
- * The WASI API provides an implementation of the [WebAssembly System Interface](https://wasi.dev/) specification. WASI gives WebAssembly applications access to the underlying
8
- * operating system via a collection of POSIX-like functions.
9
- *
10
- * ```js
11
- * import { readFile } from 'node:fs/promises';
12
- * import { WASI } from 'wasi';
13
- * import { argv, env } from 'node:process';
14
- *
15
- * const wasi = new WASI({
16
- * version: 'preview1',
17
- * args: argv,
18
- * env,
19
- * preopens: {
20
- * '/local': '/some/real/path/that/wasm/can/access',
21
- * },
22
- * });
23
- *
24
- * const wasm = await WebAssembly.compile(
25
- * await readFile(new URL('./demo.wasm', import.meta.url)),
26
- * );
27
- * const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject());
28
- *
29
- * wasi.start(instance);
30
- * ```
31
- *
32
- * To run the above example, create a new WebAssembly text format file named `demo.wat`:
33
- *
34
- * ```text
35
- * (module
36
- * ;; Import the required fd_write WASI function which will write the given io vectors to stdout
37
- * ;; The function signature for fd_write is:
38
- * ;; (File Descriptor, *iovs, iovs_len, nwritten) -> Returns number of bytes written
39
- * (import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32)))
40
- *
41
- * (memory 1)
42
- * (export "memory" (memory 0))
43
- *
44
- * ;; Write 'hello world\n' to memory at an offset of 8 bytes
45
- * ;; Note the trailing newline which is required for the text to appear
46
- * (data (i32.const 8) "hello world\n")
47
- *
48
- * (func $main (export "_start")
49
- * ;; Creating a new io vector within linear memory
50
- * (i32.store (i32.const 0) (i32.const 8)) ;; iov.iov_base - This is a pointer to the start of the 'hello world\n' string
51
- * (i32.store (i32.const 4) (i32.const 12)) ;; iov.iov_len - The length of the 'hello world\n' string
52
- *
53
- * (call $fd_write
54
- * (i32.const 1) ;; file_descriptor - 1 for stdout
55
- * (i32.const 0) ;; *iovs - The pointer to the iov array, which is stored at memory location 0
56
- * (i32.const 1) ;; iovs_len - We're printing 1 string stored in an iov - so one.
57
- * (i32.const 20) ;; nwritten - A place in memory to store the number of bytes written
58
- * )
59
- * drop ;; Discard the number of bytes written from the top of the stack
60
- * )
61
- * )
62
- * ```
63
- *
64
- * Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm`
65
- *
66
- * ```bash
67
- * wat2wasm demo.wat
68
- * ```
69
- * @experimental
70
- * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/wasi.js)
71
- */
72
- declare module "wasi" {
73
- interface WASIOptions {
74
- /**
75
- * An array of strings that the WebAssembly application will
76
- * see as command line arguments. The first argument is the virtual path to the
77
- * WASI command itself.
78
- * @default []
79
- */
80
- args?: readonly string[] | undefined;
81
- /**
82
- * An object similar to `process.env` that the WebAssembly
83
- * application will see as its environment.
84
- * @default {}
85
- */
86
- env?: object | undefined;
87
- /**
88
- * This object represents the WebAssembly application's
89
- * sandbox directory structure. The string keys of `preopens` are treated as
90
- * directories within the sandbox. The corresponding values in `preopens` are
91
- * the real paths to those directories on the host machine.
92
- */
93
- preopens?: NodeJS.Dict<string> | undefined;
94
- /**
95
- * By default, when WASI applications call `__wasi_proc_exit()`
96
- * `wasi.start()` will return with the exit code specified rather than terminatng the process.
97
- * Setting this option to `false` will cause the Node.js process to exit with
98
- * the specified exit code instead.
99
- * @default true
100
- */
101
- returnOnExit?: boolean | undefined;
102
- /**
103
- * The file descriptor used as standard input in the WebAssembly application.
104
- * @default 0
105
- */
106
- stdin?: number | undefined;
107
- /**
108
- * The file descriptor used as standard output in the WebAssembly application.
109
- * @default 1
110
- */
111
- stdout?: number | undefined;
112
- /**
113
- * The file descriptor used as standard error in the WebAssembly application.
114
- * @default 2
115
- */
116
- stderr?: number | undefined;
117
- /**
118
- * The version of WASI requested.
119
- * Currently the only supported versions are `'unstable'` and `'preview1'`. This option is mandatory.
120
- * @since v19.8.0
121
- */
122
- version: "unstable" | "preview1";
123
- }
124
- /**
125
- * The `WASI` class provides the WASI system call API and additional convenience
126
- * methods for working with WASI-based applications. Each `WASI` instance
127
- * represents a distinct environment.
128
- * @since v13.3.0, v12.16.0
129
- */
130
- class WASI {
131
- constructor(options?: WASIOptions);
132
- /**
133
- * Return an import object that can be passed to `WebAssembly.instantiate()` if no other WASM imports are needed beyond those provided by WASI.
134
- *
135
- * If version `unstable` was passed into the constructor it will return:
136
- *
137
- * ```js
138
- * { wasi_unstable: wasi.wasiImport }
139
- * ```
140
- *
141
- * If version `preview1` was passed into the constructor or no version was specified it will return:
142
- *
143
- * ```js
144
- * { wasi_snapshot_preview1: wasi.wasiImport }
145
- * ```
146
- * @since v19.8.0
147
- */
148
- getImportObject(): object;
149
- /**
150
- * Attempt to begin execution of `instance` as a WASI command by invoking its `_start()` export. If `instance` does not contain a `_start()` export, or if `instance` contains an `_initialize()`
151
- * export, then an exception is thrown.
152
- *
153
- * `start()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named `memory`. If
154
- * `instance` does not have a `memory` export an exception is thrown.
155
- *
156
- * If `start()` is called more than once, an exception is thrown.
157
- * @since v13.3.0, v12.16.0
158
- */
159
- start(instance: object): number; // TODO: avoid DOM dependency until WASM moved to own lib.
160
- /**
161
- * Attempt to initialize `instance` as a WASI reactor by invoking its `_initialize()` export, if it is present. If `instance` contains a `_start()` export, then an exception is thrown.
162
- *
163
- * `initialize()` requires that `instance` exports a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) named `memory`.
164
- * If `instance` does not have a `memory` export an exception is thrown.
165
- *
166
- * If `initialize()` is called more than once, an exception is thrown.
167
- * @since v14.6.0, v12.19.0
168
- */
169
- initialize(instance: object): void; // TODO: avoid DOM dependency until WASM moved to own lib.
170
- /**
171
- * `wasiImport` is an object that implements the WASI system call API. This object
172
- * should be passed as the `wasi_snapshot_preview1` import during the instantiation
173
- * of a [`WebAssembly.Instance`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance).
174
- * @since v13.3.0, v12.16.0
175
- */
176
- readonly wasiImport: NodeJS.Dict<any>; // TODO: Narrow to DOM types
177
- }
178
- }
179
- declare module "node:wasi" {
180
- export * from "wasi";
181
- }