@alfe.ai/mcp-server 0.2.11 → 0.2.12

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