@bridge_gpt/mcp-server 0.2.34 → 0.2.37

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 (109) hide show
  1. package/README.md +490 -366
  2. package/build/agent-capabilities/probe-context.js +8 -1
  3. package/build/agent-capabilities/probes.js +7 -1
  4. package/build/agents.generated.js +1 -1
  5. package/build/base-url.js +79 -0
  6. package/build/bridge-api-urls.js +9 -0
  7. package/build/chain-orchestrator.js +93 -15
  8. package/build/claude-review-workflow.js +264 -0
  9. package/build/claude-user-config-doctor.js +317 -0
  10. package/build/cli-release.js +53 -0
  11. package/build/commands.generated.js +6 -5
  12. package/build/conductor/bridge-api-client.js +393 -4
  13. package/build/conductor/deny-enforcement-preflight.js +1 -0
  14. package/build/conductor/done-gate.js +44 -5
  15. package/build/conductor/epic-reconcile.js +6 -0
  16. package/build/conductor/install-doctor.js +462 -0
  17. package/build/conductor-bin.js +3 -3
  18. package/build/conductor-bundle-artifacts.js +37 -15
  19. package/build/credential-store.js +205 -4
  20. package/build/direct-ticket-tools.js +70 -0
  21. package/build/doctor.js +473 -81
  22. package/build/executor/cli.js +83 -6
  23. package/build/executor/credentials.js +39 -11
  24. package/build/executor/deps.js +32 -1
  25. package/build/executor/env.js +71 -28
  26. package/build/executor/heartbeat.js +138 -17
  27. package/build/executor/http-client.js +49 -8
  28. package/build/executor/index.js +4 -0
  29. package/build/executor/job-errors.js +4 -0
  30. package/build/executor/job-runner.js +530 -20
  31. package/build/executor/observation.js +130 -0
  32. package/build/executor/permissions.js +114 -8
  33. package/build/executor/preflight.js +127 -8
  34. package/build/executor/prompt-spec.js +51 -0
  35. package/build/executor/runner.js +23 -2
  36. package/build/executor/service-unit.js +876 -0
  37. package/build/executor/test-clock.js +75 -3
  38. package/build/executor/types.js +4 -18
  39. package/build/executor/worker-command.js +73 -12
  40. package/build/executor/worker-config-isolation.js +287 -0
  41. package/build/executor/worker-finalization.js +68 -14
  42. package/build/executor/worktree.js +46 -4
  43. package/build/index.js +1039 -237
  44. package/build/init.js +503 -111
  45. package/build/install-bridge-conductor.js +491 -0
  46. package/build/install-bridge.js +1188 -247
  47. package/build/install-reexec.js +233 -0
  48. package/build/launcher-config-inspection.js +351 -0
  49. package/build/mcp-host-config.js +11 -1
  50. package/build/mcp-install-state.js +32 -0
  51. package/build/mcp-invoke.js +49 -6
  52. package/build/mcp-provisioning.js +52 -13
  53. package/build/mcp-registration-doctor.js +14 -5
  54. package/build/notifications.js +553 -0
  55. package/build/pipeline-orchestrator.js +146 -4
  56. package/build/pipeline-utils.js +3 -0
  57. package/build/pipelines.generated.js +32 -13
  58. package/build/plan-execution-ledger.js +550 -0
  59. package/build/plan-phase-routing.js +272 -0
  60. package/build/plane/alembic-head.js +110 -0
  61. package/build/plane/build-freshness.js +167 -0
  62. package/build/plane/cli.js +480 -0
  63. package/build/plane/defaults.js +266 -0
  64. package/build/plane/manifest.js +377 -0
  65. package/build/plane/member-logs.js +147 -0
  66. package/build/plane/member-roster.js +147 -0
  67. package/build/plane/preflight.js +289 -0
  68. package/build/plane/shutdown.js +195 -0
  69. package/build/plane/status.js +125 -0
  70. package/build/plane/supervisor.js +569 -0
  71. package/build/plane/test-fakes.js +156 -0
  72. package/build/plane/types.js +75 -0
  73. package/build/readme.generated.js +1 -1
  74. package/build/run-unit-tests-launcher.js +259 -0
  75. package/build/setup-epic.js +772 -28
  76. package/build/sfcc/log-gate.js +38 -11
  77. package/build/sfcc/log-query.js +55 -15
  78. package/build/sfcc/ocapi-shape.js +51 -14
  79. package/build/sfcc/output.js +41 -11
  80. package/build/sfcc/permissions.js +24 -2
  81. package/build/sfcc/read-projection.js +181 -0
  82. package/build/sfcc/read-result.js +158 -0
  83. package/build/sfcc/reads-custom-object-def.js +29 -18
  84. package/build/sfcc/reads-site-preference.js +75 -29
  85. package/build/sfcc/reads-system-object.js +40 -34
  86. package/build/sfcc/sfcc-result.js +106 -0
  87. package/build/sfcc/tool-wrapper.js +56 -13
  88. package/build/sfcc/write-grants.js +45 -22
  89. package/build/sfcc/write-guard.js +21 -13
  90. package/build/sfcc/write-result.js +61 -14
  91. package/build/sfcc/write-tool-common.js +126 -32
  92. package/build/sfcc/writes-system-object.js +11 -50
  93. package/build/start-tickets-prereqs.js +129 -0
  94. package/build/start-tickets.js +17 -13
  95. package/build/ticket-backend-metadata.js +59 -0
  96. package/build/ticket-key-utils.js +92 -0
  97. package/build/tool-error-envelope.js +71 -0
  98. package/build/tool-surface-gating.js +72 -0
  99. package/build/update-status.js +102 -0
  100. package/build/upgrade-advice.js +47 -0
  101. package/build/upgrade-cli.js +412 -110
  102. package/build/version.generated.js +1 -1
  103. package/build/worktree-core.js +73 -0
  104. package/docs/CONDUCTOR.md +132 -6
  105. package/docs/install/mcp-tool-integrations.md +29 -21
  106. package/package.json +9 -6
  107. package/pipelines/implement-ticket.json +19 -4
  108. package/build/conductor/supervisor-judgment-python.js +0 -141
  109. package/build/conductor/supervisor-judgment.js +0 -215
@@ -1,215 +0,0 @@
1
- /**
2
- * LLM judgment boundary for the conductor supervisor (BAPI-396, conductor C4).
3
- *
4
- * The LLM is JUDGMENT-ONLY. It is consulted solely to classify ambiguous stalls
5
- * and to draft short escalation text — compact snapshot in, strict JSON out. It
6
- * NEVER executes privileged actions and is NEVER the source of truth: a
7
- * malformed, disabled, exhausted, or timed-out model call degrades to a
8
- * deterministic assessment. This module is pure prompt/parse/budget logic with
9
- * an injectable client and emits NO events.
10
- */
11
- /** Raised when a model response cannot be trusted as a valid judgment. */
12
- export class SupervisorJudgmentError extends Error {
13
- constructor(message) {
14
- super(message);
15
- this.name = "SupervisorJudgmentError";
16
- }
17
- }
18
- /** Classifications the supervisor accepts from the judgment model. */
19
- export const ALLOWED_JUDGMENT_CLASSIFICATIONS = new Set([
20
- "progressing",
21
- "ambiguous",
22
- "stuck",
23
- "blocked",
24
- "unknown",
25
- ]);
26
- /**
27
- * Build the judgment-only system prompt. Uses `## HEADERS ##` sections, states
28
- * the model only classifies stalls / drafts escalation text, prohibits claiming
29
- * to execute actions, and requires strict JSON output.
30
- */
31
- export function buildSupervisorAssessmentSystemPrompt() {
32
- return [
33
- "## ROLE ##",
34
- "You are a read-only watchdog assistant for a multi-agent coding supervisor.",
35
- "You classify whether a worker appears stuck and optionally draft a short, human-readable escalation note.",
36
- "",
37
- "## HARD CONSTRAINTS ##",
38
- "- You ONLY classify ambiguous stalls and draft escalation text.",
39
- "- You have NO ability to take actions. Never claim to have executed, killed, merged, retried, or fixed anything.",
40
- "- You are NEVER the source of truth; deterministic signals override your judgment.",
41
- "- Do not request or reveal secrets, tokens, or raw payloads.",
42
- "",
43
- "## OUTPUT FORMAT ##",
44
- "Return STRICT JSON only — no prose, no markdown fences. The object must have exactly these keys:",
45
- ' "classification": one of "progressing" | "ambiguous" | "stuck" | "blocked" | "unknown"',
46
- ' "confidence": a number between 0 and 1',
47
- ' "should_escalate": a boolean',
48
- ' "reason": a short machine reason string',
49
- ' "draft_escalation_text": a short human-readable string, or null',
50
- ].join("\n");
51
- }
52
- /**
53
- * Build the user prompt from a compact judgment request. The dynamic JSON
54
- * context is wrapped in triple quotes; only compact, secret-free fields are
55
- * included (the request itself must already be secret-free).
56
- */
57
- export function buildSupervisorAssessmentUserPrompt(request) {
58
- const compact = {
59
- run_id: request.run_id,
60
- candidate: {
61
- reason: request.candidate.reason,
62
- state: request.candidate.state,
63
- liveness: request.candidate.liveness,
64
- elapsed_ms: request.candidate.elapsed_ms,
65
- context: request.candidate.context,
66
- },
67
- worker: request.worker,
68
- };
69
- return [
70
- "## SUPERVISOR SNAPSHOT ##",
71
- "Classify the worker situation below and decide whether it warrants escalation.",
72
- "",
73
- '"""',
74
- JSON.stringify(compact, null, 2),
75
- '"""',
76
- ].join("\n");
77
- }
78
- /** Top-level keys that, if present, mark a response as action-like (rejected). */
79
- const ACTION_LIKE_KEYS = new Set([
80
- "executed",
81
- "action",
82
- "actions",
83
- "command",
84
- "commands",
85
- "kill",
86
- "killed",
87
- "merge",
88
- "merged",
89
- "transition",
90
- "deleted",
91
- "wrote",
92
- "mutated",
93
- "ran",
94
- ]);
95
- /** Phrases in drafted text that assert a privileged action was performed. */
96
- const ACTION_LIKE_PHRASES = [
97
- /\bi (?:have )?(?:killed|merged|executed|ran|deleted|restarted|retried|fixed|committed|pushed)\b/i,
98
- /\bhas been (?:killed|merged|executed|restarted|deleted)\b/i,
99
- /\bworker (?:killed|terminated|restarted)\b/i,
100
- ];
101
- /** Parse a JSON value (string or already-parsed object). */
102
- function asObject(raw) {
103
- let value = raw;
104
- if (typeof raw === "string") {
105
- try {
106
- value = JSON.parse(raw);
107
- }
108
- catch {
109
- throw new SupervisorJudgmentError("judgment response is not valid JSON");
110
- }
111
- }
112
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
113
- throw new SupervisorJudgmentError("judgment response must be a JSON object");
114
- }
115
- return value;
116
- }
117
- /**
118
- * Parse + validate a strict-JSON judgment response. Rejects non-objects,
119
- * malformed JSON, unknown classifications, missing/typed-wrong fields, and any
120
- * action-like output (forbidden keys or draft text claiming privileged work).
121
- * Throws {@link SupervisorJudgmentError} on any violation.
122
- */
123
- export function parseSupervisorJudgmentResponse(raw) {
124
- const obj = asObject(raw);
125
- // Reject action-like keys outright.
126
- for (const key of Object.keys(obj)) {
127
- if (ACTION_LIKE_KEYS.has(key.toLowerCase())) {
128
- throw new SupervisorJudgmentError(`judgment response contains forbidden action key "${key}"`);
129
- }
130
- }
131
- const classification = obj.classification;
132
- if (typeof classification !== "string" || !ALLOWED_JUDGMENT_CLASSIFICATIONS.has(classification)) {
133
- throw new SupervisorJudgmentError("judgment response has an invalid 'classification'");
134
- }
135
- const confidence = obj.confidence;
136
- if (typeof confidence !== "number" || !Number.isFinite(confidence) || confidence < 0 || confidence > 1) {
137
- throw new SupervisorJudgmentError("judgment response 'confidence' must be a number in [0,1]");
138
- }
139
- const shouldEscalate = obj.should_escalate;
140
- if (typeof shouldEscalate !== "boolean") {
141
- throw new SupervisorJudgmentError("judgment response 'should_escalate' must be a boolean");
142
- }
143
- const reason = obj.reason;
144
- if (typeof reason !== "string" || reason.trim().length === 0) {
145
- throw new SupervisorJudgmentError("judgment response 'reason' must be a non-empty string");
146
- }
147
- let draft = null;
148
- const draftRaw = obj.draft_escalation_text;
149
- if (draftRaw !== null && draftRaw !== undefined) {
150
- if (typeof draftRaw !== "string") {
151
- throw new SupervisorJudgmentError("judgment response 'draft_escalation_text' must be a string or null");
152
- }
153
- for (const pattern of ACTION_LIKE_PHRASES) {
154
- if (pattern.test(draftRaw)) {
155
- throw new SupervisorJudgmentError("judgment draft text claims a privileged action");
156
- }
157
- }
158
- draft = draftRaw;
159
- }
160
- return {
161
- classification,
162
- confidence,
163
- should_escalate: shouldEscalate,
164
- reason,
165
- draft_escalation_text: draft,
166
- };
167
- }
168
- /** Build the deterministic, degraded-mode assessment for a candidate. */
169
- function degradedAssessment(candidate, reason) {
170
- return {
171
- classification: "unknown",
172
- confidence: 0,
173
- // Degraded mode never SUPPRESSES a surfaced stall: a candidate the
174
- // deterministic layer already flagged stays escalated.
175
- should_escalate: true,
176
- reason: `${candidate.reason}:${reason}`,
177
- draft_escalation_text: null,
178
- source: "degraded",
179
- };
180
- }
181
- /**
182
- * Assess one escalation candidate. Enforces the LLM budget BEFORE calling the
183
- * injectable client: when the LLM is disabled, the budget is exhausted, or the
184
- * client times out / errors / returns malformed output, a deterministic
185
- * degraded-mode assessment is returned. On a successful call `budget.used_calls`
186
- * is incremented. This function emits NO events.
187
- */
188
- export async function assessSupervisorCandidate(request, config, budget, client) {
189
- const candidate = request.candidate;
190
- if (!config.llm_enabled || !budget.enabled || budget.max_calls <= 0) {
191
- return degradedAssessment(candidate, "llm_disabled");
192
- }
193
- if (budget.used_calls >= budget.max_calls) {
194
- return degradedAssessment(candidate, "budget_exhausted");
195
- }
196
- // Count the attempt against the budget regardless of outcome so a flaky model
197
- // cannot be retried unboundedly within a single run.
198
- budget.used_calls += 1;
199
- let response;
200
- try {
201
- const raw = await client(request);
202
- response = parseSupervisorJudgmentResponse(raw);
203
- }
204
- catch {
205
- return degradedAssessment(candidate, "llm_failed");
206
- }
207
- return {
208
- classification: response.classification,
209
- confidence: response.confidence,
210
- should_escalate: response.should_escalate,
211
- reason: response.reason,
212
- draft_escalation_text: response.draft_escalation_text,
213
- source: "llm",
214
- };
215
- }