@kici-dev/sdk 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-types.d.ts +25 -1
- package/dist/api-types.js +29 -3
- package/dist/approval.js +1 -1
- package/dist/cache-types.js +1 -1
- package/dist/context.d.ts +75 -2
- package/dist/context.js +14 -2
- package/dist/dynamic-group.js +1 -1
- package/dist/errors.js +3 -1
- package/dist/events/define-event.js +1 -1
- package/dist/events/event-payloads.js +1 -1
- package/dist/events/event-payloads.test-d.js +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/types.js +1 -1
- package/dist/fixture.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/types.js +1 -1
- package/dist/idempotent.js +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.js +7 -4
- package/dist/job.js +21 -7
- package/dist/matrix/expand.d.ts +1 -24
- package/dist/matrix/expand.js +2 -65
- package/dist/matrix/index.js +1 -1
- package/dist/matrix/types.d.ts +2 -19
- package/dist/matrix/types.js +1 -1
- package/dist/needs-context.d.ts +32 -0
- package/dist/needs-context.js +44 -0
- package/dist/outputs.d.ts +12 -0
- package/dist/outputs.js +37 -2
- package/dist/provenance-types.d.ts +38 -0
- package/dist/provenance-types.js +10 -0
- package/dist/rules/evaluator.js +1 -1
- package/dist/rules/index.js +1 -1
- package/dist/rules/rule.js +1 -1
- package/dist/rules/types.js +1 -1
- package/dist/secrets.js +1 -1
- package/dist/step.js +1 -1
- package/dist/triggers/comment.js +1 -1
- package/dist/triggers/create.js +1 -1
- package/dist/triggers/delete.js +1 -1
- package/dist/triggers/dispatch.js +1 -1
- package/dist/triggers/fork.js +1 -1
- package/dist/triggers/generic-webhook.js +1 -1
- package/dist/triggers/index.js +1 -1
- package/dist/triggers/job-complete.js +1 -1
- package/dist/triggers/kici-event.js +1 -1
- package/dist/triggers/lifecycle.js +1 -1
- package/dist/triggers/pr.js +1 -1
- package/dist/triggers/push.js +1 -1
- package/dist/triggers/release.js +1 -1
- package/dist/triggers/review-comment.js +1 -1
- package/dist/triggers/review.js +1 -1
- package/dist/triggers/schedule.js +1 -1
- package/dist/triggers/star.js +1 -1
- package/dist/triggers/status.js +1 -1
- package/dist/triggers/tag.js +1 -1
- package/dist/triggers/types.js +1 -1
- package/dist/triggers/watch.js +1 -1
- package/dist/triggers/webhook.js +1 -1
- package/dist/triggers/workflow-complete.js +1 -1
- package/dist/triggers/workflow-run.js +1 -1
- package/dist/types.d.ts +162 -28
- package/dist/types.js +25 -5
- package/dist/validation/dag.js +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/wait-for.js +1 -1
- package/dist/workflow.js +1 -1
- package/package.json +4 -5
- package/sbom.spdx.json +229 -179
- /package/dist/{chunk-gOLHoazu.js → chunk-BTugEXQM.js} +0 -0
package/dist/api-types.d.ts
CHANGED
|
@@ -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
|
|
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-
|
|
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 {
|
|
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 };
|
package/dist/approval.js
CHANGED
package/dist/cache-types.js
CHANGED
package/dist/context.d.ts
CHANGED
|
@@ -19,6 +19,52 @@ export interface JobInfo {
|
|
|
19
19
|
name: string;
|
|
20
20
|
runsOn: string;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Facts about the agent a `runsOnAll` host-fanout child is pinned to, exposed
|
|
24
|
+
* as `ctx.agent`. Present only for jobs that use `runsOnAll`.
|
|
25
|
+
*/
|
|
26
|
+
export interface AgentInfo {
|
|
27
|
+
/** Hostname of the agent. */
|
|
28
|
+
host: string;
|
|
29
|
+
/** The agent's label set. */
|
|
30
|
+
labels: readonly string[];
|
|
31
|
+
/** Operating-system platform (os.platform()). */
|
|
32
|
+
platform?: string;
|
|
33
|
+
/** CPU architecture (os.arch()). */
|
|
34
|
+
arch?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Outputs of a matrix job as seen by a downstream `needs:` consumer.
|
|
38
|
+
* A downstream that consumes a matrix upstream receives this envelope instead of
|
|
39
|
+
* a flat outputs object, identically under `kici run local` and the remote path.
|
|
40
|
+
*/
|
|
41
|
+
export interface MatrixJobOutputs<T = Record<string, unknown>> {
|
|
42
|
+
/** Keyed by the combination suffix (the text inside `(...)` of the child name). */
|
|
43
|
+
byMatrix: Record<string, T>;
|
|
44
|
+
/** Last-write-wins flat merge across children, in child (name) order. */
|
|
45
|
+
merged: T;
|
|
46
|
+
}
|
|
47
|
+
/** Runtime discriminator: true when `ctx.jobOutputs(ref)` returned a matrix envelope. */
|
|
48
|
+
export declare function isMatrixJobOutputs(value: Record<string, unknown> | MatrixJobOutputs | HostJobOutputs): value is MatrixJobOutputs;
|
|
49
|
+
/**
|
|
50
|
+
* Outputs of a `runsOnAll` host-fanout job as seen by a downstream `needs:`
|
|
51
|
+
* consumer. Keyed by hostname. Unlike {@link MatrixJobOutputs}, the summary does
|
|
52
|
+
* NOT collapse to a last-write-wins scalar (a fleet footgun): `summary.outputs`
|
|
53
|
+
* is an array view across hosts, and `succeededHosts`/`failedHosts` name the
|
|
54
|
+
* per-host outcome.
|
|
55
|
+
*/
|
|
56
|
+
export interface HostJobOutputs<T = Record<string, unknown>> {
|
|
57
|
+
/** Keyed by hostname. */
|
|
58
|
+
byHost: Record<string, T>;
|
|
59
|
+
summary: {
|
|
60
|
+
succeededHosts: string[];
|
|
61
|
+
failedHosts: string[];
|
|
62
|
+
/** Per output key, every host's value (array view; never a collapsing scalar). */
|
|
63
|
+
outputs: Record<string, unknown[]>;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Runtime discriminator: true when `ctx.jobOutputs(ref)` returned a host envelope. */
|
|
67
|
+
export declare function isHostJobOutputs(value: Record<string, unknown> | MatrixJobOutputs | HostJobOutputs): value is HostJobOutputs;
|
|
22
68
|
/**
|
|
23
69
|
* Augmentable interface for known secret keys.
|
|
24
70
|
* When augmented via `kici types` (.d.ts generation), narrows get/expose key parameter.
|
|
@@ -80,6 +126,17 @@ export interface StepContext<TInputs = Record<string, unknown>> {
|
|
|
80
126
|
* - Undefined for jobs without matrix configuration
|
|
81
127
|
*/
|
|
82
128
|
matrix?: MatrixValues;
|
|
129
|
+
/**
|
|
130
|
+
* Hostname of the agent this job instance is running on.
|
|
131
|
+
* Set only for jobs that use `runsOnAll` (host fan-out — one pinned execution
|
|
132
|
+
* per matching host). Undefined for jobs without host fan-out.
|
|
133
|
+
*/
|
|
134
|
+
host?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Facts about the agent this job instance is pinned to (hostname, labels,
|
|
137
|
+
* platform, arch). Set only for jobs that use `runsOnAll`. Undefined otherwise.
|
|
138
|
+
*/
|
|
139
|
+
agent?: AgentInfo;
|
|
83
140
|
/**
|
|
84
141
|
* Raw webhook payload from the git provider.
|
|
85
142
|
* Contains the full, unmodified payload as received from the webhook.
|
|
@@ -158,14 +215,22 @@ export interface StepContext<TInputs = Record<string, unknown>> {
|
|
|
158
215
|
} | ((...args: any[]) => any)): T;
|
|
159
216
|
/**
|
|
160
217
|
* Resolve outputs from a preceding job by reference.
|
|
161
|
-
*
|
|
218
|
+
*
|
|
219
|
+
* For a plain upstream this returns the job's collected outputs (step-keyed
|
|
220
|
+
* for multi-step, flat for run shorthand). For a **matrix** upstream it returns
|
|
221
|
+
* a {@link MatrixJobOutputs} envelope `{ byMatrix, merged }` keyed by the
|
|
222
|
+
* combination suffix — identical under `kici run local` and the remote path.
|
|
223
|
+
* Use {@link isMatrixJobOutputs} (or `'byMatrix' in result`) to discriminate.
|
|
162
224
|
*
|
|
163
225
|
* @example
|
|
164
226
|
* const setupOutputs = ctx.jobOutputs(setupJob);
|
|
227
|
+
* @example
|
|
228
|
+
* const m = ctx.jobOutputs(buildMatrixJob);
|
|
229
|
+
* if (isMatrixJobOutputs(m)) console.log(m.byMatrix['linux, arm64']);
|
|
165
230
|
*/
|
|
166
231
|
jobOutputs(ref: {
|
|
167
232
|
name: string;
|
|
168
|
-
}): Record<string, unknown
|
|
233
|
+
}): Record<string, unknown> | MatrixJobOutputs | HostJobOutputs;
|
|
169
234
|
/**
|
|
170
235
|
* Publish a secret output value from this job.
|
|
171
236
|
* Secret outputs are encrypted before leaving the agent and can be consumed
|
|
@@ -188,6 +253,14 @@ export interface StepContext<TInputs = Record<string, unknown>> {
|
|
|
188
253
|
* under `spec.key` (immutable — first save wins). Scoped per org + ref.
|
|
189
254
|
*/
|
|
190
255
|
cache: import('./cache-types.js').CacheApi;
|
|
256
|
+
/**
|
|
257
|
+
* Build, sign, and persist a KiCI build-provenance attestation for a produced
|
|
258
|
+
* artifact. The in-toto statement's identity is derived from a Platform-minted
|
|
259
|
+
* identity token (unforgeable); the bundle is signed with an ephemeral key and
|
|
260
|
+
* is offline-verifiable. Pass the artifact via a precomputed digest or a path
|
|
261
|
+
* the agent digests with SHA-256.
|
|
262
|
+
*/
|
|
263
|
+
attestProvenance(opts: import('./provenance-types.js').AttestProvenanceOptions): Promise<import('./provenance-types.js').AttestProvenanceResult>;
|
|
191
264
|
}
|
|
192
265
|
export {};
|
|
193
266
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
|
|
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
|
+
/** Runtime discriminator: true when `ctx.jobOutputs(ref)` returned a host envelope. */
|
|
8
|
+
function isHostJobOutputs(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && "byHost" in value && "summary" in value && typeof value.byHost === "object";
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isHostJobOutputs, isMatrixJobOutputs };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=context.js.map
|
package/dist/dynamic-group.js
CHANGED
package/dist/errors.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import "./chunk-
|
|
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;
|
package/dist/events/index.js
CHANGED
package/dist/events/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
2
|
export {};
|
package/dist/fixture.js
CHANGED
package/dist/hooks/index.js
CHANGED
package/dist/hooks/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
2
|
export {};
|
package/dist/idempotent.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -13,21 +13,26 @@ 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, StepRunFn, BareStepFn, StepInput, OutputSchema, InferOutputs, Job, JobOptions, GenericInitConfig, ContainerConfig, RunsOnSelector, RunsOn, Workflow, WorkflowOptions, Registry, Trigger, DynamicJobFn, DynamicJobContext, JobOrFactory, } from './types.js';
|
|
17
|
-
export { isDynamicJobFn, dynamicJob, getDynamicJobGroup, DYNAMIC_JOB_GROUP_TAG } from './types.js';
|
|
18
|
-
export type { TaggedDynamicJobFn } 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';
|
|
17
|
+
export { isDynamicJobFn, dynamicJob, getDynamicJobGroup, getDynamicJobNeeds, DYNAMIC_JOB_GROUP_TAG, DYNAMIC_JOB_NEEDS_TAG, } from './types.js';
|
|
18
|
+
export type { TaggedDynamicJobFn, ResultAwareDynamicJobConfig, ResultAwareDynamicJobFn, DynamicJobNeed, } from './types.js';
|
|
19
|
+
export { buildNeedsContext } from './needs-context.js';
|
|
20
|
+
export type { UpstreamSnapshot, NeedsContext, NeedEntry, GroupNeedEntry } from './needs-context.js';
|
|
19
21
|
export { CacheSpecSchema, normalizeCacheSpecs } from './cache-types.js';
|
|
20
22
|
export type { CacheSpec, CacheInput } from './cache-types.js';
|
|
21
23
|
export type { CacheRestoreResult, CacheApi } from './cache-types.js';
|
|
24
|
+
export { provenanceSubjectIsPath } from './provenance-types.js';
|
|
25
|
+
export type { AttestProvenanceOptions, AttestProvenanceResult, ProvenanceSubjectInput, } from './provenance-types.js';
|
|
22
26
|
export { dynamicGroup, isDynamicGroupRef, DYNAMIC_GROUP_TAG } from './dynamic-group.js';
|
|
23
27
|
export type { DynamicGroupRef } from './dynamic-group.js';
|
|
24
|
-
export type { StepContext, Logger, WorkflowInfo, JobInfo, RepoInfo, StepSecretsTyped, KnownSecretKeys, } from './context.js';
|
|
28
|
+
export type { StepContext, Logger, WorkflowInfo, JobInfo, AgentInfo, MatrixJobOutputs, HostJobOutputs, RepoInfo, StepSecretsTyped, KnownSecretKeys, } from './context.js';
|
|
29
|
+
export { isMatrixJobOutputs, isHostJobOutputs } from './context.js';
|
|
25
30
|
export { buildKiciApi } from './api-types.js';
|
|
26
31
|
export type { KiciApi, KiciApiTransport, InfrastructureApi, InfrastructureListResult, } from './api-types.js';
|
|
27
32
|
export { SecretNotFoundError } from './errors.js';
|
|
28
33
|
export { createStepSecrets } from './secrets.js';
|
|
29
34
|
export type { StepSecrets, TrackedStepSecrets, SecretMeta, SecretFileOptions, MountedFile, StepSecretsFileHost, StepSecretsFileWiring, StepSecretsHandle, StepSecretMountKind, StepSecretMountRecord, } from './secrets.js';
|
|
30
|
-
export { createStepOutputProxy, createJobOutputProxy, resolveStepOutputs, resolveJobOutputs, setStepOutputsMap, setJobOutputsMap, setStepRefMap, getStepOutputsMap, getJobOutputsMap, getStepRefMap, } from './outputs.js';
|
|
35
|
+
export { createStepOutputProxy, createJobOutputProxy, createSnapshotOutputProxy, resolveStepOutputs, resolveJobOutputs, setStepOutputsMap, setJobOutputsMap, setStepRefMap, getStepOutputsMap, getJobOutputsMap, getStepRefMap, } from './outputs.js';
|
|
31
36
|
export type { OutputsMap, StepRefMap } from './outputs.js';
|
|
32
37
|
export type { StaticMatrixArray, StaticMatrixObject, DynamicMatrixFn, DynamicMatrixContext, Matrix, MatrixInclude, MatrixExclude, MatrixValues, } from './matrix/index.js';
|
|
33
38
|
export { isStaticArray, isStaticObject, isDynamicFunction } from './matrix/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-BTugEXQM.js";
|
|
2
2
|
import { buildKiciApi } from "./api-types.js";
|
|
3
3
|
import { normalizeRequireApproval } from "./approval.js";
|
|
4
4
|
import { CacheSpecSchema, normalizeCacheSpecs } from "./cache-types.js";
|
|
5
|
+
import { isHostJobOutputs, isMatrixJobOutputs } from "./context.js";
|
|
5
6
|
import { DYNAMIC_GROUP_TAG, dynamicGroup, isDynamicGroupRef } from "./dynamic-group.js";
|
|
6
7
|
import { SecretNotFoundError } from "./errors.js";
|
|
7
8
|
import { fixture } from "./fixture.js";
|
|
8
|
-
import { createJobOutputProxy, createStepOutputProxy, getJobOutputsMap, getStepOutputsMap, getStepRefMap, resolveJobOutputs, resolveStepOutputs, setJobOutputsMap, setStepOutputsMap, setStepRefMap } from "./outputs.js";
|
|
9
|
+
import { createJobOutputProxy, createSnapshotOutputProxy, createStepOutputProxy, getJobOutputsMap, getStepOutputsMap, getStepRefMap, resolveJobOutputs, resolveStepOutputs, setJobOutputsMap, setStepOutputsMap, setStepRefMap } from "./outputs.js";
|
|
9
10
|
import { step } from "./step.js";
|
|
10
11
|
import { idempotent, idempotentStep } from "./idempotent.js";
|
|
11
12
|
import { job } from "./job.js";
|
|
@@ -40,7 +41,9 @@ import { isEventType } from "./events/event-payloads.js";
|
|
|
40
41
|
import "./rules/index.js";
|
|
41
42
|
import { validateDag } from "./validation/dag.js";
|
|
42
43
|
import "./validation/index.js";
|
|
43
|
-
import { DYNAMIC_JOB_GROUP_TAG, dynamicJob, getDynamicJobGroup, isDynamicJobFn } from "./types.js";
|
|
44
|
+
import { DYNAMIC_JOB_GROUP_TAG, DYNAMIC_JOB_NEEDS_TAG, dynamicJob, getDynamicJobGroup, getDynamicJobNeeds, isDynamicJobFn } from "./types.js";
|
|
45
|
+
import { buildNeedsContext } from "./needs-context.js";
|
|
46
|
+
import { provenanceSubjectIsPath } from "./provenance-types.js";
|
|
44
47
|
import { createStepSecrets } from "./secrets.js";
|
|
45
48
|
import { isDynamicFunction, isStaticArray, isStaticObject } from "./matrix/types.js";
|
|
46
49
|
import { applyIncludeExclude, expandMatrix } from "./matrix/expand.js";
|
|
@@ -49,4 +52,4 @@ import { defineEvent } from "./events/define-event.js";
|
|
|
49
52
|
import "./events/index.js";
|
|
50
53
|
import { WaitForTimeoutError, waitFor, waitForStep } from "./wait-for.js";
|
|
51
54
|
import { z } from "zod";
|
|
52
|
-
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, normalizeRequireApproval, 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 };
|
|
55
|
+
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, 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-
|
|
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;
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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((
|
|
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
|
}
|
|
@@ -25,10 +32,17 @@ function job(nameOrOptions, maybeOptions) {
|
|
|
25
32
|
steps = [options.run];
|
|
26
33
|
}
|
|
27
34
|
validateInit(options.init, name);
|
|
35
|
+
if (options.runsOn !== void 0 && options.runsOnAll !== void 0) throw new Error(`job('${name}'): runsOn and runsOnAll are mutually exclusive`);
|
|
36
|
+
if (options.runsOn === void 0 && options.runsOnAll === void 0) throw new Error(`job('${name}'): one of runsOn or runsOnAll is required`);
|
|
37
|
+
if (options.onUnreachable !== void 0 && options.runsOnAll === void 0) console.warn(`[kici] job('${name}'): onUnreachable is ignored without runsOnAll`);
|
|
28
38
|
return {
|
|
29
39
|
_tag: "Job",
|
|
30
40
|
name,
|
|
31
|
-
runsOn: options.runsOn,
|
|
41
|
+
...options.runsOn !== void 0 && { runsOn: options.runsOn },
|
|
42
|
+
...options.runsOnAll !== void 0 && { runsOnAll: options.runsOnAll },
|
|
43
|
+
...options.onUnreachable !== void 0 && { onUnreachable: options.onUnreachable },
|
|
44
|
+
...options.maxParallel !== void 0 && { maxParallel: options.maxParallel },
|
|
45
|
+
...options.failFast !== void 0 && { failFast: options.failFast },
|
|
32
46
|
steps,
|
|
33
47
|
needs: options.needs,
|
|
34
48
|
rules: options.rules,
|
package/dist/matrix/expand.d.ts
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
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
|
package/dist/matrix/expand.js
CHANGED
|
@@ -1,66 +1,3 @@
|
|
|
1
|
-
import "../chunk-
|
|
2
|
-
import
|
|
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
|
package/dist/matrix/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../chunk-
|
|
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 };
|
package/dist/matrix/types.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { $ as Shell } from 'zx';
|
|
2
2
|
import type { Logger } from '../context.js';
|
|
3
|
-
|
|
4
|
-
|
|
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 */
|
package/dist/matrix/types.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { OutputProxy, DynamicJobNeed } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Frozen snapshot of upstream outputs, captured once at first eval of a
|
|
4
|
+
* result-aware dynamic generator and replayed unchanged on re-eval.
|
|
5
|
+
*
|
|
6
|
+
* - `jobs` maps an upstream job name to its outputs record.
|
|
7
|
+
* - `groups` maps a dynamic group name to its ordered member job names.
|
|
8
|
+
*/
|
|
9
|
+
export interface UpstreamSnapshot {
|
|
10
|
+
jobs: Record<string, Record<string, unknown>>;
|
|
11
|
+
groups: Record<string, string[]>;
|
|
12
|
+
}
|
|
13
|
+
/** One entry in the array exposed for a `dynamicGroup(...)` need. */
|
|
14
|
+
export interface GroupNeedEntry {
|
|
15
|
+
name: string;
|
|
16
|
+
result: OutputProxy<any>;
|
|
17
|
+
}
|
|
18
|
+
/** A single-job need exposes `{ result }`; a group need exposes an ordered array. */
|
|
19
|
+
export type NeedEntry = {
|
|
20
|
+
result: OutputProxy<any>;
|
|
21
|
+
} | GroupNeedEntry[];
|
|
22
|
+
/** The resolved `ctx.needs` map keyed by job name or group name. */
|
|
23
|
+
export type NeedsContext = Record<string, NeedEntry>;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve declared needs against a frozen snapshot into the `ctx.needs` map.
|
|
26
|
+
*
|
|
27
|
+
* - A single static/named-job need resolves to `{ result: <proxy over jobs[name]> }`.
|
|
28
|
+
* - A `dynamicGroup(...)` need resolves to an ordered array of `{ name, result }`,
|
|
29
|
+
* one entry per group member in the snapshot's deterministic eval order.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildNeedsContext(snapshot: UpstreamSnapshot, declaredNeeds: ReadonlyArray<DynamicJobNeed>): NeedsContext;
|
|
32
|
+
//# sourceMappingURL=needs-context.d.ts.map
|