effect-ci 0.0.0-stage → 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.
@@ -0,0 +1,787 @@
1
+ import * as Cache from "effect/Cache";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Redacted from "effect/Redacted";
4
+ import * as Context from "effect/Context";
5
+ import type { RuntimeObservers } from "./observers.js";
6
+ import { type CommandDiagnostics } from "./command-diagnostics.js";
7
+ import { type SourceComparison, type SourceChanges, type SourceQueries } from "./source-changes.js";
8
+ export type { SourceComparison, SourceChanges, SourceQueries } from "./source-changes.js";
9
+ export { makeRuntimeObservers, type RuntimeObservation, type RuntimeObserver, type RuntimeObservers, type ObservationReceipt } from "./observers.js";
10
+ export { boundedCommandOutput, commandDiagnosticLimit, encodeCommandDiagnostics, decodeCommandDiagnostics, type CommandDiagnostics } from "./command-diagnostics.js";
11
+ export type WorkflowDuration = number | `${number} ${"second" | "minute" | "hour" | "day" | "week"}${"s" | ""}`;
12
+ export interface WorkflowStepConfig {
13
+ readonly retries?: {
14
+ readonly limit: number;
15
+ readonly delay: WorkflowDuration;
16
+ readonly backoff?: "constant" | "linear" | "exponential";
17
+ };
18
+ readonly timeout?: WorkflowDuration;
19
+ /**
20
+ * Put native durability around each command instead of the complete action
21
+ * body. Use this for a command-only action when losing a long-lived outer
22
+ * action acknowledgement would also hide the command's durable result.
23
+ */
24
+ readonly checkpoint?: "action" | "command";
25
+ }
26
+ export type StepOptions = WorkflowStepConfig;
27
+ /**
28
+ * `inputs` (the default): reuse a pass whenever the files and env vars its traced commands
29
+ * read are unchanged, on any commit, so it survives rebases and squashes.
30
+ * `commit`: reuse a pass only for the same commit.
31
+ */
32
+ export type CheckReuseScope = "commit" | "inputs";
33
+ export interface CheckOptions extends StepOptions {
34
+ /** Allow a trusted runner to reuse this side-effect-free check. `true` reuses by inputs. */
35
+ readonly reuse?: true | {
36
+ readonly scope?: CheckReuseScope;
37
+ };
38
+ }
39
+ /** How a tool can report what a command read. Vite+ traces the files a task reads with fspy. */
40
+ export interface CommandTrace {
41
+ readonly tool: "vite-plus";
42
+ /** The task or package.json script `vp run --cache` ran. */
43
+ readonly task: string;
44
+ }
45
+ export interface ExecOptions {
46
+ readonly trace?: CommandTrace;
47
+ /** A read-only command that only describes the step, such as a cache dry run.
48
+ * It runs every time and never makes a reused check count as executed. */
49
+ readonly diagnostic?: boolean;
50
+ }
51
+ type InternalStepOptions = StepOptions & Pick<CheckOptions, "reuse">;
52
+ export interface ActionOptions extends StepOptions {
53
+ /**
54
+ * Reverses external state introduced by this action. Rollbacks run after the
55
+ * action exhausts its retries, then unwind in reverse completion order.
56
+ */
57
+ readonly rollback?: ActionTarget;
58
+ }
59
+ export type WorkflowBody<A> = Effect.Effect<A, any, any> | (() => A | Generator<any, A, any> | Effect.Effect<A, any, any> | Promise<A>);
60
+ type StepBody<A> = WorkflowBody<A>;
61
+ export type ActionHandler<Args extends ReadonlyArray<unknown>, A> = (...args: Args) => Generator<any, A, any> | Effect.Effect<A, any, any> | Promise<A>;
62
+ export type ActionConstruction<Args extends ReadonlyArray<unknown>, A> = WorkflowBody<ActionHandler<Args, A>>;
63
+ /** An action factory that can be exposed as a zero-argument CLI target. */
64
+ export type ActionTarget = () => Effect.Effect<unknown, unknown, any>;
65
+ interface StepDefinition<A = unknown> {
66
+ readonly identity?: object;
67
+ readonly id: string;
68
+ readonly body: Effect.Effect<A, unknown, Runtime | CurrentStep>;
69
+ readonly prepare?: Effect.Effect<Effect.Effect<A, unknown, any>, unknown, any>;
70
+ readonly options: InternalStepOptions;
71
+ readonly rollback?: {
72
+ readonly id: string;
73
+ readonly effect: Effect.Effect<unknown, unknown, any>;
74
+ };
75
+ }
76
+ export interface PlannedCommand {
77
+ readonly command: string;
78
+ readonly cwd: string;
79
+ }
80
+ export interface PlanNode {
81
+ readonly id: string;
82
+ readonly after: ReadonlyArray<string>;
83
+ readonly dependencies: ReadonlyArray<string>;
84
+ readonly commands: ReadonlyArray<PlannedCommand>;
85
+ readonly condition?: Condition;
86
+ /** This node runs only after the referenced node exhausts its retry policy. */
87
+ readonly rollbackFor?: string;
88
+ readonly approval?: ApprovalRequest;
89
+ readonly artifacts: ReadonlyArray<{
90
+ readonly direction: "publish" | "restore";
91
+ readonly name: string;
92
+ readonly paths: ReadonlyArray<string>;
93
+ }>;
94
+ readonly optional: boolean;
95
+ readonly options: InternalStepOptions;
96
+ /** Secret names required by the step. Values are never part of the plan. */
97
+ readonly secrets: ReadonlyArray<string>;
98
+ readonly status: "planned" | "queued" | "running" | "complete" | "reused" | "verified" | "warning" | "failed" | "skipped";
99
+ }
100
+ export interface WorkflowPlan {
101
+ readonly workflowId: string;
102
+ readonly environment: string;
103
+ readonly mode: "plan" | "execute";
104
+ readonly nodes: ReadonlyArray<PlanNode>;
105
+ }
106
+ export interface WorkflowRerunPlan {
107
+ readonly requested: ReadonlyArray<string>;
108
+ readonly rerun: ReadonlyArray<string>;
109
+ readonly reuse: ReadonlyArray<string>;
110
+ }
111
+ export interface WorkflowAttempt {
112
+ readonly id: string;
113
+ readonly number: number;
114
+ readonly workflowId: string;
115
+ readonly previousAttemptId?: string;
116
+ readonly requested: ReadonlyArray<string>;
117
+ readonly plan: WorkflowPlan;
118
+ readonly outputs: Readonly<Record<string, unknown>>;
119
+ readonly conclusion: "success" | "failure";
120
+ readonly startedAt: string;
121
+ readonly completedAt: string;
122
+ }
123
+ export interface WorkflowRerun {
124
+ readonly previous: WorkflowAttempt;
125
+ readonly steps: ReadonlyArray<string>;
126
+ }
127
+ export declare class WorkflowPlanError extends Error {
128
+ readonly _tag = "WorkflowPlanError";
129
+ constructor(message: string);
130
+ }
131
+ /**
132
+ * Selects the requested nodes and everything that transitively consumes them.
133
+ * Ordering-only `after` edges do not carry values and therefore do not
134
+ * invalidate downstream work.
135
+ */
136
+ export declare const planRerun: (plan: WorkflowPlan, requested: ReadonlyArray<string>) => WorkflowRerunPlan;
137
+ export type RuntimeEvent = {
138
+ readonly type: "approval.requested";
139
+ readonly workflowId: string;
140
+ readonly stepId: string;
141
+ readonly requestId: string;
142
+ readonly approval: ApprovalRequest;
143
+ readonly timestamp: string;
144
+ } | {
145
+ readonly type: "approval.resolved";
146
+ readonly workflowId: string;
147
+ readonly stepId: string;
148
+ readonly requestId: string;
149
+ readonly decision: ApprovalDecision;
150
+ readonly actor?: string;
151
+ readonly timestamp: string;
152
+ } | {
153
+ readonly type: "workflow.started";
154
+ readonly workflowId: string;
155
+ readonly environment: string;
156
+ readonly mode: WorkflowPlan["mode"];
157
+ readonly timestamp: string;
158
+ } | {
159
+ readonly type: "dependency.added";
160
+ readonly workflowId: string;
161
+ readonly stepId: string;
162
+ readonly dependency: string;
163
+ readonly timestamp: string;
164
+ } | {
165
+ readonly type: "step.status";
166
+ readonly workflowId: string;
167
+ readonly stepId: string;
168
+ readonly status: PlanNode["status"];
169
+ readonly optional: boolean;
170
+ readonly timestamp: string;
171
+ } | {
172
+ readonly type: "step.command.failed";
173
+ readonly workflowId: string;
174
+ readonly stepId: string;
175
+ readonly diagnostics: CommandDiagnostics;
176
+ readonly timestamp: string;
177
+ } | {
178
+ readonly type: "step.command.unavailable";
179
+ readonly workflowId: string;
180
+ readonly stepId: string;
181
+ readonly stage: "container-execution" | "checkpoint-ack";
182
+ readonly timestamp: string;
183
+ } | {
184
+ readonly type: "step.output";
185
+ readonly workflowId: string;
186
+ readonly stepId: string;
187
+ readonly stream: "stdout" | "stderr";
188
+ readonly text: string;
189
+ readonly timestamp: string;
190
+ } | {
191
+ readonly type: "workflow.plan";
192
+ readonly workflowId: string;
193
+ readonly plan: WorkflowPlan;
194
+ readonly timestamp: string;
195
+ } | {
196
+ readonly type: "workflow.completed";
197
+ readonly workflowId: string;
198
+ readonly conclusion: "success" | "failure";
199
+ readonly timestamp: string;
200
+ };
201
+ interface RuntimeNode {
202
+ readonly id: string;
203
+ readonly artifacts: Array<{
204
+ readonly direction: "publish" | "restore";
205
+ readonly name: string;
206
+ readonly paths: ReadonlyArray<string>;
207
+ }>;
208
+ readonly commands: Array<PlannedCommand>;
209
+ approval?: ApprovalRequest;
210
+ condition?: Condition;
211
+ rollbackFor?: string;
212
+ readonly secrets: Set<string>;
213
+ executedCommands: number;
214
+ verifiedCommands: number;
215
+ status: PlanNode["status"];
216
+ }
217
+ /** @internal Runtime service shape; exported only so declarations can name it. */
218
+ export interface RuntimeShape {
219
+ readonly definitions: Map<string, StepDefinition>;
220
+ readonly ci: boolean;
221
+ readonly workflowId: string;
222
+ readonly mode: WorkflowPlan["mode"];
223
+ readonly force: boolean;
224
+ readonly nodes: Map<string, RuntimeNode>;
225
+ readonly afterEdges: Set<string>;
226
+ readonly edges: Set<string>;
227
+ readonly optionalSteps: Set<string>;
228
+ readonly outputs: Map<string, unknown>;
229
+ readonly cache: Cache.Cache<string, unknown, unknown, Runtime>;
230
+ readonly addDependency: (parent: string, child: string) => Effect.Effect<void>;
231
+ readonly addParallel: (parent: string, steps: ReadonlyArray<{
232
+ readonly id: string;
233
+ readonly optional: boolean;
234
+ }>) => Effect.Effect<void>;
235
+ readonly markOptional: (stepId: string) => Effect.Effect<void>;
236
+ readonly skip: (stepId: string, condition: Condition) => Effect.Effect<void>;
237
+ readonly registerRollback: (primaryId: string, rollbackId: string, rollback: Effect.Effect<unknown, unknown, any>) => Effect.Effect<void, unknown, any>;
238
+ readonly unwind: (original: unknown) => Effect.Effect<undefined, RollbackError>;
239
+ readonly requireSecret: (stepId: string, name: string) => Effect.Effect<void>;
240
+ readonly recordArtifact: (stepId: string, artifact: {
241
+ readonly direction: "publish" | "restore";
242
+ readonly name: string;
243
+ readonly paths: ReadonlyArray<string>;
244
+ }) => Effect.Effect<void>;
245
+ readonly recoverOptional: (stepId: string) => Effect.Effect<boolean>;
246
+ readonly execute: (stepId: string, workspace: Workspace, command: string, options?: ExecOptions) => Effect.Effect<Workspace, CommandFailure>;
247
+ readonly readFile: (stepId: string, workspace: Workspace, path: string) => Effect.Effect<string | undefined, unknown>;
248
+ readonly exists: (stepId: string, workspace: Workspace, path: string) => Effect.Effect<boolean, unknown>;
249
+ readonly changed: (stepId: string, workspace: Workspace, patterns: string | ReadonlyArray<string>) => Effect.Effect<boolean, unknown>;
250
+ readonly checkpoint: (stepId: string, workspace: Workspace, name: string) => Effect.Effect<WorkspaceCheckpoint, unknown>;
251
+ readonly restore: (stepId: string, checkpoint: WorkspaceCheckpoint) => Effect.Effect<Workspace, unknown>;
252
+ readonly requestApproval: (stepId: string, request: ApprovalRequest) => Effect.Effect<ApprovalResult, ApprovalError>;
253
+ }
254
+ export type RuntimeEventHandler = (event: RuntimeEvent) => void | Promise<void>;
255
+ export type WorkflowAttemptHandler = (attempt: WorkflowAttempt) => void | Promise<void>;
256
+ declare const Runtime_base: Context.ServiceClass<Runtime, "@effect-ci-testbed/Runtime", RuntimeShape>;
257
+ declare class Runtime extends Runtime_base {
258
+ }
259
+ declare const CurrentStep_base: Context.ServiceClass<CurrentStep, "@effect-ci-testbed/CurrentStep", string>;
260
+ declare class CurrentStep extends CurrentStep_base {
261
+ }
262
+ declare const Attempt_base: Context.ServiceClass<Attempt, "@effect-ci-testbed/Attempt", number>;
263
+ /** One-based attempt supplied by the local or durable policy interpreter. */
264
+ export declare class Attempt extends Attempt_base {
265
+ }
266
+ /** Capability-backed actions must be able to declare dependencies without executing during planning. */
267
+ export declare const executionMode: Effect.Effect<"execute" | "plan", never, Runtime>;
268
+ /** Whether this run skips cache reuse, so toolchains can bypass their own caches too. */
269
+ export declare const force: Effect.Effect<boolean, never, Runtime>;
270
+ export interface ActionExecutionResult {
271
+ readonly value: unknown;
272
+ readonly commands: ReadonlyArray<PlannedCommand>;
273
+ readonly events?: ReadonlyArray<RuntimeEvent>;
274
+ readonly metadata?: Pick<PlanNode, "artifacts" | "secrets" | "approval">;
275
+ }
276
+ /** Runner boundary for a policy-bearing leaf body, after dependencies resolve. */
277
+ export interface ActionExecutor {
278
+ readonly execute: (request: {
279
+ readonly stepId: string;
280
+ readonly options: WorkflowStepConfig;
281
+ readonly run: (attempt: number) => Effect.Effect<ActionExecutionResult, unknown, any>;
282
+ }) => Effect.Effect<ActionExecutionResult, unknown, any>;
283
+ }
284
+ export declare class CommandError extends Error {
285
+ readonly _tag = "CommandError";
286
+ readonly stepId: string;
287
+ readonly command: string;
288
+ readonly cwd: string;
289
+ readonly exitCode: number;
290
+ readonly details: string | undefined;
291
+ readonly output: {
292
+ readonly stdout: string;
293
+ readonly stderr: string;
294
+ readonly truncated: boolean;
295
+ } | undefined;
296
+ constructor(stepId: string, command: string, cwd: string, exitCode: number, details?: string, output?: {
297
+ readonly stdout: string;
298
+ readonly stderr: string;
299
+ readonly truncated: boolean;
300
+ });
301
+ }
302
+ /** The provider did not acknowledge the checkpoint; no process exit is known. */
303
+ export declare class CommandCheckpointError extends Error {
304
+ readonly _tag = "CommandCheckpointError";
305
+ readonly stage = "checkpoint-ack";
306
+ readonly processExitCode: null;
307
+ readonly effects = "unknown";
308
+ readonly stepId: string;
309
+ readonly command: string;
310
+ readonly cwd: string;
311
+ readonly checkpoint: string | undefined;
312
+ constructor(stepId: string, command: string, cwd: string, checkpoint?: string);
313
+ }
314
+ /** The container executor returned no process result. This is not an exit 1. */
315
+ export declare class CommandExecutionError extends Error {
316
+ readonly _tag = "CommandExecutionError";
317
+ readonly stage = "container-execution";
318
+ readonly processExitCode: null;
319
+ readonly effects = "unknown";
320
+ readonly stepId: string;
321
+ readonly command: string;
322
+ readonly cwd: string;
323
+ constructor(stepId: string, command: string, cwd: string);
324
+ }
325
+ export type CommandFailure = CommandError | CommandCheckpointError | CommandExecutionError;
326
+ export interface ApprovalRequest {
327
+ readonly title: string;
328
+ readonly summary: string;
329
+ readonly approveLabel?: string;
330
+ readonly rejectLabel?: string;
331
+ }
332
+ export type ApprovalDecision = "approved" | "rejected";
333
+ export interface ApprovalResult {
334
+ readonly decision: ApprovalDecision;
335
+ readonly actor?: string;
336
+ }
337
+ export interface ApprovalRuntimeRequest extends ApprovalRequest {
338
+ readonly requestId: string;
339
+ readonly stepId: string;
340
+ readonly workflowId: string;
341
+ }
342
+ export interface ApprovalHandler {
343
+ readonly request: (request: ApprovalRuntimeRequest) => Effect.Effect<ApprovalResult, unknown>;
344
+ }
345
+ export declare class ApprovalError extends Error {
346
+ readonly _tag = "ApprovalError";
347
+ readonly stepId: string;
348
+ readonly decision: "rejected" | "unavailable";
349
+ constructor(stepId: string, decision: "rejected" | "unavailable", message: string);
350
+ }
351
+ export declare class SecretError extends Error {
352
+ readonly _tag = "SecretError";
353
+ readonly secret: string;
354
+ constructor(secret: string, message?: string);
355
+ }
356
+ export interface SecretResolver {
357
+ readonly resolve: (name: string) => Effect.Effect<Redacted.Redacted<string>, SecretError>;
358
+ }
359
+ declare const SecretStore_base: Context.ServiceClass<SecretStore, "@effect-ci-testbed/SecretStore", SecretResolver>;
360
+ declare class SecretStore extends SecretStore_base {
361
+ }
362
+ /**
363
+ * Declares and resolves a secret without making its value plan-serializable.
364
+ * Runners may back this with environment variables, Varlock, Cloudflare's
365
+ * secret store, or an RPC capability that never enters the workload container.
366
+ */
367
+ export declare const Secret: (name: string) => Effect.Effect<Redacted.Redacted<string>, SecretError, Runtime | CurrentStep | SecretStore>;
368
+ export declare class RollbackError extends Error {
369
+ readonly _tag = "RollbackError";
370
+ readonly stepId: string;
371
+ readonly original: unknown;
372
+ readonly rollback: unknown;
373
+ constructor(stepId: string, original: unknown, rollback: unknown);
374
+ }
375
+ export interface ApprovalService {
376
+ readonly request: (request: ApprovalRequest) => Effect.Effect<ApprovalResult, ApprovalError, Runtime | CurrentStep>;
377
+ }
378
+ declare const Approval_base: Context.ServiceClass<Approval, "@effect-ci-testbed/Approval", ApprovalService>;
379
+ export declare class Approval extends Approval_base {
380
+ }
381
+ export type WorkspaceKind = "local" | "remote";
382
+ export declare class Workspace {
383
+ readonly cwd: string;
384
+ readonly kind: WorkspaceKind;
385
+ readonly id: string | undefined;
386
+ readonly revision: WorkspaceCheckpointHandle | undefined;
387
+ private constructor();
388
+ static local(cwd: string): Workspace;
389
+ static remote(id: string, cwd: string, revision?: WorkspaceCheckpointHandle): Workspace;
390
+ withRevision(revision: WorkspaceCheckpointHandle): Workspace;
391
+ directory(path: string): Workspace;
392
+ exec(command: string, options?: ExecOptions): Effect.Effect<Workspace, CommandFailure, Runtime | CurrentStep>;
393
+ readFile(path: string): Effect.Effect<string | undefined, unknown, Runtime | CurrentStep>;
394
+ exists(path: string): Effect.Effect<boolean, unknown, Runtime | CurrentStep>;
395
+ checkpoint(name: string): Effect.Effect<WorkspaceCheckpoint, unknown, Runtime | CurrentStep>;
396
+ /** Compare deployable bytes against the host-selected successful baseline.
397
+ * Without a provider or complete knowledge, run work rather than skip it.
398
+ */
399
+ changed(patterns: string | ReadonlyArray<string>): Effect.Effect<boolean, unknown, Runtime | CurrentStep>;
400
+ }
401
+ export interface WorkspaceCheckpointHandle {
402
+ readonly provider: string;
403
+ readonly value: unknown;
404
+ }
405
+ export declare class WorkspaceCheckpoint {
406
+ readonly name: string;
407
+ readonly workspace: Workspace;
408
+ readonly handle: WorkspaceCheckpointHandle;
409
+ constructor(name: string, workspace: Workspace, handle: WorkspaceCheckpointHandle);
410
+ restore(): Effect.Effect<Workspace, unknown, Runtime | CurrentStep>;
411
+ }
412
+ /** A runner-owned, restorable filesystem result. */
413
+ export declare class WorkspaceArtifact {
414
+ readonly name: string;
415
+ readonly paths: ReadonlyArray<string>;
416
+ readonly checkpoint: WorkspaceCheckpoint;
417
+ constructor(name: string, paths: ReadonlyArray<string>, checkpoint: WorkspaceCheckpoint);
418
+ }
419
+ export declare const Artifact: {
420
+ readonly publish: (workspace: Workspace, options: {
421
+ readonly name: string;
422
+ readonly paths: ReadonlyArray<string>;
423
+ }) => Effect.Effect<WorkspaceArtifact, unknown, Runtime | CurrentStep>;
424
+ readonly restore: (artifact: WorkspaceArtifact) => Effect.Effect<Workspace, unknown, Runtime | CurrentStep>;
425
+ };
426
+ export declare class PackageManagerError extends Error {
427
+ readonly _tag = "PackageManagerError";
428
+ readonly cwd: string;
429
+ constructor(cwd: string, message: string);
430
+ }
431
+ export type JavaScriptPackageManagerName = "npm" | "pnpm" | "yarn" | "bun";
432
+ export interface AptPackageManager {
433
+ readonly workspace: Workspace;
434
+ readonly install: (packages: ReadonlyArray<string>) => Effect.Effect<Workspace, CommandFailure | PackageManagerError, Runtime | CurrentStep>;
435
+ }
436
+ export declare const Apt: (workspace: Workspace) => Effect.Effect<AptPackageManager, PackageManagerError>;
437
+ /**
438
+ * Whether the host can run `vp` in a workspace. When it can, `PackageManager.JavaScript`
439
+ * runs scripts through Vite+. The CLI enables it for local workspaces where `vp` resolves.
440
+ */
441
+ export declare const VitePlusAvailable: Context.Reference<(workspace: Workspace) => boolean>;
442
+ export interface JavaScriptInstallOptions {
443
+ readonly frozenLockfile?: boolean;
444
+ readonly offline?: boolean;
445
+ }
446
+ export interface JavaScriptRunOptions {
447
+ /**
448
+ * With Vite+, `true` (the default) adds `--cache`, so package.json scripts are cached
449
+ * too. Vite+ then infers each script's inputs and outputs from the files it reads and
450
+ * writes, and runs it with a clean environment: only common variables such as `PATH`,
451
+ * `HOME` and `CI` pass through. `false` leaves caching to the Vite+ config. A task with
452
+ * `cache: false` is never cached. Ignored without Vite+.
453
+ */
454
+ readonly cache?: boolean;
455
+ }
456
+ export interface JavaScriptPackageManager {
457
+ /** The manager that owns the lockfile, install, and runner package cache. */
458
+ readonly name: JavaScriptPackageManagerName;
459
+ /** Whether `run` goes through `vp run`, which caches and also runs Vite+ tasks. */
460
+ readonly vitePlus: boolean;
461
+ readonly workspace: Workspace;
462
+ readonly install: (options?: JavaScriptInstallOptions) => Effect.Effect<Workspace, CommandFailure, Runtime | CurrentStep>;
463
+ /** Runs a package.json script, or with Vite+ also a `vite.config.ts` task. */
464
+ readonly run: (name: string, options?: JavaScriptRunOptions) => Effect.Effect<Workspace, unknown, Runtime | CurrentStep>;
465
+ readonly exec: (command: string) => Effect.Effect<Workspace, CommandFailure, Runtime | CurrentStep>;
466
+ }
467
+ /**
468
+ * Detects npm, pnpm, Yarn, or Bun. Where the host provides `vp` (see `VitePlusAvailable`),
469
+ * `run` goes through Vite+; elsewhere it uses the detected manager.
470
+ */
471
+ export declare const JavaScript: (workspace: Workspace) => Effect.Effect<JavaScriptPackageManager, PackageManagerError, Runtime | CurrentStep>;
472
+ /**
473
+ * The detected manager, with `run` always through Vite+. Use it for Vite+ tasks or wherever
474
+ * a run must be cached. The global `vp` runs it, or the project's own from `node_modules/.bin`.
475
+ * Install and exec stay with the detected manager, which owns the lockfile.
476
+ */
477
+ export declare const VitePlus: (workspace: Workspace) => Effect.Effect<JavaScriptPackageManager, PackageManagerError, Runtime | CurrentStep>;
478
+ export declare const PackageManager: {
479
+ readonly Apt: typeof Apt;
480
+ readonly JavaScript: typeof JavaScript;
481
+ readonly VitePlus: typeof VitePlus;
482
+ };
483
+ export declare class ToolchainError extends Error {
484
+ readonly _tag = "ToolchainError";
485
+ readonly cwd: string;
486
+ constructor(cwd: string, message: string);
487
+ }
488
+ export interface NodeToolchain {
489
+ readonly version: string;
490
+ readonly workspace: Workspace;
491
+ readonly install: () => Effect.Effect<Workspace, CommandFailure, Runtime | CurrentStep>;
492
+ readonly exec: (command: string) => Effect.Effect<Workspace, CommandFailure, Runtime | CurrentStep>;
493
+ }
494
+ export interface MiseInstallOptions {
495
+ readonly locked?: boolean;
496
+ }
497
+ export interface MiseToolchain {
498
+ readonly workspace: Workspace;
499
+ readonly install: (options?: MiseInstallOptions) => Effect.Effect<Workspace, CommandFailure, Runtime | CurrentStep>;
500
+ readonly exec: (command: string) => Effect.Effect<Workspace, CommandFailure, Runtime | CurrentStep>;
501
+ }
502
+ declare const Node: (workspace: Workspace) => Effect.Effect<NodeToolchain, ToolchainError, Runtime | CurrentStep>;
503
+ declare const Mise: (workspace: Workspace) => Effect.Effect<MiseToolchain, ToolchainError, Runtime | CurrentStep>;
504
+ declare const Turbo: (workspace: Workspace) => Effect.Effect<{
505
+ workspace: Workspace;
506
+ tags: (...tags: ReadonlyArray<string>) => Effect.Effect<Workspace, any, any>;
507
+ }, never, CurrentStep | Runtime>;
508
+ export declare const Toolchain: {
509
+ readonly Node: typeof Node;
510
+ readonly Mise: typeof Mise;
511
+ readonly Turbo: typeof Turbo;
512
+ };
513
+ export interface SourceService {
514
+ /** Acquire the repository and immutable revision selected by the initiating event. */
515
+ readonly checkout: () => Effect.Effect<Workspace, unknown>;
516
+ /** Provider-neutral provenance for logs, evidence, and cache identity. */
517
+ readonly reference?: SourceReference;
518
+ /** Optional provider diff (including non-Git sources). Missing knowledge runs work. */
519
+ readonly changes?: (comparison?: SourceComparison) => Effect.Effect<SourceChanges, unknown>;
520
+ }
521
+ /** A destination-scoped read capability, not a cache or permission to publish. */
522
+ export interface WorkspaceChangeProvider {
523
+ readonly changed: (request: {
524
+ readonly workflowId: string;
525
+ readonly stepId: string;
526
+ readonly workspace: Workspace;
527
+ readonly patterns: ReadonlyArray<string>;
528
+ }) => Effect.Effect<boolean | undefined, unknown>;
529
+ }
530
+ declare const Source_base: Context.ServiceClass<Source, "@effect-ci-testbed/Source", SourceQueries>;
531
+ export declare class Source extends Source_base {
532
+ }
533
+ export interface CommandExecutionRequest {
534
+ readonly command: string;
535
+ /** Position in the action, including commands reused by a check-cache layer. */
536
+ readonly commandIndex?: number;
537
+ readonly onOutput: (stream: "stdout" | "stderr", text: string) => void;
538
+ readonly options: WorkflowStepConfig;
539
+ readonly stepId: string;
540
+ readonly workflowId: string;
541
+ readonly workspace: Workspace;
542
+ }
543
+ export interface CommandExecutionResult {
544
+ readonly exitCode: number;
545
+ readonly stderr: string;
546
+ readonly stdout: string;
547
+ }
548
+ export interface CommandExecutor {
549
+ /**
550
+ * The executor maps retry and timeout options to its native runtime. When
551
+ * omitted, Effect applies the policy around the complete action body.
552
+ */
553
+ readonly handlesStepOptions?: boolean;
554
+ readonly execute: (request: CommandExecutionRequest) => Effect.Effect<CommandExecutionResult, CommandFailure>;
555
+ }
556
+ export interface CheckCacheRequest {
557
+ readonly command: string;
558
+ readonly event: WorkflowEventShape;
559
+ readonly policy: {
560
+ readonly scope: CheckReuseScope;
561
+ };
562
+ readonly stepId: string;
563
+ /** What the command reports about its reads, when a tool traces them. */
564
+ readonly trace?: CommandTrace;
565
+ readonly workflowId: string;
566
+ readonly workspace: Workspace;
567
+ }
568
+ /** Runner policy for reusing side-effect-free checks with the same exact inputs. */
569
+ export interface CheckCache {
570
+ readonly lookup: (request: CheckCacheRequest) => Effect.Effect<boolean, unknown>;
571
+ /** Called only after successful execution. The result is the runner's output,
572
+ * never an action-provided assertion. Older read-only adapters may ignore it. */
573
+ readonly record: (request: CheckCacheRequest, result?: CommandExecutionResult) => Effect.Effect<void, unknown>;
574
+ }
575
+ export interface StepResultCacheRequest {
576
+ readonly event: WorkflowEventShape;
577
+ readonly stepId: string;
578
+ readonly workflowId: string;
579
+ }
580
+ /** Host-owned reuse of completed computation, including its returned artifacts.
581
+ * Enrollment, input verification and value hydration belong to the adapter.
582
+ * An absent result is a miss; { value: undefined } is a valid stored result.
583
+ * Never enroll external writes, deployments or approval decisions.
584
+ */
585
+ export interface StepResultCache {
586
+ readonly lookup: (request: StepResultCacheRequest) => Effect.Effect<{
587
+ readonly value: unknown;
588
+ } | undefined, unknown>;
589
+ /** Called after successful execution and workspace commit, never before. */
590
+ readonly record: (request: StepResultCacheRequest, value: unknown) => Effect.Effect<void, unknown>;
591
+ }
592
+ export interface WorkspaceFileSystem {
593
+ readonly exists: (workspace: Workspace, path: string, stepId: string) => Effect.Effect<boolean, unknown>;
594
+ readonly readFile: (workspace: Workspace, path: string, stepId: string) => Effect.Effect<string | undefined, unknown>;
595
+ }
596
+ export interface WorkspacePersistence {
597
+ readonly commit: (request: {
598
+ readonly stepId: string;
599
+ readonly workflowId: string;
600
+ readonly workspace: Workspace;
601
+ }) => Effect.Effect<Workspace, unknown>;
602
+ readonly checkpoint: (request: {
603
+ readonly name: string;
604
+ readonly stepId: string;
605
+ readonly workflowId: string;
606
+ readonly workspace: Workspace;
607
+ }) => Effect.Effect<WorkspaceCheckpointHandle, unknown>;
608
+ readonly restore: (request: {
609
+ readonly checkpoint: WorkspaceCheckpoint;
610
+ readonly stepId: string;
611
+ readonly workflowId: string;
612
+ }) => Effect.Effect<Workspace, unknown>;
613
+ }
614
+ export interface Workflow<A> {
615
+ readonly id: string;
616
+ readonly effect: Effect.Effect<A, unknown, Runtime | CurrentStep | WorkflowEvent | Approval>;
617
+ }
618
+ /** Runner-owned reusable workspace cache policy. */
619
+ export interface WorkspaceCachePolicy {
620
+ readonly key: string;
621
+ readonly keyFiles: ReadonlyArray<string>;
622
+ readonly paths: ReadonlyArray<string>;
623
+ }
624
+ export type WorkflowEventName = "deploy_hook" | "deployment" | "deployment_status" | "merge_group" | "observability_issue" | "pull_request" | "push" | "release" | "workflow_dispatch";
625
+ export type SourceReference = {
626
+ readonly kind: "artifact";
627
+ readonly digest: string;
628
+ readonly name: string;
629
+ } | {
630
+ readonly kind: "durable_object";
631
+ readonly id: string;
632
+ readonly revision: string;
633
+ } | {
634
+ readonly kind: "git";
635
+ readonly repository: string;
636
+ readonly revision: string;
637
+ } | {
638
+ readonly kind: "local";
639
+ readonly path: string;
640
+ readonly revision?: string;
641
+ } | {
642
+ readonly kind: "r2";
643
+ readonly bucket: string;
644
+ readonly digest: string;
645
+ readonly key: string;
646
+ };
647
+ export interface WorkflowEventShape {
648
+ readonly type: WorkflowEventName;
649
+ readonly payload?: unknown;
650
+ /** Event adapter's affected-files comparison, not a cache/attestation identity. */
651
+ readonly comparison?: SourceComparison;
652
+ /** Source selected by the event adapter. Non-source events may omit it. */
653
+ readonly source?: SourceReference;
654
+ /** A normalized source ref such as `refs/heads/main` or `refs/tags/v1.0.0`. */
655
+ readonly ref?: string;
656
+ /** The immutable source revision, normally a commit SHA. */
657
+ readonly revision?: string;
658
+ }
659
+ declare const WorkflowEvent_base: Context.ServiceClass<WorkflowEvent, "@effect-ci-testbed/WorkflowEvent", WorkflowEventShape>;
660
+ export declare class WorkflowEvent extends WorkflowEvent_base {
661
+ }
662
+ /** A serializable predicate that can be rendered in a plan before it runs. */
663
+ export type Condition = {
664
+ readonly _tag: "event";
665
+ readonly oneOf: ReadonlyArray<WorkflowEventName>;
666
+ } | {
667
+ readonly _tag: "ref";
668
+ readonly oneOf: ReadonlyArray<string>;
669
+ } | {
670
+ readonly _tag: "all";
671
+ readonly conditions: ReadonlyArray<Condition>;
672
+ } | {
673
+ readonly _tag: "any";
674
+ readonly conditions: ReadonlyArray<Condition>;
675
+ } | {
676
+ readonly _tag: "not";
677
+ readonly condition: Condition;
678
+ };
679
+ export declare const Condition: {
680
+ readonly event: (...oneOf: ReadonlyArray<WorkflowEventName>) => Condition;
681
+ readonly ref: (...oneOf: ReadonlyArray<string>) => Condition;
682
+ readonly all: (...conditions: ReadonlyArray<Condition>) => Condition;
683
+ readonly any: (...conditions: ReadonlyArray<Condition>) => Condition;
684
+ readonly not: (condition: Condition) => Condition;
685
+ };
686
+ export declare const matchesCondition: (condition: Condition, event: WorkflowEventShape) => boolean;
687
+ export declare const optional: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A | undefined, E, R | Runtime>;
688
+ /**
689
+ * Conditionally executes an action while preserving the predicate in the plan.
690
+ * Use ordinary Effect control flow for runtime-only decisions; use `when` when
691
+ * operators and remote runners need to inspect the branch before execution.
692
+ */
693
+ export declare const when: <A, E, R>(condition: Condition, effect: Effect.Effect<A, E, R>) => Effect.Effect<A | undefined, E, R | Runtime | CurrentStep | WorkflowEvent>;
694
+ export declare const parallel: <Effects extends ReadonlyArray<Effect.Effect<any, any, any>>>(effects: Effects) => Effect.Effect<void, any, any>;
695
+ export declare const step: <A>(id: string, body: StepBody<A>, options?: StepOptions) => Effect.Effect<A, unknown, Runtime | CurrentStep>;
696
+ export declare const action: <A = Workspace, Args extends ReadonlyArray<unknown> = ReadonlyArray<never>>(id: string, construction: ActionConstruction<Args, NoInfer<A>>, options?: ActionOptions) => ((...args: Args) => Effect.Effect<A, unknown, Runtime | CurrentStep>);
697
+ /**
698
+ * A side-effect-free assertion whose success can be reused by a trusted runner.
699
+ * Checks return no workspace revision or domain output: they either succeed or fail.
700
+ * A handler may end with `workspace.exec(...)`; its workspace is discarded, so a
701
+ * runner never commits (snapshots) a check's workspace after the command passes.
702
+ */
703
+ export declare const check: <Args extends ReadonlyArray<unknown> = ReadonlyArray<never>>(id: string, construction: ActionConstruction<Args, void>, options?: CheckOptions) => ((...args: Args) => Effect.Effect<void, unknown, Runtime | CurrentStep>);
704
+ /** Identifies action factories exported as direct CLI targets. */
705
+ export declare const isAction: (value: unknown) => value is ActionTarget;
706
+ export declare const workflow: <A>(id: string, body: WorkflowBody<A>) => Workflow<A>;
707
+ export interface RunOptions {
708
+ readonly actionExecutor?: ActionExecutor;
709
+ readonly approval?: ApprovalHandler;
710
+ readonly ci?: boolean;
711
+ readonly executor?: CommandExecutor;
712
+ readonly env?: string;
713
+ readonly event?: WorkflowEventShape;
714
+ readonly mode?: WorkflowPlan["mode"];
715
+ readonly onAttempt?: WorkflowAttemptHandler;
716
+ /** Required event persistence/reporting. Failure remains authoritative. */
717
+ readonly onEvent?: RuntimeEventHandler;
718
+ /** Explicit, bounded presentation-only destinations. Never approval/persistence. */
719
+ readonly observers?: RuntimeObservers;
720
+ readonly output?: "inherit" | "silent";
721
+ readonly rerun?: WorkflowRerun;
722
+ readonly secrets?: SecretResolver;
723
+ readonly source?: SourceService;
724
+ readonly workspacePersistence?: WorkspacePersistence;
725
+ readonly workspaceFileSystem?: WorkspaceFileSystem;
726
+ readonly checkCache?: CheckCache;
727
+ readonly stepResultCache?: StepResultCache;
728
+ /** Skip check and step-result cache lookups. Results are still recorded. */
729
+ readonly force?: boolean;
730
+ readonly workspaceChanges?: WorkspaceChangeProvider;
731
+ }
732
+ export interface RunConfiguration extends RunOptions {
733
+ readonly dispose?: () => Promise<void>;
734
+ }
735
+ export declare const formatCondition: (condition: Condition) => string;
736
+ export declare const formatPlan: (plan: WorkflowPlan) => string;
737
+ export declare const run: <A>(workflowDefinition: Workflow<A>, options?: RunOptions) => Effect.Effect<{
738
+ attempt: Readonly<{
739
+ id: string;
740
+ number: number;
741
+ workflowId: string;
742
+ previousAttemptId?: string;
743
+ requested: readonly string[];
744
+ plan: WorkflowPlan;
745
+ outputs: Readonly<{
746
+ [k: string]: unknown;
747
+ }>;
748
+ conclusion: "failure" | "success";
749
+ startedAt: string;
750
+ completedAt: string;
751
+ }>;
752
+ plan: WorkflowPlan;
753
+ value: A;
754
+ }, unknown, never>;
755
+ export declare const runPromise: <A>(workflowDefinition: Workflow<A>, options?: RunOptions) => Promise<{
756
+ attempt: Readonly<{
757
+ id: string;
758
+ number: number;
759
+ workflowId: string;
760
+ previousAttemptId?: string;
761
+ requested: readonly string[];
762
+ plan: WorkflowPlan;
763
+ outputs: Readonly<{
764
+ [k: string]: unknown;
765
+ }>;
766
+ conclusion: "failure" | "success";
767
+ startedAt: string;
768
+ completedAt: string;
769
+ }>;
770
+ plan: WorkflowPlan;
771
+ value: A;
772
+ }>;
773
+ /** Expose package scripts and discovered Vite+ tasks as explicitly selectable actions. */
774
+ export declare const fromPackageJson: (manifest: {
775
+ readonly name?: string;
776
+ readonly scripts?: Readonly<Record<string, string>>;
777
+ }, options?: {
778
+ readonly tasks?: ReadonlyArray<string>;
779
+ /** Local Vite+ prerequisites, used only to describe the plan. Vite+ executes them. */
780
+ readonly taskDependencies?: Readonly<Record<string, ReadonlyArray<string>>>;
781
+ }) => {
782
+ requiresTarget: boolean;
783
+ actions: Record<string, () => Effect.Effect<Workspace, unknown, Runtime | CurrentStep>>;
784
+ /** Shared preparation for trusted runner-added checks; not a CLI target. */
785
+ checkout: () => Effect.Effect<Workspace, unknown, CurrentStep | Runtime>;
786
+ workflow: Workflow<Workspace | undefined>;
787
+ };