@getsupervisor/agents-studio-sdk 1.9.0 → 1.11.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/CHANGELOG.md +29 -0
- package/README.md +23 -0
- package/dist/index.cjs +177 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -10
- package/dist/index.d.ts +85 -10
- package/dist/index.js +175 -94
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -386,6 +379,64 @@ type AgentVersionDetail = components['schemas']['AgentVersionDetail'];
|
|
|
386
379
|
type AgentVersionListResponse = components['schemas']['AgentVersionListResponse'];
|
|
387
380
|
type CreateAgentVersionRequest = components['schemas']['CreateAgentVersionRequest'];
|
|
388
381
|
type UpdateAgentVersionRequest = components['schemas']['UpdateAgentVersionRequest'];
|
|
382
|
+
type AgentBlueprint = {
|
|
383
|
+
id: string;
|
|
384
|
+
agentId: string;
|
|
385
|
+
versionId: string;
|
|
386
|
+
versionStatus: 'draft' | 'active' | 'archived';
|
|
387
|
+
languageId: string;
|
|
388
|
+
personalityName: string;
|
|
389
|
+
personalityRole: string;
|
|
390
|
+
targetAudience: string;
|
|
391
|
+
mainGoal: string;
|
|
392
|
+
personalityInitialGreeting: string;
|
|
393
|
+
personalityMessageStyleId: string;
|
|
394
|
+
personalityToneStyleId: string;
|
|
395
|
+
requiredData: Record<string, unknown>[];
|
|
396
|
+
criticalRules: string[];
|
|
397
|
+
topicsAllowed: string[];
|
|
398
|
+
topicsForbidden: string[];
|
|
399
|
+
createdAt: string;
|
|
400
|
+
updatedAt: string;
|
|
401
|
+
};
|
|
402
|
+
type AgentBlueprintListItem = {
|
|
403
|
+
versionId: string;
|
|
404
|
+
status: 'draft' | 'active' | 'archived';
|
|
405
|
+
createdAt: string;
|
|
406
|
+
updatedAt: string;
|
|
407
|
+
blueprint: AgentBlueprint;
|
|
408
|
+
};
|
|
409
|
+
type AgentBlueprintListResponse = {
|
|
410
|
+
data: AgentBlueprintListItem[];
|
|
411
|
+
};
|
|
412
|
+
type CreateAgentBlueprintRequest = {
|
|
413
|
+
languageId: string;
|
|
414
|
+
personalityName: string;
|
|
415
|
+
personalityRole: string;
|
|
416
|
+
targetAudience: string;
|
|
417
|
+
mainGoal: string;
|
|
418
|
+
personalityInitialGreeting: string;
|
|
419
|
+
personalityMessageStyleId: string;
|
|
420
|
+
personalityToneStyleId: string;
|
|
421
|
+
requiredData?: Record<string, unknown>[];
|
|
422
|
+
criticalRules?: string[];
|
|
423
|
+
topicsAllowed?: string[];
|
|
424
|
+
topicsForbidden?: string[];
|
|
425
|
+
};
|
|
426
|
+
type UpdateAgentBlueprintRequest = {
|
|
427
|
+
languageId?: string;
|
|
428
|
+
personalityName?: string;
|
|
429
|
+
personalityRole?: string;
|
|
430
|
+
targetAudience?: string;
|
|
431
|
+
mainGoal?: string;
|
|
432
|
+
personalityInitialGreeting?: string;
|
|
433
|
+
personalityMessageStyleId?: string;
|
|
434
|
+
personalityToneStyleId?: string;
|
|
435
|
+
requiredData?: Record<string, unknown>[];
|
|
436
|
+
criticalRules?: string[];
|
|
437
|
+
topicsAllowed?: string[];
|
|
438
|
+
topicsForbidden?: string[];
|
|
439
|
+
};
|
|
389
440
|
type ExecuteToolRequest = components['schemas']['ExecuteToolRequest'];
|
|
390
441
|
type ExecuteToolResponse = components['schemas']['ExecuteToolResponse'];
|
|
391
442
|
type ToolSummary = components['schemas']['ToolSummary'];
|
|
@@ -423,6 +474,17 @@ type RetryPolicy = {
|
|
|
423
474
|
retryOn?: (err: unknown, attempt: number) => boolean;
|
|
424
475
|
};
|
|
425
476
|
|
|
477
|
+
type ListAgentBlueprintsOptions = Pick<ListQueryOptions, 'filter'>;
|
|
478
|
+
type AgentBlueprintsApi$1 = {
|
|
479
|
+
list(agentId: string, options?: ListAgentBlueprintsOptions): Promise<AgentBlueprintListResponse>;
|
|
480
|
+
get(agentId: string, versionId: string): Promise<AgentBlueprint>;
|
|
481
|
+
create(agentId: string, versionId: string, payload: CreateAgentBlueprintRequest): Promise<AgentBlueprint>;
|
|
482
|
+
update(agentId: string, versionId: string, payload: UpdateAgentBlueprintRequest): Promise<AgentBlueprint>;
|
|
483
|
+
};
|
|
484
|
+
declare function createAgentBlueprintsApi(cfg: ClientConfig & {
|
|
485
|
+
retry?: RetryPolicy;
|
|
486
|
+
}): AgentBlueprintsApi$1;
|
|
487
|
+
|
|
426
488
|
type ListAgentInstructionsOptions = ListQueryOptions & {
|
|
427
489
|
versionId?: string;
|
|
428
490
|
};
|
|
@@ -479,11 +541,13 @@ type AgentTagsApi = ReturnType<typeof createAgentTagsApi>;
|
|
|
479
541
|
type AgentPhonesApi = ReturnType<typeof createAgentPhonesApi>;
|
|
480
542
|
type AgentScheduleApi = ReturnType<typeof createAgentScheduleApi>;
|
|
481
543
|
type AgentVersionsApi = ReturnType<typeof createAgentVersionsApi>;
|
|
544
|
+
type AgentBlueprintsApi = ReturnType<typeof createAgentBlueprintsApi>;
|
|
482
545
|
type AgentInstructionsHelper = ReturnType<typeof bindAgentInstructions>;
|
|
483
546
|
type AgentTagsHelper = ReturnType<typeof bindAgentTags>;
|
|
484
547
|
type AgentPhonesHelper = ReturnType<typeof bindAgentPhones>;
|
|
485
548
|
type AgentScheduleHelper = ReturnType<typeof bindAgentSchedule>;
|
|
486
549
|
type AgentVersionsHelper = ReturnType<typeof bindAgentVersions>;
|
|
550
|
+
type AgentBlueprintsHelper = ReturnType<typeof bindAgentBlueprints>;
|
|
487
551
|
type AgentBase = AgentSummary & Partial<Omit<AgentDetail, keyof AgentSummary>>;
|
|
488
552
|
interface AgentEntity extends AgentBase {
|
|
489
553
|
instructions: AgentInstructionsHelper;
|
|
@@ -491,6 +555,7 @@ interface AgentEntity extends AgentBase {
|
|
|
491
555
|
phones: AgentPhonesHelper;
|
|
492
556
|
schedule: AgentScheduleHelper;
|
|
493
557
|
versions: AgentVersionsHelper;
|
|
558
|
+
blueprints: AgentBlueprintsHelper;
|
|
494
559
|
save(patch: UpdateAgentRequest): Promise<AgentEntity>;
|
|
495
560
|
delete(): Promise<void>;
|
|
496
561
|
refresh(): Promise<AgentEntity>;
|
|
@@ -501,6 +566,7 @@ type AgentEntityFactoryOptions = {
|
|
|
501
566
|
phonesApi: AgentPhonesApi;
|
|
502
567
|
scheduleApi: AgentScheduleApi;
|
|
503
568
|
versionsApi: AgentVersionsApi;
|
|
569
|
+
blueprintsApi: AgentBlueprintsApi;
|
|
504
570
|
reload(agentId: string): Promise<AgentEntity>;
|
|
505
571
|
updateAgent(agentId: string, payload: UpdateAgentRequest): Promise<AgentEntity>;
|
|
506
572
|
deleteAgent(agentId: string): Promise<void>;
|
|
@@ -508,7 +574,6 @@ type AgentEntityFactoryOptions = {
|
|
|
508
574
|
declare const bindAgentInstructions: (api: AgentInstructionsApi, agentId: string) => {
|
|
509
575
|
list(opts?: ListAgentInstructionsOptions): Promise<PaginatedResult<{
|
|
510
576
|
data: components["schemas"]["Instruction"][];
|
|
511
|
-
versionId?: string | null;
|
|
512
577
|
meta?: components["schemas"]["PaginationMeta"];
|
|
513
578
|
}, ListAgentInstructionsOptions>>;
|
|
514
579
|
create(payload: CreateInstructionRequest): Promise<{
|
|
@@ -617,7 +682,6 @@ declare const bindAgentVersions: (api: AgentVersionsApi, agentId: string) => {
|
|
|
617
682
|
instructions(versionId: string): {
|
|
618
683
|
readonly list: (opts?: ListAgentVersionInstructionsOptions) => Promise<{
|
|
619
684
|
data: components["schemas"]["Instruction"][];
|
|
620
|
-
versionId?: string | null;
|
|
621
685
|
meta?: components["schemas"]["PaginationMeta"];
|
|
622
686
|
}>;
|
|
623
687
|
readonly create: (payload: CreateInstructionRequest) => Promise<{
|
|
@@ -637,6 +701,14 @@ declare const bindAgentVersions: (api: AgentVersionsApi, agentId: string) => {
|
|
|
637
701
|
readonly delete: (instructionId: string) => Promise<void>;
|
|
638
702
|
};
|
|
639
703
|
};
|
|
704
|
+
declare const bindAgentBlueprints: (api: AgentBlueprintsApi, agentId: string) => {
|
|
705
|
+
list(opts?: ListAgentBlueprintsOptions): Promise<AgentBlueprintListResponse>;
|
|
706
|
+
version(versionId: string): {
|
|
707
|
+
readonly get: () => Promise<AgentBlueprint>;
|
|
708
|
+
readonly create: (payload: CreateAgentBlueprintRequest) => Promise<AgentBlueprint>;
|
|
709
|
+
readonly update: (payload: UpdateAgentBlueprintRequest) => Promise<AgentBlueprint>;
|
|
710
|
+
};
|
|
711
|
+
};
|
|
640
712
|
type AgentSnapshot = AgentDetail | AgentSummary;
|
|
641
713
|
declare const createAgentEntity: (dto: AgentSnapshot, options: AgentEntityFactoryOptions) => AgentEntity;
|
|
642
714
|
|
|
@@ -646,6 +718,7 @@ type AgentEntityDependencies = {
|
|
|
646
718
|
phonesApi: ReturnType<typeof createAgentPhonesApi>;
|
|
647
719
|
scheduleApi: ReturnType<typeof createAgentScheduleApi>;
|
|
648
720
|
versionsApi: ReturnType<typeof createAgentVersionsApi>;
|
|
721
|
+
blueprintsApi: ReturnType<typeof createAgentBlueprintsApi>;
|
|
649
722
|
};
|
|
650
723
|
type ListAgentsOptions = Pick<ListQueryOptions, 'page' | 'limit' | 'filter'>;
|
|
651
724
|
type AgentsApi = {
|
|
@@ -771,6 +844,7 @@ declare function createClient(initialCfg: ClientConfig & {
|
|
|
771
844
|
updateInstruction(agentId: string, versionId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
|
|
772
845
|
deleteInstruction(agentId: string, versionId: string, instructionId: string): Promise<void>;
|
|
773
846
|
} & ((agentId: string) => ReturnType<typeof bindAgentVersions>);
|
|
847
|
+
blueprints: AgentBlueprintsApi$1 & ((agentId: string) => ReturnType<typeof bindAgentBlueprints>);
|
|
774
848
|
delete: (agent: string | AgentEntity) => Promise<void>;
|
|
775
849
|
list(options?: ListAgentsOptions): Promise<PaginatedResult<Omit<{
|
|
776
850
|
data: components["schemas"]["AgentSummary"][];
|
|
@@ -839,6 +913,7 @@ declare function createClient(initialCfg: ClientConfig & {
|
|
|
839
913
|
updateInstruction(agentId: string, versionId: string, instructionId: string, payload: UpdateInstructionRequest): Promise<Instruction>;
|
|
840
914
|
deleteInstruction(agentId: string, versionId: string, instructionId: string): Promise<void>;
|
|
841
915
|
} & ((agentId: string) => ReturnType<typeof bindAgentVersions>);
|
|
916
|
+
blueprints: AgentBlueprintsApi$1 & ((agentId: string) => ReturnType<typeof bindAgentBlueprints>);
|
|
842
917
|
delete: (agent: string | AgentEntity) => Promise<void>;
|
|
843
918
|
list(options?: ListAgentsOptions): Promise<PaginatedResult<Omit<{
|
|
844
919
|
data: components["schemas"]["AgentSummary"][];
|
|
@@ -899,4 +974,4 @@ declare function createHttp(cfg: ClientConfig & {
|
|
|
899
974
|
resolveApiKey: () => string;
|
|
900
975
|
};
|
|
901
976
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,95 +1,3 @@
|
|
|
1
|
-
// src/utils/pagination.ts
|
|
2
|
-
var toNumber = (value) => {
|
|
3
|
-
return typeof value === "number" ? value : void 0;
|
|
4
|
-
};
|
|
5
|
-
var toBoolean = (value) => {
|
|
6
|
-
return typeof value === "boolean" ? value : void 0;
|
|
7
|
-
};
|
|
8
|
-
function cloneOptions(options, overrides) {
|
|
9
|
-
return {
|
|
10
|
-
...options ?? {},
|
|
11
|
-
...overrides ?? {}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function normalizeMeta(meta) {
|
|
15
|
-
if (!meta) {
|
|
16
|
-
return void 0;
|
|
17
|
-
}
|
|
18
|
-
const metaRecord = meta;
|
|
19
|
-
return {
|
|
20
|
-
...metaRecord,
|
|
21
|
-
page: toNumber(metaRecord.page),
|
|
22
|
-
limit: toNumber(metaRecord.limit) ?? toNumber(metaRecord.pageSize),
|
|
23
|
-
total: toNumber(metaRecord.total) ?? toNumber(metaRecord.totalItems),
|
|
24
|
-
hasNext: toBoolean(metaRecord.hasNext),
|
|
25
|
-
hasPrevious: toBoolean(metaRecord.hasPrevious),
|
|
26
|
-
totalPages: toNumber(metaRecord.totalPages)
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function resolveHasNext(meta, limit) {
|
|
30
|
-
if (typeof meta?.hasNext === "boolean") {
|
|
31
|
-
return meta.hasNext;
|
|
32
|
-
}
|
|
33
|
-
if (typeof meta?.total === "number" && typeof meta?.page === "number" && typeof limit === "number") {
|
|
34
|
-
return meta.page * limit < meta.total;
|
|
35
|
-
}
|
|
36
|
-
if (typeof meta?.totalPages === "number" && typeof meta?.page === "number") {
|
|
37
|
-
return meta.page < meta.totalPages;
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
function resolveHasPrevious(meta) {
|
|
42
|
-
if (typeof meta?.hasPrevious === "boolean") {
|
|
43
|
-
return meta.hasPrevious;
|
|
44
|
-
}
|
|
45
|
-
if (typeof meta?.page === "number") {
|
|
46
|
-
return meta.page > 1;
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
function attachPaginator(response, fetchPage, options) {
|
|
51
|
-
const baseOptions = options ?? {};
|
|
52
|
-
const meta = normalizeMeta(response.meta);
|
|
53
|
-
const currentPage = typeof meta?.page === "number" ? meta.page : typeof baseOptions.page === "number" ? baseOptions.page : 1;
|
|
54
|
-
const currentLimit = typeof meta?.limit === "number" ? meta.limit : typeof baseOptions.limit === "number" ? baseOptions.limit : void 0;
|
|
55
|
-
const getNextResponse = async (page, overrides) => {
|
|
56
|
-
const nextOptions = cloneOptions(baseOptions, {
|
|
57
|
-
...overrides,
|
|
58
|
-
page
|
|
59
|
-
});
|
|
60
|
-
const nextResponse = await fetchPage(nextOptions);
|
|
61
|
-
return attachPaginator(nextResponse, fetchPage, nextOptions);
|
|
62
|
-
};
|
|
63
|
-
return Object.assign(response, {
|
|
64
|
-
async next() {
|
|
65
|
-
if (!resolveHasNext(meta, currentLimit)) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
return getNextResponse(currentPage + 1);
|
|
69
|
-
},
|
|
70
|
-
async prev() {
|
|
71
|
-
if (!resolveHasPrevious(meta)) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return getNextResponse(Math.max(1, currentPage - 1));
|
|
75
|
-
},
|
|
76
|
-
async page(pageNumber) {
|
|
77
|
-
if (typeof pageNumber !== "number" || Number.isNaN(pageNumber)) {
|
|
78
|
-
throw new TypeError("page(pageNumber) requires a numeric value.");
|
|
79
|
-
}
|
|
80
|
-
if (pageNumber < 1) {
|
|
81
|
-
throw new RangeError(
|
|
82
|
-
"Page numbers must be greater than or equal to 1."
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return getNextResponse(pageNumber);
|
|
86
|
-
},
|
|
87
|
-
async reload() {
|
|
88
|
-
return getNextResponse(currentPage);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
1
|
// src/errors.ts
|
|
94
2
|
var HttpError = class extends Error {
|
|
95
3
|
constructor(status, statusText, body, url) {
|
|
@@ -380,6 +288,149 @@ function getQueryBuilderString(value) {
|
|
|
380
288
|
return String(result);
|
|
381
289
|
}
|
|
382
290
|
|
|
291
|
+
// src/api/agent-blueprints.ts
|
|
292
|
+
function createAgentBlueprintsApi(cfg) {
|
|
293
|
+
const { base, doFetch } = createHttp(cfg);
|
|
294
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
295
|
+
const list = async (agentId, options = {}) => {
|
|
296
|
+
const query = serializeListOptions({ filter: options.filter });
|
|
297
|
+
const res = await doFetch(`${base}/v1/agents/${agentId}/blueprints`, {
|
|
298
|
+
method: "GET",
|
|
299
|
+
query
|
|
300
|
+
});
|
|
301
|
+
return res.json();
|
|
302
|
+
};
|
|
303
|
+
const get = async (agentId, versionId) => {
|
|
304
|
+
const res = await doFetch(
|
|
305
|
+
`${base}/v1/agents/${agentId}/versions/${versionId}/blueprint`,
|
|
306
|
+
{
|
|
307
|
+
method: "GET"
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
return res.json();
|
|
311
|
+
};
|
|
312
|
+
const create = async (agentId, versionId, payload) => {
|
|
313
|
+
const res = await doFetch(
|
|
314
|
+
`${base}/v1/agents/${agentId}/versions/${versionId}/blueprint`,
|
|
315
|
+
{
|
|
316
|
+
method: "POST",
|
|
317
|
+
body: JSON.stringify(payload),
|
|
318
|
+
headers: jsonHeaders
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
return res.json();
|
|
322
|
+
};
|
|
323
|
+
const update = async (agentId, versionId, payload) => {
|
|
324
|
+
const res = await doFetch(
|
|
325
|
+
`${base}/v1/agents/${agentId}/versions/${versionId}/blueprint`,
|
|
326
|
+
{
|
|
327
|
+
method: "PATCH",
|
|
328
|
+
body: JSON.stringify(payload),
|
|
329
|
+
headers: jsonHeaders
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
return res.json();
|
|
333
|
+
};
|
|
334
|
+
return {
|
|
335
|
+
list,
|
|
336
|
+
get,
|
|
337
|
+
create,
|
|
338
|
+
update
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// src/utils/pagination.ts
|
|
343
|
+
var toNumber = (value) => {
|
|
344
|
+
return typeof value === "number" ? value : void 0;
|
|
345
|
+
};
|
|
346
|
+
var toBoolean = (value) => {
|
|
347
|
+
return typeof value === "boolean" ? value : void 0;
|
|
348
|
+
};
|
|
349
|
+
function cloneOptions(options, overrides) {
|
|
350
|
+
return {
|
|
351
|
+
...options ?? {},
|
|
352
|
+
...overrides ?? {}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function normalizeMeta(meta) {
|
|
356
|
+
if (!meta) {
|
|
357
|
+
return void 0;
|
|
358
|
+
}
|
|
359
|
+
const metaRecord = meta;
|
|
360
|
+
return {
|
|
361
|
+
...metaRecord,
|
|
362
|
+
page: toNumber(metaRecord.page),
|
|
363
|
+
limit: toNumber(metaRecord.limit) ?? toNumber(metaRecord.pageSize),
|
|
364
|
+
total: toNumber(metaRecord.total) ?? toNumber(metaRecord.totalItems),
|
|
365
|
+
hasNext: toBoolean(metaRecord.hasNext),
|
|
366
|
+
hasPrevious: toBoolean(metaRecord.hasPrevious),
|
|
367
|
+
totalPages: toNumber(metaRecord.totalPages)
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function resolveHasNext(meta, limit) {
|
|
371
|
+
if (typeof meta?.hasNext === "boolean") {
|
|
372
|
+
return meta.hasNext;
|
|
373
|
+
}
|
|
374
|
+
if (typeof meta?.total === "number" && typeof meta?.page === "number" && typeof limit === "number") {
|
|
375
|
+
return meta.page * limit < meta.total;
|
|
376
|
+
}
|
|
377
|
+
if (typeof meta?.totalPages === "number" && typeof meta?.page === "number") {
|
|
378
|
+
return meta.page < meta.totalPages;
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
function resolveHasPrevious(meta) {
|
|
383
|
+
if (typeof meta?.hasPrevious === "boolean") {
|
|
384
|
+
return meta.hasPrevious;
|
|
385
|
+
}
|
|
386
|
+
if (typeof meta?.page === "number") {
|
|
387
|
+
return meta.page > 1;
|
|
388
|
+
}
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
function attachPaginator(response, fetchPage, options) {
|
|
392
|
+
const baseOptions = options ?? {};
|
|
393
|
+
const meta = normalizeMeta(response.meta);
|
|
394
|
+
const currentPage = typeof meta?.page === "number" ? meta.page : typeof baseOptions.page === "number" ? baseOptions.page : 1;
|
|
395
|
+
const currentLimit = typeof meta?.limit === "number" ? meta.limit : typeof baseOptions.limit === "number" ? baseOptions.limit : void 0;
|
|
396
|
+
const getNextResponse = async (page, overrides) => {
|
|
397
|
+
const nextOptions = cloneOptions(baseOptions, {
|
|
398
|
+
...overrides,
|
|
399
|
+
page
|
|
400
|
+
});
|
|
401
|
+
const nextResponse = await fetchPage(nextOptions);
|
|
402
|
+
return attachPaginator(nextResponse, fetchPage, nextOptions);
|
|
403
|
+
};
|
|
404
|
+
return Object.assign(response, {
|
|
405
|
+
async next() {
|
|
406
|
+
if (!resolveHasNext(meta, currentLimit)) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
return getNextResponse(currentPage + 1);
|
|
410
|
+
},
|
|
411
|
+
async prev() {
|
|
412
|
+
if (!resolveHasPrevious(meta)) {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
return getNextResponse(Math.max(1, currentPage - 1));
|
|
416
|
+
},
|
|
417
|
+
async page(pageNumber) {
|
|
418
|
+
if (typeof pageNumber !== "number" || Number.isNaN(pageNumber)) {
|
|
419
|
+
throw new TypeError("page(pageNumber) requires a numeric value.");
|
|
420
|
+
}
|
|
421
|
+
if (pageNumber < 1) {
|
|
422
|
+
throw new RangeError(
|
|
423
|
+
"Page numbers must be greater than or equal to 1."
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
return getNextResponse(pageNumber);
|
|
427
|
+
},
|
|
428
|
+
async reload() {
|
|
429
|
+
return getNextResponse(currentPage);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
383
434
|
// src/api/agent-instructions.ts
|
|
384
435
|
function createAgentInstructionsApi(cfg) {
|
|
385
436
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -670,6 +721,24 @@ var bindAgentVersions = (api, agentId) => ({
|
|
|
670
721
|
};
|
|
671
722
|
}
|
|
672
723
|
});
|
|
724
|
+
var bindAgentBlueprints = (api, agentId) => ({
|
|
725
|
+
list(opts) {
|
|
726
|
+
return api.list(agentId, opts);
|
|
727
|
+
},
|
|
728
|
+
version(versionId) {
|
|
729
|
+
return {
|
|
730
|
+
get() {
|
|
731
|
+
return api.get(agentId, versionId);
|
|
732
|
+
},
|
|
733
|
+
create(payload) {
|
|
734
|
+
return api.create(agentId, versionId, payload);
|
|
735
|
+
},
|
|
736
|
+
update(payload) {
|
|
737
|
+
return api.update(agentId, versionId, payload);
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
});
|
|
673
742
|
var createAgentEntity = (dto, options) => {
|
|
674
743
|
const {
|
|
675
744
|
instructionsApi,
|
|
@@ -677,6 +746,7 @@ var createAgentEntity = (dto, options) => {
|
|
|
677
746
|
phonesApi,
|
|
678
747
|
scheduleApi,
|
|
679
748
|
versionsApi,
|
|
749
|
+
blueprintsApi,
|
|
680
750
|
reload,
|
|
681
751
|
updateAgent,
|
|
682
752
|
deleteAgent
|
|
@@ -688,6 +758,7 @@ var createAgentEntity = (dto, options) => {
|
|
|
688
758
|
phones: bindAgentPhones(phonesApi, dto.agentId),
|
|
689
759
|
schedule: bindAgentSchedule(scheduleApi, dto.agentId),
|
|
690
760
|
versions: bindAgentVersions(versionsApi, dto.agentId),
|
|
761
|
+
blueprints: bindAgentBlueprints(blueprintsApi, dto.agentId),
|
|
691
762
|
async save(patch) {
|
|
692
763
|
return updateAgent(dto.agentId, patch);
|
|
693
764
|
},
|
|
@@ -770,6 +841,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
770
841
|
phonesApi: relatedApis.phonesApi,
|
|
771
842
|
scheduleApi: relatedApis.scheduleApi,
|
|
772
843
|
versionsApi: relatedApis.versionsApi,
|
|
844
|
+
blueprintsApi: relatedApis.blueprintsApi,
|
|
773
845
|
reload: async (agentId) => {
|
|
774
846
|
const latest = await getAgentDetail(agentId);
|
|
775
847
|
return wrapAgent(latest);
|
|
@@ -1021,13 +1093,15 @@ function createClient(initialCfg) {
|
|
|
1021
1093
|
const phonesApi = createAgentPhonesApi(runtimeCfg);
|
|
1022
1094
|
const scheduleApi = createAgentScheduleApi(runtimeCfg);
|
|
1023
1095
|
const versionsApi = createAgentVersionsApi(runtimeCfg);
|
|
1096
|
+
const blueprintsApi = createAgentBlueprintsApi(runtimeCfg);
|
|
1024
1097
|
const voicesApi = createVoicesApi(runtimeCfg);
|
|
1025
1098
|
const agentsApi = createAgentsApi(runtimeCfg, {
|
|
1026
1099
|
instructionsApi,
|
|
1027
1100
|
tagsApi,
|
|
1028
1101
|
phonesApi,
|
|
1029
1102
|
scheduleApi,
|
|
1030
|
-
versionsApi
|
|
1103
|
+
versionsApi,
|
|
1104
|
+
blueprintsApi
|
|
1031
1105
|
});
|
|
1032
1106
|
const instructionsNamespace = Object.assign(
|
|
1033
1107
|
(agentId) => bindAgentInstructions(instructionsApi, agentId),
|
|
@@ -1049,6 +1123,10 @@ function createClient(initialCfg) {
|
|
|
1049
1123
|
(agentId) => bindAgentVersions(versionsApi, agentId),
|
|
1050
1124
|
versionsApi
|
|
1051
1125
|
);
|
|
1126
|
+
const blueprintsNamespace = Object.assign(
|
|
1127
|
+
(agentId) => bindAgentBlueprints(blueprintsApi, agentId),
|
|
1128
|
+
blueprintsApi
|
|
1129
|
+
);
|
|
1052
1130
|
const apis = {
|
|
1053
1131
|
agents: {
|
|
1054
1132
|
...agentsApi,
|
|
@@ -1056,7 +1134,8 @@ function createClient(initialCfg) {
|
|
|
1056
1134
|
tags: tagsNamespace,
|
|
1057
1135
|
phones: phonesNamespace,
|
|
1058
1136
|
schedule: scheduleNamespace,
|
|
1059
|
-
versions: versionsNamespace
|
|
1137
|
+
versions: versionsNamespace,
|
|
1138
|
+
blueprints: blueprintsNamespace
|
|
1060
1139
|
},
|
|
1061
1140
|
workspaces: createWorkspacesApi(runtimeCfg),
|
|
1062
1141
|
tools: createToolsApi(runtimeCfg),
|
|
@@ -1107,11 +1186,13 @@ export {
|
|
|
1107
1186
|
HttpError,
|
|
1108
1187
|
NetworkError,
|
|
1109
1188
|
TimeoutError,
|
|
1189
|
+
bindAgentBlueprints,
|
|
1110
1190
|
bindAgentInstructions,
|
|
1111
1191
|
bindAgentPhones,
|
|
1112
1192
|
bindAgentSchedule,
|
|
1113
1193
|
bindAgentTags,
|
|
1114
1194
|
bindAgentVersions,
|
|
1195
|
+
createAgentBlueprintsApi,
|
|
1115
1196
|
createAgentEntity,
|
|
1116
1197
|
createAgentInstructionsApi,
|
|
1117
1198
|
createAgentPhonesApi,
|