@@ -23,6 +23,7 @@ import { PermissionID } from "@/permission/schema"
2323import { ModelID , ProviderID } from "@/provider/schema"
2424import { errors } from "../../error"
2525import { lazy } from "@/util/lazy"
26+ import { zodObject } from "@/util/effect-zod"
2627import { Bus } from "@/bus"
2728import { NamedError } from "@opencode-ai/shared/util/error"
2829import { jsonRequest , runRequest } from "./trace"
@@ -42,7 +43,7 @@ export const SessionRoutes = lazy(() =>
4243 description : "List of sessions" ,
4344 content : {
4445 "application/json" : {
45- schema : resolver ( Session . Info . array ( ) ) ,
46+ schema : resolver ( Session . Info . zod . array ( ) ) ,
4647 } ,
4748 } ,
4849 } ,
@@ -87,7 +88,7 @@ export const SessionRoutes = lazy(() =>
8788 description : "Get session status" ,
8889 content : {
8990 "application/json" : {
90- schema : resolver ( z . record ( z . string ( ) , SessionStatus . Info ) ) ,
91+ schema : resolver ( z . record ( z . string ( ) , SessionStatus . Info . zod ) ) ,
9192 } ,
9293 } ,
9394 } ,
@@ -112,7 +113,7 @@ export const SessionRoutes = lazy(() =>
112113 description : "Get session" ,
113114 content : {
114115 "application/json" : {
115- schema : resolver ( Session . Info ) ,
116+ schema : resolver ( Session . Info . zod ) ,
116117 } ,
117118 } ,
118119 } ,
@@ -122,7 +123,7 @@ export const SessionRoutes = lazy(() =>
122123 validator (
123124 "param" ,
124125 z . object ( {
125- sessionID : Session . GetInput ,
126+ sessionID : Session . GetInput . zod ,
126127 } ) ,
127128 ) ,
128129 async ( c ) => {
@@ -145,7 +146,7 @@ export const SessionRoutes = lazy(() =>
145146 description : "List of children" ,
146147 content : {
147148 "application/json" : {
148- schema : resolver ( Session . Info . array ( ) ) ,
149+ schema : resolver ( Session . Info . zod . array ( ) ) ,
149150 } ,
150151 } ,
151152 } ,
@@ -155,7 +156,7 @@ export const SessionRoutes = lazy(() =>
155156 validator (
156157 "param" ,
157158 z . object ( {
158- sessionID : Session . ChildrenInput ,
159+ sessionID : Session . ChildrenInput . zod ,
159160 } ) ,
160161 ) ,
161162 async ( c ) => {
@@ -177,7 +178,7 @@ export const SessionRoutes = lazy(() =>
177178 description : "Todo list" ,
178179 content : {
179180 "application/json" : {
180- schema : resolver ( Todo . Info . array ( ) ) ,
181+ schema : resolver ( Todo . Info . zod . array ( ) ) ,
181182 } ,
182183 } ,
183184 } ,
@@ -210,13 +211,13 @@ export const SessionRoutes = lazy(() =>
210211 description : "Successfully created session" ,
211212 content : {
212213 "application/json" : {
213- schema : resolver ( Session . Info ) ,
214+ schema : resolver ( Session . Info . zod ) ,
214215 } ,
215216 } ,
216217 } ,
217218 } ,
218219 } ) ,
219- validator ( "json" , Session . CreateInput ) ,
220+ validator ( "json" , Session . CreateInput . zod ) ,
220221 async ( c ) =>
221222 jsonRequest ( "SessionRoutes.create" , c , function * ( ) {
222223 const body = c . req . valid ( "json" ) ?? { }
@@ -245,7 +246,7 @@ export const SessionRoutes = lazy(() =>
245246 validator (
246247 "param" ,
247248 z . object ( {
248- sessionID : Session . RemoveInput ,
249+ sessionID : Session . RemoveInput . zod ,
249250 } ) ,
250251 ) ,
251252 async ( c ) =>
@@ -267,7 +268,7 @@ export const SessionRoutes = lazy(() =>
267268 description : "Successfully updated session" ,
268269 content : {
269270 "application/json" : {
270- schema : resolver ( Session . Info ) ,
271+ schema : resolver ( Session . Info . zod ) ,
271272 } ,
272273 } ,
273274 } ,
@@ -375,7 +376,7 @@ export const SessionRoutes = lazy(() =>
375376 description : "200" ,
376377 content : {
377378 "application/json" : {
378- schema : resolver ( Session . Info ) ,
379+ schema : resolver ( Session . Info . zod ) ,
379380 } ,
380381 } ,
381382 } ,
@@ -384,14 +385,14 @@ export const SessionRoutes = lazy(() =>
384385 validator (
385386 "param" ,
386387 z . object ( {
387- sessionID : Session . ForkInput . shape . sessionID ,
388+ sessionID : SessionID . zod ,
388389 } ) ,
389390 ) ,
390- validator ( "json" , Session . ForkInput . omit ( { sessionID : true } ) ) ,
391+ validator ( "json" , zodObject ( Session . ForkInput ) . omit ( { sessionID : true } ) ) ,
391392 async ( c ) =>
392393 jsonRequest ( "SessionRoutes.fork" , c , function * ( ) {
393394 const sessionID = c . req . valid ( "param" ) . sessionID
394- const body = c . req . valid ( "json" )
395+ const body = c . req . valid ( "json" ) as { messageID ?: MessageID }
395396 const svc = yield * Session . Service
396397 return yield * svc . fork ( { ...body , sessionID } )
397398 } ) ,
@@ -438,7 +439,7 @@ export const SessionRoutes = lazy(() =>
438439 description : "Successfully shared session" ,
439440 content : {
440441 "application/json" : {
441- schema : resolver ( Session . Info ) ,
442+ schema : resolver ( Session . Info . zod ) ,
442443 } ,
443444 } ,
444445 } ,
@@ -480,18 +481,13 @@ export const SessionRoutes = lazy(() =>
480481 validator (
481482 "param" ,
482483 z . object ( {
483- sessionID : SessionSummary . DiffInput . shape . sessionID ,
484- } ) ,
485- ) ,
486- validator (
487- "query" ,
488- z . object ( {
489- messageID : SessionSummary . DiffInput . shape . messageID ,
484+ sessionID : SessionID . zod ,
490485 } ) ,
491486 ) ,
487+ validator ( "query" , zodObject ( SessionSummary . DiffInput ) . omit ( { sessionID : true } ) ) ,
492488 async ( c ) =>
493489 jsonRequest ( "SessionRoutes.diff" , c , function * ( ) {
494- const query = c . req . valid ( "query" )
490+ const query = c . req . valid ( "query" ) as Omit < SessionSummary . DiffInput , "sessionID" >
495491 const params = c . req . valid ( "param" )
496492 const summary = yield * SessionSummary . Service
497493 return yield * summary . diff ( {
@@ -511,7 +507,7 @@ export const SessionRoutes = lazy(() =>
511507 description : "Successfully unshared session" ,
512508 content : {
513509 "application/json" : {
514- schema : resolver ( Session . Info ) ,
510+ schema : resolver ( Session . Info . zod ) ,
515511 } ,
516512 } ,
517513 } ,
@@ -872,7 +868,7 @@ export const SessionRoutes = lazy(() =>
872868 sessionID : SessionID . zod ,
873869 } ) ,
874870 ) ,
875- validator ( "json" , SessionPrompt . PromptInput . omit ( { sessionID : true } ) ) ,
871+ validator ( "json" , zodObject ( SessionPrompt . PromptInput ) . omit ( { sessionID : true } ) ) ,
876872 async ( c ) => {
877873 c . status ( 200 )
878874 c . header ( "Content-Type" , "application/json" )
@@ -910,7 +906,7 @@ export const SessionRoutes = lazy(() =>
910906 sessionID : SessionID . zod ,
911907 } ) ,
912908 ) ,
913- validator ( "json" , SessionPrompt . PromptInput . omit ( { sessionID : true } ) ) ,
909+ validator ( "json" , zodObject ( SessionPrompt . PromptInput ) . omit ( { sessionID : true } ) ) ,
914910 async ( c ) => {
915911 const sessionID = c . req . valid ( "param" ) . sessionID
916912 const body = c . req . valid ( "json" )
@@ -960,11 +956,11 @@ export const SessionRoutes = lazy(() =>
960956 sessionID : SessionID . zod ,
961957 } ) ,
962958 ) ,
963- validator ( "json" , SessionPrompt . CommandInput . omit ( { sessionID : true } ) ) ,
959+ validator ( "json" , zodObject ( SessionPrompt . CommandInput ) . omit ( { sessionID : true } ) ) ,
964960 async ( c ) =>
965961 jsonRequest ( "SessionRoutes.command" , c , function * ( ) {
966962 const sessionID = c . req . valid ( "param" ) . sessionID
967- const body = c . req . valid ( "json" )
963+ const body = c . req . valid ( "json" ) as Omit < SessionPrompt . CommandInput , "sessionID" >
968964 const svc = yield * SessionPrompt . Service
969965 return yield * svc . command ( { ...body , sessionID } )
970966 } ) ,
@@ -993,11 +989,11 @@ export const SessionRoutes = lazy(() =>
993989 sessionID : SessionID . zod ,
994990 } ) ,
995991 ) ,
996- validator ( "json" , SessionPrompt . ShellInput . omit ( { sessionID : true } ) ) ,
992+ validator ( "json" , zodObject ( SessionPrompt . ShellInput ) . omit ( { sessionID : true } ) ) ,
997993 async ( c ) =>
998994 jsonRequest ( "SessionRoutes.shell" , c , function * ( ) {
999995 const sessionID = c . req . valid ( "param" ) . sessionID
1000- const body = c . req . valid ( "json" )
996+ const body = c . req . valid ( "json" ) as Omit < SessionPrompt . ShellInput , "sessionID" >
1001997 const svc = yield * SessionPrompt . Service
1002998 return yield * svc . shell ( { ...body , sessionID } )
1003999 } ) ,
@@ -1013,7 +1009,7 @@ export const SessionRoutes = lazy(() =>
10131009 description : "Updated session" ,
10141010 content : {
10151011 "application/json" : {
1016- schema : resolver ( Session . Info ) ,
1012+ schema : resolver ( Session . Info . zod ) ,
10171013 } ,
10181014 } ,
10191015 } ,
@@ -1026,16 +1022,14 @@ export const SessionRoutes = lazy(() =>
10261022 sessionID : SessionID . zod ,
10271023 } ) ,
10281024 ) ,
1029- validator ( "json" , SessionRevert . RevertInput . omit ( { sessionID : true } ) ) ,
1025+ validator ( "json" , zodObject ( SessionRevert . RevertInput ) . omit ( { sessionID : true } ) ) ,
10301026 async ( c ) => {
10311027 const sessionID = c . req . valid ( "param" ) . sessionID
1032- log . info ( "revert" , c . req . valid ( "json" ) )
1028+ const body = c . req . valid ( "json" ) as Omit < SessionRevert . RevertInput , "sessionID" >
1029+ log . info ( "revert" , body )
10331030 return jsonRequest ( "SessionRoutes.revert" , c , function * ( ) {
10341031 const svc = yield * SessionRevert . Service
1035- return yield * svc . revert ( {
1036- sessionID,
1037- ...c . req . valid ( "json" ) ,
1038- } )
1032+ return yield * svc . revert ( { sessionID, ...body } )
10391033 } )
10401034 } ,
10411035 )
@@ -1050,7 +1044,7 @@ export const SessionRoutes = lazy(() =>
10501044 description : "Updated session" ,
10511045 content : {
10521046 "application/json" : {
1053- schema : resolver ( Session . Info ) ,
1047+ schema : resolver ( Session . Info . zod ) ,
10541048 } ,
10551049 } ,
10561050 } ,
0 commit comments