akm-cli 0.9.17-alpha.8 → 0.9.17
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/CHANGELOG.md +277 -1694
- package/STABILITY.md +9 -8
- package/dist/assets/hints/cli-hints-full.md +6 -7
- package/dist/assets/improve-strategies/catchup.json +0 -3
- package/dist/assets/improve-strategies/consolidate.json +0 -1
- package/dist/assets/improve-strategies/default.json +1 -2
- package/dist/assets/improve-strategies/proactive-maintenance.json +1 -2
- package/dist/assets/improve-strategies/quick.json +1 -2
- package/dist/assets/improve-strategies/reflect-distill.json +1 -2
- package/dist/assets/improve-strategies/thorough.json +0 -3
- package/dist/assets/prompts/consolidate-pair.md +20 -0
- package/dist/assets/stash-skeleton/facts/conventions/backlinks.md +17 -19
- package/dist/assets/stash-skeleton/facts/conventions/domains.md +2 -2
- package/dist/assets/templates/html/health.html +3 -5
- package/dist/cli/retired-commands.js +1 -1
- package/dist/cli/unknown-flags.js +24 -1
- package/dist/cli.js +46 -1
- package/dist/commands/health/archive-usage.js +92 -0
- package/dist/commands/health/data-dir-usage.js +25 -13
- package/dist/commands/health/html-report.js +1 -4
- package/dist/commands/health/improve-metrics.js +25 -37
- package/dist/commands/health/md-report.js +1 -6
- package/dist/commands/health/report-view-model.js +4 -14
- package/dist/commands/health/windows.js +0 -1
- package/dist/commands/health.js +13 -0
- package/dist/commands/improve/consolidate/continuity-check.js +137 -0
- package/dist/commands/improve/consolidate/pair-pass.js +791 -0
- package/dist/commands/improve/consolidate.js +38 -63
- package/dist/commands/improve/extract-prompt.js +1 -2
- package/dist/commands/improve/improve-cli.js +1 -1
- package/dist/commands/improve/improve-strategies.js +23 -5
- package/dist/commands/improve/improve.js +19 -30
- package/dist/commands/improve/ledger.js +3 -2
- package/dist/commands/improve/loop-stages.js +5 -85
- package/dist/commands/improve/memory/memory-belief.js +3 -1
- package/dist/commands/improve/memory/memory-improve.js +262 -11
- package/dist/commands/improve/planner.js +0 -5
- package/dist/commands/improve/preparation.js +20 -135
- package/dist/commands/improve/retrieval-scope.js +19 -4
- package/dist/commands/improve/salience.js +1 -14
- package/dist/commands/improve/stage.js +0 -1
- package/dist/commands/lint/base-linter.js +19 -11
- package/dist/commands/proposal/drain.js +8 -1
- package/dist/commands/proposal/proposal-cli.js +16 -2
- package/dist/commands/proposal/proposal-types.js +7 -0
- package/dist/commands/proposal/proposal.js +37 -6
- package/dist/commands/proposal/repository.js +613 -4
- package/dist/commands/proposal/validators/proposals.js +9 -0
- package/dist/commands/read/knowledge.js +3 -2
- package/dist/commands/read/show.js +0 -14
- package/dist/commands/sources/info.js +122 -18
- package/dist/commands/sources/stash-cli.js +23 -3
- package/dist/core/bundle-rename.js +1 -7
- package/dist/core/config/config-schema.js +8 -1
- package/dist/core/config/config.js +23 -48
- package/dist/core/config/engine-semantics.js +0 -2
- package/dist/core/config/schema/improve-processes.js +17 -42
- package/dist/core/config/schema/index-config.js +5 -25
- package/dist/core/file-change.js +13 -5
- package/dist/core/improve-result.js +22 -6
- package/dist/core/improve-types.js +0 -1
- package/dist/core/loopback.js +7 -12
- package/dist/core/parse.js +13 -16
- package/dist/core/state/migrations.js +15 -0
- package/dist/core/time.js +0 -20
- package/dist/indexer/db/llm-cache.js +2 -2
- package/dist/indexer/ensure-index.js +2 -2
- package/dist/indexer/index-written-assets.js +2 -3
- package/dist/indexer/indexer.js +18 -418
- package/dist/indexer/passes/metadata.js +0 -19
- package/dist/indexer/walk/walker.js +3 -4
- package/dist/llm/client.js +8 -10
- package/dist/llm/embedders/remote.js +1 -2
- package/dist/llm/feature-gate.js +0 -5
- package/dist/output/shapes/helpers.js +20 -4
- package/dist/output/text/command-format.js +9 -8
- package/dist/output/text/proposal-format.js +47 -1
- package/dist/output/text/show-format.js +0 -20
- package/dist/scripts/akm-migrate-node.js +923 -950
- package/dist/scripts/akm-migrate.js +923 -950
- package/dist/setup/steps/connection.js +5 -6
- package/dist/setup/steps/platforms.js +2 -2
- package/dist/sources/providers/git-stash.js +83 -4
- package/dist/storage/repositories/improve-ledger-repository.js +48 -7
- package/dist/storage/repositories/index-connection.js +5 -2
- package/dist/storage/repositories/index-entries-repository.js +4 -7
- package/dist/storage/repositories/index-entry-schema.js +4 -2
- package/dist/storage/repositories/index-llm-cache-repository.js +7 -26
- package/dist/storage/repositories/index-schema.js +55 -104
- package/dist/storage/repositories/proposals-repository.js +61 -0
- package/dist/storage/repositories/salience-repository.js +1 -19
- package/docs/migration/README.md +1 -1
- package/docs/migration/release-notes/0.9.17.md +130 -41
- package/docs/migration/release-notes/README.md +7 -0
- package/docs/reference/cli.md +27 -21
- package/docs/reference/configuration.md +21 -12
- package/docs/reference/data-and-telemetry.md +0 -1
- package/package.json +1 -1
- package/schemas/akm-config.json +0 -342
- package/dist/assets/improve-strategies/graph-refresh.json +0 -15
- package/dist/assets/prompts/contradiction-judge.md +0 -33
- package/dist/assets/prompts/graph-extract-system.md +0 -1
- package/dist/assets/prompts/graph-extract-user-prompt.md +0 -35
- package/dist/assets/prompts/metadata-enhance-system.md +0 -1
- package/dist/assets/tasks/improve/akm-graph-refresh-weekly.yml +0 -4
- package/dist/indexer/db/graph-db.js +0 -399
- package/dist/indexer/graph/graph-extraction.js +0 -809
- package/dist/indexer/graph/graph-related.js +0 -131
- package/dist/indexer/graph/graph-types.js +0 -4
- package/dist/llm/graph-extract.js +0 -892
- package/dist/llm/metadata-enhance.js +0 -95
|
@@ -26583,7 +26583,8 @@ var STATE_MIGRATION_SAFETY_BY_ID = Object.freeze({
|
|
|
26583
26583
|
"025-task-history-vocabulary-backfill": "data-preserving-rebuild",
|
|
26584
26584
|
"026-proposals-strip-legacy-fragment-refs": "data-preserving-rebuild",
|
|
26585
26585
|
"027-extract-sessions-seen-harness-rename": "data-preserving-rebuild",
|
|
26586
|
-
"028-improve-ledger": "historical-destructive"
|
|
26586
|
+
"028-improve-ledger": "historical-destructive",
|
|
26587
|
+
"029-improve-ledger-content-hash": "additive"
|
|
26587
26588
|
});
|
|
26588
26589
|
var STATE_MIGRATIONS = [
|
|
26589
26590
|
{
|
|
@@ -27321,6 +27322,12 @@ var STATE_MIGRATIONS = [
|
|
|
27321
27322
|
DROP TABLE IF EXISTS improve_cycle_metrics;
|
|
27322
27323
|
DROP TABLE IF EXISTS canary_queries;
|
|
27323
27324
|
`
|
|
27325
|
+
},
|
|
27326
|
+
{
|
|
27327
|
+
id: "029-improve-ledger-content-hash",
|
|
27328
|
+
up: `
|
|
27329
|
+
ALTER TABLE improve_ledger ADD COLUMN content_hash TEXT DEFAULT NULL;
|
|
27330
|
+
`
|
|
27324
27331
|
}
|
|
27325
27332
|
];
|
|
27326
27333
|
assertMigrationRegistry(STATE_MIGRATIONS);
|
|
@@ -27552,7 +27559,6 @@ var BUILTIN_IMPROVE_STRATEGY_NAMES = [
|
|
|
27552
27559
|
"default",
|
|
27553
27560
|
"quick",
|
|
27554
27561
|
"thorough",
|
|
27555
|
-
"graph-refresh",
|
|
27556
27562
|
"consolidate",
|
|
27557
27563
|
"catchup",
|
|
27558
27564
|
"reflect-distill",
|
|
@@ -27563,7 +27569,6 @@ var IMPROVE_PROCESS_ENGINE_CAPABILITIES = {
|
|
|
27563
27569
|
distill: "llm",
|
|
27564
27570
|
consolidate: "llm",
|
|
27565
27571
|
memoryInference: "llm",
|
|
27566
|
-
graphExtraction: "llm",
|
|
27567
27572
|
extract: "llm",
|
|
27568
27573
|
validation: "llm",
|
|
27569
27574
|
triage: "runner",
|
|
@@ -27650,7 +27655,6 @@ var INTERESTING_DELTA_PATHS = [
|
|
|
27650
27655
|
"improve.memoryInference.written",
|
|
27651
27656
|
"improve.memoryInference.yieldRate",
|
|
27652
27657
|
"improve.memoryInference.skippedNoFacts",
|
|
27653
|
-
"improve.graphExtraction.failures",
|
|
27654
27658
|
"improve.autoAccept.promoted",
|
|
27655
27659
|
"improve.autoAccept.validationFailed",
|
|
27656
27660
|
"improve.coverage.acceptedProposals",
|
|
@@ -27697,13 +27701,12 @@ function renderRunsDetailMd(runs) {
|
|
|
27697
27701
|
"distill_q/llm-fail/judge/validator/cfg/skip",
|
|
27698
27702
|
"cons_proc/promo/merge/del",
|
|
27699
27703
|
"mem_cons/written/skip",
|
|
27700
|
-
"graph_f/e/r",
|
|
27701
27704
|
"orphans",
|
|
27702
27705
|
"lint_f/fl",
|
|
27703
27706
|
"result_status"
|
|
27704
27707
|
];
|
|
27705
27708
|
const rows = runs.map((r) => {
|
|
27706
|
-
const totalActions = r.actions.reflect.ok + r.actions.reflect.failed + r.actions.reflect.cooldown + r.actions.reflect.skipped + r.actions.distill.queued + r.actions.distill.llmFailed + r.actions.distill.judgeRejected + r.actions.distill.validatorRejected + r.actions.distill.configDisabled + r.actions.distill.skipped + r.actions.memoryPrune + r.actions.memoryInference + r.actions.
|
|
27709
|
+
const totalActions = r.actions.reflect.ok + r.actions.reflect.failed + r.actions.reflect.cooldown + r.actions.reflect.skipped + r.actions.distill.queued + r.actions.distill.llmFailed + r.actions.distill.judgeRejected + r.actions.distill.validatorRejected + r.actions.distill.configDisabled + r.actions.distill.skipped + r.actions.memoryPrune + r.actions.memoryInference + r.actions.error;
|
|
27707
27710
|
return [
|
|
27708
27711
|
r.startedAt,
|
|
27709
27712
|
String(r.ok),
|
|
@@ -27713,7 +27716,6 @@ function renderRunsDetailMd(runs) {
|
|
|
27713
27716
|
`${r.actions.distill.queued}/${r.actions.distill.llmFailed}/${r.actions.distill.judgeRejected}/${r.actions.distill.validatorRejected}/${r.actions.distill.configDisabled}/${r.actions.distill.skipped}`,
|
|
27714
27717
|
`${r.consolidation.processed}/${r.consolidation.promoted}/${r.consolidation.merged}/${r.consolidation.deleted}`,
|
|
27715
27718
|
`${r.memoryInference.considered}/${r.memoryInference.written}/${r.memoryInference.skippedNoFacts}`,
|
|
27716
|
-
`${r.graphExtraction.extractedFiles}/${r.graphExtraction.entities}/${r.graphExtraction.relations}`,
|
|
27717
27719
|
String(r.orphansPurged),
|
|
27718
27720
|
`${r.lintFixed}/${r.lintFlagged}`,
|
|
27719
27721
|
r.resultStatus ?? "valid"
|
|
@@ -27728,8 +27730,6 @@ function renderWindowCompareMd(windows, deltas) {
|
|
|
27728
27730
|
const badIfPositive = new Set([
|
|
27729
27731
|
"improve.actions.reflect.failed",
|
|
27730
27732
|
"improve.actions.distill.llmFailed",
|
|
27731
|
-
"improve.graphExtraction.failures",
|
|
27732
|
-
"improve.graphExtraction.nonArrayBatchFailures",
|
|
27733
27733
|
"improve.wallTime.medianMs",
|
|
27734
27734
|
"improve.wallTime.p95Ms",
|
|
27735
27735
|
"improve.memoryInference.skippedNoFacts"
|
|
@@ -27850,7 +27850,11 @@ function shapeProposalProducerOutput(result, detail) {
|
|
|
27850
27850
|
}
|
|
27851
27851
|
function shapeProposalEntry(entry, detail) {
|
|
27852
27852
|
if (detail === "brief") {
|
|
27853
|
-
|
|
27853
|
+
const retirement = entry.retirement;
|
|
27854
|
+
return {
|
|
27855
|
+
...pickFields(entry, ["id", "ref", "status", "source", "createdAt"]),
|
|
27856
|
+
...retirement?.continuityRisk ? { continuityRisk: true } : {}
|
|
27857
|
+
};
|
|
27854
27858
|
}
|
|
27855
27859
|
if (detail === "normal") {
|
|
27856
27860
|
return pickFields(entry, [
|
|
@@ -27863,7 +27867,8 @@ function shapeProposalEntry(entry, detail) {
|
|
|
27863
27867
|
"updatedAt",
|
|
27864
27868
|
"confidence",
|
|
27865
27869
|
"gateDecision",
|
|
27866
|
-
"review"
|
|
27870
|
+
"review",
|
|
27871
|
+
"retirement"
|
|
27867
27872
|
]);
|
|
27868
27873
|
}
|
|
27869
27874
|
return pickFields(entry, [
|
|
@@ -27877,7 +27882,11 @@ function shapeProposalEntry(entry, detail) {
|
|
|
27877
27882
|
"confidence",
|
|
27878
27883
|
"gateDecision",
|
|
27879
27884
|
"payload",
|
|
27880
|
-
"review"
|
|
27885
|
+
"review",
|
|
27886
|
+
"retirement",
|
|
27887
|
+
"retiredArchive",
|
|
27888
|
+
"promotionSource",
|
|
27889
|
+
"promotionSourceHash"
|
|
27881
27890
|
]);
|
|
27882
27891
|
}
|
|
27883
27892
|
function shapeProposalListOutput(result, detail) {
|
|
@@ -28124,7 +28133,6 @@ function shapeShowOutput(result, detail, shape = "human") {
|
|
|
28124
28133
|
"workflowParameters",
|
|
28125
28134
|
"steps",
|
|
28126
28135
|
"keys",
|
|
28127
|
-
"related",
|
|
28128
28136
|
"links",
|
|
28129
28137
|
...FRAGMENT_PROVENANCE_FIELDS,
|
|
28130
28138
|
...FRAGMENT_CONTEXT_FIELDS
|
|
@@ -28146,7 +28154,6 @@ function shapeShowOutput(result, detail, shape = "human") {
|
|
|
28146
28154
|
"run",
|
|
28147
28155
|
"origin",
|
|
28148
28156
|
"keys",
|
|
28149
|
-
"related",
|
|
28150
28157
|
"links",
|
|
28151
28158
|
...FRAGMENT_PROVENANCE_FIELDS,
|
|
28152
28159
|
...FRAGMENT_CONTEXT_FIELDS
|
|
@@ -28175,7 +28182,6 @@ function shapeShowOutput(result, detail, shape = "human") {
|
|
|
28175
28182
|
"cwd",
|
|
28176
28183
|
"activeRun",
|
|
28177
28184
|
"keys",
|
|
28178
|
-
"related",
|
|
28179
28185
|
"links",
|
|
28180
28186
|
...FRAGMENT_PROVENANCE_FIELDS,
|
|
28181
28187
|
...FRAGMENT_CONTEXT_FIELDS,
|
|
@@ -28931,11 +28937,17 @@ function formatInfoPlain(r) {
|
|
|
28931
28937
|
const lines = [];
|
|
28932
28938
|
if (r.version)
|
|
28933
28939
|
lines.push(`version: ${String(r.version)}`);
|
|
28940
|
+
if (typeof r.error === "string")
|
|
28941
|
+
lines.push(`error: ${r.error}`);
|
|
28934
28942
|
if (r.bundleDir)
|
|
28935
28943
|
lines.push(`bundleDir: ${String(r.bundleDir)}`);
|
|
28936
28944
|
if (r.defaultBundle !== undefined) {
|
|
28937
28945
|
lines.push(`defaultBundle: ${r.defaultBundle === null ? "(none)" : String(r.defaultBundle)}`);
|
|
28938
28946
|
}
|
|
28947
|
+
if (typeof r.configError === "string")
|
|
28948
|
+
lines.push(`configError: ${r.configError}`);
|
|
28949
|
+
if (typeof r.bundleDirError === "string")
|
|
28950
|
+
lines.push(`bundleDirError: ${r.bundleDirError}`);
|
|
28939
28951
|
if (Array.isArray(r.assetTypes) && r.assetTypes.length > 0) {
|
|
28940
28952
|
lines.push(`assetTypes: ${r.assetTypes.join(", ")}`);
|
|
28941
28953
|
}
|
|
@@ -29317,13 +29329,6 @@ Warnings (${warnings.length}):`;
|
|
|
29317
29329
|
out += `
|
|
29318
29330
|
- ${String(message)}`;
|
|
29319
29331
|
}
|
|
29320
|
-
const notices = Array.isArray(indexResult.notices) ? indexResult.notices : [];
|
|
29321
|
-
for (const notice of notices) {
|
|
29322
|
-
const severity = notice.severity === "info" ? "info" : "warning";
|
|
29323
|
-
const field = typeof notice.field === "string" ? ` field=${notice.field}` : "";
|
|
29324
|
-
out += `
|
|
29325
|
-
notice[${severity}] ${notice.code} adapter=${notice.adapter}${field}` + (notice.message ? `: ${notice.message}` : "");
|
|
29326
|
-
}
|
|
29327
29332
|
const verification = indexResult.verification;
|
|
29328
29333
|
if (verification?.ok === false && verification.message) {
|
|
29329
29334
|
out += `
|
|
@@ -29738,7 +29743,10 @@ Generate one with \`akm improve <ref>\` or \`akm proposal new <type> <name> --ta
|
|
|
29738
29743
|
const created = String(p.createdAt);
|
|
29739
29744
|
const gate = formatGateDecisionSummary(p.gateDecision);
|
|
29740
29745
|
const gateSuffix = gate ? ` ${gate}` : "";
|
|
29741
|
-
|
|
29746
|
+
const retirement = p.retirement;
|
|
29747
|
+
const flagged = p.continuityRisk === true || Boolean(retirement?.continuityRisk);
|
|
29748
|
+
const continuitySuffix = flagged ? " \u26A0 continuity-risk" : "";
|
|
29749
|
+
lines.push(`${id} [${status}] ${ref} source=${source} ${created}${gateSuffix}${continuitySuffix}`);
|
|
29742
29750
|
}
|
|
29743
29751
|
return lines.join(`
|
|
29744
29752
|
`).trimEnd();
|
|
@@ -29778,6 +29786,30 @@ function formatProposalShowPlain(r) {
|
|
|
29778
29786
|
if (review.decidedAt)
|
|
29779
29787
|
lines.push(`review.decidedAt: ${String(review.decidedAt)}`);
|
|
29780
29788
|
}
|
|
29789
|
+
const retirement = p.retirement;
|
|
29790
|
+
if (retirement) {
|
|
29791
|
+
lines.push(`retire: ${String(retirement.retiredRef)} -> ${String(retirement.successorRef)}`);
|
|
29792
|
+
lines.push(`retire.label: ${String(retirement.judgeLabel)} (cosine=${String(retirement.cosine)})`);
|
|
29793
|
+
lines.push(`retire.reason: ${String(retirement.judgeReason)}`);
|
|
29794
|
+
const continuityRisk = retirement.continuityRisk;
|
|
29795
|
+
if (continuityRisk) {
|
|
29796
|
+
const failingQueries = typeof continuityRisk.failingQueries === "number" ? continuityRisk.failingQueries : 0;
|
|
29797
|
+
const unverifiedQueries = typeof continuityRisk.unverifiedQueries === "number" ? continuityRisk.unverifiedQueries : 0;
|
|
29798
|
+
const summary = [];
|
|
29799
|
+
if (failingQueries > 0) {
|
|
29800
|
+
summary.push(`${failingQueries} of the retired asset's own quer${failingQueries === 1 ? "y" : "ies"} would not have found the successor top 10`);
|
|
29801
|
+
}
|
|
29802
|
+
if (unverifiedQueries > 0) {
|
|
29803
|
+
summary.push(`${unverifiedQueries} quer${unverifiedQueries === 1 ? "y" : "ies"} unverified (search failed or used the keyword-only fallback)`);
|
|
29804
|
+
}
|
|
29805
|
+
lines.push(`retire.continuityRisk: ${summary.join("; ")} \u2014 excluded from bulk accept`);
|
|
29806
|
+
const ranks = Array.isArray(continuityRisk.ranks) ? continuityRisk.ranks : [];
|
|
29807
|
+
for (const rank of ranks) {
|
|
29808
|
+
const successorRank = rank.successorRank === null || rank.successorRank === undefined ? "absent from top 10" : `#${String(rank.successorRank)}`;
|
|
29809
|
+
lines.push(` - "${String(rank.query)}": retired #${String(rank.retiredRank)}, successor ${successorRank}`);
|
|
29810
|
+
}
|
|
29811
|
+
}
|
|
29812
|
+
}
|
|
29781
29813
|
const validation = r.validation;
|
|
29782
29814
|
if (validation) {
|
|
29783
29815
|
const findings = Array.isArray(validation.findings) ? validation.findings : [];
|
|
@@ -30171,19 +30203,6 @@ function formatShowPlain(r, detail) {
|
|
|
30171
30203
|
if (r.schemaVersion !== undefined)
|
|
30172
30204
|
lines.push(`schemaVersion: ${String(r.schemaVersion)}`);
|
|
30173
30205
|
}
|
|
30174
|
-
const related = typeof r.related === "object" && r.related !== null ? r.related : undefined;
|
|
30175
|
-
const relatedHits = related && Array.isArray(related.hits) ? related.hits : [];
|
|
30176
|
-
if (related) {
|
|
30177
|
-
lines.push("");
|
|
30178
|
-
lines.push(`related: ${String(related.total ?? relatedHits.length)}`);
|
|
30179
|
-
for (const hit of relatedHits) {
|
|
30180
|
-
lines.push(` - ${String(hit.type ?? "?")}: ${formatRelatedLabel(hit)}`);
|
|
30181
|
-
const shared = Array.isArray(hit.sharedEntities) ? hit.sharedEntities.map(String) : [];
|
|
30182
|
-
if (shared.length > 0)
|
|
30183
|
-
lines.push(` shared: ${shared.join(", ")}`);
|
|
30184
|
-
lines.push(` relationCount: ${String(hit.relationCount ?? 0)}`);
|
|
30185
|
-
}
|
|
30186
|
-
}
|
|
30187
30206
|
const links = typeof r.links === "object" && r.links !== null ? r.links : undefined;
|
|
30188
30207
|
if (links) {
|
|
30189
30208
|
lines.push("");
|
|
@@ -30233,13 +30252,6 @@ function formatShowPlain(r, detail) {
|
|
|
30233
30252
|
return lines.length > 0 ? lines.join(`
|
|
30234
30253
|
`) : null;
|
|
30235
30254
|
}
|
|
30236
|
-
function formatRelatedLabel(hit) {
|
|
30237
|
-
const ref = typeof hit.ref === "string" ? hit.ref : undefined;
|
|
30238
|
-
if (ref)
|
|
30239
|
-
return ref;
|
|
30240
|
-
const pathValue = typeof hit.path === "string" ? hit.path : "?";
|
|
30241
|
-
return pathValue.split("/").pop() ?? pathValue;
|
|
30242
|
-
}
|
|
30243
30255
|
// src/output/text/workflow-format.ts
|
|
30244
30256
|
function formatWorkflowListPlain(result) {
|
|
30245
30257
|
const runs = Array.isArray(result.runs) ? result.runs : [];
|
|
@@ -30561,9 +30573,6 @@ var catchup_default = {
|
|
|
30561
30573
|
memoryInference: {
|
|
30562
30574
|
enabled: false
|
|
30563
30575
|
},
|
|
30564
|
-
graphExtraction: {
|
|
30565
|
-
enabled: false
|
|
30566
|
-
},
|
|
30567
30576
|
extract: {
|
|
30568
30577
|
enabled: false
|
|
30569
30578
|
},
|
|
@@ -30595,7 +30604,6 @@ var consolidate_default = {
|
|
|
30595
30604
|
distill: { enabled: false },
|
|
30596
30605
|
consolidate: { enabled: true, allowedTypes: ["memory"], maxChunkSize: 25 },
|
|
30597
30606
|
memoryInference: { enabled: false },
|
|
30598
|
-
graphExtraction: { enabled: false },
|
|
30599
30607
|
extract: { enabled: false },
|
|
30600
30608
|
triage: { enabled: false },
|
|
30601
30609
|
validation: { enabled: false },
|
|
@@ -30605,7 +30613,7 @@ var consolidate_default = {
|
|
|
30605
30613
|
};
|
|
30606
30614
|
// src/assets/improve-strategies/default.json
|
|
30607
30615
|
var default_default = {
|
|
30608
|
-
description: "Standard improve pass \u2014 reflect, distill,
|
|
30616
|
+
description: "Standard improve pass \u2014 reflect, distill, consolidation (promotion plus the reviewed pair-pass retire/supersede proposals), and validation. Memory inference is listed below but only runs when experimental.improveAutonomy is set; improve-stage extract and proactive maintenance off.",
|
|
30609
30617
|
processes: {
|
|
30610
30618
|
reflect: {
|
|
30611
30619
|
enabled: true,
|
|
@@ -30615,7 +30623,6 @@ var default_default = {
|
|
|
30615
30623
|
distill: { enabled: true, allowedTypes: ["memory"], requirePlannedRefs: true },
|
|
30616
30624
|
consolidate: { enabled: true, allowedTypes: ["memory"] },
|
|
30617
30625
|
memoryInference: { enabled: true },
|
|
30618
|
-
graphExtraction: { enabled: true },
|
|
30619
30626
|
extract: { enabled: false, triage: { enabled: true, minScore: 2 } },
|
|
30620
30627
|
validation: { enabled: true },
|
|
30621
30628
|
proactiveMaintenance: { enabled: false, dueDays: 30, maxPerRun: 15 },
|
|
@@ -30623,25 +30630,9 @@ var default_default = {
|
|
|
30623
30630
|
},
|
|
30624
30631
|
sync: { enabled: true, push: true }
|
|
30625
30632
|
};
|
|
30626
|
-
// src/assets/improve-strategies/graph-refresh.json
|
|
30627
|
-
var graph_refresh_default = {
|
|
30628
|
-
description: "Full-corpus graph extraction pass \u2014 rebuilds graph relationships across all stash files. Disables all other sub-processes. Use via `akm improve --strategy graph-refresh` or the embedded `graph-refresh-weekly` task.",
|
|
30629
|
-
processes: {
|
|
30630
|
-
reflect: { enabled: false },
|
|
30631
|
-
distill: { enabled: false },
|
|
30632
|
-
consolidate: { enabled: false },
|
|
30633
|
-
memoryInference: { enabled: false },
|
|
30634
|
-
graphExtraction: { enabled: true, fullScan: true },
|
|
30635
|
-
extract: { enabled: false },
|
|
30636
|
-
triage: { enabled: false },
|
|
30637
|
-
validation: { enabled: false },
|
|
30638
|
-
proactiveMaintenance: { enabled: false }
|
|
30639
|
-
},
|
|
30640
|
-
sync: { enabled: true, push: true }
|
|
30641
|
-
};
|
|
30642
30633
|
// src/assets/improve-strategies/proactive-maintenance.json
|
|
30643
30634
|
var proactive_maintenance_default = {
|
|
30644
|
-
description: "Opt-in proactive-maintenance pass \u2014 reflect, distill, proposal triage (promote, high budget), and the proactive-maintenance lane (maxPerRun 100); consolidate/memoryInference/
|
|
30635
|
+
description: "Opt-in proactive-maintenance pass \u2014 reflect, distill, proposal triage (promote, high budget), and the proactive-maintenance lane (maxPerRun 100); consolidate/memoryInference/extract off. Sync disabled: an interrupted run would otherwise leave an uncommitted backlog.",
|
|
30645
30636
|
processes: {
|
|
30646
30637
|
reflect: {
|
|
30647
30638
|
enabled: true,
|
|
@@ -30650,7 +30641,6 @@ var proactive_maintenance_default = {
|
|
|
30650
30641
|
distill: { enabled: true, allowedTypes: ["memory"] },
|
|
30651
30642
|
consolidate: { enabled: false },
|
|
30652
30643
|
memoryInference: { enabled: false },
|
|
30653
|
-
graphExtraction: { enabled: false },
|
|
30654
30644
|
extract: { enabled: false },
|
|
30655
30645
|
validation: { enabled: false },
|
|
30656
30646
|
triage: {
|
|
@@ -30667,7 +30657,7 @@ var proactive_maintenance_default = {
|
|
|
30667
30657
|
};
|
|
30668
30658
|
// src/assets/improve-strategies/quick.json
|
|
30669
30659
|
var quick_default = {
|
|
30670
|
-
description: "Reflect-only pass \u2014 no extract, distill, consolidate,
|
|
30660
|
+
description: "Reflect-only pass \u2014 no extract, distill, consolidate, or memoryInference.",
|
|
30671
30661
|
processes: {
|
|
30672
30662
|
reflect: {
|
|
30673
30663
|
enabled: true,
|
|
@@ -30677,7 +30667,6 @@ var quick_default = {
|
|
|
30677
30667
|
distill: { enabled: false },
|
|
30678
30668
|
consolidate: { enabled: false },
|
|
30679
30669
|
memoryInference: { enabled: false },
|
|
30680
|
-
graphExtraction: { enabled: false },
|
|
30681
30670
|
triage: { enabled: false },
|
|
30682
30671
|
validation: { enabled: false },
|
|
30683
30672
|
proactiveMaintenance: { enabled: false }
|
|
@@ -30686,7 +30675,7 @@ var quick_default = {
|
|
|
30686
30675
|
};
|
|
30687
30676
|
// src/assets/improve-strategies/reflect-distill.json
|
|
30688
30677
|
var reflect_distill_default = {
|
|
30689
|
-
description: "Reflect + distill pass \u2014 reflect, distill, memoryInference, and proposal triage (promote); proactiveMaintenance/consolidate/
|
|
30678
|
+
description: "Reflect + distill pass \u2014 reflect, distill, memoryInference, and proposal triage (promote); proactiveMaintenance/consolidate/extract off. Sync disabled: an interrupted run would otherwise leave an uncommitted backlog.",
|
|
30690
30679
|
processes: {
|
|
30691
30680
|
reflect: {
|
|
30692
30681
|
enabled: true,
|
|
@@ -30695,7 +30684,6 @@ var reflect_distill_default = {
|
|
|
30695
30684
|
distill: { enabled: true, allowedTypes: ["memory"], requirePlannedRefs: false },
|
|
30696
30685
|
consolidate: { enabled: false },
|
|
30697
30686
|
memoryInference: { enabled: true },
|
|
30698
|
-
graphExtraction: { enabled: false },
|
|
30699
30687
|
extract: {
|
|
30700
30688
|
enabled: false,
|
|
30701
30689
|
timeoutMs: 300000,
|
|
@@ -30736,9 +30724,6 @@ var thorough_default = {
|
|
|
30736
30724
|
memoryInference: {
|
|
30737
30725
|
enabled: true
|
|
30738
30726
|
},
|
|
30739
|
-
graphExtraction: {
|
|
30740
|
-
enabled: true
|
|
30741
|
-
},
|
|
30742
30727
|
extract: {
|
|
30743
30728
|
enabled: false,
|
|
30744
30729
|
triage: {
|
|
@@ -30769,607 +30754,134 @@ var thorough_default = {
|
|
|
30769
30754
|
}
|
|
30770
30755
|
};
|
|
30771
30756
|
|
|
30772
|
-
//
|
|
30773
|
-
|
|
30774
|
-
|
|
30775
|
-
|
|
30776
|
-
|
|
30757
|
+
// node_modules/zod/v3/external.js
|
|
30758
|
+
var exports_external = {};
|
|
30759
|
+
__export(exports_external, {
|
|
30760
|
+
void: () => voidType,
|
|
30761
|
+
util: () => util,
|
|
30762
|
+
unknown: () => unknownType,
|
|
30763
|
+
union: () => unionType,
|
|
30764
|
+
undefined: () => undefinedType,
|
|
30765
|
+
tuple: () => tupleType,
|
|
30766
|
+
transformer: () => effectsType,
|
|
30767
|
+
symbol: () => symbolType,
|
|
30768
|
+
string: () => stringType,
|
|
30769
|
+
strictObject: () => strictObjectType,
|
|
30770
|
+
setErrorMap: () => setErrorMap,
|
|
30771
|
+
set: () => setType,
|
|
30772
|
+
record: () => recordType,
|
|
30773
|
+
quotelessJson: () => quotelessJson,
|
|
30774
|
+
promise: () => promiseType,
|
|
30775
|
+
preprocess: () => preprocessType,
|
|
30776
|
+
pipeline: () => pipelineType,
|
|
30777
|
+
ostring: () => ostring,
|
|
30778
|
+
optional: () => optionalType,
|
|
30779
|
+
onumber: () => onumber,
|
|
30780
|
+
oboolean: () => oboolean,
|
|
30781
|
+
objectUtil: () => objectUtil,
|
|
30782
|
+
object: () => objectType,
|
|
30783
|
+
number: () => numberType,
|
|
30784
|
+
nullable: () => nullableType,
|
|
30785
|
+
null: () => nullType,
|
|
30786
|
+
never: () => neverType,
|
|
30787
|
+
nativeEnum: () => nativeEnumType,
|
|
30788
|
+
nan: () => nanType,
|
|
30789
|
+
map: () => mapType,
|
|
30790
|
+
makeIssue: () => makeIssue,
|
|
30791
|
+
literal: () => literalType,
|
|
30792
|
+
lazy: () => lazyType,
|
|
30793
|
+
late: () => late,
|
|
30794
|
+
isValid: () => isValid,
|
|
30795
|
+
isDirty: () => isDirty,
|
|
30796
|
+
isAsync: () => isAsync,
|
|
30797
|
+
isAborted: () => isAborted,
|
|
30798
|
+
intersection: () => intersectionType,
|
|
30799
|
+
instanceof: () => instanceOfType,
|
|
30800
|
+
getParsedType: () => getParsedType,
|
|
30801
|
+
getErrorMap: () => getErrorMap,
|
|
30802
|
+
function: () => functionType,
|
|
30803
|
+
enum: () => enumType,
|
|
30804
|
+
effect: () => effectsType,
|
|
30805
|
+
discriminatedUnion: () => discriminatedUnionType,
|
|
30806
|
+
defaultErrorMap: () => en_default,
|
|
30807
|
+
datetimeRegex: () => datetimeRegex,
|
|
30808
|
+
date: () => dateType,
|
|
30809
|
+
custom: () => custom,
|
|
30810
|
+
coerce: () => coerce,
|
|
30811
|
+
boolean: () => booleanType,
|
|
30812
|
+
bigint: () => bigIntType,
|
|
30813
|
+
array: () => arrayType,
|
|
30814
|
+
any: () => anyType,
|
|
30815
|
+
addIssueToContext: () => addIssueToContext,
|
|
30816
|
+
ZodVoid: () => ZodVoid,
|
|
30817
|
+
ZodUnknown: () => ZodUnknown,
|
|
30818
|
+
ZodUnion: () => ZodUnion,
|
|
30819
|
+
ZodUndefined: () => ZodUndefined,
|
|
30820
|
+
ZodType: () => ZodType,
|
|
30821
|
+
ZodTuple: () => ZodTuple,
|
|
30822
|
+
ZodTransformer: () => ZodEffects,
|
|
30823
|
+
ZodSymbol: () => ZodSymbol,
|
|
30824
|
+
ZodString: () => ZodString,
|
|
30825
|
+
ZodSet: () => ZodSet,
|
|
30826
|
+
ZodSchema: () => ZodType,
|
|
30827
|
+
ZodRecord: () => ZodRecord,
|
|
30828
|
+
ZodReadonly: () => ZodReadonly,
|
|
30829
|
+
ZodPromise: () => ZodPromise,
|
|
30830
|
+
ZodPipeline: () => ZodPipeline,
|
|
30831
|
+
ZodParsedType: () => ZodParsedType,
|
|
30832
|
+
ZodOptional: () => ZodOptional,
|
|
30833
|
+
ZodObject: () => ZodObject,
|
|
30834
|
+
ZodNumber: () => ZodNumber,
|
|
30835
|
+
ZodNullable: () => ZodNullable,
|
|
30836
|
+
ZodNull: () => ZodNull,
|
|
30837
|
+
ZodNever: () => ZodNever,
|
|
30838
|
+
ZodNativeEnum: () => ZodNativeEnum,
|
|
30839
|
+
ZodNaN: () => ZodNaN,
|
|
30840
|
+
ZodMap: () => ZodMap,
|
|
30841
|
+
ZodLiteral: () => ZodLiteral,
|
|
30842
|
+
ZodLazy: () => ZodLazy,
|
|
30843
|
+
ZodIssueCode: () => ZodIssueCode,
|
|
30844
|
+
ZodIntersection: () => ZodIntersection,
|
|
30845
|
+
ZodFunction: () => ZodFunction,
|
|
30846
|
+
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
30847
|
+
ZodError: () => ZodError,
|
|
30848
|
+
ZodEnum: () => ZodEnum,
|
|
30849
|
+
ZodEffects: () => ZodEffects,
|
|
30850
|
+
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
30851
|
+
ZodDefault: () => ZodDefault,
|
|
30852
|
+
ZodDate: () => ZodDate,
|
|
30853
|
+
ZodCatch: () => ZodCatch,
|
|
30854
|
+
ZodBranded: () => ZodBranded,
|
|
30855
|
+
ZodBoolean: () => ZodBoolean,
|
|
30856
|
+
ZodBigInt: () => ZodBigInt,
|
|
30857
|
+
ZodArray: () => ZodArray,
|
|
30858
|
+
ZodAny: () => ZodAny,
|
|
30859
|
+
Schema: () => ZodType,
|
|
30860
|
+
ParseStatus: () => ParseStatus,
|
|
30861
|
+
OK: () => OK,
|
|
30862
|
+
NEVER: () => NEVER,
|
|
30863
|
+
INVALID: () => INVALID,
|
|
30864
|
+
EMPTY_PATH: () => EMPTY_PATH,
|
|
30865
|
+
DIRTY: () => DIRTY,
|
|
30866
|
+
BRAND: () => BRAND
|
|
30867
|
+
});
|
|
30777
30868
|
|
|
30778
|
-
//
|
|
30779
|
-
var
|
|
30780
|
-
|
|
30781
|
-
|
|
30782
|
-
|
|
30783
|
-
|
|
30784
|
-
|
|
30785
|
-
|
|
30786
|
-
"streamoptions",
|
|
30787
|
-
"enablethinking",
|
|
30788
|
-
"reasoningeffort",
|
|
30789
|
-
"chattemplatekwargs"
|
|
30790
|
-
];
|
|
30791
|
-
var EXTRA_PARAMS_CREDENTIAL_KEYS = [
|
|
30792
|
-
"authorization",
|
|
30793
|
-
"headers",
|
|
30794
|
-
"apikey",
|
|
30795
|
-
"token",
|
|
30796
|
-
"password",
|
|
30797
|
-
"secret",
|
|
30798
|
-
"cookie",
|
|
30799
|
-
"setcookie"
|
|
30800
|
-
];
|
|
30801
|
-
var PROTECTED_TOP_LEVEL_KEYS = new Set(EXTRA_PARAMS_PROTECTED_TOP_LEVEL_KEYS);
|
|
30802
|
-
var CREDENTIAL_KEYS = new Set(EXTRA_PARAMS_CREDENTIAL_KEYS);
|
|
30803
|
-
var LEGACY_EXTRA_PARAMS_FIELD = {
|
|
30804
|
-
model: "model",
|
|
30805
|
-
temperature: "temperature",
|
|
30806
|
-
maxtokens: "maxTokens",
|
|
30807
|
-
enablethinking: "enableThinking",
|
|
30808
|
-
reasoningeffort: "reasoningEffort"
|
|
30809
|
-
};
|
|
30810
|
-
var LIFTABLE_EXTRA_PARAMS_KEYS = new Set(["temperature", "maxtokens", "enablethinking", "reasoningeffort"]);
|
|
30811
|
-
var EXTRA_PARAMS_NO_FIELD_REMEDY = {
|
|
30812
|
-
messages: "AKM builds the request messages internally \u2014 remove it from extraParams",
|
|
30813
|
-
responseformat: "AKM controls the response format internally \u2014 remove it from extraParams",
|
|
30814
|
-
stream: "AKM controls streaming internally \u2014 remove it from extraParams",
|
|
30815
|
-
streamoptions: "AKM controls streaming internally \u2014 remove it from extraParams",
|
|
30816
|
-
chattemplatekwargs: "set engines.<name>.enableThinking instead of chat_template_kwargs.enable_thinking"
|
|
30817
|
-
};
|
|
30818
|
-
function protectedKeyRemedy(normalized) {
|
|
30819
|
-
const field = LEGACY_EXTRA_PARAMS_FIELD[normalized];
|
|
30820
|
-
if (field) {
|
|
30821
|
-
const note = normalized === "reasoningeffort" ? " (moved to a first-class field in 0.9.2)" : "";
|
|
30822
|
-
return `set engines.<name>.${field} instead${note}`;
|
|
30823
|
-
}
|
|
30824
|
-
return EXTRA_PARAMS_NO_FIELD_REMEDY[normalized];
|
|
30825
|
-
}
|
|
30826
|
-
function normalizeExtraParamKey(key) {
|
|
30827
|
-
return key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
30828
|
-
}
|
|
30829
|
-
function validateExtraParams(value) {
|
|
30830
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
30831
|
-
return [{ path: [], message: "must be an object" }];
|
|
30869
|
+
// node_modules/zod/v3/helpers/util.js
|
|
30870
|
+
var util;
|
|
30871
|
+
(function(util2) {
|
|
30872
|
+
util2.assertEqual = (_) => {};
|
|
30873
|
+
function assertIs(_arg) {}
|
|
30874
|
+
util2.assertIs = assertIs;
|
|
30875
|
+
function assertNever2(_x) {
|
|
30876
|
+
throw new Error;
|
|
30832
30877
|
}
|
|
30833
|
-
|
|
30834
|
-
|
|
30835
|
-
|
|
30836
|
-
|
|
30837
|
-
|
|
30838
|
-
return;
|
|
30839
|
-
seen.add(entry);
|
|
30840
|
-
entry.forEach((child, index) => {
|
|
30841
|
-
visit2(child, [...path12, index]);
|
|
30842
|
-
});
|
|
30843
|
-
return;
|
|
30844
|
-
}
|
|
30845
|
-
if (!entry || typeof entry !== "object")
|
|
30846
|
-
return;
|
|
30847
|
-
if (seen.has(entry))
|
|
30848
|
-
return;
|
|
30849
|
-
seen.add(entry);
|
|
30850
|
-
for (const [key, child] of Object.entries(entry)) {
|
|
30851
|
-
const normalized = normalizeExtraParamKey(key);
|
|
30852
|
-
if (path12.length === 0 && PROTECTED_TOP_LEVEL_KEYS.has(normalized)) {
|
|
30853
|
-
const remedy = protectedKeyRemedy(normalized);
|
|
30854
|
-
issues.push({
|
|
30855
|
-
path: [key],
|
|
30856
|
-
message: remedy ? `${key} is protected by AKM \u2014 ${remedy}.` : `${key} is protected by AKM`
|
|
30857
|
-
});
|
|
30858
|
-
}
|
|
30859
|
-
if (CREDENTIAL_KEYS.has(normalized)) {
|
|
30860
|
-
issues.push({ path: [...path12, key], message: `${key} cannot carry credentials` });
|
|
30861
|
-
}
|
|
30862
|
-
visit2(child, [...path12, key]);
|
|
30878
|
+
util2.assertNever = assertNever2;
|
|
30879
|
+
util2.arrayToEnum = (items) => {
|
|
30880
|
+
const obj = {};
|
|
30881
|
+
for (const item of items) {
|
|
30882
|
+
obj[item] = item;
|
|
30863
30883
|
}
|
|
30864
|
-
|
|
30865
|
-
visit2(value, []);
|
|
30866
|
-
return issues;
|
|
30867
|
-
}
|
|
30868
|
-
function formatExtraParamsIssue(label, issue) {
|
|
30869
|
-
const suffix = issue.path.map((part) => typeof part === "number" ? `[${part}]` : `.${part}`).join("");
|
|
30870
|
-
return `${label}${suffix} ${issue.message}`;
|
|
30871
|
-
}
|
|
30872
|
-
function liftLegacyEngineExtraParams(raw) {
|
|
30873
|
-
const lifted = [];
|
|
30874
|
-
const conflicts = [];
|
|
30875
|
-
const rawEngines = raw.engines;
|
|
30876
|
-
if (!isRecord(rawEngines)) {
|
|
30877
|
-
return { config: raw, lifted, conflicts };
|
|
30878
|
-
}
|
|
30879
|
-
const engines = {};
|
|
30880
|
-
let anyEngineChanged = false;
|
|
30881
|
-
for (const [name, engineValue] of Object.entries(rawEngines)) {
|
|
30882
|
-
if (!isRecord(engineValue) || !isRecord(engineValue.extraParams)) {
|
|
30883
|
-
engines[name] = engineValue;
|
|
30884
|
-
continue;
|
|
30885
|
-
}
|
|
30886
|
-
const engine = { ...engineValue };
|
|
30887
|
-
const extraParams = { ...engineValue.extraParams };
|
|
30888
|
-
let engineChanged = false;
|
|
30889
|
-
for (const [rawKey, value] of Object.entries(engineValue.extraParams)) {
|
|
30890
|
-
const normalized = normalizeExtraParamKey(rawKey);
|
|
30891
|
-
if (!LIFTABLE_EXTRA_PARAMS_KEYS.has(normalized))
|
|
30892
|
-
continue;
|
|
30893
|
-
const field = LEGACY_EXTRA_PARAMS_FIELD[normalized];
|
|
30894
|
-
if (!field)
|
|
30895
|
-
continue;
|
|
30896
|
-
const existing = engine[field];
|
|
30897
|
-
if (existing !== undefined && existing !== value) {
|
|
30898
|
-
conflicts.push({ engine: name, key: rawKey, field, extraParamsValue: value, fieldValue: existing });
|
|
30899
|
-
continue;
|
|
30900
|
-
}
|
|
30901
|
-
delete extraParams[rawKey];
|
|
30902
|
-
engineChanged = true;
|
|
30903
|
-
if (existing === value) {
|
|
30904
|
-
lifted.push(`engines.${name}.extraParams.${rawKey} is redundant \u2014 engines.${name}.${field} is already set to the same value; dropped the extraParams entry`);
|
|
30905
|
-
continue;
|
|
30906
|
-
}
|
|
30907
|
-
engine[field] = value;
|
|
30908
|
-
lifted.push(`engines.${name}.extraParams.${rawKey} -> engines.${name}.${field}`);
|
|
30909
|
-
}
|
|
30910
|
-
if (!engineChanged) {
|
|
30911
|
-
engines[name] = engineValue;
|
|
30912
|
-
continue;
|
|
30913
|
-
}
|
|
30914
|
-
anyEngineChanged = true;
|
|
30915
|
-
if (Object.keys(extraParams).length > 0) {
|
|
30916
|
-
engine.extraParams = extraParams;
|
|
30917
|
-
} else {
|
|
30918
|
-
delete engine.extraParams;
|
|
30919
|
-
}
|
|
30920
|
-
engines[name] = engine;
|
|
30921
|
-
}
|
|
30922
|
-
if (!anyEngineChanged) {
|
|
30923
|
-
return { config: raw, lifted, conflicts };
|
|
30924
|
-
}
|
|
30925
|
-
return { config: { ...raw, engines }, lifted, conflicts };
|
|
30926
|
-
}
|
|
30927
|
-
|
|
30928
|
-
// src/core/config/config-io.ts
|
|
30929
|
-
import fs8 from "fs";
|
|
30930
|
-
import path12 from "path";
|
|
30931
|
-
|
|
30932
|
-
// src/core/file-lock.ts
|
|
30933
|
-
import { randomUUID } from "crypto";
|
|
30934
|
-
import fs7 from "fs";
|
|
30935
|
-
function readLockSnapshot(lockPath) {
|
|
30936
|
-
let fd;
|
|
30937
|
-
try {
|
|
30938
|
-
fd = fs7.openSync(lockPath, "r");
|
|
30939
|
-
} catch (err) {
|
|
30940
|
-
if (err.code === "ENOENT")
|
|
30941
|
-
return;
|
|
30942
|
-
throw err;
|
|
30943
|
-
}
|
|
30944
|
-
try {
|
|
30945
|
-
const rawContent = readTextFileDescriptorWithLimit(fd, MAX_LOCK_METADATA_BYTES, "Lock metadata", lockPath);
|
|
30946
|
-
const stat = fs7.fstatSync(fd);
|
|
30947
|
-
return {
|
|
30948
|
-
rawContent,
|
|
30949
|
-
identity: { dev: stat.dev, ino: stat.ino, size: stat.size, mtimeMs: stat.mtimeMs }
|
|
30950
|
-
};
|
|
30951
|
-
} finally {
|
|
30952
|
-
fs7.closeSync(fd);
|
|
30953
|
-
}
|
|
30954
|
-
}
|
|
30955
|
-
function sameIdentity(left, right) {
|
|
30956
|
-
return left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs;
|
|
30957
|
-
}
|
|
30958
|
-
function releaseLockRaw(lockPath) {
|
|
30959
|
-
try {
|
|
30960
|
-
fs7.unlinkSync(lockPath);
|
|
30961
|
-
} catch {}
|
|
30962
|
-
}
|
|
30963
|
-
function tryAcquireLockSync(lockPath, payload) {
|
|
30964
|
-
try {
|
|
30965
|
-
fs7.writeFileSync(lockPath, payload, { flag: "wx" });
|
|
30966
|
-
} catch (err) {
|
|
30967
|
-
if (err.code === "EEXIST")
|
|
30968
|
-
return;
|
|
30969
|
-
throw err;
|
|
30970
|
-
}
|
|
30971
|
-
let snapshot;
|
|
30972
|
-
try {
|
|
30973
|
-
snapshot = readLockSnapshot(lockPath);
|
|
30974
|
-
} catch (error2) {
|
|
30975
|
-
releaseLockRaw(lockPath);
|
|
30976
|
-
throw error2;
|
|
30977
|
-
}
|
|
30978
|
-
if (!snapshot) {
|
|
30979
|
-
releaseLockRaw(lockPath);
|
|
30980
|
-
throw new Error(`Could not read newly acquired lock at ${lockPath}.`);
|
|
30981
|
-
}
|
|
30982
|
-
return { lockPath, ...snapshot };
|
|
30983
|
-
}
|
|
30984
|
-
function launcherPidFromEnv() {
|
|
30985
|
-
const raw = process.env.AKM_LAUNCHER_PID;
|
|
30986
|
-
if (!raw)
|
|
30987
|
-
return;
|
|
30988
|
-
const pid = Number.parseInt(raw, 10);
|
|
30989
|
-
return Number.isInteger(pid) && pid > 0 ? pid : undefined;
|
|
30990
|
-
}
|
|
30991
|
-
function createLockPayload(metadata = {}) {
|
|
30992
|
-
const launcherPid = launcherPidFromEnv();
|
|
30993
|
-
return JSON.stringify({
|
|
30994
|
-
...metadata,
|
|
30995
|
-
pid: process.pid,
|
|
30996
|
-
...launcherPid !== undefined ? { launcherPid } : {},
|
|
30997
|
-
lockId: randomUUID()
|
|
30998
|
-
});
|
|
30999
|
-
}
|
|
31000
|
-
function probeLock(lockPath, opts) {
|
|
31001
|
-
let snapshot;
|
|
31002
|
-
try {
|
|
31003
|
-
snapshot = readLockSnapshot(lockPath);
|
|
31004
|
-
} catch (error2) {
|
|
31005
|
-
const code = error2?.code;
|
|
31006
|
-
if (code === "EACCES" || code === "EPERM")
|
|
31007
|
-
return { state: "inaccessible", code };
|
|
31008
|
-
return { state: "stale", reason: "unreadable" };
|
|
31009
|
-
}
|
|
31010
|
-
if (!snapshot)
|
|
31011
|
-
return { state: "absent" };
|
|
31012
|
-
const { rawContent, identity: identity3 } = snapshot;
|
|
31013
|
-
const ageMs = Date.now() - identity3.mtimeMs;
|
|
31014
|
-
const { holderPid, launcherPid } = extractLockIdentity(rawContent);
|
|
31015
|
-
if (holderPid === undefined) {
|
|
31016
|
-
return { state: "stale", reason: "invalid_pid", ageMs, rawContent, identity: identity3 };
|
|
31017
|
-
}
|
|
31018
|
-
if (!isProcessAlive(holderPid)) {
|
|
31019
|
-
return { state: "stale", reason: "pid_dead", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
31020
|
-
}
|
|
31021
|
-
if (opts?.staleAfterMs !== undefined && ageMs > opts.staleAfterMs) {
|
|
31022
|
-
return { state: "stale", reason: "age_exceeded", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
31023
|
-
}
|
|
31024
|
-
return { state: "held", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
31025
|
-
}
|
|
31026
|
-
function reclaimStaleLock(lockPath, probe, options) {
|
|
31027
|
-
if (probe.rawContent === undefined || probe.identity === undefined)
|
|
31028
|
-
return false;
|
|
31029
|
-
const expectedContent = probe.rawContent;
|
|
31030
|
-
const expectedIdentity = probe.identity;
|
|
31031
|
-
let current;
|
|
31032
|
-
try {
|
|
31033
|
-
current = readLockSnapshot(lockPath);
|
|
31034
|
-
} catch {
|
|
31035
|
-
return false;
|
|
31036
|
-
}
|
|
31037
|
-
if (!current || current.rawContent !== expectedContent || !sameIdentity(current.identity, expectedIdentity)) {
|
|
31038
|
-
return false;
|
|
31039
|
-
}
|
|
31040
|
-
const quarantinePath = `${lockPath}.stale-${process.pid}-${randomUUID()}`;
|
|
31041
|
-
try {
|
|
31042
|
-
fs7.renameSync(lockPath, quarantinePath);
|
|
31043
|
-
} catch (err) {
|
|
31044
|
-
if (err.code === "ENOENT")
|
|
31045
|
-
return false;
|
|
31046
|
-
throw err;
|
|
31047
|
-
}
|
|
31048
|
-
let quarantined;
|
|
31049
|
-
try {
|
|
31050
|
-
quarantined = readLockSnapshot(quarantinePath);
|
|
31051
|
-
} catch {
|
|
31052
|
-
quarantined = undefined;
|
|
31053
|
-
}
|
|
31054
|
-
if (!quarantined || quarantined.rawContent !== expectedContent || !sameIdentity(quarantined.identity, expectedIdentity)) {
|
|
31055
|
-
try {
|
|
31056
|
-
fs7.linkSync(quarantinePath, lockPath);
|
|
31057
|
-
} catch (err) {
|
|
31058
|
-
if (err.code !== "EEXIST")
|
|
31059
|
-
throw err;
|
|
31060
|
-
}
|
|
31061
|
-
releaseLockRaw(quarantinePath);
|
|
31062
|
-
return false;
|
|
31063
|
-
}
|
|
31064
|
-
options?.afterQuarantineVerified?.();
|
|
31065
|
-
try {
|
|
31066
|
-
fs7.unlinkSync(quarantinePath);
|
|
31067
|
-
return true;
|
|
31068
|
-
} catch (err) {
|
|
31069
|
-
if (err.code === "ENOENT")
|
|
31070
|
-
return false;
|
|
31071
|
-
throw err;
|
|
31072
|
-
}
|
|
31073
|
-
}
|
|
31074
|
-
function releaseLock(ownership) {
|
|
31075
|
-
const { lockPath } = ownership;
|
|
31076
|
-
let current;
|
|
31077
|
-
try {
|
|
31078
|
-
current = readLockSnapshot(lockPath);
|
|
31079
|
-
} catch {
|
|
31080
|
-
return;
|
|
31081
|
-
}
|
|
31082
|
-
if (current && current.rawContent === ownership.rawContent && sameIdentity(current.identity, ownership.identity)) {
|
|
31083
|
-
releaseLockRaw(lockPath);
|
|
31084
|
-
}
|
|
31085
|
-
}
|
|
31086
|
-
function extractLockIdentity(content) {
|
|
31087
|
-
const trimmed = content.trim();
|
|
31088
|
-
if (!trimmed)
|
|
31089
|
-
return {};
|
|
31090
|
-
if (trimmed.startsWith("{")) {
|
|
31091
|
-
try {
|
|
31092
|
-
const parsed = JSON.parse(trimmed);
|
|
31093
|
-
const pid2 = typeof parsed.pid === "number" ? parsed.pid : Number.NaN;
|
|
31094
|
-
const rawLauncherPid = typeof parsed.launcherPid === "number" ? parsed.launcherPid : Number.NaN;
|
|
31095
|
-
return {
|
|
31096
|
-
holderPid: Number.isInteger(pid2) && pid2 > 0 ? pid2 : undefined,
|
|
31097
|
-
launcherPid: Number.isInteger(rawLauncherPid) && rawLauncherPid > 0 ? rawLauncherPid : undefined
|
|
31098
|
-
};
|
|
31099
|
-
} catch {
|
|
31100
|
-
return {};
|
|
31101
|
-
}
|
|
31102
|
-
}
|
|
31103
|
-
const pid = Number.parseInt(trimmed, 10);
|
|
31104
|
-
return { holderPid: Number.isInteger(pid) && pid > 0 ? pid : undefined };
|
|
31105
|
-
}
|
|
31106
|
-
|
|
31107
|
-
// src/core/config/config-io.ts
|
|
31108
|
-
function readConfigText(configPath) {
|
|
31109
|
-
try {
|
|
31110
|
-
return readTextFile(configPath, "Config file");
|
|
31111
|
-
} catch (err) {
|
|
31112
|
-
if (err.code === "ENOENT")
|
|
31113
|
-
return;
|
|
31114
|
-
throw err;
|
|
31115
|
-
}
|
|
31116
|
-
}
|
|
31117
|
-
function parseConfigText(text, sourcePath) {
|
|
31118
|
-
const stripped = stripJsonComments(text);
|
|
31119
|
-
const where = sourcePath ? ` at ${sourcePath}` : "";
|
|
31120
|
-
let parsed;
|
|
31121
|
-
try {
|
|
31122
|
-
parsed = JSON.parse(stripped);
|
|
31123
|
-
} catch (err) {
|
|
31124
|
-
const detail = err instanceof Error ? err.message : String(err);
|
|
31125
|
-
throw new ConfigError(`Failed to parse config JSON${where}: ${detail}`, "INVALID_CONFIG_FILE", "Edit the file to fix the JSON syntax error. Comments (// and /* */) are allowed; trailing commas are not.");
|
|
31126
|
-
}
|
|
31127
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
31128
|
-
throw new ConfigError(`Config file${where} must contain a JSON object at the root, got ${describeJsonRoot(parsed)}.`, "INVALID_CONFIG_FILE");
|
|
31129
|
-
}
|
|
31130
|
-
return parsed;
|
|
31131
|
-
}
|
|
31132
|
-
function describeJsonRoot(value) {
|
|
31133
|
-
if (value === null)
|
|
31134
|
-
return "null";
|
|
31135
|
-
if (Array.isArray(value))
|
|
31136
|
-
return "an array";
|
|
31137
|
-
if (typeof value === "string")
|
|
31138
|
-
return "a string";
|
|
31139
|
-
if (typeof value === "number")
|
|
31140
|
-
return "a number";
|
|
31141
|
-
if (typeof value === "boolean")
|
|
31142
|
-
return "a boolean";
|
|
31143
|
-
return typeof value;
|
|
31144
|
-
}
|
|
31145
|
-
function writeConfigAtomic(configPath, config) {
|
|
31146
|
-
writeFileAtomic(configPath, `${JSON.stringify(config, null, 2)}
|
|
31147
|
-
`);
|
|
31148
|
-
}
|
|
31149
|
-
var MAX_CONFIG_BACKUPS = 5;
|
|
31150
|
-
function backupExistingConfig(configPath, now = new Date) {
|
|
31151
|
-
if (!fs8.existsSync(configPath))
|
|
31152
|
-
return;
|
|
31153
|
-
const backupDir = path12.join(getCacheDir(), "config-backups");
|
|
31154
|
-
fs8.mkdirSync(backupDir, { recursive: true, mode: 448 });
|
|
31155
|
-
fs8.chmodSync(backupDir, 448);
|
|
31156
|
-
const timestamp = now.toISOString().replace(/[.:]/g, "-");
|
|
31157
|
-
let sequence = 0;
|
|
31158
|
-
let timestamped;
|
|
31159
|
-
while (true) {
|
|
31160
|
-
timestamped = path12.join(backupDir, `config-${timestamp}${sequence === 0 ? "" : `-${sequence}`}.json`);
|
|
31161
|
-
try {
|
|
31162
|
-
fs8.copyFileSync(configPath, timestamped, fs8.constants.COPYFILE_EXCL);
|
|
31163
|
-
break;
|
|
31164
|
-
} catch (error2) {
|
|
31165
|
-
if (error2.code !== "EEXIST")
|
|
31166
|
-
throw error2;
|
|
31167
|
-
sequence++;
|
|
31168
|
-
}
|
|
31169
|
-
}
|
|
31170
|
-
const latest = path12.join(backupDir, "config.latest.json");
|
|
31171
|
-
fs8.copyFileSync(configPath, latest);
|
|
31172
|
-
fs8.chmodSync(timestamped, 384);
|
|
31173
|
-
fs8.chmodSync(latest, 384);
|
|
31174
|
-
pruneOldBackups(backupDir);
|
|
31175
|
-
return { timestamped, latest };
|
|
31176
|
-
}
|
|
31177
|
-
function pruneOldBackups(backupDir) {
|
|
31178
|
-
pruneToNewest(backupDir, MAX_CONFIG_BACKUPS, (entry) => entry.isFile() && isTimestampedConfigBackup(entry.name));
|
|
31179
|
-
}
|
|
31180
|
-
function isTimestampedConfigBackup(name) {
|
|
31181
|
-
return name.startsWith("config-") && name.endsWith(".json") && name !== "config.latest.json";
|
|
31182
|
-
}
|
|
31183
|
-
function pruneToNewest(dir, keep, select) {
|
|
31184
|
-
let entries;
|
|
31185
|
-
try {
|
|
31186
|
-
entries = fs8.readdirSync(dir, { withFileTypes: true });
|
|
31187
|
-
} catch {
|
|
31188
|
-
return;
|
|
31189
|
-
}
|
|
31190
|
-
const candidates = entries.filter(select).map((entry) => {
|
|
31191
|
-
const full = path12.join(dir, entry.name);
|
|
31192
|
-
let mtime = 0;
|
|
31193
|
-
try {
|
|
31194
|
-
mtime = fs8.statSync(full).mtimeMs;
|
|
31195
|
-
} catch {}
|
|
31196
|
-
return { path: full, mtime };
|
|
31197
|
-
}).sort((a, b) => b.mtime - a.mtime);
|
|
31198
|
-
for (const stale of candidates.slice(keep)) {
|
|
31199
|
-
try {
|
|
31200
|
-
fs8.rmSync(stale.path, { recursive: true, force: true });
|
|
31201
|
-
} catch {}
|
|
31202
|
-
}
|
|
31203
|
-
}
|
|
31204
|
-
function getConfigLockPath() {
|
|
31205
|
-
return path12.join(getConfigDir(), "config.json.lck");
|
|
31206
|
-
}
|
|
31207
|
-
var CONFIG_LOCK_MAX_RETRIES = 40;
|
|
31208
|
-
var CONFIG_LOCK_RETRY_DELAY_MS = 50;
|
|
31209
|
-
function sleepSyncMs(ms) {
|
|
31210
|
-
sleepSync(ms);
|
|
31211
|
-
}
|
|
31212
|
-
function acquireConfigLock() {
|
|
31213
|
-
const lockPath = getConfigLockPath();
|
|
31214
|
-
try {
|
|
31215
|
-
fs8.mkdirSync(path12.dirname(lockPath), { recursive: true });
|
|
31216
|
-
} catch {}
|
|
31217
|
-
for (let attempt = 0;attempt < CONFIG_LOCK_MAX_RETRIES; attempt++) {
|
|
31218
|
-
try {
|
|
31219
|
-
const ownership = tryAcquireLockSync(lockPath, createLockPayload());
|
|
31220
|
-
if (ownership) {
|
|
31221
|
-
return () => releaseLock(ownership);
|
|
31222
|
-
}
|
|
31223
|
-
} catch (error2) {
|
|
31224
|
-
throw new ConfigError(`Unable to acquire config lock at ${lockPath}: ${error2 instanceof Error ? error2.message : String(error2)}`, "INVALID_CONFIG_FILE");
|
|
31225
|
-
}
|
|
31226
|
-
const probe = probeLock(lockPath);
|
|
31227
|
-
if (probe.state === "stale" && reclaimStaleLock(lockPath, probe)) {
|
|
31228
|
-
continue;
|
|
31229
|
-
}
|
|
31230
|
-
if (attempt < CONFIG_LOCK_MAX_RETRIES - 1) {
|
|
31231
|
-
sleepSyncMs(CONFIG_LOCK_RETRY_DELAY_MS);
|
|
31232
|
-
}
|
|
31233
|
-
}
|
|
31234
|
-
throw new ConfigError(`Timed out waiting for config lock at ${lockPath}. Another AKM process may be updating config.`, "INVALID_CONFIG_FILE");
|
|
31235
|
-
}
|
|
31236
|
-
function withConfigLock(fn) {
|
|
31237
|
-
const release = acquireConfigLock();
|
|
31238
|
-
try {
|
|
31239
|
-
return fn();
|
|
31240
|
-
} finally {
|
|
31241
|
-
release();
|
|
31242
|
-
}
|
|
31243
|
-
}
|
|
31244
|
-
|
|
31245
|
-
// node_modules/zod/v3/external.js
|
|
31246
|
-
var exports_external = {};
|
|
31247
|
-
__export(exports_external, {
|
|
31248
|
-
void: () => voidType,
|
|
31249
|
-
util: () => util,
|
|
31250
|
-
unknown: () => unknownType,
|
|
31251
|
-
union: () => unionType,
|
|
31252
|
-
undefined: () => undefinedType,
|
|
31253
|
-
tuple: () => tupleType,
|
|
31254
|
-
transformer: () => effectsType,
|
|
31255
|
-
symbol: () => symbolType,
|
|
31256
|
-
string: () => stringType,
|
|
31257
|
-
strictObject: () => strictObjectType,
|
|
31258
|
-
setErrorMap: () => setErrorMap,
|
|
31259
|
-
set: () => setType,
|
|
31260
|
-
record: () => recordType,
|
|
31261
|
-
quotelessJson: () => quotelessJson,
|
|
31262
|
-
promise: () => promiseType,
|
|
31263
|
-
preprocess: () => preprocessType,
|
|
31264
|
-
pipeline: () => pipelineType,
|
|
31265
|
-
ostring: () => ostring,
|
|
31266
|
-
optional: () => optionalType,
|
|
31267
|
-
onumber: () => onumber,
|
|
31268
|
-
oboolean: () => oboolean,
|
|
31269
|
-
objectUtil: () => objectUtil,
|
|
31270
|
-
object: () => objectType,
|
|
31271
|
-
number: () => numberType,
|
|
31272
|
-
nullable: () => nullableType,
|
|
31273
|
-
null: () => nullType,
|
|
31274
|
-
never: () => neverType,
|
|
31275
|
-
nativeEnum: () => nativeEnumType,
|
|
31276
|
-
nan: () => nanType,
|
|
31277
|
-
map: () => mapType,
|
|
31278
|
-
makeIssue: () => makeIssue,
|
|
31279
|
-
literal: () => literalType,
|
|
31280
|
-
lazy: () => lazyType,
|
|
31281
|
-
late: () => late,
|
|
31282
|
-
isValid: () => isValid,
|
|
31283
|
-
isDirty: () => isDirty,
|
|
31284
|
-
isAsync: () => isAsync,
|
|
31285
|
-
isAborted: () => isAborted,
|
|
31286
|
-
intersection: () => intersectionType,
|
|
31287
|
-
instanceof: () => instanceOfType,
|
|
31288
|
-
getParsedType: () => getParsedType,
|
|
31289
|
-
getErrorMap: () => getErrorMap,
|
|
31290
|
-
function: () => functionType,
|
|
31291
|
-
enum: () => enumType,
|
|
31292
|
-
effect: () => effectsType,
|
|
31293
|
-
discriminatedUnion: () => discriminatedUnionType,
|
|
31294
|
-
defaultErrorMap: () => en_default,
|
|
31295
|
-
datetimeRegex: () => datetimeRegex,
|
|
31296
|
-
date: () => dateType,
|
|
31297
|
-
custom: () => custom,
|
|
31298
|
-
coerce: () => coerce,
|
|
31299
|
-
boolean: () => booleanType,
|
|
31300
|
-
bigint: () => bigIntType,
|
|
31301
|
-
array: () => arrayType,
|
|
31302
|
-
any: () => anyType,
|
|
31303
|
-
addIssueToContext: () => addIssueToContext,
|
|
31304
|
-
ZodVoid: () => ZodVoid,
|
|
31305
|
-
ZodUnknown: () => ZodUnknown,
|
|
31306
|
-
ZodUnion: () => ZodUnion,
|
|
31307
|
-
ZodUndefined: () => ZodUndefined,
|
|
31308
|
-
ZodType: () => ZodType,
|
|
31309
|
-
ZodTuple: () => ZodTuple,
|
|
31310
|
-
ZodTransformer: () => ZodEffects,
|
|
31311
|
-
ZodSymbol: () => ZodSymbol,
|
|
31312
|
-
ZodString: () => ZodString,
|
|
31313
|
-
ZodSet: () => ZodSet,
|
|
31314
|
-
ZodSchema: () => ZodType,
|
|
31315
|
-
ZodRecord: () => ZodRecord,
|
|
31316
|
-
ZodReadonly: () => ZodReadonly,
|
|
31317
|
-
ZodPromise: () => ZodPromise,
|
|
31318
|
-
ZodPipeline: () => ZodPipeline,
|
|
31319
|
-
ZodParsedType: () => ZodParsedType,
|
|
31320
|
-
ZodOptional: () => ZodOptional,
|
|
31321
|
-
ZodObject: () => ZodObject,
|
|
31322
|
-
ZodNumber: () => ZodNumber,
|
|
31323
|
-
ZodNullable: () => ZodNullable,
|
|
31324
|
-
ZodNull: () => ZodNull,
|
|
31325
|
-
ZodNever: () => ZodNever,
|
|
31326
|
-
ZodNativeEnum: () => ZodNativeEnum,
|
|
31327
|
-
ZodNaN: () => ZodNaN,
|
|
31328
|
-
ZodMap: () => ZodMap,
|
|
31329
|
-
ZodLiteral: () => ZodLiteral,
|
|
31330
|
-
ZodLazy: () => ZodLazy,
|
|
31331
|
-
ZodIssueCode: () => ZodIssueCode,
|
|
31332
|
-
ZodIntersection: () => ZodIntersection,
|
|
31333
|
-
ZodFunction: () => ZodFunction,
|
|
31334
|
-
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
31335
|
-
ZodError: () => ZodError,
|
|
31336
|
-
ZodEnum: () => ZodEnum,
|
|
31337
|
-
ZodEffects: () => ZodEffects,
|
|
31338
|
-
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
31339
|
-
ZodDefault: () => ZodDefault,
|
|
31340
|
-
ZodDate: () => ZodDate,
|
|
31341
|
-
ZodCatch: () => ZodCatch,
|
|
31342
|
-
ZodBranded: () => ZodBranded,
|
|
31343
|
-
ZodBoolean: () => ZodBoolean,
|
|
31344
|
-
ZodBigInt: () => ZodBigInt,
|
|
31345
|
-
ZodArray: () => ZodArray,
|
|
31346
|
-
ZodAny: () => ZodAny,
|
|
31347
|
-
Schema: () => ZodType,
|
|
31348
|
-
ParseStatus: () => ParseStatus,
|
|
31349
|
-
OK: () => OK,
|
|
31350
|
-
NEVER: () => NEVER,
|
|
31351
|
-
INVALID: () => INVALID,
|
|
31352
|
-
EMPTY_PATH: () => EMPTY_PATH,
|
|
31353
|
-
DIRTY: () => DIRTY,
|
|
31354
|
-
BRAND: () => BRAND
|
|
31355
|
-
});
|
|
31356
|
-
|
|
31357
|
-
// node_modules/zod/v3/helpers/util.js
|
|
31358
|
-
var util;
|
|
31359
|
-
(function(util2) {
|
|
31360
|
-
util2.assertEqual = (_) => {};
|
|
31361
|
-
function assertIs(_arg) {}
|
|
31362
|
-
util2.assertIs = assertIs;
|
|
31363
|
-
function assertNever2(_x) {
|
|
31364
|
-
throw new Error;
|
|
31365
|
-
}
|
|
31366
|
-
util2.assertNever = assertNever2;
|
|
31367
|
-
util2.arrayToEnum = (items) => {
|
|
31368
|
-
const obj = {};
|
|
31369
|
-
for (const item of items) {
|
|
31370
|
-
obj[item] = item;
|
|
31371
|
-
}
|
|
31372
|
-
return obj;
|
|
30884
|
+
return obj;
|
|
31373
30885
|
};
|
|
31374
30886
|
util2.getValidEnumValues = (obj) => {
|
|
31375
30887
|
const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
@@ -31717,8 +31229,8 @@ function getErrorMap() {
|
|
|
31717
31229
|
}
|
|
31718
31230
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
31719
31231
|
var makeIssue = (params) => {
|
|
31720
|
-
const { data, path:
|
|
31721
|
-
const fullPath = [...
|
|
31232
|
+
const { data, path: path12, errorMaps, issueData } = params;
|
|
31233
|
+
const fullPath = [...path12, ...issueData.path || []];
|
|
31722
31234
|
const fullIssue = {
|
|
31723
31235
|
...issueData,
|
|
31724
31236
|
path: fullPath
|
|
@@ -31830,11 +31342,11 @@ var errorUtil;
|
|
|
31830
31342
|
|
|
31831
31343
|
// node_modules/zod/v3/types.js
|
|
31832
31344
|
class ParseInputLazyPath {
|
|
31833
|
-
constructor(parent, value,
|
|
31345
|
+
constructor(parent, value, path12, key) {
|
|
31834
31346
|
this._cachedPath = [];
|
|
31835
31347
|
this.parent = parent;
|
|
31836
31348
|
this.data = value;
|
|
31837
|
-
this._path =
|
|
31349
|
+
this._path = path12;
|
|
31838
31350
|
this._key = key;
|
|
31839
31351
|
}
|
|
31840
31352
|
get path() {
|
|
@@ -35113,108 +34625,258 @@ function custom(check, _params = {}, fatal) {
|
|
|
35113
34625
|
}
|
|
35114
34626
|
});
|
|
35115
34627
|
}
|
|
35116
|
-
if (!r) {
|
|
35117
|
-
const params = cleanParams(_params, data);
|
|
35118
|
-
const _fatal = params.fatal ?? fatal ?? true;
|
|
35119
|
-
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
34628
|
+
if (!r) {
|
|
34629
|
+
const params = cleanParams(_params, data);
|
|
34630
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
34631
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
34632
|
+
}
|
|
34633
|
+
return;
|
|
34634
|
+
});
|
|
34635
|
+
return ZodAny.create();
|
|
34636
|
+
}
|
|
34637
|
+
var late = {
|
|
34638
|
+
object: ZodObject.lazycreate
|
|
34639
|
+
};
|
|
34640
|
+
var ZodFirstPartyTypeKind;
|
|
34641
|
+
(function(ZodFirstPartyTypeKind2) {
|
|
34642
|
+
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
|
|
34643
|
+
ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
|
|
34644
|
+
ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
|
|
34645
|
+
ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
|
|
34646
|
+
ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
|
|
34647
|
+
ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
|
|
34648
|
+
ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
|
|
34649
|
+
ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
|
|
34650
|
+
ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
|
|
34651
|
+
ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
|
|
34652
|
+
ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
|
|
34653
|
+
ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
|
|
34654
|
+
ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
|
|
34655
|
+
ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
|
|
34656
|
+
ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
|
|
34657
|
+
ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
|
|
34658
|
+
ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
34659
|
+
ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
|
|
34660
|
+
ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
|
|
34661
|
+
ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
|
|
34662
|
+
ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
|
|
34663
|
+
ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
|
|
34664
|
+
ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
|
|
34665
|
+
ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
|
|
34666
|
+
ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
|
|
34667
|
+
ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
|
|
34668
|
+
ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
|
|
34669
|
+
ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
|
|
34670
|
+
ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
|
|
34671
|
+
ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
|
|
34672
|
+
ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
|
|
34673
|
+
ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
|
|
34674
|
+
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
34675
|
+
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
34676
|
+
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
34677
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
34678
|
+
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
34679
|
+
var instanceOfType = (cls, params = {
|
|
34680
|
+
message: `Input not instance of ${cls.name}`
|
|
34681
|
+
}) => custom((data) => data instanceof cls, params);
|
|
34682
|
+
var stringType = ZodString.create;
|
|
34683
|
+
var numberType = ZodNumber.create;
|
|
34684
|
+
var nanType = ZodNaN.create;
|
|
34685
|
+
var bigIntType = ZodBigInt.create;
|
|
34686
|
+
var booleanType = ZodBoolean.create;
|
|
34687
|
+
var dateType = ZodDate.create;
|
|
34688
|
+
var symbolType = ZodSymbol.create;
|
|
34689
|
+
var undefinedType = ZodUndefined.create;
|
|
34690
|
+
var nullType = ZodNull.create;
|
|
34691
|
+
var anyType = ZodAny.create;
|
|
34692
|
+
var unknownType = ZodUnknown.create;
|
|
34693
|
+
var neverType = ZodNever.create;
|
|
34694
|
+
var voidType = ZodVoid.create;
|
|
34695
|
+
var arrayType = ZodArray.create;
|
|
34696
|
+
var objectType = ZodObject.create;
|
|
34697
|
+
var strictObjectType = ZodObject.strictCreate;
|
|
34698
|
+
var unionType = ZodUnion.create;
|
|
34699
|
+
var discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
34700
|
+
var intersectionType = ZodIntersection.create;
|
|
34701
|
+
var tupleType = ZodTuple.create;
|
|
34702
|
+
var recordType = ZodRecord.create;
|
|
34703
|
+
var mapType = ZodMap.create;
|
|
34704
|
+
var setType = ZodSet.create;
|
|
34705
|
+
var functionType = ZodFunction.create;
|
|
34706
|
+
var lazyType = ZodLazy.create;
|
|
34707
|
+
var literalType = ZodLiteral.create;
|
|
34708
|
+
var enumType = ZodEnum.create;
|
|
34709
|
+
var nativeEnumType = ZodNativeEnum.create;
|
|
34710
|
+
var promiseType = ZodPromise.create;
|
|
34711
|
+
var effectsType = ZodEffects.create;
|
|
34712
|
+
var optionalType = ZodOptional.create;
|
|
34713
|
+
var nullableType = ZodNullable.create;
|
|
34714
|
+
var preprocessType = ZodEffects.createWithPreprocess;
|
|
34715
|
+
var pipelineType = ZodPipeline.create;
|
|
34716
|
+
var ostring = () => stringType().optional();
|
|
34717
|
+
var onumber = () => numberType().optional();
|
|
34718
|
+
var oboolean = () => booleanType().optional();
|
|
34719
|
+
var coerce = {
|
|
34720
|
+
string: (arg) => ZodString.create({ ...arg, coerce: true }),
|
|
34721
|
+
number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
|
|
34722
|
+
boolean: (arg) => ZodBoolean.create({
|
|
34723
|
+
...arg,
|
|
34724
|
+
coerce: true
|
|
34725
|
+
}),
|
|
34726
|
+
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
|
|
34727
|
+
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
34728
|
+
};
|
|
34729
|
+
var NEVER = INVALID;
|
|
34730
|
+
// src/core/extra-params.ts
|
|
34731
|
+
var EXTRA_PARAMS_PROTECTED_TOP_LEVEL_KEYS = [
|
|
34732
|
+
"model",
|
|
34733
|
+
"messages",
|
|
34734
|
+
"temperature",
|
|
34735
|
+
"maxtokens",
|
|
34736
|
+
"responseformat",
|
|
34737
|
+
"stream",
|
|
34738
|
+
"streamoptions",
|
|
34739
|
+
"enablethinking",
|
|
34740
|
+
"reasoningeffort",
|
|
34741
|
+
"chattemplatekwargs"
|
|
34742
|
+
];
|
|
34743
|
+
var EXTRA_PARAMS_CREDENTIAL_KEYS = [
|
|
34744
|
+
"authorization",
|
|
34745
|
+
"headers",
|
|
34746
|
+
"apikey",
|
|
34747
|
+
"token",
|
|
34748
|
+
"password",
|
|
34749
|
+
"secret",
|
|
34750
|
+
"cookie",
|
|
34751
|
+
"setcookie"
|
|
34752
|
+
];
|
|
34753
|
+
var PROTECTED_TOP_LEVEL_KEYS = new Set(EXTRA_PARAMS_PROTECTED_TOP_LEVEL_KEYS);
|
|
34754
|
+
var CREDENTIAL_KEYS = new Set(EXTRA_PARAMS_CREDENTIAL_KEYS);
|
|
34755
|
+
var LEGACY_EXTRA_PARAMS_FIELD = {
|
|
34756
|
+
model: "model",
|
|
34757
|
+
temperature: "temperature",
|
|
34758
|
+
maxtokens: "maxTokens",
|
|
34759
|
+
enablethinking: "enableThinking",
|
|
34760
|
+
reasoningeffort: "reasoningEffort"
|
|
34761
|
+
};
|
|
34762
|
+
var LIFTABLE_EXTRA_PARAMS_KEYS = new Set(["temperature", "maxtokens", "enablethinking", "reasoningeffort"]);
|
|
34763
|
+
var EXTRA_PARAMS_NO_FIELD_REMEDY = {
|
|
34764
|
+
messages: "AKM builds the request messages internally \u2014 remove it from extraParams",
|
|
34765
|
+
responseformat: "AKM controls the response format internally \u2014 remove it from extraParams",
|
|
34766
|
+
stream: "AKM controls streaming internally \u2014 remove it from extraParams",
|
|
34767
|
+
streamoptions: "AKM controls streaming internally \u2014 remove it from extraParams",
|
|
34768
|
+
chattemplatekwargs: "set engines.<name>.enableThinking instead of chat_template_kwargs.enable_thinking"
|
|
34769
|
+
};
|
|
34770
|
+
function protectedKeyRemedy(normalized) {
|
|
34771
|
+
const field = LEGACY_EXTRA_PARAMS_FIELD[normalized];
|
|
34772
|
+
if (field) {
|
|
34773
|
+
const note = normalized === "reasoningeffort" ? " (moved to a first-class field in 0.9.2)" : "";
|
|
34774
|
+
return `set engines.<name>.${field} instead${note}`;
|
|
34775
|
+
}
|
|
34776
|
+
return EXTRA_PARAMS_NO_FIELD_REMEDY[normalized];
|
|
34777
|
+
}
|
|
34778
|
+
function normalizeExtraParamKey(key) {
|
|
34779
|
+
return key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
34780
|
+
}
|
|
34781
|
+
function validateExtraParams(value) {
|
|
34782
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
34783
|
+
return [{ path: [], message: "must be an object" }];
|
|
34784
|
+
}
|
|
34785
|
+
const issues = [];
|
|
34786
|
+
const seen = new WeakSet;
|
|
34787
|
+
const visit2 = (entry, path12) => {
|
|
34788
|
+
if (Array.isArray(entry)) {
|
|
34789
|
+
if (seen.has(entry))
|
|
34790
|
+
return;
|
|
34791
|
+
seen.add(entry);
|
|
34792
|
+
entry.forEach((child, index) => {
|
|
34793
|
+
visit2(child, [...path12, index]);
|
|
34794
|
+
});
|
|
34795
|
+
return;
|
|
34796
|
+
}
|
|
34797
|
+
if (!entry || typeof entry !== "object")
|
|
34798
|
+
return;
|
|
34799
|
+
if (seen.has(entry))
|
|
34800
|
+
return;
|
|
34801
|
+
seen.add(entry);
|
|
34802
|
+
for (const [key, child] of Object.entries(entry)) {
|
|
34803
|
+
const normalized = normalizeExtraParamKey(key);
|
|
34804
|
+
if (path12.length === 0 && PROTECTED_TOP_LEVEL_KEYS.has(normalized)) {
|
|
34805
|
+
const remedy = protectedKeyRemedy(normalized);
|
|
34806
|
+
issues.push({
|
|
34807
|
+
path: [key],
|
|
34808
|
+
message: remedy ? `${key} is protected by AKM \u2014 ${remedy}.` : `${key} is protected by AKM`
|
|
34809
|
+
});
|
|
34810
|
+
}
|
|
34811
|
+
if (CREDENTIAL_KEYS.has(normalized)) {
|
|
34812
|
+
issues.push({ path: [...path12, key], message: `${key} cannot carry credentials` });
|
|
34813
|
+
}
|
|
34814
|
+
visit2(child, [...path12, key]);
|
|
34815
|
+
}
|
|
34816
|
+
};
|
|
34817
|
+
visit2(value, []);
|
|
34818
|
+
return issues;
|
|
34819
|
+
}
|
|
34820
|
+
function formatExtraParamsIssue(label, issue) {
|
|
34821
|
+
const suffix = issue.path.map((part) => typeof part === "number" ? `[${part}]` : `.${part}`).join("");
|
|
34822
|
+
return `${label}${suffix} ${issue.message}`;
|
|
34823
|
+
}
|
|
34824
|
+
function liftLegacyEngineExtraParams(raw) {
|
|
34825
|
+
const lifted = [];
|
|
34826
|
+
const conflicts = [];
|
|
34827
|
+
const rawEngines = raw.engines;
|
|
34828
|
+
if (!isRecord(rawEngines)) {
|
|
34829
|
+
return { config: raw, lifted, conflicts };
|
|
34830
|
+
}
|
|
34831
|
+
const engines = {};
|
|
34832
|
+
let anyEngineChanged = false;
|
|
34833
|
+
for (const [name, engineValue] of Object.entries(rawEngines)) {
|
|
34834
|
+
if (!isRecord(engineValue) || !isRecord(engineValue.extraParams)) {
|
|
34835
|
+
engines[name] = engineValue;
|
|
34836
|
+
continue;
|
|
34837
|
+
}
|
|
34838
|
+
const engine = { ...engineValue };
|
|
34839
|
+
const extraParams = { ...engineValue.extraParams };
|
|
34840
|
+
let engineChanged = false;
|
|
34841
|
+
for (const [rawKey, value] of Object.entries(engineValue.extraParams)) {
|
|
34842
|
+
const normalized = normalizeExtraParamKey(rawKey);
|
|
34843
|
+
if (!LIFTABLE_EXTRA_PARAMS_KEYS.has(normalized))
|
|
34844
|
+
continue;
|
|
34845
|
+
const field = LEGACY_EXTRA_PARAMS_FIELD[normalized];
|
|
34846
|
+
if (!field)
|
|
34847
|
+
continue;
|
|
34848
|
+
const existing = engine[field];
|
|
34849
|
+
if (existing !== undefined && existing !== value) {
|
|
34850
|
+
conflicts.push({ engine: name, key: rawKey, field, extraParamsValue: value, fieldValue: existing });
|
|
34851
|
+
continue;
|
|
34852
|
+
}
|
|
34853
|
+
delete extraParams[rawKey];
|
|
34854
|
+
engineChanged = true;
|
|
34855
|
+
if (existing === value) {
|
|
34856
|
+
lifted.push(`engines.${name}.extraParams.${rawKey} is redundant \u2014 engines.${name}.${field} is already set to the same value; dropped the extraParams entry`);
|
|
34857
|
+
continue;
|
|
35120
34858
|
}
|
|
35121
|
-
|
|
35122
|
-
|
|
35123
|
-
|
|
34859
|
+
engine[field] = value;
|
|
34860
|
+
lifted.push(`engines.${name}.extraParams.${rawKey} -> engines.${name}.${field}`);
|
|
34861
|
+
}
|
|
34862
|
+
if (!engineChanged) {
|
|
34863
|
+
engines[name] = engineValue;
|
|
34864
|
+
continue;
|
|
34865
|
+
}
|
|
34866
|
+
anyEngineChanged = true;
|
|
34867
|
+
if (Object.keys(extraParams).length > 0) {
|
|
34868
|
+
engine.extraParams = extraParams;
|
|
34869
|
+
} else {
|
|
34870
|
+
delete engine.extraParams;
|
|
34871
|
+
}
|
|
34872
|
+
engines[name] = engine;
|
|
34873
|
+
}
|
|
34874
|
+
if (!anyEngineChanged) {
|
|
34875
|
+
return { config: raw, lifted, conflicts };
|
|
34876
|
+
}
|
|
34877
|
+
return { config: { ...raw, engines }, lifted, conflicts };
|
|
35124
34878
|
}
|
|
35125
|
-
|
|
35126
|
-
object: ZodObject.lazycreate
|
|
35127
|
-
};
|
|
35128
|
-
var ZodFirstPartyTypeKind;
|
|
35129
|
-
(function(ZodFirstPartyTypeKind2) {
|
|
35130
|
-
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
|
|
35131
|
-
ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
|
|
35132
|
-
ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
|
|
35133
|
-
ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
|
|
35134
|
-
ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
|
|
35135
|
-
ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
|
|
35136
|
-
ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
|
|
35137
|
-
ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
|
|
35138
|
-
ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
|
|
35139
|
-
ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
|
|
35140
|
-
ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
|
|
35141
|
-
ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
|
|
35142
|
-
ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
|
|
35143
|
-
ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
|
|
35144
|
-
ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
|
|
35145
|
-
ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
|
|
35146
|
-
ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
35147
|
-
ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
|
|
35148
|
-
ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
|
|
35149
|
-
ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
|
|
35150
|
-
ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
|
|
35151
|
-
ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
|
|
35152
|
-
ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
|
|
35153
|
-
ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
|
|
35154
|
-
ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
|
|
35155
|
-
ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
|
|
35156
|
-
ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
|
|
35157
|
-
ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
|
|
35158
|
-
ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
|
|
35159
|
-
ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
|
|
35160
|
-
ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
|
|
35161
|
-
ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
|
|
35162
|
-
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
35163
|
-
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
35164
|
-
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
35165
|
-
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
35166
|
-
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
35167
|
-
var instanceOfType = (cls, params = {
|
|
35168
|
-
message: `Input not instance of ${cls.name}`
|
|
35169
|
-
}) => custom((data) => data instanceof cls, params);
|
|
35170
|
-
var stringType = ZodString.create;
|
|
35171
|
-
var numberType = ZodNumber.create;
|
|
35172
|
-
var nanType = ZodNaN.create;
|
|
35173
|
-
var bigIntType = ZodBigInt.create;
|
|
35174
|
-
var booleanType = ZodBoolean.create;
|
|
35175
|
-
var dateType = ZodDate.create;
|
|
35176
|
-
var symbolType = ZodSymbol.create;
|
|
35177
|
-
var undefinedType = ZodUndefined.create;
|
|
35178
|
-
var nullType = ZodNull.create;
|
|
35179
|
-
var anyType = ZodAny.create;
|
|
35180
|
-
var unknownType = ZodUnknown.create;
|
|
35181
|
-
var neverType = ZodNever.create;
|
|
35182
|
-
var voidType = ZodVoid.create;
|
|
35183
|
-
var arrayType = ZodArray.create;
|
|
35184
|
-
var objectType = ZodObject.create;
|
|
35185
|
-
var strictObjectType = ZodObject.strictCreate;
|
|
35186
|
-
var unionType = ZodUnion.create;
|
|
35187
|
-
var discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
35188
|
-
var intersectionType = ZodIntersection.create;
|
|
35189
|
-
var tupleType = ZodTuple.create;
|
|
35190
|
-
var recordType = ZodRecord.create;
|
|
35191
|
-
var mapType = ZodMap.create;
|
|
35192
|
-
var setType = ZodSet.create;
|
|
35193
|
-
var functionType = ZodFunction.create;
|
|
35194
|
-
var lazyType = ZodLazy.create;
|
|
35195
|
-
var literalType = ZodLiteral.create;
|
|
35196
|
-
var enumType = ZodEnum.create;
|
|
35197
|
-
var nativeEnumType = ZodNativeEnum.create;
|
|
35198
|
-
var promiseType = ZodPromise.create;
|
|
35199
|
-
var effectsType = ZodEffects.create;
|
|
35200
|
-
var optionalType = ZodOptional.create;
|
|
35201
|
-
var nullableType = ZodNullable.create;
|
|
35202
|
-
var preprocessType = ZodEffects.createWithPreprocess;
|
|
35203
|
-
var pipelineType = ZodPipeline.create;
|
|
35204
|
-
var ostring = () => stringType().optional();
|
|
35205
|
-
var onumber = () => numberType().optional();
|
|
35206
|
-
var oboolean = () => booleanType().optional();
|
|
35207
|
-
var coerce = {
|
|
35208
|
-
string: (arg) => ZodString.create({ ...arg, coerce: true }),
|
|
35209
|
-
number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
|
|
35210
|
-
boolean: (arg) => ZodBoolean.create({
|
|
35211
|
-
...arg,
|
|
35212
|
-
coerce: true
|
|
35213
|
-
}),
|
|
35214
|
-
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
|
|
35215
|
-
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
35216
|
-
};
|
|
35217
|
-
var NEVER = INVALID;
|
|
34879
|
+
|
|
35218
34880
|
// src/core/config/schema/primitives.ts
|
|
35219
34881
|
var CURRENT_CONFIG_VERSION = "0.9.0";
|
|
35220
34882
|
var positiveInt = exports_external.number().int().positive();
|
|
@@ -35507,8 +35169,6 @@ var CONSOLIDATE_PROCESS_FIELDS = {
|
|
|
35507
35169
|
limit: processLimitField,
|
|
35508
35170
|
minPoolSize: exports_external.number().int().min(0).optional(),
|
|
35509
35171
|
maxChunkSize: exports_external.number().int().min(1).max(50).optional(),
|
|
35510
|
-
incrementalSince: exports_external.string().optional(),
|
|
35511
|
-
neighborsPerChanged: exports_external.number().int().min(1).optional(),
|
|
35512
35172
|
p90ChunkSecondsDefault: exports_external.number().finite().positive().optional(),
|
|
35513
35173
|
antiCollapse: antiCollapseField
|
|
35514
35174
|
};
|
|
@@ -35516,13 +35176,6 @@ var MEMORY_INFERENCE_PROCESS_FIELDS = {
|
|
|
35516
35176
|
minPendingCount: exports_external.number().int().min(0).optional(),
|
|
35517
35177
|
cls: clsField
|
|
35518
35178
|
};
|
|
35519
|
-
var GRAPH_EXTRACTION_PROCESS_FIELDS = {
|
|
35520
|
-
topN: positiveInt.optional(),
|
|
35521
|
-
includeTypes: exports_external.array(exports_external.string().min(1)).min(1).optional(),
|
|
35522
|
-
batchSize: positiveInt.optional(),
|
|
35523
|
-
fullScan: exports_external.boolean().optional(),
|
|
35524
|
-
maxChunksPerAsset: positiveInt.optional()
|
|
35525
|
-
};
|
|
35526
35179
|
var EXTRACT_PROCESS_FIELDS = {
|
|
35527
35180
|
defaultSince: exports_external.string().min(1).optional(),
|
|
35528
35181
|
maxTotalChars: positiveInt.optional(),
|
|
@@ -35558,7 +35211,6 @@ var ImproveProcessConfigSchema = exports_external.object({
|
|
|
35558
35211
|
...DISTILL_PROCESS_FIELDS,
|
|
35559
35212
|
...CONSOLIDATE_PROCESS_FIELDS,
|
|
35560
35213
|
...MEMORY_INFERENCE_PROCESS_FIELDS,
|
|
35561
|
-
...GRAPH_EXTRACTION_PROCESS_FIELDS,
|
|
35562
35214
|
...EXTRACT_PROCESS_FIELDS,
|
|
35563
35215
|
...TRIAGE_PROCESS_FIELDS,
|
|
35564
35216
|
...PROACTIVE_MAINTENANCE_PROCESS_FIELDS
|
|
@@ -35567,17 +35219,16 @@ var ReflectProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BA
|
|
|
35567
35219
|
var DistillProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BASE_FIELDS, ...DISTILL_PROCESS_FIELDS }).passthrough().superRefine(rejectExcludeRefPrefixesOutsideReflect);
|
|
35568
35220
|
var ConsolidateProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BASE_FIELDS, ...CONSOLIDATE_PROCESS_FIELDS }).passthrough().superRefine(rejectExcludeRefPrefixesOutsideReflect);
|
|
35569
35221
|
var MemoryInferenceProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BASE_FIELDS, ...MEMORY_INFERENCE_PROCESS_FIELDS }).passthrough();
|
|
35570
|
-
var GraphExtractionProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BASE_FIELDS, ...GRAPH_EXTRACTION_PROCESS_FIELDS }).passthrough();
|
|
35571
35222
|
var ExtractProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BASE_FIELDS, ...EXTRACT_PROCESS_FIELDS }).passthrough();
|
|
35572
35223
|
var ValidationProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BASE_FIELDS }).passthrough();
|
|
35573
35224
|
var TriageProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BASE_FIELDS, ...TRIAGE_PROCESS_FIELDS }).passthrough();
|
|
35574
35225
|
var ProactiveMaintenanceProcessConfigSchema = exports_external.object({ ...IMPROVE_PROCESS_BASE_FIELDS, ...PROACTIVE_MAINTENANCE_PROCESS_FIELDS }).passthrough();
|
|
35226
|
+
var RETIRED_PROCESS_NAMES = new Set(["graphExtraction"]);
|
|
35575
35227
|
var ImproveProfileProcessesSchema = exports_external.object({
|
|
35576
35228
|
reflect: ReflectProcessConfigSchema.optional(),
|
|
35577
35229
|
distill: DistillProcessConfigSchema.optional(),
|
|
35578
35230
|
consolidate: ConsolidateProcessConfigSchema.optional(),
|
|
35579
35231
|
memoryInference: MemoryInferenceProcessConfigSchema.optional(),
|
|
35580
|
-
graphExtraction: GraphExtractionProcessConfigSchema.optional(),
|
|
35581
35232
|
extract: ExtractProcessConfigSchema.optional(),
|
|
35582
35233
|
validation: ValidationProcessConfigSchema.optional(),
|
|
35583
35234
|
triage: TriageProcessConfigSchema.optional(),
|
|
@@ -35590,7 +35241,7 @@ var ImproveProfileProcessesSchema = exports_external.object({
|
|
|
35590
35241
|
});
|
|
35591
35242
|
}
|
|
35592
35243
|
for (const [name, process2] of Object.entries(val)) {
|
|
35593
|
-
if (!(name in IMPROVE_PROCESS_ENGINE_CAPABILITIES) && process2 !== null && typeof process2 === "object" && process2.enabled === true) {
|
|
35244
|
+
if (!(name in IMPROVE_PROCESS_ENGINE_CAPABILITIES) && !RETIRED_PROCESS_NAMES.has(name) && process2 !== null && typeof process2 === "object" && process2.enabled === true) {
|
|
35594
35245
|
ctx.addIssue({
|
|
35595
35246
|
code: exports_external.ZodIssueCode.custom,
|
|
35596
35247
|
path: [name],
|
|
@@ -35659,11 +35310,8 @@ var IndexPassConfigSchema = exports_external.preprocess((raw, ctx) => {
|
|
|
35659
35310
|
model: nonEmptyString.optional(),
|
|
35660
35311
|
timeoutMs: exports_external.union([positiveInt, exports_external.null()]).optional(),
|
|
35661
35312
|
enabled: exports_external.boolean().optional(),
|
|
35662
|
-
llm: LlmInvocationOverridesSchema.optional()
|
|
35663
|
-
graphExtractionBatchSize: positiveInt.optional(),
|
|
35664
|
-
graphExtractionIncludeTypes: exports_external.array(exports_external.string().min(1)).nonempty().optional()
|
|
35313
|
+
llm: LlmInvocationOverridesSchema.optional()
|
|
35665
35314
|
}).passthrough());
|
|
35666
|
-
var MetadataEnhanceSchema = exports_external.object({ enabled: exports_external.boolean().optional() }).passthrough();
|
|
35667
35315
|
var IndexDefaultsSchema = exports_external.object({
|
|
35668
35316
|
engine: engineName.optional(),
|
|
35669
35317
|
model: nonEmptyString.optional(),
|
|
@@ -35676,7 +35324,7 @@ var IndexConfigRuntimeSchema = exports_external.preprocess((raw, ctx) => {
|
|
|
35676
35324
|
if (Array.isArray(raw)) {
|
|
35677
35325
|
ctx.addIssue({
|
|
35678
35326
|
code: exports_external.ZodIssueCode.custom,
|
|
35679
|
-
message: 'Invalid `index` config: expected an object keyed by pass name (e.g. `{ "
|
|
35327
|
+
message: 'Invalid `index` config: expected an object keyed by pass name (e.g. `{ "memory": { "enabled": false } }`).'
|
|
35680
35328
|
});
|
|
35681
35329
|
return raw;
|
|
35682
35330
|
}
|
|
@@ -35700,8 +35348,7 @@ var IndexConfigRuntimeSchema = exports_external.preprocess((raw, ctx) => {
|
|
|
35700
35348
|
}
|
|
35701
35349
|
return cleaned ?? raw;
|
|
35702
35350
|
}, exports_external.object({
|
|
35703
|
-
defaults: IndexDefaultsSchema.optional()
|
|
35704
|
-
metadataEnhance: MetadataEnhanceSchema.optional()
|
|
35351
|
+
defaults: IndexDefaultsSchema.optional()
|
|
35705
35352
|
}).catchall(IndexPassConfigSchema));
|
|
35706
35353
|
var IndexConfigSchema = IndexConfigRuntimeSchema;
|
|
35707
35354
|
|
|
@@ -35976,144 +35623,502 @@ var AkmConfigSchema = AkmConfigBaseSchema.superRefine((config, ctx) => {
|
|
|
35976
35623
|
}
|
|
35977
35624
|
}
|
|
35978
35625
|
if (config.defaultWriteTarget !== undefined) {
|
|
35979
|
-
const target = config.bundles?.[config.defaultWriteTarget];
|
|
35980
|
-
if (!target) {
|
|
35626
|
+
const target = config.bundles?.[config.defaultWriteTarget];
|
|
35627
|
+
if (!target) {
|
|
35628
|
+
ctx.addIssue({
|
|
35629
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35630
|
+
path: ["defaultWriteTarget"],
|
|
35631
|
+
message: `defaultWriteTarget "${config.defaultWriteTarget}" does not name a configured bundle`
|
|
35632
|
+
});
|
|
35633
|
+
} else if (target.enabled === false) {
|
|
35634
|
+
ctx.addIssue({
|
|
35635
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35636
|
+
path: ["defaultWriteTarget"],
|
|
35637
|
+
message: `defaultWriteTarget "${config.defaultWriteTarget}" is disabled`
|
|
35638
|
+
});
|
|
35639
|
+
}
|
|
35640
|
+
}
|
|
35641
|
+
for (const key of ["llm", "agent", "improve"]) {
|
|
35642
|
+
if (config.defaults && key in config.defaults) {
|
|
35643
|
+
ctx.addIssue({
|
|
35644
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35645
|
+
path: ["defaults", key],
|
|
35646
|
+
message: `defaults.${key} is retired in 0.9`
|
|
35647
|
+
});
|
|
35648
|
+
}
|
|
35649
|
+
}
|
|
35650
|
+
for (const [name, engine] of Object.entries(config.engines ?? {})) {
|
|
35651
|
+
if (engine.kind === "agent" && engine.llmEngine) {
|
|
35652
|
+
const fallback = config.engines?.[engine.llmEngine];
|
|
35653
|
+
if (!fallback || fallback.kind !== "llm") {
|
|
35654
|
+
ctx.addIssue({
|
|
35655
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35656
|
+
path: ["engines", name, "llmEngine"],
|
|
35657
|
+
message: "llmEngine must name an LLM engine"
|
|
35658
|
+
});
|
|
35659
|
+
}
|
|
35660
|
+
}
|
|
35661
|
+
}
|
|
35662
|
+
const defaultEngine = config.defaults?.engine;
|
|
35663
|
+
if (defaultEngine && !config.engines?.[defaultEngine]) {
|
|
35664
|
+
ctx.addIssue({
|
|
35665
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35666
|
+
path: ["defaults", "engine"],
|
|
35667
|
+
message: "engine does not name a configured engine"
|
|
35668
|
+
});
|
|
35669
|
+
}
|
|
35670
|
+
const defaultLlm = config.defaults?.llmEngine;
|
|
35671
|
+
if (defaultLlm && config.engines?.[defaultLlm]?.kind !== "llm") {
|
|
35672
|
+
ctx.addIssue({
|
|
35673
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35674
|
+
path: ["defaults", "llmEngine"],
|
|
35675
|
+
message: "llmEngine must name an LLM engine"
|
|
35676
|
+
});
|
|
35677
|
+
}
|
|
35678
|
+
const workflowJudge = config.workflow?.judgeEngine;
|
|
35679
|
+
if (workflowJudge && !config.engines?.[workflowJudge]) {
|
|
35680
|
+
ctx.addIssue({
|
|
35681
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35682
|
+
path: ["workflow", "judgeEngine"],
|
|
35683
|
+
message: "judgeEngine does not name a configured engine"
|
|
35684
|
+
});
|
|
35685
|
+
}
|
|
35686
|
+
const defaultStrategy = config.defaults?.improveStrategy;
|
|
35687
|
+
if (defaultStrategy && defaultStrategy !== "graph-refresh" && !BUILTIN_IMPROVE_STRATEGY_NAMES.includes(defaultStrategy) && !config.improve?.strategies?.[defaultStrategy]) {
|
|
35688
|
+
ctx.addIssue({
|
|
35689
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35690
|
+
path: ["defaults", "improveStrategy"],
|
|
35691
|
+
message: "improveStrategy does not name a built-in or configured strategy"
|
|
35692
|
+
});
|
|
35693
|
+
}
|
|
35694
|
+
for (const [strategyName, strategy] of Object.entries(config.improve?.strategies ?? {})) {
|
|
35695
|
+
const strategyEngine = strategy.engine;
|
|
35696
|
+
if (strategyEngine) {
|
|
35697
|
+
const engine = config.engines?.[strategyEngine];
|
|
35698
|
+
if (!engine || engine.kind !== "llm") {
|
|
35699
|
+
ctx.addIssue({
|
|
35700
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35701
|
+
path: ["improve", "strategies", strategyName, "engine"],
|
|
35702
|
+
message: engine ? "strategy engine must be an LLM engine" : "engine does not name a configured engine"
|
|
35703
|
+
});
|
|
35704
|
+
}
|
|
35705
|
+
}
|
|
35706
|
+
for (const [processName, process2] of Object.entries(strategy.processes ?? {})) {
|
|
35707
|
+
const processConfig = process2;
|
|
35708
|
+
const capability = IMPROVE_PROCESS_ENGINE_CAPABILITIES[processName];
|
|
35709
|
+
if (processConfig.engine && capability === null) {
|
|
35710
|
+
ctx.addIssue({
|
|
35711
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35712
|
+
path: ["improve", "strategies", strategyName, "processes", processName, "engine"],
|
|
35713
|
+
message: `${processName} does not dispatch an engine`
|
|
35714
|
+
});
|
|
35715
|
+
} else {
|
|
35716
|
+
const processEngine = processConfig.engine ?? strategyEngine;
|
|
35717
|
+
if (processEngine && capability === "llm") {
|
|
35718
|
+
const engine = config.engines?.[processEngine];
|
|
35719
|
+
if (!engine || engine.kind !== "llm") {
|
|
35720
|
+
ctx.addIssue({
|
|
35721
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35722
|
+
path: ["improve", "strategies", strategyName, "processes", processName, "engine"],
|
|
35723
|
+
message: engine ? `${processName} requires an LLM engine` : "engine does not name a configured engine"
|
|
35724
|
+
});
|
|
35725
|
+
}
|
|
35726
|
+
} else if (processConfig.engine && capability === "runner" && !config.engines?.[processConfig.engine]) {
|
|
35727
|
+
ctx.addIssue({
|
|
35728
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35729
|
+
path: ["improve", "strategies", strategyName, "processes", processName, "engine"],
|
|
35730
|
+
message: "engine does not name a configured engine"
|
|
35731
|
+
});
|
|
35732
|
+
}
|
|
35733
|
+
}
|
|
35734
|
+
const judgmentEngine = processConfig.judgment?.engine;
|
|
35735
|
+
if (processConfig.judgment?.enabled === true && judgmentEngine) {
|
|
35736
|
+
const engine = config.engines?.[judgmentEngine];
|
|
35737
|
+
if (!engine) {
|
|
35738
|
+
ctx.addIssue({
|
|
35739
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35740
|
+
path: ["improve", "strategies", strategyName, "processes", processName, "judgment", "engine"],
|
|
35741
|
+
message: "engine does not name a configured engine"
|
|
35742
|
+
});
|
|
35743
|
+
}
|
|
35744
|
+
}
|
|
35745
|
+
}
|
|
35746
|
+
}
|
|
35747
|
+
if (config.defaultWriteTarget !== undefined) {
|
|
35748
|
+
const knownNames = Object.keys(config.bundles ?? {});
|
|
35749
|
+
if (knownNames.length === 0) {
|
|
35981
35750
|
ctx.addIssue({
|
|
35982
35751
|
code: exports_external.ZodIssueCode.custom,
|
|
35983
35752
|
path: ["defaultWriteTarget"],
|
|
35984
|
-
message: `defaultWriteTarget "${config.defaultWriteTarget}"
|
|
35753
|
+
message: `defaultWriteTarget "${config.defaultWriteTarget}" cannot be resolved: no bundles configured. ` + "Add at least one entry to `bundles` first."
|
|
35985
35754
|
});
|
|
35986
|
-
} else if (
|
|
35755
|
+
} else if (!knownNames.includes(config.defaultWriteTarget)) {
|
|
35987
35756
|
ctx.addIssue({
|
|
35988
35757
|
code: exports_external.ZodIssueCode.custom,
|
|
35989
35758
|
path: ["defaultWriteTarget"],
|
|
35990
|
-
message: `defaultWriteTarget "${config.defaultWriteTarget}"
|
|
35759
|
+
message: `defaultWriteTarget "${config.defaultWriteTarget}" does not match any configured bundle: ${knownNames.map((n) => `"${n}"`).join(", ")}.`
|
|
35991
35760
|
});
|
|
35992
35761
|
}
|
|
35993
35762
|
}
|
|
35994
|
-
|
|
35995
|
-
|
|
35996
|
-
|
|
35997
|
-
|
|
35998
|
-
|
|
35999
|
-
|
|
36000
|
-
|
|
35763
|
+
});
|
|
35764
|
+
|
|
35765
|
+
// src/core/config/deep-merge.ts
|
|
35766
|
+
var UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
35767
|
+
function isPlainObject(value) {
|
|
35768
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
35769
|
+
return false;
|
|
35770
|
+
const prototype = Object.getPrototypeOf(value);
|
|
35771
|
+
return prototype === Object.prototype || prototype === null;
|
|
35772
|
+
}
|
|
35773
|
+
function copyConfigValue(value) {
|
|
35774
|
+
if (Array.isArray(value))
|
|
35775
|
+
return value.map(copyConfigValue);
|
|
35776
|
+
if (!isPlainObject(value))
|
|
35777
|
+
return value;
|
|
35778
|
+
const copy = {};
|
|
35779
|
+
for (const key of Object.keys(value)) {
|
|
35780
|
+
if (UNSAFE_KEYS.has(key))
|
|
35781
|
+
throw new TypeError(`Unsafe configuration key: ${key}`);
|
|
35782
|
+
copy[key] = copyConfigValue(value[key]);
|
|
35783
|
+
}
|
|
35784
|
+
return copy;
|
|
35785
|
+
}
|
|
35786
|
+
function deepMergeConfig(base, override) {
|
|
35787
|
+
const result = copyConfigValue(base);
|
|
35788
|
+
for (const key of Object.keys(override)) {
|
|
35789
|
+
if (UNSAFE_KEYS.has(key))
|
|
35790
|
+
throw new TypeError(`Unsafe configuration key: ${key}`);
|
|
35791
|
+
const next = override[key];
|
|
35792
|
+
if (next === undefined)
|
|
35793
|
+
continue;
|
|
35794
|
+
const current = result[key];
|
|
35795
|
+
result[key] = isPlainObject(current) && isPlainObject(next) ? deepMergeConfig(current, next) : copyConfigValue(next);
|
|
35796
|
+
}
|
|
35797
|
+
return result;
|
|
35798
|
+
}
|
|
35799
|
+
|
|
35800
|
+
// src/core/config/config.ts
|
|
35801
|
+
import fs10 from "fs";
|
|
35802
|
+
import os2 from "os";
|
|
35803
|
+
import path14 from "path";
|
|
35804
|
+
import { isDeepStrictEqual } from "util";
|
|
35805
|
+
|
|
35806
|
+
// src/core/config/config-io.ts
|
|
35807
|
+
import fs8 from "fs";
|
|
35808
|
+
import path12 from "path";
|
|
35809
|
+
|
|
35810
|
+
// src/core/file-lock.ts
|
|
35811
|
+
import { randomUUID } from "crypto";
|
|
35812
|
+
import fs7 from "fs";
|
|
35813
|
+
function readLockSnapshot(lockPath) {
|
|
35814
|
+
let fd;
|
|
35815
|
+
try {
|
|
35816
|
+
fd = fs7.openSync(lockPath, "r");
|
|
35817
|
+
} catch (err) {
|
|
35818
|
+
if (err.code === "ENOENT")
|
|
35819
|
+
return;
|
|
35820
|
+
throw err;
|
|
35821
|
+
}
|
|
35822
|
+
try {
|
|
35823
|
+
const rawContent = readTextFileDescriptorWithLimit(fd, MAX_LOCK_METADATA_BYTES, "Lock metadata", lockPath);
|
|
35824
|
+
const stat = fs7.fstatSync(fd);
|
|
35825
|
+
return {
|
|
35826
|
+
rawContent,
|
|
35827
|
+
identity: { dev: stat.dev, ino: stat.ino, size: stat.size, mtimeMs: stat.mtimeMs }
|
|
35828
|
+
};
|
|
35829
|
+
} finally {
|
|
35830
|
+
fs7.closeSync(fd);
|
|
35831
|
+
}
|
|
35832
|
+
}
|
|
35833
|
+
function sameIdentity(left, right) {
|
|
35834
|
+
return left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs;
|
|
35835
|
+
}
|
|
35836
|
+
function releaseLockRaw(lockPath) {
|
|
35837
|
+
try {
|
|
35838
|
+
fs7.unlinkSync(lockPath);
|
|
35839
|
+
} catch {}
|
|
35840
|
+
}
|
|
35841
|
+
function tryAcquireLockSync(lockPath, payload) {
|
|
35842
|
+
try {
|
|
35843
|
+
fs7.writeFileSync(lockPath, payload, { flag: "wx" });
|
|
35844
|
+
} catch (err) {
|
|
35845
|
+
if (err.code === "EEXIST")
|
|
35846
|
+
return;
|
|
35847
|
+
throw err;
|
|
35848
|
+
}
|
|
35849
|
+
let snapshot;
|
|
35850
|
+
try {
|
|
35851
|
+
snapshot = readLockSnapshot(lockPath);
|
|
35852
|
+
} catch (error2) {
|
|
35853
|
+
releaseLockRaw(lockPath);
|
|
35854
|
+
throw error2;
|
|
35855
|
+
}
|
|
35856
|
+
if (!snapshot) {
|
|
35857
|
+
releaseLockRaw(lockPath);
|
|
35858
|
+
throw new Error(`Could not read newly acquired lock at ${lockPath}.`);
|
|
35859
|
+
}
|
|
35860
|
+
return { lockPath, ...snapshot };
|
|
35861
|
+
}
|
|
35862
|
+
function launcherPidFromEnv() {
|
|
35863
|
+
const raw = process.env.AKM_LAUNCHER_PID;
|
|
35864
|
+
if (!raw)
|
|
35865
|
+
return;
|
|
35866
|
+
const pid = Number.parseInt(raw, 10);
|
|
35867
|
+
return Number.isInteger(pid) && pid > 0 ? pid : undefined;
|
|
35868
|
+
}
|
|
35869
|
+
function createLockPayload(metadata = {}) {
|
|
35870
|
+
const launcherPid = launcherPidFromEnv();
|
|
35871
|
+
return JSON.stringify({
|
|
35872
|
+
...metadata,
|
|
35873
|
+
pid: process.pid,
|
|
35874
|
+
...launcherPid !== undefined ? { launcherPid } : {},
|
|
35875
|
+
lockId: randomUUID()
|
|
35876
|
+
});
|
|
35877
|
+
}
|
|
35878
|
+
function probeLock(lockPath, opts) {
|
|
35879
|
+
let snapshot;
|
|
35880
|
+
try {
|
|
35881
|
+
snapshot = readLockSnapshot(lockPath);
|
|
35882
|
+
} catch (error2) {
|
|
35883
|
+
const code = error2?.code;
|
|
35884
|
+
if (code === "EACCES" || code === "EPERM")
|
|
35885
|
+
return { state: "inaccessible", code };
|
|
35886
|
+
return { state: "stale", reason: "unreadable" };
|
|
35887
|
+
}
|
|
35888
|
+
if (!snapshot)
|
|
35889
|
+
return { state: "absent" };
|
|
35890
|
+
const { rawContent, identity: identity3 } = snapshot;
|
|
35891
|
+
const ageMs = Date.now() - identity3.mtimeMs;
|
|
35892
|
+
const { holderPid, launcherPid } = extractLockIdentity(rawContent);
|
|
35893
|
+
if (holderPid === undefined) {
|
|
35894
|
+
return { state: "stale", reason: "invalid_pid", ageMs, rawContent, identity: identity3 };
|
|
35895
|
+
}
|
|
35896
|
+
if (!isProcessAlive(holderPid)) {
|
|
35897
|
+
return { state: "stale", reason: "pid_dead", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
35898
|
+
}
|
|
35899
|
+
if (opts?.staleAfterMs !== undefined && ageMs > opts.staleAfterMs) {
|
|
35900
|
+
return { state: "stale", reason: "age_exceeded", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
35901
|
+
}
|
|
35902
|
+
return { state: "held", holderPid, launcherPid, ageMs, rawContent, identity: identity3 };
|
|
35903
|
+
}
|
|
35904
|
+
function reclaimStaleLock(lockPath, probe, options) {
|
|
35905
|
+
if (probe.rawContent === undefined || probe.identity === undefined)
|
|
35906
|
+
return false;
|
|
35907
|
+
const expectedContent = probe.rawContent;
|
|
35908
|
+
const expectedIdentity = probe.identity;
|
|
35909
|
+
let current;
|
|
35910
|
+
try {
|
|
35911
|
+
current = readLockSnapshot(lockPath);
|
|
35912
|
+
} catch {
|
|
35913
|
+
return false;
|
|
35914
|
+
}
|
|
35915
|
+
if (!current || current.rawContent !== expectedContent || !sameIdentity(current.identity, expectedIdentity)) {
|
|
35916
|
+
return false;
|
|
35917
|
+
}
|
|
35918
|
+
const quarantinePath = `${lockPath}.stale-${process.pid}-${randomUUID()}`;
|
|
35919
|
+
try {
|
|
35920
|
+
fs7.renameSync(lockPath, quarantinePath);
|
|
35921
|
+
} catch (err) {
|
|
35922
|
+
if (err.code === "ENOENT")
|
|
35923
|
+
return false;
|
|
35924
|
+
throw err;
|
|
35925
|
+
}
|
|
35926
|
+
let quarantined;
|
|
35927
|
+
try {
|
|
35928
|
+
quarantined = readLockSnapshot(quarantinePath);
|
|
35929
|
+
} catch {
|
|
35930
|
+
quarantined = undefined;
|
|
35931
|
+
}
|
|
35932
|
+
if (!quarantined || quarantined.rawContent !== expectedContent || !sameIdentity(quarantined.identity, expectedIdentity)) {
|
|
35933
|
+
try {
|
|
35934
|
+
fs7.linkSync(quarantinePath, lockPath);
|
|
35935
|
+
} catch (err) {
|
|
35936
|
+
if (err.code !== "EEXIST")
|
|
35937
|
+
throw err;
|
|
35938
|
+
}
|
|
35939
|
+
releaseLockRaw(quarantinePath);
|
|
35940
|
+
return false;
|
|
35941
|
+
}
|
|
35942
|
+
options?.afterQuarantineVerified?.();
|
|
35943
|
+
try {
|
|
35944
|
+
fs7.unlinkSync(quarantinePath);
|
|
35945
|
+
return true;
|
|
35946
|
+
} catch (err) {
|
|
35947
|
+
if (err.code === "ENOENT")
|
|
35948
|
+
return false;
|
|
35949
|
+
throw err;
|
|
35950
|
+
}
|
|
35951
|
+
}
|
|
35952
|
+
function releaseLock(ownership) {
|
|
35953
|
+
const { lockPath } = ownership;
|
|
35954
|
+
let current;
|
|
35955
|
+
try {
|
|
35956
|
+
current = readLockSnapshot(lockPath);
|
|
35957
|
+
} catch {
|
|
35958
|
+
return;
|
|
35959
|
+
}
|
|
35960
|
+
if (current && current.rawContent === ownership.rawContent && sameIdentity(current.identity, ownership.identity)) {
|
|
35961
|
+
releaseLockRaw(lockPath);
|
|
35962
|
+
}
|
|
35963
|
+
}
|
|
35964
|
+
function extractLockIdentity(content) {
|
|
35965
|
+
const trimmed = content.trim();
|
|
35966
|
+
if (!trimmed)
|
|
35967
|
+
return {};
|
|
35968
|
+
if (trimmed.startsWith("{")) {
|
|
35969
|
+
try {
|
|
35970
|
+
const parsed = JSON.parse(trimmed);
|
|
35971
|
+
const pid2 = typeof parsed.pid === "number" ? parsed.pid : Number.NaN;
|
|
35972
|
+
const rawLauncherPid = typeof parsed.launcherPid === "number" ? parsed.launcherPid : Number.NaN;
|
|
35973
|
+
return {
|
|
35974
|
+
holderPid: Number.isInteger(pid2) && pid2 > 0 ? pid2 : undefined,
|
|
35975
|
+
launcherPid: Number.isInteger(rawLauncherPid) && rawLauncherPid > 0 ? rawLauncherPid : undefined
|
|
35976
|
+
};
|
|
35977
|
+
} catch {
|
|
35978
|
+
return {};
|
|
36001
35979
|
}
|
|
36002
35980
|
}
|
|
36003
|
-
|
|
36004
|
-
|
|
36005
|
-
|
|
36006
|
-
|
|
36007
|
-
|
|
36008
|
-
|
|
36009
|
-
|
|
36010
|
-
|
|
36011
|
-
|
|
36012
|
-
|
|
36013
|
-
|
|
35981
|
+
const pid = Number.parseInt(trimmed, 10);
|
|
35982
|
+
return { holderPid: Number.isInteger(pid) && pid > 0 ? pid : undefined };
|
|
35983
|
+
}
|
|
35984
|
+
|
|
35985
|
+
// src/core/config/config-io.ts
|
|
35986
|
+
function readConfigText(configPath) {
|
|
35987
|
+
try {
|
|
35988
|
+
return readTextFile(configPath, "Config file");
|
|
35989
|
+
} catch (err) {
|
|
35990
|
+
if (err.code === "ENOENT")
|
|
35991
|
+
return;
|
|
35992
|
+
throw err;
|
|
35993
|
+
}
|
|
35994
|
+
}
|
|
35995
|
+
function parseConfigText(text, sourcePath) {
|
|
35996
|
+
const stripped = stripJsonComments(text);
|
|
35997
|
+
const where = sourcePath ? ` at ${sourcePath}` : "";
|
|
35998
|
+
let parsed;
|
|
35999
|
+
try {
|
|
36000
|
+
parsed = JSON.parse(stripped);
|
|
36001
|
+
} catch (err) {
|
|
36002
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
36003
|
+
throw new ConfigError(`Failed to parse config JSON${where}: ${detail}`, "INVALID_CONFIG_FILE", "Edit the file to fix the JSON syntax error. Comments (// and /* */) are allowed; trailing commas are not.");
|
|
36014
36004
|
}
|
|
36015
|
-
|
|
36016
|
-
|
|
36017
|
-
ctx.addIssue({
|
|
36018
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36019
|
-
path: ["defaults", "engine"],
|
|
36020
|
-
message: "engine does not name a configured engine"
|
|
36021
|
-
});
|
|
36005
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
36006
|
+
throw new ConfigError(`Config file${where} must contain a JSON object at the root, got ${describeJsonRoot(parsed)}.`, "INVALID_CONFIG_FILE");
|
|
36022
36007
|
}
|
|
36023
|
-
|
|
36024
|
-
|
|
36025
|
-
|
|
36026
|
-
|
|
36027
|
-
|
|
36028
|
-
|
|
36029
|
-
|
|
36008
|
+
return parsed;
|
|
36009
|
+
}
|
|
36010
|
+
function describeJsonRoot(value) {
|
|
36011
|
+
if (value === null)
|
|
36012
|
+
return "null";
|
|
36013
|
+
if (Array.isArray(value))
|
|
36014
|
+
return "an array";
|
|
36015
|
+
if (typeof value === "string")
|
|
36016
|
+
return "a string";
|
|
36017
|
+
if (typeof value === "number")
|
|
36018
|
+
return "a number";
|
|
36019
|
+
if (typeof value === "boolean")
|
|
36020
|
+
return "a boolean";
|
|
36021
|
+
return typeof value;
|
|
36022
|
+
}
|
|
36023
|
+
function writeConfigAtomic(configPath, config) {
|
|
36024
|
+
writeFileAtomic(configPath, `${JSON.stringify(config, null, 2)}
|
|
36025
|
+
`);
|
|
36026
|
+
}
|
|
36027
|
+
var MAX_CONFIG_BACKUPS = 5;
|
|
36028
|
+
function backupExistingConfig(configPath, now = new Date) {
|
|
36029
|
+
if (!fs8.existsSync(configPath))
|
|
36030
|
+
return;
|
|
36031
|
+
const backupDir = path12.join(getCacheDir(), "config-backups");
|
|
36032
|
+
fs8.mkdirSync(backupDir, { recursive: true, mode: 448 });
|
|
36033
|
+
fs8.chmodSync(backupDir, 448);
|
|
36034
|
+
const timestamp = now.toISOString().replace(/[.:]/g, "-");
|
|
36035
|
+
let sequence = 0;
|
|
36036
|
+
let timestamped;
|
|
36037
|
+
while (true) {
|
|
36038
|
+
timestamped = path12.join(backupDir, `config-${timestamp}${sequence === 0 ? "" : `-${sequence}`}.json`);
|
|
36039
|
+
try {
|
|
36040
|
+
fs8.copyFileSync(configPath, timestamped, fs8.constants.COPYFILE_EXCL);
|
|
36041
|
+
break;
|
|
36042
|
+
} catch (error2) {
|
|
36043
|
+
if (error2.code !== "EEXIST")
|
|
36044
|
+
throw error2;
|
|
36045
|
+
sequence++;
|
|
36046
|
+
}
|
|
36030
36047
|
}
|
|
36031
|
-
const
|
|
36032
|
-
|
|
36033
|
-
|
|
36034
|
-
|
|
36035
|
-
|
|
36036
|
-
|
|
36037
|
-
|
|
36048
|
+
const latest = path12.join(backupDir, "config.latest.json");
|
|
36049
|
+
fs8.copyFileSync(configPath, latest);
|
|
36050
|
+
fs8.chmodSync(timestamped, 384);
|
|
36051
|
+
fs8.chmodSync(latest, 384);
|
|
36052
|
+
pruneOldBackups(backupDir);
|
|
36053
|
+
return { timestamped, latest };
|
|
36054
|
+
}
|
|
36055
|
+
function pruneOldBackups(backupDir) {
|
|
36056
|
+
pruneToNewest(backupDir, MAX_CONFIG_BACKUPS, (entry) => entry.isFile() && isTimestampedConfigBackup(entry.name));
|
|
36057
|
+
}
|
|
36058
|
+
function isTimestampedConfigBackup(name) {
|
|
36059
|
+
return name.startsWith("config-") && name.endsWith(".json") && name !== "config.latest.json";
|
|
36060
|
+
}
|
|
36061
|
+
function pruneToNewest(dir, keep, select) {
|
|
36062
|
+
let entries;
|
|
36063
|
+
try {
|
|
36064
|
+
entries = fs8.readdirSync(dir, { withFileTypes: true });
|
|
36065
|
+
} catch {
|
|
36066
|
+
return;
|
|
36038
36067
|
}
|
|
36039
|
-
const
|
|
36040
|
-
|
|
36041
|
-
|
|
36042
|
-
|
|
36043
|
-
|
|
36044
|
-
|
|
36045
|
-
}
|
|
36068
|
+
const candidates = entries.filter(select).map((entry) => {
|
|
36069
|
+
const full = path12.join(dir, entry.name);
|
|
36070
|
+
let mtime = 0;
|
|
36071
|
+
try {
|
|
36072
|
+
mtime = fs8.statSync(full).mtimeMs;
|
|
36073
|
+
} catch {}
|
|
36074
|
+
return { path: full, mtime };
|
|
36075
|
+
}).sort((a, b) => b.mtime - a.mtime);
|
|
36076
|
+
for (const stale of candidates.slice(keep)) {
|
|
36077
|
+
try {
|
|
36078
|
+
fs8.rmSync(stale.path, { recursive: true, force: true });
|
|
36079
|
+
} catch {}
|
|
36046
36080
|
}
|
|
36047
|
-
|
|
36048
|
-
|
|
36049
|
-
|
|
36050
|
-
|
|
36051
|
-
|
|
36052
|
-
|
|
36053
|
-
|
|
36054
|
-
|
|
36055
|
-
|
|
36056
|
-
|
|
36081
|
+
}
|
|
36082
|
+
function getConfigLockPath() {
|
|
36083
|
+
return path12.join(getConfigDir(), "config.json.lck");
|
|
36084
|
+
}
|
|
36085
|
+
var CONFIG_LOCK_MAX_RETRIES = 40;
|
|
36086
|
+
var CONFIG_LOCK_RETRY_DELAY_MS = 50;
|
|
36087
|
+
function sleepSyncMs(ms) {
|
|
36088
|
+
sleepSync(ms);
|
|
36089
|
+
}
|
|
36090
|
+
function acquireConfigLock() {
|
|
36091
|
+
const lockPath = getConfigLockPath();
|
|
36092
|
+
try {
|
|
36093
|
+
fs8.mkdirSync(path12.dirname(lockPath), { recursive: true });
|
|
36094
|
+
} catch {}
|
|
36095
|
+
for (let attempt = 0;attempt < CONFIG_LOCK_MAX_RETRIES; attempt++) {
|
|
36096
|
+
try {
|
|
36097
|
+
const ownership = tryAcquireLockSync(lockPath, createLockPayload());
|
|
36098
|
+
if (ownership) {
|
|
36099
|
+
return () => releaseLock(ownership);
|
|
36057
36100
|
}
|
|
36101
|
+
} catch (error2) {
|
|
36102
|
+
throw new ConfigError(`Unable to acquire config lock at ${lockPath}: ${error2 instanceof Error ? error2.message : String(error2)}`, "INVALID_CONFIG_FILE");
|
|
36058
36103
|
}
|
|
36059
|
-
|
|
36060
|
-
|
|
36061
|
-
|
|
36062
|
-
if (processConfig.engine && capability === null) {
|
|
36063
|
-
ctx.addIssue({
|
|
36064
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36065
|
-
path: ["improve", "strategies", strategyName, "processes", processName, "engine"],
|
|
36066
|
-
message: `${processName} does not dispatch an engine`
|
|
36067
|
-
});
|
|
36068
|
-
} else {
|
|
36069
|
-
const processEngine = processConfig.engine ?? strategyEngine;
|
|
36070
|
-
if (processEngine && capability === "llm") {
|
|
36071
|
-
const engine = config.engines?.[processEngine];
|
|
36072
|
-
if (!engine || engine.kind !== "llm") {
|
|
36073
|
-
ctx.addIssue({
|
|
36074
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36075
|
-
path: ["improve", "strategies", strategyName, "processes", processName, "engine"],
|
|
36076
|
-
message: engine ? `${processName} requires an LLM engine` : "engine does not name a configured engine"
|
|
36077
|
-
});
|
|
36078
|
-
}
|
|
36079
|
-
} else if (processConfig.engine && capability === "runner" && !config.engines?.[processConfig.engine]) {
|
|
36080
|
-
ctx.addIssue({
|
|
36081
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36082
|
-
path: ["improve", "strategies", strategyName, "processes", processName, "engine"],
|
|
36083
|
-
message: "engine does not name a configured engine"
|
|
36084
|
-
});
|
|
36085
|
-
}
|
|
36086
|
-
}
|
|
36087
|
-
const judgmentEngine = processConfig.judgment?.engine;
|
|
36088
|
-
if (processConfig.judgment?.enabled === true && judgmentEngine) {
|
|
36089
|
-
const engine = config.engines?.[judgmentEngine];
|
|
36090
|
-
if (!engine) {
|
|
36091
|
-
ctx.addIssue({
|
|
36092
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36093
|
-
path: ["improve", "strategies", strategyName, "processes", processName, "judgment", "engine"],
|
|
36094
|
-
message: "engine does not name a configured engine"
|
|
36095
|
-
});
|
|
36096
|
-
}
|
|
36097
|
-
}
|
|
36104
|
+
const probe = probeLock(lockPath);
|
|
36105
|
+
if (probe.state === "stale" && reclaimStaleLock(lockPath, probe)) {
|
|
36106
|
+
continue;
|
|
36098
36107
|
}
|
|
36099
|
-
|
|
36100
|
-
|
|
36101
|
-
const knownNames = Object.keys(config.bundles ?? {});
|
|
36102
|
-
if (knownNames.length === 0) {
|
|
36103
|
-
ctx.addIssue({
|
|
36104
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36105
|
-
path: ["defaultWriteTarget"],
|
|
36106
|
-
message: `defaultWriteTarget "${config.defaultWriteTarget}" cannot be resolved: no bundles configured. ` + "Add at least one entry to `bundles` first."
|
|
36107
|
-
});
|
|
36108
|
-
} else if (!knownNames.includes(config.defaultWriteTarget)) {
|
|
36109
|
-
ctx.addIssue({
|
|
36110
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36111
|
-
path: ["defaultWriteTarget"],
|
|
36112
|
-
message: `defaultWriteTarget "${config.defaultWriteTarget}" does not match any configured bundle: ${knownNames.map((n) => `"${n}"`).join(", ")}.`
|
|
36113
|
-
});
|
|
36108
|
+
if (attempt < CONFIG_LOCK_MAX_RETRIES - 1) {
|
|
36109
|
+
sleepSyncMs(CONFIG_LOCK_RETRY_DELAY_MS);
|
|
36114
36110
|
}
|
|
36115
36111
|
}
|
|
36116
|
-
});
|
|
36112
|
+
throw new ConfigError(`Timed out waiting for config lock at ${lockPath}. Another AKM process may be updating config.`, "INVALID_CONFIG_FILE");
|
|
36113
|
+
}
|
|
36114
|
+
function withConfigLock(fn) {
|
|
36115
|
+
const release = acquireConfigLock();
|
|
36116
|
+
try {
|
|
36117
|
+
return fn();
|
|
36118
|
+
} finally {
|
|
36119
|
+
release();
|
|
36120
|
+
}
|
|
36121
|
+
}
|
|
36117
36122
|
|
|
36118
36123
|
// src/core/config/config-sources.ts
|
|
36119
36124
|
import { createHash } from "crypto";
|
|
@@ -36248,41 +36253,6 @@ function normalizeInstalledGitRef(source, ref) {
|
|
|
36248
36253
|
return requestedRef ? `${cloneUrl}/tree/${requestedRef}` : cloneUrl;
|
|
36249
36254
|
}
|
|
36250
36255
|
|
|
36251
|
-
// src/core/config/deep-merge.ts
|
|
36252
|
-
var UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
36253
|
-
function isPlainObject(value) {
|
|
36254
|
-
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
36255
|
-
return false;
|
|
36256
|
-
const prototype = Object.getPrototypeOf(value);
|
|
36257
|
-
return prototype === Object.prototype || prototype === null;
|
|
36258
|
-
}
|
|
36259
|
-
function copyConfigValue(value) {
|
|
36260
|
-
if (Array.isArray(value))
|
|
36261
|
-
return value.map(copyConfigValue);
|
|
36262
|
-
if (!isPlainObject(value))
|
|
36263
|
-
return value;
|
|
36264
|
-
const copy = {};
|
|
36265
|
-
for (const key of Object.keys(value)) {
|
|
36266
|
-
if (UNSAFE_KEYS.has(key))
|
|
36267
|
-
throw new TypeError(`Unsafe configuration key: ${key}`);
|
|
36268
|
-
copy[key] = copyConfigValue(value[key]);
|
|
36269
|
-
}
|
|
36270
|
-
return copy;
|
|
36271
|
-
}
|
|
36272
|
-
function deepMergeConfig(base, override) {
|
|
36273
|
-
const result = copyConfigValue(base);
|
|
36274
|
-
for (const key of Object.keys(override)) {
|
|
36275
|
-
if (UNSAFE_KEYS.has(key))
|
|
36276
|
-
throw new TypeError(`Unsafe configuration key: ${key}`);
|
|
36277
|
-
const next = override[key];
|
|
36278
|
-
if (next === undefined)
|
|
36279
|
-
continue;
|
|
36280
|
-
const current = result[key];
|
|
36281
|
-
result[key] = isPlainObject(current) && isPlainObject(next) ? deepMergeConfig(current, next) : copyConfigValue(next);
|
|
36282
|
-
}
|
|
36283
|
-
return result;
|
|
36284
|
-
}
|
|
36285
|
-
|
|
36286
36256
|
// src/core/config/config-walker.ts
|
|
36287
36257
|
function unwrap(schema) {
|
|
36288
36258
|
let current = schema;
|
|
@@ -36531,11 +36501,12 @@ ${lines}`, "INVALID_CONFIG_FILE");
|
|
|
36531
36501
|
assertUniquePhysicalBundleRoots(finalResult.data, sourcePath);
|
|
36532
36502
|
return finalResult.data;
|
|
36533
36503
|
}
|
|
36504
|
+
var RETIRED_CATCHALL_KEY_PATHS = new Set(["index.graph", "index.metadataEnhance"]);
|
|
36534
36505
|
function unknownConfigKeyPaths(root, node = root, prefix = []) {
|
|
36535
36506
|
const found = [];
|
|
36536
36507
|
for (const key of Object.keys(node).sort()) {
|
|
36537
36508
|
const keyPath = [...prefix, key];
|
|
36538
|
-
if (resolveSchemaAt(keyPath, root) === undefined) {
|
|
36509
|
+
if (RETIRED_CATCHALL_KEY_PATHS.has(keyPath.join(".")) || resolveSchemaAt(keyPath, root) === undefined) {
|
|
36539
36510
|
found.push(keyPath);
|
|
36540
36511
|
continue;
|
|
36541
36512
|
}
|
|
@@ -36826,6 +36797,9 @@ function normalizeConfigFile(configPath, options) {
|
|
|
36826
36797
|
const body = withSchedulerOnDisk(configWriteBody(localRaw, current, next), next);
|
|
36827
36798
|
for (const keyPath of unknownConfigKeyPaths(body))
|
|
36828
36799
|
deleteConfigPath(body, keyPath);
|
|
36800
|
+
const strategies = body.improve?.strategies;
|
|
36801
|
+
if (strategies && Object.hasOwn(strategies, "graph-refresh"))
|
|
36802
|
+
delete strategies["graph-refresh"];
|
|
36829
36803
|
const keys = [...new Set([...Object.keys(raw), ...Object.keys(body)])].filter((key) => JSON.stringify(raw[key]) !== JSON.stringify(body[key])).sort();
|
|
36830
36804
|
if (keys.length === 0 || !options.apply)
|
|
36831
36805
|
return { keys, changed: keys.length > 0, applied: false };
|
|
@@ -36900,7 +36874,6 @@ function resolveSecret(value, resolveFromStore) {
|
|
|
36900
36874
|
return resolved ?? "";
|
|
36901
36875
|
});
|
|
36902
36876
|
}
|
|
36903
|
-
var INDEX_RESERVED_KEYS = new Set(["metadataEnhance"]);
|
|
36904
36877
|
|
|
36905
36878
|
// src/core/redaction.ts
|
|
36906
36879
|
var ENV_PASSTHROUGH_REDACTION_POLICY = {
|
|
@@ -52772,6 +52745,7 @@ var LEDGER_HARD_OUTCOMES = new Set([
|
|
|
52772
52745
|
"quality_rejected",
|
|
52773
52746
|
"expired"
|
|
52774
52747
|
]);
|
|
52748
|
+
var hasContentHashColumnCache = new WeakMap;
|
|
52775
52749
|
|
|
52776
52750
|
// src/commands/improve/improve-strategies.ts
|
|
52777
52751
|
var REF_SCOPED_PROCESSES = new Set(["reflect", "distill", "consolidate"]);
|
|
@@ -52779,7 +52753,6 @@ var BUILTIN_STRATEGIES = {
|
|
|
52779
52753
|
default: default_default,
|
|
52780
52754
|
quick: quick_default,
|
|
52781
52755
|
thorough: thorough_default,
|
|
52782
|
-
"graph-refresh": graph_refresh_default,
|
|
52783
52756
|
consolidate: consolidate_default,
|
|
52784
52757
|
catchup: catchup_default,
|
|
52785
52758
|
"reflect-distill": reflect_distill_default,
|