@ngosangns/ns-bridge 0.1.30 → 0.1.32
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/hosts/dsh/arnict/dist/index.js +1 -1
- package/dist/hosts/dsh/devin/dist/index.js +1 -1
- package/dist/hosts/dsh/grok/dist/index.js +1 -1
- package/dist/hosts/dsh/kiro/dist/index.js +1 -1
- package/dist/hosts/dsh/qoder/dist/index.js +28 -52
- package/dist/hosts/omp/dist/index.js +394 -171
- package/dist/hosts/omp/package.json +1 -1
- package/dist/hosts/pi/dist/index.js +233 -147
- package/dist/hosts/pi/package.json +1 -1
- package/dist/refresh-entry.js +213 -20
- package/dist/serve-entry.js +1 -1
- package/package.json +1 -1
package/dist/refresh-entry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ngosangns/ns-bridge 0.1.
|
|
1
|
+
// @ngosangns/ns-bridge 0.1.32 — bundled entries (catalog refresh, serve).
|
|
2
2
|
import { createRequire as __nsBridgeCreateRequire } from 'node:module';
|
|
3
3
|
const require = __nsBridgeCreateRequire(import.meta.url);
|
|
4
4
|
var __create = Object.create;
|
|
@@ -99896,6 +99896,23 @@ import { existsSync as existsSync7, readdirSync } from "node:fs";
|
|
|
99896
99896
|
import { homedir as homedir13 } from "node:os";
|
|
99897
99897
|
import { join as join14 } from "node:path";
|
|
99898
99898
|
|
|
99899
|
+
// ../qoder-core/dist/errors.js
|
|
99900
|
+
var QODER_LOGIN_MESSAGE = "No Qoder session found. Run `qodercli login`, or set QODER_PERSONAL_ACCESS_TOKEN.";
|
|
99901
|
+
var QoderAuthError = class extends Error {
|
|
99902
|
+
constructor(message = QODER_LOGIN_MESSAGE) {
|
|
99903
|
+
super(message);
|
|
99904
|
+
this.name = "QoderAuthError";
|
|
99905
|
+
}
|
|
99906
|
+
};
|
|
99907
|
+
var QoderApiError = class extends Error {
|
|
99908
|
+
code;
|
|
99909
|
+
constructor(message, code) {
|
|
99910
|
+
super(message);
|
|
99911
|
+
this.name = "QoderApiError";
|
|
99912
|
+
this.code = code;
|
|
99913
|
+
}
|
|
99914
|
+
};
|
|
99915
|
+
|
|
99899
99916
|
// ../qoder-core/dist/store.js
|
|
99900
99917
|
import { existsSync as existsSync6, readFileSync as readFileSync9 } from "node:fs";
|
|
99901
99918
|
import { createRequire as createRequire4 } from "node:module";
|
|
@@ -100040,6 +100057,7 @@ function loadExports() {
|
|
|
100040
100057
|
"model_cache_decrypt",
|
|
100041
100058
|
"qodercontext_new",
|
|
100042
100059
|
"qodercontext_prepareInferRequest",
|
|
100060
|
+
"qodercontext_prepareRequest",
|
|
100043
100061
|
"requestresult_url",
|
|
100044
100062
|
"requestresult_body",
|
|
100045
100063
|
"requestresult_headers",
|
|
@@ -100096,12 +100114,100 @@ function decryptQoderStore(encrypted, key) {
|
|
|
100096
100114
|
function decryptQoderModelCache(encrypted, uid) {
|
|
100097
100115
|
return callStringString(loadExports(), loadExports().model_cache_decrypt, encrypted, uid);
|
|
100098
100116
|
}
|
|
100117
|
+
var SIGNING_USER_FIELDS = [
|
|
100118
|
+
"uid",
|
|
100119
|
+
"encrypt_user_info",
|
|
100120
|
+
"key",
|
|
100121
|
+
"organization_id",
|
|
100122
|
+
"organization_tags",
|
|
100123
|
+
"data_policy_agreed"
|
|
100124
|
+
];
|
|
100099
100125
|
var QODER_SIGNING_EXTRAS = JSON.stringify({
|
|
100100
100126
|
client_type: "5",
|
|
100101
100127
|
business_product: "cli",
|
|
100102
100128
|
business_type: "agent",
|
|
100103
100129
|
scene: "assistant"
|
|
100104
100130
|
});
|
|
100131
|
+
function wasmResultString(exports, fn, handle) {
|
|
100132
|
+
const retptr = exports.__wbindgen_add_to_stack_pointer(-16);
|
|
100133
|
+
let ptr = 0;
|
|
100134
|
+
let len = 0;
|
|
100135
|
+
try {
|
|
100136
|
+
fn(retptr, handle);
|
|
100137
|
+
const view = new Int32Array(exports.memory.buffer, retptr, 4);
|
|
100138
|
+
ptr = view[0] ?? 0;
|
|
100139
|
+
len = view[1] ?? 0;
|
|
100140
|
+
if (ptr === 0)
|
|
100141
|
+
return void 0;
|
|
100142
|
+
return DECODER.decode(new Uint8Array(exports.memory.buffer, ptr, len));
|
|
100143
|
+
} finally {
|
|
100144
|
+
if (ptr !== 0)
|
|
100145
|
+
exports.__wbindgen_export4(ptr, len, 1);
|
|
100146
|
+
exports.__wbindgen_add_to_stack_pointer(16);
|
|
100147
|
+
}
|
|
100148
|
+
}
|
|
100149
|
+
function callContextNew(exports, identity, cosyVersion) {
|
|
100150
|
+
const retptr = exports.__wbindgen_add_to_stack_pointer(-16);
|
|
100151
|
+
try {
|
|
100152
|
+
const [machinePtr, machineLen] = passStringToWasm(exports, identity.machineId);
|
|
100153
|
+
const [versionPtr, versionLen] = passStringToWasm(exports, cosyVersion);
|
|
100154
|
+
const [userPtr, userLen] = passStringToWasm(exports, identity.userInfoJson);
|
|
100155
|
+
const [extraPtr, extraLen] = passStringToWasm(exports, QODER_SIGNING_EXTRAS);
|
|
100156
|
+
exports.qodercontext_new(retptr, machinePtr, machineLen, versionPtr, versionLen, userPtr, userLen, extraPtr, extraLen);
|
|
100157
|
+
const view = new Int32Array(exports.memory.buffer, retptr, 4);
|
|
100158
|
+
if ((view[2] ?? 0) !== 0)
|
|
100159
|
+
throw takeObject(view[1] ?? 0);
|
|
100160
|
+
return (view[0] ?? 0) >>> 0;
|
|
100161
|
+
} finally {
|
|
100162
|
+
exports.__wbindgen_add_to_stack_pointer(16);
|
|
100163
|
+
}
|
|
100164
|
+
}
|
|
100165
|
+
function signatureHeaders(exports, result) {
|
|
100166
|
+
const headers = {};
|
|
100167
|
+
const value = takeObject(exports.requestresult_headers(result));
|
|
100168
|
+
if (!value || typeof value.forEach !== "function") {
|
|
100169
|
+
throw new Error("qoder infer signer returned invalid headers");
|
|
100170
|
+
}
|
|
100171
|
+
value.forEach((headerValue2, name) => {
|
|
100172
|
+
headers[String(name)] = String(headerValue2);
|
|
100173
|
+
});
|
|
100174
|
+
return headers;
|
|
100175
|
+
}
|
|
100176
|
+
function callPrepareRequest(exports, ctx, endpoint, path6, method, authType, body) {
|
|
100177
|
+
const retptr = exports.__wbindgen_add_to_stack_pointer(-16);
|
|
100178
|
+
try {
|
|
100179
|
+
const [endpointPtr, endpointLen] = passStringToWasm(exports, endpoint);
|
|
100180
|
+
const [pathPtr, pathLen] = passStringToWasm(exports, path6);
|
|
100181
|
+
const [methodPtr, methodLen] = passStringToWasm(exports, method);
|
|
100182
|
+
const [authPtr, authLen] = passStringToWasm(exports, authType);
|
|
100183
|
+
const [bodyPtr, bodyLen] = body === void 0 ? [0, 0] : passStringToWasm(exports, body);
|
|
100184
|
+
exports.qodercontext_prepareRequest(retptr, ctx, endpointPtr, endpointLen, pathPtr, pathLen, methodPtr, methodLen, authPtr, authLen, bodyPtr, bodyLen, 0, 0);
|
|
100185
|
+
const view = new Int32Array(exports.memory.buffer, retptr, 4);
|
|
100186
|
+
if ((view[2] ?? 0) !== 0)
|
|
100187
|
+
throw takeObject(view[1] ?? 0);
|
|
100188
|
+
return (view[0] ?? 0) >>> 0;
|
|
100189
|
+
} finally {
|
|
100190
|
+
exports.__wbindgen_add_to_stack_pointer(16);
|
|
100191
|
+
}
|
|
100192
|
+
}
|
|
100193
|
+
function signQoderRequest(endpoint, path6, method, authType, body, identity, cosyVersion) {
|
|
100194
|
+
const exports = loadExports();
|
|
100195
|
+
const ctx = callContextNew(exports, identity, cosyVersion);
|
|
100196
|
+
try {
|
|
100197
|
+
const result = callPrepareRequest(exports, ctx, endpoint, path6, method, authType, body);
|
|
100198
|
+
try {
|
|
100199
|
+
const url = wasmResultString(exports, exports.requestresult_url, result);
|
|
100200
|
+
if (!url)
|
|
100201
|
+
throw new Error("qoder request signer returned an empty url");
|
|
100202
|
+
const signedBody = wasmResultString(exports, exports.requestresult_body, result);
|
|
100203
|
+
return { url, headers: signatureHeaders(exports, result), body: signedBody ?? "" };
|
|
100204
|
+
} finally {
|
|
100205
|
+
exports.__wbg_requestresult_free(result, 0);
|
|
100206
|
+
}
|
|
100207
|
+
} finally {
|
|
100208
|
+
exports.__wbg_qodercontext_free(ctx, 0);
|
|
100209
|
+
}
|
|
100210
|
+
}
|
|
100105
100211
|
function storedString(record, field) {
|
|
100106
100212
|
const value = record[field];
|
|
100107
100213
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
@@ -100132,6 +100238,27 @@ function readQoderStore(configDir) {
|
|
|
100132
100238
|
...storedString(record, "email") ? { email: storedString(record, "email") } : {}
|
|
100133
100239
|
};
|
|
100134
100240
|
}
|
|
100241
|
+
function readQoderSigningIdentity(configDir) {
|
|
100242
|
+
try {
|
|
100243
|
+
const { machineId, record } = readStoreRecord(configDir);
|
|
100244
|
+
if (!machineId)
|
|
100245
|
+
return void 0;
|
|
100246
|
+
const userInfo = {};
|
|
100247
|
+
for (const field of SIGNING_USER_FIELDS) {
|
|
100248
|
+
if (record[field] !== void 0)
|
|
100249
|
+
userInfo[field] = record[field];
|
|
100250
|
+
}
|
|
100251
|
+
if (typeof userInfo.uid !== "string")
|
|
100252
|
+
userInfo.uid = "";
|
|
100253
|
+
if (typeof userInfo.encrypt_user_info !== "string")
|
|
100254
|
+
userInfo.encrypt_user_info = "";
|
|
100255
|
+
if (typeof userInfo.key !== "string")
|
|
100256
|
+
userInfo.key = "";
|
|
100257
|
+
return { machineId, userInfoJson: JSON.stringify(userInfo) };
|
|
100258
|
+
} catch {
|
|
100259
|
+
return void 0;
|
|
100260
|
+
}
|
|
100261
|
+
}
|
|
100135
100262
|
|
|
100136
100263
|
// ../qoder-core/dist/auth.js
|
|
100137
100264
|
var QODER_PAT_ENV = "QODER_PERSONAL_ACCESS_TOKEN";
|
|
@@ -100173,9 +100300,7 @@ function resolveQoderAuth(env3 = process.env, home = homedir13()) {
|
|
|
100173
100300
|
var QODER_CATALOG_PROVIDER_ID = "qoder";
|
|
100174
100301
|
var QODER_CATALOG_FILE = `${QODER_CATALOG_PROVIDER_ID}.models.json`;
|
|
100175
100302
|
var QODER_DEFAULT_MAX_TOKENS = 16384;
|
|
100176
|
-
var
|
|
100177
|
-
var QODER_WIRE_CONTEXT_WINDOW = QODER_WIRE_BODY_LIMIT_BYTES / 4;
|
|
100178
|
-
var QODER_DEFAULT_CONTEXT_WINDOW = QODER_WIRE_CONTEXT_WINDOW;
|
|
100303
|
+
var QODER_DEFAULT_CONTEXT_WINDOW = 2e5;
|
|
100179
100304
|
var BOOTSTRAP_IDS = [
|
|
100180
100305
|
"auto",
|
|
100181
100306
|
"ultimate",
|
|
@@ -100239,7 +100364,7 @@ function qoderModelFromInfo(info) {
|
|
|
100239
100364
|
name: info.displayName ?? QODER_MODEL_DISPLAY_NAMES[info.value] ?? info.value,
|
|
100240
100365
|
reasoning: info.isReasoning === true || efforts.length > 0,
|
|
100241
100366
|
input: info.isVl === true ? ["text", "image"] : ["text"],
|
|
100242
|
-
contextWindow:
|
|
100367
|
+
contextWindow: declared,
|
|
100243
100368
|
maxTokens: positive(info.maxOutputTokens) ? info.maxOutputTokens : QODER_DEFAULT_MAX_TOKENS,
|
|
100244
100369
|
...efforts.length > 0 ? { efforts } : {}
|
|
100245
100370
|
};
|
|
@@ -100307,6 +100432,36 @@ function qoderModelInfosFromVendorCatalog(raw, scene) {
|
|
|
100307
100432
|
// ../qoder-core/dist/models-api.js
|
|
100308
100433
|
import { readdirSync as readdirSync2, readFileSync as readFileSync10, statSync as statSync3 } from "node:fs";
|
|
100309
100434
|
import { join as join15 } from "node:path";
|
|
100435
|
+
|
|
100436
|
+
// ../qoder-core/dist/stream.js
|
|
100437
|
+
var QODER_WIRE_VERSION = "1.1.83";
|
|
100438
|
+
var QODER_INFER_ORIGIN = "https://api2.qoder.sh";
|
|
100439
|
+
var ANONYMOUS_SIGNING_IDENTITY = {
|
|
100440
|
+
machineId: "00000000-0000-0000-0000-000000000000",
|
|
100441
|
+
userInfoJson: JSON.stringify({ uid: "", encrypt_user_info: "", key: "" })
|
|
100442
|
+
};
|
|
100443
|
+
function qoderWireUrl(host, endpoint) {
|
|
100444
|
+
const direct = endpoint?.trim();
|
|
100445
|
+
if (direct)
|
|
100446
|
+
return originOf(direct);
|
|
100447
|
+
const override = host?.trim();
|
|
100448
|
+
if (!override)
|
|
100449
|
+
return QODER_INFER_ORIGIN;
|
|
100450
|
+
if (override.startsWith("http://") || override.startsWith("https://"))
|
|
100451
|
+
return originOf(override);
|
|
100452
|
+
return `https://${override}`;
|
|
100453
|
+
}
|
|
100454
|
+
function originOf(value) {
|
|
100455
|
+
try {
|
|
100456
|
+
return new URL(value).origin;
|
|
100457
|
+
} catch {
|
|
100458
|
+
return value;
|
|
100459
|
+
}
|
|
100460
|
+
}
|
|
100461
|
+
var RAW_CONTROL_CHARS = new RegExp("\\p{Cc}", "gu");
|
|
100462
|
+
|
|
100463
|
+
// ../qoder-core/dist/models-api.js
|
|
100464
|
+
var QODER_MODEL_LIST_PATH = "/algo/api/v2/model/list?Encode=1";
|
|
100310
100465
|
function newestCatalogDirectory(root) {
|
|
100311
100466
|
try {
|
|
100312
100467
|
const dirs = readdirSync2(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join15(root, entry.name)).flatMap((dir) => {
|
|
@@ -100361,25 +100516,54 @@ function qoderVendorCatalogFile(configDir) {
|
|
|
100361
100516
|
return void 0;
|
|
100362
100517
|
return { file, uid: dir.slice(root.length + 1), ...scene ? { scene } : {} };
|
|
100363
100518
|
}
|
|
100364
|
-
|
|
100519
|
+
var MODEL_LIST_TIMEOUT_MS = 1e4;
|
|
100520
|
+
async function fetchServerModels(signal) {
|
|
100521
|
+
const identity = readQoderSigningIdentity(qoderConfigDir());
|
|
100522
|
+
if (!identity)
|
|
100523
|
+
throw new QoderAuthError();
|
|
100524
|
+
const signed = signQoderRequest(qoderWireUrl(process.env.QODER_MODEL_SERVER_HOST), QODER_MODEL_LIST_PATH, "GET", "auth", void 0, identity, QODER_WIRE_VERSION);
|
|
100525
|
+
const timeout = AbortSignal.timeout(MODEL_LIST_TIMEOUT_MS);
|
|
100526
|
+
const response = await fetch(signed.url, {
|
|
100527
|
+
method: "GET",
|
|
100528
|
+
headers: signed.headers,
|
|
100529
|
+
signal: signal ? AbortSignal.any([signal, timeout]) : timeout
|
|
100530
|
+
});
|
|
100531
|
+
const text = await response.text();
|
|
100532
|
+
if (response.status === 401 || response.status === 403) {
|
|
100533
|
+
throw new QoderAuthError(`${QODER_LOGIN_MESSAGE} (HTTP ${response.status}: ${text.slice(0, 200)})`);
|
|
100534
|
+
}
|
|
100535
|
+
if (!response.ok)
|
|
100536
|
+
throw new QoderApiError(`models.list failed: HTTP ${response.status}: ${text.slice(0, 200)}`);
|
|
100537
|
+
const infos = qoderModelInfosFromVendorCatalog(text);
|
|
100538
|
+
if (infos.length === 0)
|
|
100539
|
+
throw new QoderApiError("models.list returned no models for the assistant scene");
|
|
100540
|
+
return qoderModelsFromModelInfos(infos);
|
|
100541
|
+
}
|
|
100542
|
+
function readLocalCatalog() {
|
|
100543
|
+
const target = qoderVendorCatalogFile(qoderConfigDir());
|
|
100544
|
+
if (!target)
|
|
100545
|
+
return void 0;
|
|
100546
|
+
const plain = decryptQoderModelCache(readFileSync10(target.file, "utf8"), target.uid);
|
|
100547
|
+
return qoderModelsFromModelInfos(qoderModelInfosFromVendorCatalog(plain, target.scene));
|
|
100548
|
+
}
|
|
100549
|
+
async function fetchQoderModels(options = {}) {
|
|
100550
|
+
let error;
|
|
100365
100551
|
try {
|
|
100366
|
-
|
|
100367
|
-
|
|
100368
|
-
|
|
100369
|
-
|
|
100370
|
-
|
|
100552
|
+
return { models: await fetchServerModels(options.signal), source: "server" };
|
|
100553
|
+
} catch (err) {
|
|
100554
|
+
if (options.signal?.aborted)
|
|
100555
|
+
throw err;
|
|
100556
|
+
error = err instanceof Error ? err.message : String(err);
|
|
100557
|
+
}
|
|
100558
|
+
try {
|
|
100559
|
+
const models = readLocalCatalog();
|
|
100560
|
+
if (models)
|
|
100561
|
+
return { models, source: "catalog", error };
|
|
100371
100562
|
} catch {
|
|
100372
|
-
return qoderBootstrapModels();
|
|
100373
100563
|
}
|
|
100564
|
+
return { models: qoderBootstrapModels(), source: "bootstrap", error };
|
|
100374
100565
|
}
|
|
100375
100566
|
|
|
100376
|
-
// ../qoder-core/dist/stream.js
|
|
100377
|
-
var ANONYMOUS_SIGNING_IDENTITY = {
|
|
100378
|
-
machineId: "00000000-0000-0000-0000-000000000000",
|
|
100379
|
-
userInfoJson: JSON.stringify({ uid: "", encrypt_user_info: "", key: "" })
|
|
100380
|
-
};
|
|
100381
|
-
var RAW_CONTROL_CHARS = new RegExp("\\p{Cc}", "gu");
|
|
100382
|
-
|
|
100383
100567
|
// ../pi-provider/src/qoder/register.ts
|
|
100384
100568
|
var QODER_PROVIDER_ID = "qoder";
|
|
100385
100569
|
var QODER_API = "qoder-cli";
|
|
@@ -100454,7 +100638,16 @@ async function refreshQoderModels(options = {}) {
|
|
|
100454
100638
|
error: "no Qoder auth: run `qodercli login` or set QODER_PERSONAL_ACCESS_TOKEN"
|
|
100455
100639
|
};
|
|
100456
100640
|
}
|
|
100457
|
-
const
|
|
100641
|
+
const list = await fetchQoderModels();
|
|
100642
|
+
const catalog = specsToCatalog2(list.models);
|
|
100643
|
+
if (list.source !== "server") {
|
|
100644
|
+
return {
|
|
100645
|
+
models: catalogToProviderModels3(catalog),
|
|
100646
|
+
fromCache: false,
|
|
100647
|
+
source: "fallback",
|
|
100648
|
+
error: `model server unavailable (${list.error ?? "unknown error"}); showing ${list.source} list`
|
|
100649
|
+
};
|
|
100650
|
+
}
|
|
100458
100651
|
cache.store(QODER_PROVIDER_ID, catalog, { version: "qoder-cli-v1" });
|
|
100459
100652
|
return { models: catalogToProviderModels3(catalog), fromCache: false, source: "live" };
|
|
100460
100653
|
} catch (err) {
|
package/dist/serve-entry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ngosangns/ns-bridge 0.1.
|
|
1
|
+
// @ngosangns/ns-bridge 0.1.32 — bundled entries (catalog refresh, serve).
|
|
2
2
|
import { createRequire as __nsBridgeCreateRequire } from 'node:module';
|
|
3
3
|
const require = __nsBridgeCreateRequire(import.meta.url);
|
|
4
4
|
var __defProp = Object.defineProperty;
|