@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ngosangns/ns-bridge 0.1.
|
|
1
|
+
// @ngosangns/ns-bridge 0.1.32 — prebuilt host bundle.
|
|
2
2
|
import { createRequire as __nsBridgeCreateRequire } from 'node:module';
|
|
3
3
|
const require = __nsBridgeCreateRequire(import.meta.url);
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -4727,13 +4727,12 @@ function createProviderConfig(models) {
|
|
|
4727
4727
|
api: ARNICT_API,
|
|
4728
4728
|
models,
|
|
4729
4729
|
streamSimple: streamArnictForPi,
|
|
4730
|
-
// OMP
|
|
4731
|
-
//
|
|
4732
|
-
//
|
|
4733
|
-
// null here and do not become that authoritative list.
|
|
4730
|
+
// OMP 19.1.1 reads `.length` on this return, so null throws during discovery.
|
|
4731
|
+
// A disk snapshot, fresh or past the 15-minute TTL, is a real catalog. The
|
|
4732
|
+
// bootstrap list stays null so it is not pinned as authoritative for 24h.
|
|
4734
4733
|
fetchDynamicModels: async () => {
|
|
4735
4734
|
const latest = await refreshArnictModels({ allowNetwork: false });
|
|
4736
|
-
if (
|
|
4735
|
+
if (latest.source !== "cache" || latest.models.length === 0) return null;
|
|
4737
4736
|
return latest.models;
|
|
4738
4737
|
},
|
|
4739
4738
|
async refreshModels() {
|
|
@@ -5454,7 +5453,6 @@ init_endpoints();
|
|
|
5454
5453
|
var KIRO_MANAGEMENT_CACHE_VERSION = 1;
|
|
5455
5454
|
var KIRO_MANAGEMENT_CACHE_SOURCE = "ns-kiro-provider-management";
|
|
5456
5455
|
var KIRO_MANAGEMENT_CACHE_PATH = join8(homedir8(), ".ns-kiro-provider-models-cache.json");
|
|
5457
|
-
var CACHE_MAX_AGE_MS = 36e5;
|
|
5458
5456
|
var ZERO_COST = Object.freeze({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
5459
5457
|
var bootstrapKiroModels = [
|
|
5460
5458
|
{
|
|
@@ -5743,6 +5741,11 @@ function allCacheEntries(cache) {
|
|
|
5743
5741
|
function kiroProfileCacheKey(profileArn) {
|
|
5744
5742
|
return createHash2("sha256").update(profileArn).digest("base64url").slice(0, 16);
|
|
5745
5743
|
}
|
|
5744
|
+
function hasCachedKiroCatalog(region) {
|
|
5745
|
+
const cache = readManagementCache();
|
|
5746
|
+
const models = activeCacheEntry(cache, region)?.models ?? cache?.regions[region]?.models;
|
|
5747
|
+
return Array.isArray(models) && models.length > 0;
|
|
5748
|
+
}
|
|
5746
5749
|
function activeCacheEntry(cache, region) {
|
|
5747
5750
|
const override = getKiroProfileOverride();
|
|
5748
5751
|
return override ? cache?.profiles?.[kiroProfileCacheKey(override.arn)] : cache?.regions[region];
|
|
@@ -5809,10 +5812,6 @@ function getCachedModels(region) {
|
|
|
5809
5812
|
});
|
|
5810
5813
|
return changed ? corrected : models;
|
|
5811
5814
|
}
|
|
5812
|
-
function isCacheStale(region) {
|
|
5813
|
-
const entry = activeCacheEntry(readManagementCache(), region);
|
|
5814
|
-
return !entry || Date.now() - entry.fetchedAt > CACHE_MAX_AGE_MS;
|
|
5815
|
-
}
|
|
5816
5815
|
function resolveKiroModel(modelId, exactKiroModelId) {
|
|
5817
5816
|
if (exactKiroModelId)
|
|
5818
5817
|
return exactKiroModelId;
|
|
@@ -8306,11 +8305,36 @@ ${systemPrompt}` : ""}`;
|
|
|
8306
8305
|
init_endpoints();
|
|
8307
8306
|
init_management();
|
|
8308
8307
|
var MANAGE_USAGE_URL = "https://app.kiro.dev/account/usage";
|
|
8309
|
-
function
|
|
8308
|
+
function toEpochMs(value) {
|
|
8310
8309
|
if (value === void 0 || value === null)
|
|
8311
8310
|
return void 0;
|
|
8312
|
-
const
|
|
8313
|
-
return Number.isNaN(
|
|
8311
|
+
const ms = typeof value === "number" ? value * 1e3 : Date.parse(value);
|
|
8312
|
+
return Number.isNaN(ms) ? void 0 : ms;
|
|
8313
|
+
}
|
|
8314
|
+
function toIsoDate(ms) {
|
|
8315
|
+
if (ms === void 0)
|
|
8316
|
+
return void 0;
|
|
8317
|
+
return new Date(ms).toISOString();
|
|
8318
|
+
}
|
|
8319
|
+
function toUsageUnit(unit, resourceType) {
|
|
8320
|
+
const named = unit?.toLowerCase();
|
|
8321
|
+
if (resourceType?.toLowerCase() === "credit" && (named === void 0 || named === "invocations"))
|
|
8322
|
+
return "credits";
|
|
8323
|
+
switch (named) {
|
|
8324
|
+
case "credit":
|
|
8325
|
+
case "credits":
|
|
8326
|
+
return "credits";
|
|
8327
|
+
case "request":
|
|
8328
|
+
case "requests":
|
|
8329
|
+
return "requests";
|
|
8330
|
+
case "token":
|
|
8331
|
+
case "tokens":
|
|
8332
|
+
return "tokens";
|
|
8333
|
+
case "usd":
|
|
8334
|
+
return "usd";
|
|
8335
|
+
default:
|
|
8336
|
+
return "unknown";
|
|
8337
|
+
}
|
|
8314
8338
|
}
|
|
8315
8339
|
function formatCount(value) {
|
|
8316
8340
|
if (value === void 0 || Number.isNaN(value))
|
|
@@ -8333,6 +8357,7 @@ function mapBucket(bucket, index) {
|
|
|
8333
8357
|
const overages = bucket.currentOveragesWithPrecision ?? bucket.currentOverages;
|
|
8334
8358
|
const freeTrialUsed = bucket.freeTrialInfo?.currentUsageWithPrecision ?? bucket.freeTrialInfo?.currentUsage;
|
|
8335
8359
|
const freeTrialLimit = bucket.freeTrialInfo?.usageLimitWithPrecision ?? bucket.freeTrialInfo?.usageLimit;
|
|
8360
|
+
const resetAtMs = toEpochMs(bucket.nextDateReset);
|
|
8336
8361
|
return {
|
|
8337
8362
|
id: bucket.resourceType || bucket.displayName || `usage-${index}`,
|
|
8338
8363
|
label: bucket.displayName || bucket.displayNamePlural || bucket.resourceType || "Usage",
|
|
@@ -8343,14 +8368,16 @@ function mapBucket(bucket, index) {
|
|
|
8343
8368
|
usedDisplay: formatCount(used) || "0",
|
|
8344
8369
|
limitDisplay: formatCount(limit),
|
|
8345
8370
|
unit: bucket.unit,
|
|
8371
|
+
unitKind: toUsageUnit(bucket.unit, bucket.resourceType),
|
|
8346
8372
|
overagesDisplay: overages && overages > 0 ? formatCount(overages) : void 0,
|
|
8347
8373
|
overageChargesDisplay: formatMoney(bucket.overageCharges, bucket.currency),
|
|
8348
|
-
resetAt: toIsoDate(
|
|
8374
|
+
resetAt: toIsoDate(resetAtMs),
|
|
8375
|
+
resetAtMs,
|
|
8349
8376
|
bonus: freeTrialUsed !== void 0 || freeTrialLimit !== void 0 || bucket.freeTrialInfo?.freeTrialExpiry !== void 0 ? {
|
|
8350
8377
|
label: "Bonus credits",
|
|
8351
8378
|
usedDisplay: formatCount(freeTrialUsed),
|
|
8352
8379
|
limitDisplay: formatCount(freeTrialLimit),
|
|
8353
|
-
expiresAt: toIsoDate(bucket.freeTrialInfo?.freeTrialExpiry)
|
|
8380
|
+
expiresAt: toIsoDate(toEpochMs(bucket.freeTrialInfo?.freeTrialExpiry))
|
|
8354
8381
|
} : void 0
|
|
8355
8382
|
};
|
|
8356
8383
|
}
|
|
@@ -8367,10 +8394,12 @@ async function fetchKiroUsage(credentials) {
|
|
|
8367
8394
|
const auth = { accessToken: credentials.access, region: resolveApiRegion(credentials.region) };
|
|
8368
8395
|
const raw = await fetchRawUsage(auth, credentials.profileArn);
|
|
8369
8396
|
const usageBuckets = raw.usageBreakdownList?.length ? raw.usageBreakdownList.map(mapBucket) : raw.usageBreakdown ? [mapBucket(raw.usageBreakdown, 0)] : [];
|
|
8397
|
+
const resetAtMs = toEpochMs(raw.nextDateReset);
|
|
8370
8398
|
return {
|
|
8371
8399
|
summary: raw.subscriptionInfo?.subscriptionTitle,
|
|
8372
8400
|
subscriptionTitle: raw.subscriptionInfo?.subscriptionTitle,
|
|
8373
|
-
resetAt: toIsoDate(
|
|
8401
|
+
resetAt: toIsoDate(resetAtMs),
|
|
8402
|
+
resetAtMs,
|
|
8374
8403
|
daysUntilReset: raw.daysUntilReset,
|
|
8375
8404
|
overageStatus: raw.overageConfiguration?.overageStatus,
|
|
8376
8405
|
manageUrl: MANAGE_USAGE_URL,
|
|
@@ -8448,13 +8477,12 @@ ${current.models.map((model) => model.id).join("\n")}`;
|
|
|
8448
8477
|
authHeader: false,
|
|
8449
8478
|
streamSimple: streamKiroForPi,
|
|
8450
8479
|
models: current.models,
|
|
8451
|
-
// OMP
|
|
8452
|
-
//
|
|
8453
|
-
//
|
|
8454
|
-
// in place and does not lock a stale catalog.
|
|
8480
|
+
// OMP 19.1.1 reads `.length` on this return, so null throws during discovery.
|
|
8481
|
+
// A disk catalog is returned even past the 1h TTL. No disk entry stays null
|
|
8482
|
+
// so the bootstrap list is not pinned as authoritative for 24h.
|
|
8455
8483
|
fetchDynamicModels: async () => {
|
|
8456
8484
|
const latest = localKiroCatalog();
|
|
8457
|
-
if (latest.models.length === 0 ||
|
|
8485
|
+
if (latest.models.length === 0 || !hasCachedKiroCatalog(latest.region)) return null;
|
|
8458
8486
|
return latest.models;
|
|
8459
8487
|
},
|
|
8460
8488
|
async refreshModels() {
|
|
@@ -8652,6 +8680,7 @@ function loadExports() {
|
|
|
8652
8680
|
"model_cache_decrypt",
|
|
8653
8681
|
"qodercontext_new",
|
|
8654
8682
|
"qodercontext_prepareInferRequest",
|
|
8683
|
+
"qodercontext_prepareRequest",
|
|
8655
8684
|
"requestresult_url",
|
|
8656
8685
|
"requestresult_body",
|
|
8657
8686
|
"requestresult_headers",
|
|
@@ -8801,6 +8830,41 @@ function signQoderInferRequest(endpoint, bodyJson, modelKey, modelSource, identi
|
|
|
8801
8830
|
exports.__wbg_qodercontext_free(ctx, 0);
|
|
8802
8831
|
}
|
|
8803
8832
|
}
|
|
8833
|
+
function callPrepareRequest(exports, ctx, endpoint, path, method, authType, body) {
|
|
8834
|
+
const retptr = exports.__wbindgen_add_to_stack_pointer(-16);
|
|
8835
|
+
try {
|
|
8836
|
+
const [endpointPtr, endpointLen] = passStringToWasm(exports, endpoint);
|
|
8837
|
+
const [pathPtr, pathLen] = passStringToWasm(exports, path);
|
|
8838
|
+
const [methodPtr, methodLen] = passStringToWasm(exports, method);
|
|
8839
|
+
const [authPtr, authLen] = passStringToWasm(exports, authType);
|
|
8840
|
+
const [bodyPtr, bodyLen] = body === void 0 ? [0, 0] : passStringToWasm(exports, body);
|
|
8841
|
+
exports.qodercontext_prepareRequest(retptr, ctx, endpointPtr, endpointLen, pathPtr, pathLen, methodPtr, methodLen, authPtr, authLen, bodyPtr, bodyLen, 0, 0);
|
|
8842
|
+
const view = new Int32Array(exports.memory.buffer, retptr, 4);
|
|
8843
|
+
if ((view[2] ?? 0) !== 0)
|
|
8844
|
+
throw takeObject(view[1] ?? 0);
|
|
8845
|
+
return (view[0] ?? 0) >>> 0;
|
|
8846
|
+
} finally {
|
|
8847
|
+
exports.__wbindgen_add_to_stack_pointer(16);
|
|
8848
|
+
}
|
|
8849
|
+
}
|
|
8850
|
+
function signQoderRequest(endpoint, path, method, authType, body, identity, cosyVersion) {
|
|
8851
|
+
const exports = loadExports();
|
|
8852
|
+
const ctx = callContextNew(exports, identity, cosyVersion);
|
|
8853
|
+
try {
|
|
8854
|
+
const result = callPrepareRequest(exports, ctx, endpoint, path, method, authType, body);
|
|
8855
|
+
try {
|
|
8856
|
+
const url = wasmResultString(exports, exports.requestresult_url, result);
|
|
8857
|
+
if (!url)
|
|
8858
|
+
throw new Error("qoder request signer returned an empty url");
|
|
8859
|
+
const signedBody = wasmResultString(exports, exports.requestresult_body, result);
|
|
8860
|
+
return { url, headers: signatureHeaders(exports, result), body: signedBody ?? "" };
|
|
8861
|
+
} finally {
|
|
8862
|
+
exports.__wbg_requestresult_free(result, 0);
|
|
8863
|
+
}
|
|
8864
|
+
} finally {
|
|
8865
|
+
exports.__wbg_qodercontext_free(ctx, 0);
|
|
8866
|
+
}
|
|
8867
|
+
}
|
|
8804
8868
|
function storedString(record, field) {
|
|
8805
8869
|
const value = record[field];
|
|
8806
8870
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
@@ -8896,12 +8960,14 @@ function requireQoderAuth(env = process.env, home = homedir10()) {
|
|
|
8896
8960
|
}
|
|
8897
8961
|
|
|
8898
8962
|
// ../qoder-core/dist/catalog.js
|
|
8963
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
8964
|
+
import { homedir as homedir11 } from "node:os";
|
|
8965
|
+
import { join as join11 } from "node:path";
|
|
8899
8966
|
var QODER_CATALOG_PROVIDER_ID = "qoder";
|
|
8900
8967
|
var QODER_CATALOG_FILE = `${QODER_CATALOG_PROVIDER_ID}.models.json`;
|
|
8968
|
+
var QODER_CATALOG_CACHE_DIR_ENV = "NS_QODER_CATALOG_CACHE_DIR";
|
|
8901
8969
|
var QODER_DEFAULT_MAX_TOKENS = 16384;
|
|
8902
|
-
var
|
|
8903
|
-
var QODER_WIRE_CONTEXT_WINDOW = QODER_WIRE_BODY_LIMIT_BYTES / 4;
|
|
8904
|
-
var QODER_DEFAULT_CONTEXT_WINDOW = QODER_WIRE_CONTEXT_WINDOW;
|
|
8970
|
+
var QODER_DEFAULT_CONTEXT_WINDOW = 2e5;
|
|
8905
8971
|
var BOOTSTRAP_IDS = [
|
|
8906
8972
|
"auto",
|
|
8907
8973
|
"ultimate",
|
|
@@ -8945,6 +9011,28 @@ var QODER_MODEL_DISPLAY_NAMES = {
|
|
|
8945
9011
|
function qoderBootstrapModels() {
|
|
8946
9012
|
return BOOTSTRAP_IDS.map((value) => qoderModelFromInfo({ value, isEnabled: true }));
|
|
8947
9013
|
}
|
|
9014
|
+
function qoderCatalogPath(cacheDir) {
|
|
9015
|
+
return join11(cacheDir, QODER_CATALOG_FILE);
|
|
9016
|
+
}
|
|
9017
|
+
function qoderCatalogCacheDir(env = process.env, home = homedir11()) {
|
|
9018
|
+
const override = env[QODER_CATALOG_CACHE_DIR_ENV]?.trim();
|
|
9019
|
+
return override || join11(home, ".pi", "agent", "cache", "ns-pi-provider");
|
|
9020
|
+
}
|
|
9021
|
+
function resolveQoderModelSpec(modelId, cacheDir = qoderCatalogCacheDir()) {
|
|
9022
|
+
const listed2 = readQoderCatalog({ cacheDir });
|
|
9023
|
+
return listed2.find((model) => model.id === modelId) ?? qoderBootstrapModels().find((model) => model.id === modelId);
|
|
9024
|
+
}
|
|
9025
|
+
function readQoderCatalog(options) {
|
|
9026
|
+
try {
|
|
9027
|
+
const raw = readFileSync7(qoderCatalogPath(options.cacheDir), "utf8");
|
|
9028
|
+
const parsed = JSON.parse(raw);
|
|
9029
|
+
if (!parsed?.models?.length)
|
|
9030
|
+
return qoderBootstrapModels();
|
|
9031
|
+
return parsed.models;
|
|
9032
|
+
} catch {
|
|
9033
|
+
return qoderBootstrapModels();
|
|
9034
|
+
}
|
|
9035
|
+
}
|
|
8948
9036
|
var EFFORT_ORDER = ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
8949
9037
|
function positive(value) {
|
|
8950
9038
|
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
@@ -8965,7 +9053,7 @@ function qoderModelFromInfo(info) {
|
|
|
8965
9053
|
name: info.displayName ?? QODER_MODEL_DISPLAY_NAMES[info.value] ?? info.value,
|
|
8966
9054
|
reasoning: info.isReasoning === true || efforts.length > 0,
|
|
8967
9055
|
input: info.isVl === true ? ["text", "image"] : ["text"],
|
|
8968
|
-
contextWindow:
|
|
9056
|
+
contextWindow: declared,
|
|
8969
9057
|
maxTokens: positive(info.maxOutputTokens) ? info.maxOutputTokens : QODER_DEFAULT_MAX_TOKENS,
|
|
8970
9058
|
...efforts.length > 0 ? { efforts } : {}
|
|
8971
9059
|
};
|
|
@@ -9031,73 +9119,11 @@ function qoderModelInfosFromVendorCatalog(raw, scene) {
|
|
|
9031
9119
|
}
|
|
9032
9120
|
|
|
9033
9121
|
// ../qoder-core/dist/models-api.js
|
|
9034
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
9035
|
-
import { join as
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
try {
|
|
9040
|
-
return [{ dir, mtime: statSync2(dir).mtimeMs }];
|
|
9041
|
-
} catch {
|
|
9042
|
-
return [];
|
|
9043
|
-
}
|
|
9044
|
-
});
|
|
9045
|
-
dirs.sort((a, b) => b.mtime - a.mtime);
|
|
9046
|
-
for (const { dir } of dirs) {
|
|
9047
|
-
const file = newestCatalog(dir);
|
|
9048
|
-
if (file)
|
|
9049
|
-
return { dir, file };
|
|
9050
|
-
}
|
|
9051
|
-
return void 0;
|
|
9052
|
-
} catch {
|
|
9053
|
-
return void 0;
|
|
9054
|
-
}
|
|
9055
|
-
}
|
|
9056
|
-
function newestCatalog(dir) {
|
|
9057
|
-
try {
|
|
9058
|
-
const files = readdirSync3(dir).flatMap((name) => {
|
|
9059
|
-
const match = /^catalog-v(\d+)$/.exec(name);
|
|
9060
|
-
return match ? [{ file: join11(dir, name), version: Number(match[1]) }] : [];
|
|
9061
|
-
}).sort((a, b) => b.version - a.version);
|
|
9062
|
-
return files[0]?.file;
|
|
9063
|
-
} catch {
|
|
9064
|
-
return void 0;
|
|
9065
|
-
}
|
|
9066
|
-
}
|
|
9067
|
-
function qoderVendorCatalogFile(configDir) {
|
|
9068
|
-
const root = join11(configDir, ".models");
|
|
9069
|
-
let uid;
|
|
9070
|
-
let scene;
|
|
9071
|
-
try {
|
|
9072
|
-
const pointer = JSON.parse(readFileSync7(join11(root, "default"), "utf8"));
|
|
9073
|
-
if (typeof pointer.uid === "string" && pointer.uid)
|
|
9074
|
-
uid = pointer.uid;
|
|
9075
|
-
if (typeof pointer.scene === "string" && pointer.scene)
|
|
9076
|
-
scene = pointer.scene;
|
|
9077
|
-
} catch {
|
|
9078
|
-
}
|
|
9079
|
-
let dir = uid ? join11(root, uid) : void 0;
|
|
9080
|
-
let file = dir ? newestCatalog(dir) : void 0;
|
|
9081
|
-
if (!file) {
|
|
9082
|
-
const found = newestCatalogDirectory(root);
|
|
9083
|
-
dir = found?.dir;
|
|
9084
|
-
file = found?.file;
|
|
9085
|
-
}
|
|
9086
|
-
if (!dir || !file)
|
|
9087
|
-
return void 0;
|
|
9088
|
-
return { file, uid: dir.slice(root.length + 1), ...scene ? { scene } : {} };
|
|
9089
|
-
}
|
|
9090
|
-
async function fetchQoderModels(_options = {}) {
|
|
9091
|
-
try {
|
|
9092
|
-
const target = qoderVendorCatalogFile(qoderConfigDir());
|
|
9093
|
-
if (!target)
|
|
9094
|
-
return qoderBootstrapModels();
|
|
9095
|
-
const plain = decryptQoderModelCache(readFileSync7(target.file, "utf8"), target.uid);
|
|
9096
|
-
return qoderModelsFromModelInfos(qoderModelInfosFromVendorCatalog(plain, target.scene));
|
|
9097
|
-
} catch {
|
|
9098
|
-
return qoderBootstrapModels();
|
|
9099
|
-
}
|
|
9100
|
-
}
|
|
9122
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync8, statSync as statSync2 } from "node:fs";
|
|
9123
|
+
import { join as join12 } from "node:path";
|
|
9124
|
+
|
|
9125
|
+
// ../qoder-core/dist/stream.js
|
|
9126
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
9101
9127
|
|
|
9102
9128
|
// ../qoder-core/dist/prompt.js
|
|
9103
9129
|
function imageDataUrl(data, mimeType) {
|
|
@@ -9146,7 +9172,9 @@ function toWireMessage(message) {
|
|
|
9146
9172
|
return void 0;
|
|
9147
9173
|
return {
|
|
9148
9174
|
role: "assistant",
|
|
9149
|
-
|
|
9175
|
+
// Kimi, DeepSeek-Flash and MiniMax reject a tool-only turn whose content is
|
|
9176
|
+
// null. An empty string is the same "no text" and those models accept it.
|
|
9177
|
+
content: text || "",
|
|
9150
9178
|
...toolCalls.length > 0 ? { tool_calls: toolCalls } : {}
|
|
9151
9179
|
};
|
|
9152
9180
|
}
|
|
@@ -9281,7 +9309,7 @@ function reduceWireChunk(state, chunk) {
|
|
|
9281
9309
|
ensureStart2(state, events);
|
|
9282
9310
|
if (typeof record.id === "string" && record.id)
|
|
9283
9311
|
state.responseId = record.id;
|
|
9284
|
-
if (typeof record.model === "string" && record.model)
|
|
9312
|
+
if (typeof record.model === "string" && record.model && record.model !== "auto")
|
|
9285
9313
|
state.upstreamModel = record.model;
|
|
9286
9314
|
if (record.raw_usage !== void 0 || record.usage !== void 0) {
|
|
9287
9315
|
const raw = record.raw_usage ?? record.usage;
|
|
@@ -9381,7 +9409,6 @@ function qoderSessionId(raw) {
|
|
|
9381
9409
|
}
|
|
9382
9410
|
|
|
9383
9411
|
// ../qoder-core/dist/stream.js
|
|
9384
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
9385
9412
|
var QODER_WIRE_VERSION = "1.1.83";
|
|
9386
9413
|
var QODER_INFER_ORIGIN = "https://api2.qoder.sh";
|
|
9387
9414
|
var ANONYMOUS_SIGNING_IDENTITY = {
|
|
@@ -9423,40 +9450,6 @@ function machineOs() {
|
|
|
9423
9450
|
const arch = process.arch === "arm64" ? "aarch64" : process.arch;
|
|
9424
9451
|
return `${arch}_${process.platform}`;
|
|
9425
9452
|
}
|
|
9426
|
-
function estimateQoderBodyBytes(payload) {
|
|
9427
|
-
try {
|
|
9428
|
-
return Buffer.byteLength(JSON.stringify(payload));
|
|
9429
|
-
} catch {
|
|
9430
|
-
return Number.MAX_SAFE_INTEGER;
|
|
9431
|
-
}
|
|
9432
|
-
}
|
|
9433
|
-
function fitQoderBody(payload) {
|
|
9434
|
-
const messages = payload.messages;
|
|
9435
|
-
if (!Array.isArray(messages) || messages.length <= 1)
|
|
9436
|
-
return payload;
|
|
9437
|
-
if (estimateQoderBodyBytes(payload) <= QODER_WIRE_BODY_LIMIT_BYTES)
|
|
9438
|
-
return payload;
|
|
9439
|
-
const kept = messages.slice();
|
|
9440
|
-
while (kept.length > 1 && estimateQoderBodyBytes({ ...payload, messages: kept }) > QODER_WIRE_BODY_LIMIT_BYTES) {
|
|
9441
|
-
const dropped = kept[0];
|
|
9442
|
-
kept.shift();
|
|
9443
|
-
if (dropped?.role === "assistant" && Array.isArray(dropped.tool_calls) && dropped.tool_calls.length > 0) {
|
|
9444
|
-
const toolCallIds = new Set(dropped.tool_calls.map((tc) => tc && typeof tc === "object" && "id" in tc ? tc.id : void 0).filter((id) => typeof id === "string"));
|
|
9445
|
-
while (kept.length > 1) {
|
|
9446
|
-
const next = kept[0];
|
|
9447
|
-
if (next?.role === "tool" && typeof next.tool_call_id === "string" && toolCallIds.has(next.tool_call_id)) {
|
|
9448
|
-
kept.shift();
|
|
9449
|
-
toolCallIds.delete(next.tool_call_id);
|
|
9450
|
-
if (toolCallIds.size === 0)
|
|
9451
|
-
break;
|
|
9452
|
-
} else {
|
|
9453
|
-
break;
|
|
9454
|
-
}
|
|
9455
|
-
}
|
|
9456
|
-
}
|
|
9457
|
-
}
|
|
9458
|
-
return { ...payload, messages: kept };
|
|
9459
|
-
}
|
|
9460
9453
|
function toWireTool(tool) {
|
|
9461
9454
|
return {
|
|
9462
9455
|
type: "function",
|
|
@@ -9485,7 +9478,7 @@ function lastUserText(messages) {
|
|
|
9485
9478
|
}
|
|
9486
9479
|
function buildRequestBody(options, sessionId) {
|
|
9487
9480
|
const requestId = randomUUID2();
|
|
9488
|
-
const spec =
|
|
9481
|
+
const spec = resolveQoderModelSpec(options.model);
|
|
9489
9482
|
const text = lastUserText(options.messages);
|
|
9490
9483
|
const maxTokens = spec?.maxTokens ?? QODER_DEFAULT_MAX_TOKENS;
|
|
9491
9484
|
const payload = {
|
|
@@ -9600,6 +9593,9 @@ function unwrapWireChunk(chunk) {
|
|
|
9600
9593
|
} catch {
|
|
9601
9594
|
}
|
|
9602
9595
|
const status = typeof record.statusCode === "string" ? record.statusCode : String(record.statusCodeValue);
|
|
9596
|
+
if (status === "PAYLOAD_TOO_LARGE") {
|
|
9597
|
+
throw new QoderApiError(`Qoder prompt is too long for this model's context window (${status}${detail ? `: ${detail}` : ""})`);
|
|
9598
|
+
}
|
|
9603
9599
|
throw new QoderApiError(`Qoder model server rejected the request (${status}${detail ? `: ${detail}` : ""})`);
|
|
9604
9600
|
}
|
|
9605
9601
|
try {
|
|
@@ -9686,12 +9682,7 @@ async function* streamQoderResponse(options) {
|
|
|
9686
9682
|
if (payload.messages.length === 0)
|
|
9687
9683
|
throw new QoderApiError("Qoder prompt is empty");
|
|
9688
9684
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
9689
|
-
const
|
|
9690
|
-
const body = JSON.stringify(fittedPayload);
|
|
9691
|
-
const bodyBytes = Buffer.byteLength(body);
|
|
9692
|
-
if (bodyBytes > QODER_WIRE_BODY_LIMIT_BYTES) {
|
|
9693
|
-
throw new QoderApiError(`Qoder prompt is too long for this model's context window (${bodyBytes} bytes > ${QODER_WIRE_BODY_LIMIT_BYTES} bytes)`);
|
|
9694
|
-
}
|
|
9685
|
+
const body = JSON.stringify(payload);
|
|
9695
9686
|
const origin = qoderWireUrl(process.env.QODER_MODEL_SERVER_HOST, options.endpoint);
|
|
9696
9687
|
const identity = readQoderSigningIdentity(qoderConfigDir()) ?? ANONYMOUS_SIGNING_IDENTITY;
|
|
9697
9688
|
const signed = signQoderInferRequest(origin, body, options.model, "system", identity, QODER_WIRE_VERSION);
|
|
@@ -9734,7 +9725,7 @@ async function* streamQoderResponse(options) {
|
|
|
9734
9725
|
}
|
|
9735
9726
|
}
|
|
9736
9727
|
function streamQoder(options) {
|
|
9737
|
-
const contextWindow =
|
|
9728
|
+
const contextWindow = resolveQoderModelSpec(options.model)?.contextWindow ?? QODER_DEFAULT_CONTEXT_WINDOW;
|
|
9738
9729
|
return recordUsage(streamQoderResponse(options), {
|
|
9739
9730
|
vendor: "qoder",
|
|
9740
9731
|
model: options.model,
|
|
@@ -9744,6 +9735,206 @@ function streamQoder(options) {
|
|
|
9744
9735
|
});
|
|
9745
9736
|
}
|
|
9746
9737
|
|
|
9738
|
+
// ../qoder-core/dist/models-api.js
|
|
9739
|
+
var QODER_MODEL_LIST_PATH = "/algo/api/v2/model/list?Encode=1";
|
|
9740
|
+
function newestCatalogDirectory(root) {
|
|
9741
|
+
try {
|
|
9742
|
+
const dirs = readdirSync3(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join12(root, entry.name)).flatMap((dir) => {
|
|
9743
|
+
try {
|
|
9744
|
+
return [{ dir, mtime: statSync2(dir).mtimeMs }];
|
|
9745
|
+
} catch {
|
|
9746
|
+
return [];
|
|
9747
|
+
}
|
|
9748
|
+
});
|
|
9749
|
+
dirs.sort((a, b) => b.mtime - a.mtime);
|
|
9750
|
+
for (const { dir } of dirs) {
|
|
9751
|
+
const file = newestCatalog(dir);
|
|
9752
|
+
if (file)
|
|
9753
|
+
return { dir, file };
|
|
9754
|
+
}
|
|
9755
|
+
return void 0;
|
|
9756
|
+
} catch {
|
|
9757
|
+
return void 0;
|
|
9758
|
+
}
|
|
9759
|
+
}
|
|
9760
|
+
function newestCatalog(dir) {
|
|
9761
|
+
try {
|
|
9762
|
+
const files = readdirSync3(dir).flatMap((name) => {
|
|
9763
|
+
const match = /^catalog-v(\d+)$/.exec(name);
|
|
9764
|
+
return match ? [{ file: join12(dir, name), version: Number(match[1]) }] : [];
|
|
9765
|
+
}).sort((a, b) => b.version - a.version);
|
|
9766
|
+
return files[0]?.file;
|
|
9767
|
+
} catch {
|
|
9768
|
+
return void 0;
|
|
9769
|
+
}
|
|
9770
|
+
}
|
|
9771
|
+
function qoderVendorCatalogFile(configDir) {
|
|
9772
|
+
const root = join12(configDir, ".models");
|
|
9773
|
+
let uid;
|
|
9774
|
+
let scene;
|
|
9775
|
+
try {
|
|
9776
|
+
const pointer = JSON.parse(readFileSync8(join12(root, "default"), "utf8"));
|
|
9777
|
+
if (typeof pointer.uid === "string" && pointer.uid)
|
|
9778
|
+
uid = pointer.uid;
|
|
9779
|
+
if (typeof pointer.scene === "string" && pointer.scene)
|
|
9780
|
+
scene = pointer.scene;
|
|
9781
|
+
} catch {
|
|
9782
|
+
}
|
|
9783
|
+
let dir = uid ? join12(root, uid) : void 0;
|
|
9784
|
+
let file = dir ? newestCatalog(dir) : void 0;
|
|
9785
|
+
if (!file) {
|
|
9786
|
+
const found = newestCatalogDirectory(root);
|
|
9787
|
+
dir = found?.dir;
|
|
9788
|
+
file = found?.file;
|
|
9789
|
+
}
|
|
9790
|
+
if (!dir || !file)
|
|
9791
|
+
return void 0;
|
|
9792
|
+
return { file, uid: dir.slice(root.length + 1), ...scene ? { scene } : {} };
|
|
9793
|
+
}
|
|
9794
|
+
var MODEL_LIST_TIMEOUT_MS = 1e4;
|
|
9795
|
+
async function fetchServerModels(signal) {
|
|
9796
|
+
const identity = readQoderSigningIdentity(qoderConfigDir());
|
|
9797
|
+
if (!identity)
|
|
9798
|
+
throw new QoderAuthError();
|
|
9799
|
+
const signed = signQoderRequest(qoderWireUrl(process.env.QODER_MODEL_SERVER_HOST), QODER_MODEL_LIST_PATH, "GET", "auth", void 0, identity, QODER_WIRE_VERSION);
|
|
9800
|
+
const timeout = AbortSignal.timeout(MODEL_LIST_TIMEOUT_MS);
|
|
9801
|
+
const response = await fetch(signed.url, {
|
|
9802
|
+
method: "GET",
|
|
9803
|
+
headers: signed.headers,
|
|
9804
|
+
signal: signal ? AbortSignal.any([signal, timeout]) : timeout
|
|
9805
|
+
});
|
|
9806
|
+
const text = await response.text();
|
|
9807
|
+
if (response.status === 401 || response.status === 403) {
|
|
9808
|
+
throw new QoderAuthError(`${QODER_LOGIN_MESSAGE} (HTTP ${response.status}: ${text.slice(0, 200)})`);
|
|
9809
|
+
}
|
|
9810
|
+
if (!response.ok)
|
|
9811
|
+
throw new QoderApiError(`models.list failed: HTTP ${response.status}: ${text.slice(0, 200)}`);
|
|
9812
|
+
const infos = qoderModelInfosFromVendorCatalog(text);
|
|
9813
|
+
if (infos.length === 0)
|
|
9814
|
+
throw new QoderApiError("models.list returned no models for the assistant scene");
|
|
9815
|
+
return qoderModelsFromModelInfos(infos);
|
|
9816
|
+
}
|
|
9817
|
+
function readLocalCatalog() {
|
|
9818
|
+
const target = qoderVendorCatalogFile(qoderConfigDir());
|
|
9819
|
+
if (!target)
|
|
9820
|
+
return void 0;
|
|
9821
|
+
const plain = decryptQoderModelCache(readFileSync8(target.file, "utf8"), target.uid);
|
|
9822
|
+
return qoderModelsFromModelInfos(qoderModelInfosFromVendorCatalog(plain, target.scene));
|
|
9823
|
+
}
|
|
9824
|
+
async function fetchQoderModels(options = {}) {
|
|
9825
|
+
let error2;
|
|
9826
|
+
try {
|
|
9827
|
+
return { models: await fetchServerModels(options.signal), source: "server" };
|
|
9828
|
+
} catch (err) {
|
|
9829
|
+
if (options.signal?.aborted)
|
|
9830
|
+
throw err;
|
|
9831
|
+
error2 = err instanceof Error ? err.message : String(err);
|
|
9832
|
+
}
|
|
9833
|
+
try {
|
|
9834
|
+
const models = readLocalCatalog();
|
|
9835
|
+
if (models)
|
|
9836
|
+
return { models, source: "catalog", error: error2 };
|
|
9837
|
+
} catch {
|
|
9838
|
+
}
|
|
9839
|
+
return { models: qoderBootstrapModels(), source: "bootstrap", error: error2 };
|
|
9840
|
+
}
|
|
9841
|
+
|
|
9842
|
+
// ../qoder-core/dist/quota.js
|
|
9843
|
+
var QUOTA_ORIGIN = "https://center.qoder.sh";
|
|
9844
|
+
var BUCKETS = [
|
|
9845
|
+
{ key: "userQuota", id: "user", label: "Plan credits" },
|
|
9846
|
+
{ key: "addOnQuota", id: "addon", label: "Add-on credits" },
|
|
9847
|
+
{ key: "orgResourcePackage", id: "org", label: "Organization credits" }
|
|
9848
|
+
];
|
|
9849
|
+
function asRecord2(value) {
|
|
9850
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
9851
|
+
}
|
|
9852
|
+
function finiteNumber(value) {
|
|
9853
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
9854
|
+
}
|
|
9855
|
+
function positiveNumber(value) {
|
|
9856
|
+
const number = finiteNumber(value);
|
|
9857
|
+
return number !== void 0 && number > 0 ? number : void 0;
|
|
9858
|
+
}
|
|
9859
|
+
function httpUrl(value) {
|
|
9860
|
+
return typeof value === "string" && value.startsWith("https://") ? value : void 0;
|
|
9861
|
+
}
|
|
9862
|
+
function bucketFrom(id, label, value) {
|
|
9863
|
+
const record = asRecord2(value);
|
|
9864
|
+
if (!record)
|
|
9865
|
+
return void 0;
|
|
9866
|
+
const limit = positiveNumber(record.total) ?? positiveNumber(record.cap);
|
|
9867
|
+
if (limit === void 0)
|
|
9868
|
+
return void 0;
|
|
9869
|
+
const used = finiteNumber(record.used) ?? 0;
|
|
9870
|
+
const remaining = finiteNumber(record.remaining);
|
|
9871
|
+
return {
|
|
9872
|
+
id,
|
|
9873
|
+
label,
|
|
9874
|
+
used,
|
|
9875
|
+
limit,
|
|
9876
|
+
...remaining !== void 0 ? { remaining } : {},
|
|
9877
|
+
unit: "credits"
|
|
9878
|
+
};
|
|
9879
|
+
}
|
|
9880
|
+
function rawWithoutAccount(usage) {
|
|
9881
|
+
const raw = { ...usage };
|
|
9882
|
+
delete raw.userId;
|
|
9883
|
+
delete raw.user_id;
|
|
9884
|
+
return raw;
|
|
9885
|
+
}
|
|
9886
|
+
function parseQoderQuota(usageBody, planBody) {
|
|
9887
|
+
const usage = asRecord2(usageBody);
|
|
9888
|
+
if (!usage)
|
|
9889
|
+
return null;
|
|
9890
|
+
const plan = asRecord2(planBody);
|
|
9891
|
+
const planName = typeof plan?.plan_tier_name === "string" ? plan.plan_tier_name.trim() : "";
|
|
9892
|
+
const resetsAt = finiteNumber(usage.expiresAt) ?? finiteNumber(usage.refreshAt);
|
|
9893
|
+
const addOn = asRecord2(usage.addOnQuota);
|
|
9894
|
+
const manageUrl = httpUrl(addOn?.detailUrl) ?? httpUrl(usage.upgradeUrl);
|
|
9895
|
+
return {
|
|
9896
|
+
...planName ? { planName } : {},
|
|
9897
|
+
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
9898
|
+
...manageUrl ? { manageUrl } : {},
|
|
9899
|
+
buckets: BUCKETS.flatMap((entry) => {
|
|
9900
|
+
const bucket = bucketFrom(entry.id, entry.label, usage[entry.key]);
|
|
9901
|
+
return bucket ? [bucket] : [];
|
|
9902
|
+
}),
|
|
9903
|
+
raw: rawWithoutAccount(usage)
|
|
9904
|
+
};
|
|
9905
|
+
}
|
|
9906
|
+
async function getJson(fetchImpl, token, path, signal) {
|
|
9907
|
+
const response = await fetchImpl(`${QUOTA_ORIGIN}${path}`, {
|
|
9908
|
+
method: "GET",
|
|
9909
|
+
headers: {
|
|
9910
|
+
Accept: "application/json",
|
|
9911
|
+
Authorization: `Bearer ${token}`
|
|
9912
|
+
},
|
|
9913
|
+
signal
|
|
9914
|
+
});
|
|
9915
|
+
if (response.status === 401 || response.status === 403) {
|
|
9916
|
+
throw new QoderAuthError(`${QODER_LOGIN_MESSAGE} (HTTP ${response.status})`);
|
|
9917
|
+
}
|
|
9918
|
+
if (!response.ok) {
|
|
9919
|
+
throw new QoderApiError(`Qoder quota endpoint returned HTTP ${response.status}`);
|
|
9920
|
+
}
|
|
9921
|
+
return response.json();
|
|
9922
|
+
}
|
|
9923
|
+
async function fetchQoderQuota(options = {}) {
|
|
9924
|
+
const token = options.token !== void 0 ? options.token || void 0 : resolveQoderAuth()?.token;
|
|
9925
|
+
if (!token)
|
|
9926
|
+
return null;
|
|
9927
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
9928
|
+
const [usageResult, planResult] = await Promise.allSettled([
|
|
9929
|
+
getJson(fetchImpl, token, "/api/v2/quota/usage", options.signal),
|
|
9930
|
+
getJson(fetchImpl, token, "/api/v2/user/plan", options.signal)
|
|
9931
|
+
]);
|
|
9932
|
+
if (usageResult.status === "rejected")
|
|
9933
|
+
throw usageResult.reason;
|
|
9934
|
+
const plan = planResult.status === "fulfilled" ? planResult.value : void 0;
|
|
9935
|
+
return parseQoderQuota(usageResult.value, plan);
|
|
9936
|
+
}
|
|
9937
|
+
|
|
9747
9938
|
// ../pi-provider/src/qoder/api-mode.ts
|
|
9748
9939
|
function streamViaQoder(model, context, options) {
|
|
9749
9940
|
return streamToPi({
|
|
@@ -9861,7 +10052,16 @@ async function refreshQoderModels(options = {}) {
|
|
|
9861
10052
|
error: "no Qoder auth: run `qodercli login` or set QODER_PERSONAL_ACCESS_TOKEN"
|
|
9862
10053
|
};
|
|
9863
10054
|
}
|
|
9864
|
-
const
|
|
10055
|
+
const list = await fetchQoderModels();
|
|
10056
|
+
const catalog = specsToCatalog2(list.models);
|
|
10057
|
+
if (list.source !== "server") {
|
|
10058
|
+
return {
|
|
10059
|
+
models: catalogToProviderModels2(catalog),
|
|
10060
|
+
fromCache: false,
|
|
10061
|
+
source: "fallback",
|
|
10062
|
+
error: `model server unavailable (${list.error ?? "unknown error"}); showing ${list.source} list`
|
|
10063
|
+
};
|
|
10064
|
+
}
|
|
9865
10065
|
cache.store(QODER_PROVIDER_ID, catalog, { version: "qoder-cli-v1" });
|
|
9866
10066
|
return { models: catalogToProviderModels2(catalog), fromCache: false, source: "live" };
|
|
9867
10067
|
} catch (err) {
|
|
@@ -9876,9 +10076,12 @@ function createProviderConfig2(models) {
|
|
|
9876
10076
|
api: QODER_API,
|
|
9877
10077
|
models,
|
|
9878
10078
|
streamSimple: streamQoderForPi,
|
|
10079
|
+
// OMP 19.1.1 reads `.length` on this return, so null throws during discovery.
|
|
10080
|
+
// A disk snapshot, fresh or past the 15-minute TTL, is a real catalog. The
|
|
10081
|
+
// bootstrap list stays null so it is not pinned as authoritative for 24h.
|
|
9879
10082
|
fetchDynamicModels: async () => {
|
|
9880
10083
|
const latest = await refreshQoderModels({ allowNetwork: false });
|
|
9881
|
-
if (
|
|
10084
|
+
if (latest.source !== "cache" || latest.models.length === 0) return null;
|
|
9882
10085
|
return latest.models;
|
|
9883
10086
|
},
|
|
9884
10087
|
async refreshModels() {
|
|
@@ -9921,32 +10124,11 @@ async function registerQoderProvider(pi) {
|
|
|
9921
10124
|
}
|
|
9922
10125
|
|
|
9923
10126
|
// ../omp-provider/src/kiro-usage.ts
|
|
9924
|
-
function
|
|
9925
|
-
|
|
9926
|
-
if (resourceType?.toLowerCase() === "credit" && (named === void 0 || named === "invocations")) return "credits";
|
|
9927
|
-
switch (named) {
|
|
9928
|
-
case "credit":
|
|
9929
|
-
case "credits":
|
|
9930
|
-
return "credits";
|
|
9931
|
-
case "request":
|
|
9932
|
-
case "requests":
|
|
9933
|
-
return "requests";
|
|
9934
|
-
case "token":
|
|
9935
|
-
case "tokens":
|
|
9936
|
-
return "tokens";
|
|
9937
|
-
case "usd":
|
|
9938
|
-
return "usd";
|
|
9939
|
-
default:
|
|
9940
|
-
return "unknown";
|
|
9941
|
-
}
|
|
9942
|
-
}
|
|
9943
|
-
function toResetMs(iso) {
|
|
9944
|
-
if (!iso) return void 0;
|
|
9945
|
-
const ms = Date.parse(iso);
|
|
9946
|
-
return Number.isNaN(ms) ? void 0 : ms;
|
|
10127
|
+
function toUsageUnit2(bucket) {
|
|
10128
|
+
return bucket.unitKind ?? "unknown";
|
|
9947
10129
|
}
|
|
9948
10130
|
function toLimit(provider, bucket, usage) {
|
|
9949
|
-
const resetsAt =
|
|
10131
|
+
const resetsAt = bucket.resetAtMs ?? usage.resetAtMs;
|
|
9950
10132
|
const exhausted = bucket.limit !== void 0 && bucket.used >= bucket.limit;
|
|
9951
10133
|
const notes = [];
|
|
9952
10134
|
if (bucket.overagesDisplay) notes.push(`Overage: ${bucket.overagesDisplay}`);
|
|
@@ -9962,7 +10144,7 @@ function toLimit(provider, bucket, usage) {
|
|
|
9962
10144
|
amount: {
|
|
9963
10145
|
used: bucket.used,
|
|
9964
10146
|
...bucket.limit !== void 0 ? { limit: bucket.limit } : {},
|
|
9965
|
-
unit:
|
|
10147
|
+
unit: toUsageUnit2(bucket)
|
|
9966
10148
|
},
|
|
9967
10149
|
// Kiro exposes no warning threshold of its own. Inventing one would put a
|
|
9968
10150
|
// warning in front of the user that the service never raised.
|
|
@@ -10008,6 +10190,44 @@ var kiroUsageProvider = {
|
|
|
10008
10190
|
validatesCredentials: true
|
|
10009
10191
|
};
|
|
10010
10192
|
|
|
10193
|
+
// ../omp-provider/src/qoder-usage.ts
|
|
10194
|
+
function toLimit2(provider, bucket, quota) {
|
|
10195
|
+
const exhausted = bucket.remaining === 0 || bucket.used >= bucket.limit;
|
|
10196
|
+
return {
|
|
10197
|
+
id: bucket.id,
|
|
10198
|
+
label: bucket.label,
|
|
10199
|
+
scope: { provider },
|
|
10200
|
+
...quota.resetsAt !== void 0 ? { window: { id: "billing-period", label: "Billing period", resetsAt: quota.resetsAt } } : {},
|
|
10201
|
+
amount: {
|
|
10202
|
+
used: bucket.used,
|
|
10203
|
+
limit: bucket.limit,
|
|
10204
|
+
unit: "credits"
|
|
10205
|
+
},
|
|
10206
|
+
status: exhausted ? "exhausted" : "ok"
|
|
10207
|
+
};
|
|
10208
|
+
}
|
|
10209
|
+
function toQoderUsageReport(provider, quota, fetchedAt = Date.now()) {
|
|
10210
|
+
return {
|
|
10211
|
+
provider,
|
|
10212
|
+
fetchedAt,
|
|
10213
|
+
limits: quota.buckets.map((bucket) => toLimit2(provider, bucket, quota)),
|
|
10214
|
+
...quota.planName ? { notes: [quota.planName] } : {},
|
|
10215
|
+
metadata: {
|
|
10216
|
+
...quota.manageUrl ? { manageUrl: quota.manageUrl } : {}
|
|
10217
|
+
},
|
|
10218
|
+
raw: quota.raw
|
|
10219
|
+
};
|
|
10220
|
+
}
|
|
10221
|
+
var qoderUsageProvider = {
|
|
10222
|
+
id: "qoder",
|
|
10223
|
+
async fetchUsage(params, ctx) {
|
|
10224
|
+
const quota = await fetchQoderQuota({ fetchImpl: ctx.fetch });
|
|
10225
|
+
if (!quota) return null;
|
|
10226
|
+
return toQoderUsageReport(params.provider, quota);
|
|
10227
|
+
},
|
|
10228
|
+
validatesCredentials: false
|
|
10229
|
+
};
|
|
10230
|
+
|
|
10011
10231
|
// ../omp-provider/src/adapter.ts
|
|
10012
10232
|
var UNSUPPORTED_EVENTS = /* @__PURE__ */ new Set(["session_info_changed"]);
|
|
10013
10233
|
var SESSION_START_ALIASES = ["session_switch", "session_branch"];
|
|
@@ -10113,6 +10333,9 @@ function adaptProviderConfig(config, env = process.env, providerName) {
|
|
|
10113
10333
|
if (providerName === "kiro" && next.usage == null) {
|
|
10114
10334
|
next.usage = kiroUsageProvider;
|
|
10115
10335
|
}
|
|
10336
|
+
if (providerName === "qoder" && next.usage == null) {
|
|
10337
|
+
next.usage = qoderUsageProvider;
|
|
10338
|
+
}
|
|
10116
10339
|
return next;
|
|
10117
10340
|
}
|
|
10118
10341
|
function wrapExtensionApi(pi, options = {}) {
|
|
@@ -10140,9 +10363,9 @@ function wrapExtensionApi(pi, options = {}) {
|
|
|
10140
10363
|
}
|
|
10141
10364
|
|
|
10142
10365
|
// ../pi-provider/src/selection.ts
|
|
10143
|
-
import { readFileSync as
|
|
10144
|
-
import { homedir as
|
|
10145
|
-
import { join as
|
|
10366
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
10367
|
+
import { homedir as homedir12 } from "node:os";
|
|
10368
|
+
import { join as join13 } from "node:path";
|
|
10146
10369
|
var PROVIDER_KEYS = ["kiro", "devin", "grok", "arnict", "qoder"];
|
|
10147
10370
|
var DEFAULT_SELECTION = {
|
|
10148
10371
|
kiro: true,
|
|
@@ -10151,8 +10374,8 @@ var DEFAULT_SELECTION = {
|
|
|
10151
10374
|
arnict: true,
|
|
10152
10375
|
qoder: true
|
|
10153
10376
|
};
|
|
10154
|
-
function selectionFilePath(env = process.env, home =
|
|
10155
|
-
return env.NS_BRIDGE_PROVIDERS ??
|
|
10377
|
+
function selectionFilePath(env = process.env, home = homedir12()) {
|
|
10378
|
+
return env.NS_BRIDGE_PROVIDERS ?? join13(home, ".ns-bridge", "providers.json");
|
|
10156
10379
|
}
|
|
10157
10380
|
function resolveProviderSelection(env = process.env, file = readProviderFile(selectionFilePath(env))) {
|
|
10158
10381
|
const allow = listed(env.NS_OMP_PROVIDERS);
|
|
@@ -10168,7 +10391,7 @@ function resolveProviderSelection(env = process.env, file = readProviderFile(sel
|
|
|
10168
10391
|
function readProviderFile(path) {
|
|
10169
10392
|
let raw;
|
|
10170
10393
|
try {
|
|
10171
|
-
raw =
|
|
10394
|
+
raw = readFileSync9(path, "utf8");
|
|
10172
10395
|
} catch {
|
|
10173
10396
|
return {};
|
|
10174
10397
|
}
|