Class WeComChannel
java.lang.Object
io.agentscope.extensions.channel.wecom.WeComChannel
- All Implemented Interfaces:
io.agentscope.harness.agent.gateway.channel.Channel
public final class WeComChannel
extends Object
implements io.agentscope.harness.agent.gateway.channel.Channel
WeCom (企业微信) channel adapter.
Inbound: relies on Spring-managed WeComCallbackController that receives the URL
verification handshake and encrypted message callbacks, decrypts via WeComCrypto,
deduplicates by MsgId, runs the bot-loop guard, and dispatches into this channel.
Outbound: uses WeComOutboundClient to call /cgi-bin/message/send for DMs and
/cgi-bin/appchat/send for groups, authenticating with an access_token from
WeComAccessTokenProvider.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionio.agentscope.harness.agent.gateway.channel.ChannelConfigconfig()voiddeliver(io.agentscope.harness.agent.gateway.channel.OutboundAddress address, List<io.agentscope.core.message.Msg> messages) reactor.core.publisher.Mono<io.agentscope.core.message.Msg>dispatch(io.agentscope.harness.agent.gateway.channel.InboundMessage message) static WeComChannelfromProperties(String channelId, io.agentscope.harness.agent.gateway.channel.ChannelConfig routing, Map<String, Object> rawProperties) Factory used byChannelFactory.static WeComChannelfromProperties(String channelId, io.agentscope.harness.agent.gateway.channel.ChannelConfig routing, Map<String, Object> rawProperties, io.agentscope.extensions.channel.common.InboundEventDeduplicator idempotency) Factory variant that lets the application supply theInboundEventDeduplicatorused to drop platform redeliveries — for example a shared-storage implementation so duplicates are recognized across instances.static WeComChannelfromProperties(String channelId, io.agentscope.harness.agent.gateway.channel.ChannelConfig routing, Map<String, Object> rawProperties, io.agentscope.extensions.channel.common.InboundEventDeduplicator idempotency, io.agentscope.extensions.channel.common.AccessTokenStore tokenStore) Factory variant that additionally lets the application supply theAccessTokenStorecaching the outbound access token — for example a shared-storage implementation so one instance's refresh or invalidation serves the whole deployment.voidinit(io.agentscope.harness.agent.gateway.Gateway gateway) voidstart()voidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.harness.agent.gateway.channel.Channel
applyRoutingConfig, deliverWithReceipt, dispatchStream
-
Field Details
-
TYPE
typevalue used inagentscope.jsonandChannelFactory.- See Also:
-
-
Method Details
-
fromProperties
public static WeComChannel fromProperties(String channelId, io.agentscope.harness.agent.gateway.channel.ChannelConfig routing, Map<String, Object> rawProperties) Factory used byChannelFactory. Uses a process-localIdempotencyStoreandInMemoryAccessTokenStore; use the overloads takingInboundEventDeduplicatorandAccessTokenStoreto supply shared-storage implementations.- Parameters:
channelId- the channel id (key inagentscope.json#channels)routing- theChannelConfigparsed from the file entry's routing blockrawProperties- provider-specific properties (corpId, agentId, secret, token, encodingAesKey, ...)
-
fromProperties
public static WeComChannel fromProperties(String channelId, io.agentscope.harness.agent.gateway.channel.ChannelConfig routing, Map<String, Object> rawProperties, io.agentscope.extensions.channel.common.InboundEventDeduplicator idempotency) Factory variant that lets the application supply theInboundEventDeduplicatorused to drop platform redeliveries — for example a shared-storage implementation so duplicates are recognized across instances. The process-localIdempotencyStoreis used otherwise.- Parameters:
channelId- the channel id (key inagentscope.json#channels)routing- theChannelConfigparsed from the file entry's routing blockrawProperties- provider-specific properties (corpId, agentId, secret, token, encodingAesKey, ...)idempotency- deduplicator for inbound events; must be thread-safe
-
fromProperties
public static WeComChannel fromProperties(String channelId, io.agentscope.harness.agent.gateway.channel.ChannelConfig routing, Map<String, Object> rawProperties, io.agentscope.extensions.channel.common.InboundEventDeduplicator idempotency, io.agentscope.extensions.channel.common.AccessTokenStore tokenStore) Factory variant that additionally lets the application supply theAccessTokenStorecaching the outbound access token — for example a shared-storage implementation so one instance's refresh or invalidation serves the whole deployment. The process-localInMemoryAccessTokenStoreis used otherwise.- Parameters:
channelId- the channel id (key inagentscope.json#channels)routing- theChannelConfigparsed from the file entry's routing blockrawProperties- provider-specific properties (corpId, agentId, secret, token, encodingAesKey, ...)idempotency- deduplicator for inbound events; must be thread-safetokenStore- cache for this channel's access token — one instance per credential, not to be shared across channels with different credentials; must be thread-safe
-
channelId
- Specified by:
channelIdin interfaceio.agentscope.harness.agent.gateway.channel.Channel
-
config
public io.agentscope.harness.agent.gateway.channel.ChannelConfig config()- Specified by:
configin interfaceio.agentscope.harness.agent.gateway.channel.Channel
-
init
public void init(io.agentscope.harness.agent.gateway.Gateway gateway) - Specified by:
initin interfaceio.agentscope.harness.agent.gateway.channel.Channel
-
start
public void start()- Specified by:
startin interfaceio.agentscope.harness.agent.gateway.channel.Channel
-
stop
public void stop()- Specified by:
stopin interfaceio.agentscope.harness.agent.gateway.channel.Channel
-
dispatch
public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> dispatch(io.agentscope.harness.agent.gateway.channel.InboundMessage message) - Specified by:
dispatchin interfaceio.agentscope.harness.agent.gateway.channel.Channel
-
deliver
public void deliver(io.agentscope.harness.agent.gateway.channel.OutboundAddress address, List<io.agentscope.core.message.Msg> messages) - Specified by:
deliverin interfaceio.agentscope.harness.agent.gateway.channel.Channel
-