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