@ponythewhite/base-context 1.0.15 → 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 (74) hide show
  1. package/CHANGELOG.md +9 -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-O67MEO74.js → bundled-modules-2DMTK7VK.js} +2 -2
  12. package/dist/bundle/{chunk-RQFC34FM.js → chunk-MSH6QRP5.js} +1601 -820
  13. package/dist/bundle/{chunk-DGO66I3L.js → chunk-T2OK7SRV.js} +3 -2
  14. package/dist/bundle/{cli-main-2RER6PBE.js → cli-main-WL2L5IEQ.js} +2 -2
  15. package/dist/bundle/cli.js +1 -1
  16. package/dist/bundle/{main-YERLD3T4.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 +155 -9
  20. package/dist/core/agent-session.js.map +1 -1
  21. package/dist/core/history-index-worker.d.ts.map +1 -1
  22. package/dist/core/history-index-worker.js +22 -1
  23. package/dist/core/history-index-worker.js.map +1 -1
  24. package/dist/core/history-index.d.ts +2 -0
  25. package/dist/core/history-index.d.ts.map +1 -1
  26. package/dist/core/history-index.js.map +1 -1
  27. package/dist/core/job-watch.d.ts +120 -0
  28. package/dist/core/job-watch.d.ts.map +1 -0
  29. package/dist/core/job-watch.js +648 -0
  30. package/dist/core/job-watch.js.map +1 -0
  31. package/dist/core/kernel/repl-manager.d.ts +5 -1
  32. package/dist/core/kernel/repl-manager.d.ts.map +1 -1
  33. package/dist/core/kernel/repl-manager.js +52 -0
  34. package/dist/core/kernel/repl-manager.js.map +1 -1
  35. package/dist/core/kernel/shared.d.ts +12 -0
  36. package/dist/core/kernel/shared.d.ts.map +1 -1
  37. package/dist/core/kernel/shared.js.map +1 -1
  38. package/dist/core/prompts/rlm.d.ts.map +1 -1
  39. package/dist/core/prompts/rlm.js +49 -39
  40. package/dist/core/prompts/rlm.js.map +1 -1
  41. package/dist/core/session-manager.d.ts +2 -0
  42. package/dist/core/session-manager.d.ts.map +1 -1
  43. package/dist/core/session-manager.js +9 -1
  44. package/dist/core/session-manager.js.map +1 -1
  45. package/dist/core/tools/prime-context.d.ts.map +1 -1
  46. package/dist/core/tools/prime-context.js +1 -1
  47. package/dist/core/tools/prime-context.js.map +1 -1
  48. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  49. package/dist/modes/interactive/interactive-mode.js +2 -1
  50. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  51. package/dist/skills/agent-message/SKILL.md +8 -2
  52. package/dist/skills/bounded-inspect/SKILL.md +78 -0
  53. package/dist/skills/bounded-inspect/pyproject.toml +16 -0
  54. package/dist/skills/bounded-inspect/src/bounded_inspect/__init__.py +313 -0
  55. package/dist/skills/bounded-inspect/src/bounded_inspect/__main__.py +3 -0
  56. package/dist/skills/job-watch/SKILL.md +43 -0
  57. package/dist/skills/job-watch/pyproject.toml +13 -0
  58. package/dist/skills/job-watch/src/job_watch/__init__.py +61 -0
  59. package/dist/skills/rlm-heartbeat/SKILL.md +10 -6
  60. package/dist/utils/file-lines.d.ts.map +1 -1
  61. package/dist/utils/file-lines.js +6 -2
  62. package/dist/utils/file-lines.js.map +1 -1
  63. package/docs/rlm-runtime.md +4 -1
  64. package/docs/skills.md +18 -26
  65. package/package.json +4 -4
  66. package/skills/agent-message/SKILL.md +8 -2
  67. package/skills/bounded-inspect/SKILL.md +78 -0
  68. package/skills/bounded-inspect/pyproject.toml +16 -0
  69. package/skills/bounded-inspect/src/bounded_inspect/__init__.py +313 -0
  70. package/skills/bounded-inspect/src/bounded_inspect/__main__.py +3 -0
  71. package/skills/job-watch/SKILL.md +43 -0
  72. package/skills/job-watch/pyproject.toml +13 -0
  73. package/skills/job-watch/src/job_watch/__init__.py +61 -0
  74. 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();
@@ -726,6 +757,8 @@ export class ReplKernelManager {
726
757
  handleEvent(event) {
727
758
  const type = event.event;
728
759
  if (type === "ready") {
760
+ this.jobWatchCapability =
761
+ Array.isArray(event.capabilities) && event.capabilities.includes("job_watch_probe_v1");
729
762
  this.pythonVersion = typeof event.python === "string" ? event.python : undefined;
730
763
  this.readyDeferred?.resolve(typeof event.protocol === "number" ? event.protocol : -1);
731
764
  return;
@@ -1218,6 +1251,19 @@ export class ReplKernelManager {
1218
1251
  if (typeof data.type !== "string" || data.type.length === 0) {
1219
1252
  throw new Error("host request payload must have a string type");
1220
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
+ }
1221
1267
  const handler = this.options.hostHandlers?.[data.type];
1222
1268
  if (!handler) {
1223
1269
  throw new Error(`host request type "${data.type}" is not available in this session`);
@@ -1278,6 +1324,12 @@ export class ReplKernelManager {
1278
1324
  await this.writeLine({ type: "interrupt", id: requestId });
1279
1325
  }
1280
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();
1281
1333
  const failures = [];
1282
1334
  this.startGeneration++; // any teardown invalidates in-flight starts
1283
1335
  this.clearSnapshotTimer();