@kici-dev/engine 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +1 -6
- package/dist/audit/access-log-policy.d.ts +97 -0
- package/dist/audit/access-log-policy.js +195 -0
- package/dist/audit/activity.d.ts +156 -0
- package/dist/audit/activity.js +175 -0
- package/dist/audit/retention-policy.d.ts +157 -0
- package/dist/audit/retention-policy.js +364 -0
- package/dist/bundler/index.d.ts +3 -0
- package/dist/bundler/index.js +3 -0
- package/dist/bundler/rolldown-config.d.ts +41 -0
- package/dist/bundler/rolldown-config.js +40 -0
- package/dist/chunk-gOLHoazu.js +4 -0
- package/dist/env/environment-allowlist.d.ts +45 -0
- package/dist/env/environment-allowlist.js +69 -0
- package/dist/environment/index.d.ts +3 -0
- package/dist/environment/index.js +3 -0
- package/dist/environment/scope-resolver.d.ts +35 -0
- package/dist/environment/scope-resolver.js +77 -0
- package/dist/environment/types.d.ts +98 -0
- package/dist/environment/types.js +2 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +45 -0
- package/dist/labels.d.ts +106 -0
- package/dist/labels.js +162 -0
- package/dist/metrics/metric-catalog.generated.d.ts +400 -0
- package/dist/metrics/metric-catalog.generated.js +510 -0
- package/dist/protocol/dashboard-global-workflows.d.ts +9 -0
- package/dist/protocol/dashboard-global-workflows.js +3 -0
- package/dist/protocol/event-log-payload.d.ts +16 -0
- package/dist/protocol/event-log-payload.js +21 -0
- package/dist/protocol/messages/access-log.d.ts +545 -0
- package/dist/protocol/messages/access-log.js +175 -0
- package/dist/protocol/messages/actor.d.ts +100 -0
- package/dist/protocol/messages/actor.js +139 -0
- package/dist/protocol/messages/auth.d.ts +25 -0
- package/dist/protocol/messages/auth.js +36 -0
- package/dist/protocol/messages/browser.d.ts +369 -0
- package/dist/protocol/messages/browser.js +225 -0
- package/dist/protocol/messages/capabilities.d.ts +46 -0
- package/dist/protocol/messages/capabilities.js +42 -0
- package/dist/protocol/messages/common.d.ts +53 -0
- package/dist/protocol/messages/common.js +55 -0
- package/dist/protocol/messages/dashboard-global-workflows.d.ts +166 -0
- package/dist/protocol/messages/dashboard-global-workflows.js +80 -0
- package/dist/protocol/messages/dashboard.d.ts +4068 -0
- package/dist/protocol/messages/dashboard.js +1237 -0
- package/dist/protocol/messages/event-log.d.ts +49 -0
- package/dist/protocol/messages/event-log.js +45 -0
- package/dist/protocol/messages/execution-status.d.ts +164 -0
- package/dist/protocol/messages/execution-status.js +166 -0
- package/dist/protocol/messages/join.d.ts +18 -0
- package/dist/protocol/messages/join.js +28 -0
- package/dist/protocol/messages/log-pull.d.ts +27 -0
- package/dist/protocol/messages/log-pull.js +36 -0
- package/dist/protocol/messages/observe.d.ts +75 -0
- package/dist/protocol/messages/observe.js +70 -0
- package/dist/protocol/messages/orchestrator-agent.d.ts +606 -0
- package/dist/protocol/messages/orchestrator-agent.js +481 -0
- package/dist/protocol/messages/peer.d.ts +795 -0
- package/dist/protocol/messages/peer.js +372 -0
- package/dist/protocol/messages/platform-orchestrator.d.ts +1888 -0
- package/dist/protocol/messages/platform-orchestrator.js +379 -0
- package/dist/protocol/messages/run-events.d.ts +155 -0
- package/dist/protocol/messages/run-events.js +115 -0
- package/dist/protocol/messages/saas-orchestrator.d.ts +2179 -0
- package/dist/protocol/messages/source-registration.d.ts +103 -0
- package/dist/protocol/messages/source-registration.js +109 -0
- package/dist/protocol/messages/test-run.d.ts +59 -0
- package/dist/protocol/messages/test-run.js +52 -0
- package/dist/protocol/version.d.ts +12 -0
- package/dist/protocol/version.js +17 -0
- package/dist/provider/changed-files-fetcher.d.ts +24 -0
- package/dist/provider/changed-files-fetcher.js +2 -0
- package/dist/provider/check-run-conclusion.d.ts +15 -0
- package/dist/provider/check-run-conclusion.js +19 -0
- package/dist/provider/check-status-poster.d.ts +15 -0
- package/dist/provider/check-status-poster.js +2 -0
- package/dist/provider/clone-token-provider.d.ts +58 -0
- package/dist/provider/clone-token-provider.js +2 -0
- package/dist/provider/contributor-resolver.d.ts +22 -0
- package/dist/provider/contributor-resolver.js +2 -0
- package/dist/provider/index.d.ts +23 -0
- package/dist/provider/index.js +3 -0
- package/dist/provider/lock-file-fetcher.d.ts +24 -0
- package/dist/provider/lock-file-fetcher.js +2 -0
- package/dist/provider/repo-url-builder.d.ts +35 -0
- package/dist/provider/repo-url-builder.js +2 -0
- package/dist/provider/types.d.ts +9 -0
- package/dist/provider/types.js +2 -0
- package/dist/provider/webhook-normalizer.d.ts +163 -0
- package/dist/provider/webhook-normalizer.js +2 -0
- package/dist/registration/registerable-trigger-type.d.ts +52 -0
- package/dist/registration/registerable-trigger-type.js +56 -0
- package/dist/scaler/resource-types.d.ts +90 -0
- package/dist/scaler/resource-types.js +99 -0
- package/dist/scaler/scaler-backend-type.d.ts +16 -0
- package/dist/scaler/scaler-backend-type.js +20 -0
- package/dist/secrets/index.d.ts +7 -0
- package/dist/secrets/index.js +2 -0
- package/dist/secrets/types.d.ts +138 -0
- package/dist/secrets/types.js +2 -0
- package/dist/state-machine/index.d.ts +2 -0
- package/dist/state-machine/index.js +3 -0
- package/dist/state-machine/machine.d.ts +34 -0
- package/dist/state-machine/machine.js +103 -0
- package/dist/state-machine/types.d.ts +34 -0
- package/dist/state-machine/types.js +15 -0
- package/dist/trigger/decision-trace.d.ts +41 -0
- package/dist/trigger/decision-trace.js +30 -0
- package/dist/trigger/jsonpath-matcher.d.ts +27 -0
- package/dist/trigger/jsonpath-matcher.js +92 -0
- package/dist/trigger/matcher.d.ts +29 -0
- package/dist/trigger/matcher.js +704 -0
- package/dist/trigger/trigger-event-type.d.ts +14 -0
- package/dist/trigger/trigger-event-type.js +66 -0
- package/dist/trigger/types.d.ts +524 -0
- package/dist/trigger/types.js +48 -0
- package/dist/webhook/signature.d.ts +15 -0
- package/dist/webhook/signature.js +32 -0
- package/dist/ws/close-codes.d.ts +28 -0
- package/dist/ws/close-codes.js +33 -0
- package/dist/ws/rate-limiter.d.ts +86 -0
- package/dist/ws/rate-limiter.js +136 -0
- package/dist/ws/ws-like.d.ts +12 -0
- package/dist/ws/ws-like.js +2 -0
- package/package.json +54 -6
- package/sbom.spdx.json +202 -0
- package/index.js +0 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical trigger event types with human-readable metadata.
|
|
3
|
+
*
|
|
4
|
+
* These correspond to SimulatedEvent.type values produced by normalizers,
|
|
5
|
+
* plus 'rerun' for re-run events. Adding a new event type here forces
|
|
6
|
+
* compile-time failures in any exhaustive Record<TriggerEventType, ...>
|
|
7
|
+
* (e.g., the dashboard icon map).
|
|
8
|
+
*/
|
|
9
|
+
export declare const TRIGGER_EVENT_TYPES: readonly ["pull_request", "push", "tag", "comment", "review", "review_comment", "release", "dispatch", "create", "delete", "status", "workflow_run", "fork", "star", "watch", "webhook", "kici_event", "workflow_complete", "job_complete", "generic_webhook", "schedule", "lifecycle", "rerun", "manual_schedule"];
|
|
10
|
+
export type TriggerEventType = (typeof TRIGGER_EVENT_TYPES)[number];
|
|
11
|
+
export declare const TRIGGER_EVENT_META: Record<TriggerEventType, {
|
|
12
|
+
label: string;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=trigger-event-type.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "../chunk-gOLHoazu.js";
|
|
2
|
+
//#region src/trigger/trigger-event-type.ts
|
|
3
|
+
/**
|
|
4
|
+
* Canonical trigger event types with human-readable metadata.
|
|
5
|
+
*
|
|
6
|
+
* These correspond to SimulatedEvent.type values produced by normalizers,
|
|
7
|
+
* plus 'rerun' for re-run events. Adding a new event type here forces
|
|
8
|
+
* compile-time failures in any exhaustive Record<TriggerEventType, ...>
|
|
9
|
+
* (e.g., the dashboard icon map).
|
|
10
|
+
*/
|
|
11
|
+
const TRIGGER_EVENT_TYPES = [
|
|
12
|
+
"pull_request",
|
|
13
|
+
"push",
|
|
14
|
+
"tag",
|
|
15
|
+
"comment",
|
|
16
|
+
"review",
|
|
17
|
+
"review_comment",
|
|
18
|
+
"release",
|
|
19
|
+
"dispatch",
|
|
20
|
+
"create",
|
|
21
|
+
"delete",
|
|
22
|
+
"status",
|
|
23
|
+
"workflow_run",
|
|
24
|
+
"fork",
|
|
25
|
+
"star",
|
|
26
|
+
"watch",
|
|
27
|
+
"webhook",
|
|
28
|
+
"kici_event",
|
|
29
|
+
"workflow_complete",
|
|
30
|
+
"job_complete",
|
|
31
|
+
"generic_webhook",
|
|
32
|
+
"schedule",
|
|
33
|
+
"lifecycle",
|
|
34
|
+
"rerun",
|
|
35
|
+
"manual_schedule"
|
|
36
|
+
];
|
|
37
|
+
const TRIGGER_EVENT_META = {
|
|
38
|
+
pull_request: { label: "Pull request" },
|
|
39
|
+
push: { label: "Push" },
|
|
40
|
+
tag: { label: "Tag" },
|
|
41
|
+
comment: { label: "Comment" },
|
|
42
|
+
review: { label: "Review" },
|
|
43
|
+
review_comment: { label: "Review comment" },
|
|
44
|
+
release: { label: "Release" },
|
|
45
|
+
dispatch: { label: "Dispatch" },
|
|
46
|
+
create: { label: "Create" },
|
|
47
|
+
delete: { label: "Delete" },
|
|
48
|
+
status: { label: "Status" },
|
|
49
|
+
workflow_run: { label: "Workflow run" },
|
|
50
|
+
fork: { label: "Fork" },
|
|
51
|
+
star: { label: "Star" },
|
|
52
|
+
watch: { label: "Watch" },
|
|
53
|
+
webhook: { label: "Webhook" },
|
|
54
|
+
kici_event: { label: "KiCI event" },
|
|
55
|
+
workflow_complete: { label: "Workflow complete" },
|
|
56
|
+
job_complete: { label: "Job complete" },
|
|
57
|
+
generic_webhook: { label: "Generic webhook" },
|
|
58
|
+
schedule: { label: "Schedule" },
|
|
59
|
+
lifecycle: { label: "Lifecycle" },
|
|
60
|
+
rerun: { label: "Re-run" },
|
|
61
|
+
manual_schedule: { label: "Manual schedule" }
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { TRIGGER_EVENT_META, TRIGGER_EVENT_TYPES };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=trigger-event-type.js.map
|
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lock file types for the trigger matching engine.
|
|
3
|
+
* Single source of truth -- replaces local copies in @kici-dev/compiler and @kici-dev/orchestrator.
|
|
4
|
+
* Schema version 4: adds 4 internal event routing trigger types (kici_event, workflow_complete,
|
|
5
|
+
* job_complete, generic_webhook).
|
|
6
|
+
* Schema version 6: replaces job-level contexts with environment/env/concurrencyGroup.
|
|
7
|
+
* Schema version 8: adds runsOn polymorphic type (string | string[] | selector) and excludeLabels.
|
|
8
|
+
* Schema version 9: adds repos/notRepos repo pattern fields to git-event triggers for global workflow matching.
|
|
9
|
+
* Schema version 10: removes notRepos/notPaths fields, negative patterns use ! prefix in repos/paths arrays.
|
|
10
|
+
* Schema version 11: adds LockInlineValue type for pure function inline evaluation.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { ProviderType } from '../provider/types.js';
|
|
14
|
+
/** Schema version - increment on breaking changes */
|
|
15
|
+
export declare const SCHEMA_VERSION: 12;
|
|
16
|
+
/**
|
|
17
|
+
* Source file reference with meaningful path.
|
|
18
|
+
* Format: file is relative path from git root, export uses hash syntax.
|
|
19
|
+
*/
|
|
20
|
+
export interface LockSource {
|
|
21
|
+
/** Relative path from repo root: .kici/workflows/ci.ts */
|
|
22
|
+
readonly file: string;
|
|
23
|
+
/** Export name with hash syntax: #build or #default or #default[0] */
|
|
24
|
+
readonly export: string;
|
|
25
|
+
}
|
|
26
|
+
/** Branch pattern in lock file */
|
|
27
|
+
export interface LockBranchPattern {
|
|
28
|
+
readonly type: 'glob' | 'regex';
|
|
29
|
+
readonly pattern: string;
|
|
30
|
+
readonly flags?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* PR trigger in lock file.
|
|
34
|
+
* Optimized for orchestrator event matching - flat structure with all filters accessible.
|
|
35
|
+
*/
|
|
36
|
+
export interface LockPrTrigger {
|
|
37
|
+
readonly _type: 'pr';
|
|
38
|
+
readonly events: readonly string[];
|
|
39
|
+
readonly targetBranches: readonly LockBranchPattern[];
|
|
40
|
+
readonly sourceBranches: readonly LockBranchPattern[];
|
|
41
|
+
readonly paths: readonly string[];
|
|
42
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Push trigger in lock file.
|
|
46
|
+
* Optimized for orchestrator event matching - flat structure with all filters accessible.
|
|
47
|
+
*/
|
|
48
|
+
export interface LockPushTrigger {
|
|
49
|
+
readonly _type: 'push';
|
|
50
|
+
readonly branches: readonly LockBranchPattern[];
|
|
51
|
+
readonly paths: readonly string[];
|
|
52
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Tag trigger in lock file.
|
|
56
|
+
* Matches tag push events. Reuses LockBranchPattern for tag name patterns.
|
|
57
|
+
*/
|
|
58
|
+
export interface LockTagTrigger {
|
|
59
|
+
readonly _type: 'tag';
|
|
60
|
+
readonly patterns: readonly LockBranchPattern[];
|
|
61
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Comment trigger in lock file.
|
|
65
|
+
* Matches issue_comment and pull_request_review_comment events.
|
|
66
|
+
*/
|
|
67
|
+
export interface LockCommentTrigger {
|
|
68
|
+
readonly _type: 'comment';
|
|
69
|
+
readonly actions: readonly string[];
|
|
70
|
+
readonly source?: 'issue' | 'pr';
|
|
71
|
+
readonly bodyMatch?: {
|
|
72
|
+
readonly pattern: string;
|
|
73
|
+
readonly type: 'glob' | 'regex';
|
|
74
|
+
readonly flags?: string;
|
|
75
|
+
};
|
|
76
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Review trigger in lock file.
|
|
80
|
+
* Matches pull_request_review events.
|
|
81
|
+
*/
|
|
82
|
+
export interface LockReviewTrigger {
|
|
83
|
+
readonly _type: 'review';
|
|
84
|
+
readonly actions: readonly string[];
|
|
85
|
+
readonly states: readonly string[];
|
|
86
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Review comment trigger in lock file.
|
|
90
|
+
* Matches pull_request_review_comment events.
|
|
91
|
+
*/
|
|
92
|
+
export interface LockReviewCommentTrigger {
|
|
93
|
+
readonly _type: 'review_comment';
|
|
94
|
+
readonly actions: readonly string[];
|
|
95
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Release trigger in lock file.
|
|
99
|
+
* Matches release events (published, created, etc.).
|
|
100
|
+
*/
|
|
101
|
+
export interface LockReleaseTrigger {
|
|
102
|
+
readonly _type: 'release';
|
|
103
|
+
readonly actions: readonly string[];
|
|
104
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Dispatch trigger in lock file.
|
|
108
|
+
* Matches repository_dispatch events by type.
|
|
109
|
+
*/
|
|
110
|
+
export interface LockDispatchTrigger {
|
|
111
|
+
readonly _type: 'dispatch';
|
|
112
|
+
readonly types: readonly string[];
|
|
113
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Create trigger in lock file.
|
|
117
|
+
* Matches create events (branch or tag creation).
|
|
118
|
+
*/
|
|
119
|
+
export interface LockCreateTrigger {
|
|
120
|
+
readonly _type: 'create';
|
|
121
|
+
readonly refTypes: readonly ('branch' | 'tag')[];
|
|
122
|
+
readonly patterns: readonly LockBranchPattern[];
|
|
123
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Delete trigger in lock file.
|
|
127
|
+
* Matches delete events (branch or tag deletion).
|
|
128
|
+
*/
|
|
129
|
+
export interface LockDeleteTrigger {
|
|
130
|
+
readonly _type: 'delete';
|
|
131
|
+
readonly refTypes: readonly ('branch' | 'tag')[];
|
|
132
|
+
readonly patterns: readonly LockBranchPattern[];
|
|
133
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Status trigger in lock file.
|
|
137
|
+
* Matches status events (commit status updates).
|
|
138
|
+
*/
|
|
139
|
+
export interface LockStatusTrigger {
|
|
140
|
+
readonly _type: 'status';
|
|
141
|
+
readonly contexts: readonly string[];
|
|
142
|
+
readonly states: readonly string[];
|
|
143
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Workflow run trigger in lock file.
|
|
147
|
+
* Matches workflow_run events.
|
|
148
|
+
*/
|
|
149
|
+
export interface LockWorkflowRunTrigger {
|
|
150
|
+
readonly _type: 'workflow_run';
|
|
151
|
+
readonly actions: readonly string[];
|
|
152
|
+
readonly workflows: readonly string[];
|
|
153
|
+
readonly conclusions: readonly string[];
|
|
154
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Fork trigger in lock file.
|
|
158
|
+
* Matches fork events. No filter fields.
|
|
159
|
+
*/
|
|
160
|
+
export interface LockForkTrigger {
|
|
161
|
+
readonly _type: 'fork';
|
|
162
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Star trigger in lock file.
|
|
166
|
+
* Matches star (watch) events.
|
|
167
|
+
*/
|
|
168
|
+
export interface LockStarTrigger {
|
|
169
|
+
readonly _type: 'star';
|
|
170
|
+
readonly actions: readonly string[];
|
|
171
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Watch trigger in lock file.
|
|
175
|
+
* Matches watch events (GitHub "started watching" activity).
|
|
176
|
+
*/
|
|
177
|
+
export interface LockWatchTrigger {
|
|
178
|
+
readonly _type: 'watch';
|
|
179
|
+
readonly actions: readonly string[];
|
|
180
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Generic webhook trigger in lock file.
|
|
184
|
+
* Matches arbitrary webhook events not covered by specific trigger types.
|
|
185
|
+
*/
|
|
186
|
+
export interface LockWebhookTrigger {
|
|
187
|
+
readonly _type: 'webhook';
|
|
188
|
+
readonly events: readonly string[];
|
|
189
|
+
readonly actions: readonly string[];
|
|
190
|
+
readonly repos?: readonly LockBranchPattern[];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* KiCI internal event trigger in lock file.
|
|
194
|
+
* Matches custom named events emitted via ctx.emit() from within steps.
|
|
195
|
+
* Supports JSONPath payload matching via match/not expressions.
|
|
196
|
+
*/
|
|
197
|
+
export interface LockKiciEventTrigger {
|
|
198
|
+
readonly _type: 'kici_event';
|
|
199
|
+
readonly eventName: string;
|
|
200
|
+
readonly match?: Record<string, unknown>;
|
|
201
|
+
readonly not?: Record<string, unknown>;
|
|
202
|
+
readonly source?: string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Workflow completion trigger in lock file.
|
|
206
|
+
* Matches when a workflow finishes execution (success, failed, cancelled).
|
|
207
|
+
*/
|
|
208
|
+
export interface LockWorkflowCompleteTrigger {
|
|
209
|
+
readonly _type: 'workflow_complete';
|
|
210
|
+
readonly name?: string;
|
|
211
|
+
readonly status?: readonly string[];
|
|
212
|
+
readonly source?: string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Job completion trigger in lock file.
|
|
216
|
+
* Matches when a specific job within a workflow finishes execution.
|
|
217
|
+
*/
|
|
218
|
+
export interface LockJobCompleteTrigger {
|
|
219
|
+
readonly _type: 'job_complete';
|
|
220
|
+
readonly workflow?: string;
|
|
221
|
+
readonly job?: string;
|
|
222
|
+
readonly status?: readonly string[];
|
|
223
|
+
readonly source?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Auth configuration for generic webhook verification in lock file.
|
|
227
|
+
*/
|
|
228
|
+
export interface LockGenericWebhookAuth {
|
|
229
|
+
readonly method: 'hmac-sha256' | 'api-key';
|
|
230
|
+
readonly secret: string;
|
|
231
|
+
/** For HMAC: header containing signature */
|
|
232
|
+
readonly signatureHeader?: string;
|
|
233
|
+
/** For API key: header to check (default 'authorization') */
|
|
234
|
+
readonly header?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Generic webhook ingestion trigger in lock file.
|
|
238
|
+
* Matches webhooks from non-Git sources (external services, APIs, etc.).
|
|
239
|
+
* Supports JSONPath payload matching via match/not expressions.
|
|
240
|
+
*/
|
|
241
|
+
export interface LockGenericWebhookTrigger {
|
|
242
|
+
readonly _type: 'generic_webhook';
|
|
243
|
+
readonly source: string;
|
|
244
|
+
readonly events?: readonly string[];
|
|
245
|
+
readonly match?: Record<string, unknown>;
|
|
246
|
+
readonly not?: Record<string, unknown>;
|
|
247
|
+
readonly auth?: LockGenericWebhookAuth;
|
|
248
|
+
/** URL path pattern for routing */
|
|
249
|
+
readonly path?: string;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Schedule trigger in lock file.
|
|
253
|
+
* Matches cron-based events fired by the scheduler.
|
|
254
|
+
*/
|
|
255
|
+
export interface LockScheduleTrigger {
|
|
256
|
+
readonly _type: 'schedule';
|
|
257
|
+
readonly cronExpression: string;
|
|
258
|
+
readonly timezone: string;
|
|
259
|
+
readonly description?: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Lifecycle trigger in lock file.
|
|
263
|
+
* Matches cross-workflow lifecycle events (workflow_complete, job_complete, etc.).
|
|
264
|
+
*/
|
|
265
|
+
export interface LockLifecycleTrigger {
|
|
266
|
+
readonly _type: 'lifecycle';
|
|
267
|
+
readonly events: readonly string[];
|
|
268
|
+
readonly sources?: readonly string[];
|
|
269
|
+
readonly description?: string;
|
|
270
|
+
}
|
|
271
|
+
/** Union of all trigger types */
|
|
272
|
+
export type LockTrigger = LockPrTrigger | LockPushTrigger | LockTagTrigger | LockCommentTrigger | LockReviewTrigger | LockReviewCommentTrigger | LockReleaseTrigger | LockDispatchTrigger | LockCreateTrigger | LockDeleteTrigger | LockStatusTrigger | LockWorkflowRunTrigger | LockForkTrigger | LockStarTrigger | LockWatchTrigger | LockWebhookTrigger | LockKiciEventTrigger | LockWorkflowCompleteTrigger | LockJobCompleteTrigger | LockGenericWebhookTrigger | LockScheduleTrigger | LockLifecycleTrigger;
|
|
273
|
+
/**
|
|
274
|
+
* Matrix configuration in lock file.
|
|
275
|
+
* Static matrices are expanded at orchestrator, dynamic at agent runtime.
|
|
276
|
+
*/
|
|
277
|
+
export interface LockMatrix {
|
|
278
|
+
readonly _type: 'static' | 'dynamic';
|
|
279
|
+
/** Static values (only when _type is 'static') */
|
|
280
|
+
readonly values?: Record<string, readonly string[]> | readonly string[];
|
|
281
|
+
/** Source reference for dynamic matrices */
|
|
282
|
+
readonly source?: {
|
|
283
|
+
readonly file: string;
|
|
284
|
+
readonly jobName: string;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Rule reference in lock file.
|
|
289
|
+
* Rules are always dynamic - they contain check functions evaluated at agent runtime.
|
|
290
|
+
*/
|
|
291
|
+
export interface LockRule {
|
|
292
|
+
readonly _type: 'dynamic';
|
|
293
|
+
readonly label: string;
|
|
294
|
+
readonly source: {
|
|
295
|
+
readonly file: string;
|
|
296
|
+
readonly index: number;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Step in lock file.
|
|
301
|
+
* Minimal representation - agents load full step functions from source.
|
|
302
|
+
*/
|
|
303
|
+
export interface LockStep {
|
|
304
|
+
readonly name: string;
|
|
305
|
+
readonly hasOutputs: boolean;
|
|
306
|
+
/** When true, job proceeds even if this step fails. */
|
|
307
|
+
readonly continueOnError?: boolean;
|
|
308
|
+
/** Step-level timeout in milliseconds. */
|
|
309
|
+
readonly timeout?: number;
|
|
310
|
+
/** Source location of the step() call in the original TypeScript file (for annotations). */
|
|
311
|
+
readonly sourceLocation?: {
|
|
312
|
+
readonly file: string;
|
|
313
|
+
readonly line: number;
|
|
314
|
+
readonly column: number;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Inline expression value for pure dynamic functions.
|
|
319
|
+
* The compiler serializes pure functions as { _type: 'inline', expression: '(event) => ...' }
|
|
320
|
+
* and the orchestrator evaluates them via vm.runInNewContext at dispatch time.
|
|
321
|
+
* struct with discriminant and expression field.
|
|
322
|
+
* _type: 'inline' alongside existing 'static' and 'dynamic' discriminants.
|
|
323
|
+
*/
|
|
324
|
+
export interface LockInlineValue {
|
|
325
|
+
readonly _type: 'inline';
|
|
326
|
+
readonly expression: string;
|
|
327
|
+
}
|
|
328
|
+
/** Type guard for inline expression values */
|
|
329
|
+
export declare function isLockInlineValue(value: unknown): value is LockInlineValue;
|
|
330
|
+
/**
|
|
331
|
+
* Needs entry with per-edge failure policy.
|
|
332
|
+
* Used in lock file needs arrays for explicit ifFailed override.
|
|
333
|
+
*/
|
|
334
|
+
export declare const NeedsEntrySchema: z.ZodObject<{
|
|
335
|
+
name: z.ZodString;
|
|
336
|
+
ifFailed: z.ZodDefault<z.ZodEnum<{
|
|
337
|
+
run: "run";
|
|
338
|
+
skip: "skip";
|
|
339
|
+
}>>;
|
|
340
|
+
}, z.core.$strip>;
|
|
341
|
+
export type NeedsEntry = z.infer<typeof NeedsEntrySchema>;
|
|
342
|
+
/**
|
|
343
|
+
* Needs group entry with per-edge failure policy.
|
|
344
|
+
* Used in lock file needs arrays for dynamic group dependencies.
|
|
345
|
+
*/
|
|
346
|
+
export declare const NeedsGroupEntrySchema: z.ZodObject<{
|
|
347
|
+
group: z.ZodString;
|
|
348
|
+
ifFailed: z.ZodDefault<z.ZodEnum<{
|
|
349
|
+
run: "run";
|
|
350
|
+
skip: "skip";
|
|
351
|
+
}>>;
|
|
352
|
+
}, z.core.$strip>;
|
|
353
|
+
export type NeedsGroupEntry = z.infer<typeof NeedsGroupEntrySchema>;
|
|
354
|
+
/**
|
|
355
|
+
* Static job in lock file.
|
|
356
|
+
* Contains all orchestrator-readable information for scheduling.
|
|
357
|
+
*/
|
|
358
|
+
export interface LockJob {
|
|
359
|
+
readonly _type: 'static';
|
|
360
|
+
readonly name: string;
|
|
361
|
+
readonly runsOn: string | readonly string[];
|
|
362
|
+
readonly excludeLabels?: readonly string[];
|
|
363
|
+
readonly needs: readonly (string | NeedsEntry | NeedsGroupEntry)[];
|
|
364
|
+
/** Group names this job depends on (populated by compiler from dynamicGroup refs). */
|
|
365
|
+
readonly dependsOnGroups?: readonly string[];
|
|
366
|
+
readonly steps: readonly LockStep[];
|
|
367
|
+
readonly matrix?: LockMatrix;
|
|
368
|
+
readonly include?: readonly Record<string, string>[];
|
|
369
|
+
readonly exclude?: readonly Record<string, string>[];
|
|
370
|
+
readonly rules?: readonly LockRule[];
|
|
371
|
+
readonly description?: string;
|
|
372
|
+
/** Deployment environment name (static string) or inline expression (pure function). */
|
|
373
|
+
readonly environment?: string | LockInlineValue;
|
|
374
|
+
/** When true, environment is dynamic (function) -- resolved at orchestrator two-phase eval or inline. */
|
|
375
|
+
readonly dynamicEnvironment?: boolean;
|
|
376
|
+
/** Static environment variables or inline expression (pure function). */
|
|
377
|
+
readonly env?: Record<string, string> | LockInlineValue;
|
|
378
|
+
/** When true, env is dynamic (function) -- resolved at orchestrator two-phase eval or inline. */
|
|
379
|
+
readonly dynamicEnv?: boolean;
|
|
380
|
+
/** Concurrency group name (static string) or inline expression (pure function). */
|
|
381
|
+
readonly concurrencyGroup?: string | LockInlineValue;
|
|
382
|
+
/** When true, concurrencyGroup is dynamic (function) -- resolved at orchestrator two-phase eval or inline. */
|
|
383
|
+
readonly dynamicConcurrencyGroup?: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Resource request and limit for this job.
|
|
386
|
+
* Threaded from SDK `Job.resources` to the orchestrator scaler for cap accounting
|
|
387
|
+
* (`requests`) and kernel-side enforcement (`limits`) on the spawned agent.
|
|
388
|
+
*/
|
|
389
|
+
readonly resources?: import('../scaler/resource-types.js').ResourceRequest;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Dynamic job generator reference.
|
|
393
|
+
* Points to async function that generates jobs at agent runtime.
|
|
394
|
+
*/
|
|
395
|
+
export interface LockDynamicJobFn {
|
|
396
|
+
readonly _type: 'dynamic';
|
|
397
|
+
readonly source: {
|
|
398
|
+
readonly file: string;
|
|
399
|
+
readonly index: number;
|
|
400
|
+
};
|
|
401
|
+
/** Group name for cross-domain needs (set when dynamicJob('name', fn) is used). */
|
|
402
|
+
readonly group?: string;
|
|
403
|
+
}
|
|
404
|
+
/** Job or dynamic job generator */
|
|
405
|
+
export type LockJobOrFactory = LockJob | LockDynamicJobFn;
|
|
406
|
+
/**
|
|
407
|
+
* Private npm registry declaration in the lock file.
|
|
408
|
+
* Carries the URL/scope/secret-reference but NOT the resolved token —
|
|
409
|
+
* the orchestrator resolves the token at dispatch time via the per-environment
|
|
410
|
+
* secretResolver.resolveForJob path.
|
|
411
|
+
*/
|
|
412
|
+
export interface LockRegistry {
|
|
413
|
+
readonly url: string;
|
|
414
|
+
readonly scope?: string;
|
|
415
|
+
/** Qualified secret reference: `<environment>:<secret-name>`. */
|
|
416
|
+
readonly tokenSecret: string;
|
|
417
|
+
readonly alwaysAuth?: boolean;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Workflow in lock file.
|
|
421
|
+
* Complete workflow definition ready for orchestrator consumption.
|
|
422
|
+
*/
|
|
423
|
+
export interface LockWorkflow {
|
|
424
|
+
readonly name: string;
|
|
425
|
+
/** Per-workflow source file reference. Required when workflows span multiple files. */
|
|
426
|
+
readonly source?: LockSource;
|
|
427
|
+
/** SHA-256 content hash of the compiled bundle (and optional hashFiles contents) mixed with compileSchemaVersion */
|
|
428
|
+
readonly contentHash: string;
|
|
429
|
+
/** Compile schema version used when computing the content hash */
|
|
430
|
+
readonly compileSchemaVersion: number;
|
|
431
|
+
readonly triggers: readonly LockTrigger[];
|
|
432
|
+
readonly jobs: readonly LockJobOrFactory[];
|
|
433
|
+
readonly rules?: readonly LockRule[];
|
|
434
|
+
readonly description?: string;
|
|
435
|
+
/** Declared hashFiles patterns from the workflow (paths/globs relative to repo root). Optional. */
|
|
436
|
+
readonly hashFiles?: string[];
|
|
437
|
+
/** Resolved paths (relative to repo root) used to compute contentHash. Enables agent to verify hash without re-discovering workflow. Optional. */
|
|
438
|
+
readonly resolvedHashFiles?: string[];
|
|
439
|
+
/** Secret contexts declared by the workflow. Orchestrator validates access before dispatch. Optional. */
|
|
440
|
+
readonly contexts?: readonly string[];
|
|
441
|
+
/**
|
|
442
|
+
* Private npm registries the agent should authenticate against before `npm install`.
|
|
443
|
+
* Resolved-token bytes never appear in the lock file; only the secret reference does.
|
|
444
|
+
*/
|
|
445
|
+
readonly registries?: readonly LockRegistry[];
|
|
446
|
+
/**
|
|
447
|
+
* Extra qualified secret refs (`<environment>:<secret-name>`) to project as
|
|
448
|
+
* env vars on the install subprocess for use with a customer-committed `.kici/.npmrc`.
|
|
449
|
+
*/
|
|
450
|
+
readonly installEnv?: readonly string[];
|
|
451
|
+
/** Workflow-level concurrency configuration. */
|
|
452
|
+
readonly concurrency?: {
|
|
453
|
+
readonly hasGroup: boolean;
|
|
454
|
+
readonly cancelInProgress?: boolean;
|
|
455
|
+
readonly max?: number;
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Complete lock file structure.
|
|
460
|
+
* Schema version 11 - designed for fast orchestrator event matching.
|
|
461
|
+
* v2 adds per-workflow contentHash and compileSchemaVersion.
|
|
462
|
+
* v3 adds 13 new trigger types (tag, comment, review, release, dispatch, etc.).
|
|
463
|
+
* v4 adds 4 internal event routing trigger types (kici_event, workflow_complete,
|
|
464
|
+
* job_complete, generic_webhook).
|
|
465
|
+
* v5 adds schedule, lifecycle triggers, generic webhook auth, and job-level contexts.
|
|
466
|
+
* v6 replaces job-level contexts with environment/env/concurrencyGroup.
|
|
467
|
+
* v7 adds hook flags, step rules, gracePeriod, and workflow concurrency config.
|
|
468
|
+
* v8 adds runsOn polymorphic type (string | string[] | selector) and excludeLabels.
|
|
469
|
+
* v9 adds repos/notRepos repo pattern fields to git-event triggers for global workflow matching.
|
|
470
|
+
* v10 removes notRepos/notPaths fields; negative patterns use ! prefix in repos/paths arrays.
|
|
471
|
+
* v11 adds LockInlineValue type for pure function inline evaluation.
|
|
472
|
+
* v12 adds workflow-level registries and installEnv for private npm registry auth.
|
|
473
|
+
*/
|
|
474
|
+
export interface LockFile {
|
|
475
|
+
readonly schemaVersion: typeof SCHEMA_VERSION;
|
|
476
|
+
readonly source: LockSource;
|
|
477
|
+
/** SHA-256 hash of the serialized lock file content (excluding this field). Changes only when workflows, triggers, jobs, or bundle hashes change. */
|
|
478
|
+
readonly contentHash: string;
|
|
479
|
+
/** SHA-256 hash of .kici/ lockfile (pnpm-lock.yaml or package-lock.json). Used for dependency cache keying. */
|
|
480
|
+
readonly lockfileHash?: string;
|
|
481
|
+
readonly workflows: readonly LockWorkflow[];
|
|
482
|
+
}
|
|
483
|
+
/** Type guard for static jobs */
|
|
484
|
+
export declare function isLockStaticJob(job: LockJobOrFactory): job is LockJob;
|
|
485
|
+
/** Type guard for dynamic job generators */
|
|
486
|
+
export declare function isLockDynamicJobFn(job: LockJobOrFactory): job is LockDynamicJobFn;
|
|
487
|
+
/**
|
|
488
|
+
* Simulated event payload structure for trigger matching.
|
|
489
|
+
*
|
|
490
|
+
* Known event types: push, pull_request, tag, comment, review, review_comment,
|
|
491
|
+
* dispatch, release, create, delete, status, workflow_run, fork, star, watch,
|
|
492
|
+
* kici_event, workflow_complete, job_complete, generic_webhook, schedule, lifecycle
|
|
493
|
+
*/
|
|
494
|
+
export interface SimulatedEvent {
|
|
495
|
+
type: string;
|
|
496
|
+
action?: string;
|
|
497
|
+
payload: Record<string, unknown>;
|
|
498
|
+
/** Branch being pushed to or PR target */
|
|
499
|
+
targetBranch: string;
|
|
500
|
+
/** PR source branch (only for PRs) */
|
|
501
|
+
sourceBranch?: string;
|
|
502
|
+
/** Changed files (for path filtering) */
|
|
503
|
+
changedFiles?: string[];
|
|
504
|
+
/** Which provider originated this event. Optional for backward compatibility with compiler/test CLI. */
|
|
505
|
+
provider?: ProviderType;
|
|
506
|
+
/** Whether this PR comes from a fork (head repo != base repo). Only set for PR events. */
|
|
507
|
+
isForkPR?: boolean;
|
|
508
|
+
/** Base branch ref for PR events (the branch being merged into). */
|
|
509
|
+
baseBranch?: string;
|
|
510
|
+
/** Sender username from the webhook payload (e.g. GitHub login). */
|
|
511
|
+
senderUsername?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Immutable IDP-side numeric id of the sender (e.g. GitHub's `sender.id`).
|
|
514
|
+
* Mirrors Platform's `identity_links.provider_user_id`. The orchestrator
|
|
515
|
+
* trust resolver prefers this over `senderUsername` because GitHub logins
|
|
516
|
+
* are mutable and a recycled login can otherwise inherit trust granted
|
|
517
|
+
* to the previous owner.
|
|
518
|
+
*/
|
|
519
|
+
senderUserId?: string;
|
|
520
|
+
/** Repository identifier where the event occurred (e.g., "owner/repo").
|
|
521
|
+
* Used by global workflow repo pattern matching. */
|
|
522
|
+
sourceRepo?: string;
|
|
523
|
+
}
|
|
524
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import "../chunk-gOLHoazu.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/trigger/types.ts
|
|
4
|
+
/**
|
|
5
|
+
* Lock file types for the trigger matching engine.
|
|
6
|
+
* Single source of truth -- replaces local copies in @kici-dev/compiler and @kici-dev/orchestrator.
|
|
7
|
+
* Schema version 4: adds 4 internal event routing trigger types (kici_event, workflow_complete,
|
|
8
|
+
* job_complete, generic_webhook).
|
|
9
|
+
* Schema version 6: replaces job-level contexts with environment/env/concurrencyGroup.
|
|
10
|
+
* Schema version 8: adds runsOn polymorphic type (string | string[] | selector) and excludeLabels.
|
|
11
|
+
* Schema version 9: adds repos/notRepos repo pattern fields to git-event triggers for global workflow matching.
|
|
12
|
+
* Schema version 10: removes notRepos/notPaths fields, negative patterns use ! prefix in repos/paths arrays.
|
|
13
|
+
* Schema version 11: adds LockInlineValue type for pure function inline evaluation.
|
|
14
|
+
*/
|
|
15
|
+
/** Schema version - increment on breaking changes */
|
|
16
|
+
const SCHEMA_VERSION = 12;
|
|
17
|
+
/** Type guard for inline expression values */
|
|
18
|
+
function isLockInlineValue(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && value._type === "inline";
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Needs entry with per-edge failure policy.
|
|
23
|
+
* Used in lock file needs arrays for explicit ifFailed override.
|
|
24
|
+
*/
|
|
25
|
+
const NeedsEntrySchema = z.object({
|
|
26
|
+
name: z.string(),
|
|
27
|
+
ifFailed: z.enum(["skip", "run"]).default("skip")
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Needs group entry with per-edge failure policy.
|
|
31
|
+
* Used in lock file needs arrays for dynamic group dependencies.
|
|
32
|
+
*/
|
|
33
|
+
const NeedsGroupEntrySchema = z.object({
|
|
34
|
+
group: z.string(),
|
|
35
|
+
ifFailed: z.enum(["skip", "run"]).default("skip")
|
|
36
|
+
});
|
|
37
|
+
/** Type guard for static jobs */
|
|
38
|
+
function isLockStaticJob(job) {
|
|
39
|
+
return job._type === "static";
|
|
40
|
+
}
|
|
41
|
+
/** Type guard for dynamic job generators */
|
|
42
|
+
function isLockDynamicJobFn(job) {
|
|
43
|
+
return job._type === "dynamic";
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { NeedsEntrySchema, NeedsGroupEntrySchema, SCHEMA_VERSION, isLockDynamicJobFn, isLockInlineValue, isLockStaticJob };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify GitHub webhook signature using HMAC-SHA256.
|
|
3
|
+
*
|
|
4
|
+
* @param body - Raw webhook payload body (as string)
|
|
5
|
+
* @param signature - Signature from X-Hub-Signature-256 header
|
|
6
|
+
* @param secret - Webhook secret configured on GitHub
|
|
7
|
+
* @returns true if signature is valid, false otherwise
|
|
8
|
+
*
|
|
9
|
+
* Security:
|
|
10
|
+
* - Uses crypto.timingSafeEqual to prevent timing attacks
|
|
11
|
+
* - Validates signature format before comparison
|
|
12
|
+
* - Handles length mismatches before timingSafeEqual (which throws on length mismatch)
|
|
13
|
+
*/
|
|
14
|
+
export declare function verifySignature(body: string, signature: string, secret: string): boolean;
|
|
15
|
+
//# sourceMappingURL=signature.d.ts.map
|