@zhin.js/adapter-wecom 1.1.20 → 1.1.22

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,67 @@
1
1
  # @zhin.js/adapter-wecom
2
2
 
3
+ ## 1.1.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 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.
8
+ - 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.
9
+ - 4fe49b5: 支持配置按需生效:分离保存与有效版本,独立变更先应用,账号资料更新保留连接,模型按回合使用确定版本;Console 返回结构化应用结果。监听改为仅显式 --watch 启用,开发模板显式选择源码和配置监听。
10
+
11
+ 自变更消费配置应用回执,避免已处理配置被二次重载;持久化本次写入修订和应用结果,未知结果或修订冲突时停止自动续作并保留现场,恢复不会覆盖未经本次变更确认的配置。
12
+
13
+ - Updated dependencies [b249e5e]
14
+ - Updated dependencies [57661f6]
15
+ - Updated dependencies [cbd3f14]
16
+ - Updated dependencies [299863a]
17
+ - Updated dependencies [aaa93d7]
18
+ - Updated dependencies [bd524d1]
19
+ - Updated dependencies [126ae99]
20
+ - Updated dependencies [4fe49b5]
21
+ - Updated dependencies [cce07db]
22
+ - Updated dependencies [b652db3]
23
+ - Updated dependencies [0315ba0]
24
+ - Updated dependencies [00be764]
25
+ - @zhin.js/core@1.1.56
26
+ - @zhin.js/adapter@1.1.28
27
+ - @zhin.js/im-contract@1.1.11
28
+ - @zhin.js/tool@1.1.15
29
+ - @zhin.js/skill@1.1.13
30
+ - @zhin.js/host-http@1.1.14
31
+ - @zhin.js/feature-kit@1.1.12
32
+ - @zhin.js/client@1.1.24
33
+ - @zhin.js/page@1.1.14
34
+ - @zhin.js/agent-feature@1.1.13
35
+
36
+ ## 1.1.21
37
+
38
+ ### Patch Changes
39
+
40
+ - af8f803: Use the current Endpoint's platform profile for Agent account identity, with per-field configured fallbacks and scoped, identity-approved profile tools. Keep SOUL first-person and independent of account names. Profile ports preserve the source Client, cancellation, truthful update outcomes and private image authority.
41
+
42
+ Adapter Feature API 2.1 and Tool Feature API 1.1 describe the additive profile requirements; new Core, official adapters and generated plugins declare the corresponding floors. Existing compatible API-2.0/API-1.0 plugins remain accepted by the newer providers. npm releases remain patch.
43
+
44
+ Private IM assets now bind to the full canonical conversation and principal. Existing IM asset records that contain only the earlier lossy hash remain on disk until their original expiry, but cannot be safely rebound; recapture them. No automatic file deletion, platform profile mutation or workspace SOUL rewrite occurs during upgrade.
45
+
46
+ - Updated dependencies [b88e988]
47
+ - Updated dependencies [f78eb84]
48
+ - Updated dependencies [c15cef9]
49
+ - Updated dependencies [b0c02a2]
50
+ - Updated dependencies [af8f803]
51
+ - Updated dependencies [26fda97]
52
+ - Updated dependencies [976886c]
53
+ - Updated dependencies [032dc96]
54
+ - @zhin.js/adapter@1.1.27
55
+ - @zhin.js/client@1.1.23
56
+ - @zhin.js/im-contract@1.1.10
57
+ - @zhin.js/core@1.1.55
58
+ - @zhin.js/tool@1.1.14
59
+ - @zhin.js/page@1.1.13
60
+ - @zhin.js/host-http@1.1.13
61
+ - @zhin.js/agent-feature@1.1.12
62
+ - @zhin.js/feature-kit@1.1.11
63
+ - @zhin.js/skill@1.1.12
64
+
3
65
  ## 1.1.20
4
66
 
5
67
  ### Patch Changes
@@ -9,12 +9,22 @@ import {} from "../../lib/protocol.js";
9
9
  export { WecomEndpoint } from "../../lib/endpoint.js";
10
10
  export default defineAdapter({
11
11
  capabilities: ['inbound', 'outbound'],
12
- operations: ['recall'],
13
12
  // image 段全部经 /cgi-bin/media/upload 物化为 media_id(url 下载后上传、
14
13
  // base64/path 直接上传、file 引用直用 media_id);无卡片交互面,交互段降级纯文本。
15
- segments: {
16
- outboundMedia: ['upload'],
17
- interactive: 'text',
14
+ profile: {
15
+ default: {
16
+ messaging: {
17
+ segments: {
18
+ outboundMedia: ['upload'],
19
+ interactive: 'text',
20
+ },
21
+ recall: {},
22
+ },
23
+ actions: {
24
+ recall: { scopes: ['private', 'group'] },
25
+ },
26
+ delivery: { send: true, proactive: true, spool: true },
27
+ },
18
28
  },
19
29
  createAdapter: context => new WecomAdapter(context),
20
30
  });
@@ -13,12 +13,22 @@ export type { WecomEndpointOptions, WecomFetch } from '../../src/endpoint.js';
13
13
 
14
14
  export default defineAdapter<WecomEndpointConfig>({
15
15
  capabilities: ['inbound', 'outbound'],
16
- operations: ['recall'],
17
16
  // image 段全部经 /cgi-bin/media/upload 物化为 media_id(url 下载后上传、
18
17
  // base64/path 直接上传、file 引用直用 media_id);无卡片交互面,交互段降级纯文本。
19
- segments: {
20
- outboundMedia: ['upload'],
21
- interactive: 'text',
18
+ profile: {
19
+ default: {
20
+ messaging: {
21
+ segments: {
22
+ outboundMedia: ['upload'],
23
+ interactive: 'text',
24
+ },
25
+ recall: {},
26
+ },
27
+ actions: {
28
+ recall: { scopes: ['private', 'group'] },
29
+ },
30
+ delivery: { send: true, proactive: true, spool: true },
31
+ },
22
32
  },
23
33
  createAdapter: context => new WecomAdapter(context),
24
34
  });
@@ -26,8 +26,6 @@ tools:
26
26
 
27
27
  # 企业微信技能
28
28
 
29
- 企业微信(WeCom)是腾讯面向企业的 IM 平台,具备组织架构(部门树)、应用消息推送等能力。
30
-
31
29
  ## 核心原则
32
30
 
33
31
  ### 组织架构是核心
@@ -44,25 +42,9 @@ wecom_get_user(user_id) → 获取用户详情
44
42
  `wecom_send_text` 通过应用消息接口发送文本消息,需要知道接收者的 `userid`。
45
43
  群消息通过 webhook 回调自动处理,不需要主动调用发送工具。
46
44
 
47
- ## 工具分类
48
-
49
- ### 组织架构
50
-
51
- | 工具 | 用途 | 说明 |
52
- |------|------|------|
53
- | `wecom_list_departments` | 部门列表 | 默认从根部门 ID=1 开始 |
54
- | `wecom_get_dept_users` | 部门用户列表 | 返回简单用户信息 |
55
- | `wecom_get_user` | 用户详情 | 需要通讯录权限 |
56
-
57
- ### 消息
58
-
59
- | 工具 | 用途 | 说明 |
60
- |------|------|------|
61
- | `wecom_send_text` | 发送文本消息 | 发给指定用户,通过应用消息接口 |
62
-
63
45
  ## 易错点
64
46
 
65
47
  1. **部门查询从根部门 ID=1 开始**。不知道部门 ID 时先 `list_departments` 获取整棵部门树。
66
48
  2. **消息发送需要 userid**,不是用户名或昵称。仅有昵称时先通过 `get_dept_users` 查找。
67
- 3. **企业微信不支持机器人撤回消息**,一旦发出无法撤回。
68
- 4. **Access Token 有效期 7200 秒**,适配器会自动刷新。
49
+ 3. **用户详情查询需要通讯录权限**。
50
+ 4. **企业微信不支持机器人撤回消息**,一旦发出无法撤回。
package/lib/client.d.ts CHANGED
@@ -59,7 +59,7 @@ export declare class WecomClient extends EventEmitter {
59
59
  recallMessage(messageId: string, { signal }?: EndpointOperationOptions): Promise<void>;
60
60
  /** Test / internal: admit a parsed message when open (non-webhook path). */
61
61
  admit(msg: WecomMessage): void;
62
- getApplicationInfo(): Promise<WecomApiResponse>;
62
+ getApplicationInfo(request?: EndpointOperationOptions): Promise<WecomApiResponse>;
63
63
  getUserInfo(userId: string): Promise<WecomApiResponse | null>;
64
64
  getDepartmentUsers(deptId: number): Promise<unknown[]>;
65
65
  getDepartmentList(deptId?: number): Promise<unknown[]>;
package/lib/client.js CHANGED
@@ -223,8 +223,8 @@ export class WecomClient extends EventEmitter {
223
223
  }));
224
224
  });
225
225
  }
226
- async getApplicationInfo() {
227
- const response = await this.#request('/cgi-bin/agent/get', { params: { agentid: this.config.agentId } });
226
+ async getApplicationInfo(request = {}) {
227
+ const response = await this.#request('/cgi-bin/agent/get', { params: { agentid: this.config.agentId }, signal: request.signal });
228
228
  if (response.errcode !== 0)
229
229
  throw new Error('WeCom application identity verification failed');
230
230
  return response;
package/lib/endpoint.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createEndpointSpecification, endpointSpec } from 'zhin.js/adapter';
2
2
  import { WecomClient } from './client.js';
3
+ import { createWecomSelfProfile } from './self-profile.js';
3
4
  /** Actual protocol Client; framework lifecycle and admission stay in their symbol namespace. */
4
5
  export class WecomEndpoint extends WecomClient {
5
6
  [endpointSpec] = this.#createSpecification();
@@ -11,6 +12,7 @@ export class WecomEndpoint extends WecomClient {
11
12
  send: (request) => this.sendPayload(request),
12
13
  name: this.configName(),
13
14
  control: this.endpointControl,
15
+ profile: createWecomSelfProfile(this),
14
16
  };
15
17
  Object.defineProperty(hooks, 'transportState', { get: () => this.transportState });
16
18
  return createEndpointSpecification(this, hooks);
package/lib/protocol.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
1
2
  import { type Locale } from 'zhin.js/i18n';
2
3
  import type { IncomingMessage } from 'node:http';
3
4
  import type { ConversationRef } from '@zhin.js/im-contract';
4
5
  /** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
5
- export interface WecomEndpointConfig {
6
+ export interface WecomEndpointConfig extends EndpointProfileConfiguration {
6
7
  readonly id: string;
7
8
  readonly corpId: string;
8
9
  readonly agentId: string;
@@ -0,0 +1,4 @@
1
+ import { type EndpointProfile } from 'zhin.js/adapter';
2
+ import type { WecomClient } from './client.js';
3
+ /** Enterprise application profile; no member/user profile is impersonated. */
4
+ export declare function createWecomSelfProfile(client: Pick<WecomClient, 'getApplicationInfo'>): EndpointProfile;
@@ -0,0 +1,13 @@
1
+ import { createEndpointOperation } from 'zhin.js/adapter';
2
+ /** Enterprise application profile; no member/user profile is impersonated. */
3
+ export function createWecomSelfProfile(client) {
4
+ return Object.freeze({
5
+ writableFields: Object.freeze([]),
6
+ async read({ signal }) {
7
+ const self = await createEndpointOperation({ signal }).prepare(() => client.getApplicationInfo({ signal }));
8
+ return { ...(typeof self.name === 'string' ? { nickname: self.name } : {}),
9
+ ...(typeof self.description === 'string' ? { bio: self.description } : {}),
10
+ ...(typeof self.square_logo_url === 'string' ? { avatar: self.square_logo_url } : {}) };
11
+ },
12
+ });
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-wecom",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "Zhin.js WeCom (企业微信) adapter for Plugin Runtime (HTTP webhook)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -33,27 +33,27 @@
33
33
  "directory": "plugins/adapters/wecom"
34
34
  },
35
35
  "dependencies": {
36
- "@zhin.js/adapter": "1.1.26",
37
- "@zhin.js/agent-feature": "1.1.11",
36
+ "@zhin.js/adapter": "1.1.28",
37
+ "@zhin.js/agent-feature": "1.1.13",
38
+ "@zhin.js/client": "1.1.24",
38
39
  "@zhin.js/console-contract": "1.1.3",
39
- "@zhin.js/client": "1.1.22",
40
- "@zhin.js/core": "1.1.54",
41
- "@zhin.js/im-contract": "1.1.9",
40
+ "@zhin.js/core": "1.1.56",
41
+ "@zhin.js/feature-kit": "1.1.12",
42
+ "@zhin.js/host-http": "1.1.14",
43
+ "@zhin.js/im-contract": "1.1.11",
42
44
  "@zhin.js/logger": "1.1.2",
43
- "@zhin.js/page": "1.1.12",
44
- "@zhin.js/skill": "1.1.11",
45
- "@zhin.js/tool": "1.1.13",
46
- "@zhin.js/host-http": "1.1.12",
47
- "@zhin.js/feature-kit": "1.1.10"
45
+ "@zhin.js/page": "1.1.14",
46
+ "@zhin.js/skill": "1.1.13",
47
+ "@zhin.js/tool": "1.1.15"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "zod": "^4.0.0",
51
- "@zhin.js/adapter": "^1.1.26",
52
- "@zhin.js/command": "^1.1.12",
53
- "@zhin.js/core": "^1.1.54",
54
- "@zhin.js/permission": "^1.1.10",
55
- "zhin.js": "^1.1.19",
56
- "@zhin.js/host-http": "^1.1.12"
51
+ "@zhin.js/adapter": "^1.1.28",
52
+ "@zhin.js/command": "^1.1.14",
53
+ "@zhin.js/core": "^1.1.56",
54
+ "@zhin.js/host-http": "^1.1.14",
55
+ "@zhin.js/permission": "^1.1.12",
56
+ "zhin.js": "^1.1.21"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "@zhin.js/command": {
@@ -71,7 +71,7 @@
71
71
  "typescript": "^6.0.3",
72
72
  "vitest": "^4.1.10",
73
73
  "zod": "^4.4.3",
74
- "zhin.js": "1.1.19"
74
+ "zhin.js": "1.1.21"
75
75
  },
76
76
  "files": [
77
77
  "adapters",
@@ -103,7 +103,7 @@
103
103
  "features": [
104
104
  {
105
105
  "package": "@zhin.js/adapter",
106
- "api": "^2.0.0"
106
+ "api": "^2.1.0"
107
107
  },
108
108
  {
109
109
  "package": "@zhin.js/command",
@@ -111,7 +111,7 @@
111
111
  },
112
112
  {
113
113
  "package": "@zhin.js/tool",
114
- "api": "^1.0.0"
114
+ "api": "^1.1.0"
115
115
  },
116
116
  {
117
117
  "package": "@zhin.js/skill",
package/plugin.js CHANGED
@@ -5,6 +5,7 @@ import { checkWecomPlatformPermit } from "./lib/platform-permit.js";
5
5
  import { createWecomConsoleRpc } from "./lib/console.js";
6
6
  export default definePlugin({
7
7
  name: 'wecom',
8
+ configUpdate: { featurePaths: [['nickname'], ['profile'], ['endpoints']] },
8
9
  metadata: {
9
10
  displayName: 'WeCom (企业微信) Adapter',
10
11
  },
package/schema.json CHANGED
@@ -113,6 +113,27 @@
113
113
  "description": "WeCom application AgentId (not the application secret)"
114
114
  }
115
115
  }
116
+ },
117
+ "nickname": {
118
+ "type": [
119
+ "string",
120
+ "null"
121
+ ],
122
+ "description": "账号昵称兜底",
123
+ "x-i18n": {
124
+ "en": {
125
+ "description": "Fallback account nickname"
126
+ }
127
+ }
128
+ },
129
+ "profile": {
130
+ "$ref": "#/$defs/selfProfileFallback",
131
+ "description": "账号资料兜底",
132
+ "x-i18n": {
133
+ "en": {
134
+ "description": "Fallback account profile"
135
+ }
136
+ }
116
137
  }
117
138
  },
118
139
  "required": [
@@ -139,9 +160,93 @@
139
160
  "description": "Command prefix. The default empty string allows unprefixed commands; '/' requires a leading slash. Each endpoints[i] can override it."
140
161
  }
141
162
  }
163
+ },
164
+ "nickname": {
165
+ "type": [
166
+ "string",
167
+ "null"
168
+ ],
169
+ "description": "账号昵称兜底",
170
+ "x-i18n": {
171
+ "en": {
172
+ "description": "Fallback account nickname"
173
+ }
174
+ }
175
+ },
176
+ "profile": {
177
+ "$ref": "#/$defs/selfProfileFallback",
178
+ "description": "账号资料兜底",
179
+ "x-i18n": {
180
+ "en": {
181
+ "description": "Fallback account profile"
182
+ }
183
+ }
142
184
  }
143
185
  },
144
186
  "required": [
145
187
  "endpoints"
146
- ]
188
+ ],
189
+ "$defs": {
190
+ "selfProfileFallback": {
191
+ "type": "object",
192
+ "additionalProperties": false,
193
+ "properties": {
194
+ "gender": {
195
+ "type": [
196
+ "string",
197
+ "null"
198
+ ],
199
+ "enum": [
200
+ "male",
201
+ "female",
202
+ "other",
203
+ "unknown",
204
+ null
205
+ ]
206
+ },
207
+ "age": {
208
+ "type": [
209
+ "integer",
210
+ "null"
211
+ ],
212
+ "minimum": 0
213
+ },
214
+ "birthday": {
215
+ "type": [
216
+ "string",
217
+ "null"
218
+ ],
219
+ "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
220
+ },
221
+ "signature": {
222
+ "type": [
223
+ "string",
224
+ "null"
225
+ ]
226
+ },
227
+ "avatar": {
228
+ "type": [
229
+ "string",
230
+ "null"
231
+ ],
232
+ "pattern": "^(https?://[^\\s/?#]+(?:[/?#].*)?|)$"
233
+ },
234
+ "interests": {
235
+ "type": [
236
+ "array",
237
+ "null"
238
+ ],
239
+ "items": {
240
+ "type": "string"
241
+ }
242
+ },
243
+ "bio": {
244
+ "type": [
245
+ "string",
246
+ "null"
247
+ ]
248
+ }
249
+ }
250
+ }
251
+ }
147
252
  }
package/src/client.ts CHANGED
@@ -282,8 +282,8 @@ export class WecomClient extends EventEmitter {
282
282
  });
283
283
  }
284
284
 
285
- async getApplicationInfo(): Promise<WecomApiResponse> {
286
- const response = await this.#request('/cgi-bin/agent/get', { params: { agentid: this.config.agentId } });
285
+ async getApplicationInfo(request: EndpointOperationOptions = {}): Promise<WecomApiResponse> {
286
+ const response = await this.#request('/cgi-bin/agent/get', { params: { agentid: this.config.agentId }, signal: request.signal });
287
287
  if (response.errcode !== 0) throw new Error('WeCom application identity verification failed');
288
288
  return response;
289
289
  }
package/src/endpoint.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createEndpointSpecification, endpointSpec, type Endpoint } from 'zhin.js/adapter';
2
2
  import { WecomClient, type WecomEndpointOptions } from './client.js';
3
+ import { createWecomSelfProfile } from './self-profile.js';
3
4
  export type { WecomEndpointOptions } from './client.js';
4
5
  export type { WecomFetch } from './client.js';
5
6
 
@@ -14,6 +15,7 @@ export class WecomEndpoint extends WecomClient implements Endpoint {
14
15
  send: (request: import('zhin.js/adapter').EndpointSendRequest) => this.sendPayload(request),
15
16
  name: this.configName(),
16
17
  control: this.endpointControl,
18
+ profile: createWecomSelfProfile(this),
17
19
  };
18
20
  Object.defineProperty(hooks, 'transportState', { get: () => this.transportState });
19
21
  return createEndpointSpecification(this, hooks);
package/src/protocol.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
1
2
  import { createMessages, type Locale } from 'zhin.js/i18n';
2
3
  /**
3
4
  * WeCom (企业微信) protocol helpers — no legacy Adapter/Endpoint / segment-mapper.
@@ -9,7 +10,7 @@ import type { IncomingMessage } from 'node:http';
9
10
  import type { ConversationRef } from '@zhin.js/im-contract';
10
11
 
11
12
  /** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
12
- export interface WecomEndpointConfig {
13
+ export interface WecomEndpointConfig extends EndpointProfileConfiguration {
13
14
  readonly id: string;
14
15
  readonly corpId: string;
15
16
  readonly agentId: string;
@@ -0,0 +1,15 @@
1
+ import { createEndpointOperation, type EndpointProfile } from 'zhin.js/adapter';
2
+ import type { WecomClient } from './client.js';
3
+
4
+ /** Enterprise application profile; no member/user profile is impersonated. */
5
+ export function createWecomSelfProfile(client: Pick<WecomClient, 'getApplicationInfo'>): EndpointProfile {
6
+ return Object.freeze<EndpointProfile>({
7
+ writableFields: Object.freeze([]),
8
+ async read({ signal }) {
9
+ const self = await createEndpointOperation({ signal }).prepare(() => client.getApplicationInfo({ signal }));
10
+ return { ...(typeof self.name === 'string' ? { nickname: self.name } : {}),
11
+ ...(typeof self.description === 'string' ? { bio: self.description } : {}),
12
+ ...(typeof self.square_logo_url === 'string' ? { avatar: self.square_logo_url } : {}) };
13
+ },
14
+ });
15
+ }