Skip to content

Commit bb3b2a0

Browse files
authored
refactor: merge protocol into @execbox/core/protocol (#20)
1 parent e23449d commit bb3b2a0

55 files changed

Lines changed: 412 additions & 402 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/modern-bears-dance.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@execbox/core": minor
3+
"@execbox/quickjs": minor
4+
"@execbox/remote": minor
5+
---
6+
7+
Move the standalone protocol helpers into the new `@execbox/core/protocol` entrypoint and remove the separate `@execbox/protocol` package. Transport-backed integrations should now import protocol messages, host-session helpers, and resource-pool utilities from `@execbox/core/protocol`.

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- `execbox` is a Node.js 22+ npm workspace that publishes the `@execbox/*` package family.
66
- Core source lives under `packages/*/src`, tests live under `packages/*/__tests__`, runnable examples live under `examples/`, and the public docs site lives under `docs/`.
7-
- The workspace currently contains `@execbox/core`, `@execbox/protocol`, `@execbox/quickjs`, `@execbox/remote`, and `@execbox/isolated-vm`.
7+
- The workspace currently contains `@execbox/core`, `@execbox/quickjs`, `@execbox/remote`, and `@execbox/isolated-vm`.
88
- Keep changes aligned with existing package boundaries. Prefer changing the owning package instead of introducing cross-package shortcuts.
99

1010
## Setup Commands
@@ -32,7 +32,7 @@
3232

3333
- For most code changes, run `npm run format:check`, `npm run lint`, `npm run typecheck`, `npm test`, and `npm run build`.
3434
- If you change package exports, manifest fields, or published type-resolution behavior, also run `npm run package:check`.
35-
- If you change the public API of `@execbox/core`, `@execbox/core/mcp`, `@execbox/protocol`, `@execbox/quickjs`, `@execbox/quickjs/runner`, `@execbox/quickjs/runner/protocol-endpoint`, `@execbox/remote`, `@execbox/isolated-vm`, or `@execbox/isolated-vm/runner`, also run `npm run api:check`.
35+
- If you change the public API of `@execbox/core`, `@execbox/core/mcp`, `@execbox/core/protocol`, `@execbox/quickjs`, `@execbox/quickjs/runner`, `@execbox/quickjs/runner/protocol-endpoint`, `@execbox/remote`, `@execbox/isolated-vm`, or `@execbox/isolated-vm/runner`, also run `npm run api:check`.
3636
- If you change docs site content, navigation, or VitePress config, also run `npm run docs:build`.
3737
- If you touch execution boundaries, timeout handling, abort propagation, schema validation, or log/memory controls, also run `npm run test:security`.
3838
- If you touch `@execbox/isolated-vm` or codepaths guarded by `VITEST_INCLUDE_ISOLATED_VM`, run `npm run test:isolated-vm` or `npm run verify:isolated-vm`.
@@ -48,7 +48,7 @@
4848
- Use Conventional Commits for git commit messages, for example `docs: add agent and contributor guides` or `fix(worker): handle timeout classification`.
4949
- Published package releases are managed with Changesets and GitHub Actions.
5050
- Add a `.changeset/*.md` entry when a change affects published package behavior, public APIs, or release notes for one or more `@execbox/*` packages.
51-
- If you intentionally change a checked-in API report for `@execbox/core`, `@execbox/core/mcp`, `@execbox/protocol`, `@execbox/quickjs`, `@execbox/quickjs/runner`, `@execbox/quickjs/runner/protocol-endpoint`, `@execbox/remote`, `@execbox/isolated-vm`, or `@execbox/isolated-vm/runner`, update it with `npm run api:update` in the same change as the code and changeset.
51+
- If you intentionally change a checked-in API report for `@execbox/core`, `@execbox/core/mcp`, `@execbox/core/protocol`, `@execbox/quickjs`, `@execbox/quickjs/runner`, `@execbox/quickjs/runner/protocol-endpoint`, `@execbox/remote`, `@execbox/isolated-vm`, or `@execbox/isolated-vm/runner`, update it with `npm run api:update` in the same change as the code and changeset.
5252
- Skip a changeset for docs-only, examples-only, CI-only, or internal maintenance changes that do not affect published package behavior.
5353

5454
## Useful References

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This guide is for both humans and coding agents. Agent-specific operating instru
2727

2828
Choose the smallest verification set that covers your change, and include the commands you ran in your PR or handoff notes when the context would help reviewers.
2929

30-
- Public API changes to `@execbox/core`, `@execbox/core/mcp`, `@execbox/protocol`, `@execbox/quickjs`, `@execbox/quickjs/runner`, `@execbox/quickjs/runner/protocol-endpoint`, `@execbox/remote`, `@execbox/isolated-vm`, or `@execbox/isolated-vm/runner`: run `npm run api:check`
30+
- Public API changes to `@execbox/core`, `@execbox/core/mcp`, `@execbox/core/protocol`, `@execbox/quickjs`, `@execbox/quickjs/runner`, `@execbox/quickjs/runner/protocol-endpoint`, `@execbox/remote`, `@execbox/isolated-vm`, or `@execbox/isolated-vm/runner`: run `npm run api:check`
3131

3232
## Changesets
3333

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ Portable code execution for [Model Context Protocol](https://modelcontextprotoco
66

77
[![License](https://img.shields.io/github/license/aallam/execbox?style=flat-square)](https://github.com/aallam/execbox/blob/main/LICENSE)
88
[![Docs](https://img.shields.io/badge/docs-site-0ea5e9?style=flat-square)](https://execbox.aallam.com)
9-
[![Packages](https://img.shields.io/badge/packages-5-111827?style=flat-square)](#package-map)
9+
[![Packages](https://img.shields.io/badge/packages-4-111827?style=flat-square)](#package-map)
1010

1111
</div>
1212

1313
Execbox turns host tool catalogs into callable guest namespaces, supports MCP wrapping on both sides of the boundary, and lets you place guest JavaScript where it fits your deployment: inline, behind a worker or child-process host, or across your own remote transport.
1414

1515
## Package Map
1616

17-
| Package | npm | What it is for |
18-
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
19-
| [`@execbox/core`](./packages/core/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fcore?style=flat-square)](https://www.npmjs.com/package/@execbox/core) | Core execution contract, provider resolution, and MCP adapters |
20-
| [`@execbox/protocol`](./packages/protocol/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fprotocol?style=flat-square)](https://www.npmjs.com/package/@execbox/protocol) | Low-level transport messages, sessions, and resource pools |
21-
| [`@execbox/quickjs`](./packages/quickjs/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fquickjs?style=flat-square)](https://www.npmjs.com/package/@execbox/quickjs) | QuickJS executor for inline, worker, and process hosts |
22-
| [`@execbox/remote`](./packages/remote/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fremote?style=flat-square)](https://www.npmjs.com/package/@execbox/remote) | Transport-backed remote executor |
23-
| [`@execbox/isolated-vm`](./packages/isolated-vm/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fisolated-vm?style=flat-square)](https://www.npmjs.com/package/@execbox/isolated-vm) | `isolated-vm` backend for execbox |
17+
| Package | npm | What it is for |
18+
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
19+
| [`@execbox/core`](./packages/core/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fcore?style=flat-square)](https://www.npmjs.com/package/@execbox/core) | Core execution contract, provider resolution, MCP adapters, and the `@execbox/core/protocol` transport subpath |
20+
| [`@execbox/quickjs`](./packages/quickjs/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fquickjs?style=flat-square)](https://www.npmjs.com/package/@execbox/quickjs) | QuickJS executor for inline, worker, and process hosts |
21+
| [`@execbox/remote`](./packages/remote/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fremote?style=flat-square)](https://www.npmjs.com/package/@execbox/remote) | Transport-backed remote executor |
22+
| [`@execbox/isolated-vm`](./packages/isolated-vm/) | [![npm](https://img.shields.io/npm/v/%40execbox%2Fisolated-vm?style=flat-square)](https://www.npmjs.com/package/@execbox/isolated-vm) | `isolated-vm` backend for execbox |
2423

2524
## Examples
2625

docs/architecture/README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This doc set is for two audiences:
1212
- Start here for the package map, trust model, and overall flow.
1313
- Read [execbox-core.md](./execbox-core.md) for provider resolution, execution contracts, and error handling.
1414
- Read [execbox-executors.md](./execbox-executors.md) for QuickJS host modes, remote execution, and `isolated-vm` trade-offs.
15-
- Read [execbox-mcp-and-protocol.md](./execbox-mcp-and-protocol.md) for MCP wrapping and where `execbox-protocol` fits.
15+
- Read [execbox-mcp-and-protocol.md](./execbox-mcp-and-protocol.md) for MCP wrapping and where `@execbox/core/protocol` fits.
1616
- Read [execbox-remote-workflow.md](./execbox-remote-workflow.md) for the end-to-end remote execution control flow.
1717
- Read [execbox-protocol-reference.md](./execbox-protocol-reference.md) for the protocol message catalog and session rules.
1818
- Read [execbox-runner-specification.md](./execbox-runner-specification.md) for the normative runner specification for non-TypeScript runners.
@@ -26,7 +26,7 @@ flowchart LR
2626
QJS["@execbox/quickjs<br/>QuickJS executor + reusable runner"]
2727
REM["@execbox/remote<br/>transport-backed remote executor"]
2828
IVM["@execbox/isolated-vm<br/>in-process isolated-vm executor + reusable runner"]
29-
PROTO["@execbox/protocol<br/>transport messages + shared host session"]
29+
PROTO["@execbox/core/protocol<br/>transport messages + shared host session"]
3030
MCP["MCP sources and wrapped servers"]
3131
3232
APP --> CORE
@@ -40,13 +40,12 @@ flowchart LR
4040

4141
### Package Roles
4242

43-
| Package | Role |
44-
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
45-
| `@execbox/core` | Core types, provider resolution, shared runner semantics, and MCP adapters |
46-
| `@execbox/quickjs` | Default QuickJS executor package with inline, worker-hosted, and process-hosted modes plus a reusable runner |
47-
| `@execbox/remote` | Transport-backed executor that reuses the QuickJS protocol endpoint across an app-defined boundary |
48-
| `@execbox/isolated-vm` | Alternate executor backend using a fresh `isolated-vm` context and a reusable isolated-vm runner |
49-
| `@execbox/protocol` | Transport-safe execution messages, shared host sessions, and reusable resource pools for hosted QuickJS and remote execution |
43+
| Package | Role |
44+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------- |
45+
| `@execbox/core` | Core types, provider resolution, shared runner semantics, MCP adapters, and the `@execbox/core/protocol` transport subpath |
46+
| `@execbox/quickjs` | Default QuickJS executor package with inline, worker-hosted, and process-hosted modes plus a reusable runner |
47+
| `@execbox/remote` | Transport-backed executor that reuses the QuickJS protocol endpoint across an app-defined boundary |
48+
| `@execbox/isolated-vm` | Alternate executor backend using a fresh `isolated-vm` context and a reusable isolated-vm runner |
5049

5150
## End-to-End Execution Model
5251

@@ -101,4 +100,4 @@ Key implications:
101100

102101
## Architecture In One Paragraph
103102

104-
`@execbox/core` owns the stable execution contract, provider resolution, shared runner semantics, and MCP adapters. `@execbox/quickjs` and `@execbox/isolated-vm` each expose a runtime-specific reusable runner. Hosted `@execbox/quickjs` modes and `@execbox/remote` sit on top of `@execbox/protocol`, which owns the transport boundary: message shapes, shared host sessions, and reusable resource pools for transport-backed execution.
103+
`@execbox/core` owns the stable execution contract, provider resolution, shared runner semantics, MCP adapters, and the `@execbox/core/protocol` transport surface. `@execbox/quickjs` and `@execbox/isolated-vm` each expose a runtime-specific reusable runner. Hosted `@execbox/quickjs` modes and `@execbox/remote` sit on top of `@execbox/core/protocol`, which owns the transport boundary: message shapes, shared host sessions, and reusable resource pools for transport-backed execution.

docs/architecture/execbox-core.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ This seam is what lets execbox share semantics across:
106106

107107
- the in-process QuickJS executor
108108
- the in-process `isolated-vm` executor
109-
- transport-backed executors that reuse the same manifest and dispatcher model through `@execbox/protocol`
109+
- transport-backed executors that reuse the same manifest and dispatcher model through `@execbox/core/protocol`
110110

111111
without forcing every runtime through the same transport implementation.
112112

@@ -199,7 +199,7 @@ The core package does not own QuickJS, `isolated-vm`, worker threads, or transpo
199199
The consequence is deliberate separation between:
200200

201201
- core execution and runner semantics in `@execbox/core`
202-
- transport/session mechanics in `@execbox/protocol`
202+
- transport/session mechanics in `@execbox/core/protocol`
203203
- runtime-specific bridge code in executor packages
204204

205205
That split keeps the public contract stable without forcing every backend through identical plumbing.

docs/architecture/execbox-executors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ flowchart LR
2626
IVMRT["isolated-vm context"]
2727
THREAD["Worker thread"]
2828
RUNNER["core runner semantics"]
29-
PROTO["execbox-protocol<br/>messages + host session"]
29+
PROTO["@execbox/core/protocol<br/>messages + host session"]
3030
WQJSRT["QuickJS runtime in worker"]
3131
PQJSRT["QuickJS runtime in child process"]
3232
@@ -143,7 +143,7 @@ Every `execute()` call still creates a fresh QuickJS runtime/context, reinjects
143143

144144
Pooling is implemented at the host-shell layer, not at the QuickJS runtime layer.
145145

146-
- `@execbox/protocol` exposes a small bounded async `createResourcePool()` helper that owns reusable shells, idle eviction, and `prewarm()` / `dispose()` support.
146+
- `@execbox/core/protocol` exposes a small bounded async `createResourcePool()` helper that owns reusable shells, idle eviction, and `prewarm()` / `dispose()` support.
147147
- Hosted `QuickJsExecutor` pools either `ChildProcess` or `Worker` shells. Each shell owns one long-lived transport wrapper plus one attached QuickJS protocol endpoint.
148148
- The child/worker entrypoint only attaches `attachQuickJsProtocolEndpoint(...)` once. That endpoint accepts one active `execute` message at a time and starts a fresh `runQuickJsSession()` for each message.
149149
- Concurrency therefore comes from pool size, not from multiplexing several executions through one shell.

docs/architecture/execbox-mcp-and-protocol.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This page covers two related but separate parts of the execbox architecture:
44

55
- MCP adapters in `@execbox/core`
6-
- transport-safe execution plumbing in `@execbox/protocol`
6+
- transport-safe execution plumbing in `@execbox/core/protocol`
77

88
Use this page as the overview. For the remote execution control flow, read [execbox-remote-workflow.md](./execbox-remote-workflow.md). For the message-level protocol contract, read [execbox-protocol-reference.md](./execbox-protocol-reference.md). For the normative runner specification, read [execbox-runner-specification.md](./execbox-runner-specification.md).
99

@@ -39,7 +39,7 @@ flowchart LR
3939

4040
## Protocol Responsibilities
4141

42-
`@execbox/protocol` is not a sandbox runtime. It provides the transport-safe layer that lets a trusted host and a runtime exchange execution messages without sharing host closures.
42+
`@execbox/core/protocol` is not a sandbox runtime. It provides the transport-safe layer that lets a trusted host and a runtime exchange execution messages without sharing host closures.
4343

4444
It owns:
4545

@@ -51,13 +51,13 @@ It owns:
5151
The architecture split is:
5252

5353
- `@execbox/core` owns provider resolution, manifest extraction, and host-side tool dispatch semantics
54-
- `@execbox/protocol` owns wire messages, host-session lifecycle, and host-side shell pooling utilities around those semantics
54+
- `@execbox/core/protocol` owns wire messages, host-session lifecycle, and host-side shell pooling utilities around those semantics
5555

5656
## How The Packages Fit Together
5757

5858
- `QuickJsExecutor` uses the shared runner semantics from `@execbox/core` directly.
5959
- `IsolatedVmExecutor` uses the same core runner semantics, but keeps a direct `isolated-vm` bridge instead of transport messages.
60-
- `QuickJsExecutor` in `host: "process"` and `host: "worker"` modes uses the shared host session from `@execbox/protocol` plus the shared QuickJS protocol endpoint inside the child or worker shell.
60+
- `QuickJsExecutor` in `host: "process"` and `host: "worker"` modes uses the shared host session from `@execbox/core/protocol` plus the shared QuickJS protocol endpoint inside the child or worker shell.
6161
- `RemoteExecutor` uses that same host session across an app-owned transport boundary.
6262
- Pooled process and worker execution reuse only the outer host shell. Each `execute()` call still starts a fresh QuickJS runtime through the shared protocol endpoint.
6363

@@ -73,7 +73,7 @@ flowchart TB
7373
end
7474
7575
subgraph TransportBacked["Transport-backed executors"]
76-
PROTO["@execbox/protocol<br/>messages + host session + resource pool"]
76+
PROTO["@execbox/core/protocol<br/>messages + host session + resource pool"]
7777
HOSTED["QuickJsExecutor host modes"]
7878
REM["RemoteExecutor"]
7979
ENDPOINT["QuickJS protocol endpoint"]

docs/architecture/execbox-protocol-reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Execbox Protocol Reference
1+
# Execbox Core Protocol Reference
22

3-
This page is the message-level reference for `@execbox/protocol`.
3+
This page is the message-level reference for `@execbox/core/protocol`.
44

55
It describes the wire shapes and session semantics used by transport-backed execbox runtimes such as hosted QuickJS and remote execution. It is grounded in the shipped implementation and should be read as a practical reference, not as a formal RFC.
66

0 commit comments

Comments
 (0)