@lostgradient/weft 0.23.0 → 0.24.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/README.md +72 -4
- package/dist/cli/codegen-emit-dedup.d.ts +81 -0
- package/dist/cli/codegen-emit-dedup.js +45 -0
- package/dist/cli/codegen-emit-registry.d.ts +90 -0
- package/dist/cli/codegen-emit-registry.js +50 -0
- package/dist/cli/codegen-emit.d.ts +26 -39
- package/dist/cli/codegen-emit.js +4 -27
- package/dist/cli/codegen-validate.d.ts +49 -0
- package/dist/cli/codegen-validate.js +186 -0
- package/dist/cli/codegen.js +6 -87
- package/dist/cli/generated/operation-catalog.snapshot.json +287 -3
- package/dist/cli/generated/operation-client.generated.d.ts +324 -10
- package/dist/cli/generated/operation-client.generated.js +12 -0
- package/dist/cli/output.js +1 -1
- package/dist/cli/storage-factory.js +2 -0
- package/dist/cli/workflow-commands.js +2 -0
- package/dist/cli-main.js +1 -1
- package/dist/core/application-payload-digest.d.ts +42 -0
- package/dist/core/application-payload-digest.js +76 -0
- package/dist/core/application-primitive-abort.d.ts +50 -0
- package/dist/core/application-primitive-abort.js +40 -0
- package/dist/core/application-primitive-attempt-registry.d.ts +74 -0
- package/dist/core/application-primitive-attempt-registry.js +73 -0
- package/dist/core/application-primitive-codec.d.ts +36 -0
- package/dist/core/application-primitive-codec.js +56 -0
- package/dist/core/application-primitive-commit.d.ts +67 -0
- package/dist/core/application-primitive-commit.js +66 -0
- package/dist/core/application-primitive-guards.d.ts +62 -0
- package/dist/core/application-primitive-guards.js +89 -0
- package/dist/core/application-primitive-payload.d.ts +29 -0
- package/dist/core/application-primitive-payload.js +65 -0
- package/dist/core/application-primitive-timing.d.ts +18 -0
- package/dist/core/application-primitive-timing.js +22 -0
- package/dist/core/atomic-state.js +2 -0
- package/dist/core/catalog/codec.d.ts +40 -0
- package/dist/core/catalog/codec.js +45 -0
- package/dist/core/catalog/errors.d.ts +104 -0
- package/dist/core/catalog/errors.js +41 -0
- package/dist/core/catalog/index.d.ts +25 -0
- package/dist/core/catalog/index.js +15 -0
- package/dist/core/catalog/reference-counts.d.ts +105 -0
- package/dist/core/catalog/reference-counts.js +28 -0
- package/dist/core/catalog/removal.d.ts +52 -0
- package/dist/core/catalog/removal.js +14 -0
- package/dist/core/catalog/storage-io.d.ts +78 -0
- package/dist/core/catalog/storage-io.js +106 -0
- package/dist/core/catalog/types.d.ts +108 -0
- package/dist/core/catalog/types.js +0 -0
- package/dist/core/catalog/workflow-catalog.d.ts +165 -0
- package/dist/core/catalog/workflow-catalog.js +198 -0
- package/dist/core/compare-codepoint.d.ts +13 -0
- package/dist/core/compare-codepoint.js +7 -0
- package/dist/core/compression.js +2 -0
- package/dist/core/context/attributes.d.ts +1 -1
- package/dist/core/context/durable-operations.d.ts +2 -2
- package/dist/core/context/index.js +5 -3
- package/dist/core/context/state-namespace.d.ts +1 -1
- package/dist/core/contract/build.d.ts +64 -0
- package/dist/core/contract/build.js +99 -0
- package/dist/core/contract/compatibility.d.ts +187 -0
- package/dist/core/contract/compatibility.js +37 -0
- package/dist/core/contract/failure.d.ts +64 -0
- package/dist/core/contract/failure.js +4 -0
- package/dist/core/contract/hash.d.ts +92 -0
- package/dist/core/contract/hash.js +34 -0
- package/dist/core/contract/index.d.ts +21 -0
- package/dist/core/contract/index.js +22 -0
- package/dist/core/contract/limits.d.ts +74 -0
- package/dist/core/contract/limits.js +1 -0
- package/dist/core/contract/manifest-parse-schema.d.ts +37 -0
- package/dist/core/contract/manifest-parse-schema.js +106 -0
- package/dist/core/contract/manifest-parse.d.ts +76 -0
- package/dist/core/contract/manifest-parse.js +189 -0
- package/dist/core/contract/manifest.d.ts +56 -0
- package/dist/core/contract/manifest.js +31 -0
- package/dist/core/contract/normalize.d.ts +97 -0
- package/dist/core/contract/normalize.js +127 -0
- package/dist/core/contract/revision.d.ts +29 -0
- package/dist/core/contract/revision.js +5 -0
- package/dist/core/contract/types.d.ts +274 -0
- package/dist/core/contract/types.js +1 -0
- package/dist/core/engine/catalog-activation.d.ts +40 -0
- package/dist/core/engine/catalog-activation.js +17 -0
- package/dist/core/engine/catalog-events.d.ts +36 -0
- package/dist/core/engine/catalog-events.js +15 -0
- package/dist/core/engine/catalog-readiness.d.ts +49 -0
- package/dist/core/engine/catalog-readiness.js +59 -0
- package/dist/core/engine/catalog-removal.d.ts +132 -0
- package/dist/core/engine/catalog-removal.js +70 -0
- package/dist/core/engine/construction.d.ts +1 -1
- package/dist/core/engine/construction.js +4 -2
- package/dist/core/engine/disposal.js +9 -0
- package/dist/core/engine/engine-workflows-namespace.d.ts +130 -0
- package/dist/core/engine/engine-workflows-namespace.js +49 -0
- package/dist/core/engine/finalizer-metadata.d.ts +22 -0
- package/dist/core/engine/finalizer-metadata.js +12 -0
- package/dist/core/engine/handle-result.js +2 -0
- package/dist/core/engine/index.d.ts +83 -0
- package/dist/core/engine/index.js +61 -0
- package/dist/core/engine/internals.d.ts +44 -1
- package/dist/core/engine/internals.js +6 -0
- package/dist/core/engine/lifecycle/start.js +3 -0
- package/dist/core/engine/registration.d.ts +76 -0
- package/dist/core/engine/registration.js +12 -6
- package/dist/core/engine/source-registration.d.ts +42 -0
- package/dist/core/engine/source-registration.js +36 -0
- package/dist/core/engine/source-resolution.d.ts +85 -0
- package/dist/core/engine/source-resolution.js +119 -0
- package/dist/core/engine/validation.js +2 -2
- package/dist/core/events/catalog-events.d.ts +117 -0
- package/dist/core/events/catalog-events.js +62 -0
- package/dist/core/events/event-map.d.ts +6 -0
- package/dist/core/events/index.d.ts +1 -0
- package/dist/core/events/index.js +1 -0
- package/dist/core/mailbox-admission.d.ts +26 -0
- package/dist/core/mailbox-admission.js +130 -0
- package/dist/core/mailbox-claims.d.ts +251 -0
- package/dist/core/mailbox-claims.js +0 -0
- package/dist/core/mailbox-codec.d.ts +32 -0
- package/dist/core/mailbox-codec.js +221 -0
- package/dist/core/mailbox-contract.d.ts +290 -0
- package/dist/core/mailbox-contract.js +0 -0
- package/dist/core/mailbox-delivery.d.ts +37 -0
- package/dist/core/mailbox-delivery.js +193 -0
- package/dist/core/mailbox-guards.d.ts +78 -0
- package/dist/core/mailbox-guards.js +58 -0
- package/dist/core/mailbox-index-codec.d.ts +41 -0
- package/dist/core/mailbox-index-codec.js +71 -0
- package/dist/core/mailbox-internals.d.ts +156 -0
- package/dist/core/mailbox-internals.js +154 -0
- package/dist/core/mailbox-maintenance.d.ts +29 -0
- package/dist/core/mailbox-maintenance.js +196 -0
- package/dist/core/mailbox-settlement.d.ts +69 -0
- package/dist/core/mailbox-settlement.js +206 -0
- package/dist/core/mailbox-storage.d.ts +117 -0
- package/dist/core/mailbox-storage.js +115 -0
- package/dist/core/mailbox-transition-helpers.d.ts +70 -0
- package/dist/core/mailbox-transition-helpers.js +43 -0
- package/dist/core/mailbox-transitions-recovery.d.ts +28 -0
- package/dist/core/mailbox-transitions-recovery.js +64 -0
- package/dist/core/mailbox-transitions.d.ts +138 -0
- package/dist/core/mailbox-transitions.js +180 -0
- package/dist/core/mailbox-types.d.ts +406 -0
- package/dist/core/mailbox-types.js +16 -0
- package/dist/core/mailbox-validation.d.ts +65 -0
- package/dist/core/mailbox-validation.js +73 -0
- package/dist/core/mailbox-waits.d.ts +50 -0
- package/dist/core/mailbox-waits.js +97 -0
- package/dist/core/mailbox.d.ts +163 -0
- package/dist/core/mailbox.js +211 -0
- package/dist/core/outbox-claims.d.ts +307 -0
- package/dist/core/outbox-claims.js +0 -0
- package/dist/core/outbox-codec.d.ts +24 -0
- package/dist/core/outbox-codec.js +257 -0
- package/dist/core/outbox-contract.d.ts +346 -0
- package/dist/core/outbox-contract.js +0 -0
- package/dist/core/outbox-delivery.d.ts +34 -0
- package/dist/core/outbox-delivery.js +149 -0
- package/dist/core/outbox-drain.d.ts +29 -0
- package/dist/core/outbox-drain.js +158 -0
- package/dist/core/outbox-enqueue.d.ts +24 -0
- package/dist/core/outbox-enqueue.js +115 -0
- package/dist/core/outbox-guards.d.ts +76 -0
- package/dist/core/outbox-guards.js +60 -0
- package/dist/core/outbox-index-codec.d.ts +33 -0
- package/dist/core/outbox-index-codec.js +71 -0
- package/dist/core/outbox-internals.d.ts +99 -0
- package/dist/core/outbox-internals.js +159 -0
- package/dist/core/outbox-listing.d.ts +12 -0
- package/dist/core/outbox-listing.js +38 -0
- package/dist/core/outbox-maintenance.d.ts +28 -0
- package/dist/core/outbox-maintenance.js +191 -0
- package/dist/core/outbox-operations.d.ts +18 -0
- package/dist/core/outbox-operations.js +46 -0
- package/dist/core/outbox-runner.d.ts +30 -0
- package/dist/core/outbox-runner.js +217 -0
- package/dist/core/outbox-settlement.d.ts +57 -0
- package/dist/core/outbox-settlement.js +183 -0
- package/dist/core/outbox-storage.d.ts +107 -0
- package/dist/core/outbox-storage.js +127 -0
- package/dist/core/outbox-transition-helpers.d.ts +83 -0
- package/dist/core/outbox-transition-helpers.js +63 -0
- package/dist/core/outbox-transitions-recovery.d.ts +30 -0
- package/dist/core/outbox-transitions-recovery.js +42 -0
- package/dist/core/outbox-transitions.d.ts +145 -0
- package/dist/core/outbox-transitions.js +236 -0
- package/dist/core/outbox-types.d.ts +400 -0
- package/dist/core/outbox-types.js +20 -0
- package/dist/core/outbox-validation.d.ts +101 -0
- package/dist/core/outbox-validation.js +127 -0
- package/dist/core/outbox-waits.d.ts +39 -0
- package/dist/core/outbox-waits.js +88 -0
- package/dist/core/outbox.d.ts +156 -0
- package/dist/core/outbox.js +234 -0
- package/dist/core/registry-limits.d.ts +49 -0
- package/dist/core/registry-limits.js +10 -0
- package/dist/core/registry-schema-conversion.d.ts +20 -0
- package/dist/core/registry-schema-conversion.js +22 -0
- package/dist/core/registry-snapshot.d.ts +91 -42
- package/dist/core/registry-snapshot.js +39 -77
- package/dist/core/registry-workflow-contract-draft.d.ts +32 -0
- package/dist/core/registry-workflow-contract-draft.js +28 -0
- package/dist/core/registry-workflow-manifest.d.ts +122 -0
- package/dist/core/registry-workflow-manifest.js +92 -0
- package/dist/core/source/errors.d.ts +55 -0
- package/dist/core/source/errors.js +13 -0
- package/dist/core/source/index.d.ts +19 -0
- package/dist/core/source/index.js +4 -0
- package/dist/core/source/resolvers.d.ts +45 -0
- package/dist/core/source/resolvers.js +9 -0
- package/dist/core/source/types.d.ts +211 -0
- package/dist/core/source/types.js +0 -0
- package/dist/core/source/validate.d.ts +91 -0
- package/dist/core/source/validate.js +62 -0
- package/dist/core/source/workflow-source.d.ts +43 -0
- package/dist/core/source/workflow-source.js +16 -0
- package/dist/core/types/workflow-registries.d.ts +7 -0
- package/dist/core/types/workflow-registry.d.ts +12 -0
- package/dist/core/versioning.js +2 -0
- package/dist/core/weft-error.d.ts +1 -1
- package/dist/core/weft-error.js +9 -1
- package/dist/http.js +2 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +50 -0
- package/dist/indexeddb.js +1 -1
- package/dist/json-schema.js +3 -3
- package/dist/mcp/resources.js +2 -0
- package/dist/runtime/portable.d.ts +9 -1
- package/dist/server/fault-to-json-rpc.js +3 -1
- package/dist/server/handler/auth-context-principal.js +4 -0
- package/dist/server/json-rpc-http.js +2 -0
- package/dist/server/json-rpc-websocket.js +6 -4
- package/dist/server/operation-catalog/index.d.ts +1 -1
- package/dist/server/operation-catalog/pipeline-helpers.js +2 -0
- package/dist/server/operation-catalog/types.d.ts +17 -0
- package/dist/server/operation-fault.d.ts +3 -0
- package/dist/server/operation-fault.js +3 -1
- package/dist/server/operations/activate-workflow-revision.d.ts +30 -0
- package/dist/server/operations/activate-workflow-revision.js +69 -0
- package/dist/server/operations/fleet-events-subscription.js +1 -1
- package/dist/server/operations/fork-workflow.js +1 -1
- package/dist/server/operations/get-active-workflow-revision.d.ts +32 -0
- package/dist/server/operations/get-active-workflow-revision.js +46 -0
- package/dist/server/operations/get-catalog-diagnostics.d.ts +85 -0
- package/dist/server/operations/get-catalog-diagnostics.js +57 -0
- package/dist/server/operations/get-registry.js +17 -4
- package/dist/server/operations/get-workflow-revision.d.ts +25 -0
- package/dist/server/operations/get-workflow-revision.js +50 -0
- package/dist/server/operations/install-workflow-revision.d.ts +27 -0
- package/dist/server/operations/install-workflow-revision.js +46 -0
- package/dist/server/operations/list-workflow-revisions.d.ts +20 -0
- package/dist/server/operations/list-workflow-revisions.js +40 -0
- package/dist/server/operations/start-or-signal-workflow.js +1 -1
- package/dist/server/operations/start-workflow.js +1 -1
- package/dist/server/operations/static-registrations.js +36 -0
- package/dist/server/operations/storage.js +2 -2
- package/dist/server/operations/submit-review-decision.js +1 -1
- package/dist/server/operations/workflow-catalog-operation-helpers.d.ts +59 -0
- package/dist/server/operations/workflow-catalog-operation-helpers.js +135 -0
- package/dist/server/runtime/websocket-upgrade.js +2 -0
- package/dist/storage/bun-sql.js +49 -6
- package/dist/storage/catalog-keys.d.ts +45 -0
- package/dist/storage/catalog-keys.js +6 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/derived-operations.js +1 -1
- package/dist/storage/index.d.ts +26 -1
- package/dist/storage/interface.d.ts +26 -1
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-encoding.d.ts +15 -0
- package/dist/storage/key-encoding.js +3 -0
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +15 -0
- package/dist/storage/lmdb.d.ts +26 -1
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/mailbox-keys.d.ts +80 -0
- package/dist/storage/mailbox-keys.js +14 -0
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.js +2 -2
- package/dist/storage/node-sqlite-loader.d.ts +1 -1
- package/dist/storage/node-sqlite-loader.js +2 -2
- package/dist/storage/node-sqlite.js +51 -8
- package/dist/storage/outbox-keys.d.ts +77 -0
- package/dist/storage/outbox-keys.js +14 -0
- package/dist/storage/postgres.js +2 -2
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/storage-configuration.d.ts +6 -0
- package/dist/storage/testing.js +1 -1
- package/dist/storage/turso.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-extension.js +1 -1
- package/dist/worker/manifest/registry-contract-builder.d.ts +21 -3
- package/dist/worker/manifest/registry-contract-builder.js +40 -31
- package/package.json +1 -1
|
@@ -129,9 +129,17 @@ export declare function hashString(data: string): string;
|
|
|
129
129
|
* try to resolve or stub. Returns `undefined` in the browser or any runtime
|
|
130
130
|
* lacking `process.getBuiltinModule`, so callers on a browser-reachable path
|
|
131
131
|
* must treat the result as optional rather than throwing at import time.
|
|
132
|
+
*
|
|
133
|
+
* Overloaded per known specifier so callers get the correct module type from
|
|
134
|
+
* the literal `id` argument alone, without an explicit type argument. Add a
|
|
135
|
+
* new literal overload here when a new built-in specifier is loaded through
|
|
136
|
+
* this helper.
|
|
132
137
|
* @internal
|
|
133
138
|
*/
|
|
134
|
-
export declare function tryLoadNodeBuiltin
|
|
139
|
+
export declare function tryLoadNodeBuiltin(id: 'node:fs'): typeof import('node:fs') | undefined;
|
|
140
|
+
export declare function tryLoadNodeBuiltin(id: 'node:fs/promises'): typeof import('node:fs/promises') | undefined;
|
|
141
|
+
export declare function tryLoadNodeBuiltin(id: 'node:zlib'): typeof import('node:zlib') | undefined;
|
|
142
|
+
export declare function tryLoadNodeBuiltin(id: 'node:module'): typeof import('node:module') | undefined;
|
|
135
143
|
/**
|
|
136
144
|
* Return the byte size of a file at the given path.
|
|
137
145
|
*
|
|
@@ -34,7 +34,9 @@ function dataForConflict(data) {
|
|
|
34
34
|
reason: data.reason,
|
|
35
35
|
missingTypes: data.missingTypes === void 0 ? void 0 : [...data.missingTypes],
|
|
36
36
|
missingWorkflowCount: data.missingWorkflowCount,
|
|
37
|
-
samplesTruncated: data.samplesTruncated
|
|
37
|
+
samplesTruncated: data.samplesTruncated,
|
|
38
|
+
currentGeneration: data.currentGeneration,
|
|
39
|
+
compatibilityReasons: data.compatibilityReasons === void 0 ? void 0 : [...data.compatibilityReasons]
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
function dataForNotFound(data) {
|
|
@@ -21,5 +21,9 @@ export function authContextToPrincipal(authContext) {
|
|
|
21
21
|
return principalFromMutualTls({ subject: "mtls-caller", scopes: [] });
|
|
22
22
|
case "public":
|
|
23
23
|
return anonymousPrincipal();
|
|
24
|
+
default: {
|
|
25
|
+
const exhaustiveCheck = authContext.method;
|
|
26
|
+
throw Error(`Unknown auth context method: ${JSON.stringify(exhaustiveCheck)}`);
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
}
|
|
@@ -66,6 +66,8 @@ function dispatchResultToResponse(result) {
|
|
|
66
66
|
return Response.json(result.response, { status: 200, headers: CACHE_CONTROL_HEADERS });
|
|
67
67
|
case "batch":
|
|
68
68
|
return Response.json(result.responses, { status: 200, headers: CACHE_CONTROL_HEADERS });
|
|
69
|
+
default:
|
|
70
|
+
throw Error(`Unknown JSON-RPC dispatch result kind: ${JSON.stringify(result)}`);
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
const CONTENT_LENGTH_PATTERN = /^(0|[1-9]\d*)$/;
|
|
@@ -12,8 +12,13 @@ import {
|
|
|
12
12
|
validateSessionPrimitiveFrame,
|
|
13
13
|
validateSubscribeParams
|
|
14
14
|
} from "./json-rpc-websocket-validation.js";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
executeSubscription
|
|
17
|
+
} from "./operation-catalog.js";
|
|
16
18
|
const DEFAULT_MAX_SUBSCRIPTIONS = 100, DEFAULT_MAX_FRAME_BYTES = 1048576;
|
|
19
|
+
function isSessionPrimitive(method) {
|
|
20
|
+
return method === SESSION_METHODS.SUBSCRIBE || method === WORKFLOW_EVENTS_OPERATION_NAME || method === SESSION_METHODS.FLEET_SUBSCRIBE || method === SESSION_METHODS.UNSUBSCRIBE;
|
|
21
|
+
}
|
|
17
22
|
export function createJsonRpcWebSocketSession(options) {
|
|
18
23
|
const { registry, engine, principal, emitter, feed, fleetFeed } = options, maxSubscriptions = options.maxSubscriptions ?? DEFAULT_MAX_SUBSCRIPTIONS, maxFrameBytes = options.maxFrameBytes ?? DEFAULT_MAX_FRAME_BYTES, transport = options.transport ?? "jsonRpcWebSocket", subscriptions = new Map;
|
|
19
24
|
let emitterBroken = !1, disposed = !1;
|
|
@@ -186,9 +191,6 @@ export function createJsonRpcWebSocketSession(options) {
|
|
|
186
191
|
params: { subscriptionId, reason: "client-unsubscribed" }
|
|
187
192
|
});
|
|
188
193
|
}
|
|
189
|
-
function isSessionPrimitive(method) {
|
|
190
|
-
return method === SESSION_METHODS.SUBSCRIBE || method === WORKFLOW_EVENTS_OPERATION_NAME || method === SESSION_METHODS.FLEET_SUBSCRIBE || method === SESSION_METHODS.UNSUBSCRIBE;
|
|
191
|
-
}
|
|
192
194
|
async function handleSessionPrimitive(validation) {
|
|
193
195
|
const sessionPrimitiveError = validateSessionPrimitiveFrame(validation);
|
|
194
196
|
if (sessionPrimitiveError !== null) {
|
|
@@ -17,6 +17,6 @@ export { executeOperation } from './pipeline.ts';
|
|
|
17
17
|
export { UNIVERSAL_FAULT_DEFAULTS, raiseFault } from './raise-fault.ts';
|
|
18
18
|
export { createOperationRegistry } from './registry.ts';
|
|
19
19
|
export { SubscriptionElementValidationError, executeStream, executeSubscription, } from './stream-pipeline.ts';
|
|
20
|
-
export { OPERATION_NAME_PATTERN, isValidOperationName, validateOperationName, type AuthorizationDecision, type DispatchContext, type DispatchResult, type ErasedOperation, type McpToolMetadata, type OperationContext, type OperationDefinition, type OperationInvocationResult, type OperationKind, type OperationRegistry, type ParameterizedAccessHint, type PipelineTrace, type PipelineTraceMarker, type RegistrableOperation, type StreamOperationInvocation, type SubscriptionOperationInvocation, type TransportAvailability, type UnknownKeyDisposition, type UnknownKeyPolicy, } from './types.ts';
|
|
20
|
+
export { OPERATION_NAME_PATTERN, isValidOperationName, validateOperationName, type AuthorizationDecision, type DispatchContext, type DispatchResult, type ErasedOperation, type McpToolMetadata, type OperationContext, type OperationDefinition, type OperationInvocationResult, type OperationKind, type OperationRegistry, type ParameterizedAccessHint, type PipelineTrace, type PipelineTraceMarker, type RegistrableOperation, type StreamOperationInvocation, type SubscriptionOperationInvocation, type SubscriptionStartEnvelope, type TransportAvailability, type UnknownKeyDisposition, type UnknownKeyPolicy, } from './types.ts';
|
|
21
21
|
export { catalogWorkflow } from './workflow-adapter.ts';
|
|
22
22
|
export type { CatalogWorkflowOptions } from './workflow-adapter.ts';
|
|
@@ -28,6 +28,8 @@ export function transportToAvailabilityKey(transport) {
|
|
|
28
28
|
return "jsonRpcWebSocket";
|
|
29
29
|
case "jsonRpcStdio":
|
|
30
30
|
return "jsonRpcStdio";
|
|
31
|
+
default:
|
|
32
|
+
throw Error(`Unknown transport kind: ${JSON.stringify(transport)}`);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
export function extractTopLevelObjectKeys(schema) {
|
|
@@ -45,6 +45,23 @@ export type SubscriptionOperationInvocation<Element, Envelope> = {
|
|
|
45
45
|
readonly iterable: AsyncIterable<Element>;
|
|
46
46
|
readonly close: () => Promise<void>;
|
|
47
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Envelope acknowledging that a JSON-RPC subscription has started. This is
|
|
50
|
+
* the protocol-level shape the built-in JSON-RPC WebSocket subscriptions
|
|
51
|
+
* (`weft.workflows.events` and the fleet-events subscription in
|
|
52
|
+
* `json-rpc-websocket.ts`) use for their own `outputSchema`/envelope — it is
|
|
53
|
+
* NOT the general contract for every `kind: 'subscription'` operation.
|
|
54
|
+
* `executeSubscription` in `stream-pipeline.ts` stays generic over
|
|
55
|
+
* `Envelope` precisely because a catalog subscription can declare any
|
|
56
|
+
* envelope shape its own `outputSchema` validates; other subscription
|
|
57
|
+
* operations are free to use a different shape (see the
|
|
58
|
+
* `subscriptionId`-only regression case in
|
|
59
|
+
* `operation-catalog/dispatch-audit.test.ts`).
|
|
60
|
+
*/
|
|
61
|
+
export type SubscriptionStartEnvelope = {
|
|
62
|
+
readonly subscriptionId: string;
|
|
63
|
+
readonly cursor: string;
|
|
64
|
+
};
|
|
48
65
|
export type OperationInvocationResult<Output, Element = unknown> = Output | StreamOperationInvocation<Element> | SubscriptionOperationInvocation<Element, Output>;
|
|
49
66
|
/**
|
|
50
67
|
* Metadata that connects an operation-catalog entry to a live MCP tool.
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
* `data` payload forms the basis of cross-transport parity: every fault is
|
|
35
35
|
* serialized consistently across REST and JSON-RPC transports.
|
|
36
36
|
*/
|
|
37
|
+
import type { WorkflowCompatibilityReason } from '../core/contract/compatibility.ts';
|
|
37
38
|
import type { FaultCode } from '../core/fault-code.ts';
|
|
38
39
|
import { type WeftErrorCode } from '../core/weft-error.ts';
|
|
39
40
|
/** Transport identifiers as seen by `executeOperation`. */
|
|
@@ -78,6 +79,8 @@ export type OperationFault = {
|
|
|
78
79
|
missingTypes?: readonly string[] | undefined;
|
|
79
80
|
missingWorkflowCount?: number | undefined;
|
|
80
81
|
samplesTruncated?: boolean | undefined;
|
|
82
|
+
currentGeneration?: number | undefined;
|
|
83
|
+
compatibilityReasons?: readonly WorkflowCompatibilityReason[] | undefined;
|
|
81
84
|
};
|
|
82
85
|
} | {
|
|
83
86
|
code: 'Unprocessable';
|
|
@@ -30,7 +30,9 @@ const NO_REST_FAULT_DATA = Object.freeze({}), REST_FAULT_DATA_EXTRACTORS = {
|
|
|
30
30
|
Conflict: (data) => filterDefined({
|
|
31
31
|
missingTypes: data.missingTypes === void 0 ? void 0 : [...data.missingTypes],
|
|
32
32
|
missingWorkflowCount: data.missingWorkflowCount,
|
|
33
|
-
samplesTruncated: data.samplesTruncated
|
|
33
|
+
samplesTruncated: data.samplesTruncated,
|
|
34
|
+
currentGeneration: data.currentGeneration,
|
|
35
|
+
compatibilityReasons: data.compatibilityReasons === void 0 ? void 0 : [...data.compatibilityReasons]
|
|
34
36
|
}),
|
|
35
37
|
Unprocessable: () => NO_REST_FAULT_DATA,
|
|
36
38
|
PayloadTooLarge: (data) => ({ maxBytes: data.maxBytes }),
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weft.workflows.revisions.activate` operation + REST binding.
|
|
3
|
+
*
|
|
4
|
+
* Activates an already-installed `(name, revision)` as the durably
|
|
5
|
+
* advertised active revision — bookkeeping only. See
|
|
6
|
+
* `core/engine/engine-workflows-namespace.ts`'s module doc: activation
|
|
7
|
+
* moves `RegistrySnapshot.activeRevisions`, never which in-process handler
|
|
8
|
+
* `engine.start()` dispatches to.
|
|
9
|
+
*
|
|
10
|
+
* @module server/operations/activate-workflow-revision
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { WorkflowCatalogActivationResult } from '../../core/catalog/index.ts';
|
|
14
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
15
|
+
declare const activateWorkflowRevisionInput: z.ZodObject<{
|
|
16
|
+
name: z.ZodUnknown;
|
|
17
|
+
revision: z.ZodUnknown;
|
|
18
|
+
expectedGeneration: z.ZodOptional<z.ZodUnknown>;
|
|
19
|
+
policy: z.ZodOptional<z.ZodUnknown>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type ActivateWorkflowRevisionInput = z.infer<typeof activateWorkflowRevisionInput>;
|
|
22
|
+
export type ActivateWorkflowRevisionOutput = WorkflowCatalogActivationResult;
|
|
23
|
+
export declare const activateWorkflowRevisionOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
24
|
+
name: unknown;
|
|
25
|
+
revision: unknown;
|
|
26
|
+
expectedGeneration?: unknown;
|
|
27
|
+
policy?: unknown;
|
|
28
|
+
}, WorkflowCatalogActivationResult, unknown>;
|
|
29
|
+
export declare const activateWorkflowRevisionRestBinding: UnknownRestBinding;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineOperation } from "../operation-registry.js";
|
|
3
|
+
import {
|
|
4
|
+
activationRefusalToFault,
|
|
5
|
+
readWorkflowCatalogRestBody,
|
|
6
|
+
throwWorkflowCatalogOperationFault,
|
|
7
|
+
validateExpectedGenerationField,
|
|
8
|
+
validatePolicyField,
|
|
9
|
+
validateWorkflowNameField,
|
|
10
|
+
validateWorkflowRevisionField,
|
|
11
|
+
workflowsAdminAccess
|
|
12
|
+
} from "./workflow-catalog-operation-helpers.js";
|
|
13
|
+
const activateWorkflowRevisionInput = z.object({
|
|
14
|
+
name: z.unknown().describe("Workflow name. Runtime validation requires a wire-safe identifier."),
|
|
15
|
+
revision: z.unknown().describe("Installed revision to activate. Runtime validation requires a non-empty string."),
|
|
16
|
+
expectedGeneration: z.unknown().optional().describe("The durable generation this caller last observed. Required once the workflow has an " + "active revision \u2014 omitting it there refuses with expected-generation-required."),
|
|
17
|
+
policy: z.unknown().optional().describe("Optional compatibility policy override.")
|
|
18
|
+
}), activateWorkflowRevisionOutput = z.unknown();
|
|
19
|
+
export const activateWorkflowRevisionOperation = defineOperation({
|
|
20
|
+
name: "weft.workflows.revisions.activate",
|
|
21
|
+
mcpExposable: !1,
|
|
22
|
+
summary: "Activate an installed workflow revision",
|
|
23
|
+
description: "Activate an already-installed `(name, revision)` as the durably advertised active revision for `name`. Returns the structured result verbatim: `{ applied: true, pointer }` on success, " + "or `{ applied: false, reason, ... }` on refusal \u2014 surfaced as a Conflict fault with `reason` " + "one of `incompatible`, `stale-generation`, `expected-generation-required`, or `conflict`. Faults with NotFound when the revision was never installed. Never changes which in-process " + "handler `engine.start()` dispatches to \u2014 see the workflow-versioning guide.",
|
|
24
|
+
destructive: !0,
|
|
25
|
+
tags: ["Workflow Catalog"],
|
|
26
|
+
inputSchema: activateWorkflowRevisionInput,
|
|
27
|
+
outputSchema: activateWorkflowRevisionOutput,
|
|
28
|
+
access: workflowsAdminAccess,
|
|
29
|
+
producibleFaults: ["NotFound", "Conflict", "InvalidParams"],
|
|
30
|
+
discoverable: !0,
|
|
31
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
32
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
33
|
+
invoke: async ({ input, engine }) => {
|
|
34
|
+
const e = engine, name = validateWorkflowNameField(input.name), revision = validateWorkflowRevisionField(input.revision), expectedGeneration = validateExpectedGenerationField(input.expectedGeneration), policy = validatePolicyField(input.policy);
|
|
35
|
+
let result;
|
|
36
|
+
try {
|
|
37
|
+
result = await e.workflows.activate(name, revision, {
|
|
38
|
+
...expectedGeneration === void 0 ? {} : { expectedGeneration },
|
|
39
|
+
...policy === void 0 ? {} : { policy }
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throwWorkflowCatalogOperationFault(error);
|
|
43
|
+
}
|
|
44
|
+
if (!result.applied)
|
|
45
|
+
throw activationRefusalToFault(result);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
}), activateWorkflowRevisionRestBinding = {
|
|
49
|
+
method: "POST",
|
|
50
|
+
path: "/v1/registry/workflows/:name/activate",
|
|
51
|
+
pathParamNames: ["name"],
|
|
52
|
+
operationName: "weft.workflows.revisions.activate",
|
|
53
|
+
inputSources: {
|
|
54
|
+
name: { kind: "path", pathParam: "name" },
|
|
55
|
+
revision: { kind: "body-field", bodyField: "revision" },
|
|
56
|
+
expectedGeneration: { kind: "body-field", bodyField: "expectedGeneration" },
|
|
57
|
+
policy: { kind: "body-field", bodyField: "policy" }
|
|
58
|
+
},
|
|
59
|
+
extractInput: async (request, pathParams, context) => {
|
|
60
|
+
const body = await readWorkflowCatalogRestBody(request, context);
|
|
61
|
+
return {
|
|
62
|
+
name: pathParams.name ?? "",
|
|
63
|
+
revision: body.revision,
|
|
64
|
+
expectedGeneration: body.expectedGeneration,
|
|
65
|
+
policy: body.policy
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
success: { kind: "json", status: 200 }
|
|
69
|
+
};
|
|
@@ -85,7 +85,7 @@ function getFleetEventFeed(engine, transport) {
|
|
|
85
85
|
if (isFleetEventSubscriber(fleetFeed))
|
|
86
86
|
return fleetFeed;
|
|
87
87
|
}
|
|
88
|
-
raiseFault(fleetEventsSubscriptionOperation, {
|
|
88
|
+
return raiseFault(fleetEventsSubscriptionOperation, {
|
|
89
89
|
code: "UnsupportedTransport",
|
|
90
90
|
message: "Fleet event subscription requires a WebSocket fleet event feed",
|
|
91
91
|
data: { transport, supported: ["jsonRpcWebSocket"] }
|
|
@@ -54,7 +54,7 @@ export const forkWorkflowOperation = defineOperation({
|
|
|
54
54
|
try {
|
|
55
55
|
return { id: (await typedEngine.fork(input.workflowId, options)).id };
|
|
56
56
|
} catch (error) {
|
|
57
|
-
resolveForkAccess(error);
|
|
57
|
+
return resolveForkAccess(error);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}), forkWorkflowRestBinding = {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weft.workflows.active.get` operation + REST binding.
|
|
3
|
+
*
|
|
4
|
+
* Returns the currently active revision pointer for one workflow name.
|
|
5
|
+
* Named `active.get` rather than `revisions.getActive` — `OPERATION_NAME_PATTERN`
|
|
6
|
+
* forbids camelCase wire segments, and `getActive` is only this namespace
|
|
7
|
+
* method's TypeScript name (`engine.workflows.getActive`).
|
|
8
|
+
*
|
|
9
|
+
* In-memory only: matches `RegistrySnapshot.activeRevisions`' existing
|
|
10
|
+
* staleness contract exactly (see `engine-workflows-namespace.ts`'s
|
|
11
|
+
* `getActive` JSDoc), which is what makes "operations and the registry
|
|
12
|
+
* snapshot agree" true by construction.
|
|
13
|
+
*
|
|
14
|
+
* @module server/operations/get-active-workflow-revision
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import type { WorkflowCatalogActivePointer } from '../../core/catalog/index.ts';
|
|
18
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
19
|
+
declare const getActiveWorkflowRevisionInput: z.ZodObject<{
|
|
20
|
+
name: z.ZodUnknown;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type GetActiveWorkflowRevisionInput = z.infer<typeof getActiveWorkflowRevisionInput>;
|
|
23
|
+
export type GetActiveWorkflowRevisionOutput = WorkflowCatalogActivePointer;
|
|
24
|
+
export declare const getActiveWorkflowRevisionOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
25
|
+
name: unknown;
|
|
26
|
+
}, Readonly<{
|
|
27
|
+
revision: string;
|
|
28
|
+
generation: number;
|
|
29
|
+
activatedAt: number;
|
|
30
|
+
}>, unknown>;
|
|
31
|
+
export declare const getActiveWorkflowRevisionRestBinding: UnknownRestBinding;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineOperation } from "../operation-registry.js";
|
|
3
|
+
import {
|
|
4
|
+
validateWorkflowNameField,
|
|
5
|
+
workflowsReadAccess
|
|
6
|
+
} from "./workflow-catalog-operation-helpers.js";
|
|
7
|
+
const getActiveWorkflowRevisionInput = z.object({
|
|
8
|
+
name: z.unknown().describe("Workflow name. Runtime validation requires a wire-safe identifier.")
|
|
9
|
+
}), getActiveWorkflowRevisionOutput = z.unknown();
|
|
10
|
+
export const getActiveWorkflowRevisionOperation = defineOperation({
|
|
11
|
+
name: "weft.workflows.active.get",
|
|
12
|
+
mcpExposable: !1,
|
|
13
|
+
summary: "Get the currently active revision pointer for a workflow",
|
|
14
|
+
description: "Read the current `{ revision, generation, activatedAt }` active pointer for `name`. Read-only, in-memory (matches `RegistrySnapshot.activeRevisions`' staleness contract exactly). Faults with NotFound when `name` has never been activated.",
|
|
15
|
+
destructive: !1,
|
|
16
|
+
tags: ["Workflow Catalog"],
|
|
17
|
+
inputSchema: getActiveWorkflowRevisionInput,
|
|
18
|
+
outputSchema: getActiveWorkflowRevisionOutput,
|
|
19
|
+
access: workflowsReadAccess,
|
|
20
|
+
producibleFaults: ["NotFound", "InvalidParams"],
|
|
21
|
+
discoverable: !0,
|
|
22
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
23
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
24
|
+
invoke: async ({ input, engine }) => {
|
|
25
|
+
const e = engine, name = validateWorkflowNameField(input.name), pointer = await e.workflows.getActive(name);
|
|
26
|
+
if (pointer === null)
|
|
27
|
+
throw {
|
|
28
|
+
code: "NotFound",
|
|
29
|
+
message: `Workflow "${name}" has never been activated`,
|
|
30
|
+
data: { resource: "workflow-active-revision", identifier: name }
|
|
31
|
+
};
|
|
32
|
+
return pointer;
|
|
33
|
+
}
|
|
34
|
+
}), getActiveWorkflowRevisionRestBinding = {
|
|
35
|
+
method: "GET",
|
|
36
|
+
path: "/v1/registry/workflows/:name/active",
|
|
37
|
+
pathParamNames: ["name"],
|
|
38
|
+
operationName: "weft.workflows.active.get",
|
|
39
|
+
inputSources: {
|
|
40
|
+
name: { kind: "path", pathParam: "name" }
|
|
41
|
+
},
|
|
42
|
+
extractInput: async (_request, pathParams) => ({
|
|
43
|
+
name: pathParams.name ?? ""
|
|
44
|
+
}),
|
|
45
|
+
success: { kind: "json", status: 200 }
|
|
46
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weft.catalog.diagnostics` operation + REST binding (WFT-12).
|
|
3
|
+
*
|
|
4
|
+
* Read-only, bounded diagnostics for one `(name, revision)` workflow
|
|
5
|
+
* catalog entry: whether it is installed, whether it is currently active,
|
|
6
|
+
* its full reference-count breakdown, and whether it would currently be
|
|
7
|
+
* removable. No REST/JSON-RPC removal surface exists this batch — removal
|
|
8
|
+
* (`removeWorkflowRevision`) is a plain in-process function, not a wire
|
|
9
|
+
* operation, per the coordinator's "single bounded diagnostics operation"
|
|
10
|
+
* steer.
|
|
11
|
+
*
|
|
12
|
+
* Static, not factory-built — unlike `get-worker-diagnostics.ts`'s injected
|
|
13
|
+
* `WorkerRegistry`, this operation needs no per-server state beyond the
|
|
14
|
+
* live `engine` every `invoke` already receives, matching
|
|
15
|
+
* `get-retention-overview.ts`'s shape.
|
|
16
|
+
*
|
|
17
|
+
* @module server/operations/get-catalog-diagnostics
|
|
18
|
+
*/
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
21
|
+
declare const getCatalogDiagnosticsInput: z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
revision: z.ZodString;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
declare const getCatalogDiagnosticsOutput: z.ZodObject<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
revision: z.ZodString;
|
|
28
|
+
installed: z.ZodBoolean;
|
|
29
|
+
active: z.ZodBoolean;
|
|
30
|
+
activeRevision: z.ZodOptional<z.ZodString>;
|
|
31
|
+
references: z.ZodObject<{
|
|
32
|
+
registeredDefinitions: z.ZodNumber;
|
|
33
|
+
inFlightStarts: z.ZodNumber;
|
|
34
|
+
nonTerminalRuns: z.ZodNumber;
|
|
35
|
+
pinnedSchedules: z.ZodNumber;
|
|
36
|
+
pendingDispatches: z.ZodNumber;
|
|
37
|
+
activeExecutionRealms: z.ZodNumber;
|
|
38
|
+
retainedRecoveryRecords: z.ZodNumber;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
removable: z.ZodBoolean;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export type GetCatalogDiagnosticsInput = z.infer<typeof getCatalogDiagnosticsInput>;
|
|
43
|
+
export type GetCatalogDiagnosticsOutput = z.infer<typeof getCatalogDiagnosticsOutput>;
|
|
44
|
+
/**
|
|
45
|
+
* `weft.catalog.diagnostics`: bounded, per-`(name, revision)` diagnostics
|
|
46
|
+
* for the durable workflow catalog. Requires `system:read`. Never returns
|
|
47
|
+
* manifest or contract content — only identity, active-pointer state, and
|
|
48
|
+
* low-cardinality reference counts, matching the repository's "metrics
|
|
49
|
+
* remain low-cardinality" observability convention.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { HttpClient } from '@lostgradient/weft/client';
|
|
54
|
+
*
|
|
55
|
+
* const client = new HttpClient({ baseUrl: 'https://weft.example.com' });
|
|
56
|
+
* const diagnostics = await client.operations['weft.catalog.diagnostics']({
|
|
57
|
+
* name: 'checkout',
|
|
58
|
+
* revision: 'some-revision',
|
|
59
|
+
* });
|
|
60
|
+
* console.log(diagnostics.installed, diagnostics.removable);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const getCatalogDiagnosticsOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
64
|
+
name: string;
|
|
65
|
+
revision: string;
|
|
66
|
+
}, {
|
|
67
|
+
name: string;
|
|
68
|
+
revision: string;
|
|
69
|
+
installed: boolean;
|
|
70
|
+
active: boolean;
|
|
71
|
+
references: {
|
|
72
|
+
registeredDefinitions: number;
|
|
73
|
+
inFlightStarts: number;
|
|
74
|
+
nonTerminalRuns: number;
|
|
75
|
+
pinnedSchedules: number;
|
|
76
|
+
pendingDispatches: number;
|
|
77
|
+
activeExecutionRealms: number;
|
|
78
|
+
retainedRecoveryRecords: number;
|
|
79
|
+
};
|
|
80
|
+
removable: boolean;
|
|
81
|
+
activeRevision?: string | undefined;
|
|
82
|
+
}, unknown>;
|
|
83
|
+
/** REST binding for `weft.catalog.diagnostics`: `GET /v1/catalog/:name/revisions/:revision/diagnostics`. */
|
|
84
|
+
export declare const getCatalogDiagnosticsRestBinding: UnknownRestBinding;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { getWorkflowRevisionDiagnostics } from "../../core/engine.js";
|
|
3
|
+
import { shapeOperationFaultAsJson } from "../operation-fault.js";
|
|
4
|
+
import { defineOperation } from "../operation-registry.js";
|
|
5
|
+
const workflowRevisionReferenceCountsSchema = z.object({
|
|
6
|
+
registeredDefinitions: z.number().int().nonnegative(),
|
|
7
|
+
inFlightStarts: z.number().int().nonnegative(),
|
|
8
|
+
nonTerminalRuns: z.number().int().nonnegative(),
|
|
9
|
+
pinnedSchedules: z.number().int().nonnegative(),
|
|
10
|
+
pendingDispatches: z.number().int().nonnegative(),
|
|
11
|
+
activeExecutionRealms: z.number().int().nonnegative(),
|
|
12
|
+
retainedRecoveryRecords: z.number().int().nonnegative()
|
|
13
|
+
}).strict(), getCatalogDiagnosticsInput = z.object({
|
|
14
|
+
name: z.string().min(1),
|
|
15
|
+
revision: z.string().min(1)
|
|
16
|
+
}).strict(), getCatalogDiagnosticsOutput = z.object({
|
|
17
|
+
name: z.string(),
|
|
18
|
+
revision: z.string(),
|
|
19
|
+
installed: z.boolean(),
|
|
20
|
+
active: z.boolean(),
|
|
21
|
+
activeRevision: z.string().optional(),
|
|
22
|
+
references: workflowRevisionReferenceCountsSchema,
|
|
23
|
+
removable: z.boolean()
|
|
24
|
+
}).strict();
|
|
25
|
+
export const getCatalogDiagnosticsOperation = defineOperation({
|
|
26
|
+
name: "weft.catalog.diagnostics",
|
|
27
|
+
mcpExposable: !1,
|
|
28
|
+
summary: "Get bounded reference-count and removability diagnostics for one workflow revision",
|
|
29
|
+
description: "Report whether a `(name, revision)` workflow catalog entry is installed, whether it is currently the active revision, its full reference-count breakdown, and whether it's currently removable. Never returns manifest or contract content.",
|
|
30
|
+
destructive: !1,
|
|
31
|
+
tags: ["Observability"],
|
|
32
|
+
inputSchema: getCatalogDiagnosticsInput,
|
|
33
|
+
outputSchema: getCatalogDiagnosticsOutput,
|
|
34
|
+
access: { kind: "scoped", scopes: { kind: "anyOf", scopes: ["system:read"] } },
|
|
35
|
+
producibleFaults: [],
|
|
36
|
+
discoverable: !0,
|
|
37
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
38
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
39
|
+
invoke: async ({ engine, input }) => {
|
|
40
|
+
return getWorkflowRevisionDiagnostics(engine, input.name, input.revision);
|
|
41
|
+
}
|
|
42
|
+
}), getCatalogDiagnosticsRestBinding = {
|
|
43
|
+
method: "GET",
|
|
44
|
+
path: "/v1/catalog/:name/revisions/:revision/diagnostics",
|
|
45
|
+
pathParamNames: ["name", "revision"],
|
|
46
|
+
operationName: "weft.catalog.diagnostics",
|
|
47
|
+
inputSources: {
|
|
48
|
+
name: { kind: "path", pathParam: "name" },
|
|
49
|
+
revision: { kind: "path", pathParam: "revision" }
|
|
50
|
+
},
|
|
51
|
+
extractInput: async (_request, pathParams) => ({
|
|
52
|
+
name: pathParams.name ?? "",
|
|
53
|
+
revision: pathParams.revision ?? ""
|
|
54
|
+
}),
|
|
55
|
+
success: { kind: "json", status: 200 },
|
|
56
|
+
shapeFault: shapeOperationFaultAsJson
|
|
57
|
+
};
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import {
|
|
3
3
|
buildRegistrySnapshot,
|
|
4
|
-
|
|
4
|
+
REGISTRY_VERSION,
|
|
5
|
+
RegistryManifestLimitError,
|
|
6
|
+
RegistrySchemaConversionError,
|
|
7
|
+
RegistryWorkflowCountLimitError
|
|
5
8
|
} from "../../core/registry-snapshot.js";
|
|
6
9
|
import { defineOperation } from "../operation-registry.js";
|
|
7
10
|
const getRegistryInput = z.object({}), objectValue = z.unknown().refine((value) => typeof value === "object" && value !== null && !Array.isArray(value), {
|
|
8
11
|
message: "expected an object"
|
|
9
12
|
}), getRegistryOutput = z.object({
|
|
10
|
-
registryVersion: z.literal(
|
|
11
|
-
|
|
13
|
+
registryVersion: z.literal(REGISTRY_VERSION),
|
|
14
|
+
generatedAt: z.string(),
|
|
15
|
+
workflows: z.array(objectValue),
|
|
16
|
+
activeRevisions: objectValue,
|
|
12
17
|
activities: objectValue
|
|
13
18
|
}).strict();
|
|
14
19
|
export const getRegistryOperation = defineOperation({
|
|
@@ -28,7 +33,7 @@ export const getRegistryOperation = defineOperation({
|
|
|
28
33
|
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
29
34
|
invoke: async ({ engine }) => {
|
|
30
35
|
try {
|
|
31
|
-
return buildRegistrySnapshot(engine);
|
|
36
|
+
return await buildRegistrySnapshot(engine);
|
|
32
37
|
} catch (error) {
|
|
33
38
|
if (error instanceof RegistrySchemaConversionError)
|
|
34
39
|
console.error(`[weft.system.registry] ${error.message}`, {
|
|
@@ -36,6 +41,14 @@ export const getRegistryOperation = defineOperation({
|
|
|
36
41
|
entityName: error.entityName,
|
|
37
42
|
direction: error.direction
|
|
38
43
|
});
|
|
44
|
+
else if (error instanceof RegistryManifestLimitError)
|
|
45
|
+
console.error(`[weft.system.registry] ${error.message}`, {
|
|
46
|
+
workflowType: error.workflowType
|
|
47
|
+
});
|
|
48
|
+
else if (error instanceof RegistryWorkflowCountLimitError)
|
|
49
|
+
console.error(`[weft.system.registry] ${error.message}`, {
|
|
50
|
+
count: error.count
|
|
51
|
+
});
|
|
39
52
|
throw error;
|
|
40
53
|
}
|
|
41
54
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weft.workflows.revisions.get` operation + REST binding.
|
|
3
|
+
*
|
|
4
|
+
* Returns one installed `(name, revision)` workflow catalog record.
|
|
5
|
+
*
|
|
6
|
+
* @module server/operations/get-workflow-revision
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import type { WorkflowRevisionRecord } from '../../core/catalog/index.ts';
|
|
10
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
11
|
+
declare const getWorkflowRevisionInput: z.ZodObject<{
|
|
12
|
+
name: z.ZodUnknown;
|
|
13
|
+
revision: z.ZodUnknown;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type GetWorkflowRevisionInput = z.infer<typeof getWorkflowRevisionInput>;
|
|
16
|
+
export type GetWorkflowRevisionOutput = WorkflowRevisionRecord;
|
|
17
|
+
export declare const getWorkflowRevisionOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
18
|
+
name: unknown;
|
|
19
|
+
revision: unknown;
|
|
20
|
+
}, Readonly<{
|
|
21
|
+
manifest: import("../../index.ts").WorkflowRevisionManifest;
|
|
22
|
+
installedAt: number;
|
|
23
|
+
}>, unknown>;
|
|
24
|
+
export declare const getWorkflowRevisionRestBinding: UnknownRestBinding;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineOperation } from "../operation-registry.js";
|
|
3
|
+
import {
|
|
4
|
+
validateWorkflowNameField,
|
|
5
|
+
validateWorkflowRevisionField,
|
|
6
|
+
workflowsReadAccess
|
|
7
|
+
} from "./workflow-catalog-operation-helpers.js";
|
|
8
|
+
const getWorkflowRevisionInput = z.object({
|
|
9
|
+
name: z.unknown().describe("Workflow name. Runtime validation requires a wire-safe identifier."),
|
|
10
|
+
revision: z.unknown().describe("Installed revision. Runtime validation requires a non-empty string.")
|
|
11
|
+
}), getWorkflowRevisionOutput = z.unknown();
|
|
12
|
+
export const getWorkflowRevisionOperation = defineOperation({
|
|
13
|
+
name: "weft.workflows.revisions.get",
|
|
14
|
+
mcpExposable: !1,
|
|
15
|
+
summary: "Get one installed workflow revision",
|
|
16
|
+
description: "Read one durably installed `(name, revision)` workflow catalog record. Read-only. Faults with NotFound when no such revision was installed.",
|
|
17
|
+
destructive: !1,
|
|
18
|
+
tags: ["Workflow Catalog"],
|
|
19
|
+
inputSchema: getWorkflowRevisionInput,
|
|
20
|
+
outputSchema: getWorkflowRevisionOutput,
|
|
21
|
+
access: workflowsReadAccess,
|
|
22
|
+
producibleFaults: ["NotFound", "InvalidParams"],
|
|
23
|
+
discoverable: !0,
|
|
24
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
25
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
26
|
+
invoke: async ({ input, engine }) => {
|
|
27
|
+
const e = engine, name = validateWorkflowNameField(input.name), revision = validateWorkflowRevisionField(input.revision), record = await e.workflows.getRevision(name, revision);
|
|
28
|
+
if (record === null)
|
|
29
|
+
throw {
|
|
30
|
+
code: "NotFound",
|
|
31
|
+
message: `Workflow "${name}" has no installed revision "${revision}"`,
|
|
32
|
+
data: { resource: "workflow-revision", identifier: `${name}:${revision}` }
|
|
33
|
+
};
|
|
34
|
+
return record;
|
|
35
|
+
}
|
|
36
|
+
}), getWorkflowRevisionRestBinding = {
|
|
37
|
+
method: "GET",
|
|
38
|
+
path: "/v1/registry/workflows/:name/revisions/:revision",
|
|
39
|
+
pathParamNames: ["name", "revision"],
|
|
40
|
+
operationName: "weft.workflows.revisions.get",
|
|
41
|
+
inputSources: {
|
|
42
|
+
name: { kind: "path", pathParam: "name" },
|
|
43
|
+
revision: { kind: "path", pathParam: "revision" }
|
|
44
|
+
},
|
|
45
|
+
extractInput: async (_request, pathParams) => ({
|
|
46
|
+
name: pathParams.name ?? "",
|
|
47
|
+
revision: pathParams.revision ?? ""
|
|
48
|
+
}),
|
|
49
|
+
success: { kind: "json", status: 200 }
|
|
50
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weft.workflows.revisions.install` operation + REST binding.
|
|
3
|
+
*
|
|
4
|
+
* Durably installs a validated {@link WorkflowRevisionManifest} for a
|
|
5
|
+
* workflow the engine already has an in-process definition for. Catalog
|
|
6
|
+
* bookkeeping only — see `core/engine/engine-workflows-namespace.ts`'s
|
|
7
|
+
* module doc: installing (and later activating) a revision never changes
|
|
8
|
+
* which in-process handler `engine.start()` dispatches to.
|
|
9
|
+
*
|
|
10
|
+
* @module server/operations/install-workflow-revision
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { WorkflowRevisionRecord } from '../../core/catalog/index.ts';
|
|
14
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
15
|
+
declare const installWorkflowRevisionInput: z.ZodObject<{
|
|
16
|
+
manifest: z.ZodUnknown;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export type InstallWorkflowRevisionInput = z.infer<typeof installWorkflowRevisionInput>;
|
|
19
|
+
export type InstallWorkflowRevisionOutput = WorkflowRevisionRecord;
|
|
20
|
+
export declare const installWorkflowRevisionOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
21
|
+
manifest: unknown;
|
|
22
|
+
}, Readonly<{
|
|
23
|
+
manifest: import("../../index.ts").WorkflowRevisionManifest;
|
|
24
|
+
installedAt: number;
|
|
25
|
+
}>, unknown>;
|
|
26
|
+
export declare const installWorkflowRevisionRestBinding: UnknownRestBinding;
|
|
27
|
+
export {};
|