@skastr0/prism-linux-x64 0.5.1 → 0.8.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.
- package/bin/prism +2 -2
- package/package.json +3 -3
- package/types/amp-projects.d.ts +39 -0
- package/types/amp-runners.d.ts +71 -0
- package/types/ast-to-json-schema.d.ts +46 -0
- 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/fs.d.ts +2 -2
- package/types/harness-types-discover.d.ts +34 -0
- package/types/harness-types.d.ts +12 -0
- package/types/index.d.ts +21 -2
- package/types/jev.d.ts +254 -0
- package/types/lowerer-capabilities.d.ts +104 -118
- package/types/prism-home.d.ts +3 -4
- package/types/services/jev.d.ts +131 -0
- package/types/types.d.ts +3 -13
- package/types/workflow-amp-remote-worker.d.ts +69 -0
- package/types/workflow-amp-worker.d.ts +89 -0
- package/types/workflow-antigravity-pty.d.ts +22 -0
- package/types/workflow-antigravity-worker.d.ts +84 -0
- package/types/workflow-bun-runtime.d.ts +2 -0
- package/types/workflow-claude-worker.d.ts +36 -0
- package/types/workflow-cli-command.d.ts +1 -0
- package/types/workflow-codex-worker.d.ts +36 -0
- package/types/workflow-cursor-worker.d.ts +24 -0
- package/types/workflow-devin-worker.d.ts +25 -0
- package/types/workflow-effort.d.ts +18 -0
- package/types/workflow-grok-worker.d.ts +32 -0
- package/types/workflow-harness-detection.d.ts +5 -8
- package/types/workflow-hermes-worker.d.ts +28 -0
- package/types/workflow-identity.d.ts +35 -6
- package/types/workflow-kimi-effort.d.ts +17 -0
- package/types/workflow-kimi-worker.d.ts +27 -0
- package/types/workflow-omp-worker.d.ts +49 -0
- package/types/workflow-opencode-worker.d.ts +26 -0
- package/types/workflow-output-schema.d.ts +6 -0
- package/types/workflow-permissions.d.ts +10 -0
- package/types/workflow-process-guard.d.ts +28 -0
- 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 +46 -29
- package/types/workflow-store.d.ts +142 -7
- package/types/workflow-worker-process.d.ts +40 -0
- package/types/workflow-workers.d.ts +50 -0
- package/types/workflows.d.ts +204 -23
|
@@ -35,11 +35,9 @@ export interface WorkflowHarnessDetectionSpec {
|
|
|
35
35
|
readonly envVar: string;
|
|
36
36
|
readonly probeArgs: ReadonlyArray<string>;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* profiles (not the premium tier) so a scaffolded workflow never crashes at
|
|
42
|
-
* run with "no concrete model for workflow worker X".
|
|
38
|
+
* Documented cheap-fast slug for this harness. Detection/probes may cite it.
|
|
39
|
+
* Unpinned workflow tasks must omit the harness model flag so the user's
|
|
40
|
+
* harness default stays in force — do not feed this into spawn.
|
|
43
41
|
*/
|
|
44
42
|
readonly defaultModel: string;
|
|
45
43
|
/**
|
|
@@ -81,9 +79,8 @@ export interface WorkflowHarnessDetectionOptions {
|
|
|
81
79
|
export declare const WORKFLOW_HARNESS_DETECTION_SPECS: Readonly<Record<WorkflowHarnessId, WorkflowHarnessDetectionSpec>>;
|
|
82
80
|
export declare const isWorkflowHarnessId: (id: string) => id is WorkflowHarnessId;
|
|
83
81
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* (src/workflows.ts) — do not hand-maintain a second per-harness default list.
|
|
82
|
+
* Documented cheap-fast slug for a workflow harness, or `undefined` outside
|
|
83
|
+
* the registry. Not applied to unpinned tasks — omit the spawn flag instead.
|
|
87
84
|
*/
|
|
88
85
|
export declare const workflowHarnessDefaultModel: (harness: string) => string | undefined;
|
|
89
86
|
/** Provider paired with `workflowHarnessDefaultModel` for provider-multiplexing harnesses (hermes). */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AnyWorkflowWorkerTask, WorkflowPermissionMode } from "./workflows.js";
|
|
2
|
+
import type { WorkflowTaskExecution, WorkflowTaskProgressReporter, WorkflowTaskRepairLoopOption } from "./workflow-runner.js";
|
|
3
|
+
export type HermesWorkflowWorkerOptions = {
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
readonly bin?: string;
|
|
6
|
+
readonly model?: string;
|
|
7
|
+
readonly provider?: string;
|
|
8
|
+
readonly profile?: string;
|
|
9
|
+
readonly effort?: string;
|
|
10
|
+
readonly resolvedPermission: WorkflowPermissionMode;
|
|
11
|
+
readonly abortSignal?: AbortSignal;
|
|
12
|
+
readonly reportProgress?: WorkflowTaskProgressReporter;
|
|
13
|
+
} & WorkflowTaskRepairLoopOption<"hermes">;
|
|
14
|
+
export declare class HermesWorkflowWorkerError extends Error {
|
|
15
|
+
readonly name = "HermesWorkflowWorkerError";
|
|
16
|
+
readonly metadata?: Record<string, unknown>;
|
|
17
|
+
constructor(message: string, metadata?: Record<string, unknown>);
|
|
18
|
+
}
|
|
19
|
+
export declare const buildHermesArgs: (input: {
|
|
20
|
+
readonly profile?: string;
|
|
21
|
+
readonly model?: string;
|
|
22
|
+
readonly provider?: string;
|
|
23
|
+
readonly effort?: string;
|
|
24
|
+
readonly prompt: string;
|
|
25
|
+
readonly resumeSessionId?: string;
|
|
26
|
+
readonly permission?: WorkflowPermissionMode;
|
|
27
|
+
}) => ReadonlyArray<string>;
|
|
28
|
+
export declare const runHermesWorkflowTask: (task: AnyWorkflowWorkerTask, options: HermesWorkflowWorkerOptions) => Promise<WorkflowTaskExecution>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type AnyWorkflowTask, type WorkflowSessionPersistence, type WorkflowRuntimeOptions } from "./workflows.js";
|
|
2
|
+
import { type JevQuestions, type JevEntry } from "./jev.js";
|
|
3
|
+
import type { JevPublicConfig } from "./services/jev.js";
|
|
2
4
|
/**
|
|
3
5
|
* `cacheKey` and `promptHash` AND together in the cache primary key
|
|
4
6
|
* (workflow-store.ts) — `cacheKey` never substitutes for `promptHash`, and
|
|
@@ -24,29 +26,56 @@ export interface WorkflowJudgeIdentity {
|
|
|
24
26
|
readonly criterion: string;
|
|
25
27
|
readonly cacheKey: string;
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
interface WorkflowRunTaskSnapshotBase {
|
|
28
30
|
readonly runId: string;
|
|
29
31
|
readonly ordinal: number;
|
|
30
32
|
readonly taskId: string;
|
|
31
33
|
readonly phase?: string;
|
|
32
|
-
readonly prompt: string;
|
|
33
34
|
readonly cacheKey: string;
|
|
34
35
|
readonly promptHash: string;
|
|
36
|
+
readonly outputSchema?: unknown;
|
|
37
|
+
readonly createdAt: string;
|
|
38
|
+
}
|
|
39
|
+
export interface WorkflowWorkerRunTaskSnapshot extends WorkflowRunTaskSnapshotBase {
|
|
40
|
+
readonly kind: "workflow-task";
|
|
41
|
+
readonly prompt: string;
|
|
35
42
|
readonly worker?: {
|
|
36
43
|
readonly worker?: string;
|
|
37
44
|
readonly model?: string;
|
|
38
45
|
readonly profile?: string;
|
|
46
|
+
readonly effort?: string;
|
|
39
47
|
readonly sessionPersistence?: WorkflowSessionPersistence;
|
|
40
48
|
};
|
|
41
|
-
readonly outputSchema?: unknown;
|
|
42
49
|
readonly finishCriteria: ReadonlyArray<string>;
|
|
43
|
-
readonly createdAt: string;
|
|
44
50
|
}
|
|
45
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Persisted record of one native Jev decision: the exact request that was
|
|
53
|
+
* identity-hashed and executed, with the effective (non-secret) endpoint and
|
|
54
|
+
* model. Never contains the API key.
|
|
55
|
+
*/
|
|
56
|
+
export interface JevRunTaskSnapshot extends WorkflowRunTaskSnapshotBase {
|
|
57
|
+
readonly kind: "jev";
|
|
58
|
+
readonly request: {
|
|
59
|
+
readonly state: JevEntry;
|
|
60
|
+
readonly questions: JevQuestions;
|
|
61
|
+
readonly model: string;
|
|
62
|
+
readonly baseURL: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export type WorkflowRunTaskSnapshot = WorkflowWorkerRunTaskSnapshot | JevRunTaskSnapshot;
|
|
66
|
+
/**
|
|
67
|
+
* Distributive snapshot-input union. Plain `Omit<Union, "createdAt">` would
|
|
68
|
+
* collapse variant-specific properties (`prompt`, `request`), so each
|
|
69
|
+
* variant's input form is spelled out.
|
|
70
|
+
*/
|
|
71
|
+
export type WorkflowRunTaskSnapshotInput = Omit<WorkflowWorkerRunTaskSnapshot, "createdAt"> | Omit<JevRunTaskSnapshot, "createdAt">;
|
|
72
|
+
export declare const workflowTaskIdentity: (workflow: string, task: AnyWorkflowTask, runtimeOptions?: WorkflowRuntimeOptions, jev?: JevPublicConfig) => WorkflowTaskIdentity;
|
|
46
73
|
export declare const workflowRunTaskSnapshotForTask: (input: {
|
|
47
74
|
readonly runId: string;
|
|
48
75
|
readonly ordinal: number;
|
|
49
76
|
readonly workflow: string;
|
|
50
77
|
readonly task: AnyWorkflowTask;
|
|
51
78
|
readonly runtimeOptions?: WorkflowRuntimeOptions;
|
|
52
|
-
|
|
79
|
+
readonly jev?: JevPublicConfig;
|
|
80
|
+
}) => WorkflowRunTaskSnapshotInput;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const kimiCodeHome: (home?: string) => string;
|
|
2
|
+
export type KimiModelEffortSupport = {
|
|
3
|
+
readonly declared: false;
|
|
4
|
+
} | {
|
|
5
|
+
readonly declared: true;
|
|
6
|
+
readonly efforts: readonly string[];
|
|
7
|
+
} | {
|
|
8
|
+
readonly error: string;
|
|
9
|
+
};
|
|
10
|
+
/** Read one model's optional support_efforts entry from Kimi's config TOML. */
|
|
11
|
+
export declare const parseKimiModelEffortSupport: (source: string, model: string, configPath?: string) => KimiModelEffortSupport;
|
|
12
|
+
/** Validate Kimi's optional model-specific ladder after checking the fixed union. */
|
|
13
|
+
export declare const validateKimiWorkflowEffort: (input: {
|
|
14
|
+
readonly model?: string;
|
|
15
|
+
readonly effort?: string;
|
|
16
|
+
readonly kimiHome?: string;
|
|
17
|
+
}) => string | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AnyWorkflowWorkerTask, WorkflowPermissionMode } from "./workflows.js";
|
|
2
|
+
import type { WorkflowTaskExecution, WorkflowTaskProgressReporter, WorkflowTaskRepairLoopOption } from "./workflow-runner.js";
|
|
3
|
+
export type KimiWorkflowWorkerOptions = {
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
readonly bin?: string;
|
|
6
|
+
readonly model?: string;
|
|
7
|
+
readonly effort?: string;
|
|
8
|
+
readonly kimiHome?: string;
|
|
9
|
+
readonly resolvedPermission: WorkflowPermissionMode;
|
|
10
|
+
readonly abortSignal?: AbortSignal;
|
|
11
|
+
readonly reportProgress?: WorkflowTaskProgressReporter;
|
|
12
|
+
} & WorkflowTaskRepairLoopOption<"kimi-code">;
|
|
13
|
+
export declare class KimiWorkflowWorkerError extends Error {
|
|
14
|
+
readonly name = "KimiWorkflowWorkerError";
|
|
15
|
+
readonly metadata?: Record<string, unknown>;
|
|
16
|
+
constructor(message: string, metadata?: Record<string, unknown>);
|
|
17
|
+
}
|
|
18
|
+
export declare const isKimiAuthOutput: (output: string) => boolean;
|
|
19
|
+
export declare const kimiSessionIdFromStream: (stdout: string) => string | undefined;
|
|
20
|
+
export declare const buildKimiArgs: (input: {
|
|
21
|
+
readonly model?: string;
|
|
22
|
+
readonly prompt: string;
|
|
23
|
+
readonly skillsDir?: string;
|
|
24
|
+
readonly sessionId?: string;
|
|
25
|
+
readonly permission?: WorkflowPermissionMode;
|
|
26
|
+
}) => ReadonlyArray<string>;
|
|
27
|
+
export declare const runKimiWorkflowTask: (task: AnyWorkflowWorkerTask, options: KimiWorkflowWorkerOptions) => Promise<WorkflowTaskExecution>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AnyWorkflowWorkerTask, WorkflowPermissionMode, WorkflowSessionPersistence } from "./workflows.js";
|
|
2
|
+
import type { WorkflowTaskExecution, WorkflowTaskProgressReporter, WorkflowTaskRepairLoopOption } from "./workflow-runner.js";
|
|
3
|
+
export type OmpWorkflowWorkerOptions = {
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
readonly bin?: string;
|
|
6
|
+
readonly model?: string;
|
|
7
|
+
readonly provider?: string;
|
|
8
|
+
readonly profile?: string;
|
|
9
|
+
readonly effort?: string;
|
|
10
|
+
readonly sessionPersistence?: WorkflowSessionPersistence;
|
|
11
|
+
readonly resolvedPermission: WorkflowPermissionMode;
|
|
12
|
+
readonly restrictedTools?: readonly string[];
|
|
13
|
+
readonly abortSignal?: AbortSignal;
|
|
14
|
+
readonly reportProgress?: WorkflowTaskProgressReporter;
|
|
15
|
+
} & WorkflowTaskRepairLoopOption<"omp">;
|
|
16
|
+
export declare class OmpWorkflowWorkerError extends Error {
|
|
17
|
+
readonly name = "OmpWorkflowWorkerError";
|
|
18
|
+
readonly metadata?: Record<string, unknown>;
|
|
19
|
+
constructor(message: string, metadata?: Record<string, unknown>);
|
|
20
|
+
}
|
|
21
|
+
/** Console Go selectors 400 in workflow `--print` (no `x-opencode-session`). */
|
|
22
|
+
export declare const OMP_CONSOLE_GO_PREFIX = "opencode-go/";
|
|
23
|
+
export declare const ompConsoleGoPinError: (model: string) => string;
|
|
24
|
+
export declare const assertOmpWorkflowModel: (model: string | undefined) => void;
|
|
25
|
+
type OmpWorkflowSessionArgs = {
|
|
26
|
+
readonly sessionPersistence?: "persistent";
|
|
27
|
+
readonly sessionId?: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly sessionPersistence: "ephemeral";
|
|
30
|
+
readonly sessionId?: never;
|
|
31
|
+
};
|
|
32
|
+
export declare const buildOmpArgs: (input: {
|
|
33
|
+
readonly cwd: string;
|
|
34
|
+
readonly model?: string;
|
|
35
|
+
readonly provider?: string;
|
|
36
|
+
readonly profile?: string;
|
|
37
|
+
readonly effort?: string;
|
|
38
|
+
readonly prompt: string;
|
|
39
|
+
readonly permission?: WorkflowPermissionMode;
|
|
40
|
+
readonly restrictedTools?: readonly string[];
|
|
41
|
+
} & OmpWorkflowSessionArgs) => ReadonlyArray<string>;
|
|
42
|
+
export interface OmpJsonStreamResult {
|
|
43
|
+
readonly sessionId?: string;
|
|
44
|
+
readonly text: string;
|
|
45
|
+
readonly error?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const parseOmpJsonStream: (stdout: string) => OmpJsonStreamResult;
|
|
48
|
+
export declare const runOmpWorkflowTask: (task: AnyWorkflowWorkerTask, options: OmpWorkflowWorkerOptions) => Promise<WorkflowTaskExecution>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AnyWorkflowWorkerTask, WorkflowPermissionMode } from "./workflows.js";
|
|
2
|
+
import type { WorkflowTaskExecution, WorkflowTaskProgressReporter, WorkflowTaskRepairLoopOption } from "./workflow-runner.js";
|
|
3
|
+
export type OpenCodeWorkflowWorkerOptions = {
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
readonly bin?: string;
|
|
6
|
+
readonly model?: string;
|
|
7
|
+
readonly resolvedPermission: WorkflowPermissionMode;
|
|
8
|
+
readonly abortSignal?: AbortSignal;
|
|
9
|
+
readonly reportProgress?: WorkflowTaskProgressReporter;
|
|
10
|
+
} & WorkflowTaskRepairLoopOption<"opencode">;
|
|
11
|
+
export declare class OpenCodeWorkflowWorkerError extends Error {
|
|
12
|
+
readonly name = "OpenCodeWorkflowWorkerError";
|
|
13
|
+
readonly metadata?: Record<string, unknown>;
|
|
14
|
+
constructor(message: string, metadata?: Record<string, unknown>);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* OpenCode v2 `run` has no `--dir` (the process cwd is the project) and uses
|
|
18
|
+
* `--auto` instead of `--dangerously-skip-permissions`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const buildOpenCodeArgs: (input: {
|
|
21
|
+
readonly model?: string;
|
|
22
|
+
readonly prompt: string;
|
|
23
|
+
readonly sessionId?: string;
|
|
24
|
+
readonly permission?: WorkflowPermissionMode;
|
|
25
|
+
}) => ReadonlyArray<string>;
|
|
26
|
+
export declare const runOpenCodeWorkflowTask: (task: AnyWorkflowWorkerTask, options: OpenCodeWorkflowWorkerOptions) => Promise<WorkflowTaskExecution>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Schema } from "effect";
|
|
2
|
+
import { WorkflowOutputSchemaError, type JsonSchema as WorkflowJsonSchema } from "./ast-to-json-schema.js";
|
|
3
|
+
export { WorkflowOutputSchemaError };
|
|
4
|
+
export type { WorkflowJsonSchema };
|
|
5
|
+
export declare const workflowJsonSchemaFromEffectSchema: (schema: Schema.Top) => WorkflowJsonSchema;
|
|
6
|
+
export declare const tryWorkflowJsonSchemaFromEffectSchema: (schema: Schema.Top) => WorkflowJsonSchema | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WorkflowPermissionMode } from "./workflows.js";
|
|
2
|
+
export declare const WORKFLOW_PERMISSION_MODES: readonly ["legacy", "permissive", "restricted", "interactive", "sandbox-read-only", "sandbox-workspace-write", "full-access"];
|
|
3
|
+
export declare const isWorkflowPermissionMode: (value: string) => value is WorkflowPermissionMode;
|
|
4
|
+
export declare const assertNeverWorkflowPermissionMode: (worker: string, mode: never) => never;
|
|
5
|
+
export declare class WorkflowPermissionError extends Error {
|
|
6
|
+
readonly worker: string;
|
|
7
|
+
readonly mode: string;
|
|
8
|
+
readonly name = "WorkflowPermissionError";
|
|
9
|
+
constructor(worker: string, mode: string, message: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface WorkflowProcessGuardRequest {
|
|
2
|
+
readonly cwd: string;
|
|
3
|
+
readonly command: string;
|
|
4
|
+
readonly args: ReadonlyArray<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare class WorkflowProcessGuardError extends Error {
|
|
7
|
+
readonly name = "WorkflowProcessGuardError";
|
|
8
|
+
}
|
|
9
|
+
export declare const encodeWorkflowProcessGuardRequest: (request: WorkflowProcessGuardRequest) => ReadonlyArray<string>;
|
|
10
|
+
export declare const decodeWorkflowProcessGuardRequest: (encodedCwd: string, encodedCommand: string, encodedArgs: ReadonlyArray<string>) => WorkflowProcessGuardRequest;
|
|
11
|
+
export declare const workflowProcessGroupExists: (pid: number) => boolean;
|
|
12
|
+
export declare const waitForWorkflowProcessGroupAbsence: (pid: number, timeoutMs: number) => Promise<boolean>;
|
|
13
|
+
export interface WorkflowProcessGroupTerminationResult {
|
|
14
|
+
readonly escalated: boolean;
|
|
15
|
+
readonly alreadyAbsent: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface WorkflowProcessGroupTerminationOptions {
|
|
18
|
+
readonly termGraceMs?: number;
|
|
19
|
+
readonly killConfirmationMs?: number;
|
|
20
|
+
readonly onEscalated?: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const terminateWorkflowProcessGroup: (pid: number, options?: WorkflowProcessGroupTerminationOptions) => Promise<WorkflowProcessGroupTerminationResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Own a detached workload process group for exactly as long as the caller keeps
|
|
25
|
+
* this guard's stdin open. Every shutdown cause shares the same bounded group
|
|
26
|
+
* termination and direct-child reap operation.
|
|
27
|
+
*/
|
|
28
|
+
export declare const runWorkflowProcessGuard: (request: WorkflowProcessGuardRequest) => Promise<number>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type AnyWorkflowDefinition, type AnyWorkflowTask, type WorkflowRuntimeOptions } from "./workflows.js";
|
|
1
|
+
import { type AnyWorkflowDefinition, type AnyWorkflowTask, type AnyWorkflowWorkerTask, type WorkflowRuntimeOptions } from "./workflows.js";
|
|
2
|
+
import type { JevPublicConfig } from "./services/jev.js";
|
|
2
3
|
import type { WorkflowStore } from "./workflow-store.js";
|
|
3
4
|
import { type WorkflowRepairLoopContinuationWorkerId, type WorkflowStableSession } from "./workflow-session.js";
|
|
4
5
|
export interface WorkflowTaskExecution {
|
|
@@ -55,6 +56,12 @@ export type WorkflowTaskRepairLoopOption<Worker extends string> = Worker extends
|
|
|
55
56
|
readonly repair?: never;
|
|
56
57
|
};
|
|
57
58
|
export type WorkflowTaskExecutor = (task: AnyWorkflowTask, context?: WorkflowTaskExecutionContext) => Promise<unknown | WorkflowTaskExecution>;
|
|
59
|
+
/**
|
|
60
|
+
* The worker-shaped half of {@link WorkflowTaskExecutor}: worker adapters and
|
|
61
|
+
* the mock-output path only ever receive workflow worker tasks. Jev tasks are
|
|
62
|
+
* dispatched separately by kind (see workflow-executors.ts).
|
|
63
|
+
*/
|
|
64
|
+
export type WorkflowWorkerTaskExecutor = (task: AnyWorkflowWorkerTask, context?: WorkflowTaskExecutionContext) => Promise<unknown | WorkflowTaskExecution>;
|
|
58
65
|
/**
|
|
59
66
|
* Internal scheduler pacing, not a budget: excess live tasks queue and run as
|
|
60
67
|
* slots free, so this never fails a task. Sized to the machine because each
|
|
@@ -62,11 +69,18 @@ export type WorkflowTaskExecutor = (task: AnyWorkflowTask, context?: WorkflowTas
|
|
|
62
69
|
* about a workflow's intent belongs in this number.
|
|
63
70
|
*/
|
|
64
71
|
export declare const WORKFLOW_TASK_CONCURRENCY: number;
|
|
72
|
+
/**
|
|
73
|
+
* Jev tasks are one HTTP call (not a harness process), so they run on a
|
|
74
|
+
* separate, wider run-scoped limiter than worker tasks. Same semantics: queue,
|
|
75
|
+
* never fail.
|
|
76
|
+
*/
|
|
77
|
+
export declare const WORKFLOW_JEV_CONCURRENCY = 32;
|
|
65
78
|
export declare const runWorkflow: (workflow: AnyWorkflowDefinition, options: {
|
|
66
79
|
readonly executeTask: WorkflowTaskExecutor;
|
|
67
80
|
readonly store?: WorkflowStore;
|
|
68
81
|
readonly mockOutput?: boolean;
|
|
69
82
|
readonly runId?: string;
|
|
70
83
|
readonly runtimeOptions?: WorkflowRuntimeOptions;
|
|
84
|
+
readonly jev?: JevPublicConfig;
|
|
71
85
|
readonly abortSignal?: AbortSignal;
|
|
72
86
|
}) => Promise<WorkflowRunResult>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect's `Cron` module, narrowed to Prism's scheduling dialect.
|
|
3
|
+
*
|
|
4
|
+
* Prism ships no cron parser. `effect`'s `Cron` already implements the
|
|
5
|
+
* five-field dialect Prism documents — names, ranges, steps, lists, Vixie
|
|
6
|
+
* DOM/DOW OR semantics, named timezones, and DST resolution — and it is
|
|
7
|
+
* already a Prism-owned dependency pinned to one exact release by
|
|
8
|
+
* `scripts/effect-version-guard.ts`. Re-deriving a parser here would be a
|
|
9
|
+
* second implementation of the same contract, which AGENTS.md rule 3 forbids.
|
|
10
|
+
*
|
|
11
|
+
* This module is the adapter that *pins the dialect Prism accepts*, so the
|
|
12
|
+
* accepted language lives in one place instead of being whatever the
|
|
13
|
+
* dependency happens to accept today. Two deliberate narrowings, both
|
|
14
|
+
* fail-closed:
|
|
15
|
+
*
|
|
16
|
+
* - **Exactly five fields.** `Cron.parse` also accepts a six-field,
|
|
17
|
+
* seconds-first form. A six-field expression is rejected so an expression
|
|
18
|
+
* copied from a seconds-capable scheduler cannot silently mean something
|
|
19
|
+
* else than it reads.
|
|
20
|
+
* - **Named timezones only.** `Cron.parse` accepts fixed offsets such as
|
|
21
|
+
* `+03:00`. A fixed offset is not DST-aware, so a schedule declared with
|
|
22
|
+
* one drifts by an hour at a transition. A named IANA zone — including the
|
|
23
|
+
* DST-free `Etc/GMT+3` — is required.
|
|
24
|
+
*
|
|
25
|
+
* DST policy is inherited from `effect`'s `Cron` and pinned by `cron.test.ts`:
|
|
26
|
+
* a wall-clock time inside a spring-forward gap resolves to the first valid
|
|
27
|
+
* instant after the gap, and a time inside a fall-back fold resolves to the
|
|
28
|
+
* **first** of the two occurrences. That is a documented policy, not an
|
|
29
|
+
* accident of the dependency, so the tests assert it rather than assume it.
|
|
30
|
+
*
|
|
31
|
+
* Only `next` is exposed. Prism never asks "what was the previous occurrence?"
|
|
32
|
+
* because the durable cursor is the schedule row's `next_due_at` — see
|
|
33
|
+
* `docs/workflow-scheduling.md`. `Cron.prev` is also subtly exclusive at exact
|
|
34
|
+
* minute boundaries, which makes it the wrong primitive for "the occurrence
|
|
35
|
+
* that is due now".
|
|
36
|
+
*/
|
|
37
|
+
import { Cron } from "effect";
|
|
38
|
+
/** The field count Prism accepts. Six-field (seconds-first) expressions are rejected. */
|
|
39
|
+
export declare const WORKFLOW_CRON_FIELD_COUNT = 5;
|
|
40
|
+
export interface ParsedWorkflowCron {
|
|
41
|
+
readonly expression: string;
|
|
42
|
+
readonly timezone: string;
|
|
43
|
+
/** The parsed `effect` `Cron`, ready for `Cron.next`. */
|
|
44
|
+
readonly cron: Cron.Cron;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Validate a cron expression + timezone pair, returning the parsed schedule.
|
|
48
|
+
*
|
|
49
|
+
* Throws `WorkflowScheduleError` — never a bare string or a dependency's error
|
|
50
|
+
* type — so every rejection carries the field, a headline, and the exact fix.
|
|
51
|
+
*/
|
|
52
|
+
export declare const parseWorkflowCron: (expression: string, timezone: string) => ParsedWorkflowCron;
|
|
53
|
+
/**
|
|
54
|
+
* The first occurrence strictly after `afterMs`.
|
|
55
|
+
*
|
|
56
|
+
* `Cron.next` is exclusive of its argument, which is what the tick algorithm
|
|
57
|
+
* needs: advancing the cursor from a consumed occurrence must never re-yield
|
|
58
|
+
* that same occurrence.
|
|
59
|
+
*/
|
|
60
|
+
export declare const nextWorkflowCronOccurrence: (schedule: ParsedWorkflowCron, afterMs: number) => number;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scheduler error vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* These are `Schema.TaggedError`s rather than plain `Error`s for two reasons:
|
|
5
|
+
* every one of them is both a typed Effect failure *and* a durable record (a
|
|
6
|
+
* scheduler event, an execution's `cause_json`), and `message` is an explicit
|
|
7
|
+
* schema field so the rendered headline survives a round trip through SQLite.
|
|
8
|
+
* `Schema.TaggedError`'s optional third-argument message function is not used
|
|
9
|
+
* because it does not take effect in this Effect release; carrying `message`
|
|
10
|
+
* as a field keeps the rendered text identical before and after persistence.
|
|
11
|
+
*
|
|
12
|
+
* `hint` is required, never optional: AGENTS.md rule 6 forbids warnings, so a
|
|
13
|
+
* failure that cannot name its own remediation does not belong here.
|
|
14
|
+
*/
|
|
15
|
+
import { Schema } from "effect";
|
|
16
|
+
declare const WorkflowScheduleError_base: Schema.Class<WorkflowScheduleError, Schema.TaggedStruct<"WorkflowScheduleError", {
|
|
17
|
+
readonly message: Schema.String;
|
|
18
|
+
readonly field: Schema.String;
|
|
19
|
+
readonly hint: Schema.String;
|
|
20
|
+
}>, import("effect/Cause").YieldableError>;
|
|
21
|
+
/** A declared schedule that Prism cannot accept. `field` is the offending key. */
|
|
22
|
+
export declare class WorkflowScheduleError extends WorkflowScheduleError_base {
|
|
23
|
+
}
|
|
24
|
+
declare const WorkflowScheduleInstallError_base: Schema.Class<WorkflowScheduleInstallError, Schema.TaggedStruct<"WorkflowScheduleInstallError", {
|
|
25
|
+
readonly message: Schema.String;
|
|
26
|
+
readonly hint: Schema.String;
|
|
27
|
+
}>, import("effect/Cause").YieldableError>;
|
|
28
|
+
/** A schedule installation or lifecycle operation Prism refuses to perform. */
|
|
29
|
+
export declare class WorkflowScheduleInstallError extends WorkflowScheduleInstallError_base {
|
|
30
|
+
}
|
|
31
|
+
declare const SchedulerStoreError_base: Schema.Class<SchedulerStoreError, Schema.TaggedStruct<"SchedulerStoreError", {
|
|
32
|
+
readonly message: Schema.String;
|
|
33
|
+
readonly hint: Schema.String;
|
|
34
|
+
readonly path: Schema.String;
|
|
35
|
+
}>, import("effect/Cause").YieldableError>;
|
|
36
|
+
/** The scheduler store could not be opened, migrated, or read as expected. */
|
|
37
|
+
export declare class SchedulerStoreError extends SchedulerStoreError_base {
|
|
38
|
+
}
|
|
39
|
+
declare const SchedulerAlreadyRunningError_base: Schema.Class<SchedulerAlreadyRunningError, Schema.TaggedStruct<"SchedulerAlreadyRunningError", {
|
|
40
|
+
readonly message: Schema.String;
|
|
41
|
+
readonly hint: Schema.String;
|
|
42
|
+
readonly holderInstanceId: Schema.NullOr<Schema.String>;
|
|
43
|
+
readonly holderPid: Schema.NullOr<Schema.Number>;
|
|
44
|
+
}>, import("effect/Cause").YieldableError>;
|
|
45
|
+
/** Another scheduler instance holds the machine-wide instance lock. */
|
|
46
|
+
export declare class SchedulerAlreadyRunningError extends SchedulerAlreadyRunningError_base {
|
|
47
|
+
}
|
|
48
|
+
declare const SchedulerLaunchError_base: Schema.Class<SchedulerLaunchError, Schema.TaggedStruct<"SchedulerLaunchError", {
|
|
49
|
+
readonly message: Schema.String;
|
|
50
|
+
readonly hint: Schema.String;
|
|
51
|
+
readonly executionId: Schema.String;
|
|
52
|
+
}>, import("effect/Cause").YieldableError>;
|
|
53
|
+
/** A worker process could not be launched, or its launch could not be authorized. */
|
|
54
|
+
export declare class SchedulerLaunchError extends SchedulerLaunchError_base {
|
|
55
|
+
}
|
|
56
|
+
declare const SchedulerFatalError_base: Schema.Class<SchedulerFatalError, Schema.TaggedStruct<"SchedulerFatalError", {
|
|
57
|
+
readonly message: Schema.String;
|
|
58
|
+
readonly hint: Schema.String;
|
|
59
|
+
}>, import("effect/Cause").YieldableError>;
|
|
60
|
+
/**
|
|
61
|
+
* The scheduler loop itself hit an unrecoverable defect. The owner's contract
|
|
62
|
+
* is explicit that a scheduler defect must surface and end the process so the
|
|
63
|
+
* service manager restarts it — never be swallowed into an endlessly
|
|
64
|
+
* "healthy"-looking loop.
|
|
65
|
+
*/
|
|
66
|
+
export declare class SchedulerFatalError extends SchedulerFatalError_base {
|
|
67
|
+
}
|
|
68
|
+
export type SchedulerError = WorkflowScheduleError | WorkflowScheduleInstallError | SchedulerStoreError | SchedulerAlreadyRunningError | SchedulerLaunchError | SchedulerFatalError;
|
|
69
|
+
/** One-line headline plus a `hint:` line — the repo's human error shape. */
|
|
70
|
+
export declare const renderSchedulerError: (error: SchedulerError) => string;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inert `schedule` declaration on a workflow definition.
|
|
3
|
+
*
|
|
4
|
+
* A workflow may declare how it wants to be scheduled; declaring it does
|
|
5
|
+
* nothing. `defineWorkflow` records the policy on the definition object and
|
|
6
|
+
* no more — importing, typechecking, validating, or running the file has no
|
|
7
|
+
* scheduling side effect whatsoever. Registration happens only through
|
|
8
|
+
* `prism workflow schedule install`, which reads the declaration back out of
|
|
9
|
+
* the loaded definition. This split is what makes `install` the single
|
|
10
|
+
* activation gate, and it is why a schedule edit requires a reinstall while a
|
|
11
|
+
* task/prompt edit does not.
|
|
12
|
+
*
|
|
13
|
+
* **Only implemented policies are representable.** `overlap` and `missedRuns`
|
|
14
|
+
* each admit exactly one value, so `overlap: "queue"` is a TypeScript error at
|
|
15
|
+
* authoring time and a hard, self-explaining `WorkflowScheduleError` at the
|
|
16
|
+
* cross-version boundary. AGENTS.md rule 6 forbids warnings, and rule 8 says a
|
|
17
|
+
* type that needs a runtime membership check is lying — so the unions stay
|
|
18
|
+
* closed rather than admitting a policy Prism does not implement.
|
|
19
|
+
*
|
|
20
|
+
* The two policies, stated precisely, because both names are easy to misread:
|
|
21
|
+
*
|
|
22
|
+
* - `overlap: "skip"` — at most one unresolved execution per schedule. A due
|
|
23
|
+
* occurrence that arrives while the previous execution is still running,
|
|
24
|
+
* still reserving, or still *uncertain* is consumed as a skip and
|
|
25
|
+
* recorded; it is never queued and never run in parallel. A stranded
|
|
26
|
+
* execution cannot be cleared by a timeout, only by evidence.
|
|
27
|
+
* - `missedRuns: "skip"` — overdue occurrences are coalesced into at most one
|
|
28
|
+
* opportunity. A machine asleep for three hours produces one run on wake, not
|
|
29
|
+
* eighteen, and a scheduler restart behaves the same way rather than silently
|
|
30
|
+
* swallowing an occurrence. Nothing accumulates: the cursor advances whether
|
|
31
|
+
* or not the run succeeds, so a crash-loop fires at most once per occurrence.
|
|
32
|
+
*/
|
|
33
|
+
/** Policies Prism implements for a due occurrence that overlaps a live execution. */
|
|
34
|
+
export declare const WORKFLOW_SCHEDULE_OVERLAP_POLICIES: readonly ["skip"];
|
|
35
|
+
export type WorkflowScheduleOverlap = (typeof WORKFLOW_SCHEDULE_OVERLAP_POLICIES)[number];
|
|
36
|
+
/** Policies Prism implements for occurrences that passed while nothing was watching. */
|
|
37
|
+
export declare const WORKFLOW_SCHEDULE_MISSED_RUN_POLICIES: readonly ["skip"];
|
|
38
|
+
export type WorkflowScheduleMissedRuns = (typeof WORKFLOW_SCHEDULE_MISSED_RUN_POLICIES)[number];
|
|
39
|
+
export interface WorkflowSchedule {
|
|
40
|
+
/** Five-field cron: `minute hour day-of-month month day-of-week`. */
|
|
41
|
+
readonly cron: string;
|
|
42
|
+
/** A named IANA timezone. Fixed UTC offsets are rejected; see `cron.ts`. */
|
|
43
|
+
readonly timezone: string;
|
|
44
|
+
readonly overlap: WorkflowScheduleOverlap;
|
|
45
|
+
readonly missedRuns: WorkflowScheduleMissedRuns;
|
|
46
|
+
}
|
|
47
|
+
/** The complete key set. An unrecognized key is an error, not an ignored field. */
|
|
48
|
+
export declare const WORKFLOW_SCHEDULE_KEYS: ReadonlyArray<keyof WorkflowSchedule>;
|
|
49
|
+
/**
|
|
50
|
+
* Validate an already-loaded `schedule` value and return it typed.
|
|
51
|
+
*
|
|
52
|
+
* Used twice on purpose: `defineWorkflow` calls it so an authoring mistake
|
|
53
|
+
* fails at import with the file in front of the author, and
|
|
54
|
+
* `prism workflow schedule install` calls it again because an installed
|
|
55
|
+
* schedule is data that crossed a boundary (a hand-written object, or a
|
|
56
|
+
* definition produced by a different Prism version) and must not be trusted
|
|
57
|
+
* just because some other layer once checked it.
|
|
58
|
+
*/
|
|
59
|
+
export declare const parseWorkflowSchedule: (value: unknown) => WorkflowSchedule;
|
|
60
|
+
/** Non-throwing form for the `isWorkflowDefinition` type guard. */
|
|
61
|
+
export declare const isWorkflowSchedule: (value: unknown) => value is WorkflowSchedule;
|