@bridge_gpt/mcp-server 0.2.70 → 0.2.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -17
- package/build/agent-launchers/claude-executor-adapter.js +29 -4
- package/build/agent-notes.js +171 -95
- package/build/agent-registry.js +5 -5
- package/build/agents.generated.js +12 -2
- package/build/bounded-wait.js +9 -1
- package/build/bridge-permissions.js +17 -5
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -0
- package/build/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-skill-adapter.js +2 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +776 -23
- package/build/conductor/command-drift-production.js +7 -2
- package/build/conductor/doctor.js +93 -13
- package/build/conductor/epic-implementer-cli.js +55 -2
- package/build/conductor/gate-discovery.js +659 -19
- package/build/conductor/gate-settings-review.js +751 -0
- package/build/conductor/git-hooks-uninstall.js +112 -0
- package/build/conductor/git-hooks.js +81 -15
- package/build/conductor/guided-repair.js +10 -1
- package/build/conductor/install-doctor.js +2 -4
- package/build/conductor/launch-need-probes.js +16 -11
- package/build/conductor/launch-plan.js +185 -0
- package/build/conductor/local-merge.js +12 -1
- package/build/conductor/merge-execution-contract.js +1 -1
- package/build/conductor/merged-child-check.js +2 -1
- package/build/conductor/precheck-timings.js +14 -0
- package/build/conductor/prerequisite-inputs.js +379 -0
- package/build/conductor/preview-observations.js +10 -0
- package/build/conductor/readiness-assessment.js +78 -0
- package/build/conductor/readiness-cli.js +10 -0
- package/build/conductor/readiness-prerequisites.js +53 -0
- package/build/conductor/readiness-sections.js +25 -9
- package/build/conductor/readiness.js +20 -2
- package/build/conductor/recovery-cli.js +281 -14
- package/build/conductor/recovery-operations.js +78 -5
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +34 -3
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +96 -3
- package/build/conductor/worker-database-doctor-inspector.js +1 -0
- package/build/credential-store.js +25 -20
- package/build/dependency-install-declarations.js +157 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +37 -5
- package/build/drive-epic-help.js +2 -2
- package/build/drive-epic.js +240 -56
- package/build/epic-ci-workflow-drift.js +71 -23
- package/build/epic-ci-workflow-install.js +83 -26
- package/build/epic-ci-workflow-v1.js +132 -0
- package/build/epic-ci-workflow.js +174 -13
- package/build/epic-implementer-bin.js +119 -44
- package/build/epic-launch-profile.js +1 -1
- package/build/executor/ci-rerun-job.js +220 -14
- package/build/executor/cli.js +2 -0
- package/build/executor/completion-contract.js +16 -0
- package/build/executor/credentials.js +1 -1
- package/build/executor/delivery-observations.js +113 -0
- package/build/executor/delivery-outcome.js +30 -0
- package/build/executor/dependency-refresh-runner.js +132 -0
- package/build/executor/dependency-refresh.js +530 -0
- package/build/executor/deps.js +4 -0
- package/build/executor/env.js +274 -5
- package/build/executor/gate-qualification-job.js +20 -5
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +35 -1
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +355 -36
- package/build/executor/likely-tests.js +100 -98
- package/build/executor/preflight.js +5 -0
- package/build/executor/process-containment.js +18 -0
- package/build/executor/prompt-spec.js +84 -15
- package/build/executor/reconcile-overlap-job.js +6 -1
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +30 -0
- package/build/executor/required-work-ledger.js +19 -1
- package/build/executor/results.js +42 -0
- package/build/executor/service-discovery.js +42 -0
- package/build/executor/service-lifecycle.js +109 -2
- package/build/executor/service-uninstall.js +205 -0
- package/build/executor/service-unit.js +5 -3
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +188 -1
- package/build/executor/worker-database.js +299 -40
- package/build/executor/worker-finalization.js +65 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +12 -1
- package/build/executor/worker-verification-guidance.js +64 -0
- package/build/executor/worktree-inspection.js +42 -0
- package/build/github-sign-in.js +1 -1
- package/build/index.js +767 -310
- package/build/init.js +3 -3
- package/build/install-bridge-conductor-gate.js +416 -41
- package/build/install-bridge-conductor-setup.js +135 -32
- package/build/install-bridge-conductor.js +769 -353
- package/build/install-bridge.js +419 -124
- package/build/install-maintenance.js +104 -0
- package/build/install-reexec.js +1 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-install-state.js +68 -2
- package/build/merge-workflow-install.js +22 -2
- package/build/package-script-semantics.js +10 -0
- package/build/pipeline-utils.js +1 -1
- package/build/pipelines.generated.js +6 -6
- package/build/plan-execution-ledger.js +171 -10
- package/build/plane/plane-freshness.js +12 -9
- package/build/plane/preflight.js +19 -0
- package/build/plane/terminal-run-cleanup.js +5 -1
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +31 -4
- package/build/readiness-check.js +1 -78
- package/build/readiness-prerequisites.generated.js +199 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +623 -0
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +26 -9
- package/build/setup-question.js +62 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +61 -80
- package/build/test-support/notes-fs.js +40 -0
- package/build/ticket-delivery-artifacts.js +7 -0
- package/build/ticket-delivery-enrollment.js +80 -4
- package/build/ticket-delivery-run-scope.js +128 -0
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER.md +43 -0
- package/docs/epic-implementer/getting-started.md +95 -14
- package/package.json +2 -2
|
@@ -1054,8 +1054,12 @@ export async function promoteBootstrapPendingCredential(params, deps) {
|
|
|
1054
1054
|
error: `No pending bootstrap-invite credential for ${getBootstrapPendingTarget(repoName)} in ${primaryPath}.`,
|
|
1055
1055
|
};
|
|
1056
1056
|
}
|
|
1057
|
+
if (Object.prototype.hasOwnProperty.call(params, "observedKey") &&
|
|
1058
|
+
(typeof base[target]?.BAPI_API_KEY === "string" ? base[target].BAPI_API_KEY : null) !== params.observedKey) {
|
|
1059
|
+
return { ok: false, path: primaryPath, target, kind: "credential-conflict", error: "Credential changed since the replacement decision; replay proof preserved." };
|
|
1060
|
+
}
|
|
1057
1061
|
const hadKey = hasExistingBapiKey(base, repoName);
|
|
1058
|
-
if (hadKey && !params.allowOverwriteExistingCredential) {
|
|
1062
|
+
if (hadKey && base[target]?.BAPI_API_KEY !== pending.keySecret && !params.allowOverwriteExistingCredential) {
|
|
1059
1063
|
return {
|
|
1060
1064
|
ok: false,
|
|
1061
1065
|
path: primaryPath,
|
|
@@ -1068,6 +1072,8 @@ export async function promoteBootstrapPendingCredential(params, deps) {
|
|
|
1068
1072
|
delete next[getBootstrapPendingTarget(repoName)];
|
|
1069
1073
|
// Preserve sibling secret names under bapi:<repo>; replace ONLY BAPI_API_KEY.
|
|
1070
1074
|
next[target] = { ...(base[target] ?? {}), BAPI_API_KEY: pending.keySecret };
|
|
1075
|
+
if (base[target]?.BAPI_API_KEY !== pending.keySecret)
|
|
1076
|
+
delete next[target].BAPI_EPIC_LAUNCH_BOUND_BASE_URL;
|
|
1071
1077
|
const written = await durablyReplaceCredentialStoreJson(primaryPath, next, deps);
|
|
1072
1078
|
if (!written.ok) {
|
|
1073
1079
|
return { ok: false, path: primaryPath, target, kind: written.kind, error: written.error };
|
|
@@ -1308,22 +1314,10 @@ export async function discardBootstrapPendingCredential(params, deps) {
|
|
|
1308
1314
|
return { ok: true, path: primaryPath, target };
|
|
1309
1315
|
}, (error) => ({ ok: false, path: primaryPath, target, kind: "lock-error", error }));
|
|
1310
1316
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
* - Always targets {@link getPrimaryCredentialStorePath}; never writes the
|
|
1316
|
-
* fallback path and never touches project/worktree config.
|
|
1317
|
-
* - Preserves every existing top-level entry and every sibling secret under
|
|
1318
|
-
* `bapi:<repoName>`; replaces only `BAPI_API_KEY`.
|
|
1319
|
-
* - On a first primary write, seeds from the legacy fallback store so its
|
|
1320
|
-
* entries are not shadowed (`migratedFallback: true`).
|
|
1321
|
-
* - POSIX: writes mode `0600` and `chmod`s the temp file before rename.
|
|
1322
|
-
* `win32`: skips chmod and relies on user-profile ACLs.
|
|
1323
|
-
* - Returns a structured, secret-free result. The `apiKey` value never appears
|
|
1324
|
-
* in any returned error, even if an underlying I/O error message contains it.
|
|
1325
|
-
*/
|
|
1326
|
-
export async function upsertBapiCredential(repoName, apiKey, deps) {
|
|
1317
|
+
function observationChanged(options, actual) {
|
|
1318
|
+
return Object.prototype.hasOwnProperty.call(options, "observedKey") && options.observedKey !== (actual ?? null);
|
|
1319
|
+
}
|
|
1320
|
+
export async function upsertBapiCredential(repoName, apiKey, deps, options = {}) {
|
|
1327
1321
|
const primaryPath = getPrimaryCredentialStorePath(deps);
|
|
1328
1322
|
const trimmedRepo = (repoName ?? "").trim();
|
|
1329
1323
|
const trimmedKey = (apiKey ?? "").trim();
|
|
@@ -1369,6 +1363,12 @@ export async function upsertBapiCredential(repoName, apiKey, deps) {
|
|
|
1369
1363
|
migratedFallback = seeded.migratedFallback;
|
|
1370
1364
|
}
|
|
1371
1365
|
const existingEntry = base[target];
|
|
1366
|
+
const actualKey = existingEntry?.BAPI_API_KEY?.trim() || undefined;
|
|
1367
|
+
if (observationChanged(options, actualKey))
|
|
1368
|
+
return { ok: false, path: primaryPath, target,
|
|
1369
|
+
kind: "changed-since-decision", error: "Saved credential changed since the decision. Re-evaluate before writing." };
|
|
1370
|
+
if (actualKey === trimmedKey)
|
|
1371
|
+
return { ok: true, path: primaryPath, target, action: "unchanged", migratedFallback: false };
|
|
1372
1372
|
const hadKey = !!existingEntry &&
|
|
1373
1373
|
typeof existingEntry.BAPI_API_KEY === "string" &&
|
|
1374
1374
|
existingEntry.BAPI_API_KEY.length > 0;
|
|
@@ -1504,7 +1504,7 @@ export async function resolveEpicLaunchCredential(repoName, targetBaseUrl, deps,
|
|
|
1504
1504
|
kind: "binding-unbound",
|
|
1505
1505
|
error: `The stored credential "${diagnosticComponent(bundleKey)}" has not been approved for this Bridge API endpoint ` +
|
|
1506
1506
|
`(${diagnosticComponent(primaryPath)}). Production needs no approval; any other endpoint does. Run guided setup ` +
|
|
1507
|
-
`once to bind it: install
|
|
1507
|
+
`once to bind it: install epic-implementer --launch-profile <name> --base-url ${diagnosticComponent(target)}.`,
|
|
1508
1508
|
};
|
|
1509
1509
|
}
|
|
1510
1510
|
// An unreadable read-back is refused like a mismatch: the key was read a
|
|
@@ -1516,7 +1516,7 @@ export async function resolveEpicLaunchCredential(repoName, targetBaseUrl, deps,
|
|
|
1516
1516
|
error: `The stored credential "${diagnosticComponent(bundleKey)}" is approved for a different Bridge API endpoint than the ` +
|
|
1517
1517
|
"selected target. It was not sent. A key approved for a local server is never sent to " +
|
|
1518
1518
|
"production: pass that server's --launch-profile <name> or --base-url <url>, or bind the key " +
|
|
1519
|
-
"once with install
|
|
1519
|
+
"once with install epic-implementer --launch-profile <name> --base-url <url>.",
|
|
1520
1520
|
};
|
|
1521
1521
|
}
|
|
1522
1522
|
return { ok: true, apiKey: stored.values.BAPI_API_KEY, source: "file", binding: "store-bound" };
|
|
@@ -1573,7 +1573,7 @@ export async function readStoredBinding(bundleKey, deps) {
|
|
|
1573
1573
|
* durable replacement; every other entry and sibling field is preserved. A store
|
|
1574
1574
|
* with no key for the repository is refused rather than creating one.
|
|
1575
1575
|
*/
|
|
1576
|
-
export async function bindEpicLaunchCredential(repoName, targetBaseUrl, deps) {
|
|
1576
|
+
export async function bindEpicLaunchCredential(repoName, targetBaseUrl, deps, options = {}) {
|
|
1577
1577
|
const target = `bapi:${repoName.trim()}`;
|
|
1578
1578
|
const baseUrl = normalizeBoundBaseUrl(targetBaseUrl);
|
|
1579
1579
|
if (repoName.trim().length === 0 || baseUrl === null) {
|
|
@@ -1594,6 +1594,9 @@ export async function bindEpicLaunchCredential(repoName, targetBaseUrl, deps) {
|
|
|
1594
1594
|
error: `No stored BAPI_API_KEY under "${target}" in ${primaryPath} to bind.`,
|
|
1595
1595
|
};
|
|
1596
1596
|
}
|
|
1597
|
+
if (observationChanged(options, entry.BAPI_API_KEY.trim()))
|
|
1598
|
+
return { ok: false, target,
|
|
1599
|
+
kind: "changed-since-decision", error: "Saved credential changed since endpoint authorization. Re-evaluate before binding." };
|
|
1597
1600
|
const previous = normalizeBoundBaseUrl(entry[BAPI_EPIC_LAUNCH_BOUND_BASE_URL_FIELD]);
|
|
1598
1601
|
if (previous === baseUrl)
|
|
1599
1602
|
return { ok: true, target, action: "unchanged", path: primaryPath };
|
|
@@ -1913,6 +1916,8 @@ export async function promoteModernBootstrapCredential(scope, proof, deps, allow
|
|
|
1913
1916
|
return { ok: true, path: getPrimaryCredentialStorePath(deps) };
|
|
1914
1917
|
if (!record || record.keySecret !== proof.keySecret || record.canonical !== proof.canonical || record.fingerprint !== proof.fingerprint || record.folder !== scope.folder || record.baseUrl !== scope.baseUrl || reference?.LOCATOR !== scope.locator || reference.FOLDER !== scope.folder || reference.BASE_URL !== scope.baseUrl)
|
|
1915
1918
|
throw new Error(modernRecoveryError);
|
|
1919
|
+
if (consentedKey !== undefined && (existingKey ?? null) !== consentedKey)
|
|
1920
|
+
return { ok: false, error: "Destination credential changed after the decision. Replay proof preserved." };
|
|
1916
1921
|
if (existingKey && existingKey !== proof.keySecret) {
|
|
1917
1922
|
if (!allowOverwrite)
|
|
1918
1923
|
return { ok: false, error: "The canonical credential already exists; overwrite consent is required.", needsConsent: true, observedKey: existingKey };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1551 — the TypeScript copy of the `dependency_install` and `ci_database`
|
|
3
|
+
* gate-profile declaration rules.
|
|
4
|
+
*
|
|
5
|
+
* `api/library/epic_implementer/gate_profile.py` (`validate_dependency_install`,
|
|
6
|
+
* `validate_ci_database`) is the authority; this module mirrors its bounds so the
|
|
7
|
+
* Bridge API client can parse a stored profile fail-closed and the executor can
|
|
8
|
+
* re-check a job payload without trusting it.
|
|
9
|
+
*
|
|
10
|
+
* Two consumers, two postures:
|
|
11
|
+
*
|
|
12
|
+
* - {@link parseDependencyInstallStrict} — the client. Any invalid entry makes the
|
|
13
|
+
* whole list unreadable (`null`), like any other malformed profile member.
|
|
14
|
+
* - {@link admitDependencyInstallDeclarations} — the executor. Never throws: a bad
|
|
15
|
+
* entry is skipped with a closed reason and the rest still apply.
|
|
16
|
+
*
|
|
17
|
+
* Nothing here logs, and nothing returned for a refusal carries an argv item. A
|
|
18
|
+
* `cwd` is returned beside a refusal only after it passed the path rules, so it
|
|
19
|
+
* is safe to print.
|
|
20
|
+
*
|
|
21
|
+
* Identity: two entries are duplicates when they share the canonical
|
|
22
|
+
* `(cwd, sorted lockfiles)` pair. A JavaScript and a Python toolchain at the same
|
|
23
|
+
* root are two distinct entries.
|
|
24
|
+
*/
|
|
25
|
+
export const MAX_DEPENDENCY_INSTALL_ENTRIES = 8;
|
|
26
|
+
export const MAX_DEPENDENCY_INSTALL_ARGV_ITEMS = 32;
|
|
27
|
+
export const MAX_DEPENDENCY_INSTALL_ARG_CHARS = 1024;
|
|
28
|
+
export const MAX_DEPENDENCY_INSTALL_LOCKFILES = 8;
|
|
29
|
+
/** The longest repository-relative path a declaration may name. */
|
|
30
|
+
export const MAX_DEPENDENCY_INSTALL_PATH_CHARS = 512;
|
|
31
|
+
export const CI_DATABASE_VALUES = ["none", "provided", "unknown"];
|
|
32
|
+
export const CI_DATABASE_DEFAULT = "unknown";
|
|
33
|
+
const ENTRY_KEYS = new Set(["cwd", "argv", "lockfiles"]);
|
|
34
|
+
/** Absolute-looking, backslash, colon, and every control or line-separator character. */
|
|
35
|
+
const FORBIDDEN_PATH_CHARS = /[:\\\x00-\x1f\x7f-\x9f\u2028\u2029]/;
|
|
36
|
+
const FORBIDDEN_ARG_CHARS = /[\u0000\r\n]/;
|
|
37
|
+
/**
|
|
38
|
+
* True when `value` is a safe repository-relative path: not absolute, no `..`,
|
|
39
|
+
* no `.` segment, no empty segment, no backslash, colon, or control character.
|
|
40
|
+
* `allowRoot` admits the lone `"."` (the repository root) for a `cwd`.
|
|
41
|
+
*/
|
|
42
|
+
export function isSafeRepoRelativePath(value, options = {}) {
|
|
43
|
+
if (typeof value !== "string" || value.length === 0 || value.length > MAX_DEPENDENCY_INSTALL_PATH_CHARS) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (value === ".")
|
|
47
|
+
return options.allowRoot === true;
|
|
48
|
+
if (value.startsWith("/") || FORBIDDEN_PATH_CHARS.test(value))
|
|
49
|
+
return false;
|
|
50
|
+
return value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
51
|
+
}
|
|
52
|
+
/** The canonical identity of an entry: its `cwd` and its lockfiles, sorted. */
|
|
53
|
+
export function dependencyInstallEntryIdentity(entry) {
|
|
54
|
+
return JSON.stringify([entry.cwd, [...entry.lockfiles].sort()]);
|
|
55
|
+
}
|
|
56
|
+
/** Check one raw entry against every rule except list bounds and duplicates. */
|
|
57
|
+
export function checkDependencyInstallEntry(raw) {
|
|
58
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
59
|
+
return { ok: false, reason: "dependency_install_invalid_entry" };
|
|
60
|
+
}
|
|
61
|
+
const item = raw;
|
|
62
|
+
for (const key of Object.keys(item)) {
|
|
63
|
+
if (!ENTRY_KEYS.has(key))
|
|
64
|
+
return { ok: false, reason: "dependency_install_invalid_entry" };
|
|
65
|
+
}
|
|
66
|
+
const { cwd, argv, lockfiles } = item;
|
|
67
|
+
if (typeof cwd !== "string")
|
|
68
|
+
return { ok: false, reason: "dependency_install_invalid_entry" };
|
|
69
|
+
if (!isSafeRepoRelativePath(cwd, { allowRoot: true })) {
|
|
70
|
+
return { ok: false, reason: "dependency_install_invalid_path" };
|
|
71
|
+
}
|
|
72
|
+
if (!Array.isArray(argv) || !Array.isArray(lockfiles)) {
|
|
73
|
+
return { ok: false, reason: "dependency_install_invalid_entry", cwd };
|
|
74
|
+
}
|
|
75
|
+
if (argv.length === 0 || lockfiles.length === 0) {
|
|
76
|
+
return { ok: false, reason: "dependency_install_invalid_entry", cwd };
|
|
77
|
+
}
|
|
78
|
+
if (argv.length > MAX_DEPENDENCY_INSTALL_ARGV_ITEMS || lockfiles.length > MAX_DEPENDENCY_INSTALL_LOCKFILES) {
|
|
79
|
+
return { ok: false, reason: "dependency_install_over_bound", cwd };
|
|
80
|
+
}
|
|
81
|
+
for (const arg of argv) {
|
|
82
|
+
if (typeof arg !== "string" || arg.length === 0 || FORBIDDEN_ARG_CHARS.test(arg)) {
|
|
83
|
+
return { ok: false, reason: "dependency_install_invalid_entry", cwd };
|
|
84
|
+
}
|
|
85
|
+
if (arg.length > MAX_DEPENDENCY_INSTALL_ARG_CHARS) {
|
|
86
|
+
return { ok: false, reason: "dependency_install_over_bound", cwd };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const seenLockfiles = new Set();
|
|
90
|
+
for (const file of lockfiles) {
|
|
91
|
+
if (!isSafeRepoRelativePath(file))
|
|
92
|
+
return { ok: false, reason: "dependency_install_invalid_path", cwd };
|
|
93
|
+
if (seenLockfiles.has(file))
|
|
94
|
+
return { ok: false, reason: "dependency_install_duplicate", cwd };
|
|
95
|
+
seenLockfiles.add(file);
|
|
96
|
+
}
|
|
97
|
+
return { ok: true, entry: { cwd, argv: [...argv], lockfiles: [...lockfiles] } };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The executor's never-throwing admission: re-check every server bound and skip
|
|
101
|
+
* a bad entry with a closed reason. The first occurrence of an identity wins.
|
|
102
|
+
*/
|
|
103
|
+
export function admitDependencyInstallDeclarations(raw) {
|
|
104
|
+
if (!Array.isArray(raw))
|
|
105
|
+
return { entries: [], skipped: [], notAList: true };
|
|
106
|
+
const entries = [];
|
|
107
|
+
const skipped = [];
|
|
108
|
+
const seen = new Set();
|
|
109
|
+
for (let index = 0; index < raw.length; index++) {
|
|
110
|
+
if (index >= MAX_DEPENDENCY_INSTALL_ENTRIES) {
|
|
111
|
+
skipped.push({ reason: "dependency_install_over_bound" });
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
const checked = checkDependencyInstallEntry(raw[index]);
|
|
115
|
+
if (!checked.ok) {
|
|
116
|
+
skipped.push({ reason: checked.reason, ...(checked.cwd !== undefined ? { cwd: checked.cwd } : {}) });
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const identity = dependencyInstallEntryIdentity(checked.entry);
|
|
120
|
+
if (seen.has(identity)) {
|
|
121
|
+
skipped.push({ reason: "dependency_install_duplicate", cwd: checked.entry.cwd });
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
seen.add(identity);
|
|
125
|
+
entries.push(checked.entry);
|
|
126
|
+
}
|
|
127
|
+
return { entries, skipped, notAList: false };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The client's fail-closed parse: the whole list or `null`. `undefined` (an
|
|
131
|
+
* absent field) reads as no declarations.
|
|
132
|
+
*/
|
|
133
|
+
export function parseDependencyInstallStrict(raw) {
|
|
134
|
+
if (raw === undefined)
|
|
135
|
+
return [];
|
|
136
|
+
if (!Array.isArray(raw) || raw.length > MAX_DEPENDENCY_INSTALL_ENTRIES)
|
|
137
|
+
return null;
|
|
138
|
+
const admitted = admitDependencyInstallDeclarations(raw);
|
|
139
|
+
if (admitted.notAList || admitted.skipped.length > 0)
|
|
140
|
+
return null;
|
|
141
|
+
return admitted.entries;
|
|
142
|
+
}
|
|
143
|
+
/** True when `value` is one of the three `ci_database` values. */
|
|
144
|
+
export function isCiDatabase(value) {
|
|
145
|
+
return typeof value === "string" && CI_DATABASE_VALUES.includes(value);
|
|
146
|
+
}
|
|
147
|
+
/** Any value other than the three reads as `unknown`. */
|
|
148
|
+
export function normalizeCiDatabase(value) {
|
|
149
|
+
return isCiDatabase(value) ? value : CI_DATABASE_DEFAULT;
|
|
150
|
+
}
|
|
151
|
+
/** True when two declaration lists are the same, entry for entry and in order. */
|
|
152
|
+
export function sameDependencyInstall(a, b) {
|
|
153
|
+
return JSON.stringify(a.map(canonicalEntry)) === JSON.stringify(b.map(canonicalEntry));
|
|
154
|
+
}
|
|
155
|
+
function canonicalEntry(entry) {
|
|
156
|
+
return { cwd: entry.cwd, argv: [...entry.argv], lockfiles: [...entry.lockfiles] };
|
|
157
|
+
}
|