PSF: Foundry Progress Sync. 57 high-fidelity blueprints established. Open Fleet routing (Kimi/Qwen) active. GTD updated.
This commit is contained in:
@@ -33,15 +33,89 @@ Implement a Lisp-to-Node bridge using Playwright for high-fidelity web interacti
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Browser Logic
|
||||
|
||||
*** Headless Query Script
|
||||
#+begin_src javascript :tangle ../projects/org-skill-web-research/src/gemini-web.js
|
||||
const { chromium } = require('playwright-extra');
|
||||
const stealth = require('puppeteer-extra-plugin-stealth')();
|
||||
chromium.use(stealth);
|
||||
|
||||
async function askGemini(prompt) {
|
||||
const browser = await chromium.launchPersistentContext('/home/user/.local/share/org-agent/browser-profile', {
|
||||
headless: true,
|
||||
args: ['--disable-blink-features=AutomationControlled']
|
||||
});
|
||||
|
||||
const page = await browser.newPage();
|
||||
try {
|
||||
await page.goto('https://gemini.google.com/app', { waitUntil: 'networkidle', timeout: 60000 });
|
||||
|
||||
const inputSelector = 'div[role="textbox"], textarea[aria-label="Prompt"], .input-area';
|
||||
await page.waitForSelector(inputSelector, { timeout: 15000 });
|
||||
|
||||
await page.fill(inputSelector, prompt);
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
// Wait for response to generate
|
||||
await page.waitForSelector('.model-response-text:last-child, message-content:last-child', { state: 'visible', timeout: 60000 });
|
||||
const response = await page.innerText('.model-response-text:last-child, message-content:last-child');
|
||||
console.log(response);
|
||||
} catch (err) {
|
||||
const url = page.url();
|
||||
console.error(`FAILED at ${url}`);
|
||||
throw err;
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const prompt = args[0];
|
||||
|
||||
askGemini(prompt).catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
#+end_src
|
||||
|
||||
*** Human-in-the-Loop Login Script
|
||||
#+begin_src javascript :tangle ../projects/org-skill-web-research/src/gemini-auth.js
|
||||
const { chromium } = require('playwright-extra');
|
||||
const stealth = require('puppeteer-extra-plugin-stealth')();
|
||||
chromium.use(stealth);
|
||||
|
||||
async function loginGemini() {
|
||||
console.log("Opening browser for manual Google login...");
|
||||
console.log("Please log in, pass any captchas, wait for the Gemini chat interface to load, and then close the browser window.");
|
||||
|
||||
const browser = await chromium.launchPersistentContext('/home/user/.local/share/org-agent/browser-profile', {
|
||||
headless: false,
|
||||
args: ['--disable-blink-features=AutomationControlled']
|
||||
});
|
||||
|
||||
const page = await browser.newPage();
|
||||
await page.goto('https://gemini.google.com/app');
|
||||
|
||||
// The script keeps running until the user manually closes the window
|
||||
}
|
||||
|
||||
loginGemini().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
#+end_src
|
||||
|
||||
#+begin_src lisp :tangle ../projects/org-skill-web-research/src/research-logic.lisp
|
||||
(in-package :org-agent)
|
||||
|
||||
(defun ask-gemini-web (prompt)
|
||||
"Calls the Playwright bridge to interact with Gemini Web UI."
|
||||
(let* ((cookie-str (uiop:getenv "GEMINI_COOKIES"))
|
||||
(script-path (namestring (merge-pathnames "src/gemini-web.js" (asdf:system-source-directory :org-skill-web-research)))))
|
||||
(unless cookie-str (return-from ask-gemini-web "(:type :LOG :payload (:text \"Gemini Cookies missing\"))"))
|
||||
(uiop:run-program (list "node" script-path prompt cookie-str) :output :string)))
|
||||
"Calls the Playwright stealth bridge to interact with Gemini Web UI via a persistent profile."
|
||||
(let* ((script-path (namestring (merge-pathnames "src/gemini-web.js" (asdf:system-source-directory :org-skill-web-research)))))
|
||||
(multiple-value-bind (output error-output exit-code)
|
||||
(uiop:run-program (list "node" script-path prompt) :output :string :error-output :string :ignore-error-status t)
|
||||
(if (= exit-code 0)
|
||||
output
|
||||
(format nil "(:type :LOG :payload (:text \"Node Error (~a): ~a\"))" exit-code error-output)))))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
|
||||
Reference in New Issue
Block a user