@vite-hub/workflow 0.4.1 → 0.5.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.
Files changed (60) hide show
  1. package/README.md +28 -10
  2. package/dist/{app-He0GTrYZ.js → app-DXUHElAz.js} +2 -3
  3. package/dist/{app-BojnC_yf.d.ts → app-wkVFd7m-.d.ts} +0 -2
  4. package/dist/{client-DkwOxEiT.js → client-CbBg4HlH.js} +88 -67
  5. package/dist/{cloudflare-BHfClPvT.js → cloudflare-Sgywkm1N.js} +3 -5
  6. package/dist/{cloudflare-env-CGLx7lUd.js → cloudflare-env-DHhzRZOs.js} +2 -4
  7. package/dist/cloudflare-env-lookup-BqomAHN5.d.ts +2 -0
  8. package/dist/{cloudflare-shared-CTqh_a2s.d.ts → cloudflare-shared-B9cY3-jD.d.ts} +1 -3
  9. package/dist/{config-C3DvtjfJ.js → config-CizNRTMi.js} +4 -7
  10. package/dist/definition.d.ts +2 -4
  11. package/dist/definition.js +3 -4
  12. package/dist/{delay-D1-nq_VE.js → delay-CtT3442d.js} +2 -4
  13. package/dist/{dev-recorder-CTN5Fkao.js → dev-recorder-Dltdmlkv.js} +1 -2
  14. package/dist/durability.d.ts +2 -4
  15. package/dist/durability.js +2 -3
  16. package/dist/{error-diagnostics-0V2T3JFw.js → error-diagnostics--2cV_ER1.js} +24 -7
  17. package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-kKXseq8d.js} +10 -3
  18. package/dist/{errors-uhP8DZTi.d.ts → errors-CJZuvOcx.d.ts} +0 -7
  19. package/dist/{errors-DCqRnZpN.js → errors-CZf7oz4k.js} +1 -6
  20. package/dist/index.d.ts +7 -11
  21. package/dist/index.js +5 -6
  22. package/dist/{inspect-B72iFyj-.js → inspect-NBCAwsxi.js} +1 -2
  23. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  24. package/dist/{openworkflow-BhzxV_Y3.d.ts → openworkflow-CdKbUGGa.d.ts} +7 -10
  25. package/dist/{openworkflow-defaults-DDig2M4s.js → openworkflow-defaults-DfQWtSRU.js} +2 -4
  26. package/dist/{openworkflow-storage-Dj9zUAsk.js → openworkflow-storage-Dde_f0es.js} +1 -2
  27. package/dist/openworkflow.js +1 -2
  28. package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
  29. package/dist/{operations-D_WJwjrS.js → operations-BBTmDm2H.js} +31 -44
  30. package/dist/operations.d.ts +5 -12
  31. package/dist/operations.js +33 -43
  32. package/dist/{out-DxLKolA0.js → out-r9T3bhTE.js} +2933 -2301
  33. package/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-DYf_mQCB.js} +2 -3
  34. package/dist/{run-error-DBWqiJHH.js → run-error-8p4BtTMv.js} +5 -8
  35. package/dist/{run-failed-gVGo1BaF.js → run-failed-BcSjSU2t.js} +1 -2
  36. package/dist/runtime/cloudflare-runner.d.ts +14 -6
  37. package/dist/runtime/cloudflare-runner.js +16 -10
  38. package/dist/runtime/cloudflare-shared.d.ts +2 -2
  39. package/dist/runtime/cloudflare-shared.js +1 -2
  40. package/dist/runtime/cloudflare-vite.d.ts +5 -7
  41. package/dist/runtime/cloudflare-vite.js +5 -7
  42. package/dist/runtime/dev-runs.d.ts +1 -3
  43. package/dist/runtime/dev-runs.js +3 -3
  44. package/dist/runtime/execute.d.ts +3 -5
  45. package/dist/runtime/execute.js +66 -35
  46. package/dist/runtime/openworkflow-worker.d.ts +3 -4
  47. package/dist/runtime/openworkflow-worker.js +4 -10
  48. package/dist/runtime/openworkflow.d.ts +2 -2
  49. package/dist/runtime/openworkflow.js +37 -53
  50. package/dist/runtime/state.d.ts +2 -4
  51. package/dist/runtime/state.js +5 -4
  52. package/dist/runtime/vercel-vite.d.ts +3 -6
  53. package/dist/runtime/vercel-vite.js +4 -6
  54. package/dist/signals-BHQdxoJo.js +79 -0
  55. package/dist/{types-Dsmwsdlv.d.ts → types-DvYcvbPG.d.ts} +34 -6
  56. package/dist/{vercel-DTvm61iY.js → vercel-Cw_Z9-j4.js} +5 -14
  57. package/dist/vite.d.ts +12 -29
  58. package/dist/vite.js +4492 -2125
  59. package/package.json +13 -13
  60. package/dist/cloudflare-env-lookup-CfX6wZKb.d.ts +0 -4
@@ -1,6 +1,6 @@
1
- import { t as resolveOpenWorkflowStorage } from "./openworkflow-storage-Dj9zUAsk.js";
1
+ import { t as resolveOpenWorkflowStorage } from "./openworkflow-storage-Dde_f0es.js";
2
2
  import { resolveDurabilityValue } from "@vite-hub/runtime/durability";
3
- //#region src/durability.ts
3
+ // src/durability.ts
4
4
  const sqliteFix = "Set OPENWORKFLOW_POSTGRES_URL to a Postgres URL, or set `workflow.postgres.url`.";
5
5
  function sqlite(path) {
6
6
  return [{
@@ -58,5 +58,4 @@ function workflowDurabilityUrl(value) {
58
58
  default: "set"
59
59
  } : value;
60
60
  }
61
- //#endregion
62
61
  export { workflowDurability, workflowDurabilityUrl };
@@ -1,5 +1,5 @@
1
1
  import { defineDiagnostics } from "nostics";
2
- //#region src/error-diagnostics.ts
2
+ // src/error-diagnostics.ts
3
3
  const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
4
4
  const workflowErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
5
5
  docsBase: "https://vitehub.dev/docs/workflows/diagnostics",
@@ -49,16 +49,12 @@ const workflowErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
49
49
  },
50
50
  WORKFLOW_RUNS_UNAVAILABLE: {
51
51
  why: "This runtime keeps no Workflow run history. Only `vite dev` records runs.",
52
- fix: "Run the app with `vite dev`. On a deployment, read one run with `vitehub workflow get <runId> --workflow <name>`, or use the provider dashboard."
52
+ fix: "Run the app with `vite dev`. On a deployment, read one run with `vitehub workflow runs get <runId> --workflow <name>`, or use the provider dashboard."
53
53
  },
54
54
  WORKFLOW_RUN_AMBIGUOUS: {
55
55
  why: ({ id, workflows }) => `Runs of ${workflows} have the id ${id}.`,
56
56
  fix: "Pass the name of the Workflow with `--workflow <name>`."
57
57
  },
58
- WORKFLOW_RUN_NOT_FOUND: {
59
- why: ({ id }) => `No recorded run has the id ${id}.`,
60
- fix: "Run `vitehub workflow runs list` for the ids. The dev server keeps the newest 200 runs until it restarts or `vitehub workflow runs clear` empties the history."
61
- },
62
58
  WORKFLOW_RUN_UNKNOWN: {
63
59
  why: ({ runId }) => `Run ${runId} was not started by \`workflow.start\` in this runtime.`,
64
60
  fix: "Pass the name of the Workflow with `--workflow <name>`."
@@ -283,10 +279,32 @@ const workflowErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
283
279
  why: ({ value }) => `\`workflow.provider\` is ${value}. ViteHub renamed this key to \`driver\`, and it does not read \`provider\`, so Workflow would not use the driver you chose.`,
284
280
  fix: ({ value }) => `Set \`workflow: { driver: ${value} }\`, or run \`npx @vite-hub/codemods driver-key\` to rename it in every config file.`
285
281
  },
282
+ WORKFLOW_ROOT_STEP_SIGNAL: {
283
+ why: ({ name }) => `[vitehub] The Workflow ${JSON.stringify(name)} called \`signal.wait()\` in its root step. Only a folder Workflow can wait for a signal: move it to \`server/workflows/${name}/index.ts\` and put the work in numbered step files.`,
284
+ fix: "A single-file Workflow runs as one step, so a replay after the wait would run the code before the wait again. Move the handler to `server/workflows/<name>/index.ts`, put each side effect in a numbered step file such as `01.request-transcript.ts`, and call `signal.wait()` between the steps."
285
+ },
286
286
  WORKFLOW_ROOT_STEP_SLEEP: {
287
287
  why: ({ name }) => `[vitehub] The Workflow ${JSON.stringify(name)} called \`context.sleep()\` in its root step. Only a folder Workflow can sleep: move it to \`server/workflows/${name}/index.ts\` and put the work in numbered step files.`,
288
288
  fix: "A single-file Workflow runs as one step, so a replay after a sleep would run the code before the sleep again. Move the handler to `server/workflows/<name>/index.ts`, put each side effect in a numbered step file such as `01.charge.ts`, and call `context.sleep()` between the steps."
289
289
  },
290
+ WORKFLOW_SIGNAL_NOT_WAITING: {
291
+ why: ({ run }) => `[vitehub] No run waits for this signal token. The run ${JSON.stringify(run)} has not reached \`signal.wait()\` yet, it got the signal already, or it ended.`,
292
+ fix: "Retry later when the run can still be before its `signal.wait()`, for example by answering a webhook with a 5xx status so the sender retries. Check the run with `getWorkflowRun()`. An inline run in `vite dev` waits in memory, so a restart of the dev server loses it.",
293
+ data: ({ run }) => ({ run })
294
+ },
295
+ WORKFLOW_SIGNAL_TIMEOUT: {
296
+ why: ({ name }) => `[vitehub] The Workflow ${JSON.stringify(name)} waited one year for a signal, and no \`resumeWorkflow()\` call sent it.`,
297
+ fix: "Call `resumeWorkflow(signal.token, value)` within one year. To stop waiting sooner, cancel the run with `cancelWorkflow()`."
298
+ },
299
+ WORKFLOW_SIGNAL_TOKEN_INVALID: {
300
+ why: ({ provider }) => `[vitehub] \`resumeWorkflow()\` got a token that \`context.createSignal()\` did not make for the ${provider} Workflow provider of this app.`,
301
+ fix: "Pass the `token` of `context.createSignal()` from a run of this app, as it is. A token from another provider, such as an inline run in `vite dev`, does not resume a deployed run.",
302
+ data: ({ provider }) => ({ provider })
303
+ },
304
+ WORKFLOW_SIGNAL_VERCEL_UNSUPPORTED: {
305
+ why: ({ name }) => `[vitehub] The Workflow ${JSON.stringify(name)} called \`context.createSignal()\`. Signals do not work on Vercel yet.`,
306
+ fix: "Run the Workflow on Cloudflare or OpenWorkflow to wait for a signal. On Vercel, a `native` entry can wait with `defineHook()` from the Workflow DevKit, and `resumeWorkflow()` resumes its hook token."
307
+ },
290
308
  WORKFLOW_SLEEP_DURATION_INVALID: {
291
309
  why: ({ name, value }) => `[vitehub] The Workflow ${JSON.stringify(name)} called \`context.sleep(${value})\`. A sleep takes a duration such as \`'30 seconds'\` or \`'1 day'\`, a number of milliseconds that is 0 or more, or a valid \`Date\`.`,
292
310
  fix: "Write the duration as a number, one space, and a unit: second, minute, hour, day, week, month, or year, with or without a final `s`. For example `context.sleep('2 hours')`, `context.sleep(5_000)`, or `context.sleep(new Date(payload.remindAt))`."
@@ -313,5 +331,4 @@ const workflowErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
313
331
  }
314
332
  }
315
333
  });
316
- //#endregion
317
334
  export { workflowErrorDiagnostics as t };
@@ -1,5 +1,5 @@
1
1
  import { defineDiagnostics } from "nostics";
2
- //#region ../internal/src/error-diagnostics.ts
2
+ // ../internal/src/error-diagnostics.ts
3
3
  const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
4
4
  const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
5
5
  docsBase: "https://vitehub.dev/docs/development/diagnostics",
@@ -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: {
@@ -244,6 +244,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
244
244
  why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
245
245
  fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
246
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
+ },
247
251
  INTERNAL_SECRET_PURPOSE_MISSING: {
248
252
  why: "[vitehub] A derived secret requires a purpose.",
249
253
  fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
@@ -252,6 +256,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
252
256
  why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
253
257
  fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
254
258
  },
259
+ INTERNAL_SITE_TOKEN_TOO_LONG: {
260
+ why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
261
+ fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
262
+ },
255
263
  INTERNAL_SQLITE_ARGUMENT_INVALID: {
256
264
  why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
257
265
  fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
@@ -266,5 +274,4 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
266
274
  }
267
275
  }
268
276
  });
269
- //#endregion
270
277
  export { internalErrorDiagnostics as t };
@@ -1,5 +1,4 @@
1
1
  import { ViteHubError } from "@vite-hub/runtime";
2
- //#region src/errors.d.ts
3
2
  declare const workflowErrorMessages: {
4
3
  readonly OPENWORKFLOW_BACKEND_CLOSE_FAILED: "OpenWorkflow backend cleanup failed.";
5
4
  readonly OPENWORKFLOW_RUNTIME_RESET: "OpenWorkflow runtime was reset while it was being acquired.";
@@ -45,7 +44,6 @@ type WorkflowProviderFailure = {
45
44
  };
46
45
  type WorkflowProviderOperationDetails = WorkflowOperationDetails & {
47
46
  acknowledgement?: WorkflowProviderAcknowledgement;
48
- /** The provider error name and the first line of its message, without URLs, file paths, or credentials. */
49
47
  reason?: string;
50
48
  status?: number;
51
49
  };
@@ -54,14 +52,9 @@ type WorkflowErrorDetails<TCode extends WorkflowErrorCode = WorkflowErrorCode> =
54
52
  } : TCode extends "VERCEL_WORKFLOW_SDK_LOAD_FAILED" ? {
55
53
  provider: "vercel";
56
54
  } : TCode extends "WORKFLOW_DEFINITION_NOT_FOUND" ? WorkflowNameDetails : TCode extends "WORKFLOW_DISABLED" ? Record<string, never> : TCode extends "WORKFLOW_NATIVE_ENTRY_INVALID" | "WORKFLOW_NATIVE_ENTRY_REQUIRED" | "WORKFLOW_RUN_ID_UNSUPPORTED" ? VercelWorkflowDetails : TCode extends "WORKFLOW_OPERATION_UNSUPPORTED" ? WorkflowOperationDetails : TCode extends "WORKFLOW_PROVIDER_OPERATION_FAILED" ? WorkflowProviderOperationDetails : never;
57
- /**
58
- * Throw it from a step or a handler to fail the run at once, with no more attempts, on every provider. Cloudflare reads
59
- * `isRetryable`, Workflow DevKit reads `fatal`, and ViteHub stops OpenWorkflow retries itself.
60
- */
61
55
  declare class NonRetryableError extends Error {
62
56
  override name: string;
63
57
  readonly isRetryable = false;
64
58
  readonly fatal = true;
65
59
  }
66
- //#endregion
67
60
  export { WorkflowProviderFailure as a, WorkflowOperationName as i, WorkflowErrorCode as n, WorkflowProviderName as o, WorkflowErrorDetails as r, NonRetryableError as t };
@@ -1,5 +1,5 @@
1
1
  import { ViteHubError } from "@vite-hub/runtime";
2
- //#region src/errors.ts
2
+ // src/errors.ts
3
3
  const workflowErrorMessages = {
4
4
  OPENWORKFLOW_BACKEND_CLOSE_FAILED: "OpenWorkflow backend cleanup failed.",
5
5
  OPENWORKFLOW_RUNTIME_RESET: "OpenWorkflow runtime was reset while it was being acquired.",
@@ -17,10 +17,6 @@ const workflowErrorMessages = {
17
17
  function createWorkflowError(options) {
18
18
  return new ViteHubError(options.code, workflowErrorMessages[options.code], options);
19
19
  }
20
- /**
21
- * Throw it from a step or a handler to fail the run at once, with no more attempts, on every provider. Cloudflare reads
22
- * `isRetryable`, Workflow DevKit reads `fatal`, and ViteHub stops OpenWorkflow retries itself.
23
- */
24
20
  var NonRetryableError = class extends Error {
25
21
  name = "NonRetryableError";
26
22
  isRetryable = false;
@@ -31,5 +27,4 @@ function isNonRetryableError(error) {
31
27
  if (typeof error !== "object" || error === null) return false;
32
28
  return typeof Reflect.get(error, "message") === "string" && (Reflect.get(error, "isRetryable") === false || Reflect.get(error, "name") === "NonRetryableError");
33
29
  }
34
- //#endregion
35
30
  export { createWorkflowError as n, isNonRetryableError as r, NonRetryableError as t };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,8 @@
1
- import { A as WorkflowRun, B as WorkflowStep, C as WorkflowName, D as WorkflowProviderStep, E as WorkflowProviderContext, F as WorkflowSharedOptions, G as WorkflowStepRegistry, H as WorkflowStepContext, I as WorkflowSignalResult, K as WorkflowStepRetries, L as WorkflowStartArguments, M as WorkflowRunStatus, N as WorkflowRunStep, O as WorkflowRegistry, R as WorkflowStartDelay, S as WorkflowModuleDriverOptions, T as WorkflowPayload, U as WorkflowStepFunction, V as WorkflowStepBackoff, W as WorkflowStepOptions, _ as WorkflowDuration, a as InferredWorkflowDriverOptions, b as WorkflowHandle, c as OpenWorkflowWorkerOptions, d as WorkflowCreateOptions, f as WorkflowDefinition, g as WorkflowDriverOptions, h as WorkflowDriver, i as DiscoveredWorkflowDefinition, j as WorkflowRunError, k as WorkflowResultErrorCode, l as ResolvedWorkflowOptions, m as WorkflowDefinitionRegistry, n as CloudflareWorkflowDriverOptions, o as OpenWorkflowDriverOptions, p as WorkflowDefinitionOptions, q as WorkflowSteps, r as CloudflareWorkflowInstance, s as OpenWorkflowPostgresOptions, t as CloudflareWorkflowBinding, u as VercelWorkflowDriverOptions, v as WorkflowDurationUnit, w as WorkflowOptions, x as WorkflowHandler, y as WorkflowExecutionContext, z as WorkflowStartOptions } from "./types-Dsmwsdlv.js";
2
1
  import { defineWorkflow } from "./definition.js";
3
- import { a as WorkflowProviderFailure, i as WorkflowOperationName, n as WorkflowErrorCode, o as WorkflowProviderName, r as WorkflowErrorDetails, t as NonRetryableError } from "./errors-uhP8DZTi.js";
2
+ import { a as WorkflowProviderFailure, i as WorkflowOperationName, n as WorkflowErrorCode, o as WorkflowProviderName, r as WorkflowErrorDetails, t as NonRetryableError } from "./errors-CJZuvOcx.js";
3
+ import { A as WorkflowRun, B as WorkflowStartOptions, C as WorkflowName, D as WorkflowProviderStep, E as WorkflowProviderContext, F as WorkflowSharedOptions, G as WorkflowStepOptions, H as WorkflowStepBackoff, I as WorkflowSignal, J as WorkflowSteps, K as WorkflowStepRegistry, L as WorkflowSignalResult, M as WorkflowRunStatus, N as WorkflowRunStep, O as WorkflowRegistry, R as WorkflowStartArguments, S as WorkflowModuleDriverOptions, T as WorkflowPayload, U as WorkflowStepContext, V as WorkflowStep, W as WorkflowStepFunction, _ as WorkflowDuration, a as InferredWorkflowDriverOptions, b as WorkflowHandle, c as OpenWorkflowWorkerOptions, d as WorkflowCreateOptions, f as WorkflowDefinition, g as WorkflowDriverOptions, h as WorkflowDriver, i as DiscoveredWorkflowDefinition, j as WorkflowRunError, k as WorkflowResultErrorCode, l as ResolvedWorkflowOptions, m as WorkflowDefinitionRegistry, n as CloudflareWorkflowDriverOptions, o as OpenWorkflowDriverOptions, p as WorkflowDefinitionOptions, q as WorkflowStepRetries, r as CloudflareWorkflowInstance, s as OpenWorkflowPostgresOptions, t as CloudflareWorkflowBinding, u as VercelWorkflowDriverOptions, v as WorkflowDurationUnit, w as WorkflowOptions, x as WorkflowHandler, y as WorkflowExecutionContext, z as WorkflowStartDelay } from "./types-DvYcvbPG.js";
4
4
  import { Result } from "@vite-hub/runtime";
5
- //#region src/integrations/cloudflare.d.ts
6
5
  export declare function getCloudflareWorkflowBindingName(name: string): string;
7
- //#endregion
8
- //#region src/runtime/client.d.ts
9
6
  export declare function createWorkflow<TPayload = unknown, TResult = unknown>(options: WorkflowCreateOptions<TPayload, TResult> & {
10
7
  handler: WorkflowHandler<TPayload, TResult>;
11
8
  name: string;
@@ -36,8 +33,10 @@ export declare function getWorkflowRun(name: string, id: string): Promise<Result
36
33
  */
37
34
  export declare function cancelWorkflow(name: string, id: string): Promise<Result<WorkflowRun<unknown, unknown>, WorkflowResultErrorCode>>;
38
35
  /**
39
- * Resumes a run that waits for a signal and returns `[error, signal]`. `token` is the opaque token that the provider
40
- * gave the waiting step. An empty token or a provider failure is `error`. Config errors throw.
36
+ * Resumes a run that waits for a signal and returns `[error, signal]`. `token` is `signal.token` from
37
+ * `context.createSignal()`, or the hook token of a native Vercel entry. `payload` is the value that `signal.wait()`
38
+ * returns: send a JSON value. An invalid token, a run that does not wait for the token, or a provider failure is
39
+ * `error`. Config errors throw.
41
40
  */
42
41
  export declare function resumeWorkflow<TPayload = unknown>(token: string, payload: TPayload): Promise<Result<WorkflowSignalResult, WorkflowResultErrorCode>>;
43
42
  /**
@@ -45,8 +44,6 @@ export declare function resumeWorkflow<TPayload = unknown>(token: string, payloa
45
44
  * Call `startWorkflow()` when the caller needs the run ID or the start error.
46
45
  */
47
46
  export declare function deferWorkflow(...[name, payload, options]: WorkflowStartCall): void;
48
- //#endregion
49
- //#region src/runtime/payload.d.ts
50
47
  interface PayloadSchema<T> {
51
48
  safeParse: (payload: unknown) => {
52
49
  success: boolean;
@@ -62,5 +59,4 @@ type PayloadValidator<T> = PayloadSchema<T> | ParsePayloadSchema<T> | ((payload:
62
59
  export declare function readRequestPayload(request: Request): Promise<unknown>;
63
60
  export declare function validatePayload<T>(payload: unknown, schema: PayloadValidator<T>): Promise<T>;
64
61
  export declare function readValidatedPayload<T>(request: Request, schema: PayloadValidator<T>): Promise<T>;
65
- //#endregion
66
- export { type CloudflareWorkflowBinding, type CloudflareWorkflowDriverOptions, type CloudflareWorkflowInstance, type DiscoveredWorkflowDefinition, type InferredWorkflowDriverOptions, NonRetryableError, type OpenWorkflowDriverOptions, type OpenWorkflowPostgresOptions, type OpenWorkflowWorkerOptions, type ResolvedWorkflowOptions, type VercelWorkflowDriverOptions, type WorkflowCreateOptions, type WorkflowDefinition, type WorkflowDefinitionOptions, type WorkflowDefinitionRegistry, type WorkflowDriver, type WorkflowDriverOptions, type WorkflowDuration, type WorkflowDurationUnit, type WorkflowErrorCode, type WorkflowErrorDetails, type WorkflowExecutionContext, type WorkflowHandle, type WorkflowHandler, type WorkflowModuleDriverOptions, type WorkflowName, type WorkflowOperationName, type WorkflowOptions, type WorkflowPayload, type WorkflowProviderContext, type WorkflowProviderFailure, type WorkflowProviderName, type WorkflowProviderStep, type WorkflowRegistry, type WorkflowResultErrorCode, type WorkflowRun, type WorkflowRunError, type WorkflowRunStatus, type WorkflowRunStep, type WorkflowSharedOptions, type WorkflowSignalResult, type WorkflowStartDelay, type WorkflowStartOptions, type WorkflowStep, type WorkflowStepBackoff, type WorkflowStepContext, type WorkflowStepFunction, type WorkflowStepOptions, type WorkflowStepRegistry, type WorkflowStepRetries, type WorkflowSteps, defineWorkflow };
62
+ export { type CloudflareWorkflowBinding, type CloudflareWorkflowDriverOptions, type CloudflareWorkflowInstance, type DiscoveredWorkflowDefinition, type InferredWorkflowDriverOptions, NonRetryableError, type OpenWorkflowDriverOptions, type OpenWorkflowPostgresOptions, type OpenWorkflowWorkerOptions, type ResolvedWorkflowOptions, type VercelWorkflowDriverOptions, type WorkflowCreateOptions, type WorkflowDefinition, type WorkflowDefinitionOptions, type WorkflowDefinitionRegistry, type WorkflowDriver, type WorkflowDriverOptions, type WorkflowDuration, type WorkflowDurationUnit, type WorkflowErrorCode, type WorkflowErrorDetails, type WorkflowExecutionContext, type WorkflowHandle, type WorkflowHandler, type WorkflowModuleDriverOptions, type WorkflowName, type WorkflowOperationName, type WorkflowOptions, type WorkflowPayload, type WorkflowProviderContext, type WorkflowProviderFailure, type WorkflowProviderName, type WorkflowProviderStep, type WorkflowRegistry, type WorkflowResultErrorCode, type WorkflowRun, type WorkflowRunError, type WorkflowRunStatus, type WorkflowRunStep, type WorkflowSharedOptions, type WorkflowSignal, type WorkflowSignalResult, type WorkflowStartDelay, type WorkflowStartOptions, type WorkflowStep, type WorkflowStepBackoff, type WorkflowStepContext, type WorkflowStepFunction, type WorkflowStepOptions, type WorkflowStepRegistry, type WorkflowStepRetries, type WorkflowSteps, defineWorkflow };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { t as workflowErrorDiagnostics } from "./error-diagnostics-0V2T3JFw.js";
2
1
  import { defineWorkflow } from "./definition.js";
3
- import { t as NonRetryableError } from "./errors-DCqRnZpN.js";
4
- import { n as getCloudflareWorkflowBindingName } from "./cloudflare-BHfClPvT.js";
5
- import { a as resumeWorkflow, i as getWorkflowRun, n as createWorkflow, o as startWorkflow, r as deferWorkflow, t as cancelWorkflow } from "./client-DkwOxEiT.js";
6
- //#region src/runtime/payload.ts
2
+ import { t as NonRetryableError } from "./errors-CZf7oz4k.js";
3
+ import { n as getCloudflareWorkflowBindingName } from "./cloudflare-Sgywkm1N.js";
4
+ import { a as resumeWorkflow, i as getWorkflowRun, n as createWorkflow, o as startWorkflow, r as deferWorkflow, t as cancelWorkflow } from "./client-CbBg4HlH.js";
5
+ import { t as workflowErrorDiagnostics } from "./error-diagnostics--2cV_ER1.js";
6
+ // src/runtime/payload.ts
7
7
  /** Reads a JSON body as parsed JSON and any other body as text. The value is not checked: pass it to `validatePayload()`. */
8
8
  async function readRequestPayload(request) {
9
9
  const contentType = request.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
@@ -40,5 +40,4 @@ function hasSchemaMethod(value, key) {
40
40
  async function readValidatedPayload(request, schema) {
41
41
  return await validatePayload(await readRequestPayload(request), schema);
42
42
  }
43
- //#endregion
44
43
  export { NonRetryableError, cancelWorkflow, createWorkflow, deferWorkflow, defineWorkflow, getCloudflareWorkflowBindingName, getWorkflowRun, readRequestPayload, readValidatedPayload, resumeWorkflow, startWorkflow, validatePayload };
@@ -1,5 +1,5 @@
1
1
  import { relative } from "pathe";
2
- //#region ../internal/src/inspect.ts
2
+ // ../internal/src/inspect.ts
3
3
  function relativeDefinitionFile(projectRoot, file) {
4
4
  return relative(projectRoot, file).replaceAll("\\", "/");
5
5
  }
@@ -66,5 +66,4 @@ function redactInspectionValue(value, key) {
66
66
  }
67
67
  return visit(value, key);
68
68
  }
69
- //#endregion
70
69
  export { redactInspectionValue as n, relativeDefinitionFile as r, redactInspectionText as t };
@@ -1,4 +1,4 @@
1
- //#region ../internal/src/object.ts
1
+ // ../internal/src/object.ts
2
2
  /** A non-null object that is not an array. Functions do not pass. */
3
3
  function isRecord(value) {
4
4
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -7,5 +7,4 @@ function isRecord(value) {
7
7
  function isRecordOrFunction(value) {
8
8
  return Object(value) === value && !Array.isArray(value);
9
9
  }
10
- //#endregion
11
10
  export { isRecordOrFunction as n, isRecord as t };
@@ -1,5 +1,4 @@
1
- import { A as WorkflowRun, f as WorkflowDefinition, l as ResolvedWorkflowOptions, z as WorkflowStartOptions } from "./types-Dsmwsdlv.js";
2
- //#region src/runtime/openworkflow.d.ts
1
+ import { A as WorkflowRun, B as WorkflowStartOptions, f as WorkflowDefinition, l as ResolvedWorkflowOptions } from "./types-DvYcvbPG.js";
3
2
  type OpenWorkflowModule = typeof import("openworkflow");
4
3
  type OpenWorkflowPostgresModule = typeof import("openworkflow/postgres");
5
4
  type OpenWorkflowSqliteModule = typeof import("openworkflow/sqlite");
@@ -10,9 +9,7 @@ type OpenWorkflowImporter = <T>(specifier: string) => Promise<T>;
10
9
  interface OpenWorkflowRuntime {
11
10
  backend: OpenWorkflowBackend;
12
11
  client: OpenWorkflowClient;
13
- /** The registered ViteHub definitions, by name. */
14
12
  definitions: Map<string, WorkflowDefinition>;
15
- /** Returns the OpenWorkflow id of the first run of `name` that started with the id `key`. */
16
13
  findRunId: (name: string, key: string) => Promise<string | undefined>;
17
14
  workflows: Map<string, OpenWorkflowRunnable>;
18
15
  }
@@ -33,13 +30,14 @@ declare function describeOpenWorkflowStorage(config: ResolvedWorkflowOptions): {
33
30
  source: OpenWorkflowStorageSource;
34
31
  };
35
32
  declare function getOpenWorkflowRuntime(config: ResolvedWorkflowOptions): Promise<OpenWorkflowRuntime>;
33
+ /**
34
+ * Sends `value` to a live run that waits for the signal `token`. OpenWorkflow drops early signals and can match
35
+ * a wait left behind by cancellation, so check the run before sending.
36
+ */
37
+ declare function resumeOpenWorkflowSignal(config: ResolvedWorkflowOptions, workflow: string, id: string, token: string, value: unknown): Promise<boolean>;
36
38
  declare function registerOpenWorkflowDefinition(runtime: OpenWorkflowRuntime, name: string, definition: WorkflowDefinition): Promise<OpenWorkflowRunnable>;
37
39
  declare function runOpenWorkflow<TPayload = unknown, TResult = unknown>(config: ResolvedWorkflowOptions, name: string, payload: TPayload | undefined, definition: WorkflowDefinition<TPayload, TResult>, options: WorkflowStartOptions, onDispatch?: () => void, startAt?: number): Promise<WorkflowRun<TPayload, TResult>>;
38
40
  declare function getOpenWorkflowRun<TPayload = unknown, TResult = unknown>(config: ResolvedWorkflowOptions, name: string, id: string): Promise<WorkflowRun<TPayload, TResult>>;
39
- /**
40
- * Cancels a pending or running OpenWorkflow run of this Workflow and returns its state afterwards. A run of another
41
- * Workflow, or an unknown run, reports `unknown` without being cancelled. A finished run keeps and reports its status.
42
- */
43
41
  declare function cancelOpenWorkflowRun<TPayload = unknown, TResult = unknown>(config: ResolvedWorkflowOptions, name: string, id: string): Promise<WorkflowRun<TPayload, TResult>>;
44
42
  declare function resetOpenWorkflowRuntime(): Promise<void>;
45
43
  /**
@@ -48,5 +46,4 @@ declare function resetOpenWorkflowRuntime(): Promise<void>;
48
46
  */
49
47
  declare function detachOpenWorkflowRuntimes(): () => Promise<void>;
50
48
  declare function setOpenWorkflowImporter(importer: OpenWorkflowImporter): void;
51
- //#endregion
52
- export { getOpenWorkflowRun as a, resetOpenWorkflowRuntime as c, setOpenWorkflowImporter as d, detachOpenWorkflowRuntimes as i, runOpenWorkflow as l, cancelOpenWorkflowRun as n, getOpenWorkflowRuntime as o, describeOpenWorkflowStorage as r, registerOpenWorkflowDefinition as s, OpenWorkflowStorageSource as t, setOpenWorkflowDatabaseUrl as u };
49
+ export { getOpenWorkflowRun as a, resetOpenWorkflowRuntime as c, setOpenWorkflowDatabaseUrl as d, setOpenWorkflowImporter as f, detachOpenWorkflowRuntimes as i, resumeOpenWorkflowSignal as l, cancelOpenWorkflowRun as n, getOpenWorkflowRuntime as o, describeOpenWorkflowStorage as r, registerOpenWorkflowDefinition as s, OpenWorkflowStorageSource as t, runOpenWorkflow as u };
@@ -1,5 +1,5 @@
1
1
  import { defineDiagnostics } from "nostics";
2
- //#region ../internal/src/invariant.ts
2
+ // ../internal/src/invariant.ts
3
3
  const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
4
4
  docsBase: "https://vitehub.dev/docs/development/diagnostics",
5
5
  codes: { INTERNAL_INVARIANT_FAILED: {
@@ -18,9 +18,7 @@ function invariantError(what) {
18
18
  function invariant(condition, what) {
19
19
  if (!condition) throw invariantError(what);
20
20
  }
21
- //#endregion
22
- //#region src/internal/openworkflow-defaults.ts
21
+ // src/internal/openworkflow-defaults.ts
23
22
  /** The SQLite file that OpenWorkflow uses without configured storage, relative to the working directory of the server. */
24
23
  const defaultOpenWorkflowSqlitePath = ".vitehub/data/openworkflow.sqlite.db";
25
- //#endregion
26
24
  export { invariant as n, invariantError as r, defaultOpenWorkflowSqlitePath as t };
@@ -1,4 +1,4 @@
1
- //#region src/internal/openworkflow-storage.ts
1
+ // src/internal/openworkflow-storage.ts
2
2
  /** Select storage once for both the OpenWorkflow runtime and its durability report. Values are already resolved. */
3
3
  function resolveOpenWorkflowStorage(input, readEnv) {
4
4
  const sqlitePath = input.sqlitePath || (!input.postgresUrl ? readEnv("OPENWORKFLOW_SQLITE_PATH") : void 0);
@@ -24,5 +24,4 @@ function resolveOpenWorkflowStorage(input, readEnv) {
24
24
  source: "default"
25
25
  };
26
26
  }
27
- //#endregion
28
27
  export { resolveOpenWorkflowStorage as t };
@@ -1,2 +1 @@
1
- import { createOpenWorkflowWorker, installOpenWorkflow, startOpenWorkflowWorker } from "./runtime/openworkflow-worker.js";
2
- export { createOpenWorkflowWorker, installOpenWorkflow, startOpenWorkflowWorker };
1
+ export { createOpenWorkflowWorker, installOpenWorkflow, startOpenWorkflowWorker } from "./runtime/openworkflow-worker.js";
@@ -1,4 +1,3 @@
1
- //#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
2
1
  /** The Standard Typed interface. This is a base type extended by other specs. */
3
2
  interface StandardTypedV1<Input = unknown, Output = Input> {
4
3
  /** The Standard properties. */
@@ -74,8 +73,6 @@ declare namespace StandardSchemaV1 {
74
73
  /** Infers the output type of a Standard. */
75
74
  type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
76
75
  }
77
- //#endregion
78
- //#region ../internal/src/operation-definition.d.ts
79
76
  /** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
80
77
  type OperationKind = "read" | "write" | "destructive";
81
78
  /** The signed-in user of a call. */
@@ -104,6 +101,11 @@ interface OperationAccess {
104
101
  */
105
102
  readonly sections: "all" | readonly string[];
106
103
  readonly user?: OperationUser;
104
+ /**
105
+ * Who signed the call: `"console"` when the ViteHub Console signed it for a person, whose `user` is then a Console
106
+ * account and not an app user, or `"cli"` for a key. Not set for other calls.
107
+ */
108
+ readonly via?: "console" | "cli";
107
109
  }
108
110
  interface OperationContext {
109
111
  /** The checked Console access of the call. */
@@ -166,7 +168,8 @@ interface OperationDefinition<Input, Output> {
166
168
  /** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
167
169
  input: StandardSchemaV1<unknown, Input>;
168
170
  output?: StandardSchemaV1<unknown, Output>;
169
- cli?: {
171
+ /** `false`: no `vitehub` command. The Console and MCP still call the operation. */
172
+ cli?: false | {
170
173
  /** Defaults: namespace = section, command = verb. */
171
174
  namespace?: string;
172
175
  /** A space groups commands: `jobs list` and `jobs show` run as `vitehub <namespace> jobs list` and `jobs show`. */
@@ -207,7 +210,7 @@ interface OperationDefinition<Input, Output> {
207
210
  /** An operation of any input and output, as a registry holds it. */
208
211
  interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "mcp" | "output" | "readOnlyWhen" | "run" | "scope" | "section"> {
209
212
  readOnlyWhen?: (input: never) => boolean;
210
- cli?: {
213
+ cli?: false | {
211
214
  namespace?: string;
212
215
  command?: string;
213
216
  default?: boolean;
@@ -235,5 +238,4 @@ interface OperationContributionEntry {
235
238
  /** `false`: the app already has these operations at runtime. Only tools such as the CLI and `vitehub inspect` read the entry. */
236
239
  runtime?: false;
237
240
  }
238
- //#endregion
239
241
  export { OperationContributionEntry as n, AnyOperation as t };
@@ -1,19 +1,13 @@
1
- import { t as isRecord } from "./object-Da1zyPCR.js";
2
- import { t as workflowErrorDiagnostics } from "./error-diagnostics-0V2T3JFw.js";
3
- import { a as resumeWorkflow, i as getWorkflowRun, o as startWorkflow, t as cancelWorkflow } from "./client-DkwOxEiT.js";
4
- import { t as getWorkflowDevRecorder } from "./dev-recorder-CTN5Fkao.js";
5
- import { n as redactInspectionValue, t as redactInspectionText } from "./inspect-B72iFyj-.js";
6
- import { t as toWorkflowRunError } from "./run-error-DBWqiJHH.js";
1
+ import { n as redactInspectionValue, t as redactInspectionText } from "./inspect-NBCAwsxi.js";
2
+ import { t as isRecord } from "./object-CAK6UYR5.js";
3
+ import { t as workflowErrorDiagnostics } from "./error-diagnostics--2cV_ER1.js";
4
+ import { a as resumeWorkflow, i as getWorkflowRun, o as startWorkflow, t as cancelWorkflow } from "./client-CbBg4HlH.js";
5
+ import { t as getWorkflowDevRecorder } from "./dev-recorder-Dltdmlkv.js";
6
+ import { t as toWorkflowRunError } from "./run-error-8p4BtTMv.js";
7
7
  import { getInlineWorkflowDefinitions, getWorkflowRuntimeConfig, getWorkflowRuntimeRegistry } from "./runtime/state.js";
8
- import { deserializeResponse, isSerializedResponse } from "@vite-hub/runtime";
9
- //#region src/results.ts
8
+ import { deserializeResponse, isSerializedResponse } from "@vite-hub/runtime/internal/response";
9
+ // src/results.ts
10
10
  const inlineRunNote = "Runs the Workflow inline in the Nitro runtime, as the app does in development. Inline runs are not durable and have no retries.";
11
- function unsupported(note) {
12
- return {
13
- note,
14
- supported: false
15
- };
16
- }
17
11
  /**
18
12
  * Operations that each provider supports. A supported operation can still fail when the runtime decides, for example
19
13
  * cancel on an inline Vercel run.
@@ -28,7 +22,10 @@ function resolveWorkflowOperationSupport(provider) {
28
22
  note: "Reads the run from the Cloudflare Workflow binding when the runtime has one.",
29
23
  supported: true
30
24
  },
31
- resume: unsupported("Cloudflare Workflows do not support ViteHub signals."),
25
+ resume: {
26
+ note: "Queues a signal through the Cloudflare Workflow binding, or delivers it to an inline run in this process.",
27
+ supported: true
28
+ },
32
29
  start: {
33
30
  note: `Uses the Cloudflare Workflow binding when the runtime has one. Otherwise: ${inlineRunNote}`,
34
31
  supported: true
@@ -43,7 +40,10 @@ function resolveWorkflowOperationSupport(provider) {
43
40
  note: "Reads the run from OpenWorkflow storage.",
44
41
  supported: true
45
42
  },
46
- resume: unsupported("OpenWorkflow does not support ViteHub signals."),
43
+ resume: {
44
+ note: "Delivers a signal to a waiting OpenWorkflow run, or to an inline run in this process.",
45
+ supported: true
46
+ },
47
47
  start: {
48
48
  note: "Enqueues the run in OpenWorkflow storage. The run stays queued until an OpenWorkflow worker processes the same storage.",
49
49
  supported: true
@@ -68,10 +68,8 @@ function resolveWorkflowOperationSupport(provider) {
68
68
  }
69
69
  };
70
70
  }
71
- //#endregion
72
- //#region src/runtime/operations.ts
71
+ // src/runtime/operations.ts
73
72
  const maxRememberedRuns = 1024;
74
- /** The HTTP status that the CLI, the Console, and Agents report for each code of a failed operation. */
75
73
  const operationStatus = {
76
74
  VERCEL_WORKFLOW_SDK_LOAD_FAILED: 501,
77
75
  WORKFLOW_DEFINITION_NOT_FOUND: 404,
@@ -83,11 +81,11 @@ const operationStatus = {
83
81
  WORKFLOW_PROVIDER_OPERATION_FAILED: 502,
84
82
  WORKFLOW_REGISTRY_MISSING: 409,
85
83
  WORKFLOW_RUN_AMBIGUOUS: 400,
86
- WORKFLOW_RUN_NOT_FOUND: 404,
87
84
  WORKFLOW_RUN_UNKNOWN: 400,
88
- WORKFLOW_RUNS_UNAVAILABLE: 409
85
+ WORKFLOW_RUNS_UNAVAILABLE: 409,
86
+ WORKFLOW_SIGNAL_NOT_WAITING: 409,
87
+ WORKFLOW_SIGNAL_TOKEN_INVALID: 400
89
88
  };
90
- /** Gives an operation error the status of its code and the redacted message that the CLI and the Console report. */
91
89
  function failure(error, message = error.message) {
92
90
  return Object.defineProperties(error, {
93
91
  status: {
@@ -107,11 +105,6 @@ function failure(error, message = error.message) {
107
105
  function hasStatus(error) {
108
106
  return error instanceof Error && typeof Reflect.get(error, "status") === "number" && typeof Reflect.get(error, "code") === "string";
109
107
  }
110
- /**
111
- * Checks the Fetch Response fields, not one realm's constructor, so a Response from another Fetch implementation also
112
- * matches. `status` and `headers` alone also match an HTTP client result, such as an Axios response, so the body fields
113
- * are checked too. The Agent package has the same check.
114
- */
115
108
  function isResponse$1(value) {
116
109
  if (typeof value !== "object" || value === null) return false;
117
110
  const response = value;
@@ -267,13 +260,22 @@ async function run(operation, input) {
267
260
  } };
268
261
  }
269
262
  const { runId, workflow: named } = input;
263
+ const recorded = operation === "get" ? getWorkflowDevRecorder()?.list().filter((record) => record.id === runId && (named === void 0 || record.workflow === named)) ?? [] : [];
264
+ if (recorded.length > 1) throw failure(workflowErrorDiagnostics.WORKFLOW_RUN_AMBIGUOUS({
265
+ id: runId,
266
+ workflows: recorded.map((record) => record.workflow).join(", ")
267
+ }));
268
+ const [record] = recorded;
269
+ if (record) return { run: {
270
+ ...await toWorkflowRunView(devRunView(record), record.workflow),
271
+ steps: record.steps.map(stepView)
272
+ } };
270
273
  const workflow = named ?? startedRuns.get(runId);
271
274
  if (!workflow) throw failure(workflowErrorDiagnostics.WORKFLOW_RUN_UNKNOWN({ runId }));
272
275
  const [error, found] = operation === "get" ? await getWorkflowRun(workflow, runId) : await cancelWorkflow(workflow, runId);
273
276
  if (error) throw error;
274
277
  return { run: await toWorkflowRunView(found, workflow) };
275
278
  }
276
- /** The run history of `vite dev`. Hosted providers keep their own history, which ViteHub does not list. */
277
279
  function devRecorder() {
278
280
  if (getWorkflowRuntimeConfig() === false) throw failure(workflowErrorDiagnostics.WORKFLOW_DISABLED());
279
281
  const recorder = getWorkflowDevRecorder();
@@ -311,23 +313,8 @@ async function listWorkflowRuns(input) {
311
313
  stepCount: record.steps.length
312
314
  }))) };
313
315
  }
314
- /** Shows one run that `vite dev` recorded, with its steps, result, and error. */
315
- async function showWorkflowRun(input) {
316
- const matches = devRecorder().list().filter((record) => record.id === input.id && (input.workflow === void 0 || record.workflow === input.workflow));
317
- if (matches.length === 0) throw failure(workflowErrorDiagnostics.WORKFLOW_RUN_NOT_FOUND({ id: input.id }));
318
- if (matches.length > 1) throw failure(workflowErrorDiagnostics.WORKFLOW_RUN_AMBIGUOUS({
319
- id: input.id,
320
- workflows: matches.map((record) => record.workflow).join(", ")
321
- }));
322
- const record = matches[0];
323
- return { run: {
324
- ...await toWorkflowRunView(devRunView(record), record.workflow),
325
- steps: record.steps.map(stepView)
326
- } };
327
- }
328
316
  /** Removes the runs that `vite dev` recorded. A run that is still active finishes but is not listed again. */
329
317
  function clearWorkflowRuns() {
330
318
  return { cleared: devRecorder().clear() };
331
319
  }
332
- //#endregion
333
- export { clearWorkflowRuns, listWorkflowRuns, runWorkflowOperation, showWorkflowRun, toWorkflowRunView };
320
+ export { clearWorkflowRuns, listWorkflowRuns, runWorkflowOperation, toWorkflowRunView };
@@ -1,6 +1,5 @@
1
- import { M as WorkflowRunStatus, h as WorkflowDriver } from "./types-Dsmwsdlv.js";
2
- import { t as AnyOperation } from "./operation-definition-nmRu_O3V.js";
3
- //#region src/results.d.ts
1
+ import { t as AnyOperation } from "./operation-definition-CqZkx1Rm.js";
2
+ import { M as WorkflowRunStatus, h as WorkflowDriver } from "./types-DvYcvbPG.js";
4
3
  /** One Workflow run as the operations return it. The start payload is not included. */
5
4
  interface WorkflowRunView {
6
5
  completedAt?: string;
@@ -24,7 +23,8 @@ interface WorkflowSignalView {
24
23
  provider: WorkflowDriver;
25
24
  }
26
25
  interface WorkflowRunResult {
27
- run: WorkflowRunView;
26
+ /** `workflow.get` adds the steps of a run that `vite dev` recorded. */
27
+ run: WorkflowRunView | WorkflowRunDetailView;
28
28
  }
29
29
  /** One step of a run that `vite dev` recorded. */
30
30
  interface WorkflowRunStepView {
@@ -53,19 +53,12 @@ interface WorkflowRunsListResult {
53
53
  interface WorkflowRunsClearResult {
54
54
  cleared: number;
55
55
  }
56
- /** Result of `workflow.runs-show`. */
57
- interface WorkflowRunsShowResult {
58
- run: WorkflowRunDetailView;
59
- }
60
56
  interface WorkflowSignalResult {
61
57
  signal: WorkflowSignalView;
62
58
  }
63
- //#endregion
64
- //#region src/operations.d.ts
65
59
  /**
66
60
  * The `workflow.*` operations: start, get, cancel, resume, and the run history of `vite dev`. The Console,
67
61
  * `vitehub workflow`, and agents run them.
68
62
  */
69
63
  export declare const workflowOperations: readonly AnyOperation[];
70
- //#endregion
71
- export type { WorkflowRunDetailView, WorkflowRunResult, WorkflowRunStepView, WorkflowRunView, WorkflowRunsClearResult, WorkflowRunsListResult, WorkflowRunsShowResult, WorkflowSignalResult, WorkflowSignalView };
64
+ export type { WorkflowRunDetailView, WorkflowRunResult, WorkflowRunStepView, WorkflowRunView, WorkflowRunsClearResult, WorkflowRunsListResult, WorkflowSignalResult, WorkflowSignalView };