@fleetagent/pi-coding-agent 0.0.7 → 0.0.8
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/CHANGELOG.md +19 -1
- package/README.md +3 -3
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +44 -10
- package/dist/core/agent-session.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +4 -3
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +10 -4
- package/dist/utils/version-check.js.map +1 -1
- package/docs/settings.md +1 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -168,6 +168,7 @@ export class AgentSession {
|
|
|
168
168
|
// (session persistence, extensions, auto-compaction, retry logic)
|
|
169
169
|
this._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);
|
|
170
170
|
this._installAgentToolHooks();
|
|
171
|
+
this._installAgentTurnPreparation();
|
|
171
172
|
this._buildRuntime({
|
|
172
173
|
activeToolNames: this._initialActiveToolNames,
|
|
173
174
|
includeAllExtensionTools: true,
|
|
@@ -256,6 +257,27 @@ export class AgentSession {
|
|
|
256
257
|
};
|
|
257
258
|
};
|
|
258
259
|
}
|
|
260
|
+
_installAgentTurnPreparation() {
|
|
261
|
+
const previousPrepareNextTurn = this.agent.prepareNextTurn;
|
|
262
|
+
this.agent.prepareNextTurn = async (signal) => {
|
|
263
|
+
const previousUpdate = await previousPrepareNextTurn?.(signal);
|
|
264
|
+
const compacted = await this._drainExtensionCompactionQueue("between-turns");
|
|
265
|
+
if (!compacted) {
|
|
266
|
+
return previousUpdate;
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
...previousUpdate,
|
|
270
|
+
context: this._buildCurrentAgentContext(previousUpdate?.context),
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
_buildCurrentAgentContext(previousContext) {
|
|
275
|
+
return {
|
|
276
|
+
systemPrompt: previousContext?.systemPrompt ?? this.agent.state.systemPrompt,
|
|
277
|
+
messages: this.agent.state.messages.slice(),
|
|
278
|
+
tools: previousContext?.tools ?? this.agent.state.tools.slice(),
|
|
279
|
+
};
|
|
280
|
+
}
|
|
259
281
|
// =========================================================================
|
|
260
282
|
// Event Subscription
|
|
261
283
|
// =========================================================================
|
|
@@ -1529,30 +1551,33 @@ export class AgentSession {
|
|
|
1529
1551
|
void this._drainExtensionCompactionQueue();
|
|
1530
1552
|
}, 0);
|
|
1531
1553
|
}
|
|
1532
|
-
async _drainExtensionCompactionQueue() {
|
|
1554
|
+
async _drainExtensionCompactionQueue(mode = "idle") {
|
|
1533
1555
|
if (this._extensionCompactionRunning) {
|
|
1534
|
-
return;
|
|
1556
|
+
return false;
|
|
1535
1557
|
}
|
|
1536
1558
|
this._extensionCompactionRunning = true;
|
|
1559
|
+
let compacted = false;
|
|
1537
1560
|
try {
|
|
1538
|
-
while (!this.isStreaming) {
|
|
1561
|
+
while (mode === "between-turns" || !this.isStreaming) {
|
|
1539
1562
|
const options = this._extensionCompactionQueue.shift();
|
|
1540
1563
|
if (!options) {
|
|
1541
1564
|
break;
|
|
1542
1565
|
}
|
|
1543
|
-
|
|
1566
|
+
compacted = true;
|
|
1567
|
+
await this._runRequestedExtensionCompaction(options, mode === "idle");
|
|
1544
1568
|
}
|
|
1545
1569
|
}
|
|
1546
1570
|
finally {
|
|
1547
1571
|
this._extensionCompactionRunning = false;
|
|
1548
1572
|
}
|
|
1549
|
-
if (!this.isStreaming) {
|
|
1573
|
+
if (mode === "idle" && !this.isStreaming) {
|
|
1550
1574
|
this._scheduleExtensionCompactions();
|
|
1551
1575
|
}
|
|
1576
|
+
return compacted;
|
|
1552
1577
|
}
|
|
1553
|
-
async _runRequestedExtensionCompaction(options) {
|
|
1578
|
+
async _runRequestedExtensionCompaction(options, abortActiveRun) {
|
|
1554
1579
|
try {
|
|
1555
|
-
const result = await this.
|
|
1580
|
+
const result = await this._compactSession(options.customInstructions, { abortActiveRun });
|
|
1556
1581
|
options.onComplete?.(result);
|
|
1557
1582
|
}
|
|
1558
1583
|
catch (error) {
|
|
@@ -1566,8 +1591,15 @@ export class AgentSession {
|
|
|
1566
1591
|
* @param customInstructions Optional instructions for the compaction summary
|
|
1567
1592
|
*/
|
|
1568
1593
|
async compact(customInstructions) {
|
|
1569
|
-
this.
|
|
1570
|
-
|
|
1594
|
+
return this._compactSession(customInstructions, { abortActiveRun: true });
|
|
1595
|
+
}
|
|
1596
|
+
async _compactSession(customInstructions, options) {
|
|
1597
|
+
let disconnected = false;
|
|
1598
|
+
if (options.abortActiveRun) {
|
|
1599
|
+
this._disconnectFromAgent();
|
|
1600
|
+
disconnected = true;
|
|
1601
|
+
await this.abort();
|
|
1602
|
+
}
|
|
1571
1603
|
this._compactionAbortController = new AbortController();
|
|
1572
1604
|
this._emit({ type: "compaction_start", reason: "manual" });
|
|
1573
1605
|
try {
|
|
@@ -1669,7 +1701,9 @@ export class AgentSession {
|
|
|
1669
1701
|
}
|
|
1670
1702
|
finally {
|
|
1671
1703
|
this._compactionAbortController = undefined;
|
|
1672
|
-
|
|
1704
|
+
if (disconnected) {
|
|
1705
|
+
this._reconnectToAgent();
|
|
1706
|
+
}
|
|
1673
1707
|
}
|
|
1674
1708
|
}
|
|
1675
1709
|
/**
|