@rubytech/create-realagent 1.0.619 → 1.0.621

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 (23) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/mcp-stderr-tee/dist/index.d.ts.map +1 -1
  3. package/payload/platform/lib/mcp-stderr-tee/dist/index.js +11 -5
  4. package/payload/platform/lib/mcp-stderr-tee/dist/index.js.map +1 -1
  5. package/payload/platform/lib/mcp-stderr-tee/src/index.ts +10 -5
  6. package/payload/platform/plugins/admin/skills/onboarding/SKILL.md +11 -7
  7. package/payload/platform/plugins/cloudflare/PLUGIN.md +10 -13
  8. package/payload/platform/plugins/cloudflare/mcp/dist/index.js +181 -1033
  9. package/payload/platform/plugins/cloudflare/mcp/dist/index.js.map +1 -1
  10. package/payload/platform/plugins/cloudflare/mcp/dist/lib/cloudflared.d.ts +117 -261
  11. package/payload/platform/plugins/cloudflare/mcp/dist/lib/cloudflared.d.ts.map +1 -1
  12. package/payload/platform/plugins/cloudflare/mcp/dist/lib/cloudflared.js +379 -903
  13. package/payload/platform/plugins/cloudflare/mcp/dist/lib/cloudflared.js.map +1 -1
  14. package/payload/platform/plugins/cloudflare/mcp/package.json +3 -7
  15. package/payload/platform/plugins/cloudflare/references/setup-guide.md +70 -76
  16. package/payload/platform/plugins/cloudflare/skills/setup-tunnel/SKILL.md +34 -82
  17. package/payload/platform/plugins/docs/PLUGIN.md +1 -1
  18. package/payload/platform/plugins/docs/references/cloudflare.md +21 -30
  19. package/payload/platform/templates/agents/admin/IDENTITY.md +8 -0
  20. package/payload/platform/templates/agents/public/IDENTITY.md +8 -0
  21. package/payload/platform/templates/specialists/agents/personal-assistant.md +9 -9
  22. package/payload/server/server.js +85 -9
  23. package/payload/platform/plugins/cloudflare/mcp/__tests__/auth-binding.test.ts +0 -195
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-realagent",
3
- "version": "1.0.619",
3
+ "version": "1.0.621",
4
4
  "description": "Install Real Agent — Built for agents. By agents.",
5
5
  "bin": {
6
6
  "create-realagent": "./dist/index.js"
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAeH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAyItD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAeH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CA8ItD"}
@@ -172,12 +172,18 @@ function initStderrTee(serverName) {
172
172
  // Mark the patch so a second initStderrTee() call is refused at the top.
173
173
  process.stderr.write[INIT_MARKER] = true;
174
174
  // Flush any trailing unterminated segment on graceful event-loop drain.
175
- // `beforeExit` fires only when the event loop is empty — it does NOT run
176
- // on SIGTERM, SIGKILL, or explicit process.exit(). Acceptable: console.error
177
- // always terminates with \n, so the buffer is effectively always empty at
178
- // shutdown anyway. This hook exists for the rare caller that uses
179
- // process.stderr.write without a trailing newline.
175
+ // `beforeExit` can fire repeatedly: each async write to `streamLogStream`
176
+ // schedules I/O that keeps the event loop alive, which drains, which fires
177
+ // `beforeExit` again. With N MCP servers attached, the handler can emit
178
+ // thousands of detach lines per second. The `detached` flag gates the
179
+ // drain+detach emission to a single invocation; subsequent firings are
180
+ // no-ops. Buffer flushing also runs only once — partial-line state at true
181
+ // process exit doesn't change across re-fires.
182
+ let detached = false;
180
183
  process.on("beforeExit", () => {
184
+ if (detached)
185
+ return;
186
+ detached = true;
181
187
  if (streamLogStream && !streamLogStream.destroyed && !streamLogStream.writableEnded) {
182
188
  if (lineBuffer.length > 0) {
183
189
  streamLogStream.write(`${tsPrefix()} [mcp:${serverName}] ${lineBuffer}\n`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;AA8BH,sCAyIC;AArKD,qCAIiB;AACjB,yCAA6C;AAC7C,6DAAoD;AAEpD,wEAAwE;AACxE,wEAAwE;AACxE,uDAAuD;AACvD,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,SAAgB,aAAa,CAAC,UAAkB;IAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IACnC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAElD,qEAAqE;IACrE,qEAAqE;IACrE,gDAAgD;IAChD,IAAK,OAAO,CAAC,MAAM,CAAC,KAA6C,CAAC,WAAW,CAAC;QAAE,OAAO;IAEvF,yEAAyE;IACzE,iEAAiE;IACjE,yEAAyE;IACzE,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhE,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC;IACvD,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QACtD,aAAa,CAAC,GAAG,QAAQ,EAAE,qCAAqC,UAAU,gBAAgB,WAAW,WAAW,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9I,CAAC,CAAC;IAEF,iFAAiF;IACjF,IAAI,eAAwC,CAAC;IAC7C,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CAAC;YACH,IAAA,mBAAS,EAAC,MAAM,EAAE,E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AE,CAAC;gBAC1B,eAAe,CAAC,KAAK,CAAC,GAAG,QAAQ,EAAE,SAAS,UAAU,KAAK,UAAU,IAAI,CAAC,CAAC;YAC7E,CAAC;YACD,eAAe,CAAC,KAAK,CAAC,GAAG,QAAQ,EAAE,uCAAuC,UAAU,+BAA+B,CAAC,CAAC;QACvH,CAAC;QACD,UAAU,GAAG,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -184,12 +184,17 @@ export function initStderrTee(serverName: string): void {
184
184
  (process.stderr.write as unknown as { [k: symbol]: boolean })[INIT_MARKER] = true;
185
185
 
186
186
  // Flush any trailing unterminated segment on graceful event-loop drain.
187
- // `beforeExit` fires only when the event loop is empty — it does NOT run
188
- // on SIGTERM, SIGKILL, or explicit process.exit(). Acceptable: console.error
189
- // always terminates with \n, so the buffer is effectively always empty at
190
- // shutdown anyway. This hook exists for the rare caller that uses
191
- // process.stderr.write without a trailing newline.
187
+ // `beforeExit` can fire repeatedly: each async write to `streamLogStream`
188
+ // schedules I/O that keeps the event loop alive, which drains, which fires
189
+ // `beforeExit` again. With N MCP servers attached, the handler can emit
190
+ // thousands of detach lines per second. The `detached` flag gates the
191
+ // drain+detach emission to a single invocation; subsequent firings are
192
+ // no-ops. Buffer flushing also runs only once — partial-line state at true
193
+ // process exit doesn't change across re-fires.
194
+ let detached = false;
192
195
  process.on("beforeExit", () => {
196
+ if (detached) return;
197
+ detached = true;
193
198
  if (streamLogStream && !streamLogStream.destroyed && !streamLogStream.writableEnded) {
194
199
  if (lineBuffer.length > 0) {
195
200
  streamLogStream.write(`${tsPrefix()} [mcp:${serverName}] ${lineBuffer}\n`);
@@ -127,15 +127,19 @@ Ask the user: "Would you like to set up remote access now? This connects your pl
127
127
 
128
128
  If the user skips, let them know they can set up Cloudflare at any time by asking. Also mention that remote access is still possible without Cloudflare — WhatsApp, Telegram, and Email channels all connect directly to the device, so the user (and their customers) can reach the agent from anywhere through those channels without needing a tunnel or custom domain. Call `onboarding-complete-step` with step 7.
129
129
 
130
- If the user wants to proceed, ask for their domain name and then call `cloudflare-setup` with it. The tool is a deterministic state machine it checks the current state, advances as far as possible, and returns a structured JSON result with `status` and `message` fields. Relay the `message` to the user verbatim. Handle the `status` as follows:
130
+ If the user wants to proceed, coach them through the dashboard the agent never reads Cloudflare account state. The operator's logged-in dashboard is the source of truth; this step's job is to get them signed in on the correct account and then run `cloudflared` against that sign-in.
131
131
 
132
- - `awaiting_auth`: The tool returned an `authUrl` in `data`. Call `render-component` with `name: "browser-viewer"` and `data: { title: "Cloudflare" }`, then use `browser_navigate` to open the auth URL. Relay the message. When the user confirms, call `cloudflare-setup` again with the same domain.
133
- - `awaiting_nameservers`: Relay the message (it contains the nameservers to set). When the user confirms, call `cloudflare-setup` again with the same domain.
134
- - `awaiting_password`: Relay the message (it contains the setup URL in backticks). When the user confirms, call `cloudflare-setup` again with the same domain.
135
- - `complete`: Call `onboarding-complete-step` with step 7.
136
- - `error`: Relay the message. Offer to try again or skip.
132
+ 1. Ask: "What domain do you want to use, and is it already on Cloudflare?" If the domain is already on their Cloudflare account, skip to step 3.
133
+ 2. If not: call `render-component` with `name: "browser-viewer"` and `data: { title: "Cloudflare" }`, then `browser_navigate` to `https://dash.cloudflare.com/`. Tell the user: "Open Cloudflare, go to Websites → Add a site, enter your domain, and follow the instructions. Cloudflare will give you two nameservers to set at your domain registrar — the page walks you through it. When the domain shows as Active in the dashboard (minutes to 24 hours), tell me."
134
+ 3. Call `tunnel-login`. Relay the sign-in URL to the user: "Open this URL in your browser, pick the Cloudflare account that owns your domain (the name shows in the top-left of Cloudflare), and click Authorize. Tell me when you are done." When they confirm, call `tunnel-login` again it will detect the completed sign-in and record it.
135
+ 4. Ask for the sub-addresses (defaults: `admin` and `public`). Call `tunnel-create` with the domain and sub-addresses.
136
+ 5. If `tunnel-create` returns a refusal message about the Cloudflare account not owning the domain, relay the message verbatim (it contains the dashboard instructions). When the user confirms they have switched accounts in the browser, call `tunnel-login` with `force=true`, wait for the fresh sign-in, then retry `tunnel-create`.
137
+ 6. Set the remote password. Relay the URL from `tunnel-create`'s response (wrap it in backticks — `/__remote-auth/setup` contains double-underscores). When the user confirms, continue.
138
+ 7. Call `tunnel-enable`. If it succeeds, call `onboarding-complete-step` with step 7.
139
+
140
+ If any step fails, relay the error message verbatim. Offer to try again or skip.
137
141
 
138
- Do not read any skill files. Do not call any other Cloudflare tools. Do not dispatch specialists. The `cloudflare-setup` tool handles the entire flow.
142
+ Do not read any skill files. Do not dispatch specialists. The cloudflare plugin's tools handle all the mechanics.
139
143
 
140
144
  ## Step 8 — Anthropic API key
141
145
 
@@ -1,12 +1,7 @@
1
1
  ---
2
2
  name: cloudflare
3
- description: Cloudflare Tunnel setup and management — bound account is the universe, agent owns it absolutely
3
+ description: Cloudflare Tunnel setup and management — the dashboard is the source of truth, the agent executes cloudflared CLI only
4
4
  tools:
5
- - cloudflare-setup
6
- - cf-add-zone
7
- - cf-zone-status
8
- - cf-verify
9
- - cf-rebuild
10
5
  - tunnel-login
11
6
  - tunnel-status
12
7
  - tunnel-install
@@ -19,14 +14,16 @@ tools:
19
14
 
20
15
  # Cloudflare Tunnel Setup
21
16
 
22
- Each installation has its own Cloudflare account, owned by the user, accessed via `cert.pem` from `tunnel-login` (OAuth — the only auth path). The bound account is the entire universe of routable zones; the agent has absolute authority over it (add, delete, restructure). Anything on the account that doesn't belong to the user's current intended state is pollution — `cf-rebuild` deletes it, with `reason=no-intent` refusal when intent is unstated. `cloudflare-setup` is the onboarding orchestrator: a UI-driven state machine that surfaces what's on the account, asks the user to pick a domain, requires explicit cleanup confirmation for any pollution, then creates the tunnel. `cf-verify` is the non-mutating audit (account state + device state + default pollution view). The device records `account-binding.json` on first login so cert rotation under a different account is detected and refused that's the only inherited identity check.
17
+ Each installation has its own Cloudflare account. The operator signs in with OAuth (`tunnel-login`) — `cloudflared` writes `cert.pem` and the plugin records which Cloudflare account this laptop is signed into (`account-binding.json`). That binding is a drift detector only: if the operator later signs in under a different account, subsequent tool calls refuse and point the operator back to the browser.
18
+
19
+ The Cloudflare dashboard is the single source of truth for which domains, addresses, and tunnels exist on the account. The plugin never reads or mutates account state via any API path — only `cloudflared` CLI shell-outs (which use the signed-in cert locally) and DNS + HTTPS probes against public surfaces. When something is wrong, the agent tells the operator where to click in the dashboard; the operator clicks; then the agent runs the next `cloudflared` command.
23
20
 
24
21
  ## When to activate
25
22
 
26
- - User mentions Cloudflare, custom domain, public access, or internet access
27
- - User wants to expose the assistant publicly with a custom URL
28
- - User asks about setting up remote access with a custom domain
29
- - User says "set up Cloudflare" or similar
23
+ - Operator mentions Cloudflare, custom domain, public access, or internet access
24
+ - Operator wants to expose the assistant publicly with a custom URL
25
+ - Operator asks about setting up remote access with a custom domain
26
+ - Operator says "set up Cloudflare" or similar
30
27
 
31
28
  ## What it unlocks
32
29
 
@@ -39,12 +36,12 @@ Each installation has its own Cloudflare account, owned by the user, accessed vi
39
36
 
40
37
  | Skill | Purpose |
41
38
  |-------|---------|
42
- | [setup-tunnel/SKILL.md](skills/setup-tunnel/SKILL.md) | Reference documentation for manual tunnel setup — the `cloudflare-setup` tool handles this deterministically during onboarding |
39
+ | [setup-tunnel/SKILL.md](skills/setup-tunnel/SKILL.md) | Dashboard-driven tunnel setup flow — the agent is the coach, the operator clicks |
43
40
 
44
41
  ## References
45
42
 
46
43
  | Reference | Topics |
47
44
  |-----------|--------|
48
- | [setup-guide.md](references/setup-guide.md) | Prerequisites, domain setup, troubleshooting, tool reference |
45
+ | [setup-guide.md](references/setup-guide.md) | Prerequisites, domain setup in the dashboard, troubleshooting, tool reference |
49
46
 
50
47
  Load the relevant skill or reference based on the task.