@skastr0/prism-linux-x64 0.5.1 → 0.7.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/bin/prism +2 -2
- package/package.json +3 -3
- package/types/compile/errors.d.ts +57 -79
- package/types/compile/runtime/schema-bridge.d.ts +15 -12
- package/types/errors.d.ts +24 -34
- package/types/index.d.ts +2 -1
- package/types/jev.d.ts +254 -0
- package/types/lowerer-capabilities.d.ts +21 -0
- package/types/prism-home.d.ts +3 -4
- package/types/services/jev.d.ts +131 -0
- package/types/types.d.ts +2 -1
- package/types/workflow-harness-detection.d.ts +5 -8
- package/types/workflow-identity.d.ts +34 -6
- package/types/workflow-runner.d.ts +15 -1
- package/types/workflow-scheduler/cron.d.ts +60 -0
- package/types/workflow-scheduler/errors.d.ts +71 -0
- package/types/workflow-scheduler/schedule.d.ts +61 -0
- package/types/workflow-session.d.ts +26 -19
- package/types/workflow-store.d.ts +142 -7
- package/types/workflows.d.ts +93 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type WorkflowRetentionCleanupReport, type WorkflowRunArtifactCounts, type WorkflowRunDeletionReport } from "./workflow-data-governance.js";
|
|
2
2
|
import type { WorkflowJudgeVerdict } from "./workflows.js";
|
|
3
|
-
import type { WorkflowJudgeIdentity, WorkflowRunTaskSnapshot, WorkflowTaskIdentity } from "./workflow-identity.js";
|
|
4
|
-
export { workflowRunTaskSnapshotForTask, workflowTaskIdentity, type WorkflowJudgeIdentity, type WorkflowRunTaskSnapshot, type WorkflowTaskIdentity } from "./workflow-identity.js";
|
|
3
|
+
import type { WorkflowJudgeIdentity, WorkflowRunTaskSnapshot, WorkflowRunTaskSnapshotInput, WorkflowTaskIdentity } from "./workflow-identity.js";
|
|
4
|
+
export { workflowRunTaskSnapshotForTask, workflowTaskIdentity, type JevRunTaskSnapshot, type WorkflowJudgeIdentity, type WorkflowRunTaskSnapshot, type WorkflowRunTaskSnapshotInput, type WorkflowTaskIdentity, type WorkflowWorkerRunTaskSnapshot, } from "./workflow-identity.js";
|
|
5
5
|
import { type WorkflowDatabase } from "./workflow-runtime.js";
|
|
6
6
|
import type { WorkflowSpanRecord } from "./workflow-tracing.js";
|
|
7
7
|
import { type WorkflowUsage, type WorkflowUsageTotals } from "./workflow-usage.js";
|
|
@@ -200,11 +200,73 @@ export type WorkflowRunStatus = "running" | "completed" | "failed" | "escalated"
|
|
|
200
200
|
* A run's persisted status can read "completed" while carrying isolated task failures: the
|
|
201
201
|
* dynamic runtime's fault-isolation contract (PQ-166) lets an author's `run` program finish
|
|
202
202
|
* successfully after recovering from a task that itself failed or escalated (e.g. via
|
|
203
|
-
* `Effect.
|
|
203
|
+
* `Effect.result`). That is not a caller-visible success — a caller gating on `$?` (the CLI)
|
|
204
204
|
* must still see the partial failure. Success requires both: the run itself reached
|
|
205
205
|
* "completed", and every recorded task did too.
|
|
206
206
|
*/
|
|
207
207
|
export declare function isWorkflowRunOutcomeSuccessful(runStatus: WorkflowRunStatus, taskStatuses: ReadonlyArray<WorkflowRunTaskProgressStatus>): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Provenance for a run the scheduler launched, rather than one a human started.
|
|
210
|
+
*
|
|
211
|
+
* Absent on a hand-run workflow. That absence is the honest answer — there was
|
|
212
|
+
* no execution and no occurrence — so it is modelled as an optional parameter
|
|
213
|
+
* and a nullable column, not as a sentinel string.
|
|
214
|
+
*/
|
|
215
|
+
export interface WorkflowRunScheduling {
|
|
216
|
+
/** The scheduler execution that launched this run. */
|
|
217
|
+
readonly executionId: string;
|
|
218
|
+
/** The installed schedule the execution belongs to. */
|
|
219
|
+
readonly scheduleId: string;
|
|
220
|
+
/** The cron occurrence this run represents, as an ISO-8601 instant. */
|
|
221
|
+
readonly scheduledFor: string | null;
|
|
222
|
+
}
|
|
223
|
+
/** The triple that identifies a runner process without relying on the pid alone. */
|
|
224
|
+
export interface WorkflowRunRunnerIdentity {
|
|
225
|
+
readonly pid: number;
|
|
226
|
+
readonly bootId: string | null;
|
|
227
|
+
readonly startId: string | null;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The scheduler's read-only view of a run it owns.
|
|
231
|
+
*
|
|
232
|
+
* Purpose-built rather than reusing `WorkflowRunRecord`: reconciliation needs
|
|
233
|
+
* the runner identity and the launch-authorization state, which are internal to
|
|
234
|
+
* the scheduling protocol and not part of the general run surface.
|
|
235
|
+
*/
|
|
236
|
+
export interface WorkflowScheduledRunState {
|
|
237
|
+
readonly runId: string;
|
|
238
|
+
readonly workflow: string;
|
|
239
|
+
readonly status: WorkflowRunStatus;
|
|
240
|
+
readonly schedulingExecutionId: string | null;
|
|
241
|
+
readonly schedulingScheduleId: string | null;
|
|
242
|
+
readonly scheduledFor: string | null;
|
|
243
|
+
readonly runner: WorkflowRunRunnerIdentity | null;
|
|
244
|
+
/**
|
|
245
|
+
* Whether a runner consumed this run's launch authorization.
|
|
246
|
+
*
|
|
247
|
+
* Meaningful only when `schedulingExecutionId` is set. The scheduler always
|
|
248
|
+
* issues an authorization token before spawning, so for a scheduled run a
|
|
249
|
+
* present token means no runner ever consumed it, and a consumed token means
|
|
250
|
+
* a runner did. A hand-run workflow has no token to consume and no execution
|
|
251
|
+
* to reconcile, so this field is not consulted for one.
|
|
252
|
+
*/
|
|
253
|
+
readonly launchAuthorized: boolean;
|
|
254
|
+
readonly terminalCause: WorkflowRunTerminalCause | null;
|
|
255
|
+
readonly finishedAt: string | null;
|
|
256
|
+
readonly heartbeatAt: string | null;
|
|
257
|
+
}
|
|
258
|
+
/** The outcome of a runner attempting to consume its launch authorization. */
|
|
259
|
+
export type WorkflowRunLaunchAuthorization = {
|
|
260
|
+
readonly kind: "authorized";
|
|
261
|
+
} | {
|
|
262
|
+
readonly kind: "not-found";
|
|
263
|
+
} | {
|
|
264
|
+
readonly kind: "unauthorized";
|
|
265
|
+
readonly reason: string;
|
|
266
|
+
} | {
|
|
267
|
+
readonly kind: "terminal";
|
|
268
|
+
readonly status: WorkflowRunStatus;
|
|
269
|
+
};
|
|
208
270
|
export interface WorkflowEventRecord {
|
|
209
271
|
readonly sequence: number;
|
|
210
272
|
readonly runId: string;
|
|
@@ -292,7 +354,7 @@ export interface WorkflowTaskAttemptRecord {
|
|
|
292
354
|
}
|
|
293
355
|
export declare const projectWorkflowStoreDir: (prismHome: string, cwd?: string) => string;
|
|
294
356
|
export declare const defaultWorkflowStorePath: (prismHome: string, cwd?: string) => string;
|
|
295
|
-
export declare const WORKFLOW_STORE_SCHEMA_VERSION =
|
|
357
|
+
export declare const WORKFLOW_STORE_SCHEMA_VERSION = 8;
|
|
296
358
|
/**
|
|
297
359
|
* Surfaces the one-time soft-divergence direction (WFE-007): a pre-existing store opened at a
|
|
298
360
|
* schema version older than the binary's `WORKFLOW_STORE_SCHEMA_VERSION` migrates in place inside
|
|
@@ -352,17 +414,78 @@ export declare class WorkflowStore {
|
|
|
352
414
|
readonly cacheKey?: string;
|
|
353
415
|
readonly promptHash?: string;
|
|
354
416
|
}): WorkflowCacheRecord[];
|
|
355
|
-
|
|
417
|
+
/**
|
|
418
|
+
* Create a run row.
|
|
419
|
+
*
|
|
420
|
+
* `scheduling` records provenance for a run the scheduler launched. It is
|
|
421
|
+
* written in the same transaction as the row itself, because a run that
|
|
422
|
+
* exists without its provenance would be a run the scheduler cannot claim
|
|
423
|
+
* during reconciliation.
|
|
424
|
+
*/
|
|
425
|
+
createRun(workflow: string, runId?: string, scheduling?: WorkflowRunScheduling): string;
|
|
426
|
+
/**
|
|
427
|
+
* Consume a run's launch authorization and record the runner's identity.
|
|
428
|
+
*
|
|
429
|
+
* This is the linearization point of the launch protocol, and it is one
|
|
430
|
+
* transaction on purpose. "A runner was authorized" and "here is the runner's
|
|
431
|
+
* identity" must not be able to disagree, or reconciliation would face a
|
|
432
|
+
* window where a runner may have imported user code but left no identity to
|
|
433
|
+
* observe — an ambiguity with no honest resolution.
|
|
434
|
+
*
|
|
435
|
+
* The token comparison is timing-safe and the update is a compare-and-set on
|
|
436
|
+
* the token column, so two runners racing for the same authorization produce
|
|
437
|
+
* exactly one winner and one `unauthorized`.
|
|
438
|
+
*
|
|
439
|
+
* This deliberately does **not** touch `heartbeat_at`. The heartbeat is the
|
|
440
|
+
* *readiness* marker a detached launcher waits on, and readiness means "the
|
|
441
|
+
* runner is executing", not "the runner claimed the run" — so it is published
|
|
442
|
+
* by `markRunRunnerStarted` after the workflow module has loaded. Publishing it
|
|
443
|
+
* here would make a workflow whose top-level code exits look like a successful
|
|
444
|
+
* start, because authorization now happens before the import.
|
|
445
|
+
*/
|
|
446
|
+
beginScheduledRun(input: {
|
|
447
|
+
readonly runId: string;
|
|
448
|
+
readonly token: string;
|
|
449
|
+
readonly runnerPid: number;
|
|
450
|
+
readonly runnerBootId: string | null;
|
|
451
|
+
readonly runnerStartId: string | null;
|
|
452
|
+
}): WorkflowRunLaunchAuthorization;
|
|
453
|
+
/**
|
|
454
|
+
* The scheduler's reconciliation view of one run. Null when the run does not
|
|
455
|
+
* exist — which is itself meaningful, since the scheduler creates the run
|
|
456
|
+
* before it spawns anything.
|
|
457
|
+
*/
|
|
458
|
+
scheduledRunState(runId: string): WorkflowScheduledRunState | null;
|
|
459
|
+
/**
|
|
460
|
+
* Terminalize a scheduled run the scheduler has established cannot continue.
|
|
461
|
+
*
|
|
462
|
+
* Returns whether it wrote, so the caller can tell "we closed it" from "the
|
|
463
|
+
* runner claimed it first". The ledger keeps its existing status vocabulary —
|
|
464
|
+
* `crashed` for a worker that died mid-run, `stopped` for one that never
|
|
465
|
+
* received its authorization — while the scheduler's more specific knowledge
|
|
466
|
+
* lives on the execution row and in the event stream. Widening
|
|
467
|
+
* `WorkflowRunStatus` for the scheduler's benefit would put a new state in
|
|
468
|
+
* front of every consumer of run history for no gain.
|
|
469
|
+
*
|
|
470
|
+
* The update is guarded on `status = 'running'`, so it is a compare-and-set
|
|
471
|
+
* against a runner claiming the run concurrently: exactly one wins.
|
|
472
|
+
*/
|
|
473
|
+
interruptScheduledRun(input: {
|
|
474
|
+
readonly runId: string;
|
|
475
|
+
readonly kind: "interrupted" | "cancelled";
|
|
476
|
+
readonly reason: string;
|
|
477
|
+
readonly runnerPid?: number | null;
|
|
478
|
+
readonly heartbeatAt?: string | null;
|
|
479
|
+
}): boolean;
|
|
356
480
|
recordRunSnapshot(input: {
|
|
357
481
|
readonly runId: string;
|
|
358
482
|
readonly workflowFile: string;
|
|
359
483
|
readonly options?: Record<string, unknown>;
|
|
360
484
|
}): void;
|
|
361
485
|
getRunSnapshot(runId: string): WorkflowRunSnapshot | null;
|
|
362
|
-
recordRunTaskSnapshot(input:
|
|
486
|
+
recordRunTaskSnapshot(input: WorkflowRunTaskSnapshotInput): void;
|
|
363
487
|
listRunTaskSnapshots(runId: string): WorkflowRunTaskSnapshot[];
|
|
364
488
|
setRunHandoffToken(runId: string, token: string): void;
|
|
365
|
-
consumeRunHandoffToken(runId: string, token: string): boolean;
|
|
366
489
|
markRunRunnerStarted(runId: string, runnerPid: number): void;
|
|
367
490
|
heartbeatRun(runId: string): void;
|
|
368
491
|
recordTaskAttemptStarted(input: WorkflowTaskAttemptStartedInput): void;
|
|
@@ -380,6 +503,18 @@ export declare class WorkflowStore {
|
|
|
380
503
|
readonly reason?: string;
|
|
381
504
|
readonly mode?: string;
|
|
382
505
|
}): WorkflowRunRecord | null;
|
|
506
|
+
/**
|
|
507
|
+
* Read a run **without** observer reconciliation.
|
|
508
|
+
*
|
|
509
|
+
* The detached launcher polls its own run while it waits for the readiness
|
|
510
|
+
* handshake, and during startup it is the authority on that run. `getRun`
|
|
511
|
+
* runs `failDeadPidRuns` first, so a launcher polling its own child would
|
|
512
|
+
* terminalize the run as `dead-runner-pid` the instant the child died —
|
|
513
|
+
* preempting the launcher's own, more specific `runner-start-failed` cause and
|
|
514
|
+
* the stderr evidence it captured. Reconciliation is for observers, not for
|
|
515
|
+
* the process that owns the handshake.
|
|
516
|
+
*/
|
|
517
|
+
peekRun(runId: string): WorkflowRunRecord | null;
|
|
383
518
|
getRun(runId: string): WorkflowRunRecord | null;
|
|
384
519
|
recordEvent(input: {
|
|
385
520
|
readonly runId: string;
|
package/types/workflows.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
2
|
-
import type { Either } from "effect/Either";
|
|
3
|
-
import type { ParseError } from "effect/ParseResult";
|
|
1
|
+
import { Effect, Result, Schema, type SchemaAST } from "effect";
|
|
4
2
|
import { type WorkflowRuntimeError } from "./workflow-errors.js";
|
|
3
|
+
import { type WorkflowSchedule } from "./workflow-scheduler/schedule.js";
|
|
4
|
+
import { type JevEntry, type JevQuestions, type JevRequest, type JevResult, type JevResultCodec } from "./jev.js";
|
|
5
5
|
export type { WorkflowRuntimeError } from "./workflow-errors.js";
|
|
6
|
+
export { WORKFLOW_SCHEDULE_MISSED_RUN_POLICIES, WORKFLOW_SCHEDULE_OVERLAP_POLICIES, isWorkflowSchedule, parseWorkflowSchedule, type WorkflowSchedule, type WorkflowScheduleMissedRuns, type WorkflowScheduleOverlap, } from "./workflow-scheduler/schedule.js";
|
|
6
7
|
export interface WorkflowModelRef {
|
|
7
8
|
readonly modelspace?: string;
|
|
8
9
|
readonly profile?: string;
|
|
@@ -42,7 +43,19 @@ export interface WorkflowValidationSummary {
|
|
|
42
43
|
readonly tasks: ReadonlyArray<WorkflowTaskSummary>;
|
|
43
44
|
readonly dynamic: boolean;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Constraint for a workflow task's output schema.
|
|
48
|
+
*
|
|
49
|
+
* The load-bearing part is `never, never`: a task output schema must decode and
|
|
50
|
+
* encode without services. `Type` stays `unknown` so the generic bound cannot
|
|
51
|
+
* silently turn decoded values into `any`.
|
|
52
|
+
*
|
|
53
|
+
* `WorkflowFinishOptions` consumes `Output` in contravariant callback positions,
|
|
54
|
+
* which makes a task invariant in its output type. A heterogeneous task tuple is
|
|
55
|
+
* therefore accepted only where the output type is erased, which happens at
|
|
56
|
+
* `AnyWorkflowTask` rather than here.
|
|
57
|
+
*/
|
|
58
|
+
export type WorkflowOutputSchema = Schema.Codec<unknown, unknown, never, never>;
|
|
46
59
|
export type WorkflowFinishCriterionError = Error;
|
|
47
60
|
export type WorkflowWorkerId = "amp-code" | "antigravity-cli" | "claude-code" | "codex-cli" | "cursor" | "devin" | "grok" | "hermes" | "kimi-code" | "opencode" | "opencode2" | "omp";
|
|
48
61
|
/**
|
|
@@ -139,11 +152,11 @@ export interface WorkflowTaskModelResolution {
|
|
|
139
152
|
* `undefined` so per-worker CLIs that tolerate an omitted --model flag
|
|
140
153
|
* (e.g. opencode) keep doing so.
|
|
141
154
|
*/
|
|
142
|
-
export declare const resolveWorkflowTaskModelResolution: (task:
|
|
155
|
+
export declare const resolveWorkflowTaskModelResolution: (task: AnyWorkflowWorkerTask, options?: {
|
|
143
156
|
readonly worker?: string;
|
|
144
157
|
readonly fallbackModel?: string;
|
|
145
158
|
}) => WorkflowTaskModelResolution | undefined;
|
|
146
|
-
export declare const resolveWorkflowTaskModel: (task:
|
|
159
|
+
export declare const resolveWorkflowTaskModel: (task: AnyWorkflowWorkerTask, options?: {
|
|
147
160
|
readonly worker?: string;
|
|
148
161
|
readonly fallbackModel?: string;
|
|
149
162
|
}) => string | undefined;
|
|
@@ -215,20 +228,66 @@ export interface WorkflowTaskDefinition<Id extends string, Output extends Workfl
|
|
|
215
228
|
readonly phase?: string;
|
|
216
229
|
readonly cacheKey?: string;
|
|
217
230
|
readonly worker?: WorkflowTaskWorkerOptions;
|
|
218
|
-
readonly finish?: WorkflowFinishOptions<
|
|
231
|
+
readonly finish?: WorkflowFinishOptions<Output["Type"]>;
|
|
219
232
|
}
|
|
220
233
|
export type WorkflowTask<Id extends string = string, Output extends WorkflowOutputSchema = WorkflowOutputSchema> = WorkflowTaskDefinition<Id, Output> & {
|
|
221
234
|
readonly kind: "workflow-task";
|
|
222
235
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
236
|
+
/**
|
|
237
|
+
* A workflow task whose output type is erased.
|
|
238
|
+
*
|
|
239
|
+
* A task is invariant in its output type (`WorkflowFinishOptions` consumes it in
|
|
240
|
+
* callback positions), so `defineWorkflow({ tasks: [build, review] })` only
|
|
241
|
+
* accepts a heterogeneous tuple when the element bound erases that type. The
|
|
242
|
+
* erasure is deliberately local to this bound: `WorkflowOutputSchema` keeps
|
|
243
|
+
* `unknown` so ordinary authoring and `defineTask` inference stay precise, and
|
|
244
|
+
* `WorkflowTaskOutput<Task>` still reads the concrete output of a concrete task.
|
|
245
|
+
*
|
|
246
|
+
* The encoded side and the service-free requirement (`never, never`) are not
|
|
247
|
+
* erased. This is a deliberate loss of proof at the task-collection boundary,
|
|
248
|
+
* not sound existential quantification.
|
|
249
|
+
*/
|
|
250
|
+
export type AnyWorkflowWorkerTask = WorkflowTask<string, Schema.Codec<any, unknown, never, never>>;
|
|
251
|
+
/**
|
|
252
|
+
* A Jev task whose question types are erased. Like the worker erasure above,
|
|
253
|
+
* this keeps heterogeneous `tasks: [...] tuples writable while concrete
|
|
254
|
+
* `jev(...)` calls keep their precise inferred output.
|
|
255
|
+
*/
|
|
256
|
+
export type AnyJevTask = JevTask<string, any>;
|
|
257
|
+
export type AnyWorkflowTask = AnyWorkflowWorkerTask | AnyJevTask;
|
|
258
|
+
export type WorkflowTaskOutput<Task extends AnyWorkflowTask> = Task["output"]["Type"];
|
|
259
|
+
export interface JevTaskDefinition<Id extends string, Q extends JevQuestions> extends JevRequest<Q> {
|
|
260
|
+
readonly id: Id;
|
|
261
|
+
/** Per-HTTP-attempt timeout override passed to the JevClient call. */
|
|
262
|
+
readonly timeoutMs?: number;
|
|
263
|
+
readonly phase?: string;
|
|
264
|
+
readonly cacheKey?: string;
|
|
265
|
+
}
|
|
266
|
+
export type JevTask<Id extends string = string, Q extends JevQuestions = JevQuestions> = JevTaskDefinition<Id, Q> & {
|
|
267
|
+
readonly kind: "jev";
|
|
268
|
+
readonly output: JevResultCodec<Q>;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Construct a native Jev decision task. The state/questions are validated,
|
|
272
|
+
* deep-copied, and frozen immediately so identity hashing and execution can
|
|
273
|
+
* never disagree, and the output codec is derived from the questions.
|
|
274
|
+
*/
|
|
275
|
+
export declare const jev: <const Id extends string, const Q extends JevQuestions>(definition: JevTaskDefinition<Id, Q>) => JevTask<Id, Q>;
|
|
276
|
+
export declare const resolveWorkflowTaskSessionPersistence: (task: Pick<AnyWorkflowWorkerTask, "worker">, effectiveWorker?: string | undefined) => WorkflowSessionPersistence | undefined;
|
|
277
|
+
export declare const assertWorkflowTaskSessionPersistence: (task: AnyWorkflowWorkerTask) => void;
|
|
278
|
+
export declare const isWorkflowWorkerTask: (value: unknown) => value is AnyWorkflowWorkerTask;
|
|
279
|
+
export declare const isJevTask: (value: unknown) => value is AnyJevTask;
|
|
227
280
|
export declare const isWorkflowTask: (value: unknown) => value is AnyWorkflowTask;
|
|
228
281
|
export interface WorkflowDefinition<Name extends string, Tasks extends ReadonlyArray<AnyWorkflowTask>> {
|
|
229
282
|
readonly kind: "workflow";
|
|
230
283
|
readonly name: Name;
|
|
231
284
|
readonly tasks: Tasks;
|
|
285
|
+
/**
|
|
286
|
+
* Inert scheduling policy. Declaring it registers nothing; only
|
|
287
|
+
* `prism workflow schedule install` activates a schedule. See
|
|
288
|
+
* `workflow-scheduler/schedule.ts`.
|
|
289
|
+
*/
|
|
290
|
+
readonly schedule?: WorkflowSchedule;
|
|
232
291
|
}
|
|
233
292
|
export interface PhaseFraming {
|
|
234
293
|
readonly purpose?: string;
|
|
@@ -254,21 +313,37 @@ export type PhaseTaskFinishOptions<Output> = WorkflowFinishOptions<Output> & {
|
|
|
254
313
|
readonly inherit?: boolean;
|
|
255
314
|
};
|
|
256
315
|
/** Decoded TypeScript value of a phase input contract (unknown when no contract). */
|
|
257
|
-
export type PhaseTaskInputValue<Input extends WorkflowOutputSchema | undefined> = Input extends WorkflowOutputSchema ?
|
|
316
|
+
export type PhaseTaskInputValue<Input extends WorkflowOutputSchema | undefined> = Input extends WorkflowOutputSchema ? Input["Type"] : unknown;
|
|
258
317
|
export type PhaseTaskDefinition<Id extends string, Input extends WorkflowOutputSchema | undefined = undefined, Output extends WorkflowOutputSchema = WorkflowOutputSchema> = Omit<WorkflowTaskDefinition<Id, Output>, "output" | "phase" | "finish"> & {
|
|
259
318
|
readonly input?: PhaseTaskInputValue<Input>;
|
|
260
319
|
readonly output?: Output;
|
|
261
320
|
readonly phase?: string;
|
|
262
|
-
readonly finish?: PhaseTaskFinishOptions<
|
|
321
|
+
readonly finish?: PhaseTaskFinishOptions<Output["Type"]>;
|
|
263
322
|
readonly brief?: boolean;
|
|
264
323
|
};
|
|
265
324
|
export type PhaseCtxTask<Input extends WorkflowOutputSchema | undefined, DefaultOutput extends WorkflowOutputSchema | undefined> = <const Id extends string, const TaskOutput extends WorkflowOutputSchema = Extract<DefaultOutput, WorkflowOutputSchema>>(def: PhaseTaskDefinition<Id, Input, TaskOutput>) => Effect.Effect<WorkflowTaskOutput<WorkflowTask<Id, TaskOutput>>, WorkflowRuntimeError>;
|
|
325
|
+
/**
|
|
326
|
+
* A `ctx.jev(...)` definition. When the phase binds an input contract, the
|
|
327
|
+
* Jev state is that contract's decoded value (it must still be a valid System
|
|
328
|
+
* One entry — schemas describing functions or class instances do not belong
|
|
329
|
+
* in state and will fail entry validation at run time).
|
|
330
|
+
*/
|
|
331
|
+
export type PhaseJevTaskDefinition<Id extends string, Input extends WorkflowOutputSchema | undefined, Q extends JevQuestions> = Omit<JevTaskDefinition<Id, Q>, "state"> & {
|
|
332
|
+
readonly state: Input extends WorkflowOutputSchema ? Input["Type"] & JevEntry : JevEntry;
|
|
333
|
+
};
|
|
334
|
+
export type PhaseCtxJev<Input extends WorkflowOutputSchema | undefined> = <const Id extends string, const Q extends JevQuestions>(definition: PhaseJevTaskDefinition<Id, Input, Q>) => Effect.Effect<JevResult<Q>, WorkflowRuntimeError>;
|
|
266
335
|
export interface PhaseCtx<Name extends string, Input extends WorkflowOutputSchema | undefined, DefaultOutput extends WorkflowOutputSchema | undefined> {
|
|
267
336
|
readonly name: Name;
|
|
268
337
|
readonly sop: string;
|
|
269
338
|
readonly plugin: string;
|
|
270
339
|
readonly phase: string;
|
|
271
340
|
readonly task: PhaseCtxTask<Input, DefaultOutput>;
|
|
341
|
+
/**
|
|
342
|
+
* Run a native Jev decision inside this phase. Unlike `ctx.task`, no prompt
|
|
343
|
+
* framing, serialized-input block, finish criteria, or phase output schema
|
|
344
|
+
* is applied — a decision is defined by its state and questions alone.
|
|
345
|
+
*/
|
|
346
|
+
readonly jev: PhaseCtxJev<Input>;
|
|
272
347
|
}
|
|
273
348
|
export declare const phase: <const Name extends string, const Input extends WorkflowOutputSchema | undefined, const Output extends WorkflowOutputSchema | undefined, Result, Err = WorkflowRuntimeError>(runtime: Pick<WorkflowRuntime, "runTask">, contract: PhaseContract<Name, Input, Output>, fn: (ctx: PhaseCtx<Name, Input, Output>) => Effect.Effect<Result, Err, never>) => Effect.Effect<Result, Err | WorkflowRuntimeError, never>;
|
|
274
349
|
export interface WorkflowRuntime {
|
|
@@ -285,6 +360,8 @@ export interface DynamicWorkflowDefinition<Name extends string, Result = unknown
|
|
|
285
360
|
readonly name: Name;
|
|
286
361
|
readonly tasks: readonly [];
|
|
287
362
|
readonly run: (runtime: WorkflowRuntime) => Effect.Effect<Result, Err, never>;
|
|
363
|
+
/** Inert scheduling policy; see `WorkflowDefinition.schedule`. */
|
|
364
|
+
readonly schedule?: WorkflowSchedule;
|
|
288
365
|
}
|
|
289
366
|
export type AnyWorkflowDefinition = WorkflowDefinition<string, ReadonlyArray<AnyWorkflowTask>> | DynamicWorkflowDefinition<string>;
|
|
290
367
|
export declare const isWorkflowDefinition: (value: unknown) => value is AnyWorkflowDefinition;
|
|
@@ -293,9 +370,11 @@ export declare const defineTask: <const Id extends string, const Output extends
|
|
|
293
370
|
export declare function defineWorkflow<const Name extends string, const Tasks extends ReadonlyArray<AnyWorkflowTask>>(definition: {
|
|
294
371
|
readonly name: Name;
|
|
295
372
|
readonly tasks: Tasks;
|
|
373
|
+
readonly schedule?: WorkflowSchedule;
|
|
296
374
|
}): WorkflowDefinition<Name, Tasks>;
|
|
297
375
|
export declare function defineWorkflow<const Name extends string, Result, Err = WorkflowRuntimeError>(definition: {
|
|
298
376
|
readonly name: Name;
|
|
299
377
|
readonly run: (runtime: WorkflowRuntime) => Effect.Effect<Result, Err, never>;
|
|
378
|
+
readonly schedule?: WorkflowSchedule;
|
|
300
379
|
}): DynamicWorkflowDefinition<Name, Result, Err>;
|
|
301
|
-
export declare const decodeTaskOutput: <Task extends AnyWorkflowTask>(task: Task, value: unknown) =>
|
|
380
|
+
export declare const decodeTaskOutput: <Task extends AnyWorkflowTask | AnyJevTask>(task: Task, value: unknown, options?: SchemaAST.ParseOptions) => Result.Result<Task["output"]["Type"], Schema.SchemaError>;
|