@msm-core/mini 0.5.1 → 0.8.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 +25 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/memory-store.d.ts +38 -0
- package/dist/adapters/memory-store.js +73 -0
- package/dist/adapters/redis-memory.d.ts +13 -8
- package/dist/adapters/redis-memory.js +5 -0
- package/dist/brain/anthropic.js +50 -17
- package/dist/brain/gemini.js +68 -35
- package/dist/brain/ollama.js +68 -19
- package/dist/brain/openai.js +57 -23
- package/dist/brain/pricing.js +1 -0
- package/dist/brain/streaming.d.ts +315 -0
- package/dist/brain/streaming.js +439 -0
- package/dist/brain/tool-context.d.ts +50 -2
- package/dist/brain/tool-context.js +88 -0
- package/dist/core/context-builder.d.ts +11 -0
- package/dist/core/context-builder.js +11 -1
- package/dist/core/hooks.d.ts +10 -0
- package/dist/core/hooks.js +14 -0
- package/dist/core/loop.d.ts +43 -1
- package/dist/core/loop.js +749 -98
- package/dist/core/types.d.ts +223 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -0
- package/package.json +11 -11
package/dist/core/loop.d.ts
CHANGED
|
@@ -7,9 +7,51 @@
|
|
|
7
7
|
* respond/clarify/escalate → deliver → done
|
|
8
8
|
* budget exhausted → force_respond → done
|
|
9
9
|
*/
|
|
10
|
-
import type { AgentConfig } from "./types.js";
|
|
10
|
+
import type { AgentConfig, Brain, CompactionPort } from "./types.js";
|
|
11
11
|
/**
|
|
12
12
|
* Create a stateful agent from config.
|
|
13
13
|
* Returns an Agent object — call .handle() on every incoming event.
|
|
14
14
|
*/
|
|
15
15
|
export declare function createAgent(config: AgentConfig): import("./types.js").Agent;
|
|
16
|
+
/** Tuning for `createBrainCompactor`. Every field has a working default. */
|
|
17
|
+
export interface BrainCompactorOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Compact once the derived conversation is LONGER than this many messages.
|
|
20
|
+
* Defaults to the budget the loop passes in — i.e. compact exactly when the
|
|
21
|
+
* trim would otherwise start dropping the head, which is the moment the
|
|
22
|
+
* silent loss begins.
|
|
23
|
+
*/
|
|
24
|
+
threshold?: number;
|
|
25
|
+
/** Trailing turns to leave verbatim. Default 2 — the current exchange and the one before it. */
|
|
26
|
+
keepTurns?: number;
|
|
27
|
+
/** The system context for the summarising call. */
|
|
28
|
+
systemContext?: string;
|
|
29
|
+
/** The instruction placed above the transcript. */
|
|
30
|
+
instruction?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A `CompactionPort` that summarises with an injected `Brain`.
|
|
34
|
+
*
|
|
35
|
+
* **A reference implementation, not a requirement.** The port is the contract;
|
|
36
|
+
* this is one way to satisfy it, and a consumer with a cheaper model, a local
|
|
37
|
+
* one, or a rule-based summariser wires up its own and the loop cannot tell.
|
|
38
|
+
*
|
|
39
|
+
* It opens no connection of its own. The summary is an ordinary `brain.run`
|
|
40
|
+
* call on a brain the caller built and injected — the same covenant as every
|
|
41
|
+
* other port in this package: nothing here knows the network.
|
|
42
|
+
*
|
|
43
|
+
* Two deliberate refusals:
|
|
44
|
+
*
|
|
45
|
+
* - It does not use the agent's own tools, history or system context. A
|
|
46
|
+
* summariser that could call tools is a second agent with no budget and no
|
|
47
|
+
* guards.
|
|
48
|
+
* - It does not swallow a provider failure. An empty answer is a decision
|
|
49
|
+
* ("nothing to compact"); a thrown error is a broken compactor, and a
|
|
50
|
+
* compactor that has been quietly failing is a session quietly losing its
|
|
51
|
+
* head — the failure ض١ exists to end.
|
|
52
|
+
*
|
|
53
|
+
* The rendering is deterministic and reuses `toWireMessage`, so the summariser
|
|
54
|
+
* reads a tool round-trip exactly as the agent's own model reads it (س٤'s wire
|
|
55
|
+
* contract), and the same conversation always produces the same prompt.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createBrainCompactor(brain: Brain, opts?: BrainCompactorOptions): CompactionPort;
|