@vybestack/llxprt-code-core 0.10.0 → 0.11.0-nightly.260728.ffaa8d5d7
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/dist/src/config/config.d.ts +20 -0
- package/dist/src/config/config.js +143 -23
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/configBaseCore.d.ts +6 -2
- package/dist/src/config/configBaseCore.js +8 -0
- package/dist/src/config/configBaseCore.js.map +1 -1
- package/dist/src/config/configConstructor.d.ts +2 -0
- package/dist/src/config/configConstructor.js +9 -1
- package/dist/src/config/configConstructor.js.map +1 -1
- package/dist/src/config/configTestHarness.d.ts +8 -6
- package/dist/src/config/configTestHarness.js +10 -4
- package/dist/src/config/configTestHarness.js.map +1 -1
- package/dist/src/config/configTypes.d.ts +7 -2
- package/dist/src/config/configTypes.js +2 -0
- package/dist/src/config/configTypes.js.map +1 -1
- package/dist/src/config/liveTrustTransitionLifecycle.d.ts +35 -0
- package/dist/src/config/liveTrustTransitionLifecycle.js +180 -0
- package/dist/src/config/liveTrustTransitionLifecycle.js.map +1 -0
- package/dist/src/config/schedulerSingleton.d.ts +2 -2
- package/dist/src/config/schedulerSingleton.js.map +1 -1
- package/dist/src/core/compression/types.d.ts +48 -1
- package/dist/src/core/compression/types.js +41 -0
- package/dist/src/core/compression/types.js.map +1 -1
- package/dist/src/core/model-limits.json +96 -0
- package/dist/src/core/model-limits.schema.d.ts +123 -0
- package/dist/src/core/model-limits.schema.js +75 -0
- package/dist/src/core/model-limits.schema.js.map +1 -0
- package/dist/src/core/tokenLimits.d.ts +6 -8
- package/dist/src/core/tokenLimits.js +56 -132
- package/dist/src/core/tokenLimits.js.map +1 -1
- package/dist/src/core/turn.d.ts +20 -3
- package/dist/src/core/turn.js +20 -3
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/hooks/hookRegistry.d.ts +1 -1
- package/dist/src/hooks/hookRegistry.js +3 -1
- package/dist/src/hooks/hookRegistry.js.map +1 -1
- package/dist/src/hooks/hookRunner.d.ts +6 -0
- package/dist/src/hooks/hookRunner.js +22 -6
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +10 -1
- package/dist/src/hooks/hookSystem.js +69 -12
- package/dist/src/hooks/hookSystem.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/llm-types/geminiContent.d.ts +3 -0
- package/dist/src/policy/config.d.ts +4 -2
- package/dist/src/policy/config.js +22 -18
- package/dist/src/policy/config.js.map +1 -1
- package/dist/src/recording/ReplayEngine.js +39 -2
- package/dist/src/recording/ReplayEngine.js.map +1 -1
- package/dist/src/recording/SessionDiscovery.d.ts +8 -0
- package/dist/src/recording/SessionDiscovery.js +88 -3
- package/dist/src/recording/SessionDiscovery.js.map +1 -1
- package/dist/src/recording/SessionLockManager.d.ts +3 -0
- package/dist/src/recording/SessionLockManager.js +9 -3
- package/dist/src/recording/SessionLockManager.js.map +1 -1
- package/dist/src/recording/SessionRecordingService.d.ts +14 -1
- package/dist/src/recording/SessionRecordingService.js +27 -3
- package/dist/src/recording/SessionRecordingService.js.map +1 -1
- package/dist/src/recording/index.d.ts +4 -3
- package/dist/src/recording/index.js +4 -3
- package/dist/src/recording/index.js.map +1 -1
- package/dist/src/recording/replay-test-helpers.d.ts +5 -0
- package/dist/src/recording/replay-test-helpers.js +13 -0
- package/dist/src/recording/replay-test-helpers.js.map +1 -1
- package/dist/src/recording/resumeNotFoundMessages.d.ts +56 -0
- package/dist/src/recording/resumeNotFoundMessages.js +64 -0
- package/dist/src/recording/resumeNotFoundMessages.js.map +1 -0
- package/dist/src/recording/resumeSession.js +3 -2
- package/dist/src/recording/resumeSession.js.map +1 -1
- package/dist/src/recording/sessionManagement.d.ts +3 -0
- package/dist/src/recording/sessionManagement.js +38 -19
- package/dist/src/recording/sessionManagement.js.map +1 -1
- package/dist/src/recording/types.d.ts +42 -3
- package/dist/src/recording/types.js +1 -1
- package/dist/src/recording/types.js.map +1 -1
- package/dist/src/runtime/AgentRuntimeLoader.js +2 -1
- package/dist/src/runtime/AgentRuntimeLoader.js.map +1 -1
- package/dist/src/scheduler/liveOutput.d.ts +10 -19
- package/dist/src/scheduler/liveOutput.js +21 -21
- package/dist/src/scheduler/liveOutput.js.map +1 -1
- package/dist/src/scheduler/types.d.ts +2 -2
- package/dist/src/services/history/ContentConverters.d.ts +4 -0
- package/dist/src/services/history/ContentConverters.js +77 -59
- package/dist/src/services/history/ContentConverters.js.map +1 -1
- package/dist/src/services/history/HistoryService.d.ts +13 -1
- package/dist/src/services/history/HistoryService.js +71 -0
- package/dist/src/services/history/HistoryService.js.map +1 -1
- package/dist/src/services/history/IContent.d.ts +10 -0
- package/dist/src/services/history/IContent.js.map +1 -1
- package/dist/src/skills/skillManager.d.ts +11 -1
- package/dist/src/skills/skillManager.js +21 -1
- package/dist/src/skills/skillManager.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +3 -3
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/test-utils/tools.d.ts +2 -2
- package/dist/src/test-utils/tools.js.map +1 -1
- package/dist/src/tools-adapters/CoreShellToolHostAdapter.js +1 -6
- package/dist/src/tools-adapters/CoreShellToolHostAdapter.js.map +1 -1
- package/dist/src/utils/browser-profile-discovery.d.ts +40 -0
- package/dist/src/utils/browser-profile-discovery.js +251 -0
- package/dist/src/utils/browser-profile-discovery.js.map +1 -0
- package/dist/src/utils/env.d.ts +12 -0
- package/dist/src/utils/env.js +15 -0
- package/dist/src/utils/env.js.map +1 -0
- package/dist/src/utils/events.d.ts +10 -1
- package/dist/src/utils/events.js +22 -0
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/fileUtils.js +8 -1
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/retry.js +3 -4
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/secure-browser-launcher.d.ts +35 -1
- package/dist/src/utils/secure-browser-launcher.js +341 -1
- package/dist/src/utils/secure-browser-launcher.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +12 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -1
- package/dist/src/utils/thoughtUtils.d.ts +2 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -1
- package/package.json +13 -9
- package/src/config/config.ts +161 -22
- package/src/config/configBaseCore.ts +10 -2
- package/src/config/configConstructor.ts +11 -0
- package/src/config/configTestHarness.ts +10 -4
- package/src/config/configTypes.ts +6 -1
- package/src/config/liveTrustTransitionLifecycle.ts +250 -0
- package/src/config/schedulerSingleton.ts +2 -5
- package/src/core/compression/types.ts +81 -1
- package/src/core/legacy-model-limits.expected.txt +96 -0
- package/src/core/model-limits.json +96 -0
- package/src/core/model-limits.schema.ts +87 -0
- package/src/core/tokenLimits.ts +73 -147
- package/src/core/turn.ts +20 -3
- package/src/hooks/hookRegistry.ts +3 -1
- package/src/hooks/hookRunner.ts +24 -7
- package/src/hooks/hookSystem.ts +73 -13
- package/src/index.ts +1 -0
- package/src/llm-types/geminiContent.ts +3 -0
- package/src/policy/config.ts +32 -19
- package/src/recording/ReplayEngine.ts +51 -2
- package/src/recording/SessionDiscovery.ts +99 -4
- package/src/recording/SessionLockManager.ts +10 -3
- package/src/recording/SessionRecordingService.ts +36 -3
- package/src/recording/index.ts +19 -2
- package/src/recording/replay-test-helpers.ts +14 -0
- package/src/recording/resumeNotFoundMessages.ts +75 -0
- package/src/recording/resumeSession.ts +3 -1
- package/src/recording/sessionManagement.ts +51 -21
- package/src/recording/types.ts +44 -2
- package/src/runtime/AgentRuntimeLoader.ts +3 -1
- package/src/scheduler/liveOutput.ts +25 -22
- package/src/scheduler/types.ts +5 -2
- package/src/services/history/ContentConverters.ts +91 -68
- package/src/services/history/HistoryService.ts +92 -1
- package/src/services/history/IContent.ts +13 -0
- package/src/skills/skillManager.ts +26 -1
- package/src/test-utils/mock-tool.ts +4 -3
- package/src/test-utils/tools.ts +4 -3
- package/src/tools-adapters/CoreShellToolHostAdapter.ts +1 -7
- package/src/utils/browser-profile-discovery.ts +358 -0
- package/src/utils/env.ts +15 -0
- package/src/utils/events.ts +31 -0
- package/src/utils/fileUtils.ts +11 -1
- package/src/utils/retry.ts +3 -4
- package/src/utils/secure-browser-launcher.ts +500 -2
- package/src/utils/terminalSerializer.ts +9 -0
- package/src/utils/thoughtUtils.ts +2 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"defaultLimit": 200000,
|
|
3
|
+
"exactLimits": {
|
|
4
|
+
"glm-5.2": 200000,
|
|
5
|
+
"glm-5.1": 200000,
|
|
6
|
+
"glm-5": 200000,
|
|
7
|
+
"glm-4.6": 128000,
|
|
8
|
+
"glm-4.5": 128000,
|
|
9
|
+
"glm-4": 128000,
|
|
10
|
+
"gemini-1.5-pro": 2097152,
|
|
11
|
+
"gemini-1.5-flash": 1048576,
|
|
12
|
+
"gemini-2.5-pro-preview-05-06": 1048576,
|
|
13
|
+
"gemini-2.5-pro-preview-06-05": 1048576,
|
|
14
|
+
"gemini-2.5-pro": 1048576,
|
|
15
|
+
"gemini-2.5-flash-preview-05-20": 1048576,
|
|
16
|
+
"gemini-2.5-flash": 1048576,
|
|
17
|
+
"gemini-2.5-flash-lite": 1048576,
|
|
18
|
+
"gemini-2.0-flash": 1048576,
|
|
19
|
+
"gemini-2.0-flash-preview-image-generation": 32000,
|
|
20
|
+
"claude-opus-5": 200000,
|
|
21
|
+
"claude-opus-5-latest": 200000,
|
|
22
|
+
"claude-opus-4-8": 200000,
|
|
23
|
+
"claude-opus-4-7": 200000,
|
|
24
|
+
"claude-opus-4-6": 200000,
|
|
25
|
+
"claude-opus-4-latest": 200000,
|
|
26
|
+
"claude-sonnet-4-6": 200000,
|
|
27
|
+
"claude-sonnet-4-latest": 400000,
|
|
28
|
+
"claude-sonnet-5": 200000,
|
|
29
|
+
"claude-sonnet-5-latest": 200000,
|
|
30
|
+
"claude-fable-5": 200000,
|
|
31
|
+
"claude-fable-5-latest": 200000,
|
|
32
|
+
"claude-3-7-opus-20250115": 300000,
|
|
33
|
+
"claude-3-7-sonnet-20250115": 300000,
|
|
34
|
+
"claude-3-opus-20240229": 200000,
|
|
35
|
+
"claude-3-sonnet-20240229": 200000,
|
|
36
|
+
"claude-3-haiku-20240307": 200000,
|
|
37
|
+
"claude-3.5-sonnet-20240620": 200000,
|
|
38
|
+
"claude-3.5-sonnet-20241022": 200000,
|
|
39
|
+
"claude-3.5-haiku-20241022": 200000,
|
|
40
|
+
"claude-3-5-sonnet-20241022": 200000,
|
|
41
|
+
"claude-3-5-haiku-20241022": 200000
|
|
42
|
+
},
|
|
43
|
+
"prefixLimits": [
|
|
44
|
+
{ "prefix": "gpt-4.1", "limit": 1000000 },
|
|
45
|
+
{ "prefix": "gpt-3.5-turbo", "limit": 16385 },
|
|
46
|
+
{ "prefix": "gemini-2.5-pro", "limit": 1048576 },
|
|
47
|
+
{ "prefix": "gemini-2.5-flash", "limit": 1048576 },
|
|
48
|
+
{ "prefix": "gemini-2.0-flash", "limit": 1048576 },
|
|
49
|
+
{ "prefix": "glm-5", "limit": 200000 },
|
|
50
|
+
{ "prefix": "glm-4", "limit": 128000 }
|
|
51
|
+
],
|
|
52
|
+
"orderedRules": [
|
|
53
|
+
{
|
|
54
|
+
"type": "substring",
|
|
55
|
+
"substring": "codex-spark",
|
|
56
|
+
"limit": 131072
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "substringOrProviderPrefix",
|
|
60
|
+
"substring": "codex",
|
|
61
|
+
"providerPrefix": "codex",
|
|
62
|
+
"limit": 262144
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "prefixGroup",
|
|
66
|
+
"prefixes": ["o3-pro", "o3-mini", "o1-mini", "o3", "o1"],
|
|
67
|
+
"limit": 200000
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"type": "prefixGroup",
|
|
71
|
+
"prefixes": [
|
|
72
|
+
"o4-mini",
|
|
73
|
+
"gpt-4o-mini",
|
|
74
|
+
"gpt-4o-realtime",
|
|
75
|
+
"gpt-4o",
|
|
76
|
+
"gpt-4-turbo"
|
|
77
|
+
],
|
|
78
|
+
"limit": 128000
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"type": "substringCaseInsensitive",
|
|
82
|
+
"substring": "claude-sonnet-5",
|
|
83
|
+
"limit": 200000
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"type": "substringCaseInsensitive",
|
|
87
|
+
"substring": "claude-opus-5",
|
|
88
|
+
"limit": 200000
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"type": "substringCaseInsensitive",
|
|
92
|
+
"substring": "claude-fable-5",
|
|
93
|
+
"limit": 200000
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const ModelLimitsCatalogSchema: z.ZodObject<{
|
|
8
|
+
defaultLimit: z.ZodNumber;
|
|
9
|
+
exactLimits: z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodNumber>;
|
|
10
|
+
prefixLimits: z.ZodArray<z.ZodObject<{
|
|
11
|
+
prefix: z.ZodEffects<z.ZodString, string, string>;
|
|
12
|
+
limit: z.ZodNumber;
|
|
13
|
+
}, "strict", z.ZodTypeAny, {
|
|
14
|
+
limit: number;
|
|
15
|
+
prefix: string;
|
|
16
|
+
}, {
|
|
17
|
+
limit: number;
|
|
18
|
+
prefix: string;
|
|
19
|
+
}>, "many">;
|
|
20
|
+
orderedRules: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
21
|
+
type: z.ZodLiteral<"substring">;
|
|
22
|
+
substring: z.ZodEffects<z.ZodString, string, string>;
|
|
23
|
+
limit: z.ZodNumber;
|
|
24
|
+
}, "strict", z.ZodTypeAny, {
|
|
25
|
+
type: "substring";
|
|
26
|
+
substring: string;
|
|
27
|
+
limit: number;
|
|
28
|
+
}, {
|
|
29
|
+
type: "substring";
|
|
30
|
+
substring: string;
|
|
31
|
+
limit: number;
|
|
32
|
+
}>, z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"substringOrProviderPrefix">;
|
|
34
|
+
substring: z.ZodEffects<z.ZodString, string, string>;
|
|
35
|
+
providerPrefix: z.ZodEffects<z.ZodString, string, string>;
|
|
36
|
+
limit: z.ZodNumber;
|
|
37
|
+
}, "strict", z.ZodTypeAny, {
|
|
38
|
+
type: "substringOrProviderPrefix";
|
|
39
|
+
substring: string;
|
|
40
|
+
limit: number;
|
|
41
|
+
providerPrefix: string;
|
|
42
|
+
}, {
|
|
43
|
+
type: "substringOrProviderPrefix";
|
|
44
|
+
substring: string;
|
|
45
|
+
limit: number;
|
|
46
|
+
providerPrefix: string;
|
|
47
|
+
}>, z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"prefixGroup">;
|
|
49
|
+
prefixes: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
50
|
+
limit: z.ZodNumber;
|
|
51
|
+
}, "strict", z.ZodTypeAny, {
|
|
52
|
+
type: "prefixGroup";
|
|
53
|
+
limit: number;
|
|
54
|
+
prefixes: string[];
|
|
55
|
+
}, {
|
|
56
|
+
type: "prefixGroup";
|
|
57
|
+
limit: number;
|
|
58
|
+
prefixes: string[];
|
|
59
|
+
}>, z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"substringCaseInsensitive">;
|
|
61
|
+
substring: z.ZodEffects<z.ZodString, string, string>;
|
|
62
|
+
limit: z.ZodNumber;
|
|
63
|
+
}, "strict", z.ZodTypeAny, {
|
|
64
|
+
type: "substringCaseInsensitive";
|
|
65
|
+
substring: string;
|
|
66
|
+
limit: number;
|
|
67
|
+
}, {
|
|
68
|
+
type: "substringCaseInsensitive";
|
|
69
|
+
substring: string;
|
|
70
|
+
limit: number;
|
|
71
|
+
}>]>, "many">;
|
|
72
|
+
}, "strict", z.ZodTypeAny, {
|
|
73
|
+
defaultLimit: number;
|
|
74
|
+
exactLimits: Record<string, number>;
|
|
75
|
+
prefixLimits: {
|
|
76
|
+
limit: number;
|
|
77
|
+
prefix: string;
|
|
78
|
+
}[];
|
|
79
|
+
orderedRules: ({
|
|
80
|
+
type: "substring";
|
|
81
|
+
substring: string;
|
|
82
|
+
limit: number;
|
|
83
|
+
} | {
|
|
84
|
+
type: "substringOrProviderPrefix";
|
|
85
|
+
substring: string;
|
|
86
|
+
limit: number;
|
|
87
|
+
providerPrefix: string;
|
|
88
|
+
} | {
|
|
89
|
+
type: "prefixGroup";
|
|
90
|
+
limit: number;
|
|
91
|
+
prefixes: string[];
|
|
92
|
+
} | {
|
|
93
|
+
type: "substringCaseInsensitive";
|
|
94
|
+
substring: string;
|
|
95
|
+
limit: number;
|
|
96
|
+
})[];
|
|
97
|
+
}, {
|
|
98
|
+
defaultLimit: number;
|
|
99
|
+
exactLimits: Record<string, number>;
|
|
100
|
+
prefixLimits: {
|
|
101
|
+
limit: number;
|
|
102
|
+
prefix: string;
|
|
103
|
+
}[];
|
|
104
|
+
orderedRules: ({
|
|
105
|
+
type: "substring";
|
|
106
|
+
substring: string;
|
|
107
|
+
limit: number;
|
|
108
|
+
} | {
|
|
109
|
+
type: "substringOrProviderPrefix";
|
|
110
|
+
substring: string;
|
|
111
|
+
limit: number;
|
|
112
|
+
providerPrefix: string;
|
|
113
|
+
} | {
|
|
114
|
+
type: "prefixGroup";
|
|
115
|
+
limit: number;
|
|
116
|
+
prefixes: string[];
|
|
117
|
+
} | {
|
|
118
|
+
type: "substringCaseInsensitive";
|
|
119
|
+
substring: string;
|
|
120
|
+
limit: number;
|
|
121
|
+
})[];
|
|
122
|
+
}>;
|
|
123
|
+
export type ModelLimitsCatalog = z.infer<typeof ModelLimitsCatalogSchema>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for the data-driven model-limits catalog, validated once at
|
|
9
|
+
* module init. See model-limits.json for the data.
|
|
10
|
+
*
|
|
11
|
+
* Hardening guarantees enforced here:
|
|
12
|
+
* - All match strings (substrings, provider prefixes, prefix-group entries)
|
|
13
|
+
* must be non-empty so a malformed entry can never silently match every
|
|
14
|
+
* model.
|
|
15
|
+
* - Prefix groups must contain at least one entry.
|
|
16
|
+
* - Every limit is a positive integer.
|
|
17
|
+
* - The catalog is a strict object: unknown top-level keys are rejected so
|
|
18
|
+
* typos like "orderedRule" vs "orderedRules" surface immediately.
|
|
19
|
+
*/
|
|
20
|
+
const PositiveLimit = z.number().int().positive();
|
|
21
|
+
/** Non-empty string without leading or trailing whitespace. */
|
|
22
|
+
const NonEmptyString = z
|
|
23
|
+
.string()
|
|
24
|
+
.refine((value) => value.length > 0 && value === value.trim());
|
|
25
|
+
const SubstringRuleSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
type: z.literal('substring'),
|
|
28
|
+
substring: NonEmptyString,
|
|
29
|
+
limit: PositiveLimit,
|
|
30
|
+
})
|
|
31
|
+
.strict();
|
|
32
|
+
const SubstringOrProviderPrefixRuleSchema = z
|
|
33
|
+
.object({
|
|
34
|
+
type: z.literal('substringOrProviderPrefix'),
|
|
35
|
+
substring: NonEmptyString,
|
|
36
|
+
providerPrefix: NonEmptyString,
|
|
37
|
+
limit: PositiveLimit,
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
40
|
+
const PrefixGroupRuleSchema = z
|
|
41
|
+
.object({
|
|
42
|
+
type: z.literal('prefixGroup'),
|
|
43
|
+
prefixes: z.array(NonEmptyString).min(1),
|
|
44
|
+
limit: PositiveLimit,
|
|
45
|
+
})
|
|
46
|
+
.strict();
|
|
47
|
+
/** Case-insensitive substring rule; runtime comparison normalizes both sides. */
|
|
48
|
+
const SubstringCaseInsensitiveRuleSchema = z
|
|
49
|
+
.object({
|
|
50
|
+
type: z.literal('substringCaseInsensitive'),
|
|
51
|
+
substring: NonEmptyString,
|
|
52
|
+
limit: PositiveLimit,
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
const OrderedRuleSchema = z.discriminatedUnion('type', [
|
|
56
|
+
SubstringRuleSchema,
|
|
57
|
+
SubstringOrProviderPrefixRuleSchema,
|
|
58
|
+
PrefixGroupRuleSchema,
|
|
59
|
+
SubstringCaseInsensitiveRuleSchema,
|
|
60
|
+
]);
|
|
61
|
+
const PrefixLimitSchema = z
|
|
62
|
+
.object({
|
|
63
|
+
prefix: NonEmptyString,
|
|
64
|
+
limit: PositiveLimit,
|
|
65
|
+
})
|
|
66
|
+
.strict();
|
|
67
|
+
export const ModelLimitsCatalogSchema = z
|
|
68
|
+
.object({
|
|
69
|
+
defaultLimit: PositiveLimit,
|
|
70
|
+
exactLimits: z.record(NonEmptyString, PositiveLimit),
|
|
71
|
+
prefixLimits: z.array(PrefixLimitSchema),
|
|
72
|
+
orderedRules: z.array(OrderedRuleSchema),
|
|
73
|
+
})
|
|
74
|
+
.strict();
|
|
75
|
+
//# sourceMappingURL=model-limits.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-limits.schema.js","sourceRoot":"","sources":["../../../src/core/model-limits.schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;GAYG;AAEH,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AAElD,+DAA+D;AAC/D,MAA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MAAM,EAAE,cAAc;IACtB,KAAK,EAAE,aAAa;CACrB,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,CAAC;IACN,YAAY,EAAE,aAAa;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,aAAa,CAAC;IACpD,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;IACxC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;CACzC,CAAC;KACD,MAAM,EAAE,CAAC"}
|
|
@@ -3,18 +3,16 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import type { ModelLimitsCatalog } from './model-limits.schema.js';
|
|
6
7
|
type Model = string;
|
|
7
8
|
type TokenCount = number;
|
|
9
|
+
export declare const DEFAULT_TOKEN_LIMIT: TokenCount;
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* real-world floor is 200K (Claude, many GLM/Gemini variants). Defaulting to
|
|
13
|
-
* 200K instead of 1M makes the unrecognized-model case fail-safe — proactive
|
|
14
|
-
* compression fires conservatively rather than silently overrunning a
|
|
15
|
-
* sub-200K backend.
|
|
11
|
+
* Resolve a single catalog's ordered rules against a model id + provider
|
|
12
|
+
* prefix. Exported so that the case-insensitive normalization can be tested
|
|
13
|
+
* with any catalog (including mixed-case fixtures) without type assertions.
|
|
16
14
|
*/
|
|
17
|
-
export declare
|
|
15
|
+
export declare function resolveOrderedRuleFromCatalog(catalog: ModelLimitsCatalog, modelWithoutPrefix: string, providerPrefix: string): TokenCount | undefined;
|
|
18
16
|
export declare function tokenLimit(model: Model, userContextLimit?: number): TokenCount;
|
|
19
17
|
/**
|
|
20
18
|
* Single source of truth for the three-tier context-window precedence
|
|
@@ -3,104 +3,58 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* compression fires conservatively rather than silently overrunning a
|
|
13
|
-
* sub-200K backend.
|
|
14
|
-
*/
|
|
15
|
-
export const DEFAULT_TOKEN_LIMIT = 200_000;
|
|
16
|
-
const OPENAI_128K_PREFIXES = [
|
|
17
|
-
'o4-mini',
|
|
18
|
-
'gpt-4o-mini',
|
|
19
|
-
'gpt-4o-realtime',
|
|
20
|
-
'gpt-4o',
|
|
21
|
-
'gpt-4-turbo',
|
|
22
|
-
];
|
|
23
|
-
const OPENAI_200K_PREFIXES = ['o3-pro', 'o3-mini', 'o1-mini', 'o3', 'o1'];
|
|
24
|
-
const PREFIX_LIMITS = [
|
|
25
|
-
{ prefix: 'gpt-4.1', limit: 1_000_000 },
|
|
26
|
-
{ prefix: 'gpt-3.5-turbo', limit: 16_385 },
|
|
27
|
-
// Gemini 2.x variants (experimental, preview, dated snapshots) — all 1M.
|
|
28
|
-
// Exact entries above take precedence, so the 32K image-generation variant
|
|
29
|
-
// is unaffected. Prevents the lowered DEFAULT_TOKEN_LIMIT from silently
|
|
30
|
-
// shrinking recognized Gemini variants (issue #2527).
|
|
31
|
-
{ prefix: 'gemini-2.5-pro', limit: 1_048_576 },
|
|
32
|
-
{ prefix: 'gemini-2.5-flash', limit: 1_048_576 },
|
|
33
|
-
{ prefix: 'gemini-2.0-flash', limit: 1_048_576 },
|
|
34
|
-
// GLM-5 family — 200K context window (z.ai API docs)
|
|
35
|
-
{ prefix: 'glm-5', limit: 200_000 },
|
|
36
|
-
// GLM-4 family — 128K context window (z.ai API docs)
|
|
37
|
-
{ prefix: 'glm-4', limit: 128_000 },
|
|
38
|
-
];
|
|
39
|
-
const EXACT_LIMITS = {
|
|
40
|
-
// GLM (z.ai) models — exact entries for commonly used variants.
|
|
41
|
-
// The GLM-5 family (glm-5, glm-5.1, glm-5.2, …) exposes a 200K context
|
|
42
|
-
// window; the GLM-4 family (glm-4, glm-4.5, glm-4.6, …) exposes 128K.
|
|
43
|
-
// Prefix-based fallbacks below cover future/dated variants.
|
|
44
|
-
'glm-5.2': 200_000,
|
|
45
|
-
'glm-5.1': 200_000,
|
|
46
|
-
'glm-5': 200_000,
|
|
47
|
-
'glm-4.6': 128_000,
|
|
48
|
-
'glm-4.5': 128_000,
|
|
49
|
-
'glm-4': 128_000,
|
|
50
|
-
// Gemini models
|
|
51
|
-
'gemini-1.5-pro': 2_097_152,
|
|
52
|
-
'gemini-1.5-flash': 1_048_576,
|
|
53
|
-
'gemini-2.5-pro-preview-05-06': 1_048_576,
|
|
54
|
-
'gemini-2.5-pro-preview-06-05': 1_048_576,
|
|
55
|
-
'gemini-2.5-pro': 1_048_576,
|
|
56
|
-
'gemini-2.5-flash-preview-05-20': 1_048_576,
|
|
57
|
-
'gemini-2.5-flash': 1_048_576,
|
|
58
|
-
'gemini-2.5-flash-lite': 1_048_576,
|
|
59
|
-
'gemini-2.0-flash': 1_048_576,
|
|
60
|
-
'gemini-2.0-flash-preview-image-generation': 32_000,
|
|
61
|
-
// Claude Opus 5 and Opus 4.6/4.7/4.8 default to the Claude Code /
|
|
62
|
-
// subscription 200K context window. The 1M window is API-only and
|
|
63
|
-
// plan-gated; override via /set or a profile (context-limit).
|
|
64
|
-
'claude-opus-5': 200_000,
|
|
65
|
-
'claude-opus-5-latest': 200_000,
|
|
66
|
-
'claude-opus-4-8': 200_000,
|
|
67
|
-
'claude-opus-4-7': 200_000,
|
|
68
|
-
'claude-opus-4-6': 200_000,
|
|
69
|
-
'claude-opus-4-latest': 200_000,
|
|
70
|
-
'claude-sonnet-4-6': 200_000,
|
|
71
|
-
'claude-sonnet-4-latest': 400_000,
|
|
72
|
-
// Claude Sonnet 5 defaults to the Claude Code / subscription 200K context
|
|
73
|
-
// window. The advertised 1M window is API-only and plan-gated; override via
|
|
74
|
-
// /set or a profile (context-limit).
|
|
75
|
-
'claude-sonnet-5': 200_000,
|
|
76
|
-
'claude-sonnet-5-latest': 200_000,
|
|
77
|
-
// Claude Fable 5 defaults to the Claude Code / subscription 200K context
|
|
78
|
-
// window. The advertised 1M window is API-only and plan-gated; override via
|
|
79
|
-
// /set or a profile (context-limit). Mirrors getContextWindowForModel.
|
|
80
|
-
'claude-fable-5': 200_000,
|
|
81
|
-
'claude-fable-5-latest': 200_000,
|
|
82
|
-
'claude-3-7-opus-20250115': 300_000,
|
|
83
|
-
'claude-3-7-sonnet-20250115': 300_000,
|
|
84
|
-
'claude-3-opus-20240229': 200_000,
|
|
85
|
-
'claude-3-sonnet-20240229': 200_000,
|
|
86
|
-
'claude-3-haiku-20240307': 200_000,
|
|
87
|
-
'claude-3.5-sonnet-20240620': 200_000,
|
|
88
|
-
'claude-3.5-sonnet-20241022': 200_000,
|
|
89
|
-
'claude-3.5-haiku-20241022': 200_000,
|
|
90
|
-
'claude-3-5-sonnet-20241022': 200_000,
|
|
91
|
-
'claude-3-5-haiku-20241022': 200_000,
|
|
92
|
-
};
|
|
6
|
+
import { ModelLimitsCatalogSchema } from './model-limits.schema.js';
|
|
7
|
+
import catalogData from './model-limits.json' with { type: 'json' };
|
|
8
|
+
// Catalog corruption is a release/configuration error. Validate eagerly so an
|
|
9
|
+
// invalid package fails deterministically instead of silently using stale limits.
|
|
10
|
+
const CATALOG = ModelLimitsCatalogSchema.parse(catalogData);
|
|
11
|
+
export const DEFAULT_TOKEN_LIMIT = CATALOG.defaultLimit;
|
|
93
12
|
function matchesAnyPrefix(model, prefixes) {
|
|
94
13
|
return prefixes.some((prefix) => model.startsWith(prefix));
|
|
95
14
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
15
|
+
function assertUnreachableRule(rule) {
|
|
16
|
+
throw new Error(`Unsupported model-limit rule: ${JSON.stringify(rule)}`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a single catalog's ordered rules against a model id + provider
|
|
20
|
+
* prefix. Exported so that the case-insensitive normalization can be tested
|
|
21
|
+
* with any catalog (including mixed-case fixtures) without type assertions.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveOrderedRuleFromCatalog(catalog, modelWithoutPrefix, providerPrefix) {
|
|
24
|
+
for (const rule of catalog.orderedRules) {
|
|
25
|
+
switch (rule.type) {
|
|
26
|
+
case 'substring':
|
|
27
|
+
if (modelWithoutPrefix.includes(rule.substring)) {
|
|
28
|
+
return rule.limit;
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
case 'substringOrProviderPrefix':
|
|
32
|
+
if (modelWithoutPrefix.includes(rule.substring) ||
|
|
33
|
+
providerPrefix === rule.providerPrefix) {
|
|
34
|
+
return rule.limit;
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
case 'prefixGroup':
|
|
38
|
+
if (matchesAnyPrefix(modelWithoutPrefix, rule.prefixes)) {
|
|
39
|
+
return rule.limit;
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case 'substringCaseInsensitive':
|
|
43
|
+
if (modelWithoutPrefix
|
|
44
|
+
.toLowerCase()
|
|
45
|
+
.includes(rule.substring.toLowerCase())) {
|
|
46
|
+
return rule.limit;
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
return assertUnreachableRule(rule);
|
|
100
51
|
}
|
|
101
52
|
}
|
|
102
53
|
return undefined;
|
|
103
54
|
}
|
|
55
|
+
function resolveOrderedRule(modelWithoutPrefix, providerPrefix) {
|
|
56
|
+
return resolveOrderedRuleFromCatalog(CATALOG, modelWithoutPrefix, providerPrefix);
|
|
57
|
+
}
|
|
104
58
|
export function tokenLimit(model, userContextLimit) {
|
|
105
59
|
// If user has set a context limit, use it
|
|
106
60
|
if (userContextLimit !== undefined && userContextLimit > 0) {
|
|
@@ -111,50 +65,20 @@ export function tokenLimit(model, userContextLimit) {
|
|
|
111
65
|
const providerPrefix = colonIndex !== -1 ? model.slice(0, colonIndex) : '';
|
|
112
66
|
const modelWithoutPrefix = colonIndex !== -1 ? model.slice(colonIndex + 1) : model;
|
|
113
67
|
// Check exact model matches first
|
|
114
|
-
|
|
115
|
-
|
|
68
|
+
const exactLimit = CATALOG.exactLimits[modelWithoutPrefix];
|
|
69
|
+
if (typeof exactLimit === 'number') {
|
|
70
|
+
return exactLimit;
|
|
116
71
|
}
|
|
117
72
|
// Check prefix-based limits
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// Codex models default to 256K context (per composition/aliases/codex.config).
|
|
123
|
-
// variant has a smaller 128K window and must be checked first since its ID
|
|
124
|
-
// also contains the substring "codex". Non-suffixed codex model IDs
|
|
125
|
-
// (gpt-5.5, gpt-5.4, gpt-5.2, gpt-5.1) are only resolvable when the
|
|
126
|
-
// provider prefix is explicitly "codex" — a bare ID is ambiguous and could
|
|
127
|
-
// belong to the regular OpenAI provider.
|
|
128
|
-
if (modelWithoutPrefix.includes('codex-spark')) {
|
|
129
|
-
return 131_072;
|
|
130
|
-
}
|
|
131
|
-
if (modelWithoutPrefix.includes('codex') || providerPrefix === 'codex') {
|
|
132
|
-
return 262_144;
|
|
133
|
-
}
|
|
134
|
-
// Check OpenAI 200K models (includes o3, o1 series)
|
|
135
|
-
if (matchesAnyPrefix(modelWithoutPrefix, OPENAI_200K_PREFIXES)) {
|
|
136
|
-
return 200_000;
|
|
137
|
-
}
|
|
138
|
-
// Check OpenAI 128K models
|
|
139
|
-
if (matchesAnyPrefix(modelWithoutPrefix, OPENAI_128K_PREFIXES)) {
|
|
140
|
-
return 128_000;
|
|
141
|
-
}
|
|
142
|
-
// Claude Sonnet 5 dated snapshot variants (e.g. claude-sonnet-5-YYYYMMDD)
|
|
143
|
-
// are not individually exact-keyed above; resolve them to the same
|
|
144
|
-
// subscription-safe 200K default as the bare alias and -latest. Mirrors
|
|
145
|
-
// getContextWindowForModel in the anthropic package.
|
|
146
|
-
if (modelWithoutPrefix.toLowerCase().includes('claude-sonnet-5')) {
|
|
147
|
-
return 200_000;
|
|
148
|
-
}
|
|
149
|
-
// Claude Opus 5 dated snapshot variants (e.g. claude-opus-5-YYYYMMDD)
|
|
150
|
-
// resolve to the same subscription-safe 200K default.
|
|
151
|
-
if (modelWithoutPrefix.toLowerCase().includes('claude-opus-5')) {
|
|
152
|
-
return 200_000;
|
|
73
|
+
for (const { prefix, limit } of CATALOG.prefixLimits) {
|
|
74
|
+
if (modelWithoutPrefix.startsWith(prefix)) {
|
|
75
|
+
return limit;
|
|
76
|
+
}
|
|
153
77
|
}
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
return
|
|
78
|
+
// Check ordered data-driven rules (codex, OpenAI groups, Claude substrings)
|
|
79
|
+
const orderedLimit = resolveOrderedRule(modelWithoutPrefix, providerPrefix);
|
|
80
|
+
if (orderedLimit !== undefined) {
|
|
81
|
+
return orderedLimit;
|
|
158
82
|
}
|
|
159
83
|
return DEFAULT_TOKEN_LIMIT;
|
|
160
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenLimits.js","sourceRoot":"","sources":["../../../src/core/tokenLimits.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"tokenLimits.js","sourceRoot":"","sources":["../../../src/core/tokenLimits.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,WAAW,MAAM,qBAAqB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAKpE,8EAA8E;AAC9E,kFAAkF;AAClF,MAAM,OAAO,GAAG,wBAAwB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,mBAAmB,GAAe,OAAO,CAAC,YAAY,CAAC;AAEpE,SAAS,gBAAgB,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AAS,EAAE,CAAC;QAC/B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAC1C,KAAa,EACb,gBAAyB,EACzB,oBAA6B,EAC7B,oBAAuC,UAAU;IAEjD,IAAI,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC5C,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,IAAI,qBAAqB,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAChD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/src/core/turn.d.ts
CHANGED
|
@@ -143,9 +143,18 @@ export declare enum CompressionStatus {
|
|
|
143
143
|
COMPRESSION_FAILED_INFLATED_TOKEN_COUNT = 2,
|
|
144
144
|
/** The compression failed due to an error counting tokens */
|
|
145
145
|
COMPRESSION_FAILED_TOKEN_COUNT_ERROR = 3,
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
/**
|
|
147
|
+
* The compression failed because the model returned an empty summary.
|
|
148
|
+
* Explicit value to avoid colliding with NOOP (issue #2602).
|
|
149
|
+
*/
|
|
150
|
+
COMPRESSION_FAILED_EMPTY_SUMMARY = 7,
|
|
151
|
+
/**
|
|
152
|
+
* Structural compression was a no-op: the strategy determined it could not
|
|
153
|
+
* produce a valid compressed candidate (e.g. no valid middle after split /
|
|
154
|
+
* tool-boundary / last-user-prompt preservation) and returned the history
|
|
155
|
+
* unchanged. Distinct serialized value from COMPRESSION_FAILED_EMPTY_SUMMARY
|
|
156
|
+
* (issue #2602).
|
|
157
|
+
*/
|
|
149
158
|
NOOP = 4,
|
|
150
159
|
/** Compression ran recently and did not reduce tokens further */
|
|
151
160
|
ALREADY_COMPRESSED = 5,
|
|
@@ -164,6 +173,14 @@ export declare enum PerformCompressionResult {
|
|
|
164
173
|
SKIPPED_EMPTY = "skipped_empty",
|
|
165
174
|
/** Compression skipped due to cooldown after repeated failures */
|
|
166
175
|
SKIPPED_COOLDOWN = "skipped_cooldown",
|
|
176
|
+
/**
|
|
177
|
+
* Structural compression was a no-op: the configured strategy (and, for
|
|
178
|
+
* middle-out, the one-shot fallback) determined it could not produce a valid
|
|
179
|
+
* compressed candidate and returned history unchanged. Distinct from skips
|
|
180
|
+
* (which never attempted) and from FAILED (which attempted and threw).
|
|
181
|
+
* (issue #2602)
|
|
182
|
+
*/
|
|
183
|
+
NOOP = "noop",
|
|
167
184
|
/** Compression was attempted but all strategies failed */
|
|
168
185
|
FAILED = "failed"
|
|
169
186
|
}
|
package/dist/src/core/turn.js
CHANGED
|
@@ -51,9 +51,18 @@ export var CompressionStatus;
|
|
|
51
51
|
CompressionStatus[CompressionStatus["COMPRESSION_FAILED_INFLATED_TOKEN_COUNT"] = 2] = "COMPRESSION_FAILED_INFLATED_TOKEN_COUNT";
|
|
52
52
|
/** The compression failed due to an error counting tokens */
|
|
53
53
|
CompressionStatus[CompressionStatus["COMPRESSION_FAILED_TOKEN_COUNT_ERROR"] = 3] = "COMPRESSION_FAILED_TOKEN_COUNT_ERROR";
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The compression failed because the model returned an empty summary.
|
|
56
|
+
* Explicit value to avoid colliding with NOOP (issue #2602).
|
|
57
|
+
*/
|
|
58
|
+
CompressionStatus[CompressionStatus["COMPRESSION_FAILED_EMPTY_SUMMARY"] = 7] = "COMPRESSION_FAILED_EMPTY_SUMMARY";
|
|
59
|
+
/**
|
|
60
|
+
* Structural compression was a no-op: the strategy determined it could not
|
|
61
|
+
* produce a valid compressed candidate (e.g. no valid middle after split /
|
|
62
|
+
* tool-boundary / last-user-prompt preservation) and returned the history
|
|
63
|
+
* unchanged. Distinct serialized value from COMPRESSION_FAILED_EMPTY_SUMMARY
|
|
64
|
+
* (issue #2602).
|
|
65
|
+
*/
|
|
57
66
|
CompressionStatus[CompressionStatus["NOOP"] = 4] = "NOOP";
|
|
58
67
|
/** Compression ran recently and did not reduce tokens further */
|
|
59
68
|
CompressionStatus[CompressionStatus["ALREADY_COMPRESSED"] = 5] = "ALREADY_COMPRESSED";
|
|
@@ -73,6 +82,14 @@ export var PerformCompressionResult;
|
|
|
73
82
|
PerformCompressionResult["SKIPPED_EMPTY"] = "skipped_empty";
|
|
74
83
|
/** Compression skipped due to cooldown after repeated failures */
|
|
75
84
|
PerformCompressionResult["SKIPPED_COOLDOWN"] = "skipped_cooldown";
|
|
85
|
+
/**
|
|
86
|
+
* Structural compression was a no-op: the configured strategy (and, for
|
|
87
|
+
* middle-out, the one-shot fallback) determined it could not produce a valid
|
|
88
|
+
* compressed candidate and returned history unchanged. Distinct from skips
|
|
89
|
+
* (which never attempted) and from FAILED (which attempted and threw).
|
|
90
|
+
* (issue #2602)
|
|
91
|
+
*/
|
|
92
|
+
PerformCompressionResult["NOOP"] = "noop";
|
|
76
93
|
/** Compression was attempted but all strategies failed */
|
|
77
94
|
PerformCompressionResult["FAILED"] = "failed";
|
|
78
95
|
})(PerformCompressionResult || (PerformCompressionResult = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn.js","sourceRoot":"","sources":["../../../src/core/turn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAK/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAE1C,uFAAuF;AACvF,MAAM,CAAC,MAAM,2BAA2B,GAAG,8BAA8B,CAAC;AAiB1E,MAAM,CAAN,IAAY,cA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