refactor: centralize task runtime contracts (#199)
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user