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