@andorra-labs/code 0.1.10 → 0.1.12

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 (238) hide show
  1. package/README.md +31 -205
  2. package/THIRD_PARTY_NOTICES.md +30 -0
  3. package/dist/src/agent-execution.js +50 -2
  4. package/dist/src/agent-mcp.js +5 -0
  5. package/dist/src/app-server/protocol.d.ts +9 -1
  6. package/dist/src/app-server/protocol.js +1 -1
  7. package/dist/src/app-server.d.ts +49 -1
  8. package/dist/src/app-server.js +353 -64
  9. package/dist/src/automation-service.js +1 -1
  10. package/dist/src/browser-panel-tool.d.ts +24 -3
  11. package/dist/src/browser-panel-tool.js +80 -6
  12. package/dist/src/browser-runner.js +3 -1
  13. package/dist/src/browser-session.d.ts +8 -0
  14. package/dist/src/browser-session.js +27 -1
  15. package/dist/src/browser-ui/app.js +237 -15
  16. package/dist/src/browser-ui/index.html +5 -5
  17. package/dist/src/browser-ui/style.css +110 -65
  18. package/dist/src/browser-ui/tokens.css +27 -26
  19. package/dist/src/browser-view.d.ts +16 -0
  20. package/dist/src/browser-view.js +38 -2
  21. package/dist/src/claude-provider.js +15 -2
  22. package/dist/src/cli.d.ts +2 -1
  23. package/dist/src/cli.js +175 -43
  24. package/dist/src/code-intelligence/CodeIntelligenceManager.js +1 -1
  25. package/dist/src/codex-provider.js +6 -3
  26. package/dist/src/coding-tools.d.ts +26 -1
  27. package/dist/src/coding-tools.js +104 -33
  28. package/dist/src/command-screens.js +1 -1
  29. package/dist/src/commands.js +1 -1
  30. package/dist/src/completion-gates.d.ts +42 -7
  31. package/dist/src/completion-gates.js +55 -9
  32. package/dist/src/completion.d.ts +51 -1
  33. package/dist/src/completion.js +164 -5
  34. package/dist/src/config.d.ts +1 -0
  35. package/dist/src/config.js +2 -0
  36. package/dist/src/dashboard-view.js +2 -2
  37. package/dist/src/deadline.js +4 -0
  38. package/dist/src/decision/PreparedSteps.js +1 -1
  39. package/dist/src/delegation-changes.js +19 -2
  40. package/dist/src/diff-preview.d.ts +1 -0
  41. package/dist/src/diff-preview.js +12 -3
  42. package/dist/src/engine-streams.d.ts +22 -0
  43. package/dist/src/engine-streams.js +16 -0
  44. package/dist/src/extensions.js +17 -6
  45. package/dist/src/file-read-key.d.ts +8 -0
  46. package/dist/src/file-read-key.js +12 -0
  47. package/dist/src/graph-editor-session.js +2 -1
  48. package/dist/src/graph-health.d.ts +21 -0
  49. package/dist/src/graph-health.js +46 -0
  50. package/dist/src/graph-manager-chat.d.ts +52 -3
  51. package/dist/src/graph-manager-chat.js +62 -17
  52. package/dist/src/graph-runner.js +62 -5
  53. package/dist/src/graph-server.d.ts +1 -1
  54. package/dist/src/graph-server.js +48 -27
  55. package/dist/src/graph-sync.d.ts +8 -0
  56. package/dist/src/graph-sync.js +54 -3
  57. package/dist/src/graph-tool.js +1 -1
  58. package/dist/src/graph-ui/app.js +362 -123
  59. package/dist/src/graph-ui/controls.css +95 -22
  60. package/dist/src/graph-ui/controls.js +31 -1
  61. package/dist/src/graph-ui/embed.js +62 -13
  62. package/dist/src/graph-ui/icons.js +7 -0
  63. package/dist/src/graph-ui/index.html +4 -4
  64. package/dist/src/graph-ui/manager-state.js +143 -5
  65. package/dist/src/graph-ui/manager.css +21 -20
  66. package/dist/src/graph-ui/manager.js +337 -75
  67. package/dist/src/graph-ui/model-picker.js +279 -0
  68. package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
  69. package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
  70. package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
  71. package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
  72. package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
  73. package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
  74. package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
  75. package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
  76. package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
  77. package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
  78. package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
  79. package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
  80. package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
  81. package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
  82. package/dist/src/graph-ui/skill-picker.js +1 -1
  83. package/dist/src/graph-ui/studio-canvas.js +8 -8
  84. package/dist/src/graph-ui/studio.css +18 -15
  85. package/dist/src/graph-ui/studio.js +92 -35
  86. package/dist/src/graph-ui/style.css +122 -79
  87. package/dist/src/graph-ui/theme.js +2 -2
  88. package/dist/src/graph-ui/tokens.css +33 -29
  89. package/dist/src/graphs.d.ts +5 -2
  90. package/dist/src/graphs.js +10 -9
  91. package/dist/src/mcp.d.ts +52 -14
  92. package/dist/src/mcp.js +285 -128
  93. package/dist/src/membership-errors.d.ts +7 -1
  94. package/dist/src/membership-errors.js +9 -3
  95. package/dist/src/memory/ProjectMemory.d.ts +77 -0
  96. package/dist/src/memory/ProjectMemory.js +310 -0
  97. package/dist/src/memory/index.d.ts +1 -0
  98. package/dist/src/memory/index.js +1 -0
  99. package/dist/src/opencode-provider.js +5 -6
  100. package/dist/src/package-name.d.ts +3 -0
  101. package/dist/src/package-name.js +3 -0
  102. package/dist/src/provider-engine.js +2 -2
  103. package/dist/src/pull-requests.d.ts +42 -6
  104. package/dist/src/pull-requests.js +11 -3
  105. package/dist/src/qa/runtime/PtyManager.js +2 -1
  106. package/dist/src/react-runtime.js +137 -22
  107. package/dist/src/read-document-doc.d.ts +20 -0
  108. package/dist/src/read-document-doc.js +524 -0
  109. package/dist/src/read-document-docx.d.ts +21 -0
  110. package/dist/src/read-document-docx.js +584 -0
  111. package/dist/src/read-document-text.d.ts +29 -0
  112. package/dist/src/read-document-text.js +67 -0
  113. package/dist/src/read-document-tool.d.ts +48 -0
  114. package/dist/src/read-document-tool.js +162 -0
  115. package/dist/src/read-document.d.ts +78 -0
  116. package/dist/src/read-document.js +353 -0
  117. package/dist/src/read-image.d.ts +29 -2
  118. package/dist/src/read-image.js +42 -17
  119. package/dist/src/remote/cert.d.ts +1 -1
  120. package/dist/src/remote/cert.js +2 -7
  121. package/dist/src/remote/client.js +1 -1
  122. package/dist/src/remote/pem.d.ts +6 -0
  123. package/dist/src/remote/pem.js +11 -0
  124. package/dist/src/run-records.js +49 -10
  125. package/dist/src/runtime.d.ts +21 -0
  126. package/dist/src/runtime.js +10 -1
  127. package/dist/src/session-changes.d.ts +6 -1
  128. package/dist/src/session-changes.js +13 -5
  129. package/dist/src/sessions.d.ts +3 -1
  130. package/dist/src/sessions.js +5 -3
  131. package/dist/src/side-panel.d.ts +6 -1
  132. package/dist/src/side-panel.js +12 -10
  133. package/dist/src/sign-in-detection.d.ts +82 -0
  134. package/dist/src/sign-in-detection.js +197 -0
  135. package/dist/src/sign-in-offer.d.ts +35 -0
  136. package/dist/src/sign-in-offer.js +116 -0
  137. package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
  138. package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
  139. package/dist/src/skills/bundled/graph-manager/SKILL.md +59 -7
  140. package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
  141. package/dist/src/skills/bundled/provenance.json +4 -4
  142. package/dist/src/skills/runtime-skills.d.ts +6 -0
  143. package/dist/src/skills/runtime-skills.js +16 -3
  144. package/dist/src/stall-recovery.d.ts +6 -2
  145. package/dist/src/stall-recovery.js +7 -2
  146. package/dist/src/stray-files.d.ts +14 -0
  147. package/dist/src/stray-files.js +81 -0
  148. package/dist/src/subagent-run.js +6 -1
  149. package/dist/src/terminal-ui.d.ts +1 -1
  150. package/dist/src/terminal-ui.js +11 -5
  151. package/dist/src/time-limit.d.ts +53 -0
  152. package/dist/src/time-limit.js +79 -0
  153. package/dist/src/tool-activity.js +1 -1
  154. package/dist/src/tool-schema-compatibility.d.ts +7 -2
  155. package/dist/src/tool-schema-compatibility.js +8 -4
  156. package/dist/src/tools.js +92 -7
  157. package/dist/src/transcript.d.ts +5 -0
  158. package/dist/src/transcript.js +12 -4
  159. package/dist/src/types.d.ts +8 -0
  160. package/dist/src/untracked-file-removal.d.ts +3 -0
  161. package/dist/src/untracked-file-removal.js +125 -0
  162. package/dist/src/update-check.js +1 -1
  163. package/dist/src/update.d.ts +11 -1
  164. package/dist/src/update.js +27 -5
  165. package/dist/src/usage-analytics.d.ts +3 -1
  166. package/dist/src/usage-analytics.js +16 -2
  167. package/dist/src/workspace-git-metadata.d.ts +15 -0
  168. package/dist/src/workspace-git-metadata.js +50 -1
  169. package/dist/src/workspace-instructions.js +1 -1
  170. package/package.json +6 -26
  171. package/docs/README.md +0 -36
  172. package/docs/agents/README.md +0 -62
  173. package/docs/agents/install-for-agents.md +0 -56
  174. package/docs/agents/mcp-server.md +0 -212
  175. package/docs/agents/subagent-mode.md +0 -149
  176. package/docs/concepts/README.md +0 -47
  177. package/docs/concepts/jev-actionable-routing.md +0 -113
  178. package/docs/concepts/jev-decision-thresholds.md +0 -412
  179. package/docs/concepts/jev-efficiency.md +0 -217
  180. package/docs/concepts/jev-eval-2026-11-01.md +0 -78
  181. package/docs/concepts/limits.md +0 -52
  182. package/docs/concepts/memory.md +0 -10
  183. package/docs/concepts/security.md +0 -50
  184. package/docs/concepts/workspace-instructions.md +0 -29
  185. package/docs/getting-started/README.md +0 -82
  186. package/docs/getting-started/accounts.md +0 -78
  187. package/docs/getting-started/configure-providers.md +0 -132
  188. package/docs/guides/README.md +0 -13
  189. package/docs/guides/browser.md +0 -39
  190. package/docs/guides/desktop-app.md +0 -414
  191. package/docs/guides/extensions.md +0 -102
  192. package/docs/guides/graph-builder.md +0 -116
  193. package/docs/guides/headless.md +0 -46
  194. package/docs/guides/tui.md +0 -75
  195. package/docs/guides/update.md +0 -70
  196. package/docs/guides/web-search.md +0 -51
  197. package/docs/guides/windows-code-signing.md +0 -319
  198. package/docs/llms.txt +0 -45
  199. package/docs/reference/README.md +0 -7
  200. package/docs/reference/cli.md +0 -76
  201. package/docs/reference/config.md +0 -91
  202. package/docs/reference/slash-commands.md +0 -59
  203. package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
  204. package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
  205. package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
  206. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
  207. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
  208. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
  209. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
  210. package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
  211. package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
  212. package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
  213. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
  214. package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
  215. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
  216. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
  217. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
  218. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
  219. package/scripts/jev-efficiency-eval.mjs +0 -187
  220. package/scripts/jev-efficiency-live.mjs +0 -193
  221. package/scripts/zcode-engine-replay.mjs +0 -223
  222. package/tests/agent-centric-mcp-test-plan.md +0 -208
  223. package/tests/analytics-settings-test-plan.md +0 -165
  224. package/tests/browser-cli-smoke.mjs +0 -276
  225. package/tests/browser-test-plan.md +0 -280
  226. package/tests/chat-side-panel-test-plan.md +0 -309
  227. package/tests/decision-engine-test-plan.md +0 -163
  228. package/tests/default-active-jev-test-plan.md +0 -85
  229. package/tests/harness-extensions-test-plan.md +0 -113
  230. package/tests/jev-all-decisions-test-plan.md +0 -156
  231. package/tests/jev-efficiency/criteria.json +0 -158
  232. package/tests/jev-efficiency/workloads.mjs +0 -242
  233. package/tests/jev-efficiency-test-plan.md +0 -198
  234. package/tests/permissions-sandbox-probe.mjs +0 -74
  235. package/tests/permissions-test-plan.md +0 -191
  236. package/tests/product-telemetry-test-plan.md +0 -536
  237. package/tests/thinking-stream-preview-test-plan.md +0 -136
  238. package/tests/zcode-react-engine-test-plan.md +0 -396
@@ -57,7 +57,7 @@ async function status(directory) {
57
57
  const live = await contact(directory, 'status');
58
58
  const registered = await installed(directory);
59
59
  return { running: !!live, installed: registered, installSupported: process.platform === 'win32', ...(live ? { pid: live.pid } : {}),
60
- detail: live ? 'Background scheduler is running. The computer must stay awake and signed in.' : registered ? 'Start at sign-in is installed; the background scheduler is stopped.' : 'Background scheduler is stopped. App-open schedules still run while Andorra is open.' };
60
+ detail: live ? 'Background scheduler is running. The computer must stay awake and signed in.' : registered ? 'Start at sign-in is installed; the background scheduler is stopped.' : 'Background scheduler is stopped. App-open schedules still run while Andorra Code is open.' };
61
61
  }
62
62
  /** Authenticated loopback control avoids signalling an unrelated process after PID reuse. */
63
63
  export async function runAutomationDaemon(directory = configDirectory(), externalSignal) {
@@ -1,5 +1,9 @@
1
1
  import type { Tool, ToolImage } from './types.js';
2
2
  import type { BrowserViewManager } from './browser-view.js';
3
+ /** How long one renewal keeps the panel browser from being idle-reaped. */
4
+ export declare const PANEL_HOLD_LEASE_MS: number;
5
+ /** How often a live run renews it: well inside the lease, so one lost renewal does not lapse it. */
6
+ export declare const PANEL_HOLD_RENEW_MS: number;
3
7
  export interface PanelArguments {
4
8
  operation: string;
5
9
  url?: string;
@@ -28,19 +32,36 @@ export type PanelBrowserRelay = (operation: string, args: Record<string, unknown
28
32
  image?: ToolImage;
29
33
  error?: string;
30
34
  }>;
35
+ /** A run's lease on its session's panel browser: armed by the agent's first panel operation, ended with the run. */
36
+ export interface PanelBrowserHold {
37
+ /** Called after each successful panel operation: takes the lease now and starts renewing it. */
38
+ touch(): void;
39
+ /** The run is over: stop renewing, and let the browser fall back to the ordinary idle window. */
40
+ stop(): void;
41
+ }
42
+ /**
43
+ * Keep the session's panel browser open while the run that drove it lives.
44
+ *
45
+ * The owning engine reaps a panel browser nobody streams after `VIEW_IDLE_CLOSE_MS`. A run that
46
+ * opened a page and then waits — on the user's answer to a question about that page, typically —
47
+ * would otherwise lose the page under them. The lease is renewed on an unref'd timer, through the
48
+ * same relay as the agent's operations when another engine owns the browser; a renewal that fails
49
+ * is retried on the next tick, and an owner that never hears from us again reaps on its own.
50
+ */
51
+ export declare function createPanelBrowserHold(views: BrowserViewManager, sessionId: string, relay?: PanelBrowserRelay): PanelBrowserHold;
31
52
  /**
32
53
  * The agent's handle on the session's browser panel: the same tabs, cookies and
33
54
  * login state the user sees and shares in the desktop's Browser panel. Created
34
55
  * per run by the app-server: on the engine that owns the panel the operations
35
56
  * run locally; on a task engine they relay through the desktop to the owning
36
57
  * engine. Environments without a panel (the CLI) never create one, so the tool
37
- * never appears there.
58
+ * never appears there. `hold`, when given, keeps the browser open while the run lives.
38
59
  */
39
- export declare function createBrowserPanelTool(views: BrowserViewManager, sessionId: string, relay?: PanelBrowserRelay): Tool;
60
+ export declare function createBrowserPanelTool(views: BrowserViewManager, sessionId: string, relay?: PanelBrowserRelay, hold?: PanelBrowserHold): Tool;
40
61
  /**
41
62
  * The agent's switch between the project profile and a throwaway incognito
42
63
  * browser in the session's Browser panel. A tool of its own rather than another
43
64
  * `browser.panel` operation, so the agent sees plainly that a signed-out, fresh
44
65
  * browser is available to it. It shares the panel tool's local and relayed paths.
45
66
  */
46
- export declare function createBrowserIncognitoTool(views: BrowserViewManager, sessionId: string, relay?: PanelBrowserRelay): Tool;
67
+ export declare function createBrowserIncognitoTool(views: BrowserViewManager, sessionId: string, relay?: PanelBrowserRelay, hold?: PanelBrowserHold): Tool;
@@ -5,7 +5,17 @@ import { browserEventArguments, IMAGE_LIMIT, PENDING_IMAGE_LIMIT, reserveBrowser
5
5
  const PAGE_OPERATIONS = ['open', 'navigate', 'back', 'forward', 'refresh', 'tabs', 'activate', 'close_tab', 'snapshot', 'click', 'fill', 'press', 'scroll', 'wait', 'screenshot'];
6
6
  /** Whole-browser switches: exposed to the agent as `browser.incognito`, relayed like any panel operation. */
7
7
  const INCOGNITO_OPERATIONS = ['incognito_start', 'incognito_end'];
8
- const OPERATIONS = [...PAGE_OPERATIONS, ...INCOGNITO_OPERATIONS];
8
+ /**
9
+ * The run's own lease on the panel browser (see `BrowserViewManager.hold`): never offered to the
10
+ * agent, sent by the tool itself while its run lives, and relayed like any panel operation so it
11
+ * reaches the engine that owns the browser.
12
+ */
13
+ const HOLD_OPERATION = 'hold';
14
+ const OPERATIONS = [...PAGE_OPERATIONS, ...INCOGNITO_OPERATIONS, HOLD_OPERATION];
15
+ /** How long one renewal keeps the panel browser from being idle-reaped. */
16
+ export const PANEL_HOLD_LEASE_MS = 3 * 60 * 1000;
17
+ /** How often a live run renews it: well inside the lease, so one lost renewal does not lapse it. */
18
+ export const PANEL_HOLD_RENEW_MS = 60 * 1000;
9
19
  const ARGUMENTS = ['operation', 'url', 'tabId', 'selector', 'value', 'key', 'button', 'deltaY'];
10
20
  function text(args, name, max = 2048) {
11
21
  const value = args[name];
@@ -98,6 +108,8 @@ export async function runPanelOperation(views, sessionId, args, signal) {
98
108
  const { operation, url, tabId, selector } = args;
99
109
  if (operation === 'tabs')
100
110
  return { result: panelTabsResult(views, sessionId) };
111
+ if (operation === HOLD_OPERATION)
112
+ return { result: JSON.stringify({ sessionId, ...views.hold(sessionId, PANEL_HOLD_LEASE_MS) }) };
101
113
  if (operation === 'incognito_start') {
102
114
  const opened = await cancellable(signal, owned => views.startIncognito(sessionId, owned), 35_000, 'Starting the incognito browser exceeded the 35-second timeout.');
103
115
  return { result: JSON.stringify({ sessionId, profile: 'incognito', tabId: opened.tabId,
@@ -179,15 +191,68 @@ function panelTabsResult(views, sessionId) {
179
191
  const summary = views.agentTabs(sessionId);
180
192
  return JSON.stringify({ sessionId, tabs: summary.tabs.map(tab => ({ tabId: tab.id, active: tab.id === summary.activeTabId, url: tab.url, title: tab.title })) });
181
193
  }
194
+ /**
195
+ * Keep the session's panel browser open while the run that drove it lives.
196
+ *
197
+ * The owning engine reaps a panel browser nobody streams after `VIEW_IDLE_CLOSE_MS`. A run that
198
+ * opened a page and then waits — on the user's answer to a question about that page, typically —
199
+ * would otherwise lose the page under them. The lease is renewed on an unref'd timer, through the
200
+ * same relay as the agent's operations when another engine owns the browser; a renewal that fails
201
+ * is retried on the next tick, and an owner that never hears from us again reaps on its own.
202
+ */
203
+ export function createPanelBrowserHold(views, sessionId, relay) {
204
+ let timer;
205
+ let stopped = false;
206
+ let renewing = false;
207
+ const renew = async () => {
208
+ if (stopped || renewing)
209
+ return;
210
+ renewing = true;
211
+ try {
212
+ if (!relay) {
213
+ views.hold(sessionId, PANEL_HOLD_LEASE_MS);
214
+ return;
215
+ }
216
+ const deadline = new AbortController();
217
+ const bound = setTimeout(() => deadline.abort(), PANEL_HOLD_RENEW_MS);
218
+ bound.unref?.();
219
+ try {
220
+ await relay(HOLD_OPERATION, { operation: HOLD_OPERATION }, deadline.signal);
221
+ }
222
+ finally {
223
+ clearTimeout(bound);
224
+ }
225
+ }
226
+ catch { /* The next tick retries; the lease outlasts one missed renewal. */ }
227
+ finally {
228
+ renewing = false;
229
+ }
230
+ };
231
+ return {
232
+ touch: () => {
233
+ if (stopped || timer)
234
+ return;
235
+ void renew();
236
+ timer = setInterval(() => { void renew(); }, PANEL_HOLD_RENEW_MS);
237
+ timer.unref?.();
238
+ },
239
+ stop: () => {
240
+ stopped = true;
241
+ if (timer)
242
+ clearInterval(timer);
243
+ timer = undefined;
244
+ },
245
+ };
246
+ }
182
247
  /**
183
248
  * The agent's handle on the session's browser panel: the same tabs, cookies and
184
249
  * login state the user sees and shares in the desktop's Browser panel. Created
185
250
  * per run by the app-server: on the engine that owns the panel the operations
186
251
  * run locally; on a task engine they relay through the desktop to the owning
187
252
  * engine. Environments without a panel (the CLI) never create one, so the tool
188
- * never appears there.
253
+ * never appears there. `hold`, when given, keeps the browser open while the run lives.
189
254
  */
190
- export function createBrowserPanelTool(views, sessionId, relay) {
255
+ export function createBrowserPanelTool(views, sessionId, relay, hold) {
191
256
  /** Captured screenshots awaiting the runtime's resultImages collection. */
192
257
  const pending = new Map();
193
258
  return {
@@ -225,6 +290,8 @@ export function createBrowserPanelTool(views, sessionId, relay) {
225
290
  const validated = validatePanelArguments(args);
226
291
  if (INCOGNITO_OPERATIONS.includes(validated.operation))
227
292
  throw new Error('Use browser.incognito to switch the panel browser to or from incognito');
293
+ if (validated.operation === HOLD_OPERATION)
294
+ throw new Error('Invalid browser panel operation or argument');
228
295
  await authorize('browser.panel', browserEventArguments(args), context);
229
296
  context.signal.throwIfAborted();
230
297
  // One operation, whichever engine's browser executes it: the owning
@@ -249,6 +316,7 @@ export function createBrowserPanelTool(views, sessionId, relay) {
249
316
  let committed = false;
250
317
  try {
251
318
  const captured = await run();
319
+ hold?.touch();
252
320
  const bytes = Number.isSafeInteger(JSON.parse(captured.result).bytes) ? JSON.parse(captured.result).bytes : IMAGE_LIMIT;
253
321
  reservation.commit(bytes);
254
322
  committed = true;
@@ -261,7 +329,10 @@ export function createBrowserPanelTool(views, sessionId, relay) {
261
329
  reservation.refund();
262
330
  }
263
331
  }
264
- return (await run()).result;
332
+ const { result } = await run();
333
+ // The agent has used the panel this run: from here the browser stays open while the run lives.
334
+ hold?.touch();
335
+ return result;
265
336
  },
266
337
  };
267
338
  }
@@ -271,7 +342,7 @@ export function createBrowserPanelTool(views, sessionId, relay) {
271
342
  * `browser.panel` operation, so the agent sees plainly that a signed-out, fresh
272
343
  * browser is available to it. It shares the panel tool's local and relayed paths.
273
344
  */
274
- export function createBrowserIncognitoTool(views, sessionId, relay) {
345
+ export function createBrowserIncognitoTool(views, sessionId, relay, hold) {
275
346
  return {
276
347
  name: 'browser.incognito', family: 'browser', capability: 'browser', executionMode: 'sequential',
277
348
  description: 'Switch this session\'s Browser panel between the project profile and a fresh incognito browser. The panel normally runs on the project\'s persistent profile: logins, cookies, history and cache shared with the user and every session of this project. start closes the panel browser (its tabs close; the saved project profile is untouched) and opens an incognito browser with one blank tab and no logins, cookies, storage, history or cache — use it to test as a signed-out or first-time visitor, then drive it with browser.panel. Nothing from incognito is saved. end closes the incognito browser so the next browser.panel open uses the project profile again; incognito also ends on its own when the panel browser closes (last tab closed, idle, or app restart). Browser capability and normal approvals are required.',
@@ -290,9 +361,12 @@ export function createBrowserIncognitoTool(views, sessionId, relay) {
290
361
  throw new Error(answer.error);
291
362
  if (answer.result === undefined)
292
363
  throw new Error('The panel browser relay returned no result');
364
+ hold?.touch();
293
365
  return answer.result;
294
366
  }
295
- return (await runPanelOperation(views, sessionId, { operation }, context.signal)).result;
367
+ const { result } = await runPanelOperation(views, sessionId, { operation }, context.signal);
368
+ hold?.touch();
369
+ return result;
296
370
  },
297
371
  };
298
372
  }
@@ -21,6 +21,7 @@ import { connectMcpServers } from './mcp.js';
21
21
  import { hostedDecisionPolicy } from './decision/hostedPolicy.js';
22
22
  import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
23
23
  import { LocalToolMemory } from './memory/LocalToolMemory.js';
24
+ import { ProjectMemory } from './memory/ProjectMemory.js';
24
25
  import { TodoStore } from './todos.js';
25
26
  import { RunControl } from './run-control.js';
26
27
  import { createSessionTrajectory } from './trajectory.js';
@@ -248,12 +249,13 @@ export async function runBrowserTask(session, task, control, options = {}) {
248
249
  adapter: adapters(refreshed), contextWindow: refreshed.contextWindow, providerType: selected.type, baseUrl: selected.baseUrl }));
249
250
  const membership = config.jevEnabled === false ? { paid: false } : await getMembership(signal, directory);
250
251
  const commandMemory = config.commandMemory === false ? undefined : await LocalToolMemory.open({ workspace, directory });
252
+ const projectMemory = config.projectMemory === false ? undefined : await ProjectMemory.open({ home: directory, workspace });
251
253
  signal.throwIfAborted();
252
254
  const result = await runGraph(graph, {
253
255
  task, runId, provider: selected.id, model: refreshed.model, adapter: adapters(refreshed), contextWindow: refreshed.contextWindow,
254
256
  tools: [...createTools(), ...snapshot.tools, ...mcp.tools], history: (session.contextHistory ?? session.history).slice(-6),
255
257
  instructions: `${workspaceGuidance}${snapshot.instructions}`,
256
- context, codeIntel, commandMemory, todoStore: new TodoStore(),
258
+ context, codeIntel, commandMemory, projectMemory, todoStore: new TodoStore(),
257
259
  ...hostedDecisionPolicy(membership, config.jevEnabled !== false, config.decisions), limits: resolveConfiguredLimits(config),
258
260
  getSteeringMessages: async () => control.steering().map(content => ({ role: 'user', content })),
259
261
  onEvent,
@@ -6,6 +6,14 @@ export declare function isBrowserToolName(name: string): boolean;
6
6
  /** Project telemetry before any event consumer can persist a browser input. */
7
7
  export declare function browserEventArguments(args: unknown): unknown;
8
8
  export declare function disposeBrowserSessions(identity?: object): Promise<void>;
9
+ /**
10
+ * Said when no channel has anything to launch. A container or server image often has no browser
11
+ * at all, and "install Chrome/Edge" sent agents off to install one mid-task; the useful answer is
12
+ * to stop calling browser tools and reach the page another way.
13
+ */
14
+ export declare const MISSING_BROWSER_MESSAGE = "Browser unavailable: no Chromium, Chrome or Edge is installed in this environment, so browser tools cannot run here. Do not call them again in this run. Fetch pages with curl or a script instead, and say in your summary that no browser check was possible. Only if the task itself needs a real browser, install one with `npx playwright-core install --with-deps chromium`.";
15
+ /** Forget a remembered "no browser" result; for tests and for a caller that just installed one. */
16
+ export declare function resetBrowserAvailability(): void;
9
17
  /**
10
18
  * Reserve one screenshot against the image budget every browser tool in this
11
19
  * agent tool batch shares. The reservation is a fixed estimate; `commit` trims
@@ -147,6 +147,9 @@ export async function disposeBrowserSessions(identity) {
147
147
  }
148
148
  /** Headless isolated profile; never attaches to the user's existing browser. */
149
149
  async function launch(signal) {
150
+ if (missingBrowser && Date.now() < missingBrowser.until)
151
+ throw new Error(missingBrowser.message);
152
+ missingBrowser = undefined;
150
153
  const specifier = 'playwright-core';
151
154
  const { chromium } = await import(specifier);
152
155
  const failures = [];
@@ -183,8 +186,31 @@ async function launch(signal) {
183
186
  failures.push((error instanceof Error ? error.message : String(error)).split('\n')[0]);
184
187
  }
185
188
  }
186
- throw new Error(`Browser unavailable: install Chrome/Edge or the Chromium version required by playwright-core. ${failures.join('; ').slice(0, 1000)}`);
189
+ const detail = failures.join('; ').slice(0, 1000);
190
+ if (failures.length && failures.every(noBrowserInstalled)) {
191
+ // Nothing to launch is a fact about the machine, not about this call: remember it so the next
192
+ // call answers at once instead of trying three channels again, and tell the model what to do
193
+ // in its place. The memory is short, so a browser installed during the run is still found.
194
+ missingBrowser = { until: Date.now() + MISSING_BROWSER_MEMORY_MS, message: `${MISSING_BROWSER_MESSAGE} ${detail}` };
195
+ throw new Error(missingBrowser.message);
196
+ }
197
+ throw new Error(`Browser unavailable: install Chrome/Edge or the Chromium version required by playwright-core. ${detail}`);
198
+ }
199
+ /** How long a "no browser is installed" result is reused before the machine is asked again. */
200
+ const MISSING_BROWSER_MEMORY_MS = 60_000;
201
+ /**
202
+ * Said when no channel has anything to launch. A container or server image often has no browser
203
+ * at all, and "install Chrome/Edge" sent agents off to install one mid-task; the useful answer is
204
+ * to stop calling browser tools and reach the page another way.
205
+ */
206
+ export const MISSING_BROWSER_MESSAGE = 'Browser unavailable: no Chromium, Chrome or Edge is installed in this environment, so browser tools cannot run here. Do not call them again in this run. Fetch pages with curl or a script instead, and say in your summary that no browser check was possible. Only if the task itself needs a real browser, install one with `npx playwright-core install --with-deps chromium`.';
207
+ let missingBrowser;
208
+ /** Playwright's wording for a channel or bundled build that is not on disk. */
209
+ function noBrowserInstalled(failure) {
210
+ return /Executable doesn't exist|is not found at|distribution '[^']+' is not found|Failed to find|ENOENT/i.test(failure);
187
211
  }
212
+ /** Forget a remembered "no browser" result; for tests and for a caller that just installed one. */
213
+ export function resetBrowserAvailability() { missingBrowser = undefined; }
188
214
  class BrowserOperationTimeoutError extends Error {
189
215
  }
190
216
  /** Own late transport settlement without awaiting an unresponsive browser close. */