@alfe.ai/agent-api-client 0.18.0 → 0.19.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
@@ -118,1582 +118,1602 @@ declare class ApiBase {
118
118
  }
119
119
  //# sourceMappingURL=transport.d.ts.map
120
120
  //#endregion
121
- //#region src/domains/integrations.d.ts
122
- /**
123
- * One entry in the agent's EFFECTIVE integration list. Agent-scope install
124
- * rows keep their full public row shape (config included, `scope: "agent"`);
125
- * connection-/channel-/custom-driven activations and inherited
126
- * org/team/project installs have no agent-scope row and appear as the
127
- * narrower projection. Discriminate on `config`: only the agent-scope row
128
- * arm carries it (`source` alone is NOT a discriminator — inherited explicit
129
- * rows land in the narrow arm with `source: "explicit"` too).
130
- */
131
- type AgentIntegrationListEntry = (IntegrationInstall$1 & {
132
- source: "explicit";
133
- }) | {
134
- integrationId: string;
135
- version: string;
136
- desiredStatus: IntegrationDesiredStatus;
137
- actualStatus: IntegrationActualStatus;
138
- source: IntegrationActivationSource$1;
139
- /** Winning row's scope — present only on inherited explicit entries. */
140
- scope?: IntegrationScope;
141
- scopeId?: string;
142
- config?: undefined;
143
- connectionId?: string;
144
- channelId?: string;
145
- displayName?: string;
146
- icon?: string;
147
- availableVersion?: string;
148
- reinstallRequestedAt?: string;
149
- };
150
- declare class IntegrationsApi extends ApiBase {
121
+ //#region src/domains/connect-credentials.d.ts
122
+ /** Provider projection plus the stable identity of its backing Connection. */
123
+ interface ConnectProviderAccount {
124
+ connectionId: string;
125
+ accountIdentifier: string;
126
+ displayName: string | null;
127
+ connectedAt: string;
128
+ [key: string]: unknown;
129
+ }
130
+ interface ConnectProviderAccounts {
131
+ provider: string;
132
+ accounts: ConnectProviderAccount[];
133
+ }
134
+ declare class ConnectCredentialsApi extends ApiBase {
151
135
  /**
152
- * List the integrations EFFECTIVE for this agent explicit agent-scope
153
- * installs plus driven activations (google, myob, xero, google-chat, …)
154
- * and inherited org-scope installs, discriminated by `source`.
136
+ * Discover all active Connections visible to this agent for one provider.
137
+ * Preserve the provider-specific credential projection without guessing a
138
+ * token shape. These rows contain secrets: tool discovery must explicitly
139
+ * select public identity fields, never return/spread the complete response.
140
+ * Use getConnectionCredentials(connectionId) for fresh per-call authority.
155
141
  */
156
- listIntegrations(): Promise<{
157
- integrations: AgentIntegrationListEntry[];
142
+ getConnectProviderAccounts(provider: string): Promise<ConnectProviderAccounts>;
143
+ /**
144
+ * Returns every connected Google account for the agent. Multi-account by
145
+ * design — the openclaw-google plugin requires the LLM to pass `email`
146
+ * explicitly to `google_run_command` so an account is always selected
147
+ * deliberately.
148
+ *
149
+ * 2026-05-14 (connections-redesign PR 1): the legacy flat shape (`email`,
150
+ * `refreshToken`, `accessToken`, etc., populated from the default account)
151
+ * is gone. Iterate over `accounts`.
152
+ */
153
+ getGoogleCredentials(): Promise<{
154
+ accounts: {
155
+ email: string;
156
+ refreshToken: string;
157
+ clientId: string;
158
+ clientSecret: string;
159
+ displayName?: string;
160
+ connectedAt?: string;
161
+ }[];
158
162
  }>;
159
- getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult$1>;
160
- updateIntegrationConfig(integrationId: string, config: Record<string, unknown>): Promise<void>;
161
- installIntegration(integrationId: string, options?: {
162
- version?: string;
163
- config?: Record<string, unknown>;
164
- }): Promise<IntegrationInstall$1>;
165
- removeIntegration(integrationId: string): Promise<IntegrationInstall$1>;
166
- getOAuthUrl(provider: string, scopes?: string[], options?: {
167
- shop?: string;
168
- }): Promise<{
169
- url: string;
170
- provider: string;
171
- expiresIn: number;
163
+ disconnectGoogleAccount(email: string): Promise<{
164
+ accounts: {
165
+ email: string;
166
+ displayName?: string;
167
+ connectedAt?: string;
168
+ }[];
172
169
  }>;
173
- getOAuthStatus(provider: string): Promise<{
170
+ getGoogleChatCredentials(): Promise<{
171
+ email: string;
172
+ refreshToken: string;
173
+ clientId: string;
174
+ clientSecret: string;
175
+ displayName?: string;
176
+ }>;
177
+ /**
178
+ * Fetch decrypted credentials for ONE specific connection by its
179
+ * stable connectionId (connection-scoped, vs the provider-scoped
180
+ * `get<Provider>Credentials` helpers). Used by the daemon to resolve
181
+ * a Custom Connection-driven integration's credentials from the
182
+ * exact connection it was installed from — every custom connection
183
+ * shares the `custom` provider id, so provider-scoping is ambiguous.
184
+ *
185
+ * For custom connections `accessToken` is the JSON-encoded secret
186
+ * bundle (the daemon un-bundles it); non-secret fields are on
187
+ * `providerMetadata`. The endpoint enforces that the connection is in
188
+ * the calling agent's effective scope (403 otherwise).
189
+ */
190
+ getConnectionCredentials(connectionId: string): Promise<{
174
191
  provider: string;
175
- connected: boolean;
176
- config?: Record<string, string>;
192
+ connectionId: string;
193
+ accountIdentifier?: string;
194
+ accessToken?: string;
195
+ providerMetadata?: Record<string, unknown>;
196
+ [key: string]: unknown;
177
197
  }>;
178
- getRegistry(): Promise<{
179
- integrations: RegistryEntry$1[];
198
+ /**
199
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
200
+ * default-connection" shape). Use `getGithubAccounts()` for the multi-
201
+ * account shape required by Pattern A — explicit selector args on every
202
+ * tool. Retained because the `@alfe.ai/github-mcp` proxy is the
203
+ * only consumer that knows about Pattern A; legacy env-interpolation
204
+ * callers will keep hitting `/credentials` until they move to the proxy.
205
+ */
206
+ getGithubCredentials(): Promise<{
207
+ login: string;
208
+ accessToken: string;
180
209
  }>;
181
- }
182
- //# sourceMappingURL=integrations.d.ts.map
183
- //#endregion
184
- //#region src/domains/workspace.d.ts
185
- /** Response of GET /agent/workspace (services/agents). */
186
- interface AgentWorkspaceInfo {
187
- templateKey?: string;
188
- defaultModel?: string;
189
- installedFrom?: {
190
- templateKey: string;
191
- authorTenantId: string;
192
- version: number;
193
- };
194
- runtime?: string;
195
- teams?: {
196
- teamId: string;
197
- name: string;
198
- description?: string;
199
- parentTeamId?: string;
200
- }[];
201
- projects?: {
202
- projectId: string;
203
- name: string;
204
- description?: string;
205
- status: string;
206
- parentProjectId?: string;
207
- }[];
208
- teamIds?: string[];
209
- projectIds?: string[];
210
- }
211
- declare class WorkspaceApi extends ApiBase {
212
210
  /**
213
- * GET /agent/workspace workspace config for the authenticated agent
214
- * (template assignment, default model, org roster).
211
+ * Pattern A: multi-account credential fetch for GitHub.
212
+ *
213
+ * Returns every agent-scoped GitHub connection. The caller is expected
214
+ * to require a `login` selector on every credential-touching tool and
215
+ * look up the matching account at dispatch time.
216
+ *
217
+ * GitHub OAuth tokens have no expiry (`tokenLifecycle: "no_expiry"`),
218
+ * so there is intentionally no `refreshGithubAccountToken` method — if
219
+ * a token is revoked the user must re-run the OAuth flow.
220
+ *
221
+ * Returned `accounts[i].login` is the GitHub username — the stable
222
+ * cross-session identifier the LLM should pass.
215
223
  */
216
- getWorkspace(): Promise<AgentWorkspaceInfo>;
224
+ getGithubAccounts(): Promise<{
225
+ accounts: {
226
+ connectionId: string;
227
+ accountIdentifier: string;
228
+ displayName: string | null;
229
+ connectedAt: string;
230
+ accessToken: string;
231
+ login: string;
232
+ scopes: string;
233
+ }[];
234
+ }>;
217
235
  /**
218
- * GET /templates/{key}/files persona/workspace file contents for a
219
- * template the agent has access to. Pass `version` to pin to the version
220
- * the agent was installed from (omit the endpoint resolves `latest`).
236
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
237
+ * default-connection" shape). Use `getXeroAccounts()` for the multi-
238
+ * account shape required by Pattern A explicit selector args on every
239
+ * tool. This method will be removed once all consumers migrate.
221
240
  */
222
- getTemplateFiles(templateKey: string, opts?: {
223
- version?: number;
224
- }): Promise<{
225
- files: Record<string, string>;
241
+ getXeroCredentials(): Promise<{
242
+ accessToken: string;
243
+ accessTokenExpiresAt: string;
244
+ xeroTenantId: string;
226
245
  }>;
227
- }
228
- //# sourceMappingURL=workspace.d.ts.map
229
- //#endregion
230
- //#region src/domains/sync.d.ts
231
- interface SyncAgentInfo {
232
- agentId: string;
233
- tenantId: string;
234
- displayName: string;
235
- s3Prefix: string;
236
- status: "stale" | "syncing" | "synced";
237
- fileCount?: number;
238
- totalSize?: number;
239
- lastSync?: string;
240
- }
241
- interface SyncManifestEntry {
242
- hash: string;
243
- size: number;
244
- modified: string;
245
- etag?: string;
246
- storageClass?: string;
247
- compressed?: boolean;
248
- }
249
- interface SyncManifest {
250
- version: 1;
251
- agentId: string;
252
- lastSync: string;
253
- files: Record<string, SyncManifestEntry>;
254
- }
255
- interface SyncPresignedUrl {
256
- path: string;
257
- url: string;
258
- expiresAt: string;
259
- }
260
- interface SyncConfirmedUpload {
261
- filePath: string;
262
- hash: string;
263
- size: number;
264
- storageClass: "STANDARD" | "GLACIER_IR";
265
- syncedAt: string;
266
- }
267
- interface SyncReconstructFile {
268
- path: string;
269
- size: number;
270
- url: string;
271
- storageClass?: string;
272
- compressed?: boolean;
273
- }
274
- interface SyncReconstructBundle {
275
- agentId: string;
276
- mode: "full" | "active" | "memory";
277
- fileCount: number;
278
- totalSize: number;
279
- files: SyncReconstructFile[];
280
- expiresAt: string;
281
- }
282
- interface SyncAgentStats {
283
- agentId: string;
284
- standardBytes: number;
285
- glacierBytes: number;
286
- fileCount: number;
287
- lastSyncAt: string | null;
288
- }
289
- interface SyncFileEntry {
290
- filePath: string;
291
- size: number;
292
- modified: string;
293
- contentHash: string;
294
- storageClass?: string;
295
- compressed?: boolean;
296
- }
297
- interface SyncSessionEntry {
298
- sessionId: string;
299
- size: number;
300
- lastModified: string;
301
- storageClass?: string;
302
- isArchived: boolean;
303
- }
304
- interface SyncSessionContent {
305
- sessionId: string;
306
- content: string;
307
- compressed: boolean;
308
- }
309
- interface SharedFileEntry {
310
- filePath: string;
311
- fileName: string;
312
- size: number;
313
- contentType?: string;
314
- }
315
- declare class SyncApi extends ApiBase {
316
- syncRegister(args?: {
317
- displayName?: string;
318
- }): Promise<{
319
- agent: SyncAgentInfo;
320
- }>;
321
- syncGetManifest(): Promise<SyncManifest>;
322
- syncPresign(args: {
323
- files: {
324
- path: string;
325
- operation: "put" | "get";
326
- contentType?: string;
246
+ /**
247
+ * Pattern A: multi-account credential fetch for Xero. Returns every
248
+ * agent-scoped Xero connection. The caller is expected to require a
249
+ * selector arg (e.g. `xeroTenantId`) on every credential-touching tool
250
+ * and look up the matching account by that selector at dispatch time.
251
+ *
252
+ * `xeroTenantId` is the model-facing organisation selector. The separate
253
+ * `accountIdentifier` is the Connect persistence key used for refresh and
254
+ * may be an email; never substitute one for the other.
255
+ */
256
+ getXeroAccounts(): Promise<{
257
+ accounts: {
258
+ connectionId: string;
259
+ accountIdentifier: string;
260
+ displayName: string | null;
261
+ connectedAt: string;
262
+ accessToken: string;
263
+ accessTokenExpiresAt: string;
264
+ xeroTenantId: string;
327
265
  }[];
328
- }): Promise<{
329
- urls: SyncPresignedUrl[];
330
- }>;
331
- syncConfirmUpload(args: {
332
- filePath: string;
333
- hash: string;
334
- size: number;
335
- storageClass?: "STANDARD" | "GLACIER_IR";
336
- }): Promise<SyncConfirmedUpload>;
337
- syncReconstruct(args: {
338
- mode: "full" | "active" | "memory";
339
- }): Promise<SyncReconstructBundle>;
340
- syncGetStats(): Promise<SyncAgentStats>;
341
- syncListFiles(args?: {
342
- prefix?: string;
343
- }): Promise<{
344
- files: SyncFileEntry[];
345
- }>;
346
- syncListSessions(): Promise<{
347
- sessions: SyncSessionEntry[];
348
- }>;
349
- syncGetSession(sessionId: string): Promise<SyncSessionContent>;
350
- syncDeleteFile(filePath: string): Promise<{
351
- removed: boolean;
352
- }>;
353
- sharedListFiles(args: {
354
- scope: "org" | "team" | "project";
355
- scopeId: string;
356
- limit?: number;
357
- cursor?: string;
358
- }): Promise<{
359
- files: SharedFileEntry[];
360
- nextCursor: string | null;
361
266
  }>;
362
- sharedDownloadUrl(args: {
363
- scope: "org" | "team" | "project";
364
- scopeId: string;
365
- filePath: string;
366
- }): Promise<{
367
- downloadUrl: string;
368
- expiresIn: number;
267
+ refreshXeroToken(): Promise<{
268
+ accessToken: string;
269
+ expiresAt: string;
369
270
  }>;
370
- }
371
- //# sourceMappingURL=sync.d.ts.map
372
- //#endregion
373
- //#region src/domains/knowledge.d.ts
374
- type KnowledgeScopeType = "org" | "team" | "project";
375
- interface KnowledgeScope {
376
- scopeType: KnowledgeScopeType;
377
- scopeId: string;
378
- name: string;
379
- }
380
- interface KnowledgeSearchHit {
381
- id: string;
382
- text: string;
383
- /** Normalized relevance in (0,1]; higher = closer. */
384
- score: number;
385
- scopeType: KnowledgeScopeType;
386
- scopeId: string;
387
271
  /**
388
- * Provenance of the hit. All live results are `"doc"`; `"fact"` only ever
389
- * appears for legacy vectors indexed before the facts primitive was removed
390
- * (the search index stays tolerant of them). Treat every hit as a doc.
272
+ * Refresh a specific Xero Connection by its exact `accountIdentifier` from
273
+ * `getXeroAccounts()`. Do not substitute `xeroTenantId`: current Xero OAuth
274
+ * rows may use the account email as their persistence key even when a sole
275
+ * organisation tenant ID is available in provider metadata.
391
276
  */
392
- source: "doc" | "fact";
393
- /** The canonical file under shared/<scope>/ (present on doc hits). */
394
- filePath?: string;
395
- /** Legacy-only: the id of a pre-removal fact vector. */
396
- factId?: string;
397
- }
398
- interface KnowledgeSearchResult {
399
- results: KnowledgeSearchHit[];
400
- /** True when fan-out breadth was capped (more member scopes than the cap). */
401
- truncatedScopes: boolean;
402
- }
403
- interface KnowledgeProfileLink {
404
- label: string;
405
- url: string;
406
- }
407
- interface KnowledgeProfile {
408
- scopeType: KnowledgeScopeType;
409
- scopeId: string;
410
- about: string | null;
411
- description: string | null;
412
- links: KnowledgeProfileLink[];
413
- updatedAt: string | null;
414
- updatedBy: string | null;
415
- }
416
- type ChangeRequestResourceType = "doc" | "profile";
417
- type ChangeRequestOperation = "create" | "update" | "delete";
418
- type ChangeRequestStatus = "open" | "approved" | "rejected" | "withdrawn" | "superseded";
419
- type ChangeRequestActorKind = "human" | "agent";
420
- /** Public projection of a change request (mirrors `PublicChangeRequest` in services/org). */
421
- interface KnowledgeChangeRequest {
422
- changeRequestId: string;
423
- scopeType: KnowledgeScopeType;
424
- scopeId: string;
425
- resourceType: ChangeRequestResourceType;
426
- operation: ChangeRequestOperation;
427
- targetPath: string | null;
428
- baseVersionId: string | null;
429
- proposedContentType: string | null;
430
- status: ChangeRequestStatus;
431
- proposerId: string;
432
- proposerKind: ChangeRequestActorKind;
433
- rationale: string;
434
- reviewerId: string | null;
435
- reviewerKind: ChangeRequestActorKind | null;
436
- reviewedAt: string | null;
437
- reviewNote: string | null;
438
- appliedRef: string | null;
439
- createdAt: string;
440
- updatedAt: string;
441
- }
442
- /** Per-type proposal payload for `proposeScopeChange`. */
443
- interface ProposeScopeChangeInput {
444
- resourceType: ChangeRequestResourceType;
445
- operation: ChangeRequestOperation;
446
- /** Why the change is proposed — shown to the reviewer. */
447
- rationale: string;
448
- /** doc: the path the proposal applies to (e.g. designs/data-center.md). */
449
- targetPath?: string;
450
- /** doc create/update: the staged body to upload (markdown or other text). */
451
- content?: string;
452
- /** doc create/update: content type of the staged body (default text/markdown). */
453
- contentType?: string;
454
- /** profile: the proposed value ({ about, description, links }). */
455
- proposedValue?: unknown;
456
- }
457
- interface KnowledgeDoc {
458
- filePath: string;
459
- fileName: string;
460
- contentType?: string;
461
- size: number;
462
- uploadedBy?: string;
463
- createdAt: string;
464
- updatedAt: string;
465
- }
466
- declare class KnowledgeApi extends ApiBase {
277
+ refreshXeroAccountToken(accountIdentifier: string): Promise<{
278
+ accessToken: string;
279
+ accessTokenExpiresAt: string;
280
+ expiresAt: string;
281
+ }>;
467
282
  /**
468
- * Semantic search across the agent's member scopes. Fan-out is gated
469
- * server-side by `listScopes` set-inclusion (fail-closed). Pass
470
- * `scopeType` + `scopeId` to narrow to one scope; a non-member scope
471
- * yields empty results (never a cross-scope leak).
283
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
284
+ * default-connection" shape). Use `getNotionAccounts()` for the multi-
285
+ * account shape required by Pattern A.
472
286
  */
473
- knowledgeSearch(query: string, opts?: {
474
- limit?: number;
475
- scopeType?: KnowledgeScopeType;
476
- scopeId?: string;
477
- }): Promise<KnowledgeSearchResult>;
478
- /** Enumerate the scopes (org + teams + projects) this agent belongs to. */
479
- listScopes(): Promise<{
480
- scopes: KnowledgeScope[];
287
+ getNotionCredentials(): Promise<{
288
+ accessToken: string;
289
+ workspaceId: string;
290
+ workspaceName: string;
481
291
  }>;
482
- /** Read a scope's structured knowledge profile (after membership check). */
483
- getScopeProfile(scopeType: KnowledgeScopeType, scopeId: string): Promise<KnowledgeProfile>;
484
292
  /**
485
- * Open a change request against a scope's knowledge resource. For a doc
486
- * create/update, `services/org` returns a presigned staging PUT; this method
487
- * uploads the proposed `content` to it (echoing the same Content-Type that
488
- * was signed), mirroring `writeScopeDoc`. The staged body is applied to the
489
- * canonical doc attributed to this agent — only when a reviewer approves.
293
+ * Pattern A: multi-account credential fetch for Notion. Returns every
294
+ * agent-scoped Notion connection. The caller is expected to require a
295
+ * selector arg (e.g. `workspaceId`) on every credential-touching tool.
296
+ *
297
+ * Returned `accounts[i].accountIdentifier` is the Notion workspaceId.
490
298
  */
491
- proposeScopeChange(scopeType: KnowledgeScopeType, scopeId: string, input: ProposeScopeChangeInput): Promise<KnowledgeChangeRequest>;
299
+ getNotionAccounts(): Promise<{
300
+ accounts: {
301
+ connectionId: string;
302
+ accountIdentifier: string;
303
+ displayName: string | null;
304
+ connectedAt: string;
305
+ accessToken: string;
306
+ workspaceId: string;
307
+ workspaceName: string;
308
+ }[];
309
+ }>;
492
310
  /**
493
- * List the agent's OWN change requests in a scope (filtered server-side to
494
- * this agent as proposer). Pass `status` to narrow to open / approved / etc.
311
+ * @deprecated Returns a single primary Atlassian Connection's credentials
312
+ * (one OAuth user, one cloudId) the legacy "pick-the-default-connection"
313
+ * shape. Atlassian is multi-site by nature (each OAuth user may have
314
+ * access to multiple Cloud sites), so Pattern A plugins MUST use
315
+ * `getAtlassianAccounts()` to discover the full set and dispatch via
316
+ * the `cloudId` selector arg.
495
317
  */
496
- listScopeChangeRequests(scopeType: KnowledgeScopeType, scopeId: string, opts?: {
497
- status?: ChangeRequestStatus;
498
- limit?: number;
499
- cursor?: string;
500
- }): Promise<{
501
- changeRequests: KnowledgeChangeRequest[];
502
- nextCursor: string | null;
318
+ getAtlassianCredentials(): Promise<{
319
+ accessToken: string;
320
+ refreshToken: string;
321
+ accessTokenExpiresAt: string;
322
+ cloudId: string;
323
+ siteName: string;
324
+ siteUrl: string;
325
+ email: string;
326
+ enabledProducts: string[];
327
+ clientId: string;
328
+ clientSecret: string;
503
329
  }>;
504
- /** List a scope's docs (the org-files corpus; mirrored to shared/<scope>/). */
505
- listScopeDocs(scopeType: KnowledgeScopeType, scopeId: string, opts?: {
506
- limit?: number;
507
- cursor?: string;
508
- }): Promise<{
509
- files: KnowledgeDoc[];
510
- nextCursor: string | null;
330
+ refreshAtlassianToken(): Promise<{
331
+ accessToken: string;
332
+ expiresAt: string;
511
333
  }>;
512
334
  /**
513
- * Read the full text of a scope doc. Resolves a presigned download URL
514
- * from `services/org`, then fetches the bytes directly from S3 (the one
515
- * legitimate raw fetch in a plugin same pattern as sync).
335
+ * Pattern A: multi-account / multi-site credential fetch for Atlassian.
336
+ *
337
+ * Returns every agent-scoped Atlassian Connection. Each Connection is
338
+ * one OAuth user with a single access token and N accessible Cloud
339
+ * sites (`availableSites`). The caller is expected to:
340
+ *
341
+ * 1. Flatten (connection × cloudId) into one MCP child per site.
342
+ * 2. Require a `cloudId` selector on every credential-touching tool.
343
+ * 3. Use the access token bound to the Connection that owns the
344
+ * requested `cloudId` (Atlassian shares one access token across
345
+ * all sites accessible to the OAuth user).
346
+ *
347
+ * Per-account token refresh uses `refreshAtlassianAccountToken(email)`
348
+ * — refreshing one Connection rotates its single access token, which
349
+ * then applies to every cloudId for that Connection.
350
+ *
351
+ * Returned `accounts[i].accountIdentifier` is the OAuth user's email
352
+ * — the stable cross-session identifier for refresh purposes. The LLM
353
+ * never sees this directly: it picks a site via the `cloudId` arg
354
+ * instead.
516
355
  */
517
- readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, opts?: {
518
- maxBytes?: number;
519
- }): Promise<{
520
- filePath: string;
521
- text: string;
356
+ getAtlassianAccounts(): Promise<{
357
+ accounts: {
358
+ connectionId: string;
359
+ accountIdentifier: string;
360
+ displayName: string | null;
361
+ connectedAt: string;
362
+ accessToken: string;
363
+ accessTokenExpiresAt: string;
364
+ clientId: string;
365
+ clientSecret: string;
366
+ cloudId: string;
367
+ siteName: string;
368
+ siteUrl: string;
369
+ availableSites: {
370
+ id: string;
371
+ url: string;
372
+ name: string;
373
+ scopes?: string[];
374
+ avatarUrl?: string;
375
+ }[];
376
+ }[];
522
377
  }>;
523
378
  /**
524
- * Write (create or overwrite) a scope doc. Two-step presigned upload:
525
- * `services/org` returns a signed URL plus `requiredHeaders` (author /
526
- * authorKind / message as `x-amz-meta-*`) that MUST be sent verbatim on
527
- * the PUT, alongside the same `Content-Type` that was signed. Author and
528
- * authorKind are server-set from the agent token never trusted here.
379
+ * Pattern A: refresh a specific Atlassian Connection by `accountIdentifier`
380
+ * (the OAuth user's email).
381
+ *
382
+ * Atlassian rotates refresh tokens (`rotatesRefreshToken: true`); the
383
+ * server-side per-account refresh endpoint handles rotation and
384
+ * persistence. Refreshing one Connection updates its single access
385
+ * token, which applies to every accessible Cloud site (cloudId) for
386
+ * that OAuth user.
387
+ *
388
+ * Returns the new access token + expiry. The proxy is responsible for
389
+ * fanning the new token out to every child server it spawned for
390
+ * cloudIds owned by this Connection.
529
391
  */
530
- writeScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, content: string, opts?: {
531
- contentType?: string;
532
- message?: string;
533
- }): Promise<{
534
- filePath: string;
392
+ refreshAtlassianAccountToken(accountIdentifier: string): Promise<{
393
+ accessToken: string;
394
+ accessTokenExpiresAt: string;
395
+ expiresAt: string;
535
396
  }>;
536
- }
537
- //# sourceMappingURL=knowledge.d.ts.map
538
- //#endregion
539
- //#region src/domains/mobile.d.ts
540
- /** Response of GET /mobile/numbers for an agent (services/mobile). */
541
- interface MobileNumberInfo {
542
- phoneNumber: string;
543
- countryCode: string;
544
- monthlyPrice?: number;
545
- status: string;
546
- errorMessage?: string;
547
- }
548
- /** One purchasable number from GET /mobile/numbers/search. */
549
- interface MobileAvailableNumber {
550
- number: string;
551
- friendlyName: string;
552
- locality: string;
553
- region: string;
554
- country: string;
555
- }
556
- /** Approved WhatsApp content template from GET /mobile/whatsapp/templates. */
557
- interface WhatsAppTemplate {
558
- contentSid: string;
559
- name: string;
560
- language: string;
561
- body: string;
562
- variables: Record<string, string>;
563
- category?: string;
564
- }
565
- declare class MobileApi extends ApiBase {
566
- getMobileNumber(): Promise<MobileNumberInfo>;
567
- searchMobileNumbers(args?: {
568
- country?: string;
569
- query?: string;
570
- }): Promise<{
571
- numbers: MobileAvailableNumber[];
572
- monthlyPrice: number;
397
+ /**
398
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
399
+ * default-connection" shape). Use `getMYOBAccounts()` for the multi-
400
+ * account shape required by Pattern A.
401
+ */
402
+ getMYOBCredentials(): Promise<{
403
+ accessToken: string;
404
+ accessTokenExpiresAt: string;
405
+ myobBusinessId: string;
406
+ clientId: string;
573
407
  }>;
574
- assignMobileNumber(args: {
575
- phoneNumber: string;
576
- countryCode: string;
577
- }): Promise<{
578
- phoneNumber: string;
579
- countryCode: string;
580
- status: "pending";
408
+ /**
409
+ * Pattern A: multi-account credential fetch for MYOB. Returns every
410
+ * agent-scoped MYOB connection. The caller is expected to require a
411
+ * selector arg (e.g. `myobBusinessId` / `accountIdentifier`) on every
412
+ * credential-touching tool.
413
+ *
414
+ * Returned `accounts[i].accountIdentifier` is the MYOB businessId.
415
+ */
416
+ getMYOBAccounts(): Promise<{
417
+ accounts: {
418
+ connectionId: string;
419
+ accountIdentifier: string;
420
+ displayName: string | null;
421
+ connectedAt: string;
422
+ accessToken: string;
423
+ accessTokenExpiresAt: string;
424
+ myobBusinessId: string;
425
+ clientId: string;
426
+ }[];
581
427
  }>;
582
- releaseMobileNumber(): Promise<{
583
- released: true;
428
+ refreshMYOBToken(): Promise<{
429
+ accessToken: string;
430
+ expiresAt: string;
584
431
  }>;
585
- sendSms(args: {
586
- to: string;
587
- body: string;
588
- }): Promise<{
589
- sent: true;
590
- sid: string;
432
+ /**
433
+ * Pattern A: refresh one MYOB Connection by its stable
434
+ * `accountIdentifier` (the MYOB business id returned by
435
+ * `getMYOBAccounts()`).
436
+ *
437
+ * MYOB refresh tokens belong to individual Connection rows. A
438
+ * multi-business client must use this method instead of refreshing the
439
+ * primary Connection and copying that access token into every cached
440
+ * business client.
441
+ */
442
+ refreshMYOBAccountToken(accountIdentifier: string): Promise<{
443
+ accessToken: string;
444
+ accessTokenExpiresAt: string;
445
+ expiresAt: string;
591
446
  }>;
592
- startOutboundCall(args: {
593
- to: string;
594
- }): Promise<{
595
- callSid: string;
596
- status: string;
447
+ /**
448
+ * @deprecated Returns a single primary credential blob. Use
449
+ * `getSalesforceAccounts()` for the multi-account shape required by
450
+ * Pattern A.
451
+ */
452
+ getSalesforceCredentials(): Promise<{
453
+ accessToken: string;
454
+ accessTokenExpiresAt: string;
455
+ instanceUrl: string;
456
+ orgId: string;
597
457
  }>;
598
- getWhatsAppSession(to: string): Promise<{
599
- active: boolean;
600
- expiresAt?: string;
458
+ /**
459
+ * Pattern A: multi-account credential fetch for Salesforce. Returns every
460
+ * agent-scoped Salesforce connection. One OAuth grant maps to one org, so
461
+ * `accounts[i].accountIdentifier` (and `orgId`) is the Salesforce org id —
462
+ * the selector every credential-touching tool requires.
463
+ */
464
+ getSalesforceAccounts(): Promise<{
465
+ accounts: {
466
+ connectionId: string;
467
+ accountIdentifier: string;
468
+ displayName: string | null;
469
+ connectedAt: string;
470
+ accessToken: string;
471
+ accessTokenExpiresAt: string;
472
+ instanceUrl: string;
473
+ orgId: string;
474
+ }[];
601
475
  }>;
602
- sendWhatsAppMessage(args: {
603
- to: string;
604
- body: string;
605
- }): Promise<{
606
- sent: true;
607
- sid: string;
476
+ /**
477
+ * Refresh the access token for a specific Salesforce org. Salesforce
478
+ * tokens aren't interchangeable across orgs, so the connection is targeted
479
+ * by `accountIdentifier` (the org id) — mirrors `refreshXeroAccountToken`.
480
+ */
481
+ refreshSalesforceAccountToken(orgId: string): Promise<{
482
+ accessToken: string;
483
+ accessTokenExpiresAt: string;
484
+ expiresAt: string;
608
485
  }>;
609
- sendWhatsAppTemplate(args: {
610
- to: string;
611
- contentSid: string;
612
- contentVariables: Record<string, string>;
613
- bodyPreview?: string;
614
- }): Promise<{
615
- sent: true;
616
- sid: string;
617
- }>;
618
- listWhatsAppTemplates(): Promise<{
619
- templates: WhatsAppTemplate[];
620
- }>;
621
- }
622
- //# sourceMappingURL=mobile.d.ts.map
623
- //#endregion
624
- //#region src/domains/remote.d.ts
625
- interface RemoteSessionInfo {
626
- sessionId: string;
627
- agentId: string;
628
- surface: "browser" | "terminal";
629
- status: "agent_driving" | "awaiting_human" | "human_in_control" | "resuming" | "completed" | "expired" | "failed";
630
- url?: string;
631
- instructions?: string;
632
- requestedAt?: string;
633
- }
634
- declare class RemoteApi extends ApiBase {
635
- requestBrowserTakeover(args: {
636
- instructions: string;
637
- url?: string;
638
- conversationId?: string;
639
- }): Promise<{
640
- sessionId: string;
641
- status: string;
642
- }>;
643
- getRemoteSession(sessionId: string): Promise<RemoteSessionInfo>;
644
- completeRemoteSession(sessionId: string): Promise<{
645
- ok: boolean;
646
- }>;
647
- }
648
- //# sourceMappingURL=remote.d.ts.map
649
- //#endregion
650
- //#region src/domains/self.d.ts
651
- /** Voice settings — core agent config. Mirrors `VoiceConfig` in `@alfe/types`. */
652
- interface AgentVoiceConfig {
653
- /** ElevenLabs voice ID; platform default when unset. */
654
- voiceId?: string;
655
- ttsModel?: string;
656
- enabled?: boolean;
657
- }
658
- /**
659
- * The agent's own public identity, as returned by `updateSelf`, `generateAvatar`,
660
- * `presignAvatar`'s finalize (`finalizeAvatar`). This is the public agent
661
- * projection; only the identity-relevant fields are typed here — the response
662
- * carries the full public agent record.
663
- */
664
- interface AgentSelf {
665
- agentId: string;
666
- tenantId: string;
667
- name: string;
668
- avatarUrl?: string;
669
- voiceConfig?: AgentVoiceConfig;
670
- status: string;
671
- }
672
- /** Result of `presignAvatar` — the agent PUTs bytes to `uploadUrl`, then finalizes with `s3Key`. */
673
- interface AgentAvatarPresign {
674
- /** Presigned PUT URL to upload the image bytes to. */
675
- uploadUrl: string;
676
- /** Object key — echoed back to `finalizeAvatar`. */
677
- s3Key: string;
678
- /** Stable public URL the avatar will be served from once finalized. */
679
- publicUrl: string;
680
- /** ISO expiry of the presigned PUT URL. */
681
- expiresAt: string;
682
- }
683
- /** A voice in the platform catalogue (ElevenLabs), from `listVoices`. */
684
- interface AgentVoice {
685
- id: string;
686
- name: string;
687
- previewUrl: string;
688
- description: string;
689
- labels: Record<string, string>;
690
- category: string;
691
- }
692
- declare class SelfApi extends ApiBase {
693
- /** Update the agent's own name and/or voice config. Returns the updated agent. */
694
- updateSelf(update: {
695
- name?: string;
696
- voiceConfig?: AgentVoiceConfig;
697
- }): Promise<AgentSelf>;
698
486
  /**
699
- * Generate the agent's own avatar from a text prompt. The image is generated,
700
- * stored, and set on the agent server-side; returns the updated agent.
487
+ * Pattern A: multi-account credential fetch for Microsoft 365.
701
488
  *
702
- * ASYNC (same reason as `generateImage`): avatar gen runs `gpt-image-1`
703
- * (30–60s) which exceeds the API Gateway 30s ceiling, so this enqueues a job
704
- * (`POST /agent/avatar/generate` `jobId`) then polls (`GET /agent/avatar/{jobId}`)
705
- * until the avatar is set. Signature unchanged — the plugin is unaffected.
706
- */
707
- generateAvatar(args: {
708
- prompt: string;
709
- }): Promise<AgentSelf>;
710
- /**
711
- * Get a presigned PUT URL to upload a new avatar image. Upload the bytes to
712
- * `uploadUrl`, then call `finalizeAvatar(s3Key)` to set it on the agent.
489
+ * Returns every agent-scoped Microsoft connection. The caller is expected
490
+ * to require an `email` selector on every credential-touching tool and
491
+ * look up the matching account at dispatch time.
492
+ *
493
+ * Returned `accounts[i].accountIdentifier` is the user's primary email
494
+ * (or the tid claim as fallback) — the stable cross-session identifier
495
+ * the LLM should pass.
496
+ *
497
+ * Per-account token refresh is exposed via `refreshMicrosoftAccountToken`,
498
+ * NOT `refreshXeroAccountToken` Microsoft refresh tokens are not
499
+ * interchangeable across (tenant, user) pairs.
713
500
  */
714
- presignAvatar(args: {
715
- mimeType: string;
716
- size: number;
717
- }): Promise<AgentAvatarPresign>;
501
+ getMicrosoftAccounts(): Promise<{
502
+ accounts: {
503
+ connectionId: string;
504
+ accountIdentifier: string;
505
+ displayName: string | null;
506
+ connectedAt: string;
507
+ accessToken: string;
508
+ accessTokenExpiresAt: string;
509
+ email: string;
510
+ microsoftTenantId: string;
511
+ workspaceDomain: string;
512
+ }[];
513
+ }>;
718
514
  /**
719
- * Finalize an avatar upload validates ownership + size, then sets the
720
- * agent's `avatarUrl` server-side. Returns the updated agent.
515
+ * Pattern A: refresh a specific Microsoft 365 connection by its
516
+ * `accountIdentifier`. For Microsoft, `accountIdentifier` is the user's
517
+ * email when the Graph profile fetch succeeded at connect time, and the
518
+ * Azure tenant id (`tid` claim) as fallback. Callers should pass the
519
+ * value returned by `getMicrosoftAccounts()` rather than synthesising
520
+ * an email locally.
521
+ *
522
+ * Microsoft refresh tokens are bound to a specific (tenant, user) pair —
523
+ * they are NOT interchangeable across accounts, so per-account refresh
524
+ * is mandatory. The generic /accounts/{accountIdentifier}/refresh
525
+ * endpoint walks the agent's full visible scope chain to find a matching
526
+ * connection (works for inherited team/project Microsoft connections).
721
527
  */
722
- finalizeAvatar(s3Key: string): Promise<AgentSelf>;
723
- /** List the platform voice catalogue (ElevenLabs) so the agent can pick its own voice. */
724
- listVoices(): Promise<{
725
- voices: AgentVoice[];
528
+ refreshMicrosoftAccountToken(accountIdentifier: string): Promise<{
529
+ accessToken: string;
530
+ accessTokenExpiresAt: string;
531
+ expiresAt: string;
726
532
  }>;
727
- }
728
- //# sourceMappingURL=self.d.ts.map
729
- //#endregion
730
- //#region src/domains/voice.d.ts
731
- /** The ElevenLabs models with a pricing row — the TTS endpoint rejects any other value. */
732
- type VoiceTtsModel = "eleven_turbo_v2_5" | "eleven_multilingual_v2";
733
- interface VoiceTtsArgs {
734
- /** Text to synthesize (1–5000 chars — the endpoint enforces this). */
735
- text: string;
736
- /** ElevenLabs voice id; platform default when unset. */
737
- voiceId?: string;
738
- /** TTS model; `eleven_turbo_v2_5` (lower latency) when unset. */
739
- model?: VoiceTtsModel;
740
- }
741
- /** Raw synthesized audio plus its PCM framing (from the response headers). */
742
- interface VoiceTtsResult {
743
- /** Raw little-endian PCM samples — no container. Wrap in WAV to make a playable file. */
744
- audio: Buffer;
745
- /** Samples per second (e.g. 24000). */
746
- sampleRate: number;
747
- /** Channel count (mono = 1). */
748
- channels: number;
749
- /** Bits per sample (e.g. 16). */
750
- bitDepth: number;
751
- }
752
- interface VoiceSttArgs {
753
- /** Raw linear16 (16-bit little-endian) mono PCM samples — no WAV/container header. */
754
- audio: Uint8Array;
755
- /** Sample rate of `audio` in Hz (8000–48000). */
756
- sampleRate: number;
757
- }
758
- interface VoiceSttResult {
759
- text: string;
760
- /** Deepgram confidence in (0,1]. */
761
- confidence: number;
762
- }
763
- declare class VoiceApi extends ApiBase {
764
533
  /**
765
- * Text-to-speech. Returns raw PCM audio bytes plus their framing the
766
- * voice service defaults to 24 kHz / mono / 16-bit. Wrap in a WAV container
767
- * to produce a playable file. Metered per character against the tenant
768
- * credit pool server-side; TTS completes regardless of metering outcome.
534
+ * Disconnects one connected Microsoft 365 account for the agent, by its
535
+ * `accountIdentifier`. Hits the generic per-account disconnect route
536
+ * (`DELETE /agent/connect/microsoft/accounts/{accountIdentifier}`), which
537
+ * resolves across the agent's full effective scope chain and deletes the
538
+ * matching Connection row. Returns the remaining accounts.
539
+ *
540
+ * IMPORTANT: pass the `accountIdentifier` from `getMicrosoftAccounts()`, NOT
541
+ * a synthesised email. For Microsoft, `accountIdentifier` is the user's email
542
+ * only when the Graph profile fetch succeeded at connect time; it falls back
543
+ * to the Azure tenant id (`tid` claim) otherwise. The backend matches on
544
+ * `accountIdentifier` exactly, so passing an email would 404 on those
545
+ * fallback-identifier accounts. (This is why the param is not named `email`,
546
+ * unlike `disconnectGoogleAccount` where the identifier is always the email.)
769
547
  */
770
- tts(args: VoiceTtsArgs): Promise<VoiceTtsResult>;
548
+ disconnectMicrosoftAccount(accountIdentifier: string): Promise<{
549
+ accounts: {
550
+ accountIdentifier: string;
551
+ displayName?: string;
552
+ connectedAt?: string;
553
+ }[];
554
+ }>;
771
555
  /**
772
- * Speech-to-text. Accepts raw linear16 (16-bit LE) mono PCM — NOT a WAV or
773
- * other container (the endpoint transcribes with a fixed linear16 encoding,
774
- * so a container header would be transcribed as noise). Strip any WAV header
775
- * and pass `sampleRate` from it before calling. Metered by transcribed
776
- * duration against the tenant credit pool server-side.
556
+ * Resolve the primary cTrader Connection's credentials for the calling
557
+ * agent. Unlike most providers, the cTrader Open API needs app-level auth
558
+ * (`clientId` + `clientSecret`) AND account auth (`accessToken` +
559
+ * `accountId`) on the socket, so `@alfe.ai/ctrader-mcp` self-fetches the
560
+ * full set here at startup (the atlassian/google pattern). `clientId` /
561
+ * `clientSecret` are the SST-sourced global app credentials the connect
562
+ * endpoint injects — they are never persisted on the connection. `host` is
563
+ * the resolved TLS endpoint (`live.ctraderapi.com` / `demo.ctraderapi.com`)
564
+ * derived from the selected account's live/demo flag.
777
565
  */
778
- stt(args: VoiceSttArgs): Promise<VoiceSttResult>;
779
- }
780
- //# sourceMappingURL=voice.d.ts.map
781
- //#endregion
782
- //#region src/domains/identity.d.ts
783
- type IdentityStatus = "anonymous" | "partial" | "identified" | "verified";
784
- interface IdentityDirectoryEntry {
785
- identityId: string;
786
- status: IdentityStatus;
787
- displayName: string;
788
- name?: string;
789
- avatarUrl?: string;
790
- lastSeenAt: string;
791
- lastSeenProvider?: string;
792
- messageable: boolean;
793
- }
794
- declare class IdentityApi extends ApiBase {
566
+ getCTraderCredentials(): Promise<{
567
+ accessToken: string;
568
+ refreshToken: string;
569
+ accountId: string;
570
+ host: string;
571
+ clientId: string;
572
+ clientSecret: string;
573
+ }>;
795
574
  /**
796
- * Returns the calling agent's own identity context — `{ agentId, tenantId }`
797
- * decoded server-side from the agent API token. Used by the
798
- * `@alfe.ai/openclaw-identity` plugin to bootstrap context when the
799
- * OpenClaw daemon doesn't plumb `ctx.agentId` through to plugin hooks.
800
- * Plugins should cache this for the daemon's lifetime (single-agent-per-
801
- * process invariant). One HTTP round-trip per process activate; not for
802
- * per-call use.
803
- */
804
- whoami(): Promise<{
805
- agentId: string;
806
- tenantId: string;
807
- }>;
808
- resolveIdentity(args: {
809
- provider: string;
810
- platformId: string;
811
- kind?: "user" | "agent" | "service" | "bot" | "workspace";
812
- displayName?: string;
813
- }): Promise<{
814
- identityId: string | null;
815
- status: string;
816
- created?: boolean;
817
- reason?: string;
818
- /**
819
- * Flattened auriclabs permission strings for the resolved identity
820
- * (scope-prefixed where applicable). Empty array on miss / org service
821
- * outage the runtime gate fails closed in that case.
822
- */
823
- permissions: string[];
824
- }>;
825
- searchIdentities(args?: {
826
- q?: string;
827
- status?: string;
828
- limit?: number;
829
- }): Promise<{
830
- identities: unknown[];
831
- }>;
832
- listIdentities(args?: {
833
- status?: IdentityStatus;
834
- limit?: number;
835
- cursor?: string;
836
- }): Promise<{
837
- identities: IdentityDirectoryEntry[];
838
- cursor: string | null;
839
- }>;
840
- getIdentityContext(identityId: string): Promise<{
841
- context: unknown;
842
- }>;
843
- mergeIdentities(survivorId: string, args: {
844
- mergedId: string;
845
- }): Promise<{
846
- ok: boolean;
847
- error?: string;
848
- }>;
849
- unmergeIdentity(identityId: string): Promise<{
850
- ok: boolean;
851
- error?: string;
575
+ * Pattern A: multi-account credential fetch for cTrader.
576
+ *
577
+ * Unlike atlassian/salesforce (one Connection row per account/site), a
578
+ * cTrader is MULTI-grant per agent: an agent may connect several distinct
579
+ * cTrader logins, each its own Connection row keyed on `accountIdentifier =
580
+ * ctid:<userId>` (Phase 1). This aggregates the *trading accounts* across
581
+ * ALL of those Connection rows — each row contributes its `availableAccounts`
582
+ * flattened, and every account carries ITS OWN grant's `accessToken` (the
583
+ * token that authenticates that account against the cTrader Open API). One
584
+ * OAuth grant still covers all accounts under that single login on one shared
585
+ * token; only the `ctidTraderAccountId` and the protobuf socket `host` (live
586
+ * vs demo) differ within a grant. Across grants the tokens differ, so the
587
+ * token is now PER-ACCOUNT rather than hoisted to the top level.
588
+ *
589
+ * `host` per account is derived from the account's `isLive` flag
590
+ * (`live.ctraderapi.com` / `demo.ctraderapi.com`) the same mapping the
591
+ * connect provider applies server-side when an account is auto-selected.
592
+ *
593
+ * `clientId` / `clientSecret` are the SST-sourced GLOBAL app credentials the
594
+ * connect endpoint injects — identical across every Connection row (one
595
+ * cTrader app), never persisted on a connection. We take them from the first
596
+ * row that carries them.
597
+ *
598
+ * Accounts are deduped on `ctidTraderAccountId` first-wins: Spotware ids are
599
+ * globally unique across logins, so a duplicate can only appear if the same
600
+ * account somehow surfaced under two grants first-wins keeps it
601
+ * deterministic.
602
+ *
603
+ * `accounts` may be empty (no cTrader Connection at all), in which case we
604
+ * return empty creds rather than throwing.
605
+ */
606
+ getCTraderAccounts(): Promise<{
607
+ accounts: {
608
+ ctidTraderAccountId: string;
609
+ host: string;
610
+ isLive: boolean;
611
+ brokerName?: string;
612
+ accountNumber?: string;
613
+ accessToken: string;
614
+ /**
615
+ * The stable per-grant Connection key (`ctid:<userId>`) this account
616
+ * belongs to. Every trading account under one cTrader login shares one
617
+ * grant (one OAuth token), so this is the identifier the MCP server
618
+ * passes to `refreshCTraderAccount()` to rotate the token for the whole
619
+ * grant on a `CH_ACCESS_TOKEN_INVALID` expiry. Empty string when the
620
+ * server did not supply one (legacy rows) — such an account can still
621
+ * trade with its current token but cannot self-refresh.
622
+ */
623
+ accountIdentifier: string;
624
+ }[];
625
+ clientId: string;
626
+ clientSecret: string;
852
627
  }>;
853
- addIdentityNote(identityId: string, args: {
854
- content: string;
855
- category?: string;
856
- }): Promise<{
857
- noteId: string | null;
628
+ /**
629
+ * Pattern A: refresh a specific cTrader grant by its stable
630
+ * `accountIdentifier` (`ctid:<userId>` from `getCTraderAccounts()`).
631
+ *
632
+ * cTrader access tokens live ~30 days; the `getCTraderAccounts()` /
633
+ * credentials reads serve the STORED token without refreshing, so refresh is
634
+ * the consumer's job. `@alfe.ai/ctrader-mcp` calls this when the cTrader Open
635
+ * API rejects an account-auth with `CH_ACCESS_TOKEN_INVALID`, then re-runs
636
+ * the socket handshake with the returned `accessToken`.
637
+ *
638
+ * Refreshing one grant rotates the single OAuth token that covers EVERY
639
+ * trading account under that login. cTrader's refresh token itself does not
640
+ * expire but may rotate on refresh (`rotatesRefreshToken: true`); connect
641
+ * persists the rotated refresh token server-side, so the caller only needs
642
+ * the new `accessToken`. Mirrors `refreshXeroAccountToken`.
643
+ */
644
+ refreshCTraderAccount(accountIdentifier: string): Promise<{
645
+ accessToken: string;
646
+ accessTokenExpiresAt: string;
647
+ expiresAt: string;
858
648
  }>;
859
- tagIdentity(identityId: string, args: {
860
- tag: string;
861
- action: "add" | "remove";
862
- }): Promise<{
863
- ok: boolean;
649
+ /**
650
+ * @deprecated Returns a single primary credential blob. Use
651
+ * `getShopifyAccounts()` for the multi-account shape required by Pattern A
652
+ * (`@alfe.ai/shopify-mcp` keys per-shop on the myshopify domain).
653
+ */
654
+ getShopifyCredentials(): Promise<{
655
+ accessToken: string;
656
+ shopDomain: string;
657
+ shopGid: string;
658
+ shopName: string;
659
+ apiVersion: string;
864
660
  }>;
865
- getIdentityChangelog(identityId: string, args?: {
866
- limit?: number;
867
- cursor?: string;
868
- }): Promise<{
869
- entries: unknown[];
870
- cursor: string | null;
661
+ /**
662
+ * Pattern A: multi-account credential fetch for Shopify. Returns every
663
+ * agent-scoped Shopify Connection. One OAuth grant maps to one store, so the
664
+ * stable per-call selector is the store's myshopify domain (`shopDomain`),
665
+ * NOT `accountIdentifier` — the connect provider keys `accountIdentifier` on
666
+ * the immutable shop GID (falling back to the domain), so `shopDomain` is the
667
+ * value the LLM passes and the plugin routes on.
668
+ *
669
+ * Each entry is shaped by the connect provider's `buildCredentialsResponse`:
670
+ * `{ accessToken, shopDomain, shopGid, shopName, apiVersion }` — offline
671
+ * Shopify tokens never expire, so there is NO token / expiry field and no
672
+ * refresh method (unlike Salesforce). The GraphQL Admin API authenticates
673
+ * purely on `X-Shopify-Access-Token`; no client credentials are on the wire.
674
+ */
675
+ getShopifyAccounts(): Promise<{
676
+ accounts: {
677
+ connectionId: string;
678
+ accountIdentifier: string;
679
+ displayName: string | null;
680
+ connectedAt: string;
681
+ accessToken: string;
682
+ shopDomain: string;
683
+ shopGid: string;
684
+ shopName: string;
685
+ apiVersion: string;
686
+ }[];
871
687
  }>;
872
- rollbackIdentity(identityId: string, args: {
873
- targetVersion: number;
874
- }): Promise<{
875
- ok: boolean;
876
- entry?: unknown;
688
+ /**
689
+ * Pattern A: provider-parameterized multi-account credential fetch for the
690
+ * social connectors (Bluesky, and the approval-gated backlog: X, Meta,
691
+ * Threads, LinkedIn, Pinterest, TikTok, Reddit, YouTube).
692
+ *
693
+ * Unlike the bespoke `getGithubAccounts()` / `getXeroAccounts()` shapes,
694
+ * this returns a UNIFORM normalized account shape so `@alfe.ai/social-mcp`'s
695
+ * shared driver can require a single `account` selector on every
696
+ * credential-touching tool regardless of platform. The backend
697
+ * `api-agents/{provider}/accounts` route is already provider-generic; this
698
+ * is the client-side normalization the plan (`do-we-need-any-moonlit-toucan`
699
+ * Phase 0, step 5) calls for.
700
+ *
701
+ * `accountIdentifier` is the stable per-account selector the LLM should
702
+ * pass back (for Bluesky: the account DID). `accessToken` carries whatever
703
+ * the provider's `buildCredentialsResponse` bundles (for Bluesky: the JSON
704
+ * session bundle — the driver parses the `accessJwt` out of it, or reads the
705
+ * top-level `accessJwt` from `providerMetadata`-adjacent fields). Everything
706
+ * else the driver needs for routing (handle, pdsHost, did, …) is on
707
+ * `providerMetadata`.
708
+ *
709
+ * Token refresh is delegated to connect (never done in-plugin) via the
710
+ * per-account route `POST /agent/connect/{provider}/accounts/{accountIdentifier}/refresh`
711
+ * — call `refreshSocialAccount(provider, accountIdentifier)`. (The non-account
712
+ * `POST /agent/connect/{provider}/refresh` route refreshes the provider's
713
+ * PRIMARY connection, which is wrong under multi-account Pattern A.)
714
+ */
715
+ getSocialAccounts(provider: string): Promise<{
716
+ provider: string;
717
+ accounts: {
718
+ connectionId: string;
719
+ accountIdentifier: string;
720
+ displayName: string | null;
721
+ accessToken: string;
722
+ providerMetadata: Record<string, unknown>;
723
+ connectedAt: string;
724
+ }[];
877
725
  }>;
878
- requestIdentityVerification(args: {
879
- claimedIdentityId: string;
880
- requestingIdentityId: string;
881
- requestingProvider: string;
882
- requestingPlatformId: string;
883
- preferredChannel?: "mobile" | "email";
884
- /**
885
- * Phase 2: agent-supplied contact endpoint. When provided, the top-level
886
- * `preferredChannel` is ignored — the contact's channel wins.
887
- */
888
- contact?: {
889
- channel: "email" | "mobile";
890
- value: string;
891
- };
892
- }): Promise<{
893
- verificationId: string;
894
- channel: string;
895
- deliveredTo: string;
726
+ /**
727
+ * Pattern A: refresh a specific social Connection by its stable
728
+ * `accountIdentifier` (for Bluesky: the account DID) via the
729
+ * provider-generic per-account refresh route. The counterpart to
730
+ * `getSocialAccounts(provider)`; `@alfe.ai/social-mcp` calls this on a
731
+ * 401/ExpiredToken from the platform PDS/API, then re-fetches accounts to
732
+ * pick up the rotated bundle.
733
+ *
734
+ * Refresh itself is ALWAYS delegated to connect — the plugin never calls
735
+ * the platform's own refresh XRPC (e.g. `com.atproto.server.refreshSession`)
736
+ * because connect owns the encrypted refresh token + rotation persistence
737
+ * (Bluesky rotates the refreshJwt; a missed rotation kills the connection
738
+ * after one refresh). The returned `accessToken` is whatever the provider's
739
+ * `refreshToken` hook re-bundled (for Bluesky: the JSON session bundle with
740
+ * the fresh `accessJwt`) — callers typically ignore it and re-fetch via
741
+ * `getSocialAccounts` for a consistent shape.
742
+ */
743
+ refreshSocialAccount(provider: string, accountIdentifier: string): Promise<{
744
+ accountIdentifier: string;
745
+ accessToken: string;
746
+ accessTokenExpiresAt: string;
896
747
  expiresAt: string;
897
- availableChannels: {
898
- channel: string;
899
- deliveredTo: string;
900
- }[];
901
- } | {
902
- error: string;
903
748
  }>;
904
- confirmIdentityVerification(args: {
905
- claimedIdentityId: string;
906
- verificationId: string;
907
- phrase: string;
749
+ }
750
+ //# sourceMappingURL=connect-credentials.d.ts.map
751
+ //#endregion
752
+ //#region src/domains/integrations.d.ts
753
+ /**
754
+ * One entry in the agent's EFFECTIVE integration list. Agent-scope install
755
+ * rows keep their full public row shape (config included, `scope: "agent"`);
756
+ * connection-/channel-/custom-driven activations and inherited
757
+ * org/team/project installs have no agent-scope row and appear as the
758
+ * narrower projection. Discriminate on `config`: only the agent-scope row
759
+ * arm carries it (`source` alone is NOT a discriminator — inherited explicit
760
+ * rows land in the narrow arm with `source: "explicit"` too).
761
+ */
762
+ type AgentIntegrationListEntry = (IntegrationInstall$1 & {
763
+ source: "explicit";
764
+ }) | {
765
+ integrationId: string;
766
+ version: string;
767
+ desiredStatus: IntegrationDesiredStatus;
768
+ actualStatus: IntegrationActualStatus;
769
+ source: IntegrationActivationSource$1;
770
+ /** Winning row's scope — present only on inherited explicit entries. */
771
+ scope?: IntegrationScope;
772
+ scopeId?: string;
773
+ config?: undefined;
774
+ connectionId?: string;
775
+ channelId?: string;
776
+ displayName?: string;
777
+ icon?: string;
778
+ availableVersion?: string;
779
+ reinstallRequestedAt?: string;
780
+ };
781
+ declare class IntegrationsApi extends ApiBase {
782
+ /**
783
+ * List the integrations EFFECTIVE for this agent — explicit agent-scope
784
+ * installs plus driven activations (google, myob, xero, google-chat, …)
785
+ * and inherited org-scope installs, discriminated by `source`.
786
+ */
787
+ listIntegrations(): Promise<{
788
+ integrations: AgentIntegrationListEntry[];
789
+ }>;
790
+ getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult$1>;
791
+ updateIntegrationConfig(integrationId: string, config: Record<string, unknown>): Promise<void>;
792
+ installIntegration(integrationId: string, options?: {
793
+ version?: string;
794
+ config?: Record<string, unknown>;
795
+ }): Promise<IntegrationInstall$1>;
796
+ removeIntegration(integrationId: string): Promise<IntegrationInstall$1>;
797
+ getOAuthUrl(provider: string, scopes?: string[], options?: {
798
+ shop?: string;
908
799
  }): Promise<{
909
- verified: boolean;
910
- identityId?: string;
911
- /** Phase 2: how the confirm resolved — Scenario A vs B. */
912
- action?: "merged" | "contact_verified" | "already_confirmed";
913
- error?: string;
800
+ url: string;
801
+ provider: string;
802
+ expiresIn: number;
803
+ }>;
804
+ getOAuthStatus(provider: string): Promise<{
805
+ provider: string;
806
+ connected: boolean;
807
+ config?: Record<string, string>;
808
+ }>;
809
+ getRegistry(): Promise<{
810
+ integrations: RegistryEntry$1[];
914
811
  }>;
812
+ }
813
+ //# sourceMappingURL=integrations.d.ts.map
814
+ //#endregion
815
+ //#region src/domains/workspace.d.ts
816
+ /** Response of GET /agent/workspace (services/agents). */
817
+ interface AgentWorkspaceInfo {
818
+ templateKey?: string;
819
+ defaultModel?: string;
820
+ installedFrom?: {
821
+ templateKey: string;
822
+ authorTenantId: string;
823
+ version: number;
824
+ };
825
+ runtime?: string;
826
+ teams?: {
827
+ teamId: string;
828
+ name: string;
829
+ description?: string;
830
+ parentTeamId?: string;
831
+ }[];
832
+ projects?: {
833
+ projectId: string;
834
+ name: string;
835
+ description?: string;
836
+ status: string;
837
+ parentProjectId?: string;
838
+ }[];
839
+ teamIds?: string[];
840
+ projectIds?: string[];
841
+ }
842
+ declare class WorkspaceApi extends ApiBase {
915
843
  /**
916
- * Update display-shape fields on an Identity. Body excludes `email` /
917
- * `phone` / `title` / `company` / `metadata` per Section D4 — contacts go
918
- * via the verify flow, title/company live on OrgMembership, metadata is
919
- * not agent-writable.
844
+ * GET /agent/workspace workspace config for the authenticated agent
845
+ * (template assignment, default model, org roster).
920
846
  */
921
- updateIdentity(identityId: string, args: {
922
- name?: string;
923
- avatarUrl?: string;
924
- timezone?: string;
925
- locale?: string;
926
- }): Promise<{
927
- ok: boolean;
928
- }>;
847
+ getWorkspace(): Promise<AgentWorkspaceInfo>;
929
848
  /**
930
- * Phase 2 (Section H): server-side verification of a Google Chat sender via
931
- * the agent's existing Google OAuth credentials. Returns the resolved
932
- * identity (created or matched via Scenario-B email enrichment).
849
+ * GET /templates/{key}/files persona/workspace file contents for a
850
+ * template the agent has access to. Pass `version` to pin to the version
851
+ * the agent was installed from (omit the endpoint resolves `latest`).
933
852
  */
934
- resolveGoogleChatSender(args: {
935
- senderUserId: string;
936
- spaceId?: string;
853
+ getTemplateFiles(templateKey: string, opts?: {
854
+ version?: number;
937
855
  }): Promise<{
938
- identityId: string | null;
939
- status: string;
856
+ files: Record<string, string>;
940
857
  }>;
941
858
  }
942
- //# sourceMappingURL=identity.d.ts.map
859
+ //# sourceMappingURL=workspace.d.ts.map
943
860
  //#endregion
944
- //#region src/domains/search.d.ts
945
- /**
946
- * The broad-news providers behind the metered `services/news` Lambda. The
947
- * server validates this with a zod enum; a value outside the union is an
948
- * unpriceable product, so keep the literal union in lockstep with the service.
949
- */
950
- type NewsProvider = "apitube" | "newsdata";
951
- /** One normalized article. `sentiment` is provider-shaped (APITube supplies it). */
952
- interface NewsArticle {
953
- title: string;
861
+ //#region src/domains/sync.d.ts
862
+ interface SyncAgentInfo {
863
+ agentId: string;
864
+ tenantId: string;
865
+ displayName: string;
866
+ s3Prefix: string;
867
+ status: "stale" | "syncing" | "synced";
868
+ fileCount?: number;
869
+ totalSize?: number;
870
+ lastSync?: string;
871
+ }
872
+ interface SyncManifestEntry {
873
+ hash: string;
874
+ size: number;
875
+ modified: string;
876
+ etag?: string;
877
+ storageClass?: string;
878
+ compressed?: boolean;
879
+ }
880
+ interface SyncManifest {
881
+ version: 1;
882
+ agentId: string;
883
+ lastSync: string;
884
+ files: Record<string, SyncManifestEntry>;
885
+ }
886
+ interface SyncPresignedUrl {
887
+ path: string;
954
888
  url: string;
955
- source: string;
956
- publishedAt: string;
957
- snippet: string;
958
- sentiment?: unknown;
889
+ expiresAt: string;
959
890
  }
960
- /** Provider-agnostic result — the server normalizes every adapter to this. */
961
- interface NewsResult {
962
- articles: NewsArticle[];
963
- provider: string;
891
+ interface SyncConfirmedUpload {
892
+ filePath: string;
893
+ hash: string;
894
+ size: number;
895
+ storageClass: "STANDARD" | "GLACIER_IR";
896
+ syncedAt: string;
964
897
  }
965
- declare class SearchApi extends ApiBase {
966
- searchWeb(params: {
967
- query: string;
968
- count?: number;
969
- offset?: number;
970
- country?: string;
971
- freshness?: string;
972
- }, options?: {
973
- signal?: AbortSignal;
974
- }): Promise<unknown>;
975
- searchImages(params: {
976
- query: string;
977
- count?: number;
978
- }, options?: {
979
- signal?: AbortSignal;
980
- }): Promise<unknown>;
981
- searchNews(params: {
982
- query: string;
983
- count?: number;
984
- offset?: number;
985
- freshness?: string;
986
- }, options?: {
987
- signal?: AbortSignal;
988
- }): Promise<unknown>;
989
- /** Search news across the selected provider's corpus. → POST /agent/news/search */
990
- newsSearch(params: {
991
- query: string;
992
- provider?: NewsProvider;
993
- source?: string;
994
- from?: string;
995
- to?: string;
996
- language?: string;
997
- category?: string;
998
- limit?: number;
999
- }): Promise<NewsResult>;
1000
- /** Top headlines for the selected provider. → POST /agent/news/headlines */
1001
- newsHeadlines(params?: {
1002
- provider?: NewsProvider;
1003
- category?: string;
1004
- source?: string;
1005
- language?: string;
1006
- limit?: number;
1007
- }): Promise<NewsResult>;
898
+ interface SyncReconstructFile {
899
+ path: string;
900
+ size: number;
901
+ url: string;
902
+ storageClass?: string;
903
+ compressed?: boolean;
1008
904
  }
1009
- //# sourceMappingURL=search.d.ts.map
1010
- //#endregion
1011
- //#region src/domains/webhooks.d.ts
1012
- interface AgentWebhook {
1013
- webhookId: string;
1014
- tenantId: string;
905
+ interface SyncReconstructBundle {
1015
906
  agentId: string;
1016
- name: string;
1017
- provider: string;
1018
- active: boolean;
1019
- createdBy: string;
1020
- createdAt: string;
1021
- updatedAt: string;
907
+ mode: "full" | "active" | "memory";
908
+ fileCount: number;
909
+ totalSize: number;
910
+ files: SyncReconstructFile[];
911
+ expiresAt: string;
1022
912
  }
1023
- interface CreatedAgentWebhook extends AgentWebhook {
1024
- url: string;
1025
- signingSecret: string;
913
+ interface SyncAgentStats {
914
+ agentId: string;
915
+ standardBytes: number;
916
+ glacierBytes: number;
917
+ fileCount: number;
918
+ lastSyncAt: string | null;
1026
919
  }
1027
- interface AgentWebhookDelivery {
1028
- deliveryId: string;
1029
- webhookId: string;
1030
- status: string;
1031
- attempts: number;
1032
- createdAt: string;
1033
- deliveredAt?: string;
920
+ interface SyncFileEntry {
921
+ filePath: string;
922
+ size: number;
923
+ modified: string;
924
+ contentHash: string;
925
+ storageClass?: string;
926
+ compressed?: boolean;
1034
927
  }
1035
- declare class WebhooksApi extends ApiBase {
1036
- createWebhook(args: {
1037
- name: string;
1038
- provider?: "generic" | "github" | "stripe" | "slack";
1039
- }): Promise<CreatedAgentWebhook>;
1040
- listWebhooks(): Promise<AgentWebhook[]>;
1041
- deleteWebhook(webhookId: string): Promise<{
1042
- webhookId: string;
1043
- active: false;
1044
- }>;
1045
- rotateWebhookSecret(webhookId: string): Promise<{
1046
- webhookId: string;
1047
- signingSecret: string;
1048
- }>;
1049
- listWebhookDeliveries(webhookId: string): Promise<AgentWebhookDelivery[]>;
928
+ interface SyncSessionEntry {
929
+ sessionId: string;
930
+ size: number;
931
+ lastModified: string;
932
+ storageClass?: string;
933
+ isArchived: boolean;
1050
934
  }
1051
- //# sourceMappingURL=webhooks.d.ts.map
1052
- //#endregion
1053
- //#region src/domains/chat.d.ts
1054
- declare class ChatApi extends ApiBase {
1055
- ensureDirectConversation(identityId: string): Promise<{
1056
- conversationId: string;
1057
- identityId: string;
1058
- tenantId: string;
1059
- userId: string;
1060
- displayName: string;
1061
- created: boolean;
935
+ interface SyncSessionContent {
936
+ sessionId: string;
937
+ content: string;
938
+ compressed: boolean;
939
+ }
940
+ interface SharedFileEntry {
941
+ filePath: string;
942
+ fileName: string;
943
+ size: number;
944
+ contentType?: string;
945
+ }
946
+ declare class SyncApi extends ApiBase {
947
+ syncRegister(args?: {
948
+ displayName?: string;
949
+ }): Promise<{
950
+ agent: SyncAgentInfo;
1062
951
  }>;
1063
- presignAttachments(files: {
1064
- filename: string;
1065
- mimeType: string;
1066
- size: number;
1067
- }[]): Promise<{
1068
- attachments: {
1069
- id: string;
1070
- uploadUrl: string;
1071
- uploadHeaders: Record<string, string>;
1072
- downloadUrl: string;
1073
- s3Key: string;
1074
- expiresAt: string;
952
+ syncGetManifest(): Promise<SyncManifest>;
953
+ syncPresign(args: {
954
+ files: {
955
+ path: string;
956
+ operation: "put" | "get";
957
+ contentType?: string;
1075
958
  }[];
959
+ }): Promise<{
960
+ urls: SyncPresignedUrl[];
1076
961
  }>;
1077
- recordActivity(data: {
1078
- userId?: string;
1079
- channel: string;
1080
- role: "user" | "assistant";
962
+ syncConfirmUpload(args: {
963
+ filePath: string;
964
+ hash: string;
965
+ size: number;
966
+ storageClass?: "STANDARD" | "GLACIER_IR";
967
+ }): Promise<SyncConfirmedUpload>;
968
+ syncReconstruct(args: {
969
+ mode: "full" | "active" | "memory";
970
+ }): Promise<SyncReconstructBundle>;
971
+ syncGetStats(): Promise<SyncAgentStats>;
972
+ syncListFiles(args?: {
973
+ prefix?: string;
1081
974
  }): Promise<{
1082
- recorded: boolean;
975
+ files: SyncFileEntry[];
1083
976
  }>;
1084
- }
1085
- //# sourceMappingURL=chat.d.ts.map
1086
- //#endregion
1087
- //#region src/domains/connect-credentials.d.ts
1088
- declare class ConnectCredentialsApi extends ApiBase {
1089
- /**
1090
- * Returns every connected Google account for the agent. Multi-account by
1091
- * design — the openclaw-google plugin requires the LLM to pass `email`
1092
- * explicitly to `google_run_command` so an account is always selected
1093
- * deliberately.
1094
- *
1095
- * 2026-05-14 (connections-redesign PR 1): the legacy flat shape (`email`,
1096
- * `refreshToken`, `accessToken`, etc., populated from the default account)
1097
- * is gone. Iterate over `accounts`.
1098
- */
1099
- getGoogleCredentials(): Promise<{
1100
- accounts: {
1101
- email: string;
1102
- refreshToken: string;
1103
- clientId: string;
1104
- clientSecret: string;
1105
- displayName?: string;
1106
- connectedAt?: string;
1107
- }[];
977
+ syncListSessions(): Promise<{
978
+ sessions: SyncSessionEntry[];
1108
979
  }>;
1109
- disconnectGoogleAccount(email: string): Promise<{
1110
- accounts: {
1111
- email: string;
1112
- displayName?: string;
1113
- connectedAt?: string;
1114
- }[];
980
+ syncGetSession(sessionId: string): Promise<SyncSessionContent>;
981
+ syncDeleteFile(filePath: string): Promise<{
982
+ removed: boolean;
1115
983
  }>;
1116
- getGoogleChatCredentials(): Promise<{
1117
- email: string;
1118
- refreshToken: string;
1119
- clientId: string;
1120
- clientSecret: string;
1121
- displayName?: string;
984
+ sharedListFiles(args: {
985
+ scope: "org" | "team" | "project";
986
+ scopeId: string;
987
+ limit?: number;
988
+ cursor?: string;
989
+ }): Promise<{
990
+ files: SharedFileEntry[];
991
+ nextCursor: string | null;
1122
992
  }>;
1123
- /**
1124
- * Fetch decrypted credentials for ONE specific connection by its
1125
- * stable connectionId (connection-scoped, vs the provider-scoped
1126
- * `get<Provider>Credentials` helpers). Used by the daemon to resolve
1127
- * a Custom Connection-driven integration's credentials from the
1128
- * exact connection it was installed from — every custom connection
1129
- * shares the `custom` provider id, so provider-scoping is ambiguous.
1130
- *
1131
- * For custom connections `accessToken` is the JSON-encoded secret
1132
- * bundle (the daemon un-bundles it); non-secret fields are on
1133
- * `providerMetadata`. The endpoint enforces that the connection is in
1134
- * the calling agent's effective scope (403 otherwise).
1135
- */
1136
- getConnectionCredentials(connectionId: string): Promise<{
1137
- provider: string;
1138
- connectionId: string;
1139
- accountIdentifier?: string;
1140
- accessToken?: string;
1141
- providerMetadata?: Record<string, unknown>;
1142
- [key: string]: unknown;
993
+ sharedDownloadUrl(args: {
994
+ scope: "org" | "team" | "project";
995
+ scopeId: string;
996
+ filePath: string;
997
+ }): Promise<{
998
+ downloadUrl: string;
999
+ expiresIn: number;
1143
1000
  }>;
1001
+ }
1002
+ //# sourceMappingURL=sync.d.ts.map
1003
+ //#endregion
1004
+ //#region src/domains/knowledge.d.ts
1005
+ type KnowledgeScopeType = "org" | "team" | "project";
1006
+ interface KnowledgeScope {
1007
+ scopeType: KnowledgeScopeType;
1008
+ scopeId: string;
1009
+ name: string;
1010
+ }
1011
+ interface KnowledgeSearchHit {
1012
+ id: string;
1013
+ text: string;
1014
+ /** Normalized relevance in (0,1]; higher = closer. */
1015
+ score: number;
1016
+ scopeType: KnowledgeScopeType;
1017
+ scopeId: string;
1144
1018
  /**
1145
- * @deprecated Returns a single primary credential blob (legacy "pick-the-
1146
- * default-connection" shape). Use `getGithubAccounts()` for the multi-
1147
- * account shape required by Pattern A explicit selector args on every
1148
- * tool. Retained because the `@alfe.ai/github-mcp` proxy is the
1149
- * only consumer that knows about Pattern A; legacy env-interpolation
1150
- * callers will keep hitting `/credentials` until they move to the proxy.
1019
+ * Provenance of the hit. All live results are `"doc"`; `"fact"` only ever
1020
+ * appears for legacy vectors indexed before the facts primitive was removed
1021
+ * (the search index stays tolerant of them). Treat every hit as a doc.
1151
1022
  */
1152
- getGithubCredentials(): Promise<{
1153
- login: string;
1154
- accessToken: string;
1155
- }>;
1023
+ source: "doc" | "fact";
1024
+ /** The canonical file under shared/<scope>/ (present on doc hits). */
1025
+ filePath?: string;
1026
+ /** Legacy-only: the id of a pre-removal fact vector. */
1027
+ factId?: string;
1028
+ }
1029
+ interface KnowledgeSearchResult {
1030
+ results: KnowledgeSearchHit[];
1031
+ /** True when fan-out breadth was capped (more member scopes than the cap). */
1032
+ truncatedScopes: boolean;
1033
+ }
1034
+ interface KnowledgeProfileLink {
1035
+ label: string;
1036
+ url: string;
1037
+ }
1038
+ interface KnowledgeProfile {
1039
+ scopeType: KnowledgeScopeType;
1040
+ scopeId: string;
1041
+ about: string | null;
1042
+ description: string | null;
1043
+ links: KnowledgeProfileLink[];
1044
+ updatedAt: string | null;
1045
+ updatedBy: string | null;
1046
+ }
1047
+ type ChangeRequestResourceType = "doc" | "profile";
1048
+ type ChangeRequestOperation = "create" | "update" | "delete";
1049
+ type ChangeRequestStatus = "open" | "approved" | "rejected" | "withdrawn" | "superseded";
1050
+ type ChangeRequestActorKind = "human" | "agent";
1051
+ /** Public projection of a change request (mirrors `PublicChangeRequest` in services/org). */
1052
+ interface KnowledgeChangeRequest {
1053
+ changeRequestId: string;
1054
+ scopeType: KnowledgeScopeType;
1055
+ scopeId: string;
1056
+ resourceType: ChangeRequestResourceType;
1057
+ operation: ChangeRequestOperation;
1058
+ targetPath: string | null;
1059
+ baseVersionId: string | null;
1060
+ proposedContentType: string | null;
1061
+ status: ChangeRequestStatus;
1062
+ proposerId: string;
1063
+ proposerKind: ChangeRequestActorKind;
1064
+ rationale: string;
1065
+ reviewerId: string | null;
1066
+ reviewerKind: ChangeRequestActorKind | null;
1067
+ reviewedAt: string | null;
1068
+ reviewNote: string | null;
1069
+ appliedRef: string | null;
1070
+ createdAt: string;
1071
+ updatedAt: string;
1072
+ }
1073
+ /** Per-type proposal payload for `proposeScopeChange`. */
1074
+ interface ProposeScopeChangeInput {
1075
+ resourceType: ChangeRequestResourceType;
1076
+ operation: ChangeRequestOperation;
1077
+ /** Why the change is proposed — shown to the reviewer. */
1078
+ rationale: string;
1079
+ /** doc: the path the proposal applies to (e.g. designs/data-center.md). */
1080
+ targetPath?: string;
1081
+ /** doc create/update: the staged body to upload (markdown or other text). */
1082
+ content?: string;
1083
+ /** doc create/update: content type of the staged body (default text/markdown). */
1084
+ contentType?: string;
1085
+ /** profile: the proposed value ({ about, description, links }). */
1086
+ proposedValue?: unknown;
1087
+ }
1088
+ interface KnowledgeDoc {
1089
+ filePath: string;
1090
+ fileName: string;
1091
+ contentType?: string;
1092
+ size: number;
1093
+ uploadedBy?: string;
1094
+ createdAt: string;
1095
+ updatedAt: string;
1096
+ }
1097
+ declare class KnowledgeApi extends ApiBase {
1156
1098
  /**
1157
- * Pattern A: multi-account credential fetch for GitHub.
1158
- *
1159
- * Returns every agent-scoped GitHub connection. The caller is expected
1160
- * to require a `login` selector on every credential-touching tool and
1161
- * look up the matching account at dispatch time.
1162
- *
1163
- * GitHub OAuth tokens have no expiry (`tokenLifecycle: "no_expiry"`),
1164
- * so there is intentionally no `refreshGithubAccountToken` method — if
1165
- * a token is revoked the user must re-run the OAuth flow.
1166
- *
1167
- * Returned `accounts[i].login` is the GitHub username — the stable
1168
- * cross-session identifier the LLM should pass.
1099
+ * Semantic search across the agent's member scopes. Fan-out is gated
1100
+ * server-side by `listScopes` set-inclusion (fail-closed). Pass
1101
+ * `scopeType` + `scopeId` to narrow to one scope; a non-member scope
1102
+ * yields empty results (never a cross-scope leak).
1169
1103
  */
1170
- getGithubAccounts(): Promise<{
1171
- accounts: {
1172
- connectionId: string;
1173
- accountIdentifier: string;
1174
- displayName: string | null;
1175
- connectedAt: string;
1176
- accessToken: string;
1177
- login: string;
1178
- scopes: string;
1179
- }[];
1104
+ knowledgeSearch(query: string, opts?: {
1105
+ limit?: number;
1106
+ scopeType?: KnowledgeScopeType;
1107
+ scopeId?: string;
1108
+ }): Promise<KnowledgeSearchResult>;
1109
+ /** Enumerate the scopes (org + teams + projects) this agent belongs to. */
1110
+ listScopes(): Promise<{
1111
+ scopes: KnowledgeScope[];
1180
1112
  }>;
1113
+ /** Read a scope's structured knowledge profile (after membership check). */
1114
+ getScopeProfile(scopeType: KnowledgeScopeType, scopeId: string): Promise<KnowledgeProfile>;
1181
1115
  /**
1182
- * @deprecated Returns a single primary credential blob (legacy "pick-the-
1183
- * default-connection" shape). Use `getXeroAccounts()` for the multi-
1184
- * account shape required by Pattern A explicit selector args on every
1185
- * tool. This method will be removed once all consumers migrate.
1116
+ * Open a change request against a scope's knowledge resource. For a doc
1117
+ * create/update, `services/org` returns a presigned staging PUT; this method
1118
+ * uploads the proposed `content` to it (echoing the same Content-Type that
1119
+ * was signed), mirroring `writeScopeDoc`. The staged body is applied to the
1120
+ * canonical doc — attributed to this agent — only when a reviewer approves.
1186
1121
  */
1187
- getXeroCredentials(): Promise<{
1188
- accessToken: string;
1189
- accessTokenExpiresAt: string;
1190
- xeroTenantId: string;
1191
- }>;
1122
+ proposeScopeChange(scopeType: KnowledgeScopeType, scopeId: string, input: ProposeScopeChangeInput): Promise<KnowledgeChangeRequest>;
1192
1123
  /**
1193
- * Pattern A: multi-account credential fetch for Xero. Returns every
1194
- * agent-scoped Xero connection. The caller is expected to require a
1195
- * selector arg (e.g. `xeroTenantId`) on every credential-touching tool
1196
- * and look up the matching account by that selector at dispatch time.
1197
- *
1198
- * `xeroTenantId` is the model-facing organisation selector. The separate
1199
- * `accountIdentifier` is the Connect persistence key used for refresh and
1200
- * may be an email; never substitute one for the other.
1124
+ * List the agent's OWN change requests in a scope (filtered server-side to
1125
+ * this agent as proposer). Pass `status` to narrow to open / approved / etc.
1201
1126
  */
1202
- getXeroAccounts(): Promise<{
1203
- accounts: {
1204
- connectionId: string;
1205
- accountIdentifier: string;
1206
- displayName: string | null;
1207
- connectedAt: string;
1208
- accessToken: string;
1209
- accessTokenExpiresAt: string;
1210
- xeroTenantId: string;
1211
- }[];
1127
+ listScopeChangeRequests(scopeType: KnowledgeScopeType, scopeId: string, opts?: {
1128
+ status?: ChangeRequestStatus;
1129
+ limit?: number;
1130
+ cursor?: string;
1131
+ }): Promise<{
1132
+ changeRequests: KnowledgeChangeRequest[];
1133
+ nextCursor: string | null;
1212
1134
  }>;
1213
- refreshXeroToken(): Promise<{
1214
- accessToken: string;
1215
- expiresAt: string;
1135
+ /** List a scope's docs (the org-files corpus; mirrored to shared/<scope>/). */
1136
+ listScopeDocs(scopeType: KnowledgeScopeType, scopeId: string, opts?: {
1137
+ limit?: number;
1138
+ cursor?: string;
1139
+ }): Promise<{
1140
+ files: KnowledgeDoc[];
1141
+ nextCursor: string | null;
1216
1142
  }>;
1217
1143
  /**
1218
- * Refresh a specific Xero Connection by its exact `accountIdentifier` from
1219
- * `getXeroAccounts()`. Do not substitute `xeroTenantId`: current Xero OAuth
1220
- * rows may use the account email as their persistence key even when a sole
1221
- * organisation tenant ID is available in provider metadata.
1144
+ * Read the full text of a scope doc. Resolves a presigned download URL
1145
+ * from `services/org`, then fetches the bytes directly from S3 (the one
1146
+ * legitimate raw fetch in a plugin same pattern as sync).
1222
1147
  */
1223
- refreshXeroAccountToken(accountIdentifier: string): Promise<{
1224
- accessToken: string;
1225
- accessTokenExpiresAt: string;
1226
- expiresAt: string;
1148
+ readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, opts?: {
1149
+ maxBytes?: number;
1150
+ }): Promise<{
1151
+ filePath: string;
1152
+ text: string;
1227
1153
  }>;
1228
1154
  /**
1229
- * @deprecated Returns a single primary credential blob (legacy "pick-the-
1230
- * default-connection" shape). Use `getNotionAccounts()` for the multi-
1231
- * account shape required by Pattern A.
1155
+ * Write (create or overwrite) a scope doc. Two-step presigned upload:
1156
+ * `services/org` returns a signed URL plus `requiredHeaders` (author /
1157
+ * authorKind / message as `x-amz-meta-*`) that MUST be sent verbatim on
1158
+ * the PUT, alongside the same `Content-Type` that was signed. Author and
1159
+ * authorKind are server-set from the agent token — never trusted here.
1232
1160
  */
1233
- getNotionCredentials(): Promise<{
1234
- accessToken: string;
1235
- workspaceId: string;
1236
- workspaceName: string;
1161
+ writeScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, content: string, opts?: {
1162
+ contentType?: string;
1163
+ message?: string;
1164
+ }): Promise<{
1165
+ filePath: string;
1166
+ }>;
1167
+ }
1168
+ //# sourceMappingURL=knowledge.d.ts.map
1169
+ //#endregion
1170
+ //#region src/domains/mobile.d.ts
1171
+ /** Response of GET /mobile/numbers for an agent (services/mobile). */
1172
+ interface MobileNumberInfo {
1173
+ phoneNumber: string;
1174
+ countryCode: string;
1175
+ monthlyPrice?: number;
1176
+ status: string;
1177
+ errorMessage?: string;
1178
+ }
1179
+ /** One purchasable number from GET /mobile/numbers/search. */
1180
+ interface MobileAvailableNumber {
1181
+ number: string;
1182
+ friendlyName: string;
1183
+ locality: string;
1184
+ region: string;
1185
+ country: string;
1186
+ }
1187
+ /** Approved WhatsApp content template from GET /mobile/whatsapp/templates. */
1188
+ interface WhatsAppTemplate {
1189
+ contentSid: string;
1190
+ name: string;
1191
+ language: string;
1192
+ body: string;
1193
+ variables: Record<string, string>;
1194
+ category?: string;
1195
+ }
1196
+ declare class MobileApi extends ApiBase {
1197
+ getMobileNumber(): Promise<MobileNumberInfo>;
1198
+ searchMobileNumbers(args?: {
1199
+ country?: string;
1200
+ query?: string;
1201
+ }): Promise<{
1202
+ numbers: MobileAvailableNumber[];
1203
+ monthlyPrice: number;
1204
+ }>;
1205
+ assignMobileNumber(args: {
1206
+ phoneNumber: string;
1207
+ countryCode: string;
1208
+ }): Promise<{
1209
+ phoneNumber: string;
1210
+ countryCode: string;
1211
+ status: "pending";
1212
+ }>;
1213
+ releaseMobileNumber(): Promise<{
1214
+ released: true;
1215
+ }>;
1216
+ sendSms(args: {
1217
+ to: string;
1218
+ body: string;
1219
+ }): Promise<{
1220
+ sent: true;
1221
+ sid: string;
1222
+ }>;
1223
+ startOutboundCall(args: {
1224
+ to: string;
1225
+ }): Promise<{
1226
+ callSid: string;
1227
+ status: string;
1228
+ }>;
1229
+ getWhatsAppSession(to: string): Promise<{
1230
+ active: boolean;
1231
+ expiresAt?: string;
1232
+ }>;
1233
+ sendWhatsAppMessage(args: {
1234
+ to: string;
1235
+ body: string;
1236
+ }): Promise<{
1237
+ sent: true;
1238
+ sid: string;
1239
+ }>;
1240
+ sendWhatsAppTemplate(args: {
1241
+ to: string;
1242
+ contentSid: string;
1243
+ contentVariables: Record<string, string>;
1244
+ bodyPreview?: string;
1245
+ }): Promise<{
1246
+ sent: true;
1247
+ sid: string;
1248
+ }>;
1249
+ listWhatsAppTemplates(): Promise<{
1250
+ templates: WhatsAppTemplate[];
1251
+ }>;
1252
+ }
1253
+ //# sourceMappingURL=mobile.d.ts.map
1254
+ //#endregion
1255
+ //#region src/domains/remote.d.ts
1256
+ interface RemoteSessionInfo {
1257
+ sessionId: string;
1258
+ agentId: string;
1259
+ surface: "browser" | "terminal";
1260
+ status: "agent_driving" | "awaiting_human" | "human_in_control" | "resuming" | "completed" | "expired" | "failed";
1261
+ url?: string;
1262
+ instructions?: string;
1263
+ requestedAt?: string;
1264
+ }
1265
+ declare class RemoteApi extends ApiBase {
1266
+ requestBrowserTakeover(args: {
1267
+ instructions: string;
1268
+ url?: string;
1269
+ conversationId?: string;
1270
+ }): Promise<{
1271
+ sessionId: string;
1272
+ status: string;
1273
+ }>;
1274
+ getRemoteSession(sessionId: string): Promise<RemoteSessionInfo>;
1275
+ completeRemoteSession(sessionId: string): Promise<{
1276
+ ok: boolean;
1237
1277
  }>;
1278
+ }
1279
+ //# sourceMappingURL=remote.d.ts.map
1280
+ //#endregion
1281
+ //#region src/domains/self.d.ts
1282
+ /** Voice settings — core agent config. Mirrors `VoiceConfig` in `@alfe/types`. */
1283
+ interface AgentVoiceConfig {
1284
+ /** ElevenLabs voice ID; platform default when unset. */
1285
+ voiceId?: string;
1286
+ ttsModel?: string;
1287
+ enabled?: boolean;
1288
+ }
1289
+ /**
1290
+ * The agent's own public identity, as returned by `updateSelf`, `generateAvatar`,
1291
+ * `presignAvatar`'s finalize (`finalizeAvatar`). This is the public agent
1292
+ * projection; only the identity-relevant fields are typed here — the response
1293
+ * carries the full public agent record.
1294
+ */
1295
+ interface AgentSelf {
1296
+ agentId: string;
1297
+ tenantId: string;
1298
+ name: string;
1299
+ avatarUrl?: string;
1300
+ voiceConfig?: AgentVoiceConfig;
1301
+ status: string;
1302
+ }
1303
+ /** Result of `presignAvatar` — the agent PUTs bytes to `uploadUrl`, then finalizes with `s3Key`. */
1304
+ interface AgentAvatarPresign {
1305
+ /** Presigned PUT URL to upload the image bytes to. */
1306
+ uploadUrl: string;
1307
+ /** Object key — echoed back to `finalizeAvatar`. */
1308
+ s3Key: string;
1309
+ /** Stable public URL the avatar will be served from once finalized. */
1310
+ publicUrl: string;
1311
+ /** ISO expiry of the presigned PUT URL. */
1312
+ expiresAt: string;
1313
+ }
1314
+ /** A voice in the platform catalogue (ElevenLabs), from `listVoices`. */
1315
+ interface AgentVoice {
1316
+ id: string;
1317
+ name: string;
1318
+ previewUrl: string;
1319
+ description: string;
1320
+ labels: Record<string, string>;
1321
+ category: string;
1322
+ }
1323
+ declare class SelfApi extends ApiBase {
1324
+ /** Update the agent's own name and/or voice config. Returns the updated agent. */
1325
+ updateSelf(update: {
1326
+ name?: string;
1327
+ voiceConfig?: AgentVoiceConfig;
1328
+ }): Promise<AgentSelf>;
1238
1329
  /**
1239
- * Pattern A: multi-account credential fetch for Notion. Returns every
1240
- * agent-scoped Notion connection. The caller is expected to require a
1241
- * selector arg (e.g. `workspaceId`) on every credential-touching tool.
1330
+ * Generate the agent's own avatar from a text prompt. The image is generated,
1331
+ * stored, and set on the agent server-side; returns the updated agent.
1242
1332
  *
1243
- * Returned `accounts[i].accountIdentifier` is the Notion workspaceId.
1333
+ * ASYNC (same reason as `generateImage`): avatar gen runs `gpt-image-1`
1334
+ * (30–60s) which exceeds the API Gateway 30s ceiling, so this enqueues a job
1335
+ * (`POST /agent/avatar/generate` → `jobId`) then polls (`GET /agent/avatar/{jobId}`)
1336
+ * until the avatar is set. Signature unchanged — the plugin is unaffected.
1244
1337
  */
1245
- getNotionAccounts(): Promise<{
1246
- accounts: {
1247
- connectionId: string;
1248
- accountIdentifier: string;
1249
- displayName: string | null;
1250
- connectedAt: string;
1251
- accessToken: string;
1252
- workspaceId: string;
1253
- workspaceName: string;
1254
- }[];
1255
- }>;
1338
+ generateAvatar(args: {
1339
+ prompt: string;
1340
+ }): Promise<AgentSelf>;
1256
1341
  /**
1257
- * @deprecated Returns a single primary Atlassian Connection's credentials
1258
- * (one OAuth user, one cloudId) the legacy "pick-the-default-connection"
1259
- * shape. Atlassian is multi-site by nature (each OAuth user may have
1260
- * access to multiple Cloud sites), so Pattern A plugins MUST use
1261
- * `getAtlassianAccounts()` to discover the full set and dispatch via
1262
- * the `cloudId` selector arg.
1342
+ * Get a presigned PUT URL to upload a new avatar image. Upload the bytes to
1343
+ * `uploadUrl`, then call `finalizeAvatar(s3Key)` to set it on the agent.
1263
1344
  */
1264
- getAtlassianCredentials(): Promise<{
1265
- accessToken: string;
1266
- refreshToken: string;
1267
- accessTokenExpiresAt: string;
1268
- cloudId: string;
1269
- siteName: string;
1270
- siteUrl: string;
1271
- email: string;
1272
- enabledProducts: string[];
1273
- clientId: string;
1274
- clientSecret: string;
1275
- }>;
1276
- refreshAtlassianToken(): Promise<{
1277
- accessToken: string;
1278
- expiresAt: string;
1279
- }>;
1345
+ presignAvatar(args: {
1346
+ mimeType: string;
1347
+ size: number;
1348
+ }): Promise<AgentAvatarPresign>;
1280
1349
  /**
1281
- * Pattern A: multi-account / multi-site credential fetch for Atlassian.
1282
- *
1283
- * Returns every agent-scoped Atlassian Connection. Each Connection is
1284
- * one OAuth user with a single access token and N accessible Cloud
1285
- * sites (`availableSites`). The caller is expected to:
1286
- *
1287
- * 1. Flatten (connection × cloudId) into one MCP child per site.
1288
- * 2. Require a `cloudId` selector on every credential-touching tool.
1289
- * 3. Use the access token bound to the Connection that owns the
1290
- * requested `cloudId` (Atlassian shares one access token across
1291
- * all sites accessible to the OAuth user).
1292
- *
1293
- * Per-account token refresh uses `refreshAtlassianAccountToken(email)`
1294
- * — refreshing one Connection rotates its single access token, which
1295
- * then applies to every cloudId for that Connection.
1296
- *
1297
- * Returned `accounts[i].accountIdentifier` is the OAuth user's email
1298
- * — the stable cross-session identifier for refresh purposes. The LLM
1299
- * never sees this directly: it picks a site via the `cloudId` arg
1300
- * instead.
1350
+ * Finalize an avatar upload validates ownership + size, then sets the
1351
+ * agent's `avatarUrl` server-side. Returns the updated agent.
1301
1352
  */
1302
- getAtlassianAccounts(): Promise<{
1303
- accounts: {
1304
- connectionId: string;
1305
- accountIdentifier: string;
1306
- displayName: string | null;
1307
- connectedAt: string;
1308
- accessToken: string;
1309
- accessTokenExpiresAt: string;
1310
- clientId: string;
1311
- clientSecret: string;
1312
- cloudId: string;
1313
- siteName: string;
1314
- siteUrl: string;
1315
- availableSites: {
1316
- id: string;
1317
- url: string;
1318
- name: string;
1319
- scopes?: string[];
1320
- avatarUrl?: string;
1321
- }[];
1322
- }[];
1353
+ finalizeAvatar(s3Key: string): Promise<AgentSelf>;
1354
+ /** List the platform voice catalogue (ElevenLabs) so the agent can pick its own voice. */
1355
+ listVoices(): Promise<{
1356
+ voices: AgentVoice[];
1323
1357
  }>;
1358
+ }
1359
+ //# sourceMappingURL=self.d.ts.map
1360
+ //#endregion
1361
+ //#region src/domains/voice.d.ts
1362
+ /** The ElevenLabs models with a pricing row — the TTS endpoint rejects any other value. */
1363
+ type VoiceTtsModel = "eleven_turbo_v2_5" | "eleven_multilingual_v2";
1364
+ interface VoiceTtsArgs {
1365
+ /** Text to synthesize (1–5000 chars — the endpoint enforces this). */
1366
+ text: string;
1367
+ /** ElevenLabs voice id; platform default when unset. */
1368
+ voiceId?: string;
1369
+ /** TTS model; `eleven_turbo_v2_5` (lower latency) when unset. */
1370
+ model?: VoiceTtsModel;
1371
+ }
1372
+ /** Raw synthesized audio plus its PCM framing (from the response headers). */
1373
+ interface VoiceTtsResult {
1374
+ /** Raw little-endian PCM samples — no container. Wrap in WAV to make a playable file. */
1375
+ audio: Buffer;
1376
+ /** Samples per second (e.g. 24000). */
1377
+ sampleRate: number;
1378
+ /** Channel count (mono = 1). */
1379
+ channels: number;
1380
+ /** Bits per sample (e.g. 16). */
1381
+ bitDepth: number;
1382
+ }
1383
+ interface VoiceSttArgs {
1384
+ /** Raw linear16 (16-bit little-endian) mono PCM samples — no WAV/container header. */
1385
+ audio: Uint8Array;
1386
+ /** Sample rate of `audio` in Hz (8000–48000). */
1387
+ sampleRate: number;
1388
+ }
1389
+ interface VoiceSttResult {
1390
+ text: string;
1391
+ /** Deepgram confidence in (0,1]. */
1392
+ confidence: number;
1393
+ }
1394
+ declare class VoiceApi extends ApiBase {
1324
1395
  /**
1325
- * Pattern A: refresh a specific Atlassian Connection by `accountIdentifier`
1326
- * (the OAuth user's email).
1327
- *
1328
- * Atlassian rotates refresh tokens (`rotatesRefreshToken: true`); the
1329
- * server-side per-account refresh endpoint handles rotation and
1330
- * persistence. Refreshing one Connection updates its single access
1331
- * token, which applies to every accessible Cloud site (cloudId) for
1332
- * that OAuth user.
1333
- *
1334
- * Returns the new access token + expiry. The proxy is responsible for
1335
- * fanning the new token out to every child server it spawned for
1336
- * cloudIds owned by this Connection.
1396
+ * Text-to-speech. Returns raw PCM audio bytes plus their framing — the
1397
+ * voice service defaults to 24 kHz / mono / 16-bit. Wrap in a WAV container
1398
+ * to produce a playable file. Metered per character against the tenant
1399
+ * credit pool server-side; TTS completes regardless of metering outcome.
1337
1400
  */
1338
- refreshAtlassianAccountToken(accountIdentifier: string): Promise<{
1339
- accessToken: string;
1340
- accessTokenExpiresAt: string;
1341
- expiresAt: string;
1342
- }>;
1401
+ tts(args: VoiceTtsArgs): Promise<VoiceTtsResult>;
1343
1402
  /**
1344
- * @deprecated Returns a single primary credential blob (legacy "pick-the-
1345
- * default-connection" shape). Use `getMYOBAccounts()` for the multi-
1346
- * account shape required by Pattern A.
1403
+ * Speech-to-text. Accepts raw linear16 (16-bit LE) mono PCM — NOT a WAV or
1404
+ * other container (the endpoint transcribes with a fixed linear16 encoding,
1405
+ * so a container header would be transcribed as noise). Strip any WAV header
1406
+ * and pass `sampleRate` from it before calling. Metered by transcribed
1407
+ * duration against the tenant credit pool server-side.
1347
1408
  */
1348
- getMYOBCredentials(): Promise<{
1349
- accessToken: string;
1350
- accessTokenExpiresAt: string;
1351
- myobBusinessId: string;
1352
- clientId: string;
1353
- }>;
1409
+ stt(args: VoiceSttArgs): Promise<VoiceSttResult>;
1410
+ }
1411
+ //# sourceMappingURL=voice.d.ts.map
1412
+ //#endregion
1413
+ //#region src/domains/identity.d.ts
1414
+ type IdentityStatus = "anonymous" | "partial" | "identified" | "verified";
1415
+ interface IdentityDirectoryEntry {
1416
+ identityId: string;
1417
+ status: IdentityStatus;
1418
+ displayName: string;
1419
+ name?: string;
1420
+ avatarUrl?: string;
1421
+ lastSeenAt: string;
1422
+ lastSeenProvider?: string;
1423
+ messageable: boolean;
1424
+ }
1425
+ declare class IdentityApi extends ApiBase {
1354
1426
  /**
1355
- * Pattern A: multi-account credential fetch for MYOB. Returns every
1356
- * agent-scoped MYOB connection. The caller is expected to require a
1357
- * selector arg (e.g. `myobBusinessId` / `accountIdentifier`) on every
1358
- * credential-touching tool.
1359
- *
1360
- * Returned `accounts[i].accountIdentifier` is the MYOB businessId.
1427
+ * Returns the calling agent's own identity context `{ agentId, tenantId }`
1428
+ * decoded server-side from the agent API token. Used by the
1429
+ * `@alfe.ai/openclaw-identity` plugin to bootstrap context when the
1430
+ * OpenClaw daemon doesn't plumb `ctx.agentId` through to plugin hooks.
1431
+ * Plugins should cache this for the daemon's lifetime (single-agent-per-
1432
+ * process invariant). One HTTP round-trip per process activate; not for
1433
+ * per-call use.
1361
1434
  */
1362
- getMYOBAccounts(): Promise<{
1363
- accounts: {
1364
- connectionId: string;
1365
- accountIdentifier: string;
1366
- displayName: string | null;
1367
- connectedAt: string;
1368
- accessToken: string;
1369
- accessTokenExpiresAt: string;
1370
- myobBusinessId: string;
1371
- clientId: string;
1372
- }[];
1435
+ whoami(): Promise<{
1436
+ agentId: string;
1437
+ tenantId: string;
1373
1438
  }>;
1374
- refreshMYOBToken(): Promise<{
1375
- accessToken: string;
1376
- expiresAt: string;
1439
+ resolveIdentity(args: {
1440
+ provider: string;
1441
+ platformId: string;
1442
+ kind?: "user" | "agent" | "service" | "bot" | "workspace";
1443
+ displayName?: string;
1444
+ }): Promise<{
1445
+ identityId: string | null;
1446
+ status: string;
1447
+ created?: boolean;
1448
+ reason?: string;
1449
+ /**
1450
+ * Flattened auriclabs permission strings for the resolved identity
1451
+ * (scope-prefixed where applicable). Empty array on miss / org service
1452
+ * outage — the runtime gate fails closed in that case.
1453
+ */
1454
+ permissions: string[];
1377
1455
  }>;
1378
- /**
1379
- * Pattern A: refresh one MYOB Connection by its stable
1380
- * `accountIdentifier` (the MYOB business id returned by
1381
- * `getMYOBAccounts()`).
1382
- *
1383
- * MYOB refresh tokens belong to individual Connection rows. A
1384
- * multi-business client must use this method instead of refreshing the
1385
- * primary Connection and copying that access token into every cached
1386
- * business client.
1387
- */
1388
- refreshMYOBAccountToken(accountIdentifier: string): Promise<{
1389
- accessToken: string;
1390
- accessTokenExpiresAt: string;
1391
- expiresAt: string;
1456
+ searchIdentities(args?: {
1457
+ q?: string;
1458
+ status?: string;
1459
+ limit?: number;
1460
+ }): Promise<{
1461
+ identities: unknown[];
1462
+ }>;
1463
+ listIdentities(args?: {
1464
+ status?: IdentityStatus;
1465
+ limit?: number;
1466
+ cursor?: string;
1467
+ }): Promise<{
1468
+ identities: IdentityDirectoryEntry[];
1469
+ cursor: string | null;
1392
1470
  }>;
1393
- /**
1394
- * @deprecated Returns a single primary credential blob. Use
1395
- * `getSalesforceAccounts()` for the multi-account shape required by
1396
- * Pattern A.
1397
- */
1398
- getSalesforceCredentials(): Promise<{
1399
- accessToken: string;
1400
- accessTokenExpiresAt: string;
1401
- instanceUrl: string;
1402
- orgId: string;
1471
+ getIdentityContext(identityId: string): Promise<{
1472
+ context: unknown;
1403
1473
  }>;
1404
- /**
1405
- * Pattern A: multi-account credential fetch for Salesforce. Returns every
1406
- * agent-scoped Salesforce connection. One OAuth grant maps to one org, so
1407
- * `accounts[i].accountIdentifier` (and `orgId`) is the Salesforce org id —
1408
- * the selector every credential-touching tool requires.
1409
- */
1410
- getSalesforceAccounts(): Promise<{
1411
- accounts: {
1412
- connectionId: string;
1413
- accountIdentifier: string;
1414
- displayName: string | null;
1415
- connectedAt: string;
1416
- accessToken: string;
1417
- accessTokenExpiresAt: string;
1418
- instanceUrl: string;
1419
- orgId: string;
1420
- }[];
1474
+ mergeIdentities(survivorId: string, args: {
1475
+ mergedId: string;
1476
+ }): Promise<{
1477
+ ok: boolean;
1478
+ error?: string;
1421
1479
  }>;
1422
- /**
1423
- * Refresh the access token for a specific Salesforce org. Salesforce
1424
- * tokens aren't interchangeable across orgs, so the connection is targeted
1425
- * by `accountIdentifier` (the org id) — mirrors `refreshXeroAccountToken`.
1426
- */
1427
- refreshSalesforceAccountToken(orgId: string): Promise<{
1428
- accessToken: string;
1429
- accessTokenExpiresAt: string;
1430
- expiresAt: string;
1480
+ unmergeIdentity(identityId: string): Promise<{
1481
+ ok: boolean;
1482
+ error?: string;
1431
1483
  }>;
1432
- /**
1433
- * Pattern A: multi-account credential fetch for Microsoft 365.
1434
- *
1435
- * Returns every agent-scoped Microsoft connection. The caller is expected
1436
- * to require an `email` selector on every credential-touching tool and
1437
- * look up the matching account at dispatch time.
1438
- *
1439
- * Returned `accounts[i].accountIdentifier` is the user's primary email
1440
- * (or the tid claim as fallback) — the stable cross-session identifier
1441
- * the LLM should pass.
1442
- *
1443
- * Per-account token refresh is exposed via `refreshMicrosoftAccountToken`,
1444
- * NOT `refreshXeroAccountToken` — Microsoft refresh tokens are not
1445
- * interchangeable across (tenant, user) pairs.
1446
- */
1447
- getMicrosoftAccounts(): Promise<{
1448
- accounts: {
1449
- connectionId: string;
1450
- accountIdentifier: string;
1451
- displayName: string | null;
1452
- connectedAt: string;
1453
- accessToken: string;
1454
- accessTokenExpiresAt: string;
1455
- email: string;
1456
- microsoftTenantId: string;
1457
- workspaceDomain: string;
1458
- }[];
1484
+ addIdentityNote(identityId: string, args: {
1485
+ content: string;
1486
+ category?: string;
1487
+ }): Promise<{
1488
+ noteId: string | null;
1459
1489
  }>;
1460
- /**
1461
- * Pattern A: refresh a specific Microsoft 365 connection by its
1462
- * `accountIdentifier`. For Microsoft, `accountIdentifier` is the user's
1463
- * email when the Graph profile fetch succeeded at connect time, and the
1464
- * Azure tenant id (`tid` claim) as fallback. Callers should pass the
1465
- * value returned by `getMicrosoftAccounts()` rather than synthesising
1466
- * an email locally.
1467
- *
1468
- * Microsoft refresh tokens are bound to a specific (tenant, user) pair —
1469
- * they are NOT interchangeable across accounts, so per-account refresh
1470
- * is mandatory. The generic /accounts/{accountIdentifier}/refresh
1471
- * endpoint walks the agent's full visible scope chain to find a matching
1472
- * connection (works for inherited team/project Microsoft connections).
1473
- */
1474
- refreshMicrosoftAccountToken(accountIdentifier: string): Promise<{
1475
- accessToken: string;
1476
- accessTokenExpiresAt: string;
1477
- expiresAt: string;
1490
+ tagIdentity(identityId: string, args: {
1491
+ tag: string;
1492
+ action: "add" | "remove";
1493
+ }): Promise<{
1494
+ ok: boolean;
1478
1495
  }>;
1479
- /**
1480
- * Disconnects one connected Microsoft 365 account for the agent, by its
1481
- * `accountIdentifier`. Hits the generic per-account disconnect route
1482
- * (`DELETE /agent/connect/microsoft/accounts/{accountIdentifier}`), which
1483
- * resolves across the agent's full effective scope chain and deletes the
1484
- * matching Connection row. Returns the remaining accounts.
1485
- *
1486
- * IMPORTANT: pass the `accountIdentifier` from `getMicrosoftAccounts()`, NOT
1487
- * a synthesised email. For Microsoft, `accountIdentifier` is the user's email
1488
- * only when the Graph profile fetch succeeded at connect time; it falls back
1489
- * to the Azure tenant id (`tid` claim) otherwise. The backend matches on
1490
- * `accountIdentifier` exactly, so passing an email would 404 on those
1491
- * fallback-identifier accounts. (This is why the param is not named `email`,
1492
- * unlike `disconnectGoogleAccount` where the identifier is always the email.)
1493
- */
1494
- disconnectMicrosoftAccount(accountIdentifier: string): Promise<{
1495
- accounts: {
1496
- accountIdentifier: string;
1497
- displayName?: string;
1498
- connectedAt?: string;
1499
- }[];
1496
+ getIdentityChangelog(identityId: string, args?: {
1497
+ limit?: number;
1498
+ cursor?: string;
1499
+ }): Promise<{
1500
+ entries: unknown[];
1501
+ cursor: string | null;
1500
1502
  }>;
1501
- /**
1502
- * Resolve the primary cTrader Connection's credentials for the calling
1503
- * agent. Unlike most providers, the cTrader Open API needs app-level auth
1504
- * (`clientId` + `clientSecret`) AND account auth (`accessToken` +
1505
- * `accountId`) on the socket, so `@alfe.ai/ctrader-mcp` self-fetches the
1506
- * full set here at startup (the atlassian/google pattern). `clientId` /
1507
- * `clientSecret` are the SST-sourced global app credentials the connect
1508
- * endpoint injects — they are never persisted on the connection. `host` is
1509
- * the resolved TLS endpoint (`live.ctraderapi.com` / `demo.ctraderapi.com`)
1510
- * derived from the selected account's live/demo flag.
1511
- */
1512
- getCTraderCredentials(): Promise<{
1513
- accessToken: string;
1514
- refreshToken: string;
1515
- accountId: string;
1516
- host: string;
1517
- clientId: string;
1518
- clientSecret: string;
1503
+ rollbackIdentity(identityId: string, args: {
1504
+ targetVersion: number;
1505
+ }): Promise<{
1506
+ ok: boolean;
1507
+ entry?: unknown;
1519
1508
  }>;
1520
- /**
1521
- * Pattern A: multi-account credential fetch for cTrader.
1522
- *
1523
- * Unlike atlassian/salesforce (one Connection row per account/site), a
1524
- * cTrader is MULTI-grant per agent: an agent may connect several distinct
1525
- * cTrader logins, each its own Connection row keyed on `accountIdentifier =
1526
- * ctid:<userId>` (Phase 1). This aggregates the *trading accounts* across
1527
- * ALL of those Connection rows each row contributes its `availableAccounts`
1528
- * flattened, and every account carries ITS OWN grant's `accessToken` (the
1529
- * token that authenticates that account against the cTrader Open API). One
1530
- * OAuth grant still covers all accounts under that single login on one shared
1531
- * token; only the `ctidTraderAccountId` and the protobuf socket `host` (live
1532
- * vs demo) differ within a grant. Across grants the tokens differ, so the
1533
- * token is now PER-ACCOUNT rather than hoisted to the top level.
1534
- *
1535
- * `host` per account is derived from the account's `isLive` flag
1536
- * (`live.ctraderapi.com` / `demo.ctraderapi.com`) — the same mapping the
1537
- * connect provider applies server-side when an account is auto-selected.
1538
- *
1539
- * `clientId` / `clientSecret` are the SST-sourced GLOBAL app credentials the
1540
- * connect endpoint injects — identical across every Connection row (one
1541
- * cTrader app), never persisted on a connection. We take them from the first
1542
- * row that carries them.
1543
- *
1544
- * Accounts are deduped on `ctidTraderAccountId` first-wins: Spotware ids are
1545
- * globally unique across logins, so a duplicate can only appear if the same
1546
- * account somehow surfaced under two grants — first-wins keeps it
1547
- * deterministic.
1548
- *
1549
- * `accounts` may be empty (no cTrader Connection at all), in which case we
1550
- * return empty creds rather than throwing.
1551
- */
1552
- getCTraderAccounts(): Promise<{
1553
- accounts: {
1554
- ctidTraderAccountId: string;
1555
- host: string;
1556
- isLive: boolean;
1557
- brokerName?: string;
1558
- accountNumber?: string;
1559
- accessToken: string;
1560
- /**
1561
- * The stable per-grant Connection key (`ctid:<userId>`) this account
1562
- * belongs to. Every trading account under one cTrader login shares one
1563
- * grant (one OAuth token), so this is the identifier the MCP server
1564
- * passes to `refreshCTraderAccount()` to rotate the token for the whole
1565
- * grant on a `CH_ACCESS_TOKEN_INVALID` expiry. Empty string when the
1566
- * server did not supply one (legacy rows) — such an account can still
1567
- * trade with its current token but cannot self-refresh.
1568
- */
1569
- accountIdentifier: string;
1509
+ requestIdentityVerification(args: {
1510
+ claimedIdentityId: string;
1511
+ requestingIdentityId: string;
1512
+ requestingProvider: string;
1513
+ requestingPlatformId: string;
1514
+ preferredChannel?: "mobile" | "email";
1515
+ /**
1516
+ * Phase 2: agent-supplied contact endpoint. When provided, the top-level
1517
+ * `preferredChannel` is ignored the contact's channel wins.
1518
+ */
1519
+ contact?: {
1520
+ channel: "email" | "mobile";
1521
+ value: string;
1522
+ };
1523
+ }): Promise<{
1524
+ verificationId: string;
1525
+ channel: string;
1526
+ deliveredTo: string;
1527
+ expiresAt: string;
1528
+ availableChannels: {
1529
+ channel: string;
1530
+ deliveredTo: string;
1570
1531
  }[];
1571
- clientId: string;
1572
- clientSecret: string;
1532
+ } | {
1533
+ error: string;
1573
1534
  }>;
1574
- /**
1575
- * Pattern A: refresh a specific cTrader grant by its stable
1576
- * `accountIdentifier` (`ctid:<userId>` from `getCTraderAccounts()`).
1577
- *
1578
- * cTrader access tokens live ~30 days; the `getCTraderAccounts()` /
1579
- * credentials reads serve the STORED token without refreshing, so refresh is
1580
- * the consumer's job. `@alfe.ai/ctrader-mcp` calls this when the cTrader Open
1581
- * API rejects an account-auth with `CH_ACCESS_TOKEN_INVALID`, then re-runs
1582
- * the socket handshake with the returned `accessToken`.
1583
- *
1584
- * Refreshing one grant rotates the single OAuth token that covers EVERY
1585
- * trading account under that login. cTrader's refresh token itself does not
1586
- * expire but may rotate on refresh (`rotatesRefreshToken: true`); connect
1587
- * persists the rotated refresh token server-side, so the caller only needs
1588
- * the new `accessToken`. Mirrors `refreshXeroAccountToken`.
1589
- */
1590
- refreshCTraderAccount(accountIdentifier: string): Promise<{
1591
- accessToken: string;
1592
- accessTokenExpiresAt: string;
1593
- expiresAt: string;
1535
+ confirmIdentityVerification(args: {
1536
+ claimedIdentityId: string;
1537
+ verificationId: string;
1538
+ phrase: string;
1539
+ }): Promise<{
1540
+ verified: boolean;
1541
+ identityId?: string;
1542
+ /** Phase 2: how the confirm resolved Scenario A vs B. */
1543
+ action?: "merged" | "contact_verified" | "already_confirmed";
1544
+ error?: string;
1594
1545
  }>;
1595
1546
  /**
1596
- * @deprecated Returns a single primary credential blob. Use
1597
- * `getShopifyAccounts()` for the multi-account shape required by Pattern A
1598
- * (`@alfe.ai/shopify-mcp` keys per-shop on the myshopify domain).
1547
+ * Update display-shape fields on an Identity. Body excludes `email` /
1548
+ * `phone` / `title` / `company` / `metadata` per Section D4 — contacts go
1549
+ * via the verify flow, title/company live on OrgMembership, metadata is
1550
+ * not agent-writable.
1599
1551
  */
1600
- getShopifyCredentials(): Promise<{
1601
- accessToken: string;
1602
- shopDomain: string;
1603
- shopGid: string;
1604
- shopName: string;
1605
- apiVersion: string;
1552
+ updateIdentity(identityId: string, args: {
1553
+ name?: string;
1554
+ avatarUrl?: string;
1555
+ timezone?: string;
1556
+ locale?: string;
1557
+ }): Promise<{
1558
+ ok: boolean;
1606
1559
  }>;
1607
1560
  /**
1608
- * Pattern A: multi-account credential fetch for Shopify. Returns every
1609
- * agent-scoped Shopify Connection. One OAuth grant maps to one store, so the
1610
- * stable per-call selector is the store's myshopify domain (`shopDomain`),
1611
- * NOT `accountIdentifier` — the connect provider keys `accountIdentifier` on
1612
- * the immutable shop GID (falling back to the domain), so `shopDomain` is the
1613
- * value the LLM passes and the plugin routes on.
1614
- *
1615
- * Each entry is shaped by the connect provider's `buildCredentialsResponse`:
1616
- * `{ accessToken, shopDomain, shopGid, shopName, apiVersion }` — offline
1617
- * Shopify tokens never expire, so there is NO token / expiry field and no
1618
- * refresh method (unlike Salesforce). The GraphQL Admin API authenticates
1619
- * purely on `X-Shopify-Access-Token`; no client credentials are on the wire.
1561
+ * Phase 2 (Section H): server-side verification of a Google Chat sender via
1562
+ * the agent's existing Google OAuth credentials. Returns the resolved
1563
+ * identity (created or matched via Scenario-B email enrichment).
1620
1564
  */
1621
- getShopifyAccounts(): Promise<{
1622
- accounts: {
1623
- connectionId: string;
1624
- accountIdentifier: string;
1625
- displayName: string | null;
1626
- connectedAt: string;
1627
- accessToken: string;
1628
- shopDomain: string;
1629
- shopGid: string;
1630
- shopName: string;
1631
- apiVersion: string;
1632
- }[];
1565
+ resolveGoogleChatSender(args: {
1566
+ senderUserId: string;
1567
+ spaceId?: string;
1568
+ }): Promise<{
1569
+ identityId: string | null;
1570
+ status: string;
1633
1571
  }>;
1634
- /**
1635
- * Pattern A: provider-parameterized multi-account credential fetch for the
1636
- * social connectors (Bluesky, and the approval-gated backlog: X, Meta,
1637
- * Threads, LinkedIn, Pinterest, TikTok, Reddit, YouTube).
1638
- *
1639
- * Unlike the bespoke `getGithubAccounts()` / `getXeroAccounts()` shapes,
1640
- * this returns a UNIFORM normalized account shape so `@alfe.ai/social-mcp`'s
1641
- * shared driver can require a single `account` selector on every
1642
- * credential-touching tool regardless of platform. The backend
1643
- * `api-agents/{provider}/accounts` route is already provider-generic; this
1644
- * is the client-side normalization the plan (`do-we-need-any-moonlit-toucan`
1645
- * Phase 0, step 5) calls for.
1646
- *
1647
- * `accountIdentifier` is the stable per-account selector the LLM should
1648
- * pass back (for Bluesky: the account DID). `accessToken` carries whatever
1649
- * the provider's `buildCredentialsResponse` bundles (for Bluesky: the JSON
1650
- * session bundle — the driver parses the `accessJwt` out of it, or reads the
1651
- * top-level `accessJwt` from `providerMetadata`-adjacent fields). Everything
1652
- * else the driver needs for routing (handle, pdsHost, did, …) is on
1653
- * `providerMetadata`.
1654
- *
1655
- * Token refresh is delegated to connect (never done in-plugin) via the
1656
- * per-account route `POST /agent/connect/{provider}/accounts/{accountIdentifier}/refresh`
1657
- * — call `refreshSocialAccount(provider, accountIdentifier)`. (The non-account
1658
- * `POST /agent/connect/{provider}/refresh` route refreshes the provider's
1659
- * PRIMARY connection, which is wrong under multi-account Pattern A.)
1660
- */
1661
- getSocialAccounts(provider: string): Promise<{
1662
- provider: string;
1663
- accounts: {
1664
- connectionId: string;
1665
- accountIdentifier: string;
1666
- displayName: string | null;
1667
- accessToken: string;
1668
- providerMetadata: Record<string, unknown>;
1669
- connectedAt: string;
1572
+ }
1573
+ //# sourceMappingURL=identity.d.ts.map
1574
+ //#endregion
1575
+ //#region src/domains/search.d.ts
1576
+ /**
1577
+ * The broad-news providers behind the metered `services/news` Lambda. The
1578
+ * server validates this with a zod enum; a value outside the union is an
1579
+ * unpriceable product, so keep the literal union in lockstep with the service.
1580
+ */
1581
+ type NewsProvider = "apitube" | "newsdata";
1582
+ /** One normalized article. `sentiment` is provider-shaped (APITube supplies it). */
1583
+ interface NewsArticle {
1584
+ title: string;
1585
+ url: string;
1586
+ source: string;
1587
+ publishedAt: string;
1588
+ snippet: string;
1589
+ sentiment?: unknown;
1590
+ }
1591
+ /** Provider-agnostic result — the server normalizes every adapter to this. */
1592
+ interface NewsResult {
1593
+ articles: NewsArticle[];
1594
+ provider: string;
1595
+ }
1596
+ declare class SearchApi extends ApiBase {
1597
+ searchWeb(params: {
1598
+ query: string;
1599
+ count?: number;
1600
+ offset?: number;
1601
+ country?: string;
1602
+ freshness?: string;
1603
+ }, options?: {
1604
+ signal?: AbortSignal;
1605
+ }): Promise<unknown>;
1606
+ searchImages(params: {
1607
+ query: string;
1608
+ count?: number;
1609
+ }, options?: {
1610
+ signal?: AbortSignal;
1611
+ }): Promise<unknown>;
1612
+ searchNews(params: {
1613
+ query: string;
1614
+ count?: number;
1615
+ offset?: number;
1616
+ freshness?: string;
1617
+ }, options?: {
1618
+ signal?: AbortSignal;
1619
+ }): Promise<unknown>;
1620
+ /** Search news across the selected provider's corpus. → POST /agent/news/search */
1621
+ newsSearch(params: {
1622
+ query: string;
1623
+ provider?: NewsProvider;
1624
+ source?: string;
1625
+ from?: string;
1626
+ to?: string;
1627
+ language?: string;
1628
+ category?: string;
1629
+ limit?: number;
1630
+ }): Promise<NewsResult>;
1631
+ /** Top headlines for the selected provider. → POST /agent/news/headlines */
1632
+ newsHeadlines(params?: {
1633
+ provider?: NewsProvider;
1634
+ category?: string;
1635
+ source?: string;
1636
+ language?: string;
1637
+ limit?: number;
1638
+ }): Promise<NewsResult>;
1639
+ }
1640
+ //# sourceMappingURL=search.d.ts.map
1641
+ //#endregion
1642
+ //#region src/domains/webhooks.d.ts
1643
+ interface AgentWebhook {
1644
+ webhookId: string;
1645
+ tenantId: string;
1646
+ agentId: string;
1647
+ name: string;
1648
+ provider: string;
1649
+ active: boolean;
1650
+ createdBy: string;
1651
+ createdAt: string;
1652
+ updatedAt: string;
1653
+ }
1654
+ interface CreatedAgentWebhook extends AgentWebhook {
1655
+ url: string;
1656
+ signingSecret: string;
1657
+ }
1658
+ interface AgentWebhookDelivery {
1659
+ deliveryId: string;
1660
+ webhookId: string;
1661
+ status: string;
1662
+ attempts: number;
1663
+ createdAt: string;
1664
+ deliveredAt?: string;
1665
+ }
1666
+ declare class WebhooksApi extends ApiBase {
1667
+ createWebhook(args: {
1668
+ name: string;
1669
+ provider?: "generic" | "github" | "stripe" | "slack";
1670
+ }): Promise<CreatedAgentWebhook>;
1671
+ listWebhooks(): Promise<AgentWebhook[]>;
1672
+ deleteWebhook(webhookId: string): Promise<{
1673
+ webhookId: string;
1674
+ active: false;
1675
+ }>;
1676
+ rotateWebhookSecret(webhookId: string): Promise<{
1677
+ webhookId: string;
1678
+ signingSecret: string;
1679
+ }>;
1680
+ listWebhookDeliveries(webhookId: string): Promise<AgentWebhookDelivery[]>;
1681
+ }
1682
+ //# sourceMappingURL=webhooks.d.ts.map
1683
+ //#endregion
1684
+ //#region src/domains/chat.d.ts
1685
+ declare class ChatApi extends ApiBase {
1686
+ ensureDirectConversation(identityId: string): Promise<{
1687
+ conversationId: string;
1688
+ identityId: string;
1689
+ tenantId: string;
1690
+ userId: string;
1691
+ displayName: string;
1692
+ created: boolean;
1693
+ }>;
1694
+ presignAttachments(files: {
1695
+ filename: string;
1696
+ mimeType: string;
1697
+ size: number;
1698
+ }[]): Promise<{
1699
+ attachments: {
1700
+ id: string;
1701
+ uploadUrl: string;
1702
+ uploadHeaders: Record<string, string>;
1703
+ downloadUrl: string;
1704
+ s3Key: string;
1705
+ expiresAt: string;
1670
1706
  }[];
1671
1707
  }>;
1672
- /**
1673
- * Pattern A: refresh a specific social Connection by its stable
1674
- * `accountIdentifier` (for Bluesky: the account DID) via the
1675
- * provider-generic per-account refresh route. The counterpart to
1676
- * `getSocialAccounts(provider)`; `@alfe.ai/social-mcp` calls this on a
1677
- * 401/ExpiredToken from the platform PDS/API, then re-fetches accounts to
1678
- * pick up the rotated bundle.
1679
- *
1680
- * Refresh itself is ALWAYS delegated to connect — the plugin never calls
1681
- * the platform's own refresh XRPC (e.g. `com.atproto.server.refreshSession`)
1682
- * because connect owns the encrypted refresh token + rotation persistence
1683
- * (Bluesky rotates the refreshJwt; a missed rotation kills the connection
1684
- * after one refresh). The returned `accessToken` is whatever the provider's
1685
- * `refreshToken` hook re-bundled (for Bluesky: the JSON session bundle with
1686
- * the fresh `accessJwt`) — callers typically ignore it and re-fetch via
1687
- * `getSocialAccounts` for a consistent shape.
1688
- */
1689
- refreshSocialAccount(provider: string, accountIdentifier: string): Promise<{
1690
- accountIdentifier: string;
1691
- accessToken: string;
1692
- accessTokenExpiresAt: string;
1693
- expiresAt: string;
1708
+ recordActivity(data: {
1709
+ userId?: string;
1710
+ channel: string;
1711
+ role: "user" | "assistant";
1712
+ }): Promise<{
1713
+ recorded: boolean;
1694
1714
  }>;
1695
1715
  }
1696
- //# sourceMappingURL=connect-credentials.d.ts.map
1716
+ //# sourceMappingURL=chat.d.ts.map
1697
1717
  //#endregion
1698
1718
  //#region src/domains/database.d.ts
1699
1719
  declare class DatabaseApi extends ApiBase {
@@ -2039,5 +2059,5 @@ declare class AgentApiClient extends ApiBase {
2039
2059
  //# sourceMappingURL=index.d.ts.map
2040
2060
 
2041
2061
  //#endregion
2042
- export { AgentApiClient, type AgentApiClientConfig, type AgentAvatarPresign, type AgentIntegrationListEntry, type AgentSelf, type AgentVoice, type AgentVoiceConfig, type AgentWebhook, type AgentWebhookDelivery, type AgentWorkspaceInfo, type ChangeRequestActorKind, type ChangeRequestOperation, type ChangeRequestResourceType, type ChangeRequestStatus, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type CreatedAgentWebhook, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type IdentityDirectoryEntry, type IdentityStatus, type InstallToolErrorCaptureOptions, type IntegrationActivationSource, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, type KnowledgeChangeRequest, type KnowledgeDoc, type KnowledgeProfile, type KnowledgeProfileLink, type KnowledgeScope, type KnowledgeScopeType, type KnowledgeSearchHit, type KnowledgeSearchResult, type MobileAvailableNumber, type MobileNumberInfo, type NewsArticle, type NewsProvider, type NewsResult, type ProposeScopeChangeInput, type RegistryEntry, type RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, type SharedFileEntry, type SyncAgentInfo, type SyncAgentStats, type SyncConfirmedUpload, type SyncFileEntry, type SyncManifest, type SyncManifestEntry, type SyncPresignedUrl, type SyncReconstructBundle, type SyncReconstructFile, type SyncSessionContent, type SyncSessionEntry, type ToolCaptureApi, type VoiceSttArgs, type VoiceSttResult, type VoiceTtsArgs, type VoiceTtsModel, type VoiceTtsResult, type WhatsAppTemplate, installToolErrorCapture };
2062
+ export { AgentApiClient, type AgentApiClientConfig, type AgentAvatarPresign, type AgentIntegrationListEntry, type AgentSelf, type AgentVoice, type AgentVoiceConfig, type AgentWebhook, type AgentWebhookDelivery, type AgentWorkspaceInfo, type ChangeRequestActorKind, type ChangeRequestOperation, type ChangeRequestResourceType, type ChangeRequestStatus, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type ConnectProviderAccount, type ConnectProviderAccounts, type CreatedAgentWebhook, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type IdentityDirectoryEntry, type IdentityStatus, type InstallToolErrorCaptureOptions, type IntegrationActivationSource, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, type KnowledgeChangeRequest, type KnowledgeDoc, type KnowledgeProfile, type KnowledgeProfileLink, type KnowledgeScope, type KnowledgeScopeType, type KnowledgeSearchHit, type KnowledgeSearchResult, type MobileAvailableNumber, type MobileNumberInfo, type NewsArticle, type NewsProvider, type NewsResult, type ProposeScopeChangeInput, type RegistryEntry, type RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, type SharedFileEntry, type SyncAgentInfo, type SyncAgentStats, type SyncConfirmedUpload, type SyncFileEntry, type SyncManifest, type SyncManifestEntry, type SyncPresignedUrl, type SyncReconstructBundle, type SyncReconstructFile, type SyncSessionContent, type SyncSessionEntry, type ToolCaptureApi, type VoiceSttArgs, type VoiceSttResult, type VoiceTtsArgs, type VoiceTtsModel, type VoiceTtsResult, type WhatsAppTemplate, installToolErrorCapture };
2043
2063
  //# sourceMappingURL=index.d.ts.map