@trazum/core 3.0.1 → 3.0.2
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 +1 -1
- package/dist/claude-model-pricing.d.ts +73 -0
- package/dist/claude-model-pricing.d.ts.map +1 -0
- package/dist/claude-model-pricing.js +208 -0
- package/dist/claude-model-pricing.js.map +1 -0
- package/dist/config-schema.d.ts +14 -1
- package/dist/config-schema.d.ts.map +1 -1
- package/dist/config-schema.js +24 -0
- package/dist/config-schema.js.map +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +1 -1
- package/dist/node.js.map +1 -1
- package/dist/otlp.d.ts +103 -0
- package/dist/otlp.d.ts.map +1 -1
- package/dist/otlp.js +185 -0
- package/dist/otlp.js.map +1 -1
- package/dist/partner-model-id.d.ts +26 -0
- package/dist/partner-model-id.d.ts.map +1 -0
- package/dist/partner-model-id.js +60 -0
- package/dist/partner-model-id.js.map +1 -0
- package/dist/plan-edit.d.ts +99 -0
- package/dist/plan-edit.d.ts.map +1 -0
- package/dist/plan-edit.js +142 -0
- package/dist/plan-edit.js.map +1 -0
- package/dist/plan.d.ts +63 -2
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +55 -0
- package/dist/plan.js.map +1 -1
- package/dist/pricing.d.ts +19 -0
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js +32 -0
- package/dist/pricing.js.map +1 -1
- package/dist/prometheus.d.ts +42 -0
- package/dist/prometheus.d.ts.map +1 -0
- package/dist/prometheus.js +112 -0
- package/dist/prometheus.js.map +1 -0
- package/dist/receipt.d.ts +2 -1
- package/dist/receipt.d.ts.map +1 -1
- package/dist/receipt.js +11 -1
- package/dist/receipt.js.map +1 -1
- package/dist/session-waste.d.ts +145 -0
- package/dist/session-waste.d.ts.map +1 -0
- package/dist/session-waste.js +489 -0
- package/dist/session-waste.js.map +1 -0
- package/dist/structure.js +3 -3
- package/dist/structure.js.map +1 -1
- package/dist/tokenizer.d.ts +9 -0
- package/dist/tokenizer.d.ts.map +1 -1
- package/dist/tokenizer.js +1 -1
- package/dist/tokenizer.js.map +1 -1
- package/dist/verify.d.ts +11 -1
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +54 -0
- package/dist/verify.js.map +1 -1
- package/dist/walk.d.ts +14 -0
- package/dist/walk.d.ts.map +1 -1
- package/dist/walk.js +35 -0
- package/dist/walk.js.map +1 -1
- package/package.json +1 -1
- package/src/claude-model-pricing.ts +245 -0
- package/src/config-schema.ts +44 -0
- package/src/index.ts +46 -4
- package/src/node.ts +1 -1
- package/src/otlp.ts +281 -0
- package/src/partner-model-id.ts +69 -0
- package/src/plan-edit.ts +180 -0
- package/src/plan.ts +104 -3
- package/src/pricing.ts +33 -0
- package/src/prometheus.ts +131 -0
- package/src/receipt.ts +16 -2
- package/src/session-waste.ts +570 -0
- package/src/structure.ts +3 -3
- package/src/tokenizer.ts +1 -1
- package/src/verify.ts +78 -2
- package/src/walk.ts +33 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Claude model as Amazon Bedrock or Google Cloud's Vertex AI names it (#858).
|
|
3
|
+
*
|
|
4
|
+
* Claude Code on those platforms records the platform's id: on Bedrock a
|
|
5
|
+
* cross-region inference profile such as `us.anthropic.claude-sonnet-4-6` or
|
|
6
|
+
* `us.anthropic.claude-haiku-4-5-20251001-v1:0`, on Vertex `claude-sonnet-4-5@20250929`.
|
|
7
|
+
* The forms are the ones Claude Code's own pages show, read 2026-11-21
|
|
8
|
+
* (code.claude.com/docs/en/amazon-bedrock, .../google-vertex-ai): the profile
|
|
9
|
+
* prefixes `us`, `eu`, `apac`, `jp`, `au`, `global` and `us-gov`, the
|
|
10
|
+
* `anthropic.` namespace, an optional `-YYYYMMDD` and an optional `-vN:M`; and
|
|
11
|
+
* Vertex's `@YYYYMMDD`.
|
|
12
|
+
*
|
|
13
|
+
* **Read, never priced.** Each platform sets its own prices, and the catalogue
|
|
14
|
+
* carries Anthropic's. So this only says which platform and which model a
|
|
15
|
+
* refused id names, so the reader can price it from the platform's page. An
|
|
16
|
+
* application inference profile ARN is opaque and is not read at all.
|
|
17
|
+
*/
|
|
18
|
+
const PROFILE_PREFIXES = ['us-gov', 'us', 'eu', 'apac', 'jp', 'au', 'global'];
|
|
19
|
+
const DIGITS = /^\d+$/;
|
|
20
|
+
const WORD = /^[a-z0-9]+$/;
|
|
21
|
+
/**
|
|
22
|
+
* A Claude id as Anthropic writes it: `claude`, then one or more hyphenated
|
|
23
|
+
* words of lowercase letters and digits. Read by splitting, not by one pattern
|
|
24
|
+
* with a repeated group, so no input can make it backtrack.
|
|
25
|
+
*/
|
|
26
|
+
function isClaudeId(value) {
|
|
27
|
+
const words = value.split('-');
|
|
28
|
+
return words.length >= 2 && words[0] === 'claude' && words.slice(1).every((word) => WORD.test(word));
|
|
29
|
+
}
|
|
30
|
+
/** The id without a Bedrock version such as `-v1` or `-v1:0`. */
|
|
31
|
+
function withoutVersion(value) {
|
|
32
|
+
const at = value.lastIndexOf('-v');
|
|
33
|
+
if (at === -1)
|
|
34
|
+
return value;
|
|
35
|
+
// A major and at most one minor, each all digits: `1` or `1:0`.
|
|
36
|
+
const parts = value.slice(at + 2).split(':');
|
|
37
|
+
const isVersion = parts.length <= 2 && parts.every((part) => DIGITS.test(part));
|
|
38
|
+
return isVersion ? value.slice(0, at) : value;
|
|
39
|
+
}
|
|
40
|
+
/** The platform and model a Bedrock or Vertex id names, or `undefined` for any other id. */
|
|
41
|
+
export function partnerModelId(id) {
|
|
42
|
+
// Bedrock: an optional profile prefix, the `anthropic.` namespace, the id, an optional version.
|
|
43
|
+
const dot = id.indexOf('.');
|
|
44
|
+
const prefix = dot === -1 ? '' : id.slice(0, dot);
|
|
45
|
+
const rest = PROFILE_PREFIXES.includes(prefix) ? id.slice(dot + 1) : id;
|
|
46
|
+
if (rest.startsWith('anthropic.')) {
|
|
47
|
+
const model = withoutVersion(rest.slice('anthropic.'.length));
|
|
48
|
+
return isClaudeId(model) ? { platform: 'bedrock', model } : undefined;
|
|
49
|
+
}
|
|
50
|
+
// Vertex: the id, `@`, an eight-digit date.
|
|
51
|
+
const at = id.indexOf('@');
|
|
52
|
+
if (at !== -1) {
|
|
53
|
+
const model = id.slice(0, at);
|
|
54
|
+
const date = id.slice(at + 1);
|
|
55
|
+
if (isClaudeId(model) && date.length === 8 && DIGITS.test(date))
|
|
56
|
+
return { platform: 'vertex', model: `${model}-${date}` };
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=partner-model-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partner-model-id.js","sourceRoot":"","sources":["../src/partner-model-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC9E,MAAM,MAAM,GAAG,OAAO,CAAC;AACvB,MAAM,IAAI,GAAG,aAAa,CAAC;AAE3B;;;;GAIG;AACH,SAAS,UAAU,CAAC,KAAa;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,iEAAiE;AACjE,SAAS,cAAc,CAAC,KAAa;IACnC,MAAM,E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AAC,SAAS,CAAC;IACxE,CAAC;IACD,4CAA4C;IAC5C,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC9B,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,IAAI,EAAE,EAAE,CAAC;IAC5H,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plan action that is an edit to a tracked file (#796).
|
|
3
|
+
*
|
|
4
|
+
* Everything else in a plan is advice a person carries out somewhere Trazum
|
|
5
|
+
* cannot see: move these calls, batch those. An edit is different, because
|
|
6
|
+
* Trazum already writes the new text: `optimize` at the `safe` level trims a
|
|
7
|
+
* prompt, and `reorderForCache` moves its stable blocks in front of the first
|
|
8
|
+
* placeholder. Until now that text was printed and the plan stopped. This
|
|
9
|
+
* module makes the edit a plan action, and gives whoever applies it, later
|
|
10
|
+
* and elsewhere, a way to make exactly that edit and nothing else.
|
|
11
|
+
*
|
|
12
|
+
* Three rules, each a refusal:
|
|
13
|
+
*
|
|
14
|
+
* - **Only the deterministic steps.** An edit is `reorder`, `trim`, or both,
|
|
15
|
+
* recomputed from the file when it is applied. No model writes any of it,
|
|
16
|
+
* and a plan has no field that could carry text somebody else wrote.
|
|
17
|
+
* - **Only the file the plan saw.** The file is hashed when the plan is made
|
|
18
|
+
* and again when the edit is applied; a file that moved on in between is
|
|
19
|
+
* refused, not merged.
|
|
20
|
+
* - **Only the text the plan promised.** The recomputed text is hashed and
|
|
21
|
+
* held to the plan's hash, so a change in the rules between the two runs is
|
|
22
|
+
* a refusal rather than a different edit under the same name.
|
|
23
|
+
*
|
|
24
|
+
* No saving is projected. The figure an edit is expected against is the
|
|
25
|
+
* workload's bill as the log measured it (`detail.baseline`); the file's
|
|
26
|
+
* tokens before and after are the estimator's, and are labelled as such
|
|
27
|
+
* wherever they are shown. `trazum verify` reads the file and the newer log
|
|
28
|
+
* and says whether the edit landed and whether the calls got shorter.
|
|
29
|
+
*
|
|
30
|
+
* Browser-safe like the rest of the core: the hash is passed in, because the
|
|
31
|
+
* core imports no Node builtin and SubtleCrypto is asynchronous.
|
|
32
|
+
*/
|
|
33
|
+
import type { PlanAction, PlanEdit, PlanEditStep } from './plan.js';
|
|
34
|
+
import type { PricingCatalogue } from './pricing.js';
|
|
35
|
+
import type { UsageProfileReport } from './usage.js';
|
|
36
|
+
/** SHA-256 of a text, lowercase hex. The caller supplies it. */
|
|
37
|
+
export type PlanDigest = (text: string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether a path is a file an edit may rewrite whole.
|
|
40
|
+
*
|
|
41
|
+
* A source file is not a prompt. `optimize` once rewrote `import OpenAI` into
|
|
42
|
+
* `Import OpenAI` in somebody's TypeScript, and an edit that replaces a whole
|
|
43
|
+
* file must never be pointed at one.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isEditableFile(path: string): boolean;
|
|
46
|
+
/** Runs an edit's steps over a text, in order. Pure and deterministic. */
|
|
47
|
+
export declare function runPlanEditSteps(text: string, edit: Pick<PlanEdit, 'steps' | 'disabledRules' | 'minPrefixTokens'>): string;
|
|
48
|
+
export interface PlanFileEditInput {
|
|
49
|
+
report: UsageProfileReport;
|
|
50
|
+
/** The workload the configuration says sends this file. */
|
|
51
|
+
label: string;
|
|
52
|
+
/** Relative to the repository root, forward slashes. */
|
|
53
|
+
path: string;
|
|
54
|
+
/** The file's text now. */
|
|
55
|
+
text: string;
|
|
56
|
+
/** `trim` always; `reorder` only when asked for, and first. */
|
|
57
|
+
steps: PlanEditStep[];
|
|
58
|
+
disabledRules: string[];
|
|
59
|
+
pricing: PricingCatalogue;
|
|
60
|
+
digest: PlanDigest;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The `edit-file` action for one file, or null when there is none to make.
|
|
64
|
+
*
|
|
65
|
+
* Null when the workload has no priced traffic in the log (there is then no
|
|
66
|
+
* measured figure to expect the edit against), when the file is a source
|
|
67
|
+
* file, or when the steps change nothing.
|
|
68
|
+
*/
|
|
69
|
+
export declare function planFileEdit(input: PlanFileEditInput): PlanAction | null;
|
|
70
|
+
/** Why an edit could not be applied. */
|
|
71
|
+
export type PlanEditRefusal =
|
|
72
|
+
/** The edit itself is malformed, or names a source file. */
|
|
73
|
+
'not-an-edit'
|
|
74
|
+
/** The file is not the one the plan was made against, nor the one it promised. */
|
|
75
|
+
| 'not-the-planned-file'
|
|
76
|
+
/** The steps, run again on the planned file, did not give the promised text. */
|
|
77
|
+
| 'steps-disagree';
|
|
78
|
+
export type PlanEditApplication =
|
|
79
|
+
/** `changed` is false when the file already holds the promised text. */
|
|
80
|
+
{
|
|
81
|
+
ok: true;
|
|
82
|
+
text: string;
|
|
83
|
+
changed: boolean;
|
|
84
|
+
} | {
|
|
85
|
+
ok: false;
|
|
86
|
+
why: PlanEditRefusal;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Makes the edit again, from the file as it is now, or says why not.
|
|
90
|
+
*
|
|
91
|
+
* The only way to the new text: the steps, run on a file whose hash is the
|
|
92
|
+
* plan's `beforeSha256`, producing a text whose hash is its `afterSha256`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function applyPlanEdit(edit: PlanEdit, current: string, digest: PlanDigest): PlanEditApplication;
|
|
95
|
+
/** The edits a plan carries, in its order. */
|
|
96
|
+
export declare function planEdits(plan: {
|
|
97
|
+
actions: readon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eAAe;AACzB,4DAA4D;AAC1D,aAAa;AACf,kFAAkF;GAChF,sBAAsB;AACxB,gFAAgF;GAC9E,gBAAgB,CAAC;AAErB,MAAM,MAAM,mBAAmB;AAC7B,wEAAwE;AACtE;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC5C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,eAAe,CAAA;CAAE,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,mBAAmB,CAQtG;AAED,8CAA8C;AAC9C,wBAAgB,SAAS,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,SAAS,UAAU,EAAE,CAAA;CAAE,GAAG,QAAQ,EAAE,CAI9E"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plan action that is an edit to a tracked file (#796).
|
|
3
|
+
*
|
|
4
|
+
* Everything else in a plan is advice a person carries out somewhere Trazum
|
|
5
|
+
* cannot see: move these calls, batch those. An edit is different, because
|
|
6
|
+
* Trazum already writes the new text: `optimize` at the `safe` level trims a
|
|
7
|
+
* prompt, and `reorderForCache` moves its stable blocks in front of the first
|
|
8
|
+
* placeholder. Until now that text was printed and the plan stopped. This
|
|
9
|
+
* module makes the edit a plan action, and gives whoever applies it, later
|
|
10
|
+
* and elsewhere, a way to make exactly that edit and nothing else.
|
|
11
|
+
*
|
|
12
|
+
* Three rules, each a refusal:
|
|
13
|
+
*
|
|
14
|
+
* - **Only the deterministic steps.** An edit is `reorder`, `trim`, or both,
|
|
15
|
+
* recomputed from the file when it is applied. No model writes any of it,
|
|
16
|
+
* and a plan has no field that could carry text somebody else wrote.
|
|
17
|
+
* - **Only the file the plan saw.** The file is hashed when the plan is made
|
|
18
|
+
* and again when the edit is applied; a file that moved on in between is
|
|
19
|
+
* refused, not merged.
|
|
20
|
+
* - **Only the text the plan promised.** The recomputed text is hashed and
|
|
21
|
+
* held to the plan's hash, so a change in the rules between the two runs is
|
|
22
|
+
* a refusal rather than a different edit under the same name.
|
|
23
|
+
*
|
|
24
|
+
* No saving is projected. The figure an edit is expected against is the
|
|
25
|
+
* workload's bill as the log measured it (`detail.baseline`); the file's
|
|
26
|
+
* tokens before and after are the estimator's, and are labelled as such
|
|
27
|
+
* wherever they are shown. `trazum verify` reads the file and the newer log
|
|
28
|
+
* and says whether the edit landed and whether the calls got shorter.
|
|
29
|
+
*
|
|
30
|
+
* Browser-safe like the rest of the core: the hash is passed in, because the
|
|
31
|
+
* core imports no Node builtin and SubtleCrypto is asynchronous.
|
|
32
|
+
*/
|
|
33
|
+
import { SOURCE_EXTENSIONS } from './extract.js';
|
|
34
|
+
import { optimize } from './optimize.js';
|
|
35
|
+
import { planEditProblem } from './plan.js';
|
|
36
|
+
import { reorderForCache } from './reorder.js';
|
|
37
|
+
import { estimateTokens } from './tokenizer.js';
|
|
38
|
+
/**
|
|
39
|
+
* Whether a path is a file an edit may rewrite whole.
|
|
40
|
+
*
|
|
41
|
+
* A source file is not a prompt. `optimize` once rewrote `import OpenAI` into
|
|
42
|
+
* `Import OpenAI` in somebody's TypeScript, and an edit that replaces a whole
|
|
43
|
+
* file must never be pointed at one.
|
|
44
|
+
*/
|
|
45
|
+
export function isEditableFile(path) {
|
|
46
|
+
const lower = path.toLowerCase();
|
|
47
|
+
return !SOURCE_EXTENSIONS.some((ext) => lower.endsWith(ext));
|
|
48
|
+
}
|
|
49
|
+
/** Runs an edit's steps over a text, in order. Pure and deterministic. */
|
|
50
|
+
export function runPlanEditSteps(text, edit) {
|
|
51
|
+
let current = text;
|
|
52
|
+
for (const step of edit.steps) {
|
|
53
|
+
if (step === 'reorder') {
|
|
54
|
+
current = reorderForCache(current, { minPrefixTokens: edit.minPrefixTokens }).text;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
current = optimize(current, { level: 'safe', disableRules: edit.disabledRules }).optimized;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return current;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The `edit-file` action for one file, or null when there is none to make.
|
|
64
|
+
*
|
|
65
|
+
* Null when the workload has no priced traffic in the log (there is then no
|
|
66
|
+
* measured figure to expect the edit against), when the file is a source
|
|
67
|
+
* file, or when the steps change nothing.
|
|
68
|
+
*/
|
|
69
|
+
export function planFileEdit(input) {
|
|
70
|
+
if (!isEditableFile(input.path))
|
|
71
|
+
return null;
|
|
72
|
+
const slice = input.report.byLabelAndModel
|
|
73
|
+
.filter((s) => s.label === input.label && s.breakdown.calls > 0)
|
|
74
|
+
.sort((a, b) => b.breakdown.totalUsd - a.breakdown.totalUsd)[0];
|
|
75
|
+
if (slice === undefined)
|
|
76
|
+
return null;
|
|
77
|
+
const minPrefixTokens = input.pricing.byId.get(slice.model)?.cacheMinTokens ?? 0;
|
|
78
|
+
const steps = ['reorder', 'trim'].filter((step) => input.steps.includes(step));
|
|
79
|
+
const after = runPlanEditSteps(input.text, { steps, disabledRules: input.disabledRules, minPrefixTokens });
|
|
80
|
+
if (after === input.text)
|
|
81
|
+
return null;
|
|
82
|
+
const b = slice.breakdown;
|
|
83
|
+
const edit = {
|
|
84
|
+
path: input.path,
|
|
85
|
+
steps,
|
|
86
|
+
level: 'safe',
|
|
87
|
+
disabledRules: [...input.disabledRules],
|
|
88
|
+
minPrefixTokens,
|
|
89
|
+
beforeSha256: input.digest(input.text),
|
|
90
|
+
afterSha256: input.digest(after),
|
|
91
|
+
beforeTokens: estimateTokens(input.text),
|
|
92
|
+
afterTokens: estimateTokens(after),
|
|
93
|
+
};
|
|
94
|
+
// Two texts that differ and hash the same would make every check below
|
|
95
|
+
// meaningless; a digest that does that is not SHA-256.
|
|
96
|
+
if (planEditProblem(edit) !== null)
|
|
97
|
+
return null;
|
|
98
|
+
return {
|
|
99
|
+
kind: 'edit-file',
|
|
100
|
+
label: input.label,
|
|
101
|
+
model: slice.model,
|
|
102
|
+
savingUsd: null,
|
|
103
|
+
stakeUsd: null,
|
|
104
|
+
assumes: [{ kind: 'file-is-what-label-sends', path: input.path }],
|
|
105
|
+
check: 'trazum verify <plan.json> --against <newer-log>',
|
|
106
|
+
detail: {
|
|
107
|
+
baseline: {
|
|
108
|
+
calls: b.calls,
|
|
109
|
+
usd: b.totalUsd,
|
|
110
|
+
inputPerCallTokens: (b.inputTokens + b.cacheReadTokens + b.cacheWriteTokens) / b.calls,
|
|
111
|
+
outputPerCallTokens: b.outputTokens / b.calls,
|
|
112
|
+
},
|
|
113
|
+
edit,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Makes the edit again, from the file as it is now, or says why not.
|
|
119
|
+
*
|
|
120
|
+
* The only way to the new text: the steps, run on a file whose hash is the
|
|
121
|
+
* plan's `beforeSha256`, producing a text whose hash is its `afterSha256`.
|
|
122
|
+
*/
|
|
123
|
+
export function applyPlanEdit(edit, current, digest) {
|
|
124
|
+
if (planEditProblem(edit) !== null || !isEditableFile(edit.path))
|
|
125
|
+
return { ok: false, why: 'not-an-edit' };
|
|
126
|
+
const now = digest(current);
|
|
127
|
+
if (now === edit.afterSha256)
|
|
128
|
+
return { ok: true, text: current, changed: false };
|
|
129
|
+
if (now !== edit.beforeSha256)
|
|
130
|
+
return { ok: false, why: 'not-the-planned-file' };
|
|
131
|
+
const after = runPlanEditSteps(current, edit);
|
|
132
|
+
if (digest(after) !== edit.afterSha256)
|
|
133
|
+
return { ok: false, why: 'steps-disagree' };
|
|
134
|
+
return { ok: true, text: after, changed: true };
|
|
135
|
+
}
|
|
136
|
+
/** The edits a plan carries, in its order. */
|
|
137
|
+
export function planEdits(plan) {
|
|
138
|
+
return plan.actions
|
|
139
|
+
.filter((action) => action.kind === 'edit-file' && action.detail.edit !== undefined)
|
|
140
|
+
.map((action) => action.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;IAC3G,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5B,IAAI,GAAG,KAAK,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACjF,IAAI,GAAG,KAAK,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,sBAAsB,EAAE,CAAC;IACjF,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,CAAC;IACpF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAClD,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,SAAS,CAAC,IAAwC;IAChE,OAAO,IAAI,CAAC,OAAO;SAChB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;SACnF,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAgB,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/plan.d.ts
CHANGED
|
@@ -27,7 +27,48 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import type { UsageProfileReport } from './usage.js';
|
|
29
29
|
import type { BillLevers } from './levers.js';
|
|
30
|
-
export type PlanActionKind = 'route' | 'batch' | 'route+batch' | 'fix-truncation' | 'fix-caching';
|
|
30
|
+
export type PlanActionKind = 'route' | 'batch' | 'route+batch' | 'fix-truncation' | 'fix-caching' | 'edit-file';
|
|
31
|
+
/**
|
|
32
|
+
* What an `edit-file` action does to the file, in the order it does it.
|
|
33
|
+
*
|
|
34
|
+
* `reorder` moves stable blocks ahead of the first placeholder
|
|
35
|
+
* (`reorderForCache`); `trim` runs the `safe` rules (`optimize`). Both are the
|
|
36
|
+
* deterministic transformations this repository already ships, and nothing
|
|
37
|
+
* else is a step: an edit a model wrote cannot be expressed here, which is
|
|
38
|
+
* the point (#796).
|
|
39
|
+
*/
|
|
40
|
+
export type PlanEditStep = 'reorder' | 'trim';
|
|
41
|
+
/** Every step an edit may name, as a value, for the validator below. */
|
|
42
|
+
export declare const PLAN_EDIT_STEPS: readonly PlanEditStep[];
|
|
43
|
+
/**
|
|
44
|
+
* An edit to one tracked file, recorded so it can be made again and checked.
|
|
45
|
+
*
|
|
46
|
+
* **The new text is not stored.** What is stored is the file the plan was
|
|
47
|
+
* made against (`beforeSha256`), what the steps turn it into
|
|
48
|
+
* (`afterSha256`), and what the steps were. Whoever applies the edit reads the
|
|
49
|
+
* file, checks it is the one the plan saw, runs the same steps, and checks the
|
|
50
|
+
* result is the one the plan promised. A plan file edited by hand to carry
|
|
51
|
+
* other text has nowhere to put it.
|
|
52
|
+
*/
|
|
53
|
+
export interface PlanEdit {
|
|
54
|
+
/** The file, relative to the repository root, forward slashes. */
|
|
55
|
+
path: string;
|
|
56
|
+
/** Applied in this order. */
|
|
57
|
+
steps: PlanEditStep[];
|
|
58
|
+
/** The rule level `trim` runs at. Only `safe` is written or accepted. */
|
|
59
|
+
level: 'safe';
|
|
60
|
+
/** Rule ids `trim` leaves off, from the configuration that made the plan. */
|
|
61
|
+
disabledRules: string[];
|
|
62
|
+
/** `reorder`'s bar: the prefix it must reach to move anything, or 0. */
|
|
63
|
+
minPrefixTokens: number;
|
|
64
|
+
/** SHA-256 of the file's text as the plan read it, lowercase hex. */
|
|
65
|
+
beforeSha256: string;
|
|
66
|
+
/** SHA-256 of the text the steps produce from it, lowercase hex. */
|
|
67
|
+
afterSha256: string;
|
|
68
|
+
/** The file's tokens before and after, by the estimator: estimated, not measured. */
|
|
69
|
+
beforeTokens: number;
|
|
70
|
+
afterTokens: number;
|
|
71
|
+
}
|
|
31
72
|
/**
|
|
32
73
|
* What the log cannot confirm, as data rather than prose.
|
|
33
74
|
*
|
|
@@ -56,6 +97,14 @@ export type PlanAssumption =
|
|
|
56
97
|
/** The traffic pattern holds — a cache underwater on this log may pay on other traffic. */
|
|
57
98
|
| {
|
|
58
99
|
kind: 'traffic-pattern-holds';
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The file is what this workload sends. The configuration says so; the log
|
|
103
|
+
* records tokens, not which file they came from.
|
|
104
|
+
*/
|
|
105
|
+
| {
|
|
106
|
+
kind: 'file-is-what-label-sends';
|
|
107
|
+
path: string;
|
|
59
108
|
};
|
|
60
109
|
export interface PlanAction {
|
|
61
110
|
kind: PlanActionKind;
|
|
@@ -66,7 +115,8 @@ export interface PlanAction {
|
|
|
66
115
|
* Projected saving per the log's own period, for route/batch — or null for
|
|
67
116
|
* the measured-stake actions, whose money is in `stakeUsd` instead. Never
|
|
68
117
|
* both: a projection and a measurement in one field is a number that is
|
|
69
|
-
* neither.
|
|
118
|
+
* neither. An `edit-file` action carries neither: its figure is the
|
|
119
|
+
* workload's measured `detail.baseline`, which the edit is expected against.
|
|
70
120
|
*/
|
|
71
121
|
savingUsd: number | null;
|
|
72
122
|
/**
|
|
@@ -99,6 +149,8 @@ export interface PlanAction {
|
|
|
99
149
|
inputPerCallTokens: number;
|
|
100
150
|
outputPerCallTokens: number;
|
|
101
151
|
};
|
|
152
|
+
/** The edit, for `edit-file`. */
|
|
153
|
+
edit?: PlanEdit;
|
|
102
154
|
};
|
|
103
155
|
}
|
|
104
156
|
export interface PlanDocument {
|
|
@@ -149,6 +201,15 @@ export declare function planLabelName(label: string, unlabelled: string): string
|
|
|
149
201
|
* place stops being accepted in the other.
|
|
150
202
|
*/
|
|
151
203
|
export declare const PLAN_ACTION_KINDS: readonly PlanActionKind[];
|
|
204
|
+
/**
|
|
205
|
+
* Why an `edit-file` action's edit is not one, or null when it is.
|
|
206
|
+
*
|
|
207
|
+
* Stricter than the rest of the validator, on purpose: the path here is
|
|
208
|
+
* something a later step reads and writes, so a path that climbs out of the
|
|
209
|
+
* repository, starts at the root, or names git's own directory is refused
|
|
210
|
+
* before anything can act on it.
|
|
211
|
+
*/
|
|
212
|
+
export declare function planEditProblem(raw: unknown): string | null;
|
|
152
213
|
/** Why a file is not a plan, in a shape a caller can render in its own words. */
|
|
153
214
|
export type PlanParseFailure = {
|
|
154
215
|
kind: 'not-json';
|
package/dist/plan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,GAAG,gBAAgB,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,GAAG,gBAAgB,GAAG,aAAa,GAAG,WAAW,CAAC;AAEhH;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9C,wEAAwE;AACxE,eAAO,MAAM,eAAe,EAAE,SAAS,YAAY,EAAwB,CAAC;AAE5E;;;;;;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ACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,cAAc,EAOtD,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CA6B3D;AAED,iFAAiF;AACjF,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,MAAM,MAAM,eAAe,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,YAAY,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACzD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CA+C/D"}
|
package/dist/plan.js
CHANGED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
* number that is neither.
|
|
27
27
|
*/
|
|
28
28
|
import { UNLABELLED, cacheEconomics } from './usage.js';
|
|
29
|
+
/** Every step an edit may name, as a value, for the validator below. */
|
|
30
|
+
export const PLAN_EDIT_STEPS = ['reorder', 'trim'];
|
|
29
31
|
/**
|
|
30
32
|
* Builds the plan from a report and its levers.
|
|
31
33
|
*
|
|
@@ -154,7 +156,52 @@ export const PLAN_ACTION_KINDS = [
|
|
|
154
156
|
'route+batch',
|
|
155
157
|
'fix-truncation',
|
|
156
158
|
'fix-caching',
|
|
159
|
+
'edit-file',
|
|
157
160
|
];
|
|
161
|
+
const HEX64 = /^[0-9a-f]{64}$/;
|
|
162
|
+
/**
|
|
163
|
+
* Why an `edit-file` action's edit is not one, or null when it is.
|
|
164
|
+
*
|
|
165
|
+
* Stricter than the rest of the validator, on purpose: the path here is
|
|
166
|
+
* something a later step reads and writes, so a path that climbs out of the
|
|
167
|
+
* repository, starts at the root, or names git's own directory is refused
|
|
168
|
+
* before anything can act on it.
|
|
169
|
+
*/
|
|
170
|
+
export function planEditProblem(raw) {
|
|
171
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
|
|
172
|
+
return 'detail.edit is not an object';
|
|
173
|
+
const edit = raw;
|
|
174
|
+
const path = edit.path;
|
|
175
|
+
if (typeof path !== 'string' || path.length === 0 || path.length > 1024)
|
|
176
|
+
return 'edit.path is not a path';
|
|
177
|
+
if (path.startsWith('/') ||
|
|
178
|
+
path.includes('\\') ||
|
|
179
|
+
/^[A-Za-z]:/.test(path) ||
|
|
180
|
+
path.split('/').some((part) => part === '' || part === '.' || part === '..' || part.toLowerCase() === '.git') ||
|
|
181
|
+
/[\u0000-\u001f]/.test(path)) {
|
|
182
|
+
return 'edit.path is not a relative path inside the repository';
|
|
183
|
+
}
|
|
184
|
+
if (!Array.isArray(edit.steps) || edit.steps.length === 0 || !edit.steps.every((step) => PLAN_EDIT_STEPS.includes(step))) {
|
|
185
|
+
return `edit.steps is not a list of ${PLAN_EDIT_STEPS.join(', ')}`;
|
|
186
|
+
}
|
|
187
|
+
if (new Set(edit.steps).size !== edit.steps.length)
|
|
188
|
+
return 'edit.steps names a step twice';
|
|
189
|
+
if (edit.level !== 'safe')
|
|
190
|
+
return 'edit.level is not safe';
|
|
191
|
+
if (!Array.isArray(edit.disabledRules) || !edit.disabledRules.every((id) => typeof id === 'string')) {
|
|
192
|
+
return 'edit.disabledRules is not a list of rule ids';
|
|
193
|
+
}
|
|
194
|
+
if (typeof edit.minPrefixTokens !== 'number' || !Number.isFinite(edit.minPrefixTokens) || edit.minPrefixTokens < 0) {
|
|
195
|
+
return 'edit.minPrefixTokens is not a number of 0 or more';
|
|
196
|
+
}
|
|
197
|
+
if (typeof edit.beforeSha256 !== 'string' || !HEX64.test(edit.beforeSha256))
|
|
198
|
+
return 'edit.beforeSha256 is not a SHA-256';
|
|
199
|
+
if (typeof edit.afterSha256 !== 'string' || !HEX64.test(edit.afterSha256))
|
|
200
|
+
return 'edit.afterSha256 is not a SHA-256';
|
|
201
|
+
if (edit.beforeSha256 === edit.afterSha256)
|
|
202
|
+
return 'edit changes nothing';
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
158
205
|
/**
|
|
159
206
|
* Reads a `plan.json` back, or says exactly why it is not one.
|
|
160
207
|
*
|
|
@@ -213,6 +260,14 @@ export function parsePlanDocument(text) {
|
|
|
213
260
|
why: { kind: 'action-malformed', index, because: `kind is not one of ${PLAN_ACTION_KINDS.join(', ')}` },
|
|
214
261
|
};
|
|
215
262
|
}
|
|
263
|
+
// An edit is the one action something later acts on rather than reads,
|
|
264
|
+
// so its detail is checked here, once, for every surface that parses.
|
|
265
|
+
if (action.kind === 'edit-file') {
|
|
266
|
+
const detail = action.detail;
|
|
267
|
+
const problem = planEditProblem(typeof detail === 'object' && detail !== null ? detail.edit : undefined);
|
|
268
|
+
if (problem !== null)
|
|
269
|
+
return { ok: false, why: { kind: 'action-malformed', index, because: problem } };
|
|
270
|
+
}
|
|
216
271
|
}
|
|
217
272
|
return { ok: true, plan: doc };
|
|
218
273
|
}
|
package/dist/plan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA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,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;QACzG,CAAC;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAuD,EAAE,CAAC;AACrF,CAAC"}
|
package/dist/pricing.d.ts
CHANGED
|
@@ -34,6 +34,25 @@ export declare const PROVIDER_REVIEWED: Readonly<Record<string, string>>;
|
|
|
34
34
|
* old this table is wants the answer for the worst part of it, not the best.
|
|
35
35
|
*/
|
|
36
36
|
export declare const PRICING_LAST_REVIEWED: string;
|
|
37
|
+
/**
|
|
38
|
+
* The pages each provider's prices were read from on its `PROVIDER_REVIEWED`
|
|
39
|
+
* date, copied from the comment above that date and from nowhere else.
|
|
40
|
+
*
|
|
41
|
+
* Per provider, because that is how the catalogue records a review: a date
|
|
42
|
+
* per provider, and the pages read that day in prose above it. No model has
|
|
43
|
+
* a source of its own here, and none is implied. Kept as data so that the
|
|
44
|
+
* published dataset (`scripts/pricing-dataset.mjs`, #784) can put a page
|
|
45
|
+
* beside the date on every row without reading prose. Where the comment
|
|
46
|
+
* names an address that has since moved, this holds the one read on the
|
|
47
|
+
* date: Google's prices were read at aistudio.google.com on 2026-11-16, and
|
|
48
|
+
* Mistral's on 2026-11-05 at its inference page and three model cards, not
|
|
49
|
+
* at the `mistral.ai/pricing` that review began from in August.
|
|
50
|
+
*
|
|
51
|
+
* Moves with the date: a re-read that reads another page changes both.
|
|
52
|
+
* `provider-sources.test.js` fails on a provider without pages and on a page
|
|
53
|
+
* the comment above its date does not name.
|
|
54
|
+
*/
|
|
55
|
+
export declare const PROVIDER_SOURCES: Readonly<Record<string, readonly string[]>>;
|
|
37
56
|
/** Cost multipliers relative to the input price. */
|
|
38
57
|
/**
|
|
39
58
|
* The defaults, which are Anthropic's numbers.
|
package/dist/pricing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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AAE,GAAE,IAAiB,EACrB,OAAO,GAAE,UAAe,GACvB,KAAK,CAqHP;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EACxB,SAAS,EAAE,gBAAgB,GAC1B,MAAM,CAgBR;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY,CAKzE;AAED;;;;;;;;;;;;;;;GAeG;AACH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAU5E"}
|
package/dist/pricing.js
CHANGED
|
@@ -207,6 +207,38 @@ export const PROVIDER_REVIEWED = Object.freeze({
|
|
|
207
207
|
* old this table is wants the answer for the worst part of it, not the best.
|
|
208
208
|
*/
|
|
209
209
|
export const PRICING_LAST_REVIEWED = Object.values(PROVIDER_REVIEWED).reduce((oldest, date) => (date < oldest ? date : oldest));
|
|
210
|
+
/**
|
|
211
|
+
* The pages each provider's prices were read from on its `PROVIDER_REVIEWED`
|
|
212
|
+
* date, copied from the comment above that date and from nowhere else.
|
|
213
|
+
*
|
|
214
|
+
* Per provider, because that is how the catalogue records a review: a date
|
|
215
|
+
* per provider, and the pages read that day in prose above it. No model has
|
|
216
|
+
* a source of its own here, and none is implied. Kept as data so that the
|
|
217
|
+
* published dataset (`scripts/pricing-dataset.mjs`, #784) can put a page
|
|
218
|
+
* beside the date on every row without reading prose. Where the comment
|
|
219
|
+
* names an address that has since moved, this holds the one read on the
|
|
220
|
+
* date: Google's prices were read at aistudio.google.com on 2026-11-16, and
|
|
221
|
+
* Mistral's on 2026-11-05 at its inference page and three model cards, not
|
|
222
|
+
* at the `mistral.ai/pricing` that review began from in August.
|
|
223
|
+
*
|
|
224
|
+
* Moves with the date: a re-read that reads another page changes both.
|
|
225
|
+
* `provider-sources.test.js` fails on a provider without pages and on a page
|
|
226
|
+
* the comment above its date does not name.
|
|
227
|
+
*/
|
|
228
|
+
export const PROVIDER_SOURCES = Object.freeze({
|
|
229
|
+
anthropic: Object.freeze(['https://platform.claude.com/docs/en/about-claude/pricing']),
|
|
230
|
+
openai: Object.freeze(['https://developers.openai.com/api/docs/pricing']),
|
|
231
|
+
google: Object.freeze(['https://aistudio.google.com/docs/pricing']),
|
|
232
|
+
moonshot: Object.freeze(['https://platform.kimi.ai/docs/pricing/chat']),
|
|
233
|
+
deepseek: Object.freeze(['https://api-docs.deepseek.com/quick_start/pricing']),
|
|
234
|
+
xai: Object.freeze(['https://docs.x.ai/developers/models']),
|
|
235
|
+
mistral: Object.freeze([
|
|
236
|
+
'https://mistral.ai/cloud/inference/',
|
|
237
|
+
'https://mistral.ai/news/mistral-3/',
|
|
238
|
+
'https://mistral.ai/news/mistral-small-4/',
|
|
239
|
+
'https://mistral.ai/news/vibe-remote-agents-mistral-medium-3-5/',
|
|
240
|
+
]),
|
|
241
|
+
});
|
|
210
242
|
/** Cost multipliers relative to the input price. */
|
|
211
243
|
/**
|
|
212
244
|
* The defaults, which are Anthropic's numbers.
|