@alfe.ai/agent-api-client 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -54,40 +54,117 @@ interface InstallToolErrorCaptureOptions {
54
54
  declare function installToolErrorCapture(api: ToolCaptureApi, options: InstallToolErrorCaptureOptions): void;
55
55
  //# sourceMappingURL=tool-error-capture.d.ts.map
56
56
  //#endregion
57
- //#region src/index.d.ts
57
+ //#region src/transport.d.ts
58
+ /**
59
+ * Shared HTTP transport for the Agent API client — request core, retry
60
+ * policy, error formatting, and the `ApiBase` class the domain method
61
+ * groups under `./domains/` build on.
62
+ */
58
63
  interface AgentApiClientConfig {
59
64
  apiKey: string;
60
65
  apiUrl: string;
61
66
  }
62
67
  /**
63
- * The broad-news providers behind the metered `services/news` Lambda. The
64
- * server validates this with a zod enum; a value outside the union is an
65
- * unpriceable product, so keep the literal union in lockstep with the service.
68
+ * Encode each path segment but keep the `/` separators — `encodeURIComponent`
69
+ * would escape the slashes too, breaking greedy proxy routes.
66
70
  */
67
- type NewsProvider = "apitube" | "newsdata";
68
- /** One normalized article. `sentiment` is provider-shaped (APITube supplies it). */
69
- interface NewsArticle {
70
- title: string;
71
- url: string;
72
- source: string;
73
- publishedAt: string;
74
- snippet: string;
75
- sentiment?: unknown;
71
+
72
+ declare class AgentApiTransport {
73
+ private readonly apiKey;
74
+ private readonly apiUrl;
75
+ constructor(config: AgentApiClientConfig);
76
+ /**
77
+ * Binary sibling of `request<T>()`. `request()` forces
78
+ * `Content-Type: application/json` and parses a `{ data: T }` envelope,
79
+ * neither of which fits a raw-audio flow (voice TTS/STT), so those go
80
+ * through this instead. Auth (Bearer), the request budget, and the single
81
+ * retry policy on transient 5xx / network errors is kept in sync with
82
+ * `request()`. Safe read methods retry once by default; mutation methods do
83
+ * not, because a response can be lost after a handler or provider call has
84
+ * already succeeded.
85
+ */
86
+ rawRequest(path: string, init: {
87
+ method: string;
88
+ headers: Headers;
89
+ body?: BodyInit | Uint8Array;
90
+ }, extra?: {
91
+ retry?: boolean;
92
+ }): Promise<Response>;
93
+ /**
94
+ * @param extra.timeoutMs Per-request abort timeout (default REQUEST_TIMEOUT_MS).
95
+ * Long endpoints (image generation) pass a larger value so the gateway's
96
+ * own timeout wins with a readable status instead of a client-side abort.
97
+ * @param extra.retry Whether to retry once on transient failures. Safe reads
98
+ * (GET/HEAD/OPTIONS) default to true; mutations default to false. Set true
99
+ * only when the endpoint's server-side contract is explicitly idempotent.
100
+ * @param extra.signal Optional caller cancellation combined with the client's
101
+ * own timeout budget. Aborting either signal cancels the request.
102
+ */
103
+ request<T>(path: string, options?: RequestInit, extra?: {
104
+ timeoutMs?: number;
105
+ retry?: boolean;
106
+ signal?: AbortSignal;
107
+ }): Promise<T>;
76
108
  }
77
- /** Provider-agnostic result — the server normalizes every adapter to this. */
78
- interface NewsResult {
79
- articles: NewsArticle[];
80
- provider: string;
109
+ /**
110
+ * Base class for the domain method groups. Holds the shared transport;
111
+ * `AgentApiClient` assembles the groups onto one class via `applyMixins`
112
+ * (prototype copy), so methods keep their original `this`-on-the-client
113
+ * call shape.
114
+ */
115
+ declare class ApiBase {
116
+ protected readonly transport: AgentApiTransport;
117
+ constructor(transport: AgentApiTransport);
81
118
  }
82
- interface RemoteSessionInfo {
83
- sessionId: string;
84
- agentId: string;
85
- surface: "browser" | "terminal";
86
- status: "agent_driving" | "awaiting_human" | "human_in_control" | "resuming" | "completed" | "expired" | "failed";
87
- url?: string;
88
- instructions?: string;
89
- requestedAt?: string;
119
+ //# sourceMappingURL=transport.d.ts.map
120
+ //#endregion
121
+ //#region src/domains/workspace.d.ts
122
+ /** Response of GET /agent/workspace (services/agents). */
123
+ interface AgentWorkspaceInfo {
124
+ templateKey?: string;
125
+ defaultModel?: string;
126
+ installedFrom?: {
127
+ templateKey: string;
128
+ authorTenantId: string;
129
+ version: number;
130
+ };
131
+ runtime?: string;
132
+ teams?: {
133
+ teamId: string;
134
+ name: string;
135
+ description?: string;
136
+ parentTeamId?: string;
137
+ }[];
138
+ projects?: {
139
+ projectId: string;
140
+ name: string;
141
+ description?: string;
142
+ status: string;
143
+ parentProjectId?: string;
144
+ }[];
145
+ teamIds?: string[];
146
+ projectIds?: string[];
147
+ }
148
+ declare class WorkspaceApi extends ApiBase {
149
+ /**
150
+ * GET /agent/workspace — workspace config for the authenticated agent
151
+ * (template assignment, default model, org roster).
152
+ */
153
+ getWorkspace(): Promise<AgentWorkspaceInfo>;
154
+ /**
155
+ * GET /templates/{key}/files — persona/workspace file contents for a
156
+ * template the agent has access to. Pass `version` to pin to the version
157
+ * the agent was installed from (omit → the endpoint resolves `latest`).
158
+ */
159
+ getTemplateFiles(templateKey: string, opts?: {
160
+ version?: number;
161
+ }): Promise<{
162
+ files: Record<string, string>;
163
+ }>;
90
164
  }
165
+ //# sourceMappingURL=workspace.d.ts.map
166
+ //#endregion
167
+ //#region src/domains/sync.d.ts
91
168
  interface SyncAgentInfo {
92
169
  agentId: string;
93
170
  tenantId: string;
@@ -172,6 +249,65 @@ interface SharedFileEntry {
172
249
  size: number;
173
250
  contentType?: string;
174
251
  }
252
+ declare class SyncApi extends ApiBase {
253
+ syncRegister(args?: {
254
+ displayName?: string;
255
+ }): Promise<{
256
+ agent: SyncAgentInfo;
257
+ }>;
258
+ syncGetManifest(): Promise<SyncManifest>;
259
+ syncPresign(args: {
260
+ files: {
261
+ path: string;
262
+ operation: "put" | "get";
263
+ contentType?: string;
264
+ }[];
265
+ }): Promise<{
266
+ urls: SyncPresignedUrl[];
267
+ }>;
268
+ syncConfirmUpload(args: {
269
+ filePath: string;
270
+ hash: string;
271
+ size: number;
272
+ storageClass?: "STANDARD" | "GLACIER_IR";
273
+ }): Promise<SyncConfirmedUpload>;
274
+ syncReconstruct(args: {
275
+ mode: "full" | "active" | "memory";
276
+ }): Promise<SyncReconstructBundle>;
277
+ syncGetStats(): Promise<SyncAgentStats>;
278
+ syncListFiles(args?: {
279
+ prefix?: string;
280
+ }): Promise<{
281
+ files: SyncFileEntry[];
282
+ }>;
283
+ syncListSessions(): Promise<{
284
+ sessions: SyncSessionEntry[];
285
+ }>;
286
+ syncGetSession(sessionId: string): Promise<SyncSessionContent>;
287
+ syncDeleteFile(filePath: string): Promise<{
288
+ removed: boolean;
289
+ }>;
290
+ sharedListFiles(args: {
291
+ scope: "org" | "team" | "project";
292
+ scopeId: string;
293
+ limit?: number;
294
+ cursor?: string;
295
+ }): Promise<{
296
+ files: SharedFileEntry[];
297
+ nextCursor: string | null;
298
+ }>;
299
+ sharedDownloadUrl(args: {
300
+ scope: "org" | "team" | "project";
301
+ scopeId: string;
302
+ filePath: string;
303
+ }): Promise<{
304
+ downloadUrl: string;
305
+ expiresIn: number;
306
+ }>;
307
+ }
308
+ //# sourceMappingURL=sync.d.ts.map
309
+ //#endregion
310
+ //#region src/domains/knowledge.d.ts
175
311
  type KnowledgeScopeType = "org" | "team" | "project";
176
312
  interface KnowledgeScope {
177
313
  scopeType: KnowledgeScopeType;
@@ -214,15 +350,6 @@ interface KnowledgeProfile {
214
350
  updatedAt: string | null;
215
351
  updatedBy: string | null;
216
352
  }
217
- interface KnowledgeDoc {
218
- filePath: string;
219
- fileName: string;
220
- contentType?: string;
221
- size: number;
222
- uploadedBy?: string;
223
- createdAt: string;
224
- updatedAt: string;
225
- }
226
353
  type ChangeRequestResourceType = "doc" | "profile";
227
354
  type ChangeRequestOperation = "create" | "update" | "delete";
228
355
  type ChangeRequestStatus = "open" | "approved" | "rejected" | "withdrawn" | "superseded";
@@ -264,6 +391,200 @@ interface ProposeScopeChangeInput {
264
391
  /** profile: the proposed value ({ about, description, links }). */
265
392
  proposedValue?: unknown;
266
393
  }
394
+ interface KnowledgeDoc {
395
+ filePath: string;
396
+ fileName: string;
397
+ contentType?: string;
398
+ size: number;
399
+ uploadedBy?: string;
400
+ createdAt: string;
401
+ updatedAt: string;
402
+ }
403
+ declare class KnowledgeApi extends ApiBase {
404
+ /**
405
+ * Semantic search across the agent's member scopes. Fan-out is gated
406
+ * server-side by `listScopes` set-inclusion (fail-closed). Pass
407
+ * `scopeType` + `scopeId` to narrow to one scope; a non-member scope
408
+ * yields empty results (never a cross-scope leak).
409
+ */
410
+ knowledgeSearch(query: string, opts?: {
411
+ limit?: number;
412
+ scopeType?: KnowledgeScopeType;
413
+ scopeId?: string;
414
+ }): Promise<KnowledgeSearchResult>;
415
+ /** Enumerate the scopes (org + teams + projects) this agent belongs to. */
416
+ listScopes(): Promise<{
417
+ scopes: KnowledgeScope[];
418
+ }>;
419
+ /** Read a scope's structured knowledge profile (after membership check). */
420
+ getScopeProfile(scopeType: KnowledgeScopeType, scopeId: string): Promise<KnowledgeProfile>;
421
+ /**
422
+ * Open a change request against a scope's knowledge resource. For a doc
423
+ * create/update, `services/org` returns a presigned staging PUT; this method
424
+ * uploads the proposed `content` to it (echoing the same Content-Type that
425
+ * was signed), mirroring `writeScopeDoc`. The staged body is applied to the
426
+ * canonical doc — attributed to this agent — only when a reviewer approves.
427
+ */
428
+ proposeScopeChange(scopeType: KnowledgeScopeType, scopeId: string, input: ProposeScopeChangeInput): Promise<KnowledgeChangeRequest>;
429
+ /**
430
+ * List the agent's OWN change requests in a scope (filtered server-side to
431
+ * this agent as proposer). Pass `status` to narrow to open / approved / etc.
432
+ */
433
+ listScopeChangeRequests(scopeType: KnowledgeScopeType, scopeId: string, opts?: {
434
+ status?: ChangeRequestStatus;
435
+ limit?: number;
436
+ cursor?: string;
437
+ }): Promise<{
438
+ changeRequests: KnowledgeChangeRequest[];
439
+ nextCursor: string | null;
440
+ }>;
441
+ /** List a scope's docs (the org-files corpus; mirrored to shared/<scope>/). */
442
+ listScopeDocs(scopeType: KnowledgeScopeType, scopeId: string, opts?: {
443
+ limit?: number;
444
+ cursor?: string;
445
+ }): Promise<{
446
+ files: KnowledgeDoc[];
447
+ nextCursor: string | null;
448
+ }>;
449
+ /**
450
+ * Read the full text of a scope doc. Resolves a presigned download URL
451
+ * from `services/org`, then fetches the bytes directly from S3 (the one
452
+ * legitimate raw fetch in a plugin — same pattern as sync).
453
+ */
454
+ readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, opts?: {
455
+ maxBytes?: number;
456
+ }): Promise<{
457
+ filePath: string;
458
+ text: string;
459
+ }>;
460
+ /**
461
+ * Write (create or overwrite) a scope doc. Two-step presigned upload:
462
+ * `services/org` returns a signed URL plus `requiredHeaders` (author /
463
+ * authorKind / message as `x-amz-meta-*`) that MUST be sent verbatim on
464
+ * the PUT, alongside the same `Content-Type` that was signed. Author and
465
+ * authorKind are server-set from the agent token — never trusted here.
466
+ */
467
+ writeScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, content: string, opts?: {
468
+ contentType?: string;
469
+ message?: string;
470
+ }): Promise<{
471
+ filePath: string;
472
+ }>;
473
+ }
474
+ //# sourceMappingURL=knowledge.d.ts.map
475
+ //#endregion
476
+ //#region src/domains/mobile.d.ts
477
+ /** Response of GET /mobile/numbers for an agent (services/mobile). */
478
+ interface MobileNumberInfo {
479
+ phoneNumber: string;
480
+ countryCode: string;
481
+ monthlyPrice?: number;
482
+ status: string;
483
+ errorMessage?: string;
484
+ }
485
+ /** One purchasable number from GET /mobile/numbers/search. */
486
+ interface MobileAvailableNumber {
487
+ number: string;
488
+ friendlyName: string;
489
+ locality: string;
490
+ region: string;
491
+ country: string;
492
+ }
493
+ /** Approved WhatsApp content template from GET /mobile/whatsapp/templates. */
494
+ interface WhatsAppTemplate {
495
+ contentSid: string;
496
+ name: string;
497
+ language: string;
498
+ body: string;
499
+ variables: Record<string, string>;
500
+ category?: string;
501
+ }
502
+ declare class MobileApi extends ApiBase {
503
+ getMobileNumber(): Promise<MobileNumberInfo>;
504
+ searchMobileNumbers(args?: {
505
+ country?: string;
506
+ query?: string;
507
+ }): Promise<{
508
+ numbers: MobileAvailableNumber[];
509
+ monthlyPrice: number;
510
+ }>;
511
+ assignMobileNumber(args: {
512
+ phoneNumber: string;
513
+ countryCode: string;
514
+ }): Promise<{
515
+ phoneNumber: string;
516
+ countryCode: string;
517
+ status: "pending";
518
+ }>;
519
+ releaseMobileNumber(): Promise<{
520
+ released: true;
521
+ }>;
522
+ sendSms(args: {
523
+ to: string;
524
+ body: string;
525
+ }): Promise<{
526
+ sent: true;
527
+ sid: string;
528
+ }>;
529
+ startOutboundCall(args: {
530
+ to: string;
531
+ }): Promise<{
532
+ callSid: string;
533
+ status: string;
534
+ }>;
535
+ getWhatsAppSession(to: string): Promise<{
536
+ active: boolean;
537
+ expiresAt?: string;
538
+ }>;
539
+ sendWhatsAppMessage(args: {
540
+ to: string;
541
+ body: string;
542
+ }): Promise<{
543
+ sent: true;
544
+ sid: string;
545
+ }>;
546
+ sendWhatsAppTemplate(args: {
547
+ to: string;
548
+ contentSid: string;
549
+ contentVariables: Record<string, string>;
550
+ bodyPreview?: string;
551
+ }): Promise<{
552
+ sent: true;
553
+ sid: string;
554
+ }>;
555
+ listWhatsAppTemplates(): Promise<{
556
+ templates: WhatsAppTemplate[];
557
+ }>;
558
+ }
559
+ //# sourceMappingURL=mobile.d.ts.map
560
+ //#endregion
561
+ //#region src/domains/remote.d.ts
562
+ interface RemoteSessionInfo {
563
+ sessionId: string;
564
+ agentId: string;
565
+ surface: "browser" | "terminal";
566
+ status: "agent_driving" | "awaiting_human" | "human_in_control" | "resuming" | "completed" | "expired" | "failed";
567
+ url?: string;
568
+ instructions?: string;
569
+ requestedAt?: string;
570
+ }
571
+ declare class RemoteApi extends ApiBase {
572
+ requestBrowserTakeover(args: {
573
+ instructions: string;
574
+ url?: string;
575
+ conversationId?: string;
576
+ }): Promise<{
577
+ sessionId: string;
578
+ status: string;
579
+ }>;
580
+ getRemoteSession(sessionId: string): Promise<RemoteSessionInfo>;
581
+ completeRemoteSession(sessionId: string): Promise<{
582
+ ok: boolean;
583
+ }>;
584
+ }
585
+ //# sourceMappingURL=remote.d.ts.map
586
+ //#endregion
587
+ //#region src/domains/self.d.ts
267
588
  /** Voice settings — core agent config. Mirrors `VoiceConfig` in `@alfe/types`. */
268
589
  interface AgentVoiceConfig {
269
590
  /** ElevenLabs voice ID; platform default when unset. */
@@ -305,13 +626,52 @@ interface AgentVoice {
305
626
  labels: Record<string, string>;
306
627
  category: string;
307
628
  }
308
- /** The ElevenLabs models with a pricing row — the TTS endpoint rejects any other value. */
309
- type VoiceTtsModel = "eleven_turbo_v2_5" | "eleven_multilingual_v2";
310
- interface VoiceTtsArgs {
311
- /** Text to synthesize (1–5000 chars — the endpoint enforces this). */
312
- text: string;
313
- /** ElevenLabs voice id; platform default when unset. */
314
- voiceId?: string;
629
+ declare class SelfApi extends ApiBase {
630
+ /** Update the agent's own name and/or voice config. Returns the updated agent. */
631
+ updateSelf(update: {
632
+ name?: string;
633
+ voiceConfig?: AgentVoiceConfig;
634
+ }): Promise<AgentSelf>;
635
+ /**
636
+ * Generate the agent's own avatar from a text prompt. The image is generated,
637
+ * stored, and set on the agent server-side; returns the updated agent.
638
+ *
639
+ * ASYNC (same reason as `generateImage`): avatar gen runs `gpt-image-1`
640
+ * (30–60s) which exceeds the API Gateway 30s ceiling, so this enqueues a job
641
+ * (`POST /agent/avatar/generate` → `jobId`) then polls (`GET /agent/avatar/{jobId}`)
642
+ * until the avatar is set. Signature unchanged — the plugin is unaffected.
643
+ */
644
+ generateAvatar(args: {
645
+ prompt: string;
646
+ }): Promise<AgentSelf>;
647
+ /**
648
+ * Get a presigned PUT URL to upload a new avatar image. Upload the bytes to
649
+ * `uploadUrl`, then call `finalizeAvatar(s3Key)` to set it on the agent.
650
+ */
651
+ presignAvatar(args: {
652
+ mimeType: string;
653
+ size: number;
654
+ }): Promise<AgentAvatarPresign>;
655
+ /**
656
+ * Finalize an avatar upload — validates ownership + size, then sets the
657
+ * agent's `avatarUrl` server-side. Returns the updated agent.
658
+ */
659
+ finalizeAvatar(s3Key: string): Promise<AgentSelf>;
660
+ /** List the platform voice catalogue (ElevenLabs) so the agent can pick its own voice. */
661
+ listVoices(): Promise<{
662
+ voices: AgentVoice[];
663
+ }>;
664
+ }
665
+ //# sourceMappingURL=self.d.ts.map
666
+ //#endregion
667
+ //#region src/domains/voice.d.ts
668
+ /** The ElevenLabs models with a pricing row — the TTS endpoint rejects any other value. */
669
+ type VoiceTtsModel = "eleven_turbo_v2_5" | "eleven_multilingual_v2";
670
+ interface VoiceTtsArgs {
671
+ /** Text to synthesize (1–5000 chars — the endpoint enforces this). */
672
+ text: string;
673
+ /** ElevenLabs voice id; platform default when unset. */
674
+ voiceId?: string;
315
675
  /** TTS model; `eleven_turbo_v2_5` (lower latency) when unset. */
316
676
  model?: VoiceTtsModel;
317
677
  }
@@ -337,84 +697,161 @@ interface VoiceSttResult {
337
697
  /** Deepgram confidence in (0,1]. */
338
698
  confidence: number;
339
699
  }
340
- declare class AgentApiClient {
341
- private readonly apiKey;
342
- private readonly apiUrl;
343
- constructor(config: AgentApiClientConfig);
344
- private request;
345
- syncRegister(args?: {
346
- displayName?: string;
347
- }): Promise<{
348
- agent: SyncAgentInfo;
349
- }>;
350
- syncGetManifest(): Promise<SyncManifest>;
351
- syncPresign(args: {
352
- files: {
353
- path: string;
354
- operation: "put" | "get";
355
- contentType?: string;
356
- }[];
357
- }): Promise<{
358
- urls: SyncPresignedUrl[];
359
- }>;
360
- syncConfirmUpload(args: {
361
- filePath: string;
362
- hash: string;
700
+ declare class VoiceApi extends ApiBase {
701
+ /**
702
+ * Text-to-speech. Returns raw PCM audio bytes plus their framing — the
703
+ * voice service defaults to 24 kHz / mono / 16-bit. Wrap in a WAV container
704
+ * to produce a playable file. Metered per character against the tenant
705
+ * credit pool server-side; TTS completes regardless of metering outcome.
706
+ */
707
+ tts(args: VoiceTtsArgs): Promise<VoiceTtsResult>;
708
+ /**
709
+ * Speech-to-text. Accepts raw linear16 (16-bit LE) mono PCM — NOT a WAV or
710
+ * other container (the endpoint transcribes with a fixed linear16 encoding,
711
+ * so a container header would be transcribed as noise). Strip any WAV header
712
+ * and pass `sampleRate` from it before calling. Metered by transcribed
713
+ * duration against the tenant credit pool server-side.
714
+ */
715
+ stt(args: VoiceSttArgs): Promise<VoiceSttResult>;
716
+ }
717
+ //# sourceMappingURL=voice.d.ts.map
718
+ //#endregion
719
+ //#region src/domains/search.d.ts
720
+ /**
721
+ * The broad-news providers behind the metered `services/news` Lambda. The
722
+ * server validates this with a zod enum; a value outside the union is an
723
+ * unpriceable product, so keep the literal union in lockstep with the service.
724
+ */
725
+ type NewsProvider = "apitube" | "newsdata";
726
+ /** One normalized article. `sentiment` is provider-shaped (APITube supplies it). */
727
+ interface NewsArticle {
728
+ title: string;
729
+ url: string;
730
+ source: string;
731
+ publishedAt: string;
732
+ snippet: string;
733
+ sentiment?: unknown;
734
+ }
735
+ /** Provider-agnostic result — the server normalizes every adapter to this. */
736
+ interface NewsResult {
737
+ articles: NewsArticle[];
738
+ provider: string;
739
+ }
740
+ declare class SearchApi extends ApiBase {
741
+ searchWeb(params: {
742
+ query: string;
743
+ count?: number;
744
+ offset?: number;
745
+ country?: string;
746
+ freshness?: string;
747
+ }, options?: {
748
+ signal?: AbortSignal;
749
+ }): Promise<unknown>;
750
+ searchImages(params: {
751
+ query: string;
752
+ count?: number;
753
+ }, options?: {
754
+ signal?: AbortSignal;
755
+ }): Promise<unknown>;
756
+ searchNews(params: {
757
+ query: string;
758
+ count?: number;
759
+ offset?: number;
760
+ freshness?: string;
761
+ }, options?: {
762
+ signal?: AbortSignal;
763
+ }): Promise<unknown>;
764
+ /** Search news across the selected provider's corpus. → POST /agent/news/search */
765
+ newsSearch(params: {
766
+ query: string;
767
+ provider?: NewsProvider;
768
+ source?: string;
769
+ from?: string;
770
+ to?: string;
771
+ language?: string;
772
+ category?: string;
773
+ limit?: number;
774
+ }): Promise<NewsResult>;
775
+ /** Top headlines for the selected provider. → POST /agent/news/headlines */
776
+ newsHeadlines(params?: {
777
+ provider?: NewsProvider;
778
+ category?: string;
779
+ source?: string;
780
+ language?: string;
781
+ limit?: number;
782
+ }): Promise<NewsResult>;
783
+ }
784
+ //# sourceMappingURL=search.d.ts.map
785
+ //#endregion
786
+ //#region src/domains/webhooks.d.ts
787
+ interface AgentWebhook {
788
+ webhookId: string;
789
+ tenantId: string;
790
+ agentId: string;
791
+ name: string;
792
+ provider: string;
793
+ active: boolean;
794
+ createdBy: string;
795
+ createdAt: string;
796
+ updatedAt: string;
797
+ }
798
+ interface CreatedAgentWebhook extends AgentWebhook {
799
+ url: string;
800
+ signingSecret: string;
801
+ }
802
+ interface AgentWebhookDelivery {
803
+ deliveryId: string;
804
+ webhookId: string;
805
+ status: string;
806
+ attempts: number;
807
+ createdAt: string;
808
+ deliveredAt?: string;
809
+ }
810
+ declare class WebhooksApi extends ApiBase {
811
+ createWebhook(args: {
812
+ name: string;
813
+ provider?: "generic" | "github" | "stripe" | "slack";
814
+ }): Promise<CreatedAgentWebhook>;
815
+ listWebhooks(): Promise<AgentWebhook[]>;
816
+ deleteWebhook(webhookId: string): Promise<{
817
+ webhookId: string;
818
+ active: false;
819
+ }>;
820
+ rotateWebhookSecret(webhookId: string): Promise<{
821
+ webhookId: string;
822
+ signingSecret: string;
823
+ }>;
824
+ listWebhookDeliveries(webhookId: string): Promise<AgentWebhookDelivery[]>;
825
+ }
826
+ //# sourceMappingURL=webhooks.d.ts.map
827
+ //#endregion
828
+ //#region src/domains/chat.d.ts
829
+ declare class ChatApi extends ApiBase {
830
+ presignAttachments(files: {
831
+ filename: string;
832
+ mimeType: string;
363
833
  size: number;
364
- storageClass?: "STANDARD" | "GLACIER_IR";
365
- }): Promise<SyncConfirmedUpload>;
366
- syncReconstruct(args: {
367
- mode: "full" | "active" | "memory";
368
- }): Promise<SyncReconstructBundle>;
369
- syncGetStats(): Promise<SyncAgentStats>;
370
- syncListFiles(args?: {
371
- prefix?: string;
372
- }): Promise<{
373
- files: SyncFileEntry[];
374
- }>;
375
- syncListSessions(): Promise<{
376
- sessions: SyncSessionEntry[];
377
- }>;
378
- syncGetSession(sessionId: string): Promise<SyncSessionContent>;
379
- syncDeleteFile(filePath: string): Promise<{
380
- removed: boolean;
381
- }>;
382
- sharedListFiles(args: {
383
- scope: "org" | "team" | "project";
384
- scopeId: string;
385
- }): Promise<{
386
- files: SharedFileEntry[];
387
- nextCursor: string | null;
834
+ }[]): Promise<{
835
+ attachments: {
836
+ id: string;
837
+ uploadUrl: string;
838
+ downloadUrl: string;
839
+ s3Key: string;
840
+ expiresAt: string;
841
+ }[];
388
842
  }>;
389
- sharedDownloadUrl(args: {
390
- scope: "org" | "team" | "project";
391
- scopeId: string;
392
- filePath: string;
843
+ recordActivity(data: {
844
+ userId?: string;
845
+ channel: string;
846
+ role: "user" | "assistant";
393
847
  }): Promise<{
394
- downloadUrl: string;
395
- expiresIn: number;
396
- }>;
397
- listIntegrations(): Promise<IntegrationInstall$1[]>;
398
- getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult$1>;
399
- updateIntegrationConfig(integrationId: string, config: Record<string, unknown>): Promise<void>;
400
- installIntegration(integrationId: string, options?: {
401
- version?: string;
402
- config?: Record<string, unknown>;
403
- }): Promise<IntegrationInstall$1>;
404
- removeIntegration(integrationId: string): Promise<IntegrationInstall$1>;
405
- getOAuthUrl(provider: string, scopes?: string[]): Promise<{
406
- url: string;
407
- provider: string;
408
- expiresIn: number;
409
- }>;
410
- getOAuthStatus(provider: string): Promise<{
411
- provider: string;
412
- connected: boolean;
413
- config?: Record<string, string>;
414
- }>;
415
- getRegistry(): Promise<{
416
- integrations: RegistryEntry$1[];
848
+ recorded: boolean;
417
849
  }>;
850
+ }
851
+ //# sourceMappingURL=chat.d.ts.map
852
+ //#endregion
853
+ //#region src/domains/connect-credentials.d.ts
854
+ declare class ConnectCredentialsApi extends ApiBase {
418
855
  /**
419
856
  * Returns every connected Google account for the agent. Multi-account by
420
857
  * design — the openclaw-google plugin requires the LLM to pass `email`
@@ -471,82 +908,19 @@ declare class AgentApiClient {
471
908
  [key: string]: unknown;
472
909
  }>;
473
910
  /**
474
- * Resolve the primary cTrader Connection's credentials for the calling
475
- * agent. Unlike most providers, the cTrader Open API needs app-level auth
476
- * (`clientId` + `clientSecret`) AND account auth (`accessToken` +
477
- * `accountId`) on the socket, so `@alfe.ai/ctrader-mcp` self-fetches the
478
- * full set here at startup (the atlassian/google pattern). `clientId` /
479
- * `clientSecret` are the SST-sourced global app credentials the connect
480
- * endpoint injects — they are never persisted on the connection. `host` is
481
- * the resolved TLS endpoint (`live.ctraderapi.com` / `demo.ctraderapi.com`)
482
- * derived from the selected account's live/demo flag.
911
+ * @deprecated Returns a single primary credential blob (legacy "pick-the-
912
+ * default-connection" shape). Use `getGithubAccounts()` for the multi-
913
+ * account shape required by Pattern A explicit selector args on every
914
+ * tool. Retained because the `@alfe.ai/github-mcp` proxy is the
915
+ * only consumer that knows about Pattern A; legacy env-interpolation
916
+ * callers will keep hitting `/credentials` until they move to the proxy.
483
917
  */
484
- getCTraderCredentials(): Promise<{
918
+ getGithubCredentials(): Promise<{
919
+ login: string;
485
920
  accessToken: string;
486
- refreshToken: string;
487
- accountId: string;
488
- host: string;
489
- clientId: string;
490
- clientSecret: string;
491
921
  }>;
492
922
  /**
493
- * Pattern A: multi-account credential fetch for cTrader.
494
- *
495
- * Unlike atlassian/salesforce (one Connection row per account/site), a
496
- * cTrader is MULTI-grant per agent: an agent may connect several distinct
497
- * cTrader logins, each its own Connection row keyed on `accountIdentifier =
498
- * ctid:<userId>` (Phase 1). This aggregates the *trading accounts* across
499
- * ALL of those Connection rows — each row contributes its `availableAccounts`
500
- * flattened, and every account carries ITS OWN grant's `accessToken` (the
501
- * token that authenticates that account against the cTrader Open API). One
502
- * OAuth grant still covers all accounts under that single login on one shared
503
- * token; only the `ctidTraderAccountId` and the protobuf socket `host` (live
504
- * vs demo) differ within a grant. Across grants the tokens differ, so the
505
- * token is now PER-ACCOUNT rather than hoisted to the top level.
506
- *
507
- * `host` per account is derived from the account's `isLive` flag
508
- * (`live.ctraderapi.com` / `demo.ctraderapi.com`) — the same mapping the
509
- * connect provider applies server-side when an account is auto-selected.
510
- *
511
- * `clientId` / `clientSecret` are the SST-sourced GLOBAL app credentials the
512
- * connect endpoint injects — identical across every Connection row (one
513
- * cTrader app), never persisted on a connection. We take them from the first
514
- * row that carries them.
515
- *
516
- * Accounts are deduped on `ctidTraderAccountId` first-wins: Spotware ids are
517
- * globally unique across logins, so a duplicate can only appear if the same
518
- * account somehow surfaced under two grants — first-wins keeps it
519
- * deterministic.
520
- *
521
- * `accounts` may be empty (no cTrader Connection at all), in which case we
522
- * return empty creds rather than throwing.
523
- */
524
- getCTraderAccounts(): Promise<{
525
- accounts: {
526
- ctidTraderAccountId: string;
527
- host: string;
528
- isLive: boolean;
529
- brokerName?: string;
530
- accountNumber?: string;
531
- accessToken: string;
532
- }[];
533
- clientId: string;
534
- clientSecret: string;
535
- }>;
536
- /**
537
- * @deprecated Returns a single primary credential blob (legacy "pick-the-
538
- * default-connection" shape). Use `getGithubAccounts()` for the multi-
539
- * account shape required by Pattern A — explicit selector args on every
540
- * tool. Retained because the `@alfe.ai/github-mcp` proxy is the
541
- * only consumer that knows about Pattern A; legacy env-interpolation
542
- * callers will keep hitting `/credentials` until they move to the proxy.
543
- */
544
- getGithubCredentials(): Promise<{
545
- login: string;
546
- accessToken: string;
547
- }>;
548
- /**
549
- * Pattern A: multi-account credential fetch for GitHub.
923
+ * Pattern A: multi-account credential fetch for GitHub.
550
924
  *
551
925
  * Returns every agent-scoped GitHub connection. The caller is expected
552
926
  * to require a `login` selector on every credential-touching tool and
@@ -570,67 +944,6 @@ declare class AgentApiClient {
570
944
  scopes: string;
571
945
  }[];
572
946
  }>;
573
- /**
574
- * Pattern A: provider-parameterized multi-account credential fetch for the
575
- * social connectors (Bluesky, and the approval-gated backlog: X, Meta,
576
- * Threads, LinkedIn, Pinterest, TikTok, Reddit, YouTube).
577
- *
578
- * Unlike the bespoke `getGithubAccounts()` / `getXeroAccounts()` shapes,
579
- * this returns a UNIFORM normalized account shape so `@alfe.ai/social-mcp`'s
580
- * shared driver can require a single `account` selector on every
581
- * credential-touching tool regardless of platform. The backend
582
- * `api-agents/{provider}/accounts` route is already provider-generic; this
583
- * is the client-side normalization the plan (`do-we-need-any-moonlit-toucan`
584
- * Phase 0, step 5) calls for.
585
- *
586
- * `accountIdentifier` is the stable per-account selector the LLM should
587
- * pass back (for Bluesky: the account DID). `accessToken` carries whatever
588
- * the provider's `buildCredentialsResponse` bundles (for Bluesky: the JSON
589
- * session bundle — the driver parses the `accessJwt` out of it, or reads the
590
- * top-level `accessJwt` from `providerMetadata`-adjacent fields). Everything
591
- * else the driver needs for routing (handle, pdsHost, did, …) is on
592
- * `providerMetadata`.
593
- *
594
- * Token refresh is delegated to connect (never done in-plugin) via the
595
- * per-account route `POST /agent/connect/{provider}/accounts/{accountIdentifier}/refresh`
596
- * — call `refreshSocialAccount(provider, accountIdentifier)`. (The non-account
597
- * `POST /agent/connect/{provider}/refresh` route refreshes the provider's
598
- * PRIMARY connection, which is wrong under multi-account Pattern A.)
599
- */
600
- getSocialAccounts(provider: string): Promise<{
601
- provider: string;
602
- accounts: {
603
- connectionId: string;
604
- accountIdentifier: string;
605
- displayName: string | null;
606
- accessToken: string;
607
- providerMetadata: Record<string, unknown>;
608
- connectedAt: string;
609
- }[];
610
- }>;
611
- /**
612
- * Pattern A: refresh a specific social Connection by its stable
613
- * `accountIdentifier` (for Bluesky: the account DID) via the
614
- * provider-generic per-account refresh route. The counterpart to
615
- * `getSocialAccounts(provider)`; `@alfe.ai/social-mcp` calls this on a
616
- * 401/ExpiredToken from the platform PDS/API, then re-fetches accounts to
617
- * pick up the rotated bundle.
618
- *
619
- * Refresh itself is ALWAYS delegated to connect — the plugin never calls
620
- * the platform's own refresh XRPC (e.g. `com.atproto.server.refreshSession`)
621
- * because connect owns the encrypted refresh token + rotation persistence
622
- * (Bluesky rotates the refreshJwt; a missed rotation kills the connection
623
- * after one refresh). The returned `accessToken` is whatever the provider's
624
- * `refreshToken` hook re-bundled (for Bluesky: the JSON session bundle with
625
- * the fresh `accessJwt`) — callers typically ignore it and re-fetch via
626
- * `getSocialAccounts` for a consistent shape.
627
- */
628
- refreshSocialAccount(provider: string, accountIdentifier: string): Promise<{
629
- accountIdentifier: string;
630
- accessToken: string;
631
- accessTokenExpiresAt: string;
632
- expiresAt: string;
633
- }>;
634
947
  /**
635
948
  * @deprecated Returns a single primary credential blob (legacy "pick-the-
636
949
  * default-connection" shape). Use `getXeroAccounts()` for the multi-
@@ -648,8 +961,9 @@ declare class AgentApiClient {
648
961
  * selector arg (e.g. `xeroTenantId`) on every credential-touching tool
649
962
  * and look up the matching account by that selector at dispatch time.
650
963
  *
651
- * Returned `accounts[i].accountIdentifier` is the Xero tenantId the
652
- * stable cross-session identifier the LLM should pass.
964
+ * `xeroTenantId` is the model-facing organisation selector. The separate
965
+ * `accountIdentifier` is the Connect persistence key used for refresh and
966
+ * may be an email; never substitute one for the other.
653
967
  */
654
968
  getXeroAccounts(): Promise<{
655
969
  accounts: {
@@ -667,12 +981,12 @@ declare class AgentApiClient {
667
981
  expiresAt: string;
668
982
  }>;
669
983
  /**
670
- * Pattern A: refresh a specific Xero connection by its `accountIdentifier`
671
- * (the Xero `tenantId`). The legacy `refreshXeroToken()` only refreshes
672
- * the *primary* connection, which is wrong for multi-tenant Xero where
673
- * each tenant has its own non-interchangeable access token.
984
+ * Refresh a specific Xero Connection by its exact `accountIdentifier` from
985
+ * `getXeroAccounts()`. Do not substitute `xeroTenantId`: current Xero OAuth
986
+ * rows may use the account email as their persistence key even when a sole
987
+ * organisation tenant ID is available in provider metadata.
674
988
  */
675
- refreshXeroAccountToken(xeroTenantId: string): Promise<{
989
+ refreshXeroAccountToken(accountIdentifier: string): Promise<{
676
990
  accessToken: string;
677
991
  accessTokenExpiresAt: string;
678
992
  expiresAt: string;
@@ -827,6 +1141,21 @@ declare class AgentApiClient {
827
1141
  accessToken: string;
828
1142
  expiresAt: string;
829
1143
  }>;
1144
+ /**
1145
+ * Pattern A: refresh one MYOB Connection by its stable
1146
+ * `accountIdentifier` (the MYOB business id returned by
1147
+ * `getMYOBAccounts()`).
1148
+ *
1149
+ * MYOB refresh tokens belong to individual Connection rows. A
1150
+ * multi-business client must use this method instead of refreshing the
1151
+ * primary Connection and copying that access token into every cached
1152
+ * business client.
1153
+ */
1154
+ refreshMYOBAccountToken(accountIdentifier: string): Promise<{
1155
+ accessToken: string;
1156
+ accessTokenExpiresAt: string;
1157
+ expiresAt: string;
1158
+ }>;
830
1159
  /**
831
1160
  * @deprecated Returns a single primary credential blob. Use
832
1161
  * `getSalesforceAccounts()` for the multi-account shape required by
@@ -866,67 +1195,6 @@ declare class AgentApiClient {
866
1195
  accessTokenExpiresAt: string;
867
1196
  expiresAt: string;
868
1197
  }>;
869
- /**
870
- * @deprecated Returns a single primary credential blob. Use
871
- * `getShopifyAccounts()` for the multi-account shape required by Pattern A
872
- * (`@alfe.ai/shopify-mcp` keys per-shop on the myshopify domain).
873
- */
874
- getShopifyCredentials(): Promise<{
875
- accessToken: string;
876
- shopDomain: string;
877
- shopGid: string;
878
- shopName: string;
879
- apiVersion: string;
880
- }>;
881
- /**
882
- * Pattern A: multi-account credential fetch for Shopify. Returns every
883
- * agent-scoped Shopify Connection. One OAuth grant maps to one store, so the
884
- * stable per-call selector is the store's myshopify domain (`shopDomain`),
885
- * NOT `accountIdentifier` — the connect provider keys `accountIdentifier` on
886
- * the immutable shop GID (falling back to the domain), so `shopDomain` is the
887
- * value the LLM passes and the plugin routes on.
888
- *
889
- * Each entry is shaped by the connect provider's `buildCredentialsResponse`:
890
- * `{ accessToken, shopDomain, shopGid, shopName, apiVersion }` — offline
891
- * Shopify tokens never expire, so there is NO token / expiry field and no
892
- * refresh method (unlike Salesforce). The GraphQL Admin API authenticates
893
- * purely on `X-Shopify-Access-Token`; no client credentials are on the wire.
894
- */
895
- getShopifyAccounts(): Promise<{
896
- accounts: {
897
- connectionId: string;
898
- accountIdentifier: string;
899
- displayName: string | null;
900
- connectedAt: string;
901
- accessToken: string;
902
- shopDomain: string;
903
- shopGid: string;
904
- shopName: string;
905
- apiVersion: string;
906
- }[];
907
- }>;
908
- /**
909
- * Disconnects one connected Microsoft 365 account for the agent, by its
910
- * `accountIdentifier`. Hits the generic per-account disconnect route
911
- * (`DELETE /agent/connect/microsoft/accounts/{accountIdentifier}`), which
912
- * resolves across the agent's full effective scope chain and deletes the
913
- * matching Connection row. Returns the remaining accounts.
914
- *
915
- * IMPORTANT: pass the `accountIdentifier` from `getMicrosoftAccounts()`, NOT
916
- * a synthesised email. For Microsoft, `accountIdentifier` is the user's email
917
- * only when the Graph profile fetch succeeded at connect time; it falls back
918
- * to the Azure tenant id (`tid` claim) otherwise. The backend matches on
919
- * `accountIdentifier` exactly, so passing an email would 404 on those
920
- * fallback-identifier accounts. (This is why the param is not named `email`,
921
- * unlike `disconnectGoogleAccount` where the identifier is always the email.)
922
- */
923
- disconnectMicrosoftAccount(accountIdentifier: string): Promise<{
924
- accounts: {
925
- accountIdentifier: string;
926
- displayName?: string;
927
- connectedAt?: string;
928
- }[];
929
- }>;
930
1198
  /**
931
1199
  * Pattern A: multi-account credential fetch for Microsoft 365.
932
1200
  *
@@ -950,9 +1218,6 @@ declare class AgentApiClient {
950
1218
  connectedAt: string;
951
1219
  accessToken: string;
952
1220
  accessTokenExpiresAt: string;
953
- refreshToken: string;
954
- clientId: string;
955
- clientSecret: string;
956
1221
  email: string;
957
1222
  microsoftTenantId: string;
958
1223
  workspaceDomain: string;
@@ -977,242 +1242,213 @@ declare class AgentApiClient {
977
1242
  accessTokenExpiresAt: string;
978
1243
  expiresAt: string;
979
1244
  }>;
980
- getTeamsCredentials(): Promise<{
981
- agentId: string;
982
- tenantId: string;
983
- azureAppId: string;
984
- azureBotId: string;
985
- azureClientSecret: string;
986
- botDisplayName?: string;
987
- teamsTenantId?: string;
988
- serviceUrl?: string;
989
- }>;
990
- sendTeamsMessage(data: {
991
- conversationId: string;
992
- text?: string;
993
- adaptiveCard?: Record<string, unknown>;
994
- }): Promise<{
995
- ok: boolean;
996
- activityId: string;
997
- }>;
998
- listTeamsChannels(): Promise<{
999
- channels: {
1000
- id: string;
1001
- name: string;
1002
- description?: string;
1245
+ /**
1246
+ * Disconnects one connected Microsoft 365 account for the agent, by its
1247
+ * `accountIdentifier`. Hits the generic per-account disconnect route
1248
+ * (`DELETE /agent/connect/microsoft/accounts/{accountIdentifier}`), which
1249
+ * resolves across the agent's full effective scope chain and deletes the
1250
+ * matching Connection row. Returns the remaining accounts.
1251
+ *
1252
+ * IMPORTANT: pass the `accountIdentifier` from `getMicrosoftAccounts()`, NOT
1253
+ * a synthesised email. For Microsoft, `accountIdentifier` is the user's email
1254
+ * only when the Graph profile fetch succeeded at connect time; it falls back
1255
+ * to the Azure tenant id (`tid` claim) otherwise. The backend matches on
1256
+ * `accountIdentifier` exactly, so passing an email would 404 on those
1257
+ * fallback-identifier accounts. (This is why the param is not named `email`,
1258
+ * unlike `disconnectGoogleAccount` where the identifier is always the email.)
1259
+ */
1260
+ disconnectMicrosoftAccount(accountIdentifier: string): Promise<{
1261
+ accounts: {
1262
+ accountIdentifier: string;
1263
+ displayName?: string;
1264
+ connectedAt?: string;
1003
1265
  }[];
1004
1266
  }>;
1005
- presignAttachments(files: {
1006
- filename: string;
1007
- mimeType: string;
1008
- size: number;
1009
- }[]): Promise<{
1010
- attachments: {
1011
- id: string;
1012
- uploadUrl: string;
1013
- downloadUrl: string;
1014
- s3Key: string;
1015
- expiresAt: string;
1016
- }[];
1267
+ /**
1268
+ * Resolve the primary cTrader Connection's credentials for the calling
1269
+ * agent. Unlike most providers, the cTrader Open API needs app-level auth
1270
+ * (`clientId` + `clientSecret`) AND account auth (`accessToken` +
1271
+ * `accountId`) on the socket, so `@alfe.ai/ctrader-mcp` self-fetches the
1272
+ * full set here at startup (the atlassian/google pattern). `clientId` /
1273
+ * `clientSecret` are the SST-sourced global app credentials the connect
1274
+ * endpoint injects — they are never persisted on the connection. `host` is
1275
+ * the resolved TLS endpoint (`live.ctraderapi.com` / `demo.ctraderapi.com`)
1276
+ * derived from the selected account's live/demo flag.
1277
+ */
1278
+ getCTraderCredentials(): Promise<{
1279
+ accessToken: string;
1280
+ refreshToken: string;
1281
+ accountId: string;
1282
+ host: string;
1283
+ clientId: string;
1284
+ clientSecret: string;
1017
1285
  }>;
1018
1286
  /**
1019
- * Generate an image from a text prompt and get back a STABLE, public URL
1020
- * (served from the agent-assets CDN — it does not expire). Embed the returned
1021
- * `imageUrl` in a reply as markdown to show it to the user.
1287
+ * Pattern A: multi-account credential fetch for cTrader.
1022
1288
  *
1023
- * ASYNC: `gpt-image-1` routinely runs 30–60s, which exceeds the API Gateway
1024
- * 30s ceiling, so this enqueues a job (`POST /agent/images/generate`
1025
- * `jobId`) then polls (`GET /agent/images/{jobId}`) until it completes. The
1026
- * worker's real failure message (e.g. an unsupported `size`) surfaces via the
1027
- * job's `error` field.
1028
- */
1029
- generateImage(args: {
1030
- prompt: string;
1031
- model?: string;
1032
- size?: string;
1033
- quality?: string;
1034
- }): Promise<{
1035
- imageUrl: string;
1036
- model: string;
1037
- }>;
1038
- recordActivity(data: {
1039
- userId?: string;
1040
- channel: string;
1041
- role: "user" | "assistant";
1042
- }): Promise<{
1043
- recorded: boolean;
1044
- }>;
1045
- /** Update the agent's own name and/or voice config. Returns the updated agent. */
1046
- updateSelf(update: {
1047
- name?: string;
1048
- voiceConfig?: AgentVoiceConfig;
1049
- }): Promise<AgentSelf>;
1050
- /**
1051
- * Generate the agent's own avatar from a text prompt. The image is generated,
1052
- * stored, and set on the agent server-side; returns the updated agent.
1289
+ * Unlike atlassian/salesforce (one Connection row per account/site), a
1290
+ * cTrader is MULTI-grant per agent: an agent may connect several distinct
1291
+ * cTrader logins, each its own Connection row keyed on `accountIdentifier =
1292
+ * ctid:<userId>` (Phase 1). This aggregates the *trading accounts* across
1293
+ * ALL of those Connection rows — each row contributes its `availableAccounts`
1294
+ * flattened, and every account carries ITS OWN grant's `accessToken` (the
1295
+ * token that authenticates that account against the cTrader Open API). One
1296
+ * OAuth grant still covers all accounts under that single login on one shared
1297
+ * token; only the `ctidTraderAccountId` and the protobuf socket `host` (live
1298
+ * vs demo) differ within a grant. Across grants the tokens differ, so the
1299
+ * token is now PER-ACCOUNT rather than hoisted to the top level.
1053
1300
  *
1054
- * ASYNC (same reason as `generateImage`): avatar gen runs `gpt-image-1`
1055
- * (30–60s) which exceeds the API Gateway 30s ceiling, so this enqueues a job
1056
- * (`POST /agent/avatar/generate` `jobId`) then polls (`GET /agent/avatar/{jobId}`)
1057
- * until the avatar is set. Signature unchanged — the plugin is unaffected.
1058
- */
1059
- generateAvatar(args: {
1060
- prompt: string;
1061
- }): Promise<AgentSelf>;
1062
- /**
1063
- * Get a presigned PUT URL to upload a new avatar image. Upload the bytes to
1064
- * `uploadUrl`, then call `finalizeAvatar(s3Key)` to set it on the agent.
1065
- */
1066
- presignAvatar(args: {
1067
- mimeType: string;
1068
- size: number;
1069
- }): Promise<AgentAvatarPresign>;
1070
- /**
1071
- * Finalize an avatar upload — validates ownership + size, then sets the
1072
- * agent's `avatarUrl` server-side. Returns the updated agent.
1301
+ * `host` per account is derived from the account's `isLive` flag
1302
+ * (`live.ctraderapi.com` / `demo.ctraderapi.com`) the same mapping the
1303
+ * connect provider applies server-side when an account is auto-selected.
1304
+ *
1305
+ * `clientId` / `clientSecret` are the SST-sourced GLOBAL app credentials the
1306
+ * connect endpoint injects — identical across every Connection row (one
1307
+ * cTrader app), never persisted on a connection. We take them from the first
1308
+ * row that carries them.
1309
+ *
1310
+ * Accounts are deduped on `ctidTraderAccountId` first-wins: Spotware ids are
1311
+ * globally unique across logins, so a duplicate can only appear if the same
1312
+ * account somehow surfaced under two grants — first-wins keeps it
1313
+ * deterministic.
1314
+ *
1315
+ * `accounts` may be empty (no cTrader Connection at all), in which case we
1316
+ * return empty creds rather than throwing.
1073
1317
  */
1074
- finalizeAvatar(s3Key: string): Promise<AgentSelf>;
1075
- /** List the platform voice catalogue (ElevenLabs) so the agent can pick its own voice. */
1076
- listVoices(): Promise<{
1077
- voices: AgentVoice[];
1318
+ getCTraderAccounts(): Promise<{
1319
+ accounts: {
1320
+ ctidTraderAccountId: string;
1321
+ host: string;
1322
+ isLive: boolean;
1323
+ brokerName?: string;
1324
+ accountNumber?: string;
1325
+ accessToken: string;
1326
+ }[];
1327
+ clientId: string;
1328
+ clientSecret: string;
1078
1329
  }>;
1079
1330
  /**
1080
- * Mint a fresh AES-256 data key for a specific (secret, field) pair. The
1081
- * encryption context is rebuilt server-side from `auth.tenantId` + the body
1082
- * fields including `fieldKey`; the agent cannot forge context for a scope
1083
- * or field it doesn't own. Legacy single-envelope secrets are migrated to
1084
- * `field#value` rows by the data migration, so call with `fieldKey: "value"`
1085
- * to reach them.
1331
+ * @deprecated Returns a single primary credential blob. Use
1332
+ * `getShopifyAccounts()` for the multi-account shape required by Pattern A
1333
+ * (`@alfe.ai/shopify-mcp` keys per-shop on the myshopify domain).
1086
1334
  */
1087
- generateSecretDataKey(args: {
1088
- scope: SecretScope$1;
1089
- scopeId: string;
1090
- secretId: string;
1091
- fieldKey: string;
1092
- }): Promise<GeneratedDataKey$1>;
1335
+ getShopifyCredentials(): Promise<{
1336
+ accessToken: string;
1337
+ shopDomain: string;
1338
+ shopGid: string;
1339
+ shopName: string;
1340
+ apiVersion: string;
1341
+ }>;
1093
1342
  /**
1094
- * Unwrap a wrapped data key so the agent can decrypt the envelope locally.
1095
- * `fieldKey` MUST match the value supplied when the data key was generated
1096
- * (it's bound into KMS encryption context); mismatch fails with
1097
- * `InvalidCiphertextException`.
1343
+ * Pattern A: multi-account credential fetch for Shopify. Returns every
1344
+ * agent-scoped Shopify Connection. One OAuth grant maps to one store, so the
1345
+ * stable per-call selector is the store's myshopify domain (`shopDomain`),
1346
+ * NOT `accountIdentifier` — the connect provider keys `accountIdentifier` on
1347
+ * the immutable shop GID (falling back to the domain), so `shopDomain` is the
1348
+ * value the LLM passes and the plugin routes on.
1349
+ *
1350
+ * Each entry is shaped by the connect provider's `buildCredentialsResponse`:
1351
+ * `{ accessToken, shopDomain, shopGid, shopName, apiVersion }` — offline
1352
+ * Shopify tokens never expire, so there is NO token / expiry field and no
1353
+ * refresh method (unlike Salesforce). The GraphQL Admin API authenticates
1354
+ * purely on `X-Shopify-Access-Token`; no client credentials are on the wire.
1098
1355
  */
1099
- decryptSecretDataKey(args: {
1100
- scope: SecretScope$1;
1101
- scopeId: string;
1102
- secretId: string;
1103
- fieldKey: string;
1104
- dataKeyCiphertext: string;
1105
- }): Promise<{
1106
- plaintextKey: string;
1356
+ getShopifyAccounts(): Promise<{
1357
+ accounts: {
1358
+ connectionId: string;
1359
+ accountIdentifier: string;
1360
+ displayName: string | null;
1361
+ connectedAt: string;
1362
+ accessToken: string;
1363
+ shopDomain: string;
1364
+ shopGid: string;
1365
+ shopName: string;
1366
+ apiVersion: string;
1367
+ }[];
1107
1368
  }>;
1108
1369
  /**
1109
- * Create a new secret with one or more fields. Encrypted fields must arrive
1110
- * pre-sealed (the agent has already obtained per-field data keys via
1111
- * `generateSecretDataKey({ ..., fieldKey })` and AES-encrypted locally).
1112
- * Plaintext fields ship the value inline.
1370
+ * Pattern A: provider-parameterized multi-account credential fetch for the
1371
+ * social connectors (Bluesky, and the approval-gated backlog: X, Meta,
1372
+ * Threads, LinkedIn, Pinterest, TikTok, Reddit, YouTube).
1373
+ *
1374
+ * Unlike the bespoke `getGithubAccounts()` / `getXeroAccounts()` shapes,
1375
+ * this returns a UNIFORM normalized account shape so `@alfe.ai/social-mcp`'s
1376
+ * shared driver can require a single `account` selector on every
1377
+ * credential-touching tool regardless of platform. The backend
1378
+ * `api-agents/{provider}/accounts` route is already provider-generic; this
1379
+ * is the client-side normalization the plan (`do-we-need-any-moonlit-toucan`
1380
+ * Phase 0, step 5) calls for.
1381
+ *
1382
+ * `accountIdentifier` is the stable per-account selector the LLM should
1383
+ * pass back (for Bluesky: the account DID). `accessToken` carries whatever
1384
+ * the provider's `buildCredentialsResponse` bundles (for Bluesky: the JSON
1385
+ * session bundle — the driver parses the `accessJwt` out of it, or reads the
1386
+ * top-level `accessJwt` from `providerMetadata`-adjacent fields). Everything
1387
+ * else the driver needs for routing (handle, pdsHost, did, …) is on
1388
+ * `providerMetadata`.
1389
+ *
1390
+ * Token refresh is delegated to connect (never done in-plugin) via the
1391
+ * per-account route `POST /agent/connect/{provider}/accounts/{accountIdentifier}/refresh`
1392
+ * — call `refreshSocialAccount(provider, accountIdentifier)`. (The non-account
1393
+ * `POST /agent/connect/{provider}/refresh` route refreshes the provider's
1394
+ * PRIMARY connection, which is wrong under multi-account Pattern A.)
1113
1395
  */
1114
- createSecret(args: {
1115
- scope: SecretScope$1;
1116
- scopeId: string;
1117
- secretId: string;
1118
- secretName: string;
1119
- category?: SecretCategory$1;
1120
- description?: string;
1121
- tags?: string[];
1122
- fields: {
1123
- key: string;
1124
- format?: FieldFormat$1;
1125
- sensitivity: FieldSensitivity$1;
1126
- value?: string;
1127
- envelope?: EncryptedEnvelopeV1$1;
1396
+ getSocialAccounts(provider: string): Promise<{
1397
+ provider: string;
1398
+ accounts: {
1399
+ connectionId: string;
1400
+ accountIdentifier: string;
1401
+ displayName: string | null;
1402
+ accessToken: string;
1403
+ providerMetadata: Record<string, unknown>;
1404
+ connectedAt: string;
1128
1405
  }[];
1129
- reason?: string;
1130
- }): Promise<SecretAggregate$1>;
1131
- /** Fetch the secret aggregate plus per-field encrypted envelopes. */
1132
- getSecret(args: {
1133
- scope: SecretScope$1;
1134
- scopeId: string;
1135
- secretId: string;
1136
- }): Promise<{
1137
- aggregate: SecretAggregate$1;
1138
- envelopes: FieldEnvelope$1[];
1139
1406
  }>;
1140
- /** Fetch one field. Plaintext: value inline. Encrypted: envelope. */
1141
- getSecretField(args: {
1142
- scope: SecretScope$1;
1143
- scopeId: string;
1144
- secretId: string;
1145
- fieldKey: string;
1146
- }): Promise<{
1147
- key: string;
1148
- sensitivity: FieldSensitivity$1;
1149
- format?: FieldFormat$1;
1150
- value?: string;
1151
- envelope?: EncryptedEnvelopeV1$1;
1152
- rotatedAt?: string;
1153
- createdAt: string;
1154
- updatedAt: string;
1155
- }>;
1156
- /** Add OR rotate one field. */
1157
- setSecretField(args: {
1158
- scope: SecretScope$1;
1159
- scopeId: string;
1160
- secretId: string;
1161
- fieldKey: string;
1162
- sensitivity: FieldSensitivity$1;
1163
- format?: FieldFormat$1;
1164
- value?: string;
1165
- envelope?: EncryptedEnvelopeV1$1;
1166
- reason?: string;
1167
- }): Promise<{
1168
- fieldKey: string;
1169
- rotated: boolean;
1407
+ /**
1408
+ * Pattern A: refresh a specific social Connection by its stable
1409
+ * `accountIdentifier` (for Bluesky: the account DID) via the
1410
+ * provider-generic per-account refresh route. The counterpart to
1411
+ * `getSocialAccounts(provider)`; `@alfe.ai/social-mcp` calls this on a
1412
+ * 401/ExpiredToken from the platform PDS/API, then re-fetches accounts to
1413
+ * pick up the rotated bundle.
1414
+ *
1415
+ * Refresh itself is ALWAYS delegated to connect — the plugin never calls
1416
+ * the platform's own refresh XRPC (e.g. `com.atproto.server.refreshSession`)
1417
+ * because connect owns the encrypted refresh token + rotation persistence
1418
+ * (Bluesky rotates the refreshJwt; a missed rotation kills the connection
1419
+ * after one refresh). The returned `accessToken` is whatever the provider's
1420
+ * `refreshToken` hook re-bundled (for Bluesky: the JSON session bundle with
1421
+ * the fresh `accessJwt`) — callers typically ignore it and re-fetch via
1422
+ * `getSocialAccounts` for a consistent shape.
1423
+ */
1424
+ refreshSocialAccount(provider: string, accountIdentifier: string): Promise<{
1425
+ accountIdentifier: string;
1426
+ accessToken: string;
1427
+ accessTokenExpiresAt: string;
1428
+ expiresAt: string;
1170
1429
  }>;
1171
- /** Remove one field. */
1172
- removeSecretField(args: {
1173
- scope: SecretScope$1;
1174
- scopeId: string;
1175
- secretId: string;
1176
- fieldKey: string;
1177
- }): Promise<void>;
1178
- /** Update secret-level metadata (name/description/tags/category). */
1179
- updateSecretMetadata(args: {
1180
- scope: SecretScope$1;
1181
- scopeId: string;
1182
- secretId: string;
1183
- secretName?: string;
1184
- description?: string;
1185
- tags?: string[];
1186
- category?: SecretCategory$1;
1187
- reason?: string;
1188
- }): Promise<SecretAggregate$1>;
1189
- /** List metadata for secrets in a scope. Optional filters route through the byFacet GSI. */
1190
- listSecrets(args: {
1191
- scope: SecretScope$1;
1192
- scopeId: string;
1193
- category?: SecretCategory$1;
1194
- tag?: string;
1195
- fieldKey?: string;
1196
- }): Promise<SecretMetadata$1[]>;
1197
- /** Bounded changelog read — metadata-only audit entries. */
1198
- getSecretHistory(args: {
1199
- scope: SecretScope$1;
1200
- scopeId: string;
1201
- secretId: string;
1202
- limit?: number;
1203
- cursor?: string;
1204
- }): Promise<{
1205
- entries: ChangelogEntry$1[];
1206
- nextCursor?: string;
1430
+ }
1431
+ //# sourceMappingURL=connect-credentials.d.ts.map
1432
+ //#endregion
1433
+ //#region src/domains/database.d.ts
1434
+ declare class DatabaseApi extends ApiBase {
1435
+ registerDatabaseCredentials(): Promise<{
1436
+ connectionString: string;
1437
+ username: string;
1438
+ password: string;
1439
+ databases: string[];
1207
1440
  }>;
1208
- /** Delete a secret (and all its field rows + tag rows + changelog rows). */
1209
- deleteSecret(args: {
1210
- scope: SecretScope$1;
1211
- scopeId: string;
1212
- secretId: string;
1441
+ reportDatabaseAudit(entry: {
1442
+ database: string;
1443
+ collection: string;
1444
+ operation: string;
1445
+ summary?: string;
1213
1446
  }): Promise<void>;
1214
- /** Enumerate scopes (org/team/project/agent) this agent can access. */
1215
- listSecretScopes(): Promise<ScopeInfo$1[]>;
1447
+ }
1448
+ //# sourceMappingURL=database.d.ts.map
1449
+ //#endregion
1450
+ //#region src/domains/identity.d.ts
1451
+ declare class IdentityApi extends ApiBase {
1216
1452
  /**
1217
1453
  * Returns the calling agent's own identity context — `{ agentId, tenantId }`
1218
1454
  * decoded server-side from the agent API token. Used by the
@@ -1255,59 +1491,35 @@ declare class AgentApiClient {
1255
1491
  }>;
1256
1492
  mergeIdentities(survivorId: string, args: {
1257
1493
  mergedId: string;
1258
- changedBy: {
1259
- type: string;
1260
- id: string;
1261
- name?: string;
1262
- };
1263
1494
  }): Promise<{
1264
1495
  ok: boolean;
1265
1496
  error?: string;
1266
1497
  }>;
1267
- unmergeIdentity(identityId: string, args: {
1268
- changedBy: {
1269
- type: string;
1270
- id: string;
1271
- name?: string;
1272
- };
1273
- }): Promise<{
1498
+ unmergeIdentity(identityId: string): Promise<{
1274
1499
  ok: boolean;
1275
1500
  error?: string;
1276
1501
  }>;
1277
1502
  addIdentityNote(identityId: string, args: {
1278
1503
  content: string;
1279
1504
  category?: string;
1280
- changedBy: {
1281
- type: string;
1282
- id: string;
1283
- name?: string;
1284
- };
1285
1505
  }): Promise<{
1286
1506
  noteId: string | null;
1287
1507
  }>;
1288
1508
  tagIdentity(identityId: string, args: {
1289
1509
  tag: string;
1290
1510
  action: "add" | "remove";
1291
- changedBy: {
1292
- type: string;
1293
- id: string;
1294
- name?: string;
1295
- };
1296
1511
  }): Promise<{
1297
1512
  ok: boolean;
1298
1513
  }>;
1299
1514
  getIdentityChangelog(identityId: string, args?: {
1300
1515
  limit?: number;
1516
+ cursor?: string;
1301
1517
  }): Promise<{
1302
1518
  entries: unknown[];
1519
+ cursor: string | null;
1303
1520
  }>;
1304
1521
  rollbackIdentity(identityId: string, args: {
1305
1522
  targetVersion: number;
1306
- changedBy: {
1307
- type: string;
1308
- id: string;
1309
- name?: string;
1310
- };
1311
1523
  }): Promise<{
1312
1524
  ok: boolean;
1313
1525
  entry?: unknown;
@@ -1346,7 +1558,7 @@ declare class AgentApiClient {
1346
1558
  verified: boolean;
1347
1559
  identityId?: string;
1348
1560
  /** Phase 2: how the confirm resolved — Scenario A vs B. */
1349
- action?: "merged" | "contact_verified";
1561
+ action?: "merged" | "contact_verified" | "already_confirmed";
1350
1562
  error?: string;
1351
1563
  }>;
1352
1564
  /**
@@ -1375,6 +1587,62 @@ declare class AgentApiClient {
1375
1587
  identityId: string | null;
1376
1588
  status: string;
1377
1589
  }>;
1590
+ }
1591
+ //# sourceMappingURL=identity.d.ts.map
1592
+ //#endregion
1593
+ //#region src/domains/images.d.ts
1594
+ declare class ImagesApi extends ApiBase {
1595
+ /**
1596
+ * Generate an image from a text prompt and get back a STABLE, public URL
1597
+ * (served from the agent-assets CDN — it does not expire). Embed the returned
1598
+ * `imageUrl` in a reply as markdown to show it to the user.
1599
+ *
1600
+ * ASYNC: `gpt-image-1` routinely runs 30–60s, which exceeds the API Gateway
1601
+ * 30s ceiling, so this enqueues a job (`POST /agent/images/generate` →
1602
+ * `jobId`) then polls (`GET /agent/images/{jobId}`) until it completes. The
1603
+ * worker's real failure message (e.g. an unsupported `size`) surfaces via the
1604
+ * job's `error` field.
1605
+ */
1606
+ generateImage(args: {
1607
+ prompt: string;
1608
+ model?: string;
1609
+ size?: string;
1610
+ quality?: string;
1611
+ }): Promise<{
1612
+ imageUrl: string;
1613
+ model: string;
1614
+ }>;
1615
+ }
1616
+ //# sourceMappingURL=images.d.ts.map
1617
+ //#endregion
1618
+ //#region src/domains/integrations.d.ts
1619
+ declare class IntegrationsApi extends ApiBase {
1620
+ listIntegrations(): Promise<IntegrationInstall$1[]>;
1621
+ getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult$1>;
1622
+ updateIntegrationConfig(integrationId: string, config: Record<string, unknown>): Promise<void>;
1623
+ installIntegration(integrationId: string, options?: {
1624
+ version?: string;
1625
+ config?: Record<string, unknown>;
1626
+ }): Promise<IntegrationInstall$1>;
1627
+ removeIntegration(integrationId: string): Promise<IntegrationInstall$1>;
1628
+ getOAuthUrl(provider: string, scopes?: string[]): Promise<{
1629
+ url: string;
1630
+ provider: string;
1631
+ expiresIn: number;
1632
+ }>;
1633
+ getOAuthStatus(provider: string): Promise<{
1634
+ provider: string;
1635
+ connected: boolean;
1636
+ config?: Record<string, string>;
1637
+ }>;
1638
+ getRegistry(): Promise<{
1639
+ integrations: RegistryEntry$1[];
1640
+ }>;
1641
+ }
1642
+ //# sourceMappingURL=integrations.d.ts.map
1643
+ //#endregion
1644
+ //#region src/domains/memory.d.ts
1645
+ declare class MemoryApi extends ApiBase {
1378
1646
  memorySearch(query: string, opts?: {
1379
1647
  limit?: number;
1380
1648
  topic?: string;
@@ -1422,8 +1690,21 @@ declare class AgentApiClient {
1422
1690
  messageCount: number;
1423
1691
  }>;
1424
1692
  memoryLoadContext(tier?: number, topicHint?: string): Promise<{
1693
+ tier: number;
1694
+ facts: {
1695
+ subject: string;
1696
+ predicate: string;
1697
+ object: string;
1698
+ since: string;
1699
+ }[];
1700
+ memories: {
1701
+ text: string;
1702
+ topic: string;
1703
+ subtopic: string;
1704
+ score: number;
1705
+ }[];
1706
+ tokenEstimate: number;
1425
1707
  formatted: string;
1426
- [key: string]: unknown;
1427
1708
  }>;
1428
1709
  memoryLookupEntity(subject: string): Promise<{
1429
1710
  subject: string;
@@ -1450,197 +1731,217 @@ declare class AgentApiClient {
1450
1731
  memoryStats(): Promise<{
1451
1732
  vectorCount: number;
1452
1733
  tripleCount: number;
1453
- storageEstimateBytes: number;
1454
- lastIngestionAt?: string;
1455
- }>;
1456
- memoryLearn(args: {
1457
- text: string;
1458
- source?: string;
1459
- sourceType?: "file" | "url" | "inline";
1460
- metadata?: {
1461
- sessionId?: string;
1462
- channelId?: string;
1463
- userName?: string;
1464
- };
1465
- }): Promise<{
1466
- memoriesStored: number;
1467
- triplesStored: number;
1468
- chunks: number;
1469
- source?: string;
1470
- }>;
1471
- memoryBootstrapStatus(): Promise<{
1472
- synced: boolean;
1473
- syncedAt?: string;
1474
- sessionsBackfillSynced?: boolean;
1475
- sessionsBackfillSyncedAt?: string;
1476
- }>;
1477
- memoryBootstrapStatusMark(scope?: "files" | "sessions"): Promise<{
1478
- synced: true;
1479
- syncedAt: string;
1480
- }>;
1481
- sendSms(args: {
1482
- to: string;
1483
- body: string;
1484
- }): Promise<{
1485
- sent: boolean;
1486
- sid: string;
1487
- }>;
1488
- searchWeb(params: {
1489
- query: string;
1490
- count?: number;
1491
- offset?: number;
1492
- country?: string;
1493
- freshness?: string;
1494
- }): Promise<unknown>;
1495
- searchImages(params: {
1496
- query: string;
1497
- count?: number;
1498
- }): Promise<unknown>;
1499
- searchNews(params: {
1500
- query: string;
1501
- count?: number;
1502
- freshness?: string;
1503
- }): Promise<unknown>;
1504
- /** Search news across the selected provider's corpus. → POST /agent/news/search */
1505
- newsSearch(params: {
1506
- query: string;
1507
- provider?: NewsProvider;
1508
- source?: string;
1509
- from?: string;
1510
- to?: string;
1511
- language?: string;
1512
- category?: string;
1513
- limit?: number;
1514
- }): Promise<NewsResult>;
1515
- /** Top headlines for the selected provider. → POST /agent/news/headlines */
1516
- newsHeadlines(params?: {
1517
- provider?: NewsProvider;
1518
- category?: string;
1519
- source?: string;
1520
- language?: string;
1521
- limit?: number;
1522
- }): Promise<NewsResult>;
1523
- /**
1524
- * Semantic search across the agent's member scopes. Fan-out is gated
1525
- * server-side by `listScopes` set-inclusion (fail-closed). Pass
1526
- * `scopeType` + `scopeId` to narrow to one scope; a non-member scope
1527
- * yields empty results (never a cross-scope leak).
1528
- */
1529
- knowledgeSearch(query: string, opts?: {
1530
- limit?: number;
1531
- scopeType?: KnowledgeScopeType;
1532
- scopeId?: string;
1533
- }): Promise<KnowledgeSearchResult>;
1534
- /** Enumerate the scopes (org + teams + projects) this agent belongs to. */
1535
- listScopes(): Promise<{
1536
- scopes: KnowledgeScope[];
1734
+ storageEstimateBytes: number;
1735
+ lastIngestionAt?: string;
1537
1736
  }>;
1538
- /** Read a scope's structured knowledge profile (after membership check). */
1539
- getScopeProfile(scopeType: KnowledgeScopeType, scopeId: string): Promise<KnowledgeProfile>;
1540
- /** List a scope's docs (the org-files corpus; mirrored to shared/<scope>/). */
1541
- listScopeDocs(scopeType: KnowledgeScopeType, scopeId: string, opts?: {
1542
- limit?: number;
1543
- cursor?: string;
1737
+ memoryLearn(args: {
1738
+ text: string;
1739
+ source?: string;
1740
+ sourceType?: "file" | "url" | "inline";
1741
+ metadata?: {
1742
+ sessionId?: string;
1743
+ channelId?: string;
1744
+ userName?: string;
1745
+ };
1544
1746
  }): Promise<{
1545
- files: KnowledgeDoc[];
1546
- nextCursor: string | null;
1747
+ memoriesStored: number;
1748
+ triplesStored: number;
1749
+ chunks: number;
1750
+ source?: string;
1751
+ }>;
1752
+ memoryBootstrapStatus(): Promise<{
1753
+ synced: boolean;
1754
+ syncedAt?: string;
1755
+ sessionsBackfillSynced?: boolean;
1756
+ sessionsBackfillSyncedAt?: string;
1757
+ }>;
1758
+ memoryBootstrapStatusMark(scope?: "files" | "sessions"): Promise<{
1759
+ synced: true;
1760
+ syncedAt: string;
1547
1761
  }>;
1762
+ }
1763
+ //# sourceMappingURL=memory.d.ts.map
1764
+ //#endregion
1765
+ //#region src/domains/secrets.d.ts
1766
+ declare class SecretsApi extends ApiBase {
1548
1767
  /**
1549
- * Read the full text of a scope doc. Resolves a presigned download URL
1550
- * from `services/org`, then fetches the bytes directly from S3 (the one
1551
- * legitimate raw fetch in a plugin same pattern as sync).
1768
+ * Mint a fresh AES-256 data key for a specific (secret, field) pair. The
1769
+ * encryption context is rebuilt server-side from `auth.tenantId` + the body
1770
+ * fields including `fieldKey`; the agent cannot forge context for a scope
1771
+ * or field it doesn't own. Legacy single-envelope secrets are migrated to
1772
+ * `field#value` rows by the data migration, so call with `fieldKey: "value"`
1773
+ * to reach them.
1552
1774
  */
1553
- readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string): Promise<{
1554
- filePath: string;
1555
- text: string;
1556
- }>;
1775
+ generateSecretDataKey(args: {
1776
+ scope: SecretScope$1;
1777
+ scopeId: string;
1778
+ secretId: string;
1779
+ fieldKey: string;
1780
+ }): Promise<GeneratedDataKey$1>;
1557
1781
  /**
1558
- * Write (create or overwrite) a scope doc. Two-step presigned upload:
1559
- * `services/org` returns a signed URL plus `requiredHeaders` (author /
1560
- * authorKind / message as `x-amz-meta-*`) that MUST be sent verbatim on
1561
- * the PUT, alongside the same `Content-Type` that was signed. Author and
1562
- * authorKind are server-set from the agent token — never trusted here.
1782
+ * Unwrap a wrapped data key so the agent can decrypt the envelope locally.
1783
+ * `fieldKey` MUST match the value supplied when the data key was generated
1784
+ * (it's bound into KMS encryption context); mismatch fails with
1785
+ * `InvalidCiphertextException`.
1563
1786
  */
1564
- writeScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, content: string, opts?: {
1565
- contentType?: string;
1566
- message?: string;
1787
+ decryptSecretDataKey(args: {
1788
+ scope: SecretScope$1;
1789
+ scopeId: string;
1790
+ secretId: string;
1791
+ fieldKey: string;
1792
+ dataKeyCiphertext: string;
1567
1793
  }): Promise<{
1568
- filePath: string;
1794
+ plaintextKey: string;
1569
1795
  }>;
1570
1796
  /**
1571
- * Open a change request against a scope's knowledge resource. For a doc
1572
- * create/update, `services/org` returns a presigned staging PUT; this method
1573
- * uploads the proposed `content` to it (echoing the same Content-Type that
1574
- * was signed), mirroring `writeScopeDoc`. The staged body is applied to the
1575
- * canonical doc — attributed to this agent — only when a reviewer approves.
1576
- */
1577
- proposeScopeChange(scopeType: KnowledgeScopeType, scopeId: string, input: ProposeScopeChangeInput): Promise<KnowledgeChangeRequest>;
1578
- /**
1579
- * List the agent's OWN change requests in a scope (filtered server-side to
1580
- * this agent as proposer). Pass `status` to narrow to open / approved / etc.
1797
+ * Create a new secret with one or more fields. Encrypted fields must arrive
1798
+ * pre-sealed (the agent has already obtained per-field data keys via
1799
+ * `generateSecretDataKey({ ..., fieldKey })` and AES-encrypted locally).
1800
+ * Plaintext fields ship the value inline.
1581
1801
  */
1582
- listScopeChangeRequests(scopeType: KnowledgeScopeType, scopeId: string, opts?: {
1583
- status?: ChangeRequestStatus;
1584
- limit?: number;
1585
- cursor?: string;
1802
+ createSecret(args: {
1803
+ scope: SecretScope$1;
1804
+ scopeId: string;
1805
+ secretId: string;
1806
+ secretName: string;
1807
+ category?: SecretCategory$1;
1808
+ description?: string;
1809
+ tags?: string[];
1810
+ fields: {
1811
+ key: string;
1812
+ format?: FieldFormat$1;
1813
+ sensitivity: FieldSensitivity$1;
1814
+ value?: string;
1815
+ envelope?: EncryptedEnvelopeV1$1;
1816
+ }[];
1817
+ reason?: string;
1818
+ }): Promise<SecretAggregate$1>;
1819
+ /** Fetch the secret aggregate plus per-field encrypted envelopes. */
1820
+ getSecret(args: {
1821
+ scope: SecretScope$1;
1822
+ scopeId: string;
1823
+ secretId: string;
1586
1824
  }): Promise<{
1587
- changeRequests: KnowledgeChangeRequest[];
1588
- nextCursor: string | null;
1825
+ aggregate: SecretAggregate$1;
1826
+ envelopes: FieldEnvelope$1[];
1589
1827
  }>;
1590
- registerDatabaseCredentials(): Promise<{
1591
- connectionString: string;
1592
- username: string;
1593
- password: string;
1594
- databases: string[];
1828
+ /** Fetch one field. Plaintext: value inline. Encrypted: envelope. */
1829
+ getSecretField(args: {
1830
+ scope: SecretScope$1;
1831
+ scopeId: string;
1832
+ secretId: string;
1833
+ fieldKey: string;
1834
+ }): Promise<{
1835
+ key: string;
1836
+ sensitivity: FieldSensitivity$1;
1837
+ format?: FieldFormat$1;
1838
+ value?: string;
1839
+ envelope?: EncryptedEnvelopeV1$1;
1840
+ rotatedAt?: string;
1841
+ createdAt: string;
1842
+ updatedAt: string;
1595
1843
  }>;
1596
- reportDatabaseAudit(entry: {
1597
- database: string;
1598
- collection: string;
1599
- operation: string;
1600
- summary?: string;
1844
+ /** Add OR rotate one field. */
1845
+ setSecretField(args: {
1846
+ scope: SecretScope$1;
1847
+ scopeId: string;
1848
+ secretId: string;
1849
+ fieldKey: string;
1850
+ sensitivity: FieldSensitivity$1;
1851
+ format?: FieldFormat$1;
1852
+ value?: string;
1853
+ envelope?: EncryptedEnvelopeV1$1;
1854
+ reason?: string;
1855
+ }): Promise<{
1856
+ fieldKey: string;
1857
+ rotated: boolean;
1858
+ }>;
1859
+ /** Remove one field. */
1860
+ removeSecretField(args: {
1861
+ scope: SecretScope$1;
1862
+ scopeId: string;
1863
+ secretId: string;
1864
+ fieldKey: string;
1601
1865
  }): Promise<void>;
1602
- requestBrowserTakeover(args: {
1603
- instructions: string;
1604
- url?: string;
1605
- conversationId?: string;
1866
+ /** Update secret-level metadata (name/description/tags/category). */
1867
+ updateSecretMetadata(args: {
1868
+ scope: SecretScope$1;
1869
+ scopeId: string;
1870
+ secretId: string;
1871
+ secretName?: string;
1872
+ description?: string;
1873
+ tags?: string[];
1874
+ category?: SecretCategory$1;
1875
+ reason?: string;
1876
+ }): Promise<SecretAggregate$1>;
1877
+ /** List metadata for secrets in a scope. Optional filters route through the byFacet GSI. */
1878
+ listSecrets(args: {
1879
+ scope: SecretScope$1;
1880
+ scopeId: string;
1881
+ category?: SecretCategory$1;
1882
+ tag?: string;
1883
+ fieldKey?: string;
1884
+ }): Promise<SecretMetadata$1[]>;
1885
+ /** Bounded changelog read — metadata-only audit entries. */
1886
+ getSecretHistory(args: {
1887
+ scope: SecretScope$1;
1888
+ scopeId: string;
1889
+ secretId: string;
1890
+ limit?: number;
1891
+ cursor?: string;
1606
1892
  }): Promise<{
1607
- sessionId: string;
1608
- status: string;
1893
+ entries: ChangelogEntry$1[];
1894
+ nextCursor?: string;
1609
1895
  }>;
1610
- getRemoteSession(sessionId: string): Promise<RemoteSessionInfo>;
1611
- completeRemoteSession(sessionId: string): Promise<{
1896
+ /** Delete a secret (and all its field rows + tag rows + changelog rows). */
1897
+ deleteSecret(args: {
1898
+ scope: SecretScope$1;
1899
+ scopeId: string;
1900
+ secretId: string;
1901
+ }): Promise<void>;
1902
+ /** Enumerate scopes (org/team/project/agent) this agent can access. */
1903
+ listSecretScopes(): Promise<ScopeInfo$1[]>;
1904
+ }
1905
+ //# sourceMappingURL=secrets.d.ts.map
1906
+ //#endregion
1907
+ //#region src/domains/teams.d.ts
1908
+ declare class TeamsApi extends ApiBase {
1909
+ getTeamsCredentials(): Promise<{
1910
+ agentId: string;
1911
+ tenantId: string;
1912
+ azureAppId: string;
1913
+ azureBotId: string;
1914
+ azureClientSecret: string;
1915
+ botDisplayName?: string;
1916
+ teamsTenantId?: string;
1917
+ serviceUrl?: string;
1918
+ }>;
1919
+ sendTeamsMessage(data: {
1920
+ conversationId: string;
1921
+ text?: string;
1922
+ adaptiveCard?: Record<string, unknown>;
1923
+ }): Promise<{
1612
1924
  ok: boolean;
1925
+ activityId: string;
1613
1926
  }>;
1614
- /**
1615
- * Issue a request that returns the raw `Response` (no JSON parsing, no
1616
- * forced Content-Type). The caller sets `Content-Type`/`Accept` on `headers`
1617
- * and reads the body itself (`arrayBuffer()` / `json()`).
1618
- *
1619
- * A single retry fires only on the same transient statuses `request()`
1620
- * retries (authorizer-timeout 500 + LB 502/503/504) and transient network
1621
- * errors — before the route handler runs — so re-issuing a POST does not
1622
- * risk a duplicate side effect. Voice TTS/STT are effectively idempotent
1623
- * (re-synthesize / re-transcribe) and meter server-side keyed on the
1624
- * gateway requestId, so a retried transcription doesn't double-bill.
1625
- */
1626
- private rawFetch;
1627
- /**
1628
- * Text-to-speech. Returns raw PCM audio bytes plus their framing — the
1629
- * voice service defaults to 24 kHz / mono / 16-bit. Wrap in a WAV container
1630
- * to produce a playable file. Metered per character against the tenant
1631
- * credit pool server-side; TTS completes regardless of metering outcome.
1632
- */
1633
- tts(args: VoiceTtsArgs): Promise<VoiceTtsResult>;
1634
- /**
1635
- * Speech-to-text. Accepts raw linear16 (16-bit LE) mono PCM — NOT a WAV or
1636
- * other container (the endpoint transcribes with a fixed linear16 encoding,
1637
- * so a container header would be transcribed as noise). Strip any WAV header
1638
- * and pass `sampleRate` from it before calling. Metered by transcribed
1639
- * duration against the tenant credit pool server-side.
1640
- */
1641
- stt(args: VoiceSttArgs): Promise<VoiceSttResult>;
1927
+ listTeamsChannels(): Promise<{
1928
+ channels: {
1929
+ id: string;
1930
+ name: string;
1931
+ description?: string;
1932
+ }[];
1933
+ }>;
1934
+ }
1935
+ //# sourceMappingURL=teams.d.ts.map
1936
+
1937
+ //#endregion
1938
+ //#region src/index.d.ts
1939
+ interface AgentApiClient extends SyncApi, IntegrationsApi, WorkspaceApi, ConnectCredentialsApi, TeamsApi, ChatApi, SecretsApi, IdentityApi, MemoryApi, SearchApi, KnowledgeApi, DatabaseApi, MobileApi, RemoteApi, SelfApi, VoiceApi, ImagesApi, WebhooksApi {}
1940
+ declare class AgentApiClient extends ApiBase {
1941
+ constructor(config: AgentApiClientConfig);
1642
1942
  }
1643
1943
  //# sourceMappingURL=index.d.ts.map
1944
+
1644
1945
  //#endregion
1645
- export { AgentApiClient, AgentApiClientConfig, AgentAvatarPresign, AgentSelf, AgentVoice, AgentVoiceConfig, ChangeRequestActorKind, ChangeRequestOperation, ChangeRequestResourceType, ChangeRequestStatus, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type InstallToolErrorCaptureOptions, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, KnowledgeChangeRequest, KnowledgeDoc, KnowledgeProfile, KnowledgeProfileLink, KnowledgeScope, KnowledgeScopeType, KnowledgeSearchHit, KnowledgeSearchResult, NewsArticle, NewsProvider, NewsResult, ProposeScopeChangeInput, type RegistryEntry, RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, SharedFileEntry, SyncAgentInfo, SyncAgentStats, SyncConfirmedUpload, SyncFileEntry, SyncManifest, SyncManifestEntry, SyncPresignedUrl, SyncReconstructBundle, SyncReconstructFile, SyncSessionContent, SyncSessionEntry, type ToolCaptureApi, VoiceSttArgs, VoiceSttResult, VoiceTtsArgs, VoiceTtsModel, VoiceTtsResult, installToolErrorCapture };
1946
+ export { AgentApiClient, type AgentApiClientConfig, type AgentAvatarPresign, type AgentSelf, type AgentVoice, type AgentVoiceConfig, type AgentWebhook, type AgentWebhookDelivery, type AgentWorkspaceInfo, type ChangeRequestActorKind, type ChangeRequestOperation, type ChangeRequestResourceType, type ChangeRequestStatus, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type CreatedAgentWebhook, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type InstallToolErrorCaptureOptions, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, type KnowledgeChangeRequest, type KnowledgeDoc, type KnowledgeProfile, type KnowledgeProfileLink, type KnowledgeScope, type KnowledgeScopeType, type KnowledgeSearchHit, type KnowledgeSearchResult, type MobileAvailableNumber, type MobileNumberInfo, type NewsArticle, type NewsProvider, type NewsResult, type ProposeScopeChangeInput, type RegistryEntry, type RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, type SharedFileEntry, type SyncAgentInfo, type SyncAgentStats, type SyncConfirmedUpload, type SyncFileEntry, type SyncManifest, type SyncManifestEntry, type SyncPresignedUrl, type SyncReconstructBundle, type SyncReconstructFile, type SyncSessionContent, type SyncSessionEntry, type ToolCaptureApi, type VoiceSttArgs, type VoiceSttResult, type VoiceTtsArgs, type VoiceTtsModel, type VoiceTtsResult, type WhatsAppTemplate, installToolErrorCapture };
1646
1947
  //# sourceMappingURL=index.d.cts.map