@kici-dev/engine 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/audit/access-log-policy.js +1 -0
  2. package/dist/audit/retention-policy.js +2 -0
  3. package/dist/context/held-run-job-id.d.ts +26 -10
  4. package/dist/context/held-run-job-id.js +30 -11
  5. package/dist/context/host-match.js +2 -1
  6. package/dist/context/index.d.ts +1 -1
  7. package/dist/context/index.js +3 -3
  8. package/dist/context/types.d.ts +10 -1
  9. package/dist/context/types.js +10 -1
  10. package/dist/index.d.ts +6 -2
  11. package/dist/index.js +17 -12
  12. package/dist/labels/compile.d.ts +2 -7
  13. package/dist/labels/compile.js +1 -10
  14. package/dist/labels.d.ts +74 -12
  15. package/dist/labels.js +82 -17
  16. package/dist/mcp/held-run-resolve.d.ts +40 -0
  17. package/dist/mcp/held-run-resolve.js +68 -15
  18. package/dist/mcp/tool-schemas.d.ts +4 -0
  19. package/dist/mcp/tool-schemas.js +13 -1
  20. package/dist/metrics/catalog-policy.d.ts +17 -3
  21. package/dist/metrics/catalog-policy.js +44 -13
  22. package/dist/metrics/metric-catalog.generated.d.ts +140 -0
  23. package/dist/metrics/metric-catalog.generated.js +168 -0
  24. package/dist/protocol/dashboard-global-workflows.js +2 -2
  25. package/dist/protocol/event-log-payload.js +1 -1
  26. package/dist/protocol/messages/access-log.d.ts +5 -0
  27. package/dist/protocol/messages/access-log.js +1 -0
  28. package/dist/protocol/messages/actor.d.ts +13 -2
  29. package/dist/protocol/messages/actor.js +16 -5
  30. package/dist/protocol/messages/common.js +1 -1
  31. package/dist/protocol/messages/dashboard-global-workflows.d.ts +29 -3
  32. package/dist/protocol/messages/dashboard-global-workflows.js +48 -4
  33. package/dist/protocol/messages/dashboard.d.ts +48 -7
  34. package/dist/protocol/messages/dashboard.js +62 -6
  35. package/dist/protocol/messages/execution-status.d.ts +44 -0
  36. package/dist/protocol/messages/execution-status.js +69 -2
  37. package/dist/protocol/messages/git-credential-relay.d.ts +78 -0
  38. package/dist/protocol/messages/git-credential-relay.js +86 -0
  39. package/dist/protocol/messages/orchestrator-agent.d.ts +138 -0
  40. package/dist/protocol/messages/orchestrator-agent.js +131 -3
  41. package/dist/protocol/messages/peer.d.ts +7 -0
  42. package/dist/protocol/messages/peer.js +18 -1
  43. package/dist/protocol/messages/platform-orchestrator.d.ts +155 -2
  44. package/dist/protocol/messages/platform-orchestrator.js +178 -19
  45. package/dist/protocol/version.d.ts +19 -2
  46. package/dist/protocol/version.js +20 -3
  47. package/dist/provenance/verify.js +11 -10
  48. package/dist/provider/check-status-poster.d.ts +37 -2
  49. package/dist/provider/contributor-resolver.d.ts +11 -3
  50. package/dist/provider/file-contents-fetcher.d.ts +39 -0
  51. package/dist/provider/file-contents-fetcher.js +2 -0
  52. package/dist/provider/git-credential.d.ts +77 -0
  53. package/dist/provider/git-credential.js +10 -0
  54. package/dist/provider/index.d.ts +4 -0
  55. package/dist/provider/index.js +2 -1
  56. package/dist/provider/webhook-normalizer.d.ts +12 -12
  57. package/dist/repo/pattern-negation.d.ts +73 -0
  58. package/dist/repo/pattern-negation.js +86 -0
  59. package/dist/safe-regex.d.ts +16 -0
  60. package/dist/safe-regex.js +24 -0
  61. package/dist/scaler/registry-auth.d.ts +18 -0
  62. package/dist/scaler/registry-auth.js +28 -0
  63. package/dist/scaler/scaler-backend-type.d.ts +35 -0
  64. package/dist/scaler/scaler-backend-type.js +39 -2
  65. package/dist/scaler/scaler-events.d.ts +79 -0
  66. package/dist/scaler/scaler-events.js +87 -0
  67. package/dist/trigger/compiled-matchers.d.ts +21 -1
  68. package/dist/trigger/compiled-matchers.js +30 -3
  69. package/dist/trigger/content-requirements.d.ts +31 -0
  70. package/dist/trigger/content-requirements.js +125 -0
  71. package/dist/trigger/decision-trace.d.ts +168 -0
  72. package/dist/trigger/decision-trace.js +207 -4
  73. package/dist/trigger/jsonpath-matcher.js +5 -1
  74. package/dist/trigger/matcher.js +61 -10
  75. package/dist/trigger/text-match.d.ts +27 -0
  76. package/dist/trigger/text-match.js +86 -0
  77. package/dist/trigger/types.d.ts +265 -23
  78. package/dist/trigger/types.js +37 -5
  79. package/dist/ws/rate-limiter.js +3 -3
  80. package/package.json +20 -3
  81. package/sbom.spdx.json +40 -15
@@ -58,6 +58,17 @@ const ExecutionJobStatus = z.enum([
58
58
  "unroutable"
59
59
  ]);
60
60
  /**
61
+ * Job kind on the wire. `standard` runs steps on an agent; `gate` is an invoke
62
+ * gate that summons source-repo runs instead of running steps; `proxy` mirrors
63
+ * one summoned run's lifecycle. The orchestrator's DB `JobKind` enum mirrors
64
+ * these members.
65
+ */
66
+ const JobKind = z.enum([
67
+ "standard",
68
+ "gate",
69
+ "proxy"
70
+ ]);
71
+ /**
61
72
  * The status values a notification subscription may target at the given level.
62
73
  *
63
74
  * A run-level subscription matches against an `ExecutionRunStatus`; a job-level
@@ -164,6 +175,27 @@ const RunFailureClass = z.enum([
164
175
  * dashboard can render it inline alongside the real steps.
165
176
  */
166
177
  const CacheStepType = z.enum(["cache:restore", "cache:save"]);
178
+ /**
179
+ * `step_type` values for pseudo-steps that run BEFORE a job's real steps.
180
+ *
181
+ * A run's step timeline is ordered by `step_index`, and every pseudo-step index
182
+ * sits ABOVE the real steps (the wire schema requires a non-negative index, and
183
+ * the in-sandbox allocators claim a high block). That is fine for the cache
184
+ * pseudo-steps, which mostly bracket the work — but a job's image build runs
185
+ * strictly first, and rendering it last reads as though it happened last.
186
+ *
187
+ * A reader therefore sorts these types ahead of everything else, by TYPE rather
188
+ * than by index. Keeping the ordering rule here — rather than as a negative
189
+ * index — is deliberate: `step.status` rejects a negative index outright, so an
190
+ * agent that sent one to an older orchestrator would have its connection closed
191
+ * mid-job, and two consumers (the check-run reporter's array write, the
192
+ * dashboard's `stepIndex >= 0` log gate) treat a negative index as absent.
193
+ */
194
+ const SetupStepType = z.enum(["container:build"]);
195
+ /** True when a `step_type` names a pseudo-step that ran before the real steps. */
196
+ function isSetupStepType(stepType) {
197
+ return stepType != null && SetupStepType.safeParse(stepType).success;
198
+ }
167
199
  /** `run.event` types emitted for user-facing cache operations. */
168
200
  const CacheRunEventType = z.enum(["cache.restore", "cache.save"]);
169
201
  /**
@@ -239,6 +271,26 @@ const executionStatusSchema = z.object({
239
271
  routingKey: z.string().max(128).optional(),
240
272
  repoIdentifier: z.string().max(256).optional(),
241
273
  /**
274
+ * The repository that DEFINES the workflow, when that is not
275
+ * `repoIdentifier` — a global workflow authored in one repository and
276
+ * dispatched against another. Absent for every per-repository run, where the
277
+ * two are the same repository, so "present" is a precise marker for a
278
+ * cross-repository global run. Optional for backward compatibility with an
279
+ * older orchestrator that never sends it.
280
+ */
281
+ workflowRepoIdentifier: z.string().max(256).optional(),
282
+ /**
283
+ * True when this run records a global evaluation round rather than a
284
+ * workflow.
285
+ *
286
+ * The Platform mirrors it so its own re-run refusal can admit a round: a
287
+ * round is definitionally cross-repository, and re-running one re-evaluates
288
+ * the original event instead of resolving a workflow out of the acted-on
289
+ * repository's lock file. Absent means an ordinary run — optional for
290
+ * backward compatibility with an orchestrator that never sends it.
291
+ */
292
+ isGlobalEvalRound: z.boolean().optional(),
293
+ /**
242
294
  * Run-level repo provider (origin host: `github` / `gitlab` / `bitbucket` /
243
295
  * `local`). Distinct from the routing-key-derived source provider; drives the
244
296
  * dashboard's provider-aware repo links.
@@ -342,7 +394,15 @@ const jobStatusForwardSchema = z.object({
342
394
  logBytes: z.number().int().nonnegative().optional(),
343
395
  timestamp: z.number(),
344
396
  /** Structured init-failure signal — set for synthetic rejected-* / init-failed-* jobs. */
345
- initFailure: initFailureSchema.optional()
397
+ initFailure: initFailureSchema.optional(),
398
+ /**
399
+ * Job kind. Absent means an ordinary `standard` job. `gate`/`proxy` mark an
400
+ * invoke gate and its per-run proxy children. Additive/optional — an older
401
+ * peer ignores it.
402
+ */
403
+ jobKind: JobKind.optional(),
404
+ /** For a `proxy` job, the summoned run it mirrors. Additive/optional. */
405
+ summonedRunId: z.string().max(128).optional()
346
406
  });
347
407
  /** State replay sent on orchestrator reconnection -- full snapshot of active runs and jobs. */
348
408
  /**
@@ -359,6 +419,13 @@ const stateReplayRunSchema = z.object({
359
419
  status: ExecutionRunStatus,
360
420
  routingKey: z.string().max(128).optional(),
361
421
  repoIdentifier: z.string().max(256).optional(),
422
+ /**
423
+ * The repository that DEFINES the workflow, when that is not
424
+ * `repoIdentifier`. Same meaning and same absent-for-per-repository-runs
425
+ * contract as on `execution.status`; carried here so a run that reaches the
426
+ * Platform only through the reconnect replay keeps its attribution.
427
+ */
428
+ workflowRepoIdentifier: z.string().max(256).optional(),
362
429
  sha: z.string().max(128).optional(),
363
430
  ref: z.string().max(128).optional(),
364
431
  triggerEvent: z.string().max(128).optional(),
@@ -395,6 +462,6 @@ const stateReplaySchema = z.object({
395
462
  timestamp: z.number()
396
463
  });
397
464
  //#endregion
398
- export { CONTEXTS_MAX, CacheOutcome, CacheRunEventType, CacheStepType, DEAD_ORCH_FAILURE_REASON, ExecutionJobStatus, ExecutionRunStatus, ExecutionStepStatus, InitFailureCategory, MAX_JOBS_PER_RUN, REPO_IDENTIFIER_MAX, RUNS_ON_LABELS_MAX, RunFailureClass, STATE_REPLAY_MAX_RUNS, STATUS_FREE_TEXT_MAX, STATUS_ID_MAX, StepConcurrencyKind, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, TERMINAL_STEP_STATES, TimeoutReason, executionStatusSchema, initFailureSchema, jobStatusForwardSchema, stateReplayRunSchema, stateReplaySchema, statusOptionsForLevel, stepStatusForwardSchema };
465
+ export { CONTEXTS_MAX, CacheOutcome, CacheRunEventType, CacheStepType, DEAD_ORCH_FAILURE_REASON, ExecutionJobStatus, ExecutionRunStatus, ExecutionStepStatus, InitFailureCategory, JobKind, MAX_JOBS_PER_RUN, REPO_IDENTIFIER_MAX, RUNS_ON_LABELS_MAX, RunFailureClass, STATE_REPLAY_MAX_RUNS, STATUS_FREE_TEXT_MAX, STATUS_ID_MAX, SetupStepType, StepConcurrencyKind, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, TERMINAL_STEP_STATES, TimeoutReason, executionStatusSchema, initFailureSchema, isSetupStepType, jobStatusForwardSchema, stateReplayRunSchema, stateReplaySchema, statusOptionsForLevel, stepStatusForwardSchema };
399
466
 
400
467
  //# sourceMappingURL=execution-status.js.map
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Agent → orchestrator relay for git credentials.
3
+ *
4
+ * The agent's credential helper calls this on every git network operation, so
5
+ * a token is always minted seconds before use — which is what defeats the
6
+ * one-hour GitHub App installation-token expiry for arbitrarily long jobs.
7
+ *
8
+ * Mirrors the browser-safe types in `provider/git-credential.ts`; this module
9
+ * is the validating half and is the only one that imports Zod.
10
+ */
11
+ import { z } from 'zod';
12
+ /** Method name on the agent private API registry. */
13
+ export declare const GIT_CREDENTIAL_REQUEST_METHOD = "git.credential.request";
14
+ export declare const gitCredentialRefSchema: z.ZodUnion<readonly [z.ZodIntersection<z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
15
+ kind: z.ZodLiteral<"app">;
16
+ }, z.core.$strip>, z.ZodObject<{
17
+ [x: string]: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>>, z.ZodObject<{
19
+ [x: string]: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>>, z.ZodObject<{
21
+ [x: string]: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
23
+ kind: z.ZodLiteral<"token">;
24
+ user: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strip>, z.ZodObject<{
26
+ [x: string]: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
28
+ kind: z.ZodLiteral<"ssh">;
29
+ }, z.core.$strip>, z.ZodObject<{
30
+ [x: string]: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strip>>]>;
32
+ export declare const gitCredentialRequestParamsSchema: z.ZodObject<{
33
+ jobId: z.ZodString;
34
+ repositories: z.ZodArray<z.ZodString>;
35
+ ref: z.ZodOptional<z.ZodUnion<readonly [z.ZodIntersection<z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
36
+ kind: z.ZodLiteral<"app">;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ [x: string]: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>>, z.ZodObject<{
40
+ [x: string]: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strip>>, z.ZodObject<{
42
+ [x: string]: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
44
+ kind: z.ZodLiteral<"token">;
45
+ user: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strip>, z.ZodObject<{
47
+ [x: string]: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
49
+ kind: z.ZodLiteral<"ssh">;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ [x: string]: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strip>>]>>;
53
+ permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
54
+ }, z.core.$strip>;
55
+ export type GitCredentialRequestParams = z.infer<typeof gitCredentialRequestParamsSchema>;
56
+ export declare const gitCredentialGrantSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
57
+ scoped: z.ZodLiteral<false>;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ scoped: z.ZodLiteral<true>;
60
+ permissions: z.ZodRecord<z.ZodString, z.ZodString>;
61
+ }, z.core.$strip>], "scoped">;
62
+ export declare const gitCredentialResultSchema: z.ZodObject<{
63
+ kind: z.ZodEnum<{
64
+ basic: "basic";
65
+ ssh: "ssh";
66
+ }>;
67
+ user: z.ZodOptional<z.ZodString>;
68
+ secret: z.ZodString;
69
+ grant: z.ZodDiscriminatedUnion<[z.ZodObject<{
70
+ scoped: z.ZodLiteral<false>;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ scoped: z.ZodLiteral<true>;
73
+ permissions: z.ZodRecord<z.ZodString, z.ZodString>;
74
+ }, z.core.$strip>], "scoped">;
75
+ expiresAt: z.ZodNullable<z.ZodString>;
76
+ }, z.core.$strip>;
77
+ export type GitCredentialRelayResult = z.infer<typeof gitCredentialResultSchema>;
78
+ //# sourceMappingURL=git-credential-relay.d.ts.map
@@ -0,0 +1,86 @@
1
+ import "../../rolldown-runtime-ClRpJifh.js";
2
+ import { z } from "zod";
3
+ //#region src/protocol/messages/git-credential-relay.ts
4
+ /**
5
+ * Agent → orchestrator relay for git credentials.
6
+ *
7
+ * The agent's credential helper calls this on every git network operation, so
8
+ * a token is always minted seconds before use — which is what defeats the
9
+ * one-hour GitHub App installation-token expiry for arbitrarily long jobs.
10
+ *
11
+ * Mirrors the browser-safe types in `provider/git-credential.ts`; this module
12
+ * is the validating half and is the only one that imports Zod.
13
+ */
14
+ /** Method name on the agent private API registry. */
15
+ const GIT_CREDENTIAL_REQUEST_METHOD = "git.credential.request";
16
+ /**
17
+ * A repository must be named explicitly — no wildcards, no "every repo in the
18
+ * installation". A write grant is therefore always a specific repository
19
+ * written down in the workflow source and reviewable in a diff.
20
+ */
21
+ const repositorySchema = z.string().min(1).max(512).refine((v) => !v.includes("*") && !v.includes("?"), { message: "repository must be explicit — wildcards are not accepted" });
22
+ /**
23
+ * Requested permissions.
24
+ *
25
+ * Deliberate carve-out from the enums-over-hardcoded-strings rule: GitHub adds
26
+ * permissions over time, and a closed enum would mean a permission GitHub
27
+ * shipped yesterday needs an SDK release before anyone can use it. Known keys
28
+ * are typed in the SDK for autocomplete; here they pass through verbatim for
29
+ * the forge itself to accept or reject.
30
+ */
31
+ const permissionsSchema = z.record(z.string().min(1), z.string().min(1));
32
+ /**
33
+ * Exactly one of `<name>Secret` / `<name>Value` per pair.
34
+ *
35
+ * `*Secret` is a qualified `<context>:<secret-name>` reference — the same form
36
+ * `packages/sdk/src/workflow.ts` validates with `isQualifiedSecretRef` — so the
37
+ * context travels with the reference and nothing has to infer a scope.
38
+ * `*Value` is material supplied at runtime.
39
+ */
40
+ function sourced(name) {
41
+ const qualified = z.string().min(1).refine((v) => {
42
+ const i = v.indexOf(":");
43
+ return i > 0 && i < v.length - 1 && !v.slice(i + 1).includes(":");
44
+ }, { message: `${name}Secret must be a qualified <context>:<secret-name> reference` }).refine((v) => !v.startsWith("-----BEGIN") && !/^gh[pousr]_/.test(v) && !v.startsWith("github_pat_"), { message: `${name}Secret looks like the credential itself, not the name of a secret holding it. Use ${name}Value if you genuinely have runtime material.` });
45
+ return z.object({
46
+ [`${name}Secret`]: qualified.optional(),
47
+ [`${name}Value`]: z.string().min(1).optional()
48
+ }).refine((o) => Boolean(o[`${name}Secret`]) !== Boolean(o[`${name}Value`]), { message: `exactly one of ${name}Secret or ${name}Value must be set` });
49
+ }
50
+ const gitCredentialRefSchema = z.union([
51
+ z.object({ kind: z.literal("app") }).and(sourced("appId")).and(sourced("installationId")).and(sourced("privateKey")),
52
+ z.object({
53
+ kind: z.literal("token"),
54
+ user: z.string().optional()
55
+ }).and(sourced("token")),
56
+ z.object({ kind: z.literal("ssh") }).and(sourced("privateKey"))
57
+ ]);
58
+ const gitCredentialRequestParamsSchema = z.object({
59
+ jobId: z.string().min(1),
60
+ /**
61
+ * Every repository the credential must cover, most-specific first.
62
+ *
63
+ * A list rather than one name because a GitHub App token is minted per
64
+ * installation and can name several repositories at once — which is the
65
+ * point of `getToken({ repositories })`. The credential helper, which is
66
+ * asked about one URL at a time, sends a one-element list.
67
+ */
68
+ repositories: z.array(repositorySchema).min(1),
69
+ ref: gitCredentialRefSchema.optional(),
70
+ permissions: permissionsSchema.optional()
71
+ });
72
+ const gitCredentialGrantSchema = z.discriminatedUnion("scoped", [z.object({ scoped: z.literal(false) }), z.object({
73
+ scoped: z.literal(true),
74
+ permissions: permissionsSchema
75
+ })]);
76
+ const gitCredentialResultSchema = z.object({
77
+ kind: z.enum(["basic", "ssh"]),
78
+ user: z.string().optional(),
79
+ secret: z.string(),
80
+ grant: gitCredentialGrantSchema,
81
+ expiresAt: z.string().nullable()
82
+ });
83
+ //#endregion
84
+ export { GIT_CREDENTIAL_REQUEST_METHOD, gitCredentialGrantSchema, gitCredentialRefSchema, gitCredentialRequestParamsSchema, gitCredentialResultSchema };
85
+
86
+ //# sourceMappingURL=git-credential-relay.js.map
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import type { LockJob } from '../../trigger/types.js';
2
3
  /**
3
4
  * Cache write scope for a job's user-facing cache.
4
5
  *
@@ -24,7 +25,17 @@ export type CacheRefScope = z.infer<typeof CacheRefScope>;
24
25
  * - `groups` maps a dynamic group name to its ordered member job names.
25
26
  * - `statuses` maps an upstream job name to its terminal status, so the
26
27
  * generator's `ctx.needs.<job>.status` reflects the frozen upstream outcome.
28
+ * - `invokeResults` maps an invoke-gate job name to its ordered per-run results,
29
+ * so the generator's `ctx.needs.<gate>.result` reflects each summoned run.
27
30
  */
31
+ export declare const invokeResultSchema: z.ZodObject<{
32
+ repo: z.ZodString;
33
+ workflow: z.ZodString;
34
+ runId: z.ZodString;
35
+ status: z.ZodString;
36
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
37
+ }, z.core.$strip>;
38
+ export type InvokeResult = z.infer<typeof invokeResultSchema>;
28
39
  export declare const upstreamSnapshotSchema: z.ZodObject<{
29
40
  jobs: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
30
41
  groups: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
@@ -42,6 +53,13 @@ export declare const upstreamSnapshotSchema: z.ZodObject<{
42
53
  timed_out_stale: "timed_out_stale";
43
54
  unroutable: "unroutable";
44
55
  }>>>;
56
+ invokeResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
57
+ repo: z.ZodString;
58
+ workflow: z.ZodString;
59
+ runId: z.ZodString;
60
+ status: z.ZodString;
61
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
62
+ }, z.core.$strip>>>>;
45
63
  }, z.core.$strip>;
46
64
  export type UpstreamSnapshot = z.infer<typeof upstreamSnapshotSchema>;
47
65
  /**
@@ -110,6 +128,13 @@ export declare const jobDispatchSchema: z.ZodObject<{
110
128
  timed_out_stale: "timed_out_stale";
111
129
  unroutable: "unroutable";
112
130
  }>>>;
131
+ upstreamInvokeResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
132
+ repo: z.ZodString;
133
+ workflow: z.ZodString;
134
+ runId: z.ZodString;
135
+ status: z.ZodString;
136
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
137
+ }, z.core.$strip>>>>;
113
138
  sourceAuth: z.ZodOptional<z.ZodObject<{
114
139
  kind: z.ZodEnum<{
115
140
  basic: "basic";
@@ -142,6 +167,11 @@ export declare const jobDispatchSchema: z.ZodObject<{
142
167
  alwaysAuth: z.ZodBoolean;
143
168
  token: z.ZodString;
144
169
  }, z.core.$strip>>>;
170
+ containerRegistryAuth: z.ZodOptional<z.ZodObject<{
171
+ username: z.ZodString;
172
+ password: z.ZodString;
173
+ serveraddress: z.ZodString;
174
+ }, z.core.$strip>>;
145
175
  installEnvSecrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
146
176
  orgId: z.ZodOptional<z.ZodString>;
147
177
  repoId: z.ZodOptional<z.ZodString>;
@@ -166,6 +196,7 @@ export declare const registerAckSchema: z.ZodObject<{
166
196
  labels: z.ZodArray<z.ZodString>;
167
197
  scalerManaged: z.ZodDefault<z.ZodBoolean>;
168
198
  pendingDispatch: z.ZodOptional<z.ZodBoolean>;
199
+ warmPool: z.ZodOptional<z.ZodBoolean>;
169
200
  capabilities: z.ZodOptional<z.ZodObject<{
170
201
  artifactCompleteAck: z.ZodOptional<z.ZodBoolean>;
171
202
  }, z.core.$loose>>;
@@ -232,6 +263,54 @@ export declare const jobStatusSchema: z.ZodObject<{
232
263
  encrypted: z.ZodString;
233
264
  }, z.core.$strip>>>;
234
265
  }, z.core.$strip>;
266
+ /**
267
+ * One candidate workflow's verdict from the pre-run global eval round — the
268
+ * job the agent runs once per (event × workflow repo) before any run row
269
+ * exists, evaluating each candidate's `filter` and then its `DynamicJobFn`s on
270
+ * a single dual checkout.
271
+ *
272
+ * `jobs` carries `LockJob[]` as an unvalidated pass-through, the same shape and
273
+ * for the same reason as `jobDispatchSchema.jobConfig`: the lock-file job shape
274
+ * has no Zod mirror anywhere in this package, its single source of truth is the
275
+ * `LockJob` interface in `trigger/types.ts`, and a hand-written Zod copy would
276
+ * drift and start rejecting legitimate generated jobs.
277
+ *
278
+ * Every field beyond the verdict itself is `.optional()` so an older peer
279
+ * tolerates the message unchanged.
280
+ */
281
+ export declare const globalEvalCandidateResultSchema: z.ZodObject<{
282
+ workflowName: z.ZodString;
283
+ run: z.ZodBoolean;
284
+ jobs: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
285
+ indeterminate: z.ZodOptional<z.ZodBoolean>;
286
+ reason: z.ZodOptional<z.ZodString>;
287
+ }, z.core.$strip>;
288
+ /** Every candidate's verdict from one global eval round, in candidate order. */
289
+ export declare const globalEvalRoundResultSchema: z.ZodObject<{
290
+ candidates: z.ZodArray<z.ZodObject<{
291
+ workflowName: z.ZodString;
292
+ run: z.ZodBoolean;
293
+ jobs: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
294
+ indeterminate: z.ZodOptional<z.ZodBoolean>;
295
+ reason: z.ZodOptional<z.ZodString>;
296
+ }, z.core.$strip>>;
297
+ }, z.core.$strip>;
298
+ /**
299
+ * Typed view of {@link globalEvalCandidateResultSchema}. Declared rather than
300
+ * inferred so `jobs` is the real `LockJob[]` on both sides of the wire; the Zod
301
+ * schema stays the loose validator (see its doc comment).
302
+ */
303
+ export interface GlobalEvalCandidateResult {
304
+ workflowName: string;
305
+ run: boolean;
306
+ jobs?: LockJob[];
307
+ indeterminate?: boolean;
308
+ reason?: string;
309
+ }
310
+ /** Typed view of {@link globalEvalRoundResultSchema}. */
311
+ export interface GlobalEvalRoundResult {
312
+ candidates: GlobalEvalCandidateResult[];
313
+ }
235
314
  /** Reasons an agent can refuse a job.dispatch. */
236
315
  export declare const JobRejectReason: z.ZodEnum<{
237
316
  busy: "busy";
@@ -597,6 +676,35 @@ export declare const eventEmitResponseSchema: z.ZodObject<{
597
676
  deliveryId: z.ZodOptional<z.ZodString>;
598
677
  error: z.ZodOptional<z.ZodString>;
599
678
  }, z.core.$strip>;
679
+ /**
680
+ * Agent -> Orchestrator: exchanges a single-use claim code (delivered on a
681
+ * `kici.scaler.scale-up` event) for freshly minted ephemeral agent credentials.
682
+ * A provisioned agent normally sends this itself to self-bootstrap — the claim
683
+ * code is the authorization, so it may send it before it authenticates or
684
+ * registers. A provisioning workflow can also send it to obtain the token
685
+ * directly. Additive/negotiated by presence — older peers that never emit it
686
+ * are unaffected, so it needs no `PROTOCOL_VERSION` bump of its own.
687
+ */
688
+ export declare const scalerClaimCredentialsSchema: z.ZodObject<{
689
+ type: z.ZodLiteral<"scaler.claim-credentials">;
690
+ requestId: z.ZodString;
691
+ claimCode: z.ZodString;
692
+ }, z.core.$strip>;
693
+ /**
694
+ * Orchestrator -> Agent: minted ephemeral credentials for a claimed provision,
695
+ * or an error. The token appears only here — never in the persisted event log.
696
+ */
697
+ export declare const scalerClaimCredentialsResponseSchema: z.ZodObject<{
698
+ type: z.ZodLiteral<"scaler.claim-credentials.response">;
699
+ requestId: z.ZodString;
700
+ credentials: z.ZodOptional<z.ZodObject<{
701
+ agentToken: z.ZodString;
702
+ agentId: z.ZodString;
703
+ orchestratorUrl: z.ZodString;
704
+ labels: z.ZodArray<z.ZodString>;
705
+ }, z.core.$strip>>;
706
+ error: z.ZodOptional<z.ZodString>;
707
+ }, z.core.$strip>;
600
708
  /** Periodic metrics push from agent to orchestrator. */
601
709
  export declare const agentMetricsSchema: z.ZodObject<{
602
710
  type: z.ZodLiteral<"agent.metrics">;
@@ -781,6 +889,13 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
781
889
  timed_out_stale: "timed_out_stale";
782
890
  unroutable: "unroutable";
783
891
  }>>>;
892
+ upstreamInvokeResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
893
+ repo: z.ZodString;
894
+ workflow: z.ZodString;
895
+ runId: z.ZodString;
896
+ status: z.ZodString;
897
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
898
+ }, z.core.$strip>>>>;
784
899
  sourceAuth: z.ZodOptional<z.ZodObject<{
785
900
  kind: z.ZodEnum<{
786
901
  basic: "basic";
@@ -813,6 +928,11 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
813
928
  alwaysAuth: z.ZodBoolean;
814
929
  token: z.ZodString;
815
930
  }, z.core.$strip>>>;
931
+ containerRegistryAuth: z.ZodOptional<z.ZodObject<{
932
+ username: z.ZodString;
933
+ password: z.ZodString;
934
+ serveraddress: z.ZodString;
935
+ }, z.core.$strip>>;
816
936
  installEnvSecrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
817
937
  orgId: z.ZodOptional<z.ZodString>;
818
938
  repoId: z.ZodOptional<z.ZodString>;
@@ -833,6 +953,7 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
833
953
  labels: z.ZodArray<z.ZodString>;
834
954
  scalerManaged: z.ZodDefault<z.ZodBoolean>;
835
955
  pendingDispatch: z.ZodOptional<z.ZodBoolean>;
956
+ warmPool: z.ZodOptional<z.ZodBoolean>;
836
957
  capabilities: z.ZodOptional<z.ZodObject<{
837
958
  artifactCompleteAck: z.ZodOptional<z.ZodBoolean>;
838
959
  }, z.core.$loose>>;
@@ -907,6 +1028,16 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
907
1028
  requestId: z.ZodString;
908
1029
  deliveryId: z.ZodOptional<z.ZodString>;
909
1030
  error: z.ZodOptional<z.ZodString>;
1031
+ }, z.core.$strip>, z.ZodObject<{
1032
+ type: z.ZodLiteral<"scaler.claim-credentials.response">;
1033
+ requestId: z.ZodString;
1034
+ credentials: z.ZodOptional<z.ZodObject<{
1035
+ agentToken: z.ZodString;
1036
+ agentId: z.ZodString;
1037
+ orchestratorUrl: z.ZodString;
1038
+ labels: z.ZodArray<z.ZodString>;
1039
+ }, z.core.$strip>>;
1040
+ error: z.ZodOptional<z.ZodString>;
910
1041
  }, z.core.$strip>, z.ZodObject<{
911
1042
  type: z.ZodLiteral<"agent.api.response">;
912
1043
  requestId: z.ZodString;
@@ -1088,6 +1219,7 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
1088
1219
  lockfileHash: z.ZodOptional<z.ZodString>;
1089
1220
  platform: z.ZodString;
1090
1221
  arch: z.ZodString;
1222
+ depsHash: z.ZodOptional<z.ZodString>;
1091
1223
  }, z.core.$strip>, z.ZodObject<{
1092
1224
  type: z.ZodLiteral<"cache.upload.complete">;
1093
1225
  messageId: z.ZodString;
@@ -1177,6 +1309,10 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
1177
1309
  target: z.ZodOptional<z.ZodObject<{
1178
1310
  repos: z.ZodOptional<z.ZodArray<z.ZodString>>;
1179
1311
  }, z.core.$strip>>;
1312
+ }, z.core.$strip>, z.ZodObject<{
1313
+ type: z.ZodLiteral<"scaler.claim-credentials">;
1314
+ requestId: z.ZodString;
1315
+ claimCode: z.ZodString;
1180
1316
  }, z.core.$strip>, z.ZodObject<{
1181
1317
  type: z.ZodLiteral<"agent.api.request">;
1182
1318
  requestId: z.ZodString;
@@ -1263,6 +1399,8 @@ export type ArtifactsDownloadResponse = z.infer<typeof artifactsDownloadResponse
1263
1399
  export type FleetLogsRequest = z.infer<typeof fleetLogsRequestSchema>;
1264
1400
  export type FleetBundleChunk = z.infer<typeof fleetBundleChunkSchema>;
1265
1401
  export type FleetBundleError = z.infer<typeof fleetBundleErrorSchema>;
1402
+ export type ScalerClaimCredentials = z.infer<typeof scalerClaimCredentialsSchema>;
1403
+ export type ScalerClaimCredentialsResponse = z.infer<typeof scalerClaimCredentialsResponseSchema>;
1266
1404
  export type OrchestratorToAgentMessage = z.infer<typeof orchestratorToAgentMessageSchema>;
1267
1405
  export type AgentToOrchestratorMessage = z.infer<typeof agentToOrchestratorMessageSchema>;
1268
1406
  //# sourceMappingURL=orchestrator-agent.d.ts.map