#+TITLE: SKILL: Router Agent (Universal Literate Note) #+ID: skill-router #+STARTUP: content #+FILETAGS: :router:meta-cognitive:delegation:psf: * Overview The *Router Agent* is the system's "Pre-Frontal Cortex." It classifies unstructured user input, decomposes complex requests into atomic intents, and orchestrates delegation to specialized sub-agents. * Phase A: Demand (PRD) :PROPERTIES: :STATUS: FROZEN :END: ** 1. Purpose Define the interfaces for intent classification and sub-agent delegation. ** 2. User Needs - *Perception:* Monitor for explicit commands and implicit `@agent` requests. - *Decomposition:* Break natural language into sequential atomic operations. - *Efficiency:* Utilize low-latency models for rapid routing. - *Dynamic Identity:* Adapt triggers based on the active agent name. ** 3. Success Criteria *** TODO @Agent Tag Detection *** TODO Multi-Intent Decomposition *** TODO Sub-agent Stimulus Injection * Phase B: Blueprint (PROTOCOL) :PROPERTIES: :STATUS: SIGNED :END: ** 1. Architectural Intent Interfaces for AST inspection and intent-driven stimulus injection. Source of truth is the dynamic kernel identity and the Org AST. ** 2. Semantic Interfaces #+begin_src lisp (defun trigger-skill-router (context) "Triggers on :user-command or @agent requests in AST.") (defun find-agent-request (ast agent-name) "Recursive search for addressed headlines.") (defun verify-skill-router (proposed-action context) "Executes delegation by injecting new stimuli.") #+end_src * Phase D: Build (Implementation) ** Request Perception #+begin_src lisp :tangle projects/org-skill-router/src/router-logic.lisp (defun find-agent-request (ast agent-name) (when (listp ast) (let* ((type (getf ast :type)) (props (getf ast :properties)) (title (or (getf props :TITLE) ""))) (if (and (eq type :HEADLINE) (or (search "@agent" title :test #'string-equal) (search (format nil "@~a" agent-name) title :test #'string-equal))) (let* ((pos (or (search "@agent" title :test #'string-equal) (search (format nil "@~a" agent-name) title :test #'string-equal))) (instruction (subseq title (+ pos (if (search "@agent" title :test #'string-equal) 6 (1+ (length agent-name))))))) (string-trim '(#\Space #\Tab) instruction)) (cl:some (lambda (c) (find-agent-request c agent-name)) (getf ast :contents)))))) #+end_src ** Symbolic Delegation #+begin_src lisp :tangle projects/org-skill-router/src/router-logic.lisp (defun verify-skill-router (proposed-action context) (let ((type (getf proposed-action :type))) (cond ((eq type :MULTI-DELEGATION) (dolist (intent (getf proposed-action :intents)) (org-agent:inject-stimulus `(:type :EVENT :payload (:sensor :delegation ,@intent)))) nil) ((eq type :DELEGATION) (org-agent:inject-stimulus `(:type :EVENT :payload (:sensor :delegation ,@(getf proposed-action :payload)))) nil) (t '(:type :LOG :payload (:text "Router failed to classify.")))))) #+end_src * Registration #+begin_src lisp (defskill :skill-router :priority 90 :trigger #'trigger-skill-router :neuro #'neuro-skill-router :symbolic #'verify-skill-router) #+end_src