refactor: moved org-agent to its own repository as a submodule
This commit is contained in:
95
notes/skill-web-research.org
Normal file
95
notes/skill-web-research.org
Normal file
@@ -0,0 +1,95 @@
|
||||
#+TITLE: Web Research Skill (Generalized)
|
||||
#+AUTHOR: org-agent
|
||||
#+SKILL_NAME: skill-web-research
|
||||
|
||||
This skill provides the agent with internet connectivity via multiple pluggable browser engines.
|
||||
|
||||
* Trigger
|
||||
#+begin_src lisp
|
||||
(defun trigger-skill-web-research (context)
|
||||
(let ((type (getf context :type))
|
||||
(payload (getf context :payload)))
|
||||
(and (eq type :EVENT)
|
||||
(eq (getf payload :sensor) :delegation)
|
||||
(eq (getf payload :target-skill) :web))))
|
||||
#+end_src
|
||||
|
||||
* Browser Engines
|
||||
We define multiple backends for fetching web content.
|
||||
|
||||
#+begin_src lisp
|
||||
(defun fetch-with-lynx (url)
|
||||
"Engine: Lynx. Best for fast text extraction from blogs/docs."
|
||||
(let ((cmd (format nil "lynx -dump -nolist '~a'" url)))
|
||||
(uiop:run-program cmd :output :string :ignore-error-status t)))
|
||||
|
||||
(defun fetch-with-curl (url)
|
||||
"Engine: Curl. Best for raw HTML or API inspection."
|
||||
(let ((cmd (format nil "curl -sL '~a'" url)))
|
||||
(uiop:run-program cmd :output :string :ignore-error-status t)))
|
||||
|
||||
(defun fetch-with-playwright (url)
|
||||
"Engine: Playwright (Placeholder). In the future, this calls a Python bridge."
|
||||
(format nil "ERROR: Playwright engine not yet implemented. Falling back to Lynx...~%~a"
|
||||
(fetch-with-lynx url)))
|
||||
|
||||
(defun web-fetch (url &optional engine)
|
||||
"Dispatch the fetch request to the specified engine (defaults to Lynx)."
|
||||
(case engine
|
||||
(:lynx (fetch-with-lynx url))
|
||||
(:curl (fetch-with-curl url))
|
||||
(:playwright (fetch-with-playwright url))
|
||||
(t (fetch-with-lynx url))))
|
||||
#+end_src
|
||||
|
||||
* Neuro Prompt
|
||||
System 1 chooses the engine based on the task complexity.
|
||||
|
||||
#+begin_src lisp
|
||||
(defun neuro-skill-web-research (context)
|
||||
(let* ((payload (getf context :payload))
|
||||
(query (getf payload :query))
|
||||
;; The LLM can specify an engine. If not, we default to Lynx.
|
||||
(requested-engine (or (getf payload :engine) :lynx))
|
||||
(is-url (or (search "http://" query) (search "https://" query)))
|
||||
(target-url (if is-url
|
||||
query
|
||||
(format nil "https://duckduckgo.com/html/?q=~a" query)))
|
||||
(web-text (web-fetch target-url requested-engine)))
|
||||
|
||||
(let ((curated (if (and web-text (> (length web-text) 5000))
|
||||
(format nil "~a... [TRUNCATED]" (subseq web-text 0 5000))
|
||||
(or web-text "No content fetched."))))
|
||||
|
||||
(format nil "
|
||||
You are the Web Research synthesizer.
|
||||
USER QUERY - '~a'
|
||||
ENGINE USED - ~a
|
||||
TARGET URL - ~a
|
||||
|
||||
RAW CONTENT FETCHED -
|
||||
---
|
||||
~a
|
||||
---
|
||||
|
||||
Synthesize a concise, factual answer.
|
||||
Return a Lisp plist - (:target :emacs :action :message :text \"your summary\")
|
||||
" query requested-engine target-url curated))))
|
||||
#+end_src
|
||||
|
||||
* Symbolic Verification
|
||||
#+begin_src lisp
|
||||
(defun verify-skill-web-research (proposed-action context)
|
||||
(if (eq (getf proposed-action :action) :message)
|
||||
proposed-action
|
||||
'(:target :emacs :action :message :text "Web skill failed to synthesize message.")))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-web-research
|
||||
:priority 80
|
||||
:trigger #'trigger-skill-web-research
|
||||
:neuro #'neuro-skill-web-research
|
||||
:symbolic #'verify-skill-web-research)
|
||||
#+end_src
|
||||
Reference in New Issue
Block a user