@uipath/agent-sdk 0.1.2 → 0.2.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.js +0 -136
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -27017,141 +27017,6 @@ async function createApiClient(ApiClass, options) {
|
|
|
27017
27017
|
const config2 = await createAgentRuntimeConfig(options);
|
|
27018
27018
|
return new ApiClass(config2);
|
|
27019
27019
|
}
|
|
27020
|
-
// src/scripts/generate-sdk.ts
|
|
27021
|
-
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
27022
|
-
import { mkdir as mkdir2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
27023
|
-
import { join as join2 } from "node:path";
|
|
27024
|
-
var SWAGGER_URL = "https://alpha.uipath.com/uipattycyrhx/abizon_1/agentsruntime_/swagger/v1/swagger.json";
|
|
27025
|
-
var OUTPUT_DIR = join2(process.cwd(), "generated");
|
|
27026
|
-
var TEMP_DIR = join2(process.cwd(), "temp");
|
|
27027
|
-
var SWAGGER_DIR = join2(process.cwd(), "swagger");
|
|
27028
|
-
var ALLOWED_PATHS = [
|
|
27029
|
-
"/api/execution/agents/{agentId}/evalSetRuns",
|
|
27030
|
-
"/api/execution/agents/{agentId}/evalSets/{evalSetId}/evalSetRuns",
|
|
27031
|
-
"/api/execution/agents/{agentId}/evalSets/{evalSetId}/evalSetRuns/{evalSetRunId}",
|
|
27032
|
-
"/api/execution/agents/{agentId}/evalSets/{evalSetId}/evalSetRuns/{evalSetRunId}/evalRuns",
|
|
27033
|
-
"/api/execution/agents/{agentId}/evalSets/{evalSetId}/startMultipleEvaluators",
|
|
27034
|
-
"/api/designer/{tenantId}/resources/models"
|
|
27035
|
-
];
|
|
27036
|
-
async function downloadSwagger() {
|
|
27037
|
-
console.log("Downloading swagger.json...");
|
|
27038
|
-
const response = await fetch(SWAGGER_URL);
|
|
27039
|
-
if (!response.ok) {
|
|
27040
|
-
throw new Error(`Failed to download swagger: ${response.statusText}`);
|
|
27041
|
-
}
|
|
27042
|
-
return await response.json();
|
|
27043
|
-
}
|
|
27044
|
-
function filterSwaggerPaths(swagger) {
|
|
27045
|
-
const paths = swagger.paths;
|
|
27046
|
-
const filteredPaths = {};
|
|
27047
|
-
for (const [path3, methods] of Object.entries(paths)) {
|
|
27048
|
-
if (ALLOWED_PATHS.includes(path3)) {
|
|
27049
|
-
filteredPaths[path3] = methods;
|
|
27050
|
-
console.log(`Including path: ${path3}`);
|
|
27051
|
-
}
|
|
27052
|
-
}
|
|
27053
|
-
console.log(`
|
|
27054
|
-
Filtered ${Object.keys(filteredPaths).length} paths from ${Object.keys(paths).length} total`);
|
|
27055
|
-
return { ...swagger, paths: filteredPaths };
|
|
27056
|
-
}
|
|
27057
|
-
function collectReferencedSchemas(swagger, paths) {
|
|
27058
|
-
const referenced = new Set;
|
|
27059
|
-
const schemas3 = swagger.components?.schemas;
|
|
27060
|
-
const refPattern = /#\/(components\/schemas|definitions)\/(.+)/;
|
|
27061
|
-
const findRefs = (obj) => {
|
|
27062
|
-
if (!obj || typeof obj !== "object")
|
|
27063
|
-
return;
|
|
27064
|
-
const record2 = obj;
|
|
27065
|
-
if ("$ref" in record2 && typeof record2.$ref === "string") {
|
|
27066
|
-
const match = record2.$ref.match(refPattern);
|
|
27067
|
-
if (match?.[2]) {
|
|
27068
|
-
const schemaName = match[2];
|
|
27069
|
-
if (!referenced.has(schemaName)) {
|
|
27070
|
-
referenced.add(schemaName);
|
|
27071
|
-
if (schemas3?.[schemaName]) {
|
|
27072
|
-
findRefs(schemas3[schemaName]);
|
|
27073
|
-
}
|
|
27074
|
-
}
|
|
27075
|
-
}
|
|
27076
|
-
}
|
|
27077
|
-
if (Array.isArray(obj)) {
|
|
27078
|
-
for (const item of obj) {
|
|
27079
|
-
findRefs(item);
|
|
27080
|
-
}
|
|
27081
|
-
} else {
|
|
27082
|
-
for (const val of Object.values(record2)) {
|
|
27083
|
-
findRefs(val);
|
|
27084
|
-
}
|
|
27085
|
-
}
|
|
27086
|
-
};
|
|
27087
|
-
for (const methods of Object.values(paths)) {
|
|
27088
|
-
for (const operation of Object.values(methods)) {
|
|
27089
|
-
if (typeof operation === "object" && operation !== null) {
|
|
27090
|
-
findRefs(operation);
|
|
27091
|
-
}
|
|
27092
|
-
}
|
|
27093
|
-
}
|
|
27094
|
-
return referenced;
|
|
27095
|
-
}
|
|
27096
|
-
function filterUnusedSchemas(swagger) {
|
|
27097
|
-
const components = swagger.components;
|
|
27098
|
-
const allSchemas = components?.schemas ?? {};
|
|
27099
|
-
const referencedSchemas = collectReferencedSchemas(swagger, swagger.paths);
|
|
27100
|
-
const filteredSchemas = {};
|
|
27101
|
-
console.log(`
|
|
27102
|
-
Found ${referencedSchemas.size} referenced schemas out of ${Object.keys(allSchemas).length} total`);
|
|
27103
|
-
for (const schemaName of referencedSchemas) {
|
|
27104
|
-
if (allSchemas[schemaName]) {
|
|
27105
|
-
filteredSchemas[schemaName] = allSchemas[schemaName];
|
|
27106
|
-
console.log(`Including schema: ${schemaName}`);
|
|
27107
|
-
}
|
|
27108
|
-
}
|
|
27109
|
-
return {
|
|
27110
|
-
...swagger,
|
|
27111
|
-
components: { ...components, schemas: filteredSchemas }
|
|
27112
|
-
};
|
|
27113
|
-
}
|
|
27114
|
-
async function generateClient(filteredSwagger) {
|
|
27115
|
-
console.log(`
|
|
27116
|
-
Generating TypeScript client...`);
|
|
27117
|
-
await rm2(TEMP_DIR, { recursive: true, force: true });
|
|
27118
|
-
await rm2(OUTPUT_DIR, { recursive: true, force: true });
|
|
27119
|
-
await mkdir2(TEMP_DIR, { recursive: true });
|
|
27120
|
-
await mkdir2(OUTPUT_DIR, { recursive: true });
|
|
27121
|
-
const swaggerPath = join2(TEMP_DIR, "filtered-swagger.json");
|
|
27122
|
-
await writeFile2(swaggerPath, JSON.stringify(filteredSwagger, null, 2));
|
|
27123
|
-
execFileSync3("npx", [
|
|
27124
|
-
"@openapitools/openapi-generator-cli",
|
|
27125
|
-
"generate",
|
|
27126
|
-
"-i",
|
|
27127
|
-
swaggerPath,
|
|
27128
|
-
"-g",
|
|
27129
|
-
"typescript-fetch",
|
|
27130
|
-
"-o",
|
|
27131
|
-
OUTPUT_DIR,
|
|
27132
|
-
"--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=@uipath/agent-sdk"
|
|
27133
|
-
], { stdio: "inherit" });
|
|
27134
|
-
console.log("Client generated successfully!");
|
|
27135
|
-
}
|
|
27136
|
-
async function main() {
|
|
27137
|
-
try {
|
|
27138
|
-
const swagger = await downloadSwagger();
|
|
27139
|
-
const filteredPaths = filterSwaggerPaths(swagger);
|
|
27140
|
-
const filtered = filterUnusedSchemas(filteredPaths);
|
|
27141
|
-
await mkdir2(SWAGGER_DIR, { recursive: true });
|
|
27142
|
-
await writeFile2(join2(SWAGGER_DIR, "swagger.json"), JSON.stringify(swagger, null, 2));
|
|
27143
|
-
await writeFile2(join2(SWAGGER_DIR, "filtered-swagger.json"), JSON.stringify(filtered, null, 2));
|
|
27144
|
-
await generateClient(filtered);
|
|
27145
|
-
await rm2(TEMP_DIR, { recursive: true, force: true });
|
|
27146
|
-
console.log(`
|
|
27147
|
-
Generated SDK available in: ${OUTPUT_DIR}`);
|
|
27148
|
-
console.log(`Reference files saved in: ${SWAGGER_DIR}`);
|
|
27149
|
-
} catch (error48) {
|
|
27150
|
-
console.error("Error generating SDK:", error48);
|
|
27151
|
-
process.exit(1);
|
|
27152
|
-
}
|
|
27153
|
-
}
|
|
27154
|
-
if (false) {}
|
|
27155
27020
|
// src/types.ts
|
|
27156
27021
|
var ProjectFilesSource2 = {
|
|
27157
27022
|
Cloud: 0,
|
|
@@ -27234,7 +27099,6 @@ export {
|
|
|
27234
27099
|
instanceOfAgentGuardrailPolicy,
|
|
27235
27100
|
instanceOfAgentDefinition,
|
|
27236
27101
|
instanceOfAgentAppearance,
|
|
27237
|
-
main as generateSdk,
|
|
27238
27102
|
exists,
|
|
27239
27103
|
createApiClient,
|
|
27240
27104
|
createAgentRuntimeConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/agent-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "SDK for the UiPath Agent Runtime API — evaluation execution and debug sessions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"lint": "biome check ."
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@openapitools/openapi-generator-cli": "^2.
|
|
33
|
+
"@openapitools/openapi-generator-cli": "^2.31.1",
|
|
34
34
|
"@types/node": "^25.5.0",
|
|
35
|
-
"@uipath/auth": "0.
|
|
35
|
+
"@uipath/auth": "0.2.0",
|
|
36
36
|
"typescript": "^5"
|
|
37
37
|
}
|
|
38
38
|
}
|