sweagent 0.0.4 → 0.0.5
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/README.md +21 -106
- package/dist/index.cjs +26 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -3
- package/dist/index.d.ts +33 -3
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/stdio.js +22 -24
- package/dist/stdio.js.map +1 -1
- package/package.json +1 -1
package/dist/stdio.js
CHANGED
|
@@ -959,7 +959,7 @@ Return ONLY valid JSON:
|
|
|
959
959
|
}],
|
|
960
960
|
"middleware": [{ "name": "authMiddleware", "type": "auth", "config": {} }],
|
|
961
961
|
"envVars": ["PORT", "DATABASE_URL", "JWT_SECRET", "NODE_ENV"]
|
|
962
|
-
}`;function Mr(e){return ka.replace("{requirement}",e)}var Bt=I("validate_express",Be,"Validates an Express config JSON string against the ExpressConfig schema. Returns valid: true or valid: false with errors.","config");function Jt(e){return S({name:"generate_express",description:"Generate a complete Express.js application configuration from data model and API design. Returns routers, models, middleware, and env vars as JSON.",input:z$1.object({requirement:z$1.string().describe("Data model, API design, and project requirements")}),handler:async({requirement:t})=>{let o=Mr(t),r=[{role:"system",content:"You are an Express.js architect. Return only valid JSON."},{role:"user",content:o}],n=await e.invoke(r,{temperature:.3,maxOutputTokens:16384});return M(n.text,Be)}})}function ja(e,t){return oe.compile(e,{noEscape:true})(t)}function qa(e,t=e){let o=[];if(!Z.existsSync(e))return o;let r=Z.readdirSync(e,{withFileTypes:true});for(let n of r){let s=le.join(e,n.name);n.isDirectory()?o.push(...qa(s,t)):n.name.endsWith(".hbs")&&o.push(le.relative(t,s));}return o}function Ni(e){return e.replace(/\.hbs$/,"")}function _i(e,t){for(let o of t)if(new RegExp("^"+o.replace(/\./g,"\\.").replace(/\*\*/g,"<<GLOBSTAR>>").replace(/\*/g,"[^/]*").replace(/<<GLOBSTAR>>/g,".*")+"$").test(e))return true;return false}async function me(e){let{templateDir:t,outputDir:o,context:r,skipPatterns:n=[]}=e,s=qa(t),a=[],i=[];for(let l of s){if(_i(l,n))continue;let p=Ni(l),c=le.join(t,l),d=le.join(o,p);try{let g=Z.readFileSync(c,"utf-8"),h=ja(g,r);Z.mkdirSync(le.dirname(d),{recursive:!0}),Z.writeFileSync(d,h,"utf-8"),a.push(p);}catch(g){i.push({file:l,message:g instanceof Error?g.message:String(g)});}}return {fileCount:a.length,files:a,errors:i}}function Fa(){oe.registerHelper("eq",(e,t)=>e===t),oe.registerHelper("neq",(e,t)=>e!==t),oe.registerHelper("json",e=>JSON.stringify(e,null,2)),oe.registerHelper("uppercase",e=>typeof e=="string"?e.toUpperCase():""),oe.registerHelper("lowercase",e=>typeof e=="string"?e.toLowerCase():""),oe.registerHelper("capitalize",e=>typeof e=="string"?e.charAt(0).toUpperCase()+e.slice(1):""),oe.registerHelper("camelCase",e=>typeof e!="string"?"":e.replace(/[-_\s]+(.)?/g,(t,o)=>o?o.toUpperCase():"").replace(/^(.)/,t=>t.toLowerCase())),oe.registerHelper("pascalCase",e=>typeof e!="string"?"":e.replace(/[-_\s]+(.)?/g,(t,o)=>o?o.toUpperCase():"").replace(/^(.)/,t=>t.toUpperCase()));}Fa();function ki(e){return {appName:e.appName,port:e.port,database:e.database,routers:e.routers,models:e.models,middleware:e.middleware,envVars:e.envVars,modules:e.routers.map(t=>({name:t.resource,pascalName:t.name.charAt(0).toUpperCase()+t.name.slice(1),camelName:t.resource,methods:t.methods}))}}
|
|
962
|
+
}`;function Mr(e){return ka.replace("{requirement}",e)}var Bt=I("validate_express",Be,"Validates an Express config JSON string against the ExpressConfig schema. Returns valid: true or valid: false with errors.","config");function Jt(e){return S({name:"generate_express",description:"Generate a complete Express.js application configuration from data model and API design. Returns routers, models, middleware, and env vars as JSON.",input:z$1.object({requirement:z$1.string().describe("Data model, API design, and project requirements")}),handler:async({requirement:t})=>{let o=Mr(t),r=[{role:"system",content:"You are an Express.js architect. Return only valid JSON."},{role:"user",content:o}],n=await e.invoke(r,{temperature:.3,maxOutputTokens:16384});return M(n.text,Be)}})}function ja(e,t){return oe.compile(e,{noEscape:true})(t)}function qa(e,t=e){let o=[];if(!Z.existsSync(e))return o;let r=Z.readdirSync(e,{withFileTypes:true});for(let n of r){let s=le.join(e,n.name);n.isDirectory()?o.push(...qa(s,t)):n.name.endsWith(".hbs")&&o.push(le.relative(t,s));}return o}function Ni(e){return e.replace(/\.hbs$/,"")}function _i(e,t){for(let o of t)if(new RegExp("^"+o.replace(/\./g,"\\.").replace(/\*\*/g,"<<GLOBSTAR>>").replace(/\*/g,"[^/]*").replace(/<<GLOBSTAR>>/g,".*")+"$").test(e))return true;return false}async function me(e){let{templateDir:t,outputDir:o,context:r,skipPatterns:n=[]}=e,s=qa(t),a=[],i=[];for(let l of s){if(_i(l,n))continue;let p=Ni(l),c=le.join(t,l),d=le.join(o,p);try{let g=Z.readFileSync(c,"utf-8"),h=ja(g,r);Z.mkdirSync(le.dirname(d),{recursive:!0}),Z.writeFileSync(d,h,"utf-8"),a.push(p);}catch(g){i.push({file:l,message:g instanceof Error?g.message:String(g)});}}return {fileCount:a.length,files:a,errors:i}}function Fa(){oe.registerHelper("eq",(e,t)=>e===t),oe.registerHelper("neq",(e,t)=>e!==t),oe.registerHelper("json",e=>JSON.stringify(e,null,2)),oe.registerHelper("uppercase",e=>typeof e=="string"?e.toUpperCase():""),oe.registerHelper("lowercase",e=>typeof e=="string"?e.toLowerCase():""),oe.registerHelper("capitalize",e=>typeof e=="string"?e.charAt(0).toUpperCase()+e.slice(1):""),oe.registerHelper("camelCase",e=>typeof e!="string"?"":e.replace(/[-_\s]+(.)?/g,(t,o)=>o?o.toUpperCase():"").replace(/^(.)/,t=>t.toLowerCase())),oe.registerHelper("pascalCase",e=>typeof e!="string"?"":e.replace(/[-_\s]+(.)?/g,(t,o)=>o?o.toUpperCase():"").replace(/^(.)/,t=>t.toUpperCase()));}Fa();function ki(e){return {appName:e.appName,port:e.port,database:e.database,routers:e.routers,models:e.models,middleware:e.middleware,envVars:e.envVars,modules:e.routers.map(t=>({name:t.resource,pascalName:t.name.charAt(0).toUpperCase()+t.name.slice(1),camelName:t.resource,methods:t.methods}))}}S({name:"scaffold_express",description:"Scaffold an Express.js project from a validated config. Compiles Handlebars templates and writes the project to the output directory.",input:z$1.object({config:z$1.string().describe("JSON string of the validated Express config"),outputDir:z$1.string().describe("Absolute path to the output directory")}),handler:async({config:e,outputDir:t})=>{let o=_e(e,"express config"),r=le.resolve(process.cwd(),".ref/templates/express"),n=ki(o);return me({templateDir:r,outputDir:t,context:n})}});function Cr(e,t){let o={validate_express:Bt,generate_express:Jt(e)};return o}var Ii=`You are an Express.js route specialist. Given an API design, you generate route definitions using a co-located router pattern.
|
|
963
963
|
|
|
964
964
|
## Co-located Router Pattern
|
|
965
965
|
Each feature lives in src/routers/{name}/ with three files:
|
|
@@ -1023,17 +1023,16 @@ Respond with structured route definitions. Do NOT return JSON.`,zt=f({name:"rout
|
|
|
1023
1023
|
1. **Global**: Limit requests per IP per time window
|
|
1024
1024
|
2. **Auth routes**: Stricter limits on login/signup
|
|
1025
1025
|
|
|
1026
|
-
Respond with structured middleware analysis. Do NOT return JSON.`,$t=f({name:"middleware-configurator",description:"Designs the Express middleware stack including auth, validation, error handling, CORS, and rate limiting. Use before generating the Express config.",systemPrompt:ji,tools:{},maxIterations:2});
|
|
1026
|
+
Respond with structured middleware analysis. Do NOT return JSON.`,$t=f({name:"middleware-configurator",description:"Designs the Express middleware stack including auth, validation, error handling, CORS, and rate limiting. Use before generating the Express config.",systemPrompt:ji,tools:{},maxIterations:2});function Fi(e){return `${Er}
|
|
1027
1027
|
|
|
1028
1028
|
You are the Express builder orchestrator. When the user provides requirements:
|
|
1029
1029
|
|
|
1030
1030
|
1. **Generate routes**: Use subagent_route-generator to design route definitions from the API design.
|
|
1031
1031
|
2. **Configure middleware**: Use subagent_middleware-configurator to design the middleware stack.
|
|
1032
1032
|
3. **Generate config**: Use generate_express to produce the complete Express configuration as JSON.
|
|
1033
|
-
4. **Validate**: Use validate_express to check the config JSON before returning
|
|
1034
|
-
5. **Scaffold (optional)**: If an output directory is provided, use scaffold_express to compile templates.
|
|
1033
|
+
4. **Validate**: Use validate_express to check the config JSON before returning.${""}
|
|
1035
1034
|
|
|
1036
|
-
Respond with the final Express config as JSON
|
|
1035
|
+
Respond with the final Express config as JSON.`}async function Dr(e){let{input:t,model:o,maxIterations:r=15,onStep:n,logger:s}=e,i=E(o??{provider:"openai",model:"gpt-4o-mini"}),l=Cr(i),p=q([zt,$t],{parentModel:i}),c={...l,...p};return N({model:i,tools:c,systemPrompt:Fi(),input:t,maxIterations:r,onStep:n,logger:s})}var La=e=>z$1.string().transform(t=>t.toLowerCase().trim()).pipe(z$1.enum(e)),Nr=z$1.object({name:z$1.string(),type:z$1.string(),nullable:z$1.coerce.boolean().default(false),isList:z$1.coerce.boolean().default(false),description:z$1.string().default("")}),_r=z$1.object({name:z$1.string(),kind:La(["type","input","enum","interface","union"]),fields:z$1.array(Nr).default([]),values:z$1.array(z$1.string()).default([]),description:z$1.string().default(""),isEntity:z$1.coerce.boolean().default(false),keyFields:z$1.array(z$1.string()).default([])}),Ga=z$1.object({name:z$1.string(),type:La(["query","mutation","subscription"]),args:z$1.array(Nr).default([]),returnType:z$1.string(),auth:z$1.coerce.boolean().default(true),roles:z$1.array(z$1.string()).default([]),description:z$1.string().default("")}),Ba=z$1.object({name:z$1.string(),entity:z$1.string(),types:z$1.array(_r).default([]),operations:z$1.array(Ga).default([]),datasource:z$1.string().default(""),loader:z$1.string().default("")}),Je=z$1.object({appName:z$1.string().default("app"),port:z$1.number().default(4e3),database:z$1.string().default("mongodb"),modules:z$1.array(Ba).default([]),sharedTypes:z$1.array(_r).default([]),authDirective:z$1.coerce.boolean().default(true),cacheDirective:z$1.coerce.boolean().default(false),envVars:z$1.array(z$1.string()).default([])});var kr=`You are an expert Apollo GraphQL subgraph architect using Apollo Federation v2.
|
|
1037
1036
|
|
|
1038
1037
|
You generate production-ready Apollo subgraph configurations from data models and API designs:
|
|
1039
1038
|
- 4-file module pattern per entity: {module}.graphql, {module}.resolver.ts, {module}.datasource.ts, {module}.loader.ts
|
|
@@ -1081,7 +1080,7 @@ Return ONLY valid JSON:
|
|
|
1081
1080
|
"authDirective": true,
|
|
1082
1081
|
"cacheDirective": false,
|
|
1083
1082
|
"envVars": ["PORT", "DATABASE_URL", "JWT_SECRET", "REDIS_URL"]
|
|
1084
|
-
}`;function Ir(e){return Ja.replace("{requirement}",e)}var Qt=I("validate_subgraph",Je,"Validates a subgraph config JSON string against the SubgraphConfig schema. Returns valid: true or valid: false with errors.","config");function Ht(e){return S({name:"generate_subgraph",description:"Generate a complete Apollo GraphQL subgraph configuration from data model and API design. Returns modules, types, operations, and datasources as JSON.",input:z$1.object({requirement:z$1.string().describe("Data model, API design, and project requirements")}),handler:async({requirement:t})=>{let o=Ir(t),r=[{role:"system",content:"You are an Apollo GraphQL architect. Return only valid JSON."},{role:"user",content:o}],n=await e.invoke(r,{temperature:.3,maxOutputTokens:16384});return M(n.text,Je)}})}function
|
|
1083
|
+
}`;function Ir(e){return Ja.replace("{requirement}",e)}var Qt=I("validate_subgraph",Je,"Validates a subgraph config JSON string against the SubgraphConfig schema. Returns valid: true or valid: false with errors.","config");function Ht(e){return S({name:"generate_subgraph",description:"Generate a complete Apollo GraphQL subgraph configuration from data model and API design. Returns modules, types, operations, and datasources as JSON.",input:z$1.object({requirement:z$1.string().describe("Data model, API design, and project requirements")}),handler:async({requirement:t})=>{let o=Ir(t),r=[{role:"system",content:"You are an Apollo GraphQL architect. Return only valid JSON."},{role:"user",content:o}],n=await e.invoke(r,{temperature:.3,maxOutputTokens:16384});return M(n.text,Je)}})}function Ui(e){return {appName:e.appName,port:e.port,database:e.database,modules:e.modules.map(t=>({name:t.name,pascalName:t.name.charAt(0).toUpperCase()+t.name.slice(1),camelName:t.name.charAt(0).toLowerCase()+t.name.slice(1),entity:t.entity,datasource:t.datasource,types:t.types,operations:t.operations})),authDirective:e.authDirective,envVars:e.envVars,sharedTypes:e.sharedTypes}}S({name:"scaffold_subgraph",description:"Scaffold an Apollo GraphQL subgraph project from a validated config. Compiles Handlebars templates and writes the project to the output directory.",input:z$1.object({config:z$1.string().describe("JSON string of the validated subgraph config"),outputDir:z$1.string().describe("Absolute path to the output directory")}),handler:async({config:e,outputDir:t})=>{let o=_e(e,"subgraph config"),r=le.resolve(process.cwd(),".ref/templates/subgraph"),n=Ui(o);return me({templateDir:r,outputDir:t,context:n})}});function qr(e,t){let o={validate_subgraph:Qt,generate_subgraph:Ht(e)};return o}var Li=`You are a GraphQL schema specialist for Apollo Federation v2 subgraphs. Given a data model, you generate GraphQL type definitions using buildSubgraphSchema.
|
|
1085
1084
|
|
|
1086
1085
|
## Type Generation
|
|
1087
1086
|
For each entity in the data model:
|
|
@@ -1112,7 +1111,7 @@ For each entity in the data model:
|
|
|
1112
1111
|
- Inputs: PascalCase + Input suffix (CreateUserInput, UpdateUserInput)
|
|
1113
1112
|
- Enums: SCREAMING_SNAKE_CASE values (ADMIN, ACTIVE)
|
|
1114
1113
|
|
|
1115
|
-
Respond with the full GraphQL SDL. Do NOT return JSON.`,Wt=f({name:"schema-generator",description:"Generates GraphQL type definitions, input types, and enums from a data model. Use before generating the subgraph config.",systemPrompt:
|
|
1114
|
+
Respond with the full GraphQL SDL. Do NOT return JSON.`,Wt=f({name:"schema-generator",description:"Generates GraphQL type definitions, input types, and enums from a data model. Use before generating the subgraph config.",systemPrompt:Li,tools:{},maxIterations:2});var Gi=`You are a GraphQL resolver architect for Apollo Federation v2 subgraphs. Given types and operations, you plan resolver implementations.
|
|
1116
1115
|
|
|
1117
1116
|
## 4-File Module Pattern
|
|
1118
1117
|
Each module has four files:
|
|
@@ -1159,17 +1158,16 @@ Each module has a loader file that creates DataLoader instances:
|
|
|
1159
1158
|
- Verify role permissions per operation
|
|
1160
1159
|
- Resource ownership checks for user-specific data
|
|
1161
1160
|
|
|
1162
|
-
Respond with structured analysis per module. Do NOT return JSON.`,Xt=f({name:"resolver-planner",description:"Plans resolver implementations, datasource methods, and auth integration per GraphQL module. Use after schema generation.",systemPrompt:
|
|
1161
|
+
Respond with structured analysis per module. Do NOT return JSON.`,Xt=f({name:"resolver-planner",description:"Plans resolver implementations, datasource methods, and auth integration per GraphQL module. Use after schema generation.",systemPrompt:Gi,tools:{},maxIterations:2});function Ji(e){return `${kr}
|
|
1163
1162
|
|
|
1164
1163
|
You are the Apollo subgraph builder orchestrator. When the user provides requirements:
|
|
1165
1164
|
|
|
1166
1165
|
1. **Generate schema**: Use subagent_schema-generator to create GraphQL type definitions from the data model.
|
|
1167
1166
|
2. **Plan resolvers**: Use subagent_resolver-planner to design resolver implementations per module.
|
|
1168
1167
|
3. **Generate config**: Use generate_subgraph to produce the complete subgraph configuration as JSON.
|
|
1169
|
-
4. **Validate**: Use validate_subgraph to check the config JSON before returning
|
|
1170
|
-
5. **Scaffold (optional)**: If an output directory is provided, use scaffold_subgraph to compile templates.
|
|
1168
|
+
4. **Validate**: Use validate_subgraph to check the config JSON before returning.${""}
|
|
1171
1169
|
|
|
1172
|
-
Respond with the final subgraph config as JSON
|
|
1170
|
+
Respond with the final subgraph config as JSON.`}async function Fr(e){let{input:t,model:o,maxIterations:r=15,onStep:n,logger:s}=e,i=E(o??{provider:"openai",model:"gpt-4o-mini"}),l=qr(i),p=q([Wt,Xt],{parentModel:i}),c={...l,...p};return N({model:i,tools:c,systemPrompt:Ji(),input:t,maxIterations:r,onStep:n,logger:s})}var Ur=z$1.object({brandName:z$1.string().describe("The brand's display name"),primaryColor:z$1.string().describe("The brand's primary color code (e.g., #FFFFFF)"),secondaryColor:z$1.string().describe("The brand's secondary color code (e.g., #000000)"),logo:z$1.url().describe("URL pointing to the brand's logo")});var Lr=z$1.object({name:z$1.string().describe("Application name"),description:z$1.string().describe("Brief description of the application"),author:z$1.string().describe("Author or owner of the application").default("sijeeshmiziha (HubSpire)"),branding:Ur.describe("Branding information for the application"),apiEndpoint:z$1.url().describe("URL endpoint for the app's API calls")});var $a=z$1.object({minLength:z$1.number().optional().describe("Minimum length requirement"),zodString:z$1.string().describe("Raw Zod string validation (e.g. regex)")}),Qa=z$1.object({hookName:z$1.string().optional().describe("Name of the hook for dynamic field options"),queryString:z$1.string().optional().describe("Optional query string for fetching field options"),labelKey:z$1.string().optional().describe("Key used as label when displaying options"),valueKey:z$1.string().optional().describe("Key used as value for a field when selecting options"),values:z$1.array(z$1.string()).optional().describe("Static list of possible field values")}),Kt=z$1.object({name:z$1.string().describe("The field's key or identifier"),type:z$1.enum(["text","email","password","number","multiSelect","textarea","hidden","select","date","image"]).describe('Type of input field. If it has options, it should not be "hidden". If the field is required, it should not be hidden unless it serves as the current user.'),required:z$1.boolean().optional().describe("Whether this field must be filled"),validation:$a.optional().describe("Optional field validation requirements"),defaultValue:z$1.union([z$1.string(),z$1.number(),z$1.boolean()]).optional().describe("Default value can be string, number, or boolean"),options:Qa.optional().describe("Additional dynamic or static options for this field")}),Gr=z$1.object({field:z$1.string().describe("Key or name of the data field in the table"),label:z$1.string().describe("User-friendly label to show on the table header")});var Jr=z$1.object({type:z$1.string().describe("Indicates the response type (e.g., 'object')"),properties:z$1.record(z$1.string(),z$1.object({type:z$1.string().describe("Property type as returned by the API")})).describe("Key-value record describing each field in the response")}).optional().describe("Describes the expected structure of an API response"),Ha=z$1.object({type:z$1.enum(["list","create","update","delete","getById"]).describe("Type of API call for CRUD operations"),graphqlHook:z$1.string().describe("Name of the GraphQL hook (e.g. useGetAllUserQuery, useCreateUserMutation)"),queryString:z$1.string().describe("Actual GraphQL query string"),responseType:Jr.describe("Optional schema describing shape of the API response")}),Va=z$1.object({type:z$1.enum(["login","currentUser","forgotPassword","resetPassword"]).describe("Type of API call"),graphqlHook:z$1.string().describe("Name of the GraphQL hook (e.g. useLoginMutation)"),queryString:z$1.string().describe("Actual GraphQL query string"),responseType:Jr.describe("Optional schema describing shape of the API response")}),Br=z$1.object({title:z$1.string().describe("Title displayed on the drawer"),graphqlHook:z$1.string().describe("Name of the GraphQL hook (e.g. useCreateUserMutation, useDeleteOneUserMutation)"),fields:z$1.array(Kt).describe("List of fields displayed within the drawer")}),Wa=z$1.object({name:z$1.enum(["LoginPage","ForgotPasswordPage","ResetPasswordPage"]).describe("Internal name of the auth page"),type:z$1.enum(["EmailPassword","ForgotPassword","ResetPassword"]).describe("Type of authentication page"),route:z$1.string().describe("URL route for this page (e.g., '/login')"),isPrivate:z$1.boolean().describe("Whether this page requires an authenticated session"),api:z$1.array(Va).describe("List of API calls involved in this page"),fields:z$1.array(Kt).optional().describe("Optional form fields needed on this auth page")}),Xa=z$1.object({type:z$1.literal("Listing").describe("Indicates that this page is a listing-type page"),name:z$1.string().describe("Internal name of the listing page"),route:z$1.string().describe("URL route for this listing page"),isPrivate:z$1.boolean().describe("Whether this page is private (requires auth)"),api:z$1.array(Ha).describe("List of API calls that power this listing page"),columns:z$1.array(Gr).describe("Table columns displayed on the listing page"),actions:z$1.array(z$1.string()).describe("List of possible actions on each row (e.g., create, edit, delete, view)"),drawerCreate:Br.describe("Drawer configuration for creating new records"),drawerUpdate:Br.describe("Drawer configuration for editing existing records")}),Yr=z$1.discriminatedUnion("type",[Wa,Xa]);var Ka=z$1.object({name:z$1.string().describe("Name of the module"),pages:z$1.array(Yr).describe("Pages included within this module")}),Qe=z$1.object({app:Lr.describe("Overall application configuration"),modules:z$1.array(Ka).describe("List of modules that make up the application. Ensure all modules use every available CRUD GraphQL query and mutation from the schema.")});z$1.object({email:z$1.email().describe("User's email address, must be valid format"),password:z$1.string().min(8).describe("User's password, minimum length of 8")});var Za=z$1.object({_id:z$1.string().describe("Unique identifier of the specialization, type: string"),title:z$1.string().describe("Display title for the specialization, type: string")});z$1.object({_id:z$1.string().describe("Unique ID of the user, type: string"),firstName:z$1.string().min(2).max(30).describe("First name, 2-30 characters, type: string"),lastName:z$1.string().min(2).max(30).describe("Last name, 2-30 characters, type: string"),email:z$1.email().describe("Email address in valid format, type: string"),phoneNumber:z$1.string().min(10).describe("User's phone number, at least 10 digits, type: string"),profileImage:z$1.string().optional().describe("Optional URL to user's profile image, type: string, optional"),role:z$1.enum(["ADMIN","TRAINER","CLIENT"]).describe("User's role in the system (ADMIN, TRAINER, CLIENT)"),rate:z$1.number().min(1).optional().describe("User's rate (e.g., hourly, etc.), type: number, optional"),specializations:z$1.array(Za).optional().describe("Array of specialization objects, optional"),languages:z$1.array(z$1.string()).optional().describe("Array of languages the user speaks, type: string[], optional"),about:z$1.string().min(20).max(500).optional().describe("Brief bio or description (20-500 chars), type: string, optional"),gender:z$1.string().optional().describe("User's gender, type: string, optional"),timezone:z$1.string().optional().describe("User's timezone, type: string, optional"),averageRating:z$1.number().optional().describe("Average rating for this user, type: number, optional")});z$1.object({firstName:z$1.string().min(2).max(30).describe("First name, 2-30 characters, type: string"),lastName:z$1.string().min(2).max(30).describe("Last name, 2-30 characters, type: string"),email:z$1.email().describe("Valid email for the new user, type: string"),phoneNumber:z$1.string().min(10).describe("Phone number (at least 10 digits), type: string"),password:z$1.string().min(8).describe("Password with min length 8, type: string"),role:z$1.enum(["ADMIN","TRAINER","CLIENT"]).describe("Role of the new user (ADMIN, TRAINER, CLIENT)"),rate:z$1.number().min(1).optional().describe("Rate for the new user, type: number, optional"),specializationIds:z$1.array(z$1.string()).min(1).optional().describe("Array of specialization IDs, optional"),languages:z$1.array(z$1.string()).min(1).optional().describe("List of languages user speaks, optional"),about:z$1.string().min(20).max(500).optional().describe("User's about/bio field, 20-500 chars, optional")});z$1.object({_id:z$1.string().describe("ID of the user to be updated, type: string"),firstName:z$1.string().min(2).max(30).optional().describe("Updated first name, type: string, optional"),lastName:z$1.string().min(2).max(30).optional().describe("Updated last name, type: string, optional"),email:z$1.email().optional().describe("Updated email, type: string, optional"),phoneNumber:z$1.string().min(10).optional().describe("Updated phone number, at least 10 digits, optional"),rate:z$1.number().min(1).optional().describe("Updated rate, type: number, optional"),specializationIds:z$1.array(z$1.string()).min(1).optional().describe("Updated array of specialization IDs, optional"),languages:z$1.array(z$1.string()).min(1).optional().describe("Updated list of languages, optional"),about:z$1.string().min(20).max(500).optional().describe("Updated about/bio (20-500 chars), optional")});z$1.object({email:z$1.email().describe("Email to initiate the password reset process, type: string")});z$1.object({type:z$1.enum(["EMAIL","SMS"]).describe("How the reset code was sent (EMAIL or SMS)"),resetTicket:z$1.string().describe("Token/ticket to validate the reset request, type: string"),newPassword:z$1.string().min(8).describe("The new password, min length 8, type: string")});var He=`You are an expert GraphQL-to-frontend configuration converter. Transform the provided GraphQL schema into a structured JSON configuration for a React + Vite frontend application.
|
|
1173
1171
|
|
|
1174
1172
|
## Target Tech Stack
|
|
1175
1173
|
The generated configuration will be consumed by a Vite + React 19 + TypeScript template with:
|
|
@@ -1300,7 +1298,7 @@ EXPECTED JSON OUTPUT:
|
|
|
1300
1298
|
\`\`\`json
|
|
1301
1299
|
${ts}
|
|
1302
1300
|
\`\`\`
|
|
1303
|
-
`.trim()}var ke=I("validate_frontend_config",Qe,"Validates a frontend configuration JSON string against the ApplicationSchema. Returns valid: true or valid: false with errors array.","config");function
|
|
1301
|
+
`.trim()}var ke=I("validate_frontend_config",Qe,"Validates a frontend configuration JSON string against the ApplicationSchema. Returns valid: true or valid: false with errors array.","config");function Wi(e,t){let o=zr(),r=$r(),n=t?`
|
|
1304
1302
|
**Project context:**
|
|
1305
1303
|
- name: ${t.projectName??"project"}
|
|
1306
1304
|
- description: ${t.projectDescription??""}
|
|
@@ -1316,14 +1314,14 @@ ${n}
|
|
|
1316
1314
|
${e}
|
|
1317
1315
|
\`\`\`
|
|
1318
1316
|
|
|
1319
|
-
Generate the Frontend Config JSON. Use every available CRUD GraphQL query and mutation. Return ONLY valid JSON.`}function eo(e){return S({name:"generate_frontend",description:"Convert a GraphQL schema into a frontend configuration JSON (app, modules, pages, fields, API hooks). Optionally provide app info (project name, description, apiEndpoint). Returns the full application config as JSON.",input:z$1.object({graphqlSchema:z$1.string().describe("The GraphQL schema string to convert"),appInfo:z$1.object({projectName:z$1.string().optional(),projectDescription:z$1.string().optional(),modules:z$1.string().optional(),apiEndpoint:z$1.string().optional()}).optional().describe("Optional project/app context")}),handler:async({graphqlSchema:t,appInfo:o})=>{let r=
|
|
1317
|
+
Generate the Frontend Config JSON. Use every available CRUD GraphQL query and mutation. Return ONLY valid JSON.`}function eo(e){return S({name:"generate_frontend",description:"Convert a GraphQL schema into a frontend configuration JSON (app, modules, pages, fields, API hooks). Optionally provide app info (project name, description, apiEndpoint). Returns the full application config as JSON.",input:z$1.object({graphqlSchema:z$1.string().describe("The GraphQL schema string to convert"),appInfo:z$1.object({projectName:z$1.string().optional(),projectDescription:z$1.string().optional(),modules:z$1.string().optional(),apiEndpoint:z$1.string().optional()}).optional().describe("Optional project/app context")}),handler:async({graphqlSchema:t,appInfo:o})=>{let r=Wi(t,o),n=[{role:"system",content:He},{role:"user",content:r}],s=await e.invoke(n,{temperature:.2,maxOutputTokens:16384});return M(s.text,Qe)}})}function to(e){return S({name:"generate_feature_breakdown",description:"Analyze a GraphQL schema and produce a feature/component breakdown: list of modules, CRUD operations, and suggested pages. Returns a structured summary (not the full frontend JSON).",input:z$1.object({graphqlSchema:z$1.string().describe("The GraphQL schema string to analyze")}),handler:async({graphqlSchema:t})=>{let o=`${Zt}
|
|
1320
1318
|
|
|
1321
1319
|
**Schema to analyze:**
|
|
1322
1320
|
\`\`\`graphql
|
|
1323
1321
|
${t}
|
|
1324
1322
|
\`\`\`
|
|
1325
1323
|
|
|
1326
|
-
Respond with a structured breakdown only (no full JSON config): list modules, list Query/Mutation operations, and suggested pages for each module. Use clear headings and bullet points.`,r=[{role:"system",content:"You are a GraphQL schema analyst. Return a clear, structured text breakdown."},{role:"user",content:o}];return {summary:(await e.invoke(r,{temperature:.3,maxOutputTokens:4096})).text,modules:[],operations:[],suggestedPages:[]}}})}function
|
|
1324
|
+
Respond with a structured breakdown only (no full JSON config): list modules, list Query/Mutation operations, and suggested pages for each module. Use clear headings and bullet points.`,r=[{role:"system",content:"You are a GraphQL schema analyst. Return a clear, structured text breakdown."},{role:"user",content:o}];return {summary:(await e.invoke(r,{temperature:.3,maxOutputTokens:4096})).text,modules:[],operations:[],suggestedPages:[]}}})}function Xi(e){return {appName:e.app.name,description:e.app.description,apiEndpoint:e.app.apiEndpoint,branding:{brandName:e.app.branding.brandName,primaryColor:e.app.branding.primaryColor,secondaryColor:e.app.branding.secondaryColor,logo:e.app.branding.logo},modules:e.modules.map(t=>({name:t.name,pascalName:t.name.charAt(0).toUpperCase()+t.name.slice(1),camelName:t.name.charAt(0).toLowerCase()+t.name.slice(1)})),author:e.app.author,pages:e.modules.flatMap(t=>t.pages)}}S({name:"scaffold_vite",description:"Scaffold a Vite + React project from a validated ApplicationSchema config. Compiles Handlebars templates from .ref/templates/vite/ and writes the project to the output directory.",input:z$1.object({config:z$1.string().describe("JSON string of the validated ApplicationSchema config"),outputDir:z$1.string().describe("Absolute path to the output directory")}),handler:async({config:e,outputDir:t})=>{let o=_e(e,"application schema config"),r=le.resolve(process.cwd(),".ref/templates/vite"),n=Xi(o);return me({templateDir:r,outputDir:t,context:n})}});function Vr(e,t){let o={validate_frontend_config:ke,generate_frontend:eo(e),generate_feature_breakdown:to(e)};return o}var Ki=`You are an expert at analyzing GraphQL schemas. Your job is to:
|
|
1327
1325
|
|
|
1328
1326
|
1. **Types**: List all object types, enums, scalars, and input types.
|
|
1329
1327
|
2. **Queries**: List every Query field with arguments and return type.
|
|
@@ -1331,13 +1329,13 @@ Respond with a structured breakdown only (no full JSON config): list modules, li
|
|
|
1331
1329
|
4. **Relationships**: Identify types that reference other types (e.g. User has role: Role, or Order has customer: User).
|
|
1332
1330
|
5. **Auth/directives**: Note any @auth, @directive usage that affects access control.
|
|
1333
1331
|
|
|
1334
|
-
Respond with a clear, structured analysis (headings and bullet points). The user will use this to generate a frontend configuration.`,oo=f({name:"graphql-analyzer",description:"Analyzes a GraphQL schema to extract types, queries, mutations, and relationships. Use when you need to understand the schema before generating frontend config. Returns structured analysis (no JSON).",systemPrompt:
|
|
1332
|
+
Respond with a clear, structured analysis (headings and bullet points). The user will use this to generate a frontend configuration.`,oo=f({name:"graphql-analyzer",description:"Analyzes a GraphQL schema to extract types, queries, mutations, and relationships. Use when you need to understand the schema before generating frontend config. Returns structured analysis (no JSON).",systemPrompt:Ki,tools:{},maxIterations:2});var Zi=`You are a frontend configuration validator. Your job is to:
|
|
1335
1333
|
|
|
1336
1334
|
1. Validate the provided frontend config JSON using the validate_frontend_config tool.
|
|
1337
1335
|
2. Compare the config against the GraphQL schema (if provided) and check that all CRUD operations are covered.
|
|
1338
1336
|
3. Report any missing modules, pages, or API hooks.
|
|
1339
1337
|
|
|
1340
|
-
When the user gives you a config (as JSON string) and optionally the GraphQL schema, first call validate_frontend_config to check structure. Then summarize completeness.`;function ro(){return f({name:"config-validator",description:"Validates a frontend configuration JSON and checks completeness against the GraphQL schema. Use when you have a draft config and want to validate it. Has access to validate_frontend_config tool.",systemPrompt:
|
|
1338
|
+
When the user gives you a config (as JSON string) and optionally the GraphQL schema, first call validate_frontend_config to check structure. Then summarize completeness.`;function ro(){return f({name:"config-validator",description:"Validates a frontend configuration JSON and checks completeness against the GraphQL schema. Use when you have a draft config and want to validate it. Has access to validate_frontend_config tool.",systemPrompt:Zi,tools:{validate_frontend_config:ke},maxIterations:5})}var el=`${He}
|
|
1341
1339
|
|
|
1342
1340
|
You are the React frontend builder orchestrator. When the user provides a GraphQL schema and asks for a frontend configuration:
|
|
1343
1341
|
|
|
@@ -1347,7 +1345,7 @@ You are the React frontend builder orchestrator. When the user provides a GraphQ
|
|
|
1347
1345
|
4. **Validate directly**: You can use validate_frontend_config to check any config JSON.
|
|
1348
1346
|
5. **Feature breakdown**: Use generate_feature_breakdown to get a module/operation breakdown before generating.
|
|
1349
1347
|
|
|
1350
|
-
Respond with the final frontend config (as JSON) or a clear summary and the config. If the user gives feedback, use generate_frontend again with the same schema and consider their feedback in your instructions.`;async function Wr(e){let{input:t,model:o,maxIterations:r=15,onStep:n,logger:s}=e,
|
|
1348
|
+
Respond with the final frontend config (as JSON) or a clear summary and the config. If the user gives feedback, use generate_frontend again with the same schema and consider their feedback in your instructions.`;async function Wr(e){let{input:t,model:o,maxIterations:r=15,onStep:n,logger:s}=e,i=E(o??{provider:"openai",model:"gpt-4o-mini"}),l=Vr(i),p=ro(),c=q([oo,p],{parentModel:i}),d={...l,...c};return N({model:i,tools:d,systemPrompt:el,input:t,maxIterations:r,onStep:n,logger:s})}var ns=e=>z$1.string().transform(t=>t.toLowerCase().trim()).pipe(z$1.enum(e)),tl=z$1.string().transform(e=>e.toUpperCase().trim()).pipe(z$1.enum(["GET","POST","PUT","PATCH","DELETE"])),as=z$1.object({path:z$1.string(),name:z$1.string(),access:ns(["public","protected"]),routeGroup:z$1.string().default(""),purpose:z$1.string(),hasForm:z$1.coerce.boolean().default(false),formFields:z$1.array(z$1.string()).default([]),dataFetching:ns(["server","client","hybrid"]).default("server"),actions:z$1.array(z$1.string()).default([])}),ss=z$1.object({name:z$1.string(),path:z$1.string(),routeGroup:z$1.string().default(""),components:z$1.array(z$1.string()).default([]),purpose:z$1.string()}),is=z$1.object({path:z$1.string(),methods:z$1.array(tl).default([]),auth:z$1.coerce.boolean().default(true),description:z$1.string()}),ls=z$1.object({name:z$1.string(),module:z$1.string(),description:z$1.string(),revalidates:z$1.array(z$1.string()).default([])}),Ve=z$1.object({appName:z$1.string().default("app"),pages:z$1.array(as).default([]),layouts:z$1.array(ss).default([]),apiRoutes:z$1.array(is).default([]),serverActions:z$1.array(ls).default([]),middleware:z$1.array(z$1.string()).default([]),envVars:z$1.array(z$1.string()).default([]),packages:z$1.array(z$1.string()).default([])});var Xr=`You are an expert Next.js application architect using the App Router.
|
|
1351
1349
|
|
|
1352
1350
|
You generate production-ready Next.js configurations from frontend designs and API designs:
|
|
1353
1351
|
- App Router file structure with route groups, layouts, pages, loading, and error boundaries
|
|
@@ -1407,7 +1405,7 @@ Return ONLY valid JSON:
|
|
|
1407
1405
|
"middleware": ["Redirect unauthenticated users to /login"],
|
|
1408
1406
|
"envVars": ["DATABASE_URL", "NEXTAUTH_SECRET"],
|
|
1409
1407
|
"packages": ["next-auth", "prisma", "@prisma/client", "tailwindcss"]
|
|
1410
|
-
}`;function Kr(e){return cs.replace("{requirement}",e)}var no=I("validate_nextjs",Ve,"Validates a Next.js config JSON string against the NextjsConfig schema. Returns valid: true or valid: false with errors.","config");function ao(e){return S({name:"generate_nextjs",description:"Generate a complete Next.js App Router configuration from frontend design and requirements. Returns pages, layouts, API routes, server actions, and middleware as JSON.",input:z$1.object({requirement:z$1.string().describe("Frontend design, API design, and project requirements")}),handler:async({requirement:t})=>{let o=Kr(t),r=[{role:"system",content:"You are a Next.js architect. Return only valid JSON."},{role:"user",content:o}],n=await e.invoke(r,{temperature:.3,maxOutputTokens:16384});return M(n.text,Ve)}})}function Zr(e){return {validate_nextjs:no,generate_nextjs:ao(e)}}var
|
|
1408
|
+
}`;function Kr(e){return cs.replace("{requirement}",e)}var no=I("validate_nextjs",Ve,"Validates a Next.js config JSON string against the NextjsConfig schema. Returns valid: true or valid: false with errors.","config");function ao(e){return S({name:"generate_nextjs",description:"Generate a complete Next.js App Router configuration from frontend design and requirements. Returns pages, layouts, API routes, server actions, and middleware as JSON.",input:z$1.object({requirement:z$1.string().describe("Frontend design, API design, and project requirements")}),handler:async({requirement:t})=>{let o=Kr(t),r=[{role:"system",content:"You are a Next.js architect. Return only valid JSON."},{role:"user",content:o}],n=await e.invoke(r,{temperature:.3,maxOutputTokens:16384});return M(n.text,Ve)}})}function Zr(e){return {validate_nextjs:no,generate_nextjs:ao(e)}}var ol=`You are a Next.js App Router specialist. Given page specs, you plan the file structure.
|
|
1411
1409
|
|
|
1412
1410
|
## Route Groups
|
|
1413
1411
|
- (auth) for public auth pages: login, signup, forgot-password
|
|
@@ -1433,7 +1431,7 @@ Return ONLY valid JSON:
|
|
|
1433
1431
|
- Parallel routes: @modal, @sidebar
|
|
1434
1432
|
- Intercepting routes: (.)photo, (..)details
|
|
1435
1433
|
|
|
1436
|
-
Respond with the full file tree and route structure. Do NOT return JSON.`,so=f({name:"route-planner",description:"Plans Next.js App Router file structure with route groups, layouts, and page files. Use before generating the Next.js config.",systemPrompt:
|
|
1434
|
+
Respond with the full file tree and route structure. Do NOT return JSON.`,so=f({name:"route-planner",description:"Plans Next.js App Router file structure with route groups, layouts, and page files. Use before generating the Next.js config.",systemPrompt:ol,tools:{},maxIterations:2});var rl=`You are a Next.js API specialist. Given an API design, you plan route handlers and server actions.
|
|
1437
1435
|
|
|
1438
1436
|
## API Route Handlers (app/api/)
|
|
1439
1437
|
For external integrations, webhooks, and file uploads:
|
|
@@ -1458,7 +1456,7 @@ For form submissions and data writes:
|
|
|
1458
1456
|
- Server Actions: check session at the start of each action
|
|
1459
1457
|
- Middleware: protect route groups with matcher patterns
|
|
1460
1458
|
|
|
1461
|
-
Respond with structured analysis per module. Do NOT return JSON.`,io=f({name:"api-route-generator",description:"Generates Next.js API route handlers and server actions from API design. Use after route planning.",systemPrompt:
|
|
1459
|
+
Respond with structured analysis per module. Do NOT return JSON.`,io=f({name:"api-route-generator",description:"Generates Next.js API route handlers and server actions from API design. Use after route planning.",systemPrompt:rl,tools:{},maxIterations:2});var nl=`${Xr}
|
|
1462
1460
|
|
|
1463
1461
|
You are the Next.js builder orchestrator. When the user provides requirements:
|
|
1464
1462
|
|
|
@@ -1467,7 +1465,7 @@ You are the Next.js builder orchestrator. When the user provides requirements:
|
|
|
1467
1465
|
3. **Generate config**: Use generate_nextjs to produce the complete Next.js configuration as JSON.
|
|
1468
1466
|
4. **Validate**: Use validate_nextjs to check the config JSON before returning.
|
|
1469
1467
|
|
|
1470
|
-
Respond with the final Next.js config as JSON.`;async function en(e){let{input:t,model:o,maxIterations:r=15,onStep:n,logger:s}=e,a=E(o??{provider:"openai",model:"gpt-4o-mini"}),i=Zr(a),l=q([so,io],{parentModel:a}),p={...i,...l};return N({model:a,tools:p,systemPrompt:
|
|
1468
|
+
Respond with the final Next.js config as JSON.`;async function en(e){let{input:t,model:o,maxIterations:r=15,onStep:n,logger:s}=e,a=E(o??{provider:"openai",model:"gpt-4o-mini"}),i=Zr(a),l=q([so,io],{parentModel:a}),p={...i,...l};return N({model:a,tools:p,systemPrompt:nl,input:t,maxIterations:r,onStep:n,logger:s})}var ds=z$1.object({order:z$1.number(),action:z$1.string(),details:z$1.string()}),us=z$1.object({name:z$1.string(),description:z$1.string(),steps:z$1.array(ds)}),ms=z$1.object({area:z$1.string(),scenario:z$1.string(),handling:z$1.string(),severity:z$1.string().transform(e=>e.toLowerCase().trim()).pipe(z$1.enum(["critical","warning","info"]))}),gs=z$1.object({flow:z$1.string(),item:z$1.string(),expectedResult:z$1.string()}),We=z$1.object({phases:z$1.array(us).default([]),currentState:z$1.string().default(""),desiredEndState:z$1.string().default(""),edgeCases:z$1.array(ms).default([]),securityNotes:z$1.array(z$1.string()).default([]),performanceNotes:z$1.array(z$1.string()).default([]),testingChecklist:z$1.array(gs).default([])});var tn=`You are a senior tech lead specializing in implementation strategy and project execution planning.
|
|
1471
1469
|
|
|
1472
1470
|
You create enterprise-quality execution plans with:
|
|
1473
1471
|
- Phased implementation order with concrete, numbered steps per phase
|
|
@@ -1499,7 +1497,7 @@ Return ONLY valid JSON:
|
|
|
1499
1497
|
"securityNotes": ["..."],
|
|
1500
1498
|
"performanceNotes": ["..."],
|
|
1501
1499
|
"testingChecklist": [{ "flow": "Auth Flow", "item": "Sign up with valid credentials", "expectedResult": "Account created, redirected to dashboard" }]
|
|
1502
|
-
}`;function on(e){return fs.replace("{context}",e)}var lo=I("validate_execution_plan",We,"Validates an execution plan JSON string against the ExecutionPlan schema. Returns valid: true or valid: false with errors.","plan");function co(e){return S({name:"create_execution_plan",description:"Generate a comprehensive execution plan with phases, edge cases, and testing checklist from the full plan context.",input:z$1.object({context:z$1.string().describe("Full plan context: all sections generated so far")}),handler:async({context:t})=>{let o=on(t),r=[{role:"system",content:"You are a tech lead. Return only valid JSON."},{role:"user",content:o}],n=await e.invoke(r,{temperature:.3,maxOutputTokens:16384});return M(n.text,We)}})}function rn(e){return {validate_execution_plan:lo,create_execution_plan:co(e)}}var
|
|
1500
|
+
}`;function on(e){return fs.replace("{context}",e)}var lo=I("validate_execution_plan",We,"Validates an execution plan JSON string against the ExecutionPlan schema. Returns valid: true or valid: false with errors.","plan");function co(e){return S({name:"create_execution_plan",description:"Generate a comprehensive execution plan with phases, edge cases, and testing checklist from the full plan context.",input:z$1.object({context:z$1.string().describe("Full plan context: all sections generated so far")}),handler:async({context:t})=>{let o=on(t),r=[{role:"system",content:"You are a tech lead. Return only valid JSON."},{role:"user",content:o}],n=await e.invoke(r,{temperature:.3,maxOutputTokens:16384});return M(n.text,We)}})}function rn(e){return {validate_execution_plan:lo,create_execution_plan:co(e)}}var al=`${tn}
|
|
1503
1501
|
|
|
1504
1502
|
You are the execution planning orchestrator. When the user provides plan sections:
|
|
1505
1503
|
|
|
@@ -1508,7 +1506,7 @@ You are the execution planning orchestrator. When the user provides plan section
|
|
|
1508
1506
|
3. **Generate plan**: Use create_execution_plan to produce the complete execution plan with phases, edge cases, and testing checklist.
|
|
1509
1507
|
4. **Validate**: Use validate_execution_plan to check the final plan JSON before returning.
|
|
1510
1508
|
|
|
1511
|
-
Respond with the final execution plan as JSON.`;async function nn(e){let{input:t,model:o,maxIterations:r=15,onStep:n,logger:s}=e,a=E(o??{provider:"openai",model:"gpt-4o-mini"}),i=rn(a),l=q([we,ve],{parentModel:a}),p={...i,...l};return N({model:a,tools:p,systemPrompt:
|
|
1512
|
-
`);},xs=200;function
|
|
1509
|
+
Respond with the final execution plan as JSON.`;async function nn(e){let{input:t,model:o,maxIterations:r=15,onStep:n,logger:s}=e,a=E(o??{provider:"openai",model:"gpt-4o-mini"}),i=rn(a),l=q([we,ve],{parentModel:a}),p={...i,...l};return N({model:a,tools:p,systemPrompt:al,input:t,maxIterations:r,onStep:n,logger:s})}var an=S({name:"hello_world",description:"Returns a greeting message for the given name",input:z$1.object({name:z$1.string().describe("Name to greet")}),handler:async({name:e})=>({greeting:`Hello, ${e}! Welcome to sweagent.`})});var sl="You are a friendly greeter. Use the hello_world tool to greet users.";async function sn(e){let{input:t,model:o,systemPrompt:r=sl,maxIterations:n=3,onStep:s,logger:a}=e,i=E(o??{provider:"openai",model:"gpt-4o-mini"});return N({model:i,tools:{hello_world:an},systemPrompt:r,input:t,maxIterations:n,onStep:s,logger:a})}function z(e,t,o){return {name:e,description:t,handler:(r,n,s)=>o({input:r,model:n,onStep:s})}}var po=[z("plan","Generate a full software plan (discovery, requirements, design, synthesis) from a project description.",_o),z("gather_requirements","Extract structured requirements (actors, flows, stories, modules) from a project description.",Vo),z("design_data_model","Design a database schema (MongoDB or PostgreSQL) with entities, relations, and indexes.",ir),z("design_api","Design REST or GraphQL API contracts (endpoints, request/response schemas) from requirements.",gr),z("design_auth","Design authentication and authorization strategy (providers, roles, permissions, flows).",Sr),z("architect_backend","Design backend architecture (folder structure, services, middleware, deployment) from requirements.",Pr),z("architect_frontend","Design frontend architecture (components, state management, routing, styling) from requirements.",Ar),z("build_express","Generate Express.js REST API configuration and boilerplate from an API design.",e=>Dr({...e})),z("build_apollo","Generate Apollo GraphQL subgraph configuration and resolvers from an API design.",e=>Fr({...e})),z("build_react","Generate React + Vite application configuration and components from a GraphQL schema.",e=>Wr({...e})),z("build_nextjs","Generate Next.js App Router configuration and pages from requirements.",en),z("plan_execution","Create a phased execution plan with edge-case analysis and testing strategy.",nn),z("hello_world","Test agent that greets users. Use to verify the MCP server is working.",sn)];var Ss={input:z$1.string().describe("Natural language description of what to build or design"),provider:z$1.enum(["openai","anthropic","google"]).optional().describe("LLM provider (defaults to openai)"),model:z$1.string().optional().describe("Model name, e.g. gpt-4o-mini, claude-3-5-sonnet-20241022"),temperature:z$1.number().min(0).max(1).optional().describe("Sampling temperature (0-1)")};function bs(e){if(!(!e.provider&&!e.model))return {provider:e.provider??"openai",model:e.model??"gpt-4o-mini",temperature:e.temperature}}var ll="sweagent",cl="0.0.3",Xe=e=>{process.stderr.write(`[sweagent] ${e}
|
|
1510
|
+
`);},xs=200;function pl(e){return t=>{let o=`${e} \u2014 step ${t.iteration+1}`;if(t.content){let r=t.content.length>xs?t.content.slice(0,xs)+"\u2026":t.content;Xe(`${o}: ${r}`);}else {let r=t.toolCalls?.map(n=>n.toolName).join(", ");Xe(`${o}${r?` (tools: ${r})`:""}`);}}}function Ts(){let e=new McpServer({name:ll,version:cl},{capabilities:{tools:{}}});for(let t of po)e.registerTool(t.name,{description:t.description,inputSchema:Ss},async o=>{Xe(`${t.name} \u2014 started`);try{let r=bs(o),n=pl(t.name),s=await t.handler(o.input,r,n);return Xe(`${t.name} \u2014 completed`),{content:[{type:"text",text:s.output}]}}catch(r){let n=r instanceof Error?r.message:String(r);return Xe(`${t.name} \u2014 error: ${n}`),{content:[{type:"text",text:n}],isError:true}}});return e}var Ps=e=>{process.stderr.write(`[sweagent] ${e}
|
|
1513
1511
|
`);};try{let e=Ts(),t=new StdioServerTransport;await e.connect(t),Ps(`MCP server running (stdio) \u2014 ${po.length} tools registered`);}catch(e){Ps(`Failed to start: ${e}`),process.exit(1);}//# sourceMappingURL=stdio.js.map
|
|
1514
1512
|
//# sourceMappingURL=stdio.js.map
|