@zhin.js/plugin-music 6.0.1 → 6.0.3

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.
@@ -0,0 +1,24 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineComponent } from '@zhin.js/component';
3
+ import { musicServices } from "../lib/sources/index.js";
4
+ import { sourceConfigMap } from "../lib/config.js";
5
+ /**
6
+ * Async music share card. Adapters that understand `share` segments render the
7
+ * rich card; others may fall back to text.
8
+ */
9
+ export default defineComponent({
10
+ async render({ platform, musicId }) {
11
+ const service = musicServices[platform];
12
+ if (!service)
13
+ return 'unsupported music source';
14
+ const detail = await service.getDetail(musicId);
15
+ const { id: _id, source: _source, ...rest } = detail;
16
+ return {
17
+ type: 'share',
18
+ data: {
19
+ ...rest,
20
+ config: sourceConfigMap[platform],
21
+ },
22
+ };
23
+ },
24
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/plugin-music",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Music search and sharing plugin for Zhin.js (Plugin Runtime)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -14,7 +14,7 @@
14
14
  "./package.json": "./package.json"
15
15
  },
16
16
  "files": [
17
- "plugin.ts",
17
+ "plugin.js",
18
18
  "schema.json",
19
19
  "components",
20
20
  "tools",
@@ -41,16 +41,16 @@
41
41
  },
42
42
  "license": "MIT",
43
43
  "dependencies": {
44
- "@zhin.js/component": "1.0.3",
44
+ "@zhin.js/component": "1.0.4",
45
45
  "@zhin.js/plugin-runtime": "1.1.1",
46
- "@zhin.js/tool": "1.0.3"
46
+ "@zhin.js/tool": "1.0.4"
47
47
  },
48
48
  "devDependencies": {
49
49
  "typescript": "^6.0.3",
50
50
  "vitest": "^4.1.10"
51
51
  },
52
52
  "peerDependencies": {
53
- "@zhin.js/adapter-icqq": "7.0.1"
53
+ "@zhin.js/adapter-icqq": "7.0.3"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@zhin.js/adapter-icqq": {
@@ -72,7 +72,7 @@
72
72
  "zhin": {
73
73
  "protocol": 1,
74
74
  "type": "plugin",
75
- "entry": "./plugin.ts",
75
+ "entry": "./plugin.js",
76
76
  "engine": "^1.0.0",
77
77
  "runtime": "trusted",
78
78
  "features": [
package/plugin.js ADDED
@@ -0,0 +1,8 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { definePlugin } from '@zhin.js/plugin-runtime';
3
+ export default definePlugin({
4
+ name: 'music',
5
+ metadata: {
6
+ displayName: 'Music',
7
+ },
8
+ });
@@ -0,0 +1,17 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { searchMusic } from "../lib/music-lib.js";
4
+ export default defineAgentTool({
5
+ description: '搜索音乐并返回结果列表',
6
+ inputSchema: {
7
+ type: 'object',
8
+ properties: {
9
+ keyword: { type: 'string', description: '搜索关键词' },
10
+ source: { type: 'string', enum: ['qq', 'netease'] },
11
+ limit: { type: 'number', description: '返回结果数量(默认 5)' },
12
+ },
13
+ required: ['keyword'],
14
+ },
15
+ approval: 'never',
16
+ execute: ({ keyword, source, limit }) => searchMusic(String(keyword), source, typeof limit === 'number' ? limit : 5),
17
+ });
@@ -0,0 +1,16 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { shareMusicDetail } from "../lib/music-lib.js";
4
+ export default defineAgentTool({
5
+ description: '分享指定的音乐',
6
+ inputSchema: {
7
+ type: 'object',
8
+ properties: {
9
+ id: { type: 'string', description: '音乐 ID' },
10
+ source: { type: 'string', enum: ['qq', 'netease'] },
11
+ },
12
+ required: ['id', 'source'],
13
+ },
14
+ approval: 'never',
15
+ execute: ({ id, source }) => shareMusicDetail(String(id), source),
16
+ });
package/plugin.ts DELETED
@@ -1,8 +0,0 @@
1
- import { definePlugin } from '@zhin.js/plugin-runtime';
2
-
3
- export default definePlugin({
4
- name: 'music',
5
- metadata: {
6
- displayName: 'Music',
7
- },
8
- });