@getsupervisor/agents-studio-sdk 1.11.0 → 1.13.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
@@ -350,6 +350,8 @@ type ClientConfig = {
350
350
  getWorkspaceId?: () => string | undefined;
351
351
  apiKey?: string;
352
352
  getApiKey?: () => string | undefined;
353
+ accessToken?: string;
354
+ getAccessToken?: () => string | undefined;
353
355
  };
354
356
  type AgentDetail = components['schemas']['AgentDetail'];
355
357
  type AgentSummary = components['schemas']['AgentSummary'];
@@ -372,6 +374,28 @@ type WorkspaceEnableRequest = components['schemas']['WorkspaceEnableRequest'];
372
374
  type WorkspaceEnableResponse = components['schemas']['WorkspaceEnableResponse'];
373
375
  type VoiceSummary = components['schemas']['VoiceSummary'];
374
376
  type VoiceListResponse = components['schemas']['VoiceListResponse'];
377
+ type ApiKeySummary = {
378
+ id: string;
379
+ name: string;
380
+ description?: string | null;
381
+ scopes: string[];
382
+ environment: 'production' | 'sandbox' | 'staging' | 'development';
383
+ keyPreview: string;
384
+ createdAt: string;
385
+ updatedAt: string;
386
+ lastUsedAt?: string | null;
387
+ revokedAt?: string | null;
388
+ };
389
+ type ApiKeyListResponse = ApiKeySummary[];
390
+ type CreateApiKeyRequest = {
391
+ name: string;
392
+ description?: string | null;
393
+ environment?: 'production' | 'sandbox' | 'staging' | 'development';
394
+ scopes?: string[];
395
+ };
396
+ type CreateApiKeyResponse = ApiKeySummary & {
397
+ key: string;
398
+ };
375
399
  type AgentSchedule = components['schemas']['AgentSchedule'];
376
400
  type UpdateAgentScheduleRequest = components['schemas']['UpdateAgentScheduleRequest'];
377
401
  type AgentVersionSummary = components['schemas']['AgentVersionSummary'];
@@ -741,6 +765,16 @@ declare function createAgentsApi(cfg: ClientConfig & {
741
765
  retry?: RetryPolicy;
742
766
  }, relatedApis?: AgentEntityDependencies): AgentsApi | AgentsApiWithEntities;
743
767
 
768
+ type ApiKeysApi = {
769
+ list(): Promise<ApiKeyListResponse>;
770
+ create(payload: CreateApiKeyRequest): Promise<CreateApiKeyResponse>;
771
+ revoke(apiKeyId: string): Promise<void>;
772
+ show(apiKeyId: string): Promise<CreateApiKeyResponse>;
773
+ };
774
+ declare function createApiKeysApi(cfg: ClientConfig & {
775
+ retry?: RetryPolicy;
776
+ }): ApiKeysApi;
777
+
744
778
  type ListToolsOptions = ListQueryOptions & {
745
779
  agentType?: 'chat' | 'voice';
746
780
  };
@@ -794,6 +828,10 @@ declare function createClient(initialCfg: ClientConfig & {
794
828
  setApiKey(key?: string): void;
795
829
  useApiKey(getter?: () => string | undefined): void;
796
830
  clearApiKey(): void;
831
+ getAccessToken: () => string;
832
+ setAccessToken(token?: string): void;
833
+ useAccessToken(getter?: () => string | undefined): void;
834
+ clearAccessToken(): void;
797
835
  };
798
836
  workspace: {
799
837
  get: () => string;
@@ -806,6 +844,10 @@ declare function createClient(initialCfg: ClientConfig & {
806
844
  setApiKey(key?: string): void;
807
845
  useApiKey(getter?: () => string | undefined): void;
808
846
  clearApiKey(): void;
847
+ getAccessToken: () => string;
848
+ setAccessToken(token?: string): void;
849
+ useAccessToken(getter?: () => string | undefined): void;
850
+ clearAccessToken(): void;
809
851
  };
810
852
  workspace: {
811
853
  get: () => string;
@@ -881,6 +923,7 @@ declare function createClient(initialCfg: ClientConfig & {
881
923
  voices: {
882
924
  list(options?: ListVoicesOptions): Promise<PaginatedResult<VoiceListResponse, ListVoicesOptions>>;
883
925
  };
926
+ apiKeys: ApiKeysApi;
884
927
  };
885
928
  };
886
929
  agents: {
@@ -950,6 +993,7 @@ declare function createClient(initialCfg: ClientConfig & {
950
993
  voices: {
951
994
  list(options?: ListVoicesOptions): Promise<PaginatedResult<VoiceListResponse, ListVoicesOptions>>;
952
995
  };
996
+ apiKeys: ApiKeysApi;
953
997
  };
954
998
 
955
999
  type QueryParamPrimitive = string | number | boolean;
@@ -972,6 +1016,7 @@ declare function createHttp(cfg: ClientConfig & {
972
1016
  buildHeaders: (extra?: HeadersInit) => Record<string, string>;
973
1017
  resolveWorkspaceId: () => string;
974
1018
  resolveApiKey: () => string;
1019
+ resolveAccessToken: () => string;
975
1020
  };
976
1021
 
977
- export { type AgentBlueprint, type AgentBlueprintListItem, type AgentBlueprintListResponse, type AgentBlueprintsApi$1 as AgentBlueprintsApi, 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 CreateAgentBlueprintRequest, type CreateAgentRequest, type CreateAgentVersionRequest, type CreateInstructionRequest, type ErrorResponse, type ExecuteToolRequest, type ExecuteToolResponse, HttpError, type Instruction, type InstructionCreatedResponse, type InstructionListResponse, type ListAgentBlueprintsOptions, 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 UpdateAgentBlueprintRequest, type UpdateAgentRequest, type UpdateAgentScheduleRequest, type UpdateAgentVersionRequest, type UpdateInstructionRequest, type VoiceListResponse, type VoiceSummary, type WorkspaceEnableRequest, type WorkspaceEnableResponse, type WorkspacePhone, type WorkspacePhoneChannel, type WorkspacePhonesResponse, bindAgentBlueprints, bindAgentInstructions, bindAgentPhones, bindAgentSchedule, bindAgentTags, bindAgentVersions, createAgentBlueprintsApi, createAgentEntity, createAgentInstructionsApi, createAgentPhonesApi, createAgentScheduleApi, createAgentTagsApi, createAgentVersionsApi, createAgentsApi, createClient, createHttp, createToolsApi, createVoicesApi, createWorkspacesApi };
1022
+ export { type AgentBlueprint, type AgentBlueprintListItem, type AgentBlueprintListResponse, type AgentBlueprintsApi$1 as AgentBlueprintsApi, 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 ApiKeyListResponse, type ApiKeySummary, type ApiKeysApi, type ClientConfig, type ConnectPhoneRequest, type CreateAgentBlueprintRequest, type CreateAgentRequest, type CreateAgentVersionRequest, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateInstructionRequest, type ErrorResponse, type ExecuteToolRequest, type ExecuteToolResponse, HttpError, type Instruction, type InstructionCreatedResponse, type InstructionListResponse, type ListAgentBlueprintsOptions, 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 UpdateAgentBlueprintRequest, type UpdateAgentRequest, type UpdateAgentScheduleRequest, type UpdateAgentVersionRequest, type UpdateInstructionRequest, type VoiceListResponse, type VoiceSummary, type WorkspaceEnableRequest, type WorkspaceEnableResponse, type WorkspacePhone, type WorkspacePhoneChannel, type WorkspacePhonesResponse, bindAgentBlueprints, bindAgentInstructions, bindAgentPhones, bindAgentSchedule, bindAgentTags, bindAgentVersions, createAgentBlueprintsApi, createAgentEntity, createAgentInstructionsApi, createAgentPhonesApi, createAgentScheduleApi, createAgentTagsApi, createAgentVersionsApi, createAgentsApi, createApiKeysApi, createClient, createHttp, createToolsApi, createVoicesApi, createWorkspacesApi };
package/dist/index.js CHANGED
@@ -101,8 +101,10 @@ function createHttp(cfg) {
101
101
  const retry = cfg.retry;
102
102
  const WORKSPACE_HEADER = "x-workspace-id";
103
103
  const API_KEY_HEADER = "x-api-key";
104
+ const AUTHORIZATION_HEADER = "authorization";
104
105
  const resolveWorkspaceId = () => cfg.getWorkspaceId?.() ?? cfg.workspaceId ?? void 0;
105
106
  const resolveApiKey = () => cfg.getApiKey?.() ?? cfg.apiKey ?? void 0;
107
+ const resolveAccessToken = () => cfg.getAccessToken?.() ?? cfg.accessToken ?? void 0;
106
108
  const normalizeHeaders = (headers) => {
107
109
  if (!headers) {
108
110
  return {};
@@ -128,10 +130,15 @@ function createHttp(cfg) {
128
130
  const headersWithWorkspace = workspaceId ? { [WORKSPACE_HEADER]: workspaceId } : {};
129
131
  const apiKey = resolveApiKey();
130
132
  const headersWithApiKey = apiKey ? { [API_KEY_HEADER]: apiKey } : {};
133
+ const accessToken = resolveAccessToken();
134
+ const headersWithAuthorization = accessToken ? {
135
+ [AUTHORIZATION_HEADER]: accessToken.startsWith("Bearer ") ? accessToken : `Bearer ${accessToken}`
136
+ } : {};
131
137
  return {
132
138
  ...baseHeaders,
133
139
  ...headersWithWorkspace,
134
140
  ...headersWithApiKey,
141
+ ...headersWithAuthorization,
135
142
  ...normalizedExtra
136
143
  };
137
144
  };
@@ -173,7 +180,8 @@ function createHttp(cfg) {
173
180
  doFetch,
174
181
  buildHeaders,
175
182
  resolveWorkspaceId,
176
- resolveApiKey
183
+ resolveApiKey,
184
+ resolveAccessToken
177
185
  };
178
186
  }
179
187
 
@@ -884,6 +892,37 @@ function createAgentsApi(cfg, relatedApis) {
884
892
  };
885
893
  }
886
894
 
895
+ // src/api/api-keys.ts
896
+ function createApiKeysApi(cfg) {
897
+ const { base, doFetch } = createHttp(cfg);
898
+ const jsonHeaders = { "content-type": "application/json" };
899
+ return {
900
+ async list() {
901
+ const res = await doFetch(`${base}/v1/api-keys`, { method: "GET" });
902
+ return res.json();
903
+ },
904
+ async create(payload) {
905
+ const res = await doFetch(`${base}/v1/api-keys`, {
906
+ method: "POST",
907
+ headers: jsonHeaders,
908
+ body: JSON.stringify(payload)
909
+ });
910
+ return res.json();
911
+ },
912
+ async revoke(apiKeyId) {
913
+ await doFetch(`${base}/v1/api-keys/${apiKeyId}`, {
914
+ method: "DELETE"
915
+ });
916
+ },
917
+ async show(apiKeyId) {
918
+ const res = await doFetch(`${base}/v1/api-keys/${apiKeyId}/show`, {
919
+ method: "GET"
920
+ });
921
+ return res.json();
922
+ }
923
+ };
924
+ }
925
+
887
926
  // src/api/tools.ts
888
927
  var isFormData = (value) => {
889
928
  return typeof FormData !== "undefined" && value instanceof FormData;
@@ -1076,6 +1115,7 @@ function createClient(initialCfg) {
1076
1115
  };
1077
1116
  const resolveWorkspaceId = () => runtimeCfg.workspaceId ?? runtimeCfg.getWorkspaceId?.();
1078
1117
  const resolveApiKey = () => runtimeCfg.apiKey ?? runtimeCfg.getApiKey?.();
1118
+ const resolveAccessToken = () => runtimeCfg.accessToken ?? runtimeCfg.getAccessToken?.();
1079
1119
  const setWorkspaceId = (workspaceId) => {
1080
1120
  runtimeCfg.workspaceId = workspaceId;
1081
1121
  };
@@ -1088,6 +1128,12 @@ function createClient(initialCfg) {
1088
1128
  const setApiKeyGetter = (getter) => {
1089
1129
  runtimeCfg.getApiKey = getter;
1090
1130
  };
1131
+ const setAccessToken = (token) => {
1132
+ runtimeCfg.accessToken = token;
1133
+ };
1134
+ const setAccessTokenGetter = (getter) => {
1135
+ runtimeCfg.getAccessToken = getter;
1136
+ };
1091
1137
  const instructionsApi = createAgentInstructionsApi(runtimeCfg);
1092
1138
  const tagsApi = createAgentTagsApi(runtimeCfg);
1093
1139
  const phonesApi = createAgentPhonesApi(runtimeCfg);
@@ -1095,6 +1141,7 @@ function createClient(initialCfg) {
1095
1141
  const versionsApi = createAgentVersionsApi(runtimeCfg);
1096
1142
  const blueprintsApi = createAgentBlueprintsApi(runtimeCfg);
1097
1143
  const voicesApi = createVoicesApi(runtimeCfg);
1144
+ const apiKeysApi = createApiKeysApi(runtimeCfg);
1098
1145
  const agentsApi = createAgentsApi(runtimeCfg, {
1099
1146
  instructionsApi,
1100
1147
  tagsApi,
@@ -1139,7 +1186,8 @@ function createClient(initialCfg) {
1139
1186
  },
1140
1187
  workspaces: createWorkspacesApi(runtimeCfg),
1141
1188
  tools: createToolsApi(runtimeCfg),
1142
- voices: voicesApi
1189
+ voices: voicesApi,
1190
+ apiKeys: apiKeysApi
1143
1191
  };
1144
1192
  return {
1145
1193
  ...apis,
@@ -1155,6 +1203,18 @@ function createClient(initialCfg) {
1155
1203
  clearApiKey() {
1156
1204
  setApiKeyGetter(void 0);
1157
1205
  setApiKey(void 0);
1206
+ },
1207
+ getAccessToken: resolveAccessToken,
1208
+ setAccessToken(token) {
1209
+ setAccessTokenGetter(void 0);
1210
+ setAccessToken(token);
1211
+ },
1212
+ useAccessToken(getter) {
1213
+ setAccessTokenGetter(getter);
1214
+ },
1215
+ clearAccessToken() {
1216
+ setAccessTokenGetter(void 0);
1217
+ setAccessToken(void 0);
1158
1218
  }
1159
1219
  },
1160
1220
  workspace: {
@@ -1176,7 +1236,9 @@ function createClient(initialCfg) {
1176
1236
  workspaceId: id,
1177
1237
  getWorkspaceId: void 0,
1178
1238
  apiKey: runtimeCfg.apiKey,
1179
- getApiKey: runtimeCfg.getApiKey
1239
+ getApiKey: runtimeCfg.getApiKey,
1240
+ accessToken: runtimeCfg.accessToken,
1241
+ getAccessToken: runtimeCfg.getAccessToken
1180
1242
  });
1181
1243
  }
1182
1244
  }
@@ -1200,6 +1262,7 @@ export {
1200
1262
  createAgentTagsApi,
1201
1263
  createAgentVersionsApi,
1202
1264
  createAgentsApi,
1265
+ createApiKeysApi,
1203
1266
  createClient,
1204
1267
  createHttp,
1205
1268
  createToolsApi,