@getsupervisor/agents-studio-sdk 1.8.0 → 1.10.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
@@ -60,15 +60,11 @@ type components = {
60
60
  };
61
61
  InstructionListResponse: {
62
62
  data: components['schemas']['Instruction'][];
63
- versionId?: string | null;
64
63
  meta?: components['schemas']['PaginationMeta'];
65
64
  };
66
65
  CreateInstructionRequest: {
67
66
  order: number;
68
67
  content: string;
69
- metadata?: {
70
- [key: string]: unknown;
71
- };
72
68
  };
73
69
  InstructionCreatedResponse: {
74
70
  id: string;
@@ -79,9 +75,6 @@ type components = {
79
75
  UpdateInstructionRequest: {
80
76
  order?: number;
81
77
  content?: string;
82
- metadata?: {
83
- [key: string]: unknown;
84
- };
85
78
  };
86
79
  VoiceSummary: {
87
80
  id: string;
@@ -355,6 +348,8 @@ type ClientConfig = {
355
348
  };
356
349
  workspaceId?: string;
357
350
  getWorkspaceId?: () => string | undefined;
351
+ apiKey?: string;
352
+ getApiKey?: () => string | undefined;
358
353
  };
359
354
  type AgentDetail = components['schemas']['AgentDetail'];
360
355
  type AgentSummary = components['schemas']['AgentSummary'];
@@ -506,7 +501,6 @@ type AgentEntityFactoryOptions = {
506
501
  declare const bindAgentInstructions: (api: AgentInstructionsApi, agentId: string) => {
507
502
  list(opts?: ListAgentInstructionsOptions): Promise<PaginatedResult<{
508
503
  data: components["schemas"]["Instruction"][];
509
- versionId?: string | null;
510
504
  meta?: components["schemas"]["PaginationMeta"];
511
505
  }, ListAgentInstructionsOptions>>;
512
506
  create(payload: CreateInstructionRequest): Promise<{
@@ -615,7 +609,6 @@ declare const bindAgentVersions: (api: AgentVersionsApi, agentId: string) => {
615
609
  instructions(versionId: string): {
616
610
  readonly list: (opts?: ListAgentVersionInstructionsOptions) => Promise<{
617
611
  data: components["schemas"]["Instruction"][];
618
- versionId?: string | null;
619
612
  meta?: components["schemas"]["PaginationMeta"];
620
613
  }>;
621
614
  readonly create: (payload: CreateInstructionRequest) => Promise<{
@@ -714,12 +707,24 @@ declare function createWorkspacesApi(cfg: ClientConfig & {
714
707
  declare function createClient(initialCfg: ClientConfig & {
715
708
  retry?: RetryPolicy;
716
709
  }): {
710
+ auth: {
711
+ getApiKey: () => string;
712
+ setApiKey(key?: string): void;
713
+ useApiKey(getter?: () => string | undefined): void;
714
+ clearApiKey(): void;
715
+ };
717
716
  workspace: {
718
717
  get: () => string;
719
718
  set(id?: string): void;
720
719
  useGetter(getter?: () => string | undefined): void;
721
720
  clear(): void;
722
721
  scoped(id: string): {
722
+ auth: {
723
+ getApiKey: () => string;
724
+ setApiKey(key?: string): void;
725
+ useApiKey(getter?: () => string | undefined): void;
726
+ clearApiKey(): void;
727
+ };
723
728
  workspace: {
724
729
  get: () => string;
725
730
  set(id?: string): void;
@@ -733,19 +738,19 @@ declare function createClient(initialCfg: ClientConfig & {
733
738
  create(agentId: string, payload: CreateInstructionRequest): Promise<InstructionCreatedResponse>;
734
739
  update(agentId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
735
740
  delete(agentId: string, instructionId: string): Promise<void>;
736
- };
741
+ } & ((agentId: string) => ReturnType<typeof bindAgentInstructions>);
737
742
  tags: {
738
743
  readonly add: (agentId: string, payload: AgentTagRequest) => Promise<AgentTagsResponse>;
739
744
  readonly remove: (agentId: string, tagId: string) => Promise<void>;
740
- };
745
+ } & ((agentId: string) => ReturnType<typeof bindAgentTags>);
741
746
  phones: {
742
747
  connect(agentId: string, payload: ConnectPhoneRequest): Promise<PhoneAssignmentResponse>;
743
748
  disconnect(agentId: string, phoneId: string): Promise<void>;
744
- };
749
+ } & ((agentId: string) => ReturnType<typeof bindAgentPhones>);
745
750
  schedule: {
746
751
  get(agentId: string): Promise<AgentSchedule>;
747
752
  update(agentId: string, payload: UpdateAgentScheduleRequest): Promise<AgentSchedule>;
748
- };
753
+ } & ((agentId: string) => ReturnType<typeof bindAgentSchedule>);
749
754
  versions: {
750
755
  list(agentId: string, opts?: ListAgentVersionsOptions): Promise<PaginatedResult<AgentVersionListResponse, ListAgentVersionsOptions>>;
751
756
  get(agentId: string, versionId: string): Promise<AgentVersionDetail>;
@@ -756,7 +761,7 @@ declare function createClient(initialCfg: ClientConfig & {
756
761
  createInstruction(agentId: string, versionId: string, payload: CreateInstructionRequest): Promise<InstructionCreatedResponse>;
757
762
  updateInstruction(agentId: string, versionId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
758
763
  deleteInstruction(agentId: string, versionId: string, instructionId: string): Promise<void>;
759
- };
764
+ } & ((agentId: string) => ReturnType<typeof bindAgentVersions>);
760
765
  delete: (agent: string | AgentEntity) => Promise<void>;
761
766
  list(options?: ListAgentsOptions): Promise<PaginatedResult<Omit<{
762
767
  data: components["schemas"]["AgentSummary"][];
@@ -801,19 +806,19 @@ declare function createClient(initialCfg: ClientConfig & {
801
806
  create(agentId: string, payload: CreateInstructionRequest): Promise<InstructionCreatedResponse>;
802
807
  update(agentId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
803
808
  delete(agentId: string, instructionId: string): Promise<void>;
804
- };
809
+ } & ((agentId: string) => ReturnType<typeof bindAgentInstructions>);
805
810
  tags: {
806
811
  readonly add: (agentId: string, payload: AgentTagRequest) => Promise<AgentTagsResponse>;
807
812
  readonly remove: (agentId: string, tagId: string) => Promise<void>;
808
- };
813
+ } & ((agentId: string) => ReturnType<typeof bindAgentTags>);
809
814
  phones: {
810
815
  connect(agentId: string, payload: ConnectPhoneRequest): Promise<PhoneAssignmentResponse>;
811
816
  disconnect(agentId: string, phoneId: string): Promise<void>;
812
- };
817
+ } & ((agentId: string) => ReturnType<typeof bindAgentPhones>);
813
818
  schedule: {
814
819
  get(agentId: string): Promise<AgentSchedule>;
815
820
  update(agentId: string, payload: UpdateAgentScheduleRequest): Promise<AgentSchedule>;
816
- };
821
+ } & ((agentId: string) => ReturnType<typeof bindAgentSchedule>);
817
822
  versions: {
818
823
  list(agentId: string, opts?: ListAgentVersionsOptions): Promise<PaginatedResult<AgentVersionListResponse, ListAgentVersionsOptions>>;
819
824
  get(agentId: string, versionId: string): Promise<AgentVersionDetail>;
@@ -824,7 +829,7 @@ declare function createClient(initialCfg: ClientConfig & {
824
829
  createInstruction(agentId: string, versionId: string, payload: CreateInstructionRequest): Promise<InstructionCreatedResponse>;
825
830
  updateInstruction(agentId: string, versionId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
826
831
  deleteInstruction(agentId: string, versionId: string, instructionId: string): Promise<void>;
827
- };
832
+ } & ((agentId: string) => ReturnType<typeof bindAgentVersions>);
828
833
  delete: (agent: string | AgentEntity) => Promise<void>;
829
834
  list(options?: ListAgentsOptions): Promise<PaginatedResult<Omit<{
830
835
  data: components["schemas"]["AgentSummary"][];
@@ -882,6 +887,7 @@ declare function createHttp(cfg: ClientConfig & {
882
887
  doFetch: (url: string, init?: FetchOptions) => Promise<Response>;
883
888
  buildHeaders: (extra?: HeadersInit) => Record<string, string>;
884
889
  resolveWorkspaceId: () => string;
890
+ resolveApiKey: () => string;
885
891
  };
886
892
 
887
893
  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
 
@@ -997,12 +1003,19 @@ function createClient(initialCfg) {
997
1003
  ...initialCfg
998
1004
  };
999
1005
  const resolveWorkspaceId = () => runtimeCfg.workspaceId ?? runtimeCfg.getWorkspaceId?.();
1006
+ const resolveApiKey = () => runtimeCfg.apiKey ?? runtimeCfg.getApiKey?.();
1000
1007
  const setWorkspaceId = (workspaceId) => {
1001
1008
  runtimeCfg.workspaceId = workspaceId;
1002
1009
  };
1003
1010
  const setWorkspaceGetter = (getter) => {
1004
1011
  runtimeCfg.getWorkspaceId = getter;
1005
1012
  };
1013
+ const setApiKey = (apiKey) => {
1014
+ runtimeCfg.apiKey = apiKey;
1015
+ };
1016
+ const setApiKeyGetter = (getter) => {
1017
+ runtimeCfg.getApiKey = getter;
1018
+ };
1006
1019
  const instructionsApi = createAgentInstructionsApi(runtimeCfg);
1007
1020
  const tagsApi = createAgentTagsApi(runtimeCfg);
1008
1021
  const phonesApi = createAgentPhonesApi(runtimeCfg);
@@ -1016,14 +1029,34 @@ function createClient(initialCfg) {
1016
1029
  scheduleApi,
1017
1030
  versionsApi
1018
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
+ );
1019
1052
  const apis = {
1020
1053
  agents: {
1021
1054
  ...agentsApi,
1022
- instructions: instructionsApi,
1023
- tags: tagsApi,
1024
- phones: phonesApi,
1025
- schedule: scheduleApi,
1026
- versions: versionsApi
1055
+ instructions: instructionsNamespace,
1056
+ tags: tagsNamespace,
1057
+ phones: phonesNamespace,
1058
+ schedule: scheduleNamespace,
1059
+ versions: versionsNamespace
1027
1060
  },
1028
1061
  workspaces: createWorkspacesApi(runtimeCfg),
1029
1062
  tools: createToolsApi(runtimeCfg),
@@ -1031,6 +1064,20 @@ function createClient(initialCfg) {
1031
1064
  };
1032
1065
  return {
1033
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
+ },
1034
1081
  workspace: {
1035
1082
  get: resolveWorkspaceId,
1036
1083
  set(id) {
@@ -1048,7 +1095,9 @@ function createClient(initialCfg) {
1048
1095
  return createClient({
1049
1096
  ...initialCfg,
1050
1097
  workspaceId: id,
1051
- getWorkspaceId: void 0
1098
+ getWorkspaceId: void 0,
1099
+ apiKey: runtimeCfg.apiKey,
1100
+ getApiKey: runtimeCfg.getApiKey
1052
1101
  });
1053
1102
  }
1054
1103
  }