@zhin.js/adapter-dingtalk 6.0.13 → 7.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.
- package/CHANGELOG.md +52 -0
- package/README.md +1 -0
- package/adapters/dingtalk.js +5 -2
- package/adapters/dingtalk.ts +5 -2
- package/lib/endpoint.d.ts +2 -1
- package/lib/protocol.js +10 -9
- package/package.json +14 -14
- package/src/endpoint.ts +2 -1
- package/src/protocol.ts +10 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @zhin.js/adapter-dingtalk
|
|
2
2
|
|
|
3
|
+
## 7.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [b10d058]
|
|
8
|
+
- Updated dependencies [f2c532f]
|
|
9
|
+
- Updated dependencies [3dbf990]
|
|
10
|
+
- @zhin.js/host-http@1.0.12
|
|
11
|
+
- @zhin.js/adapter@1.2.0
|
|
12
|
+
- @zhin.js/core@1.5.13
|
|
13
|
+
- @zhin.js/agent@1.1.15
|
|
14
|
+
- zhin.js@6.0.13
|
|
15
|
+
|
|
16
|
+
## 6.0.14
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 974772e: Replace the user-facing `Prompt` vocabulary with the `UserInteraction` authoring surface for input, confirmation, and selection. Commands and handlers now expose `interaction`; IM Runtime exposes `createInteraction`; schema-driven endpoint collection is named `SchemaInteraction`. The old prompt-named interaction types and properties are removed rather than aliased. User interactions render through one canonical Markdown and keyboard/list presentation module shared by commands and Agent `ask_user` turns.
|
|
21
|
+
|
|
22
|
+
Extract the transport-neutral interaction contract into `@zhin.js/interaction`. A discriminated `ask()` API supports text, number, confirmation, single-select, multi-select, and typed lists with structured `title`, `description`, and `tip` content. Typed `sequence()` interactions return one result object keyed by step id, render progress, and retry invalid replies without leaking invalid values to callers.
|
|
23
|
+
|
|
24
|
+
Preserve AI Markdown and card command actions through outbound publishing. QQ delivers Markdown with native command buttons; KOOK, Discord, Telegram, DingTalk, and Lark/Feishu now declare and encode their native Markdown dialects while retaining each adapter's interaction policy. Correct QQ callback button action encoding and button style mapping.
|
|
25
|
+
|
|
26
|
+
- 5969c5b: Add SideEventGateway so adapters forward notice/request/system into HandlerIndex. HandlerContext now exposes only generation-safe capabilities and prompt ports; live Endpoint escape hatches are removed.
|
|
27
|
+
- Updated dependencies [5969c5b]
|
|
28
|
+
- Updated dependencies [d336a3f]
|
|
29
|
+
- Updated dependencies [0c82a7e]
|
|
30
|
+
- Updated dependencies [b9217e4]
|
|
31
|
+
- Updated dependencies [5969c5b]
|
|
32
|
+
- Updated dependencies [5969c5b]
|
|
33
|
+
- Updated dependencies [974772e]
|
|
34
|
+
- Updated dependencies [5969c5b]
|
|
35
|
+
- Updated dependencies [5969c5b]
|
|
36
|
+
- Updated dependencies [2f786bd]
|
|
37
|
+
- Updated dependencies [63d89f9]
|
|
38
|
+
- Updated dependencies [71c7cdd]
|
|
39
|
+
- Updated dependencies [3cca0ea]
|
|
40
|
+
- Updated dependencies [1312ca0]
|
|
41
|
+
- Updated dependencies [985fa22]
|
|
42
|
+
- Updated dependencies [04b861d]
|
|
43
|
+
- Updated dependencies [a23d544]
|
|
44
|
+
- Updated dependencies [8cddabf]
|
|
45
|
+
- Updated dependencies [dbe5081]
|
|
46
|
+
- @zhin.js/im-contract@1.0.4
|
|
47
|
+
- @zhin.js/core@1.5.12
|
|
48
|
+
- @zhin.js/adapter@1.1.11
|
|
49
|
+
- @zhin.js/agent@1.1.14
|
|
50
|
+
- @zhin.js/host-http@1.0.11
|
|
51
|
+
- @zhin.js/command@1.0.15
|
|
52
|
+
- zhin.js@6.0.12
|
|
53
|
+
- @zhin.js/permission@1.0.3
|
|
54
|
+
|
|
3
55
|
## 6.0.13
|
|
4
56
|
|
|
5
57
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ Zhin.js 钉钉适配器(Plugin Runtime),通过 Runtime Host HTTP Webhook
|
|
|
7
7
|
- Webhook 事件接收(`httpHostToken` POST + HMAC-SHA256 签名验证)
|
|
8
8
|
- Access Token 自动刷新
|
|
9
9
|
- Session Webhook 优先回复 / `/robot/send` 主动发送
|
|
10
|
+
- canonical `markdown` 段编码为钉钉原生 `msgtype: markdown`
|
|
10
11
|
- 约定式 `defineAdapter` / `definePlugin`(无需 `usePlugin`)
|
|
11
12
|
|
|
12
13
|
## 安装
|
package/adapters/dingtalk.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Convention entry: discover `adapters/dingtalk.ts` → defineAdapter.
|
|
4
4
|
*/
|
|
5
5
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
6
|
-
import { messageGatewayToken } from '@zhin.js/core/runtime';
|
|
6
|
+
import { messageGatewayToken, sideEventGatewayToken } from '@zhin.js/core/runtime';
|
|
7
7
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
8
8
|
import { DingTalkEndpoint } from "../lib/endpoint.js";
|
|
9
9
|
import { resolveDingTalkConfig, } from "../lib/protocol.js";
|
|
@@ -11,10 +11,12 @@ import { dingtalkRuntimeStateToken } from "../lib/dingtalk-runtime-state.js";
|
|
|
11
11
|
export { DingTalkEndpoint } from "../lib/endpoint.js";
|
|
12
12
|
export default defineAdapter({
|
|
13
13
|
capabilities: ['inbound', 'outbound'],
|
|
14
|
-
// 钉钉机器人媒体消息仅消费远程 URL
|
|
14
|
+
// 钉钉机器人媒体消息仅消费远程 URL;Markdown 走原生 msgtype;
|
|
15
|
+
// 无按钮交互面,交互段降级纯文本。
|
|
15
16
|
segments: {
|
|
16
17
|
outboundMedia: ['url'],
|
|
17
18
|
interactive: 'text',
|
|
19
|
+
markdown: 'native',
|
|
18
20
|
},
|
|
19
21
|
create(context) {
|
|
20
22
|
const config = resolveDingTalkConfig(context.config);
|
|
@@ -26,6 +28,7 @@ export default defineAdapter({
|
|
|
26
28
|
return new DingTalkEndpoint({
|
|
27
29
|
id: context.id,
|
|
28
30
|
gateway: context.use(messageGatewayToken),
|
|
31
|
+
sideEvents: context.use(sideEventGatewayToken),
|
|
29
32
|
http: context.use(httpHostToken),
|
|
30
33
|
config,
|
|
31
34
|
});
|
package/adapters/dingtalk.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Convention entry: discover `adapters/dingtalk.ts` → defineAdapter.
|
|
3
3
|
*/
|
|
4
4
|
import { defineAdapter } from 'zhin.js/adapter';
|
|
5
|
-
import { messageGatewayToken } from '@zhin.js/core/runtime';
|
|
5
|
+
import { messageGatewayToken, sideEventGatewayToken } from '@zhin.js/core/runtime';
|
|
6
6
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
7
7
|
import { DingTalkEndpoint } from '../src/endpoint.js';
|
|
8
8
|
import {
|
|
@@ -16,10 +16,12 @@ export type { DingTalkEndpointOptions, DingTalkFetch } from '../src/endpoint.js'
|
|
|
16
16
|
|
|
17
17
|
export default defineAdapter<DingTalkAdapterConfig>({
|
|
18
18
|
capabilities: ['inbound', 'outbound'],
|
|
19
|
-
// 钉钉机器人媒体消息仅消费远程 URL
|
|
19
|
+
// 钉钉机器人媒体消息仅消费远程 URL;Markdown 走原生 msgtype;
|
|
20
|
+
// 无按钮交互面,交互段降级纯文本。
|
|
20
21
|
segments: {
|
|
21
22
|
outboundMedia: ['url'],
|
|
22
23
|
interactive: 'text',
|
|
24
|
+
markdown: 'native',
|
|
23
25
|
},
|
|
24
26
|
create(context) {
|
|
25
27
|
const config = resolveDingTalkConfig(context.config);
|
|
@@ -31,6 +33,7 @@ export default defineAdapter<DingTalkAdapterConfig>({
|
|
|
31
33
|
return new DingTalkEndpoint({
|
|
32
34
|
id: context.id,
|
|
33
35
|
gateway: context.use(messageGatewayToken),
|
|
36
|
+
sideEvents: context.use(sideEventGatewayToken),
|
|
34
37
|
http: context.use(httpHostToken),
|
|
35
38
|
config,
|
|
36
39
|
});
|
package/lib/endpoint.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* DingTalkEndpoint — lifecycle, outbound, admit, OpenAPI helpers for agent tools.
|
|
3
3
|
*/
|
|
4
4
|
import type { EndpointInstance, EndpointSendRequest } from 'zhin.js/adapter';
|
|
5
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
5
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
6
6
|
import type { HttpHost } from '@zhin.js/host-http';
|
|
7
7
|
import type { CapabilityId } from 'zhin.js';
|
|
8
8
|
import { type DingTalkEvent, type DingTalkMessage, type ResolvedDingTalkConfig } from './protocol.js';
|
|
@@ -19,6 +19,7 @@ export type DingTalkFetch = (url: string, init?: {
|
|
|
19
19
|
export interface DingTalkEndpointOptions {
|
|
20
20
|
readonly id: CapabilityId;
|
|
21
21
|
readonly gateway: MessageGateway;
|
|
22
|
+
readonly sideEvents?: SideEventGateway;
|
|
22
23
|
readonly http: HttpHost;
|
|
23
24
|
readonly config: ResolvedDingTalkConfig;
|
|
24
25
|
readonly fetch?: DingTalkFetch;
|
package/lib/protocol.js
CHANGED
|
@@ -156,6 +156,7 @@ export function formatOutboundBody(payload) {
|
|
|
156
156
|
const textParts = [];
|
|
157
157
|
const atUserIds = [];
|
|
158
158
|
let media = null;
|
|
159
|
+
let markdownTitle;
|
|
159
160
|
for (const item of items) {
|
|
160
161
|
if (typeof item === 'string') {
|
|
161
162
|
textParts.push(item);
|
|
@@ -203,15 +204,8 @@ export function formatOutboundBody(payload) {
|
|
|
203
204
|
}));
|
|
204
205
|
break;
|
|
205
206
|
case 'markdown':
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
msgtype: 'markdown',
|
|
209
|
-
markdown: {
|
|
210
|
-
title: String(data.title || '消息'),
|
|
211
|
-
text: String(data.content ?? data.text ?? ''),
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
}
|
|
207
|
+
markdownTitle ??= String(data.title || '消息');
|
|
208
|
+
textParts.push(String(data.content ?? data.text ?? ''));
|
|
215
209
|
break;
|
|
216
210
|
case 'link':
|
|
217
211
|
if (!media) {
|
|
@@ -232,6 +226,13 @@ export function formatOutboundBody(payload) {
|
|
|
232
226
|
}
|
|
233
227
|
if (media)
|
|
234
228
|
return media;
|
|
229
|
+
if (markdownTitle !== undefined) {
|
|
230
|
+
return {
|
|
231
|
+
msgtype: 'markdown',
|
|
232
|
+
markdown: { title: markdownTitle, text: textParts.join('') },
|
|
233
|
+
...(atUserIds.length > 0 ? { at: { atUserIds, isAtAll: false } } : {}),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
235
236
|
const result = {
|
|
236
237
|
msgtype: 'text',
|
|
237
238
|
text: { content: textParts.join('') },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-dingtalk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Zhin.js DingTalk (钉钉) adapter for Plugin Runtime (HTTP webhook)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -33,21 +33,21 @@
|
|
|
33
33
|
"directory": "plugins/adapters/dingtalk"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@zhin.js/adapter": "1.
|
|
37
|
-
"@zhin.js/core": "1.5.
|
|
38
|
-
"@zhin.js/host-http": "1.0.
|
|
39
|
-
"@zhin.js/im-contract": "1.0.
|
|
36
|
+
"@zhin.js/adapter": "1.2.0",
|
|
37
|
+
"@zhin.js/core": "1.5.13",
|
|
38
|
+
"@zhin.js/host-http": "1.0.12",
|
|
39
|
+
"@zhin.js/im-contract": "1.0.4",
|
|
40
40
|
"@zhin.js/logger": "1.0.76"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"zod": "^4.0.0",
|
|
44
|
-
"@zhin.js/adapter": "1.
|
|
45
|
-
"@zhin.js/agent": "1.1.
|
|
46
|
-
"@zhin.js/command": "1.0.
|
|
47
|
-
"@zhin.js/core": "1.5.
|
|
48
|
-
"@zhin.js/host-http": "1.0.
|
|
49
|
-
"@zhin.js/permission": "1.0.
|
|
50
|
-
"zhin.js": "6.0.
|
|
44
|
+
"@zhin.js/adapter": "1.2.0",
|
|
45
|
+
"@zhin.js/agent": "1.1.15",
|
|
46
|
+
"@zhin.js/command": "1.0.15",
|
|
47
|
+
"@zhin.js/core": "1.5.13",
|
|
48
|
+
"@zhin.js/host-http": "1.0.12",
|
|
49
|
+
"@zhin.js/permission": "1.0.3",
|
|
50
|
+
"zhin.js": "6.0.13"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"@zhin.js/agent": {
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
69
|
"vitest": "^4.1.10",
|
|
70
70
|
"zod": "^4.4.3",
|
|
71
|
-
"@zhin.js/agent": "1.1.
|
|
72
|
-
"zhin.js": "6.0.
|
|
71
|
+
"@zhin.js/agent": "1.1.15",
|
|
72
|
+
"zhin.js": "6.0.13"
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
"adapters",
|
package/src/endpoint.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* DingTalkEndpoint — lifecycle, outbound, admit, OpenAPI helpers for agent tools.
|
|
3
3
|
*/
|
|
4
4
|
import type { EndpointInstance, EndpointSendRequest } from 'zhin.js/adapter';
|
|
5
|
-
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
5
|
+
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
6
6
|
import type { HttpHost, HttpRouteRegistration } from '@zhin.js/host-http';
|
|
7
7
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
8
8
|
import type { CapabilityId } from 'zhin.js';
|
|
@@ -42,6 +42,7 @@ export type DingTalkFetch = (
|
|
|
42
42
|
export interface DingTalkEndpointOptions {
|
|
43
43
|
readonly id: CapabilityId;
|
|
44
44
|
readonly gateway: MessageGateway;
|
|
45
|
+
readonly sideEvents?: SideEventGateway;
|
|
45
46
|
readonly http: HttpHost;
|
|
46
47
|
readonly config: ResolvedDingTalkConfig;
|
|
47
48
|
readonly fetch?: DingTalkFetch;
|
package/src/protocol.ts
CHANGED
|
@@ -268,6 +268,7 @@ export function formatOutboundBody(payload: unknown): DingTalkSendBody {
|
|
|
268
268
|
const textParts: string[] = [];
|
|
269
269
|
const atUserIds: string[] = [];
|
|
270
270
|
let media: DingTalkSendBody | null = null;
|
|
271
|
+
let markdownTitle: string | undefined;
|
|
271
272
|
|
|
272
273
|
for (const item of items) {
|
|
273
274
|
if (typeof item === 'string') {
|
|
@@ -315,15 +316,8 @@ export function formatOutboundBody(payload: unknown): DingTalkSendBody {
|
|
|
315
316
|
}));
|
|
316
317
|
break;
|
|
317
318
|
case 'markdown':
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
msgtype: 'markdown',
|
|
321
|
-
markdown: {
|
|
322
|
-
title: String(data.title || '消息'),
|
|
323
|
-
text: String(data.content ?? data.text ?? ''),
|
|
324
|
-
},
|
|
325
|
-
};
|
|
326
|
-
}
|
|
319
|
+
markdownTitle ??= String(data.title || '消息');
|
|
320
|
+
textParts.push(String(data.content ?? data.text ?? ''));
|
|
327
321
|
break;
|
|
328
322
|
case 'link':
|
|
329
323
|
if (!media) {
|
|
@@ -344,6 +338,13 @@ export function formatOutboundBody(payload: unknown): DingTalkSendBody {
|
|
|
344
338
|
}
|
|
345
339
|
|
|
346
340
|
if (media) return media;
|
|
341
|
+
if (markdownTitle !== undefined) {
|
|
342
|
+
return {
|
|
343
|
+
msgtype: 'markdown',
|
|
344
|
+
markdown: { title: markdownTitle, text: textParts.join('') },
|
|
345
|
+
...(atUserIds.length > 0 ? { at: { atUserIds, isAtAll: false } } : {}),
|
|
346
|
+
};
|
|
347
|
+
}
|
|
347
348
|
|
|
348
349
|
const result: DingTalkSendBody = {
|
|
349
350
|
msgtype: 'text',
|