@getsupervisor/agents-studio-sdk 1.7.0 → 1.9.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.ts CHANGED
@@ -1,41 +1,17 @@
1
1
  type components = {
2
2
  schemas: {
3
- AgentDetail: {
4
- agentId: string;
5
- name: string;
6
- agentType: 'chat' | 'voice';
7
- workspaceId: string;
8
- versionId?: string;
9
- status: 'inactive' | 'training' | 'active' | 'archived';
10
- languageCode?: string;
11
- description?: string | null;
12
- toneId?: string | null;
13
- messageStyleId?: string | null;
14
- ownerUserId?: string | null;
15
- knowledgeBaseIds?: string[];
16
- tags?: string[];
17
- tools?: {
18
- identifier: string;
19
- displayName: string;
20
- enabled: boolean;
21
- }[];
22
- voiceConfig?: {
23
- voiceId?: string;
24
- webhookUrl?: string;
25
- llmId?: string | null;
26
- } | null;
27
- createdAt: string;
28
- updatedAt: string;
29
- metadata?: {
30
- [key: string]: unknown;
31
- };
3
+ AgentDetail: components['schemas']['AgentSummary'] & {
4
+ description?: string;
5
+ avatarUrl?: string;
6
+ ownerUserId: string;
7
+ debounceDelayMs: number;
32
8
  };
33
9
  PaginationMeta: {
34
10
  total: number;
35
11
  page: number;
36
12
  limit: number;
37
13
  hasNext: boolean;
38
- hasPrevious?: boolean;
14
+ hasPrevious: boolean;
39
15
  };
40
16
  QueryFilters: string;
41
17
  QueryOrGroups: string;
@@ -54,15 +30,11 @@ type components = {
54
30
  };
55
31
  CreateAgentRequest: {
56
32
  name: string;
57
- description?: string | null;
58
33
  agentType: 'chat' | 'voice';
59
- languageCode: string;
60
- status?: 'inactive' | 'training' | 'active';
61
- avatarUrl?: string | null;
62
- debounceDelayMs?: number | null;
63
- metadata?: {
64
- [key: string]: unknown;
65
- };
34
+ description?: string;
35
+ status: 'inactive' | 'training' | 'active';
36
+ avatarUrl?: string;
37
+ debounceDelayMs: number;
66
38
  };
67
39
  AgentTagRequest: {
68
40
  tagId: string;
@@ -74,15 +46,9 @@ type components = {
74
46
  UpdateAgentRequest: {
75
47
  name?: string;
76
48
  status?: 'inactive' | 'training' | 'active' | 'archived';
77
- description?: string | null;
78
- toneId?: string | null;
79
- messageStyleId?: string | null;
80
- tags?: string[];
81
- debounceDelayMs?: number | null;
82
- ownerUserId?: string | null;
83
- metadata?: {
84
- [key: string]: unknown;
85
- };
49
+ description?: string;
50
+ avatarUrl?: string;
51
+ debounceDelayMs?: number;
86
52
  };
87
53
  Instruction: {
88
54
  id: string;
@@ -389,6 +355,8 @@ type ClientConfig = {
389
355
  };
390
356
  workspaceId?: string;
391
357
  getWorkspaceId?: () => string | undefined;
358
+ apiKey?: string;
359
+ getApiKey?: () => string | undefined;
392
360
  };
393
361
  type AgentDetail = components['schemas']['AgentDetail'];
394
362
  type AgentSummary = components['schemas']['AgentSummary'];
@@ -679,7 +647,7 @@ type AgentEntityDependencies = {
679
647
  scheduleApi: ReturnType<typeof createAgentScheduleApi>;
680
648
  versionsApi: ReturnType<typeof createAgentVersionsApi>;
681
649
  };
682
- type ListAgentsOptions = ListQueryOptions;
650
+ type ListAgentsOptions = Pick<ListQueryOptions, 'page' | 'limit' | 'filter'>;
683
651
  type AgentsApi = {
684
652
  list(options?: ListAgentsOptions): Promise<PaginatedResult<AgentListResponse, ListAgentsOptions>>;
685
653
  get(agentId: string): Promise<AgentDetail>;
@@ -748,12 +716,24 @@ declare function createWorkspacesApi(cfg: ClientConfig & {
748
716
  declare function createClient(initialCfg: ClientConfig & {
749
717
  retry?: RetryPolicy;
750
718
  }): {
719
+ auth: {
720
+ getApiKey: () => string;
721
+ setApiKey(key?: string): void;
722
+ useApiKey(getter?: () => string | undefined): void;
723
+ clearApiKey(): void;
724
+ };
751
725
  workspace: {
752
726
  get: () => string;
753
727
  set(id?: string): void;
754
728
  useGetter(getter?: () => string | undefined): void;
755
729
  clear(): void;
756
730
  scoped(id: string): {
731
+ auth: {
732
+ getApiKey: () => string;
733
+ setApiKey(key?: string): void;
734
+ useApiKey(getter?: () => string | undefined): void;
735
+ clearApiKey(): void;
736
+ };
757
737
  workspace: {
758
738
  get: () => string;
759
739
  set(id?: string): void;
@@ -767,19 +747,19 @@ declare function createClient(initialCfg: ClientConfig & {
767
747
  create(agentId: string, payload: CreateInstructionRequest): Promise<InstructionCreatedResponse>;
768
748
  update(agentId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
769
749
  delete(agentId: string, instructionId: string): Promise<void>;
770
- };
750
+ } & ((agentId: string) => ReturnType<typeof bindAgentInstructions>);
771
751
  tags: {
772
752
  readonly add: (agentId: string, payload: AgentTagRequest) => Promise<AgentTagsResponse>;
773
753
  readonly remove: (agentId: string, tagId: string) => Promise<void>;
774
- };
754
+ } & ((agentId: string) => ReturnType<typeof bindAgentTags>);
775
755
  phones: {
776
756
  connect(agentId: string, payload: ConnectPhoneRequest): Promise<PhoneAssignmentResponse>;
777
757
  disconnect(agentId: string, phoneId: string): Promise<void>;
778
- };
758
+ } & ((agentId: string) => ReturnType<typeof bindAgentPhones>);
779
759
  schedule: {
780
760
  get(agentId: string): Promise<AgentSchedule>;
781
761
  update(agentId: string, payload: UpdateAgentScheduleRequest): Promise<AgentSchedule>;
782
- };
762
+ } & ((agentId: string) => ReturnType<typeof bindAgentSchedule>);
783
763
  versions: {
784
764
  list(agentId: string, opts?: ListAgentVersionsOptions): Promise<PaginatedResult<AgentVersionListResponse, ListAgentVersionsOptions>>;
785
765
  get(agentId: string, versionId: string): Promise<AgentVersionDetail>;
@@ -790,7 +770,7 @@ declare function createClient(initialCfg: ClientConfig & {
790
770
  createInstruction(agentId: string, versionId: string, payload: CreateInstructionRequest): Promise<InstructionCreatedResponse>;
791
771
  updateInstruction(agentId: string, versionId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
792
772
  deleteInstruction(agentId: string, versionId: string, instructionId: string): Promise<void>;
793
- };
773
+ } & ((agentId: string) => ReturnType<typeof bindAgentVersions>);
794
774
  delete: (agent: string | AgentEntity) => Promise<void>;
795
775
  list(options?: ListAgentsOptions): Promise<PaginatedResult<Omit<{
796
776
  data: components["schemas"]["AgentSummary"][];
@@ -835,19 +815,19 @@ declare function createClient(initialCfg: ClientConfig & {
835
815
  create(agentId: string, payload: CreateInstructionRequest): Promise<InstructionCreatedResponse>;
836
816
  update(agentId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
837
817
  delete(agentId: string, instructionId: string): Promise<void>;
838
- };
818
+ } & ((agentId: string) => ReturnType<typeof bindAgentInstructions>);
839
819
  tags: {
840
820
  readonly add: (agentId: string, payload: AgentTagRequest) => Promise<AgentTagsResponse>;
841
821
  readonly remove: (agentId: string, tagId: string) => Promise<void>;
842
- };
822
+ } & ((agentId: string) => ReturnType<typeof bindAgentTags>);
843
823
  phones: {
844
824
  connect(agentId: string, payload: ConnectPhoneRequest): Promise<PhoneAssignmentResponse>;
845
825
  disconnect(agentId: string, phoneId: string): Promise<void>;
846
- };
826
+ } & ((agentId: string) => ReturnType<typeof bindAgentPhones>);
847
827
  schedule: {
848
828
  get(agentId: string): Promise<AgentSchedule>;
849
829
  update(agentId: string, payload: UpdateAgentScheduleRequest): Promise<AgentSchedule>;
850
- };
830
+ } & ((agentId: string) => ReturnType<typeof bindAgentSchedule>);
851
831
  versions: {
852
832
  list(agentId: string, opts?: ListAgentVersionsOptions): Promise<PaginatedResult<AgentVersionListResponse, ListAgentVersionsOptions>>;
853
833
  get(agentId: string, versionId: string): Promise<AgentVersionDetail>;
@@ -858,7 +838,7 @@ declare function createClient(initialCfg: ClientConfig & {
858
838
  createInstruction(agentId: string, versionId: string, payload: CreateInstructionRequest): Promise<InstructionCreatedResponse>;
859
839
  updateInstruction(agentId: string, versionId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
860
840
  deleteInstruction(agentId: string, versionId: string, instructionId: string): Promise<void>;
861
- };
841
+ } & ((agentId: string) => ReturnType<typeof bindAgentVersions>);
862
842
  delete: (agent: string | AgentEntity) => Promise<void>;
863
843
  list(options?: ListAgentsOptions): Promise<PaginatedResult<Omit<{
864
844
  data: components["schemas"]["AgentSummary"][];
@@ -916,6 +896,7 @@ declare function createHttp(cfg: ClientConfig & {
916
896
  doFetch: (url: string, init?: FetchOptions) => Promise<Response>;
917
897
  buildHeaders: (extra?: HeadersInit) => Record<string, string>;
918
898
  resolveWorkspaceId: () => string;
899
+ resolveApiKey: () => string;
919
900
  };
920
901
 
921
902
  export { type AgentDetail, type AgentEntity, type AgentEntityFactoryOptions, type AgentListResponse, type AgentSchedule, type AgentSummary, type AgentTagRequest, type AgentTagsResponse, type AgentVersionDetail, type AgentVersionListResponse, type AgentVersionSummary, type AgentsApi, type AgentsApiWithEntities, type ClientConfig, type ConnectPhoneRequest, type CreateAgentRequest, type CreateAgentVersionRequest, type CreateInstructionRequest, type ErrorResponse, type ExecuteToolRequest, type ExecuteToolResponse, HttpError, type Instruction, type InstructionCreatedResponse, type InstructionListResponse, type ListAgentInstructionsOptions, type ListAgentVersionInstructionsOptions, type ListAgentVersionsOptions, type ListAgentsOptions, type ListQueryOptions, type ListToolResourcesOptions, type ListToolsOptions, type ListVoicesOptions, type ListWorkspacePhonesOptions, NetworkError, type PaginatedResult, type PaginationMeta, type PhoneAssignmentResponse, type QueryBuilderInput, type QueryBuilderSerializable, type QueryFilterOperators, type QueryFilters, type QueryOrGroups, type QueryValue, type RetryPolicy, TimeoutError, type ToolConnectionRequest, type ToolConnectionResponse, type ToolListResponse, type ToolResourceListResponse, type ToolResourceReloadResponse, type ToolResourceSummary, type ToolResourceUploadRequest, type ToolResourceUploadResponse, type ToolSummary, type UpdateAgentRequest, type UpdateAgentScheduleRequest, type UpdateAgentVersionRequest, type UpdateInstructionRequest, type VoiceListResponse, type VoiceSummary, type WorkspaceEnableRequest, type WorkspaceEnableResponse, type WorkspacePhone, type WorkspacePhoneChannel, type WorkspacePhonesResponse, bindAgentInstructions, bindAgentPhones, bindAgentSchedule, bindAgentTags, bindAgentVersions, createAgentEntity, createAgentInstructionsApi, createAgentPhonesApi, createAgentScheduleApi, createAgentTagsApi, createAgentVersionsApi, createAgentsApi, createClient, createHttp, createToolsApi, createVoicesApi, createWorkspacesApi };
package/dist/index.js CHANGED
@@ -192,7 +192,9 @@ function createHttp(cfg) {
192
192
  const log = cfg.logger ?? {};
193
193
  const retry = cfg.retry;
194
194
  const WORKSPACE_HEADER = "x-workspace-id";
195
+ const API_KEY_HEADER = "x-api-key";
195
196
  const resolveWorkspaceId = () => cfg.getWorkspaceId?.() ?? cfg.workspaceId ?? void 0;
197
+ const resolveApiKey = () => cfg.getApiKey?.() ?? cfg.apiKey ?? void 0;
196
198
  const normalizeHeaders = (headers) => {
197
199
  if (!headers) {
198
200
  return {};
@@ -216,9 +218,12 @@ function createHttp(cfg) {
216
218
  const workspaceId = resolveWorkspaceId();
217
219
  const normalizedExtra = normalizeHeaders(extra);
218
220
  const headersWithWorkspace = workspaceId ? { [WORKSPACE_HEADER]: workspaceId } : {};
221
+ const apiKey = resolveApiKey();
222
+ const headersWithApiKey = apiKey ? { [API_KEY_HEADER]: apiKey } : {};
219
223
  return {
220
224
  ...baseHeaders,
221
225
  ...headersWithWorkspace,
226
+ ...headersWithApiKey,
222
227
  ...normalizedExtra
223
228
  };
224
229
  };
@@ -259,7 +264,8 @@ function createHttp(cfg) {
259
264
  retry,
260
265
  doFetch,
261
266
  buildHeaders,
262
- resolveWorkspaceId
267
+ resolveWorkspaceId,
268
+ resolveApiKey
263
269
  };
264
270
  }
265
271
 
@@ -700,7 +706,12 @@ function createAgentsApi(cfg, relatedApis) {
700
706
  const { base, doFetch } = createHttp(cfg);
701
707
  const jsonHeaders = { "content-type": "application/json" };
702
708
  const fetchAgentsPage = async (options = {}) => {
703
- const query = serializeListOptions(options);
709
+ const sanitizedOptions = {
710
+ page: options.page,
711
+ limit: options.limit,
712
+ filter: options.filter
713
+ };
714
+ const query = serializeListOptions(sanitizedOptions);
704
715
  const res = await doFetch(`${base}/v1/agents`, {
705
716
  method: "GET",
706
717
  query
@@ -992,12 +1003,19 @@ function createClient(initialCfg) {
992
1003
  ...initialCfg
993
1004
  };
994
1005
  const resolveWorkspaceId = () => runtimeCfg.workspaceId ?? runtimeCfg.getWorkspaceId?.();
1006
+ const resolveApiKey = () => runtimeCfg.apiKey ?? runtimeCfg.getApiKey?.();
995
1007
  const setWorkspaceId = (workspaceId) => {
996
1008
  runtimeCfg.workspaceId = workspaceId;
997
1009
  };
998
1010
  const setWorkspaceGetter = (getter) => {
999
1011
  runtimeCfg.getWorkspaceId = getter;
1000
1012
  };
1013
+ const setApiKey = (apiKey) => {
1014
+ runtimeCfg.apiKey = apiKey;
1015
+ };
1016
+ const setApiKeyGetter = (getter) => {
1017
+ runtimeCfg.getApiKey = getter;
1018
+ };
1001
1019
  const instructionsApi = createAgentInstructionsApi(runtimeCfg);
1002
1020
  const tagsApi = createAgentTagsApi(runtimeCfg);
1003
1021
  const phonesApi = createAgentPhonesApi(runtimeCfg);
@@ -1011,14 +1029,34 @@ function createClient(initialCfg) {
1011
1029
  scheduleApi,
1012
1030
  versionsApi
1013
1031
  });
1032
+ const instructionsNamespace = Object.assign(
1033
+ (agentId) => bindAgentInstructions(instructionsApi, agentId),
1034
+ instructionsApi
1035
+ );
1036
+ const tagsNamespace = Object.assign(
1037
+ (agentId) => bindAgentTags(tagsApi, agentId),
1038
+ tagsApi
1039
+ );
1040
+ const phonesNamespace = Object.assign(
1041
+ (agentId) => bindAgentPhones(phonesApi, agentId),
1042
+ phonesApi
1043
+ );
1044
+ const scheduleNamespace = Object.assign(
1045
+ (agentId) => bindAgentSchedule(scheduleApi, agentId),
1046
+ scheduleApi
1047
+ );
1048
+ const versionsNamespace = Object.assign(
1049
+ (agentId) => bindAgentVersions(versionsApi, agentId),
1050
+ versionsApi
1051
+ );
1014
1052
  const apis = {
1015
1053
  agents: {
1016
1054
  ...agentsApi,
1017
- instructions: instructionsApi,
1018
- tags: tagsApi,
1019
- phones: phonesApi,
1020
- schedule: scheduleApi,
1021
- versions: versionsApi
1055
+ instructions: instructionsNamespace,
1056
+ tags: tagsNamespace,
1057
+ phones: phonesNamespace,
1058
+ schedule: scheduleNamespace,
1059
+ versions: versionsNamespace
1022
1060
  },
1023
1061
  workspaces: createWorkspacesApi(runtimeCfg),
1024
1062
  tools: createToolsApi(runtimeCfg),
@@ -1026,6 +1064,20 @@ function createClient(initialCfg) {
1026
1064
  };
1027
1065
  return {
1028
1066
  ...apis,
1067
+ auth: {
1068
+ getApiKey: resolveApiKey,
1069
+ setApiKey(key) {
1070
+ setApiKeyGetter(void 0);
1071
+ setApiKey(key);
1072
+ },
1073
+ useApiKey(getter) {
1074
+ setApiKeyGetter(getter);
1075
+ },
1076
+ clearApiKey() {
1077
+ setApiKeyGetter(void 0);
1078
+ setApiKey(void 0);
1079
+ }
1080
+ },
1029
1081
  workspace: {
1030
1082
  get: resolveWorkspaceId,
1031
1083
  set(id) {
@@ -1043,7 +1095,9 @@ function createClient(initialCfg) {
1043
1095
  return createClient({
1044
1096
  ...initialCfg,
1045
1097
  workspaceId: id,
1046
- getWorkspaceId: void 0
1098
+ getWorkspaceId: void 0,
1099
+ apiKey: runtimeCfg.apiKey,
1100
+ getApiKey: runtimeCfg.getApiKey
1047
1101
  });
1048
1102
  }
1049
1103
  }