From 5a771be55968ed27cb2d4f86bafad3093fd4537d Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 2 Dec 2026 13:55:56 -0800 Subject: [PATCH 1/3] Add the plan for unified ToolInfo Record the plan for moving Workshop's pins to contract 0.9, updating `WorkshopBroker::chat` to `ToolInfo`, and flattening `ToolInfo` onto `ContractResponse` for `/prompts/contract`. Plan: /plan/2026-12-02-2-unified-tool-info.plan.md --- plan/2026-12-02-2-unified-tool-info.plan.md | 153 ++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 plan/2026-12-02-2-unified-tool-info.plan.md diff --git a/plan/2026-12-02-2-unified-tool-info.plan.md b/plan/2026-12-02-2-unified-tool-info.plan.md new file mode 100644 index 00000000..4bcb8f45 --- /dev/null +++ b/plan/2026-12-02-2-unified-tool-info.plan.md @@ -0,0 +1,153 @@ +--- +name: Unified ToolInfo +overview: Consolidate all tool, MCP function, and prompt callable metadata into a single plain pub struct ToolInfo in gateway-types (using explicit Arc at shared catalog/binding/chat sites), sync its source verbatim into runvil-plugin-sdk over a JSON RvToolInfo C ABI (v0.9.0), and roll it out in small testable commits across Waves 1-4 (pushing to origin, opening PRs, waiting on CI, and merging to upstream at each wave). +todos: + - id: wave1-gateway-client + content: "Wave 1a (gateway-client): 3 testable commits (plan copy, add gateway_types::ToolInfo, replace ToolSchema with concrete Arc); verify all CI gates, push to origin, open PR to upstream, wait for green CI/reviews, and merge to upstream (SHA G)" + status: completed + - id: wave1-plugin-api + content: "Wave 1b (runvil-plugin-api, parallel with 1a once tool.rs is written): 3 testable commits (plan copy, sync tool_info.rs + xtask check + serde deps, bump contract to 0.9.0 with 24-byte JSON RvToolInfo); verify 1.85 MSRV + c-layout, push to origin, open PR, merge to upstream (SHA P)" + status: completed + - id: wave2-three-plugins + content: "Wave 2a (runvil-plugin-std, bashkit, web in parallel): 2 testable commits per repo (plan copy, pin SDK 0.9.0 at SHA P + Value/with_* updates); verify, push to origin, open PRs, and merge to upstream (SHAs S, B, W)" + status: in_progress + - id: wave2-harness + content: "Wave 2b (runvil-harness, parallel with 2a): 4 testable commits (plan copy, pin G + adopt ToolInfo across engine/harness/mcp on 0.8 loader, embed Arc in Frontmatter & drop Annotations, pin contract 0.9.0 at P + JSON RvToolInfo in loader/test-plugin + decisions); verify, push to origin, open PR, merge to upstream (SHA H)" + status: pending + - id: wave3-workshop-and-runvil + content: "Wave 3 (runvil-workshop, then runvil): 3 testable commits in workshop (plan copy, pin H/P/S/B/W + WorkshopBroker::chat, flatten prompt.tool_info() into /prompts/contract + UI tests), PR & merge to upstream (SHA K); then pin Workshop SHA K in runvil, PR & merge to upstream" + status: pending +isProject: false +--- + +# Unify Tool, Prompt, and MCP Metadata into `gateway_types::ToolInfo` + +## Goal and Design Summary + +Replace the separate tool, prompt-annotation, MCP-listing, and wire-schema structs across the fleet with one plain `pub struct ToolInfo` defined in `gateway-types` and copied verbatim into `runvil-plugin-sdk`: + +- **Plain struct + explicit `Arc` for \(O(1)\) sharing (zero `serde/rc` needed)**: `ToolInfo` is a plain Rust struct with `pub` fields matching `ModelInfo`, `Message`, and `Error` in `gateway-types`. Single-owner boundaries (`Pack::tools() -> Vec`, `Pack::render(...) -> Result>`, `PackToolSets` in `EffectAnswer::Render`) move `ToolInfo` by value in \(O(1)\) so `Pack::render` mutates fields naturally and `EffectAnswer::Render` serializes without enabling `serde/rc`. Shared multi-owner lifetimes (`ToolCatalog`, `OfferedTool`, `ToolBinding`, `LuaToolHandle`, `Prompt`, `Effect::Chat`, `InferenceBroker::chat`) hold `Arc` explicitly so schemas and descriptions are never deep-copied across runs, Lua VMs, or model rounds. +- **100% self-describing flat struct (zero helper structs)**: `ToolInfo` holds `name`, `pack` (losslessly splitting 2+ segment `ToolId`s at the first `/`, e.g. `pack = Some("fixtures")`, `name = "tools/inspect"`), `wire_name` (plus `effective_wire_name` and `qualified_name` helpers), `title`, `description`, `input_schema`, optional `output_schema`, the 4 closed MCP hints (`read_only_hint`, `destructive_hint`, `idempotent_hint`, `open_world_hint`), and the 5 Engine execution flags (`structured_output`, `survives_stop`, `describes_tools`, `model_only_call`, `changes_files`). +- **Third-party safe & Engine-stage validated**: `ToolInfo::new` is infallible (preserving Engine tests that place unvalidated schemas into `ToolCatalog` and reject them at `scope` freeze), `output_schema: Option` is descriptive and optional, and `structured_output: bool` remains the explicit opt-in switch for Lua `tools.call` JSON decoding. +- **Standalone plugin repo**: `tool.rs` uses only `std`, `serde`, and `serde_json` (Rust 1.85 syntax, functions `<= 100` lines and `<= 7` args, no `#[non_exhaustive]`) and is copied into `runvil-plugin-sdk` and committed to Git, passing JSON text across `RvToolInfo` in C ABI v0.9.0. + +## Git, Commit, PR, and Upstream Merge Protocol + +Every downstream `Cargo.toml` pins `https://github.com/cppalliance/` (`upstream`) by exact commit SHA, while local `master` pushes to `git@github.com:vinniefalco/.git` (`origin`). Therefore each wave completes its `origin` push -> PR -> green CI -> `upstream` merge cycle before the next wave pins its merged `upstream` SHA: + +1. **Stay on `master`** (no topical branches; `origin` is the fork, `upstream` is `cppalliance/*`). Sync `master` with `upstream/master` before starting each repo. +2. **Plan copy commit first**: Commit 1 in every touched repo adds `plan/2026-12-02-2-unified-tool-info.plan.md` so every commit message follows `.cursor/rules/commit.mdc` (`Plan: /plan/2026-12-02-2-unified-tool-info.plan.md`). +3. **Every commit is independently green**: Before each `git commit`, run `cargo fmt`, `cargo clippy` (warnings denied), and the workspace test suite (+ `xtask` / `public-api` / MSRV checks where applicable) so `git bisect` passes at every single commit. +4. **PR & merge per wave**: Push `master` to `origin`, open a PR against `cppalliance/:master` via `gh pr create`, monitor GitHub Actions checks and review comments until green, address any findings in follow-up testable commits, merge the PR to `upstream` via `gh pr merge`, and `git fetch upstream && git merge --ff-only upstream/master` locally to capture the exact merged `upstream` SHA for the next wave. + +```mermaid +flowchart TD + GatewayTypes["gateway-types"] -->|"copy tool.rs"| PluginApi["plugin-api 0.9"] + GatewayTypes -->|"upstream SHA G"| Harness["runvil-harness"] + PluginApi -->|"upstream SHA P"| PluginStd["plugin-std"] + PluginApi -->|"upstream SHA P"| PluginBash["plugin-bashkit"] + PluginApi -->|"upstream SHA P"| PluginWeb["plugin-web"] + PluginApi -->|"upstream SHA P"| Harness + PluginStd -->|"upstream SHA S"| Workshop["runvil-workshop"] + PluginBash -->|"upstream SHA B"| Workshop + PluginWeb -->|"upstream SHA W"| Workshop + Harness -->|"upstream SHA H"| Workshop + Workshop -->|"upstream SHA K"| Runvil["runvil"] +``` + +## Wave 1: `gateway-client` and `runvil-plugin-api` (Parallel PRs once `tool.rs` is written) + +### Wave 1a: `gateway-client` (3 Testable Commits -> Merged Upstream SHA `G`) + +- **Commit 1**: Add `plan/2026-12-02-2-unified-tool-info.plan.md`. +- **Commit 2 (additive, keeps `ToolSchema` compiling)**: Add [`gateway-client/crates/gateway-types/src/tool.rs`](https://github.com/cppalliance/gateway-client/blob/master/crates/gateway-types/src/tool.rs) + unit tests, re-export `ToolInfo` from [`gateway-client/crates/gateway-types/src/lib.rs`](https://github.com/cppalliance/gateway-client/blob/master/crates/gateway-types/src/lib.rs) and [`gateway-client/crates/gateway-client/src/lib.rs`](https://github.com/cppalliance/gateway-client/blob/master/crates/gateway-client/src/lib.rs), and update both `public-api.txt` snapshots: + - Rust 1.85 syntax (no `let` chains), no `#[non_exhaustive]`, `<= 100` lines and `<= 7` args per function, `use std::fmt;`, text-only doc fences, and intra-doc links scoped strictly to `ToolInfo`: + +```rust +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[expect( + clippy::struct_excessive_bools, + reason = "the five execution flags are independent properties of one tool" +)] +pub struct ToolInfo { + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pack: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub wire_name: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub title: Option, + pub description: String, + pub input_schema: Value, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub output_schema: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub read_only_hint: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub destructive_hint: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub idempotent_hint: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub open_world_hint: Option, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub structured_output: bool, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub survives_stop: bool, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub describes_tools: bool, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub model_only_call: bool, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub changes_files: bool, +} +``` + + - Provide infallible `ToolInfo::new(name, description, input_schema)`, `with_*` builders, `effective_wire_name(&self) -> Cow<'_, str>`, `qualified_name(&self) -> Cow<'_, str>`, and field getters. +- **Commit 3 (replace `ToolSchema` with concrete `Arc`)**: Update [`gateway-client/crates/gateway-types/src/request.rs`](https://github.com/cppalliance/gateway-client/blob/master/crates/gateway-types/src/request.rs), `request-tests.rs`, [`gateway-client/crates/gateway-types/src/broker.rs`](https://github.com/cppalliance/gateway-client/blob/master/crates/gateway-types/src/broker.rs), and [`gateway-client/crates/gateway-client/src/transport.rs`](https://github.com/cppalliance/gateway-client/blob/master/crates/gateway-client/src/transport.rs). Keep `tools` concrete (`Option<&[Arc]>` on `build_request_body` and `GatewayClient::complete`; `Vec>` on `InferenceBroker::chat`) so all 22 bare `None` / `Some(&[])` call sites infer cleanly without `E0282`. Validate `(tool.effective_wire_name(), &tool.input_schema)` via `validate_tool_schema` (retaining `ErrorCode::ToolSchemaInvalid = 509`), refresh both `public-api.txt` files, verify all CI gates (`+1.88`, `dylint`, `deny`, `nextest`), push to `origin`, open PR, and merge to `upstream` -> SHA `G`. + +### Wave 1b: `runvil-plugin-api` v0.9.0 (3 Testable Commits -> Merged Upstream SHA `P`) + +- **Commit 1**: Add `plan/2026-12-02-2-unified-tool-info.plan.md`. +- **Commit 2 (sync `tool_info.rs` + `xtask` check, keeping 0.8 ABI intact)**: Add `serde` and `serde_json` to [`runvil-plugin-api/Cargo.toml`](https://github.com/cppalliance/runvil-plugin-api/blob/master/Cargo.toml) and [`runvil-plugin-api/crates/runvil-plugin-sdk/Cargo.toml`](https://github.com/cppalliance/runvil-plugin-api/blob/master/crates/runvil-plugin-sdk/Cargo.toml) (`runvil-plugin-sys` stays `#![no_std]` with zero dependencies), copy `tool.rs` verbatim to [`runvil-plugin-api/crates/runvil-plugin-sdk/src/tool_info.rs`](https://github.com/cppalliance/runvil-plugin-api/blob/master/crates/runvil-plugin-sdk/src/tool_info.rs), and add `sync-tool-info` check in [`runvil-plugin-api/crates/build-xtask/src/main.rs`](https://github.com/cppalliance/runvil-plugin-api/blob/master/crates/build-xtask/src/main.rs). Verify `+1.85 check` and `cargo test` pass. +- **Commit 3 (bump C contract & SDK to `0.9.0` with JSON `RvToolInfo`)**: + - Update [`runvil-plugin-api/crates/runvil-plugin-sys/src/lib.rs`](https://github.com/cppalliance/runvil-plugin-api/blob/master/crates/runvil-plugin-sys/src/lib.rs) (`RV_API_MINOR = 9`, `RvToolInfo { size: u32, reserved: u32, json: RvStr }` size 24, `RV_MAX_TOOL_JSON = 262_144`, keeping `RV_MAX_TOOL_TEXT = 65_536` for `description`), regenerate [`runvil-plugin-api/crates/runvil-plugin-sys/include/runvil_plugin.h`](https://github.com/cppalliance/runvil-plugin-api/blob/master/crates/runvil-plugin-sys/include/runvil_plugin.h), and update [`runvil-plugin-api/tests/c-layout/src/lib.rs`](https://github.com/cppalliance/runvil-plugin-api/blob/master/tests/c-layout/src/lib.rs) + `layout.c`. + - Switch `runvil-plugin-sdk` (`src/tool.rs`, `src/entry/{pack,tool,file}.rs`, `src/testing.rs`, `src/testing/{pack,render,fixture}.rs`, `examples/hello-plugin/src/lib.rs`, `AGENTS.md`, `README.md`) to re-export `tool_info::ToolInfo`, keeping `let jsons: Vec` alive across `extern "C"` render calls and updating `Mode::Respaced` in `testing/render.rs` for semantic JSON `Value` comparison. + - Verify all CI checks (`+1.85`, `c-layout`, `clippy`, `doc`), push to `origin`, open PR, and merge to `upstream` -> SHA `P`. + +## Wave 2: Three Plugin Repos + `runvil-harness` (4 Parallel PRs once `G` and `P` Merge) + +### Wave 2a: `runvil-plugin-std`, `runvil-plugin-bashkit`, and `runvil-plugin-web` (2 Testable Commits Each -> Merged SHAs `S`, `B`, `W`) + +In each of [`runvil-plugin-std`](https://github.com/cppalliance/runvil-plugin-std), [`runvil-plugin-bashkit`](https://github.com/cppalliance/runvil-plugin-bashkit), and [`runvil-plugin-web`](https://github.com/cppalliance/runvil-plugin-web) independently in parallel: +- **Commit 1**: Add `plan/2026-12-02-2-unified-tool-info.plan.md`. +- **Commit 2**: Pin `runvil-plugin-sdk = "0.9.0"` at `P`, pass `serde_json::Value` directly to `ToolInfo::new` using `.with_wire_name(...)` and `.with_changes_files(true)`, update `[ToolInfo::with_changes_files]` doc link in [`runvil-plugin-std/crates/plugin-std/src/lib.rs`](https://github.com/cppalliance/runvil-plugin-std/blob/master/crates/plugin-std/src/lib.rs), and update `tool.input_schema` assertions in `pack-tests.rs` and `web-tests.rs`. +- Verify all checks (`build-checks`, `clippy`, `test`, `doc`), push to `origin`, open PRs, and merge to `upstream` -> SHAs `S`, `B`, `W`. + +### Wave 2b: `runvil-harness` (4 Testable Commits -> Merged Upstream SHA `H`) + +- **Commit 1**: Add `plan/2026-12-02-2-unified-tool-info.plan.md`. +- **Commit 2 (pin `gateway-types` at `G` and unify `ToolInfo` across Engine, Harness, and `plugin-mcp` while keeping loader on 0.8)**: + - Update [`Cargo.toml`](../Cargo.toml) to pin `gateway-client` / `gateway-types` at `G`. + - Delete `runvil_types::tools::ToolInfo` in [`crates/runvil-internal/types/src/tools.rs`](../crates/runvil-internal/types/src/tools.rs) and re-export `gateway_types::ToolInfo`. Split 2+ segment `ToolId`s at the first `/` (`pack` + `name`) and index `(ToolId, Arc)` inside `ToolCatalog`, `OfferedTool::Catalog`, `ToolBinding`, and `LuaToolHandle` (keeping `.id() -> &ToolId` borrowed at all 30+ Engine sites and `.parameters` userdata reading `input_schema`). + - Update `Effect::Chat` (`tools: Vec>`), `scope.rs`, `RunPacks`, `plugin-mcp` (`rmcp::model::Tool` -> `Arc` preserving `title`, `output_schema`, and hints while keeping `mcp/get_dynamic_tools` output unchanged), `harness-plugin-loader` (adapting 0.8 `RvToolInfo` into new `ToolInfo`), `harness-gateway-client`, and facades (`runvil-engine`, `runvil`, dropping `ToolSchema` re-exports and blessing `public-api.txt`). Every workspace test and `xtask` check passes at this commit. +- **Commit 3 (embed `Arc` in `Frontmatter` / `Prompt` and drop `pub struct Annotations`)**: + - In [`crates/runvil-internal/prompt/src/frontmatter.rs`](../crates/runvil-internal/prompt/src/frontmatter.rs) and `prompt.rs`, keep private `RawAnnotations` so every YAML error message and span test in `frontmatter-tests-annotations.rs` stays identical, build `tool: Arc` on `Frontmatter` (keeping `.name()`, `.description()`, `.title()`, `.args()` delegating on `Frontmatter` and adding `Frontmatter::tool_info` + `Prompt::tool_info`), remove `Annotations` from `runvil-engine` and `runvil`, and bless `public-api.txt`. +- **Commit 4 (pin `runvil-plugin-sys = "0.9.0"` at `P` and switch loader + `test-plugin` to JSON `RvToolInfo`)**: + - Pin `runvil-plugin-sys = "0.9.0"` at `P` in `Cargo.toml`. + - Delete `AddedTool`, `Offered`, and `raw_parameters` in [`crates/harness-internal/plugin-loader/src/pack.rs`](../crates/harness-internal/plugin-loader/src/pack.rs) and `session.rs`, deserializing `RvToolInfo.json` straight into `ToolInfo` (keeping `Vec` alive across `send_render`). + - Update zero-dep [`crates/harness-internal/test-plugin/src/lib.rs`](../crates/harness-internal/test-plugin/src/lib.rs) + `lib-tests.rs` to contract `0.9` (`size == 24`, balanced-brace `object_of` helper for `"shape"`), add a `build-xtask` sync check when sibling repos are present, and update `decisions/tools-and-packs.md` and `decisions/prompt-language.md`. +- Run full pre-push + CI suite (`docs-claims.mjs`, `clippy`, `nextest`, `xtask tidy`, `+nightly-2026-09-05 xtask api`, `dylint`, `deny`), push to `origin`, open PR, and merge to `upstream` -> SHA `H`. + +## Wave 3: `runvil-workshop` and `runvil` (Sequential Final Wave) + +### Wave 3a: `runvil-workshop` (3 Testable Commits -> Merged Upstream SHA `K`) + +- **Commit 1**: Add `plan/2026-12-02-2-unified-tool-info.plan.md`. +- **Commit 2 (pins + broker)**: Update [`runvil-workshop/Cargo.toml`](https://github.com/cppalliance/runvil-workshop/blob/master/Cargo.toml) to pin `runvil-harness` (`H`), `runvil-plugin-sdk` `0.9.0` (`P`), and `std-plugin` (`S`), `bashkit-plugin` (`B`), `web-plugin` (`W`), and switch `WorkshopBroker::chat` in [`runvil-workshop/crates/workshop/server/src/agents/broker.rs`](https://github.com/cppalliance/runvil-workshop/blob/master/crates/workshop/server/src/agents/broker.rs) to `Vec>`. Verify `cargo test` and `xtask tidy`. +- **Commit 3 (`/prompts/contract` + UI)**: Flatten `&**prompt.tool_info()` onto `ContractResponse` in [`runvil-workshop/crates/workshop/server/src/routes/prompts.rs`](https://github.com/cppalliance/runvil-workshop/blob/master/crates/workshop/server/src/routes/prompts.rs) (keeping explicit `null` for absent `runvil` and `max_tool_iterations`), and update `prompts-tests.rs`, [`runvil-workshop/crates/workshop/ui/src/services/run-api.ts`](https://github.com/cppalliance/runvil-workshop/blob/master/crates/workshop/ui/src/services/run-api.ts), `run-rows.ts`, `test/run-api.mjs`, and `test/run-panel.mjs`. +- Verify Rust + UI tests + `xtask tidy`, push to `origin`, open PR, and merge to `upstream` -> SHA `K`. + +### Wave 3b: `runvil` (2 Testable Commits -> Merged Upstream) + +- **Commit 1**: Add `plan/2026-12-02-2-unified-tool-info.plan.md`. +- **Commit 2**: Pin `[workspace.metadata.workshop]` in [`runvil/Cargo.toml`](https://github.com/cppalliance/runvil/blob/master/Cargo.toml) to SHA `K`, verify `xtask`, push to `origin`, open PR, and merge to `upstream`. From 3370508128fcdcdbc543352fcfac9008ccdd7a54 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 2 Dec 2026 14:04:02 -0800 Subject: [PATCH 2/3] Pin contract 0.9 and pass Arc in the broker Move Workshop's pins of the Harness, `runvil-plugin-sdk`, and the three library Plugins to contract 0.9 and unified `ToolInfo`. The root `Cargo.toml` pins each dependency at its merged commit, `Cargo.lock` updates to match, and `InferenceBroker` on `WorkshopBroker` switches `tools` from `Vec` to `Vec>`. - `runvil`, `harness-gateway-client`, and `plugin-mcp` move to `64b085369f9432073f0baa9e40d9cbdbe0a720cd`, and `runvil-plugin-sdk` moves to version `0.9.0` at `4c10a7d4d26c11e6a3055c6f6c4b5657f1bf2faa`. - `std-plugin` moves to `d45fa9e1746ed1afa099dee9392925d819c475d6`, `bashkit-plugin` to `f41b5002ae5a1412b04443236483ea6350197199`, and `web-plugin` to `0f2189478645a9d5ae892a13ab9b6879438ca794`. - The prompt contract route and the Run window client remain unchanged in this commit. Plan: /plan/2026-12-02-2-unified-tool-info.plan.md --- Cargo.lock | 46 +++++++++++---------- Cargo.toml | 16 +++---- crates/workshop/server/src/agents/broker.rs | 8 ++-- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16f45bb9..c08241fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1882,7 +1882,7 @@ dependencies = [ [[package]] name = "gateway-client" version = "0.1.0" -source = "git+https://github.com/cppalliance/gateway-client?rev=b77b3017967b6c4f2690a556a5f14e9d33968be7#b77b3017967b6c4f2690a556a5f14e9d33968be7" +source = "git+https://github.com/cppalliance/gateway-client?rev=a385828ca983eb21c70d09282d24d54dd74b98b5#a385828ca983eb21c70d09282d24d54dd74b98b5" dependencies = [ "bytes", "gateway-types", @@ -1896,7 +1896,7 @@ dependencies = [ [[package]] name = "gateway-types" version = "0.1.0" -source = "git+https://github.com/cppalliance/gateway-client?rev=b77b3017967b6c4f2690a556a5f14e9d33968be7#b77b3017967b6c4f2690a556a5f14e9d33968be7" +source = "git+https://github.com/cppalliance/gateway-client?rev=a385828ca983eb21c70d09282d24d54dd74b98b5#a385828ca983eb21c70d09282d24d54dd74b98b5" dependencies = [ "serde", "serde_json", @@ -2250,7 +2250,7 @@ dependencies = [ [[package]] name = "harness-gateway-client" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "gateway-client", "runvil", @@ -2261,7 +2261,7 @@ dependencies = [ [[package]] name = "harness-plugin-loader" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "libloading 0.8.9", "runvil-plugin", @@ -2272,7 +2272,7 @@ dependencies = [ [[package]] name = "harness-runner" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "futures-util", "gateway-types", @@ -4037,7 +4037,7 @@ dependencies = [ [[package]] name = "plugin-bashkit" version = "0.1.0" -source = "git+https://github.com/cppalliance/runvil-plugin-bashkit?rev=67cc930c47bedace9af648982f72b6e12c77ba08#67cc930c47bedace9af648982f72b6e12c77ba08" +source = "git+https://github.com/cppalliance/runvil-plugin-bashkit?rev=f41b5002ae5a1412b04443236483ea6350197199#f41b5002ae5a1412b04443236483ea6350197199" dependencies = [ "bashkit", "runvil-plugin-sdk", @@ -4049,7 +4049,7 @@ dependencies = [ [[package]] name = "plugin-mcp" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "futures-util", "reqwest", @@ -4063,7 +4063,7 @@ dependencies = [ [[package]] name = "plugin-std" version = "0.1.0" -source = "git+https://github.com/cppalliance/runvil-plugin-std?rev=c3653768df3817a7140059c1de66195e51408b70#c3653768df3817a7140059c1de66195e51408b70" +source = "git+https://github.com/cppalliance/runvil-plugin-std?rev=d45fa9e1746ed1afa099dee9392925d819c475d6#d45fa9e1746ed1afa099dee9392925d819c475d6" dependencies = [ "regex", "runvil-plugin-sdk", @@ -4074,7 +4074,7 @@ dependencies = [ [[package]] name = "plugin-web" version = "0.1.0" -source = "git+https://github.com/cppalliance/runvil-plugin-web?rev=a24f3400022e43f237319db89ec4454063ec859a#a24f3400022e43f237319db89ec4454063ec859a" +source = "git+https://github.com/cppalliance/runvil-plugin-web?rev=0f2189478645a9d5ae892a13ab9b6879438ca794#0f2189478645a9d5ae892a13ab9b6879438ca794" dependencies = [ "encoding_rs", "htmd", @@ -4719,7 +4719,7 @@ dependencies = [ [[package]] name = "runvil" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "harness-plugin-loader", "harness-runner", @@ -4730,7 +4730,7 @@ dependencies = [ [[package]] name = "runvil-engine" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "gateway-types", "runvil-lua", @@ -4743,7 +4743,7 @@ dependencies = [ [[package]] name = "runvil-lua" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "gateway-types", "mlua", @@ -4757,7 +4757,7 @@ dependencies = [ [[package]] name = "runvil-markdown" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "pulldown-cmark", "serde", @@ -4768,7 +4768,7 @@ dependencies = [ [[package]] name = "runvil-plugin" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "runvil-types", "runvil-vfs", @@ -4777,21 +4777,23 @@ dependencies = [ [[package]] name = "runvil-plugin-sdk" -version = "0.8.0" -source = "git+https://github.com/cppalliance/runvil-plugin-api?rev=f2d42cc41b0f28f81ac73193f21c2eacfafc11d9#f2d42cc41b0f28f81ac73193f21c2eacfafc11d9" +version = "0.9.0" +source = "git+https://github.com/cppalliance/runvil-plugin-api?rev=4c10a7d4d26c11e6a3055c6f6c4b5657f1bf2faa#4c10a7d4d26c11e6a3055c6f6c4b5657f1bf2faa" dependencies = [ "runvil-plugin-sys", + "serde", + "serde_json", ] [[package]] name = "runvil-plugin-sys" -version = "0.8.0" -source = "git+https://github.com/cppalliance/runvil-plugin-api?rev=f2d42cc41b0f28f81ac73193f21c2eacfafc11d9#f2d42cc41b0f28f81ac73193f21c2eacfafc11d9" +version = "0.9.0" +source = "git+https://github.com/cppalliance/runvil-plugin-api?rev=4c10a7d4d26c11e6a3055c6f6c4b5657f1bf2faa#4c10a7d4d26c11e6a3055c6f6c4b5657f1bf2faa" [[package]] name = "runvil-prompt" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "pulldown-cmark", "runvil-lua", @@ -4804,7 +4806,7 @@ dependencies = [ [[package]] name = "runvil-runtime" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "gateway-types", "mlua", @@ -4822,7 +4824,7 @@ dependencies = [ [[package]] name = "runvil-types" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" dependencies = [ "gateway-types", "serde", @@ -4833,7 +4835,7 @@ dependencies = [ [[package]] name = "runvil-vfs" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0#faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" +source = "git+https://github.com/cppalliance/runvil-harness?rev=64b085369f9432073f0baa9e40d9cbdbe0a720cd#64b085369f9432073f0baa9e40d9cbdbe0a720cd" [[package]] name = "rust-embed" diff --git a/Cargo.toml b/Cargo.toml index ad3afe35..bc6c4951 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,35 +25,35 @@ repository = "https://github.com/cppalliance/runvil-workshop" # Workshop links in. All three name one commit, because two commits would # be two copies of every type the crates share. `version` beside `git` # keeps cargo-deny's wildcard check quiet. -runvil = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" } -harness-gateway-client = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" } -plugin-mcp = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "faf6d613bb9e76fd422fbaba3e5aba6b67ba58e0" } -# The safe layer over the C Plugin contract, version 0.8, from its own +runvil = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "64b085369f9432073f0baa9e40d9cbdbe0a720cd" } +harness-gateway-client = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "64b085369f9432073f0baa9e40d9cbdbe0a720cd" } +plugin-mcp = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "64b085369f9432073f0baa9e40d9cbdbe0a720cd" } +# The safe layer over the C Plugin contract, version 0.9, from its own # repository, pinned by commit. Only the library Plugin crates under # `crates/workshop/` name it, for `export_plugin!`. The commit is the one # runvil-harness pins the contract's `runvil-plugin-sys` at: that crate # sets `links`, so Cargo refuses two commits of the contract in one build. -runvil-plugin-sdk = { version = "0.8.0", git = "https://github.com/cppalliance/runvil-plugin-api", rev = "f2d42cc41b0f28f81ac73193f21c2eacfafc11d9" } +runvil-plugin-sdk = { version = "0.9.0", git = "https://github.com/cppalliance/runvil-plugin-api", rev = "4c10a7d4d26c11e6a3055c6f6c4b5657f1bf2faa" } # The std Plugin, from its own repository, pinned by commit, which must be # built against the contract commit above. default-features off drops its # own export of `runvil_plugin`, which `workshop-plugin-std` makes instead. # The key is `std-plugin` because that crate's own library is named # `plugin_std`, the name of the file Workshop ships. -std-plugin = { package = "plugin-std", version = "0.1.0", git = "https://github.com/cppalliance/runvil-plugin-std", rev = "c3653768df3817a7140059c1de66195e51408b70", default-features = false } +std-plugin = { package = "plugin-std", version = "0.1.0", git = "https://github.com/cppalliance/runvil-plugin-std", rev = "d45fa9e1746ed1afa099dee9392925d819c475d6", default-features = false } # The bashkit Plugin, from its own repository, pinned by commit and built # against the same contract commit. default-features off drops its own # export of `runvil_plugin`, which `workshop-plugin-bashkit` makes # instead. The key is `bashkit-plugin` for the reason std's is # `std-plugin`: the crate's own library has the name of the file Workshop # ships, `plugin_bashkit`. -bashkit-plugin = { package = "plugin-bashkit", version = "0.1.0", git = "https://github.com/cppalliance/runvil-plugin-bashkit", rev = "67cc930c47bedace9af648982f72b6e12c77ba08", default-features = false } +bashkit-plugin = { package = "plugin-bashkit", version = "0.1.0", git = "https://github.com/cppalliance/runvil-plugin-bashkit", rev = "f41b5002ae5a1412b04443236483ea6350197199", default-features = false } # The web Plugin, from its own repository, pinned by commit and built # against the same contract commit. default-features off drops its own # export of `runvil_plugin`, which `workshop-plugin-web` makes instead. # The key is `web-plugin` for the reason std's is `std-plugin`: the # crate's own library has the name of the file Workshop ships, # `plugin_web`. -web-plugin = { package = "plugin-web", version = "0.1.0", git = "https://github.com/cppalliance/runvil-plugin-web", rev = "a24f3400022e43f237319db89ec4454063ec859a", default-features = false } +web-plugin = { package = "plugin-web", version = "0.1.0", git = "https://github.com/cppalliance/runvil-plugin-web", rev = "0f2189478645a9d5ae892a13ab9b6879438ca794", default-features = false } workshop-gateway-discovery = { path = "crates/workshop/gateway-discovery" } workshop-server = { path = "crates/workshop/server" } workshop-server-api = { path = "crates/workshop/server-api" } diff --git a/crates/workshop/server/src/agents/broker.rs b/crates/workshop/server/src/agents/broker.rs index 177c60d3..5c035a42 100644 --- a/crates/workshop/server/src/agents/broker.rs +++ b/crates/workshop/server/src/agents/broker.rs @@ -23,10 +23,10 @@ use harness_gateway_client::GatewayBroker; use runvil::effect::Round; use runvil::harness::{InferenceBroker, PieceSink}; use runvil::model::{ - Completion, CompletionOptions, Message, ModelBinding, ModelCatalog, ToolSchema, - make_completion_error, phrase, + Completion, CompletionOptions, Message, ModelBinding, ModelCatalog, make_completion_error, + phrase, }; -use runvil::{BoxFuture, Error, ErrorCode}; +use runvil::{BoxFuture, Error, ErrorCode, ToolInfo}; use serde_json::Value; use workshop_menu::MenuHandles; use workshop_registry::Registry; @@ -111,7 +111,7 @@ impl InferenceBroker for WorkshopBroker { &self, binding: ModelBinding, messages: Vec, - tools: Vec, + tools: Vec>, mut options: CompletionOptions, round: Round, on_piece: Option, From 66f01cec981afb3164be29a8c7199cfb71769ea1 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 2 Dec 2026 14:11:44 -0800 Subject: [PATCH 3/3] Flatten ToolInfo onto ContractResponse and RunContract Expose a prompt's callable tool metadata directly in the Run window's contract wire shape. `ContractResponse` flattens `Prompt::tool_info` via `#[serde(flatten)]` in `crates/workshop/server/src/routes/prompts.rs`, and `parseContract` in `crates/workshop/ui/src/services/run-api.ts` narrows `input_schema`, `title`, and the four hint keys onto `RunContract`. - `ContractResponse` replaces `args` with `input_schema` from `ToolInfo`, emits `title`, `read_only_hint`, `destructive_hint`, `idempotent_hint`, and `open_world_hint` only when set, and preserves `null` for absent `runvil` and `max_tool_iterations`. - `parseContract` maps missing or `null` `title` and hint keys to `null` on `RunContract` and rejects non-string or non-boolean values. - `renderContractRows` in `crates/workshop/ui/src/parts/run/run-rows.ts` reads `contract.inputSchema` and renders no rows for `title` or behavior hints. Plan: /plan/2026-12-02-2-unified-tool-info.plan.md --- .../server/src/routes/prompts-tests.rs | 52 ++++++- crates/workshop/server/src/routes/prompts.rs | 42 +++--- crates/workshop/ui/src/parts/run/run-rows.ts | 6 +- crates/workshop/ui/src/services/run-api.ts | 57 ++++++-- crates/workshop/ui/test/run-api.mjs | 130 +++++++++++++----- crates/workshop/ui/test/run-panel.mjs | 9 +- 6 files changed, 216 insertions(+), 80 deletions(-) diff --git a/crates/workshop/server/src/routes/prompts-tests.rs b/crates/workshop/server/src/routes/prompts-tests.rs index f5bea10a..156ca091 100644 --- a/crates/workshop/server/src/routes/prompts-tests.rs +++ b/crates/workshop/server/src/routes/prompts-tests.rs @@ -85,11 +85,11 @@ async fn a_full_frontmatter_prompt_answers_every_contract_section() { { "id": "poop" }, ]) ); - // The declaration is sent as JSON Schema: every object node writes - // `additionalProperties`, and `required` lists the fields a caller - // must send. + // The declaration is sent as JSON Schema under `input_schema`: every + // object node writes `additionalProperties`, and `required` lists the + // fields a caller must send. assert_eq!( - json["args"], + json["input_schema"], serde_json::json!({ "type": "object", "properties": { @@ -147,7 +147,7 @@ async fn a_prompt_without_args_yields_the_default_declaration() { let (status, json) = post_contract(body).await; assert_eq!(status, StatusCode::OK); assert_eq!( - json["args"], + json["input_schema"], serde_json::json!({ "type": "object", "properties": { @@ -208,4 +208,46 @@ async fn the_dto_serializes_absent_declarations_as_nulls() { // Absent declarations serialize as explicit nulls, not missing keys. assert!(json["max_tool_iterations"].is_null()); assert!(json["runvil"].is_null()); + // Optional ToolInfo fields that the prompt leaves out are omitted. + for omitted in [ + "title", + "read_only_hint", + "destructive_hint", + "idempotent_hint", + "open_world_hint", + ] { + assert!( + json.get(omitted).is_none(), + "an unset {omitted} is omitted from the flattened ToolInfo: {json}" + ); + } +} + +#[tokio::test] +async fn title_and_annotations_flatten_onto_the_contract_through_tool_info() { + let text = r"--- +name: annotated +title: Paper Screener +description: screens a submission +annotations: + readOnlyHint: true + destructiveHint: false + idempotentHint: true + openWorldHint: false +--- + +## S + +p +"; + let body = serde_json::json!({ "name": "annotated", "text": text }); + let (status, json) = post_contract(body).await; + assert_eq!(status, StatusCode::OK); + assert_eq!(json["name"], "annotated"); + assert_eq!(json["title"], "Paper Screener"); + assert_eq!(json["description"], "screens a submission"); + assert_eq!(json["read_only_hint"], true); + assert_eq!(json["destructive_hint"], false); + assert_eq!(json["idempotent_hint"], true); + assert_eq!(json["open_world_hint"], false); } diff --git a/crates/workshop/server/src/routes/prompts.rs b/crates/workshop/server/src/routes/prompts.rs index e2d1ec7a..d4761c71 100644 --- a/crates/workshop/server/src/routes/prompts.rs +++ b/crates/workshop/server/src/routes/prompts.rs @@ -3,11 +3,10 @@ //! //! The parse route is pure - no state, no disk, no clock: it turns the //! posted markdown into the contract the Run window renders, or a `422` -//! envelope naming the parse failure kind and line. The parser's own -//! types are `Deserialize`-only, so the wire DTO is hand-written -//! `Serialize` structs built from [`Frontmatter`] accessors. Its `args` -//! field is the JSON Schema that -//! [`ArgsSchema::as_json`](runvil::prompt::ArgsSchema::as_json) gives. +//! envelope naming the parse failure kind and line. The wire DTO +//! flattens [`Prompt::tool_info`] (`name`, `description`, +//! `input_schema`, and any declared `title` or behavior hints) beside +//! the execution declarations read from [`Prompt::frontmatter`]. use std::num::NonZeroU32; @@ -15,12 +14,11 @@ use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; use axum::routing::post; use axum::{Json, Router}; -use runvil::Prompt; use runvil::model::ModelRole; use runvil::packs::{PackId, PackRef}; -use runvil::prompt::{Frontmatter, RoleRequirements}; +use runvil::prompt::RoleRequirements; +use runvil::{Prompt, ToolInfo}; use serde::{Deserialize, Serialize}; -use serde_json::Value; use crate::error::AppError; @@ -41,22 +39,19 @@ struct ContractRequest { } /// The Run-window contract: everything the panel renders, built from -/// the parsed frontmatter. +/// the parsed prompt. #[derive(Debug, Serialize)] struct ContractResponse<'a> { - /// The prompt's identifier. - name: &'a str, - /// The one-line description shown in listings. - description: &'a str, + /// The callable tool metadata built from the prompt's `name`, + /// `title`, `description`, `args`, and `annotations` declarations. + #[serde(flatten)] + tool: &'a ToolInfo, /// The Engine major the `runvil:` key declares; `null` when absent. runvil: Option, /// The declared tool-loop cap; `null` for the runtime default. max_tool_iterations: Option, /// The declared Packs, in declaration order. uses: Vec>, - /// The `args` declaration as JSON Schema. The root is an object node, - /// and its `properties` are the prompt's arguments by name. - args: &'a Value, /// The declared model roles, sorted by label. models: Vec, } @@ -96,15 +91,14 @@ impl ModelDto { } } -impl<'a> From<&'a Frontmatter> for ContractResponse<'a> { - fn from(frontmatter: &'a Frontmatter) -> Self { +impl<'a> From<&'a Prompt> for ContractResponse<'a> { + fn from(prompt: &'a Prompt) -> Self { + let frontmatter = prompt.frontmatter(); Self { - name: frontmatter.name(), - description: frontmatter.description(), + tool: prompt.tool_info().as_ref(), runvil: frontmatter.runvil(), max_tool_iterations: frontmatter.max_tool_iterations().map(NonZeroU32::get), uses: frontmatter.uses().iter().map(PackDto::from).collect(), - args: frontmatter.args().as_json(), models: ModelRole::ALL .into_iter() .filter_map(|role| { @@ -126,11 +120,7 @@ impl<'a> From<&'a Frontmatter> for ContractResponse<'a> { /// prompt that is missing or malformed is not reported here. async fn contract(Json(body): Json) -> Response { match Prompt::parse(&|_: &str| Ok(body.text.clone()), &body.name) { - Ok(prompt) => ( - StatusCode::OK, - Json(ContractResponse::from(prompt.frontmatter())), - ) - .into_response(), + Ok(prompt) => (StatusCode::OK, Json(ContractResponse::from(&prompt))).into_response(), Err(error) => AppError::prompt_parse(&error).into_response(), } } diff --git a/crates/workshop/ui/src/parts/run/run-rows.ts b/crates/workshop/ui/src/parts/run/run-rows.ts index 802a50b4..1c68b6f8 100644 --- a/crates/workshop/ui/src/parts/run/run-rows.ts +++ b/crates/workshop/ui/src/parts/run/run-rows.ts @@ -3,7 +3,7 @@ // key present in the prompt except `uses`, which has nothing to // bind, appears as exactly one row: name, description, and runvil // read-only; one row for each top-level property -// of the `args` schema, its control chosen by the property's type, with +// of `inputSchema`, its control chosen by the property's type, with // the required marker and the default prefilled; model roles // read-only; max_tool_iterations numeric with the runtime-default // placeholder. No bind-time validation runs here - validation is the @@ -158,8 +158,8 @@ export function renderContractRows(container: HTMLElement, contract: RunContract rows.appendChild(row("runvil", [readOnly(String(contract.runvil))])); } - const required = contract.args.required ?? []; - for (const [name, arg] of Object.entries(contract.args.properties ?? {})) { + const required = contract.inputSchema.required ?? []; + for (const [name, arg] of Object.entries(contract.inputSchema.properties ?? {})) { // The description is a visible second line under the label, not a tooltip. rows.appendChild( row(name, [argControl(name, arg)], { diff --git a/crates/workshop/ui/src/services/run-api.ts b/crates/workshop/ui/src/services/run-api.ts index 8dda379a..7c48952a 100644 --- a/crates/workshop/ui/src/services/run-api.ts +++ b/crates/workshop/ui/src/services/run-api.ts @@ -26,8 +26,8 @@ export type RunContractSchemaType = | "object"; /** - * One node of the `args` declaration, a subset of JSON Schema. The root - * is an object node whose properties are the prompt's arguments. + * One node of the `input_schema` declaration, a subset of JSON Schema. The + * root is an object node whose properties are the prompt's arguments. */ export interface RunContractSchema { readonly type: RunContractSchemaType; @@ -60,14 +60,19 @@ export interface RunContractModel { /** The Run-window contract: everything the panel renders. */ export interface RunContract { readonly name: string; + readonly title: string | null; readonly description: string; /** The Engine major the `runvil:` key declares; null when absent. */ readonly runvil: number | null; /** The declared tool-loop cap; null for the runtime default. */ readonly maxToolIterations: number | null; readonly uses: readonly RunContractPack[]; - /** The `args` declaration: an object node. */ - readonly args: RunContractSchema; + /** The prompt's `input_schema` (`args` in frontmatter): an object node. */ + readonly inputSchema: RunContractSchema; + readonly readOnlyHint: boolean | null; + readonly destructiveHint: boolean | null; + readonly idempotentHint: boolean | null; + readonly openWorldHint: boolean | null; readonly models: readonly RunContractModel[]; } @@ -198,14 +203,45 @@ function parseModel(value: unknown): RunContractModel | null { }; } +function isOptionalString(value: unknown): value is string | null | undefined { + return value === undefined || value === null || typeof value === "string"; +} + +function isOptionalBoolean(value: unknown): value is boolean | null | undefined { + return value === undefined || value === null || typeof value === "boolean"; +} + function parseContract(body: unknown): RunContract | null { if (!isRecord(body)) { return null; } - const { name, description, runvil, max_tool_iterations, uses, models } = body; + const { + name, + title, + description, + runvil, + max_tool_iterations, + uses, + read_only_hint, + destructive_hint, + idempotent_hint, + open_world_hint, + models, + } = body; if (typeof name !== "string" || typeof description !== "string") { return null; } + if (!isOptionalString(title)) { + return null; + } + if ( + !isOptionalBoolean(read_only_hint) || + !isOptionalBoolean(destructive_hint) || + !isOptionalBoolean(idempotent_hint) || + !isOptionalBoolean(open_world_hint) + ) { + return null; + } if (runvil !== null && typeof runvil !== "number") { return null; } @@ -224,8 +260,8 @@ function parseContract(body: unknown): RunContract | null { parsedPacks.push(parsed); } // The root of the declaration is an object node. - const args = parseSchema(body.args); - if (args === null || args.type !== "object") { + const inputSchema = parseSchema(body.input_schema); + if (inputSchema === null || inputSchema.type !== "object") { return null; } const parsedModels: RunContractModel[] = []; @@ -238,11 +274,16 @@ function parseContract(body: unknown): RunContract | null { } return { name, + title: title ?? null, description, runvil: runvil ?? null, maxToolIterations: max_tool_iterations ?? null, uses: parsedPacks, - args, + inputSchema, + readOnlyHint: read_only_hint ?? null, + destructiveHint: destructive_hint ?? null, + idempotentHint: idempotent_hint ?? null, + openWorldHint: open_world_hint ?? null, models: parsedModels, }; } diff --git a/crates/workshop/ui/test/run-api.mjs b/crates/workshop/ui/test/run-api.mjs index 11429e62..b5d4820e 100644 --- a/crates/workshop/ui/test/run-api.mjs +++ b/crates/workshop/ui/test/run-api.mjs @@ -35,11 +35,12 @@ function check(name, condition) { // The full-frontmatter contract, as POST /prompts/contract answers it. const CONTRACT = { name: "papergate", + title: "Paper Screener", description: "Screens papers", runvil: 1, max_tool_iterations: 12, uses: [{ id: "tools/web" }], - args: { + input_schema: { type: "object", properties: { deep: { type: "boolean", default: false }, @@ -56,6 +57,10 @@ const CONTRACT = { required: ["topic"], additionalProperties: false, }, + read_only_hint: true, + destructive_hint: false, + idempotent_hint: true, + open_world_hint: false, models: [ { label: "strong", min_context: 32000, thinking: true }, ], @@ -92,36 +97,41 @@ const json = (body, status = 200) => ({ check( "scalars narrow", contract.name === "papergate" && + contract.title === "Paper Screener" && contract.description === "Screens papers" && contract.runvil === 1 && - contract.maxToolIterations === 12, + contract.maxToolIterations === 12 && + contract.readOnlyHint === true && + contract.destructiveHint === false && + contract.idempotentHint === true && + contract.openWorldHint === false, ); check( "uses narrow", contract.uses.length === 1 && contract.uses[0].id === "tools/web", ); check("a contract without tools narrows with no tools section", !("tools" in contract)); - const { args } = contract; + const { inputSchema } = contract; check( - "the args root narrows as an object node with its required list", - args.type === "object" && - args.additionalProperties === false && - args.required?.join(",") === "topic", + "the inputSchema root narrows as an object node with its required list", + inputSchema.type === "object" && + inputSchema.additionalProperties === false && + inputSchema.required?.join(",") === "topic", ); // The Run window draws one row per property, top to bottom, so the // narrowed properties must keep the order the server sends them. check( "the properties keep the order the server sends them", - Object.keys(args.properties ?? {}).join(",") === "deep,focus,limit,opts,tone,topic", + Object.keys(inputSchema.properties ?? {}).join(",") === "deep,focus,limit,opts,tone,topic", ); check( "a property narrows with its type and default", - args.properties.topic.type === "string" && - args.properties.topic.default === undefined && - args.properties.deep.type === "boolean" && - args.properties.deep.default === false && - args.properties.limit.type === "integer" && - args.properties.limit.default === 5, + inputSchema.properties.topic.type === "string" && + inputSchema.properties.topic.default === undefined && + inputSchema.properties.deep.type === "boolean" && + inputSchema.properties.deep.default === false && + inputSchema.properties.limit.type === "integer" && + inputSchema.properties.limit.default === 5, ); // The Run window shows a described arg's text as a second line under its // label and draws no line for an undescribed one, so the narrowed @@ -129,28 +139,28 @@ const json = (body, status = 200) => ({ // gives none. check( "an arg's description narrows to its text, or to nothing when the prompt gives none", - args.properties.topic.description === "the topic" && - args.properties.deep.description === undefined && - args.properties.limit.description === undefined, + inputSchema.properties.topic.description === "the topic" && + inputSchema.properties.deep.description === undefined && + inputSchema.properties.limit.description === undefined, ); check( "an enum narrows to its allowed values, strings or integers", - args.properties.tone.enum?.join(",") === "formal,casual" && - args.properties.opts.properties.depth.enum?.join(",") === "1,2" && - args.properties.opts.properties.depth.enum?.[0] === 1, + inputSchema.properties.tone.enum?.join(",") === "formal,casual" && + inputSchema.properties.opts.properties.depth.enum?.join(",") === "1,2" && + inputSchema.properties.opts.properties.depth.enum?.[0] === 1, ); check( "an array node narrows its items and keeps its default", - args.properties.focus.type === "array" && - args.properties.focus.items?.type === "string" && - JSON.stringify(args.properties.focus.default) === '["methods"]', + inputSchema.properties.focus.type === "array" && + inputSchema.properties.focus.items?.type === "string" && + JSON.stringify(inputSchema.properties.focus.default) === '["methods"]', ); check( "a nested object node narrows its own properties", - args.properties.opts.type === "object" && - args.properties.opts.additionalProperties === true && - args.properties.opts.required === undefined && - args.properties.opts.properties.depth.type === "integer", + inputSchema.properties.opts.type === "object" && + inputSchema.properties.opts.additionalProperties === true && + inputSchema.properties.opts.required === undefined && + inputSchema.properties.opts.properties.depth.type === "integer", ); check( "model roles narrow", @@ -171,7 +181,7 @@ const json = (body, status = 200) => ({ runvil: null, max_tool_iterations: null, uses: [], - args: { + input_schema: { type: "object", properties: { text: { type: "string", description: "Freeform text for this prompt" }, @@ -184,14 +194,62 @@ const json = (body, status = 200) => ({ const contract = await fetchPromptContract("bare.md", "text"); check( "absent sections narrow to null", - contract.runvil === null && contract.maxToolIterations === null, + contract.title === null && + contract.runvil === null && + contract.maxToolIterations === null && + contract.readOnlyHint === null && + contract.destructiveHint === null && + contract.idempotentHint === null && + contract.openWorldHint === null, ); check( "the default declaration narrows to one optional string named text", - Object.keys(contract.args.properties ?? {}).join(",") === "text" && - contract.args.properties.text.type === "string" && - contract.args.properties.text.description === "Freeform text for this prompt" && - contract.args.required === undefined, + Object.keys(contract.inputSchema.properties ?? {}).join(",") === "text" && + contract.inputSchema.properties.text.type === "string" && + contract.inputSchema.properties.text.description === "Freeform text for this prompt" && + contract.inputSchema.required === undefined, + ); +} + +{ + scriptFetch(() => + json({ + ...CONTRACT, + title: null, + read_only_hint: null, + destructive_hint: null, + idempotent_hint: null, + open_world_hint: null, + }), + ); + const contract = await fetchPromptContract("null-hints.md", "text"); + check( + "explicit null title and hints narrow to null", + contract.title === null && + contract.readOnlyHint === null && + contract.destructiveHint === null && + contract.idempotentHint === null && + contract.openWorldHint === null, + ); +} + +for (const [field, bad] of [ + ["title", 42], + ["read_only_hint", "yes"], + ["destructive_hint", 1], + ["idempotent_hint", {}], + ["open_world_hint", []], +]) { + scriptFetch(() => json({ ...CONTRACT, [field]: bad })); + let caught = null; + try { + await fetchPromptContract("p.md", "text"); + } catch (error) { + caught = error; + } + check( + `an invalid ${field} type is a shape failure`, + caught !== null && caught.code === "unexpected_shape", ); } @@ -239,7 +297,7 @@ const json = (body, status = 200) => ({ scriptFetch(() => json({ ...CONTRACT, - args: { + input_schema: { type: "object", properties: { when: { type: "date" } }, additionalProperties: false, @@ -262,7 +320,7 @@ const json = (body, status = 200) => ({ scriptFetch(() => json({ ...CONTRACT, - args: { + input_schema: { type: "object", properties: { tags: { type: "array", items: { type: "date" } } }, additionalProperties: false, @@ -282,7 +340,7 @@ const json = (body, status = 200) => ({ } { - scriptFetch(() => json({ ...CONTRACT, args: { type: "string" } })); + scriptFetch(() => json({ ...CONTRACT, input_schema: { type: "string" } })); let caught = null; try { await fetchPromptContract("p.md", "text"); diff --git a/crates/workshop/ui/test/run-panel.mjs b/crates/workshop/ui/test/run-panel.mjs index 91bcc491..26f98b20 100644 --- a/crates/workshop/ui/test/run-panel.mjs +++ b/crates/workshop/ui/test/run-panel.mjs @@ -128,7 +128,7 @@ function contractFor(name) { runvil: 1, max_tool_iterations: 12, uses: [{ id: "tools/web" }], - args: { + input_schema: { type: "object", properties: { deep: { type: "boolean", default: false }, @@ -509,11 +509,16 @@ check("the Run button does nothing when clicked", calls.length === fetchesBefore const noArgsRows = window.document.createElement("div"); renderContractRows(noArgsRows, { name: "noargs", + title: null, description: "", runvil: null, maxToolIterations: null, uses: [], - args: { type: "object", properties: {}, additionalProperties: false }, + inputSchema: { type: "object", properties: {}, additionalProperties: false }, + readOnlyHint: null, + destructiveHint: null, + idempotentHint: null, + openWorldHint: null, models: [], }); check(