@steipete/oracle 0.14.1 → 0.15.1

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 (85) hide show
  1. package/dist/bin/oracle-cli.js +16 -6
  2. package/dist/bin/oracle.js +569 -0
  3. package/dist/docs-site/.nojekyll +0 -0
  4. package/dist/docs-site/CNAME +1 -0
  5. package/dist/docs-site/RELEASING.html +410 -0
  6. package/dist/docs-site/agents.html +374 -0
  7. package/dist/docs-site/anthropic.html +368 -0
  8. package/dist/docs-site/bridge.html +416 -0
  9. package/dist/docs-site/browser-mode.html +594 -0
  10. package/dist/docs-site/chromium-forks.html +347 -0
  11. package/dist/docs-site/cli-reference.html +346 -0
  12. package/dist/docs-site/configuration.html +462 -0
  13. package/dist/docs-site/favicon.svg +14 -0
  14. package/dist/docs-site/followup.html +375 -0
  15. package/dist/docs-site/gemini.html +383 -0
  16. package/dist/docs-site/grok.html +325 -0
  17. package/dist/docs-site/index.html +360 -0
  18. package/dist/docs-site/install.html +335 -0
  19. package/dist/docs-site/linux.html +321 -0
  20. package/dist/docs-site/llms.txt +43 -0
  21. package/dist/docs-site/manual-tests.html +596 -0
  22. package/dist/docs-site/mcp.html +391 -0
  23. package/dist/docs-site/multimodel.html +364 -0
  24. package/dist/docs-site/mythical-pro-agents.html +360 -0
  25. package/dist/docs-site/notifier.html +338 -0
  26. package/dist/docs-site/openai-endpoints.html +399 -0
  27. package/dist/docs-site/openrouter.html +344 -0
  28. package/dist/docs-site/quickstart.html +369 -0
  29. package/dist/docs-site/refactor/ux.html +532 -0
  30. package/dist/docs-site/sessions.html +388 -0
  31. package/dist/docs-site/social-card.png +0 -0
  32. package/dist/docs-site/social-card.svg +79 -0
  33. package/dist/docs-site/spec.html +363 -0
  34. package/dist/docs-site/testing.html +320 -0
  35. package/dist/docs-site/tui-debug.html +326 -0
  36. package/dist/docs-site/windows-work.html +323 -0
  37. package/dist/docs-site/windows.html +320 -0
  38. package/dist/src/browser/actions/assistantResponse.js +40 -31
  39. package/dist/src/browser/actions/attachments.js +28 -1
  40. package/dist/src/browser/actions/deepResearch.js +344 -128
  41. package/dist/src/browser/actions/modelSelection.js +75 -9
  42. package/dist/src/browser/actions/promptComposer.js +71 -14
  43. package/dist/src/browser/actions/thinkingStatus.js +19 -1
  44. package/dist/src/browser/actions/thinkingTime.js +65 -20
  45. package/dist/src/browser/artifacts.js +193 -14
  46. package/dist/src/browser/chatgptFiles.js +674 -91
  47. package/dist/src/browser/chromeCookies.js +312 -0
  48. package/dist/src/browser/chromeLifecycle.js +35 -4
  49. package/dist/src/browser/constants.js +5 -0
  50. package/dist/src/browser/deepResearchResult.js +23 -0
  51. package/dist/src/browser/index.js +112 -41
  52. package/dist/src/browser/keytarShim.js +56 -0
  53. package/dist/src/browser/profileCopy.js +93 -0
  54. package/dist/src/browser/sessionRunner.js +9 -3
  55. package/dist/src/browser/windowsCookies.js +219 -0
  56. package/dist/src/cli/bridge/client.js +4 -1
  57. package/dist/src/cli/bridge/doctor.js +19 -0
  58. package/dist/src/cli/browserConfig.js +17 -1
  59. package/dist/src/cli/runOptions.js +11 -2
  60. package/dist/src/cli/sessionDisplay.js +6 -1
  61. package/dist/src/cli/sessionRunner.js +41 -17
  62. package/dist/src/config.js +3 -0
  63. package/dist/src/oracle/client.js +2 -0
  64. package/dist/src/oracle/modelResolver.js +85 -0
  65. package/dist/src/oracle/multiModelRunner.js +4 -1
  66. package/dist/src/oracle/run.js +4 -1
  67. package/dist/src/remote/client.js +253 -22
  68. package/dist/src/remote/health.js +27 -0
  69. package/dist/src/remote/server.js +239 -4
  70. package/dist/src/remote/types.js +1 -1
  71. package/dist/src/sessionManager.js +1 -0
  72. package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/CodeResources +0 -0
  73. package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/Info.plist +20 -0
  74. package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/MacOS/OracleNotifier +0 -0
  75. package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/Resources/OracleIcon.icns +0 -0
  76. package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/_CodeSignature/CodeResources +128 -0
  77. package/dist/vendor/oracle-notifier/build-notifier.sh +0 -0
  78. package/package.json +45 -43
  79. package/vendor/oracle-notifier/OracleNotifier.app/Contents/CodeResources +0 -0
  80. package/vendor/oracle-notifier/OracleNotifier.app/Contents/Info.plist +20 -0
  81. package/vendor/oracle-notifier/OracleNotifier.app/Contents/MacOS/OracleNotifier +0 -0
  82. package/vendor/oracle-notifier/OracleNotifier.app/Contents/Resources/OracleIcon.icns +0 -0
  83. package/vendor/oracle-notifier/OracleNotifier.app/Contents/_CodeSignature/CodeResources +128 -0
  84. package/vendor/oracle-notifier/README.md +26 -0
  85. package/vendor/oracle-notifier/build-notifier.sh +0 -0
@@ -0,0 +1,312 @@
1
+ import path from 'node:path';
2
+ import os from 'node:os';
3
+ import fs from 'node:fs/promises';
4
+ import { existsSync } from 'node:fs';
5
+ import { createRequire } from 'node:module';
6
+ import chromeCookies from 'chrome-cookies-secure';
7
+ import { COOKIE_URLS } from './constants.js';
8
+ import { ensureCookiesDirForFallback } from './windowsCookies.js';
9
+ const COOKIE_READ_TIMEOUT_MS = readDuration('ORACLE_COOKIE_LOAD_TIMEOUT_MS', 5_000);
10
+ const KEYCHAIN_PROBE_TIMEOUT_MS = readDuration('ORACLE_KEYCHAIN_PROBE_TIMEOUT_MS', 3_000);
11
+ const MAC_KEYCHAIN_LABELS = loadKeychainLabels();
12
+ export async function loadChromeCookies({ targetUrl, profile, explicitCookiePath, filterNames, }) {
13
+ if (process.platform === 'win32') {
14
+ throw new Error('Cookie sync is disabled on Windows; use --browser-manual-login (persistent profile) or inline cookies instead.');
15
+ }
16
+ const urlsToCheck = Array.from(new Set([stripQuery(targetUrl), ...COOKIE_URLS]));
17
+ const merged = new Map();
18
+ const cookieFile = await resolveCookieFilePath({ explicitPath: explicitCookiePath, profile });
19
+ const cookiesPath = await materializeCookieFile(cookieFile); // returns the copied file (or source on non-Windows)
20
+ const fallbackDir = await ensureCookiesDirForFallback(cookiesPath);
21
+ if (process.env.ORACLE_DEBUG_COOKIES === '1') {
22
+ // eslint-disable-next-line no-console
23
+ console.log(`[cookies] resolved cookie file: ${cookiesPath}`);
24
+ console.log(`[cookies] fallback dir for chrome-cookies-secure: ${fallbackDir}`);
25
+ }
26
+ await ensureMacKeychainReadable();
27
+ for (const url of urlsToCheck) {
28
+ let raw;
29
+ try {
30
+ const pathForSecure = await adaptPathForChromeCookies(fallbackDir);
31
+ raw = await settleWithTimeout(chromeCookies.getCookiesPromised(url, 'puppeteer', pathForSecure), COOKIE_READ_TIMEOUT_MS, `Timed out reading Chrome cookies from ${pathForSecure} (after ${COOKIE_READ_TIMEOUT_MS} ms)`);
32
+ }
33
+ catch (error) {
34
+ const message = error instanceof Error ? error.message : String(error);
35
+ throw new Error(`Failed to load Chrome cookies for ${url}: ${message}`);
36
+ }
37
+ if (!Array.isArray(raw))
38
+ continue;
39
+ const fallbackHost = new URL(url).hostname;
40
+ for (const cookie of raw) {
41
+ if (filterNames && filterNames.size > 0 && !filterNames.has(cookie.name))
42
+ continue;
43
+ const normalized = normalizeCookie(cookie, fallbackHost);
44
+ if (!normalized)
45
+ continue;
46
+ const key = `${normalized.domain ?? fallbackHost}:${normalized.name}`;
47
+ if (!merged.has(key)) {
48
+ merged.set(key, normalized);
49
+ }
50
+ }
51
+ }
52
+ return Array.from(merged.values());
53
+ }
54
+ async function ensureMacKeychainReadable() {
55
+ if (process.platform === 'win32') {
56
+ return;
57
+ }
58
+ // chrome-cookies-secure can hang forever when the platform keyring rejects access (e.g., SSH/no GUI).
59
+ // Probe the keyring ourselves with a timeout so callers fail fast instead of blocking the run.
60
+ let keytar = null;
61
+ let keytarPath = null;
62
+ try {
63
+ const require = createRequire(import.meta.url);
64
+ keytarPath = require.resolve('keytar');
65
+ const keytarModule = await import('keytar');
66
+ keytar = (keytarModule.default ?? keytarModule);
67
+ }
68
+ catch (error) {
69
+ const base = error instanceof Error ? error.message : String(error);
70
+ const rebuildHint = keytarPath
71
+ ? ` You may need to rebuild keytar: PYTHON=/usr/bin/python3 /Users/steipete/Projects/oracle/runner npx node-gyp rebuild (run inside ${path.dirname(keytarPath)}).`
72
+ : '';
73
+ throw new Error(`Failed to load keytar for secure cookie copy (${base}). Install keyring deps (macOS Keychain / libsecret) or rerun with --render --copy to paste into ChatGPT manually.${rebuildHint}`);
74
+ }
75
+ const password = await settleWithTimeout(findKeychainPassword(keytar, MAC_KEYCHAIN_LABELS), KEYCHAIN_PROBE_TIMEOUT_MS, `Timed out reading macOS Keychain while looking up Chrome Safe Storage (after ${KEYCHAIN_PROBE_TIMEOUT_MS} ms). Unlock the login keychain or start oracle serve from a GUI session.`);
76
+ if (!password) {
77
+ throw new Error('macOS Keychain denied access to Chrome cookies. Unlock the login keychain or run oracle serve from a GUI session, then retry.');
78
+ }
79
+ }
80
+ async function findKeychainPassword(keytar, labels) {
81
+ let lastError = null;
82
+ for (const label of labels) {
83
+ try {
84
+ const value = await keytar.getPassword(label.service, label.account);
85
+ if (value)
86
+ return value;
87
+ }
88
+ catch (error) {
89
+ lastError = error instanceof Error ? error : new Error(String(error));
90
+ }
91
+ }
92
+ if (lastError) {
93
+ throw lastError;
94
+ }
95
+ return null;
96
+ }
97
+ function settleWithTimeout(promise, timeoutMs, timeoutMessage) {
98
+ return new Promise((resolve, reject) => {
99
+ const timer = setTimeout(() => reject(new Error(timeoutMessage)), timeoutMs);
100
+ timer.unref?.();
101
+ promise.then((value) => {
102
+ clearTimeout(timer);
103
+ resolve(value);
104
+ }, (error) => {
105
+ clearTimeout(timer);
106
+ reject(error);
107
+ });
108
+ });
109
+ }
110
+ function normalizeCookie(cookie, fallbackHost) {
111
+ if (!cookie?.name)
112
+ return null;
113
+ const domain = cookie.domain?.startsWith('.') ? cookie.domain.slice(1) : cookie.domain ?? fallbackHost;
114
+ const expires = normalizeExpiration(cookie.expires);
115
+ const secure = typeof cookie.Secure === 'boolean' ? cookie.Secure : true;
116
+ const httpOnly = typeof cookie.HttpOnly === 'boolean' ? cookie.HttpOnly : false;
117
+ return {
118
+ name: cookie.name,
119
+ value: cleanValue(cookie.value ?? ''),
120
+ domain,
121
+ path: cookie.path ?? '/',
122
+ expires,
123
+ secure,
124
+ httpOnly,
125
+ };
126
+ }
127
+ function cleanValue(value) {
128
+ let i = 0;
129
+ while (i < value.length && value.charCodeAt(i) < 0x20)
130
+ i += 1;
131
+ return value.slice(i);
132
+ }
133
+ function normalizeExpiration(expires) {
134
+ if (!expires || Number.isNaN(expires)) {
135
+ return undefined;
136
+ }
137
+ const value = Number(expires);
138
+ if (value <= 0)
139
+ return undefined;
140
+ if (value > 1_000_000_000_000) {
141
+ return Math.round(value / 1_000_000 - 11644473600);
142
+ }
143
+ if (value > 1_000_000_000) {
144
+ return Math.round(value / 1000);
145
+ }
146
+ return Math.round(value);
147
+ }
148
+ async function resolveCookieFilePath({ explicitPath, profile, }) {
149
+ if (explicitPath && explicitPath.trim().length > 0) {
150
+ return ensureCookieFile(explicitPath);
151
+ }
152
+ if (profile && looksLikePath(profile)) {
153
+ return ensureCookieFile(profile);
154
+ }
155
+ const profileName = profile && profile.trim().length > 0 ? profile : 'Default';
156
+ const baseDir = await defaultProfileRoot();
157
+ return ensureCookieFile(path.join(baseDir, profileName));
158
+ }
159
+ async function adaptPathForChromeCookies(resolved) {
160
+ const stat = await fs.stat(resolved).catch(() => null);
161
+ if (stat?.isFile()) {
162
+ // chrome-cookies-secure appends "Cookies" when given a directory; if we already have the file, return its directory.
163
+ return path.dirname(resolved);
164
+ }
165
+ return resolved;
166
+ }
167
+ async function ensureCookieFile(inputPath) {
168
+ const expanded = expandPath(inputPath);
169
+ const stat = await fs.stat(expanded).catch(() => null);
170
+ if (!stat) {
171
+ throw new Error(`Unable to locate Chrome cookie DB at ${expanded}`);
172
+ }
173
+ if (stat.isDirectory()) {
174
+ const directFile = path.join(expanded, 'Cookies');
175
+ if (await fileExists(directFile))
176
+ return directFile;
177
+ const networkFile = path.join(expanded, 'Network', 'Cookies');
178
+ if (await fileExists(networkFile))
179
+ return networkFile;
180
+ throw new Error(`No Cookies DB found under ${expanded}`);
181
+ }
182
+ return expanded;
183
+ }
184
+ async function fileExists(candidate) {
185
+ try {
186
+ const stat = await fs.stat(candidate);
187
+ return stat.isFile();
188
+ }
189
+ catch {
190
+ return false;
191
+ }
192
+ }
193
+ function expandPath(input) {
194
+ if (input.startsWith('~/')) {
195
+ return path.join(os.homedir(), input.slice(2));
196
+ }
197
+ return path.isAbsolute(input) ? input : path.resolve(process.cwd(), input);
198
+ }
199
+ function looksLikePath(value) {
200
+ return value.includes('/') || value.includes('\\');
201
+ }
202
+ async function materializeCookieFile(sourcePath) {
203
+ if (process.platform !== 'win32')
204
+ return sourcePath;
205
+ // Chrome can keep the Cookies DB locked; copy to a temp file so sqlite can open it reliably.
206
+ const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'oracle-cookies-'));
207
+ const tempPath = path.join(tempDir, 'Cookies');
208
+ try {
209
+ await fs.copyFile(sourcePath, tempPath);
210
+ return tempPath;
211
+ }
212
+ catch (_error) {
213
+ // Fall back to the original path if the copy fails; upstream error handling will surface issues.
214
+ return sourcePath;
215
+ }
216
+ }
217
+ async function defaultProfileRoot() {
218
+ const candidates = [];
219
+ if (process.platform === 'darwin') {
220
+ candidates.push(path.join(os.homedir(), 'Library', 'Application Support', 'Google', 'Chrome'), path.join(os.homedir(), 'Library', 'Application Support', 'Microsoft Edge'), path.join(os.homedir(), 'Library', 'Application Support', 'Chromium'));
221
+ }
222
+ else if (process.platform === 'linux') {
223
+ if (isWsl()) {
224
+ const windowsHomes = [process.env.USERPROFILE, process.env.WIN_HOME, process.env.HOME?.replace('/home', '/mnt/c/Users')]
225
+ .filter((p) => Boolean(p))
226
+ .map((p) => p.replace(/\\/g, '/'));
227
+ const wslCandidates = [];
228
+ for (const home of windowsHomes) {
229
+ const normalized = home.startsWith('/mnt/') ? home : `/mnt/c/Users/${path.basename(home)}`;
230
+ wslCandidates.push(path.join(normalized, 'AppData', 'Local', 'Google', 'Chrome', 'User Data'), path.join(normalized, 'AppData', 'Local', 'Microsoft', 'Edge', 'User Data'));
231
+ }
232
+ // Ensure we don't pick a non-user Default profile ahead of real ones.
233
+ for (const candidate of wslCandidates) {
234
+ const hasProfile = existsSync(path.join(candidate, 'Default'));
235
+ if (hasProfile) {
236
+ candidates.push(candidate);
237
+ }
238
+ }
239
+ }
240
+ candidates.push(path.join(os.homedir(), '.config', 'google-chrome'), path.join(os.homedir(), '.config', 'microsoft-edge'), path.join(os.homedir(), '.config', 'chromium'),
241
+ // Snap Chromium profiles
242
+ path.join(os.homedir(), 'snap', 'chromium', 'common', 'chromium'), path.join(os.homedir(), 'snap', 'chromium', 'current', 'chromium'));
243
+ }
244
+ else if (process.platform === 'win32') {
245
+ const localAppData = process.env.LOCALAPPDATA ?? path.join(os.homedir(), 'AppData', 'Local');
246
+ candidates.push(path.join(localAppData, 'Google', 'Chrome', 'User Data'), path.join(localAppData, 'Microsoft', 'Edge', 'User Data'), path.join(localAppData, 'Chromium', 'User Data'));
247
+ }
248
+ else {
249
+ throw new Error(`Unsupported platform: ${process.platform}`);
250
+ }
251
+ for (const candidate of candidates) {
252
+ if (existsSync(candidate)) {
253
+ return candidate;
254
+ }
255
+ }
256
+ // fallback: first candidate even if missing; upstream will throw clearer error
257
+ return candidates[0];
258
+ }
259
+ function stripQuery(url) {
260
+ try {
261
+ const parsed = new URL(url);
262
+ parsed.hash = '';
263
+ parsed.search = '';
264
+ return parsed.toString();
265
+ }
266
+ catch {
267
+ return url;
268
+ }
269
+ }
270
+ function readDuration(envKey, fallback) {
271
+ const raw = process.env[envKey];
272
+ if (!raw)
273
+ return fallback;
274
+ const parsed = Number.parseInt(raw, 10);
275
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
276
+ }
277
+ function isWsl() {
278
+ if (process.platform !== 'linux')
279
+ return false;
280
+ return Boolean(process.env.WSL_DISTRO_NAME || os.release().toLowerCase().includes('microsoft'));
281
+ }
282
+ function loadKeychainLabels() {
283
+ const defaults = [
284
+ { service: 'Chrome Safe Storage', account: 'Chrome' },
285
+ { service: 'Chromium Safe Storage', account: 'Chromium' },
286
+ { service: 'Microsoft Edge Safe Storage', account: 'Microsoft Edge' },
287
+ { service: 'Brave Safe Storage', account: 'Brave' },
288
+ { service: 'Vivaldi Safe Storage', account: 'Vivaldi' },
289
+ ];
290
+ const rawEnv = process.env.ORACLE_KEYCHAIN_LABELS;
291
+ if (!rawEnv)
292
+ return defaults;
293
+ try {
294
+ const parsed = JSON.parse(rawEnv);
295
+ if (!Array.isArray(parsed))
296
+ return defaults;
297
+ const envLabels = parsed
298
+ .map((entry) => (entry && typeof entry === 'object' ? entry : null))
299
+ .filter((entry) => Boolean(entry?.service && entry?.account));
300
+ return envLabels.length ? [...envLabels, ...defaults] : defaults;
301
+ }
302
+ catch {
303
+ return defaults;
304
+ }
305
+ }
306
+ // biome-ignore lint/style/useNamingConvention: test-only export used in vitest suite
307
+ export const __test__ = {
308
+ normalizeExpiration,
309
+ cleanValue,
310
+ looksLikePath,
311
+ defaultProfileRoot,
312
+ };
@@ -15,20 +15,31 @@ export async function launchChrome(config, userDataDir, logger) {
15
15
  const debugPort = config.debugPort ?? parseDebugPortEnv();
16
16
  const chromeFlags = buildChromeFlags(config.headless ?? false, debugBindAddress);
17
17
  const usePatchedLauncher = Boolean(connectHost && connectHost !== "127.0.0.1");
18
+ // copy-profile reuses a copied signed-in profile whose cookies are
19
+ // Keychain-encrypted, so it must launch with the real Keychain (not mocked):
20
+ // strip the keychain-mocking flags from both chrome-launcher's defaults and
21
+ // Oracle's set, and ignore the defaults so they aren't re-added.
22
+ const usingCopiedProfile = Boolean(config.copyProfileSource);
23
+ if (usingCopiedProfile && config.chromeProfile) {
24
+ chromeFlags.push(`--profile-directory=${config.chromeProfile}`);
25
+ }
26
+ const launchOptions = resolveChromeLaunchOptions(chromeFlags, usingCopiedProfile);
18
27
  const launcher = usePatchedLauncher
19
28
  ? await launchWithCustomHost({
20
- chromeFlags,
29
+ chromeFlags: launchOptions.chromeFlags,
21
30
  chromePath: config.chromePath ?? undefined,
22
31
  userDataDir,
23
32
  host: connectHost ?? "127.0.0.1",
24
33
  requestedPort: debugPort ?? undefined,
34
+ ignoreDefaultFlags: launchOptions.ignoreDefaultFlags,
25
35
  })
26
36
  : await launch({
27
37
  chromePath: config.chromePath ?? undefined,
28
- chromeFlags,
38
+ chromeFlags: launchOptions.chromeFlags,
29
39
  userDataDir,
30
40
  handleSIGINT: false,
31
41
  port: debugPort ?? undefined,
42
+ ignoreDefaultFlags: launchOptions.ignoreDefaultFlags,
32
43
  });
33
44
  const pidLabel = typeof launcher.pid === "number" ? ` (pid ${launcher.pid})` : "";
34
45
  const hostLabel = connectHost ? ` on ${connectHost}` : "";
@@ -44,10 +55,14 @@ export function registerTerminationHooks(chrome, userDataDir, keepBrowser, logge
44
55
  }
45
56
  handling = true;
46
57
  const inFlight = opts?.isInFlight?.() ?? false;
47
- const leaveRunning = keepBrowser || inFlight;
58
+ const forceCleanup = opts?.forceProfileCleanup ?? false;
59
+ const leaveRunning = (keepBrowser || inFlight) && !forceCleanup;
48
60
  if (leaveRunning) {
49
61
  logger(`Received ${signal}; leaving Chrome running${inFlight ? " (assistant response pending)" : ""}`);
50
62
  }
63
+ else if (forceCleanup && (keepBrowser || inFlight)) {
64
+ logger(`Received ${signal}; terminating Chrome and removing the copied profile (copy-profile is not retained)`);
65
+ }
51
66
  else {
52
67
  logger(`Received ${signal}; terminating Chrome process`);
53
68
  }
@@ -343,6 +358,9 @@ function createSessionBoundChromeClient(browser, sessionId) {
343
358
  // Raw `send` here is the browser-level send (not session-bound), so callers
344
359
  // that issue Target.* via `send` must pass this page session id explicitly to
345
360
  // stay scoped to this tab (e.g. Deep Research OOPIF auto-attach).
361
+ // chrome-remote-interface defines `send` on the client prototype, so object
362
+ // spread does not preserve it. Bind it explicitly for raw session commands.
363
+ send: typeof browser.send === "function" ? browser.send.bind(browser) : undefined,
346
364
  oraclePageSessionId: sessionId,
347
365
  Network: bindDomain("Network"),
348
366
  Page: bindDomain("Page"),
@@ -472,6 +490,18 @@ function buildChromeFlags(headless, debugBindAddress) {
472
490
  }
473
491
  return flags;
474
492
  }
493
+ function resolveChromeLaunchOptions(chromeFlags, usingCopiedProfile) {
494
+ if (!usingCopiedProfile) {
495
+ return { chromeFlags, ignoreDefaultFlags: false };
496
+ }
497
+ return {
498
+ chromeFlags: [...Launcher.defaultFlags(), ...chromeFlags].filter((flag) => flag !== "--use-mock-keychain" && flag !== "--password-store=basic"),
499
+ ignoreDefaultFlags: true,
500
+ };
501
+ }
502
+ export function resolveChromeLaunchOptionsForTest(chromeFlags, usingCopiedProfile) {
503
+ return resolveChromeLaunchOptions(chromeFlags, usingCopiedProfile);
504
+ }
475
505
  function parseDebugPortEnv() {
476
506
  const raw = process.env.ORACLE_BROWSER_PORT ?? process.env.ORACLE_BROWSER_DEBUG_PORT;
477
507
  if (!raw)
@@ -514,13 +544,14 @@ function isWsl() {
514
544
  const release = os.release();
515
545
  return release.toLowerCase().includes("microsoft");
516
546
  }
517
- async function launchWithCustomHost({ chromeFlags, chromePath, userDataDir, host, requestedPort, }) {
547
+ async function launchWithCustomHost({ chromeFlags, chromePath, userDataDir, host, requestedPort, ignoreDefaultFlags, }) {
518
548
  const launcher = new Launcher({
519
549
  chromePath: chromePath ?? undefined,
520
550
  chromeFlags,
521
551
  userDataDir,
522
552
  handleSIGINT: false,
523
553
  port: requestedPort ?? undefined,
554
+ ignoreDefaultFlags,
524
555
  });
525
556
  if (host) {
526
557
  const patched = launcher;
@@ -63,6 +63,11 @@ export const UPLOAD_STATUS_SELECTORS = [
63
63
  '[aria-live="assertive"]',
64
64
  ];
65
65
  export const STOP_BUTTON_SELECTOR = '[data-testid="stop-button"]';
66
+ export const STOP_BUTTON_SELECTORS = [
67
+ STOP_BUTTON_SELECTOR,
68
+ '[data-testid="composer-stop-button"]',
69
+ 'button[aria-label*="stop" i]',
70
+ ];
66
71
  export const SEND_BUTTON_SELECTORS = [
67
72
  'button[data-testid="send-button"]',
68
73
  'button[data-testid*="composer-send"]',
@@ -0,0 +1,23 @@
1
+ export function isDeepResearchIncompleteText(text) {
2
+ const normalized = text.toLowerCase().replace(/\s+/g, " ").trim();
3
+ const lines = text
4
+ .split(/\n+/)
5
+ .map((line) => line.trim())
6
+ .filter(Boolean);
7
+ const tailIsPlanningPanel = text.length <= 1_500 &&
8
+ lines.length >= 4 &&
9
+ lines.length <= 20 &&
10
+ /^update$/i.test(lines[1] ?? "") &&
11
+ /^stop research$/i.test(lines.at(-1) ?? "") &&
12
+ /^determining steps for creating a report(?:\.\.\.)?$/i.test(lines.at(-2) ?? "");
13
+ return (normalized === "called tool" ||
14
+ normalized === "used tool" ||
15
+ normalized === "użyto narzędzia" ||
16
+ normalized === "narzędzie wywołane" ||
17
+ normalized === "planning" ||
18
+ normalized === "researching" ||
19
+ normalized === "searching the web" ||
20
+ (text.trimStart().startsWith("<system-reminder>") &&
21
+ /<system-reminder>[\s\S]*#\s*plan mode\b/i.test(text)) ||
22
+ tailIsPlanningPanel);
23
+ }