File tree Expand file tree Collapse file tree 3 files changed +38
-2
lines changed
Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @perstack/core " : patch
3+ " @perstack/runtime " : patch
4+ ---
5+
6+ Add runSettingSchema for validating stored run settings
Original file line number Diff line number Diff line change @@ -134,6 +134,34 @@ export type RunParamsInput = {
134134 checkpoint ?: Checkpoint
135135}
136136
137+ export const runSettingSchema = z . object ( {
138+ model : z . string ( ) ,
139+ providerConfig : providerConfigSchema ,
140+ runId : z . string ( ) ,
141+ expertKey : z . string ( ) . min ( 1 ) . regex ( expertKeyRegex ) ,
142+ input : z . object ( {
143+ text : z . string ( ) . optional ( ) ,
144+ interactiveToolCallResult : z
145+ . object ( {
146+ toolCallId : z . string ( ) ,
147+ toolName : z . string ( ) ,
148+ text : z . string ( ) ,
149+ } )
150+ . optional ( ) ,
151+ } ) ,
152+ experts : z . record ( z . string ( ) , expertSchema ) ,
153+ temperature : z . number ( ) . min ( 0 ) . max ( 1 ) ,
154+ maxSteps : z . number ( ) . min ( 1 ) . optional ( ) ,
155+ maxRetries : z . number ( ) . min ( 0 ) ,
156+ timeout : z . number ( ) . min ( 0 ) ,
157+ startedAt : z . number ( ) ,
158+ updatedAt : z . number ( ) ,
159+ perstackApiBaseUrl : z . string ( ) . url ( ) ,
160+ perstackApiKey : z . string ( ) . optional ( ) ,
161+ perstackBaseSkillCommand : z . array ( z . string ( ) ) . optional ( ) ,
162+ env : z . record ( z . string ( ) , z . string ( ) ) ,
163+ } )
164+
137165export const runParamsSchema = z . object ( {
138166 setting : z . object ( {
139167 model : z . string ( ) ,
Original file line number Diff line number Diff line change 11import path from "node:path"
2- import type { RunSetting } from "@perstack/core"
2+ import { type RunSetting , runSettingSchema } from "@perstack/core"
33
44export type FileSystem = {
55 existsSync : ( path : string ) => boolean
@@ -36,7 +36,9 @@ export async function storeRunSetting(
3636 const runDir = getRunDir ( setting . runId )
3737 if ( fileSystem . existsSync ( runDir ) ) {
3838 const runSettingPath = path . resolve ( runDir , "run-setting.json" )
39- const runSetting = JSON . parse ( await fileSystem . readFile ( runSettingPath , "utf-8" ) ) as RunSetting
39+ const runSetting = runSettingSchema . parse (
40+ JSON . parse ( await fileSystem . readFile ( runSettingPath , "utf-8" ) ) ,
41+ )
4042 runSetting . updatedAt = Date . now ( )
4143 await fileSystem . writeFile ( runSettingPath , JSON . stringify ( runSetting ) , "utf-8" )
4244 } else {
You can’t perform that action at this time.
0 commit comments