@elizaos/plugin-tlon 2.0.0-alpha.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/dist/actions/sendMessage.d.ts +7 -0
- package/dist/actions/sendMessage.d.ts.map +1 -0
- package/dist/client.d.ts +104 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/constants.d.ts +17 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/environment.d.ts +79 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5189 -0
- package/dist/index.js.map +25 -0
- package/dist/providers/chatState.d.ts +7 -0
- package/dist/providers/chatState.d.ts.map +1 -0
- package/dist/service.d.ts +61 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/types.d.ts +226 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +74 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Provider } from "@elizaos/core";
|
|
2
|
+
export declare const CHAT_STATE_PROVIDER = "tlon_chat_state";
|
|
3
|
+
/**
|
|
4
|
+
* Provider that exposes the current Tlon chat context
|
|
5
|
+
*/
|
|
6
|
+
export declare const chatStateProvider: Provider;
|
|
7
|
+
//# sourceMappingURL=chatState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatState.d.ts","sourceRoot":"","sources":["../../src/providers/chatState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,QAAQ,EAGT,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAmE/B,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Content, type IAgentRuntime, Service, type TargetInfo } from "@elizaos/core";
|
|
2
|
+
import { type TlonClient } from "./client";
|
|
3
|
+
import { type TlonSettings } from "./environment";
|
|
4
|
+
/**
|
|
5
|
+
* Tlon/Urbit service for elizaOS
|
|
6
|
+
*/
|
|
7
|
+
export declare class TlonService extends Service {
|
|
8
|
+
static serviceType: string;
|
|
9
|
+
capabilityDescription: string;
|
|
10
|
+
private client;
|
|
11
|
+
private settings;
|
|
12
|
+
private subscribedChannels;
|
|
13
|
+
private subscribedDMs;
|
|
14
|
+
private processedMessages;
|
|
15
|
+
private maxProcessedMessages;
|
|
16
|
+
constructor(runtime?: IAgentRuntime);
|
|
17
|
+
/**
|
|
18
|
+
* Start the Tlon service
|
|
19
|
+
*/
|
|
20
|
+
static start(runtime: IAgentRuntime): Promise<TlonService>;
|
|
21
|
+
/**
|
|
22
|
+
* Stop the Tlon service
|
|
23
|
+
*/
|
|
24
|
+
static stop(runtime: IAgentRuntime): Promise<void>;
|
|
25
|
+
stop(): Promise<void>;
|
|
26
|
+
private initializeSubscriptions;
|
|
27
|
+
private discoverChannels;
|
|
28
|
+
private subscribeToDM;
|
|
29
|
+
private subscribeToChannel;
|
|
30
|
+
private markMessageProcessed;
|
|
31
|
+
private handleDMEvent;
|
|
32
|
+
private handleChannelEvent;
|
|
33
|
+
private emitMessageEvent;
|
|
34
|
+
/**
|
|
35
|
+
* Send a direct message to a ship
|
|
36
|
+
*/
|
|
37
|
+
sendDirectMessage(toShip: string, text: string): Promise<{
|
|
38
|
+
messageId: string;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Send a message to a group channel
|
|
42
|
+
*/
|
|
43
|
+
sendChannelMessage(channelNest: string, text: string, replyToId?: string): Promise<{
|
|
44
|
+
messageId: string;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Register the send handler with the runtime
|
|
48
|
+
*/
|
|
49
|
+
static registerSendHandlers(runtime: IAgentRuntime, serviceInstance: TlonService): void;
|
|
50
|
+
/**
|
|
51
|
+
* Handle outgoing messages from the runtime
|
|
52
|
+
*/
|
|
53
|
+
handleSendMessage(runtime: IAgentRuntime, target: TargetInfo, content: Content): Promise<void>;
|
|
54
|
+
/** Get the underlying client */
|
|
55
|
+
getClient(): TlonClient | null;
|
|
56
|
+
/** Get the current settings */
|
|
57
|
+
getSettings(): TlonSettings | null;
|
|
58
|
+
/** Check if service is connected */
|
|
59
|
+
isConnected(): boolean;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EAEZ,KAAK,aAAa,EAElB,OAAO,EACP,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAO,EAKL,KAAK,YAAY,EAElB,MAAM,eAAe,CAAC;AAsBvB;;GAEG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACtC,MAAM,CAAC,WAAW,SAAqB;IACvC,qBAAqB,SAC4C;IAEjE,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,oBAAoB,CAAQ;gBAExB,OAAO,CAAC,EAAE,aAAa;IAInC;;OAEG;WACU,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;IA0EhE;;OAEG;WACU,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IASlD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAUb,uBAAuB;YAuCvB,gBAAgB;YAgBhB,aAAa;YAsBb,kBAAkB;IAgChC,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,aAAa;IAiDrB,OAAO,CAAC,kBAAkB;IAgF1B,OAAO,CAAC,gBAAgB;IAyBxB;;OAEG;IACG,iBAAiB,CACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAajC;;OAEG;IACG,kBAAkB,CACtB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAoBjC;;OAEG;IACH,MAAM,CAAC,oBAAoB,CACzB,OAAO,EAAE,aAAa,EACtB,eAAe,EAAE,WAAW,GAC3B,IAAI;IAcP;;OAEG;IACG,iBAAiB,CACrB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC;IA4ChB,gCAAgC;IAChC,SAAS,IAAI,UAAU,GAAG,IAAI;IAI9B,+BAA+B;IAC/B,WAAW,IAAI,YAAY,GAAG,IAAI;IAIlC,oCAAoC;IACpC,WAAW,IAAI,OAAO;CAGvB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import type { Content, EntityPayload, MessagePayload, WorldPayload } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Extended content type for Tlon messages
|
|
4
|
+
*/
|
|
5
|
+
export interface TlonContent extends Content {
|
|
6
|
+
/** The ship that sent the message */
|
|
7
|
+
ship?: string;
|
|
8
|
+
/** Channel nest for group messages */
|
|
9
|
+
channelNest?: string;
|
|
10
|
+
/** Parent message ID for thread replies */
|
|
11
|
+
replyToId?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Event types emitted by the Tlon plugin
|
|
15
|
+
*/
|
|
16
|
+
export declare enum TlonEventTypes {
|
|
17
|
+
WORLD_JOINED = "TLON_WORLD_JOINED",
|
|
18
|
+
WORLD_CONNECTED = "TLON_WORLD_CONNECTED",
|
|
19
|
+
WORLD_LEFT = "TLON_WORLD_LEFT",
|
|
20
|
+
ENTITY_JOINED = "TLON_ENTITY_JOINED",
|
|
21
|
+
ENTITY_LEFT = "TLON_ENTITY_LEFT",
|
|
22
|
+
MESSAGE_RECEIVED = "TLON_MESSAGE_RECEIVED",
|
|
23
|
+
MESSAGE_SENT = "TLON_MESSAGE_SENT",
|
|
24
|
+
DM_RECEIVED = "TLON_DM_RECEIVED",
|
|
25
|
+
GROUP_MESSAGE_RECEIVED = "TLON_GROUP_MESSAGE_RECEIVED",
|
|
26
|
+
CONNECTION_ERROR = "TLON_CONNECTION_ERROR",
|
|
27
|
+
RECONNECTED = "TLON_RECONNECTED"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tlon channel types
|
|
31
|
+
*/
|
|
32
|
+
export declare enum TlonChannelType {
|
|
33
|
+
DM = "dm",
|
|
34
|
+
GROUP = "group",
|
|
35
|
+
THREAD = "thread"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Urbit ship information
|
|
39
|
+
*/
|
|
40
|
+
export interface TlonShip {
|
|
41
|
+
/** Ship name (without ~) */
|
|
42
|
+
name: string;
|
|
43
|
+
/** Display name if available */
|
|
44
|
+
displayName?: string;
|
|
45
|
+
/** Ship avatar URL */
|
|
46
|
+
avatar?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Tlon chat/channel information
|
|
50
|
+
*/
|
|
51
|
+
export interface TlonChat {
|
|
52
|
+
/** Channel identifier (ship for DM, nest for groups) */
|
|
53
|
+
id: string;
|
|
54
|
+
/** Channel type */
|
|
55
|
+
type: TlonChannelType;
|
|
56
|
+
/** Channel name/title */
|
|
57
|
+
name?: string;
|
|
58
|
+
/** Host ship for group channels */
|
|
59
|
+
hostShip?: string;
|
|
60
|
+
/** Channel description */
|
|
61
|
+
description?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Payload for received messages
|
|
65
|
+
*/
|
|
66
|
+
export interface TlonMessagePayload extends MessagePayload {
|
|
67
|
+
/** The message ID */
|
|
68
|
+
messageId: string;
|
|
69
|
+
/** The chat where the message was received */
|
|
70
|
+
chat: TlonChat;
|
|
71
|
+
/** The sender ship */
|
|
72
|
+
fromShip: TlonShip;
|
|
73
|
+
/** Message text content */
|
|
74
|
+
text: string;
|
|
75
|
+
/** Timestamp (ms since epoch) */
|
|
76
|
+
timestamp: number;
|
|
77
|
+
/** Parent message ID for thread replies */
|
|
78
|
+
replyToId?: string;
|
|
79
|
+
/** Raw memo content from Urbit */
|
|
80
|
+
rawContent?: unknown;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Payload for sent messages
|
|
84
|
+
*/
|
|
85
|
+
export interface TlonMessageSentPayload extends MessagePayload {
|
|
86
|
+
/** The message ID */
|
|
87
|
+
messageId: string;
|
|
88
|
+
/** Target chat */
|
|
89
|
+
chat: TlonChat;
|
|
90
|
+
/** Message text */
|
|
91
|
+
text: string;
|
|
92
|
+
/** Whether it was a reply */
|
|
93
|
+
isReply: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Payload for world/connection events
|
|
97
|
+
*/
|
|
98
|
+
export interface TlonWorldPayload extends WorldPayload {
|
|
99
|
+
/** The connected ship */
|
|
100
|
+
ship: TlonShip;
|
|
101
|
+
/** Available DM conversations */
|
|
102
|
+
dmConversations?: string[];
|
|
103
|
+
/** Available group channels */
|
|
104
|
+
groupChannels?: string[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Payload for entity (ship) events
|
|
108
|
+
*/
|
|
109
|
+
export interface TlonEntityPayload extends EntityPayload {
|
|
110
|
+
/** The ship involved */
|
|
111
|
+
ship: TlonShip;
|
|
112
|
+
/** The chat context */
|
|
113
|
+
chat: TlonChat;
|
|
114
|
+
/** Action type */
|
|
115
|
+
action: "joined" | "left" | "updated";
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Event payload map for type safety
|
|
119
|
+
*/
|
|
120
|
+
export interface TlonEventPayloadMap {
|
|
121
|
+
[TlonEventTypes.MESSAGE_RECEIVED]: TlonMessagePayload;
|
|
122
|
+
[TlonEventTypes.MESSAGE_SENT]: TlonMessageSentPayload;
|
|
123
|
+
[TlonEventTypes.DM_RECEIVED]: TlonMessagePayload;
|
|
124
|
+
[TlonEventTypes.GROUP_MESSAGE_RECEIVED]: TlonMessagePayload;
|
|
125
|
+
[TlonEventTypes.WORLD_JOINED]: TlonWorldPayload;
|
|
126
|
+
[TlonEventTypes.WORLD_CONNECTED]: TlonWorldPayload;
|
|
127
|
+
[TlonEventTypes.WORLD_LEFT]: TlonWorldPayload;
|
|
128
|
+
[TlonEventTypes.ENTITY_JOINED]: TlonEntityPayload;
|
|
129
|
+
[TlonEventTypes.ENTITY_LEFT]: TlonEntityPayload;
|
|
130
|
+
[TlonEventTypes.CONNECTION_ERROR]: {
|
|
131
|
+
error: Error;
|
|
132
|
+
willRetry: boolean;
|
|
133
|
+
};
|
|
134
|
+
[TlonEventTypes.RECONNECTED]: {
|
|
135
|
+
attempt: number;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Authorization rule for a channel
|
|
140
|
+
*/
|
|
141
|
+
export interface TlonChannelRule {
|
|
142
|
+
/** Authorization mode */
|
|
143
|
+
mode: "restricted" | "open";
|
|
144
|
+
/** List of ships allowed when in restricted mode */
|
|
145
|
+
allowedShips?: string[];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Plugin authorization configuration
|
|
149
|
+
*/
|
|
150
|
+
export interface TlonAuthorization {
|
|
151
|
+
/** Rules by channel nest */
|
|
152
|
+
channelRules?: Record<string, TlonChannelRule>;
|
|
153
|
+
/** Default allowed ships for all channels */
|
|
154
|
+
defaultAuthorizedShips?: string[];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Message content as sent/received from Urbit
|
|
158
|
+
*/
|
|
159
|
+
export interface TlonMemo {
|
|
160
|
+
content: TlonStory;
|
|
161
|
+
author: string;
|
|
162
|
+
sent: number;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Story content (array of verse elements)
|
|
166
|
+
*/
|
|
167
|
+
export type TlonStory = TlonVerse[];
|
|
168
|
+
/**
|
|
169
|
+
* Verse element (inline content)
|
|
170
|
+
*/
|
|
171
|
+
export interface TlonVerse {
|
|
172
|
+
inline?: TlonInline[];
|
|
173
|
+
block?: TlonBlock;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Inline content types
|
|
177
|
+
*/
|
|
178
|
+
export type TlonInline = string | TlonInlineElement;
|
|
179
|
+
/**
|
|
180
|
+
* Inline element types (links, mentions, etc.)
|
|
181
|
+
*/
|
|
182
|
+
export interface TlonInlineElement {
|
|
183
|
+
ship?: string;
|
|
184
|
+
link?: {
|
|
185
|
+
href: string;
|
|
186
|
+
content: string;
|
|
187
|
+
};
|
|
188
|
+
bold?: TlonInline[];
|
|
189
|
+
italic?: TlonInline[];
|
|
190
|
+
strike?: TlonInline[];
|
|
191
|
+
code?: string;
|
|
192
|
+
blockquote?: TlonInline[];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Block content types (images, code blocks, etc.)
|
|
196
|
+
*/
|
|
197
|
+
export interface TlonBlock {
|
|
198
|
+
image?: {
|
|
199
|
+
src: string;
|
|
200
|
+
alt?: string;
|
|
201
|
+
width?: number;
|
|
202
|
+
height?: number;
|
|
203
|
+
};
|
|
204
|
+
code?: {
|
|
205
|
+
code: string;
|
|
206
|
+
lang?: string;
|
|
207
|
+
};
|
|
208
|
+
header?: {
|
|
209
|
+
content: TlonInline[];
|
|
210
|
+
tag: "h1" | "h2" | "h3";
|
|
211
|
+
};
|
|
212
|
+
listing?: {
|
|
213
|
+
type: "ordered" | "unordered";
|
|
214
|
+
items: TlonInline[][];
|
|
215
|
+
};
|
|
216
|
+
rule?: boolean;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Subscription information
|
|
220
|
+
*/
|
|
221
|
+
export interface TlonSubscription {
|
|
222
|
+
id: number;
|
|
223
|
+
app: string;
|
|
224
|
+
path: string;
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,cAAc,EACd,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO;IAC1C,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,YAAY,sBAAsB;IAClC,eAAe,yBAAyB;IACxC,UAAU,oBAAoB;IAC9B,aAAa,uBAAuB;IACpC,WAAW,qBAAqB;IAChC,gBAAgB,0BAA0B;IAC1C,YAAY,sBAAsB;IAClC,WAAW,qBAAqB;IAChC,sBAAsB,gCAAgC;IACtD,gBAAgB,0BAA0B;IAC1C,WAAW,qBAAqB;CACjC;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,EAAE,OAAO;IACT,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,EAAE,EAAE,MAA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I,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for poke API (subset of TlonClient)
|
|
3
|
+
*/
|
|
4
|
+
export interface TlonPokeApi {
|
|
5
|
+
poke: (params: {
|
|
6
|
+
app: string;
|
|
7
|
+
mark: string;
|
|
8
|
+
json: unknown;
|
|
9
|
+
}) => Promise<unknown>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Format a number as Urbit @ud (with dots)
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatUd(n: bigint): string;
|
|
15
|
+
/**
|
|
16
|
+
* Convert Unix timestamp (ms) to Urbit @da
|
|
17
|
+
*/
|
|
18
|
+
export declare function unixToUrbitDa(unixMs: number): bigint;
|
|
19
|
+
/**
|
|
20
|
+
* Generate a Urbit-style message ID
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateMessageId(ship: string, timestamp: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Parameters for sending a DM
|
|
25
|
+
*/
|
|
26
|
+
interface SendDmParams {
|
|
27
|
+
api: TlonPokeApi;
|
|
28
|
+
fromShip: string;
|
|
29
|
+
toShip: string;
|
|
30
|
+
text: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Send a direct message to another ship
|
|
34
|
+
*/
|
|
35
|
+
export declare function sendDm({ api, fromShip, toShip, text, }: SendDmParams): Promise<{
|
|
36
|
+
channel: string;
|
|
37
|
+
messageId: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Parameters for sending a group message
|
|
41
|
+
*/
|
|
42
|
+
interface SendGroupParams {
|
|
43
|
+
api: TlonPokeApi;
|
|
44
|
+
fromShip: string;
|
|
45
|
+
hostShip: string;
|
|
46
|
+
channelName: string;
|
|
47
|
+
text: string;
|
|
48
|
+
replyToId?: string | null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Send a message to a group channel
|
|
52
|
+
*/
|
|
53
|
+
export declare function sendGroupMessage({ api, fromShip, hostShip, channelName, text, replyToId, }: SendGroupParams): Promise<{
|
|
54
|
+
channel: string;
|
|
55
|
+
messageId: string;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Extract plain text from Tlon story/content format
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractMessageText(content: unknown): string;
|
|
61
|
+
/**
|
|
62
|
+
* Build message text combining text and optional media URL
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildMediaText(text: string | undefined, mediaUrl: string | undefined): string;
|
|
65
|
+
/**
|
|
66
|
+
* Check if a ship is mentioned in the message text
|
|
67
|
+
*/
|
|
68
|
+
export declare function isBotMentioned(text: string, botShip: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a ship is in the DM allowlist
|
|
71
|
+
*/
|
|
72
|
+
export declare function isDmAllowed(ship: string, allowlist: string[]): boolean;
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,CAAC,MAAM,EAAE;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;KACf,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO1C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM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;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAItE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elizaos/plugin-tlon",
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "bun build.ts",
|
|
18
|
+
"dev": "bun --hot build.ts",
|
|
19
|
+
"typecheck": "tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"zod": "^4.3.6"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@elizaos/core": "2.0.0-alpha.1",
|
|
26
|
+
"@types/bun": "^1.3.5",
|
|
27
|
+
"@types/node": "^25.0.3",
|
|
28
|
+
"typescript": "^5.9.3"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@elizaos/core": "workspace:*"
|
|
32
|
+
},
|
|
33
|
+
"milaidy": {
|
|
34
|
+
"platforms": [
|
|
35
|
+
"node"
|
|
36
|
+
],
|
|
37
|
+
"runtime": "node",
|
|
38
|
+
"platformDetails": {
|
|
39
|
+
"node": "ESM build available via exports.import"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|