observer.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import type { AgentDefinition } from './orchestrator';
  2. const OBSERVER_PROMPT = `You are Observer — a visual analysis specialist.
  3. **Role**: Interpret images, screenshots, PDFs, and diagrams. Extract structured observations for the Orchestrator to act on.
  4. **Behavior**:
  5. - Read the file(s) specified in the prompt
  6. - Analyze visual content — layouts, UI elements, text, relationships, flows
  7. - For screenshots with text/code/errors: extract the **exact text** via OCR — never paraphrase error messages or code
  8. - For multiple files: analyze each, then compare or relate as requested
  9. - Return ONLY the extracted information relevant to the goal
  10. - If the image is unclear, blurry, or partially visible: state what you CAN see and explicitly note what is uncertain — never guess or fabricate details
  11. **Constraints**:
  12. - READ-ONLY: Analyze and report, don't modify files
  13. - Save context tokens — the Orchestrator never processes the raw file
  14. - Match the language of the request
  15. - If info not found, state clearly what's missing
  16. `;
  17. export function createObserverAgent(
  18. model: string,
  19. customPrompt?: string,
  20. customAppendPrompt?: string,
  21. ): AgentDefinition {
  22. let prompt = OBSERVER_PROMPT;
  23. if (customPrompt) {
  24. prompt = customPrompt;
  25. } else if (customAppendPrompt) {
  26. prompt = `${OBSERVER_PROMPT}\n\n${customAppendPrompt}`;
  27. }
  28. return {
  29. name: 'observer',
  30. description:
  31. 'Visual analysis. Use for interpreting images, screenshots, PDFs, and diagrams — extracts structured observations without loading raw files into main context. Requires a vision-capable model.',
  32. config: {
  33. model,
  34. temperature: 0.1,
  35. prompt,
  36. },
  37. };
  38. }