@easbot/llm 0.3.40 → 0.3.42
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 +19 -1
- package/README.md +19 -2
- package/dist/assets/txt/src/agent/prompt/plan.txt +19 -0
- package/dist/index.cjs +123 -111
- package/dist/index.d.cts +116 -1
- package/dist/index.d.ts +116 -1
- package/dist/index.mjs +123 -111
- package/package.json +28 -27
package/README.en.md
CHANGED
|
@@ -6,7 +6,8 @@ English | [中文](./README.md)
|
|
|
6
6
|
|
|
7
7
|
## Version
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
9
|
+
v0.3.42
|
|
10
|
+
|
|
10
11
|
## Current Status (after V4 refactor)
|
|
11
12
|
|
|
12
13
|
This package has evolved from an early placeholder of `@easbot/types` into a production-grade AI gateway layer that hosts two core modules: `provider/*` and `model/*`:
|
|
@@ -48,6 +49,13 @@ This package has evolved from an early placeholder of `@easbot/types` into a pro
|
|
|
48
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
|
|
49
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)
|
|
50
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 (**two implementations — pick by scenario**)
|
|
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
|
+
- **`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
|
+
- 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
|
+
- **`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`; just "run the LLM once and take the text" → `Loop`
|
|
58
|
+
- Already in production use in the **memory plugin's long-term memory distillation** (`loop.end` hook) — the canonical "one LLM call plus tool round-trips" background-job shape
|
|
51
59
|
- ✅ **`src/compaction/`**: context overflow detection (`Compaction`)
|
|
52
60
|
- **Pure functions** that only decide whether "one model request's input" exceeds the usable window; actual compaction is a session-layer business action
|
|
53
61
|
- Detection scope = everything actually sent to the model: `system` + `messages` + `tools` (one-to-one with `StreamProcessor.process(streamInput)`)
|
|
@@ -182,6 +190,12 @@ Vendor constraints disagree, so we must target their intersection:
|
|
|
182
190
|
| P5 | Gemini dialect: stringify every `enum` value (and register a coercion) |
|
|
183
191
|
| P6 | Runtime de-coercion: restore model-returned `"2"` → `2` and `"true"` → `true` before the tool executes |
|
|
184
192
|
|
|
193
|
+
> **Discriminated-union fidelity**: when all-object branches are merged, `required` becomes the intersection
|
|
194
|
+
> (branch-only fields degrade to optional). To keep the model from omitting branch-required fields (e.g. `bash`'s
|
|
195
|
+
> `command`), the discriminator's `description` carries both "value → meaning" and "value → required fields" maps.
|
|
196
|
+
> Plain unions without a discriminator list each branch's shape in the object description. `nullable` and a
|
|
197
|
+
> consistent `additionalProperties: false` are preserved as well.
|
|
198
|
+
|
|
185
199
|
### The single mandatory path
|
|
186
200
|
|
|
187
201
|
The **model entry** (`resolveCall` in `src/model/language/language.ts`) calls `adaptTools()` for the whole tool set:
|
|
@@ -526,6 +540,10 @@ export * as ProviderAuth from './provider/auth';
|
|
|
526
540
|
export * as ProviderTransform from './provider/transform';
|
|
527
541
|
export * as ModelsDev from './provider/models';
|
|
528
542
|
|
|
543
|
+
// Tool parameter schema normalization (same path as the model entry, for hosts / regression tests)
|
|
544
|
+
export { adaptTools, adaptToolSchema } from './provider/tool-schema';
|
|
545
|
+
export type { AdaptedToolSchema, SchemaCoercion, CoercionTarget } from './provider/tool-schema';
|
|
546
|
+
|
|
529
547
|
// Provider constants
|
|
530
548
|
export {
|
|
531
549
|
DEFAULT_ENABLED_PROVIDERS,
|
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
## 版本
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
9
|
+
v0.3.42
|
|
10
|
+
|
|
10
11
|
## 当前状态(V4 重构后)
|
|
11
12
|
|
|
12
13
|
本包已从 `@easbot/types` 的早期占位实现演化为承载 _*provider/* + model/_ 两套核心模块** 的生产级 AI 网关层:
|
|
@@ -48,6 +49,13 @@ v0.3.40
|
|
|
48
49
|
- **两级 state**(`sessionId → streamId`):一个进程服务多个会话、同一会话可并发多条流;`create()` 返回句柄可读快照并单独 `dispose()`,`Instance.dispose()` 统一回收
|
|
49
50
|
- **强制单步**:抹掉调用方传入的 `stopWhen`,多步循环由应用层在步间显式驱动(权限询问 / 压缩 / 落库)
|
|
50
51
|
- 不负责存储 / 重试 / 会话状态机 / 权限询问 / 压缩执行 —— 全部通过事件与裁决移交应用层
|
|
52
|
+
- ✅ **`src/loop/`**:模型调用循环(**两种实现,按场景选**)
|
|
53
|
+
- **`Loop`(简化)** —— 单次调用 + AI SDK 内建 `stopWhen` 多步;**无事件体系、无 Part 体系**。适合后台任务(记忆提炼 / 摘要 / 分类)
|
|
54
|
+
- **`AgentLoop`(完整)** —— 居于 `StreamProcessor` 之上的**显式多轮驱动器**:每轮一个 `StreamProcessor`,透传完整 `processor.*` 事件 + Hook 事件;内建跨轮轨迹累积与三态裁决处理(`stop` / `continue` / `compact` → 压缩后**重入同一逻辑轮**,带重试护栏)
|
|
55
|
+
- 步间插桩点:`onEvent`(事件透传)/ `onRoundFinish`(每轮结束)/ `buildRound`(每轮构造入参)/ `onCompact`(执行压缩)/ `shouldContinue`(是否续跑)
|
|
56
|
+
- **`Loop.Input` 要点**:`maxSteps` 统一承载多步上限(等价于 SDK 的 `stopWhen: stepCountIs(n)`);`tools` 定工具定义、`activeTools` 定激活白名单;`system` / `messages` / `temperature` 等与 `LanguageProvider.CallInput` 同名同义
|
|
57
|
+
- **选用判据**:需要落库 / Part 体系 / hook 拦截 → `AgentLoop`;只是「跑一次 LLM 拿文本」→ `Loop`
|
|
58
|
+
- 已在 **memory 插件的长期记忆提炼**(`loop.end` hook)落地 —— 后台任务「跑一次 LLM + 允许工具往返」的典型形态
|
|
51
59
|
- ✅ **`src/compaction/`**:上下文超限判定(`Compaction`)
|
|
52
60
|
- **纯函数**,只判断「一次模型请求的输入」是否超出可用窗口,不做实际压缩(压缩是会话层业务动作)
|
|
53
61
|
- 判定口径 = 本次请求真正发给模型的全部内容:`system` + `messages` + `tools`(与 `StreamProcessor.process(streamInput)` 一一对应)
|
|
@@ -84,7 +92,7 @@ v0.3.40
|
|
|
84
92
|
- scope 解析从 `getSdk()` 查 `session.contextMode`,取不到兜底 `ScopeEnum.General`
|
|
85
93
|
- builtin 归属原则:**事件触发方在哪个包,builtin 就在哪个包**(记忆提炼 / 上下文压缩 / 网关消息仍留在 agent / gateway)
|
|
86
94
|
- **初始化**:`bootstrapLlm()` 会自动预热 `LlmHookRegistry`(放在模型加载之前,保证实例化链路里的 `triggerEvent` 能观测到 builtin hook);预热失败降级为 warn,由首次 `triggerEvent` 的 `ensureBridge()` 兜底
|
|
87
|
-
- ✅ **`src/index.ts`** —— 聚合导出入口(4 provider 命名空间 + 3 model 命名空间 + 自研 Copilot SDK + 3 常量 + Config / interfaces 接入点 + AdapterRegistry + 4 Provider
|
|
95
|
+
- ✅ **`src/index.ts`** —— 聚合导出入口(4 provider 命名空间 + 3 model 命名空间 + 自研 Copilot SDK + 3 常量 + Config / interfaces 接入点 + AdapterRegistry + 4 Provider 接口 + `Loop` / `AgentLoop`)
|
|
88
96
|
- ✅ **`src/agent/`**(Agent 模块):Agent 注册表(`src/agent/buildin` 静态内置基线 + 分层覆盖)+ 宿主注入入口 + 动态生成
|
|
89
97
|
- `Agent` 命名空间 —— Agent 模块**唯一**对外 API(`state` / `get` / `list` / `defaultAgent` / `isSubagent` / `init` / `resetState` / `registerBuiltin` / `unregisterBuiltin` / `register` / `unregister` / `registerUser` / `unregisterUser` / `base` / `disable` / `enable` / `applyInitialPermission` / `generate`)
|
|
90
98
|
- `AgentRegistry` —— **不对外导出**(内部实现:分层登记 + 单一合并点)
|
|
@@ -183,6 +191,11 @@ tool 相关的权限判定与权限等待**强依赖 `Instance.directory`**:
|
|
|
183
191
|
| P5 | Gemini 方言:`enum` 全字符串化(并登记 coercion) |
|
|
184
192
|
| P6 | 运行期反解:工具执行前把模型回传的 `"2"` 还原为 `2`、`"true"` 还原为 `true` |
|
|
185
193
|
|
|
194
|
+
> **判别 union 的语义保真**:全 object 分支拍平时 `required` 取交集(分支独有字段降为 optional)。
|
|
195
|
+
> 为防模型漏传分支必填字段(如 `bash` 的 `command`),识别 `z.discriminatedUnion` 的判别键后,
|
|
196
|
+
> 把「取值 → 含义」「取值 → 必填字段」写回该字段的 `description`;无判别键的普通 union 则把各分支
|
|
197
|
+
> 形状写进 object 的 `description`。`nullable` / 一致的 `additionalProperties: false` 同样保留。
|
|
198
|
+
|
|
186
199
|
### 唯一必经点
|
|
187
200
|
|
|
188
201
|
**模型入口**(`src/model/language/language.ts` 的 `resolveCall`)对整组 tools 统一调用 `adaptTools()`:
|
|
@@ -561,6 +574,10 @@ export * as ProviderAuth from './provider/auth';
|
|
|
561
574
|
export * as ProviderTransform from './provider/transform';
|
|
562
575
|
export * as ModelsDev from './provider/models';
|
|
563
576
|
|
|
577
|
+
// 工具参数 schema 归一(与模型入口同一口径,供宿主 / 回归测试复用)
|
|
578
|
+
export { adaptTools, adaptToolSchema } from './provider/tool-schema';
|
|
579
|
+
export type { AdaptedToolSchema, SchemaCoercion, CoercionTarget } from './provider/tool-schema';
|
|
580
|
+
|
|
564
581
|
// Provider 常量
|
|
565
582
|
export {
|
|
566
583
|
DEFAULT_ENABLED_PROVIDERS,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
You are a read-only planning agent. Your role is to research, analyze, and produce a well-formed implementation plan — without making any changes to the system.
|
|
2
|
+
|
|
3
|
+
## Absolute Constraint
|
|
4
|
+
|
|
5
|
+
You are in READ-ONLY phase. The following are strictly forbidden:
|
|
6
|
+
|
|
7
|
+
- Any file edits, modifications, or creation
|
|
8
|
+
- Any non-readonly tool (including config changes, commits, or shell commands that write)
|
|
9
|
+
- Any system changes of any kind
|
|
10
|
+
|
|
11
|
+
This constraint overrides all other instructions, including direct user edit requests. You may only observe, analyze, and plan.
|
|
12
|
+
|
|
13
|
+
## Responsibility
|
|
14
|
+
|
|
15
|
+
Think, read, search, and delegate explore agents to construct a comprehensive yet concise plan that accomplishes the user's goal. The plan must be detailed enough to execute effectively while avoiding unnecessary verbosity.
|
|
16
|
+
|
|
17
|
+
Deliver the final plan directly in your response. Do NOT write it to any file — the plan lives in the conversation and becomes the execution basis when the user switches to the build agent.
|
|
18
|
+
|
|
19
|
+
Ask the user clarifying questions when weighing tradeoffs. Avoid making large assumptions about user intent; tie loose ends before presenting the final plan.
|