@h-rig/core 0.0.6-alpha.18 → 0.0.6-alpha.180
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/agent-role-registry.d.ts +4 -0
- package/dist/src/agent-role-registry.js +27 -0
- package/dist/src/authority-paths.d.ts +15 -0
- package/dist/src/authority-paths.js +80 -0
- package/dist/src/baked-secrets.d.ts +3 -0
- package/dist/src/baked-secrets.js +63 -0
- package/dist/src/build-time-config.d.ts +12 -0
- package/dist/src/build-time-config.js +25 -0
- package/dist/src/build-time-config.macro.d.ts +1 -0
- package/dist/src/capability-loaders.d.ts +51 -0
- package/dist/src/capability-loaders.js +870 -0
- package/dist/src/capability.d.ts +79 -0
- package/dist/src/capability.js +63 -0
- package/dist/src/checkout-root.d.ts +1 -0
- package/dist/src/checkout-root.js +30 -0
- package/dist/src/config-env.d.ts +4 -0
- package/dist/src/config-env.js +23 -0
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.js +44 -0
- package/dist/src/declarative-config.d.ts +14 -0
- package/dist/src/declarative-config.js +85 -0
- package/dist/src/default-kernel.d.ts +1 -0
- package/dist/src/default-kernel.js +12 -0
- package/dist/src/define-config.d.ts +20 -0
- package/dist/src/define-config.js +28 -15
- package/dist/src/define-plugin.d.ts +13 -0
- package/dist/src/define-plugin.js +4 -43
- package/dist/src/embedded-plugins.d.ts +59 -0
- package/dist/src/embedded-plugins.js +22 -0
- package/dist/src/exec.d.ts +13 -0
- package/dist/src/exec.js +101 -0
- package/dist/src/harness-paths.d.ts +9 -0
- package/dist/src/harness-paths.js +126 -0
- package/dist/src/hook-materializer.d.ts +21 -0
- package/dist/src/hook-materializer.js +152 -0
- package/dist/src/hook-protocol.d.ts +2 -0
- package/dist/src/hook-protocol.js +432 -0
- package/dist/src/hook-runner.d.ts +48 -0
- package/dist/src/hook-runner.js +868 -0
- package/dist/src/hook-runtime.d.ts +52 -0
- package/dist/src/hook-runtime.js +432 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +210 -2499
- package/dist/src/json-files.d.ts +9 -0
- package/dist/src/json-files.js +124 -0
- package/dist/src/kernel-boot.d.ts +2 -0
- package/dist/src/kernel-boot.js +10 -0
- package/dist/src/kernel-entrypoint.d.ts +22 -0
- package/dist/src/kernel-entrypoint.js +660 -0
- package/dist/src/kernel-plugin-abi.d.ts +1 -0
- package/dist/src/kernel-plugin-abi.js +1 -0
- package/dist/src/kernel-resolver.d.ts +2 -0
- package/dist/src/kernel-resolver.js +6 -0
- package/dist/src/layout.d.ts +10 -0
- package/dist/src/layout.js +138 -0
- package/dist/src/load-config.d.ts +2 -0
- package/dist/src/load-config.js +535 -30
- package/dist/src/placement.d.ts +58 -0
- package/dist/src/placement.js +53 -0
- package/dist/src/plugin-host-context.d.ts +65 -0
- package/dist/src/plugin-host-context.js +1171 -0
- package/dist/src/plugin-host-registries.d.ts +31 -0
- package/dist/src/plugin-host-registries.js +79 -0
- package/dist/src/plugin-host.d.ts +77 -0
- package/dist/src/plugin-host.js +127 -63
- package/dist/src/plugin-runtime.d.ts +173 -0
- package/dist/src/project-plugins.d.ts +63 -0
- package/dist/src/project-plugins.js +905 -0
- package/dist/src/remote-config.d.ts +125 -0
- package/dist/src/remote-config.js +85 -0
- package/dist/src/root-resolver.d.ts +5 -0
- package/dist/src/root-resolver.js +68 -0
- package/dist/src/run-provisioning.d.ts +37 -0
- package/dist/src/run-provisioning.js +35 -0
- package/dist/src/runtime-context.d.ts +20 -0
- package/dist/src/runtime-context.js +257 -0
- package/dist/src/runtime-events.d.ts +44 -0
- package/dist/src/runtime-events.js +208 -0
- package/dist/src/runtime-overlay.d.ts +11 -0
- package/dist/src/runtime-overlay.js +69 -0
- package/dist/src/runtime-paths.d.ts +21 -0
- package/dist/src/runtime-paths.js +181 -0
- package/dist/src/runtime-provisioning-env.d.ts +5 -0
- package/dist/src/runtime-provisioning-env.js +217 -0
- package/dist/src/runtime-runner-context.d.ts +12 -0
- package/dist/src/runtime-runner-context.js +1 -0
- package/dist/src/safe-identifiers.d.ts +44 -0
- package/dist/src/safe-identifiers.js +96 -0
- package/dist/src/scope-rules.d.ts +4 -0
- package/dist/src/scope-rules.js +21 -0
- package/dist/src/server-paths.d.ts +22 -0
- package/dist/src/server-paths.js +219 -0
- package/dist/src/setup-version.d.ts +3 -0
- package/dist/src/setup-version.js +14 -0
- package/dist/src/task-record-reader.d.ts +3 -0
- package/dist/src/task-record-reader.js +9 -0
- package/dist/src/validator-registry.d.ts +27 -0
- package/dist/src/validator-registry.js +64 -0
- package/package.json +162 -10
- package/dist/src/engineReadModelReducer.js +0 -1780
- package/dist/src/rig-init-builder.js +0 -57
- package/dist/src/rigSelectors.js +0 -293
- package/dist/src/taskGraph.js +0 -64
- package/dist/src/taskGraphCodes.js +0 -26
- package/dist/src/taskGraphLayout.js +0 -374
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function appendJsonlRecord(path: string, value: unknown): void;
|
|
2
|
+
export declare function writeJsonFile(path: string, value: unknown): void;
|
|
3
|
+
export declare function readJsonFile<T>(path: string, fallback: T): T;
|
|
4
|
+
export declare function readAuthorityStateJson<T>(projectRoot: string, relativePath: string, fallback: T): T;
|
|
5
|
+
export declare function writeAuthorityStateJson(projectRoot: string, relativePath: string, value: unknown): string;
|
|
6
|
+
export declare function readAuthorityProjectStateJson<T>(projectRoot: string, relativePath: string, fallback: T): T;
|
|
7
|
+
export declare function writeAuthorityProjectStateJson(projectRoot: string, relativePath: string, value: unknown): string;
|
|
8
|
+
export declare function readJsonlFile(path: string): unknown[];
|
|
9
|
+
export declare function stripAuthorityRunLiveCollabFields<T extends Record<string, unknown>>(record: T): T;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/json-files.ts
|
|
3
|
+
import { appendFileSync, existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
4
|
+
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
5
|
+
|
|
6
|
+
// packages/core/src/layout.ts
|
|
7
|
+
import {
|
|
8
|
+
RIG_DEFINITION_DIRNAME,
|
|
9
|
+
RIG_STATE_DIRNAME
|
|
10
|
+
} from "@rig/contracts";
|
|
11
|
+
|
|
12
|
+
// packages/core/src/authority-paths.ts
|
|
13
|
+
import { existsSync } from "fs";
|
|
14
|
+
import { dirname, resolve } from "path";
|
|
15
|
+
function normalizeOptionalString(value) {
|
|
16
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
17
|
+
}
|
|
18
|
+
function resolveAuthorityStateRoot(projectRoot) {
|
|
19
|
+
const normalizedRoot = resolve(projectRoot);
|
|
20
|
+
const taskWorkspace = normalizeOptionalString(process.env.RIG_TASK_WORKSPACE);
|
|
21
|
+
if (taskWorkspace) {
|
|
22
|
+
return resolve(taskWorkspace, ".rig");
|
|
23
|
+
}
|
|
24
|
+
const stateDir = normalizeOptionalString(process.env.RIG_STATE_DIR);
|
|
25
|
+
if (stateDir) {
|
|
26
|
+
return dirname(resolve(stateDir));
|
|
27
|
+
}
|
|
28
|
+
const logsDir = normalizeOptionalString(process.env.RIG_LOGS_DIR);
|
|
29
|
+
if (logsDir) {
|
|
30
|
+
return dirname(resolve(logsDir));
|
|
31
|
+
}
|
|
32
|
+
const sessionFile = normalizeOptionalString(process.env.RIG_SESSION_FILE);
|
|
33
|
+
if (sessionFile) {
|
|
34
|
+
return dirname(dirname(resolve(sessionFile)));
|
|
35
|
+
}
|
|
36
|
+
const projectStateRoot = resolve(normalizedRoot, ".rig");
|
|
37
|
+
if (existsSync(projectStateRoot)) {
|
|
38
|
+
return projectStateRoot;
|
|
39
|
+
}
|
|
40
|
+
return resolve(normalizedRoot, ".rig");
|
|
41
|
+
}
|
|
42
|
+
function resolveAuthorityStateDir(projectRoot) {
|
|
43
|
+
const explicit = normalizeOptionalString(process.env.RIG_STATE_DIR);
|
|
44
|
+
if (explicit) {
|
|
45
|
+
return resolve(explicit);
|
|
46
|
+
}
|
|
47
|
+
return resolve(resolveAuthorityStateRoot(projectRoot), "state");
|
|
48
|
+
}
|
|
49
|
+
function resolveAuthorityProjectStateDir(projectRoot) {
|
|
50
|
+
const explicit = normalizeOptionalString(process.env.RIG_STATE_DIR);
|
|
51
|
+
if (explicit) {
|
|
52
|
+
return resolve(explicit);
|
|
53
|
+
}
|
|
54
|
+
return resolve(resolve(projectRoot), ".rig", "state");
|
|
55
|
+
}
|
|
56
|
+
// packages/core/src/json-files.ts
|
|
57
|
+
function appendJsonlRecord(path, value) {
|
|
58
|
+
mkdirSync(dirname2(path), { recursive: true });
|
|
59
|
+
appendFileSync(path, `${JSON.stringify(value)}
|
|
60
|
+
`, "utf8");
|
|
61
|
+
}
|
|
62
|
+
function writeJsonFile(path, value) {
|
|
63
|
+
mkdirSync(dirname2(path), { recursive: true });
|
|
64
|
+
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
65
|
+
`, "utf8");
|
|
66
|
+
}
|
|
67
|
+
function readJsonFile(path, fallback) {
|
|
68
|
+
if (!existsSync2(path))
|
|
69
|
+
return fallback;
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
72
|
+
} catch {
|
|
73
|
+
return fallback;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function readAuthorityStateJson(projectRoot, relativePath, fallback) {
|
|
77
|
+
return readJsonFile(resolve2(resolveAuthorityStateDir(projectRoot), relativePath), fallback);
|
|
78
|
+
}
|
|
79
|
+
function writeAuthorityStateJson(projectRoot, relativePath, value) {
|
|
80
|
+
const path = resolve2(resolveAuthorityStateDir(projectRoot), relativePath);
|
|
81
|
+
writeJsonFile(path, value);
|
|
82
|
+
return path;
|
|
83
|
+
}
|
|
84
|
+
function readAuthorityProjectStateJson(projectRoot, relativePath, fallback) {
|
|
85
|
+
return readJsonFile(resolve2(resolveAuthorityProjectStateDir(projectRoot), relativePath), fallback);
|
|
86
|
+
}
|
|
87
|
+
function writeAuthorityProjectStateJson(projectRoot, relativePath, value) {
|
|
88
|
+
const path = resolve2(resolveAuthorityProjectStateDir(projectRoot), relativePath);
|
|
89
|
+
writeJsonFile(path, value);
|
|
90
|
+
return path;
|
|
91
|
+
}
|
|
92
|
+
function readJsonlFile(path) {
|
|
93
|
+
if (!existsSync2(path))
|
|
94
|
+
return [];
|
|
95
|
+
return readFileSync(path, "utf8").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).flatMap((line) => {
|
|
96
|
+
try {
|
|
97
|
+
return [JSON.parse(line)];
|
|
98
|
+
} catch {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function stripAuthorityRunLiveCollabFields(record) {
|
|
104
|
+
const {
|
|
105
|
+
collabLink: _collabLink,
|
|
106
|
+
collabWebLink: _collabWebLink,
|
|
107
|
+
collabRoomId: _collabRoomId,
|
|
108
|
+
collabRelayUrl: _collabRelayUrl,
|
|
109
|
+
collabToken: _collabToken,
|
|
110
|
+
...rest
|
|
111
|
+
} = record;
|
|
112
|
+
return rest;
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
writeJsonFile,
|
|
116
|
+
writeAuthorityStateJson,
|
|
117
|
+
writeAuthorityProjectStateJson,
|
|
118
|
+
stripAuthorityRunLiveCollabFields,
|
|
119
|
+
readJsonlFile,
|
|
120
|
+
readJsonFile,
|
|
121
|
+
readAuthorityStateJson,
|
|
122
|
+
readAuthorityProjectStateJson,
|
|
123
|
+
appendJsonlRecord
|
|
124
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { JournalCapability, TransportCapability } from "@rig/contracts";
|
|
2
|
+
import { type DefaultKernelBootRecord } from "./kernel-boot";
|
|
3
|
+
import type { CapabilityProviderPlugin } from "./kernel-plugin-abi";
|
|
4
|
+
export type HydrationResult = {
|
|
5
|
+
readonly projectRoot: string;
|
|
6
|
+
readonly dotenvLoaded: boolean;
|
|
7
|
+
readonly configLoaded: boolean;
|
|
8
|
+
readonly errors: readonly string[];
|
|
9
|
+
};
|
|
10
|
+
export type HydrateProjectProcessEnvOptions = {
|
|
11
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
12
|
+
readonly dotenvPath?: string;
|
|
13
|
+
};
|
|
14
|
+
export type AdoptKernelOptions = HydrateProjectProcessEnvOptions & {
|
|
15
|
+
readonly entrypoint?: string;
|
|
16
|
+
readonly journal?: JournalCapability;
|
|
17
|
+
readonly transport?: TransportCapability;
|
|
18
|
+
readonly hydrateEnv?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function createPlacementKernelTransportPlugin(transport: TransportCapability): CapabilityProviderPlugin;
|
|
21
|
+
export declare function hydrateProjectProcessEnv(projectRoot: string, options?: HydrateProjectProcessEnvOptions): Promise<HydrationResult>;
|
|
22
|
+
export declare function adopt(root?: string, options?: AdoptKernelOptions): Promise<DefaultKernelBootRecord>;
|