@jiggai/recipes 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/handlers/cron.ts +20 -1
package/package.json
CHANGED
package/src/handlers/cron.ts
CHANGED
|
@@ -154,6 +154,11 @@ async function cronList(api: OpenClawPluginApi) {
|
|
|
154
154
|
return { jobs: parsed?.jobs ?? [] };
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
function isCronToolUnavailableError(err: unknown): boolean {
|
|
158
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
159
|
+
return /Tool not available:\s*cron/i.test(msg);
|
|
160
|
+
}
|
|
161
|
+
|
|
157
162
|
type CronAddResponse = { id?: string; job?: { id?: string } } | null;
|
|
158
163
|
|
|
159
164
|
async function cronAdd(api: OpenClawPluginApi, job: Record<string, unknown>): Promise<CronAddResponse> {
|
|
@@ -351,7 +356,21 @@ export async function reconcileRecipeCronJobs(opts: {
|
|
|
351
356
|
const statePath = path.join(opts.scope.stateDir, "notes", "cron-jobs.json");
|
|
352
357
|
const state = await loadCronMappingState(statePath);
|
|
353
358
|
const hasAnyInstalled = desired.some((j) => Boolean(state.entries[cronKey(opts.scope, j.id)]?.installedCronId));
|
|
354
|
-
|
|
359
|
+
|
|
360
|
+
// Cron is managed by the Gateway subsystem. Some OpenClaw builds do not expose it via toolsInvoke.
|
|
361
|
+
// In that case, cron reconciliation must be best-effort and must NOT block scaffolds.
|
|
362
|
+
let list: { jobs: OpenClawCronJob[] } = { jobs: [] };
|
|
363
|
+
if (hasAnyInstalled) {
|
|
364
|
+
try {
|
|
365
|
+
list = await cronList(opts.api);
|
|
366
|
+
} catch (err) {
|
|
367
|
+
if (isCronToolUnavailableError(err)) {
|
|
368
|
+
console.error('[recipes] note: cron tool unavailable; skipping cron reconciliation (scaffold will proceed).');
|
|
369
|
+
return { ok: true as const, changed: false as const, note: "cron-tool-unavailable" as const, desiredCount: desired.length };
|
|
370
|
+
}
|
|
371
|
+
throw err;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
355
374
|
const byId = new Map((list?.jobs ?? []).map((j) => [j.id, j] as const));
|
|
356
375
|
const now = Date.now();
|
|
357
376
|
const desiredIds = new Set(desired.map((j) => j.id));
|