@bridge_gpt/mcp-server 0.2.59 → 0.2.62

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 (78) hide show
  1. package/README.md +181 -51
  2. package/build/agent-guidance.generated.js +1 -1
  3. package/build/agent-notes.js +7 -1
  4. package/build/commands.generated.js +6 -6
  5. package/build/conductor/bridge-api-client.js +406 -4
  6. package/build/conductor/doctor.js +255 -53
  7. package/build/conductor/epic-runtime.js +11 -2
  8. package/build/conductor/install-doctor.js +24 -2
  9. package/build/conductor/local-merge.js +319 -26
  10. package/build/conductor/merge-execution-contract.js +86 -0
  11. package/build/conductor/merge-execution-eligibility.js +130 -0
  12. package/build/conductor/readiness-sections.js +256 -16
  13. package/build/conductor/readiness.js +203 -29
  14. package/build/conductor/recovery-operations.js +8 -2
  15. package/build/connect-bitbucket-api.js +6 -1
  16. package/build/connect-bitbucket.js +398 -88
  17. package/build/credential-store.js +172 -0
  18. package/build/docs.generated.js +2 -2
  19. package/build/doctor.js +277 -15
  20. package/build/drive-epic.js +147 -12
  21. package/build/epic-implementer-bin.js +15 -15
  22. package/build/epic-implementer-claude-hook-bin.js +1 -1
  23. package/build/epic-implementer-env.js +43 -14
  24. package/build/epic-integration-pr.js +61 -15
  25. package/build/epic-launch-profile.js +455 -0
  26. package/build/executor/ci-rerun-job.js +269 -0
  27. package/build/executor/cli.js +40 -0
  28. package/build/executor/credentials.js +28 -1
  29. package/build/executor/env.js +60 -0
  30. package/build/executor/http-client.js +45 -1
  31. package/build/executor/index.js +21 -4
  32. package/build/executor/integration-job.js +759 -0
  33. package/build/executor/job-runner.js +218 -9
  34. package/build/executor/job-types.js +12 -2
  35. package/build/executor/merge-job.js +11 -2
  36. package/build/executor/observation.js +114 -7
  37. package/build/executor/runner.js +101 -1
  38. package/build/executor/service-lifecycle.js +136 -0
  39. package/build/executor/service-unit.js +427 -9
  40. package/build/executor/types.js +48 -0
  41. package/build/index.js +479 -240
  42. package/build/install-bridge-conductor.js +599 -14
  43. package/build/install-bridge.js +448 -46
  44. package/build/mcp-install-state.js +42 -4
  45. package/build/merge-pull-request.js +103 -10
  46. package/build/merge-workflow-codeowners.js +224 -0
  47. package/build/merge-workflow-config.js +187 -0
  48. package/build/merge-workflow-drift.js +97 -0
  49. package/build/merge-workflow-install.js +638 -0
  50. package/build/merge-workflow.js +956 -0
  51. package/build/pipelines.generated.js +3 -3
  52. package/build/plane/cli.js +24 -2
  53. package/build/plane/preflight.js +68 -0
  54. package/build/plane/supervisor.js +6 -0
  55. package/build/readme.generated.js +1 -1
  56. package/build/run-unit-tests-launcher.js +5 -0
  57. package/build/setup-epic.js +263 -38
  58. package/build/version.generated.js +3 -3
  59. package/package.json +3 -3
  60. package/build/conduct-epic/bridge-client.js +0 -773
  61. package/build/conduct-epic/checkpoint-store.js +0 -542
  62. package/build/conduct-epic/cli.js +0 -3145
  63. package/build/conduct-epic/cut-protocol.js +0 -392
  64. package/build/conduct-epic/lock.js +0 -302
  65. package/build/conduct-epic/pr-state.js +0 -286
  66. package/build/conduct-epic/spawn.js +0 -113
  67. package/build/conductor/cli.js +0 -1278
  68. package/build/conductor-bundle-cli.js +0 -256
  69. package/build/direct-ticket-tools.js +0 -70
  70. package/build/executor/reconcile-overlap-governance.js +0 -129
  71. package/build/implement-epic/bridge-client.js +0 -773
  72. package/build/implement-epic/checkpoint-store.js +0 -542
  73. package/build/implement-epic/cli.js +0 -3158
  74. package/build/implement-epic/cut-protocol.js +0 -392
  75. package/build/implement-epic/lock.js +0 -302
  76. package/build/implement-epic/pr-state.js +0 -286
  77. package/build/implement-epic/spawn.js +0 -113
  78. package/build/plan-epic-conductor-eligibility.js +0 -213
@@ -36,6 +36,24 @@
36
36
  * The command forms address user-domain (per-user) services directly:
37
37
  * `launchctl` against `gui/<uid>/<label>` on darwin, and `systemctl --user`
38
38
  * on linux.
39
+ *
40
+ * FOUR INDEPENDENT FACTS (BAPI-1137). A durable host is described by four
41
+ * separate observations, and no one of them implies another:
42
+ *
43
+ * 1. **Unit-content compliance** — what the generated/on-disk unit DECLARES
44
+ * (`service-unit.ts`). A perfect unit file can be sitting unloaded.
45
+ * 2. **Service-manager state** — what the manager is running RIGHT NOW
46
+ * ({@link inspectExecutorServiceState}). The manager may still be running a
47
+ * previously loaded definition rather than the current bytes on disk.
48
+ * 3. **Session persistence** — whether the host keeps running it once nobody is
49
+ * logged in ({@link inspectExecutorServiceDurability}). An `active` service
50
+ * with lingering off is active exactly until the operator logs out.
51
+ * 4. **Server-observed readiness** — whether BRIDGE has seen an executor claim.
52
+ * Only this one can produce `executor_ready`, and rule 4 above is why:
53
+ * nothing local, however green, is evidence for it.
54
+ *
55
+ * They are reported separately everywhere, and collapsing any pair of them would
56
+ * reintroduce exactly the dishonest-green this module is built to refuse.
39
57
  */
40
58
  import { posixShellQuote } from "../platform-escaping.js";
41
59
  /**
@@ -62,6 +80,10 @@ function renderCommand(command) {
62
80
  /**
63
81
  * Build the platform-specific start sequence.
64
82
  *
83
+ * UNCHANGED by BAPI-1137: start remains separately consented, one-shot, and
84
+ * non-retrying. The durability inspection added lower in this file is read-only
85
+ * and has no path to this function or to {@link startExecutorService}.
86
+ *
65
87
  * darwin: `launchctl bootstrap gui/<uid> <plist-path>`
66
88
  * linux: `systemctl --user daemon-reload`, then
67
89
  * `systemctl --user enable --now <unit-name>`
@@ -267,3 +289,117 @@ export async function inspectExecutorServiceState(target, run) {
267
289
  return { state: "inactive", probe };
268
290
  return { state: "unknown", probe };
269
291
  }
292
+ /**
293
+ * The Linux remediation, verbatim and in one place so the lifecycle module, the
294
+ * installer, and doctor cannot print three subtly different commands.
295
+ */
296
+ export const EXECUTOR_LINGER_REMEDIATION = "run `loginctl enable-linger $USER` yourself to keep this user's services running " +
297
+ "without an active login session (Bridge never runs it for you)";
298
+ /**
299
+ * The macOS prerequisite. A LaunchAgent bootstrapped into `gui/<uid>` lives in a
300
+ * user-login domain, which `launchctl(1)` documents as created when the user logs
301
+ * in at the GUI — so it needs that login to exist, and after a reboot it needs
302
+ * the user to log in again (automatic login, or a human at the keyboard).
303
+ */
304
+ export const EXECUTOR_MACOS_SESSION_REMEDIATION = "keep this user logged in at the GUI — a launchd LaunchAgent runs in the gui/<uid> " +
305
+ "login domain, so after a reboot the user must log in again (e.g. enable automatic " +
306
+ "login) for the executor to come back";
307
+ /**
308
+ * Build the strictly read-only durability prerequisite probe for a target.
309
+ *
310
+ * linux: `loginctl show-user <uid> --property=Linger` — a QUERY. `show-user`
311
+ * reads properties; it cannot enable or disable anything, which is what makes it
312
+ * safe to run unprompted where `enable-linger` would not be.
313
+ * darwin: `launchctl print gui/<uid>` — the login domain itself, not a service
314
+ * inside it. A zero exit means the GUI login domain exists for this uid.
315
+ *
316
+ * PURE: consults no runner, no environment, and no filesystem, so an
317
+ * incompletely described target is refused before anything could be executed.
318
+ */
319
+ export function buildExecutorServiceDurabilityProbe(target) {
320
+ if (typeof target.uid !== "number" || !Number.isInteger(target.uid) || target.uid < 0) {
321
+ return null;
322
+ }
323
+ if (target.platform === "linux") {
324
+ return {
325
+ stage: "loginctl show-user --property=Linger",
326
+ executable: "loginctl",
327
+ args: ["show-user", String(target.uid), "--property=Linger"],
328
+ };
329
+ }
330
+ if (target.platform === "darwin") {
331
+ return {
332
+ stage: "launchctl print gui",
333
+ executable: "launchctl",
334
+ args: ["print", `gui/${target.uid}`],
335
+ };
336
+ }
337
+ return null;
338
+ }
339
+ /**
340
+ * Inspect the local session/linger durability prerequisite. STRICTLY read-only:
341
+ * it issues exactly one query and never enables lingering, starts a service,
342
+ * reloads a manager, or writes anything.
343
+ *
344
+ * Everything the runner returns beyond a recognized state token is DISCARDED —
345
+ * stdout past the token, stderr entirely, and any thrown value — because a
346
+ * service manager's output can name paths, units, and environment values that
347
+ * have no place in operator-facing text.
348
+ */
349
+ export async function inspectExecutorServiceDurability(target, run) {
350
+ if (target.platform !== "darwin" && target.platform !== "linux") {
351
+ return { prerequisite: "not-applicable", probe: null, remediation: null };
352
+ }
353
+ const probe = buildExecutorServiceDurabilityProbe(target);
354
+ if (!probe)
355
+ return { prerequisite: "unverifiable", probe: null, remediation: null };
356
+ let exitCode;
357
+ let stdout;
358
+ try {
359
+ const result = await run(probe.executable, probe.args);
360
+ exitCode = typeof result?.exitCode === "number" ? result.exitCode : 1;
361
+ stdout = typeof result?.stdout === "string" ? result.stdout : "";
362
+ }
363
+ catch {
364
+ return { prerequisite: "unverifiable", probe, remediation: null };
365
+ }
366
+ if (target.platform === "darwin") {
367
+ // The login domain either exists for this uid or it does not; launchctl
368
+ // exposes no third answer here, and a non-zero exit is reported as an
369
+ // unavailable session rather than dressed up as a confirmed absence of
370
+ // durability the probe did not establish.
371
+ //
372
+ // A ZERO exit is NOT `configured`. It says the gui/<uid> domain exists at
373
+ // this instant — which it does whenever an operator runs `install conductor`
374
+ // or `doctor` from their own logged-in session — and a LaunchAgent in that
375
+ // domain is tied to the login, not to the machine being powered on. Calling
376
+ // it `configured` would let a renderer that means "survives logout" assert
377
+ // the opposite of what launchd guarantees, so darwin gets its own state and
378
+ // carries the session prerequisite as the thing to keep true.
379
+ if (exitCode === 0) {
380
+ return {
381
+ prerequisite: "session-bound",
382
+ probe,
383
+ remediation: EXECUTOR_MACOS_SESSION_REMEDIATION,
384
+ };
385
+ }
386
+ return {
387
+ prerequisite: "not-configured",
388
+ probe,
389
+ remediation: EXECUTOR_MACOS_SESSION_REMEDIATION,
390
+ };
391
+ }
392
+ if (exitCode !== 0)
393
+ return { prerequisite: "unverifiable", probe, remediation: null };
394
+ // `loginctl show-user --property=Linger` prints exactly `Linger=yes|no`. Only
395
+ // those two tokens are mapped; anything else is unverifiable rather than a
396
+ // guess derived from a format this module does not recognize.
397
+ const match = stdout.match(/^\s*Linger=(\S+)\s*$/m);
398
+ const value = match?.[1]?.toLowerCase();
399
+ if (value === "yes")
400
+ return { prerequisite: "configured", probe, remediation: null };
401
+ if (value === "no") {
402
+ return { prerequisite: "not-configured", probe, remediation: EXECUTOR_LINGER_REMEDIATION };
403
+ }
404
+ return { prerequisite: "unverifiable", probe, remediation: null };
405
+ }