@zhin.js/adapter-icqq 7.0.1 → 7.0.2

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,23 @@
1
1
  # @zhin.js/adapter-icqq
2
2
 
3
+ ## 7.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - d5cd4aa: Publish Plugin Runtime entry points and convention modules as JavaScript so
8
+ installed npm plugins load on Node without TypeScript stripping. Workspace
9
+ development continues to prefer TypeScript sources for local HMR.
10
+
11
+ Remove the unconsumed legacy game hub APIs from game-kit; game navigation and
12
+ records now use ordinary convention commands owned by the game hub plugin.
13
+
14
+ - Updated dependencies [d5cd4aa]
15
+ - @zhin.js/command@1.0.4
16
+ - zhin.js@5.0.2
17
+ - @zhin.js/adapter@1.1.2
18
+ - @zhin.js/core@1.4.2
19
+ - @zhin.js/agent@1.0.7
20
+
3
21
  ## 7.0.1
4
22
 
5
23
  ### Patch Changes
@@ -0,0 +1,89 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ /**
3
+ * Convention entry: discover `adapters/icqq.ts` → defineAdapter.
4
+ */
5
+ import { defineAdapter } from '@zhin.js/adapter';
6
+ import { messageGatewayToken } from '@zhin.js/core/runtime';
7
+ import { formatCompact, getLogger } from '@zhin.js/logger';
8
+ import { databaseHostToken, INBOX_TABLE_NOTICE, INBOX_TABLE_REQUEST, runtimeEventPublisherToken, } from '@zhin.js/plugin-runtime';
9
+ import { IcqqIpcEndpoint } from "../lib/endpoint.js";
10
+ import { icqqRuntimeStateToken } from "../lib/icqq-runtime-state.js";
11
+ import { resolveIcqqConfig, } from "../lib/protocol.js";
12
+ export { IcqqIpcEndpoint } from "../lib/endpoint.js";
13
+ const logger = getLogger('icqq');
14
+ export default defineAdapter({
15
+ capabilities: ['inbound', 'outbound'],
16
+ // 统一消息元素通道(UNI-Channel):端点可消费 base64 / url / upload 媒体
17
+ // (path 由出站物化按 file/base64 模式转换,非声明消费形态);
18
+ // 卡片/按钮等富交互段无原生承载,降级纯文本。
19
+ segments: {
20
+ outboundMedia: ['base64', 'url', 'upload'],
21
+ interactive: 'text',
22
+ },
23
+ create(context) {
24
+ // Client-library / IPC daemon path — no httpHostToken.
25
+ // Console loginAssist + host-router routes deferred.
26
+ const config = resolveIcqqConfig(context.config);
27
+ // 注册到插件运行时状态(icqq endpoint list 的"运行中"数据源)
28
+ context.use(icqqRuntimeStateToken).endpoints.set(config.name, {
29
+ name: config.name,
30
+ mode: config.rpc ? 'rpc' : 'ipc',
31
+ });
32
+ const inbox = resolveInboxHooks(context);
33
+ return new IcqqIpcEndpoint({
34
+ id: context.id,
35
+ gateway: context.use(messageGatewayToken),
36
+ config,
37
+ ...(inbox ? { inbox } : {}),
38
+ });
39
+ },
40
+ });
41
+ /** 资源可选(轻量 Root 无 DatabaseHost / console hub):缺失时降级为不写收件箱。 */
42
+ function tryUse(context, token) {
43
+ try {
44
+ return context.use(token);
45
+ }
46
+ catch {
47
+ return undefined;
48
+ }
49
+ }
50
+ /**
51
+ * 收件箱钩子:写 unified_inbox_request/notice(按 platform_*_id 去重,
52
+ * 推送事件与 GET_SYSTEM_MSG 首拉可能重复同一请求),并经 console hub 广播。
53
+ */
54
+ function resolveInboxHooks(context) {
55
+ const host = tryUse(context, databaseHostToken);
56
+ const publisher = tryUse(context, runtimeEventPublisherToken);
57
+ if (!host && !publisher)
58
+ return undefined;
59
+ const insertDeduped = async (table, idField, row) => {
60
+ const model = host?.models.get(table);
61
+ if (!model)
62
+ return;
63
+ try {
64
+ const existing = await model.select().where({
65
+ adapter: row.adapter,
66
+ endpoint_id: row.endpoint_id,
67
+ [idField]: row[idField],
68
+ });
69
+ if (Array.isArray(existing) && existing.length > 0)
70
+ return;
71
+ await model.insert(row);
72
+ }
73
+ catch (error) {
74
+ logger.warn(formatCompact({
75
+ op: 'inbox_insert',
76
+ table,
77
+ error: error instanceof Error ? error.message : String(error),
78
+ }));
79
+ }
80
+ };
81
+ const publish = publisher;
82
+ return {
83
+ recordRequest: (row) => insertDeduped(INBOX_TABLE_REQUEST, 'platform_request_id', row),
84
+ recordNotice: (row) => insertDeduped(INBOX_TABLE_NOTICE, 'platform_notice_id', row),
85
+ ...(publish
86
+ ? { publish: (type, data) => publish.publish(type, data) }
87
+ : {}),
88
+ };
89
+ }
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { icqqEndpointCommands } from "../../../lib/icqq-endpoint-commands.js";
3
+ export default icqqEndpointCommands.add;
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { icqqEndpointCommands } from "../../lib/icqq-endpoint-commands.js";
3
+ export default icqqEndpointCommands.list;
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { icqqEndpointCommands } from "../../../lib/icqq-endpoint-commands.js";
3
+ export default icqqEndpointCommands.remove;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-icqq",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "description": "Zhin.js ICQQ adapter for Plugin Runtime (IPC daemon client)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -34,19 +34,19 @@
34
34
  "directory": "plugins/adapters/icqq"
35
35
  },
36
36
  "dependencies": {
37
- "@zhin.js/adapter": "1.1.1",
38
- "@zhin.js/command": "1.0.3",
39
- "@zhin.js/core": "1.4.1",
37
+ "@zhin.js/adapter": "1.1.2",
38
+ "@zhin.js/command": "1.0.4",
39
+ "@zhin.js/core": "1.4.2",
40
40
  "@zhin.js/logger": "1.0.75",
41
41
  "@zhin.js/plugin-runtime": "1.1.1"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "zod": "^4.0.0",
45
- "@zhin.js/adapter": "1.1.1",
46
- "@zhin.js/agent": "1.0.6",
47
- "@zhin.js/core": "1.4.1",
45
+ "@zhin.js/adapter": "1.1.2",
46
+ "@zhin.js/agent": "1.0.7",
47
+ "@zhin.js/core": "1.4.2",
48
48
  "@zhin.js/plugin-runtime": "1.1.1",
49
- "zhin.js": "5.0.1"
49
+ "zhin.js": "5.0.2"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "zhin.js": {
@@ -64,13 +64,13 @@
64
64
  "typescript": "^6.0.3",
65
65
  "vitest": "^4.1.10",
66
66
  "zod": "^4.4.3",
67
- "@zhin.js/agent": "1.0.6",
68
- "zhin.js": "5.0.1"
67
+ "@zhin.js/agent": "1.0.7",
68
+ "zhin.js": "5.0.2"
69
69
  },
70
70
  "files": [
71
71
  "adapters",
72
72
  "commands",
73
- "plugin.ts",
73
+ "plugin.js",
74
74
  "schema.json",
75
75
  "src",
76
76
  "lib",
@@ -88,7 +88,7 @@
88
88
  "zhin": {
89
89
  "protocol": 1,
90
90
  "type": "plugin",
91
- "entry": "./plugin.ts",
91
+ "entry": "./plugin.js",
92
92
  "engine": "^1.0.0",
93
93
  "runtime": "trusted",
94
94
  "features": [
package/plugin.js ADDED
@@ -0,0 +1,37 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { createEndpointRuntimeState } from '@zhin.js/adapter';
3
+ import { definePlugin } from '@zhin.js/plugin-runtime';
4
+ import { icqqRuntimeStateToken } from "./lib/icqq-runtime-state.js";
5
+ // Module-level guard: multiple icqq instances (icqq, icqq-2, …) share this
6
+ // module, but the prompt contributor is per-platform — register it once.
7
+ let promptContributorRegistered = false;
8
+ export default definePlugin({
9
+ name: 'icqq',
10
+ metadata: {
11
+ displayName: 'ICQQ Adapter',
12
+ },
13
+ setup(context) {
14
+ // 运行中 endpoint 注册表(icqq endpoint list 的"运行中"数据源)
15
+ context.resources.provide(icqqRuntimeStateToken, createEndpointRuntimeState());
16
+ // Agent prompt contributor (orchestrator/deferred-worker ICQQ guidance).
17
+ // `zhin.js/agent` is an optional peer — skip silently on IM-only installs.
18
+ if (promptContributorRegistered)
19
+ return;
20
+ let cancelled = false;
21
+ let unregister;
22
+ void Promise.all([
23
+ import('zhin.js/agent'),
24
+ import("./lib/agent-prompt.js"),
25
+ ]).then(([agent, prompt]) => {
26
+ if (cancelled || promptContributorRegistered)
27
+ return;
28
+ agent.registerAgentPromptContributor(prompt.createIcqqAgentPromptContributor());
29
+ promptContributorRegistered = true;
30
+ unregister = () => agent.unregisterAgentPromptContributor('icqq');
31
+ }).catch(() => { });
32
+ return () => {
33
+ cancelled = true;
34
+ unregister?.();
35
+ };
36
+ },
37
+ });
package/plugin.ts DELETED
@@ -1,36 +0,0 @@
1
- import { createEndpointRuntimeState } from '@zhin.js/adapter';
2
- import { definePlugin } from '@zhin.js/plugin-runtime';
3
- import { icqqRuntimeStateToken } from './src/icqq-runtime-state.js';
4
-
5
- // Module-level guard: multiple icqq instances (icqq, icqq-2, …) share this
6
- // module, but the prompt contributor is per-platform — register it once.
7
- let promptContributorRegistered = false;
8
-
9
- export default definePlugin({
10
- name: 'icqq',
11
- metadata: {
12
- displayName: 'ICQQ Adapter',
13
- },
14
- setup(context) {
15
- // 运行中 endpoint 注册表(icqq endpoint list 的"运行中"数据源)
16
- context.resources.provide(icqqRuntimeStateToken, createEndpointRuntimeState());
17
- // Agent prompt contributor (orchestrator/deferred-worker ICQQ guidance).
18
- // `zhin.js/agent` is an optional peer — skip silently on IM-only installs.
19
- if (promptContributorRegistered) return;
20
- let cancelled = false;
21
- let unregister: (() => void) | undefined;
22
- void Promise.all([
23
- import('zhin.js/agent'),
24
- import('./src/agent-prompt.js'),
25
- ]).then(([agent, prompt]) => {
26
- if (cancelled || promptContributorRegistered) return;
27
- agent.registerAgentPromptContributor(prompt.createIcqqAgentPromptContributor());
28
- promptContributorRegistered = true;
29
- unregister = () => agent.unregisterAgentPromptContributor('icqq');
30
- }).catch(() => { /* optional peer not installed */ });
31
- return () => {
32
- cancelled = true;
33
- unregister?.();
34
- };
35
- },
36
- });