(params: {
basePrompt: string
rootDir?: string
currentDir?: string
workload?: string
priority?: 'now' | 'next' | 'later'
shouldCreate?: () => boolean
})
| 1051 | } |
| 1052 | |
| 1053 | export async function createProactiveAutonomyCommands(params: { |
| 1054 | basePrompt: string |
| 1055 | rootDir?: string |
| 1056 | currentDir?: string |
| 1057 | workload?: string |
| 1058 | priority?: 'now' | 'next' | 'later' |
| 1059 | shouldCreate?: () => boolean |
| 1060 | }): Promise<QueuedCommand[]> { |
| 1061 | const rootDir = resolve(params.rootDir ?? getProjectRoot()) |
| 1062 | const currentDir = resolve(params.currentDir ?? getCwd()) |
| 1063 | const prepared = await prepareAutonomyTurnPrompt({ |
| 1064 | basePrompt: params.basePrompt, |
| 1065 | trigger: 'proactive-tick', |
| 1066 | rootDir, |
| 1067 | currentDir, |
| 1068 | }) |
| 1069 | if (params.shouldCreate && !params.shouldCreate()) { |
| 1070 | return [] |
| 1071 | } |
| 1072 | |
| 1073 | const commands: QueuedCommand[] = [ |
| 1074 | await commitAutonomyQueuedPrompt({ |
| 1075 | prepared, |
| 1076 | rootDir, |
| 1077 | currentDir, |
| 1078 | workload: params.workload, |
| 1079 | priority: params.priority, |
| 1080 | }), |
| 1081 | ] |
| 1082 | |
| 1083 | for (const task of prepared.dueHeartbeatTasks) { |
| 1084 | if (task.steps.length === 0) { |
| 1085 | continue |
| 1086 | } |
| 1087 | if (params.shouldCreate && !params.shouldCreate()) { |
| 1088 | break |
| 1089 | } |
| 1090 | const flowCommand = await startManagedAutonomyFlowFromHeartbeatTask({ |
| 1091 | task, |
| 1092 | rootDir, |
| 1093 | currentDir, |
| 1094 | priority: params.priority, |
| 1095 | workload: params.workload, |
| 1096 | }) |
| 1097 | if (flowCommand) { |
| 1098 | commands.push(flowCommand) |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | return commands |
| 1103 | } |
| 1104 | |
| 1105 | export function formatAutonomyRunsStatus(runs: AutonomyRunRecord[]): string { |
| 1106 | const counts = { |
no test coverage detected