@@ -6,6 +6,7 @@ import { createServer } from "./server.js";
66import { loadFixtureFile , loadFixturesFromDir , validateFixtures } from "./fixture-loader.js" ;
77import { Logger , type LogLevel } from "./logger.js" ;
88import { watchFixtures } from "./watcher.js" ;
9+ import { AGUIMock } from "./agui-mock.js" ;
910import type { ChaosConfig , RecordConfig } from "./types.js" ;
1011
1112const HELP = `
@@ -32,6 +33,9 @@ Options:
3233 --provider-azure <url> Upstream URL for Azure OpenAI
3334 --provider-ollama <url> Upstream URL for Ollama
3435 --provider-cohere <url> Upstream URL for Cohere
36+ --agui-record Enable AG-UI recording (proxy unmatched AG-UI requests)
37+ --agui-upstream <url> Upstream AG-UI agent URL (used with --agui-record)
38+ --agui-proxy-only AG-UI proxy mode: forward without saving
3539 --chaos-drop <rate> Probability (0-1) of dropping requests with 500
3640 --chaos-malformed <rate> Probability (0-1) of returning malformed JSON
3741 --chaos-disconnect <rate> Probability (0-1) of destroying connection
@@ -60,6 +64,9 @@ const { values } = parseArgs({
6064 "provider-azure" : { type : "string" } ,
6165 "provider-ollama" : { type : "string" } ,
6266 "provider-cohere" : { type : "string" } ,
67+ "agui-record" : { type : "boolean" , default : false } ,
68+ "agui-upstream" : { type : "string" } ,
69+ "agui-proxy-only" : { type : "boolean" , default : false } ,
6370 "chaos-drop" : { type : "string" } ,
6471 "chaos-malformed" : { type : "string" } ,
6572 "chaos-disconnect" : { type : "string" } ,
@@ -168,6 +175,22 @@ if (values.record || values["proxy-only"]) {
168175 } ;
169176}
170177
178+ // Parse AG-UI record/proxy config from CLI flags
179+ let aguiMount : { path: string ; handler: AGUIMock } | undefined ;
180+ if ( values [ "agui-record" ] || values [ "agui-proxy-only" ] ) {
181+ if ( ! values [ "agui-upstream" ] ) {
182+ console . error ( "Error: --agui-record/--agui-proxy-only requires --agui-upstream" ) ;
183+ process . exit ( 1 ) ;
184+ }
185+ const agui = new AGUIMock ( ) ;
186+ agui . enableRecording ( {
187+ upstream : values [ "agui-upstream" ] ,
188+ fixturePath : resolve ( fixturePath , "agui-recorded" ) ,
189+ proxyOnly : values [ "agui-proxy-only" ] ,
190+ } ) ;
191+ aguiMount = { path : "/agui" , handler : agui } ;
192+ }
193+
171194async function main ( ) {
172195 // Load fixtures from path (detect file vs directory)
173196 let isDir : boolean ;
@@ -219,17 +242,23 @@ async function main() {
219242 }
220243 }
221244
222- const instance = await createServer ( fixtures , {
223- port,
224- host,
225- latency,
226- chunkSize,
227- logLevel,
228- chaos,
229- metrics : values . metrics ,
230- record,
231- strict : values . strict ,
232- } ) ;
245+ const mounts = aguiMount ? [ aguiMount ] : undefined ;
246+
247+ const instance = await createServer (
248+ fixtures ,
249+ {
250+ port,
251+ host,
252+ latency,
253+ chunkSize,
254+ logLevel,
255+ chaos,
256+ metrics : values . metrics ,
257+ record,
258+ strict : values . strict ,
259+ } ,
260+ mounts ,
261+ ) ;
233262
234263 logger . info ( `aimock server listening on ${ instance . url } ` ) ;
235264
0 commit comments