@vulcan-energy/mcp-helper 0.2.3 → 0.2.4
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.
- package/THIRD_PARTY_NOTICES.md +185 -0
- package/dist/bin/vulcan-mcp-helper.js +30 -23
- package/dist/hem-target-runtime/browser-adapter.mjs +25 -11
- package/dist/hem-target-runtime/host.mjs +11033 -1146
- package/dist/hem-target-runtime/python-worker.mjs +183 -7
- package/dist/hem-target-runtime/release-manifests.mjs +3 -3
- package/dist/hem-target-runtime/rust-worker.mjs +199 -8
- package/dist/server.js +29 -22
- package/package.json +1 -1
- package/wasm/wasm_version.json +10 -10
- package/wasm/wasm_wrapper.js +41 -7
- package/wasm/wasm_wrapper_bg.wasm +0 -0
|
@@ -129,6 +129,8 @@ export async function runTargetBrowser(options, dependencies = {}) {
|
|
|
129
129
|
catch { throw new Error('Target execution needs playwright-core and installed Google Chrome. Install the supported MCP helper runtime dependencies.'); }
|
|
130
130
|
const workspace = await realpath(options.workspace);
|
|
131
131
|
const jobId = options.jobId ?? `target_${randomUUID()}`;
|
|
132
|
+
// Every record this run writes carries its start: status readers order runs by it, not by file times.
|
|
133
|
+
const startedAt = new Date().toISOString();
|
|
132
134
|
if (!/^[a-zA-Z0-9_-]+$/.test(jobId) || (options.configName && !/^[a-zA-Z0-9_. -]+$/.test(options.configName))) throw new Error('Invalid target job/config name');
|
|
133
135
|
const contained = path => {
|
|
134
136
|
if (typeof path !== 'string' || path.includes('\\')) throw new Error('Invalid workspace path');
|
|
@@ -167,11 +169,17 @@ export async function runTargetBrowser(options, dependencies = {}) {
|
|
|
167
169
|
const progress = value => {
|
|
168
170
|
if (options.operation !== 'batch') return Promise.resolve();
|
|
169
171
|
// Download callbacks can overlap. Preserve ordering through the final status.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
// Status readers poll this file: write a new file and rename it over the old, so none sees it truncated.
|
|
173
|
+
const file = `output/progress_${jobId}.json`;
|
|
174
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
175
|
+
progressWrites = progressWrites.catch(() => {}).then(async () => {
|
|
176
|
+
await write(temporary, JSON.stringify({
|
|
177
|
+
job_id: jobId, config_name: options.configName, startedAt, ...value, targetBundleId: manifest?.bundleId ?? bundleId,
|
|
178
|
+
status: ['completed', 'error'].includes(value.status) ? value.status : 'running',
|
|
179
|
+
percentage: value.progress ?? (value.total ? Math.round(value.completed / value.total * 100) : 0),
|
|
180
|
+
}));
|
|
181
|
+
await rename(contained(temporary), contained(file));
|
|
182
|
+
});
|
|
175
183
|
return progressWrites;
|
|
176
184
|
};
|
|
177
185
|
const lockPath = join(workspace, '.hem-target-active');
|
|
@@ -218,18 +226,24 @@ export async function runTargetBrowser(options, dependencies = {}) {
|
|
|
218
226
|
await page.exposeFunction('targetCliProgress', progress);
|
|
219
227
|
await progress({ status: 'running', progress: 0 });
|
|
220
228
|
await page.goto(origin);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
// Return the message, not the thrown error: Playwright appends the in-page stack to it.
|
|
230
|
+
const outcome = await page.evaluate(async request => {
|
|
231
|
+
try {
|
|
232
|
+
const { run } = await import('/host.mjs');
|
|
233
|
+
return { result: await run(request) };
|
|
234
|
+
} catch (error) { return { error: error instanceof Error ? error.message : String(error) }; }
|
|
235
|
+
}, { manifest, operation: options.operation, csv: options.csv, config: options.config, configName: options.configName, jobId, startedAt });
|
|
225
236
|
if (interrupted) throw interrupted;
|
|
237
|
+
if ('error' in outcome) throw new Error(outcome.error);
|
|
238
|
+
const { result } = outcome;
|
|
226
239
|
await progress({ status: 'completed', progress: 100, targetBundleId: manifest.bundleId, ...(result?.warnings?.length ? { warnings: result.warnings } : {}) });
|
|
227
240
|
return result;
|
|
228
241
|
} catch (caught) {
|
|
229
242
|
const error = interrupted ?? caught;
|
|
230
243
|
if (lock) {
|
|
231
|
-
|
|
232
|
-
await
|
|
244
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
245
|
+
for (const [path, marker] of markers) if (marker.status === 'running') await write(path, JSON.stringify({ ...marker, status: 'failed', error: message })).catch(() => {});
|
|
246
|
+
await progress({ status: 'error', error: message }).catch(() => {});
|
|
233
247
|
}
|
|
234
248
|
throw error;
|
|
235
249
|
} finally {
|