@kodelyth/codex 2026.5.40 → 2026.5.42
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/client-ChMX13_o.js +642 -0
- package/dist/client-factory-D3dIsp4Y.js +9 -0
- package/dist/command-formatters-BRW7_Nu7.js +519 -0
- package/dist/command-handlers-P2IqtXaZ.js +1462 -0
- package/dist/compact-baos5flR.js +329 -0
- package/dist/computer-use-VfLvTMaa.js +367 -0
- package/dist/config-CezENx_E.js +510 -0
- package/dist/doctor-contract-api.js +53 -0
- package/dist/harness.js +51 -0
- package/dist/index.js +1133 -0
- package/dist/media-understanding-provider.js +335 -0
- package/dist/models-B9DhrIwD.js +110 -0
- package/dist/node-cli-sessions-De4_DuFw.js +1216 -0
- package/dist/plugin-activation-BlMuJeXz.js +452 -0
- package/dist/prompt-overlay.js +12 -0
- package/dist/protocol-C9UWI98H.js +9 -0
- package/dist/protocol-validators-BGBspNmF.js +5988 -0
- package/dist/provider-catalog.js +84 -0
- package/dist/provider-discovery.js +33 -0
- package/dist/provider.js +150 -0
- package/dist/rate-limit-cache-CHuacE27.js +24 -0
- package/dist/request-CTQKUxaa.js +89 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/run-attempt-DqV2OU1R.js +5366 -0
- package/dist/session-binding-3PzU7ZTW.js +222 -0
- package/dist/shared-client-Cnyr9dyT.js +631 -0
- package/dist/side-question-CP5XlA0U.js +667 -0
- package/dist/test-api.js +45 -0
- package/dist/thread-lifecycle-DBJetBuV.js +1561 -0
- package/dist/vision-tools-Cl_5a93K.js +1379 -0
- package/doctor-contract-api.test.ts +44 -0
- package/doctor-contract-api.ts +68 -0
- package/harness.ts +72 -0
- package/index.test.ts +230 -0
- package/index.ts +66 -0
- package/klaw.plugin.json +24 -85
- package/media-understanding-provider.test.ts +486 -0
- package/media-understanding-provider.ts +521 -0
- package/package.json +3 -3
- package/prompt-overlay-runtime-contract.test.ts +48 -0
- package/prompt-overlay.ts +21 -0
- package/provider-catalog.ts +83 -0
- package/provider-discovery.ts +45 -0
- package/provider.test.ts +384 -0
- package/provider.ts +243 -0
- package/src/app-server/app-inventory-cache.test.ts +176 -0
- package/src/app-server/app-inventory-cache.ts +324 -0
- package/src/app-server/approval-bridge.test.ts +1471 -0
- package/src/app-server/approval-bridge.ts +1211 -0
- package/src/app-server/auth-bridge.test.ts +1449 -0
- package/src/app-server/auth-bridge.ts +614 -0
- package/src/app-server/auth-profile-runtime-contract.test.ts +239 -0
- package/src/app-server/capabilities.ts +27 -0
- package/src/app-server/client-factory.ts +24 -0
- package/src/app-server/client.test.ts +563 -0
- package/src/app-server/client.ts +715 -0
- package/src/app-server/compact.test.ts +710 -0
- package/src/app-server/compact.ts +500 -0
- package/src/app-server/computer-use.test.ts +788 -0
- package/src/app-server/computer-use.ts +683 -0
- package/src/app-server/config.test.ts +879 -0
- package/src/app-server/config.ts +1038 -0
- package/src/app-server/context-engine-projection.test.ts +252 -0
- package/src/app-server/context-engine-projection.ts +403 -0
- package/src/app-server/delivery-no-reply-runtime-contract.test.ts +80 -0
- package/src/app-server/dynamic-tool-diagnostics.ts +73 -0
- package/src/app-server/dynamic-tool-profile.ts +69 -0
- package/src/app-server/dynamic-tools.test.ts +1302 -0
- package/src/app-server/dynamic-tools.ts +623 -0
- package/src/app-server/elicitation-bridge.test.ts +1056 -0
- package/src/app-server/elicitation-bridge.ts +783 -0
- package/src/app-server/event-projector.test.ts +2668 -0
- package/src/app-server/event-projector.ts +2057 -0
- package/src/app-server/image-payload-sanitizer.test.ts +49 -0
- package/src/app-server/image-payload-sanitizer.ts +167 -0
- package/src/app-server/klaw-owned-tool-runtime-contract.test.ts +456 -0
- package/src/app-server/local-runtime-attribution.ts +39 -0
- package/src/app-server/managed-binary.test.ts +139 -0
- package/src/app-server/managed-binary.ts +193 -0
- package/src/app-server/models.test.ts +246 -0
- package/src/app-server/models.ts +172 -0
- package/src/app-server/native-hook-relay.test.ts +271 -0
- package/src/app-server/native-hook-relay.ts +150 -0
- package/src/app-server/native-subagent-task-mirror.test.ts +573 -0
- package/src/app-server/native-subagent-task-mirror.ts +497 -0
- package/src/app-server/outcome-fallback-runtime-contract.test.ts +404 -0
- package/src/app-server/plugin-activation.test.ts +336 -0
- package/src/app-server/plugin-activation.ts +283 -0
- package/src/app-server/plugin-app-cache-key.ts +74 -0
- package/src/app-server/plugin-approval-roundtrip.ts +122 -0
- package/src/app-server/plugin-inventory.test.ts +355 -0
- package/src/app-server/plugin-inventory.ts +357 -0
- package/src/app-server/plugin-thread-config.test.ts +865 -0
- package/src/app-server/plugin-thread-config.ts +455 -0
- package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +33 -0
- package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +199 -0
- package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +102 -0
- package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +227 -0
- package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +2630 -0
- package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +2630 -0
- package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +1659 -0
- package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +1655 -0
- package/src/app-server/protocol-validators.test.ts +75 -0
- package/src/app-server/protocol-validators.ts +203 -0
- package/src/app-server/protocol.ts +520 -0
- package/src/app-server/rate-limit-cache.ts +48 -0
- package/src/app-server/rate-limits.test.ts +202 -0
- package/src/app-server/rate-limits.ts +583 -0
- package/src/app-server/request.ts +73 -0
- package/src/app-server/run-attempt.context-engine.test.ts +1004 -0
- package/src/app-server/run-attempt.test.ts +9477 -0
- package/src/app-server/run-attempt.ts +4683 -0
- package/src/app-server/run-attempt.vision-tools.test.ts +35 -0
- package/src/app-server/schema-normalization-runtime-contract.test.ts +206 -0
- package/src/app-server/session-binding.test.ts +303 -0
- package/src/app-server/session-binding.ts +398 -0
- package/src/app-server/session-history.ts +44 -0
- package/src/app-server/shared-client.test.ts +589 -0
- package/src/app-server/shared-client.ts +289 -0
- package/src/app-server/side-question.test.ts +1175 -0
- package/src/app-server/side-question.ts +1007 -0
- package/src/app-server/test-support.ts +48 -0
- package/src/app-server/thread-lifecycle.test.ts +447 -0
- package/src/app-server/thread-lifecycle.ts +939 -0
- package/src/app-server/thread-lifecycle.user-mcp-servers.test.ts +442 -0
- package/src/app-server/timeout.ts +9 -0
- package/src/app-server/tool-progress-normalization.ts +77 -0
- package/src/app-server/trajectory.test.ts +205 -0
- package/src/app-server/trajectory.ts +365 -0
- package/src/app-server/transcript-mirror.test.ts +524 -0
- package/src/app-server/transcript-mirror.ts +208 -0
- package/src/app-server/transcript-repair-runtime-contract.test.ts +44 -0
- package/src/app-server/transport-stdio.test.ts +171 -0
- package/src/app-server/transport-stdio.ts +107 -0
- package/src/app-server/transport-websocket.test.ts +69 -0
- package/src/app-server/transport-websocket.ts +90 -0
- package/src/app-server/transport.ts +117 -0
- package/src/app-server/user-input-bridge.test.ts +249 -0
- package/src/app-server/user-input-bridge.ts +316 -0
- package/src/app-server/version.ts +4 -0
- package/src/app-server/vision-tools.ts +12 -0
- package/src/command-account.ts +544 -0
- package/src/command-formatters.ts +425 -0
- package/src/command-handlers.ts +2004 -0
- package/src/command-rpc.test.ts +16 -0
- package/src/command-rpc.ts +142 -0
- package/src/commands.test.ts +3312 -0
- package/src/commands.ts +65 -0
- package/src/conversation-binding-data.ts +124 -0
- package/src/conversation-binding.test.ts +599 -0
- package/src/conversation-binding.ts +561 -0
- package/src/conversation-control.test.ts +126 -0
- package/src/conversation-control.ts +303 -0
- package/src/conversation-turn-collector.test.ts +191 -0
- package/src/conversation-turn-collector.ts +186 -0
- package/src/conversation-turn-input.test.ts +141 -0
- package/src/conversation-turn-input.ts +106 -0
- package/src/manifest.test.ts +20 -0
- package/src/migration/apply.ts +501 -0
- package/src/migration/helpers.ts +55 -0
- package/src/migration/plan.ts +461 -0
- package/src/migration/provider.test.ts +1741 -0
- package/src/migration/provider.ts +41 -0
- package/src/migration/source.ts +643 -0
- package/src/migration/targets.ts +25 -0
- package/src/node-cli-sessions.test.ts +180 -0
- package/src/node-cli-sessions.ts +711 -0
- package/test-api.ts +82 -0
- package/tsconfig.json +16 -0
- package/doctor-contract-api.js +0 -7
- package/harness.js +0 -7
- package/index.js +0 -7
- package/media-understanding-provider.js +0 -7
- package/prompt-overlay.js +0 -7
- package/provider-catalog.js +0 -7
- package/provider-discovery.js +0 -7
- package/provider.js +0 -7
- package/test-api.js +0 -7
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
formatCodexUsageLimitErrorMessage,
|
|
4
|
+
resolveCodexUsageLimitResetAtMs,
|
|
5
|
+
summarizeCodexAccountUsage,
|
|
6
|
+
summarizeCodexRateLimits,
|
|
7
|
+
} from "./rate-limits.js";
|
|
8
|
+
|
|
9
|
+
describe("formatCodexUsageLimitErrorMessage", () => {
|
|
10
|
+
it("preserves Codex retry hints when structured reset windows are absent", () => {
|
|
11
|
+
const message = formatCodexUsageLimitErrorMessage({
|
|
12
|
+
message:
|
|
13
|
+
"You've hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/codex/settings/usage to purchase more credits or try again at May 11th, 2026 9:00 AM.",
|
|
14
|
+
codexErrorInfo: "usageLimitExceeded",
|
|
15
|
+
rateLimits: {
|
|
16
|
+
rateLimits: {
|
|
17
|
+
limitId: "codex",
|
|
18
|
+
primary: { usedPercent: 100, windowDurationMins: 300, resetsAt: null },
|
|
19
|
+
secondary: null,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
nowMs: Date.UTC(2026, 4, 10, 23, 0, 0),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
expect(message).toContain("You've reached your Codex subscription usage limit.");
|
|
26
|
+
expect(message).toContain("Codex says to try again at May 11th, 2026 9:00 AM.");
|
|
27
|
+
expect(message).not.toContain("Codex did not return a reset time");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("accepts snake_case rate limit snapshots from Codex core payloads", () => {
|
|
31
|
+
const message = formatCodexUsageLimitErrorMessage({
|
|
32
|
+
message: "You've reached your usage limit.",
|
|
33
|
+
codexErrorInfo: "usageLimitExceeded",
|
|
34
|
+
rateLimits: {
|
|
35
|
+
rate_limits: {
|
|
36
|
+
limit_id: "codex",
|
|
37
|
+
primary: { used_percent: 100, window_minutes: 300, resets_at: 1_700_003_600 },
|
|
38
|
+
secondary: null,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
nowMs: 1_700_000_000_000,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
expect(message).toContain("Next reset in 1 hour, ");
|
|
45
|
+
expect(message).toMatch(/\b[A-Z][a-z]{2} \d{1,2}(?:, \d{4})? at \d{1,2}:\d{2} [AP]M\b/u);
|
|
46
|
+
expect(message).not.toMatch(/\(\d{4}-\d{2}-\d{2}T/u);
|
|
47
|
+
expect(message).not.toContain("Codex did not return a reset time");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("Codex rate limit blocking resets", () => {
|
|
52
|
+
it("keeps subscriptions blocked until all exhausted windows reset", () => {
|
|
53
|
+
const nowMs = 1_700_000_000_000;
|
|
54
|
+
const shortTermReset = Math.ceil(nowMs / 1000) + 60 * 60;
|
|
55
|
+
const weeklyReset = Math.ceil(nowMs / 1000) + 24 * 60 * 60;
|
|
56
|
+
const payload = {
|
|
57
|
+
rateLimitsByLimitId: {
|
|
58
|
+
codex: {
|
|
59
|
+
limitId: "codex",
|
|
60
|
+
primary: { usedPercent: 100, windowDurationMins: 300, resetsAt: shortTermReset },
|
|
61
|
+
secondary: { usedPercent: 100, windowDurationMins: 10_080, resetsAt: weeklyReset },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
expect(resolveCodexUsageLimitResetAtMs(payload, nowMs)).toBe(weeklyReset * 1000);
|
|
67
|
+
expect(summarizeCodexAccountUsage(payload, nowMs)?.blockedUntilMs).toBe(weeklyReset * 1000);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("summarizeCodexRateLimits", () => {
|
|
72
|
+
it("formats status limits like provider usage summaries", () => {
|
|
73
|
+
const nowMs = 1_700_000_000_000;
|
|
74
|
+
const nowSeconds = nowMs / 1000;
|
|
75
|
+
|
|
76
|
+
expect(
|
|
77
|
+
summarizeCodexRateLimits(
|
|
78
|
+
{
|
|
79
|
+
rateLimits: {
|
|
80
|
+
limitId: "codex",
|
|
81
|
+
limitName: "Codex",
|
|
82
|
+
primary: {
|
|
83
|
+
usedPercent: 26,
|
|
84
|
+
windowDurationMins: 300,
|
|
85
|
+
resetsAt: nowSeconds + 3 * 60 * 60,
|
|
86
|
+
},
|
|
87
|
+
secondary: {
|
|
88
|
+
usedPercent: 4,
|
|
89
|
+
windowDurationMins: 7 * 24 * 60,
|
|
90
|
+
resetsAt: nowSeconds + 7 * 24 * 60 * 60,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
nowMs,
|
|
95
|
+
),
|
|
96
|
+
).toBe("Codex: primary 74% left ⏱3h · secondary 96% left ⏱7d");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("ignores empty named buckets instead of showing them as available limits", () => {
|
|
100
|
+
const nowMs = 1_700_000_000_000;
|
|
101
|
+
const payload = {
|
|
102
|
+
rateLimitsByLimitId: {
|
|
103
|
+
premium: {
|
|
104
|
+
limitId: "premium",
|
|
105
|
+
limitName: "premium",
|
|
106
|
+
primary: null,
|
|
107
|
+
secondary: null,
|
|
108
|
+
credits: null,
|
|
109
|
+
planType: "pro",
|
|
110
|
+
rateLimitReachedType: null,
|
|
111
|
+
},
|
|
112
|
+
codex: {
|
|
113
|
+
limitId: "codex",
|
|
114
|
+
limitName: "Codex",
|
|
115
|
+
primary: {
|
|
116
|
+
usedPercent: 5,
|
|
117
|
+
windowDurationMins: 300,
|
|
118
|
+
resetsAt: Math.ceil(nowMs / 1000) + 3600,
|
|
119
|
+
},
|
|
120
|
+
secondary: null,
|
|
121
|
+
credits: null,
|
|
122
|
+
planType: "pro",
|
|
123
|
+
rateLimitReachedType: null,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
expect(summarizeCodexRateLimits(payload, nowMs)).toContain("Codex: primary 95% left ⏱1h");
|
|
129
|
+
expect(summarizeCodexRateLimits(payload, nowMs)).not.toContain("premium");
|
|
130
|
+
expect(summarizeCodexAccountUsage(payload, nowMs)?.usageLine).toBe("short-term 5%");
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("does not render a server-reported usage-limit block as available", () => {
|
|
134
|
+
const payload = {
|
|
135
|
+
rateLimits: {
|
|
136
|
+
limitId: "codex",
|
|
137
|
+
limitName: "Codex",
|
|
138
|
+
primary: null,
|
|
139
|
+
secondary: null,
|
|
140
|
+
credits: null,
|
|
141
|
+
rateLimitReachedType: "rate_limit_reached",
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
expect(summarizeCodexRateLimits(payload, 1_700_000_000_000)).toBe("Codex: rate limit reached");
|
|
146
|
+
expect(summarizeCodexAccountUsage(payload, 1_700_000_000_000)).toMatchObject({
|
|
147
|
+
blocked: true,
|
|
148
|
+
blockingReason: "Codex usage limit is reached",
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("ignores metadata-only Codex buckets", () => {
|
|
153
|
+
expect(
|
|
154
|
+
summarizeCodexRateLimits({
|
|
155
|
+
rateLimitsByLimitId: {
|
|
156
|
+
codex: {
|
|
157
|
+
limitId: "codex",
|
|
158
|
+
limitName: "Codex",
|
|
159
|
+
primary: null,
|
|
160
|
+
secondary: null,
|
|
161
|
+
credits: null,
|
|
162
|
+
planType: "plus",
|
|
163
|
+
rateLimitReachedType: null,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
}),
|
|
167
|
+
).toBeUndefined();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("keeps displayable buckets when sibling buckets are empty", () => {
|
|
171
|
+
const nowMs = 1_700_000_000_000;
|
|
172
|
+
const nowSeconds = nowMs / 1000;
|
|
173
|
+
|
|
174
|
+
expect(
|
|
175
|
+
summarizeCodexRateLimits(
|
|
176
|
+
{
|
|
177
|
+
rateLimitsByLimitId: {
|
|
178
|
+
codex: {
|
|
179
|
+
limitId: "codex",
|
|
180
|
+
limitName: "Codex",
|
|
181
|
+
primary: { usedPercent: 26, windowDurationMins: 300, resetsAt: nowSeconds + 3600 },
|
|
182
|
+
secondary: null,
|
|
183
|
+
credits: null,
|
|
184
|
+
planType: "plus",
|
|
185
|
+
rateLimitReachedType: null,
|
|
186
|
+
},
|
|
187
|
+
"gpt-5.3-codex-spark": {
|
|
188
|
+
limitId: "gpt-5.3-codex-spark",
|
|
189
|
+
limitName: "GPT 5.3 Codex Spark",
|
|
190
|
+
primary: null,
|
|
191
|
+
secondary: null,
|
|
192
|
+
credits: null,
|
|
193
|
+
planType: "plus",
|
|
194
|
+
rateLimitReachedType: null,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
nowMs,
|
|
199
|
+
),
|
|
200
|
+
).toBe("Codex: primary 74% left ⏱1h");
|
|
201
|
+
});
|
|
202
|
+
});
|