MCPcopy Create free account
hub / github.com/ByBrawe/opencode-loop / maybeRunDueJobs

Function maybeRunDueJobs

src/index.js:1237–1361  ·  view source on GitHub ↗
(directory, client, sessionID, options = {})

Source from the content-addressed store, hash-verified

1235function goalStatusText(job) {
1236 const status = job?.goalStatus || (isGoalJob(job) ? "active" : "");
1237 if (!status)
1238 return "";
1239 if (status === "completed")
1240 return "completed";
1241 if (status === "blocked")
1242 return "blocked";
1243 if (job?.paused)
1244 return "paused";
1245 return status;
1246}
1247function applyTestfixPreset(job, defaults = {}) {
1248 if (defaults.testfixPreset) {
1249 const defaultCommand = String(defaults.verifyCommand || "npm test");
1250 const parsedAction = String(job.action || "").trim();
1251 const usedDefaultAction = parsedAction === String(defaults.action || "").trim();
1252 if (!usedDefaultAction && job.verifyCommand === defaults.verifyCommand) {
1253 job.verifyCommand = parsedAction;
1254 job.action = `Run the project tests. Fix failures. Re-run the tests. Test command hint: ${parsedAction}`;
1255 } else if (usedDefaultAction && job.verifyCommand !== defaults.verifyCommand) {
1256 job.action = `Run the project tests. Fix failures. Re-run the tests. Test command hint: ${job.verifyCommand || defaultCommand}`;
1257 }
1258 }
1259 return job;
1260}
1261
1262// src/source/opencode/command-router.js
1263var HANDLER_NAMES = [
1264 "addGoal",
1265 "statusGoal",
1266 "pauseGoal",
1267 "resumeGoal",
1268 "clearGoal",
1269 "completeGoalCommand",
1270 "blockGoalCommand",
1271 "addLoop",
1272 "stopLoop",
1273 "statusLoop",
1274 "logsLoop",
1275 "helpLoop",
1276 "runNow",
1277 "updateJobState",
1278 "doctorLoop",
1279 "initLoop",
1280 "exportLoop"
1281];
1282function requireFunction(value, name) {
1283 if (typeof value !== "function")
1284 throw new TypeError(`createCommandRouter requires ${name}`);
1285 return value;
1286}
1287function createCommandRouter(options = {}) {
1288 const rememberSession = requireFunction(options.rememberSession, "rememberSession");
1289 const captureSessionExecutionContext2 = typeof options.captureSessionExecutionContext === "function" ? options.captureSessionExecutionContext : captureSessionExecutionContext;
1290 const guardLoopOwnedUserMessage2 = typeof options.guardLoopOwnedUserMessage === "function" ? options.guardLoopOwnedUserMessage : guardLoopOwnedUserMessage;
1291 const handlers = {};
1292 for (const name of HANDLER_NAMES)
1293 handlers[name] = requireFunction(options.handlers?.[name], `handlers.${name}`);
1294 return async function handleCommand(directory, client, input, fallbackName, fallbackArgs, output, source = "before") {

Callers 5

startHeartbeatFunction · 0.85
scheduleIdleWorkFunction · 0.85
startWatchdogFunction · 0.85
scheduleDueWorkFunction · 0.85
runNowFunction · 0.85

Calls 15

rememberSessionFunction · 0.85
rescheduleFunction · 0.85
nowFunction · 0.85
finalizeActiveRunFunction · 0.85
sessionIsIdleFunction · 0.85
toastFunction · 0.85
clearActiveRunFunction · 0.85
readStateFunction · 0.85
watchChangedFunction · 0.85
dueJobsFunction · 0.85
writeStateFunction · 0.85
notifyJobFunction · 0.85

Tested by

no test coverage detected