@axiom-lattice/client-sdk 8.4.1 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -82,6 +82,19 @@ interface ClientConfig {
82
82
  * Additional headers to include in requests (optional)
83
83
  */
84
84
  headers?: Record<string, string>;
85
+ /**
86
+ * Latest access token for every request and SSE connection. When provided,
87
+ * the client reads it per request instead of the constructor snapshot.
88
+ */
89
+ getApiKey?: () => string | null;
90
+ /**
91
+ * Host-owned single-flight session refresh. Returns the new token, or null
92
+ * when the session is no longer valid.
93
+ */
94
+ refreshSession?: () => Promise<{
95
+ token: string;
96
+ expiresAt: number;
97
+ } | null>;
85
98
  /**
86
99
  * Configuration for retry behavior (optional)
87
100
  */
@@ -602,7 +615,8 @@ declare class NetworkError extends Error {
602
615
  constructor(message: string);
603
616
  }
604
617
  declare class AuthenticationError extends Error {
605
- constructor(message: string);
618
+ readonly code?: string | undefined;
619
+ constructor(message: string, code?: string | undefined);
606
620
  }
607
621
  /**
608
622
  * Schedule execution type
@@ -1413,6 +1427,79 @@ interface StreamEvent {
1413
1427
  event: string;
1414
1428
  data: Record<string, unknown>;
1415
1429
  }
1430
+ /** Origin of a durable run record. */
1431
+ type AgentRunSource = "run_api" | "legacy" | "project_task";
1432
+ /** Derived monitor kind for a persisted thread. */
1433
+ type ThreadMonitorKind = "conversation" | "room_presence" | "task_execution" | "open_api" | "web_app" | "cron" | "channel";
1434
+ /** Filters accepted by `client.monitor.threads.list`. */
1435
+ interface ThreadMonitorQuery {
1436
+ limit?: number;
1437
+ offset?: number;
1438
+ kind?: ThreadMonitorKind;
1439
+ assistantId?: string;
1440
+ createdAfter?: string;
1441
+ }
1442
+ /** Safe thread projection returned by the tenant monitor. */
1443
+ interface ThreadMonitorRecord {
1444
+ id: string;
1445
+ tenantId: string;
1446
+ assistantId: string;
1447
+ kind: ThreadMonitorKind;
1448
+ workspaceId?: string;
1449
+ projectId?: string;
1450
+ roomId?: string;
1451
+ taskId?: string;
1452
+ createdAt: string;
1453
+ updatedAt: string;
1454
+ expiresAt?: string;
1455
+ }
1456
+ /** Filters accepted by `client.monitor.runs.list`. */
1457
+ interface AgentRunMonitorQuery {
1458
+ limit?: number;
1459
+ offset?: number;
1460
+ status?: AgentRunStatus;
1461
+ source?: AgentRunSource;
1462
+ assistantId?: string;
1463
+ createdAfter?: string;
1464
+ }
1465
+ /** Safe run projection returned by the tenant monitor. */
1466
+ interface AgentRunMonitorRecord {
1467
+ runId: string;
1468
+ tenantId: string;
1469
+ assistantId: string;
1470
+ threadId: string;
1471
+ workspaceId?: string;
1472
+ projectId?: string;
1473
+ taskId?: string;
1474
+ status: AgentRunStatus;
1475
+ source: AgentRunSource;
1476
+ owner: string | null;
1477
+ attempts: number;
1478
+ error: string | null;
1479
+ cancelRequested: boolean;
1480
+ leaseExpiresAt: number | null;
1481
+ createdAt: number;
1482
+ updatedAt: number;
1483
+ startedAt: number | null;
1484
+ finishedAt: number | null;
1485
+ messageId?: string | null;
1486
+ inputPreview?: string | null;
1487
+ }
1488
+ /** Tenant monitor overview payload. */
1489
+ interface TenantMonitorOverview {
1490
+ since: string;
1491
+ counts: Record<AgentRunStatus, number>;
1492
+ oldestPendingAgeMs: number | null;
1493
+ stuckRunning: number;
1494
+ pendingThreads: number;
1495
+ }
1496
+ /** Generic server-paginated result. */
1497
+ interface MonitorPage<T> {
1498
+ records: T[];
1499
+ total: number;
1500
+ limit: number;
1501
+ offset: number;
1502
+ }
1416
1503
 
1417
1504
  /** Completion evidence accepted by the task lifecycle endpoint. */
1418
1505
  interface CompleteTaskInput {
@@ -1921,13 +2008,17 @@ declare abstract class AbstractClient {
1921
2008
  */
1922
2009
  auditLogs: (params?: {
1923
2010
  credentialId?: string;
2011
+ projectId?: string;
1924
2012
  domain?: string;
1925
- status?: "ok" | "error";
2013
+ action?: string;
2014
+ status?: "ok" | "error" | "cancelled";
1926
2015
  from?: string;
1927
2016
  to?: string;
1928
2017
  limit?: number;
1929
2018
  offset?: number;
1930
2019
  }) => Promise<OpenAuditLogRecord[]>;
2020
+ /** Read one tenant-scoped Open audit record by id. */
2021
+ auditLog: (id: string) => Promise<OpenAuditLogRecord>;
1931
2022
  };
1932
2023
  /**
1933
2024
  * MCP Apps namespace for resolving UI resources and proxying allow-listed
@@ -2452,6 +2543,20 @@ declare abstract class AbstractClient {
2452
2543
  */
2453
2544
  cancelActive: (threadId: string, assistantId?: string) => Promise<RunCancelActiveResult>;
2454
2545
  };
2546
+ /**
2547
+ * Read-only tenant monitor surface (owner/admin only on the server).
2548
+ */
2549
+ monitor: {
2550
+ overview: (options?: {
2551
+ sinceHours?: number;
2552
+ }) => Promise<TenantMonitorOverview>;
2553
+ threads: {
2554
+ list: (query?: ThreadMonitorQuery) => Promise<MonitorPage<ThreadMonitorRecord>>;
2555
+ };
2556
+ runs: {
2557
+ list: (query?: AgentRunMonitorQuery) => Promise<MonitorPage<AgentRunMonitorRecord>>;
2558
+ };
2559
+ };
2455
2560
  /**
2456
2561
  * Tenant-scoped namespaced key-value store (viewer/editor surface).
2457
2562
  */
@@ -3553,7 +3658,14 @@ declare class Client extends AbstractClient {
3553
3658
  method?: string;
3554
3659
  body?: any;
3555
3660
  headers?: Record<string, string>;
3556
- }): Promise<T>;
3661
+ }, retry?: boolean): Promise<T>;
3662
+ private refreshInFlight;
3663
+ /** Host-facing single-flight refresh (used by ThreadStream on a 401). */
3664
+ refreshSession(): Promise<{
3665
+ token: string;
3666
+ expiresAt: number;
3667
+ } | null>;
3668
+ private refreshOnce;
3557
3669
  /**
3558
3670
  * Implementation of the abstract streamRequest method for web clients
3559
3671
  */
@@ -3936,4 +4048,4 @@ declare class McpAppShareRuntimeClient implements McpAppShareRuntimeClientApi {
3936
4048
  private parse;
3937
4049
  }
3938
4050
 
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 };
4051
+ export { type A2AKeyListItem, type A2AKeysListResponse, type AbortAgentParams, AbstractClient, type AddPlatformTenantMemberInput, type AddProjectBotMembershipInput, type AddProjectMembershipInput, type AgentCron, type AgentGraphTree, type AgentRunMonitorQuery, type AgentRunMonitorRecord, type AgentRunSource, 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 MonitorPage, 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 TenantMonitorOverview, type TestConnectionResponse, type TestMcpServerResponse, type TestOidcProviderInput, type TestStoredOidcProviderOverrides, type Thread, type ThreadEvent, type ThreadEventStreamError, type ThreadEventStreamOptions, type ThreadHistoryPage, type ThreadListResponse, type ThreadMonitorKind, type ThreadMonitorQuery, type ThreadMonitorRecord, 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 };
package/dist/index.d.ts CHANGED
@@ -82,6 +82,19 @@ interface ClientConfig {
82
82
  * Additional headers to include in requests (optional)
83
83
  */
84
84
  headers?: Record<string, string>;
85
+ /**
86
+ * Latest access token for every request and SSE connection. When provided,
87
+ * the client reads it per request instead of the constructor snapshot.
88
+ */
89
+ getApiKey?: () => string | null;
90
+ /**
91
+ * Host-owned single-flight session refresh. Returns the new token, or null
92
+ * when the session is no longer valid.
93
+ */
94
+ refreshSession?: () => Promise<{
95
+ token: string;
96
+ expiresAt: number;
97
+ } | null>;
85
98
  /**
86
99
  * Configuration for retry behavior (optional)
87
100
  */
@@ -602,7 +615,8 @@ declare class NetworkError extends Error {
602
615
  constructor(message: string);
603
616
  }
604
617
  declare class AuthenticationError extends Error {
605
- constructor(message: string);
618
+ readonly code?: string | undefined;
619
+ constructor(message: string, code?: string | undefined);
606
620
  }
607
621
  /**
608
622
  * Schedule execution type
@@ -1413,6 +1427,79 @@ interface StreamEvent {
1413
1427
  event: string;
1414
1428
  data: Record<string, unknown>;
1415
1429
  }
1430
+ /** Origin of a durable run record. */
1431
+ type AgentRunSource = "run_api" | "legacy" | "project_task";
1432
+ /** Derived monitor kind for a persisted thread. */
1433
+ type ThreadMonitorKind = "conversation" | "room_presence" | "task_execution" | "open_api" | "web_app" | "cron" | "channel";
1434
+ /** Filters accepted by `client.monitor.threads.list`. */
1435
+ interface ThreadMonitorQuery {
1436
+ limit?: number;
1437
+ offset?: number;
1438
+ kind?: ThreadMonitorKind;
1439
+ assistantId?: string;
1440
+ createdAfter?: string;
1441
+ }
1442
+ /** Safe thread projection returned by the tenant monitor. */
1443
+ interface ThreadMonitorRecord {
1444
+ id: string;
1445
+ tenantId: string;
1446
+ assistantId: string;
1447
+ kind: ThreadMonitorKind;
1448
+ workspaceId?: string;
1449
+ projectId?: string;
1450
+ roomId?: string;
1451
+ taskId?: string;
1452
+ createdAt: string;
1453
+ updatedAt: string;
1454
+ expiresAt?: string;
1455
+ }
1456
+ /** Filters accepted by `client.monitor.runs.list`. */
1457
+ interface AgentRunMonitorQuery {
1458
+ limit?: number;
1459
+ offset?: number;
1460
+ status?: AgentRunStatus;
1461
+ source?: AgentRunSource;
1462
+ assistantId?: string;
1463
+ createdAfter?: string;
1464
+ }
1465
+ /** Safe run projection returned by the tenant monitor. */
1466
+ interface AgentRunMonitorRecord {
1467
+ runId: string;
1468
+ tenantId: string;
1469
+ assistantId: string;
1470
+ threadId: string;
1471
+ workspaceId?: string;
1472
+ projectId?: string;
1473
+ taskId?: string;
1474
+ status: AgentRunStatus;
1475
+ source: AgentRunSource;
1476
+ owner: string | null;
1477
+ attempts: number;
1478
+ error: string | null;
1479
+ cancelRequested: boolean;
1480
+ leaseExpiresAt: number | null;
1481
+ createdAt: number;
1482
+ updatedAt: number;
1483
+ startedAt: number | null;
1484
+ finishedAt: number | null;
1485
+ messageId?: string | null;
1486
+ inputPreview?: string | null;
1487
+ }
1488
+ /** Tenant monitor overview payload. */
1489
+ interface TenantMonitorOverview {
1490
+ since: string;
1491
+ counts: Record<AgentRunStatus, number>;
1492
+ oldestPendingAgeMs: number | null;
1493
+ stuckRunning: number;
1494
+ pendingThreads: number;
1495
+ }
1496
+ /** Generic server-paginated result. */
1497
+ interface MonitorPage<T> {
1498
+ records: T[];
1499
+ total: number;
1500
+ limit: number;
1501
+ offset: number;
1502
+ }
1416
1503
 
1417
1504
  /** Completion evidence accepted by the task lifecycle endpoint. */
1418
1505
  interface CompleteTaskInput {
@@ -1921,13 +2008,17 @@ declare abstract class AbstractClient {
1921
2008
  */
1922
2009
  auditLogs: (params?: {
1923
2010
  credentialId?: string;
2011
+ projectId?: string;
1924
2012
  domain?: string;
1925
- status?: "ok" | "error";
2013
+ action?: string;
2014
+ status?: "ok" | "error" | "cancelled";
1926
2015
  from?: string;
1927
2016
  to?: string;
1928
2017
  limit?: number;
1929
2018
  offset?: number;
1930
2019
  }) => Promise<OpenAuditLogRecord[]>;
2020
+ /** Read one tenant-scoped Open audit record by id. */
2021
+ auditLog: (id: string) => Promise<OpenAuditLogRecord>;
1931
2022
  };
1932
2023
  /**
1933
2024
  * MCP Apps namespace for resolving UI resources and proxying allow-listed
@@ -2452,6 +2543,20 @@ declare abstract class AbstractClient {
2452
2543
  */
2453
2544
  cancelActive: (threadId: string, assistantId?: string) => Promise<RunCancelActiveResult>;
2454
2545
  };
2546
+ /**
2547
+ * Read-only tenant monitor surface (owner/admin only on the server).
2548
+ */
2549
+ monitor: {
2550
+ overview: (options?: {
2551
+ sinceHours?: number;
2552
+ }) => Promise<TenantMonitorOverview>;
2553
+ threads: {
2554
+ list: (query?: ThreadMonitorQuery) => Promise<MonitorPage<ThreadMonitorRecord>>;
2555
+ };
2556
+ runs: {
2557
+ list: (query?: AgentRunMonitorQuery) => Promise<MonitorPage<AgentRunMonitorRecord>>;
2558
+ };
2559
+ };
2455
2560
  /**
2456
2561
  * Tenant-scoped namespaced key-value store (viewer/editor surface).
2457
2562
  */
@@ -3553,7 +3658,14 @@ declare class Client extends AbstractClient {
3553
3658
  method?: string;
3554
3659
  body?: any;
3555
3660
  headers?: Record<string, string>;
3556
- }): Promise<T>;
3661
+ }, retry?: boolean): Promise<T>;
3662
+ private refreshInFlight;
3663
+ /** Host-facing single-flight refresh (used by ThreadStream on a 401). */
3664
+ refreshSession(): Promise<{
3665
+ token: string;
3666
+ expiresAt: number;
3667
+ } | null>;
3668
+ private refreshOnce;
3557
3669
  /**
3558
3670
  * Implementation of the abstract streamRequest method for web clients
3559
3671
  */
@@ -3936,4 +4048,4 @@ declare class McpAppShareRuntimeClient implements McpAppShareRuntimeClientApi {
3936
4048
  private parse;
3937
4049
  }
3938
4050
 
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 };
4051
+ export { type A2AKeyListItem, type A2AKeysListResponse, type AbortAgentParams, AbstractClient, type AddPlatformTenantMemberInput, type AddProjectBotMembershipInput, type AddProjectMembershipInput, type AgentCron, type AgentGraphTree, type AgentRunMonitorQuery, type AgentRunMonitorRecord, type AgentRunSource, 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 MonitorPage, 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 TenantMonitorOverview, type TestConnectionResponse, type TestMcpServerResponse, type TestOidcProviderInput, type TestStoredOidcProviderOverrides, type Thread, type ThreadEvent, type ThreadEventStreamError, type ThreadEventStreamOptions, type ThreadHistoryPage, type ThreadListResponse, type ThreadMonitorKind, type ThreadMonitorQuery, type ThreadMonitorRecord, 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 };
package/dist/index.js CHANGED
@@ -1866,8 +1866,9 @@ var NetworkError = class extends Error {
1866
1866
  }
1867
1867
  };
1868
1868
  var AuthenticationError = class extends Error {
1869
- constructor(message) {
1869
+ constructor(message, code) {
1870
1870
  super(message);
1871
+ this.code = code;
1871
1872
  this.name = "AuthenticationError";
1872
1873
  }
1873
1874
  };
@@ -2286,7 +2287,9 @@ var AbstractClient = class {
2286
2287
  auditLogs: async (params) => {
2287
2288
  const searchParams = new URLSearchParams();
2288
2289
  if (params?.credentialId) searchParams.set("credentialId", params.credentialId);
2290
+ if (params?.projectId) searchParams.set("projectId", params.projectId);
2289
2291
  if (params?.domain) searchParams.set("domain", params.domain);
2292
+ if (params?.action) searchParams.set("action", params.action);
2290
2293
  if (params?.status) searchParams.set("status", params.status);
2291
2294
  if (params?.from) searchParams.set("from", params.from);
2292
2295
  if (params?.to) searchParams.set("to", params.to);
@@ -2295,6 +2298,11 @@ var AbstractClient = class {
2295
2298
  const qs = searchParams.toString();
2296
2299
  const response = await this.makeRequest(`/api/open/audit${qs ? `?${qs}` : ""}`);
2297
2300
  return response.data.records;
2301
+ },
2302
+ /** Read one tenant-scoped Open audit record by id. */
2303
+ auditLog: async (id) => {
2304
+ const response = await this.makeRequest(`/api/open/audit/${encodeURIComponent(id)}`);
2305
+ return response.data.record;
2298
2306
  }
2299
2307
  };
2300
2308
  /**
@@ -3210,6 +3218,47 @@ var AbstractClient = class {
3210
3218
  );
3211
3219
  }
3212
3220
  };
3221
+ /**
3222
+ * Read-only tenant monitor surface (owner/admin only on the server).
3223
+ */
3224
+ this.monitor = {
3225
+ overview: async (options) => {
3226
+ const params = new URLSearchParams();
3227
+ if (options?.sinceHours !== void 0) {
3228
+ params.set("sinceHours", String(options.sinceHours));
3229
+ }
3230
+ const query = params.toString();
3231
+ const response = await this.makeRequest(`/api/tenant-monitor/overview${query ? `?${query}` : ""}`);
3232
+ return response.data;
3233
+ },
3234
+ threads: {
3235
+ list: async (query = {}) => {
3236
+ const params = new URLSearchParams();
3237
+ if (query.limit !== void 0) params.set("limit", String(query.limit));
3238
+ if (query.offset !== void 0) params.set("offset", String(query.offset));
3239
+ if (query.kind) params.set("kind", query.kind);
3240
+ if (query.assistantId) params.set("assistantId", query.assistantId);
3241
+ if (query.createdAfter) params.set("createdAfter", query.createdAfter);
3242
+ const suffix = params.toString();
3243
+ const response = await this.makeRequest(`/api/tenant-monitor/threads${suffix ? `?${suffix}` : ""}`);
3244
+ return response.data;
3245
+ }
3246
+ },
3247
+ runs: {
3248
+ list: async (query = {}) => {
3249
+ const params = new URLSearchParams();
3250
+ if (query.limit !== void 0) params.set("limit", String(query.limit));
3251
+ if (query.offset !== void 0) params.set("offset", String(query.offset));
3252
+ if (query.status) params.set("status", query.status);
3253
+ if (query.source) params.set("source", query.source);
3254
+ if (query.assistantId) params.set("assistantId", query.assistantId);
3255
+ if (query.createdAfter) params.set("createdAfter", query.createdAfter);
3256
+ const suffix = params.toString();
3257
+ const response = await this.makeRequest(`/api/tenant-monitor/runs${suffix ? `?${suffix}` : ""}`);
3258
+ return response.data;
3259
+ }
3260
+ }
3261
+ };
3213
3262
  /**
3214
3263
  * Tenant-scoped namespaced key-value store (viewer/editor surface).
3215
3264
  */
@@ -5677,6 +5726,7 @@ var _Client = class _Client extends AbstractClient {
5677
5726
  super(config);
5678
5727
  /** Last SSE event id observed per thread, for automatic resume. */
5679
5728
  this.resumeEventIds = /* @__PURE__ */ new Map();
5729
+ this.refreshInFlight = null;
5680
5730
  this.headers = {
5681
5731
  "Content-Type": "application/json",
5682
5732
  Authorization: `Bearer ${this.config.apiKey}`,
@@ -5698,7 +5748,15 @@ var _Client = class _Client extends AbstractClient {
5698
5748
  async handleResponse(response) {
5699
5749
  if (!response.ok) {
5700
5750
  if (response.status === 401) {
5701
- throw new AuthenticationError("Authentication failed");
5751
+ const body = await response.json().catch(() => void 0);
5752
+ const code = typeof body?.code === "string" ? body.code : void 0;
5753
+ if (code === "SESSION_INVALID" && !this.config.refreshSession) {
5754
+ this.getUnauthorizedHandler()?.();
5755
+ }
5756
+ throw new AuthenticationError(
5757
+ body?.error ?? body?.message ?? "Authentication failed",
5758
+ code
5759
+ );
5702
5760
  } else {
5703
5761
  const errorData = await response.json().catch(() => ({}));
5704
5762
  throw new ApiError(
@@ -5839,12 +5897,10 @@ var _Client = class _Client extends AbstractClient {
5839
5897
  * @param options - Request options
5840
5898
  * @returns A promise that resolves to the response data
5841
5899
  */
5842
- async makeRequest(url, options) {
5900
+ async makeRequest(url, options, retry = true) {
5843
5901
  const method = options?.method || "GET";
5844
- const workspaceHeaders = this.getWorkspaceHeaders();
5845
5902
  const requestHeaders = {
5846
- ...this.headers,
5847
- ...workspaceHeaders,
5903
+ ...this.getAllHeaders(),
5848
5904
  ...this.bodyAffinityHeaders(options?.body),
5849
5905
  ...options?.headers || {}
5850
5906
  };
@@ -5863,7 +5919,34 @@ var _Client = class _Client extends AbstractClient {
5863
5919
  requestOptions.body = JSON.stringify(options.body);
5864
5920
  }
5865
5921
  }
5866
- return this.fetchWithTimeout(url, requestOptions);
5922
+ try {
5923
+ return await this.fetchWithTimeout(url, requestOptions);
5924
+ } catch (error) {
5925
+ if (retry && error instanceof AuthenticationError && error.code === "SESSION_INVALID" && this.config.refreshSession && !url.includes("/api/auth/")) {
5926
+ const refreshed = await this.refreshOnce();
5927
+ if (refreshed) {
5928
+ if (!this.config.getApiKey) {
5929
+ this.headers.Authorization = `Bearer ${refreshed.token}`;
5930
+ }
5931
+ return this.makeRequest(url, options, false);
5932
+ }
5933
+ this.getUnauthorizedHandler()?.();
5934
+ }
5935
+ throw error;
5936
+ }
5937
+ }
5938
+ /** Host-facing single-flight refresh (used by ThreadStream on a 401). */
5939
+ async refreshSession() {
5940
+ return this.refreshOnce();
5941
+ }
5942
+ async refreshOnce() {
5943
+ if (!this.config.refreshSession) return null;
5944
+ if (!this.refreshInFlight) {
5945
+ this.refreshInFlight = this.config.refreshSession().finally(() => {
5946
+ this.refreshInFlight = null;
5947
+ });
5948
+ }
5949
+ return this.refreshInFlight;
5867
5950
  }
5868
5951
  /**
5869
5952
  * Implementation of the abstract streamRequest method for web clients
@@ -5991,8 +6074,10 @@ var _Client = class _Client extends AbstractClient {
5991
6074
  */
5992
6075
  getAllHeaders() {
5993
6076
  const workspaceHeaders = this.getWorkspaceHeaders();
6077
+ const apiKey = this.config.getApiKey?.() ?? this.config.apiKey;
5994
6078
  return {
5995
6079
  ...this.headers,
6080
+ ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
5996
6081
  ...workspaceHeaders
5997
6082
  };
5998
6083
  }