@xmtp/agent-sdk 0.0.12 → 0.0.13
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/README.md +24 -21
- package/dist/core/Agent.d.ts +11 -14
- package/dist/core/Agent.js +11 -5
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/AgentContext.d.ts +9 -0
- package/dist/core/AgentContext.js +2 -0
- package/dist/core/AgentContext.js.map +1 -0
- package/dist/core/ConversationContext.d.ts +3 -1
- package/dist/core/ConversationContext.js +7 -0
- package/dist/core/ConversationContext.js.map +1 -1
- package/dist/core/MessageContext.d.ts +14 -7
- package/dist/core/MessageContext.js +14 -1
- package/dist/core/MessageContext.js.map +1 -1
- package/dist/demo.js +6 -4
- package/dist/demo.js.map +1 -1
- package/dist/utils/filter.d.ts +19 -75
- package/dist/utils/filter.js +51 -158
- package/dist/utils/filter.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Subscribe only to what you need using Node’s `EventEmitter` interface. Events
|
|
|
91
91
|
- `reaction` – a new incoming reaction message
|
|
92
92
|
- `reply` – a new incoming reply message
|
|
93
93
|
- `attachment` – a new incoming remote attachment message
|
|
94
|
-
- `
|
|
94
|
+
- `unknownMessage` – a message that doesn't match any specific type
|
|
95
95
|
|
|
96
96
|
**Conversation Events**
|
|
97
97
|
|
|
@@ -210,30 +210,30 @@ agent.on("unhandledError", (error) => {
|
|
|
210
210
|
|
|
211
211
|
### 3. Built‑in Filters
|
|
212
212
|
|
|
213
|
-
Instead of manually checking every incoming message, you can
|
|
213
|
+
Instead of manually checking every incoming message, you can use the provided filters.
|
|
214
214
|
|
|
215
215
|
**Example**
|
|
216
216
|
|
|
217
217
|
```ts
|
|
218
|
-
import {
|
|
218
|
+
import { filter } from "@xmtp/agent-sdk";
|
|
219
219
|
|
|
220
220
|
// Using filter in message handler
|
|
221
|
-
agent.on(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
await ctx.conversation.send("
|
|
235
|
-
}
|
|
236
|
-
);
|
|
221
|
+
agent.on("text", async (ctx) => {
|
|
222
|
+
if (filter.isText(ctx.message)) {
|
|
223
|
+
await ctx.conversation.send("You sent a text message!");
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// Combine multiple conditions
|
|
228
|
+
agent.on("text", async (ctx) => {
|
|
229
|
+
if (
|
|
230
|
+
filter.hasDefinedContent(ctx.message) &&
|
|
231
|
+
!filter.fromSelf(ctx.message, ctx.client) &&
|
|
232
|
+
filter.isText(ctx.message)
|
|
233
|
+
) {
|
|
234
|
+
await ctx.conversation.send("Valid text message received ✅");
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
237
|
```
|
|
238
238
|
|
|
239
239
|
For convenience, the `filter` object can also be imported as `f`:
|
|
@@ -243,10 +243,13 @@ For convenience, the `filter` object can also be imported as `f`:
|
|
|
243
243
|
import { filter, f } from "@xmtp/agent-sdk";
|
|
244
244
|
|
|
245
245
|
// Both work the same way:
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
if (f.isText(ctx.message)) {
|
|
247
|
+
// Handle message...
|
|
248
|
+
}
|
|
248
249
|
```
|
|
249
250
|
|
|
251
|
+
**Available Filters:**
|
|
252
|
+
|
|
250
253
|
You can find all available prebuilt filters [here](https://github.com/xmtp/xmtp-js/blob/main/sdks/agent-sdk/src/utils/filter.ts).
|
|
251
254
|
|
|
252
255
|
### 4. Rich Context
|
package/dist/core/Agent.d.ts
CHANGED
|
@@ -4,13 +4,15 @@ import { ReactionCodec } from "@xmtp/content-type-reaction";
|
|
|
4
4
|
import { RemoteAttachmentCodec } from "@xmtp/content-type-remote-attachment";
|
|
5
5
|
import { ReplyCodec } from "@xmtp/content-type-reply";
|
|
6
6
|
import type { TextCodec } from "@xmtp/content-type-text";
|
|
7
|
-
import { Client, Dm, Group, type ClientOptions
|
|
7
|
+
import { Client, Dm, Group, type ClientOptions } from "@xmtp/node-sdk";
|
|
8
|
+
import type { AgentErrorContext } from "./AgentContext.js";
|
|
8
9
|
import { ConversationContext } from "./ConversationContext.js";
|
|
9
10
|
import { MessageContext } from "./MessageContext.js";
|
|
10
|
-
|
|
11
|
+
type EventHandlerMap<ContentTypes> = {
|
|
11
12
|
attachment: [
|
|
12
13
|
ctx: MessageContext<ReturnType<RemoteAttachmentCodec["decode"]>>
|
|
13
14
|
];
|
|
15
|
+
conversation: [ctx: ConversationContext<ContentTypes>];
|
|
14
16
|
dm: [ctx: ConversationContext<ContentTypes, Dm<ContentTypes>>];
|
|
15
17
|
group: [ctx: ConversationContext<ContentTypes, Group<ContentTypes>>];
|
|
16
18
|
reaction: [ctx: MessageContext<ReturnType<ReactionCodec["decode"]>>];
|
|
@@ -19,32 +21,27 @@ interface EventHandlerMap<ContentTypes> {
|
|
|
19
21
|
stop: [];
|
|
20
22
|
text: [ctx: MessageContext<ReturnType<TextCodec["decode"]>>];
|
|
21
23
|
unhandledError: [error: Error];
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
export type AgentErrorContext<ContentTypes = unknown> = {
|
|
25
|
-
message?: DecodedMessage<ContentTypes>;
|
|
26
|
-
client: Client<ContentTypes>;
|
|
27
|
-
conversation?: Conversation;
|
|
24
|
+
unknownMessage: [ctx: MessageContext<ContentTypes>];
|
|
28
25
|
};
|
|
29
|
-
export
|
|
26
|
+
export type AgentOptions<ContentTypes> = {
|
|
30
27
|
client: Client<ContentTypes>;
|
|
31
|
-
}
|
|
28
|
+
};
|
|
32
29
|
export type AgentMessageHandler<ContentTypes = unknown> = (ctx: MessageContext<ContentTypes>) => Promise<void> | void;
|
|
33
30
|
export type AgentMiddleware<ContentTypes = unknown> = (ctx: MessageContext<ContentTypes>, next: () => Promise<void> | void) => Promise<void>;
|
|
34
31
|
export type AgentErrorMiddleware<ContentTypes = unknown> = (error: unknown, ctx: AgentErrorContext<ContentTypes>, next: (err?: unknown) => Promise<void> | void) => Promise<void> | void;
|
|
35
32
|
export type StreamAllMessagesOptions<ContentTypes> = Parameters<Client<ContentTypes>["conversations"]["streamAllMessages"]>[0];
|
|
36
|
-
export
|
|
33
|
+
export type AgentErrorRegistrar<ContentTypes> = {
|
|
37
34
|
use(...errorMiddleware: Array<AgentErrorMiddleware<ContentTypes> | AgentErrorMiddleware<ContentTypes>[]>): AgentErrorRegistrar<ContentTypes>;
|
|
38
|
-
}
|
|
35
|
+
};
|
|
39
36
|
export declare class Agent<ContentTypes = unknown> extends EventEmitter<EventHandlerMap<ContentTypes>> {
|
|
40
37
|
#private;
|
|
41
38
|
constructor({ client }: AgentOptions<ContentTypes>);
|
|
42
39
|
static create<ContentCodecs extends ContentCodec[] = []>(signer: Parameters<typeof Client.create>[0], options?: Omit<ClientOptions, "codecs"> & {
|
|
43
40
|
codecs?: ContentCodecs;
|
|
44
|
-
}): Promise<Agent<import("@xmtp/node-sdk").ExtractCodecContentTypes<(
|
|
41
|
+
}): Promise<Agent<import("@xmtp/node-sdk").ExtractCodecContentTypes<(ReplyCodec | ReactionCodec | RemoteAttachmentCodec | (never[] | ContentCodecs)[number])[]>>>;
|
|
45
42
|
static createFromEnv<ContentCodecs extends ContentCodec[] = []>(options?: Omit<ClientOptions, "codecs"> & {
|
|
46
43
|
codecs?: ContentCodecs;
|
|
47
|
-
}): Promise<Agent<import("@xmtp/node-sdk").ExtractCodecContentTypes<(
|
|
44
|
+
}): Promise<Agent<import("@xmtp/node-sdk").ExtractCodecContentTypes<(ReplyCodec | ReactionCodec | RemoteAttachmentCodec | (never[] | ContentCodecs)[number])[]>>>;
|
|
48
45
|
use(...middleware: Array<AgentMiddleware<ContentTypes> | AgentMiddleware<ContentTypes>[]>): this;
|
|
49
46
|
start(options?: StreamAllMessagesOptions<ContentTypes>): Promise<void>;
|
|
50
47
|
get client(): Client<ContentTypes>;
|
package/dist/core/Agent.js
CHANGED
|
@@ -100,6 +100,13 @@ export class Agent extends EventEmitter {
|
|
|
100
100
|
this.#conversationsStream = await this.#client.conversations.stream({
|
|
101
101
|
onValue: async (conversation) => {
|
|
102
102
|
try {
|
|
103
|
+
if (!conversation) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.emit("conversation", new ConversationContext({
|
|
107
|
+
conversation,
|
|
108
|
+
client: this.#client,
|
|
109
|
+
}));
|
|
103
110
|
if (conversation instanceof Group) {
|
|
104
111
|
this.emit("group", new ConversationContext({
|
|
105
112
|
conversation,
|
|
@@ -172,28 +179,27 @@ export class Agent extends EventEmitter {
|
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
|
-
async #processMessage(message, topic = "
|
|
182
|
+
async #processMessage(message, topic = "unknownMessage") {
|
|
176
183
|
// Skip messages with undefined content (failed to decode)
|
|
177
|
-
if (!filter.
|
|
184
|
+
if (!filter.hasContent(message)) {
|
|
178
185
|
return;
|
|
179
186
|
}
|
|
180
187
|
// Skip messages from agent itself
|
|
181
188
|
if (filter.fromSelf(message, this.#client)) {
|
|
182
189
|
return;
|
|
183
190
|
}
|
|
184
|
-
let context = null;
|
|
185
191
|
const conversation = await this.#client.conversations.getConversationById(message.conversationId);
|
|
186
192
|
if (!conversation) {
|
|
187
193
|
throw new AgentError(1003, `Failed to process message ID "${message.id}" for conversation ID "${message.conversationId}" because the conversation could not be found.`);
|
|
188
194
|
}
|
|
189
|
-
context = new MessageContext({
|
|
195
|
+
const context = new MessageContext({
|
|
190
196
|
message,
|
|
191
197
|
conversation,
|
|
192
198
|
client: this.#client,
|
|
193
199
|
});
|
|
194
200
|
await this.#runMiddlewareChain(context, topic);
|
|
195
201
|
}
|
|
196
|
-
async #runMiddlewareChain(context, topic = "
|
|
202
|
+
async #runMiddlewareChain(context, topic = "unknownMessage") {
|
|
197
203
|
const finalEmit = async () => {
|
|
198
204
|
try {
|
|
199
205
|
this.emit(topic, context);
|
package/dist/core/Agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.js","sourceRoot":"","sources":["../../src/core/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,MAAM,EACN,EAAE,EACF,KAAK,GAMN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Agent.js","sourceRoot":"","sources":["../../src/core/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,MAAM,EACN,EAAE,EACF,KAAK,GAMN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC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AC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Client, Conversation, DecodedMessage } from "@xmtp/node-sdk";
|
|
2
|
+
export type AgentBaseContext<ContentTypes = unknown> = {
|
|
3
|
+
client: Client<ContentTypes>;
|
|
4
|
+
conversation: Conversation;
|
|
5
|
+
message: DecodedMessage;
|
|
6
|
+
};
|
|
7
|
+
export type AgentErrorContext<ContentTypes = unknown> = Partial<AgentBaseContext<ContentTypes>> & {
|
|
8
|
+
client: Client<ContentTypes>;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentContext.js","sourceRoot":"","sources":["../../src/core/AgentContext.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Client, type Conversation, type Dm, type Group } from "@xmtp/node-sdk";
|
|
2
2
|
import { ClientContext } from "./ClientContext.js";
|
|
3
3
|
export declare class ConversationContext<ContentTypes = unknown, ConversationType extends Conversation = Conversation> extends ClientContext<ContentTypes> {
|
|
4
4
|
#private;
|
|
@@ -6,6 +6,8 @@ export declare class ConversationContext<ContentTypes = unknown, ConversationTyp
|
|
|
6
6
|
conversation: ConversationType;
|
|
7
7
|
client: Client<ContentTypes>;
|
|
8
8
|
});
|
|
9
|
+
isDm(): this is ConversationContext<ContentTypes, Dm<ContentTypes>>;
|
|
10
|
+
isGroup(): this is ConversationContext<ContentTypes, Group<ContentTypes>>;
|
|
9
11
|
sendText(text: string): Promise<void>;
|
|
10
12
|
get conversation(): ConversationType;
|
|
11
13
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ContentTypeText } from "@xmtp/content-type-text";
|
|
2
|
+
import { filter } from "../utils/filter.js";
|
|
2
3
|
import { ClientContext } from "./ClientContext.js";
|
|
3
4
|
export class ConversationContext extends ClientContext {
|
|
4
5
|
#conversation;
|
|
@@ -6,6 +7,12 @@ export class ConversationContext extends ClientContext {
|
|
|
6
7
|
super({ client });
|
|
7
8
|
this.#conversation = conversation;
|
|
8
9
|
}
|
|
10
|
+
isDm() {
|
|
11
|
+
return filter.isDM(this.#conversation);
|
|
12
|
+
}
|
|
13
|
+
isGroup() {
|
|
14
|
+
return filter.isGroup(this.#conversation);
|
|
15
|
+
}
|
|
9
16
|
async sendText(text) {
|
|
10
17
|
await this.#conversation.send(text, ContentTypeText);
|
|
11
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationContext.js","sourceRoot":"","sources":["../../src/core/ConversationContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConversationContext.js","sourceRoot":"","sources":["../../src/core/ConversationContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAO1D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,OAAO,mBAGX,SAAQ,aAA2B;IACnC,aAAa,CAAmB;IAEhC,YAAY,EACV,YAAY,EACZ,MAAM,GAIP;QACC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED,IAAI;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;IAED,OAAO;QACL,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { type Reaction } from "@xmtp/content-type-reaction";
|
|
2
|
-
import
|
|
1
|
+
import { type Reaction, type ReactionCodec } from "@xmtp/content-type-reaction";
|
|
2
|
+
import { type RemoteAttachmentCodec } from "@xmtp/content-type-remote-attachment";
|
|
3
|
+
import { type ReplyCodec } from "@xmtp/content-type-reply";
|
|
4
|
+
import { type TextCodec } from "@xmtp/content-type-text";
|
|
5
|
+
import type { DecodedMessage } from "@xmtp/node-sdk";
|
|
6
|
+
import type { AgentBaseContext } from "./AgentContext.js";
|
|
3
7
|
import { ConversationContext } from "./ConversationContext.js";
|
|
4
8
|
type DecodedMessageWithContent<ContentTypes = unknown> = DecodedMessage<ContentTypes> & {
|
|
5
9
|
content: ContentTypes;
|
|
6
10
|
};
|
|
11
|
+
export type MessageContextParams<ContentTypes = unknown> = Omit<AgentBaseContext<ContentTypes>, "message"> & {
|
|
12
|
+
message: DecodedMessageWithContent<ContentTypes>;
|
|
13
|
+
};
|
|
7
14
|
export declare class MessageContext<ContentTypes = unknown> extends ConversationContext<ContentTypes> {
|
|
8
15
|
#private;
|
|
9
|
-
constructor({ message, conversation, client, }:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
constructor({ message, conversation, client, }: MessageContextParams<ContentTypes>);
|
|
17
|
+
isText(): this is MessageContext<ReturnType<TextCodec["decode"]>>;
|
|
18
|
+
isReply(): this is MessageContext<ReturnType<ReplyCodec["decode"]>>;
|
|
19
|
+
isReaction(): this is MessageContext<ReturnType<ReactionCodec["decode"]>>;
|
|
20
|
+
isRemoteAttachment(): this is MessageContext<ReturnType<RemoteAttachmentCodec["decode"]>>;
|
|
14
21
|
sendReaction(content: string, schema?: Reaction["schema"]): Promise<void>;
|
|
15
22
|
sendTextReply(text: string): Promise<void>;
|
|
16
23
|
getSenderAddress(): Promise<string>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ContentTypeReaction, } from "@xmtp/content-type-reaction";
|
|
2
|
-
import { ContentTypeReply } from "@xmtp/content-type-reply";
|
|
2
|
+
import { ContentTypeReply, } from "@xmtp/content-type-reply";
|
|
3
3
|
import { ContentTypeText } from "@xmtp/content-type-text";
|
|
4
|
+
import { filter } from "../utils/filter.js";
|
|
4
5
|
import { ConversationContext } from "./ConversationContext.js";
|
|
5
6
|
export class MessageContext extends ConversationContext {
|
|
6
7
|
#message;
|
|
@@ -8,6 +9,18 @@ export class MessageContext extends ConversationContext {
|
|
|
8
9
|
super({ conversation, client });
|
|
9
10
|
this.#message = message;
|
|
10
11
|
}
|
|
12
|
+
isText() {
|
|
13
|
+
return filter.isText(this.#message);
|
|
14
|
+
}
|
|
15
|
+
isReply() {
|
|
16
|
+
return filter.isReply(this.#message);
|
|
17
|
+
}
|
|
18
|
+
isReaction() {
|
|
19
|
+
return filter.isReaction(this.#message);
|
|
20
|
+
}
|
|
21
|
+
isRemoteAttachment() {
|
|
22
|
+
return filter.isRemoteAttachment(this.#message);
|
|
23
|
+
}
|
|
11
24
|
async sendReaction(content, schema = "unicode") {
|
|
12
25
|
const reaction = {
|
|
13
26
|
action: "added",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageContext.js","sourceRoot":"","sources":["../../src/core/MessageContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"MessageContext.js","sourceRoot":"","sources":["../../src/core/MessageContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAGpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,gBAAgB,GAGjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAkB,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B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C,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,sBAAsB,CAAC;YACtE,IAAI,CAAC,QAAQ,CAAC,aAAa;SAC5B,CAAC,CAAC;QACH,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IACjD,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
|
package/dist/demo.js
CHANGED
|
@@ -2,7 +2,7 @@ import { loadEnvFile } from "node:process";
|
|
|
2
2
|
import { Agent } from "./core/index.js";
|
|
3
3
|
import { CommandRouter } from "./middleware/CommandRouter.js";
|
|
4
4
|
import { getTestUrl } from "./utils/debug.js";
|
|
5
|
-
import { AgentError, createSigner, createUser
|
|
5
|
+
import { AgentError, createSigner, createUser } from "./utils/index.js";
|
|
6
6
|
try {
|
|
7
7
|
loadEnvFile(".env");
|
|
8
8
|
console.info(`Loaded keys from ".env" file.`);
|
|
@@ -36,9 +36,11 @@ agent.on("reaction", (ctx) => {
|
|
|
36
36
|
agent.on("reply", (ctx) => {
|
|
37
37
|
console.log("Got reply:", ctx.message.content);
|
|
38
38
|
});
|
|
39
|
-
agent.on("text",
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
agent.on("text", async (ctx) => {
|
|
40
|
+
if (ctx.message.content.startsWith("@agent")) {
|
|
41
|
+
await ctx.conversation.send("How can I help you?");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
42
44
|
const errorHandler = (error) => {
|
|
43
45
|
if (error instanceof AgentError) {
|
|
44
46
|
console.log(`Caught error ID "${error.code}"`, error);
|
package/dist/demo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"demo.js","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,M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AC,YAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,EAAE;IACtC,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,CAAC;AAEF,KAAK,CAAC,EAAE,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAEzC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,OAAO,CAAC,GAAG,CAAC,kBAAkB,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC;AAEH,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/utils/filter.d.ts
CHANGED
|
@@ -1,54 +1,16 @@
|
|
|
1
1
|
import { type Reaction } from "@xmtp/content-type-reaction";
|
|
2
2
|
import { type RemoteAttachment } from "@xmtp/content-type-remote-attachment";
|
|
3
3
|
import { type Reply } from "@xmtp/content-type-reply";
|
|
4
|
-
import type
|
|
5
|
-
import type { MessageContext } from "../core/MessageContext.js";
|
|
6
|
-
export type MessageFilter<ContentTypes> = (message: DecodedMessage, client: Client<ContentTypes>, conversation: Conversation) => boolean | Promise<boolean>;
|
|
7
|
-
/**
|
|
8
|
-
* Creates a filter for messages from specific senders
|
|
9
|
-
*
|
|
10
|
-
* @param senderInboxId - Single sender ID or array of sender IDs to match
|
|
11
|
-
* @returns Filter function
|
|
12
|
-
*/
|
|
13
|
-
declare function fromSender(senderInboxId: string | string[]): (message: DecodedMessage) => boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a filter that matches text messages starting with a specific string.
|
|
16
|
-
*
|
|
17
|
-
* @param prefix - The string prefix to match against
|
|
18
|
-
* @returns Filter function
|
|
19
|
-
*/
|
|
20
|
-
declare function startsWith(prefix: string): (message: DecodedMessage) => boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a filter that requires all provided filters to pass
|
|
23
|
-
*
|
|
24
|
-
* @param filters - Array of filters that must all return true
|
|
25
|
-
* @returns Filter function
|
|
26
|
-
*/
|
|
27
|
-
declare function and<ContentTypes>(...filters: MessageFilter<ContentTypes>[]): MessageFilter<ContentTypes>;
|
|
28
|
-
/**
|
|
29
|
-
* Creates a filter that requires at least one provided filter to pass.
|
|
30
|
-
*
|
|
31
|
-
* @param filters - Array of filters where at least one must return true
|
|
32
|
-
* @returns Filter function
|
|
33
|
-
*/
|
|
34
|
-
declare function or<ContentTypes>(...filters: MessageFilter<ContentTypes>[]): MessageFilter<ContentTypes>;
|
|
35
|
-
/**
|
|
36
|
-
* Creates a filter that inverts the result of another filter.
|
|
37
|
-
*
|
|
38
|
-
* @param filter - The filter to negate
|
|
39
|
-
* @returns Filter function
|
|
40
|
-
*/
|
|
41
|
-
declare function not<ContentTypes>(filter: MessageFilter<ContentTypes>): MessageFilter<ContentTypes>;
|
|
42
|
-
/**
|
|
43
|
-
* Pre-configured filter instances and factory functions for common filtering scenarios
|
|
44
|
-
*/
|
|
4
|
+
import { Dm, Group, type Client, type Conversation, type DecodedMessage } from "@xmtp/node-sdk";
|
|
45
5
|
export declare const filter: {
|
|
46
|
-
fromSelf: (message: DecodedMessage
|
|
47
|
-
|
|
48
|
-
content:
|
|
49
|
-
};
|
|
50
|
-
isDM:
|
|
51
|
-
isGroup:
|
|
6
|
+
fromSelf: <ContentTypes>(message: DecodedMessage<ContentTypes>, client: Client<ContentTypes>) => boolean;
|
|
7
|
+
hasContent: <ContentTypes>(message: DecodedMessage<ContentTypes>) => message is DecodedMessage<ContentTypes> & {
|
|
8
|
+
content: NonNullable<ContentTypes>;
|
|
9
|
+
};
|
|
10
|
+
isDM: (conversation: Conversation) => conversation is Dm;
|
|
11
|
+
isGroup: (conversation: Conversation) => conversation is Group;
|
|
12
|
+
isGroupAdmin: (conversation: Conversation, message: DecodedMessage) => boolean;
|
|
13
|
+
isGroupSuperAdmin: (conversation: Conversation, message: DecodedMessage) => boolean;
|
|
52
14
|
isReaction: (message: DecodedMessage) => message is DecodedMessage & {
|
|
53
15
|
content: Reaction;
|
|
54
16
|
};
|
|
@@ -61,24 +23,17 @@ export declare const filter: {
|
|
|
61
23
|
isText: (message: DecodedMessage) => message is DecodedMessage & {
|
|
62
24
|
content: string;
|
|
63
25
|
};
|
|
64
|
-
isTextReply: (message: DecodedMessage) =>
|
|
65
|
-
content: Reply & {
|
|
66
|
-
content: string;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
fromSender: typeof fromSender;
|
|
70
|
-
startsWith: typeof startsWith;
|
|
71
|
-
and: typeof and;
|
|
72
|
-
or: typeof or;
|
|
73
|
-
not: typeof not;
|
|
26
|
+
isTextReply: (message: DecodedMessage) => boolean;
|
|
74
27
|
};
|
|
75
28
|
export declare const f: {
|
|
76
|
-
fromSelf: (message: DecodedMessage
|
|
77
|
-
|
|
78
|
-
content:
|
|
79
|
-
};
|
|
80
|
-
isDM:
|
|
81
|
-
isGroup:
|
|
29
|
+
fromSelf: <ContentTypes>(message: DecodedMessage<ContentTypes>, client: Client<ContentTypes>) => boolean;
|
|
30
|
+
hasContent: <ContentTypes>(message: DecodedMessage<ContentTypes>) => message is DecodedMessage<ContentTypes> & {
|
|
31
|
+
content: NonNullable<ContentTypes>;
|
|
32
|
+
};
|
|
33
|
+
isDM: (conversation: Conversation) => conversation is Dm;
|
|
34
|
+
isGroup: (conversation: Conversation) => conversation is Group;
|
|
35
|
+
isGroupAdmin: (conversation: Conversation, message: DecodedMessage) => boolean;
|
|
36
|
+
isGroupSuperAdmin: (conversation: Conversation, message: DecodedMessage) => boolean;
|
|
82
37
|
isReaction: (message: DecodedMessage) => message is DecodedMessage & {
|
|
83
38
|
content: Reaction;
|
|
84
39
|
};
|
|
@@ -91,16 +46,5 @@ export declare const f: {
|
|
|
91
46
|
isText: (message: DecodedMessage) => message is DecodedMessage & {
|
|
92
47
|
content: string;
|
|
93
48
|
};
|
|
94
|
-
isTextReply: (message: DecodedMessage) =>
|
|
95
|
-
content: Reply & {
|
|
96
|
-
content: string;
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
fromSender: typeof fromSender;
|
|
100
|
-
startsWith: typeof startsWith;
|
|
101
|
-
and: typeof and;
|
|
102
|
-
or: typeof or;
|
|
103
|
-
not: typeof not;
|
|
49
|
+
isTextReply: (message: DecodedMessage) => boolean;
|
|
104
50
|
};
|
|
105
|
-
export declare const withFilter: <ContentTypes>(filterFn: MessageFilter<ContentTypes>, listener: (ctx: MessageContext<ContentTypes>) => void | Promise<void>) => (ctx: MessageContext<ContentTypes>) => Promise<void>;
|
|
106
|
-
export {};
|
package/dist/utils/filter.js
CHANGED
|
@@ -2,165 +2,58 @@ import { ContentTypeReaction, } from "@xmtp/content-type-reaction";
|
|
|
2
2
|
import { ContentTypeRemoteAttachment, } from "@xmtp/content-type-remote-attachment";
|
|
3
3
|
import { ContentTypeReply } from "@xmtp/content-type-reply";
|
|
4
4
|
import { ContentTypeText } from "@xmtp/content-type-text";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @returns Filter function
|
|
9
|
-
*/
|
|
10
|
-
function fromSelf() {
|
|
11
|
-
return (message, client) => {
|
|
12
|
-
return message.senderInboxId === client.inboxId;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function hasDefinedContent() {
|
|
16
|
-
return (message) => {
|
|
17
|
-
return !!message.content;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function isDM() {
|
|
21
|
-
return async (_message, _client, conversation) => {
|
|
22
|
-
return (await conversation.metadata()).conversationType === "dm";
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function isGroup() {
|
|
26
|
-
return async (_message, _client, conversation) => {
|
|
27
|
-
return (await conversation.metadata()).conversationType === "group";
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function isReaction() {
|
|
31
|
-
return (message) => {
|
|
32
|
-
return !!message.contentType?.sameAs(ContentTypeReaction);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function isReply() {
|
|
36
|
-
return (message) => {
|
|
37
|
-
return !!message.contentType?.sameAs(ContentTypeReply);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function isRemoteAttachment() {
|
|
41
|
-
return (message) => {
|
|
42
|
-
return !!message.contentType?.sameAs(ContentTypeRemoteAttachment);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Creates a filter that includes only text messages.
|
|
47
|
-
*
|
|
48
|
-
* @returns Filter function
|
|
49
|
-
*/
|
|
50
|
-
function isText() {
|
|
51
|
-
return (message) => {
|
|
52
|
-
return !!message.contentType?.sameAs(ContentTypeText);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function isTextReply() {
|
|
56
|
-
return (message) => {
|
|
57
|
-
return isReply()(message) && typeof message.content.content === "string";
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Creates a filter for messages from specific senders
|
|
62
|
-
*
|
|
63
|
-
* @param senderInboxId - Single sender ID or array of sender IDs to match
|
|
64
|
-
* @returns Filter function
|
|
65
|
-
*/
|
|
66
|
-
function fromSender(senderInboxId) {
|
|
67
|
-
const senderIds = Array.isArray(senderInboxId)
|
|
68
|
-
? senderInboxId
|
|
69
|
-
: [senderInboxId];
|
|
70
|
-
return (message) => {
|
|
71
|
-
return senderIds.includes(message.senderInboxId);
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Creates a filter that matches text messages starting with a specific string.
|
|
76
|
-
*
|
|
77
|
-
* @param prefix - The string prefix to match against
|
|
78
|
-
* @returns Filter function
|
|
79
|
-
*/
|
|
80
|
-
function startsWith(prefix) {
|
|
81
|
-
return (message) => {
|
|
82
|
-
const getTextContent = (message) => {
|
|
83
|
-
switch (true) {
|
|
84
|
-
case filter.isReaction(message):
|
|
85
|
-
case filter.isTextReply(message):
|
|
86
|
-
return message.content.content;
|
|
87
|
-
case filter.isText(message):
|
|
88
|
-
return message.content;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const text = getTextContent(message);
|
|
92
|
-
return !!(text && text.startsWith(prefix));
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Creates a filter that requires all provided filters to pass
|
|
97
|
-
*
|
|
98
|
-
* @param filters - Array of filters that must all return true
|
|
99
|
-
* @returns Filter function
|
|
100
|
-
*/
|
|
101
|
-
function and(...filters) {
|
|
102
|
-
return async (message, client, conversation) => {
|
|
103
|
-
for (const filter of filters) {
|
|
104
|
-
const result = await filter(message, client, conversation);
|
|
105
|
-
if (!result)
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Creates a filter that requires at least one provided filter to pass.
|
|
113
|
-
*
|
|
114
|
-
* @param filters - Array of filters where at least one must return true
|
|
115
|
-
* @returns Filter function
|
|
116
|
-
*/
|
|
117
|
-
function or(...filters) {
|
|
118
|
-
return async (message, client, conversation) => {
|
|
119
|
-
for (const filter of filters) {
|
|
120
|
-
const result = await filter(message, client, conversation);
|
|
121
|
-
if (result)
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
return false;
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Creates a filter that inverts the result of another filter.
|
|
129
|
-
*
|
|
130
|
-
* @param filter - The filter to negate
|
|
131
|
-
* @returns Filter function
|
|
132
|
-
*/
|
|
133
|
-
function not(filter) {
|
|
134
|
-
return async (message, client, conversation) => {
|
|
135
|
-
return !(await filter(message, client, conversation));
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Pre-configured filter instances and factory functions for common filtering scenarios
|
|
140
|
-
*/
|
|
141
|
-
export const filter = {
|
|
142
|
-
// basic filters
|
|
143
|
-
fromSelf: fromSelf(),
|
|
144
|
-
hasDefinedContent: hasDefinedContent(),
|
|
145
|
-
isDM: isDM(),
|
|
146
|
-
isGroup: isGroup(),
|
|
147
|
-
isReaction: isReaction(),
|
|
148
|
-
isRemoteAttachment: isRemoteAttachment(),
|
|
149
|
-
isReply: isReply(),
|
|
150
|
-
isText: isText(),
|
|
151
|
-
isTextReply: isTextReply(),
|
|
152
|
-
// factory functions
|
|
153
|
-
fromSender,
|
|
154
|
-
startsWith,
|
|
155
|
-
// combinators
|
|
156
|
-
and,
|
|
157
|
-
or,
|
|
158
|
-
not,
|
|
5
|
+
import { Dm, Group, } from "@xmtp/node-sdk";
|
|
6
|
+
const fromSelf = (message, client) => {
|
|
7
|
+
return message.senderInboxId === client.inboxId;
|
|
159
8
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
9
|
+
const hasContent = (message) => {
|
|
10
|
+
return message.content !== undefined && message.content !== null;
|
|
11
|
+
};
|
|
12
|
+
const isDM = (conversation) => {
|
|
13
|
+
return conversation instanceof Dm;
|
|
14
|
+
};
|
|
15
|
+
const isGroup = (conversation) => {
|
|
16
|
+
return conversation instanceof Group;
|
|
17
|
+
};
|
|
18
|
+
const isGroupAdmin = (conversation, message) => {
|
|
19
|
+
if (isGroup(conversation)) {
|
|
20
|
+
return conversation.isAdmin(message.senderInboxId);
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
24
|
+
const isGroupSuperAdmin = (conversation, message) => {
|
|
25
|
+
if (isGroup(conversation)) {
|
|
26
|
+
return conversation.isSuperAdmin(message.senderInboxId);
|
|
164
27
|
}
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
const isReaction = (message) => {
|
|
31
|
+
return !!message.contentType?.sameAs(ContentTypeReaction);
|
|
165
32
|
};
|
|
33
|
+
const isReply = (message) => {
|
|
34
|
+
return !!message.contentType?.sameAs(ContentTypeReply);
|
|
35
|
+
};
|
|
36
|
+
const isRemoteAttachment = (message) => {
|
|
37
|
+
return !!message.contentType?.sameAs(ContentTypeRemoteAttachment);
|
|
38
|
+
};
|
|
39
|
+
const isText = (message) => {
|
|
40
|
+
return !!message.contentType?.sameAs(ContentTypeText);
|
|
41
|
+
};
|
|
42
|
+
const isTextReply = (message) => {
|
|
43
|
+
return isReply(message) && typeof message.content.content === "string";
|
|
44
|
+
};
|
|
45
|
+
export const filter = {
|
|
46
|
+
fromSelf,
|
|
47
|
+
hasContent,
|
|
48
|
+
isDM,
|
|
49
|
+
isGroup,
|
|
50
|
+
isGroupAdmin,
|
|
51
|
+
isGroupSuperAdmin,
|
|
52
|
+
isReaction,
|
|
53
|
+
isRemoteAttachment,
|
|
54
|
+
isReply,
|
|
55
|
+
isText,
|
|
56
|
+
isTextReply,
|
|
57
|
+
};
|
|
58
|
+
export const f = filter;
|
|
166
59
|
//# sourceMappingURL=filter.js.map
|
package/dist/utils/filter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/utils/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,2BAA2B,GAE5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAc,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/utils/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,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M,UAAU,GAAG,CACjB,OAAuB,EAC4B,EAAE;IACrD,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CACd,OAAuB,EACyB,EAAE;IAClD,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,OAAuB,EACoC,EAAE;IAC7D,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,2BAA2B,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CACb,OAAuB,EAC0B,EAAE;IACnD,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,OAAuB,EAAE,EAAE;IAC9C,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,OAAO;IACP,YAAY;IACZ,iBAAiB;IACjB,UAAU;IACV,kBAAkB;IAClB,OAAO;IACP,MAAM;IACN,WAAW;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"@xmtp/content-type-remote-attachment": "^2.0.2",
|
|
9
9
|
"@xmtp/content-type-reply": "^2.0.2",
|
|
10
10
|
"@xmtp/content-type-text": "^2.0.2",
|
|
11
|
-
"@xmtp/node-sdk": "^4.1.
|
|
11
|
+
"@xmtp/node-sdk": "^4.1.1",
|
|
12
12
|
"uint8arrays": "^5.1.0",
|
|
13
|
-
"viem": "^2.
|
|
13
|
+
"viem": "^2.37.6"
|
|
14
14
|
},
|
|
15
15
|
"description": "XMTP Agent SDK for interacting with XMTP networks",
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
18
|
-
"@types/node": "^22.
|
|
18
|
+
"@types/node": "^22.18.4",
|
|
19
19
|
"@vitest/coverage-v8": "^3.2.4",
|
|
20
20
|
"tsc-alias": "^1.8.16",
|
|
21
|
-
"tsx": "^4.20.
|
|
22
|
-
"typescript": "^5.
|
|
23
|
-
"vite": "^7.
|
|
21
|
+
"tsx": "^4.20.5",
|
|
22
|
+
"typescript": "^5.9.2",
|
|
23
|
+
"vite": "^7.1.5",
|
|
24
24
|
"vite-tsconfig-paths": "^5.1.4",
|
|
25
25
|
"vitest": "^3.2.4"
|
|
26
26
|
},
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"typecheck": "tsc --noEmit"
|
|
71
71
|
},
|
|
72
72
|
"type": "module",
|
|
73
|
-
"version": "0.0.
|
|
73
|
+
"version": "0.0.13"
|
|
74
74
|
}
|