@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,4 @@
1
+ import type { AgentRoleRegistration, AgentRoleRegistry } from "@rig/contracts";
2
+ export declare function createAgentRoleRegistry(pluginRoles: readonly AgentRoleRegistration[], configOverrides?: Record<string, {
3
+ model?: string;
4
+ }>): AgentRoleRegistry;
@@ -0,0 +1,27 @@
1
+ // @bun
2
+ // packages/core/src/agent-role-registry.ts
3
+ function createAgentRoleRegistry(pluginRoles, configOverrides) {
4
+ const map = new Map;
5
+ for (const r of pluginRoles) {
6
+ if (map.has(r.id))
7
+ throw new Error(`agent role already registered: ${r.id}`);
8
+ const override = configOverrides?.[r.id];
9
+ const model = override?.model ?? r.defaultModel;
10
+ if (!model) {
11
+ throw new Error(`agent role "${r.id}" has no model \u2014 provide defaultModel in plugin or model in config.runtime.agentRoles.${r.id}`);
12
+ }
13
+ map.set(r.id, { ...r, model });
14
+ }
15
+ return {
16
+ resolve(id) {
17
+ const r = map.get(id);
18
+ if (!r)
19
+ throw new Error(`agent role not registered: ${id}`);
20
+ return r;
21
+ },
22
+ list: () => Array.from(map.values())
23
+ };
24
+ }
25
+ export {
26
+ createAgentRoleRegistry
27
+ };
@@ -0,0 +1,15 @@
1
+ export type AuthorityPaths = {
2
+ projectRoot: string;
3
+ harnessRoot: string;
4
+ runsDir: string;
5
+ remoteDir: string;
6
+ stateDir: string;
7
+ remoteEndpointsPath: string;
8
+ remoteSecretsPath: string;
9
+ };
10
+ export declare function normalizeOptionalString(value: string | undefined | null): string | null;
11
+ export declare function normalizeOptionalBoolean(value: string | undefined | null, fallback: boolean): boolean;
12
+ export declare function resolveAuthorityPaths(projectRoot: string): AuthorityPaths;
13
+ export declare function resolveAuthorityStateRoot(projectRoot: string): string;
14
+ export declare function resolveAuthorityStateDir(projectRoot: string): string;
15
+ export declare function resolveAuthorityProjectStateDir(projectRoot: string): string;
@@ -0,0 +1,80 @@
1
+ // @bun
2
+ // packages/core/src/authority-paths.ts
3
+ import { existsSync } from "fs";
4
+ import { dirname, resolve } from "path";
5
+ function normalizeOptionalString(value) {
6
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
7
+ }
8
+ function normalizeOptionalBoolean(value, fallback) {
9
+ if (typeof value !== "string") {
10
+ return fallback;
11
+ }
12
+ const normalized = value.trim().toLowerCase();
13
+ if (["1", "true", "yes", "on"].includes(normalized)) {
14
+ return true;
15
+ }
16
+ if (["0", "false", "no", "off"].includes(normalized)) {
17
+ return false;
18
+ }
19
+ return fallback;
20
+ }
21
+ function resolveAuthorityPaths(projectRoot) {
22
+ const normalizedRoot = resolve(projectRoot);
23
+ const stateRoot = resolveAuthorityStateRoot(normalizedRoot);
24
+ const stateDir = resolveAuthorityStateDir(normalizedRoot);
25
+ return {
26
+ projectRoot: normalizedRoot,
27
+ harnessRoot: resolve(normalizedRoot, "rig"),
28
+ runsDir: resolve(stateRoot, "runs"),
29
+ remoteDir: resolve(stateRoot, "remote"),
30
+ stateDir,
31
+ remoteEndpointsPath: resolve(stateRoot, "remote", "endpoints.toml"),
32
+ remoteSecretsPath: resolve(stateDir, "remote-secrets.toml")
33
+ };
34
+ }
35
+ function resolveAuthorityStateRoot(projectRoot) {
36
+ const normalizedRoot = resolve(projectRoot);
37
+ const taskWorkspace = normalizeOptionalString(process.env.RIG_TASK_WORKSPACE);
38
+ if (taskWorkspace) {
39
+ return resolve(taskWorkspace, ".rig");
40
+ }
41
+ const stateDir = normalizeOptionalString(process.env.RIG_STATE_DIR);
42
+ if (stateDir) {
43
+ return dirname(resolve(stateDir));
44
+ }
45
+ const logsDir = normalizeOptionalString(process.env.RIG_LOGS_DIR);
46
+ if (logsDir) {
47
+ return dirname(resolve(logsDir));
48
+ }
49
+ const sessionFile = normalizeOptionalString(process.env.RIG_SESSION_FILE);
50
+ if (sessionFile) {
51
+ return dirname(dirname(resolve(sessionFile)));
52
+ }
53
+ const projectStateRoot = resolve(normalizedRoot, ".rig");
54
+ if (existsSync(projectStateRoot)) {
55
+ return projectStateRoot;
56
+ }
57
+ return resolve(normalizedRoot, ".rig");
58
+ }
59
+ function resolveAuthorityStateDir(projectRoot) {
60
+ const explicit = normalizeOptionalString(process.env.RIG_STATE_DIR);
61
+ if (explicit) {
62
+ return resolve(explicit);
63
+ }
64
+ return resolve(resolveAuthorityStateRoot(projectRoot), "state");
65
+ }
66
+ function resolveAuthorityProjectStateDir(projectRoot) {
67
+ const explicit = normalizeOptionalString(process.env.RIG_STATE_DIR);
68
+ if (explicit) {
69
+ return resolve(explicit);
70
+ }
71
+ return resolve(resolve(projectRoot), ".rig", "state");
72
+ }
73
+ export {
74
+ resolveAuthorityStateRoot,
75
+ resolveAuthorityStateDir,
76
+ resolveAuthorityProjectStateDir,
77
+ resolveAuthorityPaths,
78
+ normalizeOptionalString,
79
+ normalizeOptionalBoolean
80
+ };
@@ -0,0 +1,6 @@
1
+ export type RuntimeSecretKey = "ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY" | "AI_REVIEW_MODE" | "AI_REVIEW_PROVIDER" | "GREPTILE_API_BASE" | "GREPTILE_REMOTE" | "GREPTILE_REPOSITORY" | "GREPTILE_CONTEXT_BRANCH" | "GREPTILE_DEFAULT_BRANCH" | "GREPTILE_API_KEY" | "GREPTILE_GITHUB_TOKEN" | "GREPTILE_POLL_ATTEMPTS" | "GREPTILE_POLL_INTERVAL_MS" | "GH_TOKEN" | "GITHUB_TOKEN" | "GITHUB_SSH_KEY" | "AWS_ACCESS_KEY_ID" | "AWS_SECRET_ACCESS_KEY" | "AWS_REGION" | "LINEAR_API_KEY" | "LINEAR_WEBHOOK_SECRET";
2
+ export type RuntimeSecrets = Partial<Record<RuntimeSecretKey, string>>;
3
+ export declare const BAKED_RUNTIME_SECRETS: RuntimeSecrets;
4
+ export declare function resolveRuntimeSecrets(env: Record<string, string | undefined>, baked?: RuntimeSecrets): RuntimeSecrets;
5
+ export declare function loadDotEnvSecrets(projectRoot: string, env?: Record<string, string | undefined>): RuntimeSecrets;
6
+ export declare function secretDefinesFromEnv(env?: Record<string, string | undefined>, projectRoot?: string): Record<string, string>;
@@ -0,0 +1,121 @@
1
+ // @bun
2
+ // packages/core/src/baked-secrets.ts
3
+ import { existsSync, readFileSync } from "fs";
4
+ import { resolve } from "path";
5
+ var BAKED_RUNTIME_SECRETS = {
6
+ ANTHROPIC_API_KEY: typeof RIG_BAKED_ANTHROPIC_API_KEY !== "undefined" ? RIG_BAKED_ANTHROPIC_API_KEY : "",
7
+ OPENAI_API_KEY: typeof RIG_BAKED_OPENAI_API_KEY !== "undefined" ? RIG_BAKED_OPENAI_API_KEY : "",
8
+ OPENROUTER_API_KEY: typeof RIG_BAKED_OPENROUTER_API_KEY !== "undefined" ? RIG_BAKED_OPENROUTER_API_KEY : "",
9
+ AI_REVIEW_MODE: typeof RIG_BAKED_AI_REVIEW_MODE !== "undefined" ? RIG_BAKED_AI_REVIEW_MODE : "",
10
+ AI_REVIEW_PROVIDER: typeof RIG_BAKED_AI_REVIEW_PROVIDER !== "undefined" ? RIG_BAKED_AI_REVIEW_PROVIDER : "",
11
+ GREPTILE_API_BASE: typeof RIG_BAKED_GREPTILE_API_BASE !== "undefined" ? RIG_BAKED_GREPTILE_API_BASE : "",
12
+ GREPTILE_REMOTE: typeof RIG_BAKED_GREPTILE_REMOTE !== "undefined" ? RIG_BAKED_GREPTILE_REMOTE : "",
13
+ GREPTILE_REPOSITORY: typeof RIG_BAKED_GREPTILE_REPOSITORY !== "undefined" ? RIG_BAKED_GREPTILE_REPOSITORY : "",
14
+ GREPTILE_CONTEXT_BRANCH: typeof RIG_BAKED_GREPTILE_CONTEXT_BRANCH !== "undefined" ? RIG_BAKED_GREPTILE_CONTEXT_BRANCH : "",
15
+ GREPTILE_DEFAULT_BRANCH: typeof RIG_BAKED_GREPTILE_DEFAULT_BRANCH !== "undefined" ? RIG_BAKED_GREPTILE_DEFAULT_BRANCH : "",
16
+ GREPTILE_API_KEY: typeof RIG_BAKED_GREPTILE_API_KEY !== "undefined" ? RIG_BAKED_GREPTILE_API_KEY : "",
17
+ GREPTILE_GITHUB_TOKEN: typeof RIG_BAKED_GREPTILE_GITHUB_TOKEN !== "undefined" ? RIG_BAKED_GREPTILE_GITHUB_TOKEN : "",
18
+ GREPTILE_POLL_ATTEMPTS: typeof RIG_BAKED_GREPTILE_POLL_ATTEMPTS !== "undefined" ? RIG_BAKED_GREPTILE_POLL_ATTEMPTS : "",
19
+ GREPTILE_POLL_INTERVAL_MS: typeof RIG_BAKED_GREPTILE_POLL_INTERVAL_MS !== "undefined" ? RIG_BAKED_GREPTILE_POLL_INTERVAL_MS : "",
20
+ GH_TOKEN: typeof RIG_BAKED_GITHUB_TOKEN !== "undefined" ? RIG_BAKED_GITHUB_TOKEN : "",
21
+ GITHUB_TOKEN: typeof RIG_BAKED_GITHUB_TOKEN !== "undefined" ? RIG_BAKED_GITHUB_TOKEN : "",
22
+ GITHUB_SSH_KEY: typeof RIG_BAKED_GITHUB_SSH_KEY !== "undefined" ? RIG_BAKED_GITHUB_SSH_KEY : "",
23
+ AWS_ACCESS_KEY_ID: typeof RIG_BAKED_AWS_ACCESS_KEY_ID !== "undefined" ? RIG_BAKED_AWS_ACCESS_KEY_ID : "",
24
+ AWS_SECRET_ACCESS_KEY: typeof RIG_BAKED_AWS_SECRET_ACCESS_KEY !== "undefined" ? RIG_BAKED_AWS_SECRET_ACCESS_KEY : "",
25
+ AWS_REGION: typeof RIG_BAKED_AWS_REGION !== "undefined" ? RIG_BAKED_AWS_REGION : "",
26
+ LINEAR_API_KEY: typeof RIG_BAKED_LINEAR_API_KEY !== "undefined" ? RIG_BAKED_LINEAR_API_KEY : "",
27
+ LINEAR_WEBHOOK_SECRET: typeof RIG_BAKED_LINEAR_WEBHOOK_SECRET !== "undefined" ? RIG_BAKED_LINEAR_WEBHOOK_SECRET : ""
28
+ };
29
+ function resolveRuntimeSecrets(env, baked = BAKED_RUNTIME_SECRETS) {
30
+ const resolved = {};
31
+ const keys = new Set([
32
+ ...Object.keys(BAKED_RUNTIME_SECRETS),
33
+ ...Object.keys(baked)
34
+ ]);
35
+ for (const key of keys) {
36
+ const envValue = env[key]?.trim();
37
+ const bakedValue = baked[key]?.trim();
38
+ if (envValue) {
39
+ resolved[key] = envValue;
40
+ } else if (bakedValue) {
41
+ resolved[key] = bakedValue;
42
+ }
43
+ }
44
+ return resolved;
45
+ }
46
+ function loadDotEnvSecrets(projectRoot, env = process.env) {
47
+ const dotenvPath = resolve(projectRoot, ".env");
48
+ if (!existsSync(dotenvPath)) {
49
+ return {};
50
+ }
51
+ const parsed = {};
52
+ const lines = readFileSync(dotenvPath, "utf-8").split(/\r?\n/);
53
+ for (const rawLine of lines) {
54
+ const line = rawLine.trim();
55
+ if (!line || line.startsWith("#")) {
56
+ continue;
57
+ }
58
+ const exportMatch = line.match(/^(?:export\s+)?([A-Z0-9_]+)\s*=\s*(.*)$/);
59
+ if (!exportMatch) {
60
+ continue;
61
+ }
62
+ const key = exportMatch[1];
63
+ if (!(key in BAKED_RUNTIME_SECRETS)) {
64
+ continue;
65
+ }
66
+ const value = expandShellValue(exportMatch[2] ?? "", { ...env, ...parsed });
67
+ if (value) {
68
+ parsed[key] = value;
69
+ }
70
+ }
71
+ return parsed;
72
+ }
73
+ function secretDefinesFromEnv(env = process.env, projectRoot) {
74
+ const dotenvSecrets = projectRoot ? loadDotEnvSecrets(projectRoot, env) : {};
75
+ const resolved = resolveRuntimeSecrets(env, {
76
+ ...BAKED_RUNTIME_SECRETS,
77
+ ...dotenvSecrets
78
+ });
79
+ return {
80
+ RIG_BAKED_ANTHROPIC_API_KEY: resolved.ANTHROPIC_API_KEY || "",
81
+ RIG_BAKED_OPENAI_API_KEY: resolved.OPENAI_API_KEY || "",
82
+ RIG_BAKED_OPENROUTER_API_KEY: resolved.OPENROUTER_API_KEY || "",
83
+ RIG_BAKED_AI_REVIEW_MODE: resolved.AI_REVIEW_MODE || "",
84
+ RIG_BAKED_AI_REVIEW_PROVIDER: resolved.AI_REVIEW_PROVIDER || "",
85
+ RIG_BAKED_GREPTILE_API_BASE: resolved.GREPTILE_API_BASE || "",
86
+ RIG_BAKED_GREPTILE_REMOTE: resolved.GREPTILE_REMOTE || "",
87
+ RIG_BAKED_GREPTILE_REPOSITORY: resolved.GREPTILE_REPOSITORY || "",
88
+ RIG_BAKED_GREPTILE_CONTEXT_BRANCH: resolved.GREPTILE_CONTEXT_BRANCH || "",
89
+ RIG_BAKED_GREPTILE_DEFAULT_BRANCH: resolved.GREPTILE_DEFAULT_BRANCH || "",
90
+ RIG_BAKED_GREPTILE_API_KEY: resolved.GREPTILE_API_KEY || "",
91
+ RIG_BAKED_GREPTILE_GITHUB_TOKEN: resolved.GREPTILE_GITHUB_TOKEN || "",
92
+ RIG_BAKED_GREPTILE_POLL_ATTEMPTS: resolved.GREPTILE_POLL_ATTEMPTS || "",
93
+ RIG_BAKED_GREPTILE_POLL_INTERVAL_MS: resolved.GREPTILE_POLL_INTERVAL_MS || "",
94
+ RIG_BAKED_GITHUB_TOKEN: resolved.GITHUB_TOKEN || resolved.GH_TOKEN || "",
95
+ RIG_BAKED_GITHUB_SSH_KEY: resolved.GITHUB_SSH_KEY || "",
96
+ RIG_BAKED_AWS_ACCESS_KEY_ID: resolved.AWS_ACCESS_KEY_ID || "",
97
+ RIG_BAKED_AWS_SECRET_ACCESS_KEY: resolved.AWS_SECRET_ACCESS_KEY || "",
98
+ RIG_BAKED_AWS_REGION: resolved.AWS_REGION || "",
99
+ RIG_BAKED_LINEAR_API_KEY: resolved.LINEAR_API_KEY || "",
100
+ RIG_BAKED_LINEAR_WEBHOOK_SECRET: resolved.LINEAR_WEBHOOK_SECRET || ""
101
+ };
102
+ }
103
+ function expandShellValue(rawValue, env) {
104
+ let value = rawValue.trim();
105
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
106
+ value = value.slice(1, -1);
107
+ }
108
+ return value.replace(/\$\{([A-Z0-9_]+)(:-([^}]*))?\}/g, (_match, name, _defaultGroup, fallback) => {
109
+ const envValue = env[name]?.trim();
110
+ if (envValue) {
111
+ return envValue;
112
+ }
113
+ return fallback ?? "";
114
+ });
115
+ }
116
+ export {
117
+ secretDefinesFromEnv,
118
+ resolveRuntimeSecrets,
119
+ loadDotEnvSecrets,
120
+ BAKED_RUNTIME_SECRETS
121
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Runtime fallback for build-time config.
3
+ *
4
+ * Compiled binaries use `build-time-config.macro.ts` with Bun's macro import
5
+ * (`with { type: "macro" }`) to inline config constants at build time.
6
+ *
7
+ * This module provides the same interface for non-compiled execution paths
8
+ * (e.g. `bun run`, tests, CLI dev mode) where macro expansion does not run.
9
+ * It reads from the `__RIG_BUILD_CONFIG__` global (if the compiled binary sets
10
+ * it) and falls back to the `RIG_BUILD_CONFIG_JSON` environment variable.
11
+ */
12
+ export declare function readBuildConfig(): Record<string, string>;
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ // packages/core/src/build-time-config.ts
3
+ function normalizeBuildConfig(value) {
4
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
5
+ return {};
6
+ }
7
+ return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string"));
8
+ }
9
+ function readBuildConfig() {
10
+ if (typeof __RIG_BUILD_CONFIG__ !== "undefined") {
11
+ return normalizeBuildConfig(__RIG_BUILD_CONFIG__);
12
+ }
13
+ const raw = process.env.RIG_BUILD_CONFIG_JSON?.trim();
14
+ if (!raw) {
15
+ return {};
16
+ }
17
+ try {
18
+ return normalizeBuildConfig(JSON.parse(raw));
19
+ } catch {
20
+ return {};
21
+ }
22
+ }
23
+ export {
24
+ readBuildConfig
25
+ };
@@ -0,0 +1 @@
1
+ export declare function readBuildConfig(): Record<string, string>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * capability-loaders.ts — generic project-root capability resolution + a typed
3
+ * installed-capability holder.
4
+ *
5
+ * These are the substrate-neutral helpers that the dissolved
6
+ * `@rig/runtime/control-plane/*-port` modules used to provide. Each per-capability
7
+ * port (doctor / memory / isolation / browser / provider-instruction /
8
+ * managed-repo / lifecycle) collapsed into three things that already exist:
9
+ *
10
+ * 1. the capability id + interface in `@rig/contracts` (pure vocab),
11
+ * 2. the `defineCapability(id)` seam in `@rig/core/capability`, and
12
+ * 3. these two GENERIC helpers — `loadCapabilityForRoot` /
13
+ * `requireCapabilityForRoot` plus an installed-singleton holder.
14
+ *
15
+ * Consumers resolve a capability off a project's plugin host (or read a
16
+ * boot-installed singleton) WITHOUT importing any provider plugin, so no
17
+ * floor->plugin / cross-plugin import cycle is introduced. The single
18
+ * `unknown -> T` cast for capability resolution still lives once inside
19
+ * `defineCapability.resolve`; the holder cast below is the lone exception, kept
20
+ * local to this typed accessor.
21
+ */
22
+ import type { Capability } from "./capability";
23
+ import type { PluginHost } from "./plugin-host";
24
+ /**
25
+ * Build a plugin host from a project's rig.config. Returns null when no config
26
+ * is loadable (legacy projects) so callers can decide their own fallback.
27
+ */
28
+ export declare function buildProjectPluginHost(projectRoot: string): Promise<PluginHost | null>;
29
+ /**
30
+ * Resolve a capability off a project root. Returns null when no config loads or
31
+ * no plugin provides the capability, so callers degrade gracefully.
32
+ */
33
+ export declare function loadCapabilityForRoot<T>(projectRoot: string, capability: Capability<T>): Promise<T | null>;
34
+ /**
35
+ * Resolve a capability off a project root, or throw a precise, actionable error
36
+ * (`message`) when no provider is registered.
37
+ */
38
+ export declare function requireCapabilityForRoot<T>(projectRoot: string, capability: Capability<T>, message: string): Promise<T>;
39
+ /** Install a resolved capability impl for synchronous cross-package reads. */
40
+ export declare function installCapability<T>(capability: Capability<T>, impl: T): void;
41
+ /** Clear an installed capability impl (test / reset hook). */
42
+ export declare function clearInstalledCapability<T>(capability: Capability<T>): void;
43
+ /** Read a boot-installed capability impl, or null when none is installed. */
44
+ export declare function getInstalledCapability<T>(capability: Capability<T>): T | null;
45
+ /**
46
+ * Read a boot-installed capability impl, or throw a precise `message` when none
47
+ * is installed. For synchronous substrate consumers that resolve a capability
48
+ * the boot wiring installs once (e.g. task-data) and cannot re-resolve a plugin
49
+ * host on every call.
50
+ */
51
+ export declare function requireInstalledCapability<T>(capability: Capability<T>, message: string): T;