Files
docker-agent/pkg/js
Djordje Lukic e8f6745b02 refactor(tools): replace context-smuggled emitters with explicit tools.Runtime handle
Tool handlers previously reached back into the runtime through two
context keys (ToolOutputEmitter, ToolRecallEmitter), each with its own
With*/FromContext/Emit* boilerplate, invisible in the handler signature
and requiring ad-hoc lifetime tricks (context.WithoutCancel + closure
capture) for background work.

Replace both with a single tools.Runtime capability handle passed
explicitly to every handler:

- ToolHandler is now func(ctx, ToolCall, rt Runtime); runtime-managed
  handlers (toolexec.ToolHandler) grow the same parameter, unifying the
  two tool APIs on one capability surface
- Runtime methods (EmitOutput, Recall, Supports) take ctx per call and
  remain valid after the handler returns, so background jobs hold the
  handle instead of a captured closure
- NopRuntime serves hosts without an agent loop (slash commands, prompt
  expansion, tests); Supports() lets tools fail fast before starting
  background work
- NewHandler keeps its signature; NewRuntimeHandler is the variant for
  tools that talk back (shell streaming/recall, codemode forwarding)
- codemode forwards the handle into script-invoked tools, preserving
  the nested-capability inheritance the ctx transport gave implicitly
2026-07-04 09:37:25 +00:00
..