@lamplitisles/dsh-nanocodex 0.1.0-beta.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 (276) hide show
  1. package/LICENSE +65 -0
  2. package/NOTICE +2 -0
  3. package/README.md +182 -0
  4. package/THIRD_PARTY_NOTICES.md +29 -0
  5. package/cordis.patch.yml +52 -0
  6. package/dist/index.d.ts +435 -0
  7. package/dist/index.js +3405 -0
  8. package/dist/standard-preset.d.ts +7 -0
  9. package/dist/standard-preset.js +25 -0
  10. package/engine-release.json +14 -0
  11. package/package.json +119 -0
  12. package/presets/standard/agent.cordis.yml +6 -0
  13. package/presets/standard/preset.yml +2 -0
  14. package/vendor/nanocodex/README.md +1344 -0
  15. package/vendor/nanocodex/actions/events.d.mts +10 -0
  16. package/vendor/nanocodex/actions/events.mjs +163 -0
  17. package/vendor/nanocodex/actions/index.d.mts +13 -0
  18. package/vendor/nanocodex/actions/index.mjs +35 -0
  19. package/vendor/nanocodex/actions/session.d.mts +66 -0
  20. package/vendor/nanocodex/actions/session.mjs +59 -0
  21. package/vendor/nanocodex/actions/turn.d.mts +59 -0
  22. package/vendor/nanocodex/actions/turn.mjs +37 -0
  23. package/vendor/nanocodex/actions/voice.d.mts +22 -0
  24. package/vendor/nanocodex/actions/voice.mjs +50 -0
  25. package/vendor/nanocodex/browser/Agent.d.mts +55 -0
  26. package/vendor/nanocodex/browser/Agent.mjs +11 -0
  27. package/vendor/nanocodex/browser/ChatGptSubscription.d.mts +7 -0
  28. package/vendor/nanocodex/browser/ChatGptSubscription.mjs +19 -0
  29. package/vendor/nanocodex/browser/InlineAgent.mjs +266 -0
  30. package/vendor/nanocodex/browser/Transport.d.mts +74 -0
  31. package/vendor/nanocodex/browser/Transport.mjs +61 -0
  32. package/vendor/nanocodex/browser/Voice.d.mts +71 -0
  33. package/vendor/nanocodex/browser/Voice.mjs +291 -0
  34. package/vendor/nanocodex/browser/VoiceSession.mjs +688 -0
  35. package/vendor/nanocodex/browser/WorkerAgent.d.mts +65 -0
  36. package/vendor/nanocodex/browser/WorkerAgent.mjs +1472 -0
  37. package/vendor/nanocodex/browser/agent.worker.mjs +3 -0
  38. package/vendor/nanocodex/browser/config.d.mts +36 -0
  39. package/vendor/nanocodex/browser/config.mjs +439 -0
  40. package/vendor/nanocodex/browser/engine.mjs +13 -0
  41. package/vendor/nanocodex/browser/harness.mjs +55 -0
  42. package/vendor/nanocodex/browser/host.d.mts +83 -0
  43. package/vendor/nanocodex/browser/host.mjs +555 -0
  44. package/vendor/nanocodex/browser/hostManagedWebSocket.d.mts +14 -0
  45. package/vendor/nanocodex/browser/hostManagedWebSocket.mjs +110 -0
  46. package/vendor/nanocodex/browser/index.d.mts +92 -0
  47. package/vendor/nanocodex/browser/index.mjs +23 -0
  48. package/vendor/nanocodex/browser/indexeddb-durability-store.mjs +197 -0
  49. package/vendor/nanocodex/browser/workspace.d.mts +16 -0
  50. package/vendor/nanocodex/browser/workspace.mjs +107 -0
  51. package/vendor/nanocodex/cloud/Client.d.mts +83 -0
  52. package/vendor/nanocodex/cloud/Client.mjs +231 -0
  53. package/vendor/nanocodex/cloud/Decorator.d.mts +31 -0
  54. package/vendor/nanocodex/cloud/Decorator.mjs +37 -0
  55. package/vendor/nanocodex/cloud/Dialog.d.mts +113 -0
  56. package/vendor/nanocodex/cloud/Dialog.mjs +366 -0
  57. package/vendor/nanocodex/cloud/Errors.d.mts +22 -0
  58. package/vendor/nanocodex/cloud/Errors.mjs +39 -0
  59. package/vendor/nanocodex/cloud/Principal.d.mts +26 -0
  60. package/vendor/nanocodex/cloud/Principal.mjs +88 -0
  61. package/vendor/nanocodex/cloud/RemoteProvider.mjs +88 -0
  62. package/vendor/nanocodex/cloud/Transport.d.mts +47 -0
  63. package/vendor/nanocodex/cloud/Transport.mjs +454 -0
  64. package/vendor/nanocodex/cloud/actions/account.d.mts +9 -0
  65. package/vendor/nanocodex/cloud/actions/account.mjs +19 -0
  66. package/vendor/nanocodex/cloud/actions/agent.d.mts +18 -0
  67. package/vendor/nanocodex/cloud/actions/agent.mjs +428 -0
  68. package/vendor/nanocodex/cloud/actions/connection.d.mts +133 -0
  69. package/vendor/nanocodex/cloud/actions/connection.mjs +580 -0
  70. package/vendor/nanocodex/cloud/actions/grant.d.mts +10 -0
  71. package/vendor/nanocodex/cloud/actions/grant.mjs +12 -0
  72. package/vendor/nanocodex/cloud/actions/index.d.mts +7 -0
  73. package/vendor/nanocodex/cloud/actions/index.mjs +7 -0
  74. package/vendor/nanocodex/cloud/actions/machineUsd.d.mts +23 -0
  75. package/vendor/nanocodex/cloud/actions/machineUsd.mjs +37 -0
  76. package/vendor/nanocodex/cloud/actions/model.d.mts +12 -0
  77. package/vendor/nanocodex/cloud/actions/model.mjs +50 -0
  78. package/vendor/nanocodex/cloud/actions/mpp.d.mts +28 -0
  79. package/vendor/nanocodex/cloud/actions/mpp.mjs +39 -0
  80. package/vendor/nanocodex/cloud/index.d.mts +30 -0
  81. package/vendor/nanocodex/cloud/index.mjs +9 -0
  82. package/vendor/nanocodex/cloud/internal.mjs +533 -0
  83. package/vendor/nanocodex/cloud/mercator.mjs +108 -0
  84. package/vendor/nanocodex/cloud/server/HostPrincipal.d.mts +34 -0
  85. package/vendor/nanocodex/cloud/server/HostPrincipal.mjs +202 -0
  86. package/vendor/nanocodex/cloud/server/index.d.mts +1 -0
  87. package/vendor/nanocodex/cloud/server/index.mjs +1 -0
  88. package/vendor/nanocodex/cloud/types.d.mts +211 -0
  89. package/vendor/nanocodex/cloudflare/Agent.d.mts +133 -0
  90. package/vendor/nanocodex/cloudflare/Agent.mjs +811 -0
  91. package/vendor/nanocodex/cloudflare/egress-subject.mjs +19 -0
  92. package/vendor/nanocodex/cloudflare/egress.d.mts +41 -0
  93. package/vendor/nanocodex/cloudflare/egress.mjs +119 -0
  94. package/vendor/nanocodex/cloudflare/event-socket.mjs +316 -0
  95. package/vendor/nanocodex/cloudflare/index.d.mts +7 -0
  96. package/vendor/nanocodex/cloudflare/index.mjs +6 -0
  97. package/vendor/nanocodex/host/Agent.d.mts +55 -0
  98. package/vendor/nanocodex/host/Agent.mjs +1 -0
  99. package/vendor/nanocodex/host/index.d.mts +82 -0
  100. package/vendor/nanocodex/host/index.mjs +10 -0
  101. package/vendor/nanocodex/index.d.mts +81 -0
  102. package/vendor/nanocodex/index.mjs +12 -0
  103. package/vendor/nanocodex/internal.mjs +1275 -0
  104. package/vendor/nanocodex/managed/Agent.d.mts +380 -0
  105. package/vendor/nanocodex/managed/Agent.mjs +1694 -0
  106. package/vendor/nanocodex/managed/ManagedError.d.mts +9 -0
  107. package/vendor/nanocodex/managed/ManagedError.mjs +8 -0
  108. package/vendor/nanocodex/managed/README.md +241 -0
  109. package/vendor/nanocodex/managed/Voice.mjs +202 -0
  110. package/vendor/nanocodex/managed/index.d.mts +20 -0
  111. package/vendor/nanocodex/managed/index.mjs +2 -0
  112. package/vendor/nanocodex/managed/internal.mjs +119 -0
  113. package/vendor/nanocodex/node/Agent.d.mts +50 -0
  114. package/vendor/nanocodex/node/Agent.mjs +203 -0
  115. package/vendor/nanocodex/node/ChatGptSubscription.d.mts +9 -0
  116. package/vendor/nanocodex/node/ChatGptSubscription.mjs +17 -0
  117. package/vendor/nanocodex/node/Transport.d.mts +44 -0
  118. package/vendor/nanocodex/node/Transport.mjs +46 -0
  119. package/vendor/nanocodex/node/host.mjs +731 -0
  120. package/vendor/nanocodex/node/index.d.mts +73 -0
  121. package/vendor/nanocodex/node/index.mjs +17 -0
  122. package/vendor/nanocodex/node/workspace.d.mts +10 -0
  123. package/vendor/nanocodex/node/workspace.mjs +198 -0
  124. package/vendor/nanocodex/package.json +200 -0
  125. package/vendor/nanocodex/pkg-node/nanocodex.d.ts +675 -0
  126. package/vendor/nanocodex/pkg-node/nanocodex.js +2628 -0
  127. package/vendor/nanocodex/pkg-node/nanocodex_bg.wasm.d.ts +105 -0
  128. package/vendor/nanocodex/pkg-node/package.json +1 -0
  129. package/vendor/nanocodex/pkg-web/.nanocodex-bindgen-stamp +6 -0
  130. package/vendor/nanocodex/pkg-web/nanocodex-build.json +1 -0
  131. package/vendor/nanocodex/pkg-web/nanocodex.d.ts +805 -0
  132. package/vendor/nanocodex/pkg-web/nanocodex.js +2714 -0
  133. package/vendor/nanocodex/pkg-web/nanocodex_bg.js +2615 -0
  134. package/vendor/nanocodex/pkg-web/nanocodex_bg.wasm +0 -0
  135. package/vendor/nanocodex/pkg-web/nanocodex_bg.wasm.d.ts +105 -0
  136. package/vendor/nanocodex/pkg-web/nanocodex_worker.js +9 -0
  137. package/vendor/nanocodex/pkg-web/package.json +1 -0
  138. package/vendor/nanocodex/runtime/chatgpt-subscription.mjs +212 -0
  139. package/vendor/nanocodex/runtime/cloudflare-durability-store.d.mts +26 -0
  140. package/vendor/nanocodex/runtime/cloudflare-durability-store.mjs +168 -0
  141. package/vendor/nanocodex/runtime/code-evaluator.worker.mjs +137 -0
  142. package/vendor/nanocodex/runtime/code-runtime.mjs +1 -0
  143. package/vendor/nanocodex/runtime/durability-store.d.mts +85 -0
  144. package/vendor/nanocodex/runtime/durability-store.mjs +631 -0
  145. package/vendor/nanocodex/runtime/durability.mjs +153 -0
  146. package/vendor/nanocodex/runtime/managed-transport.mjs +460 -0
  147. package/vendor/nanocodex/runtime/mcp-runtime.mjs +534 -0
  148. package/vendor/nanocodex/runtime/postgres-durability-store.d.mts +64 -0
  149. package/vendor/nanocodex/runtime/postgres-durability-store.mjs +532 -0
  150. package/vendor/nanocodex/runtime/quickjs-evaluator.d.mts +17 -0
  151. package/vendor/nanocodex/runtime/quickjs-evaluator.mjs +236 -0
  152. package/vendor/nanocodex/runtime/responses-transport.mjs +22 -0
  153. package/vendor/nanocodex/runtime/subagents.d.mts +107 -0
  154. package/vendor/nanocodex/runtime/subagents.mjs +54 -0
  155. package/vendor/nanocodex/runtime/subscription-store.d.mts +8 -0
  156. package/vendor/nanocodex/runtime/subscription-store.mjs +42 -0
  157. package/vendor/nanocodex/runtime/tempo-provider.d.mts +125 -0
  158. package/vendor/nanocodex/runtime/tempo-provider.mjs +264 -0
  159. package/vendor/nanocodex/runtime/tool-configuration.mjs +1 -0
  160. package/vendor/nanocodex/runtime/tool-router.mjs +1 -0
  161. package/vendor/nanocodex/runtime/utf8.mjs +1 -0
  162. package/vendor/nanocodex/runtime/worker-evaluator.mjs +162 -0
  163. package/vendor/nanocodex/runtime/workspace.d.mts +1 -0
  164. package/vendor/nanocodex/runtime/workspace.mjs +1 -0
  165. package/vendor/nanocodex/tools/Tools.d.mts +56 -0
  166. package/vendor/nanocodex/tools/Tools.mjs +136 -0
  167. package/vendor/nanocodex/tools/artifact.d.mts +1 -0
  168. package/vendor/nanocodex/tools/artifact.mjs +1 -0
  169. package/vendor/nanocodex/tools/attachment.mjs +1 -0
  170. package/vendor/nanocodex/tools/bash.d.mts +1 -0
  171. package/vendor/nanocodex/tools/bash.mjs +1 -0
  172. package/vendor/nanocodex/tools/browser/accountInfo.mjs +795 -0
  173. package/vendor/nanocodex/tools/browser/browserBuffer.mjs +18 -0
  174. package/vendor/nanocodex/tools/browser/browserCompiler.mjs +155 -0
  175. package/vendor/nanocodex/tools/browser/browserEgress.mjs +161 -0
  176. package/vendor/nanocodex/tools/browser/browserPython.mjs +133 -0
  177. package/vendor/nanocodex/tools/browser/browserShell.mjs +1075 -0
  178. package/vendor/nanocodex/tools/browser/browserSprintf.mjs +4 -0
  179. package/vendor/nanocodex/tools/browser/browserSsh.mjs +201 -0
  180. package/vendor/nanocodex/tools/browser/browserZlib.mjs +136 -0
  181. package/vendor/nanocodex/tools/browser/compiler.worker.mjs +160 -0
  182. package/vendor/nanocodex/tools/browser/devTunnelsSshBrowser.mjs +13 -0
  183. package/vendor/nanocodex/tools/browser/index.d.mts +209 -0
  184. package/vendor/nanocodex/tools/browser/index.mjs +174 -0
  185. package/vendor/nanocodex/tools/browser/opfsGit.mjs +248 -0
  186. package/vendor/nanocodex/tools/browser/python.worker.mjs +114 -0
  187. package/vendor/nanocodex/tools/browser/threadGit.mjs +197 -0
  188. package/vendor/nanocodex/tools/browser/unsupportedNodeRsa.mjs +5 -0
  189. package/vendor/nanocodex/tools/browser/workspace.mjs +83 -0
  190. package/vendor/nanocodex/tools/dataset.d.mts +1 -0
  191. package/vendor/nanocodex/tools/dataset.mjs +1 -0
  192. package/vendor/nanocodex/tools/datasetContract.mjs +1 -0
  193. package/vendor/nanocodex/tools/datasetEngine.mjs +1 -0
  194. package/vendor/nanocodex/tools/hostedCatalog.d.mts +1 -0
  195. package/vendor/nanocodex/tools/hostedCatalog.mjs +1 -0
  196. package/vendor/nanocodex/tools/index.d.mts +49 -0
  197. package/vendor/nanocodex/tools/index.mjs +19 -0
  198. package/vendor/nanocodex/tools/namedTool.mjs +1 -0
  199. package/vendor/nanocodex/tools/repository-workspace.d.mts +1 -0
  200. package/vendor/nanocodex/tools/repository-workspace.mjs +1 -0
  201. package/vendor/nanocodex/tools/ssh.d.mts +1 -0
  202. package/vendor/nanocodex/tools/ssh.mjs +1 -0
  203. package/vendor/nanocodex/tools/standard.mjs +1 -0
  204. package/vendor/nanocodex/tools/standardDescriptions.mjs +1 -0
  205. package/vendor/nanocodex/types.d.mts +663 -0
  206. package/vendor/nanocodex/wasm.d.mts +4 -0
  207. package/vendor/nanocodex/worker/ChatGptSubscription.d.mts +9 -0
  208. package/vendor/nanocodex/worker/ChatGptSubscription.mjs +29 -0
  209. package/vendor/nanocodex/worker/index.d.mts +18 -0
  210. package/vendor/nanocodex/worker/index.mjs +5 -0
  211. package/vendor/nanocodex-tools/README.md +65 -0
  212. package/vendor/nanocodex-tools/dist/hosted/app-tool-catalog.d.ts +7 -0
  213. package/vendor/nanocodex-tools/dist/hosted/app-tool-catalog.js +14 -0
  214. package/vendor/nanocodex-tools/dist/hosted/broker-core.d.ts +172 -0
  215. package/vendor/nanocodex-tools/dist/hosted/broker-core.js +1278 -0
  216. package/vendor/nanocodex-tools/dist/hosted/index.d.ts +3 -0
  217. package/vendor/nanocodex-tools/dist/hosted/index.js +3 -0
  218. package/vendor/nanocodex-tools/dist/hosted/protocol.d.ts +120 -0
  219. package/vendor/nanocodex-tools/dist/hosted/protocol.js +415 -0
  220. package/vendor/nanocodex-tools/dist/index.d.ts +19 -0
  221. package/vendor/nanocodex-tools/dist/index.js +14 -0
  222. package/vendor/nanocodex-tools/dist/memory.d.ts +204 -0
  223. package/vendor/nanocodex-tools/dist/memory.js +411 -0
  224. package/vendor/nanocodex-tools/dist/namespace.d.ts +87 -0
  225. package/vendor/nanocodex-tools/dist/namespace.js +338 -0
  226. package/vendor/nanocodex-tools/dist/repository-archive.d.ts +4 -0
  227. package/vendor/nanocodex-tools/dist/repository-archive.js +104 -0
  228. package/vendor/nanocodex-tools/dist/runtime.d.ts +30 -0
  229. package/vendor/nanocodex-tools/dist/runtime.js +37 -0
  230. package/vendor/nanocodex-tools/dist/session.d.ts +167 -0
  231. package/vendor/nanocodex-tools/dist/session.js +286 -0
  232. package/vendor/nanocodex-tools/dist/shell.d.ts +51 -0
  233. package/vendor/nanocodex-tools/dist/shell.js +553 -0
  234. package/vendor/nanocodex-tools/dist/ssh.d.ts +29 -0
  235. package/vendor/nanocodex-tools/dist/ssh.js +66 -0
  236. package/vendor/nanocodex-tools/dist/workspace.d.ts +45 -0
  237. package/vendor/nanocodex-tools/dist/workspace.js +237 -0
  238. package/vendor/nanocodex-tools/package.json +122 -0
  239. package/vendor/nanocodex-tools/runtime/code-runtime.mjs +817 -0
  240. package/vendor/nanocodex-tools/runtime/tool-configuration.mjs +50 -0
  241. package/vendor/nanocodex-tools/runtime/tool-router.mjs +730 -0
  242. package/vendor/nanocodex-tools/runtime/utf8.d.mts +2 -0
  243. package/vendor/nanocodex-tools/runtime/utf8.mjs +25 -0
  244. package/vendor/nanocodex-tools/tools/artifact.d.mts +69 -0
  245. package/vendor/nanocodex-tools/tools/artifact.mjs +270 -0
  246. package/vendor/nanocodex-tools/tools/attachment.mjs +603 -0
  247. package/vendor/nanocodex-tools/tools/bash.d.mts +90 -0
  248. package/vendor/nanocodex-tools/tools/bash.mjs +742 -0
  249. package/vendor/nanocodex-tools/tools/dataset.d.mts +9 -0
  250. package/vendor/nanocodex-tools/tools/dataset.mjs +47 -0
  251. package/vendor/nanocodex-tools/tools/datasetContract.mjs +54 -0
  252. package/vendor/nanocodex-tools/tools/datasetEngine.mjs +1167 -0
  253. package/vendor/nanocodex-tools/tools/execution-contract.d.mts +5 -0
  254. package/vendor/nanocodex-tools/tools/execution-contract.mjs +63 -0
  255. package/vendor/nanocodex-tools/tools/hostedCatalog.d.mts +20 -0
  256. package/vendor/nanocodex-tools/tools/hostedCatalog.mjs +67 -0
  257. package/vendor/nanocodex-tools/tools/hostedMachine.d.mts +10 -0
  258. package/vendor/nanocodex-tools/tools/hostedMachine.mjs +56 -0
  259. package/vendor/nanocodex-tools/tools/just-bash-browser.d.mts +1 -0
  260. package/vendor/nanocodex-tools/tools/just-bash-browser.mjs +1 -0
  261. package/vendor/nanocodex-tools/tools/namedTool.d.mts +3 -0
  262. package/vendor/nanocodex-tools/tools/namedTool.mjs +3 -0
  263. package/vendor/nanocodex-tools/tools/nodeProcess.d.mts +10 -0
  264. package/vendor/nanocodex-tools/tools/nodeProcess.mjs +314 -0
  265. package/vendor/nanocodex-tools/tools/processOutput.mjs +56 -0
  266. package/vendor/nanocodex-tools/tools/repository-workspace.d.mts +55 -0
  267. package/vendor/nanocodex-tools/tools/repository-workspace.mjs +397 -0
  268. package/vendor/nanocodex-tools/tools/ssh.d.mts +56 -0
  269. package/vendor/nanocodex-tools/tools/ssh.mjs +503 -0
  270. package/vendor/nanocodex-tools/tools/standard.mjs +458 -0
  271. package/vendor/nanocodex-tools/tools/standardDescriptions.mjs +3 -0
  272. package/vendor/nanocodex-tools/tools/types.d.mts +83 -0
  273. package/vendor/nanocodex-tools/tools/workspace.d.mts +25 -0
  274. package/vendor/nanocodex-tools/tools/workspace.mjs +282 -0
  275. package/vendor/nanocodex-tools/tools/x.d.mts +30 -0
  276. package/vendor/nanocodex-tools/tools/x.mjs +91 -0
@@ -0,0 +1,2714 @@
1
+ /* @ts-self-types="./nanocodex.d.ts" */
2
+
3
+ /**
4
+ * Rust-owned Codex browser voice protocol and Agent bridge.
5
+ */
6
+ export class BrowserVoice {
7
+ static __wrap(ptr) {
8
+ const obj = Object.create(BrowserVoice.prototype);
9
+ obj.__wbg_ptr = ptr;
10
+ BrowserVoiceFinalization.register(obj, obj.__wbg_ptr, obj);
11
+ return obj;
12
+ }
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ BrowserVoiceFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_browservoice_free(ptr, 0);
22
+ }
23
+ /**
24
+ * Applies one typed Agent event to the Rust-owned handoff stream.
25
+ *
26
+ * # Errors
27
+ *
28
+ * Rejects only when effects cannot be serialized.
29
+ * @param {string} envelope
30
+ * @returns {string}
31
+ */
32
+ agentEvent(envelope) {
33
+ let deferred3_0;
34
+ let deferred3_1;
35
+ try {
36
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
37
+ const ptr0 = passStringToWasm0(envelope, wasm.__wbindgen_export, wasm.__wbindgen_export2);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ wasm.browservoice_agentEvent(retptr, this.__wbg_ptr, ptr0, len0);
40
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
41
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
42
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
43
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
44
+ var ptr2 = r0;
45
+ var len2 = r1;
46
+ if (r3) {
47
+ ptr2 = 0; len2 = 0;
48
+ throw takeObject(r2);
49
+ }
50
+ deferred3_0 = ptr2;
51
+ deferred3_1 = len2;
52
+ return getStringFromWasm0(ptr2, len2);
53
+ } finally {
54
+ wasm.__wbindgen_add_to_stack_pointer(16);
55
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
56
+ }
57
+ }
58
+ /**
59
+ * Adds background context without requesting speech or consuming a delegation.
60
+ *
61
+ * # Errors
62
+ * Rejects an inactive session or invalid text.
63
+ * @param {string} text
64
+ * @returns {string}
65
+ */
66
+ appendContext(text) {
67
+ let deferred3_0;
68
+ let deferred3_1;
69
+ try {
70
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
71
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ wasm.browservoice_appendContext(retptr, this.__wbg_ptr, ptr0, len0);
74
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
75
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
76
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
77
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
78
+ var ptr2 = r0;
79
+ var len2 = r1;
80
+ if (r3) {
81
+ ptr2 = 0; len2 = 0;
82
+ throw takeObject(r2);
83
+ }
84
+ deferred3_0 = ptr2;
85
+ deferred3_1 = len2;
86
+ return getStringFromWasm0(ptr2, len2);
87
+ } finally {
88
+ wasm.__wbindgen_add_to_stack_pointer(16);
89
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
90
+ }
91
+ }
92
+ /**
93
+ * Queues explicitly speakable text in the current conversation.
94
+ *
95
+ * # Errors
96
+ * Rejects inactive sessions, invalid text, or a full output queue.
97
+ * @param {string} text
98
+ * @returns {string}
99
+ */
100
+ appendSpeech(text) {
101
+ let deferred3_0;
102
+ let deferred3_1;
103
+ try {
104
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
105
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
106
+ const len0 = WASM_VECTOR_LEN;
107
+ wasm.browservoice_appendSpeech(retptr, this.__wbg_ptr, ptr0, len0);
108
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
109
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
110
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
111
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
112
+ var ptr2 = r0;
113
+ var len2 = r1;
114
+ if (r3) {
115
+ ptr2 = 0; len2 = 0;
116
+ throw takeObject(r2);
117
+ }
118
+ deferred3_0 = ptr2;
119
+ deferred3_1 = len2;
120
+ return getStringFromWasm0(ptr2, len2);
121
+ } finally {
122
+ wasm.__wbindgen_add_to_stack_pointer(16);
123
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
124
+ }
125
+ }
126
+ /**
127
+ * Appends text through Codex's subscription context adapter.
128
+ *
129
+ * # Errors
130
+ * Rejects inactive sessions, invalid roles/text, or a full output queue.
131
+ * @param {string} role
132
+ * @param {string} text
133
+ * @returns {string}
134
+ */
135
+ appendText(role, text) {
136
+ let deferred4_0;
137
+ let deferred4_1;
138
+ try {
139
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
140
+ const ptr0 = passStringToWasm0(role, wasm.__wbindgen_export, wasm.__wbindgen_export2);
141
+ const len0 = WASM_VECTOR_LEN;
142
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
143
+ const len1 = WASM_VECTOR_LEN;
144
+ wasm.browservoice_appendText(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
145
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
146
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
147
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
148
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
149
+ var ptr3 = r0;
150
+ var len3 = r1;
151
+ if (r3) {
152
+ ptr3 = 0; len3 = 0;
153
+ throw takeObject(r2);
154
+ }
155
+ deferred4_0 = ptr3;
156
+ deferred4_1 = len3;
157
+ return getStringFromWasm0(ptr3, len3);
158
+ } finally {
159
+ wasm.__wbindgen_add_to_stack_pointer(16);
160
+ wasm.__wbindgen_export5(deferred4_0, deferred4_1, 1);
161
+ }
162
+ }
163
+ /**
164
+ * Encodes the complete same-origin call request after the browser creates its SDP offer.
165
+ *
166
+ * # Errors
167
+ *
168
+ * Rejects calls made before [`Self::start`] or an empty SDP offer.
169
+ * @param {string} sdp
170
+ * @returns {string}
171
+ */
172
+ callBody(sdp) {
173
+ let deferred3_0;
174
+ let deferred3_1;
175
+ try {
176
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
177
+ const ptr0 = passStringToWasm0(sdp, wasm.__wbindgen_export, wasm.__wbindgen_export2);
178
+ const len0 = WASM_VECTOR_LEN;
179
+ wasm.browservoice_callBody(retptr, this.__wbg_ptr, ptr0, len0);
180
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
181
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
182
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
183
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
184
+ var ptr2 = r0;
185
+ var len2 = r1;
186
+ if (r3) {
187
+ ptr2 = 0; len2 = 0;
188
+ throw takeObject(r2);
189
+ }
190
+ deferred3_0 = ptr2;
191
+ deferred3_1 = len2;
192
+ return getStringFromWasm0(ptr2, len2);
193
+ } finally {
194
+ wasm.__wbindgen_add_to_stack_pointer(16);
195
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
196
+ }
197
+ }
198
+ /**
199
+ * Cancels only the active coding turn, never merely the voice transport.
200
+ *
201
+ * # Errors
202
+ *
203
+ * Rejects when the active turn cannot be cancelled.
204
+ * @returns {Promise<boolean>}
205
+ */
206
+ cancel() {
207
+ const ret = wasm.browservoice_cancel(this.__wbg_ptr);
208
+ return takeObject(ret);
209
+ }
210
+ /**
211
+ * Decodes Codex's provider response body and Location header in Rust.
212
+ *
213
+ * # Errors
214
+ *
215
+ * Rejects an empty SDP answer or a Location without a Codex call identity.
216
+ * @param {string} response_body
217
+ * @param {string} location
218
+ * @returns {string}
219
+ */
220
+ completeCall(response_body, location) {
221
+ let deferred4_0;
222
+ let deferred4_1;
223
+ try {
224
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
225
+ const ptr0 = passStringToWasm0(response_body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
226
+ const len0 = WASM_VECTOR_LEN;
227
+ const ptr1 = passStringToWasm0(location, wasm.__wbindgen_export, wasm.__wbindgen_export2);
228
+ const len1 = WASM_VECTOR_LEN;
229
+ wasm.browservoice_completeCall(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
230
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
231
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
232
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
233
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
234
+ var ptr3 = r0;
235
+ var len3 = r1;
236
+ if (r3) {
237
+ ptr3 = 0; len3 = 0;
238
+ throw takeObject(r2);
239
+ }
240
+ deferred4_0 = ptr3;
241
+ deferred4_1 = len3;
242
+ return getStringFromWasm0(ptr3, len3);
243
+ } finally {
244
+ wasm.__wbindgen_add_to_stack_pointer(16);
245
+ wasm.__wbindgen_export5(deferred4_0, deferred4_1, 1);
246
+ }
247
+ }
248
+ /**
249
+ * Sets subscription voice preferences before starting a call.
250
+ *
251
+ * # Errors
252
+ * Rejects invalid settings or changes to an active call.
253
+ * @param {string} settings_json
254
+ */
255
+ configure(settings_json) {
256
+ try {
257
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
258
+ const ptr0 = passStringToWasm0(settings_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
259
+ const len0 = WASM_VECTOR_LEN;
260
+ wasm.browservoice_configure(retptr, this.__wbg_ptr, ptr0, len0);
261
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
262
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
263
+ if (r1) {
264
+ throw takeObject(r0);
265
+ }
266
+ } finally {
267
+ wasm.__wbindgen_add_to_stack_pointer(16);
268
+ }
269
+ }
270
+ /**
271
+ * Drains one Codex-paced streamed or final Agent handoff chunk.
272
+ *
273
+ * # Errors
274
+ *
275
+ * Rejects only when effects cannot be serialized.
276
+ * @param {boolean} final_chunk
277
+ * @returns {string}
278
+ */
279
+ flush(final_chunk) {
280
+ let deferred2_0;
281
+ let deferred2_1;
282
+ try {
283
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
284
+ wasm.browservoice_flush(retptr, this.__wbg_ptr, final_chunk);
285
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
286
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
287
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
288
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
289
+ var ptr1 = r0;
290
+ var len1 = r1;
291
+ if (r3) {
292
+ ptr1 = 0; len1 = 0;
293
+ throw takeObject(r2);
294
+ }
295
+ deferred2_0 = ptr1;
296
+ deferred2_1 = len1;
297
+ return getStringFromWasm0(ptr1, len1);
298
+ } finally {
299
+ wasm.__wbindgen_add_to_stack_pointer(16);
300
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
301
+ }
302
+ }
303
+ /**
304
+ * Acknowledges frames written by the browser WebSocket effect executor.
305
+ * @param {number} count
306
+ */
307
+ framesSent(count) {
308
+ wasm.browservoice_framesSent(this.__wbg_ptr, count);
309
+ }
310
+ /**
311
+ * Selects Codex's preferred physical input from browser device labels.
312
+ *
313
+ * # Errors
314
+ *
315
+ * Rejects malformed label JSON.
316
+ * @param {string} current_label
317
+ * @param {string} labels_json
318
+ * @returns {number | undefined}
319
+ */
320
+ preferredPhysicalInput(current_label, labels_json) {
321
+ try {
322
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
323
+ const ptr0 = passStringToWasm0(current_label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
324
+ const len0 = WASM_VECTOR_LEN;
325
+ const ptr1 = passStringToWasm0(labels_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
326
+ const len1 = WASM_VECTOR_LEN;
327
+ wasm.browservoice_preferredPhysicalInput(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
328
+ var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
329
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
330
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
331
+ if (r3) {
332
+ throw takeObject(r2);
333
+ }
334
+ return r0 === Number.MAX_SAFE_INTEGER ? undefined : r0;
335
+ } finally {
336
+ wasm.__wbindgen_add_to_stack_pointer(16);
337
+ }
338
+ }
339
+ /**
340
+ * Applies one Frameless sideband event and routes any delegation through the Rust Agent.
341
+ *
342
+ * # Errors
343
+ *
344
+ * Rejects when delegated Agent work cannot be accepted or steered.
345
+ * @param {string} payload
346
+ * @returns {Promise<string>}
347
+ */
348
+ realtimeMessage(payload) {
349
+ const ptr0 = passStringToWasm0(payload, wasm.__wbindgen_export, wasm.__wbindgen_export2);
350
+ const len0 = WASM_VECTOR_LEN;
351
+ const ret = wasm.browservoice_realtimeMessage(this.__wbg_ptr, ptr0, len0);
352
+ return takeObject(ret);
353
+ }
354
+ /**
355
+ * Reports whether one Rust-decoded sideband event can admit Agent work.
356
+ * @param {string} payload
357
+ * @returns {boolean}
358
+ */
359
+ requiresAgentAdmission(payload) {
360
+ const ptr0 = passStringToWasm0(payload, wasm.__wbindgen_export, wasm.__wbindgen_export2);
361
+ const len0 = WASM_VECTOR_LEN;
362
+ const ret = wasm.browservoice_requiresAgentAdmission(this.__wbg_ptr, ptr0, len0);
363
+ return ret !== 0;
364
+ }
365
+ /**
366
+ * Applies Codex's Rust-owned Frameless reconnect policy after transport loss.
367
+ *
368
+ * # Errors
369
+ *
370
+ * Rejects only when effects cannot be serialized.
371
+ * @param {number} connected_ms
372
+ * @returns {string}
373
+ */
374
+ sidebandClosed(connected_ms) {
375
+ let deferred2_0;
376
+ let deferred2_1;
377
+ try {
378
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
379
+ wasm.browservoice_sidebandClosed(retptr, this.__wbg_ptr, connected_ms);
380
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
381
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
382
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
383
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
384
+ var ptr1 = r0;
385
+ var len1 = r1;
386
+ if (r3) {
387
+ ptr1 = 0; len1 = 0;
388
+ throw takeObject(r2);
389
+ }
390
+ deferred2_0 = ptr1;
391
+ deferred2_1 = len1;
392
+ return getStringFromWasm0(ptr1, len1);
393
+ } finally {
394
+ wasm.__wbindgen_add_to_stack_pointer(16);
395
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
396
+ }
397
+ }
398
+ /**
399
+ * Replays Rust-retained outbound frames after a sideband connects.
400
+ *
401
+ * # Errors
402
+ *
403
+ * Rejects only when effects cannot be serialized.
404
+ * @returns {string}
405
+ */
406
+ sidebandOpened() {
407
+ let deferred2_0;
408
+ let deferred2_1;
409
+ try {
410
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
411
+ wasm.browservoice_sidebandOpened(retptr, this.__wbg_ptr);
412
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
413
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
414
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
415
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
416
+ var ptr1 = r0;
417
+ var len1 = r1;
418
+ if (r3) {
419
+ ptr1 = 0; len1 = 0;
420
+ throw takeObject(r2);
421
+ }
422
+ deferred2_0 = ptr1;
423
+ deferred2_1 = len1;
424
+ return getStringFromWasm0(ptr1, len1);
425
+ } finally {
426
+ wasm.__wbindgen_add_to_stack_pointer(16);
427
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
428
+ }
429
+ }
430
+ /**
431
+ * Builds the same-origin sideband URL with Codex's Rust-owned request identity.
432
+ *
433
+ * # Errors
434
+ *
435
+ * Rejects a malformed provider call identity.
436
+ * @param {string} call_id
437
+ * @returns {string}
438
+ */
439
+ sidebandUrl(call_id) {
440
+ let deferred3_0;
441
+ let deferred3_1;
442
+ try {
443
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
444
+ const ptr0 = passStringToWasm0(call_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
445
+ const len0 = WASM_VECTOR_LEN;
446
+ wasm.browservoice_sidebandUrl(retptr, this.__wbg_ptr, ptr0, len0);
447
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
448
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
449
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
450
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
451
+ var ptr2 = r0;
452
+ var len2 = r1;
453
+ if (r3) {
454
+ ptr2 = 0; len2 = 0;
455
+ throw takeObject(r2);
456
+ }
457
+ deferred3_0 = ptr2;
458
+ deferred3_1 = len2;
459
+ return getStringFromWasm0(ptr2, len2);
460
+ } finally {
461
+ wasm.__wbindgen_add_to_stack_pointer(16);
462
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
463
+ }
464
+ }
465
+ /**
466
+ * Begins Codex's Realtime lifecycle and builds bounded browser startup context in Rust.
467
+ *
468
+ * # Errors
469
+ *
470
+ * Rejects when the Agent driver has stopped.
471
+ * @returns {Promise<void>}
472
+ */
473
+ start() {
474
+ const ret = wasm.browservoice_start(this.__wbg_ptr);
475
+ return takeObject(ret);
476
+ }
477
+ /**
478
+ * Flushes any final transcript tail and ends Codex's Realtime lifecycle.
479
+ *
480
+ * # Errors
481
+ *
482
+ * Rejects when the Agent driver stops.
483
+ * @returns {Promise<string>}
484
+ */
485
+ stop() {
486
+ const ret = wasm.browservoice_stop(this.__wbg_ptr);
487
+ return takeObject(ret);
488
+ }
489
+ }
490
+ if (Symbol.dispose) BrowserVoice.prototype[Symbol.dispose] = BrowserVoice.prototype.free;
491
+
492
+ /**
493
+ * JavaScript binding over the Rust-owned hosted ChatGPT credential lifecycle.
494
+ */
495
+ export class ChatGptSubscription {
496
+ static __wrap(ptr) {
497
+ const obj = Object.create(ChatGptSubscription.prototype);
498
+ obj.__wbg_ptr = ptr;
499
+ ChatGptSubscriptionFinalization.register(obj, obj.__wbg_ptr, obj);
500
+ return obj;
501
+ }
502
+ __destroy_into_raw() {
503
+ const ptr = this.__wbg_ptr;
504
+ this.__wbg_ptr = 0;
505
+ ChatGptSubscriptionFinalization.unregister(this);
506
+ return ptr;
507
+ }
508
+ free() {
509
+ const ptr = this.__destroy_into_raw();
510
+ wasm.__wbg_chatgptsubscription_free(ptr, 0);
511
+ }
512
+ /**
513
+ * Resolves one credential generation for a host-owned outbound request.
514
+ * @returns {Promise<string>}
515
+ */
516
+ credential() {
517
+ const ret = wasm.chatgptsubscription_credential(this.__wbg_ptr);
518
+ return takeObject(ret);
519
+ }
520
+ /**
521
+ * Clears the persisted credential and pending login.
522
+ * @returns {Promise<void>}
523
+ */
524
+ logout() {
525
+ const ret = wasm.chatgptsubscription_logout(this.__wbg_ptr);
526
+ return takeObject(ret);
527
+ }
528
+ /**
529
+ * Opens a subscription over the currently registered generic host capabilities.
530
+ * @param {string} config_json
531
+ * @returns {Promise<ChatGptSubscription>}
532
+ */
533
+ static open(config_json) {
534
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
535
+ const len0 = WASM_VECTOR_LEN;
536
+ const ret = wasm.chatgptsubscription_open(ptr0, len0);
537
+ return takeObject(ret);
538
+ }
539
+ /**
540
+ * Refreshes a rejected generation and returns the credential now current.
541
+ * @param {string} rejected_revision
542
+ * @returns {Promise<string>}
543
+ */
544
+ recover(rejected_revision) {
545
+ const ptr0 = passStringToWasm0(rejected_revision, wasm.__wbindgen_export, wasm.__wbindgen_export2);
546
+ const len0 = WASM_VECTOR_LEN;
547
+ const ret = wasm.chatgptsubscription_recover(this.__wbg_ptr, ptr0, len0);
548
+ return takeObject(ret);
549
+ }
550
+ /**
551
+ * Starts a ChatGPT device login and returns public pending state as JSON.
552
+ * @returns {Promise<string>}
553
+ */
554
+ startLogin() {
555
+ const ret = wasm.chatgptsubscription_startLogin(this.__wbg_ptr);
556
+ return takeObject(ret);
557
+ }
558
+ /**
559
+ * Polls device login and returns public state as JSON.
560
+ * @returns {Promise<string>}
561
+ */
562
+ status() {
563
+ const ret = wasm.chatgptsubscription_status(this.__wbg_ptr);
564
+ return takeObject(ret);
565
+ }
566
+ }
567
+ if (Symbol.dispose) ChatGptSubscription.prototype[Symbol.dispose] = ChatGptSubscription.prototype.free;
568
+
569
+ /**
570
+ * Standalone Rust-owned browser voice protocol for a remote managed Agent.
571
+ *
572
+ * This core owns only Realtime protocol state. The caller owns media,
573
+ * transports, the managed Agent lifecycle, and routing returned delegations.
574
+ */
575
+ export class ManagedBrowserVoice {
576
+ __destroy_into_raw() {
577
+ const ptr = this.__wbg_ptr;
578
+ this.__wbg_ptr = 0;
579
+ ManagedBrowserVoiceFinalization.unregister(this);
580
+ return ptr;
581
+ }
582
+ free() {
583
+ const ptr = this.__destroy_into_raw();
584
+ wasm.__wbg_managedbrowservoice_free(ptr, 0);
585
+ }
586
+ /**
587
+ * Applies one canonical raw `AgentEvent` JSON value to the handoff stream.
588
+ *
589
+ * # Errors
590
+ *
591
+ * Rejects only when effects cannot be serialized.
592
+ * @param {string} event_json
593
+ * @returns {string}
594
+ */
595
+ agentEvent(event_json) {
596
+ let deferred3_0;
597
+ let deferred3_1;
598
+ try {
599
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
600
+ const ptr0 = passStringToWasm0(event_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
601
+ const len0 = WASM_VECTOR_LEN;
602
+ wasm.managedbrowservoice_agentEvent(retptr, this.__wbg_ptr, ptr0, len0);
603
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
604
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
605
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
606
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
607
+ var ptr2 = r0;
608
+ var len2 = r1;
609
+ if (r3) {
610
+ ptr2 = 0; len2 = 0;
611
+ throw takeObject(r2);
612
+ }
613
+ deferred3_0 = ptr2;
614
+ deferred3_1 = len2;
615
+ return getStringFromWasm0(ptr2, len2);
616
+ } finally {
617
+ wasm.__wbindgen_add_to_stack_pointer(16);
618
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
619
+ }
620
+ }
621
+ /**
622
+ * Adds background context without requesting speech or consuming a delegation.
623
+ *
624
+ * # Errors
625
+ * Rejects an inactive session or invalid text.
626
+ * @param {string} text
627
+ * @returns {string}
628
+ */
629
+ appendContext(text) {
630
+ let deferred3_0;
631
+ let deferred3_1;
632
+ try {
633
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
634
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
635
+ const len0 = WASM_VECTOR_LEN;
636
+ wasm.managedbrowservoice_appendContext(retptr, this.__wbg_ptr, ptr0, len0);
637
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
638
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
639
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
640
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
641
+ var ptr2 = r0;
642
+ var len2 = r1;
643
+ if (r3) {
644
+ ptr2 = 0; len2 = 0;
645
+ throw takeObject(r2);
646
+ }
647
+ deferred3_0 = ptr2;
648
+ deferred3_1 = len2;
649
+ return getStringFromWasm0(ptr2, len2);
650
+ } finally {
651
+ wasm.__wbindgen_add_to_stack_pointer(16);
652
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
653
+ }
654
+ }
655
+ /**
656
+ * Queues explicitly speakable text in the current conversation.
657
+ *
658
+ * # Errors
659
+ * Rejects inactive sessions, invalid text, or a full output queue.
660
+ * @param {string} text
661
+ * @returns {string}
662
+ */
663
+ appendSpeech(text) {
664
+ let deferred3_0;
665
+ let deferred3_1;
666
+ try {
667
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
668
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
669
+ const len0 = WASM_VECTOR_LEN;
670
+ wasm.managedbrowservoice_appendSpeech(retptr, this.__wbg_ptr, ptr0, len0);
671
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
672
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
673
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
674
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
675
+ var ptr2 = r0;
676
+ var len2 = r1;
677
+ if (r3) {
678
+ ptr2 = 0; len2 = 0;
679
+ throw takeObject(r2);
680
+ }
681
+ deferred3_0 = ptr2;
682
+ deferred3_1 = len2;
683
+ return getStringFromWasm0(ptr2, len2);
684
+ } finally {
685
+ wasm.__wbindgen_add_to_stack_pointer(16);
686
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
687
+ }
688
+ }
689
+ /**
690
+ * Appends text through Codex's subscription context adapter.
691
+ *
692
+ * # Errors
693
+ * Rejects inactive sessions, invalid roles/text, or a full output queue.
694
+ * @param {string} role
695
+ * @param {string} text
696
+ * @returns {string}
697
+ */
698
+ appendText(role, text) {
699
+ let deferred4_0;
700
+ let deferred4_1;
701
+ try {
702
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
703
+ const ptr0 = passStringToWasm0(role, wasm.__wbindgen_export, wasm.__wbindgen_export2);
704
+ const len0 = WASM_VECTOR_LEN;
705
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
706
+ const len1 = WASM_VECTOR_LEN;
707
+ wasm.managedbrowservoice_appendText(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
708
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
709
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
710
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
711
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
712
+ var ptr3 = r0;
713
+ var len3 = r1;
714
+ if (r3) {
715
+ ptr3 = 0; len3 = 0;
716
+ throw takeObject(r2);
717
+ }
718
+ deferred4_0 = ptr3;
719
+ deferred4_1 = len3;
720
+ return getStringFromWasm0(ptr3, len3);
721
+ } finally {
722
+ wasm.__wbindgen_add_to_stack_pointer(16);
723
+ wasm.__wbindgen_export5(deferred4_0, deferred4_1, 1);
724
+ }
725
+ }
726
+ /**
727
+ * Encodes the managed same-origin call request after the browser creates its SDP offer.
728
+ *
729
+ * # Errors
730
+ *
731
+ * Rejects invalid session IDs or empty SDP offers. Admission can complete
732
+ * after this request; its context is then sent over the control channel.
733
+ * @param {string} sdp
734
+ * @param {string} managed_session_id
735
+ * @returns {string}
736
+ */
737
+ callBody(sdp, managed_session_id) {
738
+ let deferred4_0;
739
+ let deferred4_1;
740
+ try {
741
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
742
+ const ptr0 = passStringToWasm0(sdp, wasm.__wbindgen_export, wasm.__wbindgen_export2);
743
+ const len0 = WASM_VECTOR_LEN;
744
+ const ptr1 = passStringToWasm0(managed_session_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
745
+ const len1 = WASM_VECTOR_LEN;
746
+ wasm.managedbrowservoice_callBody(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
747
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
748
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
749
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
750
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
751
+ var ptr3 = r0;
752
+ var len3 = r1;
753
+ if (r3) {
754
+ ptr3 = 0; len3 = 0;
755
+ throw takeObject(r2);
756
+ }
757
+ deferred4_0 = ptr3;
758
+ deferred4_1 = len3;
759
+ return getStringFromWasm0(ptr3, len3);
760
+ } finally {
761
+ wasm.__wbindgen_add_to_stack_pointer(16);
762
+ wasm.__wbindgen_export5(deferred4_0, deferred4_1, 1);
763
+ }
764
+ }
765
+ /**
766
+ * Decodes Codex's provider response body and Location header in Rust.
767
+ *
768
+ * # Errors
769
+ *
770
+ * Rejects an empty SDP answer or a Location without a Codex call identity.
771
+ * @param {string} response_body
772
+ * @param {string} location
773
+ * @returns {string}
774
+ */
775
+ completeCall(response_body, location) {
776
+ let deferred4_0;
777
+ let deferred4_1;
778
+ try {
779
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
780
+ const ptr0 = passStringToWasm0(response_body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
781
+ const len0 = WASM_VECTOR_LEN;
782
+ const ptr1 = passStringToWasm0(location, wasm.__wbindgen_export, wasm.__wbindgen_export2);
783
+ const len1 = WASM_VECTOR_LEN;
784
+ wasm.managedbrowservoice_completeCall(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
785
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
786
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
787
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
788
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
789
+ var ptr3 = r0;
790
+ var len3 = r1;
791
+ if (r3) {
792
+ ptr3 = 0; len3 = 0;
793
+ throw takeObject(r2);
794
+ }
795
+ deferred4_0 = ptr3;
796
+ deferred4_1 = len3;
797
+ return getStringFromWasm0(ptr3, len3);
798
+ } finally {
799
+ wasm.__wbindgen_add_to_stack_pointer(16);
800
+ wasm.__wbindgen_export5(deferred4_0, deferred4_1, 1);
801
+ }
802
+ }
803
+ /**
804
+ * Sets subscription voice preferences before starting a call.
805
+ *
806
+ * # Errors
807
+ * Rejects invalid settings or changes to an active call.
808
+ * @param {string} settings_json
809
+ */
810
+ configure(settings_json) {
811
+ try {
812
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
813
+ const ptr0 = passStringToWasm0(settings_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
814
+ const len0 = WASM_VECTOR_LEN;
815
+ wasm.managedbrowservoice_configure(retptr, this.__wbg_ptr, ptr0, len0);
816
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
817
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
818
+ if (r1) {
819
+ throw takeObject(r0);
820
+ }
821
+ } finally {
822
+ wasm.__wbindgen_add_to_stack_pointer(16);
823
+ }
824
+ }
825
+ /**
826
+ * Drains one Codex-paced streamed or final managed Agent handoff chunk.
827
+ *
828
+ * # Errors
829
+ *
830
+ * Rejects only when effects cannot be serialized.
831
+ * @param {boolean} final_chunk
832
+ * @returns {string}
833
+ */
834
+ flush(final_chunk) {
835
+ let deferred2_0;
836
+ let deferred2_1;
837
+ try {
838
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
839
+ wasm.managedbrowservoice_flush(retptr, this.__wbg_ptr, final_chunk);
840
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
841
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
842
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
843
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
844
+ var ptr1 = r0;
845
+ var len1 = r1;
846
+ if (r3) {
847
+ ptr1 = 0; len1 = 0;
848
+ throw takeObject(r2);
849
+ }
850
+ deferred2_0 = ptr1;
851
+ deferred2_1 = len1;
852
+ return getStringFromWasm0(ptr1, len1);
853
+ } finally {
854
+ wasm.__wbindgen_add_to_stack_pointer(16);
855
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
856
+ }
857
+ }
858
+ /**
859
+ * Acknowledges frames written by the caller's WebSocket effect executor.
860
+ * @param {number} count
861
+ */
862
+ framesSent(count) {
863
+ wasm.managedbrowservoice_framesSent(this.__wbg_ptr, count);
864
+ }
865
+ /**
866
+ * Applies a scoped managed context envelope using the shared Rust queue.
867
+ *
868
+ * # Errors
869
+ * Rejects malformed JSON or effects that cannot be serialized.
870
+ * @param {string} envelope_json
871
+ * @returns {string}
872
+ */
873
+ managedEvent(envelope_json) {
874
+ let deferred3_0;
875
+ let deferred3_1;
876
+ try {
877
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
878
+ const ptr0 = passStringToWasm0(envelope_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
879
+ const len0 = WASM_VECTOR_LEN;
880
+ wasm.managedbrowservoice_managedEvent(retptr, this.__wbg_ptr, ptr0, len0);
881
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
882
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
883
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
884
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
885
+ var ptr2 = r0;
886
+ var len2 = r1;
887
+ if (r3) {
888
+ ptr2 = 0; len2 = 0;
889
+ throw takeObject(r2);
890
+ }
891
+ deferred3_0 = ptr2;
892
+ deferred3_1 = len2;
893
+ return getStringFromWasm0(ptr2, len2);
894
+ } finally {
895
+ wasm.__wbindgen_add_to_stack_pointer(16);
896
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
897
+ }
898
+ }
899
+ /**
900
+ * Creates an idle managed browser voice protocol core.
901
+ *
902
+ * # Errors
903
+ *
904
+ * Rejects voices outside Codex's ChatGPT V3 catalog.
905
+ * @param {string} voice
906
+ */
907
+ constructor(voice) {
908
+ try {
909
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
910
+ const ptr0 = passStringToWasm0(voice, wasm.__wbindgen_export, wasm.__wbindgen_export2);
911
+ const len0 = WASM_VECTOR_LEN;
912
+ wasm.managedbrowservoice_new(retptr, ptr0, len0);
913
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
914
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
915
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
916
+ if (r2) {
917
+ throw takeObject(r1);
918
+ }
919
+ this.__wbg_ptr = r0;
920
+ ManagedBrowserVoiceFinalization.register(this, this.__wbg_ptr, this);
921
+ return this;
922
+ } finally {
923
+ wasm.__wbindgen_add_to_stack_pointer(16);
924
+ }
925
+ }
926
+ /**
927
+ * Selects Codex's preferred physical input from browser device labels.
928
+ *
929
+ * # Errors
930
+ *
931
+ * Rejects malformed label JSON.
932
+ * @param {string} current_label
933
+ * @param {string} labels_json
934
+ * @returns {number | undefined}
935
+ */
936
+ preferredPhysicalInput(current_label, labels_json) {
937
+ try {
938
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
939
+ const ptr0 = passStringToWasm0(current_label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
940
+ const len0 = WASM_VECTOR_LEN;
941
+ const ptr1 = passStringToWasm0(labels_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
942
+ const len1 = WASM_VECTOR_LEN;
943
+ wasm.managedbrowservoice_preferredPhysicalInput(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
944
+ var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
945
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
946
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
947
+ if (r3) {
948
+ throw takeObject(r2);
949
+ }
950
+ return r0 === Number.MAX_SAFE_INTEGER ? undefined : r0;
951
+ } finally {
952
+ wasm.__wbindgen_add_to_stack_pointer(16);
953
+ }
954
+ }
955
+ /**
956
+ * Applies one sideband event and returns effects plus canonical delegation text.
957
+ *
958
+ * The caller must route returned delegation text through its remote managed Agent.
959
+ *
960
+ * # Errors
961
+ *
962
+ * Rejects only when the update cannot be serialized.
963
+ * @param {string} payload
964
+ * @returns {string}
965
+ */
966
+ realtimeMessage(payload) {
967
+ let deferred3_0;
968
+ let deferred3_1;
969
+ try {
970
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
971
+ const ptr0 = passStringToWasm0(payload, wasm.__wbindgen_export, wasm.__wbindgen_export2);
972
+ const len0 = WASM_VECTOR_LEN;
973
+ wasm.managedbrowservoice_realtimeMessage(retptr, this.__wbg_ptr, ptr0, len0);
974
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
975
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
976
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
977
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
978
+ var ptr2 = r0;
979
+ var len2 = r1;
980
+ if (r3) {
981
+ ptr2 = 0; len2 = 0;
982
+ throw takeObject(r2);
983
+ }
984
+ deferred3_0 = ptr2;
985
+ deferred3_1 = len2;
986
+ return getStringFromWasm0(ptr2, len2);
987
+ } finally {
988
+ wasm.__wbindgen_add_to_stack_pointer(16);
989
+ wasm.__wbindgen_export5(deferred3_0, deferred3_1, 1);
990
+ }
991
+ }
992
+ /**
993
+ * Reports whether one sideband event may produce a managed Agent delegation.
994
+ * @param {string} payload
995
+ * @returns {boolean}
996
+ */
997
+ requiresAgentAdmission(payload) {
998
+ const ptr0 = passStringToWasm0(payload, wasm.__wbindgen_export, wasm.__wbindgen_export2);
999
+ const len0 = WASM_VECTOR_LEN;
1000
+ const ret = wasm.managedbrowservoice_requiresAgentAdmission(this.__wbg_ptr, ptr0, len0);
1001
+ return ret !== 0;
1002
+ }
1003
+ /**
1004
+ * Applies Codex's bounded reconnect policy after sideband transport loss.
1005
+ *
1006
+ * # Errors
1007
+ *
1008
+ * Rejects only when effects cannot be serialized.
1009
+ * @param {number} connected_ms
1010
+ * @returns {string}
1011
+ */
1012
+ sidebandClosed(connected_ms) {
1013
+ let deferred2_0;
1014
+ let deferred2_1;
1015
+ try {
1016
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1017
+ wasm.managedbrowservoice_sidebandClosed(retptr, this.__wbg_ptr, connected_ms);
1018
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1019
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1020
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1021
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1022
+ var ptr1 = r0;
1023
+ var len1 = r1;
1024
+ if (r3) {
1025
+ ptr1 = 0; len1 = 0;
1026
+ throw takeObject(r2);
1027
+ }
1028
+ deferred2_0 = ptr1;
1029
+ deferred2_1 = len1;
1030
+ return getStringFromWasm0(ptr1, len1);
1031
+ } finally {
1032
+ wasm.__wbindgen_add_to_stack_pointer(16);
1033
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1034
+ }
1035
+ }
1036
+ /**
1037
+ * Replays Rust-retained outbound frames after a sideband connects.
1038
+ *
1039
+ * # Errors
1040
+ *
1041
+ * Rejects only when effects cannot be serialized.
1042
+ * @returns {string}
1043
+ */
1044
+ sidebandOpened() {
1045
+ let deferred2_0;
1046
+ let deferred2_1;
1047
+ try {
1048
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1049
+ wasm.managedbrowservoice_sidebandOpened(retptr, this.__wbg_ptr);
1050
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1051
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1052
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1053
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1054
+ var ptr1 = r0;
1055
+ var len1 = r1;
1056
+ if (r3) {
1057
+ ptr1 = 0; len1 = 0;
1058
+ throw takeObject(r2);
1059
+ }
1060
+ deferred2_0 = ptr1;
1061
+ deferred2_1 = len1;
1062
+ return getStringFromWasm0(ptr1, len1);
1063
+ } finally {
1064
+ wasm.__wbindgen_add_to_stack_pointer(16);
1065
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1066
+ }
1067
+ }
1068
+ /**
1069
+ * Builds the managed same-origin sideband URL for a provider call identity.
1070
+ *
1071
+ * # Errors
1072
+ *
1073
+ * Rejects malformed provider call or managed session identities.
1074
+ * @param {string} call_id
1075
+ * @param {string} managed_session_id
1076
+ * @returns {string}
1077
+ */
1078
+ sidebandUrl(call_id, managed_session_id) {
1079
+ let deferred4_0;
1080
+ let deferred4_1;
1081
+ try {
1082
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1083
+ const ptr0 = passStringToWasm0(call_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1084
+ const len0 = WASM_VECTOR_LEN;
1085
+ const ptr1 = passStringToWasm0(managed_session_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1086
+ const len1 = WASM_VECTOR_LEN;
1087
+ wasm.managedbrowservoice_sidebandUrl(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
1088
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1089
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1090
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1091
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1092
+ var ptr3 = r0;
1093
+ var len3 = r1;
1094
+ if (r3) {
1095
+ ptr3 = 0; len3 = 0;
1096
+ throw takeObject(r2);
1097
+ }
1098
+ deferred4_0 = ptr3;
1099
+ deferred4_1 = len3;
1100
+ return getStringFromWasm0(ptr3, len3);
1101
+ } finally {
1102
+ wasm.__wbindgen_add_to_stack_pointer(16);
1103
+ wasm.__wbindgen_export5(deferred4_0, deferred4_1, 1);
1104
+ }
1105
+ }
1106
+ /**
1107
+ * Starts the protocol from the managed Agent's authoritative serialized context.
1108
+ *
1109
+ * # Errors
1110
+ *
1111
+ * Rejects malformed `AgentSessionContext` JSON.
1112
+ * @param {string} context_json
1113
+ */
1114
+ start(context_json) {
1115
+ try {
1116
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1117
+ const ptr0 = passStringToWasm0(context_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1118
+ const len0 = WASM_VECTOR_LEN;
1119
+ wasm.managedbrowservoice_start(retptr, this.__wbg_ptr, ptr0, len0);
1120
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1121
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1122
+ if (r1) {
1123
+ throw takeObject(r0);
1124
+ }
1125
+ } finally {
1126
+ wasm.__wbindgen_add_to_stack_pointer(16);
1127
+ }
1128
+ }
1129
+ /**
1130
+ * Stops the protocol and returns final transcript delegation plus close effects.
1131
+ *
1132
+ * # Errors
1133
+ *
1134
+ * Rejects only when the update cannot be serialized.
1135
+ * @returns {string}
1136
+ */
1137
+ stop() {
1138
+ let deferred2_0;
1139
+ let deferred2_1;
1140
+ try {
1141
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1142
+ wasm.managedbrowservoice_stop(retptr, this.__wbg_ptr);
1143
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1144
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1145
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1146
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1147
+ var ptr1 = r0;
1148
+ var len1 = r1;
1149
+ if (r3) {
1150
+ ptr1 = 0; len1 = 0;
1151
+ throw takeObject(r2);
1152
+ }
1153
+ deferred2_0 = ptr1;
1154
+ deferred2_1 = len1;
1155
+ return getStringFromWasm0(ptr1, len1);
1156
+ } finally {
1157
+ wasm.__wbindgen_add_to_stack_pointer(16);
1158
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1159
+ }
1160
+ }
1161
+ }
1162
+ if (Symbol.dispose) ManagedBrowserVoice.prototype[Symbol.dispose] = ManagedBrowserVoice.prototype.free;
1163
+
1164
+ /**
1165
+ * JavaScript binding over the shared Rust agent lifecycle.
1166
+ */
1167
+ export class Nanocodex {
1168
+ static __wrap(ptr) {
1169
+ const obj = Object.create(Nanocodex.prototype);
1170
+ obj.__wbg_ptr = ptr;
1171
+ NanocodexFinalization.register(obj, obj.__wbg_ptr, obj);
1172
+ return obj;
1173
+ }
1174
+ __destroy_into_raw() {
1175
+ const ptr = this.__wbg_ptr;
1176
+ this.__wbg_ptr = 0;
1177
+ NanocodexFinalization.unregister(this);
1178
+ return ptr;
1179
+ }
1180
+ free() {
1181
+ const ptr = this.__destroy_into_raw();
1182
+ wasm.__wbg_nanocodex_free(ptr, 0);
1183
+ }
1184
+ /**
1185
+ * Returns the stable Agent identity.
1186
+ * @returns {string}
1187
+ */
1188
+ get agentId() {
1189
+ let deferred1_0;
1190
+ let deferred1_1;
1191
+ try {
1192
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1193
+ wasm.nanocodex_agentId(retptr, this.__wbg_ptr);
1194
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1195
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1196
+ deferred1_0 = r0;
1197
+ deferred1_1 = r1;
1198
+ return getStringFromWasm0(r0, r1);
1199
+ } finally {
1200
+ wasm.__wbindgen_add_to_stack_pointer(16);
1201
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
1202
+ }
1203
+ }
1204
+ /**
1205
+ * Appends adapter-owned developer context at the next safe model boundary.
1206
+ *
1207
+ * Returns the complete read-only session context captured at that boundary.
1208
+ *
1209
+ * # Errors
1210
+ *
1211
+ * Rejects empty text or a stopped driver.
1212
+ * @param {string} text
1213
+ * @returns {Promise<string>}
1214
+ */
1215
+ appendDeveloperMessage(text) {
1216
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1217
+ const len0 = WASM_VECTOR_LEN;
1218
+ const ret = wasm.nanocodex_appendDeveloperMessage(this.__wbg_ptr, ptr0, len0);
1219
+ return takeObject(ret);
1220
+ }
1221
+ /**
1222
+ * Creates the Rust-owned Codex browser voice controller for this agent.
1223
+ *
1224
+ * # Errors
1225
+ *
1226
+ * Rejects voices outside Codex's ChatGPT V3 catalog.
1227
+ * @param {string} voice
1228
+ * @returns {BrowserVoice}
1229
+ */
1230
+ browserVoice(voice) {
1231
+ try {
1232
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1233
+ const ptr0 = passStringToWasm0(voice, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1234
+ const len0 = WASM_VECTOR_LEN;
1235
+ wasm.nanocodex_browserVoice(retptr, this.__wbg_ptr, ptr0, len0);
1236
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1237
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1238
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1239
+ if (r2) {
1240
+ throw takeObject(r1);
1241
+ }
1242
+ return BrowserVoice.__wrap(r0);
1243
+ } finally {
1244
+ wasm.__wbindgen_add_to_stack_pointer(16);
1245
+ }
1246
+ }
1247
+ /**
1248
+ * Closes one canonical task-tree child and its descendants.
1249
+ * @param {string} task
1250
+ * @returns {Promise<string>}
1251
+ */
1252
+ closeSubagent(task) {
1253
+ const ptr0 = passStringToWasm0(task, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1254
+ const len0 = WASM_VECTOR_LEN;
1255
+ const ret = wasm.nanocodex_closeSubagent(this.__wbg_ptr, ptr0, len0);
1256
+ return takeObject(ret);
1257
+ }
1258
+ /**
1259
+ * Compacts retained history immediately without fabricating a user prompt.
1260
+ *
1261
+ * # Errors
1262
+ *
1263
+ * Throws when compaction or the agent driver fails.
1264
+ * @returns {Promise<void>}
1265
+ */
1266
+ compact() {
1267
+ const ret = wasm.nanocodex_compact(this.__wbg_ptr);
1268
+ return takeObject(ret);
1269
+ }
1270
+ /**
1271
+ * Compacts retained history and returns the private replacement mapping.
1272
+ *
1273
+ * The serialized result includes the generated summary, the replaced
1274
+ * pre-compaction range, retained tail identities, and the complete
1275
+ * post-compaction session context for custom host compaction. It is
1276
+ * `null` when provider-default compaction is active.
1277
+ * @returns {Promise<string>}
1278
+ */
1279
+ compactOutcome() {
1280
+ const ret = wasm.nanocodex_compactOutcome(this.__wbg_ptr);
1281
+ return takeObject(ret);
1282
+ }
1283
+ /**
1284
+ * Returns complete read-only session context at the latest safe boundary.
1285
+ *
1286
+ * # Errors
1287
+ *
1288
+ * Rejects after the driver stops or when context serialization fails.
1289
+ * @returns {Promise<string>}
1290
+ */
1291
+ context() {
1292
+ const ret = wasm.nanocodex_context(this.__wbg_ptr);
1293
+ return takeObject(ret);
1294
+ }
1295
+ /**
1296
+ * Builds an agent from its JavaScript JSON configuration.
1297
+ *
1298
+ * # Errors
1299
+ *
1300
+ * Throws when the JSON or agent policy is invalid.
1301
+ * @param {string} config_json
1302
+ * @returns {Promise<Nanocodex>}
1303
+ */
1304
+ static create(config_json) {
1305
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1306
+ const len0 = WASM_VECTOR_LEN;
1307
+ const ret = wasm.nanocodex_create(ptr0, len0);
1308
+ return takeObject(ret);
1309
+ }
1310
+ /**
1311
+ * Builds an agent whose ChatGPT credential lifecycle is owned by Rust.
1312
+ * @param {string} config_json
1313
+ * @param {ChatGptSubscription} subscription
1314
+ * @returns {Promise<Nanocodex>}
1315
+ */
1316
+ static createWithChatGpt(config_json, subscription) {
1317
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1318
+ const len0 = WASM_VECTOR_LEN;
1319
+ _assertClass(subscription, ChatGptSubscription);
1320
+ const ret = wasm.nanocodex_createWithChatGpt(ptr0, len0, subscription.__wbg_ptr);
1321
+ return takeObject(ret);
1322
+ }
1323
+ /**
1324
+ * Ends the canonical Codex Realtime adapter lifecycle.
1325
+ *
1326
+ * # Errors
1327
+ *
1328
+ * Rejects when the agent driver has stopped or context serialization fails.
1329
+ * @returns {Promise<string>}
1330
+ */
1331
+ endRealtimeConversation() {
1332
+ const ret = wasm.nanocodex_endRealtimeConversation(this.__wbg_ptr);
1333
+ return takeObject(ret);
1334
+ }
1335
+ /**
1336
+ * Forks the latest safe committed model boundary.
1337
+ *
1338
+ * # Errors
1339
+ *
1340
+ * Rejects before the first safe boundary or after the driver stops.
1341
+ * @returns {Promise<Nanocodex>}
1342
+ */
1343
+ fork() {
1344
+ const ret = wasm.nanocodex_fork(this.__wbg_ptr);
1345
+ return takeObject(ret);
1346
+ }
1347
+ /**
1348
+ * Forks from an exact completed historical turn.
1349
+ *
1350
+ * # Errors
1351
+ *
1352
+ * Rejects if the result belongs to another agent or the driver stopped.
1353
+ * @param {TurnResult} result
1354
+ * @returns {Promise<Nanocodex>}
1355
+ */
1356
+ forkFrom(result) {
1357
+ _assertClass(result, TurnResult);
1358
+ const ret = wasm.nanocodex_forkFrom(this.__wbg_ptr, result.__wbg_ptr);
1359
+ return takeObject(ret);
1360
+ }
1361
+ /**
1362
+ * Interrupts one canonical task-tree child while keeping it reusable.
1363
+ * @param {string} task
1364
+ * @returns {Promise<string>}
1365
+ */
1366
+ interruptSubagent(task) {
1367
+ const ptr0 = passStringToWasm0(task, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1368
+ const len0 = WASM_VECTOR_LEN;
1369
+ const ret = wasm.nanocodex_interruptSubagent(this.__wbg_ptr, ptr0, len0);
1370
+ return takeObject(ret);
1371
+ }
1372
+ /**
1373
+ * Lists the canonical task-tree directory visible to the owning root.
1374
+ * @param {string} task
1375
+ * @returns {Promise<string>}
1376
+ */
1377
+ listSubagents(task) {
1378
+ const ptr0 = passStringToWasm0(task, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1379
+ const len0 = WASM_VECTOR_LEN;
1380
+ const ret = wasm.nanocodex_listSubagents(this.__wbg_ptr, ptr0, len0);
1381
+ return takeObject(ret);
1382
+ }
1383
+ /**
1384
+ * Accepts a text prompt and returns its independently awaitable turn.
1385
+ *
1386
+ * # Errors
1387
+ *
1388
+ * Throws when the prompt is empty.
1389
+ * @param {string} instruction
1390
+ * @param {string | null} [operation_id]
1391
+ * @param {boolean | null} [cancel_on_admission]
1392
+ * @param {string | null} [supplementary_context]
1393
+ * @returns {Turn}
1394
+ */
1395
+ prompt(instruction, operation_id, cancel_on_admission, supplementary_context) {
1396
+ try {
1397
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1398
+ const ptr0 = passStringToWasm0(instruction, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1399
+ const len0 = WASM_VECTOR_LEN;
1400
+ var ptr1 = isLikeNone(operation_id) ? 0 : passStringToWasm0(operation_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1401
+ var len1 = WASM_VECTOR_LEN;
1402
+ var ptr2 = isLikeNone(supplementary_context) ? 0 : passStringToWasm0(supplementary_context, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1403
+ var len2 = WASM_VECTOR_LEN;
1404
+ wasm.nanocodex_prompt(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(cancel_on_admission) ? 0xFFFFFF : cancel_on_admission ? 1 : 0, ptr2, len2);
1405
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1406
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1407
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1408
+ if (r2) {
1409
+ throw takeObject(r1);
1410
+ }
1411
+ return Turn.__wrap(r0);
1412
+ } finally {
1413
+ wasm.__wbindgen_add_to_stack_pointer(16);
1414
+ }
1415
+ }
1416
+ /**
1417
+ * Accepts browser-safe multimodal input encoded as JSON.
1418
+ *
1419
+ * # Errors
1420
+ *
1421
+ * Throws for malformed, empty, or local-filesystem input.
1422
+ * @param {string} content_json
1423
+ * @param {string | null} [operation_id]
1424
+ * @param {boolean | null} [cancel_on_admission]
1425
+ * @param {string | null} [supplementary_context]
1426
+ * @returns {Turn}
1427
+ */
1428
+ promptContent(content_json, operation_id, cancel_on_admission, supplementary_context) {
1429
+ try {
1430
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1431
+ const ptr0 = passStringToWasm0(content_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1432
+ const len0 = WASM_VECTOR_LEN;
1433
+ var ptr1 = isLikeNone(operation_id) ? 0 : passStringToWasm0(operation_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1434
+ var len1 = WASM_VECTOR_LEN;
1435
+ var ptr2 = isLikeNone(supplementary_context) ? 0 : passStringToWasm0(supplementary_context, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1436
+ var len2 = WASM_VECTOR_LEN;
1437
+ wasm.nanocodex_promptContent(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(cancel_on_admission) ? 0xFFFFFF : cancel_on_admission ? 1 : 0, ptr2, len2);
1438
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1439
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1440
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1441
+ if (r2) {
1442
+ throw takeObject(r1);
1443
+ }
1444
+ return Turn.__wrap(r0);
1445
+ } finally {
1446
+ wasm.__wbindgen_add_to_stack_pointer(16);
1447
+ }
1448
+ }
1449
+ /**
1450
+ * Formats one structured Realtime delegation using canonical Codex markers.
1451
+ *
1452
+ * # Errors
1453
+ *
1454
+ * Rejects malformed transcript JSON.
1455
+ * @param {string} input
1456
+ * @param {string} transcript
1457
+ * @returns {string}
1458
+ */
1459
+ realtimeDelegation(input, transcript) {
1460
+ let deferred4_0;
1461
+ let deferred4_1;
1462
+ try {
1463
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1464
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1465
+ const len0 = WASM_VECTOR_LEN;
1466
+ const ptr1 = passStringToWasm0(transcript, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1467
+ const len1 = WASM_VECTOR_LEN;
1468
+ wasm.nanocodex_realtimeDelegation(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
1469
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1470
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1471
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1472
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1473
+ var ptr3 = r0;
1474
+ var len3 = r1;
1475
+ if (r3) {
1476
+ ptr3 = 0; len3 = 0;
1477
+ throw takeObject(r2);
1478
+ }
1479
+ deferred4_0 = ptr3;
1480
+ deferred4_1 = len3;
1481
+ return getStringFromWasm0(ptr3, len3);
1482
+ } finally {
1483
+ wasm.__wbindgen_add_to_stack_pointer(16);
1484
+ wasm.__wbindgen_export5(deferred4_0, deferred4_1, 1);
1485
+ }
1486
+ }
1487
+ /**
1488
+ * Formats an unconsumed Realtime transcript tail using canonical Codex markers.
1489
+ *
1490
+ * # Errors
1491
+ *
1492
+ * Rejects malformed transcript JSON.
1493
+ * @param {string} transcript
1494
+ * @returns {string | undefined}
1495
+ */
1496
+ realtimeTailDelegation(transcript) {
1497
+ try {
1498
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1499
+ const ptr0 = passStringToWasm0(transcript, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1500
+ const len0 = WASM_VECTOR_LEN;
1501
+ wasm.nanocodex_realtimeTailDelegation(retptr, this.__wbg_ptr, ptr0, len0);
1502
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1503
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1504
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1505
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1506
+ if (r3) {
1507
+ throw takeObject(r2);
1508
+ }
1509
+ let v2;
1510
+ if (r0 !== 0) {
1511
+ v2 = getStringFromWasm0(r0, r1).slice();
1512
+ wasm.__wbindgen_export5(r0, r1 * 1, 1);
1513
+ }
1514
+ return v2;
1515
+ } finally {
1516
+ wasm.__wbindgen_add_to_stack_pointer(16);
1517
+ }
1518
+ }
1519
+ /**
1520
+ * Restores persisted logical children after the JavaScript owner acquires
1521
+ * its durability generation and activates the replacement host.
1522
+ *
1523
+ * # Errors
1524
+ *
1525
+ * Rejects malformed descriptors, disabled subagents, duplicate restoration,
1526
+ * or an invalid persisted topology.
1527
+ * @param {string} descriptors_json
1528
+ * @param {string | null} [host_contexts_json]
1529
+ * @returns {Promise<void>}
1530
+ */
1531
+ restoreSubagents(descriptors_json, host_contexts_json) {
1532
+ const ptr0 = passStringToWasm0(descriptors_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1533
+ const len0 = WASM_VECTOR_LEN;
1534
+ var ptr1 = isLikeNone(host_contexts_json) ? 0 : passStringToWasm0(host_contexts_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1535
+ var len1 = WASM_VECTOR_LEN;
1536
+ const ret = wasm.nanocodex_restoreSubagents(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1537
+ return takeObject(ret);
1538
+ }
1539
+ /**
1540
+ * Atomically steers the active turn or starts a new independently awaitable turn.
1541
+ *
1542
+ * Returns `undefined` when the input was steered into an active turn.
1543
+ *
1544
+ * # Errors
1545
+ *
1546
+ * Rejects empty input, a full steering queue, or a stopped driver.
1547
+ * @param {string} instruction
1548
+ * @returns {Promise<Turn | undefined>}
1549
+ */
1550
+ routePrompt(instruction) {
1551
+ const ptr0 = passStringToWasm0(instruction, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1552
+ const len0 = WASM_VECTOR_LEN;
1553
+ const ret = wasm.nanocodex_routePrompt(this.__wbg_ptr, ptr0, len0);
1554
+ return takeObject(ret);
1555
+ }
1556
+ /**
1557
+ * Sends one canonical directed task-tree message from the owning root.
1558
+ * @param {string} task
1559
+ * @returns {Promise<string>}
1560
+ */
1561
+ sendSubagentMessage(task) {
1562
+ const ptr0 = passStringToWasm0(task, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1563
+ const len0 = WASM_VECTOR_LEN;
1564
+ const ret = wasm.nanocodex_sendSubagentMessage(this.__wbg_ptr, ptr0, len0);
1565
+ return takeObject(ret);
1566
+ }
1567
+ /**
1568
+ * Returns the stable UUID session identity (`UUIDv7` by default).
1569
+ * @returns {string}
1570
+ */
1571
+ get sessionId() {
1572
+ let deferred1_0;
1573
+ let deferred1_1;
1574
+ try {
1575
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1576
+ wasm.nanocodex_sessionId(retptr, this.__wbg_ptr);
1577
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1578
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1579
+ deferred1_0 = r0;
1580
+ deferred1_1 = r1;
1581
+ return getStringFromWasm0(r0, r1);
1582
+ } finally {
1583
+ wasm.__wbindgen_add_to_stack_pointer(16);
1584
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
1585
+ }
1586
+ }
1587
+ /**
1588
+ * Enables or disables the optional JavaScript event crossing for this handle.
1589
+ * @param {boolean} enabled
1590
+ */
1591
+ setEventForwarding(enabled) {
1592
+ wasm.nanocodex_setEventForwarding(this.__wbg_ptr, enabled);
1593
+ }
1594
+ /**
1595
+ * Enables or disables priority processing for subsequently accepted turns.
1596
+ *
1597
+ * # Errors
1598
+ *
1599
+ * Rejects after the driver stops.
1600
+ * @param {boolean} enabled
1601
+ * @returns {Promise<void>}
1602
+ */
1603
+ setFastMode(enabled) {
1604
+ const ret = wasm.nanocodex_setFastMode(this.__wbg_ptr, enabled);
1605
+ return takeObject(ret);
1606
+ }
1607
+ /**
1608
+ * Changes the model before the first turn is accepted.
1609
+ *
1610
+ * # Errors
1611
+ *
1612
+ * Rejects an invalid model, an incompatible thinking level, conversation
1613
+ * activity, or a stopped driver.
1614
+ * @param {string} model
1615
+ * @returns {Promise<void>}
1616
+ */
1617
+ setModel(model) {
1618
+ const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1619
+ const len0 = WASM_VECTOR_LEN;
1620
+ const ret = wasm.nanocodex_setModel(this.__wbg_ptr, ptr0, len0);
1621
+ return takeObject(ret);
1622
+ }
1623
+ /**
1624
+ * Changes the reasoning effort for subsequently accepted turns.
1625
+ *
1626
+ * # Errors
1627
+ *
1628
+ * Rejects an invalid effort or a stopped driver.
1629
+ * @param {string} thinking
1630
+ * @returns {Promise<void>}
1631
+ */
1632
+ setThinking(thinking) {
1633
+ const ptr0 = passStringToWasm0(thinking, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1634
+ const len0 = WASM_VECTOR_LEN;
1635
+ const ret = wasm.nanocodex_setThinking(this.__wbg_ptr, ptr0, len0);
1636
+ return takeObject(ret);
1637
+ }
1638
+ /**
1639
+ * Gracefully stops the driver and joins every resource owned by this agent.
1640
+ *
1641
+ * # Errors
1642
+ *
1643
+ * Rejects when the driver had already stopped or cleanup fails.
1644
+ * @returns {Promise<void>}
1645
+ */
1646
+ shutdown() {
1647
+ const ret = wasm.nanocodex_shutdown(this.__wbg_ptr);
1648
+ return takeObject(ret);
1649
+ }
1650
+ /**
1651
+ * Serializes the latest committed, resumable session snapshot.
1652
+ *
1653
+ * This is the engine-owned checkpoint at the latest completed safe
1654
+ * boundary. After manual compaction, it therefore captures the exact
1655
+ * post-install history that can be supplied to a fresh Agent instance.
1656
+ *
1657
+ * # Errors
1658
+ *
1659
+ * Rejects before the first committed boundary, after the driver stops,
1660
+ * or when serialization fails.
1661
+ * @returns {Promise<string>}
1662
+ */
1663
+ snapshot() {
1664
+ const ret = wasm.nanocodex_snapshot(this.__wbg_ptr);
1665
+ return takeObject(ret);
1666
+ }
1667
+ /**
1668
+ * Starts a clean sibling with the same private agent policy.
1669
+ *
1670
+ * # Errors
1671
+ *
1672
+ * Rejects after the driver stops.
1673
+ * @returns {Promise<Nanocodex>}
1674
+ */
1675
+ spawn() {
1676
+ const ret = wasm.nanocodex_spawn(this.__wbg_ptr);
1677
+ return takeObject(ret);
1678
+ }
1679
+ /**
1680
+ * Starts one canonical Rust task-tree child and returns its descriptor.
1681
+ * @param {string} task
1682
+ * @returns {Promise<string>}
1683
+ */
1684
+ spawnSubagent(task) {
1685
+ const ptr0 = passStringToWasm0(task, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1686
+ const len0 = WASM_VECTOR_LEN;
1687
+ const ret = wasm.nanocodex_spawnSubagent(this.__wbg_ptr, ptr0, len0);
1688
+ return takeObject(ret);
1689
+ }
1690
+ /**
1691
+ * Starts an ordered batch of canonical subagents in the same task tree.
1692
+ *
1693
+ * # Errors
1694
+ *
1695
+ * Rejects malformed tasks, agents without subagent tools, a stopped
1696
+ * parent, or a batch that cannot be reserved in full.
1697
+ * @param {string} tasks_json
1698
+ * @returns {Promise<string>}
1699
+ */
1700
+ spawnSubagents(tasks_json) {
1701
+ const ptr0 = passStringToWasm0(tasks_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1702
+ const len0 = WASM_VECTOR_LEN;
1703
+ const ret = wasm.nanocodex_spawnSubagents(this.__wbg_ptr, ptr0, len0);
1704
+ return takeObject(ret);
1705
+ }
1706
+ /**
1707
+ * Starts the canonical Codex Realtime adapter lifecycle.
1708
+ *
1709
+ * # Errors
1710
+ *
1711
+ * Rejects when the agent driver has stopped or context serialization fails.
1712
+ * @returns {Promise<string>}
1713
+ */
1714
+ startRealtimeConversation() {
1715
+ const ret = wasm.nanocodex_startRealtimeConversation(this.__wbg_ptr);
1716
+ return takeObject(ret);
1717
+ }
1718
+ /**
1719
+ * Waits for any selected canonical task-tree child to become terminal.
1720
+ * @param {string} task
1721
+ * @returns {Promise<string>}
1722
+ */
1723
+ waitSubagents(task) {
1724
+ const ptr0 = passStringToWasm0(task, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1725
+ const len0 = WASM_VECTOR_LEN;
1726
+ const ret = wasm.nanocodex_waitSubagents(this.__wbg_ptr, ptr0, len0);
1727
+ return takeObject(ret);
1728
+ }
1729
+ }
1730
+ if (Symbol.dispose) Nanocodex.prototype[Symbol.dispose] = Nanocodex.prototype.free;
1731
+
1732
+ /**
1733
+ * JavaScript binding over one shared Rust turn.
1734
+ */
1735
+ export class Turn {
1736
+ static __wrap(ptr) {
1737
+ const obj = Object.create(Turn.prototype);
1738
+ obj.__wbg_ptr = ptr;
1739
+ TurnFinalization.register(obj, obj.__wbg_ptr, obj);
1740
+ return obj;
1741
+ }
1742
+ __destroy_into_raw() {
1743
+ const ptr = this.__wbg_ptr;
1744
+ this.__wbg_ptr = 0;
1745
+ TurnFinalization.unregister(this);
1746
+ return ptr;
1747
+ }
1748
+ free() {
1749
+ const ptr = this.__destroy_into_raw();
1750
+ wasm.__wbg_turn_free(ptr, 0);
1751
+ }
1752
+ /**
1753
+ * Waits until the Rust driver has durably admitted this turn.
1754
+ *
1755
+ * Returns the durable request identity selected during admission, or
1756
+ * `undefined` when the agent has no execution policy.
1757
+ *
1758
+ * # Errors
1759
+ *
1760
+ * Rejects with a stable `code` describing an admission failure.
1761
+ * @returns {Promise<string | undefined>}
1762
+ */
1763
+ accepted() {
1764
+ const ret = wasm.turn_accepted(this.__wbg_ptr);
1765
+ return takeObject(ret);
1766
+ }
1767
+ /**
1768
+ * Cancels this exact active or queued turn.
1769
+ *
1770
+ * # Errors
1771
+ *
1772
+ * Rejects if the turn is already terminal or its driver stopped.
1773
+ * @returns {Promise<void>}
1774
+ */
1775
+ cancel() {
1776
+ const ret = wasm.turn_cancel(this.__wbg_ptr);
1777
+ return takeObject(ret);
1778
+ }
1779
+ /**
1780
+ * Waits for the final assistant message.
1781
+ *
1782
+ * # Errors
1783
+ *
1784
+ * Rejects with a stable `code` when the model run or driver fails.
1785
+ * @returns {Promise<TurnResult>}
1786
+ */
1787
+ result() {
1788
+ const ret = wasm.turn_result(this.__wbg_ptr);
1789
+ return takeObject(ret);
1790
+ }
1791
+ /**
1792
+ * Injects text input at the active turn's next safe model boundary.
1793
+ *
1794
+ * # Errors
1795
+ *
1796
+ * Rejects if the turn is not active or its driver stopped.
1797
+ * @param {string} instruction
1798
+ * @returns {Promise<void>}
1799
+ */
1800
+ steer(instruction) {
1801
+ const ptr0 = passStringToWasm0(instruction, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1802
+ const len0 = WASM_VECTOR_LEN;
1803
+ const ret = wasm.turn_steer(this.__wbg_ptr, ptr0, len0);
1804
+ return takeObject(ret);
1805
+ }
1806
+ /**
1807
+ * Injects browser-safe multimodal input at the active turn's next boundary.
1808
+ *
1809
+ * # Errors
1810
+ *
1811
+ * Rejects malformed input or a turn that is no longer active.
1812
+ * @param {string} content_json
1813
+ * @returns {Promise<void>}
1814
+ */
1815
+ steerContent(content_json) {
1816
+ const ptr0 = passStringToWasm0(content_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1817
+ const len0 = WASM_VECTOR_LEN;
1818
+ const ret = wasm.turn_steerContent(this.__wbg_ptr, ptr0, len0);
1819
+ return takeObject(ret);
1820
+ }
1821
+ }
1822
+ if (Symbol.dispose) Turn.prototype[Symbol.dispose] = Turn.prototype.free;
1823
+
1824
+ /**
1825
+ * JavaScript binding over one completed Rust turn result.
1826
+ */
1827
+ export class TurnResult {
1828
+ static __wrap(ptr) {
1829
+ const obj = Object.create(TurnResult.prototype);
1830
+ obj.__wbg_ptr = ptr;
1831
+ TurnResultFinalization.register(obj, obj.__wbg_ptr, obj);
1832
+ return obj;
1833
+ }
1834
+ __destroy_into_raw() {
1835
+ const ptr = this.__wbg_ptr;
1836
+ this.__wbg_ptr = 0;
1837
+ TurnResultFinalization.unregister(this);
1838
+ return ptr;
1839
+ }
1840
+ free() {
1841
+ const ptr = this.__destroy_into_raw();
1842
+ wasm.__wbg_turnresult_free(ptr, 0);
1843
+ }
1844
+ /**
1845
+ * Returns the final assistant message.
1846
+ * @returns {string}
1847
+ */
1848
+ get finalMessage() {
1849
+ let deferred1_0;
1850
+ let deferred1_1;
1851
+ try {
1852
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1853
+ wasm.turnresult_finalMessage(retptr, this.__wbg_ptr);
1854
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1855
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1856
+ deferred1_0 = r0;
1857
+ deferred1_1 = r1;
1858
+ return getStringFromWasm0(r0, r1);
1859
+ } finally {
1860
+ wasm.__wbindgen_add_to_stack_pointer(16);
1861
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
1862
+ }
1863
+ }
1864
+ /**
1865
+ * Serializes this completed boundary's resumable session snapshot.
1866
+ *
1867
+ * # Errors
1868
+ *
1869
+ * Throws when serialization fails.
1870
+ * @returns {string}
1871
+ */
1872
+ snapshot() {
1873
+ let deferred2_0;
1874
+ let deferred2_1;
1875
+ try {
1876
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1877
+ wasm.turnresult_snapshot(retptr, this.__wbg_ptr);
1878
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1879
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1880
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1881
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1882
+ var ptr1 = r0;
1883
+ var len1 = r1;
1884
+ if (r3) {
1885
+ ptr1 = 0; len1 = 0;
1886
+ throw takeObject(r2);
1887
+ }
1888
+ deferred2_0 = ptr1;
1889
+ deferred2_1 = len1;
1890
+ return getStringFromWasm0(ptr1, len1);
1891
+ } finally {
1892
+ wasm.__wbindgen_add_to_stack_pointer(16);
1893
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1894
+ }
1895
+ }
1896
+ /**
1897
+ * Serializes exact aggregate usage for this completed logical turn.
1898
+ *
1899
+ * # Errors
1900
+ *
1901
+ * Throws when serialization fails.
1902
+ * @returns {string}
1903
+ */
1904
+ usage() {
1905
+ let deferred2_0;
1906
+ let deferred2_1;
1907
+ try {
1908
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1909
+ wasm.turnresult_usage(retptr, this.__wbg_ptr);
1910
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1911
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1912
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1913
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1914
+ var ptr1 = r0;
1915
+ var len1 = r1;
1916
+ if (r3) {
1917
+ ptr1 = 0; len1 = 0;
1918
+ throw takeObject(r2);
1919
+ }
1920
+ deferred2_0 = ptr1;
1921
+ deferred2_1 = len1;
1922
+ return getStringFromWasm0(ptr1, len1);
1923
+ } finally {
1924
+ wasm.__wbindgen_add_to_stack_pointer(16);
1925
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1926
+ }
1927
+ }
1928
+ }
1929
+ if (Symbol.dispose) TurnResult.prototype[Symbol.dispose] = TurnResult.prototype.free;
1930
+
1931
+ /**
1932
+ * Applies a browser-workspace patch through the canonical Rust planner.
1933
+ *
1934
+ * The browser host uses this internal binding for nested Code Mode calls so
1935
+ * they share the direct `apply_patch` tool's verification and mutation path.
1936
+ * @param {string} patch
1937
+ * @param {string} session_id
1938
+ * @returns {Promise<string>}
1939
+ */
1940
+ export function applyBrowserPatch(patch, session_id) {
1941
+ const ptr0 = passStringToWasm0(patch, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1942
+ const len0 = WASM_VECTOR_LEN;
1943
+ const ptr1 = passStringToWasm0(session_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1944
+ const len1 = WASM_VECTOR_LEN;
1945
+ const ret = wasm.applyBrowserPatch(ptr0, len0, ptr1, len1);
1946
+ return takeObject(ret);
1947
+ }
1948
+
1949
+ /**
1950
+ * Returns the shared bounded first-prompt retrieval plan for a managed host.
1951
+ * @param {string} input
1952
+ * @returns {string}
1953
+ */
1954
+ export function managedBootstrapPlan(input) {
1955
+ let deferred2_0;
1956
+ let deferred2_1;
1957
+ try {
1958
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1959
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1960
+ const len0 = WASM_VECTOR_LEN;
1961
+ wasm.managedBootstrapPlan(retptr, ptr0, len0);
1962
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1963
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1964
+ deferred2_0 = r0;
1965
+ deferred2_1 = r1;
1966
+ return getStringFromWasm0(r0, r1);
1967
+ } finally {
1968
+ wasm.__wbindgen_add_to_stack_pointer(16);
1969
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
1970
+ }
1971
+ }
1972
+
1973
+ /**
1974
+ * Prunes old replay receipts before the full Agent runtime is constructed.
1975
+ * @param {string} durability_host_id
1976
+ * @param {string} durability_id
1977
+ * @param {number} terminal_receipt_limit
1978
+ * @returns {Promise<void>}
1979
+ */
1980
+ export function pruneDurableReceipts(durability_host_id, durability_id, terminal_receipt_limit) {
1981
+ const ptr0 = passStringToWasm0(durability_host_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1982
+ const len0 = WASM_VECTOR_LEN;
1983
+ const ptr1 = passStringToWasm0(durability_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1984
+ const len1 = WASM_VECTOR_LEN;
1985
+ const ret = wasm.pruneDurableReceipts(ptr0, len0, ptr1, len1, terminal_receipt_limit);
1986
+ return takeObject(ret);
1987
+ }
1988
+ function __wbg_get_imports() {
1989
+ const import0 = {
1990
+ __proto__: null,
1991
+ __wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
1992
+ const ret = debugString(getObject(arg1));
1993
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1994
+ const len1 = WASM_VECTOR_LEN;
1995
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1996
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1997
+ },
1998
+ __wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
1999
+ const ret = typeof(getObject(arg0)) === 'function';
2000
+ return ret;
2001
+ },
2002
+ __wbg___wbindgen_is_null_ea9085d691f535d3: function(arg0) {
2003
+ const ret = getObject(arg0) === null;
2004
+ return ret;
2005
+ },
2006
+ __wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
2007
+ const ret = getObject(arg0) === undefined;
2008
+ return ret;
2009
+ },
2010
+ __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
2011
+ const obj = getObject(arg1);
2012
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2013
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2014
+ var len1 = WASM_VECTOR_LEN;
2015
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2016
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2017
+ },
2018
+ __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
2019
+ throw new Error(getStringFromWasm0(arg0, arg1));
2020
+ },
2021
+ __wbg__wbg_cb_unref_fffb441def202758: function(arg0) {
2022
+ getObject(arg0)._wbg_cb_unref();
2023
+ },
2024
+ __wbg_beginCodeTurn_158b945b9b6521f8: function(arg0, arg1) {
2025
+ globalThis.nanocodexHost.beginCodeTurn(getStringFromWasm0(arg0, arg1));
2026
+ },
2027
+ __wbg_bindSubagentSession_bccfa5ce66ce78d0: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
2028
+ globalThis.nanocodexHost.bindSubagentSession(arg0 >>> 0, getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6), arg7 === 0 ? undefined : getStringFromWasm0(arg7, arg8));
2029
+ }, arguments); },
2030
+ __wbg_call_8a2dd23819f8a60a: function() { return handleError(function (arg0, arg1) {
2031
+ const ret = getObject(arg0).call(getObject(arg1));
2032
+ return addHeapObject(ret);
2033
+ }, arguments); },
2034
+ __wbg_call_a6e5c5dce5018821: function() { return handleError(function (arg0, arg1, arg2) {
2035
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
2036
+ return addHeapObject(ret);
2037
+ }, arguments); },
2038
+ __wbg_cancelCodeTurn_e757feca39e85741: function(arg0, arg1) {
2039
+ globalThis.nanocodexHost.cancelCodeTurn(getStringFromWasm0(arg0, arg1));
2040
+ },
2041
+ __wbg_cancelCode_0ce10d479d714d56: function(arg0, arg1) {
2042
+ globalThis.nanocodexHost.cancelCode(getStringFromWasm0(arg0, arg1));
2043
+ },
2044
+ __wbg_chatgptsubscription_new: function(arg0) {
2045
+ const ret = ChatGptSubscription.__wrap(arg0);
2046
+ return addHeapObject(ret);
2047
+ },
2048
+ __wbg_close_5e82a7961abc5249: function(arg0) {
2049
+ globalThis.nanocodexHost.close(arg0 >>> 0);
2050
+ },
2051
+ __wbg_connect_489ca7b722fdf012: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) {
2052
+ const ret = globalThis.nanocodexHost.connect(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm0(arg4, arg5), arg6 !== 0, getStringFromWasm0(arg7, arg8), getStringFromWasm0(arg9, arg10), arg11 === 0 ? undefined : getStringFromWasm0(arg11, arg12));
2053
+ return addHeapObject(ret);
2054
+ }, arguments); },
2055
+ __wbg_durabilityAcquire_c752363b56fbbdc4: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
2056
+ const ret = globalThis.nanocodexHost.durabilityAcquire(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5));
2057
+ return addHeapObject(ret);
2058
+ }, arguments); },
2059
+ __wbg_durabilityReplace_4f822a9aff3aa6a7: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) {
2060
+ const ret = globalThis.nanocodexHost.durabilityReplace(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7), getStringFromWasm0(arg8, arg9), getStringFromWasm0(arg10, arg11));
2061
+ return addHeapObject(ret);
2062
+ }, arguments); },
2063
+ __wbg_emitEvent_5c42b0387c7184d8: function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
2064
+ globalThis.nanocodexHost.emitEvent(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), arg4 >>> 0, arg5 === 0 ? undefined : getStringFromWasm0(arg5, arg6));
2065
+ },
2066
+ __wbg_error_e1480ca065e427a8: function() { return handleError(function (arg0, arg1, arg2) {
2067
+ console.error(getStringFromWasm0(arg0, arg1), getObject(arg2));
2068
+ }, arguments); },
2069
+ __wbg_executeCode_0e99eef610fa0cc0: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
2070
+ const ret = globalThis.nanocodexHost.executeCode(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7));
2071
+ return addHeapObject(ret);
2072
+ }, arguments); },
2073
+ __wbg_executeTool_3c85f934f1b9b2f8: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
2074
+ const ret = globalThis.nanocodexHost.executeTool(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7), getStringFromWasm0(arg8, arg9));
2075
+ return addHeapObject(ret);
2076
+ }, arguments); },
2077
+ __wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
2078
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2079
+ }, arguments); },
2080
+ __wbg_getRandomValues_ceb34d8ffce7e87f: function() { return handleError(function (arg0, arg1) {
2081
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2082
+ }, arguments); },
2083
+ __wbg_getTime_d6f070c088c9b5ed: function(arg0) {
2084
+ const ret = getObject(arg0).getTime();
2085
+ return ret;
2086
+ },
2087
+ __wbg_getTimezoneOffset_dc9862c79e5a81a3: function(arg0) {
2088
+ const ret = getObject(arg0).getTimezoneOffset();
2089
+ return ret;
2090
+ },
2091
+ __wbg_get_78f252d074a84d0b: function() { return handleError(function (arg0, arg1) {
2092
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2093
+ return addHeapObject(ret);
2094
+ }, arguments); },
2095
+ __wbg_httpHeaders_b21edc0710486f32: function() { return handleError(function (arg0) {
2096
+ const ret = globalThis.nanocodexHost.httpHeaders(arg0 >>> 0);
2097
+ return addHeapObject(ret);
2098
+ }, arguments); },
2099
+ __wbg_httpOpen_d2a04d19dbfe4122: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14) {
2100
+ const ret = globalThis.nanocodexHost.httpOpen(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm0(arg4, arg5), arg6 !== 0, getStringFromWasm0(arg7, arg8), getStringFromWasm0(arg9, arg10), arg11 === 0 ? undefined : getStringFromWasm0(arg11, arg12), getStringFromWasm0(arg13, arg14));
2101
+ return addHeapObject(ret);
2102
+ }, arguments); },
2103
+ __wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
2104
+ let result;
2105
+ try {
2106
+ result = getObject(arg0) instanceof Uint8Array;
2107
+ } catch (_) {
2108
+ result = false;
2109
+ }
2110
+ const ret = result;
2111
+ return ret;
2112
+ },
2113
+ __wbg_length_1f0964f4a5e2c6d8: function(arg0) {
2114
+ const ret = getObject(arg0).length;
2115
+ return ret;
2116
+ },
2117
+ __wbg_listWorkspace_df62ed70aa5f720a: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2118
+ const ret = globalThis.nanocodexHost.listWorkspace(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
2119
+ return addHeapObject(ret);
2120
+ }, arguments); },
2121
+ __wbg_nanocodex_new: function(arg0) {
2122
+ const ret = Nanocodex.__wrap(arg0);
2123
+ return addHeapObject(ret);
2124
+ },
2125
+ __wbg_new_0_3da9e97f24fc69be: function() {
2126
+ const ret = new Date();
2127
+ return addHeapObject(ret);
2128
+ },
2129
+ __wbg_new_32b398fb48b6d94a: function() {
2130
+ const ret = new Array();
2131
+ return addHeapObject(ret);
2132
+ },
2133
+ __wbg_new_b667d279fd5aa943: function(arg0, arg1) {
2134
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
2135
+ return addHeapObject(ret);
2136
+ },
2137
+ __wbg_new_cbb95886ce0eb0cb: function(arg0, arg1) {
2138
+ const ret = new Intl.DateTimeFormat(getObject(arg0), getObject(arg1));
2139
+ return addHeapObject(ret);
2140
+ },
2141
+ __wbg_new_cc984128914cfc6f: function(arg0) {
2142
+ const ret = new Date(getObject(arg0));
2143
+ return addHeapObject(ret);
2144
+ },
2145
+ __wbg_new_cd45aabdf6073e84: function(arg0) {
2146
+ const ret = new Uint8Array(getObject(arg0));
2147
+ return addHeapObject(ret);
2148
+ },
2149
+ __wbg_new_da52cf8fe3429cb2: function() {
2150
+ const ret = new Object();
2151
+ return addHeapObject(ret);
2152
+ },
2153
+ __wbg_new_from_slice_77cdfb7977362f3c: function(arg0, arg1) {
2154
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2155
+ return addHeapObject(ret);
2156
+ },
2157
+ __wbg_new_typed_1824d93f294193e5: function(arg0, arg1) {
2158
+ try {
2159
+ var state0 = {a: arg0, b: arg1};
2160
+ var cb0 = (arg0, arg1) => {
2161
+ const a = state0.a;
2162
+ state0.a = 0;
2163
+ try {
2164
+ return __wasm_bindgen_func_elem_20356(a, state0.b, arg0, arg1);
2165
+ } finally {
2166
+ state0.a = a;
2167
+ }
2168
+ };
2169
+ const ret = new Promise(cb0);
2170
+ return addHeapObject(ret);
2171
+ } finally {
2172
+ state0.a = 0;
2173
+ }
2174
+ },
2175
+ __wbg_nextCodeUpdate_02d0c91d29c978c6: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2176
+ const ret = globalThis.nanocodexHost.nextCodeUpdate(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
2177
+ return addHeapObject(ret);
2178
+ }, arguments); },
2179
+ __wbg_next_f69b14f858799a1a: function() { return handleError(function (arg0, arg1) {
2180
+ const ret = globalThis.nanocodexHost.next(arg0 >>> 0, arg1 >>> 0);
2181
+ return addHeapObject(ret);
2182
+ }, arguments); },
2183
+ __wbg_now_86c0d4ba3fa605b8: function() {
2184
+ const ret = Date.now();
2185
+ return ret;
2186
+ },
2187
+ __wbg_now_e7c6795a7f81e10f: function(arg0) {
2188
+ const ret = getObject(arg0).now();
2189
+ return ret;
2190
+ },
2191
+ __wbg_now_f663ab0a5177b799: function() { return handleError(function () {
2192
+ const ret = Date.now();
2193
+ return ret;
2194
+ }, arguments); },
2195
+ __wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
2196
+ const ret = getObject(arg0).performance;
2197
+ return addHeapObject(ret);
2198
+ },
2199
+ __wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
2200
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2201
+ },
2202
+ __wbg_queueMicrotask_0ab5b2d2393e99b9: function(arg0) {
2203
+ const ret = getObject(arg0).queueMicrotask;
2204
+ return addHeapObject(ret);
2205
+ },
2206
+ __wbg_queueMicrotask_6a09b7bc46549209: function(arg0) {
2207
+ queueMicrotask(getObject(arg0));
2208
+ },
2209
+ __wbg_readWorkspaceFile_8437f35da62d26ff: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2210
+ const ret = globalThis.nanocodexHost.readWorkspaceFile(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
2211
+ return addHeapObject(ret);
2212
+ }, arguments); },
2213
+ __wbg_releaseSubagentSession_c76ea9fb1053d0b1: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
2214
+ globalThis.nanocodexHost.releaseSubagentSession(arg0 >>> 0, getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2215
+ }, arguments); },
2216
+ __wbg_removeWorkspaceFile_77085e3121efe986: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2217
+ const ret = globalThis.nanocodexHost.removeWorkspaceFile(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
2218
+ return addHeapObject(ret);
2219
+ }, arguments); },
2220
+ __wbg_resolveCompactionInstruction_99c3f8ebb4f3a5df: function() { return handleError(function (arg0, arg1, arg2) {
2221
+ const ret = globalThis.nanocodexHost.resolveCompactionInstruction(arg0 >>> 0, getStringFromWasm0(arg1, arg2));
2222
+ return addHeapObject(ret);
2223
+ }, arguments); },
2224
+ __wbg_resolve_2191a4dfe481c25b: function(arg0) {
2225
+ const ret = Promise.resolve(getObject(arg0));
2226
+ return addHeapObject(ret);
2227
+ },
2228
+ __wbg_resolvedOptions_ce0ede387898d6bd: function(arg0) {
2229
+ const ret = getObject(arg0).resolvedOptions();
2230
+ return addHeapObject(ret);
2231
+ },
2232
+ __wbg_send_3123992aab0aeeb5: function() { return handleError(function (arg0, arg1, arg2) {
2233
+ const ret = globalThis.nanocodexHost.send(arg0 >>> 0, getStringFromWasm0(arg1, arg2));
2234
+ return addHeapObject(ret);
2235
+ }, arguments); },
2236
+ __wbg_setTimeout_5222d178168b8fb2: function(arg0, arg1) {
2237
+ const ret = globalThis.setTimeout(getObject(arg0), arg1);
2238
+ return addHeapObject(ret);
2239
+ },
2240
+ __wbg_set_8535240470bf2500: function() { return handleError(function (arg0, arg1, arg2) {
2241
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
2242
+ return ret;
2243
+ }, arguments); },
2244
+ __wbg_sleep_c693614773b9e78b: function() { return handleError(function (arg0, arg1, arg2) {
2245
+ const ret = globalThis.nanocodexHost.sleep(getStringFromWasm0(arg0, arg1), arg2 >>> 0);
2246
+ return addHeapObject(ret);
2247
+ }, arguments); },
2248
+ __wbg_static_accessor_GLOBAL_4ef717fb391d88b7: function() {
2249
+ const ret = typeof global === 'undefined' ? null : global;
2250
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2251
+ },
2252
+ __wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4: function() {
2253
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2254
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2255
+ },
2256
+ __wbg_static_accessor_SELF_146583524fe1469b: function() {
2257
+ const ret = typeof self === 'undefined' ? null : self;
2258
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2259
+ },
2260
+ __wbg_static_accessor_WINDOW_f2829a2234d7819e: function() {
2261
+ const ret = typeof window === 'undefined' ? null : window;
2262
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2263
+ },
2264
+ __wbg_subscriptionCompareAndSwap_f8eb3ab5dca5d4fc: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
2265
+ const ret = globalThis.nanocodexHost.subscriptionCompareAndSwap(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5));
2266
+ return addHeapObject(ret);
2267
+ }, arguments); },
2268
+ __wbg_subscriptionLoad_3a579915c346f53e: function() { return handleError(function (arg0, arg1) {
2269
+ const ret = globalThis.nanocodexHost.subscriptionLoad(getStringFromWasm0(arg0, arg1));
2270
+ return addHeapObject(ret);
2271
+ }, arguments); },
2272
+ __wbg_subscriptionRequest_e39715201bc8f237: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2273
+ const ret = globalThis.nanocodexHost.subscriptionRequest(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
2274
+ return addHeapObject(ret);
2275
+ }, arguments); },
2276
+ __wbg_then_16d107c451e9905d: function(arg0, arg1, arg2) {
2277
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
2278
+ return addHeapObject(ret);
2279
+ },
2280
+ __wbg_then_6ec10ae38b3e92f7: function(arg0, arg1) {
2281
+ const ret = getObject(arg0).then(getObject(arg1));
2282
+ return addHeapObject(ret);
2283
+ },
2284
+ __wbg_toolDefinitions_c9f2730e8a16336f: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2285
+ const ret = globalThis.nanocodexHost.toolDefinitions(arg1 >>> 0, getStringFromWasm0(arg2, arg3));
2286
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2287
+ const len1 = WASM_VECTOR_LEN;
2288
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2289
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2290
+ }, arguments); },
2291
+ __wbg_toolMode_1e3c6cd0bd36ba38: function(arg0, arg1, arg2, arg3) {
2292
+ const ret = globalThis.nanocodexHost.toolMode(arg1 >>> 0, getStringFromWasm0(arg2, arg3));
2293
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2294
+ const len1 = WASM_VECTOR_LEN;
2295
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2296
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2297
+ },
2298
+ __wbg_turn_new: function(arg0) {
2299
+ const ret = Turn.__wrap(arg0);
2300
+ return addHeapObject(ret);
2301
+ },
2302
+ __wbg_turnresult_new: function(arg0) {
2303
+ const ret = TurnResult.__wrap(arg0);
2304
+ return addHeapObject(ret);
2305
+ },
2306
+ __wbg_waitCode_4b20445691368c5b: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
2307
+ const ret = globalThis.nanocodexHost.waitCode(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5));
2308
+ return addHeapObject(ret);
2309
+ }, arguments); },
2310
+ __wbg_writeWorkspaceFile_16f2dd21547a9f85: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
2311
+ const ret = globalThis.nanocodexHost.writeWorkspaceFile(getStringFromWasm0(arg0, arg1), getObject(arg2), getStringFromWasm0(arg3, arg4));
2312
+ return addHeapObject(ret);
2313
+ }, arguments); },
2314
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2315
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2840, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2316
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_20354);
2317
+ return addHeapObject(ret);
2318
+ },
2319
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2320
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 519, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2321
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_4730);
2322
+ return addHeapObject(ret);
2323
+ },
2324
+ __wbindgen_cast_0000000000000003: function(arg0) {
2325
+ // Cast intrinsic for `F64 -> Externref`.
2326
+ const ret = arg0;
2327
+ return addHeapObject(ret);
2328
+ },
2329
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
2330
+ // Cast intrinsic for `Ref(String) -> Externref`.
2331
+ const ret = getStringFromWasm0(arg0, arg1);
2332
+ return addHeapObject(ret);
2333
+ },
2334
+ __wbindgen_object_clone_ref: function(arg0) {
2335
+ const ret = getObject(arg0);
2336
+ return addHeapObject(ret);
2337
+ },
2338
+ __wbindgen_object_drop_ref: function(arg0) {
2339
+ takeObject(arg0);
2340
+ },
2341
+ };
2342
+ return {
2343
+ __proto__: null,
2344
+ "./nanocodex_bg.js": import0,
2345
+ };
2346
+ }
2347
+
2348
+ function __wasm_bindgen_func_elem_4730(arg0, arg1) {
2349
+ wasm.__wasm_bindgen_func_elem_4730(arg0, arg1);
2350
+ }
2351
+
2352
+ function __wasm_bindgen_func_elem_20354(arg0, arg1, arg2) {
2353
+ try {
2354
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2355
+ wasm.__wasm_bindgen_func_elem_20354(retptr, arg0, arg1, addHeapObject(arg2));
2356
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2357
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2358
+ if (r1) {
2359
+ throw takeObject(r0);
2360
+ }
2361
+ } finally {
2362
+ wasm.__wbindgen_add_to_stack_pointer(16);
2363
+ }
2364
+ }
2365
+
2366
+ function __wasm_bindgen_func_elem_20356(arg0, arg1, arg2, arg3) {
2367
+ wasm.__wasm_bindgen_func_elem_20356(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2368
+ }
2369
+
2370
+ const BrowserVoiceFinalization = (typeof FinalizationRegistry === 'undefined')
2371
+ ? { register: () => {}, unregister: () => {} }
2372
+ : new FinalizationRegistry(ptr => wasm.__wbg_browservoice_free(ptr, 1));
2373
+ const ChatGptSubscriptionFinalization = (typeof FinalizationRegistry === 'undefined')
2374
+ ? { register: () => {}, unregister: () => {} }
2375
+ : new FinalizationRegistry(ptr => wasm.__wbg_chatgptsubscription_free(ptr, 1));
2376
+ const ManagedBrowserVoiceFinalization = (typeof FinalizationRegistry === 'undefined')
2377
+ ? { register: () => {}, unregister: () => {} }
2378
+ : new FinalizationRegistry(ptr => wasm.__wbg_managedbrowservoice_free(ptr, 1));
2379
+ const NanocodexFinalization = (typeof FinalizationRegistry === 'undefined')
2380
+ ? { register: () => {}, unregister: () => {} }
2381
+ : new FinalizationRegistry(ptr => wasm.__wbg_nanocodex_free(ptr, 1));
2382
+ const TurnFinalization = (typeof FinalizationRegistry === 'undefined')
2383
+ ? { register: () => {}, unregister: () => {} }
2384
+ : new FinalizationRegistry(ptr => wasm.__wbg_turn_free(ptr, 1));
2385
+ const TurnResultFinalization = (typeof FinalizationRegistry === 'undefined')
2386
+ ? { register: () => {}, unregister: () => {} }
2387
+ : new FinalizationRegistry(ptr => wasm.__wbg_turnresult_free(ptr, 1));
2388
+
2389
+ function addHeapObject(obj) {
2390
+ if (heap_next === heap.length) heap.push(heap.length + 1);
2391
+ const idx = heap_next;
2392
+ heap_next = heap[idx];
2393
+
2394
+ heap[idx] = obj;
2395
+ return idx;
2396
+ }
2397
+
2398
+ function _assertClass(instance, klass) {
2399
+ if (!(instance instanceof klass)) {
2400
+ throw new Error(`expected instance of ${klass.name}`);
2401
+ }
2402
+ }
2403
+
2404
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
2405
+ ? { register: () => {}, unregister: () => {} }
2406
+ : new FinalizationRegistry(state => wasm.__wbindgen_export4(state.a, state.b));
2407
+
2408
+ function debugString(val) {
2409
+ // primitive types
2410
+ const type = typeof val;
2411
+ if (type == 'number' || type == 'boolean' || val == null) {
2412
+ return `${val}`;
2413
+ }
2414
+ if (type == 'string') {
2415
+ return `"${val}"`;
2416
+ }
2417
+ if (type == 'symbol') {
2418
+ const description = val.description;
2419
+ if (description == null) {
2420
+ return 'Symbol';
2421
+ } else {
2422
+ return `Symbol(${description})`;
2423
+ }
2424
+ }
2425
+ if (type == 'function') {
2426
+ const name = val.name;
2427
+ if (typeof name == 'string' && name.length > 0) {
2428
+ return `Function(${name})`;
2429
+ } else {
2430
+ return 'Function';
2431
+ }
2432
+ }
2433
+ // objects
2434
+ if (Array.isArray(val)) {
2435
+ const length = val.length;
2436
+ let debug = '[';
2437
+ if (length > 0) {
2438
+ debug += debugString(val[0]);
2439
+ }
2440
+ for(let i = 1; i < length; i++) {
2441
+ debug += ', ' + debugString(val[i]);
2442
+ }
2443
+ debug += ']';
2444
+ return debug;
2445
+ }
2446
+ // Test for built-in
2447
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2448
+ let className;
2449
+ if (builtInMatches && builtInMatches.length > 1) {
2450
+ className = builtInMatches[1];
2451
+ } else {
2452
+ // Failed to match the standard '[object ClassName]'
2453
+ return toString.call(val);
2454
+ }
2455
+ if (className == 'Object') {
2456
+ // we're a user defined class or Object
2457
+ // JSON.stringify avoids problems with cycles, and is generally much
2458
+ // easier than looping through ownProperties of `val`.
2459
+ try {
2460
+ return 'Object(' + JSON.stringify(val) + ')';
2461
+ } catch (_) {
2462
+ return 'Object';
2463
+ }
2464
+ }
2465
+ // errors
2466
+ if (val instanceof Error) {
2467
+ return `${val.name}: ${val.message}\n${val.stack}`;
2468
+ }
2469
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2470
+ return className;
2471
+ }
2472
+
2473
+ function dropObject(idx) {
2474
+ if (idx < 1028) return;
2475
+ heap[idx] = heap_next;
2476
+ heap_next = idx;
2477
+ }
2478
+
2479
+ function getArrayU8FromWasm0(ptr, len) {
2480
+ ptr = ptr >>> 0;
2481
+ return new Uint8Array(wasm.memory.buffer, ptr, len);
2482
+ }
2483
+
2484
+ let cachedDataViewMemory0 = null;
2485
+ function getDataViewMemory0() {
2486
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2487
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2488
+ }
2489
+ return cachedDataViewMemory0;
2490
+ }
2491
+
2492
+ function getStringFromWasm0(ptr, len) {
2493
+ return decodeText(ptr >>> 0, len);
2494
+ }
2495
+
2496
+ let cachedUint8ArrayMemory0 = null;
2497
+ function getUint8ArrayMemory0() {
2498
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2499
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2500
+ }
2501
+ return cachedUint8ArrayMemory0;
2502
+ }
2503
+
2504
+ function getObject(idx) { return heap[idx]; }
2505
+
2506
+ function handleError(f, args) {
2507
+ try {
2508
+ return f.apply(this, args);
2509
+ } catch (e) {
2510
+ wasm.__wbindgen_export3(addHeapObject(e));
2511
+ }
2512
+ }
2513
+
2514
+ let heap = new Array(1024).fill(undefined);
2515
+ heap.push(undefined, null, true, false);
2516
+
2517
+ let heap_next = heap.length;
2518
+
2519
+ function isLikeNone(x) {
2520
+ return x === undefined || x === null;
2521
+ }
2522
+
2523
+ function makeMutClosure(arg0, arg1, f) {
2524
+ const state = { a: arg0, b: arg1, cnt: 1 };
2525
+ const real = (...args) => {
2526
+
2527
+ // First up with a closure we increment the internal reference
2528
+ // count. This ensures that the Rust closure environment won't
2529
+ // be deallocated while we're invoking it.
2530
+ state.cnt++;
2531
+ const a = state.a;
2532
+ state.a = 0;
2533
+ try {
2534
+ return f(a, state.b, ...args);
2535
+ } finally {
2536
+ state.a = a;
2537
+ real._wbg_cb_unref();
2538
+ }
2539
+ };
2540
+ real._wbg_cb_unref = () => {
2541
+ if (--state.cnt === 0) {
2542
+ wasm.__wbindgen_export4(state.a, state.b);
2543
+ state.a = 0;
2544
+ CLOSURE_DTORS.unregister(state);
2545
+ }
2546
+ };
2547
+ CLOSURE_DTORS.register(real, state, state);
2548
+ return real;
2549
+ }
2550
+
2551
+ function passStringToWasm0(arg, malloc, realloc) {
2552
+ if (realloc === undefined) {
2553
+ const buf = cachedTextEncoder.encode(arg);
2554
+ const ptr = malloc(buf.length, 1) >>> 0;
2555
+ new Uint8Array(wasm.memory.buffer, ptr, buf.length).set(buf);
2556
+ WASM_VECTOR_LEN = buf.length;
2557
+ return ptr;
2558
+ }
2559
+
2560
+ let len = arg.length;
2561
+ let ptr = malloc(len, 1) >>> 0;
2562
+
2563
+ const mem = getUint8ArrayMemory0();
2564
+
2565
+ let offset = 0;
2566
+
2567
+ for (; offset < len; offset++) {
2568
+ const code = arg.charCodeAt(offset);
2569
+ if (code > 0x7F) break;
2570
+ mem[ptr + offset] = code;
2571
+ }
2572
+ if (offset !== len) {
2573
+ if (offset !== 0) {
2574
+ arg = arg.slice(offset);
2575
+ }
2576
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2577
+ const view = new Uint8Array(wasm.memory.buffer, ptr + offset, len - offset);
2578
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2579
+
2580
+ offset += ret.written;
2581
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2582
+ }
2583
+
2584
+ WASM_VECTOR_LEN = offset;
2585
+ return ptr;
2586
+ }
2587
+
2588
+ function takeObject(idx) {
2589
+ const ret = getObject(idx);
2590
+ dropObject(idx);
2591
+ return ret;
2592
+ }
2593
+
2594
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2595
+ cachedTextDecoder.decode();
2596
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2597
+ let numBytesDecoded = 0;
2598
+ function decodeText(ptr, len) {
2599
+ numBytesDecoded += len;
2600
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2601
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2602
+ cachedTextDecoder.decode();
2603
+ numBytesDecoded = len;
2604
+ }
2605
+ return cachedTextDecoder.decode(new Uint8Array(wasm.memory.buffer, ptr, len));
2606
+ }
2607
+
2608
+ const cachedTextEncoder = new TextEncoder();
2609
+
2610
+ if (!('encodeInto' in cachedTextEncoder)) {
2611
+ cachedTextEncoder.encodeInto = function (arg, view) {
2612
+ const buf = cachedTextEncoder.encode(arg);
2613
+ view.set(buf);
2614
+ return {
2615
+ read: arg.length,
2616
+ written: buf.length
2617
+ };
2618
+ };
2619
+ }
2620
+
2621
+ let WASM_VECTOR_LEN = 0;
2622
+
2623
+ let wasmModule, wasmInstance, wasm;
2624
+ function __wbg_finalize_init(instance, module) {
2625
+ wasmInstance = instance;
2626
+ wasm = instance.exports;
2627
+ wasmModule = module;
2628
+ cachedDataViewMemory0 = null;
2629
+ cachedUint8ArrayMemory0 = null;
2630
+ return wasm;
2631
+ }
2632
+
2633
+ async function __wbg_load(module, imports) {
2634
+ if (typeof Response === 'function' && module instanceof Response) {
2635
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2636
+ try {
2637
+ return await WebAssembly.instantiateStreaming(module, imports);
2638
+ } catch (e) {
2639
+ const validResponse = module.ok && expectedResponseType(module.type);
2640
+
2641
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2642
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
2643
+
2644
+ } else { throw e; }
2645
+ }
2646
+ }
2647
+
2648
+ const bytes = await module.arrayBuffer();
2649
+ return await WebAssembly.instantiate(bytes, imports);
2650
+ } else {
2651
+ const instance = await WebAssembly.instantiate(module, imports);
2652
+
2653
+ if (instance instanceof WebAssembly.Instance) {
2654
+ return { instance, module };
2655
+ } else {
2656
+ return instance;
2657
+ }
2658
+ }
2659
+
2660
+ function expectedResponseType(type) {
2661
+ switch (type) {
2662
+ case 'basic': case 'cors': case 'default': return true;
2663
+ }
2664
+ return false;
2665
+ }
2666
+ }
2667
+
2668
+ function initSync(module) {
2669
+ if (wasm !== undefined) return wasm;
2670
+
2671
+
2672
+ if (module !== undefined) {
2673
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2674
+ ({module} = module)
2675
+ } else {
2676
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
2677
+ }
2678
+ }
2679
+
2680
+ const imports = __wbg_get_imports();
2681
+ if (!(module instanceof WebAssembly.Module)) {
2682
+ module = new WebAssembly.Module(module);
2683
+ }
2684
+ const instance = new WebAssembly.Instance(module, imports);
2685
+ return __wbg_finalize_init(instance, module);
2686
+ }
2687
+
2688
+ async function __wbg_init(module_or_path) {
2689
+ if (wasm !== undefined) return wasm;
2690
+
2691
+
2692
+ if (module_or_path !== undefined) {
2693
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2694
+ ({module_or_path} = module_or_path)
2695
+ } else {
2696
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
2697
+ }
2698
+ }
2699
+
2700
+ if (module_or_path === undefined) {
2701
+ module_or_path = new URL('nanocodex_bg.wasm', import.meta.url);
2702
+ }
2703
+ const imports = __wbg_get_imports();
2704
+
2705
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
2706
+ module_or_path = fetch(module_or_path);
2707
+ }
2708
+
2709
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
2710
+
2711
+ return __wbg_finalize_init(instance, module);
2712
+ }
2713
+
2714
+ export { initSync, __wbg_init as default };