@zhin.js/core 1.5.2 → 1.5.4
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 +2 -2
- package/lib/adapter.d.ts +7 -1
- package/lib/adapter.js +28 -24
- package/lib/agent-prompt.d.ts +2 -3
- package/lib/agent-prompt.js +5 -0
- package/lib/built/ai-outbound/parse.d.ts +1 -1
- package/lib/built/ai-outbound/parse.js +2 -6
- package/lib/built/ai-outbound/plain-mention-rewrite.js +4 -4
- package/lib/built/ai-outbound/resolve.js +8 -8
- package/lib/built/ai-outbound/types.d.ts +3 -3
- package/lib/built/ai-trigger.d.ts +5 -0
- package/lib/built/ai-trigger.js +40 -13
- package/lib/built/authorization.js +4 -4
- package/lib/built/command.d.ts +2 -2
- package/lib/built/command.js +2 -2
- package/lib/built/common-adapter-tools.d.ts +11 -11
- package/lib/built/common-adapter-tools.js +13 -13
- package/lib/built/config.d.ts +0 -4
- package/lib/built/config.js +0 -4
- package/lib/built/dispatcher.d.ts +2 -0
- package/lib/built/dispatcher.js +1 -1
- package/lib/built/endpoint-commands.js +2 -2
- package/lib/built/endpoint-lifecycle-service.js +13 -13
- package/lib/built/endpoint-lifecycle.d.ts +3 -3
- package/lib/built/endpoint-lifecycle.js +2 -2
- package/lib/built/endpoint-manager.d.ts +1 -1
- package/lib/built/interactive-segments/index.d.ts +1 -1
- package/lib/built/interactive-segments/index.js +1 -1
- package/lib/built/interactive-segments/keyboard-segment.d.ts +0 -1
- package/lib/built/interactive-segments/keyboard-segment.js +0 -1
- package/lib/built/interactive-segments/onebot-keyboard.d.ts +0 -3
- package/lib/built/interactive-segments/onebot-keyboard.js +0 -2
- package/lib/built/interactive-segments/resolve.d.ts +0 -3
- package/lib/built/interactive-segments/resolve.js +0 -3
- package/lib/built/interactive-segments/types.d.ts +8 -20
- package/lib/built/interactive-segments/types.js +0 -4
- package/lib/built/login-assist.d.ts +2 -2
- package/lib/built/login-assist.js +2 -2
- package/lib/built/message-enrich.d.ts +1 -1
- package/lib/built/message-enrich.js +2 -7
- package/lib/built/permission.d.ts +0 -4
- package/lib/built/permission.js +0 -4
- package/lib/built/prepend-quote-context.js +5 -5
- package/lib/built/rich-segments/capabilities.js +0 -1
- package/lib/built/rich-segments/html-segment.js +1 -4
- package/lib/built/rich-segments/markdown-segment.js +1 -4
- package/lib/built/rich-segments/types.d.ts +0 -5
- package/lib/built/schema-endpoint-manager.js +6 -6
- package/lib/built/tool.d.ts +5 -3
- package/lib/built/tool.js +14 -23
- package/lib/command.d.ts +4 -4
- package/lib/command.js +8 -11
- package/lib/endpoint-capabilities.d.ts +2 -3
- package/lib/endpoint-capabilities.js +4 -4
- package/lib/endpoint.d.ts +2 -0
- package/lib/endpoint.js +1 -0
- package/lib/errors.d.ts +2 -2
- package/lib/errors.js +4 -4
- package/lib/host-plugin-registry.d.ts +6 -5
- package/lib/host-plugin-registry.js +9 -4
- package/lib/im-scene.d.ts +1 -1
- package/lib/im-scene.js +5 -5
- package/lib/im-session-id.d.ts +2 -2
- package/lib/im-session-id.js +4 -4
- package/lib/index.d.ts +1 -2
- package/lib/index.js +0 -2
- package/lib/jsx-runtime.d.ts +1 -0
- package/lib/jsx.d.ts +19 -21
- package/lib/message.d.ts +1 -1
- package/lib/message.js +1 -1
- package/lib/notice.d.ts +2 -2
- package/lib/plugin-context.d.ts +11 -13
- package/lib/plugin-context.js +21 -18
- package/lib/plugin-runtime/im/contracts.d.ts +91 -12
- package/lib/plugin-runtime/im/contracts.js +79 -1
- package/lib/plugin-runtime/im/im-runtime.d.ts +33 -23
- package/lib/plugin-runtime/im/im-runtime.js +104 -63
- package/lib/plugin-runtime/im/index.d.ts +2 -0
- package/lib/plugin-runtime/im/index.js +2 -0
- package/lib/plugin-runtime/im/message-bus.d.ts +38 -0
- package/lib/plugin-runtime/im/message-bus.js +40 -0
- package/lib/plugin-runtime/im/message-dispatcher.js +13 -73
- package/lib/plugin-runtime/im/outbound-renderer.d.ts +3 -2
- package/lib/plugin-runtime/im/outbound-renderer.js +44 -8
- package/lib/plugin-runtime/im/service-tokens.d.ts +18 -0
- package/lib/plugin-runtime/im/service-tokens.js +13 -0
- package/lib/plugin.d.ts +4 -7
- package/lib/plugin.js +7 -30
- package/lib/request.d.ts +2 -2
- package/lib/side-event/types.d.ts +0 -4
- package/lib/types.d.ts +6 -11
- package/lib/utils.js +3 -1
- package/package.json +13 -12
- package/lib/built/qrcode-segment.d.ts +0 -18
- package/lib/built/qrcode-segment.js +0 -78
- package/lib/types-generator.d.ts +0 -5
- package/lib/types-generator.js +0 -71
package/lib/types-generator.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { getLogger } from '@zhin.js/logger';
|
|
4
|
-
const logger = getLogger('TypesGenerator');
|
|
5
|
-
/**
|
|
6
|
-
* 更新 tsconfig.json 的类型声明
|
|
7
|
-
* @param cwd 项目根目录
|
|
8
|
-
*/
|
|
9
|
-
export async function generateEnvTypes(cwd) {
|
|
10
|
-
try {
|
|
11
|
-
// 基础类型集合
|
|
12
|
-
const types = new Set(['@types/node']);
|
|
13
|
-
// 检查 package.json 中的依赖
|
|
14
|
-
const pkgPath = path.join(cwd, 'package.json');
|
|
15
|
-
if (fs.existsSync(pkgPath)) {
|
|
16
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
17
|
-
const allDeps = {
|
|
18
|
-
...(pkg.dependencies || {}),
|
|
19
|
-
...(pkg.devDependencies || {})
|
|
20
|
-
};
|
|
21
|
-
// 检查所有 @zhin.js/ 开头的包
|
|
22
|
-
for (const [name] of Object.entries(allDeps)) {
|
|
23
|
-
if (name.startsWith('@zhin.js/') || name === 'zhin.js') {
|
|
24
|
-
try {
|
|
25
|
-
const depPkgPath = path.join(cwd, 'node_modules', name, 'package.json');
|
|
26
|
-
if (fs.existsSync(depPkgPath)) {
|
|
27
|
-
const depPkg = JSON.parse(fs.readFileSync(depPkgPath, 'utf-8'));
|
|
28
|
-
if (depPkg.types || depPkg.typings) {
|
|
29
|
-
types.add(name);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
// 如果读取失败,跳过这个包
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// 更新或创建 tsconfig.json
|
|
41
|
-
const tsconfigPath = path.join(cwd, 'tsconfig.json');
|
|
42
|
-
let tsconfig = {};
|
|
43
|
-
// 读取现有的 tsconfig.json
|
|
44
|
-
if (fs.existsSync(tsconfigPath)) {
|
|
45
|
-
try {
|
|
46
|
-
tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
// console.error 已替换为注释
|
|
50
|
-
logger.warn('⚠️ Failed to parse tsconfig.json, creating new one');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// 确保 compilerOptions 存在
|
|
54
|
-
if (!tsconfig.compilerOptions) {
|
|
55
|
-
tsconfig.compilerOptions = {};
|
|
56
|
-
}
|
|
57
|
-
// 合并现有的 types
|
|
58
|
-
const existingTypes = tsconfig.compilerOptions.types || [];
|
|
59
|
-
const allTypes = new Set([...existingTypes, ...types]);
|
|
60
|
-
// 更新 types 字段
|
|
61
|
-
tsconfig.compilerOptions.types = Array.from(allTypes);
|
|
62
|
-
// 写入文件
|
|
63
|
-
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), 'utf-8');
|
|
64
|
-
logger.info('✅ Updated TypeScript types configuration');
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
logger.warn('⚠️ Failed to update TypeScript types', {
|
|
68
|
-
error: error instanceof Error ? error.message : String(error)
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|