@agent-native/core 0.107.1 → 0.108.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/docs/content/actions.mdx +48 -0
- package/corpus/core/docs/content/locales/ar-SA/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/de-DE/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/es-ES/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/fr-FR/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/hi-IN/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/ja-JP/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/ko-KR/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/pt-BR/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/zh-CN/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/zh-TW/actions.mdx +38 -0
- package/corpus/core/package.json +5 -1
- package/corpus/core/src/a2a/artifact-response.ts +32 -10
- package/corpus/core/src/a2a-claims.ts +52 -0
- package/corpus/core/src/action.ts +6 -2
- package/corpus/core/src/audit/record.ts +6 -0
- package/corpus/core/src/client/feature-flags/FeatureFlagsPanel.tsx +519 -0
- package/corpus/core/src/client/feature-flags/helpers.ts +77 -0
- package/corpus/core/src/client/feature-flags/index.ts +13 -0
- package/corpus/core/src/client/feature-flags/types.ts +29 -0
- package/corpus/core/src/client/feature-flags/use-feature-flag.ts +26 -0
- package/corpus/core/src/client/index.ts +11 -0
- package/corpus/core/src/extensions/routes.ts +1 -1
- package/corpus/core/src/feature-flags/a2a-action-route.ts +56 -0
- package/corpus/core/src/feature-flags/actions/get-feature-flags.ts +24 -0
- package/corpus/core/src/feature-flags/actions/list-feature-flags.ts +69 -0
- package/corpus/core/src/feature-flags/actions/set-feature-flag.ts +89 -0
- package/corpus/core/src/feature-flags/index.ts +21 -0
- package/corpus/core/src/feature-flags/permissions.ts +53 -0
- package/corpus/core/src/feature-flags/plugin.ts +44 -0
- package/corpus/core/src/feature-flags/registry.ts +96 -0
- package/corpus/core/src/feature-flags/store.ts +176 -0
- package/corpus/core/src/index.ts +15 -0
- package/corpus/core/src/integrations/a2a-continuation-processor.ts +107 -3
- package/corpus/core/src/integrations/pending-tasks-store.ts +98 -1
- package/corpus/core/src/integrations/plugin.ts +129 -4
- package/corpus/core/src/integrations/webhook-handler.ts +339 -36
- package/corpus/core/src/localization/default-messages.ts +47 -0
- package/corpus/core/src/server/action-discovery.ts +12 -0
- package/corpus/core/src/server/action-routes.ts +47 -5
- package/corpus/core/src/server/agent-chat-plugin.ts +93 -8
- package/corpus/core/src/server/index.ts +1 -0
- package/corpus/core/src/settings/org-settings.ts +13 -0
- package/corpus/core/src/settings/store.ts +57 -0
- package/corpus/core/src/templates/default/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/core/src/templates/default/AGENTS.md +1 -0
- package/corpus/core/src/templates/headless/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/core/src/templates/workspace-core/AGENTS.md +1 -1
- package/corpus/core/src/templates/workspace-root/AGENTS.md +1 -1
- package/corpus/core/src/vite/action-types-plugin.ts +12 -0
- package/corpus/templates/analytics/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/analytics/AGENTS.md +15 -3
- package/corpus/templates/analytics/actions/list-workspace-feature-flags.ts +15 -0
- package/corpus/templates/analytics/actions/navigate.ts +2 -2
- package/corpus/templates/analytics/actions/set-workspace-feature-flag.ts +45 -0
- package/corpus/templates/analytics/actions/view-screen.ts +13 -0
- package/corpus/templates/analytics/app/components/agents/FeatureFlagsFleetPanel.tsx +243 -0
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +11 -3
- package/corpus/templates/analytics/app/hooks/use-navigation-state.ts +3 -1
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +17 -0
- package/corpus/templates/analytics/app/i18n-data.ts +251 -0
- package/corpus/templates/analytics/app/pages/Agents.tsx +22 -2
- package/corpus/templates/analytics/changelog/2026-07-17-manage-feature-flag-rollouts-across-your-organization-s-apps.md +6 -0
- package/corpus/templates/analytics/server/lib/db-admin-connections.ts +13 -5
- package/corpus/templates/analytics/server/lib/workspace-feature-flags.ts +347 -0
- package/corpus/templates/assets/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/brain/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/calendar/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/chat/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/clips/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/clips/server/plugins/feature-flags.ts +11 -0
- package/corpus/templates/clips/shared/feature-flags.ts +30 -37
- package/corpus/templates/content/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/design/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/design/AGENTS.md +5 -3
- package/corpus/templates/design/actions/add-fusion-screens.ts +4 -6
- package/corpus/templates/design/actions/apply-fusion-edits.ts +4 -6
- package/corpus/templates/design/actions/create-fusion-app.ts +5 -4
- package/corpus/templates/design/actions/deploy-fusion-app.ts +4 -3
- package/corpus/templates/design/actions/get-fusion-deploy-status.ts +4 -6
- package/corpus/templates/design/actions/list-fusion-edits.ts +4 -3
- package/corpus/templates/design/actions/push-fusion-app.ts +4 -6
- package/corpus/templates/design/actions/queue-fusion-edit.ts +4 -3
- package/corpus/templates/design/actions/send-fusion-message.ts +4 -6
- package/corpus/templates/design/actions/sync-fusion-app.ts +4 -3
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +1 -1
- package/corpus/templates/design/app/pages/Index.tsx +8 -6
- package/corpus/templates/design/server/plugins/feature-flags.ts +5 -0
- package/corpus/templates/design/shared/full-app.ts +10 -7
- package/corpus/templates/dispatch/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/forms/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/macros/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/mail/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/plan/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/slides/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/tasks/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/a2a/artifact-response.d.ts +5 -1
- package/dist/a2a/artifact-response.d.ts.map +1 -1
- package/dist/a2a/artifact-response.js +18 -12
- package/dist/a2a/artifact-response.js.map +1 -1
- package/dist/a2a-claims.d.ts +10 -0
- package/dist/a2a-claims.d.ts.map +1 -0
- package/dist/a2a-claims.js +41 -0
- package/dist/a2a-claims.js.map +1 -0
- package/dist/action.d.ts +6 -2
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/audit/record.d.ts +3 -0
- package/dist/audit/record.d.ts.map +1 -1
- package/dist/audit/record.js +3 -0
- package/dist/audit/record.js.map +1 -1
- package/dist/client/feature-flags/FeatureFlagsPanel.d.ts +10 -0
- package/dist/client/feature-flags/FeatureFlagsPanel.d.ts.map +1 -0
- package/dist/client/feature-flags/FeatureFlagsPanel.js +143 -0
- package/dist/client/feature-flags/FeatureFlagsPanel.js.map +1 -0
- package/dist/client/feature-flags/helpers.d.ts +16 -0
- package/dist/client/feature-flags/helpers.d.ts.map +1 -0
- package/dist/client/feature-flags/helpers.js +50 -0
- package/dist/client/feature-flags/helpers.js.map +1 -0
- package/dist/client/feature-flags/index.d.ts +5 -0
- package/dist/client/feature-flags/index.d.ts.map +1 -0
- package/dist/client/feature-flags/index.js +4 -0
- package/dist/client/feature-flags/index.js.map +1 -0
- package/dist/client/feature-flags/types.d.ts +27 -0
- package/dist/client/feature-flags/types.d.ts.map +1 -0
- package/dist/client/feature-flags/types.js +2 -0
- package/dist/client/feature-flags/types.js.map +1 -0
- package/dist/client/feature-flags/use-feature-flag.d.ts +8 -0
- package/dist/client/feature-flags/use-feature-flag.d.ts.map +1 -0
- package/dist/client/feature-flags/use-feature-flag.js +15 -0
- package/dist/client/feature-flags/use-feature-flag.js.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/extensions/routes.d.ts.map +1 -1
- package/dist/extensions/routes.js +1 -1
- package/dist/extensions/routes.js.map +1 -1
- package/dist/feature-flags/a2a-action-route.d.ts +14 -0
- package/dist/feature-flags/a2a-action-route.d.ts.map +1 -0
- package/dist/feature-flags/a2a-action-route.js +50 -0
- package/dist/feature-flags/a2a-action-route.js.map +1 -0
- package/dist/feature-flags/actions/get-feature-flags.d.ts +3 -0
- package/dist/feature-flags/actions/get-feature-flags.d.ts.map +1 -0
- package/dist/feature-flags/actions/get-feature-flags.js +18 -0
- package/dist/feature-flags/actions/get-feature-flags.js.map +1 -0
- package/dist/feature-flags/actions/list-feature-flags.d.ts +28 -0
- package/dist/feature-flags/actions/list-feature-flags.d.ts.map +1 -0
- package/dist/feature-flags/actions/list-feature-flags.js +60 -0
- package/dist/feature-flags/actions/list-feature-flags.js.map +1 -0
- package/dist/feature-flags/actions/set-feature-flag.d.ts +26 -0
- package/dist/feature-flags/actions/set-feature-flag.d.ts.map +1 -0
- package/dist/feature-flags/actions/set-feature-flag.js +78 -0
- package/dist/feature-flags/actions/set-feature-flag.js.map +1 -0
- package/dist/feature-flags/index.d.ts +5 -0
- package/dist/feature-flags/index.d.ts.map +1 -0
- package/dist/feature-flags/index.js +5 -0
- package/dist/feature-flags/index.js.map +1 -0
- package/dist/feature-flags/permissions.d.ts +13 -0
- package/dist/feature-flags/permissions.d.ts.map +1 -0
- package/dist/feature-flags/permissions.js +37 -0
- package/dist/feature-flags/permissions.js.map +1 -0
- package/dist/feature-flags/plugin.d.ts +17 -0
- package/dist/feature-flags/plugin.d.ts.map +1 -0
- package/dist/feature-flags/plugin.js +29 -0
- package/dist/feature-flags/plugin.js.map +1 -0
- package/dist/feature-flags/registry.d.ts +23 -0
- package/dist/feature-flags/registry.d.ts.map +1 -0
- package/dist/feature-flags/registry.js +59 -0
- package/dist/feature-flags/registry.js.map +1 -0
- package/dist/feature-flags/store.d.ts +31 -0
- package/dist/feature-flags/store.d.ts.map +1 -0
- package/dist/feature-flags/store.js +124 -0
- package/dist/feature-flags/store.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +62 -5
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/pending-tasks-store.d.ts +3 -0
- package/dist/integrations/pending-tasks-store.d.ts.map +1 -1
- package/dist/integrations/pending-tasks-store.js +75 -1
- package/dist/integrations/pending-tasks-store.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +81 -5
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts +23 -2
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +257 -35
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/localization/default-messages.d.ts +42 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +42 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +12 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts +3 -0
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +45 -5
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +6 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +71 -6
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/settings/org-settings.d.ts +2 -0
- package/dist/settings/org-settings.d.ts.map +1 -1
- package/dist/settings/org-settings.js +5 -1
- package/dist/settings/org-settings.js.map +1 -1
- package/dist/settings/store.d.ts +8 -0
- package/dist/settings/store.d.ts.map +1 -1
- package/dist/settings/store.js +48 -0
- package/dist/settings/store.js.map +1 -1
- package/dist/templates/chat/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/templates/default/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/templates/default/AGENTS.md +1 -0
- package/dist/templates/headless/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/templates/workspace-core/AGENTS.md +1 -1
- package/dist/templates/workspace-root/AGENTS.md +1 -1
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +12 -0
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/docs/content/actions.mdx +48 -0
- package/docs/content/locales/ar-SA/actions.mdx +38 -0
- package/docs/content/locales/de-DE/actions.mdx +38 -0
- package/docs/content/locales/es-ES/actions.mdx +38 -0
- package/docs/content/locales/fr-FR/actions.mdx +38 -0
- package/docs/content/locales/hi-IN/actions.mdx +38 -0
- package/docs/content/locales/ja-JP/actions.mdx +38 -0
- package/docs/content/locales/ko-KR/actions.mdx +38 -0
- package/docs/content/locales/pt-BR/actions.mdx +38 -0
- package/docs/content/locales/zh-CN/actions.mdx +38 -0
- package/docs/content/locales/zh-TW/actions.mdx +38 -0
- package/package.json +5 -1
- package/src/templates/chat/.agents/skills/feature-flags/SKILL.md +169 -0
- package/src/templates/default/.agents/skills/feature-flags/SKILL.md +169 -0
- package/src/templates/default/AGENTS.md +1 -0
- package/src/templates/headless/.agents/skills/feature-flags/SKILL.md +169 -0
- package/src/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +169 -0
- package/src/templates/workspace-core/AGENTS.md +1 -1
- package/src/templates/workspace-root/AGENTS.md +1 -1
- package/corpus/templates/clips/actions/get-feature-flags.ts +0 -30
|
@@ -78,13 +78,16 @@ import {
|
|
|
78
78
|
import { startPendingTasksRetryJob } from "./pending-tasks-retry-job.js";
|
|
79
79
|
import {
|
|
80
80
|
claimPendingTask,
|
|
81
|
+
failTaskDeliveryTransition,
|
|
81
82
|
getNextPendingTaskIdForThread,
|
|
82
83
|
insertPendingTask,
|
|
83
84
|
isDuplicateEventError,
|
|
84
85
|
MAX_PENDING_TASK_ATTEMPTS,
|
|
85
86
|
markTaskCompleted,
|
|
87
|
+
markTaskDeliveryRetryable,
|
|
86
88
|
markTaskFailed,
|
|
87
89
|
markTaskRetryable,
|
|
90
|
+
stageTaskDeliveryPayload,
|
|
88
91
|
} from "./pending-tasks-store.js";
|
|
89
92
|
import {
|
|
90
93
|
claimNextComputerCommand,
|
|
@@ -142,12 +145,18 @@ import type {
|
|
|
142
145
|
IntegrationStatus,
|
|
143
146
|
IntegrationExecutionContext,
|
|
144
147
|
IncomingMessage,
|
|
148
|
+
PlatformDeliveryReceipt,
|
|
145
149
|
} from "./types.js";
|
|
146
150
|
import {
|
|
147
151
|
listIntegrationUsageBudgets,
|
|
148
152
|
saveIntegrationUsageBudget,
|
|
149
153
|
} from "./usage-budget-store.js";
|
|
150
|
-
import {
|
|
154
|
+
import {
|
|
155
|
+
handleWebhook,
|
|
156
|
+
processIntegrationTask,
|
|
157
|
+
recordIntegrationResponseDelivery,
|
|
158
|
+
type IntegrationResponseDeliveryTaskPayload,
|
|
159
|
+
} from "./webhook-handler.js";
|
|
151
160
|
|
|
152
161
|
type NitroPluginDef = (nitroApp: any) => void | Promise<void>;
|
|
153
162
|
|
|
@@ -1615,6 +1624,11 @@ export function createIntegrationsPlugin(
|
|
|
1615
1624
|
return { ok: true, skipped: "already-claimed-or-missing" };
|
|
1616
1625
|
}
|
|
1617
1626
|
|
|
1627
|
+
let deliveryRetryTransitionStarted = false;
|
|
1628
|
+
let deliveryRetryRecovery:
|
|
1629
|
+
| { payload: string; errorMessage: string }
|
|
1630
|
+
| undefined;
|
|
1631
|
+
let confirmedDeliveryRetryPayload: string | undefined;
|
|
1618
1632
|
try {
|
|
1619
1633
|
const adapter = adapterMap.get(task.platform);
|
|
1620
1634
|
if (!adapter) {
|
|
@@ -1622,7 +1636,7 @@ export function createIntegrationsPlugin(
|
|
|
1622
1636
|
setResponseStatus(event, 404);
|
|
1623
1637
|
return { error: "Unknown platform" };
|
|
1624
1638
|
}
|
|
1625
|
-
await runWithRequestContext(
|
|
1639
|
+
const processingResult = await runWithRequestContext(
|
|
1626
1640
|
{
|
|
1627
1641
|
userEmail: task.ownerEmail,
|
|
1628
1642
|
...(task.orgId ? { orgId: task.orgId } : {}),
|
|
@@ -1631,6 +1645,7 @@ export function createIntegrationsPlugin(
|
|
|
1631
1645
|
async () => {
|
|
1632
1646
|
const taskPayload = JSON.parse(task.payload) as
|
|
1633
1647
|
| IntegrationSystemNoticeTaskPayload
|
|
1648
|
+
| IntegrationResponseDeliveryTaskPayload
|
|
1634
1649
|
| { kind?: undefined };
|
|
1635
1650
|
if (taskPayload.kind === "system-notice") {
|
|
1636
1651
|
if (!adapter.sendSystemNotice) {
|
|
@@ -1657,13 +1672,59 @@ export function createIntegrationsPlugin(
|
|
|
1657
1672
|
);
|
|
1658
1673
|
return;
|
|
1659
1674
|
}
|
|
1675
|
+
if (taskPayload.kind === "response-delivery") {
|
|
1676
|
+
let receipt: void | PlatformDeliveryReceipt =
|
|
1677
|
+
taskPayload.deliveryReceipt;
|
|
1678
|
+
if (!receipt) {
|
|
1679
|
+
receipt = await adapter.sendResponse(
|
|
1680
|
+
taskPayload.message,
|
|
1681
|
+
taskPayload.incoming,
|
|
1682
|
+
{
|
|
1683
|
+
...(taskPayload.placeholderRef
|
|
1684
|
+
? { placeholderRef: taskPayload.placeholderRef }
|
|
1685
|
+
: {}),
|
|
1686
|
+
},
|
|
1687
|
+
);
|
|
1688
|
+
}
|
|
1689
|
+
if (receipt?.status !== "delivered") {
|
|
1690
|
+
throw new Error(
|
|
1691
|
+
`${task.platform} response completed without delivery proof`,
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
const deliveredPayload = taskPayload.deliveryReceipt
|
|
1695
|
+
? taskPayload
|
|
1696
|
+
: {
|
|
1697
|
+
...taskPayload,
|
|
1698
|
+
deliveryReceipt: receipt,
|
|
1699
|
+
deliveredAt: new Date().toISOString(),
|
|
1700
|
+
};
|
|
1701
|
+
confirmedDeliveryRetryPayload =
|
|
1702
|
+
JSON.stringify(deliveredPayload);
|
|
1703
|
+
if (!taskPayload.deliveryReceipt) {
|
|
1704
|
+
deliveryRetryRecovery = {
|
|
1705
|
+
payload: confirmedDeliveryRetryPayload,
|
|
1706
|
+
errorMessage:
|
|
1707
|
+
"Provider delivery was confirmed but its receipt checkpoint failed",
|
|
1708
|
+
};
|
|
1709
|
+
await stageTaskDeliveryPayload(
|
|
1710
|
+
task.id,
|
|
1711
|
+
deliveryRetryRecovery.payload,
|
|
1712
|
+
);
|
|
1713
|
+
deliveryRetryRecovery = undefined;
|
|
1714
|
+
}
|
|
1715
|
+
await recordIntegrationResponseDelivery(
|
|
1716
|
+
deliveredPayload,
|
|
1717
|
+
receipt,
|
|
1718
|
+
);
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1660
1721
|
const resources = await loadResourcesForPrompt(
|
|
1661
1722
|
task.ownerEmail,
|
|
1662
1723
|
true,
|
|
1663
1724
|
options?.appId,
|
|
1664
1725
|
task.orgId,
|
|
1665
1726
|
);
|
|
1666
|
-
await processIntegrationTask(task, {
|
|
1727
|
+
const result = await processIntegrationTask(task, {
|
|
1667
1728
|
adapter,
|
|
1668
1729
|
systemPrompt: baseSystemPrompt + resources,
|
|
1669
1730
|
actions,
|
|
@@ -1674,8 +1735,22 @@ export function createIntegrationsPlugin(
|
|
|
1674
1735
|
ownerEmail: task.ownerEmail,
|
|
1675
1736
|
appId: options?.appId,
|
|
1676
1737
|
});
|
|
1738
|
+
if (result?.status === "delivery-pending") {
|
|
1739
|
+
deliveryRetryTransitionStarted = true;
|
|
1740
|
+
await markTaskDeliveryRetryable(
|
|
1741
|
+
task.id,
|
|
1742
|
+
JSON.stringify(result.payload),
|
|
1743
|
+
result.errorMessage,
|
|
1744
|
+
);
|
|
1745
|
+
return "delivery-retry" as const;
|
|
1746
|
+
}
|
|
1747
|
+
return "completed" as const;
|
|
1677
1748
|
},
|
|
1678
1749
|
);
|
|
1750
|
+
if (processingResult === "delivery-retry") {
|
|
1751
|
+
setResponseStatus(event, 202);
|
|
1752
|
+
return { ok: true, taskId, retrying: "response-delivery" };
|
|
1753
|
+
}
|
|
1679
1754
|
await markTaskCompleted(taskId);
|
|
1680
1755
|
const nextTaskId = await getNextPendingTaskIdForThread(
|
|
1681
1756
|
task.platform,
|
|
@@ -1711,7 +1786,57 @@ export function createIntegrationsPlugin(
|
|
|
1711
1786
|
const errorMessage = err?.message
|
|
1712
1787
|
? String(err.message).slice(0, 1000)
|
|
1713
1788
|
: "processor failed";
|
|
1714
|
-
if (
|
|
1789
|
+
if (deliveryRetryRecovery) {
|
|
1790
|
+
try {
|
|
1791
|
+
await markTaskDeliveryRetryable(
|
|
1792
|
+
taskId,
|
|
1793
|
+
deliveryRetryRecovery.payload,
|
|
1794
|
+
`${deliveryRetryRecovery.errorMessage}: ${errorMessage}`,
|
|
1795
|
+
);
|
|
1796
|
+
setResponseStatus(event, 202);
|
|
1797
|
+
return { ok: true, taskId, retrying: "response-delivery" };
|
|
1798
|
+
} catch (transitionError) {
|
|
1799
|
+
const transitionMessage =
|
|
1800
|
+
transitionError instanceof Error
|
|
1801
|
+
? transitionError.message
|
|
1802
|
+
: String(transitionError);
|
|
1803
|
+
await failTaskDeliveryTransition(
|
|
1804
|
+
taskId,
|
|
1805
|
+
`Could not safely checkpoint the delivery receipt: ${transitionMessage}`,
|
|
1806
|
+
).catch((failureTransitionError) => {
|
|
1807
|
+
console.error(
|
|
1808
|
+
"[integrations] Failed to contain delivery receipt transition failure:",
|
|
1809
|
+
failureTransitionError,
|
|
1810
|
+
);
|
|
1811
|
+
});
|
|
1812
|
+
}
|
|
1813
|
+
} else if (confirmedDeliveryRetryPayload) {
|
|
1814
|
+
try {
|
|
1815
|
+
await markTaskDeliveryRetryable(
|
|
1816
|
+
taskId,
|
|
1817
|
+
confirmedDeliveryRetryPayload,
|
|
1818
|
+
`Provider delivery was confirmed but history persistence failed: ${errorMessage}`,
|
|
1819
|
+
);
|
|
1820
|
+
console.error("[integrations] process-task failure:", err);
|
|
1821
|
+
setResponseStatus(event, 202);
|
|
1822
|
+
return { ok: true, taskId, retrying: "response-delivery" };
|
|
1823
|
+
} catch (transitionError) {
|
|
1824
|
+
console.error(
|
|
1825
|
+
"[integrations] Failed to requeue confirmed delivery history:",
|
|
1826
|
+
transitionError,
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
} else if (deliveryRetryTransitionStarted) {
|
|
1830
|
+
await failTaskDeliveryTransition(
|
|
1831
|
+
taskId,
|
|
1832
|
+
`Could not safely checkpoint the delivery retry: ${errorMessage}`,
|
|
1833
|
+
).catch((transitionError) => {
|
|
1834
|
+
console.error(
|
|
1835
|
+
"[integrations] Failed to contain delivery retry transition failure:",
|
|
1836
|
+
transitionError,
|
|
1837
|
+
);
|
|
1838
|
+
});
|
|
1839
|
+
} else if (task.attempts >= MAX_PENDING_TASK_ATTEMPTS) {
|
|
1715
1840
|
await markTaskFailed(taskId, errorMessage);
|
|
1716
1841
|
} else {
|
|
1717
1842
|
await markTaskRetryable(taskId, errorMessage);
|