pi-openai-toolkit 0.14.2 → 0.14.4
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 +239 -246
- package/README.zh.md +243 -246
- package/docs/internals.md +73 -0
- package/extensions/auto-mode.ts +1 -1
- package/extensions/codex-astra.ts +1 -1
- package/extensions/compaction.ts +1 -1
- package/extensions/image-generation.ts +1 -1
- package/extensions/web-search.ts +1 -1
- package/package.json +2 -1
- package/src/config.ts +10 -0
- package/src/context-management/codex-provider.ts +12 -14
- package/src/context-management/history-notes.ts +8 -2
- package/src/context-management/tools.ts +5 -3
- package/src/context-management/types.ts +2 -1
- package/src/context-management/window-manager.ts +479 -421
- package/src/extension-runtime.ts +9 -5
- package/src/types.ts +7 -0
- package/src/web-search/prompt.ts +1 -1
package/src/extension-runtime.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isNativeCodexModel,
|
|
15
15
|
} from "./context-management/codex-provider";
|
|
16
16
|
import { routeContextNamespaceToolMessage } from "./context-management/namespace-tools";
|
|
17
|
+
import { loadHistoryNotesThreadHint } from "./context-management/history-notes";
|
|
17
18
|
import { CodexContextWindowManager } from "./context-management/window-manager";
|
|
18
19
|
import { registerContextManagementTools } from "./context-management/tools";
|
|
19
20
|
import { writeDebugArtifact, writeReplayFailureArtifact } from "./debug";
|
|
@@ -109,7 +110,7 @@ async function isRemoteContextActive(
|
|
|
109
110
|
model: ExtensionContext["model"] = ctx.model,
|
|
110
111
|
): Promise<boolean> {
|
|
111
112
|
if (!config.enabled || config.contextManagement !== "remote") return false;
|
|
112
|
-
const resolution = await resolveCodexContextProvider(ctx, model);
|
|
113
|
+
const resolution = await resolveCodexContextProvider(ctx, model, config.gatewayContextModels);
|
|
113
114
|
return resolution.ok;
|
|
114
115
|
}
|
|
115
116
|
|
|
@@ -118,7 +119,7 @@ function isCodexContextModel(
|
|
|
118
119
|
config: CompactionConfig,
|
|
119
120
|
): boolean {
|
|
120
121
|
return config.contextManagement === "remote"
|
|
121
|
-
&& (isNativeCodexModel(model) || isCodexGatewayModel(model));
|
|
122
|
+
&& (isNativeCodexModel(model) || isCodexGatewayModel(model, config.gatewayContextModels));
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
function notifyRemoteContextFailure(ctx: ExtensionContext, reason: string): void {
|
|
@@ -759,7 +760,9 @@ export default function registerCompactionExtension(
|
|
|
759
760
|
overrides: Partial<CompactionDependencies> = {},
|
|
760
761
|
) {
|
|
761
762
|
const loadConfig = overrides.loadConfig ?? loadToolkitConfig;
|
|
762
|
-
const contextWindows = overrides.contextWindows ?? new CodexContextWindowManager()
|
|
763
|
+
const contextWindows = overrides.contextWindows ?? new CodexContextWindowManager((ctx, signal) =>
|
|
764
|
+
loadHistoryNotesThreadHint(ctx, signal, loadConfig().config.compaction.gatewayContextModels)
|
|
765
|
+
);
|
|
763
766
|
const dependencies: CompactionDependencies = {
|
|
764
767
|
loadConfig,
|
|
765
768
|
remoteCompact: executeRemoteV2Compaction,
|
|
@@ -775,6 +778,7 @@ export default function registerCompactionExtension(
|
|
|
775
778
|
const config = dependencies.loadConfig().config.compaction;
|
|
776
779
|
return tools.isRegistered && await isRemoteContextActive(ctx, config);
|
|
777
780
|
},
|
|
781
|
+
() => dependencies.loadConfig().config.compaction.gatewayContextModels,
|
|
778
782
|
);
|
|
779
783
|
const remoteContextActive: RemoteContextActive = async (ctx, config, model = ctx.model) =>
|
|
780
784
|
tools.isRegistered && await isRemoteContextActive(ctx, config, model);
|
|
@@ -807,7 +811,7 @@ export default function registerCompactionExtension(
|
|
|
807
811
|
activationReason = "tool-name-conflict";
|
|
808
812
|
notifyRemoteContextFailure(ctx, activationReason);
|
|
809
813
|
} else {
|
|
810
|
-
const remoteResolution = await resolveCodexContextProvider(ctx, ctx.model);
|
|
814
|
+
const remoteResolution = await resolveCodexContextProvider(ctx, ctx.model, config.gatewayContextModels);
|
|
811
815
|
activationReason = remoteResolution.ok ? "codex-context-unavailable" : remoteResolution.reason;
|
|
812
816
|
notifyRemoteContextFailure(ctx, activationReason);
|
|
813
817
|
}
|
|
@@ -874,7 +878,7 @@ export default function registerCompactionExtension(
|
|
|
874
878
|
const config = dependencies.loadConfig().config.compaction;
|
|
875
879
|
if (!isCodexContextModel(ctx.model, config)) return;
|
|
876
880
|
if (!(await remoteContextActive(ctx, config))) return;
|
|
877
|
-
const provider = await resolveCodexContextProvider(ctx, ctx.model);
|
|
881
|
+
const provider = await resolveCodexContextProvider(ctx, ctx.model, config.gatewayContextModels);
|
|
878
882
|
if (provider.ok && provider.provider.kind === "codex-gateway") {
|
|
879
883
|
const sessionId = getSessionId(ctx);
|
|
880
884
|
const gatewayHeaders = codexContextProviderHeaders(provider.provider, {
|
package/src/types.ts
CHANGED
|
@@ -80,6 +80,12 @@ export type CompactionConfig = {
|
|
|
80
80
|
* Subset of RESPONSES_COMPACT_CAPABLE_APIS that should use remote compaction.
|
|
81
81
|
*/
|
|
82
82
|
responsesApis: string[];
|
|
83
|
+
/**
|
|
84
|
+
* Exact "provider/model" keys allowed to use Codex Remote Context on the
|
|
85
|
+
* `openai-responses` gateway wire. The native `openai-codex` route ignores
|
|
86
|
+
* this list; gateway coverage is opt-in per model.
|
|
87
|
+
*/
|
|
88
|
+
gatewayContextModels: string[];
|
|
83
89
|
/**
|
|
84
90
|
* Percentage of the context window that, when remaining tokens drop below it,
|
|
85
91
|
* triggers a checkpoint/new_context reminder (0-100; 0 disables reminders).
|
|
@@ -506,6 +512,7 @@ export const DEFAULT_COMPACTION_CONFIG: CompactionConfig = {
|
|
|
506
512
|
remoteCompactModel: undefined,
|
|
507
513
|
nativeFallback: { ...DEFAULT_NATIVE_FALLBACK_CONFIG },
|
|
508
514
|
responsesApis: [...RESPONSES_COMPACT_CAPABLE_APIS],
|
|
515
|
+
gatewayContextModels: [],
|
|
509
516
|
contextReminderThresholdPercent: 5,
|
|
510
517
|
notifyOnLoad: false,
|
|
511
518
|
debug: false,
|
package/src/web-search/prompt.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { isWebSearchEnabledForModel, WEB_SEARCH_PROMPT_MARKER, type WebSearchMod
|
|
|
4
4
|
export const WEB_SEARCH_PROMPT_SECTION = `${WEB_SEARCH_PROMPT_MARKER}
|
|
5
5
|
## Web Search
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The hosted \`web_search\` tool is part of your tool list for this model. The API executes it server-side: it is a real callable tool even though no client-side function schema or description accompanies it. Call it whenever current or online information matters instead of guessing, cite the returned sources in the answer, and never claim that web search or internet access is unavailable while this section is present.`;
|
|
8
8
|
|
|
9
9
|
export function appendWebSearchPrompt(args: {
|
|
10
10
|
model: WebSearchModel | undefined;
|