Skip to content

api changes for gathm ui chat#23

Merged
mukeshkumarcharak merged 2 commits into
mainfrom
claude/jolly-carson-j2c8zt
Jun 8, 2026
Merged

api changes for gathm ui chat#23
mukeshkumarcharak merged 2 commits into
mainfrom
claude/jolly-carson-j2c8zt

Conversation

@mukeshkumarcharak

Copy link
Copy Markdown
Contributor

No description provided.

claude added 2 commits June 8, 2026 20:41
api/server.py:
- POST /agent/ask now runs the matched tool instead of just returning
  which tool it found. Flow: match intent -> extract NL args ->
  execute_tool() -> return real output.
- Add _extract_tool_args(): strips common filler words + the tool name
  from the query to get bare arguments (e.g. "weather in Tokyo" -> ["Tokyo"]).
- Add _strip_ansi(): removes ANSI escape codes from tool output so the
  GUI receives clean text.
- Handle "gathm run <tool> [args]" passthrough so typing CLI commands
  in the chat also works.

gui/app.js:
- checkConnectivity() tries /ping then falls back to /api/v1/tools for
  servers that pre-date the /ping endpoint -- fixes the false Offline
  status when running an older local server.
- formatAgentReply() now handles {status, output} from executed tools;
  surfaces errors cleanly; no-match shows a friendly hint list.
- Rewrote file in plain ASCII (no smart quotes / unicode bullets) to
  fix the Node.js SyntaxError from prior edits.

https://claude.ai/code/session_01THtMvNNx21QhXYi6PBRFBz
The GUI was talking to the bash keyword-router (orchestrator.sh ask),
which has no language understanding — hence all the brittle regex
arg-extraction. The actual AI agent already exists in pilot/main.py
(LangGraph + Ollama/Gemini) but was only reachable from the terminal TUI.

Expose it over HTTP and let it do the heavy lifting:

- pilot/chat_once.py: single-shot, non-interactive entry to the Pilot
  agent. Reads {query, history} JSON on stdin, runs one agent turn,
  prints {reply, backend, model} JSON on stdout. All TUI/agent output is
  redirected to stderr so stdout stays clean. Catches SystemExit/import
  failures and emits a clean error.

- api/server.py: new POST /api/v1/agent/chat. Shells out to chat_once.py
  via the Pilot venv's Python (keeping the API server stdlib-only), so
  the LLM understands the message, picks/runs tools, and replies in
  natural language. Falls back to the keyword router (with chat_error)
  when the LLM runtime isn't available.

- gui/app.js: call /agent/chat instead of /agent/ask, keep client-side
  conversation history for multi-turn context, and simplify
  formatAgentReply to prefer the agent's reply.

Requires an LLM backend (Ollama running, or a Gemini key) plus the pilot
venv. Without them the server degrades to the router automatically.

https://claude.ai/code/session_01THtMvNNx21QhXYi6PBRFBz
@mukeshkumarcharak mukeshkumarcharak merged commit abd7231 into main Jun 8, 2026
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants