@relaymessenger/chat-sdk-adapter 0.2.1 → 0.3.0-staging.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.
Files changed (69) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +185 -98
  3. package/dist/adapter.d.ts +121 -0
  4. package/dist/adapter.d.ts.map +1 -0
  5. package/dist/adapter.js +643 -0
  6. package/dist/adapter.js.map +1 -0
  7. package/dist/client.d.ts +64 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +230 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/content.d.ts +11 -0
  12. package/dist/content.d.ts.map +1 -0
  13. package/dist/content.js +172 -0
  14. package/dist/content.js.map +1 -0
  15. package/dist/credentials.d.ts +13 -0
  16. package/dist/credentials.d.ts.map +1 -0
  17. package/dist/credentials.js +28 -0
  18. package/dist/credentials.js.map +1 -0
  19. package/dist/index.d.ts +17 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +10 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/reactions.d.ts +15 -0
  24. package/dist/reactions.d.ts.map +1 -0
  25. package/dist/reactions.js +58 -0
  26. package/dist/reactions.js.map +1 -0
  27. package/dist/signature.d.ts +22 -0
  28. package/dist/signature.d.ts.map +1 -0
  29. package/dist/signature.js +98 -0
  30. package/dist/signature.js.map +1 -0
  31. package/dist/thread-id.d.ts +8 -0
  32. package/dist/thread-id.d.ts.map +1 -0
  33. package/dist/thread-id.js +27 -0
  34. package/dist/thread-id.js.map +1 -0
  35. package/dist/turn.d.ts +16 -0
  36. package/dist/turn.d.ts.map +1 -0
  37. package/dist/turn.js +22 -0
  38. package/dist/turn.js.map +1 -0
  39. package/dist/types.d.ts +177 -0
  40. package/dist/types.d.ts.map +1 -0
  41. package/dist/types.js +27 -0
  42. package/dist/types.js.map +1 -0
  43. package/dist/webhook.d.ts +9 -0
  44. package/dist/webhook.d.ts.map +1 -0
  45. package/dist/webhook.js +115 -0
  46. package/dist/webhook.js.map +1 -0
  47. package/package.json +51 -32
  48. package/dist/src/adapter.d.ts +0 -125
  49. package/dist/src/adapter.js +0 -724
  50. package/dist/src/chunk.d.ts +0 -25
  51. package/dist/src/chunk.js +0 -108
  52. package/dist/src/client.d.ts +0 -112
  53. package/dist/src/client.js +0 -180
  54. package/dist/src/format.d.ts +0 -43
  55. package/dist/src/format.js +0 -266
  56. package/dist/src/idempotency.d.ts +0 -50
  57. package/dist/src/idempotency.js +0 -75
  58. package/dist/src/index.d.ts +0 -14
  59. package/dist/src/index.js +0 -8
  60. package/dist/src/reactions.d.ts +0 -12
  61. package/dist/src/reactions.js +0 -98
  62. package/dist/src/signature.d.ts +0 -46
  63. package/dist/src/signature.js +0 -95
  64. package/dist/src/threadId.d.ts +0 -12
  65. package/dist/src/threadId.js +0 -28
  66. package/dist/src/turn.d.ts +0 -38
  67. package/dist/src/turn.js +0 -15
  68. package/dist/src/types.d.ts +0 -177
  69. package/dist/src/types.js +0 -7
package/LICENSE CHANGED
@@ -5,9 +5,9 @@ Copyright (c) 2026 Companion Inc.
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
7
7
  in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
11
 
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
package/README.md CHANGED
@@ -1,10 +1,19 @@
1
1
  # @relaymessenger/chat-sdk-adapter
2
2
 
3
- Relay adapter for the [Vercel Chat SDK](https://chat-sdk.dev). Relay is a
4
- consumer messenger where people talk to agents the way they talk to contacts;
5
- this package makes a Relay conversation a Chat SDK thread, so anything built on
6
- the Chat SDK can reach Relay users. Raw HTTPS remains the canonical contract;
7
- this is a thin, dependency-free binding of it.
3
+ Vendor-official Relay adapter for
4
+ [Vercel Chat SDK](https://chat-sdk.dev), targeting `chat@4.39.0`.
5
+
6
+ Relay Chats map one-to-one to Chat SDK threads. Provider thread IDs are stable
7
+ `relay:<chat UUID>` values; provider message IDs are bare Relay Message UUIDs.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install chat@4.39.0 @chat-adapter/state-memory@4.39.0 \
13
+ @relaymessenger/chat-sdk-adapter
14
+ ```
15
+
16
+ ## Minimal use
8
17
 
9
18
  ```ts
10
19
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -12,11 +21,11 @@ import { createRelayAdapter } from "@relaymessenger/chat-sdk-adapter";
12
21
  import { Chat } from "chat";
13
22
 
14
23
  const chat = new Chat({
15
- userName: "My Agent",
24
+ userName: "My Relay Agent",
16
25
  adapters: {
17
26
  relay: createRelayAdapter({
18
- token: process.env.RELAY_AGENT_TOKEN!,
19
- webhookSecret: process.env.RELAY_WEBHOOK_SECRET!,
27
+ token: process.env.RELAY_AGENT_TOKEN,
28
+ webhookSecret: process.env.RELAY_WEBHOOK_SECRET,
20
29
  }),
21
30
  },
22
31
  state: createMemoryState(),
@@ -24,98 +33,176 @@ const chat = new Chat({
24
33
 
25
34
  chat.onNewMention(async (thread, message) => {
26
35
  await thread.subscribe();
27
- await thread.post({ markdown: `You said: ${message.text}` });
36
+ await thread.post(`You said: ${message.text}`);
28
37
  });
29
38
 
30
- // Mount as a POST route.
39
+ // Mount this on the Relay webhook URL.
31
40
  export const POST = (request: Request) => chat.webhooks.relay(request);
32
41
  ```
33
42
 
34
- `chat` is a peer dependency: install it alongside this package.
35
-
36
- ## With eve
37
-
38
- eve's Chat SDK channel bridges any adapter to an agent. See
39
- [`examples/eve`](../../examples/eve) in this repository for the channel file and
40
- the environment it needs.
41
-
42
- ## What the adapter enforces
43
-
44
- - Standard Webhooks signature verification over the exact raw body, then
45
- `event_id` deduplication, because Relay delivers at least once. The event id
46
- is claimed before the handler runs, so two redeliveries racing each other
47
- cannot both dispatch, and released again if the handler throws, so Relay's
48
- retry of a failed turn is still handled. **This window is a bounded set in
49
- memory, in one process.** A restart, or a second instance behind the same
50
- webhook URL, has no claim to lose and will dispatch the event again. The
51
- idempotency key below is what makes that second dispatch harmless.
52
- - A deterministic `Idempotency-Key` on every `POST /v1/messages`, derived from
53
- the inbound event id and the send's position in the turn, and from nothing
54
- else. Relay hashes the request body server side and stores it beside the key,
55
- so a retry carrying the same body replays the first response and a retry
56
- carrying a different body is refused with 409 `idempotency_conflict`. Keeping
57
- the content out of the key is what leaves both of those reachable: a key that
58
- moved with the body would make every retry a new send, and a handler backed
59
- by a model rarely writes the same words twice.
60
- - Group `invocation_id` threading. Relay delivers a group message to an agent
61
- only when that agent was invoked, and the reply is scoped to that single-use
62
- invocation, so the first send of a turn carries it and a second raises
63
- `RelayInvocationSpentError` rather than going out bare and taking a 403.
64
- - Chunking rather than truncation. Relay caps a text part at 8 KB and a message
65
- at 32 parts; a longer reply becomes more parts, and then more messages. Each
66
- text part draws as its own balloon in the app, so a long reply arrives as a
67
- stack of bubbles rather than one tall one. A split consumes the whitespace it
68
- lands on, and nothing else.
69
-
70
- ## Formatting
71
-
72
- Relay does not render Markdown. A text part carries canonical plain text plus
73
- `styles` runs with UTF-16 offsets, and clients draw the runs. So `{ markdown }`
74
- and `{ ast }` are flattened to the text a person reads, with emphasis carried
75
- across as style ranges: `strong` becomes `bold`, `emphasis` becomes `italic`,
76
- `delete` becomes `strikethrough`, and inline or fenced code becomes `monospace`.
77
-
78
- Constructs Relay has no style for keep their information in the text rather than
79
- losing it. A link whose label differs from its target renders as `label (url)`,
80
- a blockquote keeps its `> ` line prefix, a list keeps its markers, and a table is
81
- drawn as a monospace ASCII grid. A plain string is sent verbatim with an empty
82
- `styles` array, which is Relay's marker for structured plain text rather than a
83
- legacy Markdown body.
84
-
85
- ## Capabilities
86
-
87
- | Chat SDK operation | Relay |
88
- | --------------------------------- | ---------------------------------------------------------------- |
89
- | `postMessage`, `editMessage`, `deleteMessage` | `POST /v1/messages`, `PATCH` and `DELETE /v1/messages/{id}` |
90
- | `addReaction`, `removeReaction` | `POST /v1/messages/{id}/reactions` |
91
- | `startTyping` | `POST /v1/conversations/{id}/typing`, ephemeral, 80-char label |
92
- | `markAsRead` | `POST /v1/conversations/{id}/read` |
93
- | `fetchMessages`, `fetchThread` | `GET /v1/conversations/{id}/messages` and `/v1/conversations/{id}` |
94
- | `getUser` | `GET /v1/users/{id}`, scoped to a shared conversation |
95
- | `stream` | Buffered, then committed as one message |
96
-
97
- Things Relay does not do, stated rather than faked:
98
-
99
- - **No streaming bubbles.** A turn commits exactly one canonical message, so
100
- `stream` buffers the whole reply and posts it once. Nothing partial reaches a
101
- recipient. With eve's Chat SDK channel, set `streaming: false`.
102
- - **No forward history cursor.** `GET /v1/conversations/{id}/messages` pages
103
- backwards with `before_sequence`, so `fetchMessages({ direction: "forward" })`
104
- throws `NotImplementedError` instead of walking the whole conversation.
105
- - **No agent-initiated DM.** `POST /v1/conversations/direct` accepts a user
106
- session, not an Agent Token, so `openDM` is not implemented. A conversation
107
- starts when a person adds the agent.
108
- - **No single-message read.** The API has no `GET /v1/messages/{id}`, so
109
- `fetchMessage` is not implemented and the Chat SDK returns `null`.
110
- - **No cards.** Relay removed interactive components. A card is delivered as its
111
- fallback text, so the words arrive but buttons do not render and a
112
- human-in-the-loop prompt cannot be answered in the app.
113
- - **No edits carrying media.** Relay requires an edit to stay text-bearing and
114
- rejects attachment parts.
115
-
116
- Attachments work in both directions. Inbound media and voice memo parts arrive as
117
- Chat SDK attachments; outbound attachments with a public HTTPS URL are sent as
118
- media parts, and outbound bytes are uploaded through `POST /v1/attachments`
119
- first.
120
-
121
- Docs: <https://docs.relayapp.im>.
43
+ An executable Node HTTP example is in [`examples/server.mjs`](examples/server.mjs).
44
+
45
+ ## Factory API
46
+
47
+ ```ts
48
+ type RelayCredential =
49
+ | string
50
+ | (() => string | Promise<string>);
51
+
52
+ interface RelayAdapterOptions {
53
+ token?: RelayCredential; // RELAY_AGENT_TOKEN fallback
54
+ webhookSecret?: RelayCredential; // RELAY_WEBHOOK_SECRET fallback
55
+ typing?: boolean; // default true
56
+ userName?: string; // default "Relay Agent"
57
+ agentId?: string; // this agent's Relay Contact UUID
58
+ baseUrl?: string; // default https://api.relayapp.im
59
+ fetch?: typeof fetch;
60
+ client?: RelayClient;
61
+ signatureToleranceSeconds?: number; // default 300
62
+ idempotencyKeyResolver?: (context: {
63
+ chatId: string;
64
+ threadId: string;
65
+ parts: readonly RelayOutgoingPart[];
66
+ replyToMessageId?: string;
67
+ }) => string | Promise<string>;
68
+ }
69
+
70
+ createRelayAdapter(options?: RelayAdapterOptions): RelayAdapter;
71
+ ```
72
+
73
+ Credential functions satisfy Vercel's vendor-official non-static credential
74
+ requirement. The token resolver is called for every Relay API request. The
75
+ webhook-secret resolver is called for every webhook delivery. Values are not
76
+ cached.
77
+
78
+ Every send caused by an inbound webhook carries
79
+ `Idempotency-Key: relay-chat-sdk:<event_id>:<send ordinal>`. A redelivery starts
80
+ at ordinal zero again, so the same event/body replays while changed recovery
81
+ content reaches Relay under the same key and receives the contract's 409
82
+ `idempotency_conflict`. This context uses `AsyncLocalStorage` only for the
83
+ active turn and is never persisted.
84
+
85
+ Posts made outside an inbound webhook have no Relay `event_id`. The adapter
86
+ therefore requires `idempotencyKeyResolver` for those non-empty posts rather
87
+ than manufacturing a random key that changes on recovery. Think integrations
88
+ should return their stable Action/delivery identity from this resolver.
89
+
90
+ ### Think runtime typing
91
+
92
+ For a runtime that owns typing timing, disable Chat SDK surface typing:
93
+
94
+ ```ts
95
+ const relay = createRelayAdapter({
96
+ token,
97
+ webhookSecret,
98
+ typing: false,
99
+ });
100
+ ```
101
+
102
+ With `typing: false`, both `startTyping()` and `endTyping()` validate the thread
103
+ ID but make no Relay request. This prevents Think's pre-inference
104
+ `ChatThread.startTyping()` from surfacing. Other adapter instances default to
105
+ normal `POST`/`DELETE /v1/chats/{chatId}/typing` support.
106
+
107
+ ## Locked contract
108
+
109
+ This repository was rewritten against:
110
+
111
+ - Relay Server `9b4d5bb32cc749c6fd271969948c385300d404d6`
112
+ - OpenAPI SHA-256
113
+ `f62f431fc0daa48500926bf87753f81c3fdda25ab463b130ca97f2896367e0a5`
114
+ - Relay API `v1`
115
+ - Relay webhook payload version `2026-08-30`
116
+ - `chat@4.39.0`
117
+
118
+ The exact OpenAPI snapshot is retained under `contracts/` for reproducible
119
+ contract tests and is excluded from the npm package.
120
+
121
+ ## Supported surface
122
+
123
+ | Chat SDK operation | Locked Relay v1 operation |
124
+ | --- | --- |
125
+ | `postMessage`, `postChannelMessage` | `POST /v1/chats/{chatId}/messages` |
126
+ | `reply` | Same route with `message.reply_to` |
127
+ | `stream` | Buffered, then one canonical Message; never partial bubbles |
128
+ | outbound public-URL media | Message `media` part |
129
+ | outbound bytes/files | Explicitly allocate/upload with `@relaymessenger/sdk`, then post a stable public HTTPS URL |
130
+ | inbound media | Chat SDK `Attachment` |
131
+ | `addReaction`, `removeReaction` | `POST /v1/messages/{messageId}/reactions` |
132
+ | `startTyping`, `endTyping` | `POST`/`DELETE /v1/chats/{chatId}/typing` |
133
+ | `markAsRead` | `POST /v1/chats/{chatId}/read` |
134
+ | `fetchMessages({ direction: "forward" })` | `GET /v1/chats/{chatId}/messages` |
135
+ | `fetchMessage` | `GET /v1/messages/{messageId}` |
136
+ | `fetchThread`, `fetchChannelInfo` | `GET /v1/chats/{chatId}` |
137
+
138
+ Relay text parts are plain text and are limited to 10,000 UTF-16 code units.
139
+ Long Chat SDK text is split without breaking surrogate pairs. A Relay Message
140
+ is limited to 100 parts. A public HTTPS attachment URL is sent directly.
141
+ Automatic byte/file uploads are rejected because a fresh Attachment allocation
142
+ would change the Message body after an ambiguous send. Allocate and upload with
143
+ `@relaymessenger/sdk`, retain that prepared identity durably, then give this
144
+ adapter the stable HTTPS URL.
145
+
146
+ Think's `thread.post(callback.stream())` path is safe when the stream is empty:
147
+ the adapter returns a local no-op result so Chat SDK does not enter its
148
+ post-then-edit fallback. Non-empty streams are fully buffered and committed in
149
+ one request. Empty string posts are the same no-op. No partial or placeholder
150
+ Message reaches Relay.
151
+
152
+ ## Explicitly unsupported
153
+
154
+ The adapter throws Chat SDK `NotImplementedError` rather than calling an
155
+ undocumented route for:
156
+
157
+ - message editing and deletion;
158
+ - editable drafts or partial streaming bubbles;
159
+ - open-only direct messages;
160
+ - public Contact lookup;
161
+ - backward history pagination.
162
+
163
+ Relay's locked chat-history cursor advances oldest-to-newest. It cannot satisfy
164
+ Chat SDK's backward-cursor semantics, so callers must request
165
+ `direction: "forward"` explicitly.
166
+
167
+ Cards have no Relay interaction surface. Their fallback text is sent; a card
168
+ without text is rejected.
169
+
170
+ ## Webhooks
171
+
172
+ The adapter internally verifies current signed Standard Webhooks over the exact
173
+ raw body:
174
+
175
+ ```text
176
+ HMAC-SHA256(secret, "${webhook-id}.${webhook-timestamp}.${rawBody}")
177
+ ```
178
+
179
+ Every valid current event type is acknowledged. `message.received` is
180
+ dispatched to Chat SDK message handlers, and non-self `reaction.added` /
181
+ `reaction.removed` events are dispatched to reaction handlers. Receipt,
182
+ participant, Chat metadata, typing, and Contact events have no matching Chat
183
+ SDK inbound hook and are acknowledged without fabricated behavior.
184
+
185
+ Direct Chats route through Chat SDK's direct-message path and do not need an
186
+ `isMention` flag. In a group, `isMention` is true only when a canonical text
187
+ part's `mention` equals the receiving Chat `owner_handle`; when `agentId` is
188
+ configured, the owner UUID must match it.
189
+
190
+ This package adds no persistence and no adapter-owned delivery-idempotency
191
+ store. Think Actions remain the delivery-idempotency owner outside webhook
192
+ turns. `RelayClient.sendMessage()` requires an explicit idempotency key.
193
+
194
+ ## Development
195
+
196
+ ```sh
197
+ npm ci
198
+ npm run check
199
+ npm run build
200
+ npm run test:unit
201
+ npm run test:workerd
202
+ npm run test:installed
203
+ ```
204
+
205
+ `@chat-adapter/shared@4.39.0` provides shared adapter utilities and errors. That
206
+ published package has no `/tests` export; Vercel's published contract runner is
207
+ `@chat-adapter/tests@4.39.0`, which this repository uses alongside
208
+ `@chat-adapter/shared`.
@@ -0,0 +1,121 @@
1
+ import { Message, type Adapter, type AdapterPostableMessage, type ChatInstance, type EmojiValue, type FetchOptions, type FetchResult, type FormattedContent, type RawMessage, type StreamChunk, type ThreadInfo, type UserInfo, type WebhookOptions } from "chat";
2
+ import { RelayClient } from "./client.js";
3
+ import type { RelayClientOptions } from "./client.js";
4
+ import { type RelayCredential } from "./credentials.js";
5
+ import type { RelayRawMessage, RelayThreadId } from "./types.js";
6
+ export declare const RELAY_ADAPTER_NAME = "relay";
7
+ export interface RelayIdempotencyKeyContext {
8
+ chatId: string;
9
+ parts: ReadonlyArray<import("./types.js").RelayOutgoingPart>;
10
+ replyToMessageId?: string;
11
+ threadId: string;
12
+ }
13
+ export type RelayIdempotencyKeyResolver = (context: RelayIdempotencyKeyContext) => string | Promise<string>;
14
+ export interface RelayAdapterOptions extends Omit<RelayClientOptions, "token"> {
15
+ /**
16
+ * Relay Agent Token or per-call resolver.
17
+ * Defaults to `RELAY_AGENT_TOKEN`.
18
+ */
19
+ token?: RelayCredential;
20
+ /**
21
+ * Standard Webhooks signing secret or per-delivery resolver.
22
+ * Defaults to `RELAY_WEBHOOK_SECRET`.
23
+ */
24
+ webhookSecret?: RelayCredential;
25
+ /**
26
+ * Disable Chat SDK surface typing for runtimes that own typing UX.
27
+ * Defaults to true.
28
+ */
29
+ typing?: boolean;
30
+ /** Display name shown to Chat SDK handlers. */
31
+ userName?: string;
32
+ /** This Relay agent Contact UUID, when known. */
33
+ agentId?: string;
34
+ /** Standard Webhooks timestamp tolerance in seconds. */
35
+ signatureToleranceSeconds?: number;
36
+ /**
37
+ * Stable key source for posts made outside an inbound webhook turn.
38
+ * Inbound turns always derive keys from event_id plus send ordinal.
39
+ */
40
+ idempotencyKeyResolver?: RelayIdempotencyKeyResolver;
41
+ /** Controlled client injection for tests and custom transports. */
42
+ client?: RelayClient;
43
+ }
44
+ /**
45
+ * Relay adapter for `chat@4.39.0`, limited to the locked public v1 contract.
46
+ */
47
+ export declare class RelayAdapter implements Adapter<RelayThreadId, RelayRawMessage> {
48
+ readonly name = "relay";
49
+ readonly userName: string;
50
+ readonly botUserId?: string;
51
+ readonly lockScope: "thread";
52
+ readonly persistThreadHistory = false;
53
+ readonly typing: boolean;
54
+ readonly client: RelayClient;
55
+ private readonly signatureToleranceSeconds?;
56
+ private readonly webhookSecret;
57
+ private readonly idempotencyKeyResolver;
58
+ private readonly turns;
59
+ /**
60
+ * Request-scoped Chat kind hints. Entries exist only while an inbound
61
+ * dispatch is active; this is not persistence or a delivery-idempotency
62
+ * store.
63
+ */
64
+ private readonly activeChatKinds;
65
+ private chat?;
66
+ constructor(options?: RelayAdapterOptions);
67
+ initialize(chat: ChatInstance): Promise<void>;
68
+ encodeThreadId(data: RelayThreadId): string;
69
+ decodeThreadId(threadId: string): RelayThreadId;
70
+ channelIdFromThreadId(threadId: string): string;
71
+ renderFormatted(content: FormattedContent): string;
72
+ parseMessage(raw: RelayRawMessage): Message<RelayRawMessage>;
73
+ private unsupported;
74
+ private send;
75
+ private sendInTurn;
76
+ private resolveExternalIdempotencyKey;
77
+ private noopResult;
78
+ private isMentioned;
79
+ private enterChatKind;
80
+ /**
81
+ * Chat SDK asks synchronously while dispatching. Relay's stable thread ID
82
+ * intentionally contains only the Chat UUID, so the direct/group hint is
83
+ * scoped to the active webhook dispatch and never persisted.
84
+ */
85
+ isDM(threadId: string): boolean;
86
+ postMessage(threadId: string, message: AdapterPostableMessage): Promise<RawMessage<RelayRawMessage>>;
87
+ postChannelMessage(channelId: string, message: AdapterPostableMessage): Promise<RawMessage<RelayRawMessage>>;
88
+ reply(threadId: string, messageId: string, message: AdapterPostableMessage): Promise<RawMessage<RelayRawMessage>>;
89
+ editMessage(threadId: string, messageId: string, _message: AdapterPostableMessage): Promise<RawMessage<RelayRawMessage>>;
90
+ deleteMessage(threadId: string, messageId: string): Promise<void>;
91
+ addReaction(threadId: string, messageId: string, emoji: EmojiValue | string): Promise<void>;
92
+ removeReaction(threadId: string, messageId: string, emoji: EmojiValue | string): Promise<void>;
93
+ startTyping(threadId: string): Promise<void>;
94
+ endTyping(threadId: string): Promise<void>;
95
+ markAsRead(threadId: string, messageId: string): Promise<void>;
96
+ /**
97
+ * Relay's public chat cursor advances oldest-to-newest. Chat SDK's backward
98
+ * cursor contract cannot be represented, so only explicit forward reads are
99
+ * supported rather than faking backward pagination.
100
+ */
101
+ fetchMessages(threadId: string, options?: FetchOptions): Promise<FetchResult<RelayRawMessage>>;
102
+ fetchChannelMessages(channelId: string, options?: FetchOptions): Promise<FetchResult<RelayRawMessage>>;
103
+ fetchMessage(threadId: string, messageId: string): Promise<Message<RelayRawMessage> | null>;
104
+ fetchThread(threadId: string): Promise<ThreadInfo>;
105
+ fetchChannelInfo(channelId: string): Promise<{
106
+ channelVisibility: import("chat").ChannelVisibility | undefined;
107
+ id: string;
108
+ isDM: boolean | undefined;
109
+ metadata: Record<string, unknown>;
110
+ name?: string | undefined;
111
+ }>;
112
+ getChannelVisibility(): "private";
113
+ getUser(_userId: string): Promise<UserInfo | null>;
114
+ openDM(_userId: string): Promise<string>;
115
+ stream(threadId: string, stream: AsyncIterable<string | StreamChunk>): Promise<RawMessage<RelayRawMessage> | null>;
116
+ handleWebhook(request: Request, options?: WebhookOptions): Promise<Response>;
117
+ private initializedChat;
118
+ private dispatch;
119
+ }
120
+ export declare function createRelayAdapter(options?: RelayAdapterOptions): RelayAdapter;
121
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EAMP,KAAK,OAAO,EACZ,KAAK,sBAAsB,EAE3B,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,g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