@zhin.js/adapter-discord 1.1.22 → 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 +33 -0
- 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/src/endpoint.ts +1 -0
- package/src/gateway.ts +8 -4
- package/src/protocol.ts +23 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
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
|
+
|
|
3
36
|
## 1.1.22
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
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/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
|
}
|