@zhin.js/adapter-lark 4.0.2 → 5.0.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +60 -88
  3. package/adapters/lark.ts +26 -0
  4. package/agent/tools/add_members.ts +2 -2
  5. package/agent/tools/create_chat.ts +2 -2
  6. package/agent/tools/dissolve_chat.ts +2 -2
  7. package/agent/tools/get_user.ts +2 -2
  8. package/agent/tools/remove_managers.ts +2 -2
  9. package/agent/tools/set_managers.ts +2 -2
  10. package/agent/tools/update_chat.ts +2 -2
  11. package/agent/tools/upload_file.ts +2 -2
  12. package/lib/endpoint.d.ts +53 -0
  13. package/lib/endpoint.js +333 -0
  14. package/lib/index.d.ts +5 -0
  15. package/lib/index.js +5 -0
  16. package/lib/lark-agent-deps.d.ts +27 -0
  17. package/lib/lark-agent-deps.js +30 -0
  18. package/lib/platform-permit.d.ts +15 -0
  19. package/lib/{src/platform-permit.js → platform-permit.js} +1 -2
  20. package/lib/protocol.d.ts +111 -0
  21. package/lib/protocol.js +204 -0
  22. package/lib/webhook.d.ts +13 -0
  23. package/lib/webhook.js +67 -0
  24. package/package.json +43 -24
  25. package/plugin.ts +12 -0
  26. package/schema.json +61 -0
  27. package/src/endpoint.ts +354 -705
  28. package/src/index.ts +45 -59
  29. package/src/lark-agent-deps.ts +53 -9
  30. package/src/platform-permit.ts +1 -1
  31. package/src/protocol.ts +332 -0
  32. package/src/webhook.ts +101 -0
  33. package/lib/agent/tools/add_members.js +0 -21
  34. package/lib/agent/tools/add_members.js.map +0 -1
  35. package/lib/agent/tools/create_chat.js +0 -20
  36. package/lib/agent/tools/create_chat.js.map +0 -1
  37. package/lib/agent/tools/dissolve_chat.js +0 -18
  38. package/lib/agent/tools/dissolve_chat.js.map +0 -1
  39. package/lib/agent/tools/get_user.js +0 -17
  40. package/lib/agent/tools/get_user.js.map +0 -1
  41. package/lib/agent/tools/remove_managers.js +0 -21
  42. package/lib/agent/tools/remove_managers.js.map +0 -1
  43. package/lib/agent/tools/set_managers.js +0 -21
  44. package/lib/agent/tools/set_managers.js.map +0 -1
  45. package/lib/agent/tools/update_chat.js +0 -22
  46. package/lib/agent/tools/update_chat.js.map +0 -1
  47. package/lib/agent/tools/upload_file.js +0 -19
  48. package/lib/agent/tools/upload_file.js.map +0 -1
  49. package/lib/src/adapter.js +0 -48
  50. package/lib/src/adapter.js.map +0 -1
  51. package/lib/src/endpoint.js +0 -677
  52. package/lib/src/endpoint.js.map +0 -1
  53. package/lib/src/index.js +0 -43
  54. package/lib/src/index.js.map +0 -1
  55. package/lib/src/lark-agent-deps.js +0 -10
  56. package/lib/src/lark-agent-deps.js.map +0 -1
  57. package/lib/src/platform-permit.js.map +0 -1
  58. package/lib/src/segment-mapper.js +0 -2
  59. package/lib/src/segment-mapper.js.map +0 -1
  60. package/lib/src/types.js +0 -2
  61. package/lib/src/types.js.map +0 -1
  62. package/plugin.yml +0 -3
  63. package/src/adapter.ts +0 -57
  64. package/src/segment-mapper.ts +0 -1
  65. package/src/types.ts +0 -58
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # @zhin.js/adapter-lark
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 7db69c1: 命令前缀改为适配器配置项:`MessageDispatcher` 不再硬编码 `/`,默认按消息所属适配器实例 config 的 `commandPrefix` 解析(默认 `''` 无前缀,任意文本按命令匹配),`endpoints[i].commandPrefix` 逐项覆盖;`ImRuntime({ commandPrefix })` 仍可设全局静态前缀。全部 20 个平台适配器 schema 新增 `commandPrefix` 属性。
8
+
9
+ BREAKING(行为变化):未配置时命令不再需要 `/` 前缀——原 `/zt` 写法不再命中,直接发 `zt` 即可;需要斜杠风格的适配器请在配置里显式设 `commandPrefix: '/'`。
10
+
11
+ - 713445c: 适配器配置格式定稿(不兼容旧格式):`plugins.<adapter>` 顶层仅共享字段 + `commandPrefix`,`endpoints[i]` 携带 endpoint 级字段(`name` + 凭据,各 schema 已类型化),`endpoints` 为必填(icqq 另需顶层 `master`);icqq 新增 `trusted` 列表(顶层/逐项均可)。scaffold-wizard 全部字段式与自定义 configure() 产出改为新格式,examples(full-bot / qq-games-bot)与 20 个适配器 README 同步迁移。
12
+ - Updated dependencies [7db69c1]
13
+ - Updated dependencies [e5c84ed]
14
+ - Updated dependencies [3ea84a0]
15
+ - Updated dependencies [1ddcd70]
16
+ - Updated dependencies [ac9da66]
17
+ - @zhin.js/core@1.4.0
18
+ - @zhin.js/adapter@1.1.0
19
+ - @zhin.js/plugin-runtime@1.1.0
20
+ - @zhin.js/agent@1.0.5
21
+ - @zhin.js/host-http@1.0.2
22
+ - zhin.js@5.0.0
23
+
24
+ ## 4.0.3
25
+
26
+ ### Patch Changes
27
+
28
+ - cc5c94d: 约定式插件运行时迁移(breaking):插件与适配器由 `usePlugin()` / `extends Adapter` 迁移为 `definePlugin` / `defineAdapter` + `plugin.ts` + 约定目录(`adapters/`、`commands/`、`components/`、`tools/` 等)。
29
+
30
+ - 新增约定式运行时包:`@zhin.js/plugin-runtime`、`@zhin.js/adapter`、`@zhin.js/runtime`、`@zhin.js/host-http`(首版 1.0.0 走 init-publish,不在本 changeset 内 bump)。
31
+ - 全部 20 个平台适配器改为约定式 `defineAdapter`,旧 `usePlugin` / `extends Adapter` / `segment-mapper` 生产入口已删除;onebot11 反向 WSS、onebot12 webhook/wss、milky sse/webhook/wss、satori webhook、kook webhook、qq webhook/middleware 等 slice 1 推迟的连接模式已补齐。
32
+ - 游戏 / 工具 / 服务插件同步迁移到约定目录结构。
33
+ - CLI 增加 plugin-runtime host installer(http/database/outbound/schedule/console 等)。
34
+
35
+ 后续加固(同批):
36
+
37
+ - CLI:`zhin runtime start --daemon`(pidfile/崩溃拉起/风暴保护),orphan watchdog 防僵尸进程;legacy `zhin dev` / `zhin start` 已移除(含 `zhin restart`),`zhin stop` 兼容新 daemon。
38
+ - 安全:builtin 工具统一走 `security/policy-facade.ts` 的 `runToolPolicies`(声明式策略表,deny 优先);审计日志 close flush + 背压队列;`splitCompoundCommand` 引号感知、`extractCommandName` 去引号堵绕过。
39
+ - 日志:Logger 双堆栈修复、本地时区、`getLogger` 挂树(`setLevel` 递归生效)、第三方库(log4js/discord)桥接、启动人读总结。
40
+ - 结构:`plugins/games/shared` 迁为 `packages/game-kit`(`@zhin.js/game-kit`);死目录 `plugins/adapters/common` 删除。
41
+ - 脚手架:`create-zhin-app` / `zhin new` / scaffold-wizard 生成物改为 Plugin Runtime 形态(minimal-bot 同构,新配置格式)。
42
+ - Console:endpoint.list 真实名称与 phase、schema:get-all 按 instanceKey 映射、db:\* 接 DatabaseHost。
43
+
44
+ 注:按仓库发布惯例(见 1bb345dd2),本次 breaking 迁移统一使用 patch,避免 zhin.js 5.0 级联。
45
+
46
+ - Updated dependencies [16ec4e8]
47
+ - Updated dependencies [cc5c94d]
48
+ - Updated dependencies [447f3e2]
49
+ - @zhin.js/core@1.3.5
50
+ - @zhin.js/agent@1.0.4
51
+ - @zhin.js/host-http@1.0.1
52
+ - zhin.js@4.1.3
53
+ - @zhin.js/logger@1.0.75
54
+ - @zhin.js/plugin-runtime@1.0.1
55
+ - @zhin.js/adapter@1.0.1
56
+
3
57
  ## 4.0.2
4
58
 
5
59
  ### Patch Changes
package/README.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # @zhin.js/adapter-lark
2
2
 
3
- Zhin.js 飞书 / Lark 适配器,支持飞书机器人的消息收发和群管理。
3
+ Zhin.js 飞书 / Lark 适配器(Plugin Runtime),通过 Runtime Host HTTP Webhook 收发消息。
4
4
 
5
- ## 功能特性
5
+ ## 功能
6
6
 
7
- - 支持飞书和 Lark 国际版
8
- - Webhook 事件接收(HTTP 回调)
9
- - Bearer Token 自动刷新
10
- - 消息加密和签名验证(可选)
11
- - URL 验证自动处理
12
- - 群管理 AI 工具(`agent/tools/` 平台工具 + `agent/skills/lark.md`;群管标准工具由 `createSceneManagementTools` 注册)
7
+ - Webhook 事件接收(`httpHostToken` POST + 可选 verificationToken / encryptKey 签名)
8
+ - URL 验证挑战(`url_verification`)
9
+ - Tenant Access Token 自动刷新
10
+ - 支持飞书与 Lark 国际版 API 基址
11
+ - 约定式 `defineAdapter` / `definePlugin`(无需 `usePlugin`)
13
12
 
14
13
  ## 安装
15
14
 
@@ -17,103 +16,76 @@ Zhin.js 飞书 / Lark 适配器,支持飞书机器人的消息收发和群管
17
16
  pnpm add @zhin.js/adapter-lark
18
17
  ```
19
18
 
20
- ## 依赖
19
+ ## Plugin Runtime
21
20
 
22
- - `@zhin.js/host-router` — HTTP 服务(提供 Webhook 路由)
21
+ - `@zhin.js/adapter` — 约定式 `adapters/lark.ts`(`defineAdapter`)
22
+ - `@zhin.js/core` — `messageGatewayToken` 入站/出站
23
+ - `@zhin.js/host-http` — `httpHostToken` 注册 Webhook 路由(**非** legacy host-router/Koa)
24
+ - `@zhin.js/plugin-runtime` — `plugin.ts`(`definePlugin`)
25
+ - 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`
23
26
 
24
- ## 配置
27
+ 入站:`gateway.receive({ adapter, target: chat_id, content: text, sender, metadata })`
28
+ 出站:`send({ target, payload })` → `im/v1/messages`
25
29
 
26
- ```yaml
27
- # zhin.config.yml
28
- endpoints:
29
- - context: lark
30
- name: my-lark-bot
31
- appId: cli_xxxxxxxxxxxx
32
- appSecret: xxxxxxxxxxxxxxxxxxxxxxxx
33
- webhookPath: /lark/webhook
34
- # 可选配置
35
- # encryptKey: your-encrypt-key
36
- # verificationToken: your-token
37
- # isFeishu: true # 使用飞书 API(默认)
38
- # apiBaseUrl: https://open.feishu.cn/open-apis # 自定义 API 地址
30
+ 入站 `metadata.mentioned`:**未接线**。消息事件的 `mentions[]` 元素含 `id.open_id`,但本适配器拿不到 bot 自身的 open_id——配置(`appId` / `appSecret` / `name` 等)不含 bot open_id,代码也未调用 `bot/v3/info` 获取应用信息,故无可靠判据比对 mentions。
39
31
 
40
- plugins:
41
- - "@zhin.js/adapter-lark"
42
- - "@zhin.js/host-router"
43
- ```
32
+ ## 前置条件
44
33
 
45
- 或使用 TypeScript 配置:
46
-
47
- ```typescript
48
- import { defineConfig } from 'zhin.js'
49
-
50
- export default defineConfig({
51
- endpoints: [
52
- {
53
- context: 'lark',
54
- name: 'my-lark-bot',
55
- appId: process.env.LARK_APP_ID!,
56
- appSecret: process.env.LARK_APP_SECRET!,
57
- webhookPath: '/lark/webhook',
58
- }
59
- ],
60
- plugins: ['@zhin.js/adapter-lark', '@zhin.js/host-router']
61
- })
62
- ```
34
+ 1. 在 [飞书开放平台](https://open.feishu.cn/)(或 Lark)创建企业自建应用
35
+ 2. 获取 **App ID**、**App Secret**
36
+ 3. 启用机器人能力并配置事件订阅 URL:`https://your-domain/lark/webhook`
37
+ 4. Runtime Host(`http`)须已 listen,Webhook 才可达
63
38
 
64
- ## 使用示例
39
+ 必填字段(`endpoints[i]`):`name`、`appId`、`appSecret`。
65
40
 
66
- ### 注册命令
41
+ ## 最小配置
67
42
 
68
- ```typescript
69
- import { usePlugin, MessageCommand } from 'zhin.js'
70
-
71
- const { addCommand } = usePlugin()
72
-
73
- addCommand(
74
- new MessageCommand('hello')
75
- .desc('飞书问候')
76
- .action((message) => {
77
- return `你好,${message.$sender.name}!`
78
- })
79
- )
43
+ ```yaml
44
+ # zhin.config.yml(Plugin Runtime)
45
+ plugins:
46
+ lark:
47
+ webhookPath: /lark/webhook # 可选,默认 /lark/webhook
48
+ isFeishu: true # 可选,默认 true
49
+ # apiBaseUrl: https://open.feishu.cn/open-apis
50
+ endpoints:
51
+ - name: my-lark-bot
52
+ appId: ${LARK_APP_ID}
53
+ appSecret: ${LARK_APP_SECRET}
54
+ # encryptKey: ${LARK_ENCRYPT_KEY} # 可选
55
+ # verificationToken: ${LARK_VERIFY_TOKEN} # 可选
80
56
  ```
81
57
 
82
- ### 消息处理
58
+ 根插件 `zhin.plugins`(或项目图)需引用 `@zhin.js/adapter-lark`(`instanceKey: lark`)。
83
59
 
84
- ```typescript
85
- import { usePlugin } from 'zhin.js'
60
+ ## 环境变量
86
61
 
87
- const { root } = usePlugin()
62
+ | 变量 | 说明 |
63
+ |------|------|
64
+ | `LARK_APP_ID` | 应用 App ID |
65
+ | `LARK_APP_SECRET` | 应用 App Secret |
66
+ | `LARK_BOT_NAME` | 默认 endpoint 名称(可选) |
88
67
 
89
- root.addMiddleware(async (message, next) => {
90
- if (message.$adapter === 'lark') {
91
- console.log('收到飞书消息:', message.$content)
92
- }
93
- await next()
94
- })
95
- ```
68
+ ## 消息类型映射
96
69
 
97
- ## AI 工具(Skill)
70
+ | 飞书类型 | 入站 content(文本摘要) | 出站 wire |
71
+ |----------|--------------------------|-----------|
72
+ | text | 原文 | text |
73
+ | image | `[image]` | image(需 `file_key`) |
74
+ | file | `[file: name]` | file |
75
+ | audio / video / sticker | `[audio]` / `[video]` / `[sticker]` | — |
76
+ | card | — | interactive |
98
77
 
99
- | 类别 | 路径 |
100
- |------|------|
101
- | Permit 词汇 | `agent/PERMITS.md` |
102
- | 平台工具(8 个) | `agent/tools/`(`lark_*`:群聊、成员、文件等) |
103
- | 技能说明 | `agent/skills/lark.md` |
104
- | 群管标准工具 | `createSceneManagementTools()` |
78
+ ## Agent 工具
105
79
 
80
+ `agent/` 目录保留(get_user、群聊、管理员、上传文件等)。Endpoint 在 `start` 时自注册到 `lark-agent-deps`。
106
81
 
107
- > 工具使用飞书的 `open_id` 和 `chat_id` 格式标识用户和群聊。
82
+ ## 平台权限(platform permit)
108
83
 
109
- ## 飞书开发者配置
84
+ `plugin.ts` 在 generation setup 注册 `src/platform-permit.ts` checker,并在 dispose 注销;CapabilityIngress 与 ToolSystem 统一经 Core `canAccessTool()` 消费工具权限。
110
85
 
111
- 1. 登录 [飞书开放平台](https://open.feishu.cn/)
112
- 2. 创建应用并获取 `App ID` 和 `App Secret`
113
- 3. 配置事件回调 URL:`http://your-server:8086/api/lark/webhook`
114
- 4. 订阅 `im.message.receive_v1` 事件
115
- 5. 发布应用
86
+ ## 测试
116
87
 
117
- ## 许可证
118
-
119
- MIT License
88
+ ```bash
89
+ pnpm --filter @zhin.js/adapter-lark build
90
+ pnpm --filter @zhin.js/adapter-lark test
91
+ ```
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Convention entry: discover `adapters/lark.ts` → defineAdapter.
3
+ */
4
+ import { defineAdapter } from '@zhin.js/adapter';
5
+ import { messageGatewayToken } from '@zhin.js/core/runtime';
6
+ import { httpHostToken } from '@zhin.js/host-http';
7
+ import { LarkEndpoint } from '../src/endpoint.js';
8
+ import {
9
+ resolveLarkConfig,
10
+ type LarkAdapterConfig,
11
+ } from '../src/protocol.js';
12
+
13
+ export { LarkEndpoint } from '../src/endpoint.js';
14
+ export type { LarkEndpointOptions, LarkFetch } from '../src/endpoint.js';
15
+
16
+ export default defineAdapter<LarkAdapterConfig>({
17
+ capabilities: ['inbound', 'outbound'],
18
+ create(context) {
19
+ return new LarkEndpoint({
20
+ id: context.id,
21
+ gateway: context.use(messageGatewayToken),
22
+ http: context.use(httpHostToken),
23
+ config: resolveLarkConfig(context.config),
24
+ });
25
+ },
26
+ });
@@ -1,9 +1,9 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { getLarkAgentDeps } from '../../src/lark-agent-deps.js';
4
4
  import { platformPermit } from '../../src/platform-permit.js';
5
5
 
6
- export default defineTool<{ endpoint_id: string; chat_id: string; user_ids: string }>({
6
+ export default defineAgentTool<{ endpoint_id: string; chat_id: string; user_ids: string }>({
7
7
  description: '添加飞书群成员',
8
8
  inputSchema: z.object({
9
9
  endpoint_id: z.string().describe('Endpoint 名称'),
@@ -1,7 +1,7 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { getLarkAgentDeps } from '../../src/lark-agent-deps.js';
4
- export default defineTool<{ endpoint_id: string; name: string; members: string; owner?: string }>({
4
+ export default defineAgentTool<{ endpoint_id: string; name: string; members: string; owner?: string }>({
5
5
  description: '创建飞书群聊',
6
6
  inputSchema: z.object({
7
7
  endpoint_id: z.string().describe('Endpoint 名称'),
@@ -1,7 +1,7 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { getLarkAgentDeps } from '../../src/lark-agent-deps.js';
4
- export default defineTool<{ endpoint_id: string; chat_id: string }>({
4
+ export default defineAgentTool<{ endpoint_id: string; chat_id: string }>({
5
5
  description: '解散飞书群聊(需要群主权限)',
6
6
  inputSchema: z.object({
7
7
  endpoint_id: z.string().describe('Endpoint 名称'),
@@ -1,8 +1,8 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { getLarkAgentDeps } from '../../src/lark-agent-deps.js';
4
4
 
5
- export default defineTool<{ endpoint_id: string; user_id: string }>({
5
+ export default defineAgentTool<{ endpoint_id: string; user_id: string }>({
6
6
  description: '获取飞书用户信息',
7
7
  inputSchema: z.object({
8
8
  endpoint_id: z.string().describe('Endpoint 名称'),
@@ -1,9 +1,9 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { getLarkAgentDeps } from '../../src/lark-agent-deps.js';
4
4
  import { platformPermit } from '../../src/platform-permit.js';
5
5
 
6
- export default defineTool<{ endpoint_id: string; chat_id: string; user_ids: string }>({
6
+ export default defineAgentTool<{ endpoint_id: string; chat_id: string; user_ids: string }>({
7
7
  description: '移除飞书群管理员',
8
8
  inputSchema: z.object({
9
9
  endpoint_id: z.string().describe('Endpoint 名称'),
@@ -1,9 +1,9 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { getLarkAgentDeps } from '../../src/lark-agent-deps.js';
4
4
  import { platformPermit } from '../../src/platform-permit.js';
5
5
 
6
- export default defineTool<{ endpoint_id: string; chat_id: string; user_ids: string }>({
6
+ export default defineAgentTool<{ endpoint_id: string; chat_id: string; user_ids: string }>({
7
7
  description: '设置飞书群管理员',
8
8
  inputSchema: z.object({
9
9
  endpoint_id: z.string().describe('Endpoint 名称'),
@@ -1,9 +1,9 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { getLarkAgentDeps } from '../../src/lark-agent-deps.js';
4
4
  import { platformPermit } from '../../src/platform-permit.js';
5
5
 
6
- export default defineTool<{ endpoint_id: string; chat_id: string; name?: string; description?: string }>({
6
+ export default defineAgentTool<{ endpoint_id: string; chat_id: string; name?: string; description?: string }>({
7
7
  description: '更新飞书群聊信息(群名、描述)',
8
8
  inputSchema: z.object({
9
9
  endpoint_id: z.string().describe('Endpoint 名称'),
@@ -1,8 +1,8 @@
1
- import { defineTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/agent/tools';
2
2
  import { z } from 'zod';
3
3
  import { getLarkAgentDeps } from '../../src/lark-agent-deps.js';
4
4
 
5
- export default defineTool<{
5
+ export default defineAgentTool<{
6
6
  endpoint_id: string;
7
7
  file_path: string;
8
8
  file_type: 'image' | 'file' | 'video' | 'audio';
@@ -0,0 +1,53 @@
1
+ import type { EndpointInstance } from '@zhin.js/adapter';
2
+ import type { MessageGateway } from '@zhin.js/core/runtime';
3
+ import type { HttpHost } from '@zhin.js/host-http';
4
+ import type { CapabilityId } from '@zhin.js/plugin-runtime';
5
+ import { type LarkMessage, type ResolvedLarkConfig } from './protocol.js';
6
+ export type LarkFetch = (url: string, init?: {
7
+ readonly method?: string;
8
+ readonly headers?: Record<string, string>;
9
+ readonly body?: string | FormData;
10
+ }) => Promise<{
11
+ readonly ok: boolean;
12
+ readonly status: number;
13
+ text(): Promise<string>;
14
+ json(): Promise<unknown>;
15
+ }>;
16
+ export interface LarkEndpointOptions {
17
+ readonly id: CapabilityId;
18
+ readonly gateway: MessageGateway;
19
+ readonly http: HttpHost;
20
+ readonly config: ResolvedLarkConfig;
21
+ readonly fetch?: LarkFetch;
22
+ }
23
+ export declare class LarkEndpoint implements EndpointInstance {
24
+ #private;
25
+ constructor(options: LarkEndpointOptions);
26
+ /** Used by webhook handler. */
27
+ get isOpen(): boolean;
28
+ get config(): ResolvedLarkConfig;
29
+ start(): Promise<void>;
30
+ open(): void;
31
+ close(): void;
32
+ stop(): Promise<void>;
33
+ send({ target, payload }: {
34
+ readonly target: string;
35
+ readonly payload: unknown;
36
+ }): Promise<string>;
37
+ /** Test / internal: admit a parsed message when open (non-webhook path). */
38
+ admit(msg: LarkMessage): void;
39
+ getUserInfo(userId: string, userIdType?: 'open_id' | 'user_id' | 'union_id'): Promise<unknown>;
40
+ getChatInfo(chatId: string): Promise<unknown>;
41
+ uploadFile(filePath: string, fileType?: 'image' | 'file' | 'video' | 'audio'): Promise<string | null>;
42
+ createChat(name: string, userIds: string[], ownerId?: string): Promise<string | null>;
43
+ updateChatInfo(chatId: string, options: {
44
+ name?: string;
45
+ description?: string;
46
+ }): Promise<boolean>;
47
+ addChatMembers(chatId: string, userIds: string[]): Promise<boolean>;
48
+ removeChatMembers(chatId: string, userIds: string[]): Promise<boolean>;
49
+ getChatMembers(chatId: string): Promise<unknown[]>;
50
+ dissolveChat(chatId: string): Promise<boolean>;
51
+ setChatManagers(chatId: string, userIds: string[]): Promise<boolean>;
52
+ removeChatManagers(chatId: string, userIds: string[]): Promise<boolean>;
53
+ }