@alfe.ai/agent-api-client 0.1.3 → 0.2.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/dist/index.d.ts CHANGED
@@ -1,262 +1,7 @@
1
- //#region ../../packages-internal/types/dist/access.d.ts
1
+ import { ChangelogAction, ChangelogActor, ChangelogEntry, ChangelogEntry as ChangelogEntry$1, EncryptedEnvelopeV1, EncryptedEnvelopeV1 as EncryptedEnvelopeV1$1, Field, FieldEnvelope, FieldEnvelope as FieldEnvelope$1, FieldFormat, FieldFormat as FieldFormat$1, FieldSensitivity, FieldSensitivity as FieldSensitivity$1, FieldView, GeneratedDataKey, GeneratedDataKey as GeneratedDataKey$1, IntegrationConfigResult, IntegrationConfigResult as IntegrationConfigResult$1, IntegrationConfigSchemaField, IntegrationInstall, IntegrationInstall as IntegrationInstall$1, RegistryEntry, RegistryEntry as RegistryEntry$1, ScopeInfo, ScopeInfo as ScopeInfo$1, SecretAggregate, SecretAggregate as SecretAggregate$1, SecretCategory, SecretCategory as SecretCategory$1, SecretMetadata, SecretMetadata as SecretMetadata$1, SecretScope, SecretScope as SecretScope$1 } from "@alfe/types";
2
2
 
3
- /**
4
- * The four resource scopes at which a permission can apply.
5
- * Order is meaningful: broader scopes first (`org`) → narrower last (`agent`).
6
- *
7
- * `IntegrationScope` in integration.ts and `SecretScope` in secrets.ts are
8
- * intentional aliases of this same enum — there is only one concept of
9
- * "scope" in Alfe.
10
- */
11
- declare const ResourceScope: {
12
- readonly Org: "org";
13
- readonly Team: "team";
14
- readonly Project: "project";
15
- readonly Agent: "agent";
16
- };
17
- type ResourceScope = (typeof ResourceScope)[keyof typeof ResourceScope];
18
- /** Ordered tuple of resource scope string values (broad → narrow). */
19
- //#endregion
20
- //#region ../../packages-internal/types/dist/integration.d.ts
21
- /** Controls where an integration appears: public (everyone), hidden (nowhere) */
22
- declare const IntegrationVisibility: {
23
- readonly Public: "public";
24
- readonly Hidden: "hidden";
25
- };
26
- type IntegrationVisibility = (typeof IntegrationVisibility)[keyof typeof IntegrationVisibility];
27
- /** Scope at which an integration is installed */
28
- declare const IntegrationScope: {
29
- readonly Org: "org";
30
- readonly Team: "team";
31
- readonly Project: "project";
32
- readonly Agent: "agent";
33
- };
34
- type IntegrationScope = ResourceScope;
35
- declare const IntegrationDesiredStatus: {
36
- readonly Active: "active";
37
- readonly Removed: "removed";
38
- };
39
- type IntegrationDesiredStatus = (typeof IntegrationDesiredStatus)[keyof typeof IntegrationDesiredStatus];
40
- declare const IntegrationActualStatus: {
41
- readonly Installing: "installing";
42
- readonly Active: "active";
43
- readonly Error: "error";
44
- readonly Removing: "removing";
45
- readonly Inactive: "inactive";
46
- readonly Unknown: "unknown";
47
- };
48
- type IntegrationActualStatus = (typeof IntegrationActualStatus)[keyof typeof IntegrationActualStatus];
49
- interface IntegrationInstall {
50
- scope: IntegrationScope;
51
- scopeId: string;
52
- integrationId: string;
53
- tenantId: string;
54
- desiredStatus: IntegrationDesiredStatus;
55
- actualStatus: IntegrationActualStatus;
56
- version: string;
57
- config: Record<string, unknown>;
58
- errorMessage: string;
59
- installedAt: string;
60
- updatedAt: string;
61
- }
62
- /** @deprecated Use IntegrationInstall instead */
63
-
64
- interface IntegrationConfigSchemaField {
65
- key: string;
66
- label: string;
67
- type: string;
68
- description?: string;
69
- required?: boolean;
70
- default?: string | number | boolean;
71
- options?: string[];
72
- select_options?: {
73
- value: string;
74
- label: string;
75
- }[];
76
- oauth_provider?: string;
77
- oauth_scopes?: string[];
78
- oauth_integration_id?: string;
79
- editable?: string;
80
- hidden?: boolean;
81
- }
82
- interface IntegrationConfigResult {
83
- integrationId: string;
84
- config: Record<string, unknown>;
85
- configSchema: IntegrationConfigSchemaField[];
86
- }
87
- interface RegistryEntry {
88
- id: string;
89
- name: string;
90
- description: string;
91
- versions: string[];
92
- latest: string;
93
- repository: string;
94
- commit: string;
95
- icon?: string;
96
- author?: {
97
- name: string;
98
- url?: string;
99
- } | string;
100
- pricing?: {
101
- type: "free" | "paid" | "usage";
102
- price?: number;
103
- currency?: string;
104
- interval?: "month" | "year";
105
- description?: string;
106
- };
107
- features?: string[];
108
- preview_images?: string[];
109
- config_schema?: IntegrationConfigSchemaField[];
110
- supported_agents?: string[];
111
- /** Scopes where this integration can be installed */
112
- supported_scopes?: IntegrationScope[];
113
- /** Visibility status — controls where integration appears */
114
- visibility?: IntegrationVisibility;
115
- }
116
- //# sourceMappingURL=integration.d.ts.map
117
- //#endregion
118
- //#region ../../packages-internal/types/dist/secrets.d.ts
119
- /** Scope levels at which a secret can be owned. Aliased to ResourceScope. */
120
- type SecretScope = ResourceScope;
121
- /**
122
- * v1 encrypted envelope as persisted by services/secrets and exchanged with
123
- * agents. Values are AES-256-GCM ciphertext; iv/authTag/ciphertext/dataKeyCiphertext
124
- * are all base64-encoded.
125
- */
126
- interface EncryptedEnvelopeV1 {
127
- version: 1;
128
- iv: string;
129
- ciphertext: string;
130
- authTag: string;
131
- dataKeyCiphertext: string;
132
- }
133
- /**
134
- * Display/validation hint for a field's value. `"json"` signals that the
135
- * string is a JSON-stringified payload that consumers should `JSON.parse`.
136
- */
137
- declare const FIELD_FORMATS: readonly ["text", "email", "url", "phone", "date", "number", "json"];
138
- type FieldFormat = (typeof FIELD_FORMATS)[number];
139
- /**
140
- * Whether a field is stored in plaintext (visible to anyone with read access)
141
- * or encrypted (requires KMS + the right encryption context to read).
142
- */
143
- declare const FIELD_SENSITIVITIES: readonly ["plaintext", "encrypted"];
144
- type FieldSensitivity = (typeof FIELD_SENSITIVITIES)[number];
145
- /**
146
- * A field on a secret. `value` is always a string at the wire; for encrypted
147
- * fields it's the plaintext at the API edge (the service encrypts before
148
- * persistence). Reads from the dashboard omit `value` for encrypted fields;
149
- * agents get a `FieldEnvelope` instead and decrypt locally.
150
- */
151
- interface Field {
152
- key: string;
153
- format?: FieldFormat;
154
- sensitivity: FieldSensitivity;
155
- value: string;
156
- }
157
- /**
158
- * Secret category — drives icon/template/filter behaviour. Defaults to
159
- * `"other"` for migrated rows.
160
- */
161
- declare const SECRET_CATEGORIES: readonly ["login", "api_key", "database", "ssh_key", "certificate", "secure_note", "credit_card", "identity", "wifi", "other"];
162
- type SecretCategory = (typeof SECRET_CATEGORIES)[number];
163
- /**
164
- * One field as exposed to readers. Encrypted fields have no `value` on the
165
- * dashboard read path; the agent-side aggregate carries `envelope` instead.
166
- */
167
- interface FieldView {
168
- key: string;
169
- format?: FieldFormat;
170
- sensitivity: FieldSensitivity;
171
- /** Present for `sensitivity: "plaintext"` only. */
172
- value?: string;
173
- /** Present for `sensitivity: "encrypted"` on agent-side reads only. */
174
- envelope?: EncryptedEnvelopeV1;
175
- /** Plaintext fields that opt into `format: "json"` are pre-parsed for callers. */
176
- parsedValue?: unknown;
177
- rotatedAt?: string;
178
- createdAt: string;
179
- updatedAt: string;
180
- }
181
- /** A secret as assembled from its multi-row aggregate. */
182
- interface SecretAggregate {
183
- secretId: string;
184
- secretName: string;
185
- description?: string;
186
- tags: string[];
187
- category: SecretCategory;
188
- fields: FieldView[];
189
- changelogVersion: number;
190
- createdAt: string;
191
- updatedAt: string;
192
- }
193
- /** Metadata-only projection — used by list endpoints. */
194
- interface SecretMetadata {
195
- secretId: string;
196
- secretName: string;
197
- description?: string;
198
- tags: string[];
199
- category: SecretCategory;
200
- fieldKeys: string[];
201
- changelogVersion: number;
202
- createdAt: string;
203
- updatedAt: string;
204
- }
205
- /**
206
- * Per-field encrypted envelope returned to agents on the agent-side aggregate.
207
- * Agents decrypt locally using a data key fetched from `/decrypt-data-key`.
208
- */
209
- interface FieldEnvelope {
210
- key: string;
211
- format?: FieldFormat;
212
- envelope: EncryptedEnvelopeV1;
213
- rotatedAt?: string;
214
- createdAt: string;
215
- updatedAt: string;
216
- }
217
- /** A scope the caller can read or write secrets in. */
218
- interface ScopeInfo {
219
- scope: SecretScope;
220
- scopeId: string;
221
- name?: string;
222
- }
223
- /**
224
- * KMS-issued data key, returned by the secrets service's
225
- * `/secrets/generate-data-key` KMS proxy endpoint. The plaintext key is
226
- * returned base64-encoded; callers MUST decode it to a Buffer and zero the
227
- * Buffer after use — never keep the plaintext as a JS string.
228
- */
229
- interface GeneratedDataKey {
230
- plaintextKey: string;
231
- dataKeyCiphertext: string;
232
- }
233
- /**
234
- * Action types recorded in the secret changelog. Append-only.
235
- */
236
- declare const CHANGELOG_ACTIONS: readonly ["created", "deleted", "metadata_updated", "field_added", "field_rotated", "field_removed", "tag_added", "tag_removed"];
237
- type ChangelogAction = (typeof CHANGELOG_ACTIONS)[number];
238
- /** Who triggered a changelog entry. */
239
- interface ChangelogActor {
240
- kind: "user" | "agent" | "system";
241
- id: string;
242
- }
243
- /**
244
- * One audit row from the secret's changelog. Metadata only — never carries
245
- * field VALUES (old or new). Rolling back a rotated secret is intentionally
246
- * not supported.
247
- */
248
- interface ChangelogEntry {
249
- changelogVersion: number;
250
- action: ChangelogAction;
251
- fieldKey?: string;
252
- fieldSensitivity?: FieldSensitivity;
253
- changedBy: ChangelogActor;
254
- reason?: string;
255
- timestamp: string;
256
- }
257
- //# sourceMappingURL=secrets.d.ts.map
258
- //#endregion
259
3
  //#region src/index.d.ts
4
+
260
5
  interface AgentApiClientConfig {
261
6
  apiKey: string;
262
7
  apiUrl: string;
@@ -402,14 +147,14 @@ declare class AgentApiClient {
402
147
  downloadUrl: string;
403
148
  expiresIn: number;
404
149
  }>;
405
- listIntegrations(): Promise<IntegrationInstall[]>;
406
- getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult>;
150
+ listIntegrations(): Promise<IntegrationInstall$1[]>;
151
+ getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult$1>;
407
152
  updateIntegrationConfig(integrationId: string, config: Record<string, unknown>): Promise<void>;
408
153
  installIntegration(integrationId: string, options?: {
409
154
  version?: string;
410
155
  config?: Record<string, unknown>;
411
- }): Promise<IntegrationInstall>;
412
- removeIntegration(integrationId: string): Promise<IntegrationInstall>;
156
+ }): Promise<IntegrationInstall$1>;
157
+ removeIntegration(integrationId: string): Promise<IntegrationInstall$1>;
413
158
  getOAuthUrl(provider: string, scopes?: string[]): Promise<{
414
159
  url: string;
415
160
  provider: string;
@@ -421,37 +166,33 @@ declare class AgentApiClient {
421
166
  config?: Record<string, string>;
422
167
  }>;
423
168
  getRegistry(): Promise<{
424
- integrations: RegistryEntry[];
169
+ integrations: RegistryEntry$1[];
425
170
  }>;
171
+ /**
172
+ * Returns every connected Google account for the agent. Multi-account by
173
+ * design — the openclaw-google plugin requires the LLM to pass `email`
174
+ * explicitly to `google_run_command` so an account is always selected
175
+ * deliberately.
176
+ *
177
+ * 2026-05-14 (connections-redesign PR 1): the legacy flat shape (`email`,
178
+ * `refreshToken`, `accessToken`, etc., populated from the default account)
179
+ * is gone. Iterate over `accounts`.
180
+ */
426
181
  getGoogleCredentials(): Promise<{
427
- accounts?: {
182
+ accounts: {
428
183
  email: string;
429
184
  refreshToken: string;
430
185
  clientId: string;
431
186
  clientSecret: string;
432
- enabledServices?: string[];
433
- isDefault: boolean;
434
187
  displayName?: string;
188
+ connectedAt?: string;
435
189
  }[];
436
- email: string;
437
- refreshToken: string;
438
- clientId: string;
439
- clientSecret: string;
440
- projectId: string;
441
- enabledServices?: string[];
442
190
  }>;
443
191
  disconnectGoogleAccount(email: string): Promise<{
444
192
  accounts: {
445
193
  email: string;
446
194
  displayName?: string;
447
- isDefault: boolean;
448
- }[];
449
- }>;
450
- setDefaultGoogleAccount(email: string): Promise<{
451
- accounts: {
452
- email: string;
453
- displayName?: string;
454
- isDefault: boolean;
195
+ connectedAt?: string;
455
196
  }[];
456
197
  }>;
457
198
  getGoogleChatCredentials(): Promise<{
@@ -461,24 +202,125 @@ declare class AgentApiClient {
461
202
  clientSecret: string;
462
203
  displayName?: string;
463
204
  }>;
205
+ /**
206
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
207
+ * default-connection" shape). Use `getGithubAccounts()` for the multi-
208
+ * account shape required by Pattern A — explicit selector args on every
209
+ * tool. Retained because the `@alfe.ai/openclaw-github` proxy is the
210
+ * only consumer that knows about Pattern A; legacy env-interpolation
211
+ * callers will keep hitting `/credentials` until they move to the proxy.
212
+ */
464
213
  getGithubCredentials(): Promise<{
465
214
  login: string;
466
215
  accessToken: string;
467
216
  }>;
217
+ /**
218
+ * Pattern A: multi-account credential fetch for GitHub.
219
+ *
220
+ * Returns every agent-scoped GitHub connection. The caller is expected
221
+ * to require a `login` selector on every credential-touching tool and
222
+ * look up the matching account at dispatch time.
223
+ *
224
+ * GitHub OAuth tokens have no expiry (`tokenLifecycle: "no_expiry"`),
225
+ * so there is intentionally no `refreshGithubAccountToken` method — if
226
+ * a token is revoked the user must re-run the OAuth flow.
227
+ *
228
+ * Returned `accounts[i].login` is the GitHub username — the stable
229
+ * cross-session identifier the LLM should pass.
230
+ */
231
+ getGithubAccounts(): Promise<{
232
+ accounts: {
233
+ connectionId: string;
234
+ accountIdentifier: string;
235
+ displayName: string | null;
236
+ connectedAt: string;
237
+ accessToken: string;
238
+ login: string;
239
+ scopes: string;
240
+ }[];
241
+ }>;
242
+ /**
243
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
244
+ * default-connection" shape). Use `getXeroAccounts()` for the multi-
245
+ * account shape required by Pattern A — explicit selector args on every
246
+ * tool. This method will be removed once all consumers migrate.
247
+ */
468
248
  getXeroCredentials(): Promise<{
469
249
  accessToken: string;
470
250
  accessTokenExpiresAt: string;
471
251
  xeroTenantId: string;
472
252
  }>;
253
+ /**
254
+ * Pattern A: multi-account credential fetch for Xero. Returns every
255
+ * agent-scoped Xero connection. The caller is expected to require a
256
+ * selector arg (e.g. `xeroTenantId`) on every credential-touching tool
257
+ * and look up the matching account by that selector at dispatch time.
258
+ *
259
+ * Returned `accounts[i].accountIdentifier` is the Xero tenantId — the
260
+ * stable cross-session identifier the LLM should pass.
261
+ */
262
+ getXeroAccounts(): Promise<{
263
+ accounts: {
264
+ connectionId: string;
265
+ accountIdentifier: string;
266
+ displayName: string | null;
267
+ connectedAt: string;
268
+ accessToken: string;
269
+ accessTokenExpiresAt: string;
270
+ xeroTenantId: string;
271
+ }[];
272
+ }>;
473
273
  refreshXeroToken(): Promise<{
474
274
  accessToken: string;
475
275
  expiresAt: string;
476
276
  }>;
277
+ /**
278
+ * Pattern A: refresh a specific Xero connection by its `accountIdentifier`
279
+ * (the Xero `tenantId`). The legacy `refreshXeroToken()` only refreshes
280
+ * the *primary* connection, which is wrong for multi-tenant Xero where
281
+ * each tenant has its own non-interchangeable access token.
282
+ */
283
+ refreshXeroAccountToken(xeroTenantId: string): Promise<{
284
+ accessToken: string;
285
+ accessTokenExpiresAt: string;
286
+ expiresAt: string;
287
+ }>;
288
+ /**
289
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
290
+ * default-connection" shape). Use `getNotionAccounts()` for the multi-
291
+ * account shape required by Pattern A.
292
+ */
477
293
  getNotionCredentials(): Promise<{
478
294
  accessToken: string;
479
295
  workspaceId: string;
480
296
  workspaceName: string;
481
297
  }>;
298
+ /**
299
+ * Pattern A: multi-account credential fetch for Notion. Returns every
300
+ * agent-scoped Notion connection. The caller is expected to require a
301
+ * selector arg (e.g. `workspaceId`) on every credential-touching tool.
302
+ *
303
+ * Returned `accounts[i].accountIdentifier` is the Notion workspaceId.
304
+ */
305
+ getNotionAccounts(): Promise<{
306
+ accounts: {
307
+ connectionId: string;
308
+ accountIdentifier: string;
309
+ displayName: string | null;
310
+ connectedAt: string;
311
+ accessToken: string;
312
+ workspaceId: string;
313
+ workspaceName: string;
314
+ }[];
315
+ }>;
316
+ /**
317
+ * @deprecated Returns a single primary Atlassian Connection's credentials
318
+ * (one OAuth user, one cloudId) — the legacy "pick-the-default-connection"
319
+ * shape. Atlassian is multi-site by nature (each OAuth user may have
320
+ * access to multiple Cloud sites), so Pattern A plugins MUST use
321
+ * `getAtlassianAccounts()` to discover the full set and dispatch via
322
+ * the `cloudId` selector arg.
323
+ */
482
324
  getAtlassianCredentials(): Promise<{
483
325
  accessToken: string;
484
326
  refreshToken: string;
@@ -495,16 +337,177 @@ declare class AgentApiClient {
495
337
  accessToken: string;
496
338
  expiresAt: string;
497
339
  }>;
340
+ /**
341
+ * Pattern A: multi-account / multi-site credential fetch for Atlassian.
342
+ *
343
+ * Returns every agent-scoped Atlassian Connection. Each Connection is
344
+ * one OAuth user with a single access token and N accessible Cloud
345
+ * sites (`availableSites`). The caller is expected to:
346
+ *
347
+ * 1. Flatten (connection × cloudId) into one MCP child per site.
348
+ * 2. Require a `cloudId` selector on every credential-touching tool.
349
+ * 3. Use the access token bound to the Connection that owns the
350
+ * requested `cloudId` (Atlassian shares one access token across
351
+ * all sites accessible to the OAuth user).
352
+ *
353
+ * Per-account token refresh uses `refreshAtlassianAccountToken(email)`
354
+ * — refreshing one Connection rotates its single access token, which
355
+ * then applies to every cloudId for that Connection.
356
+ *
357
+ * Returned `accounts[i].accountIdentifier` is the OAuth user's email
358
+ * — the stable cross-session identifier for refresh purposes. The LLM
359
+ * never sees this directly: it picks a site via the `cloudId` arg
360
+ * instead.
361
+ */
362
+ getAtlassianAccounts(): Promise<{
363
+ accounts: {
364
+ connectionId: string;
365
+ accountIdentifier: string;
366
+ displayName: string | null;
367
+ connectedAt: string;
368
+ accessToken: string;
369
+ accessTokenExpiresAt: string;
370
+ clientId: string;
371
+ clientSecret: string;
372
+ cloudId: string;
373
+ siteName: string;
374
+ siteUrl: string;
375
+ availableSites: {
376
+ id: string;
377
+ url: string;
378
+ name: string;
379
+ scopes?: string[];
380
+ avatarUrl?: string;
381
+ }[];
382
+ }[];
383
+ }>;
384
+ /**
385
+ * Pattern A: refresh a specific Atlassian Connection by `accountIdentifier`
386
+ * (the OAuth user's email).
387
+ *
388
+ * Atlassian rotates refresh tokens (`rotatesRefreshToken: true`); the
389
+ * server-side per-account refresh endpoint handles rotation and
390
+ * persistence. Refreshing one Connection updates its single access
391
+ * token, which applies to every accessible Cloud site (cloudId) for
392
+ * that OAuth user.
393
+ *
394
+ * Returns the new access token + expiry. The proxy is responsible for
395
+ * fanning the new token out to every child server it spawned for
396
+ * cloudIds owned by this Connection.
397
+ */
398
+ refreshAtlassianAccountToken(accountIdentifier: string): Promise<{
399
+ accessToken: string;
400
+ accessTokenExpiresAt: string;
401
+ expiresAt: string;
402
+ }>;
403
+ /**
404
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
405
+ * default-connection" shape). Use `getMYOBAccounts()` for the multi-
406
+ * account shape required by Pattern A.
407
+ */
498
408
  getMYOBCredentials(): Promise<{
499
409
  accessToken: string;
500
410
  accessTokenExpiresAt: string;
501
411
  myobBusinessId: string;
502
412
  clientId: string;
503
413
  }>;
414
+ /**
415
+ * Pattern A: multi-account credential fetch for MYOB. Returns every
416
+ * agent-scoped MYOB connection. The caller is expected to require a
417
+ * selector arg (e.g. `myobBusinessId` / `accountIdentifier`) on every
418
+ * credential-touching tool.
419
+ *
420
+ * Returned `accounts[i].accountIdentifier` is the MYOB businessId.
421
+ */
422
+ getMYOBAccounts(): Promise<{
423
+ accounts: {
424
+ connectionId: string;
425
+ accountIdentifier: string;
426
+ displayName: string | null;
427
+ connectedAt: string;
428
+ accessToken: string;
429
+ accessTokenExpiresAt: string;
430
+ myobBusinessId: string;
431
+ clientId: string;
432
+ }[];
433
+ }>;
504
434
  refreshMYOBToken(): Promise<{
505
435
  accessToken: string;
506
436
  expiresAt: string;
507
437
  }>;
438
+ /**
439
+ * Microsoft 365 (delegated OAuth) credential fetch — single-account shape.
440
+ *
441
+ * @deprecated Use `getMicrosoftAccounts()` and dispatch via the `email`
442
+ * selector once per-account plugins land. Retained because the existing
443
+ * `integrations/connect/microsoft/hooks/post_activate.mjs` writes
444
+ * `mgc` credentials for the single (default) Microsoft account.
445
+ *
446
+ * Returns the agent's effective Microsoft delegated-OAuth credentials.
447
+ * Distinct from `getTeamsCredentials()` (Azure bot credentials for the
448
+ * Teams adapter, which is admin-consent flow on services/microsoft, not
449
+ * delegated OAuth on services/connect).
450
+ */
451
+ getMicrosoftCredentials(): Promise<{
452
+ accessToken: string;
453
+ accessTokenExpiresAt?: string;
454
+ refreshToken: string;
455
+ clientId: string;
456
+ clientSecret: string;
457
+ email?: string;
458
+ microsoftTenantId?: string;
459
+ workspaceDomain?: string;
460
+ }>;
461
+ /**
462
+ * Pattern A: multi-account credential fetch for Microsoft 365.
463
+ *
464
+ * Returns every agent-scoped Microsoft connection. The caller is expected
465
+ * to require an `email` selector on every credential-touching tool and
466
+ * look up the matching account at dispatch time.
467
+ *
468
+ * Returned `accounts[i].accountIdentifier` is the user's primary email
469
+ * (or the tid claim as fallback) — the stable cross-session identifier
470
+ * the LLM should pass.
471
+ *
472
+ * Per-account token refresh is exposed via `refreshMicrosoftAccountToken`,
473
+ * NOT `refreshXeroAccountToken` — Microsoft refresh tokens are not
474
+ * interchangeable across (tenant, user) pairs.
475
+ */
476
+ getMicrosoftAccounts(): Promise<{
477
+ accounts: {
478
+ connectionId: string;
479
+ accountIdentifier: string;
480
+ displayName: string | null;
481
+ connectedAt: string;
482
+ accessToken: string;
483
+ accessTokenExpiresAt: string;
484
+ refreshToken: string;
485
+ clientId: string;
486
+ clientSecret: string;
487
+ email: string;
488
+ microsoftTenantId: string;
489
+ workspaceDomain: string;
490
+ }[];
491
+ }>;
492
+ /**
493
+ * Pattern A: refresh a specific Microsoft 365 connection by its
494
+ * `accountIdentifier`. For Microsoft, `accountIdentifier` is the user's
495
+ * email when the Graph profile fetch succeeded at connect time, and the
496
+ * Azure tenant id (`tid` claim) as fallback. Callers should pass the
497
+ * value returned by `getMicrosoftAccounts()` rather than synthesising
498
+ * an email locally.
499
+ *
500
+ * Microsoft refresh tokens are bound to a specific (tenant, user) pair —
501
+ * they are NOT interchangeable across accounts, so per-account refresh
502
+ * is mandatory. The generic /accounts/{accountIdentifier}/refresh
503
+ * endpoint walks the agent's full visible scope chain to find a matching
504
+ * connection (works for inherited team/project Microsoft connections).
505
+ */
506
+ refreshMicrosoftAccountToken(accountIdentifier: string): Promise<{
507
+ accessToken: string;
508
+ accessTokenExpiresAt: string;
509
+ expiresAt: string;
510
+ }>;
508
511
  getTeamsCredentials(): Promise<{
509
512
  agentId: string;
510
513
  tenantId: string;
@@ -559,11 +562,11 @@ declare class AgentApiClient {
559
562
  * to reach them.
560
563
  */
561
564
  generateSecretDataKey(args: {
562
- scope: SecretScope;
565
+ scope: SecretScope$1;
563
566
  scopeId: string;
564
567
  secretId: string;
565
568
  fieldKey: string;
566
- }): Promise<GeneratedDataKey>;
569
+ }): Promise<GeneratedDataKey$1>;
567
570
  /**
568
571
  * Unwrap a wrapped data key so the agent can decrypt the envelope locally.
569
572
  * `fieldKey` MUST match the value supplied when the data key was generated
@@ -571,7 +574,7 @@ declare class AgentApiClient {
571
574
  * `InvalidCiphertextException`.
572
575
  */
573
576
  decryptSecretDataKey(args: {
574
- scope: SecretScope;
577
+ scope: SecretScope$1;
575
578
  scopeId: string;
576
579
  secretId: string;
577
580
  fieldKey: string;
@@ -586,57 +589,57 @@ declare class AgentApiClient {
586
589
  * Plaintext fields ship the value inline.
587
590
  */
588
591
  createSecret(args: {
589
- scope: SecretScope;
592
+ scope: SecretScope$1;
590
593
  scopeId: string;
591
594
  secretId: string;
592
595
  secretName: string;
593
- category?: SecretCategory;
596
+ category?: SecretCategory$1;
594
597
  description?: string;
595
598
  tags?: string[];
596
599
  fields: {
597
600
  key: string;
598
- format?: FieldFormat;
599
- sensitivity: FieldSensitivity;
601
+ format?: FieldFormat$1;
602
+ sensitivity: FieldSensitivity$1;
600
603
  value?: string;
601
- envelope?: EncryptedEnvelopeV1;
604
+ envelope?: EncryptedEnvelopeV1$1;
602
605
  }[];
603
606
  reason?: string;
604
- }): Promise<SecretAggregate>;
607
+ }): Promise<SecretAggregate$1>;
605
608
  /** Fetch the secret aggregate plus per-field encrypted envelopes. */
606
609
  getSecret(args: {
607
- scope: SecretScope;
610
+ scope: SecretScope$1;
608
611
  scopeId: string;
609
612
  secretId: string;
610
613
  }): Promise<{
611
- aggregate: SecretAggregate;
612
- envelopes: FieldEnvelope[];
614
+ aggregate: SecretAggregate$1;
615
+ envelopes: FieldEnvelope$1[];
613
616
  }>;
614
617
  /** Fetch one field. Plaintext: value inline. Encrypted: envelope. */
615
618
  getSecretField(args: {
616
- scope: SecretScope;
619
+ scope: SecretScope$1;
617
620
  scopeId: string;
618
621
  secretId: string;
619
622
  fieldKey: string;
620
623
  }): Promise<{
621
624
  key: string;
622
- sensitivity: FieldSensitivity;
623
- format?: FieldFormat;
625
+ sensitivity: FieldSensitivity$1;
626
+ format?: FieldFormat$1;
624
627
  value?: string;
625
- envelope?: EncryptedEnvelopeV1;
628
+ envelope?: EncryptedEnvelopeV1$1;
626
629
  rotatedAt?: string;
627
630
  createdAt: string;
628
631
  updatedAt: string;
629
632
  }>;
630
633
  /** Add OR rotate one field. */
631
634
  setSecretField(args: {
632
- scope: SecretScope;
635
+ scope: SecretScope$1;
633
636
  scopeId: string;
634
637
  secretId: string;
635
638
  fieldKey: string;
636
- sensitivity: FieldSensitivity;
637
- format?: FieldFormat;
639
+ sensitivity: FieldSensitivity$1;
640
+ format?: FieldFormat$1;
638
641
  value?: string;
639
- envelope?: EncryptedEnvelopeV1;
642
+ envelope?: EncryptedEnvelopeV1$1;
640
643
  reason?: string;
641
644
  }): Promise<{
642
645
  fieldKey: string;
@@ -644,49 +647,49 @@ declare class AgentApiClient {
644
647
  }>;
645
648
  /** Remove one field. */
646
649
  removeSecretField(args: {
647
- scope: SecretScope;
650
+ scope: SecretScope$1;
648
651
  scopeId: string;
649
652
  secretId: string;
650
653
  fieldKey: string;
651
654
  }): Promise<void>;
652
655
  /** Update secret-level metadata (name/description/tags/category). */
653
656
  updateSecretMetadata(args: {
654
- scope: SecretScope;
657
+ scope: SecretScope$1;
655
658
  scopeId: string;
656
659
  secretId: string;
657
660
  secretName?: string;
658
661
  description?: string;
659
662
  tags?: string[];
660
- category?: SecretCategory;
663
+ category?: SecretCategory$1;
661
664
  reason?: string;
662
- }): Promise<SecretAggregate>;
665
+ }): Promise<SecretAggregate$1>;
663
666
  /** List metadata for secrets in a scope. Optional filters route through the byFacet GSI. */
664
667
  listSecrets(args: {
665
- scope: SecretScope;
668
+ scope: SecretScope$1;
666
669
  scopeId: string;
667
- category?: SecretCategory;
670
+ category?: SecretCategory$1;
668
671
  tag?: string;
669
672
  fieldKey?: string;
670
- }): Promise<SecretMetadata[]>;
673
+ }): Promise<SecretMetadata$1[]>;
671
674
  /** Bounded changelog read — metadata-only audit entries. */
672
675
  getSecretHistory(args: {
673
- scope: SecretScope;
676
+ scope: SecretScope$1;
674
677
  scopeId: string;
675
678
  secretId: string;
676
679
  limit?: number;
677
680
  cursor?: string;
678
681
  }): Promise<{
679
- entries: ChangelogEntry[];
682
+ entries: ChangelogEntry$1[];
680
683
  nextCursor?: string;
681
684
  }>;
682
685
  /** Delete a secret (and all its field rows + tag rows + changelog rows). */
683
686
  deleteSecret(args: {
684
- scope: SecretScope;
687
+ scope: SecretScope$1;
685
688
  scopeId: string;
686
689
  secretId: string;
687
690
  }): Promise<void>;
688
691
  /** Enumerate scopes (org/team/project/agent) this agent can access. */
689
- listSecretScopes(): Promise<ScopeInfo[]>;
692
+ listSecretScopes(): Promise<ScopeInfo$1[]>;
690
693
  /**
691
694
  * Returns the calling agent's own identity context — `{ agentId, tenantId }`
692
695
  * decoded server-side from the agent API token. Used by the