@h-rig/runtime 0.0.6-alpha.34 → 0.0.6-alpha.35
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/bin/rig-agent-dispatch.js +518 -459
- package/dist/bin/rig-agent.js +430 -361
- package/dist/src/control-plane/agent-wrapper.js +523 -464
- package/dist/src/control-plane/harness-main.js +528 -458
- package/dist/src/control-plane/hooks/completion-verification.js +353 -283
- package/dist/src/control-plane/hooks/inject-context.js +158 -99
- package/dist/src/control-plane/hooks/submodule-branch.js +538 -479
- package/dist/src/control-plane/hooks/task-runtime-start.js +538 -479
- package/dist/src/control-plane/materialize-task-config.js +68 -8
- package/dist/src/control-plane/native/git-ops.js +10 -0
- package/dist/src/control-plane/native/harness-cli.js +513 -443
- package/dist/src/control-plane/native/task-ops.js +392 -322
- package/dist/src/control-plane/native/validator.js +159 -100
- package/dist/src/control-plane/native/verifier.js +227 -166
- package/dist/src/control-plane/pi-settings-materializer.js +52 -0
- package/dist/src/control-plane/plugin-host-context.js +59 -0
- package/dist/src/control-plane/runtime/index.js +469 -410
- package/dist/src/control-plane/runtime/isolation/index.js +493 -434
- package/dist/src/control-plane/runtime/isolation.js +493 -434
- package/dist/src/control-plane/runtime/queue.js +411 -352
- package/dist/src/control-plane/tasks/source-lifecycle.js +87 -28
- package/package.json +8 -8
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/runtime/src/control-plane/pi-settings-materializer.ts
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
4
|
+
import { dirname, resolve } from "path";
|
|
5
|
+
var SETTINGS_RELATIVE_PATH = ".pi/settings.json";
|
|
6
|
+
var MANAGED_RECORD_RELATIVE_PATH = ".rig/state/pi-managed-packages.json";
|
|
7
|
+
function readJson(path, fallback) {
|
|
8
|
+
if (!existsSync(path))
|
|
9
|
+
return fallback;
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(readFileSync(path, "utf-8"));
|
|
12
|
+
} catch {
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function packageKey(entry) {
|
|
17
|
+
if (typeof entry === "string")
|
|
18
|
+
return entry;
|
|
19
|
+
if (entry && typeof entry === "object" && typeof entry.source === "string") {
|
|
20
|
+
return entry.source;
|
|
21
|
+
}
|
|
22
|
+
return JSON.stringify(entry);
|
|
23
|
+
}
|
|
24
|
+
function materializePiPackages(projectRoot, declaredPackages) {
|
|
25
|
+
const settingsPath = resolve(projectRoot, SETTINGS_RELATIVE_PATH);
|
|
26
|
+
const managedRecordPath = resolve(projectRoot, MANAGED_RECORD_RELATIVE_PATH);
|
|
27
|
+
const settings = readJson(settingsPath, {});
|
|
28
|
+
const previouslyManaged = new Set(readJson(managedRecordPath, []));
|
|
29
|
+
const existing = Array.isArray(settings.packages) ? settings.packages : [];
|
|
30
|
+
const operatorEntries = existing.filter((entry) => !previouslyManaged.has(packageKey(entry)));
|
|
31
|
+
const operatorKeys = new Set(operatorEntries.map(packageKey));
|
|
32
|
+
const managedToAdd = declaredPackages.filter((pkg) => !operatorKeys.has(pkg));
|
|
33
|
+
const nextPackages = [...operatorEntries, ...managedToAdd];
|
|
34
|
+
if (nextPackages.length > 0 || existsSync(settingsPath)) {
|
|
35
|
+
const nextSettings = { ...settings };
|
|
36
|
+
if (nextPackages.length > 0) {
|
|
37
|
+
nextSettings.packages = nextPackages;
|
|
38
|
+
} else {
|
|
39
|
+
delete nextSettings.packages;
|
|
40
|
+
}
|
|
41
|
+
mkdirSync(dirname(settingsPath), { recursive: true });
|
|
42
|
+
writeFileSync(settingsPath, `${JSON.stringify(nextSettings, null, 2)}
|
|
43
|
+
`, "utf-8");
|
|
44
|
+
}
|
|
45
|
+
mkdirSync(dirname(managedRecordPath), { recursive: true });
|
|
46
|
+
writeFileSync(managedRecordPath, `${JSON.stringify(managedToAdd, null, 2)}
|
|
47
|
+
`, "utf-8");
|
|
48
|
+
return { settingsPath, packages: managedToAdd };
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
materializePiPackages
|
|
52
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/runtime/src/control-plane/plugin-host-context.ts
|
|
3
|
+
import { existsSync as existsSync5 } from "fs";
|
|
4
|
+
import { resolve as resolvePath } from "path";
|
|
3
5
|
import { createPluginHost } from "@rig/core";
|
|
4
6
|
import { loadConfig } from "@rig/core/load-config";
|
|
5
7
|
|
|
@@ -326,6 +328,55 @@ async function materializeSkills(projectRoot, entries) {
|
|
|
326
328
|
return written;
|
|
327
329
|
}
|
|
328
330
|
|
|
331
|
+
// packages/runtime/src/control-plane/pi-settings-materializer.ts
|
|
332
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
333
|
+
import { dirname as dirname2, resolve as resolve3 } from "path";
|
|
334
|
+
var SETTINGS_RELATIVE_PATH = ".pi/settings.json";
|
|
335
|
+
var MANAGED_RECORD_RELATIVE_PATH = ".rig/state/pi-managed-packages.json";
|
|
336
|
+
function readJson(path, fallback) {
|
|
337
|
+
if (!existsSync4(path))
|
|
338
|
+
return fallback;
|
|
339
|
+
try {
|
|
340
|
+
return JSON.parse(readFileSync3(path, "utf-8"));
|
|
341
|
+
} catch {
|
|
342
|
+
return fallback;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function packageKey(entry) {
|
|
346
|
+
if (typeof entry === "string")
|
|
347
|
+
return entry;
|
|
348
|
+
if (entry && typeof entry === "object" && typeof entry.source === "string") {
|
|
349
|
+
return entry.source;
|
|
350
|
+
}
|
|
351
|
+
return JSON.stringify(entry);
|
|
352
|
+
}
|
|
353
|
+
function materializePiPackages(projectRoot, declaredPackages) {
|
|
354
|
+
const settingsPath = resolve3(projectRoot, SETTINGS_RELATIVE_PATH);
|
|
355
|
+
const managedRecordPath = resolve3(projectRoot, MANAGED_RECORD_RELATIVE_PATH);
|
|
356
|
+
const settings = readJson(settingsPath, {});
|
|
357
|
+
const previouslyManaged = new Set(readJson(managedRecordPath, []));
|
|
358
|
+
const existing = Array.isArray(settings.packages) ? settings.packages : [];
|
|
359
|
+
const operatorEntries = existing.filter((entry) => !previouslyManaged.has(packageKey(entry)));
|
|
360
|
+
const operatorKeys = new Set(operatorEntries.map(packageKey));
|
|
361
|
+
const managedToAdd = declaredPackages.filter((pkg) => !operatorKeys.has(pkg));
|
|
362
|
+
const nextPackages = [...operatorEntries, ...managedToAdd];
|
|
363
|
+
if (nextPackages.length > 0 || existsSync4(settingsPath)) {
|
|
364
|
+
const nextSettings = { ...settings };
|
|
365
|
+
if (nextPackages.length > 0) {
|
|
366
|
+
nextSettings.packages = nextPackages;
|
|
367
|
+
} else {
|
|
368
|
+
delete nextSettings.packages;
|
|
369
|
+
}
|
|
370
|
+
mkdirSync3(dirname2(settingsPath), { recursive: true });
|
|
371
|
+
writeFileSync3(settingsPath, `${JSON.stringify(nextSettings, null, 2)}
|
|
372
|
+
`, "utf-8");
|
|
373
|
+
}
|
|
374
|
+
mkdirSync3(dirname2(managedRecordPath), { recursive: true });
|
|
375
|
+
writeFileSync3(managedRecordPath, `${JSON.stringify(managedToAdd, null, 2)}
|
|
376
|
+
`, "utf-8");
|
|
377
|
+
return { settingsPath, packages: managedToAdd };
|
|
378
|
+
}
|
|
379
|
+
|
|
329
380
|
// packages/runtime/src/control-plane/plugin-host-context.ts
|
|
330
381
|
async function buildPluginHostContext(projectRoot) {
|
|
331
382
|
let config;
|
|
@@ -373,6 +424,14 @@ async function buildPluginHostContext(projectRoot) {
|
|
|
373
424
|
} catch (err) {
|
|
374
425
|
console.warn(`[plugin-host] skill materialization failed: ${err instanceof Error ? err.message : err}`);
|
|
375
426
|
}
|
|
427
|
+
try {
|
|
428
|
+
const piPackages = config.runtime?.pi?.packages ?? [];
|
|
429
|
+
if (piPackages.length > 0 || existsSync5(resolvePath(projectRoot, ".rig/state/pi-managed-packages.json"))) {
|
|
430
|
+
materializePiPackages(projectRoot, piPackages);
|
|
431
|
+
}
|
|
432
|
+
} catch (err) {
|
|
433
|
+
console.warn(`[plugin-host] Pi package materialization failed: ${err instanceof Error ? err.message : err}`);
|
|
434
|
+
}
|
|
376
435
|
return {
|
|
377
436
|
config,
|
|
378
437
|
pluginHost,
|