@debugg-ai/debugg-ai-mcp 1.0.46 → 1.0.48
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.
|
@@ -132,72 +132,69 @@ export async function testPageChangesHandler(input, context, progressCallback) {
|
|
|
132
132
|
const executionUuid = executeResponse.executionUuid;
|
|
133
133
|
logger.info(`Execution queued: ${executionUuid}`);
|
|
134
134
|
// --- Poll ---
|
|
135
|
-
//
|
|
136
|
-
//
|
|
135
|
+
// Progress phases:
|
|
136
|
+
// 1-3: MCP setup (tunnel, template, queue) — already sent above
|
|
137
|
+
// 4-6: Backend setup (trigger, browser.setup, subworkflow starting)
|
|
138
|
+
// 7-27: Agent steps (mapped from state.stepsTaken)
|
|
139
|
+
// 28: Complete
|
|
140
|
+
const BACKEND_SETUP_END = 6;
|
|
137
141
|
let lastStepsTaken = 0;
|
|
138
|
-
let lastNodeCount = 0;
|
|
139
142
|
let observedMaxSteps = MAX_EXEC_STEPS;
|
|
140
143
|
const finalExecution = await client.workflows.pollExecution(executionUuid, async (exec) => {
|
|
141
144
|
// Keep the tunnel alive while the workflow is actively running
|
|
142
145
|
if (ctx.tunnelId)
|
|
143
146
|
touchTunnelById(ctx.tunnelId);
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
// Prefer actual brain.step node count over API stepsTaken (which may lag)
|
|
148
|
-
const stepsTaken = Math.max(brainStepCount, exec.state?.stepsTaken ?? 0);
|
|
149
|
-
if (nodeCount !== lastNodeCount || stepsTaken !== lastStepsTaken || exec.status !== 'pending') {
|
|
150
|
-
lastNodeCount = nodeCount;
|
|
147
|
+
const nodes = exec.nodeExecutions ?? [];
|
|
148
|
+
const stepsTaken = Math.max(nodes.filter(n => n.nodeType === 'brain.step').length, exec.state?.stepsTaken ?? 0);
|
|
149
|
+
if (stepsTaken !== lastStepsTaken) {
|
|
151
150
|
lastStepsTaken = stepsTaken;
|
|
152
|
-
logger.info(`Execution status: ${exec.status}, nodes: ${
|
|
151
|
+
logger.info(`Execution status: ${exec.status}, nodes: ${nodes.length}, steps: ${stepsTaken}`);
|
|
153
152
|
}
|
|
154
|
-
if (progressCallback)
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
if (!progressCallback)
|
|
154
|
+
return;
|
|
155
|
+
// --- Compute progress number ---
|
|
156
|
+
let execProgress;
|
|
157
|
+
let message;
|
|
158
|
+
if (stepsTaken > 0) {
|
|
159
|
+
// Agent is actively stepping — map into slots 7..27
|
|
160
|
+
if (stepsTaken > observedMaxSteps)
|
|
157
161
|
observedMaxSteps = stepsTaken + 5;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
const stepSlots = TOTAL_STEPS - BACKEND_SETUP_END - 1; // 21 slots
|
|
163
|
+
execProgress = BACKEND_SETUP_END + Math.max(1, Math.round((stepsTaken / observedMaxSteps) * stepSlots));
|
|
164
|
+
execProgress = Math.min(execProgress, TOTAL_STEPS - 1);
|
|
165
|
+
// Use state.currentAction for the message (backend sends intent + actionType)
|
|
166
|
+
const ca = exec.state?.currentAction;
|
|
167
|
+
if (ca?.intent) {
|
|
168
|
+
const action = ca.actionType ?? ca.action_type ?? 'working';
|
|
169
|
+
message = `Step ${stepsTaken}: [${action}] ${ca.intent}`;
|
|
164
170
|
}
|
|
165
171
|
else {
|
|
166
|
-
|
|
167
|
-
execProgress = SETUP_STEPS + 1;
|
|
172
|
+
message = `Agent evaluating... (step ${stepsTaken})`;
|
|
168
173
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
message = `Agent evaluating app... (step ${stepsTaken})`;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
else if (nodeCount === 0) {
|
|
190
|
-
message = 'Browser agent starting up...';
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
message = 'Browser ready, agent navigating...';
|
|
194
|
-
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// No agent steps yet — show backend setup progress from node transitions
|
|
177
|
+
const hasSubworkflow = nodes.some(n => n.nodeType === 'subworkflow.run');
|
|
178
|
+
const hasBrowserSetup = nodes.some(n => n.nodeType === 'browser.setup');
|
|
179
|
+
const browserReady = nodes.some(n => n.nodeType === 'browser.setup' && n.status === 'success');
|
|
180
|
+
if (browserReady || hasSubworkflow) {
|
|
181
|
+
execProgress = BACKEND_SETUP_END;
|
|
182
|
+
message = 'Browser ready, agent starting...';
|
|
183
|
+
}
|
|
184
|
+
else if (hasBrowserSetup) {
|
|
185
|
+
execProgress = SETUP_STEPS + 2;
|
|
186
|
+
message = 'Launching browser...';
|
|
187
|
+
}
|
|
188
|
+
else if (nodes.length > 0) {
|
|
189
|
+
execProgress = SETUP_STEPS + 1;
|
|
190
|
+
message = 'Workflow triggered, preparing...';
|
|
195
191
|
}
|
|
196
192
|
else {
|
|
197
|
-
|
|
193
|
+
execProgress = SETUP_STEPS + 1;
|
|
194
|
+
message = 'Waiting for execution to start...';
|
|
198
195
|
}
|
|
199
|
-
await progressCallback({ progress: execProgress, total: TOTAL_STEPS, message });
|
|
200
196
|
}
|
|
197
|
+
await progressCallback({ progress: execProgress, total: TOTAL_STEPS, message });
|
|
201
198
|
}, abortController.signal);
|
|
202
199
|
const duration = Date.now() - startTime;
|
|
203
200
|
// --- Format result ---
|
package/dist/index.js
CHANGED
|
@@ -199,6 +199,18 @@ process.on('SIGTERM', async () => {
|
|
|
199
199
|
await Telemetry.shutdown();
|
|
200
200
|
process.exit(0);
|
|
201
201
|
});
|
|
202
|
+
process.on('unhandledRejection', (reason) => {
|
|
203
|
+
logger.error('Unhandled promise rejection', {
|
|
204
|
+
error: reason instanceof Error ? reason.message : String(reason),
|
|
205
|
+
stack: reason instanceof Error ? reason.stack : undefined,
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
process.on('uncaughtException', (error) => {
|
|
209
|
+
logger.error('Uncaught exception', {
|
|
210
|
+
error: error.message,
|
|
211
|
+
stack: error.stack,
|
|
212
|
+
});
|
|
213
|
+
});
|
|
202
214
|
/**
|
|
203
215
|
* Start the server
|
|
204
216
|
*/
|
|
@@ -14,6 +14,7 @@ let initialized = false;
|
|
|
14
14
|
* Resolve the current project context: repo → project → environments → credentials.
|
|
15
15
|
* Safe to call multiple times — caches after first successful resolution.
|
|
16
16
|
*/
|
|
17
|
+
const STARTUP_TIMEOUT_MS = 10_000; // hard cap so we never block MCP connection
|
|
17
18
|
export async function resolveProjectContext() {
|
|
18
19
|
if (initialized)
|
|
19
20
|
return cached;
|
|
@@ -23,6 +24,24 @@ export async function resolveProjectContext() {
|
|
|
23
24
|
logger.info('No git repo detected — skipping project context');
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
27
|
+
try {
|
|
28
|
+
// Race against a timeout so a slow/unreachable backend never blocks startup
|
|
29
|
+
return await Promise.race([
|
|
30
|
+
resolveProjectContextInner(repoName),
|
|
31
|
+
new Promise((resolve) => {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
logger.warn('Project context resolution timed out — continuing without it');
|
|
34
|
+
resolve(null);
|
|
35
|
+
}, STARTUP_TIMEOUT_MS);
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
logger.warn(`Failed to resolve project context: ${err}`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function resolveProjectContextInner(repoName) {
|
|
26
45
|
try {
|
|
27
46
|
const client = new DebuggAIServerClient(config.api.key);
|
|
28
47
|
await client.init();
|
|
@@ -71,13 +71,20 @@ export const createWorkflowsService = (tx) => {
|
|
|
71
71
|
});
|
|
72
72
|
return execution;
|
|
73
73
|
}
|
|
74
|
+
// Check abort before sleeping to avoid missing a signal fired between polls
|
|
75
|
+
if (signal?.aborted) {
|
|
76
|
+
throw new Error(`Polling cancelled for execution ${executionUuid}`);
|
|
77
|
+
}
|
|
74
78
|
await new Promise((resolve, reject) => {
|
|
75
79
|
const timer = setTimeout(resolve, POLL_INTERVAL_MS);
|
|
76
80
|
if (signal) {
|
|
77
|
-
|
|
81
|
+
const onAbort = () => { clearTimeout(timer); reject(new Error(`Polling cancelled for execution ${executionUuid}`)); };
|
|
82
|
+
if (signal.aborted) {
|
|
78
83
|
clearTimeout(timer);
|
|
79
84
|
reject(new Error(`Polling cancelled for execution ${executionUuid}`));
|
|
80
|
-
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
81
88
|
}
|
|
82
89
|
});
|
|
83
90
|
}
|
|
@@ -68,11 +68,11 @@ export function buildTestPageChangesTool(ctx) {
|
|
|
68
68
|
},
|
|
69
69
|
username: {
|
|
70
70
|
type: "string",
|
|
71
|
-
description: "
|
|
71
|
+
description: "A real, existing account email for the target app. Do NOT invent or guess credentials — use one from the available credentials listed above, or ask the user. The browser agent will type this into the login form."
|
|
72
72
|
},
|
|
73
73
|
password: {
|
|
74
74
|
type: "string",
|
|
75
|
-
description: "
|
|
75
|
+
description: "The real password for the username above. Do NOT guess or use placeholder passwords — use credentials from the list above or ask the user."
|
|
76
76
|
},
|
|
77
77
|
repoName: {
|
|
78
78
|
type: "string",
|