@bridge_gpt/mcp-server 0.2.41 → 0.2.42

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 (73) hide show
  1. package/README.md +10 -10
  2. package/build/agent-capabilities/cli.js +2 -1
  3. package/build/agent-launchers/claude-executor-adapter.js +17 -4
  4. package/build/claude-user-config-doctor.js +42 -11
  5. package/build/cli-release.js +2 -1
  6. package/build/commands.generated.js +4 -4
  7. package/build/conduct-epic/bridge-client.js +354 -113
  8. package/build/conduct-epic/checkpoint-store.js +17 -0
  9. package/build/conduct-epic/cli.js +752 -99
  10. package/build/conduct-epic/cut-protocol.js +327 -0
  11. package/build/conduct-epic/spawn.js +14 -2
  12. package/build/conductor/bridge-api-client.js +27 -1
  13. package/build/conductor/cli.js +46 -1
  14. package/build/conductor/doctor.js +101 -16
  15. package/build/conductor/epic-reconcile.js +72 -19
  16. package/build/conductor/epic-runtime.js +15 -3
  17. package/build/conductor/errors.js +47 -0
  18. package/build/conductor/git-hooks.js +205 -11
  19. package/build/conductor/install-doctor.js +230 -1
  20. package/build/conductor/local-merge.js +130 -28
  21. package/build/conductor/tools.js +32 -3
  22. package/build/conductor/worker-ledger-cli.js +27 -1
  23. package/build/conductor-bin.js +15 -15
  24. package/build/credentials-cli.js +3 -2
  25. package/build/doctor.js +107 -41
  26. package/build/executor/cli.js +48 -1
  27. package/build/executor/env.js +21 -0
  28. package/build/executor/index-scope.js +39 -0
  29. package/build/executor/job-log-registry.js +69 -0
  30. package/build/executor/job-runner.js +148 -26
  31. package/build/executor/live-worker-registry.js +83 -0
  32. package/build/executor/observation.js +167 -6
  33. package/build/executor/platform.js +147 -3
  34. package/build/executor/process.js +58 -14
  35. package/build/executor/runner.js +235 -48
  36. package/build/executor/test-clock.js +3 -2
  37. package/build/index-scope-contract.js +96 -0
  38. package/build/index.js +153 -204
  39. package/build/init.js +83 -22
  40. package/build/install-bridge-conductor.js +323 -14
  41. package/build/install-bridge.js +202 -38
  42. package/build/install-doctor.js +23 -9
  43. package/build/install-reexec.js +2 -1
  44. package/build/launcher-config-inspection.js +83 -22
  45. package/build/mcp-host-config.js +331 -67
  46. package/build/mcp-host-targets.js +45 -21
  47. package/build/mcp-identity.js +92 -0
  48. package/build/mcp-install-state.js +94 -1
  49. package/build/mcp-invoke.js +2 -1
  50. package/build/mcp-provisioning.js +45 -12
  51. package/build/mcp-registration-doctor.js +35 -13
  52. package/build/mcp-server-invocation.js +4 -2
  53. package/build/merge-pull-request.js +208 -9
  54. package/build/pipelines.generated.js +3 -3
  55. package/build/plane/defaults.js +4 -1
  56. package/build/plane/preflight.js +81 -10
  57. package/build/plane/test-fakes.js +9 -1
  58. package/build/readme.generated.js +1 -1
  59. package/build/regression-check.js +3 -2
  60. package/build/review-tickets.js +8 -7
  61. package/build/run-unit-tests-launcher.js +74 -1
  62. package/build/schedule-run.js +3 -2
  63. package/build/setup-epic.js +453 -78
  64. package/build/sfcc/tool-wrapper.js +15 -0
  65. package/build/start-tickets-prereqs.js +11 -6
  66. package/build/start-tickets.js +91 -85
  67. package/build/update-check.js +3 -2
  68. package/build/upgrade-advice.js +2 -1
  69. package/build/upgrade-cli.js +50 -18
  70. package/build/version.generated.js +1 -1
  71. package/docs/CONDUCTOR.md +22 -0
  72. package/docs/install/mcp-tool-integrations.md +19 -3
  73. package/package.json +2 -2
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The opaque index-scope declaration carried across a process boundary (BAPI-844).
3
+ *
4
+ * An index scope is the per-epic shadow index research is routed to. A pilot
5
+ * ticket has no `epic_ticket_status` / `epic_runs` row, so server-side membership
6
+ * discovery proves "non-epic" and routes to the canonical index — which is why the
7
+ * scope has to be DECLARED by the worker rather than discovered for it.
8
+ *
9
+ * This module owns the three names that declaration travels under, and nothing
10
+ * else:
11
+ *
12
+ * - {@link INDEX_SCOPE_ENV_VAR} — the worker environment variable,
13
+ * - {@link INDEX_SCOPE_HEADER} — the out-of-band Bridge API request header,
14
+ * - {@link validateOptionalIndexScope} — the shared shape check.
15
+ *
16
+ * TOKEN-OPAQUE BY CONSTRUCTION. The validator checks type, length, and shape and
17
+ * derives NOTHING from the value: not a repository, not a branch, not an epic run,
18
+ * not a shadow repository name. Those derivations are server-side, because the
19
+ * scope id is a server-minted identity (R14) and a worker that could compute a
20
+ * shadow name from it would be authorizing itself.
21
+ *
22
+ * VALIDATION IS NOT AUTHORIZATION. A well-formed declaration only means the value
23
+ * is shaped like a scope id. Whether the declaring worker may USE that scope is
24
+ * decided server-side, against the authenticated repository — see
25
+ * `api/agent_flows/code_writer/library/research_repo_resolver.py`. Nothing here
26
+ * may ever be read as a permission check.
27
+ */
28
+ /**
29
+ * The environment variable a scoped worker carries.
30
+ *
31
+ * Deliberately NOT in `executor/env.ts`'s `ALLOWED_ENV_KEYS`, and explicitly on
32
+ * its `EXPLICIT_DENY_KEYS`: the value must arrive from an explicit, validated
33
+ * spawn option, never inherited from the executor's (or an operator's) ambient
34
+ * environment. This mirrors `BAPI_BASE_BRANCH` exactly — an ambient value that
35
+ * could override a run-scoped decision is the failure mode both keys avoid.
36
+ */
37
+ export const INDEX_SCOPE_ENV_VAR = "BAPI_INDEX_SCOPE";
38
+ /**
39
+ * The Bridge API request header a scoped MCP worker attaches.
40
+ *
41
+ * Out-of-band on purpose. Every request body keeps the CANONICAL `repo_name`,
42
+ * because repository identity is what authorization, configuration, billing, and
43
+ * Jira side effects are keyed by; only research RETRIEVAL consumes this header.
44
+ */
45
+ export const INDEX_SCOPE_HEADER = "X-Bapi-Index-Scope";
46
+ /**
47
+ * The server-minted scope-id shape: exactly 32 lowercase hexadecimal characters.
48
+ *
49
+ * Mirrors the server's own `_SCOPE_ID_RE` (`api/library/db/epic_shadow_index.py`),
50
+ * which is what `mint_scope_id()` (a `uuid4().hex`) produces. Anchored at both
51
+ * ends, so a longer string containing a valid token is rejected rather than
52
+ * partially matched.
53
+ */
54
+ const INDEX_SCOPE_PATTERN = /^[0-9a-f]{32}$/;
55
+ /**
56
+ * The ONE configuration-error message every malformed declaration produces.
57
+ *
58
+ * Fixed and value-free by design: an error that echoed the submitted value would
59
+ * push an opaque routing token into terminal output, worker logs, conductor
60
+ * events, and error reports — all places this token must never appear. Every
61
+ * rejection is therefore indistinguishable in its text, which is deliberate.
62
+ */
63
+ export const INDEX_SCOPE_CONFIGURATION_ERROR = `${INDEX_SCOPE_ENV_VAR} is not a valid index-scope declaration. ` +
64
+ "Expected a server-minted scope identity; the value was not logged.";
65
+ /** Thrown for a malformed declaration. Its message is always the fixed text above. */
66
+ export class IndexScopeConfigurationError extends Error {
67
+ constructor() {
68
+ super(INDEX_SCOPE_CONFIGURATION_ERROR);
69
+ this.name = "IndexScopeConfigurationError";
70
+ }
71
+ }
72
+ /**
73
+ * Validate an OPTIONAL scope declaration.
74
+ *
75
+ * Returns `undefined` for an absent declaration (`undefined`, `null`, or an
76
+ * empty/blank string) — absence is the ordinary unscoped case and must stay
77
+ * indistinguishable from today's behavior. Returns a well-formed value BYTE-FOR-BYTE
78
+ * unchanged: no trimming, no case folding, no normalization, because a value the
79
+ * server minted is the only value the server will recognize.
80
+ *
81
+ * Throws {@link IndexScopeConfigurationError} for anything else, including a
82
+ * non-string. Failing loudly is the point: silently dropping a malformed
83
+ * declaration would route a scoped worker's research at the canonical index while
84
+ * every observable signal still said "scoped".
85
+ */
86
+ export function validateOptionalIndexScope(value) {
87
+ if (value === undefined || value === null)
88
+ return undefined;
89
+ if (typeof value !== "string")
90
+ throw new IndexScopeConfigurationError();
91
+ if (value.trim().length === 0)
92
+ return undefined;
93
+ if (!INDEX_SCOPE_PATTERN.test(value))
94
+ throw new IndexScopeConfigurationError();
95
+ return value;
96
+ }