@vite-hub/schedule 0.3.1 → 0.5.0

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.
Files changed (47) hide show
  1. package/README.md +24 -19
  2. package/dist/{console-wEhr0LWn.d.ts → console-DueeEBcM.d.ts} +2 -0
  3. package/dist/cron-C1l3TquN.js +70 -0
  4. package/dist/definition.js +1 -2
  5. package/dist/{due-BVMRQ93v.js → due-n120-_nz.js} +22 -7
  6. package/dist/durability.d.ts +2 -2
  7. package/dist/durability.js +5 -5
  8. package/dist/{error-diagnostics-DSkCJC_L.js → error-diagnostics-C0KyI408.js} +10 -2
  9. package/dist/{error-diagnostics-Mpeks7J0.js → error-diagnostics-DTmP6baC.js} +5 -5
  10. package/dist/index.d.ts +19 -5
  11. package/dist/index.js +34 -6
  12. package/dist/{kv-storage-iJChCS5A.js → kv-storage-2kZtP2CC.js} +2 -2
  13. package/dist/{kv-storage-C0KZZB6v.d.ts → kv-storage-Bm9aYLfZ.d.ts} +5 -1
  14. package/dist/{operation-definition-8gOe-ubD.d.ts → operation-definition-CI2PJGqu.d.ts} +13 -2
  15. package/dist/{operations-DwZWFIUX.js → operations-DlrK9mlH.js} +29 -9
  16. package/dist/operations.d.ts +10 -1
  17. package/dist/operations.js +13 -10
  18. package/dist/os.d.ts +0 -1
  19. package/dist/os.js +12 -84
  20. package/dist/out-BbXG-yVX.js +21755 -0
  21. package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
  22. package/dist/runtime/console.d.ts +1 -1
  23. package/dist/runtime/console.js +2 -2
  24. package/dist/runtime/kv.d.ts +1 -1
  25. package/dist/runtime/kv.js +1 -1
  26. package/dist/runtime/process.js +24 -45
  27. package/dist/runtime/state.d.ts +2 -2
  28. package/dist/runtime/state.js +2 -2
  29. package/dist/runtime/static.d.ts +2 -73
  30. package/dist/runtime/static.js +3 -2
  31. package/dist/runtime.d.ts +4 -4
  32. package/dist/runtime.js +5 -5
  33. package/dist/{started-Bx7MDbrl.js → started-BWWr7Ufw.js} +3 -4
  34. package/dist/{started-BuGmnus4.js → started-BXdWMdji.js} +24 -6
  35. package/dist/{started-errors-p7cu_rI7.js → started-errors-BMg04lL3.js} +73 -26
  36. package/dist/started-name-DudQ0fsR.js +5 -0
  37. package/dist/{state-B-Fuyfb4.js → state-BjWnxyhv.js} +79 -118
  38. package/dist/{state-Do2wV4Tx.d.ts → state-CJKAhskJ.d.ts} +12 -2
  39. package/dist/static-BgoOCoe5.js +610 -0
  40. package/dist/static-CcBWx1kU.d.ts +96 -0
  41. package/dist/{store-Df0-fzCl.d.ts → store-CZHZfttA.d.ts} +3 -7
  42. package/dist/vite.d.ts +5 -3
  43. package/dist/vite.js +2963 -590
  44. package/package.json +6 -6
  45. package/dist/invariant-DolT9EEx.js +0 -22
  46. package/dist/static-DQwzzvPg.js +0 -266
  47. package/dist/wait-until-Dy4Bn3ZN.js +0 -112
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @vite-hub/schedule
2
2
 
3
- [![npm version](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=%40vite-hub%2Fschedule&icon=npm)](https://npmx.dev/package/@vite-hub/schedule)
4
- [![npm downloads](https://comark-ui.onmax.me/badge.svg?source=npm-downloads&package=%40vite-hub%2Fschedule&period=month&icon=npm)](https://npmx.dev/package/@vite-hub/schedule)
5
- [![license](https://comark-ui.onmax.me/badge.svg?label=license&value=Apache-2.0)](https://github.com/vite-hub/vitehub/blob/main/LICENSE)
6
- [![docs](https://comark-ui.onmax.me/badge.svg?label=docs&value=vitehub.dev)](https://vitehub.dev/docs)
3
+ [![npm version](https://img.shields.io/npm/v/@vite-hub/schedule)](https://npmx.dev/package/@vite-hub/schedule)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@vite-hub/schedule)](https://npmx.dev/package/@vite-hub/schedule)
5
+ [![license](https://img.shields.io/static/v1?label=license&message=Apache-2.0&color=blue)](https://github.com/vite-hub/vitehub/blob/main/LICENSE)
6
+ [![docs](https://img.shields.io/static/v1?label=docs&message=vitehub.dev&color=blue)](https://vitehub.dev/docs)
7
7
 
8
8
  `@vite-hub/schedule` discovers recurring work, generates cron output for supported hosts, and can run Static Schedule Definitions in one long-lived process.
9
9
 
@@ -15,7 +15,7 @@ Install `vite-hub` and `@vite-hub/schedule` for an application. `vite-hub` expos
15
15
  pnpm add vite-hub @vite-hub/schedule
16
16
  ```
17
17
 
18
- Enable Schedule with the framework integration and import application helpers from its feature path:
18
+ A file in `server/schedules/` turns Schedule on in the framework integration. Import application helpers from its feature path:
19
19
 
20
20
  ```ts
21
21
  // vite.config.ts
@@ -23,7 +23,7 @@ import { vitehub } from "vite-hub";
23
23
  import { defineConfig } from "vite";
24
24
 
25
25
  export default defineConfig({
26
- plugins: [vitehub({ host: "cloudflare", schedule: true })],
26
+ plugins: [vitehub({ host: "cloudflare" })],
27
27
  });
28
28
  ```
29
29
 
@@ -39,7 +39,7 @@ pnpm add @vite-hub/schedule
39
39
 
40
40
  Direct integrations use `@vite-hub/schedule`, `@vite-hub/schedule/runtime`, and `@vite-hub/schedule/vite`. Add Vite when the project uses `hubSchedule()`. Add `@vite-hub/kv` when using the KV Schedule Run store through `@vite-hub/schedule/runtime/kv` or the generated Process Runtime. Static Schedule Definitions, memory stores, and custom `ScheduleKVStorage` implementations do not require KV.
41
41
 
42
- Both packages require Node.js 22.18 or newer.
42
+ Both packages require Node.js 24.15 or newer.
43
43
 
44
44
  ## Run one occurrence
45
45
 
@@ -104,11 +104,11 @@ export default defineSchedule({
104
104
 
105
105
  Static Schedule Definitions use five-field cron expressions. The cron uses UTC unless the definition sets `timeZone` to an IANA name, such as `Europe/Madrid`. `timeZone` works with the Process Runtime and with every host's cron output.
106
106
 
107
- The integration can generate host-specific output for Cloudflare Cron Triggers, Vercel Cron Jobs, Netlify Scheduled Functions, standalone `Deno.cron`, Nitro's Cloudflare schedule hook, and Netlify Scheduled Functions that run in Nitro's server bundle. A build writes only the output of its host: Nitro's resolved preset, or else `nitro.preset`, `NITRO_PRESET`, `SERVER_PRESET`, or `VITEHUB_HOST`. It writes the output of every host only when no host is known. Host selection, local execution, deployment proof, limits, and billing still come from the selected host. Check the [runtime and host support matrix](https://vitehub.dev/docs/frameworks-hosts/support-matrix) before deploying.
107
+ The integration can generate host-specific output for Cloudflare Cron Triggers, Vercel Cron Jobs, Netlify Scheduled Functions, standalone `Deno.cron`, Nitro's Cloudflare schedule hook, and Netlify Scheduled Functions that run in Nitro's server bundle. A build writes only the output of its host: Nitro's resolved preset, or else `nitro.preset`, `NITRO_PRESET`, `SERVER_PRESET`, or `VITEHUB_HOST`. It writes the output of every host only when no host is known. Host selection, local execution, deployment proof, limits, and billing still come from the selected host. Check the [runtime and host support matrix](https://vitehub.dev/docs/frameworks-hosts/support-matrix) before deploying. Write weekdays as standard cron numbers, 0 to 6 from Sunday. Cloudflare and Deno number weekdays 1 to 7 from Sunday, so their output writes weekday names: `0 4 * * 1-5` becomes `0 4 * * MON,TUE,WED,THU,FRI`.
108
108
 
109
- Applications that use the framework distribution register Schedule through `vitehub({ host, schedule: true })` and import the definition helper from `vite-hub/schedule`. On Deno, the build writes standalone cron output and a `.output/main.ts` entrypoint that loads it before the Nitro server.
109
+ Applications that use the framework distribution turn Schedule on with a file in `server/schedules/`, with no `schedule` key, and import the definition helper from `vite-hub/schedule`. On Deno, the build writes standalone cron output and a `.output/main.ts` entrypoint that loads it before the Nitro server.
110
110
 
111
- Nuxt projects enable Schedule with `vite-hub/nuxt` and `vitehub: { schedule: true }`. The module installs the Vite integration and merges Schedule output into Nitro config.
111
+ Nuxt projects enable Schedule with `vite-hub/nuxt` and a file in `server/schedules/`. The module installs the Vite integration and merges Schedule output into Nitro config.
112
112
 
113
113
  ## Start a Schedule from code
114
114
 
@@ -134,7 +134,7 @@ const [, started] = await listSchedules({ name: "reminder" });
134
134
  await cancelSchedule(standUp!.id);
135
135
  ```
136
136
 
137
- The functions return `[error, data]`. The Schedules are stored in KV, so they survive restarts and deploys. When a Definition has no `cron`, the build adds the Schedule `vitehub/started-schedules` with the cron `* * * * *`: Cloudflare wakes it with a Cron Trigger, and the Process Runtime wakes it on Node. Each wake runs the started Schedules that are due. Started Schedules need KV, and on Node the Process Runtime. `vitehub schedule list`, `start`, and `cancel` and the Console Schedules page show and change them. Read the [server API](https://vitehub.dev/docs/schedule/server-api#start-a-schedule-from-code) for the delivery rules.
137
+ The functions return `[error, data]`. The Schedules are stored in KV, so they survive restarts and deploys. When a Definition has no `cron`, the build adds the Schedule `vitehub/started-schedules` with the cron `* * * * *`: Cloudflare wakes it with a Cron Trigger, and the Process Runtime wakes it on Node. Each wake runs the started Schedules that are due. Started Schedules need KV, and on Node the Process Runtime. `vitehub schedule start` and `cancel` and the Console Schedules page show and change them. `vitehub schedule list` lists them after the Static Schedule Definitions, and works without KV when no Definition can be started. Read the [server API](https://vitehub.dev/docs/schedule/server-api#start-a-schedule-from-code) for the delivery rules.
138
138
 
139
139
  ## Understand time zones
140
140
 
@@ -156,7 +156,8 @@ export default defineSchedule({
156
156
  cron: "0 7 * * *",
157
157
  timeZone: "Europe/Stockholm",
158
158
  async handler({ idempotencyKey }) {
159
- await email.send({ from, to, subject: "Today's lesson", text, idempotencyKey });
159
+ const [error] = await email.send({ from, to, subject: "Today's lesson", text, idempotencyKey });
160
+ if (error) throw error;
160
161
  },
161
162
  });
162
163
  ```
@@ -167,7 +168,7 @@ Vercel, Netlify, and Deno do not supply a scheduled timestamp to these entries.
167
168
 
168
169
  ## Run schedules in the server process
169
170
 
170
- The generated Process Runtime runs each Static Schedule Definition on its cron inside the Node.js process. It records Schedule Runs in the default KV store configured by `hubKV()`. Use it on long-lived servers, one or more:
171
+ The generated Process Runtime runs each Static Schedule Definition on its cron inside the Node.js process. It records Schedule Runs in the default KV store configured by `hubKV()`. Use it on long-lived servers, one or more. `vitehub({ host: "node", schedule: true })` turns it on for you. With `hubSchedule()` alone, set `runtime`:
171
172
 
172
173
  ```ts
173
174
  import { hubKV } from "@vite-hub/kv/vite";
@@ -197,9 +198,9 @@ Every server checks every Schedule. Before a server runs an occurrence, it takes
197
198
  - If the server loses the Database, or its event loop pauses, for longer than `leaseTtlMs`, its lease can expire while its handler still runs. Another server can run the same occurrence at the same time. The runtime reports renewal failures, but cannot stop the handler or undo its effects. Choose a TTL longer than expected pauses and make external effects idempotent.
198
199
  - If the lease store fails before a run starts, the server reports the error and retries at its next scan while the occurrence is inside `catchUpMs`.
199
200
  - A failed run is final, as on one server. It is not retried.
200
- - When a server stops during a run, for example after a crash, its lease ends after `leaseTtlMs`. Then another server runs the occurrence, unless it has a done marker. With shared run history, the run gets a new attempt, and the stopped attempt is marked as failed. This also works when every server restarts: at start, a server reads the runs inside `catchUpMs` that are still pending or running, and tries them again.
201
+ - When a server stops during a run, for example after a crash, its lease ends after `leaseTtlMs`. Then another server runs the occurrence, unless it has a done marker. A server that found the lease held tries the occurrence again until `catchUpMs` plus `leaseTtlMs` plus one minute after its scheduled minute, also with `catchUpMs: 0`. With shared run history, the run gets a new attempt, and the stopped attempt is marked as failed. This also works when every server restarts: at start, a server reads the runs inside `catchUpMs` that are still pending or running, and tries them again.
201
202
 
202
- The generated runtime keeps the leases in the `vitehub_leases` table of the Default Database, through `useLeases()` from `@vite-hub/database`. That works on Postgres, remote libSQL, and D1. A local libSQL file is safe for one server process only, because `@libsql/client` can lose writes when several processes write to one file. The server prints a warning at the first lease in that case. Without a Database, the leases stay in memory and the build prints a warning: each server then runs every occurrence, so run one server only. The run history stays in KV. Use a KV store that all servers share, such as Upstash, so catch-up and the Console see the runs of every server.
203
+ The generated runtime keeps the leases in the `vitehub_leases` table of the Default Database, through `useLeases()` from `@vite-hub/database`. That works on Postgres, with postgres.js or node-postgres, remote libSQL, and D1. With `VITEHUB_INSTANCES` greater than 1, a Node server with a Postgres or remote libSQL Default Database reports Schedule as `shared` at boot. A local libSQL file is safe for one server process only, because `@libsql/client` can lose writes when several processes write to one file. The server prints a warning at the first lease in that case. Without a Database, the leases stay in memory and the build reports the hint `SCHEDULE_PROCESS_CLAIMS_IN_MEMORY` in its output and in `.vitehub/hints.json`: each server then runs every occurrence, so run one server only. The run history stays in KV. Use a KV store that all servers share, such as Upstash, so catch-up and the Console see the runs of every server.
203
204
 
204
205
  With the Process Runtime, the default `providerOutput: "auto"` emits no host Provider Output, so the process owns Static Schedule wakes. Set `providerOutput: "standalone"` or `"nitro"` to move Static Schedule wakes to that Provider Output. `providerOutput: false` records the same wake ownership as `"auto"` in this configuration.
205
206
 
@@ -250,15 +251,19 @@ Custom stores must apply the `listRuns({ scheduleId, idPrefix, limit })` filters
250
251
 
251
252
  ## Run and inspect schedules
252
253
 
253
- `hubSchedule()` contributes the `schedule.runs`, `schedule.attempts`, `schedule.run`, `schedule.list`, `schedule.start`, and `schedule.cancel` operations. They are the `vitehub schedule runs <id> [--limit <n>]`, `attempts <runId>`, `run <name>`, `list [name]`, `start <name>`, and `cancel <id>` commands, and the Console runs them too. Each command accepts `--json` and `--url`. Without `--url` the command calls the dev server of the project, whose Nitro runtime owns the same stores and registry as the running app.
254
+ `hubSchedule()` contributes the `schedule.runs`, `schedule.attempts`, `schedule.run`, `schedule.list`, `schedule.start`, and `schedule.cancel` operations. They are the `vitehub schedule runs list <id> [--limit <n>]`, `runs get <runId>`, `run <name>`, `list [name]`, `start <name>`, and `cancel <id>` commands, and the Console runs them too. Each command accepts `--json` and `--url`. Without `--url` the command calls the dev server of the project, whose Nitro runtime owns the same stores and registry as the running app.
254
255
 
255
- Set `manual: true` on a Static Schedule Definition to allow an on-demand run, then invoke it with `vitehub schedule run <name>`. The name is the discovered schedule file name. Add `--url <app-url>` to run it on a deployment that enables `console.invoke`. The command signs the call with `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>`, so a CI job needs only that secret. `vitehub secret console-key ci` prints a new key pair. Server code can call `runSchedule(name)` from `@vite-hub/schedule`. It reads the generated registry. Each manual run gets a new `srun_manual_` id.
256
+ Set `manual: true` on a Static Schedule Definition to allow an on-demand run, then invoke it with `vitehub schedule run <name>`. The name is the discovered schedule file name. Add `--url <app-url>` to run it on a deployment that enables `console.invoke`. The command signs the call with `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>`, so a CI job needs only that secret. `vitehub secret console-key ci` prints a new key pair. Server code can call `runSchedule(name)` from `@vite-hub/schedule`. It reads the generated registry and returns `[error, run]`. A failed handler gives a run with `status: "failed"`. An invalid `scheduledAt` or a failed run store gives `error`. An unknown name or a Definition without `manual: true` throws. Each manual run gets a new `srun_manual_` id.
256
257
 
257
- Add `--at <ISO date-time>` to run it as if the cron fired at that time, for example `vitehub schedule run close-month --at 2026-01-31T23:59:00Z`. The handler gets the time as `scheduledAt`, and the run records it, so `vitehub schedule runs` lists it under that time. `runSchedule()` takes the same value as `scheduledAt`. The value needs `Z` or an offset. A value without a time zone, a date only, or a day that does not exist fails with `SCHEDULE_INVALID_SCHEDULED_AT` before the handler runs. The time is not checked against the cron. Manual runs do not advance the Process Runtime's catch-up cursor, even when their scheduled time is in the future.
258
+ Add `--at <ISO date-time>` to run it as if the cron fired at that time, for example `vitehub schedule run close-month --at 2026-01-31T23:59:00Z`. The handler gets the time as `scheduledAt`, and the run records it, so `vitehub schedule runs list` lists it under that time. `runSchedule()` takes the same value as `scheduledAt`. The value needs `Z` or an offset. A value without a time zone, a date only, or a day that does not exist fails with `SCHEDULE_INVALID_SCHEDULED_AT` before the handler runs. `runSchedule()` returns it as `error`. The time is not checked against the cron. Manual runs do not advance the Process Runtime's catch-up cursor, even when their scheduled time is in the future.
258
259
 
259
260
  Discovery reads `manual` as a literal boolean from directly exported Definitions. Use identifier keys or quoted keys without escape sequences. Spreads, computed keys, escaped keys, and metadata getters or methods fail with the source file and line.
260
261
 
261
- The Console Schedules section lists Schedule Definitions with their cron, time zone, and manual state. It reads them at build time. When the server runs the Process Runtime, the cron and time zone come from the loaded Definitions on each request, so they are the values that the runtime uses. `vitehub inspect definitions` reads them from the source file and shows `Not a static string` for a value that it cannot read there. Use `vitehub schedule runs <name>` to list the runs that the runtime recorded. The CLI and the Console redact credentials in error messages.
262
+ The Console Schedules section lists Schedule Definitions with their cron, time zone, and manual state. It reads them at build time. When the server runs the Process Runtime, the cron and time zone come from the loaded Definitions on each request, so they are the values that the runtime uses. `vitehub inspect definitions` reads them from the source file and shows `Not a static string` for a value that it cannot read there. Use `vitehub schedule runs list <name>` to list the runs that the runtime recorded. The CLI and the Console redact credentials in error messages.
263
+
264
+ ## Runs in logs
265
+
266
+ With the evlog Nitro module registered, each Schedule handler run inside Nitro gets its own evlog event, `schedule: { name, source, scheduledAt, ms, outcome }`, with the error when it fails. Standalone provider wakes do not send these events. This includes Vercel and Deno cron wakes by default, and Cloudflare or Netlify when you select standalone output. Without evlog, failures go to the console and runtimes with a run store keep their run history. See [Server API](https://vitehub.dev/docs/schedule/server-api#see-schedule-runs-in-logs).
262
267
 
263
268
  ## Import runtime helpers
264
269
 
@@ -48,6 +48,8 @@ interface ViteHubResourceSummary {
48
48
  owner: string;
49
49
  /** Absent when no id is known yet. */
50
50
  source?: ViteHubResourceIdSource;
51
+ /** The resource is in the Wrangler config of a standalone Provider Output Worker, not in Nitro's. */
52
+ standalone?: boolean;
51
53
  }
52
54
  interface ViteHubInspectionContributor {
53
55
  definitions?: readonly ViteHubDefinitionInspector[];
@@ -0,0 +1,70 @@
1
+ import { defineDiagnostics } from "nostics";
2
+ import { parseCronExpression } from "cron-schedule";
3
+ //#region ../internal/src/invariant.ts
4
+ const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
5
+ docsBase: "https://vitehub.dev/docs/development/diagnostics",
6
+ codes: { INTERNAL_INVARIANT_FAILED: {
7
+ why: ({ what }) => `ViteHub reached a state that it does not expect: ${what}`,
8
+ fix: "This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace."
9
+ } }
10
+ });
11
+ /**
12
+ * The error for a state that only a ViteHub bug can reach, such as an impossible branch. `what` says which rule broke.
13
+ * Use a code from the package catalog when a developer can cause the error or fix it.
14
+ */
15
+ function invariantError(what) {
16
+ return invariantDiagnostics.INTERNAL_INVARIANT_FAILED({ what });
17
+ }
18
+ /** Throws `INTERNAL_INVARIANT_FAILED` when `condition` is falsy. */
19
+ function invariant(condition, what) {
20
+ if (!condition) throw invariantError(what);
21
+ }
22
+ //#endregion
23
+ //#region src/os/cron.ts
24
+ const allMonths = range(1, 12);
25
+ const allWeekdays = range(0, 6);
26
+ function range(first, last) {
27
+ return Array.from({ length: last - first + 1 }, (_, index) => first + index);
28
+ }
29
+ /** Reads a five-field cron. Returns `undefined` for anything else. */
30
+ function parseCronFields(cron) {
31
+ if (cron.trim() !== cron || cron.split(/\s+/).length !== 5) return void 0;
32
+ try {
33
+ const parsed = parseCronExpression(cron);
34
+ const sorted = (values) => [...new Set(values)].sort((left, right) => left - right);
35
+ return {
36
+ minutes: sorted(parsed.minutes),
37
+ hours: sorted(parsed.hours),
38
+ days: sorted(parsed.days),
39
+ months: sorted(parsed.months.map((month) => month + 1)),
40
+ weekdays: sorted(parsed.weekdays.map((weekday) => weekday % 7))
41
+ };
42
+ } catch {
43
+ return;
44
+ }
45
+ }
46
+ function isDayRestricted(fields) {
47
+ return fields.days.length !== 31;
48
+ }
49
+ function isWeekdayRestricted(fields) {
50
+ return fields.weekdays.length !== allWeekdays.length;
51
+ }
52
+ function isMonthRestricted(fields) {
53
+ return fields.months.length !== allMonths.length;
54
+ }
55
+ /** True when every day field holds every value, so the cron runs on every day. */
56
+ function runsEveryDay(fields) {
57
+ return !isDayRestricted(fields) && !isWeekdayRestricted(fields) && !isMonthRestricted(fields);
58
+ }
59
+ /** Minutes of the day when the cron runs, sorted. */
60
+ function timesOfDay(fields) {
61
+ return fields.hours.flatMap((hour) => fields.minutes.map((minute) => hour * 60 + minute));
62
+ }
63
+ /** The step of a sorted list of two or more values with equal gaps, else `undefined`. One value has step 0. */
64
+ function arithmeticStep(values) {
65
+ if (values.length < 2) return 0;
66
+ const step = values[1] - values[0];
67
+ return values.every((value, index) => index === 0 || value - values[index - 1] === step) ? step : void 0;
68
+ }
69
+ //#endregion
70
+ export { parseCronFields as a, timesOfDay as c, isWeekdayRestricted as i, invariant as l, isDayRestricted as n, range as o, isMonthRestricted as r, runsEveryDay as s, arithmeticStep as t, invariantError as u };
@@ -1,6 +1,6 @@
1
1
  import { t as isIanaTimeZone } from "./time-zone-SBldrUgt.js";
2
2
  import { t as isRecord } from "./object-Da1zyPCR.js";
3
- import { t as scheduleErrorDiagnostics } from "./error-diagnostics-Mpeks7J0.js";
3
+ import { t as scheduleErrorDiagnostics } from "./error-diagnostics-DTmP6baC.js";
4
4
  //#region src/definition.ts
5
5
  const cronFieldPattern = /^[^\s]+$/;
6
6
  const scheduleDefinitionKeys = /* @__PURE__ */ new Set([
@@ -21,7 +21,6 @@ function validateCron(cron) {
21
21
  const fields = cron.split(/\s+/);
22
22
  if (fields.length !== 5 || !fields.every((field) => cronFieldPattern.test(field))) throw scheduleErrorDiagnostics.SCHEDULE_C0002({ message: "`defineSchedule()` cron must be a five-field cron expression." });
23
23
  }
24
- /** The `defineSchedule(cron, handler, options)` form was removed. Name the object form in the error. */
25
24
  const positionalFormMessage = "`defineSchedule(cron, handler)` was removed. Pass one object: `defineSchedule({ cron: \"0 9 * * *\", handler })`, with `manual` and `timeZone` in the same object.";
26
25
  function defineSchedule(input, ...removed) {
27
26
  if (isCronString(input) || removed.length) throw scheduleErrorDiagnostics.SCHEDULE_C0007({ message: positionalFormMessage });
@@ -1,4 +1,4 @@
1
- import { t as scheduleErrorDiagnostics } from "./error-diagnostics-Mpeks7J0.js";
1
+ import { t as scheduleErrorDiagnostics } from "./error-diagnostics-DTmP6baC.js";
2
2
  import { parseCronExpression } from "cron-schedule";
3
3
  //#region src/runtime/due.ts
4
4
  const weekdayIndexes = /* @__PURE__ */ new Map([
@@ -90,7 +90,6 @@ function localEpochMs(fields) {
90
90
  function sameLocalMinute(left, right) {
91
91
  return left.minute === right.minute && left.hour === right.hour && left.day === right.day && left.month === right.month && left.year === right.year;
92
92
  }
93
- /** Detect a repeated local minute using the actual offset before the transition (including historical 23-hour rollbacks). */
94
93
  function isRepeatedFixedLocalTime(cron, fields, scheduledAt, timeZone) {
95
94
  if (!timeZone || timeZone === "UTC" || cron.minutes.length === hourMinutes || cron.hours.length === 24) return false;
96
95
  const previous = /* @__PURE__ */ new Date(scheduledAt.getTime() - dayMinutes * minuteMs);
@@ -99,10 +98,6 @@ function isRepeatedFixedLocalTime(cron, fields, scheduledAt, timeZone) {
99
98
  if (previousOffset <= currentOffset) return false;
100
99
  return sameLocalMinute(scheduleDateFields(new Date(scheduledAt.getTime() - (previousOffset - currentOffset)), timeZone), fields);
101
100
  }
102
- /**
103
- * Detect a local time that the clock skipped on a spring-forward day, read with the offset from before the gap, as
104
- * RFC 5545 and `Temporal` do. `02:30` in a gap from `02:00` to `03:00` maps to `03:30`, so it runs once that day.
105
- */
106
101
  function matchesSkippedLocalTime(cron, fields, scheduledAt, timeZone) {
107
102
  if (!timeZone || timeZone === "UTC") return false;
108
103
  const currentOffset = localEpochMs(fields) - scheduledAt.getTime();
@@ -140,5 +135,25 @@ function latestCronMinute(cron, at) {
140
135
  for (let time = latest; time > latest - dayMinutes * minuteMs; time -= minuteMs) if (isScheduleDue(record, new Date(time))) return new Date(time);
141
136
  return new Date(latest);
142
137
  }
138
+ const weekdayNames = [
139
+ "SUN",
140
+ "MON",
141
+ "TUE",
142
+ "WED",
143
+ "THU",
144
+ "FRI",
145
+ "SAT"
146
+ ];
147
+ /**
148
+ * Returns `cron` with its weekday field written as names, such as `0 4 * * MON,FRI`. Cloudflare and Deno number
149
+ * weekdays 1-7 from Sunday, so standard 0-6 numbers fire one day early or fail to deploy. Names have one meaning on
150
+ * every host.
151
+ */
152
+ function cronWithWeekdayNames(cron) {
153
+ const fields = cron.trim().split(/\s+/);
154
+ if (fields.length !== 5 || fields[4] === "*") return fields.join(" ");
155
+ fields[4] = parseCronExpression(fields.join(" ")).weekdays.map((day) => weekdayNames[day]).join(",");
156
+ return fields.join(" ");
157
+ }
143
158
  //#endregion
144
- export { latestCronMinute as n, timeZoneOffsetMinutes as r, isScheduleDue as t };
159
+ export { timeZoneOffsetMinutes as i, isScheduleDue as n, latestCronMinute as r, cronWithWeekdayNames as t };
@@ -7,8 +7,8 @@ export interface ScheduleDurabilityInput {
7
7
  leases?: boolean;
8
8
  }
9
9
  /**
10
- * The durability of schedule claims. With SQL leases in a Postgres Default Database, one instance runs each
11
- * occurrence. Without them, each process claims each occurrence for itself.
10
+ * The durability of schedule claims. With SQL leases in a Postgres or remote libSQL Default Database, one instance runs
11
+ * each occurrence. Without them, each process claims each occurrence for itself.
12
12
  */
13
13
  export declare function scheduleDurability(input: ScheduleDurabilityInput, context: DurabilityContext): Durability[];
14
14
  //#endregion
@@ -1,13 +1,13 @@
1
1
  //#region src/durability.ts
2
2
  /**
3
- * The durability of schedule claims. With SQL leases in a Postgres Default Database, one instance runs each
4
- * occurrence. Without them, each process claims each occurrence for itself.
3
+ * The durability of schedule claims. With SQL leases in a Postgres or remote libSQL Default Database, one instance runs
4
+ * each occurrence. Without them, each process claims each occurrence for itself.
5
5
  */
6
6
  function scheduleDurability(input, context) {
7
7
  const database = input.leases ? context.find("database") : void 0;
8
- if (database?.store === "postgres") return [{
8
+ if (database?.scope === "shared" && (database.store === "postgres" || database.store === "libsql")) return [{
9
9
  primitive: "schedule",
10
- store: "postgres",
10
+ store: database.store,
11
11
  scope: "shared",
12
12
  reason: "Leases in the Default Database. One instance runs each occurrence."
13
13
  }];
@@ -16,7 +16,7 @@ function scheduleDurability(input, context) {
16
16
  store: input.driver,
17
17
  scope: "process",
18
18
  reason: database ? `Leases in the ${database.store} Default Database do not lock across processes. Every instance can run every occurrence.` : "This process claims each occurrence. Every instance runs every occurrence.",
19
- fix: input.leases ? "Define the Default Database with `dialect: \"postgresql\"`." : "Run the schedules on one instance only. Schedule has no shared lease store for Node yet."
19
+ fix: input.leases ? "Define the Default Database with `dialect: \"postgresql\"` or a remote libSQL URL." : "Turn on Database and define a Postgres or remote libSQL Default Database. The instances then share Schedule leases."
20
20
  }];
21
21
  }
22
22
  //#endregion
@@ -25,7 +25,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
25
25
  why: ({ message }) => message === void 0 ? "" : String(message)
26
26
  },
27
27
  INTERNAL_R0022: {
28
- fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
28
+ fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields, and the list_operations tool of the ViteHub MCP gives the input schema of each operation.",
29
29
  why: ({ message }) => message === void 0 ? "" : String(message)
30
30
  },
31
31
  INTERNAL_R0024: {
@@ -170,7 +170,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
170
170
  },
171
171
  INTERNAL_R0004: {
172
172
  ...dynamicError,
173
- fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `fetch()` Source options, or ask the server for a smaller response."
173
+ fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `url()` Source options, or ask the server for a smaller response."
174
174
  },
175
175
  INTERNAL_R0005: {
176
176
  ...dynamicError,
@@ -216,6 +216,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
216
216
  why: ({ variable }) => `[vitehub] ${variable} must be the 43-character private key that \`vitehub secret console-key\` prints, and its name 1 to 64 of A-Z, 0-9, and _.`,
217
217
  fix: "Set the variable that the message names to the private key that `vitehub secret console-key` prints, and name it `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` with A-Z, 0-9, and _ in `<NAME>`."
218
218
  },
219
+ INTERNAL_DEV_SERVER_NOT_FOUND: {
220
+ why: ({ command }) => `[vitehub] No dev server of this project is running, and --url is not set, so \`vitehub ${command}\` has no app to call.`,
221
+ fix: "Start the dev server of this project, such as with `pnpm dev`, or pass --url with the app URL, such as --url http://localhost:3000."
222
+ },
219
223
  INTERNAL_FORGE_NOT_INSTALLED: {
220
224
  why: ({ feature }) => `${feature} needs @vite-hub/forge, and the app did not install it.`,
221
225
  fix: "Install Forge in your app with `pnpm add @vite-hub/forge`, then build again."
@@ -240,6 +244,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
240
244
  why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
241
245
  fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
242
246
  },
247
+ INTERNAL_RUNTIME_PACKAGE_VERSION_CONFLICT: {
248
+ why: ({ first, name, second }) => `[vitehub] One server function needs ${name} from two installations: ${first} and ${second}.`,
249
+ fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`, then build again."
250
+ },
243
251
  INTERNAL_SECRET_PURPOSE_MISSING: {
244
252
  why: "[vitehub] A derived secret requires a purpose.",
245
253
  fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
@@ -8,17 +8,13 @@ const scheduleErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
8
8
  why: "Schedule run is not available. Set manual: true on the Schedule Definition and enable Console invocation.",
9
9
  fix: "Set `manual: true` in defineSchedule() and keep `console.invoke` on (it is on in development)."
10
10
  },
11
- SCHEDULE_HISTORY_INCOMPLETE: {
12
- why: ({ maxRecords, recordCount }) => `Schedule run history is incomplete because ${recordCount} records have no usable metadata index (maximum fallback is ${maxRecords}). Rebuild the schedule run index before listing history.`,
13
- fix: "Rebuild the Schedule run index of the store, as the message says, before you list the history."
14
- },
15
11
  SCHEDULE_OPERATION_FAILED: {
16
12
  why: "Schedule operation failed.",
17
13
  fix: "Read `error.cause` for the error of the Schedule store or handler. Check that the store is reachable, then retry."
18
14
  },
19
15
  SCHEDULE_RUN_NOT_FOUND: {
20
16
  why: "Schedule Run was not found.",
21
- fix: "List the runs of the Schedule with `vitehub schedule runs <name>` and pass one of their ids."
17
+ fix: "List the runs of the Schedule with `vitehub schedule runs list <name>` and pass one of their ids."
22
18
  },
23
19
  SCHEDULE_C0001: {
24
20
  ...dynamicError,
@@ -156,6 +152,10 @@ const scheduleErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
156
152
  why: ({ name }) => `Schedule "${name}" has no default export of defineSchedule() with a cron and a handler.`,
157
153
  fix: "Default-export `defineSchedule({ cron, handler })` from the Schedule file that the message names, in `server/schedules/`."
158
154
  },
155
+ SCHEDULE_PROCESS_CLAIMS_IN_MEMORY: {
156
+ why: "The Process Runtime claims each Schedule occurrence in memory, because the app has no Database. With several server processes, each one runs every occurrence.",
157
+ fix: "Run one server only, or add a Postgres Database so that more than one server runs each occurrence once."
158
+ },
159
159
  SCHEDULE_RUNTIME_CATCH_UP_INVALID: {
160
160
  why: "Schedule Process Runtime catchUpMs must be a non-negative number.",
161
161
  fix: "Set `runtime.catchUpMs` in `hubSchedule()` or in `vitehub({ schedule })` to a number of 0 or more, or remove it to use one hour (`3600000`)."
package/dist/index.d.ts CHANGED
@@ -1,15 +1,29 @@
1
1
  /// <reference path="./registry-module.d.ts" />
2
2
  import { _ as StartScheduleOptions, a as ScheduleDefinitionRegistry, b as StartedScheduleStore, c as ScheduleRunAttemptRecord, d as ScheduleRunError, f as ScheduleRunListOptions, g as ScheduleRunStore, h as ScheduleRunStatus, l as ScheduleRunAttemptStatus, m as ScheduleRunResponse, n as ScheduleDefinition, o as ScheduleHandler, p as ScheduleRunRecord, r as ScheduleDefinitionInput, s as ScheduleRegistryDefinition, t as DiscoveredScheduleDefinition, u as ScheduleRunContext, v as StartScheduleTiming, y as StartedSchedule } from "./types-Cw5LjPuc.js";
3
3
  import { defineSchedule } from "./definition.js";
4
- import { i as RunScheduleOptions, t as KVScheduleStoreOptions } from "./store-Df0-fzCl.js";
5
- import { t as ScheduleKVStorage } from "./kv-storage-C0KZZB6v.js";
4
+ import { i as RunScheduleOptions, t as KVScheduleStoreOptions } from "./store-CZHZfttA.js";
5
+ import { t as ScheduleKVStorage } from "./kv-storage-Bm9aYLfZ.js";
6
6
  import { ErrorCatalog, Result, ViteHubError } from "@vite-hub/runtime";
7
+ //#region src/run-errors.d.ts
8
+ type RunScheduleErrorCodes = {
9
+ SCHEDULE_INVALID_SCHEDULED_AT: {
10
+ fix: string;
11
+ why: string;
12
+ };
13
+ SCHEDULE_RUN_STORE_FAILED: {
14
+ fix: string;
15
+ why: string;
16
+ };
17
+ };
18
+ type RunScheduleErrorCode = keyof RunScheduleErrorCodes;
19
+ //#endregion
7
20
  //#region src/run.d.ts
8
21
  /**
9
22
  * Runs a Static Schedule Definition that sets `manual: true` now, as if its cron fired at `scheduledAt` (default: now).
10
- * It resolves with the Schedule Run, also when the handler fails.
23
+ * It returns `[error, run]`. A failed handler is a run with `status: "failed"`, not an error. An invalid `scheduledAt`
24
+ * or a failed run store is `error`. Definition loading errors, unknown names, and Definitions without `manual: true` throw.
11
25
  */
12
- export declare function runSchedule(name: string, options?: RunScheduleOptions): Promise<ScheduleRunRecord>;
26
+ export declare function runSchedule(name: string, options?: RunScheduleOptions): Promise<Result<ScheduleRunRecord, RunScheduleErrorCode>>;
13
27
  //#endregion
14
28
  //#region src/started-errors.d.ts
15
29
  type StartedScheduleErrorCodes = {
@@ -71,4 +85,4 @@ type ScheduleErrorDetails = {
71
85
  valueType: ScheduleErrorValueType;
72
86
  };
73
87
  //#endregion
74
- export { type DiscoveredScheduleDefinition, type KVScheduleStoreOptions, type RunScheduleOptions, type ScheduleDefinition, type ScheduleDefinitionInput, type ScheduleDefinitionRegistry, type ScheduleErrorCode, type ScheduleErrorDetails, type ScheduleErrorField, type ScheduleErrorValueType, type ScheduleHandler, type ScheduleKVStorage, type ScheduleRegistryDefinition, type ScheduleRunAttemptRecord, type ScheduleRunAttemptStatus, type ScheduleRunContext, type ScheduleRunError, type ScheduleRunListOptions, type ScheduleRunRecord, type ScheduleRunResponse, type ScheduleRunStatus, type ScheduleRunStore, type ScheduleValidationErrorCode, type StartScheduleOptions, type StartScheduleTiming, type StartedSchedule, type StartedScheduleErrorCode, type StartedScheduleStore, defineSchedule };
88
+ export { type DiscoveredScheduleDefinition, type KVScheduleStoreOptions, type RunScheduleErrorCode, type RunScheduleOptions, type ScheduleDefinition, type ScheduleDefinitionInput, type ScheduleDefinitionRegistry, type ScheduleErrorCode, type ScheduleErrorDetails, type ScheduleErrorField, type ScheduleErrorValueType, type ScheduleHandler, type ScheduleKVStorage, type ScheduleRegistryDefinition, type ScheduleRunAttemptRecord, type ScheduleRunAttemptStatus, type ScheduleRunContext, type ScheduleRunError, type ScheduleRunListOptions, type ScheduleRunRecord, type ScheduleRunResponse, type ScheduleRunStatus, type ScheduleRunStore, type ScheduleValidationErrorCode, type StartScheduleOptions, type StartScheduleTiming, type StartedSchedule, type StartedScheduleErrorCode, type StartedScheduleStore, defineSchedule };
package/dist/index.js CHANGED
@@ -1,10 +1,25 @@
1
1
  import { defineSchedule } from "./definition.js";
2
- import { o as createScheduleError } from "./wait-until-Dy4Bn3ZN.js";
3
- import { a as runScheduleFrom } from "./started-errors-p7cu_rI7.js";
4
- import { i as startSchedule, n as getSchedule, r as listSchedules, t as cancelSchedule } from "./started-Bx7MDbrl.js";
2
+ import { S as createScheduleError, y as parseScheduledAt } from "./static-BgoOCoe5.js";
3
+ import { r as executeManualSchedule, s as resolveManualSchedule } from "./started-errors-BMg04lL3.js";
4
+ import { i as startSchedule, n as getSchedule, r as listSchedules, t as cancelSchedule } from "./started-BWWr7Ufw.js";
5
+ import { defineErrors } from "@vite-hub/runtime";
6
+ //#region src/run-errors.ts
7
+ const runScheduleErrors = /*#__PURE__*/ defineErrors({
8
+ docs: "https://vitehub.dev/docs/schedule/diagnostics",
9
+ codes: {
10
+ SCHEDULE_INVALID_SCHEDULED_AT: {
11
+ why: "`runSchedule()` got a `scheduledAt` that is not a valid date-time.",
12
+ fix: "Pass a valid `Date`, or an ISO 8601 date-time with `Z` or an offset, such as `2026-01-31T23:59:00Z`. Leave it out to run as of now."
13
+ },
14
+ SCHEDULE_RUN_STORE_FAILED: {
15
+ why: "The store of Schedule Runs failed, so the run did not start or its record is incomplete. `error.cause` has the store error.",
16
+ fix: "Check that the Schedule run store is reachable from this server. Before retrying, confirm that the handler did not already run or that it is safe to repeat."
17
+ }
18
+ }
19
+ });
20
+ //#endregion
5
21
  //#region src/run.ts
6
22
  const registryModule = "#vitehub/schedule/registry";
7
- /** The registry that the Schedule Vite plugin generates. It loads on the first run, so importing the root stays cheap. */
8
23
  async function loadRegistry() {
9
24
  try {
10
25
  return (await import(
@@ -18,10 +33,23 @@ async function loadRegistry() {
18
33
  }
19
34
  /**
20
35
  * Runs a Static Schedule Definition that sets `manual: true` now, as if its cron fired at `scheduledAt` (default: now).
21
- * It resolves with the Schedule Run, also when the handler fails.
36
+ * It returns `[error, run]`. A failed handler is a run with `status: "failed"`, not an error. An invalid `scheduledAt`
37
+ * or a failed run store is `error`. Definition loading errors, unknown names, and Definitions without `manual: true` throw.
22
38
  */
23
39
  async function runSchedule(name, options = {}) {
24
- return await runScheduleFrom(await loadRegistry(), name, options);
40
+ const registry = await loadRegistry();
41
+ const definition = await resolveManualSchedule(registry, name);
42
+ let scheduledAt;
43
+ try {
44
+ scheduledAt = parseScheduledAt(options.scheduledAt);
45
+ } catch (cause) {
46
+ return [runScheduleErrors.SCHEDULE_INVALID_SCHEDULED_AT({ cause }), void 0];
47
+ }
48
+ try {
49
+ return [void 0, await executeManualSchedule(definition, name, scheduledAt)];
50
+ } catch (cause) {
51
+ return [runScheduleErrors.SCHEDULE_RUN_STORE_FAILED({ cause }), void 0];
52
+ }
25
53
  }
26
54
  //#endregion
27
55
  export { cancelSchedule, defineSchedule, getSchedule, listSchedules, runSchedule, startSchedule };
@@ -16,9 +16,9 @@ function createScheduleKVStorage(kvStore) {
16
16
  return value ?? false;
17
17
  },
18
18
  async keys(base) {
19
- const [error, value] = await kvStore.keys(base);
19
+ const [error, value] = await kvStore.list({ prefix: base && !/[:/\\]$/.test(base) ? `${base}:` : base });
20
20
  if (error) throw error;
21
- return value ?? [];
21
+ return value?.keys ?? [];
22
22
  },
23
23
  async set(key, value) {
24
24
  const [error] = await kvStore.set(key, value);
@@ -10,7 +10,11 @@ interface ViteHubKVStorage {
10
10
  delete(key: string): Promise<readonly [unknown, unknown]>;
11
11
  get<T = unknown>(key: string): Promise<readonly [unknown, T | null | undefined]>;
12
12
  has(key: string): Promise<readonly [unknown, boolean | undefined]>;
13
- keys(base?: string): Promise<readonly [unknown, string[] | undefined]>;
13
+ list(options: {
14
+ prefix?: string;
15
+ }): Promise<readonly [unknown, {
16
+ keys: string[];
17
+ } | undefined]>;
14
18
  set<T = unknown>(key: string, value: T): Promise<readonly [unknown, unknown]>;
15
19
  }
16
20
  declare function createScheduleKVStorage(kvStore: ViteHubKVStorage): ScheduleKVStorage;
@@ -104,6 +104,11 @@ interface OperationAccess {
104
104
  */
105
105
  readonly sections: "all" | readonly string[];
106
106
  readonly user?: OperationUser;
107
+ /**
108
+ * Who signed the call: `"console"` when the ViteHub Console signed it for a person, whose `user` is then a Console
109
+ * account and not an app user, or `"cli"` for a key. Not set for other calls.
110
+ */
111
+ readonly via?: "console" | "cli";
107
112
  }
108
113
  interface OperationContext {
109
114
  /** The checked Console access of the call. */
@@ -115,6 +120,11 @@ interface OperationContext {
115
120
  surface: "console" | "cli" | "mcp" | "agent";
116
121
  /** Set by the host from generated build identity, never from request input or runtime NODE_ENV. */
117
122
  development?: boolean;
123
+ /**
124
+ * The project root of a development server, for operations that read build files, such as `bundle.report`. Hosts set
125
+ * it only with `development`, so a deployed server never reads project files through it.
126
+ */
127
+ projectRoot?: string;
118
128
  env?: Record<string, unknown>;
119
129
  waitUntil?: (task: Promise<unknown>) => void;
120
130
  request?: Request;
@@ -161,7 +171,8 @@ interface OperationDefinition<Input, Output> {
161
171
  /** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
162
172
  input: StandardSchemaV1<unknown, Input>;
163
173
  output?: StandardSchemaV1<unknown, Output>;
164
- cli?: {
174
+ /** `false`: no `vitehub` command. The Console and MCP still call the operation. */
175
+ cli?: false | {
165
176
  /** Defaults: namespace = section, command = verb. */
166
177
  namespace?: string;
167
178
  /** A space groups commands: `jobs list` and `jobs show` run as `vitehub <namespace> jobs list` and `jobs show`. */
@@ -202,7 +213,7 @@ interface OperationDefinition<Input, Output> {
202
213
  /** An operation of any input and output, as a registry holds it. */
203
214
  interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "mcp" | "output" | "readOnlyWhen" | "run" | "scope" | "section"> {
204
215
  readOnlyWhen?: (input: never) => boolean;
205
- cli?: {
216
+ cli?: false | {
206
217
  namespace?: string;
207
218
  command?: string;
208
219
  default?: boolean;