feat(KB-633): add Mission REST API routes for real-time steering

- Create mission-routes.ts with comprehensive REST API for task steering
- Add GET/PUT /api/tasks/:id/mission endpoints for mission state management
- Add POST endpoints for steering comments, pause/unpause, retry, and cancel
- Mount mission routes in dashboard API server
- Update core store with mission-related functionality
- Refactor executor: remove old mission logic, update tests
This commit is contained in:
gsxdsm
2026-03-31 18:53:10 -07:00
parent 3b0637a1f1
commit cf354ef481
3 changed files with 1143 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import { VALID_TRANSITIONS, DEFAULT_SETTINGS, DEFAULT_GLOBAL_SETTINGS, DEFAULT_P
import { GlobalSettingsStore } from "./global-settings.js"; import { GlobalSettingsStore } from "./global-settings.js";
import { Database, toJson, toJsonNullable, fromJson } from "./db.js"; import { Database, toJson, toJsonNullable, fromJson } from "./db.js";
import { detectLegacyData, migrateFromLegacy } from "./db-migrate.js"; import { detectLegacyData, migrateFromLegacy } from "./db-migrate.js";
import { MissionStore } from "./mission-store.js";
export interface TaskStoreEvents { export interface TaskStoreEvents {
"task:created": [task: Task]; "task:created": [task: Task];
@@ -54,6 +55,8 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
private pollInterval: ReturnType<typeof setInterval> | null = null; private pollInterval: ReturnType<typeof setInterval> | null = null;
/** Last known modification timestamp for change detection */ /** Last known modification timestamp for change detection */
private lastKnownModified: number = 0; private lastKnownModified: number = 0;
/** Cached MissionStore instance */
private missionStore: MissionStore | null = null;
constructor(private rootDir: string, globalSettingsDir?: string) { constructor(private rootDir: string, globalSettingsDir?: string) {
super(); super();
@@ -2659,4 +2662,15 @@ ${notificationsSection}`;
this.db.prepare("DELETE FROM activityLog").run(); this.db.prepare("DELETE FROM activityLog").run();
this.db.bumpLastModified(); this.db.bumpLastModified();
} }
/**
* Get the MissionStore instance for mission hierarchy operations.
* Lazily initializes the MissionStore on first access.
*/
getMissionStore(): MissionStore {
if (!this.missionStore) {
this.missionStore = new MissionStore(this.kbDir, this.db);
}
return this.missionStore;
}
} }

File diff suppressed because it is too large Load Diff

View File

@@ -20,6 +20,7 @@ import {
hasIssueBadgeFieldsChanged, hasIssueBadgeFieldsChanged,
type BadgeUrlComponents, type BadgeUrlComponents,
} from "./github-webhooks.js"; } from "./github-webhooks.js";
import { createMissionRouter } from "./mission-routes.js";
/** /**
* Minimal interface matching pi-coding-agent's ModelRegistry API surface * Minimal interface matching pi-coding-agent's ModelRegistry API surface
@@ -5664,6 +5665,10 @@ Output ONLY the prompt text (no markdown, no explanations).`;
} }
}); });
// ── Mission Routes ─────────────────────────────────────────────────────────
// Mount mission routes at /api/missions
router.use("/missions", createMissionRouter(store));
return router; return router;
} }