@elizaos/plugin-nostr 2.0.0-alpha.7 → 2.0.0-beta.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/README.md +200 -0
- package/auto-enable.ts +20 -0
- package/dist/src/accounts.d.ts +15 -0
- package/dist/src/accounts.d.ts.map +1 -0
- package/dist/src/accounts.js +139 -0
- package/dist/src/accounts.js.map +1 -0
- package/dist/src/actions/index.d.ts +7 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +7 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/actions/publishProfile.d.ts +6 -0
- package/dist/src/actions/publishProfile.d.ts.map +1 -0
- package/dist/src/actions/publishProfile.js +157 -0
- package/dist/src/actions/publishProfile.js.map +1 -0
- package/dist/src/connector-account-provider.d.ts +20 -0
- package/dist/src/connector-account-provider.d.ts.map +1 -0
- package/dist/src/connector-account-provider.js +78 -0
- package/dist/src/connector-account-provider.js.map +1 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +66 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/providers/identityContext.d.ts +6 -0
- package/dist/src/providers/identityContext.d.ts.map +1 -0
- package/dist/src/providers/identityContext.js +69 -0
- package/dist/src/providers/identityContext.js.map +1 -0
- package/dist/src/providers/index.d.ts +5 -0
- package/dist/src/providers/index.d.ts.map +1 -0
- package/dist/src/providers/index.js +5 -0
- package/dist/src/providers/index.js.map +1 -0
- package/dist/src/providers/senderContext.d.ts +6 -0
- package/dist/src/providers/senderContext.d.ts.map +1 -0
- package/dist/src/providers/senderContext.js +64 -0
- package/dist/src/providers/senderContext.js.map +1 -0
- package/dist/src/service.d.ts +116 -0
- package/dist/src/service.d.ts.map +1 -0
- package/dist/src/service.js +915 -0
- package/dist/src/service.js.map +1 -0
- package/dist/src/toon.d.ts +2 -0
- package/dist/src/toon.d.ts.map +1 -0
- package/dist/src/toon.js +18 -0
- package/dist/src/toon.js.map +1 -0
- package/dist/src/types.d.ts +125 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +192 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +26 -11
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -876
- package/dist/index.js.map +0 -16
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# @elizaos/plugin-nostr
|
|
2
|
+
|
|
3
|
+
Nostr decentralized messaging plugin for ElizaOS agents. Enables secure, encrypted direct messaging (NIP-04) over the Nostr protocol.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Encrypted Direct Messages (NIP-04)**: Send and receive encrypted DMs using the Nostr protocol
|
|
8
|
+
- **Multi-relay Support**: Connect to multiple Nostr relays for redundancy
|
|
9
|
+
- **Profile Management**: Publish and update your agent's Nostr profile (kind:0)
|
|
10
|
+
- **DM Policy Control**: Configure who can message your agent (open, pairing, allowlist, disabled)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# npm
|
|
16
|
+
npm install @elizaos/plugin-nostr
|
|
17
|
+
|
|
18
|
+
# bun
|
|
19
|
+
bun add @elizaos/plugin-nostr
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
### Environment Variables
|
|
25
|
+
|
|
26
|
+
| Variable | Description | Required |
|
|
27
|
+
|----------|-------------|----------|
|
|
28
|
+
| `NOSTR_PRIVATE_KEY` | Private key (hex or nsec format) | Yes |
|
|
29
|
+
| `NOSTR_RELAYS` | Comma-separated relay URLs | No |
|
|
30
|
+
| `NOSTR_DM_POLICY` | DM policy: open, pairing, allowlist, disabled | No |
|
|
31
|
+
| `NOSTR_ALLOW_FROM` | Comma-separated pubkeys for allowlist | No |
|
|
32
|
+
| `NOSTR_ENABLED` | Enable/disable the plugin | No |
|
|
33
|
+
|
|
34
|
+
### Agent Configuration
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"plugins": ["@elizaos/plugin-nostr"],
|
|
39
|
+
"pluginParameters": {
|
|
40
|
+
"NOSTR_PRIVATE_KEY": "your-private-key-hex-or-nsec",
|
|
41
|
+
"NOSTR_RELAYS": "wss://relay.damus.io,wss://nos.lol,wss://relay.nostr.band",
|
|
42
|
+
"NOSTR_DM_POLICY": "pairing"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
### Actions
|
|
50
|
+
|
|
51
|
+
Nostr DMs and public notes are exposed through canonical connector actions. Use
|
|
52
|
+
`source: "nostr"` when a request needs to target Nostr explicitly.
|
|
53
|
+
|
|
54
|
+
| Primary action | Operation | Description |
|
|
55
|
+
|----------------|-----------|-------------|
|
|
56
|
+
| `MESSAGE` | `send` | Send an encrypted direct message to a Nostr pubkey |
|
|
57
|
+
| `MESSAGE` | `read` | Read recent direct messages where the connector can fetch them |
|
|
58
|
+
| `POST` | `send` | Publish a public Nostr note |
|
|
59
|
+
| `POST` | `read` | Read recent relay feed posts |
|
|
60
|
+
| `POST` | `search` | Search relay posts where supported |
|
|
61
|
+
|
|
62
|
+
Profile updates remain a Nostr-specific profile capability outside the
|
|
63
|
+
MESSAGE/POST connector action set.
|
|
64
|
+
|
|
65
|
+
### Providers
|
|
66
|
+
|
|
67
|
+
#### nostrIdentityContext
|
|
68
|
+
|
|
69
|
+
Provides information about the bot's Nostr identity:
|
|
70
|
+
- Public key (hex and npub)
|
|
71
|
+
- Connected relays
|
|
72
|
+
- Connection status
|
|
73
|
+
|
|
74
|
+
#### nostrSenderContext
|
|
75
|
+
|
|
76
|
+
Provides information about the current conversation partner:
|
|
77
|
+
- Sender's pubkey (hex and npub)
|
|
78
|
+
- Display name
|
|
79
|
+
- Encryption status
|
|
80
|
+
|
|
81
|
+
## DM Policies
|
|
82
|
+
|
|
83
|
+
| Policy | Description |
|
|
84
|
+
|--------|-------------|
|
|
85
|
+
| `open` | Accept DMs from anyone |
|
|
86
|
+
| `pairing` | Accept DMs and remember senders for future conversations |
|
|
87
|
+
| `allowlist` | Only accept DMs from pubkeys in NOSTR_ALLOW_FROM |
|
|
88
|
+
| `disabled` | Don't accept any DMs |
|
|
89
|
+
|
|
90
|
+
## Nostr Concepts
|
|
91
|
+
|
|
92
|
+
### Keys
|
|
93
|
+
|
|
94
|
+
- **Private Key**: Used to sign events and decrypt messages. Keep this secret!
|
|
95
|
+
- **Public Key**: Your identity on Nostr. Can be shared freely.
|
|
96
|
+
- **npub/nsec**: Bech32-encoded formats for public/private keys
|
|
97
|
+
|
|
98
|
+
### Events
|
|
99
|
+
|
|
100
|
+
- **kind:0**: Profile metadata
|
|
101
|
+
- **kind:4**: Encrypted DMs (NIP-04)
|
|
102
|
+
|
|
103
|
+
### Relays
|
|
104
|
+
|
|
105
|
+
Nostr relays are servers that store and forward events. Your agent connects to multiple relays for redundancy.
|
|
106
|
+
|
|
107
|
+
## Example
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { createAgent } from "@elizaos/core";
|
|
111
|
+
import nostrPlugin from "@elizaos/plugin-nostr";
|
|
112
|
+
|
|
113
|
+
const agent = await createAgent({
|
|
114
|
+
plugins: [nostrPlugin],
|
|
115
|
+
settings: {
|
|
116
|
+
NOSTR_PRIVATE_KEY: process.env.NOSTR_PRIVATE_KEY,
|
|
117
|
+
NOSTR_RELAYS: "wss://relay.damus.io,wss://nos.lol",
|
|
118
|
+
NOSTR_DM_POLICY: "pairing",
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// The agent can now receive DMs and respond
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Security Considerations
|
|
126
|
+
|
|
127
|
+
1. **Private Key Storage**: Never commit your private key to version control. Use environment variables or secure secret management.
|
|
128
|
+
|
|
129
|
+
2. **Key Generation**: Generate keys using a reputable tool like `nip-06` or the `nostr-tools` library.
|
|
130
|
+
|
|
131
|
+
3. **Relay Selection**: Choose relays carefully. Consider running your own relay for sensitive applications.
|
|
132
|
+
|
|
133
|
+
4. **DM Policy**: Start with a restrictive policy and relax as needed.
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
### Building
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
cd typescript && npm run build
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Testing
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm test
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## API Reference
|
|
150
|
+
|
|
151
|
+
### NostrService
|
|
152
|
+
|
|
153
|
+
#### Methods
|
|
154
|
+
|
|
155
|
+
- `isConnected()`: Check if connected to relays
|
|
156
|
+
- `getPublicKey()`: Get the bot's public key (hex)
|
|
157
|
+
- `getNpub()`: Get the bot's npub
|
|
158
|
+
- `getRelays()`: Get connected relay URLs
|
|
159
|
+
- `sendDm(options)`: Send an encrypted DM
|
|
160
|
+
- `publishProfile(profile)`: Publish profile metadata
|
|
161
|
+
|
|
162
|
+
### Types
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
interface NostrSettings {
|
|
166
|
+
privateKey: string;
|
|
167
|
+
publicKey: string;
|
|
168
|
+
relays: string[];
|
|
169
|
+
dmPolicy: "open" | "pairing" | "allowlist" | "disabled";
|
|
170
|
+
allowFrom: string[];
|
|
171
|
+
enabled: boolean;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
interface NostrProfile {
|
|
175
|
+
name?: string;
|
|
176
|
+
displayName?: string;
|
|
177
|
+
about?: string;
|
|
178
|
+
picture?: string;
|
|
179
|
+
banner?: string;
|
|
180
|
+
nip05?: string;
|
|
181
|
+
lud16?: string;
|
|
182
|
+
website?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
interface NostrDmSendOptions {
|
|
186
|
+
toPubkey: string;
|
|
187
|
+
text: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
interface NostrSendResult {
|
|
191
|
+
success: boolean;
|
|
192
|
+
eventId?: string;
|
|
193
|
+
relays: string[];
|
|
194
|
+
error?: string;
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
MIT
|
package/auto-enable.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Auto-enable check for @elizaos/plugin-nostr.
|
|
2
|
+
//
|
|
3
|
+
// Plugin manifest entry-point — referenced by package.json's
|
|
4
|
+
// `elizaos.plugin.autoEnableModule`. Keep this module light: env reads only,
|
|
5
|
+
// no service init, no transitive imports of the full plugin runtime. The
|
|
6
|
+
// auto-enable engine loads dozens of these per boot.
|
|
7
|
+
import type { PluginAutoEnableContext } from "@elizaos/core";
|
|
8
|
+
|
|
9
|
+
/** Enable when a `nostr` connector block is present and not explicitly disabled. */
|
|
10
|
+
export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
|
|
11
|
+
const c = (ctx.config?.connectors as Record<string, unknown> | undefined)?.nostr;
|
|
12
|
+
if (!c || typeof c !== "object") return false;
|
|
13
|
+
const config = c as Record<string, unknown>;
|
|
14
|
+
if (config.enabled === false) return false;
|
|
15
|
+
// The full per-connector field check (private key / relays) lives in the
|
|
16
|
+
// central engine's isConnectorConfigured. We delegate to a simple "block
|
|
17
|
+
// present + not explicitly disabled" check here; the central engine's
|
|
18
|
+
// stricter check remains as a fallback during migration.
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
import { type NostrSettings } from "./types.js";
|
|
3
|
+
export declare const DEFAULT_NOSTR_ACCOUNT_ID = "default";
|
|
4
|
+
export type NostrAccountConfig = Partial<Omit<NostrSettings, "relays" | "allowFrom" | "publicKey" | "accountId">> & {
|
|
5
|
+
accountId?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
relays?: string[] | string;
|
|
8
|
+
allowFrom?: string[] | string;
|
|
9
|
+
};
|
|
10
|
+
export declare function normalizeNostrAccountId(accountId?: unknown): string;
|
|
11
|
+
export declare function listNostrAccountIds(runtime: IAgentRuntime): string[];
|
|
12
|
+
export declare function resolveDefaultNostrAccountId(runtime: IAgentRuntime): string;
|
|
13
|
+
export declare function readNostrAccountId(...sources: unknown[]): string | undefined;
|
|
14
|
+
export declare function resolveNostrAccountSettings(runtime: IAgentRuntime, requestedAccountId?: string | null): NostrSettings;
|
|
15
|
+
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1F,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACtC,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC,CACxE,GAAG;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;CAC/B,CAAC;AAoEF,wBAAgB,uBAAuB,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAInE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAepE;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAQ3E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CA2B5E;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,aAAa,EACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GACjC,aAAa,CAqCf"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { DEFAULT_NOSTR_RELAYS } from "./types.js";
|
|
2
|
+
export const DEFAULT_NOSTR_ACCOUNT_ID = "default";
|
|
3
|
+
function stringSetting(runtime, key) {
|
|
4
|
+
const value = runtime.getSetting(key);
|
|
5
|
+
if (typeof value === "string" && value.trim())
|
|
6
|
+
return value.trim();
|
|
7
|
+
return process.env[key];
|
|
8
|
+
}
|
|
9
|
+
function characterConfig(runtime) {
|
|
10
|
+
const settings = runtime.character?.settings;
|
|
11
|
+
const raw = settings?.nostr;
|
|
12
|
+
return raw && typeof raw === "object" ? raw : {};
|
|
13
|
+
}
|
|
14
|
+
function parseAccountsJson(runtime) {
|
|
15
|
+
const raw = stringSetting(runtime, "NOSTR_ACCOUNTS");
|
|
16
|
+
if (!raw)
|
|
17
|
+
return {};
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(raw);
|
|
20
|
+
if (Array.isArray(parsed)) {
|
|
21
|
+
return Object.fromEntries(parsed
|
|
22
|
+
.filter((item) => Boolean(item) && typeof item === "object")
|
|
23
|
+
.map((item) => [normalizeNostrAccountId(item.accountId ?? item.id), item]));
|
|
24
|
+
}
|
|
25
|
+
return parsed && typeof parsed === "object"
|
|
26
|
+
? parsed
|
|
27
|
+
: {};
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function allAccountConfigs(runtime) {
|
|
34
|
+
return {
|
|
35
|
+
...(characterConfig(runtime).accounts ?? {}),
|
|
36
|
+
...parseAccountsJson(runtime),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function accountConfig(runtime, accountId) {
|
|
40
|
+
const accounts = allAccountConfigs(runtime);
|
|
41
|
+
return accounts[accountId] ?? accounts[normalizeNostrAccountId(accountId)] ?? {};
|
|
42
|
+
}
|
|
43
|
+
function boolValue(value, fallback = true) {
|
|
44
|
+
if (typeof value === "boolean")
|
|
45
|
+
return value;
|
|
46
|
+
if (typeof value === "string")
|
|
47
|
+
return value.trim().toLowerCase() !== "false";
|
|
48
|
+
return fallback;
|
|
49
|
+
}
|
|
50
|
+
function stringList(value) {
|
|
51
|
+
if (Array.isArray(value))
|
|
52
|
+
return value.map((item) => String(item).trim()).filter(Boolean);
|
|
53
|
+
if (typeof value === "string") {
|
|
54
|
+
return value
|
|
55
|
+
.split(",")
|
|
56
|
+
.map((item) => item.trim())
|
|
57
|
+
.filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
export function normalizeNostrAccountId(accountId) {
|
|
62
|
+
if (typeof accountId !== "string")
|
|
63
|
+
return DEFAULT_NOSTR_ACCOUNT_ID;
|
|
64
|
+
const trimmed = accountId.trim();
|
|
65
|
+
return trimmed || DEFAULT_NOSTR_ACCOUNT_ID;
|
|
66
|
+
}
|
|
67
|
+
export function listNostrAccountIds(runtime) {
|
|
68
|
+
const ids = new Set();
|
|
69
|
+
const config = characterConfig(runtime);
|
|
70
|
+
if (stringSetting(runtime, "NOSTR_PRIVATE_KEY") || config.privateKey) {
|
|
71
|
+
ids.add(DEFAULT_NOSTR_ACCOUNT_ID);
|
|
72
|
+
}
|
|
73
|
+
for (const id of Object.keys(allAccountConfigs(runtime))) {
|
|
74
|
+
ids.add(normalizeNostrAccountId(id));
|
|
75
|
+
}
|
|
76
|
+
return Array.from(ids.size ? ids : new Set([DEFAULT_NOSTR_ACCOUNT_ID])).sort((a, b) => a.localeCompare(b));
|
|
77
|
+
}
|
|
78
|
+
export function resolveDefaultNostrAccountId(runtime) {
|
|
79
|
+
const requested = stringSetting(runtime, "NOSTR_DEFAULT_ACCOUNT_ID") ??
|
|
80
|
+
stringSetting(runtime, "NOSTR_ACCOUNT_ID");
|
|
81
|
+
if (requested)
|
|
82
|
+
return normalizeNostrAccountId(requested);
|
|
83
|
+
const ids = listNostrAccountIds(runtime);
|
|
84
|
+
return ids.includes(DEFAULT_NOSTR_ACCOUNT_ID) ? DEFAULT_NOSTR_ACCOUNT_ID : ids[0];
|
|
85
|
+
}
|
|
86
|
+
export function readNostrAccountId(...sources) {
|
|
87
|
+
for (const source of sources) {
|
|
88
|
+
if (!source || typeof source !== "object")
|
|
89
|
+
continue;
|
|
90
|
+
const record = source;
|
|
91
|
+
const parameters = record.parameters && typeof record.parameters === "object"
|
|
92
|
+
? record.parameters
|
|
93
|
+
: {};
|
|
94
|
+
const data = record.data && typeof record.data === "object"
|
|
95
|
+
? record.data
|
|
96
|
+
: {};
|
|
97
|
+
const metadata = record.metadata && typeof record.metadata === "object"
|
|
98
|
+
? record.metadata
|
|
99
|
+
: {};
|
|
100
|
+
const nostr = data.nostr && typeof data.nostr === "object" ? data.nostr : {};
|
|
101
|
+
const value = record.accountId ??
|
|
102
|
+
parameters.accountId ??
|
|
103
|
+
data.accountId ??
|
|
104
|
+
nostr.accountId ??
|
|
105
|
+
metadata.accountId;
|
|
106
|
+
if (typeof value === "string" && value.trim())
|
|
107
|
+
return normalizeNostrAccountId(value);
|
|
108
|
+
}
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
export function resolveNostrAccountSettings(runtime, requestedAccountId) {
|
|
112
|
+
const accountId = normalizeNostrAccountId(requestedAccountId ?? resolveDefaultNostrAccountId(runtime));
|
|
113
|
+
const base = characterConfig(runtime);
|
|
114
|
+
const account = accountConfig(runtime, accountId);
|
|
115
|
+
const allowEnv = accountId === DEFAULT_NOSTR_ACCOUNT_ID;
|
|
116
|
+
const relays = stringList(account.relays ?? base.relays ?? (allowEnv ? stringSetting(runtime, "NOSTR_RELAYS") : undefined));
|
|
117
|
+
const allowFrom = stringList(account.allowFrom ??
|
|
118
|
+
base.allowFrom ??
|
|
119
|
+
(allowEnv ? stringSetting(runtime, "NOSTR_ALLOW_FROM") : undefined));
|
|
120
|
+
return {
|
|
121
|
+
accountId,
|
|
122
|
+
privateKey: account.privateKey ??
|
|
123
|
+
base.privateKey ??
|
|
124
|
+
(allowEnv ? stringSetting(runtime, "NOSTR_PRIVATE_KEY") : undefined) ??
|
|
125
|
+
"",
|
|
126
|
+
publicKey: "",
|
|
127
|
+
relays: relays.length ? relays : DEFAULT_NOSTR_RELAYS,
|
|
128
|
+
dmPolicy: (account.dmPolicy ??
|
|
129
|
+
base.dmPolicy ??
|
|
130
|
+
(allowEnv ? stringSetting(runtime, "NOSTR_DM_POLICY") : undefined) ??
|
|
131
|
+
"pairing"),
|
|
132
|
+
allowFrom,
|
|
133
|
+
profile: account.profile ?? base.profile,
|
|
134
|
+
enabled: boolValue(account.enabled ??
|
|
135
|
+
base.enabled ??
|
|
136
|
+
(allowEnv ? stringSetting(runtime, "NOSTR_ENABLED") : undefined)),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/accounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA0C,MAAM,YAAY,CAAC;AAE1F,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAelD,SAAS,aAAa,CAAC,OAAsB,EAAE,GAAW;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE;QAAE,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACnE,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,eAAe,CAAC,OAAsB;IAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,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../src/actions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishProfile.d.ts","sourceRoot":"","sources":["../../../src/actions/publishProfile.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,MAAM,EAQZ,MAAM,eAAe,CAAC;AAiCvB,eAAO,MAAM,cAAc,EAAE,MAoJ5B,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publish profile action for Nostr plugin.
|
|
3
|
+
*/
|
|
4
|
+
import { composePromptFromState, ModelType, parseJSONObjectFromText, } from "@elizaos/core";
|
|
5
|
+
import { normalizeNostrAccountId, readNostrAccountId } from "../accounts.js";
|
|
6
|
+
import { NOSTR_SERVICE_NAME } from "../types.js";
|
|
7
|
+
const PUBLISH_PROFILE_TEMPLATE = `# Task: Extract Nostr profile data
|
|
8
|
+
Based on the conversation, determine what profile information to update.
|
|
9
|
+
|
|
10
|
+
Recent conversation:
|
|
11
|
+
{{recentMessages}}
|
|
12
|
+
|
|
13
|
+
Respond with JSON only, no prose or fences, listing only the fields to update:
|
|
14
|
+
|
|
15
|
+
{
|
|
16
|
+
"name": "optional display name",
|
|
17
|
+
"about": "optional bio",
|
|
18
|
+
"picture": "optional profile picture URL",
|
|
19
|
+
"banner": "optional banner URL",
|
|
20
|
+
"nip05": "optional user@domain.com",
|
|
21
|
+
"lud16": "optional lightning address",
|
|
22
|
+
"website": "optional website URL"
|
|
23
|
+
}`;
|
|
24
|
+
const MAX_NOSTR_PROFILE_FIELD_CHARS = 500;
|
|
25
|
+
const MAX_NOSTR_PROFILE_RELAYS = 10;
|
|
26
|
+
const NOSTR_PROFILE_ACTION_TIMEOUT_MS = 30_000;
|
|
27
|
+
function truncateProfileField(value) {
|
|
28
|
+
return typeof value === "string" && value.trim()
|
|
29
|
+
? value.trim().slice(0, MAX_NOSTR_PROFILE_FIELD_CHARS)
|
|
30
|
+
: undefined;
|
|
31
|
+
}
|
|
32
|
+
export const publishProfile = {
|
|
33
|
+
name: "NOSTR_PUBLISH_PROFILE",
|
|
34
|
+
similes: ["UPDATE_NOSTR_PROFILE", "SET_NOSTR_PROFILE", "NOSTR_PROFILE"],
|
|
35
|
+
description: "Publish or update the bot's Nostr profile (kind:0 metadata)",
|
|
36
|
+
descriptionCompressed: "publish update bot Nostr profile (kind: 0 metadata)",
|
|
37
|
+
contexts: ["social_posting", "connectors"],
|
|
38
|
+
contextGate: { anyOf: ["social_posting", "connectors"] },
|
|
39
|
+
roleGate: { minRole: "USER" },
|
|
40
|
+
parameters: [
|
|
41
|
+
{
|
|
42
|
+
name: "name",
|
|
43
|
+
description: "Display name for the Nostr profile.",
|
|
44
|
+
required: false,
|
|
45
|
+
schema: { type: "string" },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "about",
|
|
49
|
+
description: "Profile bio/about text.",
|
|
50
|
+
required: false,
|
|
51
|
+
schema: { type: "string" },
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "picture",
|
|
55
|
+
description: "Profile picture URL.",
|
|
56
|
+
required: false,
|
|
57
|
+
schema: { type: "string" },
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
validate: async (_runtime, message, _state) => {
|
|
61
|
+
return message.content.source === "nostr";
|
|
62
|
+
},
|
|
63
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
64
|
+
const nostrService = runtime.getService(NOSTR_SERVICE_NAME);
|
|
65
|
+
if (!nostrService?.isConnected()) {
|
|
66
|
+
if (callback) {
|
|
67
|
+
callback({ text: "Nostr service is not available.", source: "nostr" });
|
|
68
|
+
}
|
|
69
|
+
return { success: false, error: "Nostr service not available" };
|
|
70
|
+
}
|
|
71
|
+
const requestedAccountId = normalizeNostrAccountId(readNostrAccountId(_options, message.content) ?? nostrService.getAccountId(runtime));
|
|
72
|
+
// Get or compose state
|
|
73
|
+
const currentState = state ?? (await runtime.composeState(message));
|
|
74
|
+
// Compose prompt
|
|
75
|
+
const prompt = await composePromptFromState({
|
|
76
|
+
template: PUBLISH_PROFILE_TEMPLATE,
|
|
77
|
+
state: currentState,
|
|
78
|
+
});
|
|
79
|
+
// Extract parameters using LLM
|
|
80
|
+
let profileInfo = null;
|
|
81
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
82
|
+
const response = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
83
|
+
prompt,
|
|
84
|
+
});
|
|
85
|
+
const actionParams = parseJSONObjectFromText(String(response));
|
|
86
|
+
if (actionParams) {
|
|
87
|
+
profileInfo = {
|
|
88
|
+
name: truncateProfileField(actionParams.name),
|
|
89
|
+
displayName: truncateProfileField(actionParams.displayName),
|
|
90
|
+
about: truncateProfileField(actionParams.about),
|
|
91
|
+
picture: truncateProfileField(actionParams.picture),
|
|
92
|
+
banner: truncateProfileField(actionParams.banner),
|
|
93
|
+
nip05: truncateProfileField(actionParams.nip05),
|
|
94
|
+
lud16: truncateProfileField(actionParams.lud16),
|
|
95
|
+
website: truncateProfileField(actionParams.website),
|
|
96
|
+
};
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!profileInfo) {
|
|
101
|
+
if (callback) {
|
|
102
|
+
callback({
|
|
103
|
+
text: "I couldn't understand the profile information. Please try again.",
|
|
104
|
+
source: "nostr",
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return { success: false, error: "Could not extract profile parameters" };
|
|
108
|
+
}
|
|
109
|
+
// Publish profile
|
|
110
|
+
const timeoutMs = NOSTR_PROFILE_ACTION_TIMEOUT_MS;
|
|
111
|
+
const result = await nostrService.publishProfile({
|
|
112
|
+
...profileInfo,
|
|
113
|
+
accountId: requestedAccountId,
|
|
114
|
+
});
|
|
115
|
+
if (!result.success) {
|
|
116
|
+
if (callback) {
|
|
117
|
+
callback({
|
|
118
|
+
text: `Failed to publish profile: ${result.error}`,
|
|
119
|
+
source: "nostr",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return { success: false, error: result.error };
|
|
123
|
+
}
|
|
124
|
+
if (callback) {
|
|
125
|
+
callback({
|
|
126
|
+
text: "Profile published successfully.",
|
|
127
|
+
source: message.content.source,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
success: true,
|
|
132
|
+
data: {
|
|
133
|
+
eventId: result.eventId,
|
|
134
|
+
relays: result.relays?.slice(0, MAX_NOSTR_PROFILE_RELAYS),
|
|
135
|
+
profile: profileInfo,
|
|
136
|
+
timeoutMs,
|
|
137
|
+
accountId: requestedAccountId,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
examples: [
|
|
142
|
+
[
|
|
143
|
+
{
|
|
144
|
+
name: "{{user1}}",
|
|
145
|
+
content: { text: "Update your profile name to 'Bot Assistant'" },
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "{{agent}}",
|
|
149
|
+
content: {
|
|
150
|
+
text: "I'll update my Nostr profile.",
|
|
151
|
+
actions: ["NOSTR_PUBLISH_PROFILE"],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
],
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=publishProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishProfile.js","sourceRoot":"","sources":["../../../src/actions/publishProfile.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGL,sBAAsB,EAGtB,SAAS,EACT,uBAAuB,GAExB,MAAM,eAAe,CAAC;AACvB,OAA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AC;oBACP,IAAI,EAAE,8BAA8B,MAAM,CAAC,KAAK,EAAE;oBAClD,MAAM,EAAE,OAAO;iBAChB,CAAC,CAAC;YACL,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QACjD,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC;gBACP,IAAI,EAAE,iCAAiC;gBACvC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAgB;aACzC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE;gBACJ,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC;gBACzD,OAAO,EAAE,WAAW;gBACpB,SAAS;gBACT,SAAS,EAAE,kBAAkB;aAC9B;SACF,CAAC;IACJ,CAAC;IAED,QAAQ,EAAE;QACR;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,EAAE,IAAI,EAAE,6CAA6C,EAAE;aACjE;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,+BAA+B;oBACrC,OAAO,EAAE,CAAC,uBAAuB,CAAC;iBACnC;aACF;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nostr ConnectorAccountManager provider.
|
|
3
|
+
*
|
|
4
|
+
* Adapts the multi-account scaffolding in `accounts.ts` to the
|
|
5
|
+
* `ConnectorAccountProvider` contract from
|
|
6
|
+
* `@elizaos/core/connectors/account-manager`.
|
|
7
|
+
*
|
|
8
|
+
* Source of truth for accounts is character settings (`character.settings.nostr`)
|
|
9
|
+
* + NOSTR_ACCOUNTS JSON env var + single-account env vars (NOSTR_PRIVATE_KEY,
|
|
10
|
+
* NOSTR_RELAYS, NOSTR_DM_POLICY).
|
|
11
|
+
*
|
|
12
|
+
* AccountKey is the nostr pubkey (hex). Role is `OWNER` since the private key
|
|
13
|
+
* is the user's identity. Public key is derived at service start time, so
|
|
14
|
+
* `externalId` may be empty until the service has resolved it; the manager
|
|
15
|
+
* tolerates this.
|
|
16
|
+
*/
|
|
17
|
+
import type { ConnectorAccountProvider, IAgentRuntime } from "@elizaos/core";
|
|
18
|
+
export declare const NOSTR_PROVIDER_ID = "nostr";
|
|
19
|
+
export declare function createNostrConnectorAccountProvider(runtime: IAgentRuntime): ConnectorAccountProvider;
|
|
20
|
+
//# sourceMappingURL=connector-account-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-account-provider.d.ts","sourceRoot":"","sources":["../../src/connector-account-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAIV,wBAAwB,EACxB,aAAa,EACd,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,iBAAiB,UAAU,CAAC;AA+BzC,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,aAAa,GACrB,wBAAwB,CAiC1B"}
|