Repository navigation
feat(sandbox): materialize org tool catalog into the workspace - #4445
Merged
Merged
Conversation
Adds a daemon capability to write a JSON Schema tool catalog under <repo>/.deco/tools/ so a sandboxed agent can discover and script against org/user tools from disk (pairs with the @decocms/typegen CLI/client). - tools-catalog.ts: fetch tools from the run's Virtual MCP endpoint via the MCP SDK and emit one raw JSON Schema file per tool (no TS codegen, so no prettier/json-schema-to-typescript in the daemon bundle) - route POST /_sandbox/tools/sync (token-gated) for on-demand sync - dispatch auto-fires the sync (fire-and-forget) from the per-run mcp endpoint it already receives, so every run populates the catalog - unit tests (pure file emission) + black-box e2e (stub MCP over HTTP, spawned daemon writes the catalog into the workspace)
pedrofrxncx
force-pushed
the
feat/sandbox-typegen
branch
from
July 11, 2026 00:33
ee2ab62 to
4fccfd9
Compare
- prune stale *.json on each sync so renamed/removed tools don't linger - follow the MCP pagination cursor so large orgs aren't truncated - collision-safe filenames so distinct tools can't clobber each other - exclude /.deco/tools/ via .git/info/exclude so shutdown git add -A won't commit the catalog (extracted shared ensureGitExclude, reused by repo-link) - coalesce + min-interval the dispatch auto-sync (no per-run re-list/write race) - split fetch/write so upstream failures are 502 and local write failures 500
Adds a black-box daemon e2e that proves the whole point of the catalog: a coding agent handed "archive all my emails" discovers which org tools to script against straight from disk, via the same glob/grep/bash routes its shell uses. Extends the stub MCP with LIST_EMAILS/ARCHIVE_EMAIL and asserts glob enumerates the catalog, POSIX grep narrows to the email tools (LIST_CUSTOMERS excluded), and ARCHIVE_EMAIL's inputSchema exposes the emailId contract.
decocms Bot
pushed a commit
that referenced
this pull request
Jul 11, 2026
PR: #4445 feat(sandbox): materialize org tool catalog into the workspace Bump type: minor - @decocms/sandbox (packages/sandbox/package.json): 1.13.1 -> 1.14.0 Deploy-Scope: both
4 tasks done
tlgimenes
pushed a commit
that referenced
this pull request
Jul 16, 2026
…TS.md (#4475) Mined ~300 merged PRs for the delta between the first PR proposal and the work added before merge. The dominant shape: a first draft ships the happy path, then a hardening pass (often a different engineer who takes over the branch and merges — the vibecoder→engineer handoff) adds the same categories every time. Encoded those 9 categories as an actionable first-pass checklist, each citing a real PR (#4008, #4230, #4365, #4409, #4426, #4445, #4357, #4355, #4449, #4350, #4373, #4416, #4446, #4461, #4134, #4469). Covers: variant/edge-case handling, tenant/permission scoping, concurrency & silent-data-loss, test-per-fix + invert-bug-tests + real-PG, dead-code/knip, lifecycle symmetry + state reset, kill-switch/GC/git-exclude for risky infra, input validation vs over-engineering, compile-time type-safety. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.
Summary
Lets a sandboxed coding agent discover and script against org/user tools from the filesystem. The daemon writes a JSON Schema tool catalog under
<repo>/.deco/tools/— one file per tool ({ name, description, inputSchema, outputSchema }) — sourced from the run's Virtual MCP endpoint the daemon already receives. Pairs with the@decocms/typegenCLI/client (an agent can read the catalog, or run typegen for a typed client).How it works
tools-catalog.ts— connects to the run's Virtual MCP endpoint via the MCP SDK, lists tools, and emits one raw JSON Schema file per tool. Deliberately no TypeScript codegen, so it pulls no prettier / json-schema-to-typescript into the daemon bundle. The MCP SDK is already in the bundle (via@decocms/harness), so bundle size is unchanged (3.20 MB before and after).POST /_sandbox/tools/sync(token-gated) — body{ url, headers }; syncs the catalog on demand. Returns{ count, tools }.mcpendpoint; it now fires the sync fire-and-forget (non-blocking, errors logged) so every run populates the catalog without a separate caller. Wired via an optionalonDispatchMcpdep, keepingdispatch.tsdecoupled from the fs.Why this shape
mcpreaches only the in-process harness / dispatch path, not the dev-server/exec env — so dispatch is the correct seam, notbuildDevEnv.@decocms/typegen.Testing
bun test):toolCatalogFiles— one file per tool, optional fields omitted, filename sanitization (slashes →_, dots kept,safePathclamps regardless).daemon.tools.e2e.test.ts, black-box): stands up a stub Virtual MCP over HTTP, points the spawned daemon at it, and asserts the catalog files land in the workspace with correct content; plus 400 (malformed body), 502 (unreachable endpoint), 401 (missing token).bun testfor the daemon suite: tools 7 pass, dispatch e2e 8 pass, core daemon e2e 103 pass.bun run check,bun run fmt,bun run lint(no new warnings) clean.Follow-ups (not here)
STUDIO_*env into the agent's shell sodeco call/ the generated client run flagless (needs thex-org-idheader story sorted for the typegen CLI).Summary by cubic
Materializes org/user tools into the sandbox workspace as a JSON Schema catalog under .deco/tools so agents can discover and script tools from disk. Auto-syncs on each run from the Virtual MCP and exposes a token-gated endpoint for on-demand sync.
New Features
{ type: "object" }), outputSchema? }; filenames are sanitized.POST /_sandbox/tools/sync(body{ url, headers }) to fetch via MCP; returns{ count, tools }and surfaces 400/401/502/500 errors.@modelcontextprotocol/sdkto list tools; keeps output as raw JSON Schema (no TS codegen), pairs with@decocms/typegenif a typed client is needed.ARCHIVE_EMAILinput).Bug Fixes
*.jsonon each sync and paginates via the MCP cursor so large orgs aren’t truncated.-2,-3, etc. suffix./.deco/tools/via.git/info/excludeso shutdowngit add -Anever commits the catalog.Written for commit 5d1c8e2. Summary will update on new commits.