pi-goosedump 0.12.37 → 0.12.38

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 (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.ts +11 -37
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -91,8 +91,8 @@ The footer shows the remaining turn count in hexadecimal.
91
91
  - `keep:N` leaves the last N user turns verbatim.
92
92
  - Manual requests wait until Pi is idle.
93
93
  - Memory learning runs in the background after a successful compaction.
94
- - If the turn limit expires during a tool loop, Pi saves the current batch,
95
- compacts at that turn boundary, and resumes automatically.
94
+ - If the turn limit expires during a tool loop, compaction waits until the agent
95
+ run settles, so no in-flight operation is aborted.
96
96
  - Goosedump failures fall back to Pi's compactor.
97
97
 
98
98
  ## License
package/dist/index.ts CHANGED
@@ -774,6 +774,13 @@ async function buildGoosedumpCompaction(target, preparation, branchEntries, summ
774
774
  }
775
775
 
776
776
  // src/compaction-runtime.ts
777
+ function isCompactionCancellation(error) {
778
+ if (!(error instanceof Error))
779
+ return false;
780
+ const code = error.code;
781
+ return error.name === "AbortError" || code === "ABORT_ERR" || error.message === "Compaction cancelled" || /\b(?:this|the) operation was aborted\b/i.test(error.message);
782
+ }
783
+
777
784
  class CompactionRuntime {
778
785
  overrideDefaultCompaction;
779
786
  nativeExecutablePath;
@@ -789,16 +796,12 @@ class CompactionRuntime {
789
796
  operationGeneration = 0;
790
797
  activeSessionFile = null;
791
798
  sessionActive = false;
792
- activePi = null;
793
799
  constructor(deps) {
794
800
  this.overrideDefaultCompaction = deps.overrideDefaultCompaction;
795
801
  this.nativeExecutablePath = deps.nativeExecutablePath;
796
802
  this.isAvailable = deps.isAvailable;
797
803
  this.enqueueRemember = deps.enqueueRemember;
798
804
  }
799
- setActivePi(pi) {
800
- this.activePi = pi;
801
- }
802
805
  requestCompaction(ctx, keep) {
803
806
  if (this.compactionState.phase !== "idle")
804
807
  return "busy";
@@ -872,8 +875,6 @@ class CompactionRuntime {
872
875
  onTurnEnd(event, ctx) {
873
876
  if (isCompletedAssistant(event.message))
874
877
  this.noteCompletedTurn(ctx);
875
- if (event.toolResults.length > 0)
876
- this.deferMidRunCounterCompaction(ctx);
877
878
  }
878
879
  onAgentSettled(ctx) {
879
880
  if (!this.isAvailable() || !this.overrideDefaultCompaction)
@@ -1091,32 +1092,6 @@ class CompactionRuntime {
1091
1092
  this.updateStatus(ctx);
1092
1093
  this.queueTurnCompaction(ctx, this.settlementGeneration + 1);
1093
1094
  }
1094
- resumeAfterSuccessfulCompaction(ctx, resume) {
1095
- if (!resume || !this.activePi || ctx.hasPendingMessages())
1096
- return;
1097
- this.activePi.sendMessage({
1098
- customType: "goosedump-autocompact-resume",
1099
- content: "The session was compacted to reduce context size. Continue the task you were working on from where you left off.",
1100
- display: false
1101
- }, { triggerTurn: true });
1102
- }
1103
- deferMidRunCounterCompaction(ctx) {
1104
- if (!this.isAvailable() || !this.turnCompactionEnabled() || !this.counterTriggered)
1105
- return;
1106
- if (ctx.hasPendingMessages() || !hasCompactableHistory(ctx))
1107
- return;
1108
- if (this.compactionState.phase !== "queued" || this.compactionState.request.origin !== "turn") {
1109
- return;
1110
- }
1111
- const request = this.compactionState.request;
1112
- setImmediate(() => {
1113
- if (this.compactionState.phase !== "queued" || this.compactionState.request !== request || !this.contextIsCurrent(ctx)) {
1114
- return;
1115
- }
1116
- const runStillActive = this.settlementGeneration < request.eligibleSettlement;
1117
- this.startQueuedCompaction(ctx, runStillActive ? { allowActiveRun: true, resumeAfter: true } : undefined);
1118
- });
1119
- }
1120
1095
  requestIsCurrent(request) {
1121
1096
  return request.sessionGeneration === this.sessionGeneration && request.sessionFile === this.activeSessionFile;
1122
1097
  }
@@ -1153,7 +1128,7 @@ class CompactionRuntime {
1153
1128
  }
1154
1129
  });
1155
1130
  }
1156
- startQueuedCompaction(ctx, options = {}) {
1131
+ startQueuedCompaction(ctx) {
1157
1132
  if (this.compactionState.phase !== "queued")
1158
1133
  return false;
1159
1134
  const request = this.compactionState.request;
@@ -1165,7 +1140,7 @@ class CompactionRuntime {
1165
1140
  }
1166
1141
  if (ctx.hasPendingMessages())
1167
1142
  return false;
1168
- if (!options.allowActiveRun && !ctx.isIdle())
1143
+ if (!ctx.isIdle())
1169
1144
  return false;
1170
1145
  if (!this.requestHasCompactableHistory(ctx, request.keep)) {
1171
1146
  this.setCompactionState(ctx, { phase: "idle" });
@@ -1174,7 +1149,6 @@ class CompactionRuntime {
1174
1149
  const operation = ++this.operationGeneration;
1175
1150
  const generation = request.sessionGeneration;
1176
1151
  const sessionFile = request.sessionFile;
1177
- const resumeAfter = request.origin === "turn" && options.resumeAfter === true;
1178
1152
  this.setCompactionState(ctx, {
1179
1153
  phase: "running",
1180
1154
  request,
@@ -1189,7 +1163,6 @@ class CompactionRuntime {
1189
1163
  if (!this.runningOperationIsCurrent(operation, generation, sessionFile))
1190
1164
  return;
1191
1165
  this.setCompactionState(ctx, { phase: "idle" });
1192
- this.resumeAfterSuccessfulCompaction(ctx, resumeAfter);
1193
1166
  },
1194
1167
  onError: (error) => {
1195
1168
  if (!this.runningOperationIsCurrent(operation, generation, sessionFile))
@@ -1197,6 +1170,8 @@ class CompactionRuntime {
1197
1170
  this.setCompactionState(ctx, { phase: "idle" });
1198
1171
  this.syncCompactCounters(ctx);
1199
1172
  this.updateStatus(ctx);
1173
+ if (isCompactionCancellation(error))
1174
+ return;
1200
1175
  const message = error instanceof Error ? error.message : String(error);
1201
1176
  if (ctx.hasUI)
1202
1177
  ctx.ui.notify(`goosedump compaction failed: ${message}`, "error");
@@ -2337,7 +2312,6 @@ function createGoosedumpIntegration(options = {}) {
2337
2312
  enqueueRemember
2338
2313
  });
2339
2314
  function register(pi) {
2340
- compaction.setActivePi(pi);
2341
2315
  if (shouldRegisterTool) {
2342
2316
  registerGooseTools(pi, {
2343
2317
  isAvailable: () => goosedumpAvailable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-goosedump",
3
- "version": "0.12.37",
3
+ "version": "0.12.38",
4
4
  "description": "Pi extension for goosedump session search, durable memory, session management, and compaction",
5
5
  "keywords": [
6
6
  "compaction",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@earendil-works/pi-tui": "^0.82.1",
41
- "@jarkkojs/goosedump": "^0.12.37",
41
+ "@jarkkojs/goosedump": "^0.12.38",
42
42
  "@sinclair/typebox": "^0.34.49"
43
43
  },
44
44
  "devDependencies": {