@kici-dev/engine 0.1.14 → 0.1.16
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/approval/types.d.ts +56 -0
- package/dist/approval/types.js +42 -0
- package/dist/audit/access-log-policy.js +14 -0
- package/dist/audit/retention-policy.js +10 -0
- package/dist/environment/types.d.ts +8 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +10 -8
- 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 +26 -0
- package/dist/protocol/messages/access-log.js +5 -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 +619 -6
- package/dist/protocol/messages/dashboard.js +179 -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 +56 -3
- package/dist/protocol/messages/execution-status.js +44 -4
- package/dist/protocol/messages/orchestrator-agent.d.ts +284 -0
- package/dist/protocol/messages/orchestrator-agent.js +202 -4
- package/dist/protocol/messages/peer.d.ts +89 -0
- package/dist/protocol/messages/peer.js +50 -2
- package/dist/protocol/messages/platform-orchestrator.d.ts +168 -6
- package/dist/protocol/messages/platform-orchestrator.js +15 -56
- package/dist/protocol/messages/run-events.d.ts +1 -0
- package/dist/provenance/schema.d.ts +407 -0
- package/dist/provenance/schema.js +143 -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 +29 -1
- package/dist/trigger/types.js +4 -1
- package/dist/ws/close-codes.d.ts +7 -0
- package/dist/ws/close-codes.js +8 -1
- package/package.json +19 -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">;
|
|
@@ -319,6 +424,81 @@ export declare const agentApiResponseSchema: z.ZodObject<{
|
|
|
319
424
|
result: z.ZodOptional<z.ZodUnknown>;
|
|
320
425
|
error: z.ZodOptional<z.ZodString>;
|
|
321
426
|
}, z.core.$strip>;
|
|
427
|
+
/** Orchestrator asks an agent for its log/diagnostic mini-bundle. */
|
|
428
|
+
export declare const fleetLogsRequestSchema: z.ZodObject<{
|
|
429
|
+
type: z.ZodLiteral<"fleet.logs.request">;
|
|
430
|
+
requestId: z.ZodString;
|
|
431
|
+
logWindowHours: z.ZodNumber;
|
|
432
|
+
maxBytes: z.ZodNumber;
|
|
433
|
+
}, z.core.$strip>;
|
|
434
|
+
/** One base64 frame of an agent's mini-bundle ZIP. */
|
|
435
|
+
export declare const fleetBundleChunkSchema: z.ZodObject<{
|
|
436
|
+
type: z.ZodLiteral<"fleet.bundle.chunk">;
|
|
437
|
+
requestId: z.ZodString;
|
|
438
|
+
seq: z.ZodNumber;
|
|
439
|
+
isLast: z.ZodBoolean;
|
|
440
|
+
dataB64: z.ZodString;
|
|
441
|
+
}, z.core.$strip>;
|
|
442
|
+
/** Agent failed to build/stream its mini-bundle. */
|
|
443
|
+
export declare const fleetBundleErrorSchema: z.ZodObject<{
|
|
444
|
+
type: z.ZodLiteral<"fleet.bundle.error">;
|
|
445
|
+
requestId: z.ZodString;
|
|
446
|
+
message: z.ZodString;
|
|
447
|
+
}, z.core.$strip>;
|
|
448
|
+
/** Outcome of a step-level approval hold, sent back to the waiting agent. */
|
|
449
|
+
export declare const StepApprovalOutcome: z.ZodEnum<{
|
|
450
|
+
rejected: "rejected";
|
|
451
|
+
approved: "approved";
|
|
452
|
+
expired: "expired";
|
|
453
|
+
}>;
|
|
454
|
+
export type StepApprovalOutcome = z.infer<typeof StepApprovalOutcome>;
|
|
455
|
+
/**
|
|
456
|
+
* Agent -> Orchestrator: a step carrying `requireApproval` is about to run and
|
|
457
|
+
* the agent is blocking its step loop until the orchestrator resolves the
|
|
458
|
+
* approval. The orchestrator creates a step-scoped `held_runs` row from the
|
|
459
|
+
* normalized requirement and replies with `step.approval-resolved` once the
|
|
460
|
+
* hold is approved, rejected, or expired. The agent keeps heartbeats flowing
|
|
461
|
+
* during the wait so it is not reaped as stale.
|
|
462
|
+
*
|
|
463
|
+
* NOT fast-pathed — the `log.chunk` / `heartbeat` manual-validator invariant is
|
|
464
|
+
* untouched by this message.
|
|
465
|
+
*/
|
|
466
|
+
export declare const stepApprovalRequestSchema: z.ZodObject<{
|
|
467
|
+
type: z.ZodLiteral<"step.approval-request">;
|
|
468
|
+
messageId: z.ZodString;
|
|
469
|
+
runId: z.ZodString;
|
|
470
|
+
jobId: z.ZodString;
|
|
471
|
+
stepIndex: z.ZodNumber;
|
|
472
|
+
stepName: z.ZodString;
|
|
473
|
+
clauses: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
474
|
+
team: z.ZodString;
|
|
475
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
476
|
+
user: z.ZodString;
|
|
477
|
+
}, z.core.$strict>]>>;
|
|
478
|
+
reason: z.ZodString;
|
|
479
|
+
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
480
|
+
}, z.core.$strip>;
|
|
481
|
+
export type StepApprovalRequest = z.infer<typeof stepApprovalRequestSchema>;
|
|
482
|
+
/**
|
|
483
|
+
* Orchestrator -> Agent: resolution of a step-level approval hold. `requestId`
|
|
484
|
+
* correlates to the originating `step.approval-request.messageId`. On
|
|
485
|
+
* `approved` the agent runs the step with its live workspace intact; on
|
|
486
|
+
* `rejected`/`expired` it fails the job with a clear reason.
|
|
487
|
+
*/
|
|
488
|
+
export declare const stepApprovalResolvedSchema: z.ZodObject<{
|
|
489
|
+
type: z.ZodLiteral<"step.approval-resolved">;
|
|
490
|
+
requestId: z.ZodString;
|
|
491
|
+
runId: z.ZodString;
|
|
492
|
+
jobId: z.ZodString;
|
|
493
|
+
stepIndex: z.ZodNumber;
|
|
494
|
+
outcome: z.ZodEnum<{
|
|
495
|
+
rejected: "rejected";
|
|
496
|
+
approved: "approved";
|
|
497
|
+
expired: "expired";
|
|
498
|
+
}>;
|
|
499
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
500
|
+
}, z.core.$strip>;
|
|
501
|
+
export type StepApprovalResolved = z.infer<typeof stepApprovalResolvedSchema>;
|
|
322
502
|
/** All messages that flow from Orchestrator to Agent. */
|
|
323
503
|
export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
324
504
|
type: z.ZodLiteral<"job.dispatch">;
|
|
@@ -375,6 +555,12 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
375
555
|
token: z.ZodString;
|
|
376
556
|
}, z.core.$strip>>>;
|
|
377
557
|
installEnvSecrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
558
|
+
orgId: z.ZodOptional<z.ZodString>;
|
|
559
|
+
repoId: z.ZodOptional<z.ZodString>;
|
|
560
|
+
cacheRefScope: z.ZodOptional<z.ZodEnum<{
|
|
561
|
+
shared: "shared";
|
|
562
|
+
isolated: "isolated";
|
|
563
|
+
}>>;
|
|
378
564
|
}, z.core.$strip>, z.ZodObject<{
|
|
379
565
|
type: z.ZodLiteral<"job.cancel">;
|
|
380
566
|
messageId: z.ZodString;
|
|
@@ -403,6 +589,18 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
403
589
|
type: z.ZodLiteral<"cache.upload.response">;
|
|
404
590
|
requestId: z.ZodString;
|
|
405
591
|
uploadUrl: z.ZodString;
|
|
592
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
593
|
+
type: z.ZodLiteral<"cache.user.restore.response">;
|
|
594
|
+
requestId: z.ZodString;
|
|
595
|
+
hit: z.ZodBoolean;
|
|
596
|
+
matchedKey: z.ZodOptional<z.ZodString>;
|
|
597
|
+
downloadUrl: z.ZodOptional<z.ZodString>;
|
|
598
|
+
tarHash: z.ZodOptional<z.ZodString>;
|
|
599
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
600
|
+
type: z.ZodLiteral<"cache.user.save.response">;
|
|
601
|
+
requestId: z.ZodString;
|
|
602
|
+
uploadUrl: z.ZodOptional<z.ZodString>;
|
|
603
|
+
skip: z.ZodBoolean;
|
|
406
604
|
}, z.core.$strip>, z.ZodObject<{
|
|
407
605
|
type: z.ZodLiteral<"event.emit.response">;
|
|
408
606
|
requestId: z.ZodString;
|
|
@@ -419,6 +617,23 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
419
617
|
}, z.core.$strip>, z.ZodObject<{
|
|
420
618
|
type: z.ZodLiteral<"auth.failure">;
|
|
421
619
|
reason: z.ZodString;
|
|
620
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
621
|
+
type: z.ZodLiteral<"fleet.logs.request">;
|
|
622
|
+
requestId: z.ZodString;
|
|
623
|
+
logWindowHours: z.ZodNumber;
|
|
624
|
+
maxBytes: z.ZodNumber;
|
|
625
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
626
|
+
type: z.ZodLiteral<"step.approval-resolved">;
|
|
627
|
+
requestId: z.ZodString;
|
|
628
|
+
runId: z.ZodString;
|
|
629
|
+
jobId: z.ZodString;
|
|
630
|
+
stepIndex: z.ZodNumber;
|
|
631
|
+
outcome: z.ZodEnum<{
|
|
632
|
+
rejected: "rejected";
|
|
633
|
+
approved: "approved";
|
|
634
|
+
expired: "expired";
|
|
635
|
+
}>;
|
|
636
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
422
637
|
}, z.core.$strip>], "type">;
|
|
423
638
|
/** All messages that flow from Agent to Orchestrator. */
|
|
424
639
|
export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -475,6 +690,22 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
475
690
|
agentPublicKey: z.ZodString;
|
|
476
691
|
encrypted: z.ZodString;
|
|
477
692
|
}, z.core.$strip>>>;
|
|
693
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
694
|
+
type: z.ZodLiteral<"job.reject">;
|
|
695
|
+
messageId: z.ZodString;
|
|
696
|
+
runId: z.ZodString;
|
|
697
|
+
jobId: z.ZodString;
|
|
698
|
+
reason: z.ZodEnum<{
|
|
699
|
+
draining: "draining";
|
|
700
|
+
busy: "busy";
|
|
701
|
+
}>;
|
|
702
|
+
timestamp: z.ZodNumber;
|
|
703
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
704
|
+
type: z.ZodLiteral<"job.ack">;
|
|
705
|
+
messageId: z.ZodString;
|
|
706
|
+
runId: z.ZodString;
|
|
707
|
+
jobId: z.ZodString;
|
|
708
|
+
timestamp: z.ZodNumber;
|
|
478
709
|
}, z.core.$strip>, z.ZodObject<{
|
|
479
710
|
type: z.ZodLiteral<"log.chunk">;
|
|
480
711
|
messageId: z.ZodString;
|
|
@@ -555,6 +786,24 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
555
786
|
platform: z.ZodString;
|
|
556
787
|
arch: z.ZodString;
|
|
557
788
|
depsHash: z.ZodOptional<z.ZodString>;
|
|
789
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
790
|
+
type: z.ZodLiteral<"cache.user.restore.request">;
|
|
791
|
+
messageId: z.ZodString;
|
|
792
|
+
jobId: z.ZodString;
|
|
793
|
+
key: z.ZodString;
|
|
794
|
+
restoreKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
795
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
796
|
+
type: z.ZodLiteral<"cache.user.save.request">;
|
|
797
|
+
messageId: z.ZodString;
|
|
798
|
+
jobId: z.ZodString;
|
|
799
|
+
key: z.ZodString;
|
|
800
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
801
|
+
type: z.ZodLiteral<"cache.user.save.complete">;
|
|
802
|
+
messageId: z.ZodString;
|
|
803
|
+
jobId: z.ZodString;
|
|
804
|
+
key: z.ZodString;
|
|
805
|
+
tarHash: z.ZodString;
|
|
806
|
+
sizeBytes: z.ZodNumber;
|
|
558
807
|
}, z.core.$strip>, z.ZodObject<{
|
|
559
808
|
type: z.ZodLiteral<"event.emit">;
|
|
560
809
|
jobId: z.ZodString;
|
|
@@ -595,12 +844,47 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
|
|
|
595
844
|
type: z.ZodLiteral<"auth.request">;
|
|
596
845
|
token: z.ZodString;
|
|
597
846
|
protocolVersion: z.ZodNumber;
|
|
847
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
848
|
+
type: z.ZodLiteral<"fleet.bundle.chunk">;
|
|
849
|
+
requestId: z.ZodString;
|
|
850
|
+
seq: z.ZodNumber;
|
|
851
|
+
isLast: z.ZodBoolean;
|
|
852
|
+
dataB64: z.ZodString;
|
|
853
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
854
|
+
type: z.ZodLiteral<"fleet.bundle.error">;
|
|
855
|
+
requestId: z.ZodString;
|
|
856
|
+
message: z.ZodString;
|
|
857
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
858
|
+
type: z.ZodLiteral<"step.approval-request">;
|
|
859
|
+
messageId: z.ZodString;
|
|
860
|
+
runId: z.ZodString;
|
|
861
|
+
jobId: z.ZodString;
|
|
862
|
+
stepIndex: z.ZodNumber;
|
|
863
|
+
stepName: z.ZodString;
|
|
864
|
+
clauses: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
865
|
+
team: z.ZodString;
|
|
866
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
867
|
+
user: z.ZodString;
|
|
868
|
+
}, z.core.$strict>]>>;
|
|
869
|
+
reason: z.ZodString;
|
|
870
|
+
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
598
871
|
}, z.core.$strip>], "type">;
|
|
599
872
|
export type JobDispatch = z.infer<typeof jobDispatchSchema>;
|
|
600
873
|
export type JobCancel = z.infer<typeof jobCancelSchema>;
|
|
601
874
|
export type JobStatus = z.infer<typeof jobStatusSchema>;
|
|
875
|
+
export type JobReject = z.infer<typeof jobRejectSchema>;
|
|
876
|
+
export type JobAck = z.infer<typeof jobAckSchema>;
|
|
602
877
|
export type AgentLogChunk = z.infer<typeof agentLogChunkSchema>;
|
|
603
878
|
export type AgentStepStatus = z.infer<typeof agentStepStatusSchema>;
|
|
604
879
|
export type AgentMetrics = z.infer<typeof agentMetricsSchema>;
|
|
880
|
+
export type CacheUserRestoreRequest = z.infer<typeof cacheUserRestoreRequestSchema>;
|
|
881
|
+
export type CacheUserRestoreResponse = z.infer<typeof cacheUserRestoreResponseSchema>;
|
|
882
|
+
export type CacheUserSaveRequest = z.infer<typeof cacheUserSaveRequestSchema>;
|
|
883
|
+
export type CacheUserSaveResponse = z.infer<typeof cacheUserSaveResponseSchema>;
|
|
884
|
+
export type CacheUserSaveComplete = z.infer<typeof cacheUserSaveCompleteSchema>;
|
|
885
|
+
export type FleetLogsRequest = z.infer<typeof fleetLogsRequestSchema>;
|
|
886
|
+
export type FleetBundleChunk = z.infer<typeof fleetBundleChunkSchema>;
|
|
887
|
+
export type FleetBundleError = z.infer<typeof fleetBundleErrorSchema>;
|
|
888
|
+
export type OrchestratorToAgentMessage = z.infer<typeof orchestratorToAgentMessageSchema>;
|
|
605
889
|
export type AgentToOrchestratorMessage = z.infer<typeof agentToOrchestratorMessageSchema>;
|
|
606
890
|
//# sourceMappingURL=orchestrator-agent.d.ts.map
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import "../../chunk-gOLHoazu.js";
|
|
2
2
|
import { ExecutionJobStatus, ExecutionStepStatus } from "./execution-status.js";
|
|
3
|
+
import { approverClauseSchema } from "../../approval/types.js";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
//#region src/protocol/messages/orchestrator-agent.ts
|
|
5
6
|
/**
|
|
7
|
+
* Cache write scope for a job's user-facing cache.
|
|
8
|
+
*
|
|
9
|
+
* - `shared` — trusted ref (default branch / write-permission contributor):
|
|
10
|
+
* reads AND writes the org-shared default-branch scope.
|
|
11
|
+
* - `isolated` — untrusted ref (fork PR / unknown contributor): reads the
|
|
12
|
+
* shared scope as a fallback but writes only into a per-run isolated scope,
|
|
13
|
+
* so an untrusted ref can never poison the shared cache (GitHub Actions model).
|
|
14
|
+
*/
|
|
15
|
+
const CacheRefScope = z.enum(["shared", "isolated"]);
|
|
16
|
+
/**
|
|
6
17
|
* Structured git-clone auth material. Carries everything the agent needs to
|
|
7
18
|
* authenticate a single `git clone`:
|
|
8
19
|
*
|
|
@@ -109,7 +120,18 @@ const jobDispatchSchema = z.object({
|
|
|
109
120
|
* is stripped at resolution time). For use with a customer-committed
|
|
110
121
|
* `.kici/.npmrc` containing `${VAR}` placeholders.
|
|
111
122
|
*/
|
|
112
|
-
installEnvSecrets: z.record(z.string(), z.string()).optional()
|
|
123
|
+
installEnvSecrets: z.record(z.string(), z.string()).optional(),
|
|
124
|
+
/** Org id that owns this run — namespaces the user-facing cache (per-tenant isolation). */
|
|
125
|
+
orgId: z.string().optional(),
|
|
126
|
+
/** Repo identifier (e.g. "owner/repo") — second namespacing level for the user-facing cache. */
|
|
127
|
+
repoId: z.string().optional(),
|
|
128
|
+
/**
|
|
129
|
+
* Cache write scope for this job. `shared` lets the job write the
|
|
130
|
+
* org-shared default-branch cache; `isolated` confines writes to a
|
|
131
|
+
* per-run scope while still allowing shared-scope reads. Absent ⇒ treated
|
|
132
|
+
* as `isolated` by the agent (fail-closed).
|
|
133
|
+
*/
|
|
134
|
+
cacheRefScope: CacheRefScope.optional()
|
|
113
135
|
}).superRefine((val, ctx) => {
|
|
114
136
|
if (val.token && val.sourceAuth) {
|
|
115
137
|
if (val.sourceAuth.kind !== "basic") ctx.addIssue({
|
|
@@ -222,6 +244,44 @@ const jobStatusSchema = z.object({
|
|
|
222
244
|
encrypted: z.string()
|
|
223
245
|
})).optional()
|
|
224
246
|
});
|
|
247
|
+
/** Reasons an agent can refuse a job.dispatch. */
|
|
248
|
+
const JobRejectReason = z.enum(["busy", "draining"]);
|
|
249
|
+
/**
|
|
250
|
+
* Explicit dispatch rejection (agent -> orchestrator).
|
|
251
|
+
*
|
|
252
|
+
* Sent when the agent cannot accept a job.dispatch (already running a job,
|
|
253
|
+
* or draining). The orchestrator undoes its dispatch accounting and requeues
|
|
254
|
+
* the job for another agent. Protocol invariant: every job.dispatch is
|
|
255
|
+
* answered — accepted with `job.ack` (a `job.status` with state `running`
|
|
256
|
+
* also resolves the deadline), or refused with this message. An unanswered
|
|
257
|
+
* dispatch is treated as lost once the ack deadline expires (requeue +
|
|
258
|
+
* disconnect the agent) and is also covered by disconnect-time triage.
|
|
259
|
+
*/
|
|
260
|
+
const jobRejectSchema = z.object({
|
|
261
|
+
type: z.literal("job.reject"),
|
|
262
|
+
messageId: z.string(),
|
|
263
|
+
runId: z.string(),
|
|
264
|
+
jobId: z.string(),
|
|
265
|
+
reason: JobRejectReason,
|
|
266
|
+
timestamp: z.number()
|
|
267
|
+
});
|
|
268
|
+
/**
|
|
269
|
+
* Positive dispatch acknowledgment (agent -> orchestrator).
|
|
270
|
+
*
|
|
271
|
+
* Sent immediately when the agent receives a job.dispatch and accepts it
|
|
272
|
+
* (after the drain/busy checks, before execution begins). The orchestrator
|
|
273
|
+
* arms a deadline when it sends a dispatch; `job.ack`, `job.reject`, or a
|
|
274
|
+
* `job.status` with state `running` resolves it. A dispatch with no answer
|
|
275
|
+
* inside the deadline is treated as lost: the orchestrator requeues the job
|
|
276
|
+
* and disconnects the unresponsive agent.
|
|
277
|
+
*/
|
|
278
|
+
const jobAckSchema = z.object({
|
|
279
|
+
type: z.literal("job.ack"),
|
|
280
|
+
messageId: z.string(),
|
|
281
|
+
runId: z.string(),
|
|
282
|
+
jobId: z.string(),
|
|
283
|
+
timestamp: z.number()
|
|
284
|
+
});
|
|
225
285
|
/**
|
|
226
286
|
* Streaming log chunk from step execution (agent -> orchestrator).
|
|
227
287
|
*
|
|
@@ -361,6 +421,56 @@ const cacheUploadCompleteSchema = z.object({
|
|
|
361
421
|
/** SHA-256 hash of the dependency tarball for integrity verification. Only present for deps uploads. */
|
|
362
422
|
depsHash: z.string().optional()
|
|
363
423
|
});
|
|
424
|
+
/** Agent -> Orchestrator: request a user-cache restore (presigned download). */
|
|
425
|
+
const cacheUserRestoreRequestSchema = z.object({
|
|
426
|
+
type: z.literal("cache.user.restore.request"),
|
|
427
|
+
messageId: z.string(),
|
|
428
|
+
jobId: z.string(),
|
|
429
|
+
/** Exact cache key. */
|
|
430
|
+
key: z.string(),
|
|
431
|
+
/** Ordered prefix fallbacks (newest matching entry wins). */
|
|
432
|
+
restoreKeys: z.array(z.string()).optional()
|
|
433
|
+
});
|
|
434
|
+
/** Orchestrator -> Agent: presigned download URL + matched key + tar hash, or a miss. */
|
|
435
|
+
const cacheUserRestoreResponseSchema = z.object({
|
|
436
|
+
type: z.literal("cache.user.restore.response"),
|
|
437
|
+
requestId: z.string(),
|
|
438
|
+
/** True when an entry matched (exact or prefix). */
|
|
439
|
+
hit: z.boolean(),
|
|
440
|
+
/** Full key that matched (exact key or the matched prefix entry's full key). */
|
|
441
|
+
matchedKey: z.string().optional(),
|
|
442
|
+
/** Presigned GET URL for the matched tarball. Present only on hit. */
|
|
443
|
+
downloadUrl: z.string().optional(),
|
|
444
|
+
/** SHA-256 of the tarball bytes for integrity verification on download. */
|
|
445
|
+
tarHash: z.string().optional()
|
|
446
|
+
});
|
|
447
|
+
/** Agent -> Orchestrator: request a presigned PUT for a user-cache save (immutable; may decline if key exists). */
|
|
448
|
+
const cacheUserSaveRequestSchema = z.object({
|
|
449
|
+
type: z.literal("cache.user.save.request"),
|
|
450
|
+
messageId: z.string(),
|
|
451
|
+
jobId: z.string(),
|
|
452
|
+
key: z.string()
|
|
453
|
+
});
|
|
454
|
+
/** Orchestrator -> Agent: presigned PUT URL, or `skip` when the immutable key already exists. */
|
|
455
|
+
const cacheUserSaveResponseSchema = z.object({
|
|
456
|
+
type: z.literal("cache.user.save.response"),
|
|
457
|
+
requestId: z.string(),
|
|
458
|
+
/** Presigned PUT URL to the temp object. Absent when `skip` is true. */
|
|
459
|
+
uploadUrl: z.string().optional(),
|
|
460
|
+
/** True when the exact key already exists (immutable no-op). */
|
|
461
|
+
skip: z.boolean()
|
|
462
|
+
});
|
|
463
|
+
/** Agent -> Orchestrator: confirm a user-cache upload finished; orchestrator commits temp -> final + sets metadata. */
|
|
464
|
+
const cacheUserSaveCompleteSchema = z.object({
|
|
465
|
+
type: z.literal("cache.user.save.complete"),
|
|
466
|
+
messageId: z.string(),
|
|
467
|
+
jobId: z.string(),
|
|
468
|
+
key: z.string(),
|
|
469
|
+
/** SHA-256 of the tarball bytes. */
|
|
470
|
+
tarHash: z.string(),
|
|
471
|
+
/** Tarball size in bytes (drives quota accounting). */
|
|
472
|
+
sizeBytes: z.number().int().nonnegative()
|
|
473
|
+
});
|
|
364
474
|
/** Agent -> Orchestrator: emit a custom event from a running workflow step. */
|
|
365
475
|
const eventEmitSchema = z.object({
|
|
366
476
|
type: z.literal("event.emit"),
|
|
@@ -445,6 +555,82 @@ const agentApiResponseSchema = z.object({
|
|
|
445
555
|
/** Error description (present on failure). */
|
|
446
556
|
error: z.string().optional()
|
|
447
557
|
});
|
|
558
|
+
/** Orchestrator asks an agent for its log/diagnostic mini-bundle. */
|
|
559
|
+
const fleetLogsRequestSchema = z.object({
|
|
560
|
+
type: z.literal("fleet.logs.request"),
|
|
561
|
+
/** UUID correlating the chunked response. */
|
|
562
|
+
requestId: z.string(),
|
|
563
|
+
/** Hours of log history to include. */
|
|
564
|
+
logWindowHours: z.number(),
|
|
565
|
+
/** Per-node cap on raw log bytes. */
|
|
566
|
+
maxBytes: z.number()
|
|
567
|
+
});
|
|
568
|
+
/** One base64 frame of an agent's mini-bundle ZIP. */
|
|
569
|
+
const fleetBundleChunkSchema = z.object({
|
|
570
|
+
type: z.literal("fleet.bundle.chunk"),
|
|
571
|
+
requestId: z.string(),
|
|
572
|
+
seq: z.number().int().nonnegative(),
|
|
573
|
+
isLast: z.boolean(),
|
|
574
|
+
dataB64: z.string()
|
|
575
|
+
});
|
|
576
|
+
/** Agent failed to build/stream its mini-bundle. */
|
|
577
|
+
const fleetBundleErrorSchema = z.object({
|
|
578
|
+
type: z.literal("fleet.bundle.error"),
|
|
579
|
+
requestId: z.string(),
|
|
580
|
+
message: z.string()
|
|
581
|
+
});
|
|
582
|
+
/** Outcome of a step-level approval hold, sent back to the waiting agent. */
|
|
583
|
+
const StepApprovalOutcome = z.enum([
|
|
584
|
+
"approved",
|
|
585
|
+
"rejected",
|
|
586
|
+
"expired"
|
|
587
|
+
]);
|
|
588
|
+
/**
|
|
589
|
+
* Agent -> Orchestrator: a step carrying `requireApproval` is about to run and
|
|
590
|
+
* the agent is blocking its step loop until the orchestrator resolves the
|
|
591
|
+
* approval. The orchestrator creates a step-scoped `held_runs` row from the
|
|
592
|
+
* normalized requirement and replies with `step.approval-resolved` once the
|
|
593
|
+
* hold is approved, rejected, or expired. The agent keeps heartbeats flowing
|
|
594
|
+
* during the wait so it is not reaped as stale.
|
|
595
|
+
*
|
|
596
|
+
* NOT fast-pathed — the `log.chunk` / `heartbeat` manual-validator invariant is
|
|
597
|
+
* untouched by this message.
|
|
598
|
+
*/
|
|
599
|
+
const stepApprovalRequestSchema = z.object({
|
|
600
|
+
type: z.literal("step.approval-request"),
|
|
601
|
+
messageId: z.string(),
|
|
602
|
+
runId: z.string(),
|
|
603
|
+
jobId: z.string(),
|
|
604
|
+
stepIndex: z.number().int().nonnegative(),
|
|
605
|
+
stepName: z.string(),
|
|
606
|
+
/** AND-list of approver clauses (empty = any approval-capable member). */
|
|
607
|
+
clauses: z.array(approverClauseSchema),
|
|
608
|
+
/** Human label for the gate (from the SDK `requireApproval` reason). */
|
|
609
|
+
reason: z.string(),
|
|
610
|
+
/**
|
|
611
|
+
* Per-gate timeout override (seconds) from the SDK `requireApproval.timeout`.
|
|
612
|
+
* Absent ⇒ the orchestrator uses the org-default `approval_expiry_seconds`.
|
|
613
|
+
* The orchestrator owns the authoritative `expiresAt` computation.
|
|
614
|
+
*/
|
|
615
|
+
timeoutSeconds: z.number().int().positive().optional()
|
|
616
|
+
});
|
|
617
|
+
/**
|
|
618
|
+
* Orchestrator -> Agent: resolution of a step-level approval hold. `requestId`
|
|
619
|
+
* correlates to the originating `step.approval-request.messageId`. On
|
|
620
|
+
* `approved` the agent runs the step with its live workspace intact; on
|
|
621
|
+
* `rejected`/`expired` it fails the job with a clear reason.
|
|
622
|
+
*/
|
|
623
|
+
const stepApprovalResolvedSchema = z.object({
|
|
624
|
+
type: z.literal("step.approval-resolved"),
|
|
625
|
+
/** Correlates to the originating step.approval-request messageId. */
|
|
626
|
+
requestId: z.string(),
|
|
627
|
+
runId: z.string(),
|
|
628
|
+
jobId: z.string(),
|
|
629
|
+
stepIndex: z.number().int().nonnegative(),
|
|
630
|
+
outcome: StepApprovalOutcome,
|
|
631
|
+
/** Optional human reason (e.g. the reject reason). */
|
|
632
|
+
reason: z.string().optional()
|
|
633
|
+
});
|
|
448
634
|
/** All messages that flow from Orchestrator to Agent. */
|
|
449
635
|
const orchestratorToAgentMessageSchema = z.discriminatedUnion("type", [
|
|
450
636
|
jobDispatchSchema,
|
|
@@ -452,16 +638,22 @@ const orchestratorToAgentMessageSchema = z.discriminatedUnion("type", [
|
|
|
452
638
|
registerAckSchema,
|
|
453
639
|
jobConcurrencyAckSchema,
|
|
454
640
|
cacheUploadResponseSchema,
|
|
641
|
+
cacheUserRestoreResponseSchema,
|
|
642
|
+
cacheUserSaveResponseSchema,
|
|
455
643
|
eventEmitResponseSchema,
|
|
456
644
|
agentApiResponseSchema,
|
|
457
645
|
agentAuthSuccessSchema,
|
|
458
|
-
agentAuthFailureSchema
|
|
646
|
+
agentAuthFailureSchema,
|
|
647
|
+
fleetLogsRequestSchema,
|
|
648
|
+
stepApprovalResolvedSchema
|
|
459
649
|
]);
|
|
460
650
|
/** All messages that flow from Agent to Orchestrator. */
|
|
461
651
|
const agentToOrchestratorMessageSchema = z.discriminatedUnion("type", [
|
|
462
652
|
agentRegisterSchema,
|
|
463
653
|
agentStatusSchema,
|
|
464
654
|
jobStatusSchema,
|
|
655
|
+
jobRejectSchema,
|
|
656
|
+
jobAckSchema,
|
|
465
657
|
agentLogChunkSchema,
|
|
466
658
|
agentStepStatusSchema,
|
|
467
659
|
jobHeartbeatSchema,
|
|
@@ -470,12 +662,18 @@ const agentToOrchestratorMessageSchema = z.discriminatedUnion("type", [
|
|
|
470
662
|
configAckSchema,
|
|
471
663
|
cacheUploadRequestSchema,
|
|
472
664
|
cacheUploadCompleteSchema,
|
|
665
|
+
cacheUserRestoreRequestSchema,
|
|
666
|
+
cacheUserSaveRequestSchema,
|
|
667
|
+
cacheUserSaveCompleteSchema,
|
|
473
668
|
eventEmitSchema,
|
|
474
669
|
agentApiRequestSchema,
|
|
475
670
|
agentMetricsSchema,
|
|
476
|
-
agentAuthRequestSchema
|
|
671
|
+
agentAuthRequestSchema,
|
|
672
|
+
fleetBundleChunkSchema,
|
|
673
|
+
fleetBundleErrorSchema,
|
|
674
|
+
stepApprovalRequestSchema
|
|
477
675
|
]);
|
|
478
676
|
//#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 };
|
|
677
|
+
export { CacheRefScope, JobRejectReason, StepApprovalOutcome, agentApiRequestSchema, agentApiResponseSchema, agentAuthFailureSchema, agentAuthRequestSchema, agentAuthSuccessSchema, agentLogChunkSchema, agentMetricsSchema, agentRegisterSchema, agentStatusSchema, agentStepStatusSchema, agentToOrchestratorMessageSchema, cacheUserRestoreRequestSchema, cacheUserRestoreResponseSchema, cacheUserSaveCompleteSchema, cacheUserSaveRequestSchema, cacheUserSaveResponseSchema, configAckSchema, eventEmitResponseSchema, eventEmitSchema, fleetBundleChunkSchema, fleetBundleErrorSchema, fleetLogsRequestSchema, gitAuthSchema, jobAckSchema, jobCancelSchema, jobConcurrencyAckSchema, jobConcurrencyReportSchema, jobDispatchSchema, jobRejectSchema, jobStatusSchema, orchestratorToAgentMessageSchema, registerAckSchema, stepApprovalRequestSchema, stepApprovalResolvedSchema };
|
|
480
678
|
|
|
481
679
|
//# sourceMappingURL=orchestrator-agent.js.map
|