@agentdomain/sdk 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 +43 -30
- package/dist/index.d.ts +39 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +556 -602
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -1,33 +1,70 @@
|
|
|
1
|
-
import { keccak256, toHex, getAddress, } from
|
|
2
|
-
import { base, baseSepolia } from
|
|
3
|
-
import { x402Client, x402HTTPClient } from
|
|
4
|
-
import { registerExactEvmScheme } from
|
|
5
|
-
import {
|
|
1
|
+
import { keccak256, toHex, getAddress, concatHex, encodeFunctionData, } from 'viem';
|
|
2
|
+
import { base, baseSepolia } from 'viem/chains';
|
|
3
|
+
import { x402Client, x402HTTPClient } from '@x402/core/client';
|
|
4
|
+
import { registerExactEvmScheme } from '@x402/evm/exact/client';
|
|
5
|
+
import { BUILDER_CODE_PATTERN, encodeBuilderCodeSuffix, parseBuilderCodeSuffixFromCalldata, } from '@x402/extensions/builder-code';
|
|
6
|
+
import { AGENTDOMAIN_API_BASE_URL, X402_NETWORK } from '@agentdomain/shared/constants';
|
|
6
7
|
const EIP3009_TYPES = {
|
|
7
8
|
TransferWithAuthorization: [
|
|
8
|
-
{ name:
|
|
9
|
-
{ name:
|
|
10
|
-
{ name:
|
|
11
|
-
{ name:
|
|
12
|
-
{ name:
|
|
13
|
-
{ name:
|
|
9
|
+
{ name: 'from', type: 'address' },
|
|
10
|
+
{ name: 'to', type: 'address' },
|
|
11
|
+
{ name: 'value', type: 'uint256' },
|
|
12
|
+
{ name: 'validAfter', type: 'uint256' },
|
|
13
|
+
{ name: 'validBefore', type: 'uint256' },
|
|
14
|
+
{ name: 'nonce', type: 'bytes32' },
|
|
14
15
|
],
|
|
15
16
|
};
|
|
16
17
|
const RENEWAL_VAULT_ABI = [
|
|
17
18
|
{
|
|
18
|
-
type:
|
|
19
|
-
name:
|
|
20
|
-
stateMutability:
|
|
19
|
+
type: 'function',
|
|
20
|
+
name: 'setAutoRenew',
|
|
21
|
+
stateMutability: 'nonpayable',
|
|
21
22
|
inputs: [
|
|
22
|
-
{ name:
|
|
23
|
-
{ name:
|
|
23
|
+
{ name: 'tokenId', type: 'uint256' },
|
|
24
|
+
{ name: 'enabled', type: 'bool' },
|
|
24
25
|
],
|
|
25
26
|
outputs: [],
|
|
26
27
|
},
|
|
27
28
|
];
|
|
29
|
+
/**
|
|
30
|
+
* Validates a public ERC-8021 builder code without normalizing configuration mistakes.
|
|
31
|
+
*/
|
|
32
|
+
export function validateBuilderCode(builderCode) {
|
|
33
|
+
if (!BUILDER_CODE_PATTERN.test(builderCode)) {
|
|
34
|
+
throw new Error('builderCode must contain 1-32 lowercase letters, numbers, or underscores.');
|
|
35
|
+
}
|
|
36
|
+
return builderCode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Appends one validated ERC-8021 Schema 2 app attribution suffix to EVM calldata.
|
|
40
|
+
* Existing matching attribution is preserved; conflicting attribution is rejected.
|
|
41
|
+
*/
|
|
42
|
+
export function appendBuilderCodeAttribution(data, builderCode) {
|
|
43
|
+
const validated = validateBuilderCode(builderCode);
|
|
44
|
+
const existing = parseBuilderCodeSuffixFromCalldata(data);
|
|
45
|
+
if (existing) {
|
|
46
|
+
if (existing.a === validated)
|
|
47
|
+
return data;
|
|
48
|
+
throw new Error('Transaction calldata already contains different builder-code attribution.');
|
|
49
|
+
}
|
|
50
|
+
return concatHex([data, encodeBuilderCodeSuffix({ a: validated })]);
|
|
51
|
+
}
|
|
52
|
+
/** Decodes an ERC-8021 builder-code suffix from complete transaction calldata. */
|
|
53
|
+
export function parseBuilderCodeAttribution(data) {
|
|
54
|
+
return parseBuilderCodeSuffixFromCalldata(data);
|
|
55
|
+
}
|
|
56
|
+
/** Builds the exact attributed calldata used for RenewalVault auto-renew writes. */
|
|
57
|
+
export function encodeSetAutoRenewCalldata(tokenId, enabled, builderCode) {
|
|
58
|
+
const data = encodeFunctionData({
|
|
59
|
+
abi: RENEWAL_VAULT_ABI,
|
|
60
|
+
functionName: 'setAutoRenew',
|
|
61
|
+
args: [tokenId, enabled],
|
|
62
|
+
});
|
|
63
|
+
return appendBuilderCodeAttribution(data, builderCode);
|
|
64
|
+
}
|
|
28
65
|
export async function createX402PaymentHeaders(response, walletClient) {
|
|
29
66
|
if (!walletClient.account) {
|
|
30
|
-
throw new Error(
|
|
67
|
+
throw new Error('A connected wallet account is required for x402 payment.');
|
|
31
68
|
}
|
|
32
69
|
const signer = {
|
|
33
70
|
address: walletClient.account.address,
|
|
@@ -51,12 +88,60 @@ export async function createX402PaymentHeaders(response, walletClient) {
|
|
|
51
88
|
throw new Error(`AgentDomain requires x402 v2; server returned v${paymentRequired.x402Version}.`);
|
|
52
89
|
}
|
|
53
90
|
const payload = await httpClient.createPaymentPayload(paymentRequired);
|
|
91
|
+
const requestBinding = payload.accepted.extra?.requestBinding;
|
|
92
|
+
if (requestBinding !== undefined) {
|
|
93
|
+
if (typeof requestBinding !== 'string' || !/^0x[a-fA-F0-9]{64}$/.test(requestBinding)) {
|
|
94
|
+
throw new Error('Server returned an invalid x402 request binding.');
|
|
95
|
+
}
|
|
96
|
+
const authorization = payload.payload.authorization;
|
|
97
|
+
if (!authorization?.from ||
|
|
98
|
+
!authorization.to ||
|
|
99
|
+
!authorization.value ||
|
|
100
|
+
!authorization.validAfter ||
|
|
101
|
+
!authorization.validBefore) {
|
|
102
|
+
throw new Error('AgentDomain request binding requires an EIP-3009 x402 authorization.');
|
|
103
|
+
}
|
|
104
|
+
const boundAuthorization = {
|
|
105
|
+
...authorization,
|
|
106
|
+
from: getAddress(authorization.from),
|
|
107
|
+
to: getAddress(authorization.to),
|
|
108
|
+
value: authorization.value,
|
|
109
|
+
validAfter: authorization.validAfter,
|
|
110
|
+
validBefore: authorization.validBefore,
|
|
111
|
+
nonce: requestBinding,
|
|
112
|
+
};
|
|
113
|
+
const signature = await walletClient.signTypedData({
|
|
114
|
+
account: walletClient.account,
|
|
115
|
+
domain: {
|
|
116
|
+
name: String(payload.accepted.extra?.name ?? ''),
|
|
117
|
+
version: String(payload.accepted.extra?.version ?? ''),
|
|
118
|
+
chainId: Number(X402_NETWORK.split(':')[1]),
|
|
119
|
+
verifyingContract: getAddress(payload.accepted.asset),
|
|
120
|
+
},
|
|
121
|
+
types: EIP3009_TYPES,
|
|
122
|
+
primaryType: 'TransferWithAuthorization',
|
|
123
|
+
message: {
|
|
124
|
+
from: boundAuthorization.from,
|
|
125
|
+
to: boundAuthorization.to,
|
|
126
|
+
value: BigInt(authorization.value),
|
|
127
|
+
validAfter: BigInt(authorization.validAfter),
|
|
128
|
+
validBefore: BigInt(authorization.validBefore),
|
|
129
|
+
nonce: boundAuthorization.nonce,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
payload.payload = {
|
|
133
|
+
...payload.payload,
|
|
134
|
+
authorization: boundAuthorization,
|
|
135
|
+
signature,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
54
138
|
return httpClient.encodePaymentSignatureHeader(payload);
|
|
55
139
|
}
|
|
56
140
|
export class AgentDomain {
|
|
57
141
|
apiUrl;
|
|
58
142
|
apiKey;
|
|
59
143
|
renewalVaultAddress;
|
|
144
|
+
builderCode;
|
|
60
145
|
walletClient;
|
|
61
146
|
publicClient;
|
|
62
147
|
network;
|
|
@@ -65,8 +150,15 @@ export class AgentDomain {
|
|
|
65
150
|
this.apiKey = opts?.apiKey;
|
|
66
151
|
this.walletClient = opts?.walletClient;
|
|
67
152
|
this.publicClient = opts?.publicClient;
|
|
68
|
-
this.network = opts?.network ??
|
|
153
|
+
this.network = opts?.network ?? 'base';
|
|
69
154
|
this.renewalVaultAddress = opts?.renewalVaultAddress;
|
|
155
|
+
this.builderCode = opts?.builderCode;
|
|
156
|
+
}
|
|
157
|
+
requireBuilderCode(operation) {
|
|
158
|
+
if (!this.builderCode) {
|
|
159
|
+
throw new Error(`${operation} requires builderCode in the AgentDomain constructor so the direct Base transaction is attributed.`);
|
|
160
|
+
}
|
|
161
|
+
return validateBuilderCode(this.builderCode);
|
|
70
162
|
}
|
|
71
163
|
async checkAvailability(name, opts) {
|
|
72
164
|
const url = `${this.apiUrl}/domains/availability?name=${encodeURIComponent(name)}&tld=${encodeURIComponent(opts.tld)}`;
|
|
@@ -77,26 +169,26 @@ export class AgentDomain {
|
|
|
77
169
|
}
|
|
78
170
|
async quote(args) {
|
|
79
171
|
const params = new URLSearchParams();
|
|
80
|
-
params.set(
|
|
81
|
-
params.set(
|
|
172
|
+
params.set('preferredName', args.preferredName);
|
|
173
|
+
params.set('tld', args.tld);
|
|
82
174
|
if (args.registerBasename !== undefined)
|
|
83
|
-
params.set(
|
|
175
|
+
params.set('registerBasename', String(args.registerBasename));
|
|
84
176
|
if (args.basenameLabel)
|
|
85
|
-
params.set(
|
|
177
|
+
params.set('basenameLabel', args.basenameLabel);
|
|
86
178
|
if (args.registerEns !== undefined)
|
|
87
|
-
params.set(
|
|
179
|
+
params.set('registerEns', String(args.registerEns));
|
|
88
180
|
if (args.ensLabel)
|
|
89
|
-
params.set(
|
|
181
|
+
params.set('ensLabel', args.ensLabel);
|
|
90
182
|
if (args.emailEnabled !== undefined)
|
|
91
|
-
params.set(
|
|
183
|
+
params.set('emailEnabled', String(args.emailEnabled));
|
|
92
184
|
if (args.emailUsername)
|
|
93
|
-
params.set(
|
|
185
|
+
params.set('emailUsername', args.emailUsername);
|
|
94
186
|
if (args.premiumPlan)
|
|
95
|
-
params.set(
|
|
187
|
+
params.set('premiumPlan', args.premiumPlan);
|
|
96
188
|
if (args.premiumPlanSku)
|
|
97
|
-
params.set(
|
|
189
|
+
params.set('premiumPlanSku', args.premiumPlanSku);
|
|
98
190
|
if (args.years)
|
|
99
|
-
params.set(
|
|
191
|
+
params.set('years', String(args.years));
|
|
100
192
|
const url = `${this.apiUrl}/agents/quote?${params.toString()}`;
|
|
101
193
|
const res = await fetch(url);
|
|
102
194
|
if (!res.ok)
|
|
@@ -104,48 +196,47 @@ export class AgentDomain {
|
|
|
104
196
|
return res.json();
|
|
105
197
|
}
|
|
106
198
|
async register(args) {
|
|
107
|
-
const walletAddress = (args.wallet ||
|
|
108
|
-
this.walletClient?.account?.address);
|
|
199
|
+
const walletAddress = (args.wallet || this.walletClient?.account?.address);
|
|
109
200
|
if (!walletAddress) {
|
|
110
|
-
throw new Error(
|
|
201
|
+
throw new Error('Registration requires a wallet address. Pass args.wallet or provide a walletClient with an account.');
|
|
111
202
|
}
|
|
112
203
|
const url = `${this.apiUrl}/agents/register`;
|
|
113
204
|
const body = JSON.stringify({
|
|
114
205
|
...args,
|
|
115
206
|
wallet: walletAddress,
|
|
116
|
-
tld: args.tld ??
|
|
207
|
+
tld: args.tld ?? 'xyz',
|
|
117
208
|
registerBasename: args.registerBasename ?? true,
|
|
118
209
|
registerEns: args.registerEns ?? false,
|
|
119
210
|
emailEnabled: true,
|
|
120
|
-
emailUsername: args.emailUsername ??
|
|
121
|
-
premiumPlan: args.premiumPlan ??
|
|
211
|
+
emailUsername: args.emailUsername ?? 'agent',
|
|
212
|
+
premiumPlan: args.premiumPlan ?? 'included',
|
|
122
213
|
years: args.years ?? 1,
|
|
123
214
|
autoRenew: args.autoRenew ?? false,
|
|
124
215
|
});
|
|
125
216
|
let res = await fetch(url, {
|
|
126
|
-
method:
|
|
127
|
-
headers: await this.authHeaders({
|
|
217
|
+
method: 'POST',
|
|
218
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
128
219
|
body,
|
|
129
220
|
});
|
|
130
221
|
if (res.status === 402) {
|
|
131
222
|
if (!this.walletClient || !walletAddress) {
|
|
132
|
-
throw new Error(
|
|
223
|
+
throw new Error('Registration requires x402 payment. Provide a walletClient in AgentDomain constructor so the SDK can sign the USDC authorization.');
|
|
133
224
|
}
|
|
134
|
-
if (this.network !==
|
|
135
|
-
throw new Error(
|
|
225
|
+
if (this.network !== 'base') {
|
|
226
|
+
throw new Error('AgentDomain x402 payments are supported only on Base mainnet.');
|
|
136
227
|
}
|
|
137
228
|
const paymentHeaders = await createX402PaymentHeaders(res, this.walletClient);
|
|
138
229
|
res = await fetch(url, {
|
|
139
|
-
method:
|
|
230
|
+
method: 'POST',
|
|
140
231
|
headers: await this.authHeaders({
|
|
141
|
-
|
|
232
|
+
'Content-Type': 'application/json',
|
|
142
233
|
...paymentHeaders,
|
|
143
234
|
}),
|
|
144
235
|
body,
|
|
145
236
|
});
|
|
146
237
|
}
|
|
147
238
|
if (!res.ok) {
|
|
148
|
-
let detail =
|
|
239
|
+
let detail = '';
|
|
149
240
|
try {
|
|
150
241
|
const errBody = await res.json();
|
|
151
242
|
detail = `: ${errBody.message ?? JSON.stringify(errBody)}`;
|
|
@@ -158,7 +249,7 @@ export class AgentDomain {
|
|
|
158
249
|
return res.json();
|
|
159
250
|
}
|
|
160
251
|
async buildEip3009Authorization(requirement, from) {
|
|
161
|
-
const chain = this.network ===
|
|
252
|
+
const chain = this.network === 'base-sepolia' ? baseSepolia : base;
|
|
162
253
|
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
163
254
|
const validBefore = now + BigInt(requirement.maxTimeoutSeconds || 300);
|
|
164
255
|
const nonce = keccak256(toHex(`${from}:${Date.now()}:${Math.floor(Math.random() * 1e15)}`));
|
|
@@ -172,13 +263,13 @@ export class AgentDomain {
|
|
|
172
263
|
};
|
|
173
264
|
const signature = await this.walletClient.signTypedData({
|
|
174
265
|
domain: {
|
|
175
|
-
name:
|
|
176
|
-
version:
|
|
266
|
+
name: 'USD Coin',
|
|
267
|
+
version: '2',
|
|
177
268
|
chainId: requirement.chainId ?? chain.id,
|
|
178
269
|
verifyingContract: requirement.asset,
|
|
179
270
|
},
|
|
180
271
|
types: EIP3009_TYPES,
|
|
181
|
-
primaryType:
|
|
272
|
+
primaryType: 'TransferWithAuthorization',
|
|
182
273
|
message,
|
|
183
274
|
});
|
|
184
275
|
return {
|
|
@@ -187,7 +278,7 @@ export class AgentDomain {
|
|
|
187
278
|
from,
|
|
188
279
|
to: requirement.payTo,
|
|
189
280
|
value: requirement.maxAmountRequired,
|
|
190
|
-
validAfter:
|
|
281
|
+
validAfter: '0',
|
|
191
282
|
validBefore: validBefore.toString(),
|
|
192
283
|
nonce,
|
|
193
284
|
},
|
|
@@ -217,13 +308,13 @@ export class AgentDomain {
|
|
|
217
308
|
async search(args) {
|
|
218
309
|
const params = new URLSearchParams();
|
|
219
310
|
if (args.q)
|
|
220
|
-
params.set(
|
|
311
|
+
params.set('q', args.q);
|
|
221
312
|
if (args.framework)
|
|
222
|
-
params.set(
|
|
313
|
+
params.set('framework', args.framework);
|
|
223
314
|
if (args.capability)
|
|
224
|
-
params.set(
|
|
315
|
+
params.set('capability', args.capability);
|
|
225
316
|
if (args.limit)
|
|
226
|
-
params.set(
|
|
317
|
+
params.set('limit', String(args.limit));
|
|
227
318
|
const url = `${this.apiUrl}/agents/search?${params.toString()}`;
|
|
228
319
|
const res = await fetch(url);
|
|
229
320
|
if (!res.ok)
|
|
@@ -233,12 +324,10 @@ export class AgentDomain {
|
|
|
233
324
|
async sendEmail(agentId, args) {
|
|
234
325
|
const url = `${this.apiUrl}/agents/${agentId}/email/send`;
|
|
235
326
|
const res = await fetch(url, {
|
|
236
|
-
method:
|
|
327
|
+
method: 'POST',
|
|
237
328
|
headers: await this.authHeaders({
|
|
238
|
-
|
|
239
|
-
...(args.idempotencyKey
|
|
240
|
-
? { "Idempotency-Key": args.idempotencyKey }
|
|
241
|
-
: {}),
|
|
329
|
+
'Content-Type': 'application/json',
|
|
330
|
+
...(args.idempotencyKey ? { 'Idempotency-Key': args.idempotencyKey } : {}),
|
|
242
331
|
}),
|
|
243
332
|
body: JSON.stringify(args),
|
|
244
333
|
});
|
|
@@ -248,16 +337,14 @@ export class AgentDomain {
|
|
|
248
337
|
}
|
|
249
338
|
async sendEmailBatch(agentId, args) {
|
|
250
339
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/email/batch`, {
|
|
251
|
-
method:
|
|
340
|
+
method: 'POST',
|
|
252
341
|
headers: await this.authHeaders({
|
|
253
|
-
|
|
254
|
-
...(args.idempotencyKey
|
|
255
|
-
? { "Idempotency-Key": args.idempotencyKey }
|
|
256
|
-
: {}),
|
|
342
|
+
'Content-Type': 'application/json',
|
|
343
|
+
...(args.idempotencyKey ? { 'Idempotency-Key': args.idempotencyKey } : {}),
|
|
257
344
|
}),
|
|
258
345
|
body: JSON.stringify({
|
|
259
346
|
messages: args.messages,
|
|
260
|
-
validationMode: args.validationMode ??
|
|
347
|
+
validationMode: args.validationMode ?? 'strict',
|
|
261
348
|
}),
|
|
262
349
|
});
|
|
263
350
|
if (!res.ok)
|
|
@@ -282,8 +369,8 @@ export class AgentDomain {
|
|
|
282
369
|
}
|
|
283
370
|
async setEmailWebhook(agentId, args) {
|
|
284
371
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/email/webhook`, {
|
|
285
|
-
method:
|
|
286
|
-
headers: await this.authHeaders({
|
|
372
|
+
method: 'PUT',
|
|
373
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
287
374
|
body: JSON.stringify(args),
|
|
288
375
|
});
|
|
289
376
|
if (!res.ok)
|
|
@@ -292,7 +379,7 @@ export class AgentDomain {
|
|
|
292
379
|
}
|
|
293
380
|
async rotateEmailWebhookSecret(agentId) {
|
|
294
381
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/email/webhook`, {
|
|
295
|
-
method:
|
|
382
|
+
method: 'PATCH',
|
|
296
383
|
headers: await this.authHeaders(),
|
|
297
384
|
});
|
|
298
385
|
if (!res.ok)
|
|
@@ -301,8 +388,8 @@ export class AgentDomain {
|
|
|
301
388
|
}
|
|
302
389
|
async updatePrimaryEmail(agentId, username) {
|
|
303
390
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/email`, {
|
|
304
|
-
method:
|
|
305
|
-
headers: await this.authHeaders({
|
|
391
|
+
method: 'PATCH',
|
|
392
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
306
393
|
body: JSON.stringify({ username, confirmReplace: true }),
|
|
307
394
|
});
|
|
308
395
|
if (!res.ok)
|
|
@@ -311,8 +398,8 @@ export class AgentDomain {
|
|
|
311
398
|
}
|
|
312
399
|
async createEmailAlias(agentId, username) {
|
|
313
400
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/email/aliases`, {
|
|
314
|
-
method:
|
|
315
|
-
headers: await this.authHeaders({
|
|
401
|
+
method: 'POST',
|
|
402
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
316
403
|
body: JSON.stringify({ username }),
|
|
317
404
|
});
|
|
318
405
|
if (!res.ok)
|
|
@@ -322,7 +409,7 @@ export class AgentDomain {
|
|
|
322
409
|
async deleteEmailAlias(agentId, emailAddress) {
|
|
323
410
|
const params = new URLSearchParams({ emailAddress });
|
|
324
411
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/email/aliases?${params}`, {
|
|
325
|
-
method:
|
|
412
|
+
method: 'DELETE',
|
|
326
413
|
headers: await this.authHeaders(),
|
|
327
414
|
});
|
|
328
415
|
if (!res.ok)
|
|
@@ -332,9 +419,9 @@ export class AgentDomain {
|
|
|
332
419
|
async listEmail(agentId, args = {}) {
|
|
333
420
|
const params = new URLSearchParams();
|
|
334
421
|
if (args.limit)
|
|
335
|
-
params.set(
|
|
422
|
+
params.set('limit', String(args.limit));
|
|
336
423
|
if (args.unreadOnly)
|
|
337
|
-
params.set(
|
|
424
|
+
params.set('unreadOnly', 'true');
|
|
338
425
|
const url = `${this.apiUrl}/agents/${agentId}/email?${params.toString()}`;
|
|
339
426
|
const res = await fetch(url, { headers: await this.authHeaders() });
|
|
340
427
|
if (!res.ok)
|
|
@@ -343,7 +430,7 @@ export class AgentDomain {
|
|
|
343
430
|
}
|
|
344
431
|
async deleteEmailMessage(agentId, messageId) {
|
|
345
432
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/email/${messageId}`, {
|
|
346
|
-
method:
|
|
433
|
+
method: 'DELETE',
|
|
347
434
|
headers: await this.authHeaders(),
|
|
348
435
|
});
|
|
349
436
|
if (!res.ok)
|
|
@@ -368,8 +455,8 @@ export class AgentDomain {
|
|
|
368
455
|
}
|
|
369
456
|
async createDnsRecord(agentId, record) {
|
|
370
457
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/dns`, {
|
|
371
|
-
method:
|
|
372
|
-
headers: await this.authHeaders({
|
|
458
|
+
method: 'POST',
|
|
459
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
373
460
|
body: JSON.stringify(record),
|
|
374
461
|
});
|
|
375
462
|
if (!res.ok)
|
|
@@ -378,8 +465,8 @@ export class AgentDomain {
|
|
|
378
465
|
}
|
|
379
466
|
async updateDnsRecord(agentId, recordId, record) {
|
|
380
467
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/dns/${recordId}`, {
|
|
381
|
-
method:
|
|
382
|
-
headers: await this.authHeaders({
|
|
468
|
+
method: 'PATCH',
|
|
469
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
383
470
|
body: JSON.stringify(record),
|
|
384
471
|
});
|
|
385
472
|
if (!res.ok)
|
|
@@ -388,38 +475,28 @@ export class AgentDomain {
|
|
|
388
475
|
}
|
|
389
476
|
async deleteDnsRecord(agentId, recordId) {
|
|
390
477
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/dns/${recordId}`, {
|
|
391
|
-
method:
|
|
478
|
+
method: 'DELETE',
|
|
392
479
|
headers: await this.authHeaders(),
|
|
393
480
|
});
|
|
394
481
|
if (!res.ok)
|
|
395
482
|
throw new Error(await responseError(res));
|
|
396
483
|
return res.json();
|
|
397
484
|
}
|
|
398
|
-
async previewDnsBatch(agentId, records, mode =
|
|
485
|
+
async previewDnsBatch(agentId, records, mode = 'merge') {
|
|
399
486
|
return this.sendDnsBatch(agentId, { records, mode, dryRun: true });
|
|
400
487
|
}
|
|
401
|
-
async applyDnsBatch(agentId, records, baseRevision, mode =
|
|
488
|
+
async applyDnsBatch(agentId, records, baseRevision, mode = 'merge') {
|
|
402
489
|
assertDnsRevision(baseRevision);
|
|
403
|
-
return this.sendDnsBatch(agentId, {
|
|
404
|
-
records,
|
|
405
|
-
mode,
|
|
406
|
-
dryRun: false,
|
|
407
|
-
baseRevision,
|
|
408
|
-
});
|
|
490
|
+
return this.sendDnsBatch(agentId, { records, mode, dryRun: false, baseRevision });
|
|
409
491
|
}
|
|
410
|
-
async previewDnsImport(agentId, zoneFile, mode =
|
|
492
|
+
async previewDnsImport(agentId, zoneFile, mode = 'merge') {
|
|
411
493
|
return this.sendDnsImport(agentId, { zoneFile, mode, dryRun: true });
|
|
412
494
|
}
|
|
413
|
-
async applyDnsImport(agentId, zoneFile, baseRevision, mode =
|
|
495
|
+
async applyDnsImport(agentId, zoneFile, baseRevision, mode = 'merge') {
|
|
414
496
|
assertDnsRevision(baseRevision);
|
|
415
|
-
return this.sendDnsImport(agentId, {
|
|
416
|
-
zoneFile,
|
|
417
|
-
mode,
|
|
418
|
-
dryRun: false,
|
|
419
|
-
baseRevision,
|
|
420
|
-
});
|
|
497
|
+
return this.sendDnsImport(agentId, { zoneFile, mode, dryRun: false, baseRevision });
|
|
421
498
|
}
|
|
422
|
-
async exportDnsZone(agentId, scope =
|
|
499
|
+
async exportDnsZone(agentId, scope = 'user') {
|
|
423
500
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/dns/export?scope=${scope}`, {
|
|
424
501
|
headers: await this.authHeaders(),
|
|
425
502
|
});
|
|
@@ -429,8 +506,8 @@ export class AgentDomain {
|
|
|
429
506
|
}
|
|
430
507
|
async sendDnsBatch(agentId, payload) {
|
|
431
508
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/dns/batch`, {
|
|
432
|
-
method:
|
|
433
|
-
headers: await this.authHeaders({
|
|
509
|
+
method: 'POST',
|
|
510
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
434
511
|
body: JSON.stringify(payload),
|
|
435
512
|
});
|
|
436
513
|
if (!res.ok)
|
|
@@ -439,8 +516,8 @@ export class AgentDomain {
|
|
|
439
516
|
}
|
|
440
517
|
async sendDnsImport(agentId, payload) {
|
|
441
518
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/dns/import`, {
|
|
442
|
-
method:
|
|
443
|
-
headers: await this.authHeaders({
|
|
519
|
+
method: 'POST',
|
|
520
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
444
521
|
body: JSON.stringify(payload),
|
|
445
522
|
});
|
|
446
523
|
if (!res.ok)
|
|
@@ -450,20 +527,20 @@ export class AgentDomain {
|
|
|
450
527
|
async fundRenewalVault(agentId, amountUsdc) {
|
|
451
528
|
const walletAddress = this.walletClient?.account?.address;
|
|
452
529
|
if (!this.walletClient || !walletAddress) {
|
|
453
|
-
throw new Error(
|
|
530
|
+
throw new Error('Funding the renewal vault requires a walletClient so the SDK can sign a USDC authorization.');
|
|
454
531
|
}
|
|
455
532
|
const url = `${this.apiUrl}/agents/${agentId}/renewal/fund`;
|
|
456
533
|
let res = await fetch(url, {
|
|
457
|
-
method:
|
|
458
|
-
headers: await this.authHeaders({
|
|
534
|
+
method: 'POST',
|
|
535
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
459
536
|
body: JSON.stringify({ amount: amountUsdc }),
|
|
460
537
|
});
|
|
461
538
|
if (res.status === 402) {
|
|
462
539
|
const challenge = (await res.json());
|
|
463
540
|
const authorization = await this.buildEip3009Authorization(challenge, walletAddress);
|
|
464
541
|
res = await fetch(url, {
|
|
465
|
-
method:
|
|
466
|
-
headers: await this.authHeaders({
|
|
542
|
+
method: 'POST',
|
|
543
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
467
544
|
body: JSON.stringify({
|
|
468
545
|
amount: amountUsdc,
|
|
469
546
|
signature: authorization.signature,
|
|
@@ -485,18 +562,17 @@ export class AgentDomain {
|
|
|
485
562
|
async setAutoRenew(agentId, enabled, opts = {}) {
|
|
486
563
|
const walletAddress = this.walletClient?.account?.address;
|
|
487
564
|
if (!this.walletClient || !walletAddress) {
|
|
488
|
-
throw new Error(
|
|
565
|
+
throw new Error('Auto-renew requires a walletClient for the AgentID NFT owner wallet. Any wallet can fund RenewalVault, but only the owner wallet can change auto-renew.');
|
|
489
566
|
}
|
|
490
567
|
const renewalVaultAddress = opts.renewalVaultAddress ?? this.renewalVaultAddress;
|
|
491
568
|
if (!renewalVaultAddress) {
|
|
492
|
-
throw new Error(
|
|
569
|
+
throw new Error('renewalVaultAddress is required to enable auto-renew. Pass it to the AgentDomain constructor or setAutoRenew options.');
|
|
493
570
|
}
|
|
494
571
|
const status = await this.getRenewalStatus(agentId);
|
|
495
572
|
if (!status.tokenId) {
|
|
496
|
-
throw new Error(
|
|
573
|
+
throw new Error('Auto-renew cannot be changed before the AgentID NFT is minted.');
|
|
497
574
|
}
|
|
498
|
-
if (status.ownerAddress &&
|
|
499
|
-
!sameAddress(walletAddress, status.ownerAddress)) {
|
|
575
|
+
if (status.ownerAddress && !sameAddress(walletAddress, status.ownerAddress)) {
|
|
500
576
|
throw new Error(`Auto-renew can only be changed by the AgentID NFT owner wallet (${status.ownerAddress}).`);
|
|
501
577
|
}
|
|
502
578
|
if (status.autoRenewEnabled === enabled) {
|
|
@@ -509,19 +585,21 @@ export class AgentDomain {
|
|
|
509
585
|
};
|
|
510
586
|
}
|
|
511
587
|
if (opts.waitForReceipt && !this.publicClient) {
|
|
512
|
-
throw new Error(
|
|
588
|
+
throw new Error('waitForReceipt requires a publicClient in the AgentDomain constructor.');
|
|
513
589
|
}
|
|
514
|
-
const chain = this.network ===
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
args: [BigInt(status.tokenId), enabled],
|
|
590
|
+
const chain = this.network === 'base-sepolia' ? baseSepolia : base;
|
|
591
|
+
const data = encodeSetAutoRenewCalldata(BigInt(status.tokenId), enabled, this.requireBuilderCode('Auto-renew'));
|
|
592
|
+
const txHash = (await this.walletClient.sendTransaction({
|
|
593
|
+
to: renewalVaultAddress,
|
|
594
|
+
data,
|
|
520
595
|
account: this.walletClient.account,
|
|
521
596
|
chain,
|
|
522
597
|
}));
|
|
523
598
|
if (opts.waitForReceipt) {
|
|
524
|
-
await this.publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
599
|
+
const receipt = await this.publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
600
|
+
if (receipt.status !== 'success') {
|
|
601
|
+
throw new Error(`Auto-renew transaction ${txHash} reverted on Base.`);
|
|
602
|
+
}
|
|
525
603
|
}
|
|
526
604
|
return {
|
|
527
605
|
agentId,
|
|
@@ -534,18 +612,22 @@ export class AgentDomain {
|
|
|
534
612
|
async withdrawFromVault(agentId, amountUsdc) {
|
|
535
613
|
const url = `${this.apiUrl}/agents/${agentId}/renewal/withdraw`;
|
|
536
614
|
const res = await fetch(url, {
|
|
537
|
-
method:
|
|
538
|
-
headers: await this.authHeaders({
|
|
615
|
+
method: 'POST',
|
|
616
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
539
617
|
body: JSON.stringify({ amount: amountUsdc }),
|
|
540
618
|
});
|
|
541
619
|
if (!res.ok)
|
|
542
620
|
throw new Error(await responseError(res));
|
|
543
|
-
|
|
621
|
+
const transaction = (await res.json());
|
|
622
|
+
return {
|
|
623
|
+
...transaction,
|
|
624
|
+
data: appendBuilderCodeAttribution(transaction.data, this.requireBuilderCode('RenewalVault withdrawal')),
|
|
625
|
+
};
|
|
544
626
|
}
|
|
545
627
|
async reconfigureSsl(agentId) {
|
|
546
628
|
const url = `${this.apiUrl}/agents/${agentId}/ssl`;
|
|
547
629
|
const res = await fetch(url, {
|
|
548
|
-
method:
|
|
630
|
+
method: 'POST',
|
|
549
631
|
headers: await this.authHeaders(),
|
|
550
632
|
});
|
|
551
633
|
if (!res.ok)
|
|
@@ -562,7 +644,7 @@ export class AgentDomain {
|
|
|
562
644
|
async purchaseServicePlan(args) {
|
|
563
645
|
const walletAddress = this.walletClient?.account?.address;
|
|
564
646
|
if (!this.walletClient || !walletAddress) {
|
|
565
|
-
throw new Error(
|
|
647
|
+
throw new Error('Premium Plan purchase requires a walletClient so the SDK can sign the USDC x402 payment.');
|
|
566
648
|
}
|
|
567
649
|
const url = `${this.apiUrl}/agents/${args.agentId}/plan`;
|
|
568
650
|
const body = JSON.stringify({
|
|
@@ -570,19 +652,19 @@ export class AgentDomain {
|
|
|
570
652
|
planSku: args.planSku,
|
|
571
653
|
});
|
|
572
654
|
let res = await fetch(url, {
|
|
573
|
-
method:
|
|
574
|
-
headers: await this.authHeaders({
|
|
655
|
+
method: 'POST',
|
|
656
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
575
657
|
body,
|
|
576
658
|
});
|
|
577
659
|
if (res.status === 402) {
|
|
578
|
-
if (this.network !==
|
|
579
|
-
throw new Error(
|
|
660
|
+
if (this.network !== 'base') {
|
|
661
|
+
throw new Error('AgentDomain x402 payments are supported only on Base mainnet.');
|
|
580
662
|
}
|
|
581
663
|
const paymentHeaders = await createX402PaymentHeaders(res, this.walletClient);
|
|
582
664
|
res = await fetch(url, {
|
|
583
|
-
method:
|
|
665
|
+
method: 'POST',
|
|
584
666
|
headers: await this.authHeaders({
|
|
585
|
-
|
|
667
|
+
'Content-Type': 'application/json',
|
|
586
668
|
...paymentHeaders,
|
|
587
669
|
}),
|
|
588
670
|
body,
|
|
@@ -595,8 +677,8 @@ export class AgentDomain {
|
|
|
595
677
|
async setRegistryVisibility(agentId, registryHidden) {
|
|
596
678
|
const url = `${this.apiUrl}/agents/${agentId}/plan`;
|
|
597
679
|
const res = await fetch(url, {
|
|
598
|
-
method:
|
|
599
|
-
headers: await this.authHeaders({
|
|
680
|
+
method: 'PATCH',
|
|
681
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
600
682
|
body: JSON.stringify({ registryHidden }),
|
|
601
683
|
});
|
|
602
684
|
if (!res.ok)
|
|
@@ -606,8 +688,8 @@ export class AgentDomain {
|
|
|
606
688
|
async scheduleServicePlanRenewal(agentId, args) {
|
|
607
689
|
const planSku = args.planSku ?? args.plan;
|
|
608
690
|
const res = await fetch(`${this.apiUrl}/agents/${agentId}/plan`, {
|
|
609
|
-
method:
|
|
610
|
-
headers: await this.authHeaders({
|
|
691
|
+
method: 'PATCH',
|
|
692
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }),
|
|
611
693
|
body: JSON.stringify({ renewalPlan: args.plan, renewalPlanSku: planSku }),
|
|
612
694
|
});
|
|
613
695
|
if (!res.ok)
|
|
@@ -626,8 +708,8 @@ export class AgentDomain {
|
|
|
626
708
|
}
|
|
627
709
|
async createApiKey(agentId, name) {
|
|
628
710
|
const res = await fetch(`${this.apiUrl}/keys`, {
|
|
629
|
-
method:
|
|
630
|
-
headers: await this.authHeaders({
|
|
711
|
+
method: 'POST',
|
|
712
|
+
headers: await this.authHeaders({ 'Content-Type': 'application/json' }, { useApiKey: false }),
|
|
631
713
|
body: JSON.stringify({ agentId, name }),
|
|
632
714
|
});
|
|
633
715
|
if (!res.ok)
|
|
@@ -636,7 +718,7 @@ export class AgentDomain {
|
|
|
636
718
|
}
|
|
637
719
|
async revokeApiKey(keyId) {
|
|
638
720
|
const res = await fetch(`${this.apiUrl}/keys/${keyId}`, {
|
|
639
|
-
method:
|
|
721
|
+
method: 'DELETE',
|
|
640
722
|
headers: await this.authHeaders(undefined, { useApiKey: false }),
|
|
641
723
|
});
|
|
642
724
|
if (!res.ok)
|
|
@@ -649,7 +731,7 @@ export class AgentDomain {
|
|
|
649
731
|
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
650
732
|
return headers;
|
|
651
733
|
}
|
|
652
|
-
if (!headers[
|
|
734
|
+
if (!headers['X-Agent-Signature'] && this.walletClient?.account) {
|
|
653
735
|
try {
|
|
654
736
|
const timestamp = Date.now();
|
|
655
737
|
const message = `agentdomain.app api auth ${timestamp}`;
|
|
@@ -657,7 +739,7 @@ export class AgentDomain {
|
|
|
657
739
|
account: this.walletClient.account,
|
|
658
740
|
message,
|
|
659
741
|
});
|
|
660
|
-
headers[
|
|
742
|
+
headers['X-Agent-Signature'] =
|
|
661
743
|
`${this.walletClient.account.address}:${timestamp}:${signature}`;
|
|
662
744
|
}
|
|
663
745
|
catch {
|
|
@@ -671,399 +753,336 @@ export class AgentDomain {
|
|
|
671
753
|
export function createOpenAITools() {
|
|
672
754
|
return [
|
|
673
755
|
{
|
|
674
|
-
type:
|
|
756
|
+
type: 'function',
|
|
675
757
|
function: {
|
|
676
|
-
name:
|
|
677
|
-
description:
|
|
758
|
+
name: 'check_domain_availability',
|
|
759
|
+
description: 'Check if a domain name is available for registration',
|
|
678
760
|
parameters: {
|
|
679
|
-
type:
|
|
761
|
+
type: 'object',
|
|
680
762
|
properties: {
|
|
681
|
-
name: { type:
|
|
682
|
-
tld: {
|
|
683
|
-
type: "string",
|
|
684
|
-
description: "TLD (e.g. xyz, com, ai)",
|
|
685
|
-
default: "xyz",
|
|
686
|
-
},
|
|
763
|
+
name: { type: 'string', description: 'Domain name to check' },
|
|
764
|
+
tld: { type: 'string', description: 'TLD (e.g. xyz, com, ai)', default: 'xyz' },
|
|
687
765
|
},
|
|
688
|
-
required: [
|
|
766
|
+
required: ['name'],
|
|
689
767
|
},
|
|
690
768
|
},
|
|
691
769
|
},
|
|
692
770
|
{
|
|
693
|
-
type:
|
|
771
|
+
type: 'function',
|
|
694
772
|
function: {
|
|
695
|
-
name:
|
|
696
|
-
description:
|
|
773
|
+
name: 'quote_registration',
|
|
774
|
+
description: 'Get pricing quote for registering an AI agent identity. Domain, DNS, email, SSL certification, AgentID NFT orchestration, and platform fee are included by default. Basename and ENS are optional.',
|
|
697
775
|
parameters: {
|
|
698
|
-
type:
|
|
776
|
+
type: 'object',
|
|
699
777
|
properties: {
|
|
700
|
-
preferredName: {
|
|
701
|
-
|
|
702
|
-
description: "Preferred domain name",
|
|
703
|
-
},
|
|
704
|
-
tld: { type: "string", description: "TLD", default: "xyz" },
|
|
778
|
+
preferredName: { type: 'string', description: 'Preferred domain name' },
|
|
779
|
+
tld: { type: 'string', description: 'TLD', default: 'xyz' },
|
|
705
780
|
registerBasename: {
|
|
706
|
-
type:
|
|
707
|
-
description:
|
|
781
|
+
type: 'boolean',
|
|
782
|
+
description: 'Also register Basename. Set false to skip Basename cost.',
|
|
708
783
|
default: true,
|
|
709
784
|
},
|
|
710
785
|
basenameLabel: {
|
|
711
|
-
type:
|
|
712
|
-
description:
|
|
786
|
+
type: 'string',
|
|
787
|
+
description: 'Optional alternate Basename label. Omit to use preferredName.',
|
|
713
788
|
},
|
|
714
789
|
registerEns: {
|
|
715
|
-
type:
|
|
716
|
-
description:
|
|
790
|
+
type: 'boolean',
|
|
791
|
+
description: 'Also register ENS name. Set false to skip ENS cost.',
|
|
717
792
|
default: false,
|
|
718
793
|
},
|
|
719
794
|
ensLabel: {
|
|
720
|
-
type:
|
|
721
|
-
description:
|
|
795
|
+
type: 'string',
|
|
796
|
+
description: 'Optional alternate ENS label. Omit to use preferredName.',
|
|
722
797
|
},
|
|
723
798
|
emailEnabled: {
|
|
724
|
-
type:
|
|
725
|
-
description:
|
|
799
|
+
type: 'boolean',
|
|
800
|
+
description: 'Deprecated compatibility flag. Email is now always included.',
|
|
726
801
|
default: true,
|
|
727
802
|
},
|
|
728
803
|
emailUsername: {
|
|
729
|
-
type:
|
|
730
|
-
description:
|
|
731
|
-
default:
|
|
804
|
+
type: 'string',
|
|
805
|
+
description: 'Primary email username. Defaults to agent, producing agent@domain.',
|
|
806
|
+
default: 'agent',
|
|
732
807
|
},
|
|
733
808
|
premiumPlan: {
|
|
734
|
-
type:
|
|
735
|
-
enum: [
|
|
736
|
-
description:
|
|
737
|
-
default:
|
|
738
|
-
},
|
|
739
|
-
years: {
|
|
740
|
-
type: "number",
|
|
741
|
-
description: "Registration years",
|
|
742
|
-
default: 1,
|
|
809
|
+
type: 'string',
|
|
810
|
+
enum: ['included', 'starter', 'pro', 'enterprise'],
|
|
811
|
+
description: 'Premium Plan to buy with registration. Defaults to included.',
|
|
812
|
+
default: 'included',
|
|
743
813
|
},
|
|
814
|
+
years: { type: 'number', description: 'Registration years', default: 1 },
|
|
744
815
|
},
|
|
745
|
-
required: [
|
|
816
|
+
required: ['preferredName'],
|
|
746
817
|
},
|
|
747
818
|
},
|
|
748
819
|
},
|
|
749
820
|
{
|
|
750
|
-
type:
|
|
821
|
+
type: 'function',
|
|
751
822
|
function: {
|
|
752
|
-
name:
|
|
753
|
-
description:
|
|
823
|
+
name: 'register_agent_identity',
|
|
824
|
+
description: 'Register a new AI agent identity. Domain, DNS, email, SSL certification, AgentID NFT orchestration, and platform fee are included by default. Basename and ENS are optional.',
|
|
754
825
|
parameters: {
|
|
755
|
-
type:
|
|
826
|
+
type: 'object',
|
|
756
827
|
properties: {
|
|
757
|
-
preferredName: { type:
|
|
758
|
-
tld: { type:
|
|
828
|
+
preferredName: { type: 'string', description: 'Domain name' },
|
|
829
|
+
tld: { type: 'string', description: 'TLD', default: 'xyz' },
|
|
759
830
|
registerBasename: {
|
|
760
|
-
type:
|
|
761
|
-
description:
|
|
831
|
+
type: 'boolean',
|
|
832
|
+
description: 'Register Basename. Set false to skip Basename cost.',
|
|
762
833
|
default: true,
|
|
763
834
|
},
|
|
764
835
|
basenameLabel: {
|
|
765
|
-
type:
|
|
766
|
-
description:
|
|
836
|
+
type: 'string',
|
|
837
|
+
description: 'Optional alternate Basename label. Omit to use preferredName.',
|
|
767
838
|
},
|
|
768
839
|
registerEns: {
|
|
769
|
-
type:
|
|
770
|
-
description:
|
|
840
|
+
type: 'boolean',
|
|
841
|
+
description: 'Register ENS. Set false to skip ENS cost.',
|
|
771
842
|
default: false,
|
|
772
843
|
},
|
|
773
844
|
ensLabel: {
|
|
774
|
-
type:
|
|
775
|
-
description:
|
|
845
|
+
type: 'string',
|
|
846
|
+
description: 'Optional alternate ENS label. Omit to use preferredName.',
|
|
776
847
|
},
|
|
777
848
|
ownerAddress: {
|
|
778
|
-
type:
|
|
779
|
-
description:
|
|
849
|
+
type: 'string',
|
|
850
|
+
description: 'Optional EVM address that receives the AgentID NFT. Omit to use the paying wallet.',
|
|
780
851
|
},
|
|
781
852
|
emailEnabled: {
|
|
782
|
-
type:
|
|
783
|
-
description:
|
|
853
|
+
type: 'boolean',
|
|
854
|
+
description: 'Deprecated compatibility flag. Email is now always included.',
|
|
784
855
|
default: true,
|
|
785
856
|
},
|
|
786
857
|
emailUsername: {
|
|
787
|
-
type:
|
|
788
|
-
description:
|
|
789
|
-
default:
|
|
858
|
+
type: 'string',
|
|
859
|
+
description: 'Primary email username. Defaults to agent, producing agent@domain.',
|
|
860
|
+
default: 'agent',
|
|
790
861
|
},
|
|
791
862
|
dnsTarget: {
|
|
792
|
-
type:
|
|
793
|
-
description:
|
|
863
|
+
type: 'string',
|
|
864
|
+
description: 'Optional initial endpoint URL or IP to point the domain at.',
|
|
794
865
|
},
|
|
795
866
|
premiumPlan: {
|
|
796
|
-
type:
|
|
797
|
-
enum: [
|
|
798
|
-
description:
|
|
799
|
-
default:
|
|
800
|
-
},
|
|
801
|
-
years: {
|
|
802
|
-
type: "number",
|
|
803
|
-
description: "Registration years",
|
|
804
|
-
default: 1,
|
|
867
|
+
type: 'string',
|
|
868
|
+
enum: ['included', 'starter', 'pro', 'enterprise'],
|
|
869
|
+
description: 'Premium Plan to buy with registration. Defaults to included.',
|
|
870
|
+
default: 'included',
|
|
805
871
|
},
|
|
872
|
+
years: { type: 'number', description: 'Registration years', default: 1 },
|
|
806
873
|
},
|
|
807
|
-
required: [
|
|
874
|
+
required: ['preferredName'],
|
|
808
875
|
},
|
|
809
876
|
},
|
|
810
877
|
},
|
|
811
878
|
{
|
|
812
|
-
type:
|
|
879
|
+
type: 'function',
|
|
813
880
|
function: {
|
|
814
|
-
name:
|
|
815
|
-
description:
|
|
881
|
+
name: 'search_agents',
|
|
882
|
+
description: 'Search for registered AI agents',
|
|
816
883
|
parameters: {
|
|
817
|
-
type:
|
|
884
|
+
type: 'object',
|
|
818
885
|
properties: {
|
|
819
|
-
q: { type:
|
|
820
|
-
framework: { type:
|
|
821
|
-
limit: { type:
|
|
886
|
+
q: { type: 'string', description: 'Search query' },
|
|
887
|
+
framework: { type: 'string', description: 'Filter by framework' },
|
|
888
|
+
limit: { type: 'number', description: 'Max results', default: 20 },
|
|
822
889
|
},
|
|
823
890
|
},
|
|
824
891
|
},
|
|
825
892
|
},
|
|
826
893
|
{
|
|
827
|
-
type:
|
|
894
|
+
type: 'function',
|
|
828
895
|
function: {
|
|
829
|
-
name:
|
|
830
|
-
description:
|
|
896
|
+
name: 'send_agent_email',
|
|
897
|
+
description: 'Send text-only email from an agent primary email or active alias',
|
|
831
898
|
parameters: {
|
|
832
|
-
type:
|
|
899
|
+
type: 'object',
|
|
833
900
|
properties: {
|
|
834
|
-
agentId: {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
},
|
|
838
|
-
to: { type: "string", description: "Recipient email address" },
|
|
839
|
-
subject: { type: "string", description: "Email subject" },
|
|
840
|
-
text: { type: "string", description: "Plain-text email body" },
|
|
901
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
902
|
+
to: { type: 'string', description: 'Recipient email address' },
|
|
903
|
+
subject: { type: 'string', description: 'Email subject' },
|
|
904
|
+
text: { type: 'string', description: 'Plain-text email body' },
|
|
841
905
|
fromAddress: {
|
|
842
|
-
type:
|
|
843
|
-
description:
|
|
906
|
+
type: 'string',
|
|
907
|
+
description: 'Optional primary email or active alias to send from',
|
|
844
908
|
},
|
|
845
909
|
},
|
|
846
|
-
required: [
|
|
910
|
+
required: ['agentId', 'to', 'subject', 'text'],
|
|
847
911
|
},
|
|
848
912
|
},
|
|
849
913
|
},
|
|
850
914
|
{
|
|
851
|
-
type:
|
|
915
|
+
type: 'function',
|
|
852
916
|
function: {
|
|
853
|
-
name:
|
|
854
|
-
description:
|
|
917
|
+
name: 'list_agent_email',
|
|
918
|
+
description: 'List an agent email messages and active primary/alias addresses',
|
|
855
919
|
parameters: {
|
|
856
|
-
type:
|
|
920
|
+
type: 'object',
|
|
857
921
|
properties: {
|
|
858
|
-
agentId: {
|
|
859
|
-
|
|
860
|
-
description: "AgentDomain agent ID (UUID)",
|
|
861
|
-
},
|
|
862
|
-
limit: { type: "number", description: "Max messages", default: 20 },
|
|
922
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
923
|
+
limit: { type: 'number', description: 'Max messages', default: 20 },
|
|
863
924
|
},
|
|
864
|
-
required: [
|
|
925
|
+
required: ['agentId'],
|
|
865
926
|
},
|
|
866
927
|
},
|
|
867
928
|
},
|
|
868
929
|
{
|
|
869
|
-
type:
|
|
930
|
+
type: 'function',
|
|
870
931
|
function: {
|
|
871
|
-
name:
|
|
872
|
-
description:
|
|
932
|
+
name: 'delete_agent_email',
|
|
933
|
+
description: 'Permanently delete one email message from an agent inbox',
|
|
873
934
|
parameters: {
|
|
874
|
-
type:
|
|
935
|
+
type: 'object',
|
|
875
936
|
properties: {
|
|
876
|
-
agentId: {
|
|
877
|
-
|
|
878
|
-
description: "AgentDomain agent ID (UUID)",
|
|
879
|
-
},
|
|
880
|
-
messageId: {
|
|
881
|
-
type: "string",
|
|
882
|
-
description: "Email message ID (UUID)",
|
|
883
|
-
},
|
|
937
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
938
|
+
messageId: { type: 'string', description: 'Email message ID (UUID)' },
|
|
884
939
|
},
|
|
885
|
-
required: [
|
|
940
|
+
required: ['agentId', 'messageId'],
|
|
886
941
|
},
|
|
887
942
|
},
|
|
888
943
|
},
|
|
889
944
|
{
|
|
890
|
-
type:
|
|
945
|
+
type: 'function',
|
|
891
946
|
function: {
|
|
892
|
-
name:
|
|
893
|
-
description:
|
|
947
|
+
name: 'update_primary_email',
|
|
948
|
+
description: 'Change one agent primary email username. The old primary address stops receiving new mail.',
|
|
894
949
|
parameters: {
|
|
895
|
-
type:
|
|
950
|
+
type: 'object',
|
|
896
951
|
properties: {
|
|
897
|
-
agentId: {
|
|
898
|
-
|
|
899
|
-
description: "AgentDomain agent ID (UUID)",
|
|
900
|
-
},
|
|
901
|
-
username: {
|
|
902
|
-
type: "string",
|
|
903
|
-
description: "New local-part, e.g. agent or support",
|
|
904
|
-
},
|
|
952
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
953
|
+
username: { type: 'string', description: 'New local-part, e.g. agent or support' },
|
|
905
954
|
},
|
|
906
|
-
required: [
|
|
955
|
+
required: ['agentId', 'username'],
|
|
907
956
|
},
|
|
908
957
|
},
|
|
909
958
|
},
|
|
910
959
|
{
|
|
911
|
-
type:
|
|
960
|
+
type: 'function',
|
|
912
961
|
function: {
|
|
913
|
-
name:
|
|
914
|
-
description:
|
|
962
|
+
name: 'create_email_alias',
|
|
963
|
+
description: 'Create an extra receive-and-send email alias. Requires available paid-plan alias capacity.',
|
|
915
964
|
parameters: {
|
|
916
|
-
type:
|
|
965
|
+
type: 'object',
|
|
917
966
|
properties: {
|
|
918
|
-
agentId: {
|
|
919
|
-
|
|
920
|
-
description: "AgentDomain agent ID (UUID)",
|
|
921
|
-
},
|
|
922
|
-
username: {
|
|
923
|
-
type: "string",
|
|
924
|
-
description: "Alias local-part, e.g. billing",
|
|
925
|
-
},
|
|
967
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
968
|
+
username: { type: 'string', description: 'Alias local-part, e.g. billing' },
|
|
926
969
|
},
|
|
927
|
-
required: [
|
|
970
|
+
required: ['agentId', 'username'],
|
|
928
971
|
},
|
|
929
972
|
},
|
|
930
973
|
},
|
|
931
974
|
{
|
|
932
|
-
type:
|
|
975
|
+
type: 'function',
|
|
933
976
|
function: {
|
|
934
|
-
name:
|
|
935
|
-
description:
|
|
977
|
+
name: 'delete_email_alias',
|
|
978
|
+
description: 'Delete one active email alias from an agent',
|
|
936
979
|
parameters: {
|
|
937
|
-
type:
|
|
980
|
+
type: 'object',
|
|
938
981
|
properties: {
|
|
939
|
-
agentId: {
|
|
940
|
-
|
|
941
|
-
description: "AgentDomain agent ID (UUID)",
|
|
942
|
-
},
|
|
943
|
-
emailAddress: {
|
|
944
|
-
type: "string",
|
|
945
|
-
description: "Full alias address to delete",
|
|
946
|
-
},
|
|
982
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
983
|
+
emailAddress: { type: 'string', description: 'Full alias address to delete' },
|
|
947
984
|
},
|
|
948
|
-
required: [
|
|
985
|
+
required: ['agentId', 'emailAddress'],
|
|
949
986
|
},
|
|
950
987
|
},
|
|
951
988
|
},
|
|
952
989
|
{
|
|
953
|
-
type:
|
|
990
|
+
type: 'function',
|
|
954
991
|
function: {
|
|
955
|
-
name:
|
|
956
|
-
description:
|
|
992
|
+
name: 'get_renewal_status',
|
|
993
|
+
description: 'Get renewal vault status for an agent, including exact next renewal amount, purchase snapshot, vault balance, shortfall, renewal date, and auto-renew state',
|
|
957
994
|
parameters: {
|
|
958
|
-
type:
|
|
995
|
+
type: 'object',
|
|
959
996
|
properties: {
|
|
960
|
-
agentId: {
|
|
961
|
-
type: "string",
|
|
962
|
-
description: "AgentDomain agent ID (UUID)",
|
|
963
|
-
},
|
|
997
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
964
998
|
},
|
|
965
|
-
required: [
|
|
999
|
+
required: ['agentId'],
|
|
966
1000
|
},
|
|
967
1001
|
},
|
|
968
1002
|
},
|
|
969
1003
|
{
|
|
970
|
-
type:
|
|
1004
|
+
type: 'function',
|
|
971
1005
|
function: {
|
|
972
|
-
name:
|
|
973
|
-
description:
|
|
1006
|
+
name: 'fund_renewal_vault',
|
|
1007
|
+
description: 'Deposit USDC from the connected wallet into one AgentID renewal vault. Anyone can fund; only the owner can withdraw or enable auto-renew. Call get_renewal_status first and normally use its shortfallUsdc value.',
|
|
974
1008
|
parameters: {
|
|
975
|
-
type:
|
|
1009
|
+
type: 'object',
|
|
976
1010
|
properties: {
|
|
977
|
-
agentId: {
|
|
978
|
-
type: "string",
|
|
979
|
-
description: "AgentDomain agent ID (UUID)",
|
|
980
|
-
},
|
|
1011
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
981
1012
|
amountUsdc: {
|
|
982
|
-
type:
|
|
983
|
-
description:
|
|
1013
|
+
type: 'string',
|
|
1014
|
+
description: 'USDC amount to deposit, with up to 6 decimals.',
|
|
984
1015
|
},
|
|
985
1016
|
},
|
|
986
|
-
required: [
|
|
1017
|
+
required: ['agentId', 'amountUsdc'],
|
|
987
1018
|
},
|
|
988
1019
|
},
|
|
989
1020
|
},
|
|
990
1021
|
{
|
|
991
|
-
type:
|
|
1022
|
+
type: 'function',
|
|
992
1023
|
function: {
|
|
993
|
-
name:
|
|
994
|
-
description:
|
|
1024
|
+
name: 'enable_auto_renew',
|
|
1025
|
+
description: 'Enable RenewalVault auto-renew for an agent. Requires the walletClient to be the AgentID NFT owner wallet.',
|
|
995
1026
|
parameters: {
|
|
996
|
-
type:
|
|
1027
|
+
type: 'object',
|
|
997
1028
|
properties: {
|
|
998
|
-
agentId: {
|
|
999
|
-
type: "string",
|
|
1000
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1001
|
-
},
|
|
1029
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1002
1030
|
},
|
|
1003
|
-
required: [
|
|
1031
|
+
required: ['agentId'],
|
|
1004
1032
|
},
|
|
1005
1033
|
},
|
|
1006
1034
|
},
|
|
1007
1035
|
{
|
|
1008
|
-
type:
|
|
1036
|
+
type: 'function',
|
|
1009
1037
|
function: {
|
|
1010
|
-
name:
|
|
1011
|
-
description:
|
|
1038
|
+
name: 'reconfigure_ssl',
|
|
1039
|
+
description: 'Rebuild the Cloudflare SaaS SSL hostname and sync the required Spaceship DNS validation records for an existing agent. Use this if SSL is pending, failed, or needs a refresh.',
|
|
1012
1040
|
parameters: {
|
|
1013
|
-
type:
|
|
1041
|
+
type: 'object',
|
|
1014
1042
|
properties: {
|
|
1015
|
-
agentId: {
|
|
1016
|
-
type: "string",
|
|
1017
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1018
|
-
},
|
|
1043
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1019
1044
|
},
|
|
1020
|
-
required: [
|
|
1045
|
+
required: ['agentId'],
|
|
1021
1046
|
},
|
|
1022
1047
|
},
|
|
1023
1048
|
},
|
|
1024
1049
|
{
|
|
1025
|
-
type:
|
|
1050
|
+
type: 'function',
|
|
1026
1051
|
function: {
|
|
1027
|
-
name:
|
|
1028
|
-
description:
|
|
1052
|
+
name: 'set_registry_visibility',
|
|
1053
|
+
description: 'Hide or show an agent in the public AgentDomain registry. Hiding requires an active paid Premium Plan.',
|
|
1029
1054
|
parameters: {
|
|
1030
|
-
type:
|
|
1055
|
+
type: 'object',
|
|
1031
1056
|
properties: {
|
|
1032
|
-
agentId: {
|
|
1033
|
-
type: "string",
|
|
1034
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1035
|
-
},
|
|
1057
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1036
1058
|
registryHidden: {
|
|
1037
|
-
type:
|
|
1038
|
-
description:
|
|
1059
|
+
type: 'boolean',
|
|
1060
|
+
description: 'true hides the agent from public registry/search; false makes it public',
|
|
1039
1061
|
},
|
|
1040
1062
|
},
|
|
1041
|
-
required: [
|
|
1063
|
+
required: ['agentId', 'registryHidden'],
|
|
1042
1064
|
},
|
|
1043
1065
|
},
|
|
1044
1066
|
},
|
|
1045
1067
|
{
|
|
1046
|
-
type:
|
|
1068
|
+
type: 'function',
|
|
1047
1069
|
function: {
|
|
1048
|
-
name:
|
|
1049
|
-
description:
|
|
1070
|
+
name: 'schedule_service_plan_renewal',
|
|
1071
|
+
description: 'Choose the exact Premium Plan SKU for the next identity renewal',
|
|
1050
1072
|
parameters: {
|
|
1051
|
-
type:
|
|
1073
|
+
type: 'object',
|
|
1052
1074
|
properties: {
|
|
1053
|
-
agentId: {
|
|
1054
|
-
type: "string",
|
|
1055
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1056
|
-
},
|
|
1075
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1057
1076
|
plan: {
|
|
1058
|
-
type:
|
|
1059
|
-
enum: [
|
|
1077
|
+
type: 'string',
|
|
1078
|
+
enum: ['included', 'starter', 'pro', 'enterprise'],
|
|
1060
1079
|
},
|
|
1061
1080
|
planSku: {
|
|
1062
|
-
type:
|
|
1063
|
-
description:
|
|
1081
|
+
type: 'string',
|
|
1082
|
+
description: 'Exact SKU, including Enterprise email volume tier',
|
|
1064
1083
|
},
|
|
1065
1084
|
},
|
|
1066
|
-
required: [
|
|
1085
|
+
required: ['agentId', 'plan', 'planSku'],
|
|
1067
1086
|
},
|
|
1068
1087
|
},
|
|
1069
1088
|
},
|
|
@@ -1072,363 +1091,301 @@ export function createOpenAITools() {
|
|
|
1072
1091
|
export function createAnthropicTools() {
|
|
1073
1092
|
return [
|
|
1074
1093
|
{
|
|
1075
|
-
name:
|
|
1076
|
-
description:
|
|
1094
|
+
name: 'check_domain_availability',
|
|
1095
|
+
description: 'Check if a domain name is available for registration',
|
|
1077
1096
|
input_schema: {
|
|
1078
|
-
type:
|
|
1097
|
+
type: 'object',
|
|
1079
1098
|
properties: {
|
|
1080
|
-
name: { type:
|
|
1081
|
-
tld: {
|
|
1082
|
-
type: "string",
|
|
1083
|
-
description: "TLD (e.g. xyz, com, ai)",
|
|
1084
|
-
default: "xyz",
|
|
1085
|
-
},
|
|
1099
|
+
name: { type: 'string', description: 'Domain name to check' },
|
|
1100
|
+
tld: { type: 'string', description: 'TLD (e.g. xyz, com, ai)', default: 'xyz' },
|
|
1086
1101
|
},
|
|
1087
|
-
required: [
|
|
1102
|
+
required: ['name'],
|
|
1088
1103
|
},
|
|
1089
1104
|
},
|
|
1090
1105
|
{
|
|
1091
|
-
name:
|
|
1092
|
-
description:
|
|
1106
|
+
name: 'quote_registration',
|
|
1107
|
+
description: 'Get pricing quote for registering an AI agent identity. Domain, DNS, email, SSL certification, AgentID NFT orchestration, and platform fee are included by default. Basename and ENS are optional.',
|
|
1093
1108
|
input_schema: {
|
|
1094
|
-
type:
|
|
1109
|
+
type: 'object',
|
|
1095
1110
|
properties: {
|
|
1096
|
-
preferredName: {
|
|
1097
|
-
|
|
1098
|
-
description: "Preferred domain name",
|
|
1099
|
-
},
|
|
1100
|
-
tld: { type: "string", description: "TLD", default: "xyz" },
|
|
1111
|
+
preferredName: { type: 'string', description: 'Preferred domain name' },
|
|
1112
|
+
tld: { type: 'string', description: 'TLD', default: 'xyz' },
|
|
1101
1113
|
registerBasename: {
|
|
1102
|
-
type:
|
|
1103
|
-
description:
|
|
1114
|
+
type: 'boolean',
|
|
1115
|
+
description: 'Also register Basename. Set false to skip Basename cost.',
|
|
1104
1116
|
default: true,
|
|
1105
1117
|
},
|
|
1106
1118
|
basenameLabel: {
|
|
1107
|
-
type:
|
|
1108
|
-
description:
|
|
1119
|
+
type: 'string',
|
|
1120
|
+
description: 'Optional alternate Basename label. Omit to use preferredName.',
|
|
1109
1121
|
},
|
|
1110
1122
|
registerEns: {
|
|
1111
|
-
type:
|
|
1112
|
-
description:
|
|
1123
|
+
type: 'boolean',
|
|
1124
|
+
description: 'Also register ENS name. Set false to skip ENS cost.',
|
|
1113
1125
|
default: false,
|
|
1114
1126
|
},
|
|
1115
1127
|
ensLabel: {
|
|
1116
|
-
type:
|
|
1117
|
-
description:
|
|
1128
|
+
type: 'string',
|
|
1129
|
+
description: 'Optional alternate ENS label. Omit to use preferredName.',
|
|
1118
1130
|
},
|
|
1119
1131
|
emailEnabled: {
|
|
1120
|
-
type:
|
|
1121
|
-
description:
|
|
1132
|
+
type: 'boolean',
|
|
1133
|
+
description: 'Deprecated compatibility flag. Email is now always included.',
|
|
1122
1134
|
default: true,
|
|
1123
1135
|
},
|
|
1124
1136
|
emailUsername: {
|
|
1125
|
-
type:
|
|
1126
|
-
description:
|
|
1127
|
-
default:
|
|
1137
|
+
type: 'string',
|
|
1138
|
+
description: 'Primary email username. Defaults to agent, producing agent@domain.',
|
|
1139
|
+
default: 'agent',
|
|
1128
1140
|
},
|
|
1129
1141
|
premiumPlan: {
|
|
1130
|
-
type:
|
|
1131
|
-
enum: [
|
|
1132
|
-
description:
|
|
1133
|
-
default:
|
|
1134
|
-
},
|
|
1135
|
-
years: {
|
|
1136
|
-
type: "number",
|
|
1137
|
-
description: "Registration years",
|
|
1138
|
-
default: 1,
|
|
1142
|
+
type: 'string',
|
|
1143
|
+
enum: ['included', 'starter', 'pro', 'enterprise'],
|
|
1144
|
+
description: 'Premium Plan to buy with registration. Defaults to included.',
|
|
1145
|
+
default: 'included',
|
|
1139
1146
|
},
|
|
1147
|
+
years: { type: 'number', description: 'Registration years', default: 1 },
|
|
1140
1148
|
},
|
|
1141
|
-
required: [
|
|
1149
|
+
required: ['preferredName'],
|
|
1142
1150
|
},
|
|
1143
1151
|
},
|
|
1144
1152
|
{
|
|
1145
|
-
name:
|
|
1146
|
-
description:
|
|
1153
|
+
name: 'register_agent_identity',
|
|
1154
|
+
description: 'Register a new AI agent identity. Domain, DNS, email, SSL certification, AgentID NFT orchestration, and platform fee are included by default. Basename and ENS are optional.',
|
|
1147
1155
|
input_schema: {
|
|
1148
|
-
type:
|
|
1156
|
+
type: 'object',
|
|
1149
1157
|
properties: {
|
|
1150
|
-
preferredName: { type:
|
|
1151
|
-
tld: { type:
|
|
1158
|
+
preferredName: { type: 'string', description: 'Domain name' },
|
|
1159
|
+
tld: { type: 'string', description: 'TLD', default: 'xyz' },
|
|
1152
1160
|
registerBasename: {
|
|
1153
|
-
type:
|
|
1154
|
-
description:
|
|
1161
|
+
type: 'boolean',
|
|
1162
|
+
description: 'Register Basename. Set false to skip Basename cost.',
|
|
1155
1163
|
default: true,
|
|
1156
1164
|
},
|
|
1157
1165
|
basenameLabel: {
|
|
1158
|
-
type:
|
|
1159
|
-
description:
|
|
1166
|
+
type: 'string',
|
|
1167
|
+
description: 'Optional alternate Basename label. Omit to use preferredName.',
|
|
1160
1168
|
},
|
|
1161
1169
|
registerEns: {
|
|
1162
|
-
type:
|
|
1163
|
-
description:
|
|
1170
|
+
type: 'boolean',
|
|
1171
|
+
description: 'Register ENS. Set false to skip ENS cost.',
|
|
1164
1172
|
default: false,
|
|
1165
1173
|
},
|
|
1166
1174
|
ensLabel: {
|
|
1167
|
-
type:
|
|
1168
|
-
description:
|
|
1175
|
+
type: 'string',
|
|
1176
|
+
description: 'Optional alternate ENS label. Omit to use preferredName.',
|
|
1169
1177
|
},
|
|
1170
1178
|
ownerAddress: {
|
|
1171
|
-
type:
|
|
1172
|
-
description:
|
|
1179
|
+
type: 'string',
|
|
1180
|
+
description: 'Optional EVM address that receives the AgentID NFT. Omit to use the paying wallet.',
|
|
1173
1181
|
},
|
|
1174
1182
|
emailEnabled: {
|
|
1175
|
-
type:
|
|
1176
|
-
description:
|
|
1183
|
+
type: 'boolean',
|
|
1184
|
+
description: 'Deprecated compatibility flag. Email is now always included.',
|
|
1177
1185
|
default: true,
|
|
1178
1186
|
},
|
|
1179
1187
|
emailUsername: {
|
|
1180
|
-
type:
|
|
1181
|
-
description:
|
|
1182
|
-
default:
|
|
1188
|
+
type: 'string',
|
|
1189
|
+
description: 'Primary email username. Defaults to agent, producing agent@domain.',
|
|
1190
|
+
default: 'agent',
|
|
1183
1191
|
},
|
|
1184
1192
|
dnsTarget: {
|
|
1185
|
-
type:
|
|
1186
|
-
description:
|
|
1193
|
+
type: 'string',
|
|
1194
|
+
description: 'Optional initial endpoint URL or IP to point the domain at.',
|
|
1187
1195
|
},
|
|
1188
1196
|
premiumPlan: {
|
|
1189
|
-
type:
|
|
1190
|
-
enum: [
|
|
1191
|
-
description:
|
|
1192
|
-
default:
|
|
1193
|
-
},
|
|
1194
|
-
years: {
|
|
1195
|
-
type: "number",
|
|
1196
|
-
description: "Registration years",
|
|
1197
|
-
default: 1,
|
|
1197
|
+
type: 'string',
|
|
1198
|
+
enum: ['included', 'starter', 'pro', 'enterprise'],
|
|
1199
|
+
description: 'Premium Plan to buy with registration. Defaults to included.',
|
|
1200
|
+
default: 'included',
|
|
1198
1201
|
},
|
|
1202
|
+
years: { type: 'number', description: 'Registration years', default: 1 },
|
|
1199
1203
|
},
|
|
1200
|
-
required: [
|
|
1204
|
+
required: ['preferredName'],
|
|
1201
1205
|
},
|
|
1202
1206
|
},
|
|
1203
1207
|
{
|
|
1204
|
-
name:
|
|
1205
|
-
description:
|
|
1208
|
+
name: 'search_agents',
|
|
1209
|
+
description: 'Search for registered AI agents',
|
|
1206
1210
|
input_schema: {
|
|
1207
|
-
type:
|
|
1211
|
+
type: 'object',
|
|
1208
1212
|
properties: {
|
|
1209
|
-
q: { type:
|
|
1210
|
-
framework: { type:
|
|
1211
|
-
limit: { type:
|
|
1213
|
+
q: { type: 'string', description: 'Search query' },
|
|
1214
|
+
framework: { type: 'string', description: 'Filter by framework' },
|
|
1215
|
+
limit: { type: 'number', description: 'Max results', default: 20 },
|
|
1212
1216
|
},
|
|
1213
1217
|
},
|
|
1214
1218
|
},
|
|
1215
1219
|
{
|
|
1216
|
-
name:
|
|
1217
|
-
description:
|
|
1220
|
+
name: 'send_agent_email',
|
|
1221
|
+
description: 'Send text-only email from an agent primary email or active alias',
|
|
1218
1222
|
input_schema: {
|
|
1219
|
-
type:
|
|
1223
|
+
type: 'object',
|
|
1220
1224
|
properties: {
|
|
1221
|
-
agentId: {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
},
|
|
1225
|
-
to: { type: "string", description: "Recipient email address" },
|
|
1226
|
-
subject: { type: "string", description: "Email subject" },
|
|
1227
|
-
text: { type: "string", description: "Plain-text email body" },
|
|
1225
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1226
|
+
to: { type: 'string', description: 'Recipient email address' },
|
|
1227
|
+
subject: { type: 'string', description: 'Email subject' },
|
|
1228
|
+
text: { type: 'string', description: 'Plain-text email body' },
|
|
1228
1229
|
fromAddress: {
|
|
1229
|
-
type:
|
|
1230
|
-
description:
|
|
1230
|
+
type: 'string',
|
|
1231
|
+
description: 'Optional primary email or active alias to send from',
|
|
1231
1232
|
},
|
|
1232
1233
|
},
|
|
1233
|
-
required: [
|
|
1234
|
+
required: ['agentId', 'to', 'subject', 'text'],
|
|
1234
1235
|
},
|
|
1235
1236
|
},
|
|
1236
1237
|
{
|
|
1237
|
-
name:
|
|
1238
|
-
description:
|
|
1238
|
+
name: 'list_agent_email',
|
|
1239
|
+
description: 'List an agent email messages and active primary/alias addresses',
|
|
1239
1240
|
input_schema: {
|
|
1240
|
-
type:
|
|
1241
|
+
type: 'object',
|
|
1241
1242
|
properties: {
|
|
1242
|
-
agentId: {
|
|
1243
|
-
|
|
1244
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1245
|
-
},
|
|
1246
|
-
limit: { type: "number", description: "Max messages", default: 20 },
|
|
1243
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1244
|
+
limit: { type: 'number', description: 'Max messages', default: 20 },
|
|
1247
1245
|
},
|
|
1248
|
-
required: [
|
|
1246
|
+
required: ['agentId'],
|
|
1249
1247
|
},
|
|
1250
1248
|
},
|
|
1251
1249
|
{
|
|
1252
|
-
name:
|
|
1253
|
-
description:
|
|
1250
|
+
name: 'delete_agent_email',
|
|
1251
|
+
description: 'Permanently delete one email message from an agent inbox',
|
|
1254
1252
|
input_schema: {
|
|
1255
|
-
type:
|
|
1253
|
+
type: 'object',
|
|
1256
1254
|
properties: {
|
|
1257
|
-
agentId: {
|
|
1258
|
-
|
|
1259
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1260
|
-
},
|
|
1261
|
-
messageId: { type: "string", description: "Email message ID (UUID)" },
|
|
1255
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1256
|
+
messageId: { type: 'string', description: 'Email message ID (UUID)' },
|
|
1262
1257
|
},
|
|
1263
|
-
required: [
|
|
1258
|
+
required: ['agentId', 'messageId'],
|
|
1264
1259
|
},
|
|
1265
1260
|
},
|
|
1266
1261
|
{
|
|
1267
|
-
name:
|
|
1268
|
-
description:
|
|
1262
|
+
name: 'update_primary_email',
|
|
1263
|
+
description: 'Change one agent primary email username. The old primary address stops receiving new mail.',
|
|
1269
1264
|
input_schema: {
|
|
1270
|
-
type:
|
|
1265
|
+
type: 'object',
|
|
1271
1266
|
properties: {
|
|
1272
|
-
agentId: {
|
|
1273
|
-
|
|
1274
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1275
|
-
},
|
|
1276
|
-
username: {
|
|
1277
|
-
type: "string",
|
|
1278
|
-
description: "New local-part, e.g. agent or support",
|
|
1279
|
-
},
|
|
1267
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1268
|
+
username: { type: 'string', description: 'New local-part, e.g. agent or support' },
|
|
1280
1269
|
},
|
|
1281
|
-
required: [
|
|
1270
|
+
required: ['agentId', 'username'],
|
|
1282
1271
|
},
|
|
1283
1272
|
},
|
|
1284
1273
|
{
|
|
1285
|
-
name:
|
|
1286
|
-
description:
|
|
1274
|
+
name: 'create_email_alias',
|
|
1275
|
+
description: 'Create an extra receive-and-send email alias. Requires available paid-plan alias capacity.',
|
|
1287
1276
|
input_schema: {
|
|
1288
|
-
type:
|
|
1277
|
+
type: 'object',
|
|
1289
1278
|
properties: {
|
|
1290
|
-
agentId: {
|
|
1291
|
-
|
|
1292
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1293
|
-
},
|
|
1294
|
-
username: {
|
|
1295
|
-
type: "string",
|
|
1296
|
-
description: "Alias local-part, e.g. billing",
|
|
1297
|
-
},
|
|
1279
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1280
|
+
username: { type: 'string', description: 'Alias local-part, e.g. billing' },
|
|
1298
1281
|
},
|
|
1299
|
-
required: [
|
|
1282
|
+
required: ['agentId', 'username'],
|
|
1300
1283
|
},
|
|
1301
1284
|
},
|
|
1302
1285
|
{
|
|
1303
|
-
name:
|
|
1304
|
-
description:
|
|
1286
|
+
name: 'delete_email_alias',
|
|
1287
|
+
description: 'Delete one active email alias from an agent',
|
|
1305
1288
|
input_schema: {
|
|
1306
|
-
type:
|
|
1289
|
+
type: 'object',
|
|
1307
1290
|
properties: {
|
|
1308
|
-
agentId: {
|
|
1309
|
-
|
|
1310
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1311
|
-
},
|
|
1312
|
-
emailAddress: {
|
|
1313
|
-
type: "string",
|
|
1314
|
-
description: "Full alias address to delete",
|
|
1315
|
-
},
|
|
1291
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1292
|
+
emailAddress: { type: 'string', description: 'Full alias address to delete' },
|
|
1316
1293
|
},
|
|
1317
|
-
required: [
|
|
1294
|
+
required: ['agentId', 'emailAddress'],
|
|
1318
1295
|
},
|
|
1319
1296
|
},
|
|
1320
1297
|
{
|
|
1321
|
-
name:
|
|
1322
|
-
description:
|
|
1298
|
+
name: 'get_renewal_status',
|
|
1299
|
+
description: 'Get renewal vault status for an agent, including exact next renewal amount, purchase snapshot, vault balance, shortfall, renewal date, and auto-renew state',
|
|
1323
1300
|
input_schema: {
|
|
1324
|
-
type:
|
|
1301
|
+
type: 'object',
|
|
1325
1302
|
properties: {
|
|
1326
|
-
agentId: {
|
|
1327
|
-
type: "string",
|
|
1328
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1329
|
-
},
|
|
1303
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1330
1304
|
},
|
|
1331
|
-
required: [
|
|
1305
|
+
required: ['agentId'],
|
|
1332
1306
|
},
|
|
1333
1307
|
},
|
|
1334
1308
|
{
|
|
1335
|
-
name:
|
|
1336
|
-
description:
|
|
1309
|
+
name: 'fund_renewal_vault',
|
|
1310
|
+
description: 'Deposit USDC from the connected wallet into one AgentID renewal vault. Anyone can fund; only the owner can withdraw or enable auto-renew. Call get_renewal_status first and normally use its shortfallUsdc value.',
|
|
1337
1311
|
input_schema: {
|
|
1338
|
-
type:
|
|
1312
|
+
type: 'object',
|
|
1339
1313
|
properties: {
|
|
1340
|
-
agentId: {
|
|
1341
|
-
type: "string",
|
|
1342
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1343
|
-
},
|
|
1314
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1344
1315
|
amountUsdc: {
|
|
1345
|
-
type:
|
|
1346
|
-
description:
|
|
1316
|
+
type: 'string',
|
|
1317
|
+
description: 'USDC amount to deposit, with up to 6 decimals.',
|
|
1347
1318
|
},
|
|
1348
1319
|
},
|
|
1349
|
-
required: [
|
|
1320
|
+
required: ['agentId', 'amountUsdc'],
|
|
1350
1321
|
},
|
|
1351
1322
|
},
|
|
1352
1323
|
{
|
|
1353
|
-
name:
|
|
1354
|
-
description:
|
|
1324
|
+
name: 'enable_auto_renew',
|
|
1325
|
+
description: 'Enable RenewalVault auto-renew for an agent. Requires the walletClient to be the AgentID NFT owner wallet.',
|
|
1355
1326
|
input_schema: {
|
|
1356
|
-
type:
|
|
1327
|
+
type: 'object',
|
|
1357
1328
|
properties: {
|
|
1358
|
-
agentId: {
|
|
1359
|
-
type: "string",
|
|
1360
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1361
|
-
},
|
|
1329
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1362
1330
|
},
|
|
1363
|
-
required: [
|
|
1331
|
+
required: ['agentId'],
|
|
1364
1332
|
},
|
|
1365
1333
|
},
|
|
1366
1334
|
{
|
|
1367
|
-
name:
|
|
1368
|
-
description:
|
|
1335
|
+
name: 'reconfigure_ssl',
|
|
1336
|
+
description: 'Rebuild the Cloudflare SaaS SSL hostname and sync the required Spaceship DNS validation records for an existing agent. Use this if SSL is pending, failed, or needs a refresh.',
|
|
1369
1337
|
input_schema: {
|
|
1370
|
-
type:
|
|
1338
|
+
type: 'object',
|
|
1371
1339
|
properties: {
|
|
1372
|
-
agentId: {
|
|
1373
|
-
type: "string",
|
|
1374
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1375
|
-
},
|
|
1340
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1376
1341
|
},
|
|
1377
|
-
required: [
|
|
1342
|
+
required: ['agentId'],
|
|
1378
1343
|
},
|
|
1379
1344
|
},
|
|
1380
1345
|
{
|
|
1381
|
-
name:
|
|
1382
|
-
description:
|
|
1346
|
+
name: 'set_registry_visibility',
|
|
1347
|
+
description: 'Hide or show an agent in the public AgentDomain registry. Hiding requires an active paid Premium Plan.',
|
|
1383
1348
|
input_schema: {
|
|
1384
|
-
type:
|
|
1349
|
+
type: 'object',
|
|
1385
1350
|
properties: {
|
|
1386
|
-
agentId: {
|
|
1387
|
-
type: "string",
|
|
1388
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1389
|
-
},
|
|
1351
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1390
1352
|
registryHidden: {
|
|
1391
|
-
type:
|
|
1392
|
-
description:
|
|
1353
|
+
type: 'boolean',
|
|
1354
|
+
description: 'true hides the agent from public registry/search; false makes it public',
|
|
1393
1355
|
},
|
|
1394
1356
|
},
|
|
1395
|
-
required: [
|
|
1357
|
+
required: ['agentId', 'registryHidden'],
|
|
1396
1358
|
},
|
|
1397
1359
|
},
|
|
1398
1360
|
{
|
|
1399
|
-
name:
|
|
1400
|
-
description:
|
|
1361
|
+
name: 'schedule_service_plan_renewal',
|
|
1362
|
+
description: 'Choose the exact Premium Plan SKU for the next identity renewal',
|
|
1401
1363
|
input_schema: {
|
|
1402
|
-
type:
|
|
1364
|
+
type: 'object',
|
|
1403
1365
|
properties: {
|
|
1404
|
-
agentId: {
|
|
1405
|
-
type: "string",
|
|
1406
|
-
description: "AgentDomain agent ID (UUID)",
|
|
1407
|
-
},
|
|
1366
|
+
agentId: { type: 'string', description: 'AgentDomain agent ID (UUID)' },
|
|
1408
1367
|
plan: {
|
|
1409
|
-
type:
|
|
1410
|
-
enum: [
|
|
1368
|
+
type: 'string',
|
|
1369
|
+
enum: ['included', 'starter', 'pro', 'enterprise'],
|
|
1411
1370
|
},
|
|
1412
1371
|
planSku: {
|
|
1413
|
-
type:
|
|
1414
|
-
description:
|
|
1372
|
+
type: 'string',
|
|
1373
|
+
description: 'Exact SKU, including Enterprise email volume tier',
|
|
1415
1374
|
},
|
|
1416
1375
|
},
|
|
1417
|
-
required: [
|
|
1376
|
+
required: ['agentId', 'plan', 'planSku'],
|
|
1418
1377
|
},
|
|
1419
1378
|
},
|
|
1420
1379
|
];
|
|
1421
1380
|
}
|
|
1422
1381
|
export async function runAgentDomainTool(ad, name, args) {
|
|
1423
1382
|
switch (name) {
|
|
1424
|
-
case
|
|
1425
|
-
return ad.checkAvailability(args.name, {
|
|
1426
|
-
|
|
1427
|
-
});
|
|
1428
|
-
case "quote_registration":
|
|
1383
|
+
case 'check_domain_availability':
|
|
1384
|
+
return ad.checkAvailability(args.name, { tld: args.tld ?? 'xyz' });
|
|
1385
|
+
case 'quote_registration':
|
|
1429
1386
|
return ad.quote({
|
|
1430
1387
|
preferredName: args.preferredName,
|
|
1431
|
-
tld: args.tld ??
|
|
1388
|
+
tld: args.tld ?? 'xyz',
|
|
1432
1389
|
registerBasename: args.registerBasename ?? true,
|
|
1433
1390
|
basenameLabel: args.basenameLabel,
|
|
1434
1391
|
registerEns: args.registerEns ?? false,
|
|
@@ -1438,11 +1395,10 @@ export async function runAgentDomainTool(ad, name, args) {
|
|
|
1438
1395
|
premiumPlan: args.premiumPlan,
|
|
1439
1396
|
years: args.years ?? 1,
|
|
1440
1397
|
});
|
|
1441
|
-
case
|
|
1398
|
+
case 'register_agent_identity':
|
|
1442
1399
|
return ad.register({
|
|
1443
1400
|
preferredName: args.preferredName,
|
|
1444
|
-
tld: (args.tld ??
|
|
1445
|
-
"xyz"),
|
|
1401
|
+
tld: (args.tld ?? 'xyz'),
|
|
1446
1402
|
registerBasename: args.registerBasename ?? true,
|
|
1447
1403
|
basenameLabel: args.basenameLabel,
|
|
1448
1404
|
registerEns: args.registerEns ?? false,
|
|
@@ -1456,14 +1412,14 @@ export async function runAgentDomainTool(ad, name, args) {
|
|
|
1456
1412
|
ownerAddress: args.ownerAddress,
|
|
1457
1413
|
wallet: args.wallet,
|
|
1458
1414
|
});
|
|
1459
|
-
case
|
|
1415
|
+
case 'search_agents':
|
|
1460
1416
|
return ad.search({
|
|
1461
1417
|
q: args.q,
|
|
1462
1418
|
framework: args.framework,
|
|
1463
1419
|
capability: args.capability,
|
|
1464
1420
|
limit: args.limit ?? 20,
|
|
1465
1421
|
});
|
|
1466
|
-
case
|
|
1422
|
+
case 'send_agent_email':
|
|
1467
1423
|
return ad.sendEmail(args.agentId, {
|
|
1468
1424
|
to: args.to,
|
|
1469
1425
|
fromAddress: args.fromAddress,
|
|
@@ -1471,46 +1427,44 @@ export async function runAgentDomainTool(ad, name, args) {
|
|
|
1471
1427
|
text: args.text,
|
|
1472
1428
|
replyTo: args.replyTo,
|
|
1473
1429
|
});
|
|
1474
|
-
case
|
|
1475
|
-
return ad.listEmail(args.agentId, {
|
|
1476
|
-
|
|
1477
|
-
});
|
|
1478
|
-
case "delete_agent_email":
|
|
1430
|
+
case 'list_agent_email':
|
|
1431
|
+
return ad.listEmail(args.agentId, { limit: args.limit ?? 20 });
|
|
1432
|
+
case 'delete_agent_email':
|
|
1479
1433
|
return ad.deleteEmailMessage(args.agentId, args.messageId);
|
|
1480
|
-
case
|
|
1434
|
+
case 'update_primary_email':
|
|
1481
1435
|
return ad.updatePrimaryEmail(args.agentId, args.username);
|
|
1482
|
-
case
|
|
1436
|
+
case 'create_email_alias':
|
|
1483
1437
|
return ad.createEmailAlias(args.agentId, args.username);
|
|
1484
|
-
case
|
|
1438
|
+
case 'delete_email_alias':
|
|
1485
1439
|
return ad.deleteEmailAlias(args.agentId, args.emailAddress);
|
|
1486
|
-
case
|
|
1440
|
+
case 'list_dns_records':
|
|
1487
1441
|
return ad.listDnsRecords(args.agentId);
|
|
1488
|
-
case
|
|
1442
|
+
case 'create_dns_record':
|
|
1489
1443
|
return ad.createDnsRecord(args.agentId, readDnsRecordArgs(args));
|
|
1490
|
-
case
|
|
1444
|
+
case 'update_dns_record':
|
|
1491
1445
|
return ad.updateDnsRecord(args.agentId, args.recordId, readDnsRecordArgs(args));
|
|
1492
|
-
case
|
|
1446
|
+
case 'delete_dns_record':
|
|
1493
1447
|
return ad.deleteDnsRecord(args.agentId, args.recordId);
|
|
1494
|
-
case
|
|
1448
|
+
case 'get_renewal_status':
|
|
1495
1449
|
return ad.getRenewalStatus(args.agentId);
|
|
1496
|
-
case
|
|
1450
|
+
case 'fund_renewal_vault':
|
|
1497
1451
|
return ad.fundRenewalVault(args.agentId, args.amountUsdc);
|
|
1498
|
-
case
|
|
1452
|
+
case 'withdraw_renewal_vault':
|
|
1499
1453
|
return ad.withdrawFromVault(args.agentId, args.amountUsdc);
|
|
1500
|
-
case
|
|
1454
|
+
case 'enable_auto_renew':
|
|
1501
1455
|
return ad.setAutoRenew(args.agentId, true);
|
|
1502
|
-
case
|
|
1456
|
+
case 'reconfigure_ssl':
|
|
1503
1457
|
return ad.reconfigureSsl(args.agentId);
|
|
1504
|
-
case
|
|
1458
|
+
case 'get_service_plan':
|
|
1505
1459
|
return ad.getServicePlan(args.agentId);
|
|
1506
|
-
case
|
|
1460
|
+
case 'purchase_service_plan':
|
|
1507
1461
|
return ad.purchaseServicePlan({
|
|
1508
1462
|
agentId: args.agentId,
|
|
1509
1463
|
plan: args.plan,
|
|
1510
1464
|
});
|
|
1511
|
-
case
|
|
1465
|
+
case 'set_registry_visibility':
|
|
1512
1466
|
return ad.setRegistryVisibility(args.agentId, Boolean(args.registryHidden ?? args.hidden));
|
|
1513
|
-
case
|
|
1467
|
+
case 'schedule_service_plan_renewal':
|
|
1514
1468
|
return ad.scheduleServicePlanRenewal(args.agentId, {
|
|
1515
1469
|
plan: args.plan,
|
|
1516
1470
|
planSku: args.planSku,
|
|
@@ -1520,7 +1474,7 @@ export async function runAgentDomainTool(ad, name, args) {
|
|
|
1520
1474
|
}
|
|
1521
1475
|
}
|
|
1522
1476
|
function readDnsRecordArgs(args) {
|
|
1523
|
-
const record = args.record && typeof args.record ===
|
|
1477
|
+
const record = args.record && typeof args.record === 'object'
|
|
1524
1478
|
? args.record
|
|
1525
1479
|
: args;
|
|
1526
1480
|
return {
|
|
@@ -1534,18 +1488,18 @@ function readDnsRecordArgs(args) {
|
|
|
1534
1488
|
}
|
|
1535
1489
|
function assertDnsRevision(value) {
|
|
1536
1490
|
if (!/^[a-f0-9]{64}$/i.test(value)) {
|
|
1537
|
-
throw new Error(
|
|
1491
|
+
throw new Error('DNS apply requires the 64-character baseRevision returned by a fresh preview.');
|
|
1538
1492
|
}
|
|
1539
1493
|
}
|
|
1540
1494
|
export function formatAgentDomainToolResult(result) {
|
|
1541
|
-
return typeof result ===
|
|
1495
|
+
return typeof result === 'string' ? result : JSON.stringify(result, null, 2);
|
|
1542
1496
|
}
|
|
1543
1497
|
async function responseError(res) {
|
|
1544
1498
|
try {
|
|
1545
1499
|
const body = (await res.json());
|
|
1546
1500
|
const detail = body.message ?? body.error;
|
|
1547
1501
|
const code = body.code ?? body.error;
|
|
1548
|
-
const retryAfter = body.details && typeof body.details ===
|
|
1502
|
+
const retryAfter = body.details && typeof body.details === 'object'
|
|
1549
1503
|
? body.details.retryAfterSeconds
|
|
1550
1504
|
: undefined;
|
|
1551
1505
|
const detailsMessage = detailsToMessage(body.details);
|
|
@@ -1558,7 +1512,7 @@ async function responseError(res) {
|
|
|
1558
1512
|
parts.push(`: ${detailsMessage}`);
|
|
1559
1513
|
if (retryAfter)
|
|
1560
1514
|
parts.push(`(retry after ${retryAfter}s)`);
|
|
1561
|
-
return parts.join(
|
|
1515
|
+
return parts.join('');
|
|
1562
1516
|
}
|
|
1563
1517
|
catch {
|
|
1564
1518
|
return `HTTP ${res.status}`;
|
|
@@ -1567,14 +1521,14 @@ async function responseError(res) {
|
|
|
1567
1521
|
function detailsToMessage(details) {
|
|
1568
1522
|
if (!details)
|
|
1569
1523
|
return null;
|
|
1570
|
-
if (typeof details ===
|
|
1524
|
+
if (typeof details === 'string')
|
|
1571
1525
|
return details;
|
|
1572
|
-
if (typeof details !==
|
|
1526
|
+
if (typeof details !== 'object')
|
|
1573
1527
|
return String(details);
|
|
1574
1528
|
const record = details;
|
|
1575
|
-
if (typeof record.message ===
|
|
1529
|
+
if (typeof record.message === 'string')
|
|
1576
1530
|
return record.message;
|
|
1577
|
-
if (typeof record.error ===
|
|
1531
|
+
if (typeof record.error === 'string')
|
|
1578
1532
|
return record.error;
|
|
1579
1533
|
try {
|
|
1580
1534
|
return JSON.stringify(details);
|