Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This is an experimental project intended to demonstrate JFrog's capabilities wit
- **Artifact Search**: Execute powerful AQL queries to search for artifacts and builds
- **Catalog and Curation**: Access package information, versions, vulnerabilities, and check curation status
- **Xray**: Access scan artifacts summary, group by severity per artifact
- **Workers**: Access all workers

## Tools

Expand Down
35 changes: 35 additions & 0 deletions schemas/workers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { z } from "zod";

export const JFrogWorkerReadinessSchema = z.object({
code: z.string(),
});

export const WorkersList = z.object({
workers: z.array(
z.object({
key: z.string(),
application: z.string(),
description: z.string(),
enabled: z.boolean(),
sourceCode: z.string(),
action: z.string(),
filterCriteria: z
.object({
artifactFilterCriteria: z.object({
repoKeys: z.array(z.string()),
}),
})
.optional(),
secrets: z.array(z.any()).optional(),
shared: z.boolean(),
debug: z.boolean(),
projectKey: z.string().optional(),
currentVersion: z
.object({
modifiedAt: z.number(),
modifiedBy: z.string(),
})
.optional(),
})
),
});
2 changes: 2 additions & 0 deletions tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CatalogTools } from "./catalog.js";
import { CurationTools } from "./curation.js";
import { PermissionsTools } from "./permissions.js";
import { ArtifactSecurityTools } from "./security.js";
import { WorkerTools } from "./worker.js";

export const tools =[
...RepositoryTools,
Expand All @@ -20,6 +21,7 @@ export const tools =[
...CurationTools,
...PermissionsTools,
...ArtifactSecurityTools,
...WorkerTools
];

// A function that given a tool name, executes the handler with the arguments and returns the result
Expand Down
46 changes: 46 additions & 0 deletions tools/worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";
import { jfrogRequest } from "../common/utils.js";
import { JFrogWorkerReadinessSchema } from "../schemas/workers.js";
import { WorkersList } from "../schemas/workers.js";

async function fetchWorkersList() {
const response = await jfrogRequest("/worker/api/v1/workers", {
method: "GET",
});

return WorkersList.parse(response);
}

async function checkWorkerReadiness() {
const response = await jfrogRequest("/worker/api/v1/system/liveness", {
method: "GET",
});

return JFrogWorkerReadinessSchema.parse(response);
}

const getWorkerLiveliness = {
name: "jfrog_get_worker_liveliness",
description: "Useful for checking the liveliness of a worker status. Returns OK when the worker is alive.",
inputSchema: zodToJsonSchema(z.object({})),
outputSchema: zodToJsonSchema(JFrogWorkerReadinessSchema),
handler: async () => {
return await checkWorkerReadiness();
}
};

const getWorkerList = {
name: "jfrog_get_worker_list",
description: "Useful for getting the list of workers.",
inputSchema: zodToJsonSchema(z.object({})),
outputSchema: zodToJsonSchema(WorkersList),
handler: async () => {
return await fetchWorkersList();
}
};

export const WorkerTools = [
getWorkerLiveliness,
getWorkerList
];