feat: implement spawn1337 autonomous agent protocol

Add full lifecycle management for spawning autonomous Claude sessions as
screen-based agents. Agents communicate via filesystem message bus, signal
completion via RalphTracker <promise> mechanism, and enforce resource budgets
(tokens, cost, timeout, depth limits).

New files:
- spawn-types.ts: Types, YAML parser, factory functions, serialization
- spawn-detector.ts: Terminal pattern detection for spawn1337 tags
- spawn-orchestrator.ts: Agent lifecycle (spawn, monitor, queue, cleanup)
- spawn-claude-md.ts: CLAUDE.md generator for agent sessions

Modified:
- session.ts: SpawnDetector integration, parent/child tracking
- server.ts: Orchestrator wiring, 11 API endpoints, SSE events
- types.ts: Re-exports, SessionState additions

Tests: 80 new tests across 3 test files (all passing)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-23 10:20:37 +01:00
co-authored by Claude Opus 4.5
parent 33a8febf30
commit 1705b7a67d
11 changed files with 3591 additions and 2 deletions
+22
View File
@@ -82,6 +82,10 @@ export interface SessionState {
ralphEnabled?: boolean;
/** Ralph completion phrase (if set) */
ralphCompletionPhrase?: string;
/** Parent agent ID if this session is a spawned agent */
parentAgentId?: string;
/** Child agent IDs spawned by this session */
childAgentIds?: string[];
}
// ========== Task Types ==========
@@ -722,3 +726,21 @@ export function getErrorMessage(error: unknown): string {
}
return 'An unknown error occurred';
}
// ========== Spawn1337 Protocol Re-exports ==========
export type {
SpawnPriority,
SpawnResultDelivery,
SpawnStatus,
SpawnTaskSpec,
SpawnTask,
AgentProgress,
SpawnResult,
SpawnMessage,
AgentStatusReport,
SpawnTrackerState,
SpawnOrchestratorConfig,
AgentContext,
SpawnPersistedState,
} from './spawn-types.js';