@agent-native/core 0.130.0 → 0.130.1
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 +1 -1
- package/corpus/core/CHANGELOG.md +6 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/integrations/a2a-continuation-processor.ts +481 -122
- package/corpus/core/src/integrations/a2a-continuations-store.ts +345 -14
- package/corpus/core/src/integrations/adapters/slack.ts +243 -53
- package/corpus/core/src/integrations/integration-campaign-recovery.ts +4 -1
- package/corpus/core/src/integrations/plugin.ts +39 -21
- package/corpus/core/src/integrations/task-queue-stats.ts +146 -0
- package/corpus/core/src/integrations/types.ts +25 -4
- package/corpus/core/src/integrations/webhook-handler.ts +18 -5
- package/corpus/templates/dispatch/changelog/2026-07-26-slack-replies-recover-after-connected-app-updates.md +6 -0
- package/corpus/templates/slides/.agents/skills/design-systems/SKILL.md +15 -0
- package/corpus/templates/slides/actions/delete-design-system.ts +145 -0
- package/corpus/templates/slides/actions/list-design-systems.ts +94 -2
- package/corpus/templates/slides/app/components/design-system/DesignSystemCard.tsx +43 -1
- package/corpus/templates/slides/app/hooks/use-design-systems.ts +2 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +7 -0
- package/corpus/templates/slides/app/pages/DesignSystems.tsx +56 -1
- package/corpus/templates/slides/changelog/2026-07-28-delete-a-design-system-you-own-from-the-design-systems-page-.md +6 -0
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/integrations/a2a-continuation-processor.d.ts +5 -0
- package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +293 -79
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/a2a-continuations-store.d.ts +23 -1
- package/dist/integrations/a2a-continuations-store.d.ts.map +1 -1
- package/dist/integrations/a2a-continuations-store.js +249 -15
- package/dist/integrations/a2a-continuations-store.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +155 -31
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/integration-campaign-recovery.d.ts.map +1 -1
- package/dist/integrations/integration-campaign-recovery.js +3 -1
- package/dist/integrations/integration-campaign-recovery.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +29 -12
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/task-queue-stats.d.ts +12 -0
- package/dist/integrations/task-queue-stats.d.ts.map +1 -1
- package/dist/integrations/task-queue-stats.js +106 -0
- package/dist/integrations/task-queue-stats.js.map +1 -1
- package/dist/integrations/types.d.ts +24 -6
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +12 -3
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +1 -1
- package/src/integrations/a2a-continuation-processor.ts +481 -122
- package/src/integrations/a2a-continuations-store.ts +345 -14
- package/src/integrations/adapters/slack.ts +243 -53
- package/src/integrations/integration-campaign-recovery.ts +4 -1
- package/src/integrations/plugin.ts +39 -21
- package/src/integrations/task-queue-stats.ts +146 -0
- package/src/integrations/types.ts +25 -4
- package/src/integrations/webhook-handler.ts +18 -5
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* columns before the SELECTs execute.
|
|
9
9
|
*/
|
|
10
10
|
import { getDbExec } from "../db/client.js";
|
|
11
|
+
import { ensureA2AContinuationsTable } from "./a2a-continuations-store.js";
|
|
11
12
|
import { ensurePendingTasksTable } from "./pending-tasks-store.js";
|
|
12
13
|
|
|
13
14
|
export interface RecentFailure {
|
|
@@ -23,6 +24,18 @@ export interface TaskQueueStats {
|
|
|
23
24
|
completed_last_hour: number;
|
|
24
25
|
failed_last_hour: number;
|
|
25
26
|
oldest_pending_age_seconds: number;
|
|
27
|
+
waiting_campaigns: number;
|
|
28
|
+
active_a2a_continuations: number;
|
|
29
|
+
oldest_active_a2a_age_seconds: number;
|
|
30
|
+
terminal_a2a_without_delivery: number;
|
|
31
|
+
recent_a2a_orphans: Array<{
|
|
32
|
+
continuation_id: string;
|
|
33
|
+
integration_task_id: string;
|
|
34
|
+
status: string;
|
|
35
|
+
attempts: number;
|
|
36
|
+
age_seconds: number;
|
|
37
|
+
reason_class: string;
|
|
38
|
+
}>;
|
|
26
39
|
recent_failures: RecentFailure[];
|
|
27
40
|
recent_tasks: Array<{
|
|
28
41
|
id: string;
|
|
@@ -46,6 +59,11 @@ const ZERO_STATS: TaskQueueStats = {
|
|
|
46
59
|
completed_last_hour: 0,
|
|
47
60
|
failed_last_hour: 0,
|
|
48
61
|
oldest_pending_age_seconds: 0,
|
|
62
|
+
waiting_campaigns: 0,
|
|
63
|
+
active_a2a_continuations: 0,
|
|
64
|
+
oldest_active_a2a_age_seconds: 0,
|
|
65
|
+
terminal_a2a_without_delivery: 0,
|
|
66
|
+
recent_a2a_orphans: [],
|
|
49
67
|
recent_failures: [],
|
|
50
68
|
recent_tasks: [],
|
|
51
69
|
};
|
|
@@ -66,11 +84,14 @@ export async function getTaskQueueStats(
|
|
|
66
84
|
scope: TaskQueueStatsScope,
|
|
67
85
|
): Promise<TaskQueueStats> {
|
|
68
86
|
await ensurePendingTasksTable();
|
|
87
|
+
await ensureA2AContinuationsTable();
|
|
69
88
|
const client = getDbExec();
|
|
70
89
|
const now = Date.now();
|
|
71
90
|
const oneHourAgo = now - 60 * 60 * 1000;
|
|
72
91
|
const scopeSql = `owner_email = ?
|
|
73
92
|
AND ((org_id IS NULL AND CAST(? AS TEXT) IS NULL) OR org_id = ?)`;
|
|
93
|
+
const joinedScopeSql = `t.owner_email = ?
|
|
94
|
+
AND ((t.org_id IS NULL AND CAST(? AS TEXT) IS NULL) OR t.org_id = ?)`;
|
|
74
95
|
const scopeArgs = [scope.ownerEmail, scope.orgId, scope.orgId];
|
|
75
96
|
|
|
76
97
|
try {
|
|
@@ -178,6 +199,17 @@ export async function getTaskQueueStats(
|
|
|
178
199
|
),
|
|
179
200
|
}),
|
|
180
201
|
);
|
|
202
|
+
const waitingCampaigns = await readWaitingCampaignCount(
|
|
203
|
+
client,
|
|
204
|
+
joinedScopeSql,
|
|
205
|
+
scopeArgs,
|
|
206
|
+
);
|
|
207
|
+
const a2aStats = await readA2AContinuationStats(
|
|
208
|
+
client,
|
|
209
|
+
joinedScopeSql,
|
|
210
|
+
scopeArgs,
|
|
211
|
+
now,
|
|
212
|
+
);
|
|
181
213
|
|
|
182
214
|
return {
|
|
183
215
|
pending,
|
|
@@ -185,6 +217,8 @@ export async function getTaskQueueStats(
|
|
|
185
217
|
completed_last_hour: completedLastHour,
|
|
186
218
|
failed_last_hour: failedLastHour,
|
|
187
219
|
oldest_pending_age_seconds: oldestPendingAgeSeconds,
|
|
220
|
+
waiting_campaigns: waitingCampaigns,
|
|
221
|
+
...a2aStats,
|
|
188
222
|
recent_failures: recentFailures,
|
|
189
223
|
recent_tasks: recentTasks,
|
|
190
224
|
};
|
|
@@ -195,3 +229,115 @@ export async function getTaskQueueStats(
|
|
|
195
229
|
throw err;
|
|
196
230
|
}
|
|
197
231
|
}
|
|
232
|
+
|
|
233
|
+
async function readWaitingCampaignCount(
|
|
234
|
+
client: ReturnType<typeof getDbExec>,
|
|
235
|
+
scopeSql: string,
|
|
236
|
+
scopeArgs: Array<string | null>,
|
|
237
|
+
): Promise<number> {
|
|
238
|
+
try {
|
|
239
|
+
const result = await client.execute({
|
|
240
|
+
sql: `SELECT COUNT(*) AS c
|
|
241
|
+
FROM integration_campaigns c
|
|
242
|
+
INNER JOIN integration_pending_tasks t
|
|
243
|
+
ON t.id = c.integration_task_id
|
|
244
|
+
WHERE ${scopeSql}
|
|
245
|
+
AND c.status = 'waiting'`,
|
|
246
|
+
args: scopeArgs,
|
|
247
|
+
});
|
|
248
|
+
return Number(result.rows[0]?.c ?? 0);
|
|
249
|
+
} catch (err) {
|
|
250
|
+
if (isMissingTableError(err)) return 0;
|
|
251
|
+
throw err;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async function readA2AContinuationStats(
|
|
256
|
+
client: ReturnType<typeof getDbExec>,
|
|
257
|
+
scopeSql: string,
|
|
258
|
+
scopeArgs: Array<string | null>,
|
|
259
|
+
now: number,
|
|
260
|
+
): Promise<
|
|
261
|
+
Pick<
|
|
262
|
+
TaskQueueStats,
|
|
263
|
+
| "active_a2a_continuations"
|
|
264
|
+
| "oldest_active_a2a_age_seconds"
|
|
265
|
+
| "terminal_a2a_without_delivery"
|
|
266
|
+
| "recent_a2a_orphans"
|
|
267
|
+
>
|
|
268
|
+
> {
|
|
269
|
+
try {
|
|
270
|
+
const live = await client.execute({
|
|
271
|
+
sql: `SELECT
|
|
272
|
+
COUNT(CASE WHEN c.status IN ('pending', 'processing', 'delivering') THEN 1 END) AS active_count,
|
|
273
|
+
MIN(CASE WHEN c.status IN ('pending', 'processing', 'delivering') THEN c.created_at END) AS oldest_created_at,
|
|
274
|
+
COUNT(CASE WHEN c.status IN ('completed', 'failed')
|
|
275
|
+
AND c.terminal_delivery_confirmed_at IS NULL THEN 1 END) AS orphan_count
|
|
276
|
+
FROM integration_a2a_continuations c
|
|
277
|
+
INNER JOIN integration_pending_tasks t
|
|
278
|
+
ON t.id = c.integration_task_id
|
|
279
|
+
WHERE ${scopeSql}`,
|
|
280
|
+
args: scopeArgs,
|
|
281
|
+
});
|
|
282
|
+
const orphaned = await client.execute({
|
|
283
|
+
sql: `SELECT c.id, c.integration_task_id, c.status, c.attempts,
|
|
284
|
+
c.created_at, c.error_message
|
|
285
|
+
FROM integration_a2a_continuations c
|
|
286
|
+
INNER JOIN integration_pending_tasks t
|
|
287
|
+
ON t.id = c.integration_task_id
|
|
288
|
+
WHERE ${scopeSql}
|
|
289
|
+
AND c.status IN ('completed', 'failed')
|
|
290
|
+
AND c.terminal_delivery_confirmed_at IS NULL
|
|
291
|
+
ORDER BY c.updated_at DESC
|
|
292
|
+
LIMIT 5`,
|
|
293
|
+
args: scopeArgs,
|
|
294
|
+
});
|
|
295
|
+
const activeCount = Number(live.rows[0]?.active_count ?? 0);
|
|
296
|
+
const orphanCount = Number(live.rows[0]?.orphan_count ?? 0);
|
|
297
|
+
const oldestCreatedAt = Number(live.rows[0]?.oldest_created_at ?? now);
|
|
298
|
+
const recentOrphans = (orphaned.rows as Array<Record<string, unknown>>).map(
|
|
299
|
+
(row) => ({
|
|
300
|
+
continuation_id: String(row.id ?? ""),
|
|
301
|
+
integration_task_id: String(row.integration_task_id ?? ""),
|
|
302
|
+
status: String(row.status ?? ""),
|
|
303
|
+
attempts: Number(row.attempts ?? 0),
|
|
304
|
+
age_seconds: Math.max(
|
|
305
|
+
0,
|
|
306
|
+
Math.floor((now - Number(row.created_at ?? now)) / 1000),
|
|
307
|
+
),
|
|
308
|
+
reason_class: classifyA2AOrphanReason(row.error_message),
|
|
309
|
+
}),
|
|
310
|
+
);
|
|
311
|
+
return {
|
|
312
|
+
active_a2a_continuations: activeCount,
|
|
313
|
+
oldest_active_a2a_age_seconds:
|
|
314
|
+
activeCount > 0
|
|
315
|
+
? Math.max(0, Math.floor((now - oldestCreatedAt) / 1000))
|
|
316
|
+
: 0,
|
|
317
|
+
terminal_a2a_without_delivery: orphanCount,
|
|
318
|
+
recent_a2a_orphans: recentOrphans,
|
|
319
|
+
};
|
|
320
|
+
} catch (err) {
|
|
321
|
+
if (isMissingTableError(err)) {
|
|
322
|
+
return {
|
|
323
|
+
active_a2a_continuations: 0,
|
|
324
|
+
oldest_active_a2a_age_seconds: 0,
|
|
325
|
+
terminal_a2a_without_delivery: 0,
|
|
326
|
+
recent_a2a_orphans: [],
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
throw err;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function classifyA2AOrphanReason(value: unknown): string {
|
|
334
|
+
const message = String(value ?? "");
|
|
335
|
+
if (!message) return "missing_terminal_delivery";
|
|
336
|
+
if (/timeout|timed out|abort/i.test(message)) return "timeout";
|
|
337
|
+
if (/token|secret|auth|credential/i.test(message)) return "authentication";
|
|
338
|
+
if (/database|sql|store|persist/i.test(message)) return "persistence";
|
|
339
|
+
if (/slack|provider|deliver|stream|response/i.test(message)) {
|
|
340
|
+
return "provider_delivery";
|
|
341
|
+
}
|
|
342
|
+
return "processor_failure";
|
|
343
|
+
}
|
|
@@ -134,6 +134,19 @@ export interface PlatformDeliveryReceipt {
|
|
|
134
134
|
messageRefs?: string[];
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
export interface PlatformDeliveryOptions {
|
|
138
|
+
/** Provider-owned message reference that should be updated in place. */
|
|
139
|
+
placeholderRef?: string;
|
|
140
|
+
/** Stable logical delivery key for provider-side retry reconciliation. */
|
|
141
|
+
idempotencyKey?: string;
|
|
142
|
+
/** Earliest provider timestamp (epoch ms) that can contain this delivery. */
|
|
143
|
+
reconcileAfter?: number;
|
|
144
|
+
/** Abort provider I/O before the caller releases its durable delivery claim. */
|
|
145
|
+
signal?: AbortSignal;
|
|
146
|
+
/** Do not fall back to a fresh post if the stable target cannot be updated. */
|
|
147
|
+
strictTargetRef?: boolean;
|
|
148
|
+
}
|
|
149
|
+
|
|
137
150
|
/**
|
|
138
151
|
* Proactive outbound message target for a platform.
|
|
139
152
|
* Used when the agent needs to send to a saved destination instead of replying
|
|
@@ -201,12 +214,20 @@ export interface PlatformRunProgress {
|
|
|
201
214
|
* credentials, or provider payload.
|
|
202
215
|
*/
|
|
203
216
|
ref?: PlatformRunProgressRef;
|
|
217
|
+
/** Stable provider message target that can receive the terminal answer. */
|
|
218
|
+
responseTargetRef?: string;
|
|
204
219
|
/** Receive normalized agent events. Implementations should throttle writes. */
|
|
205
|
-
onEvent(
|
|
220
|
+
onEvent(
|
|
221
|
+
event: AgentChatEvent,
|
|
222
|
+
opts?: { signal?: AbortSignal },
|
|
223
|
+
): Promise<void> | void;
|
|
206
224
|
/** Finalize the provider-native progress surface with the answer. */
|
|
207
|
-
complete(
|
|
225
|
+
complete(
|
|
226
|
+
message: OutgoingMessage,
|
|
227
|
+
opts?: { signal?: AbortSignal },
|
|
228
|
+
): Promise<void | PlatformDeliveryReceipt>;
|
|
208
229
|
/** Mark the provider-native surface failed and leave a retryable explanation. */
|
|
209
|
-
fail?(message: string): Promise<void>;
|
|
230
|
+
fail?(message: string, opts?: { signal?: AbortSignal }): Promise<void>;
|
|
210
231
|
}
|
|
211
232
|
|
|
212
233
|
/**
|
|
@@ -322,7 +343,7 @@ export interface PlatformAdapter {
|
|
|
322
343
|
sendResponse(
|
|
323
344
|
message: OutgoingMessage,
|
|
324
345
|
context: IncomingMessage,
|
|
325
|
-
opts?:
|
|
346
|
+
opts?: PlatformDeliveryOptions,
|
|
326
347
|
): Promise<void | PlatformDeliveryReceipt>;
|
|
327
348
|
|
|
328
349
|
/**
|
|
@@ -67,7 +67,8 @@ import {
|
|
|
67
67
|
import { runWithRequestContext } from "../server/request-context.js";
|
|
68
68
|
import { normalizeReasoningEffortForRequest } from "../shared/reasoning-effort.js";
|
|
69
69
|
import { A2A_CONTINUATION_QUEUED_MARKER } from "./a2a-continuation-marker.js";
|
|
70
|
-
import {
|
|
70
|
+
import { reconcileTerminalA2AParentIfDisabled } from "./a2a-continuation-processor.js";
|
|
71
|
+
import { getA2AContinuationTaskOutcome } from "./a2a-continuations-store.js";
|
|
71
72
|
import {
|
|
72
73
|
clearIntegrationAwaitingInput,
|
|
73
74
|
setIntegrationAwaitingInput,
|
|
@@ -1086,10 +1087,22 @@ async function processIncomingMessage(
|
|
|
1086
1087
|
JSON.parse(campaign.row.checkpoint).waitingForA2A === true;
|
|
1087
1088
|
} catch {}
|
|
1088
1089
|
if (waitingForA2A) {
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1090
|
+
const a2aOutcome = await getA2AContinuationTaskOutcome(opts.taskId);
|
|
1091
|
+
if (a2aOutcome !== "terminal-delivered") {
|
|
1092
|
+
if (
|
|
1093
|
+
a2aOutcome === "terminal-without-delivery" &&
|
|
1094
|
+
(await reconcileTerminalA2AParentIfDisabled(opts.taskId))
|
|
1095
|
+
) {
|
|
1096
|
+
await releaseApplicableIntegrationBudgets(
|
|
1097
|
+
budgetReservations.reservations,
|
|
1098
|
+
);
|
|
1099
|
+
return { status: "campaign-failed" };
|
|
1100
|
+
}
|
|
1101
|
+
if (a2aOutcome !== "active") {
|
|
1102
|
+
console.warn(
|
|
1103
|
+
`[integrations] Waiting campaign ${campaign.row.id} has A2A outcome ${a2aOutcome} without terminal delivery proof`,
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1093
1106
|
const waiting = await waitForA2AIntegrationCampaign(campaign.row.id, {
|
|
1094
1107
|
runId: campaign.runId,
|
|
1095
1108
|
leaseToken: campaign.leaseToken,
|