@h-rig/core 0.0.6-alpha.17 → 0.0.6-alpha.170

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 (107) hide show
  1. package/dist/src/agent-role-registry.d.ts +4 -0
  2. package/dist/src/agent-role-registry.js +27 -0
  3. package/dist/src/authority-paths.d.ts +15 -0
  4. package/dist/src/authority-paths.js +80 -0
  5. package/dist/src/baked-secrets.d.ts +6 -0
  6. package/dist/src/baked-secrets.js +121 -0
  7. package/dist/src/build-time-config.d.ts +12 -0
  8. package/dist/src/build-time-config.js +25 -0
  9. package/dist/src/build-time-config.macro.d.ts +1 -0
  10. package/dist/src/capability-loaders.d.ts +51 -0
  11. package/dist/src/capability-loaders.js +758 -0
  12. package/dist/src/capability.d.ts +79 -0
  13. package/dist/src/capability.js +63 -0
  14. package/dist/src/checkout-root.d.ts +1 -0
  15. package/dist/src/checkout-root.js +30 -0
  16. package/dist/src/config-env.d.ts +4 -0
  17. package/dist/src/config-env.js +23 -0
  18. package/dist/src/config.d.ts +3 -0
  19. package/dist/src/config.js +44 -0
  20. package/dist/src/declarative-config.d.ts +14 -0
  21. package/dist/src/declarative-config.js +82 -0
  22. package/dist/src/default-kernel.d.ts +1 -0
  23. package/dist/src/default-kernel.js +12 -0
  24. package/dist/src/define-config.d.ts +20 -0
  25. package/dist/src/define-config.js +28 -15
  26. package/dist/src/define-plugin.d.ts +13 -0
  27. package/dist/src/define-plugin.js +4 -43
  28. package/dist/src/embedded-plugins.d.ts +59 -0
  29. package/dist/src/embedded-plugins.js +22 -0
  30. package/dist/src/exec.d.ts +13 -0
  31. package/dist/src/exec.js +101 -0
  32. package/dist/src/harness-paths.d.ts +18 -0
  33. package/dist/src/harness-paths.js +141 -0
  34. package/dist/src/hook-materializer.d.ts +72 -0
  35. package/dist/src/hook-materializer.js +281 -0
  36. package/dist/src/hook-protocol.d.ts +2 -0
  37. package/dist/src/hook-protocol.js +462 -0
  38. package/dist/src/hook-runner.d.ts +48 -0
  39. package/dist/src/hook-runner.js +756 -0
  40. package/dist/src/hook-runtime.d.ts +52 -0
  41. package/dist/src/hook-runtime.js +462 -0
  42. package/dist/src/index.d.ts +8 -0
  43. package/dist/src/index.js +210 -2499
  44. package/dist/src/json-files.d.ts +9 -0
  45. package/dist/src/json-files.js +125 -0
  46. package/dist/src/kernel-boot.d.ts +2 -0
  47. package/dist/src/kernel-boot.js +10 -0
  48. package/dist/src/kernel-entrypoint.d.ts +22 -0
  49. package/dist/src/kernel-entrypoint.js +548 -0
  50. package/dist/src/kernel-plugin-abi.d.ts +1 -0
  51. package/dist/src/kernel-plugin-abi.js +1 -0
  52. package/dist/src/kernel-resolver.d.ts +2 -0
  53. package/dist/src/kernel-resolver.js +6 -0
  54. package/dist/src/layout.d.ts +10 -0
  55. package/dist/src/layout.js +144 -0
  56. package/dist/src/load-config.d.ts +2 -0
  57. package/dist/src/load-config.js +423 -30
  58. package/dist/src/placement.d.ts +50 -0
  59. package/dist/src/placement.js +996 -0
  60. package/dist/src/plugin-host-context.d.ts +66 -0
  61. package/dist/src/plugin-host-context.js +1292 -0
  62. package/dist/src/plugin-host-registries.d.ts +31 -0
  63. package/dist/src/plugin-host-registries.js +79 -0
  64. package/dist/src/plugin-host.d.ts +77 -0
  65. package/dist/src/plugin-host.js +127 -63
  66. package/dist/src/plugin-runtime.d.ts +173 -0
  67. package/dist/src/profile-ops.d.ts +9 -0
  68. package/dist/src/profile-ops.js +252 -0
  69. package/dist/src/project-plugins.d.ts +63 -0
  70. package/dist/src/project-plugins.js +793 -0
  71. package/dist/src/remote-config.d.ts +183 -0
  72. package/dist/src/remote-config.js +574 -0
  73. package/dist/src/root-resolver.d.ts +5 -0
  74. package/dist/src/root-resolver.js +69 -0
  75. package/dist/src/run-provisioning.d.ts +58 -0
  76. package/dist/src/run-provisioning.js +128 -0
  77. package/dist/src/runtime-context.d.ts +20 -0
  78. package/dist/src/runtime-context.js +257 -0
  79. package/dist/src/runtime-events.d.ts +44 -0
  80. package/dist/src/runtime-events.js +212 -0
  81. package/dist/src/runtime-overlay.d.ts +11 -0
  82. package/dist/src/runtime-overlay.js +71 -0
  83. package/dist/src/runtime-paths.d.ts +21 -0
  84. package/dist/src/runtime-paths.js +181 -0
  85. package/dist/src/runtime-provisioning-env.d.ts +5 -0
  86. package/dist/src/runtime-provisioning-env.js +217 -0
  87. package/dist/src/runtime-runner-context.d.ts +12 -0
  88. package/dist/src/runtime-runner-context.js +1 -0
  89. package/dist/src/safe-identifiers.d.ts +44 -0
  90. package/dist/src/safe-identifiers.js +96 -0
  91. package/dist/src/scope-rules.d.ts +4 -0
  92. package/dist/src/scope-rules.js +21 -0
  93. package/dist/src/server-paths.d.ts +26 -0
  94. package/dist/src/server-paths.js +308 -0
  95. package/dist/src/setup-version.d.ts +3 -0
  96. package/dist/src/setup-version.js +14 -0
  97. package/dist/src/task-record-reader.d.ts +3 -0
  98. package/dist/src/task-record-reader.js +9 -0
  99. package/dist/src/validator-registry.d.ts +27 -0
  100. package/dist/src/validator-registry.js +64 -0
  101. package/package.json +166 -10
  102. package/dist/src/engineReadModelReducer.js +0 -1780
  103. package/dist/src/rig-init-builder.js +0 -57
  104. package/dist/src/rigSelectors.js +0 -293
  105. package/dist/src/taskGraph.js +0 -64
  106. package/dist/src/taskGraphCodes.js +0 -26
  107. package/dist/src/taskGraphLayout.js +0 -374
@@ -0,0 +1,308 @@
1
+ // @bun
2
+ // packages/core/src/server-paths.ts
3
+ import { existsSync as existsSync3 } from "fs";
4
+ import { dirname as dirname3, resolve as resolve4, relative as relative2 } from "path";
5
+
6
+ // packages/core/src/layout.ts
7
+ import {
8
+ RIG_ARTIFACTS_DIRNAME,
9
+ RIG_DEFINITION_DIRNAME,
10
+ RIG_STATE_DIRNAME
11
+ } from "@rig/contracts";
12
+
13
+ // packages/core/src/checkout-root.ts
14
+ import { dirname, resolve } from "path";
15
+ import { existsSync } from "fs";
16
+ function findNearestGitCheckoutRoot(startDir) {
17
+ let current = resolve(startDir);
18
+ for (;; ) {
19
+ if (existsSync(resolve(current, ".git")))
20
+ return current;
21
+ const parent = dirname(current);
22
+ if (parent === current)
23
+ return null;
24
+ current = parent;
25
+ }
26
+ }
27
+ function resolveCheckoutRoot(projectRoot) {
28
+ const normalizedProjectRoot = resolve(projectRoot);
29
+ const explicit = process.env.MONOREPO_ROOT?.trim();
30
+ if (explicit) {
31
+ const explicitRoot = resolve(explicit);
32
+ const gitRoot = findNearestGitCheckoutRoot(explicitRoot);
33
+ if (gitRoot)
34
+ return gitRoot;
35
+ throw new Error(`MONOREPO_ROOT points to ${explicitRoot}, but no git checkout was found there or above it.`);
36
+ }
37
+ return findNearestGitCheckoutRoot(normalizedProjectRoot) ?? normalizedProjectRoot;
38
+ }
39
+
40
+ // packages/core/src/layout.ts
41
+ var resolveMonorepoRoot = resolveCheckoutRoot;
42
+
43
+ // packages/core/src/safe-identifiers.ts
44
+ import { createHash, randomUUID } from "crypto";
45
+ import { isAbsolute, relative, resolve as resolve2 } from "path";
46
+ var MAX_SEGMENT_LENGTH = 80;
47
+ var MAX_RUN_ID_LENGTH = 128;
48
+ function hashSuffix(value, length = 10) {
49
+ return createHash("sha256").update(value).digest("hex").slice(0, length);
50
+ }
51
+ function asciiSlug(value, fallback) {
52
+ return value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").trim().replace(/[^A-Za-z0-9._-]+/g, "-").replace(/[.]{2,}/g, ".").replace(/^[.-]+|[.-]+$/g, "") || fallback;
53
+ }
54
+ function trimWithHash(base, original, maxLength) {
55
+ const suffix = hashSuffix(original);
56
+ const prefixLength = Math.max(1, maxLength - suffix.length - 1);
57
+ const prefix = base.slice(0, prefixLength).replace(/[.-]+$/g, "") || "id";
58
+ return `${prefix}-${suffix}`;
59
+ }
60
+ function safePathSegment(value, options = {}) {
61
+ const original = String(value);
62
+ const trimmed = original.trim();
63
+ const fallback = asciiSlug(options.fallback ?? "id", "id");
64
+ const slug = asciiSlug(original, fallback);
65
+ const maxLength = Math.max(24, Math.trunc(options.maxLength ?? MAX_SEGMENT_LENGTH));
66
+ if (trimmed === slug && slug.length <= maxLength && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(slug) && slug !== "." && slug !== "..") {
67
+ return slug;
68
+ }
69
+ return trimWithHash(slug, original, maxLength);
70
+ }
71
+ function isSafeRunId(value) {
72
+ const trimmed = value.trim();
73
+ return trimmed.length > 0 && trimmed.length <= MAX_RUN_ID_LENGTH && trimmed !== "." && trimmed !== ".." && !trimmed.startsWith("-") && !trimmed.includes("/") && !trimmed.includes("\\") && !trimmed.includes("\x00") && !/[\x00-\x1F\x7F]/.test(trimmed) && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(trimmed);
74
+ }
75
+ function assertSafeRunId(value) {
76
+ if (!isSafeRunId(value)) {
77
+ throw new Error("Invalid runId: expected a single safe identifier segment.");
78
+ }
79
+ return value.trim();
80
+ }
81
+ function isPathInsideRoot(root, candidate) {
82
+ const safeRoot = resolve2(root);
83
+ const resolvedCandidate = resolve2(candidate);
84
+ const relativeToRoot = relative(safeRoot, resolvedCandidate);
85
+ return relativeToRoot === "" || !relativeToRoot.startsWith("..") && !isAbsolute(relativeToRoot);
86
+ }
87
+ function assertPathInsideRoot(root, candidate, label = "path") {
88
+ const resolvedCandidate = resolve2(candidate);
89
+ if (!isPathInsideRoot(root, resolvedCandidate)) {
90
+ throw new Error(`${label} escapes root.`);
91
+ }
92
+ return resolvedCandidate;
93
+ }
94
+
95
+ // packages/core/src/authority-paths.ts
96
+ import { existsSync as existsSync2 } from "fs";
97
+ import { dirname as dirname2, resolve as resolve3 } from "path";
98
+ function normalizeOptionalString(value) {
99
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
100
+ }
101
+ function normalizeOptionalBoolean(value, fallback) {
102
+ if (typeof value !== "string") {
103
+ return fallback;
104
+ }
105
+ const normalized = value.trim().toLowerCase();
106
+ if (["1", "true", "yes", "on"].includes(normalized)) {
107
+ return true;
108
+ }
109
+ if (["0", "false", "no", "off"].includes(normalized)) {
110
+ return false;
111
+ }
112
+ return fallback;
113
+ }
114
+ function resolveAuthorityPaths(projectRoot) {
115
+ const normalizedRoot = resolve3(projectRoot);
116
+ const stateRoot = resolveAuthorityStateRoot(normalizedRoot);
117
+ const stateDir = resolveAuthorityStateDir(normalizedRoot);
118
+ return {
119
+ projectRoot: normalizedRoot,
120
+ harnessRoot: resolve3(normalizedRoot, "rig"),
121
+ runsDir: resolve3(stateRoot, "runs"),
122
+ remoteDir: resolve3(stateRoot, "remote"),
123
+ stateDir,
124
+ remoteEndpointsPath: resolve3(stateRoot, "remote", "endpoints.toml"),
125
+ remoteSecretsPath: resolve3(stateDir, "remote-secrets.toml")
126
+ };
127
+ }
128
+ function resolveAuthorityStateRoot(projectRoot) {
129
+ const normalizedRoot = resolve3(projectRoot);
130
+ const taskWorkspace = normalizeOptionalString(process.env.RIG_TASK_WORKSPACE);
131
+ if (taskWorkspace) {
132
+ return resolve3(taskWorkspace, ".rig");
133
+ }
134
+ const stateDir = normalizeOptionalString(process.env.RIG_STATE_DIR);
135
+ if (stateDir) {
136
+ return dirname2(resolve3(stateDir));
137
+ }
138
+ const logsDir = normalizeOptionalString(process.env.RIG_LOGS_DIR);
139
+ if (logsDir) {
140
+ return dirname2(resolve3(logsDir));
141
+ }
142
+ const sessionFile = normalizeOptionalString(process.env.RIG_SESSION_FILE);
143
+ if (sessionFile) {
144
+ return dirname2(dirname2(resolve3(sessionFile)));
145
+ }
146
+ const projectStateRoot = resolve3(normalizedRoot, ".rig");
147
+ if (existsSync2(projectStateRoot)) {
148
+ return projectStateRoot;
149
+ }
150
+ return resolve3(normalizedRoot, ".rig");
151
+ }
152
+ function resolveAuthorityStateDir(projectRoot) {
153
+ const explicit = normalizeOptionalString(process.env.RIG_STATE_DIR);
154
+ if (explicit) {
155
+ return resolve3(explicit);
156
+ }
157
+ return resolve3(resolveAuthorityStateRoot(projectRoot), "state");
158
+ }
159
+ function resolveAuthorityProjectStateDir(projectRoot) {
160
+ const explicit = normalizeOptionalString(process.env.RIG_STATE_DIR);
161
+ if (explicit) {
162
+ return resolve3(explicit);
163
+ }
164
+ return resolve3(resolve3(projectRoot), ".rig", "state");
165
+ }
166
+
167
+ // packages/core/src/server-paths.ts
168
+ function isPathWithin(root, candidate) {
169
+ const relativePath = relative2(root, candidate);
170
+ return relativePath === "" || !relativePath.startsWith("..") && !relativePath.startsWith("/") && !relativePath.startsWith("\\");
171
+ }
172
+ function uniquePaths(paths) {
173
+ const seen = new Set;
174
+ const result = [];
175
+ for (const value of paths) {
176
+ const normalized = normalizeOptionalString(value);
177
+ if (!normalized || seen.has(normalized))
178
+ continue;
179
+ seen.add(normalized);
180
+ result.push(normalized);
181
+ }
182
+ return result;
183
+ }
184
+ function resolveRigStatePaths(projectRoot) {
185
+ const taskWorkspace = normalizeOptionalString(process.env.RIG_TASK_WORKSPACE);
186
+ const explicitStateDir = normalizeOptionalString(process.env.RIG_STATE_DIR);
187
+ const explicitLogsDir = normalizeOptionalString(process.env.RIG_LOGS_DIR);
188
+ const explicitSessionFile = normalizeOptionalString(process.env.RIG_SESSION_FILE);
189
+ const hostStateRoot = resolve4(projectRoot, ".rig");
190
+ const monorepoRoot = resolveMonorepoRoot(projectRoot);
191
+ const monorepoStateRoot = resolve4(monorepoRoot, ".rig");
192
+ const stateRoot = taskWorkspace ? resolve4(taskWorkspace, ".rig") : explicitStateDir ? dirname3(resolve4(explicitStateDir)) : explicitLogsDir ? dirname3(resolve4(explicitLogsDir)) : explicitSessionFile ? dirname3(dirname3(resolve4(explicitSessionFile))) : existsSync3(hostStateRoot) ? hostStateRoot : monorepoStateRoot;
193
+ const stateDir = explicitStateDir ? resolve4(explicitStateDir) : resolve4(stateRoot, "state");
194
+ const logsDir = explicitLogsDir ? resolve4(explicitLogsDir) : resolve4(stateRoot, "logs");
195
+ const taskConfigPath = taskWorkspace ? resolve4(taskWorkspace, ".rig", "task-config.json") : existsSync3(resolve4(projectRoot, ".rig", "task-config.json")) ? resolve4(projectRoot, ".rig", "task-config.json") : resolve4(monorepoStateRoot, "task-config.json");
196
+ return {
197
+ stateRoot,
198
+ stateDir,
199
+ logsDir,
200
+ controlPlaneEventsFile: resolve4(logsDir, "control-plane.events.jsonl"),
201
+ taskConfigPath,
202
+ notificationsFile: resolve4(projectRoot, "rig", "notifications", "targets.json"),
203
+ keybindingsPath: resolve4(projectRoot, "rig", "keybindings.json")
204
+ };
205
+ }
206
+ function resolveRigProjectRoot(input) {
207
+ if (input?.envProjectRoot) {
208
+ return input.envProjectRoot;
209
+ }
210
+ const cwd = input?.cwd ?? process.cwd();
211
+ const fallbackRoot = input?.fallbackRoot ?? cwd;
212
+ const candidates = [cwd, fallbackRoot];
213
+ for (const candidate of candidates) {
214
+ if (existsSync3(resolve4(candidate, RIG_DEFINITION_DIRNAME))) {
215
+ return candidate;
216
+ }
217
+ }
218
+ return fallbackRoot;
219
+ }
220
+ function resolveAuthorityArtifactsRoot(projectRoot) {
221
+ const explicit = normalizeOptionalString(process.env.ARTIFACTS_DIR);
222
+ if (explicit) {
223
+ return resolve4(explicit);
224
+ }
225
+ const projectArtifactsRoot = resolve4(projectRoot, "artifacts");
226
+ if (existsSync3(projectArtifactsRoot)) {
227
+ return projectArtifactsRoot;
228
+ }
229
+ const taskWorkspace = normalizeOptionalString(process.env.RIG_TASK_WORKSPACE);
230
+ if (taskWorkspace) {
231
+ return resolve4(taskWorkspace, "artifacts");
232
+ }
233
+ if (normalizeOptionalString(process.env.MONOREPO_ROOT)) {
234
+ return resolve4(resolveMonorepoRoot(projectRoot), "artifacts");
235
+ }
236
+ const normalizedRoot = resolve4(projectRoot);
237
+ const projectLooksLikeMonorepo = existsSync3(resolve4(normalizedRoot, ".git")) && existsSync3(resolve4(normalizedRoot, "rig", "task-config.json"));
238
+ if (!projectLooksLikeMonorepo) {
239
+ return projectArtifactsRoot;
240
+ }
241
+ return resolve4(resolveMonorepoRoot(projectRoot), "artifacts");
242
+ }
243
+ function resolveAuthorityRuntimeDir(projectRoot) {
244
+ return resolve4(resolveAuthorityStateRoot(projectRoot), "runtime");
245
+ }
246
+ function listAuthorityRunRoots(projectRoot) {
247
+ const normalizedRoot = resolve4(projectRoot);
248
+ const monorepoRoot = resolveMonorepoRoot(normalizedRoot);
249
+ return uniquePaths([
250
+ resolve4(resolveAuthorityStateRoot(normalizedRoot), "runs"),
251
+ resolve4(monorepoRoot, ".rig", "runs")
252
+ ]);
253
+ }
254
+ function listAuthorityArtifactRoots(projectRoot) {
255
+ return uniquePaths([
256
+ resolveAuthorityArtifactsRoot(projectRoot)
257
+ ]);
258
+ }
259
+ function listAuthorityRuntimeAgentsRoots(projectRoot) {
260
+ return uniquePaths([
261
+ resolve4(resolveAuthorityRuntimeDir(projectRoot), "agents")
262
+ ]);
263
+ }
264
+ function resolveAuthorityRunDir(projectRoot, runId) {
265
+ const safeRunId = assertSafeRunId(runId);
266
+ const roots = listAuthorityRunRoots(projectRoot);
267
+ for (const runsDir of roots) {
268
+ const candidate = resolve4(runsDir, safeRunId);
269
+ if (existsSync3(candidate)) {
270
+ return candidate;
271
+ }
272
+ }
273
+ return resolve4(roots[0] ?? resolveAuthorityPaths(projectRoot).runsDir, safeRunId);
274
+ }
275
+ function resolveTaskArtifactDirs(projectRoot, taskId) {
276
+ const candidates = [];
277
+ const safeTaskSegment = safePathSegment(taskId, { fallback: "task", maxLength: 96 });
278
+ const seen = new Set;
279
+ const add = (value) => {
280
+ const normalized = normalizeOptionalString(value);
281
+ if (!normalized || seen.has(normalized))
282
+ return;
283
+ seen.add(normalized);
284
+ candidates.push(normalized);
285
+ };
286
+ for (const artifactsRoot of listAuthorityArtifactRoots(projectRoot)) {
287
+ add(assertPathInsideRoot(artifactsRoot, resolve4(artifactsRoot, safeTaskSegment), "artifact directory"));
288
+ }
289
+ return candidates;
290
+ }
291
+ export {
292
+ resolveTaskArtifactDirs,
293
+ resolveRigStatePaths,
294
+ resolveRigProjectRoot,
295
+ resolveAuthorityStateRoot,
296
+ resolveAuthorityStateDir,
297
+ resolveAuthorityRuntimeDir,
298
+ resolveAuthorityRunDir,
299
+ resolveAuthorityProjectStateDir,
300
+ resolveAuthorityPaths,
301
+ resolveAuthorityArtifactsRoot,
302
+ normalizeOptionalString,
303
+ normalizeOptionalBoolean,
304
+ listAuthorityRuntimeAgentsRoots,
305
+ listAuthorityRunRoots,
306
+ listAuthorityArtifactRoots,
307
+ isPathWithin
308
+ };
@@ -0,0 +1,3 @@
1
+ export declare const MIN_SUPPORTED_BUN_VERSION = "1.3.11";
2
+ export declare function normalizeSemverCore(version: string): string;
3
+ export declare function isSupportedBunVersion(version: string): boolean;
@@ -0,0 +1,14 @@
1
+ // @bun
2
+ // packages/core/src/setup-version.ts
3
+ var MIN_SUPPORTED_BUN_VERSION = "1.3.11";
4
+ function normalizeSemverCore(version) {
5
+ return version.replace(/^v/, "").split("-")[0]?.split("+")[0] ?? version;
6
+ }
7
+ function isSupportedBunVersion(version) {
8
+ return Bun.semver.order(normalizeSemverCore(version), MIN_SUPPORTED_BUN_VERSION) >= 0;
9
+ }
10
+ export {
11
+ normalizeSemverCore,
12
+ isSupportedBunVersion,
13
+ MIN_SUPPORTED_BUN_VERSION
14
+ };
@@ -0,0 +1,3 @@
1
+ import type { TaskRecord, TaskRecordReader } from "@rig/contracts";
2
+ export type { TaskRecordReader };
3
+ export declare function findTaskById(reader: TaskRecordReader, id: string): Promise<TaskRecord | null>;
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ // packages/core/src/task-record-reader.ts
3
+ async function findTaskById(reader, id) {
4
+ const tasks = await reader.listTasks();
5
+ return tasks.find((task) => task.id === id) ?? null;
6
+ }
7
+ export {
8
+ findTaskById
9
+ };
@@ -0,0 +1,27 @@
1
+ import type { ValidatorRegistration } from "@rig/contracts";
2
+ export interface ValidatorResult {
3
+ id: string;
4
+ passed: boolean;
5
+ summary: string;
6
+ details?: string;
7
+ }
8
+ export interface ValidatorContext {
9
+ taskId: string;
10
+ workspaceRoot: string;
11
+ scope: readonly string[];
12
+ /** Absolute path to the monorepo checkout root (MONOREPO_ROOT / MONOREPO_MAIN_ROOT env equiv). */
13
+ monorepoRoot?: string;
14
+ /** Absolute path to the task's artifacts output directory (ARTIFACTS_DIR env equiv). */
15
+ artifactsDir?: string;
16
+ /** The full task config entry for this task — opaque to the registry, but available for advanced validators. */
17
+ taskConfig?: unknown;
18
+ }
19
+ export interface RegisteredValidator extends ValidatorRegistration {
20
+ run(ctx: ValidatorContext): Promise<ValidatorResult>;
21
+ }
22
+ export interface ValidatorRegistry {
23
+ register(v: RegisteredValidator): void;
24
+ resolve(id: string): RegisteredValidator;
25
+ list(): readonly RegisteredValidator[];
26
+ }
27
+ export declare function createValidatorRegistry(): ValidatorRegistry;
@@ -0,0 +1,64 @@
1
+ // @bun
2
+ // packages/core/src/validator-registry.ts
3
+ import { existsSync } from "fs";
4
+ import { join } from "path";
5
+ function createValidatorRegistry() {
6
+ const map = new Map;
7
+ const order = [];
8
+ const registry = {
9
+ register(v) {
10
+ if (map.has(v.id))
11
+ throw new Error(`validator already registered: ${v.id}`);
12
+ map.set(v.id, v);
13
+ order.push(v);
14
+ },
15
+ resolve(id) {
16
+ const v = map.get(id);
17
+ if (!v)
18
+ throw new Error(`validator not registered: ${id}`);
19
+ return v;
20
+ },
21
+ list: () => order
22
+ };
23
+ registerBuiltInValidators(registry);
24
+ return registry;
25
+ }
26
+ function registerBuiltInValidators(registry) {
27
+ registry.register({
28
+ id: "std:typecheck",
29
+ category: "custom",
30
+ description: "Runs the package typecheck script when present.",
31
+ run: async (ctx) => runStdTypecheck(ctx)
32
+ });
33
+ }
34
+ async function runStdTypecheck(ctx) {
35
+ const packageJsonPath = join(ctx.workspaceRoot, "package.json");
36
+ if (!existsSync(packageJsonPath)) {
37
+ return {
38
+ id: "std:typecheck",
39
+ passed: false,
40
+ summary: `package.json not found at ${packageJsonPath}`
41
+ };
42
+ }
43
+ const proc = Bun.spawn(["bun", "run", "typecheck"], {
44
+ cwd: ctx.workspaceRoot,
45
+ env: process.env,
46
+ stdout: "pipe",
47
+ stderr: "pipe"
48
+ });
49
+ const [exitCode, stdout, stderr] = await Promise.all([
50
+ proc.exited,
51
+ new Response(proc.stdout).text(),
52
+ new Response(proc.stderr).text()
53
+ ]);
54
+ const output = `${stdout}${stderr}`.trim();
55
+ return {
56
+ id: "std:typecheck",
57
+ passed: exitCode === 0,
58
+ summary: exitCode === 0 ? "typecheck passed" : "typecheck failed",
59
+ ...output ? { details: output.slice(0, 4000) } : {}
60
+ };
61
+ }
62
+ export {
63
+ createValidatorRegistry
64
+ };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@h-rig/core",
3
- "version": "0.0.6-alpha.17",
3
+ "version": "0.0.6-alpha.170",
4
4
  "type": "module",
5
- "description": "Rig package",
5
+ "description": "Config and plugin composition library for Rig's OMP extension ecosystem; not a product host/runtime.",
6
6
  "license": "UNLICENSED",
7
7
  "files": [
8
8
  "dist",
@@ -10,19 +10,172 @@
10
10
  ],
11
11
  "exports": {
12
12
  ".": {
13
+ "types": "./dist/src/index.d.ts",
13
14
  "import": "./dist/src/index.js"
14
15
  },
15
16
  "./load-config": {
17
+ "types": "./dist/src/load-config.d.ts",
16
18
  "import": "./dist/src/load-config.js"
17
19
  },
18
- "./engineReadModelReducer": {
19
- "import": "./dist/src/engineReadModelReducer.js"
20
+ "./config": {
21
+ "types": "./dist/src/config.d.ts",
22
+ "import": "./dist/src/config.js"
20
23
  },
21
- "./rigSelectors": {
22
- "import": "./dist/src/rigSelectors.js"
24
+ "./project-plugins": {
25
+ "types": "./dist/src/project-plugins.d.ts",
26
+ "import": "./dist/src/project-plugins.js"
23
27
  },
24
- "./taskGraph": {
25
- "import": "./dist/src/taskGraph.js"
28
+ "./task-record-reader": {
29
+ "types": "./dist/src/task-record-reader.d.ts",
30
+ "import": "./dist/src/task-record-reader.js"
31
+ },
32
+ "./embedded-plugins": {
33
+ "types": "./dist/src/embedded-plugins.d.ts",
34
+ "import": "./dist/src/embedded-plugins.js"
35
+ },
36
+ "./capability": {
37
+ "types": "./dist/src/capability.d.ts",
38
+ "import": "./dist/src/capability.js"
39
+ },
40
+ "./capability-loaders": {
41
+ "types": "./dist/src/capability-loaders.d.ts",
42
+ "import": "./dist/src/capability-loaders.js"
43
+ },
44
+ "./layout": {
45
+ "types": "./dist/src/layout.d.ts",
46
+ "import": "./dist/src/layout.js"
47
+ },
48
+ "./config-env": {
49
+ "types": "./dist/src/config-env.d.ts",
50
+ "import": "./dist/src/config-env.js"
51
+ },
52
+ "./kernel-entrypoint": {
53
+ "types": "./dist/src/kernel-entrypoint.d.ts",
54
+ "import": "./dist/src/kernel-entrypoint.js"
55
+ },
56
+ "./kernel-boot": {
57
+ "types": "./dist/src/kernel-boot.d.ts",
58
+ "import": "./dist/src/kernel-boot.js"
59
+ },
60
+ "./default-kernel": {
61
+ "types": "./dist/src/default-kernel.d.ts",
62
+ "import": "./dist/src/default-kernel.js"
63
+ },
64
+ "./kernel-resolver": {
65
+ "types": "./dist/src/kernel-resolver.d.ts",
66
+ "import": "./dist/src/kernel-resolver.js"
67
+ },
68
+ "./kernel-plugin-abi": {
69
+ "types": "./dist/src/kernel-plugin-abi.d.ts",
70
+ "import": "./dist/src/kernel-plugin-abi.js"
71
+ },
72
+ "./setup-version": {
73
+ "types": "./dist/src/setup-version.d.ts",
74
+ "import": "./dist/src/setup-version.js"
75
+ },
76
+ "./baked-secrets": {
77
+ "types": "./dist/src/baked-secrets.d.ts",
78
+ "import": "./dist/src/baked-secrets.js"
79
+ },
80
+ "./runtime-context": {
81
+ "types": "./dist/src/runtime-context.d.ts",
82
+ "import": "./dist/src/runtime-context.js"
83
+ },
84
+ "./runtime-events": {
85
+ "types": "./dist/src/runtime-events.d.ts",
86
+ "import": "./dist/src/runtime-events.js"
87
+ },
88
+ "./runtime-runner-context": {
89
+ "types": "./dist/src/runtime-runner-context.d.ts",
90
+ "import": "./dist/src/runtime-runner-context.js"
91
+ },
92
+ "./build-time-config": {
93
+ "types": "./dist/src/build-time-config.d.ts",
94
+ "import": "./dist/src/build-time-config.js"
95
+ },
96
+ "./build-time-config.macro": {
97
+ "types": "./dist/src/build-time-config.macro.d.ts",
98
+ "import": "./dist/src/build-time-config.macro.js"
99
+ },
100
+ "./server-paths": {
101
+ "types": "./dist/src/server-paths.d.ts",
102
+ "import": "./dist/src/server-paths.js"
103
+ },
104
+ "./harness-paths": {
105
+ "types": "./dist/src/harness-paths.d.ts",
106
+ "import": "./dist/src/harness-paths.js"
107
+ },
108
+ "./profile-ops": {
109
+ "types": "./dist/src/profile-ops.d.ts",
110
+ "import": "./dist/src/profile-ops.js"
111
+ },
112
+ "./root-resolver": {
113
+ "types": "./dist/src/root-resolver.d.ts",
114
+ "import": "./dist/src/root-resolver.js"
115
+ },
116
+ "./json-files": {
117
+ "types": "./dist/src/json-files.d.ts",
118
+ "import": "./dist/src/json-files.js"
119
+ },
120
+ "./exec": {
121
+ "types": "./dist/src/exec.d.ts",
122
+ "import": "./dist/src/exec.js"
123
+ },
124
+ "./hook-materializer": {
125
+ "types": "./dist/src/hook-materializer.d.ts",
126
+ "import": "./dist/src/hook-materializer.js"
127
+ },
128
+ "./hook-runner": {
129
+ "types": "./dist/src/hook-runner.d.ts",
130
+ "import": "./dist/src/hook-runner.js"
131
+ },
132
+ "./hook-protocol": {
133
+ "types": "./dist/src/hook-protocol.d.ts",
134
+ "import": "./dist/src/hook-protocol.js"
135
+ },
136
+ "./plugin-host-registries": {
137
+ "types": "./dist/src/plugin-host-registries.d.ts",
138
+ "import": "./dist/src/plugin-host-registries.js"
139
+ },
140
+ "./plugin-host-context": {
141
+ "types": "./dist/src/plugin-host-context.d.ts",
142
+ "import": "./dist/src/plugin-host-context.js"
143
+ },
144
+ "./safe-identifiers": {
145
+ "types": "./dist/src/safe-identifiers.d.ts",
146
+ "import": "./dist/src/safe-identifiers.js"
147
+ },
148
+ "./checkout-root": {
149
+ "types": "./dist/src/checkout-root.d.ts",
150
+ "import": "./dist/src/checkout-root.js"
151
+ },
152
+ "./scope-rules": {
153
+ "types": "./dist/src/scope-rules.d.ts",
154
+ "import": "./dist/src/scope-rules.js"
155
+ },
156
+ "./remote-config": {
157
+ "types": "./dist/src/remote-config.d.ts",
158
+ "import": "./dist/src/remote-config.js"
159
+ },
160
+ "./placement": {
161
+ "types": "./dist/src/placement.d.ts",
162
+ "import": "./dist/src/placement.js"
163
+ },
164
+ "./runtime-paths": {
165
+ "types": "./dist/src/runtime-paths.d.ts",
166
+ "import": "./dist/src/runtime-paths.js"
167
+ },
168
+ "./runtime-provisioning-env": {
169
+ "types": "./dist/src/runtime-provisioning-env.d.ts",
170
+ "import": "./dist/src/runtime-provisioning-env.js"
171
+ },
172
+ "./runtime-overlay": {
173
+ "types": "./dist/src/runtime-overlay.d.ts",
174
+ "import": "./dist/src/runtime-overlay.js"
175
+ },
176
+ "./run-provisioning": {
177
+ "types": "./dist/src/run-provisioning.d.ts",
178
+ "import": "./dist/src/run-provisioning.js"
26
179
  }
27
180
  },
28
181
  "engines": {
@@ -30,8 +183,11 @@
30
183
  },
31
184
  "main": "./dist/src/index.js",
32
185
  "module": "./dist/src/index.js",
186
+ "types": "./dist/src/index.d.ts",
33
187
  "dependencies": {
34
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.17",
35
- "effect": "4.0.0-beta.78"
188
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.170",
189
+ "@rig/kernel-seed": "npm:@h-rig/kernel-seed@0.0.6-alpha.170",
190
+ "effect": "4.0.0-beta.90",
191
+ "smol-toml": "^1.6.0"
36
192
  }
37
193
  }