fix: add projectId to remaining unscoped API functions

- GitHub import functions: apiImportGitHubIssue, apiBatchImportGitHubIssues, apiImportGitHubPull
- Task file operations: fetchFileList, fetchFileContent, saveFileContent
- AI title summarization: summarizeTitle
- Terminal command execution: execTerminalCommand
- Wire projectId through GitHubImportModal, AppModals, useFileBrowser, useFileEditor hooks

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
gsxdsm
2026-04-12 19:34:22 -07:00
parent 30eaa814e6
commit d14cba949b
9 changed files with 664 additions and 59 deletions

View File

@@ -30,6 +30,7 @@ import { SelfHealingManager } from "../self-healing.js";
import { PluginRunner } from "../plugin-runner.js";
import { MissionAutopilot } from "../mission-autopilot.js";
import { MissionExecutionLoop } from "../mission-execution-loop.js";
import { TriageProcessor } from "../triage.js";
/**
* InProcessRuntime runs a project within the main process.
@@ -88,6 +89,7 @@ export class InProcessRuntime
private routineRunner?: RoutineRunner;
private routineScheduler?: RoutineScheduler;
private missionExecutionLoop?: MissionExecutionLoop;
private triageProcessor?: TriageProcessor;
/**
* @param config - Runtime configuration
@@ -218,6 +220,7 @@ export class InProcessRuntime
beforeRequeue: (taskId) => this.selfHealingManager?.checkStuckBudget(taskId) ?? Promise.resolve(true),
onLoopDetected: (event) => this.executor?.handleLoopDetected(event) ?? Promise.resolve(false),
onStuck: (event) => {
this.triageProcessor?.markStuckAborted(event.taskId);
this.executor?.markStuckAborted(event.taskId, event.shouldRequeue);
runtimeLog.warn(
`Task ${event.taskId} stuck (${event.reason}) — ` +
@@ -372,6 +375,29 @@ export class InProcessRuntime
runtimeLog.warn(`AgentStore initialization failed (continuing without agent monitoring):`, agentErr);
}
// 7. Initialize TriageProcessor (task specification)
// Created after AgentStore so per-agent custom instructions are available.
this.triageProcessor = new TriageProcessor(
this.taskStore,
this.config.workingDirectory,
{
semaphore: this.globalSemaphore,
stuckTaskDetector: this.stuckTaskDetector,
agentStore: this.agentStore,
onSpecifyStart: (t) => {
this.recordActivity();
runtimeLog.log(`Specifying ${t.id}...`);
},
onSpecifyComplete: (t) => {
this.recordActivity();
runtimeLog.log(`Specified ${t.id} → todo`);
},
onSpecifyError: (t, e) => {
runtimeLog.error(`Triage failed for ${t.id}: ${e.message}`);
},
},
);
// Initialize RoutineScheduler (requires RoutineStore from FN-1519)
try {
const { RoutineStore: RoutineStoreClass } = await import("@fusion/core");
@@ -430,8 +456,9 @@ export class InProcessRuntime
// SelfHealingManager so the policy lives in one place.
await this.selfHealingManager.runStartupRecovery();
// 11. Start scheduler
// 11. Start scheduler and triage processor
this.scheduler.start();
this.triageProcessor?.start();
// 12. Start MissionExecutionLoop for validation cycle handling
this.missionExecutionLoop = missionExecutionLoop;
@@ -524,7 +551,13 @@ export class InProcessRuntime
runtimeLog.log("HeartbeatMonitor stopped");
}
// 6. Stop scheduler (prevents new task scheduling)
// 6. Stop triage processor (prevents new specifications)
if (this.triageProcessor) {
this.triageProcessor.stop();
runtimeLog.log("TriageProcessor stopped");
}
// 7. Stop scheduler (prevents new task scheduling)
if (this.scheduler) {
this.scheduler.stop();
runtimeLog.log("Scheduler stopped");
@@ -668,6 +701,14 @@ export class InProcessRuntime
return this.routineScheduler;
}
/**
* Get the TriageProcessor instance (if initialized).
* Returns undefined before start() completes.
*/
getTriageProcessor(): TriageProcessor | undefined {
return this.triageProcessor;
}
/**
* Execute a heartbeat run for an agent.
*