@zhin.js/core 1.1.29 → 1.1.30
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 +28 -43
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @zhin.js/core
|
|
2
2
|
|
|
3
|
-
Zhin.js 核心框架包,提供插件系统、Feature
|
|
3
|
+
Zhin.js IM 核心框架包,提供插件系统、Feature 架构、适配器、消息路由与出站发送链。**AI 编排(ZhinAgent、工具安全、MCP)在 [`@zhin.js/agent`](../agent/README.md)**;本包仅 selective re-export `@zhin.js/ai` 的 Provider / Agent 原语供插件直接使用。
|
|
4
|
+
|
|
5
|
+
领域词汇见 [CONTEXT.md](./CONTEXT.md);入站/出站流程见 [消息如何流转](../../docs/essentials/message-flow.md)。
|
|
4
6
|
|
|
5
7
|
## 核心概念
|
|
6
8
|
|
|
@@ -118,67 +120,50 @@ class IcqqAdapter extends Adapter<IcqqBot> {
|
|
|
118
120
|
|
|
119
121
|
- **Guardrail** — 鉴权、速率限制、黑名单等前置检查
|
|
120
122
|
- **Route** — 判断消息是命令还是 AI 对话
|
|
121
|
-
- **Handle** — CommandFeature
|
|
123
|
+
- **Handle** — CommandFeature 处理命令;AI 对话由 `@zhin.js/agent` 的 ZhinAgent / AIService 处理(经 Dispatcher 注册)
|
|
122
124
|
|
|
123
|
-
### AI
|
|
125
|
+
### AI 与 @zhin.js/agent
|
|
124
126
|
|
|
125
|
-
|
|
127
|
+
Core **不包含** ZhinAgent 实现。IM 侧的 AI 对话、工具收集、执行策略、MCP 客户端与 `ctx.ai` / `ctx.agent` 挂载均在 **`@zhin.js/agent`**(主包 `zhin.js` 会 `initAgentModule()` 并 re-export)。
|
|
126
128
|
|
|
127
|
-
|
|
128
|
-
用户消息 → 速率限制 → 工具过滤 → 会话记忆 → LLM 调用 → 输出
|
|
129
|
-
│
|
|
130
|
-
三条路径选择:
|
|
131
|
-
闲聊(0工具)→ 1次 LLM
|
|
132
|
-
快速(无参数工具)→ 预执行 + 1次 LLM
|
|
133
|
-
Agent(有参数工具)→ 多轮 tool-calling
|
|
134
|
-
```
|
|
129
|
+
本包从 `@zhin.js/ai` selective re-export 以下内容,供插件或适配器在不依赖 agent 层时使用:
|
|
135
130
|
|
|
136
|
-
|
|
131
|
+
| 类别 | 示例导出 |
|
|
132
|
+
|------|----------|
|
|
133
|
+
| Provider | `OpenAIProvider`、`OllamaProvider`、`AnthropicProvider` 等 |
|
|
134
|
+
| Agent 原语 | `Agent`、`createAgent`、`ModelRegistry` |
|
|
135
|
+
| 会话 / 上下文 | `SessionManager`、`ContextManager`、`ConversationMemory` |
|
|
136
|
+
| 压缩 / 限流 / 输出 | `compactSession`、`RateLimiter`、`parseOutput`、`CostTracker` |
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|------|------|
|
|
140
|
-
| `SessionManager` | 会话管理(内存/数据库) |
|
|
141
|
-
| `ContextManager` | 上下文构建与滑动窗口 |
|
|
142
|
-
| `ConversationMemory` | 话题感知、链式摘要 |
|
|
143
|
-
| `UserProfileStore` | 用户画像 |
|
|
144
|
-
| `RateLimiter` | 频率限制 |
|
|
145
|
-
| `FollowUpManager` | 定时提醒(持久化) |
|
|
146
|
-
| `ToneDetector` | 情绪分析 |
|
|
147
|
-
| `OutputParser` | 多模态输出解析 |
|
|
138
|
+
完整 Agent 能力与配置见 [`@zhin.js/agent`](../agent/README.md) 与 [AI 模块](https://zhin.js.org/advanced/ai)。
|
|
148
139
|
|
|
149
140
|
## 主要导出
|
|
150
141
|
|
|
142
|
+
入口为 [`src/index.ts`](./src/index.ts)。摘要如下(非完整列表):
|
|
143
|
+
|
|
151
144
|
```typescript
|
|
152
145
|
// 插件系统
|
|
153
146
|
export { Plugin, usePlugin, getPlugin, definePlugin } from './plugin.js'
|
|
154
147
|
|
|
155
|
-
// Feature
|
|
156
|
-
export { Feature } from '
|
|
157
|
-
export { CommandFeature } from './built
|
|
158
|
-
export { ToolFeature, ZhinTool } from './built/tool.js'
|
|
159
|
-
export { SkillFeature } from './built/skill.js'
|
|
160
|
-
export { CronFeature } from './built/cron.js'
|
|
161
|
-
export { DatabaseFeature } from './built/database.js'
|
|
162
|
-
export { ComponentFeature } from './built/component.js'
|
|
163
|
-
export { ConfigFeature } from './built/config.js'
|
|
164
|
-
export { PermissionFeature } from './built/permission.js'
|
|
148
|
+
// Feature 体系(Cron / Scheduler 来自 @zhin.js/kernel)
|
|
149
|
+
export { Feature, Cron, Scheduler } from '@zhin.js/kernel'
|
|
150
|
+
export { CommandFeature, ToolFeature, SkillFeature, CronFeature, DatabaseFeature, ... } from './built/*.js'
|
|
165
151
|
|
|
166
152
|
// 消息路由
|
|
167
153
|
export { createMessageDispatcher } from './built/dispatcher.js'
|
|
168
154
|
|
|
169
|
-
//
|
|
170
|
-
export {
|
|
171
|
-
|
|
172
|
-
// 适配器
|
|
173
|
-
export { Adapter } from './adapter.js'
|
|
155
|
+
// 适配器与消息
|
|
156
|
+
export { Adapter, Message, MessageCommand, Bot, ... } from './'
|
|
174
157
|
|
|
175
|
-
//
|
|
176
|
-
export {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
158
|
+
// AI 原语(来自 @zhin.js/ai,非 ZhinAgent)
|
|
159
|
+
export {
|
|
160
|
+
OpenAIProvider, OllamaProvider, Agent, createAgent, ModelRegistry,
|
|
161
|
+
SessionManager, ContextManager, ConversationMemory, compactSession, ...
|
|
162
|
+
} from '@zhin.js/ai'
|
|
180
163
|
```
|
|
181
164
|
|
|
165
|
+
> ZhinAgent、`initAgentModule`、`AIService`、ExecPolicy、编排 Registry 等请从 **`zhin.js`** 或 **`@zhin.js/agent`** 引入。
|
|
166
|
+
|
|
182
167
|
## 安装
|
|
183
168
|
|
|
184
169
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.30",
|
|
4
4
|
"description": "Zhin机器人核心框架",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"segment-matcher": "^1.0.5",
|
|
46
46
|
"smol-toml": "^1.6.1",
|
|
47
47
|
"yaml": "^2.9.0",
|
|
48
|
-
"@zhin.js/
|
|
49
|
-
"@zhin.js/
|
|
50
|
-
"@zhin.js/kernel": "0.0.46",
|
|
48
|
+
"@zhin.js/kernel": "0.0.47",
|
|
49
|
+
"@zhin.js/ai": "1.1.28",
|
|
51
50
|
"@zhin.js/logger": "0.1.69",
|
|
51
|
+
"@zhin.js/database": "1.0.72",
|
|
52
52
|
"@zhin.js/schema": "1.0.69"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|