@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 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAkI/B,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger interface for the SSE client
|
|
3
|
+
*/
|
|
4
|
+
export interface TlonClientLogger {
|
|
5
|
+
log?: (message: string) => void;
|
|
6
|
+
error?: (message: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating a TlonClient
|
|
10
|
+
*/
|
|
11
|
+
export interface TlonClientOptions {
|
|
12
|
+
/** Ship name (without ~) */
|
|
13
|
+
ship?: string;
|
|
14
|
+
/** Callback when reconnection occurs */
|
|
15
|
+
onReconnect?: (client: TlonClient) => Promise<void> | void;
|
|
16
|
+
/** Enable auto-reconnection (default: true) */
|
|
17
|
+
autoReconnect?: boolean;
|
|
18
|
+
/** Max reconnection attempts (default: 10) */
|
|
19
|
+
maxReconnectAttempts?: number;
|
|
20
|
+
/** Initial reconnect delay in ms (default: 1000) */
|
|
21
|
+
reconnectDelay?: number;
|
|
22
|
+
/** Maximum reconnect delay in ms (default: 30000) */
|
|
23
|
+
maxReconnectDelay?: number;
|
|
24
|
+
/** Logger instance */
|
|
25
|
+
logger?: TlonClientLogger;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Subscription parameters
|
|
29
|
+
*/
|
|
30
|
+
export interface SubscribeParams {
|
|
31
|
+
app: string;
|
|
32
|
+
path: string;
|
|
33
|
+
event?: (data: unknown) => void;
|
|
34
|
+
err?: (error: unknown) => void;
|
|
35
|
+
quit?: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Poke parameters
|
|
39
|
+
*/
|
|
40
|
+
export interface PokeParams {
|
|
41
|
+
app: string;
|
|
42
|
+
mark: string;
|
|
43
|
+
json: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Authenticates with an Urbit ship and returns the session cookie
|
|
47
|
+
*/
|
|
48
|
+
export declare function authenticate(url: string, code: string): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Tlon/Urbit HTTP API client with SSE support
|
|
51
|
+
*/
|
|
52
|
+
export declare class TlonClient {
|
|
53
|
+
readonly url: string;
|
|
54
|
+
readonly cookie: string;
|
|
55
|
+
readonly ship: string;
|
|
56
|
+
private channelId;
|
|
57
|
+
private channelUrl;
|
|
58
|
+
private subscriptions;
|
|
59
|
+
private eventHandlers;
|
|
60
|
+
private aborted;
|
|
61
|
+
private onReconnect;
|
|
62
|
+
private autoReconnect;
|
|
63
|
+
private reconnectAttempts;
|
|
64
|
+
private maxReconnectAttempts;
|
|
65
|
+
private reconnectDelay;
|
|
66
|
+
private maxReconnectDelay;
|
|
67
|
+
private _isConnected;
|
|
68
|
+
private clientLogger;
|
|
69
|
+
constructor(url: string, cookie: string, options?: TlonClientOptions);
|
|
70
|
+
/** Whether the client is currently connected */
|
|
71
|
+
get isConnected(): boolean;
|
|
72
|
+
private generateChannelId;
|
|
73
|
+
private resolveShipFromUrl;
|
|
74
|
+
/**
|
|
75
|
+
* Subscribe to an app's path for updates
|
|
76
|
+
*/
|
|
77
|
+
subscribe(params: SubscribeParams): Promise<number>;
|
|
78
|
+
private sendSubscription;
|
|
79
|
+
/**
|
|
80
|
+
* Connect to the Urbit ship and start receiving events
|
|
81
|
+
*/
|
|
82
|
+
connect(): Promise<void>;
|
|
83
|
+
private openStream;
|
|
84
|
+
private processStream;
|
|
85
|
+
private processEvent;
|
|
86
|
+
/**
|
|
87
|
+
* Send a poke to an app
|
|
88
|
+
*/
|
|
89
|
+
poke(params: PokeParams): Promise<number>;
|
|
90
|
+
/**
|
|
91
|
+
* Perform a scry (read-only query)
|
|
92
|
+
*/
|
|
93
|
+
scry<T = unknown>(path: string): Promise<T>;
|
|
94
|
+
private attemptReconnect;
|
|
95
|
+
/**
|
|
96
|
+
* Close the connection and cleanup
|
|
97
|
+
*/
|
|
98
|
+
close(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Helper to create and authenticate a TlonClient
|
|
102
|
+
*/
|
|
103
|
+
export declare function createTlonClient(url: string, code: string, options?: TlonClientOptions): Promise<TlonClient>;
|
|
104
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,CAAC,OAAO,E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
* Service name for the Tlon plugin
|
|
3
|
+
*/
|
|
4
|
+
export declare const TLON_SERVICE_NAME = "tlon";
|
|
5
|
+
/**
|
|
6
|
+
* Plugin name
|
|
7
|
+
*/
|
|
8
|
+
export declare const PLUGIN_NAME = "tlon";
|
|
9
|
+
/**
|
|
10
|
+
* Plugin version
|
|
11
|
+
*/
|
|
12
|
+
export declare const PLUGIN_VERSION = "2.0.0-alpha.1";
|
|
13
|
+
/**
|
|
14
|
+
* Plugin description
|
|
15
|
+
*/
|
|
16
|
+
export declare const PLUGIN_DESCRIPTION = "Tlon/Urbit integration for elizaOS agents";
|
|
17
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,kBAAkB,8CAA8C,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Schema for validating Tlon environment configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare const tlonEnvSchema: z.ZodObject<{
|
|
7
|
+
TLON_SHIP: z.ZodString;
|
|
8
|
+
TLON_URL: z.ZodString;
|
|
9
|
+
TLON_CODE: z.ZodString;
|
|
10
|
+
TLON_ENABLED: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
11
|
+
TLON_GROUP_CHANNELS: z.ZodOptional<z.ZodString>;
|
|
12
|
+
TLON_DM_ALLOWLIST: z.ZodOptional<z.ZodString>;
|
|
13
|
+
TLON_AUTO_DISCOVER_CHANNELS: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
TLON_SHIP: string;
|
|
16
|
+
TLON_URL: string;
|
|
17
|
+
TLON_CODE: string;
|
|
18
|
+
TLON_ENABLED: boolean;
|
|
19
|
+
TLON_AUTO_DISCOVER_CHANNELS: boolean;
|
|
20
|
+
TLON_GROUP_CHANNELS?: string | undefined;
|
|
21
|
+
TLON_DM_ALLOWLIST?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
TLON_SHIP: string;
|
|
24
|
+
TLON_URL: string;
|
|
25
|
+
TLON_CODE: string;
|
|
26
|
+
TLON_ENABLED?: boolean | undefined;
|
|
27
|
+
TLON_GROUP_CHANNELS?: string | undefined;
|
|
28
|
+
TLON_DM_ALLOWLIST?: string | undefined;
|
|
29
|
+
TLON_AUTO_DISCOVER_CHANNELS?: boolean | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export type TlonEnvConfig = z.infer<typeof tlonEnvSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* Parsed and validated Tlon settings
|
|
34
|
+
*/
|
|
35
|
+
export interface TlonSettings {
|
|
36
|
+
/** Ship name (normalized without ~) */
|
|
37
|
+
ship: string;
|
|
38
|
+
/** Urbit HTTP API URL */
|
|
39
|
+
url: string;
|
|
40
|
+
/** Authentication code */
|
|
41
|
+
code: string;
|
|
42
|
+
/** Whether the plugin is enabled */
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
/** Group channels to monitor */
|
|
45
|
+
groupChannels: string[];
|
|
46
|
+
/** Ships allowed to send DMs */
|
|
47
|
+
dmAllowlist: string[];
|
|
48
|
+
/** Auto-discover channels */
|
|
49
|
+
autoDiscoverChannels: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Normalizes a ship name by removing the ~ prefix if present
|
|
53
|
+
*/
|
|
54
|
+
export declare function normalizeShip(ship: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Formats a ship name with the ~ prefix
|
|
57
|
+
*/
|
|
58
|
+
export declare function formatShip(ship: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Validates and returns Tlon configuration from runtime settings
|
|
61
|
+
*/
|
|
62
|
+
export declare function validateTlonConfig(runtime: IAgentRuntime): Promise<TlonEnvConfig | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Builds TlonSettings from validated config
|
|
65
|
+
*/
|
|
66
|
+
export declare function buildTlonSettings(config: TlonEnvConfig): TlonSettings;
|
|
67
|
+
/**
|
|
68
|
+
* Parses a channel nest string (e.g., "chat/~host/channel-name")
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseChannelNest(nest: string): {
|
|
71
|
+
kind: string;
|
|
72
|
+
hostShip: string;
|
|
73
|
+
channelName: string;
|
|
74
|
+
} | null;
|
|
75
|
+
/**
|
|
76
|
+
* Builds a channel nest string from components
|
|
77
|
+
*/
|
|
78
|
+
export declare function buildChannelNest(kind: string, hostShip: string, channelName: string): string;
|
|
79
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;EAQxB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gCAAgC;IAChC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,6BAA6B;IAC7B,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AAeD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA6B/B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,YAAY,CAUrE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,IAAI,CAYP;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Plugin } from "@elizaos/core";
|
|
2
|
+
import { SEND_MESSAGE_ACTION, sendMessageAction } from "./actions/sendMessage";
|
|
3
|
+
import { TLON_SERVICE_NAME } from "./constants";
|
|
4
|
+
import { CHAT_STATE_PROVIDER, chatStateProvider } from "./providers/chatState";
|
|
5
|
+
import { TlonService } from "./service";
|
|
6
|
+
/**
|
|
7
|
+
* Tlon/Urbit plugin for elizaOS
|
|
8
|
+
*
|
|
9
|
+
* Provides integration with Urbit ships via the Tlon messaging protocol.
|
|
10
|
+
* Supports:
|
|
11
|
+
* - Direct messages (DMs)
|
|
12
|
+
* - Group channels
|
|
13
|
+
* - Thread replies
|
|
14
|
+
* - Real-time SSE-based message streaming
|
|
15
|
+
* - Channel authorization
|
|
16
|
+
*/
|
|
17
|
+
declare const tlonPlugin: Plugin;
|
|
18
|
+
export { TlonService, sendMessageAction, SEND_MESSAGE_ACTION, chatStateProvider, CHAT_STATE_PROVIDER, TLON_SERVICE_NAME, };
|
|
19
|
+
export * from "./client";
|
|
20
|
+
export * from "./environment";
|
|
21
|
+
export * from "./types";
|
|
22
|
+
export * from "./utils";
|
|
23
|
+
export default tlonPlugin;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAGL,iBAAiB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,UAAU,EAAE,MAOjB,CAAC;AAGF,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAE9B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAExB,eAAe,UAAU,CAAC"}
|