@easbot/llm 0.3.45 → 0.3.46
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.en.md +6 -5
- package/README.md +6 -5
- package/dist/index.cjs +83 -83
- package/dist/index.d.cts +132 -98
- package/dist/index.d.ts +132 -98
- package/dist/index.mjs +83 -83
- package/package.json +7 -7
package/README.en.md
CHANGED
|
@@ -6,7 +6,7 @@ English | [中文](./README.md)
|
|
|
6
6
|
|
|
7
7
|
## Version
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
9
|
+
v0.3.46
|
|
10
10
|
|
|
11
11
|
## Current Status (after V4 refactor)
|
|
12
12
|
|
|
@@ -49,13 +49,14 @@ This package has evolved from an early placeholder of `@easbot/types` into a pro
|
|
|
49
49
|
- **Two-level state** (`sessionId → streamId`): one process serves multiple sessions, and a session may run concurrent streams; the handle returned by `create()` exposes snapshots and per-stream `dispose()`, while `Instance.dispose()` reclaims everything
|
|
50
50
|
- **Forced single-step**: any caller-supplied `stopWhen` is stripped; multi-step loops are driven explicitly by the application layer between steps (permission prompts / compaction / persistence)
|
|
51
51
|
- Does **not** handle storage / retry / session state machine / permission prompts / actual compaction — all handed over to the application layer via events and verdicts
|
|
52
|
-
- ✅ **`src/loop/`**: model call loops (**
|
|
52
|
+
- ✅ **`src/loop/`**: model call loops (**three implementations — pick by scenario**)
|
|
53
53
|
- **`Loop` (simplified)** — one call plus the AI SDK's built-in `stopWhen` multi-step; **no event system, no Part system**. Suits background jobs (memory distillation / summarization / classification)
|
|
54
54
|
- **`AgentLoop` (complete)** — an **explicit multi-round driver** on top of `StreamProcessor`: one `StreamProcessor` per round, passing through the full `processor.*` event system plus Hook events; built-in cross-round trajectory accumulation and three-state verdict handling (`stop` / `continue` / `compact` → **re-enter the same logical round** after compaction, guarded by a retry cap)
|
|
55
|
+
- **`SdkLoop` (SDK-shaped)** — builds on `AgentLoop` and translates each round's events through `ProcessorSdkBridge` into SDK `SessionEvent`s (ACP `session/update` shape), aggregating complete `AgentMessage`s with `SdkMessageCollector`; exposes only `onSessionEvent` / `onMessage` / `onEvent` (token-level delta), so callers never wire the bridge or collector themselves
|
|
55
56
|
- Between-step instrumentation points: `onEvent` (event pass-through) / `onRoundFinish` (end of each round) / `buildRound` (build per-round input) / `onCompact` (run compaction) / `shouldContinue` (keep going or not)
|
|
56
57
|
- **`Loop.Input` highlights**: `maxSteps` carries the multi-step limit (equivalent to the SDK's `stopWhen: stepCountIs(n)`); `tools` defines the tools, `activeTools` narrows which are active; `system` / `messages` / `temperature` share the names and semantics of `LanguageProvider.CallInput`
|
|
57
|
-
- **Selection rule**: needs persistence / Part system / hook interception → `AgentLoop`;
|
|
58
|
-
-
|
|
58
|
+
- **Selection rule**: just "run the LLM once and take the text" → `Loop`; needs persistence / Part system / hook interception → `AgentLoop`; needs ACP-ready `session/update` or aggregated messages without wiring the SDK bridge (buddy / TUI / CLI) → `SdkLoop`
|
|
59
|
+
- In production: the **memory plugin's long-term memory distillation** uses `Loop` (`loop.end` hook); **buddy's react interaction layer** uses `SdkLoop`
|
|
59
60
|
- ✅ **`src/compaction/`**: context overflow detection (`Compaction`)
|
|
60
61
|
- **Pure functions** that only decide whether "one model request's input" exceeds the usable window; actual compaction is a session-layer business action
|
|
61
62
|
- Detection scope = everything actually sent to the model: `system` + `messages` + `tools` (one-to-one with `StreamProcessor.process(streamInput)`)
|
|
@@ -92,7 +93,7 @@ This package has evolved from an early placeholder of `@easbot/types` into a pro
|
|
|
92
93
|
- Scope resolution queries `session.contextMode` via `getSdk()`, falling back to `ScopeEnum.General`
|
|
93
94
|
- Builtin ownership principle: **the builtin lives in whichever package raises the event** (memory distillation / context compaction / gateway messages stay in agent / gateway)
|
|
94
95
|
- **Initialization**: `bootstrapLlm()` automatically warms up `LlmHookRegistry` (before model loading, so any `triggerEvent` in the instantiation chain observes the builtin hooks); a failed warm-up degrades to a warn and falls back to `ensureBridge()` on the first `triggerEvent`
|
|
95
|
-
- ✅ **`src/index.ts`** — aggregate export entry (4 provider namespaces + 3 model namespaces + self-developed Copilot SDK + 3 constants + Config / interfaces + AdapterRegistry + 4 Provider interfaces)
|
|
96
|
+
- ✅ **`src/index.ts`** — aggregate export entry (4 provider namespaces + 3 model namespaces + self-developed Copilot SDK + 3 constants + Config / interfaces + AdapterRegistry + 4 Provider interfaces + `Loop` / `AgentLoop` / `SdkLoop`)
|
|
96
97
|
- ✅ **`src/agent/`** (Agent module): Agent registry (`src/agent/buildin` static builtin baseline + layered overrides) + host injection entry + dynamic generation
|
|
97
98
|
- `Agent` namespace — the Agent module's **only** public API (`state` / `get` / `list` / `defaultAgent` / `isSubagent` / `init` / `resetState` / `registerBuiltin` / `unregisterBuiltin` / `register` / `unregister` / `registerUser` / `unregisterUser` / `base` / `disable` / `enable` / `applyInitialPermission` / `generate`)
|
|
98
99
|
- `AgentRegistry` — **not exported** (internal implementation: layered registration + single merge point)
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 版本
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
9
|
+
v0.3.46
|
|
10
10
|
|
|
11
11
|
## 当前状态(V4 重构后)
|
|
12
12
|
|
|
@@ -49,13 +49,14 @@ v0.3.45
|
|
|
49
49
|
- **两级 state**(`sessionId → streamId`):一个进程服务多个会话、同一会话可并发多条流;`create()` 返回句柄可读快照并单独 `dispose()`,`Instance.dispose()` 统一回收
|
|
50
50
|
- **强制单步**:抹掉调用方传入的 `stopWhen`,多步循环由应用层在步间显式驱动(权限询问 / 压缩 / 落库)
|
|
51
51
|
- 不负责存储 / 重试 / 会话状态机 / 权限询问 / 压缩执行 —— 全部通过事件与裁决移交应用层
|
|
52
|
-
- ✅ **`src/loop
|
|
52
|
+
- ✅ **`src/loop/`**:模型调用循环(**三种实现,按场景选**)
|
|
53
53
|
- **`Loop`(简化)** —— 单次调用 + AI SDK 内建 `stopWhen` 多步;**无事件体系、无 Part 体系**。适合后台任务(记忆提炼 / 摘要 / 分类)
|
|
54
54
|
- **`AgentLoop`(完整)** —— 居于 `StreamProcessor` 之上的**显式多轮驱动器**:每轮一个 `StreamProcessor`,透传完整 `processor.*` 事件 + Hook 事件;内建跨轮轨迹累积与三态裁决处理(`stop` / `continue` / `compact` → 压缩后**重入同一逻辑轮**,带重试护栏)
|
|
55
|
+
- **`SdkLoop`(SDK 形态)** —— 在 `AgentLoop` 之上经 `ProcessorSdkBridge` 把每轮事件翻译成 SDK `SessionEvent`(ACP `session/update` 形态),并用 `SdkMessageCollector` 聚合出 `AgentMessage`;对上只暴露 `onSessionEvent` / `onMessage` / `onEvent`(token 级 delta)三通道,调用方无需自行装配 SDK 桥与 collector
|
|
55
56
|
- 步间插桩点:`onEvent`(事件透传)/ `onRoundFinish`(每轮结束)/ `buildRound`(每轮构造入参)/ `onCompact`(执行压缩)/ `shouldContinue`(是否续跑)
|
|
56
57
|
- **`Loop.Input` 要点**:`maxSteps` 统一承载多步上限(等价于 SDK 的 `stopWhen: stepCountIs(n)`);`tools` 定工具定义、`activeTools` 定激活白名单;`system` / `messages` / `temperature` 等与 `LanguageProvider.CallInput` 同名同义
|
|
57
|
-
-
|
|
58
|
-
-
|
|
58
|
+
- **选用判据**:只是「跑一次 LLM 拿文本」→ `Loop`;需要落库 / Part 体系 / hook 拦截 → `AgentLoop`;需要 ACP-ready `session/update` 或聚合后的完整消息、但不想自己装配 SDK 桥(buddy / TUI / CLI)→ `SdkLoop`
|
|
59
|
+
- 落地:**memory 插件的长期记忆提炼**用 `Loop`(`loop.end` hook);**buddy 的 react 交互层**用 `SdkLoop`
|
|
59
60
|
- ✅ **`src/compaction/`**:上下文超限判定(`Compaction`)
|
|
60
61
|
- **纯函数**,只判断「一次模型请求的输入」是否超出可用窗口,不做实际压缩(压缩是会话层业务动作)
|
|
61
62
|
- 判定口径 = 本次请求真正发给模型的全部内容:`system` + `messages` + `tools`(与 `StreamProcessor.process(streamInput)` 一一对应)
|
|
@@ -92,7 +93,7 @@ v0.3.45
|
|
|
92
93
|
- scope 解析从 `getSdk()` 查 `session.contextMode`,取不到兜底 `ScopeEnum.General`
|
|
93
94
|
- builtin 归属原则:**事件触发方在哪个包,builtin 就在哪个包**(记忆提炼 / 上下文压缩 / 网关消息仍留在 agent / gateway)
|
|
94
95
|
- **初始化**:`bootstrapLlm()` 会自动预热 `LlmHookRegistry`(放在模型加载之前,保证实例化链路里的 `triggerEvent` 能观测到 builtin hook);预热失败降级为 warn,由首次 `triggerEvent` 的 `ensureBridge()` 兜底
|
|
95
|
-
- ✅ **`src/index.ts`** —— 聚合导出入口(4 provider 命名空间 + 3 model 命名空间 + 自研 Copilot SDK + 3 常量 + Config / interfaces 接入点 + AdapterRegistry + 4 Provider 接口 + `Loop` / `AgentLoop`)
|
|
96
|
+
- ✅ **`src/index.ts`** —— 聚合导出入口(4 provider 命名空间 + 3 model 命名空间 + 自研 Copilot SDK + 3 常量 + Config / interfaces 接入点 + AdapterRegistry + 4 Provider 接口 + `Loop` / `AgentLoop` / `SdkLoop`)
|
|
96
97
|
- ✅ **`src/agent/`**(Agent 模块):Agent 注册表(`src/agent/buildin` 静态内置基线 + 分层覆盖)+ 宿主注入入口 + 动态生成
|
|
97
98
|
- `Agent` 命名空间 —— Agent 模块**唯一**对外 API(`state` / `get` / `list` / `defaultAgent` / `isSubagent` / `init` / `resetState` / `registerBuiltin` / `unregisterBuiltin` / `register` / `unregister` / `registerUser` / `unregisterUser` / `base` / `disable` / `enable` / `applyInitialPermission` / `generate`)
|
|
98
99
|
- `AgentRegistry` —— **不对外导出**(内部实现:分层登记 + 单一合并点)
|