MCPcopy Index your code
hub / github.com/AI45Lab/Code / js_session_options_to_rust

Function js_session_options_to_rust

sdk/node/src/lib.rs:2295–2593  ·  view source on GitHub ↗

Build RustSessionOptions from JS SessionOptions.

(options: Option<SessionOptions>)

Source from the content-addressed store, hash-verified

2293
2294/// Build RustSessionOptions from JS SessionOptions.
2295fn js_session_options_to_rust(options: Option<SessionOptions>) -> napi::Result<RustSessionOptions> {
2296 let Some(o) = options else {
2297 return Ok(RustSessionOptions::new());
2298 };
2299 let mut opts = RustSessionOptions::new();
2300 if let Some(model) = o.model {
2301 opts = opts.with_model(model);
2302 }
2303 if o.builtin_skills.unwrap_or(false) {
2304 opts = opts.with_builtin_skills();
2305 }
2306 if let Some(dirs) = o.skill_dirs {
2307 for d in dirs {
2308 opts = opts.with_skills_from_dir(d);
2309 }
2310 }
2311 if let Some(enabled) = o.enforce_active_skill_tool_restrictions {
2312 opts = opts.with_active_skill_tool_restrictions(enabled);
2313 }
2314 if let Some(dirs) = o.agent_dirs {
2315 for d in dirs {
2316 opts = opts.with_agent_dir(d);
2317 }
2318 }
2319 if let Some(workers) = o.worker_agents {
2320 for worker in workers {
2321 opts = opts.with_worker_agent(js_worker_agent_spec_to_rust(worker)?);
2322 }
2323 }
2324 if let Some(qc) = o.queue_config {
2325 opts = opts.with_queue_config(js_queue_config_to_rust(&qc)?);
2326 }
2327 if let Some(policy) = o.permission_policy {
2328 opts = opts.with_permission_policy(js_permission_policy_to_rust(policy)?);
2329 }
2330 opts = apply_planning_mode(opts, o.planning_mode.as_deref(), o.planning)?;
2331 if o.goal_tracking.unwrap_or(false) {
2332 opts = opts.with_goal_tracking(true);
2333 }
2334 if let Some(n) = o.max_parse_retries {
2335 opts = opts.with_parse_retries(n);
2336 }
2337 if let Some(ms) = o.tool_timeout_ms {
2338 opts = opts.with_tool_timeout(ms as u64);
2339 }
2340 if let Some(n) = o.circuit_breaker_threshold {
2341 opts = opts.with_circuit_breaker(n);
2342 }
2343 if o.auto_compact.unwrap_or(false) {
2344 opts = opts.with_auto_compact(true);
2345 }
2346 if let Some(t) = o.auto_compact_threshold {
2347 opts = opts.with_auto_compact_threshold(t as f32);
2348 }
2349 if let Some(limits) = o.artifact_store_limits {
2350 opts = opts.with_artifact_store_limits(js_artifact_store_limits_to_rust(limits)?);
2351 }
2352 if let Some(ref store) = o.memory_store {