@axlsdk/axl 0.14.0 → 0.15.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/README.md CHANGED
@@ -453,6 +453,25 @@ const relevant = await ctx.recall('knowledge-base', {
453
453
 
454
454
  Vector store implementations: `InMemoryVectorStore` (testing), `SqliteVectorStore` (production, requires `better-sqlite3`).
455
455
 
456
+ **Embedder cost attribution.** `OpenAIEmbedder` reports `{ tokens, cost, model }` on every embed call — computed from the response's `prompt_tokens` and a pricing table (`text-embedding-3-small` $0.02/1M, `-large` $0.13/1M, `ada-002` $0.10/1M). The cost flows through `runtime.trackExecution()` the same way agent-call cost does, counts against `ctx.budget()`, and shows up in Studio's Cost Dashboard under "Memory (Embedder)". See [observability.md](../../docs/observability.md#trace-event-types) for the trace-event shape.
457
+
458
+ **Custom `Embedder` implementations** (breaking change in 0.15.0 — `embed()` previously returned `Promise<number[][]>`):
459
+
460
+ ```typescript
461
+ import type { Embedder, EmbedResult } from '@axlsdk/axl';
462
+
463
+ class MyEmbedder implements Embedder {
464
+ readonly dimensions = 1536;
465
+
466
+ // `signal` is optional but recommended — lets budget hard-stops and user
467
+ // aborts cancel in-flight embedder fetches mid-retry.
468
+ async embed(texts: string[], signal?: AbortSignal): Promise<EmbedResult> {
469
+ const vectors = await myProvider.embed(texts, { signal });
470
+ return { vectors }; // `usage` optional — omit if you don't compute cost
471
+ }
472
+ }
473
+ ```
474
+
456
475
  ### Agent Guardrails
457
476
 
458
477
  Input and output validation at the agent boundary. You define your own validation logic — Axl calls it before and after each LLM turn: