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

Function js_worker_agent_spec_to_rust

sdk/node/src/lib.rs:2714–2745  ·  view source on GitHub ↗
(spec: WorkerAgentSpec)

Source from the content-addressed store, hash-verified

2712}
2713
2714fn js_worker_agent_spec_to_rust(spec: WorkerAgentSpec) -> napi::Result<RustWorkerAgentSpec> {
2715 if spec.name.trim().is_empty() {
2716 return Err(napi::Error::from_reason("worker agent name is required"));
2717 }
2718 if spec.description.trim().is_empty() {
2719 return Err(napi::Error::from_reason(
2720 "worker agent description is required",
2721 ));
2722 }
2723
2724 let kind = parse_worker_agent_kind(spec.kind.as_deref())?;
2725 let mut worker = RustWorkerAgentSpec::new(kind, spec.name, spec.description);
2726 if spec.hidden.unwrap_or(false) {
2727 worker = worker.hidden(true);
2728 }
2729 if let Some(policy) = spec.permissions {
2730 worker = worker.with_permissions(js_permission_policy_to_rust(policy)?);
2731 }
2732 if let Some(model) = spec.model {
2733 worker = worker.with_model(RustAgentModelConfig::from_model_ref(model));
2734 }
2735 if let Some(prompt) = spec.prompt {
2736 worker = worker.with_prompt(prompt);
2737 }
2738 if let Some(max_steps) = spec.max_steps {
2739 worker = worker.with_max_steps(max_steps as usize);
2740 }
2741 if let Some(ci) = spec.confirmation_inheritance {
2742 worker = worker.with_confirmation(parse_confirmation_inheritance(&ci)?);
2743 }
2744 Ok(worker)
2745}
2746
2747fn parse_worker_agent_kind(kind: Option<&str>) -> napi::Result<RustWorkerAgentKind> {
2748 kind.unwrap_or("custom")

Callers 3

session_for_workerMethod · 0.85
register_worker_agentMethod · 0.85

Calls 10

parse_worker_agent_kindFunction · 0.85
hiddenMethod · 0.80
with_permissionsMethod · 0.80
with_promptMethod · 0.80
with_confirmationMethod · 0.80
is_emptyMethod · 0.45
with_modelMethod · 0.45
with_max_stepsMethod · 0.45

Tested by

no test coverage detected