@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
@@ -39,7 +39,8 @@ const COMPACTION_BOOKKEEPING_ENTRY_TYPES = new Set([
39
39
  ]);
40
40
  function isCompactionBookkeeping(entry) {
41
41
  return (COMPACTION_BOOKKEEPING_ENTRY_TYPES.has(entry.type) ||
42
- (entry.type === "custom_message" && entry.customType === COMPACTION_OUTCOME_CUSTOM_TYPE));
42
+ (entry.type === "custom_message" && entry.customType === COMPACTION_OUTCOME_CUSTOM_TYPE) ||
43
+ (entry.type === "custom" && entry.customType === "job_watch_state"));
43
44
  }
44
45
  // Entry types that can represent user intent (vs. daemon bookkeeping like
45
46
  // session_state/agent_status/git_state/child_usage_attributed). Used by
@@ -1932,6 +1933,13 @@ export class SessionManager {
1932
1933
  this.sessionFile === sessionFile &&
1933
1934
  state.branchSelectionRevision === selectionRevision;
1934
1935
  }
1936
+ /** Capture content ownership, ignoring bookkeeping and allowing the caller's known ACKed content appends. */
1937
+ captureCompactionContentOwner() {
1938
+ const sourceIsCurrent = this.captureCompactionSourceOwner();
1939
+ const state = this.writeState;
1940
+ const revision = state.compactionRevision;
1941
+ return (ownAppends = 0) => sourceIsCurrent() && state.compactionRevision === revision + ownAppends;
1942
+ }
1935
1943
  bindCompactionSink(limits = DEFAULT_MANAGER_HISTORY_LIMITS) {
1936
1944
  const state = this.writeState;
1937
1945
  const owner = state.owner;
@@ -2012,6 +2020,10 @@ export class SessionManager {
2012
2020
  isCurrent: () => isCurrent(currentRevision),
2013
2021
  readHistory: (read) => sink.readHistory((history) => read(history.branchContext)),
2014
2022
  [readCopiedEpochSource]: (read) => sink.readHistory(read),
2023
+ readCompactionEntries: (entryIds) => {
2024
+ const ids = [...new Set(entryIds)];
2025
+ return sink.readHistory((history) => this._readCompactionEntriesAt(history, ids, capturedLimits));
2026
+ },
2015
2027
  readBranch: async () => {
2016
2028
  if (indexed)
2017
2029
  return sink.readHistory(async (history) => (await this._readBranchesAt(history, [history.source.leafId], capturedLimits)).branches[0]);
@@ -2893,6 +2905,59 @@ export class SessionManager {
2893
2905
  return entries;
2894
2906
  });
2895
2907
  }
2908
+ async _readCompactionEntriesAt(history, entryIds, limits) {
2909
+ const { maxEntries, maxSourceBytes } = limits;
2910
+ if (!Number.isSafeInteger(maxEntries) ||
2911
+ maxEntries <= 0 ||
2912
+ !Number.isSafeInteger(maxSourceBytes) ||
2913
+ maxSourceBytes <= 0)
2914
+ throw new Error("Invalid compaction source limits");
2915
+ if (entryIds.length > maxEntries)
2916
+ throw new Error("Compaction entry budget exceeded");
2917
+ const selected = new Set(entryIds);
2918
+ const references = [];
2919
+ for (const id of entryIds) {
2920
+ const reference = await history.branchContext.get(id);
2921
+ if (!reference)
2922
+ throw new Error("Compaction entry is outside its captured branch");
2923
+ references.push(reference);
2924
+ }
2925
+ references.sort((a, b) => a.sequence - b.sequence);
2926
+ // Pinned older views cannot cross an omitted message to become a chronological cut.
2927
+ // Walk metadata only: excluded lifetime payloads must not consume the hydration budget.
2928
+ const suffixAnchors = new Set();
2929
+ const visited = new Set();
2930
+ let current = history.source.leafId;
2931
+ let leafKind;
2932
+ while (current !== null) {
2933
+ if (visited.has(current))
2934
+ throw new Error("Compaction parent path is unresolved");
2935
+ visited.add(current);
2936
+ const reference = await history.branchContext.get(current);
2937
+ if (!reference)
2938
+ throw new Error("Compaction parent path is unresolved");
2939
+ leafKind ??= reference.kind;
2940
+ if (["message", "custom_message", "branch_summary"].includes(reference.kind)) {
2941
+ if (!selected.has(reference.id))
2942
+ break;
2943
+ suffixAnchors.add(reference.id);
2944
+ }
2945
+ current = reference.parentId;
2946
+ }
2947
+ const entries = [];
2948
+ let sourceBytes = 0;
2949
+ for (const reference of references) {
2950
+ const remaining = maxSourceBytes - sourceBytes;
2951
+ sourceBytes += reference.locator.length;
2952
+ if (sourceBytes > maxSourceBytes)
2953
+ throw new Error("Compaction source byte budget exceeded");
2954
+ const value = await history.hydrateEntry(reference.id, remaining);
2955
+ if (!value)
2956
+ throw new Error("Compaction entry source is unavailable");
2957
+ entries.push(withEntryRetention(value.entry, value.source.retention, value.source.qualification));
2958
+ }
2959
+ return { entries, suffixAnchors, leafKind };
2960
+ }
2896
2961
  async _readBranchesAt(history, leafIds, limits) {
2897
2962
  const { maxEntries, maxSourceBytes } = limits;
2898
2963
  if (!Number.isSafeInteger(maxEntries) ||