mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: pipeline only shows compatible tools and displays errors
The pipeline tool picker was showing all tools, but only tools registered via createToolRoute() support pipeline execution. Tools with custom routes (remove-background, upscale, ocr, etc.) would silently fail with "Tool not found" and the empty catch block hid the error from users. Add GET /api/v1/pipeline/tools endpoint that returns the IDs of pipeline-compatible tools. The frontend fetches this list and filters the tool picker accordingly. Also surface pipeline execution errors in the UI instead of swallowing them.
This commit is contained in:
@@ -17,7 +17,7 @@ import { validateImageBuffer } from "../lib/file-validation.js";
|
||||
import { sanitizeFilename } from "../lib/filename.js";
|
||||
import { createWorkspace } from "../lib/workspace.js";
|
||||
import { requireAuth } from "../plugins/auth.js";
|
||||
import { getToolConfig } from "./tool-factory.js";
|
||||
import { getRegisteredToolIds, getToolConfig } from "./tool-factory.js";
|
||||
|
||||
/** Schema for a single pipeline step. */
|
||||
const pipelineStepSchema = z.object({
|
||||
@@ -312,5 +312,15 @@ export async function registerPipelineRoutes(app: FastifyInstance): Promise<void
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* GET /api/v1/pipeline/tools
|
||||
*
|
||||
* Returns the IDs of tools that can be used as pipeline steps.
|
||||
* Only tools registered via createToolRoute() support pipeline execution.
|
||||
*/
|
||||
app.get("/api/v1/pipeline/tools", async (_request: FastifyRequest, reply: FastifyReply) => {
|
||||
return reply.send({ toolIds: getRegisteredToolIds() });
|
||||
});
|
||||
|
||||
app.log.info("Pipeline routes registered");
|
||||
}
|
||||
|
||||
@@ -48,6 +48,14 @@ export function getToolConfig(toolId: string): AnyToolRouteConfig | undefined {
|
||||
return toolRegistry.get(toolId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the IDs of all tools registered via createToolRoute().
|
||||
* These are the tools that can be used in pipelines and batch processing.
|
||||
*/
|
||||
export function getRegisteredToolIds(): string[] {
|
||||
return [...toolRegistry.keys()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory that registers a POST /api/v1/tools/:toolId route.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user