( params: CreateAutonomyRunParams, rootDir: string, currentDir: string, )
| 362 | } |
| 363 | |
| 364 | function buildAutonomyRunRecord( |
| 365 | params: CreateAutonomyRunParams, |
| 366 | rootDir: string, |
| 367 | currentDir: string, |
| 368 | ): AutonomyRunRecord { |
| 369 | const createdAt = params.nowMs ?? Date.now() |
| 370 | return { |
| 371 | runId: randomUUID(), |
| 372 | runtime: params.runtime ?? (params.flow ? 'flow_step' : 'automatic'), |
| 373 | trigger: params.trigger, |
| 374 | status: 'queued', |
| 375 | rootDir, |
| 376 | currentDir, |
| 377 | ownerKey: |
| 378 | params.flow?.ownerKey ?? params.ownerKey ?? DEFAULT_AUTONOMY_OWNER_KEY, |
| 379 | ...(params.sourceId ? { sourceId: params.sourceId } : {}), |
| 380 | ...(params.sourceLabel ? { sourceLabel: params.sourceLabel } : {}), |
| 381 | ...(params.flow |
| 382 | ? { |
| 383 | parentFlowId: params.flow.flowId, |
| 384 | parentFlowKey: params.flow.flowKey, |
| 385 | parentFlowSyncMode: params.flow.syncMode, |
| 386 | flowStepId: params.flow.stepId, |
| 387 | flowStepName: params.flow.stepName, |
| 388 | } |
| 389 | : {}), |
| 390 | promptPreview: truncatePromptPreview(params.prompt), |
| 391 | createdAt, |
| 392 | ownerProcessId: process.pid, |
| 393 | ownerSessionId: getSessionId(), |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | async function persistAutonomyRunRecord( |
| 398 | record: AutonomyRunRecord, |
no test coverage detected