@getsupervisor/agents-studio-sdk 1.41.0 → 1.41.2-patch.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -409,6 +409,7 @@ type components = {
409
409
  auth: 'none' | 'oauth2' | 'api_key' | 'custom';
410
410
  requiresUserAuth: boolean;
411
411
  configSchema?: components['schemas']['ToolConfigSchema'] | null;
412
+ catalogMetadata: components['schemas']['ToolCatalogMetadata'];
412
413
  };
413
414
  ToolListResponse: {
414
415
  data: components['schemas']['ToolSummary'][];
@@ -452,6 +453,7 @@ type components = {
452
453
  message?: string;
453
454
  };
454
455
  ToolConnectionRequest: {
456
+ connectionKey?: string;
455
457
  agentId: string;
456
458
  metadata?: {
457
459
  [key: string]: unknown;
@@ -459,7 +461,7 @@ type components = {
459
461
  auth?: components['schemas']['ToolConnectionAuth'];
460
462
  };
461
463
  ToolConnectionResponse: {
462
- status: 'connected' | 'pending' | 'error';
464
+ status: 'connected' | 'pending' | 'error' | 'revoked';
463
465
  toolAgentConnectionId?: string | null;
464
466
  toolId: string;
465
467
  workspaceId: string;
@@ -472,7 +474,7 @@ type components = {
472
474
  };
473
475
  };
474
476
  ToolConnectionAuth: {
475
- type: 'none' | 'oauth2' | 'api_key';
477
+ type: 'none' | 'oauth2' | 'api_key' | 'custom';
476
478
  data?: {
477
479
  [key: string]: unknown;
478
480
  };
@@ -495,6 +497,7 @@ type components = {
495
497
  toolId: string;
496
498
  toolAgentConnectionId?: string | null;
497
499
  providerRef?: string | null;
500
+ toolExecutionId: string;
498
501
  message?: string | null;
499
502
  };
500
503
  CatalogItemLinks: {
@@ -545,6 +548,8 @@ type components = {
545
548
  code: string;
546
549
  message: string;
547
550
  details?: {
551
+ subcode?: string;
552
+ workspaceId?: string;
548
553
  [key: string]: unknown;
549
554
  };
550
555
  };
@@ -692,6 +697,14 @@ type components = {
692
697
  CreateApiKeyResponse: components['schemas']['ApiKeySummary'] & {
693
698
  key: string;
694
699
  };
700
+ WorkspaceSummary: {
701
+ id: string;
702
+ name: string;
703
+ };
704
+ WorkspaceListResponse: {
705
+ data: components['schemas']['WorkspaceSummary'][];
706
+ meta: components['schemas']['PaginationMeta'];
707
+ };
695
708
  ToolConfigSchemaActionPrompts: {
696
709
  assistant?: string;
697
710
  user?: string;
@@ -715,6 +728,79 @@ type components = {
715
728
  [key: string]: components['schemas']['ToolConfigSchemaAction'];
716
729
  };
717
730
  };
731
+ ToolCatalogAuthor: {
732
+ name: string;
733
+ url?: string | null;
734
+ };
735
+ ToolCatalogMedia: {
736
+ iconUrl: string | null;
737
+ coverImageUrl: string | null;
738
+ };
739
+ ToolCatalogDescription: {
740
+ short: string | null;
741
+ markdown: string | null;
742
+ };
743
+ ToolCatalogInstallation: {
744
+ requirements: string[];
745
+ permissions: string[];
746
+ steps: string[];
747
+ notes: string[];
748
+ };
749
+ ToolCatalogAppliesTo: {
750
+ chat: boolean | null;
751
+ voice: boolean | null;
752
+ };
753
+ ToolCatalogLinks: {
754
+ docsUrl: string | null;
755
+ privacyUrl: string | null;
756
+ termsUrl: string | null;
757
+ };
758
+ ToolCatalogCard: {
759
+ author: components['schemas']['ToolCatalogAuthor'];
760
+ media: components['schemas']['ToolCatalogMedia'];
761
+ description: components['schemas']['ToolCatalogDescription'];
762
+ features: string[];
763
+ useCases: string[];
764
+ installation: components['schemas']['ToolCatalogInstallation'];
765
+ appliesTo: components['schemas']['ToolCatalogAppliesTo'];
766
+ links: components['schemas']['ToolCatalogLinks'];
767
+ };
768
+ ToolCatalogMetadata: {
769
+ version: 1;
770
+ i18n: {
771
+ [key: string]: components['schemas']['ToolCatalogCard'];
772
+ };
773
+ };
774
+ ToolConnectionListItem: {
775
+ toolAgentConnectionId: string;
776
+ toolId: string;
777
+ workspaceId: string;
778
+ agentId: string;
779
+ connectionKey: string;
780
+ status: 'connected' | 'pending' | 'error' | 'revoked';
781
+ providerRef?: string | null;
782
+ descriptionUsage?: string | null;
783
+ usageExample?: string | null;
784
+ };
785
+ ToolConnectionListResponse: {
786
+ data: components['schemas']['ToolConnectionListItem'][];
787
+ meta: components['schemas']['PaginationMeta'];
788
+ };
789
+ CreateToolConnectionRequest: {
790
+ toolId: string;
791
+ agentId: string;
792
+ connectionKey?: string;
793
+ metadata?: {
794
+ [key: string]: unknown;
795
+ };
796
+ auth?: components['schemas']['ToolConnectionAuth'];
797
+ };
798
+ ExecuteToolConnectionRequest: {
799
+ action: string;
800
+ args?: {
801
+ [key: string]: unknown;
802
+ };
803
+ };
718
804
  CatalogItemLanguageMetadata: {
719
805
  code: string;
720
806
  locale?: string | null;
@@ -770,7 +856,9 @@ type components = {
770
856
  OrParam?: components['schemas']['QueryOrGroups'];
771
857
  ScheduleId: string;
772
858
  ApiKeyId: string;
859
+ XCacheRefresh?: boolean;
773
860
  IdempotencyKey: string;
861
+ XApiKey?: string;
774
862
  };
775
863
  requestBodies: never;
776
864
  headers: never;
@@ -839,6 +927,8 @@ type WorkspacePhonesResponse = components['schemas']['WorkspacePhonesResponse'];
839
927
  type WorkspacePhoneChannel = 'voice';
840
928
  type WorkspaceEnableRequest = components['schemas']['WorkspaceEnableRequest'];
841
929
  type WorkspaceEnableResponse = components['schemas']['WorkspaceEnableResponse'];
930
+ type WorkspaceSummary = components['schemas']['WorkspaceSummary'];
931
+ type WorkspaceListResponse = components['schemas']['WorkspaceListResponse'];
842
932
  type VoiceSummary = components['schemas']['VoiceSummary'];
843
933
  type VoiceListResponse = components['schemas']['VoiceListResponse'];
844
934
  type CatalogItemLinks = components['schemas']['CatalogItemLinks'];
@@ -1023,8 +1113,12 @@ type ToolResourceUploadRequest = components['schemas']['ToolResourceUploadReques
1023
1113
  type ToolResourceUploadResponse = components['schemas']['ToolResourceUploadResponse'];
1024
1114
  type ToolResourceReloadResponse = components['schemas']['ToolResourceReloadResponse'];
1025
1115
  type ToolConnectionAuth = components['schemas']['ToolConnectionAuth'];
1116
+ type CreateToolConnectionRequest = components['schemas']['CreateToolConnectionRequest'];
1026
1117
  type ToolConnectionRequest = components['schemas']['ToolConnectionRequest'];
1027
1118
  type ToolConnectionResponse = components['schemas']['ToolConnectionResponse'];
1119
+ type ToolConnectionListItem = components['schemas']['ToolConnectionListItem'];
1120
+ type ToolConnectionListResponse = components['schemas']['ToolConnectionListResponse'];
1121
+ type ExecuteToolConnectionRequest = components['schemas']['ExecuteToolConnectionRequest'];
1028
1122
  type ErrorResponse = components['schemas']['ErrorResponse'];
1029
1123
  type CampaignStatus = components['schemas']['CampaignStatus'];
1030
1124
  type Campaign = components['schemas']['Campaign'];
@@ -1042,13 +1136,17 @@ type EventSubscriptionListResponse = components['schemas']['EventSubscriptionLis
1042
1136
  type CreateEventSubscriptionRequest = components['schemas']['CreateEventSubscriptionRequest'];
1043
1137
  type UpdateEventSubscriptionRequest = components['schemas']['UpdateEventSubscriptionRequest'];
1044
1138
 
1045
- declare class HttpError extends Error {
1139
+ declare class HttpError<TBody = unknown> extends Error {
1046
1140
  status: number;
1047
1141
  statusText: string;
1048
- body?: unknown;
1142
+ body?: TBody;
1049
1143
  url?: string;
1050
- constructor(status: number, statusText: string, body?: unknown, url?: string);
1144
+ constructor(status: number, statusText: string, body?: TBody, url?: string);
1051
1145
  }
1146
+ type ApiErrorBody = ErrorResponse;
1147
+ type ApiHttpError = HttpError<ApiErrorBody>;
1148
+ declare function isApiErrorBody(body: unknown): body is ApiErrorBody;
1149
+ declare function isApiHttpError(err: unknown): err is ApiHttpError;
1052
1150
  declare class TimeoutError extends Error {
1053
1151
  ms: number;
1054
1152
  url?: string;
@@ -1059,6 +1157,9 @@ declare class NetworkError extends Error {
1059
1157
  url?: string;
1060
1158
  constructor(cause?: unknown, url?: string);
1061
1159
  }
1160
+ declare class WorkspaceNotSelectedError extends Error {
1161
+ constructor();
1162
+ }
1062
1163
  type RetryPolicy = {
1063
1164
  maxRetries?: number;
1064
1165
  baseDelayMs?: number;
@@ -1651,19 +1752,31 @@ type ListToolsOptions = ListQueryOptions & {
1651
1752
  type ListToolResourcesOptions = Pick<ListQueryOptions, 'page' | 'limit'> & {
1652
1753
  type?: 'document' | 'media' | 'file';
1653
1754
  };
1755
+ type ListToolConnectionsOptions = ListQueryOptions;
1654
1756
  type UploadToolResourcePayload = FormData | (Omit<ToolResourceUploadRequest, 'file'> & {
1655
1757
  file: unknown;
1656
1758
  });
1657
1759
  declare function createToolsApi(cfg: ClientConfig & {
1658
1760
  retry?: RetryPolicy;
1659
1761
  }): {
1762
+ connections: {
1763
+ readonly connect: (toolId: string, payload: ToolConnectionRequest, options?: IdempotentRequestOptions) => Promise<ToolConnectionResponse>;
1764
+ readonly create: (payload: CreateToolConnectionRequest, options?: IdempotentRequestOptions) => Promise<ToolConnectionResponse>;
1765
+ readonly execute: (toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: IdempotentRequestOptions) => Promise<ExecuteToolResponse>;
1766
+ readonly list: (options?: ListToolConnectionsOptions) => Promise<PaginatedResult<ToolConnectionListResponse, ListToolConnectionsOptions>>;
1767
+ readonly createConnection: (payload: CreateToolConnectionRequest, options?: IdempotentRequestOptions) => Promise<ToolConnectionResponse>;
1768
+ readonly executeConnection: (toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: IdempotentRequestOptions) => Promise<ExecuteToolResponse>;
1769
+ };
1660
1770
  list(options?: ListToolsOptions): Promise<PaginatedResult<ToolListResponse, ListToolsOptions>>;
1661
1771
  listResources(toolId: string, options?: ListToolResourcesOptions): Promise<PaginatedResult<ToolResourceListResponse, ListToolResourcesOptions>>;
1772
+ listConnections(options?: ListToolConnectionsOptions): Promise<PaginatedResult<ToolConnectionListResponse, ListToolConnectionsOptions>>;
1662
1773
  uploadResource(toolId: string, payload: UploadToolResourcePayload): Promise<ToolResourceUploadResponse>;
1663
1774
  deleteResource(toolId: string, resourceId: string): Promise<void>;
1664
1775
  reloadResource(toolId: string, resourceId: string): Promise<ToolResourceReloadResponse>;
1665
1776
  execute(toolId: string, payload: ExecuteToolRequest, options?: IdempotentRequestOptions): Promise<ExecuteToolResponse>;
1666
1777
  connect(toolId: string, payload: ToolConnectionRequest, options?: IdempotentRequestOptions): Promise<ToolConnectionResponse>;
1778
+ createConnection(payload: CreateToolConnectionRequest, options?: IdempotentRequestOptions): Promise<ToolConnectionResponse>;
1779
+ executeConnection(toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: IdempotentRequestOptions): Promise<ExecuteToolResponse>;
1667
1780
  };
1668
1781
 
1669
1782
  type ListVoicesOptions = ListQueryOptions & {
@@ -1699,9 +1812,13 @@ declare function createWebhooksApi(cfg: ClientConfig & {
1699
1812
  type ListWorkspacePhonesOptions = ListQueryOptions & {
1700
1813
  channel?: WorkspacePhoneChannel;
1701
1814
  };
1815
+ type ListWorkspacesOptions = ListQueryOptions & {
1816
+ refreshCache?: boolean;
1817
+ };
1702
1818
  declare function createWorkspacesApi(cfg: ClientConfig & {
1703
1819
  retry?: RetryPolicy;
1704
1820
  }): {
1821
+ list(options?: ListWorkspacesOptions): Promise<PaginatedResult<WorkspaceListResponse, ListWorkspacesOptions>>;
1705
1822
  listPhones(workspaceId: string, opts?: ListWorkspacePhonesOptions): Promise<PaginatedResult<WorkspacePhonesResponse, ListWorkspacePhonesOptions>>;
1706
1823
  enable(workspaceId: string, payload: WorkspaceEnableRequest): Promise<WorkspaceEnableResponse>;
1707
1824
  };
@@ -1796,12 +1913,32 @@ declare function createClient(initialCfg: ClientConfig & {
1796
1913
  update(agentId: string, payload: UpdateAgentRequest): Promise<AgentEntity>;
1797
1914
  };
1798
1915
  workspaces: {
1916
+ list(options?: ListWorkspacesOptions): Promise<PaginatedResult<WorkspaceListResponse, ListWorkspacesOptions>>;
1799
1917
  listPhones(workspaceId: string, opts?: ListWorkspacePhonesOptions): Promise<PaginatedResult<WorkspacePhonesResponse, ListWorkspacePhonesOptions>>;
1800
1918
  enable(workspaceId: string, payload: WorkspaceEnableRequest): Promise<WorkspaceEnableResponse>;
1801
1919
  };
1802
1920
  tools: {
1921
+ connections: {
1922
+ readonly connect: (toolId: string, payload: ToolConnectionRequest, options?: {
1923
+ idempotencyKey?: string;
1924
+ }) => Promise<ToolConnectionResponse>;
1925
+ readonly create: (payload: CreateToolConnectionRequest, options?: {
1926
+ idempotencyKey?: string;
1927
+ }) => Promise<ToolConnectionResponse>;
1928
+ readonly execute: (toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: {
1929
+ idempotencyKey?: string;
1930
+ }) => Promise<ExecuteToolResponse>;
1931
+ readonly list: (options?: ListToolConnectionsOptions) => Promise<PaginatedResult<ToolConnectionListResponse, ListToolConnectionsOptions>>;
1932
+ readonly createConnection: (payload: CreateToolConnectionRequest, options?: {
1933
+ idempotencyKey?: string;
1934
+ }) => Promise<ToolConnectionResponse>;
1935
+ readonly executeConnection: (toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: {
1936
+ idempotencyKey?: string;
1937
+ }) => Promise<ExecuteToolResponse>;
1938
+ };
1803
1939
  list(options?: ListToolsOptions): Promise<PaginatedResult<ToolListResponse, ListToolsOptions>>;
1804
1940
  listResources(toolId: string, options?: ListToolResourcesOptions): Promise<PaginatedResult<ToolResourceListResponse, ListToolResourcesOptions>>;
1941
+ listConnections(options?: ListToolConnectionsOptions): Promise<PaginatedResult<ToolConnectionListResponse, ListToolConnectionsOptions>>;
1805
1942
  uploadResource(toolId: string, payload: FormData | (Omit<{
1806
1943
  file: string;
1807
1944
  type?: "document" | "media" | "file";
@@ -1820,6 +1957,12 @@ declare function createClient(initialCfg: ClientConfig & {
1820
1957
  connect(toolId: string, payload: ToolConnectionRequest, options?: {
1821
1958
  idempotencyKey?: string;
1822
1959
  }): Promise<ToolConnectionResponse>;
1960
+ createConnection(payload: CreateToolConnectionRequest, options?: {
1961
+ idempotencyKey?: string;
1962
+ }): Promise<ToolConnectionResponse>;
1963
+ executeConnection(toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: {
1964
+ idempotencyKey?: string;
1965
+ }): Promise<ExecuteToolResponse>;
1823
1966
  };
1824
1967
  catalogs: {
1825
1968
  templates: {
@@ -1909,12 +2052,32 @@ declare function createClient(initialCfg: ClientConfig & {
1909
2052
  update(agentId: string, payload: UpdateAgentRequest): Promise<AgentEntity>;
1910
2053
  };
1911
2054
  workspaces: {
2055
+ list(options?: ListWorkspacesOptions): Promise<PaginatedResult<WorkspaceListResponse, ListWorkspacesOptions>>;
1912
2056
  listPhones(workspaceId: string, opts?: ListWorkspacePhonesOptions): Promise<PaginatedResult<WorkspacePhonesResponse, ListWorkspacePhonesOptions>>;
1913
2057
  enable(workspaceId: string, payload: WorkspaceEnableRequest): Promise<WorkspaceEnableResponse>;
1914
2058
  };
1915
2059
  tools: {
2060
+ connections: {
2061
+ readonly connect: (toolId: string, payload: ToolConnectionRequest, options?: {
2062
+ idempotencyKey?: string;
2063
+ }) => Promise<ToolConnectionResponse>;
2064
+ readonly create: (payload: CreateToolConnectionRequest, options?: {
2065
+ idempotencyKey?: string;
2066
+ }) => Promise<ToolConnectionResponse>;
2067
+ readonly execute: (toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: {
2068
+ idempotencyKey?: string;
2069
+ }) => Promise<ExecuteToolResponse>;
2070
+ readonly list: (options?: ListToolConnectionsOptions) => Promise<PaginatedResult<ToolConnectionListResponse, ListToolConnectionsOptions>>;
2071
+ readonly createConnection: (payload: CreateToolConnectionRequest, options?: {
2072
+ idempotencyKey?: string;
2073
+ }) => Promise<ToolConnectionResponse>;
2074
+ readonly executeConnection: (toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: {
2075
+ idempotencyKey?: string;
2076
+ }) => Promise<ExecuteToolResponse>;
2077
+ };
1916
2078
  list(options?: ListToolsOptions): Promise<PaginatedResult<ToolListResponse, ListToolsOptions>>;
1917
2079
  listResources(toolId: string, options?: ListToolResourcesOptions): Promise<PaginatedResult<ToolResourceListResponse, ListToolResourcesOptions>>;
2080
+ listConnections(options?: ListToolConnectionsOptions): Promise<PaginatedResult<ToolConnectionListResponse, ListToolConnectionsOptions>>;
1918
2081
  uploadResource(toolId: string, payload: FormData | (Omit<{
1919
2082
  file: string;
1920
2083
  type?: "document" | "media" | "file";
@@ -1933,6 +2096,12 @@ declare function createClient(initialCfg: ClientConfig & {
1933
2096
  connect(toolId: string, payload: ToolConnectionRequest, options?: {
1934
2097
  idempotencyKey?: string;
1935
2098
  }): Promise<ToolConnectionResponse>;
2099
+ createConnection(payload: CreateToolConnectionRequest, options?: {
2100
+ idempotencyKey?: string;
2101
+ }): Promise<ToolConnectionResponse>;
2102
+ executeConnection(toolAgentConnectionId: string, payload: ExecuteToolConnectionRequest, options?: {
2103
+ idempotencyKey?: string;
2104
+ }): Promise<ExecuteToolResponse>;
1936
2105
  };
1937
2106
  catalogs: {
1938
2107
  templates: {
@@ -1991,4 +2160,4 @@ declare function createHttp(cfg: ClientConfig & {
1991
2160
  resolveAccessToken: () => string;
1992
2161
  };
1993
2162
 
1994
- export { type AgentBlueprint, type AgentBlueprintListItem, type AgentBlueprintListResponse, type AgentBlueprintsApi$1 as AgentBlueprintsApi, type AgentDetail, type AgentEntity, type AgentEntityFactoryOptions, type AgentListResponse, type AgentSchedule, type AgentScheduleApi, type AgentScheduleException, type AgentScheduleExceptionListResponse, type AgentScheduleListResponse, type AgentStageTriggersApi$1 as AgentStageTriggersApi, type AgentStagesApi$1 as AgentStagesApi, type AgentSummary, type AgentTagRequest, type AgentTagsResponse, type AgentVersionDetail, type AgentVersionListResponse, type AgentVersionSummary, type AgentsApi, type AgentsApiWithEntities, type ApiKeyListResponse, type ApiKeySummary, type ApiKeysApi, type BlueprintStage, type BlueprintStageListResponse, type BlueprintStageReorderRequest, type BlueprintStageTrigger, type BlueprintStageTriggerListResponse, type Campaign, type CampaignExecution, type CampaignExecutionListResponse, type CampaignListResponse, type CampaignStatus, type CatalogItemCreateRequest, type CatalogItemDetail, type CatalogItemLinks, type CatalogItemListResponse, type CatalogItemSummary, type CatalogTemplateDetail, type CatalogTemplateListResponse, type CatalogTemplateSummary, type CatalogTemplateVisibility, type ClientConfig, type ConnectPhoneRequest, type CreateAgentBlueprintRequest, type CreateAgentRequest, type CreateAgentScheduleExceptionRequest, type CreateAgentVersionRequest, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateBlueprintStageRequest, type CreateBlueprintStageTriggerRequest, type CreateCampaignPayload, type CreateEventSubscriptionRequest, type CreateInstructionRequest, type CreateWebhookRequest, type ErrorResponse, type EventSubscriptionDetail, type EventSubscriptionListResponse, type EventSubscriptionSummary, type ExecuteToolRequest, type ExecuteToolResponse, type ForkAgentFromTemplateRequest, HttpError, type Instruction, type InstructionCreatedResponse, type InstructionListResponse, type ListAgentBlueprintsOptions, type ListAgentScheduleExceptionsOptions, type ListAgentSchedulesOptions, type ListAgentStageTriggersOptions, type ListAgentStagesOptions, type ListAgentVersionInstructionsOptions, type ListAgentVersionsOptions, type ListAgentsOptions, type ListCampaignExecutionsOptions, type ListCampaignsOptions, type ListCatalogItemsOptions, type ListCatalogTemplatesOptions, type ListQueryOptions, type ListToolResourcesOptions, type ListToolsOptions, type ListVoicesOptions, type ListWebhooksOptions, type ListWorkspacePhonesOptions, NetworkError, type PaginatedResult, type PaginationMeta, type PhoneAssignmentResponse, type PublishAgentVersionRequest, type QueryBuilderInput, type QueryBuilderSerializable, type QueryFilterOperators, type QueryFilters, type QueryOrGroups, type QueryValue, type RetryPolicy, TimeoutError, type ToolConnectionAuth, type ToolConnectionRequest, type ToolConnectionResponse, type ToolListResponse, type ToolResourceListResponse, type ToolResourceReloadResponse, type ToolResourceSummary, type ToolResourceUploadRequest, type ToolResourceUploadResponse, type ToolSummary, type UpdateAgentBlueprintRequest, type UpdateAgentRequest, type UpdateAgentScheduleExceptionRequest, type UpdateAgentScheduleRequest, type UpdateAgentVersionNotesRequest, type UpdateBlueprintStageRequest, type UpdateBlueprintStageTriggerRequest, type UpdateEventSubscriptionRequest, type UpdateInstructionRequest, type UpdateWebhookRequest, type VoiceListResponse, type VoiceSummary, type WebhookDetail, type WebhookListResponse, type WebhookSummary, type WorkspaceEnableRequest, type WorkspaceEnableResponse, type WorkspacePhone, type WorkspacePhoneChannel, type WorkspacePhonesResponse, bindAgentBlueprints, bindAgentPhones, bindAgentSchedule, bindAgentScheduleExceptions, bindAgentSchedules, bindAgentStageTriggers, bindAgentStages, bindAgentTags, bindAgentVersions, createAgentBlueprintsApi, createAgentEntity, createAgentPhonesApi, createAgentScheduleApi, createAgentScheduleExceptionsApi, createAgentStageTriggersApi, createAgentStagesApi, createAgentTagsApi, createAgentVersionsApi, createAgentsApi, createApiKeysApi, createCampaignsApi, createCatalogTemplatesApi, createCatalogsApi, createClient, createHttp, createToolsApi, createVoicesApi, createWebhooksApi, createWorkspacesApi };
2163
+ export { type AgentBlueprint, type AgentBlueprintListItem, type AgentBlueprintListResponse, type AgentBlueprintsApi$1 as AgentBlueprintsApi, type AgentDetail, type AgentEntity, type AgentEntityFactoryOptions, type AgentListResponse, type AgentSchedule, type AgentScheduleApi, type AgentScheduleException, type AgentScheduleExceptionListResponse, type AgentScheduleListResponse, type AgentStageTriggersApi$1 as AgentStageTriggersApi, type AgentStagesApi$1 as AgentStagesApi, type AgentSummary, type AgentTagRequest, type AgentTagsResponse, type AgentVersionDetail, type AgentVersionListResponse, type AgentVersionSummary, type AgentsApi, type AgentsApiWithEntities, type ApiErrorBody, type ApiHttpError, type ApiKeyListResponse, type ApiKeySummary, type ApiKeysApi, type BlueprintStage, type BlueprintStageListResponse, type BlueprintStageReorderRequest, type BlueprintStageTrigger, type BlueprintStageTriggerListResponse, type Campaign, type CampaignExecution, type CampaignExecutionListResponse, type CampaignListResponse, type CampaignStatus, type CatalogItemCreateRequest, type CatalogItemDetail, type CatalogItemLinks, type CatalogItemListResponse, type CatalogItemSummary, type CatalogTemplateDetail, type CatalogTemplateListResponse, type CatalogTemplateSummary, type CatalogTemplateVisibility, type ClientConfig, type ConnectPhoneRequest, type CreateAgentBlueprintRequest, type CreateAgentRequest, type CreateAgentScheduleExceptionRequest, type CreateAgentVersionRequest, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateBlueprintStageRequest, type CreateBlueprintStageTriggerRequest, type CreateCampaignPayload, type CreateEventSubscriptionRequest, type CreateInstructionRequest, type CreateToolConnectionRequest, type CreateWebhookRequest, type ErrorResponse, type EventSubscriptionDetail, type EventSubscriptionListResponse, type EventSubscriptionSummary, type ExecuteToolConnectionRequest, type ExecuteToolRequest, type ExecuteToolResponse, type ForkAgentFromTemplateRequest, HttpError, type Instruction, type InstructionCreatedResponse, type InstructionListResponse, type ListAgentBlueprintsOptions, type ListAgentScheduleExceptionsOptions, type ListAgentSchedulesOptions, type ListAgentStageTriggersOptions, type ListAgentStagesOptions, type ListAgentVersionInstructionsOptions, type ListAgentVersionsOptions, type ListAgentsOptions, type ListCampaignExecutionsOptions, type ListCampaignsOptions, type ListCatalogItemsOptions, type ListCatalogTemplatesOptions, type ListQueryOptions, type ListToolConnectionsOptions, type ListToolResourcesOptions, type ListToolsOptions, type ListVoicesOptions, type ListWebhooksOptions, type ListWorkspacePhonesOptions, type ListWorkspacesOptions, NetworkError, type PaginatedResult, type PaginationMeta, type PhoneAssignmentResponse, type PublishAgentVersionRequest, type QueryBuilderInput, type QueryBuilderSerializable, type QueryFilterOperators, type QueryFilters, type QueryOrGroups, type QueryValue, type RetryPolicy, TimeoutError, type ToolConnectionAuth, type ToolConnectionListItem, type ToolConnectionListResponse, type ToolConnectionRequest, type ToolConnectionResponse, type ToolListResponse, type ToolResourceListResponse, type ToolResourceReloadResponse, type ToolResourceSummary, type ToolResourceUploadRequest, type ToolResourceUploadResponse, type ToolSummary, type UpdateAgentBlueprintRequest, type UpdateAgentRequest, type UpdateAgentScheduleExceptionRequest, type UpdateAgentScheduleRequest, type UpdateAgentVersionNotesRequest, type UpdateBlueprintStageRequest, type UpdateBlueprintStageTriggerRequest, type UpdateEventSubscriptionRequest, type UpdateInstructionRequest, type UpdateWebhookRequest, type VoiceListResponse, type VoiceSummary, type WebhookDetail, type WebhookListResponse, type WebhookSummary, type WorkspaceEnableRequest, type WorkspaceEnableResponse, type WorkspaceListResponse, WorkspaceNotSelectedError, type WorkspacePhone, type WorkspacePhoneChannel, type WorkspacePhonesResponse, type WorkspaceSummary, bindAgentBlueprints, bindAgentPhones, bindAgentSchedule, bindAgentScheduleExceptions, bindAgentSchedules, bindAgentStageTriggers, bindAgentStages, bindAgentTags, bindAgentVersions, createAgentBlueprintsApi, createAgentEntity, createAgentPhonesApi, createAgentScheduleApi, createAgentScheduleExceptionsApi, createAgentStageTriggersApi, createAgentStagesApi, createAgentTagsApi, createAgentVersionsApi, createAgentsApi, createApiKeysApi, createCampaignsApi, createCatalogTemplatesApi, createCatalogsApi, createClient, createHttp, createToolsApi, createVoicesApi, createWebhooksApi, createWorkspacesApi, isApiErrorBody, isApiHttpError };
package/dist/index.js CHANGED
@@ -9,6 +9,14 @@ var HttpError = class extends Error {
9
9
  this.name = "HttpError";
10
10
  }
11
11
  };
12
+ function isApiErrorBody(body) {
13
+ if (!body || typeof body !== "object") return false;
14
+ const candidate = body;
15
+ return typeof candidate.code === "string" && typeof candidate.message === "string";
16
+ }
17
+ function isApiHttpError(err) {
18
+ return err instanceof HttpError && isApiErrorBody(err.body);
19
+ }
12
20
  var TimeoutError = class extends Error {
13
21
  constructor(ms, url) {
14
22
  super(`Timeout after ${ms}ms`);
@@ -25,6 +33,12 @@ var NetworkError = class extends Error {
25
33
  this.name = "NetworkError";
26
34
  }
27
35
  };
36
+ var WorkspaceNotSelectedError = class extends Error {
37
+ constructor() {
38
+ super("Workspace is not selected");
39
+ this.name = "WorkspaceNotSelectedError";
40
+ }
41
+ };
28
42
 
29
43
  // src/http.ts
30
44
  function toQueryString(query) {
@@ -1088,9 +1102,21 @@ var createAgentEntity = (dto, options) => {
1088
1102
 
1089
1103
  // src/api/agents.ts
1090
1104
  function createAgentsApi(cfg, relatedApis) {
1091
- const { base, doFetch } = createHttp(cfg);
1105
+ const { base, doFetch, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
1106
+ const requireWorkspace = () => {
1107
+ const workspaceId = resolveWorkspaceId();
1108
+ if (typeof workspaceId === "string" && workspaceId.trim().length > 0) {
1109
+ return;
1110
+ }
1111
+ const apiKey = resolveApiKey();
1112
+ if (typeof apiKey === "string" && apiKey.trim().length > 0) {
1113
+ return;
1114
+ }
1115
+ throw new WorkspaceNotSelectedError();
1116
+ };
1092
1117
  const jsonHeaders = { "content-type": "application/json" };
1093
1118
  const fetchAgentsPage = async (options = {}) => {
1119
+ requireWorkspace();
1094
1120
  const sanitizedOptions = {
1095
1121
  page: options.page,
1096
1122
  limit: options.limit,
@@ -1109,12 +1135,14 @@ function createAgentsApi(cfg, relatedApis) {
1109
1135
  return attachPaginator(response, fetchAgentsPage, normalizedOptions);
1110
1136
  };
1111
1137
  const getAgentDetail = async (agentId) => {
1138
+ requireWorkspace();
1112
1139
  const res = await doFetch(`${base}/agents/${agentId}`, {
1113
1140
  method: "GET"
1114
1141
  });
1115
1142
  return res.json();
1116
1143
  };
1117
1144
  const createAgent = async (payload) => {
1145
+ requireWorkspace();
1118
1146
  const res = await doFetch(`${base}/agents`, {
1119
1147
  method: "POST",
1120
1148
  body: JSON.stringify(payload),
@@ -1123,6 +1151,7 @@ function createAgentsApi(cfg, relatedApis) {
1123
1151
  return res.json();
1124
1152
  };
1125
1153
  const forkAgentFromTemplate = async (payload) => {
1154
+ requireWorkspace();
1126
1155
  const res = await doFetch(`${base}/agents/from-template`, {
1127
1156
  method: "POST",
1128
1157
  body: JSON.stringify(payload),
@@ -1131,6 +1160,7 @@ function createAgentsApi(cfg, relatedApis) {
1131
1160
  return res.json();
1132
1161
  };
1133
1162
  const updateAgent = async (agentId, payload) => {
1163
+ requireWorkspace();
1134
1164
  const res = await doFetch(`${base}/agents/${agentId}`, {
1135
1165
  method: "PATCH",
1136
1166
  body: JSON.stringify(payload),
@@ -1142,6 +1172,7 @@ function createAgentsApi(cfg, relatedApis) {
1142
1172
  return typeof agent === "string" ? agent : agent.agentId;
1143
1173
  };
1144
1174
  const deleteAgent = async (agent) => {
1175
+ requireWorkspace();
1145
1176
  const agentId = resolveAgentId(agent);
1146
1177
  await doFetch(`${base}/agents/${agentId}`, {
1147
1178
  method: "DELETE"
@@ -1464,7 +1495,15 @@ function createToolsApi(cfg) {
1464
1495
  });
1465
1496
  return res.json();
1466
1497
  };
1467
- return {
1498
+ const fetchToolConnectionsPage = async (options = {}) => {
1499
+ const query = serializeListOptions(options ?? {});
1500
+ const res = await doFetch(`${base}/tools/connections`, {
1501
+ method: "GET",
1502
+ query
1503
+ });
1504
+ return res.json();
1505
+ };
1506
+ const api = {
1468
1507
  async list(options = {}) {
1469
1508
  const normalizedOptions = { ...options ?? {} };
1470
1509
  const response = await fetchToolsPage(normalizedOptions);
@@ -1478,6 +1517,17 @@ function createToolsApi(cfg) {
1478
1517
  const response = await fetchPage(normalizedOptions);
1479
1518
  return attachPaginator(response, fetchPage, normalizedOptions);
1480
1519
  },
1520
+ async listConnections(options = {}) {
1521
+ const normalizedOptions = {
1522
+ ...options ?? {}
1523
+ };
1524
+ const response = await fetchToolConnectionsPage(normalizedOptions);
1525
+ return attachPaginator(
1526
+ response,
1527
+ fetchToolConnectionsPage,
1528
+ normalizedOptions
1529
+ );
1530
+ },
1481
1531
  async uploadResource(toolId, payload) {
1482
1532
  const formData = toFormData(payload);
1483
1533
  const res = await doFetch(`${base}/tools/${toolId}/resources`, {
@@ -1523,8 +1573,47 @@ function createToolsApi(cfg) {
1523
1573
  body: JSON.stringify(payload)
1524
1574
  });
1525
1575
  return res.json();
1576
+ },
1577
+ async createConnection(payload, options = {}) {
1578
+ const idempotencyKey = generateIdempotencyKey(options.idempotencyKey);
1579
+ const res = await doFetch(`${base}/tools/connections`, {
1580
+ method: "POST",
1581
+ headers: {
1582
+ ...jsonHeaders,
1583
+ [IDEMPOTENCY_HEADER]: idempotencyKey
1584
+ },
1585
+ body: JSON.stringify(payload)
1586
+ });
1587
+ return res.json();
1588
+ },
1589
+ async executeConnection(toolAgentConnectionId, payload, options = {}) {
1590
+ const idempotencyKey = generateIdempotencyKey(options.idempotencyKey);
1591
+ const res = await doFetch(
1592
+ `${base}/tools/connections/${toolAgentConnectionId}/execute`,
1593
+ {
1594
+ method: "POST",
1595
+ headers: {
1596
+ ...jsonHeaders,
1597
+ [IDEMPOTENCY_HEADER]: idempotencyKey
1598
+ },
1599
+ body: JSON.stringify(payload)
1600
+ }
1601
+ );
1602
+ return res.json();
1526
1603
  }
1527
1604
  };
1605
+ const connections = {
1606
+ connect: api.connect,
1607
+ create: api.createConnection,
1608
+ execute: api.executeConnection,
1609
+ list: api.listConnections,
1610
+ createConnection: api.createConnection,
1611
+ executeConnection: api.executeConnection
1612
+ };
1613
+ return {
1614
+ ...api,
1615
+ connections
1616
+ };
1528
1617
  }
1529
1618
 
1530
1619
  // src/utils/catalog-voices.ts
@@ -1831,6 +1920,26 @@ function createWebhooksApi(cfg) {
1831
1920
  function createWorkspacesApi(cfg) {
1832
1921
  const { base, doFetch } = createHttp(cfg);
1833
1922
  const jsonHeaders = { "content-type": "application/json" };
1923
+ const fetchWorkspacesPage = async (options = {}) => {
1924
+ const normalized = { ...options ?? {} };
1925
+ const query = serializeListOptions({
1926
+ page: normalized.page,
1927
+ limit: normalized.limit,
1928
+ sort: normalized.sort,
1929
+ fields: normalized.fields,
1930
+ include: normalized.include,
1931
+ search: normalized.search,
1932
+ filter: normalized.filter,
1933
+ or: normalized.or
1934
+ });
1935
+ const headers = normalized.refreshCache ? { "X-Cache-Refresh": "true" } : void 0;
1936
+ const res = await doFetch(`${base}/workspaces`, {
1937
+ method: "GET",
1938
+ query,
1939
+ headers
1940
+ });
1941
+ return res.json();
1942
+ };
1834
1943
  const fetchPhonesPage = async (workspaceId, opts = {}) => {
1835
1944
  const { channel } = opts ?? {};
1836
1945
  const query = serializeListOptions(
@@ -1853,6 +1962,11 @@ function createWorkspacesApi(cfg) {
1853
1962
  return res.json();
1854
1963
  };
1855
1964
  return {
1965
+ async list(options = {}) {
1966
+ const normalizedOptions = { ...options ?? {} };
1967
+ const response = await fetchWorkspacesPage(normalizedOptions);
1968
+ return attachPaginator(response, fetchWorkspacesPage, normalizedOptions);
1969
+ },
1856
1970
  async listPhones(workspaceId, opts = {}) {
1857
1971
  const normalizedOptions = {
1858
1972
  ...opts ?? {}
@@ -2040,6 +2154,7 @@ export {
2040
2154
  HttpError,
2041
2155
  NetworkError,
2042
2156
  TimeoutError,
2157
+ WorkspaceNotSelectedError,
2043
2158
  bindAgentBlueprints,
2044
2159
  bindAgentPhones,
2045
2160
  bindAgentSchedule,
@@ -2068,6 +2183,8 @@ export {
2068
2183
  createToolsApi,
2069
2184
  createVoicesApi,
2070
2185
  createWebhooksApi,
2071
- createWorkspacesApi
2186
+ createWorkspacesApi,
2187
+ isApiErrorBody,
2188
+ isApiHttpError
2072
2189
  };
2073
2190
  //# sourceMappingURL=index.js.map