@kici-dev/engine 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +1 -6
- package/dist/audit/access-log-policy.d.ts +97 -0
- package/dist/audit/access-log-policy.js +195 -0
- package/dist/audit/activity.d.ts +156 -0
- package/dist/audit/activity.js +175 -0
- package/dist/audit/retention-policy.d.ts +157 -0
- package/dist/audit/retention-policy.js +364 -0
- package/dist/bundler/index.d.ts +3 -0
- package/dist/bundler/index.js +3 -0
- package/dist/bundler/rolldown-config.d.ts +41 -0
- package/dist/bundler/rolldown-config.js +40 -0
- package/dist/chunk-gOLHoazu.js +4 -0
- package/dist/env/environment-allowlist.d.ts +45 -0
- package/dist/env/environment-allowlist.js +69 -0
- package/dist/environment/index.d.ts +3 -0
- package/dist/environment/index.js +3 -0
- package/dist/environment/scope-resolver.d.ts +35 -0
- package/dist/environment/scope-resolver.js +77 -0
- package/dist/environment/types.d.ts +98 -0
- package/dist/environment/types.js +2 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +45 -0
- package/dist/labels.d.ts +106 -0
- package/dist/labels.js +162 -0
- package/dist/metrics/metric-catalog.generated.d.ts +400 -0
- package/dist/metrics/metric-catalog.generated.js +510 -0
- package/dist/protocol/dashboard-global-workflows.d.ts +9 -0
- package/dist/protocol/dashboard-global-workflows.js +3 -0
- package/dist/protocol/event-log-payload.d.ts +16 -0
- package/dist/protocol/event-log-payload.js +21 -0
- package/dist/protocol/messages/access-log.d.ts +545 -0
- package/dist/protocol/messages/access-log.js +175 -0
- package/dist/protocol/messages/actor.d.ts +100 -0
- package/dist/protocol/messages/actor.js +139 -0
- package/dist/protocol/messages/auth.d.ts +25 -0
- package/dist/protocol/messages/auth.js +36 -0
- package/dist/protocol/messages/browser.d.ts +369 -0
- package/dist/protocol/messages/browser.js +225 -0
- package/dist/protocol/messages/capabilities.d.ts +46 -0
- package/dist/protocol/messages/capabilities.js +42 -0
- package/dist/protocol/messages/common.d.ts +53 -0
- package/dist/protocol/messages/common.js +55 -0
- package/dist/protocol/messages/dashboard-global-workflows.d.ts +166 -0
- package/dist/protocol/messages/dashboard-global-workflows.js +80 -0
- package/dist/protocol/messages/dashboard.d.ts +4068 -0
- package/dist/protocol/messages/dashboard.js +1237 -0
- package/dist/protocol/messages/event-log.d.ts +49 -0
- package/dist/protocol/messages/event-log.js +45 -0
- package/dist/protocol/messages/execution-status.d.ts +164 -0
- package/dist/protocol/messages/execution-status.js +166 -0
- package/dist/protocol/messages/join.d.ts +18 -0
- package/dist/protocol/messages/join.js +28 -0
- package/dist/protocol/messages/log-pull.d.ts +27 -0
- package/dist/protocol/messages/log-pull.js +36 -0
- package/dist/protocol/messages/observe.d.ts +75 -0
- package/dist/protocol/messages/observe.js +70 -0
- package/dist/protocol/messages/orchestrator-agent.d.ts +606 -0
- package/dist/protocol/messages/orchestrator-agent.js +481 -0
- package/dist/protocol/messages/peer.d.ts +795 -0
- package/dist/protocol/messages/peer.js +372 -0
- package/dist/protocol/messages/platform-orchestrator.d.ts +1888 -0
- package/dist/protocol/messages/platform-orchestrator.js +379 -0
- package/dist/protocol/messages/run-events.d.ts +155 -0
- package/dist/protocol/messages/run-events.js +115 -0
- package/dist/protocol/messages/saas-orchestrator.d.ts +2179 -0
- package/dist/protocol/messages/source-registration.d.ts +103 -0
- package/dist/protocol/messages/source-registration.js +109 -0
- package/dist/protocol/messages/test-run.d.ts +59 -0
- package/dist/protocol/messages/test-run.js +52 -0
- package/dist/protocol/version.d.ts +12 -0
- package/dist/protocol/version.js +17 -0
- package/dist/provider/changed-files-fetcher.d.ts +24 -0
- package/dist/provider/changed-files-fetcher.js +2 -0
- package/dist/provider/check-run-conclusion.d.ts +15 -0
- package/dist/provider/check-run-conclusion.js +19 -0
- package/dist/provider/check-status-poster.d.ts +15 -0
- package/dist/provider/check-status-poster.js +2 -0
- package/dist/provider/clone-token-provider.d.ts +58 -0
- package/dist/provider/clone-token-provider.js +2 -0
- package/dist/provider/contributor-resolver.d.ts +22 -0
- package/dist/provider/contributor-resolver.js +2 -0
- package/dist/provider/index.d.ts +23 -0
- package/dist/provider/index.js +3 -0
- package/dist/provider/lock-file-fetcher.d.ts +24 -0
- package/dist/provider/lock-file-fetcher.js +2 -0
- package/dist/provider/repo-url-builder.d.ts +35 -0
- package/dist/provider/repo-url-builder.js +2 -0
- package/dist/provider/types.d.ts +9 -0
- package/dist/provider/types.js +2 -0
- package/dist/provider/webhook-normalizer.d.ts +163 -0
- package/dist/provider/webhook-normalizer.js +2 -0
- package/dist/registration/registerable-trigger-type.d.ts +52 -0
- package/dist/registration/registerable-trigger-type.js +56 -0
- package/dist/scaler/resource-types.d.ts +90 -0
- package/dist/scaler/resource-types.js +99 -0
- package/dist/scaler/scaler-backend-type.d.ts +16 -0
- package/dist/scaler/scaler-backend-type.js +20 -0
- package/dist/secrets/index.d.ts +7 -0
- package/dist/secrets/index.js +2 -0
- package/dist/secrets/types.d.ts +138 -0
- package/dist/secrets/types.js +2 -0
- package/dist/state-machine/index.d.ts +2 -0
- package/dist/state-machine/index.js +3 -0
- package/dist/state-machine/machine.d.ts +34 -0
- package/dist/state-machine/machine.js +103 -0
- package/dist/state-machine/types.d.ts +34 -0
- package/dist/state-machine/types.js +15 -0
- package/dist/trigger/decision-trace.d.ts +41 -0
- package/dist/trigger/decision-trace.js +30 -0
- package/dist/trigger/jsonpath-matcher.d.ts +27 -0
- package/dist/trigger/jsonpath-matcher.js +92 -0
- package/dist/trigger/matcher.d.ts +29 -0
- package/dist/trigger/matcher.js +704 -0
- package/dist/trigger/trigger-event-type.d.ts +14 -0
- package/dist/trigger/trigger-event-type.js +66 -0
- package/dist/trigger/types.d.ts +524 -0
- package/dist/trigger/types.js +48 -0
- package/dist/webhook/signature.d.ts +15 -0
- package/dist/webhook/signature.js +32 -0
- package/dist/ws/close-codes.d.ts +28 -0
- package/dist/ws/close-codes.js +33 -0
- package/dist/ws/rate-limiter.d.ts +86 -0
- package/dist/ws/rate-limiter.js +136 -0
- package/dist/ws/ws-like.d.ts +12 -0
- package/dist/ws/ws-like.js +2 -0
- package/package.json +54 -6
- package/sbom.spdx.json +202 -0
- package/index.js +0 -3
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-Platform WebSocket protocol schemas.
|
|
3
|
+
*
|
|
4
|
+
* Defines all message types for the browser <-> Platform WS connection:
|
|
5
|
+
* - Browser -> Platform: auth, log subscribe/unsubscribe, status subscribe/unsubscribe
|
|
6
|
+
* - Platform -> Browser: auth response, log lines, gap, run/job/step status, error
|
|
7
|
+
*
|
|
8
|
+
* Follows the same Zod-based pattern as platform-orchestrator.ts and other protocol schemas.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
/** Browser sends JWT token for authentication (first message after WS open). */
|
|
12
|
+
export declare const browserAuthRequestSchema: z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"auth.request">;
|
|
14
|
+
token: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
/** Browser sends a refreshed JWT token to extend the session. */
|
|
17
|
+
export declare const browserAuthRefreshSchema: z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"auth.refresh">;
|
|
19
|
+
token: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
/** Browser subscribes to log lines for a specific step. */
|
|
22
|
+
export declare const browserLogSubscribeSchema: z.ZodObject<{
|
|
23
|
+
type: z.ZodLiteral<"log.subscribe">;
|
|
24
|
+
runId: z.ZodString;
|
|
25
|
+
jobId: z.ZodString;
|
|
26
|
+
stepIndex: z.ZodNumber;
|
|
27
|
+
afterLineCount: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
/** Browser unsubscribes from log lines for a specific step. */
|
|
30
|
+
export declare const browserLogUnsubscribeSchema: z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"log.unsubscribe">;
|
|
32
|
+
runId: z.ZodString;
|
|
33
|
+
jobId: z.ZodString;
|
|
34
|
+
stepIndex: z.ZodNumber;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
/** Browser subscribes to org-level status updates (run/job/step status changes). */
|
|
37
|
+
export declare const browserStatusSubscribeSchema: z.ZodObject<{
|
|
38
|
+
type: z.ZodLiteral<"status.subscribe">;
|
|
39
|
+
scope: z.ZodLiteral<"org">;
|
|
40
|
+
orgId: z.ZodString;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
/** Browser unsubscribes from status updates. */
|
|
43
|
+
export declare const browserStatusUnsubscribeSchema: z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"status.unsubscribe">;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
/** Browser sends a keepalive ping to prevent LB idle timeout. */
|
|
47
|
+
export declare const browserPingSchema: z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"ping">;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
/**
|
|
51
|
+
* Browser asks Platform to begin streaming the body of an event-log delivery.
|
|
52
|
+
*
|
|
53
|
+
* The dashboard generates `requestId` (uuid) per fetch so it can correlate
|
|
54
|
+
* incoming chunks. `orgId` is NOT taken from the wire — Platform's
|
|
55
|
+
* browser-handler resolves the run's owning org from the user's membership
|
|
56
|
+
* and gates on `event_log:read_payload`. Same trust model as the existing
|
|
57
|
+
* `log.subscribe` message.
|
|
58
|
+
*/
|
|
59
|
+
export declare const browserEventLogPayloadFetchSchema: z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"event-log.payload.fetch">;
|
|
61
|
+
requestId: z.ZodString;
|
|
62
|
+
orgId: z.ZodString;
|
|
63
|
+
deliveryId: z.ZodString;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
/** All messages that flow from Browser to Platform. */
|
|
66
|
+
export declare const browserToPlatformMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
67
|
+
type: z.ZodLiteral<"auth.request">;
|
|
68
|
+
token: z.ZodString;
|
|
69
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
70
|
+
type: z.ZodLiteral<"auth.refresh">;
|
|
71
|
+
token: z.ZodString;
|
|
72
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
73
|
+
type: z.ZodLiteral<"log.subscribe">;
|
|
74
|
+
runId: z.ZodString;
|
|
75
|
+
jobId: z.ZodString;
|
|
76
|
+
stepIndex: z.ZodNumber;
|
|
77
|
+
afterLineCount: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<"log.unsubscribe">;
|
|
80
|
+
runId: z.ZodString;
|
|
81
|
+
jobId: z.ZodString;
|
|
82
|
+
stepIndex: z.ZodNumber;
|
|
83
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
+
type: z.ZodLiteral<"status.subscribe">;
|
|
85
|
+
scope: z.ZodLiteral<"org">;
|
|
86
|
+
orgId: z.ZodString;
|
|
87
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
88
|
+
type: z.ZodLiteral<"status.unsubscribe">;
|
|
89
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
90
|
+
type: z.ZodLiteral<"event-log.payload.fetch">;
|
|
91
|
+
requestId: z.ZodString;
|
|
92
|
+
orgId: z.ZodString;
|
|
93
|
+
deliveryId: z.ZodString;
|
|
94
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
95
|
+
type: z.ZodLiteral<"ping">;
|
|
96
|
+
}, z.core.$strip>], "type">;
|
|
97
|
+
/** Platform confirms browser authentication. */
|
|
98
|
+
export declare const browserAuthSuccessSchema: z.ZodObject<{
|
|
99
|
+
type: z.ZodLiteral<"auth.success">;
|
|
100
|
+
connectionId: z.ZodString;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
/** Platform rejects browser authentication. */
|
|
103
|
+
export declare const browserAuthFailureSchema: z.ZodObject<{
|
|
104
|
+
type: z.ZodLiteral<"auth.failure">;
|
|
105
|
+
reason: z.ZodString;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
/** Platform sends log lines for a subscribed step. */
|
|
108
|
+
export declare const browserLogLinesSchema: z.ZodObject<{
|
|
109
|
+
type: z.ZodLiteral<"log.lines">;
|
|
110
|
+
runId: z.ZodString;
|
|
111
|
+
jobId: z.ZodString;
|
|
112
|
+
stepIndex: z.ZodNumber;
|
|
113
|
+
lines: z.ZodArray<z.ZodString>;
|
|
114
|
+
lineCount: z.ZodNumber;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
/** Platform notifies browser that lines were dropped due to backpressure. */
|
|
117
|
+
export declare const browserGapSchema: z.ZodObject<{
|
|
118
|
+
type: z.ZodLiteral<"log.gap">;
|
|
119
|
+
runId: z.ZodString;
|
|
120
|
+
jobId: z.ZodString;
|
|
121
|
+
stepIndex: z.ZodNumber;
|
|
122
|
+
droppedLineCount: z.ZodNumber;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
/**
|
|
125
|
+
* Reason a live-log stream was terminated by the Platform.
|
|
126
|
+
*
|
|
127
|
+
* Currently only `plan_limit_live_log_minutes` (daily live-log minute cap
|
|
128
|
+
* exceeded). New reasons land here as the Platform grows more enforcement
|
|
129
|
+
* surfaces (e.g. retention, manual operator kick).
|
|
130
|
+
*/
|
|
131
|
+
export declare const browserLogStreamTerminatedReason: z.ZodEnum<{
|
|
132
|
+
plan_limit_live_log_minutes: "plan_limit_live_log_minutes";
|
|
133
|
+
}>;
|
|
134
|
+
export type BrowserLogStreamTerminatedReason = z.infer<typeof browserLogStreamTerminatedReason>;
|
|
135
|
+
/**
|
|
136
|
+
* Platform notifies browser that a live-log stream has been terminated.
|
|
137
|
+
*
|
|
138
|
+
* Sent in two cases:
|
|
139
|
+
* 1. **At subscribe time:** the org is already over the daily live-log
|
|
140
|
+
* minute cap when the browser sends `log.subscribe`. The Platform
|
|
141
|
+
* sends `log.stream.terminated` and never registers the subscription.
|
|
142
|
+
* 2. **Mid-stream:** the periodic metering tick observed the org just
|
|
143
|
+
* crossed the cap. The Platform sends `log.stream.terminated` to all
|
|
144
|
+
* active log subscribers in that org and unregisters them.
|
|
145
|
+
*
|
|
146
|
+
* Browsers should display the upgrade prompt and NOT auto-resubscribe.
|
|
147
|
+
*/
|
|
148
|
+
export declare const browserLogStreamTerminatedSchema: z.ZodObject<{
|
|
149
|
+
type: z.ZodLiteral<"log.stream.terminated">;
|
|
150
|
+
runId: z.ZodString;
|
|
151
|
+
jobId: z.ZodString;
|
|
152
|
+
stepIndex: z.ZodNumber;
|
|
153
|
+
reason: z.ZodEnum<{
|
|
154
|
+
plan_limit_live_log_minutes: "plan_limit_live_log_minutes";
|
|
155
|
+
}>;
|
|
156
|
+
message: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
/** Platform sends a run-level status update. */
|
|
159
|
+
export declare const browserRunStatusSchema: z.ZodObject<{
|
|
160
|
+
type: z.ZodLiteral<"run.status">;
|
|
161
|
+
runId: z.ZodString;
|
|
162
|
+
status: z.ZodString;
|
|
163
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
}, z.core.$strip>;
|
|
166
|
+
/** Platform sends a job-level status update. */
|
|
167
|
+
export declare const browserJobStatusSchema: z.ZodObject<{
|
|
168
|
+
type: z.ZodLiteral<"job.status">;
|
|
169
|
+
runId: z.ZodString;
|
|
170
|
+
jobId: z.ZodString;
|
|
171
|
+
jobName: z.ZodString;
|
|
172
|
+
status: z.ZodString;
|
|
173
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
174
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
175
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
/** Platform sends a step-level status update. */
|
|
178
|
+
export declare const browserStepStatusSchema: z.ZodObject<{
|
|
179
|
+
type: z.ZodLiteral<"step.status">;
|
|
180
|
+
runId: z.ZodString;
|
|
181
|
+
jobId: z.ZodString;
|
|
182
|
+
stepIndex: z.ZodNumber;
|
|
183
|
+
stepName: z.ZodString;
|
|
184
|
+
state: z.ZodString;
|
|
185
|
+
timestamp: z.ZodNumber;
|
|
186
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
187
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
188
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
189
|
+
secretsAccessed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
/** Platform notifies browser of a new run (first-time insert, full run summary). */
|
|
192
|
+
export declare const browserRunNewSchema: z.ZodObject<{
|
|
193
|
+
type: z.ZodLiteral<"run.new">;
|
|
194
|
+
runId: z.ZodString;
|
|
195
|
+
status: z.ZodString;
|
|
196
|
+
workflowName: z.ZodString;
|
|
197
|
+
repoIdentifier: z.ZodOptional<z.ZodString>;
|
|
198
|
+
sha: z.ZodOptional<z.ZodString>;
|
|
199
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
200
|
+
triggerEvent: z.ZodOptional<z.ZodString>;
|
|
201
|
+
commitMessage: z.ZodOptional<z.ZodString>;
|
|
202
|
+
jobCount: z.ZodNumber;
|
|
203
|
+
startedAt: z.ZodNumber;
|
|
204
|
+
orgId: z.ZodString;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
/** Platform notifies browser of a new job (first-time insert). */
|
|
207
|
+
export declare const browserJobNewSchema: z.ZodObject<{
|
|
208
|
+
type: z.ZodLiteral<"job.new">;
|
|
209
|
+
runId: z.ZodString;
|
|
210
|
+
jobId: z.ZodString;
|
|
211
|
+
jobName: z.ZodString;
|
|
212
|
+
status: z.ZodString;
|
|
213
|
+
matrixValues: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
214
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
215
|
+
}, z.core.$strip>;
|
|
216
|
+
/** Platform responds to a browser keepalive ping. */
|
|
217
|
+
export declare const browserPongSchema: z.ZodObject<{
|
|
218
|
+
type: z.ZodLiteral<"pong">;
|
|
219
|
+
}, z.core.$strip>;
|
|
220
|
+
/** Platform sends an error to the browser. */
|
|
221
|
+
export declare const browserErrorSchema: z.ZodObject<{
|
|
222
|
+
type: z.ZodLiteral<"error">;
|
|
223
|
+
code: z.ZodString;
|
|
224
|
+
message: z.ZodString;
|
|
225
|
+
}, z.core.$strip>;
|
|
226
|
+
/** All messages that flow from Platform to Browser. */
|
|
227
|
+
export declare const platformToBrowserMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
228
|
+
type: z.ZodLiteral<"auth.success">;
|
|
229
|
+
connectionId: z.ZodString;
|
|
230
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
231
|
+
type: z.ZodLiteral<"auth.failure">;
|
|
232
|
+
reason: z.ZodString;
|
|
233
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
234
|
+
type: z.ZodLiteral<"log.lines">;
|
|
235
|
+
runId: z.ZodString;
|
|
236
|
+
jobId: z.ZodString;
|
|
237
|
+
stepIndex: z.ZodNumber;
|
|
238
|
+
lines: z.ZodArray<z.ZodString>;
|
|
239
|
+
lineCount: z.ZodNumber;
|
|
240
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
241
|
+
type: z.ZodLiteral<"log.gap">;
|
|
242
|
+
runId: z.ZodString;
|
|
243
|
+
jobId: z.ZodString;
|
|
244
|
+
stepIndex: z.ZodNumber;
|
|
245
|
+
droppedLineCount: z.ZodNumber;
|
|
246
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
247
|
+
type: z.ZodLiteral<"log.stream.terminated">;
|
|
248
|
+
runId: z.ZodString;
|
|
249
|
+
jobId: z.ZodString;
|
|
250
|
+
stepIndex: z.ZodNumber;
|
|
251
|
+
reason: z.ZodEnum<{
|
|
252
|
+
plan_limit_live_log_minutes: "plan_limit_live_log_minutes";
|
|
253
|
+
}>;
|
|
254
|
+
message: z.ZodOptional<z.ZodString>;
|
|
255
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
256
|
+
type: z.ZodLiteral<"run.status">;
|
|
257
|
+
runId: z.ZodString;
|
|
258
|
+
status: z.ZodString;
|
|
259
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
260
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
261
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
262
|
+
type: z.ZodLiteral<"run.new">;
|
|
263
|
+
runId: z.ZodString;
|
|
264
|
+
status: z.ZodString;
|
|
265
|
+
workflowName: z.ZodString;
|
|
266
|
+
repoIdentifier: z.ZodOptional<z.ZodString>;
|
|
267
|
+
sha: z.ZodOptional<z.ZodString>;
|
|
268
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
269
|
+
triggerEvent: z.ZodOptional<z.ZodString>;
|
|
270
|
+
commitMessage: z.ZodOptional<z.ZodString>;
|
|
271
|
+
jobCount: z.ZodNumber;
|
|
272
|
+
startedAt: z.ZodNumber;
|
|
273
|
+
orgId: z.ZodString;
|
|
274
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
275
|
+
type: z.ZodLiteral<"job.status">;
|
|
276
|
+
runId: z.ZodString;
|
|
277
|
+
jobId: z.ZodString;
|
|
278
|
+
jobName: z.ZodString;
|
|
279
|
+
status: z.ZodString;
|
|
280
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
281
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
282
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
283
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
284
|
+
type: z.ZodLiteral<"job.new">;
|
|
285
|
+
runId: z.ZodString;
|
|
286
|
+
jobId: z.ZodString;
|
|
287
|
+
jobName: z.ZodString;
|
|
288
|
+
status: z.ZodString;
|
|
289
|
+
matrixValues: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
290
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
292
|
+
type: z.ZodLiteral<"step.status">;
|
|
293
|
+
runId: z.ZodString;
|
|
294
|
+
jobId: z.ZodString;
|
|
295
|
+
stepIndex: z.ZodNumber;
|
|
296
|
+
stepName: z.ZodString;
|
|
297
|
+
state: z.ZodString;
|
|
298
|
+
timestamp: z.ZodNumber;
|
|
299
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
300
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
301
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
302
|
+
secretsAccessed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
303
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
304
|
+
type: z.ZodLiteral<"error">;
|
|
305
|
+
code: z.ZodString;
|
|
306
|
+
message: z.ZodString;
|
|
307
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
308
|
+
type: z.ZodLiteral<"pong">;
|
|
309
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
310
|
+
type: z.ZodLiteral<"run.event">;
|
|
311
|
+
runId: z.ZodString;
|
|
312
|
+
eventType: z.ZodString;
|
|
313
|
+
timestampMs: z.ZodNumber;
|
|
314
|
+
sourceService: z.ZodString;
|
|
315
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
316
|
+
durationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
317
|
+
jobId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
318
|
+
stepIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
319
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
320
|
+
type: z.ZodLiteral<"job.context">;
|
|
321
|
+
runId: z.ZodString;
|
|
322
|
+
jobId: z.ZodString;
|
|
323
|
+
context: z.ZodObject<{
|
|
324
|
+
envVars: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
325
|
+
name: z.ZodString;
|
|
326
|
+
value: z.ZodString;
|
|
327
|
+
category: z.ZodEnum<{
|
|
328
|
+
user: "user";
|
|
329
|
+
system: "system";
|
|
330
|
+
inherited: "inherited";
|
|
331
|
+
secret: "secret";
|
|
332
|
+
}>;
|
|
333
|
+
}, z.core.$strip>>>;
|
|
334
|
+
runtime: z.ZodOptional<z.ZodObject<{
|
|
335
|
+
nodeVersion: z.ZodOptional<z.ZodString>;
|
|
336
|
+
os: z.ZodOptional<z.ZodString>;
|
|
337
|
+
arch: z.ZodOptional<z.ZodString>;
|
|
338
|
+
}, z.core.$strip>>;
|
|
339
|
+
sandboxType: z.ZodOptional<z.ZodString>;
|
|
340
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
341
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
342
|
+
gitRef: z.ZodOptional<z.ZodString>;
|
|
343
|
+
lockFileVersion: z.ZodOptional<z.ZodString>;
|
|
344
|
+
sdkVersion: z.ZodOptional<z.ZodString>;
|
|
345
|
+
depCacheStatus: z.ZodOptional<z.ZodString>;
|
|
346
|
+
networkIsolation: z.ZodOptional<z.ZodString>;
|
|
347
|
+
scalerContext: z.ZodOptional<z.ZodObject<{
|
|
348
|
+
backendType: z.ZodString;
|
|
349
|
+
scalerName: z.ZodString;
|
|
350
|
+
}, z.core.$loose>>;
|
|
351
|
+
}, z.core.$strip>;
|
|
352
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
353
|
+
type: z.ZodLiteral<"event-log.payload.chunk">;
|
|
354
|
+
requestId: z.ZodString;
|
|
355
|
+
seq: z.ZodNumber;
|
|
356
|
+
data: z.ZodString;
|
|
357
|
+
isLast: z.ZodBoolean;
|
|
358
|
+
error: z.ZodOptional<z.ZodEnum<{
|
|
359
|
+
payload_unavailable: "payload_unavailable";
|
|
360
|
+
not_found: "not_found";
|
|
361
|
+
read_failed: "read_failed";
|
|
362
|
+
forbidden: "forbidden";
|
|
363
|
+
orch_stream_timeout: "orch_stream_timeout";
|
|
364
|
+
orchestrator_unavailable: "orchestrator_unavailable";
|
|
365
|
+
}>>;
|
|
366
|
+
totalBytes: z.ZodOptional<z.ZodNumber>;
|
|
367
|
+
}, z.core.$strip>], "type">;
|
|
368
|
+
export type BrowserEventLogPayloadFetch = z.infer<typeof browserEventLogPayloadFetchSchema>;
|
|
369
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import "../../chunk-gOLHoazu.js";
|
|
2
|
+
import { browserJobContextSchema, browserRunEventSchema } from "./run-events.js";
|
|
3
|
+
import { browserEventLogPayloadChunkSchema } from "./dashboard.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/protocol/messages/browser.ts
|
|
6
|
+
/**
|
|
7
|
+
* Browser-Platform WebSocket protocol schemas.
|
|
8
|
+
*
|
|
9
|
+
* Defines all message types for the browser <-> Platform WS connection:
|
|
10
|
+
* - Browser -> Platform: auth, log subscribe/unsubscribe, status subscribe/unsubscribe
|
|
11
|
+
* - Platform -> Browser: auth response, log lines, gap, run/job/step status, error
|
|
12
|
+
*
|
|
13
|
+
* Follows the same Zod-based pattern as platform-orchestrator.ts and other protocol schemas.
|
|
14
|
+
*/
|
|
15
|
+
/** Browser sends JWT token for authentication (first message after WS open). */
|
|
16
|
+
const browserAuthRequestSchema = z.object({
|
|
17
|
+
type: z.literal("auth.request"),
|
|
18
|
+
token: z.string().min(1)
|
|
19
|
+
});
|
|
20
|
+
/** Browser sends a refreshed JWT token to extend the session. */
|
|
21
|
+
const browserAuthRefreshSchema = z.object({
|
|
22
|
+
type: z.literal("auth.refresh"),
|
|
23
|
+
token: z.string().min(1)
|
|
24
|
+
});
|
|
25
|
+
/** Browser subscribes to log lines for a specific step. */
|
|
26
|
+
const browserLogSubscribeSchema = z.object({
|
|
27
|
+
type: z.literal("log.subscribe"),
|
|
28
|
+
runId: z.string(),
|
|
29
|
+
jobId: z.string(),
|
|
30
|
+
stepIndex: z.number(),
|
|
31
|
+
/** Resume from this line count (for mid-execution join after REST fetch). */
|
|
32
|
+
afterLineCount: z.number().optional()
|
|
33
|
+
});
|
|
34
|
+
/** Browser unsubscribes from log lines for a specific step. */
|
|
35
|
+
const browserLogUnsubscribeSchema = z.object({
|
|
36
|
+
type: z.literal("log.unsubscribe"),
|
|
37
|
+
runId: z.string(),
|
|
38
|
+
jobId: z.string(),
|
|
39
|
+
stepIndex: z.number()
|
|
40
|
+
});
|
|
41
|
+
/** Browser subscribes to org-level status updates (run/job/step status changes). */
|
|
42
|
+
const browserStatusSubscribeSchema = z.object({
|
|
43
|
+
type: z.literal("status.subscribe"),
|
|
44
|
+
/** Scope of status subscription. Currently only 'org' is supported. */
|
|
45
|
+
scope: z.literal("org"),
|
|
46
|
+
/** The org to subscribe to. Required so the Platform can route updates for the correct org. */
|
|
47
|
+
orgId: z.string().min(1)
|
|
48
|
+
});
|
|
49
|
+
/** Browser unsubscribes from status updates. */
|
|
50
|
+
const browserStatusUnsubscribeSchema = z.object({ type: z.literal("status.unsubscribe") });
|
|
51
|
+
/** Browser sends a keepalive ping to prevent LB idle timeout. */
|
|
52
|
+
const browserPingSchema = z.object({ type: z.literal("ping") });
|
|
53
|
+
/**
|
|
54
|
+
* Browser asks Platform to begin streaming the body of an event-log delivery.
|
|
55
|
+
*
|
|
56
|
+
* The dashboard generates `requestId` (uuid) per fetch so it can correlate
|
|
57
|
+
* incoming chunks. `orgId` is NOT taken from the wire — Platform's
|
|
58
|
+
* browser-handler resolves the run's owning org from the user's membership
|
|
59
|
+
* and gates on `event_log:read_payload`. Same trust model as the existing
|
|
60
|
+
* `log.subscribe` message.
|
|
61
|
+
*/
|
|
62
|
+
const browserEventLogPayloadFetchSchema = z.object({
|
|
63
|
+
type: z.literal("event-log.payload.fetch"),
|
|
64
|
+
requestId: z.string().min(1),
|
|
65
|
+
orgId: z.string().min(1),
|
|
66
|
+
deliveryId: z.string().min(1)
|
|
67
|
+
});
|
|
68
|
+
/** All messages that flow from Browser to Platform. */
|
|
69
|
+
const browserToPlatformMessageSchema = z.discriminatedUnion("type", [
|
|
70
|
+
browserAuthRequestSchema,
|
|
71
|
+
browserAuthRefreshSchema,
|
|
72
|
+
browserLogSubscribeSchema,
|
|
73
|
+
browserLogUnsubscribeSchema,
|
|
74
|
+
browserStatusSubscribeSchema,
|
|
75
|
+
browserStatusUnsubscribeSchema,
|
|
76
|
+
browserEventLogPayloadFetchSchema,
|
|
77
|
+
browserPingSchema
|
|
78
|
+
]);
|
|
79
|
+
/** Platform confirms browser authentication. */
|
|
80
|
+
const browserAuthSuccessSchema = z.object({
|
|
81
|
+
type: z.literal("auth.success"),
|
|
82
|
+
connectionId: z.string()
|
|
83
|
+
});
|
|
84
|
+
/** Platform rejects browser authentication. */
|
|
85
|
+
const browserAuthFailureSchema = z.object({
|
|
86
|
+
type: z.literal("auth.failure"),
|
|
87
|
+
reason: z.string()
|
|
88
|
+
});
|
|
89
|
+
/** Platform sends log lines for a subscribed step. */
|
|
90
|
+
const browserLogLinesSchema = z.object({
|
|
91
|
+
type: z.literal("log.lines"),
|
|
92
|
+
runId: z.string(),
|
|
93
|
+
jobId: z.string(),
|
|
94
|
+
stepIndex: z.number(),
|
|
95
|
+
lines: z.array(z.string()),
|
|
96
|
+
/** Total line count (cumulative offset so browser knows position). */
|
|
97
|
+
lineCount: z.number()
|
|
98
|
+
});
|
|
99
|
+
/** Platform notifies browser that lines were dropped due to backpressure. */
|
|
100
|
+
const browserGapSchema = z.object({
|
|
101
|
+
type: z.literal("log.gap"),
|
|
102
|
+
runId: z.string(),
|
|
103
|
+
jobId: z.string(),
|
|
104
|
+
stepIndex: z.number(),
|
|
105
|
+
droppedLineCount: z.number()
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Reason a live-log stream was terminated by the Platform.
|
|
109
|
+
*
|
|
110
|
+
* Currently only `plan_limit_live_log_minutes` (daily live-log minute cap
|
|
111
|
+
* exceeded). New reasons land here as the Platform grows more enforcement
|
|
112
|
+
* surfaces (e.g. retention, manual operator kick).
|
|
113
|
+
*/
|
|
114
|
+
const browserLogStreamTerminatedReason = z.enum(["plan_limit_live_log_minutes"]);
|
|
115
|
+
/**
|
|
116
|
+
* Platform notifies browser that a live-log stream has been terminated.
|
|
117
|
+
*
|
|
118
|
+
* Sent in two cases:
|
|
119
|
+
* 1. **At subscribe time:** the org is already over the daily live-log
|
|
120
|
+
* minute cap when the browser sends `log.subscribe`. The Platform
|
|
121
|
+
* sends `log.stream.terminated` and never registers the subscription.
|
|
122
|
+
* 2. **Mid-stream:** the periodic metering tick observed the org just
|
|
123
|
+
* crossed the cap. The Platform sends `log.stream.terminated` to all
|
|
124
|
+
* active log subscribers in that org and unregisters them.
|
|
125
|
+
*
|
|
126
|
+
* Browsers should display the upgrade prompt and NOT auto-resubscribe.
|
|
127
|
+
*/
|
|
128
|
+
const browserLogStreamTerminatedSchema = z.object({
|
|
129
|
+
type: z.literal("log.stream.terminated"),
|
|
130
|
+
runId: z.string(),
|
|
131
|
+
jobId: z.string(),
|
|
132
|
+
stepIndex: z.number(),
|
|
133
|
+
reason: browserLogStreamTerminatedReason,
|
|
134
|
+
/** Optional human-readable message for the dashboard to display. */
|
|
135
|
+
message: z.string().optional()
|
|
136
|
+
});
|
|
137
|
+
/** Platform sends a run-level status update. */
|
|
138
|
+
const browserRunStatusSchema = z.object({
|
|
139
|
+
type: z.literal("run.status"),
|
|
140
|
+
runId: z.string(),
|
|
141
|
+
status: z.string(),
|
|
142
|
+
completedAt: z.number().optional(),
|
|
143
|
+
durationMs: z.number().optional()
|
|
144
|
+
});
|
|
145
|
+
/** Platform sends a job-level status update. */
|
|
146
|
+
const browserJobStatusSchema = z.object({
|
|
147
|
+
type: z.literal("job.status"),
|
|
148
|
+
runId: z.string(),
|
|
149
|
+
jobId: z.string(),
|
|
150
|
+
jobName: z.string(),
|
|
151
|
+
status: z.string(),
|
|
152
|
+
startedAt: z.number().optional(),
|
|
153
|
+
completedAt: z.number().optional(),
|
|
154
|
+
durationMs: z.number().optional()
|
|
155
|
+
});
|
|
156
|
+
/** Platform sends a step-level status update. */
|
|
157
|
+
const browserStepStatusSchema = z.object({
|
|
158
|
+
type: z.literal("step.status"),
|
|
159
|
+
runId: z.string(),
|
|
160
|
+
jobId: z.string(),
|
|
161
|
+
stepIndex: z.number(),
|
|
162
|
+
stepName: z.string(),
|
|
163
|
+
state: z.string(),
|
|
164
|
+
timestamp: z.number(),
|
|
165
|
+
startedAt: z.number().optional(),
|
|
166
|
+
completedAt: z.number().optional(),
|
|
167
|
+
durationMs: z.number().optional(),
|
|
168
|
+
/** Secret key names accessed by this step. Present on completion states. */
|
|
169
|
+
secretsAccessed: z.array(z.string()).optional()
|
|
170
|
+
});
|
|
171
|
+
/** Platform notifies browser of a new run (first-time insert, full run summary). */
|
|
172
|
+
const browserRunNewSchema = z.object({
|
|
173
|
+
type: z.literal("run.new"),
|
|
174
|
+
runId: z.string(),
|
|
175
|
+
status: z.string(),
|
|
176
|
+
workflowName: z.string(),
|
|
177
|
+
repoIdentifier: z.string().optional(),
|
|
178
|
+
sha: z.string().optional(),
|
|
179
|
+
ref: z.string().optional(),
|
|
180
|
+
triggerEvent: z.string().optional(),
|
|
181
|
+
commitMessage: z.string().optional(),
|
|
182
|
+
jobCount: z.number(),
|
|
183
|
+
startedAt: z.number(),
|
|
184
|
+
orgId: z.string()
|
|
185
|
+
});
|
|
186
|
+
/** Platform notifies browser of a new job (first-time insert). */
|
|
187
|
+
const browserJobNewSchema = z.object({
|
|
188
|
+
type: z.literal("job.new"),
|
|
189
|
+
runId: z.string(),
|
|
190
|
+
jobId: z.string(),
|
|
191
|
+
jobName: z.string(),
|
|
192
|
+
status: z.string(),
|
|
193
|
+
matrixValues: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
194
|
+
startedAt: z.number().optional()
|
|
195
|
+
});
|
|
196
|
+
/** Platform responds to a browser keepalive ping. */
|
|
197
|
+
const browserPongSchema = z.object({ type: z.literal("pong") });
|
|
198
|
+
/** Platform sends an error to the browser. */
|
|
199
|
+
const browserErrorSchema = z.object({
|
|
200
|
+
type: z.literal("error"),
|
|
201
|
+
code: z.string(),
|
|
202
|
+
message: z.string()
|
|
203
|
+
});
|
|
204
|
+
/** All messages that flow from Platform to Browser. */
|
|
205
|
+
const platformToBrowserMessageSchema = z.discriminatedUnion("type", [
|
|
206
|
+
browserAuthSuccessSchema,
|
|
207
|
+
browserAuthFailureSchema,
|
|
208
|
+
browserLogLinesSchema,
|
|
209
|
+
browserGapSchema,
|
|
210
|
+
browserLogStreamTerminatedSchema,
|
|
211
|
+
browserRunStatusSchema,
|
|
212
|
+
browserRunNewSchema,
|
|
213
|
+
browserJobStatusSchema,
|
|
214
|
+
browserJobNewSchema,
|
|
215
|
+
browserStepStatusSchema,
|
|
216
|
+
browserErrorSchema,
|
|
217
|
+
browserPongSchema,
|
|
218
|
+
browserRunEventSchema,
|
|
219
|
+
browserJobContextSchema,
|
|
220
|
+
browserEventLogPayloadChunkSchema
|
|
221
|
+
]);
|
|
222
|
+
//#endregion
|
|
223
|
+
export { browserAuthFailureSchema, browserAuthRefreshSchema, browserAuthRequestSchema, browserAuthSuccessSchema, browserErrorSchema, browserEventLogPayloadFetchSchema, browserGapSchema, browserJobNewSchema, browserJobStatusSchema, browserLogLinesSchema, browserLogStreamTerminatedReason, browserLogStreamTerminatedSchema, browserLogSubscribeSchema, browserLogUnsubscribeSchema, browserPingSchema, browserPongSchema, browserRunNewSchema, browserRunStatusSchema, browserStatusSubscribeSchema, browserStatusUnsubscribeSchema, browserStepStatusSchema, browserToPlatformMessageSchema, platformToBrowserMessageSchema };
|
|
224
|
+
|
|
225
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator capability negotiation schemas.
|
|
3
|
+
*
|
|
4
|
+
* Modeled after peerCapabilitiesSchema in peer.ts.
|
|
5
|
+
* See CONTEXT.md through for design decisions.
|
|
6
|
+
*
|
|
7
|
+
* Direction: orchestrator → Platform only. The Platform is always at the latest version
|
|
8
|
+
* (centrally deployed), so Platform capabilities are unnecessary. The Platform checks
|
|
9
|
+
* orchestrator capabilities before sending feature-gated messages.
|
|
10
|
+
*
|
|
11
|
+
* Pattern: Each field indicates support for an optional protocol feature.
|
|
12
|
+
* Missing fields default to unsupported for backward compatibility.
|
|
13
|
+
* Schema uses .passthrough() so newer orchestrators sending unknown flags don't get stripped.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
/** Orchestrator role in a cluster topology. */
|
|
17
|
+
export declare const OrchRole: z.ZodEnum<{
|
|
18
|
+
coordinator: "coordinator";
|
|
19
|
+
worker: "worker";
|
|
20
|
+
}>;
|
|
21
|
+
export type OrchRole = z.infer<typeof OrchRole>;
|
|
22
|
+
/**
|
|
23
|
+
* Orchestrator-advertised capabilities sent in auth.request.
|
|
24
|
+
* Uses .passthrough() so newer orchestrators sending unknown flags are preserved.
|
|
25
|
+
*/
|
|
26
|
+
export declare const orchCapabilitiesSchema: z.ZodObject<{
|
|
27
|
+
orchRole: z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
coordinator: "coordinator";
|
|
29
|
+
worker: "worker";
|
|
30
|
+
}>>;
|
|
31
|
+
}, z.core.$loose>;
|
|
32
|
+
/** Inferred type for orchestrator capabilities. */
|
|
33
|
+
export type OrchCapabilities = z.infer<typeof orchCapabilitiesSchema>;
|
|
34
|
+
/** Default orchestrator capabilities sent in auth.request. */
|
|
35
|
+
export declare const ORCH_CAPABILITIES: Readonly<{
|
|
36
|
+
orchRole: "coordinator";
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Check whether an orchestrator advertises a specific capability flag.
|
|
40
|
+
*
|
|
41
|
+
* Takes `string` (not `keyof`) because newer versions may have flags the current code
|
|
42
|
+
* doesn't know about. Returns false if capabilities is undefined (pre-capability
|
|
43
|
+
* orchestrator) or the flag is missing/false.
|
|
44
|
+
*/
|
|
45
|
+
export declare function hasOrchCapability(capabilities: OrchCapabilities | undefined, flag: string): boolean;
|
|
46
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "../../chunk-gOLHoazu.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/protocol/messages/capabilities.ts
|
|
4
|
+
/**
|
|
5
|
+
* Orchestrator capability negotiation schemas.
|
|
6
|
+
*
|
|
7
|
+
* Modeled after peerCapabilitiesSchema in peer.ts.
|
|
8
|
+
* See CONTEXT.md through for design decisions.
|
|
9
|
+
*
|
|
10
|
+
* Direction: orchestrator → Platform only. The Platform is always at the latest version
|
|
11
|
+
* (centrally deployed), so Platform capabilities are unnecessary. The Platform checks
|
|
12
|
+
* orchestrator capabilities before sending feature-gated messages.
|
|
13
|
+
*
|
|
14
|
+
* Pattern: Each field indicates support for an optional protocol feature.
|
|
15
|
+
* Missing fields default to unsupported for backward compatibility.
|
|
16
|
+
* Schema uses .passthrough() so newer orchestrators sending unknown flags don't get stripped.
|
|
17
|
+
*/
|
|
18
|
+
/** Orchestrator role in a cluster topology. */
|
|
19
|
+
const OrchRole = z.enum(["coordinator", "worker"]);
|
|
20
|
+
/**
|
|
21
|
+
* Orchestrator-advertised capabilities sent in auth.request.
|
|
22
|
+
* Uses .passthrough() so newer orchestrators sending unknown flags are preserved.
|
|
23
|
+
*/
|
|
24
|
+
const orchCapabilitiesSchema = z.object({
|
|
25
|
+
/** Orchestrator's role in the cluster (coordinator manages DB/vault, worker is stateless). */
|
|
26
|
+
orchRole: OrchRole.optional() }).passthrough();
|
|
27
|
+
/** Default orchestrator capabilities sent in auth.request. */
|
|
28
|
+
const ORCH_CAPABILITIES = Object.freeze({ orchRole: OrchRole.enum.coordinator });
|
|
29
|
+
/**
|
|
30
|
+
* Check whether an orchestrator advertises a specific capability flag.
|
|
31
|
+
*
|
|
32
|
+
* Takes `string` (not `keyof`) because newer versions may have flags the current code
|
|
33
|
+
* doesn't know about. Returns false if capabilities is undefined (pre-capability
|
|
34
|
+
* orchestrator) or the flag is missing/false.
|
|
35
|
+
*/
|
|
36
|
+
function hasOrchCapability(capabilities, flag) {
|
|
37
|
+
return capabilities?.[flag] === true;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { ORCH_CAPABILITIES, OrchRole, hasOrchCapability, orchCapabilitiesSchema };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=capabilities.js.map
|