pi-openai-toolkit 0.23.2 → 0.24.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/README.md +4 -15
- package/README.zh.md +4 -15
- package/config.schema.json +5 -19
- package/docs/configuration.md +19 -21
- package/docs/internals.md +34 -120
- package/package.json +3 -16
- package/src/config/legacy.ts +12 -62
- package/src/config/migration.ts +19 -7
- package/src/config/notifications.ts +10 -4
- package/src/config/policy.ts +9 -10
- package/src/config/v2.ts +12 -51
- package/src/config.ts +20 -10
- package/src/extension-runtime.ts +163 -987
- package/src/native-fallback.ts +11 -23
- package/src/responses-headers.ts +1 -1
- package/src/retired-remote-windows.ts +35 -0
- package/src/runtime.ts +12 -2
- package/src/types.ts +4 -28
- package/src/context-management/codex-provider.ts +0 -270
- package/src/context-management/history-notes.ts +0 -357
- package/src/context-management/manual-compact.ts +0 -247
- package/src/context-management/messages.ts +0 -238
- package/src/context-management/namespace-tools.ts +0 -426
- package/src/context-management/responses-tools.ts +0 -238
- package/src/context-management/scoped-compaction.ts +0 -89
- package/src/context-management/tool-contract.ts +0 -62
- package/src/context-management/tools.ts +0 -371
- package/src/context-management/types.ts +0 -168
- package/src/context-management/window-budget.ts +0 -83
- package/src/context-management/window-bulk.ts +0 -155
- package/src/context-management/window-manager.ts +0 -912
- package/src/context-management/window-request.ts +0 -125
package/src/config/legacy.ts
CHANGED
|
@@ -12,8 +12,6 @@ import {
|
|
|
12
12
|
THINKING_LEVELS,
|
|
13
13
|
TOOLKIT_ID,
|
|
14
14
|
type CompactionConfig,
|
|
15
|
-
type ContextManagementMode,
|
|
16
|
-
type LeaveManagedModePolicy,
|
|
17
15
|
type ImageGenerationConfig,
|
|
18
16
|
type RemoteV2ContextSource,
|
|
19
17
|
type LoadedToolkitConfig,
|
|
@@ -22,7 +20,7 @@ import {
|
|
|
22
20
|
type WebSearchConfig,
|
|
23
21
|
type WebSearchRoute,
|
|
24
22
|
} from "../types";
|
|
25
|
-
import { RETIRED_AUTO_MODE_MESSAGE } from "./policy";
|
|
23
|
+
import { RETIRED_AUTO_MODE_MESSAGE, RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE, RETIRED_REMOTE_WINDOWS_MODE_MESSAGE } from "./policy";
|
|
26
24
|
import { MAX_IMAGE_MODEL_ID_CHARS } from "../image-generation/types";
|
|
27
25
|
|
|
28
26
|
export const CONFIG_DIR = path.join(os.homedir(), ".pi", "agent", "extensions", TOOLKIT_ID);
|
|
@@ -85,34 +83,6 @@ function toBoolean(value: unknown, fieldPath: string, warnings: string[]): boole
|
|
|
85
83
|
return undefined;
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
function toLeaveManagedMode(
|
|
89
|
-
value: unknown,
|
|
90
|
-
fieldPath: string,
|
|
91
|
-
warnings: string[],
|
|
92
|
-
): LeaveManagedModePolicy | undefined {
|
|
93
|
-
if (value === undefined) return undefined;
|
|
94
|
-
if (typeof value === "string") {
|
|
95
|
-
const normalized = value.trim();
|
|
96
|
-
if (normalized === "warn" || normalized === "compact") return normalized;
|
|
97
|
-
}
|
|
98
|
-
warnings.push(`Ignoring ${fieldPath}: expected one of warn, compact.`);
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function toContextManagementMode(
|
|
103
|
-
value: unknown,
|
|
104
|
-
fieldPath: string,
|
|
105
|
-
warnings: string[],
|
|
106
|
-
): ContextManagementMode | undefined {
|
|
107
|
-
if (value === undefined) return undefined;
|
|
108
|
-
if (typeof value === "string") {
|
|
109
|
-
const normalized = value.trim();
|
|
110
|
-
if (normalized === "off" || normalized === "remote") return normalized;
|
|
111
|
-
}
|
|
112
|
-
warnings.push(`Ignoring ${fieldPath}: expected one of off, remote.`);
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
86
|
function toRemoteV2ContextSource(
|
|
117
87
|
value: unknown,
|
|
118
88
|
fieldPath: string,
|
|
@@ -146,21 +116,6 @@ function toThinkingLevel(value: unknown, fieldPath: string, warnings: string[]):
|
|
|
146
116
|
return undefined;
|
|
147
117
|
}
|
|
148
118
|
|
|
149
|
-
function toBoundedInteger(
|
|
150
|
-
value: unknown,
|
|
151
|
-
fieldPath: string,
|
|
152
|
-
warnings: string[],
|
|
153
|
-
min: number,
|
|
154
|
-
max: number,
|
|
155
|
-
): number | undefined {
|
|
156
|
-
if (value === undefined) return undefined;
|
|
157
|
-
if (typeof value === "number" && Number.isInteger(value) && Number.isFinite(value) && value >= min && value <= max) {
|
|
158
|
-
return value;
|
|
159
|
-
}
|
|
160
|
-
warnings.push(`Ignoring ${fieldPath}: expected an integer between ${min} and ${max}.`);
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
119
|
function toSupportedApis(
|
|
165
120
|
value: unknown,
|
|
166
121
|
fieldPath: string,
|
|
@@ -309,12 +264,17 @@ function applyCompactionConfig(
|
|
|
309
264
|
warnUnknownFields(raw, COMPACTION_FIELDS, "compaction", warnings);
|
|
310
265
|
|
|
311
266
|
resolved.enabled = toBoolean(raw.enabled, "compaction.enabled", warnings) ?? resolved.enabled;
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
267
|
+
for (const key of ["leaveManagedMode", "contextReminderThresholdPercent"]) {
|
|
268
|
+
if (Object.hasOwn(raw, key)) warnings.push(`Ignoring compaction.${key}: ${RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE}`);
|
|
269
|
+
}
|
|
270
|
+
if (Object.hasOwn(raw, "contextManagement")) {
|
|
271
|
+
const mode = typeof raw.contextManagement === "string" ? raw.contextManagement.trim() : undefined;
|
|
272
|
+
warnings.push(mode === "remote"
|
|
273
|
+
? `Ignoring compaction.contextManagement: ${RETIRED_REMOTE_WINDOWS_MODE_MESSAGE}`
|
|
274
|
+
: mode === "off"
|
|
275
|
+
? `Ignoring compaction.contextManagement: ${RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE}`
|
|
276
|
+
: "Ignoring compaction.contextManagement: expected off; remote has been removed.");
|
|
277
|
+
}
|
|
318
278
|
resolved.allowCompactionContinuityBreak =
|
|
319
279
|
toBoolean(
|
|
320
280
|
raw.allowCompactionContinuityBreak,
|
|
@@ -323,16 +283,6 @@ function applyCompactionConfig(
|
|
|
323
283
|
) ?? resolved.allowCompactionContinuityBreak;
|
|
324
284
|
resolved.notifyOnLoad =
|
|
325
285
|
toBoolean(raw.notifyOnLoad, "compaction.notifyOnLoad", warnings) ?? resolved.notifyOnLoad;
|
|
326
|
-
const reminderPercent = toBoundedInteger(
|
|
327
|
-
raw.contextReminderThresholdPercent,
|
|
328
|
-
"compaction.contextReminderThresholdPercent",
|
|
329
|
-
warnings,
|
|
330
|
-
0,
|
|
331
|
-
100,
|
|
332
|
-
);
|
|
333
|
-
if (reminderPercent !== undefined) {
|
|
334
|
-
resolved.contextReminderThresholdPercent = reminderPercent;
|
|
335
|
-
}
|
|
336
286
|
resolved.debug = toBoolean(raw.debug, "compaction.debug", warnings) ?? resolved.debug;
|
|
337
287
|
resolved.logProviderPayloads =
|
|
338
288
|
toBoolean(raw.logProviderPayloads, "compaction.logProviderPayloads", warnings) ??
|
package/src/config/migration.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { resolveToolkitConfig } from "../config";
|
|
2
2
|
import type { LoadedToolkitConfig } from "../types";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
RETIRED_AUTO_MODE_ISSUE, RETIRED_AUTO_MODE_MESSAGE,
|
|
5
|
+
RETIRED_REMOTE_WINDOWS_ISSUE, RETIRED_REMOTE_WINDOWS_MODE_ISSUE,
|
|
6
|
+
RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE, RETIRED_REMOTE_WINDOWS_MODE_MESSAGE,
|
|
7
|
+
type ConfigOrigin,
|
|
8
|
+
} from "./policy";
|
|
4
9
|
import { resolveV2Config } from "./v2";
|
|
5
10
|
|
|
6
11
|
export type MigrationPreview = {
|
|
@@ -22,9 +27,13 @@ function modelRef(key: string): { provider: string; id: string; api: string } {
|
|
|
22
27
|
/** Read-only analysis: never edits a source file or claims a lossy candidate is equivalent. */
|
|
23
28
|
export function previewToolkitMigration(loaded: LoadedToolkitConfig): MigrationPreview {
|
|
24
29
|
if (loaded.document?.format === "v2") {
|
|
25
|
-
const retired = resolveToolkitConfig(loaded).issues.filter((issue) =>
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
const retired = resolveToolkitConfig(loaded).issues.filter((issue) =>
|
|
31
|
+
[RETIRED_AUTO_MODE_ISSUE, RETIRED_REMOTE_WINDOWS_ISSUE, RETIRED_REMOTE_WINDOWS_MODE_ISSUE].some((code) => code === issue.code));
|
|
32
|
+
const removedMode = retired.some((issue) => issue.code === RETIRED_REMOTE_WINDOWS_MODE_ISSUE);
|
|
33
|
+
return { status: removedMode ? "needs-review" : "already-v2", reasons: ["The document already uses schemaVersion 2.",
|
|
34
|
+
...(retired.some((issue) => issue.code === RETIRED_AUTO_MODE_ISSUE) ? [RETIRED_AUTO_MODE_MESSAGE] : []),
|
|
35
|
+
...(retired.some((issue) => issue.code === RETIRED_REMOTE_WINDOWS_ISSUE) ? [RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE] : []),
|
|
36
|
+
...(removedMode ? [RETIRED_REMOTE_WINDOWS_MODE_MESSAGE] : [])], unmappedPaths: retired.map((issue) => issue.path) };
|
|
28
37
|
}
|
|
29
38
|
if (loaded.document?.format === "invalid" || loaded.document?.format === "missing") {
|
|
30
39
|
return { status: "unavailable", reasons: ["A readable legacy document is required; no candidate was produced."], unmappedPaths: [] };
|
|
@@ -83,11 +92,14 @@ export function previewToolkitMigration(loaded: LoadedToolkitConfig): MigrationP
|
|
|
83
92
|
legacy.webSearch.models.some((key) => Object.hasOwn(legacy.webSearch.routes ?? {}, key)))) {
|
|
84
93
|
unmappedPaths.add("webSearch.models");
|
|
85
94
|
}
|
|
86
|
-
if (
|
|
87
|
-
reasons.push(
|
|
95
|
+
if (baseline.issues.some((issue) => issue.code === RETIRED_REMOTE_WINDOWS_MODE_ISSUE)) {
|
|
96
|
+
reasons.push(`${RETIRED_REMOTE_WINDOWS_MODE_MESSAGE} The preview uses Pi ownership only as a safe review placeholder; it is not behavior-equivalent. Choose a supported mode explicitly before any manual apply.`);
|
|
88
97
|
unmappedPaths.add("compaction.contextManagement");
|
|
89
98
|
}
|
|
90
|
-
|
|
99
|
+
if (baseline.issues.some((issue) => issue.code === RETIRED_REMOTE_WINDOWS_ISSUE)) {
|
|
100
|
+
reasons.push(`${RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE} No retired ancillary settings were migrated; review their removal.`);
|
|
101
|
+
}
|
|
102
|
+
// Gateway affinity is shared across retained compaction and image features.
|
|
91
103
|
if (legacy.compaction.gatewayContextModels.length) {
|
|
92
104
|
reasons.push("Gateway compatibility is now shared across features; review synthetic compaction/image affinity before using this candidate.");
|
|
93
105
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { ResolvedToolkitConfig } from "../config";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
RETIRED_AUTO_MODE_ISSUE, RETIRED_AUTO_MODE_MESSAGE,
|
|
5
|
+
RETIRED_REMOTE_WINDOWS_ISSUE, RETIRED_REMOTE_WINDOWS_MODE_ISSUE,
|
|
6
|
+
RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE, RETIRED_REMOTE_WINDOWS_MODE_MESSAGE,
|
|
7
|
+
type ConfigIssue,
|
|
8
|
+
} from "./policy";
|
|
4
9
|
import { redactValue } from "../debug";
|
|
5
10
|
|
|
6
11
|
const lastNotice = new WeakMap<object, string>();
|
|
7
12
|
|
|
8
13
|
/** Controlled human text for a known code; never built from user-supplied configuration values. */
|
|
9
14
|
function issueExplanation(issue: ConfigIssue): string {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
if (issue.code === RETIRED_AUTO_MODE_ISSUE) return RETIRED_AUTO_MODE_MESSAGE;
|
|
16
|
+
if (issue.code === RETIRED_REMOTE_WINDOWS_ISSUE) return RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE;
|
|
17
|
+
if (issue.code === RETIRED_REMOTE_WINDOWS_MODE_ISSUE) return RETIRED_REMOTE_WINDOWS_MODE_MESSAGE;
|
|
18
|
+
return issue.code;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export function formatConfigIssues(issues: readonly ConfigIssue[], limit = 12): string {
|
package/src/config/policy.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_COMPACTION_CONFIG,
|
|
3
3
|
DEFAULT_IMAGE_GENERATION_MODEL,
|
|
4
|
-
type LeaveManagedModePolicy,
|
|
5
4
|
type NativeFallbackConfig,
|
|
6
5
|
type RemoteV2ContextSource,
|
|
7
6
|
} from "../types";
|
|
@@ -18,7 +17,7 @@ export type DiagnosticsConfig = {
|
|
|
18
17
|
artifactRoot: string;
|
|
19
18
|
};
|
|
20
19
|
export type ContextPolicy = {
|
|
21
|
-
mode: "pi" | "remote-compaction"
|
|
20
|
+
mode: "pi" | "remote-compaction";
|
|
22
21
|
remoteCompaction: {
|
|
23
22
|
model: string | null;
|
|
24
23
|
inputSource: RemoteV2ContextSource;
|
|
@@ -26,10 +25,6 @@ export type ContextPolicy = {
|
|
|
26
25
|
apis: string[];
|
|
27
26
|
};
|
|
28
27
|
nativeFallback: Omit<NativeFallbackConfig, "model"> & { model: string | null };
|
|
29
|
-
remoteWindows: {
|
|
30
|
-
leaveManagedMode: LeaveManagedModePolicy;
|
|
31
|
-
reminderThresholdPercent: number;
|
|
32
|
-
};
|
|
33
28
|
};
|
|
34
29
|
export type EffectiveToolkitPolicy = {
|
|
35
30
|
context: ContextPolicy;
|
|
@@ -61,6 +56,14 @@ export const RETIRED_AUTO_MODE_ISSUE = "retired.autoMode" as const;
|
|
|
61
56
|
/** Controlled explanation of the retirement; never contains user-supplied values. */
|
|
62
57
|
export const RETIRED_AUTO_MODE_MESSAGE =
|
|
63
58
|
"Auto Mode has been removed; these settings are ignored and tool calls are no longer reviewed by it.";
|
|
59
|
+
/** Opaque ancillary settings are warning-only; explicitly selected retired modes block context. */
|
|
60
|
+
export const RETIRED_REMOTE_WINDOWS_ISSUE = "retired.remoteWindows" as const;
|
|
61
|
+
export const RETIRED_REMOTE_WINDOWS_MODE_ISSUE = "retired.remoteWindows.mode" as const;
|
|
62
|
+
export const RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE =
|
|
63
|
+
"Remote Windows has been removed; these settings are ignored. No window behavior or automatic migration is available.";
|
|
64
|
+
export const RETIRED_REMOTE_WINDOWS_MODE_MESSAGE =
|
|
65
|
+
"Remote Windows has been removed. Context operations are blocked until you explicitly select pi or remote-compaction. No replacement mode was activated.";
|
|
66
|
+
|
|
64
67
|
export type ResolvedToolkitPolicy = {
|
|
65
68
|
policy: EffectiveToolkitPolicy;
|
|
66
69
|
origins: Record<string, ConfigOrigin>;
|
|
@@ -91,10 +94,6 @@ export function createPolicyDefaults(): EffectiveToolkitPolicy {
|
|
|
91
94
|
apis: [...context.responsesApis],
|
|
92
95
|
},
|
|
93
96
|
nativeFallback: { ...context.nativeFallback, model: null },
|
|
94
|
-
remoteWindows: {
|
|
95
|
-
leaveManagedMode: context.leaveManagedMode,
|
|
96
|
-
reminderThresholdPercent: context.contextReminderThresholdPercent,
|
|
97
|
-
},
|
|
98
97
|
},
|
|
99
98
|
webSearch: { route: "unmanaged" },
|
|
100
99
|
imageGeneration: {
|
package/src/config/v2.ts
CHANGED
|
@@ -60,6 +60,8 @@ import {
|
|
|
60
60
|
import {
|
|
61
61
|
CONFIG_FEATURES,
|
|
62
62
|
RETIRED_AUTO_MODE_ISSUE,
|
|
63
|
+
RETIRED_REMOTE_WINDOWS_ISSUE,
|
|
64
|
+
RETIRED_REMOTE_WINDOWS_MODE_ISSUE,
|
|
63
65
|
createPolicyDefaults,
|
|
64
66
|
type ConfigFeature,
|
|
65
67
|
type ConfigIssue,
|
|
@@ -100,9 +102,8 @@ export const V2_ISSUE = {
|
|
|
100
102
|
imageDefaultNotAllowed: "imageGeneration.defaultModel.notAllowed",
|
|
101
103
|
} as const;
|
|
102
104
|
|
|
103
|
-
const CONTEXT_MODES = ["pi", "remote-compaction"
|
|
105
|
+
const CONTEXT_MODES = ["pi", "remote-compaction"] as const;
|
|
104
106
|
const INPUT_SOURCES = ["legacy", "pi-context-hook"] as const;
|
|
105
|
-
const LEAVE_MANAGED_MODES = ["warn", "compact"] as const;
|
|
106
107
|
const SEARCH_ROUTES = ["unmanaged", "local", "hosted", "standalone-alpha"] as const;
|
|
107
108
|
const TRANSPORTS = ["standard", "codex-gateway"] as const;
|
|
108
109
|
const DIAGNOSTIC_LEVELS = ["error", "warn", "info", "debug"] as const;
|
|
@@ -116,7 +117,6 @@ const MODEL_OVERRIDE_KEYS = new Set(["context", "webSearch", "autoMode", "compat
|
|
|
116
117
|
const CONTEXT_KEYS = new Set(["mode", "remoteCompaction", "nativeFallback", "remoteWindows"]);
|
|
117
118
|
const REMOTE_COMPACTION_KEYS = new Set(["model", "inputSource", "allowContinuityBreak", "apis"]);
|
|
118
119
|
const NATIVE_FALLBACK_KEYS = new Set(["enabled", "model", "thinkingLevel"]);
|
|
119
|
-
const REMOTE_WINDOWS_KEYS = new Set(["leaveManagedMode", "reminderThresholdPercent"]);
|
|
120
120
|
const WEB_SEARCH_KEYS = new Set(["route"]);
|
|
121
121
|
const IMAGE_GENERATION_KEYS = new Set(["enabled", "defaultModel", "allowedModels"]);
|
|
122
122
|
const RESPONSES_WEBSOCKET_KEYS = new Set(["enabled"]);
|
|
@@ -165,8 +165,6 @@ const POLICY_LEAVES: readonly { leaf: string; feature: ConfigFeature }[] = [
|
|
|
165
165
|
{ leaf: "context.nativeFallback.enabled", feature: "context" },
|
|
166
166
|
{ leaf: "context.nativeFallback.model", feature: "context" },
|
|
167
167
|
{ leaf: "context.nativeFallback.thinkingLevel", feature: "context" },
|
|
168
|
-
{ leaf: "context.remoteWindows.leaveManagedMode", feature: "context" },
|
|
169
|
-
{ leaf: "context.remoteWindows.reminderThresholdPercent", feature: "context" },
|
|
170
168
|
{ leaf: "webSearch.route", feature: "webSearch" },
|
|
171
169
|
{ leaf: "imageGeneration.enabled", feature: "imageGeneration" },
|
|
172
170
|
{ leaf: "imageGeneration.defaultModel", feature: "imageGeneration" },
|
|
@@ -410,16 +408,6 @@ function readEnum<T extends string>(allowed: readonly T[], value: unknown): Read
|
|
|
410
408
|
return { ok: false, code: V2_ISSUE.expectedEnum };
|
|
411
409
|
}
|
|
412
410
|
|
|
413
|
-
function readInteger(value: unknown, min: number, max: number): ReadResult<number> {
|
|
414
|
-
if (typeof value !== "number") {
|
|
415
|
-
return { ok: false, code: typeCode(value, V2_ISSUE.expectedInteger) };
|
|
416
|
-
}
|
|
417
|
-
if (!Number.isInteger(value) || value < min || value > max) {
|
|
418
|
-
return { ok: false, code: V2_ISSUE.range };
|
|
419
|
-
}
|
|
420
|
-
return { ok: true, value };
|
|
421
|
-
}
|
|
422
|
-
|
|
423
411
|
function readThinkingLevel(value: unknown): ReadResult<ThinkingLevel> {
|
|
424
412
|
return readEnum(THINKING_LEVELS, value);
|
|
425
413
|
}
|
|
@@ -548,7 +536,9 @@ function applyContextSettings(
|
|
|
548
536
|
{ key: "mode", leaf: "context.mode", feature: "context" },
|
|
549
537
|
scope,
|
|
550
538
|
state,
|
|
551
|
-
(value) =>
|
|
539
|
+
(value) => typeof value === "string" && value.trim() === "remote-windows"
|
|
540
|
+
? { ok: false, code: RETIRED_REMOTE_WINDOWS_MODE_ISSUE }
|
|
541
|
+
: readEnum(CONTEXT_MODES, value),
|
|
552
542
|
(value) => {
|
|
553
543
|
state.policy.context.mode = value;
|
|
554
544
|
},
|
|
@@ -560,8 +550,12 @@ function applyContextSettings(
|
|
|
560
550
|
const nativeFallback = openGroup(raw, "nativeFallback", scope, state, "context");
|
|
561
551
|
if (nativeFallback) applyNativeFallbackSettings(nativeFallback.raw, nativeFallback.scope, state);
|
|
562
552
|
|
|
563
|
-
|
|
564
|
-
|
|
553
|
+
// Retired ancillary data is opaque, even when malformed. Never validate
|
|
554
|
+
// children, create origins or invalidate otherwise valid context policy.
|
|
555
|
+
if (Object.hasOwn(raw, "remoteWindows")) state.issues.push(withModel(scope, {
|
|
556
|
+
severity: "warning", code: RETIRED_REMOTE_WINDOWS_ISSUE,
|
|
557
|
+
path: joinPath(scope.input, "remoteWindows"), feature: "context",
|
|
558
|
+
}));
|
|
565
559
|
}
|
|
566
560
|
|
|
567
561
|
function applyRemoteCompactionSettings(
|
|
@@ -692,39 +686,6 @@ function applyNativeFallbackSettings(
|
|
|
692
686
|
);
|
|
693
687
|
}
|
|
694
688
|
|
|
695
|
-
function applyRemoteWindowsSettings(
|
|
696
|
-
raw: Record<string, unknown>,
|
|
697
|
-
scope: Scope,
|
|
698
|
-
state: ResolutionState,
|
|
699
|
-
): void {
|
|
700
|
-
reportUnknownKeys(raw, REMOTE_WINDOWS_KEYS, scope, state, "context");
|
|
701
|
-
|
|
702
|
-
applyField(
|
|
703
|
-
raw,
|
|
704
|
-
{ key: "leaveManagedMode", leaf: "context.remoteWindows.leaveManagedMode", feature: "context" },
|
|
705
|
-
scope,
|
|
706
|
-
state,
|
|
707
|
-
(value) => readEnum(LEAVE_MANAGED_MODES, value),
|
|
708
|
-
(value) => {
|
|
709
|
-
state.policy.context.remoteWindows.leaveManagedMode = value;
|
|
710
|
-
},
|
|
711
|
-
);
|
|
712
|
-
applyField(
|
|
713
|
-
raw,
|
|
714
|
-
{
|
|
715
|
-
key: "reminderThresholdPercent",
|
|
716
|
-
leaf: "context.remoteWindows.reminderThresholdPercent",
|
|
717
|
-
feature: "context",
|
|
718
|
-
},
|
|
719
|
-
scope,
|
|
720
|
-
state,
|
|
721
|
-
(value) => readInteger(value, 0, 100),
|
|
722
|
-
(value) => {
|
|
723
|
-
state.policy.context.remoteWindows.reminderThresholdPercent = value;
|
|
724
|
-
},
|
|
725
|
-
);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
689
|
function applyWebSearchSettings(
|
|
729
690
|
raw: Record<string, unknown>,
|
|
730
691
|
scope: Scope,
|
package/src/config.ts
CHANGED
|
@@ -8,6 +8,10 @@ import { resolveV2Config } from "./config/v2";
|
|
|
8
8
|
import {
|
|
9
9
|
CONFIG_FEATURES,
|
|
10
10
|
RETIRED_AUTO_MODE_ISSUE,
|
|
11
|
+
RETIRED_REMOTE_WINDOWS_ISSUE,
|
|
12
|
+
RETIRED_REMOTE_WINDOWS_MODE_ISSUE,
|
|
13
|
+
RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE,
|
|
14
|
+
RETIRED_REMOTE_WINDOWS_MODE_MESSAGE,
|
|
11
15
|
createPolicyDefaults,
|
|
12
16
|
type ConfigDocumentSnapshot,
|
|
13
17
|
type ConfigFeature,
|
|
@@ -103,7 +107,7 @@ function leafPaths(value: unknown, prefix = ""): string[] {
|
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
const LEGACY_PATHS: Record<string, string> = {
|
|
106
|
-
"context.mode": "compaction.
|
|
110
|
+
"context.mode": "compaction.enabled",
|
|
107
111
|
"context.remoteCompaction.model": "compaction.remoteCompactModel",
|
|
108
112
|
"context.remoteCompaction.inputSource": "compaction.remoteV2ContextSource",
|
|
109
113
|
"context.remoteCompaction.allowContinuityBreak": "compaction.allowCompactionContinuityBreak",
|
|
@@ -111,8 +115,6 @@ const LEGACY_PATHS: Record<string, string> = {
|
|
|
111
115
|
"context.nativeFallback.enabled": "compaction.nativeFallback.enabled",
|
|
112
116
|
"context.nativeFallback.model": "compaction.nativeFallback.model",
|
|
113
117
|
"context.nativeFallback.thinkingLevel": "compaction.nativeFallback.thinkingLevel",
|
|
114
|
-
"context.remoteWindows.leaveManagedMode": "compaction.leaveManagedMode",
|
|
115
|
-
"context.remoteWindows.reminderThresholdPercent": "compaction.contextReminderThresholdPercent",
|
|
116
118
|
"webSearch.route": "webSearch.models",
|
|
117
119
|
"imageGeneration.enabled": "imageGeneration.enabled",
|
|
118
120
|
"imageGeneration.defaultModel": "imageGeneration.models",
|
|
@@ -159,6 +161,13 @@ function legacyIssues(loaded: LoadedToolkitConfig, modelKey: string | undefined)
|
|
|
159
161
|
if (warning.startsWith("Ignoring autoMode:")) {
|
|
160
162
|
return { severity: "warning", code: RETIRED_AUTO_MODE_ISSUE, path: "autoMode", feature: "document" };
|
|
161
163
|
}
|
|
164
|
+
const retiredField = /^Ignoring (compaction\.(?:contextManagement|leaveManagedMode|contextReminderThresholdPercent)):/.exec(warning)?.[1];
|
|
165
|
+
if (retiredField && (warning.endsWith(RETIRED_REMOTE_WINDOWS_CONFIG_MESSAGE) || warning.endsWith(RETIRED_REMOTE_WINDOWS_MODE_MESSAGE))) {
|
|
166
|
+
const selectedMode = warning.endsWith(RETIRED_REMOTE_WINDOWS_MODE_MESSAGE);
|
|
167
|
+
return { severity: selectedMode ? "error" : "warning",
|
|
168
|
+
code: selectedMode ? RETIRED_REMOTE_WINDOWS_MODE_ISSUE : RETIRED_REMOTE_WINDOWS_ISSUE,
|
|
169
|
+
path: retiredField, feature: "context" };
|
|
170
|
+
}
|
|
162
171
|
const match = /^Ignoring ([^:]+):/.exec(warning);
|
|
163
172
|
const field = warning.startsWith("Ignoring compaction.responsesApis entry ") ? "compaction.responsesApis" : match?.[1] ?? "$";
|
|
164
173
|
const root = field.split(".")[0];
|
|
@@ -195,8 +204,10 @@ function fromLegacy(loaded: LoadedToolkitConfig, model: WebSearchModel | undefin
|
|
|
195
204
|
const modelKey = getExactModelKey(model);
|
|
196
205
|
const route = resolveWebSearchRoute({ model, config: config.webSearch });
|
|
197
206
|
const policy = createPolicyDefaults();
|
|
207
|
+
const issues = [...(loaded.document?.issues ?? []), ...legacyIssues(loaded, modelKey)];
|
|
208
|
+
const retiredMode = issues.some((issue) => issue.code === RETIRED_REMOTE_WINDOWS_MODE_ISSUE);
|
|
198
209
|
policy.context = {
|
|
199
|
-
mode: !compaction.enabled
|
|
210
|
+
mode: !compaction.enabled || retiredMode ? "pi" : "remote-compaction",
|
|
200
211
|
remoteCompaction: {
|
|
201
212
|
model: compaction.remoteCompactModel ?? null,
|
|
202
213
|
inputSource: compaction.remoteV2ContextSource,
|
|
@@ -204,7 +215,6 @@ function fromLegacy(loaded: LoadedToolkitConfig, model: WebSearchModel | undefin
|
|
|
204
215
|
apis: [...compaction.responsesApis],
|
|
205
216
|
},
|
|
206
217
|
nativeFallback: { ...compaction.nativeFallback, model: compaction.nativeFallback.model ?? null },
|
|
207
|
-
remoteWindows: { leaveManagedMode: compaction.leaveManagedMode, reminderThresholdPercent: compaction.contextReminderThresholdPercent },
|
|
208
218
|
};
|
|
209
219
|
policy.webSearch.route = route.route === "none" ? "unmanaged" : route.route;
|
|
210
220
|
policy.imageGeneration = {
|
|
@@ -225,8 +235,12 @@ function fromLegacy(loaded: LoadedToolkitConfig, model: WebSearchModel | undefin
|
|
|
225
235
|
const origins: Record<string, ConfigOrigin> = Object.create(null);
|
|
226
236
|
const raw = loaded.document?.raw;
|
|
227
237
|
for (const leaf of leafPaths(policy)) {
|
|
238
|
+
if (leaf === "context.mode" && retiredMode) {
|
|
239
|
+
// A blocked old selection owns no supported effective-mode origin.
|
|
240
|
+
origins[leaf] = { kind: "builtin" };
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
228
243
|
let input = LEGACY_PATHS[leaf] ?? leaf;
|
|
229
|
-
if (leaf === "context.mode" && !compaction.enabled) input = "compaction.enabled";
|
|
230
244
|
if (leaf === "webSearch.route") {
|
|
231
245
|
if (!config.webSearch.enabled) input = "webSearch.enabled";
|
|
232
246
|
else if (route.source === "exact") {
|
|
@@ -242,7 +256,6 @@ function fromLegacy(loaded: LoadedToolkitConfig, model: WebSearchModel | undefin
|
|
|
242
256
|
origins[leaf] = !ignored && ((raw && containsPath(raw, input)) || (!loaded.document && loaded.source))
|
|
243
257
|
? { kind: "legacy", path: input, source: loaded.source } : { kind: "builtin" };
|
|
244
258
|
}
|
|
245
|
-
const issues = [...(loaded.document?.issues ?? []), ...legacyIssues(loaded, modelKey)];
|
|
246
259
|
return { policy, origins, issues, invalidFeatures: selectedInvalidFeatures(issues, modelKey) };
|
|
247
260
|
}
|
|
248
261
|
|
|
@@ -252,15 +265,12 @@ function engineConfig(policy: EffectiveToolkitPolicy, gatewayKeys: string[]): To
|
|
|
252
265
|
return {
|
|
253
266
|
compaction: {
|
|
254
267
|
enabled: context.mode !== "pi",
|
|
255
|
-
contextManagement: context.mode === "remote-windows" ? "remote" : "off",
|
|
256
268
|
remoteCompactModel: context.remoteCompaction.model ?? undefined,
|
|
257
269
|
remoteV2ContextSource: context.remoteCompaction.inputSource,
|
|
258
270
|
allowCompactionContinuityBreak: context.remoteCompaction.allowContinuityBreak,
|
|
259
271
|
responsesApis: [...context.remoteCompaction.apis],
|
|
260
272
|
gatewayContextModels: [...gatewayKeys],
|
|
261
273
|
nativeFallback: { ...context.nativeFallback, model: context.nativeFallback.model ?? undefined },
|
|
262
|
-
leaveManagedMode: context.remoteWindows.leaveManagedMode,
|
|
263
|
-
contextReminderThresholdPercent: context.remoteWindows.reminderThresholdPercent,
|
|
264
274
|
debug: diagnostics.level === "debug",
|
|
265
275
|
notifyOnLoad: diagnostics.notifyOnLoad,
|
|
266
276
|
logProviderPayloads: diagnostics.captureRequests,
|