@getsupervisor/agents-studio-sdk 1.41.2-patch.7 → 1.41.2-patch.9
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.cjs +40 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1136,7 +1136,8 @@ var createAgentEntity = (dto, options) => {
|
|
|
1136
1136
|
stageTriggersApi,
|
|
1137
1137
|
reload,
|
|
1138
1138
|
updateAgent,
|
|
1139
|
-
deleteAgent
|
|
1139
|
+
deleteAgent,
|
|
1140
|
+
cloneAgent
|
|
1140
1141
|
} = options;
|
|
1141
1142
|
const schedulesHelper = bindAgentSchedules(
|
|
1142
1143
|
scheduleApi,
|
|
@@ -1155,6 +1156,9 @@ var createAgentEntity = (dto, options) => {
|
|
|
1155
1156
|
async save(patch) {
|
|
1156
1157
|
return updateAgent(dto.agentId, patch);
|
|
1157
1158
|
},
|
|
1159
|
+
async clone(payload) {
|
|
1160
|
+
return cloneAgent(dto.agentId, payload);
|
|
1161
|
+
},
|
|
1158
1162
|
async delete() {
|
|
1159
1163
|
await deleteAgent(dto.agentId);
|
|
1160
1164
|
},
|
|
@@ -1180,6 +1184,22 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1180
1184
|
throw new WorkspaceNotSelectedError();
|
|
1181
1185
|
};
|
|
1182
1186
|
const jsonHeaders = { "content-type": "application/json" };
|
|
1187
|
+
const normalizeCloneSelection = (selection) => {
|
|
1188
|
+
if (!selection) {
|
|
1189
|
+
return [];
|
|
1190
|
+
}
|
|
1191
|
+
if (Array.isArray(selection)) {
|
|
1192
|
+
return selection;
|
|
1193
|
+
}
|
|
1194
|
+
return Object.entries(selection).filter(([, enabled]) => enabled).map(([component]) => component);
|
|
1195
|
+
};
|
|
1196
|
+
const buildCloneAgentRequest = (payload) => {
|
|
1197
|
+
const { clone, ...rest } = payload;
|
|
1198
|
+
return {
|
|
1199
|
+
...rest,
|
|
1200
|
+
clone: normalizeCloneSelection(clone)
|
|
1201
|
+
};
|
|
1202
|
+
};
|
|
1183
1203
|
const fetchAgentsPage = async (options = {}) => {
|
|
1184
1204
|
requireWorkspace();
|
|
1185
1205
|
const sanitizedOptions = {
|
|
@@ -1224,6 +1244,16 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1224
1244
|
});
|
|
1225
1245
|
return res.json();
|
|
1226
1246
|
};
|
|
1247
|
+
const cloneAgent = async (agentId, payload) => {
|
|
1248
|
+
requireWorkspace();
|
|
1249
|
+
const requestPayload = buildCloneAgentRequest(payload);
|
|
1250
|
+
const res = await doFetch(`${base}/agents/${agentId}/clone`, {
|
|
1251
|
+
method: "POST",
|
|
1252
|
+
body: JSON.stringify(requestPayload),
|
|
1253
|
+
headers: jsonHeaders
|
|
1254
|
+
});
|
|
1255
|
+
return res.json();
|
|
1256
|
+
};
|
|
1227
1257
|
const updateAgent = async (agentId, payload) => {
|
|
1228
1258
|
requireWorkspace();
|
|
1229
1259
|
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
@@ -1247,6 +1277,7 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1247
1277
|
list: listAgents,
|
|
1248
1278
|
get: getAgentDetail,
|
|
1249
1279
|
create: createAgent,
|
|
1280
|
+
clone: cloneAgent,
|
|
1250
1281
|
forkFromTemplate: forkAgentFromTemplate,
|
|
1251
1282
|
update: updateAgent,
|
|
1252
1283
|
delete: deleteAgent
|
|
@@ -1273,6 +1304,10 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1273
1304
|
},
|
|
1274
1305
|
deleteAgent: async (agentId) => {
|
|
1275
1306
|
await deleteAgent(agentId);
|
|
1307
|
+
},
|
|
1308
|
+
cloneAgent: async (agentId, payload) => {
|
|
1309
|
+
const cloned = await cloneAgent(agentId, payload);
|
|
1310
|
+
return wrapAgent(cloned);
|
|
1276
1311
|
}
|
|
1277
1312
|
});
|
|
1278
1313
|
return {
|
|
@@ -1298,6 +1333,10 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1298
1333
|
const detail = await createAgent(payload);
|
|
1299
1334
|
return wrapAgent(detail);
|
|
1300
1335
|
},
|
|
1336
|
+
async clone(agentId, payload) {
|
|
1337
|
+
const detail = await cloneAgent(agentId, payload);
|
|
1338
|
+
return wrapAgent(detail);
|
|
1339
|
+
},
|
|
1301
1340
|
async forkFromTemplate(payload) {
|
|
1302
1341
|
const detail = await forkAgentFromTemplate(payload);
|
|
1303
1342
|
return wrapAgent(detail);
|