Skip to content

feat(server): /tool, /status, /exec endpoints#21777

Open
micuintus wants to merge 5 commits intoanomalyco:devfrom
micuintus:feat/server-endpoints
Open

feat(server): /tool, /status, /exec endpoints#21777
micuintus wants to merge 5 commits intoanomalyco:devfrom
micuintus:feat/server-endpoints

Conversation

@micuintus
Copy link
Copy Markdown

@micuintus micuintus commented Apr 9, 2026

Issue for this PR

Closes #21771
Depends on #21772 (external flag on ToolPart)

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds three server endpoints for plugin interaction with sessions:

  • POST /session/:id/tool — injects an external tool call + result into a session, marked with external: true so the model context builder skips it.
  • POST /session/:id/status — appends a display-only status message to a session (for TUI progress reporting).
  • POST /session/:id/exec — executes a named tool with given args via a child session and returns the result.

This PR includes the external flag commit as a base. Once #21772 lands, this branch will be rebased to drop the duplicate.

How did you verify your code works?

  • Unit tests: session-tool.test.ts, session-status.test.ts, session-naming.test.ts, session-todo.test.ts, emitter-type.test.ts
  • TUI visibility test: tool-part-visibility.test.ts
  • bun turbo typecheck passes

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Part of the plugin primitives work split from #21687 (tracking issue #20018).

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

…alls from model context

External tool parts are displayed in the TUI and persisted, but excluded
from toModelMessages() to prevent orphaned tool_use/tool_result pairs.
Plugins and HTTP endpoints can mark their tool executions as external.
… scripts

Executes any registered OpenCode tool by name without LLM involvement.
Results are streamed as plain text. When a messageID is provided, creates
an external ToolPart so the execution is visible in the TUI. Introduces
the emitter() and resolveModel() helpers shared by all plugin HTTP endpoints.
…e TUI

Creates an external ToolPart tied to a parent message so plugins can surface
status text in the TUI without sending content to the LLM.
@micuintus micuintus force-pushed the feat/server-endpoints branch 2 times, most recently from b961e15 to 71d19bf Compare April 9, 2026 23:18
…ession

Scripts can delegate decisions to the LLM by POSTing a prompt. A fresh child
session is created for each call so token context never accumulates. Supports
structured JSON output, file attachments, model override, custom system prompt,
and live streaming. The parent session inherits the last-used model by default.
Adds create (POST) and bulk-update (PUT) routes for session todos.
The new Todo.add() provides O(1) single-item insertion instead of the
previous delete-all + insert-all pattern. Todo.update() is exported
for the PUT bulk-replace route. Old todo routes (at the end of the
chain) are replaced with improved versions placed after the GET route.
@micuintus micuintus force-pushed the feat/server-endpoints branch from 71d19bf to 2f5df54 Compare April 9, 2026 23:59
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.

[FEATURE]: /tool, /status, /exec server endpoints

1 participant