@adonis-agora/agent 0.66.1 → 0.68.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/providers/agent_provider.d.ts.map +1 -1
  3. package/dist/providers/agent_provider.js +46 -0
  4. package/dist/providers/agent_provider.js.map +1 -1
  5. package/dist/src/ai-sdk/ai-sdk-model.d.ts +12 -1
  6. package/dist/src/ai-sdk/ai-sdk-model.d.ts.map +1 -1
  7. package/dist/src/ai-sdk/ai-sdk-model.js +87 -5
  8. package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -1
  9. package/dist/src/channels/handler.d.ts +44 -0
  10. package/dist/src/channels/handler.d.ts.map +1 -1
  11. package/dist/src/channels/handler.js +53 -9
  12. package/dist/src/channels/handler.js.map +1 -1
  13. package/dist/src/channels/index.d.ts +1 -1
  14. package/dist/src/channels/index.d.ts.map +1 -1
  15. package/dist/src/channels/index.js.map +1 -1
  16. package/dist/src/define_config.d.ts +13 -0
  17. package/dist/src/define_config.d.ts.map +1 -1
  18. package/dist/src/define_config.js.map +1 -1
  19. package/dist/src/index.d.ts +2 -1
  20. package/dist/src/index.d.ts.map +1 -1
  21. package/dist/src/index.js +2 -1
  22. package/dist/src/index.js.map +1 -1
  23. package/dist/src/pricing/boot-pricing.d.ts +41 -0
  24. package/dist/src/pricing/boot-pricing.d.ts.map +1 -0
  25. package/dist/src/pricing/boot-pricing.js +87 -0
  26. package/dist/src/pricing/boot-pricing.js.map +1 -0
  27. package/dist/src/pricing/models-dev.d.ts +17 -12
  28. package/dist/src/pricing/models-dev.d.ts.map +1 -1
  29. package/dist/src/pricing/models-dev.js +64 -15
  30. package/dist/src/pricing/models-dev.js.map +1 -1
  31. package/dist/src/spi/model-provider.d.ts +16 -1
  32. package/dist/src/spi/model-provider.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/skills/agent-setup/SKILL.md +12 -1
@@ -10,21 +10,26 @@ export interface ModelsDevOptions {
10
10
  }
11
11
  /** Um modelo no catálogo: `'<provider>/<model>'`, por exemplo `'openai/gpt-4o-mini'`. */
12
12
  export type ModelsDevRef = string;
13
+ /** The result of a lenient lookup: what the catalog priced, and what it did not. */
14
+ export interface ModelsDevLookup {
15
+ prices: ModelPriceInput[];
16
+ /** Refs with no entry, or an entry without an input/output price. */
17
+ missing: ModelsDevRef[];
18
+ }
13
19
  /**
14
- * Busca no [models.dev](https://models.dev) os preços dos modelos pedidos.
15
- *
16
- * Existe porque a alternativa é alguém copiar números de uma tabela de preços para dentro de um
17
- * seeder à mão. Um preço errado ali não quebra nada e não avisa: ele produz uma conta errada no
18
- * dashboard, que é pior do que conta nenhuma — quem lê acredita.
19
- *
20
- * O que ele devolve são `ModelPriceInput` prontos para o `upsertModelPrice`, chaveados pelo NOME
21
- * DO MODELO (`gpt-4o-mini`), não pelo `provider/model` pedido. É de propósito: é assim que os
22
- * provedores publicam o preço, e a resolução do fold (ver `resolveModelPrice`) já sabe chegar do
23
- * snapshot datado que o provider reporta até esse alias.
20
+ * The lenient twin of {@link fetchModelsDevPrices}, for boot-time seeding: a model the catalog does
21
+ * not price is reported in `missing` instead of failing the whole batch, so one unknown model does
22
+ * not leave every other one unpriced. Throws only when the catalog itself cannot be read.
24
23
  *
25
- * FALHA ALTO. Um modelo pedido que não existe no catálogo, ou existe sem preço, vira erro — e não
26
- * uma linha faltando em silêncio, que reapareceria depois como `$0.00` num painel.
24
+ * Each ref is a LIST of candidates, tried in order — the first one the catalog prices wins.
25
+ */
26
+ export declare function lookupModelsDevPrices(refs: readonly (readonly ModelsDevRef[])[], options?: ModelsDevOptions): Promise<ModelsDevLookup>;
27
+ /**
28
+ * The models.dev refs to try for a model, most specific first: `<provider>/<modelId>`, then — for an
29
+ * OpenRouter-style id (`deepseek/deepseek-v4.1-flash`) reached through another SDK — the OpenRouter
30
+ * list price. `provider` is the AI SDK provider family (`openrouter`, `openai`, `vercel`, …).
27
31
  */
32
+ export declare function modelsDevRefsFor(modelId: string, provider: string | undefined): ModelsDevRef[];
28
33
  export declare function fetchModelsDevPrices(models: readonly ModelsDevRef[], options?: ModelsDevOptions): Promise<ModelPriceInput[]>;
29
34
  /**
30
35
  * Busca no models.dev e grava no store. O atalho de uma linha para um comando de seed.
@@ -1 +1 @@
1
- {"version":3,"file":"models-dev.d.ts","sourceRoot":"","sources":["../../../src/pricing/models-dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAElF,6DAA6D;AAC7D,eAAO,MAAM,cAAc,gCAAgC,CAAC;AAkB5D,MAAM,WAAW,gBAAgB;IAC/B,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gGAAgG;IAChG,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,yFAAyF;AACzF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAclC;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,EAAE,CAAC,CAqC5B;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
+ {"version":3,"file":"models-dev.d.ts","sourceRoot":"","sources":["../../../src/pricing/models-dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAElF,6DAA6D;AAC7D,eAAO,MAAM,cAAc,gCAAgC,CAAC;AAkB5D,MAAM,WAAW,gBAAgB;IAC/B,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gGAAgG;IAChG,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,yFAAyF;AACzF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AA0DlC,oFAAoF;AACpF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,qEAAqE;IACrE,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,SAAS,CAAC,SAAS,YAAY,EAAE,CAAC,EAAE,EAC1C,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CAW1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,EAAE,CAO9F;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,OAAO,GAAE,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"}
@@ -24,9 +24,7 @@ function parseRef(ref) {
24
24
  * FALHA ALTO. Um modelo pedido que não existe no catálogo, ou existe sem preço, vira erro — e não
25
25
  * uma linha faltando em silêncio, que reapareceria depois como `$0.00` num painel.
26
26
  */
27
- export async function fetchModelsDevPrices(models, options = {}) {
28
- if (models.length === 0)
29
- return [];
27
+ async function loadCatalog(options) {
30
28
  const doFetch = options.fetch ?? globalThis.fetch;
31
29
  if (typeof doFetch !== 'function') {
32
30
  throw new Error('models.dev: nenhum `fetch` disponível — passe `options.fetch`.');
@@ -36,25 +34,76 @@ export async function fetchModelsDevPrices(models, options = {}) {
36
34
  if (!response.ok) {
37
35
  throw new Error(`models.dev: ${url} respondeu ${response.status}`);
38
36
  }
39
- const catalog = (await response.json());
37
+ return (await response.json());
38
+ }
39
+ /** The price row a catalog entry yields, keyed by the model name — or `undefined` when it has none. */
40
+ function priceOf(catalog, ref) {
41
+ const { provider, model } = parseRef(ref);
42
+ const cost = catalog[provider]?.models?.[model]?.cost;
43
+ if (cost === undefined || typeof cost.input !== 'number' || typeof cost.output !== 'number') {
44
+ return undefined;
45
+ }
46
+ return {
47
+ modelId: model,
48
+ inputPricePer1m: cost.input,
49
+ outputPricePer1m: cost.output,
50
+ ...(typeof cost.cache_write === 'number' ? { cacheWritePricePer1m: cost.cache_write } : {}),
51
+ ...(typeof cost.cache_read === 'number' ? { cacheReadPricePer1m: cost.cache_read } : {}),
52
+ };
53
+ }
54
+ /**
55
+ * The lenient twin of {@link fetchModelsDevPrices}, for boot-time seeding: a model the catalog does
56
+ * not price is reported in `missing` instead of failing the whole batch, so one unknown model does
57
+ * not leave every other one unpriced. Throws only when the catalog itself cannot be read.
58
+ *
59
+ * Each ref is a LIST of candidates, tried in order — the first one the catalog prices wins.
60
+ */
61
+ export async function lookupModelsDevPrices(refs, options = {}) {
62
+ if (refs.length === 0)
63
+ return { prices: [], missing: [] };
64
+ const catalog = await loadCatalog(options);
65
+ const prices = [];
66
+ const missing = [];
67
+ for (const candidates of refs) {
68
+ const price = candidates.map((ref) => priceOf(catalog, ref)).find((p) => p !== undefined);
69
+ if (price !== undefined)
70
+ prices.push(price);
71
+ else if (candidates[0] !== undefined)
72
+ missing.push(candidates[0]);
73
+ }
74
+ return { prices, missing };
75
+ }
76
+ /**
77
+ * The models.dev refs to try for a model, most specific first: `<provider>/<modelId>`, then — for an
78
+ * OpenRouter-style id (`deepseek/deepseek-v4.1-flash`) reached through another SDK — the OpenRouter
79
+ * list price. `provider` is the AI SDK provider family (`openrouter`, `openai`, `vercel`, …).
80
+ */
81
+ export function modelsDevRefsFor(modelId, provider) {
82
+ const refs = [];
83
+ if (provider !== undefined && provider.length > 0)
84
+ refs.push(`${provider}/${modelId}`);
85
+ // A gateway id names its own provider (`openai/gpt-4o-mini` through the Vercel AI Gateway).
86
+ if (provider === 'vercel' && modelId.includes('/'))
87
+ refs.push(modelId);
88
+ if (modelId.includes('/') && provider !== 'openrouter')
89
+ refs.push(`openrouter/${modelId}`);
90
+ return refs;
91
+ }
92
+ export async function fetchModelsDevPrices(models, options = {}) {
93
+ if (models.length === 0)
94
+ return [];
95
+ const catalog = await loadCatalog(options);
40
96
  const prices = [];
41
97
  for (const ref of models) {
42
98
  const { provider, model } = parseRef(ref);
43
- const entry = catalog[provider]?.models?.[model];
44
- if (entry === undefined) {
99
+ if (catalog[provider]?.models?.[model] === undefined) {
45
100
  throw new Error(`models.dev: não achei "${model}" em "${provider}".`);
46
101
  }
47
- const cost = entry.cost;
48
- if (cost === undefined || typeof cost.input !== 'number' || typeof cost.output !== 'number') {
102
+ const price = priceOf(catalog, ref);
103
+ if (price === undefined) {
49
104
  throw new Error(`models.dev: "${ref}" existe no catálogo mas não publica preço de input/output.`);
50
105
  }
51
- prices.push({
52
- modelId: model,
53
- inputPricePer1m: cost.input,
54
- outputPricePer1m: cost.output,
55
- ...(typeof cost.cache_write === 'number' ? { cacheWritePricePer1m: cost.cache_write } : {}),
56
- ...(typeof cost.cache_read === 'number' ? { cacheReadPricePer1m: cost.cache_read } : {}),
57
- });
106
+ prices.push(price);
58
107
  }
59
108
  return prices;
60
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"models-dev.js","sourceRoot":"","sources":["../../../src/pricing/models-dev.ts"],"names":[],"mappings":"AAEA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,6BAA6B,CAAC;AA6B5D,SAAS,QAAQ,CAAC,GAAiB;IACjC,MAAM,KAAK,GAAG,GAA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,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -39,7 +39,7 @@ export interface ModelTurnResult {
39
39
  modelId?: string;
40
40
  /**
41
41
  * The ACTUAL USD cost of this turn, when the provider knows it — a gateway (Vercel AI Gateway
42
- * `providerMetadata.gateway.cost`, OpenRouter `total_cost`) reports real spend; a direct provider
42
+ * `providerMetadata.gateway.cost`, OpenRouter `providerMetadata.openrouter.usage.cost`) reports real spend; a direct provider
43
43
  * (Anthropic/OpenAI/Bedrock) reports only tokens and leaves this undefined. When set, the
44
44
  * governance read-model uses it verbatim; otherwise it estimates from tokens × the pricing table.
45
45
  */
@@ -72,5 +72,20 @@ export interface ModelTurnResult {
72
72
  */
73
73
  export interface ModelProvider {
74
74
  runTurn(args: ModelTurnArgs): Promise<ModelTurnResult>;
75
+ /**
76
+ * The models this provider can run, for boot-time pricing: the provider seeds a missing price row
77
+ * from models.dev and warns about a model that would record no cost at all. Optional — a provider
78
+ * without it is simply not checked. `aiSdkModel` / `aiSdkModels` implement it.
79
+ */
80
+ describeModels?(): DescribedModel[];
81
+ }
82
+ /** One model a {@link ModelProvider} runs, as boot-time pricing sees it. */
83
+ export interface DescribedModel {
84
+ /** The id the model is called with (`deepseek/deepseek-v4.1-flash`, `gpt-4o-mini`). */
85
+ modelId: string;
86
+ /** Its provider family as models.dev names it (`openrouter`, `openai`, `anthropic`, `vercel`). */
87
+ provider?: string;
88
+ /** The provider reports each call's real USD cost (a gateway), so no price row is needed. */
89
+ reportsCost: boolean;
75
90
  }
76
91
  //# sourceMappingURL=model-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-provider.d.ts","sourceRoot":"","sources":["../../../src/spi/model-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe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W,EAAE,OAAO,CAAC;CACtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonis-agora/agent",
3
- "version": "0.66.1",
3
+ "version": "0.68.0",
4
4
  "description": "Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -124,7 +124,17 @@ Source: `packages/adonis/docs/governance/quota-and-cost.mdx`.
124
124
  With a Lucid main store, pricing mirrors the same connection automatically (table
125
125
  auto-created) — no extra config. Cost per turn resolves in order: provider-reported
126
126
  (a gateway) wins, else an estimate from the current price rows fetched once per run,
127
- else `null` — never a fabricated `0`. Seed prices once (e.g. from an Ace command):
127
+ else `null` — never a fabricated `0`.
128
+
129
+ Gateways report the real cost: OpenRouter via the official `@openrouter/ai-sdk-provider`
130
+ (`providerMetadata.openrouter.usage.cost` — `aiSdkModel` / `aiSdkModels` request usage accounting on every
131
+ OpenRouter call themselves unless you set your own `openrouter.usage`) and the Vercel AI Gateway (`providerMetadata.gateway.cost`). OpenRouter
132
+ reached through `@ai-sdk/openai` with a custom `baseURL` reports no cost — use the official provider.
133
+
134
+ At boot, any configured model with no price row gets the models.dev list price written as
135
+ its row (never overwriting one; `priceCatalog: false` turns the fetch off, skipped under
136
+ `NODE_ENV=test` unless `priceCatalog` is set explicitly), and a model that still has no price and no gateway cost is named in one
137
+ boot warning. To set your own prices (e.g. from an Ace command):
128
138
 
129
139
  ```ts
130
140
  import db from '@adonisjs/lucid/services/db'
@@ -292,6 +302,7 @@ With `durable: true` in `config/agent.ts` the message is persisted as an `agora.
292
302
  before the `200` and resumed after a crash (create the handler at boot in every process that runs
293
303
  durable work). Text decisions only decide cards delivered to that conversation. Hooks for the app's
294
304
  own flows: `unknownSender`, `beforeTurn`, `canDeliver`, `texts` as a function, `onTurnStarted`,
305
+ `onTurnEnded` (always, once this process is done with a message or a run resumed after its question — `replied`/`failed`/`timeout`/`blocked`/`parked`/`stopped`/`handled`/`interrupted` (`message: null` on resumes, per attempt; throws logged and ignored); stop a "typing…" presence begun in `acknowledge` there),
295
306
  `renderComponent` (components as files), `prepareMedia` / `mediaLimits` / `transformInbound`,
296
307
  `formatOutcome`, `onWebhook`, `allowRemember: false`.
297
308
  Replies are text-only by default (components → `fallbackText`), or files `renderComponent` makes of them (`OutboundMessage.media` where the adapter declares `capabilities.media`), converted to the channel's markdown and split