@agent-native/core 0.95.1 → 0.97.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/README.md +6 -0
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +64 -0
- package/corpus/core/docs/content/audit-log.mdx +2 -1
- package/corpus/core/docs/content/automations.mdx +7 -7
- package/corpus/core/docs/content/creating-templates.mdx +1 -1
- package/corpus/core/docs/content/internationalization.mdx +2 -1
- package/corpus/core/docs/content/locales/ar-SA/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/ar-SA/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/ar-SA/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/ar-SA/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/ar-SA/package-lifecycle.mdx +19 -0
- package/corpus/core/docs/content/locales/ar-SA/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/ar-SA/security.mdx +8 -0
- package/corpus/core/docs/content/locales/de-DE/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/de-DE/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/de-DE/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/de-DE/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/package-lifecycle.mdx +22 -0
- package/corpus/core/docs/content/locales/de-DE/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/de-DE/security.mdx +8 -0
- package/corpus/core/docs/content/locales/es-ES/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/es-ES/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/es-ES/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/es-ES/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/package-lifecycle.mdx +22 -0
- package/corpus/core/docs/content/locales/es-ES/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/es-ES/security.mdx +8 -0
- package/corpus/core/docs/content/locales/fr-FR/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/fr-FR/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/fr-FR/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/fr-FR/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/package-lifecycle.mdx +21 -0
- package/corpus/core/docs/content/locales/fr-FR/sandbox-adapters.mdx +19 -8
- package/corpus/core/docs/content/locales/fr-FR/security.mdx +8 -0
- package/corpus/core/docs/content/locales/hi-IN/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/hi-IN/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/hi-IN/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/hi-IN/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/package-lifecycle.mdx +20 -0
- package/corpus/core/docs/content/locales/hi-IN/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/hi-IN/security.mdx +8 -0
- package/corpus/core/docs/content/locales/ja-JP/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/ja-JP/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/ja-JP/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/ja-JP/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/package-lifecycle.mdx +21 -0
- package/corpus/core/docs/content/locales/ja-JP/sandbox-adapters.mdx +17 -6
- package/corpus/core/docs/content/locales/ja-JP/security.mdx +8 -0
- package/corpus/core/docs/content/locales/ko-KR/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/ko-KR/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/ko-KR/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/ko-KR/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/package-lifecycle.mdx +20 -0
- package/corpus/core/docs/content/locales/ko-KR/sandbox-adapters.mdx +17 -6
- package/corpus/core/docs/content/locales/ko-KR/security.mdx +8 -0
- package/corpus/core/docs/content/locales/pt-BR/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/pt-BR/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/pt-BR/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/pt-BR/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/package-lifecycle.mdx +21 -0
- package/corpus/core/docs/content/locales/pt-BR/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/pt-BR/security.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-CN/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/zh-CN/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/zh-CN/getting-started.mdx +6 -4
- package/corpus/core/docs/content/locales/zh-CN/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/package-lifecycle.mdx +19 -0
- package/corpus/core/docs/content/locales/zh-CN/sandbox-adapters.mdx +17 -6
- package/corpus/core/docs/content/locales/zh-CN/security.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-TW/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/zh-TW/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/zh-TW/getting-started.mdx +6 -4
- package/corpus/core/docs/content/locales/zh-TW/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/package-lifecycle.mdx +19 -0
- package/corpus/core/docs/content/locales/zh-TW/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/zh-TW/security.mdx +8 -0
- package/corpus/core/docs/content/package-lifecycle.mdx +51 -0
- package/corpus/core/docs/content/sandbox-adapters.mdx +16 -5
- package/corpus/core/package.json +11 -2
- package/corpus/core/src/a2a/auth-policy.ts +33 -0
- package/corpus/core/src/a2a/client.ts +11 -1
- package/corpus/core/src/agent/durable-background.ts +15 -7
- package/corpus/core/src/agent/production-agent.ts +87 -27
- package/corpus/core/src/agent/run-store.ts +13 -4
- package/corpus/core/src/agent/thread-data-builder.ts +7 -5
- package/corpus/core/src/audit/actions/export-audit-events.ts +162 -0
- package/corpus/core/src/audit/store.ts +8 -3
- package/corpus/core/src/audit/types.ts +3 -0
- package/corpus/core/src/chat-threads/store.ts +20 -1
- package/corpus/core/src/cli/code-agent-executor.ts +1 -0
- package/corpus/core/src/cli/code-agent-runs.ts +14 -0
- package/corpus/core/src/cli/doctor.ts +396 -0
- package/corpus/core/src/cli/index.ts +56 -0
- package/corpus/core/src/cli/info.ts +3 -3
- package/corpus/core/src/cli/package-lifecycle.ts +821 -0
- package/corpus/core/src/client/AgentPanel.tsx +32 -25
- package/corpus/core/src/client/AssistantChat.tsx +36 -20
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +141 -90
- package/corpus/core/src/client/agent-chat-adapter.ts +9 -9
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +404 -0
- package/corpus/core/src/client/chat/index.ts +6 -0
- package/corpus/core/src/client/chat/tool-call-display.tsx +37 -3
- package/corpus/core/src/client/code-agent-chat-adapter.ts +72 -4
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +52 -11
- package/corpus/core/src/client/composer/TiptapComposer.tsx +157 -20
- package/corpus/core/src/client/composer/VoiceButton.tsx +28 -0
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +5 -0
- package/corpus/core/src/client/conversation/code-agent-transcript.ts +4 -5
- package/corpus/core/src/client/guided-questions.tsx +2 -1
- package/corpus/core/src/client/index.ts +11 -0
- package/corpus/core/src/client/use-chat-threads.ts +10 -1
- package/corpus/core/src/client/voice-provider-status.ts +44 -0
- package/corpus/core/src/code-agents/transcript-normalizer.ts +76 -0
- package/corpus/core/src/deploy/build.ts +12 -11
- package/corpus/core/src/guards/db-tool-scoping.ts +129 -0
- package/corpus/core/src/guards/index.ts +23 -0
- package/corpus/core/src/guards/no-drizzle-push.ts +116 -0
- package/corpus/core/src/guards/no-env-credentials.ts +229 -0
- package/corpus/core/src/guards/no-env-mutation.ts +114 -0
- package/corpus/core/src/guards/no-localhost-fallback.ts +124 -0
- package/corpus/core/src/guards/no-unscoped-credentials.ts +227 -0
- package/corpus/core/src/guards/no-unscoped-queries.ts +834 -0
- package/corpus/core/src/guards/scan-utils.ts +105 -0
- package/corpus/core/src/guards/types.ts +30 -0
- package/corpus/core/src/integrations/a2a-continuation-processor.ts +35 -5
- package/corpus/core/src/integrations/adapters/slack.ts +74 -21
- package/corpus/core/src/integrations/webhook-handler.ts +14 -0
- package/corpus/core/src/localization/default-messages.ts +6 -0
- package/corpus/core/src/observability/hosted-model-experiment.ts +118 -0
- package/corpus/core/src/observability/routes.ts +17 -0
- package/corpus/core/src/observability/store.ts +4 -1
- package/corpus/core/src/observability/traces.ts +41 -2
- package/corpus/core/src/org/accept-pending.ts +9 -1
- package/corpus/core/src/org/migrations.ts +41 -0
- package/corpus/core/src/package-lifecycle/index.ts +1 -0
- package/corpus/core/src/package-lifecycle/manifest.ts +120 -0
- package/corpus/core/src/provider-api/custom-registry.ts +56 -0
- package/corpus/core/src/provider-api/index.ts +2 -0
- package/corpus/core/src/scripts/agent-engines/list-agent-engines.ts +19 -1
- package/corpus/core/src/scripts/call-agent.ts +53 -3
- package/corpus/core/src/scripts/chat/search-chats.ts +11 -8
- package/corpus/core/src/secrets/register-framework-secrets.ts +1 -1
- package/corpus/core/src/secrets/storage.ts +47 -27
- package/corpus/core/src/server/action-discovery.ts +4 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +95 -18
- package/corpus/core/src/server/core-routes-plugin.ts +45 -14
- package/corpus/core/src/server/csrf.ts +24 -5
- package/corpus/core/src/server/framework-request-handler.ts +34 -0
- package/corpus/core/src/server/google-realtime-session.ts +1 -36
- package/corpus/core/src/server/poll.ts +24 -2
- package/corpus/core/src/server/realtime-voice.ts +80 -24
- package/corpus/core/src/server/request-origin.ts +63 -0
- package/corpus/core/src/server/transcribe-voice.ts +1 -50
- package/corpus/core/src/server/voice-providers-status.ts +4 -3
- package/corpus/core/src/shared/cache-control.ts +2 -8
- package/corpus/core/src/styles/agent-native.css +1 -0
- package/corpus/core/src/styles/chat-history-list.css +313 -0
- package/corpus/core/src/templates/default/package.json +2 -2
- package/corpus/core/src/templates/headless/package.json +0 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- package/corpus/core/src/templates/workspace-core/package.json +0 -1
- package/corpus/core/src/templates/workspace-root/package.json +0 -1
- package/corpus/core/src/triggers/actions.ts +11 -3
- package/corpus/core/src/triggers/types.ts +7 -1
- package/corpus/core/src/vite/client.ts +1 -0
- package/corpus/templates/analytics/AGENTS.md +7 -0
- package/corpus/templates/analytics/actions/bigquery.ts +26 -2
- package/corpus/templates/analytics/actions/compose-dashboard.ts +65 -37
- package/corpus/templates/analytics/actions/data-source-status.ts +18 -0
- package/corpus/templates/analytics/actions/mutate-dashboard.ts +73 -24
- package/corpus/templates/analytics/actions/reorder-dashboard-panels.ts +16 -13
- package/corpus/templates/analytics/actions/update-dashboard.ts +53 -42
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +5 -4
- package/corpus/templates/analytics/app/global.css +10 -0
- package/corpus/templates/analytics/app/pages/Ask.tsx +25 -2
- package/corpus/templates/analytics/changelog/2026-07-10-analytics-answers-simple-time-bounded-metrics-without-unnece.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-analytics-chat-reliably-uses-connected-data-sources-across-s.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-chat-threads-now-stay-clear-of-top-actions-and-fade-smoothly.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-context-chips-can-now-be-selected-and-removed-one-at-a-time-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-dashboard-edits-from-the-agent-and-the-ui-at-the-same-time-n.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-the-ask-composer-no-longer-carries-dashboard-or-panel-contex.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-the-ask-section-stays-highlighted-while-its-chat-history-is-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-timed-out-bigquery-jobs-are-now-cancelled-so-they-stop-consu.md +6 -0
- package/corpus/templates/analytics/package.json +1 -2
- package/corpus/templates/analytics/server/lib/bigquery.ts +91 -14
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +154 -11
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +82 -7
- package/corpus/templates/assets/package.json +1 -2
- package/corpus/templates/brain/package.json +1 -2
- package/corpus/templates/calendar/package.json +1 -2
- package/corpus/templates/chat/package.json +1 -2
- package/corpus/templates/clips/changelog/2026-07-10-atomic-view-tracking.md +6 -0
- package/corpus/templates/clips/chrome-extension/package.json +3 -2
- package/corpus/templates/clips/desktop/package.json +6 -4
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +26 -13
- package/corpus/templates/clips/desktop/src/lib/voice-dictation.ts +4 -1
- package/corpus/templates/clips/package.json +1 -2
- package/corpus/templates/clips/server/db/schema.ts +29 -17
- package/corpus/templates/clips/server/plugins/db.ts +8 -0
- package/corpus/templates/clips/server/routes/api/view-event.post.ts +260 -105
- package/corpus/templates/content/.agents/skills/notion-integration/SKILL.md +16 -0
- package/corpus/templates/content/AGENTS.md +72 -62
- package/corpus/templates/content/actions/_content-database-source-adapters.ts +84 -0
- package/corpus/templates/content/actions/_database-source-utils.ts +206 -96
- package/corpus/templates/content/actions/_notion-database-source-adapter.ts +216 -0
- package/corpus/templates/content/actions/_position-utils.ts +76 -0
- package/corpus/templates/content/actions/_property-utils.ts +31 -20
- package/corpus/templates/content/actions/add-database-item.ts +52 -39
- package/corpus/templates/content/actions/attach-content-database-source.ts +95 -11
- package/corpus/templates/content/actions/change-content-database-source-role.ts +24 -1
- package/corpus/templates/content/actions/configure-document-property.ts +36 -27
- package/corpus/templates/content/actions/create-content-database.ts +40 -30
- package/corpus/templates/content/actions/create-document.ts +39 -32
- package/corpus/templates/content/actions/duplicate-document-property.ts +37 -28
- package/corpus/templates/content/actions/list-notion-database-sources.ts +80 -0
- package/corpus/templates/content/actions/move-document.ts +64 -48
- package/corpus/templates/content/actions/refresh-content-database-source.ts +42 -3
- package/corpus/templates/content/actions/share-local-file-document.ts +36 -27
- package/corpus/templates/content/actions/suggest-source-join-key.ts +39 -16
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +89 -23
- package/corpus/templates/content/app/components/editor/database/settings.tsx +1 -1
- package/corpus/templates/content/app/hooks/use-content-database.ts +18 -1
- package/corpus/templates/content/app/i18n/zh-TW.ts +4 -0
- package/corpus/templates/content/app/i18n-data.ts +40 -0
- package/corpus/templates/content/changelog/2026-07-10-failed-row-creation-and-source-attach-now-show-an-error-inst.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-items-added-at-the-same-time-no-longer-end-up-with-identical.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-notion-databases-can-add-read-only-details-to-content-tables.md +6 -0
- package/corpus/templates/content/package.json +1 -2
- package/corpus/templates/content/parity/matrix.md +25 -25
- package/corpus/templates/content/parity/matrix.ts +1 -0
- package/corpus/templates/content/server/routes/api/documents/[id]/move.patch.ts +43 -26
- package/corpus/templates/content/shared/api.ts +16 -1
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +8 -4
- package/corpus/templates/design/AGENTS.md +12 -2
- package/corpus/templates/design/DEVELOPING.md +10 -6
- package/corpus/templates/design/actions/apply-visual-edit.ts +191 -6
- package/corpus/templates/design/actions/duplicate-design.ts +31 -25
- package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +5 -1
- package/corpus/templates/design/changelog/2026-07-10-duplicating-a-design-can-no-longer-produce-a-copy-with-missi.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-local-visual-edits-can-now-save-safe-leaf-text-class-and.md +6 -0
- package/corpus/templates/design/package.json +1 -1
- package/corpus/templates/design/shared/local-jsx-visual-edit.ts +388 -0
- package/corpus/templates/dispatch/package.json +1 -2
- package/corpus/templates/forms/actions/patch-form-fields.ts +82 -44
- package/corpus/templates/forms/changelog/2026-07-10-simultaneous-edits-to-different-form-fields-no-longer-overwr.md +6 -0
- package/corpus/templates/forms/package.json +1 -2
- package/corpus/templates/macros/package.json +1 -2
- package/corpus/templates/mail/app/components/email/EmailThread.tsx +3 -1
- package/corpus/templates/mail/changelog/2026-07-10-fixed-calendar-rsvp-buttons-in-emails-firing-duplicate-respo.md +6 -0
- package/corpus/templates/mail/package.json +1 -2
- package/corpus/templates/plan/actions/restore-plan-version.ts +126 -96
- package/corpus/templates/plan/changelog/2026-07-10-restoring-a-plan-version-can-no-longer-leave-a-plan-half-res.md +6 -0
- package/corpus/templates/plan/package.json +1 -2
- package/corpus/templates/plan/server/plans.ts +9 -2
- package/corpus/templates/slides/actions/list-decks.ts +28 -0
- package/corpus/templates/slides/app/components/deck/MermaidRenderer.tsx +41 -26
- package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +4 -8
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +2 -4
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +4 -8
- package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +5 -12
- package/corpus/templates/slides/app/components/editor/HistoryPanel.tsx +3 -6
- package/corpus/templates/slides/app/components/editor/ImageDropPromptPopover.tsx +3 -6
- package/corpus/templates/slides/app/components/editor/PromptDialog.tsx +2 -5
- package/corpus/templates/slides/app/context/DeckContext.tsx +47 -4
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +11 -30
- package/corpus/templates/slides/app/pages/Index.tsx +2 -3
- package/corpus/templates/slides/app/root.tsx +0 -5
- package/corpus/templates/slides/changelog/2026-07-10-deck-lists-load-much-faster-and-no-longer-re-download-slide-.md +6 -0
- package/corpus/templates/slides/package.json +1 -2
- package/dist/a2a/auth-policy.d.ts +19 -0
- package/dist/a2a/auth-policy.d.ts.map +1 -1
- package/dist/a2a/auth-policy.js +32 -0
- package/dist/a2a/auth-policy.js.map +1 -1
- package/dist/a2a/client.d.ts +7 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +2 -1
- package/dist/a2a/client.js.map +1 -1
- package/dist/agent/durable-background.d.ts +8 -5
- package/dist/agent/durable-background.d.ts.map +1 -1
- package/dist/agent/durable-background.js +15 -8
- package/dist/agent/durable-background.js.map +1 -1
- package/dist/agent/production-agent.d.ts +6 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +63 -26
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +9 -4
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +1 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +6 -5
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/audit/actions/export-audit-events.d.ts +27 -0
- package/dist/audit/actions/export-audit-events.d.ts.map +1 -0
- package/dist/audit/actions/export-audit-events.js +144 -0
- package/dist/audit/actions/export-audit-events.js.map +1 -0
- package/dist/audit/store.d.ts +1 -0
- package/dist/audit/store.d.ts.map +1 -1
- package/dist/audit/store.js +8 -3
- package/dist/audit/store.js.map +1 -1
- package/dist/audit/types.d.ts +3 -0
- package/dist/audit/types.d.ts.map +1 -1
- package/dist/audit/types.js.map +1 -1
- package/dist/chat-threads/store.d.ts +10 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +6 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +1 -0
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.d.ts +12 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +1 -0
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/cli/doctor.d.ts +83 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +277 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/index.js +50 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/info.js +3 -3
- package/dist/cli/info.js.map +1 -1
- package/dist/cli/package-lifecycle.d.ts +50 -0
- package/dist/cli/package-lifecycle.d.ts.map +1 -0
- package/dist/cli/package-lifecycle.js +560 -0
- package/dist/cli/package-lifecycle.js.map +1 -0
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +3 -3
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +11 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +7 -4
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +83 -10
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.js +7 -3
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/chat/ChatHistoryList.d.ts +88 -0
- package/dist/client/chat/ChatHistoryList.d.ts.map +1 -0
- package/dist/client/chat/ChatHistoryList.js +83 -0
- package/dist/client/chat/ChatHistoryList.js.map +1 -0
- package/dist/client/chat/index.d.ts +1 -0
- package/dist/client/chat/index.d.ts.map +1 -1
- package/dist/client/chat/index.js +1 -0
- package/dist/client/chat/index.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +13 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +10 -2
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/code-agent-chat-adapter.d.ts +17 -1
- package/dist/client/code-agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +47 -3
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +11 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.js +5 -3
- package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +25 -2
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +96 -5
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/VoiceButton.js +21 -1
- package/dist/client/composer/VoiceButton.js.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.js +5 -0
- package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
- package/dist/client/conversation/code-agent-transcript.d.ts +2 -0
- package/dist/client/conversation/code-agent-transcript.d.ts.map +1 -1
- package/dist/client/conversation/code-agent-transcript.js +3 -5
- package/dist/client/conversation/code-agent-transcript.js.map +1 -1
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +2 -1
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +9 -1
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/voice-provider-status.d.ts +10 -0
- package/dist/client/voice-provider-status.d.ts.map +1 -0
- package/dist/client/voice-provider-status.js +32 -0
- package/dist/client/voice-provider-status.js.map +1 -0
- package/dist/code-agents/transcript-normalizer.d.ts +29 -0
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -1
- package/dist/code-agents/transcript-normalizer.js +55 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +13 -11
- package/dist/deploy/build.js.map +1 -1
- package/dist/guards/db-tool-scoping.d.ts +38 -0
- package/dist/guards/db-tool-scoping.d.ts.map +1 -0
- package/dist/guards/db-tool-scoping.js +114 -0
- package/dist/guards/db-tool-scoping.js.map +1 -0
- package/dist/guards/index.d.ts +23 -0
- package/dist/guards/index.d.ts.map +1 -0
- package/dist/guards/index.js +19 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/guards/no-drizzle-push.d.ts +14 -0
- package/dist/guards/no-drizzle-push.d.ts.map +1 -0
- package/dist/guards/no-drizzle-push.js +97 -0
- package/dist/guards/no-drizzle-push.js.map +1 -0
- package/dist/guards/no-env-credentials.d.ts +36 -0
- package/dist/guards/no-env-credentials.d.ts.map +1 -0
- package/dist/guards/no-env-credentials.js +204 -0
- package/dist/guards/no-env-credentials.js.map +1 -0
- package/dist/guards/no-env-mutation.d.ts +23 -0
- package/dist/guards/no-env-mutation.d.ts.map +1 -0
- package/dist/guards/no-env-mutation.js +90 -0
- package/dist/guards/no-env-mutation.js.map +1 -0
- package/dist/guards/no-localhost-fallback.d.ts +30 -0
- package/dist/guards/no-localhost-fallback.d.ts.map +1 -0
- package/dist/guards/no-localhost-fallback.js +105 -0
- package/dist/guards/no-localhost-fallback.js.map +1 -0
- package/dist/guards/no-unscoped-credentials.d.ts +28 -0
- package/dist/guards/no-unscoped-credentials.d.ts.map +1 -0
- package/dist/guards/no-unscoped-credentials.js +199 -0
- package/dist/guards/no-unscoped-credentials.js.map +1 -0
- package/dist/guards/no-unscoped-queries.d.ts +32 -0
- package/dist/guards/no-unscoped-queries.d.ts.map +1 -0
- package/dist/guards/no-unscoped-queries.js +720 -0
- package/dist/guards/no-unscoped-queries.js.map +1 -0
- package/dist/guards/scan-utils.d.ts +28 -0
- package/dist/guards/scan-utils.d.ts.map +1 -0
- package/dist/guards/scan-utils.js +92 -0
- package/dist/guards/scan-utils.js.map +1 -0
- package/dist/guards/types.d.ts +28 -0
- package/dist/guards/types.d.ts.map +1 -0
- package/dist/guards/types.js +11 -0
- package/dist/guards/types.js.map +1 -0
- package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +25 -5
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +55 -21
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +11 -0
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/localization/default-messages.d.ts +5 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +5 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/hosted-model-experiment.d.ts +39 -0
- package/dist/observability/hosted-model-experiment.d.ts.map +1 -0
- package/dist/observability/hosted-model-experiment.js +90 -0
- package/dist/observability/hosted-model-experiment.js.map +1 -0
- package/dist/observability/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts.map +1 -1
- package/dist/observability/routes.js +16 -0
- package/dist/observability/routes.js.map +1 -1
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +4 -1
- package/dist/observability/store.js.map +1 -1
- package/dist/observability/traces.d.ts +6 -0
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +28 -2
- package/dist/observability/traces.js.map +1 -1
- package/dist/org/accept-pending.d.ts.map +1 -1
- package/dist/org/accept-pending.js +9 -1
- package/dist/org/accept-pending.js.map +1 -1
- package/dist/org/migrations.d.ts +7 -2
- package/dist/org/migrations.d.ts.map +1 -1
- package/dist/org/migrations.js +41 -0
- package/dist/org/migrations.js.map +1 -1
- package/dist/package-lifecycle/index.d.ts +2 -0
- package/dist/package-lifecycle/index.d.ts.map +1 -0
- package/dist/package-lifecycle/index.js +2 -0
- package/dist/package-lifecycle/index.js.map +1 -0
- package/dist/package-lifecycle/manifest.d.ts +24 -0
- package/dist/package-lifecycle/manifest.d.ts.map +1 -0
- package/dist/package-lifecycle/manifest.js +81 -0
- package/dist/package-lifecycle/manifest.js.map +1 -0
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/custom-registry.d.ts +32 -1
- package/dist/provider-api/custom-registry.d.ts.map +1 -1
- package/dist/provider-api/custom-registry.js +41 -1
- package/dist/provider-api/custom-registry.js.map +1 -1
- package/dist/provider-api/index.d.ts +1 -1
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +1 -1
- package/dist/provider-api/index.js.map +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +19 -1
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +43 -3
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/chat/search-chats.d.ts +1 -1
- package/dist/scripts/chat/search-chats.d.ts.map +1 -1
- package/dist/scripts/chat/search-chats.js +11 -8
- package/dist/scripts/chat/search-chats.js.map +1 -1
- package/dist/secrets/register-framework-secrets.js +1 -1
- package/dist/secrets/register-framework-secrets.js.map +1 -1
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +45 -27
- package/dist/secrets/storage.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +4 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +11 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +74 -19
- 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/core-routes-plugin.d.ts +3 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +36 -12
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/csrf.d.ts.map +1 -1
- package/dist/server/csrf.js +18 -5
- package/dist/server/csrf.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +34 -0
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/google-realtime-session.d.ts.map +1 -1
- package/dist/server/google-realtime-session.js +2 -34
- package/dist/server/google-realtime-session.js.map +1 -1
- package/dist/server/poll.d.ts.map +1 -1
- package/dist/server/poll.js +24 -2
- package/dist/server/poll.js.map +1 -1
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +64 -21
- package/dist/server/realtime-voice.js.map +1 -1
- package/dist/server/request-origin.d.ts +10 -0
- package/dist/server/request-origin.d.ts.map +1 -0
- package/dist/server/request-origin.js +60 -0
- package/dist/server/request-origin.js.map +1 -0
- package/dist/server/transcribe-voice.d.ts.map +1 -1
- package/dist/server/transcribe-voice.js +2 -48
- package/dist/server/transcribe-voice.js.map +1 -1
- package/dist/server/voice-providers-status.d.ts.map +1 -1
- package/dist/server/voice-providers-status.js +2 -3
- package/dist/server/voice-providers-status.js.map +1 -1
- package/dist/shared/cache-control.d.ts +4 -6
- package/dist/shared/cache-control.d.ts.map +1 -1
- package/dist/shared/cache-control.js +2 -7
- package/dist/shared/cache-control.js.map +1 -1
- package/dist/styles/agent-native.css +1 -0
- package/dist/styles/chat-history-list.css +313 -0
- package/dist/templates/default/package.json +2 -2
- package/dist/templates/headless/package.json +0 -1
- package/dist/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
- package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- package/dist/templates/workspace-core/package.json +0 -1
- package/dist/templates/workspace-root/package.json +0 -1
- package/dist/triggers/actions.d.ts.map +1 -1
- package/dist/triggers/actions.js +8 -3
- package/dist/triggers/actions.js.map +1 -1
- package/dist/triggers/types.d.ts +7 -1
- package/dist/triggers/types.d.ts.map +1 -1
- package/dist/triggers/types.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/audit-log.mdx +2 -1
- package/docs/content/automations.mdx +7 -7
- package/docs/content/creating-templates.mdx +1 -1
- package/docs/content/internationalization.mdx +2 -1
- package/docs/content/locales/ar-SA/audit-log.mdx +2 -1
- package/docs/content/locales/ar-SA/automations.mdx +7 -7
- package/docs/content/locales/ar-SA/getting-started.mdx +7 -1
- package/docs/content/locales/ar-SA/internationalization.mdx +1 -1
- package/docs/content/locales/ar-SA/package-lifecycle.mdx +19 -0
- package/docs/content/locales/ar-SA/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/ar-SA/security.mdx +8 -0
- package/docs/content/locales/de-DE/audit-log.mdx +2 -1
- package/docs/content/locales/de-DE/automations.mdx +7 -7
- package/docs/content/locales/de-DE/getting-started.mdx +7 -1
- package/docs/content/locales/de-DE/internationalization.mdx +1 -1
- package/docs/content/locales/de-DE/package-lifecycle.mdx +22 -0
- package/docs/content/locales/de-DE/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/de-DE/security.mdx +8 -0
- package/docs/content/locales/es-ES/audit-log.mdx +2 -1
- package/docs/content/locales/es-ES/automations.mdx +7 -7
- package/docs/content/locales/es-ES/getting-started.mdx +7 -1
- package/docs/content/locales/es-ES/internationalization.mdx +1 -1
- package/docs/content/locales/es-ES/package-lifecycle.mdx +22 -0
- package/docs/content/locales/es-ES/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/es-ES/security.mdx +8 -0
- package/docs/content/locales/fr-FR/audit-log.mdx +2 -1
- package/docs/content/locales/fr-FR/automations.mdx +7 -7
- package/docs/content/locales/fr-FR/getting-started.mdx +7 -1
- package/docs/content/locales/fr-FR/internationalization.mdx +1 -1
- package/docs/content/locales/fr-FR/package-lifecycle.mdx +21 -0
- package/docs/content/locales/fr-FR/sandbox-adapters.mdx +19 -8
- package/docs/content/locales/fr-FR/security.mdx +8 -0
- package/docs/content/locales/hi-IN/audit-log.mdx +2 -1
- package/docs/content/locales/hi-IN/automations.mdx +7 -7
- package/docs/content/locales/hi-IN/getting-started.mdx +7 -1
- package/docs/content/locales/hi-IN/internationalization.mdx +1 -1
- package/docs/content/locales/hi-IN/package-lifecycle.mdx +20 -0
- package/docs/content/locales/hi-IN/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/hi-IN/security.mdx +8 -0
- package/docs/content/locales/ja-JP/audit-log.mdx +2 -1
- package/docs/content/locales/ja-JP/automations.mdx +7 -7
- package/docs/content/locales/ja-JP/getting-started.mdx +7 -1
- package/docs/content/locales/ja-JP/internationalization.mdx +1 -1
- package/docs/content/locales/ja-JP/package-lifecycle.mdx +21 -0
- package/docs/content/locales/ja-JP/sandbox-adapters.mdx +17 -6
- package/docs/content/locales/ja-JP/security.mdx +8 -0
- package/docs/content/locales/ko-KR/audit-log.mdx +2 -1
- package/docs/content/locales/ko-KR/automations.mdx +7 -7
- package/docs/content/locales/ko-KR/getting-started.mdx +7 -1
- package/docs/content/locales/ko-KR/internationalization.mdx +1 -1
- package/docs/content/locales/ko-KR/package-lifecycle.mdx +20 -0
- package/docs/content/locales/ko-KR/sandbox-adapters.mdx +17 -6
- package/docs/content/locales/ko-KR/security.mdx +8 -0
- package/docs/content/locales/pt-BR/audit-log.mdx +2 -1
- package/docs/content/locales/pt-BR/automations.mdx +7 -7
- package/docs/content/locales/pt-BR/getting-started.mdx +7 -1
- package/docs/content/locales/pt-BR/internationalization.mdx +1 -1
- package/docs/content/locales/pt-BR/package-lifecycle.mdx +21 -0
- package/docs/content/locales/pt-BR/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/pt-BR/security.mdx +8 -0
- package/docs/content/locales/zh-CN/audit-log.mdx +2 -1
- package/docs/content/locales/zh-CN/automations.mdx +7 -7
- package/docs/content/locales/zh-CN/getting-started.mdx +6 -4
- package/docs/content/locales/zh-CN/internationalization.mdx +1 -1
- package/docs/content/locales/zh-CN/package-lifecycle.mdx +19 -0
- package/docs/content/locales/zh-CN/sandbox-adapters.mdx +17 -6
- package/docs/content/locales/zh-CN/security.mdx +8 -0
- package/docs/content/locales/zh-TW/audit-log.mdx +2 -1
- package/docs/content/locales/zh-TW/automations.mdx +7 -7
- package/docs/content/locales/zh-TW/getting-started.mdx +6 -4
- package/docs/content/locales/zh-TW/internationalization.mdx +1 -1
- package/docs/content/locales/zh-TW/package-lifecycle.mdx +19 -0
- package/docs/content/locales/zh-TW/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/zh-TW/security.mdx +8 -0
- package/docs/content/package-lifecycle.mdx +51 -0
- package/docs/content/sandbox-adapters.mdx +16 -5
- package/package.json +12 -3
- package/src/templates/default/package.json +2 -2
- package/src/templates/headless/package.json +0 -1
- package/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
- package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
- package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- package/src/templates/workspace-core/package.json +0 -1
- package/src/templates/workspace-root/package.json +0 -1
- package/corpus/templates/slides/app/components/ui/toast.tsx +0 -1
- package/corpus/templates/slides/app/components/ui/toaster.tsx +0 -1
- package/corpus/templates/slides/app/hooks/use-toast.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-agent-runs.d.ts","sourceRoot":"","sources":["../../src/cli/code-agent-runs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAElF,MAAM,MAAM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C,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAChE,kBAAkB,GAAG,IAAI,CAe3B;AAED,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAU7E;AAED,wBAAgB,yBAAyB,CACvC,MAAM,CAAC,EAAE,MAAM,GACd,kBAAkB,GAAG,IAAI,CAE3B;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,mCAAmC,GACzC,wBAAwB,CAoB1B;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,GACZ,wBAAwB,EAAE,CAS5B;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAErE;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,2BAA2B,GACjC,wBAAwB,GAAG,IAAI,CAuBjC;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,GACZ,wBAAwB,GAAG,IAAI,CAcjC"}
|
|
@@ -142,6 +142,7 @@ export function appendCodeAgentTranscriptEvent(input) {
|
|
|
142
142
|
message: input.message,
|
|
143
143
|
createdAt,
|
|
144
144
|
metadata: input.metadata,
|
|
145
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
145
146
|
};
|
|
146
147
|
fs.mkdirSync(codeAgentTranscriptsDir(), { recursive: true });
|
|
147
148
|
fs.appendFileSync(codeAgentRunTranscriptPath(input.runId), `${JSON.stringify(event)}\n`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-agent-runs.js","sourceRoot":"","sources":["../../src/cli/code-agent-runs.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAaxB,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,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K,QAAQ;YAC/B,CAAC,IAAI;YACL,OAAO,OAAO,KAAK,QAAQ;YAC3B,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,EACnC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO;YACL,GAAI,KAA2C;YAC/C,IAAI;YACJ,OAAO;SACoB,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,UAAU,KAAK,OAAO,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IACrE,IAAI,UAAU,KAAK,WAAW;QAAE,OAAO,QAAQ,CAAC;IAChD,IAAI,qBAAqB,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,qBAAqB,CAC5B,KAAc;IAEd,OAAO,CACL,KAAK,KAAK,MAAM;QAChB,KAAK,KAAK,QAAQ;QAClB,KAAK,KAAK,MAAM;QAChB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,QAAQ,CACnB,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import crypto from \"crypto\";\nimport fs from \"fs\";\nimport os from \"os\";\nimport path from \"path\";\n\nimport type { AgentPromptAttachment } from \"../code-agents/prompt-attachments.js\";\n\nexport type CodeAgentRunStatus =\n | \"queued\"\n | \"running\"\n | \"paused\"\n | \"needs-approval\"\n | \"completed\"\n | \"errored\"\n | \"unknown\";\n\nexport const CODE_AGENT_PERMISSION_MODES = [\n \"read-only\",\n \"ask-before-edit\",\n \"auto-edit\",\n \"full-auto\",\n] as const;\n\nexport type CodeAgentPermissionMode =\n (typeof CODE_AGENT_PERMISSION_MODES)[number];\n\nexport interface CodeAgentRunProgress {\n label?: string;\n completed: number;\n total: number;\n failed?: number;\n percent: number;\n}\n\nexport interface CodeAgentRunDetail {\n label: string;\n value: string;\n}\n\nexport type CodeAgentFollowUpMode = \"immediate\" | \"queued\";\n\nexport interface CodeAgentPendingFollowUp {\n id: string;\n prompt: string;\n mode: CodeAgentFollowUpMode;\n createdAt: string;\n eventId?: string;\n permissionMode?: CodeAgentPermissionMode;\n source?: string;\n attachments?: AgentPromptAttachment[];\n}\n\nexport interface CodeAgentRunRecord {\n schemaVersion: 1;\n id: string;\n goalId: string;\n title: string;\n subtitle?: string;\n status: CodeAgentRunStatus;\n phase?: string;\n needsApproval?: boolean;\n progress?: CodeAgentRunProgress;\n permissionMode?: CodeAgentPermissionMode;\n details?: CodeAgentRunDetail[];\n artifactRoot?: string;\n surfaceUrl?: string;\n cwd: string;\n createdAt: string;\n updatedAt: string;\n metadata?: Record<string, unknown>;\n}\n\nexport type CodeAgentTranscriptEventKind =\n | \"user\"\n | \"system\"\n | \"note\"\n | \"artifact\"\n | \"status\";\n\nexport interface CodeAgentTranscriptEvent {\n schemaVersion: 1;\n id: string;\n runId: string;\n kind: CodeAgentTranscriptEventKind;\n message: string;\n createdAt: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface CreateCodeAgentRunInput {\n goalId: string;\n title: string;\n subtitle?: string;\n status?: CodeAgentRunStatus;\n phase?: string;\n needsApproval?: boolean;\n progress?: CodeAgentRunProgress;\n permissionMode?: CodeAgentPermissionMode;\n details?: CodeAgentRunDetail[];\n artifactRoot?: string;\n surfaceUrl?: string;\n cwd?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface AppendCodeAgentTranscriptEventInput {\n runId: string;\n kind: CodeAgentTranscriptEventKind;\n message: string;\n createdAt?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface QueueCodeAgentFollowUpInput {\n runId: string;\n prompt: string;\n mode: CodeAgentFollowUpMode;\n eventId?: string;\n permissionMode?: CodeAgentPermissionMode;\n source?: string;\n createdAt?: string;\n attachments?: AgentPromptAttachment[];\n}\n\nconst STORE_ENV = \"AGENT_NATIVE_CODE_AGENTS_HOME\";\n\nexport function codeAgentStoreRoot(): string {\n return path.resolve(\n process.env[STORE_ENV] ??\n path.join(os.homedir(), \".agent-native\", \"code-agents\"),\n );\n}\n\nexport function codeAgentRunsDir(): string {\n return path.join(codeAgentStoreRoot(), \"runs\");\n}\n\nexport function codeAgentRunArtifactsDir(runId: string): string {\n return path.join(codeAgentStoreRoot(), \"artifacts\", runId);\n}\n\nexport function codeAgentTranscriptsDir(): string {\n return path.join(codeAgentStoreRoot(), \"transcripts\");\n}\n\nexport function codeAgentRunTranscriptPath(runId: string): string {\n return path.join(codeAgentTranscriptsDir(), `${runId}.jsonl`);\n}\n\n// --------------- Command allowlist ---------------\n\nconst COMMAND_ALLOWLIST_FILENAME = \"command-allowlist.json\";\n\nexport function codeAgentCommandAllowlistPath(): string {\n return path.join(codeAgentStoreRoot(), COMMAND_ALLOWLIST_FILENAME);\n}\n\n/**\n * Load the per-store command allowlist. Returns an array of exact command\n * strings the user has marked \"always allow\".\n */\nexport function readCodeAgentCommandAllowlist(): string[] {\n try {\n const raw = JSON.parse(\n fs.readFileSync(codeAgentCommandAllowlistPath(), \"utf-8\"),\n ) as unknown;\n if (!Array.isArray(raw)) return [];\n return raw.filter((entry): entry is string => typeof entry === \"string\");\n } catch {\n return [];\n }\n}\n\n/**\n * Persist a command to the per-store allowlist so future identical commands\n * are auto-approved without a prompt. Deduplicates by exact string match.\n */\nexport function addCodeAgentCommandToAllowlist(command: string): void {\n const current = readCodeAgentCommandAllowlist();\n if (current.includes(command)) return;\n const next = [...current, command];\n fs.mkdirSync(codeAgentStoreRoot(), { recursive: true });\n fs.writeFileSync(\n codeAgentCommandAllowlistPath(),\n JSON.stringify(next, null, 2),\n );\n}\n\n/** Return true if `command` is in the stored allowlist. */\nexport function isCodeAgentCommandAllowed(command: string): boolean {\n return readCodeAgentCommandAllowlist().includes(command);\n}\n\nexport function createCodeAgentRunRecord(\n input: CreateCodeAgentRunInput,\n): CodeAgentRunRecord {\n const now = new Date().toISOString();\n const id = `${input.goalId}-${timestampSlug(now)}-${crypto.randomUUID().slice(0, 8)}`;\n const record: CodeAgentRunRecord = {\n schemaVersion: 1,\n id,\n goalId: input.goalId,\n title: input.title,\n subtitle: input.subtitle,\n status: input.status ?? \"queued\",\n phase: input.phase,\n needsApproval: input.needsApproval,\n progress: input.progress,\n permissionMode: input.permissionMode,\n details: input.details,\n artifactRoot: input.artifactRoot,\n surfaceUrl: input.surfaceUrl,\n cwd: input.cwd ?? process.cwd(),\n createdAt: now,\n updatedAt: now,\n metadata: input.metadata,\n };\n writeCodeAgentRunRecord(record);\n return record;\n}\n\nexport function normalizeCodeAgentPermissionMode(\n value: unknown,\n): CodeAgentPermissionMode | null {\n if (typeof value !== \"string\") return null;\n return CODE_AGENT_PERMISSION_MODES.includes(value as CodeAgentPermissionMode)\n ? (value as CodeAgentPermissionMode)\n : null;\n}\n\nexport function writeCodeAgentRunRecord(record: CodeAgentRunRecord): void {\n fs.mkdirSync(codeAgentRunsDir(), { recursive: true });\n fs.writeFileSync(\n codeAgentRunRecordPath(record.id),\n `${JSON.stringify(record, null, 2)}\\n`,\n );\n}\n\nexport function getCodeAgentRunRecord(\n runId: string,\n): CodeAgentRunRecord | null {\n return readRunFile(codeAgentRunRecordPath(runId));\n}\n\nexport function updateCodeAgentRunRecord(\n runId: string,\n updates:\n | Partial<CodeAgentRunRecord>\n | ((record: CodeAgentRunRecord) => Partial<CodeAgentRunRecord>),\n): CodeAgentRunRecord | null {\n const record = getCodeAgentRunRecord(runId);\n if (!record) return null;\n const patch = typeof updates === \"function\" ? updates(record) : updates;\n const next: CodeAgentRunRecord = {\n ...record,\n ...patch,\n metadata: {\n ...(record.metadata ?? {}),\n ...(patch.metadata ?? {}),\n },\n updatedAt: patch.updatedAt ?? new Date().toISOString(),\n };\n writeCodeAgentRunRecord(next);\n return next;\n}\n\nexport function listCodeAgentRunRecords(goalId?: string): CodeAgentRunRecord[] {\n const dir = codeAgentRunsDir();\n if (!fs.existsSync(dir)) return [];\n return fs\n .readdirSync(dir)\n .filter((file) => file.endsWith(\".json\"))\n .map((file) => readRunFile(path.join(dir, file)))\n .filter((run): run is CodeAgentRunRecord => Boolean(run))\n .filter((run) => !goalId || run.goalId === goalId)\n .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));\n}\n\nexport function getLastCodeAgentRunRecord(\n goalId?: string,\n): CodeAgentRunRecord | null {\n return listCodeAgentRunRecords(goalId)[0] ?? null;\n}\n\nexport function appendCodeAgentTranscriptEvent(\n input: AppendCodeAgentTranscriptEventInput,\n): CodeAgentTranscriptEvent {\n const createdAt = input.createdAt ?? new Date().toISOString();\n const event: CodeAgentTranscriptEvent = {\n schemaVersion: 1,\n id: `evt-${timestampSlug(createdAt)}-${crypto.randomUUID().slice(0, 8)}`,\n runId: input.runId,\n kind: input.kind,\n message: input.message,\n createdAt,\n metadata: input.metadata,\n };\n\n fs.mkdirSync(codeAgentTranscriptsDir(), { recursive: true });\n fs.appendFileSync(\n codeAgentRunTranscriptPath(input.runId),\n `${JSON.stringify(event)}\\n`,\n );\n touchCodeAgentRunRecord(input.runId, createdAt);\n return event;\n}\n\nexport function listCodeAgentTranscriptEvents(\n runId: string,\n): CodeAgentTranscriptEvent[] {\n const transcriptPath = codeAgentRunTranscriptPath(runId);\n if (!fs.existsSync(transcriptPath)) return [];\n return fs\n .readFileSync(transcriptPath, \"utf-8\")\n .split(/\\r?\\n/)\n .filter(Boolean)\n .map(readTranscriptLine)\n .filter((event): event is CodeAgentTranscriptEvent => Boolean(event));\n}\n\nexport function isActiveCodeAgentRun(run: CodeAgentRunRecord): boolean {\n return run.status === \"running\" || run.status === \"needs-approval\";\n}\n\nexport function queueCodeAgentFollowUp(\n input: QueueCodeAgentFollowUpInput,\n): CodeAgentPendingFollowUp | null {\n const createdAt = input.createdAt ?? new Date().toISOString();\n const followUp: CodeAgentPendingFollowUp = {\n id: `followup-${timestampSlug(createdAt)}-${crypto.randomUUID().slice(0, 8)}`,\n prompt: input.prompt,\n mode: input.mode,\n createdAt,\n eventId: input.eventId,\n permissionMode: input.permissionMode,\n source: input.source,\n ...(input.attachments && input.attachments.length > 0\n ? { attachments: input.attachments }\n : {}),\n };\n const updated = updateCodeAgentRunRecord(input.runId, (record) => ({\n metadata: {\n pendingFollowUps: [\n ...readPendingFollowUps(record.metadata?.pendingFollowUps),\n followUp,\n ],\n },\n }));\n return updated ? followUp : null;\n}\n\nexport function dequeueCodeAgentFollowUp(\n runId: string,\n): CodeAgentPendingFollowUp | null {\n let selected: CodeAgentPendingFollowUp | null = null;\n updateCodeAgentRunRecord(runId, (record) => {\n const [first, ...rest] = readPendingFollowUps(\n record.metadata?.pendingFollowUps,\n );\n selected = first ?? null;\n return {\n metadata: {\n pendingFollowUps: rest.length > 0 ? rest : undefined,\n },\n };\n });\n return selected;\n}\n\nfunction codeAgentRunRecordPath(runId: string): string {\n return path.join(codeAgentRunsDir(), `${runId}.json`);\n}\n\nfunction readPendingFollowUps(value: unknown): CodeAgentPendingFollowUp[] {\n if (!Array.isArray(value)) return [];\n return value\n .map((item): CodeAgentPendingFollowUp | null => {\n if (!item || typeof item !== \"object\") return null;\n const candidate = item as Record<string, unknown>;\n if (\n typeof candidate.id !== \"string\" ||\n typeof candidate.prompt !== \"string\" ||\n typeof candidate.createdAt !== \"string\" ||\n (candidate.mode !== \"immediate\" && candidate.mode !== \"queued\")\n ) {\n return null;\n }\n return {\n id: candidate.id,\n prompt: candidate.prompt,\n mode: candidate.mode,\n createdAt: candidate.createdAt,\n eventId:\n typeof candidate.eventId === \"string\" ? candidate.eventId : undefined,\n permissionMode:\n normalizeCodeAgentPermissionMode(candidate.permissionMode) ??\n undefined,\n source:\n typeof candidate.source === \"string\" ? candidate.source : undefined,\n } satisfies CodeAgentPendingFollowUp;\n })\n .filter((item): item is CodeAgentPendingFollowUp => Boolean(item));\n}\n\nfunction touchCodeAgentRunRecord(runId: string, updatedAt: string): void {\n const record = readRunFile(codeAgentRunRecordPath(runId));\n if (!record) return;\n writeCodeAgentRunRecord({ ...record, updatedAt });\n}\n\nfunction readRunFile(filePath: string): CodeAgentRunRecord | null {\n try {\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as unknown;\n if (!raw || typeof raw !== \"object\") return null;\n const record = raw as Partial<CodeAgentRunRecord>;\n if (\n record.schemaVersion !== 1 ||\n typeof record.id !== \"string\" ||\n typeof record.goalId !== \"string\" ||\n typeof record.title !== \"string\" ||\n typeof record.status !== \"string\" ||\n typeof record.cwd !== \"string\" ||\n typeof record.createdAt !== \"string\" ||\n typeof record.updatedAt !== \"string\"\n ) {\n return null;\n }\n return record as CodeAgentRunRecord;\n } catch {\n return null;\n }\n}\n\nfunction readTranscriptLine(line: string): CodeAgentTranscriptEvent | null {\n try {\n const raw = JSON.parse(line) as unknown;\n if (!raw || typeof raw !== \"object\") return null;\n const event = raw as Partial<CodeAgentTranscriptEvent> & {\n type?: unknown;\n role?: unknown;\n text?: unknown;\n content?: unknown;\n };\n const kind = isTranscriptEventKind(event.kind)\n ? event.kind\n : normalizeTranscriptKind(event.type ?? event.role);\n const message =\n typeof event.message === \"string\"\n ? event.message\n : typeof event.text === \"string\"\n ? event.text\n : typeof event.content === \"string\"\n ? event.content\n : undefined;\n if (\n event.schemaVersion !== 1 ||\n typeof event.id !== \"string\" ||\n typeof event.runId !== \"string\" ||\n !kind ||\n typeof message !== \"string\" ||\n typeof event.createdAt !== \"string\"\n ) {\n return null;\n }\n return {\n ...(event as Partial<CodeAgentTranscriptEvent>),\n kind,\n message,\n } as CodeAgentTranscriptEvent;\n } catch {\n return null;\n }\n}\n\nfunction normalizeTranscriptKind(\n value: unknown,\n): CodeAgentTranscriptEventKind | null {\n if (typeof value !== \"string\") return null;\n const normalized = value.toLowerCase();\n if (normalized === \"human\" || normalized === \"prompt\") return \"user\";\n if (normalized === \"assistant\") return \"system\";\n if (isTranscriptEventKind(normalized)) return normalized;\n return null;\n}\n\nfunction isTranscriptEventKind(\n value: unknown,\n): value is CodeAgentTranscriptEventKind {\n return (\n value === \"user\" ||\n value === \"system\" ||\n value === \"note\" ||\n value === \"artifact\" ||\n value === \"status\"\n );\n}\n\nfunction timestampSlug(value: string): string {\n return value.replace(/\\D/g, \"\").slice(0, 14);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"code-agent-runs.js","sourceRoot":"","sources":["../../src/cli/code-agent-runs.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAaxB,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,WAAW;IACX,iBAAiB;IACjB,WAAW;IACX,WAAW;CACH,CAAC;AAoHX,MAAM,SAAS,GAAG,+BAA+B,CAAC;AAElD,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CAAC,OAAO,CACjB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,aAAa,CAAC,CAC1D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,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vC,IAAI,UAAU,KAAK,OAAO,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IACrE,IAAI,UAAU,KAAK,WAAW;QAAE,OAAO,QAAQ,CAAC;IAChD,IAAI,qBAAqB,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,qBAAqB,CAC5B,KAAc;IAEd,OAAO,CACL,KAAK,KAAK,MAAM;QAChB,KAAK,KAAK,QAAQ;QAClB,KAAK,KAAK,MAAM;QAChB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,QAAQ,CACnB,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import crypto from \"crypto\";\nimport fs from \"fs\";\nimport os from \"os\";\nimport path from \"path\";\n\nimport type { AgentPromptAttachment } from \"../code-agents/prompt-attachments.js\";\n\nexport type CodeAgentRunStatus =\n | \"queued\"\n | \"running\"\n | \"paused\"\n | \"needs-approval\"\n | \"completed\"\n | \"errored\"\n | \"unknown\";\n\nexport const CODE_AGENT_PERMISSION_MODES = [\n \"read-only\",\n \"ask-before-edit\",\n \"auto-edit\",\n \"full-auto\",\n] as const;\n\nexport type CodeAgentPermissionMode =\n (typeof CODE_AGENT_PERMISSION_MODES)[number];\n\nexport interface CodeAgentRunProgress {\n label?: string;\n completed: number;\n total: number;\n failed?: number;\n percent: number;\n}\n\nexport interface CodeAgentRunDetail {\n label: string;\n value: string;\n}\n\nexport type CodeAgentFollowUpMode = \"immediate\" | \"queued\";\n\nexport interface CodeAgentPendingFollowUp {\n id: string;\n prompt: string;\n mode: CodeAgentFollowUpMode;\n createdAt: string;\n eventId?: string;\n permissionMode?: CodeAgentPermissionMode;\n source?: string;\n attachments?: AgentPromptAttachment[];\n}\n\nexport interface CodeAgentRunRecord {\n schemaVersion: 1;\n id: string;\n goalId: string;\n title: string;\n subtitle?: string;\n status: CodeAgentRunStatus;\n phase?: string;\n needsApproval?: boolean;\n progress?: CodeAgentRunProgress;\n permissionMode?: CodeAgentPermissionMode;\n details?: CodeAgentRunDetail[];\n artifactRoot?: string;\n surfaceUrl?: string;\n cwd: string;\n createdAt: string;\n updatedAt: string;\n metadata?: Record<string, unknown>;\n}\n\nexport type CodeAgentTranscriptEventKind =\n | \"user\"\n | \"system\"\n | \"note\"\n | \"artifact\"\n | \"status\";\n\n/**\n * Structured, machine-checkable marker for transcript events that need\n * special handling in the UI beyond free-text matching. `\"credential-gap\"`\n * marks the status event the executor appends when no LLM provider key (or\n * Codex CLI login) is available; consumers should prefer this field over\n * regex-matching `message` (see `isCredentialGapCodeAgentEvent` in\n * `../code-agents/transcript-normalizer.js`). Optional so older, already\n * persisted JSONL transcripts without the field keep parsing unchanged.\n */\nexport type CodeAgentTranscriptEventSignal = \"credential-gap\";\n\nexport interface CodeAgentTranscriptEvent {\n schemaVersion: 1;\n id: string;\n runId: string;\n kind: CodeAgentTranscriptEventKind;\n message: string;\n createdAt: string;\n metadata?: Record<string, unknown>;\n signal?: CodeAgentTranscriptEventSignal;\n}\n\nexport interface CreateCodeAgentRunInput {\n goalId: string;\n title: string;\n subtitle?: string;\n status?: CodeAgentRunStatus;\n phase?: string;\n needsApproval?: boolean;\n progress?: CodeAgentRunProgress;\n permissionMode?: CodeAgentPermissionMode;\n details?: CodeAgentRunDetail[];\n artifactRoot?: string;\n surfaceUrl?: string;\n cwd?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface AppendCodeAgentTranscriptEventInput {\n runId: string;\n kind: CodeAgentTranscriptEventKind;\n message: string;\n createdAt?: string;\n metadata?: Record<string, unknown>;\n signal?: CodeAgentTranscriptEventSignal;\n}\n\nexport interface QueueCodeAgentFollowUpInput {\n runId: string;\n prompt: string;\n mode: CodeAgentFollowUpMode;\n eventId?: string;\n permissionMode?: CodeAgentPermissionMode;\n source?: string;\n createdAt?: string;\n attachments?: AgentPromptAttachment[];\n}\n\nconst STORE_ENV = \"AGENT_NATIVE_CODE_AGENTS_HOME\";\n\nexport function codeAgentStoreRoot(): string {\n return path.resolve(\n process.env[STORE_ENV] ??\n path.join(os.homedir(), \".agent-native\", \"code-agents\"),\n );\n}\n\nexport function codeAgentRunsDir(): string {\n return path.join(codeAgentStoreRoot(), \"runs\");\n}\n\nexport function codeAgentRunArtifactsDir(runId: string): string {\n return path.join(codeAgentStoreRoot(), \"artifacts\", runId);\n}\n\nexport function codeAgentTranscriptsDir(): string {\n return path.join(codeAgentStoreRoot(), \"transcripts\");\n}\n\nexport function codeAgentRunTranscriptPath(runId: string): string {\n return path.join(codeAgentTranscriptsDir(), `${runId}.jsonl`);\n}\n\n// --------------- Command allowlist ---------------\n\nconst COMMAND_ALLOWLIST_FILENAME = \"command-allowlist.json\";\n\nexport function codeAgentCommandAllowlistPath(): string {\n return path.join(codeAgentStoreRoot(), COMMAND_ALLOWLIST_FILENAME);\n}\n\n/**\n * Load the per-store command allowlist. Returns an array of exact command\n * strings the user has marked \"always allow\".\n */\nexport function readCodeAgentCommandAllowlist(): string[] {\n try {\n const raw = JSON.parse(\n fs.readFileSync(codeAgentCommandAllowlistPath(), \"utf-8\"),\n ) as unknown;\n if (!Array.isArray(raw)) return [];\n return raw.filter((entry): entry is string => typeof entry === \"string\");\n } catch {\n return [];\n }\n}\n\n/**\n * Persist a command to the per-store allowlist so future identical commands\n * are auto-approved without a prompt. Deduplicates by exact string match.\n */\nexport function addCodeAgentCommandToAllowlist(command: string): void {\n const current = readCodeAgentCommandAllowlist();\n if (current.includes(command)) return;\n const next = [...current, command];\n fs.mkdirSync(codeAgentStoreRoot(), { recursive: true });\n fs.writeFileSync(\n codeAgentCommandAllowlistPath(),\n JSON.stringify(next, null, 2),\n );\n}\n\n/** Return true if `command` is in the stored allowlist. */\nexport function isCodeAgentCommandAllowed(command: string): boolean {\n return readCodeAgentCommandAllowlist().includes(command);\n}\n\nexport function createCodeAgentRunRecord(\n input: CreateCodeAgentRunInput,\n): CodeAgentRunRecord {\n const now = new Date().toISOString();\n const id = `${input.goalId}-${timestampSlug(now)}-${crypto.randomUUID().slice(0, 8)}`;\n const record: CodeAgentRunRecord = {\n schemaVersion: 1,\n id,\n goalId: input.goalId,\n title: input.title,\n subtitle: input.subtitle,\n status: input.status ?? \"queued\",\n phase: input.phase,\n needsApproval: input.needsApproval,\n progress: input.progress,\n permissionMode: input.permissionMode,\n details: input.details,\n artifactRoot: input.artifactRoot,\n surfaceUrl: input.surfaceUrl,\n cwd: input.cwd ?? process.cwd(),\n createdAt: now,\n updatedAt: now,\n metadata: input.metadata,\n };\n writeCodeAgentRunRecord(record);\n return record;\n}\n\nexport function normalizeCodeAgentPermissionMode(\n value: unknown,\n): CodeAgentPermissionMode | null {\n if (typeof value !== \"string\") return null;\n return CODE_AGENT_PERMISSION_MODES.includes(value as CodeAgentPermissionMode)\n ? (value as CodeAgentPermissionMode)\n : null;\n}\n\nexport function writeCodeAgentRunRecord(record: CodeAgentRunRecord): void {\n fs.mkdirSync(codeAgentRunsDir(), { recursive: true });\n fs.writeFileSync(\n codeAgentRunRecordPath(record.id),\n `${JSON.stringify(record, null, 2)}\\n`,\n );\n}\n\nexport function getCodeAgentRunRecord(\n runId: string,\n): CodeAgentRunRecord | null {\n return readRunFile(codeAgentRunRecordPath(runId));\n}\n\nexport function updateCodeAgentRunRecord(\n runId: string,\n updates:\n | Partial<CodeAgentRunRecord>\n | ((record: CodeAgentRunRecord) => Partial<CodeAgentRunRecord>),\n): CodeAgentRunRecord | null {\n const record = getCodeAgentRunRecord(runId);\n if (!record) return null;\n const patch = typeof updates === \"function\" ? updates(record) : updates;\n const next: CodeAgentRunRecord = {\n ...record,\n ...patch,\n metadata: {\n ...(record.metadata ?? {}),\n ...(patch.metadata ?? {}),\n },\n updatedAt: patch.updatedAt ?? new Date().toISOString(),\n };\n writeCodeAgentRunRecord(next);\n return next;\n}\n\nexport function listCodeAgentRunRecords(goalId?: string): CodeAgentRunRecord[] {\n const dir = codeAgentRunsDir();\n if (!fs.existsSync(dir)) return [];\n return fs\n .readdirSync(dir)\n .filter((file) => file.endsWith(\".json\"))\n .map((file) => readRunFile(path.join(dir, file)))\n .filter((run): run is CodeAgentRunRecord => Boolean(run))\n .filter((run) => !goalId || run.goalId === goalId)\n .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));\n}\n\nexport function getLastCodeAgentRunRecord(\n goalId?: string,\n): CodeAgentRunRecord | null {\n return listCodeAgentRunRecords(goalId)[0] ?? null;\n}\n\nexport function appendCodeAgentTranscriptEvent(\n input: AppendCodeAgentTranscriptEventInput,\n): CodeAgentTranscriptEvent {\n const createdAt = input.createdAt ?? new Date().toISOString();\n const event: CodeAgentTranscriptEvent = {\n schemaVersion: 1,\n id: `evt-${timestampSlug(createdAt)}-${crypto.randomUUID().slice(0, 8)}`,\n runId: input.runId,\n kind: input.kind,\n message: input.message,\n createdAt,\n metadata: input.metadata,\n ...(input.signal ? { signal: input.signal } : {}),\n };\n\n fs.mkdirSync(codeAgentTranscriptsDir(), { recursive: true });\n fs.appendFileSync(\n codeAgentRunTranscriptPath(input.runId),\n `${JSON.stringify(event)}\\n`,\n );\n touchCodeAgentRunRecord(input.runId, createdAt);\n return event;\n}\n\nexport function listCodeAgentTranscriptEvents(\n runId: string,\n): CodeAgentTranscriptEvent[] {\n const transcriptPath = codeAgentRunTranscriptPath(runId);\n if (!fs.existsSync(transcriptPath)) return [];\n return fs\n .readFileSync(transcriptPath, \"utf-8\")\n .split(/\\r?\\n/)\n .filter(Boolean)\n .map(readTranscriptLine)\n .filter((event): event is CodeAgentTranscriptEvent => Boolean(event));\n}\n\nexport function isActiveCodeAgentRun(run: CodeAgentRunRecord): boolean {\n return run.status === \"running\" || run.status === \"needs-approval\";\n}\n\nexport function queueCodeAgentFollowUp(\n input: QueueCodeAgentFollowUpInput,\n): CodeAgentPendingFollowUp | null {\n const createdAt = input.createdAt ?? new Date().toISOString();\n const followUp: CodeAgentPendingFollowUp = {\n id: `followup-${timestampSlug(createdAt)}-${crypto.randomUUID().slice(0, 8)}`,\n prompt: input.prompt,\n mode: input.mode,\n createdAt,\n eventId: input.eventId,\n permissionMode: input.permissionMode,\n source: input.source,\n ...(input.attachments && input.attachments.length > 0\n ? { attachments: input.attachments }\n : {}),\n };\n const updated = updateCodeAgentRunRecord(input.runId, (record) => ({\n metadata: {\n pendingFollowUps: [\n ...readPendingFollowUps(record.metadata?.pendingFollowUps),\n followUp,\n ],\n },\n }));\n return updated ? followUp : null;\n}\n\nexport function dequeueCodeAgentFollowUp(\n runId: string,\n): CodeAgentPendingFollowUp | null {\n let selected: CodeAgentPendingFollowUp | null = null;\n updateCodeAgentRunRecord(runId, (record) => {\n const [first, ...rest] = readPendingFollowUps(\n record.metadata?.pendingFollowUps,\n );\n selected = first ?? null;\n return {\n metadata: {\n pendingFollowUps: rest.length > 0 ? rest : undefined,\n },\n };\n });\n return selected;\n}\n\nfunction codeAgentRunRecordPath(runId: string): string {\n return path.join(codeAgentRunsDir(), `${runId}.json`);\n}\n\nfunction readPendingFollowUps(value: unknown): CodeAgentPendingFollowUp[] {\n if (!Array.isArray(value)) return [];\n return value\n .map((item): CodeAgentPendingFollowUp | null => {\n if (!item || typeof item !== \"object\") return null;\n const candidate = item as Record<string, unknown>;\n if (\n typeof candidate.id !== \"string\" ||\n typeof candidate.prompt !== \"string\" ||\n typeof candidate.createdAt !== \"string\" ||\n (candidate.mode !== \"immediate\" && candidate.mode !== \"queued\")\n ) {\n return null;\n }\n return {\n id: candidate.id,\n prompt: candidate.prompt,\n mode: candidate.mode,\n createdAt: candidate.createdAt,\n eventId:\n typeof candidate.eventId === \"string\" ? candidate.eventId : undefined,\n permissionMode:\n normalizeCodeAgentPermissionMode(candidate.permissionMode) ??\n undefined,\n source:\n typeof candidate.source === \"string\" ? candidate.source : undefined,\n } satisfies CodeAgentPendingFollowUp;\n })\n .filter((item): item is CodeAgentPendingFollowUp => Boolean(item));\n}\n\nfunction touchCodeAgentRunRecord(runId: string, updatedAt: string): void {\n const record = readRunFile(codeAgentRunRecordPath(runId));\n if (!record) return;\n writeCodeAgentRunRecord({ ...record, updatedAt });\n}\n\nfunction readRunFile(filePath: string): CodeAgentRunRecord | null {\n try {\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as unknown;\n if (!raw || typeof raw !== \"object\") return null;\n const record = raw as Partial<CodeAgentRunRecord>;\n if (\n record.schemaVersion !== 1 ||\n typeof record.id !== \"string\" ||\n typeof record.goalId !== \"string\" ||\n typeof record.title !== \"string\" ||\n typeof record.status !== \"string\" ||\n typeof record.cwd !== \"string\" ||\n typeof record.createdAt !== \"string\" ||\n typeof record.updatedAt !== \"string\"\n ) {\n return null;\n }\n return record as CodeAgentRunRecord;\n } catch {\n return null;\n }\n}\n\nfunction readTranscriptLine(line: string): CodeAgentTranscriptEvent | null {\n try {\n const raw = JSON.parse(line) as unknown;\n if (!raw || typeof raw !== \"object\") return null;\n const event = raw as Partial<CodeAgentTranscriptEvent> & {\n type?: unknown;\n role?: unknown;\n text?: unknown;\n content?: unknown;\n };\n const kind = isTranscriptEventKind(event.kind)\n ? event.kind\n : normalizeTranscriptKind(event.type ?? event.role);\n const message =\n typeof event.message === \"string\"\n ? event.message\n : typeof event.text === \"string\"\n ? event.text\n : typeof event.content === \"string\"\n ? event.content\n : undefined;\n if (\n event.schemaVersion !== 1 ||\n typeof event.id !== \"string\" ||\n typeof event.runId !== \"string\" ||\n !kind ||\n typeof message !== \"string\" ||\n typeof event.createdAt !== \"string\"\n ) {\n return null;\n }\n return {\n ...(event as Partial<CodeAgentTranscriptEvent>),\n kind,\n message,\n } as CodeAgentTranscriptEvent;\n } catch {\n return null;\n }\n}\n\nfunction normalizeTranscriptKind(\n value: unknown,\n): CodeAgentTranscriptEventKind | null {\n if (typeof value !== \"string\") return null;\n const normalized = value.toLowerCase();\n if (normalized === \"human\" || normalized === \"prompt\") return \"user\";\n if (normalized === \"assistant\") return \"system\";\n if (isTranscriptEventKind(normalized)) return normalized;\n return null;\n}\n\nfunction isTranscriptEventKind(\n value: unknown,\n): value is CodeAgentTranscriptEventKind {\n return (\n value === \"user\" ||\n value === \"system\" ||\n value === \"note\" ||\n value === \"artifact\" ||\n value === \"status\"\n );\n}\n\nfunction timestampSlug(value: string): string {\n return value.replace(/\\D/g, \"\").slice(0, 14);\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type GuardName = "no-drizzle-push" | "no-unscoped-credentials" | "no-unscoped-queries" | "no-env-credentials" | "db-tool-scoping" | "no-env-mutation" | "no-localhost-fallback";
|
|
2
|
+
export declare const ALL_GUARD_NAMES: GuardName[];
|
|
3
|
+
export interface DoctorConfig {
|
|
4
|
+
disabledGuards: string[];
|
|
5
|
+
dbToolScopingDenylist: Record<string, string>;
|
|
6
|
+
failOnBuild: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface DoctorFinding {
|
|
9
|
+
guard: string;
|
|
10
|
+
file: string;
|
|
11
|
+
line: number;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DoctorReport {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
findings: DoctorFinding[];
|
|
17
|
+
guardsRun: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reads the optional `"doctor"` key from `<root>/agent-native.json`. All
|
|
21
|
+
* fields are optional with sane empty defaults — an app needs zero config
|
|
22
|
+
* to run `agent-native doctor` with every v1 guard enabled.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readDoctorConfig(root: string): DoctorConfig;
|
|
25
|
+
export interface RunDoctorScanOptions {
|
|
26
|
+
root: string;
|
|
27
|
+
/** Restrict to these guard names. When omitted, runs every guard not
|
|
28
|
+
* listed in `agent-native.json`'s `doctor.disabledGuards`. Unknown names
|
|
29
|
+
* are silently ignored here — the CLI layer (`runDoctor`) validates
|
|
30
|
+
* `--only` and reports a usage error before calling this. */
|
|
31
|
+
only?: string[];
|
|
32
|
+
}
|
|
33
|
+
/** Pure scan orchestrator: runs the selected guards against `root` and
|
|
34
|
+
* returns a flat report. No I/O beyond reading `agent-native.json` and the
|
|
35
|
+
* app source tree — no printing, no process.exit. */
|
|
36
|
+
export declare function runDoctorScan(options: RunDoctorScanOptions): DoctorReport;
|
|
37
|
+
/** Pure escalation rule shared by the CLI (`--strict`) and the `build`
|
|
38
|
+
* pre-step (`--strict` / `agent-native.json` `doctor.failOnBuild`). Doctor
|
|
39
|
+
* findings never fail anything on their own — only `strict` or
|
|
40
|
+
* `failOnBuild` turn findings into a hard failure. */
|
|
41
|
+
export declare function shouldFailBuild(hasFindings: boolean, opts: {
|
|
42
|
+
strict?: boolean;
|
|
43
|
+
failOnBuild?: boolean;
|
|
44
|
+
}): boolean;
|
|
45
|
+
export interface DoctorIo {
|
|
46
|
+
log: (message: string) => void;
|
|
47
|
+
err: (message: string) => void;
|
|
48
|
+
}
|
|
49
|
+
export interface DoctorCliOptions {
|
|
50
|
+
json?: boolean;
|
|
51
|
+
cwd?: string;
|
|
52
|
+
only?: string[];
|
|
53
|
+
strict?: boolean;
|
|
54
|
+
help?: boolean;
|
|
55
|
+
fix?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare function parseDoctorArgs(argv: string[]): DoctorCliOptions;
|
|
58
|
+
export declare function printDoctorHelp(io?: Pick<DoctorIo, "log">): void;
|
|
59
|
+
/** `agent-native doctor` CLI entrypoint. Returns the process exit code —
|
|
60
|
+
* callers are responsible for calling `process.exit(code)`. */
|
|
61
|
+
export declare function runDoctor(argv: string[], io?: DoctorIo): Promise<number>;
|
|
62
|
+
export interface DoctorBuildHookOptions {
|
|
63
|
+
cwd: string;
|
|
64
|
+
/** Set when the caller passed `agent-native build --strict`. */
|
|
65
|
+
strict?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface DoctorBuildHookResult {
|
|
68
|
+
/** False only when findings are present AND (`strict` was requested OR
|
|
69
|
+
* `agent-native.json`'s `doctor.failOnBuild` is true). */
|
|
70
|
+
ok: boolean;
|
|
71
|
+
report: DoctorReport;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `agent-native build`'s doctor pre-step. Always runs every enabled guard
|
|
75
|
+
* and always prints findings (as warnings) to `io.err` — never silent.
|
|
76
|
+
* Never causes the build to fail unless `strict` was passed or
|
|
77
|
+
* `agent-native.json` sets `doctor.failOnBuild: true` (see report 005,
|
|
78
|
+
* "Where it runs" — the v1 doctor has zero field mileage against arbitrary
|
|
79
|
+
* app layouts, so shipping fail-by-default would risk breaking a first
|
|
80
|
+
* deploy on a false positive).
|
|
81
|
+
*/
|
|
82
|
+
export declare function runDoctorBuildHook(options: DoctorBuildHookOptions, io?: DoctorIo): Promise<DoctorBuildHookResult>;
|
|
83
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAoCA,MAAM,MAAM,SAAS,GACjB,iBAAiB,GACjB,yBAAyB,GACzB,qBAAqB,GACrB,oBAAoB,GACpB,iBAAiB,GACjB,iBAAiB,GACjB,uBAAuB,CAAC;AAE5B,eAAO,MAAM,eAAe,EAAE,SAAS,EAQtC,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,WAAW,EAAE,OAAO,CAAC;CACtB;AAQD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,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MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC;8DAC0D;IAC1D,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,YAAY,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,sBAAsB,EAC/B,EAAE,GAAE,QAAoB,GACvB,OAAO,CAAC,qBAAqB,CAAC,CAyBhC"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent-native doctor` — scan an app's source tree for the security-
|
|
3
|
+
* critical code-safety invariants this monorepo already enforces on
|
|
4
|
+
* itself via `scripts/guard-*.mjs` (see
|
|
5
|
+
* `advisor-plans/reports/005-doctor-design.md` for the full design and
|
|
6
|
+
* `advisor-plans/015-doctor-v1-implementation.md` for the implementation
|
|
7
|
+
* plan). v1 ships 7 of those guards, ported to work against a single
|
|
8
|
+
* generated app root instead of this monorepo's multi-template layout —
|
|
9
|
+
* see `../guards/index.ts`.
|
|
10
|
+
*
|
|
11
|
+
* This is a NEW top-level command, deliberately kept separate from the two
|
|
12
|
+
* existing "doctor" precedents in this CLI:
|
|
13
|
+
* - `agent-native upgrade check` (`upgrade.ts`) — dependency-pin health.
|
|
14
|
+
* - `agent-native recap doctor` (`recap.ts`) — PR Visual Recap config health.
|
|
15
|
+
* Each diagnoses a different domain; none are folded into a shared
|
|
16
|
+
* mega-doctor (see report 005, "Relationship to upgrade doctor and recap
|
|
17
|
+
* doctor").
|
|
18
|
+
*
|
|
19
|
+
* `--fix` is reserved, not implemented in v1 — it prints a message and
|
|
20
|
+
* exits 2 rather than silently no-op, so a future implementation doesn't
|
|
21
|
+
* collide with a script already passing the flag.
|
|
22
|
+
*/
|
|
23
|
+
import fs from "node:fs";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
import { scanDbToolScoping, scanDrizzlePush, scanEnvCredentials, scanEnvMutation, scanLocalhostFallback, scanUnscopedCredentials, scanUnscopedQueries, } from "../guards/index.js";
|
|
26
|
+
export const ALL_GUARD_NAMES = [
|
|
27
|
+
"no-drizzle-push",
|
|
28
|
+
"no-unscoped-credentials",
|
|
29
|
+
"no-unscoped-queries",
|
|
30
|
+
"no-env-credentials",
|
|
31
|
+
"db-tool-scoping",
|
|
32
|
+
"no-env-mutation",
|
|
33
|
+
"no-localhost-fallback",
|
|
34
|
+
];
|
|
35
|
+
const DEFAULT_DOCTOR_CONFIG = {
|
|
36
|
+
disabledGuards: [],
|
|
37
|
+
dbToolScopingDenylist: {},
|
|
38
|
+
failOnBuild: false,
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Reads the optional `"doctor"` key from `<root>/agent-native.json`. All
|
|
42
|
+
* fields are optional with sane empty defaults — an app needs zero config
|
|
43
|
+
* to run `agent-native doctor` with every v1 guard enabled.
|
|
44
|
+
*/
|
|
45
|
+
export function readDoctorConfig(root) {
|
|
46
|
+
const manifestPath = path.join(root, "agent-native.json");
|
|
47
|
+
if (!fs.existsSync(manifestPath)) {
|
|
48
|
+
return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const raw = fs.readFileSync(manifestPath, "utf-8");
|
|
52
|
+
const parsed = JSON.parse(raw);
|
|
53
|
+
const doctor = parsed.doctor ?? {};
|
|
54
|
+
const disabledGuards = Array.isArray(doctor.disabledGuards)
|
|
55
|
+
? doctor.disabledGuards.filter((v) => typeof v === "string")
|
|
56
|
+
: [];
|
|
57
|
+
const dbToolScopingDenylist = doctor.dbToolScopingDenylist &&
|
|
58
|
+
typeof doctor.dbToolScopingDenylist === "object"
|
|
59
|
+
? Object.fromEntries(Object.entries(doctor.dbToolScopingDenylist).filter((entry) => typeof entry[1] === "string"))
|
|
60
|
+
: {};
|
|
61
|
+
const failOnBuild = doctor.failOnBuild === true;
|
|
62
|
+
return { disabledGuards, dbToolScopingDenylist, failOnBuild };
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function runGuard(name, root, config) {
|
|
69
|
+
switch (name) {
|
|
70
|
+
case "no-drizzle-push":
|
|
71
|
+
return scanDrizzlePush({ root });
|
|
72
|
+
case "no-unscoped-credentials":
|
|
73
|
+
return scanUnscopedCredentials({ root });
|
|
74
|
+
case "no-unscoped-queries":
|
|
75
|
+
return scanUnscopedQueries({ root, extraExemptPaths: [] });
|
|
76
|
+
case "no-env-credentials":
|
|
77
|
+
return scanEnvCredentials({ root });
|
|
78
|
+
case "db-tool-scoping":
|
|
79
|
+
return scanDbToolScoping({
|
|
80
|
+
root,
|
|
81
|
+
denylist: config.dbToolScopingDenylist,
|
|
82
|
+
});
|
|
83
|
+
case "no-env-mutation":
|
|
84
|
+
return scanEnvMutation({ root });
|
|
85
|
+
case "no-localhost-fallback":
|
|
86
|
+
return scanLocalhostFallback({ root, extraExemptPaths: [] });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Pure scan orchestrator: runs the selected guards against `root` and
|
|
90
|
+
* returns a flat report. No I/O beyond reading `agent-native.json` and the
|
|
91
|
+
* app source tree — no printing, no process.exit. */
|
|
92
|
+
export function runDoctorScan(options) {
|
|
93
|
+
const root = options.root;
|
|
94
|
+
const config = readDoctorConfig(root);
|
|
95
|
+
let names;
|
|
96
|
+
if (options.only && options.only.length > 0) {
|
|
97
|
+
const knownOnly = options.only.filter((n) => ALL_GUARD_NAMES.includes(n));
|
|
98
|
+
names = knownOnly;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
names = ALL_GUARD_NAMES.filter((n) => !config.disabledGuards.includes(n));
|
|
102
|
+
}
|
|
103
|
+
const findings = [];
|
|
104
|
+
for (const name of names) {
|
|
105
|
+
const result = runGuard(name, root, config);
|
|
106
|
+
for (const f of result.findings) {
|
|
107
|
+
findings.push({
|
|
108
|
+
guard: name,
|
|
109
|
+
file: f.file,
|
|
110
|
+
line: f.line,
|
|
111
|
+
message: f.message,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { ok: findings.length === 0, findings, guardsRun: names };
|
|
116
|
+
}
|
|
117
|
+
/** Pure escalation rule shared by the CLI (`--strict`) and the `build`
|
|
118
|
+
* pre-step (`--strict` / `agent-native.json` `doctor.failOnBuild`). Doctor
|
|
119
|
+
* findings never fail anything on their own — only `strict` or
|
|
120
|
+
* `failOnBuild` turn findings into a hard failure. */
|
|
121
|
+
export function shouldFailBuild(hasFindings, opts) {
|
|
122
|
+
return hasFindings && Boolean(opts.strict || opts.failOnBuild);
|
|
123
|
+
}
|
|
124
|
+
const defaultIo = {
|
|
125
|
+
log: (message) => console.log(message),
|
|
126
|
+
err: (message) => console.error(message),
|
|
127
|
+
};
|
|
128
|
+
function formatDoctorHuman(report, root) {
|
|
129
|
+
const lines = [];
|
|
130
|
+
lines.push(`agent-native doctor: ${root}`);
|
|
131
|
+
lines.push(`Guards run: ${report.guardsRun.join(", ") || "(none)"}`);
|
|
132
|
+
if (report.findings.length === 0) {
|
|
133
|
+
lines.push("Clean — no findings.");
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
lines.push(`${report.findings.length} finding(s):`);
|
|
137
|
+
for (const f of report.findings) {
|
|
138
|
+
lines.push(` [${f.guard}] ${f.file}:${f.line} — ${f.message}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return lines.join("\n");
|
|
142
|
+
}
|
|
143
|
+
export function parseDoctorArgs(argv) {
|
|
144
|
+
const opts = {};
|
|
145
|
+
for (let i = 0; i < argv.length; i++) {
|
|
146
|
+
const arg = argv[i];
|
|
147
|
+
if (arg === "--help" || arg === "-h") {
|
|
148
|
+
opts.help = true;
|
|
149
|
+
}
|
|
150
|
+
else if (arg === "--json") {
|
|
151
|
+
opts.json = true;
|
|
152
|
+
}
|
|
153
|
+
else if (arg === "--strict") {
|
|
154
|
+
opts.strict = true;
|
|
155
|
+
}
|
|
156
|
+
else if (arg === "--fix") {
|
|
157
|
+
opts.fix = true;
|
|
158
|
+
}
|
|
159
|
+
else if (arg === "--cwd" && argv[i + 1] !== undefined) {
|
|
160
|
+
opts.cwd = argv[++i];
|
|
161
|
+
}
|
|
162
|
+
else if (arg.startsWith("--cwd=")) {
|
|
163
|
+
opts.cwd = arg.slice("--cwd=".length);
|
|
164
|
+
}
|
|
165
|
+
else if (arg === "--only" && argv[i + 1] !== undefined) {
|
|
166
|
+
opts.only = splitGuardList(argv[++i]);
|
|
167
|
+
}
|
|
168
|
+
else if (arg.startsWith("--only=")) {
|
|
169
|
+
opts.only = splitGuardList(arg.slice("--only=".length));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return opts;
|
|
173
|
+
}
|
|
174
|
+
function splitGuardList(value) {
|
|
175
|
+
return value
|
|
176
|
+
.split(",")
|
|
177
|
+
.map((s) => s.trim())
|
|
178
|
+
.filter((s) => s.length > 0);
|
|
179
|
+
}
|
|
180
|
+
export function printDoctorHelp(io = defaultIo) {
|
|
181
|
+
io.log([
|
|
182
|
+
"Usage:",
|
|
183
|
+
" agent-native doctor Scan app source for security-critical guard violations",
|
|
184
|
+
" agent-native doctor --json Machine-readable report: { ok, findings, guardsRun }",
|
|
185
|
+
" agent-native doctor --only <guard,guard> Run only the named guard(s)",
|
|
186
|
+
" agent-native doctor --strict Escalate findings to a hard failure when used by `agent-native build --strict`",
|
|
187
|
+
" agent-native doctor --cwd <dir> Run against a project root other than the current directory",
|
|
188
|
+
" agent-native doctor --fix Not implemented in this version",
|
|
189
|
+
" agent-native doctor --help Show this help",
|
|
190
|
+
"",
|
|
191
|
+
`Guards: ${ALL_GUARD_NAMES.join(", ")}`,
|
|
192
|
+
"",
|
|
193
|
+
"Exit codes: 0 clean, 1 findings present, 2 usage/execution error.",
|
|
194
|
+
"",
|
|
195
|
+
"`agent-native build` runs doctor as a warn-only pre-step by default — it",
|
|
196
|
+
"never fails the build unless `agent-native build --strict` is passed or",
|
|
197
|
+
'agent-native.json sets { "doctor": { "failOnBuild": true } }.',
|
|
198
|
+
"",
|
|
199
|
+
"For dependency-pin health (framework overrides/patches, stale",
|
|
200
|
+
"@agent-native/* pins), run `agent-native upgrade check` instead.",
|
|
201
|
+
].join("\n"));
|
|
202
|
+
}
|
|
203
|
+
/** `agent-native doctor` CLI entrypoint. Returns the process exit code —
|
|
204
|
+
* callers are responsible for calling `process.exit(code)`. */
|
|
205
|
+
export async function runDoctor(argv, io = defaultIo) {
|
|
206
|
+
const opts = parseDoctorArgs(argv);
|
|
207
|
+
if (opts.help) {
|
|
208
|
+
printDoctorHelp(io);
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
if (opts.fix) {
|
|
212
|
+
io.err("agent-native doctor --fix is not implemented in this version. Fix findings manually and re-run `agent-native doctor`.");
|
|
213
|
+
return 2;
|
|
214
|
+
}
|
|
215
|
+
const root = path.resolve(opts.cwd ?? process.cwd());
|
|
216
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {
|
|
217
|
+
const message = `--cwd path does not exist or is not a directory: ${root}`;
|
|
218
|
+
if (opts.json)
|
|
219
|
+
io.err(JSON.stringify({ ok: false, message }, null, 2));
|
|
220
|
+
else
|
|
221
|
+
io.err(message);
|
|
222
|
+
return 2;
|
|
223
|
+
}
|
|
224
|
+
if (opts.only) {
|
|
225
|
+
const unknown = opts.only.filter((n) => !ALL_GUARD_NAMES.includes(n));
|
|
226
|
+
if (unknown.length > 0) {
|
|
227
|
+
const message = `Unknown guard name(s) in --only: ${unknown.join(", ")}. Known guards: ${ALL_GUARD_NAMES.join(", ")}`;
|
|
228
|
+
if (opts.json)
|
|
229
|
+
io.err(JSON.stringify({ ok: false, message }, null, 2));
|
|
230
|
+
else
|
|
231
|
+
io.err(message);
|
|
232
|
+
return 2;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const report = runDoctorScan({ root, only: opts.only });
|
|
236
|
+
if (opts.json) {
|
|
237
|
+
const sink = report.ok ? io.log : io.err;
|
|
238
|
+
sink(JSON.stringify({ ...report, strict: Boolean(opts.strict) }, null, 2));
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
io.log(formatDoctorHuman(report, root));
|
|
242
|
+
if (!report.ok) {
|
|
243
|
+
io.err("");
|
|
244
|
+
io.err("agent-native doctor found issues above. Fix them, or add a `// guard:allow-<check> — reason` opt-out with reviewer approval.");
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return report.ok ? 0 : 1;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* `agent-native build`'s doctor pre-step. Always runs every enabled guard
|
|
251
|
+
* and always prints findings (as warnings) to `io.err` — never silent.
|
|
252
|
+
* Never causes the build to fail unless `strict` was passed or
|
|
253
|
+
* `agent-native.json` sets `doctor.failOnBuild: true` (see report 005,
|
|
254
|
+
* "Where it runs" — the v1 doctor has zero field mileage against arbitrary
|
|
255
|
+
* app layouts, so shipping fail-by-default would risk breaking a first
|
|
256
|
+
* deploy on a false positive).
|
|
257
|
+
*/
|
|
258
|
+
export async function runDoctorBuildHook(options, io = defaultIo) {
|
|
259
|
+
const root = path.resolve(options.cwd);
|
|
260
|
+
const config = readDoctorConfig(root);
|
|
261
|
+
const report = runDoctorScan({ root });
|
|
262
|
+
if (report.findings.length > 0) {
|
|
263
|
+
io.err(`\n[doctor] ${report.findings.length} finding(s) from \`agent-native doctor\` — run it directly for details. This does not fail the build unless --strict was passed or agent-native.json's doctor.failOnBuild is true.`);
|
|
264
|
+
for (const f of report.findings) {
|
|
265
|
+
io.err(` [${f.guard}] ${f.file}:${f.line} — ${f.message}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const fail = shouldFailBuild(report.findings.length > 0, {
|
|
269
|
+
strict: options.strict,
|
|
270
|
+
failOnBuild: config.failOnBuild,
|
|
271
|
+
});
|
|
272
|
+
if (fail) {
|
|
273
|
+
io.err(`\n[doctor] Failing build: ${options.strict ? "--strict was passed" : "agent-native.json's doctor.failOnBuild is true"}.`);
|
|
274
|
+
}
|
|
275
|
+
return { ok: !fail, report };
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAY5B,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,iBAAiB;IACjB,yBAAyB;IACzB,qBAAqB;IACrB,oBAAoB;IACpB,iBAAiB;IACjB,iBAAiB;IACjB,uBAAuB;CACxB,CAAC;AAQF,MAAM,qBAAqB,GAAiB;IAC1C,cAAc,EAAE,EAAE;IAClB,qBAAqB,EAAE,EAAE;IACzB,WAAW,EAAE,KAAK;CACnB,CAAC;AAeF;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAC1D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,OAAO,EAAE,GAAG,qBAAqB,EAAE,qBAAqB,EAAE,EAAE,EAAE,CAAC;IACjE,CAAC;IACD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,C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,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAEvC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,EAAE,CAAC,GAAG,CACJ,cAAc,MAAM,CAAC,QAAQ,CAAC,MAAM,oLAAoL,CACzN,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAChC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAC;IACH,IAAI,IAAI,EAAE,CAAC;QACT,EAAE,CAAC,GAAG,CACJ,6BAA6B,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,gDAAgD,GAAG,CAC1H,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["/**\n * `agent-native doctor` — scan an app's source tree for the security-\n * critical code-safety invariants this monorepo already enforces on\n * itself via `scripts/guard-*.mjs` (see\n * `advisor-plans/reports/005-doctor-design.md` for the full design and\n * `advisor-plans/015-doctor-v1-implementation.md` for the implementation\n * plan). v1 ships 7 of those guards, ported to work against a single\n * generated app root instead of this monorepo's multi-template layout —\n * see `../guards/index.ts`.\n *\n * This is a NEW top-level command, deliberately kept separate from the two\n * existing \"doctor\" precedents in this CLI:\n * - `agent-native upgrade check` (`upgrade.ts`) — dependency-pin health.\n * - `agent-native recap doctor` (`recap.ts`) — PR Visual Recap config health.\n * Each diagnoses a different domain; none are folded into a shared\n * mega-doctor (see report 005, \"Relationship to upgrade doctor and recap\n * doctor\").\n *\n * `--fix` is reserved, not implemented in v1 — it prints a message and\n * exits 2 rather than silently no-op, so a future implementation doesn't\n * collide with a script already passing the flag.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport {\n scanDbToolScoping,\n scanDrizzlePush,\n scanEnvCredentials,\n scanEnvMutation,\n scanLocalhostFallback,\n scanUnscopedCredentials,\n scanUnscopedQueries,\n} from \"../guards/index.js\";\nimport type { GuardResult } from \"../guards/index.js\";\n\nexport type GuardName =\n | \"no-drizzle-push\"\n | \"no-unscoped-credentials\"\n | \"no-unscoped-queries\"\n | \"no-env-credentials\"\n | \"db-tool-scoping\"\n | \"no-env-mutation\"\n | \"no-localhost-fallback\";\n\nexport const ALL_GUARD_NAMES: GuardName[] = [\n \"no-drizzle-push\",\n \"no-unscoped-credentials\",\n \"no-unscoped-queries\",\n \"no-env-credentials\",\n \"db-tool-scoping\",\n \"no-env-mutation\",\n \"no-localhost-fallback\",\n];\n\nexport interface DoctorConfig {\n disabledGuards: string[];\n dbToolScopingDenylist: Record<string, string>;\n failOnBuild: boolean;\n}\n\nconst DEFAULT_DOCTOR_CONFIG: DoctorConfig = {\n disabledGuards: [],\n dbToolScopingDenylist: {},\n failOnBuild: false,\n};\n\nexport interface DoctorFinding {\n guard: string;\n file: string;\n line: number;\n message: string;\n}\n\nexport interface DoctorReport {\n ok: boolean;\n findings: DoctorFinding[];\n guardsRun: string[];\n}\n\n/**\n * Reads the optional `\"doctor\"` key from `<root>/agent-native.json`. All\n * fields are optional with sane empty defaults — an app needs zero config\n * to run `agent-native doctor` with every v1 guard enabled.\n */\nexport function readDoctorConfig(root: string): DoctorConfig {\n const manifestPath = path.join(root, \"agent-native.json\");\n if (!fs.existsSync(manifestPath)) {\n return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };\n }\n try {\n const raw = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(raw) as { doctor?: Record<string, unknown> };\n const doctor = parsed.doctor ?? {};\n const disabledGuards = Array.isArray(doctor.disabledGuards)\n ? doctor.disabledGuards.filter((v): v is string => typeof v === \"string\")\n : [];\n const dbToolScopingDenylist =\n doctor.dbToolScopingDenylist &&\n typeof doctor.dbToolScopingDenylist === \"object\"\n ? (Object.fromEntries(\n Object.entries(\n doctor.dbToolScopingDenylist as Record<string, unknown>,\n ).filter(\n (entry): entry is [string, string] =>\n typeof entry[1] === \"string\",\n ),\n ) as Record<string, string>)\n : {};\n const failOnBuild = doctor.failOnBuild === true;\n return { disabledGuards, dbToolScopingDenylist, failOnBuild };\n } catch {\n return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };\n }\n}\n\nfunction runGuard(\n name: GuardName,\n root: string,\n config: DoctorConfig,\n): GuardResult {\n switch (name) {\n case \"no-drizzle-push\":\n return scanDrizzlePush({ root });\n case \"no-unscoped-credentials\":\n return scanUnscopedCredentials({ root });\n case \"no-unscoped-queries\":\n return scanUnscopedQueries({ root, extraExemptPaths: [] });\n case \"no-env-credentials\":\n return scanEnvCredentials({ root });\n case \"db-tool-scoping\":\n return scanDbToolScoping({\n root,\n denylist: config.dbToolScopingDenylist,\n });\n case \"no-env-mutation\":\n return scanEnvMutation({ root });\n case \"no-localhost-fallback\":\n return scanLocalhostFallback({ root, extraExemptPaths: [] });\n }\n}\n\nexport interface RunDoctorScanOptions {\n root: string;\n /** Restrict to these guard names. When omitted, runs every guard not\n * listed in `agent-native.json`'s `doctor.disabledGuards`. Unknown names\n * are silently ignored here — the CLI layer (`runDoctor`) validates\n * `--only` and reports a usage error before calling this. */\n only?: string[];\n}\n\n/** Pure scan orchestrator: runs the selected guards against `root` and\n * returns a flat report. No I/O beyond reading `agent-native.json` and the\n * app source tree — no printing, no process.exit. */\nexport function runDoctorScan(options: RunDoctorScanOptions): DoctorReport {\n const root = options.root;\n const config = readDoctorConfig(root);\n\n let names: GuardName[];\n if (options.only && options.only.length > 0) {\n const knownOnly = options.only.filter((n): n is GuardName =>\n (ALL_GUARD_NAMES as string[]).includes(n),\n );\n names = knownOnly;\n } else {\n names = ALL_GUARD_NAMES.filter((n) => !config.disabledGuards.includes(n));\n }\n\n const findings: DoctorFinding[] = [];\n for (const name of names) {\n const result = runGuard(name, root, config);\n for (const f of result.findings) {\n findings.push({\n guard: name,\n file: f.file,\n line: f.line,\n message: f.message,\n });\n }\n }\n\n return { ok: findings.length === 0, findings, guardsRun: names };\n}\n\n/** Pure escalation rule shared by the CLI (`--strict`) and the `build`\n * pre-step (`--strict` / `agent-native.json` `doctor.failOnBuild`). Doctor\n * findings never fail anything on their own — only `strict` or\n * `failOnBuild` turn findings into a hard failure. */\nexport function shouldFailBuild(\n hasFindings: boolean,\n opts: { strict?: boolean; failOnBuild?: boolean },\n): boolean {\n return hasFindings && Boolean(opts.strict || opts.failOnBuild);\n}\n\nexport interface DoctorIo {\n log: (message: string) => void;\n err: (message: string) => void;\n}\n\nconst defaultIo: DoctorIo = {\n log: (message) => console.log(message),\n err: (message) => console.error(message),\n};\n\nfunction formatDoctorHuman(report: DoctorReport, root: string): string {\n const lines: string[] = [];\n lines.push(`agent-native doctor: ${root}`);\n lines.push(`Guards run: ${report.guardsRun.join(\", \") || \"(none)\"}`);\n if (report.findings.length === 0) {\n lines.push(\"Clean — no findings.\");\n } else {\n lines.push(`${report.findings.length} finding(s):`);\n for (const f of report.findings) {\n lines.push(` [${f.guard}] ${f.file}:${f.line} — ${f.message}`);\n }\n }\n return lines.join(\"\\n\");\n}\n\nexport interface DoctorCliOptions {\n json?: boolean;\n cwd?: string;\n only?: string[];\n strict?: boolean;\n help?: boolean;\n fix?: boolean;\n}\n\nexport function parseDoctorArgs(argv: string[]): DoctorCliOptions {\n const opts: DoctorCliOptions = {};\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--help\" || arg === \"-h\") {\n opts.help = true;\n } else if (arg === \"--json\") {\n opts.json = true;\n } else if (arg === \"--strict\") {\n opts.strict = true;\n } else if (arg === \"--fix\") {\n opts.fix = true;\n } else if (arg === \"--cwd\" && argv[i + 1] !== undefined) {\n opts.cwd = argv[++i];\n } else if (arg.startsWith(\"--cwd=\")) {\n opts.cwd = arg.slice(\"--cwd=\".length);\n } else if (arg === \"--only\" && argv[i + 1] !== undefined) {\n opts.only = splitGuardList(argv[++i]);\n } else if (arg.startsWith(\"--only=\")) {\n opts.only = splitGuardList(arg.slice(\"--only=\".length));\n }\n }\n return opts;\n}\n\nfunction splitGuardList(value: string): string[] {\n return value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\nexport function printDoctorHelp(io: Pick<DoctorIo, \"log\"> = defaultIo): void {\n io.log(\n [\n \"Usage:\",\n \" agent-native doctor Scan app source for security-critical guard violations\",\n \" agent-native doctor --json Machine-readable report: { ok, findings, guardsRun }\",\n \" agent-native doctor --only <guard,guard> Run only the named guard(s)\",\n \" agent-native doctor --strict Escalate findings to a hard failure when used by `agent-native build --strict`\",\n \" agent-native doctor --cwd <dir> Run against a project root other than the current directory\",\n \" agent-native doctor --fix Not implemented in this version\",\n \" agent-native doctor --help Show this help\",\n \"\",\n `Guards: ${ALL_GUARD_NAMES.join(\", \")}`,\n \"\",\n \"Exit codes: 0 clean, 1 findings present, 2 usage/execution error.\",\n \"\",\n \"`agent-native build` runs doctor as a warn-only pre-step by default — it\",\n \"never fails the build unless `agent-native build --strict` is passed or\",\n 'agent-native.json sets { \"doctor\": { \"failOnBuild\": true } }.',\n \"\",\n \"For dependency-pin health (framework overrides/patches, stale\",\n \"@agent-native/* pins), run `agent-native upgrade check` instead.\",\n ].join(\"\\n\"),\n );\n}\n\n/** `agent-native doctor` CLI entrypoint. Returns the process exit code —\n * callers are responsible for calling `process.exit(code)`. */\nexport async function runDoctor(\n argv: string[],\n io: DoctorIo = defaultIo,\n): Promise<number> {\n const opts = parseDoctorArgs(argv);\n\n if (opts.help) {\n printDoctorHelp(io);\n return 0;\n }\n\n if (opts.fix) {\n io.err(\n \"agent-native doctor --fix is not implemented in this version. Fix findings manually and re-run `agent-native doctor`.\",\n );\n return 2;\n }\n\n const root = path.resolve(opts.cwd ?? process.cwd());\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\n const message = `--cwd path does not exist or is not a directory: ${root}`;\n if (opts.json) io.err(JSON.stringify({ ok: false, message }, null, 2));\n else io.err(message);\n return 2;\n }\n\n if (opts.only) {\n const unknown = opts.only.filter(\n (n) => !(ALL_GUARD_NAMES as string[]).includes(n),\n );\n if (unknown.length > 0) {\n const message = `Unknown guard name(s) in --only: ${unknown.join(\", \")}. Known guards: ${ALL_GUARD_NAMES.join(\", \")}`;\n if (opts.json) io.err(JSON.stringify({ ok: false, message }, null, 2));\n else io.err(message);\n return 2;\n }\n }\n\n const report = runDoctorScan({ root, only: opts.only });\n\n if (opts.json) {\n const sink = report.ok ? io.log : io.err;\n sink(JSON.stringify({ ...report, strict: Boolean(opts.strict) }, null, 2));\n } else {\n io.log(formatDoctorHuman(report, root));\n if (!report.ok) {\n io.err(\"\");\n io.err(\n \"agent-native doctor found issues above. Fix them, or add a `// guard:allow-<check> — reason` opt-out with reviewer approval.\",\n );\n }\n }\n\n return report.ok ? 0 : 1;\n}\n\nexport interface DoctorBuildHookOptions {\n cwd: string;\n /** Set when the caller passed `agent-native build --strict`. */\n strict?: boolean;\n}\n\nexport interface DoctorBuildHookResult {\n /** False only when findings are present AND (`strict` was requested OR\n * `agent-native.json`'s `doctor.failOnBuild` is true). */\n ok: boolean;\n report: DoctorReport;\n}\n\n/**\n * `agent-native build`'s doctor pre-step. Always runs every enabled guard\n * and always prints findings (as warnings) to `io.err` — never silent.\n * Never causes the build to fail unless `strict` was passed or\n * `agent-native.json` sets `doctor.failOnBuild: true` (see report 005,\n * \"Where it runs\" — the v1 doctor has zero field mileage against arbitrary\n * app layouts, so shipping fail-by-default would risk breaking a first\n * deploy on a false positive).\n */\nexport async function runDoctorBuildHook(\n options: DoctorBuildHookOptions,\n io: DoctorIo = defaultIo,\n): Promise<DoctorBuildHookResult> {\n const root = path.resolve(options.cwd);\n const config = readDoctorConfig(root);\n const report = runDoctorScan({ root });\n\n if (report.findings.length > 0) {\n io.err(\n `\\n[doctor] ${report.findings.length} finding(s) from \\`agent-native doctor\\` — run it directly for details. This does not fail the build unless --strict was passed or agent-native.json's doctor.failOnBuild is true.`,\n );\n for (const f of report.findings) {\n io.err(` [${f.guard}] ${f.file}:${f.line} — ${f.message}`);\n }\n }\n\n const fail = shouldFailBuild(report.findings.length > 0, {\n strict: options.strict,\n failOnBuild: config.failOnBuild,\n });\n if (fail) {\n io.err(\n `\\n[doctor] Failing build: ${options.strict ? \"--strict was passed\" : \"agent-native.json's doctor.failOnBuild is true\"}.`,\n );\n }\n\n return { ok: !fail, report };\n}\n"]}
|