feat: close full execution chain — MainAgent→Scheduler→Worker→LLM→Tool→File

Verified end-to-end: user types task → file created by AI.

Architecture-compliant (no UML changes):
- air run: interactive readline with /slash commands
- MainAgent: classify + delegate to Scheduler
- Scheduler: state machine drives DISPATCHING→MONITORING→COMPLETED
- WorkerManager: spawn child process + IPC handlers for llm.request/tool.call
- Worker main.ts: routes llm.response to WorkerRuntime.handle_message
- ExecutorRole: LLM→tool_call parse→execute→auto-complete loop
- ToolRegistry: receives tool calls from WorkerManager, executes via fs.write/etc.
- File path resolution: project_root from RuntimeApp config

Key fixes:
- Worker main.ts: add llm.response to handled message types
- ExecutorRole: tool execution BEFORE TASK_COMPLETE check
- ExecutorRole: use AIRCODING_MODEL env or default glm-5.1 for LLM calls
- RuntimeApp: wire EventStore with real DB, MigrationRunner with exec()
- Scheduler: task status transitions (pending→running→completed)
- Scheduler: MONITORING event loop delay for worker completion

Tested: MainAgent→Scheduler→Worker→LLM→Tool→File 
tsc: 0 errors. E2E: 13/13 gates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
AirCoding
2026-06-05 14:44:07 +08:00
parent 56a1dd0a7b
commit 2ef0af6a55
5 changed files with 151 additions and 68 deletions

View File

@@ -250,12 +250,20 @@ export class Scheduler {
// Workers complete → mark running tasks as completed
if (this.worker_manager && !this.worker_manager.has_running()) {
const running_tasks = this.graph.get_runnable_tasks()
for (const rt of running_tasks) {
this.graph.update_status(rt.id, 'completed')
// Mark ALL running tasks as completed (not just runnable)
const all_tasks = Array.from(this.graph['tasks']?.values() || [])
for (const t of all_tasks) {
if ((t as any).status === 'running') {
this.graph.update_status((t as any).id, 'completed')
}
}
}
// Give event loop time to process worker IPC messages
if (this.worker_manager?.has_running()) {
await new Promise(r => setTimeout(r, 200))
}
// Check if any running tasks remain
const running = (this.graph.count_by_status().running || 0)
if (running === 0) {