@paperclipai/plugin-modal 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +77 -0
  2. package/package.json +52 -0
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # `@paperclipai/plugin-modal`
2
+
3
+ First-party Modal sandbox provider plugin for Paperclip.
4
+
5
+ Like the other sandbox-provider packages in this repo, it lives inside the Paperclip monorepo but is intentionally excluded from the root `pnpm` workspace and shaped to publish and install like a standalone npm package. That lets operators install it from the Plugins page by package name without introducing root lockfile churn for Modal's SDK dependencies.
6
+
7
+ ## Install
8
+
9
+ From a Paperclip instance, install:
10
+
11
+ ```text
12
+ @paperclipai/plugin-modal
13
+ ```
14
+
15
+ The host plugin installer runs `npm install` into the managed plugin directory, so the `modal` SDK dependency is pulled in during installation.
16
+
17
+ ## Runtime support note
18
+
19
+ Modal's official JS SDK README pins support to **Node 22 or later**. Paperclip's repo baseline is currently `node >= 20`; empirically `modal@0.7.4` imports and operates against the Modal API under Node 20, so the plugin runs there today, but the vendor support contract is Node 22+. The plugin logs a startup warning when it detects Node `< 22`. Operators who can pin their Paperclip runtime to Node 22+ should do so; treat Node-20 usage as best-effort until the host bumps its baseline.
20
+
21
+ The empirical Node 20 compatibility check is recorded in [PAPA-352](/PAPA/issues/PAPA-352).
22
+
23
+ ## Configuration
24
+
25
+ Configure Modal from `Company Settings -> Environments`, not from the plugin's instance settings page.
26
+
27
+ | Field | Required | Description |
28
+ | --- | --- | --- |
29
+ | `appName` | yes | Modal App name. The plugin calls `modal.apps.fromName(appName, { createIfMissing: true })`, so the App is created on first acquire if it does not already exist. |
30
+ | `image` | yes | Container image passed to `modal.images.fromRegistry()`, e.g. `python:3.13` or `node:20`. |
31
+ | `tokenId` / `tokenSecret` | yes | Modal auth tokens. Both must be provided together. Paperclip stores pasted values as company secrets. The plugin worker runs in a child process that does not inherit host env vars, so `MODAL_TOKEN_ID` / `MODAL_TOKEN_SECRET` set on the Paperclip server are **not** read by the plugin — provide the tokens in this form. |
32
+ | `environment` | no | Optional Modal environment name. Falls back to the SDK profile default. |
33
+ | `workdir` | no | Remote working directory inside the sandbox. Defaults to `/workspace/paperclip`. |
34
+ | `sandboxTimeoutMs` | no | Maximum sandbox lifetime in milliseconds. Must be a positive multiple of `1000` between `1000` and `86_400_000` (24 hours). Defaults to `3_600_000` (1 hour). |
35
+ | `idleTimeoutMs` | no | Optional idle timeout in milliseconds. Modal terminates the sandbox if no exec is active for this duration. Must be a positive multiple of `1000`. |
36
+ | `execTimeoutMs` | no | Default per-exec timeout in milliseconds when the caller does not pass one. Must be a positive multiple of `1000`. Defaults to `300_000` (5 minutes). |
37
+ | `blockNetwork` | no | Block all egress network access. |
38
+ | `cidrAllowlist` | no | List of CIDRs the sandbox may reach. Cannot be combined with `blockNetwork`. |
39
+ | `reuseLease` | no | When `true`, the sandbox is detached (not terminated) on release and reattached by id later. Defaults to `false`. |
40
+
41
+ ### Reuse semantics
42
+
43
+ Modal does **not** expose a separate pause/resume primitive for sandboxes — there is no equivalent to e2b's `pause()`. The plugin implements `reuseLease` as follows:
44
+
45
+ - **`reuseLease: false` (default)**: On release the sandbox is `terminate()`d. Subsequent runs create a new sandbox.
46
+ - **`reuseLease: true`**: On release the plugin calls `sandbox.detach()`. The sandbox keeps running on Modal until its configured `sandboxTimeoutMs` or `idleTimeoutMs` elapses. The next acquire/resume reconnects via `modal.sandboxes.fromId(providerLeaseId)`. If the sandbox has expired, `fromId` raises `NotFoundError` and the plugin reports the lease as expired so Paperclip reacquires.
47
+
48
+ Because there is no real pause, **`reuseLease: true` keeps billing running** until the sandbox or idle timeout cuts it off. Tune `idleTimeoutMs` to a value that matches your reuse window.
49
+
50
+ ## Local development
51
+
52
+ ```bash
53
+ cd packages/plugins/sandbox-providers/modal
54
+ pnpm install --ignore-workspace --no-lockfile
55
+ pnpm build
56
+ pnpm test
57
+ pnpm typecheck
58
+ ```
59
+
60
+ These commands assume the repo root has already been installed once so the local `@paperclipai/plugin-sdk` workspace package is available to the compiler during development.
61
+
62
+ ## Operator verification
63
+
64
+ 1. Provision Modal credentials in your Modal account (`modal token new`) or use a service account.
65
+ 2. Install the plugin from the Paperclip Plugins page.
66
+ 3. In `Company Settings -> Environments`, add a new Modal sandbox environment with at least `appName`, `image`, `tokenId`, and `tokenSecret`.
67
+ 4. Run the environment **Probe** action. A success result confirms auth, app creation, image pull, and `exec` round-trip.
68
+ 5. Run at least one Paperclip task with a remote-managed adapter (for example `claude_local`) bound to that environment. The adapter should provision the sandbox, run commands in it, and clean it up.
69
+
70
+ Full end-to-end manual QA is tracked separately in [PAPA-354](/PAPA/issues/PAPA-354).
71
+
72
+ ## Package layout
73
+
74
+ - `src/manifest.ts` declares the sandbox-provider driver metadata
75
+ - `src/plugin.ts` implements the environment lifecycle hooks
76
+ - `src/worker.ts` boots the plugin under the host worker runtime
77
+ - `paperclipPlugin.manifest` and `paperclipPlugin.worker` point the host at the built plugin entrypoints in `dist/`
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@paperclipai/plugin-modal",
3
+ "version": "0.1.0",
4
+ "description": "Modal sandbox provider plugin for Paperclip environments",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/paperclipai/paperclip",
7
+ "bugs": {
8
+ "url": "https://github.com/paperclipai/paperclip/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/paperclipai/paperclip",
13
+ "directory": "packages/plugins/sandbox-providers/modal"
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ }
21
+ },
22
+ "main": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ }
31
+ },
32
+ "main": "./dist/index.js",
33
+ "types": "./dist/index.d.ts"
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "paperclipPlugin": {
39
+ "manifest": "./dist/manifest.js",
40
+ "worker": "./dist/worker.js"
41
+ },
42
+ "keywords": [
43
+ "paperclip",
44
+ "plugin",
45
+ "sandbox",
46
+ "modal"
47
+ ],
48
+ "dependencies": {
49
+ "modal": "^0.7.4",
50
+ "@paperclipai/plugin-sdk": "1.0.0"
51
+ }
52
+ }