Skip to content

Commit 01c674e

Browse files
khaliqgantclaude
andcommitted
scripts: extract schedules to a leaf module so register script doesn't drag in octokit
The register-schedules script transitively loaded the agent module, which loads Octokit, which trips tsx's strict-exports resolver in CJS mode. Moving the schedule data to agents/schedules.ts (zero deps) lets the script run without touching any agent code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e2f8077 commit 01c674e

2 files changed

Lines changed: 27 additions & 27 deletions

File tree

agents/schedules.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Static schedule metadata for every time-triggered agent.
3+
*
4+
* Keeping this in a leaf module (no other imports) means the
5+
* register-schedules script can load it without dragging in the agent
6+
* code (which transitively imports Octokit/etc. and fights with tsx's
7+
* ESM resolver).
8+
*
9+
* When you add a new time-triggered agent, append its row here and
10+
* re-run `npx tsx scripts/register-schedules.ts`.
11+
*/
12+
13+
export type AgentSchedule = {
14+
agentName: string;
15+
cron: string;
16+
tz: string;
17+
};
18+
19+
export const SCHEDULES: AgentSchedule[] = [
20+
{
21+
agentName: "weekly-digest",
22+
cron: "0 9 * * 6",
23+
tz: "UTC",
24+
},
25+
];

scripts/register-schedules.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* We use plain fetch instead of @relaycron/sdk to dodge ESM/CJS resolution
1616
* drama; the API surface is small enough to inline.
1717
*/
18-
import weeklyDigest from "../agents/weekly-digest/agent";
18+
import { SCHEDULES } from "../agents/schedules";
1919

2020
const RELAYCRON_BASE = process.env.RELAYCRON_BASE_URL ?? "https://api.relaycron.dev";
2121
const SITE_BASE = process.env.SITE_BASE_URL ?? "https://proactiveagents.dev";
@@ -27,31 +27,6 @@ type Schedule = {
2727
timezone?: string;
2828
};
2929

30-
type RegisterableSchedule = {
31-
agentName: string;
32-
cron: string;
33-
tz: string;
34-
};
35-
36-
const REGISTRY: RegisterableSchedule[] = [
37-
{
38-
agentName: "weekly-digest",
39-
cron: extractCron(weeklyDigest.definition.schedule)!,
40-
tz: extractTz(weeklyDigest.definition.schedule) ?? "UTC",
41-
},
42-
];
43-
44-
function extractCron(s: unknown): string | null {
45-
if (typeof s === "string") return s;
46-
if (s && typeof s === "object" && "cron" in s) return (s as { cron: string }).cron;
47-
return null;
48-
}
49-
50-
function extractTz(s: unknown): string | null {
51-
if (s && typeof s === "object" && "tz" in s) return (s as { tz?: string }).tz ?? null;
52-
return null;
53-
}
54-
5530
async function api<T>(method: string, path: string, body?: unknown): Promise<T> {
5631
const apiKey = required("RELAYCRON_API_KEY");
5732
const res = await fetch(`${RELAYCRON_BASE}${path}`, {
@@ -92,7 +67,7 @@ async function main() {
9267
const existing = await listAllSchedules();
9368
const byName = new Map(existing.map((s) => [s.name, s]));
9469

95-
for (const reg of REGISTRY) {
70+
for (const reg of SCHEDULES) {
9671
const name = `proactive-agents/${reg.agentName}`;
9772
const url = `${SITE_BASE}/api/cron/${reg.agentName}`;
9873

0 commit comments

Comments
 (0)