remote-access-mcp 3.1.2 → 4.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 (125) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +117 -2
  3. package/dist/cli/main.d.ts.map +1 -1
  4. package/dist/cli/main.js +5 -3
  5. package/dist/cli/main.js.map +1 -1
  6. package/dist/core/agent-contracts.d.ts +57 -0
  7. package/dist/core/agent-contracts.d.ts.map +1 -0
  8. package/dist/core/agent-contracts.js +35 -0
  9. package/dist/core/agent-contracts.js.map +1 -0
  10. package/dist/core/agent-profiles.d.ts +11 -0
  11. package/dist/core/agent-profiles.d.ts.map +1 -0
  12. package/dist/core/agent-profiles.js +12 -0
  13. package/dist/core/agent-profiles.js.map +1 -0
  14. package/dist/core/automation-engine.d.ts +53 -0
  15. package/dist/core/automation-engine.d.ts.map +1 -0
  16. package/dist/core/automation-engine.js +310 -0
  17. package/dist/core/automation-engine.js.map +1 -0
  18. package/dist/core/autonomy.d.ts +11 -0
  19. package/dist/core/autonomy.d.ts.map +1 -0
  20. package/dist/core/autonomy.js +30 -0
  21. package/dist/core/autonomy.js.map +1 -0
  22. package/dist/core/capability-router.d.ts +16 -0
  23. package/dist/core/capability-router.d.ts.map +1 -0
  24. package/dist/core/capability-router.js +83 -0
  25. package/dist/core/capability-router.js.map +1 -0
  26. package/dist/core/config.d.ts +1 -1
  27. package/dist/core/config.d.ts.map +1 -1
  28. package/dist/core/config.js +1 -1
  29. package/dist/core/config.js.map +1 -1
  30. package/dist/core/context-engine.d.ts +75 -0
  31. package/dist/core/context-engine.d.ts.map +1 -0
  32. package/dist/core/context-engine.js +330 -0
  33. package/dist/core/context-engine.js.map +1 -0
  34. package/dist/core/context.d.ts +5 -0
  35. package/dist/core/context.d.ts.map +1 -1
  36. package/dist/core/context.js.map +1 -1
  37. package/dist/core/policy.d.ts.map +1 -1
  38. package/dist/core/policy.js +15 -5
  39. package/dist/core/policy.js.map +1 -1
  40. package/dist/core/project-profiles.d.ts +17 -0
  41. package/dist/core/project-profiles.d.ts.map +1 -0
  42. package/dist/core/project-profiles.js +32 -0
  43. package/dist/core/project-profiles.js.map +1 -0
  44. package/dist/core/recovery-engine.d.ts +37 -0
  45. package/dist/core/recovery-engine.d.ts.map +1 -0
  46. package/dist/core/recovery-engine.js +99 -0
  47. package/dist/core/recovery-engine.js.map +1 -0
  48. package/dist/core/security-analysis.d.ts +19 -0
  49. package/dist/core/security-analysis.d.ts.map +1 -0
  50. package/dist/core/security-analysis.js +39 -0
  51. package/dist/core/security-analysis.js.map +1 -0
  52. package/dist/core/task-engine.d.ts +76 -0
  53. package/dist/core/task-engine.d.ts.map +1 -0
  54. package/dist/core/task-engine.js +319 -0
  55. package/dist/core/task-engine.js.map +1 -0
  56. package/dist/core/tunnel-providers.d.ts +12 -0
  57. package/dist/core/tunnel-providers.d.ts.map +1 -0
  58. package/dist/core/tunnel-providers.js +76 -0
  59. package/dist/core/tunnel-providers.js.map +1 -0
  60. package/dist/core/tunnel.d.ts +3 -0
  61. package/dist/core/tunnel.d.ts.map +1 -1
  62. package/dist/core/tunnel.js +9 -3
  63. package/dist/core/tunnel.js.map +1 -1
  64. package/dist/server/app.d.ts +2 -1
  65. package/dist/server/app.d.ts.map +1 -1
  66. package/dist/server/app.js +117 -5
  67. package/dist/server/app.js.map +1 -1
  68. package/dist/server/run.d.ts +2 -0
  69. package/dist/server/run.d.ts.map +1 -1
  70. package/dist/server/run.js +21 -3
  71. package/dist/server/run.js.map +1 -1
  72. package/dist/tools/agent.d.ts +4 -0
  73. package/dist/tools/agent.d.ts.map +1 -0
  74. package/dist/tools/agent.js +16 -0
  75. package/dist/tools/agent.js.map +1 -0
  76. package/dist/tools/automation.d.ts +4 -0
  77. package/dist/tools/automation.d.ts.map +1 -0
  78. package/dist/tools/automation.js +87 -0
  79. package/dist/tools/automation.js.map +1 -0
  80. package/dist/tools/autonomous.d.ts +4 -0
  81. package/dist/tools/autonomous.d.ts.map +1 -0
  82. package/dist/tools/autonomous.js +82 -0
  83. package/dist/tools/autonomous.js.map +1 -0
  84. package/dist/tools/browser.d.ts +4 -0
  85. package/dist/tools/browser.d.ts.map +1 -0
  86. package/dist/tools/browser.js +99 -0
  87. package/dist/tools/browser.js.map +1 -0
  88. package/dist/tools/context.d.ts +4 -0
  89. package/dist/tools/context.d.ts.map +1 -0
  90. package/dist/tools/context.js +53 -0
  91. package/dist/tools/context.js.map +1 -0
  92. package/dist/tools/index.d.ts +1 -1
  93. package/dist/tools/index.d.ts.map +1 -1
  94. package/dist/tools/index.js +20 -2
  95. package/dist/tools/index.js.map +1 -1
  96. package/dist/tools/infrastructure.d.ts +4 -0
  97. package/dist/tools/infrastructure.d.ts.map +1 -0
  98. package/dist/tools/infrastructure.js +124 -0
  99. package/dist/tools/infrastructure.js.map +1 -0
  100. package/dist/tools/intelligence.d.ts +9 -0
  101. package/dist/tools/intelligence.d.ts.map +1 -0
  102. package/dist/tools/intelligence.js +120 -0
  103. package/dist/tools/intelligence.js.map +1 -0
  104. package/dist/tools/planning.d.ts.map +1 -1
  105. package/dist/tools/planning.js +9 -0
  106. package/dist/tools/planning.js.map +1 -1
  107. package/dist/tools/plugin-host.d.ts +2 -0
  108. package/dist/tools/plugin-host.d.ts.map +1 -0
  109. package/dist/tools/plugin-host.js +54 -0
  110. package/dist/tools/plugin-host.js.map +1 -0
  111. package/dist/tools/plugin-network-blocker.cjs +39 -0
  112. package/dist/tools/plugins.d.ts.map +1 -1
  113. package/dist/tools/plugins.js +344 -30
  114. package/dist/tools/plugins.js.map +1 -1
  115. package/dist/tools/router.d.ts +4 -0
  116. package/dist/tools/router.d.ts.map +1 -0
  117. package/dist/tools/router.js +39 -0
  118. package/dist/tools/router.js.map +1 -0
  119. package/dist/tools/tasks.d.ts +4 -0
  120. package/dist/tools/tasks.d.ts.map +1 -0
  121. package/dist/tools/tasks.js +71 -0
  122. package/dist/tools/tasks.js.map +1 -0
  123. package/docs/ai/agent-architecture.md +145 -0
  124. package/docs/ai/decisions.md +119 -1
  125. package/package.json +2 -2
@@ -0,0 +1,145 @@
1
+ # Agent Architecture Contract
2
+
3
+ This document defines the stable foundation for the post-3.1 agent layers.
4
+ It is deliberately a contract, not an implementation promise: Phase 1 adds
5
+ context processing, Phase 2 adds capability routing, and Phase 3 adds task
6
+ orchestration on top of these shapes.
7
+
8
+ ## Design goals
9
+
10
+ 1. Reduce model context and round trips without hiding important facts.
11
+ 2. Keep low-level tools available while exposing higher-level capabilities.
12
+ 3. Make mutation explicit, policy-checked, verifiable, and recoverable.
13
+ 4. Make long-running work resumable rather than dependent on one request.
14
+ 5. Keep existing MCP transport, per-request policy isolation, and Node 18
15
+ support intact.
16
+
17
+ ## Layers
18
+
19
+ ```text
20
+ MCP request
21
+ |
22
+ v
23
+ Task / Intent
24
+ |
25
+ v
26
+ Capability Router -----> Policy
27
+ |
28
+ v
29
+ Execution
30
+ |
31
+ v
32
+ Verification / Recovery
33
+ |
34
+ v
35
+ Context Engine -----> compact AgentResult
36
+ ```
37
+
38
+ The Context Engine is cross-cutting: it may reduce tool results and select
39
+ relevant prior state, but it must never silently change a mutation's meaning.
40
+
41
+ ## AgentResult
42
+
43
+ New agent-facing workflows should converge on:
44
+
45
+ ```json
46
+ {
47
+ "ok": true,
48
+ "summary": "short human/AI-readable result",
49
+ "data": {},
50
+ "warnings": [],
51
+ "errors": [],
52
+ "nextActions": []
53
+ }
54
+ ```
55
+
56
+ `sizeBytes` and `resultId` are optional metadata for context accounting and
57
+ large/persisted results. Existing tools are not being rewritten wholesale in
58
+ Phase 0; adapters belong to the Context Engine phase.
59
+
60
+ ## CapabilityDescriptor
61
+
62
+ Every future routed capability should declare:
63
+
64
+ - stable `id` and category
65
+ - risk and execution mode
66
+ - required scopes
67
+ - approximate context cost
68
+ - dependency capabilities
69
+ - dry-run support
70
+ - verification support
71
+
72
+ `contextCost` is an estimate used for routing/budgeting, not a billing meter.
73
+
74
+ ## ContextBudget
75
+
76
+ The future engine partitions a total budget into history, tool results,
77
+ memory, and a reserved safety margin. Allocations must never exceed total.
78
+ This is a planning contract; the current MCP server does not impose an
79
+ artificial token limit on clients.
80
+
81
+ ## Task lifecycle
82
+
83
+ ```text
84
+ queued
85
+ -> planning
86
+ -> awaiting_approval (when required)
87
+ -> executing
88
+ -> verifying
89
+ -> completed
90
+ ```
91
+
92
+ Failure/recovery paths are explicit:
93
+
94
+ ```text
95
+ planning -> failed
96
+ executing -> failed / rolled_back / cancelled
97
+ verifying -> executing / failed / rolled_back
98
+ failed -> planning / executing / rolled_back / cancelled
99
+ rolled_back -> planning / cancelled
100
+ ```
101
+
102
+ A completed or cancelled task is terminal.
103
+
104
+ ## Compatibility rules
105
+
106
+ - Do not replace the existing `ToolContext` in-place until an adapter has
107
+ been tested across the full transport/auth suite.
108
+ - Do not cache `McpServer` instances across requests: policy hot-reload and
109
+ token revocation depend on fresh registration.
110
+ - Codebase Memory remains project-isolated under its dedicated RAMCP runtime;
111
+ no future agent layer may reuse another service's Codebase Memory state.
112
+ - Node >=18 remains supported unless a future major release explicitly
113
+ changes the support policy.
114
+ - No automatic push/publish is part of an implementation phase.
115
+
116
+ ## Phase boundaries
117
+
118
+ - **Phase 0:** contracts, architecture, baseline measurements.
119
+ - **Phase 1:** Context Engine and measured token/output reduction.
120
+ - **Phase 2:** Capability Registry/Router and batched/parallel operations.
121
+ - **Phase 3:** Task/Workflow Engine, approvals, verification, recovery.
122
+
123
+ Later phases add integrations and autonomous operations without weakening
124
+ these invariants.
125
+
126
+ ## Phase 0 baseline (2026-09-06)
127
+
128
+ The reproducible benchmark is `scripts/benchmark-agent-baseline.mjs`. It runs
129
+ 30 post-warmup registrations of the current tool set with integrations disabled
130
+ and measures only registration overhead; it does not mutate the host.
131
+
132
+ Observed baseline on the development server:
133
+
134
+ | Metric | Baseline |
135
+ |---|---:|
136
+ | Registered tools | 69 |
137
+ | Samples | 30 |
138
+ | Registration p50 | 1.77 ms |
139
+ | Registration p95 | 12.21 ms |
140
+ | Registration average | 3.10 ms |
141
+ | Process RSS after benchmark | 108.1 MB |
142
+
143
+ These are engineering baselines, not universal performance guarantees. Future
144
+ phases must report the same measurements after changing the registration,
145
+ context, or routing path and must preserve correctness benchmarks separately.
@@ -138,4 +138,122 @@ call hangs until timeout (fleet's remote file writes hung 5s→timeout every
138
138
  time before this was understood; a minimal `bash -c cat` repro confirmed
139
139
  it's the API, not our code). Pattern: when stdin must be piped, use
140
140
  `spawn()` and end the stream manually. The helper shape lives in git
141
- history (core/fleet.ts) if ever needed again.
141
+ history (core/fleet.ts) if ever needed again).
142
+
143
+ ---
144
+
145
+ ## ADR-014 — Durable task orchestration is layered over the existing tool gate
146
+ **Status:** accepted · **Date:** 2026-09-07
147
+
148
+ Phase 3 introduces `task` as an orchestration layer, not a second execution
149
+ security model. Every action is still dispatched through the existing wrapped
150
+ MCP tool handler, so token scopes, read-only mode, path policy, command
151
+ allowlists, audit, context optimization, and plugin policy remain authoritative.
152
+
153
+ Task state is persisted only under RAMCP's own `dataDir()` and is token-isolated.
154
+ The workflow engine adds graph validation, bounded parallel action execution,
155
+ retry/timeout, explicit verification hooks, supervised pause/resume, and
156
+ compensation rollback. Specialized agent profiles are deterministic
157
+ capability/autonomy constraints; they are not hidden model processes and do
158
+ not touch external Codebase Memory state.
159
+
160
+ ---
161
+
162
+ ## ADR-015 — Browser and infrastructure integrations stay fixed-command and policy-first
163
+ **Status:** accepted · **Date:** 2026-09-07
164
+
165
+ Phase 5 adds headless browser access and infrastructure inspection without
166
+ introducing arbitrary shell execution. Browser URLs are restricted to public
167
+ HTTP(S) targets with the same private/metadata SSRF posture as web tools, and
168
+ screenshots must pass the existing path policy. Docker and Kubernetes calls use
169
+ fixed executables plus validated positional arguments rather than shell strings;
170
+ mutating Docker actions remain subject to read-only policy. Cloudflare access is
171
+ limited to the existing `cloudflared` binary and never exposes credentials.
172
+ Existing MySQL/PostgreSQL/Redis adapters remain unchanged and authoritative.
173
+
174
+ ---
175
+
176
+ ## ADR-016 — Automation is durable, token-isolated, and policy-first
177
+ **Status:** accepted · **Date:** 2026-09-07
178
+
179
+ Phase 6 stores automation rules only in RAMCP's own data directory and keys
180
+ ownership to the authenticated token fingerprint. Conditions are evaluated
181
+ locally and actions are bounded to a small declarative list; automation cannot
182
+ invoke control-plane, approval-decision, or plugin lifecycle tools. Mutating
183
+ lifecycle operations and action execution remain behind the normal policy,
184
+ scope, read-only, path, audit, and command-policy gates.
185
+
186
+ Persistence uses a cross-process filesystem lock with atomic replacement, while
187
+ rule execution uses an atomic per-rule claim so multiple gateway processes do
188
+ not intentionally execute the same rule concurrently. Event chains carry an
189
+ origin/depth guard and automation-origin tool events cannot recursively trigger
190
+ more automation. The authenticated inbound webhook endpoint selects rules by
191
+ token and never copies the token into the event payload. Optional integration
192
+ MCP children are started only when an automation action actually requests one,
193
+ so ordinary automation does not block on Codebase Memory/Context7 startup.
194
+
195
+ Existing schedules, outbound webhooks, and health watchers remain compatible
196
+ rather than being replaced. No external Codebase Memory state is read or
197
+ modified by the automation persistence layer.
198
+
199
+ ---
200
+
201
+ ## ADR-017 — Autonomous operations are opt-in and risk-gated
202
+ **Status:** accepted · **Date:** 2026-09-07
203
+
204
+ Phase 7 introduces centralized autonomy decisions and bounded self-healing.
205
+ Autonomous execution is disabled unless `RAMCP_AUTONOMOUS=1`; high-risk and
206
+ critical recovery additionally require explicit `RAMCP_AUTONOMOUS_HIGH_RISK=1`
207
+ and `RAMCP_AUTONOMOUS_CRITICAL=1`. Recovery rules are token-isolated,
208
+ rate-limited, attempt-bounded, persisted atomically, and executed through the
209
+ normal wrapped tool path. Automation/recovery recursion is not permitted.
210
+
211
+ ---
212
+
213
+ ## ADR-018 — Plugins are untrusted child processes, not in-process extensions
214
+ **Status:** accepted · **Date:** 2026-09-07
215
+
216
+ Phase 8 removes the previous in-process plugin execution model. An installed
217
+ plugin is copied into RAMCP's own plugin directory, validated, fingerprinted,
218
+ and only then exposed. The stored fingerprint must continue to match before
219
+ every plugin process is started; modified or unverifiable plugins are skipped
220
+ fail-closed.
221
+
222
+ Plugin tools are discovered through a short-lived MCP child process and
223
+ exposed to the gateway under a `plugin_<name>__<tool>` namespace. Each actual
224
+ invocation starts a fresh child process, bounds startup/execution time, and
225
+ closes the child after the call. This avoids persistent plugin processes and
226
+ plugin lifecycle state surviving independently of the gateway session.
227
+
228
+ On Linux, the child runs in a separate network namespace with a deny-by-default
229
+ network filter when `unshare` and `nft` are available. Node's permission system
230
+ limits filesystem reads to the plugin and required runtime dependencies,
231
+ permits writes only to the plugin's dedicated `data/` directory when `fs.write`
232
+ is explicitly declared, and permits child processes only when `process` is
233
+ explicitly declared. A network-blocking preload adds defense-in-depth for
234
+ common Node networking APIs. On platforms without the built-in sandbox,
235
+ plugins are disabled by default; `RAMCP_PLUGIN_UNSANDBOXED=1` is an explicit
236
+ local-trust escape hatch.
237
+
238
+ Installation rejects absolute/traversing entries, invalid names/versions/
239
+ permissions, symbolic links, oversized trees, and malformed manifests. Plugin
240
+ lifecycle tools require the `plugins` scope and remain blocked in read-only
241
+ mode. Plugin tool exposure also requires the plugin's declared gateway scopes
242
+ to be available to the token. There is intentionally no remote registry or
243
+ automatic download path in this phase; installation is local and explicit.
244
+
245
+ The sandbox is defense-in-depth rather than a claim of a universal kernel-grade
246
+ security boundary across every operating system. The default is fail-closed
247
+ when the required Linux sandbox is unavailable.
248
+
249
+ ---
250
+
251
+ ## ADR-019 — Plugin registry mutations are serialized across gateway processes
252
+ **Status:** accepted · **Date:** 2026-09-08
253
+
254
+ Phase 9 adds a cross-process filesystem guard around plugin installation and
255
+ removal. The registry lockfile is still replaced atomically, while failed
256
+ installations remove their partial destination and revalidate the copied
257
+ manifest before committing the integrity record. This preserves the simple
258
+ local filesystem model without allowing concurrent gateway processes to
259
+ produce competing plugin registry state.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remote-access-mcp",
3
- "version": "3.1.2",
3
+ "version": "4.1.0",
4
4
  "description": "Turn any machine into a secure AI-agent-accessible endpoint via MCP. Connect ChatGPT, Claude, Grok, and other MCP clients to files, shell, git, services, and more.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "node": ">=18"
24
24
  },
25
25
  "scripts": {
26
- "build": "tsc",
26
+ "build": "tsc && node scripts/copy-plugin-sandbox.mjs",
27
27
  "dev": "tsx watch src/main.ts",
28
28
  "start": "node dist/main.js",
29
29
  "test": "vitest run",