@agent-native/core 0.100.2 → 0.101.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +65 -0
- package/corpus/core/docs/content/locales/ar-SA/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/ar-SA/template-plan.mdx +7 -0
- package/corpus/core/docs/content/locales/de-DE/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/de-DE/template-plan.mdx +7 -0
- package/corpus/core/docs/content/locales/es-ES/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/es-ES/template-plan.mdx +14 -0
- package/corpus/core/docs/content/locales/fr-FR/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/fr-FR/template-plan.mdx +7 -0
- package/corpus/core/docs/content/locales/hi-IN/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/hi-IN/template-plan.mdx +7 -0
- package/corpus/core/docs/content/locales/ja-JP/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/ja-JP/template-plan.mdx +7 -0
- package/corpus/core/docs/content/locales/ko-KR/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/ko-KR/template-plan.mdx +7 -0
- package/corpus/core/docs/content/locales/pt-BR/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/pt-BR/template-plan.mdx +14 -0
- package/corpus/core/docs/content/locales/zh-CN/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/zh-CN/template-plan.mdx +7 -0
- package/corpus/core/docs/content/locales/zh-TW/pr-visual-recap.mdx +48 -30
- package/corpus/core/docs/content/locales/zh-TW/template-plan.mdx +7 -0
- package/corpus/core/docs/content/pr-visual-recap.mdx +50 -32
- package/corpus/core/docs/content/template-plan.mdx +14 -0
- package/corpus/core/docs/content/toolkit-comments-review.mdx +16 -2
- package/corpus/core/package.json +4 -1
- package/corpus/core/src/a2a/index.ts +2 -1
- package/corpus/core/src/a2a/server.ts +34 -9
- package/corpus/core/src/agent/production-agent.ts +56 -10
- package/corpus/core/src/cli/create.ts +47 -19
- package/corpus/core/src/cli/pr-visual-recap-workflow.ts +2 -3
- package/corpus/core/src/cli/recap.ts +3 -4932
- package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +6 -4
- package/corpus/core/src/cli/skills-content/visual-recap-skill.ts +7 -1
- package/corpus/core/src/client/AgentPanel.tsx +19 -17
- package/corpus/core/src/client/analytics.ts +8 -1
- package/corpus/core/src/client/chat/markdown-renderer.tsx +54 -8
- package/corpus/core/src/client/chat/message-components.tsx +8 -2
- package/corpus/core/src/client/clipboard.ts +28 -1
- package/corpus/core/src/client/guided-questions.tsx +4 -0
- package/corpus/core/src/client/i18n.tsx +2 -1
- package/corpus/core/src/client/index.ts +4 -0
- package/corpus/core/src/client/review/ReviewCommentComposer.tsx +108 -0
- package/corpus/core/src/client/review/ReviewThreadPanel.tsx +482 -150
- package/corpus/core/src/client/review/index.ts +8 -0
- package/corpus/core/src/client/review/use-review.ts +35 -1
- package/corpus/core/src/client/use-agent-chat-context.ts +3 -2
- package/corpus/core/src/review/actions/create-review-comment.ts +2 -1
- package/corpus/core/src/review/actions/get-review-feedback.ts +6 -11
- package/corpus/core/src/review/actions/list-review-comments.ts +38 -4
- package/corpus/core/src/review/actions/reply-review-comment.ts +33 -22
- package/corpus/core/src/review/actions/resolve-review-thread.ts +29 -2
- package/corpus/core/src/review/actions/send-review-thread-to-agent.ts +62 -0
- package/corpus/core/src/review/identity.ts +101 -0
- package/corpus/core/src/review/index.ts +14 -0
- package/corpus/core/src/review/store.ts +315 -8
- package/corpus/core/src/review/types.ts +4 -0
- package/corpus/core/src/server/action-discovery.ts +4 -0
- package/corpus/core/src/server/action-routes.ts +125 -4
- package/corpus/core/src/server/agent-chat/plugin-options.ts +16 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +1 -0
- package/corpus/core/src/server/index.ts +8 -0
- package/corpus/core/src/vite/action-types-plugin.ts +4 -0
- package/corpus/templates/analytics/changelog/2026-07-14-daily-dashboard-email-captures-authenticate-with-a-sessi.md +6 -0
- package/corpus/templates/analytics/server/lib/dashboard-report.ts +156 -3
- package/corpus/templates/assets/app/components/generation/GenerationResults.tsx +402 -142
- package/corpus/templates/assets/app/i18n/zh-TW.ts +1 -0
- package/corpus/templates/assets/app/i18n-data.ts +1 -0
- package/corpus/templates/assets/app/routes/library.tsx +187 -48
- package/corpus/templates/assets/changelog/2026-07-13-merged-the-candidates-panel-into-the-library-as-a-drafts-tab.md +6 -0
- package/corpus/templates/chat/app/lib/agent-page.tsx +40 -0
- package/corpus/templates/chat/app/routes/agent.tsx +5 -3
- package/corpus/templates/chat/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +6 -0
- package/corpus/templates/clips/.agents/skills/ai-video-tools/SKILL.md +5 -0
- package/corpus/templates/clips/AGENTS.md +4 -0
- package/corpus/templates/clips/actions/get-feature-flags.ts +30 -0
- package/corpus/templates/clips/actions/lib/transcript-preview.ts +48 -0
- package/corpus/templates/clips/actions/request-transcript.ts +41 -1
- package/corpus/templates/clips/actions/view-screen.ts +5 -9
- package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -1
- package/corpus/templates/clips/app/components/player/video-player.tsx +39 -1
- package/corpus/templates/clips/app/hooks/use-desktop-promo.ts +6 -12
- package/corpus/templates/clips/app/hooks/use-mse-video-source.ts +146 -0
- package/corpus/templates/clips/app/lib/capture-install-options.ts +21 -0
- package/corpus/templates/clips/app/lib/fmp4.ts +271 -0
- package/corpus/templates/clips/app/lib/mse-video-loader.ts +585 -0
- package/corpus/templates/clips/app/routes/_app.dictate.tsx +0 -4
- package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +5 -13
- package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +2 -37
- package/corpus/templates/clips/app/routes/download.tsx +3 -2
- package/corpus/templates/clips/changelog/2026-07-10-shared-clips-now-start-playing-instantly-instead-of-showing-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-14-clips-now-distinguishes-transcript-previews-from-incomplete-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-14-desktop-app-prompts-stay-hidden-after-you-download-the-insta.md +6 -0
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +5 -0
- package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +10 -0
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +4 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen/custom_capture.rs +2518 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen/live_upload.rs +353 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +558 -67
- package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +11 -1
- package/corpus/templates/clips/desktop/src-tauri/src/remote_flags.rs +188 -0
- package/corpus/templates/clips/desktop/src-tauri/src/whisper_speech.rs +1 -1
- package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +1 -0
- package/corpus/templates/clips/server/plugins/agent-chat.ts +5 -0
- package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +5 -1
- package/corpus/templates/clips/shared/feature-flags.ts +41 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +3 -0
- package/corpus/templates/design/.agents/skills/design-review-feedback/SKILL.md +42 -0
- package/corpus/templates/design/AGENTS.md +6 -0
- package/corpus/templates/design/README.md +1 -0
- package/corpus/templates/design/actions/navigate.ts +4 -4
- package/corpus/templates/design/actions/view-screen.ts +116 -2
- package/corpus/templates/design/agent-native.app-skill.json +5 -0
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +52 -59
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +13 -9
- package/corpus/templates/design/app/components/design/EditPanel.tsx +79 -11
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +78 -65
- package/corpus/templates/design/app/components/design/ReviewCommentsPanel.tsx +161 -0
- package/corpus/templates/design/app/components/design/ReviewStatusControl.tsx +96 -0
- package/corpus/templates/design/app/components/design/bridge/hit-test.bridge.ts +166 -0
- package/corpus/templates/design/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/design/app/components/visual-editor/ReviewCanvasPins.tsx +1077 -0
- package/corpus/templates/design/app/components/visual-editor/index.ts +1 -0
- package/corpus/templates/design/app/components/visual-editor/review-canvas-state.ts +42 -0
- package/corpus/templates/design/app/hooks/use-design-systems.ts +2 -2
- package/corpus/templates/design/app/hooks/use-navigation-state.ts +9 -6
- package/corpus/templates/design/app/hooks/use-question-flow.ts +7 -1
- package/corpus/templates/design/app/i18n/ar-SA.ts +56 -1
- package/corpus/templates/design/app/i18n/de-DE.ts +57 -1
- package/corpus/templates/design/app/i18n/en-US.ts +56 -1
- package/corpus/templates/design/app/i18n/es-ES.ts +56 -1
- package/corpus/templates/design/app/i18n/fr-FR.ts +57 -1
- package/corpus/templates/design/app/i18n/hi-IN.ts +56 -1
- package/corpus/templates/design/app/i18n/ja-JP.ts +56 -1
- package/corpus/templates/design/app/i18n/ko-KR.ts +56 -1
- package/corpus/templates/design/app/i18n/pt-BR.ts +57 -1
- package/corpus/templates/design/app/i18n/zh-CN.ts +56 -1
- package/corpus/templates/design/app/i18n/zh-TW.ts +51 -0
- package/corpus/templates/design/app/pages/Present.tsx +172 -14
- package/corpus/templates/design/app/pages/design-editor/overview-camera.ts +23 -0
- package/corpus/templates/design/app/pages/design-editor/tool-state.ts +10 -0
- package/corpus/templates/design/app/pages/present-review-state.ts +18 -0
- package/corpus/templates/design/app/public-routes.ts +8 -0
- package/corpus/templates/design/app/root.tsx +7 -6
- package/corpus/templates/design/changelog/2026-07-13-dragged-design-assets-now-appear-at-the-visible-drop-locatio.md +6 -0
- package/corpus/templates/design/changelog/2026-07-13-reviewers-can-pin-comments-on-shared-designs-and-apply-verif.md +6 -0
- package/corpus/templates/design/server/plugins/agent-chat.ts +10 -0
- package/corpus/templates/design/server/plugins/auth.ts +7 -5
- package/corpus/templates/design/server/plugins/review.ts +9 -0
- package/corpus/templates/design/shared/review-anchor.ts +83 -0
- package/corpus/templates/design/shared/review-summary.ts +25 -0
- package/corpus/templates/forms/.agents/skills/form-publishing/SKILL.md +2 -0
- package/corpus/templates/forms/AGENTS.md +4 -0
- package/corpus/templates/forms/actions/create-form.ts +2 -1
- package/corpus/templates/forms/actions/update-form.ts +5 -2
- package/corpus/templates/forms/app/i18n/ar-SA.ts +3 -0
- package/corpus/templates/forms/app/i18n/de-DE.ts +3 -0
- package/corpus/templates/forms/app/i18n/en-US.ts +3 -0
- package/corpus/templates/forms/app/i18n/es-ES.ts +3 -0
- package/corpus/templates/forms/app/i18n/fr-FR.ts +3 -0
- package/corpus/templates/forms/app/i18n/hi-IN.ts +3 -0
- package/corpus/templates/forms/app/i18n/ja-JP.ts +3 -0
- package/corpus/templates/forms/app/i18n/ko-KR.ts +3 -0
- package/corpus/templates/forms/app/i18n/pt-BR.ts +3 -0
- package/corpus/templates/forms/app/i18n/zh-CN.ts +3 -0
- package/corpus/templates/forms/app/i18n/zh-TW.ts +3 -0
- package/corpus/templates/forms/app/pages/FormBuilderPage.tsx +19 -0
- package/corpus/templates/forms/changelog/2026-07-14-fixed-the-ask-forms-loading-input-appearing-above-the-welcom.md +6 -0
- package/corpus/templates/forms/changelog/2026-07-14-form-social-previews-now-show-the-form-title-description-and.md +6 -0
- package/corpus/templates/forms/changelog/2026-07-14-forms-can-email-the-form-owner-when-new-responses-arrive.md +6 -0
- package/corpus/templates/forms/server/handlers/submissions.ts +17 -0
- package/corpus/templates/forms/server/lib/form-og-image.ts +64 -6
- package/corpus/templates/forms/server/lib/public-form-ssr.ts +6 -2
- package/corpus/templates/forms/server/lib/response-email.ts +65 -0
- package/corpus/templates/forms/server/plugins/agent-chat.ts +1 -0
- package/corpus/templates/forms/server/routes/api/forms/og/[...slug]/og.png.get.ts +184 -0
- package/corpus/templates/forms/shared/types.ts +2 -0
- package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +6 -4
- package/corpus/templates/plan/.agents/skills/visual-recap/SKILL.md +7 -1
- package/dist/a2a/index.d.ts +2 -1
- package/dist/a2a/index.d.ts.map +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/server.d.ts +25 -0
- package/dist/a2a/server.d.ts.map +1 -1
- package/dist/a2a/server.js +30 -6
- package/dist/a2a/server.js.map +1 -1
- package/dist/agent/production-agent.d.ts +2 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +37 -12
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/create.d.ts +5 -3
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +44 -19
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +2 -2
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.js +2 -2
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/cli/recap.d.ts +3 -562
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +3 -3875
- package/dist/cli/recap.js.map +1 -1
- package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
- package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/visual-plan-skill.js +6 -4
- package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
- package/dist/cli/skills-content/visual-recap-skill.d.ts +1 -1
- package/dist/cli/skills-content/visual-recap-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/visual-recap-skill.js +7 -1
- package/dist/cli/skills-content/visual-recap-skill.js.map +1 -1
- 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/analytics.d.ts +5 -0
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +3 -1
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/chat/markdown-renderer.d.ts +1 -0
- package/dist/client/chat/markdown-renderer.d.ts.map +1 -1
- package/dist/client/chat/markdown-renderer.js +36 -1
- package/dist/client/chat/markdown-renderer.js.map +1 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +5 -2
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/clipboard.d.ts +3 -1
- package/dist/client/clipboard.d.ts.map +1 -1
- package/dist/client/clipboard.js +24 -1
- package/dist/client/clipboard.js.map +1 -1
- package/dist/client/guided-questions.d.ts +3 -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/i18n.d.ts.map +1 -1
- package/dist/client/i18n.js +3 -1
- package/dist/client/i18n.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/review/ReviewCommentComposer.d.ts +18 -0
- package/dist/client/review/ReviewCommentComposer.d.ts.map +1 -0
- package/dist/client/review/ReviewCommentComposer.js +30 -0
- package/dist/client/review/ReviewCommentComposer.js.map +1 -0
- package/dist/client/review/ReviewThreadPanel.d.ts +28 -1
- package/dist/client/review/ReviewThreadPanel.d.ts.map +1 -1
- package/dist/client/review/ReviewThreadPanel.js +151 -39
- package/dist/client/review/ReviewThreadPanel.js.map +1 -1
- package/dist/client/review/index.d.ts +3 -2
- package/dist/client/review/index.d.ts.map +1 -1
- package/dist/client/review/index.js +2 -1
- package/dist/client/review/index.js.map +1 -1
- package/dist/client/review/use-review.d.ts +23 -0
- package/dist/client/review/use-review.d.ts.map +1 -1
- package/dist/client/review/use-review.js +3 -0
- package/dist/client/review/use-review.js.map +1 -1
- package/dist/client/use-agent-chat-context.d.ts +1 -1
- package/dist/client/use-agent-chat-context.d.ts.map +1 -1
- package/dist/client/use-agent-chat-context.js +4 -2
- package/dist/client/use-agent-chat-context.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +5 -5
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/review/actions/create-review-comment.js +2 -1
- package/dist/review/actions/create-review-comment.js.map +1 -1
- package/dist/review/actions/get-review-feedback.js +6 -11
- package/dist/review/actions/get-review-feedback.js.map +1 -1
- package/dist/review/actions/list-review-comments.d.ts +1 -0
- package/dist/review/actions/list-review-comments.js +25 -4
- package/dist/review/actions/list-review-comments.js.map +1 -1
- package/dist/review/actions/reply-review-comment.js +12 -5
- package/dist/review/actions/reply-review-comment.js.map +1 -1
- package/dist/review/actions/resolve-review-thread.d.ts +3 -0
- package/dist/review/actions/resolve-review-thread.js +20 -3
- package/dist/review/actions/resolve-review-thread.js.map +1 -1
- package/dist/review/actions/send-review-thread-to-agent.d.ts +17 -0
- package/dist/review/actions/send-review-thread-to-agent.d.ts.map +1 -0
- package/dist/review/actions/send-review-thread-to-agent.js +49 -0
- package/dist/review/actions/send-review-thread-to-agent.js.map +1 -0
- package/dist/review/identity.d.ts +6 -0
- package/dist/review/identity.d.ts.map +1 -0
- package/dist/review/identity.js +68 -0
- package/dist/review/identity.js.map +1 -0
- package/dist/review/index.d.ts +3 -1
- package/dist/review/index.d.ts.map +1 -1
- package/dist/review/index.js +2 -1
- package/dist/review/index.js.map +1 -1
- package/dist/review/store.d.ts +36 -0
- package/dist/review/store.d.ts.map +1 -1
- package/dist/review/store.js +223 -8
- package/dist/review/store.js.map +1 -1
- package/dist/review/types.d.ts +4 -0
- package/dist/review/types.d.ts.map +1 -1
- package/dist/review/types.js.map +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- 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/action-routes.d.ts +45 -0
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +71 -5
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat/plugin-options.d.ts +16 -0
- package/dist/server/agent-chat/plugin-options.d.ts.map +1 -1
- package/dist/server/agent-chat/plugin-options.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +1 -0
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/index.d.ts +3 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -1
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +4 -0
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/docs/content/locales/ar-SA/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/ar-SA/template-plan.mdx +7 -0
- package/docs/content/locales/de-DE/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/de-DE/template-plan.mdx +7 -0
- package/docs/content/locales/es-ES/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/es-ES/template-plan.mdx +14 -0
- package/docs/content/locales/fr-FR/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/fr-FR/template-plan.mdx +7 -0
- package/docs/content/locales/hi-IN/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/hi-IN/template-plan.mdx +7 -0
- package/docs/content/locales/ja-JP/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/ja-JP/template-plan.mdx +7 -0
- package/docs/content/locales/ko-KR/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/ko-KR/template-plan.mdx +7 -0
- package/docs/content/locales/pt-BR/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/pt-BR/template-plan.mdx +14 -0
- package/docs/content/locales/zh-CN/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/zh-CN/template-plan.mdx +7 -0
- package/docs/content/locales/zh-TW/pr-visual-recap.mdx +48 -30
- package/docs/content/locales/zh-TW/template-plan.mdx +7 -0
- package/docs/content/pr-visual-recap.mdx +50 -32
- package/docs/content/template-plan.mdx +14 -0
- package/docs/content/toolkit-comments-review.mdx +16 -2
- package/package.json +4 -1
- package/corpus/templates/forms/server/routes/api/forms/og/[slug]/og.png.get.ts +0 -45
package/dist/review/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/review/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAc1E,IAAI,uBAAkD,CAAC;AA6CvD,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC7B,uBAAuB,GAAG,CAAC,KAAK,IAAI,EAAE;YACpC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAC3B,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2B1B,CAAC;YACD,MAAM,iBAAiB,GAAG;;;;;;;;;;;;MAY1B,CAAC;YACD,MAAM,OAAO,GAAG;gBACd;6EACqE;gBACrE;4DACoD;gBACpD;8DACsD;gBACtD;yDACiD;gBACjD;iEACyD;aAC1D,CAAC;YAEF,IAAI,UAAU,EAAE,EAAE,CAAC;gBACjB,MAAM,iBAAiB,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;gBACpE,MAAM,iBAAiB,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;gBACpE,MAAM,iBAAiB,CACrB,oCAAoC,EACpC,OAAO,CAAC,CAAC,CAAC,CACX,CAAC;gBACF,MAAM,iBAAiB,CAAC,kCAAkC,EA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,CAAC,CAAC,SAAS,CAAC;AACnE,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,YAAY;QAC3B,KAAK,KAAK,YAAY;QACtB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,QAAQ;QAClB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAc;IAC5C,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACtE,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,KAAK,KAAK,WAAW;QAC1B,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,mBAAmB;QAC7B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,QAAQ;QAClE,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC;AACd,CAAC;AAED,SAAS,yBAAyB,CAChC,KAAc;IAEd,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/D,CAAC","sourcesContent":["import { getDbExec, isPostgres } from \"../db/client.js\";\nimport { ensureIndexExists, ensureTableExists } from \"../db/ddl-guard.js\";\nimport type { Visibility } from \"../sharing/schema.js\";\nimport type {\n ReviewActorKind,\n ReviewComment,\n ReviewCommentKind,\n ReviewCommentStatus,\n ReviewMention,\n ReviewResolutionTarget,\n ReviewScope,\n ReviewStatus,\n ReviewStatusEntry,\n} from \"./types.js\";\n\nlet reviewTablesInitPromise: Promise<void> | undefined;\n\nexport interface InsertReviewCommentInput {\n resourceType: string;\n resourceId: string;\n threadId?: string | null;\n parentCommentId?: string | null;\n targetId?: string | null;\n kind?: ReviewCommentKind;\n anchor?: unknown | null;\n body: string;\n authorEmail?: string | null;\n authorName?: string | null;\n createdBy?: ReviewActorKind;\n resolutionTarget?: ReviewResolutionTarget | null;\n mentions?: ReviewMention[];\n ownerEmail?: string | null;\n orgId?: string | null;\n visibility?: Visibility | null;\n metadata?: Record<string, unknown> | null;\n}\n\nexport interface QueryReviewCommentsInput {\n resourceType: string;\n resourceId: string;\n scope: ReviewScope;\n bypassScope?: boolean;\n includeResolved?: boolean;\n includeDeleted?: boolean;\n targetId?: string | null;\n limit?: number;\n}\n\nexport interface UpsertReviewStatusInput {\n resourceType: string;\n resourceId: string;\n status: ReviewStatus;\n note?: string | null;\n updatedBy?: string | null;\n ownerEmail?: string | null;\n orgId?: string | null;\n visibility?: Visibility | null;\n metadata?: Record<string, unknown> | null;\n}\n\nexport async function ensureReviewTables(): Promise<void> {\n if (!reviewTablesInitPromise) {\n reviewTablesInitPromise = (async () => {\n const client = getDbExec();\n const createCommentsSql = `CREATE TABLE IF NOT EXISTS agent_review_comments (\n id TEXT PRIMARY KEY,\n resource_type TEXT NOT NULL,\n resource_id TEXT NOT NULL,\n thread_id TEXT NOT NULL,\n parent_comment_id TEXT,\n target_id TEXT,\n kind TEXT NOT NULL DEFAULT 'comment',\n status TEXT NOT NULL DEFAULT 'open',\n anchor_json TEXT,\n body TEXT NOT NULL,\n author_email TEXT,\n author_name TEXT,\n created_by TEXT NOT NULL DEFAULT 'human',\n resolution_target TEXT,\n mentions_json TEXT,\n owner_email TEXT,\n org_id TEXT,\n visibility TEXT NOT NULL DEFAULT 'private',\n resolved_by TEXT,\n resolved_at TEXT,\n consumed_at TEXT,\n deleted_by TEXT,\n deleted_at TEXT,\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL,\n metadata_json TEXT\n )`;\n const createStatusesSql = `CREATE TABLE IF NOT EXISTS agent_review_statuses (\n id TEXT PRIMARY KEY,\n resource_type TEXT NOT NULL,\n resource_id TEXT NOT NULL,\n status TEXT NOT NULL,\n note TEXT,\n updated_by TEXT,\n updated_at TEXT NOT NULL,\n owner_email TEXT,\n org_id TEXT,\n visibility TEXT NOT NULL DEFAULT 'private',\n metadata_json TEXT\n )`;\n const indexes = [\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_resource\n ON agent_review_comments (resource_type, resource_id, created_at)`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_thread\n ON agent_review_comments (thread_id, created_at)`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_owner\n ON agent_review_comments (owner_email, created_at)`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_org\n ON agent_review_comments (org_id, created_at)`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_statuses_resource\n ON agent_review_statuses (resource_type, resource_id)`,\n ];\n\n if (isPostgres()) {\n await ensureTableExists(\"agent_review_comments\", createCommentsSql);\n await ensureTableExists(\"agent_review_statuses\", createStatusesSql);\n await ensureIndexExists(\n \"idx_agent_review_comments_resource\",\n indexes[0],\n );\n await ensureIndexExists(\"idx_agent_review_comments_thread\", indexes[1]);\n await ensureIndexExists(\"idx_agent_review_comments_owner\", indexes[2]);\n await ensureIndexExists(\"idx_agent_review_comments_org\", indexes[3]);\n await ensureIndexExists(\n \"idx_agent_review_statuses_resource\",\n indexes[4],\n );\n } else {\n await client.execute(createCommentsSql);\n await client.execute(createStatusesSql);\n for (const indexSql of indexes) {\n await client.execute(indexSql);\n }\n }\n })();\n }\n\n await reviewTablesInitPromise;\n}\n\nexport async function insertReviewComment(\n input: InsertReviewCommentInput,\n): Promise<ReviewComment> {\n await ensureReviewTables();\n const client = getDbExec();\n const id = createReviewId(\"comment\");\n const now = new Date().toISOString();\n const comment: ReviewComment = {\n id,\n resourceType: input.resourceType,\n resourceId: input.resourceId,\n threadId: input.threadId ?? id,\n parentCommentId: input.parentCommentId ?? null,\n targetId: input.targetId ?? null,\n kind: input.kind ?? \"comment\",\n status: \"open\",\n anchor: input.anchor ?? null,\n body: input.body,\n authorEmail: input.authorEmail ?? null,\n authorName: input.authorName ?? null,\n createdBy: input.createdBy ?? \"human\",\n resolutionTarget: input.resolutionTarget ?? null,\n mentions: input.mentions ?? [],\n ownerEmail: input.ownerEmail ?? input.authorEmail ?? null,\n orgId: input.orgId ?? null,\n visibility:\n input.visibility === \"org\" || input.visibility === \"public\"\n ? input.visibility\n : \"private\",\n resolvedBy: null,\n resolvedAt: null,\n consumedAt: null,\n deletedBy: null,\n deletedAt: null,\n createdAt: now,\n updatedAt: now,\n metadata: input.metadata ?? null,\n };\n\n await client.execute({\n sql: `INSERT INTO agent_review_comments (\n id,\n resource_type,\n resource_id,\n thread_id,\n parent_comment_id,\n target_id,\n kind,\n status,\n anchor_json,\n body,\n author_email,\n author_name,\n created_by,\n resolution_target,\n mentions_json,\n owner_email,\n org_id,\n visibility,\n resolved_by,\n resolved_at,\n consumed_at,\n deleted_by,\n deleted_at,\n created_at,\n updated_at,\n metadata_json\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n args: [\n comment.id,\n comment.resourceType,\n comment.resourceId,\n comment.threadId,\n comment.parentCommentId,\n comment.targetId,\n comment.kind,\n comment.status,\n stringifyOptionalJson(comment.anchor),\n comment.body,\n comment.authorEmail,\n comment.authorName,\n comment.createdBy,\n comment.resolutionTarget,\n stringifyOptionalJson(comment.mentions),\n comment.ownerEmail,\n comment.orgId,\n comment.visibility,\n comment.resolvedBy,\n comment.resolvedAt,\n comment.consumedAt,\n comment.deletedBy,\n comment.deletedAt,\n comment.createdAt,\n comment.updatedAt,\n stringifyOptionalJson(comment.metadata),\n ],\n });\n\n return comment;\n}\n\nexport async function queryReviewComments(\n input: QueryReviewCommentsInput,\n): Promise<ReviewComment[]> {\n await ensureReviewTables();\n const client = getDbExec();\n const { clause, params } = input.bypassScope\n ? { clause: \"1 = 1\", params: [] as unknown[] }\n : scopedReviewClause(input.scope);\n const filters = [\"resource_type = ?\", \"resource_id = ?\", clause];\n const filterParams: unknown[] = [\n input.resourceType,\n input.resourceId,\n ...params,\n ];\n if (!input.includeDeleted) {\n filters.push(\"deleted_at IS NULL\");\n filters.push(\"status <> 'deleted'\");\n }\n if (!input.includeResolved) {\n filters.push(\"status <> 'resolved'\");\n }\n if (input.targetId !== undefined) {\n if (input.targetId === null) {\n filters.push(\"target_id IS NULL\");\n } else {\n filters.push(\"target_id = ?\");\n filterParams.push(input.targetId);\n }\n }\n\n const result = await client.execute({\n sql: `SELECT ${commentColumns()}\n FROM agent_review_comments\n WHERE ${filters.join(\" AND \")}\n ORDER BY created_at ASC\n LIMIT ?`,\n args: [...filterParams, clampLimit(input.limit)],\n });\n return (result.rows ?? []).map(mapCommentRow);\n}\n\nexport async function getReviewCommentById(\n id: string,\n scope: ReviewScope,\n options: { bypassScope?: boolean } = {},\n): Promise<ReviewComment | null> {\n await ensureReviewTables();\n const client = getDbExec();\n const { clause, params } = options.bypassScope\n ? { clause: \"1 = 1\", params: [] as unknown[] }\n : scopedReviewClause(scope);\n const result = await client.execute({\n sql: `SELECT ${commentColumns()}\n FROM agent_review_comments\n WHERE id = ? AND ${clause}\n LIMIT 1`,\n args: [id, ...params],\n });\n const row = result.rows?.[0];\n return row ? mapCommentRow(row) : null;\n}\n\nexport async function resolveReviewThread(\n threadId: string,\n resolvedBy?: string | null,\n resource?: { resourceType: string; resourceId: string },\n): Promise<number> {\n await ensureReviewTables();\n const now = new Date().toISOString();\n const resourceClause = resource\n ? \"AND resource_type = ? AND resource_id = ?\"\n : \"\";\n const result = await getDbExec().execute({\n sql: `UPDATE agent_review_comments\n SET status = 'resolved',\n resolved_by = ?,\n resolved_at = ?,\n updated_at = ?\n WHERE thread_id = ? AND deleted_at IS NULL ${resourceClause}`,\n args: [\n resolvedBy ?? null,\n now,\n now,\n threadId,\n ...(resource ? [resource.resourceType, resource.resourceId] : []),\n ],\n });\n return result.rowsAffected ?? 0;\n}\n\nexport async function deleteReviewComment(\n id: string,\n deletedBy?: string | null,\n): Promise<number> {\n await ensureReviewTables();\n const now = new Date().toISOString();\n const result = await getDbExec().execute({\n sql: `UPDATE agent_review_comments\n SET status = 'deleted',\n deleted_by = ?,\n deleted_at = ?,\n updated_at = ?\n WHERE id = ?`,\n args: [deletedBy ?? null, now, now, id],\n });\n return result.rowsAffected ?? 0;\n}\n\nexport async function consumeReviewFeedback(\n ids: string[],\n consumedAt = new Date().toISOString(),\n resource?: { resourceType: string; resourceId: string },\n): Promise<number> {\n if (!ids.length) {\n return 0;\n }\n await ensureReviewTables();\n const placeholders = ids.map(() => \"?\").join(\", \");\n const resourceClause = resource\n ? \"AND resource_type = ? AND resource_id = ?\"\n : \"\";\n const result = await getDbExec().execute({\n sql: `UPDATE agent_review_comments\n SET consumed_at = ?,\n updated_at = ?\n WHERE id IN (${placeholders}) ${resourceClause}`,\n args: [\n consumedAt,\n consumedAt,\n ...ids,\n ...(resource ? [resource.resourceType, resource.resourceId] : []),\n ],\n });\n return result.rowsAffected ?? 0;\n}\n\nexport async function upsertReviewStatus(\n input: UpsertReviewStatusInput,\n): Promise<ReviewStatusEntry> {\n await ensureReviewTables();\n const client = getDbExec();\n const id = statusId(input.resourceType, input.resourceId);\n const now = new Date().toISOString();\n const existing = await client.execute({\n sql: \"SELECT id FROM agent_review_statuses WHERE id = ? LIMIT 1\",\n args: [id],\n });\n const entry: ReviewStatusEntry = {\n id,\n resourceType: input.resourceType,\n resourceId: input.resourceId,\n status: input.status,\n note: input.note ?? null,\n updatedBy: input.updatedBy ?? null,\n updatedAt: now,\n ownerEmail: input.ownerEmail ?? input.updatedBy ?? null,\n orgId: input.orgId ?? null,\n visibility:\n input.visibility === \"org\" || input.visibility === \"public\"\n ? input.visibility\n : \"private\",\n metadata: input.metadata ?? null,\n };\n\n if (existing.rows?.length) {\n await client.execute({\n sql: `UPDATE agent_review_statuses\n SET status = ?,\n note = ?,\n updated_by = ?,\n updated_at = ?,\n owner_email = ?,\n org_id = ?,\n visibility = ?,\n metadata_json = ?\n WHERE id = ?`,\n args: [\n entry.status,\n entry.note,\n entry.updatedBy,\n entry.updatedAt,\n entry.ownerEmail,\n entry.orgId,\n entry.visibility,\n stringifyOptionalJson(entry.metadata),\n entry.id,\n ],\n });\n } else {\n await client.execute({\n sql: `INSERT INTO agent_review_statuses (\n id,\n resource_type,\n resource_id,\n status,\n note,\n updated_by,\n updated_at,\n owner_email,\n org_id,\n visibility,\n metadata_json\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n args: [\n entry.id,\n entry.resourceType,\n entry.resourceId,\n entry.status,\n entry.note,\n entry.updatedBy,\n entry.updatedAt,\n entry.ownerEmail,\n entry.orgId,\n entry.visibility,\n stringifyOptionalJson(entry.metadata),\n ],\n });\n }\n\n return entry;\n}\n\nexport async function getReviewStatus(\n resourceType: string,\n resourceId: string,\n scope: ReviewScope,\n options: { bypassScope?: boolean } = {},\n): Promise<ReviewStatusEntry | null> {\n await ensureReviewTables();\n const client = getDbExec();\n const { clause, params } = options.bypassScope\n ? { clause: \"1 = 1\", params: [] as unknown[] }\n : scopedReviewClause(scope);\n const result = await client.execute({\n sql: `SELECT ${statusColumns()}\n FROM agent_review_statuses\n WHERE resource_type = ? AND resource_id = ? AND ${clause}\n LIMIT 1`,\n args: [resourceType, resourceId, ...params],\n });\n const row = result.rows?.[0];\n return row ? mapStatusRow(row) : null;\n}\n\nexport function __resetReviewInitForTests(): void {\n reviewTablesInitPromise = undefined;\n}\n\nfunction commentColumns(): string {\n return [\n \"id\",\n \"resource_type\",\n \"resource_id\",\n \"thread_id\",\n \"parent_comment_id\",\n \"target_id\",\n \"kind\",\n \"status\",\n \"anchor_json\",\n \"body\",\n \"author_email\",\n \"author_name\",\n \"created_by\",\n \"resolution_target\",\n \"mentions_json\",\n \"owner_email\",\n \"org_id\",\n \"visibility\",\n \"resolved_by\",\n \"resolved_at\",\n \"consumed_at\",\n \"deleted_by\",\n \"deleted_at\",\n \"created_at\",\n \"updated_at\",\n \"metadata_json\",\n ].join(\", \");\n}\n\nfunction statusColumns(): string {\n return [\n \"id\",\n \"resource_type\",\n \"resource_id\",\n \"status\",\n \"note\",\n \"updated_by\",\n \"updated_at\",\n \"owner_email\",\n \"org_id\",\n \"visibility\",\n \"metadata_json\",\n ].join(\", \");\n}\n\nfunction scopedReviewClause(scope: ReviewScope): {\n clause: string;\n params: unknown[];\n} {\n const parts: string[] = [];\n const params: unknown[] = [];\n\n if (scope.userEmail) {\n parts.push(\"owner_email = ?\");\n params.push(scope.userEmail);\n }\n if (scope.orgId) {\n parts.push(\"(visibility = 'org' AND org_id = ?)\");\n params.push(scope.orgId);\n }\n parts.push(\"visibility = 'public'\");\n\n return { clause: `(${parts.join(\" OR \")})`, params };\n}\n\nfunction mapCommentRow(row: Record<string, unknown>): ReviewComment {\n return {\n id: String(row.id),\n resourceType: String(row.resource_type),\n resourceId: String(row.resource_id),\n threadId: String(row.thread_id),\n parentCommentId: nullableString(row.parent_comment_id),\n targetId: nullableString(row.target_id),\n kind: normalizeKind(row.kind),\n status: normalizeCommentStatus(row.status),\n anchor: parseOptionalJson(row.anchor_json),\n body: String(row.body),\n authorEmail: nullableString(row.author_email),\n authorName: nullableString(row.author_name),\n createdBy: normalizeActor(row.created_by),\n resolutionTarget: normalizeResolutionTarget(row.resolution_target),\n mentions: parseMentions(row.mentions_json),\n ownerEmail: nullableString(row.owner_email),\n orgId: nullableString(row.org_id),\n visibility: normalizeVisibility(row.visibility),\n resolvedBy: nullableString(row.resolved_by),\n resolvedAt: nullableString(row.resolved_at),\n consumedAt: nullableString(row.consumed_at),\n deletedBy: nullableString(row.deleted_by),\n deletedAt: nullableString(row.deleted_at),\n createdAt: String(row.created_at),\n updatedAt: String(row.updated_at),\n metadata: parseObject(row.metadata_json),\n };\n}\n\nfunction mapStatusRow(row: Record<string, unknown>): ReviewStatusEntry {\n return {\n id: String(row.id),\n resourceType: String(row.resource_type),\n resourceId: String(row.resource_id),\n status: normalizeReviewStatus(row.status),\n note: nullableString(row.note),\n updatedBy: nullableString(row.updated_by),\n updatedAt: String(row.updated_at),\n ownerEmail: nullableString(row.owner_email),\n orgId: nullableString(row.org_id),\n visibility: normalizeVisibility(row.visibility),\n metadata: parseObject(row.metadata_json),\n };\n}\n\nfunction createReviewId(prefix: string): string {\n return `rev_${prefix}_${globalThis.crypto.randomUUID()}`;\n}\n\nfunction statusId(resourceType: string, resourceId: string): string {\n return `${resourceType}:${resourceId}`;\n}\n\nfunction clampLimit(value: number | undefined): number {\n if (!Number.isFinite(value)) {\n return 200;\n }\n return Math.min(500, Math.max(1, Math.floor(value ?? 200)));\n}\n\nfunction nullableString(value: unknown): string | null {\n return value === null || value === undefined ? null : String(value);\n}\n\nfunction stringifyOptionalJson(value: unknown): string | null {\n return value === null || value === undefined ? null : JSON.stringify(value);\n}\n\nfunction parseOptionalJson(value: unknown): unknown | null {\n if (value === null || value === undefined || value === \"\") {\n return null;\n }\n if (typeof value !== \"string\") {\n return value;\n }\n return JSON.parse(value);\n}\n\nfunction parseObject(value: unknown): Record<string, unknown> | null {\n const parsed = parseOptionalJson(value);\n return typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : null;\n}\n\nfunction parseMentions(value: unknown): ReviewMention[] {\n const parsed = parseOptionalJson(value);\n return Array.isArray(parsed) ? (parsed as ReviewMention[]) : [];\n}\n\nfunction normalizeVisibility(value: unknown): Visibility {\n return value === \"org\" || value === \"public\" ? value : \"private\";\n}\n\nfunction normalizeKind(value: unknown): ReviewCommentKind {\n return value === \"annotation\" ||\n value === \"correction\" ||\n value === \"question\" ||\n value === \"decision\" ||\n value === \"review\"\n ? value\n : \"comment\";\n}\n\nfunction normalizeCommentStatus(value: unknown): ReviewCommentStatus {\n return value === \"resolved\" || value === \"deleted\" ? value : \"open\";\n}\n\nfunction normalizeReviewStatus(value: unknown): ReviewStatus {\n return value === \"in_review\" ||\n value === \"approved\" ||\n value === \"changes_requested\"\n ? value\n : \"draft\";\n}\n\nfunction normalizeActor(value: unknown): ReviewActorKind {\n return value === \"agent\" || value === \"import\" || value === \"system\"\n ? value\n : \"human\";\n}\n\nfunction normalizeResolutionTarget(\n value: unknown,\n): ReviewResolutionTarget | null {\n return value === \"agent\" || value === \"human\" ? value : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/review/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAc1E,IAAI,uBAAkD,CAAC;AA6DvD,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC7B,uBAAuB,GAAG,CAAC,KAAK,IAAI,EAAE;YACpC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAC3B,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2B1B,CAAC;YACD,MAAM,iBAAiB,GAAG;;;;;;;;;;;;MAY1B,CAAC;YACD,MAAM,OAAO,GAAG;gBACd;6EACqE;gBACrE;4DACoD;gBACpD;8DACsD;gBACtD;yDACiD;gBACjD;;;;;;;;aAQK;gBACL;iEACyD;aAC1D,CAAC;YAEF,IAAI,UAAU,EAAE,EAAE,CAAC;gBACjB,MAAM,iBAAiB,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;gBACpE,MAAM,iBAAiB,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;gBACpE,MAAM,iBAAiB,CACrB,oCAAoC,EACpC,OAAO,CAAC,CAAC,CAAC,CACX,CAAC;gBACF,MAAM,iBAAiB,CAAC,kCAAkC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC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,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACtE,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,KAAK,KAAK,WAAW;QAC1B,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,mBAAmB;QAC7B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,QAAQ;QAClE,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC;AACd,CAAC;AAED,SAAS,yBAAyB,CAChC,KAAc;IAEd,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/D,CAAC","sourcesContent":["import { getDbExec, isPostgres, type DbExec } from \"../db/client.js\";\nimport { ensureIndexExists, ensureTableExists } from \"../db/ddl-guard.js\";\nimport type { Visibility } from \"../sharing/schema.js\";\nimport type {\n ReviewActorKind,\n ReviewComment,\n ReviewCommentKind,\n ReviewCommentStatus,\n ReviewMention,\n ReviewResolutionTarget,\n ReviewScope,\n ReviewStatus,\n ReviewStatusEntry,\n} from \"./types.js\";\n\nlet reviewTablesInitPromise: Promise<void> | undefined;\n\nexport interface InsertReviewCommentInput {\n resourceType: string;\n resourceId: string;\n threadId?: string | null;\n parentCommentId?: string | null;\n targetId?: string | null;\n kind?: ReviewCommentKind;\n anchor?: unknown | null;\n body: string;\n authorEmail?: string | null;\n authorName?: string | null;\n createdBy?: ReviewActorKind;\n resolutionTarget?: ReviewResolutionTarget | null;\n mentions?: ReviewMention[];\n ownerEmail?: string | null;\n orgId?: string | null;\n visibility?: Visibility | null;\n metadata?: Record<string, unknown> | null;\n}\n\nexport interface QueryReviewCommentsInput {\n resourceType: string;\n resourceId: string;\n scope: ReviewScope;\n bypassScope?: boolean;\n includeResolved?: boolean;\n includeDeleted?: boolean;\n targetId?: string | null;\n rootOnly?: boolean;\n resolutionTargets?: readonly (ReviewResolutionTarget | null)[];\n unconsumedOnly?: boolean;\n limit?: number;\n}\n\nexport interface GetReviewThreadSummaryInput {\n resourceType: string;\n resourceId: string;\n scope: ReviewScope;\n bypassScope?: boolean;\n targetId?: string | null;\n}\n\nexport interface ReviewThreadSummary {\n openCount: number;\n agentQueueCount: number;\n}\n\nexport interface UpsertReviewStatusInput {\n resourceType: string;\n resourceId: string;\n status: ReviewStatus;\n note?: string | null;\n updatedBy?: string | null;\n ownerEmail?: string | null;\n orgId?: string | null;\n visibility?: Visibility | null;\n metadata?: Record<string, unknown> | null;\n}\n\nexport async function ensureReviewTables(): Promise<void> {\n if (!reviewTablesInitPromise) {\n reviewTablesInitPromise = (async () => {\n const client = getDbExec();\n const createCommentsSql = `CREATE TABLE IF NOT EXISTS agent_review_comments (\n id TEXT PRIMARY KEY,\n resource_type TEXT NOT NULL,\n resource_id TEXT NOT NULL,\n thread_id TEXT NOT NULL,\n parent_comment_id TEXT,\n target_id TEXT,\n kind TEXT NOT NULL DEFAULT 'comment',\n status TEXT NOT NULL DEFAULT 'open',\n anchor_json TEXT,\n body TEXT NOT NULL,\n author_email TEXT,\n author_name TEXT,\n created_by TEXT NOT NULL DEFAULT 'human',\n resolution_target TEXT,\n mentions_json TEXT,\n owner_email TEXT,\n org_id TEXT,\n visibility TEXT NOT NULL DEFAULT 'private',\n resolved_by TEXT,\n resolved_at TEXT,\n consumed_at TEXT,\n deleted_by TEXT,\n deleted_at TEXT,\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL,\n metadata_json TEXT\n )`;\n const createStatusesSql = `CREATE TABLE IF NOT EXISTS agent_review_statuses (\n id TEXT PRIMARY KEY,\n resource_type TEXT NOT NULL,\n resource_id TEXT NOT NULL,\n status TEXT NOT NULL,\n note TEXT,\n updated_by TEXT,\n updated_at TEXT NOT NULL,\n owner_email TEXT,\n org_id TEXT,\n visibility TEXT NOT NULL DEFAULT 'private',\n metadata_json TEXT\n )`;\n const indexes = [\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_resource\n ON agent_review_comments (resource_type, resource_id, created_at)`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_thread\n ON agent_review_comments (thread_id, created_at)`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_owner\n ON agent_review_comments (owner_email, created_at)`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_org\n ON agent_review_comments (org_id, created_at)`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_queue\n ON agent_review_comments (\n resource_type,\n resource_id,\n parent_comment_id,\n resolution_target,\n consumed_at,\n created_at\n )`,\n `CREATE INDEX IF NOT EXISTS idx_agent_review_statuses_resource\n ON agent_review_statuses (resource_type, resource_id)`,\n ];\n\n if (isPostgres()) {\n await ensureTableExists(\"agent_review_comments\", createCommentsSql);\n await ensureTableExists(\"agent_review_statuses\", createStatusesSql);\n await ensureIndexExists(\n \"idx_agent_review_comments_resource\",\n indexes[0],\n );\n await ensureIndexExists(\"idx_agent_review_comments_thread\", indexes[1]);\n await ensureIndexExists(\"idx_agent_review_comments_owner\", indexes[2]);\n await ensureIndexExists(\"idx_agent_review_comments_org\", indexes[3]);\n await ensureIndexExists(\"idx_agent_review_comments_queue\", indexes[4]);\n await ensureIndexExists(\n \"idx_agent_review_statuses_resource\",\n indexes[5],\n );\n } else {\n await client.execute(createCommentsSql);\n await client.execute(createStatusesSql);\n for (const indexSql of indexes) {\n await client.execute(indexSql);\n }\n }\n })();\n }\n\n await reviewTablesInitPromise;\n}\n\nexport async function insertReviewComment(\n input: InsertReviewCommentInput,\n): Promise<ReviewComment> {\n await ensureReviewTables();\n return insertReviewCommentWithClient(input, getDbExec());\n}\n\nexport async function insertReviewReply(\n input: InsertReviewCommentInput & {\n threadId: string;\n parentCommentId: string;\n },\n routeTarget: ReviewResolutionTarget | null,\n resource: { resourceType: string; resourceId: string },\n): Promise<ReviewComment> {\n await ensureReviewTables();\n const client = getDbExec();\n const insertAndRoute = async (tx: DbExec) => {\n if (routeTarget) {\n const routedCount = await routeReviewThreadWithClient(\n tx,\n input.threadId,\n routeTarget,\n resource,\n );\n if (routedCount < 1) {\n throw new Error(\"Open review thread not found\");\n }\n }\n return insertReviewCommentWithClient(input, tx);\n };\n if (client.transaction) return client.transaction(insertAndRoute);\n\n const reply = await insertReviewCommentWithClient(input, client);\n if (!routeTarget) return reply;\n try {\n const routedCount = await routeReviewThreadWithClient(\n client,\n input.threadId,\n routeTarget,\n resource,\n );\n if (routedCount < 1) throw new Error(\"Open review thread not found\");\n return reply;\n } catch (error) {\n await client.execute({\n sql: `DELETE FROM agent_review_comments\n WHERE id = ? AND resource_type = ? AND resource_id = ?`,\n args: [reply.id, resource.resourceType, resource.resourceId],\n });\n throw error;\n }\n}\n\nasync function insertReviewCommentWithClient(\n input: InsertReviewCommentInput,\n client: DbExec,\n): Promise<ReviewComment> {\n const id = createReviewId(\"comment\");\n const now = new Date().toISOString();\n const comment: ReviewComment = {\n id,\n resourceType: input.resourceType,\n resourceId: input.resourceId,\n threadId: input.threadId ?? id,\n parentCommentId: input.parentCommentId ?? null,\n targetId: input.targetId ?? null,\n kind: input.kind ?? \"comment\",\n status: \"open\",\n anchor: input.anchor ?? null,\n body: input.body,\n authorEmail: input.authorEmail ?? null,\n authorName: input.authorName ?? null,\n createdBy: input.createdBy ?? \"human\",\n resolutionTarget: input.resolutionTarget ?? null,\n mentions: input.mentions ?? [],\n ownerEmail: input.ownerEmail ?? input.authorEmail ?? null,\n orgId: input.orgId ?? null,\n visibility:\n input.visibility === \"org\" || input.visibility === \"public\"\n ? input.visibility\n : \"private\",\n resolvedBy: null,\n resolvedAt: null,\n consumedAt: null,\n deletedBy: null,\n deletedAt: null,\n createdAt: now,\n updatedAt: now,\n metadata: input.metadata ?? null,\n resolutionNote:\n typeof input.metadata?.resolutionNote === \"string\"\n ? input.metadata.resolutionNote\n : null,\n };\n\n await client.execute({\n sql: `INSERT INTO agent_review_comments (\n id,\n resource_type,\n resource_id,\n thread_id,\n parent_comment_id,\n target_id,\n kind,\n status,\n anchor_json,\n body,\n author_email,\n author_name,\n created_by,\n resolution_target,\n mentions_json,\n owner_email,\n org_id,\n visibility,\n resolved_by,\n resolved_at,\n consumed_at,\n deleted_by,\n deleted_at,\n created_at,\n updated_at,\n metadata_json\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n args: [\n comment.id,\n comment.resourceType,\n comment.resourceId,\n comment.threadId,\n comment.parentCommentId,\n comment.targetId,\n comment.kind,\n comment.status,\n stringifyOptionalJson(comment.anchor),\n comment.body,\n comment.authorEmail,\n comment.authorName,\n comment.createdBy,\n comment.resolutionTarget,\n stringifyOptionalJson(comment.mentions),\n comment.ownerEmail,\n comment.orgId,\n comment.visibility,\n comment.resolvedBy,\n comment.resolvedAt,\n comment.consumedAt,\n comment.deletedBy,\n comment.deletedAt,\n comment.createdAt,\n comment.updatedAt,\n stringifyOptionalJson(comment.metadata),\n ],\n });\n\n return comment;\n}\n\nexport async function queryReviewComments(\n input: QueryReviewCommentsInput,\n): Promise<ReviewComment[]> {\n await ensureReviewTables();\n const client = getDbExec();\n const { clause, params } = input.bypassScope\n ? { clause: \"1 = 1\", params: [] as unknown[] }\n : scopedReviewClause(input.scope);\n const filters = [\"resource_type = ?\", \"resource_id = ?\", clause];\n const filterParams: unknown[] = [\n input.resourceType,\n input.resourceId,\n ...params,\n ];\n if (!input.includeDeleted) {\n filters.push(\"deleted_at IS NULL\");\n filters.push(\"status <> 'deleted'\");\n }\n if (!input.includeResolved) {\n filters.push(\"status <> 'resolved'\");\n }\n if (input.targetId !== undefined) {\n if (input.targetId === null) {\n filters.push(\"target_id IS NULL\");\n } else {\n filters.push(\"target_id = ?\");\n filterParams.push(input.targetId);\n }\n }\n if (input.rootOnly) {\n filters.push(\"parent_comment_id IS NULL\");\n }\n if (input.unconsumedOnly) {\n filters.push(\"consumed_at IS NULL\");\n }\n if (input.resolutionTargets !== undefined) {\n const targets = Array.from(\n new Set(\n input.resolutionTargets.filter(\n (target): target is ReviewResolutionTarget => target !== null,\n ),\n ),\n );\n const resolutionFilters: string[] = [];\n if (targets.length > 0) {\n resolutionFilters.push(\n `resolution_target IN (${targets.map(() => \"?\").join(\", \")})`,\n );\n filterParams.push(...targets);\n }\n if (input.resolutionTargets.includes(null)) {\n resolutionFilters.push(\"resolution_target IS NULL\");\n }\n filters.push(\n resolutionFilters.length > 0\n ? `(${resolutionFilters.join(\" OR \")})`\n : \"1 = 0\",\n );\n }\n\n const selectSql = input.rootOnly\n ? `SELECT ${commentColumns()}\n FROM (\n SELECT ${commentColumns()},\n ROW_NUMBER() OVER (\n PARTITION BY thread_id\n ORDER BY created_at ASC, id ASC\n ) AS review_thread_rank\n FROM agent_review_comments\n WHERE ${filters.join(\" AND \")}\n ) AS distinct_review_threads\n WHERE review_thread_rank = 1`\n : `SELECT ${commentColumns()}\n FROM agent_review_comments\n WHERE ${filters.join(\" AND \")}`;\n const result = await client.execute({\n sql: `${selectSql}\n ORDER BY created_at ASC${input.rootOnly ? \", id ASC\" : \"\"}\n LIMIT ?`,\n args: [...filterParams, clampLimit(input.limit)],\n });\n return (result.rows ?? []).map(mapCommentRow);\n}\n\nexport async function getReviewThreadSummary(\n input: GetReviewThreadSummaryInput,\n): Promise<ReviewThreadSummary> {\n await ensureReviewTables();\n const { clause, params } = input.bypassScope\n ? { clause: \"1 = 1\", params: [] as unknown[] }\n : scopedReviewClause(input.scope);\n const filters = [\n \"resource_type = ?\",\n \"resource_id = ?\",\n clause,\n \"parent_comment_id IS NULL\",\n \"deleted_at IS NULL\",\n \"status = 'open'\",\n ];\n const filterParams: unknown[] = [\n input.resourceType,\n input.resourceId,\n ...params,\n ];\n if (input.targetId !== undefined) {\n if (input.targetId === null) {\n filters.push(\"target_id IS NULL\");\n } else {\n filters.push(\"target_id = ?\");\n filterParams.push(input.targetId);\n }\n }\n const result = await getDbExec().execute({\n sql: `SELECT COUNT(DISTINCT thread_id) AS open_count,\n COUNT(DISTINCT CASE\n WHEN (resolution_target IS NULL OR resolution_target <> 'human')\n AND consumed_at IS NULL\n THEN thread_id\n END) AS agent_queue_count\n FROM agent_review_comments\n WHERE ${filters.join(\" AND \")}`,\n args: filterParams,\n });\n const row = result.rows?.[0];\n return {\n openCount: Number(row?.open_count ?? 0),\n agentQueueCount: Number(row?.agent_queue_count ?? 0),\n };\n}\n\nexport async function getReviewCommentById(\n id: string,\n scope: ReviewScope,\n options: { bypassScope?: boolean } = {},\n): Promise<ReviewComment | null> {\n await ensureReviewTables();\n const client = getDbExec();\n const { clause, params } = options.bypassScope\n ? { clause: \"1 = 1\", params: [] as unknown[] }\n : scopedReviewClause(scope);\n const result = await client.execute({\n sql: `SELECT ${commentColumns()}\n FROM agent_review_comments\n WHERE id = ? AND ${clause}\n LIMIT 1`,\n args: [id, ...params],\n });\n const row = result.rows?.[0];\n return row ? mapCommentRow(row) : null;\n}\n\nexport async function getReviewThreadRoot(\n threadId: string,\n resource: { resourceType: string; resourceId: string },\n scope: ReviewScope,\n options: { bypassScope?: boolean } = {},\n): Promise<ReviewComment | null> {\n await ensureReviewTables();\n const { clause, params } = options.bypassScope\n ? { clause: \"1 = 1\", params: [] as unknown[] }\n : scopedReviewClause(scope);\n const result = await getDbExec().execute({\n sql: `SELECT ${commentColumns()}\n FROM agent_review_comments\n WHERE thread_id = ?\n AND resource_type = ?\n AND resource_id = ?\n AND parent_comment_id IS NULL\n AND ${clause}\n ORDER BY created_at ASC, id ASC\n LIMIT 1`,\n args: [threadId, resource.resourceType, resource.resourceId, ...params],\n });\n const row = result.rows?.[0];\n return row ? mapCommentRow(row) : null;\n}\n\nexport async function resolveReviewThread(\n threadId: string,\n resolvedBy?: string | null,\n resource?: { resourceType: string; resourceId: string },\n resolutionNote?: string,\n): Promise<number> {\n await ensureReviewTables();\n const client = getDbExec();\n const resolve = (tx: DbExec) =>\n resolveReviewThreadWithClient(\n tx,\n threadId,\n resolvedBy,\n resource,\n resolutionNote,\n );\n return client.transaction ? client.transaction(resolve) : resolve(client);\n}\n\nasync function resolveReviewThreadWithClient(\n client: DbExec,\n threadId: string,\n resolvedBy?: string | null,\n resource?: { resourceType: string; resourceId: string },\n resolutionNote?: string,\n): Promise<number> {\n const now = new Date().toISOString();\n const resourceClause = resource\n ? \"AND resource_type = ? AND resource_id = ?\"\n : \"\";\n let rootMetadata: Record<string, unknown> | null = null;\n if (resolutionNote !== undefined) {\n const root = await client.execute({\n sql: `SELECT metadata_json\n FROM agent_review_comments\n WHERE thread_id = ?\n AND parent_comment_id IS NULL\n AND deleted_at IS NULL\n ${resourceClause}\n ORDER BY created_at ASC, id ASC\n LIMIT 1`,\n args: [\n threadId,\n ...(resource ? [resource.resourceType, resource.resourceId] : []),\n ],\n });\n if (!root.rows?.[0]) {\n return 0;\n }\n rootMetadata = {\n ...(parseObject(root.rows[0].metadata_json) ?? {}),\n resolutionNote,\n };\n }\n\n const metadataAssignment =\n resolutionNote === undefined\n ? \"\"\n : \", metadata_json = CASE WHEN parent_comment_id IS NULL THEN ? ELSE metadata_json END\";\n const result = await client.execute({\n sql: `UPDATE agent_review_comments\n SET status = 'resolved',\n resolved_by = ?,\n resolved_at = ?,\n updated_at = ?\n ${metadataAssignment}\n WHERE thread_id = ? AND deleted_at IS NULL ${resourceClause}`,\n args: [\n resolvedBy ?? null,\n now,\n now,\n ...(resolutionNote === undefined\n ? []\n : [stringifyOptionalJson(rootMetadata)]),\n threadId,\n ...(resource ? [resource.resourceType, resource.resourceId] : []),\n ],\n });\n return result.rowsAffected ?? 0;\n}\n\nexport async function routeReviewThread(\n threadId: string,\n resolutionTarget: ReviewResolutionTarget,\n resource: { resourceType: string; resourceId: string },\n): Promise<number> {\n await ensureReviewTables();\n return routeReviewThreadWithClient(\n getDbExec(),\n threadId,\n resolutionTarget,\n resource,\n );\n}\n\nasync function routeReviewThreadWithClient(\n client: DbExec,\n threadId: string,\n resolutionTarget: ReviewResolutionTarget,\n resource: { resourceType: string; resourceId: string },\n): Promise<number> {\n const now = new Date().toISOString();\n const result = await client.execute({\n sql: `UPDATE agent_review_comments\n SET resolution_target = ?,\n consumed_at = CASE WHEN ? = 'agent' THEN NULL ELSE consumed_at END,\n updated_at = ?\n WHERE thread_id = ?\n AND resource_type = ?\n AND resource_id = ?\n AND parent_comment_id IS NULL\n AND status = 'open'\n AND deleted_at IS NULL`,\n args: [\n resolutionTarget,\n resolutionTarget,\n now,\n threadId,\n resource.resourceType,\n resource.resourceId,\n ],\n });\n return result.rowsAffected ?? 0;\n}\n\nexport async function sendReviewThreadToAgent(\n threadId: string,\n resource: { resourceType: string; resourceId: string },\n): Promise<number> {\n return routeReviewThread(threadId, \"agent\", resource);\n}\n\nexport async function deleteReviewComment(\n id: string,\n deletedBy?: string | null,\n): Promise<number> {\n await ensureReviewTables();\n const now = new Date().toISOString();\n const result = await getDbExec().execute({\n sql: `UPDATE agent_review_comments\n SET status = 'deleted',\n deleted_by = ?,\n deleted_at = ?,\n updated_at = ?\n WHERE id = ?`,\n args: [deletedBy ?? null, now, now, id],\n });\n return result.rowsAffected ?? 0;\n}\n\nexport async function consumeReviewFeedback(\n ids: string[],\n consumedAt = new Date().toISOString(),\n resource?: { resourceType: string; resourceId: string },\n): Promise<number> {\n if (!ids.length) {\n return 0;\n }\n await ensureReviewTables();\n const placeholders = ids.map(() => \"?\").join(\", \");\n const resourceClause = resource\n ? \"AND resource_type = ? AND resource_id = ?\"\n : \"\";\n const result = await getDbExec().execute({\n sql: `UPDATE agent_review_comments\n SET consumed_at = ?,\n updated_at = ?\n WHERE id IN (${placeholders}) ${resourceClause}`,\n args: [\n consumedAt,\n consumedAt,\n ...ids,\n ...(resource ? [resource.resourceType, resource.resourceId] : []),\n ],\n });\n return result.rowsAffected ?? 0;\n}\n\nexport async function upsertReviewStatus(\n input: UpsertReviewStatusInput,\n): Promise<ReviewStatusEntry> {\n await ensureReviewTables();\n const client = getDbExec();\n const id = statusId(input.resourceType, input.resourceId);\n const now = new Date().toISOString();\n const existing = await client.execute({\n sql: \"SELECT id FROM agent_review_statuses WHERE id = ? LIMIT 1\",\n args: [id],\n });\n const entry: ReviewStatusEntry = {\n id,\n resourceType: input.resourceType,\n resourceId: input.resourceId,\n status: input.status,\n note: input.note ?? null,\n updatedBy: input.updatedBy ?? null,\n updatedAt: now,\n ownerEmail: input.ownerEmail ?? input.updatedBy ?? null,\n orgId: input.orgId ?? null,\n visibility:\n input.visibility === \"org\" || input.visibility === \"public\"\n ? input.visibility\n : \"private\",\n metadata: input.metadata ?? null,\n };\n\n if (existing.rows?.length) {\n await client.execute({\n sql: `UPDATE agent_review_statuses\n SET status = ?,\n note = ?,\n updated_by = ?,\n updated_at = ?,\n owner_email = ?,\n org_id = ?,\n visibility = ?,\n metadata_json = ?\n WHERE id = ?`,\n args: [\n entry.status,\n entry.note,\n entry.updatedBy,\n entry.updatedAt,\n entry.ownerEmail,\n entry.orgId,\n entry.visibility,\n stringifyOptionalJson(entry.metadata),\n entry.id,\n ],\n });\n } else {\n await client.execute({\n sql: `INSERT INTO agent_review_statuses (\n id,\n resource_type,\n resource_id,\n status,\n note,\n updated_by,\n updated_at,\n owner_email,\n org_id,\n visibility,\n metadata_json\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n args: [\n entry.id,\n entry.resourceType,\n entry.resourceId,\n entry.status,\n entry.note,\n entry.updatedBy,\n entry.updatedAt,\n entry.ownerEmail,\n entry.orgId,\n entry.visibility,\n stringifyOptionalJson(entry.metadata),\n ],\n });\n }\n\n return entry;\n}\n\nexport async function getReviewStatus(\n resourceType: string,\n resourceId: string,\n scope: ReviewScope,\n options: { bypassScope?: boolean } = {},\n): Promise<ReviewStatusEntry | null> {\n await ensureReviewTables();\n const client = getDbExec();\n const { clause, params } = options.bypassScope\n ? { clause: \"1 = 1\", params: [] as unknown[] }\n : scopedReviewClause(scope);\n const result = await client.execute({\n sql: `SELECT ${statusColumns()}\n FROM agent_review_statuses\n WHERE resource_type = ? AND resource_id = ? AND ${clause}\n LIMIT 1`,\n args: [resourceType, resourceId, ...params],\n });\n const row = result.rows?.[0];\n return row ? mapStatusRow(row) : null;\n}\n\nexport function __resetReviewInitForTests(): void {\n reviewTablesInitPromise = undefined;\n}\n\nfunction commentColumns(): string {\n return [\n \"id\",\n \"resource_type\",\n \"resource_id\",\n \"thread_id\",\n \"parent_comment_id\",\n \"target_id\",\n \"kind\",\n \"status\",\n \"anchor_json\",\n \"body\",\n \"author_email\",\n \"author_name\",\n \"created_by\",\n \"resolution_target\",\n \"mentions_json\",\n \"owner_email\",\n \"org_id\",\n \"visibility\",\n \"resolved_by\",\n \"resolved_at\",\n \"consumed_at\",\n \"deleted_by\",\n \"deleted_at\",\n \"created_at\",\n \"updated_at\",\n \"metadata_json\",\n ].join(\", \");\n}\n\nfunction statusColumns(): string {\n return [\n \"id\",\n \"resource_type\",\n \"resource_id\",\n \"status\",\n \"note\",\n \"updated_by\",\n \"updated_at\",\n \"owner_email\",\n \"org_id\",\n \"visibility\",\n \"metadata_json\",\n ].join(\", \");\n}\n\nfunction scopedReviewClause(scope: ReviewScope): {\n clause: string;\n params: unknown[];\n} {\n const parts: string[] = [];\n const params: unknown[] = [];\n\n if (scope.userEmail) {\n parts.push(\"owner_email = ?\");\n params.push(scope.userEmail);\n }\n if (scope.orgId) {\n parts.push(\"(visibility = 'org' AND org_id = ?)\");\n params.push(scope.orgId);\n }\n parts.push(\"visibility = 'public'\");\n\n return { clause: `(${parts.join(\" OR \")})`, params };\n}\n\nfunction mapCommentRow(row: Record<string, unknown>): ReviewComment {\n const metadata = parseObject(row.metadata_json);\n return {\n id: String(row.id),\n resourceType: String(row.resource_type),\n resourceId: String(row.resource_id),\n threadId: String(row.thread_id),\n parentCommentId: nullableString(row.parent_comment_id),\n targetId: nullableString(row.target_id),\n kind: normalizeKind(row.kind),\n status: normalizeCommentStatus(row.status),\n anchor: parseOptionalJson(row.anchor_json),\n body: String(row.body),\n authorEmail: nullableString(row.author_email),\n authorName: nullableString(row.author_name),\n createdBy: normalizeActor(row.created_by),\n resolutionTarget: normalizeResolutionTarget(row.resolution_target),\n mentions: parseMentions(row.mentions_json),\n ownerEmail: nullableString(row.owner_email),\n orgId: nullableString(row.org_id),\n visibility: normalizeVisibility(row.visibility),\n resolvedBy: nullableString(row.resolved_by),\n resolvedAt: nullableString(row.resolved_at),\n consumedAt: nullableString(row.consumed_at),\n deletedBy: nullableString(row.deleted_by),\n deletedAt: nullableString(row.deleted_at),\n createdAt: String(row.created_at),\n updatedAt: String(row.updated_at),\n metadata,\n resolutionNote:\n typeof metadata?.resolutionNote === \"string\"\n ? metadata.resolutionNote\n : null,\n };\n}\n\nfunction mapStatusRow(row: Record<string, unknown>): ReviewStatusEntry {\n return {\n id: String(row.id),\n resourceType: String(row.resource_type),\n resourceId: String(row.resource_id),\n status: normalizeReviewStatus(row.status),\n note: nullableString(row.note),\n updatedBy: nullableString(row.updated_by),\n updatedAt: String(row.updated_at),\n ownerEmail: nullableString(row.owner_email),\n orgId: nullableString(row.org_id),\n visibility: normalizeVisibility(row.visibility),\n metadata: parseObject(row.metadata_json),\n };\n}\n\nfunction createReviewId(prefix: string): string {\n return `rev_${prefix}_${globalThis.crypto.randomUUID()}`;\n}\n\nfunction statusId(resourceType: string, resourceId: string): string {\n return `${resourceType}:${resourceId}`;\n}\n\nfunction clampLimit(value: number | undefined): number {\n if (!Number.isFinite(value)) {\n return 200;\n }\n return Math.min(500, Math.max(1, Math.floor(value ?? 200)));\n}\n\nfunction nullableString(value: unknown): string | null {\n return value === null || value === undefined ? null : String(value);\n}\n\nfunction stringifyOptionalJson(value: unknown): string | null {\n return value === null || value === undefined ? null : JSON.stringify(value);\n}\n\nfunction parseOptionalJson(value: unknown): unknown | null {\n if (value === null || value === undefined || value === \"\") {\n return null;\n }\n if (typeof value !== \"string\") {\n return value;\n }\n return JSON.parse(value);\n}\n\nfunction parseObject(value: unknown): Record<string, unknown> | null {\n const parsed = parseOptionalJson(value);\n return typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : null;\n}\n\nfunction parseMentions(value: unknown): ReviewMention[] {\n const parsed = parseOptionalJson(value);\n return Array.isArray(parsed) ? (parsed as ReviewMention[]) : [];\n}\n\nfunction normalizeVisibility(value: unknown): Visibility {\n return value === \"org\" || value === \"public\" ? value : \"private\";\n}\n\nfunction normalizeKind(value: unknown): ReviewCommentKind {\n return value === \"annotation\" ||\n value === \"correction\" ||\n value === \"question\" ||\n value === \"decision\" ||\n value === \"review\"\n ? value\n : \"comment\";\n}\n\nfunction normalizeCommentStatus(value: unknown): ReviewCommentStatus {\n return value === \"resolved\" || value === \"deleted\" ? value : \"open\";\n}\n\nfunction normalizeReviewStatus(value: unknown): ReviewStatus {\n return value === \"in_review\" ||\n value === \"approved\" ||\n value === \"changes_requested\"\n ? value\n : \"draft\";\n}\n\nfunction normalizeActor(value: unknown): ReviewActorKind {\n return value === \"agent\" || value === \"import\" || value === \"system\"\n ? value\n : \"human\";\n}\n\nfunction normalizeResolutionTarget(\n value: unknown,\n): ReviewResolutionTarget | null {\n return value === \"agent\" || value === \"human\" ? value : null;\n}\n"]}
|
package/dist/review/types.d.ts
CHANGED
|
@@ -56,6 +56,10 @@ export interface ReviewComment {
|
|
|
56
56
|
createdAt: string;
|
|
57
57
|
updatedAt: string;
|
|
58
58
|
metadata: Record<string, unknown> | null;
|
|
59
|
+
/** Persisted on the root comment's metadata when a thread is resolved. */
|
|
60
|
+
resolutionNote?: string | null;
|
|
61
|
+
/** Caller-specific capability computed by list-review-comments. */
|
|
62
|
+
canDelete?: boolean;
|
|
59
63
|
}
|
|
60
64
|
export interface ReviewStatusEntry {
|
|
61
65
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1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C;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
|
package/dist/review/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/review/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Visibility } from \"../sharing/schema.js\";\n\nexport type ReviewResourceRole = \"viewer\" | \"editor\" | \"admin\" | \"owner\";\nexport type ReviewCommentKind =\n | \"comment\"\n | \"annotation\"\n | \"correction\"\n | \"question\"\n | \"decision\"\n | \"review\";\nexport type ReviewCommentStatus = \"open\" | \"resolved\" | \"deleted\";\nexport type ReviewResolutionTarget = \"agent\" | \"human\";\nexport type ReviewStatus =\n | \"draft\"\n | \"in_review\"\n | \"approved\"\n | \"changes_requested\";\nexport type ReviewActorKind = \"human\" | \"agent\" | \"import\" | \"system\";\n\nexport interface ReviewResourceAccess {\n role: ReviewResourceRole;\n ownerEmail?: string | null;\n orgId?: string | null;\n visibility?: Visibility | null;\n resource?: unknown;\n}\n\nexport interface ReviewResourceContext {\n userEmail?: string | null;\n orgId?: string | null;\n caller?: string | null;\n request?: unknown;\n [key: string]: unknown;\n}\n\nexport interface ReviewableResourceRegistration {\n type: string;\n displayName?: string;\n resolveAccess?: (\n resourceId: string,\n ctx?: ReviewResourceContext,\n ) => Promise<ReviewResourceAccess | null> | ReviewResourceAccess | null;\n}\n\nexport interface ReviewMention {\n label: string;\n email?: string | null;\n id?: string | null;\n}\n\nexport interface ReviewComment {\n id: string;\n resourceType: string;\n resourceId: string;\n threadId: string;\n parentCommentId: string | null;\n targetId: string | null;\n kind: ReviewCommentKind;\n status: ReviewCommentStatus;\n anchor: unknown | null;\n body: string;\n authorEmail: string | null;\n authorName: string | null;\n createdBy: ReviewActorKind;\n resolutionTarget: ReviewResolutionTarget | null;\n mentions: ReviewMention[];\n ownerEmail: string | null;\n orgId: string | null;\n visibility: Visibility;\n resolvedBy: string | null;\n resolvedAt: string | null;\n consumedAt: string | null;\n deletedBy: string | null;\n deletedAt: string | null;\n createdAt: string;\n updatedAt: string;\n metadata: Record<string, unknown> | null;\n}\n\nexport interface ReviewStatusEntry {\n id: string;\n resourceType: string;\n resourceId: string;\n status: ReviewStatus;\n note: string | null;\n updatedBy: string | null;\n updatedAt: string;\n ownerEmail: string | null;\n orgId: string | null;\n visibility: Visibility;\n metadata: Record<string, unknown> | null;\n}\n\nexport interface ReviewScope {\n userEmail?: string | null;\n orgId?: string | null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/review/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Visibility } from \"../sharing/schema.js\";\n\nexport type ReviewResourceRole = \"viewer\" | \"editor\" | \"admin\" | \"owner\";\nexport type ReviewCommentKind =\n | \"comment\"\n | \"annotation\"\n | \"correction\"\n | \"question\"\n | \"decision\"\n | \"review\";\nexport type ReviewCommentStatus = \"open\" | \"resolved\" | \"deleted\";\nexport type ReviewResolutionTarget = \"agent\" | \"human\";\nexport type ReviewStatus =\n | \"draft\"\n | \"in_review\"\n | \"approved\"\n | \"changes_requested\";\nexport type ReviewActorKind = \"human\" | \"agent\" | \"import\" | \"system\";\n\nexport interface ReviewResourceAccess {\n role: ReviewResourceRole;\n ownerEmail?: string | null;\n orgId?: string | null;\n visibility?: Visibility | null;\n resource?: unknown;\n}\n\nexport interface ReviewResourceContext {\n userEmail?: string | null;\n orgId?: string | null;\n caller?: string | null;\n request?: unknown;\n [key: string]: unknown;\n}\n\nexport interface ReviewableResourceRegistration {\n type: string;\n displayName?: string;\n resolveAccess?: (\n resourceId: string,\n ctx?: ReviewResourceContext,\n ) => Promise<ReviewResourceAccess | null> | ReviewResourceAccess | null;\n}\n\nexport interface ReviewMention {\n label: string;\n email?: string | null;\n id?: string | null;\n}\n\nexport interface ReviewComment {\n id: string;\n resourceType: string;\n resourceId: string;\n threadId: string;\n parentCommentId: string | null;\n targetId: string | null;\n kind: ReviewCommentKind;\n status: ReviewCommentStatus;\n anchor: unknown | null;\n body: string;\n authorEmail: string | null;\n authorName: string | null;\n createdBy: ReviewActorKind;\n resolutionTarget: ReviewResolutionTarget | null;\n mentions: ReviewMention[];\n ownerEmail: string | null;\n orgId: string | null;\n visibility: Visibility;\n resolvedBy: string | null;\n resolvedAt: string | null;\n consumedAt: string | null;\n deletedBy: string | null;\n deletedAt: string | null;\n createdAt: string;\n updatedAt: string;\n metadata: Record<string, unknown> | null;\n /** Persisted on the root comment's metadata when a thread is resolved. */\n resolutionNote?: string | null;\n /** Caller-specific capability computed by list-review-comments. */\n canDelete?: boolean;\n}\n\nexport interface ReviewStatusEntry {\n id: string;\n resourceType: string;\n resourceId: string;\n status: ReviewStatus;\n note: string | null;\n updatedBy: string | null;\n updatedAt: string;\n ownerEmail: string | null;\n orgId: string | null;\n visibility: Visibility;\n metadata: Record<string, unknown> | null;\n}\n\nexport interface ReviewScope {\n userEmail?: string | null;\n orgId?: string | null;\n}\n"]}
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
|
|
|
34
34
|
/** POST /_agent-native/secrets/:key — write a secret. */
|
|
35
35
|
export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
36
36
|
error: string;
|
|
37
|
-
ok?: undefined;
|
|
38
37
|
status?: undefined;
|
|
38
|
+
ok?: undefined;
|
|
39
39
|
} | {
|
|
40
|
-
error?: undefined;
|
|
41
40
|
ok: boolean;
|
|
42
41
|
status: string;
|
|
42
|
+
error?: undefined;
|
|
43
43
|
} | {
|
|
44
|
-
ok?: undefined;
|
|
45
44
|
error: string;
|
|
46
45
|
removed?: undefined;
|
|
46
|
+
ok?: undefined;
|
|
47
47
|
} | {
|
|
48
|
-
error?: undefined;
|
|
49
48
|
ok: boolean;
|
|
50
49
|
removed: boolean;
|
|
50
|
+
error?: undefined;
|
|
51
51
|
}>>;
|
|
52
52
|
/**
|
|
53
53
|
* POST /_agent-native/secrets/:key/test — re-run the validator against the
|
|
54
54
|
* current stored value without changing anything. Useful for the "Test" button.
|
|
55
55
|
*/
|
|
56
56
|
export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
57
|
-
ok?: undefined;
|
|
58
57
|
error: string;
|
|
59
58
|
note?: undefined;
|
|
59
|
+
ok?: undefined;
|
|
60
60
|
} | {
|
|
61
|
-
error?: undefined;
|
|
62
61
|
ok: boolean;
|
|
63
62
|
note?: undefined;
|
|
64
|
-
} | {
|
|
65
63
|
error?: undefined;
|
|
64
|
+
} | {
|
|
66
65
|
ok: boolean;
|
|
67
66
|
note: string;
|
|
67
|
+
error?: undefined;
|
|
68
68
|
} | {
|
|
69
69
|
note?: undefined;
|
|
70
70
|
ok: boolean;
|
|
@@ -95,12 +95,12 @@ export interface AdHocSecretPayload {
|
|
|
95
95
|
export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
|
|
96
96
|
error: string;
|
|
97
97
|
} | {
|
|
98
|
-
error?: undefined;
|
|
99
98
|
ok: boolean;
|
|
100
99
|
key: string;
|
|
101
|
-
} | {
|
|
102
100
|
error?: undefined;
|
|
101
|
+
} | {
|
|
103
102
|
ok: boolean;
|
|
104
103
|
removed: boolean;
|
|
104
|
+
error?: undefined;
|
|
105
105
|
}>>;
|
|
106
106
|
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-discovery.d.ts","sourceRoot":"","sources":["../../src/server/action-discovery.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA2ChE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,IAAI,CAKN;AA4RD;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAqC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAgGtC;AAED,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"action-discovery.d.ts","sourceRoot":"","sources":["../../src/server/action-discovery.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA2ChE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,IAAI,CAKN;AA4RD;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAqC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAgGtC;AAED,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC,CAmLf;AAED,oDAAoD;AACpD,eAAO,MAAM,mBAAmB,4BAAsB,CAAC"}
|
|
@@ -611,6 +611,10 @@ export async function mergeCoreSharingActions(registry) {
|
|
|
611
611
|
"set-review-status",
|
|
612
612
|
() => import("../review/actions/set-review-status.js"),
|
|
613
613
|
],
|
|
614
|
+
[
|
|
615
|
+
"send-review-thread-to-agent",
|
|
616
|
+
() => import("../review/actions/send-review-thread-to-agent.js"),
|
|
617
|
+
],
|
|
614
618
|
// Org service tokens (CI credentials, e.g. PLAN_RECAP_TOKEN). Mint/revoke
|
|
615
619
|
// are toolCallable:false — preserved via preserveActionFlags below.
|
|
616
620
|
[
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-discovery.js","sourceRoot":"","sources":["../../src/server/action-discovery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gE;oBAChE,+DAA+D;oBAC/D,2DAA2D;oBAC3D,GAAG,mBAAmB,CAAC,GAAG,CAAC;iBAC5B,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,gDAAgD;QAClD,CAAC;IACH,CAAC;AACH,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC","sourcesContent":["import nodePath from \"node:path\";\n\n/**\n * Auto-discover actions from a template's actions/ directory.\n *\n * Scans for .ts/.js files and builds an action registry suitable for\n * `createAgentChatPlugin({ actions })`.\n *\n * Supports two action conventions:\n *\n * 1. **Full interface** — exports `tool: ActionTool` and `run(args): Promise<string>`.\n * These are used directly.\n *\n * 2. **CLI-style** — exports only `default async function(args: string[])`.\n * These are wrapped: args are converted from `Record<string, string>` to\n * `[\"--key\", \"value\", ...]`, console output is captured, and a tool\n * definition is synthesized from the action name.\n *\n * 3. **defineAction** — exports `default` from `defineAction()`. Has `tool` and `run`.\n *\n * Usage in agent-chat plugins:\n * ```ts\n * import { autoDiscoverActions } from \"@agent-native/core/server\";\n *\n * export default createAgentChatPlugin({\n * actions: () => autoDiscoverActions(import.meta.url),\n * });\n * ```\n */\nimport type { ActionEntry } from \"../agent/production-agent.js\";\nimport type { ActionTool } from \"../agent/types.js\";\nimport { captureCliOutput } from \"./cli-capture.js\";\n\n// Lazy fs — loaded via dynamic import() on first use.\n// Avoids require() which bundlers convert to createRequire() that crashes on CF Workers.\nlet _fs: typeof import(\"fs\") | undefined;\nasync function getFs(): Promise<typeof import(\"fs\")> {\n if (!_fs) {\n _fs = await import(\"node:fs\");\n }\n return _fs;\n}\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\n/** Files to skip during auto-discovery (no extension). */\nconst SKIP_FILES = new Set([\n \"helpers\",\n \"run\",\n \"db-connect\",\n \"db-status\",\n \"registry\",\n]);\n\nfunction isRuntimeSourceFile(filename: string): boolean {\n if (!/\\.(ts|js)$/.test(filename)) return false;\n if (/\\.d\\.ts$/.test(filename)) return false;\n if (/\\.(test|spec)\\.(ts|js)$/.test(filename)) return false;\n return true;\n}\n\n/**\n * Global registry of actions contributed by published packages\n * (e.g. `@agent-native/dispatch`). Populated by `registerPackageActions()`\n * which the package calls from import side effects, then merged into\n * `autoDiscoverActions` after the template's local `actions/` directory.\n *\n * Ordering: template `actions/` files always win on name collision so\n * consumers can override a packaged action by dropping a same-named file\n * in their own `actions/` dir.\n */\nconst packageActionRegistry: Record<string, ActionEntry> = {};\n\n/**\n * Register a map of actions contributed by a published package.\n *\n * Called from a package's server entrypoint via import side effects:\n * ```ts\n * // packages/dispatch/src/server/index.ts\n * import { registerPackageActions } from \"@agent-native/core/server\";\n * import { actions } from \"../actions/index.js\";\n * registerPackageActions(actions);\n * ```\n *\n * Idempotent — re-registering the same name from the same import is a no-op\n * so HMR / repeated dynamic imports don't double-warn.\n */\nexport function registerPackageActions(\n actions: Record<string, ActionEntry>,\n): void {\n for (const [name, entry] of Object.entries(actions)) {\n if (packageActionRegistry[name]) continue;\n packageActionRegistry[name] = entry;\n }\n}\n\n/** Internal — used by `autoDiscoverActions`. Returns a shallow copy. */\nfunction getPackageActions(): Record<string, ActionEntry> {\n return { ...packageActionRegistry };\n}\n\n/**\n * Split a string into shell-like tokens, handling double and single quotes.\n * `--title \"My Page\" --content \"\"` → `[\"--title\", \"My Page\", \"--content\", \"\"]`\n */\nfunction splitShellArgs(input: string): string[] {\n const tokens: string[] = [];\n let current = \"\";\n let inDouble = false;\n let inSingle = false;\n let wasQuoted = false;\n\n for (let i = 0; i < input.length; i++) {\n const ch = input[i];\n if (ch === '\"' && !inSingle) {\n inDouble = !inDouble;\n wasQuoted = true;\n continue;\n }\n if (ch === \"'\" && !inDouble) {\n inSingle = !inSingle;\n wasQuoted = true;\n continue;\n }\n if ((ch === \" \" || ch === \"\\t\") && !inDouble && !inSingle) {\n if (current.length > 0 || wasQuoted) {\n tokens.push(current);\n }\n current = \"\";\n wasQuoted = false;\n continue;\n }\n current += ch;\n }\n if (current.length > 0 || wasQuoted) {\n tokens.push(current);\n }\n return tokens;\n}\n\n/**\n * Wrap a CLI-style action (that writes to console.log) as an ActionEntry\n * by capturing stdout/stderr and intercepting process.exit. Uses the\n * shared AsyncLocalStorage-backed capture so concurrent invocations do\n * not corrupt the global `console.log` / `process.stdout.write` /\n * `process.exit` pointers (see `cli-capture.ts`).\n */\nfunction wrapDefaultExport(\n name: string,\n defaultFn: (args: string[]) => Promise<void>,\n): ActionEntry {\n const tool: ActionTool = {\n description: `Run the \"${name}\" action. Pass arguments as key-value pairs.`,\n parameters: {\n type: \"object\",\n properties: {\n args: {\n type: \"string\",\n description:\n \"Space-separated CLI arguments (e.g. '--id abc --title Hello')\",\n },\n },\n },\n };\n\n return {\n tool,\n run: async (args: Record<string, string>): Promise<string> => {\n const cliArgs: string[] = [];\n // If only an \"args\" key was provided, split it into CLI tokens\n if (args.args && Object.keys(args).length === 1) {\n cliArgs.push(...splitShellArgs(args.args));\n } else {\n for (const [k, v] of Object.entries(args)) {\n cliArgs.push(`--${k}`, v);\n }\n }\n return captureCliOutput(() => defaultFn(cliArgs));\n },\n };\n}\n\nfunction preserveActionFlags(entry: Record<string, any>): Partial<ActionEntry> {\n const out: Partial<ActionEntry> = {};\n if (typeof entry.agentTool === \"boolean\") out.agentTool = entry.agentTool;\n if (typeof entry.requiresAuth === \"boolean\") {\n out.requiresAuth = entry.requiresAuth;\n }\n if (typeof entry.readOnly === \"boolean\") out.readOnly = entry.readOnly;\n if (typeof entry.allowInPlanMode === \"boolean\") {\n out.allowInPlanMode = entry.allowInPlanMode;\n }\n if (typeof entry.parallelSafe === \"boolean\") {\n out.parallelSafe = entry.parallelSafe;\n }\n if (typeof entry.toolCallable === \"boolean\") {\n out.toolCallable = entry.toolCallable;\n }\n if (\n entry.publicAgent &&\n typeof entry.publicAgent === \"object\" &&\n !Array.isArray(entry.publicAgent)\n ) {\n out.publicAgent = entry.publicAgent;\n }\n if (typeof entry.link === \"function\") {\n out.link = entry.link;\n }\n if (\n entry.mcpApp &&\n typeof entry.mcpApp === \"object\" &&\n !Array.isArray(entry.mcpApp)\n ) {\n out.mcpApp = entry.mcpApp;\n }\n if (\n entry.chatUI &&\n typeof entry.chatUI === \"object\" &&\n !Array.isArray(entry.chatUI)\n ) {\n out.chatUI = entry.chatUI;\n }\n if (typeof entry.timeoutMs === \"number\") out.timeoutMs = entry.timeoutMs;\n if (typeof entry.maxResultChars === \"number\") {\n out.maxResultChars = entry.maxResultChars;\n }\n if (\n typeof entry.needsApproval === \"boolean\" ||\n typeof entry.needsApproval === \"function\"\n ) {\n out.needsApproval = entry.needsApproval;\n }\n return out;\n}\n\nfunction shouldRetryWithJiti(filePath: string, err: unknown): boolean {\n if (!filePath.endsWith(\".ts\")) return false;\n const candidate = err as { code?: unknown; message?: unknown } | undefined;\n if (candidate?.code === \"ERR_UNKNOWN_FILE_EXTENSION\") return true;\n return /Unknown file extension \".ts\"/.test(String(candidate?.message ?? \"\"));\n}\n\nasync function importRuntimeSourceModule(\n filePath: string,\n): Promise<Record<string, any>> {\n try {\n return await import(/* @vite-ignore */ pathToFileURL(filePath).href);\n } catch (err) {\n if (!shouldRetryWithJiti(filePath, err)) throw err;\n\n const { createJiti } = await import(\"jiti\");\n const jiti = createJiti(pathToFileURL(filePath).href, {\n interopDefault: true,\n });\n return (await jiti.import(filePath)) as Record<string, any>;\n }\n}\n\n/**\n * Resolve the actions directory from the caller's context.\n *\n * @param from - Either an `import.meta.url` (file:// URL from a plugin file),\n * an absolute directory path, or \"auto\" to use `process.cwd() + \"/actions\"`.\n * When an import.meta.url is provided, the actions directory is resolved as\n * `../../actions/` relative to the caller (typically `server/plugins/agent-chat.ts`).\n * If the resolved directory doesn't exist, falls back to `../../scripts/` for\n * backwards compatibility, then to `process.cwd() + \"/actions\"`.\n */\nasync function resolveActionsDir(from: string): Promise<string> {\n const fs = await getFs();\n const exists = (p: string) => {\n try {\n return fs.existsSync(p);\n } catch {\n return false;\n }\n };\n // On edge runtimes (e.g. Cloudflare Workers), import.meta.url may be\n // undefined after bundling. Fall back to cwd-based discovery.\n if (!from) {\n const cwdActions = nodePath.join(process.cwd(), \"actions\");\n if (exists(cwdActions)) return cwdActions;\n return nodePath.join(process.cwd(), \"scripts\");\n }\n if (from.startsWith(\"file://\") || from.startsWith(\"file:///\")) {\n const callerPath = fileURLToPath(from);\n const callerDir = nodePath.dirname(callerPath);\n const actionsResolved = nodePath.resolve(callerDir, \"../../actions\");\n if (exists(actionsResolved)) return actionsResolved;\n const scriptsResolved = nodePath.resolve(callerDir, \"../../scripts\");\n if (exists(scriptsResolved)) return scriptsResolved;\n const cwdActions = nodePath.join(process.cwd(), \"actions\");\n if (exists(cwdActions)) return cwdActions;\n return nodePath.join(process.cwd(), \"scripts\");\n }\n if (from === \"auto\") {\n const cwdActions = nodePath.join(process.cwd(), \"actions\");\n if (exists(cwdActions)) return cwdActions;\n return nodePath.join(process.cwd(), \"scripts\");\n }\n return nodePath.resolve(from);\n}\n\n/**\n * Load actions from a single directory into the given registry. Shared by\n * both the template-actions discovery path and the workspace-core actions\n * layer. When `skipExisting` is true, an entry with the same name that's\n * already in the registry is left untouched (template-wins on collision).\n */\nasync function loadActionsIntoRegistry(\n actionsDir: string,\n registry: Record<string, ActionEntry>,\n skipExisting: boolean,\n): Promise<void> {\n let files: string[];\n try {\n const fs = await getFs();\n if (!fs.existsSync(actionsDir)) return;\n files = fs.readdirSync(actionsDir);\n } catch {\n return;\n }\n\n const actionFiles = files.filter((f) => {\n if (!isRuntimeSourceFile(f)) return false;\n const name = f.replace(/\\.(ts|js)$/, \"\");\n if (name.startsWith(\"_\")) return false;\n if (SKIP_FILES.has(name)) return false;\n return true;\n });\n\n for (const file of actionFiles) {\n const name = file.replace(/\\.(ts|js)$/, \"\");\n if (skipExisting && registry[name]) continue;\n\n const filePath = nodePath.join(actionsDir, file);\n try {\n const mod = await importRuntimeSourceModule(filePath);\n\n if (mod.tool && typeof mod.run === \"function\") {\n registry[name] = {\n tool: mod.tool,\n run: mod.run,\n ...(mod.http !== undefined ? { http: mod.http } : {}),\n ...preserveActionFlags(mod),\n };\n } else if (\n mod.default &&\n typeof mod.default === \"object\" &&\n mod.default.tool &&\n typeof mod.default.run === \"function\"\n ) {\n registry[name] = {\n tool: mod.default.tool,\n run: mod.default.run,\n ...(mod.default.http !== undefined ? { http: mod.default.http } : {}),\n ...preserveActionFlags(mod.default),\n };\n } else if (typeof mod.default === \"function\") {\n registry[name] = wrapDefaultExport(name, mod.default);\n }\n } catch (err) {\n // CLI-style scripts (top-level execution) throw on import — expected,\n // they're available via `pnpm action <name>` / shell instead. But a\n // syntax error, bad import, or malformed defineAction in a real action\n // file lands here too and would silently vanish from the agent's tools.\n // Warn so a broken action file is diagnosable instead of mysteriously\n // missing.\n const msg =\n err instanceof Error ? (err.stack ?? err.message) : String(err);\n console.warn(\n `[action-discovery] Skipped \"${file}\" — failed to import. If this is an ` +\n `agent action (not a CLI script), it will be missing from the agent's tools:\\n${msg}`,\n );\n }\n }\n}\n\n/**\n * Normalize a pre-bundled static action registry (name → raw module) into\n * the `Record<string, ActionEntry>` shape the agent-chat plugin expects.\n *\n * Used by `autoDiscoverActions` when `.generated/actions-registry.ts` is\n * present so that Nitro-bundled serverless functions (Netlify, Vercel,\n * AWS-Lambda) can serve `/_agent-native/actions/*` routes without relying\n * on a filesystem scan that doesn't work in bundled output.\n */\nexport function loadActionsFromStaticRegistry(\n modules: Record<string, unknown>,\n): Record<string, ActionEntry> {\n const registry: Record<string, ActionEntry> = {};\n for (const [name, raw] of Object.entries(modules)) {\n const mod = raw as Record<string, any> | null | undefined;\n if (!mod) continue;\n\n if (mod.tool && typeof mod.run === \"function\") {\n registry[name] = {\n tool: mod.tool,\n run: mod.run,\n ...(mod.http !== undefined ? { http: mod.http } : {}),\n ...preserveActionFlags(mod),\n };\n continue;\n }\n\n const def = mod.default;\n if (\n def &&\n typeof def === \"object\" &&\n def.tool &&\n typeof def.run === \"function\"\n ) {\n registry[name] = {\n tool: def.tool,\n run: def.run,\n ...(def.http !== undefined ? { http: def.http } : {}),\n ...preserveActionFlags(def),\n };\n continue;\n }\n\n if (typeof def === \"function\") {\n registry[name] = wrapDefaultExport(name, def);\n }\n }\n return registry;\n}\n\n/**\n * Auto-discover actions from a directory.\n *\n * Merges in any actions from the enterprise workspace core (if present in\n * the ancestor chain). Template actions take precedence over workspace-core\n * actions on name collision, so an app can override an enterprise-wide\n * action by dropping a same-named file under its own `actions/`.\n *\n * Note: this helper uses a filesystem scan, which works in dev and in\n * non-bundled Node deployments. In bundled serverless functions (Nitro's\n * netlify / vercel / aws-lambda presets) the `actions/` directory is not\n * on disk at runtime; templates should pass the static registry generated\n * by the Vite plugin to `createAgentChatPlugin({ actions })` instead, so\n * the bundler sees static imports and pulls every action into the bundle.\n *\n * @param from - The caller's `import.meta.url` or an absolute path to the\n * actions directory.\n * @returns A record mapping action names to ActionEntry objects, suitable for\n * passing to `createAgentChatPlugin({ actions })`.\n */\nexport async function autoDiscoverActions(\n from: string,\n): Promise<Record<string, ActionEntry>> {\n const actionsDir = await resolveActionsDir(from);\n const registry: Record<string, ActionEntry> = {};\n\n // 1. Template actions first — these are the authoritative layer for the\n // current app and must override any workspace-core entry with the same\n // name.\n try {\n await loadActionsIntoRegistry(actionsDir, registry, false);\n } catch (err: any) {\n console.warn(\n `[autoDiscoverActions] Could not read actions directory: ${actionsDir} — ${err?.message}`,\n );\n }\n\n // 1b. Fallback: if filesystem discovery found no template actions (common\n // in bundled serverless environments like Netlify/Vercel where the\n // actions/ directory doesn't exist on disk), try importing the\n // generated static registry at .generated/actions-registry.\n //\n // This prevents the silent-empty-tools footgun where the agent has no\n // template actions and falls back to generic tools like web-request.\n // Prefer `loadActionsFromStaticRegistry` over `autoDiscoverActions` for\n // production reliability — this fallback is a safety net, not the\n // primary path.\n if (Object.keys(registry).length === 0 && from) {\n try {\n let registryPath: string;\n if (from.startsWith(\"file://\") || from.startsWith(\"file:///\")) {\n const callerDir = nodePath.dirname(fileURLToPath(from));\n registryPath = nodePath.resolve(\n callerDir,\n \"../../.generated/actions-registry.js\",\n );\n } else {\n registryPath = nodePath.resolve(\n from,\n \"../.generated/actions-registry.js\",\n );\n }\n const mod = await import(/* @vite-ignore */ registryPath);\n const staticEntries = loadActionsFromStaticRegistry(mod.default || mod);\n Object.assign(registry, staticEntries);\n if (Object.keys(staticEntries).length > 0) {\n console.log(\n `[autoDiscoverActions] Filesystem scan found 0 actions — loaded ${Object.keys(staticEntries).length} from .generated/actions-registry.ts instead. ` +\n `Consider switching to loadActionsFromStaticRegistry(actionsRegistry) for production reliability.`,\n );\n }\n } catch {\n // No generated registry available — registry stays empty.\n }\n }\n\n // If still empty after all fallbacks, warn loudly.\n if (Object.keys(registry).length === 0) {\n console.warn(\n `[autoDiscoverActions] WARNING: No template actions found! ` +\n `The agent will have no template-specific tools. ` +\n `If in production, switch from autoDiscoverActions to loadActionsFromStaticRegistry. ` +\n `See: https://docs.agent-native.com/actions#static-registry`,\n );\n }\n\n // 1c. Package-registered actions — contributed by published packages\n // (e.g. @agent-native/dispatch) via `registerPackageActions()` from\n // import side effects. Merged with skip-existing so the template's\n // own actions/ files always win on name collision.\n for (const [name, entry] of Object.entries(getPackageActions())) {\n if (registry[name]) continue;\n registry[name] = entry;\n }\n\n // 2. Workspace-core actions — merged in with skipExisting so they can't\n // overwrite template entries.\n try {\n const { getWorkspaceCoreExports } =\n await import(\"../deploy/workspace-core.js\");\n const ws = await getWorkspaceCoreExports(process.cwd());\n if (ws && ws.actionsDir) {\n await loadActionsIntoRegistry(ws.actionsDir, registry, true);\n }\n } catch {\n // workspace-core discovery unavailable (e.g. edge runtime) — skip.\n }\n\n // 3. Framework-level sharing + file-upload actions — always available to any\n // template. Merged with skipExisting so templates can override by\n // providing a same-named file.\n try {\n await mergeCoreSharingActions(registry);\n } catch {\n // Ignore — templates without sharing still work.\n }\n\n return registry;\n}\n\nexport async function mergeCoreSharingActions(\n registry: Record<string, ActionEntry>,\n): Promise<void> {\n const entries: Array<[string, () => Promise<any>]> = [\n [\"share-resource\", () => import(\"../sharing/actions/share-resource.js\")],\n [\n \"unshare-resource\",\n () => import(\"../sharing/actions/unshare-resource.js\"),\n ],\n [\n \"list-resource-shares\",\n () => import(\"../sharing/actions/list-resource-shares.js\"),\n ],\n [\n \"set-resource-visibility\",\n () => import(\"../sharing/actions/set-resource-visibility.js\"),\n ],\n [\n \"create-agent-resource-link\",\n () => import(\"../sharing/actions/create-agent-resource-link.js\"),\n ],\n [\"upload-image\", () => import(\"../file-upload/actions/upload-image.js\")],\n // Agent Jobs page — UI-only scoped reads and mutations for resource-backed\n // recurring jobs and personal automations. The agent-facing native tools\n // remain the canonical conversational surface.\n [\n \"list-recurring-jobs\",\n () => import(\"../jobs/actions/list-recurring-jobs.js\"),\n ],\n [\n \"manage-recurring-job\",\n () => import(\"../jobs/actions/manage-recurring-job.js\"),\n ],\n [\n \"list-automations\",\n () => import(\"../triggers/actions/list-automations.js\"),\n ],\n [\n \"manage-automation\",\n () => import(\"../triggers/actions/manage-automation.js\"),\n ],\n [\n \"context-manifest-get\",\n () => import(\"../agent/context-xray/actions/context-manifest-get.js\"),\n ],\n [\n \"context-preview-get\",\n () => import(\"../agent/context-xray/actions/context-preview-get.js\"),\n ],\n [\n \"context-pin\",\n () => import(\"../agent/context-xray/actions/context-pin.js\"),\n ],\n [\n \"context-evict\",\n () => import(\"../agent/context-xray/actions/context-evict.js\"),\n ],\n [\n \"context-restore\",\n () => import(\"../agent/context-xray/actions/context-restore.js\"),\n ],\n [\n \"context-report\",\n () => import(\"../agent/context-xray/actions/context-report.js\"),\n ],\n [\n \"get-localization-preference\",\n () => import(\"../localization/actions/get-localization-preference.js\"),\n ],\n [\n \"set-localization-preference\",\n () => import(\"../localization/actions/set-localization-preference.js\"),\n ],\n [\n \"change-appearance\",\n () => import(\"../appearance/actions/change-appearance.js\"),\n ],\n // Audit log — read surface (who changed what, when, agent vs human).\n [\n \"list-audit-events\",\n () => import(\"../audit/actions/list-audit-events.js\"),\n ],\n [\"get-audit-event\", () => import(\"../audit/actions/get-audit-event.js\")],\n [\n \"export-audit-events\",\n () => import(\"../audit/actions/export-audit-events.js\"),\n ],\n // History kit — reusable version snapshots and restore surface.\n [\n \"create-resource-version\",\n () => import(\"../history/actions/create-resource-version.js\"),\n ],\n [\n \"list-resource-versions\",\n () => import(\"../history/actions/list-resource-versions.js\"),\n ],\n [\n \"get-resource-version\",\n () => import(\"../history/actions/get-resource-version.js\"),\n ],\n [\n \"restore-resource-version\",\n () => import(\"../history/actions/restore-resource-version.js\"),\n ],\n [\n \"list-resource-history\",\n () => import(\"../history/actions/list-resource-history.js\"),\n ],\n // Comments/review kit — reusable inline comments, feedback, and review status.\n [\n \"list-review-comments\",\n () => import(\"../review/actions/list-review-comments.js\"),\n ],\n [\n \"create-review-comment\",\n () => import(\"../review/actions/create-review-comment.js\"),\n ],\n [\n \"reply-review-comment\",\n () => import(\"../review/actions/reply-review-comment.js\"),\n ],\n [\n \"resolve-review-thread\",\n () => import(\"../review/actions/resolve-review-thread.js\"),\n ],\n [\n \"delete-review-comment\",\n () => import(\"../review/actions/delete-review-comment.js\"),\n ],\n [\n \"consume-review-feedback\",\n () => import(\"../review/actions/consume-review-feedback.js\"),\n ],\n [\n \"get-review-feedback\",\n () => import(\"../review/actions/get-review-feedback.js\"),\n ],\n [\n \"set-review-status\",\n () => import(\"../review/actions/set-review-status.js\"),\n ],\n // Org service tokens (CI credentials, e.g. PLAN_RECAP_TOKEN). Mint/revoke\n // are toolCallable:false — preserved via preserveActionFlags below.\n [\n \"create-org-service-token\",\n () => import(\"../mcp/actions/create-org-service-token.js\"),\n ],\n [\n \"list-org-service-tokens\",\n () => import(\"../mcp/actions/list-org-service-tokens.js\"),\n ],\n [\n \"revoke-org-service-token\",\n () => import(\"../mcp/actions/revoke-org-service-token.js\"),\n ],\n ];\n for (const [name, loader] of entries) {\n if (registry[name]) continue;\n try {\n const mod = await loader();\n const def = mod.default;\n if (def && def.tool && typeof def.run === \"function\") {\n registry[name] = {\n tool: def.tool,\n run: def.run,\n ...(def.http !== undefined ? { http: def.http } : {}),\n // Carry security-relevant flags (toolCallable, publicAgent, link,\n // mcpApp) plus readOnly/parallelSafe. Without this, the sharing\n // actions' `toolCallable: false` (audit-H5) is dropped and the\n // tools-iframe bridge 403 in action-routes.ts never fires.\n ...preserveActionFlags(def),\n };\n }\n } catch {\n // Skip any sharing action that fails to import.\n }\n }\n}\n\n/** @deprecated Use `autoDiscoverActions` instead */\nexport const autoDiscoverScripts = autoDiscoverActions;\n"]}
|
|
1
|
+
{"version":3,"file":"action-discovery.js","sourceRoot":"","sources":["../../src/server/action-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AA+BjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,sDAAsD;AACtD,yFAAyF;AACzF,IAAI,GAAoC,CAAC;AACzC,KAAK,UAAU,KAAK;IAClB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AACD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAExD,0DAA0D;AAC1D,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,SAAS;IACT,KAAK;IACL,YAAY;IACZ,WAAW;IACX,UAAU;CACX,CAAC,CAAC;AAEH,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,yBAAyB,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3D,OAAO,IAAI,CAAC;AAC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E,SAAS;QAC7B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,MAAM,EAAE,CAAC;YAC3B,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC;YACxB,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;gBACrD,QAAQ,CAAC,IAAI,CAAC,GAAG;oBACf,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACrD,kEAAkE;oBAClE,gEAAgE;oBAChE,+DAA+D;oBAC/D,2DAA2D;oBAC3D,GAAG,mBAAmB,CAAC,GAAG,CAAC;iBAC5B,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,gDAAgD;QAClD,CAAC;IACH,CAAC;AACH,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC","sourcesContent":["import nodePath from \"node:path\";\n\n/**\n * Auto-discover actions from a template's actions/ directory.\n *\n * Scans for .ts/.js files and builds an action registry suitable for\n * `createAgentChatPlugin({ actions })`.\n *\n * Supports two action conventions:\n *\n * 1. **Full interface** — exports `tool: ActionTool` and `run(args): Promise<string>`.\n * These are used directly.\n *\n * 2. **CLI-style** — exports only `default async function(args: string[])`.\n * These are wrapped: args are converted from `Record<string, string>` to\n * `[\"--key\", \"value\", ...]`, console output is captured, and a tool\n * definition is synthesized from the action name.\n *\n * 3. **defineAction** — exports `default` from `defineAction()`. Has `tool` and `run`.\n *\n * Usage in agent-chat plugins:\n * ```ts\n * import { autoDiscoverActions } from \"@agent-native/core/server\";\n *\n * export default createAgentChatPlugin({\n * actions: () => autoDiscoverActions(import.meta.url),\n * });\n * ```\n */\nimport type { ActionEntry } from \"../agent/production-agent.js\";\nimport type { ActionTool } from \"../agent/types.js\";\nimport { captureCliOutput } from \"./cli-capture.js\";\n\n// Lazy fs — loaded via dynamic import() on first use.\n// Avoids require() which bundlers convert to createRequire() that crashes on CF Workers.\nlet _fs: typeof import(\"fs\") | undefined;\nasync function getFs(): Promise<typeof import(\"fs\")> {\n if (!_fs) {\n _fs = await import(\"node:fs\");\n }\n return _fs;\n}\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\n/** Files to skip during auto-discovery (no extension). */\nconst SKIP_FILES = new Set([\n \"helpers\",\n \"run\",\n \"db-connect\",\n \"db-status\",\n \"registry\",\n]);\n\nfunction isRuntimeSourceFile(filename: string): boolean {\n if (!/\\.(ts|js)$/.test(filename)) return false;\n if (/\\.d\\.ts$/.test(filename)) return false;\n if (/\\.(test|spec)\\.(ts|js)$/.test(filename)) return false;\n return true;\n}\n\n/**\n * Global registry of actions contributed by published packages\n * (e.g. `@agent-native/dispatch`). Populated by `registerPackageActions()`\n * which the package calls from import side effects, then merged into\n * `autoDiscoverActions` after the template's local `actions/` directory.\n *\n * Ordering: template `actions/` files always win on name collision so\n * consumers can override a packaged action by dropping a same-named file\n * in their own `actions/` dir.\n */\nconst packageActionRegistry: Record<string, ActionEntry> = {};\n\n/**\n * Register a map of actions contributed by a published package.\n *\n * Called from a package's server entrypoint via import side effects:\n * ```ts\n * // packages/dispatch/src/server/index.ts\n * import { registerPackageActions } from \"@agent-native/core/server\";\n * import { actions } from \"../actions/index.js\";\n * registerPackageActions(actions);\n * ```\n *\n * Idempotent — re-registering the same name from the same import is a no-op\n * so HMR / repeated dynamic imports don't double-warn.\n */\nexport function registerPackageActions(\n actions: Record<string, ActionEntry>,\n): void {\n for (const [name, entry] of Object.entries(actions)) {\n if (packageActionRegistry[name]) continue;\n packageActionRegistry[name] = entry;\n }\n}\n\n/** Internal — used by `autoDiscoverActions`. Returns a shallow copy. */\nfunction getPackageActions(): Record<string, ActionEntry> {\n return { ...packageActionRegistry };\n}\n\n/**\n * Split a string into shell-like tokens, handling double and single quotes.\n * `--title \"My Page\" --content \"\"` → `[\"--title\", \"My Page\", \"--content\", \"\"]`\n */\nfunction splitShellArgs(input: string): string[] {\n const tokens: string[] = [];\n let current = \"\";\n let inDouble = false;\n let inSingle = false;\n let wasQuoted = false;\n\n for (let i = 0; i < input.length; i++) {\n const ch = input[i];\n if (ch === '\"' && !inSingle) {\n inDouble = !inDouble;\n wasQuoted = true;\n continue;\n }\n if (ch === \"'\" && !inDouble) {\n inSingle = !inSingle;\n wasQuoted = true;\n continue;\n }\n if ((ch === \" \" || ch === \"\\t\") && !inDouble && !inSingle) {\n if (current.length > 0 || wasQuoted) {\n tokens.push(current);\n }\n current = \"\";\n wasQuoted = false;\n continue;\n }\n current += ch;\n }\n if (current.length > 0 || wasQuoted) {\n tokens.push(current);\n }\n return tokens;\n}\n\n/**\n * Wrap a CLI-style action (that writes to console.log) as an ActionEntry\n * by capturing stdout/stderr and intercepting process.exit. Uses the\n * shared AsyncLocalStorage-backed capture so concurrent invocations do\n * not corrupt the global `console.log` / `process.stdout.write` /\n * `process.exit` pointers (see `cli-capture.ts`).\n */\nfunction wrapDefaultExport(\n name: string,\n defaultFn: (args: string[]) => Promise<void>,\n): ActionEntry {\n const tool: ActionTool = {\n description: `Run the \"${name}\" action. Pass arguments as key-value pairs.`,\n parameters: {\n type: \"object\",\n properties: {\n args: {\n type: \"string\",\n description:\n \"Space-separated CLI arguments (e.g. '--id abc --title Hello')\",\n },\n },\n },\n };\n\n return {\n tool,\n run: async (args: Record<string, string>): Promise<string> => {\n const cliArgs: string[] = [];\n // If only an \"args\" key was provided, split it into CLI tokens\n if (args.args && Object.keys(args).length === 1) {\n cliArgs.push(...splitShellArgs(args.args));\n } else {\n for (const [k, v] of Object.entries(args)) {\n cliArgs.push(`--${k}`, v);\n }\n }\n return captureCliOutput(() => defaultFn(cliArgs));\n },\n };\n}\n\nfunction preserveActionFlags(entry: Record<string, any>): Partial<ActionEntry> {\n const out: Partial<ActionEntry> = {};\n if (typeof entry.agentTool === \"boolean\") out.agentTool = entry.agentTool;\n if (typeof entry.requiresAuth === \"boolean\") {\n out.requiresAuth = entry.requiresAuth;\n }\n if (typeof entry.readOnly === \"boolean\") out.readOnly = entry.readOnly;\n if (typeof entry.allowInPlanMode === \"boolean\") {\n out.allowInPlanMode = entry.allowInPlanMode;\n }\n if (typeof entry.parallelSafe === \"boolean\") {\n out.parallelSafe = entry.parallelSafe;\n }\n if (typeof entry.toolCallable === \"boolean\") {\n out.toolCallable = entry.toolCallable;\n }\n if (\n entry.publicAgent &&\n typeof entry.publicAgent === \"object\" &&\n !Array.isArray(entry.publicAgent)\n ) {\n out.publicAgent = entry.publicAgent;\n }\n if (typeof entry.link === \"function\") {\n out.link = entry.link;\n }\n if (\n entry.mcpApp &&\n typeof entry.mcpApp === \"object\" &&\n !Array.isArray(entry.mcpApp)\n ) {\n out.mcpApp = entry.mcpApp;\n }\n if (\n entry.chatUI &&\n typeof entry.chatUI === \"object\" &&\n !Array.isArray(entry.chatUI)\n ) {\n out.chatUI = entry.chatUI;\n }\n if (typeof entry.timeoutMs === \"number\") out.timeoutMs = entry.timeoutMs;\n if (typeof entry.maxResultChars === \"number\") {\n out.maxResultChars = entry.maxResultChars;\n }\n if (\n typeof entry.needsApproval === \"boolean\" ||\n typeof entry.needsApproval === \"function\"\n ) {\n out.needsApproval = entry.needsApproval;\n }\n return out;\n}\n\nfunction shouldRetryWithJiti(filePath: string, err: unknown): boolean {\n if (!filePath.endsWith(\".ts\")) return false;\n const candidate = err as { code?: unknown; message?: unknown } | undefined;\n if (candidate?.code === \"ERR_UNKNOWN_FILE_EXTENSION\") return true;\n return /Unknown file extension \".ts\"/.test(String(candidate?.message ?? \"\"));\n}\n\nasync function importRuntimeSourceModule(\n filePath: string,\n): Promise<Record<string, any>> {\n try {\n return await import(/* @vite-ignore */ pathToFileURL(filePath).href);\n } catch (err) {\n if (!shouldRetryWithJiti(filePath, err)) throw err;\n\n const { createJiti } = await import(\"jiti\");\n const jiti = createJiti(pathToFileURL(filePath).href, {\n interopDefault: true,\n });\n return (await jiti.import(filePath)) as Record<string, any>;\n }\n}\n\n/**\n * Resolve the actions directory from the caller's context.\n *\n * @param from - Either an `import.meta.url` (file:// URL from a plugin file),\n * an absolute directory path, or \"auto\" to use `process.cwd() + \"/actions\"`.\n * When an import.meta.url is provided, the actions directory is resolved as\n * `../../actions/` relative to the caller (typically `server/plugins/agent-chat.ts`).\n * If the resolved directory doesn't exist, falls back to `../../scripts/` for\n * backwards compatibility, then to `process.cwd() + \"/actions\"`.\n */\nasync function resolveActionsDir(from: string): Promise<string> {\n const fs = await getFs();\n const exists = (p: string) => {\n try {\n return fs.existsSync(p);\n } catch {\n return false;\n }\n };\n // On edge runtimes (e.g. Cloudflare Workers), import.meta.url may be\n // undefined after bundling. Fall back to cwd-based discovery.\n if (!from) {\n const cwdActions = nodePath.join(process.cwd(), \"actions\");\n if (exists(cwdActions)) return cwdActions;\n return nodePath.join(process.cwd(), \"scripts\");\n }\n if (from.startsWith(\"file://\") || from.startsWith(\"file:///\")) {\n const callerPath = fileURLToPath(from);\n const callerDir = nodePath.dirname(callerPath);\n const actionsResolved = nodePath.resolve(callerDir, \"../../actions\");\n if (exists(actionsResolved)) return actionsResolved;\n const scriptsResolved = nodePath.resolve(callerDir, \"../../scripts\");\n if (exists(scriptsResolved)) return scriptsResolved;\n const cwdActions = nodePath.join(process.cwd(), \"actions\");\n if (exists(cwdActions)) return cwdActions;\n return nodePath.join(process.cwd(), \"scripts\");\n }\n if (from === \"auto\") {\n const cwdActions = nodePath.join(process.cwd(), \"actions\");\n if (exists(cwdActions)) return cwdActions;\n return nodePath.join(process.cwd(), \"scripts\");\n }\n return nodePath.resolve(from);\n}\n\n/**\n * Load actions from a single directory into the given registry. Shared by\n * both the template-actions discovery path and the workspace-core actions\n * layer. When `skipExisting` is true, an entry with the same name that's\n * already in the registry is left untouched (template-wins on collision).\n */\nasync function loadActionsIntoRegistry(\n actionsDir: string,\n registry: Record<string, ActionEntry>,\n skipExisting: boolean,\n): Promise<void> {\n let files: string[];\n try {\n const fs = await getFs();\n if (!fs.existsSync(actionsDir)) return;\n files = fs.readdirSync(actionsDir);\n } catch {\n return;\n }\n\n const actionFiles = files.filter((f) => {\n if (!isRuntimeSourceFile(f)) return false;\n const name = f.replace(/\\.(ts|js)$/, \"\");\n if (name.startsWith(\"_\")) return false;\n if (SKIP_FILES.has(name)) return false;\n return true;\n });\n\n for (const file of actionFiles) {\n const name = file.replace(/\\.(ts|js)$/, \"\");\n if (skipExisting && registry[name]) continue;\n\n const filePath = nodePath.join(actionsDir, file);\n try {\n const mod = await importRuntimeSourceModule(filePath);\n\n if (mod.tool && typeof mod.run === \"function\") {\n registry[name] = {\n tool: mod.tool,\n run: mod.run,\n ...(mod.http !== undefined ? { http: mod.http } : {}),\n ...preserveActionFlags(mod),\n };\n } else if (\n mod.default &&\n typeof mod.default === \"object\" &&\n mod.default.tool &&\n typeof mod.default.run === \"function\"\n ) {\n registry[name] = {\n tool: mod.default.tool,\n run: mod.default.run,\n ...(mod.default.http !== undefined ? { http: mod.default.http } : {}),\n ...preserveActionFlags(mod.default),\n };\n } else if (typeof mod.default === \"function\") {\n registry[name] = wrapDefaultExport(name, mod.default);\n }\n } catch (err) {\n // CLI-style scripts (top-level execution) throw on import — expected,\n // they're available via `pnpm action <name>` / shell instead. But a\n // syntax error, bad import, or malformed defineAction in a real action\n // file lands here too and would silently vanish from the agent's tools.\n // Warn so a broken action file is diagnosable instead of mysteriously\n // missing.\n const msg =\n err instanceof Error ? (err.stack ?? err.message) : String(err);\n console.warn(\n `[action-discovery] Skipped \"${file}\" — failed to import. If this is an ` +\n `agent action (not a CLI script), it will be missing from the agent's tools:\\n${msg}`,\n );\n }\n }\n}\n\n/**\n * Normalize a pre-bundled static action registry (name → raw module) into\n * the `Record<string, ActionEntry>` shape the agent-chat plugin expects.\n *\n * Used by `autoDiscoverActions` when `.generated/actions-registry.ts` is\n * present so that Nitro-bundled serverless functions (Netlify, Vercel,\n * AWS-Lambda) can serve `/_agent-native/actions/*` routes without relying\n * on a filesystem scan that doesn't work in bundled output.\n */\nexport function loadActionsFromStaticRegistry(\n modules: Record<string, unknown>,\n): Record<string, ActionEntry> {\n const registry: Record<string, ActionEntry> = {};\n for (const [name, raw] of Object.entries(modules)) {\n const mod = raw as Record<string, any> | null | undefined;\n if (!mod) continue;\n\n if (mod.tool && typeof mod.run === \"function\") {\n registry[name] = {\n tool: mod.tool,\n run: mod.run,\n ...(mod.http !== undefined ? { http: mod.http } : {}),\n ...preserveActionFlags(mod),\n };\n continue;\n }\n\n const def = mod.default;\n if (\n def &&\n typeof def === \"object\" &&\n def.tool &&\n typeof def.run === \"function\"\n ) {\n registry[name] = {\n tool: def.tool,\n run: def.run,\n ...(def.http !== undefined ? { http: def.http } : {}),\n ...preserveActionFlags(def),\n };\n continue;\n }\n\n if (typeof def === \"function\") {\n registry[name] = wrapDefaultExport(name, def);\n }\n }\n return registry;\n}\n\n/**\n * Auto-discover actions from a directory.\n *\n * Merges in any actions from the enterprise workspace core (if present in\n * the ancestor chain). Template actions take precedence over workspace-core\n * actions on name collision, so an app can override an enterprise-wide\n * action by dropping a same-named file under its own `actions/`.\n *\n * Note: this helper uses a filesystem scan, which works in dev and in\n * non-bundled Node deployments. In bundled serverless functions (Nitro's\n * netlify / vercel / aws-lambda presets) the `actions/` directory is not\n * on disk at runtime; templates should pass the static registry generated\n * by the Vite plugin to `createAgentChatPlugin({ actions })` instead, so\n * the bundler sees static imports and pulls every action into the bundle.\n *\n * @param from - The caller's `import.meta.url` or an absolute path to the\n * actions directory.\n * @returns A record mapping action names to ActionEntry objects, suitable for\n * passing to `createAgentChatPlugin({ actions })`.\n */\nexport async function autoDiscoverActions(\n from: string,\n): Promise<Record<string, ActionEntry>> {\n const actionsDir = await resolveActionsDir(from);\n const registry: Record<string, ActionEntry> = {};\n\n // 1. Template actions first — these are the authoritative layer for the\n // current app and must override any workspace-core entry with the same\n // name.\n try {\n await loadActionsIntoRegistry(actionsDir, registry, false);\n } catch (err: any) {\n console.warn(\n `[autoDiscoverActions] Could not read actions directory: ${actionsDir} — ${err?.message}`,\n );\n }\n\n // 1b. Fallback: if filesystem discovery found no template actions (common\n // in bundled serverless environments like Netlify/Vercel where the\n // actions/ directory doesn't exist on disk), try importing the\n // generated static registry at .generated/actions-registry.\n //\n // This prevents the silent-empty-tools footgun where the agent has no\n // template actions and falls back to generic tools like web-request.\n // Prefer `loadActionsFromStaticRegistry` over `autoDiscoverActions` for\n // production reliability — this fallback is a safety net, not the\n // primary path.\n if (Object.keys(registry).length === 0 && from) {\n try {\n let registryPath: string;\n if (from.startsWith(\"file://\") || from.startsWith(\"file:///\")) {\n const callerDir = nodePath.dirname(fileURLToPath(from));\n registryPath = nodePath.resolve(\n callerDir,\n \"../../.generated/actions-registry.js\",\n );\n } else {\n registryPath = nodePath.resolve(\n from,\n \"../.generated/actions-registry.js\",\n );\n }\n const mod = await import(/* @vite-ignore */ registryPath);\n const staticEntries = loadActionsFromStaticRegistry(mod.default || mod);\n Object.assign(registry, staticEntries);\n if (Object.keys(staticEntries).length > 0) {\n console.log(\n `[autoDiscoverActions] Filesystem scan found 0 actions — loaded ${Object.keys(staticEntries).length} from .generated/actions-registry.ts instead. ` +\n `Consider switching to loadActionsFromStaticRegistry(actionsRegistry) for production reliability.`,\n );\n }\n } catch {\n // No generated registry available — registry stays empty.\n }\n }\n\n // If still empty after all fallbacks, warn loudly.\n if (Object.keys(registry).length === 0) {\n console.warn(\n `[autoDiscoverActions] WARNING: No template actions found! ` +\n `The agent will have no template-specific tools. ` +\n `If in production, switch from autoDiscoverActions to loadActionsFromStaticRegistry. ` +\n `See: https://docs.agent-native.com/actions#static-registry`,\n );\n }\n\n // 1c. Package-registered actions — contributed by published packages\n // (e.g. @agent-native/dispatch) via `registerPackageActions()` from\n // import side effects. Merged with skip-existing so the template's\n // own actions/ files always win on name collision.\n for (const [name, entry] of Object.entries(getPackageActions())) {\n if (registry[name]) continue;\n registry[name] = entry;\n }\n\n // 2. Workspace-core actions — merged in with skipExisting so they can't\n // overwrite template entries.\n try {\n const { getWorkspaceCoreExports } =\n await import(\"../deploy/workspace-core.js\");\n const ws = await getWorkspaceCoreExports(process.cwd());\n if (ws && ws.actionsDir) {\n await loadActionsIntoRegistry(ws.actionsDir, registry, true);\n }\n } catch {\n // workspace-core discovery unavailable (e.g. edge runtime) — skip.\n }\n\n // 3. Framework-level sharing + file-upload actions — always available to any\n // template. Merged with skipExisting so templates can override by\n // providing a same-named file.\n try {\n await mergeCoreSharingActions(registry);\n } catch {\n // Ignore — templates without sharing still work.\n }\n\n return registry;\n}\n\nexport async function mergeCoreSharingActions(\n registry: Record<string, ActionEntry>,\n): Promise<void> {\n const entries: Array<[string, () => Promise<any>]> = [\n [\"share-resource\", () => import(\"../sharing/actions/share-resource.js\")],\n [\n \"unshare-resource\",\n () => import(\"../sharing/actions/unshare-resource.js\"),\n ],\n [\n \"list-resource-shares\",\n () => import(\"../sharing/actions/list-resource-shares.js\"),\n ],\n [\n \"set-resource-visibility\",\n () => import(\"../sharing/actions/set-resource-visibility.js\"),\n ],\n [\n \"create-agent-resource-link\",\n () => import(\"../sharing/actions/create-agent-resource-link.js\"),\n ],\n [\"upload-image\", () => import(\"../file-upload/actions/upload-image.js\")],\n // Agent Jobs page — UI-only scoped reads and mutations for resource-backed\n // recurring jobs and personal automations. The agent-facing native tools\n // remain the canonical conversational surface.\n [\n \"list-recurring-jobs\",\n () => import(\"../jobs/actions/list-recurring-jobs.js\"),\n ],\n [\n \"manage-recurring-job\",\n () => import(\"../jobs/actions/manage-recurring-job.js\"),\n ],\n [\n \"list-automations\",\n () => import(\"../triggers/actions/list-automations.js\"),\n ],\n [\n \"manage-automation\",\n () => import(\"../triggers/actions/manage-automation.js\"),\n ],\n [\n \"context-manifest-get\",\n () => import(\"../agent/context-xray/actions/context-manifest-get.js\"),\n ],\n [\n \"context-preview-get\",\n () => import(\"../agent/context-xray/actions/context-preview-get.js\"),\n ],\n [\n \"context-pin\",\n () => import(\"../agent/context-xray/actions/context-pin.js\"),\n ],\n [\n \"context-evict\",\n () => import(\"../agent/context-xray/actions/context-evict.js\"),\n ],\n [\n \"context-restore\",\n () => import(\"../agent/context-xray/actions/context-restore.js\"),\n ],\n [\n \"context-report\",\n () => import(\"../agent/context-xray/actions/context-report.js\"),\n ],\n [\n \"get-localization-preference\",\n () => import(\"../localization/actions/get-localization-preference.js\"),\n ],\n [\n \"set-localization-preference\",\n () => import(\"../localization/actions/set-localization-preference.js\"),\n ],\n [\n \"change-appearance\",\n () => import(\"../appearance/actions/change-appearance.js\"),\n ],\n // Audit log — read surface (who changed what, when, agent vs human).\n [\n \"list-audit-events\",\n () => import(\"../audit/actions/list-audit-events.js\"),\n ],\n [\"get-audit-event\", () => import(\"../audit/actions/get-audit-event.js\")],\n [\n \"export-audit-events\",\n () => import(\"../audit/actions/export-audit-events.js\"),\n ],\n // History kit — reusable version snapshots and restore surface.\n [\n \"create-resource-version\",\n () => import(\"../history/actions/create-resource-version.js\"),\n ],\n [\n \"list-resource-versions\",\n () => import(\"../history/actions/list-resource-versions.js\"),\n ],\n [\n \"get-resource-version\",\n () => import(\"../history/actions/get-resource-version.js\"),\n ],\n [\n \"restore-resource-version\",\n () => import(\"../history/actions/restore-resource-version.js\"),\n ],\n [\n \"list-resource-history\",\n () => import(\"../history/actions/list-resource-history.js\"),\n ],\n // Comments/review kit — reusable inline comments, feedback, and review status.\n [\n \"list-review-comments\",\n () => import(\"../review/actions/list-review-comments.js\"),\n ],\n [\n \"create-review-comment\",\n () => import(\"../review/actions/create-review-comment.js\"),\n ],\n [\n \"reply-review-comment\",\n () => import(\"../review/actions/reply-review-comment.js\"),\n ],\n [\n \"resolve-review-thread\",\n () => import(\"../review/actions/resolve-review-thread.js\"),\n ],\n [\n \"delete-review-comment\",\n () => import(\"../review/actions/delete-review-comment.js\"),\n ],\n [\n \"consume-review-feedback\",\n () => import(\"../review/actions/consume-review-feedback.js\"),\n ],\n [\n \"get-review-feedback\",\n () => import(\"../review/actions/get-review-feedback.js\"),\n ],\n [\n \"set-review-status\",\n () => import(\"../review/actions/set-review-status.js\"),\n ],\n [\n \"send-review-thread-to-agent\",\n () => import(\"../review/actions/send-review-thread-to-agent.js\"),\n ],\n // Org service tokens (CI credentials, e.g. PLAN_RECAP_TOKEN). Mint/revoke\n // are toolCallable:false — preserved via preserveActionFlags below.\n [\n \"create-org-service-token\",\n () => import(\"../mcp/actions/create-org-service-token.js\"),\n ],\n [\n \"list-org-service-tokens\",\n () => import(\"../mcp/actions/list-org-service-tokens.js\"),\n ],\n [\n \"revoke-org-service-token\",\n () => import(\"../mcp/actions/revoke-org-service-token.js\"),\n ],\n ];\n for (const [name, loader] of entries) {\n if (registry[name]) continue;\n try {\n const mod = await loader();\n const def = mod.default;\n if (def && def.tool && typeof def.run === \"function\") {\n registry[name] = {\n tool: def.tool,\n run: def.run,\n ...(def.http !== undefined ? { http: def.http } : {}),\n // Carry security-relevant flags (toolCallable, publicAgent, link,\n // mcpApp) plus readOnly/parallelSafe. Without this, the sharing\n // actions' `toolCallable: false` (audit-H5) is dropped and the\n // tools-iframe bridge 403 in action-routes.ts never fires.\n ...preserveActionFlags(def),\n };\n }\n } catch {\n // Skip any sharing action that fails to import.\n }\n }\n}\n\n/** @deprecated Use `autoDiscoverActions` instead */\nexport const autoDiscoverScripts = autoDiscoverActions;\n"]}
|
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
import type { ActionEntry } from "../agent/production-agent.js";
|
|
2
|
+
import { type AgentRunOwnerContext } from "./agent-run-context.js";
|
|
2
3
|
export declare function parseActionSearchParams(searchParams: URLSearchParams): Record<string, any>;
|
|
4
|
+
/**
|
|
5
|
+
* Declarative auth adapter for the HTTP action route. Its `resolveCaller` runs
|
|
6
|
+
* BEFORE the framework's `getOwnerFromEvent` / `getSession` chain, letting an
|
|
7
|
+
* app accept caller identities `getSession` doesn't understand (e.g. an A2A
|
|
8
|
+
* JWT) without reaching into request context from a Nitro `request` hook.
|
|
9
|
+
*
|
|
10
|
+
* Scoped to `/_agent-native/actions/*` only — it does not affect other routes.
|
|
11
|
+
*/
|
|
12
|
+
export type ActionRouteResolvedCaller = AgentRunOwnerContext & {
|
|
13
|
+
/**
|
|
14
|
+
* Org to scope the request to, verified from the same credential as the
|
|
15
|
+
* caller identity (e.g. the A2A token's org claim). When omitted, the org
|
|
16
|
+
* is derived from the verified owner email via the framework's owner→org
|
|
17
|
+
* membership lookup. The ambient session/org state on the request is never
|
|
18
|
+
* consulted for adapter-resolved callers: a request can carry both a valid
|
|
19
|
+
* A2A bearer and an unrelated browser cookie, and the cookie user's org
|
|
20
|
+
* must not leak into the token caller's request context.
|
|
21
|
+
*/
|
|
22
|
+
orgId?: string;
|
|
23
|
+
};
|
|
24
|
+
export interface ActionRouteAuthAdapter {
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a caller from the raw event before the cookie/bearer chain.
|
|
27
|
+
*
|
|
28
|
+
* - Return the resolved caller to run the action scoped to that identity.
|
|
29
|
+
* Org scoping comes exclusively from the caller: the returned `orgId` if
|
|
30
|
+
* set, otherwise the owner-email membership lookup — never from the
|
|
31
|
+
* request's session cookie or org context.
|
|
32
|
+
* - Return `null` when the credential isn't yours to judge — the request
|
|
33
|
+
* defers to `getOwnerFromEvent` / `getSession`.
|
|
34
|
+
* - THROW to hard-reject: the credential is present but invalid (e.g. an
|
|
35
|
+
* expired or forged A2A bearer). The action route responds 401 and does
|
|
36
|
+
* NOT fall through to the cookie/session chain, so a valid same-origin
|
|
37
|
+
* session cookie can't be used to execute the request as the logged-in
|
|
38
|
+
* user. Do not throw merely to signal "not mine" — return `null` for that.
|
|
39
|
+
*/
|
|
40
|
+
resolveCaller?: (event: any) => ActionRouteResolvedCaller | null | Promise<ActionRouteResolvedCaller | null>;
|
|
41
|
+
}
|
|
3
42
|
export interface MountActionRoutesOptions {
|
|
4
43
|
/** Resolve owner email from the H3 event (for data scoping). */
|
|
5
44
|
getOwnerFromEvent?: (event: any) => string | Promise<string>;
|
|
@@ -7,6 +46,12 @@ export interface MountActionRoutesOptions {
|
|
|
7
46
|
getUserNameFromEvent?: (event: any) => string | undefined | Promise<string | undefined>;
|
|
8
47
|
/** Resolve org ID from the H3 event (for org scoping). */
|
|
9
48
|
resolveOrgId?: (event: any) => string | null | Promise<string | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Optional caller resolver that runs before the `getOwnerFromEvent` /
|
|
51
|
+
* `getSession` chain. Lets apps accept A2A JWTs (or other bearer schemes) on
|
|
52
|
+
* the action route declaratively. See {@link ActionRouteAuthAdapter}.
|
|
53
|
+
*/
|
|
54
|
+
actionRouteAuth?: ActionRouteAuthAdapter;
|
|
10
55
|
}
|
|
11
56
|
/**
|
|
12
57
|
* Mount discovered actions as HTTP endpoints.
|