@agent-native/core 0.131.5 → 0.131.6
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 +63 -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 +14 -10
- 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/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/types.ts +4 -0
- package/corpus/core/src/action.ts +3 -0
- package/corpus/core/src/agent/engine/registry.ts +45 -5
- 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/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 +290 -9
- package/corpus/core/src/scripts/describe-workspace-apps.ts +2 -2
- package/corpus/core/src/secrets/crypto.ts +126 -34
- package/corpus/core/src/secrets/storage.ts +61 -25
- package/corpus/core/src/server/agent-capabilities.ts +1 -1
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +111 -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 +14 -7
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +14 -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 +14 -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 +6 -4
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +4 -3
- 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/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/slides/.agents/skills/analytics-data-for-decks/SKILL.md +8 -12
- package/corpus/templates/slides/AGENTS.md +4 -4
- 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-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/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/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +34 -7
- 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/collab/struct-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/file-upload/actions/upload-image.d.ts +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/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -1
- package/dist/notifications/routes.d.ts +6 -6
- 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 +233 -10
- 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 +31 -21
- package/dist/secrets/crypto.d.ts.map +1 -1
- package/dist/secrets/crypto.js +108 -33
- package/dist/secrets/crypto.js.map +1 -1
- package/dist/secrets/storage.d.ts +3 -5
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +40 -25
- 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 +92 -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 +14 -7
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +14 -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 +14 -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 +14 -10
- 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/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 +2 -2
- package/src/a2a/client.ts +449 -66
- package/src/a2a/correlation.ts +31 -0
- package/src/a2a/types.ts +4 -0
- package/src/action.ts +3 -0
- package/src/agent/engine/registry.ts +45 -5
- 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/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 +290 -9
- package/src/scripts/describe-workspace-apps.ts +2 -2
- package/src/secrets/crypto.ts +126 -34
- package/src/secrets/storage.ts +61 -25
- package/src/server/agent-capabilities.ts +1 -1
- package/src/server/agent-chat/action-filters-a2a.ts +111 -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 +14 -7
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +14 -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 +14 -7
- package/src/vite/client.ts +1 -0
|
@@ -76,6 +76,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
76
76
|
}>>;
|
|
77
77
|
}, z.core.$strip>>, {
|
|
78
78
|
id?: undefined;
|
|
79
|
+
message?: undefined;
|
|
80
|
+
provider?: undefined;
|
|
79
81
|
deleted?: undefined;
|
|
80
82
|
providers: {
|
|
81
83
|
id: string;
|
|
@@ -87,46 +89,44 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
87
89
|
updatedAt: number;
|
|
88
90
|
}[];
|
|
89
91
|
count: number;
|
|
90
|
-
provider?: undefined;
|
|
91
92
|
found?: undefined;
|
|
92
93
|
registered?: undefined;
|
|
93
94
|
label?: undefined;
|
|
94
|
-
message?: undefined;
|
|
95
95
|
} | {
|
|
96
|
-
count?: undefined;
|
|
97
96
|
id?: undefined;
|
|
97
|
+
message?: undefined;
|
|
98
98
|
deleted?: undefined;
|
|
99
99
|
providers?: undefined;
|
|
100
|
+
count?: undefined;
|
|
100
101
|
found: boolean;
|
|
101
102
|
provider: import("../custom-registry.js").CustomProviderConfig;
|
|
102
103
|
registered?: undefined;
|
|
103
104
|
label?: undefined;
|
|
104
|
-
message?: undefined;
|
|
105
105
|
} | {
|
|
106
|
-
|
|
106
|
+
message?: undefined;
|
|
107
|
+
provider?: undefined;
|
|
107
108
|
deleted?: undefined;
|
|
108
109
|
providers?: undefined;
|
|
109
|
-
|
|
110
|
+
count?: undefined;
|
|
110
111
|
found: boolean;
|
|
111
112
|
id: string;
|
|
112
113
|
registered?: undefined;
|
|
113
114
|
label?: undefined;
|
|
114
|
-
message?: undefined;
|
|
115
115
|
} | {
|
|
116
|
-
|
|
117
|
-
providers?: undefined;
|
|
116
|
+
message?: undefined;
|
|
118
117
|
provider?: undefined;
|
|
118
|
+
providers?: undefined;
|
|
119
|
+
count?: undefined;
|
|
119
120
|
found?: undefined;
|
|
120
121
|
deleted: boolean;
|
|
121
122
|
id: string;
|
|
122
123
|
registered?: undefined;
|
|
123
124
|
label?: undefined;
|
|
124
|
-
message?: undefined;
|
|
125
125
|
} | {
|
|
126
|
-
|
|
126
|
+
provider?: undefined;
|
|
127
127
|
deleted?: undefined;
|
|
128
128
|
providers?: undefined;
|
|
129
|
-
|
|
129
|
+
count?: undefined;
|
|
130
130
|
found?: undefined;
|
|
131
131
|
registered: boolean;
|
|
132
132
|
id: string;
|
|
@@ -311,10 +311,7 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
311
311
|
notes?: string | undefined;
|
|
312
312
|
scope?: "org" | "user" | undefined;
|
|
313
313
|
}, {
|
|
314
|
-
message?: undefined;
|
|
315
314
|
id?: undefined;
|
|
316
|
-
provider?: undefined;
|
|
317
|
-
deleted?: undefined;
|
|
318
315
|
providers: {
|
|
319
316
|
id: string;
|
|
320
317
|
label: string;
|
|
@@ -325,45 +322,48 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
325
322
|
updatedAt: number;
|
|
326
323
|
}[];
|
|
327
324
|
count: number;
|
|
325
|
+
provider?: undefined;
|
|
328
326
|
found?: undefined;
|
|
327
|
+
deleted?: undefined;
|
|
329
328
|
registered?: undefined;
|
|
330
329
|
label?: undefined;
|
|
331
|
-
} | {
|
|
332
330
|
message?: undefined;
|
|
333
|
-
|
|
334
|
-
deleted?: undefined;
|
|
331
|
+
} | {
|
|
335
332
|
count?: undefined;
|
|
333
|
+
id?: undefined;
|
|
336
334
|
providers?: undefined;
|
|
337
335
|
found: boolean;
|
|
338
336
|
provider: import("../custom-registry.js").CustomProviderConfig;
|
|
337
|
+
deleted?: undefined;
|
|
339
338
|
registered?: undefined;
|
|
340
339
|
label?: undefined;
|
|
341
|
-
} | {
|
|
342
340
|
message?: undefined;
|
|
343
|
-
|
|
344
|
-
deleted?: undefined;
|
|
341
|
+
} | {
|
|
345
342
|
count?: undefined;
|
|
346
343
|
providers?: undefined;
|
|
344
|
+
provider?: undefined;
|
|
347
345
|
found: boolean;
|
|
348
346
|
id: string;
|
|
347
|
+
deleted?: undefined;
|
|
349
348
|
registered?: undefined;
|
|
350
349
|
label?: undefined;
|
|
351
|
-
} | {
|
|
352
350
|
message?: undefined;
|
|
353
|
-
|
|
351
|
+
} | {
|
|
354
352
|
count?: undefined;
|
|
355
353
|
providers?: undefined;
|
|
354
|
+
provider?: undefined;
|
|
356
355
|
found?: undefined;
|
|
357
356
|
deleted: boolean;
|
|
358
357
|
id: string;
|
|
359
358
|
registered?: undefined;
|
|
360
359
|
label?: undefined;
|
|
360
|
+
message?: undefined;
|
|
361
361
|
} | {
|
|
362
|
-
provider?: undefined;
|
|
363
|
-
deleted?: undefined;
|
|
364
362
|
count?: undefined;
|
|
365
363
|
providers?: undefined;
|
|
364
|
+
provider?: undefined;
|
|
366
365
|
found?: undefined;
|
|
366
|
+
deleted?: undefined;
|
|
367
367
|
registered: boolean;
|
|
368
368
|
id: string;
|
|
369
369
|
label: string;
|
|
@@ -73,6 +73,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
73
73
|
offset?: unknown;
|
|
74
74
|
limit?: unknown;
|
|
75
75
|
}, {
|
|
76
|
+
deleted?: undefined;
|
|
76
77
|
jobs: {
|
|
77
78
|
id: string;
|
|
78
79
|
name: string;
|
|
@@ -83,7 +84,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
83
84
|
updatedAt: string;
|
|
84
85
|
}[];
|
|
85
86
|
total: number;
|
|
86
|
-
deleted?: undefined;
|
|
87
87
|
jobId?: undefined;
|
|
88
88
|
} | {
|
|
89
89
|
jobs?: undefined;
|
|
@@ -91,9 +91,9 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
91
91
|
deleted: boolean;
|
|
92
92
|
jobId: string;
|
|
93
93
|
} | {
|
|
94
|
+
deleted?: undefined;
|
|
94
95
|
jobs?: undefined;
|
|
95
96
|
total?: undefined;
|
|
96
|
-
deleted?: undefined;
|
|
97
97
|
jobId?: undefined;
|
|
98
98
|
hits: Record<string, unknown>[];
|
|
99
99
|
offset: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-agent.d.ts","sourceRoot":"","sources":["../../src/scripts/call-agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"call-agent.d.ts","sourceRoot":"","sources":["../../src/scripts/call-agent.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA8OpD,eAAO,MAAM,IAAI,EAAE,UAsDlB,CAAC;AAEF,wBAAsB,GAAG,CACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,gBAAgB,EAC1B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CA6kBjB;AAqPD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CASzE"}
|
|
@@ -1,22 +1,87 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { parseA2AAgentActivityPart } from "../a2a/activity.js";
|
|
3
|
-
import { A2ATaskTimeoutError, callAgent, shouldPreferGlobalA2ASecret, signA2AToken, } from "../a2a/client.js";
|
|
3
|
+
import { A2ATaskTimeoutError, MAX_A2A_CALLER_RESPONSE_CHARS, callAgent, shouldPreferGlobalA2ASecret, signA2AToken, } from "../a2a/client.js";
|
|
4
|
+
import { MAX_A2A_DELEGATION_HOPS } from "../a2a/correlation.js";
|
|
4
5
|
import { invokeAgentAction } from "../a2a/invoke.js";
|
|
5
6
|
import { formatLlmCredentialErrorMessage, isLlmCredentialError, } from "../agent/engine/credential-errors.js";
|
|
6
7
|
import { A2A_CONTINUATION_QUEUED_MARKER } from "../integrations/a2a-continuation-marker.js";
|
|
8
|
+
import { trackingIdentityProperties } from "../observability/tracking-identity.js";
|
|
7
9
|
import { getOrgDomain, getOrgA2ASecret } from "../org/context.js";
|
|
8
10
|
import { findAgent, discoverAgents } from "../server/agent-discovery.js";
|
|
9
11
|
import { getRequestUserEmail, getRequestOrgId, isIntegrationCallerRequest, getIntegrationRequestContext, } from "../server/request-context.js";
|
|
12
|
+
import { track } from "../tracking/registry.js";
|
|
10
13
|
const DEFAULT_SERVERLESS_INTEGRATION_A2A_TIMEOUT_MS = 18_000;
|
|
11
14
|
const NETLIFY_INTEGRATION_A2A_TIMEOUT_MS = 2_000;
|
|
12
15
|
const INTEGRATION_A2A_TOKEN_TTL = "30m";
|
|
16
|
+
const A2A_INVOCATION_EVENT = "$a2a_invocation";
|
|
17
|
+
function trackA2AInvocation(args) {
|
|
18
|
+
try {
|
|
19
|
+
track(A2A_INVOCATION_EVENT, {
|
|
20
|
+
...trackingIdentityProperties(),
|
|
21
|
+
source: "a2a_delegation",
|
|
22
|
+
invocation_id: args.invocationId,
|
|
23
|
+
caller_app: args.callerApp ?? "unknown",
|
|
24
|
+
target_app: args.targetApp,
|
|
25
|
+
mode: args.mode,
|
|
26
|
+
status: args.status,
|
|
27
|
+
duration_ms: Math.max(0, Date.now() - args.startedAt),
|
|
28
|
+
task_id: args.taskId,
|
|
29
|
+
terminal_code: args.terminalCode,
|
|
30
|
+
delegation_depth: args.correlation.delegationDepth,
|
|
31
|
+
parent_run_id: args.correlation.parentRunId,
|
|
32
|
+
parent_turn_id: args.correlation.parentTurnId,
|
|
33
|
+
}, { userId: getRequestUserEmail() });
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Tracking must never affect delegation.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
13
39
|
function buildDelegationCorrelation(context, selfAppId, invocationId) {
|
|
40
|
+
const self = normalizeAppHandle(selfAppId);
|
|
41
|
+
const inheritedVisited = Array.isArray(context?.visitedApps)
|
|
42
|
+
? context.visitedApps.map(normalizeAppHandle).filter(Boolean)
|
|
43
|
+
: [];
|
|
44
|
+
const visitedApps = self
|
|
45
|
+
? [...new Set([...inheritedVisited, self])]
|
|
46
|
+
: [...new Set(inheritedVisited)];
|
|
47
|
+
const inheritedDepth = Number.isInteger(context?.delegationDepth)
|
|
48
|
+
? Math.max(0, Number(context?.delegationDepth))
|
|
49
|
+
: 0;
|
|
14
50
|
return {
|
|
15
51
|
...(selfAppId?.trim() ? { callerApp: selfAppId.trim() } : {}),
|
|
16
52
|
...(context?.threadId ? { callerThreadId: context.threadId } : {}),
|
|
17
53
|
...(context?.runId ? { parentRunId: context.runId } : {}),
|
|
18
54
|
...(context?.turnId ? { parentTurnId: context.turnId } : {}),
|
|
19
55
|
...(invocationId ? { invocationId } : {}),
|
|
56
|
+
delegationDepth: Math.min(MAX_A2A_DELEGATION_HOPS, inheritedDepth + 1),
|
|
57
|
+
...(visitedApps.length > 0 ? { visitedApps } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function normalizeAppHandle(value) {
|
|
61
|
+
return typeof value === "string"
|
|
62
|
+
? value
|
|
63
|
+
.trim()
|
|
64
|
+
.toLowerCase()
|
|
65
|
+
.replace(/^agent-native-/, "")
|
|
66
|
+
: "";
|
|
67
|
+
}
|
|
68
|
+
function terminalTaskError(value) {
|
|
69
|
+
if (!value || typeof value !== "object")
|
|
70
|
+
return null;
|
|
71
|
+
const candidate = value;
|
|
72
|
+
if (candidate.name !== "A2ATaskTerminalError")
|
|
73
|
+
return null;
|
|
74
|
+
return {
|
|
75
|
+
state: String(candidate.state ?? "failed"),
|
|
76
|
+
...(typeof candidate.taskId === "string"
|
|
77
|
+
? { taskId: candidate.taskId }
|
|
78
|
+
: {}),
|
|
79
|
+
...(typeof candidate.responseText === "string"
|
|
80
|
+
? { responseText: candidate.responseText }
|
|
81
|
+
: {}),
|
|
82
|
+
...(typeof candidate.errorCode === "string"
|
|
83
|
+
? { errorCode: candidate.errorCode }
|
|
84
|
+
: {}),
|
|
20
85
|
};
|
|
21
86
|
}
|
|
22
87
|
function buildMessageIdempotencyKey(originatingTurnId, target, exactMessage) {
|
|
@@ -114,7 +179,7 @@ function formatDownstreamLlmCredentialFailure(agentName, value) {
|
|
|
114
179
|
: null;
|
|
115
180
|
}
|
|
116
181
|
export const tool = {
|
|
117
|
-
description: "
|
|
182
|
+
description: "Ask a DIFFERENT, separately-deployed app's agent over A2A. Use message by default so the receiving specialist interprets the objective with its own instructions, skills, connected sources, data dictionary, and tools. The receiver owns provider, schema, query, join, and SQL decisions. Use action + input only for an exact, explicitly known, bounded read whose complete input schema is already known; never expose or call a direct action to work around slow or unreliable delegation, and never guess receiver-owned query logic. NEVER use this to call your own app or perform actions you can do with your own tools. Using call-agent on yourself will fail and waste time. " +
|
|
118
183
|
'For brand-consistent generated media, the first-party Assets agent is available as agent="assets"; use it when another app needs generated heroes, diagrams, product shots, thumbnails, videos, or design imagery, unless the current app has its own generation action that already delegates there. ' +
|
|
119
184
|
"IMPORTANT — handling the response: " +
|
|
120
185
|
"(a) If it contains a URL or ID, copy it VERBATIM into your reply. Do not 'correct' or pluralize the path (e.g. /deck/ → /decks/), normalize casing, or change the slug — any edit breaks the link. " +
|
|
@@ -138,7 +203,7 @@ export const tool = {
|
|
|
138
203
|
},
|
|
139
204
|
action: {
|
|
140
205
|
type: "string",
|
|
141
|
-
description: "
|
|
206
|
+
description: "Optional exact read-only action for an explicitly known bounded operation. Prefer message when the target agent must interpret data, choose sources or tools, synthesize, mutate, or do multi-step work. Never guess the action schema or send receiver-owned SQL.",
|
|
142
207
|
},
|
|
143
208
|
input: {
|
|
144
209
|
type: "object",
|
|
@@ -185,6 +250,13 @@ export async function run(args, context, selfAppId) {
|
|
|
185
250
|
if (selfAppId && agentIdOrName.toLowerCase() === selfAppId.toLowerCase()) {
|
|
186
251
|
return `Error: You cannot use call-agent to call yourself (${selfAppId}). Use your own registered actions/tools instead. call-agent is only for communicating with OTHER separately-deployed apps.`;
|
|
187
252
|
}
|
|
253
|
+
const inheritedDepth = Number.isInteger(context?.delegationDepth)
|
|
254
|
+
? Math.max(0, Number(context?.delegationDepth))
|
|
255
|
+
: 0;
|
|
256
|
+
if (!taskId && inheritedDepth >= MAX_A2A_DELEGATION_HOPS) {
|
|
257
|
+
return (`Error: Cross-app delegation stopped at the ${MAX_A2A_DELEGATION_HOPS}-hop limit. ` +
|
|
258
|
+
"Finish with the results already collected instead of starting another agent.");
|
|
259
|
+
}
|
|
188
260
|
const agent = await findAgent(agentIdOrName, selfAppId);
|
|
189
261
|
if (!agent) {
|
|
190
262
|
const available = (await discoverAgents(selfAppId))
|
|
@@ -192,13 +264,35 @@ export async function run(args, context, selfAppId) {
|
|
|
192
264
|
.join(", ");
|
|
193
265
|
return `Error: Agent "${agentIdOrName}" not found. Available agents: ${available || "(none)"}`;
|
|
194
266
|
}
|
|
267
|
+
if (!taskId) {
|
|
268
|
+
const visited = new Set((context?.visitedApps ?? []).map(normalizeAppHandle).filter(Boolean));
|
|
269
|
+
const self = normalizeAppHandle(selfAppId);
|
|
270
|
+
if (self)
|
|
271
|
+
visited.add(self);
|
|
272
|
+
const targetHandles = [
|
|
273
|
+
normalizeAppHandle(agent.id),
|
|
274
|
+
normalizeAppHandle(agent.name),
|
|
275
|
+
normalizeAppHandle(agentIdOrName),
|
|
276
|
+
].filter(Boolean);
|
|
277
|
+
const repeated = targetHandles.find((handle) => visited.has(handle));
|
|
278
|
+
if (repeated) {
|
|
279
|
+
return (`Error: Cross-app delegation cycle blocked before calling ${agent.name}. ` +
|
|
280
|
+
`The request already visited ${[...visited].join(" -> ")}.`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
195
283
|
const correlation = buildDelegationCorrelation(context, selfAppId);
|
|
196
284
|
const idempotencyKey = message && !taskId
|
|
197
285
|
? buildMessageIdempotencyKey(context?.turnId, agent.url, message)
|
|
198
286
|
: undefined;
|
|
287
|
+
const targetApp = normalizeAppHandle(agent.id) ||
|
|
288
|
+
normalizeAppHandle(agent.name) ||
|
|
289
|
+
normalizeAppHandle(agentIdOrName) ||
|
|
290
|
+
"unknown";
|
|
199
291
|
if (action) {
|
|
200
292
|
const agentCallId = randomUUID();
|
|
201
293
|
const startedAt = Date.now();
|
|
294
|
+
let terminalStatus = "done";
|
|
295
|
+
let terminalCode;
|
|
202
296
|
if (context?.send) {
|
|
203
297
|
context.send({
|
|
204
298
|
type: "agent_call",
|
|
@@ -209,6 +303,10 @@ export async function run(args, context, selfAppId) {
|
|
|
209
303
|
}
|
|
210
304
|
try {
|
|
211
305
|
const output = await invokeReadOnlyAppAction(agent, action, input, buildDelegationCorrelation(context, selfAppId, randomUUID()));
|
|
306
|
+
if (/^Error\b/i.test(output)) {
|
|
307
|
+
terminalStatus = "error";
|
|
308
|
+
terminalCode = "direct_action_failed";
|
|
309
|
+
}
|
|
212
310
|
if (context?.send && output) {
|
|
213
311
|
context.send({
|
|
214
312
|
type: "agent_call_text",
|
|
@@ -219,12 +317,27 @@ export async function run(args, context, selfAppId) {
|
|
|
219
317
|
}
|
|
220
318
|
return output;
|
|
221
319
|
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
terminalStatus = "error";
|
|
322
|
+
terminalCode = "direct_action_failed";
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
222
325
|
finally {
|
|
326
|
+
trackA2AInvocation({
|
|
327
|
+
invocationId: agentCallId,
|
|
328
|
+
callerApp: selfAppId,
|
|
329
|
+
targetApp,
|
|
330
|
+
mode: "direct_action",
|
|
331
|
+
status: terminalStatus === "done" ? "success" : "error",
|
|
332
|
+
startedAt,
|
|
333
|
+
terminalCode,
|
|
334
|
+
correlation,
|
|
335
|
+
});
|
|
223
336
|
if (context?.send) {
|
|
224
337
|
context.send({
|
|
225
338
|
type: "agent_call",
|
|
226
339
|
agent: agent.name,
|
|
227
|
-
status:
|
|
340
|
+
status: terminalStatus,
|
|
228
341
|
agentCallId,
|
|
229
342
|
durationMs: Date.now() - startedAt,
|
|
230
343
|
});
|
|
@@ -244,6 +357,11 @@ export async function run(args, context, selfAppId) {
|
|
|
244
357
|
`If you create or reference a deck/document/design/dashboard, include its FULLY-QUALIFIED URL (e.g. ${agent.url}/deck/<id>) in your reply, not a relative path. ` +
|
|
245
358
|
`Use only artifact IDs and URL paths returned by successful actions — never invent slugs, IDs, or hosts. ` +
|
|
246
359
|
`Return a concise caller-ready synthesis rather than raw tool output or full transcripts; preserve source counts, IDs, short supporting quotes, and URLs needed to substantiate the answer.]`;
|
|
360
|
+
const invocationId = randomUUID();
|
|
361
|
+
const invocationStartedAt = Date.now();
|
|
362
|
+
let invocationStatus = "error";
|
|
363
|
+
let invocationTaskId = taskId || undefined;
|
|
364
|
+
let invocationTerminalCode;
|
|
247
365
|
try {
|
|
248
366
|
// If we have a send context, use streaming so the UI shows progressive text
|
|
249
367
|
if (context?.send) {
|
|
@@ -297,11 +415,15 @@ export async function run(args, context, selfAppId) {
|
|
|
297
415
|
let responseText = "";
|
|
298
416
|
let lastSentLength = 0;
|
|
299
417
|
const agentCallId = randomUUID();
|
|
418
|
+
let terminalStatus = "done";
|
|
300
419
|
const existingContinuationText = taskId
|
|
301
420
|
? null
|
|
302
421
|
: await formatExistingIntegrationContinuationIfRetry(agent, message);
|
|
303
|
-
if (existingContinuationText)
|
|
422
|
+
if (existingContinuationText) {
|
|
423
|
+
invocationStatus = "pending";
|
|
424
|
+
invocationTerminalCode = "existing_continuation";
|
|
304
425
|
return existingContinuationText;
|
|
426
|
+
}
|
|
305
427
|
context.send({
|
|
306
428
|
type: "agent_call",
|
|
307
429
|
agent: agent.name,
|
|
@@ -457,6 +579,9 @@ export async function run(args, context, selfAppId) {
|
|
|
457
579
|
catch (pollErr) {
|
|
458
580
|
const timeoutTaskId = getA2ATaskTimeoutTaskId(pollErr);
|
|
459
581
|
if (timeoutTaskId) {
|
|
582
|
+
terminalStatus = "pending";
|
|
583
|
+
invocationTaskId = timeoutTaskId;
|
|
584
|
+
invocationTerminalCode = "timeout_pending";
|
|
460
585
|
const queued = await enqueueIntegrationContinuationIfPossible(timeoutTaskId, agent, message, callerEmail);
|
|
461
586
|
if (queued) {
|
|
462
587
|
responseText =
|
|
@@ -480,21 +605,60 @@ export async function run(args, context, selfAppId) {
|
|
|
480
605
|
}
|
|
481
606
|
}
|
|
482
607
|
}
|
|
608
|
+
else if (terminalTaskError(pollErr)?.state === "input-required") {
|
|
609
|
+
terminalStatus = "pending";
|
|
610
|
+
const terminal = terminalTaskError(pollErr);
|
|
611
|
+
invocationTaskId = terminal.taskId;
|
|
612
|
+
invocationTerminalCode = terminal.errorCode ?? "input_required";
|
|
613
|
+
responseText = formatInputRequiredWaitInstruction(agent.name, terminal, agentIdOrName);
|
|
614
|
+
}
|
|
615
|
+
else if (terminalTaskError(pollErr)) {
|
|
616
|
+
terminalStatus = "error";
|
|
617
|
+
const terminal = terminalTaskError(pollErr);
|
|
618
|
+
invocationTaskId = terminal.taskId;
|
|
619
|
+
invocationTerminalCode = terminal.errorCode ?? terminal.state;
|
|
620
|
+
const detail = expandRelativeUrls(terminal.responseText ?? pollErr?.message ?? "unknown failure", agent.url);
|
|
621
|
+
responseText =
|
|
622
|
+
`Error: The ${agent.name} agent ended ${terminal.state}` +
|
|
623
|
+
(terminal.errorCode ? ` (${terminal.errorCode})` : "") +
|
|
624
|
+
(terminal.taskId ? ` [taskId: ${terminal.taskId}]` : "") +
|
|
625
|
+
(detail ? `: ${detail}` : "");
|
|
626
|
+
}
|
|
483
627
|
else {
|
|
628
|
+
terminalStatus = "error";
|
|
629
|
+
invocationTerminalCode = "call_failed";
|
|
484
630
|
const reason = pollErr?.message ?? "unknown error";
|
|
485
631
|
responseText =
|
|
486
632
|
formatDownstreamLlmCredentialFailure(agent.name, pollErr) ??
|
|
487
|
-
`The ${agent.name} agent
|
|
633
|
+
`Error: The ${agent.name} agent call failed. (${reason})`;
|
|
488
634
|
}
|
|
489
635
|
}
|
|
636
|
+
if (!responseText && terminalStatus === "done") {
|
|
637
|
+
terminalStatus = "error";
|
|
638
|
+
invocationTerminalCode = "empty_agent_response";
|
|
639
|
+
}
|
|
640
|
+
if (responseText.length > MAX_A2A_CALLER_RESPONSE_CHARS) {
|
|
641
|
+
terminalStatus = "error";
|
|
642
|
+
invocationTerminalCode = "a2a_response_too_large";
|
|
643
|
+
responseText =
|
|
644
|
+
`Error: The ${agent.name} agent returned more data than the caller can safely consume. ` +
|
|
645
|
+
"Ask it for a concise synthesis or a retrievable artifact instead.";
|
|
646
|
+
}
|
|
647
|
+
invocationStatus =
|
|
648
|
+
terminalStatus === "done"
|
|
649
|
+
? "success"
|
|
650
|
+
: terminalStatus === "pending"
|
|
651
|
+
? "pending"
|
|
652
|
+
: "error";
|
|
490
653
|
context.send({
|
|
491
654
|
type: "agent_call",
|
|
492
655
|
agent: agent.name,
|
|
493
|
-
status:
|
|
656
|
+
status: terminalStatus,
|
|
494
657
|
agentCallId,
|
|
658
|
+
...(invocationTaskId ? { taskId: invocationTaskId } : {}),
|
|
495
659
|
durationMs: Date.now() - callStartedAt,
|
|
496
660
|
});
|
|
497
|
-
return responseText ||
|
|
661
|
+
return (responseText || `Error: The ${agent.name} agent returned no result.`);
|
|
498
662
|
}
|
|
499
663
|
// No context — use the async + poll call so we don't get cut off at the
|
|
500
664
|
// serverless gateway's ~30s timeout. callAgent defaults to async:true.
|
|
@@ -525,24 +689,73 @@ export async function run(args, context, selfAppId) {
|
|
|
525
689
|
returnRecoverableArtifactsOnTimeout: false,
|
|
526
690
|
});
|
|
527
691
|
const sanitized = formatDownstreamLlmCredentialFailure(agent.name, response) ?? response;
|
|
528
|
-
|
|
692
|
+
const expanded = expandRelativeUrls(sanitized, agent.url);
|
|
693
|
+
if (!expanded) {
|
|
694
|
+
invocationStatus = "error";
|
|
695
|
+
invocationTerminalCode = "empty_agent_response";
|
|
696
|
+
return "Error: The remote agent returned no result.";
|
|
697
|
+
}
|
|
698
|
+
if (expanded.length > MAX_A2A_CALLER_RESPONSE_CHARS) {
|
|
699
|
+
invocationStatus = "error";
|
|
700
|
+
invocationTerminalCode = "a2a_response_too_large";
|
|
701
|
+
return (`Error: The ${agent.name} agent returned more data than the caller can safely consume. ` +
|
|
702
|
+
"Ask it for a concise synthesis or a retrievable artifact instead.");
|
|
703
|
+
}
|
|
704
|
+
invocationStatus = "success";
|
|
705
|
+
return expanded;
|
|
529
706
|
}
|
|
530
707
|
catch (err) {
|
|
531
708
|
const msg = err?.message ?? String(err);
|
|
532
709
|
const credentialMessage = formatDownstreamLlmCredentialFailure(agent.name, err);
|
|
533
710
|
if (credentialMessage)
|
|
534
711
|
return credentialMessage;
|
|
712
|
+
const terminal = terminalTaskError(err);
|
|
713
|
+
if (terminal?.state === "input-required") {
|
|
714
|
+
invocationStatus = "pending";
|
|
715
|
+
invocationTaskId = terminal.taskId;
|
|
716
|
+
invocationTerminalCode = terminal.errorCode ?? "input_required";
|
|
717
|
+
return formatInputRequiredWaitInstruction(agent.name, terminal, agentIdOrName);
|
|
718
|
+
}
|
|
719
|
+
if (terminal) {
|
|
720
|
+
invocationStatus = "error";
|
|
721
|
+
invocationTaskId = terminal.taskId;
|
|
722
|
+
invocationTerminalCode = terminal.errorCode ?? terminal.state;
|
|
723
|
+
return (`Error calling ${agent.name}: remote task ${terminal.state}` +
|
|
724
|
+
(terminal.errorCode ? ` (${terminal.errorCode})` : "") +
|
|
725
|
+
(terminal.taskId ? ` [taskId: ${terminal.taskId}]` : "") +
|
|
726
|
+
(terminal.responseText ? `: ${terminal.responseText}` : ""));
|
|
727
|
+
}
|
|
535
728
|
const timeoutTaskId = getA2ATaskTimeoutTaskId(err);
|
|
536
729
|
if (timeoutTaskId) {
|
|
730
|
+
invocationStatus = "pending";
|
|
731
|
+
invocationTaskId = timeoutTaskId;
|
|
732
|
+
invocationTerminalCode = "timeout_pending";
|
|
537
733
|
return formatExistingTaskWaitInstruction(agent.name, timeoutTaskId, agentIdOrName);
|
|
538
734
|
}
|
|
539
735
|
// Friendlier message for the common timeout case so the calling agent can
|
|
540
736
|
// decide whether to give up or retry.
|
|
541
737
|
if (/timeout|did not complete|Inactivity|504/i.test(msg)) {
|
|
542
|
-
|
|
738
|
+
invocationStatus = "error";
|
|
739
|
+
invocationTerminalCode = "timeout_without_task";
|
|
740
|
+
return `Error calling ${agent.name}: the remote request timed out before a task id could be recovered.`;
|
|
543
741
|
}
|
|
742
|
+
invocationStatus = "error";
|
|
743
|
+
invocationTerminalCode = "call_failed";
|
|
544
744
|
return `Error calling ${agent.name}: ${msg}`;
|
|
545
745
|
}
|
|
746
|
+
finally {
|
|
747
|
+
trackA2AInvocation({
|
|
748
|
+
invocationId,
|
|
749
|
+
callerApp: selfAppId,
|
|
750
|
+
targetApp,
|
|
751
|
+
mode: taskId ? "task_poll" : "message",
|
|
752
|
+
status: invocationStatus,
|
|
753
|
+
startedAt: invocationStartedAt,
|
|
754
|
+
taskId: invocationTaskId,
|
|
755
|
+
terminalCode: invocationTerminalCode,
|
|
756
|
+
correlation,
|
|
757
|
+
});
|
|
758
|
+
}
|
|
546
759
|
}
|
|
547
760
|
async function invokeReadOnlyAppAction(agent, action, input, correlation) {
|
|
548
761
|
const callerEmail = getRequestUserEmail();
|
|
@@ -588,6 +801,16 @@ function formatExistingTaskWaitInstruction(agentName, taskId, agentIdOrName) {
|
|
|
588
801
|
`Do not send ${agentName} a new check-in or follow-up message; that would start duplicate work. ` +
|
|
589
802
|
`Call call-agent again with agent="${agentIdOrName}" and taskId="${taskId}" (omit message) to continue waiting for this same task.`);
|
|
590
803
|
}
|
|
804
|
+
function formatInputRequiredWaitInstruction(agentName, terminal, agentIdOrName) {
|
|
805
|
+
const detail = terminal.responseText?.trim();
|
|
806
|
+
if (!terminal.taskId) {
|
|
807
|
+
return ((detail ? `${detail}\n\n` : "") +
|
|
808
|
+
`Pending: The ${agentName} agent needs input before it can continue.`);
|
|
809
|
+
}
|
|
810
|
+
return ((detail ? `${detail}\n\n` : "") +
|
|
811
|
+
`The ${agentName} agent is waiting for input under taskId "${terminal.taskId}". ` +
|
|
812
|
+
`After providing or approving the requested input, call call-agent with agent="${agentIdOrName}" and taskId="${terminal.taskId}" (omit message) to continue this same task. Do not start a new message for this work.`);
|
|
813
|
+
}
|
|
591
814
|
async function enqueueIntegrationContinuationIfPossible(taskId, agent, message, ownerEmail) {
|
|
592
815
|
const integration = getIntegrationRequestContext();
|
|
593
816
|
if (!integration || !ownerEmail)
|