@adonis-agora/agent 0.68.0 → 0.70.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/CHANGELOG.md +31 -0
- package/dist/providers/agent_provider.d.ts.map +1 -1
- package/dist/providers/agent_provider.js +12 -1
- package/dist/providers/agent_provider.js.map +1 -1
- package/dist/src/agent-loop.d.ts.map +1 -1
- package/dist/src/agent-loop.js +9 -2
- package/dist/src/agent-loop.js.map +1 -1
- package/dist/src/define_config.d.ts +29 -7
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/engine.d.ts +6 -0
- package/dist/src/engine.d.ts.map +1 -1
- package/dist/src/engine.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/opencode/durable/workflow.d.ts.map +1 -1
- package/dist/src/opencode/durable/workflow.js +12 -5
- package/dist/src/opencode/durable/workflow.js.map +1 -1
- package/dist/src/opencode/engine.d.ts.map +1 -1
- package/dist/src/opencode/engine.js +2 -0
- package/dist/src/opencode/engine.js.map +1 -1
- package/dist/src/opencode/host.d.ts +7 -6
- package/dist/src/opencode/host.d.ts.map +1 -1
- package/dist/src/opencode/host.js.map +1 -1
- package/dist/src/opencode/index.d.ts +1 -1
- package/dist/src/opencode/index.d.ts.map +1 -1
- package/dist/src/opencode/index.js +1 -1
- package/dist/src/opencode/index.js.map +1 -1
- package/dist/src/opencode/runner.d.ts.map +1 -1
- package/dist/src/opencode/runner.js +9 -5
- package/dist/src/opencode/runner.js.map +1 -1
- package/dist/src/opencode/turn.d.ts +69 -8
- package/dist/src/opencode/turn.d.ts.map +1 -1
- package/dist/src/opencode/turn.js +149 -36
- package/dist/src/opencode/turn.js.map +1 -1
- package/dist/src/opencode/turns.d.ts +54 -9
- package/dist/src/opencode/turns.d.ts.map +1 -1
- package/dist/src/opencode/turns.js +83 -30
- package/dist/src/opencode/turns.js.map +1 -1
- package/dist/src/pricing/bedrock.d.ts +64 -0
- package/dist/src/pricing/bedrock.d.ts.map +1 -0
- package/dist/src/pricing/bedrock.js +172 -0
- package/dist/src/pricing/bedrock.js.map +1 -0
- package/dist/src/pricing/boot-pricing.d.ts +60 -11
- package/dist/src/pricing/boot-pricing.d.ts.map +1 -1
- package/dist/src/pricing/boot-pricing.js +192 -38
- package/dist/src/pricing/boot-pricing.js.map +1 -1
- package/dist/src/pricing/models-dev.d.ts +10 -0
- package/dist/src/pricing/models-dev.d.ts.map +1 -1
- package/dist/src/pricing/models-dev.js +27 -8
- package/dist/src/pricing/models-dev.js.map +1 -1
- package/dist/src/pricing/resolve.d.ts +60 -0
- package/dist/src/pricing/resolve.d.ts.map +1 -0
- package/dist/src/pricing/resolve.js +162 -0
- package/dist/src/pricing/resolve.js.map +1 -0
- package/dist/src/spi/agent-store.d.ts +34 -7
- package/dist/src/spi/agent-store.d.ts.map +1 -1
- package/dist/src/spi/agent-store.js +14 -0
- package/dist/src/spi/agent-store.js.map +1 -1
- package/dist/src/stores/ledger-quota-provider.d.ts +11 -2
- package/dist/src/stores/ledger-quota-provider.d.ts.map +1 -1
- package/dist/src/stores/ledger-quota-provider.js +11 -4
- package/dist/src/stores/ledger-quota-provider.js.map +1 -1
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +4 -0
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +2 -5
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +9 -8
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/testing/in-memory-store.d.ts +6 -6
- package/dist/src/testing/in-memory-store.d.ts.map +1 -1
- package/dist/src/testing/in-memory-store.js +6 -9
- package/dist/src/testing/in-memory-store.js.map +1 -1
- package/package.json +1 -1
- package/skills/agent-setup/SKILL.md +9 -5
|
@@ -0,0 +1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AAI,EAAE,gBAAgB,EAAE,IAAI,EAAE;QACjF,mCAAmC;QACnC,cAAc,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE;KAC7F;CACF,CAAC;AAEF,gGAAgG;AAChG,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,SAAuB;IAEvB,MAAM,KAAK,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,KAAK,MAAM,SAAS,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;IACxD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DescribedModel } from '../spi/model-provider.js';
|
|
2
|
-
import { type AgentPricingStore } from '../spi/pricing-store.js';
|
|
2
|
+
import { type AgentPricingStore, type ModelPriceInput } from '../spi/pricing-store.js';
|
|
3
3
|
import { type ModelsDevOptions } from './models-dev.js';
|
|
4
4
|
/** How long the boot check waits for the models.dev catalog when no `signal` is given. */
|
|
5
5
|
export declare const CATALOG_TIMEOUT_MS = 15000;
|
|
@@ -8,17 +8,57 @@ export interface BootPricingLog {
|
|
|
8
8
|
info(message: string): void;
|
|
9
9
|
warn(message: string): void;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* One app-supplied price, as a rate card states it. `input`/`output`/`cacheRead`/`cacheWrite` are in
|
|
13
|
+
* `currency` per `unit` of tokens. Only USD is recorded (the ledger column is `cost_usd`); a row in
|
|
14
|
+
* another currency is refused with a warning rather than recorded as dollars.
|
|
15
|
+
*/
|
|
16
|
+
export interface PriceCatalogEntry {
|
|
17
|
+
/**
|
|
18
|
+
* The model id the price is for. A Bedrock id matches by normalized candidates, so one entry for the
|
|
19
|
+
* base id (`anthropic.claude-sonnet-4-5-20250929-v1:0`) or the profile id (`us-gov.anthropic.…`)
|
|
20
|
+
* also prices the ARN a turn reports (`arn:aws-us-gov:bedrock:…:inference-profile/us-gov.anthropic.…`).
|
|
21
|
+
*/
|
|
22
|
+
model: string;
|
|
23
|
+
input: number;
|
|
24
|
+
output: number;
|
|
25
|
+
/** Cache-read (prompt-cache hit) input tokens. Omit → priced at `input`. */
|
|
26
|
+
cacheRead?: number;
|
|
27
|
+
/** Cache-write input tokens. Omit → priced at `input`. */
|
|
28
|
+
cacheWrite?: number;
|
|
29
|
+
/** Default `'USD'`, the only one accepted. */
|
|
30
|
+
currency?: 'USD';
|
|
31
|
+
/** Default `'1M tokens'`. */
|
|
32
|
+
unit?: '1M tokens' | '1K tokens';
|
|
33
|
+
}
|
|
34
|
+
/** The `priceCatalog` option: where boot seeds missing price rows from. */
|
|
35
|
+
export interface PriceCatalogOptions extends ModelsDevOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Prices the app supplies. Seeded at boot for any model that has NO row yet (an existing row is
|
|
38
|
+
* never overwritten), and before models.dev or the built-in Bedrock table are consulted — so they
|
|
39
|
+
* win over both. Use it for GovCloud / China Bedrock, negotiated rates, or a model models.dev lacks.
|
|
40
|
+
*/
|
|
41
|
+
prices?: readonly PriceCatalogEntry[];
|
|
42
|
+
/**
|
|
43
|
+
* The AWS region Bedrock runs in, for a Bedrock model id that does not name one (a base or `us.`
|
|
44
|
+
* profile id; an ARN or a `us-gov.` id already does). Omit → `AWS_REGION` / `AWS_DEFAULT_REGION`.
|
|
45
|
+
* A GovCloud (`us-gov-*`) or China (`cn-*`) region is never seeded with models.dev's commercial price.
|
|
46
|
+
*/
|
|
47
|
+
region?: string;
|
|
48
|
+
/** `false` → never fetch models.dev (app prices and the built-in Bedrock table still apply). */
|
|
49
|
+
modelsDev?: boolean;
|
|
50
|
+
}
|
|
11
51
|
export interface EnsureModelPricingArgs {
|
|
12
52
|
/** The configured models (`ModelProvider.describeModels()`). */
|
|
13
53
|
models: readonly DescribedModel[];
|
|
14
54
|
/** The bound pricing store; `undefined` → nothing to seed, every non-gateway model is unpriced. */
|
|
15
55
|
pricingStore: AgentPricingStore | undefined;
|
|
16
|
-
/**
|
|
17
|
-
catalog:
|
|
56
|
+
/** Where to seed missing rows from; `false` → no app prices, never fetch models.dev. */
|
|
57
|
+
catalog: PriceCatalogOptions | false;
|
|
18
58
|
log: BootPricingLog;
|
|
19
59
|
}
|
|
20
60
|
export interface EnsureModelPricingResult {
|
|
21
|
-
/** Models a price row was written for
|
|
61
|
+
/** Models a price row was written for (from app prices, the built-in Bedrock table or models.dev). */
|
|
22
62
|
seeded: string[];
|
|
23
63
|
/** Models that will record a `null` cost: no gateway cost and no price row. */
|
|
24
64
|
unpriced: string[];
|
|
@@ -28,14 +68,23 @@ export interface EnsureModelPricingResult {
|
|
|
28
68
|
*
|
|
29
69
|
* A model needs nothing when its provider reports the real cost (a gateway: OpenRouter, the Vercel AI
|
|
30
70
|
* Gateway) — that figure always wins. Every other model is priced off the pricing store, so a model
|
|
31
|
-
* with no row there would record `cost_usd = NULL` on every turn, silently. For each such model
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
71
|
+
* with no row there would record `cost_usd = NULL` on every turn, silently. For each such model a row
|
|
72
|
+
* is written — only when it has NONE, so a price an operator set is never overwritten — from, in order:
|
|
73
|
+
*
|
|
74
|
+
* 1. the app's `priceCatalog.prices`;
|
|
75
|
+
* 2. for a Bedrock model in GovCloud / China, the built-in table (`BEDROCK_BUILTIN_PRICES`) — never
|
|
76
|
+
* models.dev, whose Bedrock prices are the commercial ones;
|
|
77
|
+
* 3. models.dev's current list price.
|
|
78
|
+
*
|
|
79
|
+
* The row is keyed by the exact id the model is configured with (an ARN stays an ARN), which is the id
|
|
80
|
+
* a turn reports and is priced under. Gateway models are seeded too, as the estimate a call that comes
|
|
81
|
+
* back without a cost falls back to.
|
|
35
82
|
*
|
|
36
|
-
* A model still unpriced after that
|
|
37
|
-
*
|
|
38
|
-
*
|
|
83
|
+
* A model still unpriced after that gets one warning line naming it, why, and the `priceCatalog`
|
|
84
|
+
* entry that fixes it. Never throws: this runs at boot, and pricing is bookkeeping, not a reason for
|
|
85
|
+
* the app to stay down.
|
|
39
86
|
*/
|
|
40
87
|
export declare function ensureModelPricing(args: EnsureModelPricingArgs): Promise<EnsureModelPricingResult>;
|
|
88
|
+
/** `priceCatalog.prices` as per-1M USD rows, keyed by model. Invalid entries are warned about and skipped. */
|
|
89
|
+
export declare function normalizePriceEntries(entries: readonly PriceCatalogEntry[], log?: BootPricingLog): Map<string, ModelPriceInput>;
|
|
41
90
|
//# sourceMappingURL=boot-pricing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-pricing.d.ts","sourceRoot":"","sources":["../../../src/pricing/boot-pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"boot-pricing.d.ts","sourceRoot":"","sources":["../../../src/pricing/boot-pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAErB,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAEzB,0FAA0F;AAC1F,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC,8EAA8E;AAC9E,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;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CAAC,CAuC9B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveModelPrice, } from '../spi/pricing-store.js';
|
|
2
|
-
import {
|
|
2
|
+
import { awsPartitionOfRegion, bedrockPriceCandidates, builtinBedrockPrice, isBedrockModel, parseBedrockModelId, } from './bedrock.js';
|
|
3
|
+
import { lookupModelsDevPricesEach, modelsDevRefsFor, } from './models-dev.js';
|
|
3
4
|
/** How long the boot check waits for the models.dev catalog when no `signal` is given. */
|
|
4
5
|
export const CATALOG_TIMEOUT_MS = 15_000;
|
|
5
6
|
const PREFIX = '[@adonis-agora/agent]';
|
|
@@ -8,23 +9,33 @@ const PREFIX = '[@adonis-agora/agent]';
|
|
|
8
9
|
*
|
|
9
10
|
* A model needs nothing when its provider reports the real cost (a gateway: OpenRouter, the Vercel AI
|
|
10
11
|
* Gateway) — that figure always wins. Every other model is priced off the pricing store, so a model
|
|
11
|
-
* with no row there would record `cost_usd = NULL` on every turn, silently. For each such model
|
|
12
|
-
*
|
|
13
|
-
* set is never overwritten. Gateway models are seeded too, as the estimate a call that comes back
|
|
14
|
-
* without a cost falls back to.
|
|
12
|
+
* with no row there would record `cost_usd = NULL` on every turn, silently. For each such model a row
|
|
13
|
+
* is written — only when it has NONE, so a price an operator set is never overwritten — from, in order:
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* 1. the app's `priceCatalog.prices`;
|
|
16
|
+
* 2. for a Bedrock model in GovCloud / China, the built-in table (`BEDROCK_BUILTIN_PRICES`) — never
|
|
17
|
+
* models.dev, whose Bedrock prices are the commercial ones;
|
|
18
|
+
* 3. models.dev's current list price.
|
|
19
|
+
*
|
|
20
|
+
* The row is keyed by the exact id the model is configured with (an ARN stays an ARN), which is the id
|
|
21
|
+
* a turn reports and is priced under. Gateway models are seeded too, as the estimate a call that comes
|
|
22
|
+
* back without a cost falls back to.
|
|
23
|
+
*
|
|
24
|
+
* A model still unpriced after that gets one warning line naming it, why, and the `priceCatalog`
|
|
25
|
+
* entry that fixes it. Never throws: this runs at boot, and pricing is bookkeeping, not a reason for
|
|
26
|
+
* the app to stay down.
|
|
19
27
|
*/
|
|
20
28
|
export async function ensureModelPricing(args) {
|
|
21
29
|
const models = dedupe(args.models);
|
|
30
|
+
const catalog = args.catalog === false ? undefined : args.catalog;
|
|
22
31
|
const seeded = [];
|
|
32
|
+
const reasons = new Map();
|
|
23
33
|
let current = new Map();
|
|
24
|
-
|
|
25
|
-
if (
|
|
34
|
+
const store = args.pricingStore;
|
|
35
|
+
if (store !== undefined) {
|
|
36
|
+
let needing;
|
|
26
37
|
try {
|
|
27
|
-
const rows = await
|
|
38
|
+
const rows = await store.listCurrentPrices();
|
|
28
39
|
current = new Map(rows.map((row) => [row.modelId, row]));
|
|
29
40
|
needing = models.filter((model) => resolveModelPrice(current, model.modelId) === undefined);
|
|
30
41
|
}
|
|
@@ -32,32 +43,102 @@ export async function ensureModelPricing(args) {
|
|
|
32
43
|
args.log.warn(`${PREFIX} Could not read the pricing table at boot: ${messageOf(error)}`);
|
|
33
44
|
needing = [];
|
|
34
45
|
}
|
|
35
|
-
|
|
46
|
+
const effectiveFrom = new Date().toISOString();
|
|
47
|
+
const write = async (price) => {
|
|
48
|
+
if (current.has(price.modelId))
|
|
49
|
+
return false;
|
|
36
50
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
await store.upsertModelPrice(price);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
args.log.warn(`${PREFIX} Could not write the price of ${price.modelId}: ${messageOf(error)}`);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
current.set(price.modelId, { ...price, effectiveFrom });
|
|
58
|
+
return true;
|
|
59
|
+
};
|
|
60
|
+
const stillNeeding = () => needing.filter((model) => resolveModelPrice(current, model.modelId) === undefined);
|
|
61
|
+
// 1. The app's own prices: every entry gets its row, and a configured model matching one by id.
|
|
62
|
+
const appPrices = normalizePriceEntries(catalog?.prices ?? [], args.log);
|
|
63
|
+
if (appPrices.size > 0) {
|
|
64
|
+
const before = stillNeeding();
|
|
65
|
+
for (const price of appPrices.values())
|
|
66
|
+
await write(price);
|
|
67
|
+
// Keyed by the configured id too, so the id a turn reports finds it by exact match.
|
|
68
|
+
for (const model of before) {
|
|
69
|
+
const price = matchPrice(appPrices, model.modelId);
|
|
70
|
+
if (price !== undefined)
|
|
71
|
+
await write({ ...price, modelId: model.modelId });
|
|
72
|
+
}
|
|
73
|
+
const fromApp = before
|
|
74
|
+
.filter((model) => resolveModelPrice(current, model.modelId) !== undefined)
|
|
75
|
+
.map((model) => model.modelId);
|
|
76
|
+
if (fromApp.length > 0) {
|
|
77
|
+
seeded.push(...fromApp);
|
|
78
|
+
args.log.info(`${PREFIX} Seeded prices from \`priceCatalog.prices\` for ${fromApp.join(', ')}.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// 2. Bedrock outside the commercial partition: the built-in table, never models.dev.
|
|
82
|
+
const region = catalog?.region ?? defaultAwsRegion();
|
|
83
|
+
const fromBuiltin = [];
|
|
84
|
+
const commercial = [];
|
|
85
|
+
for (const model of stillNeeding()) {
|
|
86
|
+
const partition = bedrockPartitionOf(model, region);
|
|
87
|
+
if (partition === undefined || partition === 'aws') {
|
|
88
|
+
commercial.push(model);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const price = builtinBedrockPrice(model.modelId, partition);
|
|
92
|
+
if (price !== undefined && (await write(price)))
|
|
93
|
+
fromBuiltin.push(model.modelId);
|
|
94
|
+
else {
|
|
95
|
+
reasons.set(model.modelId, `no price for AWS partition ${partition}${regionNote(model, region)} — models.dev lists commercial Bedrock prices only, and the built-in table has none for it`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (fromBuiltin.length > 0) {
|
|
99
|
+
seeded.push(...fromBuiltin);
|
|
100
|
+
args.log.info(`${PREFIX} Seeded built-in AWS GovCloud Bedrock prices for ${fromBuiltin.join(', ')} (from the AWS Price List; may go stale). Set \`priceCatalog.prices\` to override.`);
|
|
101
|
+
}
|
|
102
|
+
// 3. models.dev, for the rest.
|
|
103
|
+
if (commercial.length > 0) {
|
|
104
|
+
if (catalog === undefined || catalog.modelsDev === false) {
|
|
105
|
+
for (const model of commercial) {
|
|
106
|
+
reasons.set(model.modelId, 'no price row, and models.dev lookups are off');
|
|
48
107
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
try {
|
|
111
|
+
const refs = commercial.map((model) => modelsDevRefsFor(model.modelId, model.provider));
|
|
112
|
+
const { prices: _p, region: _r, modelsDev: _m, ...modelsDev } = catalog;
|
|
113
|
+
const found = await lookupModelsDevPricesEach(refs,
|
|
114
|
+
// Bounded: a hung catalog must not hold a shutdown (which awaits this) open forever.
|
|
115
|
+
modelsDev.signal !== undefined
|
|
116
|
+
? modelsDev
|
|
117
|
+
: { ...modelsDev, signal: AbortSignal.timeout(CATALOG_TIMEOUT_MS) });
|
|
118
|
+
const fromModelsDev = [];
|
|
119
|
+
for (const [i, model] of commercial.entries()) {
|
|
120
|
+
const price = found[i];
|
|
121
|
+
if (price === undefined) {
|
|
122
|
+
reasons.set(model.modelId, 'unknown model — models.dev does not list a price for it');
|
|
123
|
+
}
|
|
124
|
+
else if (await write({ ...price, modelId: model.modelId })) {
|
|
125
|
+
fromModelsDev.push(model.modelId);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (fromModelsDev.length > 0) {
|
|
129
|
+
seeded.push(...fromModelsDev);
|
|
130
|
+
const bedrock = commercial.some((model) => isBedrockModel(model.modelId, model.provider));
|
|
131
|
+
args.log.info(`${PREFIX} Seeded list prices from models.dev for ${fromModelsDev.join(', ')} — an estimate, used when the provider reports no cost.${bedrock
|
|
132
|
+
? ' Bedrock rows are COMMERCIAL-region prices: for GovCloud or China set `priceCatalog.region` (or `AWS_REGION`).'
|
|
133
|
+
: ''} Set your own with \`priceCatalog.prices\`, \`upsertModelPrice\` to override.`);
|
|
134
|
+
}
|
|
52
135
|
}
|
|
53
|
-
|
|
54
|
-
args.log.
|
|
55
|
-
|
|
136
|
+
catch (error) {
|
|
137
|
+
args.log.warn(`${PREFIX} Could not seed prices from models.dev: ${messageOf(error)}`);
|
|
138
|
+
for (const model of commercial)
|
|
139
|
+
reasons.set(model.modelId, 'models.dev was unreachable');
|
|
56
140
|
}
|
|
57
141
|
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
args.log.warn(`${PREFIX} Could not seed prices from models.dev: ${messageOf(error)}`);
|
|
60
|
-
}
|
|
61
142
|
}
|
|
62
143
|
}
|
|
63
144
|
const unpriced = models
|
|
@@ -65,15 +146,88 @@ export async function ensureModelPricing(args) {
|
|
|
65
146
|
.filter((model) => resolveModelPrice(current, model.modelId) === undefined)
|
|
66
147
|
.map((model) => model.modelId);
|
|
67
148
|
if (unpriced.length > 0) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
149
|
+
// Grouped by reason: `a, b (unknown model …); c (no price for AWS partition …)`.
|
|
150
|
+
const groups = new Map();
|
|
151
|
+
for (const id of unpriced) {
|
|
152
|
+
const reason = reasons.get(id) ?? '';
|
|
153
|
+
groups.set(reason, [...(groups.get(reason) ?? []), id]);
|
|
154
|
+
}
|
|
155
|
+
const named = [...groups]
|
|
156
|
+
.map(([reason, ids]) => `${ids.join(', ')}${reason !== '' ? ` (${reason})` : ''}`)
|
|
157
|
+
.join('; ');
|
|
158
|
+
const example = exampleModelFor(unpriced[0]);
|
|
159
|
+
args.log.warn(`${PREFIX} No cost will be recorded for ${named}: the provider reports no cost and ${store === undefined
|
|
160
|
+
? 'no `pricingStore` is configured. Configure one, then '
|
|
161
|
+
: 'the pricing table has no row for it. '}Add the price to \`priceCatalog.prices\`, e.g. \`{ model: '${example}', input: <USD per 1M>, output: <USD per 1M>, cacheRead?, cacheWrite? }\`, or seed a row with \`seedModelPrices(store, [...])\`, or route through a gateway that reports cost (OpenRouter, Vercel AI Gateway).`);
|
|
74
162
|
}
|
|
75
163
|
return { seeded, unpriced };
|
|
76
164
|
}
|
|
165
|
+
/** The partition a Bedrock model runs in: its id says, else the configured region; `undefined` → not Bedrock / unknown. */
|
|
166
|
+
function bedrockPartitionOf(model, region) {
|
|
167
|
+
if (!isBedrockModel(model.modelId, model.provider))
|
|
168
|
+
return undefined;
|
|
169
|
+
return parseBedrockModelId(model.modelId)?.partition ?? awsPartitionOfRegion(region);
|
|
170
|
+
}
|
|
171
|
+
function regionNote(model, region) {
|
|
172
|
+
const fromId = parseBedrockModelId(model.modelId);
|
|
173
|
+
const r = fromId?.region ?? (fromId?.partition === undefined ? region : undefined);
|
|
174
|
+
return r !== undefined ? ` (region ${r})` : '';
|
|
175
|
+
}
|
|
176
|
+
/** The id to put in the warning's example entry: the shortest id that still prices the model. */
|
|
177
|
+
function exampleModelFor(modelId) {
|
|
178
|
+
const parsed = parseBedrockModelId(modelId);
|
|
179
|
+
return parsed?.isArn ? parsed.profileId : modelId;
|
|
180
|
+
}
|
|
181
|
+
function defaultAwsRegion() {
|
|
182
|
+
const env = globalThis.process
|
|
183
|
+
?.env;
|
|
184
|
+
const region = env?.AWS_REGION ?? env?.AWS_DEFAULT_REGION;
|
|
185
|
+
return region !== undefined && region.length > 0 ? region : undefined;
|
|
186
|
+
}
|
|
187
|
+
/** A model's app price: by its exact id, then its normalized Bedrock candidates. */
|
|
188
|
+
function matchPrice(prices, modelId) {
|
|
189
|
+
for (const candidate of bedrockPriceCandidates(modelId)) {
|
|
190
|
+
const price = prices.get(candidate);
|
|
191
|
+
if (price !== undefined)
|
|
192
|
+
return price;
|
|
193
|
+
}
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
/** `priceCatalog.prices` as per-1M USD rows, keyed by model. Invalid entries are warned about and skipped. */
|
|
197
|
+
export function normalizePriceEntries(entries, log) {
|
|
198
|
+
const out = new Map();
|
|
199
|
+
const rejected = [];
|
|
200
|
+
for (const entry of entries) {
|
|
201
|
+
const label = typeof entry?.model === 'string' && entry.model.length > 0 ? entry.model : '?';
|
|
202
|
+
const currency = entry?.currency ?? 'USD';
|
|
203
|
+
const unit = entry?.unit ?? '1M tokens';
|
|
204
|
+
const scale = unit === '1M tokens' ? 1 : unit === '1K tokens' ? 1000 : undefined;
|
|
205
|
+
const rates = [entry?.input, entry?.output, entry?.cacheRead, entry?.cacheWrite];
|
|
206
|
+
const bad = rates.some((rate, i) => (i < 2 || rate !== undefined) &&
|
|
207
|
+
(typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0));
|
|
208
|
+
if (label === '?' || currency !== 'USD' || scale === undefined || bad) {
|
|
209
|
+
rejected.push(`${label} (${currency !== 'USD'
|
|
210
|
+
? `currency ${String(currency)} — only USD is recorded`
|
|
211
|
+
: scale === undefined
|
|
212
|
+
? `unit ${String(unit)} — use '1M tokens' or '1K tokens'`
|
|
213
|
+
: 'needs a model and non-negative numeric input/output'})`);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (out.has(entry.model))
|
|
217
|
+
continue; // first entry for a model wins
|
|
218
|
+
out.set(entry.model, {
|
|
219
|
+
modelId: entry.model,
|
|
220
|
+
inputPricePer1m: entry.input * scale,
|
|
221
|
+
outputPricePer1m: entry.output * scale,
|
|
222
|
+
...(entry.cacheRead !== undefined ? { cacheReadPricePer1m: entry.cacheRead * scale } : {}),
|
|
223
|
+
...(entry.cacheWrite !== undefined ? { cacheWritePricePer1m: entry.cacheWrite * scale } : {}),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (rejected.length > 0) {
|
|
227
|
+
log?.warn(`${PREFIX} Ignored \`priceCatalog.prices\` entries: ${rejected.join('; ')}.`);
|
|
228
|
+
}
|
|
229
|
+
return out;
|
|
230
|
+
}
|
|
77
231
|
function dedupe(models) {
|
|
78
232
|
const seen = new Map();
|
|
79
233
|
for (const model of models)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-pricing.js","sourceRoot":"","sources":["../../../src/pricing/boot-pricing.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAyB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjG,0FAA0F;AAC1F,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAyBzC,MAAM,MAAM,GAAG,uBAAuB,CAAC;AAEvC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;IACnD,IAAI,OAAO,GAAG,MAAM,CAAC;IAErB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACpC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC;YACzD,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;YACzD,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC,CAAC;QAC9F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,CAAC,IAAI,CA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CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -24,10 +24,20 @@ export interface ModelsDevLookup {
|
|
|
24
24
|
* Each ref is a LIST of candidates, tried in order — the first one the catalog prices wins.
|
|
25
25
|
*/
|
|
26
26
|
export declare function lookupModelsDevPrices(refs: readonly (readonly ModelsDevRef[])[], options?: ModelsDevOptions): Promise<ModelsDevLookup>;
|
|
27
|
+
/**
|
|
28
|
+
* {@link lookupModelsDevPrices}, one result per element of `refs` (in order): the price the first
|
|
29
|
+
* pricing candidate yields, or `undefined`. For callers that key the row themselves.
|
|
30
|
+
*/
|
|
31
|
+
export declare function lookupModelsDevPricesEach(refs: readonly (readonly ModelsDevRef[])[], options?: ModelsDevOptions): Promise<(ModelPriceInput | undefined)[]>;
|
|
27
32
|
/**
|
|
28
33
|
* The models.dev refs to try for a model, most specific first: `<provider>/<modelId>`, then — for an
|
|
29
34
|
* OpenRouter-style id (`deepseek/deepseek-v4.1-flash`) reached through another SDK — the OpenRouter
|
|
30
35
|
* list price. `provider` is the AI SDK provider family (`openrouter`, `openai`, `vercel`, …).
|
|
36
|
+
*
|
|
37
|
+
* A Bedrock id is normalized first (see `parseBedrockModelId`): an ARN or a geo-prefixed inference
|
|
38
|
+
* profile is tried as the full id, the profile id, then the base foundation-model id — all under
|
|
39
|
+
* `amazon-bedrock`. An ARN is never tried as an OpenRouter id (its `/` is not a vendor separator), nor
|
|
40
|
+
* looked up verbatim (models.dev lists no ARNs).
|
|
31
41
|
*/
|
|
32
42
|
export declare function modelsDevRefsFor(modelId: string, provider: string | undefined): ModelsDevRef[];
|
|
33
43
|
export declare function fetchModelsDevPrices(models: readonly ModelsDevRef[], options?: ModelsDevOptions): Promise<ModelPriceInput[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models-dev.d.ts","sourceRoot":"","sources":["../../../src/pricing/models-dev.ts"],"names":[],"mappings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gBAAqB,GAC7B,OAAO,CAAC,eAAe,EAAE,CAAC,CAoB5B;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,EAAE,CAAC,CAM5B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bedrockPriceCandidates, isBedrockModel, parseBedrockModelId } from './bedrock.js';
|
|
1
2
|
/** O endereço do catálogo. Aberto, sem chave, JSON único. */
|
|
2
3
|
export const MODELS_DEV_URL = 'https://models.dev/api.json';
|
|
3
4
|
function parseRef(ref) {
|
|
@@ -59,26 +60,44 @@ function priceOf(catalog, ref) {
|
|
|
59
60
|
* Each ref is a LIST of candidates, tried in order — the first one the catalog prices wins.
|
|
60
61
|
*/
|
|
61
62
|
export async function lookupModelsDevPrices(refs, options = {}) {
|
|
62
|
-
|
|
63
|
-
return { prices: [], missing: [] };
|
|
64
|
-
const catalog = await loadCatalog(options);
|
|
63
|
+
const found = await lookupModelsDevPricesEach(refs, options);
|
|
65
64
|
const prices = [];
|
|
66
65
|
const missing = [];
|
|
67
|
-
|
|
68
|
-
const price = candidates.map((ref) => priceOf(catalog, ref)).find((p) => p !== undefined);
|
|
66
|
+
found.forEach((price, i) => {
|
|
69
67
|
if (price !== undefined)
|
|
70
68
|
prices.push(price);
|
|
71
|
-
else if (
|
|
72
|
-
missing.push(
|
|
73
|
-
}
|
|
69
|
+
else if (refs[i]?.[0] !== undefined)
|
|
70
|
+
missing.push(refs[i][0]);
|
|
71
|
+
});
|
|
74
72
|
return { prices, missing };
|
|
75
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* {@link lookupModelsDevPrices}, one result per element of `refs` (in order): the price the first
|
|
76
|
+
* pricing candidate yields, or `undefined`. For callers that key the row themselves.
|
|
77
|
+
*/
|
|
78
|
+
export async function lookupModelsDevPricesEach(refs, options = {}) {
|
|
79
|
+
if (refs.every((candidates) => candidates.length === 0))
|
|
80
|
+
return refs.map(() => undefined);
|
|
81
|
+
const catalog = await loadCatalog(options);
|
|
82
|
+
return refs.map((candidates) => candidates.map((ref) => priceOf(catalog, ref)).find((p) => p !== undefined));
|
|
83
|
+
}
|
|
84
|
+
/** models.dev's name for AWS Bedrock. */
|
|
85
|
+
const MODELS_DEV_BEDROCK = 'amazon-bedrock';
|
|
76
86
|
/**
|
|
77
87
|
* The models.dev refs to try for a model, most specific first: `<provider>/<modelId>`, then — for an
|
|
78
88
|
* OpenRouter-style id (`deepseek/deepseek-v4.1-flash`) reached through another SDK — the OpenRouter
|
|
79
89
|
* list price. `provider` is the AI SDK provider family (`openrouter`, `openai`, `vercel`, …).
|
|
90
|
+
*
|
|
91
|
+
* A Bedrock id is normalized first (see `parseBedrockModelId`): an ARN or a geo-prefixed inference
|
|
92
|
+
* profile is tried as the full id, the profile id, then the base foundation-model id — all under
|
|
93
|
+
* `amazon-bedrock`. An ARN is never tried as an OpenRouter id (its `/` is not a vendor separator), nor
|
|
94
|
+
* looked up verbatim (models.dev lists no ARNs).
|
|
80
95
|
*/
|
|
81
96
|
export function modelsDevRefsFor(modelId, provider) {
|
|
97
|
+
if (isBedrockModel(modelId, provider)) {
|
|
98
|
+
const ids = bedrockPriceCandidates(modelId).filter((id) => parseBedrockModelId(id)?.isArn !== true);
|
|
99
|
+
return ids.map((id) => `${MODELS_DEV_BEDROCK}/${id}`);
|
|
100
|
+
}
|
|
82
101
|
const refs = [];
|
|
83
102
|
if (provider !== undefined && provider.length > 0)
|
|
84
103
|
refs.push(`${provider}/${modelId}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models-dev.js","sourceRoot":"","sources":["../../../src/pricing/models-dev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"models-dev.js","sourceRoot":"","sources":["../../../src/pricing/models-dev.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,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;QACpC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,gBAAgB,GAAG,6DAA6D,CACjF,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAwB,EACxB,MAA+B,EAC/B,OAAO,GAAqB,EAAE;IAE9B,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { CostSource } from '../spi/agent-store.js';
|
|
2
|
+
import { type AgentPricingStore, type ModelPriceInput } from '../spi/pricing-store.js';
|
|
3
|
+
import type { MessageUsage } from '../types.js';
|
|
4
|
+
import { type BootPricingLog, type PriceCatalogOptions } from './boot-pricing.js';
|
|
5
|
+
/**
|
|
6
|
+
* The cost a usage row persists: the provider's figure (`'provider'`), else the estimate off the
|
|
7
|
+
* model's price row (`'estimate'`), else nothing (`cost_usd` NULL). The one rule every engine
|
|
8
|
+
* records usage by, so the ledger, a USD quota and the message carry the same figure.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveUsageCost(usage: MessageUsage, reportedCostUsd: number | undefined, price: ModelPriceInput | undefined): {
|
|
11
|
+
costUsd?: number;
|
|
12
|
+
costSource?: CostSource;
|
|
13
|
+
};
|
|
14
|
+
/** A model to price, as an engine knows it. */
|
|
15
|
+
export interface PricedModelRef {
|
|
16
|
+
/** The id usage is recorded under. */
|
|
17
|
+
modelId: string;
|
|
18
|
+
/** Its provider family (`amazon-bedrock`, `openai`, `openrouter`, …), when known. */
|
|
19
|
+
provider?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Other ids the same model is known by, tried after `modelId` (e.g. the bare model id of a
|
|
22
|
+
* `provider/model` label, or the Bedrock id behind a gateway's alias).
|
|
23
|
+
*/
|
|
24
|
+
aliases?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export interface ModelPriceResolverOptions {
|
|
27
|
+
/** The configured pricing store (`pricingStore`). Omit → prices resolve in memory only. */
|
|
28
|
+
pricingStore?: AgentPricingStore | undefined;
|
|
29
|
+
/** `priceCatalog` in `config/agent.ts`; `false` → no app prices, never fetch models.dev. */
|
|
30
|
+
catalog?: PriceCatalogOptions | false | undefined;
|
|
31
|
+
log?: BootPricingLog;
|
|
32
|
+
/** How long the store's current prices are reused before they are read again. Default 60s. */
|
|
33
|
+
cacheMs?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The price of a model an engine only learns about at run time (OpenCode reports the model each step
|
|
37
|
+
* ran on), resolved the way boot pricing does it for configured models:
|
|
38
|
+
*
|
|
39
|
+
* 1. the pricing store's current row (by the id, then its normalized Bedrock candidates);
|
|
40
|
+
* 2. once per model and process, the boot seed (`ensureModelPricing`): the app's
|
|
41
|
+
* `priceCatalog.prices`, then the built-in GovCloud Bedrock table, then models.dev — written to
|
|
42
|
+
* the store as a row, so the dashboard and a later run read the same price;
|
|
43
|
+
* 3. without a pricing store, the same three sources, kept in memory.
|
|
44
|
+
*
|
|
45
|
+
* Never throws: pricing is bookkeeping, and an unpriced step is recorded without a cost.
|
|
46
|
+
*/
|
|
47
|
+
export declare class ModelPriceResolver {
|
|
48
|
+
private readonly options;
|
|
49
|
+
private rows;
|
|
50
|
+
private rowsAt;
|
|
51
|
+
private readonly seeded;
|
|
52
|
+
constructor(options?: ModelPriceResolverOptions);
|
|
53
|
+
priceFor(model: PricedModelRef): Promise<ModelPriceInput | undefined>;
|
|
54
|
+
private catalog;
|
|
55
|
+
private currentRows;
|
|
56
|
+
private seed;
|
|
57
|
+
/** No pricing store: the app's prices, the built-in Bedrock table, then models.dev. */
|
|
58
|
+
private inMemory;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/pricing/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAErB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQhD,OAAO,EACL,KAAK,cAAc,EAInB,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAG3B;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,YAAY,EACnB,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,KAAK,EAAE,eAAe,GAAG,SAAS,GACjC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,UAAU,CAAA;CAAE,CAI/C;AAED,+CAA+C;AAC/C,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,yBAAyB;IACxC,2FAA2F;IAC3F,YAAY,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC7C,4FAA4F;IAC5F,OAAO,CAAC,EAAE,mBAAmB,GAAG,KAAK,GAAG,SAAS,CAAC;IAClD,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID;;;;;;;;;;;GA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