@alfe.ai/agent-api-client 0.1.4 → 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
@@ -202,24 +202,125 @@ declare class AgentApiClient {
202
202
  clientSecret: string;
203
203
  displayName?: string;
204
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
+ */
205
213
  getGithubCredentials(): Promise<{
206
214
  login: string;
207
215
  accessToken: string;
208
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
+ */
209
248
  getXeroCredentials(): Promise<{
210
249
  accessToken: string;
211
250
  accessTokenExpiresAt: string;
212
251
  xeroTenantId: string;
213
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
+ }>;
214
273
  refreshXeroToken(): Promise<{
215
274
  accessToken: string;
216
275
  expiresAt: string;
217
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
+ */
218
293
  getNotionCredentials(): Promise<{
219
294
  accessToken: string;
220
295
  workspaceId: string;
221
296
  workspaceName: string;
222
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
+ */
223
324
  getAtlassianCredentials(): Promise<{
224
325
  accessToken: string;
225
326
  refreshToken: string;
@@ -236,16 +337,177 @@ declare class AgentApiClient {
236
337
  accessToken: string;
237
338
  expiresAt: string;
238
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
+ */
239
408
  getMYOBCredentials(): Promise<{
240
409
  accessToken: string;
241
410
  accessTokenExpiresAt: string;
242
411
  myobBusinessId: string;
243
412
  clientId: string;
244
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
+ }>;
245
434
  refreshMYOBToken(): Promise<{
246
435
  accessToken: string;
247
436
  expiresAt: string;
248
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
+ }>;
249
511
  getTeamsCredentials(): Promise<{
250
512
  agentId: string;
251
513
  tenantId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;AA8ES,UA/BQ,oBAAA,CA+BR;EAAM,MAAA,EAAA,MAAA;EAGE,MAAA,EAAA,MAAA;AAMjB;AAQiB,UAzCA,aAAA,CAyCmB;EAQnB,OAAA,EAAA,MAAA;EASA,QAAA,EAAA,MAAA;EAQA,WAAA,EAAA,MAAa;EASb,QAAA,EAAA,MAAA;EAQA,MAAA,EAAA,OAAA,GAAA,SAAkB,GAAA,QAAA;EAMlB,SAAA,CAAA,EAAA,MAAe;EAenB,SAAA,CAAA,EAAA,MAAc;EAAA,QAAA,CAAA,EAAA,MAAA;;AAiC6C,UA9HvD,iBAAA,CA8HuD;MAAjB,EAAA,MAAA;MAOpB,EAAA,MAAA;UAAR,EAAA,MAAA;MAML,CAAA,EAAA,MAAA;cAAhB,CAAA,EAAA,MAAA;YAYQ,CAAA,EAAA,OAAA;;AASA,UAvJG,YAAA,CAuJH;SAAR,EAAA,CAAA;SAO0B,EAAA,MAAA;UAAR,EAAA,MAAA;OAI4C,EA9J3D,MA8J2D,CAAA,MAAA,EA9J5C,iBA8J4C,CAAA;;AAOpB,UAlK/B,gBAAA,CAkK+B;MAApB,EAAA,MAAA;KAIuB,EAAA,MAAA;W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;;;;;;;0BAgDH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2DAgEiC;;;;;yBAmBlC;;;;;;;;;;;;;mBAgBZ;MACb;;;;uBAOuB;;;;;;;;;;;QAM8D;;;;;;;;;;;;;MAarF;;;;;;;;;;;;WAmCK;;;;MAIL,QAAQ;;;;;;;;WAcH;;;;;MAKL;;;;;;;;;;WAcK;;;;eAII;;;;;eAKA;mBACI;;iBAEF;;;MAGX,QAAQ;;;WAaH;;;MAGL;eAAqB;eAA4B;;;;WAQ5C;;;;MAIL;;iBAEW;aACJ;;eAEE;;;;;;;WAYJ;;;;iBAIM;aACJ;;eAEE;;MAET;;;;;;WAUK;;;;MAIL;;;WASK;;;;;;eAMI;;MAET,QAAQ;;;WAUH;;eAEI;;;MAGT,QAAQ;;;WAcH;;;;;MAKL;aAAmB;;;;;WAYd;;;MAGL;;sBAQsB,QAAQ;;;;;;;;;;YAmBlB;;;;;;;;;MASZ;;;;;;;;;;;;;;;;MAsBA;;;0CAS0C;;;;;;;;;;MAS1C;;;;;;;;;;MASA;;;;;;;;;;;;MAWA;;;;;;;;;;;MAWA;;;;;MASA;;;;;;;;;;MAUA;;;;;;;;;;;;;;;;;;MAkBA;;;;;;;;;;;;;;;;MAiBA;;;;;;;;;;;;;;;;;;MA2BD;;;;;;;;;;;MAeC;;;;;;;;;;MAqBA;;;;;;;;;;;;;;;;;;;;;;;;MAsBA;;;;;;;;;;;;MAsBA;;;;wDAYwD;;;;uCAWjB;;;;;;;;;;;oBAOnB;;;;;;;;kCAOc;;;iBAMjB;;;;;;;;;;;;;;;MAcjB;;;;;;2BAiB2B;;;;+BAII;;;;;;;;;;MAY/B;;;;MAUA;;;;;MAWA;iCASiC;;;;;;;;;;;MAcjC"}
package/dist/index.js CHANGED
@@ -145,6 +145,14 @@ var AgentApiClient = class {
145
145
  async getGoogleChatCredentials() {
146
146
  return this.request("/agent/google-chat/credentials");
147
147
  }
148
+ /**
149
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
150
+ * default-connection" shape). Use `getGithubAccounts()` for the multi-
151
+ * account shape required by Pattern A — explicit selector args on every
152
+ * tool. Retained because the `@alfe.ai/openclaw-github` proxy is the
153
+ * only consumer that knows about Pattern A; legacy env-interpolation
154
+ * callers will keep hitting `/credentials` until they move to the proxy.
155
+ */
148
156
  async getGithubCredentials() {
149
157
  const raw = await this.request("/agent/connect/github/credentials");
150
158
  return {
@@ -152,6 +160,37 @@ var AgentApiClient = class {
152
160
  accessToken: raw.accessToken
153
161
  };
154
162
  }
163
+ /**
164
+ * Pattern A: multi-account credential fetch for GitHub.
165
+ *
166
+ * Returns every agent-scoped GitHub connection. The caller is expected
167
+ * to require a `login` selector on every credential-touching tool and
168
+ * look up the matching account at dispatch time.
169
+ *
170
+ * GitHub OAuth tokens have no expiry (`tokenLifecycle: "no_expiry"`),
171
+ * so there is intentionally no `refreshGithubAccountToken` method — if
172
+ * a token is revoked the user must re-run the OAuth flow.
173
+ *
174
+ * Returned `accounts[i].login` is the GitHub username — the stable
175
+ * cross-session identifier the LLM should pass.
176
+ */
177
+ async getGithubAccounts() {
178
+ return { accounts: (await this.request("/agent/connect/github/accounts")).accounts.map((a) => ({
179
+ connectionId: a.connectionId,
180
+ accountIdentifier: a.accountIdentifier,
181
+ displayName: a.displayName,
182
+ connectedAt: a.connectedAt,
183
+ accessToken: a.accessToken ?? "",
184
+ login: a.login ?? a.accountIdentifier,
185
+ scopes: a.scopes ?? ""
186
+ })) };
187
+ }
188
+ /**
189
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
190
+ * default-connection" shape). Use `getXeroAccounts()` for the multi-
191
+ * account shape required by Pattern A — explicit selector args on every
192
+ * tool. This method will be removed once all consumers migrate.
193
+ */
155
194
  async getXeroCredentials() {
156
195
  const raw = await this.request("/agent/connect/xero/credentials");
157
196
  return {
@@ -160,9 +199,49 @@ var AgentApiClient = class {
160
199
  xeroTenantId: raw.xeroTenantId ?? ""
161
200
  };
162
201
  }
202
+ /**
203
+ * Pattern A: multi-account credential fetch for Xero. Returns every
204
+ * agent-scoped Xero connection. The caller is expected to require a
205
+ * selector arg (e.g. `xeroTenantId`) on every credential-touching tool
206
+ * and look up the matching account by that selector at dispatch time.
207
+ *
208
+ * Returned `accounts[i].accountIdentifier` is the Xero tenantId — the
209
+ * stable cross-session identifier the LLM should pass.
210
+ */
211
+ async getXeroAccounts() {
212
+ return { accounts: (await this.request("/agent/connect/xero/accounts")).accounts.map((a) => ({
213
+ connectionId: a.connectionId,
214
+ accountIdentifier: a.accountIdentifier,
215
+ displayName: a.displayName,
216
+ connectedAt: a.connectedAt,
217
+ accessToken: a.accessToken,
218
+ accessTokenExpiresAt: a.accessTokenExpiresAt ?? "",
219
+ xeroTenantId: a.xeroTenantId ?? a.accountIdentifier
220
+ })) };
221
+ }
163
222
  async refreshXeroToken() {
164
223
  return this.request("/agent/connect/xero/refresh", { method: "POST" });
165
224
  }
225
+ /**
226
+ * Pattern A: refresh a specific Xero connection by its `accountIdentifier`
227
+ * (the Xero `tenantId`). The legacy `refreshXeroToken()` only refreshes
228
+ * the *primary* connection, which is wrong for multi-tenant Xero where
229
+ * each tenant has its own non-interchangeable access token.
230
+ */
231
+ async refreshXeroAccountToken(xeroTenantId) {
232
+ const path = `/agent/connect/xero/accounts/${encodeURIComponent(xeroTenantId)}/refresh`;
233
+ const raw = await this.request(path, { method: "POST" });
234
+ return {
235
+ accessToken: raw.accessToken,
236
+ accessTokenExpiresAt: raw.accessTokenExpiresAt ?? "",
237
+ expiresAt: raw.expiresAt ?? ""
238
+ };
239
+ }
240
+ /**
241
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
242
+ * default-connection" shape). Use `getNotionAccounts()` for the multi-
243
+ * account shape required by Pattern A.
244
+ */
166
245
  async getNotionCredentials() {
167
246
  const raw = await this.request("/agent/connect/notion/credentials");
168
247
  return {
@@ -171,6 +250,32 @@ var AgentApiClient = class {
171
250
  workspaceName: raw.workspaceName ?? ""
172
251
  };
173
252
  }
253
+ /**
254
+ * Pattern A: multi-account credential fetch for Notion. Returns every
255
+ * agent-scoped Notion connection. The caller is expected to require a
256
+ * selector arg (e.g. `workspaceId`) on every credential-touching tool.
257
+ *
258
+ * Returned `accounts[i].accountIdentifier` is the Notion workspaceId.
259
+ */
260
+ async getNotionAccounts() {
261
+ return { accounts: (await this.request("/agent/connect/notion/accounts")).accounts.map((a) => ({
262
+ connectionId: a.connectionId,
263
+ accountIdentifier: a.accountIdentifier,
264
+ displayName: a.displayName,
265
+ connectedAt: a.connectedAt,
266
+ accessToken: a.accessToken,
267
+ workspaceId: a.workspaceId ?? a.accountIdentifier,
268
+ workspaceName: a.workspaceName ?? a.displayName ?? ""
269
+ })) };
270
+ }
271
+ /**
272
+ * @deprecated Returns a single primary Atlassian Connection's credentials
273
+ * (one OAuth user, one cloudId) — the legacy "pick-the-default-connection"
274
+ * shape. Atlassian is multi-site by nature (each OAuth user may have
275
+ * access to multiple Cloud sites), so Pattern A plugins MUST use
276
+ * `getAtlassianAccounts()` to discover the full set and dispatch via
277
+ * the `cloudId` selector arg.
278
+ */
174
279
  async getAtlassianCredentials() {
175
280
  const raw = await this.request("/agent/connect/atlassian/credentials");
176
281
  return {
@@ -189,6 +294,72 @@ var AgentApiClient = class {
189
294
  async refreshAtlassianToken() {
190
295
  return this.request("/agent/connect/atlassian/refresh", { method: "POST" });
191
296
  }
297
+ /**
298
+ * Pattern A: multi-account / multi-site credential fetch for Atlassian.
299
+ *
300
+ * Returns every agent-scoped Atlassian Connection. Each Connection is
301
+ * one OAuth user with a single access token and N accessible Cloud
302
+ * sites (`availableSites`). The caller is expected to:
303
+ *
304
+ * 1. Flatten (connection × cloudId) into one MCP child per site.
305
+ * 2. Require a `cloudId` selector on every credential-touching tool.
306
+ * 3. Use the access token bound to the Connection that owns the
307
+ * requested `cloudId` (Atlassian shares one access token across
308
+ * all sites accessible to the OAuth user).
309
+ *
310
+ * Per-account token refresh uses `refreshAtlassianAccountToken(email)`
311
+ * — refreshing one Connection rotates its single access token, which
312
+ * then applies to every cloudId for that Connection.
313
+ *
314
+ * Returned `accounts[i].accountIdentifier` is the OAuth user's email
315
+ * — the stable cross-session identifier for refresh purposes. The LLM
316
+ * never sees this directly: it picks a site via the `cloudId` arg
317
+ * instead.
318
+ */
319
+ async getAtlassianAccounts() {
320
+ return { accounts: (await this.request("/agent/connect/atlassian/accounts")).accounts.map((a) => ({
321
+ connectionId: a.connectionId,
322
+ accountIdentifier: a.accountIdentifier,
323
+ displayName: a.displayName,
324
+ connectedAt: a.connectedAt,
325
+ accessToken: a.accessToken ?? "",
326
+ accessTokenExpiresAt: a.accessTokenExpiresAt ?? "",
327
+ clientId: a.clientId ?? "",
328
+ clientSecret: a.clientSecret ?? "",
329
+ cloudId: a.cloudId ?? "",
330
+ siteName: a.siteName ?? "",
331
+ siteUrl: a.siteUrl ?? "",
332
+ availableSites: a.availableSites ?? []
333
+ })) };
334
+ }
335
+ /**
336
+ * Pattern A: refresh a specific Atlassian Connection by `accountIdentifier`
337
+ * (the OAuth user's email).
338
+ *
339
+ * Atlassian rotates refresh tokens (`rotatesRefreshToken: true`); the
340
+ * server-side per-account refresh endpoint handles rotation and
341
+ * persistence. Refreshing one Connection updates its single access
342
+ * token, which applies to every accessible Cloud site (cloudId) for
343
+ * that OAuth user.
344
+ *
345
+ * Returns the new access token + expiry. The proxy is responsible for
346
+ * fanning the new token out to every child server it spawned for
347
+ * cloudIds owned by this Connection.
348
+ */
349
+ async refreshAtlassianAccountToken(accountIdentifier) {
350
+ const path = `/agent/connect/atlassian/accounts/${encodeURIComponent(accountIdentifier)}/refresh`;
351
+ const raw = await this.request(path, { method: "POST" });
352
+ return {
353
+ accessToken: raw.accessToken,
354
+ accessTokenExpiresAt: raw.accessTokenExpiresAt ?? "",
355
+ expiresAt: raw.expiresAt ?? ""
356
+ };
357
+ }
358
+ /**
359
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
360
+ * default-connection" shape). Use `getMYOBAccounts()` for the multi-
361
+ * account shape required by Pattern A.
362
+ */
192
363
  async getMYOBCredentials() {
193
364
  const raw = await this.request("/agent/connect/myob/credentials");
194
365
  return {
@@ -198,9 +369,109 @@ var AgentApiClient = class {
198
369
  clientId: raw.clientId
199
370
  };
200
371
  }
372
+ /**
373
+ * Pattern A: multi-account credential fetch for MYOB. Returns every
374
+ * agent-scoped MYOB connection. The caller is expected to require a
375
+ * selector arg (e.g. `myobBusinessId` / `accountIdentifier`) on every
376
+ * credential-touching tool.
377
+ *
378
+ * Returned `accounts[i].accountIdentifier` is the MYOB businessId.
379
+ */
380
+ async getMYOBAccounts() {
381
+ return { accounts: (await this.request("/agent/connect/myob/accounts")).accounts.map((a) => ({
382
+ connectionId: a.connectionId,
383
+ accountIdentifier: a.accountIdentifier,
384
+ displayName: a.displayName,
385
+ connectedAt: a.connectedAt,
386
+ accessToken: a.accessToken,
387
+ accessTokenExpiresAt: a.accessTokenExpiresAt ?? "",
388
+ myobBusinessId: a.myobBusinessId ?? a.accountIdentifier,
389
+ clientId: a.clientId
390
+ })) };
391
+ }
201
392
  async refreshMYOBToken() {
202
393
  return this.request("/agent/connect/myob/refresh", { method: "POST" });
203
394
  }
395
+ /**
396
+ * Microsoft 365 (delegated OAuth) credential fetch — single-account shape.
397
+ *
398
+ * @deprecated Use `getMicrosoftAccounts()` and dispatch via the `email`
399
+ * selector once per-account plugins land. Retained because the existing
400
+ * `integrations/connect/microsoft/hooks/post_activate.mjs` writes
401
+ * `mgc` credentials for the single (default) Microsoft account.
402
+ *
403
+ * Returns the agent's effective Microsoft delegated-OAuth credentials.
404
+ * Distinct from `getTeamsCredentials()` (Azure bot credentials for the
405
+ * Teams adapter, which is admin-consent flow on services/microsoft, not
406
+ * delegated OAuth on services/connect).
407
+ */
408
+ async getMicrosoftCredentials() {
409
+ const raw = await this.request("/agent/connect/microsoft/credentials");
410
+ return {
411
+ accessToken: raw.accessToken ?? "",
412
+ accessTokenExpiresAt: raw.accessTokenExpiresAt,
413
+ refreshToken: raw.refreshToken ?? "",
414
+ clientId: raw.clientId ?? "",
415
+ clientSecret: raw.clientSecret ?? "",
416
+ email: raw.email ?? raw.accountIdentifier,
417
+ microsoftTenantId: raw.microsoftTenantId,
418
+ workspaceDomain: raw.workspaceDomain
419
+ };
420
+ }
421
+ /**
422
+ * Pattern A: multi-account credential fetch for Microsoft 365.
423
+ *
424
+ * Returns every agent-scoped Microsoft connection. The caller is expected
425
+ * to require an `email` selector on every credential-touching tool and
426
+ * look up the matching account at dispatch time.
427
+ *
428
+ * Returned `accounts[i].accountIdentifier` is the user's primary email
429
+ * (or the tid claim as fallback) — the stable cross-session identifier
430
+ * the LLM should pass.
431
+ *
432
+ * Per-account token refresh is exposed via `refreshMicrosoftAccountToken`,
433
+ * NOT `refreshXeroAccountToken` — Microsoft refresh tokens are not
434
+ * interchangeable across (tenant, user) pairs.
435
+ */
436
+ async getMicrosoftAccounts() {
437
+ return { accounts: (await this.request("/agent/connect/microsoft/accounts")).accounts.map((a) => ({
438
+ connectionId: a.connectionId,
439
+ accountIdentifier: a.accountIdentifier,
440
+ displayName: a.displayName,
441
+ connectedAt: a.connectedAt,
442
+ accessToken: a.accessToken ?? "",
443
+ accessTokenExpiresAt: a.accessTokenExpiresAt ?? "",
444
+ refreshToken: a.refreshToken ?? "",
445
+ clientId: a.clientId ?? "",
446
+ clientSecret: a.clientSecret ?? "",
447
+ email: a.email ?? a.accountIdentifier,
448
+ microsoftTenantId: a.microsoftTenantId ?? "",
449
+ workspaceDomain: a.workspaceDomain ?? ""
450
+ })) };
451
+ }
452
+ /**
453
+ * Pattern A: refresh a specific Microsoft 365 connection by its
454
+ * `accountIdentifier`. For Microsoft, `accountIdentifier` is the user's
455
+ * email when the Graph profile fetch succeeded at connect time, and the
456
+ * Azure tenant id (`tid` claim) as fallback. Callers should pass the
457
+ * value returned by `getMicrosoftAccounts()` rather than synthesising
458
+ * an email locally.
459
+ *
460
+ * Microsoft refresh tokens are bound to a specific (tenant, user) pair —
461
+ * they are NOT interchangeable across accounts, so per-account refresh
462
+ * is mandatory. The generic /accounts/{accountIdentifier}/refresh
463
+ * endpoint walks the agent's full visible scope chain to find a matching
464
+ * connection (works for inherited team/project Microsoft connections).
465
+ */
466
+ async refreshMicrosoftAccountToken(accountIdentifier) {
467
+ const path = `/agent/connect/microsoft/accounts/${encodeURIComponent(accountIdentifier)}/refresh`;
468
+ const raw = await this.request(path, { method: "POST" });
469
+ return {
470
+ accessToken: raw.accessToken,
471
+ accessTokenExpiresAt: raw.accessTokenExpiresAt ?? "",
472
+ expiresAt: raw.expiresAt ?? ""
473
+ };
474
+ }
204
475
  async getTeamsCredentials() {
205
476
  return this.request("/agent/microsoft/credentials");
206
477
  }