@ponythewhite/base-context 1.0.14 → 1.0.16

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 (90) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/base-context-runtime/pyproject.toml +1 -1
  3. package/dist/base-context-runtime/src/rlm/bash.py +19 -0
  4. package/dist/base-context-runtime/src/rlm/job_watch.py +156 -0
  5. package/dist/base-context-runtime/src/rlm/repl.md +28 -6
  6. package/dist/base-context-runtime/src/rlm/repl.py +6 -1
  7. package/dist/base-context-runtime/test/test_bash.py +4 -4
  8. package/dist/base-context-runtime/test/test_job_watch.py +67 -0
  9. package/dist/base-context-runtime/uv.lock +1 -1
  10. package/dist/build-info.json +1 -1
  11. package/dist/bundle/{bundled-modules-UODO7ZR7.js → bundled-modules-2DMTK7VK.js} +2 -2
  12. package/dist/bundle/{chunk-SX7CAXWU.js → chunk-MSH6QRP5.js} +1730 -867
  13. package/dist/bundle/{chunk-NLRWERWA.js → chunk-T2OK7SRV.js} +53 -21
  14. package/dist/bundle/{cli-main-6GXXIMQQ.js → cli-main-WL2L5IEQ.js} +2 -2
  15. package/dist/bundle/cli.js +1 -1
  16. package/dist/bundle/{main-HF64B4HM.js → main-XPIEIEQJ.js} +2 -2
  17. package/dist/core/agent-session.d.ts +2 -0
  18. package/dist/core/agent-session.d.ts.map +1 -1
  19. package/dist/core/agent-session.js +191 -33
  20. package/dist/core/agent-session.js.map +1 -1
  21. package/dist/core/compaction/compaction.d.ts +1 -1
  22. package/dist/core/compaction/compaction.d.ts.map +1 -1
  23. package/dist/core/compaction/compaction.js +11 -9
  24. package/dist/core/compaction/compaction.js.map +1 -1
  25. package/dist/core/history-index-worker.d.ts.map +1 -1
  26. package/dist/core/history-index-worker.js +22 -1
  27. package/dist/core/history-index-worker.js.map +1 -1
  28. package/dist/core/history-index.d.ts +2 -0
  29. package/dist/core/history-index.d.ts.map +1 -1
  30. package/dist/core/history-index.js.map +1 -1
  31. package/dist/core/inference-coordinator.d.ts.map +1 -1
  32. package/dist/core/inference-coordinator.js +13 -2
  33. package/dist/core/inference-coordinator.js.map +1 -1
  34. package/dist/core/job-watch.d.ts +120 -0
  35. package/dist/core/job-watch.d.ts.map +1 -0
  36. package/dist/core/job-watch.js +648 -0
  37. package/dist/core/job-watch.js.map +1 -0
  38. package/dist/core/kernel/repl-manager.d.ts +5 -1
  39. package/dist/core/kernel/repl-manager.d.ts.map +1 -1
  40. package/dist/core/kernel/repl-manager.js +57 -0
  41. package/dist/core/kernel/repl-manager.js.map +1 -1
  42. package/dist/core/kernel/shared.d.ts +12 -0
  43. package/dist/core/kernel/shared.d.ts.map +1 -1
  44. package/dist/core/kernel/shared.js.map +1 -1
  45. package/dist/core/prompts/rlm.d.ts.map +1 -1
  46. package/dist/core/prompts/rlm.js +49 -39
  47. package/dist/core/prompts/rlm.js.map +1 -1
  48. package/dist/core/session-manager.d.ts +10 -0
  49. package/dist/core/session-manager.d.ts.map +1 -1
  50. package/dist/core/session-manager.js +66 -1
  51. package/dist/core/session-manager.js.map +1 -1
  52. package/dist/core/tools/prime-context.d.ts.map +1 -1
  53. package/dist/core/tools/prime-context.js +1 -1
  54. package/dist/core/tools/prime-context.js.map +1 -1
  55. package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
  56. package/dist/modes/daemon/daemon-mode.js +17 -17
  57. package/dist/modes/daemon/daemon-mode.js.map +1 -1
  58. package/dist/modes/daemon/daemon-worker-client.d.ts +1 -0
  59. package/dist/modes/daemon/daemon-worker-client.d.ts.map +1 -1
  60. package/dist/modes/daemon/daemon-worker-client.js +8 -0
  61. package/dist/modes/daemon/daemon-worker-client.js.map +1 -1
  62. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  63. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  64. package/dist/modes/interactive/interactive-mode.js +31 -5
  65. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  66. package/dist/skills/agent-message/SKILL.md +8 -2
  67. package/dist/skills/bounded-inspect/SKILL.md +78 -0
  68. package/dist/skills/bounded-inspect/pyproject.toml +16 -0
  69. package/dist/skills/bounded-inspect/src/bounded_inspect/__init__.py +313 -0
  70. package/dist/skills/bounded-inspect/src/bounded_inspect/__main__.py +3 -0
  71. package/dist/skills/job-watch/SKILL.md +43 -0
  72. package/dist/skills/job-watch/pyproject.toml +13 -0
  73. package/dist/skills/job-watch/src/job_watch/__init__.py +61 -0
  74. package/dist/skills/rlm-heartbeat/SKILL.md +10 -6
  75. package/dist/utils/file-lines.d.ts.map +1 -1
  76. package/dist/utils/file-lines.js +6 -2
  77. package/dist/utils/file-lines.js.map +1 -1
  78. package/docs/rlm-runtime.md +4 -1
  79. package/docs/skills.md +18 -26
  80. package/docs/upstream-1.0.15.md +83 -0
  81. package/package.json +4 -4
  82. package/skills/agent-message/SKILL.md +8 -2
  83. package/skills/bounded-inspect/SKILL.md +78 -0
  84. package/skills/bounded-inspect/pyproject.toml +16 -0
  85. package/skills/bounded-inspect/src/bounded_inspect/__init__.py +313 -0
  86. package/skills/bounded-inspect/src/bounded_inspect/__main__.py +3 -0
  87. package/skills/job-watch/SKILL.md +43 -0
  88. package/skills/job-watch/pyproject.toml +13 -0
  89. package/skills/job-watch/src/job_watch/__init__.py +61 -0
  90. package/skills/rlm-heartbeat/SKILL.md +10 -6
@@ -78,6 +78,37 @@ export class ReplKernelManager {
78
78
  childOrphanOwner;
79
79
  readyDeferred;
80
80
  pythonVersion;
81
+ jobWatchCapability = false;
82
+ jobWatchRequests = new Map();
83
+ jobWatchProbe(request) {
84
+ if (!this.jobWatchCapability || !this.isRunning)
85
+ return Promise.reject(new Error("Kernel job_watch_probe_v1 is unavailable; no probe was launched"));
86
+ const id = uuid();
87
+ return new Promise((resolve, reject) => {
88
+ const timer = setTimeout(() => {
89
+ this.jobWatchRequests.delete(id);
90
+ void this.writeLine({ type: "job_watch_probe", id, cancel: true }).catch(() => { });
91
+ reject(new Error("Job watch probe transport timed out"));
92
+ }, request.timeoutMs + 5000);
93
+ timer.unref();
94
+ this.jobWatchRequests.set(id, { watchId: request.watchId, resolve, reject, timer });
95
+ void this.writeLine({ type: "job_watch_probe", id, ...request }).catch((error) => {
96
+ clearTimeout(timer);
97
+ this.jobWatchRequests.delete(id);
98
+ reject(error);
99
+ });
100
+ });
101
+ }
102
+ cancelJobWatchProbe(watchId) {
103
+ for (const [id, pending] of this.jobWatchRequests) {
104
+ if (pending.watchId !== watchId)
105
+ continue;
106
+ clearTimeout(pending.timer);
107
+ this.jobWatchRequests.delete(id);
108
+ void this.writeLine({ type: "job_watch_probe", id, cancel: true }).catch(() => { });
109
+ pending.reject(new Error("Job watch probe cancelled"));
110
+ }
111
+ }
81
112
  kernelStderr = "";
82
113
  /** Serializes execute() calls — the runtime runs one request at a time. */
83
114
  executionQueue = Promise.resolve();
@@ -404,6 +435,11 @@ export class ReplKernelManager {
404
435
  return;
405
436
  this.appendKernelDiagnostic(`kernel stdout error: ${errorMessage(error)}`);
406
437
  });
438
+ child.stderr?.on("error", (error) => {
439
+ if (this.child !== child)
440
+ return;
441
+ this.appendKernelDiagnostic(`kernel stderr error: ${errorMessage(error)}`);
442
+ });
407
443
  child.once("exit", () => {
408
444
  // One turn for the poll phase to deliver the bytes the kernel wrote
409
445
  // before dying (the pipe buffer bounds them), then destroy: EOF may
@@ -721,6 +757,8 @@ export class ReplKernelManager {
721
757
  handleEvent(event) {
722
758
  const type = event.event;
723
759
  if (type === "ready") {
760
+ this.jobWatchCapability =
761
+ Array.isArray(event.capabilities) && event.capabilities.includes("job_watch_probe_v1");
724
762
  this.pythonVersion = typeof event.python === "string" ? event.python : undefined;
725
763
  this.readyDeferred?.resolve(typeof event.protocol === "number" ? event.protocol : -1);
726
764
  return;
@@ -1213,6 +1251,19 @@ export class ReplKernelManager {
1213
1251
  if (typeof data.type !== "string" || data.type.length === 0) {
1214
1252
  throw new Error("host request payload must have a string type");
1215
1253
  }
1254
+ if (data.type === "job_watch.probe_result") {
1255
+ const id = typeof data.request_id === "string" ? data.request_id : "";
1256
+ const pending = this.jobWatchRequests.get(id);
1257
+ if (pending) {
1258
+ clearTimeout(pending.timer);
1259
+ this.jobWatchRequests.delete(id);
1260
+ if (isRecord(data.result))
1261
+ pending.resolve(data.result);
1262
+ else
1263
+ pending.reject(new Error("Malformed job watch probe result"));
1264
+ }
1265
+ return {};
1266
+ }
1216
1267
  const handler = this.options.hostHandlers?.[data.type];
1217
1268
  if (!handler) {
1218
1269
  throw new Error(`host request type "${data.type}" is not available in this session`);
@@ -1273,6 +1324,12 @@ export class ReplKernelManager {
1273
1324
  await this.writeLine({ type: "interrupt", id: requestId });
1274
1325
  }
1275
1326
  cleanupResources(killSignal = "SIGTERM") {
1327
+ this.jobWatchCapability = false;
1328
+ for (const pending of this.jobWatchRequests.values()) {
1329
+ clearTimeout(pending.timer);
1330
+ pending.reject(new Error("Kernel lost; job state is unknown"));
1331
+ }
1332
+ this.jobWatchRequests.clear();
1276
1333
  const failures = [];
1277
1334
  this.startGeneration++; // any teardown invalidates in-flight starts
1278
1335
  this.clearSnapshotTimer();