Skip to content

Unify tool registry on a single ToolDef shape (#85, step 1) - #102

Merged
serge-ivo merged 1 commit into
mainfrom
feat/85-unify-tooldef
Aug 1, 2026
Merged

Unify tool registry on a single ToolDef shape (#85, step 1)#102
serge-ivo merged 1 commit into
mainfrom
feat/85-unify-tooldef

Conversation

@serge-ivo

Copy link
Copy Markdown
Contributor

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 — new ToolDef + JsonSchema; registryToolDefs() passes jsonSchema through; connector/scope now optional; RegistryTool kept as deprecated alias.
  • lib/connectors/{github,meta,tmux}.ts — each tool's ad-hoc parameters map → jsonSchema (1:1), tier:"connector".
  • agent-do-tools.tsbuildAgentToolDefinitions handles both def shapes → LLM sees identical tool definitions.
  • routes/tools.tsGET …/tools emits jsonSchema; POST …/tools/:name validates 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 what buildAgentToolDefinitions used to rebuild. executeTool/executeStorageTool + the 97 MCP tools untouched; toolNamesFor + execution-time allowlist unchanged; consent gate fail-closed.

Verify

  • tsc --noEmit clean · 729 api tests pass (67 files) · biome exit 0
  • New tests: jsonSchema pass-through (registry + LLM-facing def + GET) and POST body validation (missing required→400, wrong type→400, valid→handler).

🤖 Generated with Claude Code

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>
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.

2 participants