@revealui/ai 0.6.2 → 0.6.4

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
@@ -178,7 +178,7 @@ long-running operations stop instead of just being ignored.
178
178
 
179
179
  Some MCP servers need LLM capabilities without bundling a provider. The
180
180
  spec lets servers issue `sampling/createMessage` requests — the *client*
181
- runs the inference, keeps cost + context control, and returns the result.
181
+ runs the inference, keeps cost + context control, and returns the result (`packages/ai/src/tools/mcp-sampling.ts:207`).
182
182
  On the Ubuntu reference stack, that means servers get LLM access via the
183
183
  developer's local Canonical Inference Snap — no cloud round-trip required.
184
184
 
@@ -365,8 +365,8 @@ The memory system uses deep cloning to ensure immutability and prevent data corr
365
365
  3. **AgentContextManager Level**
366
366
  - `getContext()`: Returns value from cloned context (no additional cloning)
367
367
  - `getAllContext()`: Returns cloned context from WorkingMemory
368
- - `setContext()`: Validates then sets (cloning happens in WorkingMemory)
369
- - `updateContext()`: Validates then updates (cloning happens in WorkingMemory)
368
+ - `setContext()`: Validates then sets (cloning happens in WorkingMemory) (`packages/ai/src/memory/agent/context-manager.ts:84`)
369
+ - `updateContext()`: Validates then updates (cloning happens in WorkingMemory) (`packages/ai/src/memory/agent/context-manager.ts:131`)
370
370
 
371
371
  ### Performance Implications
372
372
 
@@ -450,7 +450,7 @@ manager.setContext('user', { name: 'John', age: 30 })
450
450
 
451
451
  ### Size Limits
452
452
 
453
- The system enforces limits to prevent performance issues:
453
+ The system enforces limits (`packages/ai/src/memory/utils/validation.ts:28-39`) to prevent performance issues:
454
454
 
455
455
  - **Max Context Keys**: 10,000 keys
456
456
  - **Max Context Size**: ~10MB (approximate)
@@ -8,6 +8,15 @@
8
8
  */
9
9
  import type { AgentDefinition } from '@revealui/contracts';
10
10
  import { type A2AAgentCard } from '@revealui/contracts';
11
+ /**
12
+ * Built-in platform agents defer model selection to the inference provider the
13
+ * account configures on the API Keys page. The dispatch runtime resolves the
14
+ * real model from that provider, so the definition itself names no vendor. An
15
+ * empty value means "use the configured provider's model". Claude and other
16
+ * model ids stay valid where an operator wires a compatible provider; they are
17
+ * no longer the hardcoded default.
18
+ */
19
+ export declare const PROVIDER_RESOLVED_MODEL = "";
11
20
  declare class AgentCardRegistry {
12
21
  private readonly defs;
13
22
  constructor();
@@ -1 +1 @@
1
- {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/a2a/card.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,YAAY,EAAyB,MAAM,qBAAqB,CAAC;AAwI/E,cAAM,iBAAiB;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsC;;IAO3D,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAIpC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIpC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO;IAOzF,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIpD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAM9D,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE;IAI1C,QAAQ,IAAI,eAAe,EAAE;IAI7B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAG9B;AAED,qDAAqD;AACrD,eAAO,MAAM,iBAAiB,mBAA0B,CAAC;AAEzD,YAAY,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/a2a/card.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,YAAY,EAAyB,MAAM,qBAAqB,CAAC;AAM/E;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAoI1C,cAAM,iBAAiB;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsC;;IAO3D,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAIpC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIpC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO;IAOzF,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIpD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAM9D,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE;IAI1C,QAAQ,IAAI,eAAe,EAAE;IAI7B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAG9B;AAED,qDAAqD;AACrD,eAAO,MAAM,iBAAiB,mBAA0B,CAAC;AAEzD,YAAY,EAAE,eAAe,EAAE,CAAC"}
package/dist/a2a/card.js CHANGED
@@ -10,6 +10,15 @@ import { agentDefinitionToCard } from '@revealui/contracts';
10
10
  // =============================================================================
11
11
  // Built-in agent definitions
12
12
  // =============================================================================
13
+ /**
14
+ * Built-in platform agents defer model selection to the inference provider the
15
+ * account configures on the API Keys page. The dispatch runtime resolves the
16
+ * real model from that provider, so the definition itself names no vendor. An
17
+ * empty value means "use the configured provider's model". Claude and other
18
+ * model ids stay valid where an operator wires a compatible provider; they are
19
+ * no longer the hardcoded default.
20
+ */
21
+ export const PROVIDER_RESOLVED_MODEL = '';
13
22
  /** RevealUI platform meta-agent - "The Creator" */
14
23
  const THE_CREATOR_DEF = {
15
24
  id: 'revealui-creator',
@@ -18,7 +27,7 @@ const THE_CREATOR_DEF = {
18
27
  description: 'The RevealUI platform agent. Scaffolds new AI agents, manages agent lifecycles, ' +
19
28
  'orchestrates multi-agent workflows, and acts as the primary interface for AI capabilities ' +
20
29
  'on the RevealUI platform.',
21
- model: 'claude-opus-4-6',
30
+ model: PROVIDER_RESOLVED_MODEL,
22
31
  systemPrompt: 'You are The Creator, the meta-agent for RevealUI. You design, configure, and deploy ' +
23
32
  'purpose-built AI agents for RevealUI users. You have access to agent scaffolding tools, ' +
24
33
  'the RevealUI admin, and the billing system.',
@@ -74,7 +83,7 @@ const TICKET_AGENT_DEF = {
74
83
  name: 'Ticket Agent',
75
84
  description: 'Handles support tickets, resolves user issues, and escalates when needed. ' +
76
85
  'Uses the RevealUI admin to create and update tickets.',
77
- model: 'claude-sonnet-4-6',
86
+ model: PROVIDER_RESOLVED_MODEL,
78
87
  systemPrompt: 'You are the RevealUI Ticket Agent. You help users resolve issues by creating tickets, ' +
79
88
  'searching for solutions, and escalating complex problems to the support team.',
80
89
  tools: [
@@ -53,7 +53,7 @@ export declare function estimateCacheSavings(inputTokens: number, cacheHitRate:
53
53
  *
54
54
  * @example
55
55
  * ```ts
56
- * const response = await client.chat(messages, { enableCache: true })
56
+ * const response = await client.chat(messages, { cacheHint: true })
57
57
  * const stats = formatCacheStats(response.usage)
58
58
  * console.log(stats)
59
59
  * // "Cache: 45% read (2,500 tokens), 10% created (500 tokens)"
@@ -83,7 +83,7 @@ export declare function shouldCache(content: string, minTokens?: number): boolea
83
83
  * ],
84
84
  * })
85
85
  *
86
- * const response = await client.chat(conversation, { enableCache: true })
86
+ * const response = await client.chat(conversation, { cacheHint: true })
87
87
  * ```
88
88
  */
89
89
  export declare function createCachedConversation(config: {
@@ -92,31 +92,17 @@ export declare function createCachedConversation(config: {
92
92
  messages: Message[];
93
93
  }): Message[];
94
94
  /**
95
- * Pricing information for Anthropic Claude models (as of 2024)
96
- * Prices are per million tokens
95
+ * @deprecated Use `MODEL_PRICING` from `./token-counter.js`. Retained as a thin derived
96
+ * view (the Anthropic-with-cache subset) so existing importers keep one source of truth.
97
97
  */
98
98
  export declare const ANTHROPIC_PRICING: {
99
- readonly 'claude-3-5-sonnet-20241022': {
100
- readonly input: 3;
101
- readonly output: 15;
102
- readonly cacheWrite: 3.75;
103
- readonly cacheRead: 0.3;
104
- };
105
- readonly 'claude-3-5-haiku-20241022': {
106
- readonly input: 1;
107
- readonly output: 5;
108
- readonly cacheWrite: 1.25;
109
- readonly cacheRead: 0.1;
110
- };
111
- readonly 'claude-3-opus-20240229': {
112
- readonly input: 15;
113
- readonly output: 75;
114
- readonly cacheWrite: 18.75;
115
- readonly cacheRead: 1.5;
116
- };
99
+ readonly 'claude-3-5-sonnet-20241022': import("./token-counter.js").ModelPricing;
100
+ readonly 'claude-3-5-haiku-20241022': import("./token-counter.js").ModelPricing;
101
+ readonly 'claude-3-opus-20240229': import("./token-counter.js").ModelPricing;
117
102
  };
118
103
  /**
119
- * Calculate actual cost of a request with caching
104
+ * Calculate actual cost of a request with caching, using the unified MODEL_PRICING table.
105
+ * Unknown models price at zero (matching `estimateCost`).
120
106
  *
121
107
  * @example
122
108
  * ```ts
@@ -128,12 +114,12 @@ export declare const ANTHROPIC_PRICING: {
128
114
  * cacheReadTokens: 5000,
129
115
  * })
130
116
  *
131
- * console.log(`Request cost: $${cost.toFixed(4)}`)
117
+ * console.log(`Request cost: $${cost.total.toFixed(4)}`)
132
118
  * console.log(`Savings vs no cache: $${cost.savings.toFixed(4)}`)
133
119
  * ```
134
120
  */
135
121
  export declare function calculateCacheCost(usage: {
136
- model: keyof typeof ANTHROPIC_PRICING;
122
+ model: string;
137
123
  promptTokens: number;
138
124
  completionTokens: number;
139
125
  cacheCreationTokens?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"cache-utils.d.ts","sourceRoot":"","sources":["../../src/llm/cache-utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG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C,KAAK,EAAE;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CA6BxE"}
@@ -1,4 +1,5 @@
1
1
  /* console-allowed */
2
+ import { MODEL_PRICING } from './token-counter.js';
2
3
  /**
3
4
  * Mark a message for caching
4
5
  * Use this for system prompts, tool definitions, or large context that repeats
@@ -6,7 +7,7 @@
6
7
  export function withCache(message) {
7
8
  return {
8
9
  ...message,
9
- cacheControl: { type: 'ephemeral' },
10
+ cache: true,
10
11
  };
11
12
  }
12
13
  /**
@@ -57,7 +58,7 @@ export function estimateCacheSavings(inputTokens, cacheHitRate, cachedTokenPerce
57
58
  *
58
59
  * @example
59
60
  * ```ts
60
- * const response = await client.chat(messages, { enableCache: true })
61
+ * const response = await client.chat(messages, { cacheHint: true })
61
62
  * const stats = formatCacheStats(response.usage)
62
63
  * console.log(stats)
63
64
  * // "Cache: 45% read (2,500 tokens), 10% created (500 tokens)"
@@ -102,7 +103,7 @@ export function shouldCache(content, minTokens = 1024) {
102
103
  * ],
103
104
  * })
104
105
  *
105
- * const response = await client.chat(conversation, { enableCache: true })
106
+ * const response = await client.chat(conversation, { cacheHint: true })
106
107
  * ```
107
108
  */
108
109
  export function createCachedConversation(config) {
@@ -118,7 +119,7 @@ export function createCachedConversation(config) {
118
119
  result.push({
119
120
  role: 'system',
120
121
  content: doc,
121
- ...(isLast ? { cacheControl: { type: 'ephemeral' } } : {}),
122
+ ...(isLast ? { cache: true } : {}),
122
123
  });
123
124
  });
124
125
  }
@@ -126,32 +127,26 @@ export function createCachedConversation(config) {
126
127
  result.push(...config.messages);
127
128
  return result;
128
129
  }
130
+ /** Look up a model's pricing, asserting presence (used only for known-present keys). */
131
+ function requirePricing(model) {
132
+ const pricing = MODEL_PRICING[model];
133
+ if (!pricing) {
134
+ throw new Error(`No pricing entry for model: ${model}`);
135
+ }
136
+ return pricing;
137
+ }
129
138
  /**
130
- * Pricing information for Anthropic Claude models (as of 2024)
131
- * Prices are per million tokens
139
+ * @deprecated Use `MODEL_PRICING` from `./token-counter.js`. Retained as a thin derived
140
+ * view (the Anthropic-with-cache subset) so existing importers keep one source of truth.
132
141
  */
133
142
  export const ANTHROPIC_PRICING = {
134
- 'claude-3-5-sonnet-20241022': {
135
- input: 3.0,
136
- output: 15.0,
137
- cacheWrite: 3.75, // 25% markup for cache creation
138
- cacheRead: 0.3, // 90% discount for cache hits
139
- },
140
- 'claude-3-5-haiku-20241022': {
141
- input: 1.0,
142
- output: 5.0,
143
- cacheWrite: 1.25,
144
- cacheRead: 0.1,
145
- },
146
- 'claude-3-opus-20240229': {
147
- input: 15.0,
148
- output: 75.0,
149
- cacheWrite: 18.75,
150
- cacheRead: 1.5,
151
- },
143
+ 'claude-3-5-sonnet-20241022': requirePricing('claude-3-5-sonnet-20241022'),
144
+ 'claude-3-5-haiku-20241022': requirePricing('claude-3-5-haiku-20241022'),
145
+ 'claude-3-opus-20240229': requirePricing('claude-3-opus-20240229'),
152
146
  };
153
147
  /**
154
- * Calculate actual cost of a request with caching
148
+ * Calculate actual cost of a request with caching, using the unified MODEL_PRICING table.
149
+ * Unknown models price at zero (matching `estimateCost`).
155
150
  *
156
151
  * @example
157
152
  * ```ts
@@ -163,12 +158,17 @@ export const ANTHROPIC_PRICING = {
163
158
  * cacheReadTokens: 5000,
164
159
  * })
165
160
  *
166
- * console.log(`Request cost: $${cost.toFixed(4)}`)
161
+ * console.log(`Request cost: $${cost.total.toFixed(4)}`)
167
162
  * console.log(`Savings vs no cache: $${cost.savings.toFixed(4)}`)
168
163
  * ```
169
164
  */
170
165
  export function calculateCacheCost(usage) {
171
- const pricing = ANTHROPIC_PRICING[usage.model];
166
+ const pricing = MODEL_PRICING[usage.model] ?? {
167
+ input: 0,
168
+ output: 0,
169
+ cacheWrite: 0,
170
+ cacheRead: 0,
171
+ };
172
172
  const uncachedTokens = usage.promptTokens - (usage.cacheCreationTokens || 0) - (usage.cacheReadTokens || 0);
173
173
  const costs = {
174
174
  input: (uncachedTokens / 1_000_000) * pricing.input,
@@ -1,7 +1,11 @@
1
1
  /**
2
2
  * LLM Provider Base Interface
3
3
  *
4
- * Abstract interface for all LLM providers (OpenAI, Anthropic, etc.)
4
+ * The agnostic Reasoner port (ADR 2026-06-25). Providers are negotiated by
5
+ * `capabilities()`, never by provider-name string. The control vocabulary is neutral
6
+ * and capability-gated (`effort`, `cache`/`cacheHint`); genuinely unportable knobs ride
7
+ * the namespaced opaque `providerOptions` channel; cross-provider usage (e.g. cache token
8
+ * stats) stays neutral in `LLMResponse.usage`.
5
9
  */
6
10
  /**
7
11
  * A plain text content part - used in multipart messages.
@@ -36,10 +40,11 @@ export interface Message {
36
40
  name?: string;
37
41
  toolCalls?: ToolCall[];
38
42
  toolCallId?: string;
39
- /** Anthropic prompt caching - marks content for caching (5min TTL, 90% cost reduction) */
40
- cacheControl?: {
41
- type: 'ephemeral';
42
- };
43
+ /**
44
+ * Neutral cache breakpoint hint (gated by the `promptCache` capability). An adapter
45
+ * that supports prompt caching maps this to its native cache-control; others ignore it.
46
+ */
47
+ cache?: boolean;
43
48
  }
44
49
  export interface ToolCall {
45
50
  id: string;
@@ -58,7 +63,11 @@ export interface LLMResponse {
58
63
  promptTokens: number;
59
64
  completionTokens: number;
60
65
  totalTokens: number;
61
- /** Anthropic cache stats */
66
+ /**
67
+ * Cross-provider cache usage (neutral; gated by `promptCache`). Populated by any
68
+ * caching provider - Anthropic cache tokens, OpenAI `cached_tokens`, Gemini
69
+ * `cachedContentTokenCount`. Read by the cost path; stays in neutral `usage`.
70
+ */
62
71
  cacheCreationTokens?: number;
63
72
  cacheReadTokens?: number;
64
73
  };
@@ -81,22 +90,66 @@ export interface LLMProviderConfig {
81
90
  maxTokens?: number;
82
91
  }
83
92
  /**
84
- * Base interface for LLM providers
93
+ * Reasoning-depth hint (neutral, capability-gated by `reasoningEffort`).
94
+ *
95
+ * This is a *reasoning-depth* axis, NOT output entropy or length - adapters must never
96
+ * remap it to `temperature`/`maxTokens`. An adapter with a reasoning axis maps it to its
97
+ * native control (e.g. a thinking-token budget); an adapter without one advertises
98
+ * `reasoningEffort: false` and treats `effort` as a no-op.
85
99
  */
86
- export interface LLMProvider {
87
- /**
88
- * Chat completion
89
- */
100
+ export type ReasoningEffort = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
101
+ /**
102
+ * Runtime-queryable capability record. The loop branches on these, never on a
103
+ * provider-name string. Conformance-tested (transport tier) so a provider cannot lie:
104
+ * advertise-true-but-not-wired fails the positive assertion; advertise-false-but-emits-a-
105
+ * native-field fails the inertness assertion.
106
+ */
107
+ export interface ReasonerCapabilities {
108
+ /** Stable adapter id; also the only `providerOptions` namespace this adapter may read ('x-<tag>'). */
109
+ readonly providerTag: string;
110
+ readonly tools: boolean;
111
+ /** Implies `tools` (consistency invariant). */
112
+ readonly parallelToolCalls: boolean;
113
+ /** Implies the adapter accepts `ContentPart[]` message content. */
114
+ readonly vision: boolean;
115
+ readonly streaming: boolean;
116
+ readonly embeddings: boolean;
117
+ readonly reasoningEffort: boolean;
118
+ readonly promptCache: boolean;
119
+ readonly structuredOutput: boolean;
120
+ /** Max context window in tokens; undefined = unknown (loop budgets conservatively). */
121
+ readonly contextWindow?: number;
122
+ }
123
+ /**
124
+ * Namespaced opaque extension for genuinely unportable, request-shaped knobs.
125
+ *
126
+ * Core/loop code MUST pass this through and MUST NOT read any key - per-namespace schema
127
+ * lives in the owning adapter. A known-namespace registry (typed keys) rather than a bare
128
+ * `x-*` string convention, so a typo'd namespace fails loudly instead of silently no-opping.
129
+ */
130
+ export interface ProviderOptions {
131
+ 'x-anthropic'?: unknown;
132
+ 'x-openai'?: unknown;
133
+ 'x-google'?: unknown;
134
+ }
135
+ /**
136
+ * The Reasoner port - one swappable reasoning step plus the side capabilities
137
+ * (embeddings/streaming). The loop negotiates by `capabilities()`, never by name.
138
+ */
139
+ export interface Reasoner {
140
+ /** Runtime-queryable, conformance-tested capability record. */
141
+ capabilities(): ReasonerCapabilities;
142
+ /** Chat completion. */
90
143
  chat(messages: Message[], options?: LLMChatOptions): Promise<LLMResponse>;
91
- /**
92
- * Generate embeddings
93
- */
144
+ /** Generate embeddings. */
94
145
  embed(text: string | string[], options?: LLMEmbedOptions): Promise<Embedding | Embedding[]>;
95
- /**
96
- * Stream chat completion
97
- */
146
+ /** Stream chat completion. */
98
147
  stream(messages: Message[], options?: LLMStreamOptions): AsyncIterable<LLMChunk>;
99
148
  }
149
+ /**
150
+ * @deprecated Use `Reasoner`. Alias retained one release cycle for external callers.
151
+ */
152
+ export type LLMProvider = Reasoner;
100
153
  export interface LLMChatOptions {
101
154
  temperature?: number;
102
155
  maxTokens?: number;
@@ -107,14 +160,12 @@ export interface LLMChatOptions {
107
160
  name: string;
108
161
  };
109
162
  };
110
- /** Enable prompt caching (Anthropic only) - caches system prompts and tools */
111
- enableCache?: boolean;
112
- /**
113
- * Extended thinking token budget (Anthropic only).
114
- * Enables Claude's internal reasoning before responding.
115
- * Typical values: 512 (minimal) → 31999 (xhigh). 0 or undefined = disabled.
116
- */
117
- thinkingBudget?: number;
163
+ /** Neutral reasoning-depth hint (gated by `reasoningEffort`). No-op where unsupported. */
164
+ effort?: ReasoningEffort;
165
+ /** Neutral prompt-cache hint for the stable prefix - system + tools (gated by `promptCache`). */
166
+ cacheHint?: boolean;
167
+ /** Opaque, namespaced provider extension. Core never reads it; the adapter owns the schema. */
168
+ providerOptions?: ProviderOptions;
118
169
  }
119
170
  export interface LLMEmbedOptions {
120
171
  model?: string;
@@ -123,8 +174,10 @@ export interface LLMStreamOptions {
123
174
  temperature?: number;
124
175
  maxTokens?: number;
125
176
  tools?: ToolDefinition[];
126
- /** Enable prompt caching (Anthropic only) - caches system prompts and tools */
127
- enableCache?: boolean;
177
+ /** Neutral reasoning-depth hint (gated by `reasoningEffort`). No-op where unsupported. */
178
+ effort?: ReasoningEffort;
179
+ /** Opaque, namespaced provider extension. Core never reads it; the adapter owns the schema. */
180
+ providerOptions?: ProviderOptions;
128
181
  }
129
182
  export interface ToolDefinition {
130
183
  type: 'function';
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE;QACT,sEAAsE;QACtE,GAAG,EAAE,MAAM,CAAC;QACZ,yDAAyD;QACzD,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;KAClC,CAAC;CACH;AAED,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE/C,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C;yFACqF;IACrF,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,YAAY,CAAC,EAAE;QAAE,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC;CACtC;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;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AAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,+FAA+F;IAC/F,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACH;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,GAAG,gBAAgB,CAAC"}
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * LLM Provider Base Interface
3
3
  *
4
- * Abstract interface for all LLM providers (OpenAI, Anthropic, etc.)
4
+ * The agnostic Reasoner port (ADR 2026-06-25). Providers are negotiated by
5
+ * `capabilities()`, never by provider-name string. The control vocabulary is neutral
6
+ * and capability-gated (`effort`, `cache`/`cacheHint`); genuinely unportable knobs ride
7
+ * the namespaced opaque `providerOptions` channel; cross-provider usage (e.g. cache token
8
+ * stats) stays neutral in `LLMResponse.usage`.
5
9
  */
6
10
  export {};
@@ -5,7 +5,7 @@
5
5
  * Free tier: 6,000 TPM / 500k TPD.
6
6
  * Sign up: console.groq.com
7
7
  */
8
- import type { Embedding, LLMChatOptions, LLMChunk, LLMEmbedOptions, LLMProvider, LLMProviderConfig, LLMResponse, LLMStreamOptions, Message } from './base.js';
8
+ import type { Embedding, LLMChatOptions, LLMChunk, LLMEmbedOptions, LLMProvider, LLMProviderConfig, LLMResponse, LLMStreamOptions, Message, ReasonerCapabilities } from './base.js';
9
9
  export interface GroqProviderConfig extends Omit<LLMProviderConfig, 'apiKey'> {
10
10
  apiKey: string;
11
11
  /** Defaults to https://api.groq.com/openai/v1 */
@@ -16,6 +16,7 @@ export interface GroqProviderConfig extends Omit<LLMProviderConfig, 'apiKey'> {
16
16
  export declare class GroqProvider implements LLMProvider {
17
17
  private inner;
18
18
  constructor(config: GroqProviderConfig);
19
+ capabilities(): ReasonerCapabilities;
19
20
  chat(messages: Message[], options?: LLMChatOptions): Promise<LLMResponse>;
20
21
  stream(messages: Message[], options?: LLMStreamOptions): AsyncIterable<LLMChunk>;
21
22
  embed(_text: string | string[], _options?: LLMEmbedOptions): Promise<Embedding | Embedding[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"groq.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/groq.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,QAAQ,EACR,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,OAAO,EACR,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,YAAa,YAAW,WAAW;IAC9C,OAAO,CAAC,KAAK,CAAuB;gBAExB,MAAM,EAAE,kBAAkB;IAQtC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAIhF,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC;CAG9F"}
1
+ {"version":3,"file":"groq.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/groq.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,QAAQ,EACR,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,oBAAoB,EACrB,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,YAAa,YAAW,WAAW;IAC9C,OAAO,CAAC,KAAK,CAAuB;gBAExB,MAAM,EAAE,kBAAkB;IAQtC,YAAY,IAAI,oBAAoB;IAepC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAIhF,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC;CAG9F"}
@@ -15,6 +15,20 @@ export class GroqProvider {
15
15
  model: config.model ?? 'qwen/qwen3-32b',
16
16
  });
17
17
  }
18
+ capabilities() {
19
+ // Profile for the default model (qwen/qwen3-32b). Groq exposes no embeddings endpoint.
20
+ return {
21
+ providerTag: 'groq',
22
+ tools: true,
23
+ parallelToolCalls: false,
24
+ vision: false,
25
+ streaming: true,
26
+ embeddings: false,
27
+ reasoningEffort: false,
28
+ promptCache: false,
29
+ structuredOutput: false,
30
+ };
31
+ }
18
32
  chat(messages, options) {
19
33
  return this.inner.chat(messages, options);
20
34
  }
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * Docs: https://documentation.ubuntu.com/inference-snaps
26
26
  */
27
- import type { Embedding, LLMChatOptions, LLMChunk, LLMEmbedOptions, LLMProvider, LLMProviderConfig, LLMResponse, LLMStreamOptions, Message } from './base.js';
27
+ import type { Embedding, LLMChatOptions, LLMChunk, LLMEmbedOptions, LLMProvider, LLMProviderConfig, LLMResponse, LLMStreamOptions, Message, ReasonerCapabilities } from './base.js';
28
28
  export interface InferenceSnapsProviderConfig extends Omit<LLMProviderConfig, 'apiKey'> {
29
29
  apiKey?: string;
30
30
  /** Base URL of the inference-snaps service, e.g. http://localhost:9090/v1 */
@@ -39,6 +39,7 @@ export declare class InferenceSnapsProvider implements LLMProvider {
39
39
  private embedModel;
40
40
  private baseURL;
41
41
  constructor(config: InferenceSnapsProviderConfig);
42
+ capabilities(): ReasonerCapabilities;
42
43
  chat(messages: Message[], options?: LLMChatOptions): Promise<LLMResponse>;
43
44
  stream(messages: Message[], options?: LLMStreamOptions): AsyncIterable<LLMChunk>;
44
45
  embed(text: string | string[], _options?: LLMEmbedOptions): Promise<Embedding | Embedding[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"inference-snaps.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/inference-snaps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,QAAQ,EACR,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,OAAO,EACR,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,OAAO,EAAE,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,KAAK,CAAuB;IACpC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,4BAA4B;IAahD,YAAY,IAAI,oBAAoB;IAgBpC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAI1E,KAAK,CACT,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,QAAQ,CAAC,EAAE,eAAe,GACzB,OAAO,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC;CAsBpC"}
@@ -41,6 +41,21 @@ export class InferenceSnapsProvider {
41
41
  model: config.model ?? 'gemma3',
42
42
  });
43
43
  }
44
+ capabilities() {
45
+ // Profile for the default model (gemma3, text-only). Per-model capability
46
+ // negotiation (e.g. qwen-vl vision, deepseek-r1 reasoningEffort) is a follow-up.
47
+ return {
48
+ providerTag: 'inference-snaps',
49
+ tools: true,
50
+ parallelToolCalls: false,
51
+ vision: false,
52
+ streaming: true,
53
+ embeddings: true,
54
+ reasoningEffort: false,
55
+ promptCache: false,
56
+ structuredOutput: false,
57
+ };
58
+ }
44
59
  chat(messages, options) {
45
60
  return this.inner.chat(messages, options);
46
61
  }
@@ -5,7 +5,7 @@
5
5
  * No API key required. Zero cost, fully offline.
6
6
  * Install: https://ollama.com
7
7
  */
8
- import type { Embedding, LLMChatOptions, LLMChunk, LLMEmbedOptions, LLMProvider, LLMProviderConfig, LLMResponse, LLMStreamOptions, Message } from './base.js';
8
+ import type { Embedding, LLMChatOptions, LLMChunk, LLMEmbedOptions, LLMProvider, LLMProviderConfig, LLMResponse, LLMStreamOptions, Message, ReasonerCapabilities } from './base.js';
9
9
  export interface OllamaProviderConfig extends Omit<LLMProviderConfig, 'apiKey'> {
10
10
  apiKey?: string;
11
11
  /** Defaults to http://localhost:11434/v1 */
@@ -20,6 +20,7 @@ export declare class OllamaProvider implements LLMProvider {
20
20
  private embedModel;
21
21
  private baseURL;
22
22
  constructor(config: OllamaProviderConfig);
23
+ capabilities(): ReasonerCapabilities;
23
24
  chat(messages: Message[], options?: LLMChatOptions): Promise<LLMResponse>;
24
25
  stream(messages: Message[], options?: LLMStreamOptions): AsyncIterable<LLMChunk>;
25
26
  embed(text: string | string[], _options?: LLMEmbedOptions): Promise<Embedding | Embedding[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/ollama.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,QAAQ,EACR,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,OAAO,EACR,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,oBAAoB;IAaxC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAI1E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{
22
22
  model: config.model ?? 'gemma4:e2b',
23
23
  });
24
24
  }
25
+ capabilities() {
26
+ // Profile for the default model (gemma4:e2b, text-only).
27
+ return {
28
+ providerTag: 'ollama',
29
+ tools: true,
30
+ parallelToolCalls: false,
31
+ vision: false,
32
+ streaming: true,
33
+ embeddings: true,
34
+ reasoningEffort: false,
35
+ promptCache: false,
36
+ structuredOutput: false,
37
+ };
38
+ }
25
39
  chat(messages, options) {
26
40
  return this.inner.chat(messages, options);
27
41
  }
@@ -5,13 +5,14 @@
5
5
  * format. Used by: Ollama, Groq, Inference Snaps.
6
6
  * NOT for direct OpenAI usage - RevealUI uses open-source models only.
7
7
  */
8
- import type { Embedding, LLMChatOptions, LLMChunk, LLMEmbedOptions, LLMProvider, LLMProviderConfig, LLMResponse, LLMStreamOptions, Message } from './base.js';
8
+ import type { Embedding, LLMChatOptions, LLMChunk, LLMEmbedOptions, LLMProvider, LLMProviderConfig, LLMResponse, LLMStreamOptions, Message, ReasonerCapabilities } from './base.js';
9
9
  export interface OpenAICompatConfig extends LLMProviderConfig {
10
10
  }
11
11
  export declare class OpenAICompatProvider implements LLMProvider {
12
12
  private config;
13
13
  private baseURL;
14
14
  constructor(config: OpenAICompatConfig);
15
+ capabilities(): ReasonerCapabilities;
15
16
  chat(messages: Message[], options?: LLMChatOptions): Promise<LLMResponse>;
16
17
  embed(text: string | string[], options?: LLMEmbedOptions): Promise<Embedding | Embedding[]>;
17
18
  stream(messages: Message[], options?: LLMStreamOptions): AsyncIterable<LLMChunk>;
@@ -1 +1 @@
1
- {"version":3,"file":"openai-compat.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/openai-compat.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,SAAS,EAET,cAAc,EACd,QAAQ,EACR,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,OAAO,EAER,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,kBAAmB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E,CAAC;IAyC5B,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAuFvF,OAAO,CAAC,cAAc;CA4BvB"}
@@ -22,7 +22,7 @@ const asRecord = (value) => {
22
22
  };
23
23
  const isFunctionToolCall = (call) => {
24
24
  const record = asRecord(call);
25
- if (!record || record.type !== 'function' || typeof record.id !== 'string') {
25
+ if (record?.type !== 'function' || typeof record.id !== 'string') {
26
26
  return false;
27
27
  }
28
28
  const fn = asRecord(record.function);
@@ -38,6 +38,21 @@ export class OpenAICompatProvider {
38
38
  }
39
39
  this.baseURL = config.baseURL;
40
40
  }
41
+ capabilities() {
42
+ // Base OpenAI-compatible profile. Concrete providers (Groq, Ollama, inference-snaps)
43
+ // override per their endpoint and default model.
44
+ return {
45
+ providerTag: 'openai-compat',
46
+ tools: true,
47
+ parallelToolCalls: false,
48
+ vision: false,
49
+ streaming: true,
50
+ embeddings: true,
51
+ reasoningEffort: false,
52
+ promptCache: false,
53
+ structuredOutput: false,
54
+ };
55
+ }
41
56
  async chat(messages, options) {
42
57
  const response = await fetch(`${this.baseURL}/chat/completions`, {
43
58
  method: 'POST',
@@ -19,6 +19,24 @@ export interface CostEstimate {
19
19
  model: string;
20
20
  direction: 'input' | 'output';
21
21
  }
22
+ /**
23
+ * Per-1M-token pricing (USD). Single source of truth for every cost path in the package:
24
+ * `estimateCost` (input/output) and `calculateCacheCost` (cache-utils, cacheWrite/cacheRead).
25
+ * Cache rates follow Anthropic's model (write ~125% of input, read ~10%); non-caching
26
+ * providers carry 0 (local models are free; cache cost is not modelled for hosted
27
+ * non-Anthropic providers here).
28
+ */
29
+ export interface ModelPricing {
30
+ /** USD per 1M input tokens. */
31
+ input: number;
32
+ /** USD per 1M output tokens. */
33
+ output: number;
34
+ /** USD per 1M tokens written to the prompt cache (0 where unsupported/unmodelled). */
35
+ cacheWrite: number;
36
+ /** USD per 1M tokens read from the prompt cache (0 where unsupported/unmodelled). */
37
+ cacheRead: number;
38
+ }
39
+ export declare const MODEL_PRICING: Record<string, ModelPricing>;
22
40
  /**
23
41
  * Estimate token count for a string.
24
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"token-counter.d.ts","sourceRoot":"","sources":["../../src/llm/token-counter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC/B;AAiCD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,gBAAgB,CAGxF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,gBAAgB,CAQjG;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,OAAO,GAAG,QAAQ,GAC5B,YAAY,CASd;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,EAAE,MAAM,GACZ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAI9C"}
1
+ {"version":3,"file":"token-counter.d.ts","sourceRoot":"","sources":["../../src/llm/token-counter.ts"],"names":[],"mappings":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9C"}
@@ -8,22 +8,25 @@
8
8
  * Limitation: actual token counts differ by model tokenizer. This is
9
9
  * accurate enough for budget tracking and context window management.
10
10
  */
11
- // Cost per 1M tokens (USD) - input/output pricing
12
- const MODEL_PRICING = {
13
- // Anthropic
14
- 'claude-opus-4-6': { input: 15.0, output: 75.0 },
15
- 'claude-sonnet-4-6': { input: 3.0, output: 15.0 },
16
- 'claude-haiku-4-5-20251001': { input: 0.25, output: 1.25 },
11
+ export const MODEL_PRICING = {
12
+ // Anthropic (current)
13
+ 'claude-opus-4-6': { input: 15.0, output: 75.0, cacheWrite: 18.75, cacheRead: 1.5 },
14
+ 'claude-sonnet-4-6': { input: 3.0, output: 15.0, cacheWrite: 3.75, cacheRead: 0.3 },
15
+ 'claude-haiku-4-5-20251001': { input: 0.25, output: 1.25, cacheWrite: 0.3125, cacheRead: 0.025 },
16
+ // Anthropic (legacy 2024 - retained for cache-cost callers/examples)
17
+ 'claude-3-5-sonnet-20241022': { input: 3.0, output: 15.0, cacheWrite: 3.75, cacheRead: 0.3 },
18
+ 'claude-3-5-haiku-20241022': { input: 1.0, output: 5.0, cacheWrite: 1.25, cacheRead: 0.1 },
19
+ 'claude-3-opus-20240229': { input: 15.0, output: 75.0, cacheWrite: 18.75, cacheRead: 1.5 },
17
20
  // OpenAI
18
- 'gpt-4o': { input: 5.0, output: 15.0 },
19
- 'gpt-4o-mini': { input: 0.15, output: 0.6 },
21
+ 'gpt-4o': { input: 5.0, output: 15.0, cacheWrite: 0, cacheRead: 0 },
22
+ 'gpt-4o-mini': { input: 0.15, output: 0.6, cacheWrite: 0, cacheRead: 0 },
20
23
  // Groq (Qwen - Apache 2.0)
21
- 'qwen/qwen3-32b': { input: 0.59, output: 0.79 },
24
+ 'qwen/qwen3-32b': { input: 0.59, output: 0.79, cacheWrite: 0, cacheRead: 0 },
22
25
  // Ollama (self-hosted - no cost)
23
- 'gemma4:e2b': { input: 0, output: 0 },
24
- 'gemma4:e4b': { input: 0, output: 0 },
25
- 'gemma4:26b': { input: 0, output: 0 },
26
- 'nomic-embed-text': { input: 0, output: 0 },
26
+ 'gemma4:e2b': { input: 0, output: 0, cacheWrite: 0, cacheRead: 0 },
27
+ 'gemma4:e4b': { input: 0, output: 0, cacheWrite: 0, cacheRead: 0 },
28
+ 'gemma4:26b': { input: 0, output: 0, cacheWrite: 0, cacheRead: 0 },
29
+ 'nomic-embed-text': { input: 0, output: 0, cacheWrite: 0, cacheRead: 0 },
27
30
  };
28
31
  function charsPerToken(model) {
29
32
  const lower = model.toLowerCase();
@@ -4,24 +4,18 @@
4
4
  * Executes agent tasks with tool execution, memory management, and error handling
5
5
  */
6
6
  import type { LLMClient } from '../llm/client.js';
7
+ import type { ReasoningEffort } from '../llm/providers/base.js';
7
8
  import type { AgentSkillProvider } from '../skills/integration/agent-skill-provider.js';
8
9
  import type { ApprovalCallback } from '../tools/base.js';
9
10
  import type { MCPToolSource, McpClientLike } from '../tools/mcp-adapter.js';
10
11
  import type { Agent, AgentResult, Task } from './agent.js';
11
12
  /**
12
- * Controls how much of the model's token budget is allocated to internal reasoning.
13
- * Applies to Anthropic Claude only - ignored by other providers.
14
- *
15
- * | Level | Budget (tokens) | Use case |
16
- * |---------|-----------------|-----------------------------------|
17
- * | off | 0 | Disabled (default) |
18
- * | minimal | 512 | Simple tasks, cost-sensitive |
19
- * | low | 2 048 | Moderate complexity |
20
- * | medium | 8 000 | Multi-step reasoning |
21
- * | high | 16 000 | Complex planning |
22
- * | xhigh | 31 999 | Maximum depth (expensive) |
13
+ * Reasoning-depth hint for a task. Alias of the neutral `ReasoningEffort` the agnostic
14
+ * Reasoner port's control vocabulary. Mapping a level to a provider's native control
15
+ * (e.g. a thinking-token budget) is the adapter's job; a provider that advertises
16
+ * `reasoningEffort: false` treats it as a no-op.
23
17
  */
24
- export type ThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
18
+ export type ThinkingLevel = ReasoningEffort;
25
19
  export interface RuntimeConfig {
26
20
  maxIterations?: number;
27
21
  timeout?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/orchestration/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG5E,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAWpF,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IACpE;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,gCAAgC,EAAE,SAAS,CAAC;IAC/D;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAA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WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAI7B;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAc9E;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B9B;;OAEG;IACH,SAAS,IAAI;QACX,cAAc,EAAE,OAAO,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;KACxB;CAOF"}
@@ -9,14 +9,6 @@ import { estimateCost } from '../llm/token-counter.js';
9
9
  import { ToolCallDeduplicator } from '../tools/deduplicator.js';
10
10
  import { createToolsFromMcpClient, discoverMCPTools } from '../tools/mcp-adapter.js';
11
11
  import { createWebSearchTool } from '../tools/web/duck-duck-go.js';
12
- const THINKING_BUDGETS = {
13
- off: 0,
14
- minimal: 512,
15
- low: 2048,
16
- medium: 8000,
17
- high: 16000,
18
- xhigh: 31999,
19
- };
20
12
  export class AgentRuntime {
21
13
  config;
22
14
  taskQueue = [];
@@ -101,8 +93,8 @@ export class AgentRuntime {
101
93
  {
102
94
  role: 'system',
103
95
  content: agent.instructions,
104
- // Cache agent instructions for cost savings (Anthropic only)
105
- cacheControl: this.config.enableCache ? { type: 'ephemeral' } : undefined,
96
+ // Cache agent instructions for cost savings (effective where promptCache is supported)
97
+ cache: this.config.enableCache || undefined,
106
98
  },
107
99
  {
108
100
  role: 'user',
@@ -130,10 +122,6 @@ export class AgentRuntime {
130
122
  },
131
123
  };
132
124
  }
133
- // Resolve thinking budget if a level is configured
134
- const thinkingBudget = this.config.thinkingLevel && this.config.thinkingLevel !== 'off'
135
- ? THINKING_BUDGETS[this.config.thinkingLevel]
136
- : undefined;
137
125
  // Get LLM response (with caching for agent instructions and tools)
138
126
  const response = await llmClient.chat(messages, {
139
127
  tools: allTools.map((tool) => ({
@@ -144,8 +132,8 @@ export class AgentRuntime {
144
132
  parameters: z.toJSONSchema(tool.parameters),
145
133
  },
146
134
  })),
147
- enableCache: this.config.enableCache,
148
- thinkingBudget,
135
+ cacheHint: this.config.enableCache,
136
+ effort: this.config.thinkingLevel,
149
137
  });
150
138
  // Accumulate token usage and cost
151
139
  const iterationTokens = response.usage?.totalTokens ?? 0;
@@ -36,7 +36,7 @@ export class StreamingAgentRuntime extends AgentRuntime {
36
36
  {
37
37
  role: 'system',
38
38
  content: agent.instructions,
39
- cacheControl: { type: 'ephemeral' },
39
+ cache: true,
40
40
  },
41
41
  {
42
42
  role: 'user',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revealui/ai",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "AI runtime for agent-driven products — agents, memory, LLM providers (Inference Snaps, Ollama, OpenAI-compatible), tools, and orchestration. Anthropic-SDK-free.",
5
5
  "keywords": [
6
6
  "agent",
@@ -25,20 +25,20 @@
25
25
  "dependencies": {
26
26
  "lru-cache": "^11.5.1",
27
27
  "zod": "^4.4.3",
28
- "@revealui/contracts": "0.6.1",
29
- "@revealui/core": "0.10.1",
30
- "@revealui/db": "0.7.1",
28
+ "@revealui/contracts": "0.6.2",
29
+ "@revealui/core": "0.11.0",
30
+ "@revealui/db": "0.7.3",
31
31
  "@revealui/resilience": "0.2.4"
32
32
  },
33
33
  "devDependencies": {
34
- "@electric-sql/pglite": "^0.5.1",
34
+ "@electric-sql/pglite": "^0.5.4",
35
35
  "@testing-library/react": "^16.3.2",
36
- "@vitest/coverage-v8": "^4.1.8",
36
+ "@vitest/coverage-v8": "^4.1.10",
37
37
  "jsdom": "29.1.1",
38
38
  "react": "^19.2.7",
39
39
  "react-dom": "^19.2.7",
40
40
  "typescript": "^6.0.3",
41
- "vitest": "^4.1.8",
41
+ "vitest": "^4.1.10",
42
42
  "@revealui/dev": "0.1.0"
43
43
  },
44
44
  "engines": {