@theokit/gateway 0.20.0 → 0.21.0
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 +10 -0
- package/README.md +25 -0
- package/dist/index.cjs +47 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +47 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1303,6 +1303,11 @@ interface ChannelEntry {
|
|
|
1303
1303
|
readonly descriptor: ChannelDescriptor<BasePlatformAdapter>;
|
|
1304
1304
|
/** Values keyed by the descriptor's field keys. Absent means every required field is missing. */
|
|
1305
1305
|
readonly config?: Readonly<Record<string, unknown>>;
|
|
1306
|
+
/**
|
|
1307
|
+
* The prefix passed to `configFromEnv` for this entry, so a missing field's rejection names its
|
|
1308
|
+
* full environment variable. Defaults to `""`.
|
|
1309
|
+
*/
|
|
1310
|
+
readonly envPrefix?: string;
|
|
1306
1311
|
}
|
|
1307
1312
|
/** A channel that was not built, and the configuration error that says why. */
|
|
1308
1313
|
interface ChannelRejection {
|
|
@@ -2007,6 +2012,41 @@ declare function createAgentBindings(options: AgentBindingsOptions): AgentBindin
|
|
|
2007
2012
|
/** Prefixes another strategy's key with the bound agent, so two agents never share a session. */
|
|
2008
2013
|
declare function bindingStrategy(bindings: AgentBindings, inner: AgentIdStrategy): AgentIdStrategy;
|
|
2009
2014
|
|
|
2015
|
+
/**
|
|
2016
|
+
* `scopedStrategy` — session keys with DM scopes, peer links and account labels.
|
|
2017
|
+
*
|
|
2018
|
+
* `dm` is always the second key segment, so no label or peer name can make a
|
|
2019
|
+
* DM key equal a group (`grp`) or thread (`tpc`) key. Every segment is encoded
|
|
2020
|
+
* with `encodeURIComponent` and joined with `:`, which it never emits, so the
|
|
2021
|
+
* key mapping is injective. Linked peers and `main` use a leading `@` segment,
|
|
2022
|
+
* which no encoded platform can start with (`@` encodes to `%40`).
|
|
2023
|
+
*
|
|
2024
|
+
* @public
|
|
2025
|
+
*/
|
|
2026
|
+
|
|
2027
|
+
/** How DMs are keyed: one conversation, per peer, per channel and peer, or per account too. */
|
|
2028
|
+
type DmScope = "main" | "per-peer" | "per-channel-peer" | "per-account-channel-peer";
|
|
2029
|
+
/** Options for {@link scopedStrategy}. */
|
|
2030
|
+
interface ScopedStrategyOptions {
|
|
2031
|
+
readonly dmScope: DmScope;
|
|
2032
|
+
/** `<platform>:<senderId>` to a peer name. Used by `per-peer`. */
|
|
2033
|
+
readonly peerLinks?: ReadonlyMap<string, string>;
|
|
2034
|
+
/** Required when `dmScope` is `per-account-channel-peer`. */
|
|
2035
|
+
readonly accountLabel?: string;
|
|
2036
|
+
/** Group key: one per channel (default) or one per channel and sender. */
|
|
2037
|
+
readonly groupScope?: "channel" | "channel-sender";
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Builds a strategy for the chosen DM scope. Keys:
|
|
2041
|
+
* `main` → `_m-dm`; `per-peer` linked → `_p-dm-<peer>`, unlinked → the
|
|
2042
|
+
* per-channel-peer key; `per-channel-peer` → `<platform>-dm-<sender>`;
|
|
2043
|
+
* `per-account-channel-peer` → `<platform>-dm-<account>-<sender>`.
|
|
2044
|
+
* Groups are `<platform>-grp-<channel>[-<sender>]`, topic threads
|
|
2045
|
+
* `<platform>-tpc-<channel>-<topic>`. Every segment is escaped with `sanitize`.
|
|
2046
|
+
* Throws `GatewayConfigurationError` (`invalid_session_scope`) on bad options, never per event.
|
|
2047
|
+
*/
|
|
2048
|
+
declare function scopedStrategy(options: ScopedStrategyOptions): AgentIdStrategy;
|
|
2049
|
+
|
|
2010
2050
|
/**
|
|
2011
2051
|
* What `ChatPresenter` needs to know about one platform: how to rewrite the text, and which
|
|
2012
2052
|
* `format` to declare on the message (B-019 FR-001, FR-002).
|
|
@@ -2346,4 +2386,4 @@ interface WebhookHandlerOptions {
|
|
|
2346
2386
|
*/
|
|
2347
2387
|
declare function createWebhookHandler(options: WebhookHandlerOptions): (request: Request) => Promise<Response>;
|
|
2348
2388
|
|
|
2349
|
-
export { type AccessPolicyOptions, type AdapterCapabilities, type AdapterState, type AgentBindingRule, type AgentBindings, type AgentBindingsOptions, type AgentIdStrategy, type BaseMessageEvent, BasePlatformAdapter, type BuiltChannel, type BuzzMessageEvent, CREDENTIAL_SHAPES, type ChannelConfigField, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChatCommand, type ChunkByGraphemeOptions, type ChunkTextOptions, type ClickClackMessageEvent, type ConnectFailure, type CoveredShape, type CreateChannelsResult, DEFAULT_WEBHOOK_MAX_BYTES, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DiscordMessageEvent, type DmPolicy, type EmailMessageEvent, type EnvConfig, type FeishuLarkMessageEvent, type FenceRegion, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type InboundAudio, type IngestResult, type IrcMessageEvent, type LineMessageEvent, type ListenableApp, type ListenerLike, type MatrixMessageEvent, type MattermostMessageEvent, type MediaUnderstandingOptions, type MessageEvent, type NextcloudTalkMessageEvent, type NostrMessageEvent, type OnErrorContext, type OutboundAttachment, type OutboundMessage, type PairingStore, type ParsedChatCommand, type PlatformEventRegistry, type PlatformName, type PostOutboundContext, type PreInboundContext, type QQMessageEvent, type RaftMessageEvent, type RawBodyCaptureOptions, type RawBodyRequest, type ReconnectPolicy, type SMSMessageEvent, SeenIds, type SendResult, type SenderIdentity, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type StartResult, type SynologyChatMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type TlonUrbitMessageEvent, type TwitchMessageEvent, type UncoveredShape, type WeChatMessageEvent, type WeComMessageEvent, type WebhookAnswer, type WebhookHandlerOptions, type WebhookRequest, WeixinAdapterBase, type WeixinAdapterConfig, type WeixinFetch, type WeixinSendRequest, type WeixinWebhookAnswer, type WhatsAppMessageEvent, type XMessageEvent, type XThreadTweet, type YuanbaoMessageEvent, type ZaloMessageEvent, type ZaloPersonalMessageEvent, bindingStrategy, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFilePairingStore, createWebhookHandler, defaultStrategy, helpText, isAuthenticatedSender, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, scanFences, selectVariant, senderKey, splitKeepingRows, statusForDeliver, toDialect, withMediaUnderstanding };
|
|
2389
|
+
export { type AccessPolicyOptions, type AdapterCapabilities, type AdapterState, type AgentBindingRule, type AgentBindings, type AgentBindingsOptions, type AgentIdStrategy, type BaseMessageEvent, BasePlatformAdapter, type BuiltChannel, type BuzzMessageEvent, CREDENTIAL_SHAPES, type ChannelConfigField, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChatCommand, type ChunkByGraphemeOptions, type ChunkTextOptions, type ClickClackMessageEvent, type ConnectFailure, type CoveredShape, type CreateChannelsResult, DEFAULT_WEBHOOK_MAX_BYTES, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DiscordMessageEvent, type DmPolicy, type DmScope, type EmailMessageEvent, type EnvConfig, type FeishuLarkMessageEvent, type FenceRegion, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type InboundAudio, type IngestResult, type IrcMessageEvent, type LineMessageEvent, type ListenableApp, type ListenerLike, type MatrixMessageEvent, type MattermostMessageEvent, type MediaUnderstandingOptions, type MessageEvent, type NextcloudTalkMessageEvent, type NostrMessageEvent, type OnErrorContext, type OutboundAttachment, type OutboundMessage, type PairingStore, type ParsedChatCommand, type PlatformEventRegistry, type PlatformName, type PostOutboundContext, type PreInboundContext, type QQMessageEvent, type RaftMessageEvent, type RawBodyCaptureOptions, type RawBodyRequest, type ReconnectPolicy, type SMSMessageEvent, type ScopedStrategyOptions, SeenIds, type SendResult, type SenderIdentity, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type StartResult, type SynologyChatMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type TlonUrbitMessageEvent, type TwitchMessageEvent, type UncoveredShape, type WeChatMessageEvent, type WeComMessageEvent, type WebhookAnswer, type WebhookHandlerOptions, type WebhookRequest, WeixinAdapterBase, type WeixinAdapterConfig, type WeixinFetch, type WeixinSendRequest, type WeixinWebhookAnswer, type WhatsAppMessageEvent, type XMessageEvent, type XThreadTweet, type YuanbaoMessageEvent, type ZaloMessageEvent, type ZaloPersonalMessageEvent, bindingStrategy, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFilePairingStore, createWebhookHandler, defaultStrategy, helpText, isAuthenticatedSender, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, scanFences, scopedStrategy, selectVariant, senderKey, splitKeepingRows, statusForDeliver, toDialect, withMediaUnderstanding };
|
package/dist/index.d.ts
CHANGED
|
@@ -1303,6 +1303,11 @@ interface ChannelEntry {
|
|
|
1303
1303
|
readonly descriptor: ChannelDescriptor<BasePlatformAdapter>;
|
|
1304
1304
|
/** Values keyed by the descriptor's field keys. Absent means every required field is missing. */
|
|
1305
1305
|
readonly config?: Readonly<Record<string, unknown>>;
|
|
1306
|
+
/**
|
|
1307
|
+
* The prefix passed to `configFromEnv` for this entry, so a missing field's rejection names its
|
|
1308
|
+
* full environment variable. Defaults to `""`.
|
|
1309
|
+
*/
|
|
1310
|
+
readonly envPrefix?: string;
|
|
1306
1311
|
}
|
|
1307
1312
|
/** A channel that was not built, and the configuration error that says why. */
|
|
1308
1313
|
interface ChannelRejection {
|
|
@@ -2007,6 +2012,41 @@ declare function createAgentBindings(options: AgentBindingsOptions): AgentBindin
|
|
|
2007
2012
|
/** Prefixes another strategy's key with the bound agent, so two agents never share a session. */
|
|
2008
2013
|
declare function bindingStrategy(bindings: AgentBindings, inner: AgentIdStrategy): AgentIdStrategy;
|
|
2009
2014
|
|
|
2015
|
+
/**
|
|
2016
|
+
* `scopedStrategy` — session keys with DM scopes, peer links and account labels.
|
|
2017
|
+
*
|
|
2018
|
+
* `dm` is always the second key segment, so no label or peer name can make a
|
|
2019
|
+
* DM key equal a group (`grp`) or thread (`tpc`) key. Every segment is encoded
|
|
2020
|
+
* with `encodeURIComponent` and joined with `:`, which it never emits, so the
|
|
2021
|
+
* key mapping is injective. Linked peers and `main` use a leading `@` segment,
|
|
2022
|
+
* which no encoded platform can start with (`@` encodes to `%40`).
|
|
2023
|
+
*
|
|
2024
|
+
* @public
|
|
2025
|
+
*/
|
|
2026
|
+
|
|
2027
|
+
/** How DMs are keyed: one conversation, per peer, per channel and peer, or per account too. */
|
|
2028
|
+
type DmScope = "main" | "per-peer" | "per-channel-peer" | "per-account-channel-peer";
|
|
2029
|
+
/** Options for {@link scopedStrategy}. */
|
|
2030
|
+
interface ScopedStrategyOptions {
|
|
2031
|
+
readonly dmScope: DmScope;
|
|
2032
|
+
/** `<platform>:<senderId>` to a peer name. Used by `per-peer`. */
|
|
2033
|
+
readonly peerLinks?: ReadonlyMap<string, string>;
|
|
2034
|
+
/** Required when `dmScope` is `per-account-channel-peer`. */
|
|
2035
|
+
readonly accountLabel?: string;
|
|
2036
|
+
/** Group key: one per channel (default) or one per channel and sender. */
|
|
2037
|
+
readonly groupScope?: "channel" | "channel-sender";
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Builds a strategy for the chosen DM scope. Keys:
|
|
2041
|
+
* `main` → `_m-dm`; `per-peer` linked → `_p-dm-<peer>`, unlinked → the
|
|
2042
|
+
* per-channel-peer key; `per-channel-peer` → `<platform>-dm-<sender>`;
|
|
2043
|
+
* `per-account-channel-peer` → `<platform>-dm-<account>-<sender>`.
|
|
2044
|
+
* Groups are `<platform>-grp-<channel>[-<sender>]`, topic threads
|
|
2045
|
+
* `<platform>-tpc-<channel>-<topic>`. Every segment is escaped with `sanitize`.
|
|
2046
|
+
* Throws `GatewayConfigurationError` (`invalid_session_scope`) on bad options, never per event.
|
|
2047
|
+
*/
|
|
2048
|
+
declare function scopedStrategy(options: ScopedStrategyOptions): AgentIdStrategy;
|
|
2049
|
+
|
|
2010
2050
|
/**
|
|
2011
2051
|
* What `ChatPresenter` needs to know about one platform: how to rewrite the text, and which
|
|
2012
2052
|
* `format` to declare on the message (B-019 FR-001, FR-002).
|
|
@@ -2346,4 +2386,4 @@ interface WebhookHandlerOptions {
|
|
|
2346
2386
|
*/
|
|
2347
2387
|
declare function createWebhookHandler(options: WebhookHandlerOptions): (request: Request) => Promise<Response>;
|
|
2348
2388
|
|
|
2349
|
-
export { type AccessPolicyOptions, type AdapterCapabilities, type AdapterState, type AgentBindingRule, type AgentBindings, type AgentBindingsOptions, type AgentIdStrategy, type BaseMessageEvent, BasePlatformAdapter, type BuiltChannel, type BuzzMessageEvent, CREDENTIAL_SHAPES, type ChannelConfigField, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChatCommand, type ChunkByGraphemeOptions, type ChunkTextOptions, type ClickClackMessageEvent, type ConnectFailure, type CoveredShape, type CreateChannelsResult, DEFAULT_WEBHOOK_MAX_BYTES, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DiscordMessageEvent, type DmPolicy, type EmailMessageEvent, type EnvConfig, type FeishuLarkMessageEvent, type FenceRegion, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type InboundAudio, type IngestResult, type IrcMessageEvent, type LineMessageEvent, type ListenableApp, type ListenerLike, type MatrixMessageEvent, type MattermostMessageEvent, type MediaUnderstandingOptions, type MessageEvent, type NextcloudTalkMessageEvent, type NostrMessageEvent, type OnErrorContext, type OutboundAttachment, type OutboundMessage, type PairingStore, type ParsedChatCommand, type PlatformEventRegistry, type PlatformName, type PostOutboundContext, type PreInboundContext, type QQMessageEvent, type RaftMessageEvent, type RawBodyCaptureOptions, type RawBodyRequest, type ReconnectPolicy, type SMSMessageEvent, SeenIds, type SendResult, type SenderIdentity, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type StartResult, type SynologyChatMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type TlonUrbitMessageEvent, type TwitchMessageEvent, type UncoveredShape, type WeChatMessageEvent, type WeComMessageEvent, type WebhookAnswer, type WebhookHandlerOptions, type WebhookRequest, WeixinAdapterBase, type WeixinAdapterConfig, type WeixinFetch, type WeixinSendRequest, type WeixinWebhookAnswer, type WhatsAppMessageEvent, type XMessageEvent, type XThreadTweet, type YuanbaoMessageEvent, type ZaloMessageEvent, type ZaloPersonalMessageEvent, bindingStrategy, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFilePairingStore, createWebhookHandler, defaultStrategy, helpText, isAuthenticatedSender, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, scanFences, selectVariant, senderKey, splitKeepingRows, statusForDeliver, toDialect, withMediaUnderstanding };
|
|
2389
|
+
export { type AccessPolicyOptions, type AdapterCapabilities, type AdapterState, type AgentBindingRule, type AgentBindings, type AgentBindingsOptions, type AgentIdStrategy, type BaseMessageEvent, BasePlatformAdapter, type BuiltChannel, type BuzzMessageEvent, CREDENTIAL_SHAPES, type ChannelConfigField, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChatCommand, type ChunkByGraphemeOptions, type ChunkTextOptions, type ClickClackMessageEvent, type ConnectFailure, type CoveredShape, type CreateChannelsResult, DEFAULT_WEBHOOK_MAX_BYTES, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DiscordMessageEvent, type DmPolicy, type DmScope, type EmailMessageEvent, type EnvConfig, type FeishuLarkMessageEvent, type FenceRegion, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type InboundAudio, type IngestResult, type IrcMessageEvent, type LineMessageEvent, type ListenableApp, type ListenerLike, type MatrixMessageEvent, type MattermostMessageEvent, type MediaUnderstandingOptions, type MessageEvent, type NextcloudTalkMessageEvent, type NostrMessageEvent, type OnErrorContext, type OutboundAttachment, type OutboundMessage, type PairingStore, type ParsedChatCommand, type PlatformEventRegistry, type PlatformName, type PostOutboundContext, type PreInboundContext, type QQMessageEvent, type RaftMessageEvent, type RawBodyCaptureOptions, type RawBodyRequest, type ReconnectPolicy, type SMSMessageEvent, type ScopedStrategyOptions, SeenIds, type SendResult, type SenderIdentity, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type StartResult, type SynologyChatMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type TlonUrbitMessageEvent, type TwitchMessageEvent, type UncoveredShape, type WeChatMessageEvent, type WeComMessageEvent, type WebhookAnswer, type WebhookHandlerOptions, type WebhookRequest, WeixinAdapterBase, type WeixinAdapterConfig, type WeixinFetch, type WeixinSendRequest, type WeixinWebhookAnswer, type WhatsAppMessageEvent, type XMessageEvent, type XThreadTweet, type YuanbaoMessageEvent, type ZaloMessageEvent, type ZaloPersonalMessageEvent, bindingStrategy, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFilePairingStore, createWebhookHandler, defaultStrategy, helpText, isAuthenticatedSender, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, scanFences, scopedStrategy, selectVariant, senderKey, splitKeepingRows, statusForDeliver, toDialect, withMediaUnderstanding };
|
package/dist/index.js
CHANGED
|
@@ -629,7 +629,9 @@ function isAbsent(value) {
|
|
|
629
629
|
return value === void 0 || value === null || value === "";
|
|
630
630
|
}
|
|
631
631
|
function missingRequiredKeys(entry, values) {
|
|
632
|
-
return entry.descriptor.config.filter((field) => field.required && isAbsent(values[field.key])).map(
|
|
632
|
+
return entry.descriptor.config.filter((field) => field.required && isAbsent(values[field.key])).map(
|
|
633
|
+
(field) => field.env === void 0 ? field.key : `${field.key} (env ${(entry.envPrefix ?? "") + field.env})`
|
|
634
|
+
);
|
|
633
635
|
}
|
|
634
636
|
function refused(platform, code, reason) {
|
|
635
637
|
return {
|
|
@@ -1787,6 +1789,49 @@ function bindingStrategy(bindings, inner) {
|
|
|
1787
1789
|
return (event) => `${sanitize(bindings.agentFor(event))}-${inner(event)}`;
|
|
1788
1790
|
}
|
|
1789
1791
|
|
|
1792
|
+
// src/session/scoped-strategy.ts
|
|
1793
|
+
var join2 = (...segments) => segments.map(sanitize).join("-");
|
|
1794
|
+
function invalid(message, detail) {
|
|
1795
|
+
return new GatewayConfigurationError("gateway", {
|
|
1796
|
+
code: "invalid_session_scope",
|
|
1797
|
+
message: `gateway: invalid_session_scope: ${message}`,
|
|
1798
|
+
...detail === void 0 ? {} : { detail }
|
|
1799
|
+
});
|
|
1800
|
+
}
|
|
1801
|
+
function scopedStrategy(options) {
|
|
1802
|
+
const { dmScope, peerLinks, accountLabel, groupScope = "channel" } = options;
|
|
1803
|
+
if (dmScope === "per-account-channel-peer" && (accountLabel === void 0 || accountLabel === "")) {
|
|
1804
|
+
throw invalid("per-account-channel-peer requires a non-empty accountLabel", "accountLabel");
|
|
1805
|
+
}
|
|
1806
|
+
if (peerLinks !== void 0) {
|
|
1807
|
+
for (const [from, peer] of peerLinks) {
|
|
1808
|
+
if (peer === "") throw invalid(`empty peer name for ${from}`, from);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
const dmKey = (platform, senderId) => {
|
|
1812
|
+
switch (dmScope) {
|
|
1813
|
+
case "main":
|
|
1814
|
+
return "_m-dm";
|
|
1815
|
+
case "per-peer": {
|
|
1816
|
+
const peer = peerLinks?.get(`${platform}:${senderId}`);
|
|
1817
|
+
return peer === void 0 ? join2(platform, "dm", senderId) : `_p-dm-${sanitize(peer)}`;
|
|
1818
|
+
}
|
|
1819
|
+
case "per-channel-peer":
|
|
1820
|
+
return join2(platform, "dm", senderId);
|
|
1821
|
+
case "per-account-channel-peer":
|
|
1822
|
+
return join2(platform, "dm", accountLabel ?? "", senderId);
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
return (event) => {
|
|
1826
|
+
const { platform, channel, sender } = event;
|
|
1827
|
+
if (channel.type === "dm") return dmKey(platform, sender.id);
|
|
1828
|
+
if (channel.type === "thread" && channel.topicId !== void 0) {
|
|
1829
|
+
return join2(platform, "tpc", channel.id, channel.topicId);
|
|
1830
|
+
}
|
|
1831
|
+
return groupScope === "channel-sender" ? join2(platform, "grp", channel.id, sender.id) : join2(platform, "grp", channel.id);
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1790
1835
|
// src/text/chunk.ts
|
|
1791
1836
|
function searchBoundary(remaining, window, boundaries) {
|
|
1792
1837
|
let cut = window;
|
|
@@ -2266,6 +2311,6 @@ async function dispatch(webhook, adapter, request) {
|
|
|
2266
2311
|
return runDefault(webhook, adapter, request);
|
|
2267
2312
|
}
|
|
2268
2313
|
|
|
2269
|
-
export { BasePlatformAdapter, CREDENTIAL_SHAPES, DEFAULT_WEBHOOK_MAX_BYTES, DeliveryRouter, GatewayConfigurationError, GatewayLifecycleError, GatewayRunner, HookExecutor, SeenIds, SessionRouter, WeixinAdapterBase, bindingStrategy, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFilePairingStore, createWebhookHandler, defaultStrategy, helpText, isAuthenticatedSender, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, scanFences, selectVariant, senderKey, splitKeepingRows, statusForDeliver, toDialect, withMediaUnderstanding };
|
|
2314
|
+
export { BasePlatformAdapter, CREDENTIAL_SHAPES, DEFAULT_WEBHOOK_MAX_BYTES, DeliveryRouter, GatewayConfigurationError, GatewayLifecycleError, GatewayRunner, HookExecutor, SeenIds, SessionRouter, WeixinAdapterBase, bindingStrategy, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFilePairingStore, createWebhookHandler, defaultStrategy, helpText, isAuthenticatedSender, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, scanFences, scopedStrategy, selectVariant, senderKey, splitKeepingRows, statusForDeliver, toDialect, withMediaUnderstanding };
|
|
2270
2315
|
//# sourceMappingURL=index.js.map
|
|
2271
2316
|
//# sourceMappingURL=index.js.map
|