diff options
Diffstat (limited to 'crates/phone-opus/src')
| -rw-r--r-- | crates/phone-opus/src/mcp/catalog.rs | 64 | ||||
| -rw-r--r-- | crates/phone-opus/src/mcp/service.rs | 55 |
2 files changed, 8 insertions, 111 deletions
diff --git a/crates/phone-opus/src/mcp/catalog.rs b/crates/phone-opus/src/mcp/catalog.rs index a4a1780..3570b1f 100644 --- a/crates/phone-opus/src/mcp/catalog.rs +++ b/crates/phone-opus/src/mcp/catalog.rs @@ -41,29 +41,11 @@ impl ToolSpec { const TOOL_SPECS: &[ToolSpec] = &[ ToolSpec { name: "consult", - description: "Run a consult against the system Claude Code install using a read-only built-in toolset, optionally resume a prior Claude session by session_id, optionally queue the consult in the background, and return the response or job handle.", + description: "Run a blocking consult against the system Claude Code install using a read-only built-in toolset, optionally resume a prior Claude session by session_id, and return the response plus execution metadata.", dispatch: DispatchTarget::Worker, replay: ReplayContract::NeverReplay, }, ToolSpec { - name: "consult_job", - description: "Read the status of one background consult job by job_id. When the job has finished, the final Claude response or failure is included.", - dispatch: DispatchTarget::Host, - replay: ReplayContract::Convergent, - }, - ToolSpec { - name: "consult_wait", - description: "Block until one background consult job finishes or a timeout elapses. When the job has finished, the final Claude response or failure is included.", - dispatch: DispatchTarget::Host, - replay: ReplayContract::Convergent, - }, - ToolSpec { - name: "consult_jobs", - description: "List recent background consult jobs. Defaults to render=porcelain; use render=json for structured output.", - dispatch: DispatchTarget::Host, - replay: ReplayContract::Convergent, - }, - ToolSpec { name: "health_snapshot", description: "Read host lifecycle, worker generation, rollout state, and latest fault. Defaults to render=porcelain; use render=json for structured output.", dispatch: DispatchTarget::Host, @@ -111,54 +93,10 @@ fn tool_schema(name: &str) -> Value { "session_id": { "type": "string", "description": "Optional Claude session handle returned by a previous consult call. When set, phone_opus resumes that conversation instead of starting a fresh one." - }, - "background": { - "type": "boolean", - "description": "When true, queue the consult as a background job and return immediately with a job handle. The default is false, which keeps consult synchronous." } }, "required": ["prompt"] })), - "consult_job" => with_common_presentation(json!({ - "type": "object", - "properties": { - "job_id": { - "type": "string", - "description": "Background consult job handle returned by consult with background=true." - } - }, - "required": ["job_id"] - })), - "consult_wait" => with_common_presentation(json!({ - "type": "object", - "properties": { - "job_id": { - "type": "string", - "description": "Background consult job handle returned by consult with background=true." - }, - "timeout_ms": { - "type": "integer", - "minimum": 0, - "description": "Maximum time to wait for completion before returning the current job state. Defaults to 1800000 (30 minutes)." - }, - "poll_interval_ms": { - "type": "integer", - "minimum": 10, - "description": "Polling interval used while waiting. Defaults to 1000." - } - }, - "required": ["job_id"] - })), - "consult_jobs" => with_common_presentation(json!({ - "type": "object", - "properties": { - "limit": { - "type": "integer", - "minimum": 1, - "description": "Maximum number of recent background jobs to return. Defaults to 10." - } - } - })), "health_snapshot" | "telemetry_snapshot" => with_common_presentation(json!({ "type": "object", "properties": {} diff --git a/crates/phone-opus/src/mcp/service.rs b/crates/phone-opus/src/mcp/service.rs index 773a516..64cb778 100644 --- a/crates/phone-opus/src/mcp/service.rs +++ b/crates/phone-opus/src/mcp/service.rs @@ -86,19 +86,9 @@ impl WorkerService { let args = deserialize::<ConsultArgs>(arguments, &operation, self.generation)?; let request = ConsultRequest::parse(args) .map_err(|error| invalid_consult_request(self.generation, &operation, error))?; - match request.mode() { - ConsultMode::Sync => { - let response = invoke_claude(&request) - .map_err(|error| consult_fault(self.generation, &operation, error))?; - consult_output(&request, &response, self.generation, &operation)? - } - ConsultMode::Background => submit_background_consult( - &request, - self.generation, - FaultStage::Worker, - &operation, - )?, - } + let response = invoke_claude(&request) + .map_err(|error| consult_fault(self.generation, &operation, error))?; + consult_output(&request, &response, self.generation, &operation)? } other => { return Err(FaultRecord::invalid_input( @@ -124,7 +114,6 @@ struct ConsultArgs { prompt: String, cwd: Option<String>, session_id: Option<String>, - background: Option<bool>, } #[derive(Debug, Deserialize)] @@ -153,7 +142,6 @@ struct ConsultRequest { prompt: PromptText, cwd: WorkingDirectory, session: Option<SessionHandle>, - mode: ConsultMode, } impl ConsultRequest { @@ -162,14 +150,9 @@ impl ConsultRequest { prompt: PromptText::parse(args.prompt)?, cwd: WorkingDirectory::resolve(args.cwd)?, session: args.session_id.map(SessionHandle::parse).transpose()?, - mode: ConsultMode::from_background(args.background), }) } - fn mode(&self) -> ConsultMode { - self.mode - } - fn session_mode(&self) -> &'static str { if self.session.is_some() { "resumed" @@ -182,6 +165,7 @@ impl ConsultRequest { self.session.as_ref().map(SessionHandle::display) } + #[allow(dead_code, reason = "background submission is parked but not exposed")] fn background_request(&self) -> BackgroundConsultRequest { BackgroundConsultRequest { prompt: self.prompt.as_str().to_owned(), @@ -191,29 +175,6 @@ impl ConsultRequest { } } -#[derive(Debug, Clone, Copy, Eq, PartialEq)] -enum ConsultMode { - Sync, - Background, -} - -impl ConsultMode { - fn from_background(raw: Option<bool>) -> Self { - if raw.unwrap_or(false) { - Self::Background - } else { - Self::Sync - } - } - - fn as_str(self) -> &'static str { - match self { - Self::Sync => "sync", - Self::Background => "background", - } - } -} - #[derive(Debug, Clone)] struct PromptText { original: String, @@ -305,7 +266,6 @@ impl BackgroundConsultRequest { prompt: self.prompt, cwd: Some(self.cwd), session_id: self.session_id, - background: Some(false), }) } } @@ -895,6 +855,7 @@ pub(crate) fn consult_jobs_tool_output( ) } +#[allow(dead_code, reason = "background submission is parked but not exposed")] fn submit_background_consult( request: &ConsultRequest, generation: Generation, @@ -929,7 +890,7 @@ fn submit_background_consult( .map_err(|error| FaultRecord::process(generation, stage, operation, error.to_string()))?; let concise = json!({ - "mode": request.mode().as_str(), + "mode": "background", "job_id": record.job_id.display(), "status": record.status, "done": false, @@ -939,7 +900,7 @@ fn submit_background_consult( "follow_up_tools": ["consult_wait", "consult_job", "consult_jobs"], }); let full = json!({ - "mode": request.mode().as_str(), + "mode": "background", "job_id": record.job_id.display(), "status": record.status, "done": false, @@ -1495,7 +1456,6 @@ fn consult_output( operation: &str, ) -> Result<ToolOutput, FaultRecord> { let concise = json!({ - "mode": request.mode().as_str(), "response": response.result, "cwd": response.cwd.display(), "persisted_output_path": response.persisted_output_path.display(), @@ -1511,7 +1471,6 @@ fn consult_output( "permission_denial_count": response.permission_denials.len(), }); let full = json!({ - "mode": request.mode().as_str(), "response": response.result, "cwd": response.cwd.display(), "persisted_output_path": response.persisted_output_path.display(), |