@zhin.js/adapter-discord 1.1.22 → 1.1.24

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 CHANGED
@@ -1,5 +1,58 @@
1
1
  # @zhin.js/adapter-discord
2
2
 
3
+ ## 1.1.24
4
+
5
+ ### Patch Changes
6
+
7
+ - cbf1fb1: Unify Console page blueprints (`definePageBlueprint`, `defineAdapterPage`, `defineCommentReviewPage`, `projectBlueprintToImCard`, `projectBlueprintToCliPanel`) into `@zhin.js/console-contract` and `@zhin.js/page`, add zero-esbuild pure Blueprint synthesis + static client bundle mounting to `@zhin.js/pagemanager`, remove `@zhin.js/client` (React 19) and `.tsx` from all 30 server-side plugins and adapters (including `bilibili` and `juejin`), and remove legacy Era-1 Koa `PageManager` code.
8
+ - Updated dependencies [cbf1fb1]
9
+ - Updated dependencies [008ccad]
10
+ - Updated dependencies [a1f1028]
11
+ - @zhin.js/console-contract@1.1.4
12
+ - @zhin.js/page@1.1.16
13
+ - @zhin.js/core@1.1.58
14
+ - @zhin.js/im-contract@1.1.13
15
+ - @zhin.js/host-http@1.1.16
16
+ - @zhin.js/adapter@1.1.30
17
+ - @zhin.js/tool@1.1.17
18
+ - @zhin.js/agent-feature@1.1.15
19
+ - @zhin.js/feature-kit@1.1.14
20
+ - @zhin.js/permission@1.1.14
21
+ - @zhin.js/skill@1.1.15
22
+
23
+ ## 1.1.23
24
+
25
+ ### Patch Changes
26
+
27
+ - bc6ccb1: Deep audit bug fixes and 7 architectural improvements:
28
+ - 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.
29
+ - 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'`).
30
+ - 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.
31
+ - Push down `DatabaseContextRepository` and `DatabaseScheduleJobStorage` full-session/full-table memory scans to indexed SQL queries.
32
+ - Add kernel-level inbound `replyTo` and `mentioned` auto-promotion (`promoteInboundMessagePayload`) plus reusable `InboundDeduper` and `TtlLookupCache` primitives in `@zhin.js/adapter`.
33
+ - Add `MiddlewareContext.dispatch` (`InboundDispatchSummary`) and `onAfterDispatch` hooks for `after-dispatch` middlewares, and support incremental rendering of in-place `envelope.payload` array mutations in `OutboundDeliveryRuntime`.
34
+ - Unify `HistoryWindowTracker` and `AgentCompactionRuntime` token/message budgets (`resolveUnifiedHistoryAndCompactionBudget`).
35
+ - 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.
36
+ - Updated dependencies [3a8504b]
37
+ - Updated dependencies [6163abc]
38
+ - Updated dependencies [fed2c27]
39
+ - Updated dependencies [bc6ccb1]
40
+ - Updated dependencies [72b5a12]
41
+ - Updated dependencies [aa41889]
42
+ - Updated dependencies [4427e72]
43
+ - Updated dependencies [22bd14a]
44
+ - @zhin.js/agent-feature@1.1.14
45
+ - @zhin.js/core@1.1.57
46
+ - @zhin.js/client@1.1.25
47
+ - @zhin.js/page@1.1.15
48
+ - @zhin.js/im-contract@1.1.12
49
+ - @zhin.js/adapter@1.1.29
50
+ - @zhin.js/host-http@1.1.15
51
+ - @zhin.js/feature-kit@1.1.13
52
+ - @zhin.js/tool@1.1.16
53
+ - @zhin.js/permission@1.1.13
54
+ - @zhin.js/skill@1.1.14
55
+
3
56
  ## 1.1.22
4
57
 
5
58
  ### 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 === 4)
150
- b.setStyle(ButtonStyle.Danger);
151
- else if (btn.style === 1)
152
- b.setStyle(ButtonStyle.Primary);
153
- else
154
- b.setStyle(ButtonStyle.Secondary);
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
@@ -95,7 +95,8 @@ export interface DiscordWireSegment {
95
95
  }
96
96
  export interface DiscordOutboundComponentButton {
97
97
  type: 2;
98
- custom_id: string;
98
+ custom_id?: string;
99
+ url?: string;
99
100
  label: string;
100
101
  style: number;
101
102
  disabled?: boolean;
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
- type: 2,
264
- custom_id: String(btn.payload).slice(0, 100),
265
- label: btn.label,
266
- style: btn.style === 'danger' ? 4 : btn.style === 'primary' ? 1 : 2,
267
- disabled: !!btn.disabled,
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.22",
3
+ "version": "1.1.24",
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,25 @@
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.28",
39
- "@zhin.js/agent-feature": "1.1.13",
40
- "@zhin.js/client": "1.1.24",
41
- "@zhin.js/console-contract": "1.1.3",
42
- "@zhin.js/core": "1.1.56",
43
- "@zhin.js/feature-kit": "1.1.12",
44
- "@zhin.js/host-http": "1.1.14",
45
- "@zhin.js/im-contract": "1.1.11",
38
+ "@zhin.js/adapter": "1.1.30",
39
+ "@zhin.js/agent-feature": "1.1.15",
40
+ "@zhin.js/console-contract": "1.1.4",
41
+ "@zhin.js/core": "1.1.58",
42
+ "@zhin.js/feature-kit": "1.1.14",
43
+ "@zhin.js/host-http": "1.1.16",
44
+ "@zhin.js/im-contract": "1.1.13",
46
45
  "@zhin.js/logger": "1.1.2",
47
- "@zhin.js/page": "1.1.14",
48
- "@zhin.js/permission": "1.1.12",
49
- "@zhin.js/skill": "1.1.13",
50
- "@zhin.js/tool": "1.1.15"
46
+ "@zhin.js/page": "1.1.16",
47
+ "@zhin.js/permission": "1.1.14",
48
+ "@zhin.js/skill": "1.1.15",
49
+ "@zhin.js/tool": "1.1.17"
51
50
  },
52
51
  "peerDependencies": {
53
52
  "zod": "^4.0.0",
54
- "@zhin.js/adapter": "^1.1.28",
55
- "@zhin.js/command": "^1.1.14",
56
- "@zhin.js/core": "^1.1.56",
57
- "zhin.js": "^1.1.21"
53
+ "@zhin.js/adapter": "^1.1.30",
54
+ "@zhin.js/command": "^1.1.16",
55
+ "@zhin.js/core": "^1.1.58",
56
+ "zhin.js": "^1.1.23"
58
57
  },
59
58
  "peerDependenciesMeta": {
60
59
  "@zhin.js/command": {
@@ -72,8 +71,8 @@
72
71
  "typescript": "^6.0.3",
73
72
  "vitest": "^4.1.10",
74
73
  "zod": "^4.4.3",
75
- "@zhin.js/host-http": "1.1.14",
76
- "zhin.js": "1.1.21"
74
+ "@zhin.js/host-http": "1.1.16",
75
+ "zhin.js": "1.1.23"
77
76
  },
78
77
  "files": [
79
78
  "adapters",
@@ -1,6 +1,5 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
- import { definePage } from '@zhin.js/console-contract';
3
- import { createAdapterConsolePage } from '@zhin.js/client';
2
+ import { definePage, createAdapterConsolePage } from '@zhin.js/console-contract';
4
3
  export const meta = definePage({
5
4
  title: 'Discord',
6
5
  titleI18n: { en: 'Discord' },
@@ -1,5 +1,4 @@
1
- import { definePage } from '@zhin.js/console-contract';
2
- import { createAdapterConsolePage } from '@zhin.js/client';
1
+ import { definePage, createAdapterConsolePage } from '@zhin.js/console-contract';
3
2
 
4
3
  export const meta = definePage({
5
4
  title: 'Discord',
package/plugin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
- import { definePlugin, pluginConsoleRpcToken } from 'zhin.js';
2
+ import { definePlugin } from 'zhin.js';
3
3
  import { permissionHostToken } from '@zhin.js/permission';
4
4
  import { checkDiscordPlatformPermit } from "./lib/platform-permit.js";
5
5
  import { createDiscordConsoleRpc } from "./lib/console.js";
@@ -10,10 +10,12 @@ export default definePlugin({
10
10
  displayName: 'Discord Gateway Adapter',
11
11
  },
12
12
  setup(context) {
13
- context.resources.provide(pluginConsoleRpcToken, createDiscordConsoleRpc(() => context.config.get()));
14
- if (context.resources.has(permissionHostToken)) {
15
- const host = context.resources.use(permissionHostToken);
16
- return host.registerPlatform('discord', checkDiscordPlatformPermit);
17
- }
13
+ const dispose = context.resources.has(permissionHostToken)
14
+ ? context.resources.use(permissionHostToken).registerPlatform('discord', checkDiscordPlatformPermit)
15
+ : undefined;
16
+ return {
17
+ consoleRpc: createDiscordConsoleRpc(() => context.config.get()),
18
+ ...(dispose ? { dispose } : {}),
19
+ };
18
20
  },
19
21
  });
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 === 4) b.setStyle(ButtonStyle.Danger);
164
- else if (btn.style === 1) b.setStyle(ButtonStyle.Primary);
165
- else b.setStyle(ButtonStyle.Secondary);
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: string;
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: string;
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
- type: 2 as const,
416
- custom_id: String(btn.payload).slice(0, 100),
417
- label: btn.label,
418
- style: btn.style === 'danger' ? 4 : btn.style === 'primary' ? 1 : 2,
419
- disabled: !!btn.disabled,
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
  }