@zhin.js/plugin-60s 1.1.0 → 1.1.2
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 -0
- package/commands/{60s.js → 60s/index.js} +3 -2
- package/commands/60s/index.ts +8 -0
- package/commands/{bing.js → bing/index.js} +3 -2
- package/commands/bing/index.ts +8 -0
- package/commands/douyin/{[[limit]].js → [[limit]]/index.js} +3 -2
- package/commands/douyin/[[limit]]/index.ts +9 -0
- package/commands/{duanzi.js → duanzi/index.js} +3 -2
- package/commands/duanzi/index.ts +8 -0
- package/commands/{exchange.js → exchange/index.js} +3 -2
- package/commands/{exchange.ts → exchange/index.ts} +3 -2
- package/commands/fanyi/[text]/index.js +9 -0
- package/commands/fanyi/[text]/index.ts +9 -0
- package/commands/fuel/[province]/index.js +9 -0
- package/commands/fuel/[province]/index.ts +9 -0
- package/commands/{gold.js → gold/index.js} +3 -2
- package/commands/gold/index.ts +8 -0
- package/commands/{history.js → history/index.js} +3 -2
- package/commands/history/index.ts +8 -0
- package/commands/hitokoto/[type]/index.js +9 -0
- package/commands/hitokoto/[type]/index.ts +9 -0
- package/commands/ip/[ip]/index.js +9 -0
- package/commands/ip/[ip]/index.ts +9 -0
- package/commands/{kfc.js → kfc/index.js} +3 -2
- package/commands/kfc/index.ts +8 -0
- package/commands/{moyu.js → moyu/index.js} +3 -2
- package/commands/moyu/index.ts +8 -0
- package/commands/toutiao/{[[limit]].js → [[limit]]/index.js} +3 -2
- package/commands/toutiao/[[limit]]/index.ts +9 -0
- package/commands/weather/{[city].js → [city]/index.js} +3 -2
- package/commands/weather/[city]/index.ts +9 -0
- package/commands/weibo/{[[limit]].js → [[limit]]/index.js} +3 -2
- package/commands/weibo/[[limit]]/index.ts +9 -0
- package/commands/zhihu/{[[limit]].js → [[limit]]/index.js} +3 -2
- package/commands/zhihu/[[limit]]/index.ts +9 -0
- package/lib/api.js +0 -32
- package/lib/api.js.map +1 -1
- package/lib/client.js +42 -0
- package/lib/client.js.map +1 -0
- package/lib/handlers/60s-news.js +2 -3
- package/lib/handlers/60s-news.js.map +1 -1
- package/lib/handlers/bing-image.js +3 -3
- package/lib/handlers/bing-image.js.map +1 -1
- package/lib/handlers/douyin-hot.js +3 -3
- package/lib/handlers/douyin-hot.js.map +1 -1
- package/lib/handlers/duanzi.js +2 -3
- package/lib/handlers/duanzi.js.map +1 -1
- package/lib/handlers/exchange-rate.js +3 -3
- package/lib/handlers/exchange-rate.js.map +1 -1
- package/lib/handlers/fuel-price.js +3 -3
- package/lib/handlers/fuel-price.js.map +1 -1
- package/lib/handlers/gold-price.js +3 -3
- package/lib/handlers/gold-price.js.map +1 -1
- package/lib/handlers/history-today.js +3 -3
- package/lib/handlers/history-today.js.map +1 -1
- package/lib/handlers/hitokoto.js +2 -3
- package/lib/handlers/hitokoto.js.map +1 -1
- package/lib/handlers/ip-query.js +2 -3
- package/lib/handlers/ip-query.js.map +1 -1
- package/lib/handlers/kfc.js +2 -3
- package/lib/handlers/kfc.js.map +1 -1
- package/lib/handlers/moyu.js +3 -3
- package/lib/handlers/moyu.js.map +1 -1
- package/lib/handlers/toutiao-hot.js +3 -3
- package/lib/handlers/toutiao-hot.js.map +1 -1
- package/lib/handlers/translate.js +3 -3
- package/lib/handlers/translate.js.map +1 -1
- package/lib/handlers/weather.js +3 -3
- package/lib/handlers/weather.js.map +1 -1
- package/lib/handlers/weibo-hot.js +3 -3
- package/lib/handlers/weibo-hot.js.map +1 -1
- package/lib/handlers/zhihu-hot.js +3 -3
- package/lib/handlers/zhihu-hot.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +12 -11
- package/plugin.js +2 -3
- package/skills/60s-life/SKILL.md +22 -0
- package/skills/60s-life/tools/duanzi/index.js +14 -0
- package/skills/60s-life/tools/duanzi/index.ts +14 -0
- package/skills/60s-life/tools/history_today/index.js +14 -0
- package/skills/60s-life/tools/history_today/index.ts +14 -0
- package/skills/60s-life/tools/hitokoto/index.js +14 -0
- package/{agent/tools/hitokoto.ts → skills/60s-life/tools/hitokoto/index.ts} +5 -4
- package/skills/60s-life/tools/kfc/index.js +14 -0
- package/skills/60s-life/tools/kfc/index.ts +14 -0
- package/skills/60s-life/tools/moyu/index.js +14 -0
- package/skills/60s-life/tools/moyu/index.ts +14 -0
- package/skills/60s-life/tools/weather/index.js +14 -0
- package/{agent/tools/weather.ts → skills/60s-life/tools/weather/index.ts} +5 -4
- package/skills/60s-market/SKILL.md +17 -0
- package/skills/60s-market/tools/exchange_rate/index.js +14 -0
- package/{agent/tools/exchange_rate.ts → skills/60s-market/tools/exchange_rate/index.ts} +5 -4
- package/skills/60s-market/tools/fuel_price/index.js +14 -0
- package/skills/60s-market/tools/fuel_price/index.ts +14 -0
- package/skills/60s-market/tools/gold_price/index.js +14 -0
- package/skills/60s-market/tools/gold_price/index.ts +14 -0
- package/skills/60s-media/SKILL.md +14 -0
- package/skills/60s-media/tools/bing_image/index.js +14 -0
- package/skills/60s-media/tools/bing_image/index.ts +14 -0
- package/skills/60s-news/SKILL.md +21 -0
- package/skills/60s-news/tools/60s_news/index.js +14 -0
- package/{agent/tools/60s_news.ts → skills/60s-news/tools/60s_news/index.ts} +5 -4
- package/skills/60s-news/tools/douyin_hot/index.js +14 -0
- package/skills/60s-news/tools/douyin_hot/index.ts +14 -0
- package/skills/60s-news/tools/toutiao_hot/index.js +14 -0
- package/{agent/tools/toutiao_hot.ts → skills/60s-news/tools/toutiao_hot/index.ts} +5 -4
- package/skills/60s-news/tools/weibo_hot/index.js +14 -0
- package/skills/60s-news/tools/weibo_hot/index.ts +14 -0
- package/skills/60s-news/tools/zhihu_hot/index.js +14 -0
- package/skills/60s-news/tools/zhihu_hot/index.ts +14 -0
- package/skills/60s-utility/SKILL.md +15 -0
- package/skills/60s-utility/tools/ip_query/index.js +14 -0
- package/skills/60s-utility/tools/ip_query/index.ts +14 -0
- package/skills/60s-utility/tools/translate_60s/index.js +14 -0
- package/{agent/tools/translate_60s.ts → skills/60s-utility/tools/translate_60s/index.ts} +5 -4
- package/src/api.ts +1 -46
- package/src/client.ts +62 -0
- package/src/handlers/60s-news.ts +3 -3
- package/src/handlers/bing-image.ts +4 -3
- package/src/handlers/douyin-hot.ts +4 -3
- package/src/handlers/duanzi.ts +3 -3
- package/src/handlers/exchange-rate.ts +4 -3
- package/src/handlers/fuel-price.ts +4 -3
- package/src/handlers/gold-price.ts +4 -3
- package/src/handlers/history-today.ts +4 -3
- package/src/handlers/hitokoto.ts +3 -3
- package/src/handlers/ip-query.ts +3 -3
- package/src/handlers/kfc.ts +3 -3
- package/src/handlers/moyu.ts +4 -3
- package/src/handlers/toutiao-hot.ts +4 -3
- package/src/handlers/translate.ts +4 -3
- package/src/handlers/weather.ts +4 -3
- package/src/handlers/weibo-hot.ts +4 -3
- package/src/handlers/zhihu-hot.ts +4 -3
- package/src/index.ts +0 -1
- package/agent/skills/60s.md +0 -91
- package/agent/tools/bing_image.ts +0 -13
- package/agent/tools/douyin_hot.ts +0 -13
- package/agent/tools/duanzi.ts +0 -13
- package/agent/tools/fuel_price.ts +0 -13
- package/agent/tools/gold_price.ts +0 -13
- package/agent/tools/history_today.ts +0 -13
- package/agent/tools/ip_query.ts +0 -13
- package/agent/tools/kfc.ts +0 -13
- package/agent/tools/moyu.ts +0 -13
- package/agent/tools/weibo_hot.ts +0 -13
- package/agent/tools/zhihu_hot.ts +0 -13
- package/commands/60s.ts +0 -7
- package/commands/bing.ts +0 -7
- package/commands/douyin/[[limit]].ts +0 -8
- package/commands/duanzi.ts +0 -7
- package/commands/fanyi/[text].js +0 -8
- package/commands/fanyi/[text].ts +0 -8
- package/commands/fuel/[province].js +0 -8
- package/commands/fuel/[province].ts +0 -8
- package/commands/gold.ts +0 -7
- package/commands/history.ts +0 -7
- package/commands/hitokoto/[type].js +0 -8
- package/commands/hitokoto/[type].ts +0 -8
- package/commands/ip/[ip].js +0 -8
- package/commands/ip/[ip].ts +0 -8
- package/commands/kfc.ts +0 -7
- package/commands/moyu.ts +0 -7
- package/commands/toutiao/[[limit]].ts +0 -8
- package/commands/weather/[city].ts +0 -8
- package/commands/weibo/[[limit]].ts +0 -8
- package/commands/zhihu/[[limit]].ts +0 -8
- package/lib/runtime-deps.js +0 -22
- package/lib/runtime-deps.js.map +0 -1
- package/src/runtime-deps.ts +0 -26
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ province?: string }>({
|
|
6
|
+
description: "查询今日油价",
|
|
7
|
+
inputSchema: z.object({ province: z.string().optional() }),
|
|
8
|
+
keywords: ["油价", "汽油", "柴油", "fuel"],
|
|
9
|
+
tags: ["生活", "油价", "价格"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/fuel-price.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "查询今日黄金价格",
|
|
7
|
+
inputSchema: z.object({}),
|
|
8
|
+
keywords: ["金价", "黄金", "黄金价格", "gold"],
|
|
9
|
+
tags: ["金融", "黄金", "价格"],
|
|
10
|
+
async execute(_input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/gold-price.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "查询今日黄金价格",
|
|
7
|
+
inputSchema: z.object({}),
|
|
8
|
+
keywords: ["金价", "黄金", "黄金价格", "gold"],
|
|
9
|
+
tags: ["金融", "黄金", "价格"],
|
|
10
|
+
async execute(_input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/gold-price.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "获取 Bing 每日壁纸图片",
|
|
7
|
+
inputSchema: z.object({}),
|
|
8
|
+
keywords: ["bing", "必应", "壁纸", "每日壁纸"],
|
|
9
|
+
tags: ["图片", "壁纸", "Bing"],
|
|
10
|
+
async execute(_input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/bing-image.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "获取 Bing 每日壁纸图片",
|
|
7
|
+
inputSchema: z.object({}),
|
|
8
|
+
keywords: ["bing", "必应", "壁纸", "每日壁纸"],
|
|
9
|
+
tags: ["图片", "壁纸", "Bing"],
|
|
10
|
+
async execute(_input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/bing-image.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 60s-news
|
|
3
|
+
description: 60s 新闻及微博、知乎、抖音、头条热榜查询。
|
|
4
|
+
keywords:
|
|
5
|
+
- "新闻"
|
|
6
|
+
- "热搜"
|
|
7
|
+
- "微博"
|
|
8
|
+
- "知乎"
|
|
9
|
+
- "抖音"
|
|
10
|
+
- "头条"
|
|
11
|
+
tools:
|
|
12
|
+
- "60s_news"
|
|
13
|
+
- "douyin_hot"
|
|
14
|
+
- "toutiao_hot"
|
|
15
|
+
- "weibo_hot"
|
|
16
|
+
- "zhihu_hot"
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# 60s-news
|
|
20
|
+
|
|
21
|
+
用户查询新闻或平台热榜时加载。注明数据来源和获取时点,不把热榜当作事实核验结果。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "获取每日60秒新闻,快速了解今日要闻",
|
|
7
|
+
inputSchema: z.object({}),
|
|
8
|
+
keywords: ["60s", "新闻", "今日新闻", "60秒", "每日新闻", "读懂世界"],
|
|
9
|
+
tags: ["新闻", "资讯", "60s"],
|
|
10
|
+
async execute(_input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/60s-news.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineAgentTool } from '@zhin.js/
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
|
|
4
5
|
export default defineAgentTool({
|
|
@@ -6,8 +7,8 @@ export default defineAgentTool({
|
|
|
6
7
|
inputSchema: z.object({}),
|
|
7
8
|
keywords: ["60s", "新闻", "今日新闻", "60秒", "每日新闻", "读懂世界"],
|
|
8
9
|
tags: ["新闻", "资讯", "60s"],
|
|
9
|
-
async execute() {
|
|
10
|
-
const handler = (await import('
|
|
11
|
-
return handler();
|
|
10
|
+
async execute(_input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/60s-news.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken));
|
|
12
13
|
},
|
|
13
14
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "获取抖音热搜榜",
|
|
7
|
+
inputSchema: z.object({ limit: z.number().optional() }),
|
|
8
|
+
keywords: ["抖音", "热搜", "douyin", "dy"],
|
|
9
|
+
tags: ["热搜", "短视频", "抖音"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/douyin-hot.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ limit?: number }>({
|
|
6
|
+
description: "获取抖音热搜榜",
|
|
7
|
+
inputSchema: z.object({ limit: z.number().optional() }),
|
|
8
|
+
keywords: ["抖音", "热搜", "douyin", "dy"],
|
|
9
|
+
tags: ["热搜", "短视频", "抖音"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/douyin-hot.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "获取今日头条热搜榜",
|
|
7
|
+
inputSchema: z.object({ limit: z.number().optional() }),
|
|
8
|
+
keywords: ["头条", "今日头条", "热搜", "toutiao", "tt"],
|
|
9
|
+
tags: ["热搜", "资讯", "头条"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/toutiao-hot.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineAgentTool } from '@zhin.js/
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
|
|
4
5
|
export default defineAgentTool<{ limit?: number }>({
|
|
@@ -6,8 +7,8 @@ export default defineAgentTool<{ limit?: number }>({
|
|
|
6
7
|
inputSchema: z.object({ limit: z.number().optional() }),
|
|
7
8
|
keywords: ["头条", "今日头条", "热搜", "toutiao", "tt"],
|
|
8
9
|
tags: ["热搜", "资讯", "头条"],
|
|
9
|
-
async execute(input) {
|
|
10
|
-
const handler = (await import('
|
|
11
|
-
return handler(input);
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/toutiao-hot.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
12
13
|
},
|
|
13
14
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "获取微博热搜榜",
|
|
7
|
+
inputSchema: z.object({ limit: z.number().optional() }),
|
|
8
|
+
keywords: ["微博", "热搜", "weibo", "wb"],
|
|
9
|
+
tags: ["热搜", "社交", "微博"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/weibo-hot.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ limit?: number }>({
|
|
6
|
+
description: "获取微博热搜榜",
|
|
7
|
+
inputSchema: z.object({ limit: z.number().optional() }),
|
|
8
|
+
keywords: ["微博", "热搜", "weibo", "wb"],
|
|
9
|
+
tags: ["热搜", "社交", "微博"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/weibo-hot.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "获取知乎热榜",
|
|
7
|
+
inputSchema: z.object({ limit: z.number().optional() }),
|
|
8
|
+
keywords: ["知乎", "热榜", "zhihu", "zh"],
|
|
9
|
+
tags: ["热搜", "社交", "知乎"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/zhihu-hot.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ limit?: number }>({
|
|
6
|
+
description: "获取知乎热榜",
|
|
7
|
+
inputSchema: z.object({ limit: z.number().optional() }),
|
|
8
|
+
keywords: ["知乎", "热榜", "zhihu", "zh"],
|
|
9
|
+
tags: ["热搜", "社交", "知乎"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/zhihu-hot.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "查询 IP 地址的地理位置信息",
|
|
7
|
+
inputSchema: z.object({ ip: z.string().optional() }),
|
|
8
|
+
keywords: ["ip", "IP", "IP查询", "ip查询"],
|
|
9
|
+
tags: ["网络", "查询", "IP"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/ip-query.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export default defineAgentTool<{ ip?: string }>({
|
|
6
|
+
description: "查询 IP 地址的地理位置信息",
|
|
7
|
+
inputSchema: z.object({ ip: z.string().optional() }),
|
|
8
|
+
keywords: ["ip", "IP", "IP查询", "ip查询"],
|
|
9
|
+
tags: ["网络", "查询", "IP"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/ip-query.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { sixtySClientToken } from "../../../../lib/client.js";
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: "翻译文本",
|
|
7
|
+
inputSchema: z.object({ text: z.string().min(1), to: z.string().optional() }),
|
|
8
|
+
keywords: ["翻译", "英文", "中文", "日文", "translate", "译"],
|
|
9
|
+
tags: ["工具", "翻译", "语言"],
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import("../../../../lib/handlers/translate.js")).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineAgentTool } from '@zhin.js/
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
|
+
import { sixtySClientToken } from '../../../../src/client.js';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
|
|
4
5
|
export default defineAgentTool<{ text: string; to?: string }>({
|
|
@@ -6,8 +7,8 @@ export default defineAgentTool<{ text: string; to?: string }>({
|
|
|
6
7
|
inputSchema: z.object({ text: z.string().min(1), to: z.string().optional() }),
|
|
7
8
|
keywords: ["翻译", "英文", "中文", "日文", "translate", "译"],
|
|
8
9
|
tags: ["工具", "翻译", "语言"],
|
|
9
|
-
async execute(input) {
|
|
10
|
-
const handler = (await import('
|
|
11
|
-
return handler(input);
|
|
10
|
+
async execute(input, context) {
|
|
11
|
+
const handler = (await import('../../../../src/handlers/translate.js')).default;
|
|
12
|
+
return handler(context.use(sixtySClientToken), input);
|
|
12
13
|
},
|
|
13
14
|
});
|
package/src/api.ts
CHANGED
|
@@ -1,53 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 60s API 共享模块 — 供 *.tool.md handler 使用
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { resolveApiBase } from './runtime-deps.js';
|
|
6
|
-
|
|
7
1
|
export type ListItem = string | Record<string, unknown>;
|
|
8
2
|
|
|
9
|
-
/** Untyped 60s API JSON payload
|
|
3
|
+
/** Untyped 60s API JSON payload narrowed by handlers. */
|
|
10
4
|
export type ApiPayload = Record<string, unknown>;
|
|
11
5
|
|
|
12
|
-
export async function fetchApi<T = ApiPayload>(
|
|
13
|
-
endpoint: string,
|
|
14
|
-
params?: Record<string, string>,
|
|
15
|
-
): Promise<T> {
|
|
16
|
-
const url = new URL(`${resolveApiBase()}/v2${endpoint}`);
|
|
17
|
-
if (params) {
|
|
18
|
-
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
19
|
-
}
|
|
20
|
-
let res: Response;
|
|
21
|
-
try {
|
|
22
|
-
res = await fetch(url.toString(), { signal: AbortSignal.timeout(30_000) });
|
|
23
|
-
} catch (e) {
|
|
24
|
-
const err = e as Error;
|
|
25
|
-
throw new Error(
|
|
26
|
-
err.name === 'TimeoutError' ? '请求超时(30s)' : `请求失败: ${err.message}`,
|
|
27
|
-
{ cause: e },
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
if (!res.ok) {
|
|
31
|
-
throw new Error(`API 请求失败: ${res.status} ${res.statusText}`);
|
|
32
|
-
}
|
|
33
|
-
const contentType = res.headers.get('content-type') ?? '';
|
|
34
|
-
if (!contentType.includes('application/json')) {
|
|
35
|
-
throw new Error(`API 返回非 JSON 响应 (content-type: ${contentType || 'unknown'})`);
|
|
36
|
-
}
|
|
37
|
-
const data = (await res.json()) as {
|
|
38
|
-
error?: string;
|
|
39
|
-
code?: number;
|
|
40
|
-
message?: string;
|
|
41
|
-
msg?: string;
|
|
42
|
-
data?: T;
|
|
43
|
-
};
|
|
44
|
-
if (data.error) throw new Error(data.error);
|
|
45
|
-
if (data.code !== undefined && data.code !== 200 && data.code !== 0) {
|
|
46
|
-
throw new Error(data.message || data.msg || `API 错误: ${data.code}`);
|
|
47
|
-
}
|
|
48
|
-
return (data.data ?? data) as T;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
6
|
/** Coerce nested API JSON objects for property access in handlers. */
|
|
52
7
|
export function asRecord(value: unknown): ApiPayload {
|
|
53
8
|
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createToken } from 'zhin.js';
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_API_BASE = 'https://60s.viki.moe';
|
|
4
|
+
|
|
5
|
+
export type SixtySApiBase = () => string | undefined;
|
|
6
|
+
|
|
7
|
+
/** Owner-scoped transport for one 60s plugin instance. */
|
|
8
|
+
export class SixtySClient {
|
|
9
|
+
readonly #getApiBase: SixtySApiBase;
|
|
10
|
+
|
|
11
|
+
constructor(getApiBase: SixtySApiBase) {
|
|
12
|
+
this.#getApiBase = getApiBase;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get apiBase(): string {
|
|
16
|
+
return this.#getApiBase()?.trim().replace(/\/$/u, '') || DEFAULT_API_BASE;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async fetch<T = Record<string, unknown>>(
|
|
20
|
+
endpoint: string,
|
|
21
|
+
params?: Readonly<Record<string, string>>,
|
|
22
|
+
): Promise<T> {
|
|
23
|
+
const url = new URL(`${this.apiBase}/v2${endpoint}`);
|
|
24
|
+
for (const [key, value] of Object.entries(params ?? {})) {
|
|
25
|
+
url.searchParams.set(key, value);
|
|
26
|
+
}
|
|
27
|
+
let response: Response;
|
|
28
|
+
try {
|
|
29
|
+
response = await fetch(url, { signal: AbortSignal.timeout(30_000) });
|
|
30
|
+
} catch (error) {
|
|
31
|
+
const cause = error as Error;
|
|
32
|
+
throw new Error(
|
|
33
|
+
cause.name === 'TimeoutError' ? '请求超时(30s)' : `请求失败: ${cause.message}`,
|
|
34
|
+
{ cause: error },
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(`API 请求失败: ${response.status} ${response.statusText}`);
|
|
39
|
+
}
|
|
40
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
41
|
+
if (!contentType.includes('application/json')) {
|
|
42
|
+
throw new Error(`API 返回非 JSON 响应 (content-type: ${contentType || 'unknown'})`);
|
|
43
|
+
}
|
|
44
|
+
const envelope = (await response.json()) as {
|
|
45
|
+
error?: string;
|
|
46
|
+
code?: number;
|
|
47
|
+
message?: string;
|
|
48
|
+
msg?: string;
|
|
49
|
+
data?: T;
|
|
50
|
+
};
|
|
51
|
+
if (envelope.error) throw new Error(envelope.error);
|
|
52
|
+
if (envelope.code !== undefined && envelope.code !== 200 && envelope.code !== 0) {
|
|
53
|
+
throw new Error(envelope.message || envelope.msg || `API 错误: ${envelope.code}`);
|
|
54
|
+
}
|
|
55
|
+
return (envelope.data ?? envelope) as T;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const sixtySClientToken = createToken<SixtySClient>(
|
|
60
|
+
'zhin.sixty-s.client',
|
|
61
|
+
'Owner-scoped 60s API client',
|
|
62
|
+
);
|
package/src/handlers/60s-news.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SixtySClient } from '../client.js';
|
|
2
2
|
|
|
3
|
-
export default async function () {
|
|
4
|
-
const data = await
|
|
3
|
+
export default async function (client: SixtySClient) {
|
|
4
|
+
const data = await client.fetch('/60s');
|
|
5
5
|
const lines = [`📰 今日60秒新闻 (${data.date || ''})`, ''];
|
|
6
6
|
if (data.news && Array.isArray(data.news)) {
|
|
7
7
|
lines.push(...data.news.map((n: string, i: number) => `${i + 1}. ${n}`));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { asString
|
|
1
|
+
import { asString } from '../api.js';
|
|
2
|
+
import type { SixtySClient } from '../client.js';
|
|
2
3
|
|
|
3
|
-
export default async function () {
|
|
4
|
-
const data = await
|
|
4
|
+
export default async function (client: SixtySClient) {
|
|
5
|
+
const data = await client.fetch('/bing');
|
|
5
6
|
const lines = ['🖼️ Bing 每日壁纸', ''];
|
|
6
7
|
if (data.title) lines.push(`📌 ${data.title}`);
|
|
7
8
|
if (data.headline) lines.push(`💡 ${data.headline}`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatList, type ListItem } from '../api.js';
|
|
2
|
+
import type { SixtySClient } from '../client.js';
|
|
2
3
|
|
|
3
|
-
export default async function (args: { limit?: number }) {
|
|
4
|
-
const data = await
|
|
4
|
+
export default async function (client: SixtySClient, args: { limit?: number }) {
|
|
5
|
+
const data = await client.fetch<ListItem[]>('/douyin');
|
|
5
6
|
return ['🔥 抖音热搜', '', formatList(data, args.limit || 10)].join('\n');
|
|
6
7
|
}
|
package/src/handlers/duanzi.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SixtySClient } from '../client.js';
|
|
2
2
|
|
|
3
|
-
export default async function () {
|
|
4
|
-
const data = await
|
|
3
|
+
export default async function (client: SixtySClient) {
|
|
4
|
+
const data = await client.fetch('/duanzi');
|
|
5
5
|
return `😂 段子\n\n${data.duanzi || data.content || data.text || (typeof data === 'string' ? data : '')}`;
|
|
6
6
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { asArray, asRecord, asString
|
|
1
|
+
import { asArray, asRecord, asString } from '../api.js';
|
|
2
|
+
import type { SixtySClient } from '../client.js';
|
|
2
3
|
|
|
3
|
-
export default async function (args: { from?: string; to?: string }) {
|
|
4
|
+
export default async function (client: SixtySClient, args: { from?: string; to?: string }) {
|
|
4
5
|
const params: Record<string, string> = {};
|
|
5
6
|
if (args.from) params.from = args.from.toUpperCase();
|
|
6
7
|
if (args.to) params.to = args.to.toUpperCase();
|
|
7
|
-
const data = await
|
|
8
|
+
const data = await client.fetch(
|
|
8
9
|
'/exchange-rate',
|
|
9
10
|
Object.keys(params).length ? params : undefined,
|
|
10
11
|
);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { asRecord, asString
|
|
1
|
+
import { asRecord, asString } from '../api.js';
|
|
2
|
+
import type { SixtySClient } from '../client.js';
|
|
2
3
|
|
|
3
|
-
export default async function (args: { province?: string }) {
|
|
4
|
+
export default async function (client: SixtySClient, args: { province?: string }) {
|
|
4
5
|
const params: Record<string, string> | undefined = args.province
|
|
5
6
|
? { province: args.province }
|
|
6
7
|
: undefined;
|
|
7
|
-
const data = await
|
|
8
|
+
const data = await client.fetch('/fuel-price', params);
|
|
8
9
|
const lines = ['⛽ 今日油价', ''];
|
|
9
10
|
if (data.region) lines.push(`📍 ${data.region}`);
|
|
10
11
|
if (data.items && Array.isArray(data.items)) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { asArray, asRecord
|
|
1
|
+
import { asArray, asRecord } from '../api.js';
|
|
2
|
+
import type { SixtySClient } from '../client.js';
|
|
2
3
|
|
|
3
|
-
export default async function () {
|
|
4
|
-
const data = await
|
|
4
|
+
export default async function (client: SixtySClient) {
|
|
5
|
+
const data = await client.fetch('/gold-price');
|
|
5
6
|
const lines = ['💰 今日金价', ''];
|
|
6
7
|
if (data.date) lines.push(`📅 ${data.date}`);
|
|
7
8
|
const metals = asArray(data.metals);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { asArray, asRecord
|
|
1
|
+
import { asArray, asRecord } from '../api.js';
|
|
2
|
+
import type { SixtySClient } from '../client.js';
|
|
2
3
|
|
|
3
|
-
export default async function () {
|
|
4
|
-
const data = await
|
|
4
|
+
export default async function (client: SixtySClient) {
|
|
5
|
+
const data = await client.fetch('/today-in-history');
|
|
5
6
|
const dateStr = data.date || `${data.month || ''}月${data.day || ''}日`;
|
|
6
7
|
const lines = [`📅 历史上的今天 (${dateStr})`, ''];
|
|
7
8
|
const items = asArray(data.items);
|
package/src/handlers/hitokoto.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SixtySClient } from '../client.js';
|
|
2
2
|
|
|
3
|
-
export default async function (args: { type?: string }) {
|
|
3
|
+
export default async function (client: SixtySClient, args: { type?: string }) {
|
|
4
4
|
const params: Record<string, string> | undefined = args.type
|
|
5
5
|
? { c: args.type }
|
|
6
6
|
: undefined;
|
|
7
|
-
const data = await
|
|
7
|
+
const data = await client.fetch('/hitokoto', params);
|
|
8
8
|
const text = data.hitokoto || data.content || (typeof data === 'string' ? data : '');
|
|
9
9
|
const lines = ['💬 一言', '', `「${text}」`];
|
|
10
10
|
if (data.from || data.source || data.from_who || data.author) {
|
package/src/handlers/ip-query.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SixtySClient } from '../client.js';
|
|
2
2
|
|
|
3
|
-
export default async function (args: { ip?: string }) {
|
|
3
|
+
export default async function (client: SixtySClient, args: { ip?: string }) {
|
|
4
4
|
const params: Record<string, string> | undefined = args.ip
|
|
5
5
|
? { ip: args.ip }
|
|
6
6
|
: undefined;
|
|
7
|
-
const data = await
|
|
7
|
+
const data = await client.fetch('/ip', params);
|
|
8
8
|
const lines = ['🌐 IP 查询', '', `IP: ${data.ip || args.ip || '当前 IP'}`];
|
|
9
9
|
if (data.country || data.region || data.city) {
|
|
10
10
|
lines.push(`位置: ${[data.country, data.region, data.city].filter(Boolean).join(' ')}`);
|
package/src/handlers/kfc.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SixtySClient } from '../client.js';
|
|
2
2
|
|
|
3
|
-
export default async function () {
|
|
4
|
-
const data = await
|
|
3
|
+
export default async function (client: SixtySClient) {
|
|
4
|
+
const data = await client.fetch('/kfc');
|
|
5
5
|
return `🍗 疯狂星期四\n\n${data.kfc || data.content || data.text || (typeof data === 'string' ? data : '')}`;
|
|
6
6
|
}
|