opencode-gateway 0.1.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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/dist/binding/execution.d.ts +24 -0
  4. package/dist/binding/execution.js +1 -0
  5. package/dist/binding/gateway.d.ts +71 -0
  6. package/dist/binding/gateway.js +1 -0
  7. package/dist/binding/index.d.ts +15 -0
  8. package/dist/binding/index.js +4 -0
  9. package/dist/binding/opencode.d.ts +123 -0
  10. package/dist/binding/opencode.js +1 -0
  11. package/dist/cli/args.d.ts +9 -0
  12. package/dist/cli/args.js +53 -0
  13. package/dist/cli/doctor.d.ts +6 -0
  14. package/dist/cli/doctor.js +59 -0
  15. package/dist/cli/init.d.ts +6 -0
  16. package/dist/cli/init.js +35 -0
  17. package/dist/cli/opencode-config.d.ts +10 -0
  18. package/dist/cli/opencode-config.js +62 -0
  19. package/dist/cli/paths.d.ts +7 -0
  20. package/dist/cli/paths.js +22 -0
  21. package/dist/cli/templates.d.ts +1 -0
  22. package/dist/cli/templates.js +26 -0
  23. package/dist/cli.d.ts +2 -0
  24. package/dist/cli.js +314 -0
  25. package/dist/config/cron.d.ts +7 -0
  26. package/dist/config/cron.js +52 -0
  27. package/dist/config/gateway.d.ts +26 -0
  28. package/dist/config/gateway.js +142 -0
  29. package/dist/config/paths.d.ts +10 -0
  30. package/dist/config/paths.js +33 -0
  31. package/dist/config/telegram.d.ts +13 -0
  32. package/dist/config/telegram.js +91 -0
  33. package/dist/cron/runtime.d.ts +40 -0
  34. package/dist/cron/runtime.js +237 -0
  35. package/dist/delivery/telegram.d.ts +16 -0
  36. package/dist/delivery/telegram.js +75 -0
  37. package/dist/delivery/text.d.ts +21 -0
  38. package/dist/delivery/text.js +175 -0
  39. package/dist/gateway.d.ts +33 -0
  40. package/dist/gateway.js +105 -0
  41. package/dist/host/file-sender.d.ts +16 -0
  42. package/dist/host/file-sender.js +59 -0
  43. package/dist/host/noop.d.ts +4 -0
  44. package/dist/host/noop.js +14 -0
  45. package/dist/host/transport.d.ts +9 -0
  46. package/dist/host/transport.js +35 -0
  47. package/dist/index.d.ts +7 -0
  48. package/dist/index.js +52 -0
  49. package/dist/mailbox/router.d.ts +7 -0
  50. package/dist/mailbox/router.js +16 -0
  51. package/dist/media/mime.d.ts +2 -0
  52. package/dist/media/mime.js +45 -0
  53. package/dist/opencode/adapter.d.ts +19 -0
  54. package/dist/opencode/adapter.js +291 -0
  55. package/dist/opencode/driver-hub.d.ts +15 -0
  56. package/dist/opencode/driver-hub.js +82 -0
  57. package/dist/opencode/event-normalize.d.ts +48 -0
  58. package/dist/opencode/event-normalize.js +48 -0
  59. package/dist/opencode/event-stream.d.ts +23 -0
  60. package/dist/opencode/event-stream.js +65 -0
  61. package/dist/opencode/events.d.ts +2 -0
  62. package/dist/opencode/events.js +1 -0
  63. package/dist/questions/client.d.ts +5 -0
  64. package/dist/questions/client.js +36 -0
  65. package/dist/questions/format.d.ts +3 -0
  66. package/dist/questions/format.js +36 -0
  67. package/dist/questions/normalize.d.ts +10 -0
  68. package/dist/questions/normalize.js +45 -0
  69. package/dist/questions/parser.d.ts +11 -0
  70. package/dist/questions/parser.js +96 -0
  71. package/dist/questions/runtime.d.ts +53 -0
  72. package/dist/questions/runtime.js +195 -0
  73. package/dist/questions/types.d.ts +22 -0
  74. package/dist/questions/types.js +1 -0
  75. package/dist/runtime/attachments.d.ts +3 -0
  76. package/dist/runtime/attachments.js +12 -0
  77. package/dist/runtime/executor.d.ts +24 -0
  78. package/dist/runtime/executor.js +188 -0
  79. package/dist/runtime/mailbox.d.ts +25 -0
  80. package/dist/runtime/mailbox.js +112 -0
  81. package/dist/runtime/opencode-runner.d.ts +26 -0
  82. package/dist/runtime/opencode-runner.js +79 -0
  83. package/dist/session/context.d.ts +10 -0
  84. package/dist/session/context.js +44 -0
  85. package/dist/session/conversation-key.d.ts +3 -0
  86. package/dist/session/conversation-key.js +3 -0
  87. package/dist/session/switcher.d.ts +25 -0
  88. package/dist/session/switcher.js +59 -0
  89. package/dist/store/migrations.d.ts +2 -0
  90. package/dist/store/migrations.js +183 -0
  91. package/dist/store/sqlite.d.ts +127 -0
  92. package/dist/store/sqlite.js +678 -0
  93. package/dist/telegram/client.d.ts +35 -0
  94. package/dist/telegram/client.js +179 -0
  95. package/dist/telegram/media.d.ts +13 -0
  96. package/dist/telegram/media.js +65 -0
  97. package/dist/telegram/normalize.d.ts +47 -0
  98. package/dist/telegram/normalize.js +119 -0
  99. package/dist/telegram/poller.d.ts +29 -0
  100. package/dist/telegram/poller.js +97 -0
  101. package/dist/telegram/runtime.d.ts +51 -0
  102. package/dist/telegram/runtime.js +133 -0
  103. package/dist/telegram/state.d.ts +36 -0
  104. package/dist/telegram/state.js +128 -0
  105. package/dist/telegram/types.d.ts +80 -0
  106. package/dist/telegram/types.js +1 -0
  107. package/dist/tools/channel-new-session.d.ts +4 -0
  108. package/dist/tools/channel-new-session.js +27 -0
  109. package/dist/tools/channel-send-file.d.ts +9 -0
  110. package/dist/tools/channel-send-file.js +27 -0
  111. package/dist/tools/channel-target.d.ts +7 -0
  112. package/dist/tools/channel-target.js +28 -0
  113. package/dist/tools/cron-list.d.ts +3 -0
  114. package/dist/tools/cron-list.js +34 -0
  115. package/dist/tools/cron-remove.d.ts +3 -0
  116. package/dist/tools/cron-remove.js +12 -0
  117. package/dist/tools/cron-run.d.ts +3 -0
  118. package/dist/tools/cron-run.js +20 -0
  119. package/dist/tools/cron-upsert.d.ts +3 -0
  120. package/dist/tools/cron-upsert.js +37 -0
  121. package/dist/tools/gateway-dispatch-cron.d.ts +3 -0
  122. package/dist/tools/gateway-dispatch-cron.js +33 -0
  123. package/dist/tools/gateway-status.d.ts +3 -0
  124. package/dist/tools/gateway-status.js +25 -0
  125. package/dist/tools/telegram-send-test.d.ts +3 -0
  126. package/dist/tools/telegram-send-test.js +26 -0
  127. package/dist/tools/telegram-status.d.ts +3 -0
  128. package/dist/tools/telegram-status.js +49 -0
  129. package/dist/tools/time.d.ts +3 -0
  130. package/dist/tools/time.js +25 -0
  131. package/dist/utils/error.d.ts +1 -0
  132. package/dist/utils/error.js +57 -0
  133. package/generated/wasm/pkg/opencode_gateway_ffi.d.ts +23 -0
  134. package/generated/wasm/pkg/opencode_gateway_ffi.js +574 -0
  135. package/generated/wasm/pkg/opencode_gateway_ffi_bg.wasm +0 -0
  136. package/generated/wasm/pkg/opencode_gateway_ffi_bg.wasm.d.ts +22 -0
  137. package/package.json +61 -0
@@ -0,0 +1,574 @@
1
+ /* @ts-self-types="./opencode_gateway_ffi.d.ts" */
2
+
3
+ class OpencodeExecutionDriver {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ OpencodeExecutionDriverFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_opencodeexecutiondriver_free(ptr, 0);
13
+ }
14
+ /**
15
+ * @param {any} input
16
+ */
17
+ constructor(input) {
18
+ const ret = wasm.opencodeexecutiondriver_new(input);
19
+ if (ret[2]) {
20
+ throw takeFromExternrefTable0(ret[1]);
21
+ }
22
+ this.__wbg_ptr = ret[0] >>> 0;
23
+ OpencodeExecutionDriverFinalization.register(this, this.__wbg_ptr, this);
24
+ return this;
25
+ }
26
+ /**
27
+ * @param {any} observation
28
+ * @param {number} now_ms
29
+ * @returns {any}
30
+ */
31
+ observeEvent(observation, now_ms) {
32
+ const ret = wasm.opencodeexecutiondriver_observeEvent(this.__wbg_ptr, observation, now_ms);
33
+ if (ret[2]) {
34
+ throw takeFromExternrefTable0(ret[1]);
35
+ }
36
+ return takeFromExternrefTable0(ret[0]);
37
+ }
38
+ /**
39
+ * @param {any} result
40
+ * @returns {any}
41
+ */
42
+ resume(result) {
43
+ const ret = wasm.opencodeexecutiondriver_resume(this.__wbg_ptr, result);
44
+ if (ret[2]) {
45
+ throw takeFromExternrefTable0(ret[1]);
46
+ }
47
+ return takeFromExternrefTable0(ret[0]);
48
+ }
49
+ /**
50
+ * @returns {any}
51
+ */
52
+ start() {
53
+ const ret = wasm.opencodeexecutiondriver_start(this.__wbg_ptr);
54
+ if (ret[2]) {
55
+ throw takeFromExternrefTable0(ret[1]);
56
+ }
57
+ return takeFromExternrefTable0(ret[0]);
58
+ }
59
+ }
60
+ if (Symbol.dispose) OpencodeExecutionDriver.prototype[Symbol.dispose] = OpencodeExecutionDriver.prototype.free;
61
+ exports.OpencodeExecutionDriver = OpencodeExecutionDriver;
62
+
63
+ /**
64
+ * @param {any} target
65
+ * @returns {string}
66
+ */
67
+ function conversationKeyForDeliveryTarget(target) {
68
+ let deferred2_0;
69
+ let deferred2_1;
70
+ try {
71
+ const ret = wasm.conversationKeyForDeliveryTarget(target);
72
+ var ptr1 = ret[0];
73
+ var len1 = ret[1];
74
+ if (ret[3]) {
75
+ ptr1 = 0; len1 = 0;
76
+ throw takeFromExternrefTable0(ret[2]);
77
+ }
78
+ deferred2_0 = ptr1;
79
+ deferred2_1 = len1;
80
+ return getStringFromWasm0(ptr1, len1);
81
+ } finally {
82
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
83
+ }
84
+ }
85
+ exports.conversationKeyForDeliveryTarget = conversationKeyForDeliveryTarget;
86
+
87
+ /**
88
+ * @returns {any}
89
+ */
90
+ function gatewayStatus() {
91
+ const ret = wasm.gatewayStatus();
92
+ if (ret[2]) {
93
+ throw takeFromExternrefTable0(ret[1]);
94
+ }
95
+ return takeFromExternrefTable0(ret[0]);
96
+ }
97
+ exports.gatewayStatus = gatewayStatus;
98
+
99
+ /**
100
+ * @param {any} job
101
+ * @param {number} after_ms
102
+ * @param {string} time_zone
103
+ * @returns {number}
104
+ */
105
+ function nextCronRunAt(job, after_ms, time_zone) {
106
+ const ptr0 = passStringToWasm0(time_zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
107
+ const len0 = WASM_VECTOR_LEN;
108
+ const ret = wasm.nextCronRunAt(job, after_ms, ptr0, len0);
109
+ if (ret[2]) {
110
+ throw takeFromExternrefTable0(ret[1]);
111
+ }
112
+ return ret[0];
113
+ }
114
+ exports.nextCronRunAt = nextCronRunAt;
115
+
116
+ /**
117
+ * @param {string} time_zone
118
+ * @returns {string}
119
+ */
120
+ function normalizeCronTimeZone(time_zone) {
121
+ let deferred3_0;
122
+ let deferred3_1;
123
+ try {
124
+ const ptr0 = passStringToWasm0(time_zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
125
+ const len0 = WASM_VECTOR_LEN;
126
+ const ret = wasm.normalizeCronTimeZone(ptr0, len0);
127
+ var ptr2 = ret[0];
128
+ var len2 = ret[1];
129
+ if (ret[3]) {
130
+ ptr2 = 0; len2 = 0;
131
+ throw takeFromExternrefTable0(ret[2]);
132
+ }
133
+ deferred3_0 = ptr2;
134
+ deferred3_1 = len2;
135
+ return getStringFromWasm0(ptr2, len2);
136
+ } finally {
137
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
138
+ }
139
+ }
140
+ exports.normalizeCronTimeZone = normalizeCronTimeZone;
141
+
142
+ /**
143
+ * @param {any} job
144
+ * @returns {any}
145
+ */
146
+ function prepareCronExecution(job) {
147
+ const ret = wasm.prepareCronExecution(job);
148
+ if (ret[2]) {
149
+ throw takeFromExternrefTable0(ret[1]);
150
+ }
151
+ return takeFromExternrefTable0(ret[0]);
152
+ }
153
+ exports.prepareCronExecution = prepareCronExecution;
154
+
155
+ /**
156
+ * @param {any} message
157
+ * @returns {any}
158
+ */
159
+ function prepareInboundExecution(message) {
160
+ const ret = wasm.prepareInboundExecution(message);
161
+ if (ret[2]) {
162
+ throw takeFromExternrefTable0(ret[1]);
163
+ }
164
+ return takeFromExternrefTable0(ret[0]);
165
+ }
166
+ exports.prepareInboundExecution = prepareInboundExecution;
167
+
168
+ function __wbg_get_imports() {
169
+ const import0 = {
170
+ __proto__: null,
171
+ __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
172
+ const ret = Error(getStringFromWasm0(arg0, arg1));
173
+ return ret;
174
+ },
175
+ __wbg_Number_a5a435bd7bbec835: function(arg0) {
176
+ const ret = Number(arg0);
177
+ return ret;
178
+ },
179
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
180
+ const ret = String(arg1);
181
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
182
+ const len1 = WASM_VECTOR_LEN;
183
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
184
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
185
+ },
186
+ __wbg___wbindgen_bigint_get_as_i64_447a76b5c6ef7bda: function(arg0, arg1) {
187
+ const v = arg1;
188
+ const ret = typeof(v) === 'bigint' ? v : undefined;
189
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
190
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
191
+ },
192
+ __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) {
193
+ const v = arg0;
194
+ const ret = typeof(v) === 'boolean' ? v : undefined;
195
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
196
+ },
197
+ __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
198
+ const ret = debugString(arg1);
199
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
200
+ const len1 = WASM_VECTOR_LEN;
201
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
202
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
203
+ },
204
+ __wbg___wbindgen_in_41dbb8413020e076: function(arg0, arg1) {
205
+ const ret = arg0 in arg1;
206
+ return ret;
207
+ },
208
+ __wbg___wbindgen_is_bigint_e2141d4f045b7eda: function(arg0) {
209
+ const ret = typeof(arg0) === 'bigint';
210
+ return ret;
211
+ },
212
+ __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
213
+ const ret = typeof(arg0) === 'function';
214
+ return ret;
215
+ },
216
+ __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
217
+ const val = arg0;
218
+ const ret = typeof(val) === 'object' && val !== null;
219
+ return ret;
220
+ },
221
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
222
+ const ret = arg0 === undefined;
223
+ return ret;
224
+ },
225
+ __wbg___wbindgen_jsval_eq_ee31bfad3e536463: function(arg0, arg1) {
226
+ const ret = arg0 === arg1;
227
+ return ret;
228
+ },
229
+ __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b: function(arg0, arg1) {
230
+ const ret = arg0 == arg1;
231
+ return ret;
232
+ },
233
+ __wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
234
+ const obj = arg1;
235
+ const ret = typeof(obj) === 'number' ? obj : undefined;
236
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
237
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
238
+ },
239
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
240
+ const obj = arg1;
241
+ const ret = typeof(obj) === 'string' ? obj : undefined;
242
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
243
+ var len1 = WASM_VECTOR_LEN;
244
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
245
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
246
+ },
247
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
248
+ throw new Error(getStringFromWasm0(arg0, arg1));
249
+ },
250
+ __wbg_call_e133b57c9155d22c: function() { return handleError(function (arg0, arg1) {
251
+ const ret = arg0.call(arg1);
252
+ return ret;
253
+ }, arguments); },
254
+ __wbg_done_08ce71ee07e3bd17: function(arg0) {
255
+ const ret = arg0.done;
256
+ return ret;
257
+ },
258
+ __wbg_entries_e8a20ff8c9757101: function(arg0) {
259
+ const ret = Object.entries(arg0);
260
+ return ret;
261
+ },
262
+ __wbg_get_326e41e095fb2575: function() { return handleError(function (arg0, arg1) {
263
+ const ret = Reflect.get(arg0, arg1);
264
+ return ret;
265
+ }, arguments); },
266
+ __wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
267
+ const ret = arg0[arg1 >>> 0];
268
+ return ret;
269
+ },
270
+ __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
271
+ const ret = arg0[arg1 >>> 0];
272
+ return ret;
273
+ },
274
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
275
+ const ret = arg0[arg1];
276
+ return ret;
277
+ },
278
+ __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
279
+ let result;
280
+ try {
281
+ result = arg0 instanceof ArrayBuffer;
282
+ } catch (_) {
283
+ result = false;
284
+ }
285
+ const ret = result;
286
+ return ret;
287
+ },
288
+ __wbg_instanceof_Map_f194b366846aca0c: function(arg0) {
289
+ let result;
290
+ try {
291
+ result = arg0 instanceof Map;
292
+ } catch (_) {
293
+ result = false;
294
+ }
295
+ const ret = result;
296
+ return ret;
297
+ },
298
+ __wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
299
+ let result;
300
+ try {
301
+ result = arg0 instanceof Uint8Array;
302
+ } catch (_) {
303
+ result = false;
304
+ }
305
+ const ret = result;
306
+ return ret;
307
+ },
308
+ __wbg_isArray_33b91feb269ff46e: function(arg0) {
309
+ const ret = Array.isArray(arg0);
310
+ return ret;
311
+ },
312
+ __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
313
+ const ret = Number.isSafeInteger(arg0);
314
+ return ret;
315
+ },
316
+ __wbg_iterator_d8f549ec8fb061b1: function() {
317
+ const ret = Symbol.iterator;
318
+ return ret;
319
+ },
320
+ __wbg_length_b3416cf66a5452c8: function(arg0) {
321
+ const ret = arg0.length;
322
+ return ret;
323
+ },
324
+ __wbg_length_ea16607d7b61445b: function(arg0) {
325
+ const ret = arg0.length;
326
+ return ret;
327
+ },
328
+ __wbg_new_5f486cdf45a04d78: function(arg0) {
329
+ const ret = new Uint8Array(arg0);
330
+ return ret;
331
+ },
332
+ __wbg_new_a70fbab9066b301f: function() {
333
+ const ret = new Array();
334
+ return ret;
335
+ },
336
+ __wbg_new_ab79df5bd7c26067: function() {
337
+ const ret = new Object();
338
+ return ret;
339
+ },
340
+ __wbg_next_11b99ee6237339e3: function() { return handleError(function (arg0) {
341
+ const ret = arg0.next();
342
+ return ret;
343
+ }, arguments); },
344
+ __wbg_next_e01a967809d1aa68: function(arg0) {
345
+ const ret = arg0.next;
346
+ return ret;
347
+ },
348
+ __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
349
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
350
+ },
351
+ __wbg_set_282384002438957f: function(arg0, arg1, arg2) {
352
+ arg0[arg1 >>> 0] = arg2;
353
+ },
354
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
355
+ arg0[arg1] = arg2;
356
+ },
357
+ __wbg_value_21fc78aab0322612: function(arg0) {
358
+ const ret = arg0.value;
359
+ return ret;
360
+ },
361
+ __wbindgen_cast_0000000000000001: function(arg0) {
362
+ // Cast intrinsic for `I64 -> Externref`.
363
+ const ret = arg0;
364
+ return ret;
365
+ },
366
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
367
+ // Cast intrinsic for `Ref(String) -> Externref`.
368
+ const ret = getStringFromWasm0(arg0, arg1);
369
+ return ret;
370
+ },
371
+ __wbindgen_cast_0000000000000003: function(arg0) {
372
+ // Cast intrinsic for `U64 -> Externref`.
373
+ const ret = BigInt.asUintN(64, arg0);
374
+ return ret;
375
+ },
376
+ __wbindgen_init_externref_table: function() {
377
+ const table = wasm.__wbindgen_externrefs;
378
+ const offset = table.grow(4);
379
+ table.set(0, undefined);
380
+ table.set(offset + 0, undefined);
381
+ table.set(offset + 1, null);
382
+ table.set(offset + 2, true);
383
+ table.set(offset + 3, false);
384
+ },
385
+ };
386
+ return {
387
+ __proto__: null,
388
+ "./opencode_gateway_ffi_bg.js": import0,
389
+ };
390
+ }
391
+
392
+ const OpencodeExecutionDriverFinalization = (typeof FinalizationRegistry === 'undefined')
393
+ ? { register: () => {}, unregister: () => {} }
394
+ : new FinalizationRegistry(ptr => wasm.__wbg_opencodeexecutiondriver_free(ptr >>> 0, 1));
395
+
396
+ function addToExternrefTable0(obj) {
397
+ const idx = wasm.__externref_table_alloc();
398
+ wasm.__wbindgen_externrefs.set(idx, obj);
399
+ return idx;
400
+ }
401
+
402
+ function debugString(val) {
403
+ // primitive types
404
+ const type = typeof val;
405
+ if (type == 'number' || type == 'boolean' || val == null) {
406
+ return `${val}`;
407
+ }
408
+ if (type == 'string') {
409
+ return `"${val}"`;
410
+ }
411
+ if (type == 'symbol') {
412
+ const description = val.description;
413
+ if (description == null) {
414
+ return 'Symbol';
415
+ } else {
416
+ return `Symbol(${description})`;
417
+ }
418
+ }
419
+ if (type == 'function') {
420
+ const name = val.name;
421
+ if (typeof name == 'string' && name.length > 0) {
422
+ return `Function(${name})`;
423
+ } else {
424
+ return 'Function';
425
+ }
426
+ }
427
+ // objects
428
+ if (Array.isArray(val)) {
429
+ const length = val.length;
430
+ let debug = '[';
431
+ if (length > 0) {
432
+ debug += debugString(val[0]);
433
+ }
434
+ for(let i = 1; i < length; i++) {
435
+ debug += ', ' + debugString(val[i]);
436
+ }
437
+ debug += ']';
438
+ return debug;
439
+ }
440
+ // Test for built-in
441
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
442
+ let className;
443
+ if (builtInMatches && builtInMatches.length > 1) {
444
+ className = builtInMatches[1];
445
+ } else {
446
+ // Failed to match the standard '[object ClassName]'
447
+ return toString.call(val);
448
+ }
449
+ if (className == 'Object') {
450
+ // we're a user defined class or Object
451
+ // JSON.stringify avoids problems with cycles, and is generally much
452
+ // easier than looping through ownProperties of `val`.
453
+ try {
454
+ return 'Object(' + JSON.stringify(val) + ')';
455
+ } catch (_) {
456
+ return 'Object';
457
+ }
458
+ }
459
+ // errors
460
+ if (val instanceof Error) {
461
+ return `${val.name}: ${val.message}\n${val.stack}`;
462
+ }
463
+ // TODO we could test for more things here, like `Set`s and `Map`s.
464
+ return className;
465
+ }
466
+
467
+ function getArrayU8FromWasm0(ptr, len) {
468
+ ptr = ptr >>> 0;
469
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
470
+ }
471
+
472
+ let cachedDataViewMemory0 = null;
473
+ function getDataViewMemory0() {
474
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
475
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
476
+ }
477
+ return cachedDataViewMemory0;
478
+ }
479
+
480
+ function getStringFromWasm0(ptr, len) {
481
+ ptr = ptr >>> 0;
482
+ return decodeText(ptr, len);
483
+ }
484
+
485
+ let cachedUint8ArrayMemory0 = null;
486
+ function getUint8ArrayMemory0() {
487
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
488
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
489
+ }
490
+ return cachedUint8ArrayMemory0;
491
+ }
492
+
493
+ function handleError(f, args) {
494
+ try {
495
+ return f.apply(this, args);
496
+ } catch (e) {
497
+ const idx = addToExternrefTable0(e);
498
+ wasm.__wbindgen_exn_store(idx);
499
+ }
500
+ }
501
+
502
+ function isLikeNone(x) {
503
+ return x === undefined || x === null;
504
+ }
505
+
506
+ function passStringToWasm0(arg, malloc, realloc) {
507
+ if (realloc === undefined) {
508
+ const buf = cachedTextEncoder.encode(arg);
509
+ const ptr = malloc(buf.length, 1) >>> 0;
510
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
511
+ WASM_VECTOR_LEN = buf.length;
512
+ return ptr;
513
+ }
514
+
515
+ let len = arg.length;
516
+ let ptr = malloc(len, 1) >>> 0;
517
+
518
+ const mem = getUint8ArrayMemory0();
519
+
520
+ let offset = 0;
521
+
522
+ for (; offset < len; offset++) {
523
+ const code = arg.charCodeAt(offset);
524
+ if (code > 0x7F) break;
525
+ mem[ptr + offset] = code;
526
+ }
527
+ if (offset !== len) {
528
+ if (offset !== 0) {
529
+ arg = arg.slice(offset);
530
+ }
531
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
532
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
533
+ const ret = cachedTextEncoder.encodeInto(arg, view);
534
+
535
+ offset += ret.written;
536
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
537
+ }
538
+
539
+ WASM_VECTOR_LEN = offset;
540
+ return ptr;
541
+ }
542
+
543
+ function takeFromExternrefTable0(idx) {
544
+ const value = wasm.__wbindgen_externrefs.get(idx);
545
+ wasm.__externref_table_dealloc(idx);
546
+ return value;
547
+ }
548
+
549
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
550
+ cachedTextDecoder.decode();
551
+ function decodeText(ptr, len) {
552
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
553
+ }
554
+
555
+ const cachedTextEncoder = new TextEncoder();
556
+
557
+ if (!('encodeInto' in cachedTextEncoder)) {
558
+ cachedTextEncoder.encodeInto = function (arg, view) {
559
+ const buf = cachedTextEncoder.encode(arg);
560
+ view.set(buf);
561
+ return {
562
+ read: arg.length,
563
+ written: buf.length
564
+ };
565
+ };
566
+ }
567
+
568
+ let WASM_VECTOR_LEN = 0;
569
+
570
+ const wasmPath = `${__dirname}/opencode_gateway_ffi_bg.wasm`;
571
+ const wasmBytes = require('fs').readFileSync(wasmPath);
572
+ const wasmModule = new WebAssembly.Module(wasmBytes);
573
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
574
+ wasm.__wbindgen_start();
@@ -0,0 +1,22 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const conversationKeyForDeliveryTarget: (a: any) => [number, number, number, number];
5
+ export const gatewayStatus: () => [number, number, number];
6
+ export const nextCronRunAt: (a: any, b: number, c: number, d: number) => [number, number, number];
7
+ export const normalizeCronTimeZone: (a: number, b: number) => [number, number, number, number];
8
+ export const __wbg_opencodeexecutiondriver_free: (a: number, b: number) => void;
9
+ export const opencodeexecutiondriver_new: (a: any) => [number, number, number];
10
+ export const opencodeexecutiondriver_observeEvent: (a: number, b: any, c: number) => [number, number, number];
11
+ export const opencodeexecutiondriver_resume: (a: number, b: any) => [number, number, number];
12
+ export const opencodeexecutiondriver_start: (a: number) => [number, number, number];
13
+ export const prepareCronExecution: (a: any) => [number, number, number];
14
+ export const prepareInboundExecution: (a: any) => [number, number, number];
15
+ export const __wbindgen_malloc: (a: number, b: number) => number;
16
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
17
+ export const __wbindgen_exn_store: (a: number) => void;
18
+ export const __externref_table_alloc: () => number;
19
+ export const __wbindgen_externrefs: WebAssembly.Table;
20
+ export const __externref_table_dealloc: (a: number) => void;
21
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
22
+ export const __wbindgen_start: () => void;
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "opencode-gateway",
3
+ "version": "0.1.0",
4
+ "description": "Gateway plugin for OpenCode",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "bin": {
10
+ "opencode-gateway": "./dist/cli.js"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "generated/wasm/pkg",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "node ./scripts/build.mjs",
27
+ "build:wasm": "node ../../scripts/build-binding.mjs",
28
+ "check": "tsc --noEmit --project tsconfig.json && bun test src",
29
+ "prepack": "npm run build:wasm && npm run build",
30
+ "test": "bun test src"
31
+ },
32
+ "keywords": [
33
+ "opencode",
34
+ "plugin",
35
+ "gateway",
36
+ "telegram",
37
+ "automation"
38
+ ],
39
+ "engines": {
40
+ "node": ">=20"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/M4n5ter/aI.git",
45
+ "directory": "packages/opencode-plugin"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/M4n5ter/aI/issues"
49
+ },
50
+ "homepage": "https://github.com/M4n5ter/aI",
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "dependencies": {
55
+ "@opencode-ai/plugin": "~1.3.0",
56
+ "@opencode-ai/sdk": "~1.3.0"
57
+ },
58
+ "devDependencies": {
59
+ "bun-types": "^1.3.11"
60
+ }
61
+ }