@agentidentity/sdk 0.1.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/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/client.d.ts +788 -0
- package/dist/client.js +985 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.js +55 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/vault-crypto.d.ts +11 -0
- package/dist/vault-crypto.js +55 -0
- package/package.json +57 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,788 @@
|
|
|
1
|
+
import type { VaultKeypair } from "./vault-crypto.js";
|
|
2
|
+
export type { VaultCiphertext, VaultKeypair } from "./vault-crypto.js";
|
|
3
|
+
export { AidApiError, AidConnectionError } from "./errors.js";
|
|
4
|
+
export interface AgentClientOptions {
|
|
5
|
+
/** Base URL of the API, e.g. `https://api.agent-identity.dev`. No trailing slash needed. */
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/** An org-admin or agent-scoped API key. */
|
|
8
|
+
apiKey: string;
|
|
9
|
+
/** Override the global `fetch` — useful for tests, proxies, or custom agents. */
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
/**
|
|
12
|
+
* Per-attempt request deadline in milliseconds. Defaults to 30s. Set `0` to disable.
|
|
13
|
+
* The long-polling `events.wait`/`events.subscribe` calls set their own, longer, deadline.
|
|
14
|
+
*/
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
/**
|
|
17
|
+
* How many times to retry a failed request. Defaults to 2 (three attempts total).
|
|
18
|
+
*
|
|
19
|
+
* Retries apply to rate limits (429), errors the server flags `retryable`, and — for
|
|
20
|
+
* idempotent methods only — network failures and 5xx. A `POST` that fails mid-flight is
|
|
21
|
+
* never replayed automatically, since it may already have been applied.
|
|
22
|
+
*/
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface CreateIdentityInput {
|
|
26
|
+
handle: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
}
|
|
29
|
+
export interface IdentitySummary {
|
|
30
|
+
id: string;
|
|
31
|
+
handle: string;
|
|
32
|
+
status: string;
|
|
33
|
+
mailboxAddress: string;
|
|
34
|
+
vaultPublicKey: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface IdentityDetail {
|
|
37
|
+
id: string;
|
|
38
|
+
handle: string;
|
|
39
|
+
displayName: string;
|
|
40
|
+
status: string;
|
|
41
|
+
vaultPublicKey: string | null;
|
|
42
|
+
}
|
|
43
|
+
export interface AttachmentInput {
|
|
44
|
+
filename: string;
|
|
45
|
+
contentType: string;
|
|
46
|
+
content: Uint8Array;
|
|
47
|
+
contentId?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface Attachment {
|
|
50
|
+
id: string;
|
|
51
|
+
filename: string;
|
|
52
|
+
contentType: string;
|
|
53
|
+
sizeBytes: number;
|
|
54
|
+
sha256: string;
|
|
55
|
+
contentId: string | null;
|
|
56
|
+
}
|
|
57
|
+
export interface SendMailInput {
|
|
58
|
+
identityId: string;
|
|
59
|
+
to: string | string[];
|
|
60
|
+
cc?: string[];
|
|
61
|
+
subject?: string;
|
|
62
|
+
text?: string;
|
|
63
|
+
html?: string;
|
|
64
|
+
inReplyToMessageId?: string;
|
|
65
|
+
attachments?: AttachmentInput[];
|
|
66
|
+
idempotencyKey?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface MailParticipant {
|
|
69
|
+
address: string;
|
|
70
|
+
name: string | null;
|
|
71
|
+
}
|
|
72
|
+
export interface MailMessage {
|
|
73
|
+
id: string;
|
|
74
|
+
threadId: string;
|
|
75
|
+
direction: string;
|
|
76
|
+
status: string;
|
|
77
|
+
lastError: string | null;
|
|
78
|
+
providerMessageId: string | null;
|
|
79
|
+
from: MailParticipant[];
|
|
80
|
+
to: MailParticipant[];
|
|
81
|
+
cc: MailParticipant[];
|
|
82
|
+
subject: string | null;
|
|
83
|
+
textBody: string | null;
|
|
84
|
+
htmlBody: string | null;
|
|
85
|
+
folder: string | null;
|
|
86
|
+
createdAt: string;
|
|
87
|
+
}
|
|
88
|
+
export interface DraftMailInput {
|
|
89
|
+
identityId: string;
|
|
90
|
+
to?: string[];
|
|
91
|
+
cc?: string[];
|
|
92
|
+
subject?: string;
|
|
93
|
+
text?: string;
|
|
94
|
+
html?: string;
|
|
95
|
+
inReplyToMessageId?: string;
|
|
96
|
+
attachments?: AttachmentInput[];
|
|
97
|
+
}
|
|
98
|
+
export interface MailThread {
|
|
99
|
+
id: string;
|
|
100
|
+
subject: string | null;
|
|
101
|
+
messages: MailMessage[];
|
|
102
|
+
}
|
|
103
|
+
export interface WaitForEventInput<T extends AidEventType | string = string> {
|
|
104
|
+
/** The event type to wait for, e.g. `"mail.received"`. */
|
|
105
|
+
type: T;
|
|
106
|
+
identityId?: string;
|
|
107
|
+
aggregateType?: string;
|
|
108
|
+
aggregateId?: string;
|
|
109
|
+
filter?: {
|
|
110
|
+
threadId?: string;
|
|
111
|
+
};
|
|
112
|
+
since?: Date | string;
|
|
113
|
+
timeoutMs?: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Payload shape for each event type the platform emits, keyed by `type`.
|
|
117
|
+
*
|
|
118
|
+
* This is the discriminant for {@link AidEvent}: narrowing on `event.type` narrows
|
|
119
|
+
* `event.payload` with it, so you never have to cast.
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* if (event.type === "mail.received") {
|
|
123
|
+
* event.payload.subject; // string | null — checked, not asserted
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export interface AidEventPayloadMap {
|
|
128
|
+
/** A message was accepted by the provider for delivery. */
|
|
129
|
+
"mail.sent": {
|
|
130
|
+
messageId: string;
|
|
131
|
+
threadId: string;
|
|
132
|
+
};
|
|
133
|
+
/** Inbound mail landed in an identity's mailbox. */
|
|
134
|
+
"mail.received": {
|
|
135
|
+
messageId: string;
|
|
136
|
+
threadId: string;
|
|
137
|
+
from: string | null;
|
|
138
|
+
subject: string | null;
|
|
139
|
+
};
|
|
140
|
+
/** The provider confirmed delivery to the recipient's server. */
|
|
141
|
+
"mail.delivered": {
|
|
142
|
+
messageId: string;
|
|
143
|
+
threadId: string;
|
|
144
|
+
detail?: string;
|
|
145
|
+
};
|
|
146
|
+
/** The recipient's server rejected the message. `detail` carries the provider's reason. */
|
|
147
|
+
"mail.bounced": {
|
|
148
|
+
messageId: string;
|
|
149
|
+
threadId: string;
|
|
150
|
+
detail?: string;
|
|
151
|
+
};
|
|
152
|
+
/** The recipient marked the message as spam. */
|
|
153
|
+
"mail.complained": {
|
|
154
|
+
messageId: string;
|
|
155
|
+
threadId: string;
|
|
156
|
+
detail?: string;
|
|
157
|
+
};
|
|
158
|
+
/** Another agent opened a task against one of your identities. */
|
|
159
|
+
"a2a.task.created": {
|
|
160
|
+
taskId: string;
|
|
161
|
+
callerIdentityId: string;
|
|
162
|
+
message: string;
|
|
163
|
+
};
|
|
164
|
+
/** A task you opened changed state. */
|
|
165
|
+
"a2a.task.updated": {
|
|
166
|
+
taskId: string;
|
|
167
|
+
state: string;
|
|
168
|
+
result: string | null;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** Every event type with a known payload shape. */
|
|
172
|
+
export type AidEventType = keyof AidEventPayloadMap;
|
|
173
|
+
interface AidEventBase {
|
|
174
|
+
id: string;
|
|
175
|
+
identityId: string | null;
|
|
176
|
+
aggregateType: string | null;
|
|
177
|
+
aggregateId: string | null;
|
|
178
|
+
createdAt: string;
|
|
179
|
+
}
|
|
180
|
+
/** An event of one specific known type, with its payload narrowed to match. */
|
|
181
|
+
export interface KnownAidEvent<T extends AidEventType = AidEventType> extends AidEventBase {
|
|
182
|
+
type: T;
|
|
183
|
+
payload: AidEventPayloadMap[T];
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* An event whose `type` this SDK version doesn't know about yet. Servers may emit new event
|
|
187
|
+
* types before the SDK is updated, so this stays open rather than making a newer server's
|
|
188
|
+
* events unrepresentable — but the payload is unknown until you check it.
|
|
189
|
+
*/
|
|
190
|
+
export interface UnknownAidEvent extends AidEventBase {
|
|
191
|
+
type: Exclude<string, AidEventType>;
|
|
192
|
+
payload: Record<string, unknown>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* An event read from the event log. Discriminated on `type`: comparing against a known type
|
|
196
|
+
* narrows `payload` to the matching shape in {@link AidEventPayloadMap}.
|
|
197
|
+
*/
|
|
198
|
+
export type AidEvent = {
|
|
199
|
+
[T in AidEventType]: KnownAidEvent<T>;
|
|
200
|
+
}[AidEventType] | UnknownAidEvent;
|
|
201
|
+
/** The result of {@link AgentClient.events.wait}, narrowed to the type you waited for. */
|
|
202
|
+
export interface WaitForEventResult<T extends AidEventType | string = string> {
|
|
203
|
+
event: (T extends AidEventType ? KnownAidEvent<T> : AidEvent) | null;
|
|
204
|
+
/** True when the server's long-poll window elapsed with no matching event. */
|
|
205
|
+
timedOut: boolean;
|
|
206
|
+
}
|
|
207
|
+
/** Options for {@link AgentClient.events.subscribe}. */
|
|
208
|
+
export interface SubscribeInput<T extends AidEventType | string = string> extends Omit<WaitForEventInput<T>, "timeoutMs"> {
|
|
209
|
+
/**
|
|
210
|
+
* How long each underlying long-poll waits before the server reports a timeout and the
|
|
211
|
+
* iterator quietly re-polls. Lower values mean more requests, not missed events.
|
|
212
|
+
* Defaults to 25s.
|
|
213
|
+
*/
|
|
214
|
+
pollTimeoutMs?: number;
|
|
215
|
+
/** Stops the iterator. The `for await` loop exits normally rather than throwing. */
|
|
216
|
+
signal?: AbortSignal;
|
|
217
|
+
/**
|
|
218
|
+
* Called when a poll fails, before the iterator backs off and retries. Return `false` to
|
|
219
|
+
* stop instead of retrying. Without a handler, transient failures are retried forever.
|
|
220
|
+
*/
|
|
221
|
+
onError?: (error: unknown, attempt: number) => boolean | void;
|
|
222
|
+
}
|
|
223
|
+
export interface CreateOrganizationInput {
|
|
224
|
+
name: string;
|
|
225
|
+
slug: string;
|
|
226
|
+
}
|
|
227
|
+
export interface OrganizationBootstrap {
|
|
228
|
+
id: string;
|
|
229
|
+
slug: string;
|
|
230
|
+
name: string;
|
|
231
|
+
adminApiKey: string;
|
|
232
|
+
}
|
|
233
|
+
export interface WhoAmI {
|
|
234
|
+
actorType: string;
|
|
235
|
+
actorId: string;
|
|
236
|
+
orgId: string;
|
|
237
|
+
orgSlug: string;
|
|
238
|
+
orgName: string;
|
|
239
|
+
}
|
|
240
|
+
export interface ApiKeySummary {
|
|
241
|
+
id: string;
|
|
242
|
+
identityId: string | null;
|
|
243
|
+
name: string;
|
|
244
|
+
keyPrefix: string;
|
|
245
|
+
scopes: string[];
|
|
246
|
+
revokedAt: string | null;
|
|
247
|
+
createdAt: string;
|
|
248
|
+
}
|
|
249
|
+
export interface CreateApiKeyInput {
|
|
250
|
+
name: string;
|
|
251
|
+
identityId?: string;
|
|
252
|
+
}
|
|
253
|
+
export interface CreatedApiKey {
|
|
254
|
+
id: string;
|
|
255
|
+
key: string;
|
|
256
|
+
keyPrefix: string;
|
|
257
|
+
}
|
|
258
|
+
export interface WebhookEndpoint {
|
|
259
|
+
id: string;
|
|
260
|
+
identityId: string | null;
|
|
261
|
+
url: string;
|
|
262
|
+
/** Empty = every event type. Non-empty = only these types are delivered here. */
|
|
263
|
+
eventTypes: string[];
|
|
264
|
+
status: string;
|
|
265
|
+
createdAt: string;
|
|
266
|
+
}
|
|
267
|
+
export interface CreateWebhookEndpointInput {
|
|
268
|
+
url: string;
|
|
269
|
+
/** Scope delivery to one identity's events only — omit for org-wide. */
|
|
270
|
+
identityId?: string;
|
|
271
|
+
/** Only deliver these event types — omit (or empty) for every event type. */
|
|
272
|
+
eventTypes?: string[];
|
|
273
|
+
}
|
|
274
|
+
export interface CreatedWebhookEndpoint {
|
|
275
|
+
id: string;
|
|
276
|
+
identityId: string | null;
|
|
277
|
+
url: string;
|
|
278
|
+
secret: string;
|
|
279
|
+
eventTypes: string[];
|
|
280
|
+
createdAt: string;
|
|
281
|
+
}
|
|
282
|
+
export interface WebhookDelivery {
|
|
283
|
+
id: string;
|
|
284
|
+
webhookEndpointId: string;
|
|
285
|
+
endpointUrl: string;
|
|
286
|
+
eventId: string;
|
|
287
|
+
eventType: string;
|
|
288
|
+
attemptCount: number;
|
|
289
|
+
status: string;
|
|
290
|
+
nextAttemptAt: string | null;
|
|
291
|
+
lastError: string | null;
|
|
292
|
+
deliveredAt: string | null;
|
|
293
|
+
eventCreatedAt: string;
|
|
294
|
+
}
|
|
295
|
+
export interface VaultSecretSummary {
|
|
296
|
+
id: string;
|
|
297
|
+
identityId: string;
|
|
298
|
+
name: string;
|
|
299
|
+
version: number;
|
|
300
|
+
status: string;
|
|
301
|
+
createdAt: string;
|
|
302
|
+
}
|
|
303
|
+
export interface CreateVaultSecretInput {
|
|
304
|
+
name: string;
|
|
305
|
+
identityId: string;
|
|
306
|
+
plaintext: string;
|
|
307
|
+
}
|
|
308
|
+
export interface CreateLeaseInput {
|
|
309
|
+
operation: string;
|
|
310
|
+
ttlSeconds?: number;
|
|
311
|
+
identityId?: string;
|
|
312
|
+
}
|
|
313
|
+
export interface CreatedLease {
|
|
314
|
+
leaseId: string;
|
|
315
|
+
operation: string;
|
|
316
|
+
expiresAt: string;
|
|
317
|
+
}
|
|
318
|
+
export interface ContactEmail {
|
|
319
|
+
value: string;
|
|
320
|
+
label: string | null;
|
|
321
|
+
}
|
|
322
|
+
export interface ContactPhone {
|
|
323
|
+
value: string;
|
|
324
|
+
label: string | null;
|
|
325
|
+
}
|
|
326
|
+
export interface ContactWebsite {
|
|
327
|
+
value: string;
|
|
328
|
+
label: string | null;
|
|
329
|
+
}
|
|
330
|
+
export interface ContactAddress {
|
|
331
|
+
label: string | null;
|
|
332
|
+
street: string | null;
|
|
333
|
+
city: string | null;
|
|
334
|
+
state: string | null;
|
|
335
|
+
postalCode: string | null;
|
|
336
|
+
country: string | null;
|
|
337
|
+
}
|
|
338
|
+
export interface ContactDate {
|
|
339
|
+
label: string | null;
|
|
340
|
+
date: string;
|
|
341
|
+
}
|
|
342
|
+
export interface ContactCustomField {
|
|
343
|
+
label: string;
|
|
344
|
+
value: string;
|
|
345
|
+
}
|
|
346
|
+
export interface Contact {
|
|
347
|
+
id: string;
|
|
348
|
+
prefix: string | null;
|
|
349
|
+
firstName: string | null;
|
|
350
|
+
middleName: string | null;
|
|
351
|
+
lastName: string | null;
|
|
352
|
+
suffix: string | null;
|
|
353
|
+
displayName: string | null;
|
|
354
|
+
company: string | null;
|
|
355
|
+
jobTitle: string | null;
|
|
356
|
+
emails: ContactEmail[];
|
|
357
|
+
phones: ContactPhone[];
|
|
358
|
+
websites: ContactWebsite[];
|
|
359
|
+
addresses: ContactAddress[];
|
|
360
|
+
dates: ContactDate[];
|
|
361
|
+
customFields: ContactCustomField[];
|
|
362
|
+
notes: string | null;
|
|
363
|
+
status: "suggested" | "saved";
|
|
364
|
+
sourceIdentityId: string | null;
|
|
365
|
+
createdAt: string;
|
|
366
|
+
updatedAt: string;
|
|
367
|
+
}
|
|
368
|
+
export interface ContactWriteInput {
|
|
369
|
+
prefix?: string | null;
|
|
370
|
+
firstName?: string | null;
|
|
371
|
+
middleName?: string | null;
|
|
372
|
+
lastName?: string | null;
|
|
373
|
+
suffix?: string | null;
|
|
374
|
+
displayName?: string | null;
|
|
375
|
+
company?: string | null;
|
|
376
|
+
jobTitle?: string | null;
|
|
377
|
+
emails?: ContactEmail[];
|
|
378
|
+
phones?: ContactPhone[];
|
|
379
|
+
websites?: ContactWebsite[];
|
|
380
|
+
addresses?: ContactAddress[];
|
|
381
|
+
dates?: ContactDate[];
|
|
382
|
+
customFields?: ContactCustomField[];
|
|
383
|
+
notes?: string | null;
|
|
384
|
+
}
|
|
385
|
+
export type CreateContactInput = ContactWriteInput;
|
|
386
|
+
export type UpdateContactInput = ContactWriteInput;
|
|
387
|
+
export interface ContactRule {
|
|
388
|
+
id: string;
|
|
389
|
+
identityId: string | null;
|
|
390
|
+
channel: string;
|
|
391
|
+
matchAddress: string;
|
|
392
|
+
action: "allow" | "block";
|
|
393
|
+
createdAt: string;
|
|
394
|
+
}
|
|
395
|
+
export interface CreateContactRuleInput {
|
|
396
|
+
identityId?: string;
|
|
397
|
+
matchAddress: string;
|
|
398
|
+
action: "allow" | "block";
|
|
399
|
+
}
|
|
400
|
+
export interface A2ATrustRule {
|
|
401
|
+
id: string;
|
|
402
|
+
identityId: string;
|
|
403
|
+
peerIdentityId: string;
|
|
404
|
+
createdAt: string;
|
|
405
|
+
}
|
|
406
|
+
export interface CreateA2ATrustRuleInput {
|
|
407
|
+
identityId: string;
|
|
408
|
+
peerIdentityId: string;
|
|
409
|
+
}
|
|
410
|
+
/** A2A task lifecycle state — matches the real Agent2Agent protocol's state machine. */
|
|
411
|
+
export type A2ATaskState = "submitted" | "working" | "input_required" | "auth_required" | "completed" | "failed" | "canceled" | "rejected";
|
|
412
|
+
export interface A2ATask {
|
|
413
|
+
id: string;
|
|
414
|
+
targetIdentityId: string;
|
|
415
|
+
callerIdentityId: string;
|
|
416
|
+
state: A2ATaskState;
|
|
417
|
+
message: string;
|
|
418
|
+
result: string | null;
|
|
419
|
+
createdAt: string;
|
|
420
|
+
updatedAt: string;
|
|
421
|
+
}
|
|
422
|
+
export interface SendA2ATaskInput {
|
|
423
|
+
targetIdentityId: string;
|
|
424
|
+
message: string;
|
|
425
|
+
}
|
|
426
|
+
export interface UpdateA2ATaskInput {
|
|
427
|
+
state: A2ATaskState;
|
|
428
|
+
result?: string;
|
|
429
|
+
}
|
|
430
|
+
export interface AgentCardSkill {
|
|
431
|
+
id: string;
|
|
432
|
+
name: string;
|
|
433
|
+
}
|
|
434
|
+
export interface AgentCard {
|
|
435
|
+
name: string;
|
|
436
|
+
description: string;
|
|
437
|
+
supportedInterfaces: {
|
|
438
|
+
url: string;
|
|
439
|
+
protocolBinding: string;
|
|
440
|
+
protocolVersion: string;
|
|
441
|
+
}[];
|
|
442
|
+
provider: {
|
|
443
|
+
url: string;
|
|
444
|
+
organization: string;
|
|
445
|
+
};
|
|
446
|
+
version: string;
|
|
447
|
+
capabilities: {
|
|
448
|
+
streaming: boolean;
|
|
449
|
+
pushNotifications: boolean;
|
|
450
|
+
};
|
|
451
|
+
securitySchemes: Record<string, unknown>;
|
|
452
|
+
securityRequirements: Record<string, unknown>[];
|
|
453
|
+
skills: AgentCardSkill[];
|
|
454
|
+
defaultInputModes: string[];
|
|
455
|
+
defaultOutputModes: string[];
|
|
456
|
+
}
|
|
457
|
+
export interface A2AAgentOverview {
|
|
458
|
+
identityId: string;
|
|
459
|
+
handle: string;
|
|
460
|
+
enabled: boolean;
|
|
461
|
+
skills: string[];
|
|
462
|
+
listed: boolean;
|
|
463
|
+
inboundTasks: number;
|
|
464
|
+
outboundTasks: number;
|
|
465
|
+
}
|
|
466
|
+
export interface A2ADirectoryEntry {
|
|
467
|
+
identityId: string;
|
|
468
|
+
handle: string;
|
|
469
|
+
orgName: string;
|
|
470
|
+
skills: string[];
|
|
471
|
+
}
|
|
472
|
+
export interface A2AInvitation {
|
|
473
|
+
id: string;
|
|
474
|
+
fromIdentityId: string;
|
|
475
|
+
toIdentityId: string;
|
|
476
|
+
status: string;
|
|
477
|
+
message: string | null;
|
|
478
|
+
createdAt: string;
|
|
479
|
+
respondedAt: string | null;
|
|
480
|
+
}
|
|
481
|
+
export interface A2AInvitationWithContext extends A2AInvitation {
|
|
482
|
+
fromHandle: string;
|
|
483
|
+
toHandle: string;
|
|
484
|
+
direction: "sent" | "received";
|
|
485
|
+
}
|
|
486
|
+
export interface CreateA2AInvitationInput {
|
|
487
|
+
fromIdentityId: string;
|
|
488
|
+
toIdentityId: string;
|
|
489
|
+
message?: string;
|
|
490
|
+
}
|
|
491
|
+
export interface DomainVerification {
|
|
492
|
+
recordType: "TXT";
|
|
493
|
+
recordName: string;
|
|
494
|
+
recordValue: string;
|
|
495
|
+
}
|
|
496
|
+
export interface Domain {
|
|
497
|
+
id: string;
|
|
498
|
+
domain: string;
|
|
499
|
+
status: "pending" | "verified";
|
|
500
|
+
verification: DomainVerification;
|
|
501
|
+
verifiedAt: string | null;
|
|
502
|
+
createdAt: string;
|
|
503
|
+
}
|
|
504
|
+
export interface DeliverabilityRecord {
|
|
505
|
+
purpose: "spf" | "dkim" | "dmarc";
|
|
506
|
+
recordType: "TXT";
|
|
507
|
+
recordName: string;
|
|
508
|
+
recordValue: string | null;
|
|
509
|
+
note: string;
|
|
510
|
+
}
|
|
511
|
+
export interface DeliverabilityGuidance {
|
|
512
|
+
providerKind: string;
|
|
513
|
+
records: DeliverabilityRecord[];
|
|
514
|
+
}
|
|
515
|
+
export interface ProviderAccount {
|
|
516
|
+
id: string;
|
|
517
|
+
kind: string;
|
|
518
|
+
status: "active" | "disabled";
|
|
519
|
+
createdAt: string;
|
|
520
|
+
}
|
|
521
|
+
export interface CreateProviderAccountInput {
|
|
522
|
+
kind: string;
|
|
523
|
+
config: Record<string, unknown>;
|
|
524
|
+
}
|
|
525
|
+
export interface ProviderHealth {
|
|
526
|
+
healthy: boolean;
|
|
527
|
+
detail: string | null;
|
|
528
|
+
source: "custom" | "default";
|
|
529
|
+
}
|
|
530
|
+
export interface IdentitySuspension {
|
|
531
|
+
id: string;
|
|
532
|
+
identityId: string;
|
|
533
|
+
reason: string;
|
|
534
|
+
suspendedBy: string;
|
|
535
|
+
suspendedAt: string;
|
|
536
|
+
reinstatedAt: string | null;
|
|
537
|
+
reinstatedBy: string | null;
|
|
538
|
+
}
|
|
539
|
+
export interface VaultLease {
|
|
540
|
+
id: string;
|
|
541
|
+
secretId: string;
|
|
542
|
+
secretName: string;
|
|
543
|
+
identityId: string;
|
|
544
|
+
identityHandle: string;
|
|
545
|
+
operation: string;
|
|
546
|
+
expiresAt: string;
|
|
547
|
+
consumedAt: string | null;
|
|
548
|
+
createdAt: string;
|
|
549
|
+
}
|
|
550
|
+
export interface Tunnel {
|
|
551
|
+
id: string;
|
|
552
|
+
identityId: string;
|
|
553
|
+
hostname: string;
|
|
554
|
+
status: string;
|
|
555
|
+
connected: boolean;
|
|
556
|
+
edgeUrl: string;
|
|
557
|
+
lastConnectedAt: string | null;
|
|
558
|
+
lastDisconnectedAt: string | null;
|
|
559
|
+
createdAt: string;
|
|
560
|
+
}
|
|
561
|
+
export interface CreateTunnelInput {
|
|
562
|
+
hostname?: string;
|
|
563
|
+
}
|
|
564
|
+
export declare function createOrganization(baseUrl: string, input: CreateOrganizationInput, fetchImpl?: typeof fetch): Promise<OrganizationBootstrap>;
|
|
565
|
+
export interface SignUpInput {
|
|
566
|
+
orgName: string;
|
|
567
|
+
orgSlug: string;
|
|
568
|
+
email: string;
|
|
569
|
+
password: string;
|
|
570
|
+
}
|
|
571
|
+
export interface LogInInput {
|
|
572
|
+
email: string;
|
|
573
|
+
password: string;
|
|
574
|
+
}
|
|
575
|
+
export interface AuthSession {
|
|
576
|
+
apiKey: string;
|
|
577
|
+
orgId: string;
|
|
578
|
+
orgName: string;
|
|
579
|
+
orgSlug: string;
|
|
580
|
+
}
|
|
581
|
+
export declare function signUp(baseUrl: string, input: SignUpInput, fetchImpl?: typeof fetch): Promise<AuthSession>;
|
|
582
|
+
export declare function logIn(baseUrl: string, input: LogInInput, fetchImpl?: typeof fetch): Promise<AuthSession>;
|
|
583
|
+
export declare class AgentClient {
|
|
584
|
+
private readonly baseUrl;
|
|
585
|
+
private readonly apiKey;
|
|
586
|
+
private readonly fetchImpl;
|
|
587
|
+
private readonly timeoutMs;
|
|
588
|
+
private readonly maxRetries;
|
|
589
|
+
readonly identities: {
|
|
590
|
+
create(input: CreateIdentityInput): Promise<IdentitySummary>;
|
|
591
|
+
list(): Promise<IdentitySummary[]>;
|
|
592
|
+
get(id: string): Promise<IdentityDetail>;
|
|
593
|
+
suspend(id: string, reason: string): Promise<void>;
|
|
594
|
+
reinstate(id: string): Promise<void>;
|
|
595
|
+
listSuspensions(): Promise<IdentitySuspension[]>;
|
|
596
|
+
};
|
|
597
|
+
readonly mail: {
|
|
598
|
+
send(input: SendMailInput): Promise<MailMessage>;
|
|
599
|
+
listMessages(identityId: string): Promise<MailMessage[]>;
|
|
600
|
+
getThread(identityId: string, threadId: string): Promise<MailThread>;
|
|
601
|
+
saveDraft(input: DraftMailInput): Promise<MailMessage>;
|
|
602
|
+
listDrafts(identityId: string): Promise<MailMessage[]>;
|
|
603
|
+
updateDraft(identityId: string, messageId: string, input: Omit<DraftMailInput, "identityId" | "inReplyToMessageId">): Promise<MailMessage>;
|
|
604
|
+
deleteDraft(identityId: string, messageId: string): Promise<void>;
|
|
605
|
+
sendDraft(identityId: string, messageId: string): Promise<MailMessage>;
|
|
606
|
+
markSpam(identityId: string, messageId: string): Promise<MailMessage>;
|
|
607
|
+
unmarkSpam(identityId: string, messageId: string): Promise<MailMessage>;
|
|
608
|
+
listAttachments(identityId: string, messageId: string): Promise<Attachment[]>;
|
|
609
|
+
downloadAttachment(identityId: string, messageId: string, attachmentId: string): Promise<{
|
|
610
|
+
contentType: string;
|
|
611
|
+
filename: string;
|
|
612
|
+
bytes: Uint8Array;
|
|
613
|
+
}>;
|
|
614
|
+
};
|
|
615
|
+
readonly events: {
|
|
616
|
+
/**
|
|
617
|
+
* Long-polls for the next event of `type`, resolving as soon as one arrives or when the
|
|
618
|
+
* server's window elapses (`timedOut: true`). Narrows the payload when `type` is a known
|
|
619
|
+
* event type.
|
|
620
|
+
*
|
|
621
|
+
* Prefer {@link AgentClient.events.subscribe} for a continuous loop — it handles the
|
|
622
|
+
* cursor and retries for you.
|
|
623
|
+
*/
|
|
624
|
+
wait<T extends AidEventType | string = string>(input: WaitForEventInput<T>, options?: {
|
|
625
|
+
signal?: AbortSignal;
|
|
626
|
+
}): Promise<WaitForEventResult<T>>;
|
|
627
|
+
/**
|
|
628
|
+
* Yields matching events continuously, as an async iterator.
|
|
629
|
+
*
|
|
630
|
+
* Handles the three things a hand-written `wait` loop gets wrong: it advances the cursor
|
|
631
|
+
* using each event's own `createdAt` (not the client's wall clock, which can skip events
|
|
632
|
+
* and is vulnerable to clock skew), it re-polls transparently on timeout, and it retries
|
|
633
|
+
* failures with exponential backoff.
|
|
634
|
+
*
|
|
635
|
+
* ```ts
|
|
636
|
+
* for await (const event of client.events.subscribe({ type: "mail.received", identityId })) {
|
|
637
|
+
* await handle(event.payload.messageId); // payload is typed
|
|
638
|
+
* }
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
641
|
+
subscribe<T extends AidEventType | string = string>(input: SubscribeInput<T>): AsyncIterableIterator<T extends AidEventType ? KnownAidEvent<T> : AidEvent>;
|
|
642
|
+
/** Reads recent events newest-first. `before` takes an ISO timestamp for paging back. */
|
|
643
|
+
list(options?: {
|
|
644
|
+
limit?: number;
|
|
645
|
+
before?: string;
|
|
646
|
+
}): Promise<AidEvent[]>;
|
|
647
|
+
/** Re-delivers an event to its webhook endpoints. */
|
|
648
|
+
replay(id: string): Promise<{
|
|
649
|
+
id: string;
|
|
650
|
+
replayed: true;
|
|
651
|
+
}>;
|
|
652
|
+
};
|
|
653
|
+
readonly apiKeys: {
|
|
654
|
+
list(): Promise<ApiKeySummary[]>;
|
|
655
|
+
create(input: CreateApiKeyInput): Promise<CreatedApiKey>;
|
|
656
|
+
revoke(id: string): Promise<ApiKeySummary>;
|
|
657
|
+
};
|
|
658
|
+
readonly webhooks: {
|
|
659
|
+
list(): Promise<WebhookEndpoint[]>;
|
|
660
|
+
create(input: CreateWebhookEndpointInput): Promise<CreatedWebhookEndpoint>;
|
|
661
|
+
listDeliveries(options?: {
|
|
662
|
+
limit?: number;
|
|
663
|
+
before?: string;
|
|
664
|
+
}): Promise<WebhookDelivery[]>;
|
|
665
|
+
};
|
|
666
|
+
readonly vault: {
|
|
667
|
+
/** Generates an X25519 keypair locally (never sent to the server), registers the public half
|
|
668
|
+
* against the identity, and returns both — the private half is returned exactly once and
|
|
669
|
+
* must be stored by the caller (e.g. as that agent's own env var/config secret). Zero
|
|
670
|
+
* knowledge starts here: the API server never sees a private key. */
|
|
671
|
+
generateIdentityKey(identityId: string): Promise<VaultKeypair>;
|
|
672
|
+
listSecrets(): Promise<VaultSecretSummary[]>;
|
|
673
|
+
/** Encrypts `plaintext` locally against the target identity's registered vault public key
|
|
674
|
+
* (ECIES over X25519) before it ever reaches the network — the server only stores/forwards
|
|
675
|
+
* the resulting ciphertext envelope. */
|
|
676
|
+
createSecret(input: CreateVaultSecretInput): Promise<VaultSecretSummary>;
|
|
677
|
+
/** Only the owning identity can rotate its own secret — it's the only party with the private
|
|
678
|
+
* key to decrypt the current envelope and re-encrypt under a fresh ephemeral key. Requires
|
|
679
|
+
* that identity's own keypair (from `generateIdentityKey`). */
|
|
680
|
+
rotateSecret(secretId: string, keypair: VaultKeypair): Promise<VaultSecretSummary>;
|
|
681
|
+
createLease(secretId: string, input: CreateLeaseInput): Promise<CreatedLease>;
|
|
682
|
+
/** Redeems the lease and decrypts the envelope locally using the owning identity's private
|
|
683
|
+
* key — the server never decrypts anything. */
|
|
684
|
+
redeemLease(leaseId: string, keypair: VaultKeypair): Promise<{
|
|
685
|
+
secret: string;
|
|
686
|
+
}>;
|
|
687
|
+
listLeases(options?: {
|
|
688
|
+
limit?: number;
|
|
689
|
+
}): Promise<VaultLease[]>;
|
|
690
|
+
};
|
|
691
|
+
readonly tunnels: {
|
|
692
|
+
create(identityId: string, input?: CreateTunnelInput): Promise<Tunnel>;
|
|
693
|
+
list(identityId: string): Promise<Tunnel[]>;
|
|
694
|
+
get(tunnelId: string): Promise<Tunnel>;
|
|
695
|
+
};
|
|
696
|
+
readonly contacts: {
|
|
697
|
+
create(input: CreateContactInput): Promise<Contact>;
|
|
698
|
+
list(options?: {
|
|
699
|
+
status?: "suggested" | "saved";
|
|
700
|
+
}): Promise<Contact[]>;
|
|
701
|
+
get(id: string): Promise<Contact>;
|
|
702
|
+
update(id: string, input: UpdateContactInput): Promise<Contact>;
|
|
703
|
+
delete(id: string): Promise<void>;
|
|
704
|
+
approve(id: string): Promise<Contact>;
|
|
705
|
+
reject(id: string): Promise<void>;
|
|
706
|
+
};
|
|
707
|
+
readonly contactRules: {
|
|
708
|
+
create(input: CreateContactRuleInput): Promise<ContactRule>;
|
|
709
|
+
list(): Promise<ContactRule[]>;
|
|
710
|
+
delete(id: string): Promise<void>;
|
|
711
|
+
};
|
|
712
|
+
readonly a2a: {
|
|
713
|
+
/** Org-admin only. No trust rule, no task: A2A is off by default. */
|
|
714
|
+
createTrustRule(input: CreateA2ATrustRuleInput): Promise<A2ATrustRule>;
|
|
715
|
+
listTrustRules(): Promise<A2ATrustRule[]>;
|
|
716
|
+
deleteTrustRule(id: string): Promise<void>;
|
|
717
|
+
/** Must be called with an agent-scoped key; the target identity must already trust it. */
|
|
718
|
+
sendTask(input: SendA2ATaskInput): Promise<A2ATask>;
|
|
719
|
+
getTask(id: string): Promise<A2ATask>;
|
|
720
|
+
listTasks(identityId: string): Promise<A2ATask[]>;
|
|
721
|
+
/** Only the target identity's own key can move a task's state — the caller waits for
|
|
722
|
+
* `a2a.task.updated` via events.wait(). */
|
|
723
|
+
updateTask(id: string, input: UpdateA2ATaskInput): Promise<A2ATask>;
|
|
724
|
+
/** Publicly reachable, no auth — same as any real A2A server's well-known agent-card. */
|
|
725
|
+
getAgentCard(identityId: string): Promise<AgentCard>;
|
|
726
|
+
/** Org-admin only — every identity, its enable state, advertised skills, and task counts. */
|
|
727
|
+
listAgentOverviews(): Promise<A2AAgentOverview[]>;
|
|
728
|
+
/** Org-admin only. An identity must be enabled before it can send OR receive tasks, even
|
|
729
|
+
* with a trust rule in place. */
|
|
730
|
+
setEnabled(identityId: string, enabled: boolean): Promise<void>;
|
|
731
|
+
/** Org-admin only. Shown on the identity's public agent card. */
|
|
732
|
+
setSkills(identityId: string, skills: string[]): Promise<void>;
|
|
733
|
+
/** Org-admin only. Opts the identity into the cross-org directory — separate from `enabled`,
|
|
734
|
+
* since an identity can accept trusted tasks without being publicly discoverable. */
|
|
735
|
+
setListed(identityId: string, listed: boolean): Promise<void>;
|
|
736
|
+
/** Any authenticated actor, any org — searches identities that opted into the directory
|
|
737
|
+
* (enabled + listed) by handle substring. */
|
|
738
|
+
searchDirectory(query?: string): Promise<A2ADirectoryEntry[]>;
|
|
739
|
+
/** Org-admin only. Invites another identity — same org or a different one entirely — to a
|
|
740
|
+
* mutual trust relationship. Nothing is trusted until the invited org's admin accepts. */
|
|
741
|
+
createInvitation(input: CreateA2AInvitationInput): Promise<A2AInvitation>;
|
|
742
|
+
/** Org-admin only — invitations sent or received by any of this org's identities. */
|
|
743
|
+
listInvitations(): Promise<A2AInvitationWithContext[]>;
|
|
744
|
+
/** Only the invited identity's own org admin can accept — creates mutual trust rules in both
|
|
745
|
+
* directions atomically. */
|
|
746
|
+
acceptInvitation(id: string): Promise<A2AInvitation>;
|
|
747
|
+
/** Only the invited identity's own org admin can decline. */
|
|
748
|
+
declineInvitation(id: string): Promise<A2AInvitation>;
|
|
749
|
+
/** Only the inviting identity's own org admin can revoke, and only while still pending. */
|
|
750
|
+
revokeInvitation(id: string): Promise<A2AInvitation>;
|
|
751
|
+
};
|
|
752
|
+
readonly domains: {
|
|
753
|
+
add(domain: string): Promise<Domain>;
|
|
754
|
+
list(): Promise<Domain[]>;
|
|
755
|
+
verify(id: string): Promise<Domain>;
|
|
756
|
+
delete(id: string): Promise<void>;
|
|
757
|
+
deliverability(id: string): Promise<DeliverabilityGuidance>;
|
|
758
|
+
};
|
|
759
|
+
readonly providerAccounts: {
|
|
760
|
+
create(input: CreateProviderAccountInput): Promise<ProviderAccount>;
|
|
761
|
+
list(): Promise<ProviderAccount[]>;
|
|
762
|
+
delete(id: string): Promise<void>;
|
|
763
|
+
};
|
|
764
|
+
readonly providers: {
|
|
765
|
+
health(): Promise<ProviderHealth>;
|
|
766
|
+
};
|
|
767
|
+
/** Liveness and readiness probes. Unauthenticated on the server, but exposed here so callers
|
|
768
|
+
* can reuse one configured client rather than hand-rolling a fetch. */
|
|
769
|
+
readonly status: {
|
|
770
|
+
/** Resolves if the API process is up. Does not check its dependencies. */
|
|
771
|
+
health(): Promise<{
|
|
772
|
+
status: string;
|
|
773
|
+
}>;
|
|
774
|
+
/** Resolves only if the API can reach its database. Throws {@link AidApiError} (503) if not. */
|
|
775
|
+
ready(): Promise<{
|
|
776
|
+
status: string;
|
|
777
|
+
}>;
|
|
778
|
+
};
|
|
779
|
+
constructor(options: AgentClientOptions);
|
|
780
|
+
whoami(): Promise<WhoAmI>;
|
|
781
|
+
/** Attaches a real email+password login to the org this API key belongs to — for orgs
|
|
782
|
+
* bootstrapped the old way (a raw admin key, no account behind it). Org-admin key only. */
|
|
783
|
+
claimAccount(input: {
|
|
784
|
+
email: string;
|
|
785
|
+
password: string;
|
|
786
|
+
}): Promise<AuthSession>;
|
|
787
|
+
private request;
|
|
788
|
+
}
|