davsclaus opened a new pull request, #27912:
URL: https://github.com/apache/camel/pull/27912

   The runtime side of 
[CAMEL-25388](https://issues.apache.org/jira/browse/CAMEL-25388) step 2: the 
file transport of camel-cli-connector answers every action that has a request 
id, so the Camel CLI, the TUI and the MCP tools no longer wait for a timeout to 
find out an action failed, or that it worked.
   
   ### Answers
   
   An action written to `~/.camel/<pid>-action-<requestId>.json` gets one of 
these in `~/.camel/<pid>-output-<requestId>.json`:
   
   | Outcome | Answer |
   |---|---|
   | a result | the result, as before |
   | unknown action, exception, reported error | 
`{"status":"failed","error":"..."}` |
   | ... about something that does not exist | `{"status":"failed","error":"No 
route matching: x","reason":"not-found"}` |
   | no result (route stop, gc, logger ...) | `{"status":"success"}` |
   
   - `status:failed` + `error` is the shape the file transport has written for 
exceptions since 4.23, and the semantic commands of 4.23 read it.
   - The shared `<pid>-action.json` / `<pid>-output.json` of older Camel CLI 
versions keeps its behaviour (the result, or the error of an exception). Those 
versions never read the other answers, and the next command could read one 
instead of its own result.
   - `reason: not-found` lets the CLI exit with 3 (CAMEL-25389). It comes from 
the new `CliActionOutput.notFound(String)` (default: `error(message)`), used 
for "No route matching" and the new "No processor matching" (the processor 
action reported nothing before, not even its failures).
   
   ### Changes
   - `CliActionOutcome` turns an action into an answer for both transports: the 
exception, an unknown or missing action, a reported error, or a result with 
status error/failed (message from `exception.message`, `error`, `message`, else 
"Action failed"). The WebSocket transport now shows the message of a failed 
result where it said "Action failed", and adds `reason` to its `result` frame.
   - `FileCliConnectorTransport` writes the answer from it. An action file that 
cannot be read yet (empty, or half-written JSON from a CLI that writes in 
place) is retried for two seconds instead of dropped; after that, an action 
with a request id gets `Invalid action: ...`.
   - Fixes [CAMEL-25386](https://issues.apache.org/jira/browse/CAMEL-25386): 
the MCP route tools (`RuntimeHelper.executeAction`) get `{"status":"success"}` 
for a route stop that worked, instead of "Timeout waiting for response", and 
the real error when no route matches. The TUI already removes the answer of a 
fired request.
   
   ### Docs
   - `cli-connector.adoc`: a new "File transport" section with the answers, and 
`reason` in the WebSocket frame (catalog copy synced).
   - 4.24 upgrade guide entry.
   
   ### Tests
   - `FileCliConnectorTransportTest` (new, stub dispatcher): result, ack, 
unknown action, missing action, exception, reported error, not-found, invalid 
and half-written action files, and the shared action file keeping its behaviour.
   - `CliActionOutcomeTest` (new): message from the result, unknown action, 
exception, not-found, and cancelling the outcome cancels the action.
   - `LocalCliConnectorFileTransportTest`: an unknown action gets an error (was 
"ignored"), a route stop with a request id is acknowledged, an unknown route or 
processor is not found; the shared action file still writes nothing for a route 
stop.
   - `WebSocketCliConnectorTransportTest`: the no-match route error and its 
reason.
   - `mvn test` of camel-cli-connector: 68 tests pass.
   
   The CLI side that waits for these answers and turns them into exit codes is 
CAMEL-25391 (`ActionClient`) and CAMEL-25393 (`camel cmd` actions).
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01DDRLJAyf8cDXSg8iX785My
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to