@h-rig/runtime 0.0.6-alpha.34 → 0.0.6-alpha.36

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 (27) hide show
  1. package/dist/bin/rig-agent-dispatch.js +518 -459
  2. package/dist/bin/rig-agent.js +430 -361
  3. package/dist/src/control-plane/agent-wrapper.js +523 -464
  4. package/dist/src/control-plane/harness-main.js +544 -463
  5. package/dist/src/control-plane/hooks/completion-verification.js +369 -288
  6. package/dist/src/control-plane/hooks/inject-context.js +158 -99
  7. package/dist/src/control-plane/hooks/submodule-branch.js +538 -479
  8. package/dist/src/control-plane/hooks/task-runtime-start.js +538 -479
  9. package/dist/src/control-plane/materialize-task-config.js +68 -8
  10. package/dist/src/control-plane/native/git-ops.js +10 -0
  11. package/dist/src/control-plane/native/harness-cli.js +529 -448
  12. package/dist/src/control-plane/native/task-ops.js +408 -327
  13. package/dist/src/control-plane/native/validator.js +159 -100
  14. package/dist/src/control-plane/native/verifier.js +243 -171
  15. package/dist/src/control-plane/pi-sessiond/bin.js +0 -7
  16. package/dist/src/control-plane/pi-sessiond/server.js +0 -7
  17. package/dist/src/control-plane/pi-sessiond/session-service.js +0 -3
  18. package/dist/src/control-plane/pi-settings-materializer.js +52 -0
  19. package/dist/src/control-plane/plugin-host-context.js +59 -0
  20. package/dist/src/control-plane/runtime/index.js +469 -410
  21. package/dist/src/control-plane/runtime/isolation/index.js +493 -434
  22. package/dist/src/control-plane/runtime/isolation.js +493 -434
  23. package/dist/src/control-plane/runtime/queue.js +411 -352
  24. package/dist/src/control-plane/tasks/source-lifecycle.js +87 -28
  25. package/dist/src/index.js +16 -8
  26. package/dist/src/local-server.js +17 -8
  27. package/package.json +8 -8
@@ -525,9 +525,6 @@ class RigPiSessionService {
525
525
  await this.prompt(sessionId, trimmed, active.runtime.session.isStreaming ? "steer" : undefined);
526
526
  return { type: "done", message: `Accepted ${trimmed}` };
527
527
  }
528
- respondToCommand(_sessionId, _requestId, _value) {
529
- return { type: "unsupported", message: "No pending command selection is active." };
530
- }
531
528
  respondToExtensionUi(sessionId, input) {
532
529
  const active = this.requireActive(sessionId);
533
530
  return { accepted: active.ui.respond(input) };
@@ -737,10 +734,6 @@ async function runRigPiSessionDaemon(options = {}) {
737
734
  const body = await readJson(req);
738
735
  return json(await sessions.runCommand(sessionId, requireText(body, "text")));
739
736
  }
740
- if (action === "commands/respond" && req.method === "POST") {
741
- const body = await readJson(req);
742
- return json(sessions.respondToCommand(sessionId, requireText(body, "requestId"), body.value));
743
- }
744
737
  if (action === "extension-ui/respond" && req.method === "POST") {
745
738
  const body = await readJson(req);
746
739
  return json(sessions.respondToExtensionUi(sessionId, {
@@ -523,9 +523,6 @@ class RigPiSessionService {
523
523
  await this.prompt(sessionId, trimmed, active.runtime.session.isStreaming ? "steer" : undefined);
524
524
  return { type: "done", message: `Accepted ${trimmed}` };
525
525
  }
526
- respondToCommand(_sessionId, _requestId, _value) {
527
- return { type: "unsupported", message: "No pending command selection is active." };
528
- }
529
526
  respondToExtensionUi(sessionId, input) {
530
527
  const active = this.requireActive(sessionId);
531
528
  return { accepted: active.ui.respond(input) };
@@ -735,10 +732,6 @@ async function runRigPiSessionDaemon(options = {}) {
735
732
  const body = await readJson(req);
736
733
  return json(await sessions.runCommand(sessionId, requireText(body, "text")));
737
734
  }
738
- if (action === "commands/respond" && req.method === "POST") {
739
- const body = await readJson(req);
740
- return json(sessions.respondToCommand(sessionId, requireText(body, "requestId"), body.value));
741
- }
742
735
  if (action === "extension-ui/respond" && req.method === "POST") {
743
736
  const body = await readJson(req);
744
737
  return json(sessions.respondToExtensionUi(sessionId, {
@@ -462,9 +462,6 @@ class RigPiSessionService {
462
462
  await this.prompt(sessionId, trimmed, active.runtime.session.isStreaming ? "steer" : undefined);
463
463
  return { type: "done", message: `Accepted ${trimmed}` };
464
464
  }
465
- respondToCommand(_sessionId, _requestId, _value) {
466
- return { type: "unsupported", message: "No pending command selection is active." };
467
- }
468
465
  respondToExtensionUi(sessionId, input) {
469
466
  const active = this.requireActive(sessionId);
470
467
  return { accepted: active.ui.respond(input) };
@@ -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,