@fleetagent/pi-coding-agent 0.0.6 → 0.0.7
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 +17 -0
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -3
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -2
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +9 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +86 -15
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/export-html/template.js +6 -3
- package/dist/core/extensions/runner.d.ts +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +8 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +4 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +65 -13
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/output-guard.d.ts +1 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +52 -22
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +31 -12
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-agent.d.ts.map +1 -1
- package/dist/core/pi-agent.js +12 -3
- package/dist/core/pi-agent.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts +9 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +134 -11
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/session/jsonl-helpers.d.ts +2 -1
- package/dist/core/session/jsonl-helpers.d.ts.map +1 -1
- package/dist/core/session/jsonl-helpers.js +6 -3
- package/dist/core/session/jsonl-helpers.js.map +1 -1
- package/dist/core/session/local-session-manager.d.ts +1 -0
- package/dist/core/session/local-session-manager.d.ts.map +1 -1
- package/dist/core/session/local-session-manager.js +12 -4
- package/dist/core/session/local-session-manager.js.map +1 -1
- package/dist/core/session/session-manager.d.ts +1 -0
- package/dist/core/session/session-manager.d.ts.map +1 -1
- package/dist/core/session/session-manager.js.map +1 -1
- package/dist/core/session/stores/jsonl-session-store.d.ts +2 -1
- package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/session/stores/jsonl-session-store.js +105 -78
- package/dist/core/session/stores/jsonl-session-store.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +14 -9
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +73 -63
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +45 -76
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +27 -12
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -2
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +3 -3
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +13 -4
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts +1 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +37 -0
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +7 -6
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +24 -32
- package/dist/core/tools/write.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -2
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +118 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +14 -5
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +30 -5
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +10 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +3 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +64 -7
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +15 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +3 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js +14 -8
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +6 -27
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +60 -116
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/docs/custom-provider.md +22 -9
- package/docs/extensions.md +4 -3
- package/docs/models.md +34 -12
- package/docs/packages.md +5 -4
- package/docs/providers.md +13 -5
- package/docs/sdk.md +56 -0
- package/docs/settings.md +3 -1
- package/docs/terminal-setup.md +6 -0
- package/docs/usage.md +2 -2
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +54 -3
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +13 -12
- package/package.json +5 -5
|
@@ -110,6 +110,9 @@ export class AgentSession {
|
|
|
110
110
|
// Compaction state
|
|
111
111
|
_compactionAbortController = undefined;
|
|
112
112
|
_autoCompactionAbortController = undefined;
|
|
113
|
+
_extensionCompactionQueue = [];
|
|
114
|
+
_extensionCompactionTimer = undefined;
|
|
115
|
+
_extensionCompactionRunning = false;
|
|
113
116
|
_overflowRecoveryAttempted = false;
|
|
114
117
|
// Branch summarization state
|
|
115
118
|
_branchSummaryAbortController = undefined;
|
|
@@ -299,6 +302,9 @@ export class AgentSession {
|
|
|
299
302
|
await this._emitExtensionEvent(event);
|
|
300
303
|
// Notify all listeners
|
|
301
304
|
this._emit(event.type === "agent_end" ? { ...event, willRetry: this._willRetryAfterAgentEnd(event) } : event);
|
|
305
|
+
if (event.type === "agent_end") {
|
|
306
|
+
this._scheduleExtensionCompactions();
|
|
307
|
+
}
|
|
302
308
|
// Handle session persistence
|
|
303
309
|
if (event.type === "message_end") {
|
|
304
310
|
// Check if this is a custom message from extensions
|
|
@@ -503,6 +509,21 @@ export class AgentSession {
|
|
|
503
509
|
* Call this when completely done with the session.
|
|
504
510
|
*/
|
|
505
511
|
dispose() {
|
|
512
|
+
try {
|
|
513
|
+
this.abortRetry();
|
|
514
|
+
this.abortCompaction();
|
|
515
|
+
this.abortBranchSummary();
|
|
516
|
+
this.abortBash();
|
|
517
|
+
this.agent.abort();
|
|
518
|
+
}
|
|
519
|
+
catch {
|
|
520
|
+
// Dispose must succeed even if an abort hook throws.
|
|
521
|
+
}
|
|
522
|
+
if (this._extensionCompactionTimer !== undefined) {
|
|
523
|
+
clearTimeout(this._extensionCompactionTimer);
|
|
524
|
+
this._extensionCompactionTimer = undefined;
|
|
525
|
+
}
|
|
526
|
+
this._extensionCompactionQueue = [];
|
|
506
527
|
this._extensionRunner.invalidate("This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().");
|
|
507
528
|
this._disconnectFromAgent();
|
|
508
529
|
this._eventListeners = [];
|
|
@@ -710,7 +731,12 @@ export class AgentSession {
|
|
|
710
731
|
});
|
|
711
732
|
this._retryAttempt = 0;
|
|
712
733
|
}
|
|
713
|
-
|
|
734
|
+
if (await this._checkCompaction(msg)) {
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
// The agent loop drains both queues before emitting agent_end. Any messages
|
|
738
|
+
// here were queued by agent_end extension handlers and need a continuation.
|
|
739
|
+
return this.agent.hasQueuedMessages();
|
|
714
740
|
}
|
|
715
741
|
async getStructuredResponse(options) {
|
|
716
742
|
if (this.isStreaming) {
|
|
@@ -920,7 +946,7 @@ export class AgentSession {
|
|
|
920
946
|
let currentText = text;
|
|
921
947
|
let currentImages = options?.images;
|
|
922
948
|
if (this._extensionRunner.hasHandlers("input")) {
|
|
923
|
-
const inputResult = await this._extensionRunner.emitInput(currentText, currentImages, options?.source ?? "interactive");
|
|
949
|
+
const inputResult = await this._extensionRunner.emitInput(currentText, currentImages, options?.source ?? "interactive", this.isStreaming ? options?.streamingBehavior : undefined);
|
|
924
950
|
if (inputResult.action === "handled") {
|
|
925
951
|
preflightResult?.(true);
|
|
926
952
|
return;
|
|
@@ -1229,8 +1255,8 @@ export class AgentSession {
|
|
|
1229
1255
|
else {
|
|
1230
1256
|
this.agent.state.messages.push(appMessage);
|
|
1231
1257
|
this.session.appendCustomMessageEntry(message.customType, message.content, message.display, message.details);
|
|
1232
|
-
this._emit({ type: "message_start", message: appMessage });
|
|
1233
|
-
this._emit({ type: "message_end", message: appMessage });
|
|
1258
|
+
await this._emit({ type: "message_start", message: appMessage });
|
|
1259
|
+
await this._emit({ type: "message_end", message: appMessage });
|
|
1234
1260
|
}
|
|
1235
1261
|
}
|
|
1236
1262
|
/**
|
|
@@ -1485,6 +1511,55 @@ export class AgentSession {
|
|
|
1485
1511
|
// =========================================================================
|
|
1486
1512
|
// Compaction
|
|
1487
1513
|
// =========================================================================
|
|
1514
|
+
/** Queue extension-triggered compaction outside the currently active agent turn. */
|
|
1515
|
+
_requestExtensionCompaction(options) {
|
|
1516
|
+
this._extensionCompactionQueue.push(options ?? {});
|
|
1517
|
+
if (this.isStreaming) {
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
this._scheduleExtensionCompactions();
|
|
1521
|
+
}
|
|
1522
|
+
_scheduleExtensionCompactions() {
|
|
1523
|
+
const alreadyScheduled = this._extensionCompactionTimer !== undefined;
|
|
1524
|
+
if (this._extensionCompactionRunning || alreadyScheduled || this._extensionCompactionQueue.length === 0) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
this._extensionCompactionTimer = setTimeout(() => {
|
|
1528
|
+
this._extensionCompactionTimer = undefined;
|
|
1529
|
+
void this._drainExtensionCompactionQueue();
|
|
1530
|
+
}, 0);
|
|
1531
|
+
}
|
|
1532
|
+
async _drainExtensionCompactionQueue() {
|
|
1533
|
+
if (this._extensionCompactionRunning) {
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
this._extensionCompactionRunning = true;
|
|
1537
|
+
try {
|
|
1538
|
+
while (!this.isStreaming) {
|
|
1539
|
+
const options = this._extensionCompactionQueue.shift();
|
|
1540
|
+
if (!options) {
|
|
1541
|
+
break;
|
|
1542
|
+
}
|
|
1543
|
+
await this._runRequestedExtensionCompaction(options);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
finally {
|
|
1547
|
+
this._extensionCompactionRunning = false;
|
|
1548
|
+
}
|
|
1549
|
+
if (!this.isStreaming) {
|
|
1550
|
+
this._scheduleExtensionCompactions();
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
async _runRequestedExtensionCompaction(options) {
|
|
1554
|
+
try {
|
|
1555
|
+
const result = await this.compact(options.customInstructions);
|
|
1556
|
+
options.onComplete?.(result);
|
|
1557
|
+
}
|
|
1558
|
+
catch (error) {
|
|
1559
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
1560
|
+
options.onError?.(err);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1488
1563
|
/**
|
|
1489
1564
|
* Manually compact the session context.
|
|
1490
1565
|
* Aborts current agent operation first.
|
|
@@ -2025,16 +2100,7 @@ export class AgentSession {
|
|
|
2025
2100
|
},
|
|
2026
2101
|
getContextUsage: () => this.getContextUsage(),
|
|
2027
2102
|
compact: (options) => {
|
|
2028
|
-
|
|
2029
|
-
try {
|
|
2030
|
-
const result = await this.compact(options?.customInstructions);
|
|
2031
|
-
options?.onComplete?.(result);
|
|
2032
|
-
}
|
|
2033
|
-
catch (error) {
|
|
2034
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
2035
|
-
options?.onError?.(err);
|
|
2036
|
-
}
|
|
2037
|
-
})();
|
|
2103
|
+
this._requestExtensionCompaction(options);
|
|
2038
2104
|
},
|
|
2039
2105
|
getSystemPrompt: () => this.systemPrompt,
|
|
2040
2106
|
}, {
|
|
@@ -2182,6 +2248,9 @@ export class AgentSession {
|
|
|
2182
2248
|
// =========================================================================
|
|
2183
2249
|
// Auto-Retry
|
|
2184
2250
|
// =========================================================================
|
|
2251
|
+
_isNonRetryableProviderLimitError(errorMessage) {
|
|
2252
|
+
return /GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(errorMessage);
|
|
2253
|
+
}
|
|
2185
2254
|
/**
|
|
2186
2255
|
* Check if an error is retryable (overloaded, rate limit, server errors).
|
|
2187
2256
|
* Context overflow errors are NOT retryable (handled by compaction instead).
|
|
@@ -2194,6 +2263,8 @@ export class AgentSession {
|
|
|
2194
2263
|
if (isContextOverflow(message, contextWindow))
|
|
2195
2264
|
return false;
|
|
2196
2265
|
const err = message.errorMessage;
|
|
2266
|
+
if (this._isNonRetryableProviderLimitError(err))
|
|
2267
|
+
return false;
|
|
2197
2268
|
// Match: overloaded_error, provider returned error, rate limit, 429, 500, 502, 503, 504, service unavailable, network/connection errors (including connection lost), WebSocket transport closes/errors, fetch failed, premature stream endings, HTTP/2 closed before response, terminated, retry delay exceeded
|
|
2198
2269
|
return /overloaded|provider.?returned.?error|rate.?limit|too many requests|429|500|502|503|504|service.?unavailable|server.?error|internal.?error|network.?error|connection.?error|connection.?refused|connection.?lost|websocket.?closed|websocket.?error|other side closed|fetch failed|upstream.?connect|reset before headers|socket hang up|ended without|stream ended before message_stop|http2 request did not get a response|timed? out|timeout|terminated|retry delay/i.test(err);
|
|
2199
2270
|
}
|
|
@@ -2361,7 +2432,7 @@ export class AgentSession {
|
|
|
2361
2432
|
*/
|
|
2362
2433
|
setSessionName(name) {
|
|
2363
2434
|
this.session.appendSessionInfo(name);
|
|
2364
|
-
this._emit({ type: "session_info_changed", name: this.session.getSessionName() });
|
|
2435
|
+
void this._emit({ type: "session_info_changed", name: this.session.getSessionName() });
|
|
2365
2436
|
}
|
|
2366
2437
|
// =========================================================================
|
|
2367
2438
|
// Tree Navigation
|