@kici-dev/engine 0.0.0 → 0.1.1

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 (129) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -6
  3. package/dist/audit/access-log-policy.d.ts +97 -0
  4. package/dist/audit/access-log-policy.js +195 -0
  5. package/dist/audit/activity.d.ts +156 -0
  6. package/dist/audit/activity.js +175 -0
  7. package/dist/audit/retention-policy.d.ts +157 -0
  8. package/dist/audit/retention-policy.js +364 -0
  9. package/dist/bundler/index.d.ts +3 -0
  10. package/dist/bundler/index.js +3 -0
  11. package/dist/bundler/rolldown-config.d.ts +41 -0
  12. package/dist/bundler/rolldown-config.js +40 -0
  13. package/dist/chunk-gOLHoazu.js +4 -0
  14. package/dist/env/environment-allowlist.d.ts +45 -0
  15. package/dist/env/environment-allowlist.js +69 -0
  16. package/dist/environment/index.d.ts +3 -0
  17. package/dist/environment/index.js +3 -0
  18. package/dist/environment/scope-resolver.d.ts +35 -0
  19. package/dist/environment/scope-resolver.js +77 -0
  20. package/dist/environment/types.d.ts +98 -0
  21. package/dist/environment/types.js +2 -0
  22. package/dist/index.d.ts +54 -0
  23. package/dist/index.js +45 -0
  24. package/dist/labels.d.ts +106 -0
  25. package/dist/labels.js +162 -0
  26. package/dist/metrics/metric-catalog.generated.d.ts +400 -0
  27. package/dist/metrics/metric-catalog.generated.js +510 -0
  28. package/dist/protocol/dashboard-global-workflows.d.ts +9 -0
  29. package/dist/protocol/dashboard-global-workflows.js +3 -0
  30. package/dist/protocol/event-log-payload.d.ts +16 -0
  31. package/dist/protocol/event-log-payload.js +21 -0
  32. package/dist/protocol/messages/access-log.d.ts +545 -0
  33. package/dist/protocol/messages/access-log.js +175 -0
  34. package/dist/protocol/messages/actor.d.ts +100 -0
  35. package/dist/protocol/messages/actor.js +139 -0
  36. package/dist/protocol/messages/auth.d.ts +25 -0
  37. package/dist/protocol/messages/auth.js +36 -0
  38. package/dist/protocol/messages/browser.d.ts +369 -0
  39. package/dist/protocol/messages/browser.js +225 -0
  40. package/dist/protocol/messages/capabilities.d.ts +46 -0
  41. package/dist/protocol/messages/capabilities.js +42 -0
  42. package/dist/protocol/messages/common.d.ts +53 -0
  43. package/dist/protocol/messages/common.js +55 -0
  44. package/dist/protocol/messages/dashboard-global-workflows.d.ts +166 -0
  45. package/dist/protocol/messages/dashboard-global-workflows.js +80 -0
  46. package/dist/protocol/messages/dashboard.d.ts +4068 -0
  47. package/dist/protocol/messages/dashboard.js +1237 -0
  48. package/dist/protocol/messages/event-log.d.ts +49 -0
  49. package/dist/protocol/messages/event-log.js +45 -0
  50. package/dist/protocol/messages/execution-status.d.ts +164 -0
  51. package/dist/protocol/messages/execution-status.js +166 -0
  52. package/dist/protocol/messages/join.d.ts +18 -0
  53. package/dist/protocol/messages/join.js +28 -0
  54. package/dist/protocol/messages/log-pull.d.ts +27 -0
  55. package/dist/protocol/messages/log-pull.js +36 -0
  56. package/dist/protocol/messages/observe.d.ts +75 -0
  57. package/dist/protocol/messages/observe.js +70 -0
  58. package/dist/protocol/messages/orchestrator-agent.d.ts +606 -0
  59. package/dist/protocol/messages/orchestrator-agent.js +481 -0
  60. package/dist/protocol/messages/peer.d.ts +795 -0
  61. package/dist/protocol/messages/peer.js +372 -0
  62. package/dist/protocol/messages/platform-orchestrator.d.ts +1888 -0
  63. package/dist/protocol/messages/platform-orchestrator.js +379 -0
  64. package/dist/protocol/messages/run-events.d.ts +155 -0
  65. package/dist/protocol/messages/run-events.js +115 -0
  66. package/dist/protocol/messages/saas-orchestrator.d.ts +2179 -0
  67. package/dist/protocol/messages/source-registration.d.ts +103 -0
  68. package/dist/protocol/messages/source-registration.js +109 -0
  69. package/dist/protocol/messages/test-run.d.ts +59 -0
  70. package/dist/protocol/messages/test-run.js +52 -0
  71. package/dist/protocol/version.d.ts +12 -0
  72. package/dist/protocol/version.js +17 -0
  73. package/dist/provider/changed-files-fetcher.d.ts +24 -0
  74. package/dist/provider/changed-files-fetcher.js +2 -0
  75. package/dist/provider/check-run-conclusion.d.ts +15 -0
  76. package/dist/provider/check-run-conclusion.js +19 -0
  77. package/dist/provider/check-status-poster.d.ts +15 -0
  78. package/dist/provider/check-status-poster.js +2 -0
  79. package/dist/provider/clone-token-provider.d.ts +58 -0
  80. package/dist/provider/clone-token-provider.js +2 -0
  81. package/dist/provider/contributor-resolver.d.ts +22 -0
  82. package/dist/provider/contributor-resolver.js +2 -0
  83. package/dist/provider/index.d.ts +23 -0
  84. package/dist/provider/index.js +3 -0
  85. package/dist/provider/lock-file-fetcher.d.ts +24 -0
  86. package/dist/provider/lock-file-fetcher.js +2 -0
  87. package/dist/provider/repo-url-builder.d.ts +35 -0
  88. package/dist/provider/repo-url-builder.js +2 -0
  89. package/dist/provider/types.d.ts +9 -0
  90. package/dist/provider/types.js +2 -0
  91. package/dist/provider/webhook-normalizer.d.ts +163 -0
  92. package/dist/provider/webhook-normalizer.js +2 -0
  93. package/dist/registration/registerable-trigger-type.d.ts +52 -0
  94. package/dist/registration/registerable-trigger-type.js +56 -0
  95. package/dist/scaler/resource-types.d.ts +90 -0
  96. package/dist/scaler/resource-types.js +99 -0
  97. package/dist/scaler/scaler-backend-type.d.ts +16 -0
  98. package/dist/scaler/scaler-backend-type.js +20 -0
  99. package/dist/secrets/index.d.ts +7 -0
  100. package/dist/secrets/index.js +2 -0
  101. package/dist/secrets/types.d.ts +138 -0
  102. package/dist/secrets/types.js +2 -0
  103. package/dist/state-machine/index.d.ts +2 -0
  104. package/dist/state-machine/index.js +3 -0
  105. package/dist/state-machine/machine.d.ts +34 -0
  106. package/dist/state-machine/machine.js +103 -0
  107. package/dist/state-machine/types.d.ts +34 -0
  108. package/dist/state-machine/types.js +15 -0
  109. package/dist/trigger/decision-trace.d.ts +41 -0
  110. package/dist/trigger/decision-trace.js +30 -0
  111. package/dist/trigger/jsonpath-matcher.d.ts +27 -0
  112. package/dist/trigger/jsonpath-matcher.js +92 -0
  113. package/dist/trigger/matcher.d.ts +29 -0
  114. package/dist/trigger/matcher.js +704 -0
  115. package/dist/trigger/trigger-event-type.d.ts +14 -0
  116. package/dist/trigger/trigger-event-type.js +66 -0
  117. package/dist/trigger/types.d.ts +524 -0
  118. package/dist/trigger/types.js +48 -0
  119. package/dist/webhook/signature.d.ts +15 -0
  120. package/dist/webhook/signature.js +32 -0
  121. package/dist/ws/close-codes.d.ts +28 -0
  122. package/dist/ws/close-codes.js +33 -0
  123. package/dist/ws/rate-limiter.d.ts +86 -0
  124. package/dist/ws/rate-limiter.js +136 -0
  125. package/dist/ws/ws-like.d.ts +12 -0
  126. package/dist/ws/ws-like.js +2 -0
  127. package/package.json +54 -6
  128. package/sbom.spdx.json +202 -0
  129. package/index.js +0 -3
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Outcome of webhook processing on the orchestrator.
4
+ *
5
+ * - `received` — row written before processing started (e.g. oversized payload
6
+ * path that records the row but defers further work to the standard pipeline).
7
+ * - `processed` — webhook was processed and at least one workflow was
8
+ * evaluated. `matched_count` carries how many actually matched.
9
+ * - `duplicate` — dedup cache rejected the delivery.
10
+ * - `lockfile_missing` — repo lookup succeeded but no lock file was found
11
+ * (and no global workflows matched either).
12
+ * - `failed` — pipeline threw an unhandled error. `error_message` carries
13
+ * the message.
14
+ */
15
+ export declare const EventLogStatus: z.ZodEnum<{
16
+ failed: "failed";
17
+ received: "received";
18
+ processed: "processed";
19
+ duplicate: "duplicate";
20
+ lockfile_missing: "lockfile_missing";
21
+ }>;
22
+ export type EventLogStatus = z.infer<typeof EventLogStatus>;
23
+ /**
24
+ * Reason the payload was NOT stored to object storage.
25
+ *
26
+ * - `size_exceeded` — body exceeded the configured `eventLog.maxPayloadBytes`
27
+ * soft cap. The DB row is still written (with the hash + actual size) so the
28
+ * delivery is visible in the dashboard; the body itself can be retrieved
29
+ * from `KICI_WEBHOOK_PAYLOAD_DIR` or raw logs by hash if needed.
30
+ * - `storage_failed` — upload to LogStorage threw. The DB row is still
31
+ * written so the operator can investigate; the failure is logged at error
32
+ * level by the writer.
33
+ */
34
+ export declare const PayloadOmittedReason: z.ZodEnum<{
35
+ size_exceeded: "size_exceeded";
36
+ storage_failed: "storage_failed";
37
+ }>;
38
+ export type PayloadOmittedReason = z.infer<typeof PayloadOmittedReason>;
39
+ /**
40
+ * Where the webhook arrived.
41
+ * - `relay` — Platform-Orchestrator WS relay path.
42
+ * - `direct` — Direct HTTP ingress (independent / hybrid mode).
43
+ */
44
+ export declare const EventLogSource: z.ZodEnum<{
45
+ relay: "relay";
46
+ direct: "direct";
47
+ }>;
48
+ export type EventLogSource = z.infer<typeof EventLogSource>;
49
+ //# sourceMappingURL=event-log.d.ts.map
@@ -0,0 +1,45 @@
1
+ import "../../chunk-gOLHoazu.js";
2
+ import { z } from "zod";
3
+ //#region src/protocol/messages/event-log.ts
4
+ /**
5
+ * Outcome of webhook processing on the orchestrator.
6
+ *
7
+ * - `received` — row written before processing started (e.g. oversized payload
8
+ * path that records the row but defers further work to the standard pipeline).
9
+ * - `processed` — webhook was processed and at least one workflow was
10
+ * evaluated. `matched_count` carries how many actually matched.
11
+ * - `duplicate` — dedup cache rejected the delivery.
12
+ * - `lockfile_missing` — repo lookup succeeded but no lock file was found
13
+ * (and no global workflows matched either).
14
+ * - `failed` — pipeline threw an unhandled error. `error_message` carries
15
+ * the message.
16
+ */
17
+ const EventLogStatus = z.enum([
18
+ "received",
19
+ "processed",
20
+ "duplicate",
21
+ "lockfile_missing",
22
+ "failed"
23
+ ]);
24
+ /**
25
+ * Reason the payload was NOT stored to object storage.
26
+ *
27
+ * - `size_exceeded` — body exceeded the configured `eventLog.maxPayloadBytes`
28
+ * soft cap. The DB row is still written (with the hash + actual size) so the
29
+ * delivery is visible in the dashboard; the body itself can be retrieved
30
+ * from `KICI_WEBHOOK_PAYLOAD_DIR` or raw logs by hash if needed.
31
+ * - `storage_failed` — upload to LogStorage threw. The DB row is still
32
+ * written so the operator can investigate; the failure is logged at error
33
+ * level by the writer.
34
+ */
35
+ const PayloadOmittedReason = z.enum(["size_exceeded", "storage_failed"]);
36
+ /**
37
+ * Where the webhook arrived.
38
+ * - `relay` — Platform-Orchestrator WS relay path.
39
+ * - `direct` — Direct HTTP ingress (independent / hybrid mode).
40
+ */
41
+ const EventLogSource = z.enum(["relay", "direct"]);
42
+ //#endregion
43
+ export { EventLogSource, EventLogStatus, PayloadOmittedReason };
44
+
45
+ //# sourceMappingURL=event-log.js.map
@@ -0,0 +1,164 @@
1
+ import { z } from 'zod';
2
+ /** Status values for execution runs (execution_runs table). */
3
+ export declare const ExecutionRunStatus: z.ZodEnum<{
4
+ success: "success";
5
+ pending: "pending";
6
+ running: "running";
7
+ failed: "failed";
8
+ cancelled: "cancelled";
9
+ cancelling: "cancelling";
10
+ }>;
11
+ export type ExecutionRunStatus = z.infer<typeof ExecutionRunStatus>;
12
+ /** Status values for execution jobs (execution_jobs table + job.status protocol messages). */
13
+ export declare const ExecutionJobStatus: z.ZodEnum<{
14
+ success: "success";
15
+ pending: "pending";
16
+ running: "running";
17
+ failed: "failed";
18
+ cancelled: "cancelled";
19
+ cancelling: "cancelling";
20
+ queued: "queued";
21
+ recovering: "recovering";
22
+ skipped: "skipped";
23
+ timed_out_stale: "timed_out_stale";
24
+ drift_dropped: "drift_dropped";
25
+ }>;
26
+ export type ExecutionJobStatus = z.infer<typeof ExecutionJobStatus>;
27
+ /** Status values for execution steps (execution_steps table + step.status protocol messages). */
28
+ export declare const ExecutionStepStatus: z.ZodEnum<{
29
+ success: "success";
30
+ running: "running";
31
+ failed: "failed";
32
+ skipped: "skipped";
33
+ }>;
34
+ export type ExecutionStepStatus = z.infer<typeof ExecutionStepStatus>;
35
+ /** Terminal run states that indicate the run has completed. */
36
+ export declare const TERMINAL_RUN_STATES: ReadonlySet<string>;
37
+ /** Terminal job states that indicate the job is no longer running. */
38
+ export declare const TERMINAL_JOB_STATES: ReadonlySet<string>;
39
+ /** Structured execution status update for Platform metadata tracking. */
40
+ export declare const executionStatusSchema: z.ZodObject<{
41
+ type: z.ZodLiteral<"execution.status">;
42
+ messageId: z.ZodString;
43
+ runId: z.ZodString;
44
+ workflowName: z.ZodString;
45
+ status: z.ZodEnum<{
46
+ success: "success";
47
+ pending: "pending";
48
+ running: "running";
49
+ failed: "failed";
50
+ cancelled: "cancelled";
51
+ cancelling: "cancelling";
52
+ }>;
53
+ repoIdentifier: z.ZodOptional<z.ZodString>;
54
+ sha: z.ZodOptional<z.ZodString>;
55
+ ref: z.ZodOptional<z.ZodString>;
56
+ triggerEvent: z.ZodOptional<z.ZodString>;
57
+ commitMessage: z.ZodOptional<z.ZodString>;
58
+ jobCount: z.ZodOptional<z.ZodNumber>;
59
+ startedAt: z.ZodNumber;
60
+ completedAt: z.ZodOptional<z.ZodNumber>;
61
+ durationMs: z.ZodOptional<z.ZodNumber>;
62
+ timestamp: z.ZodNumber;
63
+ parentRunId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
64
+ originalRunId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
+ triggeredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ failureReason: z.ZodOptional<z.ZodString>;
67
+ logBytes: z.ZodOptional<z.ZodNumber>;
68
+ }, z.core.$strip>;
69
+ /** Per-step status forwarded from agent to Platform (real-time). */
70
+ export declare const stepStatusForwardSchema: z.ZodObject<{
71
+ type: z.ZodLiteral<"step.status.forward">;
72
+ messageId: z.ZodString;
73
+ runId: z.ZodString;
74
+ jobId: z.ZodString;
75
+ jobName: z.ZodString;
76
+ stepIndex: z.ZodNumber;
77
+ stepName: z.ZodString;
78
+ state: z.ZodEnum<{
79
+ success: "success";
80
+ running: "running";
81
+ failed: "failed";
82
+ skipped: "skipped";
83
+ }>;
84
+ timestamp: z.ZodNumber;
85
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
86
+ secretsAccessed: z.ZodOptional<z.ZodArray<z.ZodString>>;
87
+ }, z.core.$strip>;
88
+ /** Per-job status forwarded from orchestrator to Platform (real-time). */
89
+ export declare const jobStatusForwardSchema: z.ZodObject<{
90
+ type: z.ZodLiteral<"job.status.forward">;
91
+ messageId: z.ZodString;
92
+ runId: z.ZodString;
93
+ jobId: z.ZodString;
94
+ jobName: z.ZodString;
95
+ status: z.ZodEnum<{
96
+ success: "success";
97
+ pending: "pending";
98
+ running: "running";
99
+ failed: "failed";
100
+ cancelled: "cancelled";
101
+ cancelling: "cancelling";
102
+ queued: "queued";
103
+ recovering: "recovering";
104
+ skipped: "skipped";
105
+ timed_out_stale: "timed_out_stale";
106
+ drift_dropped: "drift_dropped";
107
+ }>;
108
+ matrixValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
109
+ startedAt: z.ZodOptional<z.ZodNumber>;
110
+ completedAt: z.ZodOptional<z.ZodNumber>;
111
+ durationMs: z.ZodOptional<z.ZodNumber>;
112
+ errorMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
113
+ agentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
114
+ orchestratorId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
115
+ runsOnLabels: z.ZodOptional<z.ZodArray<z.ZodString>>;
116
+ logBytes: z.ZodOptional<z.ZodNumber>;
117
+ timestamp: z.ZodNumber;
118
+ }, z.core.$strip>;
119
+ /** State replay sent on orchestrator reconnection -- full snapshot of active runs and jobs. */
120
+ export declare const stateReplaySchema: z.ZodObject<{
121
+ type: z.ZodLiteral<"state.replay">;
122
+ messageId: z.ZodString;
123
+ runs: z.ZodArray<z.ZodObject<{
124
+ runId: z.ZodString;
125
+ workflowName: z.ZodString;
126
+ status: z.ZodEnum<{
127
+ success: "success";
128
+ pending: "pending";
129
+ running: "running";
130
+ failed: "failed";
131
+ cancelled: "cancelled";
132
+ cancelling: "cancelling";
133
+ }>;
134
+ routingKey: z.ZodOptional<z.ZodString>;
135
+ repoIdentifier: z.ZodOptional<z.ZodString>;
136
+ sha: z.ZodOptional<z.ZodString>;
137
+ ref: z.ZodOptional<z.ZodString>;
138
+ triggerEvent: z.ZodOptional<z.ZodString>;
139
+ commitMessage: z.ZodOptional<z.ZodString>;
140
+ jobCount: z.ZodNumber;
141
+ startedAt: z.ZodNumber;
142
+ completedAt: z.ZodOptional<z.ZodNumber>;
143
+ durationMs: z.ZodOptional<z.ZodNumber>;
144
+ parentRunId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
145
+ originalRunId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
146
+ triggeredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
147
+ failureReason: z.ZodOptional<z.ZodString>;
148
+ jobs: z.ZodArray<z.ZodObject<{
149
+ jobId: z.ZodString;
150
+ jobName: z.ZodString;
151
+ status: z.ZodString;
152
+ startedAt: z.ZodOptional<z.ZodNumber>;
153
+ completedAt: z.ZodOptional<z.ZodNumber>;
154
+ durationMs: z.ZodOptional<z.ZodNumber>;
155
+ errorMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
156
+ agentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
157
+ runsOnLabels: z.ZodOptional<z.ZodArray<z.ZodString>>;
158
+ }, z.core.$strip>>;
159
+ }, z.core.$strip>>;
160
+ timestamp: z.ZodNumber;
161
+ }, z.core.$strip>;
162
+ export type ExecutionStatus = z.infer<typeof executionStatusSchema>;
163
+ export type StepStatusForward = z.infer<typeof stepStatusForwardSchema>;
164
+ //# sourceMappingURL=execution-status.d.ts.map
@@ -0,0 +1,166 @@
1
+ import "../../chunk-gOLHoazu.js";
2
+ import { z } from "zod";
3
+ //#region src/protocol/messages/execution-status.ts
4
+ /** Status values for execution runs (execution_runs table). */
5
+ const ExecutionRunStatus = z.enum([
6
+ "pending",
7
+ "running",
8
+ "success",
9
+ "failed",
10
+ "cancelled",
11
+ "cancelling"
12
+ ]);
13
+ /** Status values for execution jobs (execution_jobs table + job.status protocol messages). */
14
+ const ExecutionJobStatus = z.enum([
15
+ "pending",
16
+ "queued",
17
+ "running",
18
+ "recovering",
19
+ "cancelling",
20
+ "success",
21
+ "failed",
22
+ "cancelled",
23
+ "skipped",
24
+ "timed_out_stale",
25
+ "drift_dropped"
26
+ ]);
27
+ /** Status values for execution steps (execution_steps table + step.status protocol messages). */
28
+ const ExecutionStepStatus = z.enum([
29
+ "running",
30
+ "success",
31
+ "failed",
32
+ "skipped"
33
+ ]);
34
+ /** Terminal run states that indicate the run has completed. */
35
+ const TERMINAL_RUN_STATES = new Set([
36
+ ExecutionRunStatus.enum.success,
37
+ ExecutionRunStatus.enum.failed,
38
+ ExecutionRunStatus.enum.cancelled
39
+ ]);
40
+ /** Terminal job states that indicate the job is no longer running. */
41
+ const TERMINAL_JOB_STATES = new Set([
42
+ ExecutionJobStatus.enum.success,
43
+ ExecutionJobStatus.enum.failed,
44
+ ExecutionJobStatus.enum.cancelled,
45
+ ExecutionJobStatus.enum.skipped,
46
+ ExecutionJobStatus.enum.timed_out_stale,
47
+ ExecutionJobStatus.enum.drift_dropped
48
+ ]);
49
+ /** Structured execution status update for Platform metadata tracking. */
50
+ const executionStatusSchema = z.object({
51
+ type: z.literal("execution.status"),
52
+ messageId: z.string(),
53
+ runId: z.string(),
54
+ workflowName: z.string(),
55
+ status: ExecutionRunStatus,
56
+ repoIdentifier: z.string().optional(),
57
+ sha: z.string().optional(),
58
+ /** Git branch or tag (e.g. "main", "refs/tags/v1.0"). */
59
+ ref: z.string().optional(),
60
+ /** Trigger event type (e.g. "push", "pr:open"). */
61
+ triggerEvent: z.string().optional(),
62
+ /** First line of the commit message. */
63
+ commitMessage: z.string().optional(),
64
+ jobCount: z.number().optional(),
65
+ startedAt: z.number(),
66
+ completedAt: z.number().optional(),
67
+ durationMs: z.number().optional(),
68
+ timestamp: z.number(),
69
+ /** Parent run ID for re-run lineage (null/undefined for original runs). */
70
+ parentRunId: z.string().nullable().optional(),
71
+ /** Root ancestor run ID for re-run lineage (null/undefined for original runs). Always points to the first run in the chain. */
72
+ originalRunId: z.string().nullable().optional(),
73
+ /** User identity that triggered this re-run (null/undefined for webhook-triggered). */
74
+ triggeredBy: z.string().nullable().optional(),
75
+ /** Human-readable reason why the run failed (only present for failed runs). */
76
+ failureReason: z.string().optional(),
77
+ /**
78
+ * Total raw log bytes accumulated across all jobs of this run, summed by the
79
+ * orchestrator from per-step `logBytesStreamed` values reported by the agent.
80
+ * Only set on terminal run states. Powers the operator-side
81
+ * `kici_org_log_bytes` capacity-planning gauge on the Platform.
82
+ */
83
+ logBytes: z.number().int().nonnegative().optional()
84
+ });
85
+ /** Per-step status forwarded from agent to Platform (real-time). */
86
+ const stepStatusForwardSchema = z.object({
87
+ type: z.literal("step.status.forward"),
88
+ messageId: z.string(),
89
+ runId: z.string(),
90
+ jobId: z.string(),
91
+ jobName: z.string(),
92
+ stepIndex: z.number(),
93
+ stepName: z.string(),
94
+ state: ExecutionStepStatus,
95
+ timestamp: z.number(),
96
+ data: z.record(z.string(), z.unknown()).optional(),
97
+ /** Secret key names accessed by this step. Forwarded from agent for dashboard display. */
98
+ secretsAccessed: z.array(z.string()).optional()
99
+ });
100
+ /** Per-job status forwarded from orchestrator to Platform (real-time). */
101
+ const jobStatusForwardSchema = z.object({
102
+ type: z.literal("job.status.forward"),
103
+ messageId: z.string(),
104
+ runId: z.string(),
105
+ jobId: z.string(),
106
+ jobName: z.string(),
107
+ status: ExecutionJobStatus,
108
+ matrixValues: z.record(z.string(), z.unknown()).optional(),
109
+ startedAt: z.number().optional(),
110
+ completedAt: z.number().optional(),
111
+ durationMs: z.number().optional(),
112
+ errorMessage: z.string().nullable().optional(),
113
+ agentId: z.string().nullable().optional(),
114
+ orchestratorId: z.string().nullable().optional(),
115
+ /** Labels used for agent routing. */
116
+ runsOnLabels: z.array(z.string()).optional(),
117
+ /**
118
+ * Total raw log bytes accumulated across all steps of this job, summed by
119
+ * the orchestrator from per-step `logBytesStreamed` values reported by the
120
+ * agent. Only set on terminal job states. Powers the operator-side
121
+ * `kici_org_log_bytes` capacity-planning gauge on the Platform.
122
+ */
123
+ logBytes: z.number().int().nonnegative().optional(),
124
+ timestamp: z.number()
125
+ });
126
+ /** State replay sent on orchestrator reconnection -- full snapshot of active runs and jobs. */
127
+ const stateReplaySchema = z.object({
128
+ type: z.literal("state.replay"),
129
+ messageId: z.string(),
130
+ runs: z.array(z.object({
131
+ runId: z.string(),
132
+ workflowName: z.string(),
133
+ status: ExecutionRunStatus,
134
+ routingKey: z.string().optional(),
135
+ repoIdentifier: z.string().optional(),
136
+ sha: z.string().optional(),
137
+ ref: z.string().optional(),
138
+ triggerEvent: z.string().optional(),
139
+ commitMessage: z.string().optional(),
140
+ jobCount: z.number(),
141
+ startedAt: z.number(),
142
+ completedAt: z.number().optional(),
143
+ durationMs: z.number().optional(),
144
+ parentRunId: z.string().nullable().optional(),
145
+ originalRunId: z.string().nullable().optional(),
146
+ triggeredBy: z.string().nullable().optional(),
147
+ /** Human-readable reason why the run failed (only present for failed runs). */
148
+ failureReason: z.string().optional(),
149
+ jobs: z.array(z.object({
150
+ jobId: z.string(),
151
+ jobName: z.string(),
152
+ status: z.string(),
153
+ startedAt: z.number().optional(),
154
+ completedAt: z.number().optional(),
155
+ durationMs: z.number().optional(),
156
+ errorMessage: z.string().nullable().optional(),
157
+ agentId: z.string().nullable().optional(),
158
+ runsOnLabels: z.array(z.string()).optional()
159
+ }))
160
+ })),
161
+ timestamp: z.number()
162
+ });
163
+ //#endregion
164
+ export { ExecutionJobStatus, ExecutionRunStatus, ExecutionStepStatus, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, executionStatusSchema, jobStatusForwardSchema, stateReplaySchema, stepStatusForwardSchema };
165
+
166
+ //# sourceMappingURL=execution-status.js.map
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ /** Join request sent by a new orchestrator (via Platform relay or direct peer). */
3
+ export declare const joinRequestSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"join.request">;
5
+ messageId: z.ZodOptional<z.ZodString>;
6
+ token: z.ZodString;
7
+ }, z.core.$strip>;
8
+ /** Join response from an existing orchestrator back to the joiner. */
9
+ export declare const joinResponseSchema: z.ZodObject<{
10
+ type: z.ZodLiteral<"join.response">;
11
+ messageId: z.ZodOptional<z.ZodString>;
12
+ success: z.ZodBoolean;
13
+ encryptedBundle: z.ZodOptional<z.ZodString>;
14
+ error: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export type JoinRequest = z.infer<typeof joinRequestSchema>;
17
+ export type JoinResponse = z.infer<typeof joinResponseSchema>;
18
+ //# sourceMappingURL=join.d.ts.map
@@ -0,0 +1,28 @@
1
+ import "../../chunk-gOLHoazu.js";
2
+ import { z } from "zod";
3
+ //#region src/protocol/messages/join.ts
4
+ /** Join request sent by a new orchestrator (via Platform relay or direct peer). */
5
+ const joinRequestSchema = z.object({
6
+ type: z.literal("join.request"),
7
+ /** Correlation ID for Platform relay routing. Platform injects this on relay to match
8
+ * join.response back to the correct joining orchestrator when multiple joiners
9
+ * are active concurrently. */
10
+ messageId: z.string().optional(),
11
+ /** The full join token: kici_join_v1.<base64url_routing>.<secret_hex> */
12
+ token: z.string()
13
+ });
14
+ /** Join response from an existing orchestrator back to the joiner. */
15
+ const joinResponseSchema = z.object({
16
+ type: z.literal("join.response"),
17
+ /** Correlation ID echoed from join.request for Platform relay routing. */
18
+ messageId: z.string().optional(),
19
+ success: z.boolean(),
20
+ /** Base64-encoded AES-256-GCM encrypted config bundle (present on success). */
21
+ encryptedBundle: z.string().optional(),
22
+ /** Error message (present on failure). */
23
+ error: z.string().optional()
24
+ });
25
+ //#endregion
26
+ export { joinRequestSchema, joinResponseSchema };
27
+
28
+ //# sourceMappingURL=join.js.map
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ /** Log pull messages flowing from Platform to Orchestrator. */
3
+ export declare const logPullPlatformToOrchSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"log.request">;
5
+ messageId: z.ZodString;
6
+ executionId: z.ZodString;
7
+ jobName: z.ZodOptional<z.ZodString>;
8
+ stepIndex: z.ZodOptional<z.ZodNumber>;
9
+ cursor: z.ZodOptional<z.ZodNumber>;
10
+ limit: z.ZodOptional<z.ZodNumber>;
11
+ }, z.core.$strip>;
12
+ /** Log pull messages flowing from Orchestrator to Platform. */
13
+ export declare const logPullOrchToPlatformSchema: z.ZodObject<{
14
+ type: z.ZodLiteral<"log.response">;
15
+ messageId: z.ZodString;
16
+ executionId: z.ZodString;
17
+ chunks: z.ZodArray<z.ZodObject<{
18
+ jobName: z.ZodString;
19
+ stepIndex: z.ZodNumber;
20
+ lines: z.ZodArray<z.ZodString>;
21
+ timestamp: z.ZodNumber;
22
+ }, z.core.$strip>>;
23
+ cursor: z.ZodOptional<z.ZodNumber>;
24
+ complete: z.ZodBoolean;
25
+ error: z.ZodOptional<z.ZodString>;
26
+ }, z.core.$strip>;
27
+ //# sourceMappingURL=log-pull.d.ts.map
@@ -0,0 +1,36 @@
1
+ import "../../chunk-gOLHoazu.js";
2
+ import { z } from "zod";
3
+ //#region src/protocol/messages/log-pull.ts
4
+ /** Request historical logs for a completed or running execution. */
5
+ const logRequestSchema = z.object({
6
+ type: z.literal("log.request"),
7
+ messageId: z.string(),
8
+ executionId: z.string(),
9
+ jobName: z.string().optional(),
10
+ stepIndex: z.number().optional(),
11
+ cursor: z.number().optional(),
12
+ limit: z.number().optional()
13
+ });
14
+ /** Response with log data (correlates to log.request). */
15
+ const logResponseSchema = z.object({
16
+ type: z.literal("log.response"),
17
+ messageId: z.string(),
18
+ executionId: z.string(),
19
+ chunks: z.array(z.object({
20
+ jobName: z.string(),
21
+ stepIndex: z.number(),
22
+ lines: z.array(z.string()),
23
+ timestamp: z.number()
24
+ })),
25
+ cursor: z.number().optional(),
26
+ complete: z.boolean(),
27
+ error: z.string().optional()
28
+ });
29
+ /** Log pull messages flowing from Platform to Orchestrator. */
30
+ const logPullPlatformToOrchSchema = logRequestSchema;
31
+ /** Log pull messages flowing from Orchestrator to Platform. */
32
+ const logPullOrchToPlatformSchema = logResponseSchema;
33
+ //#endregion
34
+ export { logPullOrchToPlatformSchema, logPullPlatformToOrchSchema };
35
+
36
+ //# sourceMappingURL=log-pull.js.map
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ /** Subscribe to observe a running test execution. */
3
+ export declare const observeSubscribeSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"observe.subscribe">;
5
+ runId: z.ZodString;
6
+ token: z.ZodString;
7
+ lastSeenSequence: z.ZodOptional<z.ZodNumber>;
8
+ }, z.core.$strip>;
9
+ /** Run status update sent to observer. */
10
+ export declare const observeStatusSchema: z.ZodObject<{
11
+ type: z.ZodLiteral<"observe.status">;
12
+ runId: z.ZodString;
13
+ status: z.ZodEnum<{
14
+ success: "success";
15
+ pending: "pending";
16
+ running: "running";
17
+ failed: "failed";
18
+ cancelled: "cancelled";
19
+ cancelling: "cancelling";
20
+ }>;
21
+ jobName: z.ZodOptional<z.ZodString>;
22
+ timestamp: z.ZodNumber;
23
+ }, z.core.$strip>;
24
+ /** Log chunk sent to observer. */
25
+ export declare const observeLogSchema: z.ZodObject<{
26
+ type: z.ZodLiteral<"observe.log">;
27
+ runId: z.ZodString;
28
+ jobId: z.ZodString;
29
+ jobName: z.ZodString;
30
+ stepIndex: z.ZodNumber;
31
+ stepName: z.ZodString;
32
+ lines: z.ZodArray<z.ZodString>;
33
+ sequence: z.ZodNumber;
34
+ timestamp: z.ZodNumber;
35
+ }, z.core.$strip>;
36
+ /** Step lifecycle event sent to observer. */
37
+ export declare const observeStepSchema: z.ZodObject<{
38
+ type: z.ZodLiteral<"observe.step">;
39
+ runId: z.ZodString;
40
+ jobId: z.ZodString;
41
+ jobName: z.ZodString;
42
+ stepName: z.ZodString;
43
+ state: z.ZodEnum<{
44
+ success: "success";
45
+ pending: "pending";
46
+ running: "running";
47
+ failed: "failed";
48
+ skipped: "skipped";
49
+ }>;
50
+ durationMs: z.ZodOptional<z.ZodNumber>;
51
+ timestamp: z.ZodNumber;
52
+ }, z.core.$strip>;
53
+ /** Run completion summary sent to observer. */
54
+ export declare const observeCompleteSchema: z.ZodObject<{
55
+ type: z.ZodLiteral<"observe.complete">;
56
+ runId: z.ZodString;
57
+ status: z.ZodEnum<{
58
+ success: "success";
59
+ failed: "failed";
60
+ cancelled: "cancelled";
61
+ }>;
62
+ summary: z.ZodObject<{
63
+ totalDurationMs: z.ZodNumber;
64
+ jobs: z.ZodArray<z.ZodObject<{
65
+ name: z.ZodString;
66
+ status: z.ZodString;
67
+ durationMs: z.ZodOptional<z.ZodNumber>;
68
+ }, z.core.$strip>>;
69
+ }, z.core.$strip>;
70
+ }, z.core.$strip>;
71
+ export type ObserveStatus = z.infer<typeof observeStatusSchema>;
72
+ export type ObserveLog = z.infer<typeof observeLogSchema>;
73
+ export type ObserveStep = z.infer<typeof observeStepSchema>;
74
+ export type ObserveComplete = z.infer<typeof observeCompleteSchema>;
75
+ //# sourceMappingURL=observe.d.ts.map
@@ -0,0 +1,70 @@
1
+ import "../../chunk-gOLHoazu.js";
2
+ import { ExecutionRunStatus } from "./execution-status.js";
3
+ import { z } from "zod";
4
+ //#region src/protocol/messages/observe.ts
5
+ /** Subscribe to observe a running test execution. */
6
+ const observeSubscribeSchema = z.object({
7
+ type: z.literal("observe.subscribe"),
8
+ runId: z.string(),
9
+ token: z.string(),
10
+ lastSeenSequence: z.number().optional()
11
+ });
12
+ /** Run status update sent to observer. */
13
+ const observeStatusSchema = z.object({
14
+ type: z.literal("observe.status"),
15
+ runId: z.string(),
16
+ status: ExecutionRunStatus,
17
+ jobName: z.string().optional(),
18
+ timestamp: z.number()
19
+ });
20
+ /** Log chunk sent to observer. */
21
+ const observeLogSchema = z.object({
22
+ type: z.literal("observe.log"),
23
+ runId: z.string(),
24
+ jobId: z.string(),
25
+ jobName: z.string(),
26
+ stepIndex: z.number(),
27
+ stepName: z.string(),
28
+ lines: z.array(z.string()),
29
+ sequence: z.number(),
30
+ timestamp: z.number()
31
+ });
32
+ /** Step lifecycle event sent to observer. */
33
+ const observeStepSchema = z.object({
34
+ type: z.literal("observe.step"),
35
+ runId: z.string(),
36
+ jobId: z.string(),
37
+ jobName: z.string(),
38
+ stepName: z.string(),
39
+ state: z.enum([
40
+ "pending",
41
+ "running",
42
+ "success",
43
+ "failed",
44
+ "skipped"
45
+ ]),
46
+ durationMs: z.number().optional(),
47
+ timestamp: z.number()
48
+ });
49
+ /** Run completion summary sent to observer. */
50
+ const observeCompleteSchema = z.object({
51
+ type: z.literal("observe.complete"),
52
+ runId: z.string(),
53
+ status: z.enum([
54
+ "success",
55
+ "failed",
56
+ "cancelled"
57
+ ]),
58
+ summary: z.object({
59
+ totalDurationMs: z.number(),
60
+ jobs: z.array(z.object({
61
+ name: z.string(),
62
+ status: z.string(),
63
+ durationMs: z.number().optional()
64
+ }))
65
+ })
66
+ });
67
+ //#endregion
68
+ export { observeCompleteSchema, observeLogSchema, observeStatusSchema, observeStepSchema, observeSubscribeSchema };
69
+
70
+ //# sourceMappingURL=observe.js.map