@zhin.js/adapter-telegram 1.1.0 → 1.1.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.
- package/CHANGELOG.md +108 -0
- package/README.md +5 -5
- package/adapters/{telegram.js → telegram/index.js} +6 -6
- package/adapters/{telegram.ts → telegram/index.ts} +9 -9
- package/agents/telegram/agent.json +20 -0
- package/agents/telegram/boundaries.md +3 -0
- package/agents/telegram/conventions.md +3 -0
- package/agents/telegram/skills/telegram-chat-admin/SKILL.md +24 -0
- package/agents/telegram/skills/telegram-chat-admin/tools/create_invite/index.js +18 -0
- package/{agent/tools/create_invite.ts → agents/telegram/skills/telegram-chat-admin/tools/create_invite/index.ts} +3 -3
- package/agents/telegram/skills/telegram-chat-admin/tools/list_admins/index.js +24 -0
- package/{agent/tools/list_admins.ts → agents/telegram/skills/telegram-chat-admin/tools/list_admins/index.ts} +1 -1
- package/agents/telegram/skills/telegram-chat-admin/tools/member_count/index.js +16 -0
- package/{agent/tools/member_count.ts → agents/telegram/skills/telegram-chat-admin/tools/member_count/index.ts} +1 -1
- package/agents/telegram/skills/telegram-chat-admin/tools/pin_message/index.js +19 -0
- package/{agent/tools/pin_message.ts → agents/telegram/skills/telegram-chat-admin/tools/pin_message/index.ts} +3 -3
- package/agents/telegram/skills/telegram-chat-admin/tools/set_description/index.js +17 -0
- package/{agent/tools/set_description.ts → agents/telegram/skills/telegram-chat-admin/tools/set_description/index.ts} +1 -1
- package/agents/telegram/skills/telegram-chat-admin/tools/set_permissions/index.js +32 -0
- package/{agent/tools/set_permissions.ts → agents/telegram/skills/telegram-chat-admin/tools/set_permissions/index.ts} +3 -3
- package/agents/telegram/skills/telegram-chat-admin/tools/unpin_message/index.js +19 -0
- package/{agent/tools/unpin_message.ts → agents/telegram/skills/telegram-chat-admin/tools/unpin_message/index.ts} +3 -3
- package/agents/telegram/skills/telegram-messages/SKILL.md +19 -0
- package/agents/telegram/skills/telegram-messages/tools/react/index.js +18 -0
- package/{agent/tools/react.ts → agents/telegram/skills/telegram-messages/tools/react/index.ts} +1 -1
- package/agents/telegram/skills/telegram-messages/tools/send_poll/index.js +30 -0
- package/{agent/tools/send_poll.ts → agents/telegram/skills/telegram-messages/tools/send_poll/index.ts} +1 -1
- package/agents/telegram/skills/telegram-messages/tools/send_sticker/index.js +17 -0
- package/{agent/tools/send_sticker.ts → agents/telegram/skills/telegram-messages/tools/send_sticker/index.ts} +1 -1
- package/agents/telegram/system.md +3 -0
- package/commands/{endpoint/add/[id].js → telegram/endpoint/add/[id]/index.js} +1 -1
- package/commands/telegram/endpoint/add/[id]/index.ts +3 -0
- package/{lib/telegram-endpoint-commands.js → commands/telegram/endpoint/definition.js} +4 -3
- package/{src/telegram-endpoint-commands.ts → commands/telegram/endpoint/definition.ts} +3 -3
- package/commands/{endpoint/list.js → telegram/endpoint/list/index.js} +1 -1
- package/commands/telegram/endpoint/list/index.ts +3 -0
- package/commands/{endpoint/remove/[id].js → telegram/endpoint/remove/[id]/index.js} +1 -1
- package/commands/telegram/endpoint/remove/[id]/index.ts +3 -0
- package/lib/index.d.ts +1 -1
- package/lib/protocol.d.ts +6 -14
- package/lib/protocol.js +15 -26
- package/lib/telegram-runtime-state.js +1 -1
- package/package.json +33 -21
- package/schema.json +32 -1
- package/src/index.ts +1 -1
- package/src/protocol.ts +20 -43
- package/src/telegram-runtime-state.ts +1 -1
- package/agent/skills/telegram.md +0 -103
- package/commands/endpoint/add/[id].ts +0 -3
- package/commands/endpoint/list.ts +0 -3
- package/commands/endpoint/remove/[id].ts +0 -3
- package/lib/telegram-endpoint-commands.d.ts +0 -1
- /package/{agent/PERMITS.md → PERMITS.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,113 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [5b5d270]
|
|
8
|
+
- Updated dependencies [36c2eb9]
|
|
9
|
+
- @zhin.js/im-contract@1.1.2
|
|
10
|
+
- @zhin.js/core@1.1.38
|
|
11
|
+
- @zhin.js/adapter@1.1.15
|
|
12
|
+
- @zhin.js/host-http@1.1.2
|
|
13
|
+
- @zhin.js/agent-feature@1.1.2
|
|
14
|
+
- @zhin.js/feature-kit@1.1.2
|
|
15
|
+
- @zhin.js/skill@1.1.2
|
|
16
|
+
- @zhin.js/tool@1.1.2
|
|
17
|
+
|
|
18
|
+
## 1.1.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- a9e4a40: Derive Command user routes only from explicit `commands/**/*/index.ts(x)` entry paths instead of prepending the plugin owner. Child plugins can now publish top-level static or dynamic commands, while duplicate routes across owners fail during generation construction. Adapter endpoint commands move to explicit paths such as `commands/qq/endpoint/list/index.ts` and are invoked as `qq endpoint list`.
|
|
23
|
+
- 8740059: Standardize TypeScript capabilities on named module directories such as `commands/foo/index.ts`, `middlewares/audit/index.ts`, `handlers/message-receive/index.ts`, `pages/workroom/index.tsx`, and `mcps/filesystem/index.ts`. Only the fixed `index` entry is discovered; sibling files remain private helpers.
|
|
24
|
+
|
|
25
|
+
Command route segments come from directories, while `[name]`, `[[name]]`, `[...name]`, and `[[...name]]` directories declare dynamic parameters. Plugin owners do not enter the route unless their config explicitly sets `commandNamespace`; Endpoint `commandPrefix` remains platform-owned and defaults to an empty string.
|
|
26
|
+
|
|
27
|
+
Migrate the built-in adapters, plugins, examples, generators, migration tooling, hot reload classification, Agent authoring surfaces, documentation, and release artifacts to the explicit entry convention.
|
|
28
|
+
|
|
29
|
+
Make Tool ownership and progressive disclosure explicit across all four supported locations: plugin-public `tools/`, Agent-private `agents/<name>/tools/`, Skill-private `skills/<name>/tools/`, and Agent-Skill-private `agents/<name>/skills/<name>/tools/`. Move adapter and group-suite operations that require domain instructions into their owning Skills so `load_skill` is the only path that unlocks their schemas.
|
|
30
|
+
|
|
31
|
+
Remove the package-root `agent/` convention. Public capabilities now use named package-root directories, schedules use `schedules/<name>/index.ts` or `plugin.ts` injection, MCP connections use `mcps/<name>/index.ts`, Prompt Sections use `prompt-sections/<name>/index.ts`, Agent definitions use `agents/<name>/`, and permission vocabulary is published as `PERMITS.md`.
|
|
32
|
+
|
|
33
|
+
- 25a845a: Unify Skills on `skills/<name>/SKILL.md`, support Agent-private Skills and nested Skill-private Tools, publish and mount existing plugin Skills, add governed Skill metadata and Turn access filtering, unlock only already-admitted same-owner Tools, and make `on-risk` and `once` approval behavior precise.
|
|
34
|
+
- ddbb92e: Isolate adapter Skills under platform-specific Agents and automatically select the matching platform Agent for IM ingress, preventing unrelated adapter Skills from entering another platform's prompt surface.
|
|
35
|
+
- 40d2c8f: Reduce the default Agent Tool surface by moving process diagnostics into a Skill and splitting broad platform Skills into focused task domains. Restore ICQQ friend and group directory tools with `on-risk` approval and explicit owner, administrator, master, or trusted access.
|
|
36
|
+
- 4380cf9: Colocate adapter command definitions and Agent Skill handlers with their owning capabilities, and provide a shared validated platform permission constructor.
|
|
37
|
+
- 7b47680: Require the canonical expanded Telegram endpoint configuration. The protocol no longer reinterprets nested `endpoints` or reads endpoint identity, token, and webhook secret from `process.env`. The public config type is now `TelegramEndpointConfig`.
|
|
38
|
+
- 5c3858e: Make `@zhin.js/im-contract` the explicit zero-dependency owner of transport identities, canonical segments, media guards, conversation facts, stores, and delivery contracts. Platform adapters now read media contracts from that foundation instead of reaching through Core.
|
|
39
|
+
- 33ea736: Use `tools/<name>/index.ts` and `defineAgentTool` from `@zhin.js/tool` as the sole Agent Tool authoring model. Remove the duplicate `@zhin.js/tools` definition, context, bridge, export, and discovery path; migrate plugin manifests, examples, scaffolding, HMR, and prepack compilation to the generation-owned Tool Feature.
|
|
40
|
+
- Updated dependencies [c861789]
|
|
41
|
+
- Updated dependencies [1414ccb]
|
|
42
|
+
- Updated dependencies [743d470]
|
|
43
|
+
- Updated dependencies [62dee52]
|
|
44
|
+
- Updated dependencies [cd54131]
|
|
45
|
+
- Updated dependencies [244e475]
|
|
46
|
+
- Updated dependencies [a9e4a40]
|
|
47
|
+
- Updated dependencies [5855db7]
|
|
48
|
+
- Updated dependencies [ec921d2]
|
|
49
|
+
- Updated dependencies [8740059]
|
|
50
|
+
- Updated dependencies [63d1f7a]
|
|
51
|
+
- Updated dependencies [25a845a]
|
|
52
|
+
- Updated dependencies [103f2c3]
|
|
53
|
+
- Updated dependencies [9110ab8]
|
|
54
|
+
- Updated dependencies [cd2a888]
|
|
55
|
+
- Updated dependencies [eb3227a]
|
|
56
|
+
- Updated dependencies [b853dba]
|
|
57
|
+
- Updated dependencies [e561309]
|
|
58
|
+
- Updated dependencies [d4c6175]
|
|
59
|
+
- Updated dependencies [7a0e1ca]
|
|
60
|
+
- Updated dependencies [103b5d3]
|
|
61
|
+
- Updated dependencies [5a7a7f7]
|
|
62
|
+
- Updated dependencies [b076eae]
|
|
63
|
+
- Updated dependencies [535fed1]
|
|
64
|
+
- Updated dependencies [73a24b7]
|
|
65
|
+
- Updated dependencies [2dbbc15]
|
|
66
|
+
- Updated dependencies [1cb1163]
|
|
67
|
+
- Updated dependencies [be3061e]
|
|
68
|
+
- Updated dependencies [75f8332]
|
|
69
|
+
- Updated dependencies [81935e2]
|
|
70
|
+
- Updated dependencies [f9ed01b]
|
|
71
|
+
- Updated dependencies [ac0ab50]
|
|
72
|
+
- Updated dependencies [5140ce1]
|
|
73
|
+
- Updated dependencies [522d75f]
|
|
74
|
+
- Updated dependencies [a7611b3]
|
|
75
|
+
- Updated dependencies [8823044]
|
|
76
|
+
- Updated dependencies [379439b]
|
|
77
|
+
- Updated dependencies [11c9352]
|
|
78
|
+
- Updated dependencies [6b70e46]
|
|
79
|
+
- Updated dependencies [135ac91]
|
|
80
|
+
- Updated dependencies [140cf0f]
|
|
81
|
+
- Updated dependencies [251e4d2]
|
|
82
|
+
- Updated dependencies [203ad34]
|
|
83
|
+
- Updated dependencies [e6c5113]
|
|
84
|
+
- Updated dependencies [e0f6478]
|
|
85
|
+
- Updated dependencies [baef56b]
|
|
86
|
+
- Updated dependencies [698f16f]
|
|
87
|
+
- Updated dependencies [da0a8e3]
|
|
88
|
+
- Updated dependencies [2fd8017]
|
|
89
|
+
- Updated dependencies [5c3858e]
|
|
90
|
+
- Updated dependencies [33ea736]
|
|
91
|
+
- Updated dependencies [507d602]
|
|
92
|
+
- Updated dependencies [df9f76b]
|
|
93
|
+
- @zhin.js/core@1.1.37
|
|
94
|
+
- @zhin.js/tool@1.1.1
|
|
95
|
+
- @zhin.js/host-http@1.1.1
|
|
96
|
+
- @zhin.js/adapter@1.1.14
|
|
97
|
+
- @zhin.js/feature-kit@1.1.1
|
|
98
|
+
- @zhin.js/agent-feature@1.1.1
|
|
99
|
+
- @zhin.js/skill@1.1.1
|
|
100
|
+
- @zhin.js/logger@1.1.1
|
|
101
|
+
- @zhin.js/im-contract@1.1.1
|
|
102
|
+
|
|
103
|
+
## 1.1.1
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- Updated dependencies [769e67f]
|
|
108
|
+
- @zhin.js/adapter@1.1.13
|
|
109
|
+
- @zhin.js/core@1.1.36
|
|
110
|
+
|
|
3
111
|
## 1.1.0
|
|
4
112
|
|
|
5
113
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ pnpm add @zhin.js/adapter-telegram
|
|
|
19
19
|
|
|
20
20
|
## Plugin Runtime
|
|
21
21
|
|
|
22
|
-
- `@zhin.js/adapter` — 约定式 `adapters/telegram.ts`(`defineAdapter`)
|
|
22
|
+
- `@zhin.js/adapter` — 约定式 `adapters/telegram/index.ts`(`defineAdapter`)
|
|
23
23
|
- `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
|
|
24
24
|
- `zhin.js` — `plugin.ts`(`definePlugin`)
|
|
25
25
|
- 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`
|
|
@@ -62,8 +62,8 @@ plugins:
|
|
|
62
62
|
|
|
63
63
|
| 变量 | 说明 |
|
|
64
64
|
|------|------|
|
|
65
|
-
| `TELEGRAM_TOKEN`
|
|
66
|
-
| `
|
|
65
|
+
| `TELEGRAM_TOKEN` | 示例中由 YAML `${TELEGRAM_TOKEN}` 引用的 Bot Token;变量名可自行定义 |
|
|
66
|
+
| `TELEGRAM_WEBHOOK_SECRET` | 示例中由 YAML `${TELEGRAM_WEBHOOK_SECRET}` 引用的 webhook secret;变量名可自行定义 |
|
|
67
67
|
|
|
68
68
|
## Webhook
|
|
69
69
|
|
|
@@ -115,8 +115,8 @@ Webhook 接收确认不等于业务处理完成;需要幂等性的业务应自
|
|
|
115
115
|
|
|
116
116
|
| Kind | Path |
|
|
117
117
|
|------|------|
|
|
118
|
-
| Platform tools (10) | `
|
|
119
|
-
| Skill doc | `
|
|
118
|
+
| Platform tools (10) | `tools/`(invite / pin / admins / sticker / poll 等) |
|
|
119
|
+
| Skill doc | `agents/telegram/skills/telegram-chat-admin/SKILL.md`, `agents/telegram/skills/telegram-messages/SKILL.md` |
|
|
120
120
|
|
|
121
121
|
## 故障排查
|
|
122
122
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
2
|
/**
|
|
3
|
-
* Convention entry: discover `adapters/telegram.ts` → defineAdapter.
|
|
3
|
+
* Convention entry: discover `adapters/telegram/index.ts` → defineAdapter.
|
|
4
4
|
*/
|
|
5
5
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
6
6
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
7
|
-
import { TelegramEndpoint } from "
|
|
8
|
-
import { resolveTelegramConfig, } from "
|
|
9
|
-
import { telegramRuntimeStateToken } from "
|
|
10
|
-
export { TelegramEndpoint } from "
|
|
7
|
+
import { TelegramEndpoint } from "../../lib/endpoint.js";
|
|
8
|
+
import { resolveTelegramConfig, } from "../../lib/protocol.js";
|
|
9
|
+
import { telegramRuntimeStateToken } from "../../lib/telegram-runtime-state.js";
|
|
10
|
+
export { TelegramEndpoint } from "../../lib/endpoint.js";
|
|
11
11
|
export default defineAdapter({
|
|
12
12
|
capabilities: ['inbound', 'outbound'],
|
|
13
13
|
operations: ['recall'],
|
|
@@ -20,7 +20,7 @@ export default defineAdapter({
|
|
|
20
20
|
},
|
|
21
21
|
create(context) {
|
|
22
22
|
const config = resolveTelegramConfig(context.config);
|
|
23
|
-
// 注册到插件运行时状态(telegram
|
|
23
|
+
// 注册到插件运行时状态(telegram endpoint list 的"运行中"数据源)
|
|
24
24
|
context.use(telegramRuntimeStateToken).endpoints.set(config.id, {
|
|
25
25
|
id: config.id,
|
|
26
26
|
mode: config.mode,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Convention entry: discover `adapters/telegram.ts` → defineAdapter.
|
|
2
|
+
* Convention entry: discover `adapters/telegram/index.ts` → defineAdapter.
|
|
3
3
|
*/
|
|
4
4
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
5
5
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
6
|
-
import { TelegramEndpoint } from '
|
|
6
|
+
import { TelegramEndpoint } from '../../src/endpoint.js';
|
|
7
7
|
import {
|
|
8
8
|
resolveTelegramConfig,
|
|
9
|
-
type
|
|
10
|
-
} from '
|
|
11
|
-
import { telegramRuntimeStateToken } from '
|
|
9
|
+
type TelegramEndpointConfig,
|
|
10
|
+
} from '../../src/protocol.js';
|
|
11
|
+
import { telegramRuntimeStateToken } from '../../src/telegram-runtime-state.js';
|
|
12
12
|
|
|
13
|
-
export { TelegramEndpoint } from '
|
|
14
|
-
export type { TelegramEndpointOptions, TelegramFetch } from '
|
|
13
|
+
export { TelegramEndpoint } from '../../src/endpoint.js';
|
|
14
|
+
export type { TelegramEndpointOptions, TelegramFetch } from '../../src/endpoint.js';
|
|
15
15
|
|
|
16
|
-
export default defineAdapter<
|
|
16
|
+
export default defineAdapter<TelegramEndpointConfig>({
|
|
17
17
|
capabilities: ['inbound', 'outbound'],
|
|
18
18
|
operations: ['recall'],
|
|
19
19
|
// 媒体 url / file_id 直发,base64 / 本地路径经 multipart attach:// 上传物化;
|
|
@@ -25,7 +25,7 @@ export default defineAdapter<TelegramAdapterConfig>({
|
|
|
25
25
|
},
|
|
26
26
|
create(context) {
|
|
27
27
|
const config = resolveTelegramConfig(context.config);
|
|
28
|
-
// 注册到插件运行时状态(telegram
|
|
28
|
+
// 注册到插件运行时状态(telegram endpoint list 的"运行中"数据源)
|
|
29
29
|
context.use(telegramRuntimeStateToken).endpoints.set(config.id, {
|
|
30
30
|
id: config.id,
|
|
31
31
|
mode: config.mode,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "TELEGRAM Platform Agent",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Handles telegram platform-specific operations and progressively loads only the required platform Skill.",
|
|
5
|
+
"trigger_rules": {
|
|
6
|
+
"file_patterns": [],
|
|
7
|
+
"keywords": [
|
|
8
|
+
"telegram",
|
|
9
|
+
"adapter:telegram"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"entry_points": [
|
|
13
|
+
"system.md",
|
|
14
|
+
"boundaries.md",
|
|
15
|
+
"conventions.md"
|
|
16
|
+
],
|
|
17
|
+
"platforms": [
|
|
18
|
+
"telegram"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: telegram-chat-admin
|
|
3
|
+
platforms:
|
|
4
|
+
- telegram
|
|
5
|
+
description: Telegram 管理员查询、成员数、邀请、置顶和群权限设置能力。
|
|
6
|
+
keywords:
|
|
7
|
+
- "telegram"
|
|
8
|
+
- "admin"
|
|
9
|
+
- "invite"
|
|
10
|
+
- "pin"
|
|
11
|
+
- "permissions"
|
|
12
|
+
tools:
|
|
13
|
+
- "pin_message"
|
|
14
|
+
- "unpin_message"
|
|
15
|
+
- "list_admins"
|
|
16
|
+
- "member_count"
|
|
17
|
+
- "create_invite"
|
|
18
|
+
- "set_permissions"
|
|
19
|
+
- "set_description"
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# telegram-chat-admin
|
|
23
|
+
|
|
24
|
+
先读取管理员与成员状态,再执行邀请、置顶或权限变更。群设置写操作遵守审批策略。
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { platformPermission } from '@zhin.js/permission';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: '创建 Telegram 群组邀请链接',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
9
|
+
}),
|
|
10
|
+
adapter: 'telegram',
|
|
11
|
+
tags: ['telegram'],
|
|
12
|
+
permissions: [platformPermission('telegram', 'chat_administrator')],
|
|
13
|
+
async execute({ chat_id }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
15
|
+
const link = await endpoint.createInviteLink(Number(chat_id));
|
|
16
|
+
return { invite_link: link, message: `邀请链接: ${link}` };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineAgentTool } from '@zhin.js/
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
4
|
|
|
5
5
|
export default defineAgentTool<{ chat_id: string }>({
|
|
6
6
|
description: '创建 Telegram 群组邀请链接',
|
|
@@ -9,7 +9,7 @@ export default defineAgentTool<{ chat_id: string }>({
|
|
|
9
9
|
}),
|
|
10
10
|
adapter: 'telegram',
|
|
11
11
|
tags: ['telegram'],
|
|
12
|
-
permissions: [
|
|
12
|
+
permissions: [platformPermission('telegram', 'chat_administrator')],
|
|
13
13
|
async execute({ chat_id }: { chat_id: string }, context) {
|
|
14
14
|
const endpoint = context.$client;
|
|
15
15
|
const link = await endpoint.createInviteLink(Number(chat_id));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '获取 Telegram 群组管理员列表',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'telegram',
|
|
10
|
+
tags: ['telegram'],
|
|
11
|
+
async execute({ chat_id }, context) {
|
|
12
|
+
const endpoint = context.$client;
|
|
13
|
+
const admins = await endpoint.getChatAdmins(Number(chat_id));
|
|
14
|
+
return {
|
|
15
|
+
admins: admins.map((a) => ({
|
|
16
|
+
user_id: a.user.id,
|
|
17
|
+
username: a.user.username,
|
|
18
|
+
first_name: a.user.first_name,
|
|
19
|
+
status: a.status,
|
|
20
|
+
})),
|
|
21
|
+
count: admins.length,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '获取 Telegram 群组成员数量',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
8
|
+
}),
|
|
9
|
+
adapter: 'telegram',
|
|
10
|
+
tags: ['telegram'],
|
|
11
|
+
async execute({ chat_id }, context) {
|
|
12
|
+
const endpoint = context.$client;
|
|
13
|
+
const count = await endpoint.getChatMemberCount(Number(chat_id));
|
|
14
|
+
return { count, message: `群组共有 ${count} 名成员` };
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -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 { platformPermission } from '@zhin.js/permission';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: '置顶 Telegram 群组消息',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
9
|
+
message_id: z.string().describe('消息 ID'),
|
|
10
|
+
}),
|
|
11
|
+
adapter: 'telegram',
|
|
12
|
+
tags: ['telegram'],
|
|
13
|
+
permissions: [platformPermission('telegram', 'pin_messages')],
|
|
14
|
+
async execute({ chat_id, message_id }, context) {
|
|
15
|
+
const endpoint = context.$client;
|
|
16
|
+
const success = await endpoint.pinMessage(Number(chat_id), Number(message_id));
|
|
17
|
+
return { success, message: success ? '消息已置顶' : '操作失败' };
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineAgentTool } from '@zhin.js/
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
4
|
|
|
5
5
|
export default defineAgentTool<{ chat_id: string; message_id: string }>({
|
|
6
6
|
description: '置顶 Telegram 群组消息',
|
|
@@ -10,7 +10,7 @@ export default defineAgentTool<{ chat_id: string; message_id: string }>({
|
|
|
10
10
|
}),
|
|
11
11
|
adapter: 'telegram',
|
|
12
12
|
tags: ['telegram'],
|
|
13
|
-
permissions: [
|
|
13
|
+
permissions: [platformPermission('telegram', 'pin_messages')],
|
|
14
14
|
async execute({ chat_id, message_id }: { chat_id: string; message_id: string }, context) {
|
|
15
15
|
const endpoint = context.$client;
|
|
16
16
|
const success = await endpoint.pinMessage(Number(chat_id), Number(message_id));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '设置 Telegram 群组描述',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
8
|
+
description: z.string().describe('群描述文字'),
|
|
9
|
+
}),
|
|
10
|
+
adapter: 'telegram',
|
|
11
|
+
tags: ['telegram'],
|
|
12
|
+
async execute({ chat_id, description }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
14
|
+
const success = await endpoint.setChatDescription(Number(chat_id), description);
|
|
15
|
+
return { success, message: success ? '群描述已更新' : '操作失败' };
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { platformPermission } from '@zhin.js/permission';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: '设置 Telegram 群组的默认成员权限',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
9
|
+
can_send_messages: z.boolean().optional().describe('是否可以发消息'),
|
|
10
|
+
can_send_photos: z.boolean().optional().describe('是否可以发图片'),
|
|
11
|
+
can_send_videos: z.boolean().optional().describe('是否可以发视频'),
|
|
12
|
+
can_send_polls: z.boolean().optional().describe('是否可以发投票'),
|
|
13
|
+
can_send_other_messages: z.boolean().optional().describe('是否可以发贴纸/GIF等'),
|
|
14
|
+
can_add_web_page_previews: z.boolean().optional().describe('是否可以添加网页预览'),
|
|
15
|
+
can_change_info: z.boolean().optional().describe('是否可以改群信息'),
|
|
16
|
+
can_invite_users: z.boolean().optional().describe('是否可以邀请用户'),
|
|
17
|
+
can_pin_messages: z.boolean().optional().describe('是否可以置顶消息'),
|
|
18
|
+
}),
|
|
19
|
+
adapter: 'telegram',
|
|
20
|
+
tags: ['telegram'],
|
|
21
|
+
permissions: [platformPermission('telegram', 'manage_chat')],
|
|
22
|
+
async execute({ chat_id, ...perms }, context) {
|
|
23
|
+
const endpoint = context.$client;
|
|
24
|
+
const permissions = {};
|
|
25
|
+
for (const [k, v] of Object.entries(perms)) {
|
|
26
|
+
if (typeof v === 'boolean')
|
|
27
|
+
permissions[k] = v;
|
|
28
|
+
}
|
|
29
|
+
const success = await endpoint.setChatPermissionsAll(Number(chat_id), permissions);
|
|
30
|
+
return { success, message: success ? '群权限已更新' : '操作失败' };
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineAgentTool } from '@zhin.js/
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
4
|
|
|
5
5
|
export default defineAgentTool<{ chat_id: string; can_send_messages?: boolean; can_send_photos?: boolean; can_send_videos?: boolean; can_send_polls?: boolean; can_send_other_messages?: boolean; can_add_web_page_previews?: boolean; can_change_info?: boolean; can_invite_users?: boolean; can_pin_messages?: boolean }>({
|
|
6
6
|
description: '设置 Telegram 群组的默认成员权限',
|
|
@@ -18,7 +18,7 @@ export default defineAgentTool<{ chat_id: string; can_send_messages?: boolean; c
|
|
|
18
18
|
}),
|
|
19
19
|
adapter: 'telegram',
|
|
20
20
|
tags: ['telegram'],
|
|
21
|
-
permissions: [
|
|
21
|
+
permissions: [platformPermission('telegram', 'manage_chat')],
|
|
22
22
|
async execute({ chat_id, ...perms }: { chat_id: string; can_send_messages?: boolean; can_send_photos?: boolean; can_send_videos?: boolean; can_send_polls?: boolean; can_send_other_messages?: boolean; can_add_web_page_previews?: boolean; can_change_info?: boolean; can_invite_users?: boolean; can_pin_messages?: boolean }, context) {
|
|
23
23
|
const endpoint = context.$client;
|
|
24
24
|
const permissions: Record<string, boolean> = {};
|
|
@@ -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 { platformPermission } from '@zhin.js/permission';
|
|
5
|
+
export default defineAgentTool({
|
|
6
|
+
description: '取消置顶 Telegram 群组消息',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
9
|
+
message_id: z.string().optional().describe('消息 ID(可选,不提供则取消所有置顶)'),
|
|
10
|
+
}),
|
|
11
|
+
adapter: 'telegram',
|
|
12
|
+
tags: ['telegram'],
|
|
13
|
+
permissions: [platformPermission('telegram', 'pin_messages')],
|
|
14
|
+
async execute({ chat_id, message_id }, context) {
|
|
15
|
+
const endpoint = context.$client;
|
|
16
|
+
const success = await endpoint.unpinMessage(Number(chat_id), message_id ? Number(message_id) : undefined);
|
|
17
|
+
return { success, message: success ? '已取消置顶' : '操作失败' };
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineAgentTool } from '@zhin.js/
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { platformPermission } from '@zhin.js/permission';
|
|
4
4
|
|
|
5
5
|
export default defineAgentTool<{ chat_id: string; message_id?: string }>({
|
|
6
6
|
description: '取消置顶 Telegram 群组消息',
|
|
@@ -10,7 +10,7 @@ export default defineAgentTool<{ chat_id: string; message_id?: string }>({
|
|
|
10
10
|
}),
|
|
11
11
|
adapter: 'telegram',
|
|
12
12
|
tags: ['telegram'],
|
|
13
|
-
permissions: [
|
|
13
|
+
permissions: [platformPermission('telegram', 'pin_messages')],
|
|
14
14
|
async execute({ chat_id, message_id }: { chat_id: string; message_id?: string }, context) {
|
|
15
15
|
const endpoint = context.$client;
|
|
16
16
|
const success = await endpoint.unpinMessage(Number(chat_id), message_id ? Number(message_id) : undefined);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: telegram-messages
|
|
3
|
+
platforms:
|
|
4
|
+
- telegram
|
|
5
|
+
description: Telegram 投票、reaction 和贴纸消息能力。
|
|
6
|
+
keywords:
|
|
7
|
+
- "telegram"
|
|
8
|
+
- "poll"
|
|
9
|
+
- "reaction"
|
|
10
|
+
- "sticker"
|
|
11
|
+
tools:
|
|
12
|
+
- "send_poll"
|
|
13
|
+
- "react"
|
|
14
|
+
- "send_sticker"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# telegram-messages
|
|
18
|
+
|
|
19
|
+
用于消息互动。确认聊天和目标消息后调用,避免重复发送。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '对 Telegram 消息添加表情反应',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
8
|
+
message_id: z.string().describe('消息 ID'),
|
|
9
|
+
reaction: z.string().describe('反应表情(如 👍、❤️、🔥)'),
|
|
10
|
+
}),
|
|
11
|
+
adapter: 'telegram',
|
|
12
|
+
tags: ['telegram'],
|
|
13
|
+
async execute({ chat_id, message_id, reaction }, context) {
|
|
14
|
+
const endpoint = context.$client;
|
|
15
|
+
const success = await endpoint.setMessageReaction(Number(chat_id), Number(message_id), reaction);
|
|
16
|
+
return { success, message: success ? `已添加反应 ${reaction}` : '操作失败' };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '在 Telegram 群组中发起投票',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
8
|
+
question: z.string().describe('投票问题'),
|
|
9
|
+
options: z.string().describe('选项 JSON 数组,如 ["A","B","C"]'),
|
|
10
|
+
is_anonymous: z.boolean().optional().describe('是否匿名投票,默认 true'),
|
|
11
|
+
allows_multiple: z.boolean().optional().describe('是否允许多选,默认 false'),
|
|
12
|
+
}),
|
|
13
|
+
adapter: 'telegram',
|
|
14
|
+
tags: ['telegram'],
|
|
15
|
+
async execute({ chat_id, question, options, is_anonymous, allows_multiple }, context) {
|
|
16
|
+
const endpoint = context.$client;
|
|
17
|
+
let optList;
|
|
18
|
+
try {
|
|
19
|
+
optList = JSON.parse(options);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { success: false, message: 'options 格式错误,应为 JSON 数组' };
|
|
23
|
+
}
|
|
24
|
+
if (!Array.isArray(optList) || optList.length < 2) {
|
|
25
|
+
return { success: false, message: '至少需要 2 个选项' };
|
|
26
|
+
}
|
|
27
|
+
const result = await endpoint.sendPoll(Number(chat_id), question, optList, is_anonymous ?? true, allows_multiple ?? false);
|
|
28
|
+
return { success: true, message_id: result.message_id, message: '投票已发送' };
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineAgentTool } from '@zhin.js/
|
|
1
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
export default defineAgentTool<{ chat_id: string; question: string; options: string; is_anonymous?: boolean; allows_multiple?: boolean }>({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineAgentTool } from '@zhin.js/tool';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export default defineAgentTool({
|
|
5
|
+
description: '发送 Telegram 贴纸',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
chat_id: z.string().describe('聊天 ID'),
|
|
8
|
+
sticker: z.string().describe('贴纸 file_id 或 URL'),
|
|
9
|
+
}),
|
|
10
|
+
adapter: 'telegram',
|
|
11
|
+
tags: ['telegram'],
|
|
12
|
+
async execute({ chat_id, sticker }, context) {
|
|
13
|
+
const endpoint = context.$client;
|
|
14
|
+
const result = await endpoint.sendStickerMessage(Number(chat_id), sticker);
|
|
15
|
+
return { success: true, message_id: result.message_id, message: '贴纸已发送' };
|
|
16
|
+
},
|
|
17
|
+
});
|