mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-06 15:39:41 +02:00
refactor: remove dead code and narrow internal exports (knip sweep)
Knip-driven cleanup. All changes verified with tsc --noEmit, lint, and
build.
Removed (zero consumers):
- VERIFICATION_PROMPT constant + its barrel re-export
- createInitialOrchestratorPersistState factory
- transcriptWatcher singleton export
- createAnsiPatternFull / createAnsiPatternSimple factories
- TimerInfo interface + unused AiCheckResult/AiPlanCheckResult imports
in respawn-controller.ts
- 35 unused Zod z.infer \`*Input\` types in schemas.ts
- Dead re-exports: SessionMode from session.ts, AuthSessionRecord from
web/ports/index.ts, EnhancedPlanTask/CheckpointReview from
ralph-tracker.ts, 7 unused entries in utils/index.ts
- 14 event/config interfaces that lived only as JSDoc hints (no TS type
position usage): Session/Respawn/RalphLoop/RalphTracker/
SessionManager/SessionAutoOps/Subagent/TaskQueue/TaskTracker/
TranscriptWatcher/Image/OrchestratorLoop Events + RespawnPreset +
SessionOutput
Narrowed to module scope (kept but no longer exported):
- buildPermissionArgs in session-cli-builder.ts
- 28 type/interface declarations used only within their own file:
Ai{Idle,Plan}Check{Config,State}, BashToolParser{Events,Config},
FileStream/CreateStream{Options,Result}, PlanSubagentEvent,
SubagentCallback, RalphLoopConfig, RalphLoop{Events,Options},
ActiveTimerInfo, DetectionStatus, ActionLogEntry, AutoOpsCallbacks,
TunnelStatus, Timer/LRUMap/StaleExpirationMap Options, AuthState,
SessionListenerDeps, SseStreamManagerDeps, and 8 more
Docs: CLAUDE.md advice for global-regex `lastIndex` now points to the
remaining `execPattern()` helper instead of the deleted factories.
Knip delta: unused files 42→0, unused exports 161→16, unused types 92→0.
The 16 remaining exports are a mobile-test helper toolkit intentionally
kept for upcoming tests.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -90,7 +90,7 @@ Codeman is a Claude Code session manager with web interface and autonomous Ralph
|
|||||||
- **Single-line prompts only** — `writeViaMux()` sends text+Enter separately; multi-line breaks Ink
|
- **Single-line prompts only** — `writeViaMux()` sends text+Enter separately; multi-line breaks Ink
|
||||||
- **ESM only** — Never `require()`, use `await import()`. `tsx` masks CJS/ESM issues in dev but production breaks
|
- **ESM only** — Never `require()`, use `await import()`. `tsx` masks CJS/ESM issues in dev but production breaks
|
||||||
- **Package ≠ product name** — npm: `aicodeman`, product: **Codeman**. Release renames tags accordingly
|
- **Package ≠ product name** — npm: `aicodeman`, product: **Codeman**. Release renames tags accordingly
|
||||||
- **Global regex `lastIndex`** — Use `createAnsiPatternFull/Simple()` factories, not shared `g`-flag patterns in loops
|
- **Global regex `lastIndex`** — Shared `g`-flag patterns in loops must reset `lastIndex = 0` first, or use the `execPattern()` helper in `utils/regex-patterns.ts` (resets automatically)
|
||||||
|
|
||||||
**Import conventions**: Utils from `./utils`, types from `./types` (barrel), config from specific `./config/*` files.
|
**Import conventions**: Utils from `./utils`, types from `./types` (barrel), config from specific `./config/*` files.
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import {
|
|||||||
|
|
||||||
// ========== Types ==========
|
// ========== Types ==========
|
||||||
|
|
||||||
export type AiIdleCheckConfig = AiCheckerConfigBase;
|
type AiIdleCheckConfig = AiCheckerConfigBase;
|
||||||
|
|
||||||
export type AiCheckVerdict = 'IDLE' | 'WORKING' | 'ERROR';
|
export type AiCheckVerdict = 'IDLE' | 'WORKING' | 'ERROR';
|
||||||
|
|
||||||
|
|||||||
@@ -40,13 +40,13 @@ import {
|
|||||||
|
|
||||||
// ========== Types ==========
|
// ========== Types ==========
|
||||||
|
|
||||||
export type AiPlanCheckConfig = AiCheckerConfigBase;
|
type AiPlanCheckConfig = AiCheckerConfigBase;
|
||||||
|
|
||||||
export type AiPlanCheckVerdict = 'PLAN_MODE' | 'NOT_PLAN_MODE' | 'ERROR';
|
export type AiPlanCheckVerdict = 'PLAN_MODE' | 'NOT_PLAN_MODE' | 'ERROR';
|
||||||
|
|
||||||
export type AiPlanCheckResult = AiCheckerResultBase<AiPlanCheckVerdict>;
|
export type AiPlanCheckResult = AiCheckerResultBase<AiPlanCheckVerdict>;
|
||||||
|
|
||||||
export type AiPlanCheckState = AiCheckerStateBase<AiPlanCheckVerdict>;
|
type AiPlanCheckState = AiCheckerStateBase<AiPlanCheckVerdict>;
|
||||||
|
|
||||||
// ========== Constants ==========
|
// ========== Constants ==========
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ const LOG_FILE_MENTION_PATTERN = /([/~][^\s'"<>|;&\n]*(?:\.log|\.txt|\.out|\/log
|
|||||||
/**
|
/**
|
||||||
* Events emitted by BashToolParser.
|
* Events emitted by BashToolParser.
|
||||||
*/
|
*/
|
||||||
export interface BashToolParserEvents {
|
interface BashToolParserEvents {
|
||||||
/** New Bash tool with file paths started */
|
/** New Bash tool with file paths started */
|
||||||
toolStart: [tool: ActiveBashTool];
|
toolStart: [tool: ActiveBashTool];
|
||||||
/** Bash tool completed */
|
/** Bash tool completed */
|
||||||
@@ -111,7 +111,7 @@ export interface BashToolParserEvents {
|
|||||||
/**
|
/**
|
||||||
* Configuration options for BashToolParser.
|
* Configuration options for BashToolParser.
|
||||||
*/
|
*/
|
||||||
export interface BashToolParserConfig {
|
interface BashToolParserConfig {
|
||||||
/** Session ID this parser belongs to */
|
/** Session ID this parser belongs to */
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
/** Whether the parser is enabled (default: true) */
|
/** Whether the parser is enabled (default: true) */
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const STREAM_INACTIVITY_TIMEOUT_MS = INACTIVITY_TIMEOUT_MS;
|
|||||||
/**
|
/**
|
||||||
* Represents an active file stream.
|
* Represents an active file stream.
|
||||||
*/
|
*/
|
||||||
export interface FileStream {
|
interface FileStream {
|
||||||
/** Unique stream identifier */
|
/** Unique stream identifier */
|
||||||
id: string;
|
id: string;
|
||||||
/** Session this stream belongs to */
|
/** Session this stream belongs to */
|
||||||
@@ -74,7 +74,7 @@ export interface FileStream {
|
|||||||
/**
|
/**
|
||||||
* Options for creating a file stream.
|
* Options for creating a file stream.
|
||||||
*/
|
*/
|
||||||
export interface CreateStreamOptions {
|
interface CreateStreamOptions {
|
||||||
/** Session ID requesting the stream */
|
/** Session ID requesting the stream */
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
/** Path to the file to stream */
|
/** Path to the file to stream */
|
||||||
@@ -94,7 +94,7 @@ export interface CreateStreamOptions {
|
|||||||
/**
|
/**
|
||||||
* Result of creating a stream.
|
* Result of creating a stream.
|
||||||
*/
|
*/
|
||||||
export interface CreateStreamResult {
|
interface CreateStreamResult {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
streamId?: string;
|
streamId?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ import { KeyedDebouncer } from './utils/index.js';
|
|||||||
|
|
||||||
// ========== Types ==========
|
// ========== Types ==========
|
||||||
|
|
||||||
export interface ImageWatcherEvents {
|
|
||||||
'image:detected': (event: ImageDetectedEvent) => void;
|
|
||||||
'image:error': (error: Error, sessionId?: string) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== Constants ==========
|
// ========== Constants ==========
|
||||||
|
|
||||||
/** Supported image file extensions (lowercase) */
|
/** Supported image file extensions (lowercase) */
|
||||||
|
|||||||
@@ -60,21 +60,6 @@ const POST_PHASE_DELAY_MS = 1000;
|
|||||||
// Events
|
// Events
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
export interface OrchestratorLoopEvents {
|
|
||||||
stateChanged: (state: OrchestratorState, prevState: OrchestratorState) => void;
|
|
||||||
planProgress: (phase: string, detail: string) => void;
|
|
||||||
planReady: (plan: OrchestratorPlan) => void;
|
|
||||||
phaseStarted: (phase: OrchestratorPhase) => void;
|
|
||||||
phaseCompleted: (phase: OrchestratorPhase) => void;
|
|
||||||
phaseFailed: (phase: OrchestratorPhase, reason: string) => void;
|
|
||||||
taskAssigned: (task: OrchestratorTask, sessionId: string) => void;
|
|
||||||
taskCompleted: (task: OrchestratorTask) => void;
|
|
||||||
taskFailed: (task: OrchestratorTask, error: string) => void;
|
|
||||||
verificationResult: (phase: OrchestratorPhase, result: VerificationResult) => void;
|
|
||||||
completed: (stats: OrchestratorStats) => void;
|
|
||||||
error: (error: Error) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
// OrchestratorLoop
|
// OrchestratorLoop
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export interface DetailedPlanResult {
|
|||||||
|
|
||||||
export type ProgressCallback = (phase: string, detail: string) => void;
|
export type ProgressCallback = (phase: string, detail: string) => void;
|
||||||
|
|
||||||
export interface PlanSubagentEvent {
|
interface PlanSubagentEvent {
|
||||||
type: 'started' | 'progress' | 'completed' | 'failed';
|
type: 'started' | 'progress' | 'completed' | 'failed';
|
||||||
agentId: string;
|
agentId: string;
|
||||||
agentType: 'research' | 'planner';
|
agentType: 'research' | 'planner';
|
||||||
@@ -80,7 +80,7 @@ export interface PlanSubagentEvent {
|
|||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SubagentCallback = (event: PlanSubagentEvent) => void;
|
type SubagentCallback = (event: PlanSubagentEvent) => void;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// JSON Repair Helper
|
// JSON Repair Helper
|
||||||
|
|||||||
@@ -7,10 +7,4 @@
|
|||||||
|
|
||||||
export { RESEARCH_AGENT_PROMPT } from './research-agent.js';
|
export { RESEARCH_AGENT_PROMPT } from './research-agent.js';
|
||||||
export { PLANNER_PROMPT } from './planner.js';
|
export { PLANNER_PROMPT } from './planner.js';
|
||||||
export {
|
export { PHASE_EXECUTION_PROMPT, TEAM_LEAD_PROMPT, REPLAN_PROMPT, SINGLE_TASK_PROMPT } from './orchestrator.js';
|
||||||
PHASE_EXECUTION_PROMPT,
|
|
||||||
TEAM_LEAD_PROMPT,
|
|
||||||
VERIFICATION_PROMPT,
|
|
||||||
REPLAN_PROMPT,
|
|
||||||
SINGLE_TASK_PROMPT,
|
|
||||||
} from './orchestrator.js';
|
|
||||||
|
|||||||
@@ -57,22 +57,6 @@ Suggested teammate roles:
|
|||||||
Each teammate should focus on their assigned task area. Monitor their progress.
|
Each teammate should focus on their assigned task area. Monitor their progress.
|
||||||
When ALL tasks are complete and you've verified the results, output: <promise>{COMPLETION_PHRASE}</promise>`;
|
When ALL tasks are complete and you've verified the results, output: <promise>{COMPLETION_PHRASE}</promise>`;
|
||||||
|
|
||||||
/**
|
|
||||||
* Verification prompt — asks Claude to verify phase completion.
|
|
||||||
*
|
|
||||||
* Placeholders:
|
|
||||||
* - {PHASE_NAME}: Phase name
|
|
||||||
* - {CRITERIA}: Numbered verification criteria
|
|
||||||
* - {PASS_PHRASE}: Phrase to output on success
|
|
||||||
* - {FAIL_PHRASE}: Phrase to output on failure
|
|
||||||
*/
|
|
||||||
export const VERIFICATION_PROMPT = `Review the work done in "{PHASE_NAME}". Check these criteria:
|
|
||||||
|
|
||||||
{CRITERIA}
|
|
||||||
|
|
||||||
If ALL criteria are met, respond with: {PASS_PHRASE}
|
|
||||||
If ANY criteria fail, respond with: {FAIL_PHRASE} and explain what failed.`;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replan prompt — gives failure context and asks for recovery.
|
* Replan prompt — gives failure context and asks for recovery.
|
||||||
*
|
*
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ const YAML_LINE_PATTERN = /^([a-zA-Z_-]+):\s*"?([^"\n]+)"?\s*$/gm;
|
|||||||
/**
|
/**
|
||||||
* Ralph Loop configuration from .claude/ralph-loop.local.md
|
* Ralph Loop configuration from .claude/ralph-loop.local.md
|
||||||
*/
|
*/
|
||||||
export interface RalphLoopConfig {
|
interface RalphLoopConfig {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
iteration: number;
|
iteration: number;
|
||||||
maxIterations: number | null;
|
maxIterations: number | null;
|
||||||
|
|||||||
+1
-9
@@ -34,19 +34,11 @@ import { RalphLoopStatus, getErrorMessage } from './types.js';
|
|||||||
/**
|
/**
|
||||||
* Events emitted by RalphLoop
|
* Events emitted by RalphLoop
|
||||||
*/
|
*/
|
||||||
export interface RalphLoopEvents {
|
|
||||||
started: () => void;
|
|
||||||
stopped: () => void;
|
|
||||||
taskAssigned: (taskId: string, sessionId: string) => void;
|
|
||||||
taskCompleted: (taskId: string) => void;
|
|
||||||
taskFailed: (taskId: string, error: string) => void;
|
|
||||||
error: (error: Error) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration options for RalphLoop
|
* Configuration options for RalphLoop
|
||||||
*/
|
*/
|
||||||
export interface RalphLoopOptions {
|
interface RalphLoopOptions {
|
||||||
/** How often to check for new tasks (default from config) */
|
/** How often to check for new tasks (default from config) */
|
||||||
pollIntervalMs?: number;
|
pollIntervalMs?: number;
|
||||||
/** Minimum time to run before stopping (null = no minimum) */
|
/** Minimum time to run before stopping (null = no minimum) */
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
* Key exports:
|
* Key exports:
|
||||||
* - `RalphTracker` class — main tracker, extends EventEmitter
|
* - `RalphTracker` class — main tracker, extends EventEmitter
|
||||||
* - `RalphTrackerEvents` interface — typed event map
|
* - `RalphTrackerEvents` interface — typed event map
|
||||||
* - Re-exports: `EnhancedPlanTask`, `CheckpointReview` from ralph-plan-tracker
|
|
||||||
*
|
*
|
||||||
* Key methods: `processData(data)` — feed terminal output, `getState()`,
|
* Key methods: `processData(data)` — feed terminal output, `getState()`,
|
||||||
* `getTodos()`, `getCompletionHistory()`, `getPlanTasks()`, `reset()`
|
* `getTodos()`, `getCompletionHistory()`, `getPlanTasks()`, `reset()`
|
||||||
@@ -66,9 +65,6 @@ import { RalphStallDetector } from './ralph-stall-detector.js';
|
|||||||
import { RalphStatusParser } from './ralph-status-parser.js';
|
import { RalphStatusParser } from './ralph-status-parser.js';
|
||||||
import { STALE_DATA_MAX_AGE_MS, INACTIVITY_TIMEOUT_MS } from './config/server-timing.js';
|
import { STALE_DATA_MAX_AGE_MS, INACTIVITY_TIMEOUT_MS } from './config/server-timing.js';
|
||||||
|
|
||||||
// Re-export sub-module types for backward compatibility
|
|
||||||
export type { EnhancedPlanTask, CheckpointReview } from './ralph-plan-tracker.js';
|
|
||||||
|
|
||||||
// ========== Configuration Constants ==========
|
// ========== Configuration Constants ==========
|
||||||
// Note: MAX_TODOS_PER_SESSION and MAX_LINE_BUFFER_SIZE are imported from config modules
|
// Note: MAX_TODOS_PER_SESSION and MAX_LINE_BUFFER_SIZE are imported from config modules
|
||||||
|
|
||||||
@@ -390,32 +386,6 @@ const P2_PRIORITY_PATTERNS = [
|
|||||||
* @event circuitBreakerUpdate - Fired when circuit breaker state changes
|
* @event circuitBreakerUpdate - Fired when circuit breaker state changes
|
||||||
* @event exitGateMet - Fired when dual-condition exit gate is met
|
* @event exitGateMet - Fired when dual-condition exit gate is met
|
||||||
*/
|
*/
|
||||||
export interface RalphTrackerEvents {
|
|
||||||
/** Emitted when loop state changes */
|
|
||||||
loopUpdate: (state: RalphTrackerState) => void;
|
|
||||||
/** Emitted when todo list is modified */
|
|
||||||
todoUpdate: (todos: RalphTodoItem[]) => void;
|
|
||||||
/** Emitted when completion phrase detected (loop finished) */
|
|
||||||
completionDetected: (phrase: string) => void;
|
|
||||||
/** Emitted when tracker auto-enables from disabled state */
|
|
||||||
enabled: () => void;
|
|
||||||
/** Emitted when a RALPH_STATUS block is parsed */
|
|
||||||
statusBlockDetected: (block: RalphStatusBlock) => void;
|
|
||||||
/** Emitted when circuit breaker state changes */
|
|
||||||
circuitBreakerUpdate: (status: CircuitBreakerStatus) => void;
|
|
||||||
/** Emitted when dual-condition exit gate is met (completion indicators >= 2 AND EXIT_SIGNAL: true) */
|
|
||||||
exitGateMet: (data: { completionIndicators: number; exitSignal: boolean }) => void;
|
|
||||||
/** Emitted when iteration count hasn't changed for an extended period (stall warning) */
|
|
||||||
iterationStallWarning: (data: { iteration: number; stallDurationMs: number }) => void;
|
|
||||||
/** Emitted when iteration count hasn't changed for critical period (stall critical) */
|
|
||||||
iterationStallCritical: (data: { iteration: number; stallDurationMs: number }) => void;
|
|
||||||
/** Emitted when a common/risky completion phrase is detected (P1-002) */
|
|
||||||
phraseValidationWarning: (data: {
|
|
||||||
phrase: string;
|
|
||||||
reason: 'common' | 'short' | 'numeric';
|
|
||||||
suggestedPhrase: string;
|
|
||||||
}) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RalphTracker - Parses terminal output to detect Ralph Wiggum loops and todos
|
* RalphTracker - Parses terminal output to detect Ralph Wiggum loops and todos
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
* - `RespawnController` class — state machine, extends EventEmitter
|
* - `RespawnController` class — state machine, extends EventEmitter
|
||||||
* - `RespawnConfig` interface — all configuration options
|
* - `RespawnConfig` interface — all configuration options
|
||||||
* - `RespawnState` type — union of all state machine states
|
* - `RespawnState` type — union of all state machine states
|
||||||
* - `DetectionStatus`, `ActiveTimerInfo`, `RespawnEvents` — status/event types
|
* - `DetectionStatus`, `ActiveTimerInfo` — status types
|
||||||
*
|
*
|
||||||
* Key methods: `start()`, `stop()`, `getStatus()`, `getConfig()`,
|
* Key methods: `start()`, `stop()`, `getStatus()`, `getConfig()`,
|
||||||
* `getDetectionStatus()`, `getActiveTimers()`, `getAggregateMetrics()`,
|
* `getDetectionStatus()`, `getActiveTimers()`, `getAggregateMetrics()`,
|
||||||
@@ -46,8 +46,8 @@
|
|||||||
import { EventEmitter } from 'node:events';
|
import { EventEmitter } from 'node:events';
|
||||||
import { randomUUID } from 'node:crypto';
|
import { randomUUID } from 'node:crypto';
|
||||||
import { Session } from './session.js';
|
import { Session } from './session.js';
|
||||||
import { AiIdleChecker, type AiCheckResult, type AiCheckState } from './ai-idle-checker.js';
|
import { AiIdleChecker, type AiCheckState } from './ai-idle-checker.js';
|
||||||
import { AiPlanChecker, type AiPlanCheckResult } from './ai-plan-checker.js';
|
import { AiPlanChecker } from './ai-plan-checker.js';
|
||||||
import type { TeamWatcher } from './team-watcher.js';
|
import type { TeamWatcher } from './team-watcher.js';
|
||||||
import { BufferAccumulator, ANSI_ESCAPE_PATTERN_SIMPLE, assertNever, CleanupManager } from './utils/index.js';
|
import { BufferAccumulator, ANSI_ESCAPE_PATTERN_SIMPLE, assertNever, CleanupManager } from './utils/index.js';
|
||||||
import { MAX_RESPAWN_BUFFER_SIZE, TRIM_RESPAWN_BUFFER_TO as RESPAWN_BUFFER_TRIM_SIZE } from './config/buffer-limits.js';
|
import { MAX_RESPAWN_BUFFER_SIZE, TRIM_RESPAWN_BUFFER_TO as RESPAWN_BUFFER_TRIM_SIZE } from './config/buffer-limits.js';
|
||||||
@@ -99,13 +99,13 @@ const PLAN_MODE_SELECTOR_PATTERN = /[❯>]\s*\d+\./;
|
|||||||
* Each layer provides a confidence signal that Claude has finished working.
|
* Each layer provides a confidence signal that Claude has finished working.
|
||||||
*/
|
*/
|
||||||
/** Active timer info for UI display */
|
/** Active timer info for UI display */
|
||||||
export interface ActiveTimerInfo {
|
interface ActiveTimerInfo {
|
||||||
name: string;
|
name: string;
|
||||||
remainingMs: number;
|
remainingMs: number;
|
||||||
totalMs: number;
|
totalMs: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DetectionStatus {
|
interface DetectionStatus {
|
||||||
/** Layer 0: Stop hook received (highest priority - definitive signal) */
|
/** Layer 0: Stop hook received (highest priority - definitive signal) */
|
||||||
stopHookReceived: boolean;
|
stopHookReceived: boolean;
|
||||||
/** Timestamp when Stop hook was received */
|
/** Timestamp when Stop hook was received */
|
||||||
@@ -488,70 +488,13 @@ export interface RespawnConfig {
|
|||||||
* @event error - Fired on errors
|
* @event error - Fired on errors
|
||||||
* @event log - Fired for debug logging
|
* @event log - Fired for debug logging
|
||||||
*/
|
*/
|
||||||
/** Timer info for countdown display */
|
|
||||||
export interface TimerInfo {
|
|
||||||
name: string;
|
|
||||||
durationMs: number;
|
|
||||||
endsAt: number;
|
|
||||||
reason?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Action log entry for detailed UI feedback */
|
/** Action log entry for detailed UI feedback */
|
||||||
export interface ActionLogEntry {
|
interface ActionLogEntry {
|
||||||
type: string;
|
type: string;
|
||||||
detail: string;
|
detail: string;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RespawnEvents {
|
|
||||||
/** State machine transition */
|
|
||||||
stateChanged: (state: RespawnState, prevState: RespawnState) => void;
|
|
||||||
/** New respawn cycle started */
|
|
||||||
respawnCycleStarted: (cycleNumber: number) => void;
|
|
||||||
/** Respawn cycle finished */
|
|
||||||
respawnCycleCompleted: (cycleNumber: number) => void;
|
|
||||||
/** Command sent to session */
|
|
||||||
stepSent: (step: string, input: string) => void;
|
|
||||||
/** Step completed (ready indicator detected) */
|
|
||||||
stepCompleted: (step: string) => void;
|
|
||||||
/** Detection status update for UI display */
|
|
||||||
detectionUpdate: (status: DetectionStatus) => void;
|
|
||||||
/** Auto-accept sent for plan mode approval */
|
|
||||||
autoAcceptSent: () => void;
|
|
||||||
/** AI idle check started */
|
|
||||||
aiCheckStarted: () => void;
|
|
||||||
/** AI idle check completed with verdict */
|
|
||||||
aiCheckCompleted: (result: AiCheckResult) => void;
|
|
||||||
/** AI idle check failed */
|
|
||||||
aiCheckFailed: (error: string) => void;
|
|
||||||
/** AI idle check cooldown state changed */
|
|
||||||
aiCheckCooldown: (active: boolean, endsAt: number | null) => void;
|
|
||||||
/** AI plan check started */
|
|
||||||
planCheckStarted: () => void;
|
|
||||||
/** AI plan check completed with verdict */
|
|
||||||
planCheckCompleted: (result: AiPlanCheckResult) => void;
|
|
||||||
/** AI plan check failed */
|
|
||||||
planCheckFailed: (error: string) => void;
|
|
||||||
/** Timer started for countdown display */
|
|
||||||
timerStarted: (timer: TimerInfo) => void;
|
|
||||||
/** Timer cancelled */
|
|
||||||
timerCancelled: (timerName: string, reason?: string) => void;
|
|
||||||
/** Timer completed */
|
|
||||||
timerCompleted: (timerName: string) => void;
|
|
||||||
/** Verbose action log for detailed UI feedback */
|
|
||||||
actionLog: (action: ActionLogEntry) => void;
|
|
||||||
/** Error occurred */
|
|
||||||
error: (error: Error) => void;
|
|
||||||
/** Debug log message */
|
|
||||||
log: (message: string) => void;
|
|
||||||
/** Stuck state warning emitted */
|
|
||||||
stuckStateWarning: (state: RespawnState, durationMs: number) => void;
|
|
||||||
/** Stuck state recovery triggered */
|
|
||||||
stuckStateRecovery: (state: RespawnState, durationMs: number, attempt: number) => void;
|
|
||||||
/** Respawn blocked by external signal */
|
|
||||||
respawnBlocked: (data: { reason: string; details: string }) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert milliseconds to a non-negative whole number of seconds for countdown display.
|
* Convert milliseconds to a non-negative whole number of seconds for countdown display.
|
||||||
* Rounds up so that e.g. 1200 ms shows as 2 s (never under-reports remaining time).
|
* Rounds up so that e.g. 1200 ms shows as 2 s (never under-reports remaining time).
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ const DEFAULT_AUTO_COMPACT_THRESHOLD = 110_000;
|
|||||||
/**
|
/**
|
||||||
* Callbacks required by SessionAutoOps to interact with the parent Session.
|
* Callbacks required by SessionAutoOps to interact with the parent Session.
|
||||||
*/
|
*/
|
||||||
export interface AutoOpsCallbacks {
|
interface AutoOpsCallbacks {
|
||||||
/** Send a command via the terminal multiplexer */
|
/** Send a command via the terminal multiplexer */
|
||||||
writeCommand: (command: string) => Promise<boolean>;
|
writeCommand: (command: string) => Promise<boolean>;
|
||||||
/** Check if Claude is currently working */
|
/** Check if Claude is currently working */
|
||||||
@@ -109,12 +109,6 @@ export interface AutoOpsCallbacks {
|
|||||||
/**
|
/**
|
||||||
* Events emitted by SessionAutoOps.
|
* Events emitted by SessionAutoOps.
|
||||||
*/
|
*/
|
||||||
export interface SessionAutoOpsEvents {
|
|
||||||
/** Auto-compact was triggered and the /compact command was sent */
|
|
||||||
autoCompact: (data: { tokens: number; threshold: number; prompt?: string }) => void;
|
|
||||||
/** Auto-clear was triggered and the /clear command was sent */
|
|
||||||
autoClear: (data: { tokens: number; threshold: number }) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages auto-compact and auto-clear automation for a Session.
|
* Manages auto-compact and auto-clear automation for a Session.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { getAugmentedPath } from './utils/index.js';
|
|||||||
* Build Claude CLI permission flags based on the configured mode.
|
* Build Claude CLI permission flags based on the configured mode.
|
||||||
* Returns an array of args to pass to the CLI.
|
* Returns an array of args to pass to the CLI.
|
||||||
*/
|
*/
|
||||||
export function buildPermissionArgs(claudeMode: ClaudeMode, allowedTools?: string): string[] {
|
function buildPermissionArgs(claudeMode: ClaudeMode, allowedTools?: string): string[] {
|
||||||
switch (claudeMode) {
|
switch (claudeMode) {
|
||||||
case 'dangerously-skip-permissions':
|
case 'dangerously-skip-permissions':
|
||||||
return ['--dangerously-skip-permissions'];
|
return ['--dangerously-skip-permissions'];
|
||||||
|
|||||||
@@ -30,18 +30,6 @@ import { SessionState } from './types.js';
|
|||||||
/**
|
/**
|
||||||
* Events emitted by SessionManager
|
* Events emitted by SessionManager
|
||||||
*/
|
*/
|
||||||
export interface SessionManagerEvents {
|
|
||||||
/** Fired when a new session starts successfully */
|
|
||||||
sessionStarted: (session: Session) => void;
|
|
||||||
/** Fired when a session stops (graceful or forced) */
|
|
||||||
sessionStopped: (sessionId: string) => void;
|
|
||||||
/** Fired when a session encounters an error */
|
|
||||||
sessionError: (sessionId: string, error: string) => void;
|
|
||||||
/** Fired when a session produces terminal output */
|
|
||||||
sessionOutput: (sessionId: string, output: string) => void;
|
|
||||||
/** Fired when a completion phrase is detected */
|
|
||||||
sessionCompletion: (sessionId: string, phrase: string) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages multiple Claude sessions with lifecycle coordination.
|
* Manages multiple Claude sessions with lifecycle coordination.
|
||||||
|
|||||||
@@ -154,63 +154,6 @@ export interface ClaudeMessage {
|
|||||||
* Event signatures emitted by the Session class.
|
* Event signatures emitted by the Session class.
|
||||||
* Subscribe using `session.on('eventName', handler)`.
|
* Subscribe using `session.on('eventName', handler)`.
|
||||||
*/
|
*/
|
||||||
export interface SessionEvents {
|
|
||||||
/** Processed text output (ANSI stripped) */
|
|
||||||
output: (data: string) => void;
|
|
||||||
/** Parsed JSON message from Claude CLI */
|
|
||||||
message: (msg: ClaudeMessage) => void;
|
|
||||||
/** Error output from the session */
|
|
||||||
error: (data: string) => void;
|
|
||||||
/** Session process exited */
|
|
||||||
exit: (code: number | null) => void;
|
|
||||||
/** One-shot prompt completed with result and cost */
|
|
||||||
completion: (result: string, cost: number) => void;
|
|
||||||
/** Raw terminal data (includes ANSI codes) */
|
|
||||||
terminal: (data: string) => void;
|
|
||||||
/** Signal to clear terminal display (after mux attach) */
|
|
||||||
clearTerminal: () => void;
|
|
||||||
/** New background task started */
|
|
||||||
taskCreated: (task: BackgroundTask) => void;
|
|
||||||
/** Background task status changed */
|
|
||||||
taskUpdated: (task: BackgroundTask) => void;
|
|
||||||
/** Background task finished successfully */
|
|
||||||
taskCompleted: (task: BackgroundTask) => void;
|
|
||||||
/** Background task failed with error */
|
|
||||||
taskFailed: (task: BackgroundTask, error: string) => void;
|
|
||||||
/** Auto-clear triggered due to token threshold */
|
|
||||||
autoClear: (data: { tokens: number; threshold: number }) => void;
|
|
||||||
/** Auto-compact triggered due to token threshold */
|
|
||||||
autoCompact: (data: { tokens: number; threshold: number; prompt?: string }) => void;
|
|
||||||
/** Ralph loop state changed */
|
|
||||||
ralphLoopUpdate: (state: RalphTrackerState) => void;
|
|
||||||
/** Ralph todo list updated */
|
|
||||||
ralphTodoUpdate: (todos: RalphTodoItem[]) => void;
|
|
||||||
/** Ralph completion phrase detected */
|
|
||||||
ralphCompletionDetected: (phrase: string) => void;
|
|
||||||
/** RALPH_STATUS block detected */
|
|
||||||
ralphStatusBlockDetected: (block: import('./types.js').RalphStatusBlock) => void;
|
|
||||||
/** Circuit breaker state changed */
|
|
||||||
ralphCircuitBreakerUpdate: (status: import('./types.js').CircuitBreakerStatus) => void;
|
|
||||||
/** Dual-condition exit gate met */
|
|
||||||
ralphExitGateMet: (data: { completionIndicators: number; exitSignal: boolean }) => void;
|
|
||||||
/** Bash tool with file paths started */
|
|
||||||
bashToolStart: (tool: ActiveBashTool) => void;
|
|
||||||
/** Bash tool completed */
|
|
||||||
bashToolEnd: (tool: ActiveBashTool) => void;
|
|
||||||
/** Active Bash tools list updated */
|
|
||||||
bashToolsUpdate: (tools: ActiveBashTool[]) => void;
|
|
||||||
/** CLI info (version, model, account) updated */
|
|
||||||
cliInfoUpdated: (info: {
|
|
||||||
version: string | null;
|
|
||||||
model: string | null;
|
|
||||||
accountType: string | null;
|
|
||||||
latestVersion: string | null;
|
|
||||||
}) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SessionMode is imported from types.ts (single source of truth)
|
|
||||||
// Re-export for backwards compatibility with any external consumers
|
|
||||||
export type { SessionMode } from './types.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core session class that wraps a PTY process running Claude CLI or a shell.
|
* Core session class that wraps a PTY process running Claude CLI or a shell.
|
||||||
|
|||||||
@@ -134,17 +134,6 @@ export interface SubagentToolResult {
|
|||||||
isError: boolean; // Whether result is an error
|
isError: boolean; // Whether result is an error
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SubagentEvents {
|
|
||||||
'subagent:discovered': (info: SubagentInfo) => void;
|
|
||||||
'subagent:updated': (info: SubagentInfo) => void;
|
|
||||||
'subagent:tool_call': (data: SubagentToolCall) => void;
|
|
||||||
'subagent:tool_result': (data: SubagentToolResult) => void;
|
|
||||||
'subagent:progress': (data: SubagentProgress) => void;
|
|
||||||
'subagent:message': (data: SubagentMessage) => void;
|
|
||||||
'subagent:completed': (info: SubagentInfo) => void;
|
|
||||||
'subagent:error': (error: Error, agentId?: string) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== Constants ==========
|
// ========== Constants ==========
|
||||||
|
|
||||||
const CLAUDE_PROJECTS_DIR = join(homedir(), '.claude/projects');
|
const CLAUDE_PROJECTS_DIR = join(homedir(), '.claude/projects');
|
||||||
|
|||||||
@@ -17,14 +17,6 @@ import { getStore } from './state-store.js';
|
|||||||
/**
|
/**
|
||||||
* Events emitted by TaskQueue
|
* Events emitted by TaskQueue
|
||||||
*/
|
*/
|
||||||
export interface TaskQueueEvents {
|
|
||||||
/** Fired when a task is added to the queue */
|
|
||||||
taskAdded: (task: Task) => void;
|
|
||||||
/** Fired when a task is removed from the queue */
|
|
||||||
taskRemoved: (taskId: string) => void;
|
|
||||||
/** Fired when a task's state changes */
|
|
||||||
taskUpdated: (task: Task) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Priority queue for managing tasks with dependency support.
|
* Priority queue for managing tasks with dependency support.
|
||||||
|
|||||||
@@ -153,16 +153,6 @@ export interface BackgroundTask {
|
|||||||
* @event taskCompleted - Task finished successfully
|
* @event taskCompleted - Task finished successfully
|
||||||
* @event taskFailed - Task finished with error
|
* @event taskFailed - Task finished with error
|
||||||
*/
|
*/
|
||||||
export interface TaskTrackerEvents {
|
|
||||||
/** New task created */
|
|
||||||
taskCreated: (task: BackgroundTask) => void;
|
|
||||||
/** Task state updated */
|
|
||||||
taskUpdated: (task: BackgroundTask) => void;
|
|
||||||
/** Task completed successfully */
|
|
||||||
taskCompleted: (task: BackgroundTask) => void;
|
|
||||||
/** Task failed with error */
|
|
||||||
taskFailed: (task: BackgroundTask, error: string) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TaskTracker - Detects and tracks background tasks in Claude Code sessions.
|
* TaskTracker - Detects and tracks background tasks in Claude Code sessions.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { createInterface } from 'node:readline';
|
|||||||
/**
|
/**
|
||||||
* Parsed transcript entry from the JSONL file
|
* Parsed transcript entry from the JSONL file
|
||||||
*/
|
*/
|
||||||
export interface TranscriptEntry {
|
interface TranscriptEntry {
|
||||||
type: 'user' | 'assistant' | 'system' | 'result';
|
type: 'user' | 'assistant' | 'system' | 'result';
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
message?: {
|
message?: {
|
||||||
@@ -35,7 +35,7 @@ export interface TranscriptEntry {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TranscriptContentBlock {
|
interface TranscriptContentBlock {
|
||||||
type: 'text' | 'tool_use' | 'tool_result';
|
type: 'text' | 'tool_use' | 'tool_result';
|
||||||
text?: string;
|
text?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
@@ -68,15 +68,6 @@ export interface TranscriptState {
|
|||||||
lastUpdateAt: string | null;
|
lastUpdateAt: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TranscriptWatcherEvents {
|
|
||||||
'transcript:update': (state: TranscriptState) => void;
|
|
||||||
'transcript:complete': (state: TranscriptState) => void;
|
|
||||||
'transcript:tool_start': (toolName: string) => void;
|
|
||||||
'transcript:tool_end': (toolName: string, isError: boolean) => void;
|
|
||||||
'transcript:error': (error: Error) => void;
|
|
||||||
'transcript:plan_mode': () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== Constants ==========
|
// ========== Constants ==========
|
||||||
|
|
||||||
/** How often to check for new content when file watching fails */
|
/** How often to check for new content when file watching fails */
|
||||||
@@ -435,7 +426,3 @@ export class TranscriptWatcher extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Singleton Export ==========
|
|
||||||
|
|
||||||
export const transcriptWatcher = new TranscriptWatcher();
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import { getErrorMessage } from './types.js';
|
|||||||
|
|
||||||
// ========== Types ==========
|
// ========== Types ==========
|
||||||
|
|
||||||
export interface TunnelStatus {
|
interface TunnelStatus {
|
||||||
running: boolean;
|
running: boolean;
|
||||||
url: string | null;
|
url: string | null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,18 +268,3 @@ export function createInitialOrchestratorStats(): OrchestratorStats {
|
|||||||
replanCount: 0,
|
replanCount: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Factory function for initial orchestrator persist state */
|
|
||||||
export function createInitialOrchestratorPersistState(
|
|
||||||
config: OrchestratorConfig = DEFAULT_ORCHESTRATOR_CONFIG
|
|
||||||
): OrchestratorPersistState {
|
|
||||||
return {
|
|
||||||
state: 'idle',
|
|
||||||
plan: null,
|
|
||||||
currentPhaseIndex: 0,
|
|
||||||
startedAt: null,
|
|
||||||
completedAt: null,
|
|
||||||
config,
|
|
||||||
stats: createInitialOrchestratorStats(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -230,22 +230,6 @@ export interface TimingHistory {
|
|||||||
/**
|
/**
|
||||||
* Named respawn configuration preset for quick setup
|
* Named respawn configuration preset for quick setup
|
||||||
*/
|
*/
|
||||||
export interface RespawnPreset {
|
|
||||||
/** Unique preset identifier */
|
|
||||||
id: string;
|
|
||||||
/** User-friendly preset name */
|
|
||||||
name: string;
|
|
||||||
/** Description of when to use this preset */
|
|
||||||
description?: string;
|
|
||||||
/** The respawn configuration (without enabled flag) */
|
|
||||||
config: Omit<RespawnConfig, 'enabled'>;
|
|
||||||
/** Duration in minutes (optional default) */
|
|
||||||
durationMinutes?: number;
|
|
||||||
/** Whether this is a built-in preset */
|
|
||||||
builtIn?: boolean;
|
|
||||||
/** Timestamp when created */
|
|
||||||
createdAt: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persisted respawn configuration for mux sessions.
|
* Persisted respawn configuration for mux sessions.
|
||||||
|
|||||||
@@ -150,11 +150,3 @@ export interface SessionState {
|
|||||||
/**
|
/**
|
||||||
* Output captured from a session
|
* Output captured from a session
|
||||||
*/
|
*/
|
||||||
export interface SessionOutput {
|
|
||||||
/** Standard output content */
|
|
||||||
stdout: string;
|
|
||||||
/** Standard error content */
|
|
||||||
stderr: string;
|
|
||||||
/** Exit code of the process, null if still running */
|
|
||||||
exitCode: number | null;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import type { Disposable, CleanupRegistration, CleanupResourceType } from '../ty
|
|||||||
/**
|
/**
|
||||||
* Options for setTimeout/setInterval with automatic cleanup.
|
* Options for setTimeout/setInterval with automatic cleanup.
|
||||||
*/
|
*/
|
||||||
export interface TimerOptions {
|
interface TimerOptions {
|
||||||
/** Human-readable description for debugging */
|
/** Human-readable description for debugging */
|
||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -7,17 +7,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export { BufferAccumulator } from './buffer-accumulator.js';
|
export { BufferAccumulator } from './buffer-accumulator.js';
|
||||||
export { LRUMap, type LRUMapOptions } from './lru-map.js';
|
export { CleanupManager } from './cleanup-manager.js';
|
||||||
export { CleanupManager, type TimerOptions } from './cleanup-manager.js';
|
|
||||||
export { Debouncer, KeyedDebouncer } from './debouncer.js';
|
export { Debouncer, KeyedDebouncer } from './debouncer.js';
|
||||||
export { StaleExpirationMap, type StaleExpirationMapOptions } from './stale-expiration-map.js';
|
export { StaleExpirationMap } from './stale-expiration-map.js';
|
||||||
export {
|
export {
|
||||||
ANSI_ESCAPE_PATTERN_FULL,
|
ANSI_ESCAPE_PATTERN_FULL,
|
||||||
ANSI_ESCAPE_PATTERN_SIMPLE,
|
ANSI_ESCAPE_PATTERN_SIMPLE,
|
||||||
TOKEN_PATTERN,
|
TOKEN_PATTERN,
|
||||||
SPINNER_PATTERN,
|
SPINNER_PATTERN,
|
||||||
createAnsiPatternFull,
|
|
||||||
createAnsiPatternSimple,
|
|
||||||
stripAnsi,
|
stripAnsi,
|
||||||
SAFE_PATH_PATTERN,
|
SAFE_PATH_PATTERN,
|
||||||
execPattern,
|
execPattern,
|
||||||
@@ -27,4 +24,4 @@ export { stringSimilarity, fuzzyPhraseMatch, todoContentHash } from './string-si
|
|||||||
export { assertNever } from './type-safety.js';
|
export { assertNever } from './type-safety.js';
|
||||||
export { wrapWithNice } from './nice-wrapper.js';
|
export { wrapWithNice } from './nice-wrapper.js';
|
||||||
export { findClaudeDir, getAugmentedPath } from './claude-cli-resolver.js';
|
export { findClaudeDir, getAugmentedPath } from './claude-cli-resolver.js';
|
||||||
export { resolveOpenCodeDir, isOpenCodeAvailable } from './opencode-cli-resolver.js';
|
export { resolveOpenCodeDir } from './opencode-cli-resolver.js';
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
/**
|
/**
|
||||||
* Configuration options for LRUMap.
|
* Configuration options for LRUMap.
|
||||||
*/
|
*/
|
||||||
export interface LRUMapOptions<K, V> {
|
interface LRUMapOptions<K, V> {
|
||||||
/** Maximum number of entries before eviction */
|
/** Maximum number of entries before eviction */
|
||||||
maxSize: number;
|
maxSize: number;
|
||||||
/** Optional callback when an entry is evicted */
|
/** Optional callback when an entry is evicted */
|
||||||
|
|||||||
@@ -40,24 +40,6 @@ export const ANSI_ESCAPE_PATTERN_SIMPLE = /\x1b\[[0-9;]*[A-Za-z]/g;
|
|||||||
*/
|
*/
|
||||||
export const TOKEN_PATTERN = /(\d+(?:\.\d+)?)\s*([kKmM])?\s*tokens/;
|
export const TOKEN_PATTERN = /(\d+(?:\.\d+)?)\s*([kKmM])?\s*tokens/;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a fresh copy of ANSI_ESCAPE_PATTERN_FULL.
|
|
||||||
* Use when you need a pattern without shared lastIndex state.
|
|
||||||
*/
|
|
||||||
export function createAnsiPatternFull(): RegExp {
|
|
||||||
// eslint-disable-next-line no-control-regex
|
|
||||||
return /\x1b(?:\[[0-9;?]*[A-Za-z]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[=>])/g;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a fresh copy of ANSI_ESCAPE_PATTERN_SIMPLE.
|
|
||||||
* Use when you need a pattern without shared lastIndex state.
|
|
||||||
*/
|
|
||||||
export function createAnsiPatternSimple(): RegExp {
|
|
||||||
// eslint-disable-next-line no-control-regex
|
|
||||||
return /\x1b\[[0-9;]*[A-Za-z]/g;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strips ANSI escape codes from text using the comprehensive pattern.
|
* Strips ANSI escape codes from text using the comprehensive pattern.
|
||||||
* @param text - Text containing ANSI escape codes
|
* @param text - Text containing ANSI escape codes
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ interface TimedEntry<V> {
|
|||||||
/**
|
/**
|
||||||
* Configuration options for StaleExpirationMap.
|
* Configuration options for StaleExpirationMap.
|
||||||
*/
|
*/
|
||||||
export interface StaleExpirationMapOptions<K, V> {
|
interface StaleExpirationMapOptions<K, V> {
|
||||||
/** Time-to-live in milliseconds before entries expire */
|
/** Time-to-live in milliseconds before entries expire */
|
||||||
ttlMs: number;
|
ttlMs: number;
|
||||||
/** How often to run cleanup (default: ttlMs / 2) */
|
/** How often to run cleanup (default: ttlMs / 2) */
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
export const AUTH_COOKIE_NAME = 'codeman_session';
|
export const AUTH_COOKIE_NAME = 'codeman_session';
|
||||||
|
|
||||||
/** State returned from registerAuthMiddleware for cleanup in server stop() */
|
/** State returned from registerAuthMiddleware for cleanup in server stop() */
|
||||||
export interface AuthState {
|
interface AuthState {
|
||||||
authSessions: StaleExpirationMap<string, AuthSessionRecord> | null;
|
authSessions: StaleExpirationMap<string, AuthSessionRecord> | null;
|
||||||
authFailures: StaleExpirationMap<string, number> | null;
|
authFailures: StaleExpirationMap<string, number> | null;
|
||||||
qrAuthFailures: StaleExpirationMap<string, number> | null;
|
qrAuthFailures: StaleExpirationMap<string, number> | null;
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ export type { EventPort } from './event-port.js';
|
|||||||
export type { RespawnPort } from './respawn-port.js';
|
export type { RespawnPort } from './respawn-port.js';
|
||||||
export type { ConfigPort } from './config-port.js';
|
export type { ConfigPort } from './config-port.js';
|
||||||
export type { InfraPort, ScheduledRun } from './infra-port.js';
|
export type { InfraPort, ScheduledRun } from './infra-port.js';
|
||||||
export type { AuthPort, AuthSessionRecord } from './auth-port.js';
|
export type { AuthPort } from './auth-port.js';
|
||||||
export type { OrchestratorPort } from './orchestrator-port.js';
|
export type { OrchestratorPort } from './orchestrator-port.js';
|
||||||
|
|||||||
@@ -549,45 +549,6 @@ export const RalphLoopStartSchema = z.object({
|
|||||||
.optional(),
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// ========== Inferred Types ==========
|
|
||||||
|
|
||||||
export type CreateSessionInput = z.infer<typeof CreateSessionSchema>;
|
|
||||||
export type RunPromptInput = z.infer<typeof RunPromptSchema>;
|
|
||||||
export type ResizeInput = z.infer<typeof ResizeSchema>;
|
|
||||||
export type CreateCaseInput = z.infer<typeof CreateCaseSchema>;
|
|
||||||
export type QuickStartInput = z.infer<typeof QuickStartSchema>;
|
|
||||||
export type HookEventInput = z.infer<typeof HookEventSchema>;
|
|
||||||
export type RespawnConfigInput = z.infer<typeof RespawnConfigSchema>;
|
|
||||||
export type ConfigUpdateInput = z.infer<typeof ConfigUpdateSchema>;
|
|
||||||
export type SettingsUpdateInput = z.infer<typeof SettingsUpdateSchema>;
|
|
||||||
export type SessionInputWithLimitInput = z.infer<typeof SessionInputWithLimitSchema>;
|
|
||||||
export type SessionNameInput = z.infer<typeof SessionNameSchema>;
|
|
||||||
export type SessionColorInput = z.infer<typeof SessionColorSchema>;
|
|
||||||
export type RalphConfigInput = z.infer<typeof RalphConfigSchema>;
|
|
||||||
export type FixPlanImportInput = z.infer<typeof FixPlanImportSchema>;
|
|
||||||
export type RalphPromptWriteInput = z.infer<typeof RalphPromptWriteSchema>;
|
|
||||||
export type AutoClearInput = z.infer<typeof AutoClearSchema>;
|
|
||||||
export type AutoCompactInput = z.infer<typeof AutoCompactSchema>;
|
|
||||||
export type ImageWatcherInput = z.infer<typeof ImageWatcherSchema>;
|
|
||||||
export type FlickerFilterInput = z.infer<typeof FlickerFilterSchema>;
|
|
||||||
export type QuickRunInput = z.infer<typeof QuickRunSchema>;
|
|
||||||
export type ScheduledRunInput = z.infer<typeof ScheduledRunSchema>;
|
|
||||||
export type LinkCaseInput = z.infer<typeof LinkCaseSchema>;
|
|
||||||
export type GeneratePlanInput = z.infer<typeof GeneratePlanSchema>;
|
|
||||||
export type GeneratePlanDetailedInput = z.infer<typeof GeneratePlanDetailedSchema>;
|
|
||||||
export type CancelPlanInput = z.infer<typeof CancelPlanSchema>;
|
|
||||||
export type PlanTaskUpdateInput = z.infer<typeof PlanTaskUpdateSchema>;
|
|
||||||
export type PlanTaskAddInput = z.infer<typeof PlanTaskAddSchema>;
|
|
||||||
export type CpuLimitInput = z.infer<typeof CpuLimitSchema>;
|
|
||||||
export type ModelConfigUpdateInput = z.infer<typeof ModelConfigUpdateSchema>;
|
|
||||||
export type SubagentWindowStatesInput = z.infer<typeof SubagentWindowStatesSchema>;
|
|
||||||
export type SubagentParentMapInput = z.infer<typeof SubagentParentMapSchema>;
|
|
||||||
export type InteractiveRespawnInput = z.infer<typeof InteractiveRespawnSchema>;
|
|
||||||
export type RespawnEnableInput = z.infer<typeof RespawnEnableSchema>;
|
|
||||||
export type PushSubscribeInput = z.infer<typeof PushSubscribeSchema>;
|
|
||||||
export type PushPreferencesUpdateInput = z.infer<typeof PushPreferencesUpdateSchema>;
|
|
||||||
export type RalphLoopStartInput = z.infer<typeof RalphLoopStartSchema>;
|
|
||||||
|
|
||||||
// ========== Orchestrator Loop ==========
|
// ========== Orchestrator Loop ==========
|
||||||
|
|
||||||
/** POST /api/orchestrator/start */
|
/** POST /api/orchestrator/start */
|
||||||
@@ -612,6 +573,3 @@ export const OrchestratorStartSchema = z.object({
|
|||||||
export const OrchestratorRejectSchema = z.object({
|
export const OrchestratorRejectSchema = z.object({
|
||||||
feedback: z.string().min(1).max(10000),
|
feedback: z.string().min(1).max(10000),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type OrchestratorStartInput = z.infer<typeof OrchestratorStartSchema>;
|
|
||||||
export type OrchestratorRejectInput = z.infer<typeof OrchestratorRejectSchema>;
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export interface SessionListenerRefs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Dependencies injected by WebServer — keeps listener creation decoupled from server internals. */
|
/** Dependencies injected by WebServer — keeps listener creation decoupled from server internals. */
|
||||||
export interface SessionListenerDeps {
|
interface SessionListenerDeps {
|
||||||
broadcast(event: string, data: unknown): void;
|
broadcast(event: string, data: unknown): void;
|
||||||
batchTerminalData(sessionId: string, data: string): void;
|
batchTerminalData(sessionId: string, data: string): void;
|
||||||
batchTaskUpdate(sessionId: string, task: BackgroundTask): void;
|
batchTaskUpdate(sessionId: string, task: BackgroundTask): void;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
const SSE_PADDING = ':' + 'p'.repeat(SSE_PADDING_SIZE) + '\n';
|
const SSE_PADDING = ':' + 'p'.repeat(SSE_PADDING_SIZE) + '\n';
|
||||||
|
|
||||||
/** Dependencies injected by WebServer — keeps SseStreamManager decoupled from session/respawn state. */
|
/** Dependencies injected by WebServer — keeps SseStreamManager decoupled from session/respawn state. */
|
||||||
export interface SseStreamManagerDeps {
|
interface SseStreamManagerDeps {
|
||||||
/** Get session state with respawn info for session:updated broadcasts */
|
/** Get session state with respawn info for session:updated broadcasts */
|
||||||
getSessionStateWithRespawn(sessionId: string): unknown;
|
getSessionStateWithRespawn(sessionId: string): unknown;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user