UNPKG

genkit-cli

Version:

CLI for interacting with the Google Genkit AI framework

65 lines (64 loc) 2.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defineRuntimeTools = defineRuntimeTools; const utils_1 = require("@genkit-ai/tools-common/utils"); const zod_1 = require("zod"); const analytics_js_1 = require("./analytics.js"); function defineRuntimeTools(server, manager) { server.registerTool('start_runtime', { title: 'Starts a Genkit runtime process', description: `Use this to start a Genkit runtime process (This is typically the entry point to the users app). Once started, the runtime will be picked up by the \`genkit start\` command to power the Dev UI features like model and flow playgrounds. The inputSchema for this tool matches the function prototype for \`NodeJS.child_process.spawn\`. Examples: {command: 'go', args: ['run', 'main.go']} {command: 'npm', args: ['run', 'dev']}`, inputSchema: { command: zod_1.z.string(), args: zod_1.z.array(zod_1.z.string()), }, }, async ({ command, args }) => { await (0, utils_1.record)(new analytics_js_1.McpRunToolEvent('start_runtime')); await manager.getManagerWithDevProcess(command, args); return { content: [{ type: 'text', text: `Done.` }], }; }); server.registerTool('kill_runtime', { title: 'Kills any existing Genkit runtime process', description: 'Use this to stop an existing runtime that was started using the `start_runtime` tool', }, async () => { await (0, utils_1.record)(new analytics_js_1.McpRunToolEvent('kill_runtime')); const runtimeManager = await manager.getManager(); if (!runtimeManager.processManager) { return { isError: true, content: [ { type: 'text', text: `No runtime process currently running.` }, ], }; } await runtimeManager.processManager?.kill(); return { content: [{ type: 'text', text: `Done.` }], }; }); server.registerTool('restart_runtime', { title: 'Restarts any existing Genkit runtime process', description: 'Use this to restart an existing runtime that was started using the `start_runtime` tool', }, async () => { await (0, utils_1.record)(new analytics_js_1.McpRunToolEvent('restart_runtime')); const runtimeManager = await manager.getManager(); if (!runtimeManager.processManager) { return { isError: true, content: [ { type: 'text', text: `No runtime process currently running.` }, ], }; } await runtimeManager.processManager?.restart(); return { content: [{ type: 'text', text: `Done.` }], }; }); } //# sourceMappingURL=runtime.js.map