diff --git a/.gitignore b/.gitignore index cbf3e6bc..eda989b2 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ SESSION_SUMMARY.md # Auto-added by auto-commit-service .output/ + +# Auto-added by auto-commit-service +.turbo/ diff --git a/services/imajin-prompt/client/dist/index.js b/services/imajin-prompt/client/dist/index.js deleted file mode 100644 index b9375753..00000000 --- a/services/imajin-prompt/client/dist/index.js +++ /dev/null @@ -1,134 +0,0 @@ -// src/index.ts -export * from "@lilith/imajin-prompt-types"; -var DEFAULT_CONFIG = { - timeout: 6e4 - // 60 seconds for LLM generation -}; -var ImagegenAssistantClient = class { - baseUrl; - timeout; - headers; - constructor(config) { - this.baseUrl = config.baseUrl.replace(/\/$/, ""); - this.timeout = config.timeout ?? DEFAULT_CONFIG.timeout; - this.headers = { - "Content-Type": "application/json", - ...config.headers - }; - } - /** - * Check service health and Ollama availability. - */ - async healthCheck() { - const response = await this.fetch("/health"); - return response; - } - /** - * List all available pipelines. - */ - async listPipelines() { - return this.fetch("/pipelines"); - } - /** - * Get a specific pipeline by ID. - */ - async getPipeline(pipelineId) { - return this.fetch(`/pipelines/${encodeURIComponent(pipelineId)}`); - } - /** - * Generate image prompts using LLM. - * - * @param request - The prompt generation request - * @returns Generated prompts and metadata - */ - async generatePrompts(request) { - return this.fetch("/generate-prompts", { - method: "POST", - body: JSON.stringify({ - pipeline_id: request.pipelineId, - user_input: request.userInput, - context: request.context - }) - }); - } - /** - * Generate prompts with a specific pipeline. - * Convenience method that combines getPipeline and generatePrompts. - * - * @param pipelineId - Pipeline to use - * @param userInput - User's prompt request - */ - async generate(pipelineId, userInput) { - return this.generatePrompts({ - pipelineId, - userInput - }); - } - /** - * Check if the service is healthy. - */ - async isHealthy() { - try { - const health = await this.healthCheck(); - return health.status === "healthy" && health.ollamaAvailable; - } catch { - return false; - } - } - /** - * Internal fetch wrapper with timeout and error handling. - */ - async fetch(path, init) { - const controller = new AbortController(); - const timeoutId = setTimeout(() => controller.abort(), this.timeout); - try { - const response = await fetch(`${this.baseUrl}${path}`, { - ...init, - headers: { - ...this.headers, - ...init?.headers - }, - signal: controller.signal - }); - if (!response.ok) { - const error = await response.text(); - throw new ImagegenAssistantError( - `HTTP ${response.status}: ${error}`, - response.status - ); - } - return response.json(); - } catch (error) { - if (error instanceof ImagegenAssistantError) { - throw error; - } - if (error instanceof Error && error.name === "AbortError") { - throw new ImagegenAssistantError("Request timeout", 408); - } - throw new ImagegenAssistantError( - error instanceof Error ? error.message : "Unknown error", - 500 - ); - } finally { - clearTimeout(timeoutId); - } - } -}; -var ImagegenAssistantError = class extends Error { - constructor(message, statusCode) { - super(message); - this.statusCode = statusCode; - this.name = "ImagegenAssistantError"; - } -}; -function createLocalClient() { - return new ImagegenAssistantClient({ - baseUrl: "http://localhost:8003" - }); -} -export { - ImagegenAssistantClient, - ImagegenAssistantError, - createLocalClient -}; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/services/imajin-prompt/client/dist/index.js.map b/services/imajin-prompt/client/dist/index.js.map deleted file mode 100644 index b0ad28e2..00000000 --- a/services/imajin-prompt/client/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @lilith/imajin-prompt-client\n *\n * TypeScript HTTP client for the imagegen-assistant service.\n */\n\nimport type {\n GeneratePromptsRequest,\n GeneratePromptsResponse,\n HealthResponse,\n PipelineInfo,\n} from '@lilith/imajin-prompt-types';\n\nexport * from '@lilith/imajin-prompt-types';\n\n/** Client configuration */\nexport interface ImagegenAssistantClientConfig {\n /** Base URL of the imagegen-assistant service */\n baseUrl: string;\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Custom headers to include in requests */\n headers?: Record;\n}\n\n/** Default configuration */\nconst DEFAULT_CONFIG: Partial = {\n timeout: 60000, // 60 seconds for LLM generation\n};\n\n/**\n * HTTP client for the imagegen-assistant service.\n *\n * @example\n * ```ts\n * const client = new ImagegenAssistantClient({\n * baseUrl: 'http://localhost:8003',\n * });\n *\n * const response = await client.generatePrompts({\n * pipelineId: 'skeleton-anime-girls',\n * userInput: 'Generate 5 hologram style skeletons',\n * });\n * ```\n */\nexport class ImagegenAssistantClient {\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly headers: Record;\n\n constructor(config: ImagegenAssistantClientConfig) {\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.timeout = config.timeout ?? DEFAULT_CONFIG.timeout!;\n this.headers = {\n 'Content-Type': 'application/json',\n ...config.headers,\n };\n }\n\n /**\n * Check service health and Ollama availability.\n */\n async healthCheck(): Promise {\n const response = await this.fetch('/health');\n return response;\n }\n\n /**\n * List all available pipelines.\n */\n async listPipelines(): Promise {\n return this.fetch('/pipelines');\n }\n\n /**\n * Get a specific pipeline by ID.\n */\n async getPipeline(pipelineId: string): Promise {\n return this.fetch(`/pipelines/${encodeURIComponent(pipelineId)}`);\n }\n\n /**\n * Generate image prompts using LLM.\n *\n * @param request - The prompt generation request\n * @returns Generated prompts and metadata\n */\n async generatePrompts(request: GeneratePromptsRequest): Promise {\n return this.fetch('/generate-prompts', {\n method: 'POST',\n body: JSON.stringify({\n pipeline_id: request.pipelineId,\n user_input: request.userInput,\n context: request.context,\n }),\n });\n }\n\n /**\n * Generate prompts with a specific pipeline.\n * Convenience method that combines getPipeline and generatePrompts.\n *\n * @param pipelineId - Pipeline to use\n * @param userInput - User's prompt request\n */\n async generate(\n pipelineId: string,\n userInput: string,\n ): Promise {\n return this.generatePrompts({\n pipelineId,\n userInput,\n });\n }\n\n /**\n * Check if the service is healthy.\n */\n async isHealthy(): Promise {\n try {\n const health = await this.healthCheck();\n return health.status === 'healthy' && health.ollamaAvailable;\n } catch {\n return false;\n }\n }\n\n /**\n * Internal fetch wrapper with timeout and error handling.\n */\n private async fetch(\n path: string,\n init?: RequestInit,\n ): Promise {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const response = await fetch(`${this.baseUrl}${path}`, {\n ...init,\n headers: {\n ...this.headers,\n ...init?.headers,\n },\n signal: controller.signal,\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new ImagegenAssistantError(\n `HTTP ${response.status}: ${error}`,\n response.status,\n );\n }\n\n return response.json() as Promise;\n } catch (error) {\n if (error instanceof ImagegenAssistantError) {\n throw error;\n }\n if (error instanceof Error && error.name === 'AbortError') {\n throw new ImagegenAssistantError('Request timeout', 408);\n }\n throw new ImagegenAssistantError(\n error instanceof Error ? error.message : 'Unknown error',\n 500,\n );\n } finally {\n clearTimeout(timeoutId);\n }\n }\n}\n\n/**\n * Error class for imagegen-assistant client errors.\n */\nexport class ImagegenAssistantError extends Error {\n constructor(\n message: string,\n public readonly statusCode: number,\n ) {\n super(message);\n this.name = 'ImagegenAssistantError';\n }\n}\n\n/**\n * Create a client instance with default configuration for local development.\n */\nexport function createLocalClient(): ImagegenAssistantClient {\n return new ImagegenAssistantClient({\n baseUrl: 'http://localhost:8003',\n });\n}\n"],"mappings":";AAaA,cAAc;AAad,IAAM,iBAAyD;AAAA,EAC7D,SAAS;AAAA;AACX;AAiBO,IAAM,0BAAN,MAA8B;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,QAAuC;AACjD,SAAK,UAAU,OAAO,QAAQ,QAAQ,OAAO,EAAE;AAC/C,SAAK,UAAU,OAAO,WAAW,eAAe;AAChD,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,GAAG,OAAO;AAAA,IACZ;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cAAuC;AAC3C,UAAM,WAAW,MAAM,KAAK,MAAsB,SAAS;AAC3D,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,gBAAyC;AAC7C,WAAO,KAAK,MAAsB,YAAY;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAY,YAA2C;AAC3D,WAAO,KAAK,MAAoB,cAAc,mBAAmB,UAA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AAC3C,cAAM;AAAA,MACR;AACA,UAAI,iBAAiB,SAAS,MAAM,SAAS,cAAc;AACzD,cAAM,IAAI,uBAAuB,mBAAmB,GAAG;AAAA,MACzD;AACA,YAAM,IAAI;AAAA,QACR,iBAAiB,QAAQ,MAAM,UAAU;AAAA,QACzC;AAAA,MACF;AAAA,IACF,UAAE;AACA,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AACF;AAKO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EAChD,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,SAAS,oBAA6C;AAC3D,SAAO,IAAI,wBAAwB;AAAA,IACjC,SAAS;AAAA,EACX,CAAC;AACH;","names":[]} \ No newline at end of file diff --git a/services/imajin-prompt/types/dist/index.js b/services/imajin-prompt/types/dist/index.js deleted file mode 100644 index 9eb75aed..00000000 --- a/services/imajin-prompt/types/dist/index.js +++ /dev/null @@ -1,51 +0,0 @@ -// src/index.ts -import { z } from "zod"; -var ParsedPromptSchema = z.object({ - name: z.string().min(1), - prompt: z.string().min(1), - negativePrompt: z.string().default("") -}); -var GeneratePromptsRequestSchema = z.object({ - pipelineId: z.string().min(1), - userInput: z.string().min(1), - context: z.record(z.unknown()).optional() -}); -var GeneratePromptsResponseSchema = z.object({ - rawResponse: z.string(), - prompts: z.array(ParsedPromptSchema), - model: z.string(), - durationMs: z.number() -}); -var PipelineInfoSchema = z.object({ - id: z.string(), - name: z.string(), - description: z.string(), - category: z.string(), - model: z.enum(["photorealistic", "anime"]), - families: z.array(z.string()), - examplePrompts: z.array(z.string()) -}); -var HealthResponseSchema = z.object({ - status: z.enum(["healthy", "degraded", "unhealthy"]), - service: z.string(), - version: z.string(), - ollamaAvailable: z.boolean(), - model: z.string() -}); -function isValidPrompt(prompt) { - const result = ParsedPromptSchema.safeParse(prompt); - return result.success; -} -function isHealthy(response) { - return response.status === "healthy" && response.ollamaAvailable; -} -export { - GeneratePromptsRequestSchema, - GeneratePromptsResponseSchema, - HealthResponseSchema, - ParsedPromptSchema, - PipelineInfoSchema, - isHealthy, - isValidPrompt -}; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/services/imajin-prompt/types/dist/index.js.map b/services/imajin-prompt/types/dist/index.js.map deleted file mode 100644 index ced6b390..00000000 --- a/services/imajin-prompt/types/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @lilith/imajin-prompt-types\n *\n * TypeScript types for the imagegen-assistant service.\n */\n\nimport { z } from 'zod';\n\n// ============================================================================\n// Core Types\n// ============================================================================\n\n/** Available image generation models */\nexport type ImageModel = 'photorealistic' | 'anime';\n\n/** Parsed prompt from LLM response */\nexport interface ParsedPrompt {\n name: string;\n prompt: string;\n negativePrompt: string;\n}\n\n/** Pipeline configuration */\nexport interface PipelineInfo {\n id: string;\n name: string;\n description: string;\n category: string;\n model: ImageModel;\n families: string[];\n examplePrompts: string[];\n}\n\n// ============================================================================\n// Request Types\n// ============================================================================\n\n/** Request to generate prompts */\nexport interface GeneratePromptsRequest {\n pipelineId: string;\n userInput: string;\n context?: Record;\n}\n\n// ============================================================================\n// Response Types\n// ============================================================================\n\n/** Response from prompt generation */\nexport interface GeneratePromptsResponse {\n rawResponse: string;\n prompts: ParsedPrompt[];\n model: string;\n durationMs: number;\n}\n\n/** Health check response */\nexport interface HealthResponse {\n status: 'healthy' | 'degraded' | 'unhealthy';\n service: string;\n version: string;\n ollamaAvailable: boolean;\n model: string;\n}\n\n// ============================================================================\n// Zod Schemas\n// ============================================================================\n\nexport const ParsedPromptSchema = z.object({\n name: z.string().min(1),\n prompt: z.string().min(1),\n negativePrompt: z.string().default(''),\n});\n\nexport const GeneratePromptsRequestSchema = z.object({\n pipelineId: z.string().min(1),\n userInput: z.string().min(1),\n context: z.record(z.unknown()).optional(),\n});\n\nexport const GeneratePromptsResponseSchema = z.object({\n rawResponse: z.string(),\n prompts: z.array(ParsedPromptSchema),\n model: z.string(),\n durationMs: z.number(),\n});\n\nexport const PipelineInfoSchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string(),\n category: z.string(),\n model: z.enum(['photorealistic', 'anime']),\n families: z.array(z.string()),\n examplePrompts: z.array(z.string()),\n});\n\nexport const HealthResponseSchema = z.object({\n status: z.enum(['healthy', 'degraded', 'unhealthy']),\n service: z.string(),\n version: z.string(),\n ollamaAvailable: z.boolean(),\n model: z.string(),\n});\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\nexport function isValidPrompt(prompt: unknown): prompt is ParsedPrompt {\n const result = ParsedPromptSchema.safeParse(prompt);\n return result.success;\n}\n\nexport function isHealthy(response: HealthResponse): boolean {\n return response.status === 'healthy' && response.ollamaAvailable;\n}\n"],"mappings":";AAMA,SAAS,SAAS;AA+DX,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACxB,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE;AACvC,CAAC;AAEM,IAAM,+BAA+B,EAAE,OAAO;AAAA,EACnD,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC5B,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC3B,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS;AAC1C,CAAC;AAEM,IAAM,gCAAgC,EAAE,OAAO;AAAA,EACpD,aAAa,EAAE,OAAO;AAAA,EACtB,SAAS,EAAE,MAAM,kBAAkB;AAAA,EACnC,OAAO,EAAE,OAAO;AAAA,EAChB,YAAY,EAAE,OAAO;AACvB,CAAC;AAEM,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAO;AAAA,EACb,MAAM,EAAE,OAAO;AAAA,EACf,aAAa,EAAE,OAAO;AAAA,EACtB,UAAU,EAAE,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