1010 */
1111
1212import {
13- BaseCollectionEntitySchema ,
1413 CollectionGetInputSchema ,
15- createCollectionBindings ,
1614 createCollectionGetOutputSchema ,
1715} from "@decocms/bindings/collections" ;
16+ import {
17+ PROMPTS_COLLECTION_BINDING ,
18+ PromptSchema ,
19+ } from "@decocms/bindings/prompt" ;
1820import { createPrivateTool } from "@decocms/runtime/tools" ;
1921import { z , type ZodType } from "zod" ;
2022import { runSQL } from "../lib/postgres.ts" ;
@@ -30,75 +32,6 @@ import type { Env } from "../main.ts";
3032// Schemas (following MCP Prompts specification)
3133// ============================================================================
3234
33- /**
34- * Schema for prompt arguments that can be passed when getting a prompt
35- */
36- const PromptArgumentSchema = z . object ( {
37- name : z . string ( ) . describe ( "Argument name" ) ,
38- description : z . string ( ) . optional ( ) . describe ( "Argument description" ) ,
39- required : z . boolean ( ) . optional ( ) . describe ( "Whether argument is required" ) ,
40- } ) ;
41-
42- /**
43- * Schema for prompt icons for display in user interfaces
44- */
45- const PromptIconSchema = z . object ( {
46- src : z . string ( ) . url ( ) . describe ( "Icon URL" ) ,
47- mimeType : z . string ( ) . optional ( ) . describe ( "Icon MIME type" ) ,
48- sizes : z . array ( z . string ( ) ) . optional ( ) . describe ( "Icon sizes" ) ,
49- } ) ;
50-
51- /**
52- * Schema for content within a prompt message
53- */
54- const PromptMessageContentSchema = z . object ( {
55- type : z . enum ( [ "text" , "image" , "audio" , "resource" ] ) . describe ( "Content type" ) ,
56- text : z . string ( ) . optional ( ) . describe ( "Text content" ) ,
57- data : z . string ( ) . optional ( ) . describe ( "Base64-encoded data for image/audio" ) ,
58- mimeType : z
59- . string ( )
60- . optional ( )
61- . describe ( "MIME type for image/audio/resource" ) ,
62- resource : z
63- . object ( {
64- uri : z . string ( ) . describe ( "Resource URI" ) ,
65- mimeType : z . string ( ) . optional ( ) . describe ( "Resource MIME type" ) ,
66- text : z . string ( ) . optional ( ) . describe ( "Resource text content" ) ,
67- blob : z . string ( ) . optional ( ) . describe ( "Base64-encoded resource blob" ) ,
68- } )
69- . optional ( )
70- . describe ( "Embedded resource" ) ,
71- } ) ;
72-
73- /**
74- * Schema for a message in a prompt
75- */
76- const PromptMessageSchema = z . object ( {
77- role : z . enum ( [ "user" , "assistant" ] ) . describe ( "Message role" ) ,
78- content : PromptMessageContentSchema . describe ( "Message content" ) ,
79- } ) ;
80-
81- /**
82- * Full prompt entity schema extending base collection fields
83- */
84- export const PromptSchema = BaseCollectionEntitySchema . extend ( {
85- arguments : z
86- . array ( PromptArgumentSchema )
87- . optional ( )
88- . describe ( "Arguments that can be passed when getting this prompt" ) ,
89- icons : z
90- . array ( PromptIconSchema )
91- . optional ( )
92- . describe ( "Icons for display in user interfaces" ) ,
93- messages : z . array ( PromptMessageSchema ) . describe ( "Prompt messages template" ) ,
94- } ) ;
95-
96- // Create collection bindings
97- const PROMPTS_COLLECTION_BINDING = createCollectionBindings (
98- "prompt" ,
99- PromptSchema ,
100- ) ;
101-
10235// Extract binding schemas
10336const LIST_BINDING = PROMPTS_COLLECTION_BINDING . find (
10437 ( b ) => b . name === "COLLECTION_PROMPT_LIST" ,
0 commit comments