@agent-native/core 0.94.2 → 0.94.3

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.
Files changed (38) hide show
  1. package/corpus/core/CHANGELOG.md +8 -0
  2. package/corpus/core/package.json +1 -1
  3. package/corpus/core/src/a2a/artifact-response.ts +154 -1
  4. package/corpus/core/src/integrations/a2a-continuation-processor.ts +118 -31
  5. package/corpus/core/src/integrations/a2a-continuations-store.ts +165 -7
  6. package/corpus/core/src/integrations/adapters/slack.ts +77 -7
  7. package/corpus/core/src/integrations/types.ts +30 -0
  8. package/corpus/core/src/integrations/webhook-handler.ts +54 -18
  9. package/corpus/core/src/scripts/call-agent.ts +1 -0
  10. package/corpus/core/src/server/request-context.ts +2 -0
  11. package/dist/a2a/artifact-response.d.ts.map +1 -1
  12. package/dist/a2a/artifact-response.js +127 -1
  13. package/dist/a2a/artifact-response.js.map +1 -1
  14. package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -1
  15. package/dist/integrations/a2a-continuation-processor.js +76 -21
  16. package/dist/integrations/a2a-continuation-processor.js.map +1 -1
  17. package/dist/integrations/a2a-continuations-store.d.ts +4 -1
  18. package/dist/integrations/a2a-continuations-store.d.ts.map +1 -1
  19. package/dist/integrations/a2a-continuations-store.js +130 -6
  20. package/dist/integrations/a2a-continuations-store.js.map +1 -1
  21. package/dist/integrations/adapters/slack.d.ts.map +1 -1
  22. package/dist/integrations/adapters/slack.js +56 -7
  23. package/dist/integrations/adapters/slack.js.map +1 -1
  24. package/dist/integrations/types.d.ts +25 -0
  25. package/dist/integrations/types.d.ts.map +1 -1
  26. package/dist/integrations/types.js.map +1 -1
  27. package/dist/integrations/webhook-handler.js +54 -16
  28. package/dist/integrations/webhook-handler.js.map +1 -1
  29. package/dist/resources/handlers.d.ts +2 -2
  30. package/dist/scripts/call-agent.d.ts.map +1 -1
  31. package/dist/scripts/call-agent.js +1 -0
  32. package/dist/scripts/call-agent.js.map +1 -1
  33. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  34. package/dist/server/request-context.d.ts +2 -0
  35. package/dist/server/request-context.d.ts.map +1 -1
  36. package/dist/server/request-context.js.map +1 -1
  37. package/dist/server/transcribe-voice.d.ts +1 -1
  38. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"a2a-continuations-store.js","sourceRoot":"","sources":["../../src/integrations/a2a-continuations-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,IAAI,YAAuC,CAAC;AAC5C,MAAM,yBAAyB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAChD,MAAM,oCAAoC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvD,yEAAyE;AACzE,2EAA2E;AAC3E,6DAA6D;AAC7D,SAAS,cAAc;IACrB,OAAO;;;;;;;;;;;;;;;;eAgBM,OAAO,EAAE;oBACJ,OAAO,EAAE;;iBAEZ,OAAO,EAAE;iBACT,OAAO,EAAE;mBACP,OAAO,EAAE;;CAE3B,CAAC;AACF,CAAC;AAED,KAAK,UAAU,WAAW;IACxB,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,CAAC,KAAK,IAAI,EAAE;YACzB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAC3B,MAAM,SAAS,GAAG,cAAc,EAAE,CAAC;YACnC,IAAI,UAAU,EAAE,EAAE,CAAC;gBACjB,0FAA0F;gBAC1F,MAAM,iBAAiB,CAAC,+BAA+B,EAAE,SAAS,CAAC,CAAC;gBACpE,MAAM,iBAAiB,CACrB,mCAAmC,EACnC,sHAAsH,CACvH,CAAC;gBACF,MAAM,iBAAiB,CACrB,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pB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,GAAG,EAAE;;;+EAGsE;QAC3E,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;KACxC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,EAAU,EACV,YAAoB;IAEpB,MAAM,WAAW,EAAE,CAAC;IACpB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,GAAG,EAAE;;;iDAGwC;QAC7C,IAAI,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;KAC7D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n getDbExec,\n isPostgres,\n intType,\n retryOnDdlRace,\n} from \"../db/client.js\";\nimport {\n ensureTableExists,\n ensureColumnExists,\n ensureIndexExists,\n} from \"../db/ddl-guard.js\";\nimport { isDuplicateColumnError } from \"../db/migrations.js\";\nimport type { IncomingMessage } from \"./types.js\";\n\nlet _initPromise: Promise<void> | undefined;\nconst PROCESSING_STUCK_AFTER_MS = 5 * 60 * 1000;\nconst PROCESSING_NEXT_CHECK_STALE_AFTER_MS = 60 * 1000;\n\n// Build the CREATE SQL lazily (not at module scope) so intType() runs at\n// RUNTIME, not import time — a module-scope call breaks any consumer whose\n// db/client mock doesn't stub intType (e.g. db-admin specs).\nfunction buildCreateSql(): string {\n return `\n CREATE TABLE IF NOT EXISTS integration_a2a_continuations (\n id TEXT PRIMARY KEY,\n integration_task_id TEXT NOT NULL,\n platform TEXT NOT NULL,\n external_thread_id TEXT NOT NULL,\n incoming_payload TEXT NOT NULL,\n placeholder_ref TEXT,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n agent_name TEXT NOT NULL,\n agent_url TEXT NOT NULL,\n dedupe_key TEXT,\n a2a_task_id TEXT NOT NULL,\n a2a_auth_token TEXT,\n status TEXT NOT NULL,\n attempts ${intType()} NOT NULL DEFAULT 0,\n next_check_at ${intType()} NOT NULL,\n error_message TEXT,\n created_at ${intType()} NOT NULL,\n updated_at ${intType()} NOT NULL,\n completed_at ${intType()}\n )\n`;\n}\n\nasync function ensureTable(): Promise<void> {\n if (!_initPromise) {\n _initPromise = (async () => {\n const client = getDbExec();\n const createSql = buildCreateSql();\n if (isPostgres()) {\n // PG guard: probe via information_schema, only issue DDL if missing, bounded lock_timeout\n await ensureTableExists(\"integration_a2a_continuations\", createSql);\n await ensureIndexExists(\n \"idx_a2a_continuations_status_next\",\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_status_next ON integration_a2a_continuations(status, next_check_at)`,\n );\n await ensureIndexExists(\n \"idx_a2a_continuations_integration_task\",\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_integration_task ON integration_a2a_continuations(integration_task_id)`,\n );\n await ensureIndexExists(\n \"idx_a2a_continuations_remote_task\",\n `CREATE UNIQUE INDEX IF NOT EXISTS idx_a2a_continuations_remote_task ON integration_a2a_continuations(integration_task_id, agent_url, a2a_task_id)`,\n );\n await ensureColumnExists(\n \"integration_a2a_continuations\",\n \"a2a_auth_token\",\n `ALTER TABLE integration_a2a_continuations ADD COLUMN IF NOT EXISTS a2a_auth_token TEXT`,\n );\n await ensureColumnExists(\n \"integration_a2a_continuations\",\n \"dedupe_key\",\n `ALTER TABLE integration_a2a_continuations ADD COLUMN IF NOT EXISTS dedupe_key TEXT`,\n );\n await ensureIndexExists(\n \"idx_a2a_continuations_dedupe_key\",\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_dedupe_key ON integration_a2a_continuations(integration_task_id, agent_url, dedupe_key)`,\n );\n return;\n }\n // SQLite (local dev): keep existing behavior\n await retryOnDdlRace(() => client.execute(createSql));\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_status_next ON integration_a2a_continuations(status, next_check_at)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_integration_task ON integration_a2a_continuations(integration_task_id)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE UNIQUE INDEX IF NOT EXISTS idx_a2a_continuations_remote_task ON integration_a2a_continuations(integration_task_id, agent_url, a2a_task_id)`,\n ),\n );\n await addColumnIfMissing(\"a2a_auth_token\", \"TEXT\");\n await addColumnIfMissing(\"dedupe_key\", \"TEXT\");\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_dedupe_key ON integration_a2a_continuations(integration_task_id, agent_url, dedupe_key)`,\n ),\n );\n })().catch((err) => {\n // Retry init on the next call after a failed startup.\n _initPromise = undefined;\n throw err;\n });\n }\n return _initPromise;\n}\n\nasync function addColumnIfMissing(name: string, definition: string) {\n try {\n await retryOnDdlRace(() =>\n getDbExec().execute(\n `ALTER TABLE integration_a2a_continuations ADD COLUMN ${name} ${definition}`,\n ),\n );\n } catch (err) {\n if (isDuplicateColumnError(err)) return;\n throw err;\n }\n}\n\nexport type A2AContinuationStatus =\n | \"pending\"\n | \"processing\"\n | \"delivering\"\n | \"completed\"\n | \"failed\";\n\nexport interface A2AContinuation {\n id: string;\n integrationTaskId: string;\n platform: string;\n externalThreadId: string;\n incoming: IncomingMessage;\n placeholderRef: string | null;\n ownerEmail: string;\n orgId: string | null;\n agentName: string;\n agentUrl: string;\n dedupeKey: string | null;\n a2aTaskId: string;\n a2aAuthToken: string | null;\n status: A2AContinuationStatus;\n attempts: number;\n nextCheckAt: number;\n errorMessage: string | null;\n createdAt: number;\n updatedAt: number;\n completedAt: number | null;\n}\n\nfunction rowToContinuation(row: Record<string, unknown>): A2AContinuation {\n return {\n id: row.id as string,\n integrationTaskId: row.integration_task_id as string,\n platform: row.platform as string,\n externalThreadId: row.external_thread_id as string,\n incoming: JSON.parse(row.incoming_payload as string) as IncomingMessage,\n placeholderRef: (row.placeholder_ref as string | null) ?? null,\n ownerEmail: row.owner_email as string,\n orgId: (row.org_id as string | null) ?? null,\n agentName: row.agent_name as string,\n agentUrl: row.agent_url as string,\n dedupeKey: (row.dedupe_key as string | null) ?? null,\n a2aTaskId: row.a2a_task_id as string,\n a2aAuthToken: (row.a2a_auth_token as string | null) ?? null,\n status: row.status as A2AContinuationStatus,\n attempts: Number(row.attempts ?? 0),\n nextCheckAt: Number(row.next_check_at ?? 0),\n errorMessage: (row.error_message as string | null) ?? null,\n createdAt: Number(row.created_at ?? 0),\n updatedAt: Number(row.updated_at ?? 0),\n completedAt:\n row.completed_at == null ? null : Number(row.completed_at as number),\n };\n}\n\nexport async function insertA2AContinuation(input: {\n integrationTaskId: string;\n platform: string;\n externalThreadId: string;\n incoming: IncomingMessage;\n placeholderRef?: string | null;\n ownerEmail: string;\n orgId?: string | null;\n agentName: string;\n agentUrl: string;\n dedupeKey?: string | null;\n a2aTaskId: string;\n a2aAuthToken?: string | null;\n}): Promise<A2AContinuation> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n const id = `a2a-cont-${now}-${Math.random().toString(36).slice(2, 8)}`;\n const payload = JSON.stringify(input.incoming);\n\n try {\n await client.execute({\n sql: `INSERT INTO integration_a2a_continuations\n (id, integration_task_id, platform, external_thread_id, incoming_payload,\n placeholder_ref, owner_email, org_id, agent_name, agent_url, dedupe_key, a2a_task_id, a2a_auth_token,\n status, attempts, next_check_at, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n args: [\n id,\n input.integrationTaskId,\n input.platform,\n input.externalThreadId,\n payload,\n input.placeholderRef ?? null,\n input.ownerEmail,\n input.orgId ?? null,\n input.agentName,\n input.agentUrl,\n input.dedupeKey ?? null,\n input.a2aTaskId,\n input.a2aAuthToken ?? null,\n \"pending\",\n 0,\n now,\n now,\n now,\n ],\n });\n return (await getA2AContinuation(id))!;\n } catch (err: any) {\n if (!isDuplicateContinuationError(err)) throw err;\n const existing = await findA2AContinuation(\n input.integrationTaskId,\n input.agentUrl,\n input.a2aTaskId,\n );\n if (existing) return existing;\n throw err;\n }\n}\n\nexport async function getA2AContinuationForIntegrationTask(\n integrationTaskId: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const { rows } = await client.execute({\n sql: `SELECT * FROM integration_a2a_continuations\n WHERE integration_task_id = ?\n ORDER BY created_at ASC\n LIMIT 1`,\n args: [integrationTaskId],\n });\n return rows[0] ? rowToContinuation(rows[0] as Record<string, unknown>) : null;\n}\n\nexport async function getA2AContinuationsForIntegrationTaskAgent(\n integrationTaskId: string,\n agentUrl: string,\n dedupeKey?: string | null,\n): Promise<A2AContinuation[]> {\n await ensureTable();\n const client = getDbExec();\n const { rows } = await client.execute(\n dedupeKey\n ? {\n sql: `SELECT * FROM integration_a2a_continuations\n WHERE integration_task_id = ? AND agent_url = ? AND dedupe_key = ?\n ORDER BY created_at ASC`,\n args: [integrationTaskId, agentUrl, dedupeKey],\n }\n : {\n sql: `SELECT * FROM integration_a2a_continuations\n WHERE integration_task_id = ? AND agent_url = ?\n ORDER BY created_at ASC`,\n args: [integrationTaskId, agentUrl],\n },\n );\n return rows.map((row) => rowToContinuation(row as Record<string, unknown>));\n}\n\nfunction isDuplicateContinuationError(err: unknown): boolean {\n const e = err as { code?: string; message?: string } | null;\n if (!e) return false;\n if (e.code === \"23505\") return true;\n const msg = String(e.message ?? \"\").toLowerCase();\n return (\n msg.includes(\"unique\") ||\n msg.includes(\"duplicate entry\") ||\n msg.includes(\"duplicate key\")\n );\n}\n\nasync function findA2AContinuation(\n integrationTaskId: string,\n agentUrl: string,\n a2aTaskId: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const { rows } = await client.execute({\n sql: `SELECT * FROM integration_a2a_continuations\n WHERE integration_task_id = ? AND agent_url = ? AND a2a_task_id = ?\n LIMIT 1`,\n args: [integrationTaskId, agentUrl, a2aTaskId],\n });\n return rows[0] ? rowToContinuation(rows[0] as Record<string, unknown>) : null;\n}\n\nexport async function getA2AContinuation(\n id: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const { rows } = await client.execute({\n sql: `SELECT * FROM integration_a2a_continuations WHERE id = ? LIMIT 1`,\n args: [id],\n });\n return rows[0] ? rowToContinuation(rows[0] as Record<string, unknown>) : null;\n}\n\nexport async function claimA2AContinuation(\n id: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n const processingCutoff = now - PROCESSING_STUCK_AFTER_MS;\n const staleNextCheckCutoff = now - PROCESSING_NEXT_CHECK_STALE_AFTER_MS;\n const result = await client.execute({\n sql: isPostgres()\n ? `UPDATE integration_a2a_continuations\n SET status = ?, attempts = attempts + 1, updated_at = ?\n WHERE id = ?\n AND (\n status = 'pending'\n OR (\n status = 'processing'\n AND (updated_at <= ? OR next_check_at <= ?)\n )\n )\n RETURNING *`\n : `UPDATE integration_a2a_continuations\n SET status = ?, attempts = attempts + 1, updated_at = ?\n WHERE id = ?\n AND (\n status = 'pending'\n OR (\n status = 'processing'\n AND (updated_at <= ? OR next_check_at <= ?)\n )\n )`,\n args: [\"processing\", now, id, processingCutoff, staleNextCheckCutoff],\n });\n const rows = result.rows ?? [];\n if (isPostgres()) {\n return rows[0]\n ? rowToContinuation(rows[0] as Record<string, unknown>)\n : null;\n }\n const affected = (result as any)?.rowsAffected ?? (result as any)?.rowCount;\n if (affected === 0) return null;\n const fetched = await getA2AContinuation(id);\n if (!fetched || fetched.status !== \"processing\") return null;\n return fetched;\n}\n\nexport async function claimDueA2AContinuations(\n limit = 5,\n): Promise<A2AContinuation[]> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n const processingCutoff = now - PROCESSING_STUCK_AFTER_MS;\n const staleNextCheckCutoff = now - PROCESSING_NEXT_CHECK_STALE_AFTER_MS;\n // If a processor dies while holding a delivery claim, retry the final send.\n // The stale cutoff preserves the in-flight delivery guard while keeping\n // final integration replies at-least-once.\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, next_check_at = ?, updated_at = ?\n WHERE status = 'delivering' AND updated_at <= ?`,\n args: [\"pending\", now, now, now - 5 * 60 * 1000],\n });\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, next_check_at = ?, updated_at = ?\n WHERE status = 'processing'\n AND (updated_at <= ? OR next_check_at <= ?)`,\n args: [\"pending\", now, now, processingCutoff, staleNextCheckCutoff],\n });\n const { rows } = await client.execute({\n sql: `SELECT id FROM integration_a2a_continuations\n WHERE status = 'pending' AND next_check_at <= ?\n ORDER BY next_check_at ASC\n LIMIT ?`,\n args: [now, limit],\n });\n const claimed: A2AContinuation[] = [];\n for (const row of rows) {\n const continuation = await claimA2AContinuation(row.id as string);\n if (continuation) claimed.push(continuation);\n }\n return claimed;\n}\n\nexport async function claimA2AContinuationDelivery(\n id: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n const result = await client.execute({\n sql: isPostgres()\n ? `UPDATE integration_a2a_continuations\n SET status = ?, updated_at = ?\n WHERE id = ? AND status = 'processing'\n RETURNING *`\n : `UPDATE integration_a2a_continuations\n SET status = ?, updated_at = ?\n WHERE id = ? AND status = 'processing'`,\n args: [\"delivering\", now, id],\n });\n const rows = result.rows ?? [];\n if (isPostgres()) {\n return rows[0]\n ? rowToContinuation(rows[0] as Record<string, unknown>)\n : null;\n }\n const affected = (result as any)?.rowsAffected ?? (result as any)?.rowCount;\n if (affected === 0) return null;\n const fetched = await getA2AContinuation(id);\n if (!fetched || fetched.status !== \"delivering\") return null;\n return fetched;\n}\n\nexport async function rescheduleA2AContinuation(\n id: string,\n delayMs: number,\n): Promise<void> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, next_check_at = ?, updated_at = ?\n WHERE id = ? AND status IN ('processing', 'delivering')`,\n args: [\"pending\", now + delayMs, now, id],\n });\n}\n\nexport async function completeA2AContinuation(id: string): Promise<void> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, updated_at = ?, completed_at = ?,\n incoming_payload = ?, a2a_auth_token = NULL\n WHERE id = ? AND status IN ('processing', 'delivering', 'completed')`,\n args: [\"completed\", now, now, \"{}\", id],\n });\n}\n\nexport async function failA2AContinuation(\n id: string,\n errorMessage: string,\n): Promise<void> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, updated_at = ?, error_message = ?,\n incoming_payload = ?, a2a_auth_token = NULL\n WHERE id = ? AND status <> 'completed'`,\n args: [\"failed\", now, errorMessage.slice(0, 2000), \"{}\", id],\n });\n}\n"]}
1
+ {"version":3,"file":"a2a-continuations-store.js","sourceRoot":"","sources":["../../src/integrations/a2a-continuations-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,IAAI,YAAuC,CAAC;AAC5C,MAAM,yBAAyB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAChD,MAAM,oCAAoC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvD,yEAAyE;AACzE,2EAA2E;AAC3E,6DAA6D;AAC7D,S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E;;kEAEyD;QAC9D,IAAI,EAAE,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,EAAU;IACtD,MAAM,WAAW,EAAE,CAAC;IACpB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,GAAG,EAAE;;;+EAGsE;QAC3E,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;KACxC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,EAAU,EACV,YAAoB;IAEpB,MAAM,WAAW,EAAE,CAAC;IACpB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,GAAG,EAAE;;;iDAGwC;QAC7C,IAAI,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;KAC7D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n getDbExec,\n isPostgres,\n intType,\n retryOnDdlRace,\n} from \"../db/client.js\";\nimport {\n ensureTableExists,\n ensureColumnExists,\n ensureIndexExists,\n} from \"../db/ddl-guard.js\";\nimport { isDuplicateColumnError } from \"../db/migrations.js\";\nimport type { IncomingMessage, PlatformRunProgressRef } from \"./types.js\";\n\nlet _initPromise: Promise<void> | undefined;\nconst PROCESSING_STUCK_AFTER_MS = 5 * 60 * 1000;\nconst PROCESSING_NEXT_CHECK_STALE_AFTER_MS = 60 * 1000;\n\n// Build the CREATE SQL lazily (not at module scope) so intType() runs at\n// RUNTIME, not import time — a module-scope call breaks any consumer whose\n// db/client mock doesn't stub intType (e.g. db-admin specs).\nfunction buildCreateSql(): string {\n return `\n CREATE TABLE IF NOT EXISTS integration_a2a_continuations (\n id TEXT PRIMARY KEY,\n integration_task_id TEXT NOT NULL,\n platform TEXT NOT NULL,\n external_thread_id TEXT NOT NULL,\n incoming_payload TEXT NOT NULL,\n placeholder_ref TEXT,\n progress_ref TEXT,\n progress_ref_claimed ${intType()} NOT NULL DEFAULT 0,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n agent_name TEXT NOT NULL,\n agent_url TEXT NOT NULL,\n dedupe_key TEXT,\n a2a_task_id TEXT NOT NULL,\n a2a_auth_token TEXT,\n status TEXT NOT NULL,\n attempts ${intType()} NOT NULL DEFAULT 0,\n next_check_at ${intType()} NOT NULL,\n error_message TEXT,\n created_at ${intType()} NOT NULL,\n updated_at ${intType()} NOT NULL,\n completed_at ${intType()}\n )\n`;\n}\n\nasync function ensureTable(): Promise<void> {\n if (!_initPromise) {\n _initPromise = (async () => {\n const client = getDbExec();\n const createSql = buildCreateSql();\n if (isPostgres()) {\n // PG guard: probe via information_schema, only issue DDL if missing, bounded lock_timeout\n await ensureTableExists(\"integration_a2a_continuations\", createSql);\n await ensureIndexExists(\n \"idx_a2a_continuations_status_next\",\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_status_next ON integration_a2a_continuations(status, next_check_at)`,\n );\n await ensureIndexExists(\n \"idx_a2a_continuations_integration_task\",\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_integration_task ON integration_a2a_continuations(integration_task_id)`,\n );\n await ensureIndexExists(\n \"idx_a2a_continuations_remote_task\",\n `CREATE UNIQUE INDEX IF NOT EXISTS idx_a2a_continuations_remote_task ON integration_a2a_continuations(integration_task_id, agent_url, a2a_task_id)`,\n );\n await ensureColumnExists(\n \"integration_a2a_continuations\",\n \"a2a_auth_token\",\n `ALTER TABLE integration_a2a_continuations ADD COLUMN IF NOT EXISTS a2a_auth_token TEXT`,\n );\n await ensureColumnExists(\n \"integration_a2a_continuations\",\n \"dedupe_key\",\n `ALTER TABLE integration_a2a_continuations ADD COLUMN IF NOT EXISTS dedupe_key TEXT`,\n );\n await ensureColumnExists(\n \"integration_a2a_continuations\",\n \"progress_ref\",\n `ALTER TABLE integration_a2a_continuations ADD COLUMN IF NOT EXISTS progress_ref TEXT`,\n );\n await ensureColumnExists(\n \"integration_a2a_continuations\",\n \"progress_ref_claimed\",\n `ALTER TABLE integration_a2a_continuations ADD COLUMN IF NOT EXISTS progress_ref_claimed ${intType()} NOT NULL DEFAULT 0`,\n );\n await backfillProgressRefOwners(client);\n await ensureIndexExists(\n \"idx_a2a_continuations_dedupe_key\",\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_dedupe_key ON integration_a2a_continuations(integration_task_id, agent_url, dedupe_key)`,\n );\n await ensureIndexExists(\n \"idx_a2a_continuations_one_progress_owner\",\n `CREATE UNIQUE INDEX IF NOT EXISTS idx_a2a_continuations_one_progress_owner ON integration_a2a_continuations(integration_task_id) WHERE progress_ref_claimed = 1`,\n );\n return;\n }\n // SQLite (local dev): keep existing behavior\n await retryOnDdlRace(() => client.execute(createSql));\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_status_next ON integration_a2a_continuations(status, next_check_at)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_integration_task ON integration_a2a_continuations(integration_task_id)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE UNIQUE INDEX IF NOT EXISTS idx_a2a_continuations_remote_task ON integration_a2a_continuations(integration_task_id, agent_url, a2a_task_id)`,\n ),\n );\n await addColumnIfMissing(\"a2a_auth_token\", \"TEXT\");\n await addColumnIfMissing(\"dedupe_key\", \"TEXT\");\n await addColumnIfMissing(\"progress_ref\", \"TEXT\");\n await addColumnIfMissing(\n \"progress_ref_claimed\",\n `${intType()} NOT NULL DEFAULT 0`,\n );\n await backfillProgressRefOwners(client);\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_a2a_continuations_dedupe_key ON integration_a2a_continuations(integration_task_id, agent_url, dedupe_key)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE UNIQUE INDEX IF NOT EXISTS idx_a2a_continuations_one_progress_owner ON integration_a2a_continuations(integration_task_id) WHERE progress_ref_claimed = 1`,\n ),\n );\n })().catch((err) => {\n // Retry init on the next call after a failed startup.\n _initPromise = undefined;\n throw err;\n });\n }\n return _initPromise;\n}\n\nasync function addColumnIfMissing(name: string, definition: string) {\n try {\n await retryOnDdlRace(() =>\n getDbExec().execute(\n `ALTER TABLE integration_a2a_continuations ADD COLUMN ${name} ${definition}`,\n ),\n );\n } catch (err) {\n if (isDuplicateColumnError(err)) return;\n throw err;\n }\n}\n\nasync function backfillProgressRefOwners(\n client: ReturnType<typeof getDbExec>,\n): Promise<void> {\n await client.execute(`\n UPDATE integration_a2a_continuations AS candidate\n SET progress_ref_claimed = 1\n WHERE candidate.progress_ref IS NOT NULL\n AND candidate.status NOT IN ('completed', 'failed')\n AND candidate.progress_ref_claimed = 0\n AND NOT EXISTS (\n SELECT 1\n FROM integration_a2a_continuations AS owner\n WHERE owner.integration_task_id = candidate.integration_task_id\n AND owner.progress_ref_claimed = 1\n )\n AND candidate.id = (\n SELECT selected.id\n FROM integration_a2a_continuations AS selected\n WHERE selected.integration_task_id = candidate.integration_task_id\n AND selected.progress_ref IS NOT NULL\n AND selected.status NOT IN ('completed', 'failed')\n ORDER BY selected.created_at ASC, selected.id ASC\n LIMIT 1\n )\n `);\n}\n\nexport type A2AContinuationStatus =\n | \"pending\"\n | \"processing\"\n | \"delivering\"\n | \"completed\"\n | \"failed\";\n\nexport interface A2AContinuation {\n id: string;\n integrationTaskId: string;\n platform: string;\n externalThreadId: string;\n incoming: IncomingMessage;\n placeholderRef: string | null;\n progressRef: PlatformRunProgressRef | null;\n progressRefClaimed: boolean;\n ownerEmail: string;\n orgId: string | null;\n agentName: string;\n agentUrl: string;\n dedupeKey: string | null;\n a2aTaskId: string;\n a2aAuthToken: string | null;\n status: A2AContinuationStatus;\n attempts: number;\n nextCheckAt: number;\n errorMessage: string | null;\n createdAt: number;\n updatedAt: number;\n completedAt: number | null;\n}\n\nconst MAX_PROGRESS_REF_KIND_CHARS = 128;\nconst MAX_PROGRESS_REF_STREAM_TS_CHARS = 256;\n\n/**\n * Keep only the tiny, adapter-owned continuation reference. Invalid rows are\n * treated as unavailable rather than throwing during a retry sweep.\n */\nfunction parseProgressRef(value: unknown): PlatformRunProgressRef | null {\n if (typeof value !== \"string\" || value.length === 0) return null;\n try {\n const parsed = JSON.parse(value) as unknown;\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n return null;\n }\n const { kind, streamTs } = parsed as Record<string, unknown>;\n if (\n typeof kind !== \"string\" ||\n typeof streamTs !== \"string\" ||\n kind.length === 0 ||\n streamTs.length === 0 ||\n kind.length > MAX_PROGRESS_REF_KIND_CHARS ||\n streamTs.length > MAX_PROGRESS_REF_STREAM_TS_CHARS\n ) {\n return null;\n }\n return { kind, streamTs };\n } catch {\n return null;\n }\n}\n\nfunction serializeProgressRef(value: unknown): string | null {\n const parsed = parseProgressRef(\n typeof value === \"string\" ? value : JSON.stringify(value),\n );\n return parsed ? JSON.stringify(parsed) : null;\n}\n\nfunction rowToContinuation(row: Record<string, unknown>): A2AContinuation {\n return {\n id: row.id as string,\n integrationTaskId: row.integration_task_id as string,\n platform: row.platform as string,\n externalThreadId: row.external_thread_id as string,\n incoming: JSON.parse(row.incoming_payload as string) as IncomingMessage,\n placeholderRef: (row.placeholder_ref as string | null) ?? null,\n progressRef: parseProgressRef(row.progress_ref),\n progressRefClaimed: Number(row.progress_ref_claimed ?? 0) === 1,\n ownerEmail: row.owner_email as string,\n orgId: (row.org_id as string | null) ?? null,\n agentName: row.agent_name as string,\n agentUrl: row.agent_url as string,\n dedupeKey: (row.dedupe_key as string | null) ?? null,\n a2aTaskId: row.a2a_task_id as string,\n a2aAuthToken: (row.a2a_auth_token as string | null) ?? null,\n status: row.status as A2AContinuationStatus,\n attempts: Number(row.attempts ?? 0),\n nextCheckAt: Number(row.next_check_at ?? 0),\n errorMessage: (row.error_message as string | null) ?? null,\n createdAt: Number(row.created_at ?? 0),\n updatedAt: Number(row.updated_at ?? 0),\n completedAt:\n row.completed_at == null ? null : Number(row.completed_at as number),\n };\n}\n\nexport async function insertA2AContinuation(input: {\n integrationTaskId: string;\n platform: string;\n externalThreadId: string;\n incoming: IncomingMessage;\n placeholderRef?: string | null;\n progressRef?: PlatformRunProgressRef | null;\n ownerEmail: string;\n orgId?: string | null;\n agentName: string;\n agentUrl: string;\n dedupeKey?: string | null;\n a2aTaskId: string;\n a2aAuthToken?: string | null;\n}): Promise<A2AContinuation> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n const id = `a2a-cont-${now}-${Math.random().toString(36).slice(2, 8)}`;\n const payload = JSON.stringify(input.incoming);\n const progressRef = serializeProgressRef(input.progressRef);\n\n try {\n await client.execute({\n sql: `INSERT INTO integration_a2a_continuations\n (id, integration_task_id, platform, external_thread_id, incoming_payload,\n placeholder_ref, progress_ref, progress_ref_claimed, owner_email, org_id, agent_name, agent_url, dedupe_key, a2a_task_id, a2a_auth_token,\n status, attempts, next_check_at, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n args: [\n id,\n input.integrationTaskId,\n input.platform,\n input.externalThreadId,\n payload,\n input.placeholderRef ?? null,\n null,\n 0,\n input.ownerEmail,\n input.orgId ?? null,\n input.agentName,\n input.agentUrl,\n input.dedupeKey ?? null,\n input.a2aTaskId,\n input.a2aAuthToken ?? null,\n \"pending\",\n 0,\n now,\n now,\n now,\n ],\n });\n } catch (err: any) {\n if (!isDuplicateContinuationError(err)) throw err;\n const existing = await findA2AContinuation(\n input.integrationTaskId,\n input.agentUrl,\n input.a2aTaskId,\n );\n if (existing) {\n // A retry can reach this row after the original invocation created it\n // without a resumable progress surface (or with one that has gone\n // stale). Keep the most recent valid adapter reference for active work,\n // but never resurrect short-lived delivery state after a terminal row\n // has deliberately scrubbed it.\n if (\n progressRef &&\n existing.status !== \"completed\" &&\n existing.status !== \"failed\"\n ) {\n if (existing.progressRefClaimed) {\n if (JSON.stringify(existing.progressRef) !== progressRef) {\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET progress_ref = ?, updated_at = ?\n WHERE id = ? AND status NOT IN ('completed', 'failed')\n AND progress_ref_claimed = 1\n AND (progress_ref IS NULL OR progress_ref <> ?)`,\n args: [progressRef, now, existing.id, progressRef],\n });\n }\n } else {\n await claimA2AContinuationProgressRef(existing.id, progressRef);\n }\n return (await getA2AContinuation(existing.id)) ?? existing;\n }\n return existing;\n }\n throw err;\n }\n\n if (progressRef) {\n await claimA2AContinuationProgressRef(id, progressRef);\n }\n return (await getA2AContinuation(id))!;\n}\n\n/**\n * A native platform stream has one terminal completion. Claim it for a single\n * downstream continuation, and retain the ownership marker after terminal\n * cleanup scrubs the short-lived stream reference. The partial unique index\n * makes concurrent downstream inserts safe across processes.\n */\nasync function claimA2AContinuationProgressRef(\n id: string,\n progressRef: string,\n): Promise<void> {\n try {\n await getDbExec().execute({\n sql: `UPDATE integration_a2a_continuations\n SET progress_ref = ?, progress_ref_claimed = 1\n WHERE id = ? AND progress_ref_claimed = 0`,\n args: [progressRef, id],\n });\n } catch (err) {\n // A sibling continuation already owns this stream and will finalize it.\n // This continuation still delivers through the normal response path.\n if (isDuplicateContinuationError(err)) return;\n throw err;\n }\n}\n\nexport async function getA2AContinuationForIntegrationTask(\n integrationTaskId: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const { rows } = await client.execute({\n sql: `SELECT * FROM integration_a2a_continuations\n WHERE integration_task_id = ?\n ORDER BY created_at ASC\n LIMIT 1`,\n args: [integrationTaskId],\n });\n return rows[0] ? rowToContinuation(rows[0] as Record<string, unknown>) : null;\n}\n\nexport async function getA2AContinuationsForIntegrationTaskAgent(\n integrationTaskId: string,\n agentUrl: string,\n dedupeKey?: string | null,\n): Promise<A2AContinuation[]> {\n await ensureTable();\n const client = getDbExec();\n const { rows } = await client.execute(\n dedupeKey\n ? {\n sql: `SELECT * FROM integration_a2a_continuations\n WHERE integration_task_id = ? AND agent_url = ? AND dedupe_key = ?\n ORDER BY created_at ASC`,\n args: [integrationTaskId, agentUrl, dedupeKey],\n }\n : {\n sql: `SELECT * FROM integration_a2a_continuations\n WHERE integration_task_id = ? AND agent_url = ?\n ORDER BY created_at ASC`,\n args: [integrationTaskId, agentUrl],\n },\n );\n return rows.map((row) => rowToContinuation(row as Record<string, unknown>));\n}\n\nfunction isDuplicateContinuationError(err: unknown): boolean {\n const e = err as { code?: string; message?: string } | null;\n if (!e) return false;\n if (e.code === \"23505\") return true;\n const msg = String(e.message ?? \"\").toLowerCase();\n return (\n msg.includes(\"unique\") ||\n msg.includes(\"duplicate entry\") ||\n msg.includes(\"duplicate key\")\n );\n}\n\nasync function findA2AContinuation(\n integrationTaskId: string,\n agentUrl: string,\n a2aTaskId: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const { rows } = await client.execute({\n sql: `SELECT * FROM integration_a2a_continuations\n WHERE integration_task_id = ? AND agent_url = ? AND a2a_task_id = ?\n LIMIT 1`,\n args: [integrationTaskId, agentUrl, a2aTaskId],\n });\n return rows[0] ? rowToContinuation(rows[0] as Record<string, unknown>) : null;\n}\n\nexport async function getA2AContinuation(\n id: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const { rows } = await client.execute({\n sql: `SELECT * FROM integration_a2a_continuations WHERE id = ? LIMIT 1`,\n args: [id],\n });\n return rows[0] ? rowToContinuation(rows[0] as Record<string, unknown>) : null;\n}\n\nexport async function claimA2AContinuation(\n id: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n const processingCutoff = now - PROCESSING_STUCK_AFTER_MS;\n const staleNextCheckCutoff = now - PROCESSING_NEXT_CHECK_STALE_AFTER_MS;\n const result = await client.execute({\n sql: isPostgres()\n ? `UPDATE integration_a2a_continuations\n SET status = ?, attempts = attempts + 1, updated_at = ?\n WHERE id = ?\n AND (\n status = 'pending'\n OR (\n status = 'processing'\n AND (updated_at <= ? OR next_check_at <= ?)\n )\n )\n RETURNING *`\n : `UPDATE integration_a2a_continuations\n SET status = ?, attempts = attempts + 1, updated_at = ?\n WHERE id = ?\n AND (\n status = 'pending'\n OR (\n status = 'processing'\n AND (updated_at <= ? OR next_check_at <= ?)\n )\n )`,\n args: [\"processing\", now, id, processingCutoff, staleNextCheckCutoff],\n });\n const rows = result.rows ?? [];\n if (isPostgres()) {\n return rows[0]\n ? rowToContinuation(rows[0] as Record<string, unknown>)\n : null;\n }\n const affected = (result as any)?.rowsAffected ?? (result as any)?.rowCount;\n if (affected === 0) return null;\n const fetched = await getA2AContinuation(id);\n if (!fetched || fetched.status !== \"processing\") return null;\n return fetched;\n}\n\nexport async function claimDueA2AContinuations(\n limit = 5,\n): Promise<A2AContinuation[]> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n const processingCutoff = now - PROCESSING_STUCK_AFTER_MS;\n const staleNextCheckCutoff = now - PROCESSING_NEXT_CHECK_STALE_AFTER_MS;\n // If a processor dies while holding a delivery claim, retry the final send.\n // The stale cutoff preserves the in-flight delivery guard while keeping\n // final integration replies at-least-once.\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, next_check_at = ?, updated_at = ?\n WHERE status = 'delivering' AND updated_at <= ?`,\n args: [\"pending\", now, now, now - 5 * 60 * 1000],\n });\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, next_check_at = ?, updated_at = ?\n WHERE status = 'processing'\n AND (updated_at <= ? OR next_check_at <= ?)`,\n args: [\"pending\", now, now, processingCutoff, staleNextCheckCutoff],\n });\n const { rows } = await client.execute({\n sql: `SELECT id FROM integration_a2a_continuations\n WHERE status = 'pending' AND next_check_at <= ?\n ORDER BY next_check_at ASC\n LIMIT ?`,\n args: [now, limit],\n });\n const claimed: A2AContinuation[] = [];\n for (const row of rows) {\n const continuation = await claimA2AContinuation(row.id as string);\n if (continuation) claimed.push(continuation);\n }\n return claimed;\n}\n\nexport async function claimA2AContinuationDelivery(\n id: string,\n): Promise<A2AContinuation | null> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n const result = await client.execute({\n sql: isPostgres()\n ? `UPDATE integration_a2a_continuations\n SET status = ?, updated_at = ?\n WHERE id = ? AND status = 'processing'\n RETURNING *`\n : `UPDATE integration_a2a_continuations\n SET status = ?, updated_at = ?\n WHERE id = ? AND status = 'processing'`,\n args: [\"delivering\", now, id],\n });\n const rows = result.rows ?? [];\n if (isPostgres()) {\n return rows[0]\n ? rowToContinuation(rows[0] as Record<string, unknown>)\n : null;\n }\n const affected = (result as any)?.rowsAffected ?? (result as any)?.rowCount;\n if (affected === 0) return null;\n const fetched = await getA2AContinuation(id);\n if (!fetched || fetched.status !== \"delivering\") return null;\n return fetched;\n}\n\nexport async function rescheduleA2AContinuation(\n id: string,\n delayMs: number,\n): Promise<void> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, next_check_at = ?, updated_at = ?\n WHERE id = ? AND status IN ('processing', 'delivering')`,\n args: [\"pending\", now + delayMs, now, id],\n });\n}\n\nexport async function completeA2AContinuation(id: string): Promise<void> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, updated_at = ?, completed_at = ?,\n incoming_payload = ?, a2a_auth_token = NULL, progress_ref = NULL\n WHERE id = ? AND status IN ('processing', 'delivering', 'completed')`,\n args: [\"completed\", now, now, \"{}\", id],\n });\n}\n\nexport async function failA2AContinuation(\n id: string,\n errorMessage: string,\n): Promise<void> {\n await ensureTable();\n const client = getDbExec();\n const now = Date.now();\n await client.execute({\n sql: `UPDATE integration_a2a_continuations\n SET status = ?, updated_at = ?, error_message = ?,\n incoming_payload = ?, a2a_auth_token = NULL, progress_ref = NULL\n WHERE id = ? AND status <> 'completed'`,\n args: [\"failed\", now, errorMessage.slice(0, 2000), \"{}\", id],\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../../src/integrations/adapters/slack.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAOhB,MAAM,aAAa,CAAC;AAarB,MAAM,WAAW,mBAAmB;IAClC,8DAA8D;IAC9D,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7E,kEAAkE;IAClE,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,GAAE,mBAAwB,GAChC,eAAe,CA8ejB"}
1
+ {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../../src/integrations/adapters/slack.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAQhB,MAAM,aAAa,CAAC;AAarB,MAAM,WAAW,mBAAmB;IAClC,8DAA8D;IAC9D,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7E,kEAAkE;IAClE,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,GAAE,mBAAwB,GAChC,eAAe,CAwfjB"}
@@ -290,6 +290,14 @@ export function slackAdapter(options = {}) {
290
290
  return null;
291
291
  return startSlackRunProgress(token, incoming);
292
292
  },
293
+ async resumeRunProgress(incoming, ref) {
294
+ if (!isSlackStreamProgressRef(ref))
295
+ return null;
296
+ const token = await resolveBotToken(incoming);
297
+ if (!token)
298
+ return null;
299
+ return resumeSlackRunProgress(token, incoming, ref.streamTs);
300
+ },
293
301
  async sendResponse(message, context, opts) {
294
302
  const token = await resolveBotToken(context);
295
303
  if (!token) {
@@ -1049,6 +1057,19 @@ async function postSlackJson(token, method, body) {
1049
1057
  throw new Error(data.error || `${method} failed`);
1050
1058
  return data;
1051
1059
  }
1060
+ function streamFailureCode(error) {
1061
+ const message = error instanceof Error ? error.message.trim() : "";
1062
+ return /^[a-z0-9_:-]{1,80}$/i.test(message) ? message : "unknown";
1063
+ }
1064
+ function streamChunkType(chunk) {
1065
+ const type = chunk.type;
1066
+ return type === "task_update" ||
1067
+ type === "plan_update" ||
1068
+ type === "markdown_text" ||
1069
+ type === "blocks"
1070
+ ? type
1071
+ : "unknown";
1072
+ }
1052
1073
  async function startSlackRunProgress(token, incoming) {
1053
1074
  const channel = incoming.platformContext.channelId;
1054
1075
  const threadTs = incoming.platformContext.threadTs;
@@ -1078,12 +1099,31 @@ async function startSlackRunProgress(token, incoming) {
1078
1099
  ],
1079
1100
  });
1080
1101
  }
1081
- catch {
1102
+ catch (error) {
1103
+ console.warn("[slack] chat.startStream failed; using standard reply", {
1104
+ errorCode: streamFailureCode(error),
1105
+ isDirectMessage: incoming.conversationType === "dm",
1106
+ hasRecipientTeam: Boolean(incoming.tenantId),
1107
+ hasRecipientUser: Boolean(incoming.senderId),
1108
+ });
1082
1109
  return null;
1083
1110
  }
1084
1111
  const streamTs = started.ts;
1085
1112
  if (typeof streamTs !== "string")
1086
1113
  return null;
1114
+ return createSlackRunProgress(token, incoming, channel, threadTs, streamTs);
1115
+ }
1116
+ function isSlackStreamProgressRef(ref) {
1117
+ return (ref.kind === "slack-stream" && /^\d{1,20}\.\d{1,9}$/.test(ref.streamTs));
1118
+ }
1119
+ async function resumeSlackRunProgress(token, incoming, streamTs) {
1120
+ const channel = incoming.platformContext.channelId;
1121
+ const threadTs = incoming.platformContext.threadTs;
1122
+ if (typeof channel !== "string" || typeof threadTs !== "string")
1123
+ return null;
1124
+ return createSlackRunProgress(token, incoming, channel, threadTs, streamTs);
1125
+ }
1126
+ function createSlackRunProgress(token, incoming, channel, threadTs, streamTs) {
1087
1127
  const tasks = new Map();
1088
1128
  const toolTaskIds = new Map();
1089
1129
  const agentTaskIds = new Map();
@@ -1101,12 +1141,20 @@ async function startSlackRunProgress(token, incoming) {
1101
1141
  const now = Date.now();
1102
1142
  const write = async (value) => {
1103
1143
  lastWriteAt = Date.now();
1104
- await postSlackJson(token, "chat.appendStream", {
1105
- channel,
1106
- ts: streamTs,
1107
- markdown_text: "Progress updated.",
1108
- chunks: [value],
1109
- }).catch(() => { });
1144
+ try {
1145
+ await postSlackJson(token, "chat.appendStream", {
1146
+ channel,
1147
+ ts: streamTs,
1148
+ markdown_text: "Progress updated.",
1149
+ chunks: [value],
1150
+ });
1151
+ }
1152
+ catch (error) {
1153
+ console.warn("[slack] chat.appendStream failed; progress may be stale", {
1154
+ chunkType: streamChunkType(value),
1155
+ errorCode: streamFailureCode(error),
1156
+ });
1157
+ }
1110
1158
  };
1111
1159
  if (now - lastWriteAt >= 900) {
1112
1160
  await write(chunk);
@@ -1125,6 +1173,7 @@ async function startSlackRunProgress(token, incoming) {
1125
1173
  };
1126
1174
  const taskId = (prefix, explicit) => `${prefix}:${explicit || ++sequence}`.slice(0, 240);
1127
1175
  return {
1176
+ ref: { kind: "slack-stream", streamTs },
1128
1177
  async onEvent(event) {
1129
1178
  if (!cancelControl) {
1130
1179
  const context = getIntegrationRequestContext();