opencode-gateway 0.2.5 → 0.2.7
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.
package/dist/index.js
CHANGED
|
@@ -12688,8 +12688,8 @@ var require_pattern = __commonJS((exports) => {
|
|
|
12688
12688
|
}
|
|
12689
12689
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
12690
12690
|
function isAffectDepthOfReadingPattern(pattern) {
|
|
12691
|
-
const
|
|
12692
|
-
return endsWithSlashGlobStar(pattern) || isStaticPattern(
|
|
12691
|
+
const basename2 = path.basename(pattern);
|
|
12692
|
+
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename2);
|
|
12693
12693
|
}
|
|
12694
12694
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
12695
12695
|
function expandPatternsWithBraceExpansion(patterns) {
|
|
@@ -14975,18 +14975,29 @@ function toSqliteParams(params) {
|
|
|
14975
14975
|
var init_database = () => {};
|
|
14976
14976
|
|
|
14977
14977
|
// src/binding/index.ts
|
|
14978
|
-
import { access } from "node:fs/promises";
|
|
14979
|
-
var
|
|
14978
|
+
import { access, readFile } from "node:fs/promises";
|
|
14979
|
+
var GENERATED_WASM_ENTRYPOINT_CANDIDATES = [
|
|
14980
14980
|
new URL("../generated/wasm/pkg/opencode_gateway_ffi.js", import.meta.url),
|
|
14981
14981
|
new URL("../../generated/wasm/pkg/opencode_gateway_ffi.js", import.meta.url)
|
|
14982
14982
|
];
|
|
14983
|
+
var cachedBindingModulePromise = null;
|
|
14983
14984
|
async function loadGatewayBindingModule() {
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
|
|
14985
|
+
if (cachedBindingModulePromise !== null) {
|
|
14986
|
+
return await cachedBindingModulePromise;
|
|
14987
|
+
}
|
|
14988
|
+
cachedBindingModulePromise = loadGatewayBindingModuleOnce();
|
|
14989
|
+
return await cachedBindingModulePromise;
|
|
14990
|
+
}
|
|
14991
|
+
async function loadGatewayBindingModuleOnce() {
|
|
14992
|
+
for (const entrypointUrl of GENERATED_WASM_ENTRYPOINT_CANDIDATES) {
|
|
14993
|
+
if (!await canReadFile(entrypointUrl)) {
|
|
14994
|
+
continue;
|
|
14987
14995
|
}
|
|
14996
|
+
const module = await import(entrypointUrl.href);
|
|
14997
|
+
await initializeGatewayBindingModule(module, entrypointUrl);
|
|
14998
|
+
return module;
|
|
14988
14999
|
}
|
|
14989
|
-
throw new Error(`Unable to locate generated gateway wasm entrypoint. Checked: ${
|
|
15000
|
+
throw new Error(`Unable to locate generated gateway wasm entrypoint. Checked: ${GENERATED_WASM_ENTRYPOINT_CANDIDATES.map((candidate) => candidate.pathname).join(", ")}`);
|
|
14990
15001
|
}
|
|
14991
15002
|
async function canReadFile(candidate) {
|
|
14992
15003
|
try {
|
|
@@ -14996,13 +15007,21 @@ async function canReadFile(candidate) {
|
|
|
14996
15007
|
return false;
|
|
14997
15008
|
}
|
|
14998
15009
|
}
|
|
15010
|
+
async function initializeGatewayBindingModule(module, entrypointUrl) {
|
|
15011
|
+
if (module.initSync === undefined) {
|
|
15012
|
+
return;
|
|
15013
|
+
}
|
|
15014
|
+
const wasmUrl = new URL("./opencode_gateway_ffi_bg.wasm", entrypointUrl);
|
|
15015
|
+
const wasmBytes = await readFile(wasmUrl);
|
|
15016
|
+
module.initSync({ module: wasmBytes });
|
|
15017
|
+
}
|
|
14999
15018
|
|
|
15000
15019
|
// src/gateway.ts
|
|
15001
|
-
import { mkdir as
|
|
15020
|
+
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
15002
15021
|
|
|
15003
15022
|
// src/config/gateway.ts
|
|
15004
15023
|
import { existsSync } from "node:fs";
|
|
15005
|
-
import { readFile } from "node:fs/promises";
|
|
15024
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
15006
15025
|
import { dirname as dirname2, isAbsolute, join as join2, resolve as resolve3 } from "node:path";
|
|
15007
15026
|
|
|
15008
15027
|
// ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
|
|
@@ -16062,8 +16081,8 @@ function readOptionalString(value, field) {
|
|
|
16062
16081
|
}
|
|
16063
16082
|
|
|
16064
16083
|
// src/config/memory.ts
|
|
16065
|
-
import { stat } from "node:fs/promises";
|
|
16066
|
-
import { resolve } from "node:path";
|
|
16084
|
+
import { mkdir, stat, writeFile } from "node:fs/promises";
|
|
16085
|
+
import { basename, extname, resolve } from "node:path";
|
|
16067
16086
|
async function parseMemoryConfig(value, workspaceDirPath) {
|
|
16068
16087
|
const table = readMemoryTable(value);
|
|
16069
16088
|
const entries = await readMemoryEntries(table.entries, workspaceDirPath);
|
|
@@ -16096,7 +16115,7 @@ async function readMemoryEntry(value, index, workspaceDirPath) {
|
|
|
16096
16115
|
const displayPath = readRequiredString(entry.path, `${field}.path`);
|
|
16097
16116
|
const description = readRequiredString(entry.description, `${field}.description`);
|
|
16098
16117
|
const resolvedPath = resolve(workspaceDirPath, displayPath);
|
|
16099
|
-
const metadata = await
|
|
16118
|
+
const metadata = await ensurePathMetadata(resolvedPath, displayPath, entry, `${field}.path`);
|
|
16100
16119
|
if (metadata.isFile()) {
|
|
16101
16120
|
ensureDirectoryOnlyFieldIsAbsent(entry.inject_markdown_contents, `${field}.inject_markdown_contents`);
|
|
16102
16121
|
ensureDirectoryOnlyFieldIsAbsent(entry.globs, `${field}.globs`);
|
|
@@ -16121,12 +16140,47 @@ async function readMemoryEntry(value, index, workspaceDirPath) {
|
|
|
16121
16140
|
}
|
|
16122
16141
|
throw new Error(`${field}.path must point to a regular file or directory`);
|
|
16123
16142
|
}
|
|
16124
|
-
async function
|
|
16143
|
+
async function ensurePathMetadata(path, displayPath, entry, field) {
|
|
16125
16144
|
try {
|
|
16126
16145
|
return await stat(path);
|
|
16127
16146
|
} catch (error) {
|
|
16128
|
-
|
|
16147
|
+
if (!isMissingPathError(error)) {
|
|
16148
|
+
throw error;
|
|
16149
|
+
}
|
|
16150
|
+
const kind = inferMissingEntryKind(displayPath, entry);
|
|
16151
|
+
await createMissingEntryPath(path, kind);
|
|
16152
|
+
return await stat(path);
|
|
16153
|
+
}
|
|
16154
|
+
}
|
|
16155
|
+
function isMissingPathError(error) {
|
|
16156
|
+
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
16157
|
+
}
|
|
16158
|
+
function inferMissingEntryKind(displayPath, entry) {
|
|
16159
|
+
if (entry.inject_content !== undefined) {
|
|
16160
|
+
return "file";
|
|
16161
|
+
}
|
|
16162
|
+
if (entry.inject_markdown_contents !== undefined || entry.globs !== undefined) {
|
|
16163
|
+
return "directory";
|
|
16164
|
+
}
|
|
16165
|
+
const trimmedPath = displayPath.trim();
|
|
16166
|
+
if (trimmedPath.endsWith("/") || trimmedPath.endsWith("\\")) {
|
|
16167
|
+
return "directory";
|
|
16129
16168
|
}
|
|
16169
|
+
const name = basename(trimmedPath);
|
|
16170
|
+
if (name.startsWith(".") || extname(name).length > 0) {
|
|
16171
|
+
return "file";
|
|
16172
|
+
}
|
|
16173
|
+
return "directory";
|
|
16174
|
+
}
|
|
16175
|
+
async function createMissingEntryPath(path, kind) {
|
|
16176
|
+
if (kind === "directory") {
|
|
16177
|
+
await mkdir(path, { recursive: true });
|
|
16178
|
+
return;
|
|
16179
|
+
}
|
|
16180
|
+
const lastSlash = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
16181
|
+
const parentPath = lastSlash >= 0 ? path.slice(0, lastSlash) : ".";
|
|
16182
|
+
await mkdir(parentPath, { recursive: true });
|
|
16183
|
+
await writeFile(path, "", { flag: "a" });
|
|
16130
16184
|
}
|
|
16131
16185
|
function ensureDirectoryOnlyFieldIsAbsent(value, field) {
|
|
16132
16186
|
if (value !== undefined) {
|
|
@@ -16331,7 +16385,7 @@ async function readGatewayConfigFile(path) {
|
|
|
16331
16385
|
if (!existsSync(path)) {
|
|
16332
16386
|
return null;
|
|
16333
16387
|
}
|
|
16334
|
-
const source = await
|
|
16388
|
+
const source = await readFile2(path, "utf8");
|
|
16335
16389
|
const parsed = parse(source);
|
|
16336
16390
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
16337
16391
|
throw new Error(`gateway config must decode to a table: ${path}`);
|
|
@@ -17305,7 +17359,7 @@ import { open } from "node:fs/promises";
|
|
|
17305
17359
|
* MIT Licensed
|
|
17306
17360
|
*/
|
|
17307
17361
|
var db = require_db();
|
|
17308
|
-
var
|
|
17362
|
+
var extname2 = __require("path").extname;
|
|
17309
17363
|
var mimeScore = require_mimeScore();
|
|
17310
17364
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
17311
17365
|
var $extensions = Object.create(null);
|
|
@@ -17328,7 +17382,7 @@ function lookup(path) {
|
|
|
17328
17382
|
if (!path || typeof path !== "string") {
|
|
17329
17383
|
return false;
|
|
17330
17384
|
}
|
|
17331
|
-
var extension2 =
|
|
17385
|
+
var extension2 = extname2("x." + path).toLowerCase().slice(1);
|
|
17332
17386
|
if (!extension2) {
|
|
17333
17387
|
return false;
|
|
17334
17388
|
}
|
|
@@ -17523,8 +17577,8 @@ class GatewayMailboxRouter {
|
|
|
17523
17577
|
|
|
17524
17578
|
// src/memory/prompt.ts
|
|
17525
17579
|
var import_fast_glob = __toESM(require_out4(), 1);
|
|
17526
|
-
import { readFile as
|
|
17527
|
-
import { extname as
|
|
17580
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
17581
|
+
import { extname as extname3, relative } from "node:path";
|
|
17528
17582
|
var MARKDOWN_GLOBS = ["**/*.md", "**/*.markdown"];
|
|
17529
17583
|
var UTF8_TEXT_DECODER = new TextDecoder("utf-8", { fatal: true });
|
|
17530
17584
|
|
|
@@ -17604,7 +17658,7 @@ function addMatchingFiles(result, cwd, pattern) {
|
|
|
17604
17658
|
async function readTextFile(path, logger) {
|
|
17605
17659
|
let bytes;
|
|
17606
17660
|
try {
|
|
17607
|
-
bytes = await
|
|
17661
|
+
bytes = await readFile3(path);
|
|
17608
17662
|
} catch (error) {
|
|
17609
17663
|
logger.log("warn", `memory file could not be read and will be skipped: ${path}: ${formatError2(error)}`);
|
|
17610
17664
|
return null;
|
|
@@ -17630,7 +17684,7 @@ function relativeDisplayPath(rootPath, rootDisplayPath, filePath) {
|
|
|
17630
17684
|
return `${rootDisplayPath}/${suffix.replaceAll("\\", "/")}`;
|
|
17631
17685
|
}
|
|
17632
17686
|
function inferFenceInfoString(path) {
|
|
17633
|
-
const extension2 =
|
|
17687
|
+
const extension2 = extname3(path).slice(1).toLowerCase();
|
|
17634
17688
|
if (!/^[a-z0-9_+-]+$/.test(extension2)) {
|
|
17635
17689
|
return "";
|
|
17636
17690
|
}
|
|
@@ -17649,7 +17703,7 @@ function formatError2(error) {
|
|
|
17649
17703
|
}
|
|
17650
17704
|
|
|
17651
17705
|
// src/opencode/adapter.ts
|
|
17652
|
-
import { basename } from "node:path";
|
|
17706
|
+
import { basename as basename2 } from "node:path";
|
|
17653
17707
|
import { pathToFileURL } from "node:url";
|
|
17654
17708
|
|
|
17655
17709
|
// src/runtime/delay.ts
|
|
@@ -17891,7 +17945,7 @@ function toSessionPromptPart(part) {
|
|
|
17891
17945
|
type: "file",
|
|
17892
17946
|
mime: part.mimeType,
|
|
17893
17947
|
url: pathToFileURL(part.localPath).href,
|
|
17894
|
-
filename: part.fileName ??
|
|
17948
|
+
filename: part.fileName ?? basename2(part.localPath)
|
|
17895
17949
|
};
|
|
17896
17950
|
}
|
|
17897
17951
|
}
|
|
@@ -22369,7 +22423,7 @@ function buildGatewayContextPrompt(targets) {
|
|
|
22369
22423
|
}
|
|
22370
22424
|
|
|
22371
22425
|
// src/store/sqlite.ts
|
|
22372
|
-
import { mkdir } from "node:fs/promises";
|
|
22426
|
+
import { mkdir as mkdir2 } from "node:fs/promises";
|
|
22373
22427
|
import { dirname as dirname3 } from "node:path";
|
|
22374
22428
|
|
|
22375
22429
|
// src/store/migrations.ts
|
|
@@ -23284,7 +23338,7 @@ function readBooleanField(value, field, fallback) {
|
|
|
23284
23338
|
return raw;
|
|
23285
23339
|
}
|
|
23286
23340
|
async function openSqliteStore(path) {
|
|
23287
|
-
await
|
|
23341
|
+
await mkdir2(dirname3(path), { recursive: true });
|
|
23288
23342
|
const { SqliteDatabase: SqliteDatabase2 } = await Promise.resolve().then(() => (init_database(), exports_database));
|
|
23289
23343
|
const db2 = new SqliteDatabase2(path);
|
|
23290
23344
|
migrateGatewayDatabase(db2);
|
|
@@ -23292,7 +23346,7 @@ async function openSqliteStore(path) {
|
|
|
23292
23346
|
}
|
|
23293
23347
|
|
|
23294
23348
|
// src/telegram/client.ts
|
|
23295
|
-
import { readFile as
|
|
23349
|
+
import { readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
|
|
23296
23350
|
class TelegramApiError extends Error {
|
|
23297
23351
|
retryable;
|
|
23298
23352
|
constructor(message, retryable) {
|
|
@@ -23337,7 +23391,7 @@ class TelegramBotClient {
|
|
|
23337
23391
|
if (!response.ok) {
|
|
23338
23392
|
throw new TelegramApiError(`Telegram file download failed (${response.status}): ${response.statusText}`, isRetryableError(response.status, response.status));
|
|
23339
23393
|
}
|
|
23340
|
-
await
|
|
23394
|
+
await writeFile2(localPath, new Uint8Array(await response.arrayBuffer()));
|
|
23341
23395
|
}
|
|
23342
23396
|
async sendMessage(chatId, text, messageThreadId) {
|
|
23343
23397
|
await this.call("sendMessage", {
|
|
@@ -23436,7 +23490,7 @@ class TelegramBotClient {
|
|
|
23436
23490
|
}
|
|
23437
23491
|
}
|
|
23438
23492
|
async function readLocalFileBlob(filePath, mimeType) {
|
|
23439
|
-
const bytes = await
|
|
23493
|
+
const bytes = await readFile4(filePath);
|
|
23440
23494
|
return new Blob([bytes], { type: mimeType });
|
|
23441
23495
|
}
|
|
23442
23496
|
function inferUploadFileName(filePath) {
|
|
@@ -23481,8 +23535,8 @@ function isRetryableError(errorCode, httpStatus) {
|
|
|
23481
23535
|
}
|
|
23482
23536
|
|
|
23483
23537
|
// src/telegram/media.ts
|
|
23484
|
-
import { mkdir as
|
|
23485
|
-
import { basename as
|
|
23538
|
+
import { mkdir as mkdir3 } from "node:fs/promises";
|
|
23539
|
+
import { basename as basename3, extname as extname4, join as join3 } from "node:path";
|
|
23486
23540
|
class TelegramInboundMediaStore {
|
|
23487
23541
|
client;
|
|
23488
23542
|
mediaRootPath;
|
|
@@ -23511,9 +23565,9 @@ class TelegramInboundMediaStore {
|
|
|
23511
23565
|
if (!remotePath) {
|
|
23512
23566
|
throw new Error(`Telegram file ${attachment.fileId} did not include file_path`);
|
|
23513
23567
|
}
|
|
23514
|
-
const fileName = normalizeOptionalFileName(attachment.fileName) ?? normalizeOptionalFileName(
|
|
23568
|
+
const fileName = normalizeOptionalFileName(attachment.fileName) ?? normalizeOptionalFileName(basename3(remotePath)) ?? `telegram-image-${ordinal + 1}${extensionFromRemotePath(remotePath)}`;
|
|
23515
23569
|
const localPath = join3(this.mediaRootPath, "telegram", sanitizePathSegment(sourceKind), sanitizePathSegment(externalId), `${ordinal}-${sanitizePathSegment(fileName)}`);
|
|
23516
|
-
await
|
|
23570
|
+
await mkdir3(join3(this.mediaRootPath, "telegram", sanitizePathSegment(sourceKind), sanitizePathSegment(externalId)), {
|
|
23517
23571
|
recursive: true
|
|
23518
23572
|
});
|
|
23519
23573
|
await this.client.downloadFile(remotePath, localPath);
|
|
@@ -23536,7 +23590,7 @@ function normalizeOptionalFileName(value) {
|
|
|
23536
23590
|
return trimmed.length === 0 ? null : trimmed;
|
|
23537
23591
|
}
|
|
23538
23592
|
function extensionFromRemotePath(remotePath) {
|
|
23539
|
-
const extension2 =
|
|
23593
|
+
const extension2 = extname4(remotePath);
|
|
23540
23594
|
return extension2.length === 0 ? ".bin" : extension2;
|
|
23541
23595
|
}
|
|
23542
23596
|
|
|
@@ -24044,7 +24098,7 @@ class GatewayPluginRuntime {
|
|
|
24044
24098
|
async function createGatewayRuntime(module, input) {
|
|
24045
24099
|
const config = await loadGatewayConfig();
|
|
24046
24100
|
return await getOrCreateRuntimeSingleton(config.configPath, async () => {
|
|
24047
|
-
await
|
|
24101
|
+
await mkdir4(config.workspaceDirPath, { recursive: true });
|
|
24048
24102
|
const logger = new ConsoleLoggerHost(config.logLevel);
|
|
24049
24103
|
if (config.hasLegacyGatewayTimezone) {
|
|
24050
24104
|
const suffix = config.legacyGatewayTimezone === null ? "" : ` (${config.legacyGatewayTimezone})`;
|
|
@@ -21,3 +21,50 @@ export function normalizeCronTimeZone(time_zone: string): string;
|
|
|
21
21
|
export function prepareCronExecution(job: any): any;
|
|
22
22
|
|
|
23
23
|
export function prepareInboundExecution(message: any): any;
|
|
24
|
+
|
|
25
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
26
|
+
|
|
27
|
+
export interface InitOutput {
|
|
28
|
+
readonly memory: WebAssembly.Memory;
|
|
29
|
+
readonly conversationKeyForDeliveryTarget: (a: any) => [number, number, number, number];
|
|
30
|
+
readonly gatewayStatus: () => [number, number, number];
|
|
31
|
+
readonly nextCronRunAt: (a: any, b: number, c: number, d: number) => [number, number, number];
|
|
32
|
+
readonly normalizeCronTimeZone: (a: number, b: number) => [number, number, number, number];
|
|
33
|
+
readonly __wbg_opencodeexecutiondriver_free: (a: number, b: number) => void;
|
|
34
|
+
readonly opencodeexecutiondriver_new: (a: any) => [number, number, number];
|
|
35
|
+
readonly opencodeexecutiondriver_observeEvent: (a: number, b: any, c: number) => [number, number, number];
|
|
36
|
+
readonly opencodeexecutiondriver_resume: (a: number, b: any) => [number, number, number];
|
|
37
|
+
readonly opencodeexecutiondriver_start: (a: number) => [number, number, number];
|
|
38
|
+
readonly prepareCronExecution: (a: any) => [number, number, number];
|
|
39
|
+
readonly prepareInboundExecution: (a: any) => [number, number, number];
|
|
40
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
41
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
42
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
43
|
+
readonly __externref_table_alloc: () => number;
|
|
44
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
45
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
46
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
47
|
+
readonly __wbindgen_start: () => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
54
|
+
* a precompiled `WebAssembly.Module`.
|
|
55
|
+
*
|
|
56
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
57
|
+
*
|
|
58
|
+
* @returns {InitOutput}
|
|
59
|
+
*/
|
|
60
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
64
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
65
|
+
*
|
|
66
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
67
|
+
*
|
|
68
|
+
* @returns {Promise<InitOutput>}
|
|
69
|
+
*/
|
|
70
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./opencode_gateway_ffi.d.ts" */
|
|
2
2
|
|
|
3
|
-
class OpencodeExecutionDriver {
|
|
3
|
+
export class OpencodeExecutionDriver {
|
|
4
4
|
__destroy_into_raw() {
|
|
5
5
|
const ptr = this.__wbg_ptr;
|
|
6
6
|
this.__wbg_ptr = 0;
|
|
@@ -58,13 +58,12 @@ class OpencodeExecutionDriver {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
if (Symbol.dispose) OpencodeExecutionDriver.prototype[Symbol.dispose] = OpencodeExecutionDriver.prototype.free;
|
|
61
|
-
exports.OpencodeExecutionDriver = OpencodeExecutionDriver;
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
63
|
* @param {any} target
|
|
65
64
|
* @returns {string}
|
|
66
65
|
*/
|
|
67
|
-
function conversationKeyForDeliveryTarget(target) {
|
|
66
|
+
export function conversationKeyForDeliveryTarget(target) {
|
|
68
67
|
let deferred2_0;
|
|
69
68
|
let deferred2_1;
|
|
70
69
|
try {
|
|
@@ -82,19 +81,17 @@ function conversationKeyForDeliveryTarget(target) {
|
|
|
82
81
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
|
-
exports.conversationKeyForDeliveryTarget = conversationKeyForDeliveryTarget;
|
|
86
84
|
|
|
87
85
|
/**
|
|
88
86
|
* @returns {any}
|
|
89
87
|
*/
|
|
90
|
-
function gatewayStatus() {
|
|
88
|
+
export function gatewayStatus() {
|
|
91
89
|
const ret = wasm.gatewayStatus();
|
|
92
90
|
if (ret[2]) {
|
|
93
91
|
throw takeFromExternrefTable0(ret[1]);
|
|
94
92
|
}
|
|
95
93
|
return takeFromExternrefTable0(ret[0]);
|
|
96
94
|
}
|
|
97
|
-
exports.gatewayStatus = gatewayStatus;
|
|
98
95
|
|
|
99
96
|
/**
|
|
100
97
|
* @param {any} job
|
|
@@ -102,7 +99,7 @@ exports.gatewayStatus = gatewayStatus;
|
|
|
102
99
|
* @param {string} time_zone
|
|
103
100
|
* @returns {number}
|
|
104
101
|
*/
|
|
105
|
-
function nextCronRunAt(job, after_ms, time_zone) {
|
|
102
|
+
export function nextCronRunAt(job, after_ms, time_zone) {
|
|
106
103
|
const ptr0 = passStringToWasm0(time_zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
107
104
|
const len0 = WASM_VECTOR_LEN;
|
|
108
105
|
const ret = wasm.nextCronRunAt(job, after_ms, ptr0, len0);
|
|
@@ -111,13 +108,12 @@ function nextCronRunAt(job, after_ms, time_zone) {
|
|
|
111
108
|
}
|
|
112
109
|
return ret[0];
|
|
113
110
|
}
|
|
114
|
-
exports.nextCronRunAt = nextCronRunAt;
|
|
115
111
|
|
|
116
112
|
/**
|
|
117
113
|
* @param {string} time_zone
|
|
118
114
|
* @returns {string}
|
|
119
115
|
*/
|
|
120
|
-
function normalizeCronTimeZone(time_zone) {
|
|
116
|
+
export function normalizeCronTimeZone(time_zone) {
|
|
121
117
|
let deferred3_0;
|
|
122
118
|
let deferred3_1;
|
|
123
119
|
try {
|
|
@@ -137,33 +133,30 @@ function normalizeCronTimeZone(time_zone) {
|
|
|
137
133
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
138
134
|
}
|
|
139
135
|
}
|
|
140
|
-
exports.normalizeCronTimeZone = normalizeCronTimeZone;
|
|
141
136
|
|
|
142
137
|
/**
|
|
143
138
|
* @param {any} job
|
|
144
139
|
* @returns {any}
|
|
145
140
|
*/
|
|
146
|
-
function prepareCronExecution(job) {
|
|
141
|
+
export function prepareCronExecution(job) {
|
|
147
142
|
const ret = wasm.prepareCronExecution(job);
|
|
148
143
|
if (ret[2]) {
|
|
149
144
|
throw takeFromExternrefTable0(ret[1]);
|
|
150
145
|
}
|
|
151
146
|
return takeFromExternrefTable0(ret[0]);
|
|
152
147
|
}
|
|
153
|
-
exports.prepareCronExecution = prepareCronExecution;
|
|
154
148
|
|
|
155
149
|
/**
|
|
156
150
|
* @param {any} message
|
|
157
151
|
* @returns {any}
|
|
158
152
|
*/
|
|
159
|
-
function prepareInboundExecution(message) {
|
|
153
|
+
export function prepareInboundExecution(message) {
|
|
160
154
|
const ret = wasm.prepareInboundExecution(message);
|
|
161
155
|
if (ret[2]) {
|
|
162
156
|
throw takeFromExternrefTable0(ret[1]);
|
|
163
157
|
}
|
|
164
158
|
return takeFromExternrefTable0(ret[0]);
|
|
165
159
|
}
|
|
166
|
-
exports.prepareInboundExecution = prepareInboundExecution;
|
|
167
160
|
|
|
168
161
|
function __wbg_get_imports() {
|
|
169
162
|
const import0 = {
|
|
@@ -548,7 +541,15 @@ function takeFromExternrefTable0(idx) {
|
|
|
548
541
|
|
|
549
542
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
550
543
|
cachedTextDecoder.decode();
|
|
544
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
545
|
+
let numBytesDecoded = 0;
|
|
551
546
|
function decodeText(ptr, len) {
|
|
547
|
+
numBytesDecoded += len;
|
|
548
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
549
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
550
|
+
cachedTextDecoder.decode();
|
|
551
|
+
numBytesDecoded = len;
|
|
552
|
+
}
|
|
552
553
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
553
554
|
}
|
|
554
555
|
|
|
@@ -567,8 +568,95 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
567
568
|
|
|
568
569
|
let WASM_VECTOR_LEN = 0;
|
|
569
570
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
571
|
+
let wasmModule, wasm;
|
|
572
|
+
function __wbg_finalize_init(instance, module) {
|
|
573
|
+
wasm = instance.exports;
|
|
574
|
+
wasmModule = module;
|
|
575
|
+
cachedDataViewMemory0 = null;
|
|
576
|
+
cachedUint8ArrayMemory0 = null;
|
|
577
|
+
wasm.__wbindgen_start();
|
|
578
|
+
return wasm;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
async function __wbg_load(module, imports) {
|
|
582
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
583
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
584
|
+
try {
|
|
585
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
586
|
+
} catch (e) {
|
|
587
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
588
|
+
|
|
589
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
590
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
591
|
+
|
|
592
|
+
} else { throw e; }
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
const bytes = await module.arrayBuffer();
|
|
597
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
598
|
+
} else {
|
|
599
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
600
|
+
|
|
601
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
602
|
+
return { instance, module };
|
|
603
|
+
} else {
|
|
604
|
+
return instance;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function expectedResponseType(type) {
|
|
609
|
+
switch (type) {
|
|
610
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
611
|
+
}
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function initSync(module) {
|
|
617
|
+
if (wasm !== undefined) return wasm;
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
if (module !== undefined) {
|
|
621
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
622
|
+
({module} = module)
|
|
623
|
+
} else {
|
|
624
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
const imports = __wbg_get_imports();
|
|
629
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
630
|
+
module = new WebAssembly.Module(module);
|
|
631
|
+
}
|
|
632
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
633
|
+
return __wbg_finalize_init(instance, module);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
async function __wbg_init(module_or_path) {
|
|
637
|
+
if (wasm !== undefined) return wasm;
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
if (module_or_path !== undefined) {
|
|
641
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
642
|
+
({module_or_path} = module_or_path)
|
|
643
|
+
} else {
|
|
644
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if (module_or_path === undefined) {
|
|
649
|
+
module_or_path = new URL('opencode_gateway_ffi_bg.wasm', import.meta.url);
|
|
650
|
+
}
|
|
651
|
+
const imports = __wbg_get_imports();
|
|
652
|
+
|
|
653
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
654
|
+
module_or_path = fetch(module_or_path);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
658
|
+
|
|
659
|
+
return __wbg_finalize_init(instance, module);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export { initSync, __wbg_init as default };
|