@lostgradient/weft 0.17.0 → 0.19.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 +3 -1
- package/dist/cli/conformance.js +14 -18
- package/dist/cli/generated/operation-catalog.snapshot.json +331 -16
- package/dist/cli/generated/operation-client.generated.d.ts +39 -6
- package/dist/cli/generated/operation-client.generated.js +6 -0
- package/dist/core/context/child-workflow-pipe.d.ts +1 -1
- package/dist/core/context/child-workflow-pipe.js +1 -1
- package/dist/core/engine/construction.d.ts +2 -0
- package/dist/core/engine/construction.js +3 -0
- package/dist/core/engine/index.js +1 -0
- package/dist/core/engine/listing.d.ts +1 -0
- package/dist/core/engine/listing.js +6 -4
- package/dist/core/weft-error.d.ts +1 -1
- package/dist/core/weft-error.js +2 -1
- package/dist/core/worker-execution-dispatcher.d.ts +8 -0
- package/dist/core/worker-execution-dispatcher.js +4 -0
- package/dist/core/worker-execution-strategy-options.d.ts +16 -0
- package/dist/core/worker-execution-strategy.js +71 -89
- package/dist/core/worker-fault-handling.d.ts +45 -0
- package/dist/core/worker-fault-handling.js +88 -0
- package/dist/core/worker-protocol.d.ts +18 -1
- package/dist/core/worker-protocol.js +1 -1
- package/dist/core/worker-realm-readiness.d.ts +78 -0
- package/dist/core/worker-realm-readiness.js +127 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +28 -1
- package/dist/json-schema.js +1 -1
- package/dist/runtime/portable.d.ts +14 -0
- package/dist/runtime/portable.js +10 -0
- package/dist/server/authorization-scope.d.ts +32 -2
- package/dist/server/index.d.ts +73 -8
- package/dist/server/index.js +11 -3
- package/dist/server/operations/get-principal.d.ts +75 -0
- package/dist/server/operations/get-principal.js +41 -0
- package/dist/server/operations/get-task-diagnostics.d.ts +43 -18
- package/dist/server/operations/get-task-diagnostics.js +87 -126
- package/dist/server/operations/get-worker-diagnostics.d.ts +177 -0
- package/dist/server/operations/get-worker-diagnostics.js +117 -0
- package/dist/server/operations/list-worker-registration-rejections.d.ts +79 -0
- package/dist/server/operations/list-worker-registration-rejections.js +60 -0
- package/dist/server/operations/list-workers.js +1 -3
- package/dist/server/operations/static-registrations.d.ts +28 -0
- package/dist/server/operations/static-registrations.js +248 -0
- package/dist/server/rest-bindings.d.ts +5 -0
- package/dist/server/rest-bindings.js +34 -313
- package/dist/server/runtime/authentication-bridge.js +6 -14
- package/dist/server/runtime/context.d.ts +23 -0
- package/dist/server/runtime/task-dispatch.d.ts +7 -1
- package/dist/server/runtime/task-dispatch.js +126 -55
- package/dist/server/runtime/task-ledger-completion.d.ts +68 -0
- package/dist/server/runtime/task-ledger-completion.js +72 -0
- package/dist/server/runtime/task-ledger-recovery.d.ts +55 -0
- package/dist/server/runtime/task-ledger-recovery.js +73 -0
- package/dist/server/runtime/task-ledger-runtime.d.ts +64 -0
- package/dist/server/runtime/task-ledger-runtime.js +34 -0
- package/dist/server/runtime/task-metrics.d.ts +6 -4
- package/dist/server/runtime/task-polling.d.ts +14 -12
- package/dist/server/runtime/task-polling.js +106 -82
- package/dist/server/runtime/task-reconciliation.d.ts +35 -8
- package/dist/server/runtime/task-reconciliation.js +75 -74
- package/dist/server/runtime/task-result-resolution.d.ts +2 -10
- package/dist/server/runtime/task-result-resolution.js +0 -67
- package/dist/server/runtime/task-result-view.d.ts +82 -0
- package/dist/server/runtime/task-result-view.js +48 -0
- package/dist/server/runtime/websocket-worker-messaging.d.ts +16 -0
- package/dist/server/runtime/websocket-worker-messaging.js +32 -0
- package/dist/server/runtime/websocket-worker-registration.d.ts +41 -0
- package/dist/server/runtime/websocket-worker-registration.js +134 -0
- package/dist/server/runtime/websocket-worker.d.ts +0 -1
- package/dist/server/runtime/websocket-worker.js +64 -116
- package/dist/server/serve-internals.d.ts +9 -6
- package/dist/server/serve-internals.js +14 -40
- package/dist/server/task-ledger-codec.d.ts +40 -0
- package/dist/server/task-ledger-codec.js +195 -0
- package/dist/server/task-ledger-keys.d.ts +13 -0
- package/dist/server/task-ledger-keys.js +5 -0
- package/dist/server/task-ledger-limits.d.ts +34 -0
- package/dist/server/task-ledger-limits.js +5 -0
- package/dist/server/task-ledger-transition-helpers.d.ts +38 -0
- package/dist/server/task-ledger-transition-helpers.js +42 -0
- package/dist/server/task-ledger-transitions-cancellation.d.ts +31 -0
- package/dist/server/task-ledger-transitions-cancellation.js +73 -0
- package/dist/server/task-ledger-transitions.d.ts +129 -0
- package/dist/server/task-ledger-transitions.js +162 -0
- package/dist/server/task-ledger-types.d.ts +220 -0
- package/dist/server/task-ledger-types.js +1 -0
- package/dist/server/task-ledger.d.ts +17 -0
- package/dist/server/task-ledger.js +24 -0
- package/dist/server/task-state.d.ts +25 -152
- package/dist/server/task-state.js +0 -188
- package/dist/server/worker-admission-policy.d.ts +70 -0
- package/dist/server/worker-admission-policy.js +0 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/interface.d.ts +0 -2
- package/dist/storage/interface.js +1 -1
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.js +1 -1
- package/dist/storage/postgres.js +1 -1
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.js +1 -1
- package/dist/storage/turso.js +1 -1
- package/dist/storage/web-extension.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/index.d.ts +2 -0
- package/dist/worker/index.js +30 -4
- package/dist/worker/manifest/canonical-json.d.ts +20 -0
- package/dist/worker/manifest/canonical-json.js +13 -0
- package/dist/worker/manifest/capabilities.d.ts +24 -0
- package/dist/worker/manifest/capabilities.js +74 -0
- package/dist/worker/manifest/content-digest.d.ts +20 -0
- package/dist/worker/manifest/content-digest.js +13 -0
- package/dist/worker/manifest/declared-shape-digest.d.ts +14 -0
- package/dist/worker/manifest/declared-shape-digest.js +4 -0
- package/dist/worker/manifest/digest.d.ts +82 -0
- package/dist/worker/manifest/digest.js +9 -0
- package/dist/worker/manifest/execution-identity.d.ts +92 -0
- package/dist/worker/manifest/execution-identity.js +36 -0
- package/dist/worker/manifest/failure.d.ts +59 -0
- package/dist/worker/manifest/failure.js +4 -0
- package/dist/worker/manifest/index.d.ts +22 -0
- package/dist/worker/manifest/index.js +23 -0
- package/dist/worker/manifest/internal-realm.d.ts +50 -0
- package/dist/worker/manifest/internal-realm.js +39 -0
- package/dist/worker/manifest/is-record.d.ts +12 -0
- package/dist/worker/manifest/is-record.js +6 -0
- package/dist/worker/manifest/json-scan.d.ts +26 -0
- package/dist/worker/manifest/json-scan.js +88 -0
- package/dist/worker/manifest/limits.d.ts +138 -0
- package/dist/worker/manifest/limits.js +1 -0
- package/dist/worker/manifest/normalize.d.ts +63 -0
- package/dist/worker/manifest/normalize.js +73 -0
- package/dist/worker/manifest/parse-json.d.ts +24 -0
- package/dist/worker/manifest/parse-json.js +15 -0
- package/dist/worker/manifest/parse.d.ts +86 -0
- package/dist/worker/manifest/parse.js +188 -0
- package/dist/worker/manifest/registry-contract-builder.d.ts +120 -0
- package/dist/worker/manifest/registry-contract-builder.js +65 -0
- package/dist/worker/manifest/types.d.ts +263 -0
- package/dist/worker/manifest/types.js +1 -0
- package/dist/worker/manifest/utf8.d.ts +13 -0
- package/dist/worker/manifest/utf8.js +7 -0
- package/dist/worker/options.d.ts +55 -8
- package/dist/worker/options.js +65 -9
- package/dist/worker/protocol-internals.d.ts +1 -2
- package/dist/worker/protocol-internals.js +0 -5
- package/dist/worker/protocol-messages.d.ts +33 -17
- package/dist/worker/protocol-schemas.d.ts +36 -74
- package/dist/worker/protocol-schemas.js +25 -18
- package/dist/worker/protocol-version.d.ts +18 -14
- package/dist/worker/protocol-version.js +1 -1
- package/dist/worker/protocol.js +1 -1
- package/dist/worker/registry/deployment-consistency.d.ts +78 -0
- package/dist/worker/registry/deployment-consistency.js +27 -0
- package/dist/worker/registry/drain.d.ts +14 -0
- package/dist/worker/registry/drain.js +24 -0
- package/dist/worker/registry/rejections.d.ts +31 -0
- package/dist/worker/registry/rejections.js +10 -0
- package/dist/worker/registry/summary.d.ts +0 -3
- package/dist/worker/registry/summary.js +2 -5
- package/dist/worker/registry/types.d.ts +10 -3
- package/dist/worker/registry.d.ts +47 -2
- package/dist/worker/registry.js +45 -32
- package/dist/workers/workflow-worker-entry.d.ts +12 -7
- package/dist/workers/workflow-worker-entry.js +9 -2
- package/package.json +3 -3
- package/dist/server/task-resolved-record.d.ts +0 -12
- package/dist/server/task-resolved-record.js +0 -35
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weft.workers.diagnostics` operation + REST binding.
|
|
3
|
+
*
|
|
4
|
+
* Bounded diagnostic detail for one connected worker (WFT-29), split into
|
|
5
|
+
* two structurally distinct sub-objects: `instance` (this live socket —
|
|
6
|
+
* queue, health, connection timestamps) and `deploymentVersion` (what
|
|
7
|
+
* artifact it loaded — SDK/runtime identity, manifest digest, and every
|
|
8
|
+
* advertised workflow's version/revision/contract hash). Keeping these
|
|
9
|
+
* separate mirrors the manifest's own split between "which process" and
|
|
10
|
+
* "which build" questions.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately excludes `capabilities` and the raw payload schemas backing
|
|
13
|
+
* each `contractHash` — this surfaces identity for drift detection, not a
|
|
14
|
+
* schema dump.
|
|
15
|
+
*
|
|
16
|
+
* @module server/operations/get-worker-diagnostics
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import type { WorkerHealth, WorkerRegistry } from '../../worker/registry.ts';
|
|
20
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
21
|
+
declare const workerDiagnosticsEntrySchema: z.ZodObject<{
|
|
22
|
+
instance: z.ZodObject<{
|
|
23
|
+
workerId: z.ZodString;
|
|
24
|
+
queue: z.ZodString;
|
|
25
|
+
health: z.ZodType<WorkerHealth, unknown, z.core.$ZodTypeInternals<WorkerHealth, unknown>>;
|
|
26
|
+
connectedAt: z.ZodNumber;
|
|
27
|
+
startedAt: z.ZodNumber;
|
|
28
|
+
lastHeartbeatAt: z.ZodNumber;
|
|
29
|
+
heartbeatAgeMs: z.ZodNumber;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
deploymentVersion: z.ZodObject<{
|
|
32
|
+
deploymentName: z.ZodString;
|
|
33
|
+
buildId: z.ZodString;
|
|
34
|
+
artifactDigest: z.ZodString;
|
|
35
|
+
runtimeName: z.ZodString;
|
|
36
|
+
runtimeVersion: z.ZodString;
|
|
37
|
+
sdkVersion: z.ZodString;
|
|
38
|
+
manifestVersion: z.ZodNumber;
|
|
39
|
+
protocolVersion: z.ZodNumber;
|
|
40
|
+
manifestDigest: z.ZodString;
|
|
41
|
+
workflows: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
42
|
+
workflowVersion: z.ZodString;
|
|
43
|
+
workflowRevision: z.ZodString;
|
|
44
|
+
contractHash: z.ZodString;
|
|
45
|
+
activities: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
46
|
+
contractHash: z.ZodString;
|
|
47
|
+
implementationRevision: z.ZodString;
|
|
48
|
+
}, z.core.$strict>>;
|
|
49
|
+
}, z.core.$strict>>;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
declare const getWorkerDiagnosticsInput: z.ZodObject<{
|
|
53
|
+
workerId: z.ZodString;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
declare const getWorkerDiagnosticsOutput: z.ZodObject<{
|
|
56
|
+
worker: z.ZodNullable<z.ZodObject<{
|
|
57
|
+
instance: z.ZodObject<{
|
|
58
|
+
workerId: z.ZodString;
|
|
59
|
+
queue: z.ZodString;
|
|
60
|
+
health: z.ZodType<WorkerHealth, unknown, z.core.$ZodTypeInternals<WorkerHealth, unknown>>;
|
|
61
|
+
connectedAt: z.ZodNumber;
|
|
62
|
+
startedAt: z.ZodNumber;
|
|
63
|
+
lastHeartbeatAt: z.ZodNumber;
|
|
64
|
+
heartbeatAgeMs: z.ZodNumber;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
deploymentVersion: z.ZodObject<{
|
|
67
|
+
deploymentName: z.ZodString;
|
|
68
|
+
buildId: z.ZodString;
|
|
69
|
+
artifactDigest: z.ZodString;
|
|
70
|
+
runtimeName: z.ZodString;
|
|
71
|
+
runtimeVersion: z.ZodString;
|
|
72
|
+
sdkVersion: z.ZodString;
|
|
73
|
+
manifestVersion: z.ZodNumber;
|
|
74
|
+
protocolVersion: z.ZodNumber;
|
|
75
|
+
manifestDigest: z.ZodString;
|
|
76
|
+
workflows: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
77
|
+
workflowVersion: z.ZodString;
|
|
78
|
+
workflowRevision: z.ZodString;
|
|
79
|
+
contractHash: z.ZodString;
|
|
80
|
+
activities: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
81
|
+
contractHash: z.ZodString;
|
|
82
|
+
implementationRevision: z.ZodString;
|
|
83
|
+
}, z.core.$strict>>;
|
|
84
|
+
}, z.core.$strict>>;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
}, z.core.$strict>>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type GetWorkerDiagnosticsInput = z.infer<typeof getWorkerDiagnosticsInput>;
|
|
89
|
+
export type WorkerDiagnosticsEntry = z.infer<typeof workerDiagnosticsEntrySchema>;
|
|
90
|
+
export type GetWorkerDiagnosticsOutput = z.infer<typeof getWorkerDiagnosticsOutput>;
|
|
91
|
+
type GetWorkerDiagnosticsOptions = {
|
|
92
|
+
workerRegistry?: WorkerRegistry;
|
|
93
|
+
clock?: () => number;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Build the `weft.workers.diagnostics` operation, optionally bound to a live
|
|
97
|
+
* `WorkerRegistry` and clock. Mirrors `createListWorkersOperation`'s
|
|
98
|
+
* discovery-only fallback: when `workerRegistry` is omitted, `invoke` throws
|
|
99
|
+
* if reached — reserved for discovery-only registries (OpenAPI/AsyncAPI).
|
|
100
|
+
*/
|
|
101
|
+
export declare function createGetWorkerDiagnosticsOperation(options?: GetWorkerDiagnosticsOptions): import("../operation-catalog.ts").OperationDefinition<{
|
|
102
|
+
workerId: string;
|
|
103
|
+
}, {
|
|
104
|
+
worker: {
|
|
105
|
+
instance: {
|
|
106
|
+
workerId: string;
|
|
107
|
+
queue: string;
|
|
108
|
+
health: WorkerHealth;
|
|
109
|
+
connectedAt: number;
|
|
110
|
+
startedAt: number;
|
|
111
|
+
lastHeartbeatAt: number;
|
|
112
|
+
heartbeatAgeMs: number;
|
|
113
|
+
};
|
|
114
|
+
deploymentVersion: {
|
|
115
|
+
deploymentName: string;
|
|
116
|
+
buildId: string;
|
|
117
|
+
artifactDigest: string;
|
|
118
|
+
runtimeName: string;
|
|
119
|
+
runtimeVersion: string;
|
|
120
|
+
sdkVersion: string;
|
|
121
|
+
manifestVersion: number;
|
|
122
|
+
protocolVersion: number;
|
|
123
|
+
manifestDigest: string;
|
|
124
|
+
workflows: Record<string, {
|
|
125
|
+
workflowVersion: string;
|
|
126
|
+
workflowRevision: string;
|
|
127
|
+
contractHash: string;
|
|
128
|
+
activities: Record<string, {
|
|
129
|
+
contractHash: string;
|
|
130
|
+
implementationRevision: string;
|
|
131
|
+
}>;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
} | null;
|
|
135
|
+
}, unknown>;
|
|
136
|
+
/** Default discovery-only operation; live servers use `createGetWorkerDiagnosticsOperation(...)`. */
|
|
137
|
+
export declare const getWorkerDiagnosticsOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
138
|
+
workerId: string;
|
|
139
|
+
}, {
|
|
140
|
+
worker: {
|
|
141
|
+
instance: {
|
|
142
|
+
workerId: string;
|
|
143
|
+
queue: string;
|
|
144
|
+
health: WorkerHealth;
|
|
145
|
+
connectedAt: number;
|
|
146
|
+
startedAt: number;
|
|
147
|
+
lastHeartbeatAt: number;
|
|
148
|
+
heartbeatAgeMs: number;
|
|
149
|
+
};
|
|
150
|
+
deploymentVersion: {
|
|
151
|
+
deploymentName: string;
|
|
152
|
+
buildId: string;
|
|
153
|
+
artifactDigest: string;
|
|
154
|
+
runtimeName: string;
|
|
155
|
+
runtimeVersion: string;
|
|
156
|
+
sdkVersion: string;
|
|
157
|
+
manifestVersion: number;
|
|
158
|
+
protocolVersion: number;
|
|
159
|
+
manifestDigest: string;
|
|
160
|
+
workflows: Record<string, {
|
|
161
|
+
workflowVersion: string;
|
|
162
|
+
workflowRevision: string;
|
|
163
|
+
contractHash: string;
|
|
164
|
+
activities: Record<string, {
|
|
165
|
+
contractHash: string;
|
|
166
|
+
implementationRevision: string;
|
|
167
|
+
}>;
|
|
168
|
+
}>;
|
|
169
|
+
};
|
|
170
|
+
} | null;
|
|
171
|
+
}, unknown>;
|
|
172
|
+
/**
|
|
173
|
+
* Build the REST binding for `weft.workers.diagnostics`. The binding is
|
|
174
|
+
* metadata only; the live `WorkerRegistry` is wired into the operation.
|
|
175
|
+
*/
|
|
176
|
+
export declare function createGetWorkerDiagnosticsRestBinding(): UnknownRestBinding;
|
|
177
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { shapeOperationFaultAsJson } from "../operation-fault.js";
|
|
3
|
+
import { defineOperation } from "../operation-registry.js";
|
|
4
|
+
const workerHealthSchema = z.enum(["active", "draining", "drained"]), workerActivityContractSchema = z.object({
|
|
5
|
+
contractHash: z.string(),
|
|
6
|
+
implementationRevision: z.string()
|
|
7
|
+
}).strict(), workerWorkflowContractSummarySchema = z.object({
|
|
8
|
+
workflowVersion: z.string(),
|
|
9
|
+
workflowRevision: z.string(),
|
|
10
|
+
contractHash: z.string(),
|
|
11
|
+
activities: z.record(z.string(), workerActivityContractSchema)
|
|
12
|
+
}).strict(), workerInstanceIdentitySchema = z.object({
|
|
13
|
+
workerId: z.string(),
|
|
14
|
+
queue: z.string(),
|
|
15
|
+
health: workerHealthSchema,
|
|
16
|
+
connectedAt: z.number(),
|
|
17
|
+
startedAt: z.number(),
|
|
18
|
+
lastHeartbeatAt: z.number(),
|
|
19
|
+
heartbeatAgeMs: z.number()
|
|
20
|
+
}).strict(), workerDeploymentVersionIdentitySchema = z.object({
|
|
21
|
+
deploymentName: z.string(),
|
|
22
|
+
buildId: z.string(),
|
|
23
|
+
artifactDigest: z.string(),
|
|
24
|
+
runtimeName: z.string(),
|
|
25
|
+
runtimeVersion: z.string(),
|
|
26
|
+
sdkVersion: z.string(),
|
|
27
|
+
manifestVersion: z.number(),
|
|
28
|
+
protocolVersion: z.number(),
|
|
29
|
+
manifestDigest: z.string(),
|
|
30
|
+
workflows: z.record(z.string(), workerWorkflowContractSummarySchema)
|
|
31
|
+
}).strict(), workerDiagnosticsEntrySchema = z.object({
|
|
32
|
+
instance: workerInstanceIdentitySchema,
|
|
33
|
+
deploymentVersion: workerDeploymentVersionIdentitySchema
|
|
34
|
+
}).strict(), getWorkerDiagnosticsInput = z.object({
|
|
35
|
+
workerId: z.string().min(1)
|
|
36
|
+
}), getWorkerDiagnosticsOutput = z.object({
|
|
37
|
+
worker: workerDiagnosticsEntrySchema.nullable()
|
|
38
|
+
});
|
|
39
|
+
function projectWorkerDiagnostics(registry, workerId, now) {
|
|
40
|
+
const worker = registry.getWorker(workerId);
|
|
41
|
+
if (worker === void 0)
|
|
42
|
+
return null;
|
|
43
|
+
const summary = registry.getWorkerSummaries(now).find((entry) => entry.id === workerId);
|
|
44
|
+
if (summary === void 0)
|
|
45
|
+
return null;
|
|
46
|
+
const workflows = {};
|
|
47
|
+
for (const [workflowType, contract] of Object.entries(worker.manifest.workflows))
|
|
48
|
+
workflows[workflowType] = {
|
|
49
|
+
workflowVersion: contract.workflowVersion,
|
|
50
|
+
workflowRevision: contract.workflowRevision,
|
|
51
|
+
contractHash: contract.contractHash,
|
|
52
|
+
activities: { ...contract.activities }
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
instance: {
|
|
56
|
+
workerId: worker.id,
|
|
57
|
+
queue: worker.queue,
|
|
58
|
+
health: summary.health,
|
|
59
|
+
connectedAt: worker.connectedAt,
|
|
60
|
+
startedAt: worker.startedAt,
|
|
61
|
+
lastHeartbeatAt: worker.lastHeartbeat,
|
|
62
|
+
heartbeatAgeMs: summary.heartbeatAgeMs
|
|
63
|
+
},
|
|
64
|
+
deploymentVersion: {
|
|
65
|
+
deploymentName: worker.manifest.deployment.name,
|
|
66
|
+
buildId: worker.manifest.deployment.buildId,
|
|
67
|
+
artifactDigest: worker.manifest.deployment.artifactDigest,
|
|
68
|
+
runtimeName: worker.manifest.runtime.name,
|
|
69
|
+
runtimeVersion: worker.manifest.runtime.version,
|
|
70
|
+
sdkVersion: worker.manifest.sdkVersion,
|
|
71
|
+
manifestVersion: worker.manifest.manifestVersion,
|
|
72
|
+
protocolVersion: worker.manifest.protocolVersion,
|
|
73
|
+
manifestDigest: worker.acceptedManifestDigest,
|
|
74
|
+
workflows
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function createGetWorkerDiagnosticsOperation(options = {}) {
|
|
79
|
+
const registry = options.workerRegistry, clock = options.clock ?? Date.now;
|
|
80
|
+
return defineOperation({
|
|
81
|
+
name: "weft.workers.diagnostics",
|
|
82
|
+
mcpExposable: !1,
|
|
83
|
+
summary: "Get bounded instance and deployment-version diagnostics for one connected worker",
|
|
84
|
+
description: "Report one connected worker's identity split into two parts: `instance` (this live " + "connection \u2014 queue, health, connection timestamps) and `deploymentVersion` (the " + "artifact it loaded \u2014 SDK/runtime identity, manifest digest, and every advertised " + "workflow's version, revision, and contract hash). Returns `worker: null` when the workerId is not currently connected. Excludes capabilities and raw payload schemas.",
|
|
85
|
+
destructive: !1,
|
|
86
|
+
tags: ["Observability"],
|
|
87
|
+
inputSchema: getWorkerDiagnosticsInput,
|
|
88
|
+
outputSchema: getWorkerDiagnosticsOutput,
|
|
89
|
+
access: { kind: "scoped", scopes: { kind: "anyOf", scopes: ["system:read"] } },
|
|
90
|
+
producibleFaults: [],
|
|
91
|
+
discoverable: !0,
|
|
92
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
93
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
94
|
+
invoke: async ({ input }) => {
|
|
95
|
+
if (registry === void 0)
|
|
96
|
+
throw Error("weft.workers.diagnostics invoked from a discovery-only operation registry; no WorkerRegistry was wired in");
|
|
97
|
+
return { worker: projectWorkerDiagnostics(registry, input.workerId, clock()) };
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export const getWorkerDiagnosticsOperation = createGetWorkerDiagnosticsOperation();
|
|
102
|
+
export function createGetWorkerDiagnosticsRestBinding() {
|
|
103
|
+
return {
|
|
104
|
+
method: "GET",
|
|
105
|
+
path: "/v1/workers/:workerId/diagnostics",
|
|
106
|
+
pathParamNames: ["workerId"],
|
|
107
|
+
operationName: "weft.workers.diagnostics",
|
|
108
|
+
inputSources: {
|
|
109
|
+
workerId: { kind: "path", pathParam: "workerId" }
|
|
110
|
+
},
|
|
111
|
+
extractInput: async (_request, pathParams) => ({
|
|
112
|
+
workerId: pathParams.workerId ?? ""
|
|
113
|
+
}),
|
|
114
|
+
success: { kind: "json", status: 200 },
|
|
115
|
+
shapeFault: shapeOperationFaultAsJson
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weft.workers.rejections` operation + REST binding.
|
|
3
|
+
*
|
|
4
|
+
* Bounded, auditable log of recently declined `register` attempts (WFT-29):
|
|
5
|
+
* the rejection code, the attempted workerId when known, and whatever
|
|
6
|
+
* deployment/queue identity had already been parsed by the time the gate
|
|
7
|
+
* that rejected it ran. No free-text rejection message and no manifest
|
|
8
|
+
* content — this surfaces "who got rejected, when, and why (by code)", not
|
|
9
|
+
* a diagnostic dump.
|
|
10
|
+
*
|
|
11
|
+
* @module server/operations/list-worker-registration-rejections
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import type { WorkerRegistry } from '../../worker/registry.ts';
|
|
15
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
16
|
+
declare const listWorkerRegistrationRejectionsInput: z.ZodObject<{
|
|
17
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
declare const listWorkerRegistrationRejectionsOutput: z.ZodObject<{
|
|
20
|
+
items: z.ZodArray<z.ZodObject<{
|
|
21
|
+
code: z.ZodEnum<{
|
|
22
|
+
invalid_registration: "invalid_registration";
|
|
23
|
+
unsupported_protocol_version: "unsupported_protocol_version";
|
|
24
|
+
deployment_conflict: "deployment_conflict";
|
|
25
|
+
registration_rejected: "registration_rejected";
|
|
26
|
+
}>;
|
|
27
|
+
workerId: z.ZodOptional<z.ZodString>;
|
|
28
|
+
rejectedAt: z.ZodNumber;
|
|
29
|
+
queue: z.ZodOptional<z.ZodString>;
|
|
30
|
+
deploymentName: z.ZodOptional<z.ZodString>;
|
|
31
|
+
buildId: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strict>>;
|
|
33
|
+
limit: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type ListWorkerRegistrationRejectionsInput = z.infer<typeof listWorkerRegistrationRejectionsInput>;
|
|
36
|
+
export type ListWorkerRegistrationRejectionsOutput = z.infer<typeof listWorkerRegistrationRejectionsOutput>;
|
|
37
|
+
type ListWorkerRegistrationRejectionsOptions = {
|
|
38
|
+
workerRegistry?: WorkerRegistry;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Build the `weft.workers.rejections` operation, optionally bound to a live
|
|
42
|
+
* `WorkerRegistry`. Mirrors `createListWorkersOperation`'s discovery-only
|
|
43
|
+
* fallback: when `workerRegistry` is omitted, `invoke` throws if reached —
|
|
44
|
+
* reserved for discovery-only registries (OpenAPI/AsyncAPI).
|
|
45
|
+
*/
|
|
46
|
+
export declare function createListWorkerRegistrationRejectionsOperation(options?: ListWorkerRegistrationRejectionsOptions): import("../operation-catalog.ts").OperationDefinition<{
|
|
47
|
+
limit: number;
|
|
48
|
+
}, {
|
|
49
|
+
items: {
|
|
50
|
+
code: "invalid_registration" | "unsupported_protocol_version" | "deployment_conflict" | "registration_rejected";
|
|
51
|
+
rejectedAt: number;
|
|
52
|
+
workerId?: string | undefined;
|
|
53
|
+
queue?: string | undefined;
|
|
54
|
+
deploymentName?: string | undefined;
|
|
55
|
+
buildId?: string | undefined;
|
|
56
|
+
}[];
|
|
57
|
+
limit: number;
|
|
58
|
+
}, unknown>;
|
|
59
|
+
/** Default discovery-only operation; live servers use `createListWorkerRegistrationRejectionsOperation(...)`. */
|
|
60
|
+
export declare const listWorkerRegistrationRejectionsOperation: import("../operation-catalog.ts").OperationDefinition<{
|
|
61
|
+
limit: number;
|
|
62
|
+
}, {
|
|
63
|
+
items: {
|
|
64
|
+
code: "invalid_registration" | "unsupported_protocol_version" | "deployment_conflict" | "registration_rejected";
|
|
65
|
+
rejectedAt: number;
|
|
66
|
+
workerId?: string | undefined;
|
|
67
|
+
queue?: string | undefined;
|
|
68
|
+
deploymentName?: string | undefined;
|
|
69
|
+
buildId?: string | undefined;
|
|
70
|
+
}[];
|
|
71
|
+
limit: number;
|
|
72
|
+
}, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Build the REST binding for `weft.workers.rejections`. The
|
|
75
|
+
* binding is metadata only; the live `WorkerRegistry` is wired into the
|
|
76
|
+
* operation, not the binding.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createListWorkerRegistrationRejectionsRestBinding(): UnknownRestBinding;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineOperation } from "../operation-registry.js";
|
|
3
|
+
const DEFAULT_LIMIT = 20, MAX_LIMIT = 100, registrationRejectionCodeSchema = z.enum([
|
|
4
|
+
"invalid_registration",
|
|
5
|
+
"unsupported_protocol_version",
|
|
6
|
+
"deployment_conflict",
|
|
7
|
+
"registration_rejected"
|
|
8
|
+
]), registrationRejectionEntrySchema = z.object({
|
|
9
|
+
code: registrationRejectionCodeSchema,
|
|
10
|
+
workerId: z.string().optional(),
|
|
11
|
+
rejectedAt: z.number(),
|
|
12
|
+
queue: z.string().optional(),
|
|
13
|
+
deploymentName: z.string().optional(),
|
|
14
|
+
buildId: z.string().optional()
|
|
15
|
+
}).strict(), listWorkerRegistrationRejectionsInput = z.object({
|
|
16
|
+
limit: z.number().int().min(1).max(MAX_LIMIT).default(DEFAULT_LIMIT)
|
|
17
|
+
}), listWorkerRegistrationRejectionsOutput = z.object({
|
|
18
|
+
items: z.array(registrationRejectionEntrySchema),
|
|
19
|
+
limit: z.number().int().min(1).max(MAX_LIMIT)
|
|
20
|
+
});
|
|
21
|
+
export function createListWorkerRegistrationRejectionsOperation(options = {}) {
|
|
22
|
+
const registry = options.workerRegistry;
|
|
23
|
+
return defineOperation({
|
|
24
|
+
name: "weft.workers.rejections",
|
|
25
|
+
mcpExposable: !1,
|
|
26
|
+
summary: "List recently declined worker registration attempts",
|
|
27
|
+
description: "Bounded, most-recent-first log of declined `register` attempts: rejection code, attempted workerId when known, and whatever deployment/queue identity had already been parsed by the time the rejecting gate ran. No free-text message and no manifest content.",
|
|
28
|
+
destructive: !1,
|
|
29
|
+
tags: ["Observability"],
|
|
30
|
+
inputSchema: listWorkerRegistrationRejectionsInput,
|
|
31
|
+
outputSchema: listWorkerRegistrationRejectionsOutput,
|
|
32
|
+
access: { kind: "scoped", scopes: { kind: "anyOf", scopes: ["system:read"] } },
|
|
33
|
+
producibleFaults: [],
|
|
34
|
+
discoverable: !0,
|
|
35
|
+
transports: { http: !0, jsonRpcHttp: !0, jsonRpcWebSocket: !0, jsonRpcStdio: !0 },
|
|
36
|
+
unknownKeyPolicy: { http: "strip", jsonRpc: "reject" },
|
|
37
|
+
invoke: async ({ input }) => {
|
|
38
|
+
if (registry === void 0)
|
|
39
|
+
throw Error("weft.workers.rejections invoked from a discovery-only operation registry; no WorkerRegistry was wired in");
|
|
40
|
+
return { items: registry.getRecentRejections(input.limit), limit: input.limit };
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export const listWorkerRegistrationRejectionsOperation = createListWorkerRegistrationRejectionsOperation();
|
|
45
|
+
export function createListWorkerRegistrationRejectionsRestBinding() {
|
|
46
|
+
return {
|
|
47
|
+
method: "GET",
|
|
48
|
+
path: "/v1/workers/registration-rejections",
|
|
49
|
+
pathParamNames: [],
|
|
50
|
+
operationName: "weft.workers.rejections",
|
|
51
|
+
inputSources: {
|
|
52
|
+
limit: { kind: "query", queryParam: "limit" }
|
|
53
|
+
},
|
|
54
|
+
extractInput: async (request) => {
|
|
55
|
+
const limit = new URL(request.url).searchParams.get("limit");
|
|
56
|
+
return { limit: limit === null || limit.length === 0 ? void 0 : Number(limit) };
|
|
57
|
+
},
|
|
58
|
+
success: { kind: "json", status: 200 }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -27,13 +27,11 @@ const listWorkersInput = z.object({}), routingPolicySchema = z.enum([
|
|
|
27
27
|
health: workerHealthSchema,
|
|
28
28
|
deploymentName: z.string().optional(),
|
|
29
29
|
buildId: z.string().optional(),
|
|
30
|
-
runtimeVersion: z.string().optional()
|
|
31
|
-
gitSha: z.string().optional()
|
|
30
|
+
runtimeVersion: z.string().optional()
|
|
32
31
|
}), workerDeploymentSummarySchema = z.object({
|
|
33
32
|
deploymentName: z.string().nullable(),
|
|
34
33
|
buildId: z.string().nullable(),
|
|
35
34
|
runtimeVersion: z.string().nullable(),
|
|
36
|
-
gitSha: z.string().nullable(),
|
|
37
35
|
health: workerHealthSchema,
|
|
38
36
|
workers: z.number(),
|
|
39
37
|
activeWorkers: z.number(),
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static operation and REST-binding registrations — every operation that
|
|
3
|
+
* needs no per-server configuration, in one place.
|
|
4
|
+
*
|
|
5
|
+
* `rest-bindings.ts` composes these arrays with the per-server factory
|
|
6
|
+
* operations (metrics, workers, task queues, diagnostics) to build the live
|
|
7
|
+
* registry and binding set. Adding a new statically-configured operation
|
|
8
|
+
* means adding its import and two array entries HERE; `rest-bindings.ts`
|
|
9
|
+
* itself only changes when an operation needs per-server wiring.
|
|
10
|
+
*
|
|
11
|
+
* @module server/operations/static-registrations
|
|
12
|
+
*/
|
|
13
|
+
import type { RegistrableOperation } from '../operation-catalog.ts';
|
|
14
|
+
import type { UnknownRestBinding } from '../rest-bindings.ts';
|
|
15
|
+
/**
|
|
16
|
+
* Static REST bindings for all operations that do not need per-server
|
|
17
|
+
* configuration. `rest-bindings.ts` re-exports this as `REST_BINDINGS` and
|
|
18
|
+
* appends the per-server factory bindings in `createLiveRestBindings()`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const STATIC_REST_BINDINGS: ReadonlyArray<UnknownRestBinding>;
|
|
21
|
+
/**
|
|
22
|
+
* Statically-configured operations, in registration order.
|
|
23
|
+
* `rest-bindings.ts`'s `createLiveOperationRegistry()` appends the
|
|
24
|
+
* per-server factory operations (metrics, workers, task queues,
|
|
25
|
+
* diagnostics); the registry is keyed by operation name, so relative
|
|
26
|
+
* order carries no behavior.
|
|
27
|
+
*/
|
|
28
|
+
export declare const STATIC_OPERATIONS: ReadonlyArray<RegistrableOperation>;
|