@swirls/looms 0.0.2 → 0.2.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/CHANGELOG.md +24 -2
- package/dist/actor/cell.d.ts +9 -4
- package/dist/actor/cell.js +7 -11
- package/dist/actor/host.d.ts +7 -3
- package/dist/actor/host.js +57 -33
- package/dist/actor/index.d.ts +1 -1
- package/dist/actor/index.js +1 -1
- package/dist/actor/routing.d.ts +12 -1
- package/dist/actor/routing.js +57 -51
- package/dist/agent/agent-session.d.ts +5 -0
- package/dist/agent/agent-session.js +270 -0
- package/dist/agent/debugger/agent-chat.d.ts +2 -0
- package/dist/agent/debugger/agent-chat.js +176 -0
- package/dist/agent/debugger/index.d.ts +5 -0
- package/dist/agent/debugger/index.js +19 -0
- package/dist/agent/debugger/summarize.d.ts +2 -0
- package/dist/agent/debugger/summarize.js +51 -0
- package/dist/agent/debugger/token-usage.d.ts +3 -0
- package/dist/agent/debugger/token-usage.js +11 -0
- package/dist/agent/definitions-store.d.ts +2 -3
- package/dist/agent/definitions-store.js +2 -4
- package/dist/agent/definitions.d.ts +47 -29
- package/dist/agent/definitions.js +39 -12
- package/dist/agent/effects.d.ts +359 -2
- package/dist/agent/effects.js +60 -34
- package/dist/agent/events.d.ts +175 -19
- package/dist/agent/events.js +45 -10
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.js +1 -0
- package/dist/agent/llm.d.ts +11 -2
- package/dist/agent/llm.js +13 -3
- package/dist/agent/module.d.ts +812 -78
- package/dist/agent/module.js +16 -4
- package/dist/agent/scope.d.ts +174 -18
- package/dist/agent/signals.d.ts +26 -1
- package/dist/agent/signals.js +79 -0
- package/dist/agent/threads.d.ts +3 -33
- package/dist/agent/threads.js +20 -25
- package/dist/agent/tool-schema.d.ts +1 -17
- package/dist/agent/tool-schema.js +3 -43
- package/dist/agent/types.d.ts +49 -4
- package/dist/agent/types.js +5 -5
- package/dist/ai-vercel/index.d.ts +1 -0
- package/dist/ai-vercel/index.js +1 -0
- package/dist/ai-vercel/messages.js +22 -7
- package/dist/ai-vercel/vercel-evaluator.d.ts +36 -0
- package/dist/ai-vercel/vercel-evaluator.js +73 -0
- package/dist/ai-vercel/vercel-llm.js +64 -44
- package/dist/approval/debugger/approvals-view.d.ts +3 -0
- package/dist/approval/debugger/approvals-view.js +16 -0
- package/dist/approval/debugger/index.d.ts +4 -0
- package/dist/approval/debugger/index.js +11 -0
- package/dist/approval/debugger/summarize.d.ts +2 -0
- package/dist/approval/debugger/summarize.js +17 -0
- package/dist/approval/effects.d.ts +89 -0
- package/dist/approval/module.d.ts +179 -29
- package/dist/approval/projections.d.ts +0 -14
- package/dist/approval/projections.js +20 -3
- package/dist/approval/signals.d.ts +2 -0
- package/dist/approval/signals.js +18 -2
- package/dist/cli/cli.js +2 -0
- package/dist/cli/commands.js +12 -16
- package/dist/client/client.d.ts +1213 -18
- package/dist/client/client.js +120 -120
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/sse.d.ts +13 -0
- package/dist/client/sse.js +38 -44
- package/dist/cloudflare/alarm-scheduler.d.ts +12 -2
- package/dist/cloudflare/alarm-scheduler.js +34 -7
- package/dist/cloudflare/durable-object.d.ts +10 -2
- package/dist/cloudflare/durable-object.js +59 -28
- package/dist/cloudflare/event-store.d.ts +7 -2
- package/dist/cloudflare/event-store.js +8 -7
- package/dist/cloudflare/index.d.ts +2 -2
- package/dist/cloudflare/index.js +2 -2
- package/dist/cloudflare/router.d.ts +1 -1
- package/dist/cloudflare/router.js +15 -16
- package/dist/core/catalog.d.ts +3 -3
- package/dist/core/catalog.js +2 -5
- package/dist/core/coalesce.js +5 -3
- package/dist/core/compose.d.ts +2 -1
- package/dist/core/compose.js +19 -2
- package/dist/core/debugger-host.d.ts +16 -0
- package/dist/core/debugger-host.js +1 -0
- package/dist/core/definition-store.d.ts +11 -0
- package/dist/core/definition-store.js +6 -0
- package/dist/core/effects.d.ts +127 -15
- package/dist/core/effects.js +89 -17
- package/dist/core/envelope.d.ts +27 -7
- package/dist/core/envelope.js +20 -6
- package/dist/core/event-codec.d.ts +4 -2
- package/dist/core/event-codec.js +10 -5
- package/dist/core/event-index.js +1 -3
- package/dist/core/fold.d.ts +3 -0
- package/dist/core/fold.js +171 -24
- package/dist/core/ids.d.ts +5 -0
- package/dist/core/ids.js +35 -2
- package/dist/core/index.d.ts +7 -1
- package/dist/core/index.js +6 -1
- package/dist/core/kind.d.ts +22 -0
- package/dist/core/kind.js +17 -0
- package/dist/core/limits.d.ts +34 -0
- package/dist/core/limits.js +46 -0
- package/dist/core/match.d.ts +1 -0
- package/dist/core/match.js +10 -1
- package/dist/core/module-scope.d.ts +22 -20
- package/dist/core/module-scope.js +38 -28
- package/dist/core/module.d.ts +18 -5
- package/dist/core/module.js +4 -0
- package/dist/core/projection.d.ts +13 -13
- package/dist/core/projection.js +9 -5
- package/dist/core/protocol.d.ts +68 -11
- package/dist/core/protocol.js +82 -11
- package/dist/core/published.d.ts +43 -0
- package/dist/core/published.js +44 -0
- package/dist/core/replay.d.ts +312 -3
- package/dist/core/replay.js +11 -1
- package/dist/core/schema.d.ts +11 -20
- package/dist/core/schema.js +63 -80
- package/dist/core/serialize.js +2 -4
- package/dist/core/snapshot-store.d.ts +6 -1
- package/dist/core/snapshot-store.js +15 -2
- package/dist/core/snapshots.d.ts +5 -1
- package/dist/core/snapshots.js +10 -15
- package/dist/core/sqlite-store.js +95 -11
- package/dist/core/state.d.ts +142 -4
- package/dist/core/state.js +78 -0
- package/dist/core/store.d.ts +38 -3
- package/dist/core/store.js +77 -22
- package/dist/core/thread.d.ts +10 -9
- package/dist/core/types.d.ts +5 -8
- package/dist/core/types.js +28 -24
- package/dist/core/validate-event.js +14 -4
- package/dist/core/worker-callback.d.ts +17 -0
- package/dist/core/worker-callback.js +1 -0
- package/dist/debugger/app/assets/index-B3Ah8WAE.css +2 -0
- package/dist/debugger/app/assets/index-Qb371t_O.js +22 -0
- package/dist/debugger/app/assets/rolldown-runtime-CbXtAM7H.js +1 -0
- package/dist/debugger/app/assets/routes-CjtEHgPQ.js +47 -0
- package/dist/debugger/app/index.html +14 -0
- package/dist/debugger/components/composer.d.ts +17 -0
- package/dist/debugger/components/composer.js +25 -0
- package/dist/debugger/components/debugger-split.d.ts +2 -1
- package/dist/debugger/components/debugger-split.js +2 -2
- package/dist/debugger/components/event-inspector.d.ts +2 -1
- package/dist/debugger/components/event-inspector.js +25 -16
- package/dist/debugger/components/event-stream.d.ts +2 -1
- package/dist/debugger/components/event-stream.js +14 -74
- package/dist/debugger/components/follow-list.d.ts +19 -0
- package/dist/debugger/components/follow-list.js +96 -0
- package/dist/debugger/components/json-tree.d.ts +11 -0
- package/dist/debugger/components/json-tree.js +120 -0
- package/dist/debugger/components/json-view.js +2 -2
- package/dist/debugger/components/run-tree.js +53 -20
- package/dist/debugger/components/status-dot.d.ts +4 -0
- package/dist/debugger/components/status-dot.js +6 -2
- package/dist/debugger/context.d.ts +14 -0
- package/dist/debugger/context.js +17 -0
- package/dist/debugger/contracts.d.ts +7 -4
- package/dist/debugger/events/builtin-families.d.ts +3 -0
- package/dist/debugger/events/builtin-families.js +9 -0
- package/dist/debugger/events/catalog.d.ts +3 -4
- package/dist/debugger/events/catalog.js +27 -17
- package/dist/debugger/events/protocol-summarize.d.ts +1 -2
- package/dist/debugger/events/protocol-summarize.js +42 -24
- package/dist/debugger/index.d.ts +20 -6
- package/dist/debugger/index.js +19 -5
- package/dist/debugger/lib/cn.d.ts +1 -0
- package/dist/debugger/lib/cn.js +3 -0
- package/dist/debugger/lib/event-meta.d.ts +2 -3
- package/dist/debugger/lib/event-meta.js +6 -12
- package/dist/debugger/lib/json.d.ts +25 -0
- package/dist/debugger/lib/json.js +87 -0
- package/dist/debugger/lib/payload.d.ts +7 -0
- package/dist/debugger/lib/payload.js +11 -0
- package/dist/debugger/lib/time.d.ts +3 -0
- package/dist/debugger/lib/time.js +24 -0
- package/dist/debugger/plugin.d.ts +36 -0
- package/dist/debugger/plugin.js +14 -0
- package/dist/debugger/server/index.d.ts +14 -0
- package/dist/debugger/server/index.js +114 -0
- package/dist/debugger/shell/debugger-shell.d.ts +15 -0
- package/dist/debugger/shell/debugger-shell.js +43 -0
- package/dist/debugger/shell/definition-key.d.ts +3 -0
- package/dist/debugger/shell/definition-key.js +4 -0
- package/dist/debugger/shell/events-pane.d.ts +12 -0
- package/dist/debugger/shell/events-pane.js +25 -0
- package/dist/debugger/shell/projections-panel.d.ts +4 -0
- package/dist/debugger/shell/projections-panel.js +59 -0
- package/dist/debugger/shell/run-controls.d.ts +4 -0
- package/dist/debugger/shell/run-controls.js +72 -0
- package/dist/debugger/shell/run-search.d.ts +6 -0
- package/dist/debugger/shell/run-search.js +102 -0
- package/dist/debugger/shell/run-type-menu.d.ts +6 -0
- package/dist/debugger/shell/run-type-menu.js +11 -0
- package/dist/debugger/shell/schema-form.d.ts +31 -0
- package/dist/debugger/shell/schema-form.js +117 -0
- package/dist/debugger/shell/start-form.d.ts +3 -0
- package/dist/debugger/shell/start-form.js +75 -0
- package/dist/debugger/shell/use-start-run.d.ts +14 -0
- package/dist/debugger/shell/use-start-run.js +32 -0
- package/dist/debugger/shell/workspace.d.ts +6 -0
- package/dist/debugger/shell/workspace.js +15 -0
- package/dist/debugger/styles.css +111 -27
- package/dist/debugger/ui/button.d.ts +24 -0
- package/dist/debugger/ui/button.js +24 -0
- package/dist/debugger/ui/command.d.ts +9 -0
- package/dist/debugger/ui/command.js +24 -0
- package/dist/debugger/ui/dropdown-menu.d.ts +13 -0
- package/dist/debugger/ui/dropdown-menu.js +37 -0
- package/dist/debugger/ui/panel.d.ts +14 -0
- package/dist/debugger/ui/panel.js +16 -0
- package/dist/debugger/ui/popover.d.ts +7 -0
- package/dist/debugger/ui/popover.js +17 -0
- package/dist/debugger/ui/resizable.d.ts +7 -0
- package/dist/debugger/ui/resizable.js +14 -0
- package/dist/debugger/ui/scroll-area.d.ts +2 -1
- package/dist/debugger/ui/scroll-area.js +5 -3
- package/dist/debugger/ui/select.d.ts +10 -0
- package/dist/debugger/ui/select.js +21 -0
- package/dist/debugger/ui/tabs.js +2 -2
- package/dist/debugger/ui/textarea.d.ts +3 -0
- package/dist/debugger/ui/textarea.js +7 -0
- package/dist/evaluator/definitions-store.d.ts +11 -0
- package/dist/evaluator/definitions-store.js +8 -0
- package/dist/evaluator/definitions.d.ts +18 -0
- package/dist/evaluator/definitions.js +4 -0
- package/dist/evaluator/effects.d.ts +226 -0
- package/dist/evaluator/effects.js +132 -0
- package/dist/evaluator/evaluator.d.ts +24 -0
- package/dist/evaluator/evaluator.js +67 -0
- package/dist/evaluator/events.d.ts +59 -0
- package/dist/evaluator/events.js +21 -0
- package/dist/evaluator/index.d.ts +11 -0
- package/dist/evaluator/index.js +11 -0
- package/dist/evaluator/module.d.ts +606 -0
- package/dist/evaluator/module.js +25 -0
- package/dist/evaluator/projections.d.ts +50 -0
- package/dist/evaluator/projections.js +20 -0
- package/dist/evaluator/scope.d.ts +59 -0
- package/dist/evaluator/scope.js +7 -0
- package/dist/evaluator/signals.d.ts +3 -0
- package/dist/evaluator/signals.js +17 -0
- package/dist/evaluator/threads.d.ts +62 -0
- package/dist/evaluator/threads.js +117 -0
- package/dist/evaluator/types.d.ts +125 -0
- package/dist/evaluator/types.js +51 -0
- package/dist/projectors/delivery.d.ts +83 -0
- package/dist/projectors/delivery.js +182 -0
- package/dist/projectors/index-model.d.ts +1 -1
- package/dist/projectors/index-model.js +4 -6
- package/dist/projectors/index.d.ts +2 -0
- package/dist/projectors/index.js +2 -0
- package/dist/projectors/memory.d.ts +1 -1
- package/dist/projectors/memory.js +10 -8
- package/dist/projectors/postgres.js +44 -58
- package/dist/projectors/projector.d.ts +17 -0
- package/dist/projectors/projector.js +26 -1
- package/dist/projectors/sqlite-delivery.d.ts +4 -0
- package/dist/projectors/sqlite-delivery.js +147 -0
- package/dist/projectors/sqlite.js +23 -23
- package/dist/projectors/with-projectors.d.ts +7 -2
- package/dist/projectors/with-projectors.js +27 -28
- package/dist/react/notify.js +11 -8
- package/dist/react/react.d.ts +2 -3
- package/dist/react/react.js +14 -30
- package/dist/react/sse.d.ts +1 -1
- package/dist/react/sse.js +1 -1
- package/dist/react/store.d.ts +3 -3
- package/dist/react/store.js +109 -119
- package/dist/runtime/cancellation.d.ts +16 -0
- package/dist/runtime/cancellation.js +129 -0
- package/dist/runtime/deadline-transition-planner.d.ts +31 -0
- package/dist/runtime/deadline-transition-planner.js +139 -0
- package/dist/runtime/dispatch-effect.d.ts +3 -2
- package/dist/runtime/dispatch-effect.js +7 -13
- package/dist/runtime/errors.d.ts +51 -0
- package/dist/runtime/errors.js +39 -0
- package/dist/runtime/{runtime-helpers.d.ts → helpers.d.ts} +24 -4
- package/dist/runtime/{runtime-helpers.js → helpers.js} +56 -19
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/ingress.d.ts +15 -0
- package/dist/runtime/ingress.js +42 -0
- package/dist/runtime/local-effect-executor.d.ts +21 -0
- package/dist/runtime/local-effect-executor.js +137 -0
- package/dist/runtime/looms.d.ts +30 -4
- package/dist/runtime/looms.js +57 -37
- package/dist/runtime/observer.d.ts +45 -0
- package/dist/runtime/observer.js +11 -0
- package/dist/runtime/repository.d.ts +55 -0
- package/dist/runtime/repository.js +293 -0
- package/dist/runtime/retry-policy.d.ts +16 -0
- package/dist/runtime/retry-policy.js +29 -0
- package/dist/runtime/run-execution-context.d.ts +30 -0
- package/dist/runtime/run-execution-context.js +56 -0
- package/dist/runtime/run-start.d.ts +4 -0
- package/dist/runtime/run-start.js +44 -0
- package/dist/runtime/runtime.d.ts +6 -87
- package/dist/runtime/runtime.js +248 -470
- package/dist/runtime/server/auth.d.ts +41 -0
- package/dist/runtime/server/auth.js +45 -0
- package/dist/runtime/server/debugger-host.d.ts +11 -0
- package/dist/runtime/server/debugger-host.js +32 -0
- package/dist/runtime/server/fetch-handler.d.ts +18 -0
- package/dist/runtime/server/fetch-handler.js +62 -0
- package/dist/runtime/server/http.d.ts +38 -0
- package/dist/runtime/server/http.js +66 -0
- package/dist/runtime/server/route-table.d.ts +55 -0
- package/dist/runtime/server/route-table.js +74 -0
- package/dist/runtime/server/routes/definitions.d.ts +3 -0
- package/dist/runtime/server/routes/definitions.js +20 -0
- package/dist/runtime/server/routes/effects.d.ts +3 -0
- package/dist/runtime/server/routes/effects.js +59 -0
- package/dist/runtime/server/routes/operations.d.ts +3 -0
- package/dist/runtime/server/routes/operations.js +14 -0
- package/dist/runtime/server/routes/runs.d.ts +3 -0
- package/dist/runtime/server/routes/runs.js +199 -0
- package/dist/runtime/server.d.ts +4 -8
- package/dist/runtime/server.js +6 -211
- package/dist/runtime/sse.d.ts +2 -1
- package/dist/runtime/sse.js +24 -17
- package/dist/runtime/types.d.ts +117 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/wake-engine.d.ts +20 -0
- package/dist/runtime/wake-engine.js +311 -0
- package/dist/runtime/wake-scheduler.d.ts +3 -4
- package/dist/runtime/wake-scheduler.js +25 -31
- package/dist/runtime/worker-callbacks.d.ts +16 -0
- package/dist/runtime/worker-callbacks.js +167 -0
- package/dist/runtime/worker-effect-dispatch.d.ts +36 -0
- package/dist/runtime/worker-effect-dispatch.js +126 -0
- package/dist/s2/config.d.ts +1 -1
- package/dist/s2/config.js +1 -1
- package/dist/s2/lite.js +70 -82
- package/dist/s2/pagination.d.ts +15 -0
- package/dist/s2/pagination.js +36 -0
- package/dist/s2/projector.js +6 -5
- package/dist/s2/snapshot-store.js +188 -161
- package/dist/s2/store.d.ts +3 -21
- package/dist/s2/store.js +71 -165
- package/dist/testing/index.d.ts +15 -0
- package/dist/testing/index.js +53 -16
- package/dist/workflow/debugger/index.d.ts +4 -0
- package/dist/workflow/debugger/index.js +11 -0
- package/dist/workflow/debugger/nodes-view.d.ts +3 -0
- package/dist/workflow/debugger/nodes-view.js +13 -0
- package/dist/workflow/debugger/summarize.d.ts +2 -0
- package/dist/workflow/debugger/summarize.js +30 -0
- package/dist/workflow/definitions-store.d.ts +2 -3
- package/dist/workflow/definitions-store.js +2 -2
- package/dist/workflow/definitions.d.ts +78 -22
- package/dist/workflow/definitions.js +80 -14
- package/dist/workflow/effects.d.ts +453 -107
- package/dist/workflow/effects.js +214 -115
- package/dist/workflow/events.d.ts +149 -5
- package/dist/workflow/events.js +27 -5
- package/dist/workflow/graph.d.ts +56 -0
- package/dist/workflow/graph.js +207 -0
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.js +1 -0
- package/dist/workflow/module.d.ts +1047 -266
- package/dist/workflow/projections.d.ts +14 -12
- package/dist/workflow/projections.js +30 -8
- package/dist/workflow/scope.d.ts +146 -4
- package/dist/workflow/threads.d.ts +383 -155
- package/dist/workflow/threads.js +308 -110
- package/package.json +26 -2
- package/dist/debugger/events/domain-summarize.d.ts +0 -3
- package/dist/debugger/events/domain-summarize.js +0 -107
- package/dist/debugger/events/family.d.ts +0 -8
- package/dist/debugger/events/family.js +0 -44
- package/dist/runtime/events-api.d.ts +0 -4
- package/dist/runtime/events-api.js +0 -84
package/dist/core/projection.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Predicate, Schema, Stream } from 'effect';
|
|
2
|
+
import { DEFAULT_DEFINITION_VERSION } from './module.js';
|
|
2
3
|
import { isTerminalStatus } from './thread.js';
|
|
3
4
|
export function defineProjection(def) {
|
|
4
5
|
return def;
|
|
@@ -26,8 +27,6 @@ export function projectStream(definition, stream, from) {
|
|
|
26
27
|
const getInitial = () => (from !== undefined ? from : definition.initialState);
|
|
27
28
|
return Stream.runFold(stream, getInitial, (state, event) => event.ephemeral ? state : definition.reduce(state, event));
|
|
28
29
|
}
|
|
29
|
-
// SAFETY: TreeBuildState is folded by reducers; Schema.Unknown is a typed placeholder, not a decoder.
|
|
30
|
-
export const TreeBuildStateSchema = Schema.Unknown;
|
|
31
30
|
function readPayload(event) {
|
|
32
31
|
if (!Predicate.isObject(event.payload)) {
|
|
33
32
|
return {};
|
|
@@ -40,7 +39,6 @@ function readString(obj, key) {
|
|
|
40
39
|
}
|
|
41
40
|
export const threadTree = defineProjection({
|
|
42
41
|
name: 'threadTree',
|
|
43
|
-
shape: TreeBuildStateSchema,
|
|
44
42
|
initialState: { runId: '', records: {}, rootThreadId: null },
|
|
45
43
|
reduce(state, event) {
|
|
46
44
|
const payload = readPayload(event);
|
|
@@ -57,6 +55,7 @@ export const threadTree = defineProjection({
|
|
|
57
55
|
const threadId = readString(payload, 'threadId') ?? event.threadId;
|
|
58
56
|
const kind = readString(payload, 'kind');
|
|
59
57
|
const definitionName = readString(payload, 'definitionName');
|
|
58
|
+
const definitionVersion = readString(payload, 'definitionVersion') ?? DEFAULT_DEFINITION_VERSION;
|
|
60
59
|
if (!threadId || !kind || !definitionName) {
|
|
61
60
|
return { ...state, runId: event.runId };
|
|
62
61
|
}
|
|
@@ -66,6 +65,7 @@ export const threadTree = defineProjection({
|
|
|
66
65
|
threadId,
|
|
67
66
|
kind,
|
|
68
67
|
definitionName,
|
|
68
|
+
definitionVersion,
|
|
69
69
|
parentThreadId,
|
|
70
70
|
status: 'running',
|
|
71
71
|
input: payload.input ?? null,
|
|
@@ -173,10 +173,13 @@ export function toThreadTree(state) {
|
|
|
173
173
|
runId: state.runId,
|
|
174
174
|
status: 'running',
|
|
175
175
|
rootThreadId: state.rootThreadId,
|
|
176
|
+
startIdentity: null,
|
|
176
177
|
threads: state.records,
|
|
177
178
|
waits: {},
|
|
178
179
|
outstandingEffects: [],
|
|
180
|
+
effectExecutions: {},
|
|
179
181
|
completedEffectIds: [],
|
|
182
|
+
processedIdempotencyKeys: [],
|
|
180
183
|
});
|
|
181
184
|
}
|
|
182
185
|
export function treeFromRun(state) {
|
|
@@ -196,6 +199,7 @@ export function treeFromRun(state) {
|
|
|
196
199
|
threadId: record.threadId,
|
|
197
200
|
kind: record.kind,
|
|
198
201
|
definitionName: record.definitionName,
|
|
202
|
+
definitionVersion: record.definitionVersion,
|
|
199
203
|
status: isWaiting ? 'waiting' : record.status,
|
|
200
204
|
parentThreadId: record.parentThreadId,
|
|
201
205
|
children: (byParent.get(record.threadId) ?? []).map(toNode),
|
|
@@ -210,13 +214,13 @@ export function treeFromRun(state) {
|
|
|
210
214
|
};
|
|
211
215
|
}
|
|
212
216
|
export const TimelineEntrySchema = Schema.Struct({
|
|
213
|
-
seq: Schema.
|
|
217
|
+
seq: Schema.Finite,
|
|
214
218
|
id: Schema.String,
|
|
215
219
|
type: Schema.String,
|
|
216
220
|
threadId: Schema.NullOr(Schema.String),
|
|
217
221
|
causationId: Schema.NullOr(Schema.String),
|
|
218
222
|
effectId: Schema.NullOr(Schema.String),
|
|
219
|
-
ts: Schema.
|
|
223
|
+
ts: Schema.Finite,
|
|
220
224
|
});
|
|
221
225
|
export const TimelineSchema = Schema.mutable(Schema.Array(TimelineEntrySchema));
|
|
222
226
|
export const timeline = defineProjection({
|
package/dist/core/protocol.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
import { type EventInputOf, type EventsOfCatalog } from './catalog';
|
|
3
|
-
import type
|
|
4
|
-
export declare const WaitConditionSchema: Schema.Union<readonly [Schema.Struct<{
|
|
5
|
-
readonly type: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
|
|
6
|
-
readonly match: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
7
|
-
}>, Schema.Struct<{
|
|
8
|
-
readonly timerAt: Schema.Number;
|
|
9
|
-
}>]>;
|
|
3
|
+
import { WaitConditionSchema, type WaitCondition } from './effects';
|
|
10
4
|
export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime", {
|
|
11
5
|
'run.started': Schema.Struct<{
|
|
12
6
|
readonly rootThreadId: Schema.optional<Schema.String>;
|
|
13
7
|
readonly kind: Schema.String;
|
|
14
8
|
readonly definitionName: Schema.String;
|
|
9
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
15
10
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
11
|
+
readonly requestedThreadId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
16
12
|
}>;
|
|
17
13
|
'run.completed': Schema.Struct<{
|
|
18
14
|
readonly output: Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
19
15
|
readonly error: Schema.NullOr<Schema.String>;
|
|
20
16
|
}>;
|
|
17
|
+
'run.cancelled': Schema.Struct<{
|
|
18
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
19
|
+
}>;
|
|
21
20
|
'thread.started': Schema.Struct<{
|
|
22
21
|
readonly threadId: Schema.String;
|
|
23
22
|
readonly kind: Schema.String;
|
|
24
23
|
readonly definitionName: Schema.String;
|
|
24
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
25
25
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
26
26
|
readonly parentThreadId: Schema.NullOr<Schema.String>;
|
|
27
27
|
}>;
|
|
@@ -37,6 +37,9 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
37
37
|
readonly threadId: Schema.String;
|
|
38
38
|
readonly reason: Schema.optional<Schema.String>;
|
|
39
39
|
}>;
|
|
40
|
+
'thread.cancel.requested': Schema.Struct<{
|
|
41
|
+
readonly threadId: Schema.String;
|
|
42
|
+
}>;
|
|
40
43
|
'wait.registered': Schema.Struct<{
|
|
41
44
|
readonly waitId: Schema.String;
|
|
42
45
|
readonly threadId: Schema.optional<Schema.String>;
|
|
@@ -44,7 +47,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
44
47
|
readonly type: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
|
|
45
48
|
readonly match: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
46
49
|
}>, Schema.Struct<{
|
|
47
|
-
readonly timerAt: Schema.
|
|
50
|
+
readonly timerAt: Schema.Finite;
|
|
48
51
|
}>]>;
|
|
49
52
|
readonly tag: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
50
53
|
}>;
|
|
@@ -60,7 +63,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
60
63
|
'timer.set': Schema.Struct<{
|
|
61
64
|
readonly timerId: Schema.String;
|
|
62
65
|
readonly waitId: Schema.String;
|
|
63
|
-
readonly wakeAt: Schema.
|
|
66
|
+
readonly wakeAt: Schema.Finite;
|
|
64
67
|
}>;
|
|
65
68
|
'timer.fired': Schema.Struct<{
|
|
66
69
|
readonly timerId: Schema.String;
|
|
@@ -70,8 +73,62 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
70
73
|
readonly effectId: Schema.String;
|
|
71
74
|
readonly error: Schema.String;
|
|
72
75
|
}>;
|
|
76
|
+
'effect.attempt.started': Schema.Struct<{
|
|
77
|
+
readonly effectId: Schema.String;
|
|
78
|
+
readonly attempt: Schema.Finite;
|
|
79
|
+
}>;
|
|
80
|
+
'effect.queued': Schema.Struct<{
|
|
81
|
+
readonly effectId: Schema.String;
|
|
82
|
+
readonly attempt: Schema.Finite;
|
|
83
|
+
readonly deadlineAt: Schema.NullOr<Schema.Finite>;
|
|
84
|
+
}>;
|
|
85
|
+
'effect.dispatched': Schema.Struct<{
|
|
86
|
+
readonly effectId: Schema.String;
|
|
87
|
+
readonly attempt: Schema.Finite;
|
|
88
|
+
readonly deadlineAt: Schema.NullOr<Schema.Finite>;
|
|
89
|
+
}>;
|
|
90
|
+
'effect.worker.started': Schema.Struct<{
|
|
91
|
+
readonly effectId: Schema.String;
|
|
92
|
+
readonly attempt: Schema.Finite;
|
|
93
|
+
readonly deadlineAt: Schema.NullOr<Schema.Finite>;
|
|
94
|
+
}>;
|
|
95
|
+
'effect.heartbeat': Schema.Struct<{
|
|
96
|
+
readonly effectId: Schema.String;
|
|
97
|
+
readonly attempt: Schema.Finite;
|
|
98
|
+
readonly heartbeatAt: Schema.Finite;
|
|
99
|
+
readonly deadlineAt: Schema.NullOr<Schema.Finite>;
|
|
100
|
+
}>;
|
|
101
|
+
'effect.cancel.requested': Schema.Struct<{
|
|
102
|
+
readonly effectId: Schema.String;
|
|
103
|
+
readonly attempt: Schema.Finite;
|
|
104
|
+
readonly deadlineAt: Schema.NullOr<Schema.Finite>;
|
|
105
|
+
}>;
|
|
106
|
+
'effect.cancelled': Schema.Struct<{
|
|
107
|
+
readonly effectId: Schema.String;
|
|
108
|
+
readonly attempt: Schema.Finite;
|
|
109
|
+
}>;
|
|
110
|
+
'effect.completed': Schema.Struct<{
|
|
111
|
+
readonly effectId: Schema.String;
|
|
112
|
+
readonly attempt: Schema.Finite;
|
|
113
|
+
}>;
|
|
114
|
+
'effect.timed_out': Schema.Struct<{
|
|
115
|
+
readonly effectId: Schema.String;
|
|
116
|
+
readonly attempt: Schema.Finite;
|
|
117
|
+
readonly timeout: Schema.String;
|
|
118
|
+
}>;
|
|
119
|
+
'effect.ambiguous': Schema.Struct<{
|
|
120
|
+
readonly effectId: Schema.String;
|
|
121
|
+
readonly attempt: Schema.Finite;
|
|
122
|
+
readonly error: Schema.String;
|
|
123
|
+
}>;
|
|
124
|
+
'effect.retry.scheduled': Schema.Struct<{
|
|
125
|
+
readonly effectId: Schema.String;
|
|
126
|
+
readonly attempt: Schema.Finite;
|
|
127
|
+
readonly nextAttemptAt: Schema.Finite;
|
|
128
|
+
readonly error: Schema.String;
|
|
129
|
+
}>;
|
|
73
130
|
'snapshot.taken': Schema.Struct<{
|
|
74
|
-
readonly seq: Schema.
|
|
131
|
+
readonly seq: Schema.Finite;
|
|
75
132
|
readonly stateHash: Schema.String;
|
|
76
133
|
readonly state: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
77
134
|
}>;
|
|
@@ -81,7 +138,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
|
|
|
81
138
|
}>;
|
|
82
139
|
export type ProtocolEvent = EventsOfCatalog<typeof protocolCatalog>;
|
|
83
140
|
export type ProtocolEventInput = EventInputOf<typeof protocolCatalog>;
|
|
84
|
-
export declare const PROTOCOL_TYPES: readonly ['runtime.run.started', 'runtime.run.completed', 'runtime.thread.started', 'runtime.thread.completed', 'runtime.thread.failed', 'runtime.thread.cancelled', 'runtime.wait.registered', 'runtime.wait.satisfied', 'runtime.timer.set', 'runtime.timer.fired', 'runtime.effect.failed', 'runtime.snapshot.taken', 'runtime.signal.received'];
|
|
141
|
+
export declare const PROTOCOL_TYPES: readonly ['runtime.run.started', 'runtime.run.completed', 'runtime.run.cancelled', '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'];
|
|
85
142
|
export type ProtocolEventType = (typeof PROTOCOL_TYPES)[number];
|
|
86
143
|
export declare function isProtocolType(type: string): type is ProtocolEventType;
|
|
87
144
|
export type RunStartedPayload = Schema.Schema.Type<(typeof protocolCatalog.entries)['run.started']>;
|
package/dist/core/protocol.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
1
|
+
import { Effect, Schema } from 'effect';
|
|
2
2
|
import { defineEventCatalog } from './catalog.js';
|
|
3
|
+
import { WaitConditionSchema } from './effects.js';
|
|
3
4
|
import { JsonValueSchema } from './envelope.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
match: Schema.optional(JsonValueSchema),
|
|
7
|
-
});
|
|
8
|
-
const WaitOnTimerSchema = Schema.Struct({
|
|
9
|
-
timerAt: Schema.Number,
|
|
10
|
-
});
|
|
11
|
-
export const WaitConditionSchema = Schema.Union([WaitOnEventSchema, WaitOnTimerSchema]);
|
|
5
|
+
import { DEFAULT_DEFINITION_VERSION } from './module.js';
|
|
6
|
+
const DefinitionVersionSchema = Schema.String.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_DEFINITION_VERSION)));
|
|
12
7
|
export const protocolCatalog = defineEventCatalog('runtime', {
|
|
13
8
|
'run.started': Schema.Struct({
|
|
14
9
|
rootThreadId: Schema.optional(Schema.String),
|
|
15
10
|
kind: Schema.String,
|
|
16
11
|
definitionName: Schema.String,
|
|
12
|
+
definitionVersion: DefinitionVersionSchema,
|
|
17
13
|
input: JsonValueSchema,
|
|
14
|
+
requestedThreadId: Schema.optional(Schema.NullOr(Schema.String)),
|
|
18
15
|
}),
|
|
19
16
|
'run.completed': Schema.Struct({
|
|
20
17
|
output: Schema.NullOr(JsonValueSchema),
|
|
21
18
|
error: Schema.NullOr(Schema.String),
|
|
22
19
|
}),
|
|
20
|
+
'run.cancelled': Schema.Struct({
|
|
21
|
+
reason: Schema.optional(Schema.String),
|
|
22
|
+
}),
|
|
23
23
|
'thread.started': Schema.Struct({
|
|
24
24
|
threadId: Schema.String,
|
|
25
25
|
kind: Schema.String,
|
|
26
26
|
definitionName: Schema.String,
|
|
27
|
+
definitionVersion: DefinitionVersionSchema,
|
|
27
28
|
input: JsonValueSchema,
|
|
28
29
|
parentThreadId: Schema.NullOr(Schema.String),
|
|
29
30
|
}),
|
|
@@ -39,6 +40,9 @@ export const protocolCatalog = defineEventCatalog('runtime', {
|
|
|
39
40
|
threadId: Schema.String,
|
|
40
41
|
reason: Schema.optional(Schema.String),
|
|
41
42
|
}),
|
|
43
|
+
'thread.cancel.requested': Schema.Struct({
|
|
44
|
+
threadId: Schema.String,
|
|
45
|
+
}),
|
|
42
46
|
'wait.registered': Schema.Struct({
|
|
43
47
|
waitId: Schema.String,
|
|
44
48
|
threadId: Schema.optional(Schema.String),
|
|
@@ -57,7 +61,7 @@ export const protocolCatalog = defineEventCatalog('runtime', {
|
|
|
57
61
|
'timer.set': Schema.Struct({
|
|
58
62
|
timerId: Schema.String,
|
|
59
63
|
waitId: Schema.String,
|
|
60
|
-
wakeAt: Schema.
|
|
64
|
+
wakeAt: Schema.Finite,
|
|
61
65
|
}),
|
|
62
66
|
'timer.fired': Schema.Struct({
|
|
63
67
|
timerId: Schema.String,
|
|
@@ -67,8 +71,62 @@ export const protocolCatalog = defineEventCatalog('runtime', {
|
|
|
67
71
|
effectId: Schema.String,
|
|
68
72
|
error: Schema.String,
|
|
69
73
|
}),
|
|
74
|
+
'effect.attempt.started': Schema.Struct({
|
|
75
|
+
effectId: Schema.String,
|
|
76
|
+
attempt: Schema.Finite,
|
|
77
|
+
}),
|
|
78
|
+
'effect.queued': Schema.Struct({
|
|
79
|
+
effectId: Schema.String,
|
|
80
|
+
attempt: Schema.Finite,
|
|
81
|
+
deadlineAt: Schema.NullOr(Schema.Finite),
|
|
82
|
+
}),
|
|
83
|
+
'effect.dispatched': Schema.Struct({
|
|
84
|
+
effectId: Schema.String,
|
|
85
|
+
attempt: Schema.Finite,
|
|
86
|
+
deadlineAt: Schema.NullOr(Schema.Finite),
|
|
87
|
+
}),
|
|
88
|
+
'effect.worker.started': Schema.Struct({
|
|
89
|
+
effectId: Schema.String,
|
|
90
|
+
attempt: Schema.Finite,
|
|
91
|
+
deadlineAt: Schema.NullOr(Schema.Finite),
|
|
92
|
+
}),
|
|
93
|
+
'effect.heartbeat': Schema.Struct({
|
|
94
|
+
effectId: Schema.String,
|
|
95
|
+
attempt: Schema.Finite,
|
|
96
|
+
heartbeatAt: Schema.Finite,
|
|
97
|
+
deadlineAt: Schema.NullOr(Schema.Finite),
|
|
98
|
+
}),
|
|
99
|
+
'effect.cancel.requested': Schema.Struct({
|
|
100
|
+
effectId: Schema.String,
|
|
101
|
+
attempt: Schema.Finite,
|
|
102
|
+
deadlineAt: Schema.NullOr(Schema.Finite),
|
|
103
|
+
}),
|
|
104
|
+
'effect.cancelled': Schema.Struct({
|
|
105
|
+
effectId: Schema.String,
|
|
106
|
+
attempt: Schema.Finite,
|
|
107
|
+
}),
|
|
108
|
+
'effect.completed': Schema.Struct({
|
|
109
|
+
effectId: Schema.String,
|
|
110
|
+
attempt: Schema.Finite,
|
|
111
|
+
}),
|
|
112
|
+
'effect.timed_out': Schema.Struct({
|
|
113
|
+
effectId: Schema.String,
|
|
114
|
+
attempt: Schema.Finite,
|
|
115
|
+
timeout: Schema.String,
|
|
116
|
+
}),
|
|
117
|
+
'effect.ambiguous': Schema.Struct({
|
|
118
|
+
effectId: Schema.String,
|
|
119
|
+
attempt: Schema.Finite,
|
|
120
|
+
error: Schema.String,
|
|
121
|
+
}),
|
|
122
|
+
'effect.retry.scheduled': Schema.Struct({
|
|
123
|
+
effectId: Schema.String,
|
|
124
|
+
attempt: Schema.Finite,
|
|
125
|
+
nextAttemptAt: Schema.Finite,
|
|
126
|
+
error: Schema.String,
|
|
127
|
+
}),
|
|
70
128
|
'snapshot.taken': Schema.Struct({
|
|
71
|
-
seq: Schema.
|
|
129
|
+
seq: Schema.Finite,
|
|
72
130
|
stateHash: Schema.String,
|
|
73
131
|
state: Schema.optional(JsonValueSchema),
|
|
74
132
|
}),
|
|
@@ -79,15 +137,28 @@ export const protocolCatalog = defineEventCatalog('runtime', {
|
|
|
79
137
|
export const PROTOCOL_TYPES = [
|
|
80
138
|
'runtime.run.started',
|
|
81
139
|
'runtime.run.completed',
|
|
140
|
+
'runtime.run.cancelled',
|
|
82
141
|
'runtime.thread.started',
|
|
83
142
|
'runtime.thread.completed',
|
|
84
143
|
'runtime.thread.failed',
|
|
85
144
|
'runtime.thread.cancelled',
|
|
145
|
+
'runtime.thread.cancel.requested',
|
|
86
146
|
'runtime.wait.registered',
|
|
87
147
|
'runtime.wait.satisfied',
|
|
88
148
|
'runtime.timer.set',
|
|
89
149
|
'runtime.timer.fired',
|
|
90
150
|
'runtime.effect.failed',
|
|
151
|
+
'runtime.effect.attempt.started',
|
|
152
|
+
'runtime.effect.queued',
|
|
153
|
+
'runtime.effect.dispatched',
|
|
154
|
+
'runtime.effect.worker.started',
|
|
155
|
+
'runtime.effect.heartbeat',
|
|
156
|
+
'runtime.effect.cancel.requested',
|
|
157
|
+
'runtime.effect.cancelled',
|
|
158
|
+
'runtime.effect.completed',
|
|
159
|
+
'runtime.effect.timed_out',
|
|
160
|
+
'runtime.effect.ambiguous',
|
|
161
|
+
'runtime.effect.retry.scheduled',
|
|
91
162
|
'runtime.snapshot.taken',
|
|
92
163
|
'runtime.signal.received',
|
|
93
164
|
];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import type { RegisteredDefinition } from './module';
|
|
3
|
+
import { type RunState } from './state';
|
|
4
|
+
/** A registered definition as `GET /definitions` publishes it. */
|
|
5
|
+
export declare const PublishedDefinitionSchema: Schema.Struct<{
|
|
6
|
+
readonly kind: Schema.String;
|
|
7
|
+
readonly name: Schema.String;
|
|
8
|
+
readonly version: Schema.String;
|
|
9
|
+
readonly description: Schema.optional<Schema.String>;
|
|
10
|
+
/** JSON Schema derived from the definition's `input`. */
|
|
11
|
+
readonly inputSchema: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
12
|
+
}>;
|
|
13
|
+
export type PublishedDefinition = Schema.Schema.Type<typeof PublishedDefinitionSchema>;
|
|
14
|
+
export declare const DefinitionCatalogSchema: Schema.Struct<{
|
|
15
|
+
readonly definitions: Schema.$Array<Schema.Struct<{
|
|
16
|
+
readonly kind: Schema.String;
|
|
17
|
+
readonly name: Schema.String;
|
|
18
|
+
readonly version: Schema.String;
|
|
19
|
+
readonly description: Schema.optional<Schema.String>;
|
|
20
|
+
/** JSON Schema derived from the definition's `input`. */
|
|
21
|
+
readonly inputSchema: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
22
|
+
}>>;
|
|
23
|
+
readonly projections: Schema.$Array<Schema.String>;
|
|
24
|
+
}>;
|
|
25
|
+
export type DefinitionCatalog = Schema.Schema.Type<typeof DefinitionCatalogSchema>;
|
|
26
|
+
export declare function publishDefinition(definition: RegisteredDefinition): PublishedDefinition;
|
|
27
|
+
/** A run as `GET /runs/summaries` lists it. */
|
|
28
|
+
export declare const RunSummarySchema: Schema.Struct<{
|
|
29
|
+
readonly runId: Schema.String;
|
|
30
|
+
readonly status: Schema.Union<readonly [Schema.Literal<"running">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"cancelled">]>;
|
|
31
|
+
readonly kind: Schema.NullOr<Schema.String>;
|
|
32
|
+
readonly definitionName: Schema.NullOr<Schema.String>;
|
|
33
|
+
}>;
|
|
34
|
+
export type RunSummary = Schema.Schema.Type<typeof RunSummarySchema>;
|
|
35
|
+
export declare function summarizeRun(state: RunState): RunSummary;
|
|
36
|
+
export declare const RunSummariesSchema: Schema.Struct<{
|
|
37
|
+
readonly runs: Schema.$Array<Schema.Struct<{
|
|
38
|
+
readonly runId: Schema.String;
|
|
39
|
+
readonly status: Schema.Union<readonly [Schema.Literal<"running">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"cancelled">]>;
|
|
40
|
+
readonly kind: Schema.NullOr<Schema.String>;
|
|
41
|
+
readonly definitionName: Schema.NullOr<Schema.String>;
|
|
42
|
+
}>>;
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { JsonValueSchema } from './envelope.js';
|
|
3
|
+
import { jsonSchemaOfInput } from './schema.js';
|
|
4
|
+
import { RunStateSchema } from './state.js';
|
|
5
|
+
/** A registered definition as `GET /definitions` publishes it. */
|
|
6
|
+
export const PublishedDefinitionSchema = Schema.Struct({
|
|
7
|
+
kind: Schema.String,
|
|
8
|
+
name: Schema.String,
|
|
9
|
+
version: Schema.String,
|
|
10
|
+
description: Schema.optional(Schema.String),
|
|
11
|
+
/** JSON Schema derived from the definition's `input`. */
|
|
12
|
+
inputSchema: Schema.optional(JsonValueSchema),
|
|
13
|
+
});
|
|
14
|
+
export const DefinitionCatalogSchema = Schema.Struct({
|
|
15
|
+
definitions: Schema.Array(PublishedDefinitionSchema),
|
|
16
|
+
projections: Schema.Array(Schema.String),
|
|
17
|
+
});
|
|
18
|
+
export function publishDefinition(definition) {
|
|
19
|
+
return {
|
|
20
|
+
kind: definition.kind,
|
|
21
|
+
name: definition.name,
|
|
22
|
+
version: definition.version,
|
|
23
|
+
description: definition.description,
|
|
24
|
+
inputSchema: jsonSchemaOfInput(definition.input),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** A run as `GET /runs/summaries` lists it. */
|
|
28
|
+
export const RunSummarySchema = Schema.Struct({
|
|
29
|
+
runId: Schema.String,
|
|
30
|
+
status: RunStateSchema.fields.status,
|
|
31
|
+
kind: Schema.NullOr(Schema.String),
|
|
32
|
+
definitionName: Schema.NullOr(Schema.String),
|
|
33
|
+
});
|
|
34
|
+
export function summarizeRun(state) {
|
|
35
|
+
return {
|
|
36
|
+
runId: state.runId,
|
|
37
|
+
status: state.status,
|
|
38
|
+
kind: state.startIdentity?.kind ?? null,
|
|
39
|
+
definitionName: state.startIdentity?.definitionName ?? null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export const RunSummariesSchema = Schema.Struct({
|
|
43
|
+
runs: Schema.Array(RunSummarySchema),
|
|
44
|
+
});
|