@agent-native/core 0.132.1 → 0.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +198 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/correlation.ts +11 -1
- package/corpus/core/src/a2a/types.ts +11 -3
- package/corpus/core/src/agent/engine/ai-sdk-engine.ts +33 -46
- package/corpus/core/src/agent/engine/builder-engine.ts +22 -10
- package/corpus/core/src/agent/engine/error-detail.ts +184 -3
- package/corpus/core/src/agent/engine/failure-taxonomy.ts +123 -0
- package/corpus/core/src/agent/engine/index.ts +8 -0
- package/corpus/core/src/agent/engine/registry.ts +92 -8
- package/corpus/core/src/agent/engine/translate-ai-sdk.ts +17 -2
- package/corpus/core/src/agent/production-agent.ts +13 -33
- package/corpus/core/src/agent/run-loop-with-resume.ts +1 -1
- package/corpus/core/src/agent/run-manager.ts +43 -14
- package/corpus/core/src/agent/run-store.ts +30 -3
- package/corpus/core/src/agent/thread-data-builder.ts +36 -4
- package/corpus/core/src/chat-threads/store.ts +42 -0
- package/corpus/core/src/cli/templates-meta.ts +13 -0
- package/corpus/core/src/cli/workspace-dev.ts +1 -0
- package/corpus/core/src/client/error-format.ts +12 -0
- package/corpus/core/src/client/use-chat-threads.ts +76 -16
- package/corpus/core/src/credentials/index.ts +51 -12
- package/corpus/core/src/extensions/url-safety.ts +46 -12
- package/corpus/core/src/integrations/adapters/slack.ts +32 -10
- package/corpus/core/src/integrations/google-docs-poller.ts +12 -1
- package/corpus/core/src/integrations/installations-store.ts +30 -0
- package/corpus/core/src/integrations/plugin.ts +5 -5
- package/corpus/core/src/integrations/types.ts +7 -0
- package/corpus/core/src/integrations/webhook-handler.ts +24 -1
- package/corpus/core/src/jobs/background-automation-runner.ts +38 -1
- package/corpus/core/src/provider-api/index.ts +8 -2
- package/corpus/core/src/scripts/call-agent.ts +6 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +46 -10
- package/corpus/core/src/server/agent-discovery.ts +2 -0
- package/corpus/core/src/server/builder-design-systems.ts +21 -0
- package/corpus/core/src/server/credential-provider.ts +51 -12
- package/corpus/core/src/server/index.ts +1 -0
- package/corpus/core/src/server/onboarding-html.ts +37 -2
- package/corpus/core/src/shared/reasoning-effort.ts +1 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +11 -0
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +6 -2
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +39 -19
- package/corpus/templates/assets/changelog/2026-07-31-the-agent-native-logo-stays-visible-when-the-sidebar-is-coll.md +6 -0
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +30 -3
- package/corpus/templates/brain/changelog/2026-07-31-clicking-the-agent-native-logo-now-toggles-the-app-sidebar.md +6 -0
- package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +1 -1
- package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +54 -25
- package/corpus/templates/calendar/changelog/2026-07-31-the-agent-native-logo-stays-visible-when-the-sidebar-is-coll.md +6 -0
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +30 -3
- package/corpus/templates/chat/changelog/2026-07-31-clicking-the-agent-native-logo-now-toggles-the-app-sidebar.md +6 -0
- package/corpus/templates/clips/app/components/library/library-layout.tsx +37 -21
- package/corpus/templates/clips/changelog/2026-07-30-meeting-microphone-transcription-works-reliably-from-the-fir.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-31-the-agent-native-logo-stays-visible-when-the-sidebar-is-coll.md +6 -0
- package/corpus/templates/clips/desktop/src/hooks/useMediaDevices.ts +1 -1
- package/corpus/templates/clips/desktop/src/lib/media-capture-constraints.ts +1 -1
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen/custom_capture.rs +13 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +2 -0
- package/corpus/templates/clips/desktop/src-tauri/src/system_audio.rs +25 -132
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +34 -17
- package/corpus/templates/content/changelog/2026-07-31-the-agent-native-logo-stays-visible-when-the-sidebar-is-coll.md +6 -0
- package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +6 -2
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +5 -0
- package/corpus/templates/design/actions/create-design-system.ts +1 -0
- package/corpus/templates/design/actions/set-default-design-system.ts +34 -26
- package/corpus/templates/design/app/components/design/KeyboardShortcutsPanel.tsx +5 -3
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +23 -0
- package/corpus/templates/design/app/components/design/keyboard-shortcuts.ts +3 -0
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +21 -4
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +11 -7
- package/corpus/templates/design/app/i18n-data.ts +39 -0
- package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +229 -12
- package/corpus/templates/design/app/pages/DesignSystems.tsx +10 -4
- package/corpus/templates/design/changelog/2026-07-30-fixed-the-keyboard-shortcuts-panel-not-opening-with-ctrl-shi.md +6 -0
- package/corpus/templates/design/changelog/2026-07-31-clicking-the-agent-native-logo-now-toggles-the-app-sidebar.md +6 -0
- package/corpus/templates/design/changelog/2026-07-31-design-system-indexing-keeps-your-chosen-name-when-you-uploa.md +6 -0
- package/corpus/templates/design/server/lib/builder-design-system-proxy.ts +19 -4
- package/corpus/templates/dispatch/AGENTS.md +4 -0
- package/corpus/templates/factory/.agents/skills/actions/SKILL.md +562 -0
- package/corpus/templates/factory/.agents/skills/adding-a-feature/SKILL.md +198 -0
- package/corpus/templates/factory/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/factory/.agents/skills/agent-native-toolkit/SKILL.md +182 -0
- package/corpus/templates/factory/.agents/skills/capture-learnings/SKILL.md +89 -0
- package/corpus/templates/factory/.agents/skills/create-skill/SKILL.md +221 -0
- package/corpus/templates/factory/.agents/skills/customizing-agent-native/SKILL.md +220 -0
- package/corpus/templates/factory/.agents/skills/delegate-to-agent/SKILL.md +263 -0
- package/corpus/templates/factory/.agents/skills/factory-graphs/SKILL.md +52 -0
- package/corpus/templates/factory/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/factory/.agents/skills/frontend-design/SKILL.md +174 -0
- package/corpus/templates/factory/.agents/skills/real-time-sync/SKILL.md +232 -0
- package/corpus/templates/factory/.agents/skills/security/SKILL.md +324 -0
- package/corpus/templates/factory/.agents/skills/self-modifying-code/SKILL.md +119 -0
- package/corpus/templates/factory/.agents/skills/shadcn-ui/SKILL.md +123 -0
- package/corpus/templates/factory/.agents/skills/sharing/SKILL.md +232 -0
- package/corpus/templates/factory/.agents/skills/storing-data/SKILL.md +178 -0
- package/corpus/templates/factory/.agents/skills/upgrade-agent-native/SKILL.md +122 -0
- package/corpus/templates/factory/.env.example +24 -0
- package/corpus/templates/factory/.ignore +0 -0
- package/corpus/templates/factory/.oxfmtrc.json +8 -0
- package/corpus/templates/factory/AGENTS.md +90 -0
- package/corpus/templates/factory/CHANGELOG.md +10 -0
- package/corpus/templates/factory/DEVELOPING.md +185 -0
- package/corpus/templates/factory/README.md +64 -0
- package/corpus/templates/factory/_gitignore +42 -0
- package/corpus/templates/factory/actions/add-factory-comment.ts +55 -0
- package/corpus/templates/factory/actions/approve-factory-item.ts +214 -0
- package/corpus/templates/factory/actions/babysit-pull-request.ts +126 -0
- package/corpus/templates/factory/actions/evaluate-triage-item.ts +172 -0
- package/corpus/templates/factory/actions/get-factory-graph.ts +62 -0
- package/corpus/templates/factory/actions/get-triage-config.ts +42 -0
- package/corpus/templates/factory/actions/get-triage-item.ts +74 -0
- package/corpus/templates/factory/actions/hello.ts +13 -0
- package/corpus/templates/factory/actions/ingest-github-observation.ts +100 -0
- package/corpus/templates/factory/actions/list-factories.ts +40 -0
- package/corpus/templates/factory/actions/list-factory-comments.ts +40 -0
- package/corpus/templates/factory/actions/list-triage-items.ts +85 -0
- package/corpus/templates/factory/actions/list-triage-rules.ts +44 -0
- package/corpus/templates/factory/actions/navigate.ts +41 -0
- package/corpus/templates/factory/actions/poll-slack-channel.ts +118 -0
- package/corpus/templates/factory/actions/reconcile-triage-run.ts +179 -0
- package/corpus/templates/factory/actions/record-triage-feedback.ts +58 -0
- package/corpus/templates/factory/actions/run.ts +2 -0
- package/corpus/templates/factory/actions/save-factory-graph.ts +129 -0
- package/corpus/templates/factory/actions/save-triage-config.ts +67 -0
- package/corpus/templates/factory/actions/save-triage-rule.ts +89 -0
- package/corpus/templates/factory/actions/suggest-factory-rules.ts +70 -0
- package/corpus/templates/factory/actions/view-screen.ts +73 -0
- package/corpus/templates/factory/app/components/factory/FactoryCanvas.tsx +441 -0
- package/corpus/templates/factory/app/components/factory/FactoryInspector.tsx +388 -0
- package/corpus/templates/factory/app/components/layout/Header.tsx +60 -0
- package/corpus/templates/factory/app/components/layout/Layout.tsx +190 -0
- package/corpus/templates/factory/app/components/layout/Sidebar.tsx +538 -0
- package/corpus/templates/factory/app/components/triage/triage-status-pill.tsx +28 -0
- package/corpus/templates/factory/app/components/ui/button.tsx +1 -0
- package/corpus/templates/factory/app/components/ui/card.tsx +1 -0
- package/corpus/templates/factory/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/templates/factory/app/components/ui/input.tsx +1 -0
- package/corpus/templates/factory/app/components/ui/label.tsx +1 -0
- package/corpus/templates/factory/app/components/ui/sheet.tsx +1 -0
- package/corpus/templates/factory/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/factory/app/components/ui/toolkit-provider.tsx +17 -0
- package/corpus/templates/factory/app/components/ui/tooltip.tsx +1 -0
- package/corpus/templates/factory/app/design-system.ts +3 -0
- package/corpus/templates/factory/app/entry.client.tsx +22 -0
- package/corpus/templates/factory/app/entry.server.tsx +10 -0
- package/corpus/templates/factory/app/global.css +93 -0
- package/corpus/templates/factory/app/hooks/use-navigation-state.ts +113 -0
- package/corpus/templates/factory/app/i18n/en-US.ts +211 -0
- package/corpus/templates/factory/app/i18n/index.ts +34 -0
- package/corpus/templates/factory/app/i18n-data.ts +556 -0
- package/corpus/templates/factory/app/lib/agent-page.tsx +49 -0
- package/corpus/templates/factory/app/lib/app-config.ts +11 -0
- package/corpus/templates/factory/app/lib/tab-id.ts +1 -0
- package/corpus/templates/factory/app/lib/utils.ts +1 -0
- package/corpus/templates/factory/app/root.tsx +175 -0
- package/corpus/templates/factory/app/routes/_index.tsx +94 -0
- package/corpus/templates/factory/app/routes/agent.tsx +24 -0
- package/corpus/templates/factory/app/routes/chat.$threadId.tsx +1 -0
- package/corpus/templates/factory/app/routes/database.tsx +17 -0
- package/corpus/templates/factory/app/routes/extensions.$id.$slug.tsx +2 -0
- package/corpus/templates/factory/app/routes/extensions.$id.tsx +11 -0
- package/corpus/templates/factory/app/routes/extensions._index.tsx +11 -0
- package/corpus/templates/factory/app/routes/extensions.tsx +5 -0
- package/corpus/templates/factory/app/routes/factory.tsx +1003 -0
- package/corpus/templates/factory/app/routes/observability.tsx +19 -0
- package/corpus/templates/factory/app/routes/settings.tsx +89 -0
- package/corpus/templates/factory/app/routes/team.tsx +11 -0
- package/corpus/templates/factory/app/routes.ts +4 -0
- package/corpus/templates/factory/app/vite-env.d.ts +6 -0
- package/corpus/templates/factory/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/factory/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/factory/changelog/2026-06-27-traditional-chinese-copy-uses-taiwan-terminology.md +6 -0
- package/corpus/templates/factory/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
- package/corpus/templates/factory/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
- package/corpus/templates/factory/changelog/2026-07-10-chat-now-makes-ai-connection-setup-clear-without-shifting-th.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-14-chat-opens-reliably-on-hosted-deployments-instead-of-failing.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-15-chat-navigation-focuses-on-chat-and-agent.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-22-manage-agent-navigation-now-uses-the-connected-nodes-icon.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-23-full-page-chat-is-better-centered-with-quieter-chat-history-.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-24-borderless-secondary-surfaces.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-24-sidebar-footer-controls-follow-a-consistent-order.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-31-added-an-inspectable-observe-only-factory-queue-for-slack-.md +6 -0
- package/corpus/templates/factory/changelog/2026-07-31-clicking-the-agent-native-logo-now-toggles-the-app-sidebar.md +6 -0
- package/corpus/templates/factory/components.json +20 -0
- package/corpus/templates/factory/data/sync-config.json +1 -0
- package/corpus/templates/factory/learnings.defaults.md +5 -0
- package/corpus/templates/factory/netlify.toml +10 -0
- package/corpus/templates/factory/package.json +105 -0
- package/corpus/templates/factory/public/agent-native-icon-dark.svg +10 -0
- package/corpus/templates/factory/public/agent-native-icon-light.svg +10 -0
- package/corpus/templates/factory/public/agent-native-logo-dark.svg +21 -0
- package/corpus/templates/factory/public/agent-native-logo-light.svg +21 -0
- package/corpus/templates/factory/public/favicon.svg +1 -0
- package/corpus/templates/factory/public/icon-180.svg +1 -0
- package/corpus/templates/factory/public/icon-192.svg +1 -0
- package/corpus/templates/factory/public/icon-512.svg +1 -0
- package/corpus/templates/factory/public/manifest.json +21 -0
- package/corpus/templates/factory/react-router.config.ts +7 -0
- package/corpus/templates/factory/server/connectors/credentials.ts +129 -0
- package/corpus/templates/factory/server/connectors/slack.ts +129 -0
- package/corpus/templates/factory/server/db/index.ts +6 -0
- package/corpus/templates/factory/server/db/schema.ts +193 -0
- package/corpus/templates/factory/server/factory-graph/contracts.ts +212 -0
- package/corpus/templates/factory/server/factory-graph/store.ts +121 -0
- package/corpus/templates/factory/server/lib/require-workspace-member.ts +55 -0
- package/corpus/templates/factory/server/middleware/auth.ts +15 -0
- package/corpus/templates/factory/server/plugins/agent-chat.ts +58 -0
- package/corpus/templates/factory/server/plugins/auth.ts +14 -0
- package/corpus/templates/factory/server/plugins/factory-migrations.ts +247 -0
- package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +116 -0
- package/corpus/templates/factory/server/plugins/integrations.ts +46 -0
- package/corpus/templates/factory/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/factory/server/routes/_agent-native/factory/builder-callback.post.ts +116 -0
- package/corpus/templates/factory/server/triage/ai-services-git.ts +197 -0
- package/corpus/templates/factory/server/triage/builder-executor.ts +118 -0
- package/corpus/templates/factory/server/triage/contracts.ts +164 -0
- package/corpus/templates/factory/server/triage/github-ingestion.ts +35 -0
- package/corpus/templates/factory/server/triage/guards.ts +121 -0
- package/corpus/templates/factory/server/triage/ids.ts +27 -0
- package/corpus/templates/factory/server/triage/pr-babysit.ts +100 -0
- package/corpus/templates/factory/server/triage/pr-monitor.ts +220 -0
- package/corpus/templates/factory/server/triage/slack-client.ts +55 -0
- package/corpus/templates/factory/server/triage/slack-poller.ts +152 -0
- package/corpus/templates/factory/ssr-entry.ts +15 -0
- package/corpus/templates/factory/tsconfig.json +21 -0
- package/corpus/templates/factory/vite.config.ts +19 -0
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +55 -5
- package/corpus/templates/forms/changelog/2026-07-31-the-agent-native-logo-stays-visible-when-the-sidebar-is-coll.md +6 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +6 -2
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +21 -6
- package/corpus/templates/plan/changelog/2026-07-31-clicking-the-agent-native-logo-now-toggles-the-app-sidebar.md +6 -0
- package/corpus/templates/slides/.agents/skills/create-deck/SKILL.md +12 -0
- package/corpus/templates/slides/.agents/skills/design-systems/SKILL.md +9 -0
- package/corpus/templates/slides/.agents/skills/slide-editing/SKILL.md +11 -0
- package/corpus/templates/slides/AGENTS.md +5 -6
- package/corpus/templates/slides/actions/_await-fit-check.ts +20 -10
- package/corpus/templates/slides/actions/add-slide.ts +17 -4
- package/corpus/templates/slides/actions/create-design-system.ts +16 -4
- package/corpus/templates/slides/actions/delete-design-system.ts +18 -2
- package/corpus/templates/slides/actions/get-layout-overflows.ts +88 -0
- package/corpus/templates/slides/actions/import-file.ts +1 -0
- package/corpus/templates/slides/actions/index-design-system-with-builder.ts +8 -0
- package/corpus/templates/slides/actions/patch-deck.ts +48 -16
- package/corpus/templates/slides/actions/set-default-design-system.ts +49 -19
- package/corpus/templates/slides/actions/update-slide.ts +13 -3
- package/corpus/templates/slides/actions/view-screen.ts +87 -10
- package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +155 -28
- package/corpus/templates/slides/app/components/design-system/DesignSystemCard.tsx +21 -17
- package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +849 -341
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +102 -2
- package/corpus/templates/slides/app/components/editor/PromptDialog.tsx +13 -16
- package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +60 -12
- package/corpus/templates/slides/app/components/editor/SlideOverflowWarning.tsx +11 -1
- package/corpus/templates/slides/app/components/layout/Sidebar.tsx +66 -19
- package/corpus/templates/slides/app/i18n/en-US.ts +23 -0
- package/corpus/templates/slides/app/lib/normalize-slide-padding.ts +8 -15
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +4 -3
- package/corpus/templates/slides/app/pages/DesignSystems.tsx +4 -3
- package/corpus/templates/slides/app/pages/Index.tsx +1 -1
- package/corpus/templates/slides/changelog/2026-07-31-design-system-details-now-show-their-source-and-indexing-sta.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-31-design-system-indexing-keeps-your-chosen-name-when-you-uploa.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-31-design-system-setup-keeps-focus-rings-visible-and-uses-a-sim.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-31-skip-prompt-is-now-available-in-the-new-deck-prompt-header.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-31-slides-now-detect-real-text-and-box-overflow-across-the-deck.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-31-the-agent-native-logo-stays-visible-when-the-sidebar-is-coll.md +6 -0
- package/corpus/templates/slides/server/handlers/design-systems.ts +1 -0
- package/corpus/templates/slides/server/handlers/index-design-system-sources.ts +1 -0
- package/corpus/templates/slides/server/lib/builder-design-system-proxy.ts +23 -4
- package/corpus/templates/slides/server/plugins/agent-chat.ts +5 -0
- package/corpus/templates/slides/server/plugins/creative-context.ts +16 -3
- package/corpus/templates/slides/server/workspace-defaults.ts +5 -1
- package/corpus/templates/slides/shared/slide-fit.ts +26 -0
- package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +30 -3
- package/corpus/templates/tasks/changelog/2026-07-31-clicking-the-agent-native-logo-now-toggles-the-app-sidebar.md +6 -0
- package/dist/a2a/correlation.d.ts +4 -1
- package/dist/a2a/correlation.d.ts.map +1 -1
- package/dist/a2a/correlation.js +8 -1
- package/dist/a2a/correlation.js.map +1 -1
- package/dist/a2a/types.d.ts +11 -3
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/a2a/types.js.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +27 -41
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +18 -8
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/error-detail.d.ts +61 -0
- package/dist/agent/engine/error-detail.d.ts.map +1 -1
- package/dist/agent/engine/error-detail.js +145 -3
- package/dist/agent/engine/error-detail.js.map +1 -1
- package/dist/agent/engine/failure-taxonomy.d.ts +24 -0
- package/dist/agent/engine/failure-taxonomy.d.ts.map +1 -0
- package/dist/agent/engine/failure-taxonomy.js +88 -0
- package/dist/agent/engine/failure-taxonomy.js.map +1 -0
- package/dist/agent/engine/index.d.ts +2 -1
- package/dist/agent/engine/index.d.ts.map +1 -1
- package/dist/agent/engine/index.js +2 -1
- package/dist/agent/engine/index.js.map +1 -1
- package/dist/agent/engine/registry.d.ts +16 -0
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +71 -6
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/engine/translate-ai-sdk.d.ts.map +1 -1
- package/dist/agent/engine/translate-ai-sdk.js +14 -2
- package/dist/agent/engine/translate-ai-sdk.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +13 -24
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.js +1 -1
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +39 -10
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +10 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +20 -3
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +28 -4
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/chat-threads/store.d.ts +13 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +35 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +13 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/cli/workspace-dev.d.ts.map +1 -1
- package/dist/cli/workspace-dev.js +1 -0
- package/dist/cli/workspace-dev.js.map +1 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +10 -0
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +66 -16
- package/dist/client/use-chat-threads.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/credentials/index.d.ts +9 -2
- package/dist/credentials/index.d.ts.map +1 -1
- package/dist/credentials/index.js +50 -8
- package/dist/credentials/index.js.map +1 -1
- package/dist/extensions/url-safety.d.ts.map +1 -1
- package/dist/extensions/url-safety.js +38 -12
- package/dist/extensions/url-safety.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +25 -8
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/google-docs-poller.d.ts.map +1 -1
- package/dist/integrations/google-docs-poller.js +13 -1
- package/dist/integrations/google-docs-poller.js.map +1 -1
- package/dist/integrations/installations-store.d.ts +10 -0
- package/dist/integrations/installations-store.d.ts.map +1 -1
- package/dist/integrations/installations-store.js +24 -0
- package/dist/integrations/installations-store.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +6 -5
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/types.d.ts +7 -0
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +16 -1
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/jobs/background-automation-runner.d.ts.map +1 -1
- package/dist/jobs/background-automation-runner.js +35 -2
- package/dist/jobs/background-automation-runner.js.map +1 -1
- package/dist/notifications/routes.d.ts +6 -6
- package/dist/observability/routes.d.ts +3 -3
- package/dist/provider-api/actions/custom-provider-registration.d.ts +14 -14
- package/dist/provider-api/actions/provider-api.d.ts +8 -8
- package/dist/provider-api/index.js +7 -3
- package/dist/provider-api/index.js.map +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +6 -1
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +38 -9
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-discovery.d.ts +2 -0
- package/dist/server/agent-discovery.d.ts.map +1 -1
- package/dist/server/agent-discovery.js.map +1 -1
- package/dist/server/builder-design-systems.d.ts +4 -1
- package/dist/server/builder-design-systems.d.ts.map +1 -1
- package/dist/server/builder-design-systems.js +11 -1
- package/dist/server/builder-design-systems.js.map +1 -1
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +49 -12
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +37 -2
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/shared/reasoning-effort.d.ts +1 -0
- package/dist/shared/reasoning-effort.d.ts.map +1 -1
- package/dist/shared/reasoning-effort.js +1 -1
- package/dist/shared/reasoning-effort.js.map +1 -1
- package/dist/templates/chat/app/components/layout/Sidebar.tsx +30 -3
- package/dist/templates/chat/changelog/2026-07-31-clicking-the-agent-native-logo-now-toggles-the-app-sidebar.md +6 -0
- package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +11 -0
- package/package.json +1 -1
- package/src/a2a/correlation.ts +11 -1
- package/src/a2a/types.ts +11 -3
- package/src/agent/engine/ai-sdk-engine.ts +33 -46
- package/src/agent/engine/builder-engine.ts +22 -10
- package/src/agent/engine/error-detail.ts +184 -3
- package/src/agent/engine/failure-taxonomy.ts +123 -0
- package/src/agent/engine/index.ts +8 -0
- package/src/agent/engine/registry.ts +92 -8
- package/src/agent/engine/translate-ai-sdk.ts +17 -2
- package/src/agent/production-agent.ts +13 -33
- package/src/agent/run-loop-with-resume.ts +1 -1
- package/src/agent/run-manager.ts +43 -14
- package/src/agent/run-store.ts +30 -3
- package/src/agent/thread-data-builder.ts +36 -4
- package/src/chat-threads/store.ts +42 -0
- package/src/cli/templates-meta.ts +13 -0
- package/src/cli/workspace-dev.ts +1 -0
- package/src/client/error-format.ts +12 -0
- package/src/client/use-chat-threads.ts +76 -16
- package/src/credentials/index.ts +51 -12
- package/src/extensions/url-safety.ts +46 -12
- package/src/integrations/adapters/slack.ts +32 -10
- package/src/integrations/google-docs-poller.ts +12 -1
- package/src/integrations/installations-store.ts +30 -0
- package/src/integrations/plugin.ts +5 -5
- package/src/integrations/types.ts +7 -0
- package/src/integrations/webhook-handler.ts +24 -1
- package/src/jobs/background-automation-runner.ts +38 -1
- package/src/provider-api/index.ts +8 -2
- package/src/scripts/call-agent.ts +6 -0
- package/src/server/agent-chat-plugin.ts +46 -10
- package/src/server/agent-discovery.ts +2 -0
- package/src/server/builder-design-systems.ts +21 -0
- package/src/server/credential-provider.ts +51 -12
- package/src/server/index.ts +1 -0
- package/src/server/onboarding-html.ts +37 -2
- package/src/shared/reasoning-effort.ts +1 -1
- package/src/templates/chat/app/components/layout/Sidebar.tsx +30 -3
- package/src/templates/chat/changelog/2026-07-31-clicking-the-agent-native-logo-now-toggles-the-app-sidebar.md +6 -0
- package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +11 -0
- package/corpus/templates/clips/desktop/src/lib/media-device-selection.ts +0 -157
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ActionRunContext } from "@agent-native/core/action";
|
|
2
|
+
import { orgMembers, resolveOrgIdForEmail } from "@agent-native/core/org";
|
|
3
|
+
import {
|
|
4
|
+
getRequestOrgId,
|
|
5
|
+
getRequestUserEmail,
|
|
6
|
+
} from "@agent-native/core/server/request-context";
|
|
7
|
+
import { and, eq, sql } from "drizzle-orm";
|
|
8
|
+
|
|
9
|
+
import { getDb } from "../db/index.js";
|
|
10
|
+
|
|
11
|
+
export type WorkspaceMemberIdentity = {
|
|
12
|
+
userEmail: string;
|
|
13
|
+
orgId: string;
|
|
14
|
+
role: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type WorkspaceMemberIdentityInput = {
|
|
18
|
+
userEmail: string;
|
|
19
|
+
orgId?: string | null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function workspaceMemberIdentityFromContext(
|
|
23
|
+
context?: Pick<ActionRunContext, "userEmail" | "orgId">,
|
|
24
|
+
): WorkspaceMemberIdentityInput | undefined {
|
|
25
|
+
if (!context?.userEmail) return undefined;
|
|
26
|
+
return { userEmail: context.userEmail, orgId: context.orgId };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function requireWorkspaceMember(
|
|
30
|
+
identity?: WorkspaceMemberIdentityInput,
|
|
31
|
+
): Promise<WorkspaceMemberIdentity> {
|
|
32
|
+
const userEmail = (identity?.userEmail ?? getRequestUserEmail())
|
|
33
|
+
?.trim()
|
|
34
|
+
.toLowerCase();
|
|
35
|
+
if (!userEmail) throw new Error("Authentication required");
|
|
36
|
+
|
|
37
|
+
const requestOrgId = identity?.orgId?.trim() || getRequestOrgId()?.trim();
|
|
38
|
+
const orgId = requestOrgId || (await resolveOrgIdForEmail(userEmail));
|
|
39
|
+
if (!orgId) throw new Error("Active workspace organization required");
|
|
40
|
+
|
|
41
|
+
const rows = await getDb()
|
|
42
|
+
.select({ role: orgMembers.role })
|
|
43
|
+
.from(orgMembers)
|
|
44
|
+
.where(
|
|
45
|
+
and(
|
|
46
|
+
eq(orgMembers.orgId, orgId),
|
|
47
|
+
eq(sql`lower(${orgMembers.email})`, userEmail),
|
|
48
|
+
),
|
|
49
|
+
)
|
|
50
|
+
.limit(1);
|
|
51
|
+
|
|
52
|
+
if (!rows[0]) throw new Error("Workspace membership required");
|
|
53
|
+
|
|
54
|
+
return { userEmail, orgId, role: rows[0].role };
|
|
55
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { runAuthGuard } from "@agent-native/core/server";
|
|
2
|
+
/**
|
|
3
|
+
* Global auth middleware — runs for ALL requests (page routes, API routes,
|
|
4
|
+
* framework routes). The auth plugin configures the guard; this middleware
|
|
5
|
+
* enforces it on every request.
|
|
6
|
+
*
|
|
7
|
+
* Without this, auth only runs for /_agent-native/* routes because the
|
|
8
|
+
* framework handler's middleware registry is scoped to that catch-all.
|
|
9
|
+
* Page routes (/, /settings) and API routes (/api/*) would bypass auth.
|
|
10
|
+
*/
|
|
11
|
+
import { defineEventHandler } from "h3";
|
|
12
|
+
|
|
13
|
+
export default defineEventHandler(async (event) => {
|
|
14
|
+
return runAuthGuard(event);
|
|
15
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getOrgContext } from "@agent-native/core/org";
|
|
2
|
+
import {
|
|
3
|
+
createAgentChatPlugin,
|
|
4
|
+
loadActionsFromStaticRegistry,
|
|
5
|
+
type AgentChatPluginOptions,
|
|
6
|
+
} from "@agent-native/core/server";
|
|
7
|
+
|
|
8
|
+
import actionsRegistry from "../../.generated/actions-registry.js";
|
|
9
|
+
|
|
10
|
+
const INITIAL_TOOL_NAMES = [
|
|
11
|
+
"view-screen",
|
|
12
|
+
"list-factories",
|
|
13
|
+
"get-factory-graph",
|
|
14
|
+
"save-factory-graph",
|
|
15
|
+
"list-factory-comments",
|
|
16
|
+
"add-factory-comment",
|
|
17
|
+
"list-triage-items",
|
|
18
|
+
"get-triage-item",
|
|
19
|
+
"poll-slack-channel",
|
|
20
|
+
"evaluate-triage-item",
|
|
21
|
+
"list-triage-rules",
|
|
22
|
+
"get-triage-config",
|
|
23
|
+
"navigate",
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const options = {
|
|
27
|
+
appId: "factory",
|
|
28
|
+
actions: loadActionsFromStaticRegistry(actionsRegistry),
|
|
29
|
+
leanPrompt: true,
|
|
30
|
+
initialToolNames: INITIAL_TOOL_NAMES,
|
|
31
|
+
resolveOrgId: async (event) => (await getOrgContext(event)).orgId,
|
|
32
|
+
systemPrompt: `You are the Factory agent.
|
|
33
|
+
|
|
34
|
+
Factory is a visual factory builder. It observes Slack feedback and pull-request
|
|
35
|
+
evidence, renders the current factory graph, and helps a human decide where agents
|
|
36
|
+
should act. Use the Factory actions as the source of truth. When a user asks to
|
|
37
|
+
create or change a factory, first inspect the current graph, then propose a complete
|
|
38
|
+
versioned graph through save-factory-graph with source=ai and a concise changeSummary.
|
|
39
|
+
Never hide a graph change in prose: the visual map and the saved graph must agree.
|
|
40
|
+
The graph is currently a reviewable blueprint, not the runtime router: enabled
|
|
41
|
+
triage rules are evaluated in parallel against the same evidence. Do not claim that
|
|
42
|
+
an edge changes execution. For rule or guard changes, use the triage rule actions
|
|
43
|
+
and preserve normalizeTriagePolicyGuards; do not encode policy in graph JSON.
|
|
44
|
+
Use add-factory-comment for durable comments attached to the selected node or edge.
|
|
45
|
+
Explain the evidence and guard results before proposing work.
|
|
46
|
+
When discussing agent failures, preserve these measured taxonomy labels exactly:
|
|
47
|
+
SSL/TLS provider transport drop, Model reasoning_effort with tools, Provider
|
|
48
|
+
overloaded_error, and Missing provider authentication. Always inspect interactive
|
|
49
|
+
and scheduled job populations separately; scheduled runs have ids beginning with
|
|
50
|
+
job- and must not be hidden by an interactive-only query.
|
|
51
|
+
Never bypass a hard guard or claim that a provider action happened without a
|
|
52
|
+
durable run record and a confirmed terminal callback. When a user says to do it
|
|
53
|
+
now, use the approval action, which records the approver and applies the rule's
|
|
54
|
+
configured executor policy. Keep Slack replies concise and link to the Factory
|
|
55
|
+
item when a review is needed.`,
|
|
56
|
+
} satisfies AgentChatPluginOptions;
|
|
57
|
+
|
|
58
|
+
export default createAgentChatPlugin(options);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createAuthPlugin } from "@agent-native/core/server";
|
|
2
|
+
|
|
3
|
+
export default createAuthPlugin({
|
|
4
|
+
marketing: {
|
|
5
|
+
appName: "Factory",
|
|
6
|
+
tagline:
|
|
7
|
+
"Build agent factories: work in one end, shipped changes out the other, with gates you control.",
|
|
8
|
+
features: [
|
|
9
|
+
"Inspect Slack and pull-request signals in one queue",
|
|
10
|
+
"Tune rules with prompts and reviewable feedback",
|
|
11
|
+
"Approve bounded agent work with a durable audit trail",
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { runMigrations } from "@agent-native/core/db";
|
|
2
|
+
import { defineNitroPlugin } from "@agent-native/core/server";
|
|
3
|
+
|
|
4
|
+
const migrations = [
|
|
5
|
+
{
|
|
6
|
+
version: 1,
|
|
7
|
+
name: "factory-items-table",
|
|
8
|
+
sql: `
|
|
9
|
+
CREATE TABLE IF NOT EXISTS factory_items (
|
|
10
|
+
id TEXT PRIMARY KEY,
|
|
11
|
+
source TEXT NOT NULL,
|
|
12
|
+
external_id TEXT NOT NULL,
|
|
13
|
+
source_url TEXT,
|
|
14
|
+
title TEXT NOT NULL,
|
|
15
|
+
summary TEXT,
|
|
16
|
+
status TEXT NOT NULL DEFAULT 'received',
|
|
17
|
+
risk TEXT NOT NULL DEFAULT 'unknown',
|
|
18
|
+
channel_id TEXT,
|
|
19
|
+
thread_ts TEXT,
|
|
20
|
+
repository TEXT,
|
|
21
|
+
pull_request_number INTEGER,
|
|
22
|
+
head_sha TEXT,
|
|
23
|
+
coverage TEXT NOT NULL DEFAULT 'unknown',
|
|
24
|
+
dedupe_key TEXT NOT NULL,
|
|
25
|
+
metadata_json TEXT NOT NULL DEFAULT '{}',
|
|
26
|
+
last_seen_at TEXT,
|
|
27
|
+
created_at TEXT NOT NULL,
|
|
28
|
+
updated_at TEXT NOT NULL,
|
|
29
|
+
owner_email TEXT NOT NULL,
|
|
30
|
+
org_id TEXT
|
|
31
|
+
)
|
|
32
|
+
`,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
version: 2,
|
|
36
|
+
name: "factory-rules-table",
|
|
37
|
+
sql: `
|
|
38
|
+
CREATE TABLE IF NOT EXISTS factory_rules (
|
|
39
|
+
id TEXT PRIMARY KEY,
|
|
40
|
+
name TEXT NOT NULL,
|
|
41
|
+
description TEXT NOT NULL,
|
|
42
|
+
prompt_text TEXT NOT NULL,
|
|
43
|
+
mode TEXT NOT NULL DEFAULT 'shadow',
|
|
44
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
45
|
+
guards_json TEXT NOT NULL DEFAULT '{}',
|
|
46
|
+
prompt_version INTEGER NOT NULL DEFAULT 1,
|
|
47
|
+
created_at TEXT NOT NULL,
|
|
48
|
+
updated_at TEXT NOT NULL,
|
|
49
|
+
owner_email TEXT NOT NULL,
|
|
50
|
+
org_id TEXT
|
|
51
|
+
)
|
|
52
|
+
`,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
version: 3,
|
|
56
|
+
name: "factory-decisions-table",
|
|
57
|
+
sql: `
|
|
58
|
+
CREATE TABLE IF NOT EXISTS factory_decisions (
|
|
59
|
+
id TEXT PRIMARY KEY,
|
|
60
|
+
item_id TEXT NOT NULL,
|
|
61
|
+
rule_id TEXT,
|
|
62
|
+
mode TEXT NOT NULL DEFAULT 'shadow',
|
|
63
|
+
outcome TEXT NOT NULL,
|
|
64
|
+
reason TEXT NOT NULL,
|
|
65
|
+
guard_results_json TEXT NOT NULL DEFAULT '[]',
|
|
66
|
+
model TEXT,
|
|
67
|
+
prompt_version INTEGER,
|
|
68
|
+
created_at TEXT NOT NULL,
|
|
69
|
+
owner_email TEXT NOT NULL,
|
|
70
|
+
org_id TEXT
|
|
71
|
+
)
|
|
72
|
+
`,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
version: 4,
|
|
76
|
+
name: "factory-runs-table",
|
|
77
|
+
sql: `
|
|
78
|
+
CREATE TABLE IF NOT EXISTS factory_runs (
|
|
79
|
+
id TEXT PRIMARY KEY,
|
|
80
|
+
item_id TEXT NOT NULL,
|
|
81
|
+
source TEXT NOT NULL,
|
|
82
|
+
status TEXT NOT NULL DEFAULT 'received',
|
|
83
|
+
progress_log_json TEXT NOT NULL DEFAULT '[]',
|
|
84
|
+
dispatch_attempts INTEGER NOT NULL DEFAULT 0,
|
|
85
|
+
needs_continuation INTEGER NOT NULL DEFAULT 0,
|
|
86
|
+
started_at TEXT NOT NULL,
|
|
87
|
+
heartbeat_at TEXT,
|
|
88
|
+
completed_at TEXT,
|
|
89
|
+
error TEXT,
|
|
90
|
+
owner_email TEXT NOT NULL,
|
|
91
|
+
org_id TEXT
|
|
92
|
+
)
|
|
93
|
+
`,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
version: 5,
|
|
97
|
+
name: "factory-feedback-table",
|
|
98
|
+
sql: `
|
|
99
|
+
CREATE TABLE IF NOT EXISTS factory_feedback (
|
|
100
|
+
id TEXT PRIMARY KEY,
|
|
101
|
+
decision_id TEXT NOT NULL,
|
|
102
|
+
verdict TEXT NOT NULL,
|
|
103
|
+
note TEXT,
|
|
104
|
+
created_at TEXT NOT NULL,
|
|
105
|
+
owner_email TEXT NOT NULL,
|
|
106
|
+
org_id TEXT
|
|
107
|
+
)
|
|
108
|
+
`,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
version: 6,
|
|
112
|
+
name: "factory-config-table",
|
|
113
|
+
sql: `
|
|
114
|
+
CREATE TABLE IF NOT EXISTS factory_config (
|
|
115
|
+
id TEXT PRIMARY KEY,
|
|
116
|
+
slack_workspace TEXT NOT NULL DEFAULT 'primary',
|
|
117
|
+
slack_channel_id TEXT,
|
|
118
|
+
slack_channel_name TEXT,
|
|
119
|
+
polling_enabled INTEGER NOT NULL DEFAULT 0,
|
|
120
|
+
last_slack_ts TEXT,
|
|
121
|
+
repository TEXT,
|
|
122
|
+
created_at TEXT NOT NULL,
|
|
123
|
+
updated_at TEXT NOT NULL,
|
|
124
|
+
owner_email TEXT NOT NULL,
|
|
125
|
+
org_id TEXT
|
|
126
|
+
)
|
|
127
|
+
`,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
version: 7,
|
|
131
|
+
name: "factory-items-org-dedupe-index",
|
|
132
|
+
sql: `
|
|
133
|
+
CREATE UNIQUE INDEX IF NOT EXISTS factory_items_org_dedupe_idx
|
|
134
|
+
ON factory_items (org_id, dedupe_key)
|
|
135
|
+
`,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
version: 8,
|
|
139
|
+
name: "factory-items-org-status-index",
|
|
140
|
+
sql: `
|
|
141
|
+
CREATE INDEX IF NOT EXISTS factory_items_org_status_idx
|
|
142
|
+
ON factory_items (org_id, status, updated_at)
|
|
143
|
+
`,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
version: 9,
|
|
147
|
+
name: "factory-decisions-org-created-index",
|
|
148
|
+
sql: `
|
|
149
|
+
CREATE INDEX IF NOT EXISTS factory_decisions_org_created_idx
|
|
150
|
+
ON factory_decisions (org_id, created_at)
|
|
151
|
+
`,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
version: 10,
|
|
155
|
+
name: "factory-runs-org-status-index",
|
|
156
|
+
sql: `
|
|
157
|
+
CREATE INDEX IF NOT EXISTS factory_runs_org_status_idx
|
|
158
|
+
ON factory_runs (org_id, status, heartbeat_at)
|
|
159
|
+
`,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
version: 11,
|
|
163
|
+
name: "factory-config-slack-history-cursor",
|
|
164
|
+
sql: `
|
|
165
|
+
ALTER TABLE factory_config ADD COLUMN slack_history_cursor TEXT
|
|
166
|
+
`,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
version: 12,
|
|
170
|
+
name: "factory-runs-executor-metadata",
|
|
171
|
+
sql: `
|
|
172
|
+
ALTER TABLE factory_runs ADD COLUMN provider TEXT;
|
|
173
|
+
ALTER TABLE factory_runs ADD COLUMN provider_task_id TEXT;
|
|
174
|
+
ALTER TABLE factory_runs ADD COLUMN dedupe_key TEXT;
|
|
175
|
+
ALTER TABLE factory_runs ADD COLUMN approval_email TEXT;
|
|
176
|
+
`,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
version: 13,
|
|
180
|
+
name: "factory-definitions-table",
|
|
181
|
+
sql: `
|
|
182
|
+
CREATE TABLE IF NOT EXISTS factory_definitions (
|
|
183
|
+
id TEXT PRIMARY KEY,
|
|
184
|
+
name TEXT NOT NULL,
|
|
185
|
+
description TEXT NOT NULL DEFAULT '',
|
|
186
|
+
prompt TEXT NOT NULL DEFAULT '',
|
|
187
|
+
graph_version INTEGER NOT NULL DEFAULT 1,
|
|
188
|
+
graph_json TEXT NOT NULL DEFAULT '{}',
|
|
189
|
+
created_at TEXT NOT NULL,
|
|
190
|
+
updated_at TEXT NOT NULL,
|
|
191
|
+
owner_email TEXT NOT NULL,
|
|
192
|
+
org_id TEXT
|
|
193
|
+
);
|
|
194
|
+
CREATE INDEX IF NOT EXISTS factory_definitions_org_updated_idx
|
|
195
|
+
ON factory_definitions (org_id, updated_at);
|
|
196
|
+
`,
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
version: 14,
|
|
200
|
+
name: "factory-graph-versions-table",
|
|
201
|
+
sql: `
|
|
202
|
+
CREATE TABLE IF NOT EXISTS factory_graph_versions (
|
|
203
|
+
id TEXT PRIMARY KEY,
|
|
204
|
+
factory_id TEXT NOT NULL,
|
|
205
|
+
version INTEGER NOT NULL,
|
|
206
|
+
graph_json TEXT NOT NULL,
|
|
207
|
+
source TEXT NOT NULL DEFAULT 'manual',
|
|
208
|
+
change_summary TEXT NOT NULL DEFAULT '',
|
|
209
|
+
created_at TEXT NOT NULL,
|
|
210
|
+
created_by TEXT NOT NULL,
|
|
211
|
+
owner_email TEXT NOT NULL,
|
|
212
|
+
org_id TEXT
|
|
213
|
+
);
|
|
214
|
+
CREATE UNIQUE INDEX IF NOT EXISTS factory_graph_versions_unique_idx
|
|
215
|
+
ON factory_graph_versions (org_id, factory_id, version);
|
|
216
|
+
CREATE INDEX IF NOT EXISTS factory_graph_versions_created_idx
|
|
217
|
+
ON factory_graph_versions (org_id, factory_id, created_at);
|
|
218
|
+
`,
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
version: 15,
|
|
222
|
+
name: "factory-comments-table",
|
|
223
|
+
sql: `
|
|
224
|
+
CREATE TABLE IF NOT EXISTS factory_comments (
|
|
225
|
+
id TEXT PRIMARY KEY,
|
|
226
|
+
factory_id TEXT NOT NULL,
|
|
227
|
+
graph_version INTEGER NOT NULL,
|
|
228
|
+
target_type TEXT NOT NULL DEFAULT 'canvas',
|
|
229
|
+
target_id TEXT,
|
|
230
|
+
body TEXT NOT NULL,
|
|
231
|
+
created_at TEXT NOT NULL,
|
|
232
|
+
owner_email TEXT NOT NULL,
|
|
233
|
+
org_id TEXT
|
|
234
|
+
);
|
|
235
|
+
CREATE INDEX IF NOT EXISTS factory_comments_created_idx
|
|
236
|
+
ON factory_comments (org_id, factory_id, created_at);
|
|
237
|
+
`,
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
export const runFactoryMigrations = runMigrations(migrations, {
|
|
242
|
+
table: "factory_migrations",
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
export default defineNitroPlugin(async (nitroApp) => {
|
|
246
|
+
await runFactoryMigrations(nitroApp);
|
|
247
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WORKSPACE_OWNER,
|
|
3
|
+
resourceGetByPath,
|
|
4
|
+
resourcePut,
|
|
5
|
+
} from "@agent-native/core/resources";
|
|
6
|
+
import { defineNitroPlugin } from "@agent-native/core/server";
|
|
7
|
+
|
|
8
|
+
const JOB_PATH = "jobs/factory-observation-scheduler.md";
|
|
9
|
+
|
|
10
|
+
const JOB_BODY = `
|
|
11
|
+
# Factory observation scheduler
|
|
12
|
+
|
|
13
|
+
Call get-triage-config. If pollingEnabled is true and a Slack channel is
|
|
14
|
+
configured, call poll-slack-channel. Then call list-triage-items with status
|
|
15
|
+
received and evaluate each returned item with evaluate-triage-item. Keep the
|
|
16
|
+
work bounded to the returned page. This scheduled observer does not start work
|
|
17
|
+
or send provider messages; interactive approvals happen through the Factory agent.
|
|
18
|
+
If any action reports an error, preserve that error and continue to the next
|
|
19
|
+
item; do not report a false success.
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
function workspaceOwnerEmail() {
|
|
23
|
+
const email = process.env.WORKSPACE_OWNER_EMAIL?.trim().toLowerCase(); // guard:allow-env-credential - deployment owner identity, not a user credential
|
|
24
|
+
if (!email || /[\r\n]/.test(email)) return undefined;
|
|
25
|
+
return email;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function readFrontmatterField(content: string, key: string): string | null {
|
|
29
|
+
if (!content.startsWith("---\n")) return null;
|
|
30
|
+
const end = content.indexOf("\n---", 4);
|
|
31
|
+
if (end === -1) return null;
|
|
32
|
+
const match = content
|
|
33
|
+
.slice(4, end)
|
|
34
|
+
.match(new RegExp(`^${key}:\\s*(.*)$`, "m"));
|
|
35
|
+
return match ? match[1].trim() : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function setFrontmatterField(content: string, key: string, value: string) {
|
|
39
|
+
if (!content.startsWith("---\n")) return content;
|
|
40
|
+
const end = content.indexOf("\n---", 4);
|
|
41
|
+
if (end === -1) return content;
|
|
42
|
+
const frontmatter = content.slice(4, end);
|
|
43
|
+
const pattern = new RegExp(`^${key}:.*$`, "m");
|
|
44
|
+
if (pattern.test(frontmatter)) {
|
|
45
|
+
return `---\n${frontmatter.replace(pattern, `${key}: ${value}`)}${content.slice(end)}`;
|
|
46
|
+
}
|
|
47
|
+
return `${content.slice(0, end)}\n${key}: ${value}${content.slice(end)}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function jobContent(createdBy: string) {
|
|
51
|
+
return `---
|
|
52
|
+
schedule: "* * * * *"
|
|
53
|
+
enabled: true
|
|
54
|
+
createdBy: ${createdBy}
|
|
55
|
+
runAs: creator
|
|
56
|
+
---
|
|
57
|
+
${JOB_BODY}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function ensureSchedulerJob() {
|
|
61
|
+
const existing = await resourceGetByPath(WORKSPACE_OWNER, JOB_PATH);
|
|
62
|
+
const ownerEmail = workspaceOwnerEmail();
|
|
63
|
+
|
|
64
|
+
if (!existing) {
|
|
65
|
+
if (!ownerEmail) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
"WORKSPACE_OWNER_EMAIL is required to seed the Factory scheduler",
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
await resourcePut(
|
|
71
|
+
WORKSPACE_OWNER,
|
|
72
|
+
JOB_PATH,
|
|
73
|
+
jobContent(ownerEmail),
|
|
74
|
+
"text/markdown",
|
|
75
|
+
);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!ownerEmail) {
|
|
80
|
+
const runAs = readFrontmatterField(existing.content, "runAs");
|
|
81
|
+
const createdBy = readFrontmatterField(existing.content, "createdBy");
|
|
82
|
+
if (runAs === "creator" && createdBy) return;
|
|
83
|
+
throw new Error(
|
|
84
|
+
"WORKSPACE_OWNER_EMAIL is required to repair the Factory scheduler",
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (
|
|
89
|
+
!existing.content.startsWith("---\n") ||
|
|
90
|
+
!existing.content.includes("\n---", 4)
|
|
91
|
+
) {
|
|
92
|
+
await resourcePut(
|
|
93
|
+
WORKSPACE_OWNER,
|
|
94
|
+
JOB_PATH,
|
|
95
|
+
jobContent(ownerEmail),
|
|
96
|
+
"text/markdown",
|
|
97
|
+
);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const migrated = setFrontmatterField(
|
|
102
|
+
setFrontmatterField(existing.content, "createdBy", ownerEmail),
|
|
103
|
+
"runAs",
|
|
104
|
+
"creator",
|
|
105
|
+
);
|
|
106
|
+
if (migrated === existing.content) return;
|
|
107
|
+
await resourcePut(WORKSPACE_OWNER, JOB_PATH, migrated, "text/markdown");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default defineNitroPlugin(async () => {
|
|
111
|
+
try {
|
|
112
|
+
await ensureSchedulerJob();
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error("[factory-scheduler-job] failed to seed job:", error);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createIntegrationsPlugin,
|
|
5
|
+
loadActionsFromStaticRegistry,
|
|
6
|
+
slackAdapter,
|
|
7
|
+
type IncomingMessage,
|
|
8
|
+
} from "@agent-native/core/server";
|
|
9
|
+
|
|
10
|
+
import actionsRegistry from "../../.generated/actions-registry.js";
|
|
11
|
+
|
|
12
|
+
function fallbackOwner(incoming: IncomingMessage): string {
|
|
13
|
+
const tenant = String(
|
|
14
|
+
incoming.platformContext.teamId ??
|
|
15
|
+
incoming.platformContext.channelId ??
|
|
16
|
+
incoming.externalThreadId,
|
|
17
|
+
);
|
|
18
|
+
const digest = crypto
|
|
19
|
+
.createHash("sha256")
|
|
20
|
+
.update(`${incoming.platform}:${tenant}:${incoming.senderId ?? ""}`)
|
|
21
|
+
.digest("hex")
|
|
22
|
+
.slice(0, 16);
|
|
23
|
+
return `factory+${digest}@integration.local`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default createIntegrationsPlugin({
|
|
27
|
+
appId: "factory",
|
|
28
|
+
adapters: [slackAdapter()],
|
|
29
|
+
actions: loadActionsFromStaticRegistry(actionsRegistry),
|
|
30
|
+
resolveOwner: async (incoming) =>
|
|
31
|
+
incoming.senderVerified && incoming.senderEmail?.trim()
|
|
32
|
+
? incoming.senderEmail.trim().toLowerCase()
|
|
33
|
+
: fallbackOwner(incoming),
|
|
34
|
+
systemPrompt: `You are the Factory agent responding through Slack.
|
|
35
|
+
|
|
36
|
+
Use Factory actions to inspect Slack and pull-request evidence, explain decisions,
|
|
37
|
+
record human feedback, and tune rules. If a user asks to start work, first
|
|
38
|
+
inspect the item and its hard guard results. "Do it now" means explicit human
|
|
39
|
+
approval of that one item, so call approve-factory-item with the item and decision
|
|
40
|
+
identified in the thread. Never claim a coding agent, PR, merge, assignment, or
|
|
41
|
+
provider message exists until the returned run state confirms it. If the item
|
|
42
|
+
is protected, incomplete, unreadable, or missing a terminal callback, explain
|
|
43
|
+
that a human must intervene and include the Factory item URL when available.
|
|
44
|
+
|
|
45
|
+
Keep replies concise and operational.`,
|
|
46
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import { and, eq } from "drizzle-orm";
|
|
4
|
+
import {
|
|
5
|
+
getRequestHeader,
|
|
6
|
+
getQuery,
|
|
7
|
+
readRawBody,
|
|
8
|
+
setResponseStatus,
|
|
9
|
+
type H3Event,
|
|
10
|
+
} from "h3";
|
|
11
|
+
import { defineEventHandler } from "h3";
|
|
12
|
+
|
|
13
|
+
import { resolveConnectorSecret } from "../../../connectors/credentials.js";
|
|
14
|
+
import { getDb } from "../../../db/index.js";
|
|
15
|
+
import { triageItems, triageRuns } from "../../../db/schema.js";
|
|
16
|
+
|
|
17
|
+
export default defineEventHandler(async (event: H3Event) => {
|
|
18
|
+
const runId = String(getQuery(event).runId ?? "").trim();
|
|
19
|
+
if (!runId) {
|
|
20
|
+
setResponseStatus(event, 400);
|
|
21
|
+
return { ok: false, error: "runId is required" };
|
|
22
|
+
}
|
|
23
|
+
const rawBody = (await readRawBody(event)) ?? "";
|
|
24
|
+
let payload: {
|
|
25
|
+
status?: string;
|
|
26
|
+
taskId?: string;
|
|
27
|
+
id?: string;
|
|
28
|
+
error?: string;
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
payload = JSON.parse(rawBody) as typeof payload;
|
|
32
|
+
} catch {
|
|
33
|
+
setResponseStatus(event, 400);
|
|
34
|
+
return { ok: false, error: "Invalid JSON body" };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const db = getDb();
|
|
38
|
+
const run = (
|
|
39
|
+
await db
|
|
40
|
+
.select({
|
|
41
|
+
id: triageRuns.id,
|
|
42
|
+
ownerEmail: triageRuns.ownerEmail,
|
|
43
|
+
orgId: triageRuns.orgId,
|
|
44
|
+
itemId: triageRuns.itemId,
|
|
45
|
+
})
|
|
46
|
+
.from(triageRuns)
|
|
47
|
+
.where(eq(triageRuns.id, runId))
|
|
48
|
+
.limit(1)
|
|
49
|
+
)[0];
|
|
50
|
+
if (!run || !run.orgId) {
|
|
51
|
+
setResponseStatus(event, 404);
|
|
52
|
+
return { ok: false, error: "Factory run not found" };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const secret = await resolveConnectorSecret(
|
|
56
|
+
"FACTORY_BUILDER_WEBHOOK_SECRET",
|
|
57
|
+
run.ownerEmail,
|
|
58
|
+
{
|
|
59
|
+
orgId: run.orgId,
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
const signature = getRequestHeader(event, "x-builder-signature") ?? "";
|
|
63
|
+
if (!secret || !verifySignature(rawBody, signature, secret)) {
|
|
64
|
+
setResponseStatus(event, secret ? 401 : 503);
|
|
65
|
+
return {
|
|
66
|
+
ok: false,
|
|
67
|
+
error: secret
|
|
68
|
+
? "Invalid Builder callback signature"
|
|
69
|
+
: "Callback secret is not configured",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const now = new Date().toISOString();
|
|
74
|
+
const terminal = payload.status === "success" ? "completed" : "failed";
|
|
75
|
+
const reason =
|
|
76
|
+
payload.status === "success"
|
|
77
|
+
? "Builder reported a successful terminal callback."
|
|
78
|
+
: payload.error?.trim() || "Builder reported an error terminal callback.";
|
|
79
|
+
const progress = [{ at: now, state: terminal, reason }];
|
|
80
|
+
await db
|
|
81
|
+
.update(triageRuns)
|
|
82
|
+
.set({
|
|
83
|
+
status: terminal,
|
|
84
|
+
providerTaskId: payload.taskId ?? payload.id ?? undefined,
|
|
85
|
+
progressLogJson: JSON.stringify(progress),
|
|
86
|
+
heartbeatAt: now,
|
|
87
|
+
completedAt: now,
|
|
88
|
+
error: terminal === "failed" ? reason : null,
|
|
89
|
+
})
|
|
90
|
+
.where(and(eq(triageRuns.id, runId), eq(triageRuns.orgId, run.orgId)));
|
|
91
|
+
await db
|
|
92
|
+
.update(triageItems)
|
|
93
|
+
.set({
|
|
94
|
+
status: terminal === "completed" ? "evidence_ready" : "failed",
|
|
95
|
+
updatedAt: now,
|
|
96
|
+
})
|
|
97
|
+
.where(
|
|
98
|
+
and(eq(triageItems.id, run.itemId), eq(triageItems.orgId, run.orgId)),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return { ok: true, runId, status: terminal };
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
function verifySignature(
|
|
105
|
+
rawBody: string,
|
|
106
|
+
signature: string,
|
|
107
|
+
secret: string,
|
|
108
|
+
): boolean {
|
|
109
|
+
const expected = `sha256=${createHmac("sha256", secret).update(rawBody).digest("hex")}`;
|
|
110
|
+
const actualBytes = Buffer.from(signature);
|
|
111
|
+
const expectedBytes = Buffer.from(expected);
|
|
112
|
+
return (
|
|
113
|
+
actualBytes.length === expectedBytes.length &&
|
|
114
|
+
timingSafeEqual(actualBytes, expectedBytes)
|
|
115
|
+
);
|
|
116
|
+
}
|