lemura 1.5.4 → 1.6.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 +21 -0
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/{adapters-DAzmrg4l.d.mts → adapters-BN6und82.d.mts} +9 -0
- package/dist/{adapters-CIRkrCHl.d.ts → adapters-CnsgefYR.d.ts} +9 -0
- package/dist/{agent-UBaqufhp.d.mts → agent-B2okLlzq.d.mts} +88 -3
- package/dist/{agent-CknicweT.d.ts → agent-BppqfsIZ.d.ts} +88 -3
- package/dist/context/index.d.mts +2 -2
- package/dist/context/index.d.ts +2 -2
- package/dist/index.d.mts +65 -5
- package/dist/index.d.ts +65 -5
- package/dist/index.js +157 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -9
- package/dist/index.mjs.map +1 -1
- package/dist/tools/index.d.mts +2 -2
- package/dist/tools/index.d.ts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.6.0] - 2026-06-05
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **MetaRouter — per-turn intent classification + tool narrowing** (`SessionConfig.enableRouting`): An optional router runs once at the start of each turn, before the ReAct loop, to (1) classify the message as `chat` or `task`, and (2) select which tool categories are relevant. Tools whose `category` is not selected are hidden from the model for that turn — fewer, more relevant tools means less confusion and lower token cost. A `chat` verdict also suppresses goal planning and verification for that turn. Off by default; when disabled, all tools are exposed exactly as before (fully backward-compatible).
|
|
13
|
+
- **`IRouterAdapter` interface** (`src/types/agent.ts`): `route(userMessage, availableCategories) => RouterDecision`. Supply a custom router via `SessionConfig.router`, or use the built-in `LLMRouter`. Implementations should fail safe — return `{ mode: 'task', categories: <all> }` on error so the agent never loses tool access.
|
|
14
|
+
- **`LLMRouter`** (`src/agent/execution/Router.ts`): Built-in router. Single temperature-0 LLM classification call, a conversational fast-path that skips the LLM for greetings/acknowledgements, and a fail-safe fallback to all categories on any parse/LLM error. Hallucinated categories not in the offered set are dropped.
|
|
15
|
+
- **`RouterDecision` / `ToolCategoryInfo` interfaces** (`src/types/agent.ts`): `RouterDecision` = `{ mode: 'chat' | 'task'; categories: string[]; reason?: string }`. `ToolCategoryInfo` = `{ name: string; tools: string[] }`, passed to the router so it knows what each category contains.
|
|
16
|
+
- **`IToolDefinition.category?: string`**: Optional category tag used by the router to group tools. Open string — lemura does not own a fixed catalog. Uncategorized tools are never filtered out (treated as always available).
|
|
17
|
+
- **`SessionConfig.router`**: Custom `IRouterAdapter`. Takes precedence over the built-in router when `enableRouting` is true.
|
|
18
|
+
- **`SessionConfig.routerModel`**: Model used by the built-in router. Defaults to `config.model` — point this at a small/cheap model for fast classification.
|
|
19
|
+
- **`SessionConfig.alwaysAvailableCategories?: string[]`**: Categories always exposed regardless of the router decision (e.g. a scratchpad category).
|
|
20
|
+
- **`TraceEvent.type: 'routing'`**: New trace type. Emitted as `route_decision` with `mode`, `categories`, and `reason`.
|
|
21
|
+
- **`Router.test.ts`**: Unit tests covering tool narrowing, always-available categories, the routing-disabled default, the no-categorized-tools fallback, and the built-in `LLMRouter` (fast-path, hallucinated-category dropping, fail-safe).
|
|
22
|
+
|
|
23
|
+
## [1.5.5] - 2026-06-01
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- **Duplicated response in `stream()` during goal correction** (significant): `stream()` yielded the model's first answer to the caller *live*, then ran goal verification *afterwards*. When the verifier returned `achieved: false` and a correction re-entry followed, the corrected answer was streamed immediately after the already-emitted first answer — surfacing both as one duplicated response (contradicting the documented "delivers only the clean final response" contract). The final response is now **buffered** until verification settles; a rejected attempt is silently discarded and corrected, so the stream emits only the single approved answer. `run()` was unaffected (it already buffered).
|
|
28
|
+
|
|
8
29
|
## [1.5.4] - 2026-05-30
|
|
9
30
|
|
|
10
31
|
### Fixed
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as IProviderAdapter, l as CompletionRequest, m as CompletionResponse, k as CompletionChunk, M as ModelInfo, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse } from '../adapters-
|
|
1
|
+
import { a as IProviderAdapter, l as CompletionRequest, m as CompletionResponse, k as CompletionChunk, M as ModelInfo, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse } from '../adapters-BN6und82.mjs';
|
|
2
2
|
import '../rag-La_Bo-J8.mjs';
|
|
3
3
|
import '../logger-DxvKliuk.mjs';
|
|
4
4
|
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as IProviderAdapter, l as CompletionRequest, m as CompletionResponse, k as CompletionChunk, M as ModelInfo, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse } from '../adapters-
|
|
1
|
+
import { a as IProviderAdapter, l as CompletionRequest, m as CompletionResponse, k as CompletionChunk, M as ModelInfo, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse } from '../adapters-CnsgefYR.js';
|
|
2
2
|
import '../rag-La_Bo-J8.js';
|
|
3
3
|
import '../logger-DxvKliuk.js';
|
|
4
4
|
|
|
@@ -151,6 +151,15 @@ interface IToolDefinition {
|
|
|
151
151
|
parameters: Record<string, unknown>;
|
|
152
152
|
/** Per-call timeout in milliseconds. Falls back to ToolRegistry.defaultTimeoutMs when omitted. */
|
|
153
153
|
timeoutMs?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Optional category used by the router (see `SessionConfig.enableRouting`) to
|
|
156
|
+
* narrow which tools are exposed to the model on a given turn. Open string —
|
|
157
|
+
* lemura does not own a fixed catalog. Tools left uncategorized are never
|
|
158
|
+
* filtered out (treated as always available).
|
|
159
|
+
*
|
|
160
|
+
* @since 1.6.0
|
|
161
|
+
*/
|
|
162
|
+
category?: string;
|
|
154
163
|
execute(params: unknown, context: ToolContext): Promise<unknown>;
|
|
155
164
|
}
|
|
156
165
|
|
|
@@ -151,6 +151,15 @@ interface IToolDefinition {
|
|
|
151
151
|
parameters: Record<string, unknown>;
|
|
152
152
|
/** Per-call timeout in milliseconds. Falls back to ToolRegistry.defaultTimeoutMs when omitted. */
|
|
153
153
|
timeoutMs?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Optional category used by the router (see `SessionConfig.enableRouting`) to
|
|
156
|
+
* narrow which tools are exposed to the model on a given turn. Open string —
|
|
157
|
+
* lemura does not own a fixed catalog. Tools left uncategorized are never
|
|
158
|
+
* filtered out (treated as always available).
|
|
159
|
+
*
|
|
160
|
+
* @since 1.6.0
|
|
161
|
+
*/
|
|
162
|
+
category?: string;
|
|
154
163
|
execute(params: unknown, context: ToolContext): Promise<unknown>;
|
|
155
164
|
}
|
|
156
165
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IToolDefinition, a as IProviderAdapter, b as IContextStrategy, S as ShortTermMemoryRegistry, c as IScratchpadAdapter, T as Turn } from './adapters-
|
|
1
|
+
import { I as IToolDefinition, a as IProviderAdapter, b as IContextStrategy, S as ShortTermMemoryRegistry, c as IScratchpadAdapter, T as Turn } from './adapters-BN6und82.mjs';
|
|
2
2
|
import { I as ILogger } from './logger-DxvKliuk.mjs';
|
|
3
3
|
import { I as ISkill } from './skills-Y6D7zSSw.mjs';
|
|
4
4
|
import { I as IRAGAdapter } from './rag-La_Bo-J8.mjs';
|
|
@@ -242,6 +242,55 @@ interface GoalVerifierResult {
|
|
|
242
242
|
/** Short human-readable reason for the verdict — surfaced in trace events */
|
|
243
243
|
reason?: string;
|
|
244
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Lightweight description of a tool category, passed to a router so it can
|
|
247
|
+
* decide which categories are relevant to the current user message.
|
|
248
|
+
*
|
|
249
|
+
* @since 1.6.0
|
|
250
|
+
*/
|
|
251
|
+
interface ToolCategoryInfo {
|
|
252
|
+
/** The category name (matches `IToolDefinition.category`). */
|
|
253
|
+
name: string;
|
|
254
|
+
/** Names of the tools belonging to this category — gives the router context. */
|
|
255
|
+
tools: string[];
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Verdict returned by a router for a single user turn.
|
|
259
|
+
*
|
|
260
|
+
* @since 1.6.0
|
|
261
|
+
*/
|
|
262
|
+
interface RouterDecision {
|
|
263
|
+
/**
|
|
264
|
+
* `'chat'` marks a purely conversational turn — the consumer/loop should
|
|
265
|
+
* skip the heavy pipeline (no tool exposure beyond always-available
|
|
266
|
+
* categories, and goal planning/verification suppressed for this turn).
|
|
267
|
+
* `'task'` runs the full pipeline.
|
|
268
|
+
*/
|
|
269
|
+
mode: 'chat' | 'task';
|
|
270
|
+
/**
|
|
271
|
+
* Tool categories selected as relevant. Empty implies no categorized tools
|
|
272
|
+
* are exposed (typical for `mode: 'chat'`). Always-available categories
|
|
273
|
+
* (see `SessionConfig.alwaysAvailableCategories`) and uncategorized tools
|
|
274
|
+
* are exposed regardless of this list.
|
|
275
|
+
*/
|
|
276
|
+
categories: string[];
|
|
277
|
+
/** Short human-readable reason — surfaced in trace events. */
|
|
278
|
+
reason?: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Pluggable router. Maps a user message to a {@link RouterDecision} that
|
|
282
|
+
* narrows the tool surface for the turn. Supply your own, or enable the
|
|
283
|
+
* built-in LLM router via `SessionConfig.enableRouting`.
|
|
284
|
+
*
|
|
285
|
+
* Implementations should **fail safe**: on any internal error, return
|
|
286
|
+
* `{ mode: 'task', categories: <all categories> }` so the agent never loses
|
|
287
|
+
* access to tools because routing hiccupped.
|
|
288
|
+
*
|
|
289
|
+
* @since 1.6.0
|
|
290
|
+
*/
|
|
291
|
+
interface IRouterAdapter {
|
|
292
|
+
route(userMessage: string, availableCategories: ToolCategoryInfo[]): Promise<RouterDecision> | RouterDecision;
|
|
293
|
+
}
|
|
245
294
|
/** Configuration for a lemura Session */
|
|
246
295
|
interface SessionConfig {
|
|
247
296
|
/** The provider adapter to use */
|
|
@@ -403,11 +452,47 @@ interface SessionConfig {
|
|
|
403
452
|
* ]
|
|
404
453
|
*/
|
|
405
454
|
mcpServers?: MCPServerConfig[];
|
|
455
|
+
/**
|
|
456
|
+
* When true, a router runs once at the start of each turn (before the ReAct
|
|
457
|
+
* loop) to classify the message (`chat`/`task`) and select relevant tool
|
|
458
|
+
* categories. Tools whose `category` is not selected are hidden from the
|
|
459
|
+
* model for that turn — fewer, more relevant tools means less confusion and
|
|
460
|
+
* lower token cost. A `chat` verdict also suppresses goal planning and
|
|
461
|
+
* verification for that turn.
|
|
462
|
+
*
|
|
463
|
+
* If `router` is supplied it is used; otherwise lemura's built-in
|
|
464
|
+
* {@link LLMRouter} is used. Defaults to false (no routing — all tools
|
|
465
|
+
* always exposed, identical to pre-1.6.0 behavior).
|
|
466
|
+
*
|
|
467
|
+
* @since 1.6.0
|
|
468
|
+
*/
|
|
469
|
+
enableRouting?: boolean;
|
|
470
|
+
/**
|
|
471
|
+
* Custom router implementation. Takes precedence over the built-in router
|
|
472
|
+
* when `enableRouting` is true.
|
|
473
|
+
*
|
|
474
|
+
* @since 1.6.0
|
|
475
|
+
*/
|
|
476
|
+
router?: IRouterAdapter;
|
|
477
|
+
/**
|
|
478
|
+
* Model used by the built-in router. Defaults to `config.model`. Point this
|
|
479
|
+
* at a small/cheap model for fast, low-cost classification.
|
|
480
|
+
*
|
|
481
|
+
* @since 1.6.0
|
|
482
|
+
*/
|
|
483
|
+
routerModel?: string;
|
|
484
|
+
/**
|
|
485
|
+
* Categories that are always exposed regardless of the router decision
|
|
486
|
+
* (e.g. a scratchpad category). Uncategorized tools are also always exposed.
|
|
487
|
+
*
|
|
488
|
+
* @since 1.6.0
|
|
489
|
+
*/
|
|
490
|
+
alwaysAvailableCategories?: string[];
|
|
406
491
|
}
|
|
407
492
|
/** Rich trace event for observability */
|
|
408
493
|
interface TraceEvent {
|
|
409
494
|
sessionId?: string;
|
|
410
|
-
type: 'planning' | 'budget' | 'tool_call' | 'tool_result' | 'thinking' | 'system' | 'compression' | 'error' | 'skill' | 'verification';
|
|
495
|
+
type: 'planning' | 'budget' | 'tool_call' | 'tool_result' | 'thinking' | 'system' | 'compression' | 'error' | 'skill' | 'verification' | 'routing';
|
|
411
496
|
name: string;
|
|
412
497
|
input?: any;
|
|
413
498
|
output?: any;
|
|
@@ -417,4 +502,4 @@ interface TraceEvent {
|
|
|
417
502
|
metadata?: Record<string, any>;
|
|
418
503
|
}
|
|
419
504
|
|
|
420
|
-
export { type Goal as G, type IToolResponseProcessor as I, type MCPServerConfig as M, type SessionConfig as S, type ToolResponseEvaluation as T, type
|
|
505
|
+
export { type Goal as G, type IToolResponseProcessor as I, type MCPServerConfig as M, type RouterDecision as R, type SessionConfig as S, type ToolResponseEvaluation as T, type IRouterAdapter as a, type ToolCategoryInfo as b, type MCPToolDefinition as c, GoalInjector as d, type GoalVerifierResult as e, type MCPJsonRpcRequest as f, type MCPJsonRpcResponse as g, type MCPTransportType as h, type MediaConfig as i, type ToolDecision as j, type ToolExecutionBudget as k, type ToolFirewallConfig as l, type ToolFirewallRule as m, type TraceEvent as n };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IToolDefinition, a as IProviderAdapter, b as IContextStrategy, S as ShortTermMemoryRegistry, c as IScratchpadAdapter, T as Turn } from './adapters-
|
|
1
|
+
import { I as IToolDefinition, a as IProviderAdapter, b as IContextStrategy, S as ShortTermMemoryRegistry, c as IScratchpadAdapter, T as Turn } from './adapters-CnsgefYR.js';
|
|
2
2
|
import { I as ILogger } from './logger-DxvKliuk.js';
|
|
3
3
|
import { I as ISkill } from './skills-Y6D7zSSw.js';
|
|
4
4
|
import { I as IRAGAdapter } from './rag-La_Bo-J8.js';
|
|
@@ -242,6 +242,55 @@ interface GoalVerifierResult {
|
|
|
242
242
|
/** Short human-readable reason for the verdict — surfaced in trace events */
|
|
243
243
|
reason?: string;
|
|
244
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Lightweight description of a tool category, passed to a router so it can
|
|
247
|
+
* decide which categories are relevant to the current user message.
|
|
248
|
+
*
|
|
249
|
+
* @since 1.6.0
|
|
250
|
+
*/
|
|
251
|
+
interface ToolCategoryInfo {
|
|
252
|
+
/** The category name (matches `IToolDefinition.category`). */
|
|
253
|
+
name: string;
|
|
254
|
+
/** Names of the tools belonging to this category — gives the router context. */
|
|
255
|
+
tools: string[];
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Verdict returned by a router for a single user turn.
|
|
259
|
+
*
|
|
260
|
+
* @since 1.6.0
|
|
261
|
+
*/
|
|
262
|
+
interface RouterDecision {
|
|
263
|
+
/**
|
|
264
|
+
* `'chat'` marks a purely conversational turn — the consumer/loop should
|
|
265
|
+
* skip the heavy pipeline (no tool exposure beyond always-available
|
|
266
|
+
* categories, and goal planning/verification suppressed for this turn).
|
|
267
|
+
* `'task'` runs the full pipeline.
|
|
268
|
+
*/
|
|
269
|
+
mode: 'chat' | 'task';
|
|
270
|
+
/**
|
|
271
|
+
* Tool categories selected as relevant. Empty implies no categorized tools
|
|
272
|
+
* are exposed (typical for `mode: 'chat'`). Always-available categories
|
|
273
|
+
* (see `SessionConfig.alwaysAvailableCategories`) and uncategorized tools
|
|
274
|
+
* are exposed regardless of this list.
|
|
275
|
+
*/
|
|
276
|
+
categories: string[];
|
|
277
|
+
/** Short human-readable reason — surfaced in trace events. */
|
|
278
|
+
reason?: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Pluggable router. Maps a user message to a {@link RouterDecision} that
|
|
282
|
+
* narrows the tool surface for the turn. Supply your own, or enable the
|
|
283
|
+
* built-in LLM router via `SessionConfig.enableRouting`.
|
|
284
|
+
*
|
|
285
|
+
* Implementations should **fail safe**: on any internal error, return
|
|
286
|
+
* `{ mode: 'task', categories: <all categories> }` so the agent never loses
|
|
287
|
+
* access to tools because routing hiccupped.
|
|
288
|
+
*
|
|
289
|
+
* @since 1.6.0
|
|
290
|
+
*/
|
|
291
|
+
interface IRouterAdapter {
|
|
292
|
+
route(userMessage: string, availableCategories: ToolCategoryInfo[]): Promise<RouterDecision> | RouterDecision;
|
|
293
|
+
}
|
|
245
294
|
/** Configuration for a lemura Session */
|
|
246
295
|
interface SessionConfig {
|
|
247
296
|
/** The provider adapter to use */
|
|
@@ -403,11 +452,47 @@ interface SessionConfig {
|
|
|
403
452
|
* ]
|
|
404
453
|
*/
|
|
405
454
|
mcpServers?: MCPServerConfig[];
|
|
455
|
+
/**
|
|
456
|
+
* When true, a router runs once at the start of each turn (before the ReAct
|
|
457
|
+
* loop) to classify the message (`chat`/`task`) and select relevant tool
|
|
458
|
+
* categories. Tools whose `category` is not selected are hidden from the
|
|
459
|
+
* model for that turn — fewer, more relevant tools means less confusion and
|
|
460
|
+
* lower token cost. A `chat` verdict also suppresses goal planning and
|
|
461
|
+
* verification for that turn.
|
|
462
|
+
*
|
|
463
|
+
* If `router` is supplied it is used; otherwise lemura's built-in
|
|
464
|
+
* {@link LLMRouter} is used. Defaults to false (no routing — all tools
|
|
465
|
+
* always exposed, identical to pre-1.6.0 behavior).
|
|
466
|
+
*
|
|
467
|
+
* @since 1.6.0
|
|
468
|
+
*/
|
|
469
|
+
enableRouting?: boolean;
|
|
470
|
+
/**
|
|
471
|
+
* Custom router implementation. Takes precedence over the built-in router
|
|
472
|
+
* when `enableRouting` is true.
|
|
473
|
+
*
|
|
474
|
+
* @since 1.6.0
|
|
475
|
+
*/
|
|
476
|
+
router?: IRouterAdapter;
|
|
477
|
+
/**
|
|
478
|
+
* Model used by the built-in router. Defaults to `config.model`. Point this
|
|
479
|
+
* at a small/cheap model for fast, low-cost classification.
|
|
480
|
+
*
|
|
481
|
+
* @since 1.6.0
|
|
482
|
+
*/
|
|
483
|
+
routerModel?: string;
|
|
484
|
+
/**
|
|
485
|
+
* Categories that are always exposed regardless of the router decision
|
|
486
|
+
* (e.g. a scratchpad category). Uncategorized tools are also always exposed.
|
|
487
|
+
*
|
|
488
|
+
* @since 1.6.0
|
|
489
|
+
*/
|
|
490
|
+
alwaysAvailableCategories?: string[];
|
|
406
491
|
}
|
|
407
492
|
/** Rich trace event for observability */
|
|
408
493
|
interface TraceEvent {
|
|
409
494
|
sessionId?: string;
|
|
410
|
-
type: 'planning' | 'budget' | 'tool_call' | 'tool_result' | 'thinking' | 'system' | 'compression' | 'error' | 'skill' | 'verification';
|
|
495
|
+
type: 'planning' | 'budget' | 'tool_call' | 'tool_result' | 'thinking' | 'system' | 'compression' | 'error' | 'skill' | 'verification' | 'routing';
|
|
411
496
|
name: string;
|
|
412
497
|
input?: any;
|
|
413
498
|
output?: any;
|
|
@@ -417,4 +502,4 @@ interface TraceEvent {
|
|
|
417
502
|
metadata?: Record<string, any>;
|
|
418
503
|
}
|
|
419
504
|
|
|
420
|
-
export { type Goal as G, type IToolResponseProcessor as I, type MCPServerConfig as M, type SessionConfig as S, type ToolResponseEvaluation as T, type
|
|
505
|
+
export { type Goal as G, type IToolResponseProcessor as I, type MCPServerConfig as M, type RouterDecision as R, type SessionConfig as S, type ToolResponseEvaluation as T, type IRouterAdapter as a, type ToolCategoryInfo as b, type MCPToolDefinition as c, GoalInjector as d, type GoalVerifierResult as e, type MCPJsonRpcRequest as f, type MCPJsonRpcResponse as g, type MCPTransportType as h, type MediaConfig as i, type ToolDecision as j, type ToolExecutionBudget as k, type ToolFirewallConfig as l, type ToolFirewallRule as m, type TraceEvent as n };
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as IContextStrategy, C as ContextWindow, a as IProviderAdapter, n as IStorageAdapter, c as IScratchpadAdapter } from '../adapters-
|
|
2
|
-
export { p as STMRegistryConfig, S as ShortTermMemoryRegistry } from '../adapters-
|
|
1
|
+
import { b as IContextStrategy, C as ContextWindow, a as IProviderAdapter, n as IStorageAdapter, c as IScratchpadAdapter } from '../adapters-BN6und82.mjs';
|
|
2
|
+
export { p as STMRegistryConfig, S as ShortTermMemoryRegistry } from '../adapters-BN6und82.mjs';
|
|
3
3
|
import '../rag-La_Bo-J8.mjs';
|
|
4
4
|
import '../logger-DxvKliuk.mjs';
|
|
5
5
|
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as IContextStrategy, C as ContextWindow, a as IProviderAdapter, n as IStorageAdapter, c as IScratchpadAdapter } from '../adapters-
|
|
2
|
-
export { p as STMRegistryConfig, S as ShortTermMemoryRegistry } from '../adapters-
|
|
1
|
+
import { b as IContextStrategy, C as ContextWindow, a as IProviderAdapter, n as IStorageAdapter, c as IScratchpadAdapter } from '../adapters-CnsgefYR.js';
|
|
2
|
+
export { p as STMRegistryConfig, S as ShortTermMemoryRegistry } from '../adapters-CnsgefYR.js';
|
|
3
3
|
import '../rag-La_Bo-J8.js';
|
|
4
4
|
import '../logger-DxvKliuk.js';
|
|
5
5
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as IProviderAdapter, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse, M as ModelInfo, C as ContextWindow, T as Turn, j as ContentBlock, I as IToolDefinition } from './adapters-
|
|
2
|
-
export { k as CompletionChunk, l as CompletionRequest, m as CompletionResponse, b as IContextStrategy, c as IScratchpadAdapter, n as IStorageAdapter, N as NormalizedMessage, o as STMItem, p as STMRegistryConfig, S as ShortTermMemoryRegistry, q as TokenUsage, r as ToolCall, s as ToolContext, t as ToolResult } from './adapters-
|
|
3
|
-
import { S as SessionConfig, G as Goal, I as IToolResponseProcessor, T as ToolResponseEvaluation, M as MCPServerConfig,
|
|
4
|
-
export {
|
|
1
|
+
import { a as IProviderAdapter, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse, M as ModelInfo, C as ContextWindow, T as Turn, j as ContentBlock, I as IToolDefinition } from './adapters-BN6und82.mjs';
|
|
2
|
+
export { k as CompletionChunk, l as CompletionRequest, m as CompletionResponse, b as IContextStrategy, c as IScratchpadAdapter, n as IStorageAdapter, N as NormalizedMessage, o as STMItem, p as STMRegistryConfig, S as ShortTermMemoryRegistry, q as TokenUsage, r as ToolCall, s as ToolContext, t as ToolResult } from './adapters-BN6und82.mjs';
|
|
3
|
+
import { S as SessionConfig, G as Goal, I as IToolResponseProcessor, T as ToolResponseEvaluation, a as IRouterAdapter, b as ToolCategoryInfo, R as RouterDecision, M as MCPServerConfig, c as MCPToolDefinition } from './agent-B2okLlzq.mjs';
|
|
4
|
+
export { d as GoalInjector, e as GoalVerifierResult, f as MCPJsonRpcRequest, g as MCPJsonRpcResponse, h as MCPTransportType, i as MediaConfig, j as ToolDecision, k as ToolExecutionBudget, l as ToolFirewallConfig, m as ToolFirewallRule, n as TraceEvent } from './agent-B2okLlzq.mjs';
|
|
5
5
|
export { LemuraAdapterError, LemuraContextOverflowError, LemuraError, LemuraMCPConnectionError, LemuraMCPError, LemuraMCPTimeoutError, LemuraMaxIterationsError, LemuraSkillInjectionError, LemuraToolNotFoundError, LemuraToolTimeoutError, LemuraToolValidationError } from './types/index.mjs';
|
|
6
6
|
import { I as ILogger } from './logger-DxvKliuk.mjs';
|
|
7
7
|
export { L as LogLevel, a as LogMetadata, S as Severity } from './logger-DxvKliuk.mjs';
|
|
@@ -226,6 +226,14 @@ declare class SessionManager {
|
|
|
226
226
|
private toolResponseProcessor;
|
|
227
227
|
private goalInjector;
|
|
228
228
|
private continuationPlanner;
|
|
229
|
+
private router;
|
|
230
|
+
/**
|
|
231
|
+
* Tool categories selected by the router for the current turn, or `null` when
|
|
232
|
+
* routing is disabled / not yet run. When non-null, only tools whose
|
|
233
|
+
* `category` is in this set (plus always-available + uncategorized tools) are
|
|
234
|
+
* exposed to the model.
|
|
235
|
+
*/
|
|
236
|
+
private routedCategories;
|
|
229
237
|
/** Frozen goal/plan injection text keyed by turn index — used when staticSystemPrompt is on */
|
|
230
238
|
private _turnInjections;
|
|
231
239
|
private mcpRegistry;
|
|
@@ -358,6 +366,22 @@ declare class SessionManager {
|
|
|
358
366
|
* `stream()` await `this.mcpReady` before executing.
|
|
359
367
|
*/
|
|
360
368
|
private _initMCP;
|
|
369
|
+
/** Groups registered tools into {@link ToolCategoryInfo} by their `category`. */
|
|
370
|
+
private buildToolCategories;
|
|
371
|
+
/**
|
|
372
|
+
* Runs the router for the current turn (when enabled) and stores the selected
|
|
373
|
+
* categories in `this.routedCategories`. Returns the decision so the loop can
|
|
374
|
+
* suppress goal planning/verification on a `chat` verdict. Fail-safe: on a
|
|
375
|
+
* null/failed decision, routing is disabled for the turn (all tools exposed).
|
|
376
|
+
*/
|
|
377
|
+
private _runRoutingStep;
|
|
378
|
+
/**
|
|
379
|
+
* Returns the tools to expose this turn, filtered by the router decision.
|
|
380
|
+
* Always exposes uncategorized tools and tools in always-available /
|
|
381
|
+
* routed-in categories. When routing is off (`routedCategories === null`),
|
|
382
|
+
* returns every tool — identical to pre-routing behavior.
|
|
383
|
+
*/
|
|
384
|
+
private getActiveTools;
|
|
361
385
|
/**
|
|
362
386
|
* Runs a dedicated planning prompt against the LLM to decompose the user's
|
|
363
387
|
* message into sub-goals and success criteria. Called once at the start of
|
|
@@ -529,6 +553,42 @@ declare class FinalResponseFormatter {
|
|
|
529
553
|
static validateStructure(response: string): boolean;
|
|
530
554
|
}
|
|
531
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Options for the built-in {@link LLMRouter}.
|
|
558
|
+
*
|
|
559
|
+
* @since 1.6.0
|
|
560
|
+
*/
|
|
561
|
+
interface LLMRouterOptions {
|
|
562
|
+
adapter: IProviderAdapter;
|
|
563
|
+
model: string;
|
|
564
|
+
logger: ILogger;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Built-in MetaRouter. Classifies a user message (`chat` vs `task`) and selects
|
|
568
|
+
* the relevant tool categories with a single temperature-0 LLM call.
|
|
569
|
+
*
|
|
570
|
+
* Two cheap guards run before the LLM:
|
|
571
|
+
* - **Conversational fast-path**: short greeting/acknowledgement input is
|
|
572
|
+
* classified `chat` with no categories and no LLM call.
|
|
573
|
+
* - **No categories**: if no categorized tools exist, routing is moot — returns
|
|
574
|
+
* `task` with an empty category list (uncategorized tools are always exposed
|
|
575
|
+
* by the caller anyway).
|
|
576
|
+
*
|
|
577
|
+
* Fails safe: any error returns `{ mode: 'task', categories: <all> }` so the
|
|
578
|
+
* agent never loses tool access because routing hiccupped.
|
|
579
|
+
*
|
|
580
|
+
* @since 1.6.0
|
|
581
|
+
*/
|
|
582
|
+
declare class LLMRouter implements IRouterAdapter {
|
|
583
|
+
private adapter;
|
|
584
|
+
private model;
|
|
585
|
+
private logger;
|
|
586
|
+
/** Matches purely conversational input — greetings, thanks, acknowledgements. */
|
|
587
|
+
private static readonly CHAT_FAST_PATH;
|
|
588
|
+
constructor(opts: LLMRouterOptions);
|
|
589
|
+
route(userMessage: string, availableCategories: ToolCategoryInfo[]): Promise<RouterDecision>;
|
|
590
|
+
}
|
|
591
|
+
|
|
532
592
|
/**
|
|
533
593
|
* Low-level MCP server client.
|
|
534
594
|
*
|
|
@@ -657,4 +717,4 @@ declare class MCPClientRegistry {
|
|
|
657
717
|
private _bridge;
|
|
658
718
|
}
|
|
659
719
|
|
|
660
|
-
export { AudioChunk, ContentBlock, ContextWindow, type ContinuationPlan, ContinuationPlanner, type ContinuationStep, FinalResponseFormatter, Goal, ILogger, IProviderAdapter, IToolDefinition, IToolResponseProcessor, ImageGenRequest, ImageGenResponse, MCPClient, MCPClientRegistry, MCPServerConfig, MCPToolDefinition, MediaBridge, ModelInfo, SessionConfig, SessionManager, SkillInjector, type StepCondition, StepCounter, type StepVerifier, type StepVerifierResult, SynthesisRequest, ToolRegistry, ToolResponseEvaluation, ToolResponseProcessor, type ToolResponseProcessorConfig, TranscriptionRequest, TranscriptionResponse, Turn, VisionRequest, VisionResponse };
|
|
720
|
+
export { AudioChunk, ContentBlock, ContextWindow, type ContinuationPlan, ContinuationPlanner, type ContinuationStep, FinalResponseFormatter, Goal, ILogger, IProviderAdapter, IRouterAdapter, IToolDefinition, IToolResponseProcessor, ImageGenRequest, ImageGenResponse, LLMRouter, type LLMRouterOptions, MCPClient, MCPClientRegistry, MCPServerConfig, MCPToolDefinition, MediaBridge, ModelInfo, RouterDecision, SessionConfig, SessionManager, SkillInjector, type StepCondition, StepCounter, type StepVerifier, type StepVerifierResult, SynthesisRequest, ToolCategoryInfo, ToolRegistry, ToolResponseEvaluation, ToolResponseProcessor, type ToolResponseProcessorConfig, TranscriptionRequest, TranscriptionResponse, Turn, VisionRequest, VisionResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as IProviderAdapter, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse, M as ModelInfo, C as ContextWindow, T as Turn, j as ContentBlock, I as IToolDefinition } from './adapters-
|
|
2
|
-
export { k as CompletionChunk, l as CompletionRequest, m as CompletionResponse, b as IContextStrategy, c as IScratchpadAdapter, n as IStorageAdapter, N as NormalizedMessage, o as STMItem, p as STMRegistryConfig, S as ShortTermMemoryRegistry, q as TokenUsage, r as ToolCall, s as ToolContext, t as ToolResult } from './adapters-
|
|
3
|
-
import { S as SessionConfig, G as Goal, I as IToolResponseProcessor, T as ToolResponseEvaluation, M as MCPServerConfig,
|
|
4
|
-
export {
|
|
1
|
+
import { a as IProviderAdapter, d as TranscriptionRequest, e as TranscriptionResponse, f as SynthesisRequest, A as AudioChunk, V as VisionRequest, g as VisionResponse, h as ImageGenRequest, i as ImageGenResponse, M as ModelInfo, C as ContextWindow, T as Turn, j as ContentBlock, I as IToolDefinition } from './adapters-CnsgefYR.js';
|
|
2
|
+
export { k as CompletionChunk, l as CompletionRequest, m as CompletionResponse, b as IContextStrategy, c as IScratchpadAdapter, n as IStorageAdapter, N as NormalizedMessage, o as STMItem, p as STMRegistryConfig, S as ShortTermMemoryRegistry, q as TokenUsage, r as ToolCall, s as ToolContext, t as ToolResult } from './adapters-CnsgefYR.js';
|
|
3
|
+
import { S as SessionConfig, G as Goal, I as IToolResponseProcessor, T as ToolResponseEvaluation, a as IRouterAdapter, b as ToolCategoryInfo, R as RouterDecision, M as MCPServerConfig, c as MCPToolDefinition } from './agent-BppqfsIZ.js';
|
|
4
|
+
export { d as GoalInjector, e as GoalVerifierResult, f as MCPJsonRpcRequest, g as MCPJsonRpcResponse, h as MCPTransportType, i as MediaConfig, j as ToolDecision, k as ToolExecutionBudget, l as ToolFirewallConfig, m as ToolFirewallRule, n as TraceEvent } from './agent-BppqfsIZ.js';
|
|
5
5
|
export { LemuraAdapterError, LemuraContextOverflowError, LemuraError, LemuraMCPConnectionError, LemuraMCPError, LemuraMCPTimeoutError, LemuraMaxIterationsError, LemuraSkillInjectionError, LemuraToolNotFoundError, LemuraToolTimeoutError, LemuraToolValidationError } from './types/index.js';
|
|
6
6
|
import { I as ILogger } from './logger-DxvKliuk.js';
|
|
7
7
|
export { L as LogLevel, a as LogMetadata, S as Severity } from './logger-DxvKliuk.js';
|
|
@@ -226,6 +226,14 @@ declare class SessionManager {
|
|
|
226
226
|
private toolResponseProcessor;
|
|
227
227
|
private goalInjector;
|
|
228
228
|
private continuationPlanner;
|
|
229
|
+
private router;
|
|
230
|
+
/**
|
|
231
|
+
* Tool categories selected by the router for the current turn, or `null` when
|
|
232
|
+
* routing is disabled / not yet run. When non-null, only tools whose
|
|
233
|
+
* `category` is in this set (plus always-available + uncategorized tools) are
|
|
234
|
+
* exposed to the model.
|
|
235
|
+
*/
|
|
236
|
+
private routedCategories;
|
|
229
237
|
/** Frozen goal/plan injection text keyed by turn index — used when staticSystemPrompt is on */
|
|
230
238
|
private _turnInjections;
|
|
231
239
|
private mcpRegistry;
|
|
@@ -358,6 +366,22 @@ declare class SessionManager {
|
|
|
358
366
|
* `stream()` await `this.mcpReady` before executing.
|
|
359
367
|
*/
|
|
360
368
|
private _initMCP;
|
|
369
|
+
/** Groups registered tools into {@link ToolCategoryInfo} by their `category`. */
|
|
370
|
+
private buildToolCategories;
|
|
371
|
+
/**
|
|
372
|
+
* Runs the router for the current turn (when enabled) and stores the selected
|
|
373
|
+
* categories in `this.routedCategories`. Returns the decision so the loop can
|
|
374
|
+
* suppress goal planning/verification on a `chat` verdict. Fail-safe: on a
|
|
375
|
+
* null/failed decision, routing is disabled for the turn (all tools exposed).
|
|
376
|
+
*/
|
|
377
|
+
private _runRoutingStep;
|
|
378
|
+
/**
|
|
379
|
+
* Returns the tools to expose this turn, filtered by the router decision.
|
|
380
|
+
* Always exposes uncategorized tools and tools in always-available /
|
|
381
|
+
* routed-in categories. When routing is off (`routedCategories === null`),
|
|
382
|
+
* returns every tool — identical to pre-routing behavior.
|
|
383
|
+
*/
|
|
384
|
+
private getActiveTools;
|
|
361
385
|
/**
|
|
362
386
|
* Runs a dedicated planning prompt against the LLM to decompose the user's
|
|
363
387
|
* message into sub-goals and success criteria. Called once at the start of
|
|
@@ -529,6 +553,42 @@ declare class FinalResponseFormatter {
|
|
|
529
553
|
static validateStructure(response: string): boolean;
|
|
530
554
|
}
|
|
531
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Options for the built-in {@link LLMRouter}.
|
|
558
|
+
*
|
|
559
|
+
* @since 1.6.0
|
|
560
|
+
*/
|
|
561
|
+
interface LLMRouterOptions {
|
|
562
|
+
adapter: IProviderAdapter;
|
|
563
|
+
model: string;
|
|
564
|
+
logger: ILogger;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Built-in MetaRouter. Classifies a user message (`chat` vs `task`) and selects
|
|
568
|
+
* the relevant tool categories with a single temperature-0 LLM call.
|
|
569
|
+
*
|
|
570
|
+
* Two cheap guards run before the LLM:
|
|
571
|
+
* - **Conversational fast-path**: short greeting/acknowledgement input is
|
|
572
|
+
* classified `chat` with no categories and no LLM call.
|
|
573
|
+
* - **No categories**: if no categorized tools exist, routing is moot — returns
|
|
574
|
+
* `task` with an empty category list (uncategorized tools are always exposed
|
|
575
|
+
* by the caller anyway).
|
|
576
|
+
*
|
|
577
|
+
* Fails safe: any error returns `{ mode: 'task', categories: <all> }` so the
|
|
578
|
+
* agent never loses tool access because routing hiccupped.
|
|
579
|
+
*
|
|
580
|
+
* @since 1.6.0
|
|
581
|
+
*/
|
|
582
|
+
declare class LLMRouter implements IRouterAdapter {
|
|
583
|
+
private adapter;
|
|
584
|
+
private model;
|
|
585
|
+
private logger;
|
|
586
|
+
/** Matches purely conversational input — greetings, thanks, acknowledgements. */
|
|
587
|
+
private static readonly CHAT_FAST_PATH;
|
|
588
|
+
constructor(opts: LLMRouterOptions);
|
|
589
|
+
route(userMessage: string, availableCategories: ToolCategoryInfo[]): Promise<RouterDecision>;
|
|
590
|
+
}
|
|
591
|
+
|
|
532
592
|
/**
|
|
533
593
|
* Low-level MCP server client.
|
|
534
594
|
*
|
|
@@ -657,4 +717,4 @@ declare class MCPClientRegistry {
|
|
|
657
717
|
private _bridge;
|
|
658
718
|
}
|
|
659
719
|
|
|
660
|
-
export { AudioChunk, ContentBlock, ContextWindow, type ContinuationPlan, ContinuationPlanner, type ContinuationStep, FinalResponseFormatter, Goal, ILogger, IProviderAdapter, IToolDefinition, IToolResponseProcessor, ImageGenRequest, ImageGenResponse, MCPClient, MCPClientRegistry, MCPServerConfig, MCPToolDefinition, MediaBridge, ModelInfo, SessionConfig, SessionManager, SkillInjector, type StepCondition, StepCounter, type StepVerifier, type StepVerifierResult, SynthesisRequest, ToolRegistry, ToolResponseEvaluation, ToolResponseProcessor, type ToolResponseProcessorConfig, TranscriptionRequest, TranscriptionResponse, Turn, VisionRequest, VisionResponse };
|
|
720
|
+
export { AudioChunk, ContentBlock, ContextWindow, type ContinuationPlan, ContinuationPlanner, type ContinuationStep, FinalResponseFormatter, Goal, ILogger, IProviderAdapter, IRouterAdapter, IToolDefinition, IToolResponseProcessor, ImageGenRequest, ImageGenResponse, LLMRouter, type LLMRouterOptions, MCPClient, MCPClientRegistry, MCPServerConfig, MCPToolDefinition, MediaBridge, ModelInfo, RouterDecision, SessionConfig, SessionManager, SkillInjector, type StepCondition, StepCounter, type StepVerifier, type StepVerifierResult, SynthesisRequest, ToolCategoryInfo, ToolRegistry, ToolResponseEvaluation, ToolResponseProcessor, type ToolResponseProcessorConfig, TranscriptionRequest, TranscriptionResponse, Turn, VisionRequest, VisionResponse };
|