@particle-academy/agent-integrations 0.6.1 → 0.6.2

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.
@@ -75,12 +75,232 @@ docker build -t agent-integrations-relay .
75
75
  docker run -p 8787:8787 agent-integrations-relay
76
76
  ```
77
77
 
78
- Deploy targets that just want a container:
78
+ ## Deployment recipes
79
+
80
+ The relay is a tiny stateless Node HTTP server. Any platform that can host a
81
+ long-running Node process works. Pick whichever matches the rest of your
82
+ infrastructure — verification steps are at the bottom of each recipe.
83
+
84
+ ### Laravel Forge (Node site or daemon)
85
+
86
+ Forge supports both Node sites and standalone daemons, either fits.
87
+
88
+ **Option A — Forge "Static" site running Node:**
89
+
90
+ 1. In Forge, create a new site on your server. Set **Project Type** to
91
+ *Static / Node*. Web directory: `/public` (unused — we'll serve from the
92
+ relay port).
93
+ 2. Add a domain (e.g. `relay.particle.academy`) and an LE SSL cert.
94
+ 3. Connect the site to a deploy repo — point it at this package's git URL or
95
+ a thin wrapper repo containing just:
96
+ ```
97
+ .
98
+ ├── package.json (just "scripts": { "start": "agent-integrations-relay --port 8787" }
99
+ │ and "dependencies": { "@particle-academy/agent-integrations": "^0.6.1" })
100
+ └── README.md
101
+ ```
102
+ 4. Deploy script:
103
+ ```bash
104
+ cd $FORGE_SITE_PATH
105
+ npm install --omit=dev
106
+ ```
107
+ 5. In **Daemons** (sidebar), add:
108
+ - **Command:** `npx agent-integrations-relay --port 8787 --cors https://your-site.example`
109
+ - **Directory:** `$FORGE_SITE_PATH`
110
+ - **User:** `forge`
111
+ Daemon auto-restarts on crash.
112
+ 6. In the site's **Nginx config**, replace the upstream block with:
113
+ ```nginx
114
+ location / {
115
+ proxy_pass http://127.0.0.1:8787;
116
+ proxy_http_version 1.1;
117
+ proxy_set_header Host $host;
118
+ proxy_set_header X-Real-IP $remote_addr;
119
+
120
+ # SSE needs these — otherwise the stream is buffered and never reaches the agent.
121
+ proxy_buffering off;
122
+ proxy_cache off;
123
+ proxy_read_timeout 6h;
124
+ proxy_send_timeout 6h;
125
+ chunked_transfer_encoding on;
126
+ }
127
+ ```
128
+ 7. Restart Nginx via the Forge UI button or `sudo nginx -s reload`.
129
+
130
+ **Option B — daemon alongside an existing Laravel app on the same server:**
131
+
132
+ If you'd rather not give it its own subdomain, run it as a Forge daemon on
133
+ an internal port and proxy from an existing site's Nginx config:
134
+
135
+ ```nginx
136
+ # Inside an existing Forge Laravel site
137
+ location /mcp-relay/ {
138
+ proxy_pass http://127.0.0.1:8787/;
139
+ proxy_http_version 1.1;
140
+ proxy_buffering off;
141
+ proxy_read_timeout 6h;
142
+ chunked_transfer_encoding on;
143
+ }
144
+ ```
145
+
146
+ **Verify:**
147
+
148
+ ```bash
149
+ curl https://relay.particle.academy/ # → {"ok":true,"service":"…"}
150
+ curl -X POST -H 'content-type: application/json' \
151
+ -d '{"session":"smoke-001","token":"abcdef0123456789abcdef0123456789"}' \
152
+ https://relay.particle.academy/register # → {"ok":true}
153
+ ```
154
+
155
+ ### Fly.io
156
+
157
+ ```bash
158
+ git clone https://github.com/Particle-Academy/agent-integrations
159
+ cd agent-integrations
160
+ npm install && npm run build
161
+ docker build -t agent-integrations-relay .
162
+
163
+ # Init + deploy (first time only):
164
+ fly launch \
165
+ --name relay-particle-academy \
166
+ --no-deploy \
167
+ --copy-config \
168
+ --image agent-integrations-relay \
169
+ --internal-port 8787 \
170
+ --region iad
171
+ fly deploy
172
+ ```
173
+
174
+ Public URL prints at the end, e.g. `https://relay-particle-academy.fly.dev`.
175
+
176
+ ### Railway
177
+
178
+ ```bash
179
+ # Commit the Dockerfile to your relay repo, then:
180
+ railway login
181
+ railway init
182
+ railway up
183
+ ```
184
+
185
+ In the Railway dashboard, enable a public domain on the service; copy the
186
+ generated `*.up.railway.app` URL.
187
+
188
+ ### Render
189
+
190
+ 1. New → **Web Service**
191
+ 2. Connect a git repo containing the Dockerfile
192
+ 3. Runtime: **Docker**
193
+ 4. Port: `8787`
194
+ 5. Add `Header: Cache-Control: no-cache` on the service so Render's CDN
195
+ doesn't buffer SSE
196
+
197
+ ### Google Cloud Run
198
+
199
+ ```bash
200
+ gcloud builds submit --tag gcr.io/$PROJECT/agent-integrations-relay
201
+ gcloud run deploy agent-integrations-relay \
202
+ --image gcr.io/$PROJECT/agent-integrations-relay \
203
+ --port 8787 \
204
+ --allow-unauthenticated \
205
+ --min-instances 1 \
206
+ --timeout 3600
207
+ ```
208
+
209
+ Cloud Run's default request timeout is 60s — bump it via `--timeout 3600`
210
+ (max 3600s on managed Cloud Run) so SSE streams aren't cut off. For longer
211
+ sessions, use **Cloud Run for Anthos / GKE** or a Compute Engine VM.
212
+
213
+ ### Bare server (systemd)
214
+
215
+ If the relay is going on a VM you already own, `systemd`:
216
+
217
+ ```ini
218
+ # /etc/systemd/system/mcp-relay.service
219
+ [Unit]
220
+ Description=MCP relay broker
221
+ After=network.target
222
+
223
+ [Service]
224
+ Type=simple
225
+ User=relay
226
+ WorkingDirectory=/opt/relay
227
+ ExecStart=/usr/bin/npx agent-integrations-relay --port 8787 --cors https://your-site.example
228
+ Restart=on-failure
229
+ RestartSec=5
230
+ Environment=NODE_ENV=production
231
+
232
+ [Install]
233
+ WantedBy=multi-user.target
234
+ ```
235
+
236
+ ```bash
237
+ sudo systemctl daemon-reload
238
+ sudo systemctl enable --now mcp-relay
239
+ sudo systemctl status mcp-relay
240
+ ```
241
+
242
+ Front with Nginx using the same SSE-friendly proxy block as the Forge
243
+ recipe.
244
+
245
+ ## Smoke testing any deploy
246
+
247
+ After you have a public URL, regardless of host:
248
+
249
+ ```bash
250
+ RELAY=https://relay.example.com
251
+
252
+ # 1. Health
253
+ curl $RELAY/
254
+
255
+ # 2. Register a session
256
+ curl -X POST -H 'content-type: application/json' \
257
+ -d '{"session":"smoke-001","token":"abcdef0123456789abcdef0123456789"}' \
258
+ $RELAY/register
259
+
260
+ # 3. POST a frame
261
+ curl -X POST -H 'content-type: application/json' \
262
+ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' \
263
+ "$RELAY/smoke-001/inbox?token=abcdef0123456789abcdef0123456789"
264
+
265
+ # 4. SSE stream — should hang open + emit keepalive comments every 15s
266
+ curl -N "$RELAY/smoke-001/events?token=abcdef0123456789abcdef0123456789&direction=inbound"
267
+ ```
268
+
269
+ If `curl -N` returns immediately, your proxy is buffering. Re-check
270
+ `proxy_buffering off` (Nginx) or the equivalent on your edge.
271
+
272
+ ## Hooking into your demo site
273
+
274
+ Set the relay base URL in your demo's environment. For a Laravel host (like
275
+ particle.academy):
276
+
277
+ ```env
278
+ # .env on the demo site
279
+ MCP_RELAY_BASE_URL=https://relay.particle.academy
280
+ ```
281
+
282
+ Bind it to a config and read it from your Livewire/Blade layer:
283
+
284
+ ```php
285
+ // config/mcp.php
286
+ return [
287
+ 'relay_base_url' => env('MCP_RELAY_BASE_URL', ''),
288
+ ];
289
+ ```
290
+
291
+ Then pass it to the React mount placeholder:
292
+
293
+ ```blade
294
+ <div
295
+ data-fancy-demo="composer"
296
+ data-relay-base="{{ config('mcp.relay_base_url') }}"
297
+ ></div>
298
+ ```
79
299
 
80
- - **Fly.io:** `fly launch --image agent-integrations-relay --internal-port 8787`
81
- - **Railway:** `railway up` after committing the Dockerfile
82
- - **Render:** point a Web Service at the Dockerfile, expose 8787
83
- - **Cloud Run:** `gcloud run deploy --image agent-integrations-relay --port 8787 --allow-unauthenticated`
300
+ The React side reads `node.dataset.relayBase`, passes it to the demo
301
+ component, and the component uses it for `attachSseRelay({ baseUrl: ... })`.
302
+ See [agent-hookable-demos.md](./agent-hookable-demos.md) for the
303
+ end-to-end pattern.
84
304
 
85
305
  ## Wire protocol
86
306
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-academy/agent-integrations",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "MCP-driven agent presence in collab sessions: per-session micro-MCP server, pluggable bridges to fancy-* packages, and agent UX components (panel + on-canvas cursor).",
5
5
  "repository": {
6
6
  "type": "git",