feat: add per-session sandbox workspace for microservice mode - #49
Merged
Conversation
Expose a `sandbox` global inside codemode in microservice (server) mode: an in-memory shell + virtual filesystem (just-bash, core shell only — jq/awk/grep/sed/sort/sqlite; no network, no host FS) for wrangling data fetched from the API. Mirrors Flue's SandboxApi plus an mc8yp-only clear(). - Server-only: one sandbox per MCP session (keyed by ctx.sessionId); files persist across codemode calls. CLI does not expose it — local harnesses bring their own file I/O. - Eviction: 15-min idle TTL (reset on use) plus clean-close on client DELETE via an InfoSessionManager wrapper. In-memory only, never touches disk. - Swappable adapter seam (SandboxAdapter = Flue shape); just-bash is the first backend, kept external in the bundle (lazy WASM optional runtimes). - Discovery: appears in codemode.describe() as a peer surface; a purpose note in the tool description + prompt frames it as the workspace for saving files and processing data. - Bump @iso4/sandbox to 0.3.1 (fixes Uint8Array sandbox->host; Date is now rejected by the wire codec, so stat().mtime is exposed as epoch ms). Tests: adapter unit tests, per-session store (TTL / reset-on-use / isolation / clean-close), and execute integration (present/absent/persist/clear/describe).
schplitt
force-pushed
the
feat/sandbox-namespace
branch
from
July 23, 2026 06:51
c67d543 to
b5af46a
Compare
Both were dead weight from the interfaces work — neither is imported anywhere in src, tests, config, or scripts. Removing the devDependency and the dangling catalog entries.
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
Adds a
sandboxglobal insidecodemodefor microservice (server) mode: an in-memory shell + virtual filesystem for wrangling data fetched from the Cumulocity API. It mirrors Flue'sSandboxApiplus an mc8yp-onlyclear(), and is backed by a swappable adapter (first backend:just-bash, core shell only —jq/awk/grep/sed/sort/sqlite3; no network, no host filesystem — it never reaches Cumulocity).Built on top of the codemode-namespaces work (already merged via #47); this PR is only the sandbox diff.
Behaviour
ctx.sessionId, so files persist acrosscodemodecalls within a session. CLI mode does not expose it — local agent harnesses bring their own file I/O.unref'd timer) — the guarantee.DELETE /mcp→ transportinfo.delete(id)→ sandbox dropped immediately, via anInfoSessionManagerwrapper wired insrc/index.ts.codemode.describe()anddescribe("sandbox")returns its typed interface; a purpose note in the tool description +code-mode-guideprompt frames it as the workspace for saving files / processing data.SandboxAdapteris kept identical to Flue'sSandboxApi;clear()and lifecycle live one layer up, so the backend can be replaced without touching agent-facing code.Notable details
@iso4/sandboxto 0.3.1 (fixesUint8Arraysandbox→host transfer).Dateis now rejected by the wire codec, sostat().mtimeis exposed as epoch milliseconds.just-bash(+@tmcp/session-manager) added as deps and kept external in the bundle (just-bash lazy-loads WASM runtimes for its optional commands);session-eviction.tsis imported only by the server entrypoint, so@tmcp/session-managernever enters the CLI bundle.just-bashruns withcwd: '/'so relative paths resolve identically in the fs methods and the shell.Tests
test/sandbox-adapter.test.ts— adapter (fs round-trip, shell pipelines, jq, fs↔shell path alignment, isolation) + per-session store (15-min eviction, timer reset-on-use, per-session eviction, clean-closeDELETEhook).test/excute.test.ts— real-sandbox integration: absent in CLI, absent server-without-session, present in server, persistence across calls, session isolation,clear(), binary round-trip,mtimeas number,describegating.Validation:
pnpm test:run(all pass),pnpm lint(0 errors),pnpm typecheck(clean),pnpm build(all variants).Docs:
AGENTS.mdandREADME.mdupdated.