@andrewting19/oracle 0.10.1 → 0.10.3

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.
@@ -158,14 +158,24 @@ async function connectToNewTarget(host, port, url, logger, messages, rootSession
158
158
  try {
159
159
  let target;
160
160
  if (rootSession) {
161
- // Hidden target: not in tab strip, no window, no focus steal.
161
+ // Try hidden target (no tab strip, no window), fall back to background+focus:false.
162
162
  // Lifetime tied to rootSession (kept alive by the serve).
163
- const result = await rootSession.Target.createTarget({
164
- url,
165
- hidden: true,
166
- background: true,
167
- });
168
- target = { id: result.targetId };
163
+ try {
164
+ const result = await rootSession.Target.createTarget({
165
+ url,
166
+ hidden: true,
167
+ background: true,
168
+ });
169
+ target = { id: result.targetId };
170
+ }
171
+ catch {
172
+ const result = await rootSession.Target.createTarget({
173
+ url,
174
+ background: true,
175
+ focus: false,
176
+ });
177
+ target = { id: result.targetId };
178
+ }
169
179
  }
170
180
  else {
171
181
  // No root session: try background + focus:false, fallback to CDP.New()
@@ -290,6 +290,7 @@ export async function serveRemote(options = {}) {
290
290
  "--disable-hang-monitor",
291
291
  "--disable-popup-blocking",
292
292
  "--disable-features=TranslateUI,AutomationControlled",
293
+ "--remote-allow-origins=*",
293
294
  "--mute-audio",
294
295
  "--window-size=1280,720",
295
296
  "--password-store=basic",
@@ -305,17 +306,38 @@ export async function serveRemote(options = {}) {
305
306
  // browser endpoint directly. Hidden target lifetimes are tied to the session
306
307
  // that created them, so this must stay alive for the serve lifetime.
307
308
  const CDP = (await import("chrome-remote-interface")).default;
308
- const rootSession = await CDP({ host: "127.0.0.1", port: chrome.port, target: "browser" });
309
+ const versionInfo = await CDP.Version({ host: "127.0.0.1", port: chrome.port });
310
+ const browserWsUrl = versionInfo.webSocketDebuggerUrl;
311
+ if (!browserWsUrl) {
312
+ throw new Error("Chrome did not expose a browser WebSocket URL");
313
+ }
314
+ console.log(`Root CDP session connecting to ${browserWsUrl}`);
315
+ const rootSession = await CDP({ target: browserWsUrl });
309
316
  sharedRootSession = rootSession;
310
- // Sync ChatGPT cookies into the shared Chrome via a hidden target.
317
+ // Sync ChatGPT cookies into the shared Chrome via a background target.
318
+ // Try hidden first (no tab strip / no window), fall back to background+focus:false.
311
319
  try {
312
320
  const { syncCookies } = await import("../browser/cookies.js");
313
- const { targetId } = await rootSession.Target.createTarget({
314
- url: "about:blank",
315
- hidden: true,
316
- background: true,
317
- });
318
- const syncClient = await CDP({ host: "127.0.0.1", port: chrome.port, target: targetId });
321
+ let syncTargetId;
322
+ try {
323
+ const result = await rootSession.Target.createTarget({
324
+ url: "about:blank",
325
+ hidden: true,
326
+ background: true,
327
+ });
328
+ syncTargetId = result.targetId;
329
+ console.log("Cookie sync: created hidden target.");
330
+ }
331
+ catch {
332
+ const result = await rootSession.Target.createTarget({
333
+ url: "about:blank",
334
+ background: true,
335
+ focus: false,
336
+ });
337
+ syncTargetId = result.targetId;
338
+ console.log("Cookie sync: hidden targets unavailable, using background+focus:false.");
339
+ }
340
+ const syncClient = await CDP({ host: "127.0.0.1", port: chrome.port, target: syncTargetId });
319
341
  const { Network } = syncClient;
320
342
  await Network.enable({});
321
343
  const syncLogger = ((msg) => { if (msg)
@@ -326,7 +348,7 @@ export async function serveRemote(options = {}) {
326
348
  });
327
349
  console.log(`Synced ${count} ChatGPT cookies into shared Chrome.`);
328
350
  await syncClient.close();
329
- await rootSession.Target.closeTarget({ targetId });
351
+ await rootSession.Target.closeTarget({ targetId: syncTargetId });
330
352
  }
331
353
  catch (cookieErr) {
332
354
  const msg = cookieErr instanceof Error ? cookieErr.message : String(cookieErr);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrewting19/oracle",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "description": "CLI wrapper around OpenAI Responses API with GPT-5.4 Pro, GPT-5.4, GPT-5.2, GPT-5.1, and GPT-5.1 Codex high reasoning modes.",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/steipete/oracle#readme",