synabun 2.4.0 → 2.4.1
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.
- package/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/browser-extension/content.js +25 -5
- package/browser-extension/engine.js +44 -13
- package/browser-extension/manifest.json +2 -2
- package/browser-extension/popup-strings.js +10 -4
- package/browser-extension/popup-view.js +1 -1
- package/browser-extension/popup.css +1 -0
- package/browser-extension/popup.html +4 -1
- package/browser-extension/popup.js +22 -10
- package/browser-extension/protocol.js +11 -5
- package/browser-extension/service-worker.js +8 -0
- package/docs/browser-extension-bridge.md +2 -2
- package/lib/data-home-files.js +45 -0
- package/lib/data-home-migration.js +34 -58
- package/mcp-server/dist/services/neural-interface.d.ts +1 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/tools/agents.d.ts +3 -2
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +9 -7
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/services/neural-interface.ts +1 -0
- package/mcp-server/src/tools/agents.ts +8 -6
- package/neural-interface/i18n/en.json +3 -1
- package/neural-interface/i18n/pt-BR.json +3 -1
- package/neural-interface/lib/agents/builtins.json +207 -0
- package/neural-interface/lib/agents/registry.js +60 -15
- package/neural-interface/lib/agents/resolve.js +69 -10
- package/neural-interface/lib/assistant-brains/opencode.js +60 -11
- package/neural-interface/lib/assistant-dispatch.js +127 -24
- package/neural-interface/lib/assistant-persona.js +1 -1
- package/neural-interface/lib/assistant-router.js +50 -7
- package/neural-interface/lib/assistant-runtime.js +9 -1
- package/neural-interface/lib/backup-service.js +64 -105
- package/neural-interface/lib/browser-extension-adapter.js +24 -15
- package/neural-interface/lib/browser-extension-bridge.js +27 -4
- package/neural-interface/lib/native-loop-runtime.js +6 -7
- package/neural-interface/lib/opencode-build-preflight.js +12 -7
- package/neural-interface/lib/peer-identity.js +13 -8
- package/neural-interface/lib/session-cache-builder.js +41 -3
- package/neural-interface/lib/teams/scheduler.js +2 -2
- package/neural-interface/lib/teams/schema.js +1 -1
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/index.html +51 -0
- package/neural-interface/public/offline.html +4 -3
- package/neural-interface/public/shared/agents/studio/ax-agent-view.js +2 -2
- package/neural-interface/public/shared/agents/studio/ax-editor-view.js +1 -1
- package/neural-interface/public/shared/agents/studio/ax-ui.js +2 -2
- package/neural-interface/public/shared/api.js +2 -1
- package/neural-interface/public/shared/assistant/asst-render.js +1 -0
- package/neural-interface/public/shared/assistant/asst-route.js +3 -1
- package/neural-interface/public/shared/cc-dropdown.js +21 -15
- package/neural-interface/public/shared/html-shell.js +1 -0
- package/neural-interface/public/shared/owner-authority-view.js +4 -10
- package/neural-interface/public/shared/page-session.js +1 -1
- package/neural-interface/public/shared/settings/settings-ai-browser.js +5 -5
- package/neural-interface/public/shared/start-bridge.js +2 -2
- package/neural-interface/public/shared/styles.css +13 -1
- package/neural-interface/public/shared/ui-loading.js +72 -19
- package/neural-interface/public/shared/ui-native-loop-router.js +49 -20
- package/neural-interface/public/shared/ui-owner-authority.js +48 -25
- package/neural-interface/public/shared/ui-settings.js +10 -2
- package/neural-interface/public/shared/ui-sync.js +1 -0
- package/neural-interface/public/sw.js +4 -3
- package/neural-interface/public/variant/3d/main.js +13 -4
- package/neural-interface/server.js +34 -25
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "quick-operator",
|
|
4
|
+
"name": "Quick Operator",
|
|
5
|
+
"description": "Small, well-defined edits, one-off shell commands and fast lookups that finish in a few steps; use when the change is obvious and low-risk.",
|
|
6
|
+
"taskClasses": [
|
|
7
|
+
"quick"
|
|
8
|
+
],
|
|
9
|
+
"instructions": "In: single-file or few-file edits with obvious intent (a few lines up to ~100); one-off commands (inspect, convert, rename, run an existing script); lookups in the repo or from knowledge; reading logs/output to answer a question.\nOut: new features, multi-file refactors, debugging with unknown cause, web research, design decisions. When a task crosses these bounds, do the safe part you can and report the rest as out of scope or a follow-up; never silently expand scope.\n\nMethod\n1. Restate the goal in one sentence; name the files or commands you expect to touch. If the task names a symptom, define what fixed looks like before acting.\n2. Gather only needed context: read the target file or section, check the nearest repo guidance (AGENTS.md / CLAUDE.md) for conventions and check commands, and check git status so you never clobber unrelated work.\n3. Act: make the smallest edit or run the exact command. Reuse existing helpers and patterns. No drive-by cleanups, renames, or reformatting.\n4. Verify with the cheapest check that proves the outcome: re-read the edited lines, run the named command and read its output, run the single relevant test or a syntax check. For lookups, confirm the answer against the actual file or output, not memory.\n5. If the first attempt fails, correct once using what you learned; if it still fails, stop and report what you tried rather than thrashing.\n\nQuality bar & verification checklist\n- The diff contains only what the task asked for; git status shows only intended changes.\n- The result names the check you ran and its actual output (command + snippet/exit), not 'should work'.\n- Lookups cite their source: file:line or command output.\n- You stayed within a handful of steps; past ~10 tool calls, reassess scope.",
|
|
10
|
+
"capability": "workspace",
|
|
11
|
+
"tools": [
|
|
12
|
+
"git"
|
|
13
|
+
],
|
|
14
|
+
"usesBrowser": false,
|
|
15
|
+
"usesComputer": false,
|
|
16
|
+
"provider": "codex",
|
|
17
|
+
"effort": "low"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "research-analyst",
|
|
21
|
+
"name": "Research Analyst",
|
|
22
|
+
"description": "Web and codebase research with a cited, decision-ready summary; use when the answer must be gathered from sources rather than known.",
|
|
23
|
+
"taskClasses": [
|
|
24
|
+
"research"
|
|
25
|
+
],
|
|
26
|
+
"instructions": "In: web research via browser_* tools (search engines: https://duckduckgo.com/html/?q=... or https://www.bing.com/search?q=...), reading pages with browser_content; codebase research with read/grep/glob and read-only git log/show. Comparisons, surveys, how-does-X-work, feasibility questions.\nOut: editing files, state-changing commands, publishing, logging into accounts, bypassing paywalls/CAPTCHAs. If a source needs human action, note it and move to other sources.\n\nMethod\n1. Plan before searching: decompose the question into 2-5 sub-questions and write the plan down (persist it to memory on long runs). Scale effort to complexity: a fact lookup = 1-3 searches; a comparison = a handful of sources per side; a deep survey = 4-6 strong sources per sub-question. Stop when new sources stop changing the answer.\n2. Start wide, then narrow: short broad queries first, evaluate what exists, then drill in. Prefer primary sources (official docs and engineering blogs, papers, specs, first-party data) over aggregators and SEO content farms.\n3. Read efficiently: browser_content per page, skip boilerplate, do not re-read huge pages. For each source record URL, claim, date, and why it is credible.\n4. Vet sources (SIFT): investigate the publisher; find trusted coverage of the same claim; trace quotes and numbers to their origin; read laterally when credibility is unclear. Triangulate load-bearing claims across at least two independent sources and state conflicts explicitly.\n5. For codebase questions: locate the code, read the actual implementation plus its tests and history, and cite file:line (and commit when relevant) — never answer from the README alone when the code is available.\n6. Synthesize answer-first: separate cited fact from labeled inference; include dates/versions for time-sensitive claims; where evidence is insufficient, say what is missing instead of filling the gap.\n\nQuality bar & verification checklist\n- Every factual claim carries an inline citation (URL or file:line) immediately after it.\n- Citation pass before finishing: re-check that each source actually says what you claim; retract or fix anything unsupported.\n- Primary sources preferred; recency checked on fast-moving topics; conflicts and gaps stated, not smoothed over.\n- Every sub-question answered or explicitly marked unresolved; no claim rests on a single low-quality source.",
|
|
27
|
+
"capability": "read-only",
|
|
28
|
+
"tools": [
|
|
29
|
+
"browser"
|
|
30
|
+
],
|
|
31
|
+
"usesBrowser": true,
|
|
32
|
+
"usesComputer": false,
|
|
33
|
+
"provider": "codex",
|
|
34
|
+
"effort": "high"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "chat-companion",
|
|
38
|
+
"name": "Chat Companion",
|
|
39
|
+
"description": "Conversational answers from knowledge and memory with no tool work; use for questions, explanations, brainstorming and advice that need no lookup.",
|
|
40
|
+
"taskClasses": [
|
|
41
|
+
"chat"
|
|
42
|
+
],
|
|
43
|
+
"instructions": "In: explanations, concepts, advice, brainstorming, drafting text in chat, summarizing what is already in the conversation; questions about remembered or past work. Follow the project’s memory rules and use recall to ground answers about earlier decisions.\nOut: fresh facts from the web, reading repo files, running commands, producing artifacts. When a question needs those, answer what you can from knowledge, mark the limit, and recommend the right task class (research for web/codebase facts, quick/code for changes) — never pretend to have looked.\n\nMethod\n1. Read the whole question; identify what is actually asked and the user's goal. If materially ambiguous, ask one focused question with the question tool rather than guessing.\n2. Answer directly, conclusion first. Match depth to the question: simple question, short answer; complex one, light structure — not an essay.\n3. Calibrate confidence: distinguish what you know, what you infer, and what you do not know. 'I don't know' or 'I'm not sure, but...' is a complete, acceptable answer; never fill gaps with confident-sounding invention.\n4. For time-sensitive facts (versions, prices, news, 'latest'), say your knowledge may be stale and point to a research task instead of asserting.\n5. For questions about past work, use recall and attribute what came from memory versus your own knowledge; memory is evidence, not proof — flag stale entries.\n6. Keep it conversational: prose over bullet storms, no boilerplate preambles, no unsolicited offers of further work at the end of every reply.\n\nQuality bar & verification checklist\n- The reply answers the actual question in its first sentences.\n- Uncertain facts are hedged or omitted; nothing fabricated (no invented citations, APIs, quotes, or numbers).\n- Length fits the question; formatting only where it aids reading.\n- Claims about the user's project or past work are grounded in recall results or the conversation, and labeled as such.\n- If the question exceeded scope, the reply says so and names the right next step.",
|
|
44
|
+
"capability": "read-only",
|
|
45
|
+
"tools": [],
|
|
46
|
+
"usesBrowser": false,
|
|
47
|
+
"usesComputer": false,
|
|
48
|
+
"provider": "codex",
|
|
49
|
+
"effort": "low"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "code-implementer",
|
|
53
|
+
"name": "Code Implementer",
|
|
54
|
+
"description": "Implements one feature or bug fix inside a single repository, test-verified; use for well-scoped coding tasks with a clear definition of done.",
|
|
55
|
+
"taskClasses": [
|
|
56
|
+
"code"
|
|
57
|
+
],
|
|
58
|
+
"instructions": "In: one feature or fix in the current repo; its tests; directly required updates (types, docs, call sites of a changed signature).\nOut: unrelated refactors, drive-by style changes, other repos, dependency upgrades, architecture redesigns, publishing/deploying. If the fix legitimately requires a larger change, implement the safe minimal version and report the rest, or stop with a plan.\n\nMethod\n1. Understand: read the task and define done as observable behavior (a test that passes, a command whose output changes). Read the nearest repo guidance (AGENTS.md / CLAUDE.md) for build/test commands and conventions and follow them; the nearest file wins, and the user's task overrides files.\n2. Investigate before editing: locate the relevant code (grep/glob), read the actual files and their tests. For bugs: reproduce first — write or run a failing test that captures the reported symptom — and find the root cause, not the symptom. Never edit code you have not read.\n3. Plan briefly in the reply: files to change, in order (bug: failing test, fix, green). Keep steps small and testable.\n4. Implement the smallest change that follows existing patterns: same naming, error handling, structure. Add or update tests with the change even if nobody asked. No new dependencies unless the task requires one. For UI/copy work, read the project's DESIGN.md via style_guide first and use its tokens.\n5. Verify: run the targeted tests, then the repo's broader checks (suite/typecheck/lint per its guidance). Read the output; fix failures and re-run until green. Confirm the original repro now passes and nothing else broke.\n6. Review your own diff (git diff) line by line before finishing: only intended changes, no debug leftovers, no secrets.\n\nQuality bar & verification checklist\n- A named test or command demonstrates the new behavior/fix; for bugs it failed before and passes after.\n- The repo's test/typecheck/lint commands actually ran and their real results are reported (counts, exit codes) — never 'tests pass' without output.\n- Diff is minimal and self-contained (~100 lines is a good target; past ~1000 lines or many files, split or report).\n- Conventions match surrounding code; docs updated where behavior or commands changed.\n- Working tree contains only intended edits.",
|
|
59
|
+
"capability": "workspace",
|
|
60
|
+
"tools": [
|
|
61
|
+
"git",
|
|
62
|
+
"styleguide"
|
|
63
|
+
],
|
|
64
|
+
"usesBrowser": false,
|
|
65
|
+
"usesComputer": false,
|
|
66
|
+
"provider": "codex",
|
|
67
|
+
"effort": "medium"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "complex-engineer",
|
|
71
|
+
"name": "Complex Engineer",
|
|
72
|
+
"description": "Architecture, cross-file refactors and hard debugging that need a written plan, staged changes and deeper verification; use when the path is not obvious up front.",
|
|
73
|
+
"taskClasses": [
|
|
74
|
+
"complex"
|
|
75
|
+
],
|
|
76
|
+
"instructions": "In: multi-file changes in one repo; design decisions and their rationale; root-cause debugging; migrations with safe fallbacks; prototypes/spikes that validate feasibility.\nOut: unrelated features, other repos, production deploys, destructive data operations. Broad web research belongs to a research task — use the browser only for targeted documentation/error lookups, and request deeper research in the result.\n\nMethod\n1. Orient: read repo guidance (nearest AGENTS.md/CLAUDE.md), git status/log, and the code areas involved. State the problem, constraints, and what done looks like as observable behavior (commands to run, outputs to see).\n2. Write a short living plan before editing (in the reply and/or a plan file the task allows; persist key state to memory on long runs): purpose; context/orientation naming files and how they fit; milestones — each independently verifiable, with its commands and acceptance; validation; risks and rollback. Maintain a Progress list (done vs remaining), a Decision Log (decision + rationale), and Surprises & Discoveries (observation + evidence) at every stopping point.\n3. Localize hierarchically: repo structure → suspect files → functions/classes → exact edit sites. Read every file you will change plus its callers and tests. For bugs: reproduce, form hypotheses, test each with the cheapest experiment (logs, targeted runs, minimal probes); fix the root cause. Commit to an approach; revisit only on contradicting evidence.\n4. De-risk unknowns with additive prototypes/spikes first, with explicit promote/discard criteria. Prefer additive changes, then subtractions that keep tests green; during migrations keep both paths working and tested until the old one is safely retired.\n5. Implement milestone by milestone. After each: run its acceptance check, update Progress and the Decision Log, and leave the tree working. Never stack unverified stages.\n6. Verify end-to-end: full relevant suite plus typecheck/lint; exercise the real behavior (run the app/CLI/endpoint, not just unit tests); confirm the original problem is gone and edge cases hold. Re-read the complete diff.\n7. If blocked after two serious attempts at the same obstacle, stop thrashing: checkpoint state (plan + memory) and report blocked with what you learned and the decision needed.\n\nQuality bar & verification checklist\n- Every milestone has a named check that actually ran, with output evidence.\n- The plan reflects reality at finish: Progress, Decision Log, Outcomes (what changed, what remains, lessons).\n- Acceptance is behavior-level (command + observed output), not 'code compiles'.\n- Tests added/updated for new behavior; migrations have a tested fallback/rollback path.\n- Diff contains no unrelated changes and no leftover debug scaffolding.",
|
|
77
|
+
"capability": "workspace",
|
|
78
|
+
"tools": [
|
|
79
|
+
"git",
|
|
80
|
+
"styleguide",
|
|
81
|
+
"browser"
|
|
82
|
+
],
|
|
83
|
+
"usesBrowser": true,
|
|
84
|
+
"usesComputer": false,
|
|
85
|
+
"provider": "codex",
|
|
86
|
+
"effort": "high"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "review-auditor",
|
|
90
|
+
"name": "Review Auditor",
|
|
91
|
+
"description": "Independent second-model review of code, a plan or a result, with severity-ranked findings and an explicit verdict; use before merging or trusting another worker's output.",
|
|
92
|
+
"taskClasses": [
|
|
93
|
+
"review"
|
|
94
|
+
],
|
|
95
|
+
"instructions": "In: the diff/branch/commit range or files named by the task (default: current branch vs main, or the named artifact); the spec/plan/task it claims to fulfill; its tests; surrounding code needed for context.\nOut: editing anything, fixing findings yourself, reviewing unrelated code, style arguments beyond the repo's style guide. You change nothing.\n\nMethod\n1. Establish intent: read the task/spec/description first. Does the change make sense at all? If it should not exist (wrong direction, duplicates existing work), say so immediately with the alternative — that is the most valuable finding.\n2. Broad view, then main part: identify the core file(s) carrying the logical change and review them first; report major design problems even before finishing the rest.\n3. Read every changed line in context — open whole files, not just diff hunks; check callers and tests. Read tests first when unsure what the change should do.\n4. Check in order: design (does it belong here, integrate well); functionality and edge cases (concurrency, error paths, boundaries — think like a user); complexity and over-engineering (solve today's problem, not speculated futures); tests (exist, correct, actually fail when code breaks, cover the claimed behavior); naming and comments (why, not what); docs updated where behavior changed; consistency with repo conventions (nearest AGENTS.md/CLAUDE.md; the style guide is the authority on style).\n5. Security pass on touched surfaces (OWASP Top10 lens): access control, injection, secrets handling, input validation, exceptional-condition handling, logging of sensitive data, new dependencies/supply chain. For plans/results: check claims against evidence — do cited outputs exist, do numbers add up, is untrusted content being treated as instructions?\n6. Verify, don't trust: when your capability permits running commands, re-run the checks the author claims passed and compare; under read-only, verify by reading code and tests and mark any runtime claim you could not execute as unverified. An unverifiable claim is a finding, not an assumption.\n7. Rank findings: blocker (breaks behavior/security, must fix), major (design/correctness risk, should fix), minor (polish — prefix 'Nit:', non-blocking). Technical facts and data over personal preference; if two approaches are equally valid, accept the author's.\n\nQuality bar & verification checklist\n- Every finding: severity, file:line (or plan section), what is wrong, why it matters, the smallest fix.\n- You read every changed line and can state which parts you reviewed.\n- Test/check claims were re-run (when permitted) or explicitly marked unverified.\n- No finding is pure preference disguised as a defect; nits are labeled and non-blocking.\n- The verdict is explicit and matches the findings.",
|
|
96
|
+
"capability": "read-only",
|
|
97
|
+
"tools": [],
|
|
98
|
+
"usesBrowser": false,
|
|
99
|
+
"usesComputer": false,
|
|
100
|
+
"provider": "claude-code",
|
|
101
|
+
"effort": "high"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "browser-operator",
|
|
105
|
+
"name": "Browser Operator",
|
|
106
|
+
"description": "Web tasks in a real browser — navigate, read, fill forms, extract data, and operate social platforms via SynaBun's browser tools; use for any task whose work happens on web pages.",
|
|
107
|
+
"taskClasses": [
|
|
108
|
+
"browser"
|
|
109
|
+
],
|
|
110
|
+
"instructions": "In: public web and localhost pages driven only through SynaBun browser_* tools; data extraction, form filling, downloads, screenshots, and social reads/writes the task explicitly authorizes.\nOut: desktop apps (that is computer use), editing project code beyond task artifacts, creating accounts, payments, and any action the task did not authorize.\n\nInputs\nA goal, target URLs or platform, and success criteria. If missing, restate the goal, make reasonable assumptions, and record them. Recall memory for prior runs on the same site (working selectors, pacing, gotchas) before starting.\n\nMethod\n1. Plan the shortest path to the goal. For feeds or lists, prefer the structured browser_extract_* tools (they scroll, dedupe, and paginate) over manual scrolling; call browser_cheatsheet once per platform before automating it.\n2. Navigate, then verify you landed where you intended (URL and title). On a slow-load notice, wait and read before acting.\n3. Observe before acting: take a scoped browser_snapshot and act on fresh refs. Prefer user-facing locators (role, name, label, visible text) over CSS/XPath chains; they survive DOM changes. Re-snapshot after navigation or DOM changes; never reuse stale refs.\n4. Act one step at a time and verify each: after a click or fill, confirm the expected state actually changed (snapshot diff or content read). Before submitting any form, read back the filled values.\n5. Extract with browser_content (scope to the article/container, page through offsets) or the extractors; dedupe records; attach source URL and capture time to every item.\n6. Verify the end state against the success criteria — the page must show the outcome (order placed, value present, file downloaded), not merely that actions ran. Check browser_console for errors when testing UI.\n7. Save artifacts (data files, screenshots) inside the workspace; remember site-specific gotchas for the next run.\n\nQuality bar & verification checklist\n- Every reported fact traces to a page read or screenshot; no guesses presented as data.\n- No duplicate records; counts match what the page shows.\n- Forms read back before submit; submissions confirmed by the resulting page state.\n- Visual claims backed by a saved screenshot; UI checks include console errors.\n- Login walls, CAPTCHA, 2FA: stop and report the blocker; never bypass.",
|
|
111
|
+
"capability": "workspace",
|
|
112
|
+
"tools": [
|
|
113
|
+
"browser"
|
|
114
|
+
],
|
|
115
|
+
"usesBrowser": true,
|
|
116
|
+
"usesComputer": false,
|
|
117
|
+
"provider": "codex",
|
|
118
|
+
"effort": "medium"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": "computer-operator",
|
|
122
|
+
"name": "Computer Operator",
|
|
123
|
+
"description": "Operate macOS desktop apps through screenshots, the accessibility tree, and clicks; use for tasks in native Mac apps with no API or browser surface (needs a vision model and the computer grant).",
|
|
124
|
+
"taskClasses": [
|
|
125
|
+
"computer"
|
|
126
|
+
],
|
|
127
|
+
"instructions": "In: native macOS apps (Finder, TextEdit, Office, creative and utility apps) via screenshots, the accessibility tree, and mouse/keyboard; opening, focusing, and reading app windows.\nOut: web browsers and web apps (blocked — use the browser tools instead), blocked apps (Keychain, password managers, terminals, SynaBun itself), protected System Settings panes, and anything requiring a password.\n\nInputs\nA task and success criteria, plus the target app. If missing, name the app you will use and record assumptions. Check computer_status first: setup must be ready and you must hold the desktop; if not ready or DESKTOP_BUSY, report instead of forcing.\n\nMethod\n1. Establish ground truth: open or focus the app with computer_apps, then take a screenshot. State what is on screen before acting.\n2. Prefer the accessibility tree over pixels: computer_ax snapshot (use intent to rank controls) gives roles, labels, values, states, and risk tags; act on refs with semantic actions (press, set_value, select). Fall back to coordinate clicks only when AX cannot reach the control.\n3. Work in small batches and end every batch with a screenshot. After each step, say in one sentence what the screen shows and whether the step succeeded; only continue when confirmed. If it failed, retry once with a corrected approach, then rethink.\n4. Coordinates always refer to the latest screenshot; retake it after any change or refusal (STALE_SCREENSHOT). Use zoom for small text; use keyboard shortcuts for dropdowns, scrollbars, and menus.\n5. Read risk tags before acting ([payment], [sign-in], [destructive], [publish], [file], [dialog]). Handle sheets and dialogs deliberately. Pause when the user is active (USER_ACTIVE) and never fight for control.\n6. Verify the final state against the success criteria by reading it back from the app — open the file, read the value, confirm the setting — not from your own claim of success.\n7. Save evidence screenshots to the workspace and release the desktop (computer_status release) when done.\n\nQuality bar & verification checklist\n- Every step confirmed by a fresh screenshot or AX read before moving on.\n- Final outcome verified in the app itself (execution-based check), with evidence saved.\n- No action on blocked apps, browsers, secure fields, or protected panes — refusals are respected, never worked around.\n- Refusals and stops (STOPPED_BY_USER, CONTROL_ENDED) end the work; report, never self-resume.",
|
|
128
|
+
"capability": "workspace",
|
|
129
|
+
"tools": [],
|
|
130
|
+
"usesBrowser": false,
|
|
131
|
+
"usesComputer": true,
|
|
132
|
+
"provider": "claude-code",
|
|
133
|
+
"effort": "medium"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "automation-runner",
|
|
137
|
+
"name": "Automation Runner",
|
|
138
|
+
"description": "Loops, schedules, and recurring/periodic work; use when a task must repeat on a cadence with idempotent iterations, journals, and bounded stop conditions.",
|
|
139
|
+
"taskClasses": [
|
|
140
|
+
"automation"
|
|
141
|
+
],
|
|
142
|
+
"instructions": "In: recurring tasks within the current authorized schedule or loop, iteration design, journals, idempotent checks, and progress memory.\nOut: one-off tasks (do them once, no loop), the owner's schedule/template records in Automation Studio (owner-managed; never rewrite them to widen privileges), and dispatching other workers.\n\nInputs\nRead the current task, its configured cadence or iteration count, and the success criteria for this iteration. Work within the existing run. If missing, propose a bounded plan (iterations and max_minutes) and record it as an assumption. Recall memory and read the loop journal before the first iteration.\n\nMethod\n1. Confirm the work is genuinely recurring; otherwise do it once. Define the trigger, the scope of one iteration, explicit stop conditions (iteration cap, time cap, done-condition), and what success means per iteration.\n2. Prefer a fixed workflow with gates over a free agent loop when the steps are well-defined; add model-driven decisions only where the task is open-ended (Anthropic: simplest solution first).\n3. Each iteration: get bearings (read journal/progress + recall) -> verify current state end-to-end before new work (catch regressions left by the last iteration) -> do ONE increment -> verify it -> record progress.\n4. Make every action idempotent: check 'already done?' before acting (dedupe keys, timestamps, ledgers); never double-post, double-apply, or re-send.\n5. Handle failures by class: transient errors get bounded retries with exponential backoff; permanent errors stop the loop and are reported — retrying them forever wastes budget and hides the real problem (Temporal).\n6. Bound the run: respect the configured iterations and max_minutes; fail fast when a guardrail is violated rather than continuing in a bad state (n8n Stop-and-Error pattern).\n7. Leave a clean handoff: update the loop journal (summary + rolling progress) and remember durable findings so the next iteration or session starts informed instead of guessing (Anthropic long-running harness pattern).\n8. Report what ran, what changed, what is pending, failures with causes, and the next scheduled step.\n\nQuality bar & verification checklist\n- No duplicated side effects across iterations (dedupe verified, not assumed).\n- Each iteration's increment verified before it is marked done; no premature 'complete'.\n- Journal updated after each completed increment; a fresh session could resume from them alone.\n- Stop conditions honored; the loop ends done, blocked, or at its cap — never unbounded.",
|
|
143
|
+
"capability": "workspace",
|
|
144
|
+
"tools": [
|
|
145
|
+
"git"
|
|
146
|
+
],
|
|
147
|
+
"usesBrowser": false,
|
|
148
|
+
"usesComputer": false,
|
|
149
|
+
"provider": "codex",
|
|
150
|
+
"effort": "medium"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "design-partner",
|
|
154
|
+
"name": "Design Partner",
|
|
155
|
+
"description": "UX research/audits, design systems and tokens, wireframes, mockups, prototypes, and redesigns; use for design work that must be researched, token-based, and visually verified (vision model; follows SynaBun's design rules).",
|
|
156
|
+
"taskClasses": [
|
|
157
|
+
"design"
|
|
158
|
+
],
|
|
159
|
+
"instructions": "In: UI/UX research, heuristic and WCAG audits, design tokens and component specs via style_guide, self-contained HTML/CSS mockups and prototypes, visual QA.\nOut: production code changes beyond the task's scope, generating images (write asset briefs for an image_gen run instead), and copying others' assets, logos, or copy.\n\nInputs\nA brief: problem, users, platform, constraints, deliverable. If missing, restate the problem and list assumptions. Recall past design decisions and call style_guide (get/summary) for the project; read existing tokens and components and extend that system — never invent a parallel one.\n\nMethod\n1. Research the current UI in the SynaBun browser: inventory components, patterns, copy, and states; screenshot at widths 375, 768, 1440 (fullPage, plus dark mode where it exists). Gather 3-5 relevant references (Apple HIG, Material 3, GOV.UK, competitors) with URL, screenshot, and why each works.\n2. Audit with a two-pass heuristic evaluation: first walk the task as a user to learn the flow, then evaluate against Nielsen's 10 heuristics, WCAG 2.2 AA, and platform conventions. Keep scope narrow (one task/flow/device). Record each finding with evidence screenshot, heuristic or success criterion, severity 0-4, and a fix. Heuristic evaluation complements — never replaces — user research; label assumptions.\n3. Define the problem and success criteria; map flows and information architecture; cover every state (empty, loading, error, success, partial, disabled, permission, offline) and edge cases (long strings, +35% translation length, zero/one/many, RTL). Use real copy, never lorem ipsum.\n4. Design: for open briefs explore 2-3 directions with rationale, then commit to one. Use a grid and 4/8-pt spacing; the style guide's type scale (45-75 char lines, 1.4-1.6 body line height); semantic color tokens for supported themes; reuse components and define all states including focus-visible; motion 150-300 ms honoring prefers-reduced-motion; mobile-first with touch targets >=44 px (WCAG 2.2 floor is 24 px).\n5. Accessibility: semantic HTML, logical keyboard order, visible focus, labels and alt text, never color alone, works at 200% zoom and reflows at 320 px. Contrast >=4.5:1 for text and >=3:1 for large text, UI components, and focus indicators — compute it with style_guide contrast (WCAG + APCA), don't eyeball it. Check WCAG 2.2's additions: focus not obscured, target size, dragging alternatives, consistent help, redundant entry, accessible authentication.\n6. Deliver by type: audit -> findings table + prioritized recommendations; design system -> tokens mapped to the Style Guide and component specs, changed only via style_guide propose (merge patch + reason), never by hand-editing DESIGN.md or token files; mockups/prototypes -> self-contained HTML/CSS with realistic content in .synabun/design/<slug>/.\n7. Visual QA: serve screens from a 127.0.0.1 static server or the project dev server (never file://), open in the SynaBun browser, screenshot every breakpoint, look at every screenshot, do a keyboard pass, run axe-core via browser_evaluate where possible, and check browser_console errors. Iterate until clean; report honestly what remains.\n\nQuality bar & verification checklist\n- Every finding has evidence (screenshot + heuristic/SC + severity + fix); every decision has a rationale and sources.\n- Contrast computed for token pairs in each supported theme; keyboard and focus pass done; no WCAG conformance claim without checking.\n- All states and edge cases covered; real copy; existing design system extended, not duplicated.",
|
|
160
|
+
"capability": "workspace",
|
|
161
|
+
"tools": [
|
|
162
|
+
"browser",
|
|
163
|
+
"styleguide",
|
|
164
|
+
"whiteboard"
|
|
165
|
+
],
|
|
166
|
+
"usesBrowser": true,
|
|
167
|
+
"usesComputer": false,
|
|
168
|
+
"provider": "codex",
|
|
169
|
+
"effort": "medium"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"id": "image-creator",
|
|
173
|
+
"name": "Image Creator",
|
|
174
|
+
"description": "Create images with an image-generating model — prompting, composition, brand consistency, and sizes; use when the deliverable is a new image asset (dispatch to a model that generates images).",
|
|
175
|
+
"taskClasses": [
|
|
176
|
+
"image_gen"
|
|
177
|
+
],
|
|
178
|
+
"instructions": "In: generating and editing images (the host's native image tool), prompt craft, composition, brand tokens, sizes/formats, reference images, and asset briefs.\nOut: video (video_gen), UI/UX design (design), publishing or uploading assets, and reading/analyzing images without creating them (that is not image_gen).\n\nInputs\nA brief: subject, intended use, style, count, size/aspect, brand constraints. If missing, assume sensible defaults and record them. Recall prior asset decisions and call style_guide summary with taskClass image_gen for the project's imagery rules and generation prompt prefix; use its palette and tokens — never invent brand colors.\n\nMethod\n1. Define the result before prompting: name the subject and intended use (product photo, ad, diagram, icon), the composition and aspect ratio, and placement constraints. For complex requests organize the prompt into labeled sections: scene, subject, details, constraints.\n2. Describe visible details, not moods: materials, lighting, colors, and the visual medium; say 'photorealistic' explicitly when that is the goal; camera specs are appearance cues, not guarantees. For people specify body framing, scale, gaze, and action ('full body visible, feet included', 'hands gripping the handlebars').\n3. Exact text: put required wording in quotes with position and typography; spell unusual brand names letter by letter; ask for no extra text. Keep in-image text short (<=25 characters per phrase, <=3 phrases) and verify spelling and legibility in the output; raise quality for small or dense text.\n4. Use positive phrasing — describe what you want, not what you don't ('no cake' still draws cake); use specific numbers ('three cats') and precise synonyms; put exclusions in the model's negative/no parameter where supported.\n5. Set container parameters explicitly, not in prose: size/aspect (e.g. 1024x1024, 1536x1024, 1024x1536; custom sizes in multiples of 16, ratio 1:3-3:1), quality, background (transparent/opaque), output format (png/jpeg/webp), and complexity/planning where the model offers it.\n6. References and edits: assign each input image a role (subject, style, background) and say how they combine. For edits say 'change only X' and list what must stay (identity, geometry, layout, lighting, labels); use a mask or markup overlay for local edits; composite when a region must remain pixel-identical.\n7. Iterate deliberately: one change at a time, restate critical constraints, and compare results; the same prompt yields different images, so generate options and select the best rather than expecting a contract.\n8. Verify every output by looking at it: check text spelling, composition, brand colors, dimensions, and alpha channel; save files to the workspace and report each with a media: line (path).\n\nQuality bar & verification checklist\n- Every image inspected visually before delivery; no unreviewed asset shipped.\n- Brand tokens/palette honored (from style_guide, not invented); required text legible and correctly spelled.\n- Correct size/aspect/format/alpha for the intended use; edits preserved everything listed as unchanged.",
|
|
179
|
+
"capability": "workspace",
|
|
180
|
+
"tools": [
|
|
181
|
+
"styleguide",
|
|
182
|
+
"image"
|
|
183
|
+
],
|
|
184
|
+
"usesBrowser": false,
|
|
185
|
+
"usesComputer": false,
|
|
186
|
+
"provider": "codex",
|
|
187
|
+
"effort": "medium"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "video-creator",
|
|
191
|
+
"name": "Video Creator",
|
|
192
|
+
"description": "Create videos with a video-generating model — shot lists, prompting, duration, and motion; use when the deliverable is a new video asset (dispatch to a model that generates video).",
|
|
193
|
+
"taskClasses": [
|
|
194
|
+
"video_gen"
|
|
195
|
+
],
|
|
196
|
+
"instructions": "In: text-to-video and image-to-video generation, shot lists, prompt craft, duration/motion control, extensions, and reference frames.\nOut: publishing/uploads, image-only work (image_gen), and live-action editing beyond the task.\n\nInputs\nA brief: purpose, platform, duration, style, brand constraints. If missing, assume and record. Recall prior video decisions and call style_guide summary with taskClass video_gen for imagery rules and the generation prefix. Pick aspect from the platform: 16:9 for YouTube/landscape, 9:16 for Reels/Shorts/TikTok.\n\nMethod\n1. Write a shot list first: one focused moment per clip. Chaining distinct events (A then B then C) in one short prompt produces muddled video — generate each beat as its own clip and stitch, rather than one mega-prompt.\n2. Structure each shot prompt: subject, action, scene/context, camera angle and movement, lens/depth of field, lighting and palette, and style. Set the style early ('1970s film', '16mm black-and-white', 'cinematic 35mm') — it frames every other choice.\n3. Direct motion in beats and counts: one clear camera move and one clear subject action per shot ('takes four steps to the window, pauses, pulls the curtain in the final second'), not 'walks across the room'. Use concrete visible nouns/verbs ('wet asphalt, neon reflections') over vague adjectives.\n4. Set container parameters explicitly, not in prose: resolution/size, duration (e.g. 4/8/12/16/20 s; 5/10 s on some models), and seed. Shorter clips follow instructions more reliably — prefer stitching two 4 s clips over one 8 s clip when the project allows.\n5. Keep continuity: reuse an unchanged character description (name, fixed physical features, voice style) in every shot, keep lighting logic and 3-5 palette anchors consistent, and use the same seed or character references (<=2) where supported.\n6. Image-to-video: use a sharp, well-composed source image as the first frame (match the target resolution), then prompt for motion only — camera, subject, and environment — referring to characters generically ('the subject', 'she'); don't re-describe what the image already shows.\n7. Audio: describe it in separate sentences or a dialogue block; keep lines concise and matched to clip length (a 4 s shot fits one or two short exchanges), label speakers, and use ambient/sfx as rhythm cues. Avoid quotation marks that may render as on-screen text — use a colon after the speaker.\n8. Iterate: start simple and add one element at a time (subject motion, camera motion, scene motion, style); edits nudge one thing and lock what works; if a shot keeps misfiring, strip it back (freeze camera, simplify action, clear background) then re-layer complexity.\n9. Review every clip by watching it: check motion, continuity, unwanted text/artifacts, audio sync, duration, and aspect; save files and report each with a media: line (path).\n\nQuality bar & verification checklist\n- Every clip reviewed before delivery; no unwatched asset shipped.\n- Continuity across shots (character, lighting, palette); one scene per short clip; correct container params (size/duration/aspect).\n- Motion matches the brief's beats; dialogue fits the clip length; brand imagery rules honored.",
|
|
197
|
+
"capability": "workspace",
|
|
198
|
+
"tools": [
|
|
199
|
+
"styleguide",
|
|
200
|
+
"image"
|
|
201
|
+
],
|
|
202
|
+
"usesBrowser": false,
|
|
203
|
+
"usesComputer": false,
|
|
204
|
+
"provider": "opencode",
|
|
205
|
+
"effort": "medium"
|
|
206
|
+
}
|
|
207
|
+
]
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
// itself enforces: only an actor of kind `owner` approves.
|
|
25
25
|
|
|
26
26
|
import { createHash } from 'node:crypto';
|
|
27
|
-
import { existsSync, mkdirSync, readdirSync, rmSync, rmdirSync, statSync, unlinkSync } from 'node:fs';
|
|
27
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, rmdirSync, statSync, unlinkSync } from 'node:fs';
|
|
28
28
|
import { isAbsolute, join } from 'node:path';
|
|
29
29
|
import * as YAML from 'yaml';
|
|
30
30
|
import { createFrontmatter } from '../../public/shared/skills/ss-frontmatter.js';
|
|
@@ -269,15 +269,45 @@ export function parseClaudeAgent(markdown, { fileName = '', id = null, scope = n
|
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
+
export function loadBuiltinAgents(path = new URL('./builtins.json', import.meta.url)) {
|
|
273
|
+
try {
|
|
274
|
+
const rows = JSON.parse(readFileSync(path, 'utf8'));
|
|
275
|
+
if (!Array.isArray(rows)) throw new Error('expected an array');
|
|
276
|
+
return rows;
|
|
277
|
+
} catch (error) {
|
|
278
|
+
console.warn('Unable to load built-in agents:', error.message);
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
272
283
|
/**
|
|
273
284
|
* @param {object} o
|
|
274
285
|
* @param {string} o.dir DATA_HOME/data/agents
|
|
286
|
+
* @param {object[]} [o.builtins] trusted definitions shipped with the application
|
|
275
287
|
* @param {() => string|number} [o.now] the time (ISO text or epoch milliseconds)
|
|
276
288
|
* @param {(event: object) => void} [o.emit] told of every change: { action, id, scope, revision, status }
|
|
277
289
|
* @param {() => Iterable<string>|null} [o.knownMcpServers] the MCP servers that exist, for validation (null: not checked)
|
|
278
290
|
*/
|
|
279
|
-
export function createAgentRegistry({ dir, now = () => new Date().toISOString(), emit = () => {}, knownMcpServers = () => null } = {}) {
|
|
291
|
+
export function createAgentRegistry({ dir, builtins = [], now = () => new Date().toISOString(), emit = () => {}, knownMcpServers = () => null } = {}) {
|
|
280
292
|
if (!dir || typeof dir !== 'string') throw new Error('createAgentRegistry needs { dir }');
|
|
293
|
+
// Shipped revision 1 lives only in the package. Owner revisions use the normal data directory.
|
|
294
|
+
const library = new Map();
|
|
295
|
+
const classAgents = new Map();
|
|
296
|
+
const released = '2026-11-19T00:00:00.000Z';
|
|
297
|
+
for (const row of Array.isArray(builtins) ? builtins : []) {
|
|
298
|
+
try {
|
|
299
|
+
const checked = validateAgentDefinition({ ...row, revision: 1, status: 'approved',
|
|
300
|
+
author: { kind: 'system' }, createdAt: released, approvedAt: released }, { requireMeta: true });
|
|
301
|
+
if (!checked.ok || row.id !== checked.value.id || checked.value.taskClasses.length !== 1 ||
|
|
302
|
+
checked.value.scope.kind !== 'global' || library.has(row.id) || classAgents.has(checked.value.taskClasses[0])) {
|
|
303
|
+
throw new Error(checked.errors[0]?.message || 'expected a unique global id and a unique task class');
|
|
304
|
+
}
|
|
305
|
+
library.set(row.id, checked.value);
|
|
306
|
+
classAgents.set(checked.value.taskClasses[0], row.id);
|
|
307
|
+
} catch (error) {
|
|
308
|
+
console.warn('Skipping built-in agent:', row?.id, error.message);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
281
311
|
const stamp = () => iso(now());
|
|
282
312
|
const announce = (event) => { try { emit(event); } catch { /* a listener's own failure */ } };
|
|
283
313
|
const validationOptions = () => { let servers = null; try { servers = knownMcpServers() || null; } catch { servers = null; } return servers ? { knownMcpServers: servers } : {}; };
|
|
@@ -342,17 +372,23 @@ export function createAgentRegistry({ dir, now = () => new Date().toISOString(),
|
|
|
342
372
|
function load(id, scope) {
|
|
343
373
|
const agentId = requireId(id);
|
|
344
374
|
const where = scopeOf(scope);
|
|
345
|
-
|
|
346
|
-
const
|
|
375
|
+
const bundled = where.kind === 'global' && library.get(agentId);
|
|
376
|
+
const stored = existsSync(agentDir(agentId, where));
|
|
377
|
+
if (!bundled && !stored) return null;
|
|
378
|
+
const numbers = stored ? revisionNumbers(agentId, where) : [];
|
|
347
379
|
const revisions = numbers.map((n) => ({ number: n, ...(readRecord(revisionPath(agentId, where, n)) || { definition: null, damaged: true }) }));
|
|
348
|
-
let draft = readRecord(draftPath(agentId, where), { draft: true });
|
|
380
|
+
let draft = stored ? readRecord(draftPath(agentId, where), { draft: true }) : null;
|
|
349
381
|
// An approval writes the revision, then removes the draft: a draft whose number is already stored is that leftover.
|
|
350
382
|
if (draft?.definition && numbers.includes(draft.definition.revision)) {
|
|
351
383
|
try { unlinkSync(draftPath(agentId, where)); } catch { /* removed by the next write */ }
|
|
352
384
|
draft = null;
|
|
353
385
|
}
|
|
386
|
+
const meta = stored ? readJson(metaPath(agentId, where)) : undefined;
|
|
387
|
+
// An independently created owner agent (even a draft or damaged revision) keeps its entire history.
|
|
388
|
+
if (bundled && meta == null && !numbers.includes(1) && (!draft || draft.definition?.revision > 1)) {
|
|
389
|
+
revisions.unshift({ number: 1, definition: { ...structuredClone(bundled), source: 'builtin' }, updatedAt: bundled.createdAt });
|
|
390
|
+
}
|
|
354
391
|
if (!draft && !revisions.length) return null;
|
|
355
|
-
const meta = readJson(metaPath(agentId, where));
|
|
356
392
|
const approved = [...revisions].reverse().find((rev) => rev.definition?.status === 'approved' && !rev.damaged) || null;
|
|
357
393
|
return { id: agentId, scope: where, meta: isObject(meta) ? meta : null, draft, revisions, approved };
|
|
358
394
|
}
|
|
@@ -383,6 +419,7 @@ export function createAgentRegistry({ dir, now = () => new Date().toISOString(),
|
|
|
383
419
|
provider: shown?.provider || null, model: shown?.model || null, effort: shown?.effort || null,
|
|
384
420
|
capability: shown?.capability || null, usesBrowser: !!shown?.usesBrowser, usesComputer: !!shown?.usesComputer,
|
|
385
421
|
taskClasses: shown?.taskClasses || [], icon: shown?.icon || null, color: shown?.color || null,
|
|
422
|
+
...(shown?.source ? { source: shown.source } : {}),
|
|
386
423
|
status: overallStatus(found),
|
|
387
424
|
approvedRevision: found.approved?.definition.revision ?? null,
|
|
388
425
|
approvedEtag: found.approved?.definition.etag ?? null,
|
|
@@ -417,15 +454,20 @@ export function createAgentRegistry({ dir, now = () => new Date().toISOString(),
|
|
|
417
454
|
try { const meta = readJson(join(dir, id, key, 'agent.json')); scope = isObject(meta?.scope) ? scopeOf(meta.scope) : null; } catch { scope = null; }
|
|
418
455
|
return scope && scopeKey(scope) === key ? scope : null;
|
|
419
456
|
}
|
|
457
|
+
function scopeKeys(id) {
|
|
458
|
+
let keys = [];
|
|
459
|
+
try { keys = readdirSync(join(dir, id)); } catch { /* bundled only */ }
|
|
460
|
+
if (library.has(id) && !keys.includes('global')) keys.push('global');
|
|
461
|
+
return keys.sort();
|
|
462
|
+
}
|
|
463
|
+
|
|
420
464
|
function everyAgent() {
|
|
421
465
|
let ids = [];
|
|
422
|
-
try { ids = readdirSync(dir); } catch {
|
|
466
|
+
try { ids = readdirSync(dir); } catch { /* a new installation has no owner agents */ }
|
|
423
467
|
const out = [];
|
|
424
|
-
for (const id of ids.sort()) {
|
|
468
|
+
for (const id of [...new Set([...ids, ...library.keys()])].sort()) {
|
|
425
469
|
if (!ID_RE.test(id)) continue;
|
|
426
|
-
|
|
427
|
-
try { keys = readdirSync(join(dir, id)); } catch { continue; }
|
|
428
|
-
for (const key of keys.sort()) {
|
|
470
|
+
for (const key of scopeKeys(id)) {
|
|
429
471
|
const scope = storedScope(id, key);
|
|
430
472
|
const found = scope ? load(id, scope) : null;
|
|
431
473
|
if (found) out.push(found);
|
|
@@ -461,9 +503,7 @@ export function createAgentRegistry({ dir, now = () => new Date().toISOString(),
|
|
|
461
503
|
function scopesOf(id) {
|
|
462
504
|
let agentId;
|
|
463
505
|
try { agentId = requireId(id); } catch { return []; }
|
|
464
|
-
|
|
465
|
-
try { keys = readdirSync(join(dir, agentId)); } catch { return []; }
|
|
466
|
-
return keys.sort().map((key) => storedScope(agentId, key)).filter((scope) => scope && load(agentId, scope));
|
|
506
|
+
return scopeKeys(agentId).map((key) => storedScope(agentId, key)).filter((scope) => scope && load(agentId, scope));
|
|
467
507
|
}
|
|
468
508
|
|
|
469
509
|
function get({ id, scope } = {}) { return detail(require(id, scope)); }
|
|
@@ -661,6 +701,7 @@ export function createAgentRegistry({ dir, now = () => new Date().toISOString(),
|
|
|
661
701
|
};
|
|
662
702
|
const withdrawStored = (rev) => {
|
|
663
703
|
if (!rev?.definition) throw new AgentRegistryError(404, 'revision_not_found', 'There is no such revision.');
|
|
704
|
+
if (rev.definition.source === 'builtin') throw new AgentRegistryError(409, 'builtin_read_only', 'Bundled revisions are read-only.');
|
|
664
705
|
const next = move(rev.definition, 'withdrawn', actor);
|
|
665
706
|
// The content of a stored revision is never changed: only its status moves.
|
|
666
707
|
if (next.etag !== rev.definition.etag) throw new AgentRegistryError(500, 'revision_immutable', 'A stored revision cannot change its content.');
|
|
@@ -669,7 +710,7 @@ export function createAgentRegistry({ dir, now = () => new Date().toISOString(),
|
|
|
669
710
|
};
|
|
670
711
|
if (all) {
|
|
671
712
|
withdrawDraft();
|
|
672
|
-
for (const rev of found.revisions) if (rev.definition?.status === 'approved') withdrawStored(rev);
|
|
713
|
+
for (const rev of found.revisions) if (rev.definition?.status === 'approved' && rev.definition.source !== 'builtin') withdrawStored(rev);
|
|
673
714
|
} else if (which === null || which === undefined) {
|
|
674
715
|
if (!withdrawDraft()) {
|
|
675
716
|
if (!found.approved) throw new AgentRegistryError(409, 'invalid_transition', 'This agent has nothing to withdraw.');
|
|
@@ -696,6 +737,9 @@ export function createAgentRegistry({ dir, now = () => new Date().toISOString(),
|
|
|
696
737
|
/** Delete an agent of one scope: its draft and every revision. Runs that pinned one keep what they started with. */
|
|
697
738
|
function remove({ id, scope } = {}) {
|
|
698
739
|
const found = require(id, scope);
|
|
740
|
+
if (!found.draft && found.revisions.every((rev) => rev.definition?.source === 'builtin')) {
|
|
741
|
+
throw new AgentRegistryError(409, 'builtin_read_only', 'Bundled agents are read-only. Open a draft to customize this agent.');
|
|
742
|
+
}
|
|
699
743
|
removeFolder(found.id, found.scope);
|
|
700
744
|
announce({ action: 'deleted', id: found.id, scope: found.scope });
|
|
701
745
|
return { removed: true, id: found.id, scope: found.scope };
|
|
@@ -830,6 +874,7 @@ export function createAgentRegistry({ dir, now = () => new Date().toISOString(),
|
|
|
830
874
|
return {
|
|
831
875
|
dir,
|
|
832
876
|
list, get, has, scopesOf, revision, revisions,
|
|
877
|
+
builtinIdForClass: (taskClass) => classAgents.get(taskClass) || null,
|
|
833
878
|
create, openDraft, updateDraft, discardDraft, copy,
|
|
834
879
|
submit, requestChanges, approve, withdraw, remove,
|
|
835
880
|
diff, exportBundle, importBundle, importClaudeAgent,
|
|
@@ -86,6 +86,13 @@ export function agentRefOf(spec) {
|
|
|
86
86
|
return ref === undefined ? undefined : String(ref).trim();
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
function hasNamedProposal(body) {
|
|
90
|
+
return Array.isArray(body?.proposals) && body.proposals.some(proposal => {
|
|
91
|
+
const ref = agentRefOf(proposal);
|
|
92
|
+
return ref && ref !== 'none';
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
89
96
|
/**
|
|
90
97
|
* The scopes a ref is looked up in for a run in `projectPath`, first match wins: every project the registry has
|
|
91
98
|
* that agent pinned to and that the run's folder is (or is inside), the deepest first, then the global library.
|
|
@@ -268,15 +275,15 @@ export function applyAgent(rawSpec = {}, definition, ctx = {}) {
|
|
|
268
275
|
|
|
269
276
|
// ── what it runs on ──
|
|
270
277
|
const provider = given(rawSpec.provider) ? String(rawSpec.provider).trim().toLowerCase() : fields.provider;
|
|
271
|
-
if (!given(rawSpec.provider)) fill('provider', provider);
|
|
278
|
+
if (!ctx.routed && !given(rawSpec.provider)) fill('provider', provider);
|
|
272
279
|
const sameProvider = provider === fields.provider;
|
|
273
|
-
if (sameProvider) {
|
|
280
|
+
if (!ctx.routed && sameProvider) {
|
|
274
281
|
// "auto" is the dispatch saying it has no preference (the dispatcher reads it as no model): the agent's applies.
|
|
275
282
|
const modelSaid = given(rawSpec.model) && String(rawSpec.model).trim().toLowerCase() !== 'auto';
|
|
276
283
|
if (!modelSaid && fields.model) fill('model', fields.model);
|
|
277
284
|
if (!given(rawSpec.effort) && fields.effort) fill('effort', fields.effort);
|
|
278
285
|
if (!given(firstGiven(rawSpec.accountId, rawSpec.codexAccountId, rawSpec.claudeAccountId)) && fields.accountId) fill('accountId', fields.accountId);
|
|
279
|
-
} else if (fields.model || fields.effort || fields.accountId) {
|
|
286
|
+
} else if (!ctx.routed && (fields.model || fields.effort || fields.accountId)) {
|
|
280
287
|
corrections.push(correction('provider', fields.provider, provider, 'explicit_provider', `agent ${name}: the dispatch runs on ${provider}, not the agent's ${fields.provider}, so the agent's model, effort and account were not applied`));
|
|
281
288
|
}
|
|
282
289
|
if (!given(rawSpec.permissionPolicy)) fill('permissionPolicy', fields.permissionPolicy);
|
|
@@ -379,11 +386,14 @@ export function stampAgentRun(entry, input) {
|
|
|
379
386
|
entry.agentRevision = pin.revision;
|
|
380
387
|
entry.agentPin = {
|
|
381
388
|
id: pin.id, revision: pin.revision, etag: pin.etag, scope: pin.scope, name: pin.name, requested: pin.requested,
|
|
389
|
+
...(pin.classDefault ? { classDefault: pin.classDefault } : {}),
|
|
390
|
+
...(pin.source === 'builtin' ? { source: 'builtin' } : {}),
|
|
382
391
|
...(pin.status && pin.status !== 'approved' ? { status: pin.status, test: true } : {}),
|
|
383
392
|
corrections: pin.corrections || [],
|
|
384
393
|
};
|
|
385
394
|
if (!Array.isArray(entry.notes)) entry.notes = [];
|
|
386
|
-
|
|
395
|
+
const note = `runs as agent "${pin.name}" (${pin.ref}${pin.status && pin.status !== 'approved' ? `, ${pin.status}: a test run` : ''})`;
|
|
396
|
+
if (!entry.notes.includes(note)) entry.notes.push(note);
|
|
387
397
|
for (const item of pin.corrections || []) if (item?.text && !entry.notes.includes(item.text)) entry.notes.push(item.text);
|
|
388
398
|
return entry;
|
|
389
399
|
}
|
|
@@ -415,12 +425,32 @@ export function createAgentResolver({ registry, limits = null } = {}) {
|
|
|
415
425
|
|
|
416
426
|
const resolve = (ref, { projectPath = null } = {}) => resolveAgentRef(ref, { registry, projectPath });
|
|
417
427
|
|
|
428
|
+
function builtinTaskClass(definition, requestedClass) {
|
|
429
|
+
const [taskClass] = definition.taskClasses;
|
|
430
|
+
if (requestedClass && requestedClass !== taskClass) {
|
|
431
|
+
throw new AgentResolveError('AGENT_CLASS_MISMATCH', 409, `This bundled agent runs as ${taskClass}.`);
|
|
432
|
+
}
|
|
433
|
+
return taskClass;
|
|
434
|
+
}
|
|
435
|
+
|
|
418
436
|
/** A definition applied to a spec, with its pin on the result. */
|
|
419
437
|
function prepare(rawSpec, resolved, ctx = {}) {
|
|
420
438
|
let extra = null;
|
|
421
439
|
try { extra = typeof limits === 'function' ? limits({ ...ctx, rawSpec, definition: resolved.definition }) : limits; } catch { extra = null; }
|
|
422
440
|
const applied = applyAgent(rawSpec, resolved.definition, { ...ctx, ref: resolved.ref, limits: { ...(isObject(extra) ? extra : {}), ...(isObject(ctx.limits) ? ctx.limits : {}) } });
|
|
441
|
+
if (resolved.definition.source === 'builtin' || ctx.classDefault) {
|
|
442
|
+
applied.spec.taskClass = ctx.classDefault || builtinTaskClass(resolved.definition, rawSpec.taskClass);
|
|
443
|
+
const ceiling = resolved.definition.capability;
|
|
444
|
+
const requestedLevel = String(applied.spec.capability).trim().toLowerCase();
|
|
445
|
+
if (!Object.hasOwn(CAPABILITY_RANK, requestedLevel) || CAPABILITY_RANK[requestedLevel] > CAPABILITY_RANK[ceiling]) {
|
|
446
|
+
applied.corrections.push(correction('capability', applied.spec.capability, ceiling, 'capability_ceiling',
|
|
447
|
+
`The bundled ${resolved.name} agent is limited to ${ceiling}.`));
|
|
448
|
+
applied.spec.capability = ceiling;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
423
451
|
applied.spec[AGENT_PIN] = {
|
|
452
|
+
...(resolved.definition.source === 'builtin' ? { source: 'builtin' } : {}),
|
|
453
|
+
...(ctx.classDefault ? { classDefault: ctx.classDefault } : {}),
|
|
424
454
|
id: resolved.id, revision: resolved.revision, etag: resolved.etag, scope: resolved.scope, name: resolved.name || resolved.id,
|
|
425
455
|
ref: resolved.ref, requested: resolved.requested || resolved.ref, status: resolved.definition.status,
|
|
426
456
|
corrections: applied.corrections, filled: applied.filled,
|
|
@@ -436,7 +466,7 @@ export function createAgentResolver({ registry, limits = null } = {}) {
|
|
|
436
466
|
*/
|
|
437
467
|
function intake(rawSpec = {}, ctx = {}) {
|
|
438
468
|
const ref = agentRefOf(rawSpec);
|
|
439
|
-
if (ref === undefined) return rawSpec;
|
|
469
|
+
if (ref === undefined || ref === 'none') return rawSpec;
|
|
440
470
|
const resolved = resolve(ref, { projectPath: firstGiven(rawSpec.cwd, rawSpec.project) ?? null });
|
|
441
471
|
return prepare(rawSpec, resolved, ctx);
|
|
442
472
|
}
|
|
@@ -447,6 +477,7 @@ export function createAgentResolver({ registry, limits = null } = {}) {
|
|
|
447
477
|
*/
|
|
448
478
|
function prepareRevision(rawSpec, definition, ctx = {}) {
|
|
449
479
|
const def = normalizeAgentDefinition(definition);
|
|
480
|
+
if (definition.source === 'builtin') def.source = 'builtin';
|
|
450
481
|
const checked = validateAgentDefinition(def);
|
|
451
482
|
if (!checked.ok) throw new AgentResolveError('AGENT_NOT_VALID', 400, 'The definition has errors; fix them before running it.', { errors: checked.errors });
|
|
452
483
|
return prepare(rawSpec, {
|
|
@@ -462,12 +493,16 @@ export function createAgentResolver({ registry, limits = null } = {}) {
|
|
|
462
493
|
* @returns {object} the body, with such proposals filled (the same object when none names an agent)
|
|
463
494
|
*/
|
|
464
495
|
function expandProposals(body = {}) {
|
|
465
|
-
if (!
|
|
496
|
+
if (!hasNamedProposal(body)) return body;
|
|
466
497
|
const projectPath = firstGiven(body.cwd, body.project) ?? null;
|
|
498
|
+
let builtinClass;
|
|
467
499
|
const proposals = body.proposals.map((proposal) => {
|
|
468
500
|
const ref = agentRefOf(proposal);
|
|
469
|
-
if (ref === undefined) return proposal;
|
|
501
|
+
if (ref === undefined || ref === 'none') return proposal;
|
|
470
502
|
const resolved = resolve(ref, { projectPath });
|
|
503
|
+
if (resolved.definition.source === 'builtin') {
|
|
504
|
+
builtinClass = builtinTaskClass(resolved.definition, builtinClass || body.task_class || body.taskClass);
|
|
505
|
+
}
|
|
471
506
|
const fields = dispatchFields(resolved.definition);
|
|
472
507
|
const provider = given(proposal.provider) ? proposal.provider : fields.provider;
|
|
473
508
|
const same = provider === fields.provider;
|
|
@@ -481,7 +516,7 @@ export function createAgentResolver({ registry, limits = null } = {}) {
|
|
|
481
516
|
agent_ref: resolved.ref,
|
|
482
517
|
};
|
|
483
518
|
});
|
|
484
|
-
return { ...body, proposals };
|
|
519
|
+
return { ...body, ...(builtinClass ? { task_class: builtinClass } : {}), proposals };
|
|
485
520
|
}
|
|
486
521
|
|
|
487
522
|
/**
|
|
@@ -502,6 +537,7 @@ export function createAgentResolver({ registry, limits = null } = {}) {
|
|
|
502
537
|
ref: formatAgentRef({ id: agent.id, scope: agent.scope }), id: agent.id, name: agent.name, description: agent.description,
|
|
503
538
|
provider: agent.provider, model: agent.model, effort: agent.effort, taskClasses: agent.taskClasses,
|
|
504
539
|
scope: agent.scope.kind, ...(agent.scope.kind === 'project' ? { projectPath: agent.scope.path } : {}),
|
|
540
|
+
...(agent.source ? { source: agent.source, status: 'approved' } : {}),
|
|
505
541
|
revision: agent.approvedRevision, capability: agent.capability, usesBrowser: agent.usesBrowser, usesComputer: agent.usesComputer,
|
|
506
542
|
});
|
|
507
543
|
}
|
|
@@ -522,6 +558,24 @@ export function getAgentResolver() { return current; }
|
|
|
522
558
|
|
|
523
559
|
const resolverOf = (agents) => { try { return (typeof agents === 'function' ? agents() : agents) || null; } catch { return null; } };
|
|
524
560
|
|
|
561
|
+
/** Resolve a worker role without contributing a runtime to the model router. Only implicit lookup is best effort. */
|
|
562
|
+
export function routedAgent(agents, taskClass, projectPath, requested, pinned = null) {
|
|
563
|
+
if (requested === 'none') return { meta: { agentRequest: 'none' } };
|
|
564
|
+
const resolver = resolverOf(agents);
|
|
565
|
+
const id = requested || pinned?.id || resolver?.registry?.builtinIdForClass?.(taskClass);
|
|
566
|
+
try {
|
|
567
|
+
if (!id || !resolver) throw new AgentResolveError('AGENTS_UNAVAILABLE', 503, 'No approved class agent is available.');
|
|
568
|
+
const resolved = pinned || resolver.resolve(id, { projectPath });
|
|
569
|
+
const meta = { agentRef: resolved.ref, agentRevision: resolved.revision, ...(requested ? { agentRequest: requested } : {}) };
|
|
570
|
+
return { resolved, resolver, meta };
|
|
571
|
+
} catch (error) {
|
|
572
|
+
if (requested) throw error;
|
|
573
|
+
const note = correction('agentRef', id || taskClass, null, 'class_agent_unavailable',
|
|
574
|
+
`The ${taskClass} worker will run without its default agent. ${error.message}`);
|
|
575
|
+
return { note };
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
525
579
|
/**
|
|
526
580
|
* The dispatcher's one call: `rawSpec` with the agent it names applied, or `rawSpec` itself when it names none.
|
|
527
581
|
* A spec that names an agent on a server with no resolver is refused, never started as a plain worker.
|
|
@@ -529,7 +583,7 @@ const resolverOf = (agents) => { try { return (typeof agents === 'function' ? ag
|
|
|
529
583
|
*/
|
|
530
584
|
export function agentIntake(agents, rawSpec = {}, ctx = {}) {
|
|
531
585
|
const ref = agentRefOf(rawSpec);
|
|
532
|
-
if (ref === undefined) return rawSpec;
|
|
586
|
+
if (ref === undefined || ref === 'none') return rawSpec;
|
|
533
587
|
const resolver = resolverOf(agents);
|
|
534
588
|
if (!resolver) throw new AgentResolveError('AGENTS_UNAVAILABLE', 503, 'This dispatch names an agent, and agents are not available on this server. Nothing was started.', { agentRef: ref.slice(0, 200) });
|
|
535
589
|
return resolver.intake(rawSpec, ctx);
|
|
@@ -537,7 +591,12 @@ export function agentIntake(agents, rawSpec = {}, ctx = {}) {
|
|
|
537
591
|
|
|
538
592
|
/** agent_route's proposals with their agents filled in; the body itself when there is nothing to fill. */
|
|
539
593
|
export function expandAgentProposals(agents, body = {}) {
|
|
540
|
-
|
|
594
|
+
const requested = agentRefOf(body);
|
|
595
|
+
if (requested && Array.isArray(body.proposals)) {
|
|
596
|
+
body = { ...body, proposals: body.proposals.map(proposal =>
|
|
597
|
+
agentRefOf(proposal) || !isObject(proposal) ? proposal : { ...proposal, agent_ref: requested }) };
|
|
598
|
+
}
|
|
599
|
+
if (!hasNamedProposal(body)) return body;
|
|
541
600
|
const resolver = resolverOf(agents);
|
|
542
601
|
if (!resolver) throw new AgentResolveError('AGENTS_UNAVAILABLE', 503, 'A proposal names an agent, and agents are not available on this server.');
|
|
543
602
|
return resolver.expandProposals(body);
|