@kici-dev/sdk 0.1.15 → 0.1.17

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 (68) hide show
  1. package/dist/api-types.d.ts +25 -1
  2. package/dist/api-types.js +29 -3
  3. package/dist/approval.d.ts +34 -0
  4. package/dist/approval.js +16 -0
  5. package/dist/cache-types.js +1 -1
  6. package/dist/context.d.ts +31 -2
  7. package/dist/context.js +10 -2
  8. package/dist/dynamic-group.js +1 -1
  9. package/dist/errors.js +3 -1
  10. package/dist/events/define-event.js +1 -1
  11. package/dist/events/event-payloads.js +1 -1
  12. package/dist/events/event-payloads.test-d.js +1 -1
  13. package/dist/events/index.js +1 -1
  14. package/dist/events/types.js +1 -1
  15. package/dist/fixture.js +1 -1
  16. package/dist/hooks/index.js +1 -1
  17. package/dist/hooks/types.js +1 -1
  18. package/dist/idempotent.js +1 -1
  19. package/dist/index.d.ts +7 -2
  20. package/dist/index.js +5 -2
  21. package/dist/job.js +14 -6
  22. package/dist/matrix/expand.d.ts +1 -24
  23. package/dist/matrix/expand.js +2 -65
  24. package/dist/matrix/index.js +1 -1
  25. package/dist/matrix/types.d.ts +2 -19
  26. package/dist/matrix/types.js +1 -1
  27. package/dist/outputs.js +1 -1
  28. package/dist/provenance-types.d.ts +38 -0
  29. package/dist/provenance-types.js +10 -0
  30. package/dist/rules/evaluator.js +1 -1
  31. package/dist/rules/index.js +1 -1
  32. package/dist/rules/rule.js +1 -1
  33. package/dist/rules/types.js +1 -1
  34. package/dist/secrets.js +1 -1
  35. package/dist/step.js +2 -1
  36. package/dist/triggers/comment.js +1 -1
  37. package/dist/triggers/create.js +1 -1
  38. package/dist/triggers/delete.js +1 -1
  39. package/dist/triggers/dispatch.js +1 -1
  40. package/dist/triggers/fork.js +1 -1
  41. package/dist/triggers/generic-webhook.js +1 -1
  42. package/dist/triggers/index.js +1 -1
  43. package/dist/triggers/job-complete.js +1 -1
  44. package/dist/triggers/kici-event.js +1 -1
  45. package/dist/triggers/lifecycle.js +1 -1
  46. package/dist/triggers/pr.js +1 -1
  47. package/dist/triggers/push.js +1 -1
  48. package/dist/triggers/release.js +1 -1
  49. package/dist/triggers/review-comment.js +1 -1
  50. package/dist/triggers/review.js +1 -1
  51. package/dist/triggers/schedule.js +1 -1
  52. package/dist/triggers/star.js +1 -1
  53. package/dist/triggers/status.js +1 -1
  54. package/dist/triggers/tag.js +1 -1
  55. package/dist/triggers/types.js +1 -1
  56. package/dist/triggers/watch.js +1 -1
  57. package/dist/triggers/webhook.js +1 -1
  58. package/dist/triggers/workflow-complete.js +1 -1
  59. package/dist/triggers/workflow-run.js +1 -1
  60. package/dist/types.d.ts +69 -15
  61. package/dist/types.js +1 -1
  62. package/dist/validation/dag.js +1 -1
  63. package/dist/validation/index.js +1 -1
  64. package/dist/wait-for.js +1 -1
  65. package/dist/workflow.js +3 -2
  66. package/package.json +3 -4
  67. package/sbom.spdx.json +52 -27
  68. /package/dist/{chunk-gOLHoazu.js → chunk-BTugEXQM.js} +0 -0
@@ -8,6 +8,8 @@
8
8
  * 1. Add the typed method here (with param + return types)
9
9
  * 2. Register the handler in the orchestrator's AgentApiRegistry
10
10
  */
11
+ import { type OidcTokenResult } from '@kici-dev/engine/protocol/messages/oidc-token-relay';
12
+ export type { OidcTokenResult };
11
13
  export interface InfrastructureListResult {
12
14
  scalers: Array<{
13
15
  name: string;
@@ -28,9 +30,23 @@ export interface InfrastructureApi {
28
30
  /** List available scalers and connected agents. */
29
31
  list(): Promise<InfrastructureListResult>;
30
32
  }
33
+ export interface OidcApi {
34
+ /**
35
+ * Request a short-lived OIDC ID token for the current job, bound to
36
+ * `audience`. The token's identity claims (repository, ref, sha, run/job id)
37
+ * are derived server-side from the build context and cannot be spoofed by the
38
+ * workflow. The token is automatically masked in step logs. Only available
39
+ * inside a running job step (throws otherwise).
40
+ */
41
+ token(opts: {
42
+ audience: string;
43
+ }): Promise<OidcTokenResult>;
44
+ }
31
45
  export interface KiciApi {
32
46
  /** Query orchestrator infrastructure (scalers, agents). */
33
47
  infrastructure: InfrastructureApi;
48
+ /** Request short-lived OIDC ID tokens for the current job (build provenance). */
49
+ oidc: OidcApi;
34
50
  }
35
51
  /**
36
52
  * Low-level transport function used to implement KiciApi.
@@ -42,6 +58,14 @@ export type KiciApiTransport = (method: string, params?: Record<string, unknown>
42
58
  *
43
59
  * This is the bridge between the typed SDK interface and the untyped WS/IPC
44
60
  * transport. Each method call is mapped to { method: 'namespace.method', params }.
61
+ *
62
+ * `jobCtx` carries the per-job execution context (the job the step is running
63
+ * in). It is supplied by the agent's sandbox step context so `oidc.token()` can
64
+ * bind its request to that job; the workflow author never supplies it. It is
65
+ * omitted for contexts with no running job (e.g. DynamicJobFn re-evaluation),
66
+ * where `oidc.token()` throws rather than silently misattributing a token.
45
67
  */
46
- export declare function buildKiciApi(transport: KiciApiTransport): KiciApi;
68
+ export declare function buildKiciApi(transport: KiciApiTransport, jobCtx?: {
69
+ jobId: string;
70
+ }): KiciApi;
47
71
  //# sourceMappingURL=api-types.d.ts.map
package/dist/api-types.js CHANGED
@@ -1,13 +1,39 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
+ import { OIDC_TOKEN_REQUEST_METHOD } from "@kici-dev/engine/protocol/messages/oidc-token-relay";
2
3
  //#region src/api-types.ts
3
4
  /**
5
+ * Typed KiCI API available to workflows via ctx.kici.
6
+ *
7
+ * Each namespace groups related methods. Under the hood, calls are serialized
8
+ * to { method: 'namespace.method', params } and sent over the agent's WS
9
+ * connection to the orchestrator. Adding a new API method:
10
+ *
11
+ * 1. Add the typed method here (with param + return types)
12
+ * 2. Register the handler in the orchestrator's AgentApiRegistry
13
+ */
14
+ /**
4
15
  * Build a typed KiciApi proxy from a raw transport function.
5
16
  *
6
17
  * This is the bridge between the typed SDK interface and the untyped WS/IPC
7
18
  * transport. Each method call is mapped to { method: 'namespace.method', params }.
19
+ *
20
+ * `jobCtx` carries the per-job execution context (the job the step is running
21
+ * in). It is supplied by the agent's sandbox step context so `oidc.token()` can
22
+ * bind its request to that job; the workflow author never supplies it. It is
23
+ * omitted for contexts with no running job (e.g. DynamicJobFn re-evaluation),
24
+ * where `oidc.token()` throws rather than silently misattributing a token.
8
25
  */
9
- function buildKiciApi(transport) {
10
- return { infrastructure: { list: () => transport("infrastructure.list", {}) } };
26
+ function buildKiciApi(transport, jobCtx) {
27
+ return {
28
+ infrastructure: { list: () => transport("infrastructure.list", {}) },
29
+ oidc: { token: (opts) => {
30
+ if (!jobCtx) return Promise.reject(/* @__PURE__ */ new Error("ctx.kici.oidc.token() is only available inside a running job step"));
31
+ return transport(OIDC_TOKEN_REQUEST_METHOD, {
32
+ jobId: jobCtx.jobId,
33
+ audience: opts.audience
34
+ });
35
+ } }
36
+ };
11
37
  }
12
38
  //#endregion
13
39
  export { buildKiciApi };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Workflow-author API for declaring a manual approval gate at step, job, or
3
+ * workflow level. The author writes `requireApproval`; the compiler normalizes
4
+ * it into the lock file's `approval` block, and the orchestrator turns it into
5
+ * a held element at dispatch time.
6
+ */
7
+ /** A single approver clause: any member of a team, or a specific user. */
8
+ export type ApproverClause = {
9
+ team: string;
10
+ } | {
11
+ user: string;
12
+ };
13
+ /**
14
+ * Declarative approval requirement.
15
+ *
16
+ * - `true` — pause for ANY org member with the approval permission.
17
+ * - `ApproverClause[]` — a flat AND list (all clauses must be satisfied).
18
+ * - object form — clauses plus an optional human `reason` and a per-gate
19
+ * `timeout` (seconds) that overrides the org-default expiry.
20
+ */
21
+ export type RequireApproval = true | ApproverClause[] | {
22
+ approvers: ApproverClause[];
23
+ reason?: string;
24
+ timeout?: number;
25
+ };
26
+ /** The normalized shape written into the lock file. */
27
+ export interface NormalizedRequireApproval {
28
+ clauses: ApproverClause[];
29
+ reason?: string;
30
+ timeoutSeconds?: number;
31
+ }
32
+ /** Normalize any `RequireApproval` form into `{ clauses, reason?, timeoutSeconds? }`. */
33
+ export declare function normalizeRequireApproval(r: RequireApproval): NormalizedRequireApproval;
34
+ //# sourceMappingURL=approval.d.ts.map
@@ -0,0 +1,16 @@
1
+ import "./chunk-BTugEXQM.js";
2
+ //#region src/approval.ts
3
+ /** Normalize any `RequireApproval` form into `{ clauses, reason?, timeoutSeconds? }`. */
4
+ function normalizeRequireApproval(r) {
5
+ if (r === true) return { clauses: [] };
6
+ if (Array.isArray(r)) return { clauses: r };
7
+ return {
8
+ clauses: r.approvers,
9
+ reason: r.reason,
10
+ timeoutSeconds: r.timeout
11
+ };
12
+ }
13
+ //#endregion
14
+ export { normalizeRequireApproval };
15
+
16
+ //# sourceMappingURL=approval.js.map
@@ -1,4 +1,4 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  import { z } from "zod";
3
3
  //#region src/cache-types.ts
4
4
  /** Zod schema validating a CacheSpec at compile/serialize time. */
package/dist/context.d.ts CHANGED
@@ -19,6 +19,19 @@ export interface JobInfo {
19
19
  name: string;
20
20
  runsOn: string;
21
21
  }
22
+ /**
23
+ * Outputs of a matrix job as seen by a downstream `needs:` consumer.
24
+ * A downstream that consumes a matrix upstream receives this envelope instead of
25
+ * a flat outputs object, identically under `kici run local` and the remote path.
26
+ */
27
+ export interface MatrixJobOutputs<T = Record<string, unknown>> {
28
+ /** Keyed by the combination suffix (the text inside `(...)` of the child name). */
29
+ byMatrix: Record<string, T>;
30
+ /** Last-write-wins flat merge across children, in child (name) order. */
31
+ merged: T;
32
+ }
33
+ /** Runtime discriminator: true when `ctx.jobOutputs(ref)` returned a matrix envelope. */
34
+ export declare function isMatrixJobOutputs(value: Record<string, unknown> | MatrixJobOutputs): value is MatrixJobOutputs;
22
35
  /**
23
36
  * Augmentable interface for known secret keys.
24
37
  * When augmented via `kici types` (.d.ts generation), narrows get/expose key parameter.
@@ -158,14 +171,22 @@ export interface StepContext<TInputs = Record<string, unknown>> {
158
171
  } | ((...args: any[]) => any)): T;
159
172
  /**
160
173
  * Resolve outputs from a preceding job by reference.
161
- * Returns the job's collected outputs (step-keyed for multi-step, flat for run shorthand).
174
+ *
175
+ * For a plain upstream this returns the job's collected outputs (step-keyed
176
+ * for multi-step, flat for run shorthand). For a **matrix** upstream it returns
177
+ * a {@link MatrixJobOutputs} envelope `{ byMatrix, merged }` keyed by the
178
+ * combination suffix — identical under `kici run local` and the remote path.
179
+ * Use {@link isMatrixJobOutputs} (or `'byMatrix' in result`) to discriminate.
162
180
  *
163
181
  * @example
164
182
  * const setupOutputs = ctx.jobOutputs(setupJob);
183
+ * @example
184
+ * const m = ctx.jobOutputs(buildMatrixJob);
185
+ * if (isMatrixJobOutputs(m)) console.log(m.byMatrix['linux, arm64']);
165
186
  */
166
187
  jobOutputs(ref: {
167
188
  name: string;
168
- }): Record<string, unknown>;
189
+ }): Record<string, unknown> | MatrixJobOutputs;
169
190
  /**
170
191
  * Publish a secret output value from this job.
171
192
  * Secret outputs are encrypted before leaving the agent and can be consumed
@@ -188,6 +209,14 @@ export interface StepContext<TInputs = Record<string, unknown>> {
188
209
  * under `spec.key` (immutable — first save wins). Scoped per org + ref.
189
210
  */
190
211
  cache: import('./cache-types.js').CacheApi;
212
+ /**
213
+ * Build, sign, and persist a KiCI build-provenance attestation for a produced
214
+ * artifact. The in-toto statement's identity is derived from a Platform-minted
215
+ * identity token (unforgeable); the bundle is signed with an ephemeral key and
216
+ * is offline-verifiable. Pass the artifact via a precomputed digest or a path
217
+ * the agent digests with SHA-256.
218
+ */
219
+ attestProvenance(opts: import('./provenance-types.js').AttestProvenanceOptions): Promise<import('./provenance-types.js').AttestProvenanceResult>;
191
220
  }
192
221
  export {};
193
222
  //# sourceMappingURL=context.d.ts.map
package/dist/context.js CHANGED
@@ -1,2 +1,10 @@
1
- import "./chunk-gOLHoazu.js";
2
- export {};
1
+ import "./chunk-BTugEXQM.js";
2
+ //#region src/context.ts
3
+ /** Runtime discriminator: true when `ctx.jobOutputs(ref)` returned a matrix envelope. */
4
+ function isMatrixJobOutputs(value) {
5
+ return typeof value === "object" && value !== null && "byMatrix" in value && "merged" in value && typeof value.byMatrix === "object";
6
+ }
7
+ //#endregion
8
+ export { isMatrixJobOutputs };
9
+
10
+ //# sourceMappingURL=context.js.map
@@ -1,4 +1,4 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  //#region src/dynamic-group.ts
3
3
  /**
4
4
  * Dynamic group helpers for cross-domain needs.
package/dist/errors.js CHANGED
@@ -1,9 +1,11 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  //#region src/errors.ts
3
3
  /**
4
4
  * Thrown when accessing a secret key that does not exist in the flat secrets proxy.
5
5
  */
6
6
  var SecretNotFoundError = class extends Error {
7
+ key;
8
+ availableKeys;
7
9
  constructor(key, availableKeys) {
8
10
  super(`Secret "${key}" not found. Available keys: ${availableKeys.join(", ") || "(none)"}. Use ctx.secrets.has('${key}') to check existence, or await ctx.secrets.get('${key}') in a try/catch.`);
9
11
  this.key = key;
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/events/define-event.ts
3
3
  /**
4
4
  * Create a typed event definition with a Zod schema.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/events/event-payloads.ts
3
3
  /**
4
4
  * Narrow an EventPayload to a specific event type.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { describe, expectTypeOf, it } from "vitest";
3
3
  //#region src/events/event-payloads.test-d.ts
4
4
  describe("EventPayload narrowing", () => {
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { isEventType } from "./event-payloads.js";
3
3
  import { defineEvent } from "./define-event.js";
4
4
  export { defineEvent, isEventType };
@@ -1,2 +1,2 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  export {};
package/dist/fixture.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  //#region src/fixture.ts
3
3
  /**
4
4
  * Create a test fixture definition.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/hooks/index.ts
3
3
  /**
4
4
  * Normalize HookInput to extract run function and optional timeout.
@@ -1,2 +1,2 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  export {};
@@ -1,4 +1,4 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  import { step } from "./step.js";
3
3
  import { runIdempotentStep } from "@kici-dev/core/idempotency";
4
4
  //#region src/idempotent.ts
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { step } from './step.js';
2
2
  export { job } from './job.js';
3
3
  export { workflow } from './workflow.js';
4
+ export { normalizeRequireApproval } from './approval.js';
5
+ export type { RequireApproval, ApproverClause, NormalizedRequireApproval } from './approval.js';
4
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';
5
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
8
  export { onCancel, cleanup, onSuccess, onFailure, beforeStep, afterStep } from './hooks/index.js';
@@ -11,15 +13,18 @@ export { isEventType } from './rules/index.js';
11
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';
12
14
  export { validateDag } from './validation/index.js';
13
15
  export type { DagNode, DagValidationResult } from './validation/index.js';
14
- export type { SourceLocation, OutputProxy, Step, StepOptions, StepRunFn, BareStepFn, StepInput, OutputSchema, InferOutputs, Job, JobOptions, GenericInitConfig, ContainerConfig, RunsOnSelector, RunsOn, Workflow, WorkflowOptions, Registry, Trigger, DynamicJobFn, DynamicJobContext, JobOrFactory, } from './types.js';
16
+ export type { SourceLocation, OutputProxy, Step, StepOptions, 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';
15
17
  export { isDynamicJobFn, dynamicJob, getDynamicJobGroup, DYNAMIC_JOB_GROUP_TAG } from './types.js';
16
18
  export type { TaggedDynamicJobFn } from './types.js';
17
19
  export { CacheSpecSchema, normalizeCacheSpecs } from './cache-types.js';
18
20
  export type { CacheSpec, CacheInput } from './cache-types.js';
19
21
  export type { CacheRestoreResult, CacheApi } from './cache-types.js';
22
+ export { provenanceSubjectIsPath } from './provenance-types.js';
23
+ export type { AttestProvenanceOptions, AttestProvenanceResult, ProvenanceSubjectInput, } from './provenance-types.js';
20
24
  export { dynamicGroup, isDynamicGroupRef, DYNAMIC_GROUP_TAG } from './dynamic-group.js';
21
25
  export type { DynamicGroupRef } from './dynamic-group.js';
22
- export type { StepContext, Logger, WorkflowInfo, JobInfo, RepoInfo, StepSecretsTyped, KnownSecretKeys, } from './context.js';
26
+ export type { StepContext, Logger, WorkflowInfo, JobInfo, MatrixJobOutputs, RepoInfo, StepSecretsTyped, KnownSecretKeys, } from './context.js';
27
+ export { isMatrixJobOutputs } from './context.js';
23
28
  export { buildKiciApi } from './api-types.js';
24
29
  export type { KiciApi, KiciApiTransport, InfrastructureApi, InfrastructureListResult, } from './api-types.js';
25
30
  export { SecretNotFoundError } from './errors.js';
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  import { buildKiciApi } from "./api-types.js";
3
+ import { normalizeRequireApproval } from "./approval.js";
3
4
  import { CacheSpecSchema, normalizeCacheSpecs } from "./cache-types.js";
5
+ import { isMatrixJobOutputs } from "./context.js";
4
6
  import { DYNAMIC_GROUP_TAG, dynamicGroup, isDynamicGroupRef } from "./dynamic-group.js";
5
7
  import { SecretNotFoundError } from "./errors.js";
6
8
  import { fixture } from "./fixture.js";
@@ -40,6 +42,7 @@ import "./rules/index.js";
40
42
  import { validateDag } from "./validation/dag.js";
41
43
  import "./validation/index.js";
42
44
  import { DYNAMIC_JOB_GROUP_TAG, dynamicJob, getDynamicJobGroup, isDynamicJobFn } from "./types.js";
45
+ import { provenanceSubjectIsPath } from "./provenance-types.js";
43
46
  import { createStepSecrets } from "./secrets.js";
44
47
  import { isDynamicFunction, isStaticArray, isStaticObject } from "./matrix/types.js";
45
48
  import { applyIncludeExclude, expandMatrix } from "./matrix/expand.js";
@@ -48,4 +51,4 @@ import { defineEvent } from "./events/define-event.js";
48
51
  import "./events/index.js";
49
52
  import { WaitForTimeoutError, waitFor, waitForStep } from "./wait-for.js";
50
53
  import { z } from "zod";
51
- export { CacheSpecSchema, DYNAMIC_GROUP_TAG, DYNAMIC_JOB_GROUP_TAG, SecretNotFoundError, WaitForTimeoutError, afterStep, applyIncludeExclude, beforeStep, buildKiciApi, cleanup, comment, create, createJobOutputProxy, createStepOutputProxy, createStepSecrets, defineEvent, del as delete, dispatch, dynamicGroup, dynamicJob, evaluateRules, expandMatrix, fixture, fork, genericWebhook, getDynamicJobGroup, getJobOutputsMap, getStepOutputsMap, getStepRefMap, idempotent, idempotentStep, isDynamicFunction, isDynamicGroupRef, isDynamicJobFn, isEventType, isStaticArray, isStaticObject, job, jobComplete, kiciEvent, lifecycle, normalizeCacheSpecs, onCancel, onFailure, onSuccess, pr, push, release, resolveJobOutputs, resolveStepOutputs, review, reviewComment, rule, schedule, setJobOutputsMap, setStepOutputsMap, setStepRefMap, skip, star, status, step, tag, validateDag, waitFor, waitForStep, watch, webhook, workflow, workflowComplete, workflowRun, z };
54
+ export { CacheSpecSchema, DYNAMIC_GROUP_TAG, DYNAMIC_JOB_GROUP_TAG, SecretNotFoundError, WaitForTimeoutError, afterStep, applyIncludeExclude, beforeStep, buildKiciApi, cleanup, comment, create, createJobOutputProxy, createStepOutputProxy, createStepSecrets, defineEvent, del as delete, dispatch, dynamicGroup, dynamicJob, evaluateRules, expandMatrix, fixture, fork, genericWebhook, getDynamicJobGroup, getJobOutputsMap, getStepOutputsMap, getStepRefMap, idempotent, idempotentStep, isDynamicFunction, isDynamicGroupRef, isDynamicJobFn, isEventType, isMatrixJobOutputs, isStaticArray, isStaticObject, job, jobComplete, kiciEvent, lifecycle, normalizeCacheSpecs, normalizeRequireApproval, onCancel, onFailure, onSuccess, pr, provenanceSubjectIsPath, push, release, resolveJobOutputs, resolveStepOutputs, review, reviewComment, rule, schedule, setJobOutputsMap, setStepOutputsMap, setStepRefMap, skip, star, status, step, tag, validateDag, waitFor, waitForStep, watch, webhook, workflow, workflowComplete, workflowRun, z };
package/dist/job.js CHANGED
@@ -1,15 +1,22 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  import { createJobOutputProxy } from "./outputs.js";
3
3
  import { randomUUID } from "node:crypto";
4
4
  //#region src/job.ts
5
+ /** A typed preset is a `'mise'` string or a `{ mise }` object — neither carries `run`. */
6
+ function isPreset(item) {
7
+ return item === "mise" || typeof item === "object" && item !== null && "mise" in item;
8
+ }
5
9
  /**
6
- * Validate a job's `init` config. `undefined` / `false` are no-ops; every
7
- * remaining spec (one, or each element of an array) must carry a non-empty
8
- * `run` command. Throws with the offending index when validation fails.
10
+ * Validate a job's `init` config. `undefined` / `false` / `'auto'` are no-ops;
11
+ * typed presets (`'mise'` / `{ mise }`) carry no `run`, so they need no check.
12
+ * Every remaining generic spec (one, or each element of an array) must carry a
13
+ * non-empty `run` command. Throws with the offending index when validation fails.
9
14
  */
10
15
  function validateInit(init, jobName) {
11
- if (init === void 0 || init === false) return;
12
- (Array.isArray(init) ? init : [init]).forEach((spec, i) => {
16
+ if (init === void 0 || init === false || init === "auto") return;
17
+ (Array.isArray(init) ? init : [init]).forEach((item, i) => {
18
+ if (isPreset(item)) return;
19
+ const spec = item;
13
20
  if (typeof spec.run !== "string" || spec.run.trim().length === 0) throw new Error(`job('${jobName}'): init[${i}].run must be a non-empty command`);
14
21
  });
15
22
  }
@@ -52,6 +59,7 @@ function job(nameOrOptions, maybeOptions) {
52
59
  resources: options.resources,
53
60
  init: options.init,
54
61
  ...options.cache !== void 0 && { cache: options.cache },
62
+ ...options.requireApproval !== void 0 && { requireApproval: options.requireApproval },
55
63
  result: createJobOutputProxy(name)
56
64
  };
57
65
  }
@@ -1,25 +1,2 @@
1
- import type { StaticMatrixArray, StaticMatrixObject, MatrixInclude, MatrixExclude, MatrixValues } from './types.js';
2
- /**
3
- * Expand single-dimension matrix (array form) to MatrixValues array.
4
- * Each value becomes {value: string}.
5
- */
6
- export declare function expandSingleDimension(matrix: StaticMatrixArray): MatrixValues[];
7
- /**
8
- * Expand multi-dimensional matrix (object form) to MatrixValues array.
9
- * Uses fast-cartesian to compute cartesian product of all dimensions.
10
- * Dimension names are sorted for deterministic output.
11
- */
12
- export declare function expandMultiDimension(matrix: StaticMatrixObject): MatrixValues[];
13
- /**
14
- * Unified expand function that dispatches to single or multi-dimensional expansion.
15
- */
16
- export declare function expandMatrix(matrix: StaticMatrixArray | StaticMatrixObject): MatrixValues[];
17
- /**
18
- * Apply include/exclude modifications to expanded matrix combinations.
19
- * Per CONTEXT.md: exclude first (remove matching), then include (add new).
20
- *
21
- * Exclude matches if ALL specified dimensions match.
22
- * Include adds new combinations if they don't already exist.
23
- */
24
- export declare function applyIncludeExclude(expanded: MatrixValues[], include?: MatrixInclude[], exclude?: MatrixExclude[]): MatrixValues[];
1
+ export { expandSingleDimension, expandMultiDimension, expandMatrix, applyIncludeExclude, } from '@kici-dev/engine';
25
2
  //# sourceMappingURL=expand.d.ts.map
@@ -1,66 +1,3 @@
1
- import "../chunk-gOLHoazu.js";
2
- import fastCartesian from "fast-cartesian";
3
- //#region src/matrix/expand.ts
4
- /**
5
- * Expand single-dimension matrix (array form) to MatrixValues array.
6
- * Each value becomes {value: string}.
7
- */
8
- function expandSingleDimension(matrix) {
9
- return matrix.map((value) => ({ value }));
10
- }
11
- /**
12
- * Expand multi-dimensional matrix (object form) to MatrixValues array.
13
- * Uses fast-cartesian to compute cartesian product of all dimensions.
14
- * Dimension names are sorted for deterministic output.
15
- */
16
- function expandMultiDimension(matrix) {
17
- const dimensions = Object.entries(matrix);
18
- if (dimensions.length === 0) return [];
19
- dimensions.sort((a, b) => a[0].localeCompare(b[0]));
20
- const names = dimensions.map(([name]) => name);
21
- return fastCartesian(dimensions.map(([, values]) => values)).map((combo) => {
22
- const result = {};
23
- names.forEach((name, idx) => {
24
- result[name] = combo[idx];
25
- });
26
- return result;
27
- });
28
- }
29
- /**
30
- * Unified expand function that dispatches to single or multi-dimensional expansion.
31
- */
32
- function expandMatrix(matrix) {
33
- if (Array.isArray(matrix)) return expandSingleDimension(matrix);
34
- return expandMultiDimension(matrix);
35
- }
36
- /**
37
- * Apply include/exclude modifications to expanded matrix combinations.
38
- * Per CONTEXT.md: exclude first (remove matching), then include (add new).
39
- *
40
- * Exclude matches if ALL specified dimensions match.
41
- * Include adds new combinations if they don't already exist.
42
- */
43
- function applyIncludeExclude(expanded, include, exclude) {
44
- let result = [...expanded];
45
- if (exclude && exclude.length > 0) result = result.filter((combo) => {
46
- return !exclude.some((excl) => {
47
- const exclEntries = Object.entries(excl);
48
- if (exclEntries.length === 0) return false;
49
- return exclEntries.every(([key, value]) => combo[key] === value);
50
- });
51
- });
52
- if (include && include.length > 0) for (const incl of include) {
53
- const inclKeys = Object.keys(incl);
54
- if (inclKeys.length === 0) continue;
55
- if (!result.some((combo) => {
56
- const comboKeys = Object.keys(combo);
57
- if (inclKeys.length !== comboKeys.length) return false;
58
- return inclKeys.every((key) => combo[key] === incl[key]);
59
- })) result.push(incl);
60
- }
61
- return result;
62
- }
63
- //#endregion
1
+ import "../chunk-BTugEXQM.js";
2
+ import { applyIncludeExclude, expandMatrix, expandMultiDimension, expandSingleDimension } from "@kici-dev/engine";
64
3
  export { applyIncludeExclude, expandMatrix, expandMultiDimension, expandSingleDimension };
65
-
66
- //# sourceMappingURL=expand.js.map
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { isDynamicFunction, isStaticArray, isStaticObject } from "./types.js";
3
3
  import { applyIncludeExclude, expandMatrix } from "./expand.js";
4
4
  export { applyIncludeExclude, expandMatrix, isDynamicFunction, isStaticArray, isStaticObject };
@@ -1,9 +1,7 @@
1
1
  import type { $ as Shell } from 'zx';
2
2
  import type { Logger } from '../context.js';
3
- /** Single-dimension static matrix: array of values */
4
- export type StaticMatrixArray = string[];
5
- /** Multi-dimensional static matrix: named dimensions with values */
6
- export type StaticMatrixObject = Record<string, string[]>;
3
+ export type { StaticMatrixArray, StaticMatrixObject, MatrixInclude, MatrixExclude, MatrixValues, } from '@kici-dev/engine';
4
+ import type { StaticMatrixArray, StaticMatrixObject } from '@kici-dev/engine';
7
5
  /**
8
6
  * Context passed to dynamic matrix functions.
9
7
  * Uses destructured form: async ({$, ctx, log, env}) => values
@@ -36,21 +34,6 @@ export interface DynamicMatrixContext {
36
34
  export type DynamicMatrixFn = (context: DynamicMatrixContext) => Promise<StaticMatrixArray | StaticMatrixObject>;
37
35
  /** Union type for all matrix forms */
38
36
  export type Matrix = StaticMatrixArray | StaticMatrixObject | DynamicMatrixFn;
39
- /** Include entries for adding specific matrix combinations */
40
- export type MatrixInclude = Record<string, string>;
41
- /** Exclude entries for removing specific matrix combinations */
42
- export type MatrixExclude = Record<string, string>;
43
- /**
44
- * Matrix values as exposed to steps.
45
- * Single-dimension: {value: 'linux'}
46
- * Multi-dimensional: {os: 'linux', node: '18'}
47
- */
48
- export interface MatrixValues {
49
- /** Single-dimension: the value */
50
- value?: string;
51
- /** Multi-dimensional: named properties */
52
- [dimension: string]: string | undefined;
53
- }
54
37
  /** Type guard for static array matrices */
55
38
  export declare function isStaticArray(m: Matrix): m is StaticMatrixArray;
56
39
  /** Type guard for static object matrices */
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/matrix/types.ts
3
3
  /** Type guard for static array matrices */
4
4
  function isStaticArray(m) {
package/dist/outputs.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  //#region src/outputs.ts
3
3
  /**
4
4
  * Well-known string property names that should delegate to Reflect rather than throwing.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Types for `ctx.attestProvenance()` — the imperative step helper that builds,
3
+ * signs, and persists a KiCI build-provenance attestation for a produced
4
+ * artifact.
5
+ */
6
+ /**
7
+ * The artifact being attested. Either supply a precomputed digest, or a path
8
+ * (relative to the step working directory) the agent will digest with SHA-256.
9
+ */
10
+ export type ProvenanceSubjectInput = {
11
+ name: string;
12
+ digest: {
13
+ sha256?: string;
14
+ sha512?: string;
15
+ };
16
+ } | {
17
+ name: string;
18
+ path: string;
19
+ };
20
+ export interface AttestProvenanceOptions {
21
+ subject: ProvenanceSubjectInput;
22
+ /** OIDC audience for the identity token (defaults to 'kici-provenance'). */
23
+ audience?: string;
24
+ }
25
+ export interface AttestProvenanceResult {
26
+ /** Object-storage key the signed bundle was written to. */
27
+ storageKey: string;
28
+ /** Primary subject digest (lowercase hex). */
29
+ subjectDigest: string;
30
+ /** Media type of the persisted bundle. */
31
+ bundleMediaType: string;
32
+ }
33
+ /** Discriminate a path subject from a precomputed-digest subject. */
34
+ export declare function provenanceSubjectIsPath(s: ProvenanceSubjectInput): s is {
35
+ name: string;
36
+ path: string;
37
+ };
38
+ //# sourceMappingURL=provenance-types.d.ts.map
@@ -0,0 +1,10 @@
1
+ import "./chunk-BTugEXQM.js";
2
+ //#region src/provenance-types.ts
3
+ /** Discriminate a path subject from a precomputed-digest subject. */
4
+ function provenanceSubjectIsPath(s) {
5
+ return "path" in s;
6
+ }
7
+ //#endregion
8
+ export { provenanceSubjectIsPath };
9
+
10
+ //# sourceMappingURL=provenance-types.js.map
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { toErrorMessage } from "@kici-dev/core";
3
3
  //#region src/rules/evaluator.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { rule, skip } from "./rule.js";
3
3
  import { evaluateRules } from "./evaluator.js";
4
4
  import { isEventType } from "../events/event-payloads.js";
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/rules/rule.ts
3
3
  /**
4
4
  * Implementation of rule() factory.
@@ -1,2 +1,2 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  export {};