feat: wire full execution chain — MainAgent→Scheduler→Worker→LLM

Architecture-compliant interactive run command:
- air run: interactive readline loop, user types tasks
- MainAgent classifies (regex + 中文 support)
- Scheduler creates tasks + runs state machine
- DISPATCHING spawns worker processes via WorkerManager
- Workers receive task_spec via agent.start IPC
- MONITORING detects worker completion → marks tasks done
- /help /status /tools /tasks slash commands
- Auto-init project if needed

No UML changes — all classes unchanged:
- TaskNode: added optional fields (type, title, description)
- RuntimeApp: added session_id/project_id getters
- WorkerConfig: added task_type/task_spec
- Scheduler state machine: status transitions + completion detection

Chain: stdin → MainAgent → Scheduler → WorkerManager.spawn()
  → worker main.ts → ExecutorRole → call_llm() IPC → ProviderManager
  → tools via ToolRegistry → result → ProjectionStore → TUI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
AirCoding
2026-06-05 14:16:18 +08:00
parent 459308053c
commit 56a1dd0a7b
5 changed files with 239 additions and 31 deletions

View File

@@ -23,6 +23,8 @@ export interface WorkerConfig {
project_root: string
timeout_ms?: number
env?: Record<string, string>
task_type?: string // DD §8.3: execute/review/debug/compact/mine_experience
task_spec?: Record<string, unknown> // DD §9: TaskSpec payload for worker
}
export interface WorkerHandle {
@@ -106,12 +108,14 @@ export class WorkerManager {
// Wait for handshake: worker.ready
await this.wait_for_handshake(proc, config)
// Validate protocol version
// Validate protocol version and dispatch task
const ready_msg = this.send_and_wait(proc, 'agent.start', {
protocol_version: this.protocol.get_version(),
agent_id: config.agent_id,
session_id: config.session_id,
project_root: config.project_root
project_root: config.project_root,
task_type: config.task_type || 'execute',
task_spec: config.task_spec || { id: `${config.agent_id}_task`, title: 'Execute task', description: '' }
})
handle.state = 'ready'