@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
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1667 — the read-only SFCC repository detector setup uses.
|
|
3
|
+
*
|
|
4
|
+
* It reads the checkout through the existing discovery seam and returns closed
|
|
5
|
+
* tokens and booleans only. `dw.json`, `.env`, and every MCP configuration file
|
|
6
|
+
* are checked by name, never opened: the only file this module reads is
|
|
7
|
+
* `package.json`, and from it only dependency key names and whether `scripts`
|
|
8
|
+
* has a `dev` key. The MCP signal comes from the inventory setup already built.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here throws or stops setup. Evidence that could not be read is `null`,
|
|
11
|
+
* which is different from a confirmed absence.
|
|
12
|
+
*/
|
|
13
|
+
/** The closed list of dependency names that count as SFCC tooling. */
|
|
14
|
+
export const SFCC_TOOLING_PACKAGES = Object.freeze([
|
|
15
|
+
"@salesforce/b2c-cli",
|
|
16
|
+
"@salesforce/storefront-next-dev",
|
|
17
|
+
"sfcc-ci",
|
|
18
|
+
"sgmf-scripts",
|
|
19
|
+
]);
|
|
20
|
+
/** The npm package name of the Salesforce B2C DX MCP server. */
|
|
21
|
+
export const B2C_DX_MCP_PACKAGE = "@salesforce/b2c-dx-mcp";
|
|
22
|
+
/** The fixed order `signals` is reported in. */
|
|
23
|
+
const SIGNAL_ORDER = ["cartridges_dir", "dw_json", "b2c_tooling_dependency", "b2c_dx_mcp_candidate"];
|
|
24
|
+
/** True when one argument names the DX MCP package, with or without a version suffix. */
|
|
25
|
+
export function isB2cDxMcpPackageArg(arg) {
|
|
26
|
+
return arg === B2C_DX_MCP_PACKAGE || arg.startsWith(`${B2C_DX_MCP_PACKAGE}@`);
|
|
27
|
+
}
|
|
28
|
+
/** True when a definition's args name the DX MCP package. */
|
|
29
|
+
export function definitionNamesB2cDxMcp(definition) {
|
|
30
|
+
return definition.args.some(isB2cDxMcpPackageArg);
|
|
31
|
+
}
|
|
32
|
+
function ownKeys(value) {
|
|
33
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? Object.keys(value) : [];
|
|
34
|
+
}
|
|
35
|
+
/** What `package.json` shows: key names only. `null` when it could not be read or parsed. */
|
|
36
|
+
function readPackageEvidence(text) {
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(text);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
45
|
+
return null;
|
|
46
|
+
const doc = parsed;
|
|
47
|
+
const names = new Set([...ownKeys(doc.dependencies), ...ownKeys(doc.devDependencies)]);
|
|
48
|
+
return {
|
|
49
|
+
tooling: SFCC_TOOLING_PACKAGES.filter((name) => names.has(name)).length,
|
|
50
|
+
devScript: ownKeys(doc.scripts).includes("dev"),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detect an SFCC repository. A top-level `cartridges/` or `dw.json` settles it;
|
|
55
|
+
* otherwise two contributions do (each distinct tooling package counts once, and
|
|
56
|
+
* the MCP candidate counts once, so the MCP candidate alone is never enough).
|
|
57
|
+
* The answer is `false` only when unread evidence could not change it.
|
|
58
|
+
*/
|
|
59
|
+
export async function detectSfccRepository(fs, inventory) {
|
|
60
|
+
let root = null;
|
|
61
|
+
try {
|
|
62
|
+
root = await fs.listDir("");
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
root = null;
|
|
66
|
+
}
|
|
67
|
+
let cartridges = false;
|
|
68
|
+
if (root?.includes("cartridges") === true) {
|
|
69
|
+
try {
|
|
70
|
+
cartridges = (await fs.listDir("cartridges")) !== null;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
cartridges = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const dwJson = root?.includes("dw.json") === true;
|
|
77
|
+
// A readable root that does not list package.json confirms there is none. Without a
|
|
78
|
+
// listing, a failed read could be either fact, so it stays unknown.
|
|
79
|
+
let packageEvidence = null;
|
|
80
|
+
let packageKnown = root !== null && !root.includes("package.json");
|
|
81
|
+
if (!packageKnown) {
|
|
82
|
+
let text = null;
|
|
83
|
+
try {
|
|
84
|
+
text = await fs.readText("package.json");
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
text = null;
|
|
88
|
+
}
|
|
89
|
+
packageEvidence = text === null ? null : readPackageEvidence(text);
|
|
90
|
+
packageKnown = packageEvidence !== null;
|
|
91
|
+
}
|
|
92
|
+
const candidate = inventory?.candidates.some((c) => c.definitions.some(definitionNamesB2cDxMcp)) === true;
|
|
93
|
+
const tooling = packageEvidence?.tooling ?? 0;
|
|
94
|
+
const present = new Set();
|
|
95
|
+
if (cartridges)
|
|
96
|
+
present.add("cartridges_dir");
|
|
97
|
+
if (dwJson)
|
|
98
|
+
present.add("dw_json");
|
|
99
|
+
if (tooling > 0)
|
|
100
|
+
present.add("b2c_tooling_dependency");
|
|
101
|
+
if (candidate)
|
|
102
|
+
present.add("b2c_dx_mcp_candidate");
|
|
103
|
+
const contributions = tooling + (candidate ? 1 : 0);
|
|
104
|
+
let detected;
|
|
105
|
+
if (cartridges || dwJson || contributions >= 2)
|
|
106
|
+
detected = true;
|
|
107
|
+
else if (root === null)
|
|
108
|
+
detected = null;
|
|
109
|
+
else if (!packageKnown)
|
|
110
|
+
detected = null;
|
|
111
|
+
else if (inventory === null && contributions >= 1)
|
|
112
|
+
detected = null;
|
|
113
|
+
else
|
|
114
|
+
detected = false;
|
|
115
|
+
return {
|
|
116
|
+
detected,
|
|
117
|
+
signals: SIGNAL_ORDER.filter((signal) => present.has(signal)),
|
|
118
|
+
dev_script: packageEvidence !== null ? packageEvidence.devScript : packageKnown ? false : null,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1667 — the shared SFCC evidence both setup paths read: the bounded,
|
|
3
|
+
* fail-open wrapper around child 2's upload check, the names-only view of the
|
|
4
|
+
* worker credential record, and the fixed wording built from them.
|
|
5
|
+
*
|
|
6
|
+
* Nothing here refuses or stops setup. Every sentence is fixed text or a closed
|
|
7
|
+
* token: raw check results, exception text, source paths, selectors, and values
|
|
8
|
+
* never reach an answer, a prompt, or the assessment.
|
|
9
|
+
*/
|
|
10
|
+
import { SFCC_UPLOAD_CHECK_MISSING_REASONS } from "./conductor/epic-server-sfcc-upload.js";
|
|
11
|
+
import { definitionNamesB2cDxMcp } from "./install-sfcc-detection.js";
|
|
12
|
+
import { PLAYWRIGHT_PRESET_NAME } from "./mcp-presets.js";
|
|
13
|
+
/**
|
|
14
|
+
* Matches the 15-second bound child 2's `--check` form uses, so a slow CLI version
|
|
15
|
+
* probe does not read as `unknown` here when the same check passes on the command line.
|
|
16
|
+
*/
|
|
17
|
+
export const SFCC_SETUP_UPLOAD_CHECK_TIMEOUT_MS = 15_000;
|
|
18
|
+
/** Setup's own reason, added beside child 2's closed reasons. */
|
|
19
|
+
export const NO_WORKER_SANDBOX_CREDENTIAL = "no_worker_sandbox_credential";
|
|
20
|
+
/** The whole-file sandbox entry `/install-bridge` records. */
|
|
21
|
+
export const SUGGESTED_SFCC_CREDENTIAL_ENTRY = "sfcc-dw-json";
|
|
22
|
+
export const WORKER_UPLOAD_ADVISORY = "Workers cannot upload until /install-bridge records the dw.json sandbox entry.";
|
|
23
|
+
export const SANDBOX_SKIPPED_LINE = "No approved sandbox was recorded; uploads stay off.";
|
|
24
|
+
export const SANDBOX_MISMATCH_ADVISORY = "This sandbox id does not match the first DNS label of the sandbox host in dw.json; every upload will be refused with sandbox_mismatch until they match.";
|
|
25
|
+
export const CREDENTIAL_NOT_FOUND_ADVISORY = "Not found in this repository's worker credential record; workers receive it only after /install-bridge records it.";
|
|
26
|
+
export const CREDENTIAL_RECORD_UNAVAILABLE_LINE = "This repository's worker credential record is absent or unusable; run /install-bridge to record a sandbox entry.";
|
|
27
|
+
const SFCC_MISSING_TEXT = Object.freeze({
|
|
28
|
+
cli_unavailable: "the b2c CLI was not found",
|
|
29
|
+
node_too_old: "this Node.js version is too old for the b2c CLI",
|
|
30
|
+
server_missing: "no sandbox host is set in dw.json or the environment",
|
|
31
|
+
not_a_sandbox_host: "the configured host is not an SFCC sandbox host",
|
|
32
|
+
sandbox_mismatch: "the approved sandbox id does not match the configured sandbox host",
|
|
33
|
+
code_version_missing: "no code version is set",
|
|
34
|
+
credentials_missing: "no sandbox client credentials were found",
|
|
35
|
+
interactive_auth_required: "the sandbox login needs an interactive sign-in",
|
|
36
|
+
config_unreadable: "the sandbox configuration could not be read",
|
|
37
|
+
[NO_WORKER_SANDBOX_CREDENTIAL]: "no sandbox credential reaches workers (run /install-bridge)",
|
|
38
|
+
});
|
|
39
|
+
function reachesWorkerTools(entry) {
|
|
40
|
+
return entry.level === "sandbox" && entry.consumers.some((c) => c.kind === "worktree_file" || c.kind === "env");
|
|
41
|
+
}
|
|
42
|
+
/** Project a record read into names-only rows. Production entries are never listed. */
|
|
43
|
+
export function projectCredentialEvidence(read) {
|
|
44
|
+
if (read.state === "absent")
|
|
45
|
+
return { recordState: "absent", rows: [] };
|
|
46
|
+
if (read.state !== "ok")
|
|
47
|
+
return { recordState: "unusable", rows: [] };
|
|
48
|
+
const rows = [];
|
|
49
|
+
for (const entry of read.record.credentials) {
|
|
50
|
+
if (entry.level === "production")
|
|
51
|
+
continue;
|
|
52
|
+
rows.push({ name: entry.name, level: entry.level, reaches_worker_tools: reachesWorkerTools(entry) });
|
|
53
|
+
}
|
|
54
|
+
rows.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
55
|
+
return { recordState: "ok", rows };
|
|
56
|
+
}
|
|
57
|
+
/** Read the credential evidence. A failed read is `unusable`, never an error. */
|
|
58
|
+
export async function collectCredentialEvidence(read) {
|
|
59
|
+
try {
|
|
60
|
+
return projectCredentialEvidence(await read());
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return { recordState: "unusable", rows: [] };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** The closed-token view of child 2's result, or null for anything unrecognized. */
|
|
67
|
+
function readCheckResult(raw) {
|
|
68
|
+
if (raw === null || typeof raw !== "object")
|
|
69
|
+
return null;
|
|
70
|
+
const { outcome, missing } = raw;
|
|
71
|
+
if (!Array.isArray(missing))
|
|
72
|
+
return null;
|
|
73
|
+
const known = SFCC_UPLOAD_CHECK_MISSING_REASONS;
|
|
74
|
+
if (!missing.every((reason) => known.includes(reason)))
|
|
75
|
+
return null;
|
|
76
|
+
if (outcome === "ready" && missing.length === 0)
|
|
77
|
+
return { outcome, missing: [] };
|
|
78
|
+
if (outcome === "unavailable" && missing.length > 0)
|
|
79
|
+
return { outcome, missing: missing };
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Run child 2's check under the timeout. A timeout, a throw, or an unrecognized
|
|
84
|
+
* result is `unknown`, and a late result is ignored. It never rejects.
|
|
85
|
+
*/
|
|
86
|
+
export async function runSfccUploadCheck(check, input) {
|
|
87
|
+
const unknown = { state: "unknown", missing: [] };
|
|
88
|
+
let timer;
|
|
89
|
+
const deadline = new Promise((resolve) => {
|
|
90
|
+
timer = setTimeout(() => resolve(TIMED_OUT), input.timeoutMs ?? SFCC_SETUP_UPLOAD_CHECK_TIMEOUT_MS);
|
|
91
|
+
timer.unref?.();
|
|
92
|
+
});
|
|
93
|
+
let raw;
|
|
94
|
+
try {
|
|
95
|
+
raw = await Promise.race([Promise.resolve().then(() => check({ approvedSandboxId: input.approvedSandboxId })), deadline]);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return unknown;
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
}
|
|
103
|
+
if (raw === TIMED_OUT)
|
|
104
|
+
return unknown;
|
|
105
|
+
const result = readCheckResult(raw);
|
|
106
|
+
if (result === null)
|
|
107
|
+
return unknown;
|
|
108
|
+
// Null credentials mean nothing was collected, which is not evidence that no entry exists.
|
|
109
|
+
const workerMissing = input.credentials !== null && !input.credentials.rows.some((r) => r.reaches_worker_tools);
|
|
110
|
+
const missing = workerMissing ? [...result.missing, NO_WORKER_SANDBOX_CREDENTIAL] : result.missing;
|
|
111
|
+
if (result.outcome === "ready")
|
|
112
|
+
return { state: workerMissing ? "possible_with_advisory" : "possible", missing };
|
|
113
|
+
return { state: "not_possible", missing };
|
|
114
|
+
}
|
|
115
|
+
const TIMED_OUT = Symbol("sfcc-upload-check-timed-out");
|
|
116
|
+
/** The one rule for "upload can work here", for every recommendation and optional question. */
|
|
117
|
+
export function isSfccUploadCapable(check) {
|
|
118
|
+
return check?.state === "possible" || check?.state === "possible_with_advisory";
|
|
119
|
+
}
|
|
120
|
+
/** The fixed sentence for the upload check. Empty when the check passed outright or did not run. */
|
|
121
|
+
export function describeSfccUpload(check) {
|
|
122
|
+
if (check === null || check === undefined || check.state === "possible")
|
|
123
|
+
return "";
|
|
124
|
+
if (check.state === "possible_with_advisory")
|
|
125
|
+
return WORKER_UPLOAD_ADVISORY;
|
|
126
|
+
if (check.state === "unknown")
|
|
127
|
+
return "The upload check could not run, so setup cannot say whether upload works here.";
|
|
128
|
+
return `Upload is not possible yet: ${check.missing.map((reason) => SFCC_MISSING_TEXT[reason]).join("; ")}.`;
|
|
129
|
+
}
|
|
130
|
+
/** Re-check an entered sandbox id. Returns the fixed advisory lines; it never refuses. */
|
|
131
|
+
export async function recheckSfccSandboxId(check, sandboxId, input) {
|
|
132
|
+
const result = await runSfccUploadCheck(check, { approvedSandboxId: sandboxId, ...input });
|
|
133
|
+
return result.missing.includes("sandbox_mismatch") ? [SANDBOX_MISMATCH_ADVISORY] : [];
|
|
134
|
+
}
|
|
135
|
+
/** The entry Enter selects, when the record lists it. */
|
|
136
|
+
export function suggestedCredentialEntry(credentials) {
|
|
137
|
+
return credentials?.rows.some((r) => r.name === SUGGESTED_SFCC_CREDENTIAL_ENTRY) === true ? SUGGESTED_SFCC_CREDENTIAL_ENTRY : null;
|
|
138
|
+
}
|
|
139
|
+
function describeRow(row) {
|
|
140
|
+
return `${row.name} (${row.level}, ${row.reaches_worker_tools ? "reaches workers" : "does not reach workers"})`;
|
|
141
|
+
}
|
|
142
|
+
/** The format line for the credential question. Names, levels, and reach only. */
|
|
143
|
+
export function credentialQuestionLines(credentials, defaultRef) {
|
|
144
|
+
const enter = defaultRef === null ? "" : ` Press Enter for ${defaultRef}.`;
|
|
145
|
+
const head = "Name of the worker credential entry for the sandbox account (from /install-bridge).";
|
|
146
|
+
if (credentials === null)
|
|
147
|
+
return [`${head}${enter}`];
|
|
148
|
+
if (credentials.recordState !== "ok")
|
|
149
|
+
return [`${head}${enter}`, CREDENTIAL_RECORD_UNAVAILABLE_LINE];
|
|
150
|
+
const entries = credentials.rows.length === 0 ? "none" : credentials.rows.map(describeRow).join(", ");
|
|
151
|
+
return [`${head} Entries: ${entries}.${enter}`];
|
|
152
|
+
}
|
|
153
|
+
/** The advisory for a reference the record does not list. A valid reference is always accepted. */
|
|
154
|
+
export function credentialReferenceAdvisories(credentials, reference) {
|
|
155
|
+
if (credentials === null)
|
|
156
|
+
return [];
|
|
157
|
+
if (credentials.recordState !== "ok")
|
|
158
|
+
return [CREDENTIAL_RECORD_UNAVAILABLE_LINE];
|
|
159
|
+
return credentials.rows.some((r) => r.name === reference) ? [] : [CREDENTIAL_NOT_FOUND_ADVISORY];
|
|
160
|
+
}
|
|
161
|
+
const PROJECT_ORIGIN_PREFERENCE = ["project-claude", "project-cursor"];
|
|
162
|
+
/**
|
|
163
|
+
* The definition ids to recommend for an SFCC repository: the one preferred
|
|
164
|
+
* b2c-dx-mcp definition from this repository's own MCP configuration, and the
|
|
165
|
+
* built-in Playwright preset, when each is offered. Sorted. The inventory, its ids,
|
|
166
|
+
* and its fingerprint are read and never changed.
|
|
167
|
+
*/
|
|
168
|
+
export function sfccRecommendedDefinitionIds(inventory) {
|
|
169
|
+
const definitions = inventory.candidates.flatMap((c) => c.definitions.map((definition) => ({ name: c.name, definition })));
|
|
170
|
+
const ids = [];
|
|
171
|
+
for (const origin of PROJECT_ORIGIN_PREFERENCE) {
|
|
172
|
+
const matches = definitions
|
|
173
|
+
.filter(({ definition }) => definition.origins.includes(origin) && definitionNamesB2cDxMcp(definition))
|
|
174
|
+
.map(({ definition }) => definition.id)
|
|
175
|
+
.sort();
|
|
176
|
+
if (matches.length > 0) {
|
|
177
|
+
ids.push(matches[0]);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const preset = definitions.find(({ name, definition }) => name === PLAYWRIGHT_PRESET_NAME && definition.origins.includes("preset"));
|
|
182
|
+
if (preset !== undefined)
|
|
183
|
+
ids.push(preset.definition.id);
|
|
184
|
+
return ids.sort();
|
|
185
|
+
}
|
|
@@ -20,12 +20,20 @@
|
|
|
20
20
|
* Secret safety: an inspection result carries only sanitized launcher facts —
|
|
21
21
|
* relative path, launcher shape, the package spec token, and versions. It never
|
|
22
22
|
* carries config bodies, `env` maps, credential values, or raw error text.
|
|
23
|
+
*
|
|
24
|
+
* BAPI-1636 adds a separate destination section
|
|
25
|
+
* ({@link detectEffectiveBridgeDestination}). It is binding INSPECTION, not
|
|
26
|
+
* credential resolution: it reads only `BAPI_BASE_URL` and the stored binding
|
|
27
|
+
* state a caller already obtained through `readStoredBindingState()`. It never
|
|
28
|
+
* reads `BAPI_API_KEY`, and it takes no launcher fact, so a launcher's shape can
|
|
29
|
+
* never decide where Bridge points.
|
|
23
30
|
*/
|
|
24
31
|
import path from "path";
|
|
25
32
|
import { codexHome, isCodexHomeOverrideHonored } from "./codex-home.js";
|
|
26
33
|
import { inspectCodexLauncher } from "./codex-launcher-pin.js";
|
|
34
|
+
import { normalizeBoundBaseUrl } from "./credential-store.js";
|
|
27
35
|
import { getProjectJsonTargets, hostAdapterForTarget, MCP_HOST_TARGETS, } from "./mcp-host-targets.js";
|
|
28
|
-
import { LEGACY_SERVER_NAMES, MCP_SERVER_NAME, MCP_PACKAGE_NAME, resolveRegistrationKey, WORKTREE_SHIM_TOKEN, } from "./mcp-identity.js";
|
|
36
|
+
import { isLocalBuildLauncher, LEGACY_SERVER_NAMES, MCP_SERVER_NAME, MCP_PACKAGE_NAME, resolveRegistrationKey, WORKTREE_SHIM_TOKEN, } from "./mcp-identity.js";
|
|
29
37
|
/**
|
|
30
38
|
* The npm package every Bridge launcher spec names. Retained as a compatibility
|
|
31
39
|
* alias — `doctor.ts` still imports this name — assigned from the shared
|
|
@@ -340,6 +348,17 @@ async function inspectOne(target, options) {
|
|
|
340
348
|
action: "skip-worktree-shim",
|
|
341
349
|
};
|
|
342
350
|
}
|
|
351
|
+
// BAPI-1636: a local build has no package token either. Detected after the
|
|
352
|
+
// shim and before the token requirement, so it is preserved, not refused.
|
|
353
|
+
if (isLocalBuildLauncher(entry.command, args)) {
|
|
354
|
+
return {
|
|
355
|
+
...keyed,
|
|
356
|
+
filePresent: true,
|
|
357
|
+
bridgeEntryPresent: true,
|
|
358
|
+
shape: "local-build",
|
|
359
|
+
action: "skip-local-build",
|
|
360
|
+
};
|
|
361
|
+
}
|
|
343
362
|
const pin = parseLauncherPin(args);
|
|
344
363
|
if (!pin) {
|
|
345
364
|
return {
|
|
@@ -516,6 +535,16 @@ export async function inspectGlobalLauncherConfigs(options) {
|
|
|
516
535
|
shape: "worktree-shim",
|
|
517
536
|
action: "skip-worktree-shim",
|
|
518
537
|
};
|
|
538
|
+
case "local-build":
|
|
539
|
+
return {
|
|
540
|
+
...base,
|
|
541
|
+
filePresent: true,
|
|
542
|
+
bridgeEntryPresent: true,
|
|
543
|
+
registrationKey: found.registrationName,
|
|
544
|
+
legacyRegistration: found.registrationName !== MCP_SERVER_NAME,
|
|
545
|
+
shape: "local-build",
|
|
546
|
+
action: "skip-local-build",
|
|
547
|
+
};
|
|
519
548
|
case "located": {
|
|
520
549
|
const keyed = {
|
|
521
550
|
...base,
|
|
@@ -541,6 +570,138 @@ export async function inspectGlobalLauncherConfigs(options) {
|
|
|
541
570
|
}
|
|
542
571
|
}
|
|
543
572
|
}
|
|
573
|
+
/** Fixed, value-free reasons. Never an URL, a key, or an error message. */
|
|
574
|
+
export const BRIDGE_DESTINATION_REASON_TEXT = {
|
|
575
|
+
production_default: "no BAPI_BASE_URL and no stored binding, so the production default applies",
|
|
576
|
+
stored_binding: "the stored credential binding names the endpoint",
|
|
577
|
+
environment_only: "BAPI_BASE_URL names the endpoint and no stored credential exists",
|
|
578
|
+
environment_production: "BAPI_BASE_URL names production and the stored key has no binding",
|
|
579
|
+
environment_corroborated: "BAPI_BASE_URL and the stored credential binding name the same endpoint",
|
|
580
|
+
environment_binding_conflict: "BAPI_BASE_URL and the stored credential binding name different endpoints",
|
|
581
|
+
environment_unbound_conflict: "BAPI_BASE_URL names a non-production endpoint, but the stored key has no binding",
|
|
582
|
+
environment_malformed: "BAPI_BASE_URL is not a usable http(s) URL",
|
|
583
|
+
binding_malformed: "the stored credential binding is present but invalid",
|
|
584
|
+
binding_unreadable: "the credential store could not be read",
|
|
585
|
+
production_malformed: "the production URL is not a usable http(s) URL",
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* The Bridge origins named anywhere in the destination evidence, valid ones
|
|
589
|
+
* only, for the grant classifier. It is kept even on a conflict or a malformed
|
|
590
|
+
* result, so a candidate that names any of them fails toward exclusion. It holds
|
|
591
|
+
* no user info, path, query, or fragment, and it refuses to serialize.
|
|
592
|
+
*/
|
|
593
|
+
export class BridgeDestinationEvidence {
|
|
594
|
+
#origins;
|
|
595
|
+
constructor(origins) {
|
|
596
|
+
this.#origins = new Set(origins);
|
|
597
|
+
}
|
|
598
|
+
/** True when `value` is an http(s) URL whose scheme, host, and effective port match a known origin. */
|
|
599
|
+
matchesUrl(value) {
|
|
600
|
+
const origin = bridgeUrlOrigin(value);
|
|
601
|
+
return origin !== null && this.#origins.has(origin);
|
|
602
|
+
}
|
|
603
|
+
/** How many distinct origins the evidence names. */
|
|
604
|
+
get size() {
|
|
605
|
+
return this.#origins.size;
|
|
606
|
+
}
|
|
607
|
+
toJSON() {
|
|
608
|
+
return "[redacted]";
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
/** Parse an http(s) URL, or null. Never throws. */
|
|
612
|
+
function parseHttpUrl(value) {
|
|
613
|
+
if (typeof value !== "string")
|
|
614
|
+
return null;
|
|
615
|
+
try {
|
|
616
|
+
const url = new URL(value.trim());
|
|
617
|
+
return url.protocol === "http:" || url.protocol === "https:" ? url : null;
|
|
618
|
+
}
|
|
619
|
+
catch {
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* The comparison key for an http(s) URL: scheme, host, and effective port. Path,
|
|
625
|
+
* user info, query, and fragment are ignored. Null for anything else. No DNS.
|
|
626
|
+
*/
|
|
627
|
+
export function bridgeUrlOrigin(value) {
|
|
628
|
+
const url = parseHttpUrl(value);
|
|
629
|
+
if (url === null)
|
|
630
|
+
return null;
|
|
631
|
+
const port = url.port !== "" ? url.port : url.protocol === "https:" ? "443" : "80";
|
|
632
|
+
return `${url.protocol}//${url.hostname}:${port}`;
|
|
633
|
+
}
|
|
634
|
+
/** Scheme, host, port, and path only, with trailing slashes dropped. */
|
|
635
|
+
function projectDestination(url) {
|
|
636
|
+
return `${url.protocol}//${url.host}${url.pathname}`.replace(/\/+$/, "");
|
|
637
|
+
}
|
|
638
|
+
/** True for `localhost`, `127.0.0.0/8`, and `::1`. Decided from the text alone. */
|
|
639
|
+
function isLoopbackHost(hostname) {
|
|
640
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost"))
|
|
641
|
+
return true;
|
|
642
|
+
if (hostname === "[::1]")
|
|
643
|
+
return true;
|
|
644
|
+
return /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(hostname);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Report the effective Bridge destination from the same facts
|
|
648
|
+
* `resolveEpicLaunchCredential()` uses: `BAPI_BASE_URL`, the stored binding, and
|
|
649
|
+
* the production URL. Read-only and pure; it chooses no local behavior. On a
|
|
650
|
+
* conflict or a malformed fact, the caller that would act on the destination
|
|
651
|
+
* defers that operation and reports the fixed reason.
|
|
652
|
+
*/
|
|
653
|
+
export function detectEffectiveBridgeDestination(input) {
|
|
654
|
+
const envRaw = normalizeBoundBaseUrl(input.envBaseUrl);
|
|
655
|
+
const envUrl = parseHttpUrl(envRaw);
|
|
656
|
+
const productionRaw = normalizeBoundBaseUrl(input.productionBaseUrl);
|
|
657
|
+
const productionUrl = parseHttpUrl(productionRaw);
|
|
658
|
+
const boundRaw = input.binding.state === "bound" ? normalizeBoundBaseUrl(input.binding.baseUrl) : null;
|
|
659
|
+
const boundUrl = parseHttpUrl(boundRaw);
|
|
660
|
+
const origins = [];
|
|
661
|
+
for (const url of [envUrl, productionUrl, boundUrl]) {
|
|
662
|
+
if (url !== null)
|
|
663
|
+
origins.push(bridgeUrlOrigin(url.href));
|
|
664
|
+
}
|
|
665
|
+
const evidence = new BridgeDestinationEvidence(origins);
|
|
666
|
+
const fail = (state, reason) => ({ state, reason, evidence });
|
|
667
|
+
if (envRaw !== null && envUrl === null)
|
|
668
|
+
return fail("malformed", "environment_malformed");
|
|
669
|
+
if (input.binding.state === "invalid")
|
|
670
|
+
return fail("malformed", "binding_malformed");
|
|
671
|
+
if (input.binding.state === "unreadable")
|
|
672
|
+
return fail("malformed", "binding_unreadable");
|
|
673
|
+
if (boundRaw !== null && boundUrl === null)
|
|
674
|
+
return fail("malformed", "binding_malformed");
|
|
675
|
+
if (productionUrl === null)
|
|
676
|
+
return fail("malformed", "production_malformed");
|
|
677
|
+
const resolved = (url, suppliedBy, reason) => {
|
|
678
|
+
const baseUrl = projectDestination(url);
|
|
679
|
+
const kind = baseUrl === projectDestination(productionUrl)
|
|
680
|
+
? "production"
|
|
681
|
+
: isLoopbackHost(url.hostname)
|
|
682
|
+
? "local"
|
|
683
|
+
: "non_production";
|
|
684
|
+
return { state: "resolved", baseUrl, kind, suppliedBy, reason, evidence };
|
|
685
|
+
};
|
|
686
|
+
if (envUrl === null) {
|
|
687
|
+
if (boundUrl !== null)
|
|
688
|
+
return resolved(boundUrl, "stored-binding", "stored_binding");
|
|
689
|
+
return resolved(productionUrl, "production-default", "production_default");
|
|
690
|
+
}
|
|
691
|
+
switch (input.binding.state) {
|
|
692
|
+
case "no-entry":
|
|
693
|
+
return resolved(envUrl, "environment", "environment_only");
|
|
694
|
+
case "bound":
|
|
695
|
+
return envRaw === boundRaw
|
|
696
|
+
? resolved(envUrl, "environment-and-binding", "environment_corroborated")
|
|
697
|
+
: fail("conflict", "environment_binding_conflict");
|
|
698
|
+
case "absent":
|
|
699
|
+
// Production needs no binding; any other endpoint does (BAPI-1272).
|
|
700
|
+
return envRaw === productionRaw
|
|
701
|
+
? resolved(envUrl, "environment", "environment_production")
|
|
702
|
+
: fail("conflict", "environment_unbound_conflict");
|
|
703
|
+
}
|
|
704
|
+
}
|
|
544
705
|
// ---------------------------------------------------------------------------
|
|
545
706
|
// Effective Claude Code pin (BAPI-1446)
|
|
546
707
|
// ---------------------------------------------------------------------------
|