@ngosangns/ns-bridge 0.1.29 → 0.1.31
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/cli.js +32 -1
- package/dist/cli.js.map +1 -1
- 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 +45 -6
- package/dist/hosts/omp/dist/index.js +382 -72
- package/dist/hosts/omp/package.json +1 -1
- package/dist/hosts/pi/dist/index.js +194 -72
- package/dist/hosts/pi/package.json +1 -1
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.js +183 -0
- package/dist/plugin.js.map +1 -0
- package/dist/refresh-entry.js +211 -16
- 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.31 — 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";
|
|
@@ -100307,6 +100434,36 @@ function qoderModelInfosFromVendorCatalog(raw, scene) {
|
|
|
100307
100434
|
// ../qoder-core/dist/models-api.js
|
|
100308
100435
|
import { readdirSync as readdirSync2, readFileSync as readFileSync10, statSync as statSync3 } from "node:fs";
|
|
100309
100436
|
import { join as join15 } from "node:path";
|
|
100437
|
+
|
|
100438
|
+
// ../qoder-core/dist/stream.js
|
|
100439
|
+
var QODER_WIRE_VERSION = "1.1.83";
|
|
100440
|
+
var QODER_INFER_ORIGIN = "https://api2.qoder.sh";
|
|
100441
|
+
var ANONYMOUS_SIGNING_IDENTITY = {
|
|
100442
|
+
machineId: "00000000-0000-0000-0000-000000000000",
|
|
100443
|
+
userInfoJson: JSON.stringify({ uid: "", encrypt_user_info: "", key: "" })
|
|
100444
|
+
};
|
|
100445
|
+
function qoderWireUrl(host, endpoint) {
|
|
100446
|
+
const direct = endpoint?.trim();
|
|
100447
|
+
if (direct)
|
|
100448
|
+
return originOf(direct);
|
|
100449
|
+
const override = host?.trim();
|
|
100450
|
+
if (!override)
|
|
100451
|
+
return QODER_INFER_ORIGIN;
|
|
100452
|
+
if (override.startsWith("http://") || override.startsWith("https://"))
|
|
100453
|
+
return originOf(override);
|
|
100454
|
+
return `https://${override}`;
|
|
100455
|
+
}
|
|
100456
|
+
function originOf(value) {
|
|
100457
|
+
try {
|
|
100458
|
+
return new URL(value).origin;
|
|
100459
|
+
} catch {
|
|
100460
|
+
return value;
|
|
100461
|
+
}
|
|
100462
|
+
}
|
|
100463
|
+
var RAW_CONTROL_CHARS = new RegExp("\\p{Cc}", "gu");
|
|
100464
|
+
|
|
100465
|
+
// ../qoder-core/dist/models-api.js
|
|
100466
|
+
var QODER_MODEL_LIST_PATH = "/algo/api/v2/model/list?Encode=1";
|
|
100310
100467
|
function newestCatalogDirectory(root) {
|
|
100311
100468
|
try {
|
|
100312
100469
|
const dirs = readdirSync2(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join15(root, entry.name)).flatMap((dir) => {
|
|
@@ -100361,25 +100518,54 @@ function qoderVendorCatalogFile(configDir) {
|
|
|
100361
100518
|
return void 0;
|
|
100362
100519
|
return { file, uid: dir.slice(root.length + 1), ...scene ? { scene } : {} };
|
|
100363
100520
|
}
|
|
100364
|
-
|
|
100521
|
+
var MODEL_LIST_TIMEOUT_MS = 1e4;
|
|
100522
|
+
async function fetchServerModels(signal) {
|
|
100523
|
+
const identity = readQoderSigningIdentity(qoderConfigDir());
|
|
100524
|
+
if (!identity)
|
|
100525
|
+
throw new QoderAuthError();
|
|
100526
|
+
const signed = signQoderRequest(qoderWireUrl(process.env.QODER_MODEL_SERVER_HOST), QODER_MODEL_LIST_PATH, "GET", "auth", void 0, identity, QODER_WIRE_VERSION);
|
|
100527
|
+
const timeout = AbortSignal.timeout(MODEL_LIST_TIMEOUT_MS);
|
|
100528
|
+
const response = await fetch(signed.url, {
|
|
100529
|
+
method: "GET",
|
|
100530
|
+
headers: signed.headers,
|
|
100531
|
+
signal: signal ? AbortSignal.any([signal, timeout]) : timeout
|
|
100532
|
+
});
|
|
100533
|
+
const text = await response.text();
|
|
100534
|
+
if (response.status === 401 || response.status === 403) {
|
|
100535
|
+
throw new QoderAuthError(`${QODER_LOGIN_MESSAGE} (HTTP ${response.status}: ${text.slice(0, 200)})`);
|
|
100536
|
+
}
|
|
100537
|
+
if (!response.ok)
|
|
100538
|
+
throw new QoderApiError(`models.list failed: HTTP ${response.status}: ${text.slice(0, 200)}`);
|
|
100539
|
+
const infos = qoderModelInfosFromVendorCatalog(text);
|
|
100540
|
+
if (infos.length === 0)
|
|
100541
|
+
throw new QoderApiError("models.list returned no models for the assistant scene");
|
|
100542
|
+
return qoderModelsFromModelInfos(infos);
|
|
100543
|
+
}
|
|
100544
|
+
function readLocalCatalog() {
|
|
100545
|
+
const target = qoderVendorCatalogFile(qoderConfigDir());
|
|
100546
|
+
if (!target)
|
|
100547
|
+
return void 0;
|
|
100548
|
+
const plain = decryptQoderModelCache(readFileSync10(target.file, "utf8"), target.uid);
|
|
100549
|
+
return qoderModelsFromModelInfos(qoderModelInfosFromVendorCatalog(plain, target.scene));
|
|
100550
|
+
}
|
|
100551
|
+
async function fetchQoderModels(options = {}) {
|
|
100552
|
+
let error;
|
|
100365
100553
|
try {
|
|
100366
|
-
|
|
100367
|
-
|
|
100368
|
-
|
|
100369
|
-
|
|
100370
|
-
|
|
100554
|
+
return { models: await fetchServerModels(options.signal), source: "server" };
|
|
100555
|
+
} catch (err) {
|
|
100556
|
+
if (options.signal?.aborted)
|
|
100557
|
+
throw err;
|
|
100558
|
+
error = err instanceof Error ? err.message : String(err);
|
|
100559
|
+
}
|
|
100560
|
+
try {
|
|
100561
|
+
const models = readLocalCatalog();
|
|
100562
|
+
if (models)
|
|
100563
|
+
return { models, source: "catalog", error };
|
|
100371
100564
|
} catch {
|
|
100372
|
-
return qoderBootstrapModels();
|
|
100373
100565
|
}
|
|
100566
|
+
return { models: qoderBootstrapModels(), source: "bootstrap", error };
|
|
100374
100567
|
}
|
|
100375
100568
|
|
|
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
100569
|
// ../pi-provider/src/qoder/register.ts
|
|
100384
100570
|
var QODER_PROVIDER_ID = "qoder";
|
|
100385
100571
|
var QODER_API = "qoder-cli";
|
|
@@ -100454,7 +100640,16 @@ async function refreshQoderModels(options = {}) {
|
|
|
100454
100640
|
error: "no Qoder auth: run `qodercli login` or set QODER_PERSONAL_ACCESS_TOKEN"
|
|
100455
100641
|
};
|
|
100456
100642
|
}
|
|
100457
|
-
const
|
|
100643
|
+
const list = await fetchQoderModels();
|
|
100644
|
+
const catalog = specsToCatalog2(list.models);
|
|
100645
|
+
if (list.source !== "server") {
|
|
100646
|
+
return {
|
|
100647
|
+
models: catalogToProviderModels3(catalog),
|
|
100648
|
+
fromCache: false,
|
|
100649
|
+
source: "fallback",
|
|
100650
|
+
error: `model server unavailable (${list.error ?? "unknown error"}); showing ${list.source} list`
|
|
100651
|
+
};
|
|
100652
|
+
}
|
|
100458
100653
|
cache.store(QODER_PROVIDER_ID, catalog, { version: "qoder-cli-v1" });
|
|
100459
100654
|
return { models: catalogToProviderModels3(catalog), fromCache: false, source: "live" };
|
|
100460
100655
|
} catch (err) {
|
package/dist/serve-entry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ngosangns/ns-bridge 0.1.
|
|
1
|
+
// @ngosangns/ns-bridge 0.1.31 — 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;
|