Unify tool registry on a single ToolDef shape (#85, step 1) - #102
Merged
Conversation
Step 1 of the connector/tool-registry foundation (#85, epic #84): the load-bearing, land-alone refactor that unifies the registry's tool shape with NO behaviour change. Does NOT migrate the 97 legacy MCP tools or the connectorClient — those are later steps. - lib/tool-registry.ts: one `ToolDef { name, description, jsonSchema (draft-07 object schema), tier, connector?, scope?, handler }` replaces the ad-hoc `RegistryTool` (kept as a deprecated alias). `registryToolDefs()` now passes each tool's `jsonSchema` through instead of exposing a `parameters` map. Consent gate + catalog grouping guard the now-optional connector field (fail-closed for write tools without a connector). - lib/connectors/{github,meta,tmux}.ts: migrated each tool's `parameters` map to an equivalent `jsonSchema` and set `tier: "connector"`. - agent-do-tools.ts: buildAgentToolDefinitions is back-compatible — legacy AGENT_TOOLS/STORAGE_TOOLS still rebuild their JSON Schema from the ad-hoc map; registry tools pass their `jsonSchema` through verbatim. The LLM sees the identical {type,properties,required} object as before. - routes/tools.ts: GET …/tools emits `jsonSchema` verbatim; POST …/tools/:name validates the body against the tool's `jsonSchema` (minimal, dependency-free required-fields + basic-type check, no ajv) before dispatch. - lib/admin.ts + routes/admin.ts: tolerate the now-optional connector/scope. - Tests: jsonSchema pass-through (registry + agent-do-tools + GET route) and POST body validation (missing required, wrong type, valid → handler). executeTool/executeStorageTool and the MCP tools are untouched; allowlist semantics (toolNamesFor + execution-time re-check) are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #85 (step 1 of the connector/tool-registry foundation, epic #84 / no-code pipelines #94).
Load-bearing, land-alone, no behaviour change. Unifies the registry on one
ToolDef {name, description, jsonSchema, tier, connector?, scope?, handler}— the single shape #95/#96/#97 will derive from. Does not migrate the 97 legacy tools or connectorClient (later steps); old + new run side-by-side.Changes
lib/tool-registry.ts— newToolDef+JsonSchema;registryToolDefs()passesjsonSchemathrough;connector/scopenow optional;RegistryToolkept as deprecated alias.lib/connectors/{github,meta,tmux}.ts— each tool's ad-hocparametersmap →jsonSchema(1:1),tier:"connector".agent-do-tools.ts—buildAgentToolDefinitionshandles both def shapes → LLM sees identical tool definitions.routes/tools.ts—GET …/toolsemitsjsonSchema;POST …/tools/:namevalidates body against it (minimal, no-dep validator).admin.ts/routes/admin.ts— tolerate optional connector/scope.Back-compat
Converted
parameters→{type:"object",properties,required}byte-for-byte with whatbuildAgentToolDefinitionsused to rebuild.executeTool/executeStorageTool+ the 97 MCP tools untouched;toolNamesFor+ execution-time allowlist unchanged; consent gate fail-closed.Verify
tsc --noEmitclean · 729 api tests pass (67 files) · biome exit 0🤖 Generated with Claude Code