From 32b46f06253f6f88fcb5cccd0e267918fda03c59 Mon Sep 17 00:00:00 2001 From: Saravana Achu Mac Date: Sat, 4 Apr 2026 13:51:57 -0700 Subject: [PATCH] feat(cowork-service): map enriched checkpoint refs and IPC ids --- .../src/modules/agent-runtime/routes.test.ts | 16 ++++++++-- .../src/modules/agent-runtime/routes.ts | 32 +++++++++++++------ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/services/cowork-service/src/modules/agent-runtime/routes.test.ts b/services/cowork-service/src/modules/agent-runtime/routes.test.ts index 2946f2e9..e55a65d5 100644 --- a/services/cowork-service/src/modules/agent-runtime/routes.test.ts +++ b/services/cowork-service/src/modules/agent-runtime/routes.test.ts @@ -55,6 +55,9 @@ describe('agent runtime routes', () => { currentTaskId: 'task-1', createdAt: '2026-04-04T08:00:00.000Z', updatedAt: '2026-04-04T08:05:00.000Z', + artifactRefs: ['artifact://notelett/note-1'], + memoryRefs: ['memory://mindlyst/memory-1'], + approvalRefs: ['approval://cowork/ap-1'], }, ], }, @@ -69,6 +72,9 @@ describe('agent runtime routes', () => { productId: 'clawcowork', currentTaskId: 'task-1', status: 'active', + artifactRefs: ['artifact://notelett/note-1'], + memoryRefs: ['memory://mindlyst/memory-1'], + approvalRefs: ['approval://cowork/ap-1'], }); }); @@ -82,7 +88,7 @@ describe('agent runtime routes', () => { createdAt: '2026-04-04T08:00:00.000Z', updatedAt: '2026-04-04T08:10:00.000Z', sessionId: 'sess-1', - correlationId: 'corr-1', + eventId: 'evt_cowork_task_task-1', }, ], }, @@ -96,7 +102,7 @@ describe('agent runtime routes', () => { sessionId: 'sess-1', productId: 'clawcowork', status: 'running', - correlationId: 'corr-1', + correlationId: 'evt_cowork_task_task-1', }); }); @@ -226,6 +232,9 @@ describe('agent runtime routes', () => { completed: false, cancelled: false, completed_tool_calls: 2, + artifact_refs: ['artifact://notelett/note-1'], + memory_refs: ['memory://mindlyst/memory-1'], + approval_refs: ['approval://cowork/ap-1'], error: null, }, ], @@ -242,6 +251,9 @@ describe('agent runtime routes', () => { userId: 'demo-user', statusAtCapture: 'queued', resumeToken: 'task-1', + artifactRefs: ['artifact://notelett/note-1'], + memoryRefs: ['memory://mindlyst/memory-1'], + approvalRefs: ['approval://cowork/ap-1'], }); }); diff --git a/services/cowork-service/src/modules/agent-runtime/routes.ts b/services/cowork-service/src/modules/agent-runtime/routes.ts index d4c3e045..d64606ff 100644 --- a/services/cowork-service/src/modules/agent-runtime/routes.ts +++ b/services/cowork-service/src/modules/agent-runtime/routes.ts @@ -79,9 +79,15 @@ function toAgentSession(session: Record, fallbackNow: string): typeof session.currentTaskId === 'string' && session.currentTaskId.length > 0 ? session.currentTaskId : null, - memoryRefs: [], - artifactRefs: [], - approvalRefs: [], + memoryRefs: Array.isArray(session.memoryRefs) + ? session.memoryRefs.filter((value): value is string => typeof value === 'string') + : [], + artifactRefs: Array.isArray(session.artifactRefs) + ? session.artifactRefs.filter((value): value is string => typeof value === 'string') + : [], + approvalRefs: Array.isArray(session.approvalRefs) + ? session.approvalRefs.filter((value): value is string => typeof value === 'string') + : [], dispatchContext: { originSurface: 'desktop', originProductId: PRODUCT_ID, @@ -113,9 +119,11 @@ function toAgentRun(task: Record, fallbackNow: string): AgentRu correlationId: typeof task.correlationId === 'string' ? task.correlationId - : typeof task.id === 'string' - ? task.id - : null, + : typeof task.eventId === 'string' + ? task.eventId + : typeof task.id === 'string' + ? task.id + : null, }); } @@ -285,9 +293,15 @@ function toAgentCheckpoint( statusAtCapture: mapCheckpointStatus(task, checkpoint), currentTaskId: taskId, todoIds: [`todo_${taskId}`], - artifactRefs: [], - memoryRefs: [], - approvalRefs: [], + artifactRefs: Array.isArray(checkpoint.artifact_refs) + ? checkpoint.artifact_refs.filter((value): value is string => typeof value === 'string') + : [], + memoryRefs: Array.isArray(checkpoint.memory_refs) + ? checkpoint.memory_refs.filter((value): value is string => typeof value === 'string') + : [], + approvalRefs: Array.isArray(checkpoint.approval_refs) + ? checkpoint.approval_refs.filter((value): value is string => typeof value === 'string') + : [], dispatchContext: { originSurface: 'desktop', originProductId: PRODUCT_ID,