| 916 | } |
| 917 | |
| 918 | fn normalize_program_script_options(options: serde_json::Value) -> napi::Result<serde_json::Value> { |
| 919 | let obj = options |
| 920 | .as_object() |
| 921 | .ok_or_else(|| napi::Error::from_reason("program options must be an object"))?; |
| 922 | |
| 923 | let mut args = serde_json::Map::new(); |
| 924 | args.insert("type".to_string(), serde_json::json!("script")); |
| 925 | args.insert("language".to_string(), serde_json::json!("javascript")); |
| 926 | |
| 927 | for key in ["source", "path", "inputs", "limits"] { |
| 928 | if let Some(value) = obj.get(key) { |
| 929 | args.insert(key.to_string(), value.clone()); |
| 930 | } |
| 931 | } |
| 932 | |
| 933 | if let Some(value) = obj.get("allowedTools").or_else(|| obj.get("allowed_tools")) { |
| 934 | args.insert("allowed_tools".to_string(), value.clone()); |
| 935 | } |
| 936 | |
| 937 | Ok(serde_json::Value::Object(args)) |
| 938 | } |
| 939 | |
| 940 | fn delegate_task_options_to_args(options: DelegateTaskOptions) -> serde_json::Value { |
| 941 | let mut args = serde_json::json!({ |