@andorra-labs/code 0.1.8 → 0.1.10
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 +2 -1
- package/dist/src/account-presentation.d.ts +11 -0
- package/dist/src/account-presentation.js +29 -2
- package/dist/src/agent-execution.js +57 -4
- package/dist/src/agent-mcp.d.ts +12 -0
- package/dist/src/agent-mcp.js +81 -2
- package/dist/src/app-server/protocol.d.ts +120 -1
- package/dist/src/app-server/protocol.js +8 -1
- package/dist/src/app-server/reasoning.d.ts +0 -8
- package/dist/src/app-server/reasoning.js +15 -28
- package/dist/src/app-server.d.ts +32 -0
- package/dist/src/app-server.js +214 -21
- package/dist/src/auth/AuthManager.d.ts +15 -0
- package/dist/src/auth/AuthManager.js +66 -7
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +17 -1
- package/dist/src/auth/store.js +25 -2
- package/dist/src/browser-runner.js +1 -2
- package/dist/src/browser-server.js +10 -2
- package/dist/src/browser-session.js +6 -2
- package/dist/src/browser-stealth.d.ts +29 -0
- package/dist/src/browser-stealth.js +166 -0
- package/dist/src/browser-ui/app.js +123 -28
- package/dist/src/browser-ui/icons/chevron-right.svg +8 -0
- package/dist/src/browser-ui/index.html +8 -8
- package/dist/src/browser-ui/style.css +199 -171
- package/dist/src/browser-ui/tokens.css +198 -0
- package/dist/src/browser-view.d.ts +57 -9
- package/dist/src/browser-view.js +187 -36
- package/dist/src/cli.js +31 -9
- package/dist/src/coding-tools.js +9 -5
- package/dist/src/command-screens.js +4 -4
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +3 -2
- package/dist/src/completion-gates.d.ts +35 -0
- package/dist/src/completion-gates.js +25 -0
- package/dist/src/completion.d.ts +7 -1
- package/dist/src/completion.js +37 -4
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +2 -2
- package/dist/src/context-budget.d.ts +11 -0
- package/dist/src/context-budget.js +13 -0
- package/dist/src/decision/DecisionEngine.d.ts +5 -1
- package/dist/src/decision/DecisionManager.d.ts +1 -0
- package/dist/src/decision/DecisionManager.js +14 -3
- package/dist/src/decision/FactContinuations.d.ts +6 -0
- package/dist/src/decision/FactContinuations.js +9 -1
- package/dist/src/decision/FactServiceGate.js +1 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/hostedSkills.d.ts +37 -0
- package/dist/src/decision/hostedSkills.js +64 -0
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +10 -2
- package/dist/src/decision/providers/AndorraDecisionProvider.js +121 -10
- package/dist/src/default-graph.d.ts +11 -0
- package/dist/src/default-graph.js +20 -0
- package/dist/src/duration.d.ts +13 -2
- package/dist/src/duration.js +27 -3
- package/dist/src/file-diff.d.ts +105 -0
- package/dist/src/file-diff.js +244 -0
- package/dist/src/graph-manager-chat.d.ts +302 -0
- package/dist/src/graph-manager-chat.js +940 -0
- package/dist/src/graph-runner.js +6 -0
- package/dist/src/graph-server.d.ts +9 -0
- package/dist/src/graph-server.js +171 -20
- package/dist/src/graph-studio-features.js +2 -2
- package/dist/src/graph-sync.js +5 -2
- package/dist/src/graph-ui/app.js +369 -183
- package/dist/src/graph-ui/controls.css +55 -32
- package/dist/src/graph-ui/controls.js +85 -9
- package/dist/src/graph-ui/edge-router.js +114 -13
- package/dist/src/graph-ui/embed.js +32 -17
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +4 -4
- package/dist/src/graph-ui/library.css +4 -10
- package/dist/src/graph-ui/manager-markdown.js +155 -0
- package/dist/src/graph-ui/manager-state.js +191 -0
- package/dist/src/graph-ui/manager.css +161 -0
- package/dist/src/graph-ui/manager.js +700 -0
- package/dist/src/graph-ui/skill-picker.js +6 -6
- package/dist/src/graph-ui/studio-canvas.js +17 -15
- package/dist/src/graph-ui/studio.css +24 -23
- package/dist/src/graph-ui/studio.js +69 -48
- package/dist/src/graph-ui/style.css +128 -93
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +217 -151
- package/dist/src/graphs.d.ts +76 -2
- package/dist/src/graphs.js +172 -9
- package/dist/src/hardened-runtime.js +8 -2
- package/dist/src/mcp.d.ts +75 -0
- package/dist/src/mcp.js +240 -8
- package/dist/src/membership-errors.d.ts +14 -0
- package/dist/src/membership-errors.js +24 -1
- package/dist/src/membership.d.ts +20 -0
- package/dist/src/membership.js +45 -16
- package/dist/src/palette.d.ts +25 -8
- package/dist/src/palette.js +26 -8
- package/dist/src/provider-engine.d.ts +4 -4
- package/dist/src/provider-engine.js +39 -22
- package/dist/src/provider-keys.d.ts +5 -1
- package/dist/src/provider-keys.js +7 -3
- package/dist/src/provider-settings.d.ts +4 -1
- package/dist/src/provider-settings.js +46 -5
- package/dist/src/providers.d.ts +24 -0
- package/dist/src/providers.js +47 -2
- package/dist/src/qa/guidance.d.ts +26 -0
- package/dist/src/qa/guidance.js +46 -0
- package/dist/src/qa/index.d.ts +1 -8
- package/dist/src/qa/index.js +1 -16
- package/dist/src/qa/profile/QaProfile.d.ts +5 -1
- package/dist/src/qa/profile/QaProfile.js +6 -2
- package/dist/src/qa/runtime/ProcessManager.d.ts +20 -2
- package/dist/src/qa/runtime/ProcessManager.js +69 -13
- package/dist/src/qa/tools.d.ts +19 -1
- package/dist/src/qa/tools.js +20 -145
- package/dist/src/react-runtime.d.ts +11 -0
- package/dist/src/react-runtime.js +203 -53
- package/dist/src/remote/engine-pool.js +21 -6
- package/dist/src/run-progress.d.ts +6 -0
- package/dist/src/run-progress.js +7 -0
- package/dist/src/runtime.d.ts +8 -0
- package/dist/src/screen-selection.d.ts +38 -0
- package/dist/src/screen-selection.js +103 -0
- package/dist/src/session-changes.d.ts +117 -0
- package/dist/src/session-changes.js +796 -0
- package/dist/src/session-skills.d.ts +75 -0
- package/dist/src/session-skills.js +151 -0
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +6 -12
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/control-browser/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +8 -0
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/skills/bundled/web-gui-tester/SKILL.md +1 -1
- package/dist/src/stall-recovery.d.ts +33 -0
- package/dist/src/stall-recovery.js +83 -0
- package/dist/src/subagent-run.js +1 -2
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +1 -2
- package/dist/src/terminal-ui.d.ts +66 -22
- package/dist/src/terminal-ui.js +327 -92
- package/dist/src/tool-diff-stats.d.ts +9 -0
- package/dist/src/tool-diff-stats.js +20 -0
- package/dist/src/tool-names.d.ts +1 -1
- package/dist/src/tool-result-filter.js +1 -1
- package/dist/src/tools.js +26 -2
- package/dist/src/transcript.d.ts +11 -0
- package/dist/src/transcript.js +23 -3
- package/dist/src/types.d.ts +24 -4
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +55 -15
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/limits.md +9 -0
- package/docs/guides/desktop-app.md +1 -1
- package/docs/guides/graph-builder.md +16 -1
- package/docs/guides/tui.md +9 -9
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +203 -0
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +79 -0
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +182 -0
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +156 -0
- package/package.json +1 -1
- package/tests/chat-side-panel-test-plan.md +1 -1
- package/dist/src/qa/api/http-runner.d.ts +0 -3
- package/dist/src/qa/api/http-runner.js +0 -47
- package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
- package/dist/src/qa/git/ChangeDetector.js +0 -177
- package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
- package/dist/src/qa/git/DiffReviewer.js +0 -115
- package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
- package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
- package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
- package/dist/src/qa/orchestrator/MergeGate.js +0 -40
- package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
- package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
- package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
- package/dist/src/qa/runners/CommandRunner.js +0 -96
- package/dist/src/qa/runners/TestRunner.d.ts +0 -21
- package/dist/src/qa/runners/TestRunner.js +0 -66
- package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
- package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
- package/dist/src/qa/runtime-detect.d.ts +0 -10
- package/dist/src/qa/runtime-detect.js +0 -72
- package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
- package/dist/src/qa/security/DependencyScanner.js +0 -167
- package/dist/src/qa/security/SecretScanner.d.ts +0 -3
- package/dist/src/qa/security/SecretScanner.js +0 -55
package/dist/src/browser-view.js
CHANGED
|
@@ -5,6 +5,7 @@ import { mkdir } from 'node:fs/promises';
|
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { observePage, observationResult } from './browser-observation.js';
|
|
8
|
+
import { desktopUaOverride, hardenContext, stealthContextOptions, stealthLaunchArgs } from './browser-stealth.js';
|
|
8
9
|
export const VIEW_TAB_LIMIT = 6;
|
|
9
10
|
export const VIEW_SESSION_LIMIT = 4;
|
|
10
11
|
export const VIEW_IDLE_CLOSE_MS = 10 * 60 * 1000;
|
|
@@ -13,8 +14,40 @@ export const VIEW_FRAME_MIN_INTERVAL_MS = 16;
|
|
|
13
14
|
export const VIEW_GOTO_TIMEOUT_MS = 30_000;
|
|
14
15
|
/** The viewport Mobile mode simulates, in CSS pixels: an iPhone-class layout. */
|
|
15
16
|
export const VIEW_MOBILE_VIEWPORT = { width: 390, height: 844 };
|
|
17
|
+
/** The pixel density Mobile mode emulates: a current phone's. */
|
|
18
|
+
const VIEW_MOBILE_SCALE = 3;
|
|
16
19
|
/** The JPEG quality stream frames use; agent screenshots keep their own setting. */
|
|
17
|
-
export const VIEW_STREAM_QUALITY =
|
|
20
|
+
export const VIEW_STREAM_QUALITY = 90;
|
|
21
|
+
/**
|
|
22
|
+
* The largest display pixel ratio a desktop-mode page renders at. A 4K laptop
|
|
23
|
+
* panel at 300% scaling is the densest display Windows ships with; past that
|
|
24
|
+
* the frames only cost bandwidth the pane cannot show.
|
|
25
|
+
*/
|
|
26
|
+
export const VIEW_MAX_SCALE = 3;
|
|
27
|
+
/**
|
|
28
|
+
* The largest frame the desktop accepts, in base64 characters (`parseFrameEvent`
|
|
29
|
+
* in desktop/src/engine/browserView.ts drops anything bigger). A dropped frame
|
|
30
|
+
* leaves the pane frozen, so a frame over this is never sent: the stream steps
|
|
31
|
+
* its quality and then its size down until the page's frames fit.
|
|
32
|
+
*/
|
|
33
|
+
export const VIEW_FRAME_LIMIT = 4 * 1024 * 1024;
|
|
34
|
+
/** The lowest JPEG quality the frame budget steps down to before it shrinks frames instead. */
|
|
35
|
+
const VIEW_BUDGET_QUALITY_FLOOR = 50;
|
|
36
|
+
/**
|
|
37
|
+
* The next, smaller frame budget after a frame came out over the limit: quality
|
|
38
|
+
* first, in steps of 20 down to 50, then the frame size in steps of a quarter,
|
|
39
|
+
* down to the page's CSS size. Undefined when there is nothing left to give up.
|
|
40
|
+
*/
|
|
41
|
+
export function nextFrameBudget(budget, scale) {
|
|
42
|
+
if (budget.quality > VIEW_BUDGET_QUALITY_FLOOR)
|
|
43
|
+
return { quality: Math.max(VIEW_BUDGET_QUALITY_FLOOR, budget.quality - 20), size: budget.size };
|
|
44
|
+
const floor = 1 / Math.max(1, scale);
|
|
45
|
+
if (budget.size > floor)
|
|
46
|
+
return { quality: budget.quality, size: Math.max(floor, budget.size * 0.75) };
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
/** The largest viewport `clampViewport` allows, in CSS pixels. */
|
|
50
|
+
const VIEW_MAX_VIEWPORT = { width: 1600, height: 2200 };
|
|
18
51
|
/**
|
|
19
52
|
* The mobile Chrome UA Mobile mode presents. A Chromium engine claiming to be
|
|
20
53
|
* iOS Safari confuses sites that branch on it, so the UA names the platform the
|
|
@@ -87,7 +120,19 @@ const CURSOR_AT = `((point) => {
|
|
|
87
120
|
}
|
|
88
121
|
export function clampViewport(width, height) {
|
|
89
122
|
const value = (input, min, max, fallback) => Number.isSafeInteger(input) ? Math.max(min, Math.min(max, input)) : fallback;
|
|
90
|
-
return { width: value(width, 280,
|
|
123
|
+
return { width: value(width, 280, VIEW_MAX_VIEWPORT.width, 900), height: value(height, 240, VIEW_MAX_VIEWPORT.height, 700) };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The pane's display pixel ratio, which sizes its frames (and the factor a
|
|
127
|
+
* browser launched for it runs at), so one frame pixel is one screen pixel and
|
|
128
|
+
* the pane never stretches a frame rendered at CSS size. Anything that is not a finite number is the plain 1×
|
|
129
|
+
* an old panel (which sends none) has always had; the value is rounded to
|
|
130
|
+
* hundredths so a ratio like 1.2500000001 does not count as a change.
|
|
131
|
+
*/
|
|
132
|
+
export function clampScale(value) {
|
|
133
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
134
|
+
return 1;
|
|
135
|
+
return Math.round(Math.max(1, Math.min(VIEW_MAX_SCALE, value)) * 100) / 100;
|
|
91
136
|
}
|
|
92
137
|
/**
|
|
93
138
|
* JPEG dimensions straight from the SOF markers, without decoding pixels.
|
|
@@ -228,11 +273,18 @@ export function macEditingCommands(key, modifiers) {
|
|
|
228
273
|
* screencast carries pixels only, so the page's own audio output on the engine's
|
|
229
274
|
* machine is the only sound the panel has.
|
|
230
275
|
*/
|
|
231
|
-
export function viewLaunchOptions(channel, executablePath) {
|
|
276
|
+
export function viewLaunchOptions(channel, executablePath, scale = 1) {
|
|
232
277
|
return {
|
|
233
278
|
headless: true,
|
|
234
279
|
...(channel === 'chromium' ? { executablePath } : { channel }),
|
|
235
280
|
ignoreDefaultArgs: ['--mute-audio'],
|
|
281
|
+
// The panel's automation markers (see browser-stealth) must not reach the page.
|
|
282
|
+
// A screencast captures the browser's own surface, which is CSS size at the
|
|
283
|
+
// browser's real device scale factor; an emulated ratio alone renders the
|
|
284
|
+
// page at that ratio and then shrinks it into a 1× surface (verified live:
|
|
285
|
+
// 800×600 frames with devicePixelRatio 2). The real factor is what puts
|
|
286
|
+
// screen-resolution pixels into the frames.
|
|
287
|
+
args: [...stealthLaunchArgs(), ...(scale !== 1 ? [`--force-device-scale-factor=${scale}`] : [])],
|
|
236
288
|
timeout: 20_000,
|
|
237
289
|
};
|
|
238
290
|
}
|
|
@@ -288,6 +340,12 @@ export class BrowserViewManager {
|
|
|
288
340
|
* resumes streaming without another round trip.
|
|
289
341
|
*/
|
|
290
342
|
desired = new Map();
|
|
343
|
+
/**
|
|
344
|
+
* The display ratio a pane most recently reported, for any session. A browser
|
|
345
|
+
* an agent opens while its pane is collapsed has no request of its own to read
|
|
346
|
+
* a ratio from; the machine's display is the best answer there is.
|
|
347
|
+
*/
|
|
348
|
+
displayScale = 1;
|
|
291
349
|
/** Launches in flight per session, so concurrent opens share one browser. */
|
|
292
350
|
launching = new Map();
|
|
293
351
|
runtime = { state: 'checking' };
|
|
@@ -427,10 +485,10 @@ export class BrowserViewManager {
|
|
|
427
485
|
this.installTask = run().finally(() => { this.installTask = undefined; });
|
|
428
486
|
return this.installTask;
|
|
429
487
|
}
|
|
430
|
-
async launch() {
|
|
488
|
+
async launch(scale) {
|
|
431
489
|
// Tests supply a fake browser; production launches the real one below.
|
|
432
490
|
if (this.launchBrowser)
|
|
433
|
-
return await this.launchBrowser();
|
|
491
|
+
return await this.launchBrowser(scale);
|
|
434
492
|
const { chromium } = await import('playwright-core');
|
|
435
493
|
const failures = [];
|
|
436
494
|
// The probe's candidates in the probe's order. The bundled Chromium is launched
|
|
@@ -445,7 +503,7 @@ export class BrowserViewManager {
|
|
|
445
503
|
if (!candidate || !existsSync(candidate))
|
|
446
504
|
continue;
|
|
447
505
|
try {
|
|
448
|
-
return await chromium.launch(viewLaunchOptions(channel, candidate));
|
|
506
|
+
return await chromium.launch(viewLaunchOptions(channel, candidate, scale));
|
|
449
507
|
}
|
|
450
508
|
catch (error) {
|
|
451
509
|
failures.push((error instanceof Error ? error.message : String(error)).split('\n')[0]);
|
|
@@ -454,9 +512,9 @@ export class BrowserViewManager {
|
|
|
454
512
|
throw new Error(`Browser runtime is not usable: ${failures.join('; ').slice(0, 1000)}`);
|
|
455
513
|
}
|
|
456
514
|
/** Launch Chromium on a project's profile folder, with the same candidates as `launch`. */
|
|
457
|
-
async launchPersistent(directory, viewport) {
|
|
515
|
+
async launchPersistent(directory, viewport, scale) {
|
|
458
516
|
if (this.options.launchProfile)
|
|
459
|
-
return await this.options.launchProfile(directory, viewport);
|
|
517
|
+
return await this.options.launchProfile(directory, viewport, scale);
|
|
460
518
|
await mkdir(directory, { recursive: true });
|
|
461
519
|
const { chromium } = await import('playwright-core');
|
|
462
520
|
const failures = [];
|
|
@@ -467,7 +525,9 @@ export class BrowserViewManager {
|
|
|
467
525
|
if (!candidate || !existsSync(candidate))
|
|
468
526
|
continue;
|
|
469
527
|
try {
|
|
470
|
-
|
|
528
|
+
const context = await chromium.launchPersistentContext(directory, { ...viewLaunchOptions(channel, candidate, scale), ...stealthContextOptions(), viewport: { ...viewport }, acceptDownloads: false });
|
|
529
|
+
await hardenContext(context);
|
|
530
|
+
return context;
|
|
471
531
|
}
|
|
472
532
|
catch (error) {
|
|
473
533
|
failures.push((error instanceof Error ? error.message : String(error)).split('\n')[0]);
|
|
@@ -481,7 +541,7 @@ export class BrowserViewManager {
|
|
|
481
541
|
* A profile that is still closing is waited out rather than reopened beside it:
|
|
482
542
|
* two processes on one profile folder is exactly what Chromium refuses.
|
|
483
543
|
*/
|
|
484
|
-
async acquireProfile(owner, profile, viewport) {
|
|
544
|
+
async acquireProfile(owner, profile, viewport, scale) {
|
|
485
545
|
for (;;) {
|
|
486
546
|
const current = this.profiles.get(profile.key);
|
|
487
547
|
if (current?.closing) {
|
|
@@ -492,7 +552,11 @@ export class BrowserViewManager {
|
|
|
492
552
|
if (!current)
|
|
493
553
|
this.profiles.set(profile.key, host);
|
|
494
554
|
host.users.add(owner);
|
|
495
|
-
|
|
555
|
+
// A profile already running keeps the factor it was launched with: one
|
|
556
|
+
// process, one surface scale, shared by every session of the project.
|
|
557
|
+
if (!host.starting)
|
|
558
|
+
host.scale = scale;
|
|
559
|
+
host.starting ??= this.launchPersistent(profile.directory, viewport, scale).then(async (context) => {
|
|
496
560
|
// A persistent launch opens with a blank page of its own; every tab the
|
|
497
561
|
// panel shows is one a session asked for.
|
|
498
562
|
for (const page of context.pages?.() ?? [])
|
|
@@ -503,7 +567,7 @@ export class BrowserViewManager {
|
|
|
503
567
|
return context;
|
|
504
568
|
});
|
|
505
569
|
try {
|
|
506
|
-
return await host.starting;
|
|
570
|
+
return { context: await host.starting, scale: host.scale ?? 1 };
|
|
507
571
|
}
|
|
508
572
|
catch (error) {
|
|
509
573
|
// A failed launch is not cached: the next open tries the profile again.
|
|
@@ -537,14 +601,14 @@ export class BrowserViewManager {
|
|
|
537
601
|
* Open the browser a new session's pages will live in: its project's profile,
|
|
538
602
|
* or a throwaway browser when the session is incognito or has no usable profile.
|
|
539
603
|
*/
|
|
540
|
-
async openBrowserFor(sessionId, viewport) {
|
|
604
|
+
async openBrowserFor(sessionId, viewport, scale) {
|
|
541
605
|
if (!this.incognito.has(sessionId)) {
|
|
542
606
|
const profile = this.options.profileFor ? await this.options.profileFor(sessionId).catch(() => undefined) : undefined;
|
|
543
607
|
if (profile) {
|
|
544
608
|
try {
|
|
545
609
|
const owner = {};
|
|
546
|
-
const
|
|
547
|
-
return { context, profileKey: profile.key, profileOwner: owner, profile: 'project' };
|
|
610
|
+
const acquired = await this.acquireProfile(owner, profile, viewport, scale);
|
|
611
|
+
return { context: acquired.context, profileKey: profile.key, profileOwner: owner, profile: 'project', renderScale: acquired.scale };
|
|
548
612
|
}
|
|
549
613
|
catch (error) {
|
|
550
614
|
if (this.closed)
|
|
@@ -554,7 +618,7 @@ export class BrowserViewManager {
|
|
|
554
618
|
}
|
|
555
619
|
}
|
|
556
620
|
}
|
|
557
|
-
return { browser: await this.launch(), profile: this.incognito.has(sessionId) ? 'incognito' : 'isolated' };
|
|
621
|
+
return { browser: await this.launch(scale), profile: this.incognito.has(sessionId) ? 'incognito' : 'isolated', renderScale: scale };
|
|
558
622
|
}
|
|
559
623
|
/** Close a session's browser, or only its pages when they live in a shared project profile. */
|
|
560
624
|
async disposeBrowser(session) {
|
|
@@ -636,11 +700,11 @@ export class BrowserViewManager {
|
|
|
636
700
|
* respected, with a phone's pixel density — a mobile Chrome user agent, and
|
|
637
701
|
* touch events, so the sites the pane shows answer with their mobile layouts
|
|
638
702
|
* and hover-dependent UIs behave like they do on a phone. Leaving Mobile
|
|
639
|
-
* clears the metrics and
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
703
|
+
* clears the metrics and applies the desktop spoof identity (see
|
|
704
|
+
* browser-stealth), so the page presents as a normal desktop browser rather
|
|
705
|
+
* than the headless automation UA a reset would expose. A switch changes the
|
|
706
|
+
* page's size, so the caller restarts the screencast for the new capture
|
|
707
|
+
* scale.
|
|
644
708
|
*
|
|
645
709
|
* Calls for one tab are serialized by `queueViewportMode`: each applies
|
|
646
710
|
* whatever the session's mode is at its turn, so a rapid toggle cannot leave
|
|
@@ -656,21 +720,32 @@ export class BrowserViewManager {
|
|
|
656
720
|
// authority (verified live: the metrics override yields exactly
|
|
657
721
|
// 390×844 screencast frames at a phone's pixel density).
|
|
658
722
|
await tab.cdp.send('Emulation.setDeviceMetricsOverride', {
|
|
659
|
-
width: VIEW_MOBILE_VIEWPORT.width, height: VIEW_MOBILE_VIEWPORT.height, deviceScaleFactor:
|
|
723
|
+
width: VIEW_MOBILE_VIEWPORT.width, height: VIEW_MOBILE_VIEWPORT.height, deviceScaleFactor: VIEW_MOBILE_SCALE, mobile: true,
|
|
660
724
|
});
|
|
661
725
|
}
|
|
662
726
|
else {
|
|
663
727
|
if (tab.emulated)
|
|
664
728
|
await tab.cdp.send('Emulation.clearDeviceMetricsOverride');
|
|
665
729
|
await tab.page.setViewportSize(session.viewport).catch(() => { });
|
|
730
|
+
// Playwright sizes the page at 1×, which on a browser launched at a
|
|
731
|
+
// higher factor renders at 1× and stretches into the surface — the blur
|
|
732
|
+
// this exists to remove. The page renders at the browser's real factor
|
|
733
|
+
// instead, as a native window on that display would, sharp text and
|
|
734
|
+
// `srcset` images included. The override is sent every time and after
|
|
735
|
+
// Playwright's: Playwright skips a size it believes it already applied,
|
|
736
|
+
// so it cannot be relied on to put back a ratio this override replaced.
|
|
737
|
+
await tab.cdp.send('Emulation.setDeviceMetricsOverride', {
|
|
738
|
+
width: session.viewport.width, height: session.viewport.height, deviceScaleFactor: session.renderScale, mobile: false,
|
|
739
|
+
});
|
|
666
740
|
}
|
|
667
741
|
if (mobile === Boolean(tab.emulated))
|
|
668
742
|
return;
|
|
669
743
|
tab.emulated = mobile;
|
|
670
744
|
await tab.cdp.send('Emulation.setUserAgentOverride', mobile
|
|
671
745
|
? { userAgent: VIEW_MOBILE_USER_AGENT }
|
|
672
|
-
//
|
|
673
|
-
|
|
746
|
+
// Desktop presents the spoofed identity too: an empty override would
|
|
747
|
+
// expose the headless browser's own UA to every site the panel shows.
|
|
748
|
+
: desktopUaOverride());
|
|
674
749
|
await tab.cdp.send('Emulation.setTouchEmulationEnabled', { enabled: mobile, ...(mobile ? { maxTouchPoints: 5 } : {}) });
|
|
675
750
|
}
|
|
676
751
|
catch { /* The page is gone; the next activation retries. */ }
|
|
@@ -685,6 +760,10 @@ export class BrowserViewManager {
|
|
|
685
760
|
// Frames still in flight from a replaced browser belong to nobody.
|
|
686
761
|
if (session.closing || this.sessions.get(sessionId) !== session)
|
|
687
762
|
return;
|
|
763
|
+
if (payload.data.length > VIEW_FRAME_LIMIT) {
|
|
764
|
+
void this.shrinkStream(session, tab);
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
688
767
|
const size = jpegSize(Buffer.from(payload.data, 'base64'));
|
|
689
768
|
if (!size)
|
|
690
769
|
return;
|
|
@@ -703,14 +782,17 @@ export class BrowserViewManager {
|
|
|
703
782
|
return;
|
|
704
783
|
tab.streaming = true;
|
|
705
784
|
tab.lastEmitAt = undefined;
|
|
785
|
+
const budget = tab.budget ?? { quality: session.quality, size: 1 };
|
|
706
786
|
try {
|
|
707
787
|
await tab.cdp.send('Page.startScreencast', {
|
|
708
|
-
format: 'jpeg', quality: session.quality,
|
|
709
|
-
// The viewport
|
|
710
|
-
//
|
|
711
|
-
//
|
|
712
|
-
//
|
|
713
|
-
|
|
788
|
+
format: 'jpeg', quality: Math.min(session.quality, budget.quality),
|
|
789
|
+
// The viewport at the pane's ratio: one frame pixel per screen pixel.
|
|
790
|
+
// A browser launched at that ratio fills it exactly; one launched
|
|
791
|
+
// denser (the window moved to a lower-density monitor) is scaled down
|
|
792
|
+
// to it once, and the caps never scale a frame up. A page whose frames
|
|
793
|
+
// outgrew the payload limit runs at a reduced size until it changes.
|
|
794
|
+
maxWidth: Math.ceil(session.viewport.width * session.scale * budget.size),
|
|
795
|
+
maxHeight: Math.ceil(session.viewport.height * session.scale * budget.size),
|
|
714
796
|
everyNthFrame: 1,
|
|
715
797
|
});
|
|
716
798
|
}
|
|
@@ -718,6 +800,34 @@ export class BrowserViewManager {
|
|
|
718
800
|
tab.streaming = false;
|
|
719
801
|
}
|
|
720
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* Step one tab's frame budget down after a frame came out over the limit, and
|
|
805
|
+
* restart its stream at it. The oversized frame itself is not sent; the pane
|
|
806
|
+
* keeps its previous frame until the smaller stream delivers.
|
|
807
|
+
*/
|
|
808
|
+
async shrinkStream(session, tab) {
|
|
809
|
+
if (tab.shrinking || !tab.streaming)
|
|
810
|
+
return;
|
|
811
|
+
const next = nextFrameBudget(tab.budget ?? { quality: session.quality, size: 1 }, session.scale);
|
|
812
|
+
if (!next)
|
|
813
|
+
return;
|
|
814
|
+
tab.budget = next;
|
|
815
|
+
await this.restartStream(session, tab);
|
|
816
|
+
}
|
|
817
|
+
/** Stop and start one tab's stream, keeping it only while it still owns the pane. */
|
|
818
|
+
async restartStream(session, tab) {
|
|
819
|
+
if (tab.shrinking)
|
|
820
|
+
return;
|
|
821
|
+
tab.shrinking = true;
|
|
822
|
+
try {
|
|
823
|
+
await this.stopScreencast(tab);
|
|
824
|
+
if (session.activeTabId === tab.id && !session.closing)
|
|
825
|
+
await this.startScreencast(session, tab);
|
|
826
|
+
}
|
|
827
|
+
finally {
|
|
828
|
+
tab.shrinking = false;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
721
831
|
wireTab(sessionId, session, page, cdp) {
|
|
722
832
|
const tab = {
|
|
723
833
|
id: randomUUID(), page, cdp, url: '', title: '', loading: false,
|
|
@@ -748,6 +858,13 @@ export class BrowserViewManager {
|
|
|
748
858
|
if (newDocument) {
|
|
749
859
|
tab.loading = true;
|
|
750
860
|
tab.title = '';
|
|
861
|
+
// The budget was earned by the previous document's content; the next
|
|
862
|
+
// page gets full quality and size again.
|
|
863
|
+
if (tab.budget) {
|
|
864
|
+
tab.budget = undefined;
|
|
865
|
+
if (tab.streaming)
|
|
866
|
+
void this.restartStream(session, tab);
|
|
867
|
+
}
|
|
751
868
|
}
|
|
752
869
|
publish();
|
|
753
870
|
});
|
|
@@ -931,7 +1048,7 @@ export class BrowserViewManager {
|
|
|
931
1048
|
const starting = (async () => {
|
|
932
1049
|
const desired = this.desired.get(sessionId);
|
|
933
1050
|
const viewport = desired?.viewport ?? clampViewport(undefined, undefined);
|
|
934
|
-
const opened = await this.openBrowserFor(sessionId, viewport);
|
|
1051
|
+
const opened = await this.openBrowserFor(sessionId, viewport, desired?.scale ?? this.displayScale);
|
|
935
1052
|
// Shutdown may have finished while the launch was in flight: the browser
|
|
936
1053
|
// that arrived late belongs to nobody, so it is closed here rather than
|
|
937
1054
|
// inserted into a manager that has already visited its sessions.
|
|
@@ -954,6 +1071,7 @@ export class BrowserViewManager {
|
|
|
954
1071
|
...opened, tabs: new Map(), activeTabId: undefined, pendingTabs: 0,
|
|
955
1072
|
viewport: current?.viewport ?? viewport,
|
|
956
1073
|
mode: current?.mode ?? 'desktop',
|
|
1074
|
+
scale: current?.scale ?? this.displayScale,
|
|
957
1075
|
streaming: current !== undefined, quality: current?.quality ?? VIEW_STREAM_QUALITY, idleTimer: undefined,
|
|
958
1076
|
};
|
|
959
1077
|
this.sessions.set(sessionId, session);
|
|
@@ -980,8 +1098,8 @@ export class BrowserViewManager {
|
|
|
980
1098
|
if (session.context)
|
|
981
1099
|
return session.context;
|
|
982
1100
|
session.contextTask ??= Promise.resolve()
|
|
983
|
-
.then(() => session.browser.newContext({ viewport: { ...session.viewport }, acceptDownloads: false }))
|
|
984
|
-
.then((context) => { session.context = context; return context; });
|
|
1101
|
+
.then(() => session.browser.newContext({ viewport: { ...session.viewport }, acceptDownloads: false, ...stealthContextOptions() }))
|
|
1102
|
+
.then(async (context) => { await hardenContext(context); session.context = context; return context; });
|
|
985
1103
|
return await session.contextTask;
|
|
986
1104
|
}
|
|
987
1105
|
async openTab(sessionId, url, signal) {
|
|
@@ -1309,21 +1427,33 @@ export class BrowserViewManager {
|
|
|
1309
1427
|
const mode = options.mode === 'mobile' ? 'mobile' : 'desktop';
|
|
1310
1428
|
const viewport = mode === 'mobile' ? { ...VIEW_MOBILE_VIEWPORT } : clampViewport(options.viewportWidth, options.viewportHeight);
|
|
1311
1429
|
const quality = Number.isSafeInteger(options.quality) ? Math.max(30, Math.min(90, options.quality)) : VIEW_STREAM_QUALITY;
|
|
1312
|
-
|
|
1430
|
+
const scale = clampScale(options.scale);
|
|
1431
|
+
// Only a panel that sends a ratio speaks for the display; an old one that
|
|
1432
|
+
// sends none must not reset what a current one reported.
|
|
1433
|
+
if (options.scale !== undefined)
|
|
1434
|
+
this.displayScale = scale;
|
|
1435
|
+
this.desired.set(sessionId, { viewport, quality, mode, scale });
|
|
1313
1436
|
const session = this.sessions.get(sessionId);
|
|
1314
1437
|
if (!session)
|
|
1315
1438
|
return;
|
|
1316
1439
|
session.streaming = true;
|
|
1317
1440
|
const modeChanged = mode !== session.mode;
|
|
1318
|
-
|
|
1441
|
+
// A new display ratio (the window moved to another monitor, or the system
|
|
1442
|
+
// scaling changed) sizes the frames differently, and the screencast bakes
|
|
1443
|
+
// its frame size in at start, so it restarts like a resize does.
|
|
1444
|
+
const resized = viewport.width !== session.viewport.width || viewport.height !== session.viewport.height
|
|
1445
|
+
|| scale !== session.scale;
|
|
1319
1446
|
session.mode = mode;
|
|
1320
1447
|
session.viewport = viewport;
|
|
1321
1448
|
session.quality = quality;
|
|
1449
|
+
session.scale = scale;
|
|
1322
1450
|
this.scheduleIdleClose(sessionId, session);
|
|
1323
1451
|
const active = session.activeTabId ? session.tabs.get(session.activeTabId) : undefined;
|
|
1324
1452
|
if (!active)
|
|
1325
1453
|
return;
|
|
1326
1454
|
if (resized || modeChanged) {
|
|
1455
|
+
// A new geometry changes every frame's size; the reduced budget belonged to the old one.
|
|
1456
|
+
active.budget = undefined;
|
|
1327
1457
|
// A mode switch is more than a resize: the page is put into or taken out
|
|
1328
1458
|
// of the phone's emulation.
|
|
1329
1459
|
await this.queueViewportMode(session, active);
|
|
@@ -1629,7 +1759,28 @@ export class BrowserViewManager {
|
|
|
1629
1759
|
}
|
|
1630
1760
|
async agentScreenshot(sessionId, tabId, signal) {
|
|
1631
1761
|
const { session, tab } = this.agentTarget(sessionId, tabId);
|
|
1632
|
-
|
|
1762
|
+
// The agent reads this image against the CSS-pixel size returned with it, but
|
|
1763
|
+
// the page renders at the browser's launch factor (or Mobile's 3×). That ratio
|
|
1764
|
+
// is applied over this manager's own CDP session, so Playwright still believes
|
|
1765
|
+
// the page is 1×, and its `scale: 'css'` would return device pixels; the
|
|
1766
|
+
// capture is made here instead, scaled down by the ratio actually in effect.
|
|
1767
|
+
const ratio = tab.emulated ? VIEW_MOBILE_SCALE : session.renderScale;
|
|
1768
|
+
const capture = (async () => {
|
|
1769
|
+
const metrics = await tab.cdp.send('Page.getLayoutMetrics').catch(() => undefined);
|
|
1770
|
+
const visual = metrics?.cssVisualViewport;
|
|
1771
|
+
const clip = visual && Number.isFinite(visual.clientWidth) && visual.clientWidth > 0
|
|
1772
|
+
? { x: visual.pageX, y: visual.pageY, width: visual.clientWidth, height: visual.clientHeight }
|
|
1773
|
+
: { x: 0, y: 0, width: session.viewport.width, height: session.viewport.height };
|
|
1774
|
+
// A Mobile page without a meta viewport lays out at ~980 CSS px and the
|
|
1775
|
+
// phone shows it zoomed out to its 390: the visual viewport's scale (0.398
|
|
1776
|
+
// there, measured) is what brings that wider clip back to the size the
|
|
1777
|
+
// agent is told.
|
|
1778
|
+
const zoom = visual && Number.isFinite(visual.scale) && visual.scale > 0 ? visual.scale : 1;
|
|
1779
|
+
const shot = await tab.cdp.send('Page.captureScreenshot', { format: 'jpeg', quality: 60, clip: { ...clip, scale: zoom / ratio } });
|
|
1780
|
+
if (typeof shot?.data !== 'string')
|
|
1781
|
+
throw new Error('Browser screenshot returned no image.');
|
|
1782
|
+
return Buffer.from(shot.data, 'base64');
|
|
1783
|
+
})();
|
|
1633
1784
|
const data = await this.boundedAgentOperation(signal, capture, 'Browser screenshot exceeded the 10-second timeout.');
|
|
1634
1785
|
return { tabId: tab.id, data, width: session.viewport.width, height: session.viewport.height };
|
|
1635
1786
|
}
|
package/dist/src/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ import { configDirectory, loadConfig, resolveCodeIntelConfig, resolveConfiguredL
|
|
|
15
15
|
import { compactHistory, compactedContextEstimate, executeCommand, HELP } from './commands.js';
|
|
16
16
|
import { applyModelContextWindow, createAdapter, providerSecrets, recordProviderModel } from './providers.js';
|
|
17
17
|
import { createTools } from './tools.js';
|
|
18
|
-
import {
|
|
18
|
+
import { disposeAllQaProcesses, disposeAllQaPtys, getQaPtyManager } from './qa/index.js';
|
|
19
19
|
import { disposePooledPowerShell } from './powershell-pool.js';
|
|
20
20
|
import { loadWorkspaceInstructions } from './workspace-instructions.js';
|
|
21
21
|
import { runGraph, stopReasonPhrase } from './runtime.js';
|
|
@@ -52,7 +52,7 @@ function offerSkillCommands(terminal, config, directory) {
|
|
|
52
52
|
}
|
|
53
53
|
import { meterStreamedRequest } from './token-rate.js';
|
|
54
54
|
import { attachmentLabel, attachmentReadRoots, attachmentReferenceBlock, pruneAttachments, readClipboardImage, resolveAttachments, writeClipboardText } from './attachments.js';
|
|
55
|
-
import { describeTool, formatEvent, formatRunResult } from './transcript.js';
|
|
55
|
+
import { describeTool, formatAnswer, formatEvent, formatRunResult } from './transcript.js';
|
|
56
56
|
import { staticToolTimestamp } from './tool-call-clock.js';
|
|
57
57
|
import { LocalToolMemory } from './memory/LocalToolMemory.js';
|
|
58
58
|
import { askClarification } from './clarification-ui.js';
|
|
@@ -62,6 +62,7 @@ import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceMan
|
|
|
62
62
|
import { ToolActivity, activityForRuntimeEvent } from './tool-activity.js';
|
|
63
63
|
import { extensionSnapshot, resolveSkillInvocation } from './extensions.js';
|
|
64
64
|
import { isBuiltinSlashCommand } from './skill-commands.js';
|
|
65
|
+
import { copySessionSkill, removeSessionSkill, sessionSkillCommand, skillForRun } from './session-skills.js';
|
|
65
66
|
import { executeAuthCommand } from './auth-commands.js';
|
|
66
67
|
import { setAuthSignOutReporter } from './auth/index.js';
|
|
67
68
|
import { getAccountPresentation } from './account-presentation.js';
|
|
@@ -936,7 +937,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
936
937
|
const ownsController = !active;
|
|
937
938
|
if (ownsController)
|
|
938
939
|
active = controller;
|
|
939
|
-
terminal.setStatus({ activity: 'Checking graph models' });
|
|
940
|
+
terminal.setStatus({ activity: 'Checking graph models', backgroundActivity: true });
|
|
940
941
|
graphModelsHealthy = false;
|
|
941
942
|
// Run preflights reuse the startup graph until a refresh replaces it; dropping the
|
|
942
943
|
// cache first means a failed refresh falls back to loading again at run time.
|
|
@@ -1569,7 +1570,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
1569
1570
|
const loadedGraph = startupGraph && !startupGraphReused && startupGraphSelection === (state.graph ?? 'default')
|
|
1570
1571
|
? (startupGraphReused = true, startupGraph)
|
|
1571
1572
|
: await preflight(signal => loadGraph(state.graph ?? 'default', signal));
|
|
1572
|
-
terminal?.setStatus({ activity: 'Checking graph models' });
|
|
1573
|
+
terminal?.setStatus({ activity: 'Checking graph models', backgroundActivity: true });
|
|
1573
1574
|
graphModelsHealthy = false;
|
|
1574
1575
|
const health = await preflight(signal => checkGraphHealth(loadedGraph, config, signal, {
|
|
1575
1576
|
onUsage: (delta, reference) => {
|
|
@@ -1621,10 +1622,15 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
1621
1622
|
// QA workflow guidance rides the same channel as the workspace guide; it is
|
|
1622
1623
|
// guidance only — permission gates and the command policy still enforce.
|
|
1623
1624
|
const invocation = isBuiltinSlashCommand(task) ? undefined : await preflight(signal => resolveSkillInvocation(task, config, signal, directory));
|
|
1624
|
-
|
|
1625
|
+
// A slash invocation becomes the session's skill; a later message without one inherits it
|
|
1626
|
+
// until the user turns it off with /skill off (see `src/session-skills.ts`).
|
|
1627
|
+
const runSkill = await preflight(signal => skillForRun({ invocation, home: directory, sessionId: savedSession?.id, config, signal }));
|
|
1628
|
+
if (runSkill.notice)
|
|
1629
|
+
terminal ? terminal.print(runSkill.notice) : process.stderr.write(safeTerminal(runSkill.notice) + '\n');
|
|
1630
|
+
const snapshot = await preflight(signal => extensionSnapshot(config, signal, directory, runSkill.skill?.id));
|
|
1625
1631
|
for (const notice of snapshot.notices)
|
|
1626
1632
|
terminal ? terminal.print(notice) : process.stderr.write(safeTerminal(notice) + '\n');
|
|
1627
|
-
const instructions = `${workspaceGuidance}
|
|
1633
|
+
const instructions = `${workspaceGuidance}${snapshot.instructions}`;
|
|
1628
1634
|
const resolvedModels = new Map();
|
|
1629
1635
|
const onRunEvent = async (event) => {
|
|
1630
1636
|
if (!/reasoning|thinking\.delta/.test(event.type))
|
|
@@ -1698,7 +1704,9 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
1698
1704
|
await runResumed();
|
|
1699
1705
|
}
|
|
1700
1706
|
} };
|
|
1701
|
-
|
|
1707
|
+
const mcpModule = await import('./mcp.js');
|
|
1708
|
+
// How each server answered is recorded, so the desktop's MCP page can show it without starting it.
|
|
1709
|
+
return mcpModule.connectMcpServers(snapshot.servers, extensionContext, message => terminal ? terminal.print(message) : process.stderr.write(safeTerminal(message) + '\n'), active.signal, { status: mcpModule.mcpTaskStatusReporter(configDirectory()) });
|
|
1702
1710
|
}) : { tools: [], close: async () => { } };
|
|
1703
1711
|
if (terminal) {
|
|
1704
1712
|
try {
|
|
@@ -1739,7 +1747,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
1739
1747
|
terminal?.setStatus({ graph, jevEnabled });
|
|
1740
1748
|
const commandMemory = config.commandMemory === false ? undefined : await LocalToolMemory.open({ workspace, directory });
|
|
1741
1749
|
const execute = (options) => runGraph(graph, { ...options, runInput, runState, commandMemory, todoStore,
|
|
1742
|
-
...(
|
|
1750
|
+
...(runSkill.skill ? { inheritedSkills: [runSkill.skill.id], skillInvocationInstruction: runSkill.skill.instruction } : {}),
|
|
1743
1751
|
resolveModel: (id, model) => {
|
|
1744
1752
|
const provider = config.providers.find(item => item.id === id);
|
|
1745
1753
|
if (!provider)
|
|
@@ -2282,6 +2290,8 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
2282
2290
|
// The conversation that is being replaced keeps the log it was written to, and this one
|
|
2283
2291
|
// takes a log of its own, so neither session shows the other's records.
|
|
2284
2292
|
await openSessionTrajectory(savedSession.id);
|
|
2293
|
+
// The resumed conversation keeps following the skill its source was.
|
|
2294
|
+
await copySessionSkill(directory, record.id, savedSession.id).catch(() => { });
|
|
2285
2295
|
await trajectory.record('session.resumed', { resumedSessionId: savedSession.id, sourceSessionId: record.id });
|
|
2286
2296
|
sessionArchive = structuredClone(record.history);
|
|
2287
2297
|
state.history = structuredClone(record.contextHistory ?? record.history).slice(-6);
|
|
@@ -2297,7 +2307,10 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
2297
2307
|
// is what this turn's work answers to; the stopped turn above it still carries the original.
|
|
2298
2308
|
for (const turn of displayHistory(sessionArchive)) {
|
|
2299
2309
|
terminal.printPrompt(turn.direction ?? turn.task);
|
|
2300
|
-
|
|
2310
|
+
// A saved answer is markdown like a live one, so it is rendered the same way: printed
|
|
2311
|
+
// verbatim, a restored conversation showed raw `**`, `##` and fences.
|
|
2312
|
+
const answer = formatAnswer(turn.completion.summary);
|
|
2313
|
+
terminal.print(answer.text, answer.detail, undefined, true);
|
|
2301
2314
|
}
|
|
2302
2315
|
print(`Resumed ${record.name} (${record.id.slice(-10)}) in a new session. Saved task/outcome context restored; current model and graph settings retained.`);
|
|
2303
2316
|
if (abandonedTimers)
|
|
@@ -2356,6 +2369,12 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
2356
2369
|
const skillInvocation = line.startsWith('/') && !isBuiltinSlashCommand(line)
|
|
2357
2370
|
? await resolveSkillInvocation(line, config, undefined, directory) : undefined;
|
|
2358
2371
|
if (line.startsWith('/') && !skillInvocation) {
|
|
2372
|
+
// The session's active skill is the conversation's, so its controls answer here rather than
|
|
2373
|
+
// in `executeCommand`, which knows nothing of the session.
|
|
2374
|
+
if (/^\/skill(?:\s|$)/.test(line.trim())) {
|
|
2375
|
+
print(await sessionSkillCommand(directory, savedSession?.id, line));
|
|
2376
|
+
continue;
|
|
2377
|
+
}
|
|
2359
2378
|
let command;
|
|
2360
2379
|
if (/^\/codegraph\s+rebuild\s*$|^\/(login|logout|auth)(?:\s|$)/.test(line.trim())) {
|
|
2361
2380
|
active = new AbortController();
|
|
@@ -2393,6 +2412,9 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
|
|
|
2393
2412
|
browserBridge?.startRun();
|
|
2394
2413
|
terminal?.setStatus({ contextUsed: 0 });
|
|
2395
2414
|
}
|
|
2415
|
+
// A cleared conversation starts over, without the skill the old one was following.
|
|
2416
|
+
if (line.trim() === '/clear' && savedSession)
|
|
2417
|
+
await removeSessionSkill(directory, savedSession.id).catch(() => { });
|
|
2396
2418
|
if (command.compact && state.history?.length) {
|
|
2397
2419
|
state.history = compactHistory(state.history);
|
|
2398
2420
|
// Until the next request reports the real input size, show the compacted
|
package/dist/src/coding-tools.js
CHANGED
|
@@ -10,7 +10,7 @@ import { defaultShellKind, runShell, runNativeProcess } from './shell.js';
|
|
|
10
10
|
import { commandTimingSummary } from './command-metrics.js';
|
|
11
11
|
import { runPooledPowerShell } from './powershell-pool.js';
|
|
12
12
|
import { assertNotHostKill, assertNotHostKillArgv, hostShellOf } from './host-process-guard.js';
|
|
13
|
-
import { getQaProcessManager } from './qa/runtime/ProcessManager.js';
|
|
13
|
+
import { getQaProcessManager, PERSISTENT_JOBS_SUPPORTED } from './qa/runtime/ProcessManager.js';
|
|
14
14
|
import { clipText } from './text.js';
|
|
15
15
|
import { matchesFileRead, storeFileRead } from './file-read-state.js';
|
|
16
16
|
import { FileReadRequiredError } from './tool-errors.js';
|
|
@@ -848,9 +848,9 @@ export function createCodingTools(policy) {
|
|
|
848
848
|
const canonicalShell = (name, kind) => {
|
|
849
849
|
const actual = kind === 'powershell' ? 'PowerShell' : 'Bash';
|
|
850
850
|
const syntax = kind === 'powershell'
|
|
851
|
-
? 'PowerShell syntax; use & before a quoted executable path. No cmd.exe substitution. Do not pipe a running child into Select-Object -First: it terminates the pipeline before the child completes and can cause exit 4294967295. Host output is already tail-bounded; use Select-Object -Last if further filtering is needed. Prefer file-written scripts over nested quoting for multiline Python/JavaScript. Prefer direct invocation (& $exe @args) for child processes: Windows PowerShell Start-Process -ArgumentList flattens arrays and can split a multi-word argument unless it is quoted manually.'
|
|
851
|
+
? 'PowerShell syntax; use & before a quoted executable path. No cmd.exe substitution. Do not pipe a running child into Select-Object -First: it terminates the pipeline before the child completes and can cause exit 4294967295. Host output is already tail-bounded; use Select-Object -Last if further filtering is needed. Prefer file-written scripts over nested quoting for multiline Python/JavaScript. Prefer direct invocation (& $exe @args) for child processes: Windows PowerShell Start-Process -ArgumentList flattens arrays and can split a multi-word argument unless it is quoted manually. Windows PowerShell also alters what it hands a native program: piping a string into one (ssh, wsl, bash -s, docker exec) appends CRLF after the last line, so a remote shell runs that line with a stray \r, and double quotes inside a native argument are dropped. Send a multi-line script to a remote or POSIX shell as base64 instead: $b = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(($script -replace "`r", "") + "`n")); & ssh host "echo $b | base64 -d | bash".'
|
|
852
852
|
: 'Bash syntax (Git Bash on Windows).';
|
|
853
|
-
const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed.`, { type: 'object', properties: {
|
|
853
|
+
const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed${kind === 'powershell' ? '' : ': a command that leaves a job running (cmd &) waits for that job, and the timeout then stops it'}. Start long-running work with AsyncProcess instead${PERSISTENT_JOBS_SUPPORTED ? ', with persist: true for a service the user needs left running after you finish' : ''}.`, { type: 'object', properties: {
|
|
854
854
|
command: { type: 'string', description: 'Command to execute' },
|
|
855
855
|
timeout: { type: 'integer', minimum: 1, maximum: 600000, description: 'Timeout in milliseconds; default 30000' },
|
|
856
856
|
description: { type: 'string', description: 'Short active-voice description of what the command does' },
|
|
@@ -1025,9 +1025,12 @@ export function createCodingTools(policy) {
|
|
|
1025
1025
|
throw new Error('Native executable is not installed');
|
|
1026
1026
|
return nativeObservation(await runNativeProcess(executable, argv, cwd, timeout, context.signal, launchPolicy), true);
|
|
1027
1027
|
});
|
|
1028
|
-
const AsyncProcess = zTool('AsyncProcess',
|
|
1028
|
+
const AsyncProcess = zTool('AsyncProcess', `Start a shell command in the background and return immediately; inspect status/logs, wait for completion without polling, or stop it. Use for independent builds, test suites, and dev servers so other agent work can continue. Each job has a generated ID. ${PERSISTENT_JOBS_SUPPORTED
|
|
1029
|
+
? 'Jobs are killed when the owning CLI exits unless started with persist: true. When the task is to leave a service running for the user (a web server, daemon or listener they will use after you finish), start it with persist: true and do not stop it before you finish.'
|
|
1030
|
+
: 'Jobs are killed when the owning CLI exits.'} Full Access or explicit escalation is required to start; sandbox restrictions are never bypassed.`, { type: 'object', properties: {
|
|
1029
1031
|
action: { type: 'string', enum: ['start', 'status', 'logs', 'wait', 'stop'] },
|
|
1030
1032
|
command: { type: 'string', description: 'Shell command; only for start' },
|
|
1033
|
+
...(PERSISTENT_JOBS_SUPPORTED ? { persist: { type: 'boolean', description: 'Only for start. Keep the job running after this session ends, for a service the user needs left running. Default false: the job is stopped when the CLI exits.' } } : {}),
|
|
1031
1034
|
id: { type: 'string', description: 'Job ID returned by start; required otherwise' },
|
|
1032
1035
|
timeout: { type: 'integer', minimum: 1, maximum: 600000, description: 'Maximum wait in milliseconds; does not kill unfinished jobs' },
|
|
1033
1036
|
...sandboxFields,
|
|
@@ -1043,7 +1046,8 @@ export function createCodingTools(policy) {
|
|
|
1043
1046
|
assertNotHostKill(command, hostShellOf(defaultShellKind));
|
|
1044
1047
|
const launchPolicy = await shellPermission(policy, 'AsyncProcess', args, context);
|
|
1045
1048
|
const id = `agent-${randomUUID()}`;
|
|
1046
|
-
|
|
1049
|
+
const persist = boolArg(args, 'persist') === true;
|
|
1050
|
+
return JSON.stringify(await manager.start({ id, command, launchPolicy, signal: context.signal, persist }));
|
|
1047
1051
|
}
|
|
1048
1052
|
const id = stringArg(args, 'id');
|
|
1049
1053
|
if (!/^agent-[a-f0-9-]{36}$/.test(id))
|