Commit Graph

7 Commits

Author SHA1 Message Date
Aiden Cline c16bba8bc0 feat(opencode): JSDoc tags, Result<T> return hints, and opaque attachments
- describe/preview now surface each tool's return type as Result<T> (alias
  defined once in the prompt); the inline preview shows it too, so the model
  sees a tool's result shape without a describe round-trip. T is the declared
  outputSchema else unknown, with prose telling the model to inspect an unknown
  result before assuming fields.
- renderType pretty mode emits JSDoc tags a TS type can't express: @default,
  @format, @deprecated, @minItems/@maxItems (multi-line descriptions preserved).
- Attachments are now opaque handles: a tool's media becomes
  { type:'file', id, mime, filename?, bytes } with no inline bytes. Real bytes
  stay host-side in a per-execution attachmentTable; the program propagates or
  drops a handle (return it to surface the image to the model+user) but cannot
  read or leak the base64. Documents the divergence from prior art in rune.md.
- Records the throw/catch (not errors-as-values) decision in rune.md.
2026-07-01 10:54:42 -05:00
Aiden Cline 5085a13b0e feat(opencode): render code-mode types as TypeScript, not JSON Schema
tools.$rune.describe now returns { path, description, signature, input,
output? } with input/output as TypeScript instead of raw JSON Schema.
Rewrite renderType into a total, cycle-safe JSON-Schema -> TS renderer:
resolve local $refs (collapsing recursive refs to their name), render
enums/const as literals, anyOf/oneOf and nullable type arrays as unions,
allOf as an intersection (unwrapping the Pydantic allOf:[{$ref}] shape),
tuples, and additionalProperties as an index signature. Pretty mode emits
JSDoc (multi-line preserved) for described fields, with */ neutralized.
Falls back to any/object and never throws; depth-capped.

Docs updated; code-mode/renderType test coverage expanded.
2026-06-30 22:34:23 -05:00
Aiden Cline 05b934616b fix(tui): surface execute child call details 2026-06-30 19:23:49 -05:00
Aiden Cline bc427b11b7 feat: live code-mode execute UI in the TUI
Backend: code-mode execute now streams per-call progress. Metadata.toolCalls
becomes CallEntry[] ({ tool: dotted-path, status: running|completed|error })
and is published via ctx.metadata on every status change — when a child MCP
call starts and when it resolves/fails — so the tool part updates live.

TUI: add an Execute component (dispatched for the "execute" tool). Condensed
view shows a run header (spinner while running, ✓ when done) plus a live `↳`
line per child tool call, colored on failure; clicking toggles a syntax-
highlighted view of the program source. Unlike Task, there is no child session,
so the call list is sourced entirely from the streamed metadata.
2026-06-30 17:13:16 -05:00
Aiden Cline 79275e60fb fix(opencode): describe attachments as routable values, not opaque
The previous wording claimed attachment bytes 'aren't available in code',
but a tool result's { result, attachments } envelope is copied straight
into the sandbox (tool-runtime invoke -> checkedCopyIn), so attachment.url
is a real data: URL string the program can read and route — e.g. feed one
tool's media into another tool's input, which is exactly what code mode is
uniquely good at. Reword the description to say so. Still not the emit
pattern: only `result` becomes conversation text; returned attachments
lower to FileParts and nothing else in the sandbox re-enters the chat.

Add an integration test asserting the data URL is readable in-program.
2026-06-30 14:10:06 -05:00
Aiden Cline a3bfba809f feat(opencode): unify code mode discovery under tools.$rune
Remove Rune's vestigial built-in $rune.search/$rune.describe (which only
saw effect-Schema Definitions, never our dynamic MCP tools) and the
reserved-namespace guard. Move our ranked search and typed describe under
tools.$rune.* — the runtime's own namespace, separate from MCP server
namespaces and collision-proof since $ never appears in a sanitized
server name. One discovery implementation, no dead code.
2026-06-30 11:11:55 -05:00
Aiden Cline acc1742859 test(opencode): end-to-end code mode test over a real MCP server
Stand up an in-memory MCP server with text, structured (outputSchema),
image, and failing tools, wire it through convertTool + define, and
exercise search/describe, the result+attachments envelope, structured
composition, image forwarding/suppression, parallel calls, error
propagation, and per-call permission gating.
2026-06-30 09:55:25 -05:00