@bridge_gpt/mcp-server 0.2.73 → 0.2.75

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.
Files changed (123) hide show
  1. package/README.md +14 -7
  2. package/build/agent-launchers/claude-executor-adapter.js +12 -0
  3. package/build/agent-launchers/prompt.js +9 -21
  4. package/build/agents.generated.js +4 -4
  5. package/build/authored-plan.js +542 -0
  6. package/build/bridge-config.js +7 -1
  7. package/build/bridge-permissions.js +11 -0
  8. package/build/command-provisioning.js +4 -3
  9. package/build/commands.generated.js +6 -6
  10. package/build/conductor/bridge-api-client.js +692 -47
  11. package/build/conductor/command-drift.js +1 -1
  12. package/build/conductor/declared-extras.js +335 -0
  13. package/build/conductor/doctor.js +2 -0
  14. package/build/conductor/driver-pass-output.js +104 -0
  15. package/build/conductor/driver-pass.js +571 -0
  16. package/build/conductor/epic-branch-ci-inspection.js +61 -16
  17. package/build/conductor/epic-implementer-cli.js +370 -93
  18. package/build/conductor/epic-server-sfcc-upload.js +1567 -0
  19. package/build/conductor/epic-server-sfcc.js +58 -80
  20. package/build/conductor/epic-server.js +57 -4
  21. package/build/conductor/gate-discovery.js +253 -13
  22. package/build/conductor/gate-settings-review.js +58 -25
  23. package/build/conductor/launch-plan.js +58 -12
  24. package/build/conductor/open-decision-phrases.js +50 -0
  25. package/build/conductor/prerequisite-inputs.js +181 -14
  26. package/build/connect-github-api.js +18 -0
  27. package/build/connect-github.js +35 -18
  28. package/build/credential-delivery.js +280 -0
  29. package/build/credential-launch-safety.js +142 -0
  30. package/build/credential-materialization.js +91 -16
  31. package/build/credential-references-node-deps.js +29 -0
  32. package/build/credential-references.js +1394 -0
  33. package/build/credential-references.test-fixtures.js +211 -0
  34. package/build/credential-scan-conventions.js +145 -0
  35. package/build/credential-scan.js +517 -0
  36. package/build/credential-store.js +50 -0
  37. package/build/credentials-cli.js +252 -3
  38. package/build/dependency-install-declarations.js +47 -1
  39. package/build/docs.generated.js +8 -1
  40. package/build/doctor.js +41 -0
  41. package/build/drive-epic.js +684 -49
  42. package/build/epic-branch-ci-summary.js +18 -1
  43. package/build/epic-capability-statement.js +71 -3
  44. package/build/epic-ci-workflow-drift.js +52 -13
  45. package/build/epic-ci-workflow-install.js +31 -6
  46. package/build/epic-ci-workflow-v3.js +273 -0
  47. package/build/epic-ci-workflow.js +129 -7
  48. package/build/epic-implementer-bin.js +288 -83
  49. package/build/epic-implementer-bundle-cli.js +61 -0
  50. package/build/epic-implementer-claude-hook-bin.js +1 -1
  51. package/build/epic-implementer-env.js +3 -4
  52. package/build/epic-integration-pr.js +5 -2
  53. package/build/epic-launch-context.js +102 -7
  54. package/build/epic-server-record.js +30 -15
  55. package/build/executor/completion-contract.js +24 -1
  56. package/build/executor/credential-delivery-step.js +168 -0
  57. package/build/executor/deps.js +3 -1
  58. package/build/executor/env.js +39 -1
  59. package/build/executor/epic-server-context.js +23 -7
  60. package/build/executor/gate-qualification-job.js +193 -23
  61. package/build/executor/gate-qualification-tests-ran.js +232 -0
  62. package/build/executor/guarded-fast-forward-push.js +13 -8
  63. package/build/executor/job-runner.js +167 -738
  64. package/build/executor/job-type-wrappers.js +734 -0
  65. package/build/executor/permissions.js +85 -3
  66. package/build/executor/preflight.js +6 -2
  67. package/build/executor/process-containment.js +8 -1
  68. package/build/executor/prompt-spec.js +37 -3
  69. package/build/executor/required-verification.js +28 -2
  70. package/build/executor/runner.js +4 -1
  71. package/build/executor/types.js +9 -0
  72. package/build/executor/worker-database.js +6 -1
  73. package/build/executor/worker-guard-hook.js +24 -2
  74. package/build/executor-launch.js +4 -2
  75. package/build/generated/ticket-status.js +20 -0
  76. package/build/git-exclude-lock.js +187 -0
  77. package/build/index.js +589 -326
  78. package/build/install-bridge-conductor-answers.js +112 -22
  79. package/build/install-bridge-conductor-apply.js +38 -1
  80. package/build/install-bridge-conductor-assessment.js +482 -53
  81. package/build/install-bridge-conductor-compact.js +29 -2
  82. package/build/install-bridge-conductor-contracts.js +10 -1
  83. package/build/install-bridge-conductor-gate.js +379 -89
  84. package/build/install-bridge-conductor-setup.js +46 -8
  85. package/build/install-bridge-conductor-trial-report.js +170 -0
  86. package/build/install-bridge-conductor.js +925 -141
  87. package/build/install-bridge.js +88 -11
  88. package/build/install-doctor.js +38 -8
  89. package/build/install-sfcc-detection.js +120 -0
  90. package/build/install-sfcc-setup.js +185 -0
  91. package/build/mcp-grant-candidates.js +108 -96
  92. package/build/mcp-invoke.js +168 -4
  93. package/build/mcp-provisioning.js +21 -4
  94. package/build/mcp-server-invocation.js +13 -0
  95. package/build/merge-workflow-install.js +9 -1
  96. package/build/pipelines.generated.js +8 -7
  97. package/build/plan-generation.js +17 -0
  98. package/build/plane/status.js +8 -2
  99. package/build/printed-remedy-commands.js +59 -0
  100. package/build/project-root.js +40 -0
  101. package/build/readme.generated.js +1 -1
  102. package/build/repository-state-paths.js +5 -2
  103. package/build/repository-toolchains.js +16 -7
  104. package/build/scripts/saved-commands-config-field-driver.js +65 -0
  105. package/build/setup-epic.js +126 -16
  106. package/build/sfcc/credentials.js +3 -2
  107. package/build/sfcc/hostname.js +98 -2
  108. package/build/sfcc/tool-wrapper.js +6 -95
  109. package/build/start-tickets.js +193 -29
  110. package/build/test-support/executor-source-files.js +200 -0
  111. package/build/testing-config-client.js +25 -2
  112. package/build/third-party-mcp-targets.js +35 -4
  113. package/build/v2-readiness-requirements.js +5 -1
  114. package/build/version.generated.js +3 -3
  115. package/build/with-credentials.js +208 -0
  116. package/build/worker-guard-hook-bin.js +2 -2
  117. package/build/worktree-credential-delivery.js +340 -0
  118. package/docs/EPIC-IMPLEMENTER.md +4 -4
  119. package/docs/install/github-app.md +79 -92
  120. package/package.json +1 -1
  121. package/build/conductor/epic-reconcile.js +0 -603
  122. package/build/conductor/epic-runtime.js +0 -2020
  123. package/build/conductor/epic-state.js +0 -774
@@ -53,15 +53,67 @@ export function validateWorktreeRelativeCredentialPath(relPath) {
53
53
  // ---------------------------------------------------------------------------
54
54
  // Materialization
55
55
  // ---------------------------------------------------------------------------
56
+ function errnoCode(err) {
57
+ return err && typeof err === "object" ? err.code : undefined;
58
+ }
59
+ function isWithin(child, root) {
60
+ const rel = path.relative(root, child);
61
+ return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
62
+ }
63
+ function failure(reason, error) {
64
+ return { ok: false, reason, error };
65
+ }
66
+ /**
67
+ * BAPI-1647: prove every EXISTING parent of `destPath` (from the worktree root
68
+ * down) canonicalizes to a location under `realRoot`. A parent the worktree
69
+ * turned into a link pointing elsewhere is `dest_unsafe`; the first absent
70
+ * component ends the walk (everything below it is absent too); any error other
71
+ * than `ENOENT` is `dest_unavailable`.
72
+ */
73
+ async function checkParentChain(worktreeRoot, relDest, realRoot, deps) {
74
+ const segments = relDest.split(/[\\/]+/).filter((s) => s.length > 0 && s !== ".");
75
+ let current = worktreeRoot;
76
+ for (const segment of segments.slice(0, -1)) {
77
+ current = path.join(current, segment);
78
+ let canonical;
79
+ try {
80
+ canonical = await deps.realpath(current);
81
+ }
82
+ catch (err) {
83
+ if (errnoCode(err) === "ENOENT")
84
+ return null;
85
+ return failure("dest_unavailable", `unable to inspect a parent directory of the credential destination`);
86
+ }
87
+ if (!isWithin(canonical, realRoot)) {
88
+ return failure("dest_unsafe", `refusing a credential destination whose parent resolves outside the worktree`);
89
+ }
90
+ }
91
+ return null;
92
+ }
56
93
  /**
57
94
  * Materialize a canonical credential file into a worktree. On non-Windows this
58
95
  * creates an idempotent symlink; on Windows it is gated (see module docs) and
59
96
  * copies nothing. Never overwrites an unrelated file or a foreign symlink.
97
+ *
98
+ * BAPI-1647 hardening:
99
+ * - only `ENOENT` from `lstat` means the destination is absent; any other
100
+ * inspection error is `dest_unavailable`, never "safe to create";
101
+ * - every existing parent is `realpath`-checked against the worktree root's
102
+ * `realpath`, before creating directories and again immediately before the
103
+ * link is made or an existing matching link is accepted, so a link the
104
+ * worktree controls cannot redirect the write;
105
+ * - a destination that became occupied between inspection and creation
106
+ * (`EEXIST`) is `dest_occupied`, never overwritten.
107
+ *
108
+ * Concurrency assumption: this runs before any worker exists in the worktree —
109
+ * on the executor after the worktree lock is held, on `start-tickets` before any
110
+ * tab opens — so the only party that could race the parent checks is not yet
111
+ * running.
60
112
  */
61
113
  export async function materializeFileCredentialForWorktree(spec, worktreeRoot, deps) {
62
114
  const validated = validateWorktreeRelativeCredentialPath(spec.worktreeRelativeDestPath);
63
115
  if (!validated.ok) {
64
- return { ok: false, error: validated.error };
116
+ return failure("invalid_dest", validated.error);
65
117
  }
66
118
  const destPath = path.join(worktreeRoot, validated.value);
67
119
  if (deps.platform === "win32") {
@@ -69,39 +121,62 @@ export async function materializeFileCredentialForWorktree(spec, worktreeRoot, d
69
121
  // settled. The structured action lets callers warn without failing the row.
70
122
  return { ok: true, action: "windows-gated" };
71
123
  }
72
- // Inspect the destination without following symlinks.
124
+ let realRoot;
73
125
  try {
74
- const existing = await deps.lstat(destPath);
126
+ realRoot = await deps.realpath(worktreeRoot);
127
+ }
128
+ catch {
129
+ return failure("dest_unavailable", "unable to resolve the worktree root");
130
+ }
131
+ const parents = await checkParentChain(worktreeRoot, validated.value, realRoot, deps);
132
+ if (parents)
133
+ return parents;
134
+ // Inspect the destination without following symlinks. Only ENOENT is absent.
135
+ let existing = null;
136
+ try {
137
+ existing = await deps.lstat(destPath);
138
+ }
139
+ catch (err) {
140
+ if (errnoCode(err) !== "ENOENT") {
141
+ return failure("dest_unavailable", `unable to inspect the credential destination at ${destPath}`);
142
+ }
143
+ }
144
+ if (existing) {
75
145
  if (existing.isSymbolicLink()) {
76
146
  let currentTarget;
77
147
  try {
78
148
  currentTarget = await deps.readlink(destPath);
79
149
  }
80
150
  catch {
81
- return { ok: false, error: `unable to inspect existing symlink at ${destPath}` };
151
+ return failure("dest_unavailable", `unable to inspect existing symlink at ${destPath}`);
82
152
  }
83
153
  if (currentTarget === spec.canonicalSourcePath) {
154
+ const recheck = await checkParentChain(worktreeRoot, validated.value, realRoot, deps);
155
+ if (recheck)
156
+ return recheck;
84
157
  return { ok: true, action: "already-present" };
85
158
  }
86
- return {
87
- ok: false,
88
- error: `refusing to overwrite an existing symlink at ${destPath} that points elsewhere`,
89
- };
159
+ return failure("dest_occupied", `refusing to overwrite an existing symlink at ${destPath} that points elsewhere`);
90
160
  }
91
- return {
92
- ok: false,
93
- error: `refusing to overwrite an existing file at ${destPath}`,
94
- };
161
+ return failure("dest_occupied", `refusing to overwrite an existing file at ${destPath}`);
162
+ }
163
+ try {
164
+ await deps.mkdir(path.dirname(destPath), { recursive: true });
95
165
  }
96
166
  catch {
97
- /* ENOENT (or otherwise absent) — safe to create below. */
167
+ return failure("create_failed", `failed to create credential symlink at ${destPath}`);
98
168
  }
169
+ const recheck = await checkParentChain(worktreeRoot, validated.value, realRoot, deps);
170
+ if (recheck)
171
+ return recheck;
99
172
  try {
100
- await deps.mkdir(path.dirname(destPath), { recursive: true });
101
173
  await deps.symlink(spec.canonicalSourcePath, destPath);
102
174
  }
103
- catch {
104
- return { ok: false, error: `failed to create credential symlink at ${destPath}` };
175
+ catch (err) {
176
+ if (errnoCode(err) === "EEXIST") {
177
+ return failure("dest_occupied", `refusing to overwrite a credential destination that appeared at ${destPath}`);
178
+ }
179
+ return failure("create_failed", `failed to create credential symlink at ${destPath}`);
105
180
  }
106
181
  return { ok: true, action: "created" };
107
182
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Node-backed dependencies for `credential-references.ts` (BAPI-1646). Kept in
3
+ * their own file so the reference module itself stays free of ambient `fs`/`os`
4
+ * access; the CLI and `doctor` build their defaults here.
5
+ */
6
+ import { chmod, lstat, mkdir, open, readFile, rename, stat, unlink, writeFile } from "fs/promises";
7
+ import os from "os";
8
+ export function createNodeCredentialReferenceDeps(env) {
9
+ return {
10
+ env,
11
+ homedir: os.homedir,
12
+ platform: process.platform,
13
+ readFile: (p) => readFile(p, "utf-8"),
14
+ readBytes: (p) => readFile(p),
15
+ lstat: (p) => lstat(p),
16
+ stat: (p) => stat(p),
17
+ };
18
+ }
19
+ export function createNodeCredentialReferenceApplyDeps(env) {
20
+ return {
21
+ ...createNodeCredentialReferenceDeps(env),
22
+ mkdir: (p, o) => mkdir(p, o),
23
+ writeFile: (p, d, o) => writeFile(p, d, o),
24
+ rename: (a, b) => rename(a, b),
25
+ chmod: (p, m) => chmod(p, m),
26
+ unlink: (p) => unlink(p),
27
+ open: (p, flags, mode) => open(p, flags, mode),
28
+ };
29
+ }