remote-access-mcp 3.1.2 → 4.0.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 (111) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +104 -2
  3. package/dist/core/agent-contracts.d.ts +57 -0
  4. package/dist/core/agent-contracts.d.ts.map +1 -0
  5. package/dist/core/agent-contracts.js +35 -0
  6. package/dist/core/agent-contracts.js.map +1 -0
  7. package/dist/core/agent-profiles.d.ts +11 -0
  8. package/dist/core/agent-profiles.d.ts.map +1 -0
  9. package/dist/core/agent-profiles.js +12 -0
  10. package/dist/core/agent-profiles.js.map +1 -0
  11. package/dist/core/automation-engine.d.ts +53 -0
  12. package/dist/core/automation-engine.d.ts.map +1 -0
  13. package/dist/core/automation-engine.js +310 -0
  14. package/dist/core/automation-engine.js.map +1 -0
  15. package/dist/core/autonomy.d.ts +11 -0
  16. package/dist/core/autonomy.d.ts.map +1 -0
  17. package/dist/core/autonomy.js +30 -0
  18. package/dist/core/autonomy.js.map +1 -0
  19. package/dist/core/capability-router.d.ts +16 -0
  20. package/dist/core/capability-router.d.ts.map +1 -0
  21. package/dist/core/capability-router.js +83 -0
  22. package/dist/core/capability-router.js.map +1 -0
  23. package/dist/core/config.js +1 -1
  24. package/dist/core/config.js.map +1 -1
  25. package/dist/core/context-engine.d.ts +75 -0
  26. package/dist/core/context-engine.d.ts.map +1 -0
  27. package/dist/core/context-engine.js +330 -0
  28. package/dist/core/context-engine.js.map +1 -0
  29. package/dist/core/context.d.ts +5 -0
  30. package/dist/core/context.d.ts.map +1 -1
  31. package/dist/core/context.js.map +1 -1
  32. package/dist/core/policy.d.ts.map +1 -1
  33. package/dist/core/policy.js +15 -5
  34. package/dist/core/policy.js.map +1 -1
  35. package/dist/core/project-profiles.d.ts +17 -0
  36. package/dist/core/project-profiles.d.ts.map +1 -0
  37. package/dist/core/project-profiles.js +32 -0
  38. package/dist/core/project-profiles.js.map +1 -0
  39. package/dist/core/recovery-engine.d.ts +37 -0
  40. package/dist/core/recovery-engine.d.ts.map +1 -0
  41. package/dist/core/recovery-engine.js +99 -0
  42. package/dist/core/recovery-engine.js.map +1 -0
  43. package/dist/core/security-analysis.d.ts +19 -0
  44. package/dist/core/security-analysis.d.ts.map +1 -0
  45. package/dist/core/security-analysis.js +39 -0
  46. package/dist/core/security-analysis.js.map +1 -0
  47. package/dist/core/task-engine.d.ts +76 -0
  48. package/dist/core/task-engine.d.ts.map +1 -0
  49. package/dist/core/task-engine.js +319 -0
  50. package/dist/core/task-engine.js.map +1 -0
  51. package/dist/server/app.d.ts +2 -1
  52. package/dist/server/app.d.ts.map +1 -1
  53. package/dist/server/app.js +117 -5
  54. package/dist/server/app.js.map +1 -1
  55. package/dist/server/run.d.ts.map +1 -1
  56. package/dist/server/run.js +15 -1
  57. package/dist/server/run.js.map +1 -1
  58. package/dist/tools/agent.d.ts +4 -0
  59. package/dist/tools/agent.d.ts.map +1 -0
  60. package/dist/tools/agent.js +16 -0
  61. package/dist/tools/agent.js.map +1 -0
  62. package/dist/tools/automation.d.ts +4 -0
  63. package/dist/tools/automation.d.ts.map +1 -0
  64. package/dist/tools/automation.js +87 -0
  65. package/dist/tools/automation.js.map +1 -0
  66. package/dist/tools/autonomous.d.ts +4 -0
  67. package/dist/tools/autonomous.d.ts.map +1 -0
  68. package/dist/tools/autonomous.js +82 -0
  69. package/dist/tools/autonomous.js.map +1 -0
  70. package/dist/tools/browser.d.ts +4 -0
  71. package/dist/tools/browser.d.ts.map +1 -0
  72. package/dist/tools/browser.js +99 -0
  73. package/dist/tools/browser.js.map +1 -0
  74. package/dist/tools/context.d.ts +4 -0
  75. package/dist/tools/context.d.ts.map +1 -0
  76. package/dist/tools/context.js +53 -0
  77. package/dist/tools/context.js.map +1 -0
  78. package/dist/tools/index.d.ts +1 -1
  79. package/dist/tools/index.d.ts.map +1 -1
  80. package/dist/tools/index.js +20 -2
  81. package/dist/tools/index.js.map +1 -1
  82. package/dist/tools/infrastructure.d.ts +4 -0
  83. package/dist/tools/infrastructure.d.ts.map +1 -0
  84. package/dist/tools/infrastructure.js +124 -0
  85. package/dist/tools/infrastructure.js.map +1 -0
  86. package/dist/tools/intelligence.d.ts +9 -0
  87. package/dist/tools/intelligence.d.ts.map +1 -0
  88. package/dist/tools/intelligence.js +120 -0
  89. package/dist/tools/intelligence.js.map +1 -0
  90. package/dist/tools/planning.d.ts.map +1 -1
  91. package/dist/tools/planning.js +9 -0
  92. package/dist/tools/planning.js.map +1 -1
  93. package/dist/tools/plugin-host.d.ts +2 -0
  94. package/dist/tools/plugin-host.d.ts.map +1 -0
  95. package/dist/tools/plugin-host.js +54 -0
  96. package/dist/tools/plugin-host.js.map +1 -0
  97. package/dist/tools/plugin-network-blocker.cjs +39 -0
  98. package/dist/tools/plugins.d.ts.map +1 -1
  99. package/dist/tools/plugins.js +344 -30
  100. package/dist/tools/plugins.js.map +1 -1
  101. package/dist/tools/router.d.ts +4 -0
  102. package/dist/tools/router.d.ts.map +1 -0
  103. package/dist/tools/router.js +39 -0
  104. package/dist/tools/router.js.map +1 -0
  105. package/dist/tools/tasks.d.ts +4 -0
  106. package/dist/tools/tasks.d.ts.map +1 -0
  107. package/dist/tools/tasks.js +71 -0
  108. package/dist/tools/tasks.js.map +1 -0
  109. package/docs/ai/agent-architecture.md +145 -0
  110. package/docs/ai/decisions.md +119 -1
  111. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0 - Final Hardening
4
+
5
+ ### Security & Reliability
6
+ - Hardened plugin registry mutations with a cross-process lock and atomic lockfile replacement.
7
+ - Plugin installation now cleans up partial destinations on failure and revalidates the copied manifest before fingerprinting.
8
+ - Final release verification covers build, type checking, the complete regression suite, dependency audit, diff hygiene, production boot, Codebase Memory isolation, plugin sandbox behavior, tamper detection, and concurrent plugin installation.
9
+ - No automatic publishing or registry distribution is performed by the release process.
10
+
11
+ ## 3.9.0 - Plugin Isolation & Ecosystem
12
+
13
+ ### Added
14
+ - Out-of-process MCP plugin hosting with short-lived child processes.
15
+ - Plugin manifest validation, SHA-256 installation fingerprints and fail-closed integrity verification.
16
+ - Namespaced plugin tools (`plugin_<name>__<tool>`) with token-scope and read-only gates.
17
+ - Node filesystem permission isolation, dedicated plugin `data/` write area, optional child-process permission, Linux network namespace isolation and deny-by-default network controls.
18
+ - Bounded plugin startup/execution time and explicit `RAMCP_PLUGIN_UNSANDBOXED=1` escape hatch for operators who intentionally accept local-trust execution.
19
+
20
+ ### Changed
21
+ - The old `trusted: true` in-process plugin model is no longer a security boundary and is not accepted by the installer.
22
+ - There is no automatic remote plugin registry/download path; plugin installation remains local and explicit.
23
+
3
24
  ## 3.1.2 - Critical Packaging Fix
4
25
 
5
26
  ### Fixed
package/README.md CHANGED
@@ -37,7 +37,7 @@ Remote Access MCP includes a bounded local worker pool for long-running or paral
37
37
  - Structured system/service diagnostics and persistent health watchers with webhook alerts.
38
38
  - MySQL/PostgreSQL/Redis query and schema tools using credentials held in environment variables.
39
39
  - MCP Resources and Prompts for operational context.
40
- - Trusted local plugin manifests and lifecycle management; plugins must explicitly declare `trusted: true` and execute in-process, so only install code you trust.
40
+ - Isolated local plugin lifecycle: manifests are validated and fingerprinted, plugin tools are namespaced, and installed plugins run out-of-process behind Node's filesystem permission model plus a Linux network sandbox. Plugin access requires the `plugins` scope; untrusted or unverifiable plugins are skipped fail-closed.
41
41
 
42
42
  ## Install
43
43
 
@@ -151,7 +151,7 @@ Get it ready-made: `ramcp url`
151
151
 
152
152
  Endpoint `https://your-domain.com/mcp` + header `Authorization: Bearer <token>`
153
153
 
154
- ## Tools (45+ built-in operational tools, plus jobs, transfers, diagnostics, database, monitoring, change sets, resources, prompts and plugins)
154
+ ## Tools (101 built-in operational tools, plus optional integration tools)
155
155
 
156
156
  The built-in tool count is stable. Optional MCP integrations can add additional namespaced tools when their upstream packages are available.
157
157
 
@@ -185,6 +185,65 @@ The built-in tool count is stable. Optional MCP integrations can add additional
185
185
 
186
186
  **Operations** (2) `environment_inspect` `nginx_inspect`
187
187
 
188
+ **Browser** (3) `browser_open` `browser_extract` `browser_screenshot` — optional Playwright runtime; public-URL SSRF guard; screenshots must stay inside the token path sandbox
189
+
190
+ **Infrastructure** (9) `infra_probe` `docker_ps` `docker_inspect` `docker_logs` `docker_action` `kubernetes_get` `kubernetes_describe` `kubernetes_logs` `cloudflare_status` — fixed executables and validated arguments; missing CLIs degrade cleanly
191
+
192
+ **Database** (2) `database_query` `database_schema` — MySQL/PostgreSQL/Redis support already provided by the existing adapter
193
+
194
+ ## Automation & Events
195
+
196
+ Automation rules are persistent, token-isolated workflows triggered by intervals or tool/webhook/file/health events. They support typed conditions, bounded action lists, manual triggering, enable/disable/delete lifecycle, execution counters, and webhook outcome notifications. Every action is executed through the normal token policy/read-only/audit wrapper; automation cannot invoke control-plane, approval, or plugin lifecycle tools. File triggers are constrained by the owner's path policy, payloads are bounded, and recursive automation chains are capped.
197
+
198
+ For external events, an authenticated webhook can POST to `/<token>/automation/webhook` with a JSON body such as `{"type":"deploy.finished","data":{"service":"api"}}`. The token selects the owner's rules; the token is never copied into the event payload. Scheduler/file/health execution is persistent and protected by a cross-process execution claim so multiple gateway processes do not intentionally execute the same rule concurrently.
199
+
200
+ ## Security & Autonomous Operations
201
+
202
+ Phase 7 adds `security_analysis` and `autonomy_check` plus bounded self-healing
203
+ through `recovery_rule_create`, `recovery_rule_list`, `recovery_incidents`, and
204
+ `recovery_trigger`. Recovery state is persistent and token-isolated, with
205
+ maximum attempts and cooldowns. Autonomous operations are **disabled by
206
+ default** and require `RAMCP_AUTONOMOUS=1`; high-risk and critical recovery
207
+ also require their respective explicit environment flags. Recovery actions use
208
+ the same policy, scope, read-only, audit, and context-wrapped tool execution as
209
+ normal requests, and cannot invoke approvals, plugins, automation lifecycle,
210
+ or recovery lifecycle tools.
211
+
212
+ ## Plugin Isolation & Ecosystem
213
+
214
+ Plugins are local, explicit installations. A plugin directory must contain a
215
+ `manifest.json` with a semver-like `version` and a relative `entry` exporting
216
+ `register(server, ctx)`. The gateway validates the tree, rejects symlinks and
217
+ oversized packages, stores a SHA-256 fingerprint, and verifies that fingerprint
218
+ before every child-process start. Plugin tools are exposed as
219
+ `plugin_<name>__<tool>` and require the `plugins` token scope; declared plugin
220
+ scopes must also be available to the token.
221
+
222
+ Example manifest:
223
+
224
+ ```json
225
+ {
226
+ "name": "my-plugin",
227
+ "version": "1.0.0",
228
+ "entry": "index.js",
229
+ "permissions": ["fs.write"],
230
+ "scopes": ["filesystem"]
231
+ }
232
+ ```
233
+
234
+ Runtime permissions are deliberately small: `fs.read` permits reads inside
235
+ the plugin directory, `fs.write` permits writes only under the plugin's
236
+ `data/` directory, and `process` permits child processes. Network access is
237
+ disabled by default. On Linux the child also gets a separate network namespace
238
+ and deny-by-default network filter. If the required sandbox is unavailable,
239
+ the plugin is skipped unless `RAMCP_PLUGIN_UNSANDBOXED=1` is explicitly set by
240
+ the operator. Plugin calls are short-lived and have a bounded execution time;
241
+ there are no persistent plugin worker processes.
242
+
243
+ The plugin host receives no token secret and no gateway mutation API. This is
244
+ an intentional break from the old in-process `trusted: true` model: declaring
245
+ trust inside a manifest is not considered a security boundary.
246
+
188
247
  ## Webhooks
189
248
 
190
249
  Get notified when tools run (or fail) — incident bots, Slack relays, anything that accepts a POST:
@@ -249,6 +308,49 @@ MIT — see [LICENSE](LICENSE).
249
308
 
250
309
  📚 [README فارسی](README.fa.md) | [Roadmap](ROADMAP.md) | [Security Policy](SECURITY.md) | [Changelog](CHANGELOG.md) | [Contributing](CONTRIBUTING.md)
251
310
 
311
+ ## Capability Router & Context Efficiency
312
+
313
+ Phase 2 adds a capability catalog and discovery layer for agent clients:
314
+ `capability_discover` returns only capabilities authorized for the current
315
+ token and includes context-cost and latency hints. `capability_batch` runs up
316
+ to eight independent read-only calls in parallel and rejects mutating actions.
317
+
318
+ For tokens with explicit scopes, `RAMCP_TOOL_EXPOSURE=scoped` can also reduce
319
+ `tools/list` itself to the authorized tool set. The default remains `all` for
320
+ backward compatibility. In the built-in benchmark, a scoped token exposed
321
+ 14 tools instead of 77 and reduced the serialized `tools/list` response by
322
+ 80.3% (30,802 → 6,054 bytes).
323
+
324
+ ## Task / Workflow / Agent Engine
325
+
326
+ Phase 3 adds durable orchestration through the `task` tool. A task contains a
327
+ validated action graph and can run independent actions in parallel while
328
+ respecting dependencies, retries, per-action timeouts, verification hooks,
329
+ dry-run mode, and compensation rollback. `supervised` tasks pause before
330
+ mutating actions and resume through `task_approve`; interrupted/failed tasks
331
+ can be resumed with `task_resume` because task state is persisted under RAMCP's
332
+ own data directory and isolated by token.
333
+
334
+ Specialized profiles are available through `agent_profiles` and optional action
335
+ assignment: `explorer`, `planner`, `implementer`, `tester`, `reviewer`,
336
+ `security`, and `deployer`. Profiles constrain capability scopes and autonomy;
337
+ they are deterministic execution roles, not hidden model instances. The
338
+ existing `task_status` tool remains backward compatible with plan tracking and
339
+ also reports workflow tasks.
340
+
341
+ ## Developer Intelligence
342
+
343
+ Phase 4 adds a compact developer-intelligence layer without replacing the existing policy core:
344
+
345
+ - `project_profile` / `project_profile_list` / `project_profile_set` keep per-token workspace knowledge under RAMCP's own data directory.
346
+ - `impact_analysis` builds a lightweight reverse dependency graph for changed source files.
347
+ - `git_intelligence` summarizes repository state, history, diff statistics, branches, and remotes without permitting arbitrary Git verbs.
348
+ - `github_repo`, `github_issues`, and `github_pull_request` provide read-only GitHub intelligence when `GITHUB_TOKEN` or `GH_TOKEN` is configured.
349
+ - `sentry_projects`, `sentry_issues`, and `sentry_issue` provide read-only Sentry intelligence when `SENTRY_AUTH_TOKEN` is configured.
350
+ - `developer_context_status` reports the Codebase Memory isolation contract, Context7 proxy, and Context Mode's local/client-side role.
351
+
352
+ GitHub and Sentry credentials are read only from environment variables and are never returned by these tools. Dynamic Context7 and Codebase Memory tools can be exposed to scoped tokens only through the explicit `integrations` scope.
353
+
252
354
  ## Optional MCP integrations
253
355
 
254
356
  Remote Access MCP can expose selected developer-context MCPs as namespaced tools:
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Stable contracts for the Agent Engine planned for 3.2+.
3
+ *
4
+ * This module intentionally contains types and small pure helpers only. It
5
+ * does not execute tools, inspect the host, or alter existing request
6
+ * semantics. Future Context/Router/Task layers build on these contracts.
7
+ */
8
+ export type RiskLevel = 'none' | 'low' | 'medium' | 'high' | 'critical';
9
+ export type ExecutionMode = 'read' | 'mutate' | 'background' | 'interactive';
10
+ export type AutonomyLevel = 'readonly' | 'safe' | 'supervised' | 'autonomous';
11
+ export type TaskState = 'queued' | 'planning' | 'awaiting_approval' | 'executing' | 'verifying' | 'completed' | 'failed' | 'rolled_back' | 'cancelled';
12
+ export interface AgentResult<T = unknown> {
13
+ ok: boolean;
14
+ summary: string;
15
+ data?: T;
16
+ warnings: string[];
17
+ errors: string[];
18
+ nextActions: string[];
19
+ /** Approximate result size in UTF-8 bytes, when measured by the producer. */
20
+ sizeBytes?: number;
21
+ /** Optional identifier for a persisted/streamed result. */
22
+ resultId?: string;
23
+ }
24
+ export interface CapabilityDescriptor {
25
+ id: string;
26
+ category: string;
27
+ description: string;
28
+ risk: RiskLevel;
29
+ executionMode: ExecutionMode;
30
+ requiredScopes: string[];
31
+ contextCost: number;
32
+ latencyHintMs?: number;
33
+ dependencies: string[];
34
+ supportsDryRun: boolean;
35
+ supportsVerification: boolean;
36
+ }
37
+ export interface ContextBudget {
38
+ total: number;
39
+ history: number;
40
+ tools: number;
41
+ memory: number;
42
+ reserved: number;
43
+ }
44
+ export interface TaskContext {
45
+ taskId: string;
46
+ goal: string;
47
+ autonomy: AutonomyLevel;
48
+ budget: ContextBudget;
49
+ facts: string[];
50
+ decisions: string[];
51
+ constraints: string[];
52
+ completedActions: string[];
53
+ }
54
+ export declare function createEmptyAgentResult<T>(summary: string, ok?: boolean): AgentResult<T>;
55
+ export declare function validateContextBudget(budget: ContextBudget): void;
56
+ export declare function canTransitionTask(from: TaskState, to: TaskState): boolean;
57
+ //# sourceMappingURL=agent-contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-contracts.d.ts","sourceRoot":"","sources":["../../src/core/agent-contracts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AACxE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC;AAC7E,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;AAE9E,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,UAAU,GACV,mBAAmB,GACnB,WAAW,GACX,WAAW,GACX,WAAW,GACX,QAAQ,GACR,aAAa,GACb,WAAW,CAAC;AAEhB,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,UAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAEpF;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CASjE;AAcD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,GAAG,OAAO,CAEzE"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Stable contracts for the Agent Engine planned for 3.2+.
3
+ *
4
+ * This module intentionally contains types and small pure helpers only. It
5
+ * does not execute tools, inspect the host, or alter existing request
6
+ * semantics. Future Context/Router/Task layers build on these contracts.
7
+ */
8
+ export function createEmptyAgentResult(summary, ok = true) {
9
+ return { ok, summary, warnings: [], errors: [], nextActions: [] };
10
+ }
11
+ export function validateContextBudget(budget) {
12
+ const values = [budget.total, budget.history, budget.tools, budget.memory, budget.reserved];
13
+ if (values.some(v => !Number.isFinite(v) || v < 0)) {
14
+ throw new Error('context budget values must be finite non-negative numbers');
15
+ }
16
+ const allocated = budget.history + budget.tools + budget.memory + budget.reserved;
17
+ if (allocated > budget.total) {
18
+ throw new Error('context budget allocations exceed total budget');
19
+ }
20
+ }
21
+ const TASK_TRANSITIONS = {
22
+ queued: ['planning', 'cancelled'],
23
+ planning: ['awaiting_approval', 'executing', 'failed', 'cancelled'],
24
+ awaiting_approval: ['executing', 'cancelled', 'failed'],
25
+ executing: ['verifying', 'completed', 'failed', 'rolled_back', 'cancelled'],
26
+ verifying: ['completed', 'failed', 'rolled_back', 'executing'],
27
+ completed: [],
28
+ failed: ['planning', 'executing', 'rolled_back', 'cancelled'],
29
+ rolled_back: ['planning', 'cancelled'],
30
+ cancelled: [],
31
+ };
32
+ export function canTransitionTask(from, to) {
33
+ return TASK_TRANSITIONS[from].includes(to);
34
+ }
35
+ //# sourceMappingURL=agent-contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-contracts.js","sourceRoot":"","sources":["../../src/core/agent-contracts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+DH,MAAM,UAAU,sBAAsB,CAAI,OAAe,EAAE,EAAE,GAAG,IAAI;IAClE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAqB;IACzD,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5F,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClF,IAAI,SAAS,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAA4C;IAChE,MAAM,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,EAAE,CAAC,mBAAmB,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC;IACnE,iBAAiB,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC;IACvD,SAAS,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC;IAC3E,SAAS,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC;IAC9D,SAAS,EAAE,EAAE;IACb,MAAM,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC;IAC7D,WAAW,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;IACtC,SAAS,EAAE,EAAE;CACd,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,IAAe,EAAE,EAAa;IAC9D,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type AgentProfileId = 'explorer' | 'planner' | 'implementer' | 'tester' | 'reviewer' | 'security' | 'deployer';
2
+ export interface AgentProfile {
3
+ id: AgentProfileId;
4
+ description: string;
5
+ allowedScopes: string[];
6
+ defaultAutonomy: 'readonly' | 'safe' | 'supervised' | 'autonomous';
7
+ }
8
+ export declare const AGENT_PROFILES: Record<AgentProfileId, AgentProfile>;
9
+ export declare function getAgentProfile(id: string): AgentProfile | undefined;
10
+ export declare function listAgentProfiles(): AgentProfile[];
11
+ //# sourceMappingURL=agent-profiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-profiles.d.ts","sourceRoot":"","sources":["../../src/core/agent-profiles.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,cAAc,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;CACpE;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,YAAY,CAQ/D,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAiD;AACtH,wBAAgB,iBAAiB,IAAI,YAAY,EAAE,CAA0C"}
@@ -0,0 +1,12 @@
1
+ export const AGENT_PROFILES = {
2
+ explorer: { id: 'explorer', description: 'Read-only environment and project inspection.', allowedScopes: ['system', 'logs', 'project', 'diagnostics', 'monitoring', 'filesystem', 'database', 'resources', 'context', 'router', 'intelligence', 'integrations', 'browser', 'infrastructure'], defaultAutonomy: 'readonly' },
3
+ planner: { id: 'planner', description: 'Read-only discovery and workflow planning.', allowedScopes: ['system', 'logs', 'project', 'diagnostics', 'filesystem', 'database', 'resources', 'context', 'router', 'intelligence', 'planning', 'integrations'], defaultAutonomy: 'readonly' },
4
+ implementer: { id: 'implementer', description: 'Controlled implementation using filesystem, git, jobs and planning tools.', allowedScopes: ['filesystem', 'git', 'jobs', 'planning', 'diagnostics', 'project', 'intelligence', 'browser', 'infrastructure'], defaultAutonomy: 'safe' },
5
+ tester: { id: 'tester', description: 'Run diagnostics and tests with bounded shell/job access.', allowedScopes: ['shell', 'jobs', 'filesystem', 'project', 'diagnostics', 'system', 'intelligence', 'browser', 'infrastructure'], defaultAutonomy: 'safe' },
6
+ reviewer: { id: 'reviewer', description: 'Read-only quality and regression review.', allowedScopes: ['filesystem', 'git', 'project', 'diagnostics', 'security', 'logs', 'system', 'database', 'resources', 'context', 'router', 'intelligence', 'integrations', 'browser', 'infrastructure'], defaultAutonomy: 'readonly' },
7
+ security: { id: 'security', description: 'Read-only security and policy analysis.', allowedScopes: ['security', 'filesystem', 'project', 'logs', 'system', 'diagnostics', 'resources', 'context', 'router', 'intelligence', 'integrations', 'browser', 'infrastructure'], defaultAutonomy: 'readonly' },
8
+ deployer: { id: 'deployer', description: 'Supervised deployment and service/package operations.', allowedScopes: ['filesystem', 'shell', 'git', 'jobs', 'transfer', 'planning', 'services', 'packages', 'diagnostics', 'monitoring', 'project', 'browser', 'infrastructure'], defaultAutonomy: 'supervised' },
9
+ };
10
+ export function getAgentProfile(id) { return AGENT_PROFILES[id]; }
11
+ export function listAgentProfiles() { return Object.values(AGENT_PROFILES); }
12
+ //# sourceMappingURL=agent-profiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-profiles.js","sourceRoot":"","sources":["../../src/core/agent-profiles.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,cAAc,GAAyC;IAClE,QAAQ,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,+CAA+C,EAAE,aAAa,EAAE,CAAC,QAAQ,EAAC,MAAM,EAAC,SAAS,EAAC,aAAa,EAAC,YAAY,EAAC,YAAY,EAAC,UAAU,EAAC,WAAW,EAAC,SAAS,EAAC,QAAQ,EAAC,cAAc,EAAC,cAAc,EAAC,SAAS,EAAC,gBAAgB,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE;IAC9S,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,4CAA4C,EAAE,aAAa,EAAE,CAAC,QAAQ,EAAC,MAAM,EAAC,SAAS,EA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,EAAE,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,uDAAuD,EAAE,aAAa,EAAE,CAAC,YAAY,EAAC,OAAO,EAAC,KAAK,EAAC,MAAM,EAAC,UAAU,EAAC,UAAU,EAAC,UAAU,EAAC,UAAU,EAAC,aAAa,EAAC,YAAY,EAAC,SAAS,EAAC,SAAS,EAAC,gBAAgB,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE;CAClS,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,EAAU,IAA8B,OAAO,cAAc,CAAC,EAAoB,CAAC,CAAC,CAAC,CAAC;AACtH,MAAM,UAAU,iBAAiB,KAAqB,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { RamcpConfig } from './config.js';
2
+ export type TriggerType = 'interval' | 'file' | 'health' | 'webhook' | 'tool';
3
+ export type ConditionOp = 'equals' | 'not_equals' | 'contains' | 'gt' | 'gte' | 'lt' | 'lte';
4
+ export interface AutomationCondition {
5
+ field: string;
6
+ op: ConditionOp;
7
+ value: string | number | boolean;
8
+ }
9
+ export interface AutomationAction {
10
+ tool: string;
11
+ args: Record<string, unknown>;
12
+ }
13
+ export interface AutomationRule {
14
+ id: string;
15
+ name: string;
16
+ tokenFingerprint: string;
17
+ enabled: boolean;
18
+ trigger: {
19
+ type: TriggerType;
20
+ intervalSeconds?: number;
21
+ path?: string;
22
+ event?: string;
23
+ tool?: string;
24
+ };
25
+ conditions: AutomationCondition[];
26
+ actions: AutomationAction[];
27
+ created: string;
28
+ lastRun?: string;
29
+ nextRun?: string;
30
+ runs: number;
31
+ failures: number;
32
+ }
33
+ export interface AutomationEvent {
34
+ type: string;
35
+ tool?: string;
36
+ data?: Record<string, unknown>;
37
+ tokenFingerprint?: string;
38
+ ts: number;
39
+ /** Prevent an automation action from recursively creating an infinite chain. */
40
+ origin?: 'external' | 'automation';
41
+ depth?: number;
42
+ }
43
+ export declare function tokenRules(tokenFingerprint: string): AutomationRule[];
44
+ export declare function automationPath(): string;
45
+ export declare function automationLockPath(): string;
46
+ export declare function clearAutomationRulesForTests(): void;
47
+ export declare function createRule(rule: Omit<AutomationRule, 'id' | 'created' | 'runs' | 'failures'>): AutomationRule;
48
+ export declare function deleteRule(tokenFingerprint: string, id: string): boolean;
49
+ export declare function setRuleEnabled(tokenFingerprint: string, id: string, enabled: boolean): boolean;
50
+ export declare function matchesConditions(rule: AutomationRule, event: AutomationEvent): boolean;
51
+ export declare function dispatchAutomationEvent(event: AutomationEvent, execute: (rule: AutomationRule, action: AutomationAction) => Promise<void>, cfg?: RamcpConfig): Promise<void>;
52
+ export declare function startAutomationEngine(execute: (rule: AutomationRule, action: AutomationAction) => Promise<void>, cfg?: RamcpConfig): NodeJS.Timeout;
53
+ //# sourceMappingURL=automation-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation-engine.d.ts","sourceRoot":"","sources":["../../src/core/automation-engine.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAC9E,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AAE7F,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,WAAW,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAA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