- Unify resolveProviderAndModel across CLI and server, supporting provider/model syntax (e.g. codex/gpt-5.4) for agent runs and schedules - Add --provider flag to schedule create CLI and both MCP schedule tools - Add structured debug logging to workspace fetch hydrate, sidebar refresh, and real-time update paths - Update orchestrate skill references
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import type { Command } from "commander";
|
|
import type { SingleResult } from "../../output/index.js";
|
|
import { scheduleSchema } from "./schema.js";
|
|
import {
|
|
connectScheduleClient,
|
|
parseScheduleCreateInput,
|
|
toScheduleCommandError,
|
|
toScheduleRow,
|
|
type ScheduleCommandOptions,
|
|
type ScheduleRow,
|
|
} from "./shared.js";
|
|
|
|
export interface ScheduleCreateOptions extends ScheduleCommandOptions {
|
|
every?: string;
|
|
cron?: string;
|
|
name?: string;
|
|
target?: string;
|
|
provider?: string;
|
|
maxRuns?: string;
|
|
expiresIn?: string;
|
|
}
|
|
|
|
export async function runCreateCommand(
|
|
prompt: string,
|
|
options: ScheduleCreateOptions,
|
|
_command: Command,
|
|
): Promise<SingleResult<ScheduleRow>> {
|
|
const input = parseScheduleCreateInput({
|
|
prompt,
|
|
every: options.every,
|
|
cron: options.cron,
|
|
name: options.name,
|
|
target: options.target,
|
|
provider: options.provider,
|
|
maxRuns: options.maxRuns,
|
|
expiresIn: options.expiresIn,
|
|
});
|
|
const { client } = await connectScheduleClient(options.host);
|
|
try {
|
|
const payload = await client.scheduleCreate(input);
|
|
if (payload.error || !payload.schedule) {
|
|
throw new Error(payload.error ?? "Schedule creation failed");
|
|
}
|
|
return {
|
|
type: "single",
|
|
data: toScheduleRow(payload.schedule),
|
|
schema: scheduleSchema,
|
|
};
|
|
} catch (error) {
|
|
throw toScheduleCommandError("SCHEDULE_CREATE_FAILED", "create schedule", error);
|
|
} finally {
|
|
await client.close().catch(() => {});
|
|
}
|
|
}
|