@xmtp/agent-sdk 1.2.4 → 1.2.5-rc1

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 (73) hide show
  1. package/dist/debug.d.ts +141 -1
  2. package/dist/debug.js +85 -2
  3. package/dist/debug.js.map +1 -1
  4. package/dist/index.d.ts +176 -4
  5. package/dist/index.js +703 -5
  6. package/dist/index.js.map +1 -1
  7. package/dist/middleware.d.ts +81 -1
  8. package/dist/middleware.js +59 -2
  9. package/dist/middleware.js.map +1 -1
  10. package/dist/user.d.ts +16 -1
  11. package/dist/user.js +111 -2
  12. package/dist/user.js.map +1 -1
  13. package/dist/util.d.ts +46 -1
  14. package/dist/util.js +74 -2
  15. package/dist/util.js.map +1 -1
  16. package/package.json +14 -21
  17. package/dist/bin/generateKeys.d.ts +0 -2
  18. package/dist/bin/generateKeys.js +0 -44
  19. package/dist/bin/generateKeys.js.map +0 -1
  20. package/dist/core/Agent.d.ts +0 -84
  21. package/dist/core/Agent.js +0 -394
  22. package/dist/core/Agent.js.map +0 -1
  23. package/dist/core/AgentError.d.ts +0 -7
  24. package/dist/core/AgentError.js +0 -13
  25. package/dist/core/AgentError.js.map +0 -1
  26. package/dist/core/ClientContext.d.ts +0 -9
  27. package/dist/core/ClientContext.js +0 -13
  28. package/dist/core/ClientContext.js.map +0 -1
  29. package/dist/core/ConversationContext.d.ts +0 -19
  30. package/dist/core/ConversationContext.js +0 -43
  31. package/dist/core/ConversationContext.js.map +0 -1
  32. package/dist/core/MessageContext.d.ts +0 -33
  33. package/dist/core/MessageContext.js +0 -75
  34. package/dist/core/MessageContext.js.map +0 -1
  35. package/dist/core/filter.d.ts +0 -84
  36. package/dist/core/filter.js +0 -88
  37. package/dist/core/filter.js.map +0 -1
  38. package/dist/core/index.d.ts +0 -6
  39. package/dist/core/index.js +0 -7
  40. package/dist/core/index.js.map +0 -1
  41. package/dist/debug/index.d.ts +0 -1
  42. package/dist/debug/index.js +0 -2
  43. package/dist/debug/index.js.map +0 -1
  44. package/dist/debug/log.d.ts +0 -18
  45. package/dist/debug/log.js +0 -80
  46. package/dist/debug/log.js.map +0 -1
  47. package/dist/middleware/CommandRouter.d.ts +0 -14
  48. package/dist/middleware/CommandRouter.js +0 -57
  49. package/dist/middleware/CommandRouter.js.map +0 -1
  50. package/dist/middleware/index.d.ts +0 -1
  51. package/dist/middleware/index.js +0 -2
  52. package/dist/middleware/index.js.map +0 -1
  53. package/dist/user/NameResolver.d.ts +0 -1
  54. package/dist/user/NameResolver.js +0 -45
  55. package/dist/user/NameResolver.js.map +0 -1
  56. package/dist/user/User.d.ts +0 -10
  57. package/dist/user/User.js +0 -35
  58. package/dist/user/User.js.map +0 -1
  59. package/dist/user/index.d.ts +0 -2
  60. package/dist/user/index.js +0 -3
  61. package/dist/user/index.js.map +0 -1
  62. package/dist/util/AttachmentUtil.d.ts +0 -41
  63. package/dist/util/AttachmentUtil.js +0 -67
  64. package/dist/util/AttachmentUtil.js.map +0 -1
  65. package/dist/util/LimitedMap.d.ts +0 -6
  66. package/dist/util/LimitedMap.js +0 -20
  67. package/dist/util/LimitedMap.js.map +0 -1
  68. package/dist/util/TestUtil.d.ts +0 -35
  69. package/dist/util/TestUtil.js +0 -83
  70. package/dist/util/TestUtil.js.map +0 -1
  71. package/dist/util/index.d.ts +0 -1
  72. package/dist/util/index.js +0 -2
  73. package/dist/util/index.js.map +0 -1
@@ -1,84 +0,0 @@
1
- import EventEmitter from "node:events";
2
- import type { GroupUpdatedCodec } from "@xmtp/content-type-group-updated";
3
- import { MarkdownCodec } from "@xmtp/content-type-markdown";
4
- import type { ContentCodec } from "@xmtp/content-type-primitives";
5
- import { ReactionCodec } from "@xmtp/content-type-reaction";
6
- import { ReadReceiptCodec } from "@xmtp/content-type-read-receipt";
7
- import { AttachmentCodec, RemoteAttachmentCodec } from "@xmtp/content-type-remote-attachment";
8
- import { ReplyCodec } from "@xmtp/content-type-reply";
9
- import type { TextCodec } from "@xmtp/content-type-text";
10
- import { TransactionReferenceCodec } from "@xmtp/content-type-transaction-reference";
11
- import { WalletSendCallsCodec } from "@xmtp/content-type-wallet-send-calls";
12
- import { Client, Dm, Group, type ClientOptions, type Conversation, type CreateDmOptions, type CreateGroupOptions, type DecodedMessage, type HexString, type StreamOptions } from "@xmtp/node-sdk";
13
- import { ClientContext } from "./ClientContext.js";
14
- import { ConversationContext } from "./ConversationContext.js";
15
- import { MessageContext } from "./MessageContext.js";
16
- type EventHandlerMap<ContentTypes> = {
17
- attachment: [
18
- ctx: MessageContext<ReturnType<RemoteAttachmentCodec["decode"]>>
19
- ];
20
- conversation: [ctx: ConversationContext<ContentTypes>];
21
- "group-update": [
22
- ctx: MessageContext<ReturnType<GroupUpdatedCodec["decode"]>>
23
- ];
24
- dm: [ctx: ConversationContext<ContentTypes, Dm<ContentTypes>>];
25
- group: [ctx: ConversationContext<ContentTypes, Group<ContentTypes>>];
26
- markdown: [ctx: MessageContext<ReturnType<MarkdownCodec["decode"]>>];
27
- message: [ctx: MessageContext<ContentTypes>];
28
- reaction: [ctx: MessageContext<ReturnType<ReactionCodec["decode"]>>];
29
- "read-receipt": [ctx: MessageContext<ReturnType<ReadReceiptCodec["decode"]>>];
30
- reply: [ctx: MessageContext<ReturnType<ReplyCodec["decode"]>>];
31
- start: [ctx: ClientContext<ContentTypes>];
32
- stop: [ctx: ClientContext<ContentTypes>];
33
- text: [ctx: MessageContext<ReturnType<TextCodec["decode"]>>];
34
- "transaction-reference": [
35
- ctx: MessageContext<ReturnType<TransactionReferenceCodec["decode"]>>
36
- ];
37
- unhandledError: [error: Error];
38
- unknownMessage: [ctx: MessageContext<ContentTypes>];
39
- "wallet-send-calls": [
40
- ctx: MessageContext<ReturnType<WalletSendCallsCodec["decode"]>>
41
- ];
42
- };
43
- type EthAddress = HexString;
44
- export type AgentBaseContext<ContentTypes = unknown> = {
45
- client: Client<ContentTypes>;
46
- conversation: Conversation;
47
- message: DecodedMessage;
48
- };
49
- export type AgentErrorContext<ContentTypes = unknown> = Partial<AgentBaseContext<ContentTypes>> & {
50
- client: Client<ContentTypes>;
51
- };
52
- export type AgentOptions<ContentTypes> = {
53
- client: Client<ContentTypes>;
54
- };
55
- export type AgentMessageHandler<ContentTypes = unknown> = (ctx: MessageContext<ContentTypes>) => Promise<void> | void;
56
- export type AgentMiddleware<ContentTypes = unknown> = (ctx: MessageContext<ContentTypes>, next: () => Promise<void> | void) => Promise<void>;
57
- export type AgentErrorMiddleware<ContentTypes = unknown> = (error: unknown, ctx: AgentErrorContext<ContentTypes>, next: (err?: unknown) => Promise<void> | void) => Promise<void> | void;
58
- export type AgentStreamingOptions = Omit<StreamOptions, "onValue" | "onError">;
59
- export type StreamAllMessagesOptions<ContentTypes> = Parameters<Client<ContentTypes>["conversations"]["streamAllMessages"]>[0];
60
- export type AgentErrorRegistrar<ContentTypes> = {
61
- use(...errorMiddleware: Array<AgentErrorMiddleware<ContentTypes> | AgentErrorMiddleware<ContentTypes>[]>): AgentErrorRegistrar<ContentTypes>;
62
- };
63
- export declare class Agent<ContentTypes = unknown> extends EventEmitter<EventHandlerMap<ContentTypes>> {
64
- #private;
65
- constructor({ client }: AgentOptions<ContentTypes>);
66
- static create<ContentCodecs extends ContentCodec[] = []>(signer: Parameters<typeof Client.create>[0], options?: Omit<ClientOptions, "codecs"> & {
67
- codecs?: ContentCodecs;
68
- }): Promise<Agent<import("@xmtp/node-sdk").ExtractCodecContentTypes<(ReactionCodec | ReplyCodec | RemoteAttachmentCodec | MarkdownCodec | ReadReceiptCodec | TransactionReferenceCodec | WalletSendCallsCodec | AttachmentCodec | (never[] | ContentCodecs)[number])[]>>>;
69
- static createFromEnv<ContentCodecs extends ContentCodec[] = []>(options?: Omit<ClientOptions, "codecs"> & {
70
- codecs?: ContentCodecs;
71
- }): Promise<Agent<import("@xmtp/node-sdk").ExtractCodecContentTypes<(ReactionCodec | ReplyCodec | RemoteAttachmentCodec | MarkdownCodec | ReadReceiptCodec | TransactionReferenceCodec | WalletSendCallsCodec | AttachmentCodec | (never[] | ContentCodecs)[number])[]>>>;
72
- get libxmtpVersion(): string | undefined;
73
- use(...middleware: Array<AgentMiddleware<ContentTypes> | AgentMiddleware<ContentTypes>[]>): this;
74
- start(options?: AgentStreamingOptions): Promise<void>;
75
- get client(): Client<ContentTypes>;
76
- get errors(): AgentErrorRegistrar<ContentTypes>;
77
- stop(): Promise<void>;
78
- createDmWithAddress(address: EthAddress, options?: CreateDmOptions): Promise<Dm<ContentTypes>>;
79
- createGroupWithAddresses(addresses: EthAddress[], options?: CreateGroupOptions): Promise<Group<ContentTypes>>;
80
- addMembersWithAddresses<ContentTypes>(group: Group<ContentTypes>, addresses: EthAddress[]): Promise<void>;
81
- getConversationContext(conversationId: string): Promise<ConversationContext<ContentTypes, Dm<ContentTypes> | Group<ContentTypes>> | undefined>;
82
- get address(): string | undefined;
83
- }
84
- export {};
@@ -1,394 +0,0 @@
1
- import EventEmitter from "node:events";
2
- import fs from "node:fs";
3
- import path from "node:path";
4
- import { MarkdownCodec } from "@xmtp/content-type-markdown";
5
- import { ReactionCodec } from "@xmtp/content-type-reaction";
6
- import { ReadReceiptCodec } from "@xmtp/content-type-read-receipt";
7
- import { AttachmentCodec, RemoteAttachmentCodec, } from "@xmtp/content-type-remote-attachment";
8
- import { ReplyCodec } from "@xmtp/content-type-reply";
9
- import { TransactionReferenceCodec } from "@xmtp/content-type-transaction-reference";
10
- import { WalletSendCallsCodec } from "@xmtp/content-type-wallet-send-calls";
11
- import { ApiUrls, Client, Dm, Group, isHexString, } from "@xmtp/node-sdk";
12
- import { filter } from "../core/filter.js";
13
- import { getInstallationInfo } from "../debug.js";
14
- import { createSigner, createUser } from "../user/User.js";
15
- import { AgentError, AgentStreamingError } from "./AgentError.js";
16
- import { ClientContext } from "./ClientContext.js";
17
- import { ConversationContext } from "./ConversationContext.js";
18
- import { MessageContext } from "./MessageContext.js";
19
- export class Agent extends EventEmitter {
20
- #client;
21
- #conversationsStream;
22
- #messageStream;
23
- #middleware = [];
24
- #errorMiddleware = [];
25
- #errors = Object.freeze({
26
- use: (...errorMiddleware) => {
27
- for (const emw of errorMiddleware) {
28
- if (Array.isArray(emw)) {
29
- this.#errorMiddleware.push(...emw);
30
- }
31
- else if (typeof emw === "function") {
32
- this.#errorMiddleware.push(emw);
33
- }
34
- }
35
- return this.#errors;
36
- },
37
- });
38
- #defaultErrorHandler = (currentError) => {
39
- const emittedError = currentError instanceof Error
40
- ? currentError
41
- : new AgentError(9999, `Unhandled error caught by default error middleware.`, currentError);
42
- this.emit("unhandledError", emittedError);
43
- };
44
- #isLocked = false;
45
- constructor({ client }) {
46
- super();
47
- this.#client = client;
48
- }
49
- static async create(signer,
50
- // Note: we need to omit this so that "Client.create" can correctly infer the codecs.
51
- options) {
52
- const initializedOptions = { ...(options ?? {}) };
53
- initializedOptions.appVersion ??= "agent-sdk/alpha";
54
- initializedOptions.disableDeviceSync ??= true;
55
- const upgradedCodecs = [
56
- ...(initializedOptions.codecs ?? []),
57
- new AttachmentCodec(),
58
- new MarkdownCodec(),
59
- new ReactionCodec(),
60
- new ReadReceiptCodec(),
61
- new RemoteAttachmentCodec(),
62
- new ReplyCodec(),
63
- new TransactionReferenceCodec(),
64
- new WalletSendCallsCodec(),
65
- ];
66
- if (process.env.XMTP_FORCE_DEBUG) {
67
- const loggingLevel = process.env.XMTP_FORCE_DEBUG_LEVEL || "warn" /* LogLevel.warn */;
68
- initializedOptions.debugEventsEnabled = true;
69
- initializedOptions.loggingLevel = loggingLevel;
70
- initializedOptions.structuredLogging = true;
71
- }
72
- const client = await Client.create(signer, {
73
- ...initializedOptions,
74
- codecs: upgradedCodecs,
75
- });
76
- const info = await getInstallationInfo(client);
77
- if (info.totalInstallations > 1 && info.isMostRecent) {
78
- console.warn(`[WARNING] You have "${info.totalInstallations}" installations. Installation ID "${info.installationId}" is the most recent. Make sure to persist and reload your installation data. If you exceed the installation limit, your Agent will stop working. Read more: https://docs.xmtp.org/agents/build-agents/local-database#installation-limits-and-revocation-rules`);
79
- }
80
- return new Agent({ client });
81
- }
82
- static async createFromEnv(
83
- // Note: we need to omit this so that "Client.create" can correctly infer the codecs.
84
- options) {
85
- const { XMTP_DB_DIRECTORY, XMTP_DB_ENCRYPTION_KEY, XMTP_ENV, XMTP_WALLET_KEY, } = process.env;
86
- if (!isHexString(XMTP_WALLET_KEY)) {
87
- throw new AgentError(1000, `XMTP_WALLET_KEY env is not in hex (0x) format.`);
88
- }
89
- const signer = createSigner(createUser(XMTP_WALLET_KEY));
90
- const initializedOptions = { ...(options ?? {}) };
91
- initializedOptions.dbEncryptionKey =
92
- typeof XMTP_DB_ENCRYPTION_KEY === "string"
93
- ? isHexString(XMTP_DB_ENCRYPTION_KEY)
94
- ? XMTP_DB_ENCRYPTION_KEY
95
- : `0x${XMTP_DB_ENCRYPTION_KEY}`
96
- : undefined;
97
- if (XMTP_ENV && Object.keys(ApiUrls).includes(XMTP_ENV)) {
98
- initializedOptions.env = XMTP_ENV;
99
- }
100
- if (typeof XMTP_DB_DIRECTORY === "string") {
101
- fs.mkdirSync(XMTP_DB_DIRECTORY, { recursive: true, mode: 0o700 });
102
- initializedOptions.dbPath = (inboxId) => {
103
- const dbPath = path.join(XMTP_DB_DIRECTORY, `xmtp-${inboxId}.db3`);
104
- console.info(`Saving local database to "${dbPath}"`);
105
- return dbPath;
106
- };
107
- }
108
- return this.create(signer, initializedOptions);
109
- }
110
- get libxmtpVersion() {
111
- return this.#client.libxmtpVersion;
112
- }
113
- use(...middleware) {
114
- for (const mw of middleware) {
115
- if (Array.isArray(mw)) {
116
- this.#middleware.push(...mw);
117
- }
118
- else if (typeof mw === "function") {
119
- this.#middleware.push(mw);
120
- }
121
- }
122
- return this;
123
- }
124
- async #stopStreams() {
125
- try {
126
- await this.#conversationsStream?.end();
127
- }
128
- finally {
129
- this.#conversationsStream = undefined;
130
- }
131
- try {
132
- await this.#messageStream?.end();
133
- }
134
- finally {
135
- this.#messageStream = undefined;
136
- }
137
- }
138
- /**
139
- * Closes all existing streams and restarts the streaming system.
140
- */
141
- async #handleStreamError(error) {
142
- await this.#stopStreams();
143
- const recovered = await this.#runErrorChain(error, {
144
- client: this.#client,
145
- });
146
- if (recovered) {
147
- this.#isLocked = false;
148
- queueMicrotask(() => this.start());
149
- }
150
- }
151
- async start(options) {
152
- if (this.#isLocked || this.#conversationsStream || this.#messageStream)
153
- return;
154
- this.#isLocked = true;
155
- try {
156
- this.#conversationsStream = await this.#client.conversations.stream({
157
- ...options,
158
- onValue: async (conversation) => {
159
- try {
160
- if (!conversation) {
161
- return;
162
- }
163
- this.emit("conversation", new ConversationContext({
164
- conversation,
165
- client: this.#client,
166
- }));
167
- if (conversation instanceof Group) {
168
- this.emit("group", new ConversationContext({
169
- conversation,
170
- client: this.#client,
171
- }));
172
- }
173
- else if (conversation instanceof Dm) {
174
- this.emit("dm", new ConversationContext({
175
- conversation,
176
- client: this.#client,
177
- }));
178
- }
179
- }
180
- catch (error) {
181
- const recovered = await this.#runErrorChain(new AgentError(1001, "Emitted value from conversation stream caused an error.", error), new ClientContext({ client: this.#client }));
182
- if (!recovered)
183
- await this.stop();
184
- }
185
- },
186
- onError: async (error) => {
187
- const recovered = await this.#runErrorChain(new AgentStreamingError(1002, "Error occured during conversation streaming.", error), new ClientContext({ client: this.#client }));
188
- if (!recovered)
189
- await this.stop();
190
- },
191
- });
192
- this.#messageStream = await this.#client.conversations.streamAllMessages({
193
- ...options,
194
- onValue: async (message) => {
195
- try {
196
- switch (true) {
197
- case filter.isGroupUpdate(message):
198
- await this.#processMessage(message, "group-update");
199
- break;
200
- case filter.isRemoteAttachment(message):
201
- await this.#processMessage(message, "attachment");
202
- break;
203
- case filter.isReaction(message):
204
- await this.#processMessage(message, "reaction");
205
- break;
206
- case filter.isReadReceipt(message):
207
- await this.#processMessage(message, "read-receipt");
208
- break;
209
- case filter.isReply(message):
210
- await this.#processMessage(message, "reply");
211
- break;
212
- case filter.isTransactionReference(message):
213
- await this.#processMessage(message, "transaction-reference");
214
- break;
215
- case filter.isWalletSendCalls(message):
216
- await this.#processMessage(message, "wallet-send-calls");
217
- break;
218
- case filter.isMarkdown(message):
219
- await this.#processMessage(message, "markdown");
220
- break;
221
- case filter.isText(message):
222
- await this.#processMessage(message, "text");
223
- break;
224
- default:
225
- await this.#processMessage(message);
226
- break;
227
- }
228
- }
229
- catch (error) {
230
- const recovered = await this.#runErrorChain(error, {
231
- client: this.#client,
232
- });
233
- if (!recovered) {
234
- await this.stop();
235
- }
236
- this.#isLocked = false;
237
- }
238
- },
239
- onError: async (error) => {
240
- const recovered = await this.#runErrorChain(new AgentStreamingError(1004, "Error occured during message streaming.", error), new ClientContext({ client: this.#client }));
241
- if (!recovered)
242
- await this.stop();
243
- },
244
- });
245
- this.emit("start", new ClientContext({ client: this.#client }));
246
- this.#isLocked = false;
247
- }
248
- catch (error) {
249
- await this.#handleStreamError(error);
250
- }
251
- }
252
- async #processMessage(message, topic = "unknownMessage") {
253
- // Skip messages with undefined content (failed to decode)
254
- if (!filter.hasContent(message)) {
255
- return;
256
- }
257
- // Skip messages from agent itself
258
- if (filter.fromSelf(message, this.#client)) {
259
- return;
260
- }
261
- const conversation = await this.#client.conversations.getConversationById(message.conversationId);
262
- if (!conversation) {
263
- throw new AgentError(1003, `Failed to process message ID "${message.id}" for conversation ID "${message.conversationId}" because the conversation could not be found.`);
264
- }
265
- const context = new MessageContext({
266
- message,
267
- conversation,
268
- client: this.#client,
269
- });
270
- await this.#runMiddlewareChain(context, topic);
271
- }
272
- async #runMiddlewareChain(context, topic = "unknownMessage") {
273
- const finalEmit = async () => {
274
- try {
275
- this.emit(topic, context);
276
- this.emit("message", context);
277
- }
278
- catch (error) {
279
- await this.#runErrorChain(error, context);
280
- }
281
- };
282
- const chain = this.#middleware.reduceRight((next, mw) => {
283
- return async () => {
284
- try {
285
- await mw(context, next);
286
- }
287
- catch (error) {
288
- const resume = await this.#runErrorChain(error, context);
289
- if (resume) {
290
- await next();
291
- }
292
- // Chain is not resuming, error is being swallowed
293
- }
294
- };
295
- }, finalEmit);
296
- await chain();
297
- }
298
- async #runErrorHandler(handler, context, error) {
299
- let settled = false;
300
- let flow = { kind: "stopped" };
301
- const next = (nextErr) => {
302
- if (settled)
303
- return;
304
- settled = true;
305
- flow =
306
- nextErr === undefined
307
- ? { kind: "handled" }
308
- : { kind: "continue", error: nextErr };
309
- };
310
- try {
311
- await handler(error, context, next);
312
- return flow;
313
- }
314
- catch (thrown) {
315
- if (settled) {
316
- return flow;
317
- }
318
- return { kind: "continue", error: thrown };
319
- }
320
- }
321
- async #runErrorChain(error, context) {
322
- const chain = [...this.#errorMiddleware, this.#defaultErrorHandler];
323
- let currentError = error;
324
- for (let i = 0; i < chain.length; i++) {
325
- const handler = chain[i];
326
- if (!handler)
327
- continue;
328
- const outcome = await this.#runErrorHandler(handler, context, currentError);
329
- switch (outcome.kind) {
330
- case "handled":
331
- // Error was handled. Main middleware can continue.
332
- return true;
333
- case "stopped":
334
- // Error cannot be handled. Main middleware won't continue.
335
- return false;
336
- case "continue":
337
- // Error is passed to the next handler
338
- currentError = outcome.error;
339
- }
340
- }
341
- // Reached end of chain without recovery
342
- return false;
343
- }
344
- get client() {
345
- return this.#client;
346
- }
347
- get errors() {
348
- return this.#errors;
349
- }
350
- async stop() {
351
- this.#isLocked = true;
352
- await this.#stopStreams();
353
- this.emit("stop", new ClientContext({ client: this.#client }));
354
- this.#isLocked = false;
355
- }
356
- createDmWithAddress(address, options) {
357
- return this.#client.conversations.newDmWithIdentifier({
358
- identifier: address,
359
- identifierKind: 0 /* IdentifierKind.Ethereum */,
360
- }, options);
361
- }
362
- createGroupWithAddresses(addresses, options) {
363
- const identifiers = addresses.map((address) => {
364
- return {
365
- identifier: address,
366
- identifierKind: 0 /* IdentifierKind.Ethereum */,
367
- };
368
- });
369
- return this.#client.conversations.newGroupWithIdentifiers(identifiers, options);
370
- }
371
- addMembersWithAddresses(group, addresses) {
372
- const identifiers = addresses.map((address) => {
373
- return {
374
- identifier: address,
375
- identifierKind: 0 /* IdentifierKind.Ethereum */,
376
- };
377
- });
378
- return group.addMembersByIdentifiers(identifiers);
379
- }
380
- async getConversationContext(conversationId) {
381
- const conversation = await this.client.conversations.getConversationById(conversationId);
382
- if (conversation) {
383
- const context = new ConversationContext({
384
- conversation,
385
- client: this.#client,
386
- });
387
- return context;
388
- }
389
- }
390
- get address() {
391
- return this.#client.accountIdentifier?.identifier;
392
- }
393
- }
394
- //# sourceMappingURL=Agent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Agent.js","sourceRoot":"","sources":["../../src/core/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,eAAe,EACf,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EACL,OAAO,EACP,MAAM,EACN,EAAE,EACF,KAAK,EAEL,WAAW,GAUZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAA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ACtE,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC;gBACtC,YAAY;gBACZ,MAAM,EAAE,IAAI,CAAC,OAAO;aACrB,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACpD,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- export declare class AgentError extends Error {
2
- #private;
3
- constructor(code: number, message: string, cause?: unknown);
4
- get code(): number;
5
- }
6
- export declare class AgentStreamingError extends AgentError {
7
- }
@@ -1,13 +0,0 @@
1
- export class AgentError extends Error {
2
- #code;
3
- constructor(code, message, cause) {
4
- super(message, { cause });
5
- this.#code = code;
6
- }
7
- get code() {
8
- return this.#code;
9
- }
10
- }
11
- export class AgentStreamingError extends AgentError {
12
- }
13
- //# sourceMappingURL=AgentError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgentError.js","sourceRoot":"","sources":["../../src/core/AgentError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,KAAK,CAAS;IAEd,YAAY,IAAY,EAAE,OAAe,EAAE,KAAe;QACxD,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,UAAU;CAAG"}
@@ -1,9 +0,0 @@
1
- import type { Client } from "@xmtp/node-sdk";
2
- export declare class ClientContext<ContentTypes = unknown> {
3
- #private;
4
- constructor({ client }: {
5
- client: Client<ContentTypes>;
6
- });
7
- getClientAddress(): string | undefined;
8
- get client(): Client<ContentTypes>;
9
- }
@@ -1,13 +0,0 @@
1
- export class ClientContext {
2
- #client;
3
- constructor({ client }) {
4
- this.#client = client;
5
- }
6
- getClientAddress() {
7
- return this.#client.accountIdentifier?.identifier;
8
- }
9
- get client() {
10
- return this.#client;
11
- }
12
- }
13
- //# sourceMappingURL=ClientContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClientContext.js","sourceRoot":"","sources":["../../src/core/ClientContext.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IACxB,OAAO,CAAuB;IAE9B,YAAY,EAAE,MAAM,EAAoC;QACtD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACpD,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
@@ -1,19 +0,0 @@
1
- import { type Client, type Conversation, type Dm, type Group } from "@xmtp/node-sdk";
2
- import { type AttachmentUploadCallback } from "../util/AttachmentUtil.js";
3
- import { ClientContext } from "./ClientContext.js";
4
- export declare class ConversationContext<ContentTypes = unknown, ConversationType extends Conversation = Conversation> extends ClientContext<ContentTypes> {
5
- #private;
6
- constructor({ conversation, client, }: {
7
- conversation: ConversationType;
8
- client: Client<ContentTypes>;
9
- });
10
- isDm(): this is ConversationContext<ContentTypes, Dm<ContentTypes>>;
11
- isGroup(): this is ConversationContext<ContentTypes, Group<ContentTypes>>;
12
- sendMarkdown(markdown: string): Promise<void>;
13
- sendText(text: string): Promise<void>;
14
- sendRemoteAttachment(unencryptedFile: File, uploadCallback: AttachmentUploadCallback): Promise<void>;
15
- get conversation(): ConversationType;
16
- get isAllowed(): boolean;
17
- get isDenied(): boolean;
18
- get isUnknown(): boolean;
19
- }
@@ -1,43 +0,0 @@
1
- import { ContentTypeMarkdown } from "@xmtp/content-type-markdown";
2
- import { ContentTypeRemoteAttachment } from "@xmtp/content-type-remote-attachment";
3
- import { ContentTypeText } from "@xmtp/content-type-text";
4
- import { filter } from "../core/filter.js";
5
- import { createRemoteAttachmentFromFile, } from "../util/AttachmentUtil.js";
6
- import { ClientContext } from "./ClientContext.js";
7
- export class ConversationContext extends ClientContext {
8
- #conversation;
9
- constructor({ conversation, client, }) {
10
- super({ client });
11
- this.#conversation = conversation;
12
- }
13
- isDm() {
14
- return filter.isDM(this.#conversation);
15
- }
16
- isGroup() {
17
- return filter.isGroup(this.#conversation);
18
- }
19
- // Send methods, which don't need a message context, are in ConversationContext to make them available in both dm and group event handlers
20
- async sendMarkdown(markdown) {
21
- await this.conversation.send(markdown, ContentTypeMarkdown);
22
- }
23
- async sendText(text) {
24
- await this.conversation.send(text, ContentTypeText);
25
- }
26
- async sendRemoteAttachment(unencryptedFile, uploadCallback) {
27
- const remoteAttachment = await createRemoteAttachmentFromFile(unencryptedFile, uploadCallback);
28
- await this.conversation.send(remoteAttachment, ContentTypeRemoteAttachment);
29
- }
30
- get conversation() {
31
- return this.#conversation;
32
- }
33
- get isAllowed() {
34
- return this.#conversation.consentState === 1 /* ConsentState.Allowed */;
35
- }
36
- get isDenied() {
37
- return this.#conversation.consentState === 2 /* ConsentState.Denied */;
38
- }
39
- get isUnknown() {
40
- return this.#conversation.consentState === 0 /* ConsentState.Unknown */;
41
- }
42
- }
43
- //# sourceMappingURL=ConversationContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConversationContext.js","sourceRoot":"","sources":["../../src/core/ConversationContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAQ1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,8BAA8B,GAE/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CA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