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