@kici-dev/engine 0.1.22 → 0.1.24

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 (72) hide show
  1. package/dist/approval/types.d.ts +1 -1
  2. package/dist/audit/access-log-policy.d.ts +4 -1
  3. package/dist/audit/access-log-policy.js +11 -1
  4. package/dist/audit/activity.d.ts +3 -1
  5. package/dist/audit/activity.js +8 -16
  6. package/dist/audit/retention-policy.js +6 -0
  7. package/dist/environment/host-match.d.ts +25 -0
  8. package/dist/environment/host-match.js +67 -0
  9. package/dist/environment/index.d.ts +3 -0
  10. package/dist/environment/index.js +3 -1
  11. package/dist/environment/multi-env.d.ts +30 -0
  12. package/dist/environment/multi-env.js +38 -0
  13. package/dist/environment/scope-resolver.d.ts +15 -4
  14. package/dist/environment/scope-resolver.js +55 -15
  15. package/dist/environment/scope-template.d.ts +18 -0
  16. package/dist/environment/scope-template.js +43 -0
  17. package/dist/environment/types.d.ts +15 -2
  18. package/dist/environment/types.js +18 -1
  19. package/dist/fanout/materialize.d.ts +34 -0
  20. package/dist/fanout/materialize.js +72 -45
  21. package/dist/index.d.ts +5 -1
  22. package/dist/index.js +21 -10
  23. package/dist/inputs/build.d.ts +9 -0
  24. package/dist/inputs/build.js +44 -0
  25. package/dist/inputs/coerce.d.ts +25 -0
  26. package/dist/inputs/coerce.js +51 -0
  27. package/dist/inputs/descriptor.d.ts +53 -0
  28. package/dist/inputs/descriptor.js +42 -0
  29. package/dist/inputs/extract.d.ts +15 -0
  30. package/dist/inputs/extract.js +117 -0
  31. package/dist/inputs/index.d.ts +6 -0
  32. package/dist/inputs/index.js +7 -0
  33. package/dist/inputs/schedule.d.ts +19 -0
  34. package/dist/inputs/schedule.js +33 -0
  35. package/dist/labels/compile.d.ts +9 -0
  36. package/dist/labels/compile.js +10 -1
  37. package/dist/labels.d.ts +29 -0
  38. package/dist/labels.js +32 -1
  39. package/dist/mcp/tool-schemas.d.ts +41 -0
  40. package/dist/mcp/tool-schemas.js +49 -0
  41. package/dist/metrics/catalog-policy.d.ts +7 -0
  42. package/dist/metrics/catalog-policy.js +11 -12
  43. package/dist/metrics/metric-catalog.generated.d.ts +22 -2
  44. package/dist/metrics/metric-catalog.generated.js +34 -2
  45. package/dist/protocol/messages/access-log.d.ts +39 -10
  46. package/dist/protocol/messages/access-log.js +7 -2
  47. package/dist/protocol/messages/actor.d.ts +8 -0
  48. package/dist/protocol/messages/actor.js +17 -3
  49. package/dist/protocol/messages/agent-run-result.d.ts +350 -0
  50. package/dist/protocol/messages/agent-run-result.js +123 -0
  51. package/dist/protocol/messages/auth.d.ts +2 -0
  52. package/dist/protocol/messages/auth.js +10 -1
  53. package/dist/protocol/messages/capabilities.d.ts +2 -0
  54. package/dist/protocol/messages/capabilities.js +15 -2
  55. package/dist/protocol/messages/dashboard-global-workflows.d.ts +8 -0
  56. package/dist/protocol/messages/dashboard.d.ts +1513 -39
  57. package/dist/protocol/messages/dashboard.js +210 -15
  58. package/dist/protocol/messages/execution-status.d.ts +52 -1
  59. package/dist/protocol/messages/execution-status.js +115 -54
  60. package/dist/protocol/messages/orchestrator-agent.d.ts +21 -5
  61. package/dist/protocol/messages/orchestrator-agent.js +5 -1
  62. package/dist/protocol/messages/pat-kind.d.ts +16 -0
  63. package/dist/protocol/messages/pat-kind.js +17 -0
  64. package/dist/protocol/messages/peer.d.ts +7 -7
  65. package/dist/protocol/messages/platform-orchestrator.d.ts +424 -8
  66. package/dist/protocol/messages/platform-orchestrator.js +3 -3
  67. package/dist/protocol/messages/run-events.d.ts +5 -1
  68. package/dist/provider/check-run-conclusion.d.ts +1 -1
  69. package/dist/trigger/types.d.ts +75 -7
  70. package/dist/trigger/types.js +19 -2
  71. package/package.json +9 -1
  72. package/sbom.spdx.json +5 -5
@@ -1,11 +1,11 @@
1
1
  import "../../chunk-BTugEXQM.js";
2
2
  import { heartbeatSchema } from "./common.js";
3
- import { orchCapabilitiesSchema } from "./capabilities.js";
4
- import { authFailureSchema, authRequestSchema, authSuccessSchema } from "./auth.js";
5
3
  import { executionStatusSchema, jobStatusForwardSchema, stateReplaySchema, stepStatusForwardSchema } from "./execution-status.js";
6
- import { sourceDeregisterAckSchema, sourceDeregisterSchema, sourceRegistrationAckSchema, sourceRegistrationSchema } from "./source-registration.js";
7
4
  import { jobContextMessageSchema, runEventMessageSchema } from "./run-events.js";
5
+ import { sourceDeregisterAckSchema, sourceDeregisterSchema, sourceRegistrationAckSchema, sourceRegistrationSchema } from "./source-registration.js";
8
6
  import { dashboardPlatformToOrchSchema } from "./dashboard.js";
7
+ import { orchCapabilitiesSchema } from "./capabilities.js";
8
+ import { authFailureSchema, authRequestSchema, authSuccessSchema } from "./auth.js";
9
9
  import { z } from "zod";
10
10
  //#region src/protocol/messages/platform-orchestrator.ts
11
11
  /** Trust policy update pushed from Platform to orchestrator when policy or identity links change. */
@@ -14,9 +14,9 @@ export declare const runEventMessageSchema: z.ZodObject<{
14
14
  eventType: z.ZodString;
15
15
  timestampMs: z.ZodNumber;
16
16
  sourceService: z.ZodEnum<{
17
+ agent: "agent";
17
18
  platform: "platform";
18
19
  orchestrator: "orchestrator";
19
- agent: "agent";
20
20
  }>;
21
21
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
22
22
  traceId: z.ZodOptional<z.ZodString>;
@@ -125,6 +125,10 @@ export declare const dashboardOrchLogsRequestSchema: z.ZodObject<{
125
125
  actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
126
126
  type: z.ZodLiteral<"user">;
127
127
  sub: z.ZodString;
128
+ agent: z.ZodOptional<z.ZodObject<{
129
+ patId: z.ZodString;
130
+ label: z.ZodString;
131
+ }, z.core.$strip>>;
128
132
  }, z.core.$strip>, z.ZodObject<{
129
133
  type: z.ZodLiteral<"api_key">;
130
134
  keyId: z.ZodString;
@@ -8,8 +8,8 @@ import { z } from 'zod';
8
8
  export declare const CheckRunConclusion: z.ZodEnum<{
9
9
  success: "success";
10
10
  cancelled: "cancelled";
11
- failure: "failure";
12
11
  timed_out: "timed_out";
12
+ failure: "failure";
13
13
  }>;
14
14
  export type CheckRunConclusion = z.infer<typeof CheckRunConclusion>;
15
15
  //# sourceMappingURL=check-run-conclusion.d.ts.map
@@ -15,14 +15,20 @@
15
15
  * Schema version 18: adds LockJob.runsOnAll host fan-out predicate + onUnreachable policy.
16
16
  * Schema version 19: adds LockJob.maxParallel/failFast fan-out concurrency (rolling waves).
17
17
  * Schema version 20: runsOn/runsOnAll/excludeLabels carry LabelMatcher (exact|regex) for glob+regex selectors.
18
+ * Schema version 23: adds LockDispatchTrigger.inputs (typed dispatch inputs descriptors).
19
+ * Schema version 24: adds LockJob.runsOnPick (deterministic single-host selection).
20
+ * Schema version 25: adds LockStep.retry (step retry policy data subset; retryIf is execution-only).
21
+ * Schema version 26: adds LockJob.includeUninitialized (runsOnAll fans out to declared-but-un-agented hosts, bringing up a temporary init-runner per fresh box).
22
+ * Schema version 27: adds LockScheduleTrigger.inputs (defaults-only schedule dispatch inputs).
18
23
  */
19
24
  import { z } from 'zod';
20
25
  import type { ProviderType } from '../provider/types.js';
21
26
  import type { ApproverClause } from '../approval/types.js';
27
+ import type { InputsDescriptorMap } from '../inputs/descriptor.js';
22
28
  import { LabelMatcher } from '../labels-match.js';
23
29
  import { ExecutionJobStatus } from '../protocol/messages/execution-status.js';
24
30
  /** Schema version - increment on breaking changes */
25
- export declare const SCHEMA_VERSION: 22;
31
+ export declare const SCHEMA_VERSION: 29;
26
32
  /**
27
33
  * Normalized approval config carried in the lock file. Produced by the compiler
28
34
  * from an SDK `approval` at any of the three levels; consumed by the
@@ -139,6 +145,8 @@ export interface LockDispatchTrigger {
139
145
  readonly _type: 'dispatch';
140
146
  readonly types: readonly string[];
141
147
  readonly repos?: readonly LockBranchPattern[];
148
+ /** Typed dispatch-input descriptors (from `dispatch({ inputs })`). */
149
+ readonly inputs?: InputsDescriptorMap;
142
150
  }
143
151
  /**
144
152
  * Create trigger in lock file.
@@ -285,6 +293,8 @@ export interface LockScheduleTrigger {
285
293
  readonly cronExpression: string;
286
294
  readonly timezone: string;
287
295
  readonly description?: string;
296
+ /** Typed schedule-input descriptors (from `schedule({ inputs })`); defaults-only. */
297
+ readonly inputs?: InputsDescriptorMap;
288
298
  }
289
299
  /**
290
300
  * Lifecycle trigger in lock file.
@@ -329,12 +339,21 @@ export interface LockRule {
329
339
  * Minimal representation - agents load full step functions from source.
330
340
  */
331
341
  export interface LockStep {
342
+ /** Discriminator for the step union; absent/`'sequential'` is an ordinary step. */
343
+ readonly kind?: 'sequential';
332
344
  readonly name: string;
333
345
  readonly hasOutputs: boolean;
334
346
  /** When true, job proceeds even if this step fails. */
335
347
  readonly continueOnError?: boolean;
336
348
  /** Step-level timeout in milliseconds. */
337
349
  readonly timeout?: number;
350
+ /** Retry policy data (retryIf is execution-only and never serialized). */
351
+ readonly retry?: {
352
+ readonly maxAttempts: number;
353
+ readonly delayMs: number;
354
+ readonly backoff: 'fixed' | 'exponential';
355
+ readonly maxDelayMs: number;
356
+ };
338
357
  /** Source location of the step() call in the original TypeScript file (for annotations). */
339
358
  readonly sourceLocation?: {
340
359
  readonly file: string;
@@ -344,6 +363,24 @@ export interface LockStep {
344
363
  /** Normalized approval gate; when set the step pauses for a human approval. */
345
364
  readonly approval?: LockApproval;
346
365
  }
366
+ /**
367
+ * A concurrent group of sequential steps in the lock file. Children run
368
+ * concurrently behind a join barrier; the group wrapper itself consumes no
369
+ * flat step index (its children carry the indices). No nesting is allowed.
370
+ */
371
+ export interface LockParallelStep {
372
+ readonly kind: 'parallel';
373
+ readonly name: string;
374
+ /** Cancel in-flight siblings when the first child fails (default true). */
375
+ readonly failFast: boolean;
376
+ /** Maximum children running at once; queued children report `pending`. */
377
+ readonly maxParallel?: number;
378
+ readonly children: readonly LockStep[];
379
+ }
380
+ /** A lock-file entry in a job's `steps` array: an ordinary step or a parallel group. */
381
+ export type LockStepEntry = LockStep | LockParallelStep;
382
+ /** Type guard distinguishing a parallel group from an ordinary lock step. */
383
+ export declare function isLockParallelStep(entry: LockStepEntry): entry is LockParallelStep;
347
384
  /**
348
385
  * Inline expression value for pure dynamic functions.
349
386
  * The compiler serializes pure functions as { _type: 'inline', expression: '(event) => ...' }
@@ -469,17 +506,35 @@ export type RunsOnAllInput = string | RegExp | readonly (string | RegExp)[] | {
469
506
  * never return), independent of this policy.
470
507
  */
471
508
  export declare const OnUnreachableMode: z.ZodEnum<{
509
+ hold: "hold";
472
510
  skip: "skip";
473
511
  fail: "fail";
474
- hold: "hold";
475
512
  }>;
476
513
  export type OnUnreachableMode = z.infer<typeof OnUnreachableMode>;
514
+ /**
515
+ * Single-agent selection policy when multiple agents match a `runsOn` selector.
516
+ *
517
+ * - `deterministic` (default): sort matching candidates by `agentId` and pick the
518
+ * lowest, so a run-once-on-one-host job is reproducible across re-runs.
519
+ * - `any`: pick any available agent (load spread).
520
+ */
521
+ export declare const RunsOnPick: z.ZodEnum<{
522
+ any: "any";
523
+ deterministic: "deterministic";
524
+ }>;
525
+ export type RunsOnPick = z.infer<typeof RunsOnPick>;
477
526
  export interface LockJob {
478
527
  readonly _type: 'static';
479
528
  readonly name: string;
480
529
  /** Single-agent targeting matchers. Absent when the job uses `runsOnAll` instead. */
481
530
  readonly runsOn?: readonly LabelMatcher[];
482
531
  readonly excludeLabels?: readonly LabelMatcher[];
532
+ /**
533
+ * Single-agent selection policy when more than one agent matches `runsOn`.
534
+ * `deterministic` (default) sorts candidates by `agentId` and picks the lowest;
535
+ * `any` picks any available agent. Absent on a `runsOnAll` fan-out job.
536
+ */
537
+ readonly runsOnPick?: RunsOnPick;
483
538
  /**
484
539
  * Host fan-out predicate (mutually exclusive with `runsOn`). When set, the job
485
540
  * fans out to every roster host matching the predicate, one pinned child per host.
@@ -487,6 +542,14 @@ export interface LockJob {
487
542
  readonly runsOnAll?: RunsOnAllPredicate;
488
543
  /** Failure policy for unreachable durable hosts in a `runsOnAll` fan-out. */
489
544
  readonly onUnreachable?: OnUnreachableMode;
545
+ /**
546
+ * Widen a `runsOnAll` fan-out to declared-but-un-agented hosts. When true,
547
+ * every roster host matching the predicate is a fan-out target even with no
548
+ * live agent: a fresh host gets a temporary init-runner brought up over SSH
549
+ * and its pinned steps run there; a live host runs on its own agent. Default
550
+ * absent ⇒ only live hosts (today's behavior governed by `onUnreachable`).
551
+ */
552
+ readonly includeUninitialized?: boolean;
490
553
  /**
491
554
  * Fan-out concurrency width (sliding window; `1` = serial). When set on a
492
555
  * fan-out job (matrix or `runsOnAll`), only the first `maxParallel` children
@@ -498,16 +561,21 @@ export interface LockJob {
498
561
  readonly needs: readonly (string | NeedsEntry | NeedsGroupEntry)[];
499
562
  /** Group names this job depends on (populated by compiler from dynamicGroup refs). */
500
563
  readonly dependsOnGroups?: readonly string[];
501
- readonly steps: readonly LockStep[];
564
+ readonly steps: readonly LockStepEntry[];
502
565
  readonly matrix?: LockMatrix;
503
566
  readonly include?: readonly Record<string, string>[];
504
567
  readonly exclude?: readonly Record<string, string>[];
505
568
  readonly rules?: readonly LockRule[];
506
569
  readonly description?: string;
507
- /** Deployment environment name (static string) or inline expression (pure function). */
508
- readonly environment?: string | LockInlineValue;
509
- /** When true, environment is dynamic (function) -- resolved at orchestrator two-phase eval or inline. */
510
- readonly dynamicEnvironment?: boolean;
570
+ /**
571
+ * Deployment environments in merge order. Each entry is a static name or inline
572
+ * expression (pure function); `dynamic` is set when it is a function resolved at
573
+ * two-phase eval. Later entries override earlier ones on name collisions.
574
+ */
575
+ readonly environments?: ReadonlyArray<{
576
+ value: string | LockInlineValue;
577
+ dynamic: boolean;
578
+ }>;
511
579
  /** Static environment variables or inline expression (pure function). */
512
580
  readonly env?: Record<string, string> | LockInlineValue;
513
581
  /** When true, env is dynamic (function) -- resolved at orchestrator two-phase eval or inline. */
@@ -19,9 +19,18 @@ import { z } from "zod";
19
19
  * Schema version 18: adds LockJob.runsOnAll host fan-out predicate + onUnreachable policy.
20
20
  * Schema version 19: adds LockJob.maxParallel/failFast fan-out concurrency (rolling waves).
21
21
  * Schema version 20: runsOn/runsOnAll/excludeLabels carry LabelMatcher (exact|regex) for glob+regex selectors.
22
+ * Schema version 23: adds LockDispatchTrigger.inputs (typed dispatch inputs descriptors).
23
+ * Schema version 24: adds LockJob.runsOnPick (deterministic single-host selection).
24
+ * Schema version 25: adds LockStep.retry (step retry policy data subset; retryIf is execution-only).
25
+ * Schema version 26: adds LockJob.includeUninitialized (runsOnAll fans out to declared-but-un-agented hosts, bringing up a temporary init-runner per fresh box).
26
+ * Schema version 27: adds LockScheduleTrigger.inputs (defaults-only schedule dispatch inputs).
22
27
  */
23
28
  /** Schema version - increment on breaking changes */
24
- const SCHEMA_VERSION = 22;
29
+ const SCHEMA_VERSION = 29;
30
+ /** Type guard distinguishing a parallel group from an ordinary lock step. */
31
+ function isLockParallelStep(entry) {
32
+ return entry.kind === "parallel";
33
+ }
25
34
  /** Type guard for inline expression values */
26
35
  function isLockInlineValue(value) {
27
36
  return typeof value === "object" && value !== null && value._type === "inline";
@@ -94,6 +103,14 @@ const OnUnreachableMode = z.enum([
94
103
  "fail",
95
104
  "hold"
96
105
  ]);
106
+ /**
107
+ * Single-agent selection policy when multiple agents match a `runsOn` selector.
108
+ *
109
+ * - `deterministic` (default): sort matching candidates by `agentId` and pick the
110
+ * lowest, so a run-once-on-one-host job is reproducible across re-runs.
111
+ * - `any`: pick any available agent (load spread).
112
+ */
113
+ const RunsOnPick = z.enum(["deterministic", "any"]);
97
114
  /** Type guard for static jobs */
98
115
  function isLockStaticJob(job) {
99
116
  return job._type === "static";
@@ -103,6 +120,6 @@ function isLockDynamicJobFn(job) {
103
120
  return job._type === "dynamic";
104
121
  }
105
122
  //#endregion
106
- export { NeedsEntrySchema, NeedsGroupEntrySchema, NeedsRunOn, NeedsWhen, OnUnreachableMode, SCHEMA_VERSION, isLockDynamicJobFn, isLockInlineValue, isLockStaticJob, resolveWhenToRunOn };
123
+ export { NeedsEntrySchema, NeedsGroupEntrySchema, NeedsRunOn, NeedsWhen, OnUnreachableMode, RunsOnPick, SCHEMA_VERSION, isLockDynamicJobFn, isLockInlineValue, isLockParallelStep, isLockStaticJob, resolveWhenToRunOn };
107
124
 
108
125
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kici-dev/engine",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Shared business logic for the KiCI CI/CD stack: protocol, triggers, state machine, and provider interfaces used by the Platform relay, orchestrator, and compiler.",
5
5
  "keywords": [
6
6
  "ci",
@@ -53,6 +53,14 @@
53
53
  "import": "./dist/labels/compile.js",
54
54
  "types": "./dist/labels/compile.d.ts"
55
55
  },
56
+ "./environment/host-match": {
57
+ "import": "./dist/environment/host-match.js",
58
+ "types": "./dist/environment/host-match.d.ts"
59
+ },
60
+ "./environment/scope-template": {
61
+ "import": "./dist/environment/scope-template.js",
62
+ "types": "./dist/environment/scope-template.d.ts"
63
+ },
56
64
  "./protocol/dashboard-global-workflows": {
57
65
  "import": "./dist/protocol/dashboard-global-workflows.js",
58
66
  "types": "./dist/protocol/dashboard-global-workflows.d.ts"
package/sbom.spdx.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "spdxVersion": "SPDX-2.3",
3
3
  "dataLicense": "CC0-1.0",
4
4
  "SPDXID": "SPDXRef-DOCUMENT",
5
- "name": "@kici-dev/engine@0.1.22",
6
- "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fengine/0.1.22/5dc6919d-c8a2-40b2-aba3-44650ecac92f",
5
+ "name": "@kici-dev/engine@0.1.24",
6
+ "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fengine/0.1.24/915641e1-bf02-4cc8-a165-ac232d710e4f",
7
7
  "creationInfo": {
8
- "created": "2026-06-24T06:02:58Z",
8
+ "created": "2026-06-28T16:24:19Z",
9
9
  "creators": [
10
10
  "Tool: kici-sbom-generator"
11
11
  ]
@@ -54,7 +54,7 @@
54
54
  {
55
55
  "SPDXID": "SPDXRef-RootPackage",
56
56
  "name": "@kici-dev/engine",
57
- "versionInfo": "0.1.22",
57
+ "versionInfo": "0.1.24",
58
58
  "downloadLocation": "NOASSERTION",
59
59
  "filesAnalyzed": false,
60
60
  "licenseConcluded": "NOASSERTION",
@@ -65,7 +65,7 @@
65
65
  {
66
66
  "referenceCategory": "PACKAGE-MANAGER",
67
67
  "referenceType": "purl",
68
- "referenceLocator": "pkg:npm/%40kici-dev/engine@0.1.22"
68
+ "referenceLocator": "pkg:npm/%40kici-dev/engine@0.1.24"
69
69
  }
70
70
  ],
71
71
  "description": "Shared business logic for the KiCI CI/CD stack: protocol, triggers, state machine, and provider interfaces used by the Platform relay, orchestrator, and compiler.",