@h-rig/core 0.0.6-alpha.176 → 0.0.6-alpha.178
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/baked-secrets.d.ts +3 -6
- package/dist/src/baked-secrets.js +9 -67
- package/dist/src/capability-loaders.js +132 -20
- package/dist/src/declarative-config.js +5 -2
- package/dist/src/harness-paths.d.ts +0 -9
- package/dist/src/harness-paths.js +1 -16
- package/dist/src/hook-materializer.d.ts +9 -60
- package/dist/src/hook-materializer.js +3 -132
- package/dist/src/hook-protocol.js +1 -31
- package/dist/src/hook-runner.d.ts +3 -3
- package/dist/src/hook-runner.js +132 -20
- package/dist/src/hook-runtime.js +1 -31
- package/dist/src/json-files.js +0 -1
- package/dist/src/kernel-entrypoint.js +132 -20
- package/dist/src/layout.d.ts +2 -2
- package/dist/src/layout.js +2 -8
- package/dist/src/load-config.js +132 -20
- package/dist/src/placement.d.ts +16 -8
- package/dist/src/placement.js +18 -961
- package/dist/src/plugin-host-context.d.ts +2 -3
- package/dist/src/plugin-host-context.js +170 -294
- package/dist/src/project-plugins.js +132 -20
- package/dist/src/remote-config.d.ts +38 -96
- package/dist/src/remote-config.js +35 -524
- package/dist/src/root-resolver.js +0 -1
- package/dist/src/run-provisioning.d.ts +17 -38
- package/dist/src/run-provisioning.js +19 -112
- package/dist/src/runtime-events.js +0 -4
- package/dist/src/runtime-overlay.js +0 -2
- package/dist/src/server-paths.d.ts +0 -4
- package/dist/src/server-paths.js +36 -125
- package/package.json +3 -7
- package/dist/src/profile-ops.d.ts +0 -9
- package/dist/src/profile-ops.js +0 -252
|
@@ -1,128 +1,35 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/core/src/run-provisioning.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var RUN_WORKSPACE_ISOLATION_MODE = "worktree";
|
|
6
|
-
var RUN_WORKSPACE_PROVIDER = "pi";
|
|
7
|
-
var REMOTE_RIG_RUN_COMMAND = "rig-run";
|
|
8
|
-
var REMOTE_RESOLVED_RIG_RUN_COMMAND = '"$__RIG_RUN_BIN"';
|
|
9
|
-
function buildRunWorkspaceProvisioningOptions(input) {
|
|
10
|
-
return {
|
|
11
|
-
projectRoot: input.projectRoot,
|
|
12
|
-
id: input.runId,
|
|
13
|
-
taskId: input.taskId,
|
|
14
|
-
mode: RUN_WORKSPACE_ISOLATION_MODE,
|
|
15
|
-
provider: RUN_WORKSPACE_PROVIDER
|
|
16
|
-
};
|
|
3
|
+
function runProvisioningOwnerRequired() {
|
|
4
|
+
throw new Error("This run provisioning compatibility API is deprecated. Resolve run provisioning through the owning transport/run-host boundary instead.");
|
|
17
5
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
const title = optionalString(input.title);
|
|
21
|
-
const model = optionalString(input.model);
|
|
22
|
-
const prompt = optionalString(input.prompt);
|
|
23
|
-
if (title)
|
|
24
|
-
args.push("--title", title);
|
|
25
|
-
if (model)
|
|
26
|
-
args.push("--model", model);
|
|
27
|
-
if (input.forceSteerOnce)
|
|
28
|
-
args.push("--force-steer-once");
|
|
29
|
-
if (prompt)
|
|
30
|
-
args.push("--prompt", prompt);
|
|
31
|
-
return args;
|
|
6
|
+
function buildRunWorkspaceProvisioningOptions(_input) {
|
|
7
|
+
return runProvisioningOwnerRequired();
|
|
32
8
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
const selectedCheckout = optionalString(input.selectedCheckout);
|
|
36
|
-
return {
|
|
37
|
-
mode: selectedCheckout ? "configured" : "managed",
|
|
38
|
-
repoName,
|
|
39
|
-
checkoutPath: selectedCheckout ?? `.rig/checkouts/${repoName}`,
|
|
40
|
-
checkoutPathKind: selectedCheckout ? "literal" : "home-relative",
|
|
41
|
-
originUrl: resolveProjectOriginUrl(input.projectSlug)
|
|
42
|
-
};
|
|
9
|
+
function buildRigRunLaunchArgs(_input, _runId, _projectRoot) {
|
|
10
|
+
return runProvisioningOwnerRequired();
|
|
43
11
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
operatorAuthPath: resolve(operatorStateDir, "github-auth.json"),
|
|
48
|
-
operatorStateDir,
|
|
49
|
-
remoteAuthPath: `${checkoutExpression}/.rig/state/github-auth.json`,
|
|
50
|
-
remoteStateDir: `${checkoutExpression}/.rig/state`
|
|
51
|
-
};
|
|
12
|
+
function isCompiledBunBinary(_importMetaUrl) {
|
|
13
|
+
return runProvisioningOwnerRequired();
|
|
52
14
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
15
|
+
function resolveCompiledSiblingPath(_execPath, _siblingBinaryName, _platform = process.platform) {
|
|
16
|
+
return runProvisioningOwnerRequired();
|
|
55
17
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
`export PATH="$HOME/.local/bin:$HOME/.bun/bin:$PATH"`,
|
|
59
|
-
`__RIG_RUN_BIN="$(command -v ${command} || true)"`,
|
|
60
|
-
`if [ -z "$__RIG_RUN_BIN" ]; then for __RIG_RUN_CANDIDATE in "$HOME"/.bun/install/global/node_modules/@h-rig/cli-*/rig-run; do if [ -x "$__RIG_RUN_CANDIDATE" ]; then __RIG_RUN_BIN="$__RIG_RUN_CANDIDATE"; break; fi; done; fi`,
|
|
61
|
-
`[ -x "$__RIG_RUN_BIN" ] || { echo "rig: remote rig-run not found; install @h-rig/cli on the remote host (curl -fsSL ${installUrl} | bash) and ensure rig-run is installed" >&2; exit 1; }`
|
|
62
|
-
];
|
|
18
|
+
function ensureSiblingBinaryCurrent(_sourceBin, _siblingBin) {
|
|
19
|
+
runProvisioningOwnerRequired();
|
|
63
20
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
21
|
+
function resolveLocalDispatchRigRunBin(_input) {
|
|
22
|
+
return runProvisioningOwnerRequired();
|
|
66
23
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
return resolve(dirname(execPath), `${REMOTE_RIG_RUN_COMMAND}${suffix}`);
|
|
70
|
-
}
|
|
71
|
-
function ensureRigRunSiblingCurrent(rigBin, rigRun) {
|
|
72
|
-
const tempRigRun = `${rigRun}.tmp-${process.pid}`;
|
|
73
|
-
try {
|
|
74
|
-
if (existsSync(rigRun) && statSync(rigRun).mtimeMs >= statSync(rigBin).mtimeMs)
|
|
75
|
-
return;
|
|
76
|
-
rmSync(tempRigRun, { force: true });
|
|
77
|
-
try {
|
|
78
|
-
linkSync(rigBin, tempRigRun);
|
|
79
|
-
} catch {
|
|
80
|
-
copyFileSync(rigBin, tempRigRun);
|
|
81
|
-
}
|
|
82
|
-
chmodSync(tempRigRun, 493);
|
|
83
|
-
renameSync(tempRigRun, rigRun);
|
|
84
|
-
} catch {
|
|
85
|
-
try {
|
|
86
|
-
rmSync(tempRigRun, { force: true });
|
|
87
|
-
} catch {}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function resolveLocalDispatchRigRunBin(input) {
|
|
91
|
-
if (!isCompiledBunBinary(input.importMetaUrl))
|
|
92
|
-
return input.sourceRigRunPath;
|
|
93
|
-
const rigBin = input.execPath ?? process.execPath;
|
|
94
|
-
const rigRun = resolveCompiledRigRunSiblingPath(rigBin, input.platform);
|
|
95
|
-
ensureRigRunSiblingCurrent(rigBin, rigRun);
|
|
96
|
-
return rigRun;
|
|
97
|
-
}
|
|
98
|
-
function resolveInProcessRigRunBin(input) {
|
|
99
|
-
return isCompiledBunBinary(input.importMetaUrl) ? input.execPath ?? process.execPath : input.sourceRigRunPath;
|
|
100
|
-
}
|
|
101
|
-
function optionalString(value) {
|
|
102
|
-
const trimmed = value?.trim();
|
|
103
|
-
return trimmed ? trimmed : undefined;
|
|
104
|
-
}
|
|
105
|
-
function sanitizeRepoName(value) {
|
|
106
|
-
return (optionalString(value) ?? "project").replace(/[^A-Za-z0-9._-]/g, "-");
|
|
107
|
-
}
|
|
108
|
-
function resolveProjectOriginUrl(projectSlug) {
|
|
109
|
-
const slug = optionalString(projectSlug);
|
|
110
|
-
return slug && /^[^/]+\/[^/]+$/.test(slug) ? `https://github.com/${slug}.git` : null;
|
|
24
|
+
function resolveInProcessRigRunBin(_input) {
|
|
25
|
+
return runProvisioningOwnerRequired();
|
|
111
26
|
}
|
|
112
27
|
export {
|
|
113
|
-
resolveRunGithubAuthMaterialization,
|
|
114
|
-
resolveRemoteCheckoutPlan,
|
|
115
28
|
resolveLocalDispatchRigRunBin,
|
|
116
29
|
resolveInProcessRigRunBin,
|
|
117
|
-
|
|
118
|
-
readGithubAuthStateBase64,
|
|
30
|
+
resolveCompiledSiblingPath,
|
|
119
31
|
isCompiledBunBinary,
|
|
120
|
-
|
|
32
|
+
ensureSiblingBinaryCurrent,
|
|
121
33
|
buildRunWorkspaceProvisioningOptions,
|
|
122
|
-
buildRigRunLaunchArgs
|
|
123
|
-
buildRemoteRigRunResolutionShell,
|
|
124
|
-
RUN_WORKSPACE_PROVIDER,
|
|
125
|
-
RUN_WORKSPACE_ISOLATION_MODE,
|
|
126
|
-
REMOTE_RIG_RUN_COMMAND,
|
|
127
|
-
REMOTE_RESOLVED_RIG_RUN_COMMAND
|
|
34
|
+
buildRigRunLaunchArgs
|
|
128
35
|
};
|
|
@@ -7,7 +7,6 @@ import { dirname as dirname2, resolve as resolve3 } from "path";
|
|
|
7
7
|
// packages/core/src/layout.ts
|
|
8
8
|
import { resolve as resolve2 } from "path";
|
|
9
9
|
import {
|
|
10
|
-
RIG_ARTIFACTS_DIRNAME,
|
|
11
10
|
RIG_DEFINITION_DIRNAME,
|
|
12
11
|
RIG_STATE_DIRNAME
|
|
13
12
|
} from "@rig/contracts";
|
|
@@ -53,7 +52,6 @@ function resolveRuntimeWorkspaceLayout(workspaceDir) {
|
|
|
53
52
|
rigRoot,
|
|
54
53
|
stateDir,
|
|
55
54
|
logsDir,
|
|
56
|
-
artifactsRoot: resolve2(root, RIG_ARTIFACTS_DIRNAME),
|
|
57
55
|
runtimeDir,
|
|
58
56
|
homeDir: resolve2(rigRoot, "home"),
|
|
59
57
|
tmpDir: resolve2(rigRoot, "tmp"),
|
|
@@ -85,9 +83,7 @@ function resolveRigLayout(projectRoot) {
|
|
|
85
83
|
definitionRoot,
|
|
86
84
|
runtimeWorkspaceRoot,
|
|
87
85
|
stateRoot: runtimeLayout.rigRoot,
|
|
88
|
-
artifactsRoot: runtimeLayout.artifactsRoot,
|
|
89
86
|
configPath: resolve2(definitionRoot, "config.sh"),
|
|
90
|
-
taskConfigPath: resolve2(runtimeWorkspaceRoot, ".rig", "task-config.json"),
|
|
91
87
|
policyDir,
|
|
92
88
|
policyFile: resolve2(policyDir, "policy.json"),
|
|
93
89
|
pluginsDir: resolve2(definitionRoot, "plugins"),
|
|
@@ -5,7 +5,6 @@ import { mkdirSync } from "fs";
|
|
|
5
5
|
// packages/core/src/layout.ts
|
|
6
6
|
import { resolve } from "path";
|
|
7
7
|
import {
|
|
8
|
-
RIG_ARTIFACTS_DIRNAME,
|
|
9
8
|
RIG_DEFINITION_DIRNAME,
|
|
10
9
|
RIG_STATE_DIRNAME
|
|
11
10
|
} from "@rig/contracts";
|
|
@@ -21,7 +20,6 @@ function resolveRuntimeWorkspaceLayout(workspaceDir) {
|
|
|
21
20
|
rigRoot,
|
|
22
21
|
stateDir,
|
|
23
22
|
logsDir,
|
|
24
|
-
artifactsRoot: resolve(root, RIG_ARTIFACTS_DIRNAME),
|
|
25
23
|
runtimeDir,
|
|
26
24
|
homeDir: resolve(rigRoot, "home"),
|
|
27
25
|
tmpDir: resolve(rigRoot, "tmp"),
|
|
@@ -5,7 +5,6 @@ export type RigStatePaths = {
|
|
|
5
5
|
readonly stateDir: string;
|
|
6
6
|
readonly logsDir: string;
|
|
7
7
|
readonly controlPlaneEventsFile: string;
|
|
8
|
-
readonly taskConfigPath: string;
|
|
9
8
|
readonly notificationsFile: string;
|
|
10
9
|
readonly keybindingsPath: string;
|
|
11
10
|
};
|
|
@@ -16,11 +15,8 @@ export declare function resolveRigProjectRoot(input?: {
|
|
|
16
15
|
readonly cwd?: string;
|
|
17
16
|
readonly fallbackRoot?: string;
|
|
18
17
|
}): string;
|
|
19
|
-
export declare function resolveAuthorityArtifactsRoot(projectRoot: string): string;
|
|
20
18
|
export declare function resolveAuthorityRuntimeDir(projectRoot: string): string;
|
|
21
19
|
export declare function listAuthorityRunRoots(projectRoot: string): string[];
|
|
22
|
-
export declare function listAuthorityArtifactRoots(projectRoot: string): string[];
|
|
23
20
|
export declare function listAuthorityRuntimeAgentsRoots(projectRoot: string): string[];
|
|
24
21
|
export declare function resolveAuthorityRunDir(projectRoot: string, runId: string): string;
|
|
25
|
-
export declare function resolveTaskArtifactDirs(projectRoot: string, taskId: string): string[];
|
|
26
22
|
export { isPathWithin };
|
package/dist/src/server-paths.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/core/src/server-paths.ts
|
|
3
3
|
import { existsSync as existsSync3 } from "fs";
|
|
4
|
-
import { dirname as dirname3, resolve as
|
|
4
|
+
import { dirname as dirname3, resolve as resolve3, relative } from "path";
|
|
5
5
|
|
|
6
6
|
// packages/core/src/layout.ts
|
|
7
7
|
import {
|
|
8
|
-
RIG_ARTIFACTS_DIRNAME,
|
|
9
8
|
RIG_DEFINITION_DIRNAME,
|
|
10
9
|
RIG_STATE_DIRNAME
|
|
11
10
|
} from "@rig/contracts";
|
|
@@ -41,33 +40,7 @@ function resolveCheckoutRoot(projectRoot) {
|
|
|
41
40
|
var resolveMonorepoRoot = resolveCheckoutRoot;
|
|
42
41
|
|
|
43
42
|
// 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
43
|
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
44
|
function isSafeRunId(value) {
|
|
72
45
|
const trimmed = value.trim();
|
|
73
46
|
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);
|
|
@@ -78,23 +51,10 @@ function assertSafeRunId(value) {
|
|
|
78
51
|
}
|
|
79
52
|
return value.trim();
|
|
80
53
|
}
|
|
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
54
|
|
|
95
55
|
// packages/core/src/authority-paths.ts
|
|
96
56
|
import { existsSync as existsSync2 } from "fs";
|
|
97
|
-
import { dirname as dirname2, resolve as
|
|
57
|
+
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
98
58
|
function normalizeOptionalString(value) {
|
|
99
59
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
100
60
|
}
|
|
@@ -112,61 +72,61 @@ function normalizeOptionalBoolean(value, fallback) {
|
|
|
112
72
|
return fallback;
|
|
113
73
|
}
|
|
114
74
|
function resolveAuthorityPaths(projectRoot) {
|
|
115
|
-
const normalizedRoot =
|
|
75
|
+
const normalizedRoot = resolve2(projectRoot);
|
|
116
76
|
const stateRoot = resolveAuthorityStateRoot(normalizedRoot);
|
|
117
77
|
const stateDir = resolveAuthorityStateDir(normalizedRoot);
|
|
118
78
|
return {
|
|
119
79
|
projectRoot: normalizedRoot,
|
|
120
|
-
harnessRoot:
|
|
121
|
-
runsDir:
|
|
122
|
-
remoteDir:
|
|
80
|
+
harnessRoot: resolve2(normalizedRoot, "rig"),
|
|
81
|
+
runsDir: resolve2(stateRoot, "runs"),
|
|
82
|
+
remoteDir: resolve2(stateRoot, "remote"),
|
|
123
83
|
stateDir,
|
|
124
|
-
remoteEndpointsPath:
|
|
125
|
-
remoteSecretsPath:
|
|
84
|
+
remoteEndpointsPath: resolve2(stateRoot, "remote", "endpoints.toml"),
|
|
85
|
+
remoteSecretsPath: resolve2(stateDir, "remote-secrets.toml")
|
|
126
86
|
};
|
|
127
87
|
}
|
|
128
88
|
function resolveAuthorityStateRoot(projectRoot) {
|
|
129
|
-
const normalizedRoot =
|
|
89
|
+
const normalizedRoot = resolve2(projectRoot);
|
|
130
90
|
const taskWorkspace = normalizeOptionalString(process.env.RIG_TASK_WORKSPACE);
|
|
131
91
|
if (taskWorkspace) {
|
|
132
|
-
return
|
|
92
|
+
return resolve2(taskWorkspace, ".rig");
|
|
133
93
|
}
|
|
134
94
|
const stateDir = normalizeOptionalString(process.env.RIG_STATE_DIR);
|
|
135
95
|
if (stateDir) {
|
|
136
|
-
return dirname2(
|
|
96
|
+
return dirname2(resolve2(stateDir));
|
|
137
97
|
}
|
|
138
98
|
const logsDir = normalizeOptionalString(process.env.RIG_LOGS_DIR);
|
|
139
99
|
if (logsDir) {
|
|
140
|
-
return dirname2(
|
|
100
|
+
return dirname2(resolve2(logsDir));
|
|
141
101
|
}
|
|
142
102
|
const sessionFile = normalizeOptionalString(process.env.RIG_SESSION_FILE);
|
|
143
103
|
if (sessionFile) {
|
|
144
|
-
return dirname2(dirname2(
|
|
104
|
+
return dirname2(dirname2(resolve2(sessionFile)));
|
|
145
105
|
}
|
|
146
|
-
const projectStateRoot =
|
|
106
|
+
const projectStateRoot = resolve2(normalizedRoot, ".rig");
|
|
147
107
|
if (existsSync2(projectStateRoot)) {
|
|
148
108
|
return projectStateRoot;
|
|
149
109
|
}
|
|
150
|
-
return
|
|
110
|
+
return resolve2(normalizedRoot, ".rig");
|
|
151
111
|
}
|
|
152
112
|
function resolveAuthorityStateDir(projectRoot) {
|
|
153
113
|
const explicit = normalizeOptionalString(process.env.RIG_STATE_DIR);
|
|
154
114
|
if (explicit) {
|
|
155
|
-
return
|
|
115
|
+
return resolve2(explicit);
|
|
156
116
|
}
|
|
157
|
-
return
|
|
117
|
+
return resolve2(resolveAuthorityStateRoot(projectRoot), "state");
|
|
158
118
|
}
|
|
159
119
|
function resolveAuthorityProjectStateDir(projectRoot) {
|
|
160
120
|
const explicit = normalizeOptionalString(process.env.RIG_STATE_DIR);
|
|
161
121
|
if (explicit) {
|
|
162
|
-
return
|
|
122
|
+
return resolve2(explicit);
|
|
163
123
|
}
|
|
164
|
-
return
|
|
124
|
+
return resolve2(resolve2(projectRoot), ".rig", "state");
|
|
165
125
|
}
|
|
166
126
|
|
|
167
127
|
// packages/core/src/server-paths.ts
|
|
168
128
|
function isPathWithin(root, candidate) {
|
|
169
|
-
const relativePath =
|
|
129
|
+
const relativePath = relative(root, candidate);
|
|
170
130
|
return relativePath === "" || !relativePath.startsWith("..") && !relativePath.startsWith("/") && !relativePath.startsWith("\\");
|
|
171
131
|
}
|
|
172
132
|
function uniquePaths(paths) {
|
|
@@ -186,21 +146,19 @@ function resolveRigStatePaths(projectRoot) {
|
|
|
186
146
|
const explicitStateDir = normalizeOptionalString(process.env.RIG_STATE_DIR);
|
|
187
147
|
const explicitLogsDir = normalizeOptionalString(process.env.RIG_LOGS_DIR);
|
|
188
148
|
const explicitSessionFile = normalizeOptionalString(process.env.RIG_SESSION_FILE);
|
|
189
|
-
const hostStateRoot =
|
|
149
|
+
const hostStateRoot = resolve3(projectRoot, ".rig");
|
|
190
150
|
const monorepoRoot = resolveMonorepoRoot(projectRoot);
|
|
191
|
-
const monorepoStateRoot =
|
|
192
|
-
const stateRoot = taskWorkspace ?
|
|
193
|
-
const stateDir = explicitStateDir ?
|
|
194
|
-
const logsDir = explicitLogsDir ?
|
|
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");
|
|
151
|
+
const monorepoStateRoot = resolve3(monorepoRoot, ".rig");
|
|
152
|
+
const stateRoot = taskWorkspace ? resolve3(taskWorkspace, ".rig") : explicitStateDir ? dirname3(resolve3(explicitStateDir)) : explicitLogsDir ? dirname3(resolve3(explicitLogsDir)) : explicitSessionFile ? dirname3(dirname3(resolve3(explicitSessionFile))) : existsSync3(hostStateRoot) ? hostStateRoot : monorepoStateRoot;
|
|
153
|
+
const stateDir = explicitStateDir ? resolve3(explicitStateDir) : resolve3(stateRoot, "state");
|
|
154
|
+
const logsDir = explicitLogsDir ? resolve3(explicitLogsDir) : resolve3(stateRoot, "logs");
|
|
196
155
|
return {
|
|
197
156
|
stateRoot,
|
|
198
157
|
stateDir,
|
|
199
158
|
logsDir,
|
|
200
|
-
controlPlaneEventsFile:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
keybindingsPath: resolve4(projectRoot, "rig", "keybindings.json")
|
|
159
|
+
controlPlaneEventsFile: resolve3(logsDir, "control-plane.events.jsonl"),
|
|
160
|
+
notificationsFile: resolve3(projectRoot, "rig", "notifications", "targets.json"),
|
|
161
|
+
keybindingsPath: resolve3(projectRoot, "rig", "keybindings.json")
|
|
204
162
|
};
|
|
205
163
|
}
|
|
206
164
|
function resolveRigProjectRoot(input) {
|
|
@@ -211,85 +169,40 @@ function resolveRigProjectRoot(input) {
|
|
|
211
169
|
const fallbackRoot = input?.fallbackRoot ?? cwd;
|
|
212
170
|
const candidates = [cwd, fallbackRoot];
|
|
213
171
|
for (const candidate of candidates) {
|
|
214
|
-
if (existsSync3(
|
|
172
|
+
if (existsSync3(resolve3(candidate, RIG_DEFINITION_DIRNAME))) {
|
|
215
173
|
return candidate;
|
|
216
174
|
}
|
|
217
175
|
}
|
|
218
176
|
return fallbackRoot;
|
|
219
177
|
}
|
|
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
178
|
function resolveAuthorityRuntimeDir(projectRoot) {
|
|
244
|
-
return
|
|
179
|
+
return resolve3(resolveAuthorityStateRoot(projectRoot), "runtime");
|
|
245
180
|
}
|
|
246
181
|
function listAuthorityRunRoots(projectRoot) {
|
|
247
|
-
const normalizedRoot =
|
|
182
|
+
const normalizedRoot = resolve3(projectRoot);
|
|
248
183
|
const monorepoRoot = resolveMonorepoRoot(normalizedRoot);
|
|
249
184
|
return uniquePaths([
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
]);
|
|
253
|
-
}
|
|
254
|
-
function listAuthorityArtifactRoots(projectRoot) {
|
|
255
|
-
return uniquePaths([
|
|
256
|
-
resolveAuthorityArtifactsRoot(projectRoot)
|
|
185
|
+
resolve3(resolveAuthorityStateRoot(normalizedRoot), "runs"),
|
|
186
|
+
resolve3(monorepoRoot, ".rig", "runs")
|
|
257
187
|
]);
|
|
258
188
|
}
|
|
259
189
|
function listAuthorityRuntimeAgentsRoots(projectRoot) {
|
|
260
190
|
return uniquePaths([
|
|
261
|
-
|
|
191
|
+
resolve3(resolveAuthorityRuntimeDir(projectRoot), "agents")
|
|
262
192
|
]);
|
|
263
193
|
}
|
|
264
194
|
function resolveAuthorityRunDir(projectRoot, runId) {
|
|
265
195
|
const safeRunId = assertSafeRunId(runId);
|
|
266
196
|
const roots = listAuthorityRunRoots(projectRoot);
|
|
267
197
|
for (const runsDir of roots) {
|
|
268
|
-
const candidate =
|
|
198
|
+
const candidate = resolve3(runsDir, safeRunId);
|
|
269
199
|
if (existsSync3(candidate)) {
|
|
270
200
|
return candidate;
|
|
271
201
|
}
|
|
272
202
|
}
|
|
273
|
-
return
|
|
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;
|
|
203
|
+
return resolve3(roots[0] ?? resolveAuthorityPaths(projectRoot).runsDir, safeRunId);
|
|
290
204
|
}
|
|
291
205
|
export {
|
|
292
|
-
resolveTaskArtifactDirs,
|
|
293
206
|
resolveRigStatePaths,
|
|
294
207
|
resolveRigProjectRoot,
|
|
295
208
|
resolveAuthorityStateRoot,
|
|
@@ -298,11 +211,9 @@ export {
|
|
|
298
211
|
resolveAuthorityRunDir,
|
|
299
212
|
resolveAuthorityProjectStateDir,
|
|
300
213
|
resolveAuthorityPaths,
|
|
301
|
-
resolveAuthorityArtifactsRoot,
|
|
302
214
|
normalizeOptionalString,
|
|
303
215
|
normalizeOptionalBoolean,
|
|
304
216
|
listAuthorityRuntimeAgentsRoots,
|
|
305
217
|
listAuthorityRunRoots,
|
|
306
|
-
listAuthorityArtifactRoots,
|
|
307
218
|
isPathWithin
|
|
308
219
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/core",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.178",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Config and plugin composition library for Rig's OMP extension ecosystem; not a product host/runtime.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -105,10 +105,6 @@
|
|
|
105
105
|
"types": "./dist/src/harness-paths.d.ts",
|
|
106
106
|
"import": "./dist/src/harness-paths.js"
|
|
107
107
|
},
|
|
108
|
-
"./profile-ops": {
|
|
109
|
-
"types": "./dist/src/profile-ops.d.ts",
|
|
110
|
-
"import": "./dist/src/profile-ops.js"
|
|
111
|
-
},
|
|
112
108
|
"./root-resolver": {
|
|
113
109
|
"types": "./dist/src/root-resolver.d.ts",
|
|
114
110
|
"import": "./dist/src/root-resolver.js"
|
|
@@ -185,8 +181,8 @@
|
|
|
185
181
|
"module": "./dist/src/index.js",
|
|
186
182
|
"types": "./dist/src/index.d.ts",
|
|
187
183
|
"dependencies": {
|
|
188
|
-
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.
|
|
189
|
-
"@rig/kernel-seed": "npm:@h-rig/kernel-seed@0.0.6-alpha.
|
|
184
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.178",
|
|
185
|
+
"@rig/kernel-seed": "npm:@h-rig/kernel-seed@0.0.6-alpha.178",
|
|
190
186
|
"effect": "4.0.0-beta.90",
|
|
191
187
|
"smol-toml": "^1.6.0"
|
|
192
188
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function showProfile(projectRoot: string, compact?: boolean): Promise<void>;
|
|
2
|
-
export declare function setProfile(projectRoot: string, options: {
|
|
3
|
-
model?: string;
|
|
4
|
-
runtime?: string;
|
|
5
|
-
plugin?: string;
|
|
6
|
-
preset?: string;
|
|
7
|
-
}): Promise<void>;
|
|
8
|
-
export declare function showReviewProfile(projectRoot: string): Promise<void>;
|
|
9
|
-
export declare function setReviewProfile(projectRoot: string, mode: string, provider?: string): Promise<void>;
|