feat(cowork-service): map enriched checkpoint refs and IPC ids

This commit is contained in:
Saravana Achu Mac 2026-04-04 13:51:57 -07:00
parent 41673125af
commit 32b46f0625
2 changed files with 37 additions and 11 deletions

View File

@ -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'],
});
});

View File

@ -79,9 +79,15 @@ function toAgentSession(session: Record<string, unknown>, 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<string, unknown>, 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,