@kici-dev/engine 0.1.13 → 0.1.15
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 +13 -1
- package/dist/audit/access-log-policy.js +12 -0
- package/dist/audit/retention-policy.js +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -7
- package/dist/labels.d.ts +7 -0
- package/dist/labels.js +11 -2
- package/dist/metrics/metric-catalog.generated.d.ts +50 -0
- package/dist/metrics/metric-catalog.generated.js +60 -0
- package/dist/protocol/analytics-events.d.ts +16 -0
- package/dist/protocol/analytics-events.js +20 -0
- package/dist/protocol/dashboard-write-operations.d.ts +4 -1
- package/dist/protocol/dashboard-write-operations.js +11 -1
- package/dist/protocol/messages/access-log.d.ts +16 -0
- package/dist/protocol/messages/access-log.js +3 -0
- package/dist/protocol/messages/actor.d.ts +2 -0
- package/dist/protocol/messages/actor.js +12 -2
- package/dist/protocol/messages/auth.d.ts +1 -0
- package/dist/protocol/messages/capabilities.d.ts +1 -0
- package/dist/protocol/messages/dashboard-global-workflows.d.ts +2 -0
- package/dist/protocol/messages/dashboard.d.ts +685 -6
- package/dist/protocol/messages/dashboard.js +183 -10
- package/dist/protocol/messages/event-log.d.ts +4 -0
- package/dist/protocol/messages/event-log.js +4 -0
- package/dist/protocol/messages/execution-status.d.ts +133 -0
- package/dist/protocol/messages/execution-status.js +83 -3
- package/dist/protocol/messages/orchestrator-agent.d.ts +164 -0
- package/dist/protocol/messages/orchestrator-agent.js +118 -2
- package/dist/protocol/messages/peer.d.ts +13 -0
- package/dist/protocol/messages/peer.js +14 -1
- package/dist/protocol/messages/platform-orchestrator.d.ts +188 -0
- package/dist/protocol/messages/platform-orchestrator.js +3 -55
- package/dist/protocol/messages/run-events.d.ts +1 -0
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.js +2 -1
- package/dist/provider/lock-file-parse-error.d.ts +14 -0
- package/dist/provider/lock-file-parse-error.js +22 -0
- package/dist/trigger/types.d.ts +8 -1
- package/dist/trigger/types.js +3 -1
- package/dist/ws/close-codes.d.ts +7 -0
- package/dist/ws/close-codes.js +8 -1
- package/package.json +15 -8
- package/sbom.spdx.json +5 -5
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Cache write scope for a job's user-facing cache.
|
|
4
|
+
*
|
|
5
|
+
* - `shared` — trusted ref (default branch / write-permission contributor):
|
|
6
|
+
* reads AND writes the org-shared default-branch scope.
|
|
7
|
+
* - `isolated` — untrusted ref (fork PR / unknown contributor): reads the
|
|
8
|
+
* shared scope as a fallback but writes only into a per-run isolated scope,
|
|
9
|
+
* so an untrusted ref can never poison the shared cache (GitHub Actions model).
|
|
10
|
+
*/
|
|
11
|
+
export declare const CacheRefScope: z.ZodEnum<{
|
|
12
|
+
shared: "shared";
|
|
13
|
+
isolated: "isolated";
|
|
14
|
+
}>;
|
|
15
|
+
export type CacheRefScope = z.infer<typeof CacheRefScope>;
|
|
2
16
|
/**
|
|
3
17
|
* Structured git-clone auth material. Carries everything the agent needs to
|
|
4
18
|
* authenticate a single `git clone`:
|
|
@@ -83,6 +97,12 @@ export declare const jobDispatchSchema: z.ZodObject<{
|
|
|
83
97
|
token: z.ZodString;
|
|
84
98
|
}, z.core.$strip>>>;
|
|
85
99
|
installEnvSecrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
100
|
+
orgId: z.ZodOptional<z.ZodString>;
|
|
101
|
+
repoId: z.ZodOptional<z.ZodString>;
|
|
102
|
+
cacheRefScope: z.ZodOptional<z.ZodEnum<{
|
|
103
|
+
shared: "shared";
|
|
104
|
+
isolated: "isolated";
|
|
105
|
+
}>>;
|
|
86
106
|
}, z.core.$strip>;
|
|
87
107
|
/** Cancel a running or queued job. */
|
|
88
108
|
export declare const jobCancelSchema: z.ZodObject<{
|
|
@@ -161,6 +181,51 @@ export declare const jobStatusSchema: z.ZodObject<{
|
|
|
161
181
|
encrypted: z.ZodString;
|
|
162
182
|
}, z.core.$strip>>>;
|
|
163
183
|
}, z.core.$strip>;
|
|
184
|
+
/** Reasons an agent can refuse a job.dispatch. */
|
|
185
|
+
export declare const JobRejectReason: z.ZodEnum<{
|
|
186
|
+
draining: "draining";
|
|
187
|
+
busy: "busy";
|
|
188
|
+
}>;
|
|
189
|
+
export type JobRejectReason = z.infer<typeof JobRejectReason>;
|
|
190
|
+
/**
|
|
191
|
+
* Explicit dispatch rejection (agent -> orchestrator).
|
|
192
|
+
*
|
|
193
|
+
* Sent when the agent cannot accept a job.dispatch (already running a job,
|
|
194
|
+
* or draining). The orchestrator undoes its dispatch accounting and requeues
|
|
195
|
+
* the job for another agent. Protocol invariant: every job.dispatch is
|
|
196
|
+
* answered — accepted with `job.ack` (a `job.status` with state `running`
|
|
197
|
+
* also resolves the deadline), or refused with this message. An unanswered
|
|
198
|
+
* dispatch is treated as lost once the ack deadline expires (requeue +
|
|
199
|
+
* disconnect the agent) and is also covered by disconnect-time triage.
|
|
200
|
+
*/
|
|
201
|
+
export declare const jobRejectSchema: z.ZodObject<{
|
|
202
|
+
type: z.ZodLiteral<"job.reject">;
|
|
203
|
+
messageId: z.ZodString;
|
|
204
|
+
runId: z.ZodString;
|
|
205
|
+
jobId: z.ZodString;
|
|
206
|
+
reason: z.ZodEnum<{
|
|
207
|
+
draining: "draining";
|
|
208
|
+
busy: "busy";
|
|
209
|
+
}>;
|
|
210
|
+
timestamp: z.ZodNumber;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
/**
|
|
213
|
+
* Positive dispatch acknowledgment (agent -> orchestrator).
|
|
214
|
+
*
|
|
215
|
+
* Sent immediately when the agent receives a job.dispatch and accepts it
|
|
216
|
+
* (after the drain/busy checks, before execution begins). The orchestrator
|
|
217
|
+
* arms a deadline when it sends a dispatch; `job.ack`, `job.reject`, or a
|
|
218
|
+
* `job.status` with state `running` resolves it. A dispatch with no answer
|
|
219
|
+
* inside the deadline is treated as lost: the orchestrator requeues the job
|
|
220
|
+
* and disconnects the unresponsive agent.
|
|
221
|
+
*/
|
|
222
|
+
export declare const jobAckSchema: z.ZodObject<{
|
|
223
|
+
type: z.ZodLiteral<"job.ack">;
|
|
224
|
+
messageId: z.ZodString;
|
|
225
|
+
runId: z.ZodString;
|
|
226
|
+
jobId: z.ZodString;
|
|
227
|
+
timestamp: z.ZodNumber;
|
|
228
|
+
}, z.core.$strip>;
|
|
164
229
|
/**
|
|
165
230
|
* Streaming log chunk from step execution (agent -> orchestrator).
|
|
166
231
|
*
|
|
@@ -247,6 +312,46 @@ export declare const configAckSchema: z.ZodObject<{
|
|
|
247
312
|
messageId: z.ZodString;
|
|
248
313
|
agentId: z.ZodString;
|
|
249
314
|
}, z.core.$strip>;
|
|
315
|
+
/** Agent -> Orchestrator: request a user-cache restore (presigned download). */
|
|
316
|
+
export declare const cacheUserRestoreRequestSchema: z.ZodObject<{
|
|
317
|
+
type: z.ZodLiteral<"cache.user.restore.request">;
|
|
318
|
+
messageId: z.ZodString;
|
|
319
|
+
jobId: z.ZodString;
|
|
320
|
+
key: z.ZodString;
|
|
321
|
+
restoreKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
322
|
+
}, z.core.$strip>;
|
|
323
|
+
/** Orchestrator -> Agent: presigned download URL + matched key + tar hash, or a miss. */
|
|
324
|
+
export declare const cacheUserRestoreResponseSchema: z.ZodObject<{
|
|
325
|
+
type: z.ZodLiteral<"cache.user.restore.response">;
|
|
326
|
+
requestId: z.ZodString;
|
|
327
|
+
hit: z.ZodBoolean;
|
|
328
|
+
matchedKey: z.ZodOptional<z.ZodString>;
|
|
329
|
+
downloadUrl: z.ZodOptional<z.ZodString>;
|
|
330
|
+
tarHash: z.ZodOptional<z.ZodString>;
|
|
331
|
+
}, z.core.$strip>;
|
|
332
|
+
/** Agent -> Orchestrator: request a presigned PUT for a user-cache save (immutable; may decline if key exists). */
|
|
333
|
+
export declare const cacheUserSaveRequestSchema: z.ZodObject<{
|
|
334
|
+
type: z.ZodLiteral<"cache.user.save.request">;
|
|
335
|
+
messageId: z.ZodString;
|
|
336
|
+
jobId: z.ZodString;
|
|
337
|
+
key: z.ZodString;
|
|
338
|
+
}, z.core.$strip>;
|
|
339
|
+
/** Orchestrator -> Agent: presigned PUT URL, or `skip` when the immutable key already exists. */
|
|
340
|
+
export declare const cacheUserSaveResponseSchema: z.ZodObject<{
|
|
341
|
+
type: z.ZodLiteral<"cache.user.save.response">;
|
|
342
|
+
requestId: z.ZodString;
|
|
343
|
+
uploadUrl: z.ZodOptional<z.ZodString>;
|
|
344
|
+
skip: z.ZodBoolean;
|
|
345
|
+
}, z.core.$strip>;
|
|
346
|
+
/** Agent -> Orchestrator: confirm a user-cache upload finished; orchestrator commits temp -> final + sets metadata. */
|
|
347
|
+
export declare const cacheUserSaveCompleteSchema: z.ZodObject<{
|
|
348
|
+
type: z.ZodLiteral<"cache.user.save.complete">;
|
|
349
|
+
messageId: z.ZodString;
|
|
350
|
+
jobId: z.ZodString;
|
|
351
|
+
key: z.ZodString;
|
|
352
|
+
tarHash: z.ZodString;
|
|
353
|
+
sizeBytes: z.ZodNumber;
|
|
354
|
+
}, z.core.$strip>;
|
|
250
355
|
/** Agent -> Orchestrator: emit a custom event from a running workflow step. */
|
|
251
356
|
export declare const eventEmitSchema: z.ZodObject<{
|
|
252
357
|
type: z.ZodLiteral<"event.emit">;
|
|
@@ -375,6 +480,12 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
375
480
|
token: z.ZodString;
|
|
376
481
|
}, z.core.$strip>>>;
|
|
377
482
|
installEnvSecrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
483
|
+
orgId: z.ZodOptional<z.ZodString>;
|
|
484
|
+
repoId: z.ZodOptional<z.ZodString>;
|
|
485
|
+
cacheRefScope: z.ZodOptional<z.ZodEnum<{
|
|
486
|
+
shared: "shared";
|
|
487
|
+
isolated: "isolated";
|
|
488
|
+
}>>;
|
|
378
489
|
}, z.core.$strip>, z.ZodObject<{
|
|
379
490
|
type: z.ZodLiteral<"job.cancel">;
|
|
380
491
|
messageId: z.ZodString;
|
|
@@ -403,6 +514,18 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
403
514
|
type: z.ZodLiteral<"cache.upload.response">;
|
|
404
515
|
requestId: z.ZodString;
|
|
405
516
|
uploadUrl: z.ZodString;
|
|
517
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
518
|
+
type: z.ZodLiteral<"cache.user.restore.response">;
|
|
519
|
+
requestId: z.ZodString;
|
|
520
|
+
hit: z.ZodBoolean;
|
|
521
|
+
matchedKey: z.ZodOptional<z.ZodString>;
|
|
522
|
+
downloadUrl: z.ZodOptional<z.ZodString>;
|
|
523
|
+
tarHash: z.ZodOptional<z.ZodString>;
|
|
524
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
525
|
+
type: z.ZodLiteral<"cache.user.save.response">;
|
|
526
|
+
requestId: z.ZodString;
|
|
527
|
+
uploadUrl: z.ZodOptional<z.ZodString>;
|
|
528
|
+
skip: z.ZodBoolean;
|
|
406
529
|
}, z.core.$strip>, z.ZodObject<{
|
|
407
530
|
type: z.ZodLiteral<"event.emit.response">;
|
|
408
531
|
requestId: z.ZodString;
|
|
@@ -475,6 +598,22 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
475
598
|
agentPublicKey: z.ZodString;
|
|
476
599
|
encrypted: z.ZodString;
|
|
477
600
|
}, z.core.$strip>>>;
|
|
601
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
602
|
+
type: z.ZodLiteral<"job.reject">;
|
|
603
|
+
messageId: z.ZodString;
|
|
604
|
+
runId: z.ZodString;
|
|
605
|
+
jobId: z.ZodString;
|
|
606
|
+
reason: z.ZodEnum<{
|
|
607
|
+
draining: "draining";
|
|
608
|
+
busy: "busy";
|
|
609
|
+
}>;
|
|
610
|
+
timestamp: z.ZodNumber;
|
|
611
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
612
|
+
type: z.ZodLiteral<"job.ack">;
|
|
613
|
+
messageId: z.ZodString;
|
|
614
|
+
runId: z.ZodString;
|
|
615
|
+
jobId: z.ZodString;
|
|
616
|
+
timestamp: z.ZodNumber;
|
|
478
617
|
}, z.core.$strip>, z.ZodObject<{
|
|
479
618
|
type: z.ZodLiteral<"log.chunk">;
|
|
480
619
|
messageId: z.ZodString;
|
|
@@ -555,6 +694,24 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
555
694
|
platform: z.ZodString;
|
|
556
695
|
arch: z.ZodString;
|
|
557
696
|
depsHash: z.ZodOptional<z.ZodString>;
|
|
697
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
698
|
+
type: z.ZodLiteral<"cache.user.restore.request">;
|
|
699
|
+
messageId: z.ZodString;
|
|
700
|
+
jobId: z.ZodString;
|
|
701
|
+
key: z.ZodString;
|
|
702
|
+
restoreKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
703
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
704
|
+
type: z.ZodLiteral<"cache.user.save.request">;
|
|
705
|
+
messageId: z.ZodString;
|
|
706
|
+
jobId: z.ZodString;
|
|
707
|
+
key: z.ZodString;
|
|
708
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
709
|
+
type: z.ZodLiteral<"cache.user.save.complete">;
|
|
710
|
+
messageId: z.ZodString;
|
|
711
|
+
jobId: z.ZodString;
|
|
712
|
+
key: z.ZodString;
|
|
713
|
+
tarHash: z.ZodString;
|
|
714
|
+
sizeBytes: z.ZodNumber;
|
|
558
715
|
}, z.core.$strip>, z.ZodObject<{
|
|
559
716
|
type: z.ZodLiteral<"event.emit">;
|
|
560
717
|
jobId: z.ZodString;
|
|
@@ -599,8 +756,15 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
599
756
|
export type JobDispatch = z.infer<typeof jobDispatchSchema>;
|
|
600
757
|
export type JobCancel = z.infer<typeof jobCancelSchema>;
|
|
601
758
|
export type JobStatus = z.infer<typeof jobStatusSchema>;
|
|
759
|
+
export type JobReject = z.infer<typeof jobRejectSchema>;
|
|
760
|
+
export type JobAck = z.infer<typeof jobAckSchema>;
|
|
602
761
|
export type AgentLogChunk = z.infer<typeof agentLogChunkSchema>;
|
|
603
762
|
export type AgentStepStatus = z.infer<typeof agentStepStatusSchema>;
|
|
604
763
|
export type AgentMetrics = z.infer<typeof agentMetricsSchema>;
|
|
764
|
+
export type CacheUserRestoreRequest = z.infer<typeof cacheUserRestoreRequestSchema>;
|
|
765
|
+
export type CacheUserRestoreResponse = z.infer<typeof cacheUserRestoreResponseSchema>;
|
|
766
|
+
export type CacheUserSaveRequest = z.infer<typeof cacheUserSaveRequestSchema>;
|
|
767
|
+
export type CacheUserSaveResponse = z.infer<typeof cacheUserSaveResponseSchema>;
|
|
768
|
+
export type CacheUserSaveComplete = z.infer<typeof cacheUserSaveCompleteSchema>;
|
|
605
769
|
export type AgentToOrchestratorMessage = z.infer<typeof agentToOrchestratorMessageSchema>;
|
|
606
770
|
//# sourceMappingURL=orchestrator-agent.d.ts.map
|
|
@@ -3,6 +3,16 @@ import { ExecutionJobStatus, ExecutionStepStatus } from "./execution-status.js";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/protocol/messages/orchestrator-agent.ts
|
|
5
5
|
/**
|
|
6
|
+
* Cache write scope for a job's user-facing cache.
|
|
7
|
+
*
|
|
8
|
+
* - `shared` — trusted ref (default branch / write-permission contributor):
|
|
9
|
+
* reads AND writes the org-shared default-branch scope.
|
|
10
|
+
* - `isolated` — untrusted ref (fork PR / unknown contributor): reads the
|
|
11
|
+
* shared scope as a fallback but writes only into a per-run isolated scope,
|
|
12
|
+
* so an untrusted ref can never poison the shared cache (GitHub Actions model).
|
|
13
|
+
*/
|
|
14
|
+
const CacheRefScope = z.enum(["shared", "isolated"]);
|
|
15
|
+
/**
|
|
6
16
|
* Structured git-clone auth material. Carries everything the agent needs to
|
|
7
17
|
* authenticate a single `git clone`:
|
|
8
18
|
*
|
|
@@ -109,7 +119,18 @@ const jobDispatchSchema = z.object({
|
|
|
109
119
|
* is stripped at resolution time). For use with a customer-committed
|
|
110
120
|
* `.kici/.npmrc` containing `${VAR}` placeholders.
|
|
111
121
|
*/
|
|
112
|
-
installEnvSecrets: z.record(z.string(), z.string()).optional()
|
|
122
|
+
installEnvSecrets: z.record(z.string(), z.string()).optional(),
|
|
123
|
+
/** Org id that owns this run — namespaces the user-facing cache (per-tenant isolation). */
|
|
124
|
+
orgId: z.string().optional(),
|
|
125
|
+
/** Repo identifier (e.g. "owner/repo") — second namespacing level for the user-facing cache. */
|
|
126
|
+
repoId: z.string().optional(),
|
|
127
|
+
/**
|
|
128
|
+
* Cache write scope for this job. `shared` lets the job write the
|
|
129
|
+
* org-shared default-branch cache; `isolated` confines writes to a
|
|
130
|
+
* per-run scope while still allowing shared-scope reads. Absent ⇒ treated
|
|
131
|
+
* as `isolated` by the agent (fail-closed).
|
|
132
|
+
*/
|
|
133
|
+
cacheRefScope: CacheRefScope.optional()
|
|
113
134
|
}).superRefine((val, ctx) => {
|
|
114
135
|
if (val.token && val.sourceAuth) {
|
|
115
136
|
if (val.sourceAuth.kind !== "basic") ctx.addIssue({
|
|
@@ -222,6 +243,44 @@ const jobStatusSchema = z.object({
|
|
|
222
243
|
encrypted: z.string()
|
|
223
244
|
})).optional()
|
|
224
245
|
});
|
|
246
|
+
/** Reasons an agent can refuse a job.dispatch. */
|
|
247
|
+
const JobRejectReason = z.enum(["busy", "draining"]);
|
|
248
|
+
/**
|
|
249
|
+
* Explicit dispatch rejection (agent -> orchestrator).
|
|
250
|
+
*
|
|
251
|
+
* Sent when the agent cannot accept a job.dispatch (already running a job,
|
|
252
|
+
* or draining). The orchestrator undoes its dispatch accounting and requeues
|
|
253
|
+
* the job for another agent. Protocol invariant: every job.dispatch is
|
|
254
|
+
* answered — accepted with `job.ack` (a `job.status` with state `running`
|
|
255
|
+
* also resolves the deadline), or refused with this message. An unanswered
|
|
256
|
+
* dispatch is treated as lost once the ack deadline expires (requeue +
|
|
257
|
+
* disconnect the agent) and is also covered by disconnect-time triage.
|
|
258
|
+
*/
|
|
259
|
+
const jobRejectSchema = z.object({
|
|
260
|
+
type: z.literal("job.reject"),
|
|
261
|
+
messageId: z.string(),
|
|
262
|
+
runId: z.string(),
|
|
263
|
+
jobId: z.string(),
|
|
264
|
+
reason: JobRejectReason,
|
|
265
|
+
timestamp: z.number()
|
|
266
|
+
});
|
|
267
|
+
/**
|
|
268
|
+
* Positive dispatch acknowledgment (agent -> orchestrator).
|
|
269
|
+
*
|
|
270
|
+
* Sent immediately when the agent receives a job.dispatch and accepts it
|
|
271
|
+
* (after the drain/busy checks, before execution begins). The orchestrator
|
|
272
|
+
* arms a deadline when it sends a dispatch; `job.ack`, `job.reject`, or a
|
|
273
|
+
* `job.status` with state `running` resolves it. A dispatch with no answer
|
|
274
|
+
* inside the deadline is treated as lost: the orchestrator requeues the job
|
|
275
|
+
* and disconnects the unresponsive agent.
|
|
276
|
+
*/
|
|
277
|
+
const jobAckSchema = z.object({
|
|
278
|
+
type: z.literal("job.ack"),
|
|
279
|
+
messageId: z.string(),
|
|
280
|
+
runId: z.string(),
|
|
281
|
+
jobId: z.string(),
|
|
282
|
+
timestamp: z.number()
|
|
283
|
+
});
|
|
225
284
|
/**
|
|
226
285
|
* Streaming log chunk from step execution (agent -> orchestrator).
|
|
227
286
|
*
|
|
@@ -361,6 +420,56 @@ const cacheUploadCompleteSchema = z.object({
|
|
|
361
420
|
/** SHA-256 hash of the dependency tarball for integrity verification. Only present for deps uploads. */
|
|
362
421
|
depsHash: z.string().optional()
|
|
363
422
|
});
|
|
423
|
+
/** Agent -> Orchestrator: request a user-cache restore (presigned download). */
|
|
424
|
+
const cacheUserRestoreRequestSchema = z.object({
|
|
425
|
+
type: z.literal("cache.user.restore.request"),
|
|
426
|
+
messageId: z.string(),
|
|
427
|
+
jobId: z.string(),
|
|
428
|
+
/** Exact cache key. */
|
|
429
|
+
key: z.string(),
|
|
430
|
+
/** Ordered prefix fallbacks (newest matching entry wins). */
|
|
431
|
+
restoreKeys: z.array(z.string()).optional()
|
|
432
|
+
});
|
|
433
|
+
/** Orchestrator -> Agent: presigned download URL + matched key + tar hash, or a miss. */
|
|
434
|
+
const cacheUserRestoreResponseSchema = z.object({
|
|
435
|
+
type: z.literal("cache.user.restore.response"),
|
|
436
|
+
requestId: z.string(),
|
|
437
|
+
/** True when an entry matched (exact or prefix). */
|
|
438
|
+
hit: z.boolean(),
|
|
439
|
+
/** Full key that matched (exact key or the matched prefix entry's full key). */
|
|
440
|
+
matchedKey: z.string().optional(),
|
|
441
|
+
/** Presigned GET URL for the matched tarball. Present only on hit. */
|
|
442
|
+
downloadUrl: z.string().optional(),
|
|
443
|
+
/** SHA-256 of the tarball bytes for integrity verification on download. */
|
|
444
|
+
tarHash: z.string().optional()
|
|
445
|
+
});
|
|
446
|
+
/** Agent -> Orchestrator: request a presigned PUT for a user-cache save (immutable; may decline if key exists). */
|
|
447
|
+
const cacheUserSaveRequestSchema = z.object({
|
|
448
|
+
type: z.literal("cache.user.save.request"),
|
|
449
|
+
messageId: z.string(),
|
|
450
|
+
jobId: z.string(),
|
|
451
|
+
key: z.string()
|
|
452
|
+
});
|
|
453
|
+
/** Orchestrator -> Agent: presigned PUT URL, or `skip` when the immutable key already exists. */
|
|
454
|
+
const cacheUserSaveResponseSchema = z.object({
|
|
455
|
+
type: z.literal("cache.user.save.response"),
|
|
456
|
+
requestId: z.string(),
|
|
457
|
+
/** Presigned PUT URL to the temp object. Absent when `skip` is true. */
|
|
458
|
+
uploadUrl: z.string().optional(),
|
|
459
|
+
/** True when the exact key already exists (immutable no-op). */
|
|
460
|
+
skip: z.boolean()
|
|
461
|
+
});
|
|
462
|
+
/** Agent -> Orchestrator: confirm a user-cache upload finished; orchestrator commits temp -> final + sets metadata. */
|
|
463
|
+
const cacheUserSaveCompleteSchema = z.object({
|
|
464
|
+
type: z.literal("cache.user.save.complete"),
|
|
465
|
+
messageId: z.string(),
|
|
466
|
+
jobId: z.string(),
|
|
467
|
+
key: z.string(),
|
|
468
|
+
/** SHA-256 of the tarball bytes. */
|
|
469
|
+
tarHash: z.string(),
|
|
470
|
+
/** Tarball size in bytes (drives quota accounting). */
|
|
471
|
+
sizeBytes: z.number().int().nonnegative()
|
|
472
|
+
});
|
|
364
473
|
/** Agent -> Orchestrator: emit a custom event from a running workflow step. */
|
|
365
474
|
const eventEmitSchema = z.object({
|
|
366
475
|
type: z.literal("event.emit"),
|
|
@@ -452,6 +561,8 @@ const orchestratorToAgentMessageSchema = z.discriminatedUnion("type", [
|
|
|
452
561
|
registerAckSchema,
|
|
453
562
|
jobConcurrencyAckSchema,
|
|
454
563
|
cacheUploadResponseSchema,
|
|
564
|
+
cacheUserRestoreResponseSchema,
|
|
565
|
+
cacheUserSaveResponseSchema,
|
|
455
566
|
eventEmitResponseSchema,
|
|
456
567
|
agentApiResponseSchema,
|
|
457
568
|
agentAuthSuccessSchema,
|
|
@@ -462,6 +573,8 @@ const agentToOrchestratorMessageSchema = z.discriminatedUnion("type", [
|
|
|
462
573
|
agentRegisterSchema,
|
|
463
574
|
agentStatusSchema,
|
|
464
575
|
jobStatusSchema,
|
|
576
|
+
jobRejectSchema,
|
|
577
|
+
jobAckSchema,
|
|
465
578
|
agentLogChunkSchema,
|
|
466
579
|
agentStepStatusSchema,
|
|
467
580
|
jobHeartbeatSchema,
|
|
@@ -470,12 +583,15 @@ const agentToOrchestratorMessageSchema = z.discriminatedUnion("type", [
|
|
|
470
583
|
configAckSchema,
|
|
471
584
|
cacheUploadRequestSchema,
|
|
472
585
|
cacheUploadCompleteSchema,
|
|
586
|
+
cacheUserRestoreRequestSchema,
|
|
587
|
+
cacheUserSaveRequestSchema,
|
|
588
|
+
cacheUserSaveCompleteSchema,
|
|
473
589
|
eventEmitSchema,
|
|
474
590
|
agentApiRequestSchema,
|
|
475
591
|
agentMetricsSchema,
|
|
476
592
|
agentAuthRequestSchema
|
|
477
593
|
]);
|
|
478
594
|
//#endregion
|
|
479
|
-
export { agentApiRequestSchema, agentApiResponseSchema, agentAuthFailureSchema, agentAuthRequestSchema, agentAuthSuccessSchema, agentLogChunkSchema, agentMetricsSchema, agentRegisterSchema, agentStatusSchema, agentStepStatusSchema, agentToOrchestratorMessageSchema, configAckSchema, eventEmitResponseSchema, eventEmitSchema, gitAuthSchema, jobCancelSchema, jobConcurrencyAckSchema, jobConcurrencyReportSchema, jobDispatchSchema, jobStatusSchema, orchestratorToAgentMessageSchema, registerAckSchema };
|
|
595
|
+
export { CacheRefScope, JobRejectReason, agentApiRequestSchema, agentApiResponseSchema, agentAuthFailureSchema, agentAuthRequestSchema, agentAuthSuccessSchema, agentLogChunkSchema, agentMetricsSchema, agentRegisterSchema, agentStatusSchema, agentStepStatusSchema, agentToOrchestratorMessageSchema, cacheUserRestoreRequestSchema, cacheUserRestoreResponseSchema, cacheUserSaveCompleteSchema, cacheUserSaveRequestSchema, cacheUserSaveResponseSchema, configAckSchema, eventEmitResponseSchema, eventEmitSchema, gitAuthSchema, jobAckSchema, jobCancelSchema, jobConcurrencyAckSchema, jobConcurrencyReportSchema, jobDispatchSchema, jobRejectSchema, jobStatusSchema, orchestratorToAgentMessageSchema, registerAckSchema };
|
|
480
596
|
|
|
481
597
|
//# sourceMappingURL=orchestrator-agent.js.map
|
|
@@ -14,6 +14,7 @@ declare const scalerCapacitySummarySchema: z.ZodObject<{
|
|
|
14
14
|
labelSets: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
15
15
|
maxAgents: z.ZodNumber;
|
|
16
16
|
activeCount: z.ZodNumber;
|
|
17
|
+
spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
|
|
17
18
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
18
19
|
}, z.core.$strip>;
|
|
19
20
|
/** Peer hello: initiator sends ephemeral X25519 public key and nonce. */
|
|
@@ -57,6 +58,7 @@ export declare const peerAuthResponseSchema: z.ZodObject<{
|
|
|
57
58
|
platform: z.ZodString;
|
|
58
59
|
arch: z.ZodString;
|
|
59
60
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
61
|
+
scalerName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
62
|
}, z.core.$strip>>>;
|
|
61
63
|
scalerCapacity: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
62
64
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -64,6 +66,7 @@ export declare const peerAuthResponseSchema: z.ZodObject<{
|
|
|
64
66
|
labelSets: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
65
67
|
maxAgents: z.ZodNumber;
|
|
66
68
|
activeCount: z.ZodNumber;
|
|
69
|
+
spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
|
|
67
70
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
68
71
|
}, z.core.$strip>>>;
|
|
69
72
|
capabilities: z.ZodOptional<z.ZodObject<{
|
|
@@ -89,6 +92,7 @@ export declare const peerHeartbeatSchema: z.ZodObject<{
|
|
|
89
92
|
platform: z.ZodString;
|
|
90
93
|
arch: z.ZodString;
|
|
91
94
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
95
|
+
scalerName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
92
96
|
}, z.core.$strip>>;
|
|
93
97
|
capabilities: z.ZodObject<{
|
|
94
98
|
s3LogAccess: z.ZodBoolean;
|
|
@@ -103,6 +107,7 @@ export declare const peerHeartbeatSchema: z.ZodObject<{
|
|
|
103
107
|
labelSets: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
104
108
|
maxAgents: z.ZodNumber;
|
|
105
109
|
activeCount: z.ZodNumber;
|
|
110
|
+
spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
|
|
106
111
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
107
112
|
}, z.core.$strip>>>;
|
|
108
113
|
configVersion: z.ZodOptional<z.ZodNumber>;
|
|
@@ -373,6 +378,7 @@ export declare const peerToPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
373
378
|
platform: z.ZodString;
|
|
374
379
|
arch: z.ZodString;
|
|
375
380
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
381
|
+
scalerName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
376
382
|
}, z.core.$strip>>>;
|
|
377
383
|
scalerCapacity: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
378
384
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -380,6 +386,7 @@ export declare const peerToPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
380
386
|
labelSets: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
381
387
|
maxAgents: z.ZodNumber;
|
|
382
388
|
activeCount: z.ZodNumber;
|
|
389
|
+
spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
|
|
383
390
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
384
391
|
}, z.core.$strip>>>;
|
|
385
392
|
capabilities: z.ZodOptional<z.ZodObject<{
|
|
@@ -403,6 +410,7 @@ export declare const peerToPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
403
410
|
platform: z.ZodString;
|
|
404
411
|
arch: z.ZodString;
|
|
405
412
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
413
|
+
scalerName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
406
414
|
}, z.core.$strip>>;
|
|
407
415
|
capabilities: z.ZodObject<{
|
|
408
416
|
s3LogAccess: z.ZodBoolean;
|
|
@@ -417,6 +425,7 @@ export declare const peerToPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
417
425
|
labelSets: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
418
426
|
maxAgents: z.ZodNumber;
|
|
419
427
|
activeCount: z.ZodNumber;
|
|
428
|
+
spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
|
|
420
429
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
421
430
|
}, z.core.$strip>>>;
|
|
422
431
|
configVersion: z.ZodOptional<z.ZodNumber>;
|
|
@@ -617,6 +626,7 @@ export declare const peerFromPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
617
626
|
platform: z.ZodString;
|
|
618
627
|
arch: z.ZodString;
|
|
619
628
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
629
|
+
scalerName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
620
630
|
}, z.core.$strip>>>;
|
|
621
631
|
scalerCapacity: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
622
632
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -624,6 +634,7 @@ export declare const peerFromPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
624
634
|
labelSets: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
625
635
|
maxAgents: z.ZodNumber;
|
|
626
636
|
activeCount: z.ZodNumber;
|
|
637
|
+
spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
|
|
627
638
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
628
639
|
}, z.core.$strip>>>;
|
|
629
640
|
capabilities: z.ZodOptional<z.ZodObject<{
|
|
@@ -647,6 +658,7 @@ export declare const peerFromPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
647
658
|
platform: z.ZodString;
|
|
648
659
|
arch: z.ZodString;
|
|
649
660
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
661
|
+
scalerName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
650
662
|
}, z.core.$strip>>;
|
|
651
663
|
capabilities: z.ZodObject<{
|
|
652
664
|
s3LogAccess: z.ZodBoolean;
|
|
@@ -661,6 +673,7 @@ export declare const peerFromPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
661
673
|
labelSets: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
662
674
|
maxAgents: z.ZodNumber;
|
|
663
675
|
activeCount: z.ZodNumber;
|
|
676
|
+
spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
|
|
664
677
|
mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
665
678
|
}, z.core.$strip>>>;
|
|
666
679
|
configVersion: z.ZodOptional<z.ZodNumber>;
|
|
@@ -22,7 +22,14 @@ const peerAgentSummarySchema = z.object({
|
|
|
22
22
|
* predate the gate omit the field, and the coordinator falls back to
|
|
23
23
|
* "no gate" routing for those agents (matching pre-gate behavior).
|
|
24
24
|
*/
|
|
25
|
-
mandatoryLabels: z.array(z.string()).optional().default([])
|
|
25
|
+
mandatoryLabels: z.array(z.string()).optional().default([]),
|
|
26
|
+
/**
|
|
27
|
+
* Name of the scaler backend that spawned this agent, or null/omitted for
|
|
28
|
+
* static (stateful) agents not bound to any scaler. Carried so the dashboard
|
|
29
|
+
* diagnostics tree can group a worker peer's agents under the correct scaler
|
|
30
|
+
* row (and the stateful-agents row) without a second round trip.
|
|
31
|
+
*/
|
|
32
|
+
scalerName: z.string().nullable().optional()
|
|
26
33
|
});
|
|
27
34
|
/** Peer capabilities advertised during heartbeat and auth response. */
|
|
28
35
|
const peerCapabilitiesSchema = z.object({
|
|
@@ -42,6 +49,12 @@ const scalerCapacitySummarySchema = z.object({
|
|
|
42
49
|
/** Current active count for this backend */
|
|
43
50
|
activeCount: z.number(),
|
|
44
51
|
/**
|
|
52
|
+
* Whether this backend spawns its agents on the peer's own host (bare-metal,
|
|
53
|
+
* Firecracker, container on a local runtime socket). Lets diagnostics
|
|
54
|
+
* surface the peer's hostname as the scaler's spawning host.
|
|
55
|
+
*/
|
|
56
|
+
spawnsOnLocalHost: z.boolean().optional(),
|
|
57
|
+
/**
|
|
45
58
|
* Labels a job MUST declare in `runsOn` to be allowed on this backend
|
|
46
59
|
* (Kubernetes-taint-style opt-in gate). When omitted (legacy peer) or
|
|
47
60
|
* empty the backend has no gate. Cross-peer routing applies the same
|