@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,197 @@
|
|
|
1
|
+
import type { AiServicesPullRequestSnapshot } from "./github-ingestion.js";
|
|
2
|
+
import type { ReviewCommentObservation } from "./pr-babysit.js";
|
|
3
|
+
import type {
|
|
4
|
+
PullRequestCheckObservation,
|
|
5
|
+
PullRequestReviewObservation,
|
|
6
|
+
} from "./pr-monitor.js";
|
|
7
|
+
|
|
8
|
+
export interface AiServicesGitReadClientOptions {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
authorization: string;
|
|
11
|
+
fetchImpl?: typeof fetch;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AiServicesPullRequestLookup {
|
|
15
|
+
projectId: string;
|
|
16
|
+
repo: string;
|
|
17
|
+
pullRequestNumber: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AiServicesPullRequestRead extends AiServicesPullRequestSnapshot {
|
|
21
|
+
readonly comments: readonly ReviewCommentObservation[];
|
|
22
|
+
readonly commentsTruncated: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ai-services fetches exactly one uncapped page of this many review comments
|
|
26
|
+
// and returns no truncated flag, so a full page is the only evidence that
|
|
27
|
+
// newer comments were dropped. GitHub returns them oldest-first, so the ones
|
|
28
|
+
// lost are the most likely to still be open.
|
|
29
|
+
const REVIEW_COMMENT_PAGE_SIZE = 100;
|
|
30
|
+
|
|
31
|
+
type JsonResponse = {
|
|
32
|
+
ok: boolean;
|
|
33
|
+
status: number;
|
|
34
|
+
json(): Promise<unknown>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function createAiServicesGitReadClient(
|
|
38
|
+
options: AiServicesGitReadClientOptions,
|
|
39
|
+
) {
|
|
40
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
41
|
+
const baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
42
|
+
|
|
43
|
+
async function get<T>(path: string, lookup: AiServicesPullRequestLookup) {
|
|
44
|
+
const url = new URL(path, `${baseUrl}/`);
|
|
45
|
+
url.searchParams.set("projectId", lookup.projectId);
|
|
46
|
+
url.searchParams.set("prNumber", String(lookup.pullRequestNumber));
|
|
47
|
+
const response = (await fetchImpl(url, {
|
|
48
|
+
headers: { Authorization: options.authorization },
|
|
49
|
+
})) as JsonResponse;
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`ai-services GitHub read failed for ${path}: HTTP ${response.status}`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return (await response.json()) as T;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
async fetchPullRequest(
|
|
60
|
+
lookup: AiServicesPullRequestLookup,
|
|
61
|
+
): Promise<AiServicesPullRequestRead> {
|
|
62
|
+
const [detail, reviews, checks, files] = await Promise.all([
|
|
63
|
+
get<{
|
|
64
|
+
pullRequest: {
|
|
65
|
+
title: string;
|
|
66
|
+
body: string;
|
|
67
|
+
head: { sha: string };
|
|
68
|
+
htmlUrl: string;
|
|
69
|
+
changedFiles: number;
|
|
70
|
+
additions: number;
|
|
71
|
+
deletions: number;
|
|
72
|
+
};
|
|
73
|
+
}>("/projects/git/fetch-pull-request-detail", lookup),
|
|
74
|
+
get<{
|
|
75
|
+
reviews: Array<{
|
|
76
|
+
user: { login: string };
|
|
77
|
+
state: string;
|
|
78
|
+
submittedAt: string;
|
|
79
|
+
comments?: Array<{
|
|
80
|
+
id: number;
|
|
81
|
+
user: { login: string };
|
|
82
|
+
body: string;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
path?: string;
|
|
85
|
+
// GitHub sends a literal null once the line leaves the diff.
|
|
86
|
+
line?: number | null;
|
|
87
|
+
inReplyToId?: number;
|
|
88
|
+
isResolved?: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
}>;
|
|
91
|
+
}>("/projects/git/fetch-pull-request-reviews", lookup),
|
|
92
|
+
get<{
|
|
93
|
+
checks: Array<{
|
|
94
|
+
name: string;
|
|
95
|
+
status: string;
|
|
96
|
+
conclusion?: string;
|
|
97
|
+
startedAt?: string;
|
|
98
|
+
completedAt?: string;
|
|
99
|
+
}>;
|
|
100
|
+
}>("/projects/git/fetch-pull-request-checks", lookup),
|
|
101
|
+
get<{
|
|
102
|
+
files: Array<{
|
|
103
|
+
filename: string;
|
|
104
|
+
additions: number;
|
|
105
|
+
deletions: number;
|
|
106
|
+
}>;
|
|
107
|
+
}>("/projects/git/fetch-pull-request-files", lookup),
|
|
108
|
+
]);
|
|
109
|
+
const observedAt = new Date().toISOString();
|
|
110
|
+
const pullRequest = detail.pullRequest;
|
|
111
|
+
const reviewObservations: PullRequestReviewObservation[] =
|
|
112
|
+
reviews.reviews.map((review) => ({
|
|
113
|
+
author: review.user.login,
|
|
114
|
+
state: normalizeReviewState(review.state),
|
|
115
|
+
observedAt: review.submittedAt || observedAt,
|
|
116
|
+
}));
|
|
117
|
+
const reviewComments: ReviewCommentObservation[] =
|
|
118
|
+
reviews.reviews.flatMap((review) =>
|
|
119
|
+
(review.comments ?? []).map((comment) => ({
|
|
120
|
+
id: String(comment.id),
|
|
121
|
+
author: comment.user.login,
|
|
122
|
+
// `== null` on purpose: upstream omits this field on a
|
|
123
|
+
// thread-starting comment, so `=== null` would stringify undefined
|
|
124
|
+
// into "undefined" and no reply would ever match it.
|
|
125
|
+
inReplyToId:
|
|
126
|
+
comment.inReplyToId == null ? null : String(comment.inReplyToId),
|
|
127
|
+
body: comment.body,
|
|
128
|
+
path: comment.path,
|
|
129
|
+
line: comment.line ?? undefined,
|
|
130
|
+
// Never defaulted: undefined means the provider could not
|
|
131
|
+
// determine thread resolution, which is not "resolved".
|
|
132
|
+
isResolved: comment.isResolved,
|
|
133
|
+
createdAt: comment.createdAt,
|
|
134
|
+
})),
|
|
135
|
+
);
|
|
136
|
+
const checkObservations: PullRequestCheckObservation[] =
|
|
137
|
+
checks.checks.map((check) => ({
|
|
138
|
+
name: check.name,
|
|
139
|
+
state: normalizeCheckState(check.status, check.conclusion),
|
|
140
|
+
observedAt: check.completedAt || check.startedAt || observedAt,
|
|
141
|
+
}));
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
repo: lookup.repo,
|
|
145
|
+
pullRequestNumber: lookup.pullRequestNumber,
|
|
146
|
+
headSha: pullRequest.head.sha,
|
|
147
|
+
title: pullRequest.title,
|
|
148
|
+
sourceUrl: pullRequest.htmlUrl,
|
|
149
|
+
summary: pullRequest.body.slice(0, 4_000),
|
|
150
|
+
changedFiles: files.files.map((file) => file.filename),
|
|
151
|
+
diffLines: files.files.reduce(
|
|
152
|
+
(total, file) => total + file.additions + file.deletions,
|
|
153
|
+
0,
|
|
154
|
+
),
|
|
155
|
+
coverage: "complete",
|
|
156
|
+
reviews: reviewObservations,
|
|
157
|
+
checks: checkObservations,
|
|
158
|
+
comments: reviewComments,
|
|
159
|
+
commentsTruncated: reviewComments.length >= REVIEW_COMMENT_PAGE_SIZE,
|
|
160
|
+
observedAt,
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function normalizeReviewState(
|
|
167
|
+
state: string,
|
|
168
|
+
): PullRequestReviewObservation["state"] {
|
|
169
|
+
switch (state) {
|
|
170
|
+
case "APPROVED":
|
|
171
|
+
return "approved";
|
|
172
|
+
case "CHANGES_REQUESTED":
|
|
173
|
+
return "changes_requested";
|
|
174
|
+
case "PENDING":
|
|
175
|
+
return "pending";
|
|
176
|
+
default:
|
|
177
|
+
return "commented";
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function normalizeCheckState(
|
|
182
|
+
status: string,
|
|
183
|
+
conclusion?: string,
|
|
184
|
+
): PullRequestCheckObservation["state"] {
|
|
185
|
+
if (status !== "completed") {
|
|
186
|
+
return status === "in_progress" ? "in_progress" : "queued";
|
|
187
|
+
}
|
|
188
|
+
switch (conclusion) {
|
|
189
|
+
case "success":
|
|
190
|
+
return "passed";
|
|
191
|
+
case "cancelled":
|
|
192
|
+
case "timed_out":
|
|
193
|
+
return "cancelled";
|
|
194
|
+
default:
|
|
195
|
+
return "failed";
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { resolveConnectorSecret } from "../connectors/credentials.js";
|
|
2
|
+
|
|
3
|
+
export interface BuilderExecutorInput {
|
|
4
|
+
runId: string;
|
|
5
|
+
itemId: string;
|
|
6
|
+
ownerEmail: string;
|
|
7
|
+
orgId: string;
|
|
8
|
+
repository?: string | null;
|
|
9
|
+
summary?: string | null;
|
|
10
|
+
sourceUrl?: string | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BuilderExecutorResult {
|
|
14
|
+
providerTaskId?: string;
|
|
15
|
+
branchName: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function requiredEnv(
|
|
19
|
+
name: "BUILDER_AI_SERVICES_URL" | "BUILDER_PROJECT_ID" | "FACTORY_PUBLIC_URL",
|
|
20
|
+
): string {
|
|
21
|
+
const value =
|
|
22
|
+
name === "BUILDER_AI_SERVICES_URL"
|
|
23
|
+
? process.env.BUILDER_AI_SERVICES_URL // guard:allow-env-credential - non-secret deployment endpoint
|
|
24
|
+
: name === "BUILDER_PROJECT_ID"
|
|
25
|
+
? process.env.BUILDER_PROJECT_ID // guard:allow-env-credential - non-secret deployment project id
|
|
26
|
+
: process.env.FACTORY_PUBLIC_URL; // guard:allow-env-credential - public callback origin
|
|
27
|
+
if (!value) throw new Error(`${name} is required for the Builder executor.`);
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function publicCallbackUrl(runId: string): string {
|
|
32
|
+
const base = requiredEnv("FACTORY_PUBLIC_URL").replace(/\/$/, "");
|
|
33
|
+
return `${base}/_agent-native/factory/builder-callback?runId=${encodeURIComponent(runId)}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function startBuilderRun(
|
|
37
|
+
input: BuilderExecutorInput,
|
|
38
|
+
): Promise<BuilderExecutorResult> {
|
|
39
|
+
const baseUrl = requiredEnv("BUILDER_AI_SERVICES_URL").replace(/\/$/, "");
|
|
40
|
+
const projectId = requiredEnv("BUILDER_PROJECT_ID");
|
|
41
|
+
const privateKey = await resolveConnectorSecret(
|
|
42
|
+
"BUILDER_PRIVATE_KEY",
|
|
43
|
+
input.ownerEmail,
|
|
44
|
+
{
|
|
45
|
+
orgId: input.orgId,
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
if (!privateKey) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
"No Builder executor credential configured. Connect the Builder service in workspace settings or configure BUILDER_PRIVATE_KEY through the workspace resolver.",
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const webhookSecret = await resolveConnectorSecret(
|
|
54
|
+
"FACTORY_BUILDER_WEBHOOK_SECRET",
|
|
55
|
+
input.ownerEmail,
|
|
56
|
+
{ orgId: input.orgId },
|
|
57
|
+
);
|
|
58
|
+
if (!webhookSecret)
|
|
59
|
+
throw new Error(
|
|
60
|
+
"FACTORY_BUILDER_WEBHOOK_SECRET is required for signed callbacks.",
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const branchName = `factory/${input.itemId.slice(0, 12)}`;
|
|
64
|
+
const prompt = [
|
|
65
|
+
"Work on this approved Factory item.",
|
|
66
|
+
input.summary
|
|
67
|
+
? `Feedback: ${input.summary}`
|
|
68
|
+
: "No feedback summary was supplied.",
|
|
69
|
+
input.sourceUrl ? `Source: ${input.sourceUrl}` : "",
|
|
70
|
+
input.repository ? `Repository: ${input.repository}` : "",
|
|
71
|
+
"Inspect the repository, make the smallest safe fix, run validation, and open a pull request.",
|
|
72
|
+
"Do not touch protected areas: auth/session/identity, credentials/vault, migrations, payments, security, or publishable packages.",
|
|
73
|
+
]
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
.join("\n");
|
|
76
|
+
|
|
77
|
+
const response = await fetch(`${baseUrl}/projects/branch/message`, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: {
|
|
80
|
+
Authorization: `Bearer ${privateKey.startsWith("bpk-") ? privateKey : `bpk-${privateKey}`}`,
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
},
|
|
83
|
+
body: JSON.stringify({
|
|
84
|
+
projectId,
|
|
85
|
+
branchName,
|
|
86
|
+
userMessage: {
|
|
87
|
+
userPrompt: prompt,
|
|
88
|
+
runValidateCommand: true,
|
|
89
|
+
queue: true,
|
|
90
|
+
},
|
|
91
|
+
fireAndForget: true,
|
|
92
|
+
webhook: { url: publicCallbackUrl(input.runId), secret: webhookSecret },
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Builder executor rejected the run: HTTP ${response.status} ${await response.text()}`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
let payload: {
|
|
101
|
+
id?: string;
|
|
102
|
+
taskId?: string;
|
|
103
|
+
runId?: string;
|
|
104
|
+
};
|
|
105
|
+
try {
|
|
106
|
+
payload = (await response.json()) as typeof payload;
|
|
107
|
+
} catch {
|
|
108
|
+
throw new Error("Builder executor returned invalid JSON.");
|
|
109
|
+
}
|
|
110
|
+
const providerTaskId = payload.id ?? payload.taskId ?? payload.runId;
|
|
111
|
+
if (!providerTaskId) {
|
|
112
|
+
throw new Error("Builder executor response did not include a task id.");
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
providerTaskId,
|
|
116
|
+
branchName,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const triageSourceSchema = z.enum(["slack", "github"]);
|
|
4
|
+
export type TriageSource = z.infer<typeof triageSourceSchema>;
|
|
5
|
+
|
|
6
|
+
export const triageItemStatusSchema = z.enum([
|
|
7
|
+
"received",
|
|
8
|
+
"context_fetching",
|
|
9
|
+
"evidence_ready",
|
|
10
|
+
"classified",
|
|
11
|
+
"shadow_decided",
|
|
12
|
+
"needs_manual",
|
|
13
|
+
"failed",
|
|
14
|
+
"reconciliation_required",
|
|
15
|
+
]);
|
|
16
|
+
export type TriageItemStatus = z.infer<typeof triageItemStatusSchema>;
|
|
17
|
+
|
|
18
|
+
export const triageRiskSchema = z.enum([
|
|
19
|
+
"unknown",
|
|
20
|
+
"low",
|
|
21
|
+
"medium",
|
|
22
|
+
"high",
|
|
23
|
+
"critical",
|
|
24
|
+
]);
|
|
25
|
+
export type TriageRisk = z.infer<typeof triageRiskSchema>;
|
|
26
|
+
|
|
27
|
+
export const triageCoverageSchema = z.enum([
|
|
28
|
+
"complete",
|
|
29
|
+
"partial",
|
|
30
|
+
"unknown",
|
|
31
|
+
"unavailable",
|
|
32
|
+
]);
|
|
33
|
+
export type TriageCoverage = z.infer<typeof triageCoverageSchema>;
|
|
34
|
+
|
|
35
|
+
export const triageDecisionOutcomeSchema = z.enum([
|
|
36
|
+
"observe",
|
|
37
|
+
"needs_manual",
|
|
38
|
+
"propose_fix",
|
|
39
|
+
"propose_review",
|
|
40
|
+
]);
|
|
41
|
+
export type TriageDecisionOutcome = z.infer<typeof triageDecisionOutcomeSchema>;
|
|
42
|
+
|
|
43
|
+
export const triageRuleModeSchema = z.enum(["disabled", "shadow"]);
|
|
44
|
+
export type TriageRuleMode = z.infer<typeof triageRuleModeSchema>;
|
|
45
|
+
|
|
46
|
+
export const executorStateSchema = z.enum([
|
|
47
|
+
"submitted",
|
|
48
|
+
"acknowledged",
|
|
49
|
+
"running",
|
|
50
|
+
"completed",
|
|
51
|
+
"failed",
|
|
52
|
+
"cancelled",
|
|
53
|
+
"timed_out",
|
|
54
|
+
"reconciliation_required",
|
|
55
|
+
]);
|
|
56
|
+
export type ExecutorState = z.infer<typeof executorStateSchema>;
|
|
57
|
+
|
|
58
|
+
export const triageGuardCodeSchema = z.enum([
|
|
59
|
+
"auth",
|
|
60
|
+
"session",
|
|
61
|
+
"identity",
|
|
62
|
+
"credentials",
|
|
63
|
+
"vault",
|
|
64
|
+
"migration",
|
|
65
|
+
"payments",
|
|
66
|
+
"security",
|
|
67
|
+
"publishable_package",
|
|
68
|
+
"path_denied",
|
|
69
|
+
"diff_too_large",
|
|
70
|
+
"unknown_change",
|
|
71
|
+
]);
|
|
72
|
+
export type TriageGuardCode = z.infer<typeof triageGuardCodeSchema>;
|
|
73
|
+
|
|
74
|
+
export const hardNeverAutomateGuardCodes: TriageGuardCode[] = [
|
|
75
|
+
"auth",
|
|
76
|
+
"session",
|
|
77
|
+
"identity",
|
|
78
|
+
"credentials",
|
|
79
|
+
"vault",
|
|
80
|
+
"migration",
|
|
81
|
+
"payments",
|
|
82
|
+
"security",
|
|
83
|
+
"publishable_package",
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
export const triagePolicyGuardsSchema = z.object({
|
|
87
|
+
allowRepositories: z.array(z.string().min(1)).default([]),
|
|
88
|
+
denyPathPrefixes: z.array(z.string().min(1)).default([]),
|
|
89
|
+
maxChangedFiles: z.number().int().positive().nullable().default(30),
|
|
90
|
+
maxDiffLines: z.number().int().positive().nullable().default(1500),
|
|
91
|
+
neverAutomate: z
|
|
92
|
+
.array(triageGuardCodeSchema)
|
|
93
|
+
.default(hardNeverAutomateGuardCodes),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export interface GuardResult {
|
|
97
|
+
code: TriageGuardCode;
|
|
98
|
+
passed: boolean;
|
|
99
|
+
reason: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface TriagePolicyGuards {
|
|
103
|
+
allowRepositories: string[];
|
|
104
|
+
denyPathPrefixes: string[];
|
|
105
|
+
maxChangedFiles: number | null;
|
|
106
|
+
maxDiffLines: number | null;
|
|
107
|
+
neverAutomate: TriageGuardCode[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface IngestionEnvelope {
|
|
111
|
+
source: TriageSource;
|
|
112
|
+
externalId: string;
|
|
113
|
+
receivedAt: string;
|
|
114
|
+
sourceUrl?: string;
|
|
115
|
+
title: string;
|
|
116
|
+
summary?: string;
|
|
117
|
+
channelId?: string;
|
|
118
|
+
threadTs?: string;
|
|
119
|
+
repository?: string;
|
|
120
|
+
pullRequestNumber?: number;
|
|
121
|
+
headSha?: string;
|
|
122
|
+
coverage: TriageCoverage;
|
|
123
|
+
metadata?: Record<string, string | number | boolean | string[] | null>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface ExecutorTaskContract {
|
|
127
|
+
id: string;
|
|
128
|
+
triageItemId: string;
|
|
129
|
+
dedupeKey: string;
|
|
130
|
+
state: ExecutorState;
|
|
131
|
+
provider: "builder-http" | "harness" | "a2a" | "bot-tag";
|
|
132
|
+
providerTaskId?: string;
|
|
133
|
+
terminalReason?: string;
|
|
134
|
+
observedAt: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function normalizeTriagePolicyGuards(
|
|
138
|
+
value: unknown,
|
|
139
|
+
): TriagePolicyGuards {
|
|
140
|
+
const parsed = triagePolicyGuardsSchema.parse(value);
|
|
141
|
+
return {
|
|
142
|
+
...parsed,
|
|
143
|
+
neverAutomate: [
|
|
144
|
+
...new Set([...hardNeverAutomateGuardCodes, ...parsed.neverAutomate]),
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function defaultTriagePolicyGuards(): TriagePolicyGuards {
|
|
150
|
+
return normalizeTriagePolicyGuards({
|
|
151
|
+
allowRepositories: [],
|
|
152
|
+
denyPathPrefixes: [
|
|
153
|
+
".env",
|
|
154
|
+
"auth",
|
|
155
|
+
"credentials",
|
|
156
|
+
"migrations",
|
|
157
|
+
"payments",
|
|
158
|
+
"security",
|
|
159
|
+
"packages/",
|
|
160
|
+
],
|
|
161
|
+
maxChangedFiles: 30,
|
|
162
|
+
maxDiffLines: 1500,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { IngestionEnvelope } from "./contracts.js";
|
|
2
|
+
import type { PullRequestObservation } from "./pr-monitor.js";
|
|
3
|
+
|
|
4
|
+
export interface AiServicesPullRequestSnapshot extends PullRequestObservation {
|
|
5
|
+
readonly title: string;
|
|
6
|
+
readonly sourceUrl?: string;
|
|
7
|
+
readonly summary?: string;
|
|
8
|
+
readonly changedFiles?: readonly string[];
|
|
9
|
+
readonly diffLines?: number;
|
|
10
|
+
readonly coverage: "complete" | "partial" | "unknown" | "unavailable";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function pullRequestSnapshotToEnvelope(
|
|
14
|
+
snapshot: AiServicesPullRequestSnapshot,
|
|
15
|
+
): IngestionEnvelope {
|
|
16
|
+
const externalId = `${snapshot.repo}#${snapshot.pullRequestNumber}@${snapshot.headSha}`;
|
|
17
|
+
return {
|
|
18
|
+
source: "github",
|
|
19
|
+
externalId,
|
|
20
|
+
receivedAt: snapshot.observedAt,
|
|
21
|
+
...(snapshot.sourceUrl ? { sourceUrl: snapshot.sourceUrl } : {}),
|
|
22
|
+
title: snapshot.title,
|
|
23
|
+
summary: snapshot.summary,
|
|
24
|
+
repository: snapshot.repo,
|
|
25
|
+
pullRequestNumber: snapshot.pullRequestNumber,
|
|
26
|
+
headSha: snapshot.headSha,
|
|
27
|
+
coverage: snapshot.coverage,
|
|
28
|
+
metadata: {
|
|
29
|
+
changedFiles: snapshot.changedFiles ? [...snapshot.changedFiles] : null,
|
|
30
|
+
diffLines: snapshot.diffLines ?? null,
|
|
31
|
+
reviews: snapshot.reviews.length,
|
|
32
|
+
checks: snapshot.checks.length,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GuardResult,
|
|
3
|
+
TriageGuardCode,
|
|
4
|
+
TriagePolicyGuards,
|
|
5
|
+
} from "./contracts.js";
|
|
6
|
+
|
|
7
|
+
export function evaluateStructuredGuards(
|
|
8
|
+
guards: TriagePolicyGuards,
|
|
9
|
+
input: {
|
|
10
|
+
repository?: string;
|
|
11
|
+
changedFiles?: string[];
|
|
12
|
+
diffLines?: number;
|
|
13
|
+
risk?: string;
|
|
14
|
+
categories?: TriageGuardCode[];
|
|
15
|
+
},
|
|
16
|
+
): GuardResult[] {
|
|
17
|
+
const results: GuardResult[] = [];
|
|
18
|
+
|
|
19
|
+
for (const category of input.categories ?? []) {
|
|
20
|
+
if (guards.neverAutomate.includes(category)) {
|
|
21
|
+
results.push({
|
|
22
|
+
code: category,
|
|
23
|
+
passed: false,
|
|
24
|
+
reason: `The ${category} category is always human-gated.`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (guards.allowRepositories.length > 0) {
|
|
30
|
+
results.push({
|
|
31
|
+
code: "unknown_change",
|
|
32
|
+
passed:
|
|
33
|
+
!!input.repository &&
|
|
34
|
+
guards.allowRepositories.includes(input.repository),
|
|
35
|
+
reason: input.repository
|
|
36
|
+
? `Repository ${input.repository} is not in the allowlist.`
|
|
37
|
+
: "Repository is unavailable.",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const changedFiles = input.changedFiles ?? [];
|
|
42
|
+
const deniedPath = changedFiles.find((file) =>
|
|
43
|
+
guards.denyPathPrefixes.some((prefix) => file.startsWith(prefix)),
|
|
44
|
+
);
|
|
45
|
+
if (deniedPath) {
|
|
46
|
+
results.push({
|
|
47
|
+
code: guardCodeForPath(deniedPath),
|
|
48
|
+
passed: false,
|
|
49
|
+
reason: `Sensitive path is present: ${deniedPath}`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (
|
|
54
|
+
guards.maxChangedFiles !== null &&
|
|
55
|
+
changedFiles.length > guards.maxChangedFiles
|
|
56
|
+
) {
|
|
57
|
+
results.push({
|
|
58
|
+
code: "diff_too_large",
|
|
59
|
+
passed: false,
|
|
60
|
+
reason: `${changedFiles.length} changed files exceeds the limit of ${guards.maxChangedFiles}.`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
guards.maxDiffLines !== null &&
|
|
66
|
+
typeof input.diffLines === "number" &&
|
|
67
|
+
input.diffLines > guards.maxDiffLines
|
|
68
|
+
) {
|
|
69
|
+
results.push({
|
|
70
|
+
code: "diff_too_large",
|
|
71
|
+
passed: false,
|
|
72
|
+
reason: `${input.diffLines} diff lines exceeds the limit of ${guards.maxDiffLines}.`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (input.risk === "high" || input.risk === "critical") {
|
|
77
|
+
results.push({
|
|
78
|
+
code: "security",
|
|
79
|
+
passed: false,
|
|
80
|
+
reason: `Risk ${input.risk} is always human-gated in shadow mode.`,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (results.length === 0) {
|
|
85
|
+
const hasEvidence = Boolean(
|
|
86
|
+
input.repository ||
|
|
87
|
+
(input.changedFiles && input.changedFiles.length > 0) ||
|
|
88
|
+
input.diffLines !== undefined ||
|
|
89
|
+
(input.risk && input.risk !== "unknown"),
|
|
90
|
+
);
|
|
91
|
+
results.push({
|
|
92
|
+
code: "unknown_change",
|
|
93
|
+
passed: hasEvidence,
|
|
94
|
+
reason: hasEvidence
|
|
95
|
+
? "Structured evidence was available and no deny guard matched."
|
|
96
|
+
: "Insufficient structured evidence for an autonomous proposal.",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return results;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function guardCodeForPath(path: string): TriageGuardCode {
|
|
104
|
+
const normalized = path.toLowerCase();
|
|
105
|
+
if (normalized.startsWith("packages/")) return "publishable_package";
|
|
106
|
+
if (normalized.includes("migration")) return "migration";
|
|
107
|
+
if (normalized.includes("credential") || normalized.startsWith(".env")) {
|
|
108
|
+
return "credentials";
|
|
109
|
+
}
|
|
110
|
+
if (normalized.includes("vault")) return "vault";
|
|
111
|
+
if (normalized.includes("payment")) return "payments";
|
|
112
|
+
if (normalized.includes("security")) return "security";
|
|
113
|
+
if (
|
|
114
|
+
normalized.includes("auth") ||
|
|
115
|
+
normalized.includes("session") ||
|
|
116
|
+
normalized.includes("identity")
|
|
117
|
+
) {
|
|
118
|
+
return "auth";
|
|
119
|
+
}
|
|
120
|
+
return "path_denied";
|
|
121
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
export function stableId(...parts: string[]): string {
|
|
4
|
+
return createHash("sha256").update(parts.join("\u001f")).digest("hex");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function itemDedupeKey(
|
|
8
|
+
input: {
|
|
9
|
+
source: string;
|
|
10
|
+
externalId: string;
|
|
11
|
+
repository?: string;
|
|
12
|
+
pullRequestNumber?: number;
|
|
13
|
+
headSha?: string;
|
|
14
|
+
},
|
|
15
|
+
organizationId = "",
|
|
16
|
+
): string {
|
|
17
|
+
return stableId(
|
|
18
|
+
organizationId,
|
|
19
|
+
input.source,
|
|
20
|
+
input.externalId,
|
|
21
|
+
input.repository ?? "",
|
|
22
|
+
input.pullRequestNumber === undefined
|
|
23
|
+
? ""
|
|
24
|
+
: String(input.pullRequestNumber),
|
|
25
|
+
input.headSha ?? "",
|
|
26
|
+
);
|
|
27
|
+
}
|