nexus-agents 2.81.4 → 2.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{child-mcp-config-HVGU73XG.js → child-mcp-config-XVPIO5HV.js} +2 -2
- package/dist/{chunk-XZECNG2Q.js → chunk-2W4QJ27D.js} +3 -3
- package/dist/{chunk-BQ4YXGGQ.js → chunk-3ACDP4E6.js} +124 -2
- package/dist/chunk-3ACDP4E6.js.map +1 -0
- package/dist/{chunk-BZVYU4YD.js → chunk-3ASED5PR.js} +4 -4
- package/dist/{chunk-S5HMID6I.js → chunk-3GJAAENS.js} +4 -4
- package/dist/chunk-3GJAAENS.js.map +1 -0
- package/dist/{chunk-6M44ZXB4.js → chunk-3WUVWZUC.js} +2 -2
- package/dist/{chunk-R2VJY7Z4.js → chunk-4BXQ2OZY.js} +148 -103
- package/dist/chunk-4BXQ2OZY.js.map +1 -0
- package/dist/{chunk-M5ABED6T.js → chunk-54UXPJVM.js} +2 -2
- package/dist/{chunk-5TM5VL23.js → chunk-5T6SYCH2.js} +2 -2
- package/dist/{chunk-YW72ORKM.js → chunk-6WDJ3IE4.js} +3 -3
- package/dist/{chunk-EGK4RZV5.js → chunk-AFPHR72D.js} +2 -2
- package/dist/{chunk-F7N2T53R.js → chunk-AINOJRZX.js} +12 -23
- package/dist/chunk-AINOJRZX.js.map +1 -0
- package/dist/{chunk-ITMLH7TF.js → chunk-BZUEUD4G.js} +3 -3
- package/dist/{chunk-WVSQGGAH.js → chunk-FHGDJKCZ.js} +16 -13
- package/dist/{chunk-WVSQGGAH.js.map → chunk-FHGDJKCZ.js.map} +1 -1
- package/dist/{chunk-ZBABWKEA.js → chunk-FI77TGBY.js} +2 -2
- package/dist/{chunk-7J7PNOJQ.js → chunk-HFOQKCD2.js} +22 -5
- package/dist/chunk-HFOQKCD2.js.map +1 -0
- package/dist/{chunk-PPV23O3J.js → chunk-L362KRSU.js} +2 -2
- package/dist/{chunk-2GW2FZXY.js → chunk-NLPMYBIV.js} +50 -22
- package/dist/chunk-NLPMYBIV.js.map +1 -0
- package/dist/{chunk-M6KXR4LO.js → chunk-PMLVZXAE.js} +1246 -1068
- package/dist/chunk-PMLVZXAE.js.map +1 -0
- package/dist/{chunk-FAU7LVIG.js → chunk-PPBZQKRP.js} +28 -15
- package/dist/chunk-PPBZQKRP.js.map +1 -0
- package/dist/{chunk-7JLSKX3U.js → chunk-Q6PZMGLU.js} +2 -2
- package/dist/{chunk-RGKUBFTE.js → chunk-RVRXKNND.js} +3 -3
- package/dist/{chunk-HFSSADUV.js → chunk-RXVH52UI.js} +44 -28
- package/dist/{chunk-HFSSADUV.js.map → chunk-RXVH52UI.js.map} +1 -1
- package/dist/{chunk-B3MCX46I.js → chunk-U6LDVJS7.js} +2 -2
- package/dist/{chunk-K7WUEKCD.js → chunk-WGSRH5EQ.js} +3 -3
- package/dist/{chunk-M3KVQK54.js → chunk-WJFUTRHX.js} +2 -2
- package/dist/{chunk-JSQV2EOZ.js → chunk-YO27YAEX.js} +3 -3
- package/dist/{chunk-ZAY5M2AN.js → chunk-Z64MSLEK.js} +2 -2
- package/dist/{chunk-AMFVUDWI.js → chunk-ZIWEEVMI.js} +2 -2
- package/dist/{chunk-2HBQ6XXA.js → chunk-ZM5JKJHI.js} +9 -60
- package/dist/chunk-ZM5JKJHI.js.map +1 -0
- package/dist/{cli-circuit-breaker-NUZGOAVD.js → cli-circuit-breaker-Y26NPPNO.js} +4 -4
- package/dist/cli.js +460 -379
- package/dist/cli.js.map +1 -1
- package/dist/codebase-search-ZFJUVMVR.js +8 -0
- package/dist/{composite-router-4CF3P5D4.js → composite-router-X2ZYIEHH.js} +2 -2
- package/dist/{consensus-vote-7PLEGFWZ.js → consensus-vote-KZ6UURUI.js} +11 -11
- package/dist/{context-retriever-R5W4I4IB.js → context-retriever-QY4FNTDZ.js} +5 -5
- package/dist/{doctor-deep-7JTGI33O.js → doctor-deep-2E2GBMYR.js} +3 -3
- package/dist/expert-bridge-FHPWDFJX.js +13 -0
- package/dist/{factory-E2CKCYIK.js → factory-STNVY3Y3.js} +4 -4
- package/dist/{factory-DD2FPM3H.js → factory-W6KROBFN.js} +5 -5
- package/dist/index.d.ts +117 -61
- package/dist/index.js +100 -105
- package/dist/index.js.map +1 -1
- package/dist/{init-opencode-2BZWAACW.js → init-opencode-6LVZ4CAQ.js} +5 -5
- package/dist/{issue-triage-CRUJLWFY.js → issue-triage-Y77JI7WF.js} +4 -4
- package/dist/{registry-command-OHIJNUZJ.js → registry-command-P5VIAEOL.js} +2 -2
- package/dist/{repo-analyze-D2OY2QSR.js → repo-analyze-JZEMBE6R.js} +2 -2
- package/dist/{repo-security-plan-I4FZP7QA.js → repo-security-plan-RHSLO7H6.js} +4 -4
- package/dist/{research-helpers-synthesize-NMYYERCP.js → research-helpers-synthesize-PVP6JRZV.js} +3 -3
- package/dist/{routing-memory-7DA6WNSA.js → routing-memory-QRIJPRVD.js} +2 -2
- package/dist/{session-memory-LV35VSBK.js → session-memory-WARRGYY7.js} +3 -3
- package/dist/{setup-command-2OUPZSU7.js → setup-command-GMP5FI7F.js} +10 -10
- package/dist/{setup-config-TMXG3O7K.js → setup-config-G3KKZM7O.js} +3 -3
- package/dist/{setup-custom-api-N5VE2YPO.js → setup-custom-api-B63X7ISD.js} +4 -4
- package/dist/{tool-memory-JL5TF5BI.js → tool-memory-E7JW4YLT.js} +4 -4
- package/dist/{weather-report-CCOWOPFG.js → weather-report-RACZWJQL.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-2GW2FZXY.js.map +0 -1
- package/dist/chunk-2HBQ6XXA.js.map +0 -1
- package/dist/chunk-7J7PNOJQ.js.map +0 -1
- package/dist/chunk-AP2FD37C.js +0 -127
- package/dist/chunk-AP2FD37C.js.map +0 -1
- package/dist/chunk-BQ4YXGGQ.js.map +0 -1
- package/dist/chunk-ED6VQWNG.js +0 -63
- package/dist/chunk-ED6VQWNG.js.map +0 -1
- package/dist/chunk-F7N2T53R.js.map +0 -1
- package/dist/chunk-FAU7LVIG.js.map +0 -1
- package/dist/chunk-M6KXR4LO.js.map +0 -1
- package/dist/chunk-R2VJY7Z4.js.map +0 -1
- package/dist/chunk-S5HMID6I.js.map +0 -1
- package/dist/codebase-search-PIBRTGBE.js +0 -9
- package/dist/expert-bridge-J5ZKCYL5.js +0 -11
- package/dist/shared-memory-CM6T2MYE.js +0 -8
- package/dist/symbol-extractor-WYXPJH65.js +0 -10
- package/dist/tool-memory-JL5TF5BI.js.map +0 -1
- package/dist/weather-report-CCOWOPFG.js.map +0 -1
- /package/dist/{child-mcp-config-HVGU73XG.js.map → child-mcp-config-XVPIO5HV.js.map} +0 -0
- /package/dist/{chunk-XZECNG2Q.js.map → chunk-2W4QJ27D.js.map} +0 -0
- /package/dist/{chunk-BZVYU4YD.js.map → chunk-3ASED5PR.js.map} +0 -0
- /package/dist/{chunk-6M44ZXB4.js.map → chunk-3WUVWZUC.js.map} +0 -0
- /package/dist/{chunk-M5ABED6T.js.map → chunk-54UXPJVM.js.map} +0 -0
- /package/dist/{chunk-5TM5VL23.js.map → chunk-5T6SYCH2.js.map} +0 -0
- /package/dist/{chunk-YW72ORKM.js.map → chunk-6WDJ3IE4.js.map} +0 -0
- /package/dist/{chunk-EGK4RZV5.js.map → chunk-AFPHR72D.js.map} +0 -0
- /package/dist/{chunk-ITMLH7TF.js.map → chunk-BZUEUD4G.js.map} +0 -0
- /package/dist/{chunk-ZBABWKEA.js.map → chunk-FI77TGBY.js.map} +0 -0
- /package/dist/{chunk-PPV23O3J.js.map → chunk-L362KRSU.js.map} +0 -0
- /package/dist/{chunk-7JLSKX3U.js.map → chunk-Q6PZMGLU.js.map} +0 -0
- /package/dist/{chunk-RGKUBFTE.js.map → chunk-RVRXKNND.js.map} +0 -0
- /package/dist/{chunk-B3MCX46I.js.map → chunk-U6LDVJS7.js.map} +0 -0
- /package/dist/{chunk-K7WUEKCD.js.map → chunk-WGSRH5EQ.js.map} +0 -0
- /package/dist/{chunk-M3KVQK54.js.map → chunk-WJFUTRHX.js.map} +0 -0
- /package/dist/{chunk-JSQV2EOZ.js.map → chunk-YO27YAEX.js.map} +0 -0
- /package/dist/{chunk-ZAY5M2AN.js.map → chunk-Z64MSLEK.js.map} +0 -0
- /package/dist/{chunk-AMFVUDWI.js.map → chunk-ZIWEEVMI.js.map} +0 -0
- /package/dist/{cli-circuit-breaker-NUZGOAVD.js.map → cli-circuit-breaker-Y26NPPNO.js.map} +0 -0
- /package/dist/{codebase-search-PIBRTGBE.js.map → codebase-search-ZFJUVMVR.js.map} +0 -0
- /package/dist/{composite-router-4CF3P5D4.js.map → composite-router-X2ZYIEHH.js.map} +0 -0
- /package/dist/{consensus-vote-7PLEGFWZ.js.map → consensus-vote-KZ6UURUI.js.map} +0 -0
- /package/dist/{context-retriever-R5W4I4IB.js.map → context-retriever-QY4FNTDZ.js.map} +0 -0
- /package/dist/{doctor-deep-7JTGI33O.js.map → doctor-deep-2E2GBMYR.js.map} +0 -0
- /package/dist/{expert-bridge-J5ZKCYL5.js.map → expert-bridge-FHPWDFJX.js.map} +0 -0
- /package/dist/{factory-DD2FPM3H.js.map → factory-STNVY3Y3.js.map} +0 -0
- /package/dist/{factory-E2CKCYIK.js.map → factory-W6KROBFN.js.map} +0 -0
- /package/dist/{init-opencode-2BZWAACW.js.map → init-opencode-6LVZ4CAQ.js.map} +0 -0
- /package/dist/{issue-triage-CRUJLWFY.js.map → issue-triage-Y77JI7WF.js.map} +0 -0
- /package/dist/{registry-command-OHIJNUZJ.js.map → registry-command-P5VIAEOL.js.map} +0 -0
- /package/dist/{repo-analyze-D2OY2QSR.js.map → repo-analyze-JZEMBE6R.js.map} +0 -0
- /package/dist/{repo-security-plan-I4FZP7QA.js.map → repo-security-plan-RHSLO7H6.js.map} +0 -0
- /package/dist/{research-helpers-synthesize-NMYYERCP.js.map → research-helpers-synthesize-PVP6JRZV.js.map} +0 -0
- /package/dist/{routing-memory-7DA6WNSA.js.map → routing-memory-QRIJPRVD.js.map} +0 -0
- /package/dist/{session-memory-LV35VSBK.js.map → session-memory-WARRGYY7.js.map} +0 -0
- /package/dist/{setup-command-2OUPZSU7.js.map → setup-command-GMP5FI7F.js.map} +0 -0
- /package/dist/{setup-config-TMXG3O7K.js.map → setup-config-G3KKZM7O.js.map} +0 -0
- /package/dist/{setup-custom-api-N5VE2YPO.js.map → setup-custom-api-B63X7ISD.js.map} +0 -0
- /package/dist/{shared-memory-CM6T2MYE.js.map → tool-memory-E7JW4YLT.js.map} +0 -0
- /package/dist/{symbol-extractor-WYXPJH65.js.map → weather-report-RACZWJQL.js.map} +0 -0
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CUSTOM_API_BASE_URL_ENV,
|
|
3
|
-
PROVIDER_ENV_KEYS,
|
|
4
|
-
validateCustomApiBaseUrl
|
|
5
|
-
} from "./chunk-AMFVUDWI.js";
|
|
6
1
|
import {
|
|
7
2
|
AdapterModelError,
|
|
8
3
|
BaseAdapter,
|
|
9
4
|
createStream,
|
|
10
5
|
requireApiKey,
|
|
11
6
|
validateApiKeyPresence
|
|
12
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-54UXPJVM.js";
|
|
8
|
+
import {
|
|
9
|
+
CUSTOM_API_BASE_URL_ENV,
|
|
10
|
+
PROVIDER_ENV_KEYS,
|
|
11
|
+
validateCustomApiBaseUrl
|
|
12
|
+
} from "./chunk-ZIWEEVMI.js";
|
|
13
13
|
import {
|
|
14
14
|
getToolMemory
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-YO27YAEX.js";
|
|
16
16
|
import {
|
|
17
17
|
getDefaultAvailableModelsCache
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-Q6PZMGLU.js";
|
|
19
19
|
import {
|
|
20
20
|
CUSTOM_API_DEFAULT_MODEL
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ZM5JKJHI.js";
|
|
22
22
|
import {
|
|
23
23
|
createCliAdapter,
|
|
24
24
|
createCliDetectionCache,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
isCliAvailable,
|
|
28
28
|
sanitizeOutput,
|
|
29
29
|
withTimeout
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-FHGDJKCZ.js";
|
|
31
31
|
import {
|
|
32
32
|
AgentError,
|
|
33
33
|
CACHE_TIMEOUTS,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
resolveCliAlias,
|
|
71
71
|
resolveVoteTimeout,
|
|
72
72
|
toRateLimitError
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-RXVH52UI.js";
|
|
74
74
|
import {
|
|
75
75
|
ensureLearningDir,
|
|
76
76
|
getNexusDataDir,
|
|
@@ -1345,11 +1345,15 @@ function toSdkCallback(handler) {
|
|
|
1345
1345
|
}
|
|
1346
1346
|
var MCP_SDK_DEFAULT_REQUEST_TIMEOUT_MS = 6e4;
|
|
1347
1347
|
var TIMEOUT_MISMATCH_TELEMETRY_REL_PATH = "mcp-telemetry/timeout-mismatch-events.jsonl";
|
|
1348
|
+
var ensuredDirs = /* @__PURE__ */ new Set();
|
|
1348
1349
|
function appendTimeoutMismatchEvent(event) {
|
|
1349
1350
|
try {
|
|
1350
1351
|
const path = join(getNexusDataDir(), TIMEOUT_MISMATCH_TELEMETRY_REL_PATH);
|
|
1351
1352
|
const dir = dirname(path);
|
|
1352
|
-
if (!
|
|
1353
|
+
if (!ensuredDirs.has(dir)) {
|
|
1354
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
1355
|
+
ensuredDirs.add(dir);
|
|
1356
|
+
}
|
|
1353
1357
|
appendFileSync(path, JSON.stringify(event) + "\n", "utf-8");
|
|
1354
1358
|
} catch (err2) {
|
|
1355
1359
|
wrapperLogger.debug("Best-effort timeout-mismatch event recording failed", {
|
|
@@ -1792,7 +1796,7 @@ async function executeAndAudit(handler, sanitizedArgs, requestContext, requestLo
|
|
|
1792
1796
|
}
|
|
1793
1797
|
return result;
|
|
1794
1798
|
} catch (error) {
|
|
1795
|
-
const
|
|
1799
|
+
const rawMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1796
1800
|
requestLogger.error("Tool execution failed", error instanceof Error ? error : void 0);
|
|
1797
1801
|
if (config.auditLogger) {
|
|
1798
1802
|
emitToolAuditException(
|
|
@@ -1802,7 +1806,8 @@ async function executeAndAudit(handler, sanitizedArgs, requestContext, requestLo
|
|
|
1802
1806
|
getTimeProvider().now() - execStartTime
|
|
1803
1807
|
);
|
|
1804
1808
|
}
|
|
1805
|
-
|
|
1809
|
+
const sanitized = sanitizeOutput2(rawMessage, requestLogger);
|
|
1810
|
+
return internalError(sanitized, requestContext.requestId);
|
|
1806
1811
|
}
|
|
1807
1812
|
}
|
|
1808
1813
|
|
|
@@ -3634,12 +3639,24 @@ async function pickFallback(retiredModelId, cache, registry) {
|
|
|
3634
3639
|
}
|
|
3635
3640
|
function wrapResilientWithFallback(inner, options = {}) {
|
|
3636
3641
|
const wrapped = withModelNotFoundFallback(inner, options);
|
|
3637
|
-
|
|
3642
|
+
const surface = {
|
|
3638
3643
|
getHealth: inner.getHealth.bind(inner),
|
|
3639
3644
|
refresh: inner.refresh.bind(inner),
|
|
3640
3645
|
setPreferredCli: inner.setPreferredCli.bind(inner),
|
|
3641
3646
|
onFailover: inner.onFailover.bind(inner),
|
|
3642
3647
|
dispose: inner.dispose.bind(inner)
|
|
3648
|
+
};
|
|
3649
|
+
const explicit = Object.assign(wrapped, surface);
|
|
3650
|
+
const innerAsRecord = inner;
|
|
3651
|
+
return new Proxy(explicit, {
|
|
3652
|
+
get(target, prop, receiver) {
|
|
3653
|
+
if (prop in target) return Reflect.get(target, prop, receiver);
|
|
3654
|
+
const innerProp = innerAsRecord[prop];
|
|
3655
|
+
if (typeof innerProp === "function") {
|
|
3656
|
+
return innerProp.bind(inner);
|
|
3657
|
+
}
|
|
3658
|
+
return innerProp;
|
|
3659
|
+
}
|
|
3643
3660
|
});
|
|
3644
3661
|
}
|
|
3645
3662
|
|
|
@@ -7639,9 +7656,10 @@ import { z as z8 } from "zod";
|
|
|
7639
7656
|
var logger6 = createLogger({ component: "correlation-persistence" });
|
|
7640
7657
|
var VOTING_SUBDIR = "voting";
|
|
7641
7658
|
var CORRELATIONS_FILE = "correlations.json";
|
|
7659
|
+
var CORRELATIONS_JSONL_FILE = "correlations.jsonl";
|
|
7642
7660
|
var FILE_MODE = 384;
|
|
7643
7661
|
var DIR_MODE = 448;
|
|
7644
|
-
var SCHEMA_VERSION =
|
|
7662
|
+
var SCHEMA_VERSION = 2;
|
|
7645
7663
|
var PersistedVoteSchema = z8.object({
|
|
7646
7664
|
agentId: z8.string(),
|
|
7647
7665
|
decision: z8.enum(["approve", "reject", "abstain"]),
|
|
@@ -7661,6 +7679,9 @@ var PersistedCorrelationDataSchema = z8.object({
|
|
|
7661
7679
|
function getCorrelationDataPath() {
|
|
7662
7680
|
return nexusDataPath(VOTING_SUBDIR, CORRELATIONS_FILE);
|
|
7663
7681
|
}
|
|
7682
|
+
function getCorrelationJsonlPath() {
|
|
7683
|
+
return nexusDataPath(VOTING_SUBDIR, CORRELATIONS_JSONL_FILE);
|
|
7684
|
+
}
|
|
7664
7685
|
function ensureVotingDirectory() {
|
|
7665
7686
|
const dirPath = nexusDataPath(VOTING_SUBDIR);
|
|
7666
7687
|
try {
|
|
@@ -7671,116 +7692,137 @@ function ensureVotingDirectory() {
|
|
|
7671
7692
|
return err(new Error(`Failed to create voting directory at ${dirPath}: ${error.message}`));
|
|
7672
7693
|
}
|
|
7673
7694
|
}
|
|
7674
|
-
function
|
|
7675
|
-
const proposalMap = /* @__PURE__ */ new Map();
|
|
7676
|
-
for (const proposal of existingProposals) {
|
|
7677
|
-
proposalMap.set(proposal.proposalId, proposal);
|
|
7678
|
-
}
|
|
7679
|
-
for (const proposal of newProposals) {
|
|
7680
|
-
proposalMap.set(proposal.proposalId, proposal);
|
|
7681
|
-
}
|
|
7682
|
-
const merged = Array.from(proposalMap.values());
|
|
7683
|
-
merged.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
7684
|
-
if (merged.length > maxProposals) {
|
|
7685
|
-
return merged.slice(merged.length - maxProposals);
|
|
7686
|
-
}
|
|
7687
|
-
return merged;
|
|
7688
|
-
}
|
|
7689
|
-
function saveCorrelationData(proposals, config = DEFAULT_HIGHER_ORDER_CONFIG) {
|
|
7695
|
+
function saveCorrelationData(proposals, _config = DEFAULT_HIGHER_ORDER_CONFIG) {
|
|
7690
7696
|
const dirResult = ensureVotingDirectory();
|
|
7691
7697
|
if (!dirResult.ok) return dirResult;
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
const loadResult = loadCorrelationData();
|
|
7695
|
-
if (loadResult.ok) {
|
|
7696
|
-
existingProposals = loadResult.value.proposals;
|
|
7697
|
-
}
|
|
7698
|
-
const merged = mergeProposals(existingProposals, proposals, config.maxProposals);
|
|
7699
|
-
const data = {
|
|
7700
|
-
version: SCHEMA_VERSION,
|
|
7701
|
-
proposals: merged,
|
|
7702
|
-
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7703
|
-
};
|
|
7704
|
-
const json = JSON.stringify(data, null, 2);
|
|
7705
|
-
const tempPath = `${filePath}.tmp.${String(process.pid)}`;
|
|
7698
|
+
if (proposals.length === 0) return ok(void 0);
|
|
7699
|
+
const filePath = getCorrelationJsonlPath();
|
|
7706
7700
|
try {
|
|
7707
|
-
|
|
7708
|
-
fs.
|
|
7709
|
-
logger6.info("Correlation
|
|
7701
|
+
const lines = proposals.map((p) => JSON.stringify(p)).join("\n") + "\n";
|
|
7702
|
+
fs.appendFileSync(filePath, lines, { encoding: "utf-8", mode: FILE_MODE });
|
|
7703
|
+
logger6.info("Correlation proposals appended", {
|
|
7710
7704
|
path: filePath,
|
|
7711
|
-
proposalCount:
|
|
7705
|
+
proposalCount: proposals.length
|
|
7712
7706
|
});
|
|
7713
7707
|
return ok(void 0);
|
|
7714
7708
|
} catch (cause) {
|
|
7715
|
-
try {
|
|
7716
|
-
fs.unlinkSync(tempPath);
|
|
7717
|
-
} catch (cleanupErr) {
|
|
7718
|
-
const msg = cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr);
|
|
7719
|
-
logger6.debug("Failed to clean up temp file during correlation save", {
|
|
7720
|
-
path: tempPath,
|
|
7721
|
-
error: msg
|
|
7722
|
-
});
|
|
7723
|
-
}
|
|
7724
7709
|
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
7725
|
-
return err(new Error(`Failed to
|
|
7710
|
+
return err(new Error(`Failed to append correlation data: ${error.message}`));
|
|
7726
7711
|
}
|
|
7727
7712
|
}
|
|
7728
|
-
function
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
}
|
|
7713
|
+
function loadLegacyJsonProposals() {
|
|
7714
|
+
const filePath = getCorrelationDataPath();
|
|
7715
|
+
if (!fs.existsSync(filePath)) return [];
|
|
7732
7716
|
let rawContent;
|
|
7733
7717
|
try {
|
|
7734
7718
|
rawContent = fs.readFileSync(filePath, { encoding: "utf-8" });
|
|
7735
7719
|
} catch (cause) {
|
|
7736
|
-
|
|
7737
|
-
|
|
7720
|
+
logger6.warn("Failed to read legacy correlations.json", {
|
|
7721
|
+
path: filePath,
|
|
7722
|
+
error: cause instanceof Error ? cause.message : String(cause)
|
|
7723
|
+
});
|
|
7724
|
+
return [];
|
|
7738
7725
|
}
|
|
7726
|
+
let parsed;
|
|
7739
7727
|
try {
|
|
7740
|
-
|
|
7728
|
+
parsed = JSON.parse(rawContent);
|
|
7741
7729
|
} catch (cause) {
|
|
7742
|
-
|
|
7743
|
-
|
|
7730
|
+
logger6.warn("Corrupt legacy correlations.json \u2014 skipping", {
|
|
7731
|
+
path: filePath,
|
|
7732
|
+
error: cause instanceof Error ? cause.message : String(cause)
|
|
7733
|
+
});
|
|
7734
|
+
return [];
|
|
7735
|
+
}
|
|
7736
|
+
const result = PersistedCorrelationDataSchema.safeParse(parsed);
|
|
7737
|
+
if (!result.success) {
|
|
7738
|
+
logger6.warn("Invalid legacy correlations.json schema \u2014 skipping", {
|
|
7744
7739
|
path: filePath,
|
|
7745
|
-
error: error.message
|
|
7740
|
+
error: result.error.message
|
|
7746
7741
|
});
|
|
7747
|
-
return
|
|
7742
|
+
return [];
|
|
7748
7743
|
}
|
|
7744
|
+
return result.data.proposals;
|
|
7749
7745
|
}
|
|
7750
|
-
function
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7746
|
+
function parseJsonlLine(line) {
|
|
7747
|
+
let parsed;
|
|
7748
|
+
try {
|
|
7749
|
+
parsed = JSON.parse(line);
|
|
7750
|
+
} catch (cause) {
|
|
7751
|
+
return {
|
|
7752
|
+
kind: "skip",
|
|
7753
|
+
reason: `JSON.parse: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
7754
|
+
};
|
|
7755
|
+
}
|
|
7756
|
+
const result = PersistedProposalSchema.safeParse(parsed);
|
|
7757
|
+
if (!result.success) return { kind: "skip", reason: `schema: ${result.error.message}` };
|
|
7758
|
+
return { kind: "ok", proposal: result.data };
|
|
7759
|
+
}
|
|
7760
|
+
function loadJsonlProposals() {
|
|
7761
|
+
const filePath = getCorrelationJsonlPath();
|
|
7762
|
+
if (!fs.existsSync(filePath)) return [];
|
|
7763
|
+
let content;
|
|
7764
|
+
try {
|
|
7765
|
+
content = fs.readFileSync(filePath, { encoding: "utf-8" });
|
|
7766
|
+
} catch (cause) {
|
|
7767
|
+
logger6.warn("Failed to read correlations.jsonl", {
|
|
7754
7768
|
path: filePath,
|
|
7755
|
-
|
|
7769
|
+
error: cause instanceof Error ? cause.message : String(cause)
|
|
7756
7770
|
});
|
|
7757
|
-
return
|
|
7771
|
+
return [];
|
|
7772
|
+
}
|
|
7773
|
+
const lines = content.split("\n").filter((line) => line.trim() !== "");
|
|
7774
|
+
const proposals = [];
|
|
7775
|
+
let skippedCount = 0;
|
|
7776
|
+
let firstSkipReason;
|
|
7777
|
+
for (const line of lines) {
|
|
7778
|
+
const result = parseJsonlLine(line);
|
|
7779
|
+
if (result.kind === "ok") {
|
|
7780
|
+
proposals.push(result.proposal);
|
|
7781
|
+
} else {
|
|
7782
|
+
skippedCount++;
|
|
7783
|
+
firstSkipReason ??= result.reason;
|
|
7784
|
+
}
|
|
7758
7785
|
}
|
|
7759
|
-
if (
|
|
7760
|
-
logger6.warn("
|
|
7761
|
-
|
|
7762
|
-
|
|
7786
|
+
if (skippedCount > 0) {
|
|
7787
|
+
logger6.warn("Skipped malformed lines in correlations.jsonl", {
|
|
7788
|
+
path: filePath,
|
|
7789
|
+
skippedCount,
|
|
7790
|
+
totalLines: lines.length,
|
|
7791
|
+
firstSkipReason
|
|
7763
7792
|
});
|
|
7764
|
-
return err(
|
|
7765
|
-
new Error(
|
|
7766
|
-
`Unsupported schema version ${String(validation.data.version)} (current: ${String(SCHEMA_VERSION)})`
|
|
7767
|
-
)
|
|
7768
|
-
);
|
|
7769
7793
|
}
|
|
7770
|
-
return
|
|
7794
|
+
return proposals;
|
|
7771
7795
|
}
|
|
7772
|
-
function
|
|
7773
|
-
const
|
|
7774
|
-
const
|
|
7775
|
-
|
|
7776
|
-
const
|
|
7777
|
-
|
|
7796
|
+
function consolidate(legacyProposals, jsonlProposals, maxProposals) {
|
|
7797
|
+
const proposalMap = /* @__PURE__ */ new Map();
|
|
7798
|
+
for (const p of legacyProposals) proposalMap.set(p.proposalId, p);
|
|
7799
|
+
for (const p of jsonlProposals) proposalMap.set(p.proposalId, p);
|
|
7800
|
+
const all = Array.from(proposalMap.values()).sort(
|
|
7801
|
+
(a, b) => a.timestamp.localeCompare(b.timestamp)
|
|
7802
|
+
);
|
|
7803
|
+
return all.length > maxProposals ? all.slice(all.length - maxProposals) : all;
|
|
7804
|
+
}
|
|
7805
|
+
function loadCorrelationData(config = DEFAULT_HIGHER_ORDER_CONFIG) {
|
|
7806
|
+
const jsonlPath = getCorrelationJsonlPath();
|
|
7807
|
+
const legacyPath = getCorrelationDataPath();
|
|
7808
|
+
const jsonlExists = fs.existsSync(jsonlPath);
|
|
7809
|
+
const legacyExists = fs.existsSync(legacyPath);
|
|
7810
|
+
if (!jsonlExists && !legacyExists) {
|
|
7811
|
+
return err(new Error(`Correlation data file not found: ${jsonlPath}`));
|
|
7812
|
+
}
|
|
7813
|
+
const legacy = loadLegacyJsonProposals();
|
|
7814
|
+
const jsonl = loadJsonlProposals();
|
|
7815
|
+
const proposals = consolidate(legacy, jsonl, config.maxProposals);
|
|
7778
7816
|
logger6.info("Correlation data loaded", {
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7817
|
+
legacyCount: legacy.length,
|
|
7818
|
+
jsonlCount: jsonl.length,
|
|
7819
|
+
afterDedup: proposals.length
|
|
7820
|
+
});
|
|
7821
|
+
return ok({
|
|
7822
|
+
version: SCHEMA_VERSION,
|
|
7823
|
+
proposals,
|
|
7824
|
+
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7782
7825
|
});
|
|
7783
|
-
return validateResult;
|
|
7784
7826
|
}
|
|
7785
7827
|
function replayProposals(tracker, proposals) {
|
|
7786
7828
|
let replayed = 0;
|
|
@@ -7800,7 +7842,8 @@ function replayProposals(tracker, proposals) {
|
|
|
7800
7842
|
}
|
|
7801
7843
|
function createPersistentCorrelationTracker(config) {
|
|
7802
7844
|
const tracker = createCorrelationTracker(config);
|
|
7803
|
-
const
|
|
7845
|
+
const mergedConfig = { ...DEFAULT_HIGHER_ORDER_CONFIG, ...config };
|
|
7846
|
+
const loadResult = loadCorrelationData(mergedConfig);
|
|
7804
7847
|
if (!loadResult.ok) {
|
|
7805
7848
|
logger6.info("Starting with fresh correlation tracker", {
|
|
7806
7849
|
reason: loadResult.error.message
|
|
@@ -7965,7 +8008,7 @@ function applyErrorPolicy(votes, policy) {
|
|
|
7965
8008
|
}
|
|
7966
8009
|
|
|
7967
8010
|
// src/orchestration/outcomes/outcome-store-persistence.ts
|
|
7968
|
-
import { appendFileSync as
|
|
8011
|
+
import { appendFileSync as appendFileSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync3 } from "fs";
|
|
7969
8012
|
var PersistentOutcomeStore = class extends OutcomeStore {
|
|
7970
8013
|
filePath;
|
|
7971
8014
|
logger;
|
|
@@ -8075,7 +8118,7 @@ var PersistentOutcomeStore = class extends OutcomeStore {
|
|
|
8075
8118
|
}
|
|
8076
8119
|
persistLine(outcome) {
|
|
8077
8120
|
try {
|
|
8078
|
-
|
|
8121
|
+
appendFileSync3(this.filePath, JSON.stringify(outcome) + "\n", "utf-8");
|
|
8079
8122
|
} catch (error) {
|
|
8080
8123
|
const msg = getErrorMessage(error);
|
|
8081
8124
|
this.logger.warn("Failed to persist outcome to disk", {
|
|
@@ -8678,7 +8721,7 @@ async function processVotesWithCascade(engineVotes, opts) {
|
|
|
8678
8721
|
var CONTRARIAN_ESCALATION_THRESHOLD = 0.8;
|
|
8679
8722
|
async function runContrarianCheck(proposal, log) {
|
|
8680
8723
|
try {
|
|
8681
|
-
const { executeExpert } = await import("./expert-bridge-
|
|
8724
|
+
const { executeExpert } = await import("./expert-bridge-FHPWDFJX.js");
|
|
8682
8725
|
const prompt = [
|
|
8683
8726
|
"You are a contrarian analyst. Your job is to find reasons this proposal should be REJECTED.",
|
|
8684
8727
|
"Look for: YAGNI (not needed), MISALIGNED (wrong tech/architecture), SECURITY_RISK, SCOPE_CREEP.",
|
|
@@ -8706,7 +8749,9 @@ async function runContrarianCheck(proposal, log) {
|
|
|
8706
8749
|
return { shouldEscalate: true, reason: reasoning, confidence };
|
|
8707
8750
|
}
|
|
8708
8751
|
return { shouldEscalate: false, reason: "", confidence };
|
|
8709
|
-
} catch {
|
|
8752
|
+
} catch (error) {
|
|
8753
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8754
|
+
log.warn("Contrarian check failed; defaulting to no escalation", { error: message });
|
|
8710
8755
|
return { shouldEscalate: false, reason: "", confidence: 0 };
|
|
8711
8756
|
}
|
|
8712
8757
|
}
|
|
@@ -9095,4 +9140,4 @@ export {
|
|
|
9095
9140
|
CONSENSUS_VOTE_OUTPUT_SCHEMA,
|
|
9096
9141
|
registerConsensusVoteTool
|
|
9097
9142
|
};
|
|
9098
|
-
//# sourceMappingURL=chunk-
|
|
9143
|
+
//# sourceMappingURL=chunk-4BXQ2OZY.js.map
|