@agentdomain/agentkit-plugin 0.6.0 → 0.7.0
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/NOTICE +5 -0
- package/README.md +15 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +124 -143
- package/package.json +6 -3
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -19,3 +19,18 @@ The provider exposes actions for:
|
|
|
19
19
|
Default API base: `https://agentdomain.app/api/v1`.
|
|
20
20
|
|
|
21
21
|
Request the base URL directly to retrieve AgentDomain's machine-readable API discovery metadata.
|
|
22
|
+
|
|
23
|
+
Provide your public ERC-8021 app identifier when constructing the action
|
|
24
|
+
provider:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
const provider = new AgentDomainActionProvider({
|
|
28
|
+
builderCode: process.env.AGENTDOMAIN_BUILDER_CODE,
|
|
29
|
+
renewalVaultAddress: process.env.RENEWAL_VAULT_ADDRESS,
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`builderCode` is required only for direct Base writes such as auto-renew and
|
|
34
|
+
vault withdrawal. Missing or invalid attribution stops those actions before
|
|
35
|
+
`walletProvider.sendTransaction`; reads, signatures, and x402 v2 paid requests
|
|
36
|
+
keep their existing behavior.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
declare const QuoteSchema: z.ZodObject<{
|
|
3
3
|
preferredName: z.ZodString;
|
|
4
4
|
tld: z.ZodDefault<z.ZodEnum<["xyz", "com", "ai", "org", "io", "net", "co", "app"]>>;
|
|
@@ -108,7 +108,9 @@ export interface AgentDomainActionProviderOptions {
|
|
|
108
108
|
apiKey?: string;
|
|
109
109
|
baseRpcUrl?: string;
|
|
110
110
|
renewalVaultAddress?: string;
|
|
111
|
-
network?:
|
|
111
|
+
network?: 'base' | 'base-sepolia';
|
|
112
|
+
/** Public ERC-8021 app code required for direct Base transaction actions. */
|
|
113
|
+
builderCode?: string;
|
|
112
114
|
}
|
|
113
115
|
export declare class AgentDomainActionProvider {
|
|
114
116
|
readonly name = "agentdomain";
|
|
@@ -117,6 +119,7 @@ export declare class AgentDomainActionProvider {
|
|
|
117
119
|
private readonly baseRpcUrl;
|
|
118
120
|
private readonly renewalVaultAddress?;
|
|
119
121
|
private readonly network;
|
|
122
|
+
private readonly builderCode?;
|
|
120
123
|
constructor(opts?: AgentDomainActionProviderOptions);
|
|
121
124
|
private createAgentDomain;
|
|
122
125
|
getActions(): ({
|
|
@@ -238,6 +241,7 @@ export declare class AgentDomainActionProvider {
|
|
|
238
241
|
private renewalStatus;
|
|
239
242
|
private fundRenewal;
|
|
240
243
|
private enableAutoRenew;
|
|
244
|
+
private requireBuilderCode;
|
|
241
245
|
private reconfigureSsl;
|
|
242
246
|
private listDns;
|
|
243
247
|
private getDnsCapabilities;
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { AgentDomain } from
|
|
3
|
-
import { DNS_RECORD_TYPES, dnsRecordSchema
|
|
4
|
-
import { AGENTDOMAIN_API_BASE_URL, SERVICE_PLAN_KEYS, SUPPORTED_FRAMEWORKS, SUPPORTED_TLDS, } from
|
|
5
|
-
import { createPublicClient, createWalletClient, http
|
|
6
|
-
import { base, baseSepolia } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AgentDomain, encodeSetAutoRenewCalldata } from '@agentdomain/sdk';
|
|
3
|
+
import { DNS_RECORD_TYPES, dnsRecordSchema } from '@agentdomain/shared';
|
|
4
|
+
import { AGENTDOMAIN_API_BASE_URL, SERVICE_PLAN_KEYS, SUPPORTED_FRAMEWORKS, SUPPORTED_TLDS, } from '@agentdomain/shared/constants';
|
|
5
|
+
import { createPublicClient, createWalletClient, http } from 'viem';
|
|
6
|
+
import { base, baseSepolia } from 'viem/chains';
|
|
7
7
|
const RegisterSchema = z.object({
|
|
8
8
|
preferredName: z.string().min(3).max(63),
|
|
9
|
-
tld: z.enum(SUPPORTED_TLDS).default(
|
|
9
|
+
tld: z.enum(SUPPORTED_TLDS).default('xyz'),
|
|
10
10
|
registerBasename: z.boolean().default(true),
|
|
11
11
|
basenameLabel: z.string().min(3).max(63).optional(),
|
|
12
12
|
registerEns: z.boolean().default(false),
|
|
@@ -25,11 +25,11 @@ const RegisterSchema = z.object({
|
|
|
25
25
|
dnsTarget: z.string().url().optional(),
|
|
26
26
|
years: z.number().int().min(1).max(10).default(1),
|
|
27
27
|
autoRenew: z.boolean().default(false),
|
|
28
|
-
premiumPlan: z.enum(SERVICE_PLAN_KEYS).default(
|
|
28
|
+
premiumPlan: z.enum(SERVICE_PLAN_KEYS).default('included'),
|
|
29
29
|
});
|
|
30
30
|
const QuoteSchema = z.object({
|
|
31
31
|
preferredName: z.string(),
|
|
32
|
-
tld: z.enum(SUPPORTED_TLDS).default(
|
|
32
|
+
tld: z.enum(SUPPORTED_TLDS).default('xyz'),
|
|
33
33
|
registerBasename: z.boolean().default(true),
|
|
34
34
|
basenameLabel: z.string().min(3).max(63).optional(),
|
|
35
35
|
registerEns: z.boolean().default(false),
|
|
@@ -42,7 +42,7 @@ const QuoteSchema = z.object({
|
|
|
42
42
|
.regex(/^[a-z0-9](?:[a-z0-9._+-]{0,62}[a-z0-9])?$/)
|
|
43
43
|
.optional(),
|
|
44
44
|
years: z.number().int().min(1).max(10).default(1),
|
|
45
|
-
premiumPlan: z.enum(SERVICE_PLAN_KEYS).default(
|
|
45
|
+
premiumPlan: z.enum(SERVICE_PLAN_KEYS).default('included'),
|
|
46
46
|
});
|
|
47
47
|
const SearchSchema = z.object({
|
|
48
48
|
q: z.string().optional(),
|
|
@@ -74,7 +74,7 @@ const EmailUsageSchema = z.object({ agentId: z.string() });
|
|
|
74
74
|
const EmailWebhookSchema = z.object({
|
|
75
75
|
agentId: z.string(),
|
|
76
76
|
url: z.string().url(),
|
|
77
|
-
payloadMode: z.enum([
|
|
77
|
+
payloadMode: z.enum(['metadata', 'inline_text']).default('metadata'),
|
|
78
78
|
enabled: z.boolean().default(true),
|
|
79
79
|
});
|
|
80
80
|
const RenewalStatusSchema = z.object({
|
|
@@ -82,9 +82,7 @@ const RenewalStatusSchema = z.object({
|
|
|
82
82
|
});
|
|
83
83
|
const FundRenewalSchema = z.object({
|
|
84
84
|
agentId: z.string().min(1),
|
|
85
|
-
amountUsdc: z
|
|
86
|
-
.string()
|
|
87
|
-
.regex(/^\d+(\.\d{1,6})?$/, "Use a USDC amount with up to 6 decimals"),
|
|
85
|
+
amountUsdc: z.string().regex(/^\d+(\.\d{1,6})?$/, 'Use a USDC amount with up to 6 decimals'),
|
|
88
86
|
enableAutoRenew: z.boolean().default(false),
|
|
89
87
|
});
|
|
90
88
|
const EnableAutoRenewSchema = z.object({
|
|
@@ -108,8 +106,8 @@ const CreateDnsSchema = z
|
|
|
108
106
|
priority: z.number().int().min(0).max(65_535).optional(),
|
|
109
107
|
})
|
|
110
108
|
.refine((record) => record.value !== undefined || record.data !== undefined, {
|
|
111
|
-
message:
|
|
112
|
-
path: [
|
|
109
|
+
message: 'Provide structured data or the legacy value field',
|
|
110
|
+
path: ['data'],
|
|
113
111
|
});
|
|
114
112
|
const UpdateDnsSchema = z.object({
|
|
115
113
|
agentId: z.string().min(1),
|
|
@@ -128,33 +126,31 @@ const DeleteDnsSchema = z.object({
|
|
|
128
126
|
const ChangeDnsSchema = z.object({
|
|
129
127
|
agentId: z.string().min(1),
|
|
130
128
|
records: z.array(dnsRecordSchema).min(1).max(200),
|
|
131
|
-
mode: z.enum([
|
|
129
|
+
mode: z.enum(['merge', 'replace']).default('merge'),
|
|
132
130
|
dryRun: z.boolean().default(true),
|
|
133
131
|
baseRevision: z.string().length(64).optional(),
|
|
134
132
|
});
|
|
135
133
|
const ImportDnsSchema = z.object({
|
|
136
134
|
agentId: z.string().min(1),
|
|
137
135
|
zoneFile: z.string().min(1).max(262_144),
|
|
138
|
-
mode: z.enum([
|
|
136
|
+
mode: z.enum(['merge', 'replace']).default('merge'),
|
|
139
137
|
dryRun: z.boolean().default(true),
|
|
140
138
|
baseRevision: z.string().length(64).optional(),
|
|
141
139
|
});
|
|
142
140
|
const ExportDnsSchema = z.object({
|
|
143
141
|
agentId: z.string().min(1),
|
|
144
|
-
scope: z.enum([
|
|
142
|
+
scope: z.enum(['user', 'all']).default('user'),
|
|
145
143
|
});
|
|
146
144
|
const WithdrawRenewalSchema = z.object({
|
|
147
145
|
agentId: z.string().min(1),
|
|
148
|
-
amountUsdc: z
|
|
149
|
-
.string()
|
|
150
|
-
.regex(/^\d+(\.\d{1,6})?$/, "Use a USDC amount with up to 6 decimals"),
|
|
146
|
+
amountUsdc: z.string().regex(/^\d+(\.\d{1,6})?$/, 'Use a USDC amount with up to 6 decimals'),
|
|
151
147
|
});
|
|
152
148
|
const ServicePlanStatusSchema = z.object({
|
|
153
149
|
agentId: z.string().min(1),
|
|
154
150
|
});
|
|
155
151
|
const PurchaseServicePlanSchema = z.object({
|
|
156
152
|
agentId: z.string().min(1),
|
|
157
|
-
plan: z.enum([
|
|
153
|
+
plan: z.enum(['starter', 'pro', 'enterprise']),
|
|
158
154
|
planSku: z.custom().optional(),
|
|
159
155
|
});
|
|
160
156
|
const SetRegistryVisibilitySchema = z.object({
|
|
@@ -163,7 +159,7 @@ const SetRegistryVisibilitySchema = z.object({
|
|
|
163
159
|
});
|
|
164
160
|
const ScheduleServicePlanRenewalSchema = z.object({
|
|
165
161
|
agentId: z.string().uuid(),
|
|
166
|
-
plan: z.enum([
|
|
162
|
+
plan: z.enum(['included', 'starter', 'pro', 'enterprise']),
|
|
167
163
|
planSku: z.custom(),
|
|
168
164
|
});
|
|
169
165
|
const UpdatePrimaryEmailSchema = z.object({
|
|
@@ -180,26 +176,25 @@ const DeleteEmailAliasSchema = z.object({
|
|
|
180
176
|
emailAddress: z.string().email(),
|
|
181
177
|
});
|
|
182
178
|
export class AgentDomainActionProvider {
|
|
183
|
-
name =
|
|
179
|
+
name = 'agentdomain';
|
|
184
180
|
apiUrl;
|
|
185
181
|
apiKey;
|
|
186
182
|
baseRpcUrl;
|
|
187
183
|
renewalVaultAddress;
|
|
188
184
|
network;
|
|
185
|
+
builderCode;
|
|
189
186
|
constructor(opts = {}) {
|
|
190
187
|
this.apiUrl = opts.apiUrl ?? AGENTDOMAIN_API_BASE_URL;
|
|
191
188
|
this.apiKey = opts.apiKey;
|
|
192
|
-
this.baseRpcUrl = opts.baseRpcUrl ??
|
|
189
|
+
this.baseRpcUrl = opts.baseRpcUrl ?? 'https://mainnet.base.org';
|
|
193
190
|
this.renewalVaultAddress = opts.renewalVaultAddress;
|
|
194
|
-
this.network = opts.network ??
|
|
191
|
+
this.network = opts.network ?? 'base';
|
|
192
|
+
this.builderCode = opts.builderCode;
|
|
195
193
|
}
|
|
196
194
|
createAgentDomain(walletProvider) {
|
|
197
195
|
const wallet = walletProvider.getAddress();
|
|
198
|
-
const chain = this.network ===
|
|
199
|
-
const publicClient = createPublicClient({
|
|
200
|
-
chain,
|
|
201
|
-
transport: http(this.baseRpcUrl),
|
|
202
|
-
});
|
|
196
|
+
const chain = this.network === 'base-sepolia' ? baseSepolia : base;
|
|
197
|
+
const publicClient = createPublicClient({ chain, transport: http(this.baseRpcUrl) });
|
|
203
198
|
const walletClient = createWalletClient({
|
|
204
199
|
chain,
|
|
205
200
|
transport: http(this.baseRpcUrl),
|
|
@@ -216,6 +211,7 @@ export class AgentDomainActionProvider {
|
|
|
216
211
|
apiKey: this.apiKey,
|
|
217
212
|
network: this.network,
|
|
218
213
|
renewalVaultAddress: this.renewalVaultAddress,
|
|
214
|
+
builderCode: this.builderCode,
|
|
219
215
|
walletClient: walletClient,
|
|
220
216
|
publicClient: publicClient,
|
|
221
217
|
});
|
|
@@ -224,215 +220,210 @@ export class AgentDomainActionProvider {
|
|
|
224
220
|
getActions() {
|
|
225
221
|
return [
|
|
226
222
|
{
|
|
227
|
-
name:
|
|
228
|
-
description:
|
|
223
|
+
name: 'register_agent_identity',
|
|
224
|
+
description: 'Register a complete agent identity bundle on AgentDomain. Domain, DNS, included email setup, SSL certification, AgentID NFT orchestration, and platform fee are included by default. Basename and ENS are optional paid add-ons. Pays in USDC on Base.',
|
|
229
225
|
schema: RegisterSchema,
|
|
230
226
|
invoke: this.register.bind(this),
|
|
231
227
|
},
|
|
232
228
|
{
|
|
233
|
-
name:
|
|
234
|
-
description:
|
|
229
|
+
name: 'quote_agent_registration',
|
|
230
|
+
description: 'Price an agent identity registration before committing. Quote includes the annual platform fee with email setup, SSL certification, and AgentID NFT orchestration; Basename and ENS only charge when enabled.',
|
|
235
231
|
schema: QuoteSchema,
|
|
236
232
|
invoke: this.quote.bind(this),
|
|
237
233
|
},
|
|
238
234
|
{
|
|
239
|
-
name:
|
|
240
|
-
description:
|
|
235
|
+
name: 'search_agents',
|
|
236
|
+
description: 'Search the public AgentDomain registry.',
|
|
241
237
|
schema: SearchSchema,
|
|
242
238
|
invoke: this.search.bind(this),
|
|
243
239
|
},
|
|
244
240
|
{
|
|
245
|
-
name:
|
|
246
|
-
description:
|
|
241
|
+
name: 'send_agent_email',
|
|
242
|
+
description: 'Send text-only email from an agent primary email or active alias via AWS SES.',
|
|
247
243
|
schema: SendEmailSchema,
|
|
248
244
|
invoke: this.sendEmail.bind(this),
|
|
249
245
|
},
|
|
250
246
|
{
|
|
251
|
-
name:
|
|
252
|
-
description:
|
|
247
|
+
name: 'list_agent_email',
|
|
248
|
+
description: 'Query text-only agent email and extracted verification codes.',
|
|
253
249
|
schema: ListEmailSchema,
|
|
254
250
|
invoke: this.listEmail.bind(this),
|
|
255
251
|
},
|
|
256
252
|
{
|
|
257
|
-
name:
|
|
258
|
-
description:
|
|
253
|
+
name: 'delete_agent_email',
|
|
254
|
+
description: 'Permanently delete one email message from an agent inbox.',
|
|
259
255
|
schema: DeleteEmailMessageSchema,
|
|
260
256
|
invoke: this.deleteEmailMessage.bind(this),
|
|
261
257
|
},
|
|
262
258
|
{
|
|
263
|
-
name:
|
|
264
|
-
description:
|
|
259
|
+
name: 'send_agent_email_batch',
|
|
260
|
+
description: 'Queue up to 100 emails in one API request.',
|
|
265
261
|
schema: BatchEmailSchema,
|
|
266
262
|
invoke: this.sendEmailBatch.bind(this),
|
|
267
263
|
},
|
|
268
264
|
{
|
|
269
|
-
name:
|
|
270
|
-
description:
|
|
265
|
+
name: 'get_agent_email_usage',
|
|
266
|
+
description: 'Get combined monthly sent and received email usage.',
|
|
271
267
|
schema: EmailUsageSchema,
|
|
272
268
|
invoke: this.emailUsage.bind(this),
|
|
273
269
|
},
|
|
274
270
|
{
|
|
275
|
-
name:
|
|
276
|
-
description:
|
|
271
|
+
name: 'configure_email_webhook',
|
|
272
|
+
description: 'Configure signed inbound email events for this agent.',
|
|
277
273
|
schema: EmailWebhookSchema,
|
|
278
274
|
invoke: this.configureEmailWebhook.bind(this),
|
|
279
275
|
},
|
|
280
276
|
{
|
|
281
|
-
name:
|
|
282
|
-
description:
|
|
277
|
+
name: 'get_renewal_status',
|
|
278
|
+
description: 'Get exact next renewal amount, shortfall, vault balance, expiry date, and auto-renew state for an AgentDomain identity.',
|
|
283
279
|
schema: RenewalStatusSchema,
|
|
284
280
|
invoke: this.renewalStatus.bind(this),
|
|
285
281
|
},
|
|
286
282
|
{
|
|
287
|
-
name:
|
|
288
|
-
description:
|
|
283
|
+
name: 'fund_renewal_vault',
|
|
284
|
+
description: 'Deposit USDC from the connected wallet into one AgentID renewal vault. Anyone can fund; only the AgentID owner can withdraw or enable auto-renew. Call get_renewal_status first and usually deposit the returned shortfall.',
|
|
289
285
|
schema: FundRenewalSchema,
|
|
290
286
|
invoke: this.fundRenewal.bind(this),
|
|
291
287
|
},
|
|
292
288
|
{
|
|
293
|
-
name:
|
|
294
|
-
description:
|
|
289
|
+
name: 'enable_auto_renew',
|
|
290
|
+
description: 'Enable RenewalVault auto-renew. Requires the wallet provider to be the AgentID NFT owner and support sendTransaction.',
|
|
295
291
|
schema: EnableAutoRenewSchema,
|
|
296
292
|
invoke: this.enableAutoRenew.bind(this),
|
|
297
293
|
},
|
|
298
294
|
{
|
|
299
|
-
name:
|
|
300
|
-
description:
|
|
295
|
+
name: 'reconfigure_ssl',
|
|
296
|
+
description: 'Rebuild the Cloudflare SaaS SSL hostname and sync the required Spaceship DNS validation records for an existing agent.',
|
|
301
297
|
schema: SslReconfigureSchema,
|
|
302
298
|
invoke: this.reconfigureSsl.bind(this),
|
|
303
299
|
},
|
|
304
300
|
{
|
|
305
|
-
name:
|
|
306
|
-
description:
|
|
301
|
+
name: 'get_dns_capabilities',
|
|
302
|
+
description: 'Get machine-readable DNS types, fields, limits, and provider constraints.',
|
|
307
303
|
schema: ListDnsSchema,
|
|
308
304
|
invoke: this.getDnsCapabilities.bind(this),
|
|
309
305
|
},
|
|
310
306
|
{
|
|
311
|
-
name:
|
|
312
|
-
description:
|
|
307
|
+
name: 'list_dns_records',
|
|
308
|
+
description: 'List DNS records for an AgentDomain identity.',
|
|
313
309
|
schema: ListDnsSchema,
|
|
314
310
|
invoke: this.listDns.bind(this),
|
|
315
311
|
},
|
|
316
312
|
{
|
|
317
|
-
name:
|
|
318
|
-
description:
|
|
313
|
+
name: 'create_dns_record',
|
|
314
|
+
description: 'Create a user-managed DNS record and sync it to the domain provider.',
|
|
319
315
|
schema: CreateDnsSchema,
|
|
320
316
|
invoke: this.createDns.bind(this),
|
|
321
317
|
},
|
|
322
318
|
{
|
|
323
|
-
name:
|
|
324
|
-
description:
|
|
319
|
+
name: 'update_dns_record',
|
|
320
|
+
description: 'Update a user-managed DNS record and sync it to the domain provider.',
|
|
325
321
|
schema: UpdateDnsSchema,
|
|
326
322
|
invoke: this.updateDns.bind(this),
|
|
327
323
|
},
|
|
328
324
|
{
|
|
329
|
-
name:
|
|
330
|
-
description:
|
|
325
|
+
name: 'delete_dns_record',
|
|
326
|
+
description: 'Delete a user-managed DNS record and sync the domain provider state.',
|
|
331
327
|
schema: DeleteDnsSchema,
|
|
332
328
|
invoke: this.deleteDns.bind(this),
|
|
333
329
|
},
|
|
334
330
|
{
|
|
335
|
-
name:
|
|
336
|
-
description:
|
|
331
|
+
name: 'change_dns_records',
|
|
332
|
+
description: 'Preview or apply a revision-protected DNS batch in merge or replace mode.',
|
|
337
333
|
schema: ChangeDnsSchema,
|
|
338
334
|
invoke: this.changeDns.bind(this),
|
|
339
335
|
},
|
|
340
336
|
{
|
|
341
|
-
name:
|
|
342
|
-
description:
|
|
337
|
+
name: 'import_dns_zone',
|
|
338
|
+
description: 'Preview or apply a validated BIND zone import without deleting system-managed records.',
|
|
343
339
|
schema: ImportDnsSchema,
|
|
344
340
|
invoke: this.importDns.bind(this),
|
|
345
341
|
},
|
|
346
342
|
{
|
|
347
|
-
name:
|
|
348
|
-
description:
|
|
343
|
+
name: 'export_dns_zone',
|
|
344
|
+
description: 'Export user or permitted complete DNS state as a BIND zone file.',
|
|
349
345
|
schema: ExportDnsSchema,
|
|
350
346
|
invoke: this.exportDns.bind(this),
|
|
351
347
|
},
|
|
352
348
|
{
|
|
353
|
-
name:
|
|
354
|
-
description:
|
|
349
|
+
name: 'withdraw_renewal_vault',
|
|
350
|
+
description: 'Withdraw unused USDC from an AgentID renewal vault. Requires the AgentID NFT owner wallet.',
|
|
355
351
|
schema: WithdrawRenewalSchema,
|
|
356
352
|
invoke: this.withdrawRenewal.bind(this),
|
|
357
353
|
},
|
|
358
354
|
{
|
|
359
|
-
name:
|
|
360
|
-
description:
|
|
355
|
+
name: 'get_service_plan',
|
|
356
|
+
description: 'Get the current per-agent Premium Plan, limits, and billing state.',
|
|
361
357
|
schema: ServicePlanStatusSchema,
|
|
362
358
|
invoke: this.getServicePlan.bind(this),
|
|
363
359
|
},
|
|
364
360
|
{
|
|
365
|
-
name:
|
|
366
|
-
description:
|
|
361
|
+
name: 'purchase_service_plan',
|
|
362
|
+
description: 'Upgrade one agent to an AgentDomain Starter, Pro, or Enterprise Premium Plan using x402 USDC payment.',
|
|
367
363
|
schema: PurchaseServicePlanSchema,
|
|
368
364
|
invoke: this.purchaseServicePlan.bind(this),
|
|
369
365
|
},
|
|
370
366
|
{
|
|
371
|
-
name:
|
|
372
|
-
description:
|
|
367
|
+
name: 'set_registry_visibility',
|
|
368
|
+
description: 'Hide or show one agent in the public AgentDomain registry. Hiding requires an active paid Premium Plan.',
|
|
373
369
|
schema: SetRegistryVisibilitySchema,
|
|
374
370
|
invoke: this.setRegistryVisibility.bind(this),
|
|
375
371
|
},
|
|
376
372
|
{
|
|
377
|
-
name:
|
|
378
|
-
description:
|
|
373
|
+
name: 'schedule_service_plan_renewal',
|
|
374
|
+
description: 'Choose the exact Premium Plan SKU for the next identity renewal, including Enterprise tiers.',
|
|
379
375
|
schema: ScheduleServicePlanRenewalSchema,
|
|
380
376
|
invoke: this.scheduleServicePlanRenewal.bind(this),
|
|
381
377
|
},
|
|
382
378
|
{
|
|
383
|
-
name:
|
|
384
|
-
description:
|
|
379
|
+
name: 'update_primary_email',
|
|
380
|
+
description: 'Change one agent primary email username. The old primary address stops receiving new mail.',
|
|
385
381
|
schema: UpdatePrimaryEmailSchema,
|
|
386
382
|
invoke: this.updatePrimaryEmail.bind(this),
|
|
387
383
|
},
|
|
388
384
|
{
|
|
389
|
-
name:
|
|
390
|
-
description:
|
|
385
|
+
name: 'create_email_alias',
|
|
386
|
+
description: 'Create an extra receive-and-send alias for one agent. Requires available paid-plan alias capacity.',
|
|
391
387
|
schema: CreateEmailAliasSchema,
|
|
392
388
|
invoke: this.createEmailAlias.bind(this),
|
|
393
389
|
},
|
|
394
390
|
{
|
|
395
|
-
name:
|
|
396
|
-
description:
|
|
391
|
+
name: 'delete_email_alias',
|
|
392
|
+
description: 'Delete one active email alias from an agent.',
|
|
397
393
|
schema: DeleteEmailAliasSchema,
|
|
398
394
|
invoke: this.deleteEmailAlias.bind(this),
|
|
399
395
|
},
|
|
400
396
|
];
|
|
401
397
|
}
|
|
402
398
|
async register(walletProvider, args) {
|
|
403
|
-
const { ad, wallet } = this.createAgentDomain(walletProvider);
|
|
404
|
-
const result = await ad.register({
|
|
405
|
-
|
|
406
|
-
emailEnabled: true,
|
|
407
|
-
wallet,
|
|
408
|
-
});
|
|
409
|
-
let autoRenewMsg = "";
|
|
399
|
+
const { ad, wallet, publicClient } = this.createAgentDomain(walletProvider);
|
|
400
|
+
const result = await ad.register({ ...args, emailEnabled: true, wallet });
|
|
401
|
+
let autoRenewMsg = '';
|
|
410
402
|
if (args.autoRenew && this.renewalVaultAddress) {
|
|
411
403
|
try {
|
|
412
404
|
if (walletProvider.sendTransaction) {
|
|
413
|
-
const data =
|
|
414
|
-
abi: [
|
|
415
|
-
{
|
|
416
|
-
type: "function",
|
|
417
|
-
name: "setAutoRenew",
|
|
418
|
-
inputs: [
|
|
419
|
-
{ name: "tokenId", type: "uint256" },
|
|
420
|
-
{ name: "enabled", type: "bool" },
|
|
421
|
-
],
|
|
422
|
-
},
|
|
423
|
-
],
|
|
424
|
-
functionName: "setAutoRenew",
|
|
425
|
-
args: [BigInt(result.nftTokenId), true],
|
|
426
|
-
});
|
|
405
|
+
const data = encodeSetAutoRenewCalldata(BigInt(result.nftTokenId), true, this.requireBuilderCode('Registration auto-renew'));
|
|
427
406
|
const txHash = await walletProvider.sendTransaction({
|
|
428
407
|
to: this.renewalVaultAddress,
|
|
429
408
|
data,
|
|
430
409
|
});
|
|
410
|
+
let receipt;
|
|
411
|
+
try {
|
|
412
|
+
receipt = await publicClient.waitForTransactionReceipt({
|
|
413
|
+
hash: txHash,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
catch (e) {
|
|
417
|
+
throw new Error(`Auto-renew transaction ${txHash} was submitted but confirmation failed or remained pending: ${String(e)}`);
|
|
418
|
+
}
|
|
419
|
+
if (receipt.status !== 'success') {
|
|
420
|
+
throw new Error(`Auto-renew transaction ${txHash} confirmed with status ${receipt.status}; auto-renew was not enabled.`);
|
|
421
|
+
}
|
|
431
422
|
autoRenewMsg = ` Auto-renew enabled via tx ${txHash}.`;
|
|
432
423
|
}
|
|
433
424
|
else {
|
|
434
425
|
autoRenewMsg =
|
|
435
|
-
|
|
426
|
+
' (Cannot enable auto-renew because walletProvider lacks sendTransaction).';
|
|
436
427
|
}
|
|
437
428
|
}
|
|
438
429
|
catch (e) {
|
|
@@ -444,7 +435,7 @@ export class AgentDomainActionProvider {
|
|
|
444
435
|
async renewalStatus(walletProvider, args) {
|
|
445
436
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
446
437
|
const status = await ad.getRenewalStatus(args.agentId);
|
|
447
|
-
return `Renewal status for ${status.domain}: next renewal $${status.nextRenewalAmountUsdc}, vault balance $${status.vaultBalanceUsdc}, shortfall $${status.shortfallUsdc}, expires ${status.expiresAt ??
|
|
438
|
+
return `Renewal status for ${status.domain}: next renewal $${status.nextRenewalAmountUsdc}, vault balance $${status.vaultBalanceUsdc}, shortfall $${status.shortfallUsdc}, expires ${status.expiresAt ?? 'unknown'}, renewable from ${status.renewableFrom ?? 'unknown'}, auto-renew ${status.autoRenewEnabled ? 'enabled' : 'off'}.`;
|
|
448
439
|
}
|
|
449
440
|
async fundRenewal(walletProvider, args) {
|
|
450
441
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
@@ -457,38 +448,30 @@ export class AgentDomainActionProvider {
|
|
|
457
448
|
}
|
|
458
449
|
async enableAutoRenew(walletProvider, args) {
|
|
459
450
|
if (!this.renewalVaultAddress) {
|
|
460
|
-
throw new Error(
|
|
451
|
+
throw new Error('renewalVaultAddress is required to enable auto-renew.');
|
|
461
452
|
}
|
|
462
453
|
if (!walletProvider.sendTransaction) {
|
|
463
|
-
throw new Error(
|
|
454
|
+
throw new Error('walletProvider.sendTransaction is required to enable auto-renew.');
|
|
464
455
|
}
|
|
465
456
|
const { ad, wallet } = this.createAgentDomain(walletProvider);
|
|
466
457
|
const status = await ad.getRenewalStatus(args.agentId);
|
|
467
458
|
if (!status.tokenId)
|
|
468
|
-
throw new Error(
|
|
469
|
-
if (status.ownerAddress &&
|
|
470
|
-
status.ownerAddress.toLowerCase() !== wallet.toLowerCase()) {
|
|
459
|
+
throw new Error('AgentID NFT is not minted yet.');
|
|
460
|
+
if (status.ownerAddress && status.ownerAddress.toLowerCase() !== wallet.toLowerCase()) {
|
|
471
461
|
throw new Error(`Only the AgentID NFT owner (${status.ownerAddress}) can enable auto-renew.`);
|
|
472
462
|
}
|
|
473
|
-
const data =
|
|
474
|
-
abi: [
|
|
475
|
-
{
|
|
476
|
-
type: "function",
|
|
477
|
-
name: "setAutoRenew",
|
|
478
|
-
inputs: [
|
|
479
|
-
{ name: "tokenId", type: "uint256" },
|
|
480
|
-
{ name: "enabled", type: "bool" },
|
|
481
|
-
],
|
|
482
|
-
},
|
|
483
|
-
],
|
|
484
|
-
functionName: "setAutoRenew",
|
|
485
|
-
args: [BigInt(status.tokenId), true],
|
|
486
|
-
});
|
|
463
|
+
const data = encodeSetAutoRenewCalldata(BigInt(status.tokenId), true, this.requireBuilderCode('Auto-renew'));
|
|
487
464
|
const txHash = await walletProvider.sendTransaction({
|
|
488
465
|
to: this.renewalVaultAddress,
|
|
489
466
|
data,
|
|
490
467
|
});
|
|
491
|
-
return `Auto-renew
|
|
468
|
+
return `Auto-renew transaction submitted via tx ${txHash}.`;
|
|
469
|
+
}
|
|
470
|
+
requireBuilderCode(operation) {
|
|
471
|
+
if (!this.builderCode) {
|
|
472
|
+
throw new Error(`${operation} requires builderCode in AgentDomainActionProvider options so the direct Base transaction is attributed.`);
|
|
473
|
+
}
|
|
474
|
+
return this.builderCode;
|
|
492
475
|
}
|
|
493
476
|
async reconfigureSsl(walletProvider, args) {
|
|
494
477
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
@@ -541,7 +524,7 @@ export class AgentDomainActionProvider {
|
|
|
541
524
|
}
|
|
542
525
|
async withdrawRenewal(walletProvider, args) {
|
|
543
526
|
if (!walletProvider.sendTransaction) {
|
|
544
|
-
throw new Error(
|
|
527
|
+
throw new Error('walletProvider.sendTransaction is required to withdraw vault funds.');
|
|
545
528
|
}
|
|
546
529
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
547
530
|
const tx = await ad.withdrawFromVault(args.agentId, args.amountUsdc);
|
|
@@ -561,12 +544,12 @@ export class AgentDomainActionProvider {
|
|
|
561
544
|
async purchaseServicePlan(walletProvider, args) {
|
|
562
545
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
563
546
|
const result = await ad.purchaseServicePlan(args);
|
|
564
|
-
return `Purchased ${result.entitlement.plan} Premium Plan for ${result.domain}. Current period ends ${result.entitlement.currentPeriodEnd ??
|
|
547
|
+
return `Purchased ${result.entitlement.plan} Premium Plan for ${result.domain}. Current period ends ${result.entitlement.currentPeriodEnd ?? 'unknown'}.`;
|
|
565
548
|
}
|
|
566
549
|
async setRegistryVisibility(walletProvider, args) {
|
|
567
550
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
568
551
|
const result = await ad.setRegistryVisibility(args.agentId, args.registryHidden);
|
|
569
|
-
return `${result.domain} is now ${result.registryVisibility.hidden ?
|
|
552
|
+
return `${result.domain} is now ${result.registryVisibility.hidden ? 'hidden from' : 'visible in'} the public registry.`;
|
|
570
553
|
}
|
|
571
554
|
async scheduleServicePlanRenewal(walletProvider, args) {
|
|
572
555
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
@@ -576,13 +559,11 @@ export class AgentDomainActionProvider {
|
|
|
576
559
|
async quote(walletProvider, args) {
|
|
577
560
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
578
561
|
const q = await ad.quote(args);
|
|
579
|
-
const basenamePart = Number(q.basenameCostUsdc) > 0
|
|
580
|
-
|
|
581
|
-
: "";
|
|
582
|
-
const ensPart = Number(q.ensCostUsdc) > 0 ? ` + ENS $${q.ensCostUsdc}` : "";
|
|
562
|
+
const basenamePart = Number(q.basenameCostUsdc) > 0 ? ` + Basename $${q.basenameCostUsdc}` : '';
|
|
563
|
+
const ensPart = Number(q.ensCostUsdc) > 0 ? ` + ENS $${q.ensCostUsdc}` : '';
|
|
583
564
|
const planPart = Number(q.premiumPlanFeeUsdc ?? 0) > 0
|
|
584
565
|
? ` + ${q.premiumPlanLabel} $${q.premiumPlanFeeUsdc}`
|
|
585
|
-
:
|
|
566
|
+
: '';
|
|
586
567
|
return `Total: $${q.totalUsdc} USDC (domain $${q.domainCostUsdc} + platform $${q.platformFeeUsdc ?? q.serviceFeeUsdc}, email and SSL included${basenamePart}${ensPart}${planPart})`;
|
|
587
568
|
}
|
|
588
569
|
async search(walletProvider, args) {
|
|
@@ -590,7 +571,7 @@ export class AgentDomainActionProvider {
|
|
|
590
571
|
const result = await ad.search(args);
|
|
591
572
|
return `Found ${result.total} agents. First ${result.items.length}: ${result.items
|
|
592
573
|
.map((a) => a.domain)
|
|
593
|
-
.join(
|
|
574
|
+
.join(', ')}`;
|
|
594
575
|
}
|
|
595
576
|
async sendEmail(walletProvider, args) {
|
|
596
577
|
const { ad } = this.createAgentDomain(walletProvider);
|
|
@@ -645,7 +626,7 @@ export class AgentDomainActionProvider {
|
|
|
645
626
|
}
|
|
646
627
|
function requireDnsRevision(value) {
|
|
647
628
|
if (!value)
|
|
648
|
-
throw new Error(
|
|
629
|
+
throw new Error('Apply requires baseRevision from a fresh DNS dry-run preview.');
|
|
649
630
|
return value;
|
|
650
631
|
}
|
|
651
632
|
export default AgentDomainActionProvider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentdomain/agentkit-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Coinbase AgentKit action provider for AgentDomain",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/0xmdrakib/AgentDomain.git",
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
20
|
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"NOTICE",
|
|
21
23
|
"package.json"
|
|
22
24
|
],
|
|
23
25
|
"publishConfig": {
|
|
@@ -26,8 +28,8 @@
|
|
|
26
28
|
"dependencies": {
|
|
27
29
|
"viem": "^2.55.2",
|
|
28
30
|
"zod": "^3.24.1",
|
|
29
|
-
"@agentdomain/
|
|
30
|
-
"@agentdomain/
|
|
31
|
+
"@agentdomain/shared": "^0.7.0",
|
|
32
|
+
"@agentdomain/sdk": "^0.7.0"
|
|
31
33
|
},
|
|
32
34
|
"peerDependencies": {
|
|
33
35
|
"@coinbase/agentkit": "^0.1.0"
|
|
@@ -37,6 +39,7 @@
|
|
|
37
39
|
},
|
|
38
40
|
"scripts": {
|
|
39
41
|
"build": "tsc",
|
|
42
|
+
"test": "pnpm --filter @agentdomain/sdk build && pnpm run build && node --test test/*.test.mjs",
|
|
40
43
|
"typecheck": "tsc --noEmit",
|
|
41
44
|
"lint": "echo \"no lint\""
|
|
42
45
|
}
|