@agentdomain/eliza-plugin 0.6.0 → 0.7.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/index.js CHANGED
@@ -1,38 +1,34 @@
1
- import { AgentDomain } from "@agentdomain/sdk";
2
- import { AGENTDOMAIN_API_BASE_URL, SERVICE_PLAN_KEYS, SUPPORTED_TLDS, } from "@agentdomain/shared/constants";
3
- import { DNS_RECORD_TYPES, dnsRecordSchema as sharedDnsRecordSchema, } from "@agentdomain/shared";
4
- import { createPublicClient, createWalletClient, http, } from "viem";
5
- import { privateKeyToAccount } from "viem/accounts";
6
- import { base, baseSepolia } from "viem/chains";
7
- import { z } from "zod";
1
+ import { AgentDomain, encodeSetAutoRenewCalldata } from '@agentdomain/sdk';
2
+ import { AGENTDOMAIN_API_BASE_URL, SERVICE_PLAN_KEYS, SUPPORTED_TLDS, } from '@agentdomain/shared/constants';
3
+ import { DNS_RECORD_TYPES, dnsRecordSchema as sharedDnsRecordSchema, } from '@agentdomain/shared';
4
+ import { createPublicClient, createWalletClient, http } from 'viem';
5
+ import { privateKeyToAccount } from 'viem/accounts';
6
+ import { base, baseSepolia } from 'viem/chains';
7
+ import { z } from 'zod';
8
+ import { extractEmailAddresses, extractFencedBlock, parseCompactQuantity, readLabeledEmail, readLabeledEmailUsername, readLabeledRemainder, } from './text-parsing.js';
9
+ /** Builds the attributed direct calldata used by Eliza's post-registration auto-renew step. */
10
+ export function encodeElizaAutoRenewCalldata(tokenId, builderCode) {
11
+ if (!builderCode) {
12
+ throw new Error('AGENTDOMAIN_BUILDER_CODE is required for attributed direct Base transactions.');
13
+ }
14
+ return encodeSetAutoRenewCalldata(tokenId, true, builderCode);
15
+ }
8
16
  function getClients(runtime, opts = {}) {
9
- const apiUrl = runtime.getSetting("AGENTDOMAIN_API_URL") ?? AGENTDOMAIN_API_BASE_URL;
10
- const apiKey = runtime.getSetting("AGENTDOMAIN_API_KEY");
11
- const pk = runtime.getSetting("AGENT_PRIVATE_KEY");
12
- const rpc = runtime.getSetting("BASE_RPC_URL") ?? "https://mainnet.base.org";
13
- const network = runtime.getSetting("AGENTDOMAIN_NETWORK") ??
14
- "base";
15
- const chain = network === "base-sepolia" ? baseSepolia : base;
17
+ const apiUrl = runtime.getSetting('AGENTDOMAIN_API_URL') ?? AGENTDOMAIN_API_BASE_URL;
18
+ const apiKey = runtime.getSetting('AGENTDOMAIN_API_KEY');
19
+ const pk = runtime.getSetting('AGENT_PRIVATE_KEY');
20
+ const rpc = runtime.getSetting('BASE_RPC_URL') ?? 'https://mainnet.base.org';
21
+ const network = runtime.getSetting('AGENTDOMAIN_NETWORK') ?? 'base';
22
+ const builderCode = runtime.getSetting('AGENTDOMAIN_BUILDER_CODE');
23
+ const chain = network === 'base-sepolia' ? baseSepolia : base;
16
24
  if (!pk) {
17
25
  if (opts.requireWallet)
18
- throw new Error("AGENT_PRIVATE_KEY not set");
19
- const ad = new AgentDomain({ apiUrl, apiKey, network });
20
- return {
21
- ad,
22
- account: null,
23
- walletClient: null,
24
- publicClient: null,
25
- network,
26
- chain,
27
- rpc,
28
- };
26
+ throw new Error('AGENT_PRIVATE_KEY not set');
27
+ const ad = new AgentDomain({ apiUrl, apiKey, network, builderCode });
28
+ return { ad, account: null, walletClient: null, publicClient: null, network, chain, rpc };
29
29
  }
30
30
  const account = privateKeyToAccount(pk);
31
- const walletClient = createWalletClient({
32
- account,
33
- chain,
34
- transport: http(rpc),
35
- });
31
+ const walletClient = createWalletClient({ account, chain, transport: http(rpc) });
36
32
  const publicClient = createPublicClient({ chain, transport: http(rpc) });
37
33
  const ad = new AgentDomain({
38
34
  apiUrl,
@@ -40,30 +36,24 @@ function getClients(runtime, opts = {}) {
40
36
  network,
41
37
  walletClient: walletClient,
42
38
  publicClient: publicClient,
39
+ builderCode,
43
40
  });
44
41
  return { ad, account, walletClient, publicClient, network, chain, rpc };
45
42
  }
46
- const TLD_PATTERN = new RegExp(String.raw `([a-z0-9-]{3,63})\.([a-z]{2,20})\b`, "i");
43
+ const TLD_PATTERN = new RegExp(String.raw `([a-z0-9-]{3,63})\.([a-z]{2,20})\b`, 'i');
47
44
  const UUID_PATTERN = /[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i;
48
45
  const AMOUNT_PATTERN = /\$?\s*(\d+(?:\.\d{1,6})?)\s*(?:usdc)?/i;
49
- const EMAIL_PATTERN = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i;
50
- const EMAIL_GLOBAL_PATTERN = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi;
51
46
  const EMAIL_USERNAME_PATTERN = /^[a-z0-9](?:[a-z0-9._+-]{0,62}[a-z0-9])?$/;
52
47
  const registerSchema = z.object({
53
48
  preferredName: z.string(),
54
- tld: z.enum(SUPPORTED_TLDS).default("xyz"),
49
+ tld: z.enum(SUPPORTED_TLDS).default('xyz'),
55
50
  registerBasename: z.boolean().default(true),
56
51
  registerEns: z.boolean().default(false),
57
52
  emailEnabled: z.boolean().default(true),
58
- emailUsername: z
59
- .string()
60
- .trim()
61
- .toLowerCase()
62
- .regex(EMAIL_USERNAME_PATTERN)
63
- .default("agent"),
53
+ emailUsername: z.string().trim().toLowerCase().regex(EMAIL_USERNAME_PATTERN).default('agent'),
64
54
  years: z.number().int().min(1).max(10).default(1),
65
55
  autoRenew: z.boolean().default(false),
66
- premiumPlan: z.enum(SERVICE_PLAN_KEYS).default("included"),
56
+ premiumPlan: z.enum(SERVICE_PLAN_KEYS).default('included'),
67
57
  });
68
58
  const dnsRecordSchema = z.object({
69
59
  type: z.enum(DNS_RECORD_TYPES),
@@ -76,133 +66,123 @@ function parseParamsFromText(text) {
76
66
  const m = text.match(TLD_PATTERN);
77
67
  const lower = text.toLowerCase();
78
68
  const yearsMatch = lower.match(/([1-9]|10)\s*years?/);
79
- const noBasename = lower.includes("no basename") ||
80
- lower.includes("without basename") ||
81
- lower.includes("skip basename");
82
- const noEns = lower.includes("no ens") ||
83
- lower.includes("without ens") ||
84
- lower.includes("skip ens");
69
+ const noBasename = lower.includes('no basename') ||
70
+ lower.includes('without basename') ||
71
+ lower.includes('skip basename');
72
+ const noEns = lower.includes('no ens') || lower.includes('without ens') || lower.includes('skip ens');
85
73
  const wantsEns = /\bens\b/.test(lower);
86
74
  return {
87
- preferredName: m?.[1]?.toLowerCase() ?? "agent",
88
- tld: m?.[2]?.toLowerCase() ?? "xyz",
75
+ preferredName: m?.[1]?.toLowerCase() ?? 'agent',
76
+ tld: m?.[2]?.toLowerCase() ?? 'xyz',
89
77
  registerBasename: !noBasename,
90
78
  registerEns: wantsEns && !noEns,
91
79
  emailEnabled: true,
92
- emailUsername: parseEmailUsername(text) ?? "agent",
80
+ emailUsername: parseEmailUsername(text) ?? 'agent',
93
81
  years: yearsMatch ? parseInt(yearsMatch[1], 10) : 1,
94
- autoRenew: lower.includes("auto renew") ||
95
- lower.includes("auto-renew") ||
96
- lower.includes("autorenew"),
82
+ autoRenew: lower.includes('auto renew') || lower.includes('auto-renew') || lower.includes('autorenew'),
97
83
  premiumPlan: parseRegistrationPlan(lower),
98
84
  };
99
85
  }
100
86
  function requireAgentId(text) {
101
87
  const agentId = text.match(UUID_PATTERN)?.[0];
102
88
  if (!agentId)
103
- throw new Error("Agent ID UUID is required");
89
+ throw new Error('Agent ID UUID is required');
104
90
  return agentId;
105
91
  }
106
92
  function parseAmountUsdc(text) {
107
93
  const amount = text.match(AMOUNT_PATTERN)?.[1];
108
94
  if (!amount)
109
- throw new Error("USDC amount is required");
95
+ throw new Error('USDC amount is required');
110
96
  return amount;
111
97
  }
112
98
  function parseRegistrationPlan(lower) {
113
- if (lower.includes("enterprise"))
114
- return "enterprise";
115
- if (lower.includes("pro"))
116
- return "pro";
117
- if (lower.includes("starter"))
118
- return "starter";
119
- return "included";
99
+ if (lower.includes('enterprise'))
100
+ return 'enterprise';
101
+ if (lower.includes('pro'))
102
+ return 'pro';
103
+ if (lower.includes('starter'))
104
+ return 'starter';
105
+ return 'included';
120
106
  }
121
107
  function parsePlan(text) {
122
108
  const lower = text.toLowerCase();
123
- if (lower.includes("enterprise")) {
124
- const match = lower.match(/(\d+(?:\.\d+)?)\s*(k|m)/);
125
- const monthly = match
126
- ? Math.round(Number(match[1]) * (match[2] === "m" ? 1_000_000 : 1_000))
109
+ if (lower.includes('enterprise')) {
110
+ const quantity = parseCompactQuantity(lower);
111
+ const monthly = quantity
112
+ ? Math.round(quantity.value * (quantity.suffix === 'm' ? 1_000_000 : 1_000))
127
113
  : 100_000;
128
114
  return {
129
- plan: "enterprise",
115
+ plan: 'enterprise',
130
116
  planSku: `enterprise-${monthly}`,
131
117
  };
132
118
  }
133
- return { plan: lower.includes("starter") ? "starter" : "pro" };
119
+ return { plan: lower.includes('starter') ? 'starter' : 'pro' };
134
120
  }
135
121
  function parseDnsRecord(text) {
136
122
  const lower = text.toLowerCase();
137
123
  const typeMatch = text.match(/\b(A|AAAA|ALIAS|CAA|CNAME|HTTPS|MX|NS|PTR|SRV|SVCB|TLSA|TXT)\b/i);
138
124
  const nameMatch = text.match(/\bname[:=]\s*([^\s]+)/i);
139
- const valueMatch = text.match(/\bvalue[:=]\s*(.+?)(?=\s+\b(?:ttl|priority)[:=]|$)/i);
125
+ const value = readLabeledRemainder(text, ['value'], {
126
+ stopLabels: ['ttl', 'priority'],
127
+ });
140
128
  const ttlMatch = text.match(/\bttl[:=]\s*(\d+)/i);
141
129
  const priorityMatch = text.match(/\bpriority[:=]\s*(\d+)/i);
142
130
  const parsed = dnsRecordSchema.parse({
143
- type: typeMatch?.[1]?.toUpperCase() ?? (lower.includes("txt") ? "TXT" : "A"),
144
- name: nameMatch?.[1] ?? "@",
145
- value: valueMatch?.[1]?.trim() ??
146
- text.match(/\b(?:\d{1,3}\.){3}\d{1,3}\b/)?.[0] ??
147
- "",
131
+ type: typeMatch?.[1]?.toUpperCase() ?? (lower.includes('txt') ? 'TXT' : 'A'),
132
+ name: nameMatch?.[1] ?? '@',
133
+ value: value ?? text.match(/\b(?:\d{1,3}\.){3}\d{1,3}\b/)?.[0] ?? '',
148
134
  ttl: ttlMatch ? Number(ttlMatch[1]) : 3600,
149
135
  priority: priorityMatch ? Number(priorityMatch[1]) : undefined,
150
136
  });
151
137
  return parsed;
152
138
  }
153
139
  function parseDnsRecordsJson(text) {
154
- const fenced = text.match(/```(?:json)?\s*([\s\S]*?)```/i)?.[1];
155
- const json = fenced ?? text.slice(text.indexOf("["), text.lastIndexOf("]") + 1);
140
+ const fenced = extractFencedBlock(text, ['json']);
141
+ const json = fenced ?? text.slice(text.indexOf('['), text.lastIndexOf(']') + 1);
156
142
  if (!json)
157
- throw new Error("A JSON array of DNS records is required");
158
- return z
159
- .array(sharedDnsRecordSchema)
160
- .min(1)
161
- .max(200)
162
- .parse(JSON.parse(json));
143
+ throw new Error('A JSON array of DNS records is required');
144
+ return z.array(sharedDnsRecordSchema).min(1).max(200).parse(JSON.parse(json));
163
145
  }
164
146
  function parseZoneFile(text) {
165
- const fenced = text.match(/```(?:bind|zone|dns)?\s*([\s\S]*?)```/i)?.[1];
147
+ const fenced = extractFencedBlock(text, ['bind', 'zone', 'dns']);
166
148
  if (!fenced?.trim())
167
- throw new Error("Put the BIND zone records inside a fenced code block");
149
+ throw new Error('Put the BIND zone records inside a fenced code block');
168
150
  return fenced.trim();
169
151
  }
170
152
  function parseDnsApplyOptions(text) {
171
153
  const lower = text.toLowerCase();
172
154
  return {
173
- mode: lower.includes("replace") ? "replace" : "merge",
155
+ mode: lower.includes('replace') ? 'replace' : 'merge',
174
156
  dryRun: !/\bapply\b/i.test(text),
175
157
  baseRevision: text.match(/\bbaseRevision[:=]\s*([a-f0-9]{64})/i)?.[1],
176
158
  };
177
159
  }
178
160
  function requireDnsRevision(value) {
179
161
  if (!value)
180
- throw new Error("Apply requires baseRevision from a fresh DNS preview");
162
+ throw new Error('Apply requires baseRevision from a fresh DNS preview');
181
163
  return value;
182
164
  }
183
165
  function parseEmailUsername(text) {
184
- const explicit = text.match(/\b(?:email\s+username|primary\s+email|username|alias)[:=]?\s*([a-z0-9._+-]{1,64})/i)?.[1] ?? text.match(EMAIL_PATTERN)?.[0]?.split("@")[0];
166
+ const explicit = readLabeledEmailUsername(text, ['email username', 'primary email', 'username', 'alias']) ??
167
+ extractEmailAddresses(text)[0]?.split('@')[0];
185
168
  const username = explicit?.trim().toLowerCase();
186
169
  return username && EMAIL_USERNAME_PATTERN.test(username) ? username : null;
187
170
  }
188
171
  function parseEmailRequest(text) {
189
- const fromAddress = text.match(/\bfrom[:=]\s*([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})/i)?.[1];
190
- const explicitTo = text.match(/\bto[:=]\s*([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})/i)?.[1];
191
- const emails = text.match(EMAIL_GLOBAL_PATTERN) ?? [];
192
- const to = explicitTo ??
193
- emails.find((email) => email.toLowerCase() !== fromAddress?.toLowerCase());
172
+ const fromAddress = readLabeledEmail(text, ['from']);
173
+ const explicitTo = readLabeledEmail(text, ['to']);
174
+ const emails = extractEmailAddresses(text);
175
+ const to = explicitTo ?? emails.find((email) => email.toLowerCase() !== fromAddress?.toLowerCase());
194
176
  if (!to)
195
- throw new Error("Recipient email address is required");
196
- const subject = text.match(/\bsubject[:=]\s*([^|]+)/i)?.[1]?.trim() ??
197
- "AgentDomain message";
198
- const body = text.match(/\b(?:text|body|message)[:=]\s*([\s\S]+)/i)?.[1]?.trim() ??
199
- text.replace(to, "").trim();
200
- return { to, fromAddress, subject, text: body || "Hello from AgentDomain." };
177
+ throw new Error('Recipient email address is required');
178
+ const subject = readLabeledRemainder(text, ['subject'], { stopCharacter: '|' }) ?? 'AgentDomain message';
179
+ const body = readLabeledRemainder(text, ['text', 'body', 'message']) ?? text.replace(to, '').trim();
180
+ return { to, fromAddress, subject, text: body || 'Hello from AgentDomain.' };
201
181
  }
202
182
  export const quoteRegistrationAction = {
203
- name: "QUOTE_AGENT_REGISTRATION",
204
- description: "Quote an AgentDomain registration before paying.",
205
- similes: ["PRICE_DOMAIN", "REGISTRATION_QUOTE", "QUOTE_IDENTITY"],
183
+ name: 'QUOTE_AGENT_REGISTRATION',
184
+ description: 'Quote an AgentDomain registration before paying.',
185
+ similes: ['PRICE_DOMAIN', 'REGISTRATION_QUOTE', 'QUOTE_IDENTITY'],
206
186
  examples: [],
207
187
  validate: async () => true,
208
188
  handler: async (runtime, message) => {
@@ -216,62 +196,56 @@ export const quoteRegistrationAction = {
216
196
  },
217
197
  };
218
198
  export const registerIdentityAction = {
219
- name: "REGISTER_IDENTITY",
199
+ name: 'REGISTER_IDENTITY',
220
200
  description: 'Register a complete agent identity bundle on AgentDomain. Domain, DNS, email setup, SSL certification, AgentID NFT orchestration, and platform fee are included by default. Users can say "no basename" to skip Basename, "with ENS" to add ENS, and "email username support" to customize the primary inbox.',
221
- similes: ["CLAIM_DOMAIN", "CREATE_IDENTITY", "GET_DOMAIN"],
201
+ similes: ['CLAIM_DOMAIN', 'CREATE_IDENTITY', 'GET_DOMAIN'],
222
202
  examples: [
223
203
  [
204
+ { user: 'user1', content: { text: 'Register me as helpful-bot.ai email username support' } },
224
205
  {
225
- user: "user1",
226
- content: {
227
- text: "Register me as helpful-bot.ai email username support",
228
- },
229
- },
230
- {
231
- user: "agent",
206
+ user: 'agent',
232
207
  content: {
233
208
  text: "I'll register helpful-bot.ai with included email and SSL infrastructure now.",
234
- action: "REGISTER_IDENTITY",
209
+ action: 'REGISTER_IDENTITY',
235
210
  },
236
211
  },
237
212
  ],
238
213
  ],
239
- validate: async (runtime, _message) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY")),
214
+ validate: async (runtime, _message) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY')),
240
215
  handler: async (runtime, message) => {
241
216
  const params = parseParamsFromText(message.content.text);
242
217
  const validated = registerSchema.parse(params);
243
- const { ad, account, walletClient, chain } = getClients(runtime, {
218
+ const { ad, account, walletClient, publicClient, chain } = getClients(runtime, {
244
219
  requireWallet: true,
245
220
  });
246
- if (!account || !walletClient)
247
- throw new Error("AGENT_PRIVATE_KEY not set");
221
+ if (!account || !walletClient || !publicClient)
222
+ throw new Error('AGENT_PRIVATE_KEY not set');
248
223
  const result = await ad.register({
249
224
  ...validated,
250
225
  emailEnabled: true,
251
226
  wallet: account.address,
252
227
  });
253
- let autoRenewMsg = "";
228
+ let autoRenewMsg = '';
254
229
  if (validated.autoRenew) {
255
- const vaultAddress = runtime.getSetting("RENEWAL_VAULT_ADDRESS");
230
+ const vaultAddress = runtime.getSetting('RENEWAL_VAULT_ADDRESS');
256
231
  if (vaultAddress) {
257
232
  try {
258
- const txHash = await walletClient.writeContract({
259
- address: vaultAddress,
260
- abi: [
261
- {
262
- type: "function",
263
- name: "setAutoRenew",
264
- inputs: [
265
- { name: "tokenId", type: "uint256" },
266
- { name: "enabled", type: "bool" },
267
- ],
268
- },
269
- ],
270
- functionName: "setAutoRenew",
271
- args: [BigInt(result.nftTokenId), true],
233
+ const txHash = await walletClient.sendTransaction({
234
+ to: vaultAddress,
235
+ data: encodeElizaAutoRenewCalldata(BigInt(result.nftTokenId), runtime.getSetting('AGENTDOMAIN_BUILDER_CODE')),
272
236
  chain,
273
237
  account,
274
238
  });
239
+ let receipt;
240
+ try {
241
+ receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
242
+ }
243
+ catch (e) {
244
+ throw new Error(`Auto-renew transaction ${txHash} was submitted but confirmation failed or remained pending: ${String(e)}`);
245
+ }
246
+ if (receipt.status !== 'success') {
247
+ throw new Error(`Auto-renew transaction ${txHash} confirmed with status ${receipt.status}; auto-renew was not enabled.`);
248
+ }
275
249
  autoRenewMsg = ` Auto-renew enabled via tx ${txHash}.`;
276
250
  }
277
251
  catch (e) {
@@ -279,20 +253,19 @@ export const registerIdentityAction = {
279
253
  }
280
254
  }
281
255
  else {
282
- autoRenewMsg =
283
- " (Requires RENEWAL_VAULT_ADDRESS env var to enable auto-renew on-chain).";
256
+ autoRenewMsg = ' (Requires RENEWAL_VAULT_ADDRESS env var to enable auto-renew on-chain).';
284
257
  }
285
258
  }
286
259
  return {
287
- text: `Registered ${result.domain}${result.basename ? ` and ${result.basename}` : ""}. Token #${result.nftTokenId}.${autoRenewMsg}`,
260
+ text: `Registered ${result.domain}${result.basename ? ` and ${result.basename}` : ''}. Token #${result.nftTokenId}.${autoRenewMsg}`,
288
261
  data: result,
289
262
  };
290
263
  },
291
264
  };
292
265
  export const searchAgentsAction = {
293
- name: "SEARCH_AGENTS",
294
- description: "Search the public AgentDomain registry by name, capability, or framework.",
295
- similes: ["FIND_AGENT", "DISCOVER_AGENT"],
266
+ name: 'SEARCH_AGENTS',
267
+ description: 'Search the public AgentDomain registry by name, capability, or framework.',
268
+ similes: ['FIND_AGENT', 'DISCOVER_AGENT'],
296
269
  examples: [],
297
270
  validate: async () => true,
298
271
  handler: async (runtime, message) => {
@@ -306,43 +279,41 @@ export const searchAgentsAction = {
306
279
  },
307
280
  };
308
281
  export const listEmailAction = {
309
- name: "LIST_AGENT_EMAIL",
310
- description: "List text-only email messages and extracted verification codes for an AgentDomain identity.",
311
- similes: ["CHECK_EMAIL", "READ_INBOX"],
282
+ name: 'LIST_AGENT_EMAIL',
283
+ description: 'List text-only email messages and extracted verification codes for an AgentDomain identity.',
284
+ similes: ['CHECK_EMAIL', 'READ_INBOX'],
312
285
  examples: [],
313
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY")),
286
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY')),
314
287
  handler: async (runtime, message) => {
315
288
  const { ad } = getClients(runtime);
316
289
  const agentId = message.content.text.match(/[0-9a-f-]{36}/i)?.[0];
317
290
  if (!agentId)
318
- throw new Error("Agent ID UUID is required to list email");
291
+ throw new Error('Agent ID UUID is required to list email');
319
292
  const result = await ad.listEmail(agentId, { limit: 20 });
320
293
  return { text: `Found ${result.messages.length} messages.`, data: result };
321
294
  },
322
295
  };
323
296
  export const deleteEmailMessageAction = {
324
- name: "DELETE_AGENT_EMAIL",
325
- description: "Permanently delete one AgentDomain email message.",
326
- similes: ["DELETE_EMAIL_MESSAGE", "REMOVE_EMAIL_MESSAGE"],
297
+ name: 'DELETE_AGENT_EMAIL',
298
+ description: 'Permanently delete one AgentDomain email message.',
299
+ similes: ['DELETE_EMAIL_MESSAGE', 'REMOVE_EMAIL_MESSAGE'],
327
300
  examples: [],
328
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
329
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
301
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
330
302
  handler: async (runtime, message) => {
331
303
  const { ad } = getClients(runtime);
332
- const ids = message.content.text.match(new RegExp(UUID_PATTERN.source, "gi")) ?? [];
304
+ const ids = message.content.text.match(new RegExp(UUID_PATTERN.source, 'gi')) ?? [];
333
305
  if (!ids[0] || !ids[1])
334
- throw new Error("Agent ID and message ID UUIDs are required");
306
+ throw new Error('Agent ID and message ID UUIDs are required');
335
307
  const result = await ad.deleteEmailMessage(ids[0], ids[1]);
336
308
  return { text: `Deleted email message ${ids[1]}.`, data: result };
337
309
  },
338
310
  };
339
311
  export const sendEmailAction = {
340
- name: "SEND_AGENT_EMAIL",
341
- description: "Send text-only email from an AgentDomain primary address or active alias.",
342
- similes: ["SEND_EMAIL", "EMAIL_FROM_AGENT"],
312
+ name: 'SEND_AGENT_EMAIL',
313
+ description: 'Send text-only email from an AgentDomain primary address or active alias.',
314
+ similes: ['SEND_EMAIL', 'EMAIL_FROM_AGENT'],
343
315
  examples: [],
344
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
345
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
316
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
346
317
  handler: async (runtime, message) => {
347
318
  const { ad } = getClients(runtime);
348
319
  const agentId = requireAgentId(message.content.text);
@@ -352,12 +323,11 @@ export const sendEmailAction = {
352
323
  },
353
324
  };
354
325
  export const emailUsageAction = {
355
- name: "GET_AGENT_EMAIL_USAGE",
356
- description: "Get combined monthly sent and received email usage.",
357
- similes: ["EMAIL_USAGE", "EMAIL_QUOTA"],
326
+ name: 'GET_AGENT_EMAIL_USAGE',
327
+ description: 'Get combined monthly sent and received email usage.',
328
+ similes: ['EMAIL_USAGE', 'EMAIL_QUOTA'],
358
329
  examples: [],
359
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
360
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
330
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
361
331
  handler: async (runtime, message) => {
362
332
  const { ad } = getClients(runtime);
363
333
  const result = await ad.getEmailUsage(requireAgentId(message.content.text));
@@ -368,123 +338,110 @@ export const emailUsageAction = {
368
338
  },
369
339
  };
370
340
  export const configureEmailWebhookAction = {
371
- name: "CONFIGURE_EMAIL_WEBHOOK",
372
- description: "Configure a signed inbound email webhook. Include an HTTPS URL in the request.",
373
- similes: ["SET_EMAIL_WEBHOOK"],
341
+ name: 'CONFIGURE_EMAIL_WEBHOOK',
342
+ description: 'Configure a signed inbound email webhook. Include an HTTPS URL in the request.',
343
+ similes: ['SET_EMAIL_WEBHOOK'],
374
344
  examples: [],
375
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
376
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
345
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
377
346
  handler: async (runtime, message) => {
378
347
  const { ad } = getClients(runtime);
379
348
  const agentId = requireAgentId(message.content.text);
380
349
  const url = message.content.text.match(/https:\/\/[^\s]+/)?.[0];
381
350
  if (!url)
382
- throw new Error("HTTPS webhook URL is required");
351
+ throw new Error('HTTPS webhook URL is required');
383
352
  const result = await ad.setEmailWebhook(agentId, {
384
353
  url,
385
- payloadMode: /inline/i.test(message.content.text)
386
- ? "inline_text"
387
- : "metadata",
354
+ payloadMode: /inline/i.test(message.content.text) ? 'inline_text' : 'metadata',
388
355
  enabled: true,
389
356
  });
390
- return { text: "Inbound email webhook configured.", data: result };
357
+ return { text: 'Inbound email webhook configured.', data: result };
391
358
  },
392
359
  };
393
360
  export const sendEmailBatchAction = {
394
- name: "SEND_AGENT_EMAIL_BATCH",
395
- description: "Queue up to 100 emails supplied as a JSON messages array.",
396
- similes: ["BATCH_EMAIL"],
361
+ name: 'SEND_AGENT_EMAIL_BATCH',
362
+ description: 'Queue up to 100 emails supplied as a JSON messages array.',
363
+ similes: ['BATCH_EMAIL'],
397
364
  examples: [],
398
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
399
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
365
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
400
366
  handler: async (runtime, message) => {
401
367
  const { ad } = getClients(runtime);
402
368
  const agentId = requireAgentId(message.content.text);
403
- const json = message.content.text.slice(message.content.text.indexOf("{"));
369
+ const json = message.content.text.slice(message.content.text.indexOf('{'));
404
370
  const parsed = JSON.parse(json);
405
- const result = await ad.sendEmailBatch(agentId, {
406
- messages: parsed.messages,
407
- });
371
+ const result = await ad.sendEmailBatch(agentId, { messages: parsed.messages });
408
372
  return { text: `Queued ${result.jobs.length} email jobs.`, data: result };
409
373
  },
410
374
  };
411
375
  export const updatePrimaryEmailAction = {
412
- name: "UPDATE_PRIMARY_EMAIL",
413
- description: "Change an AgentDomain primary email username. The old primary address stops receiving new mail.",
414
- similes: ["CHANGE_PRIMARY_EMAIL", "RENAME_EMAIL"],
376
+ name: 'UPDATE_PRIMARY_EMAIL',
377
+ description: 'Change an AgentDomain primary email username. The old primary address stops receiving new mail.',
378
+ similes: ['CHANGE_PRIMARY_EMAIL', 'RENAME_EMAIL'],
415
379
  examples: [],
416
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
417
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
380
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
418
381
  handler: async (runtime, message) => {
419
382
  const { ad } = getClients(runtime);
420
383
  const agentId = requireAgentId(message.content.text);
421
384
  const username = parseEmailUsername(message.content.text);
422
385
  if (!username)
423
- throw new Error("New email username is required");
386
+ throw new Error('New email username is required');
424
387
  const result = await ad.updatePrimaryEmail(agentId, username);
425
388
  return { text: result.message, data: result };
426
389
  },
427
390
  };
428
391
  export const createEmailAliasAction = {
429
- name: "CREATE_EMAIL_ALIAS",
430
- description: "Create a receive-and-send email alias for an AgentDomain identity. Requires available paid-plan alias capacity.",
431
- similes: ["ADD_EMAIL_ALIAS", "CREATE_ALIAS"],
392
+ name: 'CREATE_EMAIL_ALIAS',
393
+ description: 'Create a receive-and-send email alias for an AgentDomain identity. Requires available paid-plan alias capacity.',
394
+ similes: ['ADD_EMAIL_ALIAS', 'CREATE_ALIAS'],
432
395
  examples: [],
433
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
434
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
396
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
435
397
  handler: async (runtime, message) => {
436
398
  const { ad } = getClients(runtime);
437
399
  const agentId = requireAgentId(message.content.text);
438
400
  const username = parseEmailUsername(message.content.text);
439
401
  if (!username)
440
- throw new Error("Alias username is required");
402
+ throw new Error('Alias username is required');
441
403
  const result = await ad.createEmailAlias(agentId, username);
442
- return {
443
- text: `Created email alias ${result.address.emailAddress}.`,
444
- data: result,
445
- };
404
+ return { text: `Created email alias ${result.address.emailAddress}.`, data: result };
446
405
  },
447
406
  };
448
407
  export const deleteEmailAliasAction = {
449
- name: "DELETE_EMAIL_ALIAS",
450
- description: "Delete an active AgentDomain email alias.",
451
- similes: ["REMOVE_EMAIL_ALIAS", "DELETE_ALIAS"],
408
+ name: 'DELETE_EMAIL_ALIAS',
409
+ description: 'Delete an active AgentDomain email alias.',
410
+ similes: ['REMOVE_EMAIL_ALIAS', 'DELETE_ALIAS'],
452
411
  examples: [],
453
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
454
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
412
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
455
413
  handler: async (runtime, message) => {
456
414
  const { ad } = getClients(runtime);
457
415
  const agentId = requireAgentId(message.content.text);
458
- const emailAddress = message.content.text.match(EMAIL_PATTERN)?.[0];
416
+ const emailAddress = extractEmailAddresses(message.content.text)[0];
459
417
  if (!emailAddress)
460
- throw new Error("Full alias email address is required");
418
+ throw new Error('Full alias email address is required');
461
419
  const result = await ad.deleteEmailAlias(agentId, emailAddress);
462
420
  return { text: `Deleted email alias ${emailAddress}.`, data: result };
463
421
  },
464
422
  };
465
423
  export const renewalStatusAction = {
466
- name: "GET_RENEWAL_STATUS",
467
- description: "Get RenewalVault balance, shortfall, renewal amount, and auto-renew state.",
468
- similes: ["RENEWAL_STATUS", "CHECK_RENEWAL", "VAULT_STATUS"],
424
+ name: 'GET_RENEWAL_STATUS',
425
+ description: 'Get RenewalVault balance, shortfall, renewal amount, and auto-renew state.',
426
+ similes: ['RENEWAL_STATUS', 'CHECK_RENEWAL', 'VAULT_STATUS'],
469
427
  examples: [],
470
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
471
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
428
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
472
429
  handler: async (runtime, message) => {
473
430
  const { ad } = getClients(runtime);
474
431
  const agentId = requireAgentId(message.content.text);
475
432
  const status = await ad.getRenewalStatus(agentId);
476
433
  return {
477
- text: `Renewal for ${status.domain}: next $${status.nextRenewalAmountUsdc}, balance $${status.vaultBalanceUsdc}, shortfall $${status.shortfallUsdc}, auto-renew ${status.autoRenewEnabled ? "enabled" : "off"}.`,
434
+ text: `Renewal for ${status.domain}: next $${status.nextRenewalAmountUsdc}, balance $${status.vaultBalanceUsdc}, shortfall $${status.shortfallUsdc}, auto-renew ${status.autoRenewEnabled ? 'enabled' : 'off'}.`,
478
435
  data: status,
479
436
  };
480
437
  },
481
438
  };
482
439
  export const fundRenewalAction = {
483
- name: "FUND_RENEWAL_VAULT",
484
- description: "Deposit USDC into an AgentID renewal vault.",
485
- similes: ["DEPOSIT_RENEWAL", "FUND_VAULT"],
440
+ name: 'FUND_RENEWAL_VAULT',
441
+ description: 'Deposit USDC into an AgentID renewal vault.',
442
+ similes: ['DEPOSIT_RENEWAL', 'FUND_VAULT'],
486
443
  examples: [],
487
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY")),
444
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY')),
488
445
  handler: async (runtime, message) => {
489
446
  const { ad } = getClients(runtime, { requireWallet: true });
490
447
  const agentId = requireAgentId(message.content.text);
@@ -497,35 +454,32 @@ export const fundRenewalAction = {
497
454
  },
498
455
  };
499
456
  export const enableAutoRenewAction = {
500
- name: "ENABLE_AUTO_RENEW",
501
- description: "Enable on-chain RenewalVault auto-renew for an AgentDomain identity.",
502
- similes: ["AUTO_RENEW", "ENABLE_RENEWAL"],
457
+ name: 'ENABLE_AUTO_RENEW',
458
+ description: 'Enable on-chain RenewalVault auto-renew for an AgentDomain identity.',
459
+ similes: ['AUTO_RENEW', 'ENABLE_RENEWAL'],
503
460
  examples: [],
504
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") &&
505
- runtime.getSetting("RENEWAL_VAULT_ADDRESS")),
461
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') && runtime.getSetting('RENEWAL_VAULT_ADDRESS')),
506
462
  handler: async (runtime, message) => {
507
463
  const { ad } = getClients(runtime, { requireWallet: true });
508
464
  const agentId = requireAgentId(message.content.text);
509
465
  const result = await ad.setAutoRenew(agentId, true, {
510
- renewalVaultAddress: runtime.getSetting("RENEWAL_VAULT_ADDRESS"),
466
+ renewalVaultAddress: runtime.getSetting('RENEWAL_VAULT_ADDRESS'),
467
+ waitForReceipt: true,
511
468
  });
512
- return {
513
- text: `Auto-renew enabled for token #${result.tokenId}.`,
514
- data: result,
515
- };
469
+ return { text: `Auto-renew enabled for token #${result.tokenId}.`, data: result };
516
470
  },
517
471
  };
518
472
  export const reconfigureSslAction = {
519
- name: "RECONFIGURE_SSL",
520
- description: "Rebuild the Cloudflare SaaS SSL hostname and sync Spaceship DNS validation records for an AgentDomain identity.",
521
- similes: ["FIX_SSL", "REPAIR_SSL", "SYNC_SSL"],
473
+ name: 'RECONFIGURE_SSL',
474
+ description: 'Rebuild the managed SSL hostname and sync DNS validation records for an AgentDomain identity.',
475
+ similes: ['FIX_SSL', 'REPAIR_SSL', 'SYNC_SSL'],
522
476
  examples: [],
523
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY")),
477
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY')),
524
478
  handler: async (runtime, message) => {
525
479
  const { ad } = getClients(runtime);
526
480
  const agentId = message.content.text.match(/[0-9a-f-]{36}/i)?.[0];
527
481
  if (!agentId)
528
- throw new Error("Agent ID UUID is required to reconfigure SSL");
482
+ throw new Error('Agent ID UUID is required to reconfigure SSL');
529
483
  const result = await ad.reconfigureSsl(agentId);
530
484
  return {
531
485
  text: `SSL reconfigured for ${result.domain}. Status: ${result.sslStatus}.`,
@@ -534,12 +488,11 @@ export const reconfigureSslAction = {
534
488
  },
535
489
  };
536
490
  export const listDnsAction = {
537
- name: "LIST_DNS_RECORDS",
538
- description: "List DNS records for an AgentDomain identity.",
539
- similes: ["DNS_RECORDS", "LIST_DNS"],
491
+ name: 'LIST_DNS_RECORDS',
492
+ description: 'List DNS records for an AgentDomain identity.',
493
+ similes: ['DNS_RECORDS', 'LIST_DNS'],
540
494
  examples: [],
541
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
542
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
495
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
543
496
  handler: async (runtime, message) => {
544
497
  const { ad } = getClients(runtime);
545
498
  const agentId = requireAgentId(message.content.text);
@@ -548,86 +501,75 @@ export const listDnsAction = {
548
501
  },
549
502
  };
550
503
  export const dnsCapabilitiesAction = {
551
- name: "GET_DNS_CAPABILITIES",
552
- description: "Get AgentDomain DNS record types, validation fields, limits, and provider warnings.",
553
- similes: ["DNS_CAPABILITIES", "DNS_TYPES", "DNS_LIMITS"],
504
+ name: 'GET_DNS_CAPABILITIES',
505
+ description: 'Get AgentDomain DNS record types, validation fields, limits, and provider warnings.',
506
+ similes: ['DNS_CAPABILITIES', 'DNS_TYPES', 'DNS_LIMITS'],
554
507
  examples: [],
555
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
556
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
508
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
557
509
  handler: async (runtime, message) => {
558
510
  const { ad } = getClients(runtime);
559
511
  const result = await ad.getDnsCapabilities(requireAgentId(message.content.text));
560
512
  return {
561
- text: `AgentDomain supports ${result.supportedTypes.length} Spaceship DNS record types.`,
513
+ text: `AgentDomain supports ${result.supportedTypes.length} DNS record types.`,
562
514
  data: result,
563
515
  };
564
516
  },
565
517
  };
566
518
  export const createDnsAction = {
567
- name: "CREATE_DNS_RECORD",
568
- description: "Create a user-managed DNS record. Use text like: agentId type A name @ value 1.2.3.4.",
569
- similes: ["ADD_DNS", "CREATE_DNS"],
519
+ name: 'CREATE_DNS_RECORD',
520
+ description: 'Create a user-managed DNS record. Use text like: agentId type A name @ value 1.2.3.4.',
521
+ similes: ['ADD_DNS', 'CREATE_DNS'],
570
522
  examples: [],
571
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
572
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
523
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
573
524
  handler: async (runtime, message) => {
574
525
  const { ad } = getClients(runtime);
575
526
  const agentId = requireAgentId(message.content.text);
576
527
  const record = parseDnsRecord(message.content.text);
577
528
  const result = await ad.createDnsRecord(agentId, record);
578
- return {
579
- text: `Created ${result.type} DNS record ${result.name}.`,
580
- data: result,
581
- };
529
+ return { text: `Created ${result.type} DNS record ${result.name}.`, data: result };
582
530
  },
583
531
  };
584
532
  export const updateDnsAction = {
585
- name: "UPDATE_DNS_RECORD",
586
- description: "Update a user-managed DNS record. Include agent UUID and record UUID.",
587
- similes: ["EDIT_DNS", "UPDATE_DNS"],
533
+ name: 'UPDATE_DNS_RECORD',
534
+ description: 'Update a user-managed DNS record. Include agent UUID and record UUID.',
535
+ similes: ['EDIT_DNS', 'UPDATE_DNS'],
588
536
  examples: [],
589
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
590
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
537
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
591
538
  handler: async (runtime, message) => {
592
539
  const { ad } = getClients(runtime);
593
- const ids = message.content.text.match(new RegExp(UUID_PATTERN.source, "gi")) ?? [];
540
+ const ids = message.content.text.match(new RegExp(UUID_PATTERN.source, 'gi')) ?? [];
594
541
  const agentId = ids[0];
595
542
  const recordId = ids[1];
596
543
  if (!agentId || !recordId)
597
- throw new Error("Agent ID and record ID UUIDs are required");
544
+ throw new Error('Agent ID and record ID UUIDs are required');
598
545
  const record = parseDnsRecord(message.content.text);
599
546
  const result = await ad.updateDnsRecord(agentId, recordId, record);
600
- return {
601
- text: `Updated ${result.type} DNS record ${result.name}.`,
602
- data: result,
603
- };
547
+ return { text: `Updated ${result.type} DNS record ${result.name}.`, data: result };
604
548
  },
605
549
  };
606
550
  export const deleteDnsAction = {
607
- name: "DELETE_DNS_RECORD",
608
- description: "Delete a user-managed DNS record. Include agent UUID and record UUID.",
609
- similes: ["REMOVE_DNS", "DELETE_DNS"],
551
+ name: 'DELETE_DNS_RECORD',
552
+ description: 'Delete a user-managed DNS record. Include agent UUID and record UUID.',
553
+ similes: ['REMOVE_DNS', 'DELETE_DNS'],
610
554
  examples: [],
611
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
612
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
555
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
613
556
  handler: async (runtime, message) => {
614
557
  const { ad } = getClients(runtime);
615
- const ids = message.content.text.match(new RegExp(UUID_PATTERN.source, "gi")) ?? [];
558
+ const ids = message.content.text.match(new RegExp(UUID_PATTERN.source, 'gi')) ?? [];
616
559
  const agentId = ids[0];
617
560
  const recordId = ids[1];
618
561
  if (!agentId || !recordId)
619
- throw new Error("Agent ID and record ID UUIDs are required");
562
+ throw new Error('Agent ID and record ID UUIDs are required');
620
563
  const result = await ad.deleteDnsRecord(agentId, recordId);
621
564
  return { text: `Deleted DNS record ${recordId}.`, data: result };
622
565
  },
623
566
  };
624
567
  export const changeDnsRecordsAction = {
625
- name: "CHANGE_DNS_RECORDS",
626
- description: "Preview or apply a revision-protected DNS batch from a JSON array of structured records.",
627
- similes: ["BATCH_DNS", "PREVIEW_DNS_CHANGES", "APPLY_DNS_CHANGES"],
568
+ name: 'CHANGE_DNS_RECORDS',
569
+ description: 'Preview or apply a revision-protected DNS batch from a JSON array of structured records.',
570
+ similes: ['BATCH_DNS', 'PREVIEW_DNS_CHANGES', 'APPLY_DNS_CHANGES'],
628
571
  examples: [],
629
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
630
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
572
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
631
573
  handler: async (runtime, message) => {
632
574
  const { ad } = getClients(runtime);
633
575
  const agentId = requireAgentId(message.content.text);
@@ -637,20 +579,17 @@ export const changeDnsRecordsAction = {
637
579
  ? await ad.previewDnsBatch(agentId, records, options.mode)
638
580
  : await ad.applyDnsBatch(agentId, records, requireDnsRevision(options.baseRevision), options.mode);
639
581
  return {
640
- text: options.dryRun
641
- ? "DNS preview generated."
642
- : "DNS change set applied.",
582
+ text: options.dryRun ? 'DNS preview generated.' : 'DNS change set applied.',
643
583
  data: result,
644
584
  };
645
585
  },
646
586
  };
647
587
  export const importDnsZoneAction = {
648
- name: "IMPORT_DNS_ZONE",
649
- description: "Preview or apply a validated BIND DNS zone import.",
650
- similes: ["DNS_ZONE_IMPORT", "IMPORT_BIND_ZONE"],
588
+ name: 'IMPORT_DNS_ZONE',
589
+ description: 'Preview or apply a validated BIND DNS zone import.',
590
+ similes: ['DNS_ZONE_IMPORT', 'IMPORT_BIND_ZONE'],
651
591
  examples: [],
652
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
653
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
592
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
654
593
  handler: async (runtime, message) => {
655
594
  const { ad } = getClients(runtime);
656
595
  const agentId = requireAgentId(message.content.text);
@@ -660,33 +599,29 @@ export const importDnsZoneAction = {
660
599
  ? await ad.previewDnsImport(agentId, zoneFile, options.mode)
661
600
  : await ad.applyDnsImport(agentId, zoneFile, requireDnsRevision(options.baseRevision), options.mode);
662
601
  return {
663
- text: options.dryRun
664
- ? "DNS import preview generated."
665
- : "DNS zone import applied.",
602
+ text: options.dryRun ? 'DNS import preview generated.' : 'DNS zone import applied.',
666
603
  data: result,
667
604
  };
668
605
  },
669
606
  };
670
607
  export const exportDnsZoneAction = {
671
- name: "EXPORT_DNS_ZONE",
672
- description: "Export AgentDomain DNS records as a standard BIND zone file.",
673
- similes: ["DNS_ZONE_EXPORT", "EXPORT_BIND_ZONE"],
608
+ name: 'EXPORT_DNS_ZONE',
609
+ description: 'Export AgentDomain DNS records as a standard BIND zone file.',
610
+ similes: ['DNS_ZONE_EXPORT', 'EXPORT_BIND_ZONE'],
674
611
  examples: [],
675
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
676
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
612
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
677
613
  handler: async (runtime, message) => {
678
614
  const { ad } = getClients(runtime);
679
- const zone = await ad.exportDnsZone(requireAgentId(message.content.text), /\b(?:all|complete)\b/i.test(message.content.text) ? "all" : "user");
680
- return { text: zone, data: { format: "bind", zone } };
615
+ const zone = await ad.exportDnsZone(requireAgentId(message.content.text), /\b(?:all|complete)\b/i.test(message.content.text) ? 'all' : 'user');
616
+ return { text: zone, data: { format: 'bind', zone } };
681
617
  },
682
618
  };
683
619
  export const servicePlanStatusAction = {
684
- name: "GET_SERVICE_PLAN",
685
- description: "Get an agent Premium Plan, limits, current period, and billing state.",
686
- similes: ["PLAN_STATUS", "CHECK_PLAN"],
620
+ name: 'GET_SERVICE_PLAN',
621
+ description: 'Get an agent Premium Plan, limits, current period, and billing state.',
622
+ similes: ['PLAN_STATUS', 'CHECK_PLAN'],
687
623
  examples: [],
688
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
689
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
624
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
690
625
  handler: async (runtime, message) => {
691
626
  const { ad } = getClients(runtime);
692
627
  const agentId = requireAgentId(message.content.text);
@@ -698,45 +633,39 @@ export const servicePlanStatusAction = {
698
633
  },
699
634
  };
700
635
  export const setRegistryVisibilityAction = {
701
- name: "SET_REGISTRY_VISIBILITY",
702
- description: "Hide or show an agent in the public AgentDomain registry. Hiding requires an active paid Premium Plan.",
703
- similes: [
704
- "HIDE_AGENT_REGISTRY",
705
- "SHOW_AGENT_REGISTRY",
706
- "REGISTRY_VISIBILITY",
707
- ],
636
+ name: 'SET_REGISTRY_VISIBILITY',
637
+ description: 'Hide or show an agent in the public AgentDomain registry. Hiding requires an active paid Premium Plan.',
638
+ similes: ['HIDE_AGENT_REGISTRY', 'SHOW_AGENT_REGISTRY', 'REGISTRY_VISIBILITY'],
708
639
  examples: [],
709
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
710
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
640
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
711
641
  handler: async (runtime, message) => {
712
642
  const { ad } = getClients(runtime);
713
643
  const agentId = requireAgentId(message.content.text);
714
644
  const text = message.content.text.toLowerCase();
715
- const wantsPublic = text.includes("unhide") ||
716
- text.includes("show") ||
717
- text.includes("visible") ||
718
- text.includes("public");
719
- const registryHidden = !wantsPublic && (text.includes("hide") || text.includes("private"));
645
+ const wantsPublic = text.includes('unhide') ||
646
+ text.includes('show') ||
647
+ text.includes('visible') ||
648
+ text.includes('public');
649
+ const registryHidden = !wantsPublic && (text.includes('hide') || text.includes('private'));
720
650
  const result = await ad.setRegistryVisibility(agentId, registryHidden);
721
651
  return {
722
- text: `${result.domain} is now ${result.registryVisibility.hidden ? "hidden from" : "visible in"} the public registry.`,
652
+ text: `${result.domain} is now ${result.registryVisibility.hidden ? 'hidden from' : 'visible in'} the public registry.`,
723
653
  data: result,
724
654
  };
725
655
  },
726
656
  };
727
657
  export const scheduleServicePlanRenewalAction = {
728
- name: "SCHEDULE_SERVICE_PLAN_RENEWAL",
729
- description: "Choose the exact AgentDomain Premium Plan SKU for the next identity renewal.",
730
- similes: ["CHANGE_RENEWAL_PLAN", "SET_NEXT_RENEWAL_PLAN"],
658
+ name: 'SCHEDULE_SERVICE_PLAN_RENEWAL',
659
+ description: 'Choose the exact AgentDomain Premium Plan SKU for the next identity renewal.',
660
+ similes: ['CHANGE_RENEWAL_PLAN', 'SET_NEXT_RENEWAL_PLAN'],
731
661
  examples: [],
732
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY") ||
733
- runtime.getSetting("AGENTDOMAIN_API_KEY")),
662
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY') || runtime.getSetting('AGENTDOMAIN_API_KEY')),
734
663
  handler: async (runtime, message) => {
735
664
  const { ad } = getClients(runtime);
736
665
  const agentId = requireAgentId(message.content.text);
737
666
  const lower = message.content.text.toLowerCase();
738
667
  const plan = parseRegistrationPlan(lower);
739
- const parsed = plan === "enterprise" ? parsePlan(lower) : { plan, planSku: plan };
668
+ const parsed = plan === 'enterprise' ? parsePlan(lower) : { plan, planSku: plan };
740
669
  const result = await ad.scheduleServicePlanRenewal(agentId, parsed);
741
670
  return {
742
671
  text: `Scheduled ${result.renewalPlanSku} for the next identity renewal.`,
@@ -745,11 +674,11 @@ export const scheduleServicePlanRenewalAction = {
745
674
  },
746
675
  };
747
676
  export const purchaseServicePlanAction = {
748
- name: "PURCHASE_SERVICE_PLAN",
749
- description: "Upgrade an agent to AgentDomain Starter, Pro, or Enterprise using x402 USDC.",
750
- similes: ["BUY_PLAN", "UPGRADE_PLAN"],
677
+ name: 'PURCHASE_SERVICE_PLAN',
678
+ description: 'Upgrade an agent to AgentDomain Starter, Pro, or Enterprise using x402 USDC.',
679
+ similes: ['BUY_PLAN', 'UPGRADE_PLAN'],
751
680
  examples: [],
752
- validate: async (runtime) => Boolean(runtime.getSetting("AGENT_PRIVATE_KEY")),
681
+ validate: async (runtime) => Boolean(runtime.getSetting('AGENT_PRIVATE_KEY')),
753
682
  handler: async (runtime, message) => {
754
683
  const { ad } = getClients(runtime, { requireWallet: true });
755
684
  const agentId = requireAgentId(message.content.text);
@@ -765,8 +694,8 @@ export const purchaseServicePlanAction = {
765
694
  },
766
695
  };
767
696
  export const agentDomainPlugin = {
768
- name: "agentdomain",
769
- description: "Identity infrastructure for AI agents on Base (domain + Basename + DNS + email + SSL).",
697
+ name: 'agentdomain',
698
+ description: 'Identity infrastructure for AI agents on Base (domain + Basename + DNS + email + SSL).',
770
699
  actions: [
771
700
  quoteRegistrationAction,
772
701
  registerIdentityAction,