@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.
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,175 @@
1
+ import "../../chunk-gOLHoazu.js";
2
+ import { ActorType, actorPrincipalSchema } from "./actor.js";
3
+ import { z } from "zod";
4
+ //#region src/protocol/messages/access-log.ts
5
+ /**
6
+ * Access log enums + dashboard protocol schemas.
7
+ *
8
+ * The orchestrator `access_log` table captures every read AND
9
+ * orchestrator-admin mutation attributable to an ActorPrincipal. These enums
10
+ * are the single source of truth for the column values; SQL, CLI filters,
11
+ * dashboard UI, and tests all import from here.
12
+ *
13
+ * secret_audit_log stays as-is for secret *mutations* (create/update/delete).
14
+ * access_log covers secret *reveals* (read-side attribution) and all other
15
+ * reads/mutations surfaced via Platform proxy or orchestrator admin HTTP.
16
+ */
17
+ /** Where the access-log entry was originated from. */
18
+ const AccessLogSource = z.enum([
19
+ "platform_proxy",
20
+ "admin_http",
21
+ "admin_cli"
22
+ ]);
23
+ /** Outcome of the attempted action. */
24
+ const AccessLogOutcome = z.enum([
25
+ "allowed",
26
+ "denied",
27
+ "error"
28
+ ]);
29
+ /** Target object category. */
30
+ const AccessLogTargetType = z.enum([
31
+ "run",
32
+ "job",
33
+ "step",
34
+ "payload",
35
+ "event_log",
36
+ "event_log_payload",
37
+ "secret_scope",
38
+ "environment",
39
+ "registration",
40
+ "backend",
41
+ "diagnostics",
42
+ "scaler",
43
+ "held_run",
44
+ "access_log",
45
+ "event_dlq"
46
+ ]);
47
+ /**
48
+ * Dotted-namespace action names. Every handler that writes an access_log
49
+ * row uses one of these values; a new handler means adding a new entry here.
50
+ */
51
+ const AccessLogAction = z.enum([
52
+ "run.detail.read",
53
+ "run.payload.read",
54
+ "run.orch_logs.read",
55
+ "step.logs.read",
56
+ "run.cancel",
57
+ "run.rerun",
58
+ "run.manual_schedule",
59
+ "job.cancel",
60
+ "event_log.list.read",
61
+ "event_log.detail.read",
62
+ "event_log.payload.read",
63
+ "environment.list.read",
64
+ "environment.get.read",
65
+ "environment.create",
66
+ "environment.update",
67
+ "environment.delete",
68
+ "env_var.list.read",
69
+ "env_var.set",
70
+ "env_var.delete",
71
+ "source_override.list.read",
72
+ "source_override.set",
73
+ "source_override.delete",
74
+ "env_binding.list.read",
75
+ "env_binding.set",
76
+ "secret.list.read",
77
+ "secret.set",
78
+ "secret.delete",
79
+ "secret.reveal",
80
+ "secret_scope.create",
81
+ "secret_scope.rename",
82
+ "secret_scope.delete",
83
+ "environment.history.read",
84
+ "held_run.list.read",
85
+ "held_run.approve",
86
+ "held_run.reject",
87
+ "registration.list.read",
88
+ "registration.disable",
89
+ "registration.delete",
90
+ "diagnostics.read",
91
+ "scaler.capacity.read",
92
+ "scaler.agents.read",
93
+ "backend.list.read",
94
+ "backend.get.read",
95
+ "backend.sync",
96
+ "backend.sync.one",
97
+ "backend.test",
98
+ "global_workflows.get.read",
99
+ "global_workflows.update",
100
+ "access_log.list.read",
101
+ "event_dlq.list.read",
102
+ "event_dlq.retry",
103
+ "event_dlq.discard",
104
+ "archive_chunk"
105
+ ]);
106
+ /**
107
+ * Single row as surfaced to the dashboard / CLI. Includes optional
108
+ * displayName/email for `user` and `platform_operator` actors — those are
109
+ * resolved Platform-side by joining `actor_id` against the ZITADEL-backed
110
+ * `users` table. The orchestrator never returns them; it emits a minimal
111
+ * row and Platform enriches before forwarding to the browser.
112
+ */
113
+ const accessLogItemSchema = z.object({
114
+ id: z.string(),
115
+ orgId: z.string().nullable(),
116
+ routingKey: z.string().nullable(),
117
+ actorType: ActorType,
118
+ actorId: z.string(),
119
+ actorMeta: z.record(z.string(), z.unknown()).nullable(),
120
+ /** Resolved by Platform when actor_type is user / platform_operator. */
121
+ actorEmail: z.string().nullable().optional(),
122
+ actorDisplayName: z.string().nullable().optional(),
123
+ action: AccessLogAction,
124
+ targetType: AccessLogTargetType.nullable(),
125
+ targetId: z.string().nullable(),
126
+ requestId: z.string().nullable(),
127
+ source: AccessLogSource,
128
+ outcome: AccessLogOutcome,
129
+ errorMessage: z.string().nullable(),
130
+ createdAt: z.string()
131
+ });
132
+ /** Shared filter shape reused by Platform proxy + orchestrator HTTP + CLI. */
133
+ const accessLogFilterSchema = z.object({
134
+ actorType: ActorType.optional(),
135
+ actorId: z.string().optional(),
136
+ action: AccessLogAction.optional(),
137
+ source: AccessLogSource.optional(),
138
+ outcome: AccessLogOutcome.optional(),
139
+ targetType: AccessLogTargetType.optional(),
140
+ targetId: z.string().optional(),
141
+ fromTimestamp: z.string().optional(),
142
+ toTimestamp: z.string().optional(),
143
+ limit: z.number().int().positive().max(200).optional(),
144
+ cursor: z.string().optional()
145
+ });
146
+ const dashboardAccessLogListRequestSchema = z.object({
147
+ type: z.literal("dashboard.access-log.list"),
148
+ requestId: z.string(),
149
+ actor: actorPrincipalSchema,
150
+ orgId: z.string(),
151
+ actorType: ActorType.optional(),
152
+ actorId: z.string().optional(),
153
+ action: AccessLogAction.optional(),
154
+ source: AccessLogSource.optional(),
155
+ outcome: AccessLogOutcome.optional(),
156
+ targetType: AccessLogTargetType.optional(),
157
+ targetId: z.string().optional(),
158
+ fromTimestamp: z.string().optional(),
159
+ toTimestamp: z.string().optional(),
160
+ /** Full-text search over `error_message` (trigram-indexed via migration 009). */
161
+ q: z.string().optional(),
162
+ limit: z.number().int().positive().max(200).optional(),
163
+ cursor: z.string().optional()
164
+ });
165
+ const dashboardAccessLogListResponseSchema = z.object({
166
+ type: z.literal("dashboard.access-log.list.response"),
167
+ requestId: z.string(),
168
+ items: z.array(accessLogItemSchema).optional(),
169
+ nextCursor: z.string().nullable().optional(),
170
+ error: z.string().optional()
171
+ });
172
+ //#endregion
173
+ export { AccessLogAction, AccessLogOutcome, AccessLogSource, AccessLogTargetType, accessLogFilterSchema, accessLogItemSchema, dashboardAccessLogListRequestSchema, dashboardAccessLogListResponseSchema };
174
+
175
+ //# sourceMappingURL=access-log.js.map
@@ -0,0 +1,100 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Typed actor principal for attributable reads, writes, and admin operations
4
+ * across the Platform → orchestrator and orchestrator → agent boundaries.
5
+ *
6
+ * Every dashboard.* / run.* proxy message carries an `actor` field so the
7
+ * orchestrator can write an `access_log` row attributable to a specific
8
+ * principal. The discriminated union prevents string-shape drift between
9
+ * tiers and encodes the reason for break-glass operator access at the
10
+ * protocol level rather than in free-text metadata.
11
+ */
12
+ export declare const ActorType: z.ZodEnum<{
13
+ user: "user";
14
+ api_key: "api_key";
15
+ service_account: "service_account";
16
+ platform_operator: "platform_operator";
17
+ system: "system";
18
+ }>;
19
+ export type ActorType = z.infer<typeof ActorType>;
20
+ export declare const userActorSchema: z.ZodObject<{
21
+ type: z.ZodLiteral<"user">;
22
+ sub: z.ZodString;
23
+ }, z.core.$strip>;
24
+ export type UserActor = z.infer<typeof userActorSchema>;
25
+ export declare const apiKeyActorSchema: z.ZodObject<{
26
+ type: z.ZodLiteral<"api_key">;
27
+ keyId: z.ZodString;
28
+ ownerSub: z.ZodString;
29
+ }, z.core.$strip>;
30
+ export type ApiKeyActor = z.infer<typeof apiKeyActorSchema>;
31
+ export declare const serviceAccountActorSchema: z.ZodObject<{
32
+ type: z.ZodLiteral<"service_account">;
33
+ id: z.ZodString;
34
+ }, z.core.$strip>;
35
+ export type ServiceAccountActor = z.infer<typeof serviceAccountActorSchema>;
36
+ export declare const platformOperatorActorSchema: z.ZodObject<{
37
+ type: z.ZodLiteral<"platform_operator">;
38
+ sub: z.ZodString;
39
+ reason: z.ZodString;
40
+ }, z.core.$strip>;
41
+ export type PlatformOperatorActor = z.infer<typeof platformOperatorActorSchema>;
42
+ export declare const systemActorSchema: z.ZodObject<{
43
+ type: z.ZodLiteral<"system">;
44
+ component: z.ZodString;
45
+ }, z.core.$strip>;
46
+ export type SystemActor = z.infer<typeof systemActorSchema>;
47
+ export declare const actorPrincipalSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
48
+ type: z.ZodLiteral<"user">;
49
+ sub: z.ZodString;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ type: z.ZodLiteral<"api_key">;
52
+ keyId: z.ZodString;
53
+ ownerSub: z.ZodString;
54
+ }, z.core.$strip>, z.ZodObject<{
55
+ type: z.ZodLiteral<"service_account">;
56
+ id: z.ZodString;
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ type: z.ZodLiteral<"platform_operator">;
59
+ sub: z.ZodString;
60
+ reason: z.ZodString;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"system">;
63
+ component: z.ZodString;
64
+ }, z.core.$strip>], "type">;
65
+ export type ActorPrincipal = z.infer<typeof actorPrincipalSchema>;
66
+ /**
67
+ * Convert an ActorPrincipal to a colon-prefixed string suitable for DB
68
+ * persistence in columns like `execution_runs.triggered_by` / `.cancelled_by`.
69
+ * The inverse of parseActor().
70
+ *
71
+ * Format: `${type}:${id}` where id is the variant's natural identifier.
72
+ * Extra metadata (api_key.ownerSub, platform_operator.reason) is NOT
73
+ * round-tripped through the string form — callers that need full fidelity
74
+ * must persist the actor object separately (e.g. in `access_log.actor_meta`).
75
+ */
76
+ export declare function stringifyActor(actor: ActorPrincipal): string;
77
+ /**
78
+ * Parse a `${type}:${id}` string back into a partial ActorPrincipal.
79
+ * Because the string form drops metadata, api_key.ownerSub and
80
+ * platform_operator.reason are null when the source is a string.
81
+ *
82
+ * Returns null for unrecognized inputs; callers that need strict parsing
83
+ * should throw on null.
84
+ */
85
+ export declare function parseActor(value: string | null | undefined): {
86
+ type: ActorType;
87
+ id: string;
88
+ } | null;
89
+ /**
90
+ * Flatten an ActorPrincipal into the three columns the orchestrator
91
+ * `access_log` table uses: (actor_type, actor_id, actor_meta).
92
+ * actor_meta preserves the variant-specific extras that are lost in
93
+ * stringifyActor().
94
+ */
95
+ export declare function flattenActor(actor: ActorPrincipal): {
96
+ actorType: ActorType;
97
+ actorId: string;
98
+ actorMeta: Record<string, unknown> | null;
99
+ };
100
+ //# sourceMappingURL=actor.d.ts.map
@@ -0,0 +1,139 @@
1
+ import "../../chunk-gOLHoazu.js";
2
+ import { z } from "zod";
3
+ //#region src/protocol/messages/actor.ts
4
+ /**
5
+ * Typed actor principal for attributable reads, writes, and admin operations
6
+ * across the Platform → orchestrator and orchestrator → agent boundaries.
7
+ *
8
+ * Every dashboard.* / run.* proxy message carries an `actor` field so the
9
+ * orchestrator can write an `access_log` row attributable to a specific
10
+ * principal. The discriminated union prevents string-shape drift between
11
+ * tiers and encodes the reason for break-glass operator access at the
12
+ * protocol level rather than in free-text metadata.
13
+ */
14
+ const ActorType = z.enum([
15
+ "user",
16
+ "api_key",
17
+ "service_account",
18
+ "platform_operator",
19
+ "system"
20
+ ]);
21
+ const userActorSchema = z.object({
22
+ type: z.literal(ActorType.enum.user),
23
+ /** ZITADEL subject. */
24
+ sub: z.string().min(1)
25
+ });
26
+ const apiKeyActorSchema = z.object({
27
+ type: z.literal(ActorType.enum.api_key),
28
+ /** Opaque key identifier (not the secret). */
29
+ keyId: z.string().min(1),
30
+ /** ZITADEL sub of the human who owns this key. */
31
+ ownerSub: z.string().min(1)
32
+ });
33
+ const serviceAccountActorSchema = z.object({
34
+ type: z.literal(ActorType.enum.service_account),
35
+ /** Service-account identifier (orchestrator admin tokens, CI bot tokens, etc.). */
36
+ id: z.string().min(1)
37
+ });
38
+ const platformOperatorActorSchema = z.object({
39
+ type: z.literal(ActorType.enum.platform_operator),
40
+ /** ZITADEL sub of the SaaS operator performing break-glass access. */
41
+ sub: z.string().min(1),
42
+ /**
43
+ * Free-text justification recorded in `access_log.actor_meta.reason`.
44
+ * Length bounds reject empty / obviously-bad-faith values; not a ticket
45
+ * pattern (we support multiple incident systems).
46
+ */
47
+ reason: z.string().min(10).max(200)
48
+ });
49
+ const systemActorSchema = z.object({
50
+ type: z.literal(ActorType.enum.system),
51
+ /** Subsystem initiating the action (e.g. 'scheduler', 'retry', 'cleanup'). */
52
+ component: z.string().min(1)
53
+ });
54
+ const actorPrincipalSchema = z.discriminatedUnion("type", [
55
+ userActorSchema,
56
+ apiKeyActorSchema,
57
+ serviceAccountActorSchema,
58
+ platformOperatorActorSchema,
59
+ systemActorSchema
60
+ ]);
61
+ /**
62
+ * Convert an ActorPrincipal to a colon-prefixed string suitable for DB
63
+ * persistence in columns like `execution_runs.triggered_by` / `.cancelled_by`.
64
+ * The inverse of parseActor().
65
+ *
66
+ * Format: `${type}:${id}` where id is the variant's natural identifier.
67
+ * Extra metadata (api_key.ownerSub, platform_operator.reason) is NOT
68
+ * round-tripped through the string form — callers that need full fidelity
69
+ * must persist the actor object separately (e.g. in `access_log.actor_meta`).
70
+ */
71
+ function stringifyActor(actor) {
72
+ switch (actor.type) {
73
+ case "user": return `user:${actor.sub}`;
74
+ case "api_key": return `api_key:${actor.keyId}`;
75
+ case "service_account": return `service_account:${actor.id}`;
76
+ case "platform_operator": return `platform_operator:${actor.sub}`;
77
+ case "system": return `system:${actor.component}`;
78
+ }
79
+ }
80
+ /**
81
+ * Parse a `${type}:${id}` string back into a partial ActorPrincipal.
82
+ * Because the string form drops metadata, api_key.ownerSub and
83
+ * platform_operator.reason are null when the source is a string.
84
+ *
85
+ * Returns null for unrecognized inputs; callers that need strict parsing
86
+ * should throw on null.
87
+ */
88
+ function parseActor(value) {
89
+ if (value == null || value === "") return null;
90
+ const idx = value.indexOf(":");
91
+ if (idx < 1 || idx === value.length - 1) return null;
92
+ const prefix = value.slice(0, idx);
93
+ const id = value.slice(idx + 1);
94
+ const parsed = ActorType.safeParse(prefix);
95
+ if (!parsed.success) return null;
96
+ return {
97
+ type: parsed.data,
98
+ id
99
+ };
100
+ }
101
+ /**
102
+ * Flatten an ActorPrincipal into the three columns the orchestrator
103
+ * `access_log` table uses: (actor_type, actor_id, actor_meta).
104
+ * actor_meta preserves the variant-specific extras that are lost in
105
+ * stringifyActor().
106
+ */
107
+ function flattenActor(actor) {
108
+ switch (actor.type) {
109
+ case "user": return {
110
+ actorType: "user",
111
+ actorId: actor.sub,
112
+ actorMeta: null
113
+ };
114
+ case "api_key": return {
115
+ actorType: "api_key",
116
+ actorId: actor.keyId,
117
+ actorMeta: { ownerSub: actor.ownerSub }
118
+ };
119
+ case "service_account": return {
120
+ actorType: "service_account",
121
+ actorId: actor.id,
122
+ actorMeta: null
123
+ };
124
+ case "platform_operator": return {
125
+ actorType: "platform_operator",
126
+ actorId: actor.sub,
127
+ actorMeta: { reason: actor.reason }
128
+ };
129
+ case "system": return {
130
+ actorType: "system",
131
+ actorId: actor.component,
132
+ actorMeta: null
133
+ };
134
+ }
135
+ }
136
+ //#endregion
137
+ export { ActorType, actorPrincipalSchema, apiKeyActorSchema, flattenActor, parseActor, platformOperatorActorSchema, serviceAccountActorSchema, stringifyActor, systemActorSchema, userActorSchema };
138
+
139
+ //# sourceMappingURL=actor.js.map
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ /** Auth request sent by orchestrator to Platform when connecting via WebSocket. */
3
+ export declare const authRequestSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"auth.request">;
5
+ token: z.ZodString;
6
+ protocolVersion: z.ZodNumber;
7
+ capabilities: z.ZodOptional<z.ZodObject<{
8
+ orchRole: z.ZodOptional<z.ZodEnum<{
9
+ coordinator: "coordinator";
10
+ worker: "worker";
11
+ }>>;
12
+ }, z.core.$loose>>;
13
+ }, z.core.$strip>;
14
+ /** Auth success response sent by Platform to orchestrator after successful authentication. */
15
+ export declare const authSuccessSchema: z.ZodObject<{
16
+ type: z.ZodLiteral<"auth.success">;
17
+ connectionId: z.ZodString;
18
+ orgPublicAlias: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>;
20
+ /** Auth failure response sent by Platform to orchestrator when authentication fails. */
21
+ export declare const authFailureSchema: z.ZodObject<{
22
+ type: z.ZodLiteral<"auth.failure">;
23
+ reason: z.ZodString;
24
+ }, z.core.$strip>;
25
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1,36 @@
1
+ import "../../chunk-gOLHoazu.js";
2
+ import { orchCapabilitiesSchema } from "./capabilities.js";
3
+ import { z } from "zod";
4
+ //#region src/protocol/messages/auth.ts
5
+ /** Auth request sent by orchestrator to Platform when connecting via WebSocket. */
6
+ const authRequestSchema = z.object({
7
+ type: z.literal("auth.request"),
8
+ token: z.string().min(1),
9
+ protocolVersion: z.number().int().positive(),
10
+ /** Orchestrator capabilities (optional for backward compat with pre-capability orchestrators). */
11
+ capabilities: orchCapabilitiesSchema.optional()
12
+ });
13
+ /** Auth success response sent by Platform to orchestrator after successful authentication. */
14
+ const authSuccessSchema = z.object({
15
+ type: z.literal("auth.success"),
16
+ connectionId: z.string(),
17
+ /**
18
+ * Public alias of the authenticated orchestrator's owning org
19
+ * (`oal_<12-char>`). Used by the orchestrator's check-run emitter to
20
+ * build a `details_url` that points at the dashboard's resolver
21
+ * route, so the canonical `org_<12-char>` id never appears in URLs
22
+ * that reach public surfaces. Optional for back-compat with Platforms
23
+ * that don't yet supply it; when absent, the orchestrator skips
24
+ * `details_url` (preserving today's behaviour).
25
+ */
26
+ orgPublicAlias: z.string().optional()
27
+ });
28
+ /** Auth failure response sent by Platform to orchestrator when authentication fails. */
29
+ const authFailureSchema = z.object({
30
+ type: z.literal("auth.failure"),
31
+ reason: z.string()
32
+ });
33
+ //#endregion
34
+ export { authFailureSchema, authRequestSchema, authSuccessSchema };
35
+
36
+ //# sourceMappingURL=auth.js.map