@claudexor/harness-codex 3.9.7 → 3.10.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/dist/effort-gate.d.ts +4 -5
- package/dist/effort-gate.d.ts.map +1 -1
- package/dist/effort-gate.js +4 -5
- package/dist/effort-gate.js.map +1 -1
- package/dist/effort-probe.d.ts +6 -6
- package/dist/effort-probe.d.ts.map +1 -1
- package/dist/effort-probe.js +11 -7
- package/dist/effort-probe.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/model-auth.d.ts +21 -0
- package/dist/model-auth.d.ts.map +1 -0
- package/dist/model-auth.js +202 -0
- package/dist/model-auth.js.map +1 -0
- package/dist/model.d.ts +11 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +217 -0
- package/dist/model.js.map +1 -0
- package/dist/pricing.d.ts +8 -12
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js +14 -24
- package/dist/pricing.js.map +1 -1
- package/dist/responses.d.ts +18 -0
- package/dist/responses.d.ts.map +1 -0
- package/dist/responses.js +389 -0
- package/dist/responses.js.map +1 -0
- package/dist/retry-signals.d.ts.map +1 -1
- package/dist/retry-signals.js +1 -1
- package/dist/retry-signals.js.map +1 -1
- package/dist/vendor-cli-version.js +1 -1
- package/package.json +5 -5
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ModelAdapter } from "@claudexor/core";
|
|
2
|
+
import type { ModelCatalogEntry } from "@claudexor/schema";
|
|
3
|
+
import { type CodexModelAuthDeps } from "./model-auth.js";
|
|
4
|
+
export interface CodexModelAdapterDeps extends CodexModelAuthDeps {
|
|
5
|
+
fetch?: typeof fetch;
|
|
6
|
+
}
|
|
7
|
+
/** Exact backend metadata only; no CLI alias list, compaction limit, or historical default. */
|
|
8
|
+
export declare function parseCodexModelCatalog(value: unknown): ModelCatalogEntry[];
|
|
9
|
+
/** One adapter-owned generation, with the official CLI owning token refresh. */
|
|
10
|
+
export declare function createCodexModelAdapter(deps?: CodexModelAdapterDeps): ModelAdapter;
|
|
11
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,YAAY,EAA4B,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAA+B,iBAAiB,EAAc,MAAM,mBAAmB,CAAC;AAEpG,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAgBzB,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAiCD,+FAA+F;AAC/F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,EAAE,CAuD1E;AAkDD,gFAAgF;AAChF,wBAAgB,uBAAuB,CAAC,IAAI,GAAE,qBAA0B,GAAG,YAAY,CAgItF"}
|
package/dist/model.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { validateModel } from "@claudexor/core";
|
|
2
|
+
import { CLAUDEXOR_VERSION } from "@claudexor/util";
|
|
3
|
+
import { prepareCodexModelAuth, } from "./model-auth.js";
|
|
4
|
+
import { buildResponsesRequest, CodexModelError, emptyModelResult, providerProblem, readResponsesStream, record, text, validateCodexModelOptions, } from "./responses.js";
|
|
5
|
+
import { CODEX_VENDOR_CLI_VERSION } from "./vendor-cli-version.js";
|
|
6
|
+
const ENDPOINT = "https://chatgpt.com/backend-api/codex";
|
|
7
|
+
const CLIENT = "claudexor";
|
|
8
|
+
function headers(auth) {
|
|
9
|
+
return {
|
|
10
|
+
Authorization: `Bearer ${auth.accessToken}`,
|
|
11
|
+
"ChatGPT-Account-ID": auth.accountId,
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
originator: CLIENT,
|
|
14
|
+
"User-Agent": `${CLIENT}/${CLAUDEXOR_VERSION}`,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function capacity(value) {
|
|
18
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : null;
|
|
19
|
+
}
|
|
20
|
+
/** An expired/opaque access token's 401 is not proof that a new login is needed. */
|
|
21
|
+
function authenticatedProblem(response, body, auth, now) {
|
|
22
|
+
const problem = providerProblem(response.status, body, response.headers);
|
|
23
|
+
return response.status === 401 && (auth.expiresAt === null || auth.expiresAt <= now)
|
|
24
|
+
? new CodexModelError("auth_refresh_failed", "Codex refused access credentials whose freshness could not be confirmed.", problem.context).problem
|
|
25
|
+
: problem;
|
|
26
|
+
}
|
|
27
|
+
/** Exact backend metadata only; no CLI alias list, compaction limit, or historical default. */
|
|
28
|
+
export function parseCodexModelCatalog(value) {
|
|
29
|
+
const models = record(value)?.models;
|
|
30
|
+
if (!Array.isArray(models))
|
|
31
|
+
throw new CodexModelError("catalog_unavailable", "Codex did not return a model catalog.");
|
|
32
|
+
// Mirror ModelsManager::build_available_models + mark_default_by_picker_visibility
|
|
33
|
+
// using THIS account's metadata. Incomplete metadata does not invent a default.
|
|
34
|
+
const hasPriority = models.every((value) => {
|
|
35
|
+
const item = record(value);
|
|
36
|
+
return (Number.isSafeInteger(item?.priority) &&
|
|
37
|
+
["list", "hide", "none"].includes(String(item?.visibility)));
|
|
38
|
+
});
|
|
39
|
+
const ordered = hasPriority
|
|
40
|
+
? [...models].sort((a, b) => Number(record(a)?.priority) - Number(record(b)?.priority))
|
|
41
|
+
: models;
|
|
42
|
+
const defaultEntry = hasPriority
|
|
43
|
+
? (ordered.find((value) => record(value)?.visibility === "list") ?? ordered[0])
|
|
44
|
+
: null;
|
|
45
|
+
return ordered.map((value) => {
|
|
46
|
+
const entry = record(value), id = text(entry?.slug);
|
|
47
|
+
if (!entry || !id)
|
|
48
|
+
throw new CodexModelError("catalog_unavailable", "Codex returned an invalid model catalog entry.");
|
|
49
|
+
const efforts = Array.isArray(entry.supported_reasoning_levels)
|
|
50
|
+
? entry.supported_reasoning_levels
|
|
51
|
+
.map((item) => text(record(item)?.effort))
|
|
52
|
+
.filter((item) => item !== null)
|
|
53
|
+
: [];
|
|
54
|
+
const modalities = Array.isArray(entry.input_modalities)
|
|
55
|
+
? entry.input_modalities.filter((item) => typeof item === "string")
|
|
56
|
+
: [];
|
|
57
|
+
return {
|
|
58
|
+
id,
|
|
59
|
+
label: text(entry.display_name),
|
|
60
|
+
isDefault: value === defaultEntry,
|
|
61
|
+
contextWindow: capacity(entry.context_window),
|
|
62
|
+
maxContextWindow: capacity(entry.max_context_window),
|
|
63
|
+
// Backend output-cap parameters are unsupported even when a model has a published output capacity.
|
|
64
|
+
maxOutputTokens: capacity(entry.max_output_tokens),
|
|
65
|
+
inputModalities: modalities,
|
|
66
|
+
reasoningEfforts: efforts,
|
|
67
|
+
defaultReasoningEffort: text(entry.default_reasoning_level),
|
|
68
|
+
supportedOptions: [
|
|
69
|
+
"toolChoice",
|
|
70
|
+
"cacheKey",
|
|
71
|
+
"serviceTier",
|
|
72
|
+
...(efforts.length ? ["reasoningEffort"] : []),
|
|
73
|
+
...(entry.supports_parallel_tool_calls === true ? ["parallelToolCalls"] : []),
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async function catalogFor(auth, context, fetcher, now) {
|
|
79
|
+
context.signal.throwIfAborted();
|
|
80
|
+
let response;
|
|
81
|
+
try {
|
|
82
|
+
response = await fetcher(`${ENDPOINT}/models?client_version=${CODEX_VENDOR_CLI_VERSION}`, {
|
|
83
|
+
headers: headers(auth),
|
|
84
|
+
signal: context.signal,
|
|
85
|
+
redirect: "error",
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
context.signal.throwIfAborted();
|
|
90
|
+
throw new CodexModelError("catalog_unavailable", "The selected Codex account's catalog could not be reached.", {}, true);
|
|
91
|
+
}
|
|
92
|
+
let body = null;
|
|
93
|
+
try {
|
|
94
|
+
body = await response.json();
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
if (response.ok)
|
|
98
|
+
throw new CodexModelError("catalog_unavailable", "Codex returned an unreadable model catalog.");
|
|
99
|
+
}
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
const problem = authenticatedProblem(response, body, auth, now());
|
|
102
|
+
const code = problem.code === "provider_failed" ? "catalog_unavailable" : problem.code;
|
|
103
|
+
throw new CodexModelError(code, problem.message, problem.context, problem.retryable);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
source: "codex",
|
|
107
|
+
credentialProfileId: context.profile.profile_id,
|
|
108
|
+
accountFingerprint: auth.accountFingerprint,
|
|
109
|
+
observedAt: new Date(now()).toISOString(),
|
|
110
|
+
provenance: `codex.backend.models; client_version=${CODEX_VENDOR_CLI_VERSION}; default=vendor-priority-and-visibility`,
|
|
111
|
+
models: parseCodexModelCatalog(body),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** One adapter-owned generation, with the official CLI owning token refresh. */
|
|
115
|
+
export function createCodexModelAdapter(deps = {}) {
|
|
116
|
+
const fetcher = deps.fetch ?? globalThis.fetch;
|
|
117
|
+
const now = deps.now ?? Date.now;
|
|
118
|
+
return {
|
|
119
|
+
id: "codex",
|
|
120
|
+
async catalog(context) {
|
|
121
|
+
const auth = await prepareCodexModelAuth(context.profile, context.signal, deps);
|
|
122
|
+
return catalogFor(auth, context, fetcher, now);
|
|
123
|
+
},
|
|
124
|
+
async invoke(request, context) {
|
|
125
|
+
let route = {
|
|
126
|
+
source: "codex",
|
|
127
|
+
credentialProfileId: context.profile.profile_id,
|
|
128
|
+
accountFingerprint: null,
|
|
129
|
+
model: request.model,
|
|
130
|
+
};
|
|
131
|
+
let dispatched = false;
|
|
132
|
+
try {
|
|
133
|
+
if (request.source !== "codex" ||
|
|
134
|
+
(request.account.mode === "pin" &&
|
|
135
|
+
request.account.profileId !== context.profile.profile_id)) {
|
|
136
|
+
throw new CodexModelError("invalid_request", "The selected profile does not match the requested Codex route.");
|
|
137
|
+
}
|
|
138
|
+
// Refuse unsupported explicit options before auth helpers, catalog I/O, or dispatch.
|
|
139
|
+
validateCodexModelOptions(request.options);
|
|
140
|
+
const auth = await prepareCodexModelAuth(context.profile, context.signal, deps);
|
|
141
|
+
route = { ...route, accountFingerprint: auth.accountFingerprint };
|
|
142
|
+
const discovered = context.catalog;
|
|
143
|
+
if (discovered &&
|
|
144
|
+
(discovered.source !== route.source ||
|
|
145
|
+
discovered.credentialProfileId !== route.credentialProfileId ||
|
|
146
|
+
discovered.accountFingerprint !== auth.accountFingerprint))
|
|
147
|
+
throw new CodexModelError("auth_changed", "The managed Codex account changed after model discovery.");
|
|
148
|
+
// The caller may hand off this operation's exact-account catalog.
|
|
149
|
+
// Unknown identity cannot authorize reuse, but remains a usable route:
|
|
150
|
+
// obtain fresh metadata rather than inventing a fingerprint or a limit.
|
|
151
|
+
const catalog = discovered?.accountFingerprint
|
|
152
|
+
? discovered
|
|
153
|
+
: await catalogFor(auth, context, fetcher, now);
|
|
154
|
+
const checked = validateModel(request.model, catalog.models.map((model) => model.id), "api");
|
|
155
|
+
const model = catalog.models.find((entry) => entry.id === request.model);
|
|
156
|
+
if (checked.status !== "ok" || !model)
|
|
157
|
+
throw new CodexModelError("model_unavailable", "The requested model is not in this account's Codex model catalog.");
|
|
158
|
+
if (request.options.reasoningEffort &&
|
|
159
|
+
!model.reasoningEfforts.includes(request.options.reasoningEffort)) {
|
|
160
|
+
throw new CodexModelError("unsupported_parameter", "The requested reasoning effort is not advertised for this model.", { parameter: "reasoningEffort" });
|
|
161
|
+
}
|
|
162
|
+
const body = JSON.stringify(buildResponsesRequest(request, route));
|
|
163
|
+
const requestHeaders = new Headers(headers(auth));
|
|
164
|
+
if (request.options.cacheKey !== undefined) {
|
|
165
|
+
try {
|
|
166
|
+
requestHeaders.set("session_id", request.options.cacheKey);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
throw new CodexModelError("unsupported_parameter", "The requested cacheKey cannot be represented in a Codex HTTP header.", { parameter: "cacheKey" });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// HTTP header validation is preparation, not evidence of a physical send.
|
|
173
|
+
context.signal.throwIfAborted();
|
|
174
|
+
await context.onDispatch(route);
|
|
175
|
+
dispatched = true;
|
|
176
|
+
const response = await fetcher(`${ENDPOINT}/responses`, {
|
|
177
|
+
method: "POST",
|
|
178
|
+
headers: requestHeaders,
|
|
179
|
+
body,
|
|
180
|
+
signal: context.signal,
|
|
181
|
+
redirect: "error",
|
|
182
|
+
});
|
|
183
|
+
if (!response.ok) {
|
|
184
|
+
const result = emptyModelResult({ ...route, model: null });
|
|
185
|
+
let error = null;
|
|
186
|
+
try {
|
|
187
|
+
error = await response.json();
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
/* HTTP status remains an authoritative refusal. */
|
|
191
|
+
}
|
|
192
|
+
result.problem = authenticatedProblem(response, error, auth, now());
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
return await readResponsesStream(response, route);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
const result = emptyModelResult({ ...route, model: null });
|
|
199
|
+
result.outcome = dispatched ? "unknown" : "failed";
|
|
200
|
+
result.problem =
|
|
201
|
+
error instanceof CodexModelError
|
|
202
|
+
? error.problem
|
|
203
|
+
: new CodexModelError(dispatched
|
|
204
|
+
? "transport_unknown"
|
|
205
|
+
: context.signal.aborted
|
|
206
|
+
? "cancelled"
|
|
207
|
+
: "model_unavailable", dispatched
|
|
208
|
+
? "The Codex generation outcome is unknown; it was not retried."
|
|
209
|
+
: context.signal.aborted
|
|
210
|
+
? "The model operation was cancelled before dispatch."
|
|
211
|
+
: "The Codex model request could not be prepared.").problem;
|
|
212
|
+
return result;
|
|
213
|
+
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,CAAC,CAAC,CAAC,QAAQ,CAAC;gBACnD,MAAM,CAAC,OAAO;oBACZ,KAAK,YAAY,eAAe;wBAC9B,CAAC,CAAC,KAAK,CAAC,OAAO;wBACf,CAAC,CAAC,IAAI,eAAe,CACjB,UAAU;4BACR,CAAC,CAAC,mBAAmB;4BACrB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO;gCACtB,CAAC,CAAC,WAAW;gCACb,CAAC,CAAC,mBAAmB,EACzB,UAAU;4BACR,CAAC,CAAC,8DAA8D;4BAChE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO;gCACtB,CAAC,CAAC,oDAAoD;gCACtD,CAAC,CAAC,gDAAgD,CACvD,CAAC,OAAO,CAAC;gBAChB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/pricing.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Codex
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* (not "exact") signal — honest about its provenance.
|
|
7
|
-
*
|
|
8
|
-
* Prices are approximate USD per 1M tokens and can drift; override per model via
|
|
9
|
-
* env: CLAUDEXOR_CODEX_PRICE_INPUT / _OUTPUT / _CACHED (USD per 1M tokens).
|
|
2
|
+
* Codex reports token usage, not a dollar cost. Only explicitly configured
|
|
3
|
+
* CLAUDEXOR_CODEX_PRICE_INPUT / _OUTPUT / _CACHED rates (USD per 1M tokens)
|
|
4
|
+
* may produce an estimate. Without a rate for every used token category,
|
|
5
|
+
* cost remains unknown; the budget owner handles subscription cash separately.
|
|
10
6
|
*/
|
|
11
7
|
export interface TokenUsage {
|
|
12
8
|
input_tokens?: number;
|
|
@@ -14,11 +10,11 @@ export interface TokenUsage {
|
|
|
14
10
|
cached_input_tokens?: number;
|
|
15
11
|
}
|
|
16
12
|
interface Price {
|
|
17
|
-
input: number;
|
|
18
|
-
output: number;
|
|
19
|
-
cached: number;
|
|
13
|
+
input: number | undefined;
|
|
14
|
+
output: number | undefined;
|
|
15
|
+
cached: number | undefined;
|
|
20
16
|
}
|
|
21
|
-
export declare function priceForModel(
|
|
17
|
+
export declare function priceForModel(_model: string | null | undefined): Price;
|
|
22
18
|
/**
|
|
23
19
|
* Estimate USD cost from token usage. Returns undefined when no usable token
|
|
24
20
|
* counts are present (so we never fabricate a zero/spurious cost).
|
package/dist/pricing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AASD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAMtE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,KAAK,EAAE,UAAU,GAChB,MAAM,GAAG,SAAS,CAwBpB"}
|
package/dist/pricing.js
CHANGED
|
@@ -1,31 +1,15 @@
|
|
|
1
|
-
// Approximate public list prices (USD / 1M tokens). Matched by substring so
|
|
2
|
-
// versioned model ids (gpt-5.1-codex, gpt-5-codex, ...) resolve to a family.
|
|
3
|
-
// ORDER MATTERS: mini/nano rows come FIRST — a `gpt-5.x-mini` must resolve to
|
|
4
|
-
// the mini price, not fall into the broad gpt-5 row above it (that ordering
|
|
5
|
-
// bug over-estimated mini turns ~8x in the budget ledger).
|
|
6
|
-
const TABLE = [
|
|
7
|
-
{ match: /mini|nano/i, price: { input: 0.15, output: 0.6, cached: 0.075 } },
|
|
8
|
-
{
|
|
9
|
-
match: /gpt-5[.\d]*-codex|gpt-5[.\d]*-pro/i,
|
|
10
|
-
price: { input: 1.25, output: 10, cached: 0.125 },
|
|
11
|
-
},
|
|
12
|
-
{ match: /gpt-5|o3|o4/i, price: { input: 1.25, output: 10, cached: 0.125 } },
|
|
13
|
-
{ match: /gpt-4o|gpt-4\.1/i, price: { input: 2.5, output: 10, cached: 1.25 } },
|
|
14
|
-
];
|
|
15
|
-
const DEFAULT_PRICE = { input: 1.25, output: 10, cached: 0.125 };
|
|
16
1
|
function envNum(name) {
|
|
17
2
|
const v = process.env[name];
|
|
18
|
-
if (v === undefined)
|
|
3
|
+
if (v === undefined || v.trim() === "")
|
|
19
4
|
return undefined;
|
|
20
|
-
const n = Number
|
|
21
|
-
return Number.isFinite(n) ? n : undefined;
|
|
5
|
+
const n = Number(v);
|
|
6
|
+
return Number.isFinite(n) && n >= 0 ? n : undefined;
|
|
22
7
|
}
|
|
23
|
-
export function priceForModel(
|
|
24
|
-
const base = TABLE.find((e) => model && e.match.test(model))?.price ?? DEFAULT_PRICE;
|
|
8
|
+
export function priceForModel(_model) {
|
|
25
9
|
return {
|
|
26
|
-
input: envNum("CLAUDEXOR_CODEX_PRICE_INPUT")
|
|
27
|
-
output: envNum("CLAUDEXOR_CODEX_PRICE_OUTPUT")
|
|
28
|
-
cached: envNum("CLAUDEXOR_CODEX_PRICE_CACHED")
|
|
10
|
+
input: envNum("CLAUDEXOR_CODEX_PRICE_INPUT"),
|
|
11
|
+
output: envNum("CLAUDEXOR_CODEX_PRICE_OUTPUT"),
|
|
12
|
+
cached: envNum("CLAUDEXOR_CODEX_PRICE_CACHED"),
|
|
29
13
|
};
|
|
30
14
|
}
|
|
31
15
|
/**
|
|
@@ -46,7 +30,13 @@ export function estimateCodexCostUsd(model, usage) {
|
|
|
46
30
|
// twice (once inside input_tokens at the full input rate, once at the cached
|
|
47
31
|
// rate), over-reporting codex spend by up to ~4x on cache-heavy turns.
|
|
48
32
|
const nonCached = Math.max(0, input - cached);
|
|
49
|
-
|
|
33
|
+
if ((nonCached > 0 && p.input === undefined) ||
|
|
34
|
+
(output > 0 && p.output === undefined) ||
|
|
35
|
+
(cached > 0 && p.cached === undefined))
|
|
36
|
+
return undefined;
|
|
37
|
+
const usd = (nonCached / 1e6) * (p.input ?? 0) +
|
|
38
|
+
(output / 1e6) * (p.output ?? 0) +
|
|
39
|
+
(cached / 1e6) * (p.cached ?? 0);
|
|
50
40
|
return Number.isFinite(usd) ? usd : undefined;
|
|
51
41
|
}
|
|
52
42
|
//# sourceMappingURL=pricing.js.map
|
package/dist/pricing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAkBA,SAAS,MAAM,CAAC,IAAY;IAC1B,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IACzD,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAiC;IAC7D,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,6BAA6B,CAAC;QAC5C,MAAM,E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IAAI,CAAC,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ControlProblem, ModelCallOptions, ModelCallRequest, ModelCallResult, ModelRoute, ModelUsage } from "@claudexor/schema";
|
|
2
|
+
export declare const CODEX_CONTINUATION_FORMAT = "codex.responses.v1";
|
|
3
|
+
/** Carries only deliberate public diagnostics, never a provider body or credentials. */
|
|
4
|
+
export declare class CodexModelError extends Error {
|
|
5
|
+
readonly problem: ControlProblem;
|
|
6
|
+
constructor(code: string, message: string, context?: Record<string, unknown>, retryable?: boolean);
|
|
7
|
+
}
|
|
8
|
+
export declare function record(value: unknown): Record<string, unknown> | null;
|
|
9
|
+
export declare function text(value: unknown): string | null;
|
|
10
|
+
export declare function responseUsage(value: unknown): ModelUsage;
|
|
11
|
+
export declare function emptyModelResult(route: ModelRoute): ModelCallResult;
|
|
12
|
+
export declare function validateCodexModelOptions(options: ModelCallOptions): void;
|
|
13
|
+
/** Pure request translation. The first system message is the actual instructions field. */
|
|
14
|
+
export declare function buildResponsesRequest(request: ModelCallRequest, route: ModelRoute): Record<string, unknown>;
|
|
15
|
+
export declare function providerProblem(status: number | null, value: unknown, headers?: Headers): ControlProblem;
|
|
16
|
+
/** SSE frames use a streaming UTF-8 decoder. Only a provider terminal makes a response final. */
|
|
17
|
+
export declare function readResponsesStream(response: Response, selected: ModelRoute): Promise<ModelCallResult>;
|
|
18
|
+
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../src/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAEf,UAAU,EACV,UAAU,EACX,MAAM,mBAAmB,CAAC;A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