crosscheck-mcp 0.2.26 → 0.2.28
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/README.md +4 -20
- package/dist/browser-ext.cjs +372 -381
- package/dist/browser-ext.cjs.map +1 -1
- package/dist/browser-ext.js +357 -366
- package/dist/browser-ext.js.map +1 -1
- package/dist/embed.cjs +374 -387
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.d.cts +58 -1
- package/dist/embed.d.ts +58 -1
- package/dist/embed.js +352 -368
- package/dist/embed.js.map +1 -1
- package/dist/node-stdio.cjs +398 -483
- package/dist/node-stdio.cjs.map +1 -1
- package/dist/node-stdio.d.cts +11 -47
- package/dist/node-stdio.d.ts +11 -47
- package/dist/node-stdio.js +369 -454
- package/dist/node-stdio.js.map +1 -1
- package/dist/pricing.json +90 -22
- package/dist/self-check.cjs.map +1 -1
- package/dist/self-check.js.map +1 -1
- package/package.json +7 -2
package/dist/node-stdio.cjs
CHANGED
|
@@ -958,8 +958,8 @@ __export(node_stdio_exports, {
|
|
|
958
958
|
});
|
|
959
959
|
module.exports = __toCommonJS(node_stdio_exports);
|
|
960
960
|
init_cjs_shims();
|
|
961
|
-
var
|
|
962
|
-
var
|
|
961
|
+
var import_node_fs20 = require("fs");
|
|
962
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
963
963
|
var import_node_url2 = require("url");
|
|
964
964
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
965
965
|
|
|
@@ -976,10 +976,10 @@ var StderrEmitter = class {
|
|
|
976
976
|
}
|
|
977
977
|
};
|
|
978
978
|
var FileEmitter = class {
|
|
979
|
-
constructor(
|
|
980
|
-
this.path =
|
|
979
|
+
constructor(path16) {
|
|
980
|
+
this.path = path16;
|
|
981
981
|
try {
|
|
982
|
-
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(
|
|
982
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(path16), { recursive: true });
|
|
983
983
|
} catch {
|
|
984
984
|
}
|
|
985
985
|
}
|
|
@@ -1012,13 +1012,13 @@ var NullEmitter = class {
|
|
|
1012
1012
|
function buildDefaultEmitter(env) {
|
|
1013
1013
|
const mode = (env["CROSSCHECK_EVENTS"] ?? "stderr").toLowerCase();
|
|
1014
1014
|
if (mode === "off") return new NullEmitter();
|
|
1015
|
-
const
|
|
1015
|
+
const path16 = env["CROSSCHECK_EVENTS_PATH"];
|
|
1016
1016
|
if (mode === "file") {
|
|
1017
|
-
return
|
|
1017
|
+
return path16 ? new FileEmitter(path16) : new NullEmitter();
|
|
1018
1018
|
}
|
|
1019
1019
|
if (mode === "both") {
|
|
1020
1020
|
const ems = [new StderrEmitter()];
|
|
1021
|
-
if (
|
|
1021
|
+
if (path16) ems.push(new FileEmitter(path16));
|
|
1022
1022
|
return new TeeEmitter(ems);
|
|
1023
1023
|
}
|
|
1024
1024
|
return new StderrEmitter();
|
|
@@ -1067,10 +1067,10 @@ function envelopeBytes(v) {
|
|
|
1067
1067
|
// src/core/pricing.ts
|
|
1068
1068
|
init_cjs_shims();
|
|
1069
1069
|
var import_node_fs2 = require("fs");
|
|
1070
|
-
function loadPricing(
|
|
1070
|
+
function loadPricing(path16) {
|
|
1071
1071
|
let raw;
|
|
1072
1072
|
try {
|
|
1073
|
-
raw = (0, import_node_fs2.readFileSync)(
|
|
1073
|
+
raw = (0, import_node_fs2.readFileSync)(path16, "utf8");
|
|
1074
1074
|
} catch {
|
|
1075
1075
|
return {};
|
|
1076
1076
|
}
|
|
@@ -1087,20 +1087,30 @@ function modelPricing(pricing, provider, model) {
|
|
|
1087
1087
|
const block = pricing[provider];
|
|
1088
1088
|
if (!block || typeof block !== "object" || Array.isArray(block)) return null;
|
|
1089
1089
|
const table = block;
|
|
1090
|
+
if (model.startsWith("_")) return null;
|
|
1090
1091
|
let entry = table[model];
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1092
|
+
let match = "exact";
|
|
1093
|
+
if (!isRates(entry)) {
|
|
1094
|
+
const best = Object.keys(table).filter((k) => !k.startsWith("_")).filter((k) => model.startsWith(k) && DATE_STAMP.test(model.slice(k.length))).sort((a, b) => b.length - a.length)[0];
|
|
1095
|
+
if (best !== void 0) {
|
|
1096
|
+
entry = table[best];
|
|
1097
|
+
match = "stamp";
|
|
1098
|
+
}
|
|
1094
1099
|
}
|
|
1095
|
-
if (!
|
|
1100
|
+
if (!isRates(entry)) return null;
|
|
1096
1101
|
const e = entry;
|
|
1097
1102
|
return {
|
|
1098
1103
|
prompt_per_1k: numberOrZero(e["prompt_per_1k"]),
|
|
1099
1104
|
completion_per_1k: numberOrZero(e["completion_per_1k"]),
|
|
1100
1105
|
cached_per_1k: numberOrZero(e["cached_per_1k"]),
|
|
1101
|
-
...e["estimated"] === true ? { estimated: true } : {}
|
|
1106
|
+
...e["estimated"] === true ? { estimated: true } : {},
|
|
1107
|
+
match
|
|
1102
1108
|
};
|
|
1103
1109
|
}
|
|
1110
|
+
var DATE_STAMP = /^-\d{8}$/;
|
|
1111
|
+
function isRates(v) {
|
|
1112
|
+
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
1113
|
+
}
|
|
1104
1114
|
function numberOrZero(v) {
|
|
1105
1115
|
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
1106
1116
|
if (typeof v === "string") {
|
|
@@ -1240,8 +1250,20 @@ var PROVIDER_CAPS = {
|
|
|
1240
1250
|
gemini: {
|
|
1241
1251
|
family: "gemini",
|
|
1242
1252
|
system_role: "separate",
|
|
1243
|
-
|
|
1244
|
-
|
|
1253
|
+
// No sampling, on any Gemini model. Ignored since 3.6 Flash and rejected
|
|
1254
|
+
// by upcoming models (Google, 2026-10). "model" means "omit for reasoning
|
|
1255
|
+
// models", and every Gemini model is reasoning-class (below) — so this
|
|
1256
|
+
// resolves to never, through the same rule the other providers use. The
|
|
1257
|
+
// adapter also never sends it; this keeps the record honest for anything
|
|
1258
|
+
// else that reads it.
|
|
1259
|
+
supports_temperature: "model",
|
|
1260
|
+
// EVERY Gemini model is reasoning-class. The old list named three
|
|
1261
|
+
// families and missed gemini-3.8-flash — the DEFAULT — so the default
|
|
1262
|
+
// model got the small non-reasoning budgets (768 tokens for an audit)
|
|
1263
|
+
// while spending up to ~480 tokens of each call thinking. Google's docs
|
|
1264
|
+
// say thinking cannot be switched off on current models, so a list of
|
|
1265
|
+
// which ones think is a list that can only ever be incomplete.
|
|
1266
|
+
reasoning_prefixes: ["gemini-"]
|
|
1245
1267
|
},
|
|
1246
1268
|
// Qwen's "Max" tier (qwen-v3.8, qwen-v3.7) is a standard instruct/chat
|
|
1247
1269
|
// model, not a visible-reasoning model like QwQ — normal temperature and
|
|
@@ -1366,6 +1388,74 @@ function httpFailureToProviderError(provider, status, bodyText, retryAfterS, mod
|
|
|
1366
1388
|
);
|
|
1367
1389
|
}
|
|
1368
1390
|
|
|
1391
|
+
// src/providers/network-errors.ts
|
|
1392
|
+
init_cjs_shims();
|
|
1393
|
+
function codeOf(e) {
|
|
1394
|
+
if (!e || typeof e !== "object") return null;
|
|
1395
|
+
const c = e.code;
|
|
1396
|
+
return typeof c === "string" && c.length > 0 ? c : null;
|
|
1397
|
+
}
|
|
1398
|
+
function rootCause(e, depth = 0) {
|
|
1399
|
+
if (depth > 5 || !e || typeof e !== "object") return e;
|
|
1400
|
+
const o = e;
|
|
1401
|
+
if (Array.isArray(o.errors) && o.errors.length > 0) {
|
|
1402
|
+
const coded = o.errors.find((x) => codeOf(x) !== null);
|
|
1403
|
+
return rootCause(coded ?? o.errors[0], depth + 1);
|
|
1404
|
+
}
|
|
1405
|
+
if (o.cause !== void 0 && o.cause !== null) return rootCause(o.cause, depth + 1);
|
|
1406
|
+
return e;
|
|
1407
|
+
}
|
|
1408
|
+
var BY_CODE = {
|
|
1409
|
+
ENOTFOUND: { cause: "dns", detail: "the provider's hostname did not resolve \u2014 DNS, or a typo'd base URL", transient: false, kind: "network" },
|
|
1410
|
+
EAI_AGAIN: { cause: "dns", detail: "DNS lookup failed temporarily \u2014 resolver or network is flapping", transient: true, kind: "network" },
|
|
1411
|
+
ECONNREFUSED: { cause: "refused", detail: "the connection was refused \u2014 nothing is listening, or a proxy blocked it", transient: false, kind: "network" },
|
|
1412
|
+
ECONNRESET: { cause: "reset", detail: "the peer closed the connection mid-request \u2014 flaky path, or an upstream error behind a proxy", transient: true, kind: "network" },
|
|
1413
|
+
EPIPE: { cause: "reset", detail: "the connection closed while we were still writing", transient: true, kind: "network" },
|
|
1414
|
+
ETIMEDOUT: { cause: "connect_timeout", detail: "the connection timed out before it was established", transient: true, kind: "timeout" },
|
|
1415
|
+
EHOSTUNREACH: { cause: "unreachable", detail: "no route to the provider \u2014 VPN, or offline", transient: true, kind: "network" },
|
|
1416
|
+
ENETUNREACH: { cause: "unreachable", detail: "the network is unreachable \u2014 offline, or a routing change", transient: true, kind: "network" },
|
|
1417
|
+
ENETDOWN: { cause: "unreachable", detail: "the local network is down", transient: true, kind: "network" },
|
|
1418
|
+
EPROTO: { cause: "tls", detail: "the TLS handshake failed \u2014 an intercepting proxy, or a protocol mismatch", transient: false, kind: "network" },
|
|
1419
|
+
ERR_TLS_CERT_ALTNAME_INVALID: { cause: "tls", detail: "the certificate did not match the hostname \u2014 traffic is being intercepted", transient: false, kind: "network" },
|
|
1420
|
+
CERT_HAS_EXPIRED: { cause: "tls", detail: "the server certificate has expired, or this machine's clock is wrong", transient: false, kind: "network" },
|
|
1421
|
+
UNABLE_TO_VERIFY_LEAF_SIGNATURE: { cause: "tls", detail: "the certificate chain could not be verified \u2014 a corporate proxy's root is probably not trusted here", transient: false, kind: "network" },
|
|
1422
|
+
UND_ERR_CONNECT_TIMEOUT: { cause: "connect_timeout", detail: "could not open a connection within the timeout \u2014 firewall, or the host is down", transient: true, kind: "timeout" },
|
|
1423
|
+
UND_ERR_HEADERS_TIMEOUT: { cause: "read_timeout", detail: "connected, but the provider sent no response headers in time \u2014 it is overloaded or thinking too long", transient: true, kind: "timeout" },
|
|
1424
|
+
UND_ERR_BODY_TIMEOUT: { cause: "read_timeout", detail: "the response body stalled mid-stream", transient: true, kind: "timeout" },
|
|
1425
|
+
UND_ERR_SOCKET: { cause: "reset", detail: "the socket closed unexpectedly", transient: true, kind: "network" },
|
|
1426
|
+
UND_ERR_ABORTED: { cause: "aborted", detail: "the request was cancelled", transient: false, kind: "network" },
|
|
1427
|
+
ABORT_ERR: { cause: "aborted", detail: "the request was cancelled", transient: false, kind: "network" }
|
|
1428
|
+
};
|
|
1429
|
+
function diagnoseNetworkError(e) {
|
|
1430
|
+
const root = rootCause(e);
|
|
1431
|
+
const code = codeOf(root) ?? codeOf(e);
|
|
1432
|
+
if (code && BY_CODE[code]) return { ...BY_CODE[code], code };
|
|
1433
|
+
const name = root && typeof root === "object" ? root.name : void 0;
|
|
1434
|
+
if (name === "AbortError" || name === "TimeoutError") {
|
|
1435
|
+
return {
|
|
1436
|
+
cause: name === "TimeoutError" ? "read_timeout" : "aborted",
|
|
1437
|
+
code: code ?? String(name),
|
|
1438
|
+
detail: name === "TimeoutError" ? "the request exceeded its timeout" : "the request was cancelled",
|
|
1439
|
+
transient: name === "TimeoutError",
|
|
1440
|
+
kind: name === "TimeoutError" ? "timeout" : "network"
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
return {
|
|
1444
|
+
cause: "unknown",
|
|
1445
|
+
code,
|
|
1446
|
+
detail: code ? `the connection failed with ${code}` : "the connection failed and the underlying error carried no code",
|
|
1447
|
+
transient: true,
|
|
1448
|
+
kind: "network"
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
function looksLikeNetworkFailure(d) {
|
|
1452
|
+
return d.code !== null || d.cause !== "unknown";
|
|
1453
|
+
}
|
|
1454
|
+
function networkErrorMessage(provider, d) {
|
|
1455
|
+
const code = d.code ? ` [${d.code}]` : "";
|
|
1456
|
+
return `${provider}: ${d.detail}${code}`;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1369
1459
|
// src/providers/retry.ts
|
|
1370
1460
|
init_cjs_shims();
|
|
1371
1461
|
var override = null;
|
|
@@ -1697,7 +1787,11 @@ async function sendAnthropic(args) {
|
|
|
1697
1787
|
try {
|
|
1698
1788
|
respLike = await doFetch(url, init);
|
|
1699
1789
|
} catch (e) {
|
|
1700
|
-
|
|
1790
|
+
const d = diagnoseNetworkError(e);
|
|
1791
|
+
if (!looksLikeNetworkFailure(d)) throw e;
|
|
1792
|
+
throw new ProviderError(d.kind, networkErrorMessage("anthropic", d), {
|
|
1793
|
+
transient: d.transient
|
|
1794
|
+
});
|
|
1701
1795
|
}
|
|
1702
1796
|
const status = respLike.status;
|
|
1703
1797
|
if (status >= 200 && status < 300) {
|
|
@@ -1771,6 +1865,11 @@ function jsonSchemaToGeminiSchema(schema) {
|
|
|
1771
1865
|
}
|
|
1772
1866
|
return out;
|
|
1773
1867
|
}
|
|
1868
|
+
var GEMINI_THINKING_HEADROOM_TOKENS = 16384;
|
|
1869
|
+
function thinkingHeadroom() {
|
|
1870
|
+
const raw = Number(process.env["CROSSCHECK_GEMINI_THINKING_HEADROOM_TOKENS"]);
|
|
1871
|
+
return Number.isFinite(raw) && raw >= 0 ? Math.trunc(raw) : GEMINI_THINKING_HEADROOM_TOKENS;
|
|
1872
|
+
}
|
|
1774
1873
|
function buildGeminiRequest(opts) {
|
|
1775
1874
|
const contents = [];
|
|
1776
1875
|
let systemText = null;
|
|
@@ -1789,8 +1888,9 @@ function buildGeminiRequest(opts) {
|
|
|
1789
1888
|
const body = {
|
|
1790
1889
|
contents,
|
|
1791
1890
|
generationConfig: {
|
|
1792
|
-
|
|
1793
|
-
|
|
1891
|
+
// Answer budget + thinking headroom. No temperature / topP / topK /
|
|
1892
|
+
// thinkingBudget, on any model — see the header note.
|
|
1893
|
+
maxOutputTokens: opts.maxTokens + thinkingHeadroom()
|
|
1794
1894
|
}
|
|
1795
1895
|
};
|
|
1796
1896
|
if (systemText !== null && systemText !== "") {
|
|
@@ -1800,8 +1900,8 @@ function buildGeminiRequest(opts) {
|
|
|
1800
1900
|
body.generationConfig.responseMimeType = "application/json";
|
|
1801
1901
|
body.generationConfig.responseSchema = jsonSchemaToGeminiSchema(opts.jsonSchema);
|
|
1802
1902
|
}
|
|
1803
|
-
const url = `${GEMINI_API_URL_BASE}/${encodeURIComponent(opts.model)}:generateContent
|
|
1804
|
-
return { url, headers: {}, body };
|
|
1903
|
+
const url = `${GEMINI_API_URL_BASE}/${encodeURIComponent(opts.model)}:generateContent`;
|
|
1904
|
+
return { url, headers: { "x-goog-api-key": opts.apiKey }, body };
|
|
1805
1905
|
}
|
|
1806
1906
|
function parseGeminiResponse(opts) {
|
|
1807
1907
|
const r = opts.resp ?? {};
|
|
@@ -1831,16 +1931,19 @@ function parseGeminiResponse(opts) {
|
|
|
1831
1931
|
}
|
|
1832
1932
|
try {
|
|
1833
1933
|
const first = cands[0];
|
|
1834
|
-
const
|
|
1835
|
-
const
|
|
1934
|
+
const finishReason = typeof first["finishReason"] === "string" ? first["finishReason"] : void 0;
|
|
1935
|
+
const content = first["content"] ?? {};
|
|
1936
|
+
const parts = Array.isArray(content["parts"]) ? content["parts"] : [];
|
|
1836
1937
|
let text = "";
|
|
1837
1938
|
for (const p of parts) {
|
|
1838
1939
|
if (p && typeof p === "object") {
|
|
1839
|
-
const
|
|
1940
|
+
const part = p;
|
|
1941
|
+
if (part["thought"] === true) continue;
|
|
1942
|
+
const t = part["text"];
|
|
1840
1943
|
if (typeof t === "string") text += t;
|
|
1841
1944
|
}
|
|
1842
1945
|
}
|
|
1843
|
-
return { text, usage };
|
|
1946
|
+
return { text, usage, ...finishReason ? { finishReason } : {} };
|
|
1844
1947
|
} catch (e) {
|
|
1845
1948
|
throw new ProviderError(
|
|
1846
1949
|
"parse",
|
|
@@ -1869,7 +1972,8 @@ async function sendGemini(args) {
|
|
|
1869
1972
|
apiKey: args.apiKey,
|
|
1870
1973
|
messages: args.messages,
|
|
1871
1974
|
maxTokens: args.maxTokens,
|
|
1872
|
-
|
|
1975
|
+
// args.temperature is deliberately NOT forwarded: Gemini ignores it and
|
|
1976
|
+
// upcoming models reject it. See the header note.
|
|
1873
1977
|
...args.jsonSchema ? { jsonSchema: args.jsonSchema } : {}
|
|
1874
1978
|
});
|
|
1875
1979
|
const doFetch = args.fetchImpl ?? globalThis.fetch;
|
|
@@ -1884,7 +1988,11 @@ async function sendGemini(args) {
|
|
|
1884
1988
|
try {
|
|
1885
1989
|
respLike = await doFetch(url, init);
|
|
1886
1990
|
} catch (e) {
|
|
1887
|
-
|
|
1991
|
+
const d = diagnoseNetworkError(e);
|
|
1992
|
+
if (!looksLikeNetworkFailure(d)) throw e;
|
|
1993
|
+
throw new ProviderError(d.kind, networkErrorMessage("gemini", d), {
|
|
1994
|
+
transient: d.transient
|
|
1995
|
+
});
|
|
1888
1996
|
}
|
|
1889
1997
|
const status = respLike.status;
|
|
1890
1998
|
if (status >= 200 && status < 300) {
|
|
@@ -1894,11 +2002,18 @@ async function sendGemini(args) {
|
|
|
1894
2002
|
} catch (e) {
|
|
1895
2003
|
throw new ProviderError("parse", `gemini: response body not JSON: ${e.message}`);
|
|
1896
2004
|
}
|
|
1897
|
-
const { text, usage } = parseGeminiResponse({
|
|
2005
|
+
const { text, usage, finishReason } = parseGeminiResponse({
|
|
1898
2006
|
resp: parsed,
|
|
1899
2007
|
model: args.model,
|
|
1900
2008
|
purpose: args.purpose ?? "worker"
|
|
1901
2009
|
});
|
|
2010
|
+
if (text.trim() === "" && finishReason === "MAX_TOKENS") {
|
|
2011
|
+
throw new ProviderError(
|
|
2012
|
+
"parse",
|
|
2013
|
+
`gemini: the answer was cut off before any visible text \u2014 thinking used the whole output budget (${usage.completion_tokens} tokens). Raise CROSSCHECK_GEMINI_THINKING_HEADROOM_TOKENS or the purpose's budget.`,
|
|
2014
|
+
{ transient: false }
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
1902
2017
|
return { text, attempts: 1, usage: applyPricing2(usage, args.pricing) };
|
|
1903
2018
|
}
|
|
1904
2019
|
const bodyText = await respLike.text().catch(() => "");
|
|
@@ -2066,7 +2181,11 @@ async function sendOpenAICompatible(args) {
|
|
|
2066
2181
|
try {
|
|
2067
2182
|
respLike = await doFetch(url, init);
|
|
2068
2183
|
} catch (e) {
|
|
2069
|
-
|
|
2184
|
+
const d = diagnoseNetworkError(e);
|
|
2185
|
+
if (!looksLikeNetworkFailure(d)) throw e;
|
|
2186
|
+
throw new ProviderError(d.kind, networkErrorMessage(args.provider, d), {
|
|
2187
|
+
transient: d.transient
|
|
2188
|
+
});
|
|
2070
2189
|
}
|
|
2071
2190
|
const status = respLike.status;
|
|
2072
2191
|
if (status >= 200 && status < 300) {
|
|
@@ -2094,7 +2213,7 @@ async function sendOpenAICompatible(args) {
|
|
|
2094
2213
|
// src/providers/registry.ts
|
|
2095
2214
|
var DEFAULT_MODELS = {
|
|
2096
2215
|
anthropic: "claude-opus-5-5",
|
|
2097
|
-
openai: "gpt-
|
|
2216
|
+
openai: "gpt-6-sol",
|
|
2098
2217
|
xai: "grok-4-latest",
|
|
2099
2218
|
mistral: "mistral-large-latest",
|
|
2100
2219
|
groq: "llama-3.3-70b-versatile",
|
|
@@ -2251,50 +2370,6 @@ init_cjs_shims();
|
|
|
2251
2370
|
var import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
2252
2371
|
var import_types9 = require("@modelcontextprotocol/sdk/types.js");
|
|
2253
2372
|
|
|
2254
|
-
// src/bridge/index.ts
|
|
2255
|
-
init_cjs_shims();
|
|
2256
|
-
|
|
2257
|
-
// src/bridge/proxy-tools.ts
|
|
2258
|
-
init_cjs_shims();
|
|
2259
|
-
function buildPythonProxies(bridge) {
|
|
2260
|
-
const proxies = /* @__PURE__ */ new Map();
|
|
2261
|
-
for (const name of bridge.toolNames) {
|
|
2262
|
-
proxies.set(name, makeProxy(bridge, name));
|
|
2263
|
-
}
|
|
2264
|
-
return proxies;
|
|
2265
|
-
}
|
|
2266
|
-
function makeProxy(bridge, name) {
|
|
2267
|
-
return {
|
|
2268
|
-
name,
|
|
2269
|
-
description: `(forwarded to Python crosscheck-agent) ${name}`,
|
|
2270
|
-
// We don't carry the per-tool input schema across the bridge in
|
|
2271
|
-
// route-all mode — the TS server is a transparent forwarder, so
|
|
2272
|
-
// arg validation happens on the Python side. inputSchema is left
|
|
2273
|
-
// permissive; the Python validator throws structured errors that
|
|
2274
|
-
// tunnel back through `callTool()`.
|
|
2275
|
-
inputSchema: {
|
|
2276
|
-
type: "object",
|
|
2277
|
-
additionalProperties: true,
|
|
2278
|
-
description: `Forwarded to Python \u2014 see Python tool '${name}' for full schema.`
|
|
2279
|
-
},
|
|
2280
|
-
handler: async (args) => {
|
|
2281
|
-
const r = await bridge.callTool(name, args);
|
|
2282
|
-
if (!r.content.length) {
|
|
2283
|
-
return {};
|
|
2284
|
-
}
|
|
2285
|
-
const first = r.content[0];
|
|
2286
|
-
if (first.type === "text" && first.text) {
|
|
2287
|
-
try {
|
|
2288
|
-
return JSON.parse(first.text);
|
|
2289
|
-
} catch {
|
|
2290
|
-
return { text: first.text };
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
return { content: r.content };
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
2373
|
// src/instructions.ts
|
|
2299
2374
|
init_cjs_shims();
|
|
2300
2375
|
var ROUTABLE_TOOLS = [
|
|
@@ -2358,13 +2433,13 @@ Examples:
|
|
|
2358
2433
|
This convention is opt-in: a user message without the \`xc\`/\`XC\` prefix should NOT be auto-routed here. Pick tools normally based on the conversation.
|
|
2359
2434
|
|
|
2360
2435
|
Reasoning upgrade (Fable 5):
|
|
2361
|
-
- The reasoning tools (plan, solve, debate, orchestrate, audit, triangulate) can bump their lead reasoning seat to Fable 5 \u2014 Anthropic's newest thinking model \u2014 instead of the default Opus
|
|
2436
|
+
- The reasoning tools (plan, solve, debate, orchestrate, audit, triangulate) can bump their lead reasoning seat to Fable 5 \u2014 Anthropic's newest thinking model \u2014 instead of the default Opus 5.5. Only that one seat is upgraded; other panel seats stay on their normal models, so premium tokens are not wasted.
|
|
2362
2437
|
- When a tool result includes a "suggested_upgrade" block, the engine judged the task reasoning-heavy. Surface it: ask the user something like "This looks reasoning-heavy \u2014 bump the lead seat to Fable 5 (higher quality, higher cost)?" If they say yes, re-run the SAME tool with reasoning:"max" added. Do NOT upgrade silently.
|
|
2363
2438
|
- If the user explicitly asks for the best/deepest reasoning up front, pass reasoning:"max" directly. A result with reasoning_upgrade.applied = true confirms Fable 5 was used.
|
|
2364
2439
|
|
|
2365
2440
|
Super mode (confer / debate / plan / triangulate / list_providers only \u2014 internal team trial, do not mention this outside the team or write it into any docs/help text):
|
|
2366
2441
|
- When the token immediately after the tool name is \`super\` (e.g. \`xc confer super what's the best caching strategy?\`), pass \`super: true\` in that tool's args and treat everything after \`super\` as the normal primary-argument text (same slot as usual \u2014 \`question\`/\`topic\`/\`goal\`). Example: \`xc confer super what's the best caching strategy?\` \u2192 \`mcp__crosscheck__confer({ question: "what's the best caching strategy?", super: true })\`.
|
|
2367
|
-
- This swaps the panel to a fixed top-tier lineup (one flagship model per provider, restricted to providers the user actually has keys for) and triples the completion-token budget. For debate/plan/triangulate it also forces the Fable 5 +
|
|
2442
|
+
- This swaps the panel to a fixed top-tier lineup (one flagship model per provider, restricted to providers the user actually has keys for) and triples the completion-token budget. For debate/plan/triangulate it also forces the Fable 5 + OpenAI co-reasoner synthesis path automatically \u2014 no need to also pass reasoning:"max".
|
|
2368
2443
|
- A result with a "super_mode" block confirms it ran; show the panel it used.
|
|
2369
2444
|
- \`xc list_providers super\` (no text after \`super\` \u2014 list_providers takes no other args) \u2192 \`mcp__crosscheck__list_providers({ super: true })\`. Shows the top-tier lineup and which of those models are actually available, instead of the normal default-model listing.
|
|
2370
2445
|
|
|
@@ -2381,7 +2456,7 @@ var import_zod = require("zod");
|
|
|
2381
2456
|
// src/server-meta.ts
|
|
2382
2457
|
init_cjs_shims();
|
|
2383
2458
|
var SERVER_NAME = "crosscheck-agent";
|
|
2384
|
-
var SERVER_VERSION = true ? "0.2.
|
|
2459
|
+
var SERVER_VERSION = true ? "0.2.28" : "0.0.0-dev";
|
|
2385
2460
|
|
|
2386
2461
|
// src/tools/audit.ts
|
|
2387
2462
|
init_cjs_shims();
|
|
@@ -2448,27 +2523,27 @@ function extractJson(text) {
|
|
|
2448
2523
|
|
|
2449
2524
|
// src/core/json-schema.ts
|
|
2450
2525
|
init_cjs_shims();
|
|
2451
|
-
function validateSchema(value, schema,
|
|
2526
|
+
function validateSchema(value, schema, path16 = "") {
|
|
2452
2527
|
const errs = [];
|
|
2453
2528
|
if ("anyOf" in schema) {
|
|
2454
2529
|
const subs = schema["anyOf"].map(
|
|
2455
|
-
(s) => validateSchema(value, s,
|
|
2530
|
+
(s) => validateSchema(value, s, path16)
|
|
2456
2531
|
);
|
|
2457
2532
|
if (!subs.some((e) => e.length === 0)) {
|
|
2458
|
-
errs.push(`${
|
|
2533
|
+
errs.push(`${path16 || "<root>"}: did not match anyOf`);
|
|
2459
2534
|
}
|
|
2460
2535
|
return errs;
|
|
2461
2536
|
}
|
|
2462
2537
|
if ("oneOf" in schema) {
|
|
2463
|
-
const passed = schema["oneOf"].filter((s) => validateSchema(value, s,
|
|
2538
|
+
const passed = schema["oneOf"].filter((s) => validateSchema(value, s, path16).length === 0).length;
|
|
2464
2539
|
if (passed !== 1) {
|
|
2465
|
-
errs.push(`${
|
|
2540
|
+
errs.push(`${path16 || "<root>"}: matched ${passed} of oneOf, expected 1`);
|
|
2466
2541
|
}
|
|
2467
2542
|
return errs;
|
|
2468
2543
|
}
|
|
2469
2544
|
if ("const" in schema && !deepEqual(value, schema["const"])) {
|
|
2470
2545
|
errs.push(
|
|
2471
|
-
`${
|
|
2546
|
+
`${path16 || "<root>"}: expected const ${pyRepr(schema["const"])}, got ${pyRepr(value)}`
|
|
2472
2547
|
);
|
|
2473
2548
|
return errs;
|
|
2474
2549
|
}
|
|
@@ -2478,7 +2553,7 @@ function validateSchema(value, schema, path15 = "") {
|
|
|
2478
2553
|
const ok = types.some((tt) => matchesType(value, String(tt)));
|
|
2479
2554
|
if (!ok) {
|
|
2480
2555
|
errs.push(
|
|
2481
|
-
`${
|
|
2556
|
+
`${path16 || "<root>"}: expected type ${pyReprType(t)}, got ${pyTypeName(value)}`
|
|
2482
2557
|
);
|
|
2483
2558
|
return errs;
|
|
2484
2559
|
}
|
|
@@ -2487,29 +2562,29 @@ function validateSchema(value, schema, path15 = "") {
|
|
|
2487
2562
|
if ("enum" in schema) {
|
|
2488
2563
|
const en = schema["enum"];
|
|
2489
2564
|
if (!en.some((x) => deepEqual(x, value))) {
|
|
2490
|
-
errs.push(`${
|
|
2565
|
+
errs.push(`${path16 || "<root>"}: value ${pyRepr(value)} not in enum`);
|
|
2491
2566
|
}
|
|
2492
2567
|
}
|
|
2493
2568
|
if ("minLength" in schema && value.length < schema["minLength"]) {
|
|
2494
|
-
errs.push(`${
|
|
2569
|
+
errs.push(`${path16 || "<root>"}: shorter than minLength ${schema["minLength"]}`);
|
|
2495
2570
|
}
|
|
2496
2571
|
}
|
|
2497
2572
|
if (typeof value === "number" && !Number.isNaN(value)) {
|
|
2498
2573
|
if ("minimum" in schema && value < schema["minimum"]) {
|
|
2499
|
-
errs.push(`${
|
|
2574
|
+
errs.push(`${path16 || "<root>"}: ${value} < minimum ${schema["minimum"]}`);
|
|
2500
2575
|
}
|
|
2501
2576
|
if ("maximum" in schema && value > schema["maximum"]) {
|
|
2502
|
-
errs.push(`${
|
|
2577
|
+
errs.push(`${path16 || "<root>"}: ${value} > maximum ${schema["maximum"]}`);
|
|
2503
2578
|
}
|
|
2504
2579
|
}
|
|
2505
2580
|
if (Array.isArray(value)) {
|
|
2506
2581
|
if ("minItems" in schema && value.length < schema["minItems"]) {
|
|
2507
|
-
errs.push(`${
|
|
2582
|
+
errs.push(`${path16 || "<root>"}: fewer items than minItems ${schema["minItems"]}`);
|
|
2508
2583
|
}
|
|
2509
2584
|
const itemSchema = schema["items"];
|
|
2510
2585
|
if (isObj(itemSchema)) {
|
|
2511
2586
|
for (let i = 0; i < value.length; i++) {
|
|
2512
|
-
errs.push(...validateSchema(value[i], itemSchema, `${
|
|
2587
|
+
errs.push(...validateSchema(value[i], itemSchema, `${path16}[${i}]`));
|
|
2513
2588
|
}
|
|
2514
2589
|
}
|
|
2515
2590
|
}
|
|
@@ -2518,19 +2593,19 @@ function validateSchema(value, schema, path15 = "") {
|
|
|
2518
2593
|
const required = schema["required"] ?? [];
|
|
2519
2594
|
for (const r of required) {
|
|
2520
2595
|
if (!(r in value)) {
|
|
2521
|
-
errs.push(`${
|
|
2596
|
+
errs.push(`${path16 || "<root>"}: missing required key ${pyRepr(r)}`);
|
|
2522
2597
|
}
|
|
2523
2598
|
}
|
|
2524
2599
|
if (schema["additionalProperties"] === false) {
|
|
2525
2600
|
for (const k of Object.keys(value)) {
|
|
2526
2601
|
if (!(k in props)) {
|
|
2527
|
-
errs.push(`${
|
|
2602
|
+
errs.push(`${path16 || "<root>"}: unknown key ${pyRepr(k)}`);
|
|
2528
2603
|
}
|
|
2529
2604
|
}
|
|
2530
2605
|
}
|
|
2531
2606
|
for (const [k, v] of Object.entries(value)) {
|
|
2532
2607
|
const ps = props[k];
|
|
2533
|
-
if (ps) errs.push(...validateSchema(v, ps,
|
|
2608
|
+
if (ps) errs.push(...validateSchema(v, ps, path16 ? `${path16}.${k}` : k));
|
|
2534
2609
|
}
|
|
2535
2610
|
}
|
|
2536
2611
|
return errs;
|
|
@@ -2612,6 +2687,34 @@ function pyReprType(t) {
|
|
|
2612
2687
|
|
|
2613
2688
|
// src/core/usage.ts
|
|
2614
2689
|
init_cjs_shims();
|
|
2690
|
+
|
|
2691
|
+
// src/core/session.ts
|
|
2692
|
+
init_cjs_shims();
|
|
2693
|
+
var import_node_crypto2 = require("crypto");
|
|
2694
|
+
var processSessionId = null;
|
|
2695
|
+
var startedAt = null;
|
|
2696
|
+
function engineSessionId() {
|
|
2697
|
+
if (processSessionId === null) {
|
|
2698
|
+
processSessionId = (0, import_node_crypto2.randomUUID)();
|
|
2699
|
+
startedAt = Date.now();
|
|
2700
|
+
}
|
|
2701
|
+
return processSessionId;
|
|
2702
|
+
}
|
|
2703
|
+
function resolveSessionId(callerSupplied) {
|
|
2704
|
+
const trimmed = typeof callerSupplied === "string" ? callerSupplied.trim() : "";
|
|
2705
|
+
return trimmed.length > 0 ? trimmed : engineSessionId();
|
|
2706
|
+
}
|
|
2707
|
+
function localSessionRecordingEnabled(env = globalThis.process?.env ?? {}) {
|
|
2708
|
+
const v = (env["CROSSCHECK_RECORD_SESSIONS"] ?? "").trim().toLowerCase();
|
|
2709
|
+
return !["0", "false", "off", "no"].includes(v);
|
|
2710
|
+
}
|
|
2711
|
+
function recordingSessionId(callerSupplied) {
|
|
2712
|
+
if (localSessionRecordingEnabled()) return resolveSessionId(callerSupplied);
|
|
2713
|
+
const trimmed = typeof callerSupplied === "string" ? callerSupplied.trim() : "";
|
|
2714
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
// src/core/usage.ts
|
|
2615
2718
|
function emptyUsage(provider, model, purpose = "worker") {
|
|
2616
2719
|
return {
|
|
2617
2720
|
provider,
|
|
@@ -2716,11 +2819,11 @@ function withCommas(n) {
|
|
|
2716
2819
|
function renderRunSummary(opts) {
|
|
2717
2820
|
const endedAt = opts.endedAtS ?? Math.trunc(Date.now() / 1e3);
|
|
2718
2821
|
let scope = "call";
|
|
2719
|
-
let
|
|
2822
|
+
let startedAt2 = null;
|
|
2720
2823
|
let rows = [];
|
|
2721
2824
|
if (opts.sessionScope && opts.sessionScope.rows.length > 0) {
|
|
2722
2825
|
scope = "session";
|
|
2723
|
-
|
|
2826
|
+
startedAt2 = opts.sessionScope.startedAt;
|
|
2724
2827
|
rows = opts.sessionScope.rows.map((r) => ({ ...r }));
|
|
2725
2828
|
} else {
|
|
2726
2829
|
const byPurpose = /* @__PURE__ */ new Map();
|
|
@@ -2751,6 +2854,7 @@ function renderRunSummary(opts) {
|
|
|
2751
2854
|
row.cpu_ms += a.cpu_ms ?? 0;
|
|
2752
2855
|
if (a.cache_hit) row.cache_hits += 1;
|
|
2753
2856
|
if (a.error) row.errors += 1;
|
|
2857
|
+
if (a.usage?.estimated) row.estimated = true;
|
|
2754
2858
|
}
|
|
2755
2859
|
rows = Array.from(byPurpose.values());
|
|
2756
2860
|
}
|
|
@@ -2763,16 +2867,18 @@ function renderRunSummary(opts) {
|
|
|
2763
2867
|
wall_ms: rows.reduce((s, r) => s + r.wall_ms, 0),
|
|
2764
2868
|
cpu_ms: rows.reduce((s, r) => s + r.cpu_ms, 0),
|
|
2765
2869
|
cache_hits: rows.reduce((s, r) => s + r.cache_hits, 0),
|
|
2766
|
-
errors: rows.reduce((s, r) => s + r.errors, 0)
|
|
2870
|
+
errors: rows.reduce((s, r) => s + r.errors, 0),
|
|
2871
|
+
...rows.some((r) => r.estimated) ? { estimated: true } : {}
|
|
2767
2872
|
};
|
|
2768
2873
|
const titleLeft = scope === "session" ? `session: ${opts.sessionId ?? ""}` : `call: ${opts.toolName}`;
|
|
2769
|
-
const
|
|
2874
|
+
const costText = totals.estimated ? `$${totals.cost_usd.toFixed(4)}+ (some calls unpriced)` : `$${totals.cost_usd.toFixed(4)}`;
|
|
2875
|
+
const header = `${titleLeft} (${totals.calls} calls, ${withCommas(totals.total_tokens)} tokens, ${costText}, ${(totals.wall_ms / 1e3).toFixed(1)}s wall, ${(totals.cpu_ms / 1e3).toFixed(3)}s cpu)`;
|
|
2770
2876
|
const bodyLines = [];
|
|
2771
2877
|
for (let i = 0; i < rows.length; i++) {
|
|
2772
2878
|
const r = rows[i];
|
|
2773
2879
|
const glyph = i === rows.length - 1 ? "`-" : "|-";
|
|
2774
2880
|
bodyLines.push(
|
|
2775
|
-
`${glyph} purpose: ${r.purpose} (calls=${r.calls} tokens=${withCommas(r.total_tokens)} cost=$${r.cost_usd.toFixed(4)} wall=${(r.wall_ms / 1e3).toFixed(1)}s cpu=${(r.cpu_ms / 1e3).toFixed(3)}s)`
|
|
2881
|
+
`${glyph} purpose: ${r.purpose} (calls=${r.calls} tokens=${withCommas(r.total_tokens)} cost=$${r.cost_usd.toFixed(4)}${r.estimated ? "+" : ""} wall=${(r.wall_ms / 1e3).toFixed(1)}s cpu=${(r.cpu_ms / 1e3).toFixed(3)}s)`
|
|
2776
2882
|
);
|
|
2777
2883
|
}
|
|
2778
2884
|
const callByModel = rollupSpendByModel(
|
|
@@ -2820,7 +2926,7 @@ function renderRunSummary(opts) {
|
|
|
2820
2926
|
tool: opts.toolName,
|
|
2821
2927
|
scope,
|
|
2822
2928
|
currency: "USD",
|
|
2823
|
-
started_at:
|
|
2929
|
+
started_at: startedAt2,
|
|
2824
2930
|
ended_at: endedAt,
|
|
2825
2931
|
rows,
|
|
2826
2932
|
totals,
|
|
@@ -2945,14 +3051,15 @@ async function attachUsageBlock(result, answers, opts) {
|
|
|
2945
3051
|
delete result["_suppress_run_summary"];
|
|
2946
3052
|
}
|
|
2947
3053
|
async function appendUsageLog(storage, sessionId, toolName, answers, nowS) {
|
|
2948
|
-
|
|
3054
|
+
const sid = recordingSessionId(sessionId);
|
|
3055
|
+
if (!sid || answers.length === 0) return;
|
|
2949
3056
|
const now = nowS ?? Math.trunc(Date.now() / 1e3);
|
|
2950
3057
|
const rows = [];
|
|
2951
3058
|
for (const a of answers) {
|
|
2952
3059
|
const u = a.usage;
|
|
2953
3060
|
if (!u || typeof u.provider !== "string" || u.provider === "") continue;
|
|
2954
3061
|
rows.push({
|
|
2955
|
-
session_id:
|
|
3062
|
+
session_id: sid,
|
|
2956
3063
|
ts: now,
|
|
2957
3064
|
tool: toolName,
|
|
2958
3065
|
purpose: u.purpose ?? "worker",
|
|
@@ -2975,13 +3082,14 @@ async function appendUsageLog(storage, sessionId, toolName, answers, nowS) {
|
|
|
2975
3082
|
}
|
|
2976
3083
|
}
|
|
2977
3084
|
async function recordSessionCall(storage, sessionId, answers, wallMs, cpuMs, nowS) {
|
|
2978
|
-
|
|
3085
|
+
const sid = recordingSessionId(sessionId);
|
|
3086
|
+
if (!sid) return;
|
|
2979
3087
|
const now = nowS ?? Math.trunc(Date.now() / 1e3);
|
|
2980
3088
|
try {
|
|
2981
|
-
let existing = await storage.getSession(
|
|
3089
|
+
let existing = await storage.getSession(sid);
|
|
2982
3090
|
if (!existing) {
|
|
2983
3091
|
await storage.upsertSession({
|
|
2984
|
-
session_id:
|
|
3092
|
+
session_id: sid,
|
|
2985
3093
|
started_at: now,
|
|
2986
3094
|
last_at: now,
|
|
2987
3095
|
calls: 0,
|
|
@@ -2994,7 +3102,7 @@ async function recordSessionCall(storage, sessionId, answers, wallMs, cpuMs, now
|
|
|
2994
3102
|
total_cost_usd: 0,
|
|
2995
3103
|
total_cpu_ms: 0
|
|
2996
3104
|
});
|
|
2997
|
-
existing = await storage.getSession(
|
|
3105
|
+
existing = await storage.getSession(sid);
|
|
2998
3106
|
}
|
|
2999
3107
|
if (!existing) return;
|
|
3000
3108
|
let promptDelta = 0;
|
|
@@ -3014,7 +3122,7 @@ async function recordSessionCall(storage, sessionId, answers, wallMs, cpuMs, now
|
|
|
3014
3122
|
}
|
|
3015
3123
|
if (a.cache_hit) cacheHitDelta += 1;
|
|
3016
3124
|
}
|
|
3017
|
-
await storage.accumulateSessionTotals(
|
|
3125
|
+
await storage.accumulateSessionTotals(sid, {
|
|
3018
3126
|
calls: answers.length,
|
|
3019
3127
|
wall_ms: wallMs,
|
|
3020
3128
|
cache_hits: cacheHitDelta,
|
|
@@ -3409,7 +3517,7 @@ function buildPersonaInjection(opts) {
|
|
|
3409
3517
|
|
|
3410
3518
|
// src/core/canary.ts
|
|
3411
3519
|
init_cjs_shims();
|
|
3412
|
-
var
|
|
3520
|
+
var import_node_crypto3 = require("crypto");
|
|
3413
3521
|
|
|
3414
3522
|
// src/core/injection.ts
|
|
3415
3523
|
init_cjs_shims();
|
|
@@ -3428,8 +3536,8 @@ var UNTRUSTED_SYSTEM_NOTE = "Some inputs in this conversation are wrapped in <un
|
|
|
3428
3536
|
function mintCanary() {
|
|
3429
3537
|
const t = process.hrtime.bigint().toString();
|
|
3430
3538
|
const pid = String(process.pid);
|
|
3431
|
-
const r = (0,
|
|
3432
|
-
const hex = (0,
|
|
3539
|
+
const r = (0, import_node_crypto3.randomBytes)(16).toString("hex");
|
|
3540
|
+
const hex = (0, import_node_crypto3.createHash)("sha256").update(`${t}-${pid}-${r}`).digest("hex").slice(0, 16).toUpperCase();
|
|
3433
3541
|
return `CC_CANARY_${hex}`;
|
|
3434
3542
|
}
|
|
3435
3543
|
function wrapUntrusted(content, canary) {
|
|
@@ -3619,7 +3727,7 @@ var import_node_path3 = __toESM(require("path"), 1);
|
|
|
3619
3727
|
|
|
3620
3728
|
// src/core/redact.ts
|
|
3621
3729
|
init_cjs_shims();
|
|
3622
|
-
var
|
|
3730
|
+
var import_node_crypto4 = require("crypto");
|
|
3623
3731
|
function builtinRedactionRules() {
|
|
3624
3732
|
return [
|
|
3625
3733
|
{ pattern: /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, label: "EMAIL", prefix_group: false },
|
|
@@ -3646,7 +3754,7 @@ function hmacSuffix(cfg2, label, value) {
|
|
|
3646
3754
|
const sid = cfg2.session_id ?? "";
|
|
3647
3755
|
const sidBytes = Buffer.from(sid, "utf8");
|
|
3648
3756
|
const key = Buffer.concat([Buffer.from(secret), sidBytes]);
|
|
3649
|
-
const digest = (0,
|
|
3757
|
+
const digest = (0, import_node_crypto4.createHmac)("sha256", key).update(`${label}:${value}`, "utf8").digest("hex");
|
|
3650
3758
|
return digest.slice(0, 8);
|
|
3651
3759
|
}
|
|
3652
3760
|
function redactText(s, cfg2) {
|
|
@@ -3984,13 +4092,25 @@ var import_node_perf_hooks = require("perf_hooks");
|
|
|
3984
4092
|
|
|
3985
4093
|
// src/core/co-reason.ts
|
|
3986
4094
|
init_cjs_shims();
|
|
3987
|
-
var CO_REASON_MODEL = "gpt-
|
|
4095
|
+
var CO_REASON_MODEL = "gpt-6-sol";
|
|
4096
|
+
var CO_REASON_ALTERNATE = "gpt-6-astra";
|
|
4097
|
+
var LABELS = {
|
|
4098
|
+
"gpt-6-sol": "GPT-6 Sol",
|
|
4099
|
+
"gpt-6-astra": "GPT-6 Astra",
|
|
4100
|
+
"gpt-5.6-sol": "GPT-5.6 Sol"
|
|
4101
|
+
};
|
|
4102
|
+
function coReasonLabel(model) {
|
|
4103
|
+
return LABELS[model] ?? model;
|
|
4104
|
+
}
|
|
4105
|
+
var CO_REASON_LABEL = coReasonLabel(CO_REASON_MODEL);
|
|
3988
4106
|
var CO_REASON_PROVIDER = "openai";
|
|
3989
|
-
|
|
3990
|
-
function pickCoReasoner(providers, upgradeRequested) {
|
|
4107
|
+
function pickCoReasoner(providers, upgradeRequested, openAiSeatModel) {
|
|
3991
4108
|
if (!upgradeRequested) return null;
|
|
3992
4109
|
const base = providers[CO_REASON_PROVIDER];
|
|
3993
|
-
|
|
4110
|
+
if (!base) return null;
|
|
4111
|
+
const seat = openAiSeatModel ?? base.model;
|
|
4112
|
+
const model = seat === CO_REASON_MODEL ? CO_REASON_ALTERNATE : CO_REASON_MODEL;
|
|
4113
|
+
return retargetProvider(base, model);
|
|
3994
4114
|
}
|
|
3995
4115
|
async function coReasonThenInject(opts) {
|
|
3996
4116
|
const { provider, messages, maxTokens } = opts;
|
|
@@ -4221,7 +4341,7 @@ function buildSuggestedUpgrade(toolName, assessment) {
|
|
|
4221
4341
|
model: UPGRADE_MODEL,
|
|
4222
4342
|
label: UPGRADE_LABEL,
|
|
4223
4343
|
reason: assessment.reason,
|
|
4224
|
-
how: `re-run \`${toolName}\` with reasoning:"max" (or upgrade:true) to route the lead reasoning seat to ${UPGRADE_LABEL}, and \u2014 when an OpenAI key is configured \u2014 add
|
|
4344
|
+
how: `re-run \`${toolName}\` with reasoning:"max" (or upgrade:true) to route the lead reasoning seat to ${UPGRADE_LABEL}, and \u2014 when an OpenAI key is configured \u2014 add an OpenAI second-opinion pass that ${UPGRADE_LABEL} weighs before finalizing (the result names which model ran). Other panel seats stay on their normal models.`
|
|
4225
4345
|
};
|
|
4226
4346
|
}
|
|
4227
4347
|
|
|
@@ -4524,8 +4644,9 @@ ${rubricText}`;
|
|
|
4524
4644
|
const upgradeRequested = isUpgradeRequested(args);
|
|
4525
4645
|
const upgraded = upgradeRequested && opts.providers["anthropic"] !== void 0;
|
|
4526
4646
|
const auditorForCall = upgraded ? retargetProvider(opts.providers["anthropic"], UPGRADE_MODEL) : auditor;
|
|
4647
|
+
const coProvider = pickCoReasoner(opts.providers, upgradeRequested);
|
|
4527
4648
|
const coReason = await coReasonThenInject({
|
|
4528
|
-
provider:
|
|
4649
|
+
provider: coProvider,
|
|
4529
4650
|
messages: msgs,
|
|
4530
4651
|
maxTokens: 2048,
|
|
4531
4652
|
purpose: "audit-coreason"
|
|
@@ -4609,7 +4730,7 @@ ${rubricText}`;
|
|
|
4609
4730
|
model: UPGRADE_MODEL,
|
|
4610
4731
|
label: UPGRADE_LABEL,
|
|
4611
4732
|
seat: "auditor",
|
|
4612
|
-
...coReasoned ? { co_reasoner: { model:
|
|
4733
|
+
...coReasoned ? { co_reasoner: { model: coProvider.model, label: coReasonLabel(coProvider.model) } } : {}
|
|
4613
4734
|
};
|
|
4614
4735
|
} else if (upgradeRequested) {
|
|
4615
4736
|
result["reasoning_upgrade"] = {
|
|
@@ -5348,8 +5469,12 @@ var SUPER_MODELS = {
|
|
|
5348
5469
|
// Fable 5.1 verified present on the account; 5 as the fallback for accounts
|
|
5349
5470
|
// that haven't been granted 5.1 yet.
|
|
5350
5471
|
anthropic: ["claude-fable-5-1", UPGRADE_MODEL],
|
|
5351
|
-
// Astra
|
|
5352
|
-
|
|
5472
|
+
// Astra is live (verified against the account's model list 2026-09-23).
|
|
5473
|
+
// The fallback is named explicitly rather than reusing CO_REASON_MODEL:
|
|
5474
|
+
// that constant means "OpenAI's top reasoning model" for the max-reasoning
|
|
5475
|
+
// co-reasoner, which is a different question from "what should super fall
|
|
5476
|
+
// back to". Sharing the symbol silently coupled two unrelated decisions.
|
|
5477
|
+
openai: ["gpt-6-astra", "gpt-6-sol"],
|
|
5353
5478
|
// Explicitly left as-is per product decision. Note grok-4-latest is not in
|
|
5354
5479
|
// xAI's published model list, but it resolves in practice — real panel calls
|
|
5355
5480
|
// on it succeeded as recently as 2026-08-30 — so it is an unlisted alias
|
|
@@ -5966,10 +6091,6 @@ If you need supporting evidence, you may emit ONE \`<tool_call>...</tool_call>\`
|
|
|
5966
6091
|
}
|
|
5967
6092
|
|
|
5968
6093
|
// src/tools/confer.ts
|
|
5969
|
-
var DEFERRED_OPTS = [
|
|
5970
|
-
// empty — every confer opt runs natively except worker_tools, which
|
|
5971
|
-
// is gated below (non-empty list → defer).
|
|
5972
|
-
];
|
|
5973
6094
|
async function runConfer(args, opts) {
|
|
5974
6095
|
const callStartedWall = import_node_perf_hooks2.performance.now();
|
|
5975
6096
|
const callStartedCpu = process.cpuUsage();
|
|
@@ -5985,16 +6106,11 @@ async function runConfer(args, opts) {
|
|
|
5985
6106
|
rejectedWorkerTools.push(t);
|
|
5986
6107
|
}
|
|
5987
6108
|
}
|
|
5988
|
-
|
|
5989
|
-
const needsBridge = DEFERRED_OPTS.some((k) => Boolean(args[k])) || workerToolsNeedsBridge;
|
|
5990
|
-
if (needsBridge) {
|
|
5991
|
-
if (opts.bridge && opts.bridge.toolNames.has("confer")) {
|
|
5992
|
-
return await deferConfer(args, opts.bridge);
|
|
5993
|
-
}
|
|
6109
|
+
if (acceptedWorkerTools.length > 0 && !opts.innerCallers) {
|
|
5994
6110
|
return errorEnvelope2(
|
|
5995
6111
|
"CONFER_OPT_NOT_NATIVE",
|
|
5996
6112
|
"worker_tools requested but innerCallers are not wired",
|
|
5997
|
-
"Native confer covers untrusted_input + early_stop + extract_claims + inject_session_memory + auto_panel. worker_tools needs innerCallers wired by the host
|
|
6113
|
+
"Native confer covers untrusted_input + early_stop + extract_claims + inject_session_memory + auto_panel. worker_tools needs innerCallers wired by the host."
|
|
5998
6114
|
);
|
|
5999
6115
|
}
|
|
6000
6116
|
const question = typeof args["question"] === "string" ? args["question"] : String(args["question"] ?? "");
|
|
@@ -6345,21 +6461,6 @@ function unknownProviderError(unknownNames, available) {
|
|
|
6345
6461
|
available_now: Object.keys(available).sort()
|
|
6346
6462
|
};
|
|
6347
6463
|
}
|
|
6348
|
-
async function deferConfer(args, bridge) {
|
|
6349
|
-
const r = await bridge.callTool("confer", args);
|
|
6350
|
-
const text = r.content[0]?.text;
|
|
6351
|
-
if (typeof text === "string") {
|
|
6352
|
-
try {
|
|
6353
|
-
return JSON.parse(text);
|
|
6354
|
-
} catch {
|
|
6355
|
-
}
|
|
6356
|
-
}
|
|
6357
|
-
return errorEnvelope2(
|
|
6358
|
-
"CONFER_BRIDGE_BAD_ENVELOPE",
|
|
6359
|
-
"bridge returned an unparseable envelope for confer",
|
|
6360
|
-
"Check that the Python child is healthy."
|
|
6361
|
-
);
|
|
6362
|
-
}
|
|
6363
6464
|
function errorEnvelope2(code, message, hint) {
|
|
6364
6465
|
return {
|
|
6365
6466
|
tool: "confer",
|
|
@@ -6735,7 +6836,7 @@ function errorEnvelope3(code, message, hint) {
|
|
|
6735
6836
|
transient: false
|
|
6736
6837
|
};
|
|
6737
6838
|
}
|
|
6738
|
-
async function runVerify(args,
|
|
6839
|
+
async function runVerify(args, fetchConfig) {
|
|
6739
6840
|
const checks = args["checks"];
|
|
6740
6841
|
if (!Array.isArray(checks) || checks.length === 0) {
|
|
6741
6842
|
return {
|
|
@@ -6747,7 +6848,6 @@ async function runVerify(args, bridge, fetchConfig) {
|
|
|
6747
6848
|
)
|
|
6748
6849
|
};
|
|
6749
6850
|
}
|
|
6750
|
-
void bridge;
|
|
6751
6851
|
const allowShell = Boolean(args["allow_shell"] ?? false);
|
|
6752
6852
|
const wallStart = import_node_perf_hooks3.performance.now();
|
|
6753
6853
|
const cpuStart = process.cpuUsage();
|
|
@@ -7049,7 +7149,6 @@ async function runBench(args, opts) {
|
|
|
7049
7149
|
const innerOpts = {
|
|
7050
7150
|
providers: opts.providers,
|
|
7051
7151
|
allowlist: opts.allowlist ?? null,
|
|
7052
|
-
...opts.bridge ? { bridge: opts.bridge } : {},
|
|
7053
7152
|
...opts.moderator ? { moderator: opts.moderator } : {}
|
|
7054
7153
|
};
|
|
7055
7154
|
let inner;
|
|
@@ -7262,7 +7361,7 @@ function isObj4(v) {
|
|
|
7262
7361
|
|
|
7263
7362
|
// src/tools/config-pin.ts
|
|
7264
7363
|
init_cjs_shims();
|
|
7265
|
-
var
|
|
7364
|
+
var import_node_crypto5 = require("crypto");
|
|
7266
7365
|
var import_node_fs7 = require("fs");
|
|
7267
7366
|
var import_node_path7 = __toESM(require("path"), 1);
|
|
7268
7367
|
var DEFAULT_PIN_PATH = ".crosscheck/config_pins.json";
|
|
@@ -7417,7 +7516,7 @@ function hashFile(abs) {
|
|
|
7417
7516
|
return "";
|
|
7418
7517
|
}
|
|
7419
7518
|
const normalized = stripCrBeforeLf(raw);
|
|
7420
|
-
return "sha256:" + (0,
|
|
7519
|
+
return "sha256:" + (0, import_node_crypto5.createHash)("sha256").update(normalized).digest("hex");
|
|
7421
7520
|
}
|
|
7422
7521
|
function stripCrBeforeLf(buf) {
|
|
7423
7522
|
const out = [];
|
|
@@ -7495,7 +7594,7 @@ function pyRepr2(v) {
|
|
|
7495
7594
|
|
|
7496
7595
|
// src/tools/create.ts
|
|
7497
7596
|
init_cjs_shims();
|
|
7498
|
-
var
|
|
7597
|
+
var import_node_crypto8 = require("crypto");
|
|
7499
7598
|
var import_node_fs10 = require("fs");
|
|
7500
7599
|
var import_node_path10 = __toESM(require("path"), 1);
|
|
7501
7600
|
|
|
@@ -7598,7 +7697,7 @@ function isDeadModelError(err) {
|
|
|
7598
7697
|
|
|
7599
7698
|
// src/core/node-cache.ts
|
|
7600
7699
|
init_cjs_shims();
|
|
7601
|
-
var
|
|
7700
|
+
var import_node_crypto6 = require("crypto");
|
|
7602
7701
|
var import_node_fs8 = require("fs");
|
|
7603
7702
|
var import_node_path8 = require("path");
|
|
7604
7703
|
var NODE_CACHE_KEY_VERSION = "v2";
|
|
@@ -7625,7 +7724,7 @@ function canonicalizeNodeText(s) {
|
|
|
7625
7724
|
return out;
|
|
7626
7725
|
}
|
|
7627
7726
|
function sha256Hex(s) {
|
|
7628
|
-
return (0,
|
|
7727
|
+
return (0, import_node_crypto6.createHash)("sha256").update(s, "utf8").digest("hex");
|
|
7629
7728
|
}
|
|
7630
7729
|
function nodeCacheKey(node, upstreamOutputs, provider, model) {
|
|
7631
7730
|
const canonUpstream = {};
|
|
@@ -7683,11 +7782,11 @@ function getNodeCache(cfg2, repoRoot, key, nowMs) {
|
|
|
7683
7782
|
return null;
|
|
7684
7783
|
}
|
|
7685
7784
|
}
|
|
7686
|
-
function atomicWriteJson(
|
|
7687
|
-
(0, import_node_fs8.mkdirSync)((0, import_node_path8.dirname)(
|
|
7688
|
-
const tmp = `${
|
|
7785
|
+
function atomicWriteJson(path16, payload) {
|
|
7786
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path8.dirname)(path16), { recursive: true });
|
|
7787
|
+
const tmp = `${path16}.${process.pid}.${Date.now()}.tmp`;
|
|
7689
7788
|
(0, import_node_fs8.writeFileSync)(tmp, JSON.stringify(payload), "utf8");
|
|
7690
|
-
(0, import_node_fs8.renameSync)(tmp,
|
|
7789
|
+
(0, import_node_fs8.renameSync)(tmp, path16);
|
|
7691
7790
|
}
|
|
7692
7791
|
function putNodeCache(cfg2, repoRoot, key, value) {
|
|
7693
7792
|
if (!cfg2 || cfg2.enabled === false) return;
|
|
@@ -7745,7 +7844,6 @@ var EST_TOKENS = {
|
|
|
7745
7844
|
med: [1500, 800],
|
|
7746
7845
|
high: [2500, 1500]
|
|
7747
7846
|
};
|
|
7748
|
-
var DEFERRED_OPTS2 = [];
|
|
7749
7847
|
var REACTIVE_SIGNAL_RE = /<signals>\s*(\{[\s\S]*?\})\s*<\/signals>/g;
|
|
7750
7848
|
function parseReactiveSignals(output) {
|
|
7751
7849
|
if (typeof output !== "string" || !output.includes("<signals>")) return [];
|
|
@@ -7785,17 +7883,6 @@ async function runOrchestrate(args, opts) {
|
|
|
7785
7883
|
);
|
|
7786
7884
|
if (breakerEnv) return breakerEnv;
|
|
7787
7885
|
}
|
|
7788
|
-
const needsBridge = DEFERRED_OPTS2.some((k) => Boolean(args[k]));
|
|
7789
|
-
if (needsBridge) {
|
|
7790
|
-
if (opts.bridge && opts.bridge.toolNames.has("orchestrate")) {
|
|
7791
|
-
return await deferOrchestrate(args, opts.bridge);
|
|
7792
|
-
}
|
|
7793
|
-
return errorEnvelope5(
|
|
7794
|
-
"ORCHESTRATE_OPT_NOT_NATIVE",
|
|
7795
|
-
"this orchestrate opt-in requires the Python bridge in v1",
|
|
7796
|
-
"v1 native covers the plain DAG flow + cheap_mode. reactive (mid-flight DAG updates) still defers. Set CROSSCHECK_BRIDGE_PYTHON=1 to enable."
|
|
7797
|
-
);
|
|
7798
|
-
}
|
|
7799
7886
|
const goal = typeof args["goal"] === "string" ? args["goal"] : null;
|
|
7800
7887
|
const dagIn = isObj5(args["dag"]) ? args["dag"] : null;
|
|
7801
7888
|
if (goal === null === (dagIn === null)) {
|
|
@@ -8338,8 +8425,9 @@ ${recombineSys}` : recombineSys },
|
|
|
8338
8425
|
provider: synthProvider.name
|
|
8339
8426
|
} }
|
|
8340
8427
|
);
|
|
8428
|
+
const coProvider = pickCoReasoner(opts.providers, upgradeRequested);
|
|
8341
8429
|
const coReason = await coReasonThenInject({
|
|
8342
|
-
provider:
|
|
8430
|
+
provider: coProvider,
|
|
8343
8431
|
messages: recMsgs,
|
|
8344
8432
|
maxTokens,
|
|
8345
8433
|
purpose: "orchestrate-coreason"
|
|
@@ -8398,7 +8486,7 @@ ${recombineSys}` : recombineSys },
|
|
|
8398
8486
|
model: UPGRADE_MODEL,
|
|
8399
8487
|
label: UPGRADE_LABEL,
|
|
8400
8488
|
seat: "recombine/synthesis",
|
|
8401
|
-
...coReasoned ? { co_reasoner: { model:
|
|
8489
|
+
...coReasoned ? { co_reasoner: { model: coProvider.model, label: coReasonLabel(coProvider.model) } } : {}
|
|
8402
8490
|
};
|
|
8403
8491
|
} else if (upgradeRequested) {
|
|
8404
8492
|
result["reasoning_upgrade"] = {
|
|
@@ -8736,21 +8824,6 @@ function resolveProviders3(names, available, allowlist) {
|
|
|
8736
8824
|
}
|
|
8737
8825
|
return out;
|
|
8738
8826
|
}
|
|
8739
|
-
async function deferOrchestrate(args, bridge) {
|
|
8740
|
-
const r = await bridge.callTool("orchestrate", args);
|
|
8741
|
-
const text = r.content[0]?.text;
|
|
8742
|
-
if (typeof text === "string") {
|
|
8743
|
-
try {
|
|
8744
|
-
return JSON.parse(text);
|
|
8745
|
-
} catch {
|
|
8746
|
-
}
|
|
8747
|
-
}
|
|
8748
|
-
return errorEnvelope5(
|
|
8749
|
-
"ORCHESTRATE_BRIDGE_BAD_ENVELOPE",
|
|
8750
|
-
"bridge returned an unparseable envelope for orchestrate",
|
|
8751
|
-
"Check that the Python child is healthy."
|
|
8752
|
-
);
|
|
8753
|
-
}
|
|
8754
8827
|
function errorEnvelope5(code, message, hint, kind = "client") {
|
|
8755
8828
|
return {
|
|
8756
8829
|
tool: "orchestrate",
|
|
@@ -8799,7 +8872,7 @@ function pyRound6(x) {
|
|
|
8799
8872
|
|
|
8800
8873
|
// src/tools/fetch.ts
|
|
8801
8874
|
init_cjs_shims();
|
|
8802
|
-
var
|
|
8875
|
+
var import_node_crypto7 = require("crypto");
|
|
8803
8876
|
var import_node_fs9 = require("fs");
|
|
8804
8877
|
var import_node_path9 = __toESM(require("path"), 1);
|
|
8805
8878
|
var DEFAULT_CONFIG = {
|
|
@@ -9013,10 +9086,10 @@ function extractHost(url) {
|
|
|
9013
9086
|
}
|
|
9014
9087
|
}
|
|
9015
9088
|
function sha256Hex2(s) {
|
|
9016
|
-
return (0,
|
|
9089
|
+
return (0, import_node_crypto7.createHash)("sha256").update(s, "utf8").digest("hex");
|
|
9017
9090
|
}
|
|
9018
9091
|
function sha256HexBytes(bytes) {
|
|
9019
|
-
return (0,
|
|
9092
|
+
return (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex");
|
|
9020
9093
|
}
|
|
9021
9094
|
function resolveEvidenceDir(configured, repoRoot) {
|
|
9022
9095
|
if (import_node_path9.default.isAbsolute(configured)) return configured;
|
|
@@ -9115,7 +9188,6 @@ ${documentsPayload}`;
|
|
|
9115
9188
|
}, {
|
|
9116
9189
|
providers: opts.providers,
|
|
9117
9190
|
allowlist: opts.allowlist ?? null,
|
|
9118
|
-
...opts.bridge ? { bridge: opts.bridge } : {},
|
|
9119
9191
|
ctx
|
|
9120
9192
|
});
|
|
9121
9193
|
const scopeAnswer = Array.isArray(scope["answers"]) ? scope["answers"].filter((a) => typeof a["response"] === "string" && a["response"]).map((a) => `[${a["provider"]}]
|
|
@@ -9138,7 +9210,6 @@ ${scopeAnswer || "(none)"}
|
|
|
9138
9210
|
providers: opts.providers,
|
|
9139
9211
|
allowlist: opts.allowlist ?? null,
|
|
9140
9212
|
moderator,
|
|
9141
|
-
...opts.bridge ? { bridge: opts.bridge } : {},
|
|
9142
9213
|
ctx
|
|
9143
9214
|
});
|
|
9144
9215
|
let attempts = 1;
|
|
@@ -9173,7 +9244,6 @@ ${scopeAnswer || "(none)"}
|
|
|
9173
9244
|
}, {
|
|
9174
9245
|
providers: opts.providers,
|
|
9175
9246
|
allowlist: opts.allowlist ?? null,
|
|
9176
|
-
...opts.bridge ? { bridge: opts.bridge } : {},
|
|
9177
9247
|
ctx
|
|
9178
9248
|
});
|
|
9179
9249
|
}
|
|
@@ -9196,7 +9266,6 @@ ${scopeAnswer || "(none)"}
|
|
|
9196
9266
|
}, {
|
|
9197
9267
|
providers: opts.providers,
|
|
9198
9268
|
allowlist: opts.allowlist ?? null,
|
|
9199
|
-
...opts.bridge ? { bridge: opts.bridge } : {},
|
|
9200
9269
|
ctx
|
|
9201
9270
|
});
|
|
9202
9271
|
let overallF = toNumberOrNull(auditEnvelope["overall_score"]);
|
|
@@ -9221,7 +9290,6 @@ ${documentsPayload}`
|
|
|
9221
9290
|
providers: opts.providers,
|
|
9222
9291
|
allowlist: opts.allowlist ?? null,
|
|
9223
9292
|
moderator,
|
|
9224
|
-
...opts.bridge ? { bridge: opts.bridge } : {},
|
|
9225
9293
|
ctx
|
|
9226
9294
|
}
|
|
9227
9295
|
);
|
|
@@ -9241,7 +9309,6 @@ ${documentsPayload}`
|
|
|
9241
9309
|
}, {
|
|
9242
9310
|
providers: opts.providers,
|
|
9243
9311
|
allowlist: opts.allowlist ?? null,
|
|
9244
|
-
...opts.bridge ? { bridge: opts.bridge } : {},
|
|
9245
9312
|
ctx
|
|
9246
9313
|
});
|
|
9247
9314
|
overallF = toNumberOrNull(auditEnvelope["overall_score"]);
|
|
@@ -9378,7 +9445,7 @@ async function ingestDocuments(documents, sessionId, opts) {
|
|
|
9378
9445
|
source: ref,
|
|
9379
9446
|
type: "file",
|
|
9380
9447
|
status: "ok",
|
|
9381
|
-
hash: (0,
|
|
9448
|
+
hash: (0, import_node_crypto8.createHash)("sha256").update(text, "utf8").digest("hex"),
|
|
9382
9449
|
content: ""
|
|
9383
9450
|
}, text));
|
|
9384
9451
|
}
|
|
@@ -9415,7 +9482,7 @@ ${d.content}
|
|
|
9415
9482
|
function makeSessionId(opts, supplied) {
|
|
9416
9483
|
if (typeof supplied === "string" && supplied) return supplied;
|
|
9417
9484
|
const stamp = opts.nowEpochSeconds ? opts.nowEpochSeconds() : Math.floor(Date.now() / 1e3);
|
|
9418
|
-
const rnd = opts.randomBytes ? opts.randomBytes() : (0,
|
|
9485
|
+
const rnd = opts.randomBytes ? opts.randomBytes() : (0, import_node_crypto8.createHash)("sha256").update(`${stamp}-${process.pid}-${Math.random()}`).digest("hex");
|
|
9419
9486
|
const suffix = rnd.slice(0, 8);
|
|
9420
9487
|
return `${opts.toolName}-${stamp}-${suffix}`;
|
|
9421
9488
|
}
|
|
@@ -9480,11 +9547,6 @@ function errorEnvelope6(toolName, code, message, hint) {
|
|
|
9480
9547
|
// src/tools/coordinate.ts
|
|
9481
9548
|
init_cjs_shims();
|
|
9482
9549
|
var import_node_perf_hooks7 = require("perf_hooks");
|
|
9483
|
-
var DEFERRED_OPTS3 = [
|
|
9484
|
-
// empty — every coordinate opt runs natively when its deps
|
|
9485
|
-
// (storage / innerCallers) are wired. Without them the
|
|
9486
|
-
// worker_tools gate still triggers a bridge defer.
|
|
9487
|
-
];
|
|
9488
9550
|
var COORDINATE_DEFAULT_TEMP = 0.4;
|
|
9489
9551
|
var ROLE_TURN_SCHEMA = {
|
|
9490
9552
|
type: "object",
|
|
@@ -9539,23 +9601,18 @@ async function runCoordinate(args, opts) {
|
|
|
9539
9601
|
rejectedWorkerTools.push(t);
|
|
9540
9602
|
}
|
|
9541
9603
|
}
|
|
9542
|
-
|
|
9543
|
-
const needsBridge = DEFERRED_OPTS3.some((k) => Boolean(args[k])) || workerToolsNeedsBridge;
|
|
9544
|
-
if (needsBridge) {
|
|
9604
|
+
if (acceptedWorkerTools.length > 0 && !opts.innerCallers) {
|
|
9545
9605
|
if (superRequested) {
|
|
9546
9606
|
return errorEnvelope7(
|
|
9547
9607
|
"COORDINATE_SUPER_NOT_NATIVE",
|
|
9548
|
-
"super mode requested
|
|
9549
|
-
"worker_tools
|
|
9608
|
+
"super mode requested with worker_tools, but innerCallers are not wired",
|
|
9609
|
+
"worker_tools needs innerCallers wired by the host. Drop worker_tools, or wire innerCallers, to use super."
|
|
9550
9610
|
);
|
|
9551
9611
|
}
|
|
9552
|
-
if (opts.bridge && opts.bridge.toolNames.has("coordinate")) {
|
|
9553
|
-
return await deferCoordinate(args, opts.bridge);
|
|
9554
|
-
}
|
|
9555
9612
|
return errorEnvelope7(
|
|
9556
9613
|
"COORDINATE_OPT_NOT_NATIVE",
|
|
9557
9614
|
"worker_tools requested but innerCallers are not wired",
|
|
9558
|
-
"Native coordinate covers the three-role flow + untrusted_input + inject_session_memory. worker_tools needs innerCallers wired by the host
|
|
9615
|
+
"Native coordinate covers the three-role flow + untrusted_input + inject_session_memory. worker_tools needs innerCallers wired by the host."
|
|
9559
9616
|
);
|
|
9560
9617
|
}
|
|
9561
9618
|
const untrusted = Boolean(args["untrusted_input"]);
|
|
@@ -9747,8 +9804,9 @@ CRITIQUES:
|
|
|
9747
9804
|
${critiqueBlock}`
|
|
9748
9805
|
}
|
|
9749
9806
|
];
|
|
9807
|
+
const coProvider = pickCoReasoner(opts.providers, upgradeRequested);
|
|
9750
9808
|
const coReason = await coReasonThenInject({
|
|
9751
|
-
provider:
|
|
9809
|
+
provider: coProvider,
|
|
9752
9810
|
messages: synthMessages,
|
|
9753
9811
|
maxTokens,
|
|
9754
9812
|
purpose: "coordinate-coreason"
|
|
@@ -9812,7 +9870,7 @@ ${critiqueBlock}`
|
|
|
9812
9870
|
model: superRequested ? superPrimary("anthropic") ?? UPGRADE_MODEL : UPGRADE_MODEL,
|
|
9813
9871
|
label: UPGRADE_LABEL,
|
|
9814
9872
|
seat: "synthesizer",
|
|
9815
|
-
...coReasonAns ? { co_reasoner: { model:
|
|
9873
|
+
...coReasonAns ? { co_reasoner: { model: coProvider.model, label: coReasonLabel(coProvider.model) } } : {}
|
|
9816
9874
|
};
|
|
9817
9875
|
} else if (upgradeRequested) {
|
|
9818
9876
|
result["reasoning_upgrade"] = {
|
|
@@ -9954,21 +10012,6 @@ function unknownProviderError3(unknownNames, available) {
|
|
|
9954
10012
|
available_now: Object.keys(available).sort()
|
|
9955
10013
|
};
|
|
9956
10014
|
}
|
|
9957
|
-
async function deferCoordinate(args, bridge) {
|
|
9958
|
-
const r = await bridge.callTool("coordinate", args);
|
|
9959
|
-
const text = r.content[0]?.text;
|
|
9960
|
-
if (typeof text === "string") {
|
|
9961
|
-
try {
|
|
9962
|
-
return JSON.parse(text);
|
|
9963
|
-
} catch {
|
|
9964
|
-
}
|
|
9965
|
-
}
|
|
9966
|
-
return errorEnvelope7(
|
|
9967
|
-
"COORDINATE_BRIDGE_BAD_ENVELOPE",
|
|
9968
|
-
"bridge returned an unparseable envelope for coordinate",
|
|
9969
|
-
"Check that the Python child is healthy."
|
|
9970
|
-
);
|
|
9971
|
-
}
|
|
9972
10015
|
function errorEnvelope7(code, message, hint) {
|
|
9973
10016
|
return {
|
|
9974
10017
|
tool: "coordinate",
|
|
@@ -10301,10 +10344,6 @@ function buildModeratorTranscript(transcript) {
|
|
|
10301
10344
|
|
|
10302
10345
|
// src/tools/debate.ts
|
|
10303
10346
|
var import_node_perf_hooks9 = require("perf_hooks");
|
|
10304
|
-
var DEFERRED_OPTS4 = [
|
|
10305
|
-
// empty — every debate opt runs natively when its deps
|
|
10306
|
-
// (storage / innerCallers) are wired.
|
|
10307
|
-
];
|
|
10308
10347
|
async function runDebate(args, opts) {
|
|
10309
10348
|
const callStartedWall = import_node_perf_hooks9.performance.now();
|
|
10310
10349
|
const callStartedCpu = process.cpuUsage();
|
|
@@ -10322,23 +10361,18 @@ async function runDebate(args, opts) {
|
|
|
10322
10361
|
rejectedWorkerTools.push(t);
|
|
10323
10362
|
}
|
|
10324
10363
|
}
|
|
10325
|
-
|
|
10326
|
-
const needsBridge = DEFERRED_OPTS4.some((k) => Boolean(args[k])) || workerToolsNeedsBridge;
|
|
10327
|
-
if (needsBridge) {
|
|
10364
|
+
if (acceptedWorkerTools.length > 0 && !opts.innerCallers) {
|
|
10328
10365
|
if (superRequested) {
|
|
10329
10366
|
return errorEnvelope9(
|
|
10330
10367
|
"DEBATE_SUPER_NOT_NATIVE",
|
|
10331
|
-
"super mode requested
|
|
10332
|
-
"worker_tools
|
|
10368
|
+
"super mode requested with worker_tools, but innerCallers are not wired",
|
|
10369
|
+
"worker_tools needs innerCallers wired by the host. Drop worker_tools, or wire innerCallers, to use super."
|
|
10333
10370
|
);
|
|
10334
10371
|
}
|
|
10335
|
-
if (opts.bridge && opts.bridge.toolNames.has("debate")) {
|
|
10336
|
-
return await deferDebate(args, opts.bridge);
|
|
10337
|
-
}
|
|
10338
10372
|
return errorEnvelope9(
|
|
10339
10373
|
"DEBATE_OPT_NOT_NATIVE",
|
|
10340
10374
|
"worker_tools requested but innerCallers are not wired",
|
|
10341
|
-
"Native debate covers N-round + plain/structured moderator synthesis + inject_session_memory + auto_panel + extract_claims + early_stop. worker_tools needs innerCallers wired by the host
|
|
10375
|
+
"Native debate covers N-round + plain/structured moderator synthesis + inject_session_memory + auto_panel + extract_claims + early_stop. worker_tools needs innerCallers wired by the host."
|
|
10342
10376
|
);
|
|
10343
10377
|
}
|
|
10344
10378
|
const topic = typeof args["topic"] === "string" ? args["topic"] : String(args["topic"] ?? "");
|
|
@@ -10539,6 +10573,7 @@ ${prior.body}` });
|
|
|
10539
10573
|
let synthesisErrors = [];
|
|
10540
10574
|
let personaMeta = null;
|
|
10541
10575
|
let coReasoned = false;
|
|
10576
|
+
let coReasonerModel = null;
|
|
10542
10577
|
if (moderator) {
|
|
10543
10578
|
const synthProvider = superRequested && opts.providers["anthropic"] ? retargetForSuper(opts.providers["anthropic"]) : upgraded ? retargetProvider(opts.providers["anthropic"], UPGRADE_MODEL) : moderator;
|
|
10544
10579
|
const condensed = buildModeratorTranscript(transcript);
|
|
@@ -10566,13 +10601,16 @@ TRANSCRIPT:
|
|
|
10566
10601
|
${condensed}`
|
|
10567
10602
|
}
|
|
10568
10603
|
];
|
|
10604
|
+
const openAiSeat = selected.find((p) => p.name === "openai")?.model;
|
|
10605
|
+
const coProvider = pickCoReasoner(opts.providers, upgradeRequested, openAiSeat);
|
|
10569
10606
|
const coReason = await coReasonThenInject({
|
|
10570
|
-
provider:
|
|
10607
|
+
provider: coProvider,
|
|
10571
10608
|
messages: synthMessages,
|
|
10572
10609
|
maxTokens,
|
|
10573
10610
|
purpose: "debate-coreason"
|
|
10574
10611
|
});
|
|
10575
10612
|
synthMessages = coReason.messages;
|
|
10613
|
+
coReasonerModel = coProvider?.model ?? null;
|
|
10576
10614
|
if (coReason.answer) extraAnswers.push(coReason.answer);
|
|
10577
10615
|
coReasoned = coReason.answer !== null;
|
|
10578
10616
|
if (structuredOpt) {
|
|
@@ -10631,7 +10669,7 @@ ${condensed}`
|
|
|
10631
10669
|
model: superRequested ? superPrimary("anthropic") ?? UPGRADE_MODEL : UPGRADE_MODEL,
|
|
10632
10670
|
label: UPGRADE_LABEL,
|
|
10633
10671
|
seat: "moderator synthesis",
|
|
10634
|
-
...coReasoned ? { co_reasoner: { model:
|
|
10672
|
+
...coReasoned && coReasonerModel ? { co_reasoner: { model: coReasonerModel, label: coReasonLabel(coReasonerModel) } } : {}
|
|
10635
10673
|
};
|
|
10636
10674
|
} else if (upgradeRequested) {
|
|
10637
10675
|
result["reasoning_upgrade"] = {
|
|
@@ -10771,21 +10809,6 @@ function unknownProviderError5(unknownNames, available) {
|
|
|
10771
10809
|
available_now: Object.keys(available).sort()
|
|
10772
10810
|
};
|
|
10773
10811
|
}
|
|
10774
|
-
async function deferDebate(args, bridge) {
|
|
10775
|
-
const r = await bridge.callTool("debate", args);
|
|
10776
|
-
const text = r.content[0]?.text;
|
|
10777
|
-
if (typeof text === "string") {
|
|
10778
|
-
try {
|
|
10779
|
-
return JSON.parse(text);
|
|
10780
|
-
} catch {
|
|
10781
|
-
}
|
|
10782
|
-
}
|
|
10783
|
-
return errorEnvelope9(
|
|
10784
|
-
"DEBATE_BRIDGE_BAD_ENVELOPE",
|
|
10785
|
-
"bridge returned an unparseable envelope for debate",
|
|
10786
|
-
"Check that the Python child is healthy."
|
|
10787
|
-
);
|
|
10788
|
-
}
|
|
10789
10812
|
function errorEnvelope9(code, message, hint) {
|
|
10790
10813
|
return {
|
|
10791
10814
|
tool: "debate",
|
|
@@ -10806,9 +10829,6 @@ var DEFAULT_DELEGATION_LIMITS = {
|
|
|
10806
10829
|
};
|
|
10807
10830
|
async function runDelegate(args, opts) {
|
|
10808
10831
|
if (!opts.storage) {
|
|
10809
|
-
if (opts.bridge && opts.bridge.toolNames.has("delegate")) {
|
|
10810
|
-
return await deferDelegate(args, opts.bridge);
|
|
10811
|
-
}
|
|
10812
10832
|
return errorEnvelope10(
|
|
10813
10833
|
"DELEGATE_STORAGE_UNAVAILABLE",
|
|
10814
10834
|
"delegate needs the local database (for quota tracking), which isn't available",
|
|
@@ -10880,7 +10900,6 @@ async function runDelegate(args, opts) {
|
|
|
10880
10900
|
const innerOpts = {
|
|
10881
10901
|
providers: opts.providers,
|
|
10882
10902
|
allowlist: opts.allowlist ?? null,
|
|
10883
|
-
...opts.bridge ? { bridge: opts.bridge } : {},
|
|
10884
10903
|
...opts.moderator ? { moderator: opts.moderator } : {}
|
|
10885
10904
|
};
|
|
10886
10905
|
let result;
|
|
@@ -10919,21 +10938,6 @@ async function record(storage, sessionId, requester, toolCall, via, accepted, no
|
|
|
10919
10938
|
created_at: nowEpochSeconds
|
|
10920
10939
|
});
|
|
10921
10940
|
}
|
|
10922
|
-
async function deferDelegate(args, bridge) {
|
|
10923
|
-
const r = await bridge.callTool("delegate", args);
|
|
10924
|
-
const text = r.content[0]?.text;
|
|
10925
|
-
if (typeof text === "string") {
|
|
10926
|
-
try {
|
|
10927
|
-
return JSON.parse(text);
|
|
10928
|
-
} catch {
|
|
10929
|
-
}
|
|
10930
|
-
}
|
|
10931
|
-
return errorEnvelope10(
|
|
10932
|
-
"DELEGATE_BRIDGE_BAD_ENVELOPE",
|
|
10933
|
-
"bridge returned an unparseable envelope for delegate",
|
|
10934
|
-
"Check that the Python child is healthy."
|
|
10935
|
-
);
|
|
10936
|
-
}
|
|
10937
10941
|
function errorEnvelope10(code, message, hint) {
|
|
10938
10942
|
return {
|
|
10939
10943
|
tool: "delegate",
|
|
@@ -10977,9 +10981,6 @@ async function runExplain(args, opts) {
|
|
|
10977
10981
|
);
|
|
10978
10982
|
}
|
|
10979
10983
|
if (!opts.storage) {
|
|
10980
|
-
if (opts.bridge && opts.bridge.toolNames.has("explain")) {
|
|
10981
|
-
return await deferExplain(args, opts.bridge);
|
|
10982
|
-
}
|
|
10983
10984
|
return errorEnvelope11(
|
|
10984
10985
|
"EXPLAIN_STORAGE_UNAVAILABLE",
|
|
10985
10986
|
"explain needs the local transcript/stats database, which isn't available",
|
|
@@ -11261,21 +11262,6 @@ function pyRepr5(v) {
|
|
|
11261
11262
|
}
|
|
11262
11263
|
return String(v);
|
|
11263
11264
|
}
|
|
11264
|
-
async function deferExplain(args, bridge) {
|
|
11265
|
-
const r = await bridge.callTool("explain", args);
|
|
11266
|
-
const text = r.content[0]?.text;
|
|
11267
|
-
if (typeof text === "string") {
|
|
11268
|
-
try {
|
|
11269
|
-
return JSON.parse(text);
|
|
11270
|
-
} catch {
|
|
11271
|
-
}
|
|
11272
|
-
}
|
|
11273
|
-
return errorEnvelope11(
|
|
11274
|
-
"EXPLAIN_BRIDGE_BAD_ENVELOPE",
|
|
11275
|
-
"bridge returned an unparseable envelope for explain",
|
|
11276
|
-
"Check that the Python child is healthy."
|
|
11277
|
-
);
|
|
11278
|
-
}
|
|
11279
11265
|
function errorEnvelope11(code, message, hint, kind = "client", extra = {}) {
|
|
11280
11266
|
return {
|
|
11281
11267
|
tool: "explain",
|
|
@@ -11833,9 +11819,6 @@ async function runRecall(args, opts) {
|
|
|
11833
11819
|
if (k < 1) k = 1;
|
|
11834
11820
|
if (k > 50) k = 50;
|
|
11835
11821
|
if (!opts.storage) {
|
|
11836
|
-
if (opts.bridge && opts.bridge.toolNames.has("recall")) {
|
|
11837
|
-
return await deferRecall(args, opts.bridge);
|
|
11838
|
-
}
|
|
11839
11822
|
return errorEnvelope12(
|
|
11840
11823
|
"RECALL_STORAGE_UNAVAILABLE",
|
|
11841
11824
|
"recall needs the local database, which isn't available",
|
|
@@ -11888,21 +11871,6 @@ async function runRecall(args, opts) {
|
|
|
11888
11871
|
applied_filters: applied
|
|
11889
11872
|
};
|
|
11890
11873
|
}
|
|
11891
|
-
async function deferRecall(args, bridge) {
|
|
11892
|
-
const r = await bridge.callTool("recall", args);
|
|
11893
|
-
const text = r.content[0]?.text;
|
|
11894
|
-
if (typeof text === "string") {
|
|
11895
|
-
try {
|
|
11896
|
-
return JSON.parse(text);
|
|
11897
|
-
} catch {
|
|
11898
|
-
}
|
|
11899
|
-
}
|
|
11900
|
-
return errorEnvelope12(
|
|
11901
|
-
"RECALL_BRIDGE_BAD_ENVELOPE",
|
|
11902
|
-
"bridge returned an unparseable envelope for recall",
|
|
11903
|
-
"Check that the Python child is healthy."
|
|
11904
|
-
);
|
|
11905
|
-
}
|
|
11906
11874
|
function errorEnvelope12(code, message, hint) {
|
|
11907
11875
|
return {
|
|
11908
11876
|
tool: "recall",
|
|
@@ -11926,9 +11894,6 @@ async function runRecommendPanel(args, opts) {
|
|
|
11926
11894
|
);
|
|
11927
11895
|
}
|
|
11928
11896
|
if (!opts.storage) {
|
|
11929
|
-
if (opts.bridge && opts.bridge.toolNames.has("recommend_panel")) {
|
|
11930
|
-
return await deferRecommendPanel(args, opts.bridge);
|
|
11931
|
-
}
|
|
11932
11897
|
return errorEnvelope13(
|
|
11933
11898
|
"RECOMMEND_PANEL_STORAGE_UNAVAILABLE",
|
|
11934
11899
|
"recommend_panel needs the local stats database, which isn't available",
|
|
@@ -11991,21 +11956,6 @@ async function runRecommendPanel(args, opts) {
|
|
|
11991
11956
|
meta: result.meta
|
|
11992
11957
|
};
|
|
11993
11958
|
}
|
|
11994
|
-
async function deferRecommendPanel(args, bridge) {
|
|
11995
|
-
const r = await bridge.callTool("recommend_panel", args);
|
|
11996
|
-
const text = r.content[0]?.text;
|
|
11997
|
-
if (typeof text === "string") {
|
|
11998
|
-
try {
|
|
11999
|
-
return JSON.parse(text);
|
|
12000
|
-
} catch {
|
|
12001
|
-
}
|
|
12002
|
-
}
|
|
12003
|
-
return errorEnvelope13(
|
|
12004
|
-
"RECOMMEND_PANEL_BRIDGE_BAD_ENVELOPE",
|
|
12005
|
-
"bridge returned an unparseable envelope for recommend_panel",
|
|
12006
|
-
"Check that the Python child is healthy."
|
|
12007
|
-
);
|
|
12008
|
-
}
|
|
12009
11959
|
function errorEnvelope13(code, message, hint) {
|
|
12010
11960
|
return {
|
|
12011
11961
|
tool: "recommend_panel",
|
|
@@ -12036,9 +11986,6 @@ init_cjs_shims();
|
|
|
12036
11986
|
var import_node_fs12 = require("fs");
|
|
12037
11987
|
async function runScoreboard(args, opts) {
|
|
12038
11988
|
if (!opts.storage) {
|
|
12039
|
-
if (opts.bridge && opts.bridge.toolNames.has("scoreboard")) {
|
|
12040
|
-
return await deferScoreboard(args, opts.bridge);
|
|
12041
|
-
}
|
|
12042
11989
|
return errorEnvelope14(
|
|
12043
11990
|
"SCOREBOARD_STORAGE_UNAVAILABLE",
|
|
12044
11991
|
"scoreboard needs the local stats database, which isn't available",
|
|
@@ -12161,21 +12108,6 @@ function clampInt3(raw, min, max, fallback) {
|
|
|
12161
12108
|
if (!Number.isFinite(n)) return fallback;
|
|
12162
12109
|
return Math.min(max, Math.max(min, Math.trunc(n)));
|
|
12163
12110
|
}
|
|
12164
|
-
async function deferScoreboard(args, bridge) {
|
|
12165
|
-
const r = await bridge.callTool("scoreboard", args);
|
|
12166
|
-
const text = r.content[0]?.text;
|
|
12167
|
-
if (typeof text === "string") {
|
|
12168
|
-
try {
|
|
12169
|
-
return JSON.parse(text);
|
|
12170
|
-
} catch {
|
|
12171
|
-
}
|
|
12172
|
-
}
|
|
12173
|
-
return errorEnvelope14(
|
|
12174
|
-
"SCOREBOARD_BRIDGE_BAD_ENVELOPE",
|
|
12175
|
-
"bridge returned an unparseable envelope for scoreboard",
|
|
12176
|
-
"Check that the Python child is healthy."
|
|
12177
|
-
);
|
|
12178
|
-
}
|
|
12179
12111
|
function errorEnvelope14(code, message, hint) {
|
|
12180
12112
|
return {
|
|
12181
12113
|
tool: "scoreboard",
|
|
@@ -12213,9 +12145,6 @@ async function runSessionMemory(args, opts) {
|
|
|
12213
12145
|
);
|
|
12214
12146
|
}
|
|
12215
12147
|
if (!opts.storage) {
|
|
12216
|
-
if (opts.bridge && opts.bridge.toolNames.has("session_memory")) {
|
|
12217
|
-
return await deferSessionMemory(args, opts.bridge);
|
|
12218
|
-
}
|
|
12219
12148
|
return errorEnvelope15(
|
|
12220
12149
|
"SESSION_MEMORY_STORAGE_UNAVAILABLE",
|
|
12221
12150
|
"session_memory needs the local database, which isn't available",
|
|
@@ -12320,21 +12249,6 @@ function clampInt4(raw, min, max, fallback) {
|
|
|
12320
12249
|
if (!Number.isFinite(n)) return fallback;
|
|
12321
12250
|
return Math.min(max, Math.max(min, Math.trunc(n)));
|
|
12322
12251
|
}
|
|
12323
|
-
async function deferSessionMemory(args, bridge) {
|
|
12324
|
-
const r = await bridge.callTool("session_memory", args);
|
|
12325
|
-
const text = r.content[0]?.text;
|
|
12326
|
-
if (typeof text === "string") {
|
|
12327
|
-
try {
|
|
12328
|
-
return JSON.parse(text);
|
|
12329
|
-
} catch {
|
|
12330
|
-
}
|
|
12331
|
-
}
|
|
12332
|
-
return errorEnvelope15(
|
|
12333
|
-
"SESSION_MEMORY_BRIDGE_BAD_ENVELOPE",
|
|
12334
|
-
"bridge returned an unparseable envelope for session_memory",
|
|
12335
|
-
"Check that the Python child is healthy."
|
|
12336
|
-
);
|
|
12337
|
-
}
|
|
12338
12252
|
function errorEnvelope15(code, message, hint) {
|
|
12339
12253
|
return {
|
|
12340
12254
|
tool: "session_memory",
|
|
@@ -12667,7 +12581,7 @@ Re-emit the FULL solution. No commentary.`
|
|
|
12667
12581
|
model: UPGRADE_MODEL,
|
|
12668
12582
|
label: UPGRADE_LABEL,
|
|
12669
12583
|
seat: "solver",
|
|
12670
|
-
...coReasoned ? { co_reasoner: { model:
|
|
12584
|
+
...coReasoned ? { co_reasoner: { model: coProvider.model, label: coReasonLabel(coProvider.model) } } : {}
|
|
12671
12585
|
};
|
|
12672
12586
|
} else if (upgradeRequested) {
|
|
12673
12587
|
result["reasoning_upgrade"] = {
|
|
@@ -12958,7 +12872,7 @@ var CHECK_INTERVAL_SECONDS = 3 * 24 * 60 * 60;
|
|
|
12958
12872
|
var DEFAULT_PACKAGE = "crosscheck-cli";
|
|
12959
12873
|
var FETCH_TIMEOUT_MS = 3e3;
|
|
12960
12874
|
function engineVersion() {
|
|
12961
|
-
return true ? "0.2.
|
|
12875
|
+
return true ? "0.2.28" : "0.0.0-dev";
|
|
12962
12876
|
}
|
|
12963
12877
|
function defaultUpdateCachePath() {
|
|
12964
12878
|
const base = process.env["CROSSCHECK_DATA_DIR"] || import_node_path13.default.join(import_node_os2.default.homedir() || import_node_os2.default.tmpdir(), ".crosscheck");
|
|
@@ -13732,12 +13646,11 @@ function helpTool() {
|
|
|
13732
13646
|
}
|
|
13733
13647
|
});
|
|
13734
13648
|
}
|
|
13735
|
-
function registerCoreTools(
|
|
13736
|
-
const o = opts && typeof opts === "object" && "toolNames" in opts ? { bridge: opts } : opts;
|
|
13649
|
+
function registerCoreTools(o = {}) {
|
|
13737
13650
|
const tools = /* @__PURE__ */ new Map();
|
|
13738
13651
|
const list = [
|
|
13739
13652
|
pingTool(),
|
|
13740
|
-
verifyTool(o.
|
|
13653
|
+
verifyTool(o.fetchConfig),
|
|
13741
13654
|
pickTool(
|
|
13742
13655
|
o.providers ?? {},
|
|
13743
13656
|
o.providerAllowlist ?? null,
|
|
@@ -13749,7 +13662,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13749
13662
|
auditTool(
|
|
13750
13663
|
o.providers ?? {},
|
|
13751
13664
|
o.providerAllowlist ?? null,
|
|
13752
|
-
o.bridge,
|
|
13753
13665
|
o.transcriptsDir,
|
|
13754
13666
|
o.pricing,
|
|
13755
13667
|
o.storage,
|
|
@@ -13759,7 +13671,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13759
13671
|
conferTool(
|
|
13760
13672
|
o.providers ?? {},
|
|
13761
13673
|
o.providerAllowlist ?? null,
|
|
13762
|
-
o.bridge,
|
|
13763
13674
|
o.moderatorDefault ?? "anthropic",
|
|
13764
13675
|
o.pricing,
|
|
13765
13676
|
o.storage,
|
|
@@ -13772,7 +13683,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13772
13683
|
debateTool(
|
|
13773
13684
|
o.providers ?? {},
|
|
13774
13685
|
o.providerAllowlist ?? null,
|
|
13775
|
-
o.bridge,
|
|
13776
13686
|
buildInnerCallers(o),
|
|
13777
13687
|
o.storage,
|
|
13778
13688
|
o.pricing,
|
|
@@ -13784,7 +13694,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13784
13694
|
coordinateTool(
|
|
13785
13695
|
o.providers ?? {},
|
|
13786
13696
|
o.providerAllowlist ?? null,
|
|
13787
|
-
o.bridge,
|
|
13788
13697
|
buildInnerCallers(o),
|
|
13789
13698
|
o.storage,
|
|
13790
13699
|
o.circuitBreakers,
|
|
@@ -13795,7 +13704,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13795
13704
|
triangulateTool(
|
|
13796
13705
|
o.providers ?? {},
|
|
13797
13706
|
o.providerAllowlist ?? null,
|
|
13798
|
-
o.bridge,
|
|
13799
13707
|
o.storage,
|
|
13800
13708
|
o.circuitBreakers,
|
|
13801
13709
|
o.transcriptsDir,
|
|
@@ -13804,7 +13712,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13804
13712
|
planTool(
|
|
13805
13713
|
o.providers ?? {},
|
|
13806
13714
|
o.providerAllowlist ?? null,
|
|
13807
|
-
o.bridge,
|
|
13808
13715
|
o.storage,
|
|
13809
13716
|
o.circuitBreakers,
|
|
13810
13717
|
o.transcriptsDir,
|
|
@@ -13813,7 +13720,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13813
13720
|
critiqueTool(
|
|
13814
13721
|
o.providers ?? {},
|
|
13815
13722
|
o.providerAllowlist ?? null,
|
|
13816
|
-
o.bridge,
|
|
13817
13723
|
o.storage,
|
|
13818
13724
|
o.circuitBreakers,
|
|
13819
13725
|
o.transcriptsDir,
|
|
@@ -13822,7 +13728,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13822
13728
|
reviewTool(
|
|
13823
13729
|
o.providers ?? {},
|
|
13824
13730
|
o.providerAllowlist ?? null,
|
|
13825
|
-
o.bridge,
|
|
13826
13731
|
o.storage,
|
|
13827
13732
|
o.circuitBreakers,
|
|
13828
13733
|
o.transcriptsDir,
|
|
@@ -13830,25 +13735,23 @@ function registerCoreTools(opts = {}) {
|
|
|
13830
13735
|
),
|
|
13831
13736
|
listProvidersTool(o.providers ?? {}, o.activeProviders ?? null, o.moderatorDefault ?? "anthropic"),
|
|
13832
13737
|
modelsTool(o.providers ?? {}, o.activeProviders ?? null),
|
|
13833
|
-
recallTool(o.storage
|
|
13834
|
-
sessionMemoryTool(o.storage
|
|
13835
|
-
scoreboardTool(o.storage, o.
|
|
13836
|
-
explainTool(o.storage, o.
|
|
13738
|
+
recallTool(o.storage),
|
|
13739
|
+
sessionMemoryTool(o.storage),
|
|
13740
|
+
scoreboardTool(o.storage, o.eventsPath),
|
|
13741
|
+
explainTool(o.storage, o.transcriptsDir),
|
|
13837
13742
|
delegateTool(
|
|
13838
13743
|
o.providers ?? {},
|
|
13839
13744
|
o.providerAllowlist ?? null,
|
|
13840
13745
|
o.storage,
|
|
13841
|
-
o.bridge,
|
|
13842
13746
|
o.moderatorDefault ?? "anthropic"
|
|
13843
13747
|
),
|
|
13844
13748
|
fetchTool(o.storage, o.fetchConfig, o.repoRoot),
|
|
13845
|
-
recommendPanelTool(o.providers ?? {}, o.storage
|
|
13749
|
+
recommendPanelTool(o.providers ?? {}, o.storage),
|
|
13846
13750
|
updateCrosscheckTool(o.repoRoot ?? null),
|
|
13847
13751
|
benchTool(
|
|
13848
13752
|
o.providers ?? {},
|
|
13849
13753
|
o.providerAllowlist ?? null,
|
|
13850
13754
|
o.storage,
|
|
13851
|
-
o.bridge,
|
|
13852
13755
|
o.moderatorDefault ?? "anthropic",
|
|
13853
13756
|
o.benchGoldensDir,
|
|
13854
13757
|
o.circuitBreakers,
|
|
@@ -13859,7 +13762,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13859
13762
|
solveTool(
|
|
13860
13763
|
o.providers ?? {},
|
|
13861
13764
|
o.providerAllowlist ?? null,
|
|
13862
|
-
o.bridge,
|
|
13863
13765
|
o.storage,
|
|
13864
13766
|
o.circuitBreakers,
|
|
13865
13767
|
o.transcriptsDir,
|
|
@@ -13868,7 +13770,6 @@ function registerCoreTools(opts = {}) {
|
|
|
13868
13770
|
orchestrateTool(
|
|
13869
13771
|
o.providers ?? {},
|
|
13870
13772
|
o.providerAllowlist ?? null,
|
|
13871
|
-
o.bridge,
|
|
13872
13773
|
o.moderatorDefault ?? "anthropic",
|
|
13873
13774
|
o.storage,
|
|
13874
13775
|
o.pricing,
|
|
@@ -13915,7 +13816,6 @@ function createTool(o, toolName, cheapDefault) {
|
|
|
13915
13816
|
providers: o.providers ?? {},
|
|
13916
13817
|
allowlist: o.providerAllowlist ?? null,
|
|
13917
13818
|
...o.storage ? { storage: o.storage } : {},
|
|
13918
|
-
...o.bridge ? { bridge: o.bridge } : {},
|
|
13919
13819
|
...o.moderatorDefault ? { moderator: o.moderatorDefault } : {},
|
|
13920
13820
|
...o.fetchConfig ? { fetchConfig: o.fetchConfig } : {},
|
|
13921
13821
|
...o.repoRoot ? { repoRoot: o.repoRoot } : {},
|
|
@@ -13924,7 +13824,7 @@ function createTool(o, toolName, cheapDefault) {
|
|
|
13924
13824
|
})
|
|
13925
13825
|
};
|
|
13926
13826
|
}
|
|
13927
|
-
function orchestrateTool(providers, allowlist,
|
|
13827
|
+
function orchestrateTool(providers, allowlist, moderator, storage, pricing, breakers, transcriptsDir, repoRoot, nodeCache) {
|
|
13928
13828
|
return {
|
|
13929
13829
|
name: "orchestrate",
|
|
13930
13830
|
description: "Plan and execute a DAG of LLM subtasks. Either supply a `goal` (planner will draft the DAG) OR a hand-authored `dag`. Workers run topologically; recombine produces a single `final`. Covers the sequential flow, cheap_mode (per-node tier picking), and reactive (mid-flight DAG updates) \u2014 all native.",
|
|
@@ -13949,7 +13849,6 @@ function orchestrateTool(providers, allowlist, bridge, moderator, storage, prici
|
|
|
13949
13849
|
providers,
|
|
13950
13850
|
allowlist,
|
|
13951
13851
|
moderator,
|
|
13952
|
-
...bridge ? { bridge } : {},
|
|
13953
13852
|
...storage ? { storage } : {},
|
|
13954
13853
|
...pricing ? { pricing } : {},
|
|
13955
13854
|
...breakers ? { breakers } : {},
|
|
@@ -13959,7 +13858,7 @@ function orchestrateTool(providers, allowlist, bridge, moderator, storage, prici
|
|
|
13959
13858
|
})
|
|
13960
13859
|
};
|
|
13961
13860
|
}
|
|
13962
|
-
function solveTool(providers, allowlist,
|
|
13861
|
+
function solveTool(providers, allowlist, storage, breakers, transcriptsDir, repoRoot) {
|
|
13963
13862
|
return {
|
|
13964
13863
|
name: "solve",
|
|
13965
13864
|
description: "Iterative LLM solver. Generates a proposal, verifies it against the supplied verifier, and retries with feedback up to max_attempts. Verifier kinds: regex_response and shell (run in a native sandbox with wall-clock + optional memory/CPU limits). With target_path, returns a unified-diff patch.",
|
|
@@ -13981,7 +13880,6 @@ function solveTool(providers, allowlist, bridge, storage, breakers, transcriptsD
|
|
|
13981
13880
|
handler: (args) => runSolve(args, {
|
|
13982
13881
|
providers,
|
|
13983
13882
|
allowlist,
|
|
13984
|
-
...bridge ? { bridge } : {},
|
|
13985
13883
|
...storage ? { storage } : {},
|
|
13986
13884
|
...breakers ? { breakers } : {},
|
|
13987
13885
|
...transcriptsDir ? { transcriptsDir } : {},
|
|
@@ -14020,7 +13918,7 @@ function configPinTool(repoRoot, config2, rejectDriftEnv) {
|
|
|
14020
13918
|
}
|
|
14021
13919
|
};
|
|
14022
13920
|
}
|
|
14023
|
-
function benchTool(providers, allowlist, storage,
|
|
13921
|
+
function benchTool(providers, allowlist, storage, moderator, defaultGoldensDir, breakers, transcriptsDir, repoRoot) {
|
|
14024
13922
|
return {
|
|
14025
13923
|
name: "bench",
|
|
14026
13924
|
description: "Run benchmark goldens against each provider's confer/review output. Each golden: {name, tool_call: confer|review, args, verifiers[]}. Returns per-provider pass/fail/error + a ranking sorted by score. Records ballots into provider_stats when storage is wired (used by triangulate's win-rate weights).",
|
|
@@ -14039,7 +13937,6 @@ function benchTool(providers, allowlist, storage, bridge, moderator, defaultGold
|
|
|
14039
13937
|
allowlist,
|
|
14040
13938
|
moderator,
|
|
14041
13939
|
...storage ? { storage } : {},
|
|
14042
|
-
...bridge ? { bridge } : {},
|
|
14043
13940
|
...defaultGoldensDir ? { defaultGoldensDir } : {},
|
|
14044
13941
|
...breakers ? { breakers } : {},
|
|
14045
13942
|
...transcriptsDir ? { transcriptsDir } : {},
|
|
@@ -14066,7 +13963,7 @@ function updateCrosscheckTool(repoRoot) {
|
|
|
14066
13963
|
}
|
|
14067
13964
|
};
|
|
14068
13965
|
}
|
|
14069
|
-
function recommendPanelTool(providers, storage
|
|
13966
|
+
function recommendPanelTool(providers, storage) {
|
|
14070
13967
|
return {
|
|
14071
13968
|
name: "recommend_panel",
|
|
14072
13969
|
description: "Recommend a minimal effective panel for a given purpose, based on historical usage_log + provider_stats. Cold-start falls back to the configured panel ordered by win-rate.",
|
|
@@ -14084,8 +13981,7 @@ function recommendPanelTool(providers, storage, bridge) {
|
|
|
14084
13981
|
},
|
|
14085
13982
|
handler: (args) => runRecommendPanel(args, {
|
|
14086
13983
|
providers,
|
|
14087
|
-
...storage ? { storage } : {}
|
|
14088
|
-
...bridge ? { bridge } : {}
|
|
13984
|
+
...storage ? { storage } : {}
|
|
14089
13985
|
})
|
|
14090
13986
|
};
|
|
14091
13987
|
}
|
|
@@ -14110,7 +14006,7 @@ function fetchTool(storage, fetchConfig, repoRoot) {
|
|
|
14110
14006
|
})
|
|
14111
14007
|
};
|
|
14112
14008
|
}
|
|
14113
|
-
function delegateTool(providers, allowlist, storage,
|
|
14009
|
+
function delegateTool(providers, allowlist, storage, moderator) {
|
|
14114
14010
|
return {
|
|
14115
14011
|
name: "delegate",
|
|
14116
14012
|
description: "Run a delegable tool (confer | review) restricted to a single named provider, with explicit quota check. Records every attempt (accepted or refused) to the delegations table; quota in the response reflects counts AFTER the current call.",
|
|
@@ -14130,12 +14026,11 @@ function delegateTool(providers, allowlist, storage, bridge, moderator) {
|
|
|
14130
14026
|
providers,
|
|
14131
14027
|
allowlist,
|
|
14132
14028
|
moderator,
|
|
14133
|
-
...storage ? { storage } : {}
|
|
14134
|
-
...bridge ? { bridge } : {}
|
|
14029
|
+
...storage ? { storage } : {}
|
|
14135
14030
|
})
|
|
14136
14031
|
};
|
|
14137
14032
|
}
|
|
14138
|
-
function explainTool(storage,
|
|
14033
|
+
function explainTool(storage, transcriptsDir) {
|
|
14139
14034
|
return {
|
|
14140
14035
|
name: "explain",
|
|
14141
14036
|
description: "Replay a session as a navigable tree with cost/latency annotations. Reads usage_log + optionally walks the transcripts directory for per-tool summaries.",
|
|
@@ -14153,12 +14048,11 @@ function explainTool(storage, bridge, transcriptsDir) {
|
|
|
14153
14048
|
},
|
|
14154
14049
|
handler: (args) => runExplain(args, {
|
|
14155
14050
|
...storage ? { storage } : {},
|
|
14156
|
-
...bridge ? { bridge } : {},
|
|
14157
14051
|
...transcriptsDir ? { transcriptsDir } : {}
|
|
14158
14052
|
})
|
|
14159
14053
|
};
|
|
14160
14054
|
}
|
|
14161
|
-
function scoreboardTool(storage,
|
|
14055
|
+
function scoreboardTool(storage, eventsPath) {
|
|
14162
14056
|
return {
|
|
14163
14057
|
name: "scoreboard",
|
|
14164
14058
|
description: "Aggregate provider ballot stats + delegation counts + table totals. Supports top_k (rank limit) and recent_limit (tail of events.jsonl when configured). Reads the engine's local stats database (auto-created at <data dir>/db.sqlite).",
|
|
@@ -14172,12 +14066,11 @@ function scoreboardTool(storage, bridge, eventsPath) {
|
|
|
14172
14066
|
},
|
|
14173
14067
|
handler: (args) => runScoreboard(args, {
|
|
14174
14068
|
...storage ? { storage } : {},
|
|
14175
|
-
...bridge ? { bridge } : {},
|
|
14176
14069
|
...eventsPath ? { eventsPath } : {}
|
|
14177
14070
|
})
|
|
14178
14071
|
};
|
|
14179
14072
|
}
|
|
14180
|
-
function sessionMemoryTool(storage
|
|
14073
|
+
function sessionMemoryTool(storage) {
|
|
14181
14074
|
return {
|
|
14182
14075
|
name: "session_memory",
|
|
14183
14076
|
description: "CRUD over the per-session working memory ledger. Actions: list, add, mark_stale, clear. Uses the engine's local database (auto-created at <data dir>/db.sqlite).",
|
|
@@ -14200,15 +14093,14 @@ function sessionMemoryTool(storage, bridge) {
|
|
|
14200
14093
|
required: ["action", "session_id"]
|
|
14201
14094
|
},
|
|
14202
14095
|
handler: (args) => runSessionMemory(args, {
|
|
14203
|
-
...storage ? { storage } : {}
|
|
14204
|
-
...bridge ? { bridge } : {}
|
|
14096
|
+
...storage ? { storage } : {}
|
|
14205
14097
|
})
|
|
14206
14098
|
};
|
|
14207
14099
|
}
|
|
14208
|
-
function recallTool(storage
|
|
14100
|
+
function recallTool(storage) {
|
|
14209
14101
|
return {
|
|
14210
14102
|
name: "recall",
|
|
14211
|
-
description: "Full-text search across persisted transcripts via SQLite FTS5. Returns rows ordered by relevance with a windowed snippet. Requires a wired Storage adapter
|
|
14103
|
+
description: "Full-text search across persisted transcripts via SQLite FTS5. Returns rows ordered by relevance with a windowed snippet. Requires a wired Storage adapter.",
|
|
14212
14104
|
inputSchema: {
|
|
14213
14105
|
type: "object",
|
|
14214
14106
|
additionalProperties: true,
|
|
@@ -14222,8 +14114,7 @@ function recallTool(storage, bridge) {
|
|
|
14222
14114
|
required: ["query"]
|
|
14223
14115
|
},
|
|
14224
14116
|
handler: (args) => runRecall(args, {
|
|
14225
|
-
...storage ? { storage } : {}
|
|
14226
|
-
...bridge ? { bridge } : {}
|
|
14117
|
+
...storage ? { storage } : {}
|
|
14227
14118
|
})
|
|
14228
14119
|
};
|
|
14229
14120
|
}
|
|
@@ -14259,7 +14150,7 @@ function modelsTool(providers, activeProviders) {
|
|
|
14259
14150
|
handler: async (args) => runModels(args, { providers, activeProviders })
|
|
14260
14151
|
};
|
|
14261
14152
|
}
|
|
14262
|
-
function reviewTool(providers, allowlist,
|
|
14153
|
+
function reviewTool(providers, allowlist, storage, breakers, transcriptsDir, repoRoot) {
|
|
14263
14154
|
return {
|
|
14264
14155
|
name: "review",
|
|
14265
14156
|
description: "Have an LLM panel peer-review a code or proposal snippet. Returns the confer envelope (one answer per provider).",
|
|
@@ -14278,7 +14169,6 @@ function reviewTool(providers, allowlist, bridge, storage, breakers, transcripts
|
|
|
14278
14169
|
handler: (args) => runReview(args, {
|
|
14279
14170
|
providers,
|
|
14280
14171
|
allowlist,
|
|
14281
|
-
...bridge ? { bridge } : {},
|
|
14282
14172
|
...storage ? { storage } : {},
|
|
14283
14173
|
...breakers ? { breakers } : {},
|
|
14284
14174
|
...transcriptsDir ? { transcriptsDir } : {},
|
|
@@ -14286,7 +14176,7 @@ function reviewTool(providers, allowlist, bridge, storage, breakers, transcripts
|
|
|
14286
14176
|
})
|
|
14287
14177
|
};
|
|
14288
14178
|
}
|
|
14289
|
-
function critiqueTool(providers, allowlist,
|
|
14179
|
+
function critiqueTool(providers, allowlist, storage, breakers, transcriptsDir, repoRoot) {
|
|
14290
14180
|
return {
|
|
14291
14181
|
name: "critique",
|
|
14292
14182
|
description: "Have each LLM panelist list the top weaknesses of a proposed answer or approach (severity-rated). Returns per-provider weakness lists + a merged list ordered by severity.",
|
|
@@ -14306,7 +14196,6 @@ function critiqueTool(providers, allowlist, bridge, storage, breakers, transcrip
|
|
|
14306
14196
|
handler: (args) => runCritique(args, {
|
|
14307
14197
|
providers,
|
|
14308
14198
|
allowlist,
|
|
14309
|
-
...bridge ? { bridge } : {},
|
|
14310
14199
|
...storage ? { storage } : {},
|
|
14311
14200
|
...breakers ? { breakers } : {},
|
|
14312
14201
|
...transcriptsDir ? { transcriptsDir } : {},
|
|
@@ -14314,7 +14203,7 @@ function critiqueTool(providers, allowlist, bridge, storage, breakers, transcrip
|
|
|
14314
14203
|
})
|
|
14315
14204
|
};
|
|
14316
14205
|
}
|
|
14317
|
-
function planTool(providers, allowlist,
|
|
14206
|
+
function planTool(providers, allowlist, storage, breakers, transcriptsDir, repoRoot) {
|
|
14318
14207
|
return {
|
|
14319
14208
|
name: "plan",
|
|
14320
14209
|
description: 'Have an LLM panel debate a step-by-step plan for the stated goal under the given constraints. Returns the debate envelope with a moderator-synthesised plan. Defaults to `mode: "fast"` (2 rounds + early_stop) \u2014 set `mode: "thorough"` for 5 rounds without early_stop. Explicit `max_rounds` / `early_stop` / `early_stop_threshold` always override the mode preset. Use `structured: true` for schema-validated synthesis.',
|
|
@@ -14341,7 +14230,6 @@ function planTool(providers, allowlist, bridge, storage, breakers, transcriptsDi
|
|
|
14341
14230
|
handler: (args) => runPlan(args, {
|
|
14342
14231
|
providers,
|
|
14343
14232
|
allowlist,
|
|
14344
|
-
...bridge ? { bridge } : {},
|
|
14345
14233
|
...storage ? { storage } : {},
|
|
14346
14234
|
...breakers ? { breakers } : {},
|
|
14347
14235
|
...transcriptsDir ? { transcriptsDir } : {},
|
|
@@ -14349,7 +14237,7 @@ function planTool(providers, allowlist, bridge, storage, breakers, transcriptsDi
|
|
|
14349
14237
|
})
|
|
14350
14238
|
};
|
|
14351
14239
|
}
|
|
14352
|
-
function triangulateTool(providers, allowlist,
|
|
14240
|
+
function triangulateTool(providers, allowlist, storage, breakers, transcriptsDir, repoRoot) {
|
|
14353
14241
|
return {
|
|
14354
14242
|
name: "triangulate",
|
|
14355
14243
|
description: "Run a coordinate flow and reshape the output as a consensus + minority report with per-provider weights. v1 uses 1.0 weights (matches a fresh provider_stats DB); future versions thread real win-rate weights when the DB layer ports.",
|
|
@@ -14370,7 +14258,6 @@ function triangulateTool(providers, allowlist, bridge, storage, breakers, transc
|
|
|
14370
14258
|
handler: (args) => runTriangulate(args, {
|
|
14371
14259
|
providers,
|
|
14372
14260
|
allowlist,
|
|
14373
|
-
...bridge ? { bridge } : {},
|
|
14374
14261
|
...storage ? { storage } : {},
|
|
14375
14262
|
...breakers ? { breakers } : {},
|
|
14376
14263
|
...transcriptsDir ? { transcriptsDir } : {},
|
|
@@ -14378,7 +14265,7 @@ function triangulateTool(providers, allowlist, bridge, storage, breakers, transc
|
|
|
14378
14265
|
})
|
|
14379
14266
|
};
|
|
14380
14267
|
}
|
|
14381
|
-
function coordinateTool(providers, allowlist,
|
|
14268
|
+
function coordinateTool(providers, allowlist, innerCallers, storage, breakers, transcriptsDir, repoRoot, workerToolsCfg) {
|
|
14382
14269
|
return {
|
|
14383
14270
|
name: "coordinate",
|
|
14384
14271
|
description: "Run a three-role coordination flow (proposer \u2192 critics \u2192 synthesizer) with structured output at every step. Native opts: untrusted_input (canary + neutralize), worker_tools (bounded ReAct on proposer + critic roles; synth never sees inner tools), inject_session_memory (storage-backed working-memory block prepended to the topic).",
|
|
@@ -14403,7 +14290,6 @@ function coordinateTool(providers, allowlist, bridge, innerCallers, storage, bre
|
|
|
14403
14290
|
handler: (args) => runCoordinate(args, {
|
|
14404
14291
|
providers,
|
|
14405
14292
|
allowlist,
|
|
14406
|
-
...bridge ? { bridge } : {},
|
|
14407
14293
|
innerCallers,
|
|
14408
14294
|
...storage ? { storage } : {},
|
|
14409
14295
|
...breakers ? { breakers } : {},
|
|
@@ -14413,7 +14299,7 @@ function coordinateTool(providers, allowlist, bridge, innerCallers, storage, bre
|
|
|
14413
14299
|
})
|
|
14414
14300
|
};
|
|
14415
14301
|
}
|
|
14416
|
-
function debateTool(providers, allowlist,
|
|
14302
|
+
function debateTool(providers, allowlist, innerCallers, storage, pricing, breakers, transcriptsDir, repoRoot, workerToolsCfg) {
|
|
14417
14303
|
return {
|
|
14418
14304
|
name: "debate",
|
|
14419
14305
|
description: "Run a multi-round debate between LLM providers and synthesise the result via a moderator. Native opts: inject_session_memory, auto_panel, worker_tools, structured synthesis (schema-validated), extract_claims (final-round distillation), early_stop (post-round agreement check).",
|
|
@@ -14443,7 +14329,6 @@ function debateTool(providers, allowlist, bridge, innerCallers, storage, pricing
|
|
|
14443
14329
|
handler: (args) => runDebate(args, {
|
|
14444
14330
|
providers,
|
|
14445
14331
|
allowlist,
|
|
14446
|
-
...bridge ? { bridge } : {},
|
|
14447
14332
|
innerCallers,
|
|
14448
14333
|
...storage ? { storage } : {},
|
|
14449
14334
|
...pricing ? { pricing } : {},
|
|
@@ -14463,10 +14348,10 @@ function buildInnerCallers(o) {
|
|
|
14463
14348
|
...o.repoRoot ? { repoRoot: o.repoRoot } : {}
|
|
14464
14349
|
});
|
|
14465
14350
|
}
|
|
14466
|
-
out.verify = (args) => runVerify(args, o.
|
|
14351
|
+
out.verify = (args) => runVerify(args, o.fetchConfig);
|
|
14467
14352
|
return out;
|
|
14468
14353
|
}
|
|
14469
|
-
function conferTool(providers, allowlist,
|
|
14354
|
+
function conferTool(providers, allowlist, moderator, pricing, storage, innerCallers, breakers, transcriptsDir, repoRoot, workerToolsCfg) {
|
|
14470
14355
|
return {
|
|
14471
14356
|
name: "confer",
|
|
14472
14357
|
description: "Ask a panel of LLM providers the same question; return one answer per provider. Native opts: untrusted_input (canary + neutralization), early_stop (cheap-tier agreement check after first 2 panelists when N>=3), extract_claims (cheap-tier extractor with per-provider support maps), inject_session_memory (storage-backed working-memory block prepended to the first user message), auto_panel (router-driven top-N panel pick), worker_tools (bounded ReAct loop per panelist when innerCallers are wired by the host).",
|
|
@@ -14493,7 +14378,6 @@ function conferTool(providers, allowlist, bridge, moderator, pricing, storage, i
|
|
|
14493
14378
|
handler: (args) => runConfer(args, {
|
|
14494
14379
|
providers,
|
|
14495
14380
|
allowlist,
|
|
14496
|
-
...bridge ? { bridge } : {},
|
|
14497
14381
|
moderator,
|
|
14498
14382
|
...pricing ? { pricing } : {},
|
|
14499
14383
|
...storage ? { storage } : {},
|
|
@@ -14505,7 +14389,7 @@ function conferTool(providers, allowlist, bridge, moderator, pricing, storage, i
|
|
|
14505
14389
|
})
|
|
14506
14390
|
};
|
|
14507
14391
|
}
|
|
14508
|
-
function auditTool(providers, allowlist,
|
|
14392
|
+
function auditTool(providers, allowlist, transcriptsDir, pricing, storage, breakers, repoRoot) {
|
|
14509
14393
|
return {
|
|
14510
14394
|
name: "audit",
|
|
14511
14395
|
description: "Score a piece of output against an audit rubric. Single-judge by default; coalesce-mode (multi-judge consensus) and panel-exhausted self-audit run natively. cheap_mode picks the cheapest 'med'-tier model as auditor when a pricing.json is wired. session_id-only inputs load the latest transcript automatically when a transcripts directory is wired.",
|
|
@@ -14531,7 +14415,6 @@ function auditTool(providers, allowlist, bridge, transcriptsDir, pricing, storag
|
|
|
14531
14415
|
handler: (args) => runAudit(args, {
|
|
14532
14416
|
providers,
|
|
14533
14417
|
allowlist,
|
|
14534
|
-
...bridge ? { bridge } : {},
|
|
14535
14418
|
...transcriptsDir ? { transcriptsDir } : {},
|
|
14536
14419
|
...pricing ? { pricing } : {},
|
|
14537
14420
|
...storage ? { storage } : {},
|
|
@@ -14595,7 +14478,7 @@ function pickTool(providers, allowlist, storage, breakers, transcriptsDir, repoR
|
|
|
14595
14478
|
})
|
|
14596
14479
|
};
|
|
14597
14480
|
}
|
|
14598
|
-
function verifyTool(
|
|
14481
|
+
function verifyTool(fetchConfig) {
|
|
14599
14482
|
return {
|
|
14600
14483
|
name: "verify",
|
|
14601
14484
|
description: "Run a list of deterministic property checks against caller-supplied data. No LLM calls; everything is local. Returns per-check {passed, reason} plus all_passed / summary / timing fields. Supports the text kinds (contains, not_contains, regex_match, contains_any, contains_all, min_length), shell (sandboxed subprocess with timeout + Unix pgid isolation), and url_head (HEAD request gated by fetch.url_allowlist). All kinds run natively.",
|
|
@@ -14613,7 +14496,7 @@ function verifyTool(bridge, fetchConfig) {
|
|
|
14613
14496
|
},
|
|
14614
14497
|
required: ["checks"]
|
|
14615
14498
|
},
|
|
14616
|
-
handler: (args) => runVerify(args,
|
|
14499
|
+
handler: (args) => runVerify(args, fetchConfig)
|
|
14617
14500
|
};
|
|
14618
14501
|
}
|
|
14619
14502
|
function pingTool() {
|
|
@@ -14693,18 +14576,18 @@ function attachUpdateNotice(result, toolName, opts) {
|
|
|
14693
14576
|
|
|
14694
14577
|
// src/core/telemetry.ts
|
|
14695
14578
|
init_cjs_shims();
|
|
14696
|
-
var
|
|
14579
|
+
var import_node_crypto11 = __toESM(require("crypto"), 1);
|
|
14697
14580
|
|
|
14698
14581
|
// src/core/segments.ts
|
|
14699
14582
|
init_cjs_shims();
|
|
14700
|
-
var
|
|
14583
|
+
var import_node_crypto10 = __toESM(require("crypto"), 1);
|
|
14701
14584
|
var import_node_fs17 = require("fs");
|
|
14702
14585
|
var import_node_path16 = __toESM(require("path"), 1);
|
|
14703
14586
|
|
|
14704
14587
|
// src/core/git-context.ts
|
|
14705
14588
|
init_cjs_shims();
|
|
14706
14589
|
var import_node_child_process3 = require("child_process");
|
|
14707
|
-
var
|
|
14590
|
+
var import_node_crypto9 = __toESM(require("crypto"), 1);
|
|
14708
14591
|
var TRUNK_BRANCHES = /* @__PURE__ */ new Set([
|
|
14709
14592
|
"main",
|
|
14710
14593
|
"master",
|
|
@@ -14733,7 +14616,7 @@ function repoIdentity(cwd) {
|
|
|
14733
14616
|
return top ? `path:${top}` : null;
|
|
14734
14617
|
}
|
|
14735
14618
|
function fingerprintOf(seatKey, parts) {
|
|
14736
|
-
return
|
|
14619
|
+
return import_node_crypto9.default.createHmac("sha256", seatKey).update(parts.join("\0")).digest("hex");
|
|
14737
14620
|
}
|
|
14738
14621
|
function readGitContext(seatKey, cwd) {
|
|
14739
14622
|
try {
|
|
@@ -14786,7 +14669,7 @@ function canonicalSegmentBody(s) {
|
|
|
14786
14669
|
].join("|");
|
|
14787
14670
|
}
|
|
14788
14671
|
function signSegment(seatKey, s) {
|
|
14789
|
-
return
|
|
14672
|
+
return import_node_crypto10.default.createHmac("sha256", seatKey).update(canonicalSegmentBody(s)).digest("hex");
|
|
14790
14673
|
}
|
|
14791
14674
|
var cfgResolved = false;
|
|
14792
14675
|
var cfg = null;
|
|
@@ -14801,7 +14684,7 @@ function getConfig() {
|
|
|
14801
14684
|
const seatKey = process.env["CROSSCHECK_SEAT_HMAC_KEY"];
|
|
14802
14685
|
if (!base || !seatId || !orgId || !seatKey) return cfg = null;
|
|
14803
14686
|
if (!UUID_RE.test(seatId) || !UUID_RE.test(orgId)) return cfg = null;
|
|
14804
|
-
const sessionId = process.env["CLAUDE_SESSION_ID"] || process.env["CLAUDE_CODE_SESSION_ID"] || `engine-${
|
|
14687
|
+
const sessionId = process.env["CLAUDE_SESSION_ID"] || process.env["CLAUDE_CODE_SESSION_ID"] || `engine-${import_node_crypto10.default.randomUUID()}`;
|
|
14805
14688
|
cfg = {
|
|
14806
14689
|
url: base.replace(/\/telemetry\/?$/, "/segments"),
|
|
14807
14690
|
seatId,
|
|
@@ -14874,7 +14757,7 @@ function syncSegment(cwd) {
|
|
|
14874
14757
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
14875
14758
|
if (current) emit(c, current, now);
|
|
14876
14759
|
current = {
|
|
14877
|
-
segmentId:
|
|
14760
|
+
segmentId: import_node_crypto10.default.randomUUID(),
|
|
14878
14761
|
seq: nextSeq++,
|
|
14879
14762
|
context,
|
|
14880
14763
|
startedAt: now
|
|
@@ -14945,10 +14828,12 @@ function canonicalEventBody(e) {
|
|
|
14945
14828
|
e.status,
|
|
14946
14829
|
e.errorClass ?? ""
|
|
14947
14830
|
].join("|");
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14831
|
+
const hasV2 = e.runId !== void 0 || e.purpose !== void 0 || e.fingerprint !== void 0;
|
|
14832
|
+
const hasV3 = e.sessionId !== void 0;
|
|
14833
|
+
if (!hasV2 && !hasV3) return base;
|
|
14834
|
+
const parts = [base, e.runId ?? "", e.purpose ?? "", e.fingerprint ?? ""];
|
|
14835
|
+
if (hasV3) parts.push(e.sessionId ?? "");
|
|
14836
|
+
return parts.join("|");
|
|
14952
14837
|
}
|
|
14953
14838
|
function normalizePurpose(v) {
|
|
14954
14839
|
if (typeof v !== "string") return void 0;
|
|
@@ -14956,7 +14841,7 @@ function normalizePurpose(v) {
|
|
|
14956
14841
|
return /^[a-z0-9][a-z0-9_-]*$/.test(slug) ? slug : void 0;
|
|
14957
14842
|
}
|
|
14958
14843
|
function signEvent(seatSigningKey, e) {
|
|
14959
|
-
return
|
|
14844
|
+
return import_node_crypto11.default.createHmac("sha256", seatSigningKey).update(canonicalEventBody(e)).digest("hex");
|
|
14960
14845
|
}
|
|
14961
14846
|
var configResolved = false;
|
|
14962
14847
|
var config = null;
|
|
@@ -15066,9 +14951,9 @@ function scheduleFlush() {
|
|
|
15066
14951
|
}, FLUSH_INTERVAL_MS);
|
|
15067
14952
|
if (typeof flushTimer.unref === "function") flushTimer.unref();
|
|
15068
14953
|
}
|
|
15069
|
-
function enqueue(cfg2, input, runId, fingerprint) {
|
|
14954
|
+
function enqueue(cfg2, input, runId, fingerprint, sessionId) {
|
|
15070
14955
|
const base = {
|
|
15071
|
-
eventId:
|
|
14956
|
+
eventId: import_node_crypto11.default.randomUUID(),
|
|
15072
14957
|
seatId: cfg2.seatId,
|
|
15073
14958
|
orgId: cfg2.orgId,
|
|
15074
14959
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -15085,6 +14970,7 @@ function enqueue(cfg2, input, runId, fingerprint) {
|
|
|
15085
14970
|
// omitting keeps the JSON honest about what we actually know.
|
|
15086
14971
|
...input.errorClass === void 0 ? {} : { errorClass: input.errorClass },
|
|
15087
14972
|
runId,
|
|
14973
|
+
sessionId,
|
|
15088
14974
|
// Omit entirely (not "") when unknown, so the canonical body stays
|
|
15089
14975
|
// consistent with what the server reconstructs from the JSON.
|
|
15090
14976
|
...input.purpose === void 0 ? {} : { purpose: input.purpose },
|
|
@@ -15099,15 +14985,23 @@ function enqueue(cfg2, input, runId, fingerprint) {
|
|
|
15099
14985
|
if (queue.length >= FLUSH_BATCH_AT) void flush();
|
|
15100
14986
|
else scheduleFlush();
|
|
15101
14987
|
}
|
|
14988
|
+
function sessionIdFromEnvelope(out) {
|
|
14989
|
+
if (!out || typeof out !== "object") return null;
|
|
14990
|
+
const rs = out["run_summary"];
|
|
14991
|
+
if (!rs || typeof rs !== "object") return null;
|
|
14992
|
+
const v = rs["session_id"];
|
|
14993
|
+
return typeof v === "string" && v.trim().length > 0 ? v : null;
|
|
14994
|
+
}
|
|
15102
14995
|
function recordUsage(out, toolName) {
|
|
15103
14996
|
try {
|
|
15104
14997
|
const cfg2 = getConfig2();
|
|
15105
14998
|
if (!cfg2) return;
|
|
15106
14999
|
if (toolName === "update_crosscheck") return;
|
|
15107
|
-
const runId =
|
|
15000
|
+
const runId = import_node_crypto11.default.randomUUID();
|
|
15001
|
+
const sessionId = resolveSessionId(sessionIdFromEnvelope(out));
|
|
15108
15002
|
const fingerprint = currentFingerprint();
|
|
15109
15003
|
for (const ev of usageEventsFromEnvelope(out, toolName)) {
|
|
15110
|
-
enqueue(cfg2, ev, runId, fingerprint);
|
|
15004
|
+
enqueue(cfg2, ev, runId, fingerprint, sessionId);
|
|
15111
15005
|
}
|
|
15112
15006
|
} catch {
|
|
15113
15007
|
}
|
|
@@ -15214,7 +15108,7 @@ function createServer(opts = {}) {
|
|
|
15214
15108
|
throw new Error(`unknown tool: ${name}`);
|
|
15215
15109
|
}
|
|
15216
15110
|
const args = req.params.arguments ?? {};
|
|
15217
|
-
const
|
|
15111
|
+
const startedAt2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
15218
15112
|
const startedHr = process.hrtime.bigint();
|
|
15219
15113
|
const id = nextEventId();
|
|
15220
15114
|
syncSegment(opts.repoRoot);
|
|
@@ -15228,7 +15122,7 @@ function createServer(opts = {}) {
|
|
|
15228
15122
|
event: "tool_invoke",
|
|
15229
15123
|
id,
|
|
15230
15124
|
tool: name,
|
|
15231
|
-
started_at:
|
|
15125
|
+
started_at: startedAt2,
|
|
15232
15126
|
duration_ms: 0,
|
|
15233
15127
|
status: "ok",
|
|
15234
15128
|
args_keys: topLevelKeys(args),
|
|
@@ -15262,7 +15156,7 @@ function createServer(opts = {}) {
|
|
|
15262
15156
|
event: "tool_invoke",
|
|
15263
15157
|
id,
|
|
15264
15158
|
tool: name,
|
|
15265
|
-
started_at:
|
|
15159
|
+
started_at: startedAt2,
|
|
15266
15160
|
duration_ms: durationMs,
|
|
15267
15161
|
status: "ok",
|
|
15268
15162
|
args_keys: topLevelKeys(args),
|
|
@@ -15284,7 +15178,7 @@ function createServer(opts = {}) {
|
|
|
15284
15178
|
event: "tool_invoke",
|
|
15285
15179
|
id,
|
|
15286
15180
|
tool: name,
|
|
15287
|
-
started_at:
|
|
15181
|
+
started_at: startedAt2,
|
|
15288
15182
|
duration_ms: durationMs,
|
|
15289
15183
|
status: "error",
|
|
15290
15184
|
args_keys: topLevelKeys(args),
|
|
@@ -15315,7 +15209,6 @@ async function connectAndServe(transport, opts = {}) {
|
|
|
15315
15209
|
}
|
|
15316
15210
|
function buildToolRegistry(opts) {
|
|
15317
15211
|
const registerOpts = {};
|
|
15318
|
-
if (opts.bridge) registerOpts.bridge = opts.bridge;
|
|
15319
15212
|
if (opts.providers) registerOpts.providers = opts.providers;
|
|
15320
15213
|
if (opts.providerAllowlist !== void 0)
|
|
15321
15214
|
registerOpts.providerAllowlist = opts.providerAllowlist;
|
|
@@ -15332,20 +15225,14 @@ function buildToolRegistry(opts) {
|
|
|
15332
15225
|
if (opts.moderatorDefault) registerOpts.moderatorDefault = opts.moderatorDefault;
|
|
15333
15226
|
if (opts.benchGoldensDir) registerOpts.benchGoldensDir = opts.benchGoldensDir;
|
|
15334
15227
|
if (opts.eventsPath) registerOpts.eventsPath = opts.eventsPath;
|
|
15335
|
-
|
|
15336
|
-
if (!opts.bridge) return tools;
|
|
15337
|
-
const proxies = buildPythonProxies(opts.bridge);
|
|
15338
|
-
for (const [name, proxy] of proxies) {
|
|
15339
|
-
if (!tools.has(name)) tools.set(name, proxy);
|
|
15340
|
-
}
|
|
15341
|
-
return tools;
|
|
15228
|
+
return registerCoreTools(registerOpts);
|
|
15342
15229
|
}
|
|
15343
15230
|
|
|
15344
15231
|
// src/core/config-file.ts
|
|
15345
15232
|
init_cjs_shims();
|
|
15346
15233
|
var import_node_fs18 = require("fs");
|
|
15347
15234
|
var import_node_path17 = __toESM(require("path"), 1);
|
|
15348
|
-
var
|
|
15235
|
+
var import_node_crypto12 = require("crypto");
|
|
15349
15236
|
function asObj(v) {
|
|
15350
15237
|
return v && typeof v === "object" && !Array.isArray(v) ? v : void 0;
|
|
15351
15238
|
}
|
|
@@ -15479,7 +15366,7 @@ function mapConfig(raw, sourcePath) {
|
|
|
15479
15366
|
if (extras && extras.length > 0) cfg2.patterns_extra = extras;
|
|
15480
15367
|
if (bool(red["hmac_tokens"]) === true) {
|
|
15481
15368
|
cfg2.hmac_tokens = true;
|
|
15482
|
-
cfg2.hmac_secret = (0,
|
|
15369
|
+
cfg2.hmac_secret = (0, import_node_crypto12.randomBytes)(32);
|
|
15483
15370
|
}
|
|
15484
15371
|
if (Object.keys(cfg2).length > 0) setRedactionConfig(cfg2);
|
|
15485
15372
|
}
|
|
@@ -15513,14 +15400,39 @@ function loadConfigFile(opts) {
|
|
|
15513
15400
|
return mapConfig(obj, file);
|
|
15514
15401
|
}
|
|
15515
15402
|
|
|
15403
|
+
// src/core/process-registry.ts
|
|
15404
|
+
init_cjs_shims();
|
|
15405
|
+
var import_node_fs19 = require("fs");
|
|
15406
|
+
var import_node_os3 = __toESM(require("os"), 1);
|
|
15407
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
15408
|
+
function registryDir(env = process.env) {
|
|
15409
|
+
const base = env["CROSSCHECK_DATA_DIR"] || import_node_path18.default.join(env["HOME"] ?? env["USERPROFILE"] ?? import_node_os3.default.homedir(), ".crosscheck");
|
|
15410
|
+
return import_node_path18.default.join(base, "procs");
|
|
15411
|
+
}
|
|
15412
|
+
function registerProcess(rec, env = process.env) {
|
|
15413
|
+
try {
|
|
15414
|
+
const dir = registryDir(env);
|
|
15415
|
+
(0, import_node_fs19.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
15416
|
+
(0, import_node_fs19.writeFileSync)(import_node_path18.default.join(dir, `${rec.pid}.json`), JSON.stringify(rec), { mode: 384 });
|
|
15417
|
+
} catch {
|
|
15418
|
+
}
|
|
15419
|
+
}
|
|
15420
|
+
function unregisterProcess(pid = process.pid, env = process.env) {
|
|
15421
|
+
try {
|
|
15422
|
+
(0, import_node_fs19.rmSync)(import_node_path18.default.join(registryDir(env), `${pid}.json`), { force: true });
|
|
15423
|
+
} catch {
|
|
15424
|
+
}
|
|
15425
|
+
}
|
|
15426
|
+
|
|
15516
15427
|
// src/entrypoints/node-stdio.ts
|
|
15428
|
+
var HERE = typeof __dirname !== "undefined" ? __dirname : import_node_path19.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl));
|
|
15517
15429
|
var SHUTDOWN_TIMEOUT_MS = 2e3;
|
|
15518
15430
|
async function main() {
|
|
15519
15431
|
enforceLicenseOrExit();
|
|
15520
|
-
const cfgDataDir = process.env["CROSSCHECK_DATA_DIR"] ||
|
|
15432
|
+
const cfgDataDir = process.env["CROSSCHECK_DATA_DIR"] || import_node_path19.default.join(process.env["HOME"] ?? process.env["USERPROFILE"] ?? "", ".crosscheck");
|
|
15521
15433
|
const configFile = loadConfigFile({
|
|
15522
15434
|
startDir: process.cwd(),
|
|
15523
|
-
repoRoot: findGitRoot(
|
|
15435
|
+
repoRoot: findGitRoot(HERE),
|
|
15524
15436
|
dataDir: cfgDataDir
|
|
15525
15437
|
});
|
|
15526
15438
|
if (configFile) {
|
|
@@ -15534,15 +15446,17 @@ async function main() {
|
|
|
15534
15446
|
`);
|
|
15535
15447
|
}
|
|
15536
15448
|
setEventEmitter(buildDefaultEmitter(process.env));
|
|
15537
|
-
if (process.env["CROSSCHECK_BRIDGE_PYTHON"] === "1") {
|
|
15538
|
-
process.stderr.write(
|
|
15539
|
-
"crosscheck-agent: CROSSCHECK_BRIDGE_PYTHON is deprecated and ignored \u2014 the engine is native-only.\n"
|
|
15540
|
-
);
|
|
15541
|
-
}
|
|
15542
15449
|
installShutdownHandlers();
|
|
15450
|
+
registerProcess({
|
|
15451
|
+
pid: process.pid,
|
|
15452
|
+
version: SERVER_VERSION,
|
|
15453
|
+
startedAt: Date.now(),
|
|
15454
|
+
ppid: process.ppid,
|
|
15455
|
+
sessionId: engineSessionId()
|
|
15456
|
+
});
|
|
15543
15457
|
const bundledPricing = (() => {
|
|
15544
15458
|
try {
|
|
15545
|
-
return
|
|
15459
|
+
return import_node_path19.default.join(import_node_path19.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl)), "pricing.json");
|
|
15546
15460
|
} catch {
|
|
15547
15461
|
return void 0;
|
|
15548
15462
|
}
|
|
@@ -15551,7 +15465,7 @@ async function main() {
|
|
|
15551
15465
|
process.env["CROSSCHECK_PRICING_PATH"],
|
|
15552
15466
|
resolveRepoFile("config/pricing.json"),
|
|
15553
15467
|
bundledPricing
|
|
15554
|
-
].find((p) => p && (0,
|
|
15468
|
+
].find((p) => p && (0, import_node_fs20.existsSync)(p));
|
|
15555
15469
|
const pricing = pricingPath ? loadPricing(pricingPath) : {};
|
|
15556
15470
|
const providers = buildProviders({ env: process.env, pricing });
|
|
15557
15471
|
if (Object.keys(providers).length > 0) {
|
|
@@ -15569,10 +15483,10 @@ async function main() {
|
|
|
15569
15483
|
}
|
|
15570
15484
|
let storage;
|
|
15571
15485
|
if (process.env["CROSSCHECK_DB_DISABLED"] !== "1") {
|
|
15572
|
-
const dbPath = process.env["CROSSCHECK_DB_PATH"] ?? resolveRepoFile(".crosscheck/db.sqlite") ??
|
|
15486
|
+
const dbPath = process.env["CROSSCHECK_DB_PATH"] ?? resolveRepoFile(".crosscheck/db.sqlite") ?? import_node_path19.default.join(cfgDataDir, "db.sqlite");
|
|
15573
15487
|
if (dbPath) {
|
|
15574
15488
|
try {
|
|
15575
|
-
(0,
|
|
15489
|
+
(0, import_node_fs20.mkdirSync)(import_node_path19.default.dirname(dbPath), { recursive: true });
|
|
15576
15490
|
const { openBetterSqliteStorage: openBetterSqliteStorage2 } = await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports));
|
|
15577
15491
|
storage = openBetterSqliteStorage2({ path: dbPath });
|
|
15578
15492
|
await storage.migrate();
|
|
@@ -15590,7 +15504,7 @@ async function main() {
|
|
|
15590
15504
|
}
|
|
15591
15505
|
}
|
|
15592
15506
|
const transcriptsDir = configFile?.logTranscripts === false ? void 0 : process.env["CROSSCHECK_TRANSCRIPTS_DIR"] ?? configFile?.transcriptsDir ?? resolveRepoFile(".crosscheck/transcripts");
|
|
15593
|
-
const repoRoot = process.env["CROSSCHECK_REPO_ROOT"] ?? findGitRoot(
|
|
15507
|
+
const repoRoot = process.env["CROSSCHECK_REPO_ROOT"] ?? findGitRoot(HERE);
|
|
15594
15508
|
const transport = new import_stdio.StdioServerTransport();
|
|
15595
15509
|
const serverOpts = { providers };
|
|
15596
15510
|
if (storage) serverOpts.storage = storage;
|
|
@@ -15620,6 +15534,7 @@ function installShutdownHandlers() {
|
|
|
15620
15534
|
new Promise((resolve2) => setTimeout(resolve2, SHUTDOWN_TIMEOUT_MS))
|
|
15621
15535
|
]).catch(() => {
|
|
15622
15536
|
});
|
|
15537
|
+
unregisterProcess();
|
|
15623
15538
|
process.stderr.write(`crosscheck-agent: shutdown (${reason})
|
|
15624
15539
|
`);
|
|
15625
15540
|
process.exit(0);
|
|
@@ -15638,11 +15553,11 @@ function installShutdownHandlers() {
|
|
|
15638
15553
|
});
|
|
15639
15554
|
}
|
|
15640
15555
|
function resolveRepoFile(rel) {
|
|
15641
|
-
let dir =
|
|
15556
|
+
let dir = HERE;
|
|
15642
15557
|
for (let i = 0; i < 8; i++) {
|
|
15643
|
-
const candidate =
|
|
15644
|
-
if ((0,
|
|
15645
|
-
const parent =
|
|
15558
|
+
const candidate = import_node_path19.default.join(dir, rel);
|
|
15559
|
+
if ((0, import_node_fs20.existsSync)(candidate)) return candidate;
|
|
15560
|
+
const parent = import_node_path19.default.dirname(dir);
|
|
15646
15561
|
if (parent === dir) break;
|
|
15647
15562
|
dir = parent;
|
|
15648
15563
|
}
|
|
@@ -15651,8 +15566,8 @@ function resolveRepoFile(rel) {
|
|
|
15651
15566
|
function findGitRoot(startDir) {
|
|
15652
15567
|
let dir = startDir;
|
|
15653
15568
|
for (let i = 0; i < 12; i++) {
|
|
15654
|
-
if ((0,
|
|
15655
|
-
const parent =
|
|
15569
|
+
if ((0, import_node_fs20.existsSync)(import_node_path19.default.join(dir, ".git"))) return dir;
|
|
15570
|
+
const parent = import_node_path19.default.dirname(dir);
|
|
15656
15571
|
if (parent === dir) break;
|
|
15657
15572
|
dir = parent;
|
|
15658
15573
|
}
|
|
@@ -15662,7 +15577,7 @@ var isMainEntry = (() => {
|
|
|
15662
15577
|
try {
|
|
15663
15578
|
const argv1 = process.argv[1];
|
|
15664
15579
|
if (!argv1) return false;
|
|
15665
|
-
return /(?:\/|\\)node-stdio\.(?:js|cjs|mjs)$/.test(argv1);
|
|
15580
|
+
return /(?:\/|\\)node-stdio\.(?:js|cjs|mjs|ts)$/.test(argv1);
|
|
15666
15581
|
} catch {
|
|
15667
15582
|
return false;
|
|
15668
15583
|
}
|