clementine-agent 1.8.0 → 1.8.2
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/dist/cli/browser.d.ts +19 -0
- package/dist/cli/browser.js +78 -4
- package/dist/cli/dashboard.js +2 -2
- package/dist/tools/admin-tools.js +8 -0
- package/package.json +1 -1
package/dist/cli/browser.d.ts
CHANGED
|
@@ -32,5 +32,24 @@ export declare function cmdBrowserEnable(): Promise<void>;
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function maybePromptBrowserHarness(): Promise<void>;
|
|
34
34
|
export declare function cmdBrowserDisable(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Non-interactive connect — meant for callers that aren't a TTY (MCP tool,
|
|
37
|
+
* daemon-internal callers). Returns a structured result instead of prompting
|
|
38
|
+
* or printing decorative output. Caller decides how to surface failures.
|
|
39
|
+
*
|
|
40
|
+
* Behavior:
|
|
41
|
+
* - CDP already up → { ok: true, alreadyConnected: true }
|
|
42
|
+
* - No Chrome running → launch with flag, poll, return result
|
|
43
|
+
* - Chrome running without flag → if allowQuitChrome=false, refuse with
|
|
44
|
+
* a clear message; if true, quit + relaunch (DESTRUCTIVE — closes tabs).
|
|
45
|
+
*/
|
|
46
|
+
export declare function runConnectNonInteractive(opts?: {
|
|
47
|
+
allowQuitChrome?: boolean;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
ok: boolean;
|
|
50
|
+
message: string;
|
|
51
|
+
alreadyConnected?: boolean;
|
|
52
|
+
needsForceQuit?: boolean;
|
|
53
|
+
}>;
|
|
35
54
|
export declare function cmdBrowserConnect(): Promise<void>;
|
|
36
55
|
//# sourceMappingURL=browser.d.ts.map
|
package/dist/cli/browser.js
CHANGED
|
@@ -354,11 +354,85 @@ export async function cmdBrowserDisable() {
|
|
|
354
354
|
console.log();
|
|
355
355
|
}
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
358
|
-
*
|
|
357
|
+
* Non-interactive connect — meant for callers that aren't a TTY (MCP tool,
|
|
358
|
+
* daemon-internal callers). Returns a structured result instead of prompting
|
|
359
|
+
* or printing decorative output. Caller decides how to surface failures.
|
|
359
360
|
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
361
|
+
* Behavior:
|
|
362
|
+
* - CDP already up → { ok: true, alreadyConnected: true }
|
|
363
|
+
* - No Chrome running → launch with flag, poll, return result
|
|
364
|
+
* - Chrome running without flag → if allowQuitChrome=false, refuse with
|
|
365
|
+
* a clear message; if true, quit + relaunch (DESTRUCTIVE — closes tabs).
|
|
366
|
+
*/
|
|
367
|
+
export async function runConnectNonInteractive(opts = {}) {
|
|
368
|
+
if (await probeCdp()) {
|
|
369
|
+
return { ok: true, alreadyConnected: true, message: 'Already connected — Chrome is running with remote debugging on :9222.' };
|
|
370
|
+
}
|
|
371
|
+
if (process.platform !== 'darwin' && process.platform !== 'linux') {
|
|
372
|
+
return {
|
|
373
|
+
ok: false,
|
|
374
|
+
message: 'Auto-connect is only supported on macOS and Linux. Launch Chrome manually with --remote-debugging-port=9222.',
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
if (isChromeRunning() && !opts.allowQuitChrome) {
|
|
378
|
+
return {
|
|
379
|
+
ok: false,
|
|
380
|
+
needsForceQuit: true,
|
|
381
|
+
message: 'Chrome is running without remote debugging. Connecting requires quitting Chrome and relaunching with --remote-debugging-port=9222 (this closes your current Chrome windows). Re-run with force_quit=true to proceed, or quit Chrome yourself first and call this again.',
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (isChromeRunning() && opts.allowQuitChrome) {
|
|
385
|
+
try {
|
|
386
|
+
if (process.platform === 'darwin') {
|
|
387
|
+
execSync('osascript -e \'tell application "Google Chrome" to quit\'', { stdio: 'pipe' });
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
try {
|
|
391
|
+
execSync('pkill -TERM -x "google-chrome|chromium|chrome"', { stdio: 'pipe' });
|
|
392
|
+
}
|
|
393
|
+
catch { /* ok */ }
|
|
394
|
+
}
|
|
395
|
+
for (let i = 0; i < 15; i++) {
|
|
396
|
+
if (!isChromeRunning())
|
|
397
|
+
break;
|
|
398
|
+
await new Promise(r => setTimeout(r, 300));
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
catch {
|
|
402
|
+
return { ok: false, message: 'Failed to quit Chrome. Quit it manually and try again.' };
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
try {
|
|
406
|
+
if (process.platform === 'darwin') {
|
|
407
|
+
execSync('open -na "Google Chrome" --args --remote-debugging-port=9222', { stdio: 'pipe' });
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
const candidates = ['google-chrome', 'chromium', 'chrome'];
|
|
411
|
+
const bin = candidates.find(commandExists);
|
|
412
|
+
if (!bin) {
|
|
413
|
+
return { ok: false, message: 'No Chrome / Chromium binary found in PATH.' };
|
|
414
|
+
}
|
|
415
|
+
execSync(`nohup ${bin} --remote-debugging-port=9222 >/dev/null 2>&1 &`, { stdio: 'pipe' });
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
catch (e) {
|
|
419
|
+
return { ok: false, message: `Failed to launch Chrome: ${String(e).slice(0, 200)}` };
|
|
420
|
+
}
|
|
421
|
+
for (let i = 0; i < 24; i++) {
|
|
422
|
+
await new Promise(r => setTimeout(r, 250));
|
|
423
|
+
if (await probeCdp()) {
|
|
424
|
+
return { ok: true, message: 'Connected — Chrome is running with remote debugging on :9222.' };
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
ok: false,
|
|
429
|
+
message: 'Chrome launched, but CDP socket isn\'t responding yet. Check that Chrome started successfully, then verify with: curl http://localhost:9222/json/version',
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Interactive CLI connect — wraps runConnectNonInteractive with TTY prompts
|
|
434
|
+
* and decorative output. Used by `clementine browser connect` and the auto-
|
|
435
|
+
* prompt flow.
|
|
362
436
|
*/
|
|
363
437
|
async function runConnect(opts = {}) {
|
|
364
438
|
// 1. Already connected? Done.
|
package/dist/cli/dashboard.js
CHANGED
|
@@ -21292,8 +21292,8 @@ async function refreshMemoryHealth() {
|
|
|
21292
21292
|
html += '<div style="font-weight:600;margin-bottom:4px">Retrieval running on sparse vectors for ' + missing.toLocaleString() + ' chunks</div>';
|
|
21293
21293
|
html += '<div style="font-size:12px;color:var(--text-muted)">Backfill builds 768-dim neural embeddings for semantic search. First run downloads ~440MB.</div>';
|
|
21294
21294
|
html += '</div>';
|
|
21295
|
-
html += '<button class="btn-sm" onclick="memoryHealthAction(
|
|
21296
|
-
html += '<button class="btn-sm" onclick="memoryHealthAction(
|
|
21295
|
+
html += '<button class="btn-sm" onclick="memoryHealthAction(\\'reembed-dense\\', { limit: 200 })" title="Embed up to 200 chunks now">Backfill 200</button>';
|
|
21296
|
+
html += '<button class="btn-sm" onclick="memoryHealthAction(\\'reembed-dense\\', { limit: 2000 })" title="Embed up to 2000 chunks now (slower)">Backfill 2000</button>';
|
|
21297
21297
|
html += '</div></div>';
|
|
21298
21298
|
}
|
|
21299
21299
|
|
|
@@ -1873,5 +1873,13 @@ export function registerAdminTools(server) {
|
|
|
1873
1873
|
logger.info({ jobName: job_name, runCount: updated.runCount }, 'Cron progress saved');
|
|
1874
1874
|
return textResult(`Progress saved for "${job_name}" (run #${updated.runCount}). ${(completedItems?.length ?? 0)} items completed, ${(updated.pendingItems?.length ?? 0)} pending.`);
|
|
1875
1875
|
});
|
|
1876
|
+
// ── Browser harness — chat-driven Chrome connect ────────────────────
|
|
1877
|
+
server.tool('browser_connect', 'Connect Chrome to the browser harness via CDP. Idempotent — if Chrome is already running with remote debugging on :9222 this is a no-op. If no Chrome is running, launches Chrome with --remote-debugging-port=9222. If Chrome is running normally without the flag, refuses unless force_quit=true (which closes the user\'s open tabs). Use this so the user can connect from any chat channel without dropping to the terminal.', {
|
|
1878
|
+
force_quit: z.boolean().optional().describe('If true, quit any running Chrome before relaunching with the debug flag. DESTRUCTIVE — closes the user\'s open tabs. Only set after the user has explicitly confirmed they want this. Defaults to false.'),
|
|
1879
|
+
}, async ({ force_quit }) => {
|
|
1880
|
+
const { runConnectNonInteractive } = await import('../cli/browser.js');
|
|
1881
|
+
const result = await runConnectNonInteractive({ allowQuitChrome: !!force_quit });
|
|
1882
|
+
return textResult(result.message);
|
|
1883
|
+
});
|
|
1876
1884
|
}
|
|
1877
1885
|
//# sourceMappingURL=admin-tools.js.map
|