hevy-mcp 1.14.0 → 1.14.1

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/cli.js CHANGED
@@ -11,7 +11,7 @@ import { z as z6 } from "zod";
11
11
 
12
12
  // package.json
13
13
  var name = "hevy-mcp";
14
- var version = "1.13.2";
14
+ var version = "1.14.0";
15
15
 
16
16
  // src/tools/folders.ts
17
17
  import { z } from "zod";
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../package.json","../src/tools/folders.ts","../src/utils/error-handler.ts","../src/utils/formatters.ts","../src/utils/response-formatter.ts","../src/tools/routines.ts","../src/tools/templates.ts","../src/tools/webhooks.ts","../src/tools/workouts.ts","../src/utils/config.ts","../src/utils/hevyClientKubb.ts","../src/generated/client/api/deleteV1WebhookSubscription.ts","../src/generated/client/api/getV1ExerciseTemplates.ts","../src/generated/client/api/getV1ExerciseTemplatesExercisetemplateid.ts","../src/generated/client/api/getV1RoutineFolders.ts","../src/generated/client/api/getV1RoutineFoldersFolderid.ts","../src/generated/client/api/getV1Routines.ts","../src/generated/client/api/getV1RoutinesRoutineid.ts","../src/generated/client/api/getV1WebhookSubscription.ts","../src/generated/client/api/getV1Workouts.ts","../src/generated/client/api/getV1WorkoutsCount.ts","../src/generated/client/api/getV1WorkoutsEvents.ts","../src/generated/client/api/getV1WorkoutsWorkoutid.ts","../src/generated/client/api/postV1RoutineFolders.ts","../src/generated/client/api/postV1Routines.ts","../src/generated/client/api/postV1WebhookSubscription.ts","../src/generated/client/api/postV1Workouts.ts","../src/generated/client/api/putV1RoutinesRoutineid.ts","../src/generated/client/api/putV1WorkoutsWorkoutid.ts","../src/utils/hevyClient.ts","../src/cli.ts"],"sourcesContent":["import dotenvx from \"@dotenvx/dotenvx\";\nimport * as Sentry from \"@sentry/node\";\n\n// Configure dotenvx with quiet mode to prevent stdout pollution in stdio mode\ndotenvx.config({ quiet: true });\n\n// Sentry monitoring is baked into the built MCP server so usage and errors\n// from users of the published package are captured for observability.\nconst sentryConfig = {\n\tdsn: \"https://ce696d8333b507acbf5203eb877bce0f@o4508975499575296.ingest.de.sentry.io/4509049671647312\",\n\t// Tracing must be enabled for MCP monitoring to work\n\ttracesSampleRate: 1.0,\n\tsendDefaultPii: false,\n} as const;\n\nSentry.init(sentryConfig);\n\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { z } from \"zod\";\nimport { name, version } from \"../package.json\";\nimport { registerFolderTools } from \"./tools/folders.js\";\nimport { registerRoutineTools } from \"./tools/routines.js\";\nimport { registerTemplateTools } from \"./tools/templates.js\";\nimport { registerWebhookTools } from \"./tools/webhooks.js\";\nimport { registerWorkoutTools } from \"./tools/workouts.js\";\nimport { assertApiKey, parseConfig } from \"./utils/config.js\";\nimport { createClient } from \"./utils/hevyClient.js\";\n\nconst HEVY_API_BASEURL = \"https://api.hevyapp.com\";\n\nconst serverConfigSchema = z.object({\n\tapiKey: z\n\t\t.string()\n\t\t.min(1, \"Hevy API key is required\")\n\t\t.describe(\"Your Hevy API key (available in the Hevy app settings).\"),\n});\n\nexport const configSchema = serverConfigSchema;\ntype ServerConfig = z.infer<typeof serverConfigSchema>;\n\nfunction buildServer(apiKey: string) {\n\tconst baseServer = new McpServer({\n\t\tname,\n\t\tversion,\n\t});\n\tconst server = Sentry.wrapMcpServerWithSentry(baseServer);\n\n\tconst hevyClient = createClient(apiKey, HEVY_API_BASEURL);\n\tconsole.error(\"Hevy client initialized with API key\");\n\n\tregisterWorkoutTools(server, hevyClient);\n\tregisterRoutineTools(server, hevyClient);\n\tregisterTemplateTools(server, hevyClient);\n\tregisterFolderTools(server, hevyClient);\n\tregisterWebhookTools(server, hevyClient);\n\n\treturn server;\n}\n\nexport default function createServer({ config }: { config: ServerConfig }) {\n\tconst { apiKey } = serverConfigSchema.parse(config);\n\tconst server = buildServer(apiKey);\n\treturn server.server;\n}\n\nexport async function runServer() {\n\tconst args = process.argv.slice(2);\n\tconst cfg = parseConfig(args, process.env);\n\tconst apiKey = cfg.apiKey;\n\tassertApiKey(apiKey);\n\n\tconst server = buildServer(apiKey);\n\tconsole.error(\"Starting MCP server in stdio mode\");\n\tconst transport = new StdioServerTransport();\n\tawait server.connect(transport);\n}\n","{\n\t\"name\": \"hevy-mcp\",\n\t\"version\": \"1.13.2\",\n\t\"main\": \"dist/index.js\",\n\t\"module\": \"src/index.ts\",\n\t\"types\": \"dist/index.d.ts\",\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"README.md\"\n\t],\n\t\"access\": \"public\",\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/chrisdoc/hevy-mcp/issues\"\n\t},\n\t\"homepage\": \"https://github.com/chrisdoc/hevy-mcp#readme\",\n\t\"bin\": {\n\t\t\"hevy-mcp\": \"dist/cli.js\"\n\t},\n\t\"scripts\": {\n\t\t\"inspect\": \"pnpm run build && dotenvx run -- pnpm dlx @modelcontextprotocol/inspector@latest node dist/index.js\",\n\t\t\"inspect:npm\": \"dotenvx run -- pnpm dlx @modelcontextprotocol/inspector@latest pnpm dlx hevy-mcp@latest\",\n\t\t\"test\": \"vitest --run\",\n\t\t\"export-specs\": \"node ./scripts/export-openapi-spec.js\",\n\t\t\"build\": \"tsup\",\n\t\t\"build:client\": \"kubb generate\",\n\t\t\"start\": \"node dist/cli.js\",\n\t\t\"dev\": \"tsx watch --clear-screen=false src/cli.ts\",\n\t\t\"smithery:build\": \"smithery build\",\n\t\t\"smithery:dev\": \"smithery dev\",\n\t\t\"check\": \"biome check --write --unsafe\",\n\t\t\"check:types\": \"tsc --noEmit\",\n\t\t\"version:patch\": \"pnpm version patch\",\n\t\t\"version:minor\": \"pnpm version minor\",\n\t\t\"version:major\": \"pnpm version major\",\n\t\t\"release\": \"semantic-release\",\n\t\t\"commit\": \"commit\"\n\t},\n\t\"type\": \"module\",\n\t\"keywords\": [\n\t\t\"mcp\",\n\t\t\"hevy\",\n\t\t\"fitness\",\n\t\t\"api\",\n\t\t\"model context protocol\"\n\t],\n\t\"author\": \"Christoph Kieslich\",\n\t\"license\": \"MIT\",\n\t\"description\": \"A Model Context Protocol (MCP) server implementation that interfaces with the Hevy fitness tracking app and its API.\",\n\t\"dependencies\": {\n\t\t\"@dotenvx/dotenvx\": \"^1.51.1\",\n\t\t\"@kubb/cli\": \"^4.7.2\",\n\t\t\"@kubb/core\": \"^4.7.2\",\n\t\t\"@kubb/plugin-client\": \"^4.7.2\",\n\t\t\"@kubb/plugin-faker\": \"^4.7.2\",\n\t\t\"@kubb/plugin-oas\": \"^4.7.2\",\n\t\t\"@kubb/plugin-ts\": \"^4.7.2\",\n\t\t\"@kubb/plugin-zod\": \"^4.7.2\",\n\t\t\"@modelcontextprotocol/sdk\": \"^1.23.0\",\n\t\t\"@sentry/node\": \"^9.47.1\",\n\t\t\"@smithery/sdk\": \"2.1.0\",\n\t\t\"axios\": \"^1.13.2\",\n\t\t\"chalk\": \"^5.6.2\",\n\t\t\"cors\": \"^2.8.5\",\n\t\t\"express\": \"5.2.1\",\n\t\t\"zod\": \"^4.1.13\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@biomejs/biome\": \"2.3.8\",\n\t\t\"@commitlint/cli\": \"^20.1.0\",\n\t\t\"@commitlint/config-conventional\": \"^20.0.0\",\n\t\t\"@commitlint/prompt-cli\": \"^20.1.0\",\n\t\t\"@semantic-release/changelog\": \"^6.0.3\",\n\t\t\"@semantic-release/commit-analyzer\": \"^13.0.1\",\n\t\t\"@semantic-release/git\": \"^10.0.1\",\n\t\t\"@semantic-release/github\": \"^12.0.2\",\n\t\t\"@semantic-release/npm\": \"^13.1.2\",\n\t\t\"@semantic-release/release-notes-generator\": \"^14.1.0\",\n\t\t\"@smithery/cli\": \"^1.6.3\",\n\t\t\"@types/node\": \"^24.10.1\",\n\t\t\"@vitest/coverage-v8\": \"^4.0.14\",\n\t\t\"abstract-syntax-tree\": \"^2.22.0\",\n\t\t\"cross-env\": \"^10.1.0\",\n\t\t\"lefthook\": \"^2.0.4\",\n\t\t\"semantic-release\": \"^25.0.2\",\n\t\t\"tsup\": \"^8.5.1\",\n\t\t\"tsx\": \"^4.20.6\",\n\t\t\"typescript\": \"^5.9.3\",\n\t\t\"vitest\": \"^4.0.14\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=20.0.0\"\n\t},\n\t\"packageManager\": \"pnpm@10.22.0+sha512.bf049efe995b28f527fd2b41ae0474ce29186f7edcb3bf545087bd61fbbebb2bf75362d1307fda09c2d288e1e499787ac12d4fcb617a974718a6051f2eee741c\"\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\n// Import types from generated client\nimport type { RoutineFolder } from \"../generated/client/types/index.js\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport { formatRoutineFolder } from \"../utils/formatters.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\n// Type definitions for the folder operations\ntype HevyClient = ReturnType<\n\ttypeof import(\"../utils/hevyClientKubb.js\").createClient\n>;\n\n/**\n * Register all routine folder-related tools with the MCP server\n */\nexport function registerFolderTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get routine folders\n\tconst getRoutineFoldersSchema = {\n\t\tpage: z.coerce.number().int().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(10).default(5),\n\t} as const;\n\ttype GetRoutineFoldersParams = InferToolParams<\n\t\ttypeof getRoutineFoldersSchema\n\t>;\n\n\tserver.tool(\n\t\t\"get-routine-folders\",\n\t\t\"Get a paginated list of your routine folders, including both default and custom folders. Useful for organizing and browsing your workout routines.\",\n\t\tgetRoutineFoldersSchema,\n\t\twithErrorHandling(async (args: GetRoutineFoldersParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize } = args;\n\t\t\tconst data = await hevyClient.getRoutineFolders({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t});\n\n\t\t\t// Process routine folders to extract relevant information\n\t\t\tconst folders =\n\t\t\t\tdata?.routine_folders?.map((folder: RoutineFolder) =>\n\t\t\t\t\tformatRoutineFolder(folder),\n\t\t\t\t) || [];\n\n\t\t\tif (folders.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No routine folders found for the specified parameters\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(folders);\n\t\t}, \"get-routine-folders\"),\n\t);\n\n\t// Get single routine folder by ID\n\tconst getRoutineFolderSchema = {\n\t\tfolderId: z.string().min(1),\n\t} as const;\n\ttype GetRoutineFolderParams = InferToolParams<typeof getRoutineFolderSchema>;\n\n\tserver.tool(\n\t\t\"get-routine-folder\",\n\t\t\"Get complete details of a specific routine folder by its ID, including name, creation date, and associated routines.\",\n\t\tgetRoutineFolderSchema,\n\t\twithErrorHandling(async (args: GetRoutineFolderParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { folderId } = args;\n\t\t\tconst data = await hevyClient.getRoutineFolder(folderId);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`Routine folder with ID ${folderId} not found`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst folder = formatRoutineFolder(data);\n\t\t\treturn createJsonResponse(folder);\n\t\t}, \"get-routine-folder\"),\n\t);\n\n\t// Create new routine folder\n\tconst createRoutineFolderSchema = {\n\t\tname: z.string().min(1),\n\t} as const;\n\ttype CreateRoutineFolderParams = InferToolParams<\n\t\ttypeof createRoutineFolderSchema\n\t>;\n\n\tserver.tool(\n\t\t\"create-routine-folder\",\n\t\t\"Create a new routine folder in your Hevy account. Requires a name for the folder. Returns the full folder details including the new folder ID.\",\n\t\tcreateRoutineFolderSchema,\n\t\twithErrorHandling(async (args: CreateRoutineFolderParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { name } = args;\n\t\t\tconst data = await hevyClient.createRoutineFolder({\n\t\t\t\troutine_folder: {\n\t\t\t\t\ttitle: name,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to create routine folder: Server returned no data\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst folder = formatRoutineFolder(data);\n\t\t\treturn createJsonResponse(folder, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"create-routine-folder\"),\n\t);\n}\n","/**\n * Centralized error handling utility for MCP tools\n */\n\n// Import the McpToolResponse type from response-formatter to ensure consistency\nimport type { McpToolResponse } from \"./response-formatter.js\";\n\n/**\n * Standard error response interface\n */\nexport interface ErrorResponse {\n\tmessage: string;\n\tcode?: string;\n\tdetails?: unknown;\n}\n\n/**\n * Specific error types for better categorization\n */\nexport enum ErrorType {\n\tAPI_ERROR = \"API_ERROR\",\n\tVALIDATION_ERROR = \"VALIDATION_ERROR\",\n\tNOT_FOUND = \"NOT_FOUND\",\n\tNETWORK_ERROR = \"NETWORK_ERROR\",\n\tUNKNOWN_ERROR = \"UNKNOWN_ERROR\",\n}\n\n/**\n * Enhanced error response with type categorization\n */\nexport interface EnhancedErrorResponse extends ErrorResponse {\n\ttype: ErrorType;\n}\n\n/**\n * Create a standardized error response for MCP tools\n *\n * @param error - The error object or message\n * @param context - Optional context information about where the error occurred\n * @returns A formatted MCP tool response with error information\n */\nexport function createErrorResponse(\n\terror: unknown,\n\tcontext?: string,\n): McpToolResponse {\n\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t// Extract error code if available (for logging purposes)\n\tconst errorCode =\n\t\terror instanceof Error && \"code\" in error\n\t\t\t? (error as { code?: string }).code\n\t\t\t: undefined;\n\n\t// Determine error type based on error characteristics\n\tconst errorType = determineErrorType(error, errorMessage);\n\n\t// Include error code in logs if available\n\tif (errorCode) {\n\t\tconsole.debug(`Error code: ${errorCode}`);\n\t}\n\n\tconst contextPrefix = context ? `[${context}] ` : \"\";\n\tconst formattedMessage = `${contextPrefix}Error: ${errorMessage}`;\n\n\t// Log the error for server-side debugging with type information\n\tconsole.error(`${formattedMessage} (Type: ${errorType})`, error);\n\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\" as const,\n\t\t\t\ttext: formattedMessage,\n\t\t\t},\n\t\t],\n\t\tisError: true,\n\t};\n}\n\n/**\n * Determine the type of error based on error characteristics\n */\nfunction determineErrorType(error: unknown, message: string): ErrorType {\n\tconst messageLower = message.toLowerCase();\n\tconst nameLower = error instanceof Error ? error.name.toLowerCase() : \"\";\n\n\tif (\n\t\tnameLower.includes(\"network\") ||\n\t\tmessageLower.includes(\"network\") ||\n\t\tnameLower.includes(\"fetch\") ||\n\t\tmessageLower.includes(\"fetch\") ||\n\t\tnameLower.includes(\"timeout\") ||\n\t\tmessageLower.includes(\"timeout\")\n\t) {\n\t\treturn ErrorType.NETWORK_ERROR;\n\t}\n\n\tif (\n\t\tnameLower.includes(\"validation\") ||\n\t\tmessageLower.includes(\"validation\") ||\n\t\tmessageLower.includes(\"invalid\") ||\n\t\tmessageLower.includes(\"required\")\n\t) {\n\t\treturn ErrorType.VALIDATION_ERROR;\n\t}\n\n\tif (\n\t\tmessageLower.includes(\"not found\") ||\n\t\tmessageLower.includes(\"404\") ||\n\t\tmessageLower.includes(\"does not exist\")\n\t) {\n\t\treturn ErrorType.NOT_FOUND;\n\t}\n\n\tif (\n\t\tnameLower.includes(\"api\") ||\n\t\tmessageLower.includes(\"api\") ||\n\t\tmessageLower.includes(\"server error\") ||\n\t\tmessageLower.includes(\"500\")\n\t) {\n\t\treturn ErrorType.API_ERROR;\n\t}\n\n\treturn ErrorType.UNKNOWN_ERROR;\n}\n\n/**\n * Wrap an async function with standardized error handling\n *\n * This function preserves the parameter types of the wrapped function while\n * providing error handling. The returned function accepts Record<string, unknown>\n * (as required by MCP SDK) but internally casts to the original parameter type.\n *\n * @param fn - The async function to wrap\n * @param context - Context information for error messages\n * @returns A function that catches errors and returns standardized error responses\n */\nexport function withErrorHandling<TParams extends Record<string, unknown>>(\n\tfn: (args: TParams) => Promise<McpToolResponse>,\n\tcontext: string,\n): (args: Record<string, unknown>) => Promise<McpToolResponse> {\n\treturn async (args: Record<string, unknown>) => {\n\t\ttry {\n\t\t\treturn await fn(args as TParams);\n\t\t} catch (error) {\n\t\t\treturn createErrorResponse(error, context);\n\t\t}\n\t};\n}\n","import type {\n\tExerciseTemplate,\n\tRoutine,\n\tRoutineFolder,\n\tWorkout,\n} from \"../generated/client/types/index.js\";\n\n/**\n * Formatted workout set interface\n */\nexport interface FormattedWorkoutSet {\n\tindex: number | undefined;\n\ttype: string | undefined;\n\tweight: number | undefined | null;\n\treps: number | undefined | null;\n\tdistance: number | undefined | null;\n\tduration: number | undefined | null;\n\trpe: number | undefined | null;\n\tcustomMetric: number | undefined | null;\n}\n\n/**\n * Formatted workout exercise interface\n */\nexport interface FormattedWorkoutExercise {\n\tindex: number | undefined;\n\tname: string | undefined;\n\texerciseTemplateId: string | undefined;\n\tnotes: string | undefined | null;\n\tsupersetsId: number | undefined | null;\n\tsets: FormattedWorkoutSet[] | undefined;\n}\n\n/**\n * Formatted workout interface\n */\nexport interface FormattedWorkout {\n\tid: string | undefined;\n\ttitle: string | undefined;\n\tdescription: string | undefined | null;\n\tstartTime: number | undefined;\n\tendTime: number | undefined;\n\tcreatedAt: string | undefined;\n\tupdatedAt: string | undefined;\n\tduration: string;\n\texercises: FormattedWorkoutExercise[] | undefined;\n}\n\n/**\n * Formatted routine set interface\n */\nexport interface FormattedRoutineSet {\n\tindex: number | undefined;\n\ttype: string | undefined;\n\tweight: number | undefined | null;\n\treps: number | undefined | null;\n\tdistance: number | undefined | null;\n\tduration: number | undefined | null;\n\tcustomMetric: number | undefined | null;\n\trepRange?: { start?: number | null; end?: number | null } | undefined | null;\n\trpe?: number | undefined | null;\n}\n\n/**\n * Formatted routine exercise interface\n */\nexport interface FormattedRoutineExercise {\n\tname: string | undefined;\n\tindex: number | undefined;\n\texerciseTemplateId: string | undefined;\n\tnotes: string | undefined | null;\n\tsupersetId: number | undefined | null;\n\trestSeconds: string | undefined;\n\tsets: FormattedRoutineSet[] | undefined;\n}\n\n/**\n * Formatted routine interface\n */\nexport interface FormattedRoutine {\n\tid: string | undefined;\n\ttitle: string | undefined;\n\tfolderId: number | undefined | null;\n\tcreatedAt: string | undefined;\n\tupdatedAt: string | undefined;\n\texercises: FormattedRoutineExercise[] | undefined;\n}\n\n/**\n * Formatted routine folder interface\n */\nexport interface FormattedRoutineFolder {\n\tid: number | undefined;\n\ttitle: string | undefined;\n\tcreatedAt: string | undefined;\n\tupdatedAt: string | undefined;\n}\n\n/**\n * Formatted exercise template interface\n */\nexport interface FormattedExerciseTemplate {\n\tid: string | undefined;\n\ttitle: string | undefined;\n\ttype: string | undefined;\n\tprimaryMuscleGroup: string | undefined;\n\tsecondaryMuscleGroups: string[] | undefined;\n\tisCustom: boolean | undefined;\n}\n\n/**\n * Format a workout object for consistent presentation\n *\n * @param workout - The workout object from the API\n * @returns A formatted workout object with standardized properties\n */\nexport function formatWorkout(workout: Workout): FormattedWorkout {\n\treturn {\n\t\tid: workout.id,\n\t\ttitle: workout.title,\n\t\tdescription: workout.description,\n\t\tstartTime: workout.start_time,\n\t\tendTime: workout.end_time,\n\t\tcreatedAt: workout.created_at,\n\t\tupdatedAt: workout.updated_at,\n\t\tduration: calculateDuration(workout.start_time, workout.end_time),\n\t\texercises: workout.exercises?.map((exercise) => {\n\t\t\treturn {\n\t\t\t\tindex: exercise.index,\n\t\t\t\tname: exercise.title,\n\t\t\t\texerciseTemplateId: exercise.exercise_template_id,\n\t\t\t\tnotes: exercise.notes,\n\t\t\t\tsupersetsId: exercise.supersets_id,\n\t\t\t\tsets: exercise.sets?.map((set) => ({\n\t\t\t\t\tindex: set.index,\n\t\t\t\t\ttype: set.type,\n\t\t\t\t\tweight: set.weight_kg,\n\t\t\t\t\treps: set.reps,\n\t\t\t\t\tdistance: set.distance_meters,\n\t\t\t\t\tduration: set.duration_seconds,\n\t\t\t\t\trpe: set.rpe,\n\t\t\t\t\tcustomMetric: set.custom_metric,\n\t\t\t\t})),\n\t\t\t};\n\t\t}),\n\t};\n}\n\n/**\n * Format a routine object for consistent presentation\n *\n * @param routine - The routine object from the API\n * @returns A formatted routine object with standardized properties\n */\nexport function formatRoutine(routine: Routine): FormattedRoutine {\n\treturn {\n\t\tid: routine.id,\n\t\ttitle: routine.title,\n\t\tfolderId: routine.folder_id,\n\t\tcreatedAt: routine.created_at,\n\t\tupdatedAt: routine.updated_at,\n\t\texercises: routine.exercises?.map((exercise) => {\n\t\t\treturn {\n\t\t\t\tname: exercise.title,\n\t\t\t\tindex: exercise.index,\n\t\t\t\texerciseTemplateId: exercise.exercise_template_id,\n\t\t\t\tnotes: exercise.notes,\n\t\t\t\tsupersetId: exercise.supersets_id,\n\t\t\t\trestSeconds: exercise.rest_seconds,\n\t\t\t\tsets: exercise.sets?.map((set) => ({\n\t\t\t\t\tindex: set.index,\n\t\t\t\t\ttype: set.type,\n\t\t\t\t\tweight: set.weight_kg,\n\t\t\t\t\treps: set.reps,\n\t\t\t\t\t...(set.rep_range !== undefined && { repRange: set.rep_range }),\n\t\t\t\t\tdistance: set.distance_meters,\n\t\t\t\t\tduration: set.duration_seconds,\n\t\t\t\t\t...(set.rpe !== undefined && { rpe: set.rpe }),\n\t\t\t\t\tcustomMetric: set.custom_metric,\n\t\t\t\t})),\n\t\t\t};\n\t\t}),\n\t};\n}\n\n/**\n * Format a routine folder object for consistent presentation\n *\n * @param folder - The routine folder object from the API\n * @returns A formatted routine folder object with standardized properties\n */\nexport function formatRoutineFolder(\n\tfolder: RoutineFolder,\n): FormattedRoutineFolder {\n\treturn {\n\t\tid: folder.id,\n\t\ttitle: folder.title,\n\t\tcreatedAt: folder.created_at,\n\t\tupdatedAt: folder.updated_at,\n\t};\n}\n\n/**\n * Calculate duration between two ISO timestamp strings\n *\n * @param startTime - The start time as ISO string or timestamp\n * @param endTime - The end time as ISO string or timestamp\n * @returns A formatted duration string (e.g. \"1h 30m 45s\") or \"Unknown duration\" if inputs are invalid\n */\nexport function calculateDuration(\n\tstartTime: string | number | null | undefined,\n\tendTime: string | number | null | undefined,\n): string {\n\tif (!startTime || !endTime) return \"Unknown duration\";\n\n\ttry {\n\t\tconst start = new Date(startTime);\n\t\tconst end = new Date(endTime);\n\n\t\t// Validate dates\n\t\tif (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime())) {\n\t\t\treturn \"Unknown duration\";\n\t\t}\n\n\t\tconst durationMs = end.getTime() - start.getTime();\n\n\t\t// Handle negative durations\n\t\tif (durationMs < 0) {\n\t\t\treturn \"Invalid duration (end time before start time)\";\n\t\t}\n\n\t\tconst hours = Math.floor(durationMs / (1000 * 60 * 60));\n\t\tconst minutes = Math.floor((durationMs % (1000 * 60 * 60)) / (1000 * 60));\n\t\tconst seconds = Math.floor((durationMs % (1000 * 60)) / 1000);\n\n\t\treturn `${hours}h ${minutes}m ${seconds}s`;\n\t} catch (error) {\n\t\tconsole.error(\"Error calculating duration:\", error);\n\t\treturn \"Unknown duration\";\n\t}\n}\n\n/**\n * Format an exercise template object for consistent presentation\n *\n * @param template - The exercise template object from the API\n * @returns A formatted exercise template object with standardized properties\n */\nexport function formatExerciseTemplate(\n\ttemplate: ExerciseTemplate,\n): FormattedExerciseTemplate {\n\treturn {\n\t\tid: template.id,\n\t\ttitle: template.title,\n\t\ttype: template.type,\n\t\tprimaryMuscleGroup: template.primary_muscle_group,\n\t\tsecondaryMuscleGroups: template.secondary_muscle_groups,\n\t\tisCustom: template.is_custom,\n\t};\n}\n","/**\n * MCP Tool Response type\n */\nexport interface McpToolResponse {\n\t[x: string]: unknown;\n\tcontent: Array<{\n\t\ttype: \"text\";\n\t\ttext: string;\n\t}>;\n}\n\n/**\n * Format options for JSON responses\n */\nexport interface JsonFormatOptions {\n\t/** Whether to pretty-print the JSON with indentation */\n\tpretty?: boolean;\n\t/** Indentation spaces for pretty-printing (default: 2) */\n\tindent?: number;\n}\n\n/**\n * Create a standardized success response with JSON data\n *\n * @param data - The data to include in the response\n * @param options - Formatting options\n * @returns A formatted MCP tool response with the data as JSON\n */\nexport function createJsonResponse(\n\tdata: unknown,\n\toptions: JsonFormatOptions = { pretty: true, indent: 2 },\n): McpToolResponse {\n\tconst jsonString = options.pretty\n\t\t? JSON.stringify(data, null, options.indent)\n\t\t: JSON.stringify(data);\n\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\" as const,\n\t\t\t\ttext: jsonString,\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Create a standardized success response with text data\n *\n * @param message - The text message to include in the response\n * @returns A formatted MCP tool response with the text message\n */\nexport function createTextResponse(message: string): McpToolResponse {\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\" as const,\n\t\t\t\ttext: message,\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Create a standardized success response for empty or null results\n *\n * @param message - Optional message to include (default: \"No data found\")\n * @returns A formatted MCP tool response for empty results\n */\nexport function createEmptyResponse(\n\tmessage = \"No data found\",\n): McpToolResponse {\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\" as const,\n\t\t\t\ttext: message,\n\t\t\t},\n\t\t],\n\t};\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\n// Import types from generated client\nimport type {\n\tPostRoutinesRequestExercise,\n\tPostRoutinesRequestSet,\n\tPostRoutinesRequestSetTypeEnumKey,\n\tPutRoutinesRequestExercise,\n\tPutRoutinesRequestSet,\n\tPutRoutinesRequestSetTypeEnumKey,\n\tRoutine,\n} from \"../generated/client/types/index.js\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport { formatRoutine } from \"../utils/formatters.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\n// Type definitions for the routine operations\ntype HevyClient = ReturnType<\n\ttypeof import(\"../utils/hevyClientKubb.js\").createClient\n>;\n\n/**\n * Register all routine-related tools with the MCP server\n */\nexport function registerRoutineTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get routines\n\tconst getRoutinesSchema = {\n\t\tpage: z.coerce.number().int().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(10).default(5),\n\t} as const;\n\ttype GetRoutinesParams = InferToolParams<typeof getRoutinesSchema>;\n\n\tserver.tool(\n\t\t\"get-routines\",\n\t\t\"Get a paginated list of your workout routines, including custom and default routines. Useful for browsing or searching your available routines.\",\n\t\tgetRoutinesSchema,\n\t\twithErrorHandling(async (args: GetRoutinesParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize } = args;\n\t\t\tconst data = await hevyClient.getRoutines({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t});\n\n\t\t\t// Process routines to extract relevant information\n\t\t\tconst routines =\n\t\t\t\tdata?.routines?.map((routine: Routine) => formatRoutine(routine)) || [];\n\n\t\t\tif (routines.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No routines found for the specified parameters\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(routines);\n\t\t}, \"get-routines\"),\n\t);\n\n\t// Get single routine by ID (new, direct endpoint)\n\tconst getRoutineSchema = {\n\t\troutineId: z.string().min(1),\n\t} as const;\n\ttype GetRoutineParams = InferToolParams<typeof getRoutineSchema>;\n\n\tserver.tool(\n\t\t\"get-routine\",\n\t\t\"Get a routine by its ID using the direct endpoint. Returns all details for the specified routine.\",\n\t\tgetRoutineSchema,\n\t\twithErrorHandling(async (args: GetRoutineParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { routineId } = args;\n\t\t\tconst data = await hevyClient.getRoutineById(String(routineId));\n\t\t\tif (!data || !data.routine) {\n\t\t\t\treturn createEmptyResponse(`Routine with ID ${routineId} not found`);\n\t\t\t}\n\t\t\tconst routine = formatRoutine(data.routine);\n\t\t\treturn createJsonResponse(routine);\n\t\t}, \"get-routine\"),\n\t);\n\n\t// Create new routine\n\tconst createRoutineSchema = {\n\t\ttitle: z.string().min(1),\n\t\tfolderId: z.coerce.number().nullable().optional(),\n\t\tnotes: z.string().optional(),\n\t\texercises: z.array(\n\t\t\tz.object({\n\t\t\t\texerciseTemplateId: z.string().min(1),\n\t\t\t\tsupersetId: z.coerce.number().nullable().optional(),\n\t\t\t\trestSeconds: z.coerce.number().int().min(0).optional(),\n\t\t\t\tnotes: z.string().optional(),\n\t\t\t\tsets: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z\n\t\t\t\t\t\t\t.enum([\"warmup\", \"normal\", \"failure\", \"dropset\"])\n\t\t\t\t\t\t\t.default(\"normal\"),\n\t\t\t\t\t\tweight: z.coerce.number().optional(),\n\t\t\t\t\t\tweightKg: z.coerce.number().optional(),\n\t\t\t\t\t\treps: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdistance: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdistanceMeters: z.coerce.number().int().optional(),\n\t\t\t\t\t\tduration: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdurationSeconds: z.coerce.number().int().optional(),\n\t\t\t\t\t\tcustomMetric: z.coerce.number().optional(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t} as const;\n\ttype CreateRoutineParams = InferToolParams<typeof createRoutineSchema>;\n\n\tserver.tool(\n\t\t\"create-routine\",\n\t\t\"Create a new workout routine in your Hevy account. Requires a title and at least one exercise with sets. Optionally assign to a folder. Returns the full routine details including the new routine ID.\",\n\t\tcreateRoutineSchema,\n\t\twithErrorHandling(async (args: CreateRoutineParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { title, folderId, notes, exercises } = args;\n\t\t\tconst data = await hevyClient.createRoutine({\n\t\t\t\troutine: {\n\t\t\t\t\ttitle,\n\t\t\t\t\tfolder_id: folderId ?? null,\n\t\t\t\t\tnotes: notes ?? \"\",\n\t\t\t\t\texercises: exercises.map(\n\t\t\t\t\t\t(exercise): PostRoutinesRequestExercise => ({\n\t\t\t\t\t\t\texercise_template_id: exercise.exerciseTemplateId,\n\t\t\t\t\t\t\tsuperset_id: exercise.supersetId ?? null,\n\t\t\t\t\t\t\trest_seconds: exercise.restSeconds ?? null,\n\t\t\t\t\t\t\tnotes: exercise.notes ?? null,\n\t\t\t\t\t\t\tsets: exercise.sets.map(\n\t\t\t\t\t\t\t\t(set): PostRoutinesRequestSet => ({\n\t\t\t\t\t\t\t\t\ttype: set.type as PostRoutinesRequestSetTypeEnumKey,\n\t\t\t\t\t\t\t\t\tweight_kg: set.weight ?? set.weightKg ?? null,\n\t\t\t\t\t\t\t\t\treps: set.reps ?? null,\n\t\t\t\t\t\t\t\t\tdistance_meters: set.distance ?? set.distanceMeters ?? null,\n\t\t\t\t\t\t\t\t\tduration_seconds: set.duration ?? set.durationSeconds ?? null,\n\t\t\t\t\t\t\t\t\tcustom_metric: set.customMetric ?? null,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to create routine: Server returned no data\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst routine = formatRoutine(data);\n\t\t\treturn createJsonResponse(routine, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"create-routine\"),\n\t);\n\n\t// Update existing routine\n\tconst updateRoutineSchema = {\n\t\troutineId: z.string().min(1),\n\t\ttitle: z.string().min(1),\n\t\tnotes: z.string().optional(),\n\t\texercises: z.array(\n\t\t\tz.object({\n\t\t\t\texerciseTemplateId: z.string().min(1),\n\t\t\t\tsupersetId: z.coerce.number().nullable().optional(),\n\t\t\t\trestSeconds: z.coerce.number().int().min(0).optional(),\n\t\t\t\tnotes: z.string().optional(),\n\t\t\t\tsets: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z\n\t\t\t\t\t\t\t.enum([\"warmup\", \"normal\", \"failure\", \"dropset\"])\n\t\t\t\t\t\t\t.default(\"normal\"),\n\t\t\t\t\t\tweight: z.coerce.number().optional(),\n\t\t\t\t\t\tweightKg: z.coerce.number().optional(),\n\t\t\t\t\t\treps: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdistance: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdistanceMeters: z.coerce.number().int().optional(),\n\t\t\t\t\t\tduration: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdurationSeconds: z.coerce.number().int().optional(),\n\t\t\t\t\t\tcustomMetric: z.coerce.number().optional(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t} as const;\n\ttype UpdateRoutineParams = InferToolParams<typeof updateRoutineSchema>;\n\n\tserver.tool(\n\t\t\"update-routine\",\n\t\t\"Update an existing routine by ID. You can modify the title, notes, and exercise configurations. Returns the updated routine with all changes applied.\",\n\t\tupdateRoutineSchema,\n\t\twithErrorHandling(async (args: UpdateRoutineParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { routineId, title, notes, exercises } = args;\n\t\t\tconst data = await hevyClient.updateRoutine(routineId, {\n\t\t\t\troutine: {\n\t\t\t\t\ttitle,\n\t\t\t\t\tnotes: notes ?? null,\n\t\t\t\t\texercises: exercises.map(\n\t\t\t\t\t\t(exercise): PutRoutinesRequestExercise => ({\n\t\t\t\t\t\t\texercise_template_id: exercise.exerciseTemplateId,\n\t\t\t\t\t\t\tsuperset_id: exercise.supersetId ?? null,\n\t\t\t\t\t\t\trest_seconds: exercise.restSeconds ?? null,\n\t\t\t\t\t\t\tnotes: exercise.notes ?? null,\n\t\t\t\t\t\t\tsets: exercise.sets.map(\n\t\t\t\t\t\t\t\t(set): PutRoutinesRequestSet => ({\n\t\t\t\t\t\t\t\t\ttype: set.type as PutRoutinesRequestSetTypeEnumKey,\n\t\t\t\t\t\t\t\t\tweight_kg: set.weight ?? set.weightKg ?? null,\n\t\t\t\t\t\t\t\t\treps: set.reps ?? null,\n\t\t\t\t\t\t\t\t\tdistance_meters: set.distance ?? set.distanceMeters ?? null,\n\t\t\t\t\t\t\t\t\tduration_seconds: set.duration ?? set.durationSeconds ?? null,\n\t\t\t\t\t\t\t\t\tcustom_metric: set.customMetric ?? null,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`Failed to update routine with ID ${routineId}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst routine = formatRoutine(data);\n\t\t\treturn createJsonResponse(routine, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"update-routine\"),\n\t);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\n// Import types from generated client\nimport type { ExerciseTemplate } from \"../generated/client/types/index.js\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport { formatExerciseTemplate } from \"../utils/formatters.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\n// Type definitions for the template operations\ntype HevyClient = ReturnType<\n\ttypeof import(\"../utils/hevyClientKubb.js\").createClient\n>;\n\n/**\n * Register all exercise template-related tools with the MCP server\n */\nexport function registerTemplateTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get exercise templates\n\tconst getExerciseTemplatesSchema = {\n\t\tpage: z.coerce.number().int().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(100).default(5),\n\t} as const;\n\ttype GetExerciseTemplatesParams = InferToolParams<\n\t\ttypeof getExerciseTemplatesSchema\n\t>;\n\n\tserver.tool(\n\t\t\"get-exercise-templates\",\n\t\t\"Get a paginated list of exercise templates (default and custom) with details like name, category, equipment, and muscle groups. Useful for browsing or searching available exercises.\",\n\t\tgetExerciseTemplatesSchema,\n\t\twithErrorHandling(async (args: GetExerciseTemplatesParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize } = args;\n\t\t\tconst data = await hevyClient.getExerciseTemplates({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t});\n\n\t\t\t// Process exercise templates to extract relevant information\n\t\t\tconst templates =\n\t\t\t\tdata?.exercise_templates?.map((template: ExerciseTemplate) =>\n\t\t\t\t\tformatExerciseTemplate(template),\n\t\t\t\t) || [];\n\n\t\t\tif (templates.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No exercise templates found for the specified parameters\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(templates);\n\t\t}, \"get-exercise-templates\"),\n\t);\n\n\t// Get single exercise template by ID\n\tconst getExerciseTemplateSchema = {\n\t\texerciseTemplateId: z.string().min(1),\n\t} as const;\n\ttype GetExerciseTemplateParams = InferToolParams<\n\t\ttypeof getExerciseTemplateSchema\n\t>;\n\n\tserver.tool(\n\t\t\"get-exercise-template\",\n\t\t\"Get complete details of a specific exercise template by its ID, including name, category, equipment, muscle groups, and notes.\",\n\t\tgetExerciseTemplateSchema,\n\t\twithErrorHandling(async (args: GetExerciseTemplateParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { exerciseTemplateId } = args;\n\t\t\tconst data = await hevyClient.getExerciseTemplate(exerciseTemplateId);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`Exercise template with ID ${exerciseTemplateId} not found`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst template = formatExerciseTemplate(data);\n\t\t\treturn createJsonResponse(template);\n\t\t}, \"get-exercise-template\"),\n\t);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\ntype HevyClient = ReturnType<\n\ttypeof import(\"../utils/hevyClientKubb.js\").createClient\n>;\n\n// Enhanced webhook URL validation\nconst webhookUrlSchema = z\n\t.string()\n\t.url()\n\t.refine(\n\t\t(url) => {\n\t\t\ttry {\n\t\t\t\tconst parsed = new URL(url);\n\t\t\t\treturn parsed.protocol === \"https:\" || parsed.protocol === \"http:\";\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tmessage: \"Webhook URL must be a valid HTTP or HTTPS URL\",\n\t\t},\n\t)\n\t.refine(\n\t\t(url) => {\n\t\t\ttry {\n\t\t\t\tconst parsed = new URL(url);\n\t\t\t\treturn (\n\t\t\t\t\tparsed.hostname !== \"localhost\" && !parsed.hostname.startsWith(\"127.\")\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tmessage: \"Webhook URL cannot be localhost or loopback address\",\n\t\t},\n\t);\n\nexport function registerWebhookTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get webhook subscription\n\tconst getWebhookSubscriptionSchema = {} as const;\n\ttype GetWebhookSubscriptionParams = InferToolParams<\n\t\ttypeof getWebhookSubscriptionSchema\n\t>;\n\n\tserver.tool(\n\t\t\"get-webhook-subscription\",\n\t\t\"Get the current webhook subscription for this account. Returns the webhook URL and auth token if a subscription exists.\",\n\t\tgetWebhookSubscriptionSchema,\n\t\twithErrorHandling(async (_args: GetWebhookSubscriptionParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\t// TODO: Uncomment after regenerating client from updated OpenAPI spec\n\t\t\tif (!(\"getWebhookSubscription\" in hevyClient)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Webhook subscription API not available. Please regenerate the client from the updated OpenAPI spec.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await (hevyClient as any).getWebhookSubscription();\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No webhook subscription found for this account\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn createJsonResponse(data);\n\t\t}, \"get-webhook-subscription\"),\n\t);\n\n\t// Create webhook subscription\n\tconst createWebhookSubscriptionSchema = {\n\t\turl: webhookUrlSchema.describe(\n\t\t\t\"The webhook URL that will receive POST requests when workouts are created\",\n\t\t),\n\t\tauthToken: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Optional auth token that will be sent as Authorization header in webhook requests\",\n\t\t\t),\n\t} as const;\n\ttype CreateWebhookSubscriptionParams = InferToolParams<\n\t\ttypeof createWebhookSubscriptionSchema\n\t>;\n\n\tserver.tool(\n\t\t\"create-webhook-subscription\",\n\t\t\"Create a new webhook subscription for this account. The webhook will receive POST requests when workouts are created. Your endpoint must respond with 200 OK within 5 seconds.\",\n\t\tcreateWebhookSubscriptionSchema,\n\t\twithErrorHandling(async (args: CreateWebhookSubscriptionParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { url, authToken } = args;\n\t\t\t// TODO: Uncomment after regenerating client from updated OpenAPI spec\n\t\t\tif (!(\"createWebhookSubscription\" in hevyClient)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Webhook subscription API not available. Please regenerate the client from the updated OpenAPI spec.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await (hevyClient as any).createWebhookSubscription({\n\t\t\t\twebhook: {\n\t\t\t\t\turl,\n\t\t\t\t\tauthToken: authToken || null,\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to create webhook subscription - please check your URL and try again\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn createJsonResponse(data);\n\t\t}, \"create-webhook-subscription\"),\n\t);\n\n\t// Delete webhook subscription\n\tconst deleteWebhookSubscriptionSchema = {} as const;\n\ttype DeleteWebhookSubscriptionParams = InferToolParams<\n\t\ttypeof deleteWebhookSubscriptionSchema\n\t>;\n\n\tserver.tool(\n\t\t\"delete-webhook-subscription\",\n\t\t\"Delete the current webhook subscription for this account. This will stop all webhook notifications.\",\n\t\tdeleteWebhookSubscriptionSchema,\n\t\twithErrorHandling(async (_args: DeleteWebhookSubscriptionParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\t// TODO: Uncomment after regenerating client from updated OpenAPI spec\n\t\t\tif (!(\"deleteWebhookSubscription\" in hevyClient)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Webhook subscription API not available. Please regenerate the client from the updated OpenAPI spec.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await (hevyClient as any).deleteWebhookSubscription();\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to delete webhook subscription - no subscription may exist or there was a server error\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn createJsonResponse(data);\n\t\t}, \"delete-webhook-subscription\"),\n\t);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type {\n\tPostWorkoutsRequestBody,\n\tPostWorkoutsRequestExercise,\n\tPostWorkoutsRequestSetRpeEnumKey,\n\tPostWorkoutsRequestSetTypeEnumKey,\n} from \"../generated/client/types/index.js\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport { formatWorkout } from \"../utils/formatters.js\";\nimport type { HevyClient } from \"../utils/hevyClient.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\n/**\n * Register all workout-related tools with the MCP server\n */\nexport function registerWorkoutTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get workouts\n\tconst getWorkoutsSchema = {\n\t\tpage: z.coerce.number().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(10).default(5),\n\t} as const;\n\ttype GetWorkoutsParams = InferToolParams<typeof getWorkoutsSchema>;\n\n\tserver.tool(\n\t\t\"get-workouts\",\n\t\t\"Get a paginated list of workouts. Returns workout details including title, description, start/end times, and exercises performed. Results are ordered from newest to oldest.\",\n\t\tgetWorkoutsSchema,\n\t\twithErrorHandling(async (args: GetWorkoutsParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize } = args;\n\t\t\tconst data = await hevyClient.getWorkouts({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t});\n\n\t\t\tconst workouts =\n\t\t\t\tdata?.workouts?.map((workout) => formatWorkout(workout)) || [];\n\n\t\t\tif (workouts.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No workouts found for the specified parameters\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(workouts);\n\t\t}, \"get-workouts\"),\n\t);\n\n\t// Get single workout by ID\n\tconst getWorkoutSchema = {\n\t\tworkoutId: z.string().min(1),\n\t} as const;\n\ttype GetWorkoutParams = InferToolParams<typeof getWorkoutSchema>;\n\n\tserver.tool(\n\t\t\"get-workout\",\n\t\t\"Get complete details of a specific workout by ID. Returns all workout information including title, description, start/end times, and detailed exercise data.\",\n\t\tgetWorkoutSchema,\n\t\twithErrorHandling(async (args: GetWorkoutParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { workoutId } = args;\n\t\t\tconst data = await hevyClient.getWorkout(workoutId);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(`Workout with ID ${workoutId} not found`);\n\t\t\t}\n\n\t\t\tconst workout = formatWorkout(data);\n\t\t\treturn createJsonResponse(workout);\n\t\t}, \"get-workout\"),\n\t);\n\n\t// Get workout count\n\tserver.tool(\n\t\t\"get-workout-count\",\n\t\t\"Get the total number of workouts on the account. Useful for pagination or statistics.\",\n\t\t{},\n\t\twithErrorHandling(async () => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await hevyClient.getWorkoutCount();\n\t\t\tconst count = data\n\t\t\t\t? (data as { workoutCount?: number }).workoutCount || 0\n\t\t\t\t: 0;\n\t\t\treturn createJsonResponse({ count });\n\t\t}, \"get-workout-count\"),\n\t);\n\n\t// Get workout events (updates/deletes)\n\tconst getWorkoutEventsSchema = {\n\t\tpage: z.coerce.number().int().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(10).default(5),\n\t\tsince: z.string().default(\"1970-01-01T00:00:00Z\"),\n\t} as const;\n\ttype GetWorkoutEventsParams = InferToolParams<typeof getWorkoutEventsSchema>;\n\n\tserver.tool(\n\t\t\"get-workout-events\",\n\t\t\"Retrieve a paged list of workout events (updates or deletes) since a given date. Events are ordered from newest to oldest. The intention is to allow clients to keep their local cache of workouts up to date without having to fetch the entire list of workouts.\",\n\t\tgetWorkoutEventsSchema,\n\t\twithErrorHandling(async (args: GetWorkoutEventsParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize, since } = args;\n\t\t\tconst data = await hevyClient.getWorkoutEvents({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t\tsince,\n\t\t\t});\n\n\t\t\tconst events = data?.events || [];\n\n\t\t\tif (events.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`No workout events found for the specified parameters since ${since}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(events);\n\t\t}, \"get-workout-events\"),\n\t);\n\n\t// Create workout\n\tconst createWorkoutSchema = {\n\t\ttitle: z.string().min(1),\n\t\tdescription: z.string().optional().nullable(),\n\t\tstartTime: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/),\n\t\tendTime: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/),\n\t\tisPrivate: z.boolean().default(false),\n\t\texercises: z.array(\n\t\t\tz.object({\n\t\t\t\texerciseTemplateId: z.string().min(1),\n\t\t\t\tsupersetId: z.coerce.number().nullable().optional(),\n\t\t\t\tnotes: z.string().optional().nullable(),\n\t\t\t\tsets: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z\n\t\t\t\t\t\t\t.enum([\"warmup\", \"normal\", \"failure\", \"dropset\"])\n\t\t\t\t\t\t\t.default(\"normal\"),\n\t\t\t\t\t\tweight: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\tweightKg: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\treps: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdistance: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdistanceMeters: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tduration: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdurationSeconds: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\trpe: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\tcustomMetric: z.coerce.number().optional().nullable(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t} as const;\n\ttype CreateWorkoutParams = InferToolParams<typeof createWorkoutSchema>;\n\n\tserver.tool(\n\t\t\"create-workout\",\n\t\t\"Create a new workout in your Hevy account. Requires title, start/end times, and at least one exercise with sets. Returns the complete workout details upon successful creation including the newly assigned workout ID.\",\n\t\tcreateWorkoutSchema,\n\t\twithErrorHandling(async (args: CreateWorkoutParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { title, description, startTime, endTime, isPrivate, exercises } =\n\t\t\t\targs;\n\t\t\tconst requestBody: PostWorkoutsRequestBody = {\n\t\t\t\tworkout: {\n\t\t\t\t\ttitle,\n\t\t\t\t\tdescription: description || null,\n\t\t\t\t\tstart_time: startTime,\n\t\t\t\t\tend_time: endTime,\n\t\t\t\t\tis_private: isPrivate,\n\t\t\t\t\texercises: exercises.map(\n\t\t\t\t\t\t(exercise): PostWorkoutsRequestExercise => ({\n\t\t\t\t\t\t\texercise_template_id: exercise.exerciseTemplateId,\n\t\t\t\t\t\t\tsuperset_id: exercise.supersetId ?? null,\n\t\t\t\t\t\t\tnotes: exercise.notes ?? null,\n\t\t\t\t\t\t\tsets: exercise.sets.map((set) => ({\n\t\t\t\t\t\t\t\ttype: set.type as PostWorkoutsRequestSetTypeEnumKey,\n\t\t\t\t\t\t\t\tweight_kg: set.weight ?? set.weightKg ?? null,\n\t\t\t\t\t\t\t\treps: set.reps ?? null,\n\t\t\t\t\t\t\t\tdistance_meters: set.distance ?? set.distanceMeters ?? null,\n\t\t\t\t\t\t\t\tduration_seconds: set.duration ?? set.durationSeconds ?? null,\n\t\t\t\t\t\t\t\trpe:\n\t\t\t\t\t\t\t\t\t(set.rpe as PostWorkoutsRequestSetRpeEnumKey | null) ?? null,\n\t\t\t\t\t\t\t\tcustom_metric: set.customMetric ?? null,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst data = await hevyClient.createWorkout(requestBody);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to create workout: Server returned no data\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst workout = formatWorkout(data);\n\t\t\treturn createJsonResponse(workout, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"create-workout\"),\n\t);\n\n\t// Update workout\n\tconst updateWorkoutSchema = {\n\t\tworkoutId: z.string().min(1),\n\t\ttitle: z.string().min(1),\n\t\tdescription: z.string().optional().nullable(),\n\t\tstartTime: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/),\n\t\tendTime: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/),\n\t\tisPrivate: z.boolean().default(false),\n\t\texercises: z.array(\n\t\t\tz.object({\n\t\t\t\texerciseTemplateId: z.string().min(1),\n\t\t\t\tsupersetId: z.coerce.number().nullable().optional(),\n\t\t\t\tnotes: z.string().optional().nullable(),\n\t\t\t\tsets: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z\n\t\t\t\t\t\t\t.enum([\"warmup\", \"normal\", \"failure\", \"dropset\"])\n\t\t\t\t\t\t\t.default(\"normal\"),\n\t\t\t\t\t\tweight: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\tweightKg: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\treps: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdistance: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdistanceMeters: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tduration: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdurationSeconds: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\trpe: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\tcustomMetric: z.coerce.number().optional().nullable(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t} as const;\n\ttype UpdateWorkoutParams = InferToolParams<typeof updateWorkoutSchema>;\n\n\tserver.tool(\n\t\t\"update-workout\",\n\t\t\"Update an existing workout by ID. You can modify the title, description, start/end times, privacy setting, and exercise data. Returns the updated workout with all changes applied.\",\n\t\tupdateWorkoutSchema,\n\t\twithErrorHandling(async (args: UpdateWorkoutParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tworkoutId,\n\t\t\t\ttitle,\n\t\t\t\tdescription,\n\t\t\t\tstartTime,\n\t\t\t\tendTime,\n\t\t\t\tisPrivate,\n\t\t\t\texercises,\n\t\t\t} = args;\n\t\t\tconst requestBody: PostWorkoutsRequestBody = {\n\t\t\t\tworkout: {\n\t\t\t\t\ttitle,\n\t\t\t\t\tdescription: description || null,\n\t\t\t\t\tstart_time: startTime,\n\t\t\t\t\tend_time: endTime,\n\t\t\t\t\tis_private: isPrivate,\n\t\t\t\t\texercises: exercises.map(\n\t\t\t\t\t\t(exercise): PostWorkoutsRequestExercise => ({\n\t\t\t\t\t\t\texercise_template_id: exercise.exerciseTemplateId,\n\t\t\t\t\t\t\tsuperset_id: exercise.supersetId ?? null,\n\t\t\t\t\t\t\tnotes: exercise.notes ?? null,\n\t\t\t\t\t\t\tsets: exercise.sets.map((set) => ({\n\t\t\t\t\t\t\t\ttype: set.type as PostWorkoutsRequestSetTypeEnumKey,\n\t\t\t\t\t\t\t\tweight_kg: set.weight ?? set.weightKg ?? null,\n\t\t\t\t\t\t\t\treps: set.reps ?? null,\n\t\t\t\t\t\t\t\tdistance_meters: set.distance ?? set.distanceMeters ?? null,\n\t\t\t\t\t\t\t\tduration_seconds: set.duration ?? set.durationSeconds ?? null,\n\t\t\t\t\t\t\t\trpe:\n\t\t\t\t\t\t\t\t\t(set.rpe as PostWorkoutsRequestSetRpeEnumKey | null) ?? null,\n\t\t\t\t\t\t\t\tcustom_metric: set.customMetric ?? null,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst data = await hevyClient.updateWorkout(workoutId, requestBody);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`Failed to update workout with ID ${workoutId}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst workout = formatWorkout(data);\n\t\t\treturn createJsonResponse(workout, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"update-workout-operation\"),\n\t);\n}\n","export interface HevyConfig {\n\tapiKey?: string;\n}\n\n/**\n * Parse CLI arguments and environment to derive configuration.\n * Priority order for API key: CLI flag forms > environment variable.\n * Supported CLI arg forms:\n * --hevy-api-key=KEY\n * --hevyApiKey=KEY\n * hevy-api-key=KEY (bare, e.g. when passed after npm start -- )\n */\nexport function parseConfig(\n\targv: string[],\n\tenv: NodeJS.ProcessEnv,\n): HevyConfig {\n\tlet apiKey = \"\";\n\tconst apiKeyArgPatterns = [\n\t\t/^--hevy-api-key=(.+)$/i,\n\t\t/^--hevyApiKey=(.+)$/i,\n\t\t/^hevy-api-key=(.+)$/i,\n\t];\n\tfor (const raw of argv) {\n\t\tfor (const pattern of apiKeyArgPatterns) {\n\t\t\tconst m = raw.match(pattern);\n\t\t\tif (m) {\n\t\t\t\tapiKey = m[1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (apiKey) break;\n\t}\n\tif (!apiKey) {\n\t\tapiKey = env.HEVY_API_KEY || \"\";\n\t}\n\n\treturn {\n\t\tapiKey,\n\t};\n}\n\nexport function assertApiKey(\n\tapiKey: string | undefined,\n): asserts apiKey is string {\n\tif (!apiKey) {\n\t\tconsole.error(\n\t\t\t\"Hevy API key is required. Provide it via the HEVY_API_KEY environment variable or the --hevy-api-key=YOUR_KEY command argument.\",\n\t\t);\n\t\tprocess.exit(1);\n\t}\n}\n","import type {\n\tRequestConfig,\n\tResponseConfig,\n} from \"@kubb/plugin-client/clients/axios\";\nimport axios from \"axios\";\nimport * as api from \"../generated/client/api\";\nimport type {\n\tGetV1ExerciseTemplatesQueryParams,\n\tGetV1RoutineFoldersQueryParams,\n\tGetV1RoutinesQueryParams,\n\tGetV1WorkoutsEventsQueryParams,\n\tGetV1WorkoutsQueryParams,\n\tPostV1RoutineFoldersMutationRequest,\n\tPostV1RoutinesMutationRequest,\n\tPostV1WorkoutsMutationRequest,\n\tPutV1RoutinesRoutineidMutationRequest,\n\tPutV1WorkoutsWorkoutidMutationRequest,\n} from \"../generated/client/types\";\n\n// Define a proper client type that matches the Kubb client interface\ntype KubbClient = {\n\t<TData, _TError = unknown, TVariables = unknown>(\n\t\tconfig: RequestConfig<TVariables>,\n\t): Promise<ResponseConfig<TData>>;\n\tgetConfig: () => Partial<RequestConfig<unknown>>;\n\tsetConfig: (config: RequestConfig) => Partial<RequestConfig<unknown>>;\n};\n\nexport function createClient(\n\tapiKey: string,\n\tbaseUrl = \"https://api.hevyapp.com\",\n) {\n\t// Create an axios instance with the API key\n\tconst axiosInstance = axios.create({\n\t\tbaseURL: baseUrl,\n\t\theaders: {\n\t\t\t\"api-key\": apiKey,\n\t\t},\n\t});\n\n\t// Create headers object with API key\n\tconst headers = {\n\t\t\"api-key\": apiKey,\n\t};\n\n\t// Cast axios instance to the expected client type\n\tconst client = axiosInstance as unknown as KubbClient;\n\n\t// Return an object with all the API methods using ReturnType for automatic type inference\n\treturn {\n\t\t// Workouts\n\t\tgetWorkouts: (\n\t\t\tparams?: GetV1WorkoutsQueryParams,\n\t\t): ReturnType<typeof api.getV1Workouts> =>\n\t\t\tapi.getV1Workouts(headers, params, { client }),\n\t\tgetWorkout: (\n\t\t\tworkoutId: string,\n\t\t): ReturnType<typeof api.getV1WorkoutsWorkoutid> =>\n\t\t\tapi.getV1WorkoutsWorkoutid(workoutId, headers, { client }),\n\t\tcreateWorkout: (\n\t\t\tdata: PostV1WorkoutsMutationRequest,\n\t\t): ReturnType<typeof api.postV1Workouts> =>\n\t\t\tapi.postV1Workouts(headers, data, { client }),\n\t\tupdateWorkout: (\n\t\t\tworkoutId: string,\n\t\t\tdata: PutV1WorkoutsWorkoutidMutationRequest,\n\t\t): ReturnType<typeof api.putV1WorkoutsWorkoutid> =>\n\t\t\tapi.putV1WorkoutsWorkoutid(workoutId, headers, data, {\n\t\t\t\tclient,\n\t\t\t}),\n\t\tgetWorkoutCount: (): ReturnType<typeof api.getV1WorkoutsCount> =>\n\t\t\tapi.getV1WorkoutsCount(headers, { client }),\n\t\tgetWorkoutEvents: (\n\t\t\tparams?: GetV1WorkoutsEventsQueryParams,\n\t\t): ReturnType<typeof api.getV1WorkoutsEvents> =>\n\t\t\tapi.getV1WorkoutsEvents(headers, params, { client }),\n\n\t\t// Routines\n\t\tgetRoutines: (\n\t\t\tparams?: GetV1RoutinesQueryParams,\n\t\t): ReturnType<typeof api.getV1Routines> =>\n\t\t\tapi.getV1Routines(headers, params, { client }),\n\t\tgetRoutineById: (\n\t\t\troutineId: string,\n\t\t): ReturnType<typeof api.getV1RoutinesRoutineid> =>\n\t\t\tapi.getV1RoutinesRoutineid(routineId, headers, { client }),\n\t\tcreateRoutine: (\n\t\t\tdata: PostV1RoutinesMutationRequest,\n\t\t): ReturnType<typeof api.postV1Routines> =>\n\t\t\tapi.postV1Routines(headers, data, { client }),\n\t\tupdateRoutine: (\n\t\t\troutineId: string,\n\t\t\tdata: PutV1RoutinesRoutineidMutationRequest,\n\t\t): ReturnType<typeof api.putV1RoutinesRoutineid> =>\n\t\t\tapi.putV1RoutinesRoutineid(routineId, headers, data, {\n\t\t\t\tclient,\n\t\t\t}),\n\n\t\t// Exercise Templates\n\t\tgetExerciseTemplates: (\n\t\t\tparams?: GetV1ExerciseTemplatesQueryParams,\n\t\t): ReturnType<typeof api.getV1ExerciseTemplates> =>\n\t\t\tapi.getV1ExerciseTemplates(headers, params, { client }),\n\t\tgetExerciseTemplate: (\n\t\t\ttemplateId: string,\n\t\t): ReturnType<typeof api.getV1ExerciseTemplatesExercisetemplateid> =>\n\t\t\tapi.getV1ExerciseTemplatesExercisetemplateid(templateId, headers, {\n\t\t\t\tclient,\n\t\t\t}),\n\n\t\t// Routine Folders\n\t\tgetRoutineFolders: (\n\t\t\tparams?: GetV1RoutineFoldersQueryParams,\n\t\t): ReturnType<typeof api.getV1RoutineFolders> =>\n\t\t\tapi.getV1RoutineFolders(headers, params, { client }),\n\t\tcreateRoutineFolder: (\n\t\t\tdata: PostV1RoutineFoldersMutationRequest,\n\t\t): ReturnType<typeof api.postV1RoutineFolders> =>\n\t\t\tapi.postV1RoutineFolders(headers, data, { client }),\n\t\tgetRoutineFolder: (\n\t\t\tfolderId: string,\n\t\t): ReturnType<typeof api.getV1RoutineFoldersFolderid> =>\n\t\t\tapi.getV1RoutineFoldersFolderid(folderId, headers, {\n\t\t\t\tclient,\n\t\t\t}),\n\n\t\t// Webhooks\n\t\tgetWebhookSubscription: (): ReturnType<\n\t\t\ttypeof api.getV1WebhookSubscription\n\t\t> => api.getV1WebhookSubscription(headers, { client }),\n\t\tcreateWebhookSubscription: (\n\t\t\tdata: import(\"../generated/client/types\").PostV1WebhookSubscriptionMutationRequest,\n\t\t): ReturnType<typeof api.postV1WebhookSubscription> =>\n\t\t\tapi.postV1WebhookSubscription(headers, data, { client }),\n\t\tdeleteWebhookSubscription: (): ReturnType<\n\t\t\ttypeof api.deleteV1WebhookSubscription\n\t\t> => api.deleteV1WebhookSubscription(headers, { client }),\n\t};\n}\n","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { DeleteV1WebhookSubscriptionMutationResponse, DeleteV1WebhookSubscriptionHeaderParams } from \"../types/DeleteV1WebhookSubscription.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getDeleteV1WebhookSubscriptionUrl() {\n const res = { method: 'DELETE', url: `/v1/webhook-subscription` as const } \n return res\n}\n\n/**\n * @summary Delete a webhook subscription.\n * {@link /v1/webhook-subscription}\n */\nexport async function deleteV1WebhookSubscription(headers: DeleteV1WebhookSubscriptionHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<DeleteV1WebhookSubscriptionMutationResponse, ResponseErrorConfig<Error>, unknown>({ method : \"DELETE\", url : getDeleteV1WebhookSubscriptionUrl().url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1ExerciseTemplatesQueryResponse, GetV1ExerciseTemplatesQueryParams, GetV1ExerciseTemplatesHeaderParams, GetV1ExerciseTemplates400 } from \"../types/GetV1ExerciseTemplates.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1ExerciseTemplatesUrl() {\n const res = { method: 'GET', url: `/v1/exercise_templates` as const } \n return res\n}\n\n/**\n * @summary Get a paginated list of exercise templates available on the account.\n * {@link /v1/exercise_templates}\n */\nexport async function getV1ExerciseTemplates(headers: GetV1ExerciseTemplatesHeaderParams, params?: GetV1ExerciseTemplatesQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1ExerciseTemplatesQueryResponse, ResponseErrorConfig<GetV1ExerciseTemplates400>, unknown>({ method : \"GET\", url : getGetV1ExerciseTemplatesUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1ExerciseTemplatesExercisetemplateidQueryResponse, GetV1ExerciseTemplatesExercisetemplateidPathParams, GetV1ExerciseTemplatesExercisetemplateidHeaderParams, GetV1ExerciseTemplatesExercisetemplateid404 } from \"../types/GetV1ExerciseTemplatesExercisetemplateid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1ExerciseTemplatesExercisetemplateidUrl(exerciseTemplateId: GetV1ExerciseTemplatesExercisetemplateidPathParams[\"exerciseTemplateId\"]) {\n const res = { method: 'GET', url: `/v1/exercise_templates/${exerciseTemplateId}` as const } \n return res\n}\n\n/**\n * @summary Get a single exercise template by id.\n * {@link /v1/exercise_templates/:exerciseTemplateId}\n */\nexport async function getV1ExerciseTemplatesExercisetemplateid(exerciseTemplateId: GetV1ExerciseTemplatesExercisetemplateidPathParams[\"exerciseTemplateId\"], headers: GetV1ExerciseTemplatesExercisetemplateidHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1ExerciseTemplatesExercisetemplateidQueryResponse, ResponseErrorConfig<GetV1ExerciseTemplatesExercisetemplateid404>, unknown>({ method : \"GET\", url : getGetV1ExerciseTemplatesExercisetemplateidUrl(exerciseTemplateId).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1RoutineFoldersQueryResponse, GetV1RoutineFoldersQueryParams, GetV1RoutineFoldersHeaderParams, GetV1RoutineFolders400 } from \"../types/GetV1RoutineFolders.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1RoutineFoldersUrl() {\n const res = { method: 'GET', url: `/v1/routine_folders` as const } \n return res\n}\n\n/**\n * @summary Get a paginated list of routine folders available on the account.\n * {@link /v1/routine_folders}\n */\nexport async function getV1RoutineFolders(headers: GetV1RoutineFoldersHeaderParams, params?: GetV1RoutineFoldersQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1RoutineFoldersQueryResponse, ResponseErrorConfig<GetV1RoutineFolders400>, unknown>({ method : \"GET\", url : getGetV1RoutineFoldersUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1RoutineFoldersFolderidQueryResponse, GetV1RoutineFoldersFolderidPathParams, GetV1RoutineFoldersFolderidHeaderParams, GetV1RoutineFoldersFolderid404 } from \"../types/GetV1RoutineFoldersFolderid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1RoutineFoldersFolderidUrl(folderId: GetV1RoutineFoldersFolderidPathParams[\"folderId\"]) {\n const res = { method: 'GET', url: `/v1/routine_folders/${folderId}` as const } \n return res\n}\n\n/**\n * @summary Get a single routine folder by id.\n * {@link /v1/routine_folders/:folderId}\n */\nexport async function getV1RoutineFoldersFolderid(folderId: GetV1RoutineFoldersFolderidPathParams[\"folderId\"], headers: GetV1RoutineFoldersFolderidHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1RoutineFoldersFolderidQueryResponse, ResponseErrorConfig<GetV1RoutineFoldersFolderid404>, unknown>({ method : \"GET\", url : getGetV1RoutineFoldersFolderidUrl(folderId).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1RoutinesQueryResponse, GetV1RoutinesQueryParams, GetV1RoutinesHeaderParams, GetV1Routines400 } from \"../types/GetV1Routines.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1RoutinesUrl() {\n const res = { method: 'GET', url: `/v1/routines` as const } \n return res\n}\n\n/**\n * @summary Get a paginated list of routines\n * {@link /v1/routines}\n */\nexport async function getV1Routines(headers: GetV1RoutinesHeaderParams, params?: GetV1RoutinesQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1RoutinesQueryResponse, ResponseErrorConfig<GetV1Routines400>, unknown>({ method : \"GET\", url : getGetV1RoutinesUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1RoutinesRoutineidQueryResponse, GetV1RoutinesRoutineidPathParams, GetV1RoutinesRoutineidHeaderParams, GetV1RoutinesRoutineid400 } from \"../types/GetV1RoutinesRoutineid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1RoutinesRoutineidUrl(routineId: GetV1RoutinesRoutineidPathParams[\"routineId\"]) {\n const res = { method: 'GET', url: `/v1/routines/${routineId}` as const } \n return res\n}\n\n/**\n * @summary Get a routine by its Id\n * {@link /v1/routines/:routineId}\n */\nexport async function getV1RoutinesRoutineid(routineId: GetV1RoutinesRoutineidPathParams[\"routineId\"], headers: GetV1RoutinesRoutineidHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1RoutinesRoutineidQueryResponse, ResponseErrorConfig<GetV1RoutinesRoutineid400>, unknown>({ method : \"GET\", url : getGetV1RoutinesRoutineidUrl(routineId).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WebhookSubscriptionQueryResponse, GetV1WebhookSubscriptionHeaderParams, GetV1WebhookSubscription404 } from \"../types/GetV1WebhookSubscription.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WebhookSubscriptionUrl() {\n const res = { method: 'GET', url: `/v1/webhook-subscription` as const } \n return res\n}\n\n/**\n * @summary Get the current webhook subscription.\n * {@link /v1/webhook-subscription}\n */\nexport async function getV1WebhookSubscription(headers: GetV1WebhookSubscriptionHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WebhookSubscriptionQueryResponse, ResponseErrorConfig<GetV1WebhookSubscription404>, unknown>({ method : \"GET\", url : getGetV1WebhookSubscriptionUrl().url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WorkoutsQueryResponse, GetV1WorkoutsQueryParams, GetV1WorkoutsHeaderParams, GetV1Workouts400 } from \"../types/GetV1Workouts.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WorkoutsUrl() {\n const res = { method: 'GET', url: `/v1/workouts` as const } \n return res\n}\n\n/**\n * @summary Get a paginated list of workouts\n * {@link /v1/workouts}\n */\nexport async function getV1Workouts(headers: GetV1WorkoutsHeaderParams, params?: GetV1WorkoutsQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WorkoutsQueryResponse, ResponseErrorConfig<GetV1Workouts400>, unknown>({ method : \"GET\", url : getGetV1WorkoutsUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WorkoutsCountQueryResponse, GetV1WorkoutsCountHeaderParams } from \"../types/GetV1WorkoutsCount.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WorkoutsCountUrl() {\n const res = { method: 'GET', url: `/v1/workouts/count` as const } \n return res\n}\n\n/**\n * @summary Get the total number of workouts on the account\n * {@link /v1/workouts/count}\n */\nexport async function getV1WorkoutsCount(headers: GetV1WorkoutsCountHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WorkoutsCountQueryResponse, ResponseErrorConfig<Error>, unknown>({ method : \"GET\", url : getGetV1WorkoutsCountUrl().url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WorkoutsEventsQueryResponse, GetV1WorkoutsEventsQueryParams, GetV1WorkoutsEventsHeaderParams, GetV1WorkoutsEvents500 } from \"../types/GetV1WorkoutsEvents.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WorkoutsEventsUrl() {\n const res = { method: 'GET', url: `/v1/workouts/events` as const } \n return res\n}\n\n/**\n * @description Returns a paginated array of workout events, indicating updates or deletions.\n * @summary Retrieve a paged list of workout events (updates or deletes) since a given date. Events are ordered from newest to oldest. The intention is to allow clients to keep their local cache of workouts up to date without having to fetch the entire list of workouts.\n * {@link /v1/workouts/events}\n */\nexport async function getV1WorkoutsEvents(headers: GetV1WorkoutsEventsHeaderParams, params?: GetV1WorkoutsEventsQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WorkoutsEventsQueryResponse, ResponseErrorConfig<GetV1WorkoutsEvents500>, unknown>({ method : \"GET\", url : getGetV1WorkoutsEventsUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WorkoutsWorkoutidQueryResponse, GetV1WorkoutsWorkoutidPathParams, GetV1WorkoutsWorkoutidHeaderParams, GetV1WorkoutsWorkoutid404 } from \"../types/GetV1WorkoutsWorkoutid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WorkoutsWorkoutidUrl(workoutId: GetV1WorkoutsWorkoutidPathParams[\"workoutId\"]) {\n const res = { method: 'GET', url: `/v1/workouts/${workoutId}` as const } \n return res\n}\n\n/**\n * @summary Get a single workout’s complete details by the workoutId\n * {@link /v1/workouts/:workoutId}\n */\nexport async function getV1WorkoutsWorkoutid(workoutId: GetV1WorkoutsWorkoutidPathParams[\"workoutId\"], headers: GetV1WorkoutsWorkoutidHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WorkoutsWorkoutidQueryResponse, ResponseErrorConfig<GetV1WorkoutsWorkoutid404>, unknown>({ method : \"GET\", url : getGetV1WorkoutsWorkoutidUrl(workoutId).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PostV1RoutineFoldersMutationRequest, PostV1RoutineFoldersMutationResponse, PostV1RoutineFoldersHeaderParams, PostV1RoutineFolders400 } from \"../types/PostV1RoutineFolders.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPostV1RoutineFoldersUrl() {\n const res = { method: 'POST', url: `/v1/routine_folders` as const } \n return res\n}\n\n/**\n * @summary Create a new routine folder. The folder will be created at index 0, and all other folders will have their indexes incremented.\n * {@link /v1/routine_folders}\n */\nexport async function postV1RoutineFolders(headers: PostV1RoutineFoldersHeaderParams, data?: PostV1RoutineFoldersMutationRequest, config: Partial<RequestConfig<PostV1RoutineFoldersMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PostV1RoutineFoldersMutationResponse, ResponseErrorConfig<PostV1RoutineFolders400>, PostV1RoutineFoldersMutationRequest>({ method : \"POST\", url : getPostV1RoutineFoldersUrl().url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PostV1RoutinesMutationRequest, PostV1RoutinesMutationResponse, PostV1RoutinesHeaderParams, PostV1Routines400, PostV1Routines403 } from \"../types/PostV1Routines.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPostV1RoutinesUrl() {\n const res = { method: 'POST', url: `/v1/routines` as const } \n return res\n}\n\n/**\n * @summary Create a new routine\n * {@link /v1/routines}\n */\nexport async function postV1Routines(headers: PostV1RoutinesHeaderParams, data?: PostV1RoutinesMutationRequest, config: Partial<RequestConfig<PostV1RoutinesMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PostV1RoutinesMutationResponse, ResponseErrorConfig<PostV1Routines400 | PostV1Routines403>, PostV1RoutinesMutationRequest>({ method : \"POST\", url : getPostV1RoutinesUrl().url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PostV1WebhookSubscriptionMutationRequest, PostV1WebhookSubscriptionMutationResponse, PostV1WebhookSubscriptionHeaderParams, PostV1WebhookSubscription400 } from \"../types/PostV1WebhookSubscription.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPostV1WebhookSubscriptionUrl() {\n const res = { method: 'POST', url: `/v1/webhook-subscription` as const } \n return res\n}\n\n/**\n * @description This endpoint allows you to create a webhook subscription that will notify your application when a workout is created. Your endpoint must respond with a `200 OK` status within **5 seconds**, otherwise the delivery will be retried.When a new workout is created, we will send a POST request to your provided URL with the following JSON payload:```json { \"id\": \"00000000-0000-0000-0000-000000000001\", \"payload\": { \"workoutId\": \"f1085cdb-32b2-4003-967d-53a3af8eaecb\" }}\n * @summary Create a new webhook subscription.\n * {@link /v1/webhook-subscription}\n */\nexport async function postV1WebhookSubscription(headers: PostV1WebhookSubscriptionHeaderParams, data?: PostV1WebhookSubscriptionMutationRequest, config: Partial<RequestConfig<PostV1WebhookSubscriptionMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PostV1WebhookSubscriptionMutationResponse, ResponseErrorConfig<PostV1WebhookSubscription400>, PostV1WebhookSubscriptionMutationRequest>({ method : \"POST\", url : getPostV1WebhookSubscriptionUrl().url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PostV1WorkoutsMutationRequest, PostV1WorkoutsMutationResponse, PostV1WorkoutsHeaderParams, PostV1Workouts400 } from \"../types/PostV1Workouts.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPostV1WorkoutsUrl() {\n const res = { method: 'POST', url: `/v1/workouts` as const } \n return res\n}\n\n/**\n * @summary Create a new workout\n * {@link /v1/workouts}\n */\nexport async function postV1Workouts(headers: PostV1WorkoutsHeaderParams, data?: PostV1WorkoutsMutationRequest, config: Partial<RequestConfig<PostV1WorkoutsMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PostV1WorkoutsMutationResponse, ResponseErrorConfig<PostV1Workouts400>, PostV1WorkoutsMutationRequest>({ method : \"POST\", url : getPostV1WorkoutsUrl().url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PutV1RoutinesRoutineidMutationRequest, PutV1RoutinesRoutineidMutationResponse, PutV1RoutinesRoutineidPathParams, PutV1RoutinesRoutineidHeaderParams, PutV1RoutinesRoutineid400, PutV1RoutinesRoutineid404 } from \"../types/PutV1RoutinesRoutineid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPutV1RoutinesRoutineidUrl(routineId: PutV1RoutinesRoutineidPathParams[\"routineId\"]) {\n const res = { method: 'PUT', url: `/v1/routines/${routineId}` as const } \n return res\n}\n\n/**\n * @summary Update an existing routine\n * {@link /v1/routines/:routineId}\n */\nexport async function putV1RoutinesRoutineid(routineId: PutV1RoutinesRoutineidPathParams[\"routineId\"], headers: PutV1RoutinesRoutineidHeaderParams, data?: PutV1RoutinesRoutineidMutationRequest, config: Partial<RequestConfig<PutV1RoutinesRoutineidMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PutV1RoutinesRoutineidMutationResponse, ResponseErrorConfig<PutV1RoutinesRoutineid400 | PutV1RoutinesRoutineid404>, PutV1RoutinesRoutineidMutationRequest>({ method : \"PUT\", url : getPutV1RoutinesRoutineidUrl(routineId).url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PutV1WorkoutsWorkoutidMutationRequest, PutV1WorkoutsWorkoutidMutationResponse, PutV1WorkoutsWorkoutidPathParams, PutV1WorkoutsWorkoutidHeaderParams, PutV1WorkoutsWorkoutid400 } from \"../types/PutV1WorkoutsWorkoutid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPutV1WorkoutsWorkoutidUrl(workoutId: PutV1WorkoutsWorkoutidPathParams[\"workoutId\"]) {\n const res = { method: 'PUT', url: `/v1/workouts/${workoutId}` as const } \n return res\n}\n\n/**\n * @summary Update an existing workout\n * {@link /v1/workouts/:workoutId}\n */\nexport async function putV1WorkoutsWorkoutid(workoutId: PutV1WorkoutsWorkoutidPathParams[\"workoutId\"], headers: PutV1WorkoutsWorkoutidHeaderParams, data?: PutV1WorkoutsWorkoutidMutationRequest, config: Partial<RequestConfig<PutV1WorkoutsWorkoutidMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PutV1WorkoutsWorkoutidMutationResponse, ResponseErrorConfig<PutV1WorkoutsWorkoutid400>, PutV1WorkoutsWorkoutidMutationRequest>({ method : \"PUT\", url : getPutV1WorkoutsWorkoutidUrl(workoutId).url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","// Import the Kubb-based client\nimport { createClient as createKubbClient } from \"./hevyClientKubb.js\";\n\nexport function createClient(apiKey: string, baseUrl: string) {\n\treturn createKubbClient(apiKey, baseUrl);\n}\n\n// Export the HevyClient type for use in other modules\nexport type HevyClient = ReturnType<typeof createClient>;\n","import { runServer } from \"./index.js\";\n\nvoid runServer().catch((error) => {\n\tconsole.error(\"Fatal error in main():\", error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;AAAA,OAAO,aAAa;AACpB,YAAY,YAAY;AAgBxB,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,KAAAA,UAAS;;;AClBjB,WAAQ;AACR,cAAW;;;ACDZ,SAAS,SAAS;;;ACwCX,SAAS,oBACf,OACA,SACkB;AAClB,QAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAE1E,QAAM,YACL,iBAAiB,SAAS,UAAU,QAChC,MAA4B,OAC7B;AAGJ,QAAM,YAAY,mBAAmB,OAAO,YAAY;AAGxD,MAAI,WAAW;AACd,YAAQ,MAAM,eAAe,SAAS,EAAE;AAAA,EACzC;AAEA,QAAM,gBAAgB,UAAU,IAAI,OAAO,OAAO;AAClD,QAAM,mBAAmB,GAAG,aAAa,UAAU,YAAY;AAG/D,UAAQ,MAAM,GAAG,gBAAgB,WAAW,SAAS,KAAK,KAAK;AAE/D,SAAO;AAAA,IACN,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,MAAM;AAAA,MACP;AAAA,IACD;AAAA,IACA,SAAS;AAAA,EACV;AACD;AAKA,SAAS,mBAAmB,OAAgB,SAA4B;AACvE,QAAM,eAAe,QAAQ,YAAY;AACzC,QAAM,YAAY,iBAAiB,QAAQ,MAAM,KAAK,YAAY,IAAI;AAEtE,MACC,UAAU,SAAS,SAAS,KAC5B,aAAa,SAAS,SAAS,KAC/B,UAAU,SAAS,OAAO,KAC1B,aAAa,SAAS,OAAO,KAC7B,UAAU,SAAS,SAAS,KAC5B,aAAa,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QAAQ,gBAAgB;AACxD,UAAQ,MAAM,sCAAsC;AAEpD,uBAAqB,QAAQ,UAAU;AACvC,uBAAqB,QAAQ,UAAU;AACvC,wBAAsB,QAAQ,UAAU;AACxC,sBAAoB,QAAQ,UAAU;AACtC,uBAAqB,QAAQ,UAAU;AAEvC,SAAO;AACR;AAQA,eAAsB,YAAY;AACjC,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,QAAM,MAAM,YAAY,MAAM,QAAQ,GAAG;AACzC,QAAM,SAAS,IAAI;AACnB,eAAa,MAAM;AAEnB,QAAM,SAAS,YAAY,MAAM;AACjC,UAAQ,MAAM,mCAAmC;AACjD,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAC/B;;;A+B1EA,KAAK,UAAU,EAAE,MAAM,CAAC,UAAU;AACjC,UAAQ,MAAM,0BAA0B,KAAK;AAC7C,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["z","name","z","z","z","z","z","z","z","z","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","createClient","z","createClient"]}
1
+ {"version":3,"sources":["../src/index.ts","../package.json","../src/tools/folders.ts","../src/utils/error-handler.ts","../src/utils/formatters.ts","../src/utils/response-formatter.ts","../src/tools/routines.ts","../src/tools/templates.ts","../src/tools/webhooks.ts","../src/tools/workouts.ts","../src/utils/config.ts","../src/utils/hevyClientKubb.ts","../src/generated/client/api/deleteV1WebhookSubscription.ts","../src/generated/client/api/getV1ExerciseTemplates.ts","../src/generated/client/api/getV1ExerciseTemplatesExercisetemplateid.ts","../src/generated/client/api/getV1RoutineFolders.ts","../src/generated/client/api/getV1RoutineFoldersFolderid.ts","../src/generated/client/api/getV1Routines.ts","../src/generated/client/api/getV1RoutinesRoutineid.ts","../src/generated/client/api/getV1WebhookSubscription.ts","../src/generated/client/api/getV1Workouts.ts","../src/generated/client/api/getV1WorkoutsCount.ts","../src/generated/client/api/getV1WorkoutsEvents.ts","../src/generated/client/api/getV1WorkoutsWorkoutid.ts","../src/generated/client/api/postV1RoutineFolders.ts","../src/generated/client/api/postV1Routines.ts","../src/generated/client/api/postV1WebhookSubscription.ts","../src/generated/client/api/postV1Workouts.ts","../src/generated/client/api/putV1RoutinesRoutineid.ts","../src/generated/client/api/putV1WorkoutsWorkoutid.ts","../src/utils/hevyClient.ts","../src/cli.ts"],"sourcesContent":["import dotenvx from \"@dotenvx/dotenvx\";\nimport * as Sentry from \"@sentry/node\";\n\n// Configure dotenvx with quiet mode to prevent stdout pollution in stdio mode\ndotenvx.config({ quiet: true });\n\n// Sentry monitoring is baked into the built MCP server so usage and errors\n// from users of the published package are captured for observability.\nconst sentryConfig = {\n\tdsn: \"https://ce696d8333b507acbf5203eb877bce0f@o4508975499575296.ingest.de.sentry.io/4509049671647312\",\n\t// Tracing must be enabled for MCP monitoring to work\n\ttracesSampleRate: 1.0,\n\tsendDefaultPii: false,\n} as const;\n\nSentry.init(sentryConfig);\n\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { z } from \"zod\";\nimport { name, version } from \"../package.json\";\nimport { registerFolderTools } from \"./tools/folders.js\";\nimport { registerRoutineTools } from \"./tools/routines.js\";\nimport { registerTemplateTools } from \"./tools/templates.js\";\nimport { registerWebhookTools } from \"./tools/webhooks.js\";\nimport { registerWorkoutTools } from \"./tools/workouts.js\";\nimport { assertApiKey, parseConfig } from \"./utils/config.js\";\nimport { createClient } from \"./utils/hevyClient.js\";\n\nconst HEVY_API_BASEURL = \"https://api.hevyapp.com\";\n\nconst serverConfigSchema = z.object({\n\tapiKey: z\n\t\t.string()\n\t\t.min(1, \"Hevy API key is required\")\n\t\t.describe(\"Your Hevy API key (available in the Hevy app settings).\"),\n});\n\nexport const configSchema = serverConfigSchema;\ntype ServerConfig = z.infer<typeof serverConfigSchema>;\n\nfunction buildServer(apiKey: string) {\n\tconst baseServer = new McpServer({\n\t\tname,\n\t\tversion,\n\t});\n\tconst server = Sentry.wrapMcpServerWithSentry(baseServer);\n\n\tconst hevyClient = createClient(apiKey, HEVY_API_BASEURL);\n\tconsole.error(\"Hevy client initialized with API key\");\n\n\tregisterWorkoutTools(server, hevyClient);\n\tregisterRoutineTools(server, hevyClient);\n\tregisterTemplateTools(server, hevyClient);\n\tregisterFolderTools(server, hevyClient);\n\tregisterWebhookTools(server, hevyClient);\n\n\treturn server;\n}\n\nexport default function createServer({ config }: { config: ServerConfig }) {\n\tconst { apiKey } = serverConfigSchema.parse(config);\n\tconst server = buildServer(apiKey);\n\treturn server.server;\n}\n\nexport async function runServer() {\n\tconst args = process.argv.slice(2);\n\tconst cfg = parseConfig(args, process.env);\n\tconst apiKey = cfg.apiKey;\n\tassertApiKey(apiKey);\n\n\tconst server = buildServer(apiKey);\n\tconsole.error(\"Starting MCP server in stdio mode\");\n\tconst transport = new StdioServerTransport();\n\tawait server.connect(transport);\n}\n","{\n\t\"name\": \"hevy-mcp\",\n\t\"version\": \"1.14.0\",\n\t\"main\": \"dist/index.js\",\n\t\"module\": \"src/index.ts\",\n\t\"types\": \"dist/index.d.ts\",\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"README.md\"\n\t],\n\t\"access\": \"public\",\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/chrisdoc/hevy-mcp/issues\"\n\t},\n\t\"homepage\": \"https://github.com/chrisdoc/hevy-mcp#readme\",\n\t\"bin\": {\n\t\t\"hevy-mcp\": \"dist/cli.js\"\n\t},\n\t\"scripts\": {\n\t\t\"inspect\": \"pnpm run build && dotenvx run -- pnpm dlx @modelcontextprotocol/inspector@latest node dist/index.js\",\n\t\t\"inspect:npm\": \"dotenvx run -- pnpm dlx @modelcontextprotocol/inspector@latest pnpm dlx hevy-mcp@latest\",\n\t\t\"test\": \"vitest --run\",\n\t\t\"export-specs\": \"node ./scripts/export-openapi-spec.js\",\n\t\t\"build\": \"tsup\",\n\t\t\"build:client\": \"kubb generate\",\n\t\t\"start\": \"node dist/cli.js\",\n\t\t\"dev\": \"tsx watch --clear-screen=false src/cli.ts\",\n\t\t\"smithery:build\": \"smithery build\",\n\t\t\"smithery:dev\": \"smithery dev\",\n\t\t\"check\": \"biome check --write --unsafe\",\n\t\t\"check:types\": \"tsc --noEmit\",\n\t\t\"version:patch\": \"pnpm version patch\",\n\t\t\"version:minor\": \"pnpm version minor\",\n\t\t\"version:major\": \"pnpm version major\",\n\t\t\"release\": \"semantic-release\",\n\t\t\"commit\": \"commit\"\n\t},\n\t\"type\": \"module\",\n\t\"keywords\": [\n\t\t\"mcp\",\n\t\t\"hevy\",\n\t\t\"fitness\",\n\t\t\"api\",\n\t\t\"model context protocol\"\n\t],\n\t\"author\": \"Christoph Kieslich\",\n\t\"license\": \"MIT\",\n\t\"description\": \"A Model Context Protocol (MCP) server implementation that interfaces with the Hevy fitness tracking app and its API.\",\n\t\"dependencies\": {\n\t\t\"@dotenvx/dotenvx\": \"^1.51.1\",\n\t\t\"@kubb/cli\": \"^4.7.2\",\n\t\t\"@kubb/core\": \"^4.7.2\",\n\t\t\"@kubb/plugin-client\": \"^4.7.2\",\n\t\t\"@kubb/plugin-faker\": \"^4.7.2\",\n\t\t\"@kubb/plugin-oas\": \"^4.7.2\",\n\t\t\"@kubb/plugin-ts\": \"^4.7.2\",\n\t\t\"@kubb/plugin-zod\": \"^4.7.2\",\n\t\t\"@modelcontextprotocol/sdk\": \"^1.23.0\",\n\t\t\"@sentry/node\": \"^9.47.1\",\n\t\t\"@smithery/sdk\": \"2.1.0\",\n\t\t\"axios\": \"^1.13.2\",\n\t\t\"chalk\": \"^5.6.2\",\n\t\t\"cors\": \"^2.8.5\",\n\t\t\"express\": \"5.2.1\",\n\t\t\"zod\": \"^4.1.13\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@biomejs/biome\": \"2.3.8\",\n\t\t\"@commitlint/cli\": \"^20.1.0\",\n\t\t\"@commitlint/config-conventional\": \"^20.0.0\",\n\t\t\"@commitlint/prompt-cli\": \"^20.1.0\",\n\t\t\"@semantic-release/changelog\": \"^6.0.3\",\n\t\t\"@semantic-release/commit-analyzer\": \"^13.0.1\",\n\t\t\"@semantic-release/git\": \"^10.0.1\",\n\t\t\"@semantic-release/github\": \"^12.0.2\",\n\t\t\"@semantic-release/npm\": \"^13.1.2\",\n\t\t\"@semantic-release/release-notes-generator\": \"^14.1.0\",\n\t\t\"@smithery/cli\": \"^1.6.3\",\n\t\t\"@types/node\": \"^24.10.1\",\n\t\t\"@vitest/coverage-v8\": \"^4.0.14\",\n\t\t\"abstract-syntax-tree\": \"^2.22.0\",\n\t\t\"cross-env\": \"^10.1.0\",\n\t\t\"lefthook\": \"^2.0.4\",\n\t\t\"semantic-release\": \"^25.0.2\",\n\t\t\"tsup\": \"^8.5.1\",\n\t\t\"tsx\": \"^4.20.6\",\n\t\t\"typescript\": \"^5.9.3\",\n\t\t\"vitest\": \"^4.0.14\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=20.0.0\"\n\t},\n\t\"packageManager\": \"pnpm@10.22.0+sha512.bf049efe995b28f527fd2b41ae0474ce29186f7edcb3bf545087bd61fbbebb2bf75362d1307fda09c2d288e1e499787ac12d4fcb617a974718a6051f2eee741c\"\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\n// Import types from generated client\nimport type { RoutineFolder } from \"../generated/client/types/index.js\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport { formatRoutineFolder } from \"../utils/formatters.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\n// Type definitions for the folder operations\ntype HevyClient = ReturnType<\n\ttypeof import(\"../utils/hevyClientKubb.js\").createClient\n>;\n\n/**\n * Register all routine folder-related tools with the MCP server\n */\nexport function registerFolderTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get routine folders\n\tconst getRoutineFoldersSchema = {\n\t\tpage: z.coerce.number().int().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(10).default(5),\n\t} as const;\n\ttype GetRoutineFoldersParams = InferToolParams<\n\t\ttypeof getRoutineFoldersSchema\n\t>;\n\n\tserver.tool(\n\t\t\"get-routine-folders\",\n\t\t\"Get a paginated list of your routine folders, including both default and custom folders. Useful for organizing and browsing your workout routines.\",\n\t\tgetRoutineFoldersSchema,\n\t\twithErrorHandling(async (args: GetRoutineFoldersParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize } = args;\n\t\t\tconst data = await hevyClient.getRoutineFolders({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t});\n\n\t\t\t// Process routine folders to extract relevant information\n\t\t\tconst folders =\n\t\t\t\tdata?.routine_folders?.map((folder: RoutineFolder) =>\n\t\t\t\t\tformatRoutineFolder(folder),\n\t\t\t\t) || [];\n\n\t\t\tif (folders.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No routine folders found for the specified parameters\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(folders);\n\t\t}, \"get-routine-folders\"),\n\t);\n\n\t// Get single routine folder by ID\n\tconst getRoutineFolderSchema = {\n\t\tfolderId: z.string().min(1),\n\t} as const;\n\ttype GetRoutineFolderParams = InferToolParams<typeof getRoutineFolderSchema>;\n\n\tserver.tool(\n\t\t\"get-routine-folder\",\n\t\t\"Get complete details of a specific routine folder by its ID, including name, creation date, and associated routines.\",\n\t\tgetRoutineFolderSchema,\n\t\twithErrorHandling(async (args: GetRoutineFolderParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { folderId } = args;\n\t\t\tconst data = await hevyClient.getRoutineFolder(folderId);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`Routine folder with ID ${folderId} not found`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst folder = formatRoutineFolder(data);\n\t\t\treturn createJsonResponse(folder);\n\t\t}, \"get-routine-folder\"),\n\t);\n\n\t// Create new routine folder\n\tconst createRoutineFolderSchema = {\n\t\tname: z.string().min(1),\n\t} as const;\n\ttype CreateRoutineFolderParams = InferToolParams<\n\t\ttypeof createRoutineFolderSchema\n\t>;\n\n\tserver.tool(\n\t\t\"create-routine-folder\",\n\t\t\"Create a new routine folder in your Hevy account. Requires a name for the folder. Returns the full folder details including the new folder ID.\",\n\t\tcreateRoutineFolderSchema,\n\t\twithErrorHandling(async (args: CreateRoutineFolderParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { name } = args;\n\t\t\tconst data = await hevyClient.createRoutineFolder({\n\t\t\t\troutine_folder: {\n\t\t\t\t\ttitle: name,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to create routine folder: Server returned no data\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst folder = formatRoutineFolder(data);\n\t\t\treturn createJsonResponse(folder, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"create-routine-folder\"),\n\t);\n}\n","/**\n * Centralized error handling utility for MCP tools\n */\n\n// Import the McpToolResponse type from response-formatter to ensure consistency\nimport type { McpToolResponse } from \"./response-formatter.js\";\n\n/**\n * Standard error response interface\n */\nexport interface ErrorResponse {\n\tmessage: string;\n\tcode?: string;\n\tdetails?: unknown;\n}\n\n/**\n * Specific error types for better categorization\n */\nexport enum ErrorType {\n\tAPI_ERROR = \"API_ERROR\",\n\tVALIDATION_ERROR = \"VALIDATION_ERROR\",\n\tNOT_FOUND = \"NOT_FOUND\",\n\tNETWORK_ERROR = \"NETWORK_ERROR\",\n\tUNKNOWN_ERROR = \"UNKNOWN_ERROR\",\n}\n\n/**\n * Enhanced error response with type categorization\n */\nexport interface EnhancedErrorResponse extends ErrorResponse {\n\ttype: ErrorType;\n}\n\n/**\n * Create a standardized error response for MCP tools\n *\n * @param error - The error object or message\n * @param context - Optional context information about where the error occurred\n * @returns A formatted MCP tool response with error information\n */\nexport function createErrorResponse(\n\terror: unknown,\n\tcontext?: string,\n): McpToolResponse {\n\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t// Extract error code if available (for logging purposes)\n\tconst errorCode =\n\t\terror instanceof Error && \"code\" in error\n\t\t\t? (error as { code?: string }).code\n\t\t\t: undefined;\n\n\t// Determine error type based on error characteristics\n\tconst errorType = determineErrorType(error, errorMessage);\n\n\t// Include error code in logs if available\n\tif (errorCode) {\n\t\tconsole.debug(`Error code: ${errorCode}`);\n\t}\n\n\tconst contextPrefix = context ? `[${context}] ` : \"\";\n\tconst formattedMessage = `${contextPrefix}Error: ${errorMessage}`;\n\n\t// Log the error for server-side debugging with type information\n\tconsole.error(`${formattedMessage} (Type: ${errorType})`, error);\n\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\" as const,\n\t\t\t\ttext: formattedMessage,\n\t\t\t},\n\t\t],\n\t\tisError: true,\n\t};\n}\n\n/**\n * Determine the type of error based on error characteristics\n */\nfunction determineErrorType(error: unknown, message: string): ErrorType {\n\tconst messageLower = message.toLowerCase();\n\tconst nameLower = error instanceof Error ? error.name.toLowerCase() : \"\";\n\n\tif (\n\t\tnameLower.includes(\"network\") ||\n\t\tmessageLower.includes(\"network\") ||\n\t\tnameLower.includes(\"fetch\") ||\n\t\tmessageLower.includes(\"fetch\") ||\n\t\tnameLower.includes(\"timeout\") ||\n\t\tmessageLower.includes(\"timeout\")\n\t) {\n\t\treturn ErrorType.NETWORK_ERROR;\n\t}\n\n\tif (\n\t\tnameLower.includes(\"validation\") ||\n\t\tmessageLower.includes(\"validation\") ||\n\t\tmessageLower.includes(\"invalid\") ||\n\t\tmessageLower.includes(\"required\")\n\t) {\n\t\treturn ErrorType.VALIDATION_ERROR;\n\t}\n\n\tif (\n\t\tmessageLower.includes(\"not found\") ||\n\t\tmessageLower.includes(\"404\") ||\n\t\tmessageLower.includes(\"does not exist\")\n\t) {\n\t\treturn ErrorType.NOT_FOUND;\n\t}\n\n\tif (\n\t\tnameLower.includes(\"api\") ||\n\t\tmessageLower.includes(\"api\") ||\n\t\tmessageLower.includes(\"server error\") ||\n\t\tmessageLower.includes(\"500\")\n\t) {\n\t\treturn ErrorType.API_ERROR;\n\t}\n\n\treturn ErrorType.UNKNOWN_ERROR;\n}\n\n/**\n * Wrap an async function with standardized error handling\n *\n * This function preserves the parameter types of the wrapped function while\n * providing error handling. The returned function accepts Record<string, unknown>\n * (as required by MCP SDK) but internally casts to the original parameter type.\n *\n * @param fn - The async function to wrap\n * @param context - Context information for error messages\n * @returns A function that catches errors and returns standardized error responses\n */\nexport function withErrorHandling<TParams extends Record<string, unknown>>(\n\tfn: (args: TParams) => Promise<McpToolResponse>,\n\tcontext: string,\n): (args: Record<string, unknown>) => Promise<McpToolResponse> {\n\treturn async (args: Record<string, unknown>) => {\n\t\ttry {\n\t\t\treturn await fn(args as TParams);\n\t\t} catch (error) {\n\t\t\treturn createErrorResponse(error, context);\n\t\t}\n\t};\n}\n","import type {\n\tExerciseTemplate,\n\tRoutine,\n\tRoutineFolder,\n\tWorkout,\n} from \"../generated/client/types/index.js\";\n\n/**\n * Formatted workout set interface\n */\nexport interface FormattedWorkoutSet {\n\tindex: number | undefined;\n\ttype: string | undefined;\n\tweight: number | undefined | null;\n\treps: number | undefined | null;\n\tdistance: number | undefined | null;\n\tduration: number | undefined | null;\n\trpe: number | undefined | null;\n\tcustomMetric: number | undefined | null;\n}\n\n/**\n * Formatted workout exercise interface\n */\nexport interface FormattedWorkoutExercise {\n\tindex: number | undefined;\n\tname: string | undefined;\n\texerciseTemplateId: string | undefined;\n\tnotes: string | undefined | null;\n\tsupersetsId: number | undefined | null;\n\tsets: FormattedWorkoutSet[] | undefined;\n}\n\n/**\n * Formatted workout interface\n */\nexport interface FormattedWorkout {\n\tid: string | undefined;\n\ttitle: string | undefined;\n\tdescription: string | undefined | null;\n\tstartTime: number | undefined;\n\tendTime: number | undefined;\n\tcreatedAt: string | undefined;\n\tupdatedAt: string | undefined;\n\tduration: string;\n\texercises: FormattedWorkoutExercise[] | undefined;\n}\n\n/**\n * Formatted routine set interface\n */\nexport interface FormattedRoutineSet {\n\tindex: number | undefined;\n\ttype: string | undefined;\n\tweight: number | undefined | null;\n\treps: number | undefined | null;\n\tdistance: number | undefined | null;\n\tduration: number | undefined | null;\n\tcustomMetric: number | undefined | null;\n\trepRange?: { start?: number | null; end?: number | null } | undefined | null;\n\trpe?: number | undefined | null;\n}\n\n/**\n * Formatted routine exercise interface\n */\nexport interface FormattedRoutineExercise {\n\tname: string | undefined;\n\tindex: number | undefined;\n\texerciseTemplateId: string | undefined;\n\tnotes: string | undefined | null;\n\tsupersetId: number | undefined | null;\n\trestSeconds: string | undefined;\n\tsets: FormattedRoutineSet[] | undefined;\n}\n\n/**\n * Formatted routine interface\n */\nexport interface FormattedRoutine {\n\tid: string | undefined;\n\ttitle: string | undefined;\n\tfolderId: number | undefined | null;\n\tcreatedAt: string | undefined;\n\tupdatedAt: string | undefined;\n\texercises: FormattedRoutineExercise[] | undefined;\n}\n\n/**\n * Formatted routine folder interface\n */\nexport interface FormattedRoutineFolder {\n\tid: number | undefined;\n\ttitle: string | undefined;\n\tcreatedAt: string | undefined;\n\tupdatedAt: string | undefined;\n}\n\n/**\n * Formatted exercise template interface\n */\nexport interface FormattedExerciseTemplate {\n\tid: string | undefined;\n\ttitle: string | undefined;\n\ttype: string | undefined;\n\tprimaryMuscleGroup: string | undefined;\n\tsecondaryMuscleGroups: string[] | undefined;\n\tisCustom: boolean | undefined;\n}\n\n/**\n * Format a workout object for consistent presentation\n *\n * @param workout - The workout object from the API\n * @returns A formatted workout object with standardized properties\n */\nexport function formatWorkout(workout: Workout): FormattedWorkout {\n\treturn {\n\t\tid: workout.id,\n\t\ttitle: workout.title,\n\t\tdescription: workout.description,\n\t\tstartTime: workout.start_time,\n\t\tendTime: workout.end_time,\n\t\tcreatedAt: workout.created_at,\n\t\tupdatedAt: workout.updated_at,\n\t\tduration: calculateDuration(workout.start_time, workout.end_time),\n\t\texercises: workout.exercises?.map((exercise) => {\n\t\t\treturn {\n\t\t\t\tindex: exercise.index,\n\t\t\t\tname: exercise.title,\n\t\t\t\texerciseTemplateId: exercise.exercise_template_id,\n\t\t\t\tnotes: exercise.notes,\n\t\t\t\tsupersetsId: exercise.supersets_id,\n\t\t\t\tsets: exercise.sets?.map((set) => ({\n\t\t\t\t\tindex: set.index,\n\t\t\t\t\ttype: set.type,\n\t\t\t\t\tweight: set.weight_kg,\n\t\t\t\t\treps: set.reps,\n\t\t\t\t\tdistance: set.distance_meters,\n\t\t\t\t\tduration: set.duration_seconds,\n\t\t\t\t\trpe: set.rpe,\n\t\t\t\t\tcustomMetric: set.custom_metric,\n\t\t\t\t})),\n\t\t\t};\n\t\t}),\n\t};\n}\n\n/**\n * Format a routine object for consistent presentation\n *\n * @param routine - The routine object from the API\n * @returns A formatted routine object with standardized properties\n */\nexport function formatRoutine(routine: Routine): FormattedRoutine {\n\treturn {\n\t\tid: routine.id,\n\t\ttitle: routine.title,\n\t\tfolderId: routine.folder_id,\n\t\tcreatedAt: routine.created_at,\n\t\tupdatedAt: routine.updated_at,\n\t\texercises: routine.exercises?.map((exercise) => {\n\t\t\treturn {\n\t\t\t\tname: exercise.title,\n\t\t\t\tindex: exercise.index,\n\t\t\t\texerciseTemplateId: exercise.exercise_template_id,\n\t\t\t\tnotes: exercise.notes,\n\t\t\t\tsupersetId: exercise.supersets_id,\n\t\t\t\trestSeconds: exercise.rest_seconds,\n\t\t\t\tsets: exercise.sets?.map((set) => ({\n\t\t\t\t\tindex: set.index,\n\t\t\t\t\ttype: set.type,\n\t\t\t\t\tweight: set.weight_kg,\n\t\t\t\t\treps: set.reps,\n\t\t\t\t\t...(set.rep_range !== undefined && { repRange: set.rep_range }),\n\t\t\t\t\tdistance: set.distance_meters,\n\t\t\t\t\tduration: set.duration_seconds,\n\t\t\t\t\t...(set.rpe !== undefined && { rpe: set.rpe }),\n\t\t\t\t\tcustomMetric: set.custom_metric,\n\t\t\t\t})),\n\t\t\t};\n\t\t}),\n\t};\n}\n\n/**\n * Format a routine folder object for consistent presentation\n *\n * @param folder - The routine folder object from the API\n * @returns A formatted routine folder object with standardized properties\n */\nexport function formatRoutineFolder(\n\tfolder: RoutineFolder,\n): FormattedRoutineFolder {\n\treturn {\n\t\tid: folder.id,\n\t\ttitle: folder.title,\n\t\tcreatedAt: folder.created_at,\n\t\tupdatedAt: folder.updated_at,\n\t};\n}\n\n/**\n * Calculate duration between two ISO timestamp strings\n *\n * @param startTime - The start time as ISO string or timestamp\n * @param endTime - The end time as ISO string or timestamp\n * @returns A formatted duration string (e.g. \"1h 30m 45s\") or \"Unknown duration\" if inputs are invalid\n */\nexport function calculateDuration(\n\tstartTime: string | number | null | undefined,\n\tendTime: string | number | null | undefined,\n): string {\n\tif (!startTime || !endTime) return \"Unknown duration\";\n\n\ttry {\n\t\tconst start = new Date(startTime);\n\t\tconst end = new Date(endTime);\n\n\t\t// Validate dates\n\t\tif (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime())) {\n\t\t\treturn \"Unknown duration\";\n\t\t}\n\n\t\tconst durationMs = end.getTime() - start.getTime();\n\n\t\t// Handle negative durations\n\t\tif (durationMs < 0) {\n\t\t\treturn \"Invalid duration (end time before start time)\";\n\t\t}\n\n\t\tconst hours = Math.floor(durationMs / (1000 * 60 * 60));\n\t\tconst minutes = Math.floor((durationMs % (1000 * 60 * 60)) / (1000 * 60));\n\t\tconst seconds = Math.floor((durationMs % (1000 * 60)) / 1000);\n\n\t\treturn `${hours}h ${minutes}m ${seconds}s`;\n\t} catch (error) {\n\t\tconsole.error(\"Error calculating duration:\", error);\n\t\treturn \"Unknown duration\";\n\t}\n}\n\n/**\n * Format an exercise template object for consistent presentation\n *\n * @param template - The exercise template object from the API\n * @returns A formatted exercise template object with standardized properties\n */\nexport function formatExerciseTemplate(\n\ttemplate: ExerciseTemplate,\n): FormattedExerciseTemplate {\n\treturn {\n\t\tid: template.id,\n\t\ttitle: template.title,\n\t\ttype: template.type,\n\t\tprimaryMuscleGroup: template.primary_muscle_group,\n\t\tsecondaryMuscleGroups: template.secondary_muscle_groups,\n\t\tisCustom: template.is_custom,\n\t};\n}\n","/**\n * MCP Tool Response type\n */\nexport interface McpToolResponse {\n\t[x: string]: unknown;\n\tcontent: Array<{\n\t\ttype: \"text\";\n\t\ttext: string;\n\t}>;\n}\n\n/**\n * Format options for JSON responses\n */\nexport interface JsonFormatOptions {\n\t/** Whether to pretty-print the JSON with indentation */\n\tpretty?: boolean;\n\t/** Indentation spaces for pretty-printing (default: 2) */\n\tindent?: number;\n}\n\n/**\n * Create a standardized success response with JSON data\n *\n * @param data - The data to include in the response\n * @param options - Formatting options\n * @returns A formatted MCP tool response with the data as JSON\n */\nexport function createJsonResponse(\n\tdata: unknown,\n\toptions: JsonFormatOptions = { pretty: true, indent: 2 },\n): McpToolResponse {\n\tconst jsonString = options.pretty\n\t\t? JSON.stringify(data, null, options.indent)\n\t\t: JSON.stringify(data);\n\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\" as const,\n\t\t\t\ttext: jsonString,\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Create a standardized success response with text data\n *\n * @param message - The text message to include in the response\n * @returns A formatted MCP tool response with the text message\n */\nexport function createTextResponse(message: string): McpToolResponse {\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\" as const,\n\t\t\t\ttext: message,\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Create a standardized success response for empty or null results\n *\n * @param message - Optional message to include (default: \"No data found\")\n * @returns A formatted MCP tool response for empty results\n */\nexport function createEmptyResponse(\n\tmessage = \"No data found\",\n): McpToolResponse {\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\" as const,\n\t\t\t\ttext: message,\n\t\t\t},\n\t\t],\n\t};\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\n// Import types from generated client\nimport type {\n\tPostRoutinesRequestExercise,\n\tPostRoutinesRequestSet,\n\tPostRoutinesRequestSetTypeEnumKey,\n\tPutRoutinesRequestExercise,\n\tPutRoutinesRequestSet,\n\tPutRoutinesRequestSetTypeEnumKey,\n\tRoutine,\n} from \"../generated/client/types/index.js\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport { formatRoutine } from \"../utils/formatters.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\n// Type definitions for the routine operations\ntype HevyClient = ReturnType<\n\ttypeof import(\"../utils/hevyClientKubb.js\").createClient\n>;\n\n/**\n * Register all routine-related tools with the MCP server\n */\nexport function registerRoutineTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get routines\n\tconst getRoutinesSchema = {\n\t\tpage: z.coerce.number().int().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(10).default(5),\n\t} as const;\n\ttype GetRoutinesParams = InferToolParams<typeof getRoutinesSchema>;\n\n\tserver.tool(\n\t\t\"get-routines\",\n\t\t\"Get a paginated list of your workout routines, including custom and default routines. Useful for browsing or searching your available routines.\",\n\t\tgetRoutinesSchema,\n\t\twithErrorHandling(async (args: GetRoutinesParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize } = args;\n\t\t\tconst data = await hevyClient.getRoutines({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t});\n\n\t\t\t// Process routines to extract relevant information\n\t\t\tconst routines =\n\t\t\t\tdata?.routines?.map((routine: Routine) => formatRoutine(routine)) || [];\n\n\t\t\tif (routines.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No routines found for the specified parameters\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(routines);\n\t\t}, \"get-routines\"),\n\t);\n\n\t// Get single routine by ID (new, direct endpoint)\n\tconst getRoutineSchema = {\n\t\troutineId: z.string().min(1),\n\t} as const;\n\ttype GetRoutineParams = InferToolParams<typeof getRoutineSchema>;\n\n\tserver.tool(\n\t\t\"get-routine\",\n\t\t\"Get a routine by its ID using the direct endpoint. Returns all details for the specified routine.\",\n\t\tgetRoutineSchema,\n\t\twithErrorHandling(async (args: GetRoutineParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { routineId } = args;\n\t\t\tconst data = await hevyClient.getRoutineById(String(routineId));\n\t\t\tif (!data || !data.routine) {\n\t\t\t\treturn createEmptyResponse(`Routine with ID ${routineId} not found`);\n\t\t\t}\n\t\t\tconst routine = formatRoutine(data.routine);\n\t\t\treturn createJsonResponse(routine);\n\t\t}, \"get-routine\"),\n\t);\n\n\t// Create new routine\n\tconst createRoutineSchema = {\n\t\ttitle: z.string().min(1),\n\t\tfolderId: z.coerce.number().nullable().optional(),\n\t\tnotes: z.string().optional(),\n\t\texercises: z.array(\n\t\t\tz.object({\n\t\t\t\texerciseTemplateId: z.string().min(1),\n\t\t\t\tsupersetId: z.coerce.number().nullable().optional(),\n\t\t\t\trestSeconds: z.coerce.number().int().min(0).optional(),\n\t\t\t\tnotes: z.string().optional(),\n\t\t\t\tsets: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z\n\t\t\t\t\t\t\t.enum([\"warmup\", \"normal\", \"failure\", \"dropset\"])\n\t\t\t\t\t\t\t.default(\"normal\"),\n\t\t\t\t\t\tweight: z.coerce.number().optional(),\n\t\t\t\t\t\tweightKg: z.coerce.number().optional(),\n\t\t\t\t\t\treps: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdistance: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdistanceMeters: z.coerce.number().int().optional(),\n\t\t\t\t\t\tduration: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdurationSeconds: z.coerce.number().int().optional(),\n\t\t\t\t\t\tcustomMetric: z.coerce.number().optional(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t} as const;\n\ttype CreateRoutineParams = InferToolParams<typeof createRoutineSchema>;\n\n\tserver.tool(\n\t\t\"create-routine\",\n\t\t\"Create a new workout routine in your Hevy account. Requires a title and at least one exercise with sets. Optionally assign to a folder. Returns the full routine details including the new routine ID.\",\n\t\tcreateRoutineSchema,\n\t\twithErrorHandling(async (args: CreateRoutineParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { title, folderId, notes, exercises } = args;\n\t\t\tconst data = await hevyClient.createRoutine({\n\t\t\t\troutine: {\n\t\t\t\t\ttitle,\n\t\t\t\t\tfolder_id: folderId ?? null,\n\t\t\t\t\tnotes: notes ?? \"\",\n\t\t\t\t\texercises: exercises.map(\n\t\t\t\t\t\t(exercise): PostRoutinesRequestExercise => ({\n\t\t\t\t\t\t\texercise_template_id: exercise.exerciseTemplateId,\n\t\t\t\t\t\t\tsuperset_id: exercise.supersetId ?? null,\n\t\t\t\t\t\t\trest_seconds: exercise.restSeconds ?? null,\n\t\t\t\t\t\t\tnotes: exercise.notes ?? null,\n\t\t\t\t\t\t\tsets: exercise.sets.map(\n\t\t\t\t\t\t\t\t(set): PostRoutinesRequestSet => ({\n\t\t\t\t\t\t\t\t\ttype: set.type as PostRoutinesRequestSetTypeEnumKey,\n\t\t\t\t\t\t\t\t\tweight_kg: set.weight ?? set.weightKg ?? null,\n\t\t\t\t\t\t\t\t\treps: set.reps ?? null,\n\t\t\t\t\t\t\t\t\tdistance_meters: set.distance ?? set.distanceMeters ?? null,\n\t\t\t\t\t\t\t\t\tduration_seconds: set.duration ?? set.durationSeconds ?? null,\n\t\t\t\t\t\t\t\t\tcustom_metric: set.customMetric ?? null,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to create routine: Server returned no data\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst routine = formatRoutine(data);\n\t\t\treturn createJsonResponse(routine, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"create-routine\"),\n\t);\n\n\t// Update existing routine\n\tconst updateRoutineSchema = {\n\t\troutineId: z.string().min(1),\n\t\ttitle: z.string().min(1),\n\t\tnotes: z.string().optional(),\n\t\texercises: z.array(\n\t\t\tz.object({\n\t\t\t\texerciseTemplateId: z.string().min(1),\n\t\t\t\tsupersetId: z.coerce.number().nullable().optional(),\n\t\t\t\trestSeconds: z.coerce.number().int().min(0).optional(),\n\t\t\t\tnotes: z.string().optional(),\n\t\t\t\tsets: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z\n\t\t\t\t\t\t\t.enum([\"warmup\", \"normal\", \"failure\", \"dropset\"])\n\t\t\t\t\t\t\t.default(\"normal\"),\n\t\t\t\t\t\tweight: z.coerce.number().optional(),\n\t\t\t\t\t\tweightKg: z.coerce.number().optional(),\n\t\t\t\t\t\treps: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdistance: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdistanceMeters: z.coerce.number().int().optional(),\n\t\t\t\t\t\tduration: z.coerce.number().int().optional(),\n\t\t\t\t\t\tdurationSeconds: z.coerce.number().int().optional(),\n\t\t\t\t\t\tcustomMetric: z.coerce.number().optional(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t} as const;\n\ttype UpdateRoutineParams = InferToolParams<typeof updateRoutineSchema>;\n\n\tserver.tool(\n\t\t\"update-routine\",\n\t\t\"Update an existing routine by ID. You can modify the title, notes, and exercise configurations. Returns the updated routine with all changes applied.\",\n\t\tupdateRoutineSchema,\n\t\twithErrorHandling(async (args: UpdateRoutineParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { routineId, title, notes, exercises } = args;\n\t\t\tconst data = await hevyClient.updateRoutine(routineId, {\n\t\t\t\troutine: {\n\t\t\t\t\ttitle,\n\t\t\t\t\tnotes: notes ?? null,\n\t\t\t\t\texercises: exercises.map(\n\t\t\t\t\t\t(exercise): PutRoutinesRequestExercise => ({\n\t\t\t\t\t\t\texercise_template_id: exercise.exerciseTemplateId,\n\t\t\t\t\t\t\tsuperset_id: exercise.supersetId ?? null,\n\t\t\t\t\t\t\trest_seconds: exercise.restSeconds ?? null,\n\t\t\t\t\t\t\tnotes: exercise.notes ?? null,\n\t\t\t\t\t\t\tsets: exercise.sets.map(\n\t\t\t\t\t\t\t\t(set): PutRoutinesRequestSet => ({\n\t\t\t\t\t\t\t\t\ttype: set.type as PutRoutinesRequestSetTypeEnumKey,\n\t\t\t\t\t\t\t\t\tweight_kg: set.weight ?? set.weightKg ?? null,\n\t\t\t\t\t\t\t\t\treps: set.reps ?? null,\n\t\t\t\t\t\t\t\t\tdistance_meters: set.distance ?? set.distanceMeters ?? null,\n\t\t\t\t\t\t\t\t\tduration_seconds: set.duration ?? set.durationSeconds ?? null,\n\t\t\t\t\t\t\t\t\tcustom_metric: set.customMetric ?? null,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`Failed to update routine with ID ${routineId}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst routine = formatRoutine(data);\n\t\t\treturn createJsonResponse(routine, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"update-routine\"),\n\t);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\n// Import types from generated client\nimport type { ExerciseTemplate } from \"../generated/client/types/index.js\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport { formatExerciseTemplate } from \"../utils/formatters.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\n// Type definitions for the template operations\ntype HevyClient = ReturnType<\n\ttypeof import(\"../utils/hevyClientKubb.js\").createClient\n>;\n\n/**\n * Register all exercise template-related tools with the MCP server\n */\nexport function registerTemplateTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get exercise templates\n\tconst getExerciseTemplatesSchema = {\n\t\tpage: z.coerce.number().int().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(100).default(5),\n\t} as const;\n\ttype GetExerciseTemplatesParams = InferToolParams<\n\t\ttypeof getExerciseTemplatesSchema\n\t>;\n\n\tserver.tool(\n\t\t\"get-exercise-templates\",\n\t\t\"Get a paginated list of exercise templates (default and custom) with details like name, category, equipment, and muscle groups. Useful for browsing or searching available exercises.\",\n\t\tgetExerciseTemplatesSchema,\n\t\twithErrorHandling(async (args: GetExerciseTemplatesParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize } = args;\n\t\t\tconst data = await hevyClient.getExerciseTemplates({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t});\n\n\t\t\t// Process exercise templates to extract relevant information\n\t\t\tconst templates =\n\t\t\t\tdata?.exercise_templates?.map((template: ExerciseTemplate) =>\n\t\t\t\t\tformatExerciseTemplate(template),\n\t\t\t\t) || [];\n\n\t\t\tif (templates.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No exercise templates found for the specified parameters\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(templates);\n\t\t}, \"get-exercise-templates\"),\n\t);\n\n\t// Get single exercise template by ID\n\tconst getExerciseTemplateSchema = {\n\t\texerciseTemplateId: z.string().min(1),\n\t} as const;\n\ttype GetExerciseTemplateParams = InferToolParams<\n\t\ttypeof getExerciseTemplateSchema\n\t>;\n\n\tserver.tool(\n\t\t\"get-exercise-template\",\n\t\t\"Get complete details of a specific exercise template by its ID, including name, category, equipment, muscle groups, and notes.\",\n\t\tgetExerciseTemplateSchema,\n\t\twithErrorHandling(async (args: GetExerciseTemplateParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { exerciseTemplateId } = args;\n\t\t\tconst data = await hevyClient.getExerciseTemplate(exerciseTemplateId);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`Exercise template with ID ${exerciseTemplateId} not found`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst template = formatExerciseTemplate(data);\n\t\t\treturn createJsonResponse(template);\n\t\t}, \"get-exercise-template\"),\n\t);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\ntype HevyClient = ReturnType<\n\ttypeof import(\"../utils/hevyClientKubb.js\").createClient\n>;\n\n// Enhanced webhook URL validation\nconst webhookUrlSchema = z\n\t.string()\n\t.url()\n\t.refine(\n\t\t(url) => {\n\t\t\ttry {\n\t\t\t\tconst parsed = new URL(url);\n\t\t\t\treturn parsed.protocol === \"https:\" || parsed.protocol === \"http:\";\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tmessage: \"Webhook URL must be a valid HTTP or HTTPS URL\",\n\t\t},\n\t)\n\t.refine(\n\t\t(url) => {\n\t\t\ttry {\n\t\t\t\tconst parsed = new URL(url);\n\t\t\t\treturn (\n\t\t\t\t\tparsed.hostname !== \"localhost\" && !parsed.hostname.startsWith(\"127.\")\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tmessage: \"Webhook URL cannot be localhost or loopback address\",\n\t\t},\n\t);\n\nexport function registerWebhookTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get webhook subscription\n\tconst getWebhookSubscriptionSchema = {} as const;\n\ttype GetWebhookSubscriptionParams = InferToolParams<\n\t\ttypeof getWebhookSubscriptionSchema\n\t>;\n\n\tserver.tool(\n\t\t\"get-webhook-subscription\",\n\t\t\"Get the current webhook subscription for this account. Returns the webhook URL and auth token if a subscription exists.\",\n\t\tgetWebhookSubscriptionSchema,\n\t\twithErrorHandling(async (_args: GetWebhookSubscriptionParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\t// TODO: Uncomment after regenerating client from updated OpenAPI spec\n\t\t\tif (!(\"getWebhookSubscription\" in hevyClient)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Webhook subscription API not available. Please regenerate the client from the updated OpenAPI spec.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await (hevyClient as any).getWebhookSubscription();\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No webhook subscription found for this account\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn createJsonResponse(data);\n\t\t}, \"get-webhook-subscription\"),\n\t);\n\n\t// Create webhook subscription\n\tconst createWebhookSubscriptionSchema = {\n\t\turl: webhookUrlSchema.describe(\n\t\t\t\"The webhook URL that will receive POST requests when workouts are created\",\n\t\t),\n\t\tauthToken: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Optional auth token that will be sent as Authorization header in webhook requests\",\n\t\t\t),\n\t} as const;\n\ttype CreateWebhookSubscriptionParams = InferToolParams<\n\t\ttypeof createWebhookSubscriptionSchema\n\t>;\n\n\tserver.tool(\n\t\t\"create-webhook-subscription\",\n\t\t\"Create a new webhook subscription for this account. The webhook will receive POST requests when workouts are created. Your endpoint must respond with 200 OK within 5 seconds.\",\n\t\tcreateWebhookSubscriptionSchema,\n\t\twithErrorHandling(async (args: CreateWebhookSubscriptionParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { url, authToken } = args;\n\t\t\t// TODO: Uncomment after regenerating client from updated OpenAPI spec\n\t\t\tif (!(\"createWebhookSubscription\" in hevyClient)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Webhook subscription API not available. Please regenerate the client from the updated OpenAPI spec.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await (hevyClient as any).createWebhookSubscription({\n\t\t\t\twebhook: {\n\t\t\t\t\turl,\n\t\t\t\t\tauthToken: authToken || null,\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to create webhook subscription - please check your URL and try again\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn createJsonResponse(data);\n\t\t}, \"create-webhook-subscription\"),\n\t);\n\n\t// Delete webhook subscription\n\tconst deleteWebhookSubscriptionSchema = {} as const;\n\ttype DeleteWebhookSubscriptionParams = InferToolParams<\n\t\ttypeof deleteWebhookSubscriptionSchema\n\t>;\n\n\tserver.tool(\n\t\t\"delete-webhook-subscription\",\n\t\t\"Delete the current webhook subscription for this account. This will stop all webhook notifications.\",\n\t\tdeleteWebhookSubscriptionSchema,\n\t\twithErrorHandling(async (_args: DeleteWebhookSubscriptionParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\t// TODO: Uncomment after regenerating client from updated OpenAPI spec\n\t\t\tif (!(\"deleteWebhookSubscription\" in hevyClient)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Webhook subscription API not available. Please regenerate the client from the updated OpenAPI spec.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await (hevyClient as any).deleteWebhookSubscription();\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to delete webhook subscription - no subscription may exist or there was a server error\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn createJsonResponse(data);\n\t\t}, \"delete-webhook-subscription\"),\n\t);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type {\n\tPostWorkoutsRequestBody,\n\tPostWorkoutsRequestExercise,\n\tPostWorkoutsRequestSetRpeEnumKey,\n\tPostWorkoutsRequestSetTypeEnumKey,\n} from \"../generated/client/types/index.js\";\nimport { withErrorHandling } from \"../utils/error-handler.js\";\nimport { formatWorkout } from \"../utils/formatters.js\";\nimport type { HevyClient } from \"../utils/hevyClient.js\";\nimport {\n\tcreateEmptyResponse,\n\tcreateJsonResponse,\n} from \"../utils/response-formatter.js\";\nimport type { InferToolParams } from \"../utils/tool-helpers.js\";\n\n/**\n * Register all workout-related tools with the MCP server\n */\nexport function registerWorkoutTools(\n\tserver: McpServer,\n\thevyClient: HevyClient | null,\n) {\n\t// Get workouts\n\tconst getWorkoutsSchema = {\n\t\tpage: z.coerce.number().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(10).default(5),\n\t} as const;\n\ttype GetWorkoutsParams = InferToolParams<typeof getWorkoutsSchema>;\n\n\tserver.tool(\n\t\t\"get-workouts\",\n\t\t\"Get a paginated list of workouts. Returns workout details including title, description, start/end times, and exercises performed. Results are ordered from newest to oldest.\",\n\t\tgetWorkoutsSchema,\n\t\twithErrorHandling(async (args: GetWorkoutsParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize } = args;\n\t\t\tconst data = await hevyClient.getWorkouts({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t});\n\n\t\t\tconst workouts =\n\t\t\t\tdata?.workouts?.map((workout) => formatWorkout(workout)) || [];\n\n\t\t\tif (workouts.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"No workouts found for the specified parameters\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(workouts);\n\t\t}, \"get-workouts\"),\n\t);\n\n\t// Get single workout by ID\n\tconst getWorkoutSchema = {\n\t\tworkoutId: z.string().min(1),\n\t} as const;\n\ttype GetWorkoutParams = InferToolParams<typeof getWorkoutSchema>;\n\n\tserver.tool(\n\t\t\"get-workout\",\n\t\t\"Get complete details of a specific workout by ID. Returns all workout information including title, description, start/end times, and detailed exercise data.\",\n\t\tgetWorkoutSchema,\n\t\twithErrorHandling(async (args: GetWorkoutParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { workoutId } = args;\n\t\t\tconst data = await hevyClient.getWorkout(workoutId);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(`Workout with ID ${workoutId} not found`);\n\t\t\t}\n\n\t\t\tconst workout = formatWorkout(data);\n\t\t\treturn createJsonResponse(workout);\n\t\t}, \"get-workout\"),\n\t);\n\n\t// Get workout count\n\tserver.tool(\n\t\t\"get-workout-count\",\n\t\t\"Get the total number of workouts on the account. Useful for pagination or statistics.\",\n\t\t{},\n\t\twithErrorHandling(async () => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst data = await hevyClient.getWorkoutCount();\n\t\t\tconst count = data\n\t\t\t\t? (data as { workoutCount?: number }).workoutCount || 0\n\t\t\t\t: 0;\n\t\t\treturn createJsonResponse({ count });\n\t\t}, \"get-workout-count\"),\n\t);\n\n\t// Get workout events (updates/deletes)\n\tconst getWorkoutEventsSchema = {\n\t\tpage: z.coerce.number().int().gte(1).default(1),\n\t\tpageSize: z.coerce.number().int().gte(1).lte(10).default(5),\n\t\tsince: z.string().default(\"1970-01-01T00:00:00Z\"),\n\t} as const;\n\ttype GetWorkoutEventsParams = InferToolParams<typeof getWorkoutEventsSchema>;\n\n\tserver.tool(\n\t\t\"get-workout-events\",\n\t\t\"Retrieve a paged list of workout events (updates or deletes) since a given date. Events are ordered from newest to oldest. The intention is to allow clients to keep their local cache of workouts up to date without having to fetch the entire list of workouts.\",\n\t\tgetWorkoutEventsSchema,\n\t\twithErrorHandling(async (args: GetWorkoutEventsParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { page, pageSize, since } = args;\n\t\t\tconst data = await hevyClient.getWorkoutEvents({\n\t\t\t\tpage,\n\t\t\t\tpageSize,\n\t\t\t\tsince,\n\t\t\t});\n\n\t\t\tconst events = data?.events || [];\n\n\t\t\tif (events.length === 0) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`No workout events found for the specified parameters since ${since}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn createJsonResponse(events);\n\t\t}, \"get-workout-events\"),\n\t);\n\n\t// Create workout\n\tconst createWorkoutSchema = {\n\t\ttitle: z.string().min(1),\n\t\tdescription: z.string().optional().nullable(),\n\t\tstartTime: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/),\n\t\tendTime: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/),\n\t\tisPrivate: z.boolean().default(false),\n\t\texercises: z.array(\n\t\t\tz.object({\n\t\t\t\texerciseTemplateId: z.string().min(1),\n\t\t\t\tsupersetId: z.coerce.number().nullable().optional(),\n\t\t\t\tnotes: z.string().optional().nullable(),\n\t\t\t\tsets: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z\n\t\t\t\t\t\t\t.enum([\"warmup\", \"normal\", \"failure\", \"dropset\"])\n\t\t\t\t\t\t\t.default(\"normal\"),\n\t\t\t\t\t\tweight: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\tweightKg: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\treps: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdistance: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdistanceMeters: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tduration: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdurationSeconds: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\trpe: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\tcustomMetric: z.coerce.number().optional().nullable(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t} as const;\n\ttype CreateWorkoutParams = InferToolParams<typeof createWorkoutSchema>;\n\n\tserver.tool(\n\t\t\"create-workout\",\n\t\t\"Create a new workout in your Hevy account. Requires title, start/end times, and at least one exercise with sets. Returns the complete workout details upon successful creation including the newly assigned workout ID.\",\n\t\tcreateWorkoutSchema,\n\t\twithErrorHandling(async (args: CreateWorkoutParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst { title, description, startTime, endTime, isPrivate, exercises } =\n\t\t\t\targs;\n\t\t\tconst requestBody: PostWorkoutsRequestBody = {\n\t\t\t\tworkout: {\n\t\t\t\t\ttitle,\n\t\t\t\t\tdescription: description || null,\n\t\t\t\t\tstart_time: startTime,\n\t\t\t\t\tend_time: endTime,\n\t\t\t\t\tis_private: isPrivate,\n\t\t\t\t\texercises: exercises.map(\n\t\t\t\t\t\t(exercise): PostWorkoutsRequestExercise => ({\n\t\t\t\t\t\t\texercise_template_id: exercise.exerciseTemplateId,\n\t\t\t\t\t\t\tsuperset_id: exercise.supersetId ?? null,\n\t\t\t\t\t\t\tnotes: exercise.notes ?? null,\n\t\t\t\t\t\t\tsets: exercise.sets.map((set) => ({\n\t\t\t\t\t\t\t\ttype: set.type as PostWorkoutsRequestSetTypeEnumKey,\n\t\t\t\t\t\t\t\tweight_kg: set.weight ?? set.weightKg ?? null,\n\t\t\t\t\t\t\t\treps: set.reps ?? null,\n\t\t\t\t\t\t\t\tdistance_meters: set.distance ?? set.distanceMeters ?? null,\n\t\t\t\t\t\t\t\tduration_seconds: set.duration ?? set.durationSeconds ?? null,\n\t\t\t\t\t\t\t\trpe:\n\t\t\t\t\t\t\t\t\t(set.rpe as PostWorkoutsRequestSetRpeEnumKey | null) ?? null,\n\t\t\t\t\t\t\t\tcustom_metric: set.customMetric ?? null,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst data = await hevyClient.createWorkout(requestBody);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t\"Failed to create workout: Server returned no data\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst workout = formatWorkout(data);\n\t\t\treturn createJsonResponse(workout, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"create-workout\"),\n\t);\n\n\t// Update workout\n\tconst updateWorkoutSchema = {\n\t\tworkoutId: z.string().min(1),\n\t\ttitle: z.string().min(1),\n\t\tdescription: z.string().optional().nullable(),\n\t\tstartTime: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/),\n\t\tendTime: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/),\n\t\tisPrivate: z.boolean().default(false),\n\t\texercises: z.array(\n\t\t\tz.object({\n\t\t\t\texerciseTemplateId: z.string().min(1),\n\t\t\t\tsupersetId: z.coerce.number().nullable().optional(),\n\t\t\t\tnotes: z.string().optional().nullable(),\n\t\t\t\tsets: z.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\ttype: z\n\t\t\t\t\t\t\t.enum([\"warmup\", \"normal\", \"failure\", \"dropset\"])\n\t\t\t\t\t\t\t.default(\"normal\"),\n\t\t\t\t\t\tweight: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\tweightKg: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\treps: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdistance: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdistanceMeters: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tduration: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\tdurationSeconds: z.coerce.number().int().optional().nullable(),\n\t\t\t\t\t\trpe: z.coerce.number().optional().nullable(),\n\t\t\t\t\t\tcustomMetric: z.coerce.number().optional().nullable(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t} as const;\n\ttype UpdateWorkoutParams = InferToolParams<typeof updateWorkoutSchema>;\n\n\tserver.tool(\n\t\t\"update-workout\",\n\t\t\"Update an existing workout by ID. You can modify the title, description, start/end times, privacy setting, and exercise data. Returns the updated workout with all changes applied.\",\n\t\tupdateWorkoutSchema,\n\t\twithErrorHandling(async (args: UpdateWorkoutParams) => {\n\t\t\tif (!hevyClient) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"API client not initialized. Please provide HEVY_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tworkoutId,\n\t\t\t\ttitle,\n\t\t\t\tdescription,\n\t\t\t\tstartTime,\n\t\t\t\tendTime,\n\t\t\t\tisPrivate,\n\t\t\t\texercises,\n\t\t\t} = args;\n\t\t\tconst requestBody: PostWorkoutsRequestBody = {\n\t\t\t\tworkout: {\n\t\t\t\t\ttitle,\n\t\t\t\t\tdescription: description || null,\n\t\t\t\t\tstart_time: startTime,\n\t\t\t\t\tend_time: endTime,\n\t\t\t\t\tis_private: isPrivate,\n\t\t\t\t\texercises: exercises.map(\n\t\t\t\t\t\t(exercise): PostWorkoutsRequestExercise => ({\n\t\t\t\t\t\t\texercise_template_id: exercise.exerciseTemplateId,\n\t\t\t\t\t\t\tsuperset_id: exercise.supersetId ?? null,\n\t\t\t\t\t\t\tnotes: exercise.notes ?? null,\n\t\t\t\t\t\t\tsets: exercise.sets.map((set) => ({\n\t\t\t\t\t\t\t\ttype: set.type as PostWorkoutsRequestSetTypeEnumKey,\n\t\t\t\t\t\t\t\tweight_kg: set.weight ?? set.weightKg ?? null,\n\t\t\t\t\t\t\t\treps: set.reps ?? null,\n\t\t\t\t\t\t\t\tdistance_meters: set.distance ?? set.distanceMeters ?? null,\n\t\t\t\t\t\t\t\tduration_seconds: set.duration ?? set.durationSeconds ?? null,\n\t\t\t\t\t\t\t\trpe:\n\t\t\t\t\t\t\t\t\t(set.rpe as PostWorkoutsRequestSetRpeEnumKey | null) ?? null,\n\t\t\t\t\t\t\t\tcustom_metric: set.customMetric ?? null,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst data = await hevyClient.updateWorkout(workoutId, requestBody);\n\n\t\t\tif (!data) {\n\t\t\t\treturn createEmptyResponse(\n\t\t\t\t\t`Failed to update workout with ID ${workoutId}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst workout = formatWorkout(data);\n\t\t\treturn createJsonResponse(workout, {\n\t\t\t\tpretty: true,\n\t\t\t\tindent: 2,\n\t\t\t});\n\t\t}, \"update-workout-operation\"),\n\t);\n}\n","export interface HevyConfig {\n\tapiKey?: string;\n}\n\n/**\n * Parse CLI arguments and environment to derive configuration.\n * Priority order for API key: CLI flag forms > environment variable.\n * Supported CLI arg forms:\n * --hevy-api-key=KEY\n * --hevyApiKey=KEY\n * hevy-api-key=KEY (bare, e.g. when passed after npm start -- )\n */\nexport function parseConfig(\n\targv: string[],\n\tenv: NodeJS.ProcessEnv,\n): HevyConfig {\n\tlet apiKey = \"\";\n\tconst apiKeyArgPatterns = [\n\t\t/^--hevy-api-key=(.+)$/i,\n\t\t/^--hevyApiKey=(.+)$/i,\n\t\t/^hevy-api-key=(.+)$/i,\n\t];\n\tfor (const raw of argv) {\n\t\tfor (const pattern of apiKeyArgPatterns) {\n\t\t\tconst m = raw.match(pattern);\n\t\t\tif (m) {\n\t\t\t\tapiKey = m[1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (apiKey) break;\n\t}\n\tif (!apiKey) {\n\t\tapiKey = env.HEVY_API_KEY || \"\";\n\t}\n\n\treturn {\n\t\tapiKey,\n\t};\n}\n\nexport function assertApiKey(\n\tapiKey: string | undefined,\n): asserts apiKey is string {\n\tif (!apiKey) {\n\t\tconsole.error(\n\t\t\t\"Hevy API key is required. Provide it via the HEVY_API_KEY environment variable or the --hevy-api-key=YOUR_KEY command argument.\",\n\t\t);\n\t\tprocess.exit(1);\n\t}\n}\n","import type {\n\tRequestConfig,\n\tResponseConfig,\n} from \"@kubb/plugin-client/clients/axios\";\nimport axios from \"axios\";\nimport * as api from \"../generated/client/api\";\nimport type {\n\tGetV1ExerciseTemplatesQueryParams,\n\tGetV1RoutineFoldersQueryParams,\n\tGetV1RoutinesQueryParams,\n\tGetV1WorkoutsEventsQueryParams,\n\tGetV1WorkoutsQueryParams,\n\tPostV1RoutineFoldersMutationRequest,\n\tPostV1RoutinesMutationRequest,\n\tPostV1WorkoutsMutationRequest,\n\tPutV1RoutinesRoutineidMutationRequest,\n\tPutV1WorkoutsWorkoutidMutationRequest,\n} from \"../generated/client/types\";\n\n// Define a proper client type that matches the Kubb client interface\ntype KubbClient = {\n\t<TData, _TError = unknown, TVariables = unknown>(\n\t\tconfig: RequestConfig<TVariables>,\n\t): Promise<ResponseConfig<TData>>;\n\tgetConfig: () => Partial<RequestConfig<unknown>>;\n\tsetConfig: (config: RequestConfig) => Partial<RequestConfig<unknown>>;\n};\n\nexport function createClient(\n\tapiKey: string,\n\tbaseUrl = \"https://api.hevyapp.com\",\n) {\n\t// Create an axios instance with the API key\n\tconst axiosInstance = axios.create({\n\t\tbaseURL: baseUrl,\n\t\theaders: {\n\t\t\t\"api-key\": apiKey,\n\t\t},\n\t});\n\n\t// Create headers object with API key\n\tconst headers = {\n\t\t\"api-key\": apiKey,\n\t};\n\n\t// Cast axios instance to the expected client type\n\tconst client = axiosInstance as unknown as KubbClient;\n\n\t// Return an object with all the API methods using ReturnType for automatic type inference\n\treturn {\n\t\t// Workouts\n\t\tgetWorkouts: (\n\t\t\tparams?: GetV1WorkoutsQueryParams,\n\t\t): ReturnType<typeof api.getV1Workouts> =>\n\t\t\tapi.getV1Workouts(headers, params, { client }),\n\t\tgetWorkout: (\n\t\t\tworkoutId: string,\n\t\t): ReturnType<typeof api.getV1WorkoutsWorkoutid> =>\n\t\t\tapi.getV1WorkoutsWorkoutid(workoutId, headers, { client }),\n\t\tcreateWorkout: (\n\t\t\tdata: PostV1WorkoutsMutationRequest,\n\t\t): ReturnType<typeof api.postV1Workouts> =>\n\t\t\tapi.postV1Workouts(headers, data, { client }),\n\t\tupdateWorkout: (\n\t\t\tworkoutId: string,\n\t\t\tdata: PutV1WorkoutsWorkoutidMutationRequest,\n\t\t): ReturnType<typeof api.putV1WorkoutsWorkoutid> =>\n\t\t\tapi.putV1WorkoutsWorkoutid(workoutId, headers, data, {\n\t\t\t\tclient,\n\t\t\t}),\n\t\tgetWorkoutCount: (): ReturnType<typeof api.getV1WorkoutsCount> =>\n\t\t\tapi.getV1WorkoutsCount(headers, { client }),\n\t\tgetWorkoutEvents: (\n\t\t\tparams?: GetV1WorkoutsEventsQueryParams,\n\t\t): ReturnType<typeof api.getV1WorkoutsEvents> =>\n\t\t\tapi.getV1WorkoutsEvents(headers, params, { client }),\n\n\t\t// Routines\n\t\tgetRoutines: (\n\t\t\tparams?: GetV1RoutinesQueryParams,\n\t\t): ReturnType<typeof api.getV1Routines> =>\n\t\t\tapi.getV1Routines(headers, params, { client }),\n\t\tgetRoutineById: (\n\t\t\troutineId: string,\n\t\t): ReturnType<typeof api.getV1RoutinesRoutineid> =>\n\t\t\tapi.getV1RoutinesRoutineid(routineId, headers, { client }),\n\t\tcreateRoutine: (\n\t\t\tdata: PostV1RoutinesMutationRequest,\n\t\t): ReturnType<typeof api.postV1Routines> =>\n\t\t\tapi.postV1Routines(headers, data, { client }),\n\t\tupdateRoutine: (\n\t\t\troutineId: string,\n\t\t\tdata: PutV1RoutinesRoutineidMutationRequest,\n\t\t): ReturnType<typeof api.putV1RoutinesRoutineid> =>\n\t\t\tapi.putV1RoutinesRoutineid(routineId, headers, data, {\n\t\t\t\tclient,\n\t\t\t}),\n\n\t\t// Exercise Templates\n\t\tgetExerciseTemplates: (\n\t\t\tparams?: GetV1ExerciseTemplatesQueryParams,\n\t\t): ReturnType<typeof api.getV1ExerciseTemplates> =>\n\t\t\tapi.getV1ExerciseTemplates(headers, params, { client }),\n\t\tgetExerciseTemplate: (\n\t\t\ttemplateId: string,\n\t\t): ReturnType<typeof api.getV1ExerciseTemplatesExercisetemplateid> =>\n\t\t\tapi.getV1ExerciseTemplatesExercisetemplateid(templateId, headers, {\n\t\t\t\tclient,\n\t\t\t}),\n\n\t\t// Routine Folders\n\t\tgetRoutineFolders: (\n\t\t\tparams?: GetV1RoutineFoldersQueryParams,\n\t\t): ReturnType<typeof api.getV1RoutineFolders> =>\n\t\t\tapi.getV1RoutineFolders(headers, params, { client }),\n\t\tcreateRoutineFolder: (\n\t\t\tdata: PostV1RoutineFoldersMutationRequest,\n\t\t): ReturnType<typeof api.postV1RoutineFolders> =>\n\t\t\tapi.postV1RoutineFolders(headers, data, { client }),\n\t\tgetRoutineFolder: (\n\t\t\tfolderId: string,\n\t\t): ReturnType<typeof api.getV1RoutineFoldersFolderid> =>\n\t\t\tapi.getV1RoutineFoldersFolderid(folderId, headers, {\n\t\t\t\tclient,\n\t\t\t}),\n\n\t\t// Webhooks\n\t\tgetWebhookSubscription: (): ReturnType<\n\t\t\ttypeof api.getV1WebhookSubscription\n\t\t> => api.getV1WebhookSubscription(headers, { client }),\n\t\tcreateWebhookSubscription: (\n\t\t\tdata: import(\"../generated/client/types\").PostV1WebhookSubscriptionMutationRequest,\n\t\t): ReturnType<typeof api.postV1WebhookSubscription> =>\n\t\t\tapi.postV1WebhookSubscription(headers, data, { client }),\n\t\tdeleteWebhookSubscription: (): ReturnType<\n\t\t\ttypeof api.deleteV1WebhookSubscription\n\t\t> => api.deleteV1WebhookSubscription(headers, { client }),\n\t};\n}\n","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { DeleteV1WebhookSubscriptionMutationResponse, DeleteV1WebhookSubscriptionHeaderParams } from \"../types/DeleteV1WebhookSubscription.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getDeleteV1WebhookSubscriptionUrl() {\n const res = { method: 'DELETE', url: `/v1/webhook-subscription` as const } \n return res\n}\n\n/**\n * @summary Delete a webhook subscription.\n * {@link /v1/webhook-subscription}\n */\nexport async function deleteV1WebhookSubscription(headers: DeleteV1WebhookSubscriptionHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<DeleteV1WebhookSubscriptionMutationResponse, ResponseErrorConfig<Error>, unknown>({ method : \"DELETE\", url : getDeleteV1WebhookSubscriptionUrl().url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1ExerciseTemplatesQueryResponse, GetV1ExerciseTemplatesQueryParams, GetV1ExerciseTemplatesHeaderParams, GetV1ExerciseTemplates400 } from \"../types/GetV1ExerciseTemplates.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1ExerciseTemplatesUrl() {\n const res = { method: 'GET', url: `/v1/exercise_templates` as const } \n return res\n}\n\n/**\n * @summary Get a paginated list of exercise templates available on the account.\n * {@link /v1/exercise_templates}\n */\nexport async function getV1ExerciseTemplates(headers: GetV1ExerciseTemplatesHeaderParams, params?: GetV1ExerciseTemplatesQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1ExerciseTemplatesQueryResponse, ResponseErrorConfig<GetV1ExerciseTemplates400>, unknown>({ method : \"GET\", url : getGetV1ExerciseTemplatesUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1ExerciseTemplatesExercisetemplateidQueryResponse, GetV1ExerciseTemplatesExercisetemplateidPathParams, GetV1ExerciseTemplatesExercisetemplateidHeaderParams, GetV1ExerciseTemplatesExercisetemplateid404 } from \"../types/GetV1ExerciseTemplatesExercisetemplateid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1ExerciseTemplatesExercisetemplateidUrl(exerciseTemplateId: GetV1ExerciseTemplatesExercisetemplateidPathParams[\"exerciseTemplateId\"]) {\n const res = { method: 'GET', url: `/v1/exercise_templates/${exerciseTemplateId}` as const } \n return res\n}\n\n/**\n * @summary Get a single exercise template by id.\n * {@link /v1/exercise_templates/:exerciseTemplateId}\n */\nexport async function getV1ExerciseTemplatesExercisetemplateid(exerciseTemplateId: GetV1ExerciseTemplatesExercisetemplateidPathParams[\"exerciseTemplateId\"], headers: GetV1ExerciseTemplatesExercisetemplateidHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1ExerciseTemplatesExercisetemplateidQueryResponse, ResponseErrorConfig<GetV1ExerciseTemplatesExercisetemplateid404>, unknown>({ method : \"GET\", url : getGetV1ExerciseTemplatesExercisetemplateidUrl(exerciseTemplateId).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1RoutineFoldersQueryResponse, GetV1RoutineFoldersQueryParams, GetV1RoutineFoldersHeaderParams, GetV1RoutineFolders400 } from \"../types/GetV1RoutineFolders.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1RoutineFoldersUrl() {\n const res = { method: 'GET', url: `/v1/routine_folders` as const } \n return res\n}\n\n/**\n * @summary Get a paginated list of routine folders available on the account.\n * {@link /v1/routine_folders}\n */\nexport async function getV1RoutineFolders(headers: GetV1RoutineFoldersHeaderParams, params?: GetV1RoutineFoldersQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1RoutineFoldersQueryResponse, ResponseErrorConfig<GetV1RoutineFolders400>, unknown>({ method : \"GET\", url : getGetV1RoutineFoldersUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1RoutineFoldersFolderidQueryResponse, GetV1RoutineFoldersFolderidPathParams, GetV1RoutineFoldersFolderidHeaderParams, GetV1RoutineFoldersFolderid404 } from \"../types/GetV1RoutineFoldersFolderid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1RoutineFoldersFolderidUrl(folderId: GetV1RoutineFoldersFolderidPathParams[\"folderId\"]) {\n const res = { method: 'GET', url: `/v1/routine_folders/${folderId}` as const } \n return res\n}\n\n/**\n * @summary Get a single routine folder by id.\n * {@link /v1/routine_folders/:folderId}\n */\nexport async function getV1RoutineFoldersFolderid(folderId: GetV1RoutineFoldersFolderidPathParams[\"folderId\"], headers: GetV1RoutineFoldersFolderidHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1RoutineFoldersFolderidQueryResponse, ResponseErrorConfig<GetV1RoutineFoldersFolderid404>, unknown>({ method : \"GET\", url : getGetV1RoutineFoldersFolderidUrl(folderId).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1RoutinesQueryResponse, GetV1RoutinesQueryParams, GetV1RoutinesHeaderParams, GetV1Routines400 } from \"../types/GetV1Routines.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1RoutinesUrl() {\n const res = { method: 'GET', url: `/v1/routines` as const } \n return res\n}\n\n/**\n * @summary Get a paginated list of routines\n * {@link /v1/routines}\n */\nexport async function getV1Routines(headers: GetV1RoutinesHeaderParams, params?: GetV1RoutinesQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1RoutinesQueryResponse, ResponseErrorConfig<GetV1Routines400>, unknown>({ method : \"GET\", url : getGetV1RoutinesUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1RoutinesRoutineidQueryResponse, GetV1RoutinesRoutineidPathParams, GetV1RoutinesRoutineidHeaderParams, GetV1RoutinesRoutineid400 } from \"../types/GetV1RoutinesRoutineid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1RoutinesRoutineidUrl(routineId: GetV1RoutinesRoutineidPathParams[\"routineId\"]) {\n const res = { method: 'GET', url: `/v1/routines/${routineId}` as const } \n return res\n}\n\n/**\n * @summary Get a routine by its Id\n * {@link /v1/routines/:routineId}\n */\nexport async function getV1RoutinesRoutineid(routineId: GetV1RoutinesRoutineidPathParams[\"routineId\"], headers: GetV1RoutinesRoutineidHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1RoutinesRoutineidQueryResponse, ResponseErrorConfig<GetV1RoutinesRoutineid400>, unknown>({ method : \"GET\", url : getGetV1RoutinesRoutineidUrl(routineId).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WebhookSubscriptionQueryResponse, GetV1WebhookSubscriptionHeaderParams, GetV1WebhookSubscription404 } from \"../types/GetV1WebhookSubscription.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WebhookSubscriptionUrl() {\n const res = { method: 'GET', url: `/v1/webhook-subscription` as const } \n return res\n}\n\n/**\n * @summary Get the current webhook subscription.\n * {@link /v1/webhook-subscription}\n */\nexport async function getV1WebhookSubscription(headers: GetV1WebhookSubscriptionHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WebhookSubscriptionQueryResponse, ResponseErrorConfig<GetV1WebhookSubscription404>, unknown>({ method : \"GET\", url : getGetV1WebhookSubscriptionUrl().url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WorkoutsQueryResponse, GetV1WorkoutsQueryParams, GetV1WorkoutsHeaderParams, GetV1Workouts400 } from \"../types/GetV1Workouts.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WorkoutsUrl() {\n const res = { method: 'GET', url: `/v1/workouts` as const } \n return res\n}\n\n/**\n * @summary Get a paginated list of workouts\n * {@link /v1/workouts}\n */\nexport async function getV1Workouts(headers: GetV1WorkoutsHeaderParams, params?: GetV1WorkoutsQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WorkoutsQueryResponse, ResponseErrorConfig<GetV1Workouts400>, unknown>({ method : \"GET\", url : getGetV1WorkoutsUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WorkoutsCountQueryResponse, GetV1WorkoutsCountHeaderParams } from \"../types/GetV1WorkoutsCount.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WorkoutsCountUrl() {\n const res = { method: 'GET', url: `/v1/workouts/count` as const } \n return res\n}\n\n/**\n * @summary Get the total number of workouts on the account\n * {@link /v1/workouts/count}\n */\nexport async function getV1WorkoutsCount(headers: GetV1WorkoutsCountHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WorkoutsCountQueryResponse, ResponseErrorConfig<Error>, unknown>({ method : \"GET\", url : getGetV1WorkoutsCountUrl().url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WorkoutsEventsQueryResponse, GetV1WorkoutsEventsQueryParams, GetV1WorkoutsEventsHeaderParams, GetV1WorkoutsEvents500 } from \"../types/GetV1WorkoutsEvents.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WorkoutsEventsUrl() {\n const res = { method: 'GET', url: `/v1/workouts/events` as const } \n return res\n}\n\n/**\n * @description Returns a paginated array of workout events, indicating updates or deletions.\n * @summary Retrieve a paged list of workout events (updates or deletes) since a given date. Events are ordered from newest to oldest. The intention is to allow clients to keep their local cache of workouts up to date without having to fetch the entire list of workouts.\n * {@link /v1/workouts/events}\n */\nexport async function getV1WorkoutsEvents(headers: GetV1WorkoutsEventsHeaderParams, params?: GetV1WorkoutsEventsQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WorkoutsEventsQueryResponse, ResponseErrorConfig<GetV1WorkoutsEvents500>, unknown>({ method : \"GET\", url : getGetV1WorkoutsEventsUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { GetV1WorkoutsWorkoutidQueryResponse, GetV1WorkoutsWorkoutidPathParams, GetV1WorkoutsWorkoutidHeaderParams, GetV1WorkoutsWorkoutid404 } from \"../types/GetV1WorkoutsWorkoutid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getGetV1WorkoutsWorkoutidUrl(workoutId: GetV1WorkoutsWorkoutidPathParams[\"workoutId\"]) {\n const res = { method: 'GET', url: `/v1/workouts/${workoutId}` as const } \n return res\n}\n\n/**\n * @summary Get a single workout’s complete details by the workoutId\n * {@link /v1/workouts/:workoutId}\n */\nexport async function getV1WorkoutsWorkoutid(workoutId: GetV1WorkoutsWorkoutidPathParams[\"workoutId\"], headers: GetV1WorkoutsWorkoutidHeaderParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const res = await request<GetV1WorkoutsWorkoutidQueryResponse, ResponseErrorConfig<GetV1WorkoutsWorkoutid404>, unknown>({ method : \"GET\", url : getGetV1WorkoutsWorkoutidUrl(workoutId).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PostV1RoutineFoldersMutationRequest, PostV1RoutineFoldersMutationResponse, PostV1RoutineFoldersHeaderParams, PostV1RoutineFolders400 } from \"../types/PostV1RoutineFolders.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPostV1RoutineFoldersUrl() {\n const res = { method: 'POST', url: `/v1/routine_folders` as const } \n return res\n}\n\n/**\n * @summary Create a new routine folder. The folder will be created at index 0, and all other folders will have their indexes incremented.\n * {@link /v1/routine_folders}\n */\nexport async function postV1RoutineFolders(headers: PostV1RoutineFoldersHeaderParams, data?: PostV1RoutineFoldersMutationRequest, config: Partial<RequestConfig<PostV1RoutineFoldersMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PostV1RoutineFoldersMutationResponse, ResponseErrorConfig<PostV1RoutineFolders400>, PostV1RoutineFoldersMutationRequest>({ method : \"POST\", url : getPostV1RoutineFoldersUrl().url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PostV1RoutinesMutationRequest, PostV1RoutinesMutationResponse, PostV1RoutinesHeaderParams, PostV1Routines400, PostV1Routines403 } from \"../types/PostV1Routines.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPostV1RoutinesUrl() {\n const res = { method: 'POST', url: `/v1/routines` as const } \n return res\n}\n\n/**\n * @summary Create a new routine\n * {@link /v1/routines}\n */\nexport async function postV1Routines(headers: PostV1RoutinesHeaderParams, data?: PostV1RoutinesMutationRequest, config: Partial<RequestConfig<PostV1RoutinesMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PostV1RoutinesMutationResponse, ResponseErrorConfig<PostV1Routines400 | PostV1Routines403>, PostV1RoutinesMutationRequest>({ method : \"POST\", url : getPostV1RoutinesUrl().url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PostV1WebhookSubscriptionMutationRequest, PostV1WebhookSubscriptionMutationResponse, PostV1WebhookSubscriptionHeaderParams, PostV1WebhookSubscription400 } from \"../types/PostV1WebhookSubscription.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPostV1WebhookSubscriptionUrl() {\n const res = { method: 'POST', url: `/v1/webhook-subscription` as const } \n return res\n}\n\n/**\n * @description This endpoint allows you to create a webhook subscription that will notify your application when a workout is created. Your endpoint must respond with a `200 OK` status within **5 seconds**, otherwise the delivery will be retried.When a new workout is created, we will send a POST request to your provided URL with the following JSON payload:```json { \"id\": \"00000000-0000-0000-0000-000000000001\", \"payload\": { \"workoutId\": \"f1085cdb-32b2-4003-967d-53a3af8eaecb\" }}\n * @summary Create a new webhook subscription.\n * {@link /v1/webhook-subscription}\n */\nexport async function postV1WebhookSubscription(headers: PostV1WebhookSubscriptionHeaderParams, data?: PostV1WebhookSubscriptionMutationRequest, config: Partial<RequestConfig<PostV1WebhookSubscriptionMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PostV1WebhookSubscriptionMutationResponse, ResponseErrorConfig<PostV1WebhookSubscription400>, PostV1WebhookSubscriptionMutationRequest>({ method : \"POST\", url : getPostV1WebhookSubscriptionUrl().url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PostV1WorkoutsMutationRequest, PostV1WorkoutsMutationResponse, PostV1WorkoutsHeaderParams, PostV1Workouts400 } from \"../types/PostV1Workouts.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPostV1WorkoutsUrl() {\n const res = { method: 'POST', url: `/v1/workouts` as const } \n return res\n}\n\n/**\n * @summary Create a new workout\n * {@link /v1/workouts}\n */\nexport async function postV1Workouts(headers: PostV1WorkoutsHeaderParams, data?: PostV1WorkoutsMutationRequest, config: Partial<RequestConfig<PostV1WorkoutsMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PostV1WorkoutsMutationResponse, ResponseErrorConfig<PostV1Workouts400>, PostV1WorkoutsMutationRequest>({ method : \"POST\", url : getPostV1WorkoutsUrl().url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PutV1RoutinesRoutineidMutationRequest, PutV1RoutinesRoutineidMutationResponse, PutV1RoutinesRoutineidPathParams, PutV1RoutinesRoutineidHeaderParams, PutV1RoutinesRoutineid400, PutV1RoutinesRoutineid404 } from \"../types/PutV1RoutinesRoutineid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPutV1RoutinesRoutineidUrl(routineId: PutV1RoutinesRoutineidPathParams[\"routineId\"]) {\n const res = { method: 'PUT', url: `/v1/routines/${routineId}` as const } \n return res\n}\n\n/**\n * @summary Update an existing routine\n * {@link /v1/routines/:routineId}\n */\nexport async function putV1RoutinesRoutineid(routineId: PutV1RoutinesRoutineidPathParams[\"routineId\"], headers: PutV1RoutinesRoutineidHeaderParams, data?: PutV1RoutinesRoutineidMutationRequest, config: Partial<RequestConfig<PutV1RoutinesRoutineidMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PutV1RoutinesRoutineidMutationResponse, ResponseErrorConfig<PutV1RoutinesRoutineid400 | PutV1RoutinesRoutineid404>, PutV1RoutinesRoutineidMutationRequest>({ method : \"PUT\", url : getPutV1RoutinesRoutineidUrl(routineId).url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/\n\nimport fetch from \"@kubb/plugin-client/clients/axios\";\nimport type { PutV1WorkoutsWorkoutidMutationRequest, PutV1WorkoutsWorkoutidMutationResponse, PutV1WorkoutsWorkoutidPathParams, PutV1WorkoutsWorkoutidHeaderParams, PutV1WorkoutsWorkoutid400 } from \"../types/PutV1WorkoutsWorkoutid.ts\";\nimport type { RequestConfig, ResponseErrorConfig } from \"@kubb/plugin-client/clients/axios\";\n\nfunction getPutV1WorkoutsWorkoutidUrl(workoutId: PutV1WorkoutsWorkoutidPathParams[\"workoutId\"]) {\n const res = { method: 'PUT', url: `/v1/workouts/${workoutId}` as const } \n return res\n}\n\n/**\n * @summary Update an existing workout\n * {@link /v1/workouts/:workoutId}\n */\nexport async function putV1WorkoutsWorkoutid(workoutId: PutV1WorkoutsWorkoutidPathParams[\"workoutId\"], headers: PutV1WorkoutsWorkoutidHeaderParams, data?: PutV1WorkoutsWorkoutidMutationRequest, config: Partial<RequestConfig<PutV1WorkoutsWorkoutidMutationRequest>> & { client?: typeof fetch } = {}) {\n const { client: request = fetch, ...requestConfig } = config \n \n const requestData = data \n \n const res = await request<PutV1WorkoutsWorkoutidMutationResponse, ResponseErrorConfig<PutV1WorkoutsWorkoutid400>, PutV1WorkoutsWorkoutidMutationRequest>({ method : \"PUT\", url : getPutV1WorkoutsWorkoutidUrl(workoutId).url.toString(), data : requestData, ... requestConfig, headers : { ...headers, ...requestConfig.headers } }) \n return res.data\n}","// Import the Kubb-based client\nimport { createClient as createKubbClient } from \"./hevyClientKubb.js\";\n\nexport function createClient(apiKey: string, baseUrl: string) {\n\treturn createKubbClient(apiKey, baseUrl);\n}\n\n// Export the HevyClient type for use in other modules\nexport type HevyClient = ReturnType<typeof createClient>;\n","import { runServer } from \"./index.js\";\n\nvoid runServer().catch((error) => {\n\tconsole.error(\"Fatal error in main():\", error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;AAAA,OAAO,aAAa;AACpB,YAAY,YAAY;AAgBxB,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,KAAAA,UAAS;;;AClBjB,WAAQ;AACR,cAAW;;;ACDZ,SAAS,SAAS;;;ACwCX,SAAS,oBACf,OACA,SACkB;AAClB,QAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAE1E,QAAM,YACL,iBAAiB,SAAS,UAAU,QAChC,MAA4B,OAC7B;AAGJ,QAAM,YAAY,mBAAmB,OAAO,YAAY;AAGxD,MAAI,WAAW;AACd,YAAQ,MAAM,eAAe,SAAS,EAAE;AAAA,EACzC;AAEA,QAAM,gBAAgB,UAAU,IAAI,OAAO,OAAO;AAClD,QAAM,mBAAmB,GAAG,aAAa,UAAU,YAAY;AAG/D,UAAQ,MAAM,GAAG,gBAAgB,WAAW,SAAS,KAA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AAI9B,IAAM,eAAe;AAAA,EACpB,KAAK;AAAA;AAAA,EAEL,kBAAkB;AAAA,EAClB,gBAAgB;AACjB;AAEO,YAAK,YAAY;AAcxB,IAAM,mBAAmB;AAEzB,IAAM,qBAAqBC,GAAE,OAAO;AAAA,EACnC,QAAQA,GACN,OAAO,EACP,IAAI,GAAG,0BAA0B,EACjC,SAAS,yDAAyD;AACrE,CAAC;AAKD,SAAS,YAAY,QAAgB;AACpC,QAAM,aAAa,IAAI,UAAU;AAAA,IAChC;AAAA,IACA;AAAA,EACD,CAAC;AACD,QAAM,SAAgB,+BAAwB,UAAU;AAExD,QAAM,aAAaC,cAAa,QAAQ,gBAAgB;AACxD,UAAQ,MAAM,sCAAsC;AAEpD,uBAAqB,QAAQ,UAAU;AACvC,uBAAqB,QAAQ,UAAU;AACvC,wBAAsB,QAAQ,UAAU;AACxC,sBAAoB,QAAQ,UAAU;AACtC,uBAAqB,QAAQ,UAAU;AAEvC,SAAO;AACR;AAQA,eAAsB,YAAY;AACjC,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,QAAM,MAAM,YAAY,MAAM,QAAQ,GAAG;AACzC,QAAM,SAAS,IAAI;AACnB,eAAa,MAAM;AAEnB,QAAM,SAAS,YAAY,MAAM;AACjC,UAAQ,MAAM,mCAAmC;AACjD,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAC/B;;;A+B1EA,KAAK,UAAU,EAAE,MAAM,CAAC,UAAU;AACjC,UAAQ,MAAM,0BAA0B,KAAK;AAC7C,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["z","name","z","z","z","z","z","z","z","z","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","fetch","createClient","z","createClient"]}