MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / legacyPersistedTaskToInfo

Function legacyPersistedTaskToInfo

apps/vis/server/src/lib/task-store.ts:186–213  ·  view source on GitHub ↗
(task: LegacyPersistedTask)

Source from the content-addressed store, hash-verified

184}
185
186function legacyPersistedTaskToInfo(task: LegacyPersistedTask): BackgroundTaskInfo {
187 const status = legacyStatusToCurrent(task);
188 const base = {
189 taskId: task.task_id,
190 description: task.description,
191 status,
192 detached: true,
193 startedAt: task.started_at,
194 endedAt: task.ended_at,
195 stopReason: optionalNonEmptyString(task.stop_reason),
196 timeoutMs: typeof task.timeout_ms === 'number' ? task.timeout_ms : undefined,
197 };
198 if (task.task_id.startsWith('agent-')) {
199 return {
200 ...base,
201 kind: 'agent',
202 agentId: optionalNonEmptyString(task.agent_id),
203 subagentType: optionalNonEmptyString(task.subagent_type),
204 };
205 }
206 return {
207 ...base,
208 kind: 'process',
209 command: task.command,
210 pid: task.pid,
211 exitCode: task.exit_code,
212 };
213}
214
215function legacyStatusToCurrent(task: LegacyPersistedTask): BackgroundTaskStatus {
216 if (task.status === 'awaiting_approval') return 'running';

Callers 1

normalizePersistedTaskFunction · 0.70

Calls 2

legacyStatusToCurrentFunction · 0.70
optionalNonEmptyStringFunction · 0.70

Tested by

no test coverage detected