@axiom-lattice/client-sdk 8.2.0 → 8.3.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.
@@ -0,0 +1,3939 @@
1
+ import * as _axiom_lattice_protocols from '@axiom-lattice/protocols';
2
+ import { OpenGrant, McpTool, TaskItem, Message, AgentInterrupt, McpUiResourcePayload, CapabilityBundle, CapabilityPreview, AgentWebApp, DatabaseConfigEntry, DataSource, LocalA2ATemplateDefinition, McpServerConfigEntry, MetricsServerConfigEntry, MessageChunk, CreateDatabaseConfigRequest, UpdateDatabaseConfigRequest, ModelProviderPublicEntry, CreateModelProviderRequest, UpdateModelProviderRequest, ModelProviderProbeRequest, ModelProviderProbeResult, ModelSelection, ModelDiscoveryResult, TenantModelCatalog, CreateMetricsServerConfigRequest, UpdateMetricsServerConfigRequest, CreateMcpServerConfigRequest, UpdateMcpServerConfigRequest, ConnectionEntry, CreateTaskRequest, UpdateTaskRequest, TaskWorkItem, ThreadCheckpointStorage, LocalA2AProviderState, OpenCatalog, McpUiRef, CreateCapabilityBundleInput, UpdateCapabilityBundleInput, CreateAgentWebAppInput, UpdateAgentWebAppInput, Skill, CreateSkillRequest, CreateShareRequest, ShareResult, ShareRecordPatch, ShareRecord, ProjectBotRole, ProjectHumanRole, ProjectRoomPublicMessage, ProjectRoomMention, ProjectMembership, ProjectBotMembership, ProjectRoom, ProjectRoomPublicBotMembership, ProjectRoomPublicMembership, Project as Project$1, ProjectRoomEventScope, UserTenantRole, PlatformBrandingSettings, PlatformRole, EffectivePlatformSettings, PlatformSettingSource, PlatformSettingsDocument, ResolvedPlatformBranding, TenantStatus, UserStatus, OidcIdentityClaimStatus, ToolCallUi, McpAppShareBootstrap } from '@axiom-lattice/protocols';
3
+ export { AgentInterrupt, AgentWebApp, AgentWebAppAppearance, AgentWebAppFeatures, AgentWebAppQuickPrompt, AgentWebAppScope, AgentWebAppStatus, CapabilityBundle, CapabilityPreview, CreateAgentWebAppInput, CreateCapabilityBundleInput, LocalA2AProviderId, LocalA2AProviderState, LocalA2AProviderStatus, LocalA2ATemplateDefinition, LocalRuntimeConfig, OidcIdentityClaimStatus, PlatformRole, TenantStatus, ThreadCheckpointStorage, UpdateAgentWebAppInput, UpdateCapabilityBundleInput, UserTenantRole } from '@axiom-lattice/protocols';
4
+
5
+ /** Resolved MCP App UI resource plus its ready-to-use CSP policy string. */
6
+ interface McpUiResourceResponse extends McpUiResourcePayload {
7
+ cspPolicy: string;
8
+ }
9
+ /** Optional filters for listing Agent Web Apps. */
10
+ interface ListAgentWebAppsParams {
11
+ /** Return only publications for this assistant. */
12
+ assistantId?: string;
13
+ }
14
+ /** Project capability bundle selection and its resolved preview. */
15
+ interface ProjectCapabilitiesResponse {
16
+ project: Project;
17
+ persistedBundleIds?: string[];
18
+ bundles: CapabilityBundle[];
19
+ preview: CapabilityPreview;
20
+ }
21
+ /** Safe status for a persisted capability bundle that cannot be returned. */
22
+ interface InvalidCapabilityBundleSummary {
23
+ bundleId: string;
24
+ code: "INVALID_BUNDLE_CONFIG";
25
+ message: string;
26
+ }
27
+ /** Valid capability bundles plus safe summaries for invalid legacy records. */
28
+ interface CapabilityBundleListResponse {
29
+ bundles: CapabilityBundle[];
30
+ errors: InvalidCapabilityBundleSummary[];
31
+ }
32
+ /** Agent Web App list data, unwrapped from the gateway response envelope. */
33
+ interface AgentWebAppsListResponse {
34
+ records: AgentWebApp[];
35
+ total: number;
36
+ }
37
+ /**
38
+ * Tool interface for API responses
39
+ * Represents a tool configuration stored in the database
40
+ */
41
+ interface Tool {
42
+ id: string;
43
+ name: string;
44
+ description: string;
45
+ license?: string;
46
+ compatibility?: string;
47
+ metadata?: Record<string, any>;
48
+ config?: any;
49
+ createdAt: Date | string;
50
+ updatedAt: Date | string;
51
+ }
52
+ /**
53
+ * Transport method for client-server communication
54
+ * Note: Currently only "ws" is used for tool registration
55
+ */
56
+ type Transport = "sse" | "ws";
57
+ /**
58
+ * Configuration options for the Client
59
+ */
60
+ interface ClientConfig {
61
+ /**
62
+ * Base URL for the API
63
+ */
64
+ baseURL: string;
65
+ /**
66
+ * API key for authentication
67
+ */
68
+ apiKey: string;
69
+ /**
70
+ * Assistant identifier
71
+ */
72
+ assistantId: string;
73
+ /**
74
+ * Transport method (Server-Sent Events or WebSocket)
75
+ */
76
+ transport: Transport;
77
+ /**
78
+ * Request timeout in milliseconds (optional, defaults to 30000)
79
+ */
80
+ timeout?: number;
81
+ /**
82
+ * Additional headers to include in requests (optional)
83
+ */
84
+ headers?: Record<string, string>;
85
+ /**
86
+ * Configuration for retry behavior (optional)
87
+ */
88
+ retry?: RetryConfig;
89
+ }
90
+ /**
91
+ * Configuration for retry behavior
92
+ */
93
+ interface RetryConfig {
94
+ /**
95
+ * Maximum number of retry attempts
96
+ */
97
+ maxRetries: number;
98
+ /**
99
+ * Initial delay between retries in milliseconds
100
+ */
101
+ initialDelayMs: number;
102
+ /**
103
+ * Maximum delay between retries in milliseconds
104
+ */
105
+ maxDelayMs: number;
106
+ /**
107
+ * Factor to multiply delay by after each retry attempt
108
+ */
109
+ backoffFactor: number;
110
+ }
111
+ /**
112
+ * Thread creation options
113
+ */
114
+ interface CreateThreadOptions {
115
+ /**
116
+ * Optional metadata for the thread
117
+ */
118
+ metadata?: Record<string, any>;
119
+ /** Optional relative TTL in seconds. */
120
+ ttlSeconds?: number;
121
+ /** Optional absolute ISO expiry; ignored when ttlSeconds is supplied. */
122
+ expiresAt?: string;
123
+ /** Optional pre-populated graph state written at creation. */
124
+ supersteps?: ThreadSuperstepInput[];
125
+ }
126
+ /** One checkpoint update applied when creating a thread. */
127
+ interface ThreadSuperstepInput {
128
+ updates: Array<{
129
+ values: Record<string, unknown>;
130
+ as_node?: string;
131
+ }>;
132
+ }
133
+ /** Thread status and pending HITL interrupts. */
134
+ interface ThreadStatusInfo {
135
+ status: "idle" | "busy" | "interrupted" | "error";
136
+ pendingMessages: number;
137
+ interrupts: AgentInterrupt[];
138
+ }
139
+ /** One page of thread checkpoint history (newest first). */
140
+ interface ThreadHistoryPage {
141
+ history: unknown[];
142
+ }
143
+ /** Result of a thread copy operation. */
144
+ type CopiedThread = Thread;
145
+ /** Prune strategy input. */
146
+ interface PruneThreadInput {
147
+ strategy: "delete" | "keep_latest";
148
+ keep?: number;
149
+ }
150
+ /** Result of a thread prune operation. */
151
+ interface PruneThreadResult {
152
+ pruned: boolean;
153
+ strategy?: "delete" | "keep_latest";
154
+ keep?: number;
155
+ counts?: {
156
+ checkpoints: number;
157
+ blobs: number;
158
+ writes: number;
159
+ };
160
+ }
161
+ /**
162
+ * Thread information
163
+ */
164
+ interface Thread {
165
+ /**
166
+ * Thread identifier
167
+ */
168
+ id: string;
169
+ /**
170
+ * Assistant identifier this thread belongs to
171
+ */
172
+ assistantId: string;
173
+ /**
174
+ * Thread metadata
175
+ */
176
+ metadata?: Record<string, any>;
177
+ /**
178
+ * Thread creation timestamp
179
+ */
180
+ createdAt: Date | string;
181
+ /**
182
+ * Thread last update timestamp
183
+ */
184
+ updatedAt: Date | string;
185
+ }
186
+ /**
187
+ * Chat send options
188
+ */
189
+ interface ChatSendOptions {
190
+ /**
191
+ * Assistant identifier
192
+ */
193
+ assistantId?: string;
194
+ /**
195
+ * Thread identifier
196
+ */
197
+ threadId: string;
198
+ /**
199
+ * Messages to send
200
+ */
201
+ messages: Message[];
202
+ /**
203
+ * Files to attach (optional)
204
+ */
205
+ files?: any[];
206
+ /**
207
+ * Command to execute (optional)
208
+ */
209
+ command?: {
210
+ resume?: {
211
+ action: string;
212
+ data: Record<string, any> & {
213
+ config?: {
214
+ thread_id?: string;
215
+ work_log_id?: string;
216
+ };
217
+ };
218
+ message: string;
219
+ };
220
+ update?: any;
221
+ send?: {
222
+ node: string;
223
+ input: any;
224
+ };
225
+ };
226
+ /**
227
+ * Queue mode for message processing (optional)
228
+ * - 'collect': Batch process messages
229
+ * - 'followup': Process messages one by one
230
+ * - 'steer': Process immediately with high priority
231
+ */
232
+ mode?: 'collect' | 'followup' | 'steer';
233
+ [key: string]: any;
234
+ }
235
+ /**
236
+ * Chat stream options
237
+ */
238
+ interface ChatStreamOptions extends ChatSendOptions {
239
+ /**
240
+ * Whether to run in background (optional)
241
+ */
242
+ background?: boolean;
243
+ /**
244
+ * Whether to return agent state when stream completes (optional)
245
+ */
246
+ enableReturnStateWhenSteamCompleted?: boolean;
247
+ }
248
+ /**
249
+ * Stream callbacks interface
250
+ */
251
+ interface StreamCallbacks {
252
+ /**
253
+ * Called when a stream event is received
254
+ */
255
+ onEvent: (event: MessageChunk) => void;
256
+ /**
257
+ * Called when the stream completes, with optional agent state
258
+ */
259
+ onComplete?: (state?: AgentState) => void;
260
+ /**
261
+ * Called when an error occurs
262
+ */
263
+ onError?: (error: Error) => void;
264
+ }
265
+ /**
266
+ * Chat response
267
+ */
268
+ interface ChatResponse {
269
+ /**
270
+ * Response messages
271
+ */
272
+ messages: Message[];
273
+ /**
274
+ * Trace ID for debugging
275
+ */
276
+ traceId?: string;
277
+ }
278
+ /**
279
+ * Tool registration options
280
+ */
281
+ interface RegisterToolOptions {
282
+ /**
283
+ * Tool name
284
+ */
285
+ name: string;
286
+ /**
287
+ * Tool parameter schema
288
+ */
289
+ schema: object;
290
+ /**
291
+ * Tool handler function
292
+ */
293
+ handler: (params: any) => Promise<any>;
294
+ }
295
+ /**
296
+ * Get messages options
297
+ */
298
+ interface GetMessagesOptions {
299
+ /**
300
+ * Thread identifier
301
+ */
302
+ threadId: string;
303
+ /**
304
+ * Maximum number of messages to return
305
+ */
306
+ limit?: number;
307
+ /**
308
+ * Message ID to start from (for pagination)
309
+ */
310
+ after?: string;
311
+ /**
312
+ * Whether to return messages in reverse chronological order
313
+ */
314
+ reverse?: boolean;
315
+ }
316
+ /**
317
+ * Resume stream options
318
+ */
319
+ interface ResumeStreamOptions {
320
+ /**
321
+ * Assistant identifier
322
+ */
323
+ assistantId: string;
324
+ /**
325
+ * Thread identifier
326
+ */
327
+ threadId: string;
328
+ /**
329
+ * Message identifier (usually run_id)
330
+ */
331
+ messageId: string;
332
+ /**
333
+ * Content already received (used to find resume position)
334
+ */
335
+ knownContent: string;
336
+ /**
337
+ * Polling interval in milliseconds (default: 100ms)
338
+ */
339
+ pollInterval?: number;
340
+ /**
341
+ * Last SSE event id received on a prior connection.
342
+ *
343
+ * Sent as `Last-Event-ID` so a shared/cursor-addressable chunk source resumes
344
+ * strictly after that record. Omit to position by message id.
345
+ */
346
+ lastEventId?: string;
347
+ }
348
+ /**
349
+ * Thread list options
350
+ */
351
+ interface ListThreadsOptions {
352
+ /**
353
+ * Maximum number of threads to return
354
+ */
355
+ limit?: number;
356
+ /**
357
+ * Offset for pagination
358
+ */
359
+ offset?: number;
360
+ }
361
+ /**
362
+ * Run options
363
+ */
364
+ type RunOptions = {
365
+ /**
366
+ * Thread identifier
367
+ */
368
+ threadId: string;
369
+ /**
370
+ * Message to send
371
+ */
372
+ message: string;
373
+ /**
374
+ * Message ID (optional, for tracking pending messages)
375
+ */
376
+ messageId?: string;
377
+ /**
378
+ * Files to attach (optional)
379
+ */
380
+ files?: any[];
381
+ /**
382
+ * Command to execute (optional)
383
+ */
384
+ command?: any;
385
+ /**
386
+ * Whether to stream the response (optional)
387
+ */
388
+ streaming?: boolean;
389
+ /**
390
+ * Whether to run in background (optional)
391
+ */
392
+ background?: boolean;
393
+ /**
394
+ * Whether to return agent state when stream completes (optional)
395
+ */
396
+ enableReturnStateWhenSteamCompleted?: boolean;
397
+ /**
398
+ * Custom runtime configuration to override or extend agent's runConfig
399
+ */
400
+ custom_run_config?: Record<string, any>;
401
+ } & Record<string, any>;
402
+ /**
403
+ * Agent state
404
+ */
405
+ interface AgentState {
406
+ createdAt?: string;
407
+ values: {
408
+ messages: Message[];
409
+ [key: string]: any;
410
+ };
411
+ tasks: Array<{
412
+ interrupts: Array<{
413
+ value: any;
414
+ id: string;
415
+ }>;
416
+ }>;
417
+ threadStatus?: 'idle' | 'busy' | 'interrupted';
418
+ queueConfig?: {
419
+ mode: 'collect' | 'followup' | 'steer';
420
+ maxSize: number;
421
+ };
422
+ pendingMessages?: PendingMessage[];
423
+ pendingCount?: number;
424
+ }
425
+ /**
426
+ * Pending message in queue
427
+ */
428
+ interface PendingMessage {
429
+ id: string;
430
+ content: string;
431
+ type: 'human' | 'system';
432
+ sequence: number;
433
+ createdAt: Date | string;
434
+ }
435
+ /**
436
+ * Assistant information
437
+ */
438
+ interface Assistant {
439
+ /**
440
+ * Assistant identifier
441
+ */
442
+ id: string;
443
+ /**
444
+ * Assistant name
445
+ */
446
+ name: string;
447
+ /**
448
+ * Assistant description (optional)
449
+ */
450
+ description?: string;
451
+ /**
452
+ * Graph definition for the assistant
453
+ */
454
+ graphDefinition: any;
455
+ /**
456
+ * Creation timestamp
457
+ */
458
+ createdAt: Date | string;
459
+ /**
460
+ * Last update timestamp
461
+ */
462
+ updatedAt: Date | string;
463
+ }
464
+ /**
465
+ * Create assistant request options
466
+ */
467
+ interface CreateAssistantOptions {
468
+ /**
469
+ * Assistant name
470
+ */
471
+ name: string;
472
+ /**
473
+ * Assistant description (optional)
474
+ */
475
+ description?: string;
476
+ /**
477
+ * Graph definition for the assistant
478
+ */
479
+ graphDefinition: any;
480
+ }
481
+ /**
482
+ * Update assistant request options
483
+ */
484
+ interface UpdateAssistantOptions {
485
+ /**
486
+ * Assistant name (optional)
487
+ */
488
+ name?: string;
489
+ /**
490
+ * Assistant description (optional)
491
+ */
492
+ description?: string;
493
+ /**
494
+ * Graph definition for the assistant (optional)
495
+ */
496
+ graphDefinition?: any;
497
+ }
498
+ /**
499
+ * Assistant list response
500
+ */
501
+ interface AssistantListResponse {
502
+ /**
503
+ * Whether the operation was successful
504
+ */
505
+ success: boolean;
506
+ /**
507
+ * Response message
508
+ */
509
+ message: string;
510
+ /**
511
+ * Response data
512
+ */
513
+ data: {
514
+ /**
515
+ * List of assistants
516
+ */
517
+ records: Assistant[];
518
+ /**
519
+ * Total number of assistants
520
+ */
521
+ total: number;
522
+ };
523
+ }
524
+ /**
525
+ * Assistant response
526
+ */
527
+ interface AssistantResponse {
528
+ /**
529
+ * Whether the operation was successful
530
+ */
531
+ success: boolean;
532
+ /**
533
+ * Response message
534
+ */
535
+ message: string;
536
+ /**
537
+ * Assistant data (optional)
538
+ */
539
+ data?: Assistant;
540
+ }
541
+ /**
542
+ * Thread list response
543
+ */
544
+ interface ThreadListResponse {
545
+ /**
546
+ * Whether the operation was successful
547
+ */
548
+ success: boolean;
549
+ /**
550
+ * Response message
551
+ */
552
+ message: string;
553
+ /**
554
+ * Response data
555
+ */
556
+ data: {
557
+ /**
558
+ * List of threads
559
+ */
560
+ records: Thread[];
561
+ /**
562
+ * Total number of threads
563
+ */
564
+ total: number;
565
+ };
566
+ }
567
+ /**
568
+ * Thread response
569
+ */
570
+ interface ThreadResponse {
571
+ /**
572
+ * Whether the operation was successful
573
+ */
574
+ success: boolean;
575
+ /**
576
+ * Response message
577
+ */
578
+ message: string;
579
+ /**
580
+ * Thread data (optional)
581
+ */
582
+ data?: Thread;
583
+ }
584
+ /**
585
+ * Update thread request options
586
+ */
587
+ interface UpdateThreadOptions {
588
+ /**
589
+ * Thread metadata (optional)
590
+ */
591
+ metadata?: Record<string, any>;
592
+ }
593
+ /**
594
+ * Custom error classes
595
+ */
596
+ declare class ApiError extends Error {
597
+ statusCode: number;
598
+ responseBody?: any | undefined;
599
+ constructor(message: string, statusCode: number, responseBody?: any | undefined);
600
+ }
601
+ declare class NetworkError extends Error {
602
+ constructor(message: string);
603
+ }
604
+ declare class AuthenticationError extends Error {
605
+ constructor(message: string);
606
+ }
607
+ /**
608
+ * Schedule execution type
609
+ */
610
+ declare enum ScheduleExecutionType {
611
+ ONCE = "once",
612
+ CRON = "cron"
613
+ }
614
+ /**
615
+ * Scheduled task status
616
+ */
617
+ declare enum ScheduledTaskStatus {
618
+ PENDING = "pending",
619
+ RUNNING = "running",
620
+ COMPLETED = "completed",
621
+ FAILED = "failed",
622
+ CANCELLED = "cancelled",
623
+ PAUSED = "paused"
624
+ }
625
+ /**
626
+ * Scheduled task definition
627
+ */
628
+ /** Queue behavior for an Agent cron. */
629
+ type CronMultitaskStrategy = "enqueue" | "interrupt";
630
+ /** Completion behavior for a stateless Agent cron. */
631
+ type CronOnRunCompleted = "keep" | "delete";
632
+ /** Agent cron resource returned by the gateway. */
633
+ interface AgentCron {
634
+ cron_id: string;
635
+ thread_id?: string;
636
+ assistant_id: string;
637
+ /** Workspace scope captured when the cron was created. */
638
+ workspace_id?: string;
639
+ /** Project scope captured when the cron was created. */
640
+ project_id?: string;
641
+ schedule: string;
642
+ timezone: string;
643
+ end_time?: string;
644
+ next_run_date?: string;
645
+ enabled: boolean;
646
+ payload: Record<string, unknown>;
647
+ on_run_completed?: CronOnRunCompleted;
648
+ multitask_strategy: CronMultitaskStrategy;
649
+ created_at: string;
650
+ updated_at: string;
651
+ run_count: number;
652
+ status: string;
653
+ }
654
+ /** Shared create fields for thread and stateless crons. */
655
+ interface CreateCronInput {
656
+ schedule: string;
657
+ timezone?: string;
658
+ end_time?: string;
659
+ payload: {
660
+ input: Record<string, unknown>;
661
+ };
662
+ enabled?: boolean;
663
+ multitask_strategy?: CronMultitaskStrategy;
664
+ /** Workspace to bind to the scheduled runs. */
665
+ workspace_id?: string;
666
+ /** Project to bind to the scheduled runs. */
667
+ project_id?: string;
668
+ }
669
+ /** Create a cron bound to an existing thread. */
670
+ type CreateThreadCronInput = CreateCronInput;
671
+ /** Create a stateless cron that starts a fresh thread per fire. */
672
+ interface CreateStatelessCronInput extends CreateCronInput {
673
+ assistant_id: string;
674
+ on_run_completed?: CronOnRunCompleted;
675
+ }
676
+ /** Filters accepted by cron search/count. */
677
+ interface CronSearchFilters {
678
+ assistant_id?: string;
679
+ thread_id?: string;
680
+ enabled?: boolean;
681
+ limit?: number;
682
+ offset?: number;
683
+ }
684
+ /** Count filters accepted by the cron count endpoint. */
685
+ interface CronCountFilters {
686
+ assistant_id?: string;
687
+ thread_id?: string;
688
+ enabled?: boolean;
689
+ }
690
+ /** Patchable fields on an Agent cron (D1: enabled only). */
691
+ interface UpdateAgentCronInput {
692
+ enabled: boolean;
693
+ }
694
+ /** Structured Agent graph returned by `agent.getTree`. */
695
+ interface AgentGraphTree {
696
+ nodes: unknown[];
697
+ edges: unknown[];
698
+ mermaid: string;
699
+ namespaces: string[][];
700
+ }
701
+ /** Input payload accepted by the `run.start` thread command. */
702
+ interface CommandRunStartInput {
703
+ message?: string;
704
+ messages?: Array<{
705
+ role: string;
706
+ content: unknown;
707
+ }>;
708
+ id?: string;
709
+ }
710
+ /** Arguments for `run.start`. */
711
+ interface CommandRunStartArgs {
712
+ input: CommandRunStartInput;
713
+ config?: Record<string, unknown>;
714
+ metadata?: Record<string, unknown>;
715
+ multitask_strategy?: "enqueue" | "interrupt" | "collect";
716
+ }
717
+ /** Result of `run.start`. */
718
+ interface CommandRunStartResult {
719
+ messageId: string;
720
+ queued: boolean;
721
+ mode: string;
722
+ }
723
+ /** Arguments for `input.respond`. */
724
+ interface CommandInputRespondArgs {
725
+ interrupt_id: string;
726
+ response?: unknown;
727
+ answers?: unknown[];
728
+ resume?: Record<string, unknown>;
729
+ config?: Record<string, unknown>;
730
+ /** Server currently derives this from `interrupt_id`; accepted for forward compatibility. */
731
+ expected_interrupt_id?: string;
732
+ }
733
+ /** Result of `input.respond` (queue-first: the answer is accepted before it runs). */
734
+ interface CommandInputRespondResult {
735
+ messageId: string;
736
+ queued: boolean;
737
+ interruptId: string;
738
+ /** Present on queue-first responses; the answer was durably accepted. */
739
+ accepted?: boolean;
740
+ /** Present on queue-first responses; the queued command id. */
741
+ commandId?: string;
742
+ }
743
+ /** Input accepted by the single-run create API. */
744
+ interface RunCreateInput {
745
+ message?: string;
746
+ messages?: Array<{
747
+ role: string;
748
+ content: unknown;
749
+ }>;
750
+ id?: string;
751
+ }
752
+ /** Options accepted by the single-run create API. */
753
+ interface RunCreateOptions {
754
+ config?: Record<string, unknown>;
755
+ mode?: "followup" | "enqueue";
756
+ /** HITL resume command; mutually exclusive with `input`. */
757
+ command?: {
758
+ resume: unknown;
759
+ };
760
+ /**
761
+ * Behavior when the thread already has an active run. Defaults to `enqueue`.
762
+ *
763
+ * @remarks `reject` returns `409 RUN_REJECTED` without touching the active
764
+ * run; `interrupt` settles or interrupts exactly one active run, waits for it
765
+ * to become terminal, then creates the new pending run; `rollback` rewinds
766
+ * and deletes the active run first. `interrupt`/`rollback` return
767
+ * `409 MULTITASK_INTERRUPT_CONFLICT` / `409 MULTITASK_ROLLBACK_CONFLICT` when
768
+ * more than one run is active.
769
+ */
770
+ multitaskStrategy?: "enqueue" | "reject" | "interrupt" | "rollback";
771
+ }
772
+ /** Result of creating a single run (durable pending queue entry). */
773
+ interface RunCreateResult {
774
+ runId: string;
775
+ /** Present for input runs; command runs do not create a user message. */
776
+ messageId?: string;
777
+ status: "pending";
778
+ }
779
+ /** Safe, client-facing projection of a run ledger record. */
780
+ interface RunRecord {
781
+ runId: string;
782
+ status: AgentRunStatus;
783
+ /** Null while the run is pending. */
784
+ owner: string | null;
785
+ attempts: number;
786
+ error: string | null;
787
+ cancelRequested: boolean;
788
+ createdAt: number;
789
+ updatedAt: number;
790
+ /** Null while the run is pending. */
791
+ startedAt: number | null;
792
+ finishedAt: number | null;
793
+ /** Input message id, when the run was created from a user message. */
794
+ messageId?: string | null;
795
+ /** Bounded preview of the queued user input. */
796
+ inputPreview?: string | null;
797
+ }
798
+ /** Result of cancelling every active run on a thread. */
799
+ interface RunCancelActiveResult {
800
+ success: boolean;
801
+ accepted: boolean;
802
+ cancelled: RunRecord[];
803
+ requested: RunRecord[];
804
+ failed: Array<{
805
+ runId: string;
806
+ code: string;
807
+ message: string;
808
+ }>;
809
+ }
810
+ /** Options for cancelling a run. */
811
+ interface RunCancelOptions {
812
+ /** Wait for the run to reach a terminal status (server caps the wait). */
813
+ wait?: boolean;
814
+ /**
815
+ * `interrupt` keeps the run and its checkpoints; `rollback` deletes the
816
+ * pending row or rewinds a running run's checkpoints and row.
817
+ */
818
+ action?: "interrupt" | "rollback";
819
+ }
820
+ /** Result of a run cancellation request. */
821
+ interface RunCancelResult {
822
+ success: boolean;
823
+ accepted: boolean;
824
+ /** `rolled_back` means the run row was deleted; no `run` is returned. */
825
+ status: AgentRunStatus | "requested" | "rolled_back";
826
+ terminal: boolean;
827
+ run?: RunRecord;
828
+ }
829
+ /** One projected thread event from the SSE event stream. */
830
+ interface ThreadEvent {
831
+ type: "event";
832
+ event_id: string;
833
+ seq: string;
834
+ method: string;
835
+ params: {
836
+ namespace: string[];
837
+ timestamp: number;
838
+ data: unknown;
839
+ node?: string;
840
+ };
841
+ }
842
+ /** Filters/resume cursor for the thread event stream. */
843
+ interface ThreadEventStreamOptions {
844
+ channels?: string[];
845
+ namespaces?: string[][];
846
+ depth?: number;
847
+ since?: string | number;
848
+ }
849
+ /** Error delivered to `streamThreadEvents` consumers. */
850
+ interface ThreadEventStreamError extends Error {
851
+ code?: string;
852
+ /** HTTP status for non-OK stream responses. */
853
+ status?: number;
854
+ /** Parsed JSON body for non-OK stream responses. */
855
+ responseBody?: unknown;
856
+ }
857
+ /** Public gateway identity, flags, capabilities, and endpoint paths. */
858
+ interface GatewayInfo {
859
+ service: "lattice-gateway";
860
+ version: string;
861
+ commit?: string;
862
+ startedAt: string;
863
+ uptimeSeconds: number;
864
+ flags: {
865
+ authRequired: boolean;
866
+ executionWorker: boolean;
867
+ chunkSource: "memory" | "redis";
868
+ multiReplica: boolean;
869
+ };
870
+ capabilities: {
871
+ a2a: boolean;
872
+ mcp: boolean;
873
+ store: boolean;
874
+ crons: boolean;
875
+ threadEvents: boolean;
876
+ threadEventsWebSocket: boolean;
877
+ metrics: boolean;
878
+ taskLifecycle: boolean;
879
+ };
880
+ endpoints: {
881
+ health: string;
882
+ /** Legacy public Prometheus endpoint; retained for monitoring. */
883
+ metrics: string;
884
+ /** Legacy public identity endpoint; retained for monitoring. */
885
+ info: string;
886
+ /** Platform-viewer-guarded equivalent of `info`. */
887
+ platformInfo?: string;
888
+ /** Platform-viewer-guarded JSON equivalent of `metrics`. */
889
+ platformMetrics?: string;
890
+ mcp: string;
891
+ store: string;
892
+ threadEvents: string;
893
+ a2aAgentCard: string;
894
+ a2aJsonRpc: string;
895
+ };
896
+ metadata: {
897
+ deployment?: string;
898
+ };
899
+ }
900
+ /** Agent run lifecycle status exposed by `/metrics`. */
901
+ type AgentRunStatus = "pending" | "running" | "success" | "error" | "interrupted" | "cancelled" | "timeout";
902
+ /** Execution worker posture exposed by `/metrics`. */
903
+ interface SystemMetricsWorker {
904
+ enabled: boolean;
905
+ started?: boolean;
906
+ inFlight?: number;
907
+ maxConcurrentThreads?: number;
908
+ scanIntervalMs?: number;
909
+ }
910
+ /** Chunk stream posture exposed by `/metrics`. */
911
+ interface SystemMetricsChunk {
912
+ source: "memory" | "redis";
913
+ ttlMs: number;
914
+ maxLen: number;
915
+ }
916
+ /** Point-in-time gateway posture returned by `/metrics?format=json`. */
917
+ interface SystemMetrics {
918
+ replicaId: string;
919
+ uptimeSeconds: number;
920
+ agentRuns?: Record<AgentRunStatus, number>;
921
+ pendingThreads?: number;
922
+ worker: SystemMetricsWorker;
923
+ chunk: SystemMetricsChunk;
924
+ }
925
+ /** Tenant-scoped namespaced store item. */
926
+ interface StoreItem {
927
+ namespace: string[];
928
+ key: string;
929
+ value: Record<string, unknown>;
930
+ createdAt: string;
931
+ updatedAt: string;
932
+ expiresAt?: string;
933
+ }
934
+ /** Create/replace input for a store item. */
935
+ interface StorePutInput {
936
+ namespace: string[];
937
+ key: string;
938
+ value: Record<string, unknown>;
939
+ ttlMinutes?: number;
940
+ index?: boolean | string[];
941
+ }
942
+ /** Search input for the tenant store. */
943
+ interface StoreSearchInput {
944
+ namespacePrefix?: string[];
945
+ filter?: Record<string, unknown>;
946
+ query?: string;
947
+ limit?: number;
948
+ offset?: number;
949
+ }
950
+ interface ScheduledTask {
951
+ /**
952
+ * Unique task identifier
953
+ */
954
+ taskId: string;
955
+ /**
956
+ * Type of the task (maps to registered handler)
957
+ */
958
+ taskType: string;
959
+ /**
960
+ * Task payload data
961
+ */
962
+ payload: Record<string, any>;
963
+ /**
964
+ * Assistant ID that owns this task
965
+ */
966
+ assistantId?: string;
967
+ /**
968
+ * Thread ID this task belongs to
969
+ */
970
+ threadId?: string;
971
+ /**
972
+ * Execution type (once or cron)
973
+ */
974
+ executionType: ScheduleExecutionType;
975
+ /**
976
+ * Timestamp when to execute (for ONCE type)
977
+ */
978
+ executeAt?: number;
979
+ /**
980
+ * Delay in milliseconds (for reference)
981
+ */
982
+ delayMs?: number;
983
+ /**
984
+ * Cron expression (for CRON type)
985
+ */
986
+ cronExpression?: string;
987
+ /**
988
+ * Timezone for cron execution
989
+ */
990
+ timezone?: string;
991
+ /**
992
+ * Next scheduled run time
993
+ */
994
+ nextRunAt?: number;
995
+ /**
996
+ * Last execution time
997
+ */
998
+ lastRunAt?: number;
999
+ /**
1000
+ * Current task status
1001
+ */
1002
+ status: ScheduledTaskStatus;
1003
+ /**
1004
+ * Number of times executed
1005
+ */
1006
+ runCount: number;
1007
+ /**
1008
+ * Maximum executions allowed
1009
+ */
1010
+ maxRuns?: number;
1011
+ /**
1012
+ * Current retry count
1013
+ */
1014
+ retryCount: number;
1015
+ /**
1016
+ * Maximum retry attempts
1017
+ */
1018
+ maxRetries: number;
1019
+ /**
1020
+ * Last error message
1021
+ */
1022
+ lastError?: string;
1023
+ /**
1024
+ * Creation timestamp
1025
+ */
1026
+ createdAt: number;
1027
+ /**
1028
+ * Last update timestamp
1029
+ */
1030
+ updatedAt: number;
1031
+ /**
1032
+ * Expiration timestamp
1033
+ */
1034
+ expiresAt?: number;
1035
+ /**
1036
+ * Additional metadata
1037
+ */
1038
+ metadata?: Record<string, any>;
1039
+ }
1040
+ /**
1041
+ * Options for getting scheduled tasks
1042
+ */
1043
+ interface GetScheduledTasksOptions {
1044
+ /**
1045
+ * Thread identifier
1046
+ */
1047
+ threadId: string;
1048
+ /**
1049
+ * Filter by status (optional)
1050
+ */
1051
+ status?: ScheduledTaskStatus;
1052
+ /**
1053
+ * Maximum number of tasks to return (optional)
1054
+ */
1055
+ limit?: number;
1056
+ /**
1057
+ * Offset for pagination (optional)
1058
+ */
1059
+ offset?: number;
1060
+ }
1061
+ /**
1062
+ * Scheduled tasks list response
1063
+ */
1064
+ interface ScheduledTasksListResponse {
1065
+ /**
1066
+ * Whether the operation was successful
1067
+ */
1068
+ success: boolean;
1069
+ /**
1070
+ * Response message
1071
+ */
1072
+ message: string;
1073
+ /**
1074
+ * Response data
1075
+ */
1076
+ data: {
1077
+ /**
1078
+ * List of scheduled tasks
1079
+ */
1080
+ records: ScheduledTask[];
1081
+ /**
1082
+ * Total count
1083
+ */
1084
+ total: number;
1085
+ };
1086
+ }
1087
+ /**
1088
+ * Storage type for workspace
1089
+ */
1090
+ type StorageType = "sandbox" | "filesystem";
1091
+ /**
1092
+ * Workspace information
1093
+ */
1094
+ interface Workspace {
1095
+ id: string;
1096
+ tenantId: string;
1097
+ name: string;
1098
+ description?: string;
1099
+ storageType: StorageType;
1100
+ createdAt: Date | string;
1101
+ updatedAt: Date | string;
1102
+ }
1103
+ /**
1104
+ * Create workspace request
1105
+ */
1106
+ interface CreateWorkspaceRequest {
1107
+ name: string;
1108
+ description?: string;
1109
+ storageType: StorageType;
1110
+ }
1111
+ /**
1112
+ * Update workspace request
1113
+ */
1114
+ interface UpdateWorkspaceRequest {
1115
+ name?: string;
1116
+ description?: string;
1117
+ storageType?: StorageType;
1118
+ }
1119
+ /**
1120
+ * Project kind classification
1121
+ *
1122
+ * Defaults to "business" for legacy data and omitted input.
1123
+ */
1124
+ type ProjectKind = "business" | "training" | "personal" | "public";
1125
+ /**
1126
+ * Project information
1127
+ */
1128
+ interface Project {
1129
+ id: string;
1130
+ tenantId: string;
1131
+ workspaceId: string;
1132
+ name: string;
1133
+ description?: string;
1134
+ /** Application-specific configuration stored as JSON */
1135
+ config?: Record<string, unknown>;
1136
+ /** Project classification; defaults to "business" when omitted */
1137
+ kind?: ProjectKind;
1138
+ createdAt: Date | string;
1139
+ updatedAt: Date | string;
1140
+ }
1141
+ /**
1142
+ * Create project request
1143
+ */
1144
+ interface CreateProjectRequest {
1145
+ name: string;
1146
+ description?: string;
1147
+ /** Application-specific configuration stored as JSON (optional) */
1148
+ config?: Record<string, unknown>;
1149
+ /** Project classification; defaults to "business" when omitted */
1150
+ kind?: ProjectKind;
1151
+ }
1152
+ /**
1153
+ * Update project request
1154
+ *
1155
+ * @remarks
1156
+ * - The `config` field uses **replace** semantics: if provided, it completely
1157
+ * overwrites the existing config. To preserve the current config, omit this field.
1158
+ */
1159
+ interface UpdateProjectRequest {
1160
+ name?: string;
1161
+ description?: string;
1162
+ /** Application-specific configuration stored as JSON (replaces existing if provided) */
1163
+ config?: Record<string, unknown>;
1164
+ /** Project classification */
1165
+ kind?: ProjectKind;
1166
+ }
1167
+ /**
1168
+ * File item in workspace
1169
+ */
1170
+ interface FileItem {
1171
+ path: string;
1172
+ name?: string;
1173
+ is_dir?: boolean;
1174
+ size?: number;
1175
+ modified_at?: string;
1176
+ created_at?: string;
1177
+ }
1178
+ interface ToolsListResponse {
1179
+ success: boolean;
1180
+ message: string;
1181
+ data: {
1182
+ records: Tool[];
1183
+ total: number;
1184
+ };
1185
+ }
1186
+ interface ToolResponse {
1187
+ success: boolean;
1188
+ message: string;
1189
+ data?: Tool;
1190
+ }
1191
+ interface DatabaseConfigsListResponse {
1192
+ success: boolean;
1193
+ message: string;
1194
+ data: {
1195
+ records: DatabaseConfigEntry[];
1196
+ total: number;
1197
+ };
1198
+ }
1199
+ interface DatabaseConfigResponse {
1200
+ success: boolean;
1201
+ message: string;
1202
+ data?: DatabaseConfigEntry;
1203
+ }
1204
+ interface TestConnectionResponse {
1205
+ success: boolean;
1206
+ message: string;
1207
+ data?: {
1208
+ connected: boolean;
1209
+ latency?: number;
1210
+ error?: string;
1211
+ };
1212
+ }
1213
+ interface MetricsConfigsListResponse {
1214
+ success: boolean;
1215
+ message: string;
1216
+ data: {
1217
+ records: MetricsServerConfigEntry[];
1218
+ total: number;
1219
+ };
1220
+ }
1221
+ interface MetricsConfigResponse {
1222
+ success: boolean;
1223
+ message: string;
1224
+ data?: MetricsServerConfigEntry;
1225
+ }
1226
+ interface DatasourcesListResponse {
1227
+ success: boolean;
1228
+ message: string;
1229
+ data?: {
1230
+ datasources: DataSource[];
1231
+ };
1232
+ }
1233
+ interface McpServersListResponse {
1234
+ success: boolean;
1235
+ message: string;
1236
+ data: {
1237
+ records: McpServerConfigEntry[];
1238
+ total: number;
1239
+ };
1240
+ }
1241
+ interface McpServerResponse {
1242
+ success: boolean;
1243
+ message: string;
1244
+ data?: McpServerConfigEntry;
1245
+ }
1246
+ interface TestMcpServerResponse {
1247
+ success: boolean;
1248
+ message: string;
1249
+ data?: {
1250
+ connected: boolean;
1251
+ latency?: number;
1252
+ error?: string;
1253
+ tools?: McpTool[];
1254
+ };
1255
+ }
1256
+ interface LocalA2ATemplatesListResponse {
1257
+ success: boolean;
1258
+ message?: string;
1259
+ data: {
1260
+ records: LocalA2ATemplateDefinition[];
1261
+ total: number;
1262
+ };
1263
+ }
1264
+ /**
1265
+ * A single A2A API key as returned by the management endpoints.
1266
+ *
1267
+ * The `key` value is masked in list responses (only the first 8 characters
1268
+ * followed by "..." are returned); only create/rotate responses expose the
1269
+ * full key value.
1270
+ */
1271
+ interface A2AKeyListItem {
1272
+ id: string;
1273
+ key: string;
1274
+ tenantId: string;
1275
+ projectId: string;
1276
+ assistantIds?: string[];
1277
+ /** Open-door grants (default-deny capability list). */
1278
+ grants?: OpenGrant[];
1279
+ label?: string;
1280
+ enabled: boolean;
1281
+ createdAt: string;
1282
+ updatedAt: string;
1283
+ }
1284
+ /** What an API key exposes to external callers. */
1285
+ interface KeyExposure {
1286
+ tenantId: string;
1287
+ projectId: string;
1288
+ grants: OpenGrant[];
1289
+ mcp: {
1290
+ endpoint: string;
1291
+ tools: Array<{
1292
+ domain: string;
1293
+ toolName: string;
1294
+ description: string;
1295
+ annotations: {
1296
+ readOnlyHint: boolean;
1297
+ destructiveHint: boolean;
1298
+ };
1299
+ /** This tool exposes an interactive MCP App UI resource over Open MCP. */
1300
+ hasUi?: boolean;
1301
+ }>;
1302
+ /**
1303
+ * Tenant sandbox plugin catalog could not be read; the listed tools are
1304
+ * global-only and tenant plugin tools are currently not exposed.
1305
+ */
1306
+ tenantCatalogDegraded?: boolean;
1307
+ };
1308
+ a2a: {
1309
+ agents: Array<{
1310
+ assistantId: string;
1311
+ cardUrl: string;
1312
+ jsonrpcUrl: string;
1313
+ /** A2A 1.0 Agent Card endpoint (same credential as the 0.3 endpoint). */
1314
+ v1CardUrl?: string;
1315
+ /** A2A 1.0 JSON-RPC endpoint. */
1316
+ v1JsonrpcUrl?: string;
1317
+ card: Record<string, unknown>;
1318
+ }>;
1319
+ };
1320
+ }
1321
+ /** Open audit log record as returned over JSON (dates are ISO strings). */
1322
+ type OpenAuditLogRecord = Omit<_axiom_lattice_protocols.OpenAuditRecord, "createdAt"> & {
1323
+ createdAt: string;
1324
+ };
1325
+ /**
1326
+ * Input for creating a new A2A API key.
1327
+ */
1328
+ interface CreateA2AKeyInput {
1329
+ tenantId: string;
1330
+ projectId: string;
1331
+ assistantIds?: string[];
1332
+ /** Open-door grants; omit for legacy assistant-only keys. */
1333
+ grants?: OpenGrant[];
1334
+ label?: string;
1335
+ }
1336
+ /**
1337
+ * A2A API key list response (already unwrapped from `{ success, data }`).
1338
+ */
1339
+ interface A2AKeysListResponse {
1340
+ records: A2AKeyListItem[];
1341
+ total: number;
1342
+ }
1343
+ /**
1344
+ * Options for removing a pending message
1345
+ */
1346
+ interface RemovePendingMessageOptions {
1347
+ /**
1348
+ * Assistant identifier
1349
+ */
1350
+ assistantId: string;
1351
+ /**
1352
+ * Thread identifier
1353
+ */
1354
+ threadId: string;
1355
+ /**
1356
+ * Message identifier
1357
+ */
1358
+ messageId: string;
1359
+ }
1360
+ /**
1361
+ * Options for aborting agent execution
1362
+ */
1363
+ interface AbortAgentParams {
1364
+ /**
1365
+ * Assistant identifier
1366
+ */
1367
+ assistantId: string;
1368
+ /**
1369
+ * Thread identifier
1370
+ */
1371
+ threadId: string;
1372
+ }
1373
+ interface TasksListResponse {
1374
+ success: boolean;
1375
+ data?: TaskItem[];
1376
+ count?: number;
1377
+ error?: string;
1378
+ }
1379
+ interface TaskResponse {
1380
+ success: boolean;
1381
+ data?: TaskItem;
1382
+ error?: string;
1383
+ }
1384
+ /** A recoverable lifecycle evidence write failure returned with task completion. */
1385
+ interface TaskLifecycleWarning {
1386
+ code: string;
1387
+ taskId: string;
1388
+ evidenceId?: string;
1389
+ eventKey?: string;
1390
+ parentTaskId?: string;
1391
+ }
1392
+ /** The full response envelope returned by the task completion endpoint. */
1393
+ interface CompleteTaskResponse extends TaskResponse {
1394
+ evidenceId?: string;
1395
+ eventKey?: string;
1396
+ warnings?: TaskLifecycleWarning[];
1397
+ }
1398
+ /** A human-issued project task command. */
1399
+ interface TaskCommandInput {
1400
+ type: "start" | "cancel" | "retry" | "reopen" | "reassign" | "delete" | "comment";
1401
+ commandId?: string;
1402
+ expectedUpdatedAt?: string;
1403
+ payload?: Record<string, unknown>;
1404
+ }
1405
+ /** The full response envelope returned by the task command endpoint. */
1406
+ interface TaskCommandResponse extends TaskResponse {
1407
+ warnings?: TaskLifecycleWarning[];
1408
+ }
1409
+ /**
1410
+ * A single parsed Server-Sent Events payload yielded by `Client.streamEvents`.
1411
+ */
1412
+ interface StreamEvent {
1413
+ event: string;
1414
+ data: Record<string, unknown>;
1415
+ }
1416
+
1417
+ /** Completion evidence accepted by the task lifecycle endpoint. */
1418
+ interface CompleteTaskInput {
1419
+ result: string;
1420
+ beliefImpact?: Array<{
1421
+ key: string;
1422
+ after: number;
1423
+ basis: string;
1424
+ }>;
1425
+ }
1426
+
1427
+ /**
1428
+ * Abstract client class for interacting with the Axiom Lattice Agent Service API
1429
+ * Provides common functionality for different client implementations
1430
+ */
1431
+ declare abstract class AbstractClient {
1432
+ protected config: ClientConfig;
1433
+ assistantId: string;
1434
+ tenantId: string;
1435
+ protected registeredTools: Map<string, RegisterToolOptions>;
1436
+ private onUnauthorizedHandler?;
1437
+ private hydrateAgentWebApp;
1438
+ /**
1439
+ * Server tools namespace for managing tools via API
1440
+ */
1441
+ serverTools: {
1442
+ list: () => Promise<Tool[]>;
1443
+ get: (id: string) => Promise<Tool>;
1444
+ create: (data: any) => Promise<Tool>;
1445
+ update: (id: string, data: any) => Promise<Tool>;
1446
+ delete: (id: string) => Promise<void>;
1447
+ };
1448
+ /**
1449
+ * Database configurations namespace for managing database connections
1450
+ */
1451
+ databaseConfigs: {
1452
+ list: () => Promise<DatabaseConfigEntry[]>;
1453
+ get: (id: string) => Promise<DatabaseConfigEntry>;
1454
+ create: (data: CreateDatabaseConfigRequest) => Promise<DatabaseConfigEntry>;
1455
+ update: (id: string, data: UpdateDatabaseConfigRequest) => Promise<DatabaseConfigEntry>;
1456
+ delete: (id: string) => Promise<void>;
1457
+ test: (id: string) => Promise<TestConnectionResponse>;
1458
+ };
1459
+ /**
1460
+ * Tenant-scoped model provider catalog. Writes require a tenant owner/admin.
1461
+ */
1462
+ modelProviders: {
1463
+ list: () => Promise<ModelProviderPublicEntry[]>;
1464
+ get: (id: string) => Promise<ModelProviderPublicEntry>;
1465
+ create: (data: CreateModelProviderRequest) => Promise<ModelProviderPublicEntry>;
1466
+ update: (id: string, data: UpdateModelProviderRequest) => Promise<ModelProviderPublicEntry>;
1467
+ delete: (id: string) => Promise<void>;
1468
+ /** Probe a base URL + API key that may not be saved yet. */
1469
+ probe: (data: ModelProviderProbeRequest) => Promise<ModelProviderProbeResult>;
1470
+ /** Replace this provider's model set with exactly these models. */
1471
+ setModels: (id: string, models: ModelSelection[]) => Promise<ModelProviderPublicEntry>;
1472
+ discover: (id: string) => Promise<ModelDiscoveryResult>;
1473
+ setModelEnabled: (id: string, modelId: string, enabled: boolean) => Promise<ModelProviderPublicEntry>;
1474
+ };
1475
+ /**
1476
+ * Models visible to the current tenant, from discovery snapshots and the
1477
+ * in-memory registry.
1478
+ */
1479
+ tenantModels: {
1480
+ list: () => Promise<TenantModelCatalog>;
1481
+ };
1482
+ /**
1483
+ * Metrics server configurations namespace for managing metrics servers
1484
+ */
1485
+ metricsConfigs: {
1486
+ list: () => Promise<MetricsServerConfigEntry[]>;
1487
+ get: (id: string) => Promise<MetricsServerConfigEntry>;
1488
+ create: (data: CreateMetricsServerConfigRequest) => Promise<MetricsServerConfigEntry>;
1489
+ update: (id: string, data: UpdateMetricsServerConfigRequest) => Promise<MetricsServerConfigEntry>;
1490
+ delete: (id: string) => Promise<void>;
1491
+ test: (id: string) => Promise<TestConnectionResponse>;
1492
+ getDatasources: (id: string) => Promise<DataSource[]>;
1493
+ };
1494
+ /**
1495
+ * MCP server configurations namespace for managing MCP servers
1496
+ */
1497
+ mcpServers: {
1498
+ list: () => Promise<McpServerConfigEntry[]>;
1499
+ get: (id: string) => Promise<McpServerConfigEntry>;
1500
+ create: (data: CreateMcpServerConfigRequest) => Promise<McpServerConfigEntry>;
1501
+ update: (id: string, data: UpdateMcpServerConfigRequest) => Promise<McpServerConfigEntry>;
1502
+ delete: (id: string) => Promise<void>;
1503
+ test: (id: string) => Promise<TestMcpServerResponse>;
1504
+ connect: (id: string) => Promise<McpServerConfigEntry>;
1505
+ disconnect: (id: string) => Promise<McpServerConfigEntry>;
1506
+ };
1507
+ /**
1508
+ * Personal-assistant MCP namespace. Same shape as {@link mcpServers} but
1509
+ * scoped to the caller's own personal assistant; the server resolves the
1510
+ * assistant from the authenticated user, so no assistant id is accepted.
1511
+ *
1512
+ * Every single-entry method accepts either the business `key` or the
1513
+ * config `id`.
1514
+ */
1515
+ personalMcpServers: {
1516
+ list: () => Promise<McpServerConfigEntry[]>;
1517
+ get: (keyOrId: string) => Promise<McpServerConfigEntry>;
1518
+ create: (data: CreateMcpServerConfigRequest) => Promise<McpServerConfigEntry>;
1519
+ update: (keyOrId: string, data: UpdateMcpServerConfigRequest) => Promise<McpServerConfigEntry>;
1520
+ delete: (keyOrId: string) => Promise<void>;
1521
+ test: (keyOrId: string) => Promise<TestMcpServerResponse>;
1522
+ connect: (keyOrId: string) => Promise<McpServerConfigEntry>;
1523
+ disconnect: (keyOrId: string) => Promise<McpServerConfigEntry>;
1524
+ };
1525
+ /**
1526
+ * Connections namespace for managing plugin connections
1527
+ */
1528
+ connections: {
1529
+ list: (type: string) => Promise<ConnectionEntry[]>;
1530
+ create: (data: {
1531
+ type: string;
1532
+ key: string;
1533
+ name: string;
1534
+ description?: string;
1535
+ config: Record<string, unknown>;
1536
+ }) => Promise<{
1537
+ success: boolean;
1538
+ data: ConnectionEntry;
1539
+ }>;
1540
+ update: (type: string, key: string, data: Record<string, unknown>) => Promise<{
1541
+ success: boolean;
1542
+ data: ConnectionEntry;
1543
+ }>;
1544
+ delete: (type: string, key: string) => Promise<void>;
1545
+ };
1546
+ /**
1547
+ * Tasks namespace for managing tasks
1548
+ */
1549
+ tasks: {
1550
+ list: (params?: Record<string, string>) => Promise<TaskItem[]>;
1551
+ get: (id: string) => Promise<TaskItem>;
1552
+ create: (data: CreateTaskRequest) => Promise<TaskItem>;
1553
+ update: (id: string, data: UpdateTaskRequest) => Promise<TaskItem>;
1554
+ delete: (id: string) => Promise<void>;
1555
+ complete: (id: string, data: CompleteTaskInput) => Promise<CompleteTaskResponse>;
1556
+ command: (id: string, input: TaskCommandInput) => Promise<TaskCommandResponse>;
1557
+ workItems: {
1558
+ list: (taskId: string, params?: {
1559
+ action?: string;
1560
+ limit?: number;
1561
+ offset?: number;
1562
+ }) => Promise<TaskWorkItem[]>;
1563
+ };
1564
+ };
1565
+ /**
1566
+ * Menu namespace for managing custom menu items
1567
+ */
1568
+ menu: {
1569
+ list: (menuTarget?: string) => Promise<any[]>;
1570
+ get: (id: string) => Promise<any>;
1571
+ create: (data: any) => Promise<any>;
1572
+ update: (id: string, data: any) => Promise<any>;
1573
+ delete: (id: string) => Promise<void>;
1574
+ };
1575
+ /**
1576
+ * Set handler for 401 unauthorized errors
1577
+ * @param handler - Callback function to handle unauthorized errors
1578
+ */
1579
+ setUnauthorizedHandler(handler: () => void): void;
1580
+ /**
1581
+ * Get the unauthorized handler
1582
+ * @returns The handler function or undefined
1583
+ */
1584
+ protected getUnauthorizedHandler(): (() => void) | undefined;
1585
+ /**
1586
+ * Creates a new AbstractClient instance
1587
+ * @param config - Configuration options for the client
1588
+ */
1589
+ constructor(config: ClientConfig);
1590
+ /**
1591
+ * Make a generic API request
1592
+ * Exposed as public for advanced use cases
1593
+ * @param url - The URL to make the request to
1594
+ * @param options - Request options
1595
+ * @returns A promise that resolves to the response data
1596
+ */
1597
+ request<T>(url: string, options?: {
1598
+ method?: string;
1599
+ body?: any;
1600
+ headers?: Record<string, string>;
1601
+ }): Promise<T>;
1602
+ /**
1603
+ * Set tenant ID for multi-tenant environments
1604
+ * @param tenantId - Tenant identifier
1605
+ */
1606
+ abstract setTenantId(tenantId: string): void;
1607
+ /**
1608
+ * Set assistant ID for the client
1609
+ * @param assistantId - Assistant identifier
1610
+ */
1611
+ setAssistantId(assistantId: string): void;
1612
+ /**
1613
+ * Workspace/project headers for THIS instance. Clones share this object
1614
+ * with their parent (see {@link clone}), so workspace-context changes on
1615
+ * any client of the same family propagate to all sibling clones — e.g.
1616
+ * a scoped WorkspaceContextProvider syncing the "__GLOBAL__" client also
1617
+ * updates every per-assistant chat client created from the same base.
1618
+ */
1619
+ protected workspaceHeaders: Record<string, string>;
1620
+ /**
1621
+ * Creates a new instance of the client with the given configuration
1622
+ * @param config - Configuration options for the client
1623
+ * @returns A new instance of the client
1624
+ */
1625
+ protected abstract createInstance(config: ClientConfig): AbstractClient;
1626
+ /**
1627
+ * Creates a clone of the current client instance
1628
+ * @param overrides - Optional configuration overrides for the cloned client
1629
+ * @returns A new client instance with the same configuration and state
1630
+ */
1631
+ clone(overrides?: Partial<ClientConfig>): AbstractClient;
1632
+ /**
1633
+ * Headers for thread event SSE requests. Concrete clients may add live
1634
+ * tenant/workspace/auth state.
1635
+ *
1636
+ * @returns Request headers.
1637
+ */
1638
+ protected getThreadEventHeaders(): Record<string, string>;
1639
+ /**
1640
+ * Stream thread-wide projected events over SSE.
1641
+ *
1642
+ * The caller owns reconnection: pass the last `event.seq` as `since`.
1643
+ * There is no automatic retry. Browser WebSocket auth is not covered here;
1644
+ * this SSE path uses `fetch` and the normal Authorization headers.
1645
+ *
1646
+ * @param threadId - Thread id.
1647
+ * @param options - Channel/namespace/depth filters and resume cursor.
1648
+ * @param onEvent - Callback for each projected event.
1649
+ * @param onError - Callback for stream/cursor errors (stream stops).
1650
+ * @returns Abort function.
1651
+ */
1652
+ streamThreadEvents(threadId: string, options: ThreadEventStreamOptions, onEvent: (event: ThreadEvent) => void, onError?: (error: ThreadEventStreamError) => void): () => void;
1653
+ /**
1654
+ * Abstract method for making API requests
1655
+ * To be implemented by concrete client classes
1656
+ */
1657
+ protected abstract makeRequest<T>(url: string, options?: {
1658
+ method?: string;
1659
+ body?: any;
1660
+ headers?: Record<string, string>;
1661
+ }): Promise<T>;
1662
+ /**
1663
+ * Abstract method for streaming API requests
1664
+ * To be implemented by concrete client classes
1665
+ */
1666
+ /**
1667
+ * Helper method to build stream request parameters
1668
+ * @param options - Options for running the agent
1669
+ * @returns The formatted request parameters
1670
+ */
1671
+ protected buildStreamRequestParams(options: RunOptions): {
1672
+ url: string;
1673
+ method: string;
1674
+ body: any;
1675
+ };
1676
+ protected abstract streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
1677
+ /**
1678
+ * Creates a new thread
1679
+ * @deprecated Use threads.create() instead
1680
+ * @param options - Options for creating a thread
1681
+ * @returns A promise that resolves to the thread ID
1682
+ */
1683
+ createThread(options: CreateThreadOptions): Promise<string>;
1684
+ /**
1685
+ * Retrieves thread information
1686
+ * @deprecated Use threads.get() instead
1687
+ * @param threadId - Thread identifier
1688
+ * @returns A promise that resolves to the thread information
1689
+ */
1690
+ getThread(threadId: string): Promise<Thread>;
1691
+ /**
1692
+ * Lists all threads
1693
+ * @deprecated Use threads.list() instead
1694
+ * @param options - Options for listing threads
1695
+ * @returns A promise that resolves to an array of threads
1696
+ */
1697
+ listThreads(options?: ListThreadsOptions): Promise<Thread[]>;
1698
+ /**
1699
+ * Reads a thread's run status, pending message count, and interrupts.
1700
+ * @param threadId - Thread identifier.
1701
+ * @returns Thread status projection.
1702
+ */
1703
+ getThreadStatus(threadId: string): Promise<ThreadStatusInfo>;
1704
+ /**
1705
+ * Reads a page of thread checkpoint history.
1706
+ * @param threadId - Thread identifier.
1707
+ * @param options - Optional limit and before-checkpoint cursor.
1708
+ * @returns Checkpoint snapshots, newest first.
1709
+ */
1710
+ getThreadHistory(threadId: string, options?: {
1711
+ limit?: number;
1712
+ before?: string;
1713
+ }): Promise<unknown[]>;
1714
+ /**
1715
+ * Reads the raw snapshot at one checkpoint.
1716
+ * @param threadId - Thread identifier.
1717
+ * @param checkpointId - Checkpoint identifier.
1718
+ * @returns The raw checkpoint snapshot.
1719
+ */
1720
+ getThreadStateAtCheckpoint(threadId: string, checkpointId: string): Promise<unknown>;
1721
+ /**
1722
+ * Reads checkpoint storage accounting for a thread.
1723
+ * @param threadId - Thread identifier.
1724
+ * @returns Storage byte/count projection.
1725
+ */
1726
+ getThreadStorage(threadId: string): Promise<ThreadCheckpointStorage>;
1727
+ /**
1728
+ * Copies a thread's checkpoints and row into a new thread.
1729
+ * @param threadId - Source thread identifier.
1730
+ * @returns The created thread.
1731
+ */
1732
+ copyThread(threadId: string): Promise<CopiedThread>;
1733
+ /**
1734
+ * Prunes a thread's checkpoints or deletes the thread.
1735
+ * @param threadId - Thread identifier.
1736
+ * @param input - Prune strategy and optional keep count.
1737
+ * @returns Prune result.
1738
+ */
1739
+ pruneThread(threadId: string, input: PruneThreadInput): Promise<PruneThreadResult>;
1740
+ /**
1741
+ * Reads the public gateway info surface.
1742
+ * @returns Service identity, flags, capabilities, endpoints, and metadata.
1743
+ */
1744
+ getInfo(): Promise<GatewayInfo>;
1745
+ /**
1746
+ * Reads the current gateway replica's runtime metrics.
1747
+ * @returns Run counts, pending threads, worker posture, and chunk posture.
1748
+ */
1749
+ getSystemMetrics(): Promise<SystemMetrics>;
1750
+ /**
1751
+ * Deletes a thread
1752
+ * @deprecated Use threads.delete() instead
1753
+ * @param threadId - Thread identifier
1754
+ * @returns A promise that resolves when the thread is deleted
1755
+ */
1756
+ deleteThread(threadId: string): Promise<void>;
1757
+ /**
1758
+ * Retrieves messages from a thread
1759
+ * @param options - Options for retrieving messages
1760
+ * @returns A promise that resolves to an array of messages
1761
+ */
1762
+ getMessages(options: GetMessagesOptions): Promise<Message[]>;
1763
+ /**
1764
+ * Retrieves agent state
1765
+ * @param threadId - Thread identifier
1766
+ * @returns A promise that resolves to the agent state
1767
+ */
1768
+ getAgentState(threadId: string): Promise<AgentState>;
1769
+ /**
1770
+ * Gets agent graph visualization
1771
+ * @returns A promise that resolves to the graph visualization data
1772
+ */
1773
+ getAgentGraph(): Promise<string>;
1774
+ /**
1775
+ * Run agent with options
1776
+ * @param options - Options for running the agent
1777
+ * @returns A promise that resolves to the run result
1778
+ */
1779
+ run(options: RunOptions): Promise<ChatResponse>;
1780
+ /**
1781
+ * Chat namespace for sending messages and streaming responses
1782
+ */
1783
+ chat: {
1784
+ /**
1785
+ * Sends a message to a thread and receives a response
1786
+ * @param options - Options for sending a message
1787
+ * @returns A promise that resolves to the chat response
1788
+ */
1789
+ send: (options: ChatSendOptions) => Promise<ChatResponse>;
1790
+ /**
1791
+ * Enqueues a message into the thread's background queue without waiting for a response.
1792
+ * Uses the background flag so the server returns 202 immediately.
1793
+ * Response chunks are delivered through the shared ThreadStream SSE connection.
1794
+ * @param options - Options for the background message
1795
+ * @returns A promise resolving to the enqueued message ID
1796
+ */
1797
+ sendBackground: (options: ChatSendOptions) => Promise<{
1798
+ messageId: string;
1799
+ queued: boolean;
1800
+ runId?: string;
1801
+ }>;
1802
+ /**
1803
+ * Sends a message to a thread and streams the response
1804
+ * @param options - Options for streaming a message
1805
+ * @param onEvent - Callback function that receives stream events
1806
+ * @param onComplete - Optional callback function called when streaming completes
1807
+ * @param onError - Optional callback function called when an error occurs
1808
+ * @returns A function that can be called to stop the stream
1809
+ */
1810
+ stream: (options: ChatStreamOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void) => (() => void);
1811
+ /**
1812
+ * Remove a pending message from the queue
1813
+ * @param options - Options for removing the message
1814
+ * @returns Promise with success status
1815
+ */
1816
+ removePendingMessage: (options: RemovePendingMessageOptions) => Promise<{
1817
+ success: boolean;
1818
+ }>;
1819
+ /**
1820
+ * Abort agent execution for a thread
1821
+ * @param params - Parameters for aborting
1822
+ * @returns Promise with success status
1823
+ */
1824
+ abort: (params: AbortAgentParams) => Promise<{
1825
+ success: boolean;
1826
+ message: string;
1827
+ }>;
1828
+ };
1829
+ /**
1830
+ * Resume streaming from a known position
1831
+ * @param options - Options for resuming the stream
1832
+ * @param onEvent - Callback function that receives stream events
1833
+ * @param onComplete - Optional callback function called when streaming completes
1834
+ * @param onError - Optional callback function called when an error occurs
1835
+ * @returns A function that can be called to stop the stream
1836
+ */
1837
+ abstract resumeStream(options: ResumeStreamOptions, onEvent: (event: MessageChunk) => void, onComplete?: () => void, onError?: (error: Error) => void): () => void;
1838
+ /**
1839
+ * Tools namespace for registering and unregistering client-side tools
1840
+ */
1841
+ tools: {
1842
+ /**
1843
+ * Registers a client-side tool
1844
+ * @param options - Options for registering a tool
1845
+ */
1846
+ register: (options: RegisterToolOptions) => void;
1847
+ /**
1848
+ * Unregisters a client-side tool
1849
+ * @param name - Tool name
1850
+ */
1851
+ unregister: (name: string) => void;
1852
+ };
1853
+ /**
1854
+ * Assistants namespace for managing assistants
1855
+ */
1856
+ assistants: {
1857
+ /**
1858
+ * Lists all available assistants
1859
+ * Returns both code-configured and stored assistants
1860
+ * @returns A promise that resolves to the list of assistants
1861
+ */
1862
+ list: () => Promise<Assistant[]>;
1863
+ /**
1864
+ * Retrieves a single assistant by ID
1865
+ * Checks both code-configured and stored assistants
1866
+ * @param id - Assistant identifier
1867
+ * @returns A promise that resolves to the assistant information
1868
+ */
1869
+ get: (id: string) => Promise<Assistant>;
1870
+ /**
1871
+ * Creates a new assistant
1872
+ * Only creates stored assistants (code-configured assistants cannot be created via API)
1873
+ * @param options - Options for creating an assistant
1874
+ * @returns A promise that resolves to the created assistant
1875
+ */
1876
+ create: (options: CreateAssistantOptions) => Promise<Assistant>;
1877
+ /**
1878
+ * Updates an existing assistant by ID
1879
+ * Only works on stored assistants (code-configured assistants cannot be updated)
1880
+ * @param id - Assistant identifier
1881
+ * @param options - Options for updating an assistant
1882
+ * @returns A promise that resolves to the updated assistant
1883
+ */
1884
+ update: (id: string, options: UpdateAssistantOptions) => Promise<Assistant>;
1885
+ /**
1886
+ * Deletes an assistant by ID
1887
+ * Only works on stored assistants (code-configured assistants cannot be deleted)
1888
+ * @param id - Assistant identifier
1889
+ * @returns A promise that resolves when the assistant is deleted
1890
+ */
1891
+ delete: (id: string) => Promise<void>;
1892
+ localA2A: {
1893
+ list: () => Promise<LocalA2AProviderState[]>;
1894
+ get: (assistantId: string) => Promise<LocalA2AProviderState>;
1895
+ start: (assistantId: string) => Promise<LocalA2AProviderState>;
1896
+ stop: (assistantId: string) => Promise<LocalA2AProviderState>;
1897
+ restart: (assistantId: string) => Promise<LocalA2AProviderState>;
1898
+ templates: {
1899
+ list: () => Promise<LocalA2ATemplateDefinition[]>;
1900
+ };
1901
+ };
1902
+ };
1903
+ /**
1904
+ * A2A API keys namespace for managing A2A API keys
1905
+ */
1906
+ /** Open API surface helpers (capability catalog for the key picker). */
1907
+ open: {
1908
+ /**
1909
+ * Fetch the grantable capability catalog for the current tenant.
1910
+ * Drives the key-management grants picker.
1911
+ */
1912
+ catalog: () => Promise<OpenCatalog>;
1913
+ /**
1914
+ * Fetch what a key exposes (MCP tools + A2A agent cards).
1915
+ * @param id - Key identifier
1916
+ */
1917
+ exposure: (id: string) => Promise<KeyExposure>;
1918
+ /**
1919
+ * Query the tenant's Open audit log (newest first).
1920
+ * @param params - Optional credential/domain/status/time filters and pagination
1921
+ */
1922
+ auditLogs: (params?: {
1923
+ credentialId?: string;
1924
+ domain?: string;
1925
+ status?: "ok" | "error";
1926
+ from?: string;
1927
+ to?: string;
1928
+ limit?: number;
1929
+ offset?: number;
1930
+ }) => Promise<OpenAuditLogRecord[]>;
1931
+ };
1932
+ /**
1933
+ * MCP Apps namespace for resolving UI resources and proxying allow-listed
1934
+ * JSON-RPC calls to the owning MCP server.
1935
+ */
1936
+ mcpApps: {
1937
+ /**
1938
+ * Resolve a UI resource for an MCP App ref.
1939
+ * @param ref - Parsed UI ref from the `mcp_app` content fence.
1940
+ * @returns The resolved resource plus its ready-to-use CSP policy string.
1941
+ */
1942
+ getResource: (ref: McpUiRef) => Promise<McpUiResourceResponse>;
1943
+ /**
1944
+ * Proxy an allow-listed JSON-RPC method for an MCP App ref.
1945
+ * @param ref - Parsed UI ref from the `mcp_app` content fence.
1946
+ * @param method - JSON-RPC method (`tools/call`, `tools/list`, `resources/read`).
1947
+ * @param params - JSON-RPC params forwarded to the backend.
1948
+ * @returns The raw backend result.
1949
+ */
1950
+ rpc: (ref: McpUiRef, method: string, params: Record<string, unknown>) => Promise<unknown>;
1951
+ };
1952
+ /**
1953
+ * @deprecated Use {@link open} / `/api/keys`; kept as a compatibility alias.
1954
+ */
1955
+ a2aKeys: {
1956
+ /**
1957
+ * Lists A2A API keys, optionally filtered by tenant
1958
+ * Key values are masked in list responses
1959
+ * @param params - Optional tenant filter and pagination
1960
+ * @returns A promise that resolves to the list of key records and total
1961
+ */
1962
+ list: (params?: {
1963
+ tenantId?: string;
1964
+ limit?: number;
1965
+ offset?: number;
1966
+ }) => Promise<A2AKeysListResponse>;
1967
+ /**
1968
+ * Creates a new A2A API key
1969
+ * The full key value is returned only from this call
1970
+ * @param input - Key creation input (tenant, project, optional assistant whitelist and label)
1971
+ * @returns A promise that resolves to the created key record (full key value)
1972
+ */
1973
+ create: (input: CreateA2AKeyInput) => Promise<A2AKeyListItem>;
1974
+ /**
1975
+ * Updates mutable fields (label, project, assistants, grants) of an existing key.
1976
+ * @param id - Key identifier
1977
+ * @param input - Fields to update (only provided fields change)
1978
+ * @returns A promise that resolves to the updated key record
1979
+ */
1980
+ update: (id: string, input: Partial<CreateA2AKeyInput>) => Promise<A2AKeyListItem>;
1981
+ /**
1982
+ * Permanently deletes an A2A API key
1983
+ * @param id - Key identifier
1984
+ * @returns A promise that resolves when the key is deleted
1985
+ */
1986
+ delete: (id: string) => Promise<void>;
1987
+ /**
1988
+ * Disables an A2A API key
1989
+ * @param id - Key identifier
1990
+ * @returns A promise that resolves to the updated key record
1991
+ */
1992
+ disable: (id: string) => Promise<A2AKeyListItem>;
1993
+ /**
1994
+ * Enables a previously disabled A2A API key
1995
+ * @param id - Key identifier
1996
+ * @returns A promise that resolves to the updated key record
1997
+ */
1998
+ enable: (id: string) => Promise<A2AKeyListItem>;
1999
+ /**
2000
+ * Rotates an A2A API key, generating a new key value
2001
+ * The full new key value is returned only from this call
2002
+ * @param id - Key identifier
2003
+ * @returns A promise that resolves to the updated key record (full new key value)
2004
+ */
2005
+ rotate: (id: string) => Promise<A2AKeyListItem>;
2006
+ };
2007
+ /** Capability bundle namespace for managing tenant-scoped bundles. */
2008
+ capabilityBundles: {
2009
+ /**
2010
+ * List all capability bundles visible to the current tenant.
2011
+ * @returns The tenant's capability bundles, unwrapped from the API response.
2012
+ */
2013
+ list: () => Promise<CapabilityBundle[]>;
2014
+ /**
2015
+ * List valid bundles together with safe invalid-record summaries.
2016
+ * @returns Inventory suitable for management and remediation workflows.
2017
+ */
2018
+ listInventory: () => Promise<CapabilityBundleListResponse>;
2019
+ /**
2020
+ * Get one capability bundle by identifier.
2021
+ * @param bundleId - Capability bundle identifier.
2022
+ * @returns The requested capability bundle.
2023
+ */
2024
+ get: (bundleId: string) => Promise<CapabilityBundle>;
2025
+ /**
2026
+ * Create a capability bundle for the current tenant.
2027
+ * @param input - Bundle name, optional description, and capabilities. The server generates the stable key.
2028
+ * @returns The created capability bundle.
2029
+ */
2030
+ create: (input: CreateCapabilityBundleInput) => Promise<CapabilityBundle>;
2031
+ /**
2032
+ * Update a capability bundle for the current tenant.
2033
+ * @param bundleId - Capability bundle identifier.
2034
+ * @param input - The partial bundle fields and required expected revision to update.
2035
+ * @returns The updated capability bundle.
2036
+ */
2037
+ update: (bundleId: string, input: UpdateCapabilityBundleInput) => Promise<CapabilityBundle>;
2038
+ /**
2039
+ * Delete a capability bundle when the backend permits deletion.
2040
+ * @param bundleId - Capability bundle identifier.
2041
+ * @returns A promise that resolves after the bundle is deleted.
2042
+ * @throws ApiError when the bundle is missing, in use, or the request fails.
2043
+ */
2044
+ delete: (bundleId: string) => Promise<void>;
2045
+ };
2046
+ projects: {
2047
+ capabilities: {
2048
+ /**
2049
+ * Get a project's selected bundles and its persisted capability preview.
2050
+ * @param projectId - Project identifier.
2051
+ * @returns The project, selected bundles, and preview resolved from persisted selections.
2052
+ */
2053
+ get: (projectId: string) => Promise<ProjectCapabilitiesResponse>;
2054
+ /**
2055
+ * Replace a project's selected capability bundles.
2056
+ * @param projectId - Project identifier.
2057
+ * @param bundleIds - Ordered capability bundle identifiers to persist.
2058
+ * @returns The updated project, selected bundles, and persisted-selection preview.
2059
+ */
2060
+ update: (projectId: string, bundleIds: string[], expectedRevisions: Record<string, string>) => Promise<ProjectCapabilitiesResponse>;
2061
+ /**
2062
+ * Preview the capability bundles currently persisted on a project.
2063
+ * @param projectId - Project identifier.
2064
+ * @returns The preview resolved from the project's persisted bundle selections.
2065
+ */
2066
+ preview: (projectId: string) => Promise<CapabilityPreview>;
2067
+ /**
2068
+ * Preview a draft bundle selection without changing the project.
2069
+ * @param projectId - Project identifier.
2070
+ * @param bundleIds - Ordered capability bundle identifiers to preview.
2071
+ * @returns The draft preview resolved from the supplied bundle IDs; no project state is changed.
2072
+ */
2073
+ previewWithBundles: (projectId: string, bundleIds: string[]) => Promise<CapabilityPreview>;
2074
+ };
2075
+ };
2076
+ /** Agent Web Apps namespace for managing React SDK publications. */
2077
+ webApps: {
2078
+ /**
2079
+ * Lists Agent Web Apps, optionally filtered by assistant.
2080
+ * @param params - Optional assistant filter
2081
+ * @returns A promise that resolves to the publication records and total
2082
+ */
2083
+ list: (params?: ListAgentWebAppsParams) => Promise<AgentWebAppsListResponse>;
2084
+ /**
2085
+ * Retrieves an Agent Web App by ID.
2086
+ * @param id - Agent Web App identifier
2087
+ * @returns A promise that resolves to the publication
2088
+ */
2089
+ get: (id: string) => Promise<AgentWebApp>;
2090
+ /**
2091
+ * Creates an Agent Web App.
2092
+ * @param input - Publication configuration
2093
+ * @returns A promise that resolves to the created publication
2094
+ */
2095
+ create: (input: CreateAgentWebAppInput) => Promise<AgentWebApp>;
2096
+ /**
2097
+ * Updates editable fields on an Agent Web App.
2098
+ * @param id - Agent Web App identifier
2099
+ * @param input - Fields to update
2100
+ * @returns A promise that resolves to the updated publication
2101
+ */
2102
+ update: (id: string, input: UpdateAgentWebAppInput) => Promise<AgentWebApp>;
2103
+ /**
2104
+ * Enables an Agent Web App.
2105
+ * @param id - Agent Web App identifier
2106
+ * @returns A promise that resolves to the enabled publication
2107
+ */
2108
+ enable: (id: string) => Promise<AgentWebApp>;
2109
+ /**
2110
+ * Disables an Agent Web App.
2111
+ * @param id - Agent Web App identifier
2112
+ * @returns A promise that resolves to the disabled publication
2113
+ */
2114
+ disable: (id: string) => Promise<AgentWebApp>;
2115
+ /**
2116
+ * Permanently deletes an Agent Web App.
2117
+ * @param id - Agent Web App identifier
2118
+ * @returns A promise that resolves when the publication is deleted
2119
+ */
2120
+ delete: (id: string) => Promise<void>;
2121
+ };
2122
+ /**
2123
+ * Skills namespace for managing skills
2124
+ */
2125
+ skills: {
2126
+ /**
2127
+ * Lists all available skills
2128
+ * @returns A promise that resolves to the list of skills
2129
+ */
2130
+ list: () => Promise<Skill[]>;
2131
+ /**
2132
+ * Retrieves a single skill by ID
2133
+ * @param id - Skill identifier
2134
+ * @returns A promise that resolves to the skill information
2135
+ */
2136
+ get: (id: string) => Promise<Skill>;
2137
+ /**
2138
+ * Creates a new skill
2139
+ * @param options - Options for creating a skill
2140
+ * @returns A promise that resolves to the created skill
2141
+ */
2142
+ create: (options: CreateSkillRequest) => Promise<Skill>;
2143
+ /**
2144
+ * Updates an existing skill by ID
2145
+ * @param id - Skill identifier
2146
+ * @param options - Options for updating a skill
2147
+ * @returns A promise that resolves to the updated skill
2148
+ */
2149
+ update: (id: string, options: Partial<CreateSkillRequest>) => Promise<Skill>;
2150
+ /**
2151
+ * Deletes a skill by ID
2152
+ * @param id - Skill identifier
2153
+ * @returns A promise that resolves when the skill is deleted
2154
+ */
2155
+ delete: (id: string) => Promise<void>;
2156
+ };
2157
+ /**
2158
+ * Collections namespace for managing vector collections
2159
+ */
2160
+ collections: {
2161
+ /**
2162
+ * Lists all available collections
2163
+ * @returns A promise that resolves to the list of collections
2164
+ */
2165
+ list: () => Promise<any[]>;
2166
+ /**
2167
+ * Retrieves a single collection by name
2168
+ * @param name - Collection name
2169
+ * @returns A promise that resolves to the collection information
2170
+ */
2171
+ get: (name: string) => Promise<any>;
2172
+ /**
2173
+ * Creates a new collection
2174
+ * @param options - Options for creating a collection
2175
+ * @returns A promise that resolves to the created collection
2176
+ */
2177
+ create: (options: {
2178
+ name: string;
2179
+ label: string;
2180
+ embeddingKey: string;
2181
+ schema?: {
2182
+ fields: Array<{
2183
+ key: string;
2184
+ type: string;
2185
+ enumValues?: string[];
2186
+ required?: boolean;
2187
+ }>;
2188
+ };
2189
+ }) => Promise<any>;
2190
+ /**
2191
+ * Updates an existing collection by name
2192
+ * @param name - Collection name
2193
+ * @param options - Options for updating a collection
2194
+ * @returns A promise that resolves to the updated collection
2195
+ */
2196
+ update: (name: string, options: {
2197
+ label?: string;
2198
+ embeddingKey?: string;
2199
+ schema?: any;
2200
+ }) => Promise<any>;
2201
+ /**
2202
+ * Deletes a collection by name
2203
+ * @param name - Collection name
2204
+ * @returns A promise that resolves when the collection is deleted
2205
+ */
2206
+ delete: (name: string) => Promise<void>;
2207
+ /**
2208
+ * Entries sub-namespace for a specific collection.
2209
+ * Returns entry CRUD + search methods scoped to the given collection.
2210
+ * @param collectionName - The collection name
2211
+ * @returns Entry operation methods
2212
+ */
2213
+ entries: (collectionName: string) => {
2214
+ list: () => Promise<any[]>;
2215
+ create: (data: {
2216
+ content: string;
2217
+ metadata?: Record<string, unknown>;
2218
+ }) => Promise<any>;
2219
+ /**
2220
+ * Creates 1-50 entries in one all-or-nothing vector-store write.
2221
+ *
2222
+ * @param data - Batch payload with one or more entries.
2223
+ * @returns The created entries with generated ids.
2224
+ */
2225
+ createMany: (data: {
2226
+ entries: Array<{
2227
+ content: string;
2228
+ metadata?: Record<string, unknown>;
2229
+ }>;
2230
+ }) => Promise<any[]>;
2231
+ get: (id: string) => Promise<any>;
2232
+ update: (id: string, data: {
2233
+ content?: string;
2234
+ metadata?: Record<string, unknown>;
2235
+ }) => Promise<any>;
2236
+ delete: (id: string) => Promise<void>;
2237
+ /**
2238
+ * Deletes 1-50 entries in one all-or-nothing vector-store call.
2239
+ *
2240
+ * @param entryIds - Entry IDs to delete.
2241
+ * @returns The number of requested entry IDs processed by the delete call.
2242
+ */
2243
+ deleteMany: (entryIds: string[]) => Promise<number>;
2244
+ search: (query: string, opts?: {
2245
+ filter?: Record<string, unknown>;
2246
+ top_k?: number;
2247
+ }) => Promise<any[]>;
2248
+ };
2249
+ };
2250
+ /**
2251
+ * Threads namespace for managing threads for the current assistant
2252
+ */
2253
+ threads: {
2254
+ /**
2255
+ * Lists all threads for the current assistant
2256
+ * @returns A promise that resolves to the list of threads
2257
+ */
2258
+ list: () => Promise<Thread[]>;
2259
+ /**
2260
+ * Retrieves a single thread by ID for the current assistant
2261
+ * @param threadId - Thread identifier
2262
+ * @returns A promise that resolves to the thread information
2263
+ */
2264
+ get: (threadId: string) => Promise<Thread>;
2265
+ /**
2266
+ * Creates a new thread for the current assistant
2267
+ * @param options - Options for creating a thread
2268
+ * @returns A promise that resolves to the created thread
2269
+ */
2270
+ create: (options: CreateThreadOptions) => Promise<Thread>;
2271
+ /**
2272
+ * Updates an existing thread by ID for the current assistant
2273
+ * @param threadId - Thread identifier
2274
+ * @param options - Options for updating a thread
2275
+ * @returns A promise that resolves to the updated thread
2276
+ */
2277
+ update: (threadId: string, options: UpdateThreadOptions) => Promise<Thread>;
2278
+ /**
2279
+ * Deletes a thread by ID for the current assistant
2280
+ * @param threadId - Thread identifier
2281
+ * @returns A promise that resolves when the thread is deleted
2282
+ */
2283
+ delete: (threadId: string) => Promise<void>;
2284
+ };
2285
+ /**
2286
+ * Schedules namespace for managing scheduled tasks
2287
+ */
2288
+ schedules: {
2289
+ /**
2290
+ * Gets scheduled tasks for a specific thread
2291
+ * @param options - Options for getting scheduled tasks
2292
+ * @returns A promise that resolves to the list of scheduled tasks
2293
+ */
2294
+ getByThread: (options: GetScheduledTasksOptions) => Promise<ScheduledTask[]>;
2295
+ /**
2296
+ * Gets a single scheduled task by ID
2297
+ * @param taskId - Task identifier
2298
+ * @returns A promise that resolves to the scheduled task or null
2299
+ */
2300
+ get: (taskId: string) => Promise<ScheduledTask | null>;
2301
+ /**
2302
+ * Cancels a scheduled task
2303
+ * @param taskId - Task identifier
2304
+ * @returns A promise that resolves when the task is cancelled
2305
+ */
2306
+ cancel: (taskId: string) => Promise<boolean>;
2307
+ /**
2308
+ * Pauses a scheduled cron task
2309
+ * @param taskId - Task identifier
2310
+ * @returns A promise that resolves when the task is paused
2311
+ */
2312
+ pause: (taskId: string) => Promise<boolean>;
2313
+ /**
2314
+ * Resumes a paused cron task
2315
+ * @param taskId - Task identifier
2316
+ * @returns A promise that resolves when the task is resumed
2317
+ */
2318
+ resume: (taskId: string) => Promise<boolean>;
2319
+ };
2320
+ /**
2321
+ * Agent cron resources (`/api/runs/crons` and thread-bound crons).
2322
+ */
2323
+ crons: {
2324
+ /**
2325
+ * Creates a cron bound to an existing thread.
2326
+ * @param threadId - Thread that receives follow-up runs.
2327
+ * @param body - Cron definition.
2328
+ * @returns The created cron.
2329
+ */
2330
+ createForThread: (threadId: string, body: CreateThreadCronInput) => Promise<AgentCron>;
2331
+ /**
2332
+ * Creates a stateless cron that starts a fresh thread per fire.
2333
+ * @param body - Cron definition including the assistant id.
2334
+ * @returns The created cron.
2335
+ */
2336
+ createStateless: (body: CreateStatelessCronInput) => Promise<AgentCron>;
2337
+ /**
2338
+ * Searches tenant-scoped Agent crons.
2339
+ * @param body - Optional assistant/thread/enabled/pagination filters.
2340
+ * @returns Matching crons.
2341
+ */
2342
+ search: (body?: CronSearchFilters) => Promise<AgentCron[]>;
2343
+ /**
2344
+ * Counts tenant-scoped Agent crons.
2345
+ * @param body - Optional assistant/thread/enabled filters.
2346
+ * @returns Matching cron count.
2347
+ */
2348
+ count: (body?: CronCountFilters) => Promise<number>;
2349
+ /**
2350
+ * Reads one Agent cron.
2351
+ * @param cronId - Cron id.
2352
+ * @returns The cron resource.
2353
+ */
2354
+ get: (cronId: string) => Promise<AgentCron>;
2355
+ /**
2356
+ * Pauses or resumes a cron.
2357
+ * @param cronId - Cron id.
2358
+ * @param enabled - Desired enabled state.
2359
+ * @returns The updated cron.
2360
+ */
2361
+ updateEnabled: (cronId: string, enabled: boolean) => Promise<AgentCron>;
2362
+ /**
2363
+ * Cancels/deletes a cron.
2364
+ * @param cronId - Cron id.
2365
+ * @returns True when the gateway reports success.
2366
+ */
2367
+ delete: (cronId: string) => Promise<boolean>;
2368
+ };
2369
+ /**
2370
+ * Thread command surface (`run.start`, `input.respond`, `agent.getTree`).
2371
+ */
2372
+ commands: {
2373
+ /**
2374
+ * Starts a run on a thread.
2375
+ * @param threadId - Thread id.
2376
+ * @param args - Input/config/metadata/strategy.
2377
+ * @returns Queued message id and mode.
2378
+ */
2379
+ runStart: (threadId: string, args: CommandRunStartArgs) => Promise<CommandRunStartResult>;
2380
+ /**
2381
+ * Answers a pending interrupt.
2382
+ * @param threadId - Thread id.
2383
+ * @param args - Interrupt id and response/resume payload.
2384
+ * @returns Queued message id and interrupt id.
2385
+ */
2386
+ respond: (threadId: string, args: CommandInputRespondArgs) => Promise<CommandInputRespondResult>;
2387
+ /**
2388
+ * Reads the structured Agent graph.
2389
+ * @param threadId - Thread id.
2390
+ * @returns Nodes, edges, Mermaid, and namespace placeholder.
2391
+ */
2392
+ getTree: (threadId: string) => Promise<AgentGraphTree>;
2393
+ };
2394
+ /**
2395
+ * Single-run surface (`POST/GET /threads/:id/runs`, cancellation).
2396
+ */
2397
+ runs: {
2398
+ /**
2399
+ * Enqueues one run-bound input or HITL resume command.
2400
+ * @param threadId - Thread id.
2401
+ * @param input - Message or messages accepted by the run API; omit for command runs.
2402
+ * @param options - Optional config, mode, command, and multitask strategy.
2403
+ * @param assistantId - Assistant id override (defaults to the client's).
2404
+ * @returns Pending run id and the optional input message id.
2405
+ */
2406
+ create: (threadId: string, input: RunCreateInput | undefined, options?: RunCreateOptions, assistantId?: string) => Promise<RunCreateResult>;
2407
+ /**
2408
+ * Lists run ledger records for a thread.
2409
+ * @param threadId - Thread id.
2410
+ * @param assistantId - Assistant id override (defaults to the client's).
2411
+ * @returns Safe run records.
2412
+ */
2413
+ list: (threadId: string, assistantId?: string) => Promise<RunRecord[]>;
2414
+ /**
2415
+ * Lists only `run_api` runs that are pending or running.
2416
+ * @param threadId - Thread id.
2417
+ * @param assistantId - Assistant id override (defaults to the client's).
2418
+ * @returns Active run records in ledger order.
2419
+ */
2420
+ listActive: (threadId: string, assistantId?: string) => Promise<RunRecord[]>;
2421
+ /**
2422
+ * Reads one run ledger record.
2423
+ * @param threadId - Thread id.
2424
+ * @param runId - Run id.
2425
+ * @param assistantId - Assistant id override (defaults to the client's).
2426
+ * @returns The safe run record.
2427
+ */
2428
+ get: (threadId: string, runId: string, assistantId?: string) => Promise<RunRecord>;
2429
+ /**
2430
+ * Waits for a run to reach a terminal status (server-capped).
2431
+ * @param threadId - Thread id.
2432
+ * @param runId - Run id.
2433
+ * @param assistantId - Assistant id override (defaults to the client's).
2434
+ * @returns The terminal run record.
2435
+ * @throws {ApiError} On `504 RUN_JOIN_TIMEOUT` or `404 RUN_NOT_FOUND`.
2436
+ */
2437
+ join: (threadId: string, runId: string, assistantId?: string) => Promise<RunRecord>;
2438
+ /**
2439
+ * Requests cancellation of one run.
2440
+ * @param threadId - Thread id.
2441
+ * @param runId - Run id.
2442
+ * @param options - Optional `wait` and `action` (`interrupt` or `rollback`).
2443
+ * @param assistantId - Assistant id override (defaults to the client's).
2444
+ * @returns Acceptance, terminal status, and optional latest run.
2445
+ */
2446
+ cancel: (threadId: string, runId: string, options?: RunCancelOptions, assistantId?: string) => Promise<RunCancelResult>;
2447
+ /**
2448
+ * Cancels every active `run_api` run on a thread.
2449
+ * @param threadId - Thread id.
2450
+ * @param assistantId - Assistant id override (defaults to the client's).
2451
+ * @returns Per-run cancellation outcomes.
2452
+ */
2453
+ cancelActive: (threadId: string, assistantId?: string) => Promise<RunCancelActiveResult>;
2454
+ };
2455
+ /**
2456
+ * Tenant-scoped namespaced key-value store (viewer/editor surface).
2457
+ */
2458
+ store: {
2459
+ /**
2460
+ * Creates or replaces a store item.
2461
+ * @param input - Namespace, key, value, optional TTL/index hint.
2462
+ * @returns The persisted item.
2463
+ */
2464
+ put: (input: StorePutInput) => Promise<StoreItem>;
2465
+ /**
2466
+ * Reads one item by namespace and key.
2467
+ * @param namespace - Namespace path.
2468
+ * @param key - Item key.
2469
+ * @returns The item.
2470
+ */
2471
+ get: (namespace: string[], key: string) => Promise<StoreItem>;
2472
+ /**
2473
+ * Deletes one item.
2474
+ * @param namespace - Namespace path.
2475
+ * @param key - Item key.
2476
+ * @returns True when deleted.
2477
+ */
2478
+ delete: (namespace: string[], key: string) => Promise<boolean>;
2479
+ /**
2480
+ * Searches items under a namespace prefix.
2481
+ * @param input - Prefix/filter/query/pagination.
2482
+ * @returns Matching items.
2483
+ */
2484
+ search: (input?: StoreSearchInput) => Promise<StoreItem[]>;
2485
+ /**
2486
+ * Lists distinct namespace paths.
2487
+ * @param prefix - Optional namespace prefix.
2488
+ * @param limit - Optional result cap (gateway clamps).
2489
+ * @returns Namespace paths.
2490
+ */
2491
+ namespaces: (prefix?: string[], limit?: number) => Promise<string[][]>;
2492
+ };
2493
+ }
2494
+
2495
+ /**
2496
+ * ResourcesClient
2497
+ *
2498
+ * Client for resource sharing API: create, update, delete, and list shared resource records.
2499
+ */
2500
+
2501
+ declare class ResourcesClient {
2502
+ private baseURL;
2503
+ private getHeaders;
2504
+ constructor(baseURL: string, getHeaders: () => Record<string, string>);
2505
+ share(request: CreateShareRequest): Promise<ShareResult>;
2506
+ unshare(token: string): Promise<void>;
2507
+ updateShare(token: string, patch: ShareRecordPatch): Promise<void>;
2508
+ listShares(): Promise<ShareRecord[]>;
2509
+ }
2510
+
2511
+ /** A registered entity type that can be exported. */
2512
+ interface ExportableTypeInfo {
2513
+ entityType: string;
2514
+ label: string;
2515
+ category: "core" | "plugin";
2516
+ dependsOn: string[];
2517
+ cascadeParents: string[];
2518
+ }
2519
+ /** Explicit entity IDs selected for each exportable type. */
2520
+ type ExportEntityIds = Record<string, string[]>;
2521
+ /** An export preview that requires dependency confirmation. */
2522
+ interface ExportConfirmationRequired {
2523
+ needsConfirmation: true;
2524
+ missingDependencies: string[];
2525
+ cascadeAdditions: string[];
2526
+ }
2527
+ /** Result of starting an export: the archive bytes, or dependencies requiring confirmation. */
2528
+ type ExportConfigResult = ExportDownload | ExportConfirmationRequired;
2529
+ /** A selectable entity shown before an export. */
2530
+ interface ExportEntityPreview {
2531
+ id: string;
2532
+ name: string;
2533
+ description?: string;
2534
+ }
2535
+ /** Selectable entities grouped by entity type. */
2536
+ type ExportEntityPreviewMap = Record<string, ExportEntityPreview[]>;
2537
+ /** A single entity stored in an export bundle. */
2538
+ interface ExportableEntity {
2539
+ _exportId: string;
2540
+ data: Record<string, unknown>;
2541
+ }
2542
+ /** Plain JSON bundle contained in an export archive. */
2543
+ interface ExportBundle {
2544
+ version: 1;
2545
+ exportedAt: string;
2546
+ sourceTenantId: string;
2547
+ entities: Record<string, ExportableEntity[]>;
2548
+ dependencyOrder: string[];
2549
+ _warning?: string;
2550
+ }
2551
+ /** A conflict discovered while previewing an import. */
2552
+ interface ImportConflict {
2553
+ _exportId: string;
2554
+ entityType: string;
2555
+ conflictType: "id_exists" | "unique_constraint";
2556
+ existingName?: string;
2557
+ existingId?: string;
2558
+ field?: string;
2559
+ }
2560
+ /** A new entity discovered while previewing an import. */
2561
+ interface ImportInsertion {
2562
+ _exportId: string;
2563
+ entityType: string;
2564
+ name: string;
2565
+ }
2566
+ /** An invalid entity discovered while previewing an import. */
2567
+ interface ImportPreviewError {
2568
+ _exportId: string;
2569
+ entityType: string;
2570
+ error: string;
2571
+ }
2572
+ /** Gateway result for an import preview. */
2573
+ interface ImportPreviewResult {
2574
+ conflicts: ImportConflict[];
2575
+ insertions: ImportInsertion[];
2576
+ errors: ImportPreviewError[];
2577
+ }
2578
+ /** Resolution selected for an import conflict. */
2579
+ interface ImportResolution {
2580
+ _exportId: string;
2581
+ action: "skip" | "overwrite" | "rename";
2582
+ newId?: string;
2583
+ }
2584
+ /** Import conflict resolutions keyed by export ID. */
2585
+ type ImportResolutions = Record<string, ImportResolution>;
2586
+ /** Result for one imported entity. */
2587
+ interface ImportEntityResult {
2588
+ _exportId: string;
2589
+ entityType: string;
2590
+ status: "created" | "updated" | "skipped" | "failed";
2591
+ newId?: string;
2592
+ error?: string;
2593
+ }
2594
+ /** Gateway result after applying an import. */
2595
+ interface ImportApplyResult {
2596
+ results: ImportEntityResult[];
2597
+ idMap: Record<string, string>;
2598
+ }
2599
+ /**
2600
+ * Binary or encoded archive accepted by import operations.
2601
+ *
2602
+ * `Blob` also covers the browser/Node `File` subclass, so the SDK does not
2603
+ * require DOM-only types; an optional `name` is read when present.
2604
+ */
2605
+ type ArchiveInput = Blob | ArrayBuffer | Uint8Array | string;
2606
+ /** Explicit archive or plain-bundle source for an import operation. */
2607
+ type ImportSource = {
2608
+ archive: ArchiveInput;
2609
+ bundle?: never;
2610
+ } | {
2611
+ bundle: ExportBundle;
2612
+ archive?: never;
2613
+ };
2614
+ /** Decoded archive returned by an export download. */
2615
+ interface ExportDownload {
2616
+ filename: string;
2617
+ data: Uint8Array;
2618
+ }
2619
+
2620
+ type HeaderProvider = () => Record<string, string>;
2621
+ /** Client for the gateway tenant export/import archive API. */
2622
+ declare class ExportImportClient {
2623
+ private readonly baseURL;
2624
+ private readonly headers;
2625
+ private readonly headerProvider?;
2626
+ /**
2627
+ * Creates an export/import client.
2628
+ *
2629
+ * @param config - Base client configuration.
2630
+ * @param headerProvider - Optional provider for headers that change after construction.
2631
+ */
2632
+ constructor(config: ClientConfig, headerProvider?: HeaderProvider);
2633
+ private request;
2634
+ private postJson;
2635
+ private readArchive;
2636
+ /** Returns all entity types registered for export. */
2637
+ getExportableTypes(): Promise<ExportableTypeInfo[]>;
2638
+ /**
2639
+ * Runs an export and streams the archive back in the same request.
2640
+ * Returns a dependency-confirmation request instead when the selection
2641
+ * needs cascade additions the caller has not confirmed yet.
2642
+ */
2643
+ exportConfig(tenantId: string, entityTypes: string[], entityIds?: ExportEntityIds): Promise<ExportConfigResult>;
2644
+ /** Runs an export after the caller confirmed dependency additions, streaming the archive back. */
2645
+ exportConfigConfirm(tenantId: string, entityTypes: string[], entityIds?: ExportEntityIds): Promise<ExportDownload>;
2646
+ /** Lists selectable entities for the requested export types. */
2647
+ previewEntities(tenantId: string, entityTypes: string[]): Promise<ExportEntityPreviewMap>;
2648
+ /** Previews an archive or plain JSON bundle import. */
2649
+ importPreview(tenantId: string, source: ImportSource): Promise<ImportPreviewResult>;
2650
+ /** Applies an archive or plain JSON bundle import with conflict resolutions. */
2651
+ importApply(tenantId: string, source: ImportSource, resolutions: ImportResolutions): Promise<ImportApplyResult>;
2652
+ }
2653
+
2654
+ declare class ProjectRoomClientError extends Error {
2655
+ readonly status: number;
2656
+ readonly code: string;
2657
+ readonly retryable: boolean;
2658
+ readonly details?: unknown | undefined;
2659
+ constructor(message: string, status: number, code: string, retryable: boolean, details?: unknown | undefined);
2660
+ }
2661
+
2662
+ interface ProjectRoomRecord extends Omit<ProjectRoom, "createdAt" | "updatedAt"> {
2663
+ createdAt: Date;
2664
+ updatedAt: Date;
2665
+ }
2666
+ interface ProjectRoomMessageRecord extends Omit<ProjectRoomPublicMessage, "createdAt"> {
2667
+ createdAt: Date;
2668
+ }
2669
+ interface ProjectRoomMembershipRecord extends Omit<ProjectMembership, "joinedAt" | "updatedAt"> {
2670
+ joinedAt: Date;
2671
+ updatedAt: Date;
2672
+ name?: string;
2673
+ }
2674
+ interface ProjectRoomBotRecord extends Omit<ProjectBotMembership, "joinedAt" | "updatedAt"> {
2675
+ joinedAt: Date;
2676
+ updatedAt: Date;
2677
+ }
2678
+ interface ProjectRoomPublicMembershipRecord extends Omit<ProjectRoomPublicMembership, "joinedAt" | "updatedAt"> {
2679
+ joinedAt: Date;
2680
+ updatedAt: Date;
2681
+ }
2682
+ interface ProjectRoomPublicBotRecord extends Omit<ProjectRoomPublicBotMembership, "joinedAt" | "updatedAt"> {
2683
+ joinedAt: Date;
2684
+ updatedAt: Date;
2685
+ }
2686
+ type ProjectRoomDispatchErrorCode = "BOT_PAUSED" | "TARGET_UNAVAILABLE" | "TARGET_REQUIRED" | "CHANNEL_UNAVAILABLE" | "DISPATCH_FAILED" | "DISPATCH_STATUS_UNKNOWN" | "AUTHORIZATION_REVOKED" | "ROSTER_CONFLICT";
2687
+ interface ProjectRoomDispatchResult {
2688
+ membershipId?: string;
2689
+ success: boolean;
2690
+ errorCode?: ProjectRoomDispatchErrorCode;
2691
+ }
2692
+ interface ProjectRoomSendResult {
2693
+ message: ProjectRoomMessageRecord;
2694
+ dispatch: ProjectRoomDispatchResult[];
2695
+ replayed: boolean;
2696
+ }
2697
+ interface SendProjectRoomMessageInput {
2698
+ text: string;
2699
+ mentions: ProjectRoomMention[];
2700
+ replyToMessageId?: string;
2701
+ idempotencyKey: string;
2702
+ }
2703
+ interface ListProjectRoomMessagesOptions {
2704
+ limit?: number;
2705
+ cursor?: {
2706
+ createdAt: Date;
2707
+ id: string;
2708
+ };
2709
+ }
2710
+ interface UpdateProjectMembershipInput {
2711
+ role: ProjectHumanRole;
2712
+ expectedUpdatedAt: Date;
2713
+ }
2714
+ interface MutationExpectedUpdatedAt {
2715
+ expectedUpdatedAt: Date | string;
2716
+ }
2717
+ interface AddProjectMembershipInput {
2718
+ userId: string;
2719
+ role: ProjectHumanRole;
2720
+ }
2721
+ interface AddProjectBotMembershipInput {
2722
+ assistantId: string;
2723
+ role: ProjectBotRole;
2724
+ title: string;
2725
+ responsibility?: string;
2726
+ mentionName: string;
2727
+ }
2728
+ interface UpdateProjectBotMembershipInput {
2729
+ role?: ProjectBotRole;
2730
+ title?: string;
2731
+ responsibility?: string;
2732
+ mentionName?: string;
2733
+ expectedUpdatedAt: Date | string;
2734
+ }
2735
+ interface ProjectRoomInterruptAnswerInput {
2736
+ questionIndex: number;
2737
+ otherText?: string;
2738
+ selectedOptions?: string[];
2739
+ filePath?: string;
2740
+ }
2741
+ type ResumeProjectRoomInterruptInput = {
2742
+ ref: {
2743
+ kind: "presence";
2744
+ membershipId: string;
2745
+ };
2746
+ interruptId?: string;
2747
+ answers?: ProjectRoomInterruptAnswerInput[];
2748
+ } | {
2749
+ ref: {
2750
+ kind: "task";
2751
+ taskId: string;
2752
+ };
2753
+ interruptId?: string;
2754
+ answers?: ProjectRoomInterruptAnswerInput[];
2755
+ } | {
2756
+ membershipId: string;
2757
+ interruptId?: string;
2758
+ answers?: ProjectRoomInterruptAnswerInput[];
2759
+ };
2760
+ type HeadersGetter$1 = () => Record<string, string>;
2761
+ declare class ProjectRoomsClient {
2762
+ private readonly baseURL;
2763
+ private readonly getHeaders;
2764
+ readonly messages: {
2765
+ list: (projectId: string, options?: ListProjectRoomMessagesOptions) => Promise<ProjectRoomMessageRecord[]>;
2766
+ send: (projectId: string, input: SendProjectRoomMessageInput) => Promise<ProjectRoomSendResult>;
2767
+ retry: (projectId: string, messageId: string) => Promise<ProjectRoomDispatchResult[]>;
2768
+ markRead: (projectId: string) => Promise<void>;
2769
+ };
2770
+ readonly members: {
2771
+ list: (projectId: string) => Promise<ProjectRoomMembershipRecord[]>;
2772
+ add: (projectId: string, input: AddProjectMembershipInput) => Promise<ProjectRoomMembershipRecord>;
2773
+ update: (projectId: string, membershipId: string, input: UpdateProjectMembershipInput) => Promise<ProjectRoomMembershipRecord>;
2774
+ remove: (projectId: string, membershipId: string, input: MutationExpectedUpdatedAt) => Promise<unknown>;
2775
+ };
2776
+ readonly bots: {
2777
+ list: (projectId: string) => Promise<ProjectRoomBotRecord[]>;
2778
+ ensure: (projectId: string, membershipId: string) => Promise<ProjectRoomBotRecord>;
2779
+ add: (projectId: string, input: AddProjectBotMembershipInput) => Promise<ProjectRoomBotRecord>;
2780
+ update: (projectId: string, membershipId: string, input: UpdateProjectBotMembershipInput) => Promise<ProjectRoomBotRecord>;
2781
+ pause: (projectId: string, membershipId: string, input: MutationExpectedUpdatedAt) => Promise<ProjectRoomBotRecord>;
2782
+ resume: (projectId: string, membershipId: string, input: MutationExpectedUpdatedAt) => Promise<ProjectRoomBotRecord>;
2783
+ remove: (projectId: string, membershipId: string, input: MutationExpectedUpdatedAt) => Promise<unknown>;
2784
+ };
2785
+ readonly interrupts: {
2786
+ resume: (projectId: string, input: ResumeProjectRoomInterruptInput) => Promise<void>;
2787
+ };
2788
+ constructor(baseURL: string, getHeaders: HeadersGetter$1);
2789
+ getRoom(projectId: string): Promise<ProjectRoomRecord>;
2790
+ private records;
2791
+ private request;
2792
+ }
2793
+
2794
+ interface ProjectRecord extends Omit<Project$1, "createdAt" | "updatedAt"> {
2795
+ createdAt: Date;
2796
+ updatedAt: Date;
2797
+ }
2798
+ /** A hydrated workspace room entry from the aggregated rooms endpoint. */
2799
+ interface WorkspaceRoomEntryRecord {
2800
+ project: ProjectRecord;
2801
+ room: ProjectRoomRecord;
2802
+ lastMessage?: ProjectRoomMessageRecord;
2803
+ participantCount: number;
2804
+ participantNames: string[];
2805
+ /** Viewer-relative title for human direct rooms; absent to fall back to `room.name`. */
2806
+ displayName?: string;
2807
+ isPublic?: boolean;
2808
+ /** Messages after the user's read horizon, excluding the user's own messages. */
2809
+ unreadCount: number;
2810
+ }
2811
+ /** Aggregated workspace room list client (single request, server-computed unread counts). */
2812
+ declare class WorkspaceRoomsClient {
2813
+ private readonly baseURL;
2814
+ private readonly getHeaders;
2815
+ constructor(baseURL: string, getHeaders: () => Record<string, string>);
2816
+ /** Lists the user's rooms in a workspace with last message and unread count. */
2817
+ list(workspaceId: string): Promise<WorkspaceRoomEntryRecord[]>;
2818
+ }
2819
+
2820
+ /** A tenant user available in a workspace, as returned by GET /workspaces/:id/orgs/members. */
2821
+ interface WorkspaceMemberRecord {
2822
+ userId: string;
2823
+ name: string;
2824
+ email?: string;
2825
+ role: string;
2826
+ hasDirectRoom: boolean;
2827
+ joinedAt?: string;
2828
+ }
2829
+ /** Workspace-scoped tenant member directory (used to pick people to add to a project). */
2830
+ declare class WorkspaceMembersClient {
2831
+ private readonly baseURL;
2832
+ private readonly getHeaders;
2833
+ constructor(baseURL: string, getHeaders: () => Record<string, string>);
2834
+ /** Lists the tenant users visible in a workspace, excluding the current user. */
2835
+ list(workspaceId: string): Promise<WorkspaceMemberRecord[]>;
2836
+ }
2837
+
2838
+ /** Routing scope attached to room-scoped frames by the workspace stream. */
2839
+ type RoomEventScopeRecord = ProjectRoomEventScope;
2840
+ type WorkspaceRoomKnownBusinessEvent = {
2841
+ type: "message.created";
2842
+ id: string;
2843
+ occurredAt: Date;
2844
+ scope: RoomEventScopeRecord;
2845
+ data: {
2846
+ message: ProjectRoomMessageRecord;
2847
+ };
2848
+ } | {
2849
+ type: "roster.changed";
2850
+ id: string;
2851
+ occurredAt: Date;
2852
+ scope: RoomEventScopeRecord;
2853
+ data: {
2854
+ change: string;
2855
+ membership: ProjectRoomPublicBotRecord;
2856
+ };
2857
+ } | {
2858
+ type: "membership.changed";
2859
+ id: string;
2860
+ occurredAt: Date;
2861
+ scope: RoomEventScopeRecord;
2862
+ data: {
2863
+ change: string;
2864
+ membership: ProjectRoomPublicMembershipRecord;
2865
+ };
2866
+ } | {
2867
+ type: "task.changed";
2868
+ id: string;
2869
+ occurredAt: Date;
2870
+ scope: RoomEventScopeRecord;
2871
+ data: {
2872
+ taskId: string;
2873
+ status: string;
2874
+ ownerMembershipId: string;
2875
+ updatedAt: Date;
2876
+ };
2877
+ } | {
2878
+ type: "read.changed";
2879
+ id: string;
2880
+ occurredAt: Date;
2881
+ data: {
2882
+ projectId: string;
2883
+ roomId: string;
2884
+ lastReadAt: Date;
2885
+ };
2886
+ } | {
2887
+ type: "membership.affected";
2888
+ id: string;
2889
+ occurredAt: Date;
2890
+ data: {
2891
+ change: "added" | "removed" | "role_changed";
2892
+ projectId: string;
2893
+ roomId: string;
2894
+ };
2895
+ };
2896
+ /** A business event of a type this client version does not know (forward compatibility). */
2897
+ interface WorkspaceRoomUnknownBusinessEvent {
2898
+ type: string;
2899
+ id: string;
2900
+ occurredAt: Date;
2901
+ data: unknown;
2902
+ scope?: RoomEventScopeRecord;
2903
+ }
2904
+ type WorkspaceRoomBusinessEvent = WorkspaceRoomKnownBusinessEvent | WorkspaceRoomUnknownBusinessEvent;
2905
+ type WorkspaceRoomControlEvent = {
2906
+ type: "ready";
2907
+ data: {
2908
+ epoch: string;
2909
+ headEventId: string | null;
2910
+ };
2911
+ } | {
2912
+ type: "resync";
2913
+ data: {
2914
+ reason: "SERVER_RESTART" | "CURSOR_EXPIRED" | "SLOW_CONSUMER";
2915
+ };
2916
+ } | {
2917
+ type: "access.revoked";
2918
+ data: {
2919
+ reason: "PROJECT_ACCESS_REVOKED" | "TOKEN_EXPIRED" | "CONNECTION_SUPERSEDED";
2920
+ };
2921
+ };
2922
+ interface WorkspaceRoomEventFrame {
2923
+ event: WorkspaceRoomBusinessEvent | WorkspaceRoomControlEvent;
2924
+ id?: string;
2925
+ retry?: number;
2926
+ }
2927
+ interface WorkspaceRoomEventConnection extends AsyncIterable<WorkspaceRoomEventFrame> {
2928
+ readonly opened: Promise<{
2929
+ status: 200;
2930
+ }>;
2931
+ }
2932
+ type HeadersGetter = () => Record<string, string>;
2933
+ /** Live-only workspace-scoped room events SSE client (no cursor, replay, or resync). */
2934
+ declare class RoomEventsClient {
2935
+ private readonly baseURL;
2936
+ private readonly getHeaders;
2937
+ constructor(baseURL: string, getHeaders: HeadersGetter);
2938
+ connect(workspaceId: string, options: {
2939
+ signal: AbortSignal;
2940
+ }): WorkspaceRoomEventConnection;
2941
+ }
2942
+
2943
+ /** Platform-level OIDC provider management client. */
2944
+ interface OidcProviderSummary {
2945
+ id: string;
2946
+ displayName: string;
2947
+ issuer: string;
2948
+ clientId: string;
2949
+ hasClientSecret: boolean;
2950
+ scopes: string;
2951
+ enabled: boolean;
2952
+ jitProvisioning: boolean;
2953
+ autoLinkEmail: boolean;
2954
+ defaultTenantId?: string;
2955
+ allowedPrivateHosts?: string[];
2956
+ redirectUri: string;
2957
+ source: "env" | "store";
2958
+ updatedAt: string | null;
2959
+ }
2960
+ interface CreateOidcProviderInput {
2961
+ id: string;
2962
+ displayName: string;
2963
+ issuer: string;
2964
+ clientId: string;
2965
+ clientSecret?: string;
2966
+ scopes?: string;
2967
+ enabled?: boolean;
2968
+ jitProvisioning?: boolean;
2969
+ autoLinkEmail?: boolean;
2970
+ defaultTenantId?: string | null;
2971
+ allowedPrivateHosts?: string[];
2972
+ }
2973
+ interface UpdateOidcProviderInput {
2974
+ displayName?: string;
2975
+ issuer?: string;
2976
+ clientId?: string;
2977
+ clientSecret?: string;
2978
+ scopes?: string;
2979
+ enabled?: boolean;
2980
+ jitProvisioning?: boolean;
2981
+ autoLinkEmail?: boolean;
2982
+ defaultTenantId?: string | null;
2983
+ allowedPrivateHosts?: string[];
2984
+ }
2985
+ interface TestOidcProviderInput {
2986
+ issuer: string;
2987
+ clientId: string;
2988
+ clientSecret?: string;
2989
+ allowedPrivateHosts?: string[];
2990
+ }
2991
+ interface TestStoredOidcProviderOverrides {
2992
+ issuer?: string;
2993
+ clientId?: string;
2994
+ clientSecret?: string;
2995
+ allowedPrivateHosts?: string[];
2996
+ }
2997
+ interface OidcProviderTestResult {
2998
+ issuer: string;
2999
+ authorizationEndpoint: string;
3000
+ tokenEndpoint: string;
3001
+ jwksUri: string;
3002
+ userinfoEndpoint?: string;
3003
+ scopesSupported?: string[];
3004
+ }
3005
+ /** Typed error thrown for non-success provider-management responses. */
3006
+ declare class OidcProviderClientError extends Error {
3007
+ readonly status: number;
3008
+ readonly code: string;
3009
+ readonly retryable: boolean;
3010
+ readonly details?: unknown | undefined;
3011
+ constructor(message: string, status: number, code: string, retryable?: boolean, details?: unknown | undefined);
3012
+ }
3013
+ /** Client for `/api/oidc-providers` (platform admin only). */
3014
+ declare class OidcProvidersClient {
3015
+ private readonly baseURL;
3016
+ private readonly getHeaders;
3017
+ constructor(baseURL: string, getHeaders: () => Record<string, string>);
3018
+ list(): Promise<OidcProviderSummary[]>;
3019
+ create(input: CreateOidcProviderInput): Promise<OidcProviderSummary>;
3020
+ update(id: string, input: UpdateOidcProviderInput): Promise<OidcProviderSummary>;
3021
+ delete(id: string): Promise<void>;
3022
+ test(input: TestOidcProviderInput): Promise<OidcProviderTestResult>;
3023
+ testStored(id: string, overrides?: TestStoredOidcProviderOverrides): Promise<OidcProviderTestResult>;
3024
+ private request;
3025
+ }
3026
+
3027
+ /** Platform administration client (platform roles and tenant assignments). */
3028
+
3029
+ /** Effective platform settings snapshot with ISO-string timestamps. */
3030
+ interface PlatformSettingsSnapshot {
3031
+ version: number;
3032
+ effective: EffectivePlatformSettings;
3033
+ sources: Record<string, PlatformSettingSource>;
3034
+ fallbacks: EffectivePlatformSettings;
3035
+ updatedBy?: string;
3036
+ updatedAt?: string;
3037
+ refreshedAt?: string;
3038
+ }
3039
+ /** Body accepted by `PATCH /api/platform/settings`. */
3040
+ interface UpdatePlatformSettingsInput {
3041
+ expectedVersion: number;
3042
+ patch?: PlatformSettingsDocument;
3043
+ reset?: string[];
3044
+ }
3045
+ /** Sanitized platform branding settings with ISO-string timestamps. */
3046
+ interface BrandingSettingsView {
3047
+ version: number;
3048
+ branding: PlatformBrandingSettings;
3049
+ updatedBy?: string;
3050
+ updatedAt?: string;
3051
+ }
3052
+ /** Body accepted by `PATCH /api/platform/branding`. */
3053
+ interface UpdateBrandingSettingsInput {
3054
+ expectedVersion: number;
3055
+ branding: PlatformBrandingSettings;
3056
+ }
3057
+ /** Runtime identity embedded in the platform environment view. */
3058
+ interface PlatformEnvironmentRuntime {
3059
+ service: string;
3060
+ version: string;
3061
+ commit?: string;
3062
+ environment?: string;
3063
+ replicaId?: string;
3064
+ uptimeSeconds: number;
3065
+ startedAt: string;
3066
+ readiness: unknown;
3067
+ }
3068
+ /** Public endpoint URLs embedded in the platform environment view. */
3069
+ interface PlatformEnvironmentEndpoints {
3070
+ gatewayUrl?: string;
3071
+ consoleUrl?: string;
3072
+ oidcRedirectUri?: string;
3073
+ inviteBaseUrl?: string;
3074
+ }
3075
+ /** Effective settings embedded in the platform environment view. */
3076
+ interface PlatformEnvironmentSettings {
3077
+ version: number;
3078
+ refreshedAt: string;
3079
+ effective: EffectivePlatformSettings;
3080
+ sources: Record<string, PlatformSettingSource>;
3081
+ fallbacks: EffectivePlatformSettings;
3082
+ }
3083
+ /** Non-sensitive diagnostics embedded in the platform environment view. */
3084
+ interface PlatformEnvironmentDiagnostics {
3085
+ migrationVersion?: number;
3086
+ providerCount?: number;
3087
+ warnings: string[];
3088
+ }
3089
+ /** Safe runtime environment projection returned by the gateway. */
3090
+ interface PlatformEnvironmentView {
3091
+ runtime: PlatformEnvironmentRuntime;
3092
+ publicEndpoints: PlatformEnvironmentEndpoints;
3093
+ dependencies: Record<string, "configured" | "not_configured" | "connected">;
3094
+ settings: PlatformEnvironmentSettings;
3095
+ diagnostics: PlatformEnvironmentDiagnostics;
3096
+ }
3097
+ /** Tenant row as returned by `GET /api/tenants`. */
3098
+ interface PlatformTenant {
3099
+ id: string;
3100
+ name: string;
3101
+ description?: string | null;
3102
+ status: TenantStatus;
3103
+ metadata?: Record<string, unknown>;
3104
+ createdAt: string;
3105
+ updatedAt: string;
3106
+ }
3107
+ /** Public user row used by platform assignment pickers. */
3108
+ interface PlatformUserSummary {
3109
+ id: string;
3110
+ email: string;
3111
+ name: string;
3112
+ status: UserStatus;
3113
+ metadata?: Record<string, unknown>;
3114
+ createdAt?: string;
3115
+ updatedAt?: string;
3116
+ }
3117
+ interface CreatePlatformUserInput {
3118
+ email: string;
3119
+ name: string;
3120
+ status?: UserStatus;
3121
+ password?: string;
3122
+ }
3123
+ interface UpdatePlatformUserInput {
3124
+ name?: string;
3125
+ status?: UserStatus;
3126
+ }
3127
+ interface CreatePlatformTenantInput {
3128
+ name: string;
3129
+ description?: string;
3130
+ status?: TenantStatus;
3131
+ metadata?: Record<string, unknown>;
3132
+ }
3133
+ interface UpdatePlatformTenantInput {
3134
+ name?: string;
3135
+ description?: string;
3136
+ status?: TenantStatus;
3137
+ metadata?: Record<string, unknown>;
3138
+ }
3139
+ /** Platform member joined with the public fields of its user. */
3140
+ interface PlatformMemberSummary {
3141
+ id: string;
3142
+ email: string | null;
3143
+ name: string | null;
3144
+ status: UserStatus | null;
3145
+ role: PlatformRole;
3146
+ grantedAt: string;
3147
+ grantedBy?: string;
3148
+ }
3149
+ /** Tenant assignment joined with the public fields of its user. */
3150
+ interface PlatformTenantMember {
3151
+ userId: string;
3152
+ tenantId: string;
3153
+ role: UserTenantRole;
3154
+ joinedAt: string;
3155
+ email: string | null;
3156
+ name: string | null;
3157
+ status: UserStatus | null;
3158
+ }
3159
+ /** Pending platform invitation keyed by normalized email. */
3160
+ interface PlatformInvitationSummary {
3161
+ email: string;
3162
+ role: PlatformRole;
3163
+ invitedBy?: string;
3164
+ createdAt: string;
3165
+ expiresAt?: string;
3166
+ consumedAt?: string;
3167
+ }
3168
+ /** Existing local user matched to a pending SSO claim email. */
3169
+ interface OidcIdentityClaimExistingUser {
3170
+ id: string;
3171
+ email: string;
3172
+ name: string;
3173
+ status: UserStatus;
3174
+ platformRole?: PlatformRole;
3175
+ }
3176
+ /** Pending enterprise-SSO identity claim shown to platform admins. */
3177
+ interface OidcIdentityClaimSummary {
3178
+ id: string;
3179
+ providerId: string;
3180
+ issuer: string;
3181
+ email: string;
3182
+ name?: string;
3183
+ picture?: string;
3184
+ status: OidcIdentityClaimStatus;
3185
+ createdAt: string;
3186
+ updatedAt: string;
3187
+ expiresAt: string;
3188
+ reviewedBy?: string;
3189
+ reviewedAt?: string;
3190
+ linkedUserId?: string;
3191
+ source?: "email_completion" | "invite_link";
3192
+ inviteLinkId?: string;
3193
+ requestedUserId?: string;
3194
+ requestedPlatformRole?: PlatformRole;
3195
+ requestedTenantId?: string;
3196
+ requestedTenantRole?: UserTenantRole;
3197
+ expired: boolean;
3198
+ existingUser?: OidcIdentityClaimExistingUser;
3199
+ }
3200
+ interface ApproveOidcIdentityClaimInput {
3201
+ email?: string;
3202
+ userId?: string;
3203
+ tenantId?: string;
3204
+ role?: UserTenantRole;
3205
+ }
3206
+ /** Opaque link invitation for a platform role or tenant membership. */
3207
+ interface InviteLinkSummary {
3208
+ id: string;
3209
+ scope: "platform" | "tenant";
3210
+ email?: string;
3211
+ platformRole?: PlatformRole;
3212
+ tenantId?: string;
3213
+ tenantRole?: UserTenantRole;
3214
+ createdBy?: string;
3215
+ createdAt: string;
3216
+ updatedAt: string;
3217
+ expiresAt: string;
3218
+ maxUses: number;
3219
+ usedCount: number;
3220
+ revokedAt?: string;
3221
+ active: boolean;
3222
+ url: string;
3223
+ }
3224
+ interface CreateInviteLinkInput {
3225
+ scope: "platform" | "tenant";
3226
+ email?: string;
3227
+ platformRole?: PlatformRole;
3228
+ tenantId?: string;
3229
+ tenantRole?: UserTenantRole;
3230
+ expiresInHours?: number;
3231
+ maxUses?: number;
3232
+ }
3233
+ interface InviteLinkClaimResult {
3234
+ status: "joined" | "pending_approval";
3235
+ scope: "platform" | "tenant";
3236
+ tenantId?: string;
3237
+ tenantRole?: UserTenantRole;
3238
+ platformRole?: PlatformRole;
3239
+ }
3240
+ /** Result of a platform member grant: a member or a pending invitation. */
3241
+ interface GrantPlatformMemberResult {
3242
+ member?: PlatformMemberSummary;
3243
+ invitation?: PlatformInvitationSummary;
3244
+ }
3245
+ interface GrantPlatformMemberInput {
3246
+ userId?: string;
3247
+ email?: string;
3248
+ role: PlatformRole;
3249
+ }
3250
+ interface AddPlatformTenantMemberInput {
3251
+ userId: string;
3252
+ tenantId: string;
3253
+ role: UserTenantRole;
3254
+ }
3255
+ /** Persisted platform audit record with a hydrated `createdAt`. */
3256
+ interface PlatformAuditRecord {
3257
+ id: string;
3258
+ initiator: {
3259
+ type: "human";
3260
+ userId: string;
3261
+ role: "owner" | "admin" | "auditor";
3262
+ } | {
3263
+ type: "bootstrap";
3264
+ } | {
3265
+ type: "system";
3266
+ component: string;
3267
+ };
3268
+ source: "admin_center" | "ops_agent" | "bootstrap" | "system";
3269
+ executor: {
3270
+ type: "admin_center";
3271
+ route: string;
3272
+ } | {
3273
+ type: "ops_agent";
3274
+ agentId: "platform-ops";
3275
+ threadId: string;
3276
+ runId: string;
3277
+ toolName: string;
3278
+ } | {
3279
+ type: "bootstrap";
3280
+ } | {
3281
+ type: "system";
3282
+ component: string;
3283
+ };
3284
+ tenantId?: string;
3285
+ action: "write" | "playbook";
3286
+ status: "ok" | "error" | "cancelled";
3287
+ summary: Record<string, unknown>;
3288
+ before?: Record<string, unknown>;
3289
+ after?: Record<string, unknown>;
3290
+ errorCode?: string;
3291
+ durationMs: number;
3292
+ createdAt: Date;
3293
+ }
3294
+ /** Filter and pagination options accepted by `listAudit`. */
3295
+ interface PlatformAuditQuery {
3296
+ initiatorUserId?: string;
3297
+ source?: PlatformAuditRecord["source"];
3298
+ tenantId?: string;
3299
+ action?: PlatformAuditRecord["action"];
3300
+ status?: PlatformAuditRecord["status"];
3301
+ from?: string;
3302
+ to?: string;
3303
+ limit?: number;
3304
+ offset?: number;
3305
+ }
3306
+ /** One effective platform rate-limit policy for the Admin Center view. */
3307
+ interface PlatformRateLimitPolicyView {
3308
+ policy: string;
3309
+ group: "authentication" | "invite" | "platform-api" | "mcp-app" | "internal";
3310
+ defaultLimit: number;
3311
+ effectiveLimit: number;
3312
+ windowMs: number;
3313
+ dimensions: string[];
3314
+ dimensionLimits?: Record<string, number>;
3315
+ enabled: boolean;
3316
+ editable: boolean;
3317
+ platformOverride: {
3318
+ limit?: number;
3319
+ enabled?: boolean;
3320
+ } | null;
3321
+ source: "platform" | "deployment";
3322
+ }
3323
+ /** Rate-limit policy matrix plus the per-tenant run quota. */
3324
+ interface PlatformRateLimitsView {
3325
+ policies: PlatformRateLimitPolicyView[];
3326
+ maxActiveRunTasksPerTenant: number | null;
3327
+ }
3328
+ /** Platform Ops Agent runtime configuration. */
3329
+ interface PlatformOpsConfig {
3330
+ enabled: boolean;
3331
+ modelKey: string;
3332
+ modelConfigured: boolean;
3333
+ }
3334
+ /** Platform Ops Agent runtime configuration client. */
3335
+ interface PlatformOpsClient {
3336
+ getConfig(): Promise<PlatformOpsConfig>;
3337
+ }
3338
+ /**
3339
+ * Platform-owned model provider catalog.
3340
+ *
3341
+ * Mirrors the tenant `client.modelProviders` namespace, but every call is
3342
+ * scoped to the reserved platform catalog rather than a tenant. Reads are
3343
+ * available to any platform role; mutations require platform admin.
3344
+ */
3345
+ interface PlatformModelProvidersClient {
3346
+ list(): Promise<ModelProviderPublicEntry[]>;
3347
+ get(providerId: string): Promise<ModelProviderPublicEntry>;
3348
+ create(input: CreateModelProviderRequest): Promise<ModelProviderPublicEntry>;
3349
+ update(providerId: string, input: UpdateModelProviderRequest): Promise<ModelProviderPublicEntry>;
3350
+ delete(providerId: string): Promise<void>;
3351
+ probe(input: ModelProviderProbeRequest): Promise<ModelProviderProbeResult>;
3352
+ setModels(providerId: string, models: ModelSelection[]): Promise<ModelProviderPublicEntry>;
3353
+ discover(providerId: string): Promise<ModelDiscoveryResult>;
3354
+ setModelEnabled(providerId: string, modelId: string, enabled: boolean): Promise<ModelProviderPublicEntry>;
3355
+ }
3356
+ /** Typed error thrown for non-success platform-management responses. */
3357
+ declare class PlatformClientError extends Error {
3358
+ readonly status: number;
3359
+ readonly code: string;
3360
+ readonly retryable: boolean;
3361
+ readonly details?: unknown | undefined;
3362
+ constructor(message: string, status: number, code: string, retryable?: boolean, details?: unknown | undefined);
3363
+ }
3364
+ /** Client for `/api/platform/*`. */
3365
+ declare class PlatformClient {
3366
+ private readonly baseURL;
3367
+ private readonly getHeaders;
3368
+ /** Platform-owned model provider catalog (reserved `__platform__` scope). */
3369
+ readonly modelProviders: PlatformModelProvidersClient;
3370
+ /** Platform Ops Agent threads and streaming messages. */
3371
+ readonly ops: PlatformOpsClient;
3372
+ constructor(baseURL: string, getHeaders: () => Record<string, string>);
3373
+ /**
3374
+ * Reads the platform-owned model catalog (providers plus visible models).
3375
+ *
3376
+ * This is the platform-scoped counterpart of `client.tenantModels.list()`.
3377
+ */
3378
+ modelCatalog(): Promise<TenantModelCatalog>;
3379
+ rateLimits(): Promise<PlatformRateLimitsView>;
3380
+ me(): Promise<PlatformRole | null>;
3381
+ /**
3382
+ * Reads the platform-guarded gateway identity and capability surface.
3383
+ *
3384
+ * @returns The same `GatewayInfo` payload as the legacy public `/info`.
3385
+ */
3386
+ getInfo(): Promise<GatewayInfo>;
3387
+ /**
3388
+ * Reads the platform-guarded JSON runtime metrics for this replica.
3389
+ *
3390
+ * @returns The same `SystemMetrics` payload as legacy `/metrics?format=json`.
3391
+ */
3392
+ getSystemMetrics(): Promise<SystemMetrics>;
3393
+ /**
3394
+ * Reads the effective platform settings, provenance, and version.
3395
+ *
3396
+ * @returns The current snapshot with ISO-string `updatedAt`.
3397
+ */
3398
+ getSettings(): Promise<PlatformSettingsSnapshot>;
3399
+ /**
3400
+ * Applies a partial settings patch and/or resets existing overrides.
3401
+ *
3402
+ * @param input Version guard plus the patch and reset paths.
3403
+ * @returns The committed snapshot after the update.
3404
+ */
3405
+ updateSettings(input: UpdatePlatformSettingsInput): Promise<PlatformSettingsSnapshot>;
3406
+ /**
3407
+ * Reads the safe runtime environment projection.
3408
+ *
3409
+ * @returns Runtime identity, public endpoints, dependency presence, and
3410
+ * diagnostics. Secret values are never included.
3411
+ */
3412
+ getEnvironment(): Promise<PlatformEnvironmentView>;
3413
+ /**
3414
+ * Reads platform audit records, newest first.
3415
+ *
3416
+ * @param query Optional filters and pagination. Undefined values are omitted
3417
+ * from the request.
3418
+ * @returns Hydrated records with `createdAt` as a `Date`.
3419
+ */
3420
+ listAudit(query?: PlatformAuditQuery): Promise<PlatformAuditRecord[]>;
3421
+ /**
3422
+ * Reads a single platform audit record by id.
3423
+ *
3424
+ * @param auditId Audit record id.
3425
+ * @returns The hydrated record with `createdAt` as a `Date`.
3426
+ */
3427
+ getAudit(auditId: string): Promise<PlatformAuditRecord>;
3428
+ /**
3429
+ * Resolves the public branding for the current gateway host.
3430
+ *
3431
+ * The public `/api/branding` route does not require a session, but this
3432
+ * method reuses the normal request helper and headers.
3433
+ */
3434
+ getBranding(): Promise<ResolvedPlatformBranding>;
3435
+ /** Reads the platform default and host-scoped branding settings. */
3436
+ getBrandingSettings(): Promise<BrandingSettingsView>;
3437
+ /**
3438
+ * Replaces the full branding configuration with versioning.
3439
+ *
3440
+ * @param input Version guard plus the complete branding settings document.
3441
+ * @returns The committed branding settings after the update.
3442
+ */
3443
+ updateBrandingSettings(input: UpdateBrandingSettingsInput): Promise<BrandingSettingsView>;
3444
+ listTenants(): Promise<PlatformTenant[]>;
3445
+ createTenant(input: CreatePlatformTenantInput): Promise<PlatformTenant>;
3446
+ updateTenant(tenantId: string, input: UpdatePlatformTenantInput): Promise<PlatformTenant>;
3447
+ deleteTenant(tenantId: string): Promise<void>;
3448
+ listUsers(): Promise<PlatformUserSummary[]>;
3449
+ createUser(input: CreatePlatformUserInput): Promise<PlatformUserSummary>;
3450
+ updateUser(userId: string, input: UpdatePlatformUserInput): Promise<PlatformUserSummary>;
3451
+ deleteUser(userId: string): Promise<void>;
3452
+ listMembers(): Promise<PlatformMemberSummary[]>;
3453
+ grantMember(input: GrantPlatformMemberInput): Promise<GrantPlatformMemberResult>;
3454
+ listInvitations(): Promise<PlatformInvitationSummary[]>;
3455
+ revokeInvitation(email: string): Promise<void>;
3456
+ updateMember(userId: string, role: PlatformRole): Promise<PlatformMemberSummary>;
3457
+ revokeMember(userId: string): Promise<void>;
3458
+ listTenantMembers(tenantId: string): Promise<PlatformTenantMember[]>;
3459
+ addTenantMember(input: AddPlatformTenantMemberInput): Promise<PlatformTenantMember>;
3460
+ listInviteLinks(): Promise<InviteLinkSummary[]>;
3461
+ createInviteLink(input: CreateInviteLinkInput): Promise<InviteLinkSummary>;
3462
+ revokeInviteLink(id: string): Promise<InviteLinkSummary>;
3463
+ getInviteLink(token: string): Promise<InviteLinkSummary>;
3464
+ claimInviteLink(token: string): Promise<InviteLinkClaimResult>;
3465
+ updateTenantMemberRole(tenantId: string, userId: string, role: UserTenantRole): Promise<PlatformTenantMember>;
3466
+ removeTenantMember(tenantId: string, userId: string): Promise<void>;
3467
+ listOidcClaims(status?: OidcIdentityClaimStatus | "all"): Promise<OidcIdentityClaimSummary[]>;
3468
+ updateOidcClaimEmail(id: string, email: string): Promise<OidcIdentityClaimSummary>;
3469
+ approveOidcClaim(id: string, input?: ApproveOidcIdentityClaimInput): Promise<OidcIdentityClaimSummary>;
3470
+ rejectOidcClaim(id: string): Promise<OidcIdentityClaimSummary>;
3471
+ private request;
3472
+ }
3473
+
3474
+ /**
3475
+ * Web client class for interacting with the Axiom Lattice Agent Service API
3476
+ */
3477
+ declare class Client extends AbstractClient {
3478
+ private headers;
3479
+ /** Last SSE event id observed per thread, for automatic resume. */
3480
+ private resumeEventIds;
3481
+ resources: ResourcesClient;
3482
+ exportImport: ExportImportClient;
3483
+ readonly projectRooms: ProjectRoomsClient;
3484
+ readonly workspaceRooms: WorkspaceRoomsClient;
3485
+ readonly workspaceMembers: WorkspaceMembersClient;
3486
+ readonly roomEvents: RoomEventsClient;
3487
+ readonly oidcProviders: OidcProvidersClient;
3488
+ readonly platform: PlatformClient;
3489
+ /**
3490
+ * Creates a new Client instance
3491
+ * @param config - Configuration options for the client
3492
+ */
3493
+ constructor(config: ClientConfig);
3494
+ /**
3495
+ * Helper method to handle fetch responses and errors
3496
+ * @private
3497
+ */
3498
+ private handleResponse;
3499
+ /**
3500
+ * Helper method to make fetch requests
3501
+ * @private
3502
+ */
3503
+ private fetchWithTimeout;
3504
+ private static globalWorkspaceHeaders;
3505
+ /**
3506
+ * Set tenant ID for multi-tenant environments
3507
+ * @param tenantId - Tenant identifier
3508
+ */
3509
+ setTenantId(tenantId: string): void;
3510
+ /**
3511
+ * Set workspace and project headers for THIS client instance.
3512
+ * Instance-scoped: each Client instance carries its own context, so
3513
+ * nested page-level containers get isolated headers.
3514
+ * @param workspaceId - Workspace identifier
3515
+ * @param projectId - Project identifier
3516
+ */
3517
+ setWorkspaceContext(workspaceId?: string, projectId?: string): void;
3518
+ /**
3519
+ * Set workspace and project headers globally (legacy static API).
3520
+ * Used by callers without a client instance. Affects all instances
3521
+ * that fall back to global headers.
3522
+ * @param workspaceId - Workspace identifier
3523
+ * @param projectId - Project identifier
3524
+ */
3525
+ static setWorkspaceContext(workspaceId?: string, projectId?: string): void;
3526
+ /**
3527
+ * Get workspace headers for THIS instance (merged with global fallback)
3528
+ */
3529
+ getWorkspaceHeaders(): Record<string, string>;
3530
+ /**
3531
+ * Instance-only workspace headers (never merged with the process-global
3532
+ * Console context). Runtime transports use this so a web-app scope cannot
3533
+ * inherit a Console tenant/project selection from another client.
3534
+ */
3535
+ getInstanceWorkspaceHeaders(): Record<string, string>;
3536
+ /**
3537
+ * Get global workspace headers (legacy static API)
3538
+ */
3539
+ static getWorkspaceHeaders(): Record<string, string>;
3540
+ /**
3541
+ * Creates a new instance of the client with the given configuration
3542
+ * @param config - Configuration options for the client
3543
+ * @returns A new Client instance
3544
+ */
3545
+ protected createInstance(config: ClientConfig): AbstractClient;
3546
+ /**
3547
+ * Implementation of the abstract makeRequest method for web clients
3548
+ * @param url - The URL to make the request to
3549
+ * @param options - Request options
3550
+ * @returns A promise that resolves to the response data
3551
+ */
3552
+ protected makeRequest<T>(url: string, options?: {
3553
+ method?: string;
3554
+ body?: any;
3555
+ headers?: Record<string, string>;
3556
+ }): Promise<T>;
3557
+ /**
3558
+ * Implementation of the abstract streamRequest method for web clients
3559
+ */
3560
+ protected streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
3561
+ /**
3562
+ * Resume streaming from a known position
3563
+ * @param options - Options for resuming the stream
3564
+ * @param onEvent - Callback function that receives stream events
3565
+ * @param onComplete - Optional callback function called when streaming completes
3566
+ * @param onError - Optional callback function called when an error occurs
3567
+ * @returns A function that can be called to stop the stream
3568
+ */
3569
+ resumeStream(options: ResumeStreamOptions, onEvent: (event: MessageChunk) => void, onComplete?: () => void, onError?: (error: Error) => void): () => void;
3570
+ /**
3571
+ * Stream run results
3572
+ * @param options - Options for streaming run results
3573
+ * @param onEvent - Callback function that receives stream events
3574
+ * @param onComplete - Optional callback function called when streaming completes
3575
+ * @param onError - Optional callback function called when an error occurs
3576
+ * @returns A function that can be called to stop the stream
3577
+ */
3578
+ /**
3579
+ * Open an SSE stream and yield parsed events.
3580
+ *
3581
+ * Headers (auth, tenant, workspace) are resolved live at request time, so
3582
+ * a tenant selected after client construction is always sent.
3583
+ *
3584
+ * @param path - API path, e.g. "/api/eval/runs/r1/stream"
3585
+ * @param signal - Optional AbortSignal to cancel the stream
3586
+ * @yields Parsed `{ event, data }` pairs
3587
+ */
3588
+ streamEvents(path: string, signal?: AbortSignal): AsyncIterableIterator<StreamEvent>;
3589
+ /**
3590
+ * Get all headers including workspace context
3591
+ * @private
3592
+ */
3593
+ protected getAllHeaders(): Record<string, string>;
3594
+ protected getThreadEventHeaders(): Record<string, string>;
3595
+ protected bodyAffinityHeaders(body: unknown): Record<string, string>;
3596
+ private streamRun;
3597
+ }
3598
+
3599
+ /**
3600
+ * Identity presented to an Agent Web App runtime by {@link RuntimeAxiomClient}.
3601
+ *
3602
+ * Mirrors the web-app SDK identity union: `verified` sessions authenticate
3603
+ * with a short-lived `Authorization: Bearer` token resolved (and refreshed)
3604
+ * per transport use, while `unverified` sessions identify through the stable
3605
+ * `X-Axiom-External-User-Id` header the gateway accepts without a token.
3606
+ */
3607
+ type RuntimeAxiomIdentity = {
3608
+ mode: "verified";
3609
+ tokenProvider: () => Promise<string>;
3610
+ } | {
3611
+ mode: "unverified";
3612
+ userId: string;
3613
+ };
3614
+ /**
3615
+ * AxiomClient transport wired to an Agent Web App runtime instead of the
3616
+ * Console. Reuse-first: only the transport differs. `baseURL` points at
3617
+ * `<gateway>/api/web-apps/:webAppId/runtime`, every Console `/api/...` path
3618
+ * the chat stack produces lands on the gateway's `/runtime/api` console
3619
+ * mirror, and the web-app identity (bearer or external-user header) is
3620
+ * injected fresh per request.
3621
+ *
3622
+ * The chat stack (AgentThreadContext + Chating) therefore runs unmodified.
3623
+ */
3624
+ declare class RuntimeAxiomClient extends Client {
3625
+ private readonly gatewayUrl;
3626
+ private readonly webAppId;
3627
+ private readonly identity;
3628
+ private token;
3629
+ private tokenPromise;
3630
+ constructor(config: Omit<ClientConfig, "apiKey" | "baseURL"> & {
3631
+ gatewayUrl: string;
3632
+ webAppId: string;
3633
+ identity: RuntimeAxiomIdentity;
3634
+ });
3635
+ /**
3636
+ * Resolve (and cache) the current identity credential.
3637
+ *
3638
+ * - `verified`: resolves the bearer token from the provider (single-flight;
3639
+ * call again later to force a refresh, or pass through a fresh provider).
3640
+ * - `unverified`: no credential is needed; returns `""`.
3641
+ *
3642
+ * Transport methods resolve this lazily, so the chat stack needs no explicit
3643
+ * priming — the first request triggers the token provider.
3644
+ */
3645
+ primeToken(): Promise<string>;
3646
+ private identityHeaders;
3647
+ protected getAllHeaders(): Record<string, string>;
3648
+ protected makeRequest<T>(url: string, options?: {
3649
+ method?: string;
3650
+ body?: unknown;
3651
+ headers?: Record<string, string>;
3652
+ }): Promise<T>;
3653
+ private getBaseUrl;
3654
+ /**
3655
+ * Clone into a real sibling instance sharing the runtime identity so the
3656
+ * `AxiomLatticeProvider` per-assistant `clone({ assistantId })` cache keeps
3657
+ * working (each clone carries its own resolved credential cache).
3658
+ */
3659
+ protected createInstance(config: ClientConfig): Client;
3660
+ protected streamRequest(_options: RunOptions, _onEvent: (event: MessageChunk) => void, _onComplete?: (state?: AgentState) => void, _onError?: (error: Error) => void): () => void;
3661
+ }
3662
+
3663
+ /**
3664
+ * WeChat Mini Program client for interacting with the Axiom Lattice Agent Service API
3665
+ */
3666
+ declare class WeChatClient extends AbstractClient {
3667
+ /**
3668
+ * Creates a new WeChatClient instance
3669
+ * @param config - Configuration options for the client
3670
+ */
3671
+ constructor(config: ClientConfig);
3672
+ /**
3673
+ * Set tenant ID for multi-tenant environments
3674
+ * @param tenantId - Tenant identifier
3675
+ */
3676
+ setTenantId(tenantId: string): void;
3677
+ /**
3678
+ * Set workspace and project headers for requests made by this client.
3679
+ * @param workspaceId - Workspace identifier, or undefined to leave it unchanged
3680
+ * @param projectId - Project identifier, or undefined to leave it unchanged
3681
+ */
3682
+ setWorkspaceContext(workspaceId?: string, projectId?: string): void;
3683
+ /**
3684
+ * Get the workspace and project headers currently applied to this client.
3685
+ * @returns A copy of the current workspace and project header values
3686
+ */
3687
+ getWorkspaceHeaders(): Record<string, string>;
3688
+ /**
3689
+ * Creates a new instance of the client with the given configuration
3690
+ * @param config - Configuration options for the client
3691
+ * @returns A new WeChatClient instance
3692
+ */
3693
+ protected createInstance(config: ClientConfig): AbstractClient;
3694
+ /**
3695
+ * Implementation of the abstract makeRequest method for WeChat clients
3696
+ * @param url - The URL to make the request to
3697
+ * @param options - Request options
3698
+ * @returns A promise that resolves to the response data
3699
+ */
3700
+ protected makeRequest<T>(url: string, options?: {
3701
+ method?: string;
3702
+ body?: any;
3703
+ headers?: Record<string, string>;
3704
+ }): Promise<T>;
3705
+ /**
3706
+ * Implementation of the abstract streamRequest method for WeChat clients
3707
+ */
3708
+ protected streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
3709
+ /**
3710
+ * Returns the WeChat request primitive or throws a descriptive error when
3711
+ * this client is used outside a WeChat Mini Program runtime.
3712
+ */
3713
+ private getWxRequest;
3714
+ /**
3715
+ * Builds a stateful chunk processor: UTF-8 is decoded across chunk
3716
+ * boundaries and only complete SSE lines are parsed, so a JSON frame or a
3717
+ * multibyte character split across chunks is not lost.
3718
+ */
3719
+ private createChunkProcessor;
3720
+ /**
3721
+ * Extracts a human-readable message from an error body. With
3722
+ * `responseType: "text"` the body can be an object, a JSON string, or plain
3723
+ * text.
3724
+ */
3725
+ private errorMessageFromBody;
3726
+ private recordMessage;
3727
+ /**
3728
+ * Maps a non-2xx stream response to the same typed errors as `makeRequest`,
3729
+ * returning `undefined` for 2xx responses.
3730
+ */
3731
+ private streamStatusError;
3732
+ /**
3733
+ * Resume streaming from a known position
3734
+ * @param options - Options for resuming the stream
3735
+ * @param onEvent - Callback function that receives stream events
3736
+ * @param onComplete - Optional callback function called when streaming completes
3737
+ * @param onError - Optional callback function called when an error occurs
3738
+ * @returns A function that can be called to stop the stream
3739
+ */
3740
+ resumeStream(options: ResumeStreamOptions, onEvent: (event: MessageChunk) => void, onComplete?: () => void, onError?: (error: Error) => void): () => void;
3741
+ /**
3742
+ * Helper method to make WeChat HTTP requests
3743
+ * @private
3744
+ */
3745
+ private wechatRequest;
3746
+ /**
3747
+ * Stream run results using WeChat's downloadFile API
3748
+ * @param options - Options for streaming run results
3749
+ * @param onEvent - Callback function that receives stream events
3750
+ * @param onComplete - Optional callback function called when streaming completes
3751
+ * @param onError - Optional callback function called when an error occurs
3752
+ * @returns A function that can be called to stop the stream
3753
+ */
3754
+ private streamRun;
3755
+ decodeUint8Array(uint8Array: ArrayBuffer): any;
3756
+ buf2hex(arrayBuffer: ArrayBuffer): string;
3757
+ /**
3758
+ * Convert hexadecimal string to text (supports Chinese characters)
3759
+ * @param {String} hex - Hexadecimal string
3760
+ * @return {String} Decoded string including Chinese characters
3761
+ */
3762
+ hexToStr(hex: string): any;
3763
+ }
3764
+
3765
+ /**
3766
+ * WorkspaceClient
3767
+ *
3768
+ * Client for workspace and project management API
3769
+ */
3770
+
3771
+ declare class WorkspaceClient {
3772
+ private baseURL;
3773
+ private headers;
3774
+ private tenantId;
3775
+ resources: ResourcesClient;
3776
+ constructor(config: ClientConfig, tenantId?: string);
3777
+ private request;
3778
+ listWorkspaces(): Promise<Workspace[]>;
3779
+ createWorkspace(data: CreateWorkspaceRequest): Promise<Workspace>;
3780
+ getWorkspace(workspaceId: string): Promise<Workspace>;
3781
+ updateWorkspace(workspaceId: string, updates: UpdateWorkspaceRequest): Promise<Workspace>;
3782
+ deleteWorkspace(workspaceId: string): Promise<void>;
3783
+ listProjects(workspaceId: string, kind?: ProjectKind): Promise<Project[]>;
3784
+ createProject(workspaceId: string, data: CreateProjectRequest): Promise<Project>;
3785
+ getProject(workspaceId: string, projectId: string): Promise<Project>;
3786
+ updateProject(workspaceId: string, projectId: string, updates: UpdateProjectRequest): Promise<Project>;
3787
+ deleteProject(workspaceId: string, projectId: string): Promise<void>;
3788
+ listPath(workspaceId: string, projectId: string, path?: string, assistantId?: string): Promise<FileItem[]>;
3789
+ readFile(workspaceId: string, projectId: string, path: string, offset?: number, limit?: number, assistantId?: string): Promise<{
3790
+ content: string;
3791
+ offset: number;
3792
+ limit: number;
3793
+ }>;
3794
+ /**
3795
+ * Upload a file to the workspace project storage.
3796
+ *
3797
+ * Uses multipart/form-data against:
3798
+ * POST /api/workspaces/:workspaceId/projects/:projectId/uploadfile
3799
+ */
3800
+ uploadFile(workspaceId: string, projectId: string, file: Blob, path?: string, assistantId?: string): Promise<FileItem>;
3801
+ getFileDownloadUrl(workspaceId: string, projectId: string, filePath: string, assistantId?: string): string;
3802
+ /**
3803
+ * Download a project folder as an authenticated ZIP Blob.
3804
+ *
3805
+ * The request is scoped by this client's bearer token and tenant headers;
3806
+ * callers are responsible for triggering browser download behavior.
3807
+ *
3808
+ * @param workspaceId - Workspace identifier.
3809
+ * @param projectId - Project identifier.
3810
+ * @param folderPath - Backend folder path to archive.
3811
+ * @param assistantId - Optional sandbox assistant context.
3812
+ * @returns The ZIP response as a Blob.
3813
+ * @throws Error when the authenticated request fails.
3814
+ */
3815
+ downloadFolder(workspaceId: string, projectId: string, folderPath: string, assistantId?: string): Promise<Blob>;
3816
+ /**
3817
+ * Get a URL for viewing a file inline in the browser (not download).
3818
+ * The file will be displayed in the browser rather than downloaded.
3819
+ */
3820
+ getFileViewUrl(workspaceId: string, projectId: string, filePath: string, assistantId?: string): string;
3821
+ /**
3822
+ * Browse local filesystem directories for the folder picker.
3823
+ *
3824
+ * Restricted to the user's home directory for security.
3825
+ */
3826
+ browseFilesystem(fsPath?: string): Promise<{
3827
+ path: string;
3828
+ parentPath?: string;
3829
+ entries: Array<{
3830
+ name: string;
3831
+ path: string;
3832
+ isDirectory: boolean;
3833
+ }>;
3834
+ }>;
3835
+ }
3836
+
3837
+ /**
3838
+ * ChunkMessageMerger
3839
+ *
3840
+ * A utility for handling streaming message chunks and merging them into complete messages.
3841
+ */
3842
+
3843
+ /**
3844
+ * Creates a simple message merger for handling streaming message chunks
3845
+ * @returns An object with methods to push chunks and retrieve merged messages
3846
+ */
3847
+ declare function createSimpleMessageMerger(): {
3848
+ push: (chunk: MessageChunk) => void;
3849
+ initialMessages: (msgs: any[]) => void;
3850
+ getMessages: () => any[];
3851
+ getMessagesWithoutToolCalls: () => any[];
3852
+ removeMessageById: (messageId: string) => boolean;
3853
+ reset: () => void;
3854
+ };
3855
+
3856
+ /**
3857
+ * Normalize a LangChain/MCP tool message into model-visible text plus a
3858
+ * UI-only rich payload.
3859
+ *
3860
+ * `@langchain/mcp-adapters` returns MCP `CallToolResult` data in two places:
3861
+ * the message `content` (string, a single block object, or a block array) and
3862
+ * the `artifact` array (`{ type: "mcp_structured_content" | "mcp_meta" }`
3863
+ * sentinels plus non-text image/audio/resource/file blocks). The frontend must
3864
+ * render that data without leaking it into the model-visible `content`, so this
3865
+ * is the single normalization point shared by live streaming and history.
3866
+ */
3867
+
3868
+ /** Result of {@link normalizeToolResult}. */
3869
+ interface NormalizedToolResult {
3870
+ /** Model-visible plain text (still contains any `mcp_app` fence). */
3871
+ text: string;
3872
+ /** UI-only rich payload; absent when the result carried none. */
3873
+ ui?: ToolCallUi;
3874
+ }
3875
+ /**
3876
+ * Normalize a tool message into `{ text, ui }`.
3877
+ *
3878
+ * @param message - Raw tool message with its `content` and `artifact`.
3879
+ * @returns Model-visible text plus the UI-only payload (when non-empty).
3880
+ *
3881
+ * @example
3882
+ * ```ts
3883
+ * const { text, ui } = normalizeToolResult({ content: "ok", artifact: [{ type: "mcp_structured_content", data: { a: 1 } }] });
3884
+ * // text === "ok"; ui?.structuredContent deep-equals { a: 1 }
3885
+ * ```
3886
+ */
3887
+ declare function normalizeToolResult(message: {
3888
+ content?: unknown;
3889
+ artifact?: unknown;
3890
+ }): NormalizedToolResult;
3891
+
3892
+ /**
3893
+ * Runtime client for a shared MCP App.
3894
+ *
3895
+ * The share token is the only credential. This client deliberately exposes the
3896
+ * same `mcpApps` surface as {@link Client} so the MCP App sandbox can be reused
3897
+ * without the console session or tenant headers.
3898
+ */
3899
+
3900
+ /** Options for {@link McpAppShareRuntimeClient}. */
3901
+ interface McpAppShareRuntimeClientOptions {
3902
+ /** Gateway origin that serves the share routes. */
3903
+ baseURL: string;
3904
+ /** Opaque share token from `/s/:token`. */
3905
+ token: string;
3906
+ }
3907
+ /** Minimal MCP App host client surface used by `McpAppSandbox`. */
3908
+ interface McpAppShareRuntimeClientApi {
3909
+ config: {
3910
+ baseURL: string;
3911
+ };
3912
+ mcpApps: {
3913
+ getResource(ref: McpUiRef): Promise<McpUiResourceResponse>;
3914
+ rpc(ref: McpUiRef, method: string, params: Record<string, unknown>): Promise<unknown>;
3915
+ };
3916
+ bootstrap(): Promise<McpAppShareBootstrap>;
3917
+ unlock(password: string): Promise<void>;
3918
+ }
3919
+ /**
3920
+ * Client for `/api/mcp-app-shares/:token/*`.
3921
+ */
3922
+ declare class McpAppShareRuntimeClient implements McpAppShareRuntimeClientApi {
3923
+ readonly config: {
3924
+ baseURL: string;
3925
+ };
3926
+ readonly mcpApps: McpAppShareRuntimeClientApi["mcpApps"];
3927
+ private readonly baseURL;
3928
+ private readonly token;
3929
+ constructor(options: McpAppShareRuntimeClientOptions);
3930
+ /** Load the app identity and a fresh first tool result. */
3931
+ bootstrap(): Promise<McpAppShareBootstrap>;
3932
+ /** Exchange the share password for the unlock cookie. */
3933
+ unlock(password: string): Promise<void>;
3934
+ private get;
3935
+ private request;
3936
+ private parse;
3937
+ }
3938
+
3939
+ export { type A2AKeyListItem, type A2AKeysListResponse, type AbortAgentParams, AbstractClient, type AddPlatformTenantMemberInput, type AddProjectBotMembershipInput, type AddProjectMembershipInput, type AgentCron, type AgentGraphTree, type AgentRunStatus, type AgentState, type AgentWebAppsListResponse, ApiError, type ApproveOidcIdentityClaimInput, type ArchiveInput, type Assistant, type AssistantListResponse, type AssistantResponse, AuthenticationError, type BrandingSettingsView, type CapabilityBundleListResponse, type ChatResponse, type ChatSendOptions, type ChatStreamOptions, Client, type ClientConfig, type CommandInputRespondArgs, type CommandInputRespondResult, type CommandRunStartArgs, type CommandRunStartInput, type CommandRunStartResult, type CompleteTaskInput, type CompleteTaskResponse, type CopiedThread, type CreateA2AKeyInput, type CreateAssistantOptions, type CreateCronInput, type CreateInviteLinkInput, type CreateOidcProviderInput, type CreatePlatformTenantInput, type CreatePlatformUserInput, type CreateProjectRequest, type CreateStatelessCronInput, type CreateThreadCronInput, type CreateThreadOptions, type CreateWorkspaceRequest, type CronCountFilters, type CronMultitaskStrategy, type CronOnRunCompleted, type CronSearchFilters, type DatabaseConfigResponse, type DatabaseConfigsListResponse, type DatasourcesListResponse, type ExportBundle, type ExportConfigResult, type ExportConfirmationRequired, type ExportDownload, type ExportEntityIds, type ExportEntityPreview, type ExportEntityPreviewMap, ExportImportClient, type ExportableEntity, type ExportableTypeInfo, type FileItem, type GatewayInfo, type GetMessagesOptions, type GetScheduledTasksOptions, type GrantPlatformMemberInput, type GrantPlatformMemberResult, type ImportApplyResult, type ImportConflict, type ImportEntityResult, type ImportInsertion, type ImportPreviewError, type ImportPreviewResult, type ImportResolution, type ImportResolutions, type ImportSource, type InvalidCapabilityBundleSummary, type InviteLinkClaimResult, type InviteLinkSummary, type KeyExposure, type ListAgentWebAppsParams, type ListProjectRoomMessagesOptions, type ListThreadsOptions, type LocalA2ATemplatesListResponse, McpAppShareRuntimeClient, type McpAppShareRuntimeClientApi, type McpAppShareRuntimeClientOptions, type McpServerResponse, type McpServersListResponse, type McpUiResourceResponse, type MetricsConfigResponse, type MetricsConfigsListResponse, type MutationExpectedUpdatedAt, NetworkError, type NormalizedToolResult, type OidcIdentityClaimExistingUser, type OidcIdentityClaimSummary, OidcProviderClientError, type OidcProviderSummary, type OidcProviderTestResult, OidcProvidersClient, type OpenAuditLogRecord, type PendingMessage, type PlatformAuditQuery, type PlatformAuditRecord, PlatformClient, PlatformClientError, type PlatformEnvironmentDiagnostics, type PlatformEnvironmentEndpoints, type PlatformEnvironmentRuntime, type PlatformEnvironmentSettings, type PlatformEnvironmentView, type PlatformInvitationSummary, type PlatformMemberSummary, type PlatformModelProvidersClient, type PlatformOpsClient, type PlatformOpsConfig, type PlatformRateLimitPolicyView, type PlatformRateLimitsView, type PlatformSettingsSnapshot, type PlatformTenant, type PlatformTenantMember, type PlatformUserSummary, type Project, type ProjectCapabilitiesResponse, type ProjectKind, type ProjectRecord, type ProjectRoomBotRecord, ProjectRoomClientError, type ProjectRoomDispatchErrorCode, type ProjectRoomDispatchResult, type ProjectRoomInterruptAnswerInput, type ProjectRoomMembershipRecord, type ProjectRoomMessageRecord, type ProjectRoomPublicBotRecord, type ProjectRoomPublicMembershipRecord, type ProjectRoomRecord, type ProjectRoomSendResult, ProjectRoomsClient, type PruneThreadInput, type PruneThreadResult, type RegisterToolOptions, type RemovePendingMessageOptions, ResourcesClient, type ResumeProjectRoomInterruptInput, type ResumeStreamOptions, type RetryConfig, type RoomEventScopeRecord, RoomEventsClient, type RunCancelActiveResult, type RunCancelOptions, type RunCancelResult, type RunCreateInput, type RunCreateOptions, type RunCreateResult, type RunOptions, type RunRecord, RuntimeAxiomClient, type RuntimeAxiomIdentity, ScheduleExecutionType, type ScheduledTask, ScheduledTaskStatus, type ScheduledTasksListResponse, type SendProjectRoomMessageInput, type StorageType, type StoreItem, type StorePutInput, type StoreSearchInput, type StreamCallbacks, type StreamEvent, type SystemMetrics, type SystemMetricsChunk, type SystemMetricsWorker, type TaskCommandInput, type TaskCommandResponse, type TaskLifecycleWarning, type TaskResponse, type TasksListResponse, type TestConnectionResponse, type TestMcpServerResponse, type TestOidcProviderInput, type TestStoredOidcProviderOverrides, type Thread, type ThreadEvent, type ThreadEventStreamError, type ThreadEventStreamOptions, type ThreadHistoryPage, type ThreadListResponse, type ThreadResponse, type ThreadStatusInfo, type ThreadSuperstepInput, type Tool, type ToolResponse, type ToolsListResponse, type Transport, type UpdateAgentCronInput, type UpdateAssistantOptions, type UpdateBrandingSettingsInput, type UpdateOidcProviderInput, type UpdatePlatformSettingsInput, type UpdatePlatformTenantInput, type UpdatePlatformUserInput, type UpdateProjectBotMembershipInput, type UpdateProjectMembershipInput, type UpdateProjectRequest, type UpdateThreadOptions, type UpdateWorkspaceRequest, WeChatClient, type Workspace, WorkspaceClient, type WorkspaceMemberRecord, WorkspaceMembersClient, type WorkspaceRoomBusinessEvent, type WorkspaceRoomControlEvent, type WorkspaceRoomEntryRecord, type WorkspaceRoomEventConnection, type WorkspaceRoomEventFrame, type WorkspaceRoomKnownBusinessEvent, type WorkspaceRoomUnknownBusinessEvent, WorkspaceRoomsClient, createSimpleMessageMerger, normalizeToolResult };