Logo Deterministic Agent Control Protocol

Deterministic Agent Control Protocol

Cộng đồng
elliot35

Governance gateway for AI agents — bounded, auditable, session-aware control with MCP proxy, shell proxy & HTTP API. Works with Cursor, Claude Code, Codex, and any MCP-compatible agent.

Nhà phát hànhelliot35
Kho mãdeterministic-agent-control-protocol
Ngôn ngữTypeScript
Bản fork
7
Sao
82
Công cụ có sẵn
0
Phương thức truyền tảistdio
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Deterministic Agent Control Protocol cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    82 sao và 7 bản fork từ kho mã được liên kết.

Self-Evolving Deterministic Agent Control Protocol

Stars Forks Contributors License npm version TypeScript Node.js

A governance gateway for AI agents — making every action bounded, auditable, reversible, and explainable.

Works transparently with Cursor, Claude Code, Codex, and any MCP-compatible agent. Also supports shell command governance and a language-agnostic HTTP API.

🛡️ Governance in Action

https://github.com/user-attachments/assets/ec7a9524-1527-4e51-b837-7e05a24b189d


Table of Contents


How It Works

Agents never execute tools directly. Every action flows through the control plane for evaluation, enforcement, and audit:

The protocol does not execute actions itself. It evaluates them against a policy, enforces session-level budgets, requires human approval for risky operations, and records everything in a tamper-evident audit ledger.


Core Principles

PrincipleDescription
BoundedAgents can only perform allowed actions within allowed scopes
Session-AwareBudget, rate limits, and escalation rules across the full interaction
AuditableEvery action logged in a tamper-evident ledger with SHA-256 hash chaining
ReversibleCompensation plans for undoing executed actions
ExplainableFull reporting — what was allowed, denied, gated, and why

Quick Start

Install

bash
npm i @det-acp/core

Set Up Governance (One Command)

bash
npx det-acp init cursor        # Cursor
npx det-acp init codex         # Codex CLI
npx det-acp init claude-code   # Claude Code

This generates all required files (policy, MCP config, governance rules) with sensible defaults. Edit policy.yaml to customize — everything else is handled automatically.

bash
# Use your own policy instead of the default
npx det-acp init cursor --policy ./my-policy.yaml

After running init, restart your agent to pick up the MCP server.

Define a Policy

Create agent.policy.yaml:

yaml
version: "1.0"
name: "my-agent"

capabilities:
  - tool: "file:read"
    scope:
      paths: ["./src/**"]
  - tool: "file:write"
    scope:
      paths: ["./src/**"]
  - tool: "command:run"
    scope:
      binaries: ["npm", "node", "tsc"]

limits:
  max_runtime_ms: 1800000
  max_files_changed: 50

gates:
  - action: "file:delete"
    approval: "human"
    risk_level: "high"

evidence:
  require: ["checksums", "diffs"]
  format: "jsonl"

forbidden:
  - pattern: "**/.env"
  - pattern: "rm -rf"

session:
  max_actions: 100
  max_denials: 10
  rate_limit:
    max_per_minute: 30
  escalation:
    - after_actions: 50
      require: human_checkin
    - after_minutes: 15
      require: human_checkin

Use as a Library

typescript
import { AgentGateway } from '@det-acp/core';

const gateway = await AgentGateway.create({
  ledgerDir: './ledgers',
  onStateChange: (sessionId, from, to) => console.log(`${from} -> ${to}`),
});

// Create a session
const session = await gateway.createSession('./agent.policy.yaml', {
  agent: 'my-coding-agent',
});

// Evaluate an action (does NOT execute it)
const verdict = await gateway.evaluate(session.id, {
  tool: 'file:read',
  input: { path: './src/index.ts' },
});

if (verdict.decision === 'allow') {
  // Execute the action yourself
  const content = fs.readFileSync('./src/index.ts', 'utf-8');

  // Record the result
  await gateway.recordResult(session.id, verdict.actionId, {
    success: true,
    output: content,
    durationMs: 5,
  });
}

// Terminate and get report
const report = await gateway.terminateSession(session.id, 'task complete');
console.log(`Allowed: ${report.allowed}, Denied: ${report.denied}`);

Agent Integrations

Ready-to-use guides for popular AI agents. Each integration includes policy, config templates, governance rules, test sandbox, and step-by-step instructions.

AgentIntegration ModeGovernance LevelGuide
CursorMCP Proxy + Cursor RulesSoftintegrations/cursor/
Codex CLIMCP Proxy + AGENTS.md + OS SandboxSoft + Sandboxintegrations/codex/
Claude CodeMCP Proxy + CLAUDE.md + settings.jsonSoft + Semi-Hardintegrations/claude-code/
OpenClawHTTP API + Skill + Docker SandboxHardintegrations/openclaw/
  • Soft — The LLM is instructed (via rules/instructions files) to prefer governed tools. Effective in practice, but a creative prompt could theoretically bypass it.
  • Semi-Hard — Soft instructions combined with the agent's built-in permission system that can deny direct tool access (e.g., Claude Code's settings.json).
  • Hard — The agent physically cannot access tools outside the governance layer. Achieved via Docker sandboxing, tool allow/deny lists, or custom agent harnesses.

For any MCP-compatible agent not listed above, see MCP Proxy (General).


Built-in Policies

Production-ready policies in examples/ — usable out of the box:

PolicyFileUse CaseTools Used
Coding Agentcoding-agent.policy.yamlAI coding agents operating on a project13 tools
DevOps Deploydevops-deploy.policy.yamlDeployment agents that build, test, and deploy code16 tools
Video Upscalervideo-upscaler.policy.yamlMedia processing agents running upscaling pipelines11 tools
Data Analystdata-analyst.policy.yamlData analysis agents processing datasets and generating reports12 tools
Security Auditsecurity-audit.policy.yamlSecurity scanning agents auditing code and dependencies11 tools
Infrastructure Managerinfrastructure-manager.policy.yamlInfrastructure management agents handling IaC, deployments, and monitoring16 tools

Validate any policy with: npx det-acp validate ./policy.yaml


Integration Modes

ModeHow It WorksBest For
MCP ProxyTransparent proxy between agent and MCP serversCursor, Claude Code, any MCP client
Shell ProxyCommand wrapper that validates before executingCLI agents, shell-based workflows
HTTP APIREST endpoints for session managementAny language, custom integrations
Library SDKTypeScript API for in-process governanceCustom TypeScript agents

MCP Proxy (General)

Works with any MCP-compatible client.

Simplified mode — point at a policy file, auto-configures filesystem backend:

bash
npx det-acp proxy --policy ./policy.yaml
npx det-acp proxy --policy ./policy.yaml --dir /path/to/project

For advanced setups with multiple backends, SSE transport, etc.:

bash
cat > mcp-proxy.config.yaml << 'EOF'
policy: ./agent.policy.yaml
ledger_dir: ./.det-acp/ledgers
transport: stdio
backends:
  - name: filesystem
    transport: stdio
    command: npx
    args: ["-y", "@modelcontextprotocol/server-filesystem", "./src"]
EOF

npx det-acp proxy ./mcp-proxy.config.yaml

Shell Proxy

Execute commands through the policy gateway:

bash
npx det-acp exec ./agent.policy.yaml echo "hello"    # Allowed
npx det-acp exec ./agent.policy.yaml rm -rf /tmp      # Denied (forbidden)

HTTP Session Server

bash
npx det-acp serve --port 3100
bash
# Create a session
curl -X POST http://localhost:3100/sessions \
  -H "Content-Type: application/json" \
  -d '{"policy": "version: \"1.0\"\nname: test\ncapabilities:\n  - tool: file:read\n    scope:\n      paths: [\"./src/**\"]"}'

# Evaluate an action
curl -X POST http://localhost:3100/sessions/<session-id>/evaluate \
  -H "Content-Type: application/json" \
  -d '{"action": {"tool": "file:read", "input": {"path": "./src/index.ts"}}}'

# Record result
curl -X POST http://localhost:3100/sessions/<session-id>/record \
  -H "Content-Type: application/json" \
  -d '{"actionId": "<action-id>", "result": {"success": true, "output": "..."}}'

# Terminate session
curl -X POST http://localhost:3100/sessions/<session-id>/terminate

CLI Reference

bash
npx det-acp init <agent>                  # Set up governance (cursor, codex, claude-code)
npx det-acp init <agent> --policy <file>  # Use custom policy
npx det-acp validate <policy-file>        # Validate a policy
npx det-acp proxy --policy <policy-file>  # Start MCP proxy (simplified)
npx det-acp proxy --policy <policy-file> --evolve  # With policy self-evolution
npx det-acp proxy <config-file>           # Start MCP proxy (full config)
npx det-acp exec <policy-file> <command>  # Execute via shell proxy
npx det-acp report <ledger-file>          # View audit report
npx det-acp serve [--port <port>]         # Start HTTP session server

Policy Self-Evolution

When an action is denied by the policy, the self-evolution feature can suggest a minimal policy change that would allow it, prompt you for a decision, and optionally update the policy (in memory and/or on disk). This keeps governance strict by default while letting you relax policy incrementally when you approve.

What it does

  • Analyses denials — Pattern-matches denial reasons (missing capability, path/binary/domain outside scope, forbidden pattern) and produces a single, minimal policy edit.
  • Prompts you — Presents the suggestion (e.g. “Add file:read capability for path ./config/**?”) via the agent’s own chat UI.
  • Three choices:
    • Add to policy — Apply the change to the session’s policy and persist it to the policy YAML file.
    • Allow once — Apply the change in memory only for the current session (no disk write).
    • Deny — Keep the block; no change.
  • Retry — After approval, the agent retries the original tool call against the updated policy.

Budget and session-limit denials (e.g. “Budget exceeded”, “Rate limit exceeded”) are not suggestible; only permission/scope/forbidden denials can trigger evolution.

How it works (MCP-native)

When running as an MCP proxy (the default for Cursor, Claude Code, and Codex), evolution uses a two-step asynchronous protocol built entirely on standard MCP tool calls — no terminal stdin/stdout required:

  1. On deny: The proxy returns the denial to the agent with a structured suggestion and a unique suggestion_id.
  2. On approve: The agent presents the suggestion to the user in chat, collects their decision, and calls policy_evolution_approve with the suggestion_id and decision.
  3. On retry: The proxy applies the policy change. The agent retries the original tool call, which now succeeds.

This works in every MCP client because it uses only the standard MCP tool-call protocol — no readline, no stdin conflicts.

Enabling self-evolution

MCP proxy (simplified mode):

bash
npx det-acp proxy --policy ./policy.yaml --evolve

The init command includes --evolve by default in generated MCP configurations.

Programmatic (library): pass policyEvolution in GatewayConfig for non-MCP setups (e.g. CLI scripts, custom agents):

typescript
import { AgentGateway, createCliEvolutionHandler } from '@det-acp/core';

const gateway = await AgentGateway.create({
  ledgerDir: './ledgers',
  policyEvolution: {
    policyPath: './agent.policy.yaml',
    handler: createCliEvolutionHandler(),
    timeoutMs: 30_000,
  },
});

You can plug a custom EvolutionHandler (e.g. GUI dialog, webhook) instead of createCliEvolutionHandler().

Evolution architecture (high level)

The Suggestion Engine maps denial reasons to one of: add capability, widen scope (paths/binaries/domains/methods/repos), or remove a forbidden pattern. In MCP proxy mode, the MCP Evolution Handler returns the suggestion to the agent as a structured denial with a suggestion_id, and the agent calls policy_evolution_approve after collecting the user’s decision. In library mode, the Policy Evolution Manager uses a pluggable handler (CLI, GUI, webhook) with a configurable timeout and re-evaluates the action inline.


Architecture

Component Architecture

Action Evaluation Flow

Session Lifecycle

Evidence Ledger

Every action produces an immutable audit record in JSONL format with SHA-256 hash chaining:

jsonl
{"seq":1,"ts":"...","hash":"sha256:abc...","prev":"sha256:000...","type":"session:start","data":{...}}
{"seq":2,"ts":"...","hash":"sha256:def...","prev":"sha256:abc...","type":"action:evaluate","data":{...}}
{"seq":3,"ts":"...","hash":"sha256:ghi...","prev":"sha256:def...","type":"action:result","data":{...}}

If any entry is tampered with, the hash chain breaks and integrity verification fails.


Policy DSL Reference

SectionPurpose
capabilitiesAllowed tools and their scoped paths, binaries, or domains
limitsRuntime, cost, file change, and retry budgets
gatesActions requiring human or webhook approval
evidenceArtifacts that must be recorded (checksums, diffs)
forbiddenPatterns that are always blocked
sessionMax actions, rate limits, escalation rules
remediationError handling rules and fallback chains

See examples/ for complete policy files.


Built-in Tool Adapters

File Operations

ToolDescriptionRollback
file:readRead files within scoped pathsN/A (read-only)
file:writeWrite files with backup for rollbackRestores previous content
file:deleteDelete files within scoped pathsRestores file from backup
file:moveMove/rename files within scoped pathsMoves file back to original location
file:copyCopy files within scoped pathsRemoves copied file

Directory Operations

ToolDescriptionRollback
directory:listList files and directories within scoped pathsN/A (read-only)
directory:createCreate directories within scoped pathsRemoves created directories

Command Execution

ToolDescriptionRollback
command:runExecute allow-listed binaries with timeoutCompensation actions

Git Operations

ToolDescriptionRollback
git:diffGet git diff outputN/A (read-only)
git:applyApply git patches with stash-based rollbackgit checkout . && git stash pop
git:commitStage and commit changesgit reset --soft HEAD~1
git:statusGet working tree statusN/A (read-only)

Network & HTTP

ToolDescriptionRollback
http:requestHTTP requests to allow-listed domainsCompensation actions
network:dnsDNS lookups for allow-listed domainsN/A (read-only)

Environment & System

ToolDescriptionRollback
env:readRead environment variables with auto-redaction of secretsN/A (read-only)
archive:extractExtract tar/zip archives within scoped pathsRemoves extracted files

Custom Tool Adapters

Extend the ToolAdapter base class to add your own tools:

typescript
import { ToolAdapter } from '@det-acp/core';
import { z } from 'zod';

class MyCustomTool extends ToolAdapter {
  readonly name = 'custom:mytool';
  readonly description = 'My custom tool';
  readonly inputSchema = z.object({
    target: z.string().min(1),
    options: z.record(z.string()).optional(),
  });

  validate(input, policy) { /* ... */ }
  async dryRun(input, ctx) { /* ... */ }
  async execute(input, ctx) { /* ... */ }
  async rollback(input, ctx) { /* ... */ }
}

// Register it
gateway.getRegistry().register(new MyCustomTool());

Every tool adapter follows the execution lifecycle: validate -> dryRun -> (gate check) -> execute -> verify. Each step is recorded in the evidence ledger.


Development

bash
npm install          # Install dependencies
npm run lint         # Type check (TypeScript strict)
npm test             # Run tests (Vitest)
npm run build        # Build

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository and create a feature branch
  2. Follow the coding standards (TypeScript strict, ESM, Zod validation)
  3. Write tests mirroring src/ structure under tests/
  4. Run npm test && npm run lint before submitting
  5. Use Conventional Commits for commit messages
  6. Open a PR with a clear description of changes

License

MIT


Star History

Star History Chart

Dùng MCP Deterministic Agent Control Protocol với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Deterministic Agent Control Protocol, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Deterministic Agent Control Protocol làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Deterministic Agent Control Protocol.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "deterministic-agent-control-protocol": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Deterministic Agent Control Protocol, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Deterministic Agent Control Protocol.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Deterministic Agent Control Protocol giúp tôi làm việc này không?
Deterministic Agent Control Protocol
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Deterministic Agent Control Protocol.

Câu hỏi thường gặp

Máy chủ MCP Deterministic Agent Control Protocol dùng để làm gì?

Deterministic Agent Control Protocol là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Deterministic Agent Control Protocol với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Deterministic Agent Control Protocol với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Deterministic Agent Control Protocol với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Deterministic Agent Control Protocol, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Deterministic Agent Control Protocol với TypingMind?

Deterministic Agent Control Protocol hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Deterministic Agent Control Protocol cung cấp những công cụ nào trong TypingMind?

Deterministic Agent Control Protocol cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Deterministic Agent Control Protocol không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Deterministic Agent Control Protocol yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇