pi-openai-toolkit 0.20.7 → 0.21.0
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/LICENSE +21 -21
- package/NOTICE +83 -83
- package/README.md +8 -26
- package/README.zh.md +8 -26
- package/config.schema.json +278 -366
- package/docs/configuration.md +294 -310
- package/docs/internals.md +166 -175
- package/package.json +3 -13
- package/src/compact-client.ts +412 -389
- package/src/compaction-errors.ts +96 -0
- package/src/compaction-projection.ts +35 -35
- package/src/config/legacy.ts +519 -717
- package/src/config/migration.ts +103 -100
- package/src/config/notifications.ts +36 -28
- package/src/config/policy.ts +10 -18
- package/src/config/v2.ts +1167 -1380
- package/src/config.ts +310 -319
- package/src/context-management/codex-provider.ts +270 -270
- package/src/context-management/history-notes.ts +357 -357
- package/src/context-management/manual-compact.ts +0 -11
- package/src/context-management/tools.ts +371 -371
- package/src/context-management/types.ts +168 -168
- package/src/context-management/window-manager.ts +801 -801
- package/src/debug.ts +238 -237
- package/src/deferred-tool-carryover.ts +282 -282
- package/src/details-store.ts +151 -151
- package/src/extension-runtime.ts +1662 -1623
- package/src/image-generation/extension.ts +189 -189
- package/src/image-generation/protocol.ts +579 -579
- package/src/image-generation/types.ts +300 -300
- package/src/native-fallback.ts +4 -132
- package/src/payload-rewrite.ts +515 -518
- package/src/pi-context-hook.ts +117 -117
- package/src/remote-v2-client.ts +811 -814
- package/src/request-context-cache.ts +155 -155
- package/src/responses-headers.ts +180 -180
- package/src/runtime.ts +865 -832
- package/src/serializer.ts +882 -882
- package/src/supported-environment.ts +27 -27
- package/src/types.ts +565 -648
- package/src/web-search/alpha-client.ts +876 -876
- package/src/web-search/extension.ts +530 -530
- package/src/web-search/payload.ts +299 -299
- package/src/web-search/prompt.ts +60 -60
- package/src/web-search/types.ts +166 -166
- package/tsconfig.check.json +50 -54
- package/src/auto-mode/classifier.ts +0 -161
- package/src/auto-mode/extension.ts +0 -691
- package/src/auto-mode/model-selection-guard.ts +0 -52
- package/src/auto-mode/policy.ts +0 -146
- package/src/auto-mode/prompt.ts +0 -279
- package/src/auto-mode/reviewer.ts +0 -325
- package/src/auto-mode/tool-review-tui.ts +0 -211
- package/src/auto-mode/transcript.ts +0 -135
- package/src/auto-mode/types.ts +0 -137
|
@@ -2,8 +2,6 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
3
3
|
import { buildSessionContext, estimateTokens, type ExtensionAPI, type ExtensionContext, type SessionBeforeCompactEvent, type SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { resolveToolkitConfig, type ResolvedToolkitConfig } from "../config";
|
|
5
|
-
import { isAutoModeEligible } from "../auto-mode/policy";
|
|
6
|
-
import { protectAutoModeSelection } from "../auto-mode/model-selection-guard";
|
|
7
5
|
import { parseModelSpec } from "../runtime";
|
|
8
6
|
import { THINKING_LEVELS } from "../types";
|
|
9
7
|
import { resolveCodexContextProvider } from "./codex-provider";
|
|
@@ -88,7 +86,6 @@ export class ManagedManualCompact implements ContextRolloverHandoff {
|
|
|
88
86
|
private sourcePolicy: ResolvedToolkitConfig | undefined;
|
|
89
87
|
private instructions = "";
|
|
90
88
|
private attemptSignal: AbortSignal | undefined;
|
|
91
|
-
private releaseApproval: (() => void) | undefined;
|
|
92
89
|
private selecting: string | undefined;
|
|
93
90
|
private selectionPromise: Promise<boolean> | undefined;
|
|
94
91
|
private expectedThinking: ThinkingLevel | undefined;
|
|
@@ -123,8 +120,6 @@ export class ManagedManualCompact implements ContextRolloverHandoff {
|
|
|
123
120
|
private clearActivity(): void {
|
|
124
121
|
clearTimeout(this.deliveryTimer);
|
|
125
122
|
this.deliveryTimer = undefined;
|
|
126
|
-
this.releaseApproval?.();
|
|
127
|
-
this.releaseApproval = undefined;
|
|
128
123
|
this.sourcePolicy = undefined;
|
|
129
124
|
}
|
|
130
125
|
private belongs(ctx: ExtensionContext, record = this.record): boolean {
|
|
@@ -193,12 +188,6 @@ export class ManagedManualCompact implements ContextRolloverHandoff {
|
|
|
193
188
|
if (!originalProvider.ok || !targetProvider.ok || !sameContextScope(originalProvider.provider, targetProvider.provider)) {
|
|
194
189
|
throw new Error("checkpoint model must authenticate to the same context backend/account");
|
|
195
190
|
}
|
|
196
|
-
const protection = protectAutoModeSelection(this.pi, {
|
|
197
|
-
sessionId: this.record!.sessionId, operationId: this.record!.operationId, target,
|
|
198
|
-
eligible: !targetPolicy.invalidFeatures.includes("autoMode") && isAutoModeEligible(target, targetPolicy.config.autoMode),
|
|
199
|
-
});
|
|
200
|
-
this.releaseApproval = protection.release;
|
|
201
|
-
if (!protection.allowed) throw new Error("checkpoint model would disable the engaged approval gate; allowlist it or choose another model");
|
|
202
191
|
this.notify(ctx, `checkpoint handoff requested (${this.record!.originalModel} → ${targetKey}); native compaction is intentionally cancelled.`);
|
|
203
192
|
} catch (error) {
|
|
204
193
|
if (!this.current(ctx, generation)) return;
|