refactor: centralize task runtime contracts (#199)

This commit is contained in:
Eyejoker
2026-05-30 01:56:41 +09:00
committed by GitHub
parent 1531482363
commit 37b57b20bb
14 changed files with 152 additions and 77 deletions

View File

@@ -1,4 +1,8 @@
import { CronExpressionParser } from 'cron-parser';
import {
DEFAULT_TASK_CONTEXT_MODE,
isTaskContextMode,
} from 'ejclaw-runners-shared';
import { TIMEZONE } from './config.js';
import { isWatchCiTask } from './task-watch-status.js';
@@ -100,10 +104,6 @@ function isScheduleType(
return value === 'cron' || value === 'interval' || value === 'once';
}
function isContextMode(value: unknown): value is ScheduledTask['context_mode'] {
return value === 'group' || value === 'isolated';
}
function isAgentType(value: unknown): value is AgentType {
return value === 'claude-code' || value === 'codex';
}
@@ -294,9 +294,9 @@ async function handleTaskCreateRoute(
return jsonResponse({ error: next.error }, { status: 400 });
}
const contextMode = isContextMode(body.contextMode)
const contextMode = isTaskContextMode(body.contextMode)
? body.contextMode
: 'isolated';
: DEFAULT_TASK_CONTEXT_MODE;
const agentType = isAgentType(body.agentType)
? body.agentType
: (room.group.agentType ?? 'claude-code');