@vite-hub/workflow 0.0.4 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -47
- package/dist/{_app-DgwN4ulW.d.ts → app-BojnC_yf.d.ts} +1 -4
- package/dist/{app-BZpq2cwC.js → app-CmMq8l4t.js} +2 -1
- package/dist/client-CU5rELC0.js +658 -0
- package/dist/{cloudflare-D0Di-QYL.js → cloudflare-BfFnNWB0.js} +20 -4
- package/dist/cloudflare-env-CGLx7lUd.js +115 -0
- package/dist/cloudflare-env-lookup-CfX6wZKb.d.ts +4 -0
- package/dist/{cloudflare-env-CIjdFTv6.d.ts → cloudflare-shared-CTqh_a2s.d.ts} +2 -2
- package/dist/config-DCvRDlxA.js +145 -0
- package/dist/definition.d.ts +19 -0
- package/dist/definition.js +31 -0
- package/dist/delay--ESDybVT.js +81 -0
- package/dist/dev-recorder-CTN5Fkao.js +10 -0
- package/dist/durability.d.ts +23 -0
- package/dist/durability.js +62 -0
- package/dist/error-diagnostics-8YNJ37rP.js +286 -0
- package/dist/error-diagnostics-DSkCJC_L.js +266 -0
- package/dist/errors-DCqRnZpN.js +35 -0
- package/dist/errors-DVwFb6Fd.d.ts +56 -0
- package/dist/index.d.ts +23 -71
- package/dist/index.js +23 -378
- package/dist/inspect-B72iFyj-.js +70 -0
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/openworkflow-TEaNk0LV.d.ts +50 -0
- package/dist/openworkflow-defaults-DDig2M4s.js +26 -0
- package/dist/openworkflow-storage-Dj9zUAsk.js +28 -0
- package/dist/openworkflow.d.ts +2 -0
- package/dist/openworkflow.js +2 -0
- package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
- package/dist/operations-B0L8kV5s.js +329 -0
- package/dist/operations.d.ts +71 -0
- package/dist/operations.js +314 -0
- package/dist/out-fRNaVslw.js +20357 -0
- package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
- package/dist/run-error-DBWqiJHH.js +110 -0
- package/dist/runtime/cloudflare-runner.d.ts +7 -19
- package/dist/runtime/cloudflare-runner.js +27 -10
- package/dist/runtime/cloudflare-shared.d.ts +2 -1
- package/dist/runtime/cloudflare-shared.js +1 -1
- package/dist/runtime/cloudflare-vite.d.ts +10 -11
- package/dist/runtime/cloudflare-vite.js +47 -1
- package/dist/runtime/dev-runs.d.ts +4 -0
- package/dist/runtime/dev-runs.js +73 -0
- package/dist/runtime/execute.d.ts +24 -7
- package/dist/runtime/execute.js +135 -6
- package/dist/runtime/openworkflow-worker.d.ts +34 -9
- package/dist/runtime/openworkflow-worker.js +156 -37
- package/dist/runtime/openworkflow.d.ts +2 -23
- package/dist/runtime/openworkflow.js +289 -46
- package/dist/runtime/state.d.ts +22 -21
- package/dist/runtime/state.js +99 -25
- package/dist/runtime/vercel-vite.d.ts +10 -12
- package/dist/runtime/vercel-vite.js +7 -4
- package/dist/types-CnKVDnEp.d.ts +241 -0
- package/dist/{vercel-B0MuIVgJ.js → vercel-BZU_O6ay.js} +78 -24
- package/dist/vite.d.ts +529 -23
- package/dist/vite.js +2789 -1609
- package/package.json +62 -34
- package/dist/cloudflare-env-DjxQNbrx.js +0 -58
- package/dist/cloudflare-shared-BVVgDSdq.d.ts +0 -1
- package/dist/cloudflare-vite-BkDgB6Sr.js +0 -46
- package/dist/config-BHknO_rT.js +0 -136
- package/dist/provider-operation-CW2cYfVy.js +0 -65
- package/dist/runtime-type-DGUn8Ple.js +0 -37
- package/dist/types-B9RdRkKh.d.ts +0 -169
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { O as WorkflowRunStatus, h as WorkflowDriver } from "./types-CnKVDnEp.js";
|
|
2
|
+
import { t as AnyOperation } from "./operation-definition-8gOe-ubD.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: WorkflowDriver;
|
|
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: WorkflowDriver;
|
|
25
|
+
}
|
|
26
|
+
interface WorkflowRunResult {
|
|
27
|
+
run: WorkflowRunView;
|
|
28
|
+
}
|
|
29
|
+
/** One step of a run that `vite dev` recorded. */
|
|
30
|
+
interface WorkflowRunStepView {
|
|
31
|
+
completedAt?: string;
|
|
32
|
+
error?: {
|
|
33
|
+
code?: string;
|
|
34
|
+
message: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
};
|
|
37
|
+
name: string;
|
|
38
|
+
output?: unknown;
|
|
39
|
+
startedAt: string;
|
|
40
|
+
status: "completed" | "failed" | "running";
|
|
41
|
+
}
|
|
42
|
+
/** A run that `vite dev` recorded, with its steps. */
|
|
43
|
+
interface WorkflowRunDetailView extends WorkflowRunView {
|
|
44
|
+
steps: WorkflowRunStepView[];
|
|
45
|
+
}
|
|
46
|
+
/** Result of `workflow.runs-list`. The runs are newest first and have no steps. */
|
|
47
|
+
interface WorkflowRunsListResult {
|
|
48
|
+
runs: Array<WorkflowRunView & {
|
|
49
|
+
stepCount: number;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
/** Result of `workflow.runs-clear`: the number of recorded runs that it removed. */
|
|
53
|
+
interface WorkflowRunsClearResult {
|
|
54
|
+
cleared: number;
|
|
55
|
+
}
|
|
56
|
+
/** Result of `workflow.runs-show`. */
|
|
57
|
+
interface WorkflowRunsShowResult {
|
|
58
|
+
run: WorkflowRunDetailView;
|
|
59
|
+
}
|
|
60
|
+
interface WorkflowSignalResult {
|
|
61
|
+
signal: WorkflowSignalView;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/operations.d.ts
|
|
65
|
+
/**
|
|
66
|
+
* The `workflow.*` operations: start, get, cancel, resume, and the run history of `vite dev`. The Console,
|
|
67
|
+
* `vitehub workflow`, and agents run them.
|
|
68
|
+
*/
|
|
69
|
+
export declare const workflowOperations: readonly AnyOperation[];
|
|
70
|
+
//#endregion
|
|
71
|
+
export type { WorkflowRunDetailView, WorkflowRunResult, WorkflowRunStepView, WorkflowRunView, WorkflowRunsClearResult, WorkflowRunsListResult, WorkflowRunsShowResult, WorkflowSignalResult, WorkflowSignalView };
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { t as internalErrorDiagnostics } from "./error-diagnostics-DSkCJC_L.js";
|
|
2
|
+
import { n as isRecordOrFunction } from "./object-Da1zyPCR.js";
|
|
3
|
+
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
//#region ../internal/src/standard-schema.ts
|
|
6
|
+
function readOwn(value, key) {
|
|
7
|
+
if (value === null || Object(value) !== value) return;
|
|
8
|
+
try {
|
|
9
|
+
return Reflect.get(Object(value), key);
|
|
10
|
+
} catch {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Read a Standard JSON Schema projection without throwing.
|
|
16
|
+
*
|
|
17
|
+
* Returns `undefined` when the schema has no `~standard.jsonSchema`, when the library cannot represent the type
|
|
18
|
+
* (Zod throws for `Date`), or when the projection is not an object. Callers decide how to fall back.
|
|
19
|
+
*/
|
|
20
|
+
function standardJsonSchema(schema, direction, target = "draft-2020-12", libraryOptions) {
|
|
21
|
+
const jsonSchema = readOwn(readOwn(schema, "~standard"), "jsonSchema");
|
|
22
|
+
const project = readOwn(jsonSchema, direction);
|
|
23
|
+
if (typeof project !== "function") return;
|
|
24
|
+
try {
|
|
25
|
+
const result = project.call(jsonSchema, libraryOptions ? {
|
|
26
|
+
target,
|
|
27
|
+
libraryOptions
|
|
28
|
+
} : { target });
|
|
29
|
+
return isRecordOrFunction(result) ? result : void 0;
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region ../internal/src/valibot.ts
|
|
36
|
+
const valibotTargets = /* @__PURE__ */ new Set([
|
|
37
|
+
"draft-07",
|
|
38
|
+
"draft-2020-12",
|
|
39
|
+
"openapi-3.0"
|
|
40
|
+
]);
|
|
41
|
+
function isValibotTarget(value) {
|
|
42
|
+
return valibotTargets.has(String(value));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Add Standard JSON Schema conversion to a plain Valibot schema. Valibot schemas validate as Standard Schema but carry
|
|
46
|
+
* no JSON Schema, so forms, tools, and model providers would get no shape for them. Other schemas, Valibot schemas that
|
|
47
|
+
* already convert, and async Valibot schemas return unchanged. The copy keeps every Valibot property, so validation
|
|
48
|
+
* does not change.
|
|
49
|
+
*
|
|
50
|
+
* `target` fixes the JSON Schema dialect. Without it, each conversion uses the dialect that the caller asks for.
|
|
51
|
+
*/
|
|
52
|
+
function withValibotJsonSchema(schema, options = {}) {
|
|
53
|
+
const standard = schema["~standard"];
|
|
54
|
+
if (standard.vendor !== "valibot" || Reflect.get(schema, "async") === true) return schema;
|
|
55
|
+
if (Object.hasOwn(standard, "jsonSchema") && standard.jsonSchema) return schema;
|
|
56
|
+
const convert = (typeMode) => (request) => {
|
|
57
|
+
const target = options.target ?? request.target;
|
|
58
|
+
if (!isValibotTarget(target)) throw internalErrorDiagnostics.INTERNAL_VALIBOT_JSON_SCHEMA_TARGET_UNSUPPORTED({ target: String(target) });
|
|
59
|
+
return toJsonSchema(schema, {
|
|
60
|
+
target,
|
|
61
|
+
typeMode,
|
|
62
|
+
errorMode: "ignore"
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
...schema,
|
|
67
|
+
"~standard": {
|
|
68
|
+
...standard,
|
|
69
|
+
jsonSchema: {
|
|
70
|
+
input: convert("input"),
|
|
71
|
+
output: convert("output")
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region ../internal/src/operation-definition.ts
|
|
78
|
+
const nameFormat = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/;
|
|
79
|
+
const kinds = /* @__PURE__ */ new Set([
|
|
80
|
+
"read",
|
|
81
|
+
"write",
|
|
82
|
+
"destructive"
|
|
83
|
+
]);
|
|
84
|
+
function invalidDefinition(name, reason) {
|
|
85
|
+
return internalErrorDiagnostics.INTERNAL_R0020({ message: `[vitehub] Operation ${JSON.stringify(name)} is invalid: ${reason}` });
|
|
86
|
+
}
|
|
87
|
+
function checkDefinition(definition) {
|
|
88
|
+
if (!isRecordOrFunction(definition)) throw invalidDefinition(void 0, "defineOperation() takes an object.");
|
|
89
|
+
const { name } = definition;
|
|
90
|
+
if (String(name) !== name || !nameFormat.test(name)) throw invalidDefinition(name, "the name must look like `section.verb`, in lower case.");
|
|
91
|
+
if (String(definition.description) !== definition.description || !definition.description) throw invalidDefinition(name, "add a one sentence description.");
|
|
92
|
+
const { section } = definition;
|
|
93
|
+
if (section !== false && !(section instanceof Function) && !isSectionId(section)) throw invalidDefinition(name, "section must be a Console section id, a function, or false; section ids cannot contain ':'.");
|
|
94
|
+
if (definition.scope !== void 0 && (!(definition.scope instanceof Function) || String(section) !== section)) throw invalidDefinition(name, "scope must be a function, and it needs a section id.");
|
|
95
|
+
if (!kinds.has(String(definition.kind))) throw invalidDefinition(name, "kind must be \"read\", \"write\", or \"destructive\".");
|
|
96
|
+
const input = definition.input;
|
|
97
|
+
if (!isRecordOrFunction(input) || !isRecordOrFunction(input["~standard"]) || !(input["~standard"].validate instanceof Function)) throw invalidDefinition(name, "input must be a Standard Schema, such as a valibot object.");
|
|
98
|
+
if (!(definition.run instanceof Function)) throw invalidDefinition(name, "run must be a function.");
|
|
99
|
+
const { maxRequestBytes } = definition;
|
|
100
|
+
if (maxRequestBytes !== void 0 && (!Number.isInteger(maxRequestBytes) || Number(maxRequestBytes) < 65536)) throw invalidDefinition(name, `maxRequestBytes can only raise the limit above ${defaultRequestBytes} bytes (64 KiB).`);
|
|
101
|
+
if (definition.readOnlyWhen !== void 0 && !(definition.readOnlyWhen instanceof Function)) throw invalidDefinition(name, "readOnlyWhen must be a function.");
|
|
102
|
+
const { mcp } = definition;
|
|
103
|
+
if (mcp !== void 0 && mcp !== false && (!isRecordOrFunction(mcp) || mcp.title !== void 0 && (String(mcp.title) !== mcp.title || !mcp.title) || mcp.format !== void 0 && !(mcp.format instanceof Function))) throw invalidDefinition(name, "mcp must be false, or an object with a title string and a format function.");
|
|
104
|
+
}
|
|
105
|
+
/** The default limit of a call, in bytes. */
|
|
106
|
+
const defaultRequestBytes = 65536;
|
|
107
|
+
/** Input keys that the generated CLI commands read themselves. */
|
|
108
|
+
const reservedOperationFlags = [
|
|
109
|
+
"input",
|
|
110
|
+
"json",
|
|
111
|
+
"timeout",
|
|
112
|
+
"url",
|
|
113
|
+
"yes"
|
|
114
|
+
];
|
|
115
|
+
/**
|
|
116
|
+
* Define one operation. The Console, the CLI, MCP, and agent tools call the same definition. Contribute it with
|
|
117
|
+
* `vitehub: { operations: [{ module, export }] }` on a Vite plugin.
|
|
118
|
+
*/
|
|
119
|
+
function defineOperation(definition) {
|
|
120
|
+
checkDefinition(definition);
|
|
121
|
+
const defined = {
|
|
122
|
+
...definition,
|
|
123
|
+
input: withValibotJsonSchema(definition.input)
|
|
124
|
+
};
|
|
125
|
+
const properties = operationInputJsonSchema(defined).properties;
|
|
126
|
+
const clashes = isRecordOrFunction(properties) ? Object.keys(properties).filter((key) => reservedOperationFlags.includes(key)) : [];
|
|
127
|
+
if (clashes.length) throw invalidDefinition(definition.name, `the input key ${clashes.map((key) => JSON.stringify(key)).join(", ")} is a CLI flag of every command (${reservedOperationFlags.join(", ")}). Rename it.`);
|
|
128
|
+
return defined;
|
|
129
|
+
}
|
|
130
|
+
function isSectionId(section) {
|
|
131
|
+
return typeof section === "string" && section !== "" && !section.includes(":");
|
|
132
|
+
}
|
|
133
|
+
/** JSON Schema of the input, for CLI flags and MCP tool schemas. Falls back to an open object. */
|
|
134
|
+
function operationInputJsonSchema(operation) {
|
|
135
|
+
return standardJsonSchema(operation.input, "input") ?? { type: "object" };
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region ../internal/src/operations.ts
|
|
139
|
+
/** Align rows of text cells in columns for CLI output. The last column is not padded. */
|
|
140
|
+
function table(rows) {
|
|
141
|
+
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
142
|
+
return rows.map((row) => row.map((cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths[column])).join(" ")).join("\n");
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/operations.ts
|
|
146
|
+
const runtime = () => import("./operations-B0L8kV5s.js");
|
|
147
|
+
const name = v.pipe(v.string(), v.check((value) => value.trim() !== "", "Name a Workflow."));
|
|
148
|
+
const runId = v.pipe(v.string(), v.check((value) => value.trim() !== "", "Pass the id of a run."));
|
|
149
|
+
const maxRequestBytes = 1048576;
|
|
150
|
+
function defineWorkflowOperation(definition) {
|
|
151
|
+
return defineOperation({
|
|
152
|
+
...definition,
|
|
153
|
+
cli: {
|
|
154
|
+
namespace: "workflow",
|
|
155
|
+
...definition.cli
|
|
156
|
+
},
|
|
157
|
+
section: "workflows",
|
|
158
|
+
user: false
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const start = defineWorkflowOperation({
|
|
162
|
+
cli: { positional: ["workflow", "payload"] },
|
|
163
|
+
description: "Start a Workflow run by name. The payload is any JSON value.",
|
|
164
|
+
input: v.object({
|
|
165
|
+
payload: v.optional(v.unknown()),
|
|
166
|
+
workflow: name
|
|
167
|
+
}),
|
|
168
|
+
invoke: true,
|
|
169
|
+
kind: "write",
|
|
170
|
+
maxRequestBytes,
|
|
171
|
+
name: "workflow.start",
|
|
172
|
+
run: async (input) => (await runtime()).runWorkflowOperation("start", input)
|
|
173
|
+
});
|
|
174
|
+
const get = defineWorkflowOperation({
|
|
175
|
+
cli: { positional: ["runId"] },
|
|
176
|
+
description: "Show the status and result of a Workflow run. Pass `workflow` for a run that this runtime did not start.",
|
|
177
|
+
input: v.object({
|
|
178
|
+
runId,
|
|
179
|
+
workflow: v.optional(name)
|
|
180
|
+
}),
|
|
181
|
+
kind: "read",
|
|
182
|
+
name: "workflow.get",
|
|
183
|
+
run: async (input) => (await runtime()).runWorkflowOperation("get", input)
|
|
184
|
+
});
|
|
185
|
+
const cancel = defineWorkflowOperation({
|
|
186
|
+
cli: { positional: ["runId"] },
|
|
187
|
+
description: "Cancel a Workflow run. Only providers that support cancellation accept it.",
|
|
188
|
+
input: v.object({
|
|
189
|
+
runId,
|
|
190
|
+
workflow: v.optional(name)
|
|
191
|
+
}),
|
|
192
|
+
kind: "destructive",
|
|
193
|
+
name: "workflow.cancel",
|
|
194
|
+
run: async (input) => (await runtime()).runWorkflowOperation("cancel", input)
|
|
195
|
+
});
|
|
196
|
+
const resume = defineWorkflowOperation({
|
|
197
|
+
cli: { positional: ["token", "payload"] },
|
|
198
|
+
description: "Resume a Workflow signal with its opaque token. The payload is any JSON value.",
|
|
199
|
+
input: v.object({
|
|
200
|
+
payload: v.optional(v.unknown()),
|
|
201
|
+
token: v.pipe(v.string(), v.check((value) => value.trim() !== "", "Pass the signal token."))
|
|
202
|
+
}),
|
|
203
|
+
invoke: true,
|
|
204
|
+
kind: "write",
|
|
205
|
+
maxRequestBytes,
|
|
206
|
+
name: "workflow.resume",
|
|
207
|
+
run: async (input) => (await runtime()).runWorkflowOperation("resume", input)
|
|
208
|
+
});
|
|
209
|
+
function formatRuns({ runs }) {
|
|
210
|
+
if (runs.length === 0) return "No runs.\n";
|
|
211
|
+
return `${table([[
|
|
212
|
+
"RUN",
|
|
213
|
+
"WORKFLOW",
|
|
214
|
+
"STATUS",
|
|
215
|
+
"CREATED AT",
|
|
216
|
+
"STEPS",
|
|
217
|
+
"ERROR"
|
|
218
|
+
], ...runs.map((run) => [
|
|
219
|
+
run.id,
|
|
220
|
+
run.workflow,
|
|
221
|
+
run.status,
|
|
222
|
+
run.createdAt ?? "-",
|
|
223
|
+
String(run.stepCount),
|
|
224
|
+
run.error?.message ?? "-"
|
|
225
|
+
])])}\n`;
|
|
226
|
+
}
|
|
227
|
+
function json(value) {
|
|
228
|
+
return JSON.stringify(value ?? null, null, 2);
|
|
229
|
+
}
|
|
230
|
+
function formatRun({ run }) {
|
|
231
|
+
return [
|
|
232
|
+
`Run: ${run.id}`,
|
|
233
|
+
`Workflow: ${run.workflow}`,
|
|
234
|
+
`Status: ${run.status}`,
|
|
235
|
+
`Provider: ${run.provider}`,
|
|
236
|
+
...run.createdAt ? [`Created at: ${run.createdAt}`] : [],
|
|
237
|
+
...run.startedAt ? [`Started at: ${run.startedAt}`] : [],
|
|
238
|
+
...run.completedAt ? [`Completed at: ${run.completedAt}`] : [],
|
|
239
|
+
...run.error ? [`Error: ${run.error.code ? `${run.error.code} ` : ""}${run.error.message}`] : [],
|
|
240
|
+
...run.steps.length ? ["Steps:", table([[
|
|
241
|
+
"STEP",
|
|
242
|
+
"STATUS",
|
|
243
|
+
"STARTED AT",
|
|
244
|
+
"COMPLETED AT",
|
|
245
|
+
"ERROR"
|
|
246
|
+
], ...run.steps.map((step) => [
|
|
247
|
+
step.name,
|
|
248
|
+
step.status,
|
|
249
|
+
step.startedAt,
|
|
250
|
+
step.completedAt ?? "-",
|
|
251
|
+
step.error?.message ?? "-"
|
|
252
|
+
])])] : ["Steps: none"],
|
|
253
|
+
...run.status === "completed" ? ["Result:", json(run.result)] : [],
|
|
254
|
+
""
|
|
255
|
+
].join("\n");
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The `workflow.*` operations: start, get, cancel, resume, and the run history of `vite dev`. The Console,
|
|
259
|
+
* `vitehub workflow`, and agents run them.
|
|
260
|
+
*/
|
|
261
|
+
const workflowOperations = [
|
|
262
|
+
start,
|
|
263
|
+
get,
|
|
264
|
+
cancel,
|
|
265
|
+
resume,
|
|
266
|
+
defineWorkflowOperation({
|
|
267
|
+
cli: {
|
|
268
|
+
command: "runs list",
|
|
269
|
+
format: formatRuns
|
|
270
|
+
},
|
|
271
|
+
description: "List the Workflow runs that `vite dev` recorded, newest first. Other runtimes keep no history and fail with WORKFLOW_RUNS_UNAVAILABLE.",
|
|
272
|
+
input: v.strictObject({
|
|
273
|
+
limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(200))),
|
|
274
|
+
status: v.optional(v.picklist([
|
|
275
|
+
"queued",
|
|
276
|
+
"running",
|
|
277
|
+
"completed",
|
|
278
|
+
"failed"
|
|
279
|
+
])),
|
|
280
|
+
workflow: v.optional(name)
|
|
281
|
+
}),
|
|
282
|
+
kind: "read",
|
|
283
|
+
name: "workflow.runs-list",
|
|
284
|
+
run: async (input) => (await runtime()).listWorkflowRuns(input)
|
|
285
|
+
}),
|
|
286
|
+
defineWorkflowOperation({
|
|
287
|
+
cli: {
|
|
288
|
+
command: "runs show",
|
|
289
|
+
format: formatRun,
|
|
290
|
+
positional: ["id"]
|
|
291
|
+
},
|
|
292
|
+
description: "Show one Workflow run that `vite dev` recorded, with its steps, status, result, and error.",
|
|
293
|
+
input: v.strictObject({
|
|
294
|
+
id: runId,
|
|
295
|
+
workflow: v.optional(name)
|
|
296
|
+
}),
|
|
297
|
+
kind: "read",
|
|
298
|
+
name: "workflow.runs-show",
|
|
299
|
+
run: async (input) => (await runtime()).showWorkflowRun(input)
|
|
300
|
+
}),
|
|
301
|
+
defineWorkflowOperation({
|
|
302
|
+
cli: {
|
|
303
|
+
command: "runs clear",
|
|
304
|
+
format: ({ cleared }) => `Cleared ${cleared} ${cleared === 1 ? "run" : "runs"}.\n`
|
|
305
|
+
},
|
|
306
|
+
description: "Remove the Workflow runs that `vite dev` recorded. Other runtimes keep no history and fail with WORKFLOW_RUNS_UNAVAILABLE.",
|
|
307
|
+
input: v.strictObject({}),
|
|
308
|
+
kind: "destructive",
|
|
309
|
+
name: "workflow.runs-clear",
|
|
310
|
+
run: async () => (await runtime()).clearWorkflowRuns()
|
|
311
|
+
})
|
|
312
|
+
];
|
|
313
|
+
//#endregion
|
|
314
|
+
export { workflowOperations };
|