@zhin.js/plugin-short-url 1.1.0 → 1.1.1

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.
@@ -1,6 +1,6 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineCommand } from 'zhin.js/command';
3
- import { expandUrl, isValidUrl } from "../../lib/short-url-lib.js";
3
+ import { expandUrl, isValidUrl } from "../../../lib/short-url-lib.js";
4
4
  export default defineCommand({
5
5
  description: '展开一个短链接,显示原始地址',
6
6
  params: { url: { type: 'string' } },
@@ -1,5 +1,5 @@
1
1
  import { defineCommand } from 'zhin.js/command';
2
- import { expandUrl, isValidUrl } from '../../src/short-url-lib.js';
2
+ import { expandUrl, isValidUrl } from '../../../src/short-url-lib.js';
3
3
 
4
4
  export default defineCommand({
5
5
  description: '展开一个短链接,显示原始地址',
@@ -1,6 +1,6 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { defineCommand } from 'zhin.js/command';
3
- import { isValidUrl, shortenUrl } from "../../lib/short-url-lib.js";
3
+ import { isValidUrl, shortenUrl } from "../../../lib/short-url-lib.js";
4
4
  export default defineCommand({
5
5
  description: '缩短一个 URL',
6
6
  params: { url: { type: 'string' } },
@@ -1,5 +1,5 @@
1
1
  import { defineCommand } from 'zhin.js/command';
2
- import { isValidUrl, shortenUrl } from '../../src/short-url-lib.js';
2
+ import { isValidUrl, shortenUrl } from '../../../src/short-url-lib.js';
3
3
 
4
4
  export default defineCommand({
5
5
  description: '缩短一个 URL',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/plugin-short-url",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "URL shortener plugin for Zhin.js — shorten & expand URLs (Plugin Runtime)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -19,7 +19,8 @@
19
19
  "commands",
20
20
  "src",
21
21
  "lib",
22
- "agent",
22
+ "tools",
23
+ "skills",
23
24
  "README.md"
24
25
  ],
25
26
  "keywords": [
@@ -40,19 +41,14 @@
40
41
  "typescript": "^6.0.3",
41
42
  "vitest": "^4.1.10",
42
43
  "zod": "^4.4.3",
43
- "@zhin.js/agent": "1.1.23",
44
- "zhin.js": "1.1.0"
44
+ "zhin.js": "1.1.2"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "zod": "^4.0.0",
48
- "@zhin.js/agent": "^1.1.23",
49
- "@zhin.js/command": "^1.1.0",
50
- "zhin.js": "^1.1.0"
48
+ "@zhin.js/command": "^1.1.1",
49
+ "zhin.js": "^1.1.2"
51
50
  },
52
51
  "peerDependenciesMeta": {
53
- "@zhin.js/agent": {
54
- "optional": true
55
- },
56
52
  "@zhin.js/command": {
57
53
  "optional": true
58
54
  },
@@ -82,10 +78,22 @@
82
78
  {
83
79
  "package": "@zhin.js/command",
84
80
  "api": "^1.0.0"
81
+ },
82
+ {
83
+ "package": "@zhin.js/tool",
84
+ "api": "^1.0.0"
85
+ },
86
+ {
87
+ "package": "@zhin.js/skill",
88
+ "api": "^1.0.0"
85
89
  }
86
90
  ],
87
91
  "plugins": []
88
92
  },
93
+ "dependencies": {
94
+ "@zhin.js/tool": "1.1.1",
95
+ "@zhin.js/skill": "1.1.1"
96
+ },
89
97
  "scripts": {
90
98
  "build": "tsc",
91
99
  "clean": "rimraf lib",
@@ -0,0 +1,19 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { isValidUrl, shortenUrl } from "../../../../lib/short-url-lib.js";
5
+ export default defineAgentTool({
6
+ description: '缩短一个 URL,返回短链接',
7
+ inputSchema: z.object({ url: z.string().min(1) }),
8
+ keywords: ['短链', '缩短', 'shorten', 'short url'],
9
+ async execute({ url }) {
10
+ if (!isValidUrl(url))
11
+ return '无效的 URL,需要 http:// 或 https:// 开头';
12
+ try {
13
+ return await shortenUrl(url);
14
+ }
15
+ catch (e) {
16
+ return `缩短失败: ${e instanceof Error ? e.message : String(e)}`;
17
+ }
18
+ },
19
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { isValidUrl, shortenUrl } from '../../src/short-url-lib.js';
3
+ import { isValidUrl, shortenUrl } from '../../../../src/short-url-lib.js';
4
4
 
5
5
  export default defineAgentTool<{ url: string }>({
6
6
  description: '缩短一个 URL,返回短链接',