@zhin.js/adapter-discord 1.1.21 → 1.1.23
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 +67 -0
- package/adapters/discord/index.js +20 -4
- package/adapters/discord/index.ts +20 -4
- package/lib/endpoint.js +1 -0
- package/lib/gateway.js +12 -7
- package/lib/protocol.d.ts +2 -1
- package/lib/protocol.js +19 -7
- package/package.json +18 -18
- package/plugin.js +1 -0
- package/src/endpoint.ts +1 -0
- package/src/gateway.ts +8 -4
- package/src/protocol.ts +23 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# @zhin.js/adapter-discord
|
|
2
2
|
|
|
3
|
+
## 1.1.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bc6ccb1: Deep audit bug fixes and 7 architectural improvements:
|
|
8
|
+
- Sink Agent Turn ingress pipeline from `@zhin.js/cli` into `@zhin.js/agent/runtime` (`plugin-runtime/ingress/`) and decompose `ingress-route.ts` into modular pipeline stages.
|
|
9
|
+
- Bind Session State Plane (`JsxButtonRegistry`, `InteractionRuntime`, `RuntimeInteractiveRouter`) to `PluginIncarnationRef` so active buttons and interactions survive unrelated-plugin HMR while expiring when the owning plugin reloads, and support per-conversation fallback numbering (`numberingScope: 'conversation'`).
|
|
10
|
+
- Establish `conversation_events` as the canonical message SSOT and reference `conversation_event_id`, `conversation_key`, `platform_message_id`, and `message_key` in `agent_messages` (`AGENT_MESSAGE_QUERY_VERSION = 2`), threading `conversationSequence` across inbound and outbound delivery receipts.
|
|
11
|
+
- Push down `DatabaseContextRepository` and `DatabaseScheduleJobStorage` full-session/full-table memory scans to indexed SQL queries.
|
|
12
|
+
- Add kernel-level inbound `replyTo` and `mentioned` auto-promotion (`promoteInboundMessagePayload`) plus reusable `InboundDeduper` and `TtlLookupCache` primitives in `@zhin.js/adapter`.
|
|
13
|
+
- Add `MiddlewareContext.dispatch` (`InboundDispatchSummary`) and `onAfterDispatch` hooks for `after-dispatch` middlewares, and support incremental rendering of in-place `envelope.payload` array mutations in `OutboundDeliveryRuntime`.
|
|
14
|
+
- Unify `HistoryWindowTracker` and `AgentCompactionRuntime` token/message budgets (`resolveUnifiedHistoryAndCompactionBudget`).
|
|
15
|
+
- Fix schema validation, database transaction connection cleanup and SQLite WAL mode, schedule timer wheel head-of-line blocking, security policy bash read paths and subagent guard propagation, group merge window permission carrier handoff, micro-compact namespaced tool matching, and WebSocket force-close / inbound segment mapping across adapters.
|
|
16
|
+
- Updated dependencies [3a8504b]
|
|
17
|
+
- Updated dependencies [6163abc]
|
|
18
|
+
- Updated dependencies [fed2c27]
|
|
19
|
+
- Updated dependencies [bc6ccb1]
|
|
20
|
+
- Updated dependencies [72b5a12]
|
|
21
|
+
- Updated dependencies [aa41889]
|
|
22
|
+
- Updated dependencies [4427e72]
|
|
23
|
+
- Updated dependencies [22bd14a]
|
|
24
|
+
- @zhin.js/agent-feature@1.1.14
|
|
25
|
+
- @zhin.js/core@1.1.57
|
|
26
|
+
- @zhin.js/client@1.1.25
|
|
27
|
+
- @zhin.js/page@1.1.15
|
|
28
|
+
- @zhin.js/im-contract@1.1.12
|
|
29
|
+
- @zhin.js/adapter@1.1.29
|
|
30
|
+
- @zhin.js/host-http@1.1.15
|
|
31
|
+
- @zhin.js/feature-kit@1.1.13
|
|
32
|
+
- @zhin.js/tool@1.1.16
|
|
33
|
+
- @zhin.js/permission@1.1.13
|
|
34
|
+
- @zhin.js/skill@1.1.14
|
|
35
|
+
|
|
36
|
+
## 1.1.22
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 41ff1a5: ADR 0044 C5: every official adapter now declares a capability `profile` (its `segments` moved into `profile.default.messaging.segments`). icqq declares the complete profile (per conversation kind: scene, all 14 actions with real limits, events, feedback, delivery) and implements the seven new management ports (`pokeUser`, `unmuteGroupMember`, `muteAllGroupMembers`, `setGroupCard`, `setGroupTitle`, `setGroupEssence`, `inviteGroupMember`) with fresh bot-role reads. qq official declares its passive reply windows; undeclared capabilities stay unsupported.
|
|
41
|
+
- cbd3f14: ADR 0044 integration and C6 guard. `delivery.spool` now reproduces the pre-0044 media rule (icqq `false`, every other official adapter `true`). icqq narrows `actions.recall.others` unless the Bot is admin or owner, and declares recall for groups. Endpoint kind capabilities merge the Endpoint's `operations` (Discord reactions keep working; Discord declares reaction feedback). Adapters in the `@zhin.js/` scope are trusted: their custom prompt text is not labelled `external_content`. Core no longer keeps a telegram/discord interactive-policy table (adapters declare `segments.interactive`). New `pnpm check:no-platform-branches` blocks platform-name branches in runtime code.
|
|
42
|
+
- 4fe49b5: 支持配置按需生效:分离保存与有效版本,独立变更先应用,账号资料更新保留连接,模型按回合使用确定版本;Console 返回结构化应用结果。监听改为仅显式 --watch 启用,开发模板显式选择源码和配置监听。
|
|
43
|
+
|
|
44
|
+
自变更消费配置应用回执,避免已处理配置被二次重载;持久化本次写入修订和应用结果,未知结果或修订冲突时停止自动续作并保留现场,恢复不会覆盖未经本次变更确认的配置。
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [b249e5e]
|
|
47
|
+
- Updated dependencies [57661f6]
|
|
48
|
+
- Updated dependencies [cbd3f14]
|
|
49
|
+
- Updated dependencies [299863a]
|
|
50
|
+
- Updated dependencies [aaa93d7]
|
|
51
|
+
- Updated dependencies [bd524d1]
|
|
52
|
+
- Updated dependencies [126ae99]
|
|
53
|
+
- Updated dependencies [4fe49b5]
|
|
54
|
+
- Updated dependencies [cce07db]
|
|
55
|
+
- Updated dependencies [b652db3]
|
|
56
|
+
- Updated dependencies [0315ba0]
|
|
57
|
+
- Updated dependencies [00be764]
|
|
58
|
+
- @zhin.js/core@1.1.56
|
|
59
|
+
- @zhin.js/adapter@1.1.28
|
|
60
|
+
- @zhin.js/im-contract@1.1.11
|
|
61
|
+
- @zhin.js/tool@1.1.15
|
|
62
|
+
- @zhin.js/skill@1.1.13
|
|
63
|
+
- @zhin.js/host-http@1.1.14
|
|
64
|
+
- @zhin.js/feature-kit@1.1.12
|
|
65
|
+
- @zhin.js/client@1.1.24
|
|
66
|
+
- @zhin.js/page@1.1.14
|
|
67
|
+
- @zhin.js/agent-feature@1.1.13
|
|
68
|
+
- @zhin.js/permission@1.1.12
|
|
69
|
+
|
|
3
70
|
## 1.1.21
|
|
4
71
|
|
|
5
72
|
### Patch Changes
|
|
@@ -11,11 +11,27 @@ export default defineAdapter({
|
|
|
11
11
|
operations: (context) => context.config.connection === 'interactions'
|
|
12
12
|
? ['recall']
|
|
13
13
|
: ['recall', 'reaction'],
|
|
14
|
+
// 反应(reaction)留在上面的 operations:profile 对 Adapter 静态,而 interactions 传输不能加反应。
|
|
14
15
|
// 媒体 url 直发或由 AttachmentBuilder 物化本地文件上传;message components 原生按钮承载交互段。
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
profile: {
|
|
17
|
+
default: {
|
|
18
|
+
messaging: {
|
|
19
|
+
segments: {
|
|
20
|
+
outboundMedia: ['url', 'upload'],
|
|
21
|
+
interactive: 'native',
|
|
22
|
+
markdown: 'native',
|
|
23
|
+
},
|
|
24
|
+
quote: true,
|
|
25
|
+
recall: {},
|
|
26
|
+
},
|
|
27
|
+
actions: {
|
|
28
|
+
recall: { scopes: ['private', 'group', 'channel'] },
|
|
29
|
+
quoteReply: { scopes: ['private', 'group', 'channel'] },
|
|
30
|
+
},
|
|
31
|
+
// Activity feedback prefers a reaction; the interactions transport has none, so it degrades to a status message.
|
|
32
|
+
feedback: { mode: 'reaction' },
|
|
33
|
+
delivery: { send: true, proactive: true, spool: true },
|
|
34
|
+
},
|
|
19
35
|
},
|
|
20
36
|
createAdapter: context => new DiscordAdapter(context),
|
|
21
37
|
});
|
|
@@ -22,11 +22,27 @@ export default defineAdapter<DiscordEndpointConfig>({
|
|
|
22
22
|
operations: (context) => context.config.connection === 'interactions'
|
|
23
23
|
? ['recall']
|
|
24
24
|
: ['recall', 'reaction'],
|
|
25
|
+
// 反应(reaction)留在上面的 operations:profile 对 Adapter 静态,而 interactions 传输不能加反应。
|
|
25
26
|
// 媒体 url 直发或由 AttachmentBuilder 物化本地文件上传;message components 原生按钮承载交互段。
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
profile: {
|
|
28
|
+
default: {
|
|
29
|
+
messaging: {
|
|
30
|
+
segments: {
|
|
31
|
+
outboundMedia: ['url', 'upload'],
|
|
32
|
+
interactive: 'native',
|
|
33
|
+
markdown: 'native',
|
|
34
|
+
},
|
|
35
|
+
quote: true,
|
|
36
|
+
recall: {},
|
|
37
|
+
},
|
|
38
|
+
actions: {
|
|
39
|
+
recall: { scopes: ['private', 'group', 'channel'] },
|
|
40
|
+
quoteReply: { scopes: ['private', 'group', 'channel'] },
|
|
41
|
+
},
|
|
42
|
+
// Activity feedback prefers a reaction; the interactions transport has none, so it degrades to a status message.
|
|
43
|
+
feedback: { mode: 'reaction' },
|
|
44
|
+
delivery: { send: true, proactive: true, spool: true },
|
|
45
|
+
},
|
|
30
46
|
},
|
|
31
47
|
createAdapter: context => new DiscordAdapter(context),
|
|
32
48
|
});
|
package/lib/endpoint.js
CHANGED
|
@@ -177,6 +177,7 @@ export class DiscordGatewayEndpoint extends Client {
|
|
|
177
177
|
},
|
|
178
178
|
endpointId: this.#options.config.id,
|
|
179
179
|
...(msg.mentionedBot ? { mentioned: true } : {}),
|
|
180
|
+
...(msg.replyToId ? { replyTo: { id: msg.replyToId } } : {}),
|
|
180
181
|
metadata: Object.freeze({
|
|
181
182
|
channelKind: msg.channelKind,
|
|
182
183
|
userId: msg.authorId,
|
package/lib/gateway.js
CHANGED
|
@@ -143,15 +143,20 @@ export async function toMessageCreateOptions(body) {
|
|
|
143
143
|
if (body.components?.length) {
|
|
144
144
|
options.components = body.components.map((row) => new ActionRowBuilder().addComponents(...row.components.map((btn) => {
|
|
145
145
|
const b = new ButtonBuilder()
|
|
146
|
-
.setCustomId(btn.custom_id)
|
|
147
146
|
.setLabel(btn.label)
|
|
148
147
|
.setDisabled(!!btn.disabled);
|
|
149
|
-
if (btn.style ===
|
|
150
|
-
b.setStyle(ButtonStyle.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
if (btn.url && btn.style === 5) {
|
|
149
|
+
b.setStyle(ButtonStyle.Link).setURL(btn.url);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
b.setCustomId(btn.custom_id ?? '');
|
|
153
|
+
if (btn.style === 4)
|
|
154
|
+
b.setStyle(ButtonStyle.Danger);
|
|
155
|
+
else if (btn.style === 1)
|
|
156
|
+
b.setStyle(ButtonStyle.Primary);
|
|
157
|
+
else
|
|
158
|
+
b.setStyle(ButtonStyle.Secondary);
|
|
159
|
+
}
|
|
155
160
|
return b;
|
|
156
161
|
})));
|
|
157
162
|
}
|
package/lib/protocol.d.ts
CHANGED
package/lib/protocol.js
CHANGED
|
@@ -259,13 +259,25 @@ export function formatOutboundBody(payload) {
|
|
|
259
259
|
const rows = (data.rows ?? []);
|
|
260
260
|
components = rows.map((row) => ({
|
|
261
261
|
type: 1,
|
|
262
|
-
components: row.map((btn) =>
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
262
|
+
components: row.map((btn) => {
|
|
263
|
+
const url = typeof btn.url === 'string' && /^https?:\/\//i.test(btn.url.trim()) ? btn.url.trim() : undefined;
|
|
264
|
+
if (url) {
|
|
265
|
+
return {
|
|
266
|
+
type: 2,
|
|
267
|
+
url,
|
|
268
|
+
label: btn.label,
|
|
269
|
+
style: 5,
|
|
270
|
+
disabled: !!btn.disabled,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
type: 2,
|
|
275
|
+
custom_id: String(btn.payload ?? '').slice(0, 100),
|
|
276
|
+
label: btn.label,
|
|
277
|
+
style: btn.style === 'danger' ? 4 : btn.style === 'primary' ? 1 : 2,
|
|
278
|
+
disabled: !!btn.disabled,
|
|
279
|
+
};
|
|
280
|
+
}),
|
|
269
281
|
}));
|
|
270
282
|
break;
|
|
271
283
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-discord",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"description": "Zhin.js Discord adapter for Plugin Runtime (Gateway WebSocket)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -35,26 +35,26 @@
|
|
|
35
35
|
"@discordjs/ws": "1.2.3",
|
|
36
36
|
"discord.js": "^14.27.0",
|
|
37
37
|
"undici": "6.29.1",
|
|
38
|
-
"@zhin.js/adapter": "1.1.
|
|
39
|
-
"@zhin.js/agent-feature": "1.1.
|
|
40
|
-
"@zhin.js/client": "1.1.
|
|
38
|
+
"@zhin.js/adapter": "1.1.29",
|
|
39
|
+
"@zhin.js/agent-feature": "1.1.14",
|
|
40
|
+
"@zhin.js/client": "1.1.25",
|
|
41
41
|
"@zhin.js/console-contract": "1.1.3",
|
|
42
|
-
"@zhin.js/core": "1.1.
|
|
43
|
-
"@zhin.js/feature-kit": "1.1.
|
|
44
|
-
"@zhin.js/host-http": "1.1.
|
|
45
|
-
"@zhin.js/im-contract": "1.1.
|
|
42
|
+
"@zhin.js/core": "1.1.57",
|
|
43
|
+
"@zhin.js/feature-kit": "1.1.13",
|
|
44
|
+
"@zhin.js/host-http": "1.1.15",
|
|
45
|
+
"@zhin.js/im-contract": "1.1.12",
|
|
46
46
|
"@zhin.js/logger": "1.1.2",
|
|
47
|
-
"@zhin.js/page": "1.1.
|
|
48
|
-
"@zhin.js/permission": "1.1.
|
|
49
|
-
"@zhin.js/skill": "1.1.
|
|
50
|
-
"@zhin.js/tool": "1.1.
|
|
47
|
+
"@zhin.js/page": "1.1.15",
|
|
48
|
+
"@zhin.js/permission": "1.1.13",
|
|
49
|
+
"@zhin.js/skill": "1.1.14",
|
|
50
|
+
"@zhin.js/tool": "1.1.16"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"zod": "^4.0.0",
|
|
54
|
-
"@zhin.js/adapter": "^1.1.
|
|
55
|
-
"@zhin.js/command": "^1.1.
|
|
56
|
-
"@zhin.js/core": "^1.1.
|
|
57
|
-
"zhin.js": "^1.1.
|
|
54
|
+
"@zhin.js/adapter": "^1.1.29",
|
|
55
|
+
"@zhin.js/command": "^1.1.15",
|
|
56
|
+
"@zhin.js/core": "^1.1.57",
|
|
57
|
+
"zhin.js": "^1.1.22"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@zhin.js/command": {
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"typescript": "^6.0.3",
|
|
73
73
|
"vitest": "^4.1.10",
|
|
74
74
|
"zod": "^4.4.3",
|
|
75
|
-
"@zhin.js/host-http": "1.1.
|
|
76
|
-
"zhin.js": "1.1.
|
|
75
|
+
"@zhin.js/host-http": "1.1.15",
|
|
76
|
+
"zhin.js": "1.1.22"
|
|
77
77
|
},
|
|
78
78
|
"files": [
|
|
79
79
|
"adapters",
|
package/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ import { checkDiscordPlatformPermit } from "./lib/platform-permit.js";
|
|
|
5
5
|
import { createDiscordConsoleRpc } from "./lib/console.js";
|
|
6
6
|
export default definePlugin({
|
|
7
7
|
name: 'discord',
|
|
8
|
+
configUpdate: { featurePaths: [['nickname'], ['profile'], ['endpoints']] },
|
|
8
9
|
metadata: {
|
|
9
10
|
displayName: 'Discord Gateway Adapter',
|
|
10
11
|
},
|
package/src/endpoint.ts
CHANGED
|
@@ -239,6 +239,7 @@ export class DiscordGatewayEndpoint extends Client implements Endpoint {
|
|
|
239
239
|
},
|
|
240
240
|
endpointId: this.#options.config.id,
|
|
241
241
|
...(msg.mentionedBot ? { mentioned: true } : {}),
|
|
242
|
+
...(msg.replyToId ? { replyTo: { id: msg.replyToId } } : {}),
|
|
242
243
|
metadata: Object.freeze({
|
|
243
244
|
channelKind: msg.channelKind,
|
|
244
245
|
userId: msg.authorId,
|
package/src/gateway.ts
CHANGED
|
@@ -157,12 +157,16 @@ export async function toMessageCreateOptions(body: DiscordOutboundBody): Promise
|
|
|
157
157
|
new ActionRowBuilder<ButtonBuilder>().addComponents(
|
|
158
158
|
...row.components.map((btn) => {
|
|
159
159
|
const b = new ButtonBuilder()
|
|
160
|
-
.setCustomId(btn.custom_id)
|
|
161
160
|
.setLabel(btn.label)
|
|
162
161
|
.setDisabled(!!btn.disabled);
|
|
163
|
-
if (btn.style ===
|
|
164
|
-
|
|
165
|
-
else
|
|
162
|
+
if (btn.url && btn.style === 5) {
|
|
163
|
+
b.setStyle(ButtonStyle.Link).setURL(btn.url);
|
|
164
|
+
} else {
|
|
165
|
+
b.setCustomId(btn.custom_id ?? '');
|
|
166
|
+
if (btn.style === 4) b.setStyle(ButtonStyle.Danger);
|
|
167
|
+
else if (btn.style === 1) b.setStyle(ButtonStyle.Primary);
|
|
168
|
+
else b.setStyle(ButtonStyle.Secondary);
|
|
169
|
+
}
|
|
166
170
|
return b;
|
|
167
171
|
}),
|
|
168
172
|
),
|
package/src/protocol.ts
CHANGED
|
@@ -114,7 +114,8 @@ export interface DiscordWireSegment {
|
|
|
114
114
|
|
|
115
115
|
export interface DiscordOutboundComponentButton {
|
|
116
116
|
type: 2;
|
|
117
|
-
custom_id
|
|
117
|
+
custom_id?: string;
|
|
118
|
+
url?: string;
|
|
118
119
|
label: string;
|
|
119
120
|
style: number;
|
|
120
121
|
disabled?: boolean;
|
|
@@ -405,19 +406,32 @@ export function formatOutboundBody(payload: unknown): DiscordOutboundBody {
|
|
|
405
406
|
case 'keyboard': {
|
|
406
407
|
const rows = (data.rows ?? []) as Array<Array<{
|
|
407
408
|
label: string;
|
|
408
|
-
payload
|
|
409
|
+
payload?: string;
|
|
410
|
+
url?: string;
|
|
409
411
|
disabled?: boolean;
|
|
410
412
|
style?: string;
|
|
411
413
|
}>>;
|
|
412
414
|
components = rows.map((row) => ({
|
|
413
415
|
type: 1 as const,
|
|
414
|
-
components: row.map((btn) =>
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
416
|
+
components: row.map((btn) => {
|
|
417
|
+
const url = typeof btn.url === 'string' && /^https?:\/\//i.test(btn.url.trim()) ? btn.url.trim() : undefined;
|
|
418
|
+
if (url) {
|
|
419
|
+
return {
|
|
420
|
+
type: 2 as const,
|
|
421
|
+
url,
|
|
422
|
+
label: btn.label,
|
|
423
|
+
style: 5,
|
|
424
|
+
disabled: !!btn.disabled,
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
type: 2 as const,
|
|
429
|
+
custom_id: String(btn.payload ?? '').slice(0, 100),
|
|
430
|
+
label: btn.label,
|
|
431
|
+
style: btn.style === 'danger' ? 4 : btn.style === 'primary' ? 1 : 2,
|
|
432
|
+
disabled: !!btn.disabled,
|
|
433
|
+
};
|
|
434
|
+
}),
|
|
421
435
|
}));
|
|
422
436
|
break;
|
|
423
437
|
}
|