loopzero-gateway 0.1.0 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Minor Changes
6
+
7
+ - An inbound event may carry `images`, a list of the new `InboundImage`: media type, optional size and file name, and a `read()` that fetches the bytes on its first call. Nothing is downloaded until `read()` is called.
8
+
3
9
  ## 0.33.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -97,6 +97,15 @@ presenter per turn; it keeps state between `present()` calls.
97
97
  - `loopzero-presenter` is your dependency, not this package's: `loopzero-gateway` does not depend
98
98
  on it.
99
99
 
100
+ ## Receiving an image
101
+
102
+ An inbound event may carry `images`, a list of `InboundImage`: `mediaType`, optional `size` and
103
+ `filename`, and `read()`, which fetches the bytes on its first call and returns the same bytes
104
+ after. Nothing is downloaded until a hook or the handler calls `read()`, so a `pre_inbound` hook
105
+ that refuses a sender costs no request. `read()` rejects when the platform cannot deliver the
106
+ bytes, with a message that is safe to log. The Mattermost adapter fills `images`; an adapter that
107
+ does not read images leaves the field out.
108
+
100
109
  ## Sending an image
101
110
 
102
111
  `ctx.reply` takes an optional `attachments` list of images, each an `OutboundAttachment`: its
@@ -106,10 +115,11 @@ an empty list out. `post_outbound` hooks see the same outbound, image bytes incl
106
115
  the bytes or the list until the reply's promise settles: Telegram reads each image only when its
107
116
  turn comes. `DeliveryRouter.send` takes the same `attachments` field for a scheduled delivery.
108
117
 
109
- Only Telegram sends images today. Code that holds the adapter reads `supportsAttachments` before
118
+ Telegram and Mattermost send attachments today, images and audio both; `adapter.capabilities.attachments`
119
+ lists the kinds. Code that holds the adapter reads `supportsAttachments` before
110
120
  attaching: every other adapter reports `false` and refuses an outbound carrying attachments with
111
121
  `attachments_unsupported`, making no platform call, so an image is never dropped in silence. An
112
- edit carrying attachments is refused the same way on every adapter, Telegram included.
122
+ edit carrying attachments is refused the same way on every adapter, those two included.
113
123
  `BasePlatformAdapter`, `OutboundAttachment` and `SendResult` come from `loopzero-gateway`.
114
124
 
115
125
  ```typescript
package/dist/index.d.cts CHANGED
@@ -396,6 +396,24 @@ interface InboundAudio {
396
396
  /** The length in whole seconds the platform reported; 0 when it reported none. */
397
397
  readonly durationSeconds: number;
398
398
  }
399
+ /**
400
+ * An image an inbound message carries: read on demand, like {@link InboundAudio}, so an app whose
401
+ * `pre_inbound` hook refuses a sender never downloads the sender's media.
402
+ *
403
+ * Nothing is fetched until `read()` is called. The first call fetches; later calls return the
404
+ * same bytes. `read()` rejects when the platform cannot deliver them (the error message is safe
405
+ * to log: it never carries a credential).
406
+ */
407
+ interface InboundImage {
408
+ /** The image bytes, fetched on the first call and cached. */
409
+ read(): Promise<Uint8Array>;
410
+ /** The length in bytes the platform reported before any download; absent when it reported none. */
411
+ readonly size?: number;
412
+ /** The media type of the bytes, such as `image/png`. */
413
+ readonly mediaType: string;
414
+ /** The file name the sender's client gave; absent when the platform reported none. */
415
+ readonly filename?: string;
416
+ }
399
417
  /** Fields common to every platform's inbound event. */
400
418
  interface BaseMessageEvent {
401
419
  /** Stable id used as a session-key segment and for dedup. */
@@ -441,6 +459,11 @@ interface BaseMessageEvent {
441
459
  * and for a voice the adapter could not read.
442
460
  */
443
461
  readonly audio?: InboundAudio;
462
+ /**
463
+ * The images the message carries, in the order the platform lists them. Absent for a message
464
+ * with none, and on an adapter that does not read them.
465
+ */
466
+ readonly images?: readonly InboundImage[];
444
467
  }
445
468
  /** Telegram-specific event variant. */
446
469
  interface TelegramMessageEvent extends BaseMessageEvent {
@@ -2849,4 +2872,4 @@ declare function verifyDigest(opts: {
2849
2872
  prefix?: string;
2850
2873
  }): boolean;
2851
2874
 
2852
- export { type AccessPolicyMessages, 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 ChannelConfigInput, type ChannelConfigReaders, type ChannelDeps, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChatCommand, type ChunkByGraphemeOptions, type ChunkTextOptions, type ClickClackMessageEvent, type ConnectFailure, type CoveredShape, type CreateChannelsResult, type CredentialStore, DEFAULT_WEBHOOK_MAX_BYTES, type DecodedJwt, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DigestEncoding, type DiscordMessageEvent, type DmPolicy, type DmScope, type EmailMessageEvent, type EnvConfig, type EnvOptions, type FeishuLarkMessageEvent, type FenceRegion, type FetchedToken, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type GroupActivationMode, type GroupActivationOptions, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type InboundAudio, type IngestResult, type IrcMessageEvent, type JsonRpcChild, JsonRpcLineClient, type JwksKeySet, type JwksKeySetOptions, type JwksLookup, 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, ReconnectBackoff, type ReconnectBackoffOptions, type ReconnectPolicy, type ReportDiagnosticOptions, type RpcNotification, type RpcOutcome, type SMSMessageEvent, type ScopedStrategyOptions, SeenIds, type SendError, type SendErrorCode, type SendResult, type SenderIdentity, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type SplitKeepingRowsOptions, type StartResult, type SynologyChatMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type TlonUrbitMessageEvent, type TokenCache, type TokenCacheOptions, type TwitchMessageEvent, type UncoveredShape, type VerifyHmacOptions, type VerifyJwtResult, 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, channelConfigReaders, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFileCredentialStore, createFilePairingStore, createTokenCache, createWebhookHandler, decodeJwt, defaultStrategy, groupActivationHook, helpText, isAuthenticatedSender, jwksKeySet, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, refuseUnsupportedAttachments, reportDiagnostic, safeEqualString, scanFences, scopedStrategy, selectVariant, sendErrorFromHttp, senderKey, splitKeepingRows, statusForDeliver, toDialect, verifyDigest, verifyHmac, verifyRs256Jwt, withMediaUnderstanding };
2875
+ export { type AccessPolicyMessages, 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 ChannelConfigInput, type ChannelConfigReaders, type ChannelDeps, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChatCommand, type ChunkByGraphemeOptions, type ChunkTextOptions, type ClickClackMessageEvent, type ConnectFailure, type CoveredShape, type CreateChannelsResult, type CredentialStore, DEFAULT_WEBHOOK_MAX_BYTES, type DecodedJwt, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DigestEncoding, type DiscordMessageEvent, type DmPolicy, type DmScope, type EmailMessageEvent, type EnvConfig, type EnvOptions, type FeishuLarkMessageEvent, type FenceRegion, type FetchedToken, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type GroupActivationMode, type GroupActivationOptions, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type InboundAudio, type InboundImage, type IngestResult, type IrcMessageEvent, type JsonRpcChild, JsonRpcLineClient, type JwksKeySet, type JwksKeySetOptions, type JwksLookup, 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, ReconnectBackoff, type ReconnectBackoffOptions, type ReconnectPolicy, type ReportDiagnosticOptions, type RpcNotification, type RpcOutcome, type SMSMessageEvent, type ScopedStrategyOptions, SeenIds, type SendError, type SendErrorCode, type SendResult, type SenderIdentity, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type SplitKeepingRowsOptions, type StartResult, type SynologyChatMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type TlonUrbitMessageEvent, type TokenCache, type TokenCacheOptions, type TwitchMessageEvent, type UncoveredShape, type VerifyHmacOptions, type VerifyJwtResult, 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, channelConfigReaders, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFileCredentialStore, createFilePairingStore, createTokenCache, createWebhookHandler, decodeJwt, defaultStrategy, groupActivationHook, helpText, isAuthenticatedSender, jwksKeySet, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, refuseUnsupportedAttachments, reportDiagnostic, safeEqualString, scanFences, scopedStrategy, selectVariant, sendErrorFromHttp, senderKey, splitKeepingRows, statusForDeliver, toDialect, verifyDigest, verifyHmac, verifyRs256Jwt, withMediaUnderstanding };
package/dist/index.d.ts CHANGED
@@ -396,6 +396,24 @@ interface InboundAudio {
396
396
  /** The length in whole seconds the platform reported; 0 when it reported none. */
397
397
  readonly durationSeconds: number;
398
398
  }
399
+ /**
400
+ * An image an inbound message carries: read on demand, like {@link InboundAudio}, so an app whose
401
+ * `pre_inbound` hook refuses a sender never downloads the sender's media.
402
+ *
403
+ * Nothing is fetched until `read()` is called. The first call fetches; later calls return the
404
+ * same bytes. `read()` rejects when the platform cannot deliver them (the error message is safe
405
+ * to log: it never carries a credential).
406
+ */
407
+ interface InboundImage {
408
+ /** The image bytes, fetched on the first call and cached. */
409
+ read(): Promise<Uint8Array>;
410
+ /** The length in bytes the platform reported before any download; absent when it reported none. */
411
+ readonly size?: number;
412
+ /** The media type of the bytes, such as `image/png`. */
413
+ readonly mediaType: string;
414
+ /** The file name the sender's client gave; absent when the platform reported none. */
415
+ readonly filename?: string;
416
+ }
399
417
  /** Fields common to every platform's inbound event. */
400
418
  interface BaseMessageEvent {
401
419
  /** Stable id used as a session-key segment and for dedup. */
@@ -441,6 +459,11 @@ interface BaseMessageEvent {
441
459
  * and for a voice the adapter could not read.
442
460
  */
443
461
  readonly audio?: InboundAudio;
462
+ /**
463
+ * The images the message carries, in the order the platform lists them. Absent for a message
464
+ * with none, and on an adapter that does not read them.
465
+ */
466
+ readonly images?: readonly InboundImage[];
444
467
  }
445
468
  /** Telegram-specific event variant. */
446
469
  interface TelegramMessageEvent extends BaseMessageEvent {
@@ -2849,4 +2872,4 @@ declare function verifyDigest(opts: {
2849
2872
  prefix?: string;
2850
2873
  }): boolean;
2851
2874
 
2852
- export { type AccessPolicyMessages, 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 ChannelConfigInput, type ChannelConfigReaders, type ChannelDeps, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChatCommand, type ChunkByGraphemeOptions, type ChunkTextOptions, type ClickClackMessageEvent, type ConnectFailure, type CoveredShape, type CreateChannelsResult, type CredentialStore, DEFAULT_WEBHOOK_MAX_BYTES, type DecodedJwt, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DigestEncoding, type DiscordMessageEvent, type DmPolicy, type DmScope, type EmailMessageEvent, type EnvConfig, type EnvOptions, type FeishuLarkMessageEvent, type FenceRegion, type FetchedToken, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type GroupActivationMode, type GroupActivationOptions, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type InboundAudio, type IngestResult, type IrcMessageEvent, type JsonRpcChild, JsonRpcLineClient, type JwksKeySet, type JwksKeySetOptions, type JwksLookup, 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, ReconnectBackoff, type ReconnectBackoffOptions, type ReconnectPolicy, type ReportDiagnosticOptions, type RpcNotification, type RpcOutcome, type SMSMessageEvent, type ScopedStrategyOptions, SeenIds, type SendError, type SendErrorCode, type SendResult, type SenderIdentity, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type SplitKeepingRowsOptions, type StartResult, type SynologyChatMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type TlonUrbitMessageEvent, type TokenCache, type TokenCacheOptions, type TwitchMessageEvent, type UncoveredShape, type VerifyHmacOptions, type VerifyJwtResult, 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, channelConfigReaders, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFileCredentialStore, createFilePairingStore, createTokenCache, createWebhookHandler, decodeJwt, defaultStrategy, groupActivationHook, helpText, isAuthenticatedSender, jwksKeySet, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, refuseUnsupportedAttachments, reportDiagnostic, safeEqualString, scanFences, scopedStrategy, selectVariant, sendErrorFromHttp, senderKey, splitKeepingRows, statusForDeliver, toDialect, verifyDigest, verifyHmac, verifyRs256Jwt, withMediaUnderstanding };
2875
+ export { type AccessPolicyMessages, 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 ChannelConfigInput, type ChannelConfigReaders, type ChannelDeps, type ChannelDescriptor, type ChannelEntry, type ChannelRejection, type ChannelRendering, type ChannelWebhook, type ChatCommand, type ChunkByGraphemeOptions, type ChunkTextOptions, type ClickClackMessageEvent, type ConnectFailure, type CoveredShape, type CreateChannelsResult, type CredentialStore, DEFAULT_WEBHOOK_MAX_BYTES, type DecodedJwt, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DigestEncoding, type DiscordMessageEvent, type DmPolicy, type DmScope, type EmailMessageEvent, type EnvConfig, type EnvOptions, type FeishuLarkMessageEvent, type FenceRegion, type FetchedToken, GatewayConfigurationError, type GatewayConfigurationErrorOptions, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayLifecycleError, type GatewayLifecycleErrorOptions, GatewayRunner, type GatewayRunnerOptions, type GoogleChatMessageEvent, type GroupActivationMode, type GroupActivationOptions, type HookDecision, HookExecutor, type HookName, type IMessageMessageEvent, type InboundAudio, type InboundImage, type IngestResult, type IrcMessageEvent, type JsonRpcChild, JsonRpcLineClient, type JwksKeySet, type JwksKeySetOptions, type JwksLookup, 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, ReconnectBackoff, type ReconnectBackoffOptions, type ReconnectPolicy, type ReportDiagnosticOptions, type RpcNotification, type RpcOutcome, type SMSMessageEvent, type ScopedStrategyOptions, SeenIds, type SendError, type SendErrorCode, type SendResult, type SenderIdentity, SessionRouter, type SignalMessageEvent, type SlackMessageEvent, type SplitKeepingRowsOptions, type StartResult, type SynologyChatMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type TlonUrbitMessageEvent, type TokenCache, type TokenCacheOptions, type TwitchMessageEvent, type UncoveredShape, type VerifyHmacOptions, type VerifyJwtResult, 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, channelConfigReaders, channelRendering, chunkByGrapheme, chunkText, commandHook, configFromEnv, createAccessPolicyHook, createAgentBindings, createChannels, createFileCredentialStore, createFilePairingStore, createTokenCache, createWebhookHandler, decodeJwt, defaultStrategy, groupActivationHook, helpText, isAuthenticatedSender, jwksKeySet, listenerLifecycle, loadPeer, maskSecrets, maskShapes, parseChatCommand, parseFlatXml, rawBodyCapture, redactSecrets, refuseUnsupportedAttachments, reportDiagnostic, safeEqualString, scanFences, scopedStrategy, selectVariant, sendErrorFromHttp, senderKey, splitKeepingRows, statusForDeliver, toDialect, verifyDigest, verifyHmac, verifyRs256Jwt, withMediaUnderstanding };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopzero-gateway",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Multi-platform messaging gateway core for loopzero-sdk — transport-agnostic primitives (BasePlatformAdapter, MessageEvent, SessionRouter, DeliveryRouter, GatewayRunner, hooks). Inspired by hermes-agent/gateway. ADRs D170-D181.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {