@kici-dev/sdk 0.1.22 → 0.1.23

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.
@@ -74,6 +74,40 @@ export interface HostApi {
74
74
  deadlineMs?: number;
75
75
  }): Promise<void>;
76
76
  }
77
+ export interface BootstrapApi {
78
+ /**
79
+ * Bring up a temporary privileged init-runner on a declared-but-un-agented
80
+ * host over SSH, so it auto-enrolls as a short-lived `kici:init` agent. The
81
+ * step calling this must run on an agent holding the
82
+ * `kici:capability:ssh-transport` capability (the orchestrator refuses
83
+ * otherwise). No-op (`broughtUp: false`) when the target already has a live
84
+ * agent. Each bring-up is access-logged.
85
+ *
86
+ * The target's reach metadata + the bring-up SSH key (a scoped secret) are
87
+ * resolved server-side from the host roster — the workflow author supplies
88
+ * only the target agent id.
89
+ */
90
+ ensureInitRunner(targetAgentId: string): Promise<{
91
+ broughtUp: boolean;
92
+ }>;
93
+ /**
94
+ * Ship an input to a host's pre-boot SSH channel (e.g. a LUKS passphrase to
95
+ * a dropbear/initramfs `cryptroot-unlock` prompt on port 2222). Generic
96
+ * "pipe stdin to a forced-command endpoint"; the unlock recipe is
97
+ * per-host-passphrase → `preBootSend` → `waitForHostAlive`. Same
98
+ * `kici:capability:ssh-transport` gate + access-log as `ensureInitRunner`.
99
+ *
100
+ * `inputSecret` is a scoped-secret ref (`scope/key`) the orchestrator
101
+ * resolves server-side; the plaintext never passes through the workflow.
102
+ * Success is the send completing (the session drops as the box boots) —
103
+ * compose `restartHost`/host-alive waits to confirm the boot.
104
+ */
105
+ preBootSend(targetAgentId: string, opts: {
106
+ inputSecret: string;
107
+ port?: number;
108
+ command?: string;
109
+ }): Promise<void>;
110
+ }
77
111
  export interface KiciApi {
78
112
  /** Query orchestrator infrastructure (scalers, agents). */
79
113
  infrastructure: InfrastructureApi;
@@ -83,6 +117,8 @@ export interface KiciApi {
83
117
  oidc: OidcApi;
84
118
  /** Host-lifecycle operations on the agent's own host (e.g. reboot). */
85
119
  host: HostApi;
120
+ /** Fresh-box bootstrap bring-up (init-runner over SSH, pre-boot unlock). */
121
+ bootstrap: BootstrapApi;
86
122
  }
87
123
  /**
88
124
  * Low-level transport function used to implement KiciApi.
package/dist/api-types.js CHANGED
@@ -37,7 +37,14 @@ function buildKiciApi(transport, jobCtx) {
37
37
  audience: opts.audience
38
38
  });
39
39
  } },
40
- host: { requestReboot: (opts) => transport("host.requestReboot", { ...opts?.deadlineMs !== void 0 ? { deadlineMs: opts.deadlineMs } : {} }) }
40
+ host: { requestReboot: (opts) => transport("host.requestReboot", { ...opts?.deadlineMs !== void 0 ? { deadlineMs: opts.deadlineMs } : {} }) },
41
+ bootstrap: {
42
+ ensureInitRunner: (targetAgentId) => transport("kici.ensureInitRunner", { targetAgentId }),
43
+ preBootSend: (targetAgentId, opts) => transport("kici.preBootSend", {
44
+ targetAgentId,
45
+ ...opts
46
+ })
47
+ }
41
48
  };
42
49
  }
43
50
  //#endregion
package/dist/context.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { MatrixValues } from './matrix/types.js';
3
3
  import type { EventEmitOptions } from './events/types.js';
4
4
  import type { StepSecrets } from './secrets.js';
5
5
  import type { KiciApi } from './api-types.js';
6
+ import type { FanoutPosition } from './fanout-context.js';
6
7
  /** Logger interface for step execution */
7
8
  export interface Logger {
8
9
  info(message: string, ...args: unknown[]): void;
@@ -115,6 +116,12 @@ export interface StepContext<TInputs = Record<string, unknown>> {
115
116
  addPath(dir: string): void;
116
117
  /** Typed inputs from dependencies */
117
118
  inputs: TInputs;
119
+ /**
120
+ * Operator-supplied, validated + coerced workflow-dispatch inputs (from `dispatch({ inputs })`).
121
+ * Distinct from `inputs` (typed outputs from `needs` dependencies). Empty when none declared.
122
+ * Prefer the typed `defineDispatchInputs(...).from(ctx)` accessor for per-key types.
123
+ */
124
+ dispatchInputs: Readonly<Record<string, string | number | boolean | null>>;
118
125
  /** Current workflow metadata */
119
126
  workflow: WorkflowInfo;
120
127
  /** Current job metadata */
@@ -137,6 +144,12 @@ export interface StepContext<TInputs = Record<string, unknown>> {
137
144
  * platform, arch). Set only for jobs that use `runsOnAll`. Undefined otherwise.
138
145
  */
139
146
  agent?: AgentInfo;
147
+ /**
148
+ * Position of this child within its fan-out (a `runsOnAll` host or a matrix
149
+ * combination), deterministically ordered (host: by `agentId`; matrix: by
150
+ * variant label). Undefined on a non-fan-out job.
151
+ */
152
+ fanout?: FanoutPosition;
140
153
  /**
141
154
  * Raw webhook payload from the git provider.
142
155
  * Contains the full, unmodified payload as received from the webhook.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Deterministic position of a fan-out child within its fan-out.
3
+ *
4
+ * A fan-out child is one of:
5
+ * - a `runsOnAll` host execution (one pinned execution per matching roster host), or
6
+ * - a matrix combination (one execution per expanded combination).
7
+ *
8
+ * The order is deterministic: host fan-out is sorted by `agentId`, matrix fan-out by
9
+ * its variant label, so `first` is always reproducible across re-runs.
10
+ */
11
+ export interface FanoutPosition {
12
+ /** 0-based position in the deterministically-ordered fan-out. */
13
+ index: number;
14
+ /** Number of children in this fan-out. */
15
+ total: number;
16
+ /** Whether this is the first child (`index === 0`). */
17
+ first: boolean;
18
+ /** Whether this is the last child (`index === total - 1`). */
19
+ last: boolean;
20
+ }
21
+ //# sourceMappingURL=fanout-context.d.ts.map
@@ -0,0 +1,2 @@
1
+ import "./chunk-BTugEXQM.js";
2
+ export {};
@@ -21,7 +21,8 @@
21
21
  * whose run function executes `idempotent(...)` and propagates ctx.log
22
22
  * into the runner's status sink.
23
23
  */
24
- import type { Step } from './types.js';
24
+ import type { Step, StepOptionsBase } from './types.js';
25
+ import type { StepContext } from './context.js';
25
26
  export interface IdempotentOptions<TDrift, TInSync = void, TApplied = void> {
26
27
  /** Optional name surfaced in status lines and error messages. */
27
28
  name?: string;
@@ -68,4 +69,34 @@ export declare function idempotent<TDrift, TInSync = void, TApplied = void>(opts
68
69
  * The step's typed return value is the IdempotentResult union.
69
70
  */
70
71
  export declare function idempotentStep<TDrift, TInSync = void, TApplied = void>(name: string, opts: Omit<IdempotentOptions<TDrift, TInSync, TApplied>, 'name' | 'log'>): Step<IdempotentResult<TDrift, TInSync, TApplied>>;
72
+ /**
73
+ * Options for {@link checkStep}. The same shape as `idempotentStep`'s options,
74
+ * except `apply` and `whenInSync` receive `ctx` first (matching the `step()`
75
+ * check facet's `run(ctx, drift)` form) so the apply logic has access to
76
+ * `ctx.$` / `ctx.log` / `ctx.secrets`. The remaining `StepOptionsBase`
77
+ * passthroughs (`continueOnError`, `timeout`, `rules`, `outputs`, `retry`, …)
78
+ * are forwarded to the underlying step.
79
+ */
80
+ export interface CheckStepOptions<TDrift, TInSync = void, TApplied = void> extends Omit<StepOptionsBase, 'onCancel' | 'cleanup' | 'approval'> {
81
+ /** Read-only inspection: drift if apply would change state, or null if in sync. */
82
+ check: (ctx: StepContext) => Promise<TDrift | null>;
83
+ /** Brings the system to the desired state. Runs only in apply mode (skipped under `kici run --check`). */
84
+ apply: (ctx: StepContext, drift: TDrift) => Promise<TApplied>;
85
+ /** Required: human-readable summary of what apply() would do; shown in check-mode drift output. */
86
+ summarize: (drift: TDrift) => string;
87
+ /** Runs when check() returns null (already in sync). */
88
+ whenInSync?: (ctx: StepContext) => Promise<TInSync>;
89
+ }
90
+ /**
91
+ * Factory returning a check-facet SDK Step — the check-mode-aware sibling of
92
+ * {@link idempotentStep}. Unlike `idempotentStep` (which always applies on
93
+ * drift), a `checkStep` respects the run-level check mode: `kici run --check`
94
+ * reports the drift and skips `apply`, while apply mode applies it.
95
+ *
96
+ * It desugars to the `step()` check facet
97
+ * (`run: (ctx, drift) => apply(ctx, drift)`), so it inherits the agent
98
+ * step-loop and local-executor check-mode drive for free — no engine, agent,
99
+ * orchestrator, or lockfile change.
100
+ */
101
+ export declare function checkStep<TDrift, TInSync = void, TApplied = void>(name: string, options: CheckStepOptions<TDrift, TInSync, TApplied>): Step<TApplied | TInSync>;
71
102
  //# sourceMappingURL=idempotent.d.ts.map
@@ -71,7 +71,32 @@ function idempotentStep(name, opts) {
71
71
  log: (line) => ctx.log.info(line)
72
72
  }) });
73
73
  }
74
+ /**
75
+ * Factory returning a check-facet SDK Step — the check-mode-aware sibling of
76
+ * {@link idempotentStep}. Unlike `idempotentStep` (which always applies on
77
+ * drift), a `checkStep` respects the run-level check mode: `kici run --check`
78
+ * reports the drift and skips `apply`, while apply mode applies it.
79
+ *
80
+ * It desugars to the `step()` check facet
81
+ * (`run: (ctx, drift) => apply(ctx, drift)`), so it inherits the agent
82
+ * step-loop and local-executor check-mode drive for free — no engine, agent,
83
+ * orchestrator, or lockfile change.
84
+ */
85
+ function checkStep(name, options) {
86
+ return step(name, {
87
+ check: options.check,
88
+ summarize: options.summarize,
89
+ run: (ctx, drift) => options.apply(ctx, drift),
90
+ ...options.whenInSync && { whenInSync: options.whenInSync },
91
+ ...options.outputs !== void 0 && { outputs: options.outputs },
92
+ ...options.continueOnError !== void 0 && { continueOnError: options.continueOnError },
93
+ ...options.timeout !== void 0 && { timeout: options.timeout },
94
+ ...options.retry !== void 0 && { retry: options.retry },
95
+ ...options.cache !== void 0 && { cache: options.cache },
96
+ ...options.rules !== void 0 && { rules: options.rules }
97
+ });
98
+ }
74
99
  //#endregion
75
- export { idempotent, idempotentStep };
100
+ export { checkStep, idempotent, idempotentStep };
76
101
 
77
102
  //# sourceMappingURL=idempotent.js.map
package/dist/index.d.ts CHANGED
@@ -3,17 +3,17 @@ export { job } from './job.js';
3
3
  export { workflow } from './workflow.js';
4
4
  export { normalizeApproval } from './approval.js';
5
5
  export type { ApprovalConfig, ApprovalWhen, ApproverClause, NormalizedApproval, } from './approval.js';
6
- export { pr, push, tag, comment, review, reviewComment, release, dispatch, create, delete as delete, status, workflowRun, fork, star, watch, webhook, kiciEvent, workflowComplete, jobComplete, genericWebhook, schedule, lifecycle, } from './triggers/index.js';
7
- export type { TriggerConfig, PrTriggerConfig, PushTriggerConfig, TagTriggerConfig, CommentTriggerConfig, ReviewTriggerConfig, ReviewCommentTriggerConfig, ReleaseTriggerConfig, DispatchTriggerConfig, CreateTriggerConfig, DeleteTriggerConfig, StatusTriggerConfig, WorkflowRunTriggerConfig, ForkTriggerConfig, StarTriggerConfig, WatchTriggerConfig, WebhookTriggerConfig, BranchPattern, BodyMatchPattern, PrEvent, PushEvent, PrConfigInput, PushConfigInput, TagConfigInput, CommentConfigInput, CommentAction, CommentSource, ReviewConfigInput, ReviewAction, ReviewState, ReviewCommentConfigInput, ReviewCommentAction, ReleaseConfigInput, ReleaseAction, DispatchConfigInput, CreateConfigInput, DeleteConfigInput, RefType, StatusConfigInput, StatusState, WorkflowRunConfigInput, WorkflowRunAction, ForkConfigInput, StarConfigInput, StarAction, WatchConfigInput, WatchAction, WebhookConfigInput, KiciEventConfigInput, KiciEventTriggerConfig, WorkflowCompleteConfigInput, WorkflowCompleteTriggerConfig, WorkflowCompleteStatus, JobCompleteConfigInput, JobCompleteTriggerConfig, JobCompleteStatus, GenericWebhookConfigInput, GenericWebhookTriggerConfig, GenericWebhookAuthMethod, GenericWebhookHmacAuth, GenericWebhookApiKeyAuth, GenericWebhookAuth, ScheduleConfigInput, ScheduleTriggerConfig, LifecycleEvent, LifecycleConfigInput, LifecycleTriggerConfig, } from './triggers/index.js';
6
+ export { pr, push, tag, comment, review, reviewComment, release, dispatch, create, delete as delete, status, workflowRun, fork, star, watch, webhook, kiciEvent, workflowComplete, jobComplete, genericWebhook, schedule, lifecycle, defineDispatchInputs, } from './triggers/index.js';
7
+ export type { DefinedDispatchInputs, InferDispatchInputs, DispatchInputsMap, TriggerConfig, PrTriggerConfig, PushTriggerConfig, TagTriggerConfig, CommentTriggerConfig, ReviewTriggerConfig, ReviewCommentTriggerConfig, ReleaseTriggerConfig, DispatchTriggerConfig, CreateTriggerConfig, DeleteTriggerConfig, StatusTriggerConfig, WorkflowRunTriggerConfig, ForkTriggerConfig, StarTriggerConfig, WatchTriggerConfig, WebhookTriggerConfig, BranchPattern, BodyMatchPattern, PrEvent, PushEvent, PrConfigInput, PushConfigInput, TagConfigInput, CommentConfigInput, CommentAction, CommentSource, ReviewConfigInput, ReviewAction, ReviewState, ReviewCommentConfigInput, ReviewCommentAction, ReleaseConfigInput, ReleaseAction, DispatchConfigInput, CreateConfigInput, DeleteConfigInput, RefType, StatusConfigInput, StatusState, WorkflowRunConfigInput, WorkflowRunAction, ForkConfigInput, StarConfigInput, StarAction, WatchConfigInput, WatchAction, WebhookConfigInput, KiciEventConfigInput, KiciEventTriggerConfig, WorkflowCompleteConfigInput, WorkflowCompleteTriggerConfig, WorkflowCompleteStatus, JobCompleteConfigInput, JobCompleteTriggerConfig, JobCompleteStatus, GenericWebhookConfigInput, GenericWebhookTriggerConfig, GenericWebhookAuthMethod, GenericWebhookHmacAuth, GenericWebhookApiKeyAuth, GenericWebhookAuth, ScheduleConfigInput, ScheduleTriggerConfig, LifecycleEvent, LifecycleConfigInput, LifecycleTriggerConfig, } from './triggers/index.js';
8
8
  export { onCancel, cleanup, onSuccess, onFailure, beforeStep, afterStep } from './hooks/index.js';
9
9
  export type { HookConfig, HookFn, HookInput, HookContext, OutcomeMetadata } from './hooks/index.js';
10
- export { rule, skip } from './rules/index.js';
10
+ export { rule, skip, onlyOnFirstHost, onlyOnLastHost, onlyOnFanoutIndex } from './rules/index.js';
11
11
  export { evaluateRules } from './rules/index.js';
12
12
  export { isEventType } from './rules/index.js';
13
13
  export type { Rule, RuleContext, RuleCheckFn, RuleResult, EventPayload, RuleEvaluationResult, EventBase, PullRequestEventPayload, PushEventPayload, TagEventPayload, CommentEventPayload, ReviewEventPayload, ReviewCommentEventPayload, ReleaseEventPayload, DispatchEventPayload, CreateEventPayload, DeleteEventPayload, StatusEventPayload, WorkflowRunEventPayload, ForkEventPayload, StarEventPayload, WatchEventPayload, WebhookEventPayload, KiciEventPayload, WorkflowCompleteEventPayload, JobCompleteEventPayload, GenericWebhookEventPayload, ScheduleEventPayload, LifecycleEventPayload, GitHubRepository, GitHubUser, GitHubPullRequest, GitHubCommit, GitHubComment, GitHubReview, GitHubRelease, } from './rules/index.js';
14
14
  export { validateDag } from './validation/index.js';
15
15
  export type { DagNode, DagValidationResult } from './validation/index.js';
16
- export type { SourceLocation, OutputProxy, Step, StepOptions, StepOptionsBase, StepOptionsPlain, StepOptionsWithCheck, StepRunFn, BareStepFn, StepInput, OutputSchema, InferOutputs, Job, JobOptions, GenericInitConfig, MiseInitConfig, InitPreset, InitItem, InitConfig, ContainerConfig, RunsOnSelector, RunsOn, Workflow, WorkflowOptions, Registry, Trigger, DynamicJobFn, DynamicJobContext, JobOrFactory, } from './types.js';
16
+ export type { SourceLocation, OutputProxy, Step, StepOptions, StepOptionsBase, StepOptionsPlain, StepOptionsWithCheck, StepRunFn, RetryConfig, NormalizedRetry, BareStepFn, StepInput, OutputSchema, InferOutputs, Job, JobOptions, GenericInitConfig, MiseInitConfig, InitPreset, InitItem, InitConfig, ContainerConfig, RunsOnSelector, RunsOn, RunsOnPick, Workflow, WorkflowOptions, Registry, Trigger, DynamicJobFn, DynamicJobContext, JobOrFactory, } from './types.js';
17
17
  export { isDynamicJobFn, dynamicJob, getDynamicJobGroup, getDynamicJobNeeds, DYNAMIC_JOB_GROUP_TAG, DYNAMIC_JOB_NEEDS_TAG, } from './types.js';
18
18
  export type { TaggedDynamicJobFn, ResultAwareDynamicJobConfig, ResultAwareDynamicJobFn, DynamicJobNeed, NeedsWhen, NeedsWhenInput, } from './types.js';
19
19
  export { buildNeedsContext } from './needs-context.js';
@@ -27,6 +27,7 @@ export { dynamicGroup, isDynamicGroupRef, DYNAMIC_GROUP_TAG } from './dynamic-gr
27
27
  export type { DynamicGroupRef } from './dynamic-group.js';
28
28
  export type { StepContext, Logger, WorkflowInfo, JobInfo, AgentInfo, MatrixJobOutputs, HostJobOutputs, RepoInfo, StepSecretsTyped, KnownSecretKeys, } from './context.js';
29
29
  export { isMatrixJobOutputs, isHostJobOutputs } from './context.js';
30
+ export type { FanoutPosition } from './fanout-context.js';
30
31
  export { buildKiciApi } from './api-types.js';
31
32
  export type { KiciApi, KiciApiTransport, InfrastructureApi, InfrastructureListResult, InventoryApi, HostApi, HostInventoryEntry, InventorySelector, } from './api-types.js';
32
33
  export { SecretNotFoundError } from './errors.js';
@@ -42,8 +43,8 @@ export type { EventDefinition } from './events/index.js';
42
43
  export type { EventEmitOptions } from './events/index.js';
43
44
  export { fixture } from './fixture.js';
44
45
  export type { Fixture, FixtureOptions } from './fixture.js';
45
- export { idempotent, idempotentStep } from './idempotent.js';
46
- export type { IdempotentOptions, IdempotentResult } from './idempotent.js';
46
+ export { idempotent, idempotentStep, checkStep } from './idempotent.js';
47
+ export type { IdempotentOptions, IdempotentResult, CheckStepOptions } from './idempotent.js';
47
48
  export { waitFor, waitForStep, WaitForTimeoutError } from './wait-for.js';
48
49
  export type { WaitForOptions, WaitForResult } from './wait-for.js';
49
50
  export { waitForHostAlive, restartHost } from './host-restart.js';
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { createJobOutputProxy, createSnapshotOutputProxy, createStepOutputProxy,
10
10
  import { step } from "./step.js";
11
11
  import { WaitForTimeoutError, waitFor, waitForStep } from "./wait-for.js";
12
12
  import { restartHost, waitForHostAlive } from "./host-restart.js";
13
- import { idempotent, idempotentStep } from "./idempotent.js";
13
+ import { checkStep, idempotent, idempotentStep } from "./idempotent.js";
14
14
  import { job } from "./job.js";
15
15
  import { workflow } from "./workflow.js";
16
16
  import { pr } from "./triggers/pr.js";
@@ -35,9 +35,10 @@ import { jobComplete } from "./triggers/job-complete.js";
35
35
  import { genericWebhook } from "./triggers/generic-webhook.js";
36
36
  import { schedule } from "./triggers/schedule.js";
37
37
  import { lifecycle } from "./triggers/lifecycle.js";
38
+ import { defineDispatchInputs } from "./triggers/dispatch-inputs.js";
38
39
  import "./triggers/index.js";
39
40
  import { afterStep, beforeStep, cleanup, onCancel, onFailure, onSuccess } from "./hooks/index.js";
40
- import { rule, skip } from "./rules/rule.js";
41
+ import { onlyOnFanoutIndex, onlyOnFirstHost, onlyOnLastHost, rule, skip } from "./rules/rule.js";
41
42
  import { evaluateRules } from "./rules/evaluator.js";
42
43
  import { isEventType } from "./events/event-payloads.js";
43
44
  import "./rules/index.js";
@@ -53,4 +54,4 @@ import "./matrix/index.js";
53
54
  import { defineEvent } from "./events/define-event.js";
54
55
  import "./events/index.js";
55
56
  import { z } from "zod";
56
- export { CacheSpecSchema, DYNAMIC_GROUP_TAG, DYNAMIC_JOB_GROUP_TAG, DYNAMIC_JOB_NEEDS_TAG, SecretNotFoundError, WaitForTimeoutError, afterStep, applyIncludeExclude, beforeStep, buildKiciApi, buildNeedsContext, cleanup, comment, create, createJobOutputProxy, createSnapshotOutputProxy, createStepOutputProxy, createStepSecrets, defineEvent, del as delete, dispatch, dynamicGroup, dynamicJob, evaluateRules, expandMatrix, fixture, fork, genericWebhook, getDynamicJobGroup, getDynamicJobNeeds, getJobOutputsMap, getStepOutputsMap, getStepRefMap, idempotent, idempotentStep, isDynamicFunction, isDynamicGroupRef, isDynamicJobFn, isEventType, isHostJobOutputs, isMatrixJobOutputs, isStaticArray, isStaticObject, job, jobComplete, kiciEvent, lifecycle, normalizeApproval, normalizeCacheSpecs, onCancel, onFailure, onSuccess, pr, provenanceSubjectIsPath, push, release, resolveJobOutputs, resolveStepOutputs, restartHost, review, reviewComment, rule, schedule, setJobOutputsMap, setStepOutputsMap, setStepRefMap, skip, star, status, step, tag, validateDag, waitFor, waitForHostAlive, waitForStep, watch, webhook, workflow, workflowComplete, workflowRun, z };
57
+ export { CacheSpecSchema, DYNAMIC_GROUP_TAG, DYNAMIC_JOB_GROUP_TAG, DYNAMIC_JOB_NEEDS_TAG, SecretNotFoundError, WaitForTimeoutError, afterStep, applyIncludeExclude, beforeStep, buildKiciApi, buildNeedsContext, checkStep, cleanup, comment, create, createJobOutputProxy, createSnapshotOutputProxy, createStepOutputProxy, createStepSecrets, defineDispatchInputs, defineEvent, del as delete, dispatch, dynamicGroup, dynamicJob, evaluateRules, expandMatrix, fixture, fork, genericWebhook, getDynamicJobGroup, getDynamicJobNeeds, getJobOutputsMap, getStepOutputsMap, getStepRefMap, idempotent, idempotentStep, isDynamicFunction, isDynamicGroupRef, isDynamicJobFn, isEventType, isHostJobOutputs, isMatrixJobOutputs, isStaticArray, isStaticObject, job, jobComplete, kiciEvent, lifecycle, normalizeApproval, normalizeCacheSpecs, onCancel, onFailure, onSuccess, onlyOnFanoutIndex, onlyOnFirstHost, onlyOnLastHost, pr, provenanceSubjectIsPath, push, release, resolveJobOutputs, resolveStepOutputs, restartHost, review, reviewComment, rule, schedule, setJobOutputsMap, setStepOutputsMap, setStepRefMap, skip, star, status, step, tag, validateDag, waitFor, waitForHostAlive, waitForStep, watch, webhook, workflow, workflowComplete, workflowRun, z };
package/dist/job.js CHANGED
@@ -35,12 +35,14 @@ function job(nameOrOptions, maybeOptions) {
35
35
  if (options.runsOn !== void 0 && options.runsOnAll !== void 0) throw new Error(`job('${name}'): runsOn and runsOnAll are mutually exclusive`);
36
36
  if (options.runsOn === void 0 && options.runsOnAll === void 0) throw new Error(`job('${name}'): one of runsOn or runsOnAll is required`);
37
37
  if (options.onUnreachable !== void 0 && options.runsOnAll === void 0) console.warn(`[kici] job('${name}'): onUnreachable is ignored without runsOnAll`);
38
+ if (options.includeUninitialized !== void 0 && options.runsOnAll === void 0) console.warn(`[kici] job('${name}'): includeUninitialized is ignored without runsOnAll`);
38
39
  return {
39
40
  _tag: "Job",
40
41
  name,
41
42
  ...options.runsOn !== void 0 && { runsOn: options.runsOn },
42
43
  ...options.runsOnAll !== void 0 && { runsOnAll: options.runsOnAll },
43
44
  ...options.onUnreachable !== void 0 && { onUnreachable: options.onUnreachable },
45
+ ...options.includeUninitialized !== void 0 && { includeUninitialized: options.includeUninitialized },
44
46
  ...options.maxParallel !== void 0 && { maxParallel: options.maxParallel },
45
47
  ...options.failFast !== void 0 && { failFast: options.failFast },
46
48
  steps,
@@ -1,4 +1,4 @@
1
- export { rule, skip } from './rule.js';
1
+ export { rule, skip, onlyOnFirstHost, onlyOnLastHost, onlyOnFanoutIndex } from './rule.js';
2
2
  export { evaluateRules, type RuleEvaluationResult } from './evaluator.js';
3
3
  export type { Rule, RuleCheckFn, RuleContext, RuleResult, EventPayload } from './types.js';
4
4
  export { isEventType } from '../events/event-payloads.js';
@@ -1,5 +1,5 @@
1
1
  import "../chunk-BTugEXQM.js";
2
- import { rule, skip } from "./rule.js";
2
+ import { onlyOnFanoutIndex, onlyOnFirstHost, onlyOnLastHost, rule, skip } from "./rule.js";
3
3
  import { evaluateRules } from "./evaluator.js";
4
4
  import { isEventType } from "../events/event-payloads.js";
5
- export { evaluateRules, isEventType, rule, skip };
5
+ export { evaluateRules, isEventType, onlyOnFanoutIndex, onlyOnFirstHost, onlyOnLastHost, rule, skip };
@@ -31,4 +31,24 @@ export declare function rule(label: string, check: RuleCheckFn): Rule;
31
31
  * });
32
32
  */
33
33
  export declare function skip(label: string, check: RuleCheckFn): Rule;
34
+ /**
35
+ * Run a step only on the first fan-out child (the lowest-`agentId` host, or the
36
+ * first matrix variant). KiCI's `run_once`-on-the-first-host primitive.
37
+ *
38
+ * A non-fan-out job is treated as a single implicit child at index 0, so a step
39
+ * gated this way runs normally there (there is exactly one host, which is first).
40
+ *
41
+ * @example
42
+ * step('enable sync mode', async (ctx) => { ... }, { rules: [onlyOnFirstHost()] })
43
+ */
44
+ export declare function onlyOnFirstHost(): Rule;
45
+ /**
46
+ * Run a step only on the last fan-out child. Runs normally when not fanned out.
47
+ */
48
+ export declare function onlyOnLastHost(): Rule;
49
+ /**
50
+ * Run a step only on the fan-out child at index `n`. A non-fan-out job is the
51
+ * implicit child at index 0, so `onlyOnFanoutIndex(0)` runs normally there.
52
+ */
53
+ export declare function onlyOnFanoutIndex(n: number): Rule;
34
54
  //# sourceMappingURL=rule.d.ts.map
@@ -31,7 +31,33 @@ function skip(label, check) {
31
31
  check: async (ctx) => !await check(ctx)
32
32
  };
33
33
  }
34
+ /**
35
+ * Run a step only on the first fan-out child (the lowest-`agentId` host, or the
36
+ * first matrix variant). KiCI's `run_once`-on-the-first-host primitive.
37
+ *
38
+ * A non-fan-out job is treated as a single implicit child at index 0, so a step
39
+ * gated this way runs normally there (there is exactly one host, which is first).
40
+ *
41
+ * @example
42
+ * step('enable sync mode', async (ctx) => { ... }, { rules: [onlyOnFirstHost()] })
43
+ */
44
+ function onlyOnFirstHost() {
45
+ return rule("fanout: first host only", (ctx) => ctx.fanout === void 0 || ctx.fanout.first);
46
+ }
47
+ /**
48
+ * Run a step only on the last fan-out child. Runs normally when not fanned out.
49
+ */
50
+ function onlyOnLastHost() {
51
+ return rule("fanout: last host only", (ctx) => ctx.fanout === void 0 || ctx.fanout.last);
52
+ }
53
+ /**
54
+ * Run a step only on the fan-out child at index `n`. A non-fan-out job is the
55
+ * implicit child at index 0, so `onlyOnFanoutIndex(0)` runs normally there.
56
+ */
57
+ function onlyOnFanoutIndex(n) {
58
+ return rule(`fanout: index ${n} only`, (ctx) => (ctx.fanout?.index ?? 0) === n);
59
+ }
34
60
  //#endregion
35
- export { rule, skip };
61
+ export { onlyOnFanoutIndex, onlyOnFirstHost, onlyOnLastHost, rule, skip };
36
62
 
37
63
  //# sourceMappingURL=rule.js.map
@@ -1,5 +1,6 @@
1
1
  import type { $ as Shell } from 'zx';
2
2
  import type { EventPayload } from '../events/event-payloads.js';
3
+ import type { FanoutPosition } from '../fanout-context.js';
3
4
  export type { EventPayload } from '../events/event-payloads.js';
4
5
  /**
5
6
  * Context passed to rule check functions.
@@ -12,6 +13,14 @@ export interface RuleContext {
12
13
  changedFiles: string[];
13
14
  /** Environment variables */
14
15
  env: Record<string, string | undefined>;
16
+ /** Operator-supplied, validated + coerced workflow-dispatch inputs. Empty when none declared. */
17
+ dispatchInputs: Readonly<Record<string, string | number | boolean | null>>;
18
+ /**
19
+ * Position of this child within its fan-out (a `runsOnAll` host or a matrix
20
+ * combination); undefined on a non-fan-out job. Read by the run-once rule
21
+ * helpers (`onlyOnFirstHost` / `onlyOnLastHost` / `onlyOnFanoutIndex`).
22
+ */
23
+ fanout?: FanoutPosition;
15
24
  /** zx shell executor for running commands */
16
25
  $: typeof Shell;
17
26
  }
package/dist/step.js CHANGED
@@ -3,6 +3,22 @@ import { normalizeApproval } from "./approval.js";
3
3
  import { createStepOutputProxy } from "./outputs.js";
4
4
  //#region src/step.ts
5
5
  /**
6
+ * Fill retry defaults and expand the `retry: N` shorthand into a
7
+ * {@link NormalizedRetry}. `retryIf` is carried through unchanged (it is
8
+ * execution-only and never serialized).
9
+ */
10
+ function normalizeRetry(retry) {
11
+ if (retry === void 0) return void 0;
12
+ const cfg = typeof retry === "number" ? { maxAttempts: retry } : retry;
13
+ return {
14
+ maxAttempts: cfg.maxAttempts,
15
+ delayMs: cfg.delayMs ?? 1e3,
16
+ backoff: cfg.backoff ?? "exponential",
17
+ maxDelayMs: cfg.maxDelayMs ?? 3e4,
18
+ ...cfg.retryIf && { retryIf: cfg.retryIf }
19
+ };
20
+ }
21
+ /**
6
22
  * Capture the call-site source location of step() using the V8 stack trace API.
7
23
  * Uses Error.captureStackTrace with the `step` function as the constructor argument
8
24
  * so the stack starts from step()'s caller.
@@ -61,6 +77,7 @@ function step(nameOrRunOrOptions, runOrOptions) {
61
77
  }
62
78
  if (options.check && !options.summarize) throw new Error("summarize is required when check is set");
63
79
  if (options.approval !== void 0 && normalizeApproval(options.approval).when === "drift" && !options.check) throw new Error("approval.when \"drift\" requires a check facet");
80
+ const retry = normalizeRetry(options.retry);
64
81
  return {
65
82
  _tag: "Step",
66
83
  name,
@@ -72,6 +89,7 @@ function step(nameOrRunOrOptions, runOrOptions) {
72
89
  ...options.whenInSync !== void 0 && { whenInSync: options.whenInSync },
73
90
  continueOnError: options.continueOnError,
74
91
  timeout: options.timeout,
92
+ ...retry !== void 0 && { retry },
75
93
  ...options.cache !== void 0 && { cache: options.cache },
76
94
  rules: options.rules,
77
95
  onCancel: options.onCancel,
@@ -0,0 +1,32 @@
1
+ import type { z } from 'zod';
2
+ import type { DispatchInputsMap } from './types.js';
3
+ /** The per-key inferred output type of a declared dispatch-inputs map. */
4
+ export type InferDispatchInputs<TMap extends DispatchInputsMap> = {
5
+ [K in keyof TMap]: z.infer<TMap[K]>;
6
+ };
7
+ /** A context that may carry validated, coerced dispatch inputs. */
8
+ interface DispatchInputsCarrier {
9
+ dispatchInputs?: Record<string, unknown>;
10
+ }
11
+ /**
12
+ * A branded handle returned by `defineDispatchInputs`. It is accepted directly
13
+ * by `dispatch({ inputs })` and exposes typed `.from(ctx)` / `.fromRule(ctx)`
14
+ * readers over `ctx.dispatchInputs`, typed per declared key.
15
+ */
16
+ export interface DefinedDispatchInputs<TMap extends DispatchInputsMap> {
17
+ readonly __kiciDispatchInputs: true;
18
+ readonly map: TMap;
19
+ /** Read the validated, coerced dispatch inputs from a step context, typed per declared key. */
20
+ from(ctx: DispatchInputsCarrier): InferDispatchInputs<TMap>;
21
+ /** Same, from a rule context. */
22
+ fromRule(ctx: DispatchInputsCarrier): InferDispatchInputs<TMap>;
23
+ }
24
+ /**
25
+ * Declare a typed workflow-dispatch inputs map once and get back a handle that
26
+ * both `dispatch({ inputs })` accepts and exposes a typed `.from(ctx)` reader —
27
+ * no double type annotation. Type safety comes via Standard-Schema inference
28
+ * (Zod 4 implements `~standard`), without a builder-generics refactor.
29
+ */
30
+ export declare function defineDispatchInputs<TMap extends DispatchInputsMap>(map: TMap): DefinedDispatchInputs<TMap>;
31
+ export {};
32
+ //# sourceMappingURL=dispatch-inputs.d.ts.map
@@ -0,0 +1,21 @@
1
+ import "../chunk-BTugEXQM.js";
2
+ //#region src/triggers/dispatch-inputs.ts
3
+ /**
4
+ * Declare a typed workflow-dispatch inputs map once and get back a handle that
5
+ * both `dispatch({ inputs })` accepts and exposes a typed `.from(ctx)` reader —
6
+ * no double type annotation. Type safety comes via Standard-Schema inference
7
+ * (Zod 4 implements `~standard`), without a builder-generics refactor.
8
+ */
9
+ function defineDispatchInputs(map) {
10
+ const read = (ctx) => ctx.dispatchInputs ?? {};
11
+ return Object.freeze({
12
+ __kiciDispatchInputs: true,
13
+ map: Object.freeze({ ...map }),
14
+ from: read,
15
+ fromRule: read
16
+ });
17
+ }
18
+ //#endregion
19
+ export { defineDispatchInputs };
20
+
21
+ //# sourceMappingURL=dispatch-inputs.js.map
@@ -13,11 +13,15 @@ import { asArray, toBranchPattern } from "./types.js";
13
13
  */
14
14
  function dispatch(config) {
15
15
  const repos = config?.repos ? asArray(config.repos).map(toBranchPattern) : [];
16
+ const rawInputs = config?.inputs;
17
+ let inputsMap;
18
+ if (rawInputs) inputsMap = "__kiciDispatchInputs" in rawInputs ? rawInputs.map : rawInputs;
16
19
  const result = {
17
20
  _tag: "DispatchTrigger",
18
21
  types: Object.freeze(config?.types ? [...config.types] : []),
19
22
  repos: Object.freeze([...repos]),
20
- ...config?.description !== void 0 && { description: config.description }
23
+ ...config?.description !== void 0 && { description: config.description },
24
+ ...inputsMap && { inputs: Object.freeze({ ...inputsMap }) }
21
25
  };
22
26
  return Object.freeze(result);
23
27
  }
@@ -23,6 +23,8 @@ export { jobComplete } from './job-complete.js';
23
23
  export { genericWebhook } from './generic-webhook.js';
24
24
  export { schedule } from './schedule.js';
25
25
  export { lifecycle } from './lifecycle.js';
26
- export type { BranchPattern, BodyMatchPattern, PrEvent, PushEvent, PrTriggerConfig, PushTriggerConfig, TagTriggerConfig, CommentTriggerConfig, ReviewTriggerConfig, ReviewCommentTriggerConfig, ReleaseTriggerConfig, DispatchTriggerConfig, CreateTriggerConfig, DeleteTriggerConfig, StatusTriggerConfig, WorkflowRunTriggerConfig, ForkTriggerConfig, StarTriggerConfig, WatchTriggerConfig, WebhookTriggerConfig, TriggerConfig, PrConfigInput, PushConfigInput, TagConfigInput, CommentConfigInput, CommentAction, CommentSource, ReviewConfigInput, ReviewAction, ReviewState, ReviewCommentConfigInput, ReviewCommentAction, ReleaseConfigInput, ReleaseAction, DispatchConfigInput, CreateConfigInput, DeleteConfigInput, RefType, StatusConfigInput, StatusState, WorkflowRunConfigInput, WorkflowRunAction, ForkConfigInput, StarConfigInput, StarAction, WatchConfigInput, WatchAction, WebhookConfigInput, KiciEventConfigInput, KiciEventTriggerConfig, WorkflowCompleteConfigInput, WorkflowCompleteTriggerConfig, WorkflowCompleteStatus, JobCompleteConfigInput, JobCompleteTriggerConfig, JobCompleteStatus, GenericWebhookConfigInput, GenericWebhookTriggerConfig, GenericWebhookAuthMethod, GenericWebhookHmacAuth, GenericWebhookApiKeyAuth, GenericWebhookAuth, ScheduleConfigInput, ScheduleTriggerConfig, LifecycleEvent, LifecycleConfigInput, LifecycleTriggerConfig, } from './types.js';
26
+ export { defineDispatchInputs } from './dispatch-inputs.js';
27
+ export type { DefinedDispatchInputs, InferDispatchInputs } from './dispatch-inputs.js';
28
+ export type { DispatchInputsMap, BranchPattern, BodyMatchPattern, PrEvent, PushEvent, PrTriggerConfig, PushTriggerConfig, TagTriggerConfig, CommentTriggerConfig, ReviewTriggerConfig, ReviewCommentTriggerConfig, ReleaseTriggerConfig, DispatchTriggerConfig, CreateTriggerConfig, DeleteTriggerConfig, StatusTriggerConfig, WorkflowRunTriggerConfig, ForkTriggerConfig, StarTriggerConfig, WatchTriggerConfig, WebhookTriggerConfig, TriggerConfig, PrConfigInput, PushConfigInput, TagConfigInput, CommentConfigInput, CommentAction, CommentSource, ReviewConfigInput, ReviewAction, ReviewState, ReviewCommentConfigInput, ReviewCommentAction, ReleaseConfigInput, ReleaseAction, DispatchConfigInput, CreateConfigInput, DeleteConfigInput, RefType, StatusConfigInput, StatusState, WorkflowRunConfigInput, WorkflowRunAction, ForkConfigInput, StarConfigInput, StarAction, WatchConfigInput, WatchAction, WebhookConfigInput, KiciEventConfigInput, KiciEventTriggerConfig, WorkflowCompleteConfigInput, WorkflowCompleteTriggerConfig, WorkflowCompleteStatus, JobCompleteConfigInput, JobCompleteTriggerConfig, JobCompleteStatus, GenericWebhookConfigInput, GenericWebhookTriggerConfig, GenericWebhookAuthMethod, GenericWebhookHmacAuth, GenericWebhookApiKeyAuth, GenericWebhookAuth, ScheduleConfigInput, ScheduleTriggerConfig, LifecycleEvent, LifecycleConfigInput, LifecycleTriggerConfig, } from './types.js';
27
29
  export { DEFAULT_PR_EVENTS, toBranchPattern } from './types.js';
28
30
  //# sourceMappingURL=index.d.ts.map
@@ -22,4 +22,5 @@ import { jobComplete } from "./job-complete.js";
22
22
  import { genericWebhook } from "./generic-webhook.js";
23
23
  import { schedule } from "./schedule.js";
24
24
  import { lifecycle } from "./lifecycle.js";
25
- export { DEFAULT_PR_EVENTS, comment, create, del as delete, dispatch, fork, genericWebhook, jobComplete, kiciEvent, lifecycle, pr, push, release, review, reviewComment, schedule, star, status, tag, toBranchPattern, watch, webhook, workflowComplete, workflowRun };
25
+ import { defineDispatchInputs } from "./dispatch-inputs.js";
26
+ export { DEFAULT_PR_EVENTS, comment, create, defineDispatchInputs, del as delete, dispatch, fork, genericWebhook, jobComplete, kiciEvent, lifecycle, pr, push, release, review, reviewComment, schedule, star, status, tag, toBranchPattern, watch, webhook, workflowComplete, workflowRun };
@@ -2,6 +2,14 @@
2
2
  * Trigger types and interfaces for pr() and push() trigger helpers.
3
3
  * Supports both glob patterns and regex patterns for branch/path matching.
4
4
  */
5
+ import type { z } from 'zod';
6
+ /**
7
+ * A declared map of typed workflow-dispatch inputs: `{ name: ZodSchema }`.
8
+ * Each schema must fall within the closed dispatch-input subset (extracted by
9
+ * the compiler) — z.string/number/boolean/enum/literal plus
10
+ * .optional/.nullable/.default/.min/.max/.regex/.int.
11
+ */
12
+ export type DispatchInputsMap = Record<string, z.ZodType>;
5
13
  /**
6
14
  * Branch pattern - discriminated union supporting both glob and regex patterns.
7
15
  * Glob patterns use micromatch syntax, regex patterns use standard JS regex.
@@ -165,6 +173,8 @@ export interface DispatchTriggerConfig {
165
173
  readonly types: readonly string[];
166
174
  readonly repos: readonly BranchPattern[];
167
175
  readonly description?: string;
176
+ /** Declared, typed workflow-dispatch inputs (frozen `{ name: ZodSchema }`). */
177
+ readonly inputs?: DispatchInputsMap;
168
178
  }
169
179
  /**
170
180
  * Input configuration for dispatch() factory function.
@@ -173,6 +183,16 @@ export interface DispatchConfigInput {
173
183
  readonly types?: string[];
174
184
  readonly repos?: string | RegExp | (string | RegExp)[];
175
185
  readonly description?: string;
186
+ /**
187
+ * Typed workflow-dispatch inputs. Accepts a bare `{ name: ZodSchema }` map or
188
+ * a `defineDispatchInputs(...)` branded handle (which also exposes a typed
189
+ * `.from(ctx)` accessor). The compiler validates each schema against the
190
+ * closed dispatch-input subset.
191
+ */
192
+ readonly inputs?: DispatchInputsMap | {
193
+ readonly __kiciDispatchInputs: true;
194
+ readonly map: DispatchInputsMap;
195
+ };
176
196
  }
177
197
  export type RefType = 'branch' | 'tag';
178
198
  /**
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { z } from 'zod';
2
2
  import type { $ as Shell } from 'zx';
3
+ import type { RetryBackoff } from '@kici-dev/core';
3
4
  import type { ResourceRequest, RunsOnAllInput, OnUnreachableMode, NeedsWhen, ExecutionJobStatus } from '@kici-dev/engine';
4
5
  import type { StepContext, Logger } from './context.js';
5
6
  import type { TriggerConfig } from './triggers/types.js';
@@ -64,6 +65,8 @@ export interface Step<TResult = void> {
64
65
  readonly continueOnError?: boolean;
65
66
  /** Step-level timeout in milliseconds. Overrides the agent's default (30 minutes). */
66
67
  readonly timeout?: number;
68
+ /** Normalized retry policy (defaults filled, shorthand expanded). `retryIf` is execution-only. */
69
+ readonly retry?: NormalizedRetry;
67
70
  /** Declarative cache: restored before this step, saved after on key miss. */
68
71
  readonly cache?: import('./cache-types.js').CacheInput;
69
72
  /** Step-level conditional rules (evaluated agent-side). */
@@ -95,6 +98,33 @@ export type BareStepFn<TResult = void> = (ctx: StepContext) => Promise<TResult>;
95
98
  export type StepInput = Step<any> | BareStepFn<any>;
96
99
  /** Options for step() factory - simple form (just async function) */
97
100
  export type StepRunFn = (ctx: StepContext) => Promise<void>;
101
+ /**
102
+ * Author-supplied retry policy for a step. A thrown attempt is re-run while
103
+ * attempts remain and `retryIf(err)` is true.
104
+ */
105
+ export interface RetryConfig {
106
+ /** Total attempts incl. the first; `maxAttempts: 3` ⇒ up to 3 runs. Must be >= 1. */
107
+ maxAttempts: number;
108
+ /** Base delay between attempts, ms. Default 1000. */
109
+ delayMs?: number;
110
+ /** Delay growth. Default 'exponential'. */
111
+ backoff?: RetryBackoff;
112
+ /** Cap for exponential backoff, ms. Default 30000. */
113
+ maxDelayMs?: number;
114
+ /** Retry only when this returns true for the thrown error. Default: retry on any throw. */
115
+ retryIf?: (err: unknown) => boolean;
116
+ }
117
+ /**
118
+ * Retry policy with defaults filled in, carried on the built {@link Step}.
119
+ * `retryIf` rides along on the in-memory step (it is never serialized).
120
+ */
121
+ export interface NormalizedRetry {
122
+ maxAttempts: number;
123
+ delayMs: number;
124
+ backoff: RetryBackoff;
125
+ maxDelayMs: number;
126
+ retryIf?: (err: unknown) => boolean;
127
+ }
98
128
  /**
99
129
  * Facets shared by both the plain and the check variant of {@link StepOptions}.
100
130
  * These compose unchanged whether or not a step declares a `check` facet.
@@ -106,6 +136,8 @@ export interface StepOptionsBase {
106
136
  continueOnError?: boolean;
107
137
  /** Step-level timeout in milliseconds. Overrides the agent's default (30 minutes). */
108
138
  timeout?: number;
139
+ /** Retry policy: re-run a thrown step with backoff. `retry: N` ⇒ `{ maxAttempts: N }`. */
140
+ retry?: number | RetryConfig;
109
141
  /** Declarative cache: restored before this step, saved after on key miss. */
110
142
  cache?: import('./cache-types.js').CacheInput;
111
143
  /** Step-level conditional rules (evaluated agent-side). */
@@ -361,7 +393,21 @@ export type InitConfig = InitItem | InitItem[] | 'auto' | false;
361
393
  export interface RunsOnSelector {
362
394
  labels: string | RegExp | (string | RegExp)[];
363
395
  exclude?: string | RegExp | (string | RegExp)[];
396
+ /**
397
+ * How to pick the single agent when more than one matches.
398
+ *
399
+ * - `'deterministic'` (default) — sort matching candidates by `agentId` and
400
+ * pick the lowest, so a run-once-on-one-host job (a migration, a dump) lands
401
+ * on the same host across re-runs. Can hot-spot equivalent agents.
402
+ * - `'any'` — pick any available agent (load spread). Opt out of determinism
403
+ * for jobs that don't need a stable host.
404
+ *
405
+ * The string / array shorthand `runsOn` forms imply `'deterministic'` too.
406
+ */
407
+ pick?: RunsOnPick;
364
408
  }
409
+ /** Single-agent selection policy when multiple agents match a `runsOn` selector. */
410
+ export type RunsOnPick = 'deterministic' | 'any';
365
411
  /**
366
412
  * Polymorphic runsOn type: string shorthand, array shorthand, or full selector object.
367
413
  * - `'kici:os:linux'` — single label shorthand (targets any linux agent)
@@ -391,6 +437,14 @@ export interface Job {
391
437
  readonly runsOnAll?: RunsOnAllInput;
392
438
  /** Failure policy for unreachable durable hosts when using `runsOnAll`. */
393
439
  readonly onUnreachable?: OnUnreachableMode;
440
+ /**
441
+ * Widen a `runsOnAll` fan-out to declared-but-un-agented hosts: each matching
442
+ * host that has no live agent gets a temporary init-runner brought up over SSH
443
+ * and its steps run on it (fresh-box bootstrap convergence). Already-live hosts
444
+ * run on their own agent. Default `false` (only live hosts run). Only
445
+ * meaningful alongside `runsOnAll`.
446
+ */
447
+ readonly includeUninitialized?: boolean;
394
448
  /** Fan-out concurrency width (sliding window; `1` = serial). Applies to matrix and `runsOnAll`. */
395
449
  readonly maxParallel?: number;
396
450
  /** Halt the fan-out on first child failure, skipping the remainder. Default `false`. */
@@ -491,6 +545,13 @@ export interface JobOptions {
491
545
  * pinned child and waits. Only meaningful alongside `runsOnAll`.
492
546
  */
493
547
  onUnreachable?: OnUnreachableMode;
548
+ /**
549
+ * Widen a `runsOnAll` fan-out to declared-but-un-agented hosts: a matching host
550
+ * with no live agent gets a temporary init-runner brought up over SSH and its
551
+ * steps run on it (fresh-box bootstrap convergence); already-live hosts run on
552
+ * their own agent. Default `false`. Only meaningful alongside `runsOnAll`.
553
+ */
554
+ includeUninitialized?: boolean;
494
555
  /**
495
556
  * Fan-out concurrency width: the maximum number of fan-out children (matrix
496
557
  * combinations or `runsOnAll` hosts) that run at once. A sliding window —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kici-dev/sdk",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "TypeScript SDK for defining KiCI workflows. Import into `.kici/workflows/*.ts` to declare workflows, jobs, steps, triggers, rules, and matrix configurations.",
5
5
  "keywords": [
6
6
  "ci",
@@ -49,8 +49,8 @@
49
49
  "micromatch": "^4.0.8",
50
50
  "zod": "^4.4.3",
51
51
  "zx": "^8.8.5",
52
- "@kici-dev/core": "0.1.22",
53
- "@kici-dev/engine": "0.1.22"
52
+ "@kici-dev/core": "0.1.23",
53
+ "@kici-dev/engine": "0.1.23"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/micromatch": "^4.0.10"
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/sdk@0.1.22",
6
- "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fsdk/0.1.22/fea982d5-064e-481c-8436-fbd07a92a3c8",
5
+ "name": "@kici-dev/sdk@0.1.23",
6
+ "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fsdk/0.1.23/91b9ac0e-988f-4da4-8a22-0a3413875c5f",
7
7
  "creationInfo": {
8
- "created": "2026-06-24T06:03:05Z",
8
+ "created": "2026-06-25T11:12:47Z",
9
9
  "creators": [
10
10
  "Tool: kici-sbom-generator"
11
11
  ]
@@ -146,9 +146,9 @@
146
146
  "homepage": "https://ericsmekens.github.io/jsep/tree/master/packages/regex#readme"
147
147
  },
148
148
  {
149
- "SPDXID": "SPDXRef-Package--kici-dev-core-0.1.22",
149
+ "SPDXID": "SPDXRef-Package--kici-dev-core-0.1.23",
150
150
  "name": "@kici-dev/core",
151
- "versionInfo": "0.1.22",
151
+ "versionInfo": "0.1.23",
152
152
  "downloadLocation": "NOASSERTION",
153
153
  "filesAnalyzed": false,
154
154
  "licenseConcluded": "NOASSERTION",
@@ -159,16 +159,16 @@
159
159
  {
160
160
  "referenceCategory": "PACKAGE-MANAGER",
161
161
  "referenceType": "purl",
162
- "referenceLocator": "pkg:npm/%40kici-dev/core@0.1.22"
162
+ "referenceLocator": "pkg:npm/%40kici-dev/core@0.1.23"
163
163
  }
164
164
  ],
165
165
  "description": "Light shared utilities for the KiCI stack (logging, errors, formatting, crypto, zx init, the TypeScript ESM loader hook). No server-side dependencies.",
166
166
  "homepage": "https://kici.dev"
167
167
  },
168
168
  {
169
- "SPDXID": "SPDXRef-Package--kici-dev-engine-0.1.22",
169
+ "SPDXID": "SPDXRef-Package--kici-dev-engine-0.1.23",
170
170
  "name": "@kici-dev/engine",
171
- "versionInfo": "0.1.22",
171
+ "versionInfo": "0.1.23",
172
172
  "downloadLocation": "NOASSERTION",
173
173
  "filesAnalyzed": false,
174
174
  "licenseConcluded": "NOASSERTION",
@@ -179,7 +179,7 @@
179
179
  {
180
180
  "referenceCategory": "PACKAGE-MANAGER",
181
181
  "referenceType": "purl",
182
- "referenceLocator": "pkg:npm/%40kici-dev/engine@0.1.22"
182
+ "referenceLocator": "pkg:npm/%40kici-dev/engine@0.1.23"
183
183
  }
184
184
  ],
185
185
  "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.",
@@ -188,7 +188,7 @@
188
188
  {
189
189
  "SPDXID": "SPDXRef-RootPackage",
190
190
  "name": "@kici-dev/sdk",
191
- "versionInfo": "0.1.22",
191
+ "versionInfo": "0.1.23",
192
192
  "downloadLocation": "NOASSERTION",
193
193
  "filesAnalyzed": false,
194
194
  "licenseConcluded": "NOASSERTION",
@@ -199,7 +199,7 @@
199
199
  {
200
200
  "referenceCategory": "PACKAGE-MANAGER",
201
201
  "referenceType": "purl",
202
- "referenceLocator": "pkg:npm/%40kici-dev/sdk@0.1.22"
202
+ "referenceLocator": "pkg:npm/%40kici-dev/sdk@0.1.23"
203
203
  }
204
204
  ],
205
205
  "description": "TypeScript SDK for defining KiCI workflows. Import into `.kici/workflows/*.ts` to declare workflows, jobs, steps, triggers, rules, and matrix configurations.",
@@ -1584,68 +1584,68 @@
1584
1584
  "relationshipType": "DEPENDS_ON"
1585
1585
  },
1586
1586
  {
1587
- "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.22",
1587
+ "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.23",
1588
1588
  "relatedSpdxElement": "SPDXRef-Package-oxc-transform-0.135.0",
1589
1589
  "relationshipType": "DEPENDS_ON"
1590
1590
  },
1591
1591
  {
1592
- "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.22",
1592
+ "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.23",
1593
1593
  "relatedSpdxElement": "SPDXRef-Package-picocolors-1.1.1",
1594
1594
  "relationshipType": "DEPENDS_ON"
1595
1595
  },
1596
1596
  {
1597
- "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.22",
1597
+ "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.23",
1598
1598
  "relatedSpdxElement": "SPDXRef-Package-winston-daily-rotate-file-5.0.0",
1599
1599
  "relationshipType": "DEPENDS_ON"
1600
1600
  },
1601
1601
  {
1602
- "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.22",
1602
+ "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.23",
1603
1603
  "relatedSpdxElement": "SPDXRef-Package-winston-3.19.0",
1604
1604
  "relationshipType": "DEPENDS_ON"
1605
1605
  },
1606
1606
  {
1607
- "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.22",
1607
+ "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.23",
1608
1608
  "relatedSpdxElement": "SPDXRef-Package-zod-4.4.3",
1609
1609
  "relationshipType": "DEPENDS_ON"
1610
1610
  },
1611
1611
  {
1612
- "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.22",
1612
+ "spdxElementId": "SPDXRef-Package--kici-dev-core-0.1.23",
1613
1613
  "relatedSpdxElement": "SPDXRef-Package-zx-8.8.5",
1614
1614
  "relationshipType": "DEPENDS_ON"
1615
1615
  },
1616
1616
  {
1617
- "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.22",
1617
+ "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.23",
1618
1618
  "relatedSpdxElement": "SPDXRef-Package-jose-6.2.3",
1619
1619
  "relationshipType": "DEPENDS_ON"
1620
1620
  },
1621
1621
  {
1622
- "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.22",
1622
+ "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.23",
1623
1623
  "relatedSpdxElement": "SPDXRef-Package-jsonpath-plus-10.4.0",
1624
1624
  "relationshipType": "DEPENDS_ON"
1625
1625
  },
1626
1626
  {
1627
- "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.22",
1627
+ "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.23",
1628
1628
  "relatedSpdxElement": "SPDXRef-Package-picomatch-4.0.4",
1629
1629
  "relationshipType": "DEPENDS_ON"
1630
1630
  },
1631
1631
  {
1632
- "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.22",
1632
+ "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.23",
1633
1633
  "relatedSpdxElement": "SPDXRef-Package-safe-regex-2.1.1",
1634
1634
  "relationshipType": "DEPENDS_ON"
1635
1635
  },
1636
1636
  {
1637
- "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.22",
1637
+ "spdxElementId": "SPDXRef-Package--kici-dev-engine-0.1.23",
1638
1638
  "relatedSpdxElement": "SPDXRef-Package-zod-4.4.3",
1639
1639
  "relationshipType": "DEPENDS_ON"
1640
1640
  },
1641
1641
  {
1642
1642
  "spdxElementId": "SPDXRef-RootPackage",
1643
- "relatedSpdxElement": "SPDXRef-Package--kici-dev-core-0.1.22",
1643
+ "relatedSpdxElement": "SPDXRef-Package--kici-dev-core-0.1.23",
1644
1644
  "relationshipType": "DEPENDS_ON"
1645
1645
  },
1646
1646
  {
1647
1647
  "spdxElementId": "SPDXRef-RootPackage",
1648
- "relatedSpdxElement": "SPDXRef-Package--kici-dev-engine-0.1.22",
1648
+ "relatedSpdxElement": "SPDXRef-Package--kici-dev-engine-0.1.23",
1649
1649
  "relationshipType": "DEPENDS_ON"
1650
1650
  },
1651
1651
  {