@agent-native/core 0.131.5 → 0.131.7
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 +3 -3
- package/corpus/core/CHANGELOG.md +70 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +13 -6
- package/corpus/core/docs/content/cloneable-saas.mdx +5 -5
- package/corpus/core/docs/content/creating-templates.mdx +9 -0
- package/corpus/core/docs/content/deployment.mdx +18 -12
- package/corpus/core/docs/content/doctor.mdx +8 -1
- package/corpus/core/docs/content/drop-in-agent.mdx +1 -1
- package/corpus/core/docs/content/extensions.mdx +18 -18
- package/corpus/core/docs/content/faq.mdx +4 -4
- package/corpus/core/docs/content/key-concepts.mdx +30 -21
- package/corpus/core/docs/content/security.mdx +2 -2
- package/corpus/core/docs/content/template-brain-developers.mdx +4 -1
- package/corpus/core/docs/content/template-mail-developers.mdx +4 -1
- package/corpus/core/docs/content/what-is-agent-native.mdx +6 -6
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/client.ts +449 -66
- package/corpus/core/src/a2a/correlation.ts +31 -0
- package/corpus/core/src/a2a/invoke.ts +4 -2
- package/corpus/core/src/a2a/types.ts +4 -0
- package/corpus/core/src/action.ts +3 -0
- package/corpus/core/src/agent/action-continuation-guidance.ts +2 -1
- package/corpus/core/src/agent/engine/registry.ts +98 -6
- package/corpus/core/src/agent/production-agent.ts +151 -18
- package/corpus/core/src/agent/run-loop-with-resume.ts +190 -3
- package/corpus/core/src/agent/run-manager.ts +117 -41
- package/corpus/core/src/agent/thread-debug-history.ts +86 -0
- package/corpus/core/src/agent/types.ts +3 -1
- package/corpus/core/src/cli/create.ts +11 -1
- package/corpus/core/src/cli/templates-meta.ts +2 -2
- package/corpus/core/src/client/agent-chat-adapter.ts +91 -13
- package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +11 -9
- package/corpus/core/src/client/sse-event-processor.ts +17 -3
- package/corpus/core/src/db/client.ts +57 -17
- package/corpus/core/src/guards/no-env-credentials.ts +2 -0
- package/corpus/core/src/integrations/adapters/slack.ts +8 -3
- package/corpus/core/src/localization/default-messages.ts +44 -0
- package/corpus/core/src/observability/traces.ts +78 -5
- package/corpus/core/src/scripts/call-agent.ts +294 -11
- package/corpus/core/src/scripts/describe-workspace-apps.ts +2 -2
- package/corpus/core/src/secrets/crypto.ts +156 -35
- package/corpus/core/src/secrets/storage.ts +64 -26
- package/corpus/core/src/server/agent-capabilities.ts +1 -1
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +113 -7
- package/corpus/core/src/server/agent-chat/context-tools.ts +2 -0
- package/corpus/core/src/server/agent-chat/plugin-options.ts +34 -1
- package/corpus/core/src/server/agent-chat/prompt-resources.ts +1 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +91 -59
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +19 -7
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +19 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/corpus/core/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +19 -7
- package/corpus/core/src/vite/client.ts +1 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-ops/SKILL.md +5 -4
- package/corpus/templates/analytics/.agents/skills/gong/SKILL.md +6 -4
- package/corpus/templates/analytics/AGENTS.md +7 -4
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +4 -3
- package/corpus/templates/analytics/changelog/2026-07-30-delegated-analytics-questions-now-return-a-useful-current-me.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-30-scheduled-dashboard-emails-complete-every-panel-without-pool.md +6 -0
- package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +28 -1
- package/corpus/templates/analytics/server/jobs/dashboard-report.ts +18 -11
- package/corpus/templates/analytics/server/lib/analytics-connector-catalog.ts +4 -4
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +9 -5
- package/corpus/templates/analytics/server/lib/dashboard-panel-query.ts +6 -2
- package/corpus/templates/analytics/server/lib/dashboard-panel-source-resolver.ts +11 -4
- package/corpus/templates/analytics/server/lib/dashboard-report-render.ts +49 -31
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +16 -8
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +9 -3
- package/corpus/templates/analytics/server/lib/production-serverless-runtime.ts +11 -0
- package/corpus/templates/analytics/server/lib/real-data-actions.ts +10 -0
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +3 -2
- package/corpus/templates/analytics/server/plugins/analytics-alert-jobs.ts +2 -1
- package/corpus/templates/analytics/server/plugins/dashboard-report-jobs.ts +2 -1
- package/corpus/templates/analytics/server/plugins/uptime-monitor-jobs.ts +1 -12
- package/corpus/templates/brain/.agents/skills/brain/RUNBOOK.md +54 -6
- package/corpus/templates/brain/.agents/skills/brain/SKILL.md +20 -9
- package/corpus/templates/brain/.agents/skills/ingestion-and-connectors/SKILL.md +33 -1
- package/corpus/templates/brain/AGENTS.md +3 -1
- package/corpus/templates/brain/README.md +4 -1
- package/corpus/templates/brain/actions/_schemas.ts +30 -8
- package/corpus/templates/brain/actions/ask-brain.ts +124 -14
- package/corpus/templates/brain/actions/create-source.ts +18 -2
- package/corpus/templates/brain/actions/enqueue-captures-distillation.ts +8 -123
- package/corpus/templates/brain/actions/enqueue-distillation.ts +6 -127
- package/corpus/templates/brain/actions/import-capture.ts +17 -5
- package/corpus/templates/brain/actions/import-transcript.ts +17 -5
- package/corpus/templates/brain/actions/update-source.ts +25 -5
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +1 -1
- package/corpus/templates/brain/changelog/2026-07-30-blessed-resources-can-feed-cited-company-answers.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-30-the-left-sidebar-no-longer-shows-a-blank-organization-placeh.md +6 -0
- package/corpus/templates/brain/server/lib/brain.ts +49 -19
- package/corpus/templates/brain/server/lib/distillation-queue.ts +147 -0
- package/corpus/templates/brain/server/lib/source-policy.ts +264 -0
- package/corpus/templates/brain/server/plugins/agent-chat.ts +3 -2
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +116 -19
- package/corpus/templates/clips/app/components/meetings/google-oauth-identity-notice.tsx +51 -0
- package/corpus/templates/clips/app/i18n/en-US.ts +4 -0
- package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +3 -1
- package/corpus/templates/clips/changelog/2026-07-30-google-calendar-warning.md +6 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +72 -8
- package/corpus/templates/content/changelog/2026-07-30-the-slash-command-hint-now-stays-on-only-the-active-empty-li.md +6 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +506 -11
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +148 -17
- package/corpus/templates/design/app/components/design/canvas-interactions/design-canvas-interactions.ts +357 -0
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +7 -466
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +15 -311
- package/corpus/templates/design/app/components/visual-editor/CanvasCommentPins.tsx +19 -997
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +8 -1216
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +31 -38
- package/corpus/templates/design/package.json +0 -1
- package/corpus/templates/dispatch/AGENTS.md +8 -0
- package/corpus/templates/dispatch/DEVELOPING.md +29 -0
- package/corpus/templates/dispatch/actions/view-screen.ts +34 -2
- package/corpus/templates/dispatch/app/i18n-data.ts +457 -0
- package/corpus/templates/dispatch/changelog/2026-07-30-delegated-dispatch-work-continues-reliably-in-the-background.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-30-find-failed-runs-across-apps.md +6 -0
- package/corpus/templates/dispatch/netlify.toml +3 -0
- package/corpus/templates/plan/actions/get-visual-plan.ts +10 -6
- package/corpus/templates/plan/actions/patch-visual-plan-source.ts +117 -1
- package/corpus/templates/plan/actions/update-visual-plan.ts +56 -14
- package/corpus/templates/plan/app/pages/PlansPage.tsx +1 -1
- package/corpus/templates/plan/changelog/2026-07-30-plan-agents-recover-with-targeted-writes.md +6 -0
- package/corpus/templates/plan/shared/plan-content.ts +35 -0
- package/corpus/templates/slides/.agents/skills/analytics-data-for-decks/SKILL.md +8 -12
- package/corpus/templates/slides/AGENTS.md +4 -4
- package/corpus/templates/slides/actions/create-deck.ts +1 -1
- package/corpus/templates/slides/actions/duplicate-deck.ts +19 -4
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +2 -10
- package/corpus/templates/slides/app/components/deck/MermaidRenderer.tsx +12 -1
- package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +30 -13
- package/corpus/templates/slides/app/components/editor/DeckEditorSkeleton.tsx +35 -0
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +63 -56
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +21 -76
- package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +1110 -292
- package/corpus/templates/slides/app/components/editor/SlideOverflowWarning.tsx +53 -0
- package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +235 -18
- package/corpus/templates/slides/app/components/editor/SpeakerNotesPanel.tsx +4 -1
- package/corpus/templates/slides/app/components/editor/canvas-interactions/index.ts +11 -0
- package/corpus/templates/slides/app/components/editor/canvas-interactions/slides-canvas-adapter.ts +129 -0
- package/corpus/templates/slides/app/components/editor/selection-overlay-measurement.ts +70 -0
- package/corpus/templates/slides/app/components/editor/slide-object-interactions.ts +519 -65
- package/corpus/templates/slides/app/components/visual-editor/CanvasCommentPins.tsx +36 -426
- package/corpus/templates/slides/app/components/visual-editor/DrawOverlay.tsx +19 -458
- package/corpus/templates/slides/app/context/DeckContext.tsx +179 -72
- package/corpus/templates/slides/app/global.css +105 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +8 -0
- package/corpus/templates/slides/app/lib/deck-editor-loading.ts +26 -0
- package/corpus/templates/slides/app/lib/mermaid-blocks.ts +27 -0
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +71 -38
- package/corpus/templates/slides/app/pages/Index.tsx +98 -41
- package/corpus/templates/slides/changelog/2026-07-30-deck-loading-no-longer-flashes-an-unavailable-message.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-duplicating-a-deck-from-the-deck-list-now-opens-the-copy-imm.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-layout-overflow-warning-is-readable-and-dismissible.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-new-decks-now-start-with-an-empty-slide-list-when-no-slides-.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-shared-canvas-annotations.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-slide-objects-can-be-moved-as-a-group-copied-and-pasted-with.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-slide-text-editing-and-object-controls-now-match-google-slides.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-style-panel-now-scrolls-with-speaker-notes-open-shows-the-sl.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-top-toolbar-controls-now-use-consistent-sizing-with-undo-and.md +6 -0
- package/corpus/templates/slides/netlify.toml +3 -1
- package/corpus/templates/slides/package.json +0 -1
- package/corpus/templates/slides/server/lib/chat-attachments.ts +18 -0
- package/corpus/templates/slides/server/plugins/agent-chat.ts +5 -0
- package/corpus/templates/slides/vite.config.ts +0 -1
- package/corpus/toolkit/CHANGELOG.md +13 -0
- package/corpus/toolkit/README.md +19 -0
- package/corpus/toolkit/agent-native.eject.json +38 -0
- package/corpus/toolkit/package.json +29 -1
- package/corpus/toolkit/src/canvas-annotations/CanvasCommentPins.tsx +861 -0
- package/corpus/toolkit/src/canvas-annotations/DrawOverlay.tsx +1233 -0
- package/corpus/toolkit/src/canvas-annotations/index.ts +15 -0
- package/corpus/toolkit/src/canvas-annotations/types.ts +14 -0
- package/corpus/toolkit/src/canvas-interactions/canvas-interactions.ts +933 -0
- package/corpus/toolkit/src/canvas-interactions/index.ts +67 -0
- package/corpus/toolkit/src/design-tweaks/scrub-input-utils.ts +311 -0
- package/corpus/toolkit/src/design-tweaks/scrub-input.tsx +491 -0
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +26 -171
- package/corpus/toolkit/src/index.ts +1 -0
- package/dist/a2a/client.d.ts +23 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +309 -44
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/correlation.d.ts +1 -0
- package/dist/a2a/correlation.d.ts.map +1 -1
- package/dist/a2a/correlation.js +27 -0
- package/dist/a2a/correlation.js.map +1 -1
- package/dist/a2a/invoke.d.ts.map +1 -1
- package/dist/a2a/invoke.js +4 -2
- package/dist/a2a/invoke.js.map +1 -1
- package/dist/a2a/types.d.ts +4 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/a2a/types.js.map +1 -1
- package/dist/action.d.ts +3 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/action-continuation-guidance.d.ts.map +1 -1
- package/dist/agent/action-continuation-guidance.js +2 -1
- package/dist/agent/action-continuation-guidance.js.map +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +82 -8
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/production-agent.d.ts +40 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +113 -15
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts +21 -0
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +163 -4
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/agent/run-manager.d.ts +16 -9
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +93 -42
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/thread-debug-history.d.ts +10 -0
- package/dist/agent/thread-debug-history.d.ts.map +1 -0
- package/dist/agent/thread-debug-history.js +68 -0
- package/dist/agent/thread-debug-history.js.map +1 -0
- package/dist/agent/types.d.ts +3 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +6 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/templates-meta.js +2 -2
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +76 -13
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.js +1 -1
- package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +12 -3
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +48 -17
- package/dist/db/client.js.map +1 -1
- package/dist/guards/no-env-credentials.d.ts.map +1 -1
- package/dist/guards/no-env-credentials.js +2 -0
- package/dist/guards/no-env-credentials.js.map +1 -1
- package/dist/integrations/adapters/slack.js +7 -3
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/localization/default-messages.d.ts +43 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +43 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/observability/traces.d.ts +3 -1
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +73 -4
- package/dist/observability/traces.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +12 -12
- package/dist/provider-api/actions/provider-api.d.ts +13 -13
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +237 -12
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/describe-workspace-apps.js +2 -2
- package/dist/scripts/describe-workspace-apps.js.map +1 -1
- package/dist/secrets/crypto.d.ts +36 -21
- package/dist/secrets/crypto.d.ts.map +1 -1
- package/dist/secrets/crypto.js +134 -33
- package/dist/secrets/crypto.js.map +1 -1
- package/dist/secrets/storage.d.ts +6 -6
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +43 -26
- package/dist/secrets/storage.js.map +1 -1
- package/dist/server/agent-capabilities.js +1 -1
- package/dist/server/agent-capabilities.js.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +17 -3
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.js +94 -3
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -1
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -1
- package/dist/server/agent-chat/context-tools.js +2 -0
- package/dist/server/agent-chat/context-tools.js.map +1 -1
- package/dist/server/agent-chat/plugin-options.d.ts +23 -0
- package/dist/server/agent-chat/plugin-options.d.ts.map +1 -1
- package/dist/server/agent-chat/plugin-options.js +4 -1
- package/dist/server/agent-chat/plugin-options.js.map +1 -1
- package/dist/server/agent-chat/prompt-resources.js +1 -1
- package/dist/server/agent-chat/prompt-resources.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +2 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +79 -56
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +19 -7
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +19 -7
- package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/dist/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +19 -7
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/agent-native-toolkit.mdx +13 -6
- package/docs/content/cloneable-saas.mdx +5 -5
- package/docs/content/creating-templates.mdx +9 -0
- package/docs/content/deployment.mdx +18 -12
- package/docs/content/doctor.mdx +8 -1
- package/docs/content/drop-in-agent.mdx +1 -1
- package/docs/content/extensions.mdx +18 -18
- package/docs/content/faq.mdx +4 -4
- package/docs/content/key-concepts.mdx +30 -21
- package/docs/content/security.mdx +2 -2
- package/docs/content/template-brain-developers.mdx +4 -1
- package/docs/content/template-mail-developers.mdx +4 -1
- package/docs/content/what-is-agent-native.mdx +6 -6
- package/package.json +3 -3
- package/src/a2a/client.ts +449 -66
- package/src/a2a/correlation.ts +31 -0
- package/src/a2a/invoke.ts +4 -2
- package/src/a2a/types.ts +4 -0
- package/src/action.ts +3 -0
- package/src/agent/action-continuation-guidance.ts +2 -1
- package/src/agent/engine/registry.ts +98 -6
- package/src/agent/production-agent.ts +151 -18
- package/src/agent/run-loop-with-resume.ts +190 -3
- package/src/agent/run-manager.ts +117 -41
- package/src/agent/thread-debug-history.ts +86 -0
- package/src/agent/types.ts +3 -1
- package/src/cli/create.ts +11 -1
- package/src/cli/templates-meta.ts +2 -2
- package/src/client/agent-chat-adapter.ts +91 -13
- package/src/client/resources/McpIntegrationDialog.tsx +11 -9
- package/src/client/sse-event-processor.ts +17 -3
- package/src/db/client.ts +57 -17
- package/src/guards/no-env-credentials.ts +2 -0
- package/src/integrations/adapters/slack.ts +8 -3
- package/src/localization/default-messages.ts +44 -0
- package/src/observability/traces.ts +78 -5
- package/src/scripts/call-agent.ts +294 -11
- package/src/scripts/describe-workspace-apps.ts +2 -2
- package/src/secrets/crypto.ts +156 -35
- package/src/secrets/storage.ts +64 -26
- package/src/server/agent-capabilities.ts +1 -1
- package/src/server/agent-chat/action-filters-a2a.ts +113 -7
- package/src/server/agent-chat/context-tools.ts +2 -0
- package/src/server/agent-chat/plugin-options.ts +34 -1
- package/src/server/agent-chat/prompt-resources.ts +1 -1
- package/src/server/agent-chat-plugin.ts +91 -59
- package/src/templates/default/.agents/skills/secrets/SKILL.md +19 -7
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +19 -7
- package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +19 -7
- package/src/vite/client.ts +1 -0
|
@@ -39,6 +39,27 @@ export declare function appendDurableContinuationContext(messages: EngineMessage
|
|
|
39
39
|
* generation (prompt + 3 variants ≈ 4 LLM calls), with a small safety margin.
|
|
40
40
|
*/
|
|
41
41
|
export declare const MAX_RUN_LOOP_CONTINUATIONS = 6;
|
|
42
|
+
/**
|
|
43
|
+
* A delegated turn that is proven to be running inside a durable background
|
|
44
|
+
* function has the same 15-minute host budget as main chat, but this wrapper
|
|
45
|
+
* historically kept the foreground-sized six-continuation cap. A healthy
|
|
46
|
+
* child A2A call can consume several minutes and the receiving model may then
|
|
47
|
+
* need more than six recovery/model-stream boundaries to finish its own tool
|
|
48
|
+
* work. Keep a hard cap, but give the proven background path the same bounded
|
|
49
|
+
* continuation allowance as the durable main-chat runner. The cumulative
|
|
50
|
+
* soft-timeout below still prevents these rounds from exceeding the one real
|
|
51
|
+
* background-function wall-clock budget.
|
|
52
|
+
*/
|
|
53
|
+
export declare const MAX_BACKGROUND_RUN_LOOP_CONTINUATIONS = 20;
|
|
54
|
+
/**
|
|
55
|
+
* The engine already performs its own short provider retries. After those are
|
|
56
|
+
* exhausted, a proven durable background A2A/MCP run gets one cooled-down
|
|
57
|
+
* continuation for a transient 429/529. One extra round is enough to bridge a
|
|
58
|
+
* short provider bucket without multiplying a sustained rate limit into a
|
|
59
|
+
* request storm across the larger background continuation allowance.
|
|
60
|
+
*/
|
|
61
|
+
export declare const MAX_BACKGROUND_RATE_LIMIT_CONTINUATIONS = 1;
|
|
62
|
+
export declare const BACKGROUND_RATE_LIMIT_CONTINUATION_DELAY_MS = 20000;
|
|
42
63
|
/** Machine-readable code carried on the give-up terminal `error` event so the
|
|
43
64
|
* client renders a loud "stopped before finishing" terminal instead of an
|
|
44
65
|
* ambiguous silent stall. Deliberately NOT in the client's auto-recoverable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-loop-with-resume.d.ts","sourceRoot":"","sources":["../../src/agent/run-loop-with-resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,YAAY,
|
|
1
|
+
{"version":3,"file":"run-loop-with-resume.d.ts","sourceRoot":"","sources":["../../src/agent/run-loop-with-resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,YAAY,EAQZ,KAAK,2BAA2B,EAEjC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AA4FrE;;;GAGG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,aAAa,EAAE,EACzB,MAAM,EAAE,2BAA2B,EACnC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAEf;AAsCD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qCAAqC,KAAK,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,uCAAuC,IAAI,CAAC;AACzD,eAAO,MAAM,2CAA2C,QAAS,CAAC;AAoBlE;;;;wDAIwD;AACxD,eAAO,MAAM,+BAA+B,yBAAyB,CAAC;AAEtE;;;;;iCAKiC;AACjC,eAAO,MAAM,4BAA4B,QAGkD,CAAC;AAE5F;;;;;;;;GAQG;AACH,wBAAsB,iCAAiC,CACrD,IAAI,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,EACxC,aAAa,CAAC,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,4BAA4B,GAC5C,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CA0WnD"}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* Both paths route through `appendAgentLoopContinuation` so the agent sees a
|
|
21
21
|
* uniform "continue" instruction regardless of which recovery fired.
|
|
22
22
|
*/
|
|
23
|
-
import { runAgentLoop, appendAgentLoopContinuation, isResumableEngineError, continuationReasonForResumableError, lastUnfinishedPreparingActionToolFromEvents, resolveFinalResponseGuardRequestText, SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS, } from "./production-agent.js";
|
|
23
|
+
import { runAgentLoop, appendAgentLoopContinuation, isResumableEngineError, isTransientProviderRateLimitError, continuationReasonForResumableError, lastUnfinishedPreparingActionToolFromEvents, resolveFinalResponseGuardRequestText, SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS, } from "./production-agent.js";
|
|
24
24
|
import { resolveRunSoftTimeoutMs } from "./run-manager.js";
|
|
25
25
|
import { getCurrentTurnEventsForThread } from "./run-store.js";
|
|
26
26
|
import { classifyToolCallJournal, buildResumeJournalNote, } from "./tool-call-journal.js";
|
|
@@ -136,6 +136,40 @@ function internalContinuationReasonForAttempt(events) {
|
|
|
136
136
|
* generation (prompt + 3 variants ≈ 4 LLM calls), with a small safety margin.
|
|
137
137
|
*/
|
|
138
138
|
export const MAX_RUN_LOOP_CONTINUATIONS = 6;
|
|
139
|
+
/**
|
|
140
|
+
* A delegated turn that is proven to be running inside a durable background
|
|
141
|
+
* function has the same 15-minute host budget as main chat, but this wrapper
|
|
142
|
+
* historically kept the foreground-sized six-continuation cap. A healthy
|
|
143
|
+
* child A2A call can consume several minutes and the receiving model may then
|
|
144
|
+
* need more than six recovery/model-stream boundaries to finish its own tool
|
|
145
|
+
* work. Keep a hard cap, but give the proven background path the same bounded
|
|
146
|
+
* continuation allowance as the durable main-chat runner. The cumulative
|
|
147
|
+
* soft-timeout below still prevents these rounds from exceeding the one real
|
|
148
|
+
* background-function wall-clock budget.
|
|
149
|
+
*/
|
|
150
|
+
export const MAX_BACKGROUND_RUN_LOOP_CONTINUATIONS = 20;
|
|
151
|
+
/**
|
|
152
|
+
* The engine already performs its own short provider retries. After those are
|
|
153
|
+
* exhausted, a proven durable background A2A/MCP run gets one cooled-down
|
|
154
|
+
* continuation for a transient 429/529. One extra round is enough to bridge a
|
|
155
|
+
* short provider bucket without multiplying a sustained rate limit into a
|
|
156
|
+
* request storm across the larger background continuation allowance.
|
|
157
|
+
*/
|
|
158
|
+
export const MAX_BACKGROUND_RATE_LIMIT_CONTINUATIONS = 1;
|
|
159
|
+
export const BACKGROUND_RATE_LIMIT_CONTINUATION_DELAY_MS = 20_000;
|
|
160
|
+
function waitForBackgroundRateLimitCooldown(signal) {
|
|
161
|
+
if (signal.aborted)
|
|
162
|
+
return Promise.resolve();
|
|
163
|
+
return new Promise((resolve) => {
|
|
164
|
+
const finish = () => {
|
|
165
|
+
clearTimeout(timer);
|
|
166
|
+
signal.removeEventListener("abort", finish);
|
|
167
|
+
resolve();
|
|
168
|
+
};
|
|
169
|
+
const timer = setTimeout(finish, BACKGROUND_RATE_LIMIT_CONTINUATION_DELAY_MS);
|
|
170
|
+
signal.addEventListener("abort", finish, { once: true });
|
|
171
|
+
});
|
|
172
|
+
}
|
|
139
173
|
/** Machine-readable code carried on the give-up terminal `error` event so the
|
|
140
174
|
* client renders a loud "stopped before finishing" terminal instead of an
|
|
141
175
|
* ambiguous silent stall. Deliberately NOT in the client's auto-recoverable
|
|
@@ -165,8 +199,72 @@ export async function runAgentLoopDirectWithSoftTimeout(opts, softTimeoutMs, tim
|
|
|
165
199
|
resolveFinalResponseGuardRequestText(opts.messages);
|
|
166
200
|
const stableOpts = { ...opts, finalResponseGuardRequestText };
|
|
167
201
|
const timeoutMs = resolveRunSoftTimeoutMs(softTimeoutMs, timeoutOptions);
|
|
168
|
-
|
|
169
|
-
|
|
202
|
+
let finalOutcomeReported = false;
|
|
203
|
+
const reportFinalOutcome = (outcome) => {
|
|
204
|
+
if (finalOutcomeReported)
|
|
205
|
+
return;
|
|
206
|
+
finalOutcomeReported = true;
|
|
207
|
+
try {
|
|
208
|
+
opts.onOutcome?.(outcome);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
// Outcome observers cannot alter recovery or completion.
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
// Disabling continuation recovery must not disable terminal classification.
|
|
215
|
+
// Keep the same outcome boundary around a direct loop so A2A/MCP callers
|
|
216
|
+
// never infer success from a rejected or canceled run.
|
|
217
|
+
if (timeoutMs <= 0) {
|
|
218
|
+
const directEvents = [];
|
|
219
|
+
let directOutcome;
|
|
220
|
+
try {
|
|
221
|
+
const result = await runAgentLoop({
|
|
222
|
+
...stableOpts,
|
|
223
|
+
send: (event) => {
|
|
224
|
+
directEvents.push(event);
|
|
225
|
+
stableOpts.send(event);
|
|
226
|
+
},
|
|
227
|
+
onOutcome: (outcome) => {
|
|
228
|
+
directOutcome = outcome;
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
const unfinishedReason = internalContinuationReasonForAttempt(directEvents);
|
|
232
|
+
if (opts.signal.aborted) {
|
|
233
|
+
reportFinalOutcome({
|
|
234
|
+
state: "canceled",
|
|
235
|
+
message: "Agent run was aborted.",
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
else if (unfinishedReason) {
|
|
239
|
+
reportFinalOutcome({
|
|
240
|
+
state: "failed",
|
|
241
|
+
code: unfinishedReason,
|
|
242
|
+
retryable: false,
|
|
243
|
+
message: `Agent stopped before finishing (${unfinishedReason}).`,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
reportFinalOutcome(directOutcome ?? { state: "completed" });
|
|
248
|
+
}
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
const candidate = err;
|
|
253
|
+
reportFinalOutcome(opts.signal.aborted
|
|
254
|
+
? { state: "canceled", message: "Agent run was aborted." }
|
|
255
|
+
: {
|
|
256
|
+
state: "failed",
|
|
257
|
+
code: typeof candidate?.errorCode === "string" && candidate.errorCode
|
|
258
|
+
? candidate.errorCode
|
|
259
|
+
: "internal_error",
|
|
260
|
+
retryable: isResumableEngineError(err),
|
|
261
|
+
message: typeof candidate?.message === "string"
|
|
262
|
+
? candidate.message
|
|
263
|
+
: String(err),
|
|
264
|
+
});
|
|
265
|
+
throw err;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
170
268
|
const upstreamSignal = opts.signal;
|
|
171
269
|
const usage = {
|
|
172
270
|
inputTokens: 0,
|
|
@@ -202,6 +300,10 @@ export async function runAgentLoopDirectWithSoftTimeout(opts, softTimeoutMs, tim
|
|
|
202
300
|
// pattern, already proven for the analogous foreground self-chain case).
|
|
203
301
|
// The first round is unaffected — it always gets the full `timeoutMs`.
|
|
204
302
|
const loopEntryAt = Date.now();
|
|
303
|
+
const maxRunLoopContinuations = timeoutOptions?.backgroundFunction === true
|
|
304
|
+
? MAX_BACKGROUND_RUN_LOOP_CONTINUATIONS
|
|
305
|
+
: MAX_RUN_LOOP_CONTINUATIONS;
|
|
306
|
+
let backgroundRateLimitContinuations = 0;
|
|
205
307
|
// Tracks whether the most recent attempt ended by scheduling another
|
|
206
308
|
// continuation (soft-timeout or resumable error → `continue`) rather than
|
|
207
309
|
// returning a finished turn. When the loop then exits because the budget is
|
|
@@ -209,7 +311,7 @@ export async function runAgentLoopDirectWithSoftTimeout(opts, softTimeoutMs, tim
|
|
|
209
311
|
// this is the silent give-up case: emit a loud terminal so the user sees an
|
|
210
312
|
// unambiguous "stopped before finishing" instead of a bare done/"…".
|
|
211
313
|
let lastAttemptWasUnfinishedContinuation = false;
|
|
212
|
-
while (!upstreamSignal.aborted && attempts <
|
|
314
|
+
while (!upstreamSignal.aborted && attempts < maxRunLoopContinuations) {
|
|
213
315
|
const roundTimeoutMs = attempts === 0 ? timeoutMs : timeoutMs - (Date.now() - loopEntryAt);
|
|
214
316
|
if (attempts > 0 &&
|
|
215
317
|
roundTimeoutMs < SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS) {
|
|
@@ -245,10 +347,14 @@ export async function runAgentLoopDirectWithSoftTimeout(opts, softTimeoutMs, tim
|
|
|
245
347
|
opts.send(event);
|
|
246
348
|
};
|
|
247
349
|
try {
|
|
350
|
+
let attemptOutcome;
|
|
248
351
|
const nextUsage = await runAgentLoop({
|
|
249
352
|
...stableOpts,
|
|
250
353
|
send,
|
|
251
354
|
signal: controller.signal,
|
|
355
|
+
onOutcome: (outcome) => {
|
|
356
|
+
attemptOutcome = outcome;
|
|
357
|
+
},
|
|
252
358
|
});
|
|
253
359
|
addUsage(nextUsage);
|
|
254
360
|
const attemptEvents = localTurnEvents.slice(attemptStartIndex);
|
|
@@ -267,6 +373,9 @@ export async function runAgentLoopDirectWithSoftTimeout(opts, softTimeoutMs, tim
|
|
|
267
373
|
await appendContinuationAndJournal(opts.messages, "run_timeout", opts.threadId, localTurnEvents);
|
|
268
374
|
continue;
|
|
269
375
|
}
|
|
376
|
+
reportFinalOutcome(upstreamSignal.aborted
|
|
377
|
+
? { state: "canceled", message: "Agent run was aborted." }
|
|
378
|
+
: (attemptOutcome ?? { state: "completed" }));
|
|
270
379
|
return usage;
|
|
271
380
|
}
|
|
272
381
|
catch (err) {
|
|
@@ -280,6 +389,26 @@ export async function runAgentLoopDirectWithSoftTimeout(opts, softTimeoutMs, tim
|
|
|
280
389
|
await appendContinuationAndJournal(opts.messages, "run_timeout", opts.threadId, localTurnEvents);
|
|
281
390
|
continue;
|
|
282
391
|
}
|
|
392
|
+
const transientRateLimit = isTransientProviderRateLimitError(err);
|
|
393
|
+
const rateLimitRetryFitsBudget = timeoutOptions?.backgroundFunction === true &&
|
|
394
|
+
backgroundRateLimitContinuations <
|
|
395
|
+
MAX_BACKGROUND_RATE_LIMIT_CONTINUATIONS &&
|
|
396
|
+
timeoutMs -
|
|
397
|
+
(Date.now() - loopEntryAt) -
|
|
398
|
+
BACKGROUND_RATE_LIMIT_CONTINUATION_DELAY_MS >=
|
|
399
|
+
SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS;
|
|
400
|
+
if (!upstreamSignal.aborted &&
|
|
401
|
+
transientRateLimit &&
|
|
402
|
+
rateLimitRetryFitsBudget) {
|
|
403
|
+
lastAttemptWasUnfinishedContinuation = true;
|
|
404
|
+
backgroundRateLimitContinuations++;
|
|
405
|
+
if (!(await hasCompletedSideEffectToolCallInCurrentTurn(opts.threadId, localTurnEvents))) {
|
|
406
|
+
opts.send({ type: "clear" });
|
|
407
|
+
}
|
|
408
|
+
await appendContinuationAndJournal(opts.messages, "rate_limited", opts.threadId, localTurnEvents);
|
|
409
|
+
await waitForBackgroundRateLimitCooldown(upstreamSignal);
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
283
412
|
// Resumable transport / gateway interruptions: the LLM call was cut off
|
|
284
413
|
// mid-stream (gateway 45s timeout, socket hang up, function-level
|
|
285
414
|
// timeout that didn't trip our soft timer first). Treat it the same way
|
|
@@ -301,6 +430,24 @@ export async function runAgentLoopDirectWithSoftTimeout(opts, softTimeoutMs, tim
|
|
|
301
430
|
await appendContinuationAndJournal(opts.messages, continuationReasonForResumableError(err), opts.threadId, localTurnEvents);
|
|
302
431
|
continue;
|
|
303
432
|
}
|
|
433
|
+
if (upstreamSignal.aborted) {
|
|
434
|
+
reportFinalOutcome({
|
|
435
|
+
state: "canceled",
|
|
436
|
+
message: "Agent run was aborted.",
|
|
437
|
+
});
|
|
438
|
+
throw err;
|
|
439
|
+
}
|
|
440
|
+
const candidate = err;
|
|
441
|
+
reportFinalOutcome({
|
|
442
|
+
state: "failed",
|
|
443
|
+
code: typeof candidate?.errorCode === "string" && candidate.errorCode
|
|
444
|
+
? candidate.errorCode
|
|
445
|
+
: "internal_error",
|
|
446
|
+
retryable: false,
|
|
447
|
+
message: typeof candidate?.message === "string"
|
|
448
|
+
? candidate.message
|
|
449
|
+
: String(err),
|
|
450
|
+
});
|
|
304
451
|
throw err;
|
|
305
452
|
}
|
|
306
453
|
finally {
|
|
@@ -329,6 +476,18 @@ export async function runAgentLoopDirectWithSoftTimeout(opts, softTimeoutMs, tim
|
|
|
329
476
|
errorCode: RUN_BUDGET_EXHAUSTED_ERROR_CODE,
|
|
330
477
|
recoverable: true,
|
|
331
478
|
});
|
|
479
|
+
reportFinalOutcome({
|
|
480
|
+
state: "failed",
|
|
481
|
+
code: RUN_BUDGET_EXHAUSTED_ERROR_CODE,
|
|
482
|
+
retryable: false,
|
|
483
|
+
message: RUN_BUDGET_EXHAUSTED_MESSAGE,
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
else if (upstreamSignal.aborted) {
|
|
487
|
+
reportFinalOutcome({
|
|
488
|
+
state: "canceled",
|
|
489
|
+
message: "Agent run was aborted.",
|
|
490
|
+
});
|
|
332
491
|
}
|
|
333
492
|
return usage;
|
|
334
493
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-loop-with-resume.js","sourceRoot":"","sources":["../../src/agent/run-loop-with-resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,oCAAoC,EACpC,qCAAqC,GAEtC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;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,yEAAyE;QACzE,wEAAwE;QACxE,uEAAuE;QACvE,IACE,CAAC,CAAC,MAAM,2CAA2C,CACjD,IAAI,CAAC,QAAQ,EACb,eAAe,CAChB,CAAC,EACF,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,4BAA4B;YACnC,SAAS,EAAE,+BAA+B;YAC1C,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * Wraps `runAgentLoop` with two layered recovery mechanisms so a single hosted\n * invocation can survive interruptions without showing the user a dead chat:\n *\n * 1. **Soft timeout** — an inner timer that aborts the LLM call before the\n * hosting function's hard limit (Lambda 75s, Vercel 60s, etc.) so we have a\n * chance to gracefully wind down and append a continuation nudge. Without\n * this the function gets killed mid-stream and the user sees a frozen\n * spinner.\n *\n * 2. **Resumable-error continuation** — when the LLM call errors with a\n * transport- or gateway-level interruption (Builder gateway 45s timeout,\n * socket hang up, ECONNRESET, upstream 5xx that survived engine retries),\n * we save the conversation prefix, append a \"continue from where you left\n * off\" message, and run another LLM call. Anthropic's prompt cache makes\n * the resume call dramatically faster than the cold first attempt, and the\n * agent gets explicit context that it was cut off so it doesn't re-do\n * completed work.\n *\n * Both paths route through `appendAgentLoopContinuation` so the agent sees a\n * uniform \"continue\" instruction regardless of which recovery fired.\n */\n\nimport type { EngineMessage } from \"./engine/types.js\";\nimport {\n runAgentLoop,\n appendAgentLoopContinuation,\n isResumableEngineError,\n continuationReasonForResumableError,\n lastUnfinishedPreparingActionToolFromEvents,\n resolveFinalResponseGuardRequestText,\n SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS,\n type AgentLoopContinuationReason,\n} from \"./production-agent.js\";\nimport { resolveRunSoftTimeoutMs } from \"./run-manager.js\";\nimport type { ResolveRunSoftTimeoutOptions } from \"./run-manager.js\";\nimport { getCurrentTurnEventsForThread } from \"./run-store.js\";\nimport {\n classifyToolCallJournal,\n buildResumeJournalNote,\n} from \"./tool-call-journal.js\";\nimport type { AgentChatEvent } from \"./types.js\";\n\nasync function readCurrentTurnEventsForResume(\n threadId: string | undefined,\n localEvents: readonly AgentChatEvent[] = [],\n): Promise<AgentChatEvent[]> {\n let persistedEvents: AgentChatEvent[] = [];\n try {\n persistedEvents = threadId\n ? await getCurrentTurnEventsForThread(threadId)\n : [];\n } catch {\n persistedEvents = [];\n }\n if (localEvents.length === 0) return persistedEvents;\n const seen = new Set(persistedEvents.map((event) => JSON.stringify(event)));\n return [\n ...persistedEvents,\n ...localEvents.filter((event) => !seen.has(JSON.stringify(event))),\n ];\n}\n\nfunction actionPreparationContinuationOptions(\n events: readonly AgentChatEvent[],\n): { actionPreparationTool?: string } {\n const actionPreparationTool =\n lastUnfinishedPreparingActionToolFromEvents(events);\n return actionPreparationTool ? { actionPreparationTool } : {};\n}\n\n/**\n * Derive the per-turn tool-call journal from the durable run-event ledger and,\n * when there is anything to report, append a STRUCTURED note to the message\n * prefix so the resumed model:\n * - does NOT re-execute tool calls that already completed (avoiding duplicate\n * side effects like re-sending an email or re-creating a ticket), and\n * - is explicitly told about any tool call that started but whose outcome was\n * never recorded (\"interrupted, unknown outcome\") so it can decide.\n *\n * This is additive to the existing \"continue from where you left off\" nudge —\n * it is appended right after it. When the journal is empty (no completed or\n * interrupted tool calls — e.g. a turn with no tool activity, or a clean\n * continuation), nothing extra is appended and resume behavior is byte-for-byte\n * what it was before. Best-effort: any ledger read/parse failure is swallowed so\n * a journal hiccup can never block a recovery that would otherwise succeed.\n *\n * This prompt-level journal is paired with tool-layer enforcement in\n * production-agent.ts/runToolCall, which refuses to re-execute a journaled-\n * complete write tool (returning the journaled result instead). See\n * `tool-call-journal.ts` (`findCompletedJournalEntry`) for the keying used.\n */\nfunction appendToolCallJournalNote(\n messages: EngineMessage[],\n events: readonly AgentChatEvent[],\n): void {\n try {\n if (events.length === 0) return;\n const journal = classifyToolCallJournal(events);\n const note = buildResumeJournalNote(journal);\n if (!note) return;\n messages.push({\n role: \"user\",\n content: [{ type: \"text\", text: note }],\n });\n } catch {\n // The journal is a hardening layer, never a gate. A failed ledger read or\n // parse must not break the resume that the continuation nudge already set\n // up — the model still continues, just without the structured journal.\n }\n}\n\nasync function appendContinuationAndJournal(\n messages: EngineMessage[],\n reason: AgentLoopContinuationReason,\n threadId: string | undefined,\n localEvents: readonly AgentChatEvent[] = [],\n): Promise<void> {\n const events = await readCurrentTurnEventsForResume(threadId, localEvents);\n appendAgentLoopContinuation(\n messages,\n reason,\n actionPreparationContinuationOptions(events),\n );\n appendToolCallJournalNote(messages, events);\n}\n\n/**\n * Rebuild the same safe continuation context for a logical turn that resumes\n * in a fresh hosted invocation.\n */\nexport async function appendDurableContinuationContext(\n messages: EngineMessage[],\n reason: AgentLoopContinuationReason,\n threadId: string,\n): Promise<void> {\n await appendContinuationAndJournal(messages, reason, threadId);\n}\n\nasync function hasCompletedSideEffectToolCallInCurrentTurn(\n threadId: string | undefined,\n localEvents: readonly AgentChatEvent[] = [],\n): Promise<boolean> {\n try {\n const events = await readCurrentTurnEventsForResume(threadId, localEvents);\n if (events.length === 0) return false;\n return events.some(\n (event) =>\n event.type === \"tool_done\" &&\n event.completedSideEffect === true &&\n event.isError !== true,\n );\n } catch {\n return false;\n }\n}\n\nfunction internalContinuationReasonForAttempt(\n events: readonly AgentChatEvent[],\n): AgentLoopContinuationReason | undefined {\n const last = events.at(-1);\n if (last?.type !== \"auto_continue\") return undefined;\n if (\n last.reason === \"run_timeout\" ||\n last.reason === \"loop_limit\" ||\n last.reason === \"no_progress\" ||\n last.reason === \"stream_ended\" ||\n last.reason === \"gateway_timeout\" ||\n last.reason === \"network_interrupted\"\n ) {\n return last.reason;\n }\n return undefined;\n}\n\n/**\n * Cap on continuation iterations inside a single\n * `runAgentLoopDirectWithSoftTimeout` invocation. The host's hard function\n * timeout usually bounds this naturally — but a defensive cap prevents an\n * instant-error spiral from looping forever inside hosting environments with a\n * generous budget.\n *\n * 6 leaves room for: 1 normal completion + a few resume rounds for design\n * generation (prompt + 3 variants ≈ 4 LLM calls), with a small safety margin.\n */\nexport const MAX_RUN_LOOP_CONTINUATIONS = 6;\n\n/** Machine-readable code carried on the give-up terminal `error` event so the\n * client renders a loud \"stopped before finishing\" terminal instead of an\n * ambiguous silent stall. Deliberately NOT in the client's auto-recoverable\n * allow-list (`isAutoRecoverableError`) so it terminates the chain rather than\n * looping another POST that would hit the same wall. */\nexport const RUN_BUDGET_EXHAUSTED_ERROR_CODE = \"run_budget_exhausted\";\n\n/** User-facing terminal message when a hosted run is cut off mid-step and\n * exhausts its in-invocation continuation budget without finishing. Generic and\n * framework-level (not app-specific). Mirrors the `reliable-mutations` skill's\n * \"fail loud, retry as a single bulk action\" guidance so the user understands\n * the turn stopped before finishing without implying that earlier completed\n * tool calls did not persist. */\nexport const RUN_BUDGET_EXHAUSTED_MESSAGE =\n \"I ran out of time before finishing this step. \" +\n \"I stopped rather than keep retrying silently. \" +\n \"Check any completed tool cards above before retrying, ideally as one smaller follow-up.\";\n\n/**\n * Internal entry point used by the agent-chat plugin's run handler. Wraps\n * `runAgentLoop` with soft-timeout + resumable-error continuation recovery.\n *\n * The `softTimeoutMs` argument falls back to `resolveRunSoftTimeoutMs(...)` so\n * different hosting environments (Lambda, Vercel, Cloudflare, local dev) get\n * an appropriate inner budget. Setting it to <= 0 disables both layers — the\n * call goes straight to `runAgentLoop` with no wrapping.\n */\nexport async function runAgentLoopDirectWithSoftTimeout(\n opts: Parameters<typeof runAgentLoop>[0],\n softTimeoutMs?: number,\n timeoutOptions?: ResolveRunSoftTimeoutOptions,\n): Promise<Awaited<ReturnType<typeof runAgentLoop>>> {\n const finalResponseGuardRequestText =\n opts.finalResponseGuardRequestText ??\n resolveFinalResponseGuardRequestText(opts.messages);\n const stableOpts = { ...opts, finalResponseGuardRequestText };\n const timeoutMs = resolveRunSoftTimeoutMs(softTimeoutMs, timeoutOptions);\n if (timeoutMs <= 0) return runAgentLoop(stableOpts);\n\n const upstreamSignal = opts.signal;\n const usage: Awaited<ReturnType<typeof runAgentLoop>> = {\n inputTokens: 0,\n outputTokens: 0,\n cacheReadTokens: 0,\n cacheWriteTokens: 0,\n model: opts.model,\n };\n\n const addUsage = (next: Awaited<ReturnType<typeof runAgentLoop>>) => {\n usage.inputTokens += next.inputTokens;\n usage.outputTokens += next.outputTokens;\n usage.cacheReadTokens += next.cacheReadTokens;\n usage.cacheWriteTokens += next.cacheWriteTokens;\n usage.model = next.model;\n // Without these, a retry that never got a usage report merges its zeros\n // over an earlier attempt's real numbers, and telemetry reports an\n // unmeasured run as a measured empty one.\n if (next.usageReported) usage.usageReported = true;\n usage.firstEngineEventAtMs ??= next.firstEngineEventAtMs;\n };\n\n const localTurnEvents: AgentChatEvent[] = [];\n let attempts = 0;\n // Every current hosted caller of this function (A2A/MCP delegated turns)\n // runs inside ONE serverless invocation whose real platform hard-kill is\n // what `timeoutMs` was sized to survive ONCE — reusing that same fresh\n // window for every one of up to `MAX_RUN_LOOP_CONTINUATIONS` in-process\n // rounds ignores the wall-clock the earlier rounds already spent, so a 2nd+\n // round can gamble past the host's real limit and die with a silent\n // mid-stream kill instead of a clean give-up. Budget subsequent rounds\n // against cumulative elapsed time since this call started (mirrors\n // `resolveSelfChainContinuationBudget`'s \"remaining = ceiling - elapsed\"\n // pattern, already proven for the analogous foreground self-chain case).\n // The first round is unaffected — it always gets the full `timeoutMs`.\n const loopEntryAt = Date.now();\n // Tracks whether the most recent attempt ended by scheduling another\n // continuation (soft-timeout or resumable error → `continue`) rather than\n // returning a finished turn. When the loop then exits because the budget is\n // exhausted (NOT because the user aborted and NOT because the turn finished),\n // this is the silent give-up case: emit a loud terminal so the user sees an\n // unambiguous \"stopped before finishing\" instead of a bare done/\"…\".\n let lastAttemptWasUnfinishedContinuation = false;\n while (!upstreamSignal.aborted && attempts < MAX_RUN_LOOP_CONTINUATIONS) {\n const roundTimeoutMs =\n attempts === 0 ? timeoutMs : timeoutMs - (Date.now() - loopEntryAt);\n if (\n attempts > 0 &&\n roundTimeoutMs < SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS\n ) {\n // Not enough wall-clock left in this invocation to safely start\n // another round — stop here (lastAttemptWasUnfinishedContinuation is\n // already true from the prior round) so the loop exits through the\n // existing RUN_BUDGET_EXHAUSTED_MESSAGE path below instead of risking\n // a raw platform kill mid-stream.\n break;\n }\n attempts++;\n lastAttemptWasUnfinishedContinuation = false;\n const controller = new AbortController();\n const abortFromUpstream = () => controller.abort();\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n upstreamSignal.addEventListener(\"abort\", abortFromUpstream, {\n once: true,\n });\n }\n\n let softTimedOut = false;\n const timer = setTimeout(() => {\n if (controller.signal.aborted) return;\n softTimedOut = true;\n controller.abort();\n }, roundTimeoutMs);\n\n const attemptStartIndex = localTurnEvents.length;\n const send = (event: AgentChatEvent) => {\n localTurnEvents.push(event);\n opts.send(event);\n };\n\n try {\n const nextUsage = await runAgentLoop({\n ...stableOpts,\n send,\n signal: controller.signal,\n });\n addUsage(nextUsage);\n const attemptEvents = localTurnEvents.slice(attemptStartIndex);\n const internalContinuationReason =\n internalContinuationReasonForAttempt(attemptEvents);\n if (internalContinuationReason && !upstreamSignal.aborted) {\n lastAttemptWasUnfinishedContinuation = true;\n const continuationEvents = [...localTurnEvents];\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n continuationEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n await appendContinuationAndJournal(\n opts.messages,\n internalContinuationReason,\n opts.threadId,\n continuationEvents,\n );\n continue;\n }\n if (softTimedOut && !upstreamSignal.aborted) {\n lastAttemptWasUnfinishedContinuation = true;\n await appendContinuationAndJournal(\n opts.messages,\n \"run_timeout\",\n opts.threadId,\n localTurnEvents,\n );\n continue;\n }\n return usage;\n } catch (err) {\n if (softTimedOut && !upstreamSignal.aborted) {\n // Clear partial text the client received before the abort so the\n // resumed model doesn't re-emit it and produce duplicated output.\n lastAttemptWasUnfinishedContinuation = true;\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n localTurnEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n await appendContinuationAndJournal(\n opts.messages,\n \"run_timeout\",\n opts.threadId,\n localTurnEvents,\n );\n continue;\n }\n // Resumable transport / gateway interruptions: the LLM call was cut off\n // mid-stream (gateway 45s timeout, socket hang up, function-level\n // timeout that didn't trip our soft timer first). Treat it the same way\n // as a soft timeout — append a \"continue from where you left off\" nudge\n // and let the loop run another LLM call. The conversation prefix up to\n // the cut-off is preserved in opts.messages, and Anthropic's prompt\n // cache makes the resume call much faster.\n //\n // Emit 'clear' so any partial streamed text is discarded on the client\n // before the model resumes. Without this the model restarts its sentence\n // from scratch and the fold produces duplicated text in one message\n // (the partial text was already sent to the client but never entered\n // the in-memory messages array, so the next attempt re-emits it).\n if (!upstreamSignal.aborted && isResumableEngineError(err)) {\n lastAttemptWasUnfinishedContinuation = true;\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n localTurnEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n await appendContinuationAndJournal(\n opts.messages,\n continuationReasonForResumableError(err),\n opts.threadId,\n localTurnEvents,\n );\n continue;\n }\n throw err;\n } finally {\n clearTimeout(timer);\n upstreamSignal.removeEventListener(\"abort\", abortFromUpstream);\n }\n }\n\n // The loop exited without a clean return. If the user aborted, that's a Stop —\n // stay silent. Otherwise we only get here by exhausting\n // MAX_RUN_LOOP_CONTINUATIONS while the last attempt was still trying to\n // continue (soft-timeout / resumable error). That is the genuinely-silent\n // give-up the run-manager would otherwise report as a clean `done`: emit a\n // loud, non-auto-continuing terminal so the user knows the turn stopped\n // before finishing and nothing was partially saved by the run itself.\n if (!upstreamSignal.aborted && lastAttemptWasUnfinishedContinuation) {\n // Discard any partial text already streamed for the unfinished attempt so\n // the terminal message stands alone instead of trailing a half sentence.\n // Preserve completed tool cards: they are the user's only durable proof\n // that a side effect landed before the final assistant note timed out.\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n localTurnEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n opts.send({\n type: \"error\",\n error: RUN_BUDGET_EXHAUSTED_MESSAGE,\n errorCode: RUN_BUDGET_EXHAUSTED_ERROR_CODE,\n recoverable: true,\n });\n }\n\n return usage;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"run-loop-with-resume.js","sourceRoot":"","sources":["../../src/agent/run-loop-with-resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,sBAAsB,EACtB,iCAAiC,EACjC,mCAAmC,EACnC,2CAA2C,EAC3C,oCAAoC,EACpC,qCAAqC,GAGtC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAGhC,KAAK,UAAU,8BAA8B,CAC3C,QAA4B,EAC5B,WAAW,GAA8B,EAAE;IAE3C,IAAI,eAAe,GAAqB,EAAE,CAAC;IAC3C,IAAI,CAAC;QACH,eAAe,GAAG,QAAQ;YACxB,CAAC,CAAC,MAAM,6BAA6B,CAAC,QAAQ,CAAC;YAC/C,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;IAAC,MAAM,CAAC;QACP,eAAe,GAAG,EAAE,CAAC;IACvB,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,eAAe,CAAC;IACrD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,G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ACH,CAAC;IAED,+EAA+E;IAC/E,wDAAwD;IACxD,wEAAwE;IACxE,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,sEAAsE;IACtE,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,oCAAoC,EAAE,CAAC;QACpE,0EAA0E;QAC1E,yEAAyE;QACzE,wEAAwE;QACxE,uEAAuE;QACvE,IACE,CAAC,CAAC,MAAM,2CAA2C,CACjD,IAAI,CAAC,QAAQ,EACb,eAAe,CAChB,CAAC,EACF,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,4BAA4B;YACnC,SAAS,EAAE,+BAA+B;YAC1C,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QACH,kBAAkB,CAAC;YACjB,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,+BAA+B;YACrC,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,4BAA4B;SACtC,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;QAClC,kBAAkB,CAAC;YACjB,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,wBAAwB;SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * Wraps `runAgentLoop` with two layered recovery mechanisms so a single hosted\n * invocation can survive interruptions without showing the user a dead chat:\n *\n * 1. **Soft timeout** — an inner timer that aborts the LLM call before the\n * hosting function's hard limit (Lambda 75s, Vercel 60s, etc.) so we have a\n * chance to gracefully wind down and append a continuation nudge. Without\n * this the function gets killed mid-stream and the user sees a frozen\n * spinner.\n *\n * 2. **Resumable-error continuation** — when the LLM call errors with a\n * transport- or gateway-level interruption (Builder gateway 45s timeout,\n * socket hang up, ECONNRESET, upstream 5xx that survived engine retries),\n * we save the conversation prefix, append a \"continue from where you left\n * off\" message, and run another LLM call. Anthropic's prompt cache makes\n * the resume call dramatically faster than the cold first attempt, and the\n * agent gets explicit context that it was cut off so it doesn't re-do\n * completed work.\n *\n * Both paths route through `appendAgentLoopContinuation` so the agent sees a\n * uniform \"continue\" instruction regardless of which recovery fired.\n */\n\nimport type { EngineMessage } from \"./engine/types.js\";\nimport {\n runAgentLoop,\n appendAgentLoopContinuation,\n isResumableEngineError,\n isTransientProviderRateLimitError,\n continuationReasonForResumableError,\n lastUnfinishedPreparingActionToolFromEvents,\n resolveFinalResponseGuardRequestText,\n SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS,\n type AgentLoopContinuationReason,\n type AgentLoopOutcome,\n} from \"./production-agent.js\";\nimport { resolveRunSoftTimeoutMs } from \"./run-manager.js\";\nimport type { ResolveRunSoftTimeoutOptions } from \"./run-manager.js\";\nimport { getCurrentTurnEventsForThread } from \"./run-store.js\";\nimport {\n classifyToolCallJournal,\n buildResumeJournalNote,\n} from \"./tool-call-journal.js\";\nimport type { AgentChatEvent } from \"./types.js\";\n\nasync function readCurrentTurnEventsForResume(\n threadId: string | undefined,\n localEvents: readonly AgentChatEvent[] = [],\n): Promise<AgentChatEvent[]> {\n let persistedEvents: AgentChatEvent[] = [];\n try {\n persistedEvents = threadId\n ? await getCurrentTurnEventsForThread(threadId)\n : [];\n } catch {\n persistedEvents = [];\n }\n if (localEvents.length === 0) return persistedEvents;\n const seen = new Set(persistedEvents.map((event) => JSON.stringify(event)));\n return [\n ...persistedEvents,\n ...localEvents.filter((event) => !seen.has(JSON.stringify(event))),\n ];\n}\n\nfunction actionPreparationContinuationOptions(\n events: readonly AgentChatEvent[],\n): { actionPreparationTool?: string } {\n const actionPreparationTool =\n lastUnfinishedPreparingActionToolFromEvents(events);\n return actionPreparationTool ? { actionPreparationTool } : {};\n}\n\n/**\n * Derive the per-turn tool-call journal from the durable run-event ledger and,\n * when there is anything to report, append a STRUCTURED note to the message\n * prefix so the resumed model:\n * - does NOT re-execute tool calls that already completed (avoiding duplicate\n * side effects like re-sending an email or re-creating a ticket), and\n * - is explicitly told about any tool call that started but whose outcome was\n * never recorded (\"interrupted, unknown outcome\") so it can decide.\n *\n * This is additive to the existing \"continue from where you left off\" nudge —\n * it is appended right after it. When the journal is empty (no completed or\n * interrupted tool calls — e.g. a turn with no tool activity, or a clean\n * continuation), nothing extra is appended and resume behavior is byte-for-byte\n * what it was before. Best-effort: any ledger read/parse failure is swallowed so\n * a journal hiccup can never block a recovery that would otherwise succeed.\n *\n * This prompt-level journal is paired with tool-layer enforcement in\n * production-agent.ts/runToolCall, which refuses to re-execute a journaled-\n * complete write tool (returning the journaled result instead). See\n * `tool-call-journal.ts` (`findCompletedJournalEntry`) for the keying used.\n */\nfunction appendToolCallJournalNote(\n messages: EngineMessage[],\n events: readonly AgentChatEvent[],\n): void {\n try {\n if (events.length === 0) return;\n const journal = classifyToolCallJournal(events);\n const note = buildResumeJournalNote(journal);\n if (!note) return;\n messages.push({\n role: \"user\",\n content: [{ type: \"text\", text: note }],\n });\n } catch {\n // The journal is a hardening layer, never a gate. A failed ledger read or\n // parse must not break the resume that the continuation nudge already set\n // up — the model still continues, just without the structured journal.\n }\n}\n\nasync function appendContinuationAndJournal(\n messages: EngineMessage[],\n reason: AgentLoopContinuationReason | \"rate_limited\",\n threadId: string | undefined,\n localEvents: readonly AgentChatEvent[] = [],\n): Promise<void> {\n const events = await readCurrentTurnEventsForResume(threadId, localEvents);\n appendAgentLoopContinuation(\n messages,\n reason,\n actionPreparationContinuationOptions(events),\n );\n appendToolCallJournalNote(messages, events);\n}\n\n/**\n * Rebuild the same safe continuation context for a logical turn that resumes\n * in a fresh hosted invocation.\n */\nexport async function appendDurableContinuationContext(\n messages: EngineMessage[],\n reason: AgentLoopContinuationReason,\n threadId: string,\n): Promise<void> {\n await appendContinuationAndJournal(messages, reason, threadId);\n}\n\nasync function hasCompletedSideEffectToolCallInCurrentTurn(\n threadId: string | undefined,\n localEvents: readonly AgentChatEvent[] = [],\n): Promise<boolean> {\n try {\n const events = await readCurrentTurnEventsForResume(threadId, localEvents);\n if (events.length === 0) return false;\n return events.some(\n (event) =>\n event.type === \"tool_done\" &&\n event.completedSideEffect === true &&\n event.isError !== true,\n );\n } catch {\n return false;\n }\n}\n\nfunction internalContinuationReasonForAttempt(\n events: readonly AgentChatEvent[],\n): AgentLoopContinuationReason | undefined {\n const last = events.at(-1);\n if (last?.type !== \"auto_continue\") return undefined;\n if (\n last.reason === \"run_timeout\" ||\n last.reason === \"loop_limit\" ||\n last.reason === \"no_progress\" ||\n last.reason === \"stream_ended\" ||\n last.reason === \"gateway_timeout\" ||\n last.reason === \"network_interrupted\"\n ) {\n return last.reason;\n }\n return undefined;\n}\n\n/**\n * Cap on continuation iterations inside a single\n * `runAgentLoopDirectWithSoftTimeout` invocation. The host's hard function\n * timeout usually bounds this naturally — but a defensive cap prevents an\n * instant-error spiral from looping forever inside hosting environments with a\n * generous budget.\n *\n * 6 leaves room for: 1 normal completion + a few resume rounds for design\n * generation (prompt + 3 variants ≈ 4 LLM calls), with a small safety margin.\n */\nexport const MAX_RUN_LOOP_CONTINUATIONS = 6;\n\n/**\n * A delegated turn that is proven to be running inside a durable background\n * function has the same 15-minute host budget as main chat, but this wrapper\n * historically kept the foreground-sized six-continuation cap. A healthy\n * child A2A call can consume several minutes and the receiving model may then\n * need more than six recovery/model-stream boundaries to finish its own tool\n * work. Keep a hard cap, but give the proven background path the same bounded\n * continuation allowance as the durable main-chat runner. The cumulative\n * soft-timeout below still prevents these rounds from exceeding the one real\n * background-function wall-clock budget.\n */\nexport const MAX_BACKGROUND_RUN_LOOP_CONTINUATIONS = 20;\n\n/**\n * The engine already performs its own short provider retries. After those are\n * exhausted, a proven durable background A2A/MCP run gets one cooled-down\n * continuation for a transient 429/529. One extra round is enough to bridge a\n * short provider bucket without multiplying a sustained rate limit into a\n * request storm across the larger background continuation allowance.\n */\nexport const MAX_BACKGROUND_RATE_LIMIT_CONTINUATIONS = 1;\nexport const BACKGROUND_RATE_LIMIT_CONTINUATION_DELAY_MS = 20_000;\n\nfunction waitForBackgroundRateLimitCooldown(\n signal: AbortSignal,\n): Promise<void> {\n if (signal.aborted) return Promise.resolve();\n return new Promise((resolve) => {\n const finish = () => {\n clearTimeout(timer);\n signal.removeEventListener(\"abort\", finish);\n resolve();\n };\n const timer = setTimeout(\n finish,\n BACKGROUND_RATE_LIMIT_CONTINUATION_DELAY_MS,\n );\n signal.addEventListener(\"abort\", finish, { once: true });\n });\n}\n\n/** Machine-readable code carried on the give-up terminal `error` event so the\n * client renders a loud \"stopped before finishing\" terminal instead of an\n * ambiguous silent stall. Deliberately NOT in the client's auto-recoverable\n * allow-list (`isAutoRecoverableError`) so it terminates the chain rather than\n * looping another POST that would hit the same wall. */\nexport const RUN_BUDGET_EXHAUSTED_ERROR_CODE = \"run_budget_exhausted\";\n\n/** User-facing terminal message when a hosted run is cut off mid-step and\n * exhausts its in-invocation continuation budget without finishing. Generic and\n * framework-level (not app-specific). Mirrors the `reliable-mutations` skill's\n * \"fail loud, retry as a single bulk action\" guidance so the user understands\n * the turn stopped before finishing without implying that earlier completed\n * tool calls did not persist. */\nexport const RUN_BUDGET_EXHAUSTED_MESSAGE =\n \"I ran out of time before finishing this step. \" +\n \"I stopped rather than keep retrying silently. \" +\n \"Check any completed tool cards above before retrying, ideally as one smaller follow-up.\";\n\n/**\n * Internal entry point used by the agent-chat plugin's run handler. Wraps\n * `runAgentLoop` with soft-timeout + resumable-error continuation recovery.\n *\n * The `softTimeoutMs` argument falls back to `resolveRunSoftTimeoutMs(...)` so\n * different hosting environments (Lambda, Vercel, Cloudflare, local dev) get\n * an appropriate inner budget. Setting it to <= 0 disables both layers — the\n * call goes straight to `runAgentLoop` with no wrapping.\n */\nexport async function runAgentLoopDirectWithSoftTimeout(\n opts: Parameters<typeof runAgentLoop>[0],\n softTimeoutMs?: number,\n timeoutOptions?: ResolveRunSoftTimeoutOptions,\n): Promise<Awaited<ReturnType<typeof runAgentLoop>>> {\n const finalResponseGuardRequestText =\n opts.finalResponseGuardRequestText ??\n resolveFinalResponseGuardRequestText(opts.messages);\n const stableOpts = { ...opts, finalResponseGuardRequestText };\n const timeoutMs = resolveRunSoftTimeoutMs(softTimeoutMs, timeoutOptions);\n let finalOutcomeReported = false;\n const reportFinalOutcome = (outcome: AgentLoopOutcome) => {\n if (finalOutcomeReported) return;\n finalOutcomeReported = true;\n try {\n opts.onOutcome?.(outcome);\n } catch {\n // Outcome observers cannot alter recovery or completion.\n }\n };\n\n // Disabling continuation recovery must not disable terminal classification.\n // Keep the same outcome boundary around a direct loop so A2A/MCP callers\n // never infer success from a rejected or canceled run.\n if (timeoutMs <= 0) {\n const directEvents: AgentChatEvent[] = [];\n let directOutcome: AgentLoopOutcome | undefined;\n try {\n const result = await runAgentLoop({\n ...stableOpts,\n send: (event) => {\n directEvents.push(event);\n stableOpts.send(event);\n },\n onOutcome: (outcome) => {\n directOutcome = outcome;\n },\n });\n const unfinishedReason =\n internalContinuationReasonForAttempt(directEvents);\n if (opts.signal.aborted) {\n reportFinalOutcome({\n state: \"canceled\",\n message: \"Agent run was aborted.\",\n });\n } else if (unfinishedReason) {\n reportFinalOutcome({\n state: \"failed\",\n code: unfinishedReason,\n retryable: false,\n message: `Agent stopped before finishing (${unfinishedReason}).`,\n });\n } else {\n reportFinalOutcome(directOutcome ?? { state: \"completed\" });\n }\n return result;\n } catch (err) {\n const candidate = err as { errorCode?: unknown; message?: unknown };\n reportFinalOutcome(\n opts.signal.aborted\n ? { state: \"canceled\", message: \"Agent run was aborted.\" }\n : {\n state: \"failed\",\n code:\n typeof candidate?.errorCode === \"string\" && candidate.errorCode\n ? candidate.errorCode\n : \"internal_error\",\n retryable: isResumableEngineError(err),\n message:\n typeof candidate?.message === \"string\"\n ? candidate.message\n : String(err),\n },\n );\n throw err;\n }\n }\n\n const upstreamSignal = opts.signal;\n const usage: Awaited<ReturnType<typeof runAgentLoop>> = {\n inputTokens: 0,\n outputTokens: 0,\n cacheReadTokens: 0,\n cacheWriteTokens: 0,\n model: opts.model,\n };\n\n const addUsage = (next: Awaited<ReturnType<typeof runAgentLoop>>) => {\n usage.inputTokens += next.inputTokens;\n usage.outputTokens += next.outputTokens;\n usage.cacheReadTokens += next.cacheReadTokens;\n usage.cacheWriteTokens += next.cacheWriteTokens;\n usage.model = next.model;\n // Without these, a retry that never got a usage report merges its zeros\n // over an earlier attempt's real numbers, and telemetry reports an\n // unmeasured run as a measured empty one.\n if (next.usageReported) usage.usageReported = true;\n usage.firstEngineEventAtMs ??= next.firstEngineEventAtMs;\n };\n\n const localTurnEvents: AgentChatEvent[] = [];\n let attempts = 0;\n // Every current hosted caller of this function (A2A/MCP delegated turns)\n // runs inside ONE serverless invocation whose real platform hard-kill is\n // what `timeoutMs` was sized to survive ONCE — reusing that same fresh\n // window for every one of up to `MAX_RUN_LOOP_CONTINUATIONS` in-process\n // rounds ignores the wall-clock the earlier rounds already spent, so a 2nd+\n // round can gamble past the host's real limit and die with a silent\n // mid-stream kill instead of a clean give-up. Budget subsequent rounds\n // against cumulative elapsed time since this call started (mirrors\n // `resolveSelfChainContinuationBudget`'s \"remaining = ceiling - elapsed\"\n // pattern, already proven for the analogous foreground self-chain case).\n // The first round is unaffected — it always gets the full `timeoutMs`.\n const loopEntryAt = Date.now();\n const maxRunLoopContinuations =\n timeoutOptions?.backgroundFunction === true\n ? MAX_BACKGROUND_RUN_LOOP_CONTINUATIONS\n : MAX_RUN_LOOP_CONTINUATIONS;\n let backgroundRateLimitContinuations = 0;\n // Tracks whether the most recent attempt ended by scheduling another\n // continuation (soft-timeout or resumable error → `continue`) rather than\n // returning a finished turn. When the loop then exits because the budget is\n // exhausted (NOT because the user aborted and NOT because the turn finished),\n // this is the silent give-up case: emit a loud terminal so the user sees an\n // unambiguous \"stopped before finishing\" instead of a bare done/\"…\".\n let lastAttemptWasUnfinishedContinuation = false;\n while (!upstreamSignal.aborted && attempts < maxRunLoopContinuations) {\n const roundTimeoutMs =\n attempts === 0 ? timeoutMs : timeoutMs - (Date.now() - loopEntryAt);\n if (\n attempts > 0 &&\n roundTimeoutMs < SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS\n ) {\n // Not enough wall-clock left in this invocation to safely start\n // another round — stop here (lastAttemptWasUnfinishedContinuation is\n // already true from the prior round) so the loop exits through the\n // existing RUN_BUDGET_EXHAUSTED_MESSAGE path below instead of risking\n // a raw platform kill mid-stream.\n break;\n }\n attempts++;\n lastAttemptWasUnfinishedContinuation = false;\n const controller = new AbortController();\n const abortFromUpstream = () => controller.abort();\n if (upstreamSignal.aborted) {\n controller.abort();\n } else {\n upstreamSignal.addEventListener(\"abort\", abortFromUpstream, {\n once: true,\n });\n }\n\n let softTimedOut = false;\n const timer = setTimeout(() => {\n if (controller.signal.aborted) return;\n softTimedOut = true;\n controller.abort();\n }, roundTimeoutMs);\n\n const attemptStartIndex = localTurnEvents.length;\n const send = (event: AgentChatEvent) => {\n localTurnEvents.push(event);\n opts.send(event);\n };\n\n try {\n let attemptOutcome: AgentLoopOutcome | undefined;\n const nextUsage = await runAgentLoop({\n ...stableOpts,\n send,\n signal: controller.signal,\n onOutcome: (outcome) => {\n attemptOutcome = outcome;\n },\n });\n addUsage(nextUsage);\n const attemptEvents = localTurnEvents.slice(attemptStartIndex);\n const internalContinuationReason =\n internalContinuationReasonForAttempt(attemptEvents);\n if (internalContinuationReason && !upstreamSignal.aborted) {\n lastAttemptWasUnfinishedContinuation = true;\n const continuationEvents = [...localTurnEvents];\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n continuationEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n await appendContinuationAndJournal(\n opts.messages,\n internalContinuationReason,\n opts.threadId,\n continuationEvents,\n );\n continue;\n }\n if (softTimedOut && !upstreamSignal.aborted) {\n lastAttemptWasUnfinishedContinuation = true;\n await appendContinuationAndJournal(\n opts.messages,\n \"run_timeout\",\n opts.threadId,\n localTurnEvents,\n );\n continue;\n }\n reportFinalOutcome(\n upstreamSignal.aborted\n ? { state: \"canceled\", message: \"Agent run was aborted.\" }\n : (attemptOutcome ?? { state: \"completed\" }),\n );\n return usage;\n } catch (err) {\n if (softTimedOut && !upstreamSignal.aborted) {\n // Clear partial text the client received before the abort so the\n // resumed model doesn't re-emit it and produce duplicated output.\n lastAttemptWasUnfinishedContinuation = true;\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n localTurnEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n await appendContinuationAndJournal(\n opts.messages,\n \"run_timeout\",\n opts.threadId,\n localTurnEvents,\n );\n continue;\n }\n const transientRateLimit = isTransientProviderRateLimitError(err);\n const rateLimitRetryFitsBudget =\n timeoutOptions?.backgroundFunction === true &&\n backgroundRateLimitContinuations <\n MAX_BACKGROUND_RATE_LIMIT_CONTINUATIONS &&\n timeoutMs -\n (Date.now() - loopEntryAt) -\n BACKGROUND_RATE_LIMIT_CONTINUATION_DELAY_MS >=\n SELF_CHAIN_MIN_CONTINUATION_BUDGET_MS;\n if (\n !upstreamSignal.aborted &&\n transientRateLimit &&\n rateLimitRetryFitsBudget\n ) {\n lastAttemptWasUnfinishedContinuation = true;\n backgroundRateLimitContinuations++;\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n localTurnEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n await appendContinuationAndJournal(\n opts.messages,\n \"rate_limited\",\n opts.threadId,\n localTurnEvents,\n );\n await waitForBackgroundRateLimitCooldown(upstreamSignal);\n continue;\n }\n // Resumable transport / gateway interruptions: the LLM call was cut off\n // mid-stream (gateway 45s timeout, socket hang up, function-level\n // timeout that didn't trip our soft timer first). Treat it the same way\n // as a soft timeout — append a \"continue from where you left off\" nudge\n // and let the loop run another LLM call. The conversation prefix up to\n // the cut-off is preserved in opts.messages, and Anthropic's prompt\n // cache makes the resume call much faster.\n //\n // Emit 'clear' so any partial streamed text is discarded on the client\n // before the model resumes. Without this the model restarts its sentence\n // from scratch and the fold produces duplicated text in one message\n // (the partial text was already sent to the client but never entered\n // the in-memory messages array, so the next attempt re-emits it).\n if (!upstreamSignal.aborted && isResumableEngineError(err)) {\n lastAttemptWasUnfinishedContinuation = true;\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n localTurnEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n await appendContinuationAndJournal(\n opts.messages,\n continuationReasonForResumableError(err),\n opts.threadId,\n localTurnEvents,\n );\n continue;\n }\n if (upstreamSignal.aborted) {\n reportFinalOutcome({\n state: \"canceled\",\n message: \"Agent run was aborted.\",\n });\n throw err;\n }\n const candidate = err as { errorCode?: unknown; message?: unknown };\n reportFinalOutcome({\n state: \"failed\",\n code:\n typeof candidate?.errorCode === \"string\" && candidate.errorCode\n ? candidate.errorCode\n : \"internal_error\",\n retryable: false,\n message:\n typeof candidate?.message === \"string\"\n ? candidate.message\n : String(err),\n });\n throw err;\n } finally {\n clearTimeout(timer);\n upstreamSignal.removeEventListener(\"abort\", abortFromUpstream);\n }\n }\n\n // The loop exited without a clean return. If the user aborted, that's a Stop —\n // stay silent. Otherwise we only get here by exhausting\n // MAX_RUN_LOOP_CONTINUATIONS while the last attempt was still trying to\n // continue (soft-timeout / resumable error). That is the genuinely-silent\n // give-up the run-manager would otherwise report as a clean `done`: emit a\n // loud, non-auto-continuing terminal so the user knows the turn stopped\n // before finishing and nothing was partially saved by the run itself.\n if (!upstreamSignal.aborted && lastAttemptWasUnfinishedContinuation) {\n // Discard any partial text already streamed for the unfinished attempt so\n // the terminal message stands alone instead of trailing a half sentence.\n // Preserve completed tool cards: they are the user's only durable proof\n // that a side effect landed before the final assistant note timed out.\n if (\n !(await hasCompletedSideEffectToolCallInCurrentTurn(\n opts.threadId,\n localTurnEvents,\n ))\n ) {\n opts.send({ type: \"clear\" });\n }\n opts.send({\n type: \"error\",\n error: RUN_BUDGET_EXHAUSTED_MESSAGE,\n errorCode: RUN_BUDGET_EXHAUSTED_ERROR_CODE,\n recoverable: true,\n });\n reportFinalOutcome({\n state: \"failed\",\n code: RUN_BUDGET_EXHAUSTED_ERROR_CODE,\n retryable: false,\n message: RUN_BUDGET_EXHAUSTED_MESSAGE,\n });\n } else if (upstreamSignal.aborted) {\n reportFinalOutcome({\n state: \"canceled\",\n message: \"Agent run was aborted.\",\n });\n }\n\n return usage;\n}\n"]}
|
|
@@ -85,15 +85,6 @@ export declare const BACKGROUND_SOFT_TIMEOUT_CEILING_MS: number;
|
|
|
85
85
|
* off to a chained background continuation.
|
|
86
86
|
*/
|
|
87
87
|
export declare const DEFAULT_BACKGROUND_RUN_SOFT_TIMEOUT_MS: number;
|
|
88
|
-
/**
|
|
89
|
-
* Default no-progress window for a run executing inside a proven durable
|
|
90
|
-
* background function. Keep this below the 13-minute soft timeout so a truly
|
|
91
|
-
* wedged background turn can still checkpoint, persist, and continue before
|
|
92
|
-
* the function budget expires, but far above the foreground 150s window so
|
|
93
|
-
* large Design/Plan/Assets generations are not chopped up while the model is
|
|
94
|
-
* legitimately planning a big tool payload.
|
|
95
|
-
*/
|
|
96
|
-
export declare const DEFAULT_BACKGROUND_NO_PROGRESS_TIMEOUT_MS: number;
|
|
97
88
|
/**
|
|
98
89
|
* AUTHORITATIVE no-progress backstop for a run, enforced by the run manager
|
|
99
90
|
* itself (timer-driven, independent of any layer below).
|
|
@@ -122,6 +113,15 @@ export declare const DEFAULT_BACKGROUND_NO_PROGRESS_TIMEOUT_MS: number;
|
|
|
122
113
|
* runs); local dev stays unbounded.
|
|
123
114
|
*/
|
|
124
115
|
export declare const RUN_NO_PROGRESS_HARD_TIMEOUT_MS = 150000;
|
|
116
|
+
/**
|
|
117
|
+
* Default no-progress window for a run executing inside a proven durable
|
|
118
|
+
* background function. A background worker that is heartbeating but has no
|
|
119
|
+
* real progress and no tool/A2A work in flight is still wedged; letting that
|
|
120
|
+
* state outlive the client's follow budget only turns a recoverable stall into
|
|
121
|
+
* a terminal timeout. In-flight work suspends this backstop, so use the same
|
|
122
|
+
* server-owned 150s bound as the long foreground regime.
|
|
123
|
+
*/
|
|
124
|
+
export declare const DEFAULT_BACKGROUND_NO_PROGRESS_TIMEOUT_MS = 150000;
|
|
125
125
|
/**
|
|
126
126
|
* Largest per-tool timeout that can actually fire inside this run's chunk
|
|
127
127
|
* budget. `0` means "no run-imposed ceiling" (local dev / unbounded runs), in
|
|
@@ -181,7 +181,14 @@ export declare const SQL_SUBSCRIPTION_IDLE_POLL_MS = 500;
|
|
|
181
181
|
export declare const SQL_SUBSCRIPTION_ACTIVE_GRACE_MS = 2000;
|
|
182
182
|
/** Keep terminal/status probes at the historical cadence to bound DB work. */
|
|
183
183
|
export declare const SQL_SUBSCRIPTION_STATUS_POLL_MS = 500;
|
|
184
|
+
/** Initial retry delay after a transient cross-isolate SQL polling failure. */
|
|
185
|
+
export declare const SQL_SUBSCRIPTION_RETRY_BASE_MS = 250;
|
|
186
|
+
/** Bound consecutive SQL polling failures so a dead subscription fails loud. */
|
|
187
|
+
export declare const SQL_SUBSCRIPTION_MAX_CONSECUTIVE_FAILURES = 4;
|
|
188
|
+
/** Cap retry delay even if the failure bound changes independently. */
|
|
189
|
+
export declare const SQL_SUBSCRIPTION_RETRY_MAX_MS = 2000;
|
|
184
190
|
export declare function resolveSqlSubscriptionPollMs(now: number, activePollUntil: number): number;
|
|
191
|
+
export declare function resolveSqlSubscriptionRetryMs(consecutiveFailures: number): number;
|
|
185
192
|
export interface StartRunOptions {
|
|
186
193
|
/** Keep a request-scoped serverless invocation alive for this run. */
|
|
187
194
|
waitUntil?: (promise: Promise<unknown>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-manager.d.ts","sourceRoot":"","sources":["../../src/agent/run-manager.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,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