synabun 2.3.1 → 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 +41 -0
- package/README.md +1 -1
- package/browser-extension/content.js +189 -0
- package/browser-extension/engine.js +508 -0
- package/browser-extension/icons/icon-128.png +0 -0
- package/browser-extension/icons/icon-16.png +0 -0
- package/browser-extension/icons/icon-32.png +0 -0
- package/browser-extension/icons/icon-48.png +0 -0
- package/browser-extension/icons/status-off-16.png +0 -0
- package/browser-extension/icons/status-off-32.png +0 -0
- package/browser-extension/icons/status-off-48.png +0 -0
- package/browser-extension/icons/status-on-16.png +0 -0
- package/browser-extension/icons/status-on-32.png +0 -0
- package/browser-extension/icons/status-on-48.png +0 -0
- package/browser-extension/manifest.json +56 -0
- package/browser-extension/popup-strings.js +250 -0
- package/browser-extension/popup-view.js +151 -0
- package/browser-extension/popup.css +166 -0
- package/browser-extension/popup.html +108 -0
- package/browser-extension/popup.js +359 -0
- package/browser-extension/protocol.js +232 -0
- package/browser-extension/service-worker.js +275 -0
- package/browser-extension/setup-content.js +36 -0
- package/browser-extension/tokens.css +326 -0
- package/docs/browser-extension-bridge.md +84 -0
- package/docs/whatsapp.md +1 -1
- package/lib/data-home-files.js +45 -0
- package/lib/data-home-migration.js +34 -58
- package/mcp-server/dist/http.d.ts +2 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +9 -1
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts +11 -0
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +38 -3
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.d.ts +6 -2
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.js +10 -3
- package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
- package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -1
- package/mcp-server/dist/services/codex-config-heal.js +7 -0
- package/mcp-server/dist/services/codex-config-heal.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +95 -3
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +168 -23
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/team-context.d.ts +18 -0
- package/mcp-server/dist/services/team-context.d.ts.map +1 -0
- package/mcp-server/dist/services/team-context.js +29 -0
- package/mcp-server/dist/services/team-context.js.map +1 -0
- package/mcp-server/dist/services/tool-catalog.d.ts +5 -2
- package/mcp-server/dist/services/tool-catalog.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +22 -6
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-list.js +4 -0
- package/mcp-server/dist/services/tool-list.js.map +1 -1
- package/mcp-server/dist/services/tool-runtime.d.ts +8 -1
- package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-runtime.js +18 -1
- package/mcp-server/dist/services/tool-runtime.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +133 -0
- package/mcp-server/dist/tools/agent-definition.d.ts.map +1 -0
- package/mcp-server/dist/tools/agent-definition.js +483 -0
- package/mcp-server/dist/tools/agent-definition.js.map +1 -0
- package/mcp-server/dist/tools/agents.d.ts +92 -9
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +163 -20
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +8 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +70 -6
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/git-tools.d.ts +4 -2
- package/mcp-server/dist/tools/git-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/git-tools.js +283 -2
- package/mcp-server/dist/tools/git-tools.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts +8 -2
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +22 -5
- package/mcp-server/dist/tools/morelogin.js.map +1 -1
- package/mcp-server/dist/tools/team.d.ts +32 -0
- package/mcp-server/dist/tools/team.d.ts.map +1 -0
- package/mcp-server/dist/tools/team.js +87 -0
- package/mcp-server/dist/tools/team.js.map +1 -0
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +9 -1
- package/mcp-server/src/index.ts +34 -4
- package/mcp-server/src/services/browser-route-flow.ts +12 -5
- package/mcp-server/src/services/codex-config-heal.ts +7 -0
- package/mcp-server/src/services/neural-interface.ts +191 -29
- package/mcp-server/src/services/team-context.ts +27 -0
- package/mcp-server/src/services/tool-catalog.ts +26 -8
- package/mcp-server/src/services/tool-list.ts +4 -0
- package/mcp-server/src/services/tool-runtime.ts +21 -2
- package/mcp-server/src/tools/agent-definition.ts +458 -0
- package/mcp-server/src/tools/agents.ts +177 -19
- package/mcp-server/src/tools/browser-advanced.ts +60 -6
- package/mcp-server/src/tools/git-tools.ts +249 -3
- package/mcp-server/src/tools/morelogin.ts +20 -5
- package/mcp-server/src/tools/team.ts +97 -0
- package/neural-interface/i18n/en.json +1119 -47
- package/neural-interface/i18n/pt-BR.json +1119 -47
- package/neural-interface/lib/account-usage.js +1 -1
- package/neural-interface/lib/agents/builtins.json +207 -0
- package/neural-interface/lib/agents/density.js +101 -0
- package/neural-interface/lib/agents/forge-host.js +223 -0
- package/neural-interface/lib/agents/native-export-targets.js +190 -0
- package/neural-interface/lib/agents/native-export.js +365 -0
- package/neural-interface/lib/agents/registry.js +885 -0
- package/neural-interface/lib/agents/resolve.js +603 -0
- package/neural-interface/lib/agents/schema.js +642 -0
- package/neural-interface/lib/agents/split.js +37 -0
- package/neural-interface/lib/agents-studio-api.js +591 -0
- package/neural-interface/lib/assistant-api.js +76 -7
- package/neural-interface/lib/assistant-brains/opencode.js +60 -11
- package/neural-interface/lib/assistant-catalog.js +2 -0
- package/neural-interface/lib/assistant-continuity.js +49 -0
- package/neural-interface/lib/assistant-dispatch.js +351 -121
- package/neural-interface/lib/assistant-persona.js +105 -8
- package/neural-interface/lib/assistant-route-gate.js +24 -9
- package/neural-interface/lib/assistant-router.js +432 -47
- package/neural-interface/lib/assistant-run-tail.js +151 -0
- package/neural-interface/lib/assistant-run-wait.js +183 -0
- package/neural-interface/lib/assistant-runtime.js +449 -94
- package/neural-interface/lib/assistant-task-prompt.js +11 -2
- package/neural-interface/lib/assistant-usage.js +3 -2
- package/neural-interface/lib/automation-approval.js +2 -2
- package/neural-interface/lib/backup-service.js +64 -105
- package/neural-interface/lib/browser-close-evidence.js +80 -0
- package/neural-interface/lib/browser-default.js +210 -0
- package/neural-interface/lib/browser-extension-adapter.js +264 -0
- package/neural-interface/lib/browser-extension-bridge.js +441 -0
- package/neural-interface/lib/browser-extension-folder.js +116 -0
- package/neural-interface/lib/browser-extension-setup.js +140 -0
- package/neural-interface/lib/browser-profile-choices.js +3 -3
- package/neural-interface/lib/browser-tool-policy.js +1 -1
- package/neural-interface/lib/claude-account-links.js +301 -0
- package/neural-interface/lib/claude-accounts.js +45 -20
- package/neural-interface/lib/claude-agent-bridge.js +142 -10
- package/neural-interface/lib/claude-model-catalog.js +6 -0
- package/neural-interface/lib/claude-panel-session.js +33 -0
- package/neural-interface/lib/codex-accounts.js +67 -24
- package/neural-interface/lib/coordination/README.md +384 -0
- package/neural-interface/lib/coordination/service.js +563 -0
- package/neural-interface/lib/coordination/store.js +1138 -0
- package/neural-interface/lib/db.js +22 -1
- package/neural-interface/lib/effort-levels.js +10 -1
- package/neural-interface/lib/memory-list-page.js +49 -0
- package/neural-interface/lib/memory-list-stamp.js +60 -0
- package/neural-interface/lib/morelogin-outside-close.js +186 -0
- package/neural-interface/lib/morelogin-profile-failures.js +206 -0
- package/neural-interface/lib/morelogin-start-cooldown.js +160 -0
- package/neural-interface/lib/morelogin.js +194 -8
- package/neural-interface/lib/native-loop-runtime.js +26 -7
- package/neural-interface/lib/opencode-build-preflight.js +28 -8
- package/neural-interface/lib/opencode-native-boundary.js +83 -13
- package/neural-interface/lib/opencode-serve-records.js +14 -9
- package/neural-interface/lib/page-session.js +1 -1
- package/neural-interface/lib/peer-identity.js +73 -29
- package/neural-interface/lib/process-identity.js +68 -7
- package/neural-interface/lib/request-gate.js +3 -0
- package/neural-interface/lib/screenshot-location.js +33 -0
- package/neural-interface/lib/session-cache-builder.js +41 -3
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
- package/neural-interface/lib/studio-attention.js +56 -0
- package/neural-interface/lib/teams/README.md +382 -0
- package/neural-interface/lib/teams/api.js +287 -0
- package/neural-interface/lib/teams/brief.js +185 -0
- package/neural-interface/lib/teams/claims.js +315 -0
- package/neural-interface/lib/teams/git.js +293 -0
- package/neural-interface/lib/teams/index.js +122 -0
- package/neural-interface/lib/teams/integration.js +580 -0
- package/neural-interface/lib/teams/landing.js +184 -0
- package/neural-interface/lib/teams/recovery.js +256 -0
- package/neural-interface/lib/teams/scheduler.js +1474 -0
- package/neural-interface/lib/teams/schema.js +559 -0
- package/neural-interface/lib/teams/state.js +181 -0
- package/neural-interface/lib/teams/test-runner.js +86 -0
- package/neural-interface/lib/teams/test-sandbox.js +99 -0
- package/neural-interface/lib/teams/worktrees.js +757 -0
- package/neural-interface/lib/tool-permission-choices.js +226 -0
- package/neural-interface/lib/whatsapp/cards.js +24 -10
- package/neural-interface/lib/worker-confinement.js +206 -6
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +107 -0
- package/neural-interface/public/index.html +103 -12
- package/neural-interface/public/offline.html +4 -3
- package/neural-interface/public/shared/agent-runtime-options.js +3 -1
- package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
- package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
- package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
- package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
- package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
- package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
- package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
- package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
- package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
- package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
- package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
- package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
- package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
- package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
- package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
- package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
- package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
- package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
- package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
- package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
- package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
- package/neural-interface/public/shared/agy/agy-panel.js +142 -28
- package/neural-interface/public/shared/agy/agy-styles.js +25 -5
- package/neural-interface/public/shared/api.js +2 -1
- package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
- package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
- package/neural-interface/public/shared/assistant/asst-control.js +3 -0
- package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
- package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
- package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
- package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
- package/neural-interface/public/shared/assistant/asst-render.js +37 -6
- package/neural-interface/public/shared/assistant/asst-route.js +80 -12
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
- package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
- package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
- package/neural-interface/public/shared/assistant/asst-state.js +66 -1
- package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
- package/neural-interface/public/shared/assistant/route-identity.js +16 -0
- package/neural-interface/public/shared/cc-dropdown.js +21 -15
- package/neural-interface/public/shared/cdx/cdx-output.js +10 -0
- package/neural-interface/public/shared/cdx/cdx-panel.js +18 -16
- package/neural-interface/public/shared/cdx/cdx-plan.js +3 -2
- package/neural-interface/public/shared/cdx/cdx-render.js +122 -45
- package/neural-interface/public/shared/cdx/cdx-requests.js +4 -4
- package/neural-interface/public/shared/cdx/cdx-styles.js +8 -36
- package/neural-interface/public/shared/cdx/cdx-tabs.js +110 -42
- package/neural-interface/public/shared/claude-panel-lazy.js +12 -0
- package/neural-interface/public/shared/code-copy.js +120 -0
- package/neural-interface/public/shared/constants.js +7 -0
- package/neural-interface/public/shared/context-menu-model.js +1 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-session-model.js +86 -5
- package/neural-interface/public/shared/cp/cp-session-settings.js +58 -30
- package/neural-interface/public/shared/cp/cp-styles.js +9 -0
- package/neural-interface/public/shared/dom-change-flag.js +66 -0
- package/neural-interface/public/shared/dom-morph.js +124 -0
- package/neural-interface/public/shared/extension-setup/es-page.css +134 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +120 -0
- package/neural-interface/public/shared/extension-setup/es-view.js +100 -0
- package/neural-interface/public/shared/html-shell.js +34 -4
- package/neural-interface/public/shared/i18n.js +14 -1
- package/neural-interface/public/shared/idle-queue.js +78 -0
- package/neural-interface/public/shared/iface-config.js +227 -0
- package/neural-interface/public/shared/lazy-module.js +108 -0
- package/neural-interface/public/shared/memory-list.js +117 -0
- package/neural-interface/public/shared/morelogin-profile-choices.js +1 -1
- package/neural-interface/public/shared/morelogin-profile-field.js +3 -3
- package/neural-interface/public/shared/mtc/mtc-panel.js +3 -1
- package/neural-interface/public/shared/mtc/mtc-styles.js +4 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +35 -15
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +77 -23
- package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +3 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +24 -21
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +16 -5
- package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +16 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -43
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +73 -9
- 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/schedules-view.js +2 -2
- package/neural-interface/public/shared/session-project-items.js +11 -0
- package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
- package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
- package/neural-interface/public/shared/settings/settings-ia.js +4 -2
- package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
- package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
- package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
- package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
- package/neural-interface/public/shared/sidepanel-shown.js +73 -0
- package/neural-interface/public/shared/start-bridge.js +2 -2
- package/neural-interface/public/shared/storage.js +6 -1
- package/neural-interface/public/shared/studio-attention.js +83 -0
- package/neural-interface/public/shared/styles.css +694 -50
- package/neural-interface/public/shared/term-browser-tabs.js +34 -0
- package/neural-interface/public/shared/transcript-rows.js +334 -0
- package/neural-interface/public/shared/tray-auto-close.js +106 -0
- package/neural-interface/public/shared/ui-agents.js +97 -0
- package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
- package/neural-interface/public/shared/ui-automation-studio.js +3 -3
- package/neural-interface/public/shared/ui-claude-panel.js +162 -95
- package/neural-interface/public/shared/ui-code-copy.js +256 -0
- package/neural-interface/public/shared/ui-codex-panel.js +14 -10
- package/neural-interface/public/shared/ui-context-menu.js +1 -1
- package/neural-interface/public/shared/ui-file-explorer.js +2 -3
- package/neural-interface/public/shared/ui-games.js +1 -1
- package/neural-interface/public/shared/ui-loading.js +83 -19
- package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
- package/neural-interface/public/shared/ui-menubar.js +23 -0
- package/neural-interface/public/shared/ui-native-loop-router.js +50 -21
- package/neural-interface/public/shared/ui-navbar.js +15 -9
- package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
- package/neural-interface/public/shared/ui-owner-authority.js +48 -25
- package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
- package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
- package/neural-interface/public/shared/ui-sessions.js +3 -3
- package/neural-interface/public/shared/ui-settings-entry.js +55 -0
- package/neural-interface/public/shared/ui-settings.js +363 -400
- package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
- package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
- package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
- package/neural-interface/public/shared/ui-styleguide.js +10 -2
- package/neural-interface/public/shared/ui-sync.js +6 -0
- package/neural-interface/public/shared/ui-terminal.js +13 -9
- package/neural-interface/public/shared/ui-tooltip.js +28 -7
- package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
- package/neural-interface/public/shared/ui-tray-columns.js +375 -0
- package/neural-interface/public/shared/ui-whiteboard.js +51 -6
- package/neural-interface/public/shared/ui-worker-end.js +28 -1
- package/neural-interface/public/shared/ui-workspaces.js +13 -0
- package/neural-interface/public/shared/window-keys.js +71 -0
- package/neural-interface/public/sw.js +4 -3
- package/neural-interface/public/variant/2d/main.js +2 -0
- package/neural-interface/public/variant/3d/app.js +620 -0
- package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
- package/neural-interface/public/variant/3d/main.js +30 -544
- package/neural-interface/public/variant/3d/map-controls.js +4 -2
- package/neural-interface/public/vendor/fonts/fonts.css +508 -0
- package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/manifest.json +142 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
- package/neural-interface/scripts/boot-graph.mjs +270 -0
- package/neural-interface/scripts/vendor-fonts.mjs +124 -0
- package/neural-interface/server.js +1083 -164
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -1
- package/skills/agent-forge/SKILL.md +182 -0
- package/skills/agent-forge/evals/evals.json +56 -0
- package/skills/agent-forge/references/definition-fields.md +61 -0
- package/skills/agent-forge/references/examples.md +105 -0
- package/skills/agent-forge/references/instructions.md +51 -0
- package/skills/agent-forge/references/review-and-export.md +84 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun — Agents: where a native export goes, and the write (phase P6)
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// The one place that turns "Claude Code, this account" or "OpenCode, that project" into a path, looks at what is
|
|
6
|
+
// there, and writes an export (lib/agents/native-export.js makes the text). The rules are the ones Skills Studio's
|
|
7
|
+
// own agent creation follows (server.js POST /api/skills-studio/create):
|
|
8
|
+
//
|
|
9
|
+
// - two places only: the account level (Claude Code's config dir, OpenCode's configuration folder) or a project
|
|
10
|
+
// SynaBun has registered. A project that is not registered is refused; no path is ever taken from a request.
|
|
11
|
+
// - the file must really land in that folder (lib/path-confine.js confineToRoot): a linked `.claude/agents` in a
|
|
12
|
+
// project that leads elsewhere is refused before any folder is made.
|
|
13
|
+
// - a new file is created exclusively (lib/confined-fs.js). Nothing that exists is replaced unless the owner says
|
|
14
|
+
// so AND names the digest of what is there now; a link, a folder or a device at the file's place is never written.
|
|
15
|
+
// - OpenCode has one document for many things: only the `agents.<id>` key is set, the rest of the user's file stays
|
|
16
|
+
// as it is, and a file that is not JSON is never overwritten. `opencode.jsonc` is the user's and is never written.
|
|
17
|
+
//
|
|
18
|
+
// Nothing here decides who may write: lib/agents-studio-api.js lets only the owner's page reach `write`. `inspect`
|
|
19
|
+
// reads and never writes, so a preview is safe for the Assistant.
|
|
20
|
+
|
|
21
|
+
import { lstatSync, statSync } from 'node:fs';
|
|
22
|
+
import { join, resolve } from 'node:path';
|
|
23
|
+
import { entryKind, readConfinedFile, replaceFileAtomic, writeConfinedFile } from '../confined-fs.js';
|
|
24
|
+
import { OPENCODE_CONFIG_FILE, OPENCODE_CONFIG_SCHEMA, agentOf, parseJsonc, setAgent } from '../opencode-config.js';
|
|
25
|
+
import { PathConfineError, confineToRoot } from '../path-confine.js';
|
|
26
|
+
import { NativeExportError, entryDigest, nativeDigest } from './native-export.js';
|
|
27
|
+
|
|
28
|
+
export const NATIVE_TARGET_KINDS = Object.freeze(['account', 'project']);
|
|
29
|
+
/** The most an existing file is read to compare it (an agent file or an opencode.json is far smaller). */
|
|
30
|
+
export const NATIVE_TARGET_MAX_BYTES = 2 * 1024 * 1024;
|
|
31
|
+
|
|
32
|
+
const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {object} o
|
|
36
|
+
* @param {() => string} o.claudeHome Claude Code's config dir (CLAUDE_CONFIG_DIR, else ~/.claude)
|
|
37
|
+
* @param {() => string} o.opencodeConfigDir OpenCode's configuration folder (lib/opencode-config.js opencodeConfigDir)
|
|
38
|
+
* @param {(path: string) => boolean} o.isRegisteredProject is this folder a project SynaBun has registered?
|
|
39
|
+
*/
|
|
40
|
+
export function createNativeExportTargets({ claudeHome, opencodeConfigDir, isRegisteredProject } = {}) {
|
|
41
|
+
if (typeof claudeHome !== 'function' || typeof opencodeConfigDir !== 'function' || typeof isRegisteredProject !== 'function') {
|
|
42
|
+
throw new Error('createNativeExportTargets needs { claudeHome, opencodeConfigDir, isRegisteredProject }');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Where an export of `exported` would be written.
|
|
47
|
+
* @param {object} exported an exportNative() result (supported)
|
|
48
|
+
* @param {{ id: string, target?: 'account'|'project', projectPath?: string|null }} where
|
|
49
|
+
* @returns {{ host, kind: 'account'|'project', projectPath: string|null, path: string, root: { dir: string, anchor: string } }}
|
|
50
|
+
* @throws {NativeExportError} 400 `no_native_format` / `invalid_target` / `project_required`, 403 `project_not_registered`
|
|
51
|
+
*/
|
|
52
|
+
function resolveTarget(exported, { id, target = 'account', projectPath = null } = {}) {
|
|
53
|
+
if (!exported?.supported) throw new NativeExportError(400, 'no_native_format', exported?.reason || 'This host has no native agent format.', { host: exported?.host || null });
|
|
54
|
+
const kind = String(target || 'account').trim().toLowerCase();
|
|
55
|
+
if (!NATIVE_TARGET_KINDS.includes(kind)) throw new NativeExportError(400, 'invalid_target', 'target is "account" (the host\'s own folder) or "project" (a registered project).');
|
|
56
|
+
let project = null;
|
|
57
|
+
if (kind === 'project') {
|
|
58
|
+
if (typeof projectPath !== 'string' || !projectPath.trim()) throw new NativeExportError(400, 'project_required', 'A project target names its project: the absolute path of a registered project.');
|
|
59
|
+
let registered = false;
|
|
60
|
+
try { registered = !!isRegisteredProject(projectPath); } catch { registered = false; }
|
|
61
|
+
if (!registered) throw new NativeExportError(403, 'project_not_registered', 'Not a registered project: an export goes to the account level or to a project SynaBun knows.');
|
|
62
|
+
project = resolve(projectPath);
|
|
63
|
+
}
|
|
64
|
+
let dir;
|
|
65
|
+
let path;
|
|
66
|
+
if (exported.host === 'claude-code') {
|
|
67
|
+
dir = join(project || resolve(claudeHome()), ...(project ? ['.claude', 'agents'] : ['agents']));
|
|
68
|
+
path = join(dir, `${id}.md`);
|
|
69
|
+
} else {
|
|
70
|
+
dir = project || resolve(opencodeConfigDir());
|
|
71
|
+
path = join(dir, OPENCODE_CONFIG_FILE);
|
|
72
|
+
}
|
|
73
|
+
// The folder the file must really land in, and (for a folder inside a project) the project it must stay within.
|
|
74
|
+
// OpenCode's project document sits in the project's own folder: there is no folder between them to check.
|
|
75
|
+
const root = { dir, anchor: project && dir !== project ? project : '' };
|
|
76
|
+
try { confineToRoot(root, path); } catch (error) {
|
|
77
|
+
if (error instanceof PathConfineError) throw new NativeExportError(403, 'target_leaves_folder', 'That place leads out of its folder through a link: nothing is written there.');
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
return { host: exported.host, kind, projectPath: project, path, root };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The text of the file at a target, or what is in its place: { kind, text, stat }. Never follows a link. */
|
|
84
|
+
function onDisk(resolved) {
|
|
85
|
+
const kind = entryKind(resolved.path);
|
|
86
|
+
if (kind !== 'file') return { kind, text: null, stat: null };
|
|
87
|
+
let text;
|
|
88
|
+
try { text = readConfinedFile(resolved.root.dir, resolved.path, { maxBytes: NATIVE_TARGET_MAX_BYTES, encoding: 'utf-8' }); } catch (error) {
|
|
89
|
+
if (error instanceof PathConfineError) return { kind: 'unreadable', text: null, stat: null, problem: error.message };
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
let stat = null;
|
|
93
|
+
try { const st = lstatSync(resolved.path); stat = { dev: st.dev, ino: st.ino, mtimeMs: st.mtimeMs, size: st.size, mode: st.mode & 0o777 }; } catch { stat = null; }
|
|
94
|
+
return { kind, text, stat };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** An OpenCode document's text as its object. `error` when it is not a JSON object (such a file is never written). */
|
|
98
|
+
function readDocument(text) {
|
|
99
|
+
try {
|
|
100
|
+
const value = text.trim() ? JSON.parse(text.replace(/^/, '')) : {};
|
|
101
|
+
return isObject(value) ? { config: value, error: null } : { config: null, error: 'it does not hold a JSON object' };
|
|
102
|
+
} catch (error) { return { config: null, error: error?.message || 'it is not JSON' }; }
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Does the `opencode.jsonc` beside a document define this agent too? (It wins over opencode.json.) */
|
|
106
|
+
function jsoncOverrides(resolved, id) {
|
|
107
|
+
const path = join(resolved.root.dir, 'opencode.jsonc');
|
|
108
|
+
if (entryKind(path) !== 'file') return false;
|
|
109
|
+
try {
|
|
110
|
+
const config = parseJsonc(readConfinedFile(resolved.root.dir, path, { maxBytes: NATIVE_TARGET_MAX_BYTES, encoding: 'utf-8' }));
|
|
111
|
+
return isObject(config) && (isObject(config.agents?.[id]) || isObject(config.agent?.[id]));
|
|
112
|
+
} catch { return false; }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* What is at the target now, compared with what an export would put there. Reads only.
|
|
117
|
+
* @returns {{ host, kind, projectPath, path, exists: boolean, existingDigest: string|null, same: boolean,
|
|
118
|
+
* writable: boolean, problem: string|null, overriddenByJsonc?: boolean }}
|
|
119
|
+
* `exists`: the agent is there already (the file, or the entry of that id). `existingDigest`: of the file's text
|
|
120
|
+
* (Claude Code) or of the entry (OpenCode): what a replace must name.
|
|
121
|
+
*/
|
|
122
|
+
function inspect(resolved, exported, { id } = {}) {
|
|
123
|
+
return inspectDisk(resolved, exported, id, onDisk(resolved));
|
|
124
|
+
}
|
|
125
|
+
function inspectDisk(resolved, exported, id, disk) {
|
|
126
|
+
const base = { host: resolved.host, kind: resolved.kind, projectPath: resolved.projectPath, path: resolved.path };
|
|
127
|
+
if (disk.kind !== 'file' && disk.kind !== 'absent') {
|
|
128
|
+
return { ...base, exists: disk.kind !== 'unreadable', existingDigest: null, same: false, writable: false, problem: disk.problem || `There is a ${disk.kind === 'dir' ? 'folder' : disk.kind === 'link' ? 'link' : 'special file'} at that place: nothing is written over it.` };
|
|
129
|
+
}
|
|
130
|
+
if (exported.kind === 'file') {
|
|
131
|
+
if (disk.kind === 'absent') return { ...base, exists: false, existingDigest: null, same: false, writable: true, problem: null };
|
|
132
|
+
const existingDigest = nativeDigest(disk.text);
|
|
133
|
+
return { ...base, exists: true, existingDigest, same: existingDigest === exported.digest, writable: true, problem: null };
|
|
134
|
+
}
|
|
135
|
+
// An entry of a document.
|
|
136
|
+
const overriddenByJsonc = jsoncOverrides(resolved, id);
|
|
137
|
+
if (disk.kind === 'absent') return { ...base, exists: false, existingDigest: null, same: false, writable: true, problem: null, ...(overriddenByJsonc ? { overriddenByJsonc } : {}) };
|
|
138
|
+
const doc = readDocument(disk.text);
|
|
139
|
+
if (doc.error) return { ...base, exists: false, existingDigest: null, same: false, writable: false, problem: `The file could not be read (${doc.error}); SynaBun does not change it.` };
|
|
140
|
+
const has = isObject(doc.config.agents?.[id]) || isObject(doc.config.agent?.[id]);
|
|
141
|
+
const existingDigest = has ? entryDigest(agentOf(doc.config, id)) : null;
|
|
142
|
+
// The same entry, already in OpenCode 2's own key (an OpenCode 1 `agent.<id>` of the same content is still moved).
|
|
143
|
+
const unchanged = has && existingDigest === exported.entryDigest && isObject(doc.config.agents?.[id]) && !isObject(doc.config.agent?.[id]);
|
|
144
|
+
return { ...base, exists: has, existingDigest, same: unchanged, writable: true, problem: null, ...(overriddenByJsonc ? { overriddenByJsonc } : {}) };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Write an export to its target. The caller is the owner's page (lib/agents-studio-api.js): nothing else reaches this.
|
|
149
|
+
* @param {object} resolved a resolveTarget() result
|
|
150
|
+
* @param {object} exported an exportNative() result
|
|
151
|
+
* @param {{ id: string, replace?: boolean, expectedDigest?: string|null }} options `replace` with the
|
|
152
|
+
* `existingDigest` the owner saw replaces what is there; without both, an agent that exists is left alone.
|
|
153
|
+
* @returns {{ host, kind, projectPath, path, action: 'created'|'replaced'|'unchanged', digest: string }}
|
|
154
|
+
* @throws {NativeExportError} 409 `export_exists` (with `existingDigest`), 409 `export_changed`, 409 `target_not_writable`
|
|
155
|
+
*/
|
|
156
|
+
function write(resolved, exported, { id, replace = false, expectedDigest = null } = {}) {
|
|
157
|
+
// One read: what is compared and what is replaced are the same bytes (`expect` refuses a file that changed since).
|
|
158
|
+
const disk = onDisk(resolved);
|
|
159
|
+
const before = inspectDisk(resolved, exported, id, disk);
|
|
160
|
+
const base = { host: resolved.host, kind: resolved.kind, projectPath: resolved.projectPath, path: resolved.path };
|
|
161
|
+
if (!before.writable) throw new NativeExportError(409, 'target_not_writable', before.problem || 'That place cannot be written.', { path: resolved.path });
|
|
162
|
+
if (before.same) return { ...base, action: 'unchanged', digest: exported.kind === 'file' ? exported.digest : exported.entryDigest };
|
|
163
|
+
if (before.exists) {
|
|
164
|
+
if (replace !== true) throw new NativeExportError(409, 'export_exists', `${exported.kind === 'file' ? 'A file' : 'An agent'} "${id}" is already there. Look at it first: replacing it needs replace and its digest.`, { path: resolved.path, existingDigest: before.existingDigest });
|
|
165
|
+
if (typeof expectedDigest !== 'string' || expectedDigest !== before.existingDigest) throw new NativeExportError(409, 'export_changed', 'What is there is not what you looked at: read it again before replacing it.', { path: resolved.path, existingDigest: before.existingDigest });
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
if (exported.kind === 'file') {
|
|
169
|
+
if (disk.kind === 'absent') writeConfinedFile(resolved.root.dir, resolved.path, exported.content, { exclusive: true, mode: 0o644 });
|
|
170
|
+
else replaceFileAtomic(resolved.path, exported.content, { mode: disk.stat?.mode || 0o644, expect: disk.stat, exactMode: true });
|
|
171
|
+
return { ...base, action: disk.kind === 'absent' ? 'created' : 'replaced', digest: exported.digest };
|
|
172
|
+
}
|
|
173
|
+
const doc = disk.kind === 'absent' ? { config: { $schema: OPENCODE_CONFIG_SCHEMA }, error: null } : readDocument(disk.text);
|
|
174
|
+
if (doc.error) throw new NativeExportError(409, 'target_not_writable', `The file could not be read (${doc.error}); SynaBun does not change it.`, { path: resolved.path });
|
|
175
|
+
const next = `${JSON.stringify(setAgent(doc.config, id, exported.entry), null, 2)}\n`;
|
|
176
|
+
// A new opencode.json is the user's alone (it can come to hold keys); one that exists keeps the mode it had.
|
|
177
|
+
if (disk.kind === 'absent') writeConfinedFile(resolved.root.dir, resolved.path, next, { exclusive: true, mode: 0o600 });
|
|
178
|
+
else replaceFileAtomic(resolved.path, next, { mode: disk.stat?.mode || 0o600, expect: disk.stat, exactMode: true });
|
|
179
|
+
return { ...base, action: before.exists ? 'replaced' : 'created', digest: exported.entryDigest };
|
|
180
|
+
} catch (error) {
|
|
181
|
+
if (error instanceof PathConfineError) throw new NativeExportError(error.status === 409 ? 409 : 403, error.status === 409 ? 'export_changed' : 'target_leaves_folder', error.message, { path: resolved.path });
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Is anything at this path a regular file? (For a test and a status line.) */
|
|
187
|
+
function exists(path) { try { return statSync(path).isFile(); } catch { return false; } }
|
|
188
|
+
|
|
189
|
+
return { resolveTarget, inspect, write, exists };
|
|
190
|
+
}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun — Agents: native export and import (phase P6)
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// A SynaBun agent definition as the file a host reads its own agents from, and back. Two hosts have such a file in
|
|
6
|
+
// what SynaBun's adapters know:
|
|
7
|
+
//
|
|
8
|
+
// Claude Code <config dir>/agents/<id>.md, <project>/.claude/agents/<id>.md: YAML frontmatter (name, description,
|
|
9
|
+
// tools, model, and the newer effort / skills / mcpServers) and a body that is the agent's prompt.
|
|
10
|
+
// The reader is the registry's parseClaudeAgent (lib/agents/registry.js).
|
|
11
|
+
// OpenCode the `agents.<id>` entry of an `opencode.json` (OpenCode 2's schema, lib/opencode-config.js:
|
|
12
|
+
// `system`, `description`, `permissions` as rules). OpenCode has one document for many things, so
|
|
13
|
+
// the export is that one key, never a whole file.
|
|
14
|
+
//
|
|
15
|
+
// Codex and Antigravity have none: their adapters here read rules (AGENTS.md, GEMINI.md), prompts and skills, and
|
|
16
|
+
// none of those names a model, tools and limits for one agent. For them the answer says so (`supported: false`),
|
|
17
|
+
// with what to do instead; no format is made up.
|
|
18
|
+
//
|
|
19
|
+
// A native file holds less than a definition does. Every mapping says what it left out (`unrepresented`: the field,
|
|
20
|
+
// its value, why), so nobody reads a native agent as the reviewed one: the capability guard, the browser, the
|
|
21
|
+
// MoreLogin profile, SynaBun's tool groups, routing and revisions stay SynaBun's.
|
|
22
|
+
//
|
|
23
|
+
// Pure: no file, network or clock access. Where an export may be written, and the write itself, is
|
|
24
|
+
// lib/agents/native-export-targets.js; who may ask for it is lib/agents-studio-api.js (the owner's page only).
|
|
25
|
+
|
|
26
|
+
import { createHash } from 'node:crypto';
|
|
27
|
+
import * as YAML from 'yaml';
|
|
28
|
+
import { OPENCODE_CONFIG_SCHEMA, agentOf, opencodeAgentEntry, parseJsonc, permissionRule } from '../opencode-config.js';
|
|
29
|
+
import { AgentRegistryError, parseClaudeAgent, scopeOf, slugifyAgentId } from './registry.js';
|
|
30
|
+
import { AGENT_LIMITS, AGENT_PROVIDERS, normalizeAgentDefinition } from './schema.js';
|
|
31
|
+
|
|
32
|
+
export const NATIVE_EXPORT_VERSION = 1;
|
|
33
|
+
/** The largest OpenCode document an import reads (a user's opencode.json is a few kilobytes). */
|
|
34
|
+
export const OPENCODE_IMPORT_MAX_BYTES = 1024 * 1024;
|
|
35
|
+
|
|
36
|
+
export class NativeExportError extends Error {
|
|
37
|
+
/** @param {number} status @param {string} code @param {string} message @param {object} [extra] */
|
|
38
|
+
constructor(status, code, message, extra = {}) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.name = 'NativeExportError';
|
|
41
|
+
this.status = status;
|
|
42
|
+
this.code = code;
|
|
43
|
+
Object.assign(this, extra);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* What each host has for an agent of its own. `kind`: `file` (one file per agent) or `entry` (one key of a document
|
|
51
|
+
* that holds other things). `locations` are where the host reads it, in words (the real paths are the targets').
|
|
52
|
+
*/
|
|
53
|
+
const FORMATS = Object.freeze({
|
|
54
|
+
'claude-code': Object.freeze({
|
|
55
|
+
host: 'claude-code', supported: true, format: 'claude-agent-markdown', label: 'Claude Code agent file', kind: 'file',
|
|
56
|
+
mediaType: 'text/markdown', imports: true,
|
|
57
|
+
locations: Object.freeze({ account: '<Claude Code config dir>/agents/<id>.md', project: '<project>/.claude/agents/<id>.md' }),
|
|
58
|
+
carries: Object.freeze(['id', 'description', 'instructions', 'model', 'effort', 'skills', 'mcpServers', 'capability (read-only)']),
|
|
59
|
+
}),
|
|
60
|
+
opencode: Object.freeze({
|
|
61
|
+
host: 'opencode', supported: true, format: 'opencode-agent-entry', label: 'OpenCode agent entry (opencode.json, agents.<id>)', kind: 'entry',
|
|
62
|
+
mediaType: 'application/json', imports: true,
|
|
63
|
+
locations: Object.freeze({ account: '<OpenCode config dir>/opencode.json', project: '<project>/opencode.json' }),
|
|
64
|
+
carries: Object.freeze(['id', 'description', 'instructions', 'capability (read-only)', 'permissionPolicy (ask)']),
|
|
65
|
+
}),
|
|
66
|
+
codex: Object.freeze({
|
|
67
|
+
host: 'codex', supported: false, format: null, label: 'Codex', kind: null, imports: false,
|
|
68
|
+
reason: 'Codex has no agent definition file that SynaBun reads or writes: its adapter knows rules (AGENTS.md), prompts and skills, and none of them names a model, tools and limits for one agent.',
|
|
69
|
+
instead: 'Run the agent through SynaBun (agent_ref on a dispatch runs it on Codex when its provider is codex), or export a SynaBun bundle.',
|
|
70
|
+
}),
|
|
71
|
+
antigravity: Object.freeze({
|
|
72
|
+
host: 'antigravity', supported: false, format: null, label: 'Antigravity', kind: null, imports: false,
|
|
73
|
+
reason: 'Antigravity has no agent definition file that SynaBun reads or writes: its adapter knows rules (GEMINI.md), skills and MCP servers, and none of them names a model, tools and limits for one agent.',
|
|
74
|
+
instead: 'Run the agent through SynaBun (agent_ref on a dispatch runs it on Antigravity when its provider is antigravity), or export a SynaBun bundle.',
|
|
75
|
+
}),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/** One row per host SynaBun runs workers on (lib/agents/schema.js AGENT_PROVIDERS): what it has, or why it has nothing. */
|
|
79
|
+
export function nativeFormats() {
|
|
80
|
+
return AGENT_PROVIDERS.map((host) => FORMATS[host] || { host, supported: false, format: null, label: host, kind: null, imports: false, reason: `SynaBun knows no agent definition file for ${host}.`, instead: 'Run the agent through SynaBun, or export a SynaBun bundle.' });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The row of one host. Throws 400 `unknown_host` for a host SynaBun does not run. */
|
|
84
|
+
export function nativeFormatOf(host) {
|
|
85
|
+
const id = typeof host === 'string' ? host.trim().toLowerCase() : '';
|
|
86
|
+
const row = nativeFormats().find((format) => format.host === id);
|
|
87
|
+
if (!row) throw new NativeExportError(400, 'unknown_host', `host is one of ${AGENT_PROVIDERS.join(', ')}.`, { hosts: [...AGENT_PROVIDERS] });
|
|
88
|
+
return row;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** `sha256:<64 hex>` of a text as it would be written (UTF-8). */
|
|
92
|
+
export function nativeDigest(content) {
|
|
93
|
+
return `sha256:${createHash('sha256').update(String(content ?? ''), 'utf8').digest('hex')}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Keys in one order at every depth, so the digest of an entry never depends on how its object was built. */
|
|
97
|
+
function canonical(value) {
|
|
98
|
+
if (Array.isArray(value)) return value.map(canonical);
|
|
99
|
+
if (!isObject(value)) return value;
|
|
100
|
+
return Object.fromEntries(Object.keys(value).sort().map((key) => [key, canonical(value[key])]));
|
|
101
|
+
}
|
|
102
|
+
/** The digest of a JSON value (an OpenCode agent entry as a document holds it). */
|
|
103
|
+
export function entryDigest(entry) {
|
|
104
|
+
return nativeDigest(JSON.stringify(canonical(entry ?? null)));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ── what a native agent cannot hold ──────────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
const WHY = Object.freeze({
|
|
110
|
+
name: (host) => `${host} names an agent by its id: the display name is not kept.`,
|
|
111
|
+
provider: (host, provider) => `The definition runs on ${provider}; this is ${host}'s own file, and what it runs there is ${host}'s to decide.`,
|
|
112
|
+
model: (host, provider) => `The model belongs to ${provider}: it is not a model ${host} can be told to use.`,
|
|
113
|
+
effort: (host, provider) => `The effort belongs to ${provider}.`,
|
|
114
|
+
accountId: (host) => `A native agent runs in the account ${host} is signed in to.`,
|
|
115
|
+
tools: () => 'SynaBun tool groups are served by SynaBun\'s MCP server: a native agent has them only as far as its session has that server.',
|
|
116
|
+
mcpAll: (host) => `"*" (every MCP server you allow) has no form in a native file: the agent has the servers ${host} is configured with.`,
|
|
117
|
+
workspace: (host) => `The workspace guard (writes inside the project, the temp folder and the run's scratch folder only) is SynaBun's worker guard: a native agent writes wherever ${host}'s own permissions let it.`,
|
|
118
|
+
full: (host) => `Full capability is a SynaBun dispatch setting: a native agent writes wherever ${host}'s own permissions let it.`,
|
|
119
|
+
readOnlyShell: () => 'A read-only SynaBun worker may still run read-only commands and the project\'s tests: a tool list cannot say that, so the agent has no shell.',
|
|
120
|
+
policy: (host) => `The permission policy is how SynaBun's dispatcher answers a worker's permission requests: a native agent follows ${host}'s own permission mode.`,
|
|
121
|
+
browser: () => 'The SynaBun browser is given to a dispatched worker: a native agent has no browser from this file.',
|
|
122
|
+
computer: () => 'Computer use is granted to a dispatched worker by SynaBun: a native agent has none from this file.',
|
|
123
|
+
profile: () => 'A MoreLogin profile is chosen by SynaBun for a dispatched worker\'s browser tab.',
|
|
124
|
+
skillId: () => 'A library id (skl_…) names a skill of SynaBun\'s library: only skill names are carried.',
|
|
125
|
+
memory: () => 'The memory category is part of the role block SynaBun gives a dispatched worker.',
|
|
126
|
+
classes: () => 'Task classes are how SynaBun\'s Assistant picks an agent for a task.',
|
|
127
|
+
icon: () => 'The icon is shown in SynaBun only.',
|
|
128
|
+
color: () => 'The colour is a token of SynaBun\'s style guide.',
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
/** The findings every host shares: what is SynaBun's own and no native file holds. */
|
|
132
|
+
function sharedLosses(def, host, lost) {
|
|
133
|
+
if (def.name && def.name !== def.id) lost('name', def.name, WHY.name(host));
|
|
134
|
+
if (def.accountId) lost('accountId', def.accountId, WHY.accountId(host));
|
|
135
|
+
if (def.tools !== null) lost('tools', def.tools, WHY.tools());
|
|
136
|
+
if (def.usesBrowser) lost('usesBrowser', true, WHY.browser());
|
|
137
|
+
if (def.usesComputer) lost('usesComputer', true, WHY.computer());
|
|
138
|
+
if (def.moreloginProfile) lost('moreloginProfile', def.moreloginProfile, WHY.profile());
|
|
139
|
+
if (def.memoryCategory) lost('memoryCategory', def.memoryCategory, WHY.memory());
|
|
140
|
+
if (def.taskClasses.length) lost('taskClasses', def.taskClasses, WHY.classes());
|
|
141
|
+
if (def.icon) lost('icon', def.icon, WHY.icon());
|
|
142
|
+
if (def.color) lost('color', def.color, WHY.color());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const COPY_NOTE = 'A native file is a copy: SynaBun\'s review, revisions and run records do not follow it, and a later change of the agent does not update it.';
|
|
146
|
+
|
|
147
|
+
// ── Claude Code ──────────────────────────────────────────────────────────────
|
|
148
|
+
|
|
149
|
+
/** The tools of a Claude Code agent that only reads (the registry's reader takes a list without Write, Edit or Bash as read-only). */
|
|
150
|
+
const CLAUDE_READ_TOOLS = Object.freeze(['Read', 'Grep', 'Glob']);
|
|
151
|
+
const SKILL_NAME_RE = /^[a-z0-9][a-z0-9-]{0,63}(?::[a-z0-9][a-z0-9-]{0,63})?$/;
|
|
152
|
+
const SERVER_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/;
|
|
153
|
+
|
|
154
|
+
function claudeAgent(def) {
|
|
155
|
+
const host = 'Claude Code';
|
|
156
|
+
const unrepresented = [];
|
|
157
|
+
const notes = [];
|
|
158
|
+
const lost = (field, value, reason, extra = {}) => unrepresented.push({ field, value, reason, ...extra });
|
|
159
|
+
const own = def.provider === 'claude-code';
|
|
160
|
+
const fm = { name: def.id, description: def.description || def.name || def.id };
|
|
161
|
+
if (!def.description) notes.push('The definition has no description: its name stands in, because Claude Code picks an agent by its description.');
|
|
162
|
+
|
|
163
|
+
const servers = def.mcpServers.filter((name) => name !== '*' && SERVER_NAME_RE.test(name) && name.toLowerCase() !== 'synabun');
|
|
164
|
+
if (def.mcpServers.includes('*')) lost('mcpServers', ['*'], WHY.mcpAll(host));
|
|
165
|
+
if (def.capability === 'read-only') {
|
|
166
|
+
// A list with nothing that writes: what the reader takes as read-only. The MCP servers it names are let in by name.
|
|
167
|
+
fm.tools = [...CLAUDE_READ_TOOLS, ...servers.map((name) => `mcp__${name}`)].join(', ');
|
|
168
|
+
// Carried, but not whole: `partial` says the field is in the file and this is what it does not say there.
|
|
169
|
+
lost('capability', 'read-only', WHY.readOnlyShell(), { partial: true });
|
|
170
|
+
if (servers.length) notes.push('The MCP servers are named in the tool list, so their tools are available: a server\'s tool that writes is not held back here, as SynaBun\'s read-only guard would.');
|
|
171
|
+
} else {
|
|
172
|
+
lost('capability', def.capability, def.capability === 'full' ? WHY.full(host) : WHY.workspace(host));
|
|
173
|
+
}
|
|
174
|
+
if (!own) {
|
|
175
|
+
lost('provider', def.provider, WHY.provider(host, def.provider));
|
|
176
|
+
if (def.model) lost('model', def.model, WHY.model(host, def.provider));
|
|
177
|
+
if (def.effort) lost('effort', def.effort, WHY.effort(host, def.provider));
|
|
178
|
+
}
|
|
179
|
+
fm.model = own && def.model ? def.model : 'inherit';
|
|
180
|
+
if (own && def.effort) fm.effort = def.effort;
|
|
181
|
+
const skills = def.skills.filter((ref) => SKILL_NAME_RE.test(ref));
|
|
182
|
+
const skillIds = def.skills.filter((ref) => !SKILL_NAME_RE.test(ref));
|
|
183
|
+
if (skills.length) fm.skills = skills;
|
|
184
|
+
if (skillIds.length) lost('skills', skillIds, WHY.skillId());
|
|
185
|
+
if (servers.length) fm.mcpServers = servers;
|
|
186
|
+
if (def.permissionPolicy !== 'auto') lost('permissionPolicy', def.permissionPolicy, WHY.policy(host));
|
|
187
|
+
sharedLosses(def, host, lost);
|
|
188
|
+
if (!def.instructions) notes.push('The definition has no instructions: the file has an empty body.');
|
|
189
|
+
notes.push(COPY_NOTE);
|
|
190
|
+
|
|
191
|
+
const yaml = YAML.stringify(fm, { lineWidth: 0 });
|
|
192
|
+
const content = `---\n${yaml}---\n\n${def.instructions}${def.instructions ? '\n' : ''}`;
|
|
193
|
+
return { fileName: `${def.id}.md`, content, frontmatter: fm, unrepresented, notes };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ── OpenCode ─────────────────────────────────────────────────────────────────
|
|
197
|
+
|
|
198
|
+
function openCodeAgent(def) {
|
|
199
|
+
const host = 'OpenCode';
|
|
200
|
+
const unrepresented = [];
|
|
201
|
+
const notes = [];
|
|
202
|
+
const lost = (field, value, reason) => unrepresented.push({ field, value, reason });
|
|
203
|
+
const own = def.provider === 'opencode';
|
|
204
|
+
const entry = {};
|
|
205
|
+
if (def.description) entry.description = def.description;
|
|
206
|
+
if (def.instructions) entry.system = def.instructions;
|
|
207
|
+
else notes.push('The definition has no instructions: the entry has no system prompt.');
|
|
208
|
+
|
|
209
|
+
const rules = [];
|
|
210
|
+
if (def.capability === 'read-only') {
|
|
211
|
+
// What SynaBun's own read-only OpenCode agent is made of (lib/assistant-brains/opencode.js): no edits, every command asks.
|
|
212
|
+
rules.push(permissionRule('edit', 'deny'), permissionRule('shell', 'ask'));
|
|
213
|
+
if (def.permissionPolicy === 'ask') notes.push('The "ask" policy is in the read-only rules already: edits are refused and every command asks.');
|
|
214
|
+
else if (def.permissionPolicy !== 'auto') lost('permissionPolicy', def.permissionPolicy, WHY.policy(host));
|
|
215
|
+
} else {
|
|
216
|
+
lost('capability', def.capability, def.capability === 'full' ? WHY.full(host) : WHY.workspace(host));
|
|
217
|
+
if (def.permissionPolicy === 'ask') rules.push(permissionRule('edit', 'ask'), permissionRule('shell', 'ask'));
|
|
218
|
+
else if (def.permissionPolicy !== 'auto') lost('permissionPolicy', def.permissionPolicy, WHY.policy(host));
|
|
219
|
+
}
|
|
220
|
+
if (rules.length) entry.permissions = rules;
|
|
221
|
+
|
|
222
|
+
if (!own) lost('provider', def.provider, WHY.provider(host, def.provider));
|
|
223
|
+
// SynaBun writes no model into an OpenCode agent entry anywhere, so it has no checked form for one: left out
|
|
224
|
+
// rather than guessed, because a document OpenCode cannot read stops OpenCode.
|
|
225
|
+
if (def.model) lost('model', def.model, own ? 'SynaBun has no checked form for a model in an OpenCode agent entry: pick the model in OpenCode.' : WHY.model(host, def.provider));
|
|
226
|
+
if (def.effort) lost('effort', def.effort, own ? 'An OpenCode agent entry has no effort: pick the variant in OpenCode.' : WHY.effort(host, def.provider));
|
|
227
|
+
if (def.mcpServers.length) lost('mcpServers', def.mcpServers, def.mcpServers.includes('*') ? WHY.mcpAll(host) : 'An OpenCode agent has the MCP servers of its configuration: a list per agent is not part of the entry.');
|
|
228
|
+
if (def.skills.length) lost('skills', def.skills, 'An OpenCode agent entry names no skills: OpenCode offers the skills of its folders to every agent.');
|
|
229
|
+
sharedLosses(def, host, lost);
|
|
230
|
+
notes.push('The entry sets no `mode`: OpenCode decides whether the agent is a primary agent or a subagent; add `mode` in opencode.json to choose.');
|
|
231
|
+
notes.push('An `opencode.jsonc` beside the file wins over it: an agent of this id there replaces this entry.');
|
|
232
|
+
notes.push(COPY_NOTE);
|
|
233
|
+
|
|
234
|
+
const document = { $schema: OPENCODE_CONFIG_SCHEMA, agents: { [def.id]: entry } };
|
|
235
|
+
return { fileName: 'opencode.json', content: `${JSON.stringify(document, null, 2)}\n`, entry, entryPath: `agents.${def.id}`, unrepresented, notes };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* A definition as `host`'s native agent.
|
|
240
|
+
*
|
|
241
|
+
* @param {object} definition a definition in any accepted spelling (it is normalized first)
|
|
242
|
+
* @param {string} host one of the worker providers
|
|
243
|
+
* @returns {{
|
|
244
|
+
* host: string, supported: true, format: string, label: string, kind: 'file'|'entry', mediaType: string,
|
|
245
|
+
* fileName: string, content: string, digest: string, entry?: object, entryPath?: string, entryDigest?: string,
|
|
246
|
+
* unrepresented: { field: string, value: any, reason: string, partial?: true }[], notes: string[],
|
|
247
|
+
* } | { host: string, supported: false, format: null, label: string, reason: string, instead: string, unrepresented: [], notes: string[] }}
|
|
248
|
+
* `content` is the text of the file (for OpenCode: a document that holds only the agent's entry; a write merges
|
|
249
|
+
* that one key into the user's own file and leaves the rest of it as it is).
|
|
250
|
+
* @throws {NativeExportError} 400 `unknown_host`, 400 `not_exportable` (a definition without an id)
|
|
251
|
+
*/
|
|
252
|
+
export function exportNative(definition, host) {
|
|
253
|
+
const format = nativeFormatOf(host);
|
|
254
|
+
if (!format.supported) {
|
|
255
|
+
return { host: format.host, supported: false, format: null, label: format.label, reason: format.reason, instead: format.instead, unrepresented: [], notes: [format.instead] };
|
|
256
|
+
}
|
|
257
|
+
const def = normalizeAgentDefinition(definition);
|
|
258
|
+
if (!def.id || slugifyAgentId(def.id) !== def.id) throw new NativeExportError(400, 'not_exportable', 'The definition has no usable id: a native agent is named by it.');
|
|
259
|
+
const made = format.host === 'claude-code' ? claudeAgent(def) : openCodeAgent(def);
|
|
260
|
+
return {
|
|
261
|
+
host: format.host, supported: true, format: format.format, label: format.label, kind: format.kind, mediaType: format.mediaType,
|
|
262
|
+
fileName: made.fileName, content: made.content, digest: nativeDigest(made.content),
|
|
263
|
+
...(made.entry ? { entry: made.entry, entryPath: made.entryPath, entryDigest: entryDigest(made.entry) } : {}),
|
|
264
|
+
unrepresented: made.unrepresented, notes: made.notes,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ── back: a native agent as the content of a draft ───────────────────────────
|
|
269
|
+
|
|
270
|
+
const modelText = (value) => {
|
|
271
|
+
if (typeof value === 'string') return value.trim() || null;
|
|
272
|
+
if (!isObject(value)) return null;
|
|
273
|
+
const provider = typeof value.providerID === 'string' ? value.providerID.trim() : '';
|
|
274
|
+
const model = [value.modelID, value.id, value.model].find((part) => typeof part === 'string' && part.trim());
|
|
275
|
+
return provider && model ? `${provider}/${model.trim()}` : null;
|
|
276
|
+
};
|
|
277
|
+
const ruleFor = (rules, action, effect) => rules.some((rule) => isObject(rule) && rule.action === action && rule.effect === effect && (rule.resource === undefined || rule.resource === '*'));
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* An OpenCode agent as the content of a SynaBun agent draft, with what was mapped and what was left out. Pure.
|
|
281
|
+
* @param {string|object} source the text of an opencode.json / .jsonc, the document as an object, or one agent entry
|
|
282
|
+
* @param {{ name?: string, id?: string, scope?: object }} [options] `name`: which agent of the document (needed when
|
|
283
|
+
* it holds more than one, or when `source` is an entry)
|
|
284
|
+
* @returns {{ content: object, notes: string[] }}
|
|
285
|
+
* @throws {AgentRegistryError} 400 `opencode_agent_unreadable`, 413 `too_large`
|
|
286
|
+
*/
|
|
287
|
+
export function parseOpenCodeAgent(source, { name = '', id = null, scope = null } = {}) {
|
|
288
|
+
let value = source;
|
|
289
|
+
if (typeof source === 'string') {
|
|
290
|
+
if (!source.trim()) throw new AgentRegistryError(400, 'opencode_agent_unreadable', 'Send the text of an opencode.json, or one agent entry.');
|
|
291
|
+
if (Buffer.byteLength(source, 'utf8') > OPENCODE_IMPORT_MAX_BYTES) throw new AgentRegistryError(413, 'too_large', `An OpenCode document is at most ${OPENCODE_IMPORT_MAX_BYTES / 1024} KB.`);
|
|
292
|
+
try { value = parseJsonc(source); } catch (error) { throw new AgentRegistryError(400, 'opencode_agent_unreadable', `The document could not be read: ${error?.message || 'it is not JSON'}.`); }
|
|
293
|
+
}
|
|
294
|
+
if (!isObject(value)) throw new AgentRegistryError(400, 'opencode_agent_unreadable', 'An OpenCode document, or one agent entry, is a JSON object.');
|
|
295
|
+
const notes = [];
|
|
296
|
+
let wanted = typeof name === 'string' ? name.trim() : '';
|
|
297
|
+
let entry;
|
|
298
|
+
const holds = isObject(value.agents) || isObject(value.agent);
|
|
299
|
+
if (holds) {
|
|
300
|
+
const names = [...new Set([...Object.keys(isObject(value.agent) ? value.agent : {}), ...Object.keys(isObject(value.agents) ? value.agents : {})])];
|
|
301
|
+
if (!wanted) {
|
|
302
|
+
if (names.length !== 1) throw new AgentRegistryError(400, 'opencode_agent_unreadable', names.length ? `The document holds ${names.length} agents: name the one to take (${names.slice(0, 12).join(', ')}).` : 'The document holds no agent.', { agents: names.slice(0, 50) });
|
|
303
|
+
[wanted] = names;
|
|
304
|
+
}
|
|
305
|
+
if (!names.includes(wanted)) throw new AgentRegistryError(400, 'opencode_agent_unreadable', `The document has no agent "${wanted.slice(0, 80)}".`, { agents: names.slice(0, 50) });
|
|
306
|
+
entry = agentOf(value, wanted);
|
|
307
|
+
} else {
|
|
308
|
+
if (!wanted) throw new AgentRegistryError(400, 'opencode_agent_unreadable', 'Name the agent: an entry does not hold its own name.');
|
|
309
|
+
entry = opencodeAgentEntry(value);
|
|
310
|
+
}
|
|
311
|
+
const agentId = id ? String(id).trim().toLowerCase() : slugifyAgentId(wanted);
|
|
312
|
+
if (!agentId) throw new AgentRegistryError(400, 'opencode_agent_unreadable', 'The agent\'s name gives no usable id: pass one.');
|
|
313
|
+
|
|
314
|
+
let description = typeof entry.description === 'string' ? entry.description.replace(/\s+/g, ' ').trim() : '';
|
|
315
|
+
if (description.length > AGENT_LIMITS.description) {
|
|
316
|
+
description = `${description.slice(0, AGENT_LIMITS.description - 1).trimEnd()}…`;
|
|
317
|
+
notes.push(`The description was cut to ${AGENT_LIMITS.description} characters.`);
|
|
318
|
+
}
|
|
319
|
+
let instructions = typeof entry.system === 'string' ? entry.system.replace(/\r\n?/g, '\n').trim() : '';
|
|
320
|
+
if (instructions.length > AGENT_LIMITS.instructions) {
|
|
321
|
+
instructions = instructions.slice(0, AGENT_LIMITS.instructions).trimEnd();
|
|
322
|
+
notes.push(`The instructions were cut to ${AGENT_LIMITS.instructions} characters.`);
|
|
323
|
+
}
|
|
324
|
+
const rules = Array.isArray(entry.permissions) ? entry.permissions : [];
|
|
325
|
+
const readOnly = ruleFor(rules, 'edit', 'deny');
|
|
326
|
+
const asks = !readOnly && (ruleFor(rules, 'edit', 'ask') || ruleFor(rules, 'shell', 'ask'));
|
|
327
|
+
if (rules.length) notes.push(`Permission rules read: ${readOnly ? 'edits are refused, so the agent is read-only' : asks ? 'edits or commands ask, so the policy is "ask"' : 'none that changes the capability or the policy'}. Other rules are not carried over.`);
|
|
328
|
+
const model = modelText(entry.model);
|
|
329
|
+
const known = new Set(['description', 'system', 'model', 'permissions']);
|
|
330
|
+
const dropped = Object.keys(entry).filter((key) => !known.has(key));
|
|
331
|
+
if (dropped.length) notes.push(`Not carried over: ${dropped.slice(0, 12).join(', ')}.`);
|
|
332
|
+
notes.push('OpenCode\'s tools are not SynaBun tool groups: the agent keeps the worker\'s default tools.');
|
|
333
|
+
|
|
334
|
+
return {
|
|
335
|
+
content: {
|
|
336
|
+
id: agentId,
|
|
337
|
+
name: wanted.replace(/\s+/g, ' ').slice(0, AGENT_LIMITS.name) || agentId,
|
|
338
|
+
description,
|
|
339
|
+
instructions,
|
|
340
|
+
provider: 'opencode',
|
|
341
|
+
model,
|
|
342
|
+
tools: null,
|
|
343
|
+
mcpServers: [],
|
|
344
|
+
capability: readOnly ? 'read-only' : 'workspace',
|
|
345
|
+
permissionPolicy: asks ? 'ask' : 'auto',
|
|
346
|
+
scope: scope ? scopeOf(scope) : { kind: 'global' },
|
|
347
|
+
},
|
|
348
|
+
notes,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* A host's native agent as the content of a draft: `{ content, notes }`. Nothing is stored and nothing is approved:
|
|
354
|
+
* the registry lands it as a draft (lib/agents/registry.js create / importClaudeAgent).
|
|
355
|
+
* @param {string} host
|
|
356
|
+
* @param {string|object} source the file's text (Claude Code: markdown; OpenCode: JSON, or an entry object)
|
|
357
|
+
* @param {{ fileName?: string, name?: string, id?: string, scope?: object }} [options]
|
|
358
|
+
* @throws {NativeExportError} 400 `unknown_host`, 400 `no_native_format`; the readers' own errors otherwise
|
|
359
|
+
*/
|
|
360
|
+
export function importNative(host, source, { fileName = '', name = '', id = null, scope = null } = {}) {
|
|
361
|
+
const format = nativeFormatOf(host);
|
|
362
|
+
if (!format.supported) throw new NativeExportError(400, 'no_native_format', format.reason, { host: format.host, instead: format.instead });
|
|
363
|
+
if (format.host === 'claude-code') return parseClaudeAgent(source, { fileName, id, scope });
|
|
364
|
+
return parseOpenCodeAgent(source, { name, id, scope });
|
|
365
|
+
}
|