@swirls/looms 0.4.0 → 0.5.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/CHANGELOG.md +61 -0
- package/dist/actor/cell.d.ts +21 -2
- package/dist/actor/cell.js +15 -3
- package/dist/actor/host.d.ts +10 -2
- package/dist/actor/host.js +27 -4
- package/dist/actor/index.d.ts +2 -1
- package/dist/actor/index.js +1 -1
- package/dist/actor/routing.d.ts +3 -0
- package/dist/actor/routing.js +13 -2
- package/dist/agent/definitions-store.d.ts +1 -1
- package/dist/agent/definitions-store.js +1 -1
- package/dist/agent/definitions.d.ts +48 -0
- package/dist/agent/definitions.js +44 -0
- package/dist/agent/effects.d.ts +184 -0
- package/dist/agent/effects.js +172 -40
- package/dist/agent/events.d.ts +89 -0
- package/dist/agent/events.js +25 -0
- package/dist/agent/module.d.ts +412 -0
- package/dist/agent/module.js +5 -1
- package/dist/agent/scope.d.ts +88 -0
- package/dist/agent/threads.js +39 -3
- package/dist/agent/types.d.ts +4 -0
- package/dist/approval/effects.d.ts +40 -0
- package/dist/approval/module.d.ts +80 -0
- package/dist/client/client.d.ts +468 -119
- package/dist/client/client.js +214 -21
- package/dist/client/index.d.ts +1 -1
- package/dist/client/sse.d.ts +1 -1
- package/dist/client/sse.js +2 -2
- package/dist/cloudflare/durable-object.d.ts +66 -2
- package/dist/cloudflare/durable-object.js +96 -1
- package/dist/cloudflare/event-store.d.ts +7 -3
- package/dist/cloudflare/event-store.js +16 -3
- package/dist/cloudflare/index.d.ts +7 -1
- package/dist/cloudflare/index.js +7 -1
- package/dist/cloudflare/memory-queue.d.ts +18 -0
- package/dist/cloudflare/memory-queue.js +53 -0
- package/dist/cloudflare/queue-consumer.d.ts +52 -0
- package/dist/cloudflare/queue-consumer.js +102 -0
- package/dist/cloudflare/queue-message.d.ts +31 -0
- package/dist/cloudflare/queue-message.js +33 -0
- package/dist/cloudflare/queue-pull.d.ts +62 -0
- package/dist/cloudflare/queue-pull.js +130 -0
- package/dist/cloudflare/queue-worker.d.ts +39 -0
- package/dist/cloudflare/queue-worker.js +62 -0
- package/dist/cloudflare/queues.d.ts +10 -0
- package/dist/cloudflare/queues.js +10 -0
- package/dist/cloudflare/r2-blob-store.d.ts +33 -0
- package/dist/cloudflare/r2-blob-store.js +60 -0
- package/dist/cloudflare/router.d.ts +4 -1
- package/dist/cloudflare/router.js +8 -3
- package/dist/cloudflare/websocket.d.ts +27 -0
- package/dist/cloudflare/websocket.js +215 -0
- package/dist/core/blob-offload.d.ts +21 -0
- package/dist/core/blob-offload.js +143 -0
- package/dist/core/blob-store.d.ts +45 -0
- package/dist/core/blob-store.js +164 -0
- package/dist/core/blobs.d.ts +37 -0
- package/dist/core/blobs.js +160 -0
- package/dist/core/definition-resolver.d.ts +40 -0
- package/dist/core/definition-resolver.js +129 -0
- package/dist/core/definition-store.d.ts +6 -0
- package/dist/core/definition-store.js +37 -1
- package/dist/core/effects.d.ts +86 -3
- package/dist/core/effects.js +99 -3
- package/dist/core/envelope.d.ts +9 -0
- package/dist/core/envelope.js +4 -0
- package/dist/core/event-codec.js +3 -0
- package/dist/core/fold.js +83 -1
- package/dist/core/ids.d.ts +2 -0
- package/dist/core/ids.js +4 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +8 -0
- package/dist/core/launcher.d.ts +97 -0
- package/dist/core/launcher.js +67 -0
- package/dist/core/module-scope.d.ts +7 -3
- package/dist/core/module-scope.js +3 -0
- package/dist/core/module.d.ts +10 -0
- package/dist/core/projection.js +4 -0
- package/dist/core/protocol.d.ts +36 -1
- package/dist/core/protocol.js +35 -0
- package/dist/core/published.d.ts +2 -0
- package/dist/core/published.js +4 -1
- package/dist/core/replay.d.ts +96 -0
- package/dist/core/run-context.d.ts +33 -0
- package/dist/core/run-context.js +23 -0
- package/dist/core/sqlite-store.js +57 -5
- package/dist/core/state.d.ts +60 -0
- package/dist/core/state.js +19 -0
- package/dist/core/store.d.ts +6 -0
- package/dist/core/store.js +7 -0
- package/dist/core/subscription.d.ts +97 -0
- package/dist/core/subscription.js +224 -0
- package/dist/core/thread.d.ts +7 -0
- package/dist/core/thread.js +1 -0
- package/dist/core/trace.d.ts +21 -0
- package/dist/core/trace.js +45 -0
- package/dist/core/worker-callback.d.ts +25 -1
- package/dist/debugger/app/assets/{index-CgDzWJg7.css → index-B7GdT1UA.css} +1 -1
- package/dist/debugger/app/assets/index-C31SnCuN.js +22 -0
- package/dist/debugger/app/assets/routes-DPA3O5AF.js +47 -0
- package/dist/debugger/app/index.html +2 -2
- package/dist/debugger/components/event-inspector.d.ts +3 -1
- package/dist/debugger/components/event-inspector.js +25 -4
- package/dist/debugger/components/event-stream.d.ts +4 -1
- package/dist/debugger/components/event-stream.js +2 -2
- package/dist/debugger/components/run-tree.d.ts +5 -2
- package/dist/debugger/components/run-tree.js +10 -4
- package/dist/debugger/context.d.ts +8 -1
- package/dist/debugger/context.js +15 -3
- package/dist/debugger/events/protocol-summarize.js +18 -3
- package/dist/debugger/index.d.ts +1 -1
- package/dist/debugger/index.js +1 -1
- package/dist/debugger/shell/debugger-shell.js +1 -1
- package/dist/debugger/shell/events-pane.js +4 -3
- package/dist/debugger/styles.css +1 -0
- package/dist/evaluator/definitions-store.d.ts +3 -4
- package/dist/evaluator/definitions-store.js +3 -3
- package/dist/evaluator/definitions.d.ts +4 -1
- package/dist/evaluator/definitions.js +5 -2
- package/dist/evaluator/effects.d.ts +41 -0
- package/dist/evaluator/effects.js +6 -2
- package/dist/evaluator/module.d.ts +84 -0
- package/dist/evaluator/module.js +7 -3
- package/dist/evaluator/threads.d.ts +2 -0
- package/dist/evaluator/threads.js +4 -0
- package/dist/projectors/event-log.d.ts +87 -0
- package/dist/projectors/event-log.js +396 -0
- package/dist/projectors/index-model.d.ts +12 -0
- package/dist/projectors/index-model.js +12 -3
- package/dist/projectors/memory.js +7 -0
- package/dist/projectors/postgres.d.ts +1 -0
- package/dist/projectors/postgres.js +32 -15
- package/dist/projectors/schema.d.ts +5 -0
- package/dist/projectors/schema.js +26 -1
- package/dist/projectors/sqlite.js +47 -19
- package/dist/projectors/with-projectors.d.ts +7 -1
- package/dist/projectors/with-projectors.js +13 -3
- package/dist/react/materialize.js +5 -1
- package/dist/react/react.d.ts +10 -2
- package/dist/react/react.js +43 -19
- package/dist/react/store.d.ts +11 -2
- package/dist/react/store.js +104 -12
- package/dist/react/tables.d.ts +4 -1
- package/dist/runtime/cancellation.d.ts +2 -1
- package/dist/runtime/cancellation.js +35 -2
- package/dist/runtime/child-run.d.ts +10 -0
- package/dist/runtime/child-run.js +58 -0
- package/dist/runtime/deadline-transition-planner.js +11 -2
- package/dist/runtime/dispatch-effect.d.ts +2 -2
- package/dist/runtime/dispatch-effect.js +43 -19
- package/dist/runtime/errors.d.ts +14 -1
- package/dist/runtime/errors.js +10 -0
- package/dist/runtime/filesystem-blob-store.d.ts +6 -0
- package/dist/runtime/filesystem-blob-store.js +59 -0
- package/dist/runtime/helpers.d.ts +15 -6
- package/dist/runtime/helpers.js +46 -6
- package/dist/runtime/index.d.ts +4 -2
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/local-effect-executor.d.ts +11 -2
- package/dist/runtime/local-effect-executor.js +80 -4
- package/dist/runtime/looms.d.ts +38 -4
- package/dist/runtime/looms.js +17 -3
- package/dist/runtime/repository.d.ts +5 -4
- package/dist/runtime/repository.js +5 -2
- package/dist/runtime/retry-policy.d.ts +5 -0
- package/dist/runtime/retry-policy.js +10 -2
- package/dist/runtime/run-start.d.ts +1 -1
- package/dist/runtime/run-start.js +10 -0
- package/dist/runtime/runtime.d.ts +2 -2
- package/dist/runtime/runtime.js +191 -68
- package/dist/runtime/server/auth.d.ts +3 -0
- package/dist/runtime/server/fetch-handler.d.ts +2 -2
- package/dist/runtime/server/fetch-handler.js +35 -4
- package/dist/runtime/server/grant.d.ts +49 -0
- package/dist/runtime/server/grant.js +177 -0
- package/dist/runtime/server/routes/effects.js +47 -5
- package/dist/runtime/server/routes/runs.js +6 -1
- package/dist/runtime/server/run-route.d.ts +18 -0
- package/dist/runtime/server/run-route.js +26 -0
- package/dist/runtime/server.d.ts +3 -1
- package/dist/runtime/server.js +3 -1
- package/dist/runtime/sse.js +26 -4
- package/dist/runtime/subscription.d.ts +8 -0
- package/dist/runtime/subscription.js +23 -0
- package/dist/runtime/types.d.ts +87 -8
- package/dist/runtime/wake-engine.d.ts +4 -2
- package/dist/runtime/wake-engine.js +57 -6
- package/dist/runtime/worker-callbacks.d.ts +12 -2
- package/dist/runtime/worker-callbacks.js +102 -72
- package/dist/runtime/worker-effect-dispatch.d.ts +14 -5
- package/dist/runtime/worker-effect-dispatch.js +84 -18
- package/dist/schedule/debugger/index.d.ts +4 -0
- package/dist/schedule/debugger/index.js +11 -0
- package/dist/schedule/debugger/schedule-view.d.ts +3 -0
- package/dist/schedule/debugger/schedule-view.js +68 -0
- package/dist/schedule/debugger/summarize.d.ts +2 -0
- package/dist/schedule/debugger/summarize.js +43 -0
- package/dist/schedule/definitions-store.d.ts +10 -0
- package/dist/schedule/definitions-store.js +8 -0
- package/dist/schedule/definitions.d.ts +57 -0
- package/dist/schedule/definitions.js +30 -0
- package/dist/schedule/effects.d.ts +756 -0
- package/dist/schedule/effects.js +244 -0
- package/dist/schedule/ensure.d.ts +55 -0
- package/dist/schedule/ensure.js +109 -0
- package/dist/schedule/events.d.ts +116 -0
- package/dist/schedule/events.js +49 -0
- package/dist/schedule/index.d.ts +11 -0
- package/dist/schedule/index.js +11 -0
- package/dist/schedule/module.d.ts +1474 -0
- package/dist/schedule/module.js +22 -0
- package/dist/schedule/projections.d.ts +55 -0
- package/dist/schedule/projections.js +88 -0
- package/dist/schedule/scope.d.ts +121 -0
- package/dist/schedule/scope.js +7 -0
- package/dist/schedule/signals.d.ts +25 -0
- package/dist/schedule/signals.js +33 -0
- package/dist/schedule/specs.d.ts +59 -0
- package/dist/schedule/specs.js +231 -0
- package/dist/schedule/threads.d.ts +25 -0
- package/dist/schedule/threads.js +259 -0
- package/dist/testing/corpus-module.d.ts +34 -0
- package/dist/testing/corpus-module.js +87 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +5 -6
- package/dist/testing/replay-corpus.d.ts +22 -0
- package/dist/testing/replay-corpus.js +50 -0
- package/dist/workflow/definitions-store.d.ts +1 -1
- package/dist/workflow/definitions-store.js +1 -1
- package/dist/workflow/definitions.d.ts +14 -0
- package/dist/workflow/effects.d.ts +122 -0
- package/dist/workflow/effects.js +16 -6
- package/dist/workflow/events.d.ts +42 -0
- package/dist/workflow/events.js +4 -0
- package/dist/workflow/module.d.ts +313 -0
- package/dist/workflow/module.js +7 -3
- package/dist/workflow/scope.d.ts +42 -0
- package/dist/workflow/threads.d.ts +72 -0
- package/dist/workflow/threads.js +106 -38
- package/package.json +14 -1
- package/dist/debugger/app/assets/index-D--9esm9.js +0 -22
- package/dist/debugger/app/assets/routes-Dakrdusf.js +0 -47
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Context, Effect, Schema } from 'effect';
|
|
2
|
+
import type { EventInput } from './envelope';
|
|
3
|
+
import type { RunAttributes, SecretContext } from './run-context';
|
|
4
|
+
import type { TraceContext } from './trace';
|
|
5
|
+
import type { JsonValue, RunStatus } from './types';
|
|
6
|
+
export declare const ChildCloseSchema: Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>;
|
|
7
|
+
export type ChildClose = Schema.Schema.Type<typeof ChildCloseSchema>;
|
|
8
|
+
/** The effect that launched a run, recorded on the launched run's `runtime.run.started`. */
|
|
9
|
+
export declare const RunLaunchSourceSchema: Schema.Struct<{
|
|
10
|
+
readonly runId: Schema.String;
|
|
11
|
+
readonly threadId: Schema.String;
|
|
12
|
+
readonly effectId: Schema.String;
|
|
13
|
+
/** The event in `runId` that requested the launching effect. */
|
|
14
|
+
readonly causationId: Schema.String;
|
|
15
|
+
readonly causationSeq: Schema.Finite;
|
|
16
|
+
}>;
|
|
17
|
+
export type RunLaunchSource = Schema.Schema.Type<typeof RunLaunchSourceSchema>;
|
|
18
|
+
export declare function readRunLaunchSource(value: JsonValue | undefined): RunLaunchSource | null;
|
|
19
|
+
/** Arguments for starting a run without waiting for it to finish. */
|
|
20
|
+
export interface LaunchRunArgs {
|
|
21
|
+
readonly runId?: string;
|
|
22
|
+
readonly kind: string;
|
|
23
|
+
readonly definitionName: string;
|
|
24
|
+
readonly definitionVersion?: string;
|
|
25
|
+
readonly input?: JsonValue;
|
|
26
|
+
readonly threadId?: string;
|
|
27
|
+
readonly idempotencyKey?: string;
|
|
28
|
+
/** Set by the runtime when an effect launches. A value passed by the effect is replaced. */
|
|
29
|
+
readonly launchedBy?: RunLaunchSource;
|
|
30
|
+
/**
|
|
31
|
+
* Groups runs launched from the same root run. The runtime sets it to the launching run's
|
|
32
|
+
* correlation id, or to the launching run's id when that run has none.
|
|
33
|
+
*/
|
|
34
|
+
readonly correlationId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* What the launching run does with this child when the launching run closes.
|
|
37
|
+
* `terminate` cancels the child. `wait` lets the child finish cancelling first.
|
|
38
|
+
*/
|
|
39
|
+
readonly close?: ChildClose;
|
|
40
|
+
readonly attributes?: RunAttributes;
|
|
41
|
+
readonly secrets?: SecretContext;
|
|
42
|
+
/** Defaults to the launching run's trace context. */
|
|
43
|
+
readonly trace?: TraceContext;
|
|
44
|
+
}
|
|
45
|
+
/** Enough of a run to decide whether a previous fire is still in progress. */
|
|
46
|
+
export interface RunStatusSnapshot {
|
|
47
|
+
readonly status: RunStatus;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Starts runs and reads their status from inside an effect. A single-store host launches into its
|
|
51
|
+
* own runtime. An actor host launches into the cell that owns `runId`.
|
|
52
|
+
*/
|
|
53
|
+
export interface RunLauncher {
|
|
54
|
+
readonly launch: (args: LaunchRunArgs) => Effect.Effect<void, Error>;
|
|
55
|
+
readonly status: (runId: string) => Effect.Effect<RunStatusSnapshot | null, Error>;
|
|
56
|
+
/**
|
|
57
|
+
* Append events to a run and wake it. When that run is already waking, the wake coalesces
|
|
58
|
+
* instead of waiting, so a child can notify its parent from inside the parent's wake.
|
|
59
|
+
*/
|
|
60
|
+
readonly signal: (runId: string, events: readonly EventInput[], options?: {
|
|
61
|
+
readonly idempotencyKey?: string;
|
|
62
|
+
}) => Effect.Effect<void, Error>;
|
|
63
|
+
readonly cancel: (runId: string) => Effect.Effect<void, Error>;
|
|
64
|
+
}
|
|
65
|
+
declare const RunLauncherTag_base: Context.ServiceClass<RunLauncherTag, "looms/RunLauncher", RunLauncher>;
|
|
66
|
+
export declare class RunLauncherTag extends RunLauncherTag_base {
|
|
67
|
+
}
|
|
68
|
+
declare const RunLauncherError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
69
|
+
readonly _tag: "RunLauncherError";
|
|
70
|
+
} & Readonly<A>;
|
|
71
|
+
export declare class RunLauncherError extends RunLauncherError_base<{
|
|
72
|
+
readonly message: string;
|
|
73
|
+
readonly cause?: unknown;
|
|
74
|
+
}> {
|
|
75
|
+
}
|
|
76
|
+
export declare function runLauncherError(cause: unknown): RunLauncherError;
|
|
77
|
+
declare const RunLauncherUnavailableError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
78
|
+
readonly _tag: "RunLauncherUnavailableError";
|
|
79
|
+
} & Readonly<A>;
|
|
80
|
+
export declare class RunLauncherUnavailableError extends RunLauncherUnavailableError_base<{
|
|
81
|
+
readonly message: string;
|
|
82
|
+
}> {
|
|
83
|
+
constructor();
|
|
84
|
+
}
|
|
85
|
+
/** Fails both operations. Actor cells and Durable Objects use this unless a launcher is configured. */
|
|
86
|
+
export declare const unavailableRunLauncher: RunLauncher;
|
|
87
|
+
/** Adapts a per-`runId` RPC or cell lookup into a `RunLauncher`. */
|
|
88
|
+
export declare function createRemoteRunLauncher(target: {
|
|
89
|
+
readonly launch: (runId: string, args: LaunchRunArgs) => Promise<void>;
|
|
90
|
+
readonly status: (runId: string) => Promise<RunStatusSnapshot | null>;
|
|
91
|
+
readonly accept: (runId: string, events: readonly EventInput[], options?: {
|
|
92
|
+
readonly idempotencyKey?: string;
|
|
93
|
+
readonly coalesce?: boolean;
|
|
94
|
+
}) => Promise<void>;
|
|
95
|
+
readonly cancel: (runId: string) => Promise<void>;
|
|
96
|
+
}): RunLauncher;
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Context, Data, Effect, Option, Schema } from 'effect';
|
|
2
|
+
export const ChildCloseSchema = Schema.Union([Schema.Literal('terminate'), Schema.Literal('wait')]);
|
|
3
|
+
/** The effect that launched a run, recorded on the launched run's `runtime.run.started`. */
|
|
4
|
+
export const RunLaunchSourceSchema = Schema.Struct({
|
|
5
|
+
runId: Schema.String,
|
|
6
|
+
threadId: Schema.String,
|
|
7
|
+
effectId: Schema.String,
|
|
8
|
+
/** The event in `runId` that requested the launching effect. */
|
|
9
|
+
causationId: Schema.String,
|
|
10
|
+
causationSeq: Schema.Finite,
|
|
11
|
+
});
|
|
12
|
+
const decodeRunLaunchSource = Schema.decodeUnknownOption(RunLaunchSourceSchema);
|
|
13
|
+
export function readRunLaunchSource(value) {
|
|
14
|
+
return value === undefined ? null : Option.getOrNull(decodeRunLaunchSource(value));
|
|
15
|
+
}
|
|
16
|
+
export class RunLauncherTag extends Context.Service()('looms/RunLauncher') {
|
|
17
|
+
}
|
|
18
|
+
export class RunLauncherError extends Data.TaggedError('RunLauncherError') {
|
|
19
|
+
}
|
|
20
|
+
export function runLauncherError(cause) {
|
|
21
|
+
return new RunLauncherError({
|
|
22
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
23
|
+
cause,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export class RunLauncherUnavailableError extends Data.TaggedError('RunLauncherUnavailableError') {
|
|
27
|
+
constructor() {
|
|
28
|
+
super({
|
|
29
|
+
message: 'No RunLauncher is configured. Pass launcher when hosting schedules in an actor cell or Durable Object.',
|
|
30
|
+
});
|
|
31
|
+
this.name = 'RunLauncherUnavailableError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Fails both operations. Actor cells and Durable Objects use this unless a launcher is configured. */
|
|
35
|
+
export const unavailableRunLauncher = {
|
|
36
|
+
launch: () => Effect.fail(new RunLauncherUnavailableError()),
|
|
37
|
+
status: () => Effect.fail(new RunLauncherUnavailableError()),
|
|
38
|
+
signal: () => Effect.fail(new RunLauncherUnavailableError()),
|
|
39
|
+
cancel: () => Effect.fail(new RunLauncherUnavailableError()),
|
|
40
|
+
};
|
|
41
|
+
/** Adapts a per-`runId` RPC or cell lookup into a `RunLauncher`. */
|
|
42
|
+
export function createRemoteRunLauncher(target) {
|
|
43
|
+
return {
|
|
44
|
+
launch: (args) => {
|
|
45
|
+
const runId = args.runId;
|
|
46
|
+
if (!runId) {
|
|
47
|
+
return Effect.fail(new RunLauncherError({ message: 'RunLauncher.launch requires runId' }));
|
|
48
|
+
}
|
|
49
|
+
return Effect.tryPromise({
|
|
50
|
+
try: () => target.launch(runId, { ...args, runId }),
|
|
51
|
+
catch: runLauncherError,
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
status: (runId) => Effect.tryPromise({
|
|
55
|
+
try: () => target.status(runId),
|
|
56
|
+
catch: runLauncherError,
|
|
57
|
+
}),
|
|
58
|
+
signal: (runId, events, options) => Effect.tryPromise({
|
|
59
|
+
try: () => target.accept(runId, events, { ...options, coalesce: true }),
|
|
60
|
+
catch: runLauncherError,
|
|
61
|
+
}),
|
|
62
|
+
cancel: (runId) => Effect.tryPromise({
|
|
63
|
+
try: () => target.cancel(runId),
|
|
64
|
+
catch: runLauncherError,
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -3,7 +3,8 @@ import { type CatalogEntries, type EventCatalog, type EventInputOf, type EventsO
|
|
|
3
3
|
import type { EventsOf, ProtocolEvents } from './compose';
|
|
4
4
|
import { type EffectDefinition, type EffectExecution, type EffectHandlerResult, type EmitEffect, type RetryPolicy, type RuntimeEffect, type ScopedEffectContext } from './effects';
|
|
5
5
|
import type { EventEnvelope, EventInput } from './envelope';
|
|
6
|
-
import
|
|
6
|
+
import type { RunLauncherTag } from './launcher';
|
|
7
|
+
import { type AnyRuntimeModule, type DefinitionHost, type EffectMiddleware, type RuntimeModule, type DefinitionRef, type RuntimeModuleDependency, type SignalInterruptRule } from './module';
|
|
7
8
|
import { type ProjectionDefinition } from './projection';
|
|
8
9
|
import type { InferDefinedSchema, InferSchemaOutput, SchemaInput } from './schema';
|
|
9
10
|
import { type StartContext, type ThreadContext, type ThreadDefinition } from './thread';
|
|
@@ -18,9 +19,9 @@ export interface DefineModuleOptions<TNamespace extends string, TEvents extends
|
|
|
18
19
|
export type ScopeUniverse<TEvents extends EventCatalog | undefined, TObserves extends readonly EventCatalog[] | undefined> = ProtocolEvents | (TEvents extends EventCatalog ? EventsOfCatalog<TEvents> : never) | (TObserves extends readonly EventCatalog[] ? EventsOfCatalog<TObserves[number]> : never);
|
|
19
20
|
export type EffectRequirementsOf<TEffects> = TEffects extends {
|
|
20
21
|
readonly [key: string]: EffectDefinition<any, any, any>;
|
|
21
|
-
} ? {
|
|
22
|
+
} ? Exclude<{
|
|
22
23
|
[K in keyof TEffects]: TEffects[K] extends EffectDefinition<any, infer R, any> ? R : never;
|
|
23
|
-
}[keyof TEffects] : never;
|
|
24
|
+
}[keyof TEffects], RunLauncherTag> : never;
|
|
24
25
|
export type ModuleServicesConfig<TR> = [TR] extends [never] ? {
|
|
25
26
|
readonly services?: () => Layer.Layer<any>;
|
|
26
27
|
} : {
|
|
@@ -36,6 +37,7 @@ export interface ModuleScope<TNamespace extends string, U extends EventEnvelope<
|
|
|
36
37
|
readonly kind: string;
|
|
37
38
|
readonly shape?: undefined;
|
|
38
39
|
readonly input?: TInputSchema;
|
|
40
|
+
readonly forgetsCompletedEffects?: boolean;
|
|
39
41
|
initialState(ctx: StartContext<InferDefinedSchema<TInputSchema>>): S;
|
|
40
42
|
step(state: S, event: U, ctx: ThreadContext): S;
|
|
41
43
|
effects?(state: S, ctx: ThreadContext): RuntimeEffect[];
|
|
@@ -44,6 +46,7 @@ export interface ModuleScope<TNamespace extends string, U extends EventEnvelope<
|
|
|
44
46
|
readonly kind: string;
|
|
45
47
|
readonly shape: TShape;
|
|
46
48
|
readonly input?: TInputSchema;
|
|
49
|
+
readonly forgetsCompletedEffects?: boolean;
|
|
47
50
|
initialState(ctx: StartContext<InferDefinedSchema<TInputSchema>>): InferSchemaOutput<TShape>;
|
|
48
51
|
step(state: NoInfer<InferSchemaOutput<TShape>>, event: U, ctx: ThreadContext): InferSchemaOutput<TShape>;
|
|
49
52
|
effects?(state: NoInfer<InferSchemaOutput<TShape>>, ctx: ThreadContext): RuntimeEffect[];
|
|
@@ -95,6 +98,7 @@ export declare function defineModule<const N extends string, E extends EventCata
|
|
|
95
98
|
readonly definitions?: readonly DefinitionRef[];
|
|
96
99
|
readonly middleware?: readonly EffectMiddleware[];
|
|
97
100
|
readonly interruptsOnSignal?: SignalInterruptRule;
|
|
101
|
+
readonly bindHost?: (host: DefinitionHost) => void;
|
|
98
102
|
} & ModuleServicesConfig<EffectRequirementsOf<FX>>): RuntimeModule<N, Extract<ModuleCatalog<N, E>, EventCatalog>, FX, TH, PR> & {
|
|
99
103
|
readonly effects: FX;
|
|
100
104
|
readonly threads: TH;
|
package/dist/core/module.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context, Effect, Layer } from 'effect';
|
|
2
2
|
import type { EventCatalog } from './catalog';
|
|
3
|
+
import type { DefinitionResolver } from './definition-resolver';
|
|
3
4
|
import type { EffectContext, EffectDefinition, RuntimeEffect } from './effects';
|
|
4
5
|
import type { EventInput } from './envelope';
|
|
5
6
|
import type { ProjectionDefinition } from './projection';
|
|
@@ -14,6 +15,10 @@ export type EffectMiddleware = (effect: RuntimeEffect, ctx: EffectContext, next:
|
|
|
14
15
|
* descendants. Return an empty array when the event interrupts nothing.
|
|
15
16
|
*/
|
|
16
17
|
export type SignalInterruptRule = (event: EventInput) => readonly string[];
|
|
18
|
+
/** Passed to a module once, before its services layer is constructed. */
|
|
19
|
+
export interface DefinitionHost {
|
|
20
|
+
readonly definitionResolver: DefinitionResolver;
|
|
21
|
+
}
|
|
17
22
|
export interface RuntimeModuleDependency {
|
|
18
23
|
readonly namespace: string;
|
|
19
24
|
readonly protocolVersion?: string;
|
|
@@ -70,6 +75,11 @@ export interface RuntimeModule<TNamespace extends string = string, TEvents exten
|
|
|
70
75
|
readonly interruptsOnSignal?: SignalInterruptRule;
|
|
71
76
|
/** Host-side services this module's effect handlers need (an LLM, a definition lookup, a DB pool). */
|
|
72
77
|
readonly services?: () => Layer.Layer<TServices>;
|
|
78
|
+
/**
|
|
79
|
+
* Receives the host's definition resolver before `services()` runs.
|
|
80
|
+
* Modules that look definitions up during fold share one store with this resolver.
|
|
81
|
+
*/
|
|
82
|
+
readonly bindHost?: (host: DefinitionHost) => void;
|
|
73
83
|
}
|
|
74
84
|
export declare function defineRuntimeModule<TNamespace extends string, TEvents extends EventCatalog, TEffects extends {
|
|
75
85
|
readonly [key: string]: EffectDefinition;
|
package/dist/core/projection.js
CHANGED
|
@@ -175,12 +175,16 @@ export function toThreadTree(state) {
|
|
|
175
175
|
rootThreadId: state.rootThreadId,
|
|
176
176
|
startIdentity: null,
|
|
177
177
|
forkedFrom: null,
|
|
178
|
+
attributes: {},
|
|
178
179
|
threads: state.records,
|
|
179
180
|
waits: {},
|
|
180
181
|
outstandingEffects: [],
|
|
181
182
|
effectExecutions: {},
|
|
182
183
|
completedEffectIds: [],
|
|
183
184
|
processedIdempotencyKeys: [],
|
|
185
|
+
launchedRuns: [],
|
|
186
|
+
closeWaiting: false,
|
|
187
|
+
childCloseSent: false,
|
|
184
188
|
});
|
|
185
189
|
}
|
|
186
190
|
export function treeFromRun(state) {
|
package/dist/core/protocol.d.ts
CHANGED
|
@@ -9,6 +9,18 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
9
9
|
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
10
10
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
11
11
|
readonly requestedThreadId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
12
|
+
readonly launchedBy: Schema.optional<Schema.Struct<{
|
|
13
|
+
readonly runId: Schema.String;
|
|
14
|
+
readonly threadId: Schema.String;
|
|
15
|
+
readonly effectId: Schema.String;
|
|
16
|
+
readonly causationId: Schema.String;
|
|
17
|
+
readonly causationSeq: Schema.Finite;
|
|
18
|
+
}>>;
|
|
19
|
+
readonly attributes: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
20
|
+
readonly trace: Schema.optional<Schema.Struct<{
|
|
21
|
+
readonly traceparent: Schema.String;
|
|
22
|
+
readonly tracestate: Schema.optional<Schema.String>;
|
|
23
|
+
}>>;
|
|
12
24
|
}>;
|
|
13
25
|
'run.completed': Schema.Struct<{
|
|
14
26
|
readonly output: Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
@@ -17,6 +29,24 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
17
29
|
'run.cancelled': Schema.Struct<{
|
|
18
30
|
readonly reason: Schema.optional<Schema.String>;
|
|
19
31
|
}>;
|
|
32
|
+
'run.launched': Schema.Struct<{
|
|
33
|
+
readonly runId: Schema.String;
|
|
34
|
+
readonly kind: Schema.String;
|
|
35
|
+
readonly definitionName: Schema.String;
|
|
36
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
37
|
+
/** In the payload, not the envelope: an envelope `effectId` would complete the effect. */
|
|
38
|
+
readonly effectId: Schema.String;
|
|
39
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
40
|
+
}>;
|
|
41
|
+
'child.settled': Schema.Struct<{
|
|
42
|
+
readonly runId: Schema.String;
|
|
43
|
+
readonly status: Schema.Union<readonly [Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"cancelled">]>;
|
|
44
|
+
readonly output: Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
45
|
+
readonly error: Schema.NullOr<Schema.String>;
|
|
46
|
+
}>;
|
|
47
|
+
'child.close.requested': Schema.Struct<{
|
|
48
|
+
readonly policy: Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>;
|
|
49
|
+
}>;
|
|
20
50
|
'run.forked': Schema.Struct<{
|
|
21
51
|
readonly sourceRunId: Schema.String;
|
|
22
52
|
readonly sourceSeq: Schema.Finite;
|
|
@@ -81,6 +111,8 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
81
111
|
'effect.failed': Schema.Struct<{
|
|
82
112
|
readonly effectId: Schema.String;
|
|
83
113
|
readonly error: Schema.String;
|
|
114
|
+
readonly nonRetryable: Schema.optional<Schema.Boolean>;
|
|
115
|
+
readonly retryAfterMs: Schema.optional<Schema.Finite>;
|
|
84
116
|
}>;
|
|
85
117
|
'effect.attempt.started': Schema.Struct<{
|
|
86
118
|
readonly effectId: Schema.String;
|
|
@@ -106,6 +138,8 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
106
138
|
readonly attempt: Schema.Finite;
|
|
107
139
|
readonly heartbeatAt: Schema.Finite;
|
|
108
140
|
readonly deadlineAt: Schema.NullOr<Schema.Finite>;
|
|
141
|
+
/** Progress the next attempt should resume from. Absent on heartbeats that only extend the deadline. */
|
|
142
|
+
readonly details: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
109
143
|
}>;
|
|
110
144
|
'effect.cancel.requested': Schema.Struct<{
|
|
111
145
|
readonly effectId: Schema.String;
|
|
@@ -147,10 +181,11 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
147
181
|
}>;
|
|
148
182
|
export type ProtocolEvent = EventsOfCatalog<typeof protocolCatalog>;
|
|
149
183
|
export type ProtocolEventInput = EventInputOf<typeof protocolCatalog>;
|
|
150
|
-
export declare const PROTOCOL_TYPES: readonly ['runtime.run.started', 'runtime.run.completed', 'runtime.run.cancelled', 'runtime.run.forked', 'runtime.fork.elided', 'runtime.thread.started', 'runtime.thread.completed', 'runtime.thread.failed', 'runtime.thread.cancelled', 'runtime.thread.cancel.requested', 'runtime.wait.registered', 'runtime.wait.satisfied', 'runtime.timer.set', 'runtime.timer.fired', 'runtime.effect.failed', 'runtime.effect.attempt.started', 'runtime.effect.queued', 'runtime.effect.dispatched', 'runtime.effect.worker.started', 'runtime.effect.heartbeat', 'runtime.effect.cancel.requested', 'runtime.effect.cancelled', 'runtime.effect.completed', 'runtime.effect.timed_out', 'runtime.effect.ambiguous', 'runtime.effect.retry.scheduled', 'runtime.snapshot.taken', 'runtime.signal.received'];
|
|
184
|
+
export declare const PROTOCOL_TYPES: readonly ['runtime.run.started', 'runtime.run.completed', 'runtime.run.cancelled', 'runtime.run.launched', 'runtime.child.settled', 'runtime.child.close.requested', 'runtime.run.forked', 'runtime.fork.elided', 'runtime.thread.started', 'runtime.thread.completed', 'runtime.thread.failed', 'runtime.thread.cancelled', 'runtime.thread.cancel.requested', 'runtime.wait.registered', 'runtime.wait.satisfied', 'runtime.timer.set', 'runtime.timer.fired', 'runtime.effect.failed', 'runtime.effect.attempt.started', 'runtime.effect.queued', 'runtime.effect.dispatched', 'runtime.effect.worker.started', 'runtime.effect.heartbeat', 'runtime.effect.cancel.requested', 'runtime.effect.cancelled', 'runtime.effect.completed', 'runtime.effect.timed_out', 'runtime.effect.ambiguous', 'runtime.effect.retry.scheduled', 'runtime.snapshot.taken', 'runtime.signal.received'];
|
|
151
185
|
export type ProtocolEventType = (typeof PROTOCOL_TYPES)[number];
|
|
152
186
|
export declare function isProtocolType(type: string): type is ProtocolEventType;
|
|
153
187
|
export type RunStartedPayload = Schema.Schema.Type<(typeof protocolCatalog.entries)['run.started']>;
|
|
188
|
+
export type RunLaunchedPayload = Schema.Schema.Type<(typeof protocolCatalog.entries)['run.launched']>;
|
|
154
189
|
export type RunCompletedPayload = Schema.Schema.Type<(typeof protocolCatalog.entries)['run.completed']>;
|
|
155
190
|
export type ThreadStartedPayload = Schema.Schema.Type<(typeof protocolCatalog.entries)['thread.started']>;
|
|
156
191
|
export type ThreadCompletedPayload = Schema.Schema.Type<(typeof protocolCatalog.entries)['thread.completed']>;
|
package/dist/core/protocol.js
CHANGED
|
@@ -2,7 +2,10 @@ import { Effect, Schema } from 'effect';
|
|
|
2
2
|
import { defineEventCatalog } from './catalog.js';
|
|
3
3
|
import { WaitConditionSchema } from './effects.js';
|
|
4
4
|
import { JsonValueSchema } from './envelope.js';
|
|
5
|
+
import { RunLaunchSourceSchema } from './launcher.js';
|
|
5
6
|
import { DEFAULT_DEFINITION_VERSION } from './module.js';
|
|
7
|
+
import { RunAttributesSchema } from './run-context.js';
|
|
8
|
+
import { TraceContextSchema } from './trace.js';
|
|
6
9
|
const DefinitionVersionSchema = Schema.String.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_DEFINITION_VERSION)));
|
|
7
10
|
export const protocolCatalog = defineEventCatalog('runtime', {
|
|
8
11
|
'run.started': Schema.Struct({
|
|
@@ -12,6 +15,9 @@ export const protocolCatalog = defineEventCatalog('runtime', {
|
|
|
12
15
|
definitionVersion: DefinitionVersionSchema,
|
|
13
16
|
input: JsonValueSchema,
|
|
14
17
|
requestedThreadId: Schema.optional(Schema.NullOr(Schema.String)),
|
|
18
|
+
launchedBy: Schema.optional(RunLaunchSourceSchema),
|
|
19
|
+
attributes: Schema.optional(RunAttributesSchema),
|
|
20
|
+
trace: Schema.optional(TraceContextSchema),
|
|
15
21
|
}),
|
|
16
22
|
'run.completed': Schema.Struct({
|
|
17
23
|
output: Schema.NullOr(JsonValueSchema),
|
|
@@ -20,6 +26,28 @@ export const protocolCatalog = defineEventCatalog('runtime', {
|
|
|
20
26
|
'run.cancelled': Schema.Struct({
|
|
21
27
|
reason: Schema.optional(Schema.String),
|
|
22
28
|
}),
|
|
29
|
+
'run.launched': Schema.Struct({
|
|
30
|
+
runId: Schema.String,
|
|
31
|
+
kind: Schema.String,
|
|
32
|
+
definitionName: Schema.String,
|
|
33
|
+
definitionVersion: DefinitionVersionSchema,
|
|
34
|
+
/** In the payload, not the envelope: an envelope `effectId` would complete the effect. */
|
|
35
|
+
effectId: Schema.String,
|
|
36
|
+
close: Schema.Union([Schema.Literal('terminate'), Schema.Literal('wait')]).pipe(Schema.withDecodingDefaultKey(Effect.succeed('terminate'))),
|
|
37
|
+
}),
|
|
38
|
+
'child.settled': Schema.Struct({
|
|
39
|
+
runId: Schema.String,
|
|
40
|
+
status: Schema.Union([
|
|
41
|
+
Schema.Literal('completed'),
|
|
42
|
+
Schema.Literal('failed'),
|
|
43
|
+
Schema.Literal('cancelled'),
|
|
44
|
+
]),
|
|
45
|
+
output: Schema.NullOr(JsonValueSchema),
|
|
46
|
+
error: Schema.NullOr(Schema.String),
|
|
47
|
+
}),
|
|
48
|
+
'child.close.requested': Schema.Struct({
|
|
49
|
+
policy: Schema.Union([Schema.Literal('terminate'), Schema.Literal('wait')]),
|
|
50
|
+
}),
|
|
23
51
|
'run.forked': Schema.Struct({
|
|
24
52
|
sourceRunId: Schema.String,
|
|
25
53
|
sourceSeq: Schema.Finite,
|
|
@@ -79,6 +107,8 @@ export const protocolCatalog = defineEventCatalog('runtime', {
|
|
|
79
107
|
'effect.failed': Schema.Struct({
|
|
80
108
|
effectId: Schema.String,
|
|
81
109
|
error: Schema.String,
|
|
110
|
+
nonRetryable: Schema.optional(Schema.Boolean),
|
|
111
|
+
retryAfterMs: Schema.optional(Schema.Finite),
|
|
82
112
|
}),
|
|
83
113
|
'effect.attempt.started': Schema.Struct({
|
|
84
114
|
effectId: Schema.String,
|
|
@@ -104,6 +134,8 @@ export const protocolCatalog = defineEventCatalog('runtime', {
|
|
|
104
134
|
attempt: Schema.Finite,
|
|
105
135
|
heartbeatAt: Schema.Finite,
|
|
106
136
|
deadlineAt: Schema.NullOr(Schema.Finite),
|
|
137
|
+
/** Progress the next attempt should resume from. Absent on heartbeats that only extend the deadline. */
|
|
138
|
+
details: Schema.optional(JsonValueSchema),
|
|
107
139
|
}),
|
|
108
140
|
'effect.cancel.requested': Schema.Struct({
|
|
109
141
|
effectId: Schema.String,
|
|
@@ -147,6 +179,9 @@ export const PROTOCOL_TYPES = [
|
|
|
147
179
|
'runtime.run.started',
|
|
148
180
|
'runtime.run.completed',
|
|
149
181
|
'runtime.run.cancelled',
|
|
182
|
+
'runtime.run.launched',
|
|
183
|
+
'runtime.child.settled',
|
|
184
|
+
'runtime.child.close.requested',
|
|
150
185
|
'runtime.run.forked',
|
|
151
186
|
'runtime.fork.elided',
|
|
152
187
|
'runtime.thread.started',
|
package/dist/core/published.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare const RunSummarySchema: Schema.Struct<{
|
|
|
30
30
|
readonly status: Schema.Union<readonly [Schema.Literal<"running">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"cancelled">]>;
|
|
31
31
|
readonly kind: Schema.NullOr<Schema.String>;
|
|
32
32
|
readonly definitionName: Schema.NullOr<Schema.String>;
|
|
33
|
+
readonly attributes: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>;
|
|
33
34
|
}>;
|
|
34
35
|
export type RunSummary = Schema.Schema.Type<typeof RunSummarySchema>;
|
|
35
36
|
export declare function summarizeRun(state: RunState): RunSummary;
|
|
@@ -39,5 +40,6 @@ export declare const RunSummariesSchema: Schema.Struct<{
|
|
|
39
40
|
readonly status: Schema.Union<readonly [Schema.Literal<"running">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"cancelled">]>;
|
|
40
41
|
readonly kind: Schema.NullOr<Schema.String>;
|
|
41
42
|
readonly definitionName: Schema.NullOr<Schema.String>;
|
|
43
|
+
readonly attributes: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>;
|
|
42
44
|
}>>;
|
|
43
45
|
}>;
|
package/dist/core/published.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
1
|
+
import { Effect, Schema } from 'effect';
|
|
2
2
|
import { JsonValueSchema } from './envelope.js';
|
|
3
|
+
import { RunAttributesSchema } from './run-context.js';
|
|
3
4
|
import { jsonSchemaOfInput } from './schema.js';
|
|
4
5
|
import { RunStateSchema } from './state.js';
|
|
5
6
|
/** A registered definition as `GET /definitions` publishes it. */
|
|
@@ -30,6 +31,7 @@ export const RunSummarySchema = Schema.Struct({
|
|
|
30
31
|
status: RunStateSchema.fields.status,
|
|
31
32
|
kind: Schema.NullOr(Schema.String),
|
|
32
33
|
definitionName: Schema.NullOr(Schema.String),
|
|
34
|
+
attributes: RunAttributesSchema.pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
|
|
33
35
|
});
|
|
34
36
|
export function summarizeRun(state) {
|
|
35
37
|
return {
|
|
@@ -37,6 +39,7 @@ export function summarizeRun(state) {
|
|
|
37
39
|
status: state.status,
|
|
38
40
|
kind: state.startIdentity?.kind ?? null,
|
|
39
41
|
definitionName: state.startIdentity?.definitionName ?? null,
|
|
42
|
+
attributes: state.attributes ?? {},
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
export const RunSummariesSchema = Schema.Struct({
|
package/dist/core/replay.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
32
32
|
readonly actorId: Schema.optional<Schema.String>;
|
|
33
33
|
}>, Schema.Struct<{
|
|
34
34
|
readonly type: Schema.Literal<"system">;
|
|
35
|
+
}>, Schema.Struct<{
|
|
36
|
+
readonly type: Schema.Literal<"run">;
|
|
37
|
+
readonly runId: Schema.String;
|
|
35
38
|
}>]>;
|
|
36
39
|
readonly ephemeral: Schema.optional<Schema.Boolean>;
|
|
37
40
|
readonly idempotencyKey: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
@@ -48,7 +51,21 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
48
51
|
readonly requestedThreadId: Schema.NullOr<Schema.String>;
|
|
49
52
|
readonly idempotencyKey: Schema.NullOr<Schema.String>;
|
|
50
53
|
readonly rootThreadId: Schema.String;
|
|
54
|
+
readonly launchedBy: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Struct<{
|
|
55
|
+
readonly runId: Schema.String;
|
|
56
|
+
readonly threadId: Schema.String;
|
|
57
|
+
readonly effectId: Schema.String;
|
|
58
|
+
readonly causationId: Schema.String;
|
|
59
|
+
readonly causationSeq: Schema.Finite;
|
|
60
|
+
}>>, never>;
|
|
61
|
+
readonly correlationId: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.String>, never>;
|
|
62
|
+
readonly attributes: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>;
|
|
63
|
+
readonly trace: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Struct<{
|
|
64
|
+
readonly traceparent: Schema.String;
|
|
65
|
+
readonly tracestate: Schema.optional<Schema.String>;
|
|
66
|
+
}>>, never>;
|
|
51
67
|
}>>, never>;
|
|
68
|
+
readonly attributes: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>;
|
|
52
69
|
readonly forkedFrom: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Struct<{
|
|
53
70
|
readonly runId: Schema.String;
|
|
54
71
|
readonly seq: Schema.Finite;
|
|
@@ -116,6 +133,9 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
116
133
|
readonly actorId: Schema.optional<Schema.String>;
|
|
117
134
|
}>, Schema.Struct<{
|
|
118
135
|
readonly type: Schema.Literal<"system">;
|
|
136
|
+
}>, Schema.Struct<{
|
|
137
|
+
readonly type: Schema.Literal<"run">;
|
|
138
|
+
readonly runId: Schema.String;
|
|
119
139
|
}>]>>;
|
|
120
140
|
readonly ephemeral: Schema.optional<Schema.Boolean>;
|
|
121
141
|
readonly id: Schema.optional<Schema.String>;
|
|
@@ -133,10 +153,24 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
133
153
|
readonly type: Schema.Literal<"runtime.cancel">;
|
|
134
154
|
readonly threadId: Schema.String;
|
|
135
155
|
readonly tag: Schema.optional<Schema.String>;
|
|
156
|
+
}>, Schema.Struct<{
|
|
157
|
+
readonly type: Schema.Literal<"runtime.launch">;
|
|
158
|
+
readonly runId: Schema.String;
|
|
159
|
+
readonly kind: Schema.String;
|
|
160
|
+
readonly definitionName: Schema.String;
|
|
161
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
162
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
163
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
164
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
165
|
+
}>, Schema.Struct<{
|
|
166
|
+
readonly type: Schema.Literal<"runtime.cancelRun">;
|
|
167
|
+
readonly runId: Schema.String;
|
|
168
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
136
169
|
}>, Schema.Struct<{
|
|
137
170
|
readonly type: Schema.String;
|
|
138
171
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
139
172
|
readonly tag: Schema.optional<Schema.String>;
|
|
173
|
+
readonly at: Schema.optional<Schema.Finite>;
|
|
140
174
|
}>]>;
|
|
141
175
|
}>>;
|
|
142
176
|
readonly effectExecutions: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.Struct<{
|
|
@@ -147,10 +181,17 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
147
181
|
readonly deadlineAt: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
148
182
|
readonly startedAt: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
149
183
|
readonly lastHeartbeatAt: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
184
|
+
readonly heartbeatDetails: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never>;
|
|
150
185
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
151
186
|
}>>, never>;
|
|
152
187
|
readonly completedEffectIds: Schema.withDecodingDefaultKey<Schema.$Array<Schema.String>, never>;
|
|
153
188
|
readonly processedIdempotencyKeys: Schema.withDecodingDefaultKey<Schema.$Array<Schema.String>, never>;
|
|
189
|
+
readonly launchedRuns: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
|
|
190
|
+
readonly runId: Schema.String;
|
|
191
|
+
readonly close: Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>;
|
|
192
|
+
}>>, never>;
|
|
193
|
+
readonly closeWaiting: Schema.withDecodingDefaultKey<Schema.Boolean, never>;
|
|
194
|
+
readonly childCloseSent: Schema.withDecodingDefaultKey<Schema.Boolean, never>;
|
|
154
195
|
}>;
|
|
155
196
|
readonly after: Schema.Struct<{
|
|
156
197
|
readonly runId: Schema.String;
|
|
@@ -164,7 +205,21 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
164
205
|
readonly requestedThreadId: Schema.NullOr<Schema.String>;
|
|
165
206
|
readonly idempotencyKey: Schema.NullOr<Schema.String>;
|
|
166
207
|
readonly rootThreadId: Schema.String;
|
|
208
|
+
readonly launchedBy: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Struct<{
|
|
209
|
+
readonly runId: Schema.String;
|
|
210
|
+
readonly threadId: Schema.String;
|
|
211
|
+
readonly effectId: Schema.String;
|
|
212
|
+
readonly causationId: Schema.String;
|
|
213
|
+
readonly causationSeq: Schema.Finite;
|
|
214
|
+
}>>, never>;
|
|
215
|
+
readonly correlationId: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.String>, never>;
|
|
216
|
+
readonly attributes: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>;
|
|
217
|
+
readonly trace: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Struct<{
|
|
218
|
+
readonly traceparent: Schema.String;
|
|
219
|
+
readonly tracestate: Schema.optional<Schema.String>;
|
|
220
|
+
}>>, never>;
|
|
167
221
|
}>>, never>;
|
|
222
|
+
readonly attributes: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.String>, never>;
|
|
168
223
|
readonly forkedFrom: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Struct<{
|
|
169
224
|
readonly runId: Schema.String;
|
|
170
225
|
readonly seq: Schema.Finite;
|
|
@@ -232,6 +287,9 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
232
287
|
readonly actorId: Schema.optional<Schema.String>;
|
|
233
288
|
}>, Schema.Struct<{
|
|
234
289
|
readonly type: Schema.Literal<"system">;
|
|
290
|
+
}>, Schema.Struct<{
|
|
291
|
+
readonly type: Schema.Literal<"run">;
|
|
292
|
+
readonly runId: Schema.String;
|
|
235
293
|
}>]>>;
|
|
236
294
|
readonly ephemeral: Schema.optional<Schema.Boolean>;
|
|
237
295
|
readonly id: Schema.optional<Schema.String>;
|
|
@@ -249,10 +307,24 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
249
307
|
readonly type: Schema.Literal<"runtime.cancel">;
|
|
250
308
|
readonly threadId: Schema.String;
|
|
251
309
|
readonly tag: Schema.optional<Schema.String>;
|
|
310
|
+
}>, Schema.Struct<{
|
|
311
|
+
readonly type: Schema.Literal<"runtime.launch">;
|
|
312
|
+
readonly runId: Schema.String;
|
|
313
|
+
readonly kind: Schema.String;
|
|
314
|
+
readonly definitionName: Schema.String;
|
|
315
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
316
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
317
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
318
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
319
|
+
}>, Schema.Struct<{
|
|
320
|
+
readonly type: Schema.Literal<"runtime.cancelRun">;
|
|
321
|
+
readonly runId: Schema.String;
|
|
322
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
252
323
|
}>, Schema.Struct<{
|
|
253
324
|
readonly type: Schema.String;
|
|
254
325
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
255
326
|
readonly tag: Schema.optional<Schema.String>;
|
|
327
|
+
readonly at: Schema.optional<Schema.Finite>;
|
|
256
328
|
}>]>;
|
|
257
329
|
}>>;
|
|
258
330
|
readonly effectExecutions: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.Struct<{
|
|
@@ -263,10 +335,17 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
263
335
|
readonly deadlineAt: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
264
336
|
readonly startedAt: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
265
337
|
readonly lastHeartbeatAt: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
338
|
+
readonly heartbeatDetails: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never>;
|
|
266
339
|
readonly lastError: Schema.NullOr<Schema.String>;
|
|
267
340
|
}>>, never>;
|
|
268
341
|
readonly completedEffectIds: Schema.withDecodingDefaultKey<Schema.$Array<Schema.String>, never>;
|
|
269
342
|
readonly processedIdempotencyKeys: Schema.withDecodingDefaultKey<Schema.$Array<Schema.String>, never>;
|
|
343
|
+
readonly launchedRuns: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
|
|
344
|
+
readonly runId: Schema.String;
|
|
345
|
+
readonly close: Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>;
|
|
346
|
+
}>>, never>;
|
|
347
|
+
readonly closeWaiting: Schema.withDecodingDefaultKey<Schema.Boolean, never>;
|
|
348
|
+
readonly childCloseSent: Schema.withDecodingDefaultKey<Schema.Boolean, never>;
|
|
270
349
|
}>;
|
|
271
350
|
readonly effects: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
272
351
|
readonly type: Schema.Literal<"runtime.spawn">;
|
|
@@ -303,6 +382,9 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
303
382
|
readonly actorId: Schema.optional<Schema.String>;
|
|
304
383
|
}>, Schema.Struct<{
|
|
305
384
|
readonly type: Schema.Literal<"system">;
|
|
385
|
+
}>, Schema.Struct<{
|
|
386
|
+
readonly type: Schema.Literal<"run">;
|
|
387
|
+
readonly runId: Schema.String;
|
|
306
388
|
}>]>>;
|
|
307
389
|
readonly ephemeral: Schema.optional<Schema.Boolean>;
|
|
308
390
|
readonly id: Schema.optional<Schema.String>;
|
|
@@ -320,10 +402,24 @@ export declare const ReplayStepSchema: Schema.Struct<{
|
|
|
320
402
|
readonly type: Schema.Literal<"runtime.cancel">;
|
|
321
403
|
readonly threadId: Schema.String;
|
|
322
404
|
readonly tag: Schema.optional<Schema.String>;
|
|
405
|
+
}>, Schema.Struct<{
|
|
406
|
+
readonly type: Schema.Literal<"runtime.launch">;
|
|
407
|
+
readonly runId: Schema.String;
|
|
408
|
+
readonly kind: Schema.String;
|
|
409
|
+
readonly definitionName: Schema.String;
|
|
410
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
411
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
412
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
413
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
414
|
+
}>, Schema.Struct<{
|
|
415
|
+
readonly type: Schema.Literal<"runtime.cancelRun">;
|
|
416
|
+
readonly runId: Schema.String;
|
|
417
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
323
418
|
}>, Schema.Struct<{
|
|
324
419
|
readonly type: Schema.String;
|
|
325
420
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
326
421
|
readonly tag: Schema.optional<Schema.String>;
|
|
422
|
+
readonly at: Schema.optional<Schema.Finite>;
|
|
327
423
|
}>]>>;
|
|
328
424
|
}>;
|
|
329
425
|
export declare function replayTo(events: readonly EventEnvelope[], registry: FoldRegistry, seq: number): ReplayStep | null;
|