@bridge_gpt/mcp-server 0.2.71 → 0.2.73
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 +22 -3
- package/build/agent-notes.js +171 -95
- package/build/agents.generated.js +7 -7
- package/build/bridge-permissions.js +31 -0
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -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/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +5 -1
- package/build/command-host.js +33 -0
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +1352 -50
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +47 -0
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/doctor.js +187 -28
- 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-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 +222 -29
- package/build/conductor/epic-implementer-cli.js +213 -13
- 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.js +107 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +594 -0
- package/build/conductor/gate-discovery.js +281 -10
- package/build/conductor/gate-settings-review.js +525 -5
- 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 +6 -53
- package/build/conductor/launch-plan.js +318 -121
- 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/prerequisite-inputs.js +1213 -0
- package/build/conductor/readiness-assessment.js +93 -0
- package/build/conductor/readiness-cli.js +30 -9
- package/build/conductor/readiness-prerequisites.js +77 -5
- package/build/conductor/readiness-sections.js +146 -126
- package/build/conductor/readiness.js +21 -3
- package/build/conductor/recovery-cli.js +236 -15
- package/build/conductor/recovery-operations.js +34 -4
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +36 -4
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +300 -21
- package/build/conductor/worker-database-doctor-inspector.js +34 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- package/build/credential-store.js +96 -21
- package/build/dependency-install-declarations.js +212 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +91 -8
- package/build/drive-epic-help.js +23 -4
- package/build/drive-epic.js +1841 -340
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +140 -0
- package/build/epic-capability-statement.js +107 -0
- package/build/epic-ci-workflow-drift.js +30 -15
- package/build/epic-ci-workflow-install.js +110 -42
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow.js +38 -12
- package/build/epic-implementer-bin.js +2184 -52
- package/build/epic-launch-context.js +607 -0
- package/build/epic-launch-profile.js +1 -1
- package/build/epic-server-record.js +273 -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/cli.js +2 -0
- package/build/executor/completion-contract.js +24 -1
- 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 +119 -17
- package/build/executor/epic-server-context.js +141 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +87 -6
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +659 -87
- package/build/executor/likely-tests.js +94 -97
- package/build/executor/observation.js +8 -0
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +127 -5
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +32 -0
- package/build/executor/required-work-ledger.js +955 -39
- package/build/executor/results.js +100 -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/terminal-mutation.js +8 -0
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +126 -5
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +575 -116
- package/build/executor/worker-finalization.js +71 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +55 -5
- package/build/executor/worktree-inspection.js +42 -0
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +54 -2
- package/build/generated-assets-catalog.js +2 -2
- package/build/github-sign-in.js +1 -1
- package/build/index.js +1111 -381
- package/build/init.js +29 -14
- package/build/install-bridge-conductor-answers.js +465 -0
- package/build/install-bridge-conductor-apply.js +259 -0
- package/build/install-bridge-conductor-assessment.js +895 -0
- package/build/install-bridge-conductor-compact.js +161 -0
- package/build/install-bridge-conductor-contracts.js +63 -0
- package/build/install-bridge-conductor-gate.js +1383 -188
- package/build/install-bridge-conductor-setup.js +637 -92
- package/build/install-bridge-conductor.js +3163 -740
- package/build/install-bridge.js +601 -128
- package/build/install-maintenance.js +127 -0
- package/build/install-reexec.js +1 -1
- package/build/launcher-config-inspection.js +162 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-grant-candidates.js +767 -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-install-state.js +68 -2
- package/build/mcp-invoke.js +126 -13
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +134 -2
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +6 -1
- package/build/merge-workflow-install.js +236 -111
- 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-discovery.js +97 -4
- package/build/plan-execution-ledger.js +248 -9
- 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 +23 -7
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/terminal-run-cleanup.js +23 -5
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +229 -15
- package/build/readiness-check.js +1 -1
- package/build/readiness-prerequisites.generated.js +311 -4
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +38 -0
- package/build/repository-toolchains.js +50 -8
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +1192 -198
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +180 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +32 -88
- package/build/test-support/notes-fs.js +40 -0
- package/build/third-party-mcp-targets.js +30 -0
- package/build/ticket-delivery-enrollment.js +30 -8
- package/build/ticket-delivery-run-scope.js +128 -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/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/EPIC-IMPLEMENTER.md +5 -0
- package/docs/epic-implementer/getting-started.md +42 -15
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
package/build/mcp-invoke.js
CHANGED
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
* manifest entry, resolves the target's required env overlay atomically from
|
|
16
16
|
* the secret store, and spawns the manifest `command`/`args`.
|
|
17
17
|
*
|
|
18
|
+
* BAPI-1545 adds the GRANT PATH, selected by `--grant-repo <repo>`. On it the
|
|
19
|
+
* shim never reads `<project-root>/.bridge/config`: `--target bapi` takes its
|
|
20
|
+
* repository identity from the flag, and every other target is resolved from
|
|
21
|
+
* the owner's grant file outside the worktree (`mcp-grant.ts`). Without the
|
|
22
|
+
* flag, both legacy paths above are unchanged.
|
|
23
|
+
*
|
|
18
24
|
* This file is the highest-risk surface of the worktree-credentials work: the
|
|
19
25
|
* stdio passthrough plus the signal/exit-code contract is covered exhaustively
|
|
20
26
|
* by its unit tests.
|
|
@@ -23,11 +29,13 @@ import { spawn, execFile } from "child_process";
|
|
|
23
29
|
import { stat, readFile } from "fs/promises";
|
|
24
30
|
import path from "path";
|
|
25
31
|
import os from "os";
|
|
26
|
-
import { resolveRepoNameForProjectRoot, readBridgeConfig, validateMcpTarget, } from "./bridge-config.js";
|
|
27
|
-
import { resolveBapiCredentials } from "./credential-store.js";
|
|
32
|
+
import { resolveRepoNameForProjectRoot, readBridgeConfig, validateMcpTarget, validateRepoName, } from "./bridge-config.js";
|
|
33
|
+
import { resolveBapiCredentials, resolveCredentialBundle, } from "./credential-store.js";
|
|
34
|
+
import { readMcpGrant } from "./mcp-grant.js";
|
|
35
|
+
import { applyPlaywrightOriginLimit, isPlaywrightPresetEntry, PLAYWRIGHT_ORIGIN_ENV_KEYS, resolvePlaywrightAllowedOrigin, } from "./mcp-presets.js";
|
|
28
36
|
import { describeBaseUrlRejection, validateHttpBaseUrl } from "./base-url.js";
|
|
29
37
|
import { MCP_PACKAGE_NAME } from "./mcp-identity.js";
|
|
30
|
-
import { getThirdPartyTargetDefinition, resolveThirdPartyTargetEnv, validateThirdPartyTargetManifestEntry, } from "./third-party-mcp-targets.js";
|
|
38
|
+
import { getThirdPartyTargetDefinition, grantedEntryRequiredKeys, resolveThirdPartyTargetEnv, validateGrantedTargetEntry, validateThirdPartyTargetManifestEntry, } from "./third-party-mcp-targets.js";
|
|
31
39
|
// ---------------------------------------------------------------------------
|
|
32
40
|
// Usage / argument parsing
|
|
33
41
|
// ---------------------------------------------------------------------------
|
|
@@ -54,10 +62,14 @@ export function getMcpInvokeUsage() {
|
|
|
54
62
|
" omitted, the child inherits BAPI_BASE_URL",
|
|
55
63
|
" unchanged. Must be an absolute http/https URL",
|
|
56
64
|
" with no embedded username or password.",
|
|
65
|
+
" --grant-repo <REPO> Optional. Resolve the target from the owner's",
|
|
66
|
+
" MCP grant for this repository (outside the",
|
|
67
|
+
" worktree) and never from .bridge/config. With",
|
|
68
|
+
" --target bapi, use this repository name.",
|
|
57
69
|
" -h, --help Show this help",
|
|
58
70
|
].join("\n");
|
|
59
71
|
}
|
|
60
|
-
const KNOWN_FLAGS = new Set(["--target", "--project-root", "--base-url"]);
|
|
72
|
+
const KNOWN_FLAGS = new Set(["--target", "--project-root", "--base-url", "--grant-repo"]);
|
|
61
73
|
/**
|
|
62
74
|
* Parse `--target`, `--project-root`, and the optional `--base-url` (split or `=`
|
|
63
75
|
* form). Rejects unknown flags, positional arguments, missing values, and
|
|
@@ -73,6 +85,7 @@ export function parseMcpInvokeArgs(argv) {
|
|
|
73
85
|
let target;
|
|
74
86
|
let projectRoot;
|
|
75
87
|
let baseUrl;
|
|
88
|
+
let grantRepo;
|
|
76
89
|
for (let i = 0; i < argv.length; i++) {
|
|
77
90
|
const token = argv[i];
|
|
78
91
|
if (token === "-h" || token === "--help") {
|
|
@@ -115,6 +128,17 @@ export function parseMcpInvokeArgs(argv) {
|
|
|
115
128
|
}
|
|
116
129
|
baseUrl = validation.baseUrl;
|
|
117
130
|
}
|
|
131
|
+
else if (flag === "--grant-repo") {
|
|
132
|
+
if (grantRepo !== undefined) {
|
|
133
|
+
return { status: "error", message: "Duplicate --grant-repo flag" };
|
|
134
|
+
}
|
|
135
|
+
const repo = validateRepoName(value);
|
|
136
|
+
// The rejected value is never echoed.
|
|
137
|
+
if (!repo.ok || repo.value !== value) {
|
|
138
|
+
return { status: "error", message: "Invalid --grant-repo: not a usable repository name" };
|
|
139
|
+
}
|
|
140
|
+
grantRepo = repo.value;
|
|
141
|
+
}
|
|
118
142
|
else {
|
|
119
143
|
if (projectRoot !== undefined) {
|
|
120
144
|
return { status: "error", message: "Duplicate --project-root flag" };
|
|
@@ -141,9 +165,13 @@ export function parseMcpInvokeArgs(argv) {
|
|
|
141
165
|
message: "--base-url is only valid with --target bapi",
|
|
142
166
|
};
|
|
143
167
|
}
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
168
|
+
return {
|
|
169
|
+
status: "ok",
|
|
170
|
+
target: targetValidation.value,
|
|
171
|
+
projectRoot,
|
|
172
|
+
...(baseUrl !== undefined ? { baseUrl } : {}),
|
|
173
|
+
...(grantRepo !== undefined ? { grantRepo } : {}),
|
|
174
|
+
};
|
|
147
175
|
}
|
|
148
176
|
// ---------------------------------------------------------------------------
|
|
149
177
|
// Validation, env construction, signals
|
|
@@ -374,6 +402,66 @@ export async function resolveThirdPartyInvocation(target, projectRoot, deps) {
|
|
|
374
402
|
const env = buildChildEnv(deps.env, envResult.env);
|
|
375
403
|
return { ok: true, invocation: { command, args, env } };
|
|
376
404
|
}
|
|
405
|
+
/** One fixed line when `BRIDGE_EPIC_SERVER_URL` is set but unusable. Never the value. */
|
|
406
|
+
export const PLAYWRIGHT_INVALID_EPIC_SERVER_URL_MESSAGE = "Warning: BRIDGE_EPIC_SERVER_URL is not an http or https URL; the browser is limited to an origin that allows nothing.";
|
|
407
|
+
/**
|
|
408
|
+
* BAPI-1545: resolve a non-Bridge target from the owner's grant ONLY. Never
|
|
409
|
+
* reads `.bridge/config`. A missing entry, an unusable or absent grant, or a
|
|
410
|
+
* failed credential resolution is a fixed, secret-free error (the shim exits
|
|
411
|
+
* non-zero, the host shows the server as failed, and the job continues).
|
|
412
|
+
*
|
|
413
|
+
* The child env is the inherited env, then the entry's non-secret `env`, then
|
|
414
|
+
* the resolved secrets. For the Playwright preset, exactly one
|
|
415
|
+
* `--allowed-origins <origin>` pair is appended (deny-all when
|
|
416
|
+
* `BRIDGE_EPIC_SERVER_URL` is absent or invalid), and the ambient
|
|
417
|
+
* `PLAYWRIGHT_MCP_ALLOWED_ORIGINS` / `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` are removed
|
|
418
|
+
* last, so nothing ambient can widen the list.
|
|
419
|
+
*/
|
|
420
|
+
export async function resolveGrantedInvocation(target, grantRepo, deps) {
|
|
421
|
+
const read = await deps.readGrant(grantRepo);
|
|
422
|
+
if (read.state === "absent") {
|
|
423
|
+
return { ok: false, error: `no MCP grant exists for this repository; target '${target}' is not granted` };
|
|
424
|
+
}
|
|
425
|
+
if (read.state === "unusable") {
|
|
426
|
+
return { ok: false, error: `the MCP grant for this repository is unusable (${read.reason}); target '${target}' is withheld` };
|
|
427
|
+
}
|
|
428
|
+
const entry = read.grant.servers.find((s) => s.name === target);
|
|
429
|
+
if (!entry) {
|
|
430
|
+
return { ok: false, error: `target '${target}' is not in the MCP grant for this repository` };
|
|
431
|
+
}
|
|
432
|
+
const validation = validateGrantedTargetEntry(entry);
|
|
433
|
+
if (!validation.ok)
|
|
434
|
+
return { ok: false, error: validation.error };
|
|
435
|
+
const overlay = { ...(entry.env ?? {}) };
|
|
436
|
+
const keys = grantedEntryRequiredKeys(entry);
|
|
437
|
+
if (keys.length > 0) {
|
|
438
|
+
if (entry.secret_bundle === undefined) {
|
|
439
|
+
return { ok: false, error: `granted server '${target}' requires a secret_bundle` };
|
|
440
|
+
}
|
|
441
|
+
const resolved = await deps.resolveBundle(entry.secret_bundle, keys);
|
|
442
|
+
if (!resolved.ok) {
|
|
443
|
+
return { ok: false, error: `failed to resolve credentials for '${target}': ${resolved.error}` };
|
|
444
|
+
}
|
|
445
|
+
for (const key of keys) {
|
|
446
|
+
const value = resolved.values[key];
|
|
447
|
+
if (typeof value !== "string") {
|
|
448
|
+
return { ok: false, error: `failed to resolve credentials for '${target}': a required key is missing` };
|
|
449
|
+
}
|
|
450
|
+
overlay[key] = value;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
let args = [...entry.args];
|
|
454
|
+
const env = buildChildEnv(deps.env, overlay);
|
|
455
|
+
if (isPlaywrightPresetEntry(entry)) {
|
|
456
|
+
const origin = resolvePlaywrightAllowedOrigin(deps.env);
|
|
457
|
+
if (origin.invalidSupplied)
|
|
458
|
+
deps.stderr(PLAYWRIGHT_INVALID_EPIC_SERVER_URL_MESSAGE);
|
|
459
|
+
args = applyPlaywrightOriginLimit(args, origin.origin);
|
|
460
|
+
for (const key of PLAYWRIGHT_ORIGIN_ENV_KEYS)
|
|
461
|
+
delete env[key];
|
|
462
|
+
}
|
|
463
|
+
return { ok: true, invocation: { command: entry.command, args, env } };
|
|
464
|
+
}
|
|
377
465
|
/**
|
|
378
466
|
* Run the `mcp-invoke` subcommand. Returns a process exit code (never calls
|
|
379
467
|
* `process.exit`). Parses args BEFORE any validation/resolution; validates the
|
|
@@ -397,7 +485,7 @@ export async function runMcpInvokeCli(argv, overrides = {}) {
|
|
|
397
485
|
stderr(getMcpInvokeUsage());
|
|
398
486
|
return 1;
|
|
399
487
|
}
|
|
400
|
-
const { target, projectRoot, baseUrl } = parsed;
|
|
488
|
+
const { target, projectRoot, baseUrl, grantRepo } = parsed;
|
|
401
489
|
const statFn = overrides.stat ?? ((p) => stat(p));
|
|
402
490
|
const dirCheck = await validateProjectRootDirectory(projectRoot, statFn);
|
|
403
491
|
if (!dirCheck.ok) {
|
|
@@ -412,12 +500,37 @@ export async function runMcpInvokeCli(argv, overrides = {}) {
|
|
|
412
500
|
stat: (p) => stat(p),
|
|
413
501
|
stderr,
|
|
414
502
|
};
|
|
503
|
+
// BAPI-1545: on the grant path a non-Bridge target is resolved from the grant
|
|
504
|
+
// file only, before any worktree-config reader is even constructed.
|
|
505
|
+
if (grantRepo !== undefined && target !== "bapi") {
|
|
506
|
+
const readGrant = overrides.readMcpGrant ??
|
|
507
|
+
((repo) => readMcpGrant(repo, { env, homedir: os.homedir, readFile: (p) => readFile(p, "utf-8") }));
|
|
508
|
+
const resolveBundle = overrides.resolveCredentialBundle ??
|
|
509
|
+
((bundle, keys) => resolveCredentialBundle(bundle, keys, credentialDeps));
|
|
510
|
+
const resolved = await resolveGrantedInvocation(target, grantRepo, {
|
|
511
|
+
env,
|
|
512
|
+
readGrant,
|
|
513
|
+
resolveBundle,
|
|
514
|
+
stderr,
|
|
515
|
+
});
|
|
516
|
+
if (!resolved.ok) {
|
|
517
|
+
stderr(`Error: ${resolved.error}`);
|
|
518
|
+
return 1;
|
|
519
|
+
}
|
|
520
|
+
return spawnInvocation(resolved.invocation, overrides);
|
|
521
|
+
}
|
|
415
522
|
if (target === "bapi") {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
523
|
+
// BAPI-1545: with `--grant-repo`, the trusted repository name is used as is
|
|
524
|
+
// and the worktree's `.bridge/config` is never consulted, so a worker that
|
|
525
|
+
// rewrites `repoName` there cannot pick another repository's credential.
|
|
526
|
+
// The grant itself is not read: Bridge works even when the grant is unusable.
|
|
527
|
+
const resolveRepoName = grantRepo !== undefined
|
|
528
|
+
? async () => ({ ok: true, value: grantRepo })
|
|
529
|
+
: overrides.resolveRepoName ??
|
|
530
|
+
((pr) => resolveRepoNameForProjectRoot(pr, {
|
|
531
|
+
readFile: (p) => readFile(p, "utf-8"),
|
|
532
|
+
runCommand: defaultRunCommand,
|
|
533
|
+
}));
|
|
421
534
|
const resolveCredentials = overrides.resolveCredentials ??
|
|
422
535
|
((rn) => resolveBapiCredentials(rn, credentialDeps));
|
|
423
536
|
// The parsed URL reaches ONLY this branch; the parser already rejected
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in MCP presets offered at the grant setup item (BAPI-1545).
|
|
3
|
+
*
|
|
4
|
+
* One preset today: Playwright. It is a pinned `@playwright/mcp` run through
|
|
5
|
+
* `npx -y` with `--headless --isolated`. The `mcp-invoke` shim adds exactly one
|
|
6
|
+
* `--allowed-origins <origin>` pair at launch, derived from the
|
|
7
|
+
* `BRIDGE_EPIC_SERVER_URL` the shim itself inherits (child 3 sets it at spawn).
|
|
8
|
+
*
|
|
9
|
+
* WHY A DENY-ALL ORIGIN AND NOT AN EMPTY LIST. In `@playwright/mcp` 0.0.83 the
|
|
10
|
+
* browser context installs its block-all route only when
|
|
11
|
+
* `network.allowedOrigins` is NON-EMPTY (`_setupRequestInterception` checks
|
|
12
|
+
* `allowedOrigins?.length`). An empty list, or no flag at all, allows every
|
|
13
|
+
* origin. So "allow nothing" has to be a non-empty list naming one origin that
|
|
14
|
+
* can never match a real request: a reserved `.invalid` host (RFC 6761).
|
|
15
|
+
* This was verified against the locally cached 0.0.83 package; the pin below is
|
|
16
|
+
* that version. If a future pin cannot limit origins, set
|
|
17
|
+
* `PLAYWRIGHT_PRESET_LIMITS_ORIGINS` to false: the preset is then not offered at
|
|
18
|
+
* all, never shipped allowing everything.
|
|
19
|
+
*
|
|
20
|
+
* CAVEAT, stated plainly: upstream documents that `--allowed-origins` "does not
|
|
21
|
+
* serve as a security boundary and does not affect redirects". It narrows what
|
|
22
|
+
* the browser requests; it is not OS isolation. The replacing environment and
|
|
23
|
+
* fixed port child 3 adds are separate limits this module does not provide.
|
|
24
|
+
*/
|
|
25
|
+
/** The grant name the Playwright preset is registered under. Reserved. */
|
|
26
|
+
export const PLAYWRIGHT_PRESET_NAME = "playwright";
|
|
27
|
+
/** The pinned, locally verified package version. Never a floating tag. */
|
|
28
|
+
export const PLAYWRIGHT_MCP_PINNED_VERSION = "0.0.83";
|
|
29
|
+
/** The pinned package spec `npx -y` launches. */
|
|
30
|
+
export const PLAYWRIGHT_MCP_PACKAGE_SPEC = `@playwright/mcp@${PLAYWRIGHT_MCP_PINNED_VERSION}`;
|
|
31
|
+
/** Baseline arguments, before the shim appends the origin limit. */
|
|
32
|
+
export const PLAYWRIGHT_PRESET_BASE_ARGS = ["-y", PLAYWRIGHT_MCP_PACKAGE_SPEC, "--headless", "--isolated"];
|
|
33
|
+
/** Whether the pinned version honors `--allowed-origins` (verified for 0.0.83). */
|
|
34
|
+
export const PLAYWRIGHT_PRESET_LIMITS_ORIGINS = true;
|
|
35
|
+
/** The non-empty origin list that allows nothing (RFC 6761 reserved TLD). */
|
|
36
|
+
export const PLAYWRIGHT_DENY_ALL_ORIGIN = "http://deny-all.invalid";
|
|
37
|
+
/** The env var the shim reads the one allowed origin from. */
|
|
38
|
+
export const EPIC_SERVER_URL_ENV = "BRIDGE_EPIC_SERVER_URL";
|
|
39
|
+
/** The ambient env vars that could widen the origin list; removed from the child env. */
|
|
40
|
+
export const PLAYWRIGHT_ORIGIN_ENV_KEYS = [
|
|
41
|
+
"PLAYWRIGHT_MCP_ALLOWED_ORIGINS",
|
|
42
|
+
"PLAYWRIGHT_MCP_BLOCKED_ORIGINS",
|
|
43
|
+
];
|
|
44
|
+
/** Shown in the setup item when the preset cannot limit origins. */
|
|
45
|
+
export const PLAYWRIGHT_PRESET_UNAVAILABLE_TEXT = "Playwright preset unavailable: this version cannot limit origins";
|
|
46
|
+
/** The preset's grant entry, or null when it must not be offered. */
|
|
47
|
+
export function playwrightPresetEntry() {
|
|
48
|
+
if (!PLAYWRIGHT_PRESET_LIMITS_ORIGINS)
|
|
49
|
+
return null;
|
|
50
|
+
return {
|
|
51
|
+
name: PLAYWRIGHT_PRESET_NAME,
|
|
52
|
+
source: "preset",
|
|
53
|
+
transport: "stdio",
|
|
54
|
+
command: "npx",
|
|
55
|
+
args: [...PLAYWRIGHT_PRESET_BASE_ARGS],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** True when a granted entry is the built-in Playwright preset. */
|
|
59
|
+
export function isPlaywrightPresetEntry(entry) {
|
|
60
|
+
return entry.source === "preset" && entry.name === PLAYWRIGHT_PRESET_NAME;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Derive the one allowed origin from the shim's environment. Only an http or
|
|
64
|
+
* https URL counts, reduced to its origin. Absent or invalid → the deny-all
|
|
65
|
+
* origin. `invalidSupplied` lets the caller print one fixed diagnostic; the
|
|
66
|
+
* supplied value is never returned or printed.
|
|
67
|
+
*/
|
|
68
|
+
export function resolvePlaywrightAllowedOrigin(env) {
|
|
69
|
+
const raw = env[EPIC_SERVER_URL_ENV];
|
|
70
|
+
if (raw === undefined || raw.trim().length === 0)
|
|
71
|
+
return { origin: PLAYWRIGHT_DENY_ALL_ORIGIN, invalidSupplied: false };
|
|
72
|
+
try {
|
|
73
|
+
const url = new URL(raw.trim());
|
|
74
|
+
if ((url.protocol === "http:" || url.protocol === "https:") && url.origin !== "null") {
|
|
75
|
+
return { origin: url.origin, invalidSupplied: false };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
/* fall through to deny-all */
|
|
80
|
+
}
|
|
81
|
+
return { origin: PLAYWRIGHT_DENY_ALL_ORIGIN, invalidSupplied: true };
|
|
82
|
+
}
|
|
83
|
+
function isOriginFlag(arg) {
|
|
84
|
+
return (arg === "--allowed-origins" ||
|
|
85
|
+
arg.startsWith("--allowed-origins=") ||
|
|
86
|
+
arg === "--blocked-origins" ||
|
|
87
|
+
arg.startsWith("--blocked-origins="));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Remove every origin flag (split or `=` form) and append exactly one
|
|
91
|
+
* `--allowed-origins <origin>` pair.
|
|
92
|
+
*/
|
|
93
|
+
export function applyPlaywrightOriginLimit(args, origin) {
|
|
94
|
+
const out = [];
|
|
95
|
+
for (let i = 0; i < args.length; i++) {
|
|
96
|
+
const arg = args[i];
|
|
97
|
+
if (isOriginFlag(arg)) {
|
|
98
|
+
// A split form also consumes its value.
|
|
99
|
+
if (!arg.includes("=") && i + 1 < args.length)
|
|
100
|
+
i++;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
out.push(arg);
|
|
104
|
+
}
|
|
105
|
+
out.push("--allowed-origins", origin);
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
@@ -16,12 +16,22 @@
|
|
|
16
16
|
* provisioned as its own shim entry. Unsupported or incomplete non-`bapi`
|
|
17
17
|
* targets produce a non-fatal, secret-free warning.
|
|
18
18
|
*
|
|
19
|
+
* BAPI-1545 adds the GRANT PATH. When the caller supplies a trusted repository
|
|
20
|
+
* name (the executor passes the claimed job's `repo_name`) and that repository
|
|
21
|
+
* has an MCP grant file outside the worktree, the worktree's `.bridge/config` is
|
|
22
|
+
* never read. The registration is rebuilt from the grant on every spawn — Bridge
|
|
23
|
+
* plus one shim per granted server, nothing else — replacing the whole server
|
|
24
|
+
* map so a worker's edits cannot survive. An unusable grant yields Bridge only.
|
|
25
|
+
* With no trusted name, or no grant file, the legacy path below is unchanged.
|
|
26
|
+
*
|
|
19
27
|
* All filesystem access is dependency-injected so this is unit-testable, and the
|
|
20
28
|
* platform path API is resolved locally (never imported from `start-tickets.ts`)
|
|
21
29
|
* to avoid a runtime import cycle.
|
|
22
30
|
*/
|
|
31
|
+
import os from "os";
|
|
23
32
|
import path from "path";
|
|
24
33
|
import { readBridgeConfig } from "./bridge-config.js";
|
|
34
|
+
import { readMcpGrant } from "./mcp-grant.js";
|
|
25
35
|
import { getThirdPartyTargetDefinition, validateThirdPartyTargetManifestEntry, } from "./third-party-mcp-targets.js";
|
|
26
36
|
import { buildMcpShimCommand, } from "./mcp-server-invocation.js";
|
|
27
37
|
import { getWorktreeHostTargets, hostAdapterForTarget } from "./mcp-host-targets.js";
|
|
@@ -90,8 +100,8 @@ export function serverNameForMcpTarget(target) {
|
|
|
90
100
|
* `command` and `args`; credentials continue to be resolved by the `mcp-invoke`
|
|
91
101
|
* shim at launch and are never written into the worktree.
|
|
92
102
|
*/
|
|
93
|
-
export function buildShimMcpServerEntry(target, absoluteWorktreePath, invocation, bridgeApiBaseUrl) {
|
|
94
|
-
const entry = buildMcpShimCommand(invocation, target, absoluteWorktreePath);
|
|
103
|
+
export function buildShimMcpServerEntry(target, absoluteWorktreePath, invocation, bridgeApiBaseUrl, grantRepo) {
|
|
104
|
+
const entry = buildMcpShimCommand(invocation, target, absoluteWorktreePath, grantRepo);
|
|
95
105
|
// Tier-2 targets are structurally unchanged: `--base-url` is a `bapi`-only flag
|
|
96
106
|
// and `mcp-invoke` rejects it for any other target, so appending it elsewhere
|
|
97
107
|
// would generate a registration that refuses to launch.
|
|
@@ -240,6 +250,25 @@ export function mergeBridgeApiMcpRegistration(existing, topLevelKey, entry) {
|
|
|
240
250
|
// canonical name is sufficient — and keeps ONE place that decides the key.
|
|
241
251
|
return mergeMcpRegistrations(existing, topLevelKey, { [MCP_SERVER_NAME]: entry });
|
|
242
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* BAPI-1545: the authoritative server map for the grant path. Bridge is always
|
|
255
|
+
* present (with `--grant-repo`, so the shim takes its repository identity from
|
|
256
|
+
* the trusted name). A usable grant adds exactly one shim per granted server; an
|
|
257
|
+
* unusable grant adds none.
|
|
258
|
+
*/
|
|
259
|
+
export function buildGrantMcpServerEntries(grant, trustedRepoName, absoluteWorktreePath, invocation, bridgeApiBaseUrl) {
|
|
260
|
+
const entries = {
|
|
261
|
+
[serverNameForMcpTarget("bapi")]: buildShimMcpServerEntry("bapi", absoluteWorktreePath, invocation, bridgeApiBaseUrl, trustedRepoName),
|
|
262
|
+
};
|
|
263
|
+
if (grant.state === "ok") {
|
|
264
|
+
for (const server of grant.grant.servers) {
|
|
265
|
+
entries[serverNameForMcpTarget(server.name)] = buildShimMcpServerEntry(server.name, absoluteWorktreePath, invocation, undefined, trustedRepoName);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return entries;
|
|
269
|
+
}
|
|
270
|
+
/** Fixed, secret-free warning for an unusable grant. */
|
|
271
|
+
export const UNUSABLE_GRANT_WARNING = "the MCP grant for this repository is unusable; this worker gets Bridge only. Re-run `install epic-implementer` to repair it.";
|
|
243
272
|
// ---------------------------------------------------------------------------
|
|
244
273
|
// Filesystem writes
|
|
245
274
|
// ---------------------------------------------------------------------------
|
|
@@ -281,6 +310,55 @@ export async function writeMcpRegistrationFile(target, entries, deps) {
|
|
|
281
310
|
}
|
|
282
311
|
return { ok: true };
|
|
283
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* BAPI-1545: write a registration file AUTHORITATIVELY — the whole server map
|
|
315
|
+
* under `topLevelKey` is replaced by `entries`, removing stale extras and any
|
|
316
|
+
* Bridge alias. Unrelated top-level fields of a valid existing document are
|
|
317
|
+
* kept. A malformed existing document is refused, never overwritten blindly.
|
|
318
|
+
* The file is then read back and its server map compared with `entries`.
|
|
319
|
+
*/
|
|
320
|
+
export async function writeAuthoritativeMcpRegistrationFile(target, entries, deps) {
|
|
321
|
+
const api = pathApiForProvisioningPlatform(deps.platform);
|
|
322
|
+
let existing = {};
|
|
323
|
+
try {
|
|
324
|
+
const raw = await deps.readFile(target.filePath);
|
|
325
|
+
let parsed;
|
|
326
|
+
try {
|
|
327
|
+
parsed = JSON.parse(raw);
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
return { ok: false, error: `existing ${target.filePath} contains malformed JSON; not overwriting` };
|
|
331
|
+
}
|
|
332
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
333
|
+
return { ok: false, error: `existing ${target.filePath} is not a JSON object; not overwriting` };
|
|
334
|
+
}
|
|
335
|
+
existing = { ...parsed };
|
|
336
|
+
}
|
|
337
|
+
catch (err) {
|
|
338
|
+
const code = err && typeof err === "object" ? err.code : undefined;
|
|
339
|
+
if (code !== "ENOENT")
|
|
340
|
+
return { ok: false, error: `unable to read ${target.filePath}` };
|
|
341
|
+
}
|
|
342
|
+
const document = { ...existing, [target.topLevelKey]: { ...entries } };
|
|
343
|
+
try {
|
|
344
|
+
await deps.mkdir(api.dirname(target.filePath), { recursive: true });
|
|
345
|
+
await deps.writeFile(target.filePath, `${JSON.stringify(document, null, 2)}\n`);
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
return { ok: false, error: `failed to write ${target.filePath}` };
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
const readBack = JSON.parse(await deps.readFile(target.filePath));
|
|
352
|
+
const servers = readBack?.[target.topLevelKey];
|
|
353
|
+
if (JSON.stringify(servers) !== JSON.stringify(entries)) {
|
|
354
|
+
return { ok: false, error: `${target.filePath} did not read back as written` };
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
catch {
|
|
358
|
+
return { ok: false, error: `${target.filePath} could not be read back` };
|
|
359
|
+
}
|
|
360
|
+
return { ok: true };
|
|
361
|
+
}
|
|
284
362
|
/**
|
|
285
363
|
* Write (or merge) the worktree's `.claude/settings.local.json` so the given
|
|
286
364
|
* `.mcp.json` server names are pre-approved via `enabledMcpjsonServers`. This
|
|
@@ -381,6 +459,25 @@ export async function provisionMcpRegistrationForWorktree(row, deps) {
|
|
|
381
459
|
if (row.status !== "created" || !row.path) {
|
|
382
460
|
return row;
|
|
383
461
|
}
|
|
462
|
+
// BAPI-1545: choose the authority BEFORE reading anything from the worktree.
|
|
463
|
+
if (deps.trustedRepoName !== undefined) {
|
|
464
|
+
const readGrant = deps.readMcpGrant ??
|
|
465
|
+
((repo) => readMcpGrant(repo, {
|
|
466
|
+
env: deps.env ?? process.env,
|
|
467
|
+
homedir: deps.homedir ?? os.homedir,
|
|
468
|
+
readFile: deps.readFile,
|
|
469
|
+
}));
|
|
470
|
+
let grant;
|
|
471
|
+
try {
|
|
472
|
+
grant = await readGrant(deps.trustedRepoName);
|
|
473
|
+
}
|
|
474
|
+
catch {
|
|
475
|
+
grant = { state: "unusable", reason: "the grant file could not be read" };
|
|
476
|
+
}
|
|
477
|
+
if (grant.state !== "absent") {
|
|
478
|
+
return provisionGrantMcpRegistration(row, row.path, deps.trustedRepoName, grant, deps);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
384
481
|
const read = await readBridgeConfig(row.path, { readFile: deps.readFile });
|
|
385
482
|
if (!read.ok) {
|
|
386
483
|
if (read.kind === "missing") {
|
|
@@ -422,6 +519,41 @@ export async function provisionMcpRegistrationForWorktree(row, deps) {
|
|
|
422
519
|
}
|
|
423
520
|
return result;
|
|
424
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* BAPI-1545: the grant path. Never reads `.bridge/config`. Writes BOTH
|
|
524
|
+
* registration files authoritatively from the grant, reads them back, and
|
|
525
|
+
* records the outcome on `row.mcpGrantRegistration` so the executor can refuse
|
|
526
|
+
* a spawn whose registration is not authoritative. Trust pre-approval stays
|
|
527
|
+
* best-effort.
|
|
528
|
+
*/
|
|
529
|
+
async function provisionGrantMcpRegistration(row, worktreePath, trustedRepoName, grant, deps) {
|
|
530
|
+
const normalized = normalizeWorktreePathForRegistration(worktreePath, deps);
|
|
531
|
+
if (!normalized.ok) {
|
|
532
|
+
const error = `MCP provisioning failed: ${normalized.error}`;
|
|
533
|
+
return { ...row, status: "spawn-failed", error, mcpGrantRegistration: { ok: false, error } };
|
|
534
|
+
}
|
|
535
|
+
const entries = buildGrantMcpServerEntries(grant, trustedRepoName, normalized.path, deps.mcpServerInvocation, deps.bridgeApiBaseUrl);
|
|
536
|
+
let result = { ...row, mcpRegistrationForm: deps.mcpServerInvocation.form };
|
|
537
|
+
if (grant.state === "unusable")
|
|
538
|
+
result = withWarning(result, UNUSABLE_GRANT_WARNING);
|
|
539
|
+
for (const target of getWorktreeMcpRegistrationTargets(normalized.path, deps.platform)) {
|
|
540
|
+
const written = await writeAuthoritativeMcpRegistrationFile(target, entries, deps);
|
|
541
|
+
if (!written.ok) {
|
|
542
|
+
const error = `MCP provisioning failed: ${written.error}`;
|
|
543
|
+
return { ...result, status: "spawn-failed", error, mcpGrantRegistration: { ok: false, error } };
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
const serverNames = Object.keys(entries);
|
|
547
|
+
result = { ...result, mcpGrantRegistration: { ok: true, expectedServerNames: [...serverNames].sort() } };
|
|
548
|
+
if (deps.mcpServerInvocation.form !== "absolute-build-path") {
|
|
549
|
+
result = withWarning(result, "MCP registration used npm-channel fallback because an on-disk build entry was not resolvable.");
|
|
550
|
+
}
|
|
551
|
+
const trust = await writeClaudeServerTrustSettings(normalized.path, serverNames, deps);
|
|
552
|
+
if (!trust.ok) {
|
|
553
|
+
result = withWarning(result, `Claude MCP trust pre-approval skipped: ${trust.error}`);
|
|
554
|
+
}
|
|
555
|
+
return result;
|
|
556
|
+
}
|
|
425
557
|
/**
|
|
426
558
|
* Provision MCP registrations for every created worktree row, in order.
|
|
427
559
|
* Per-row failures are isolated — a failed row never aborts later rows.
|
|
@@ -10,6 +10,7 @@ import path from "path";
|
|
|
10
10
|
import { getWorktreeHostTargets, hostAdapterForTarget } from "./mcp-host-targets.js";
|
|
11
11
|
import { MCP_SERVER_NAME, MCP_PACKAGE_NAME, resolveRegistrationKey, } from "./mcp-identity.js";
|
|
12
12
|
import { DUPLICATE_REGISTRATION_GUIDANCE } from "./launcher-config-inspection.js";
|
|
13
|
+
import { validateRepoName } from "./bridge-config.js";
|
|
13
14
|
/**
|
|
14
15
|
* Read and parse a JSON file.
|
|
15
16
|
*
|
|
@@ -63,8 +64,33 @@ function flagValue(args, flag) {
|
|
|
63
64
|
* In both forms `--target` must be `bapi` and `--project-root` must match the
|
|
64
65
|
* given worktree exactly. The server entry path is NOT required to sit under any
|
|
65
66
|
* particular username/path prefix.
|
|
67
|
+
*
|
|
68
|
+
* BAPI-1545: an executor worktree on the MCP-grant path carries a trailing
|
|
69
|
+
* `--grant-repo <repo>` pair. It is tolerated, and when present its value must
|
|
70
|
+
* be a usable repository name. Authority is never re-checked against
|
|
71
|
+
* `.bridge/config` here.
|
|
66
72
|
*/
|
|
67
73
|
export function isBridgeApiShimEntry(entry, worktreeRoot) {
|
|
74
|
+
if (!isMcpInvokeShimEntry(entry, worktreeRoot))
|
|
75
|
+
return false;
|
|
76
|
+
const args = entry.args.filter((a) => typeof a === "string");
|
|
77
|
+
if (flagValue(args, "--target") !== "bapi")
|
|
78
|
+
return false;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* BAPI-1545: the same shape check for any shim target, so a granted server's
|
|
83
|
+
* registration (`--target <name> --project-root <worktree> --grant-repo <repo>`)
|
|
84
|
+
* can be recognized. A granted entry must carry `--grant-repo`.
|
|
85
|
+
*/
|
|
86
|
+
export function isGrantedShimEntry(entry, worktreeRoot, target) {
|
|
87
|
+
if (!isMcpInvokeShimEntry(entry, worktreeRoot))
|
|
88
|
+
return false;
|
|
89
|
+
const args = entry.args.filter((a) => typeof a === "string");
|
|
90
|
+
return flagValue(args, "--target") === target && flagValue(args, "--grant-repo") !== undefined;
|
|
91
|
+
}
|
|
92
|
+
/** The shared shim shape: launcher form, `mcp-invoke`, project root, and an optional valid `--grant-repo`. */
|
|
93
|
+
function isMcpInvokeShimEntry(entry, worktreeRoot) {
|
|
68
94
|
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
69
95
|
return false;
|
|
70
96
|
const candidate = entry;
|
|
@@ -85,10 +111,13 @@ export function isBridgeApiShimEntry(entry, worktreeRoot) {
|
|
|
85
111
|
}
|
|
86
112
|
if (!args.includes("mcp-invoke"))
|
|
87
113
|
return false;
|
|
88
|
-
if (flagValue(args, "--target") !== "bapi")
|
|
89
|
-
return false;
|
|
90
114
|
if (flagValue(args, "--project-root") !== worktreeRoot)
|
|
91
115
|
return false;
|
|
116
|
+
if (args.includes("--grant-repo")) {
|
|
117
|
+
const repo = flagValue(args, "--grant-repo");
|
|
118
|
+
if (repo === undefined || !validateRepoName(repo).ok)
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
92
121
|
return true;
|
|
93
122
|
}
|
|
94
123
|
/**
|
|
@@ -50,7 +50,10 @@ export function isTransientNpxEntryPath(entryPath) {
|
|
|
50
50
|
* `nodeExecutable` is returned as the standalone `command`, never concatenated
|
|
51
51
|
* with the server entry path, so `EPIC_IMPLEMENTER_NODE_PATH` can substitute it later.
|
|
52
52
|
*/
|
|
53
|
-
export function buildMcpShimCommand(invocation, target, absoluteWorktreePath) {
|
|
53
|
+
export function buildMcpShimCommand(invocation, target, absoluteWorktreePath, grantRepo) {
|
|
54
|
+
// BAPI-1545: `--grant-repo` is appended ONLY on the grant path, after the
|
|
55
|
+
// legacy arguments, so a call without it is byte-identical to before.
|
|
56
|
+
const grantArgs = grantRepo === undefined ? [] : ["--grant-repo", grantRepo];
|
|
54
57
|
if (invocation.form === "absolute-build-path") {
|
|
55
58
|
return {
|
|
56
59
|
command: invocation.nodeExecutable,
|
|
@@ -61,6 +64,7 @@ export function buildMcpShimCommand(invocation, target, absoluteWorktreePath) {
|
|
|
61
64
|
target,
|
|
62
65
|
"--project-root",
|
|
63
66
|
absoluteWorktreePath,
|
|
67
|
+
...grantArgs,
|
|
64
68
|
],
|
|
65
69
|
};
|
|
66
70
|
}
|
|
@@ -74,6 +78,7 @@ export function buildMcpShimCommand(invocation, target, absoluteWorktreePath) {
|
|
|
74
78
|
target,
|
|
75
79
|
"--project-root",
|
|
76
80
|
absoluteWorktreePath,
|
|
81
|
+
...grantArgs,
|
|
77
82
|
],
|
|
78
83
|
};
|
|
79
84
|
}
|