@bridge_gpt/mcp-server 0.2.72 → 0.2.74
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 +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +15 -0
- package/build/agents.generated.js +6 -6
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +30 -0
- package/build/ci-system-detection.js +50 -0
- package/build/ci-trigger-adapters.js +631 -0
- package/build/ci-trigger-install.js +106 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +3 -1
- package/build/command-host.js +33 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +867 -35
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +48 -1
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +108 -21
- package/build/conductor/driver-commands.js +141 -0
- package/build/conductor/driver-guard.js +277 -0
- package/build/conductor/driver-lapse.js +321 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/driver-register.js +176 -0
- package/build/conductor/driver-release.js +174 -0
- package/build/conductor/driver-session-state.js +315 -0
- package/build/conductor/epic-branch-ci-inspection.js +281 -43
- package/build/conductor/epic-implementer-cli.js +199 -15
- package/build/conductor/epic-server-database.js +162 -0
- package/build/conductor/epic-server-guidance.js +278 -0
- package/build/conductor/epic-server-journal.js +239 -0
- package/build/conductor/epic-server-processes.js +324 -0
- package/build/conductor/epic-server-recipe.js +397 -0
- package/build/conductor/epic-server-runtime.js +1207 -0
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +85 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +647 -0
- package/build/conductor/gate-discovery.js +196 -11
- package/build/conductor/gate-settings-review.js +261 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +313 -156
- package/build/conductor/prerequisite-inputs.js +879 -45
- package/build/conductor/readiness-assessment.js +16 -1
- package/build/conductor/readiness-cli.js +20 -9
- package/build/conductor/readiness-prerequisites.js +28 -9
- package/build/conductor/readiness-sections.js +133 -126
- package/build/conductor/readiness.js +1 -1
- package/build/conductor/recovery-cli.js +13 -2
- package/build/conductor/tools.js +6 -5
- package/build/conductor/wait-run-attention.js +2 -2
- package/build/conductor/wait-run-cli.js +208 -22
- package/build/conductor/worker-database-doctor-inspector.js +33 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- package/build/credential-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +121 -1
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +102 -1
- package/build/docs.generated.js +10 -3
- package/build/doctor.js +95 -3
- package/build/drive-epic-help.js +21 -2
- package/build/drive-epic.js +2095 -375
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +157 -0
- package/build/epic-capability-statement.js +175 -0
- package/build/epic-ci-workflow-drift.js +77 -23
- package/build/epic-ci-workflow-install.js +137 -44
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +165 -18
- package/build/epic-implementer-bin.js +2204 -56
- package/build/epic-launch-context.js +702 -0
- package/build/epic-server-record.js +288 -0
- package/build/epic-shared/bridge-client.js +11 -3
- package/build/escalation-reachability.js +43 -0
- package/build/executor/ci-fix-test-runs.js +334 -0
- package/build/executor/completion-contract.js +8 -1
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +98 -23
- package/build/executor/epic-server-context.js +157 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/http-client.js +52 -5
- package/build/executor/job-runner.js +577 -81
- package/build/executor/observation.js +8 -0
- package/build/executor/permissions.js +85 -3
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +149 -3
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-work-diagnostics.js +4 -2
- package/build/executor/required-work-ledger.js +936 -38
- package/build/executor/results.js +58 -0
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/worker-command.js +72 -3
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +320 -101
- package/build/executor/worker-finalization.js +7 -1
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +18 -3
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +58 -4
- package/build/generated-assets-catalog.js +2 -2
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +824 -366
- package/build/init.js +26 -11
- package/build/install-bridge-conductor-answers.js +528 -0
- package/build/install-bridge-conductor-apply.js +288 -0
- package/build/install-bridge-conductor-assessment.js +1222 -0
- package/build/install-bridge-conductor-compact.js +186 -0
- package/build/install-bridge-conductor-contracts.js +72 -0
- package/build/install-bridge-conductor-gate.js +1312 -198
- package/build/install-bridge-conductor-setup.js +577 -83
- package/build/install-bridge-conductor.js +3381 -544
- package/build/install-bridge.js +280 -25
- package/build/install-doctor.js +38 -8
- package/build/install-maintenance.js +26 -3
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/launcher-config-inspection.js +162 -1
- package/build/mcp-grant-candidates.js +779 -0
- package/build/mcp-grant-doctor.js +63 -0
- package/build/mcp-grant.js +288 -0
- package/build/mcp-host-targets.js +8 -0
- package/build/mcp-identity.js +23 -0
- package/build/mcp-invoke.js +292 -15
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +155 -6
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +19 -1
- package/build/merge-workflow-install.js +243 -110
- package/build/pipelines.generated.js +7 -6
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +100 -7
- package/build/plan-generation-io.js +262 -0
- package/build/plan-generation.js +424 -0
- package/build/plane/build-freshness.js +6 -1
- package/build/plane/cli.js +75 -9
- package/build/plane/plane-freshness.js +17 -0
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/status.js +8 -2
- package/build/plane/terminal-run-cleanup.js +18 -4
- package/build/printed-remedy-commands.js +211 -12
- package/build/project-root.js +40 -0
- package/build/readiness-check.js +77 -0
- package/build/readiness-prerequisites.generated.js +122 -14
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +41 -0
- package/build/repository-toolchains.js +6 -3
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-epic.js +1305 -210
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +122 -4
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +63 -2
- package/build/ticket-delivery-enrollment.js +9 -0
- package/build/upgrade-cli.js +85 -2
- package/build/v2-readiness-requirements.js +28 -1
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worktree-credential-delivery.js +340 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/epic-implementer/getting-started.md +3 -1
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
package/build/install-bridge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readMcpInstallState } from "./mcp-install-state.js";
|
|
2
2
|
import { askSetupQuestion } from "./setup-question.js";
|
|
3
|
-
import { bindEpicLaunchCredential, resolveEpicLaunchCredential } from "./credential-store.js";
|
|
3
|
+
import { bindEpicLaunchCredential, normalizeBoundBaseUrl, readStoredBindingState, resolveEpicLaunchCredential } from "./credential-store.js";
|
|
4
4
|
import { settleMaintenanceCredential, authorizeMaintenanceEffect } from "./install-maintenance.js";
|
|
5
5
|
import { validateBootstrapDisplayName, validateBootstrapServerIdentity } from "./bootstrap-project-identity.js";
|
|
6
6
|
import { BRIDGE_SUPPORT_EMAIL, archiveAndReplaceModernBootstrapSignup, archiveExpiredLegacySignupAndInstallModern, lookupModernBootstrapRecord, mutateModernBootstrapRecord, prepareModernBootstrapInvite, prepareModernBootstrapSignup, transitionModernBootstrapSignup, lookupLegacyBootstrapInvite, checkpointModernBootstrapIdentity, promoteModernBootstrapCredential } from "./credential-store.js";
|
|
@@ -149,17 +149,29 @@ import { spawn } from "child_process";
|
|
|
149
149
|
import { randomBytes as cryptoRandomBytes, createHash } from "crypto";
|
|
150
150
|
import os from "os";
|
|
151
151
|
import path from "path";
|
|
152
|
+
import { discoverMcpGrantCandidates, publishMcpGrant } from "./mcp-grant-candidates.js";
|
|
153
|
+
import { readMcpGrant } from "./mcp-grant.js";
|
|
154
|
+
import { readEpicServerRecord, writeEpicServerRecord } from "./epic-server-record.js";
|
|
155
|
+
import { readEpicServerGuidance } from "./conductor/epic-server-guidance.js";
|
|
156
|
+
import { checkSfccUpload, createDefaultSfccUploadDeps } from "./conductor/epic-server-sfcc-upload.js";
|
|
157
|
+
import { readCredentialReferenceRecord } from "./credential-references.js";
|
|
158
|
+
import { createNodeCredentialReferenceDeps } from "./credential-references-node-deps.js";
|
|
159
|
+
import { writeEpicCapabilityStatement } from "./conductor/bridge-api-client.js";
|
|
152
160
|
import { detectClaudeLogin } from "./claude-login.js";
|
|
153
161
|
import { checkGithubSignIn } from "./github-sign-in.js";
|
|
154
162
|
import { readLocalGithubRemote } from "./conductor/stored-merge-credential.js";
|
|
155
163
|
import { probeStoredMergeToken } from "./conductor/stored-merge-token-probe.js";
|
|
156
164
|
import { readGithubMergeCredential, removeGithubMergeCredential, upsertGithubMergeCredential, } from "./credential-store.js";
|
|
157
165
|
import { createBridgeApiUrls } from "./bridge-api-urls.js";
|
|
166
|
+
import { installCiTriggerEdit } from "./ci-trigger-install.js";
|
|
158
167
|
import { installEpicCiWorkflow } from "./epic-ci-workflow-install.js";
|
|
159
|
-
import { fetchParseStatus,
|
|
168
|
+
import { fetchParseStatus, fetchSetupRecoveryEvidence, correctSetupBranch, admitSetupRecovery, } from "./conductor/bridge-api-client.js";
|
|
160
169
|
import readline from "readline";
|
|
161
170
|
import { runInit, InitPreflightError, buildBridgeApiEntry, buildBridgeConfigManifest, mergeBridgeApiProfileToken, resolveInitScaffoldAssets, refreshBridgeApiPackageSpec, currentBridgePackageSpec, classifyTrackedProbeExitCode, decideExistingProjectRoot, formatUndeterminedRootReplacedWarning, } from "./init.js";
|
|
162
171
|
import { hasProjectRootMarker as sharedHasProjectRootMarker } from "./project-root.js";
|
|
172
|
+
import { resolveDocsDirForRoot } from "./project-root.js";
|
|
173
|
+
import { hasVcsWorkTreeMarker, isHomeDirectory } from "./project-root.js";
|
|
174
|
+
import { createSetupRecordWriter } from "./install-bridge-conductor-apply.js";
|
|
163
175
|
import { VERSION } from "./version.generated.js";
|
|
164
176
|
import { bridgeConfigPath, parseBridgeConfigToml, rewriteBridgeConfigRepoName, validateBridgeConfigRepoNameRepresentability, validateRepoName, } from "./bridge-config.js";
|
|
165
177
|
import { renderDiagnosticValue } from "./diagnostic-text.js";
|
|
@@ -167,7 +179,9 @@ import { MCP_HOST_TARGETS, HOST_PLATFORM_ORDER, allHostTargets, agentForPlatform
|
|
|
167
179
|
import { provisionHostTarget, createDefaultVendorProcessDeps, inspectBridgeApiProfileToken, } from "./mcp-host-config.js";
|
|
168
180
|
import { adaptBridgeEntryForHostTarget, } from "./mcp-host-entry-adapter.js";
|
|
169
181
|
import { MCP_SERVER_NAME, MCP_PACKAGE_NAME, resolveRegistrationKey, } from "./mcp-identity.js";
|
|
170
|
-
import { DUPLICATE_REGISTRATION_GUIDANCE, discoverClaudeCodeEffectivePin } from "./launcher-config-inspection.js";
|
|
182
|
+
import { detectEffectiveBridgeDestination, DUPLICATE_REGISTRATION_GUIDANCE, discoverClaudeCodeEffectivePin } from "./launcher-config-inspection.js";
|
|
183
|
+
import { createCommandDriftInspector } from "./conductor/command-drift-production.js";
|
|
184
|
+
import { localBuildSetupLauncher } from "./install-bridge-conductor-setup.js";
|
|
171
185
|
import { codexHome, configureBridgeCodexProfile, inspectBridgeCodexProfile } from "./codex-bridge-profile.js";
|
|
172
186
|
import { recordInstalledConductorCapability, recordInstalledExecutorServiceUnit, recordInstalledProjectArtifact, writeMcpInstallState, } from "./mcp-install-state.js";
|
|
173
187
|
// BAPI-1207: opt-in cross-platform agent notes (AGENTS.md / CLAUDE.md).
|
|
@@ -189,7 +203,7 @@ import { runExecutorCli } from "./executor/cli.js";
|
|
|
189
203
|
import { runExecutor } from "./executor/runner.js";
|
|
190
204
|
// BAPI-1136: the merge-workflow generate-and-PR installer. Domain logic lives in
|
|
191
205
|
// its own module; this file supplies the parser and the process seams.
|
|
192
|
-
import { parseGithubRemote, runMergeWorkflowInstall, } from "./merge-workflow-install.js";
|
|
206
|
+
import { captureDefaultBranchSnapshot, parseGithubRemote, readSnapshotFile, runMergeWorkflowInstall, } from "./merge-workflow-install.js";
|
|
193
207
|
import { MERGE_WORKFLOW_CODEOWNER_INSTRUCTION, MERGE_WORKFLOW_REMEDY_COMMAND, } from "./conductor/merge-execution-contract.js";
|
|
194
208
|
import { MERGE_WORKFLOW_API_KEY_SECRET_NAME, } from "./merge-workflow-config.js";
|
|
195
209
|
import { runConductorInstallDoctor, EPIC_IMPLEMENTER_PROFILE_TOKEN, } from "./conductor/install-doctor.js";
|
|
@@ -967,6 +981,18 @@ export const INSTALL_BRIDGE_GITHUB_CONNECT_PROMPT = "Connect GitHub? [y/N]: ";
|
|
|
967
981
|
* Reuses the shared connect-github flow rather than duplicating the API, polling,
|
|
968
982
|
* browser, or picker logic — there is exactly one implementation of that handshake.
|
|
969
983
|
*/
|
|
984
|
+
/**
|
|
985
|
+
* BAPI-1677 — the installer options the conductor's `installCiWorkflow` forwards, field
|
|
986
|
+
* by field. A field left out here silently reverts a sealed list to the toolchain lines.
|
|
987
|
+
*/
|
|
988
|
+
export function ciWorkflowInstallOptions(options) {
|
|
989
|
+
return {
|
|
990
|
+
dryRun: options.dryRun,
|
|
991
|
+
...(options.snapshot !== undefined ? { snapshot: options.snapshot } : {}),
|
|
992
|
+
...(options.createOnly === true ? { createOnly: true } : {}),
|
|
993
|
+
...(options.dependencyInstall !== undefined ? { dependencyInstall: options.dependencyInstall } : {}),
|
|
994
|
+
};
|
|
995
|
+
}
|
|
970
996
|
export async function offerGithubConnection(repoName, baseUrl, deps, log, session) {
|
|
971
997
|
// No prompt surface → no offer. Never assume consent on a non-interactive run.
|
|
972
998
|
if (!deps.isTTY || !deps.promptLine)
|
|
@@ -1674,6 +1700,29 @@ export function getMergeWorkflowInstallUsage() {
|
|
|
1674
1700
|
export function buildConductorSetupDeps(deps, log, errorLog) {
|
|
1675
1701
|
const installerDeps = buildMergeWorkflowInstallDeps(deps, log, errorLog);
|
|
1676
1702
|
const storeDeps = modernWriteDeps(deps);
|
|
1703
|
+
// BAPI-1636: one read-only discovery, used at assessment AND again at
|
|
1704
|
+
// publication, so the binding, every source config, the existing grant, and
|
|
1705
|
+
// local package identity are re-read just before anything is staged. A
|
|
1706
|
+
// conflicting or malformed destination is not a setup failure: its evidence
|
|
1707
|
+
// only makes the classifier exclude more.
|
|
1708
|
+
const discoverGrantCandidates = async (repoName) => {
|
|
1709
|
+
const binding = await readStoredBindingState(`bapi:${repoName}`, installerCredentialReadDeps(deps));
|
|
1710
|
+
const destination = detectEffectiveBridgeDestination({
|
|
1711
|
+
envBaseUrl: deps.env.BAPI_BASE_URL,
|
|
1712
|
+
binding,
|
|
1713
|
+
productionBaseUrl: DEFAULT_BAPI_BASE_URL,
|
|
1714
|
+
});
|
|
1715
|
+
return discoverMcpGrantCandidates({
|
|
1716
|
+
homedir: deps.homedir,
|
|
1717
|
+
platform: deps.platform,
|
|
1718
|
+
readFile: deps.readFile,
|
|
1719
|
+
cwd: deps.cwd,
|
|
1720
|
+
repoName,
|
|
1721
|
+
productionBaseUrl: DEFAULT_BAPI_BASE_URL,
|
|
1722
|
+
destination: destination.evidence,
|
|
1723
|
+
readGrant: () => readMcpGrant(repoName, { env: deps.env, homedir: deps.homedir, readFile: deps.readFile }),
|
|
1724
|
+
});
|
|
1725
|
+
};
|
|
1677
1726
|
return {
|
|
1678
1727
|
detectClaudeLogin: () => detectClaudeLogin({ homedir: deps.homedir, readFile: deps.readFile }),
|
|
1679
1728
|
// An injected installer runner (tests) is used for these reads too, so a
|
|
@@ -1699,18 +1748,95 @@ export function buildConductorSetupDeps(deps, log, errorLog) {
|
|
|
1699
1748
|
getGetHeaders: async () => ({ "X-API-Key": access.apiKey }),
|
|
1700
1749
|
getPostHeaders: async () => ({ "X-API-Key": access.apiKey, "Content-Type": "application/json" }),
|
|
1701
1750
|
}),
|
|
1751
|
+
// The person's working tree: optional test-command hints for the server only.
|
|
1702
1752
|
readRepositoryFile: (relPath) => deps.readFile(path.join(deps.cwd, relPath)),
|
|
1703
|
-
|
|
1753
|
+
// BAPI-1603: everything the workflow is built from comes from the remote
|
|
1754
|
+
// default branch. One quiet capture, one immutable head, bounded read-only reads at it.
|
|
1755
|
+
captureDefaultBranch: async () => {
|
|
1756
|
+
const captured = await captureDefaultBranchSnapshot({ ...installerDeps, log: () => { }, errorLog: () => { } });
|
|
1757
|
+
return captured.ok ? captured.snapshot : null;
|
|
1758
|
+
},
|
|
1759
|
+
readSnapshotFile: (snapshot, relPath) => readSnapshotFile(installerDeps, snapshot, relPath),
|
|
1760
|
+
installCiWorkflow: (testCommand, toolchains, options, confirmWrite) => installEpicCiWorkflow(testCommand, toolchains, ciWorkflowInstallOptions(options), {
|
|
1704
1761
|
...installerDeps,
|
|
1705
1762
|
...(options.quiet === true ? { log: () => { }, errorLog: () => { } } : {}),
|
|
1706
1763
|
confirmWrite,
|
|
1707
1764
|
}),
|
|
1765
|
+
// BAPI-1654: the CI-only pull request for an approved trigger edit, through the same engine.
|
|
1766
|
+
installCiTriggerEdit: (edit, options, confirmWrite) => installCiTriggerEdit(edit, { dryRun: options.dryRun, ...(options.snapshot !== undefined ? { snapshot: options.snapshot } : {}) }, { ...installerDeps, confirmWrite }),
|
|
1708
1767
|
runGh: installerDeps.runGh,
|
|
1768
|
+
// BAPI-1635: committed command, agent, and host-mirror drift, read-only (the probe
|
|
1769
|
+
// `doctor` and `readiness` already use, now over the installer's rendered asset catalog).
|
|
1770
|
+
inspectCommandDrift: createCommandDriftInspector({ env: deps.env, cwd: deps.cwd, fetch: deps.fetch }),
|
|
1771
|
+
// BAPI-1635: the local-build command form is chosen only from the same effective
|
|
1772
|
+
// destination detection the MCP grant uses (kind `local`) AND a validated local-build
|
|
1773
|
+
// entry. Anything else, including a conflict or malformed destination, prints the npm form.
|
|
1774
|
+
detectLauncher: async (repoName) => {
|
|
1775
|
+
const entry = process.argv[1];
|
|
1776
|
+
if (typeof entry !== "string")
|
|
1777
|
+
return null;
|
|
1778
|
+
const binding = await readStoredBindingState(`bapi:${repoName}`, installerCredentialReadDeps(deps));
|
|
1779
|
+
const destination = detectEffectiveBridgeDestination({
|
|
1780
|
+
envBaseUrl: deps.env.BAPI_BASE_URL,
|
|
1781
|
+
binding,
|
|
1782
|
+
productionBaseUrl: DEFAULT_BAPI_BASE_URL,
|
|
1783
|
+
});
|
|
1784
|
+
return destination.state === "resolved" && destination.kind === "local" ? localBuildSetupLauncher(entry) : null;
|
|
1785
|
+
},
|
|
1709
1786
|
fetchParseStatus: (access) => fetchParseStatus(access, deps.fetch),
|
|
1710
|
-
triggerParse: (access) => triggerRepositoryParse(access, deps.fetch),
|
|
1711
1787
|
fetchRecoveryEvidence: (access, pr) => fetchSetupRecoveryEvidence(access, pr, deps.fetch),
|
|
1712
1788
|
correctBranch: (access, expected, destination) => correctSetupBranch(access, expected, destination, deps.fetch),
|
|
1713
1789
|
admitRecovery: (access, evidence, retry) => admitSetupRecovery(access, evidence, retry, deps.fetch),
|
|
1790
|
+
// BAPI-1545: the worker MCP grant and the advisory capability statement.
|
|
1791
|
+
mcpGrant: {
|
|
1792
|
+
discover: (repoName) => discoverGrantCandidates(repoName),
|
|
1793
|
+
readGrant: (repoName) => readMcpGrant(repoName, { env: deps.env, homedir: deps.homedir, readFile: deps.readFile }),
|
|
1794
|
+
readEpicServerRecord: (repoName) => readEpicServerRecord(repoName, { env: deps.env, homedir: deps.homedir, readFile: deps.readFile }),
|
|
1795
|
+
publish: (repoName, inventory, selectedIds, now) => publishMcpGrant(repoName, inventory, selectedIds, now, {
|
|
1796
|
+
rediscover: () => discoverGrantCandidates(repoName),
|
|
1797
|
+
credentialStore: storeDeps,
|
|
1798
|
+
grant: {
|
|
1799
|
+
env: deps.env,
|
|
1800
|
+
homedir: deps.homedir,
|
|
1801
|
+
platform: deps.platform,
|
|
1802
|
+
mkdir: deps.mkdir,
|
|
1803
|
+
chmod: deps.chmod,
|
|
1804
|
+
rename: deps.rename,
|
|
1805
|
+
open: deps.open,
|
|
1806
|
+
unlink: deps.unlink,
|
|
1807
|
+
},
|
|
1808
|
+
}),
|
|
1809
|
+
writeStatement: (access, statement) => writeEpicCapabilityStatement(access, statement, deps.fetch),
|
|
1810
|
+
},
|
|
1811
|
+
// BAPI-1546: the epic-server opt-in, its own record outside every worktree.
|
|
1812
|
+
epicServer: {
|
|
1813
|
+
readRecord: (repoName) => readEpicServerRecord(repoName, { env: deps.env, homedir: deps.homedir, readFile: deps.readFile }),
|
|
1814
|
+
writeRecord: (repoName, record) => writeEpicServerRecord(repoName, record, {
|
|
1815
|
+
env: deps.env,
|
|
1816
|
+
homedir: deps.homedir,
|
|
1817
|
+
platform: deps.platform,
|
|
1818
|
+
mkdir: deps.mkdir,
|
|
1819
|
+
chmod: deps.chmod,
|
|
1820
|
+
rename: deps.rename,
|
|
1821
|
+
open: deps.open,
|
|
1822
|
+
unlink: deps.unlink,
|
|
1823
|
+
}),
|
|
1824
|
+
guidancePresent: async () => (await readEpicServerGuidance((rel) => deps.readFile(path.join(deps.cwd, rel)))).state === "ok",
|
|
1825
|
+
// BAPI-1667: child 2's check, called directly on the owner's checkout. It writes
|
|
1826
|
+
// nothing and contacts no network. The run-only seams it never reads stay inert.
|
|
1827
|
+
sfccUploadCheck: ({ approvedSandboxId }) => checkSfccUpload({ repoRoot: deps.cwd, env: deps.env, approvedSandboxId }, createDefaultSfccUploadDeps({
|
|
1828
|
+
env: deps.env,
|
|
1829
|
+
homedir: deps.homedir,
|
|
1830
|
+
tmpdir: os.tmpdir,
|
|
1831
|
+
cwd: () => deps.cwd,
|
|
1832
|
+
stdout: () => { },
|
|
1833
|
+
stderr: () => { },
|
|
1834
|
+
resolveRepoName: async () => null,
|
|
1835
|
+
resolveRepoRoot: () => deps.cwd,
|
|
1836
|
+
readRecord: async () => ({ state: "absent" }),
|
|
1837
|
+
})),
|
|
1838
|
+
readCredentialReferences: (repoName) => readCredentialReferenceRecord(repoName, createNodeCredentialReferenceDeps(deps.env)),
|
|
1839
|
+
},
|
|
1714
1840
|
};
|
|
1715
1841
|
}
|
|
1716
1842
|
export function buildMergeWorkflowInstallDeps(deps, log, errorLog) {
|
|
@@ -2067,6 +2193,39 @@ function installerCredentialReadDeps(deps) {
|
|
|
2067
2193
|
return { env: deps.env, homedir: deps.homedir, platform: deps.platform,
|
|
2068
2194
|
readFile: deps.readFile, stat: async (p) => await deps.stat(p), stderr: deps.errorLog };
|
|
2069
2195
|
}
|
|
2196
|
+
/**
|
|
2197
|
+
* BAPI-1650: for a dry run only, decide whether the credential resolver's result
|
|
2198
|
+
* means the owner has not yet approved a saved key for a non-production address.
|
|
2199
|
+
*
|
|
2200
|
+
* It runs after the one existing resolver call and reads only the stored binding
|
|
2201
|
+
* state, which holds an endpoint and no key. It never resolves a credential again,
|
|
2202
|
+
* compares key values, makes a network call, asks for consent, or writes. Only a
|
|
2203
|
+
* proven `absent` binding, or one bound to a different endpoint, counts; `invalid`,
|
|
2204
|
+
* `unreadable`, `no-entry`, and a binding that matches the target keep their
|
|
2205
|
+
* existing behavior. The metadata is built field by field, never spread.
|
|
2206
|
+
*/
|
|
2207
|
+
async function classifyEndpointApproval(repoName, target, credential, readDeps) {
|
|
2208
|
+
const normalized = normalizeBoundBaseUrl(target);
|
|
2209
|
+
if (normalized === null || normalized === normalizeBoundBaseUrl(DEFAULT_BAPI_BASE_URL))
|
|
2210
|
+
return undefined;
|
|
2211
|
+
let kind;
|
|
2212
|
+
if (credential.ok) {
|
|
2213
|
+
if (credential.binding !== "env-paired")
|
|
2214
|
+
return undefined;
|
|
2215
|
+
kind = "env-paired";
|
|
2216
|
+
}
|
|
2217
|
+
else if (credential.kind === "binding-unbound" || credential.kind === "binding-mismatch") {
|
|
2218
|
+
kind = credential.kind;
|
|
2219
|
+
}
|
|
2220
|
+
else {
|
|
2221
|
+
return undefined;
|
|
2222
|
+
}
|
|
2223
|
+
const state = await readStoredBindingState(`bapi:${repoName}`, readDeps);
|
|
2224
|
+
if (state.state === "absent" || (state.state === "bound" && state.baseUrl !== normalized)) {
|
|
2225
|
+
return { needed: true, repoName, target: normalized, kind };
|
|
2226
|
+
}
|
|
2227
|
+
return undefined;
|
|
2228
|
+
}
|
|
2070
2229
|
/** Project identity evidence is read before onboarding; folder names are never identity. */
|
|
2071
2230
|
export async function observeInstalledIdentity(deps) {
|
|
2072
2231
|
const candidates = [];
|
|
@@ -5441,9 +5600,11 @@ export function buildInstallBridgeLaunchStepLabel(agent) {
|
|
|
5441
5600
|
// launch materialization, and every write — so a decline can abort with nothing
|
|
5442
5601
|
// minted, exchanged, or written.
|
|
5443
5602
|
//
|
|
5444
|
-
//
|
|
5445
|
-
//
|
|
5446
|
-
//
|
|
5603
|
+
// BAPI-1664: the gate now REFUSES the home directory outright (exit 1, before the
|
|
5604
|
+
// no-`.git` prompt). For every non-home folder, declining is still a user-initiated
|
|
5605
|
+
// CANCEL, not a failure: it exits 0. A non-TTY run warns and continues, preserving
|
|
5606
|
+
// automation compatibility (legitimate non-git, greenfield installs exist, so
|
|
5607
|
+
// blocking them outright was rejected).
|
|
5447
5608
|
// ---------------------------------------------------------------------------
|
|
5448
5609
|
/** Prefix of the always-printed "where am I installing" banner. */
|
|
5449
5610
|
export const INSTALL_BRIDGE_CWD_BANNER_PREFIX = "Installing Bridge into: ";
|
|
@@ -5455,6 +5616,22 @@ export const INSTALL_BRIDGE_NO_GIT_PROMPT = `${INSTALL_BRIDGE_NO_GIT_WARNING}
|
|
|
5455
5616
|
export const INSTALL_BRIDGE_NO_GIT_ABORT = "Aborted — run install from your project root, or re-run and confirm to continue.";
|
|
5456
5617
|
/** The non-TTY form: same finding, stated as a warning, then the run continues. */
|
|
5457
5618
|
export const INSTALL_BRIDGE_NO_GIT_NONINTERACTIVE_WARNING = `Warning: ${INSTALL_BRIDGE_NO_GIT_WARNING} — continuing (non-interactive).`;
|
|
5619
|
+
/**
|
|
5620
|
+
* BAPI-1664 refusal lines. Each is ONE line; the working directory is rendered
|
|
5621
|
+
* through {@link renderDiagnosticValue} so it cannot split the diagnostic.
|
|
5622
|
+
*/
|
|
5623
|
+
export function installBridgeEpicImplementerHomeRefusal(cwd) {
|
|
5624
|
+
return (`Error: ${renderDiagnosticValue(cwd)} is your home folder, and the home folder is never a project root. ` +
|
|
5625
|
+
"Run install epic-implementer from the repository root instead.");
|
|
5626
|
+
}
|
|
5627
|
+
export function installBridgeEpicImplementerNotRepoRootRefusal(cwd) {
|
|
5628
|
+
return (`Error: ${renderDiagnosticValue(cwd)} is not a project root (the folder that holds your repository). ` +
|
|
5629
|
+
"Run install epic-implementer from that project root, where .git lives.");
|
|
5630
|
+
}
|
|
5631
|
+
export function installBridgeHomeRefusal(cwd) {
|
|
5632
|
+
return (`Error: ${renderDiagnosticValue(cwd)} is your home folder, and the home folder is not a project root. ` +
|
|
5633
|
+
"Run install from a project folder instead.");
|
|
5634
|
+
}
|
|
5458
5635
|
/**
|
|
5459
5636
|
* Existence probe for `<cwd>/.git`, delegated to the shared project-root probe
|
|
5460
5637
|
* (BAPI-818) so `--init` and `install` use exactly one marker definition. A git
|
|
@@ -5516,13 +5693,16 @@ export function isMinttyNonInteractiveInstall(platform, env, isTTY) {
|
|
|
5516
5693
|
const msystem = env.MSYSTEM;
|
|
5517
5694
|
return (typeof msystem === "string" && msystem.trim().length > 0) || env.TERM_PROGRAM === "mintty";
|
|
5518
5695
|
}
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5696
|
+
async function refreshIndependentInstallAssets(deps, reason, presentation) {
|
|
5697
|
+
const compact = presentation?.mode === "compact";
|
|
5698
|
+
if (!compact)
|
|
5699
|
+
deps.errorLog(reason);
|
|
5522
5700
|
try {
|
|
5523
5701
|
await deps.runInit(deps.cwd, { assetsOnly: true, env: { ...deps.env, BAPI_API_KEY: undefined },
|
|
5524
|
-
stdout: deps.log, stderr: deps.errorLog });
|
|
5525
|
-
deps.log(
|
|
5702
|
+
stdout: compact && !presentation.verbose ? () => { } : deps.log, stderr: deps.errorLog });
|
|
5703
|
+
deps.log(compact
|
|
5704
|
+
? "Bridge assets refreshed; your identity, host bindings and preferences were kept."
|
|
5705
|
+
: "Independent Bridge assets refreshed. Existing identity, host bindings and preferences preserved; requested identity-dependent capabilities remain unavailable.");
|
|
5526
5706
|
}
|
|
5527
5707
|
catch {
|
|
5528
5708
|
deps.errorLog("Independent asset refresh failed; completed work was retained.");
|
|
@@ -5611,7 +5791,23 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5611
5791
|
// `epic-implementer` name. This nested `install epic-implementer` surface is
|
|
5612
5792
|
// untouched by that rename.
|
|
5613
5793
|
if (argv[0] === "conductor" || argv[0] === "epic-implementer") {
|
|
5614
|
-
// ---- BAPI-
|
|
5794
|
+
// ---- BAPI-1664: root guard, ahead of EVERYTHING below ----------------
|
|
5795
|
+
// Refuse the home folder, then any folder without a repository marker, before
|
|
5796
|
+
// merge-workflow handling, prerequisite assessment, refresh, credential
|
|
5797
|
+
// access, prompts, network, or writes. Checks the supplied cwd itself (no git
|
|
5798
|
+
// top-level resolution), so a checkout subdirectory is refused. stderr only.
|
|
5799
|
+
// `-h` / `--help` is let through: help writes nothing, and a user outside a
|
|
5800
|
+
// repository root still needs to read the usage text.
|
|
5801
|
+
const wantsHelp = argv.slice(1).some((arg) => arg === "-h" || arg === "--help");
|
|
5802
|
+
if (!wantsHelp && isHomeDirectory(deps.cwd, deps.homedir())) {
|
|
5803
|
+
errorLog(installBridgeEpicImplementerHomeRefusal(deps.cwd));
|
|
5804
|
+
return 1;
|
|
5805
|
+
}
|
|
5806
|
+
if (!wantsHelp && !(await hasVcsWorkTreeMarker(deps.cwd, deps.stat))) {
|
|
5807
|
+
errorLog(installBridgeEpicImplementerNotRepoRootRefusal(deps.cwd));
|
|
5808
|
+
return 1;
|
|
5809
|
+
}
|
|
5810
|
+
// ---- BAPI-1136:`install epic-implementer --merge-workflow` ----------
|
|
5615
5811
|
//
|
|
5616
5812
|
// Intercepted ahead of `parseInstallBridgeConductorArgs` on purpose. That
|
|
5617
5813
|
// parser REQUIRES at least one `--required-check` because an empty done gate
|
|
@@ -5667,6 +5863,17 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5667
5863
|
return 1;
|
|
5668
5864
|
}
|
|
5669
5865
|
const conductorBaseUrl = baseUrlResult.value;
|
|
5866
|
+
// In `--json` mode stdout is reserved for the single JSON document the
|
|
5867
|
+
// conductor writes through `conductorDeps.log`; human narration goes to stderr.
|
|
5868
|
+
const humanOutputSink = argv.includes("--json") ? errorLog : log;
|
|
5869
|
+
// BAPI-1650: the readiness checks still run after a refused credential, and they
|
|
5870
|
+
// read deps.env. A refused environment key must not reach them.
|
|
5871
|
+
const dropEnvironmentKey = () => {
|
|
5872
|
+
const { BAPI_API_KEY: _refused, ...kept } = deps.env;
|
|
5873
|
+
deps.env = kept;
|
|
5874
|
+
conductorDeps.env = kept;
|
|
5875
|
+
deps.startTicketsDeps = { ...deps.startTicketsDeps, env: kept };
|
|
5876
|
+
};
|
|
5670
5877
|
const conductorDeps = {
|
|
5671
5878
|
prerequisites: async (executorRequested) => {
|
|
5672
5879
|
const lookup = deps.lookupExecutable ?? defaultExecutablePresenceProbe;
|
|
@@ -5696,14 +5903,20 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5696
5903
|
const project = repoName ?? originalEnvironment.BAPI_REPO_NAME ?? (installed.status === "resolved" ? installed.repo : undefined);
|
|
5697
5904
|
if (!project || installed.status === "unavailable" || installed.status === "conflicting")
|
|
5698
5905
|
return { ok: false, error: "Project identity deferred during preview." };
|
|
5699
|
-
const
|
|
5700
|
-
|
|
5701
|
-
|
|
5906
|
+
const resolveDeps = { ...installerCredentialReadDeps(deps), env: originalEnvironment };
|
|
5907
|
+
const credential = await resolveEpicLaunchCredential(project, resolvedBaseUrl, resolveDeps, { productionBaseUrl: DEFAULT_BAPI_BASE_URL });
|
|
5908
|
+
// BAPI-1650: read-only approval evidence, attached only when proven.
|
|
5909
|
+
const endpointApproval = await classifyEndpointApproval(project, resolvedBaseUrl, credential, resolveDeps);
|
|
5910
|
+
const approval = endpointApproval !== undefined ? { endpointApproval } : {};
|
|
5911
|
+
if (credential.ok)
|
|
5912
|
+
return { ok: true, access: { repoName: project, baseUrl: resolvedBaseUrl, apiKey: credential.apiKey }, ...approval };
|
|
5913
|
+
dropEnvironmentKey();
|
|
5914
|
+
return { ok: false, error: "Credential validation and endpoint authorization deferred during dry run.", ...approval };
|
|
5702
5915
|
}
|
|
5703
5916
|
const parsedIdentity = parseInstallBridgeArgs(repoName ? ["--repo", repoName] : []);
|
|
5704
5917
|
if (parsedIdentity.status !== "ok")
|
|
5705
5918
|
return { ok: false, error: "Project selector unavailable." };
|
|
5706
|
-
if (!await selectInstalledProject(parsedIdentity.options, deps)) {
|
|
5919
|
+
if (!await selectInstalledProject(parsedIdentity.options, { ...deps, log: humanOutputSink })) {
|
|
5707
5920
|
return { ok: false, error: "Project identity remains unresolved." };
|
|
5708
5921
|
}
|
|
5709
5922
|
const access = await (deps.conductorResolveAccess ?? (async () => ({ ok: false, error: "access seam unavailable" })))(parsedIdentity.options.repo ?? repoName, resolvedBaseUrl, deps);
|
|
@@ -5713,10 +5926,11 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5713
5926
|
productionBaseUrl: DEFAULT_BAPI_BASE_URL,
|
|
5714
5927
|
hosts: await detectExistingRealKey(deps, hostConfigTargetsForPlatforms(["claude-code", "cursor", "copilot-vscode"])),
|
|
5715
5928
|
candidate: { key: access.access.apiKey, source: originalEnvironment.BAPI_API_KEY ? "env" : "store" },
|
|
5716
|
-
originalEnvironment, store: installerCredentialReadDeps(deps), report:
|
|
5717
|
-
terminal: { write:
|
|
5929
|
+
originalEnvironment, store: installerCredentialReadDeps(deps), report: humanOutputSink,
|
|
5930
|
+
terminal: { write: humanOutputSink, read: deps.isTTY ? deps.promptLine : undefined },
|
|
5718
5931
|
validate: async (key) => (await verifyConnectivity(deps, resolvedBaseUrl, access.access.repoName, key)).ok });
|
|
5719
5932
|
if (!settled.ok) {
|
|
5933
|
+
dropEnvironmentKey();
|
|
5720
5934
|
return { ok: false, error: settled.reason };
|
|
5721
5935
|
}
|
|
5722
5936
|
const identity = settled.identity;
|
|
@@ -5777,7 +5991,20 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5777
5991
|
localProvisioning: buildConductorLocalDeps(deps),
|
|
5778
5992
|
// BAPI-1461: the converging setup's seams (sign-ins, the stored merge token,
|
|
5779
5993
|
// the stored test command, the CI workflow installer, and indexing).
|
|
5780
|
-
setup: deps.conductorSetup ?? buildConductorSetupDeps(deps,
|
|
5994
|
+
setup: deps.conductorSetup ?? buildConductorSetupDeps(deps, humanOutputSink, errorLog),
|
|
5995
|
+
// BAPI-1638: `--answers <file>` (relative to this checkout) or `-` for stdin.
|
|
5996
|
+
answersSource: {
|
|
5997
|
+
readFile: (answersPath) => readFile(path.resolve(deps.cwd, answersPath), "utf-8"),
|
|
5998
|
+
readStdin: readProcessStdin,
|
|
5999
|
+
},
|
|
6000
|
+
// BAPI-1638: the setup record lives under docs_dir, the same root `ping` reports.
|
|
6001
|
+
setupRecordWriter: createSetupRecordWriter(resolveDocsDirForRoot(deps.cwd, deps.env), {
|
|
6002
|
+
lstat: (p) => lstat(p),
|
|
6003
|
+
mkdir: (p, o) => mkdir(p, o),
|
|
6004
|
+
readFile: (p, e) => readFile(p, e),
|
|
6005
|
+
writeFile: (p, t, o) => writeFile(p, t, o),
|
|
6006
|
+
rename: (a, b) => rename(a, b),
|
|
6007
|
+
}, { join: path.join, dirname: path.dirname }),
|
|
5781
6008
|
// BAPI-1391: the read-only discovery filesystem over THIS working tree, and
|
|
5782
6009
|
// the short-lived qualifying executor (the existing executor CLI with a
|
|
5783
6010
|
// `runExecutor` override limiting it to `gate_qualification` jobs).
|
|
@@ -5793,12 +6020,21 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5793
6020
|
}),
|
|
5794
6021
|
},
|
|
5795
6022
|
};
|
|
5796
|
-
|
|
6023
|
+
// Hold the verdict and next step so they print last, after the refresh output.
|
|
6024
|
+
let held;
|
|
6025
|
+
const result = await runInstallBridgeConductorCli(argv.slice(1), { ...conductorDeps, holdClosingResult: closing => { held = closing; } });
|
|
5797
6026
|
const nested = parseInstallBridgeConductorArgs(argv.slice(1));
|
|
6027
|
+
let exitCode = result;
|
|
5798
6028
|
if (result === 1 && nested.status === "ok" && !nested.options.dryRun) {
|
|
5799
|
-
|
|
6029
|
+
exitCode = await refreshIndependentInstallAssets(nested.options.json ? { ...deps, log: errorLog } : deps, "Epic Implementer setup remains incomplete; refreshing independent Bridge assets.", { mode: "compact", verbose: nested.options.verbose === true });
|
|
6030
|
+
}
|
|
6031
|
+
const closing = held;
|
|
6032
|
+
if (closing !== undefined) {
|
|
6033
|
+
log(closing.verdict);
|
|
6034
|
+
if (closing.nextStep !== undefined)
|
|
6035
|
+
log(closing.nextStep);
|
|
5800
6036
|
}
|
|
5801
|
-
return
|
|
6037
|
+
return exitCode;
|
|
5802
6038
|
}
|
|
5803
6039
|
const parsed = parseInstallBridgeArgs(argv);
|
|
5804
6040
|
if (parsed.status === "help") {
|
|
@@ -5967,6 +6203,12 @@ export async function runInstallBridgeCli(argv, overrides = {}) {
|
|
|
5967
6203
|
// ahead of ALL credential and configuration work so a decline costs nothing.
|
|
5968
6204
|
log(`${INSTALL_BRIDGE_CWD_BANNER_PREFIX}${deps.cwd}`);
|
|
5969
6205
|
log(`Bridge destination: ${baseUrl} (${deps.env.BAPI_BASE_URL === undefined ? "production default" : "BAPI_BASE_URL"}).`);
|
|
6206
|
+
// BAPI-1664: the home folder is never a project root. Refuse before the no-.git
|
|
6207
|
+
// prompt/warning so neither a "y" nor a non-TTY run can continue into it.
|
|
6208
|
+
if (isHomeDirectory(deps.cwd, deps.homedir())) {
|
|
6209
|
+
errorLog(installBridgeHomeRefusal(deps.cwd));
|
|
6210
|
+
return 1;
|
|
6211
|
+
}
|
|
5970
6212
|
if (!(await hasProjectRootMarker(deps))) {
|
|
5971
6213
|
if (deps.isTTY && deps.promptLine) {
|
|
5972
6214
|
let answer = "";
|
|
@@ -7989,3 +8231,16 @@ async function redeemModernInstallAttempt(deps, options, baseUrl, token, signupE
|
|
|
7989
8231
|
throw new ModernInstallRecoveryError("Canonical connectivity failed. Preserve proof and resume the same attempt.");
|
|
7990
8232
|
return { scope, record: checkpoint.record, repoName: exchange.repoName, displayName: exchange.displayName };
|
|
7991
8233
|
}
|
|
8234
|
+
/** BAPI-1638 — read all of stdin once, for `--answers -`. Bounded by the answers reader. */
|
|
8235
|
+
async function readProcessStdin() {
|
|
8236
|
+
const chunks = [];
|
|
8237
|
+
let total = 0;
|
|
8238
|
+
for await (const chunk of process.stdin) {
|
|
8239
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
|
|
8240
|
+
total += buffer.length;
|
|
8241
|
+
if (total > 512 * 1024)
|
|
8242
|
+
throw new Error("stdin answers exceed the size limit");
|
|
8243
|
+
chunks.push(buffer);
|
|
8244
|
+
}
|
|
8245
|
+
return Buffer.concat(chunks).toString("utf-8");
|
|
8246
|
+
}
|
package/build/install-doctor.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import path from "path";
|
|
23
23
|
import { createReadinessCheck, createReadinessCheckSafely, } from "./readiness-check.js";
|
|
24
|
-
import { resolveBapiCredentials } from "./credential-store.js";
|
|
24
|
+
import { normalizeBoundBaseUrl, readStoredBindingState, resolveBapiCredentials } from "./credential-store.js";
|
|
25
25
|
import { detectClaudeLogin, formatClaudeLoginAdvisory } from "./claude-login.js";
|
|
26
26
|
import { getProjectJsonTargets, hostAdapterForTarget } from "./mcp-host-targets.js";
|
|
27
27
|
import { existingRegistrationKey, MCP_PACKAGE_NAME, } from "./mcp-identity.js";
|
|
@@ -341,6 +341,21 @@ function readGithubConfiguredFlag(body) {
|
|
|
341
341
|
}
|
|
342
342
|
return null;
|
|
343
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* BAPI-1650: whether a saved key may go to this address. Production needs no
|
|
346
|
+
* approval unless the key is bound elsewhere; every other address needs its own.
|
|
347
|
+
* An unreadable or invalid binding is not approval.
|
|
348
|
+
*/
|
|
349
|
+
async function savedKeyApprovedForTarget(repoName, baseUrl, deps) {
|
|
350
|
+
const target = normalizeBoundBaseUrl(baseUrl);
|
|
351
|
+
if (target === null)
|
|
352
|
+
return false;
|
|
353
|
+
const binding = await readStoredBindingState(`bapi:${repoName}`, deps);
|
|
354
|
+
if (binding.state === "bound")
|
|
355
|
+
return binding.baseUrl === target;
|
|
356
|
+
return ((binding.state === "absent" || binding.state === "no-entry") &&
|
|
357
|
+
target === normalizeBoundBaseUrl(DEFAULT_BASE_URL));
|
|
358
|
+
}
|
|
344
359
|
/**
|
|
345
360
|
* Collect the install-status checklist. Never throws; every failure path becomes
|
|
346
361
|
* a WARN or SKIP check line. Performs at most three read-only GETs, and only
|
|
@@ -387,6 +402,15 @@ export async function collectInstallStatusChecks(deps) {
|
|
|
387
402
|
stat: deps.stat,
|
|
388
403
|
stderr: () => { },
|
|
389
404
|
};
|
|
405
|
+
const pushSkippedKeyChecks = (detail) => {
|
|
406
|
+
for (const [id, label] of [
|
|
407
|
+
["connectivity", "Server connectivity"],
|
|
408
|
+
["bootstrap", "Bootstrap config fields"],
|
|
409
|
+
["indexing", "Repository indexing"],
|
|
410
|
+
]) {
|
|
411
|
+
checks.push({ id, label, status: "SKIP", detail });
|
|
412
|
+
}
|
|
413
|
+
};
|
|
390
414
|
const cred = await resolveBapiCredentials(target.repoName, credDeps);
|
|
391
415
|
if (!cred.ok) {
|
|
392
416
|
checks.push({
|
|
@@ -397,13 +421,19 @@ export async function collectInstallStatusChecks(deps) {
|
|
|
397
421
|
remediation: "set BAPI_API_KEY or persist it via /install-bridge / the credentials subcommand; " +
|
|
398
422
|
"until then the remaining install checks are skipped.",
|
|
399
423
|
});
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
424
|
+
pushSkippedKeyChecks("no credential resolved");
|
|
425
|
+
return checks;
|
|
426
|
+
}
|
|
427
|
+
if (cred.credentials.source !== "env" &&
|
|
428
|
+
!(await savedKeyApprovedForTarget(target.repoName, target.baseUrl, credDeps))) {
|
|
429
|
+
checks.push({
|
|
430
|
+
id: "credential",
|
|
431
|
+
label: "Bridge API credential",
|
|
432
|
+
status: "WARN",
|
|
433
|
+
detail: `the saved key is not approved for ${target.baseUrl}, so it was not sent`,
|
|
434
|
+
remediation: "run install-bridge against this address and allow the key when asked.",
|
|
435
|
+
});
|
|
436
|
+
pushSkippedKeyChecks("the saved key is not approved for this address");
|
|
407
437
|
return checks;
|
|
408
438
|
}
|
|
409
439
|
checks.push({
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
/** One run's secret-bearing credential decision. Nothing here is a printable result. */
|
|
2
|
-
import { askSetupQuestion } from "./setup-question.js";
|
|
2
|
+
import { askSetupQuestion, askPlainSetupQuestion } from "./setup-question.js";
|
|
3
3
|
import { classifySetupAction } from "./setup-change-policy.js";
|
|
4
4
|
import { resolveBapiCredentials, readStoredBindingState } from "./credential-store.js";
|
|
5
5
|
const endpoint = (value) => value.trim().replace(/\/+$/, "");
|
|
6
6
|
/** Every consequential question uses the shared effect classifier and explained-question contract. */
|
|
7
|
-
export async function authorizeMaintenanceEffect(action, terminal, evidence, consequences) {
|
|
7
|
+
export async function authorizeMaintenanceEffect(action, terminal, evidence, consequences, presentation) {
|
|
8
8
|
const classification = classifySetupAction(action);
|
|
9
9
|
if (classification === "routine" || classification === "no-op")
|
|
10
10
|
return true;
|
|
11
11
|
if (classification === "missing-information")
|
|
12
12
|
return false;
|
|
13
|
+
if (presentation) {
|
|
14
|
+
const plain = {
|
|
15
|
+
question: presentation.question,
|
|
16
|
+
options: [{ id: "yes", label: "Yes, allow it", aliases: ["y"] },
|
|
17
|
+
{ id: "no", label: "No, keep the existing approval", aliases: ["n"] }],
|
|
18
|
+
recommended: "no",
|
|
19
|
+
recordingFlag: "rerun setup interactively to record this choice",
|
|
20
|
+
evidence: presentation.details,
|
|
21
|
+
summary: [presentation.recommendationReason, presentation.consequence],
|
|
22
|
+
consequences: [],
|
|
23
|
+
recovery: presentation.recovery,
|
|
24
|
+
};
|
|
25
|
+
// A reader exists only on an interactive terminal; the plain asker needs the flag.
|
|
26
|
+
const decision = await askPlainSetupQuestion(plain, { ...terminal, isTTY: !!terminal.read });
|
|
27
|
+
return decision.status === "selected" && decision.id === "yes";
|
|
28
|
+
}
|
|
13
29
|
const decision = await askSetupQuestion({ purpose: action.effect, evidence,
|
|
14
30
|
options: [{ id: "yes", label: "Authorize this change" }, { id: "no", label: "Preserve existing state" }],
|
|
15
31
|
consequences, deferred: "Only this change is deferred. Independent maintenance remains available.",
|
|
@@ -60,8 +76,15 @@ export async function settleMaintenanceCredential(input) {
|
|
|
60
76
|
: candidate.source === "env" && !inheritedPair && !sameEndpoint(input.productionBaseUrl);
|
|
61
77
|
let transferred = false;
|
|
62
78
|
if (transferNeeded) {
|
|
79
|
+
const sourceName = candidate.source === "store" ? "saved store" : candidate.source === "host" ? "host configuration" : candidate.source === "env" ? "environment" : candidate.source;
|
|
63
80
|
transferred = await authorizeMaintenanceEffect({ category: "credential", state: { status: "present", identity: repoName },
|
|
64
|
-
unchanged: false, context: baseUrl, effect: "Authorize the credential for this Bridge destination?", repository: repoName, trusted: true }, terminal, [`Project: ${repoName}`, `Credential source: ${candidate.source}`, `Destination: ${baseUrl}`, "Account and wider credential scope: unknown until validation"], ["Authenticated validation sends the credential to this destination. Saving approval replaces its previous endpoint binding; this does not authorize a different identity."]
|
|
81
|
+
unchanged: false, context: baseUrl, effect: "Authorize the credential for this Bridge destination?", repository: repoName, trusted: true }, terminal, [`Project: ${repoName}`, `Credential source: ${candidate.source}`, `Destination: ${baseUrl}`, "Account and wider credential scope: unknown until validation"], ["Authenticated validation sends the credential to this destination. Saving approval replaces its previous endpoint binding; this does not authorize a different identity."], { question: `Allow setup to use the Bridge key for ${repoName} at ${baseUrl}?`,
|
|
82
|
+
recommendationReason: "Recommended: No. The key should not be sent to a different destination without your approval.",
|
|
83
|
+
consequence: `Yes sends the key to ${baseUrl} to check it, and remembers that this key is approved for ${baseUrl}.`,
|
|
84
|
+
details: [`Project: ${repoName}`, `Key source: ${sourceName}`, `Destination: ${baseUrl}`,
|
|
85
|
+
"The account and what else the key can do are not known until the key is checked.",
|
|
86
|
+
"This does not approve a different key."],
|
|
87
|
+
recovery: "Choosing No keeps the existing approval. Rerun setup to decide again." });
|
|
65
88
|
if (!transferred) {
|
|
66
89
|
if (!retained || !sameEndpoint(retained.baseUrl))
|
|
67
90
|
return { ok: false, reason: "Endpoint transfer deferred; retained credential is unavailable to this destination." };
|