@agent-native/core 0.127.1 → 0.128.0
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +92 -0
- package/corpus/core/README.md +5 -26
- package/corpus/core/docs/content/actions.mdx +47 -4
- package/corpus/core/docs/content/native-chat-ui.mdx +7 -0
- package/corpus/core/docs/content/organizations-teams-permissions.mdx +109 -3
- package/corpus/core/docs/content/template-design-collaboration-and-full-apps.mdx +15 -0
- package/corpus/core/docs/content/toolkit-org-team.mdx +72 -12
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/artifact-response.ts +36 -29
- package/corpus/core/src/action.ts +83 -2
- package/corpus/core/src/chat-threads/store.ts +48 -43
- package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +46 -3
- package/corpus/core/src/cli/template-sync.ts +96 -0
- package/corpus/core/src/client/AgentPanel.tsx +26 -6
- package/corpus/core/src/client/AssistantChat.tsx +63 -7
- package/corpus/core/src/client/DefaultSpinner.tsx +29 -0
- package/corpus/core/src/client/org/TeamPage.tsx +161 -6
- package/corpus/core/src/client/org/hooks.ts +67 -0
- package/corpus/core/src/client/org/index.ts +9 -0
- package/corpus/core/src/client/transcription/use-live-transcription.ts +62 -10
- package/corpus/core/src/db/client.ts +42 -3
- package/corpus/core/src/db/ensure-additive-columns.ts +60 -33
- package/corpus/core/src/deploy/build.ts +31 -2
- package/corpus/core/src/mcp-client/routes.ts +10 -1
- package/corpus/core/src/org/app-roles-handlers.ts +152 -0
- package/corpus/core/src/org/app-roles.ts +355 -0
- package/corpus/core/src/org/index.ts +27 -1
- package/corpus/core/src/org/migrations.ts +22 -0
- package/corpus/core/src/org/plugin.ts +27 -0
- package/corpus/core/src/org/schema.ts +15 -0
- package/corpus/core/src/scripts/docs/search.ts +17 -0
- package/corpus/core/src/scripts/docs/source-search.ts +10 -0
- package/corpus/core/src/server/agent-chat/script-entries.ts +3 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +53 -52
- package/corpus/core/src/server/builder-design-systems.ts +1 -1
- package/corpus/core/src/server/core-routes-plugin.ts +6 -1
- package/corpus/core/src/server/framework-request-handler.ts +44 -6
- package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/core/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/core/src/templates/default/.agents/skills/security/SKILL.md +31 -0
- package/corpus/core/src/templates/headless/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/analytics/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/analytics/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/analytics/actions/data-source-status.ts +21 -12
- package/corpus/templates/analytics/app/global.css +7 -7
- package/corpus/templates/analytics/app/i18n-data.ts +30 -0
- package/corpus/templates/analytics/app/lib/data-source-status.ts +2 -1
- package/corpus/templates/analytics/app/pages/DataSources.tsx +54 -10
- package/corpus/templates/analytics/changelog/2026-07-28-analytics-pages-load-reliably-with-large-dashboard-workspaces.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-28-dashboard-loading-shimmer-now-flows-smoothly-in-one-directi.md +6 -0
- package/corpus/templates/analytics/server/lib/first-party-dashboard-repair.ts +5 -4
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +54 -42
- package/corpus/templates/analytics/server/plugins/db.ts +1 -18
- package/corpus/templates/assets/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/assets/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/assets/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/brain/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/brain/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/templates/brain/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/brain/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/calendar/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/calendar/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/chat/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/templates/chat/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/chat/_gitignore +2 -0
- package/corpus/templates/clips/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/clips/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/clips/actions/request-transcript.ts +77 -11
- package/corpus/templates/clips/actions/save-browser-transcript.ts +28 -7
- package/corpus/templates/clips/app/routes/record.tsx +11 -3
- package/corpus/templates/clips/changelog/2026-07-28-browser-recordings-no-longer-save-a-truncated-transcript-as-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-browser-recordings-no-longer-stop-transcribing-partway-throu.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-desktop-full-screen-clips-now-get-an-instant-local-transcrip.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-long-transcriptions-no-longer-show-a-false-transcription-sto.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-restarting-for-an-update-now-installs-the-newest-release-ins.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-the-meeting-recording-pill-now-anchors-to-the-right-edge-of-.md +6 -0
- package/corpus/templates/clips/desktop/src/lib/audio-meter.ts +31 -2
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +114 -13
- package/corpus/templates/clips/desktop/src/lib/updater.ts +12 -4
- package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +40 -15
- package/corpus/templates/clips/desktop/src/styles.css +10 -7
- package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +21 -14
- package/corpus/templates/clips/shared/transcript-status.ts +10 -0
- package/corpus/templates/content/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/content/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/content/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/crm/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/design/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +23 -0
- package/corpus/templates/design/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/design/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +46 -3
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +7 -5
- package/corpus/templates/design/actions/create-file.ts +15 -0
- package/corpus/templates/design/actions/generate-design.ts +40 -0
- package/corpus/templates/design/actions/present-design-variants.ts +16 -0
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +2 -2
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +7 -4
- package/corpus/templates/design/app/components/design/keyboard-shortcuts.ts +1 -1
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +10 -4
- package/corpus/templates/design/app/lib/design-ui-events.ts +5 -0
- package/corpus/templates/design/app/pages/design-editor/save-failure.ts +7 -1
- package/corpus/templates/design/app/root.tsx +18 -1
- package/corpus/templates/design/changelog/2026-07-28-generated-designs-with-malformed-html-are-now-rejected-at-sa.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-show-or-hide-design-editing-chrome-with-cmd-on-apple-devices.md +6 -0
- package/corpus/templates/design/server/source-workspace.ts +1 -0
- package/corpus/templates/design/shared/html-integrity.ts +608 -18
- package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/dispatch/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/dispatch/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/forms/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/forms/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/forms/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/macros/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/macros/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/mail/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/mail/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/mail/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/plan/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/plan/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/templates/plan/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/plan/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/slides/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/slides/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/slides/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +2 -6
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/tasks/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/templates/tasks/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/tasks/.agents/skills/sharing/SKILL.md +4 -0
- package/dist/a2a/artifact-response.d.ts.map +1 -1
- package/dist/a2a/artifact-response.js +30 -29
- package/dist/a2a/artifact-response.js.map +1 -1
- package/dist/action.d.ts +36 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +37 -2
- package/dist/action.js.map +1 -1
- package/dist/chat-threads/store.d.ts +12 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +48 -42
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.js +46 -3
- package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -1
- package/dist/cli/template-sync.d.ts.map +1 -1
- package/dist/cli/template-sync.js +88 -0
- package/dist/cli/template-sync.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +3 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +11 -9
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +57 -6
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/DefaultSpinner.d.ts +7 -0
- package/dist/client/DefaultSpinner.d.ts.map +1 -1
- package/dist/client/DefaultSpinner.js +25 -1
- package/dist/client/DefaultSpinner.js.map +1 -1
- package/dist/client/org/TeamPage.d.ts +13 -1
- package/dist/client/org/TeamPage.d.ts.map +1 -1
- package/dist/client/org/TeamPage.js +41 -11
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/org/hooks.d.ts +37 -0
- package/dist/client/org/hooks.d.ts.map +1 -1
- package/dist/client/org/hooks.js +37 -0
- package/dist/client/org/hooks.js.map +1 -1
- package/dist/client/org/index.d.ts +3 -2
- package/dist/client/org/index.d.ts.map +1 -1
- package/dist/client/org/index.js +1 -1
- package/dist/client/org/index.js.map +1 -1
- package/dist/client/transcription/use-live-transcription.d.ts +8 -0
- package/dist/client/transcription/use-live-transcription.d.ts.map +1 -1
- package/dist/client/transcription/use-live-transcription.js +38 -11
- package/dist/client/transcription/use-live-transcription.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/client.d.ts +12 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +40 -3
- package/dist/db/client.js.map +1 -1
- package/dist/db/ensure-additive-columns.d.ts.map +1 -1
- package/dist/db/ensure-additive-columns.js +54 -32
- package/dist/db/ensure-additive-columns.js.map +1 -1
- package/dist/deploy/build.d.ts +1 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +23 -2
- package/dist/deploy/build.js.map +1 -1
- package/dist/mcp-client/routes.d.ts +3 -1
- package/dist/mcp-client/routes.d.ts.map +1 -1
- package/dist/mcp-client/routes.js +8 -2
- package/dist/mcp-client/routes.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/org/app-roles-handlers.d.ts +27 -0
- package/dist/org/app-roles-handlers.d.ts.map +1 -0
- package/dist/org/app-roles-handlers.js +125 -0
- package/dist/org/app-roles-handlers.js.map +1 -0
- package/dist/org/app-roles.d.ts +136 -0
- package/dist/org/app-roles.d.ts.map +1 -0
- package/dist/org/app-roles.js +216 -0
- package/dist/org/app-roles.js.map +1 -0
- package/dist/org/index.d.ts +4 -1
- package/dist/org/index.d.ts.map +1 -1
- package/dist/org/index.js +3 -1
- package/dist/org/index.js.map +1 -1
- package/dist/org/migrations.d.ts.map +1 -1
- package/dist/org/migrations.js +22 -0
- package/dist/org/migrations.js.map +1 -1
- package/dist/org/plugin.d.ts +2 -0
- package/dist/org/plugin.d.ts.map +1 -1
- package/dist/org/plugin.js +20 -0
- package/dist/org/plugin.js.map +1 -1
- package/dist/org/schema.d.ts +143 -0
- package/dist/org/schema.d.ts.map +1 -1
- package/dist/org/schema.js +14 -0
- package/dist/org/schema.js.map +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +4 -4
- package/dist/provider-api/actions/provider-api.d.ts +12 -12
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/docs/search.d.ts.map +1 -1
- package/dist/scripts/docs/search.js +15 -0
- package/dist/scripts/docs/search.js.map +1 -1
- package/dist/scripts/docs/source-search.d.ts +7 -0
- package/dist/scripts/docs/source-search.d.ts.map +1 -1
- package/dist/scripts/docs/source-search.js +9 -0
- package/dist/scripts/docs/source-search.js.map +1 -1
- package/dist/server/agent-chat/script-entries.d.ts.map +1 -1
- package/dist/server/agent-chat/script-entries.js +3 -0
- package/dist/server/agent-chat/script-entries.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +46 -48
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/builder-design-systems.js +1 -1
- package/dist/server/builder-design-systems.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +6 -1
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +42 -6
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +32 -0
- package/dist/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/dist/templates/chat/.agents/skills/security/SKILL.md +31 -0
- package/dist/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
- package/dist/templates/chat/_gitignore +2 -0
- package/dist/templates/default/.agents/skills/actions/SKILL.md +32 -0
- package/dist/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/dist/templates/default/.agents/skills/security/SKILL.md +31 -0
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +32 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
- package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
- package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
- package/dist/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
- package/docs/content/actions.mdx +47 -4
- package/docs/content/native-chat-ui.mdx +7 -0
- package/docs/content/organizations-teams-permissions.mdx +109 -3
- package/docs/content/template-design-collaboration-and-full-apps.mdx +15 -0
- package/docs/content/toolkit-org-team.mdx +72 -12
- package/package.json +1 -1
- package/src/a2a/artifact-response.ts +36 -29
- package/src/action.ts +83 -2
- package/src/chat-threads/store.ts +48 -43
- package/src/cli/skills-content/design-visual-edit-skill.ts +46 -3
- package/src/cli/template-sync.ts +96 -0
- package/src/client/AgentPanel.tsx +26 -6
- package/src/client/AssistantChat.tsx +63 -7
- package/src/client/DefaultSpinner.tsx +29 -0
- package/src/client/org/TeamPage.tsx +161 -6
- package/src/client/org/hooks.ts +67 -0
- package/src/client/org/index.ts +9 -0
- package/src/client/transcription/use-live-transcription.ts +62 -10
- package/src/db/client.ts +42 -3
- package/src/db/ensure-additive-columns.ts +60 -33
- package/src/deploy/build.ts +31 -2
- package/src/mcp-client/routes.ts +10 -1
- package/src/org/app-roles-handlers.ts +152 -0
- package/src/org/app-roles.ts +355 -0
- package/src/org/index.ts +27 -1
- package/src/org/migrations.ts +22 -0
- package/src/org/plugin.ts +27 -0
- package/src/org/schema.ts +15 -0
- package/src/scripts/docs/search.ts +17 -0
- package/src/scripts/docs/source-search.ts +10 -0
- package/src/server/agent-chat/script-entries.ts +3 -0
- package/src/server/agent-chat-plugin.ts +53 -52
- package/src/server/builder-design-systems.ts +1 -1
- package/src/server/core-routes-plugin.ts +6 -1
- package/src/server/framework-request-handler.ts +44 -6
- package/src/templates/chat/.agents/skills/actions/SKILL.md +32 -0
- package/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/src/templates/chat/.agents/skills/security/SKILL.md +31 -0
- package/src/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
- package/src/templates/chat/_gitignore +2 -0
- package/src/templates/default/.agents/skills/actions/SKILL.md +32 -0
- package/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/src/templates/default/.agents/skills/security/SKILL.md +31 -0
- package/src/templates/headless/.agents/skills/actions/SKILL.md +32 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
- package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
- package/src/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
- package/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/core/src/templates/chat/.agents/skills/actions/SKILL.md +0 -530
- package/corpus/core/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +0 -191
- package/corpus/core/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +0 -115
- package/corpus/core/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +0 -177
- package/corpus/core/src/templates/chat/.agents/skills/capture-learnings/SKILL.md +0 -89
- package/corpus/core/src/templates/chat/.agents/skills/create-skill/SKILL.md +0 -221
- package/corpus/core/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +0 -220
- package/corpus/core/src/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +0 -263
- package/corpus/core/src/templates/chat/.agents/skills/feature-flags/SKILL.md +0 -169
- package/corpus/core/src/templates/chat/.agents/skills/frontend-design/SKILL.md +0 -174
- package/corpus/core/src/templates/chat/.agents/skills/real-time-sync/SKILL.md +0 -232
- package/corpus/core/src/templates/chat/.agents/skills/security/SKILL.md +0 -282
- package/corpus/core/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +0 -119
- package/corpus/core/src/templates/chat/.agents/skills/shadcn-ui/SKILL.md +0 -123
- package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +0 -122
- package/corpus/core/src/templates/chat/.env.example +0 -5
- package/corpus/core/src/templates/chat/.ignore +0 -0
- package/corpus/core/src/templates/chat/.oxfmtrc.json +0 -8
- package/corpus/core/src/templates/chat/AGENTS.md +0 -77
- package/corpus/core/src/templates/chat/CHANGELOG.md +0 -10
- package/corpus/core/src/templates/chat/DEVELOPING.md +0 -185
- package/corpus/core/src/templates/chat/README.md +0 -32
- package/corpus/core/src/templates/chat/_gitignore +0 -44
- package/corpus/core/src/templates/chat/actions/hello.ts +0 -13
- package/corpus/core/src/templates/chat/actions/navigate.ts +0 -41
- package/corpus/core/src/templates/chat/actions/run.ts +0 -2
- package/corpus/core/src/templates/chat/actions/view-screen.ts +0 -31
- package/corpus/core/src/templates/chat/app/components/layout/Header.tsx +0 -60
- package/corpus/core/src/templates/chat/app/components/layout/Layout.tsx +0 -188
- package/corpus/core/src/templates/chat/app/components/layout/Sidebar.tsx +0 -505
- package/corpus/core/src/templates/chat/app/components/ui/button.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/card.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/dropdown-menu.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/input.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/label.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/sheet.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/toolkit-provider.tsx +0 -17
- package/corpus/core/src/templates/chat/app/components/ui/tooltip.tsx +0 -1
- package/corpus/core/src/templates/chat/app/design-system.ts +0 -3
- package/corpus/core/src/templates/chat/app/entry.client.tsx +0 -22
- package/corpus/core/src/templates/chat/app/entry.server.tsx +0 -10
- package/corpus/core/src/templates/chat/app/global.css +0 -93
- package/corpus/core/src/templates/chat/app/hooks/use-navigation-state.ts +0 -93
- package/corpus/core/src/templates/chat/app/i18n/ar-SA.ts +0 -68
- package/corpus/core/src/templates/chat/app/i18n/de-DE.ts +0 -71
- package/corpus/core/src/templates/chat/app/i18n/en-US.ts +0 -70
- package/corpus/core/src/templates/chat/app/i18n/es-ES.ts +0 -71
- package/corpus/core/src/templates/chat/app/i18n/fr-FR.ts +0 -71
- package/corpus/core/src/templates/chat/app/i18n/hi-IN.ts +0 -69
- package/corpus/core/src/templates/chat/app/i18n/index.ts +0 -34
- package/corpus/core/src/templates/chat/app/i18n/ja-JP.ts +0 -70
- package/corpus/core/src/templates/chat/app/i18n/ko-KR.ts +0 -70
- package/corpus/core/src/templates/chat/app/i18n/pt-BR.ts +0 -71
- package/corpus/core/src/templates/chat/app/i18n/zh-CN.ts +0 -66
- package/corpus/core/src/templates/chat/app/i18n/zh-TW.ts +0 -66
- package/corpus/core/src/templates/chat/app/i18n-data.ts +0 -556
- package/corpus/core/src/templates/chat/app/lib/agent-page.tsx +0 -49
- package/corpus/core/src/templates/chat/app/lib/app-config.ts +0 -11
- package/corpus/core/src/templates/chat/app/lib/tab-id.ts +0 -1
- package/corpus/core/src/templates/chat/app/lib/utils.ts +0 -1
- package/corpus/core/src/templates/chat/app/root.tsx +0 -173
- package/corpus/core/src/templates/chat/app/routes/_index.tsx +0 -94
- package/corpus/core/src/templates/chat/app/routes/agent.tsx +0 -24
- package/corpus/core/src/templates/chat/app/routes/chat.$threadId.tsx +0 -1
- package/corpus/core/src/templates/chat/app/routes/database.tsx +0 -17
- package/corpus/core/src/templates/chat/app/routes/extensions.$id.$slug.tsx +0 -2
- package/corpus/core/src/templates/chat/app/routes/extensions.$id.tsx +0 -11
- package/corpus/core/src/templates/chat/app/routes/extensions._index.tsx +0 -11
- package/corpus/core/src/templates/chat/app/routes/extensions.tsx +0 -5
- package/corpus/core/src/templates/chat/app/routes/observability.tsx +0 -19
- package/corpus/core/src/templates/chat/app/routes/settings.tsx +0 -89
- package/corpus/core/src/templates/chat/app/routes/team.tsx +0 -11
- package/corpus/core/src/templates/chat/app/routes.ts +0 -4
- package/corpus/core/src/templates/chat/app/vite-env.d.ts +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-27-traditional-chinese-copy-uses-taiwan-terminology.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +0 -5
- package/corpus/core/src/templates/chat/changelog/2026-07-10-chat-now-makes-ai-connection-setup-clear-without-shifting-th.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-14-chat-opens-reliably-on-hosted-deployments-instead-of-failing.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-15-chat-navigation-focuses-on-chat-and-agent.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-22-manage-agent-navigation-now-uses-the-connected-nodes-icon.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-23-full-page-chat-is-better-centered-with-quieter-chat-history-.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-24-borderless-secondary-surfaces.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-24-sidebar-footer-controls-follow-a-consistent-order.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +0 -6
- package/corpus/core/src/templates/chat/components.json +0 -20
- package/corpus/core/src/templates/chat/learnings.defaults.md +0 -5
- package/corpus/core/src/templates/chat/netlify.toml +0 -11
- package/corpus/core/src/templates/chat/package.json +0 -92
- package/corpus/core/src/templates/chat/public/agent-native-icon-dark.svg +0 -10
- package/corpus/core/src/templates/chat/public/agent-native-icon-light.svg +0 -10
- package/corpus/core/src/templates/chat/public/agent-native-logo-dark.svg +0 -21
- package/corpus/core/src/templates/chat/public/agent-native-logo-light.svg +0 -21
- package/corpus/core/src/templates/chat/public/favicon.svg +0 -1
- package/corpus/core/src/templates/chat/public/icon-180.svg +0 -1
- package/corpus/core/src/templates/chat/public/icon-192.svg +0 -1
- package/corpus/core/src/templates/chat/public/icon-512.svg +0 -1
- package/corpus/core/src/templates/chat/public/manifest.json +0 -21
- package/corpus/core/src/templates/chat/react-router.config.ts +0 -7
- package/corpus/core/src/templates/chat/server/middleware/auth.ts +0 -15
- package/corpus/core/src/templates/chat/server/plugins/agent-chat.ts +0 -21
- package/corpus/core/src/templates/chat/server/plugins/auth.ts +0 -17
- package/corpus/core/src/templates/chat/server/routes/[...page].get.ts +0 -5
- package/corpus/core/src/templates/chat/ssr-entry.ts +0 -15
- package/corpus/core/src/templates/chat/tsconfig.json +0 -21
- package/corpus/core/src/templates/chat/vite.config.ts +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-search.js","sourceRoot":"","sources":["../../../src/scripts/docs/source-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOrD,MAAM,cAAc,GAAG,SAAS,CAAC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I,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO;IACT,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,mCAAmC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;YACjE,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,CACT,SAAS,OAAO,CAAC,MAAM,6BAA6B,MAAM,CAAC,KAAK,MAAM,CACvE,CAAC;QACF,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,YAAY,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;YACvD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACtC,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;YAC9B,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACjE,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["/**\n * Core script: source-search\n *\n * Search and read the packaged Agent Native Core, Toolkit, and template corpus.\n * The corpus is generated into @agent-native/core/corpus during package build.\n *\n * Usage:\n * pnpm action source-search --query \"defineAction\"\n * pnpm action source-search --path toolkit/src/index.ts\n * pnpm action source-search --path templates/plan/AGENTS.md\n * pnpm action source-search --list\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { parseSkillFrontmatter } from \"../../server/agents-bundle.js\";\nimport { isValidPath, parseArgs } from \"../utils.js\";\n\ninterface SourceFile {\n relativePath: string;\n absolutePath: string;\n}\n\nconst MAX_FILE_BYTES = 1_000_000;\nconst MAX_READ_CHARS = 40_000;\nconst MAX_RESULTS = 20;\nconst MAX_SNIPPETS_PER_FILE = 3;\nconst TEXT_EXTENSIONS = new Set([\n \".bash\",\n \".cjs\",\n \".cts\",\n \".css\",\n \".csv\",\n \".env\",\n \".example\",\n \".html\",\n \".js\",\n \".json\",\n \".jsonc\",\n \".jsonl\",\n \".jsx\",\n \".md\",\n \".mdc\",\n \".mdx\",\n \".mjs\",\n \".mts\",\n \".plist\",\n \".rs\",\n \".sh\",\n \".sql\",\n \".svg\",\n \".toml\",\n \".ts\",\n \".tsx\",\n \".txt\",\n \".yaml\",\n \".yml\",\n \".zsh\",\n]);\n\nfunction getCorpusRoot(): string {\n // Resolve from the package root:\n // src/scripts/docs/source-search.ts -> corpus/\n // dist/scripts/docs/source-search.js -> corpus/\n return path.resolve(\n path.dirname(fileURLToPath(import.meta.url)),\n \"../../../corpus\",\n );\n}\n\nfunction isProbablyTextFile(filePath: string): boolean {\n const ext = path.extname(filePath).toLowerCase();\n if (TEXT_EXTENSIONS.has(ext)) return true;\n const base = path.basename(filePath);\n return (\n base === \".dockerignore\" ||\n base === \".gitignore\" ||\n base === \".ignore\" ||\n base === \".npmignore\" ||\n base === \".npmrc\" ||\n base === \".oxfmtrc\" ||\n base === \".oxfmtrc.json\" ||\n base === \".prettierignore\" ||\n base === \".prettierrc\" ||\n base === \".taurignore\" ||\n base === \"AGENTS.md\" ||\n base === \"DEVELOPING.md\" ||\n base === \"README.md\" ||\n base === \"_gitignore\" ||\n base === \"_redirects\" ||\n base === \"package.json\" ||\n base.startsWith(\".env.example\") ||\n base.startsWith(\".oxfmt\") ||\n base.startsWith(\".prettier\")\n );\n}\n\nfunction toCorpusRelativePath(\n corpusRoot: string,\n absolutePath: string,\n): string {\n return path.relative(corpusRoot, absolutePath).split(path.sep).join(\"/\");\n}\n\nfunction getSkillRootRelativePath(relativePath: string): string | null {\n const segments = relativePath.split(\"/\").filter(Boolean);\n for (let index = 0; index < segments.length - 2; index += 1) {\n if (\n (segments[index] === \".agents\" || segments[index] === \".agent\") &&\n segments[index + 1] === \"skills\"\n ) {\n return segments.slice(0, index + 3).join(\"/\");\n }\n }\n return null;\n}\n\nfunction getSkillEntryRelativePath(skillRootRelativePath: string): string {\n return skillRootRelativePath.toLowerCase().endsWith(\".md\")\n ? skillRootRelativePath\n : `${skillRootRelativePath}/SKILL.md`;\n}\n\nfunction isRuntimeVisibleCorpusPath(\n corpusRoot: string,\n absolutePath: string,\n): boolean {\n const relativePath = toCorpusRelativePath(corpusRoot, absolutePath);\n const skillRootRelativePath = getSkillRootRelativePath(relativePath);\n if (!skillRootRelativePath) return true;\n\n const skillEntryPath = path.join(\n corpusRoot,\n ...getSkillEntryRelativePath(skillRootRelativePath).split(\"/\"),\n );\n if (!fs.existsSync(skillEntryPath)) return true;\n\n try {\n const raw = fs.readFileSync(skillEntryPath, \"utf-8\");\n return parseSkillFrontmatter(raw).scope !== \"dev\";\n } catch {\n return true;\n }\n}\n\nfunction listFiles(\n dir: string,\n base = dir,\n corpusRoot = getCorpusRoot(),\n): SourceFile[] {\n if (!fs.existsSync(dir)) return [];\n const files: SourceFile[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const abs = path.join(dir, entry.name);\n if (!isRuntimeVisibleCorpusPath(corpusRoot, abs)) continue;\n if (entry.isDirectory()) {\n files.push(...listFiles(abs, base, corpusRoot));\n } else if (entry.isFile() && isProbablyTextFile(abs)) {\n const stat = fs.statSync(abs);\n if (stat.size <= MAX_FILE_BYTES) {\n files.push({\n absolutePath: abs,\n relativePath: path.relative(base, abs).split(path.sep).join(\"/\"),\n });\n }\n }\n }\n return files.sort((a, b) => a.relativePath.localeCompare(b.relativePath));\n}\n\nfunction lineSnippet(line: string, terms: string[]): string {\n const trimmed = line.trim();\n if (trimmed.length <= 220) return trimmed;\n const lower = trimmed.toLowerCase();\n const hit = terms\n .map((term) => lower.indexOf(term))\n .filter((index) => index >= 0)\n .sort((a, b) => a - b)[0];\n const start = Math.max(0, (hit ?? 0) - 80);\n const end = Math.min(trimmed.length, start + 220);\n return `${start > 0 ? \"...\" : \"\"}${trimmed.slice(start, end)}${\n end < trimmed.length ? \"...\" : \"\"\n }`;\n}\n\nfunction searchCorpus(query: string): Array<{\n file: string;\n score: number;\n snippets: string[];\n}> {\n const corpusRoot = getCorpusRoot();\n const terms = query\n .toLowerCase()\n .split(/\\s+/)\n .map((term) => term.trim())\n .filter(Boolean);\n if (terms.length === 0) return [];\n\n const results: Array<{ file: string; score: number; snippets: string[] }> =\n [];\n for (const file of listFiles(corpusRoot)) {\n let raw = \"\";\n try {\n raw = fs.readFileSync(file.absolutePath, \"utf-8\");\n } catch {\n continue;\n }\n const lowerPath = file.relativePath.toLowerCase();\n const lowerRaw = raw.toLowerCase();\n let score = 0;\n for (const term of terms) {\n if (lowerPath.includes(term)) score += 8;\n const occurrences = lowerRaw.split(term).length - 1;\n score += Math.min(occurrences, 10);\n }\n if (score <= 0) continue;\n\n const snippets: string[] = [];\n const lines = raw.split(/\\r?\\n/);\n for (let index = 0; index < lines.length; index += 1) {\n const lowerLine = lines[index].toLowerCase();\n if (!terms.some((term) => lowerLine.includes(term))) continue;\n snippets.push(`${index + 1}: ${lineSnippet(lines[index], terms)}`);\n if (snippets.length >= MAX_SNIPPETS_PER_FILE) break;\n }\n\n results.push({ file: file.relativePath, score, snippets });\n }\n\n return results.sort(\n (a, b) => b.score - a.score || a.file.localeCompare(b.file),\n );\n}\n\nfunction readCorpusPath(relative: string): string {\n if (!isValidPath(relative)) {\n return `Invalid corpus path: ${relative}`;\n }\n const corpusRoot = getCorpusRoot();\n const target = path.resolve(corpusRoot, relative);\n if (!target.startsWith(corpusRoot + path.sep) && target !== corpusRoot) {\n return `Invalid corpus path: ${relative}`;\n }\n if (!fs.existsSync(target)) {\n return `Corpus path not found: ${relative}`;\n }\n if (!isRuntimeVisibleCorpusPath(corpusRoot, target)) {\n return `Corpus path is not available to runtime source-search: ${relative}`;\n }\n\n const stat = fs.statSync(target);\n if (stat.isDirectory()) {\n const entries = fs\n .readdirSync(target, { withFileTypes: true })\n .filter((entry) =>\n isRuntimeVisibleCorpusPath(corpusRoot, path.join(target, entry.name)),\n )\n .map((entry) => `${entry.isDirectory() ? \"dir \" : \"file\"} ${entry.name}`)\n .sort();\n const shown = entries.slice(0, 200);\n return [\n `# ${relative || \".\"}`,\n \"\",\n ...shown,\n entries.length > shown.length\n ? `... ${entries.length - shown.length} more entries`\n : \"\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n }\n\n if (!stat.isFile()) return `Unsupported corpus path: ${relative}`;\n if (!isProbablyTextFile(target)) return `Not a text corpus file: ${relative}`;\n if (stat.size > MAX_FILE_BYTES) {\n return `Corpus file is too large to read through source-search: ${relative}`;\n }\n\n const raw = fs.readFileSync(target, \"utf-8\");\n if (raw.length <= MAX_READ_CHARS) return raw;\n return `${raw.slice(0, MAX_READ_CHARS)}\\n\\n... truncated at ${MAX_READ_CHARS} characters. Use a narrower path or direct rg for more context.`;\n}\n\nfunction listCorpus(): unknown {\n const corpusRoot = getCorpusRoot();\n const sections = [\"core\", \"templates\"];\n return sections.map((section) => {\n const sectionRoot = path.join(corpusRoot, section);\n const files = listFiles(sectionRoot);\n const children = fs.existsSync(sectionRoot)\n ? fs\n .readdirSync(sectionRoot, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort()\n : [];\n return {\n section,\n path: section,\n files: files.length,\n directories: children,\n };\n });\n}\n\nexport default async function sourceSearchScript(\n args: string[],\n): Promise<void> {\n const parsed = parseArgs(args);\n const corpusRoot = getCorpusRoot();\n\n if (parsed.help === \"true\") {\n console.log(`Usage: pnpm action source-search [options]\n\nOptions:\n --query <text> Search source corpus by keyword\n --path <path> Read a corpus file or list a corpus directory\n --list List corpus sections\n --help Show this help message`);\n return;\n }\n\n if (!fs.existsSync(corpusRoot)) {\n console.log(\n `Source corpus not found at ${corpusRoot}. Build or reinstall @agent-native/core so node_modules/@agent-native/core/corpus exists.`,\n );\n return;\n }\n\n if (parsed.list === \"true\") {\n console.log(JSON.stringify(listCorpus(), null, 2));\n return;\n }\n\n if (parsed.path) {\n console.log(readCorpusPath(parsed.path));\n return;\n }\n\n if (parsed.query) {\n const results = searchCorpus(parsed.query);\n if (results.length === 0) {\n console.log(`No source files found matching \"${parsed.query}\".`);\n return;\n }\n console.log(\n `Found ${results.length} source file(s) matching \"${parsed.query}\":\\n`,\n );\n for (const result of results.slice(0, MAX_RESULTS)) {\n console.log(`${result.file} (score ${result.score})`);\n for (const snippet of result.snippets) {\n console.log(` ${snippet}`);\n }\n console.log(\"\");\n }\n console.log(\"Use --path <file> to read a specific corpus file.\");\n return;\n }\n\n console.log(\"Provide --query, --path, or --list. Use --help for details.\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"source-search.js","sourceRoot":"","sources":["../../../src/scripts/docs/source-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOrD,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,OAAO;IACP,MAAM;IACN,MAAM;I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,CAAC,CAAC;QACzC,OAAO;IACT,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,mCAAmC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;YACjE,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,CACT,SAAS,OAAO,CAAC,MAAM,6BAA6B,MAAM,CAAC,KAAK,MAAM,CACvE,CAAC;QACF,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,YAAY,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;YACvD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACtC,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;YAC9B,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACjE,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["/**\n * Core script: source-search\n *\n * Search and read the packaged Agent Native Core, Toolkit, and template corpus.\n * The corpus is generated into @agent-native/core/corpus during package build.\n *\n * Usage:\n * pnpm action source-search --query \"defineAction\"\n * pnpm action source-search --path toolkit/src/index.ts\n * pnpm action source-search --path templates/plan/AGENTS.md\n * pnpm action source-search --list\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { parseSkillFrontmatter } from \"../../server/agents-bundle.js\";\nimport { isValidPath, parseArgs } from \"../utils.js\";\n\ninterface SourceFile {\n relativePath: string;\n absolutePath: string;\n}\n\nconst MAX_FILE_BYTES = 1_000_000;\nconst MAX_READ_CHARS = 40_000;\nconst MAX_RESULTS = 20;\nconst MAX_SNIPPETS_PER_FILE = 3;\nconst TEXT_EXTENSIONS = new Set([\n \".bash\",\n \".cjs\",\n \".cts\",\n \".css\",\n \".csv\",\n \".env\",\n \".example\",\n \".html\",\n \".js\",\n \".json\",\n \".jsonc\",\n \".jsonl\",\n \".jsx\",\n \".md\",\n \".mdc\",\n \".mdx\",\n \".mjs\",\n \".mts\",\n \".plist\",\n \".rs\",\n \".sh\",\n \".sql\",\n \".svg\",\n \".toml\",\n \".ts\",\n \".tsx\",\n \".txt\",\n \".yaml\",\n \".yml\",\n \".zsh\",\n]);\n\nfunction getCorpusRoot(): string {\n // Resolve from the package root:\n // src/scripts/docs/source-search.ts -> corpus/\n // dist/scripts/docs/source-search.js -> corpus/\n return path.resolve(\n path.dirname(fileURLToPath(import.meta.url)),\n \"../../../corpus\",\n );\n}\n\n/**\n * The corpus is a sibling of the package root, so a bundled serverless deploy\n * never carries it. Callers register this tool conditionally: advertising a\n * search tool whose only possible answer is \"not found\" costs the agent a turn\n * and reads to it like the code genuinely does not exist.\n */\nexport function hasSourceCorpus(): boolean {\n return fs.existsSync(getCorpusRoot());\n}\n\nfunction isProbablyTextFile(filePath: string): boolean {\n const ext = path.extname(filePath).toLowerCase();\n if (TEXT_EXTENSIONS.has(ext)) return true;\n const base = path.basename(filePath);\n return (\n base === \".dockerignore\" ||\n base === \".gitignore\" ||\n base === \".ignore\" ||\n base === \".npmignore\" ||\n base === \".npmrc\" ||\n base === \".oxfmtrc\" ||\n base === \".oxfmtrc.json\" ||\n base === \".prettierignore\" ||\n base === \".prettierrc\" ||\n base === \".taurignore\" ||\n base === \"AGENTS.md\" ||\n base === \"DEVELOPING.md\" ||\n base === \"README.md\" ||\n base === \"_gitignore\" ||\n base === \"_redirects\" ||\n base === \"package.json\" ||\n base.startsWith(\".env.example\") ||\n base.startsWith(\".oxfmt\") ||\n base.startsWith(\".prettier\")\n );\n}\n\nfunction toCorpusRelativePath(\n corpusRoot: string,\n absolutePath: string,\n): string {\n return path.relative(corpusRoot, absolutePath).split(path.sep).join(\"/\");\n}\n\nfunction getSkillRootRelativePath(relativePath: string): string | null {\n const segments = relativePath.split(\"/\").filter(Boolean);\n for (let index = 0; index < segments.length - 2; index += 1) {\n if (\n (segments[index] === \".agents\" || segments[index] === \".agent\") &&\n segments[index + 1] === \"skills\"\n ) {\n return segments.slice(0, index + 3).join(\"/\");\n }\n }\n return null;\n}\n\nfunction getSkillEntryRelativePath(skillRootRelativePath: string): string {\n return skillRootRelativePath.toLowerCase().endsWith(\".md\")\n ? skillRootRelativePath\n : `${skillRootRelativePath}/SKILL.md`;\n}\n\nfunction isRuntimeVisibleCorpusPath(\n corpusRoot: string,\n absolutePath: string,\n): boolean {\n const relativePath = toCorpusRelativePath(corpusRoot, absolutePath);\n const skillRootRelativePath = getSkillRootRelativePath(relativePath);\n if (!skillRootRelativePath) return true;\n\n const skillEntryPath = path.join(\n corpusRoot,\n ...getSkillEntryRelativePath(skillRootRelativePath).split(\"/\"),\n );\n if (!fs.existsSync(skillEntryPath)) return true;\n\n try {\n const raw = fs.readFileSync(skillEntryPath, \"utf-8\");\n return parseSkillFrontmatter(raw).scope !== \"dev\";\n } catch {\n return true;\n }\n}\n\nfunction listFiles(\n dir: string,\n base = dir,\n corpusRoot = getCorpusRoot(),\n): SourceFile[] {\n if (!fs.existsSync(dir)) return [];\n const files: SourceFile[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const abs = path.join(dir, entry.name);\n if (!isRuntimeVisibleCorpusPath(corpusRoot, abs)) continue;\n if (entry.isDirectory()) {\n files.push(...listFiles(abs, base, corpusRoot));\n } else if (entry.isFile() && isProbablyTextFile(abs)) {\n const stat = fs.statSync(abs);\n if (stat.size <= MAX_FILE_BYTES) {\n files.push({\n absolutePath: abs,\n relativePath: path.relative(base, abs).split(path.sep).join(\"/\"),\n });\n }\n }\n }\n return files.sort((a, b) => a.relativePath.localeCompare(b.relativePath));\n}\n\nfunction lineSnippet(line: string, terms: string[]): string {\n const trimmed = line.trim();\n if (trimmed.length <= 220) return trimmed;\n const lower = trimmed.toLowerCase();\n const hit = terms\n .map((term) => lower.indexOf(term))\n .filter((index) => index >= 0)\n .sort((a, b) => a - b)[0];\n const start = Math.max(0, (hit ?? 0) - 80);\n const end = Math.min(trimmed.length, start + 220);\n return `${start > 0 ? \"...\" : \"\"}${trimmed.slice(start, end)}${\n end < trimmed.length ? \"...\" : \"\"\n }`;\n}\n\nfunction searchCorpus(query: string): Array<{\n file: string;\n score: number;\n snippets: string[];\n}> {\n const corpusRoot = getCorpusRoot();\n const terms = query\n .toLowerCase()\n .split(/\\s+/)\n .map((term) => term.trim())\n .filter(Boolean);\n if (terms.length === 0) return [];\n\n const results: Array<{ file: string; score: number; snippets: string[] }> =\n [];\n for (const file of listFiles(corpusRoot)) {\n let raw = \"\";\n try {\n raw = fs.readFileSync(file.absolutePath, \"utf-8\");\n } catch {\n continue;\n }\n const lowerPath = file.relativePath.toLowerCase();\n const lowerRaw = raw.toLowerCase();\n let score = 0;\n for (const term of terms) {\n if (lowerPath.includes(term)) score += 8;\n const occurrences = lowerRaw.split(term).length - 1;\n score += Math.min(occurrences, 10);\n }\n if (score <= 0) continue;\n\n const snippets: string[] = [];\n const lines = raw.split(/\\r?\\n/);\n for (let index = 0; index < lines.length; index += 1) {\n const lowerLine = lines[index].toLowerCase();\n if (!terms.some((term) => lowerLine.includes(term))) continue;\n snippets.push(`${index + 1}: ${lineSnippet(lines[index], terms)}`);\n if (snippets.length >= MAX_SNIPPETS_PER_FILE) break;\n }\n\n results.push({ file: file.relativePath, score, snippets });\n }\n\n return results.sort(\n (a, b) => b.score - a.score || a.file.localeCompare(b.file),\n );\n}\n\nfunction readCorpusPath(relative: string): string {\n if (!isValidPath(relative)) {\n return `Invalid corpus path: ${relative}`;\n }\n const corpusRoot = getCorpusRoot();\n const target = path.resolve(corpusRoot, relative);\n if (!target.startsWith(corpusRoot + path.sep) && target !== corpusRoot) {\n return `Invalid corpus path: ${relative}`;\n }\n if (!fs.existsSync(target)) {\n return `Corpus path not found: ${relative}`;\n }\n if (!isRuntimeVisibleCorpusPath(corpusRoot, target)) {\n return `Corpus path is not available to runtime source-search: ${relative}`;\n }\n\n const stat = fs.statSync(target);\n if (stat.isDirectory()) {\n const entries = fs\n .readdirSync(target, { withFileTypes: true })\n .filter((entry) =>\n isRuntimeVisibleCorpusPath(corpusRoot, path.join(target, entry.name)),\n )\n .map((entry) => `${entry.isDirectory() ? \"dir \" : \"file\"} ${entry.name}`)\n .sort();\n const shown = entries.slice(0, 200);\n return [\n `# ${relative || \".\"}`,\n \"\",\n ...shown,\n entries.length > shown.length\n ? `... ${entries.length - shown.length} more entries`\n : \"\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n }\n\n if (!stat.isFile()) return `Unsupported corpus path: ${relative}`;\n if (!isProbablyTextFile(target)) return `Not a text corpus file: ${relative}`;\n if (stat.size > MAX_FILE_BYTES) {\n return `Corpus file is too large to read through source-search: ${relative}`;\n }\n\n const raw = fs.readFileSync(target, \"utf-8\");\n if (raw.length <= MAX_READ_CHARS) return raw;\n return `${raw.slice(0, MAX_READ_CHARS)}\\n\\n... truncated at ${MAX_READ_CHARS} characters. Use a narrower path or direct rg for more context.`;\n}\n\nfunction listCorpus(): unknown {\n const corpusRoot = getCorpusRoot();\n const sections = [\"core\", \"templates\"];\n return sections.map((section) => {\n const sectionRoot = path.join(corpusRoot, section);\n const files = listFiles(sectionRoot);\n const children = fs.existsSync(sectionRoot)\n ? fs\n .readdirSync(sectionRoot, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort()\n : [];\n return {\n section,\n path: section,\n files: files.length,\n directories: children,\n };\n });\n}\n\nexport default async function sourceSearchScript(\n args: string[],\n): Promise<void> {\n const parsed = parseArgs(args);\n const corpusRoot = getCorpusRoot();\n\n if (parsed.help === \"true\") {\n console.log(`Usage: pnpm action source-search [options]\n\nOptions:\n --query <text> Search source corpus by keyword\n --path <path> Read a corpus file or list a corpus directory\n --list List corpus sections\n --help Show this help message`);\n return;\n }\n\n if (!fs.existsSync(corpusRoot)) {\n console.log(\n `Source corpus not found at ${corpusRoot}. Build or reinstall @agent-native/core so node_modules/@agent-native/core/corpus exists.`,\n );\n return;\n }\n\n if (parsed.list === \"true\") {\n console.log(JSON.stringify(listCorpus(), null, 2));\n return;\n }\n\n if (parsed.path) {\n console.log(readCorpusPath(parsed.path));\n return;\n }\n\n if (parsed.query) {\n const results = searchCorpus(parsed.query);\n if (results.length === 0) {\n console.log(`No source files found matching \"${parsed.query}\".`);\n return;\n }\n console.log(\n `Found ${results.length} source file(s) matching \"${parsed.query}\":\\n`,\n );\n for (const result of results.slice(0, MAX_RESULTS)) {\n console.log(`${result.file} (score ${result.score})`);\n for (const snippet of result.snippets) {\n console.log(` ${snippet}`);\n }\n console.log(\"\");\n }\n console.log(\"Use --path <file> to read a specific corpus file.\");\n return;\n }\n\n console.log(\"Provide --query, --path, or --list. Use --help for details.\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-entries.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/script-entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAQnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAyDvE;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,GAAE,iBAA0B,EAChC,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,GACzC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAkJtC;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CACtD,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAC5B,
|
|
1
|
+
{"version":3,"file":"script-entries.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/script-entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAQnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAyDvE;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,GAAE,iBAA0B,EAChC,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,GACzC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAkJtC;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CACtD,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAC5B,CA2EA;AAED;;GAEG;AACH,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAW3E;AAED,wBAAsB,2BAA2B,IAAI,OAAO,CAC1D,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAC5B,CAuPA;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CACtD,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAC5B,CAqJA;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAqBtC;AAED;;;GAGG;AACH,wBAAsB,oCAAoC,IAAI,OAAO,CACnE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAC5B,CAUA;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAwBtC"}
|
|
@@ -203,6 +203,9 @@ export async function createDocsScriptEntries() {
|
|
|
203
203
|
}
|
|
204
204
|
try {
|
|
205
205
|
const mod = await import("../../scripts/docs/source-search.js");
|
|
206
|
+
if (!mod.hasSourceCorpus()) {
|
|
207
|
+
return entries;
|
|
208
|
+
}
|
|
206
209
|
entries["source-search"] = wrapCliScript({
|
|
207
210
|
description: "Search and read the packaged Agent Native source corpus under node_modules/@agent-native/core/corpus. Use --list for sections, --query to search core/template source, and --path to read a file.",
|
|
208
211
|
parameters: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-entries.js","sourceRoot":"","sources":["../../../src/server/agent-chat/script-entries.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,8EAA8E;AAC9E,qEAAqE;AACrE,0EAA0E;AAC1E,2EAA2E;AAC3E,sEAAsE;AACtE,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAS,aAAa,CACpB,IAAgB,EAChB,UAA6C,EAC7C,IAGC;IAED,OAAO;QACL,IAAI;QACJ,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,EAAE,KAAK,EAAE,IAA4B,EAAmB,EAAE;YAC3D,MAAM,OAAO,GAAa,EAAE,CAAC;YAC7B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1C,kEAAkE;gBAClE,uE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C;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,4DAA4D;IAC9D,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,0CAA0C,CAAC,CAAC;QACrE,OAAO,CAAC,yBAAyB,CAAC,GAAG;YACnC,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC;SAC1D,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,4DAA4D;IAC9D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { ActionTool } from \"../../agent/types.js\";\nimport {\n renameThread,\n resolveThreadAccess,\n setThreadArchived,\n setThreadPinned,\n} from \"../../chat-threads/store.js\";\nimport type { DatabaseToolsMode } from \"../../scripts/db/tool-mode.js\";\nimport { dbExecToolParameters } from \"../../scripts/db/tool-schemas.js\";\nimport { captureCliOutput } from \"../cli-capture.js\";\nimport {\n getAmbientUserEmail,\n getRequestOrgId,\n getRequestRunContext,\n getRequestUserEmail,\n} from \"../request-context.js\";\n\n// ---------------------------------------------------------------------------\n// CLI-script-backed action entries: db-*, docs-search/source-search,\n// resources/save-memory/delete-memory, chat-history, manage-agent-engine,\n// manage-agent-loop-settings, and call-agent. Each wraps a core CLI script\n// (that writes to console.log) as an ActionEntry via `wrapCliScript`.\n// ---------------------------------------------------------------------------\n\n/**\n * Wraps a core CLI script (that writes to console.log) as a ActionEntry\n * by capturing stdout. Uses an AsyncLocalStorage-backed capture so\n * concurrent tool calls do not corrupt the global console/stdout pointers\n * (see `cli-capture.ts`).\n */\nfunction wrapCliScript(\n tool: ActionTool,\n cliDefault: (args: string[]) => Promise<void>,\n opts?: {\n allowedArgs?: readonly string[];\n readOnly?: boolean;\n },\n): ActionEntry {\n return {\n tool,\n ...(opts?.readOnly ? { readOnly: true as const } : {}),\n run: async (args: Record<string, string>): Promise<string> => {\n const cliArgs: string[] = [];\n for (const [k, v] of Object.entries(args)) {\n // MCP input schemas are descriptive and some hosts can still send\n // undeclared keys. The externally exposed DB readers must never accept\n // the CLI-only `--db` escape hatch, which could point at another local\n // SQLite file. Keep their runtime surface identical to the advertised\n // schema instead of trusting the client to validate it.\n if (opts?.allowedArgs && !opts.allowedArgs.includes(k)) {\n throw new Error(`Unknown argument: ${k}`);\n }\n const raw = v as unknown;\n const value =\n raw != null && typeof raw === \"object\"\n ? JSON.stringify(raw)\n : String(raw);\n cliArgs.push(`--${k}`, value);\n }\n return captureCliOutput(() => cliDefault(cliArgs));\n },\n };\n}\n\n/**\n * Creates db-* tools (db-query, db-exec, db-patch, db-schema) as native tools.\n * By default these let the agent inspect the app's own SQL database; raw SQL\n * writes are only exposed when the app explicitly opts into write mode.\n * Scoping to the current user/org is enforced automatically in production via\n * temp views.\n *\n * In dev mode template actions are invoked via bash and the agent can call\n * `pnpm action db-query ...` — but in production there is no bash, so these\n * must be registered as native tools for the agent to reach the app DB at all.\n */\nexport async function createDbScriptEntries(\n mode: DatabaseToolsMode = \"read\",\n options: { extensionTools?: boolean } = {},\n): Promise<Record<string, ActionEntry>> {\n try {\n if (mode === \"off\") return {};\n const extensionQueryGuidance =\n options.extensionTools === false\n ? \"Extension management tools are disabled for this app; do not query or mutate the legacy tools table as a workaround.\"\n : \"For extension management, use list-extensions, update-extension, hide-extension, or delete-extension instead of querying the legacy tools table.\";\n const [schemaMod, queryMod] = await Promise.all([\n import(\"../../scripts/db/schema.js\"),\n import(\"../../scripts/db/query.js\"),\n ]);\n const [execMod, patchMod] =\n mode === \"write\"\n ? await Promise.all([\n import(\"../../scripts/db/exec.js\"),\n import(\"../../scripts/db/patch.js\"),\n ])\n : [null, null];\n\n const entries: Record<string, ActionEntry> = {\n \"db-schema\": wrapCliScript(\n {\n description:\n \"Show the app's SQL schema — all tables, columns, types, indexes, and foreign keys. Use this to understand the data model before querying.\",\n parameters: {\n type: \"object\",\n properties: {\n format: {\n type: \"string\",\n description: 'Output format: \"json\" or \"text\" (default: text)',\n enum: [\"json\", \"text\"],\n },\n },\n },\n },\n schemaMod.default,\n {\n allowedArgs: [\"format\"],\n readOnly: true,\n },\n ),\n \"db-query\": wrapCliScript(\n {\n description: `Read from the app's own SQL database ONLY. Runs a SELECT against the app's internal tables (settings, application_state, template tables). Results are auto-scoped to the current user/org. IMPORTANT: This tool CANNOT access external data sources like data warehouses, CRMs, issue trackers, analytics platforms, calendars, mail, docs, or other third-party services. For those, use the relevant template/provider action, MCP connector, or provider-api-catalog/provider-api-docs/provider-api-request when available. If the user names a provider, that named provider wins; do not substitute a warehouse or app database copy unless they explicitly ask for it. If a table isn't in the app schema, don't try db-query — use the data-source-specific action. ${extensionQueryGuidance}`,\n parameters: {\n type: \"object\",\n properties: {\n sql: {\n type: \"string\",\n description:\n \"SELECT query to run, e.g. \\\"SELECT key, value FROM settings WHERE key LIKE 'sql-dashboard-%'\\\"\",\n },\n args: {\n type: \"string\",\n description:\n 'Optional JSON array of positional bind args for parameterized placeholders. Example: \\'[\"draft\",\"form-123\"]\\'',\n },\n format: {\n type: \"string\",\n description: 'Output format: \"json\" or \"text\" (default: text)',\n enum: [\"json\", \"text\"],\n },\n limit: {\n type: \"string\",\n description:\n \"Append LIMIT N if the query doesn't already have one\",\n },\n },\n required: [\"sql\"],\n },\n },\n queryMod.default,\n {\n allowedArgs: [\"sql\", \"args\", \"format\", \"limit\"],\n readOnly: true,\n },\n ),\n };\n\n if (execMod && patchMod) {\n entries[\"db-exec\"] = wrapCliScript(\n {\n description:\n \"Write to the app's own SQL database ONLY. Runs INSERT / UPDATE / DELETE / REPLACE against the app's internal tables. For multiple related writes, pass `statements` so they run sequentially in one transaction instead of issuing several db-exec calls. Writes are auto-scoped to the current user/org, and `owner_email` / `org_id` are auto-injected on INSERT. Schema changes (CREATE/ALTER/DROP) are blocked. Never use this to backfill missing data for a read/analysis request or to create/modify users, members, roles, permissions, admin flags, or ownership; use a dedicated app action or reviewed code. IMPORTANT: This tool CANNOT write to external data sources like BigQuery, HubSpot, etc. For external services, use the appropriate template action.\",\n parameters: dbExecToolParameters(),\n },\n execMod.default,\n );\n entries[\"db-patch\"] = wrapCliScript(\n {\n description:\n \"Surgical patch on a large text/JSON column in the app's SQL database. Two modes: (1) text find/replace via `find`/`replace`/`edits` — best for small edits to documents, slide HTML, etc. (2) structural JSON ops via `json-ops` — STRONGLY PREFERRED when the column is JSON (dashboard configs, form schemas, slide decks) because it avoids all the brace/quote/comma surgery that text find/replace requires. Use `json-ops` to set/remove values at a JSON Pointer path, or to move/insert array items — e.g. reorder dashboard panels, add a filter, rename a field. Targets exactly one row (narrow `where` by primary key). Same per-user/org scoping as db-exec.\",\n parameters: {\n type: \"object\",\n properties: {\n table: {\n type: \"string\",\n description: \"Table name (e.g. 'settings')\",\n },\n column: {\n type: \"string\",\n description:\n \"Text/JSON column to patch (e.g. 'value' for settings)\",\n },\n where: {\n type: \"string\",\n description:\n \"WHERE clause that matches exactly one row (e.g. \\\"key = 'o:org1:sql-dashboard-foo'\\\")\",\n },\n find: {\n type: \"string\",\n description:\n \"Text mode: substring to find. Must match EXACTLY ONE occurrence by default (like Claude Code's Edit tool). If 0 matches, you get 'NOT FOUND'. If >1 matches, you get surrounding context for each match — widen `find` with unique context and retry. Use `all: \\\"true\\\"` to replace every occurrence.\",\n },\n replace: {\n type: \"string\",\n description: \"Text mode: replacement substring\",\n },\n edits: {\n type: \"string\",\n description:\n 'Text mode batch: JSON array of {find, replace} pairs. Same uniqueness rule applies to each `find`. Example: \\'[{\"find\":\"a\",\"replace\":\"b\"}]\\'',\n },\n \"json-ops\": {\n type: \"string\",\n description:\n 'JSON mode: JSON array of structural ops. Each op is {op, path, value?, from?}. `op` is one of \"set\", \"remove\", \"insert\", \"move\", \"move-before\". `path` / `from` use JSON Pointer (\"/panels/3/title\"). Examples — reorder: \\'[{\"op\":\"move\",\"from\":\"/panels/7\",\"path\":\"/panels/1\"}]\\'; edit field: \\'[{\"op\":\"set\",\"path\":\"/panels/0/title\",\"value\":\"New\"}]\\'; delete filter: \\'[{\"op\":\"remove\",\"path\":\"/filters/2\"}]\\'; add panel: \\'[{\"op\":\"insert\",\"path\":\"/panels/0\",\"value\":{\"id\":\"p\",\"title\":\"...\"}}]\\'. Much safer than text find/replace for JSON columns.',\n },\n all: {\n type: \"string\",\n description:\n 'Text mode: set to \"true\" to replace every occurrence of each `find` (default requires exactly one match)',\n enum: [\"true\"],\n },\n },\n required: [\"table\", \"column\", \"where\"],\n },\n },\n patchMod.default,\n );\n }\n\n return entries;\n } catch {\n return {};\n }\n}\n\n/**\n * Creates read-only package lookup tools so agents can inspect version-matched\n * framework docs and source bundled in @agent-native/core at runtime.\n */\nexport async function createDocsScriptEntries(): Promise<\n Record<string, ActionEntry>\n> {\n const entries: Record<string, ActionEntry> = {};\n\n try {\n const mod = await import(\"../../scripts/docs/search.js\");\n entries[\"docs-search\"] = wrapCliScript(\n {\n description:\n \"Search and read agent-native framework documentation, bundled AGENTS.md, and codebase skills. Use --list to see all pages, --query to search, --slug to read a specific page. Codebase skill pages use slugs like skill-<name>.\",\n parameters: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"Search term to find relevant docs (e.g. 'actions', 'authentication', 'database')\",\n },\n slug: {\n type: \"string\",\n description:\n \"Read a specific doc page by slug (e.g. 'actions', 'authentication', 'database')\",\n },\n list: {\n type: \"string\",\n description: 'Set to \"true\" to list all available doc pages',\n enum: [\"true\"],\n },\n },\n },\n },\n mod.default,\n { readOnly: true },\n );\n } catch {\n // Keep source-search available if docs-search fails during a partial build.\n }\n\n try {\n const mod = await import(\"../../scripts/docs/source-search.js\");\n entries[\"source-search\"] = wrapCliScript(\n {\n description:\n \"Search and read the packaged Agent Native source corpus under node_modules/@agent-native/core/corpus. Use --list for sections, --query to search core/template source, and --path to read a file.\",\n parameters: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"Search term to find relevant core or template source (e.g. 'defineAction', 'useActionQuery', 'view-screen').\",\n },\n path: {\n type: \"string\",\n description:\n \"Read a specific corpus file or list a directory (e.g. 'templates/plan/AGENTS.md' or 'core/src/action.ts').\",\n },\n list: {\n type: \"string\",\n description: 'Set to \"true\" to list corpus sections',\n enum: [\"true\"],\n },\n },\n },\n },\n mod.default,\n { readOnly: true },\n );\n } catch {\n // Older package installs may not have the corpus/search script yet.\n }\n\n return entries;\n}\n\n/**\n * Creates resource ScriptEntries available in both prod and dev modes.\n */\nexport function shouldDefaultResourceWriteToWorkspace(path: string): boolean {\n const normalized = path.replace(/^\\/+/, \"\");\n return (\n normalized === \"AGENTS.md\" ||\n normalized === \"LEARNINGS.md\" ||\n normalized.startsWith(\"memory/\") ||\n normalized.startsWith(\"skills/\") ||\n normalized.startsWith(\"jobs/\") ||\n normalized.startsWith(\"agents/\") ||\n normalized.startsWith(\"remote-agents/\")\n );\n}\n\nexport async function createResourceScriptEntries(): Promise<\n Record<string, ActionEntry>\n> {\n try {\n const [list, read, effective, write, del, saveMem, delMem, store] =\n await Promise.all([\n import(\"../../scripts/resources/list.js\"),\n import(\"../../scripts/resources/read.js\"),\n import(\"../../scripts/resources/effective.js\"),\n import(\"../../scripts/resources/write.js\"),\n import(\"../../scripts/resources/delete.js\"),\n import(\"../../scripts/resources/save-memory.js\"),\n import(\"../../scripts/resources/delete-memory.js\"),\n import(\"../../resources/store.js\"),\n ]);\n\n // Wrap each CLI runner so it captures stdout and converts args properly\n const listEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n list.default,\n { readOnly: true },\n );\n const readEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n read.default,\n { readOnly: true },\n );\n const writeEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n write.default,\n );\n const effectiveEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n effective.default,\n { readOnly: true },\n );\n const deleteEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n del.default,\n );\n\n return {\n resources: {\n tool: {\n description:\n 'Manage workspace resources. Actions: \"list\" (browse visible files), \"read\" (get contents), \"effective\" (show workspace -> organization/app -> personal inheritance for a path), \"write\" (create/update personal or shared; workspace only for local file mode control files), \"promote\" (make agent scratch visible), \"delete\" (remove personal or shared; workspace only for local file mode control files). Agent scratch writes are hidden from the Workspace view by default; use visibility=\"workspace\" only for files the user explicitly wants to keep/manage.',\n parameters: {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n description: \"The operation to perform\",\n enum: [\n \"list\",\n \"read\",\n \"effective\",\n \"write\",\n \"promote\",\n \"delete\",\n ],\n },\n path: {\n type: \"string\",\n description:\n \"Resource path (e.g. 'LEARNINGS.md', 'notes/ideas.md'). Required for read/write/delete.\",\n },\n content: {\n type: \"string\",\n description: \"Content to write. Required for write.\",\n },\n scope: {\n type: \"string\",\n description:\n \"personal, shared, workspace, or all (default varies by action). Workspace is read-only when inherited from Dispatch; in local file mode AGENTS.md, agent-native.json, mcp.config.json, .mcp.json, and skills/ are writable.\",\n enum: [\"personal\", \"shared\", \"workspace\", \"all\"],\n },\n prefix: {\n type: \"string\",\n description:\n \"Filter by path prefix when listing (e.g. 'notes/')\",\n },\n mime: {\n type: \"string\",\n description:\n \"MIME type for write (default: inferred from extension)\",\n },\n format: {\n type: \"string\",\n description:\n 'Output format for list: \"json\" or \"text\" (default: text)',\n enum: [\"json\", \"text\"],\n },\n visibility: {\n type: \"string\",\n description:\n 'Visibility for write: \"agent_scratch\" for internal working files, \"workspace\" for user-requested files. Defaults to agent_scratch except durable instruction/skill/job/memory paths.',\n enum: [\"workspace\", \"agent_scratch\"],\n },\n includeAgentScratch: {\n type: \"boolean\",\n description: \"Include hidden agent scratch files when listing.\",\n },\n },\n required: [\"action\"],\n },\n },\n run: async (args: Record<string, string>) => {\n const { action: a, ...rest } = args;\n if (a === \"list\") return listEntry.run(rest);\n if (a === \"read\") {\n if (!rest.path) return \"Error: path is required for read\";\n return readEntry.run(rest);\n }\n if (a === \"effective\") {\n if (!rest.path) return \"Error: path is required for effective\";\n return effectiveEntry.run(rest);\n }\n if (a === \"write\") {\n if (\n !rest.path ||\n rest.content === undefined ||\n rest.content === null\n )\n return \"Error: path and content are required for write\";\n rest.createdBy = \"agent\";\n rest.visibility =\n rest.visibility ??\n (shouldDefaultResourceWriteToWorkspace(String(rest.path))\n ? \"workspace\"\n : \"agent_scratch\");\n const runCtx = getRequestRunContext();\n if (runCtx?.threadId) rest.threadId = runCtx.threadId;\n return writeEntry.run(rest);\n }\n if (a === \"promote\") {\n if (!rest.path) return \"Error: path is required for promote\";\n const scope = rest.scope ?? \"personal\";\n if (scope === \"workspace\" || scope === \"all\") {\n return \"Error: promote supports personal or shared scope only\";\n }\n const owner =\n scope === \"shared\"\n ? store.sharedResourceOwner(getRequestOrgId())\n : (getRequestRunContext()?.owner ??\n getRequestUserEmail() ??\n getAmbientUserEmail());\n if (!owner) {\n return \"Error: promote requires an authenticated user\";\n }\n const resource = await store.resourceGetByPath(\n owner,\n String(rest.path),\n );\n if (!resource) {\n return `Resource not found: ${rest.path}`;\n }\n const promoted = await store.resourcePut(\n owner,\n resource.path,\n resource.content,\n resource.mimeType,\n {\n createdBy: resource.createdBy,\n visibility: \"workspace\",\n threadId: resource.threadId,\n runId: resource.runId,\n expiresAt: null,\n metadata: resource.metadata,\n },\n );\n return `Promoted resource: ${promoted.path}`;\n }\n if (a === \"delete\") {\n if (!rest.path) return \"Error: path is required for delete\";\n return deleteEntry.run(rest);\n }\n return `Error: unknown action \"${a}\". Use: list, read, write, promote, delete`;\n },\n },\n \"save-memory\": wrapCliScript(\n {\n description:\n \"Save a memory for future conversations. Creates or updates a memory file and its index entry. Use proactively when you learn preferences, corrections, project context, or references.\",\n parameters: {\n type: \"object\",\n properties: {\n name: {\n type: \"string\",\n description:\n \"Short kebab-case identifier (e.g. 'coding-style', 'deploy-process'). Used as the filename.\",\n },\n type: {\n type: \"string\",\n description: \"Memory category\",\n enum: [\"user\", \"feedback\", \"project\", \"reference\"],\n },\n description: {\n type: \"string\",\n description:\n \"One-line summary shown in the memory index (keep under 80 chars)\",\n },\n content: {\n type: \"string\",\n description:\n \"The memory content in markdown. For updates, read first and provide full updated content.\",\n },\n },\n required: [\"name\", \"type\", \"description\", \"content\"],\n },\n },\n saveMem.default,\n ),\n \"delete-memory\": wrapCliScript(\n {\n description:\n \"Delete a memory entry and remove it from the memory index.\",\n parameters: {\n type: \"object\",\n properties: {\n name: {\n type: \"string\",\n description: \"The memory name to delete (e.g. 'coding-style')\",\n },\n },\n required: [\"name\"],\n },\n },\n delMem.default,\n ),\n };\n } catch {\n // Resources not available — skip silently\n return {};\n }\n}\n\n/**\n * Creates a unified chat-history ActionEntry that dispatches to search, open,\n * rename, or lightweight organization actions.\n */\nexport async function createChatScriptEntries(): Promise<\n Record<string, ActionEntry>\n> {\n try {\n const [searchMod, openMod] = await Promise.all([\n import(\"../../scripts/chat/search-chats.js\"),\n import(\"../../scripts/chat/open-chat.js\"),\n ]);\n\n const searchEntry = wrapCliScript(\n {\n description: \"Search or list past agent chat threads.\",\n parameters: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"Search term to find chats by title, preview, or content\",\n },\n limit: {\n type: \"string\",\n description: \"Max number of results (default: 20)\",\n },\n format: {\n type: \"string\",\n description: \"Output format\",\n enum: [\"json\", \"text\"],\n },\n includeArchived: {\n type: \"boolean\",\n description:\n \"Also include archived chats in the results. Archived chats are excluded by default.\",\n },\n },\n },\n },\n searchMod.default,\n );\n\n const openEntry = wrapCliScript(\n {\n description: \"Open a chat thread in the UI.\",\n parameters: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n description: \"The chat thread ID to open\",\n },\n },\n required: [\"id\"],\n },\n },\n openMod.default,\n );\n\n return {\n \"chat-history\": {\n tool: {\n description:\n \"Manage past agent chat threads. Use action 'search' to find previous conversations by keyword, 'open' to open a thread in the UI, or 'rename'/'pin'/'unpin'/'archive' to organize history.\",\n parameters: {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n description: \"The operation to perform\",\n enum: [\"search\", \"open\", \"rename\", \"pin\", \"unpin\", \"archive\"],\n },\n query: {\n type: \"string\",\n description:\n \"(search) Search term to find chats by title, preview, or content\",\n },\n limit: {\n type: \"string\",\n description: \"(search) Max number of results (default: 20)\",\n },\n format: {\n type: \"string\",\n description: \"(search) Output format\",\n enum: [\"json\", \"text\"],\n },\n includeArchived: {\n type: \"boolean\",\n description:\n \"(search) Also include archived chats in the results. Archived chats are excluded by default, matching the 'archive' action's effect on the chat list.\",\n },\n id: {\n type: \"string\",\n description:\n \"(open, rename, pin, unpin, archive) The chat thread ID to manage\",\n },\n title: {\n type: \"string\",\n description: \"(rename) New chat title\",\n },\n },\n required: [\"action\"],\n },\n },\n run: async (args) => {\n if (args?.action === \"open\") {\n return openEntry.run(args);\n }\n if (\n args?.action === \"rename\" ||\n args?.action === \"pin\" ||\n args?.action === \"unpin\" ||\n args?.action === \"archive\"\n ) {\n const id = typeof args?.id === \"string\" ? args.id : \"\";\n if (!id) return \"Missing required id.\";\n const owner =\n getRequestRunContext()?.owner ?? getRequestUserEmail() ?? \"\";\n if (!owner) return \"No authenticated user is available.\";\n const thread = await resolveThreadAccess(owner, id, \"editor\", {\n orgId: getRequestOrgId(),\n });\n if (!thread) {\n return `Chat thread \"${id}\" not found.`;\n }\n const title = thread.title || thread.preview || \"(untitled)\";\n if (args.action === \"rename\") {\n const nextTitle =\n typeof args?.title === \"string\"\n ? args.title.replace(/\\s+/g, \" \").trim().slice(0, 160)\n : \"\";\n if (!nextTitle) return \"Missing required title.\";\n const renamed = await renameThread(id, nextTitle);\n if (!renamed) return `Chat thread \"${id}\" could not be renamed.`;\n return `Renamed chat \"${title}\" to \"${nextTitle}\".`;\n }\n if (args.action === \"archive\") {\n const archived = await setThreadArchived(id, true);\n if (!archived)\n return `Chat thread \"${id}\" could not be archived.`;\n return `Archived chat: ${title}`;\n }\n const pinned = await setThreadPinned(id, args.action === \"pin\");\n if (!pinned) return `Chat thread \"${id}\" could not be updated.`;\n return `${args.action === \"pin\" ? \"Pinned\" : \"Unpinned\"} chat: ${title}`;\n }\n return searchEntry.run(args);\n },\n },\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Creates the consolidated manage-agent-engine tool (list / set / test).\n * Let the agent inspect and configure the active LLM engine.\n */\nexport async function createAgentEngineScriptEntries(\n appId?: string,\n): Promise<Record<string, ActionEntry>> {\n try {\n const mod =\n await import(\"../../scripts/agent-engines/manage-agent-engine.js\");\n\n return {\n \"manage-agent-engine\": {\n tool: mod.tool,\n run: (args) =>\n mod.run({\n ...args,\n appId:\n typeof args.appId === \"string\" && args.appId.trim()\n ? args.appId\n : (appId ?? \"\"),\n }),\n },\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Creates the manage-agent-loop-settings tool. Lets the agent inspect and\n * configure the loop step limit it may hit on long-running work.\n */\nexport async function createAgentLoopSettingsScriptEntries(): Promise<\n Record<string, ActionEntry>\n> {\n try {\n const mod = await import(\"../../scripts/manage-agent-loop-settings.js\");\n\n return {\n \"manage-agent-loop-settings\": { tool: mod.tool, run: mod.run },\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Creates the call-agent ActionEntry for cross-agent A2A communication.\n * Binds selfAppId so the agent cannot call itself via call-agent.\n */\nexport async function createCallAgentScriptEntry(\n selfAppId?: string,\n): Promise<Record<string, ActionEntry>> {\n const entries: Record<string, ActionEntry> = {};\n\n try {\n const mod = await import(\"../../scripts/call-agent.js\");\n entries[\"call-agent\"] = {\n tool: mod.tool,\n run: (args, context) => mod.run(args, context, selfAppId),\n };\n } catch {\n // A missing built-in leaves the rest of the toolset usable.\n }\n\n try {\n const mod = await import(\"../../scripts/describe-workspace-apps.js\");\n entries[\"describe-workspace-apps\"] = {\n tool: mod.tool,\n run: (args, context) => mod.run(args, context, selfAppId),\n };\n } catch {\n // A missing built-in leaves the rest of the toolset usable.\n }\n\n return entries;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"script-entries.js","sourceRoot":"","sources":["../../../src/server/agent-chat/script-entries.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,8EAA8E;AAC9E,qEAAqE;AACrE,0EAA0E;AAC1E,2EAA2E;AAC3E,sEAAsE;AACtE,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAS,aAAa,CACpB,IAAgB,EAChB,UAA6C,EAC7C,IAGC;IAED,OAAO;QACL,IAAI;QACJ,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,EAAE,KAAK,EAAE,IAA4B,EAAmB,EAAE;YAC3D,MAAM,OAAO,GAAa,EAAE,CAAC;YAC7B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1C,kEAAkE;gBAClE,uEAAuE;gBACvE,uEAAuE;gBACvE,sEAAsE;gBACtE,wDAAwD;gBACxD,IAAI,IAAI,EAAE,WAAW,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;oBACvD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAAC,CA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AC,CAAC;QACrE,OAAO,CAAC,yBAAyB,CAAC,GAAG;YACnC,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC;SAC1D,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,4DAA4D;IAC9D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { ActionTool } from \"../../agent/types.js\";\nimport {\n renameThread,\n resolveThreadAccess,\n setThreadArchived,\n setThreadPinned,\n} from \"../../chat-threads/store.js\";\nimport type { DatabaseToolsMode } from \"../../scripts/db/tool-mode.js\";\nimport { dbExecToolParameters } from \"../../scripts/db/tool-schemas.js\";\nimport { captureCliOutput } from \"../cli-capture.js\";\nimport {\n getAmbientUserEmail,\n getRequestOrgId,\n getRequestRunContext,\n getRequestUserEmail,\n} from \"../request-context.js\";\n\n// ---------------------------------------------------------------------------\n// CLI-script-backed action entries: db-*, docs-search/source-search,\n// resources/save-memory/delete-memory, chat-history, manage-agent-engine,\n// manage-agent-loop-settings, and call-agent. Each wraps a core CLI script\n// (that writes to console.log) as an ActionEntry via `wrapCliScript`.\n// ---------------------------------------------------------------------------\n\n/**\n * Wraps a core CLI script (that writes to console.log) as a ActionEntry\n * by capturing stdout. Uses an AsyncLocalStorage-backed capture so\n * concurrent tool calls do not corrupt the global console/stdout pointers\n * (see `cli-capture.ts`).\n */\nfunction wrapCliScript(\n tool: ActionTool,\n cliDefault: (args: string[]) => Promise<void>,\n opts?: {\n allowedArgs?: readonly string[];\n readOnly?: boolean;\n },\n): ActionEntry {\n return {\n tool,\n ...(opts?.readOnly ? { readOnly: true as const } : {}),\n run: async (args: Record<string, string>): Promise<string> => {\n const cliArgs: string[] = [];\n for (const [k, v] of Object.entries(args)) {\n // MCP input schemas are descriptive and some hosts can still send\n // undeclared keys. The externally exposed DB readers must never accept\n // the CLI-only `--db` escape hatch, which could point at another local\n // SQLite file. Keep their runtime surface identical to the advertised\n // schema instead of trusting the client to validate it.\n if (opts?.allowedArgs && !opts.allowedArgs.includes(k)) {\n throw new Error(`Unknown argument: ${k}`);\n }\n const raw = v as unknown;\n const value =\n raw != null && typeof raw === \"object\"\n ? JSON.stringify(raw)\n : String(raw);\n cliArgs.push(`--${k}`, value);\n }\n return captureCliOutput(() => cliDefault(cliArgs));\n },\n };\n}\n\n/**\n * Creates db-* tools (db-query, db-exec, db-patch, db-schema) as native tools.\n * By default these let the agent inspect the app's own SQL database; raw SQL\n * writes are only exposed when the app explicitly opts into write mode.\n * Scoping to the current user/org is enforced automatically in production via\n * temp views.\n *\n * In dev mode template actions are invoked via bash and the agent can call\n * `pnpm action db-query ...` — but in production there is no bash, so these\n * must be registered as native tools for the agent to reach the app DB at all.\n */\nexport async function createDbScriptEntries(\n mode: DatabaseToolsMode = \"read\",\n options: { extensionTools?: boolean } = {},\n): Promise<Record<string, ActionEntry>> {\n try {\n if (mode === \"off\") return {};\n const extensionQueryGuidance =\n options.extensionTools === false\n ? \"Extension management tools are disabled for this app; do not query or mutate the legacy tools table as a workaround.\"\n : \"For extension management, use list-extensions, update-extension, hide-extension, or delete-extension instead of querying the legacy tools table.\";\n const [schemaMod, queryMod] = await Promise.all([\n import(\"../../scripts/db/schema.js\"),\n import(\"../../scripts/db/query.js\"),\n ]);\n const [execMod, patchMod] =\n mode === \"write\"\n ? await Promise.all([\n import(\"../../scripts/db/exec.js\"),\n import(\"../../scripts/db/patch.js\"),\n ])\n : [null, null];\n\n const entries: Record<string, ActionEntry> = {\n \"db-schema\": wrapCliScript(\n {\n description:\n \"Show the app's SQL schema — all tables, columns, types, indexes, and foreign keys. Use this to understand the data model before querying.\",\n parameters: {\n type: \"object\",\n properties: {\n format: {\n type: \"string\",\n description: 'Output format: \"json\" or \"text\" (default: text)',\n enum: [\"json\", \"text\"],\n },\n },\n },\n },\n schemaMod.default,\n {\n allowedArgs: [\"format\"],\n readOnly: true,\n },\n ),\n \"db-query\": wrapCliScript(\n {\n description: `Read from the app's own SQL database ONLY. Runs a SELECT against the app's internal tables (settings, application_state, template tables). Results are auto-scoped to the current user/org. IMPORTANT: This tool CANNOT access external data sources like data warehouses, CRMs, issue trackers, analytics platforms, calendars, mail, docs, or other third-party services. For those, use the relevant template/provider action, MCP connector, or provider-api-catalog/provider-api-docs/provider-api-request when available. If the user names a provider, that named provider wins; do not substitute a warehouse or app database copy unless they explicitly ask for it. If a table isn't in the app schema, don't try db-query — use the data-source-specific action. ${extensionQueryGuidance}`,\n parameters: {\n type: \"object\",\n properties: {\n sql: {\n type: \"string\",\n description:\n \"SELECT query to run, e.g. \\\"SELECT key, value FROM settings WHERE key LIKE 'sql-dashboard-%'\\\"\",\n },\n args: {\n type: \"string\",\n description:\n 'Optional JSON array of positional bind args for parameterized placeholders. Example: \\'[\"draft\",\"form-123\"]\\'',\n },\n format: {\n type: \"string\",\n description: 'Output format: \"json\" or \"text\" (default: text)',\n enum: [\"json\", \"text\"],\n },\n limit: {\n type: \"string\",\n description:\n \"Append LIMIT N if the query doesn't already have one\",\n },\n },\n required: [\"sql\"],\n },\n },\n queryMod.default,\n {\n allowedArgs: [\"sql\", \"args\", \"format\", \"limit\"],\n readOnly: true,\n },\n ),\n };\n\n if (execMod && patchMod) {\n entries[\"db-exec\"] = wrapCliScript(\n {\n description:\n \"Write to the app's own SQL database ONLY. Runs INSERT / UPDATE / DELETE / REPLACE against the app's internal tables. For multiple related writes, pass `statements` so they run sequentially in one transaction instead of issuing several db-exec calls. Writes are auto-scoped to the current user/org, and `owner_email` / `org_id` are auto-injected on INSERT. Schema changes (CREATE/ALTER/DROP) are blocked. Never use this to backfill missing data for a read/analysis request or to create/modify users, members, roles, permissions, admin flags, or ownership; use a dedicated app action or reviewed code. IMPORTANT: This tool CANNOT write to external data sources like BigQuery, HubSpot, etc. For external services, use the appropriate template action.\",\n parameters: dbExecToolParameters(),\n },\n execMod.default,\n );\n entries[\"db-patch\"] = wrapCliScript(\n {\n description:\n \"Surgical patch on a large text/JSON column in the app's SQL database. Two modes: (1) text find/replace via `find`/`replace`/`edits` — best for small edits to documents, slide HTML, etc. (2) structural JSON ops via `json-ops` — STRONGLY PREFERRED when the column is JSON (dashboard configs, form schemas, slide decks) because it avoids all the brace/quote/comma surgery that text find/replace requires. Use `json-ops` to set/remove values at a JSON Pointer path, or to move/insert array items — e.g. reorder dashboard panels, add a filter, rename a field. Targets exactly one row (narrow `where` by primary key). Same per-user/org scoping as db-exec.\",\n parameters: {\n type: \"object\",\n properties: {\n table: {\n type: \"string\",\n description: \"Table name (e.g. 'settings')\",\n },\n column: {\n type: \"string\",\n description:\n \"Text/JSON column to patch (e.g. 'value' for settings)\",\n },\n where: {\n type: \"string\",\n description:\n \"WHERE clause that matches exactly one row (e.g. \\\"key = 'o:org1:sql-dashboard-foo'\\\")\",\n },\n find: {\n type: \"string\",\n description:\n \"Text mode: substring to find. Must match EXACTLY ONE occurrence by default (like Claude Code's Edit tool). If 0 matches, you get 'NOT FOUND'. If >1 matches, you get surrounding context for each match — widen `find` with unique context and retry. Use `all: \\\"true\\\"` to replace every occurrence.\",\n },\n replace: {\n type: \"string\",\n description: \"Text mode: replacement substring\",\n },\n edits: {\n type: \"string\",\n description:\n 'Text mode batch: JSON array of {find, replace} pairs. Same uniqueness rule applies to each `find`. Example: \\'[{\"find\":\"a\",\"replace\":\"b\"}]\\'',\n },\n \"json-ops\": {\n type: \"string\",\n description:\n 'JSON mode: JSON array of structural ops. Each op is {op, path, value?, from?}. `op` is one of \"set\", \"remove\", \"insert\", \"move\", \"move-before\". `path` / `from` use JSON Pointer (\"/panels/3/title\"). Examples — reorder: \\'[{\"op\":\"move\",\"from\":\"/panels/7\",\"path\":\"/panels/1\"}]\\'; edit field: \\'[{\"op\":\"set\",\"path\":\"/panels/0/title\",\"value\":\"New\"}]\\'; delete filter: \\'[{\"op\":\"remove\",\"path\":\"/filters/2\"}]\\'; add panel: \\'[{\"op\":\"insert\",\"path\":\"/panels/0\",\"value\":{\"id\":\"p\",\"title\":\"...\"}}]\\'. Much safer than text find/replace for JSON columns.',\n },\n all: {\n type: \"string\",\n description:\n 'Text mode: set to \"true\" to replace every occurrence of each `find` (default requires exactly one match)',\n enum: [\"true\"],\n },\n },\n required: [\"table\", \"column\", \"where\"],\n },\n },\n patchMod.default,\n );\n }\n\n return entries;\n } catch {\n return {};\n }\n}\n\n/**\n * Creates read-only package lookup tools so agents can inspect version-matched\n * framework docs and source bundled in @agent-native/core at runtime.\n */\nexport async function createDocsScriptEntries(): Promise<\n Record<string, ActionEntry>\n> {\n const entries: Record<string, ActionEntry> = {};\n\n try {\n const mod = await import(\"../../scripts/docs/search.js\");\n entries[\"docs-search\"] = wrapCliScript(\n {\n description:\n \"Search and read agent-native framework documentation, bundled AGENTS.md, and codebase skills. Use --list to see all pages, --query to search, --slug to read a specific page. Codebase skill pages use slugs like skill-<name>.\",\n parameters: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"Search term to find relevant docs (e.g. 'actions', 'authentication', 'database')\",\n },\n slug: {\n type: \"string\",\n description:\n \"Read a specific doc page by slug (e.g. 'actions', 'authentication', 'database')\",\n },\n list: {\n type: \"string\",\n description: 'Set to \"true\" to list all available doc pages',\n enum: [\"true\"],\n },\n },\n },\n },\n mod.default,\n { readOnly: true },\n );\n } catch {\n // Keep source-search available if docs-search fails during a partial build.\n }\n\n try {\n const mod = await import(\"../../scripts/docs/source-search.js\");\n if (!mod.hasSourceCorpus()) {\n return entries;\n }\n entries[\"source-search\"] = wrapCliScript(\n {\n description:\n \"Search and read the packaged Agent Native source corpus under node_modules/@agent-native/core/corpus. Use --list for sections, --query to search core/template source, and --path to read a file.\",\n parameters: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"Search term to find relevant core or template source (e.g. 'defineAction', 'useActionQuery', 'view-screen').\",\n },\n path: {\n type: \"string\",\n description:\n \"Read a specific corpus file or list a directory (e.g. 'templates/plan/AGENTS.md' or 'core/src/action.ts').\",\n },\n list: {\n type: \"string\",\n description: 'Set to \"true\" to list corpus sections',\n enum: [\"true\"],\n },\n },\n },\n },\n mod.default,\n { readOnly: true },\n );\n } catch {\n // Older package installs may not have the corpus/search script yet.\n }\n\n return entries;\n}\n\n/**\n * Creates resource ScriptEntries available in both prod and dev modes.\n */\nexport function shouldDefaultResourceWriteToWorkspace(path: string): boolean {\n const normalized = path.replace(/^\\/+/, \"\");\n return (\n normalized === \"AGENTS.md\" ||\n normalized === \"LEARNINGS.md\" ||\n normalized.startsWith(\"memory/\") ||\n normalized.startsWith(\"skills/\") ||\n normalized.startsWith(\"jobs/\") ||\n normalized.startsWith(\"agents/\") ||\n normalized.startsWith(\"remote-agents/\")\n );\n}\n\nexport async function createResourceScriptEntries(): Promise<\n Record<string, ActionEntry>\n> {\n try {\n const [list, read, effective, write, del, saveMem, delMem, store] =\n await Promise.all([\n import(\"../../scripts/resources/list.js\"),\n import(\"../../scripts/resources/read.js\"),\n import(\"../../scripts/resources/effective.js\"),\n import(\"../../scripts/resources/write.js\"),\n import(\"../../scripts/resources/delete.js\"),\n import(\"../../scripts/resources/save-memory.js\"),\n import(\"../../scripts/resources/delete-memory.js\"),\n import(\"../../resources/store.js\"),\n ]);\n\n // Wrap each CLI runner so it captures stdout and converts args properly\n const listEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n list.default,\n { readOnly: true },\n );\n const readEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n read.default,\n { readOnly: true },\n );\n const writeEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n write.default,\n );\n const effectiveEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n effective.default,\n { readOnly: true },\n );\n const deleteEntry = wrapCliScript(\n {\n description: \"\",\n parameters: { type: \"object\" as const, properties: {} },\n },\n del.default,\n );\n\n return {\n resources: {\n tool: {\n description:\n 'Manage workspace resources. Actions: \"list\" (browse visible files), \"read\" (get contents), \"effective\" (show workspace -> organization/app -> personal inheritance for a path), \"write\" (create/update personal or shared; workspace only for local file mode control files), \"promote\" (make agent scratch visible), \"delete\" (remove personal or shared; workspace only for local file mode control files). Agent scratch writes are hidden from the Workspace view by default; use visibility=\"workspace\" only for files the user explicitly wants to keep/manage.',\n parameters: {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n description: \"The operation to perform\",\n enum: [\n \"list\",\n \"read\",\n \"effective\",\n \"write\",\n \"promote\",\n \"delete\",\n ],\n },\n path: {\n type: \"string\",\n description:\n \"Resource path (e.g. 'LEARNINGS.md', 'notes/ideas.md'). Required for read/write/delete.\",\n },\n content: {\n type: \"string\",\n description: \"Content to write. Required for write.\",\n },\n scope: {\n type: \"string\",\n description:\n \"personal, shared, workspace, or all (default varies by action). Workspace is read-only when inherited from Dispatch; in local file mode AGENTS.md, agent-native.json, mcp.config.json, .mcp.json, and skills/ are writable.\",\n enum: [\"personal\", \"shared\", \"workspace\", \"all\"],\n },\n prefix: {\n type: \"string\",\n description:\n \"Filter by path prefix when listing (e.g. 'notes/')\",\n },\n mime: {\n type: \"string\",\n description:\n \"MIME type for write (default: inferred from extension)\",\n },\n format: {\n type: \"string\",\n description:\n 'Output format for list: \"json\" or \"text\" (default: text)',\n enum: [\"json\", \"text\"],\n },\n visibility: {\n type: \"string\",\n description:\n 'Visibility for write: \"agent_scratch\" for internal working files, \"workspace\" for user-requested files. Defaults to agent_scratch except durable instruction/skill/job/memory paths.',\n enum: [\"workspace\", \"agent_scratch\"],\n },\n includeAgentScratch: {\n type: \"boolean\",\n description: \"Include hidden agent scratch files when listing.\",\n },\n },\n required: [\"action\"],\n },\n },\n run: async (args: Record<string, string>) => {\n const { action: a, ...rest } = args;\n if (a === \"list\") return listEntry.run(rest);\n if (a === \"read\") {\n if (!rest.path) return \"Error: path is required for read\";\n return readEntry.run(rest);\n }\n if (a === \"effective\") {\n if (!rest.path) return \"Error: path is required for effective\";\n return effectiveEntry.run(rest);\n }\n if (a === \"write\") {\n if (\n !rest.path ||\n rest.content === undefined ||\n rest.content === null\n )\n return \"Error: path and content are required for write\";\n rest.createdBy = \"agent\";\n rest.visibility =\n rest.visibility ??\n (shouldDefaultResourceWriteToWorkspace(String(rest.path))\n ? \"workspace\"\n : \"agent_scratch\");\n const runCtx = getRequestRunContext();\n if (runCtx?.threadId) rest.threadId = runCtx.threadId;\n return writeEntry.run(rest);\n }\n if (a === \"promote\") {\n if (!rest.path) return \"Error: path is required for promote\";\n const scope = rest.scope ?? \"personal\";\n if (scope === \"workspace\" || scope === \"all\") {\n return \"Error: promote supports personal or shared scope only\";\n }\n const owner =\n scope === \"shared\"\n ? store.sharedResourceOwner(getRequestOrgId())\n : (getRequestRunContext()?.owner ??\n getRequestUserEmail() ??\n getAmbientUserEmail());\n if (!owner) {\n return \"Error: promote requires an authenticated user\";\n }\n const resource = await store.resourceGetByPath(\n owner,\n String(rest.path),\n );\n if (!resource) {\n return `Resource not found: ${rest.path}`;\n }\n const promoted = await store.resourcePut(\n owner,\n resource.path,\n resource.content,\n resource.mimeType,\n {\n createdBy: resource.createdBy,\n visibility: \"workspace\",\n threadId: resource.threadId,\n runId: resource.runId,\n expiresAt: null,\n metadata: resource.metadata,\n },\n );\n return `Promoted resource: ${promoted.path}`;\n }\n if (a === \"delete\") {\n if (!rest.path) return \"Error: path is required for delete\";\n return deleteEntry.run(rest);\n }\n return `Error: unknown action \"${a}\". Use: list, read, write, promote, delete`;\n },\n },\n \"save-memory\": wrapCliScript(\n {\n description:\n \"Save a memory for future conversations. Creates or updates a memory file and its index entry. Use proactively when you learn preferences, corrections, project context, or references.\",\n parameters: {\n type: \"object\",\n properties: {\n name: {\n type: \"string\",\n description:\n \"Short kebab-case identifier (e.g. 'coding-style', 'deploy-process'). Used as the filename.\",\n },\n type: {\n type: \"string\",\n description: \"Memory category\",\n enum: [\"user\", \"feedback\", \"project\", \"reference\"],\n },\n description: {\n type: \"string\",\n description:\n \"One-line summary shown in the memory index (keep under 80 chars)\",\n },\n content: {\n type: \"string\",\n description:\n \"The memory content in markdown. For updates, read first and provide full updated content.\",\n },\n },\n required: [\"name\", \"type\", \"description\", \"content\"],\n },\n },\n saveMem.default,\n ),\n \"delete-memory\": wrapCliScript(\n {\n description:\n \"Delete a memory entry and remove it from the memory index.\",\n parameters: {\n type: \"object\",\n properties: {\n name: {\n type: \"string\",\n description: \"The memory name to delete (e.g. 'coding-style')\",\n },\n },\n required: [\"name\"],\n },\n },\n delMem.default,\n ),\n };\n } catch {\n // Resources not available — skip silently\n return {};\n }\n}\n\n/**\n * Creates a unified chat-history ActionEntry that dispatches to search, open,\n * rename, or lightweight organization actions.\n */\nexport async function createChatScriptEntries(): Promise<\n Record<string, ActionEntry>\n> {\n try {\n const [searchMod, openMod] = await Promise.all([\n import(\"../../scripts/chat/search-chats.js\"),\n import(\"../../scripts/chat/open-chat.js\"),\n ]);\n\n const searchEntry = wrapCliScript(\n {\n description: \"Search or list past agent chat threads.\",\n parameters: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"Search term to find chats by title, preview, or content\",\n },\n limit: {\n type: \"string\",\n description: \"Max number of results (default: 20)\",\n },\n format: {\n type: \"string\",\n description: \"Output format\",\n enum: [\"json\", \"text\"],\n },\n includeArchived: {\n type: \"boolean\",\n description:\n \"Also include archived chats in the results. Archived chats are excluded by default.\",\n },\n },\n },\n },\n searchMod.default,\n );\n\n const openEntry = wrapCliScript(\n {\n description: \"Open a chat thread in the UI.\",\n parameters: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n description: \"The chat thread ID to open\",\n },\n },\n required: [\"id\"],\n },\n },\n openMod.default,\n );\n\n return {\n \"chat-history\": {\n tool: {\n description:\n \"Manage past agent chat threads. Use action 'search' to find previous conversations by keyword, 'open' to open a thread in the UI, or 'rename'/'pin'/'unpin'/'archive' to organize history.\",\n parameters: {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n description: \"The operation to perform\",\n enum: [\"search\", \"open\", \"rename\", \"pin\", \"unpin\", \"archive\"],\n },\n query: {\n type: \"string\",\n description:\n \"(search) Search term to find chats by title, preview, or content\",\n },\n limit: {\n type: \"string\",\n description: \"(search) Max number of results (default: 20)\",\n },\n format: {\n type: \"string\",\n description: \"(search) Output format\",\n enum: [\"json\", \"text\"],\n },\n includeArchived: {\n type: \"boolean\",\n description:\n \"(search) Also include archived chats in the results. Archived chats are excluded by default, matching the 'archive' action's effect on the chat list.\",\n },\n id: {\n type: \"string\",\n description:\n \"(open, rename, pin, unpin, archive) The chat thread ID to manage\",\n },\n title: {\n type: \"string\",\n description: \"(rename) New chat title\",\n },\n },\n required: [\"action\"],\n },\n },\n run: async (args) => {\n if (args?.action === \"open\") {\n return openEntry.run(args);\n }\n if (\n args?.action === \"rename\" ||\n args?.action === \"pin\" ||\n args?.action === \"unpin\" ||\n args?.action === \"archive\"\n ) {\n const id = typeof args?.id === \"string\" ? args.id : \"\";\n if (!id) return \"Missing required id.\";\n const owner =\n getRequestRunContext()?.owner ?? getRequestUserEmail() ?? \"\";\n if (!owner) return \"No authenticated user is available.\";\n const thread = await resolveThreadAccess(owner, id, \"editor\", {\n orgId: getRequestOrgId(),\n });\n if (!thread) {\n return `Chat thread \"${id}\" not found.`;\n }\n const title = thread.title || thread.preview || \"(untitled)\";\n if (args.action === \"rename\") {\n const nextTitle =\n typeof args?.title === \"string\"\n ? args.title.replace(/\\s+/g, \" \").trim().slice(0, 160)\n : \"\";\n if (!nextTitle) return \"Missing required title.\";\n const renamed = await renameThread(id, nextTitle);\n if (!renamed) return `Chat thread \"${id}\" could not be renamed.`;\n return `Renamed chat \"${title}\" to \"${nextTitle}\".`;\n }\n if (args.action === \"archive\") {\n const archived = await setThreadArchived(id, true);\n if (!archived)\n return `Chat thread \"${id}\" could not be archived.`;\n return `Archived chat: ${title}`;\n }\n const pinned = await setThreadPinned(id, args.action === \"pin\");\n if (!pinned) return `Chat thread \"${id}\" could not be updated.`;\n return `${args.action === \"pin\" ? \"Pinned\" : \"Unpinned\"} chat: ${title}`;\n }\n return searchEntry.run(args);\n },\n },\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Creates the consolidated manage-agent-engine tool (list / set / test).\n * Let the agent inspect and configure the active LLM engine.\n */\nexport async function createAgentEngineScriptEntries(\n appId?: string,\n): Promise<Record<string, ActionEntry>> {\n try {\n const mod =\n await import(\"../../scripts/agent-engines/manage-agent-engine.js\");\n\n return {\n \"manage-agent-engine\": {\n tool: mod.tool,\n run: (args) =>\n mod.run({\n ...args,\n appId:\n typeof args.appId === \"string\" && args.appId.trim()\n ? args.appId\n : (appId ?? \"\"),\n }),\n },\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Creates the manage-agent-loop-settings tool. Lets the agent inspect and\n * configure the loop step limit it may hit on long-running work.\n */\nexport async function createAgentLoopSettingsScriptEntries(): Promise<\n Record<string, ActionEntry>\n> {\n try {\n const mod = await import(\"../../scripts/manage-agent-loop-settings.js\");\n\n return {\n \"manage-agent-loop-settings\": { tool: mod.tool, run: mod.run },\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Creates the call-agent ActionEntry for cross-agent A2A communication.\n * Binds selfAppId so the agent cannot call itself via call-agent.\n */\nexport async function createCallAgentScriptEntry(\n selfAppId?: string,\n): Promise<Record<string, ActionEntry>> {\n const entries: Record<string, ActionEntry> = {};\n\n try {\n const mod = await import(\"../../scripts/call-agent.js\");\n entries[\"call-agent\"] = {\n tool: mod.tool,\n run: (args, context) => mod.run(args, context, selfAppId),\n };\n } catch {\n // A missing built-in leaves the rest of the toolset usable.\n }\n\n try {\n const mod = await import(\"../../scripts/describe-workspace-apps.js\");\n entries[\"describe-workspace-apps\"] = {\n tool: mod.tool,\n run: (args, context) => mod.run(args, context, selfAppId),\n };\n } catch {\n // A missing built-in leaves the rest of the toolset usable.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AK,EAAE,MAAM,EACb,IAAI,EAAE;IACJ,eAAe,EAAE,CACf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,KACZ,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9B,uBAAuB,EAAE,CACvB,GAAG,EAAE,oBAAoB,KACtB,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;CAC/B,GACA,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAI1B;AAED,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,cAAc,CAy6KhB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,cAAwC,CAAC;AAE9E,OAAO,EAEL,mBAAmB,EACnB,uBAAuB,EAGxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -239,22 +239,9 @@ export function createAgentChatPlugin(options) {
|
|
|
239
239
|
const initPromise = (async () => {
|
|
240
240
|
const { awaitBootstrap } = await import("./framework-request-handler.js");
|
|
241
241
|
await awaitBootstrap(nitroApp);
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
// next /runs/active check returns a terminal status and reconnecting
|
|
246
|
-
// clients don't spin on "Thinking...". Runs owned by OTHER live
|
|
247
|
-
// isolates are protected by their fresh heartbeats.
|
|
248
|
-
try {
|
|
249
|
-
const { reapAllStaleRuns } = await import("../agent/run-store.js");
|
|
250
|
-
const reaped = await reapAllStaleRuns();
|
|
251
|
-
if (reaped > 0) {
|
|
252
|
-
console.log(`[agent-chat] reaped ${reaped} stale run(s) on startup`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
catch {
|
|
256
|
-
// Best effort — don't block plugin init if SQL isn't ready yet.
|
|
257
|
-
}
|
|
242
|
+
// Never make route readiness wait on an org-global stale-run sweep.
|
|
243
|
+
// `/runs/active` reaps the requested run on demand, and the periodic
|
|
244
|
+
// recovery sweep below handles abandoned runs with no connected client.
|
|
258
245
|
const env = process.env.NODE_ENV;
|
|
259
246
|
// AGENT_MODE=production forces production agent constraints even in dev
|
|
260
247
|
const canToggle = (env === "development" || env === "test") &&
|
|
@@ -290,37 +277,41 @@ export function createAgentChatPlugin(options) {
|
|
|
290
277
|
databaseTools: options?.databaseTools,
|
|
291
278
|
extensionTools: options?.extensionTools,
|
|
292
279
|
});
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
280
|
+
// Route readiness must not wait on settings scans, remote hub fetches, or
|
|
281
|
+
// third-party MCP handshakes. Build the action surface against an empty
|
|
282
|
+
// manager, then hydrate it after every live action registry has subscribed
|
|
283
|
+
// to manager changes.
|
|
284
|
+
const mcpManager = new McpClientManager(null);
|
|
285
|
+
setGlobalMcpManager(mcpManager);
|
|
286
|
+
const mcpActionEntries = {};
|
|
287
|
+
let mcpInitializationPromise = null;
|
|
288
|
+
const initializeMcpManager = async () => {
|
|
289
|
+
let mcpConfig = await buildMergedConfig().catch((err) => {
|
|
290
|
+
console.warn(`[mcp-client] buildMergedConfig failed: ${err?.message ?? err}`);
|
|
291
|
+
return null;
|
|
292
|
+
});
|
|
293
|
+
if (!mcpConfig) {
|
|
294
|
+
mcpConfig = loadMcpConfig() ?? autoDetectMcpConfig();
|
|
295
|
+
if (mcpConfig?.source) {
|
|
296
|
+
console.log(`[mcp-client] loaded config from ${mcpConfig.source} (${Object.keys(mcpConfig.servers).length} server(s))`);
|
|
297
|
+
}
|
|
298
|
+
else if (process.env.DEBUG) {
|
|
299
|
+
console.log("[mcp-client] no configured MCP servers — skipping MCP tools");
|
|
300
|
+
}
|
|
307
301
|
}
|
|
308
|
-
else if (
|
|
309
|
-
console.log(
|
|
302
|
+
else if (mcpConfig.source) {
|
|
303
|
+
console.log(`[mcp-client] merged config (${Object.keys(mcpConfig.servers).length} server(s), source: ${mcpConfig.source})`);
|
|
310
304
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
setGlobalMcpManager(mcpManager);
|
|
323
|
-
const mcpActionEntries = mcpToolsToActionEntries(mcpManager);
|
|
305
|
+
try {
|
|
306
|
+
await mcpManager.reconfigure(mcpConfig);
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
console.warn(`[mcp-client] initialization failed: ${err?.message ?? err}. Continuing without MCP tools.`);
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
startMcpConfigRefresh(mcpManager);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
324
315
|
const getJobMcpActionEntries = (job) => {
|
|
325
316
|
const requested = job?.meta.mcpTools ?? [];
|
|
326
317
|
if (requested.length === 0)
|
|
@@ -337,8 +328,11 @@ export function createAgentChatPlugin(options) {
|
|
|
337
328
|
// Mount status + management routes so the settings UI can list / add /
|
|
338
329
|
// remove remote MCP servers and hot-reload the running manager.
|
|
339
330
|
mountMcpStatusRoute(nitroApp, mcpManager);
|
|
340
|
-
mountMcpServersRoutes(nitroApp, mcpManager
|
|
341
|
-
|
|
331
|
+
mountMcpServersRoutes(nitroApp, mcpManager, {
|
|
332
|
+
// Serialize an unusually early settings mutation behind the initial
|
|
333
|
+
// config snapshot so stale startup data cannot overwrite the write.
|
|
334
|
+
waitUntilReady: () => mcpInitializationPromise ?? Promise.resolve(),
|
|
335
|
+
});
|
|
342
336
|
// Hub-serve: expose org-scope servers to other agent-native apps in the
|
|
343
337
|
// workspace when `AGENT_NATIVE_MCP_HUB_TOKEN` is set (dispatch, by
|
|
344
338
|
// convention). Gated by the env var so mounting is a no-op otherwise.
|
|
@@ -4562,6 +4556,10 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
4562
4556
|
// Jobs module not available — skip silently
|
|
4563
4557
|
}
|
|
4564
4558
|
}
|
|
4559
|
+
mcpInitializationPromise = initializeMcpManager().catch((err) => {
|
|
4560
|
+
console.warn(`[mcp-client] deferred initialization failed: ${err?.message ?? err}`);
|
|
4561
|
+
});
|
|
4562
|
+
void mcpInitializationPromise;
|
|
4565
4563
|
// ─── Agent Teams orphan sweep ─────────────────────────────────────
|
|
4566
4564
|
// Re-fires stuck/queued dispatches when the browser is closed and the
|
|
4567
4565
|
// RunsTray's per-user reconciliation never triggers. Runs every 2 minutes
|
|
@@ -4838,7 +4836,7 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
4838
4836
|
if (process.env.DEBUG)
|
|
4839
4837
|
console.log("[triggers] Trigger dispatcher initialized");
|
|
4840
4838
|
}
|
|
4841
|
-
catch
|
|
4839
|
+
catch {
|
|
4842
4840
|
// Triggers module not available — skip silently
|
|
4843
4841
|
}
|
|
4844
4842
|
}
|