pi-goosedump 0.12.39 → 0.12.40
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.
- package/README.md +2 -2
- package/dist/index.ts +40 -5
- 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,
|
|
95
|
-
|
|
94
|
+
- If the turn limit expires during a tool loop, Pi saves the current batch,
|
|
95
|
+
compacts at that turn boundary, and resumes automatically.
|
|
96
96
|
- Goosedump failures fall back to Pi's compactor.
|
|
97
97
|
|
|
98
98
|
## License
|
package/dist/index.ts
CHANGED
|
@@ -796,12 +796,16 @@ class CompactionRuntime {
|
|
|
796
796
|
operationGeneration = 0;
|
|
797
797
|
activeSessionFile = null;
|
|
798
798
|
sessionActive = false;
|
|
799
|
+
activePi = null;
|
|
799
800
|
constructor(deps) {
|
|
800
801
|
this.overrideDefaultCompaction = deps.overrideDefaultCompaction;
|
|
801
802
|
this.nativeExecutablePath = deps.nativeExecutablePath;
|
|
802
803
|
this.isAvailable = deps.isAvailable;
|
|
803
804
|
this.enqueueRemember = deps.enqueueRemember;
|
|
804
805
|
}
|
|
806
|
+
setActivePi(pi) {
|
|
807
|
+
this.activePi = pi;
|
|
808
|
+
}
|
|
805
809
|
requestCompaction(ctx, keep) {
|
|
806
810
|
if (this.compactionState.phase !== "idle")
|
|
807
811
|
return "busy";
|
|
@@ -873,8 +877,10 @@ class CompactionRuntime {
|
|
|
873
877
|
this.setCompactionState(ctx, request ? this.requeueRequest(request, this.settlementGeneration + 1) : { phase: "idle" });
|
|
874
878
|
}
|
|
875
879
|
onTurnEnd(event, ctx) {
|
|
876
|
-
if (isCompletedAssistant(event.message))
|
|
877
|
-
|
|
880
|
+
if (!isCompletedAssistant(event.message))
|
|
881
|
+
return;
|
|
882
|
+
this.noteCompletedTurn(ctx);
|
|
883
|
+
this.deferTurnCounterCompaction(ctx, event.toolResults.length > 0);
|
|
878
884
|
}
|
|
879
885
|
onAgentSettled(ctx) {
|
|
880
886
|
if (!this.isAvailable() || !this.overrideDefaultCompaction)
|
|
@@ -1092,6 +1098,32 @@ class CompactionRuntime {
|
|
|
1092
1098
|
this.updateStatus(ctx);
|
|
1093
1099
|
this.queueTurnCompaction(ctx, this.settlementGeneration + 1);
|
|
1094
1100
|
}
|
|
1101
|
+
resumeAfterSuccessfulCompaction(ctx, resume) {
|
|
1102
|
+
if (!resume || !this.activePi || ctx.hasPendingMessages())
|
|
1103
|
+
return;
|
|
1104
|
+
this.activePi.sendMessage({
|
|
1105
|
+
customType: "goosedump-autocompact-resume",
|
|
1106
|
+
content: "The session was compacted to reduce context size. Continue the task you were working on from where you left off.",
|
|
1107
|
+
display: false
|
|
1108
|
+
}, { triggerTurn: true });
|
|
1109
|
+
}
|
|
1110
|
+
deferTurnCounterCompaction(ctx, resumeAfter) {
|
|
1111
|
+
if (!this.isAvailable() || !this.turnCompactionEnabled() || !this.counterTriggered)
|
|
1112
|
+
return;
|
|
1113
|
+
if (!hasCompactableHistory(ctx))
|
|
1114
|
+
return;
|
|
1115
|
+
if (this.compactionState.phase !== "queued" || this.compactionState.request.origin !== "turn") {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const request = this.compactionState.request;
|
|
1119
|
+
setImmediate(() => {
|
|
1120
|
+
if (this.compactionState.phase !== "queued" || this.compactionState.request !== request || !this.contextIsCurrent(ctx)) {
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
const runStillActive = this.settlementGeneration < request.eligibleSettlement;
|
|
1124
|
+
this.startQueuedCompaction(ctx, runStillActive ? { allowActiveRun: true, resumeAfter } : undefined);
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1095
1127
|
requestIsCurrent(request) {
|
|
1096
1128
|
return request.sessionGeneration === this.sessionGeneration && request.sessionFile === this.activeSessionFile;
|
|
1097
1129
|
}
|
|
@@ -1128,7 +1160,7 @@ class CompactionRuntime {
|
|
|
1128
1160
|
}
|
|
1129
1161
|
});
|
|
1130
1162
|
}
|
|
1131
|
-
startQueuedCompaction(ctx) {
|
|
1163
|
+
startQueuedCompaction(ctx, options = {}) {
|
|
1132
1164
|
if (this.compactionState.phase !== "queued")
|
|
1133
1165
|
return false;
|
|
1134
1166
|
const request = this.compactionState.request;
|
|
@@ -1138,9 +1170,9 @@ class CompactionRuntime {
|
|
|
1138
1170
|
this.setCompactionState(ctx, { phase: "idle" });
|
|
1139
1171
|
return false;
|
|
1140
1172
|
}
|
|
1141
|
-
if (ctx.hasPendingMessages())
|
|
1173
|
+
if (request.origin !== "turn" && ctx.hasPendingMessages())
|
|
1142
1174
|
return false;
|
|
1143
|
-
if (!ctx.isIdle())
|
|
1175
|
+
if (!options.allowActiveRun && !ctx.isIdle())
|
|
1144
1176
|
return false;
|
|
1145
1177
|
if (!this.requestHasCompactableHistory(ctx, request.keep)) {
|
|
1146
1178
|
this.setCompactionState(ctx, { phase: "idle" });
|
|
@@ -1149,6 +1181,7 @@ class CompactionRuntime {
|
|
|
1149
1181
|
const operation = ++this.operationGeneration;
|
|
1150
1182
|
const generation = request.sessionGeneration;
|
|
1151
1183
|
const sessionFile = request.sessionFile;
|
|
1184
|
+
const resumeAfter = request.origin === "turn" && options.resumeAfter === true;
|
|
1152
1185
|
this.setCompactionState(ctx, {
|
|
1153
1186
|
phase: "running",
|
|
1154
1187
|
request,
|
|
@@ -1163,6 +1196,7 @@ class CompactionRuntime {
|
|
|
1163
1196
|
if (!this.runningOperationIsCurrent(operation, generation, sessionFile))
|
|
1164
1197
|
return;
|
|
1165
1198
|
this.setCompactionState(ctx, { phase: "idle" });
|
|
1199
|
+
this.resumeAfterSuccessfulCompaction(ctx, resumeAfter);
|
|
1166
1200
|
},
|
|
1167
1201
|
onError: (error) => {
|
|
1168
1202
|
if (!this.runningOperationIsCurrent(operation, generation, sessionFile))
|
|
@@ -2312,6 +2346,7 @@ function createGoosedumpIntegration(options = {}) {
|
|
|
2312
2346
|
enqueueRemember
|
|
2313
2347
|
});
|
|
2314
2348
|
function register(pi) {
|
|
2349
|
+
compaction.setActivePi(pi);
|
|
2315
2350
|
if (shouldRegisterTool) {
|
|
2316
2351
|
registerGooseTools(pi, {
|
|
2317
2352
|
isAvailable: () => goosedumpAvailable,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-goosedump",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.40",
|
|
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.
|
|
41
|
+
"@jarkkojs/goosedump": "^0.12.40",
|
|
42
42
|
"@sinclair/typebox": "^0.34.49"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|