@vite-hub/workflow 0.0.4 → 0.1.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 (45) hide show
  1. package/README.md +34 -14
  2. package/dist/{_app-DgwN4ulW.d.ts → app-BojnC_yf.d.ts} +1 -4
  3. package/dist/{app-BZpq2cwC.js → app-CzPoP84f.js} +2 -1
  4. package/dist/client-DsGM3M4U.js +389 -0
  5. package/dist/cloudflare-env-BNrYo29x.js +113 -0
  6. package/dist/{cloudflare-D0Di-QYL.js → cloudflare-nF4abPd4.js} +20 -4
  7. package/dist/cloudflare-shared-CaxrMD1A.d.ts +1 -0
  8. package/dist/{cloudflare-vite-BkDgB6Sr.js → cloudflare-vite-B3IabBsv.js} +5 -4
  9. package/dist/{config-BHknO_rT.js → config-IJMb0eeZ.js} +38 -30
  10. package/dist/error-diagnostics-A_8Kp-48.js +116 -0
  11. package/dist/error-diagnostics-pwNFvAHP.js +67 -0
  12. package/dist/index.d.ts +20 -21
  13. package/dist/index.js +25 -369
  14. package/dist/inspect-B72iFyj-.js +70 -0
  15. package/dist/operations-B_rYG71W.js +230 -0
  16. package/dist/operations-tNUdj3G4.d.ts +212 -0
  17. package/dist/operations.d.ts +37 -0
  18. package/dist/operations.js +887 -0
  19. package/dist/out-CsaJxg8m.js +21755 -0
  20. package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
  21. package/dist/runtime/cloudflare-runner.d.ts +5 -15
  22. package/dist/runtime/cloudflare-runner.js +40 -5
  23. package/dist/runtime/cloudflare-shared.d.ts +1 -0
  24. package/dist/runtime/cloudflare-shared.js +1 -1
  25. package/dist/runtime/cloudflare-vite.d.ts +8 -10
  26. package/dist/runtime/cloudflare-vite.js +1 -1
  27. package/dist/runtime/execute.d.ts +8 -7
  28. package/dist/runtime/execute.js +28 -5
  29. package/dist/runtime/openworkflow-worker.d.ts +6 -8
  30. package/dist/runtime/openworkflow-worker.js +5 -4
  31. package/dist/runtime/openworkflow.d.ts +8 -10
  32. package/dist/runtime/openworkflow.js +23 -17
  33. package/dist/runtime/state.d.ts +20 -21
  34. package/dist/runtime/state.js +90 -20
  35. package/dist/runtime/vercel-vite.d.ts +10 -12
  36. package/dist/runtime/vercel-vite.js +2 -2
  37. package/dist/runtime-type-DBCvIh5x.js +7 -0
  38. package/dist/{types-B9RdRkKh.d.ts → types-D82WmfZa.d.ts} +23 -12
  39. package/dist/{vercel-B0MuIVgJ.js → vercel-D-ZNtB_u.js} +34 -9
  40. package/dist/vite.d.ts +325 -11
  41. package/dist/vite.js +1267 -691
  42. package/package.json +79 -29
  43. package/dist/cloudflare-env-DjxQNbrx.js +0 -58
  44. package/dist/cloudflare-shared-BVVgDSdq.d.ts +0 -1
  45. package/dist/runtime-type-DGUn8Ple.js +0 -37
@@ -0,0 +1,230 @@
1
+ import { a as resumeWorkflowSignal, i as getWorkflowRun, o as runWorkflow, t as cancelWorkflow } from "./client-DsGM3M4U.js";
2
+ import { getInlineWorkflowDefinitions, getWorkflowRuntimeConfig, getWorkflowRuntimeRegistry } from "./runtime/state.js";
3
+ import { n as redactInspectionValue, t as redactInspectionText } from "./inspect-B72iFyj-.js";
4
+ //#region src/results.ts
5
+ 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.";
6
+ function unsupported(note) {
7
+ return {
8
+ note,
9
+ supported: false
10
+ };
11
+ }
12
+ /**
13
+ * Operations that each provider supports. A supported operation can still fail when the runtime decides, for example
14
+ * cancel on an inline Vercel run.
15
+ */
16
+ function resolveWorkflowOperationSupport(provider) {
17
+ if (provider === "cloudflare") return {
18
+ cancel: unsupported("Cloudflare Workflows do not support cancellation through ViteHub."),
19
+ get: {
20
+ note: "Reads the run from the Cloudflare Workflow binding when the runtime has one.",
21
+ supported: true
22
+ },
23
+ resume: unsupported("Cloudflare Workflows do not support ViteHub signals."),
24
+ start: {
25
+ note: `Uses the Cloudflare Workflow binding when the runtime has one. Otherwise: ${inlineRunNote}`,
26
+ supported: true
27
+ }
28
+ };
29
+ if (provider === "openworkflow") return {
30
+ cancel: unsupported("OpenWorkflow does not support cancellation through ViteHub."),
31
+ get: {
32
+ note: "Reads the run from OpenWorkflow storage.",
33
+ supported: true
34
+ },
35
+ resume: unsupported("OpenWorkflow does not support ViteHub signals."),
36
+ start: {
37
+ note: "Enqueues the run in OpenWorkflow storage. The run stays queued until an OpenWorkflow worker processes the same storage.",
38
+ supported: true
39
+ }
40
+ };
41
+ return {
42
+ cancel: {
43
+ note: "Only native Vercel Workflow runs can be cancelled. Inline runs return an unsupported error.",
44
+ supported: true
45
+ },
46
+ get: {
47
+ note: "Reads inline runs, which expire 5 minutes after they finish. Native Vercel Workflow runs need the Workflow DevKit runtime.",
48
+ supported: true
49
+ },
50
+ resume: {
51
+ note: "Signals need a native Vercel Workflow run and the Workflow DevKit runtime.",
52
+ supported: true
53
+ },
54
+ start: {
55
+ note: `${inlineRunNote} Native Vercel Workflow Definitions need the Workflow DevKit runtime.`,
56
+ supported: true
57
+ }
58
+ };
59
+ }
60
+ //#endregion
61
+ //#region src/runtime/operations.ts
62
+ const maxRememberedRuns = 1024;
63
+ /** A failure of a Workflow operation, with the status and code that every surface reports. */
64
+ var WorkflowOperationError = class extends Error {
65
+ code;
66
+ fix;
67
+ status;
68
+ constructor(message, status, code, fix) {
69
+ super(message);
70
+ this.name = "WorkflowOperationError";
71
+ this.code = code;
72
+ this.status = status;
73
+ if (fix) this.fix = fix;
74
+ }
75
+ };
76
+ function isRecord(value) {
77
+ return !!value && typeof value === "object" && !Array.isArray(value);
78
+ }
79
+ function isResponse(value) {
80
+ if (value instanceof Response) return true;
81
+ const statusGetter = Object.getOwnPropertyDescriptor(Response.prototype, "status")?.get;
82
+ if (!statusGetter) return false;
83
+ try {
84
+ statusGetter.call(value);
85
+ return true;
86
+ } catch {
87
+ return false;
88
+ }
89
+ }
90
+ function jsonReplacer(_key, value) {
91
+ if (typeof value === "bigint") return value.toString();
92
+ if (value instanceof Error) return serializeError(value);
93
+ if (isResponse(value)) return { response: {
94
+ status: value.status,
95
+ statusText: value.statusText
96
+ } };
97
+ return value;
98
+ }
99
+ function toJsonValue(value) {
100
+ if (value === void 0) return void 0;
101
+ try {
102
+ const text = JSON.stringify(value, jsonReplacer);
103
+ return text === void 0 ? void 0 : redactInspectionValue(JSON.parse(text));
104
+ } catch {
105
+ return "[unserializable]";
106
+ }
107
+ }
108
+ function errorCode(error) {
109
+ if (!error || typeof error !== "object") return;
110
+ const code = Reflect.get(error, "code");
111
+ return typeof code === "string" ? code : void 0;
112
+ }
113
+ function serializeError(error) {
114
+ const code = errorCode(error);
115
+ return {
116
+ ...code ? { code } : {},
117
+ message: redactInspectionText(error.message),
118
+ ...error.name && error.name !== "Error" ? { name: error.name } : {}
119
+ };
120
+ }
121
+ function toIsoDate(value) {
122
+ if (value instanceof Date) return Number.isNaN(value.getTime()) ? void 0 : value.toISOString();
123
+ return typeof value === "string" ? value : void 0;
124
+ }
125
+ function isErrorLike(value) {
126
+ return value instanceof Error || isRecord(value) && typeof value.message === "string";
127
+ }
128
+ async function readResult(result) {
129
+ if (!isResponse(result)) return result;
130
+ const text = await result.clone().text();
131
+ if (!text) return void 0;
132
+ try {
133
+ return JSON.parse(text);
134
+ } catch {
135
+ return text;
136
+ }
137
+ }
138
+ /**
139
+ * Converts a runtime Workflow run to JSON data. The view omits the start
140
+ * payload and redacts credentials in the metadata, result, and error message.
141
+ */
142
+ async function toWorkflowRunView(run, workflow) {
143
+ const createdAt = toIsoDate(run.createdAt);
144
+ const startedAt = toIsoDate(run.startedAt);
145
+ const completedAt = toIsoDate(run.completedAt);
146
+ const error = run.status === "failed" && isErrorLike(run.metadata) ? serializeError(run.metadata) : void 0;
147
+ const metadata = error ? void 0 : toJsonValue(run.metadata);
148
+ const result = toJsonValue(await readResult(run.result));
149
+ return {
150
+ ...completedAt ? { completedAt } : {},
151
+ ...createdAt ? { createdAt } : {},
152
+ ...error ? { error } : {},
153
+ id: run.id,
154
+ ...metadata === void 0 ? {} : { metadata },
155
+ provider: run.provider,
156
+ ...result === void 0 ? {} : { result },
157
+ ...startedAt ? { startedAt } : {},
158
+ status: run.status,
159
+ workflow
160
+ };
161
+ }
162
+ function runtimeFailure(operation, provider, error) {
163
+ if (error instanceof WorkflowOperationError) return error;
164
+ const code = errorCode(error);
165
+ if (code === "WORKFLOW_OPERATION_UNSUPPORTED") return new WorkflowOperationError(`workflow ${operation} is not supported by the ${provider} provider for this run.`, 501, code);
166
+ if (code === "WORKFLOW_DISABLED") return new WorkflowOperationError("Workflow is disabled in this runtime.", 409, code, "Enable Workflow with `vitehub({ workflow: true })` or `hubWorkflow()`.");
167
+ if (code === "WORKFLOW_DEFINITION_NOT_FOUND") return new WorkflowOperationError("Workflow definition was not found.", 404, code);
168
+ if (code === "VERCEL_WORKFLOW_SDK_LOAD_FAILED" || code === "WORKFLOW_NATIVE_ENTRY_INVALID" || code === "WORKFLOW_NATIVE_ENTRY_REQUIRED") return new WorkflowOperationError(`workflow ${operation} needs the Vercel Workflow DevKit runtime, which the runtime could not load.`, 501, code);
169
+ if (code === "WORKFLOW_PROVIDER_OPERATION_FAILED") {
170
+ const cause = error instanceof Error ? error.cause : void 0;
171
+ return new WorkflowOperationError(`workflow ${operation} failed in the ${provider} provider.${cause instanceof Error && cause.message ? ` ${redactInspectionText(cause.message)}` : ""}`, 502, code);
172
+ }
173
+ const message = error instanceof Error ? error.message : String(error);
174
+ return new WorkflowOperationError(redactInspectionText(message || "The Workflow operation failed."), 500, code || "WORKFLOW_OPERATION_FAILED");
175
+ }
176
+ function startableWorkflows() {
177
+ return [.../* @__PURE__ */ new Set([...Object.keys(getWorkflowRuntimeRegistry() ?? {}), ...getInlineWorkflowDefinitions().keys()])].sort();
178
+ }
179
+ const startedRuns = /* @__PURE__ */ new Map();
180
+ function rememberRun(id, workflow) {
181
+ startedRuns.delete(id);
182
+ startedRuns.set(id, workflow);
183
+ if (startedRuns.size > maxRememberedRuns) {
184
+ const oldest = startedRuns.keys().next().value;
185
+ if (oldest !== void 0) startedRuns.delete(oldest);
186
+ }
187
+ }
188
+ /**
189
+ * Runs one Workflow operation in the runtime of the app, so it uses the same Workflow state and registry as the app.
190
+ * It redacts credentials in run data and error messages. Failures are `WorkflowOperationError`s.
191
+ */
192
+ async function runWorkflowOperation(operation, input) {
193
+ const runtimeConfig = getWorkflowRuntimeConfig();
194
+ if (runtimeConfig === false) throw new WorkflowOperationError("Workflow is disabled in this runtime.", 409, "WORKFLOW_DISABLED", "Enable Workflow with `vitehub({ workflow: true })` or `hubWorkflow()`.");
195
+ const provider = runtimeConfig?.provider ?? "vercel";
196
+ const support = resolveWorkflowOperationSupport(provider)[operation];
197
+ if (!support.supported) throw new WorkflowOperationError(`workflow ${operation} is not supported by the ${provider} provider. ${support.note}`, 501, "WORKFLOW_OPERATION_UNSUPPORTED");
198
+ try {
199
+ return await run(operation, input);
200
+ } catch (error) {
201
+ throw runtimeFailure(operation, provider, error);
202
+ }
203
+ }
204
+ async function run(operation, input) {
205
+ if (operation === "start") {
206
+ const { payload, workflow } = input;
207
+ const workflows = startableWorkflows();
208
+ if (!workflows.includes(workflow)) {
209
+ if (!getWorkflowRuntimeRegistry()) throw new WorkflowOperationError(`Unknown Workflow: ${workflow}. The runtime has no Workflow registry.`, 409, "WORKFLOW_REGISTRY_MISSING", "Restart the dev server. In development the Workflow Vite plugin installs the registry with the Nitro plugin .vitehub/nitro/workflow/dev-plugin.mjs.");
210
+ throw new WorkflowOperationError(`Unknown Workflow: ${workflow}.${workflows.length ? ` Available Workflows: ${workflows.join(", ")}.` : " The Workflow registry of the runtime is empty."}`, 404, "WORKFLOW_DEFINITION_NOT_FOUND");
211
+ }
212
+ const started = await runWorkflow(workflow, payload);
213
+ rememberRun(started.id, workflow);
214
+ return { run: await toWorkflowRunView(started, workflow) };
215
+ }
216
+ if (operation === "resume") {
217
+ const { payload, token } = input;
218
+ const signal = await resumeWorkflowSignal(token, payload);
219
+ return { signal: {
220
+ id: signal.id,
221
+ provider: signal.provider
222
+ } };
223
+ }
224
+ const { runId, workflow: named } = input;
225
+ const workflow = named ?? startedRuns.get(runId);
226
+ if (!workflow) throw new WorkflowOperationError(`Run ${runId} was not started by \`workflow.start\` in this runtime.`, 400, "WORKFLOW_RUN_UNKNOWN", "Pass the name of the Workflow with `--workflow <name>`.");
227
+ return { run: await toWorkflowRunView(operation === "get" ? await getWorkflowRun(workflow, runId) : await cancelWorkflow(workflow, runId), workflow) };
228
+ }
229
+ //#endregion
230
+ export { WorkflowOperationError, runWorkflowOperation, toWorkflowRunView };
@@ -0,0 +1,212 @@
1
+ //#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
2
+ /** The Standard Typed interface. This is a base type extended by other specs. */
3
+ interface StandardTypedV1<Input = unknown, Output = Input> {
4
+ /** The Standard properties. */
5
+ readonly "~standard": StandardTypedV1.Props<Input, Output>;
6
+ }
7
+ declare namespace StandardTypedV1 {
8
+ /** The Standard Typed properties interface. */
9
+ interface Props<Input = unknown, Output = Input> {
10
+ /** The version number of the standard. */
11
+ readonly version: 1;
12
+ /** The vendor name of the schema library. */
13
+ readonly vendor: string;
14
+ /** Inferred types associated with the schema. */
15
+ readonly types?: Types<Input, Output> | undefined;
16
+ }
17
+ /** The Standard Typed types interface. */
18
+ interface Types<Input = unknown, Output = Input> {
19
+ /** The input type of the schema. */
20
+ readonly input: Input;
21
+ /** The output type of the schema. */
22
+ readonly output: Output;
23
+ }
24
+ /** Infers the input type of a Standard Typed. */
25
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
26
+ /** Infers the output type of a Standard Typed. */
27
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
28
+ }
29
+ /** The Standard Schema interface. */
30
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
31
+ /** The Standard Schema properties. */
32
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
33
+ }
34
+ declare namespace StandardSchemaV1 {
35
+ /** The Standard Schema properties interface. */
36
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
37
+ /** Validates unknown input values. */
38
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
39
+ }
40
+ /** The result interface of the validate function. */
41
+ type Result<Output> = SuccessResult<Output> | FailureResult;
42
+ /** The result interface if validation succeeds. */
43
+ interface SuccessResult<Output> {
44
+ /** The typed output value. */
45
+ readonly value: Output;
46
+ /** A falsy value for `issues` indicates success. */
47
+ readonly issues?: undefined;
48
+ }
49
+ interface Options {
50
+ /** Explicit support for additional vendor-specific parameters, if needed. */
51
+ readonly libraryOptions?: Record<string, unknown> | undefined;
52
+ }
53
+ /** The result interface if validation fails. */
54
+ interface FailureResult {
55
+ /** The issues of failed validation. */
56
+ readonly issues: ReadonlyArray<Issue>;
57
+ }
58
+ /** The issue interface of the failure output. */
59
+ interface Issue {
60
+ /** The error message of the issue. */
61
+ readonly message: string;
62
+ /** The path of the issue, if any. */
63
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
64
+ }
65
+ /** The path segment interface of the issue. */
66
+ interface PathSegment {
67
+ /** The key representing a path segment. */
68
+ readonly key: PropertyKey;
69
+ }
70
+ /** The Standard types interface. */
71
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
72
+ /** Infers the input type of a Standard. */
73
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
74
+ /** Infers the output type of a Standard. */
75
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
76
+ }
77
+ //#endregion
78
+ //#region ../internal/src/operations.d.ts
79
+ /** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
80
+ type OperationKind = "read" | "write" | "destructive";
81
+ /** The signed-in user of a call. */
82
+ interface OperationUser {
83
+ id: string;
84
+ name?: string;
85
+ email?: string;
86
+ image?: string;
87
+ [key: string]: unknown;
88
+ }
89
+ /** The Agent Actor when an agent calls through a capability or MCP on behalf of a user. */
90
+ interface OperationActor {
91
+ id: string;
92
+ kind?: string;
93
+ label?: string;
94
+ meta?: object;
95
+ }
96
+ /** The checked Console access of a call. `vite-hub` issues it. `ConsoleAccess` has this shape. */
97
+ interface OperationAccess {
98
+ readonly mode: string;
99
+ /**
100
+ * The sections that the call may use. `"all"` when no section filter applies. An entry is a section id (`"kv"`, every
101
+ * operation of the section) or `"<section>:read"` (only the operations that read).
102
+ */
103
+ readonly sections: "all" | readonly string[];
104
+ readonly user?: OperationUser;
105
+ }
106
+ interface OperationContext {
107
+ /** The checked Console access of the call. */
108
+ access: OperationAccess;
109
+ /** The signed-in user, or null. */
110
+ user: OperationUser | null;
111
+ /** The Agent Actor when an agent calls on behalf of `user`. */
112
+ actor?: OperationActor;
113
+ surface: "console" | "cli" | "mcp" | "agent";
114
+ /** Set by the host from generated build identity, never from request input or runtime NODE_ENV. */
115
+ development?: boolean;
116
+ env?: Record<string, unknown>;
117
+ waitUntil?: (task: Promise<unknown>) => void;
118
+ request?: Request;
119
+ /** Operations set a success status here, such as 202 for an accepted call. */
120
+ response?: {
121
+ status?: number;
122
+ };
123
+ /**
124
+ * An agent or an MCP client may pass `lease: "override"` to `content.save`, `content.remove`, and `content.restore`
125
+ * only when the developer allowed it. Defaults to false, so a model cannot take over a document that a person is editing.
126
+ */
127
+ overrideLeases?: boolean;
128
+ /**
129
+ * What an Agent may read of the Channel conversations, set by `operations({ conversations })`. `participant`: only the
130
+ * threads that the Actor takes part in. `all`: every thread. Unset: none.
131
+ */
132
+ conversations?: "all" | "participant";
133
+ }
134
+ interface OperationDefinition<Input, Output> {
135
+ /** `<section>.<verb>`, such as `content.publish`. Unique per app. */
136
+ name: string;
137
+ /** One sentence. Becomes the CLI help line and the MCP tool description. */
138
+ description: string;
139
+ /**
140
+ * Console section that grants access, such as `content`. `false`: any Console user. A function reads the section
141
+ * from the input, for operations that serve several sections.
142
+ */
143
+ section: string | false | ((input: Input) => string | undefined);
144
+ /** `read` never changes state. `write` changes state. `destructive` deletes or publishes; the CLI asks for `--yes`, MCP marks `destructiveHint`, agents require approval by default. */
145
+ kind: OperationKind;
146
+ /** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
147
+ input: StandardSchemaV1<unknown, Input>;
148
+ output?: StandardSchemaV1<unknown, Output>;
149
+ cli?: {
150
+ /** Defaults: namespace = section, command = verb. */
151
+ namespace?: string;
152
+ command?: string;
153
+ /** Input keys read from positional arguments, in order. */
154
+ positional?: string[];
155
+ /** Human output, written verbatim. Without it the CLI prints JSON. `--json` always prints JSON. */
156
+ format?: (output: Output) => string;
157
+ /** `vitehub <namespace>` runs this command when no command is named, such as `vitehub usage`. */
158
+ default?: boolean;
159
+ /**
160
+ * Route of the app that takes a signed dispatch of this operation, such as `/_vitehub/schedules/run`. With `--url`
161
+ * and a dispatch key in the environment (`VITEHUB_DISPATCH_KEY`), the command signs the input and posts it there, so
162
+ * a CI job needs no Console credentials. Without a key it calls the RPC.
163
+ */
164
+ dispatch?: string;
165
+ };
166
+ /** Largest request body in bytes. It can raise the 64 KiB default but not lower it. */
167
+ maxRequestBytes?: number;
168
+ /**
169
+ * Returns true when this call only reads, such as a dry run of a `destructive` operation. The CLI then skips the
170
+ * confirmation, and agents run it without approval. Without it, every call of a `destructive` operation asks.
171
+ */
172
+ readOnlyWhen?: (input: Input) => boolean;
173
+ /** `false`: MCP does not offer the operation as a tool, such as an editor transport that only the Console uses. */
174
+ mcp?: false;
175
+ /** `false`: the operation never reads `context.user`, so the Console skips the session lookup for it. */
176
+ user?: false;
177
+ /**
178
+ * The operation runs code of the app, such as a workflow, a job, a task, or a schedule. The Console registers it only
179
+ * when `console.invoke` is on, which is the default in development and off in a production build.
180
+ */
181
+ invoke?: true;
182
+ run: (input: Input, context: OperationContext) => Output | Promise<Output>;
183
+ }
184
+ /** An operation of any input and output, as a registry holds it. */
185
+ interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "output" | "readOnlyWhen" | "run" | "section"> {
186
+ readOnlyWhen?: (input: never) => boolean;
187
+ cli?: {
188
+ namespace?: string;
189
+ command?: string;
190
+ default?: boolean;
191
+ dispatch?: string;
192
+ positional?: string[];
193
+ format?: (output: never) => string;
194
+ };
195
+ input: StandardSchemaV1;
196
+ output?: StandardSchemaV1;
197
+ run: (input: never, context: OperationContext) => unknown;
198
+ section: string | false | ((input: never) => string | undefined);
199
+ }
200
+ /** The contribution of one plugin: operations, or a module that exports them. */
201
+ interface OperationContributionEntry {
202
+ /** Module the app imports, such as `@vite-hub/content/operations`. */
203
+ module: string;
204
+ /** Named export that holds an operation or an array of operations. Defaults to `default`. */
205
+ export?: string;
206
+ /** Loads the export in the tool process, for a module that the tool cannot resolve by name. */
207
+ load?: () => Promise<unknown>;
208
+ /** `false`: the app already has these operations at runtime. Only tools such as the CLI and `vitehub inspect` read the entry. */
209
+ runtime?: false;
210
+ }
211
+ //#endregion
212
+ export { OperationContributionEntry as n, AnyOperation as t };
@@ -0,0 +1,37 @@
1
+ import { E as WorkflowRunStatus, x as WorkflowProvider } from "./types-D82WmfZa.js";
2
+ import { t as AnyOperation } from "./operations-tNUdj3G4.js";
3
+ //#region src/results.d.ts
4
+ /** One Workflow run as the operations return it. The start payload is not included. */
5
+ interface WorkflowRunView {
6
+ completedAt?: string;
7
+ createdAt?: string;
8
+ error?: {
9
+ code?: string;
10
+ message: string;
11
+ name?: string;
12
+ };
13
+ id: string;
14
+ metadata?: unknown;
15
+ provider: WorkflowProvider;
16
+ result?: unknown;
17
+ startedAt?: string;
18
+ status: WorkflowRunStatus;
19
+ workflow: string;
20
+ }
21
+ /** The signal that `workflow.resume` delivered. */
22
+ interface WorkflowSignalView {
23
+ id: string;
24
+ provider: WorkflowProvider;
25
+ }
26
+ interface WorkflowRunResult {
27
+ run: WorkflowRunView;
28
+ }
29
+ interface WorkflowSignalResult {
30
+ signal: WorkflowSignalView;
31
+ }
32
+ //#endregion
33
+ //#region src/operations.d.ts
34
+ /** The `workflow.*` operations: start, get, cancel, and resume. The Console, `vitehub workflow`, and agents run them. */
35
+ export declare const workflowOperations: readonly AnyOperation[];
36
+ //#endregion
37
+ export type { WorkflowRunResult, WorkflowRunView, WorkflowSignalResult, WorkflowSignalView };