@agent-wechat/agent-wechat 2.0.0-beta.0 → 2.0.0-beta.1

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/dist/index.js CHANGED
@@ -133,11 +133,15 @@ function currentCallParentKey(cfg, runtime2, agentId, bound, ownerPeer) {
133
133
  var consultPolicies = ["auto", "substantive", "always"];
134
134
  var consultThinkingLevels = ["off", "minimal", "low", "medium", "high", "xhigh", "adaptive", "max", "ultra"];
135
135
  var callSessionScopes = ["per-contact", "per-call"];
136
+ function resolveConferenceGroupConfig(voice, groupId) {
137
+ if (groupId === "*" || !groupId.endsWith("@chatroom")) return;
138
+ return Object.hasOwn(voice.conferences.groups, groupId) ? voice.conferences.groups[groupId] : voice.conferences.groups["*"];
139
+ }
136
140
  var identifier = (value) => typeof value === "string" && value.length > 0 && value.length <= 200 && !/[\u0000-\u001f\u007f]/.test(value);
137
141
  var object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
138
- function names(value) {
142
+ function names(value, allowWildcard = false) {
139
143
  if (value === void 0) return [];
140
- if (!Array.isArray(value) || value.length > 128 || value.some((name3) => !identifier(name3) || name3 === "*")) throw Error("Invalid calling allowlist");
144
+ if (!Array.isArray(value) || value.length > 128 || value.some((name3) => !identifier(name3) || !allowWildcard && name3 === "*")) throw Error("Invalid calling allowlist");
141
145
  return [...new Set(value)];
142
146
  }
143
147
  function conferenceGroups(value, toolPolicy) {
@@ -147,10 +151,10 @@ function conferenceGroups(value, toolPolicy) {
147
151
  if (entries.length > 128) throw Error("Too many conference groups");
148
152
  const groups = /* @__PURE__ */ Object.create(null);
149
153
  for (const [id2, group] of entries) {
150
- if (!identifier(id2) || !id2.endsWith("@chatroom") || !object(group) || Object.keys(group).some((key2) => !["autoJoin", "autoJoinAllowFrom", "toolPolicy", "ownerInviterToolPolicy", "sessionKey"].includes(key2)) || group.autoJoin !== void 0 && typeof group.autoJoin !== "boolean" || ![void 0, "none", "safe-read-only", "owner"].includes(group.toolPolicy) || ![void 0, "none", "safe-read-only", "owner"].includes(group.ownerInviterToolPolicy) || (group.toolPolicy === "owner" || group.ownerInviterToolPolicy === "owner") && toolPolicy !== "owner" || group.sessionKey !== void 0 && !isCallSessionKey(group.sessionKey)) throw Error("Invalid conference group policy");
154
+ if (!identifier(id2) || id2 !== "*" && !id2.endsWith("@chatroom") || !object(group) || Object.keys(group).some((key2) => !["autoJoin", "autoJoinAllowFrom", "toolPolicy", "ownerInviterToolPolicy", "sessionKey"].includes(key2)) || group.autoJoin !== void 0 && typeof group.autoJoin !== "boolean" || id2 === "*" && group.autoJoin === true && group.autoJoinAllowFrom === void 0 || ![void 0, "none", "safe-read-only", "owner"].includes(group.toolPolicy) || ![void 0, "none", "safe-read-only", "owner"].includes(group.ownerInviterToolPolicy) || (group.toolPolicy === "owner" || group.ownerInviterToolPolicy === "owner") && toolPolicy !== "owner" || group.sessionKey !== void 0 && !isCallSessionKey(group.sessionKey)) throw Error("Invalid conference group policy");
151
155
  groups[id2] = {
152
156
  autoJoin: group.autoJoin === true,
153
- ...group.autoJoinAllowFrom !== void 0 ? { autoJoinAllowFrom: names(group.autoJoinAllowFrom) } : {},
157
+ ...group.autoJoinAllowFrom !== void 0 ? { autoJoinAllowFrom: names(group.autoJoinAllowFrom, true) } : {},
154
158
  toolPolicy: toolPolicy === "none" ? "none" : group.toolPolicy ?? "safe-read-only",
155
159
  ...group.ownerInviterToolPolicy !== void 0 ? { ownerInviterToolPolicy: group.ownerInviterToolPolicy } : {},
156
160
  sessionKey: group.sessionKey
@@ -178,7 +182,7 @@ function voiceConfig(value) {
178
182
  mode,
179
183
  transcription: { provider: transcription.provider ?? "openai", model: transcription.model, language: transcription.language },
180
184
  inboundPolicy: value.inboundPolicy ?? "disabled",
181
- inboundAllowFrom: names(value.inboundAllowFrom),
185
+ inboundAllowFrom: names(value.inboundAllowFrom, true),
182
186
  outboundPolicy: value.outboundPolicy ?? "disabled",
183
187
  outboundAllowTo: names(value.outboundAllowTo),
184
188
  outboundToolAllowFrom: names(value.outboundToolAllowFrom),
@@ -222,7 +226,7 @@ var callsConfigSchema = {
222
226
  description: "Independent voice and video permissions. Voice includes direct calls and separately configured conferences; both default off.",
223
227
  properties: {
224
228
  voice: { type: "object", additionalProperties: false, properties: {
225
- enabled: { type: "boolean", default: false, description: "Enable voice calling. Conferences also require an exact configured group. Disabled voice calls are ignored without answering or declining." },
229
+ enabled: { type: "boolean", default: false, description: "Enable voice calling. Conferences require an exact group rule or an explicit wildcard group rule. Disabled voice calls are ignored without answering or declining." },
226
230
  mode: { type: "string", enum: ["bidi", "agent"], default: "bidi", description: "bidi uses a realtime voice model (including Live); agent transcribes speech, runs the configured OpenClaw agent and speaks through OpenClaw TTS. Applies to direct calls and conferences." },
227
231
  transcription: { type: "object", additionalProperties: false, properties: {
228
232
  provider: { ...nameSchema, default: "openai", description: "Registered realtime transcription provider for agent mode." },
@@ -231,22 +235,29 @@ var callsConfigSchema = {
231
235
  apiKey: { description: "Optional OpenClaw SecretRef or API-key string for the transcription provider. Omitted uses provider configuration." }
232
236
  } },
233
237
  inboundPolicy: { type: "string", enum: ["disabled", "allowlist"] },
234
- inboundAllowFrom: allowlistSchema,
238
+ inboundAllowFrom: { ...allowlistSchema, description: "Direct-call caller IDs; an explicit '*' accepts any incoming caller. Admission does not grant owner consultation." },
235
239
  outboundPolicy: { type: "string", enum: ["disabled", "allowlist"] },
236
240
  outboundAllowTo: allowlistSchema,
237
241
  outboundToolAllowFrom: allowlistSchema,
238
242
  conferences: { type: "object", additionalProperties: false, properties: {
239
- groups: { type: "object", maxProperties: 128, propertyNames: { type: "string", pattern: "^.+@chatroom$", maxLength: 200 }, additionalProperties: {
243
+ groups: {
240
244
  type: "object",
241
- additionalProperties: false,
242
- properties: {
243
- autoJoin: { type: "boolean", default: false, description: "Join current authenticated invitations for this exact group after voice preflight. No configured groups means no conference automation." },
244
- autoJoinAllowFrom: { ...allowlistSchema, description: "Optional exact conference inviter IDs. When present, only invitations from these contacts can auto-join; an empty list disables auto-join. The configured group is still required." },
245
- toolPolicy: { type: "string", enum: ["none", "safe-read-only", "owner"], default: "safe-read-only", description: "Conference consultation authority. Owner requires voice.toolPolicy=owner and an exact agent-wechat:GROUP_ID grant in commands.ownerAllowFrom. It trusts the whole group without attributing speech to a person; otherwise consultation stays read-only." },
246
- ownerInviterToolPolicy: { type: "string", enum: ["none", "safe-read-only", "owner"], description: "Optional policy for calls whose authenticated inviter exactly matches an agent-wechat:CONTACT_ID owner grant. Otherwise toolPolicy applies. Owner also requires voice.toolPolicy=owner and an exact group owner grant. Applies to the whole call, including later participants; permissions can decrease but cannot increase during a call." },
247
- sessionKey: { type: "string", pattern: CALL_SESSION_KEY_PATTERN, maxLength: MAX_CALL_SESSION_KEY_LENGTH, description: "Optional consultation parent session of this voice agent for this group. Default sessions are isolated by account, group and authority." }
245
+ maxProperties: 128,
246
+ propertyNames: { type: "string", pattern: "^(?:\\*|.+@chatroom)$", maxLength: 200 },
247
+ description: "Exact group IDs or '*'. An exact rule overrides the wildcard, including autoJoin=false. Wildcard auto-join requires autoJoinAllowFrom; use ['*'] to accept any inviter.",
248
+ allOf: [{ if: { required: ["*"], properties: { "*": { required: ["autoJoin"], properties: { autoJoin: { const: true } } } } }, then: { properties: { "*": { required: ["autoJoinAllowFrom"] } } } }],
249
+ additionalProperties: {
250
+ type: "object",
251
+ additionalProperties: false,
252
+ properties: {
253
+ autoJoin: { type: "boolean", default: false, description: "Join current authenticated invitations matching this group rule after voice preflight. No configured groups means no conference automation." },
254
+ autoJoinAllowFrom: { ...allowlistSchema, description: "Conference inviter IDs; '*' accepts any inviter and an empty list disables auto-join. Required for wildcard-group auto-join. An exact group may omit this field to accept any inviter. The current inviter is rechecked before joining." },
255
+ toolPolicy: { type: "string", enum: ["none", "safe-read-only", "owner"], default: "safe-read-only", description: "Conference consultation authority. Owner requires voice.toolPolicy=owner and an exact agent-wechat:GROUP_ID grant in commands.ownerAllowFrom. It trusts the whole group without attributing speech to a person; otherwise consultation stays read-only." },
256
+ ownerInviterToolPolicy: { type: "string", enum: ["none", "safe-read-only", "owner"], description: "Optional policy for calls whose authenticated inviter exactly matches an agent-wechat:CONTACT_ID owner grant. Otherwise toolPolicy applies. Owner also requires voice.toolPolicy=owner and an exact group owner grant. Applies to the whole call, including later participants; permissions can decrease but cannot increase during a call." },
257
+ sessionKey: { type: "string", pattern: CALL_SESSION_KEY_PATTERN, maxLength: MAX_CALL_SESSION_KEY_LENGTH, description: "Optional consultation parent session of this voice agent for this group. Default sessions are isolated by account, group and authority." }
258
+ }
248
259
  }
249
- } }
260
+ }
250
261
  } },
251
262
  agentId: nameSchema,
252
263
  realtime: { type: "object", additionalProperties: false, properties: {
@@ -6259,7 +6270,7 @@ function currentOwnerAccess(runtime2, agentId, peer) {
6259
6270
  const voice = account?.calls?.voice;
6260
6271
  const allowed = account?.enabled === true && voice?.agentId === agentId && voice.allowConsultSessionPersistence && (voice.mode === "agent" || voice.toolPolicy !== "none") && (peer.nativeAccountId === void 0 || account.native?.accountId === peer.nativeAccountId);
6261
6272
  if (peer.conference) {
6262
- const group = voice && Object.hasOwn(voice.conferences.groups, peer.conference.groupId) ? voice.conferences.groups[peer.conference.groupId] : void 0;
6273
+ const group = voice && resolveConferenceGroupConfig(voice, peer.conference.groupId);
6263
6274
  const policy = voice && group && allowed ? conferenceCallPolicy(voice, group, peer.conference, cfg.commands?.ownerAllowFrom) : { toolPolicy: "none", reason: "group_default" };
6264
6275
  return { cfg, allowed: policy.toolPolicy !== "none" || voice?.mode === "agent" && !!group && allowed, owner: policy.toolPolicy === "owner", ...policy };
6265
6276
  }
@@ -7700,7 +7711,7 @@ var NativeCallService = class {
7700
7711
  void this.prepareIncoming(active3);
7701
7712
  }
7702
7713
  allowedIncoming(offer) {
7703
- return !!this.config && this.config.inboundPolicy === "allowlist" && this.config.inboundAllowFrom.includes(offer.callerId) && offer.kind === "direct" && offer.callType === "voice";
7714
+ return !!this.config && this.config.inboundPolicy === "allowlist" && (this.config.inboundAllowFrom.includes("*") || this.config.inboundAllowFrom.includes(offer.callerId)) && offer.kind === "direct" && offer.callType === "voice";
7704
7715
  }
7705
7716
  pending(offer) {
7706
7717
  if (!this.allowedIncoming(offer)) return;
@@ -7904,11 +7915,12 @@ var NativeCallService = class {
7904
7915
  }
7905
7916
  groupPolicy(groupId) {
7906
7917
  try {
7918
+ if (groupId === "*" || !groupId.endsWith("@chatroom")) return;
7907
7919
  const cfg = this.runtime.config?.current?.() ?? this.cfg;
7908
7920
  const account = resolveWeChatAccount(cfg, this.account.accountId);
7909
7921
  const voice = account?.calls?.voice;
7910
7922
  if (!account?.enabled || !voice || voice.agentId !== this.config?.agentId || !account.native || !this.account.native || nativeConfigurationKey(account.native) !== nativeConfigurationKey(this.account.native)) return;
7911
- const group = Object.hasOwn(voice.conferences.groups, groupId) ? voice.conferences.groups[groupId] : void 0;
7923
+ const group = resolveConferenceGroupConfig(voice, groupId);
7912
7924
  return group ? { voice, group, ownerAllowFrom: cfg.commands?.ownerAllowFrom } : void 0;
7913
7925
  } catch {
7914
7926
  return;
@@ -7916,7 +7928,7 @@ var NativeCallService = class {
7916
7928
  }
7917
7929
  allowedAutoJoin(invitation) {
7918
7930
  const group = this.groupPolicy(invitation.groupId)?.group;
7919
- return !!group?.autoJoin && (group.autoJoinAllowFrom === void 0 || group.autoJoinAllowFrom.includes(invitation.callerId));
7931
+ return !!group?.autoJoin && (group.autoJoinAllowFrom === void 0 || group.autoJoinAllowFrom.includes("*") || group.autoJoinAllowFrom.includes(invitation.callerId));
7920
7932
  }
7921
7933
  autoJoinConference() {
7922
7934
  if (this.stopped || this.state !== "available" || this.active || this.busy || !this.capabilities.conferenceJoin || !this.capabilities.conferenceAudio || !this.client?.joinConference) return;
@@ -16,6 +16,9 @@
16
16
  "wechat_group_info",
17
17
  "wechat_login",
18
18
  "wechat_call"
19
+ ],
20
+ "trustedToolPolicies": [
21
+ "wechat-conference-consultation"
19
22
  ]
20
23
  },
21
24
  "toolMetadata": {
@@ -166,7 +169,7 @@
166
169
  "enabled": {
167
170
  "type": "boolean",
168
171
  "default": false,
169
- "description": "Enable voice calling. Conferences also require an exact configured group. Disabled voice calls are ignored without answering or declining."
172
+ "description": "Enable voice calling. Conferences require an exact group rule or an explicit wildcard group rule. Disabled voice calls are ignored without answering or declining."
170
173
  },
171
174
  "mode": {
172
175
  "type": "string",
@@ -217,7 +220,8 @@
217
220
  "type": "string",
218
221
  "minLength": 1,
219
222
  "maxLength": 200
220
- }
223
+ },
224
+ "description": "Direct-call caller IDs; an explicit '*' accepts any incoming caller. Admission does not grant owner consultation."
221
225
  },
222
226
  "outboundPolicy": {
223
227
  "type": "string",
@@ -253,9 +257,40 @@
253
257
  "maxProperties": 128,
254
258
  "propertyNames": {
255
259
  "type": "string",
256
- "pattern": "^.+@chatroom$",
260
+ "pattern": "^(?:\\*|.+@chatroom)$",
257
261
  "maxLength": 200
258
262
  },
263
+ "description": "Exact group IDs or '*'. An exact rule overrides the wildcard, including autoJoin=false. Wildcard auto-join requires autoJoinAllowFrom; use ['*'] to accept any inviter.",
264
+ "allOf": [
265
+ {
266
+ "if": {
267
+ "required": [
268
+ "*"
269
+ ],
270
+ "properties": {
271
+ "*": {
272
+ "required": [
273
+ "autoJoin"
274
+ ],
275
+ "properties": {
276
+ "autoJoin": {
277
+ "const": true
278
+ }
279
+ }
280
+ }
281
+ }
282
+ },
283
+ "then": {
284
+ "properties": {
285
+ "*": {
286
+ "required": [
287
+ "autoJoinAllowFrom"
288
+ ]
289
+ }
290
+ }
291
+ }
292
+ }
293
+ ],
259
294
  "additionalProperties": {
260
295
  "type": "object",
261
296
  "additionalProperties": false,
@@ -263,7 +298,7 @@
263
298
  "autoJoin": {
264
299
  "type": "boolean",
265
300
  "default": false,
266
- "description": "Join current authenticated invitations for this exact group after voice preflight. No configured groups means no conference automation."
301
+ "description": "Join current authenticated invitations matching this group rule after voice preflight. No configured groups means no conference automation."
267
302
  },
268
303
  "autoJoinAllowFrom": {
269
304
  "type": "array",
@@ -273,7 +308,7 @@
273
308
  "minLength": 1,
274
309
  "maxLength": 200
275
310
  },
276
- "description": "Optional exact conference inviter IDs. When present, only invitations from these contacts can auto-join; an empty list disables auto-join. The configured group is still required."
311
+ "description": "Conference inviter IDs; '*' accepts any inviter and an empty list disables auto-join. Required for wildcard-group auto-join. An exact group may omit this field to accept any inviter. The current inviter is rechecked before joining."
277
312
  },
278
313
  "toolPolicy": {
279
314
  "type": "string",
@@ -678,7 +713,7 @@
678
713
  "enabled": {
679
714
  "type": "boolean",
680
715
  "default": false,
681
- "description": "Enable voice calling. Conferences also require an exact configured group. Disabled voice calls are ignored without answering or declining."
716
+ "description": "Enable voice calling. Conferences require an exact group rule or an explicit wildcard group rule. Disabled voice calls are ignored without answering or declining."
682
717
  },
683
718
  "mode": {
684
719
  "type": "string",
@@ -729,7 +764,8 @@
729
764
  "type": "string",
730
765
  "minLength": 1,
731
766
  "maxLength": 200
732
- }
767
+ },
768
+ "description": "Direct-call caller IDs; an explicit '*' accepts any incoming caller. Admission does not grant owner consultation."
733
769
  },
734
770
  "outboundPolicy": {
735
771
  "type": "string",
@@ -765,9 +801,40 @@
765
801
  "maxProperties": 128,
766
802
  "propertyNames": {
767
803
  "type": "string",
768
- "pattern": "^.+@chatroom$",
804
+ "pattern": "^(?:\\*|.+@chatroom)$",
769
805
  "maxLength": 200
770
806
  },
807
+ "description": "Exact group IDs or '*'. An exact rule overrides the wildcard, including autoJoin=false. Wildcard auto-join requires autoJoinAllowFrom; use ['*'] to accept any inviter.",
808
+ "allOf": [
809
+ {
810
+ "if": {
811
+ "required": [
812
+ "*"
813
+ ],
814
+ "properties": {
815
+ "*": {
816
+ "required": [
817
+ "autoJoin"
818
+ ],
819
+ "properties": {
820
+ "autoJoin": {
821
+ "const": true
822
+ }
823
+ }
824
+ }
825
+ }
826
+ },
827
+ "then": {
828
+ "properties": {
829
+ "*": {
830
+ "required": [
831
+ "autoJoinAllowFrom"
832
+ ]
833
+ }
834
+ }
835
+ }
836
+ }
837
+ ],
771
838
  "additionalProperties": {
772
839
  "type": "object",
773
840
  "additionalProperties": false,
@@ -775,7 +842,7 @@
775
842
  "autoJoin": {
776
843
  "type": "boolean",
777
844
  "default": false,
778
- "description": "Join current authenticated invitations for this exact group after voice preflight. No configured groups means no conference automation."
845
+ "description": "Join current authenticated invitations matching this group rule after voice preflight. No configured groups means no conference automation."
779
846
  },
780
847
  "autoJoinAllowFrom": {
781
848
  "type": "array",
@@ -785,7 +852,7 @@
785
852
  "minLength": 1,
786
853
  "maxLength": 200
787
854
  },
788
- "description": "Optional exact conference inviter IDs. When present, only invitations from these contacts can auto-join; an empty list disables auto-join. The configured group is still required."
855
+ "description": "Conference inviter IDs; '*' accepts any inviter and an empty list disables auto-join. Required for wildcard-group auto-join. An exact group may omit this field to accept any inviter. The current inviter is rechecked before joining."
789
856
  },
790
857
  "toolPolicy": {
791
858
  "type": "string",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-wechat/agent-wechat",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [
@@ -218,7 +218,7 @@
218
218
  "enabled": {
219
219
  "type": "boolean",
220
220
  "default": false,
221
- "description": "Enable voice calling. Conferences also require an exact configured group. Disabled voice calls are ignored without answering or declining."
221
+ "description": "Enable voice calling. Conferences require an exact group rule or an explicit wildcard group rule. Disabled voice calls are ignored without answering or declining."
222
222
  },
223
223
  "mode": {
224
224
  "type": "string",
@@ -269,7 +269,8 @@
269
269
  "type": "string",
270
270
  "minLength": 1,
271
271
  "maxLength": 200
272
- }
272
+ },
273
+ "description": "Direct-call caller IDs; an explicit '*' accepts any incoming caller. Admission does not grant owner consultation."
273
274
  },
274
275
  "outboundPolicy": {
275
276
  "type": "string",
@@ -305,9 +306,40 @@
305
306
  "maxProperties": 128,
306
307
  "propertyNames": {
307
308
  "type": "string",
308
- "pattern": "^.+@chatroom$",
309
+ "pattern": "^(?:\\*|.+@chatroom)$",
309
310
  "maxLength": 200
310
311
  },
312
+ "description": "Exact group IDs or '*'. An exact rule overrides the wildcard, including autoJoin=false. Wildcard auto-join requires autoJoinAllowFrom; use ['*'] to accept any inviter.",
313
+ "allOf": [
314
+ {
315
+ "if": {
316
+ "required": [
317
+ "*"
318
+ ],
319
+ "properties": {
320
+ "*": {
321
+ "required": [
322
+ "autoJoin"
323
+ ],
324
+ "properties": {
325
+ "autoJoin": {
326
+ "const": true
327
+ }
328
+ }
329
+ }
330
+ }
331
+ },
332
+ "then": {
333
+ "properties": {
334
+ "*": {
335
+ "required": [
336
+ "autoJoinAllowFrom"
337
+ ]
338
+ }
339
+ }
340
+ }
341
+ }
342
+ ],
311
343
  "additionalProperties": {
312
344
  "type": "object",
313
345
  "additionalProperties": false,
@@ -315,7 +347,7 @@
315
347
  "autoJoin": {
316
348
  "type": "boolean",
317
349
  "default": false,
318
- "description": "Join current authenticated invitations for this exact group after voice preflight. No configured groups means no conference automation."
350
+ "description": "Join current authenticated invitations matching this group rule after voice preflight. No configured groups means no conference automation."
319
351
  },
320
352
  "autoJoinAllowFrom": {
321
353
  "type": "array",
@@ -325,7 +357,7 @@
325
357
  "minLength": 1,
326
358
  "maxLength": 200
327
359
  },
328
- "description": "Optional exact conference inviter IDs. When present, only invitations from these contacts can auto-join; an empty list disables auto-join. The configured group is still required."
360
+ "description": "Conference inviter IDs; '*' accepts any inviter and an empty list disables auto-join. Required for wildcard-group auto-join. An exact group may omit this field to accept any inviter. The current inviter is rechecked before joining."
329
361
  },
330
362
  "toolPolicy": {
331
363
  "type": "string",