@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;
|
|
@@ -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
|
|
|
@@ -1617,6 +1617,7 @@ function loadExports() {
|
|
|
1617
1617
|
"model_cache_decrypt",
|
|
1618
1618
|
"qodercontext_new",
|
|
1619
1619
|
"qodercontext_prepareInferRequest",
|
|
1620
|
+
"qodercontext_prepareRequest",
|
|
1620
1621
|
"requestresult_url",
|
|
1621
1622
|
"requestresult_body",
|
|
1622
1623
|
"requestresult_headers",
|
|
@@ -1859,14 +1860,13 @@ function requireQoderAuth(env = process.env, home = homedir2()) {
|
|
|
1859
1860
|
|
|
1860
1861
|
// ../qoder-core/dist/catalog.js
|
|
1861
1862
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
1863
|
+
import { homedir as homedir3 } from "node:os";
|
|
1862
1864
|
import { join as join3 } from "node:path";
|
|
1863
1865
|
var QODER_CATALOG_PROVIDER_ID = "qoder";
|
|
1864
1866
|
var QODER_CATALOG_FILE = `${QODER_CATALOG_PROVIDER_ID}.models.json`;
|
|
1865
1867
|
var QODER_CATALOG_CACHE_DIR_ENV = "NS_QODER_CATALOG_CACHE_DIR";
|
|
1866
1868
|
var QODER_DEFAULT_MAX_TOKENS = 16384;
|
|
1867
|
-
var
|
|
1868
|
-
var QODER_WIRE_CONTEXT_WINDOW = QODER_WIRE_BODY_LIMIT_BYTES / 4;
|
|
1869
|
-
var QODER_DEFAULT_CONTEXT_WINDOW = QODER_WIRE_CONTEXT_WINDOW;
|
|
1869
|
+
var QODER_DEFAULT_CONTEXT_WINDOW = 2e5;
|
|
1870
1870
|
var BOOTSTRAP_IDS = [
|
|
1871
1871
|
"auto",
|
|
1872
1872
|
"ultimate",
|
|
@@ -1913,6 +1913,14 @@ function qoderBootstrapModels() {
|
|
|
1913
1913
|
function qoderCatalogPath(cacheDir) {
|
|
1914
1914
|
return join3(cacheDir, QODER_CATALOG_FILE);
|
|
1915
1915
|
}
|
|
1916
|
+
function qoderCatalogCacheDir(env = process.env, home = homedir3()) {
|
|
1917
|
+
const override = env[QODER_CATALOG_CACHE_DIR_ENV]?.trim();
|
|
1918
|
+
return override || join3(home, ".pi", "agent", "cache", "ns-pi-provider");
|
|
1919
|
+
}
|
|
1920
|
+
function resolveQoderModelSpec(modelId, cacheDir = qoderCatalogCacheDir()) {
|
|
1921
|
+
const listed = readQoderCatalog({ cacheDir });
|
|
1922
|
+
return listed.find((model) => model.id === modelId) ?? qoderBootstrapModels().find((model) => model.id === modelId);
|
|
1923
|
+
}
|
|
1916
1924
|
function readQoderCatalog(options) {
|
|
1917
1925
|
try {
|
|
1918
1926
|
const raw = readFileSync3(qoderCatalogPath(options.cacheDir), "utf8");
|
|
@@ -1950,7 +1958,7 @@ function qoderModelFromInfo(info) {
|
|
|
1950
1958
|
name: info.displayName ?? QODER_MODEL_DISPLAY_NAMES[info.value] ?? info.value,
|
|
1951
1959
|
reasoning: info.isReasoning === true || efforts.length > 0,
|
|
1952
1960
|
input: info.isVl === true ? ["text", "image"] : ["text"],
|
|
1953
|
-
contextWindow:
|
|
1961
|
+
contextWindow: declared,
|
|
1954
1962
|
maxTokens: positive(info.maxOutputTokens) ? info.maxOutputTokens : QODER_DEFAULT_MAX_TOKENS,
|
|
1955
1963
|
...efforts.length > 0 ? { efforts } : {}
|
|
1956
1964
|
};
|
|
@@ -1958,6 +1966,9 @@ function qoderModelFromInfo(info) {
|
|
|
1958
1966
|
return compaction ? { ...base, compaction } : base;
|
|
1959
1967
|
}
|
|
1960
1968
|
|
|
1969
|
+
// ../qoder-core/dist/stream.js
|
|
1970
|
+
import { randomUUID } from "node:crypto";
|
|
1971
|
+
|
|
1961
1972
|
// ../qoder-core/dist/prompt.js
|
|
1962
1973
|
function imageDataUrl(data, mimeType) {
|
|
1963
1974
|
return data.startsWith("data:") ? data : `data:${mimeType || "image/png"};base64,${data}`;
|
|
@@ -2005,7 +2016,9 @@ function toWireMessage(message) {
|
|
|
2005
2016
|
return void 0;
|
|
2006
2017
|
return {
|
|
2007
2018
|
role: "assistant",
|
|
2008
|
-
|
|
2019
|
+
// Kimi, DeepSeek-Flash and MiniMax reject a tool-only turn whose content is
|
|
2020
|
+
// null. An empty string is the same "no text" and those models accept it.
|
|
2021
|
+
content: text || "",
|
|
2009
2022
|
...toolCalls.length > 0 ? { tool_calls: toolCalls } : {}
|
|
2010
2023
|
};
|
|
2011
2024
|
}
|
|
@@ -2140,7 +2153,7 @@ function reduceWireChunk(state, chunk) {
|
|
|
2140
2153
|
ensureStart(state, events);
|
|
2141
2154
|
if (typeof record.id === "string" && record.id)
|
|
2142
2155
|
state.responseId = record.id;
|
|
2143
|
-
if (typeof record.model === "string" && record.model)
|
|
2156
|
+
if (typeof record.model === "string" && record.model && record.model !== "auto")
|
|
2144
2157
|
state.upstreamModel = record.model;
|
|
2145
2158
|
if (record.raw_usage !== void 0 || record.usage !== void 0) {
|
|
2146
2159
|
const raw = record.raw_usage ?? record.usage;
|
|
@@ -2240,7 +2253,6 @@ function qoderSessionId(raw) {
|
|
|
2240
2253
|
}
|
|
2241
2254
|
|
|
2242
2255
|
// ../qoder-core/dist/stream.js
|
|
2243
|
-
import { randomUUID } from "node:crypto";
|
|
2244
2256
|
var QODER_WIRE_VERSION = "1.1.83";
|
|
2245
2257
|
var QODER_INFER_ORIGIN = "https://api2.qoder.sh";
|
|
2246
2258
|
var ANONYMOUS_SIGNING_IDENTITY = {
|
|
@@ -2282,40 +2294,6 @@ function machineOs() {
|
|
|
2282
2294
|
const arch = process.arch === "arm64" ? "aarch64" : process.arch;
|
|
2283
2295
|
return `${arch}_${process.platform}`;
|
|
2284
2296
|
}
|
|
2285
|
-
function estimateQoderBodyBytes(payload) {
|
|
2286
|
-
try {
|
|
2287
|
-
return Buffer.byteLength(JSON.stringify(payload));
|
|
2288
|
-
} catch {
|
|
2289
|
-
return Number.MAX_SAFE_INTEGER;
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
function fitQoderBody(payload) {
|
|
2293
|
-
const messages = payload.messages;
|
|
2294
|
-
if (!Array.isArray(messages) || messages.length <= 1)
|
|
2295
|
-
return payload;
|
|
2296
|
-
if (estimateQoderBodyBytes(payload) <= QODER_WIRE_BODY_LIMIT_BYTES)
|
|
2297
|
-
return payload;
|
|
2298
|
-
const kept = messages.slice();
|
|
2299
|
-
while (kept.length > 1 && estimateQoderBodyBytes({ ...payload, messages: kept }) > QODER_WIRE_BODY_LIMIT_BYTES) {
|
|
2300
|
-
const dropped = kept[0];
|
|
2301
|
-
kept.shift();
|
|
2302
|
-
if (dropped?.role === "assistant" && Array.isArray(dropped.tool_calls) && dropped.tool_calls.length > 0) {
|
|
2303
|
-
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"));
|
|
2304
|
-
while (kept.length > 1) {
|
|
2305
|
-
const next = kept[0];
|
|
2306
|
-
if (next?.role === "tool" && typeof next.tool_call_id === "string" && toolCallIds.has(next.tool_call_id)) {
|
|
2307
|
-
kept.shift();
|
|
2308
|
-
toolCallIds.delete(next.tool_call_id);
|
|
2309
|
-
if (toolCallIds.size === 0)
|
|
2310
|
-
break;
|
|
2311
|
-
} else {
|
|
2312
|
-
break;
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
return { ...payload, messages: kept };
|
|
2318
|
-
}
|
|
2319
2297
|
function toWireTool(tool) {
|
|
2320
2298
|
return {
|
|
2321
2299
|
type: "function",
|
|
@@ -2344,7 +2322,7 @@ function lastUserText(messages) {
|
|
|
2344
2322
|
}
|
|
2345
2323
|
function buildRequestBody(options, sessionId) {
|
|
2346
2324
|
const requestId = randomUUID();
|
|
2347
|
-
const spec =
|
|
2325
|
+
const spec = resolveQoderModelSpec(options.model);
|
|
2348
2326
|
const text = lastUserText(options.messages);
|
|
2349
2327
|
const maxTokens = spec?.maxTokens ?? QODER_DEFAULT_MAX_TOKENS;
|
|
2350
2328
|
const payload = {
|
|
@@ -2459,6 +2437,9 @@ function unwrapWireChunk(chunk) {
|
|
|
2459
2437
|
} catch {
|
|
2460
2438
|
}
|
|
2461
2439
|
const status = typeof record.statusCode === "string" ? record.statusCode : String(record.statusCodeValue);
|
|
2440
|
+
if (status === "PAYLOAD_TOO_LARGE") {
|
|
2441
|
+
throw new QoderApiError(`Qoder prompt is too long for this model's context window (${status}${detail ? `: ${detail}` : ""})`);
|
|
2442
|
+
}
|
|
2462
2443
|
throw new QoderApiError(`Qoder model server rejected the request (${status}${detail ? `: ${detail}` : ""})`);
|
|
2463
2444
|
}
|
|
2464
2445
|
try {
|
|
@@ -2545,12 +2526,7 @@ async function* streamQoderResponse(options) {
|
|
|
2545
2526
|
if (payload.messages.length === 0)
|
|
2546
2527
|
throw new QoderApiError("Qoder prompt is empty");
|
|
2547
2528
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
2548
|
-
const
|
|
2549
|
-
const body = JSON.stringify(fittedPayload);
|
|
2550
|
-
const bodyBytes = Buffer.byteLength(body);
|
|
2551
|
-
if (bodyBytes > QODER_WIRE_BODY_LIMIT_BYTES) {
|
|
2552
|
-
throw new QoderApiError(`Qoder prompt is too long for this model's context window (${bodyBytes} bytes > ${QODER_WIRE_BODY_LIMIT_BYTES} bytes)`);
|
|
2553
|
-
}
|
|
2529
|
+
const body = JSON.stringify(payload);
|
|
2554
2530
|
const origin = qoderWireUrl(process.env.QODER_MODEL_SERVER_HOST, options.endpoint);
|
|
2555
2531
|
const identity = readQoderSigningIdentity(qoderConfigDir()) ?? ANONYMOUS_SIGNING_IDENTITY;
|
|
2556
2532
|
const signed = signQoderInferRequest(origin, body, options.model, "system", identity, QODER_WIRE_VERSION);
|
|
@@ -2593,7 +2569,7 @@ async function* streamQoderResponse(options) {
|
|
|
2593
2569
|
}
|
|
2594
2570
|
}
|
|
2595
2571
|
function streamQoder(options) {
|
|
2596
|
-
const contextWindow =
|
|
2572
|
+
const contextWindow = resolveQoderModelSpec(options.model)?.contextWindow ?? QODER_DEFAULT_CONTEXT_WINDOW;
|
|
2597
2573
|
return recordUsage(streamQoderResponse(options), {
|
|
2598
2574
|
vendor: "qoder",
|
|
2599
2575
|
model: options.model,
|
|
@@ -2604,9 +2580,9 @@ function streamQoder(options) {
|
|
|
2604
2580
|
}
|
|
2605
2581
|
|
|
2606
2582
|
// ../dsh-llm-qoder/src/catalog.ts
|
|
2607
|
-
import { homedir as
|
|
2583
|
+
import { homedir as homedir4 } from "node:os";
|
|
2608
2584
|
import { join as join4 } from "node:path";
|
|
2609
|
-
function readQoderCatalogFile(home =
|
|
2585
|
+
function readQoderCatalogFile(home = homedir4(), env = process.env) {
|
|
2610
2586
|
const override = env[QODER_CATALOG_CACHE_DIR_ENV]?.trim();
|
|
2611
2587
|
const cacheDir = override || join4(home, ".pi", "agent", "cache", "ns-pi-provider");
|
|
2612
2588
|
return readQoderCatalog({ cacheDir });
|