refactor(tmux-subagent): split manager and decision-engine into focused modules

Extract session lifecycle, polling, grid planning, and event handling:
- polling.ts: session polling controller with stability detection
- event-handlers.ts: session created/deleted handlers
- grid-planning.ts, spawn-action-decider.ts, spawn-target-finder.ts
- session-status-parser.ts, session-message-count.ts
- cleanup.ts, polling-constants.ts, tmux-grid-constants.ts
This commit is contained in:
YeonGyu-Kim
2026-02-08 16:21:04 +09:00
parent e3bd43ff64
commit f8b5771443
19 changed files with 1080 additions and 763 deletions
@@ -0,0 +1,44 @@
type UnknownRecord = Record<string, unknown>
function isRecord(value: unknown): value is UnknownRecord {
return typeof value === "object" && value !== null
}
function getNestedRecord(value: unknown, key: string): UnknownRecord | undefined {
if (!isRecord(value)) return undefined
const nested = value[key]
return isRecord(nested) ? nested : undefined
}
function getNestedString(value: unknown, key: string): string | undefined {
if (!isRecord(value)) return undefined
const nested = value[key]
return typeof nested === "string" ? nested : undefined
}
export interface SessionCreatedEvent {
type: string
properties?: { info?: { id?: string; parentID?: string; title?: string } }
}
export function coerceSessionCreatedEvent(input: {
type: string
properties?: unknown
}): SessionCreatedEvent {
const properties = isRecord(input.properties) ? input.properties : undefined
const info = getNestedRecord(properties, "info")
return {
type: input.type,
properties:
info || properties
? {
info: {
id: getNestedString(info, "id"),
parentID: getNestedString(info, "parentID"),
title: getNestedString(info, "title"),
},
}
: undefined,
}
}