@det-acp/core 0.2.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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +492 -0
  3. package/dist/cli/index.d.ts +15 -0
  4. package/dist/cli/index.d.ts.map +1 -0
  5. package/dist/cli/index.js +308 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/cli/init.d.ts +32 -0
  8. package/dist/cli/init.d.ts.map +1 -0
  9. package/dist/cli/init.js +234 -0
  10. package/dist/cli/init.js.map +1 -0
  11. package/dist/cli/templates.d.ts +27 -0
  12. package/dist/cli/templates.d.ts.map +1 -0
  13. package/dist/cli/templates.js +266 -0
  14. package/dist/cli/templates.js.map +1 -0
  15. package/dist/engine/action-registry.d.ts +49 -0
  16. package/dist/engine/action-registry.d.ts.map +1 -0
  17. package/dist/engine/action-registry.js +95 -0
  18. package/dist/engine/action-registry.js.map +1 -0
  19. package/dist/engine/gate.d.ts +57 -0
  20. package/dist/engine/gate.d.ts.map +1 -0
  21. package/dist/engine/gate.js +145 -0
  22. package/dist/engine/gate.js.map +1 -0
  23. package/dist/engine/runtime.d.ts +98 -0
  24. package/dist/engine/runtime.d.ts.map +1 -0
  25. package/dist/engine/runtime.js +138 -0
  26. package/dist/engine/runtime.js.map +1 -0
  27. package/dist/engine/session.d.ts +74 -0
  28. package/dist/engine/session.d.ts.map +1 -0
  29. package/dist/engine/session.js +343 -0
  30. package/dist/engine/session.js.map +1 -0
  31. package/dist/index.d.ts +48 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +56 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/ledger/ledger.d.ts +58 -0
  36. package/dist/ledger/ledger.d.ts.map +1 -0
  37. package/dist/ledger/ledger.js +188 -0
  38. package/dist/ledger/ledger.js.map +1 -0
  39. package/dist/ledger/query.d.ts +29 -0
  40. package/dist/ledger/query.d.ts.map +1 -0
  41. package/dist/ledger/query.js +61 -0
  42. package/dist/ledger/query.js.map +1 -0
  43. package/dist/ledger/types.d.ts +27 -0
  44. package/dist/ledger/types.d.ts.map +1 -0
  45. package/dist/ledger/types.js +5 -0
  46. package/dist/ledger/types.js.map +1 -0
  47. package/dist/policy/evaluator.d.ts +21 -0
  48. package/dist/policy/evaluator.d.ts.map +1 -0
  49. package/dist/policy/evaluator.js +383 -0
  50. package/dist/policy/evaluator.js.map +1 -0
  51. package/dist/policy/loader.d.ts +27 -0
  52. package/dist/policy/loader.d.ts.map +1 -0
  53. package/dist/policy/loader.js +69 -0
  54. package/dist/policy/loader.js.map +1 -0
  55. package/dist/policy/schema.d.ts +168 -0
  56. package/dist/policy/schema.d.ts.map +1 -0
  57. package/dist/policy/schema.js +107 -0
  58. package/dist/policy/schema.js.map +1 -0
  59. package/dist/proxy/mcp-proxy.d.ts +43 -0
  60. package/dist/proxy/mcp-proxy.d.ts.map +1 -0
  61. package/dist/proxy/mcp-proxy.js +240 -0
  62. package/dist/proxy/mcp-proxy.js.map +1 -0
  63. package/dist/proxy/mcp-types.d.ts +79 -0
  64. package/dist/proxy/mcp-types.d.ts.map +1 -0
  65. package/dist/proxy/mcp-types.js +28 -0
  66. package/dist/proxy/mcp-types.js.map +1 -0
  67. package/dist/proxy/shell-proxy.d.ts +52 -0
  68. package/dist/proxy/shell-proxy.d.ts.map +1 -0
  69. package/dist/proxy/shell-proxy.js +92 -0
  70. package/dist/proxy/shell-proxy.js.map +1 -0
  71. package/dist/rollback/manager.d.ts +62 -0
  72. package/dist/rollback/manager.d.ts.map +1 -0
  73. package/dist/rollback/manager.js +151 -0
  74. package/dist/rollback/manager.js.map +1 -0
  75. package/dist/server/server.d.ts +24 -0
  76. package/dist/server/server.d.ts.map +1 -0
  77. package/dist/server/server.js +200 -0
  78. package/dist/server/server.js.map +1 -0
  79. package/dist/tools/base.d.ts +58 -0
  80. package/dist/tools/base.d.ts.map +1 -0
  81. package/dist/tools/base.js +48 -0
  82. package/dist/tools/base.js.map +1 -0
  83. package/dist/tools/command-run.d.ts +30 -0
  84. package/dist/tools/command-run.d.ts.map +1 -0
  85. package/dist/tools/command-run.js +87 -0
  86. package/dist/tools/command-run.js.map +1 -0
  87. package/dist/tools/file-read.d.ts +34 -0
  88. package/dist/tools/file-read.d.ts.map +1 -0
  89. package/dist/tools/file-read.js +67 -0
  90. package/dist/tools/file-read.js.map +1 -0
  91. package/dist/tools/file-write.d.ts +39 -0
  92. package/dist/tools/file-write.d.ts.map +1 -0
  93. package/dist/tools/file-write.js +158 -0
  94. package/dist/tools/file-write.js.map +1 -0
  95. package/dist/tools/git.d.ts +48 -0
  96. package/dist/tools/git.d.ts.map +1 -0
  97. package/dist/tools/git.js +193 -0
  98. package/dist/tools/git.js.map +1 -0
  99. package/dist/tools/http-request.d.ts +48 -0
  100. package/dist/tools/http-request.d.ts.map +1 -0
  101. package/dist/tools/http-request.js +91 -0
  102. package/dist/tools/http-request.js.map +1 -0
  103. package/dist/types.d.ts +257 -0
  104. package/dist/types.d.ts.map +1 -0
  105. package/dist/types.js +8 -0
  106. package/dist/types.js.map +1 -0
  107. package/examples/coding-agent.policy.yaml +80 -0
  108. package/examples/devops-deploy.policy.yaml +107 -0
  109. package/examples/mcp-proxy.config.yaml +34 -0
  110. package/examples/simple-session.ts +161 -0
  111. package/examples/video-upscaler.policy.yaml +86 -0
  112. package/package.json +92 -0
  113. package/schemas/generate.ts +18 -0
  114. package/schemas/policy.schema.json +7 -0
@@ -0,0 +1,308 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Deterministic Agent Control Protocol CLI
4
+ *
5
+ * Commands:
6
+ * init <integration> Set up governance for cursor, codex, or claude-code
7
+ * validate <policy.yaml> Validate a policy file
8
+ * serve Start the HTTP session server
9
+ * proxy [config.yaml] Start the MCP proxy server
10
+ * proxy --policy <policy.yaml> Start MCP proxy with auto-configured defaults
11
+ * exec <policy.yaml> -- <command> Execute a command through the shell proxy
12
+ * report <ledger-file> Show ledger summary
13
+ */
14
+ import { Command } from 'commander';
15
+ import fs from 'node:fs';
16
+ import path from 'node:path';
17
+ import yaml from 'js-yaml';
18
+ import { loadPolicyFromFile, PolicyValidationError } from '../policy/loader.js';
19
+ import { AgentGateway } from '../engine/runtime.js';
20
+ import { EvidenceLedger } from '../ledger/ledger.js';
21
+ import { summarizeSessionLedger } from '../ledger/query.js';
22
+ import { ShellProxy } from '../proxy/shell-proxy.js';
23
+ import { MCPProxyServer } from '../proxy/mcp-proxy.js';
24
+ import { MCPProxyConfigSchema } from '../proxy/mcp-types.js';
25
+ import { registerInitCommand } from './init.js';
26
+ const program = new Command();
27
+ program
28
+ .name('det-acp')
29
+ .description('Deterministic Agent Control Protocol — Agent Governance Gateway')
30
+ .version('0.2.0');
31
+ // ---------------------------------------------------------------------------
32
+ // validate
33
+ // ---------------------------------------------------------------------------
34
+ program
35
+ .command('validate')
36
+ .description('Validate a policy YAML file')
37
+ .argument('<policy>', 'Path to policy YAML file')
38
+ .action(async (policyPath) => {
39
+ try {
40
+ const policy = loadPolicyFromFile(policyPath);
41
+ console.log('Policy is valid.');
42
+ console.log(` Name: ${policy.name}`);
43
+ console.log(` Version: ${policy.version}`);
44
+ console.log(` Capabilities: ${policy.capabilities.length}`);
45
+ console.log(` Gates: ${policy.gates.length}`);
46
+ console.log(` Forbidden patterns: ${policy.forbidden.length}`);
47
+ if (policy.limits.max_runtime_ms) {
48
+ console.log(` Max runtime: ${policy.limits.max_runtime_ms}ms`);
49
+ }
50
+ if (policy.limits.max_files_changed) {
51
+ console.log(` Max files changed: ${policy.limits.max_files_changed}`);
52
+ }
53
+ if (policy.session) {
54
+ console.log(' Session constraints:');
55
+ if (policy.session.max_actions) {
56
+ console.log(` Max actions: ${policy.session.max_actions}`);
57
+ }
58
+ if (policy.session.max_denials) {
59
+ console.log(` Max denials: ${policy.session.max_denials}`);
60
+ }
61
+ if (policy.session.rate_limit) {
62
+ console.log(` Rate limit: ${policy.session.rate_limit.max_per_minute}/min`);
63
+ }
64
+ if (policy.session.escalation) {
65
+ console.log(` Escalation rules: ${policy.session.escalation.length}`);
66
+ }
67
+ }
68
+ process.exit(0);
69
+ }
70
+ catch (err) {
71
+ if (err instanceof PolicyValidationError) {
72
+ console.error('Policy validation failed:');
73
+ for (const issue of err.issues) {
74
+ console.error(` ${issue.path ? issue.path + ': ' : ''}${issue.message}`);
75
+ }
76
+ }
77
+ else {
78
+ console.error(`Error: ${err.message}`);
79
+ }
80
+ process.exit(1);
81
+ }
82
+ });
83
+ // ---------------------------------------------------------------------------
84
+ // exec
85
+ // ---------------------------------------------------------------------------
86
+ program
87
+ .command('exec')
88
+ .description('Execute a command through the shell proxy (validates against policy)')
89
+ .argument('<policy>', 'Path to policy YAML file')
90
+ .argument('<command...>', 'Command to execute')
91
+ .option('--ledger-dir <dir>', 'Directory for ledger files', '.det-acp/ledgers')
92
+ .action(async (policyPath, commandParts, opts) => {
93
+ try {
94
+ const command = commandParts.join(' ');
95
+ const ledgerDir = path.resolve(opts.ledgerDir);
96
+ const gateway = await AgentGateway.create({ ledgerDir });
97
+ const session = await gateway.createSession(policyPath);
98
+ const shell = new ShellProxy(gateway, session.id);
99
+ console.log(`Session: ${session.id}`);
100
+ console.log(`Command: ${command}`);
101
+ console.log('');
102
+ const result = await shell.exec(command);
103
+ if (!result.allowed) {
104
+ console.error('DENIED by policy:');
105
+ for (const reason of result.denied?.reasons ?? []) {
106
+ console.error(` ${reason}`);
107
+ }
108
+ await gateway.terminateSession(session.id, 'Command denied');
109
+ process.exit(1);
110
+ }
111
+ if (result.stdout) {
112
+ process.stdout.write(result.stdout);
113
+ }
114
+ if (result.stderr) {
115
+ process.stderr.write(result.stderr);
116
+ }
117
+ await gateway.terminateSession(session.id, 'Command completed');
118
+ process.exit(result.exitCode ?? 0);
119
+ }
120
+ catch (err) {
121
+ console.error(`Error: ${err.message}`);
122
+ process.exit(1);
123
+ }
124
+ });
125
+ // ---------------------------------------------------------------------------
126
+ // proxy
127
+ // ---------------------------------------------------------------------------
128
+ program
129
+ .command('proxy')
130
+ .description('Start the MCP proxy server')
131
+ .argument('[config]', 'Path to MCP proxy config YAML file')
132
+ .option('--policy <path>', 'Path to policy YAML file (simplified mode — auto-configures filesystem backend at cwd)')
133
+ .option('--dir <path>', 'Project directory for filesystem backend (default: policy file parent dir)')
134
+ .option('--ledger-dir <dir>', 'Directory for ledger files (default: .det-acp/ledgers in project dir)')
135
+ .action(async (configPath, opts) => {
136
+ try {
137
+ let proxyConfig;
138
+ if (opts.policy) {
139
+ // ----- Simplified mode: --policy flag ---------------------------------
140
+ const policyPath = path.resolve(opts.policy);
141
+ if (!fs.existsSync(policyPath)) {
142
+ console.error(`Policy file not found: ${policyPath}`);
143
+ process.exit(1);
144
+ }
145
+ const projectDir = opts.dir
146
+ ? path.resolve(opts.dir)
147
+ : path.dirname(policyPath);
148
+ const ledgerDir = opts.ledgerDir
149
+ ? path.resolve(opts.ledgerDir)
150
+ : path.resolve(projectDir, '.det-acp', 'ledgers');
151
+ proxyConfig = {
152
+ policy: policyPath,
153
+ ledgerDir,
154
+ transport: 'stdio',
155
+ backends: [
156
+ {
157
+ name: 'filesystem',
158
+ transport: 'stdio',
159
+ command: 'npx',
160
+ args: ['-y', '@modelcontextprotocol/server-filesystem', projectDir],
161
+ },
162
+ ],
163
+ };
164
+ }
165
+ else if (configPath) {
166
+ // ----- Config file mode (existing behaviour) --------------------------
167
+ const absPath = path.resolve(configPath);
168
+ if (!fs.existsSync(absPath)) {
169
+ console.error(`Config file not found: ${absPath}`);
170
+ process.exit(1);
171
+ }
172
+ const rawYaml = fs.readFileSync(absPath, 'utf-8');
173
+ const parsed = yaml.load(rawYaml);
174
+ const validated = MCPProxyConfigSchema.parse(parsed);
175
+ proxyConfig = {
176
+ policy: path.resolve(path.dirname(absPath), validated.policy),
177
+ ledgerDir: path.resolve(validated.ledger_dir),
178
+ backends: validated.backends,
179
+ transport: validated.transport,
180
+ port: validated.port,
181
+ host: validated.host,
182
+ sessionMetadata: validated.session_metadata,
183
+ };
184
+ }
185
+ else {
186
+ console.error('Either <config> argument or --policy <path> option is required.');
187
+ console.error('');
188
+ console.error(' Usage:');
189
+ console.error(' det-acp proxy <config.yaml> # Full config file');
190
+ console.error(' det-acp proxy --policy <policy.yaml> # Simplified mode');
191
+ process.exit(1);
192
+ return; // unreachable but helps TS narrow types
193
+ }
194
+ const gateway = await AgentGateway.create({
195
+ ledgerDir: proxyConfig.ledgerDir,
196
+ });
197
+ const proxy = new MCPProxyServer(proxyConfig, gateway);
198
+ console.error('Starting MCP proxy server...');
199
+ console.error(` Transport: ${proxyConfig.transport}`);
200
+ console.error(` Backends: ${proxyConfig.backends.map((b) => b.name).join(', ')}`);
201
+ await proxy.start();
202
+ // Handle graceful shutdown
203
+ const shutdown = async () => {
204
+ console.error('\nShutting down MCP proxy...');
205
+ await proxy.stop();
206
+ process.exit(0);
207
+ };
208
+ process.on('SIGINT', shutdown);
209
+ process.on('SIGTERM', shutdown);
210
+ }
211
+ catch (err) {
212
+ console.error(`Error: ${err.message}`);
213
+ process.exit(1);
214
+ }
215
+ });
216
+ // ---------------------------------------------------------------------------
217
+ // report
218
+ // ---------------------------------------------------------------------------
219
+ program
220
+ .command('report')
221
+ .description('Show the ledger summary for a session')
222
+ .argument('<ledger-file>', 'Path to the session ledger JSONL file')
223
+ .action(async (ledgerPath) => {
224
+ try {
225
+ const absPath = path.resolve(ledgerPath);
226
+ if (!fs.existsSync(absPath)) {
227
+ console.error(`Ledger file not found: ${absPath}`);
228
+ process.exit(1);
229
+ }
230
+ // Verify integrity
231
+ const integrity = EvidenceLedger.verifyIntegrity(absPath);
232
+ console.log('--- Ledger Integrity ---');
233
+ console.log(`Valid: ${integrity.valid}`);
234
+ console.log(`Entries: ${integrity.totalEntries}`);
235
+ if (!integrity.valid) {
236
+ console.log(`Broken at: seq ${integrity.brokenAt}`);
237
+ console.log(`Error: ${integrity.error}`);
238
+ }
239
+ // Read and summarize
240
+ const content = fs.readFileSync(absPath, 'utf-8').trim();
241
+ if (content.length === 0) {
242
+ console.log('Ledger is empty.');
243
+ process.exit(0);
244
+ }
245
+ const entries = content.split('\n').map((line) => JSON.parse(line));
246
+ const sessionId = entries[0]?.sessionId;
247
+ if (sessionId) {
248
+ const summary = summarizeSessionLedger(entries, sessionId);
249
+ console.log(`\n--- Session Summary (${sessionId}) ---`);
250
+ console.log(`Total entries: ${summary.totalEntries}`);
251
+ console.log(`Actions evaluated: ${summary.actionsEvaluated}`);
252
+ console.log(` Allowed: ${summary.actionsAllowed}`);
253
+ console.log(` Denied: ${summary.actionsDenied}`);
254
+ console.log(` Gated: ${summary.actionsGated}`);
255
+ console.log(`Results recorded: ${summary.resultsRecorded}`);
256
+ console.log(`Actions rolled back: ${summary.actionsRolledBack}`);
257
+ console.log(`Gates requested: ${summary.gatesRequested}`);
258
+ console.log(`Gates approved: ${summary.gatesApproved}`);
259
+ console.log(`Gates rejected: ${summary.gatesRejected}`);
260
+ console.log(`Escalations triggered: ${summary.escalationsTriggered}`);
261
+ if (summary.stateChanges.length > 0) {
262
+ console.log(`State changes: ${summary.stateChanges.join(' → ')}`);
263
+ }
264
+ if (summary.errors.length > 0) {
265
+ console.log(`Errors: ${summary.errors.join('; ')}`);
266
+ }
267
+ }
268
+ process.exit(0);
269
+ }
270
+ catch (err) {
271
+ console.error(`Error: ${err.message}`);
272
+ process.exit(1);
273
+ }
274
+ });
275
+ // ---------------------------------------------------------------------------
276
+ // serve
277
+ // ---------------------------------------------------------------------------
278
+ program
279
+ .command('serve')
280
+ .description('Start the HTTP session server')
281
+ .option('-h, --host <host>', 'Host to bind to', '127.0.0.1')
282
+ .option('-p, --port <port>', 'Port to listen on', '3100')
283
+ .option('--ledger-dir <dir>', 'Directory for ledger files', '.det-acp/ledgers')
284
+ .action(async (opts) => {
285
+ try {
286
+ const { startServer } = await import('../server/server.js');
287
+ await startServer({
288
+ host: opts.host,
289
+ port: parseInt(opts.port),
290
+ gatewayConfig: {
291
+ ledgerDir: path.resolve(opts.ledgerDir),
292
+ },
293
+ });
294
+ }
295
+ catch (err) {
296
+ console.error(`Failed to start server: ${err.message}`);
297
+ process.exit(1);
298
+ }
299
+ });
300
+ // ---------------------------------------------------------------------------
301
+ // init
302
+ // ---------------------------------------------------------------------------
303
+ registerInitCommand(program);
304
+ // ---------------------------------------------------------------------------
305
+ // Parse and execute
306
+ // ---------------------------------------------------------------------------
307
+ program.parse();
308
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,iEAAiE,CAAC;KAC9E,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,6BAA6B,C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;AACH,CAAC,CAAC,CAAC;AAEL,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAE9E,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,+BAA+B,CAAC;KAC5C,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,WAAW,CAAC;KAC3D,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,CAAC;KACxD,MAAM,CAAC,oBAAoB,EAAE,4BAA4B,EAAE,kBAAkB,CAAC;KAC9E,MAAM,CAAC,KAAK,EAAE,IAAuD,EAAE,EAAE;IACxE,IAAI,CAAC;QACH,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAC5D,MAAM,WAAW,CAAC;YAChB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YACzB,aAAa,EAAE;gBACb,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;aACxC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,2BAA4B,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,8EAA8E;AAC9E,OAAO;AACP,8EAA8E;AAE9E,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAE7B,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * `det-acp init <integration>` command.
3
+ *
4
+ * Scaffolds all required files for a given integration (cursor, codex,
5
+ * claude-code) so users can get started with a single command.
6
+ *
7
+ * The only file a user may want to customize afterwards is policy.yaml.
8
+ */
9
+ import type { Command } from 'commander';
10
+ type Integration = 'cursor' | 'codex' | 'claude-code';
11
+ interface FileToWrite {
12
+ /** Absolute path */
13
+ path: string;
14
+ /** File content */
15
+ content: string;
16
+ /** Short label for display (relative to project root) */
17
+ label: string;
18
+ /** Description shown next to the file in output */
19
+ description: string;
20
+ }
21
+ interface InitResult {
22
+ created: FileToWrite[];
23
+ skipped: FileToWrite[];
24
+ }
25
+ export interface InitOptions {
26
+ policy?: string;
27
+ force?: boolean;
28
+ }
29
+ export declare function runInit(integration: Integration, opts: InitOptions): InitResult;
30
+ export declare function registerInitCommand(program: Command): void;
31
+ export {};
32
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBzC,KAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAC;AAEtD,UAAU,WAAW;IACnB,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,UAAU;IAClB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AA0HD,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAqD/E;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsE1D"}
@@ -0,0 +1,234 @@
1
+ /**
2
+ * `det-acp init <integration>` command.
3
+ *
4
+ * Scaffolds all required files for a given integration (cursor, codex,
5
+ * claude-code) so users can get started with a single command.
6
+ *
7
+ * The only file a user may want to customize afterwards is policy.yaml.
8
+ */
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
11
+ import { DEFAULT_POLICY, GOVERNANCE_MDC, CLAUDE_MD, AGENTS_MD, CLAUDE_SETTINGS_JSON, generateCursorMcpJson, generateClaudeCodeMcpJson, generateCodexConfigToml, } from './templates.js';
12
+ // ---------------------------------------------------------------------------
13
+ // Helpers
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * Resolve the absolute path to the CLI entry point (dist/cli/index.js).
17
+ * This is used when generating mcp.json / config.toml so the MCP server
18
+ * can be spawned with `node <cliPath> proxy --policy <policy>`.
19
+ */
20
+ function resolveCliPath() {
21
+ // process.argv[1] is the script being executed, which is dist/cli/index.js
22
+ // when run via `node dist/cli/index.js` or via the `det-acp` bin link.
23
+ return path.resolve(process.argv[1]);
24
+ }
25
+ /**
26
+ * Ensure a directory exists, creating intermediate dirs as needed.
27
+ */
28
+ function ensureDir(dir) {
29
+ if (!fs.existsSync(dir)) {
30
+ fs.mkdirSync(dir, { recursive: true });
31
+ }
32
+ }
33
+ /**
34
+ * Write a file only if it doesn't exist or --force is set.
35
+ * Returns true if the file was written, false if skipped.
36
+ */
37
+ function writeIfNeeded(file, force) {
38
+ if (fs.existsSync(file.path) && !force) {
39
+ return false;
40
+ }
41
+ ensureDir(path.dirname(file.path));
42
+ fs.writeFileSync(file.path, file.content, 'utf-8');
43
+ return true;
44
+ }
45
+ // ---------------------------------------------------------------------------
46
+ // File manifests per integration
47
+ // ---------------------------------------------------------------------------
48
+ function cursorFiles(projectDir, policyAbsPath, cliPath) {
49
+ return [
50
+ {
51
+ path: policyAbsPath,
52
+ content: DEFAULT_POLICY,
53
+ label: path.relative(projectDir, policyAbsPath),
54
+ description: 'governance policy (edit to customize)',
55
+ },
56
+ {
57
+ path: path.join(projectDir, '.cursor', 'mcp.json'),
58
+ content: generateCursorMcpJson(cliPath, policyAbsPath),
59
+ label: '.cursor/mcp.json',
60
+ description: 'MCP server registration',
61
+ },
62
+ {
63
+ path: path.join(projectDir, '.cursor', 'rules', 'governance.mdc'),
64
+ content: GOVERNANCE_MDC,
65
+ label: '.cursor/rules/governance.mdc',
66
+ description: 'agent governance rule',
67
+ },
68
+ ];
69
+ }
70
+ function codexFiles(projectDir, policyAbsPath, cliPath) {
71
+ return [
72
+ {
73
+ path: policyAbsPath,
74
+ content: DEFAULT_POLICY,
75
+ label: path.relative(projectDir, policyAbsPath),
76
+ description: 'governance policy (edit to customize)',
77
+ },
78
+ {
79
+ path: path.join(projectDir, '.codex', 'config.toml'),
80
+ content: generateCodexConfigToml(cliPath, policyAbsPath),
81
+ label: '.codex/config.toml',
82
+ description: 'Codex config with MCP server registration',
83
+ },
84
+ {
85
+ path: path.join(projectDir, 'AGENTS.md'),
86
+ content: AGENTS_MD,
87
+ label: 'AGENTS.md',
88
+ description: 'agent governance instructions',
89
+ },
90
+ ];
91
+ }
92
+ function claudeCodeFiles(projectDir, policyAbsPath, cliPath) {
93
+ return [
94
+ {
95
+ path: policyAbsPath,
96
+ content: DEFAULT_POLICY,
97
+ label: path.relative(projectDir, policyAbsPath),
98
+ description: 'governance policy (edit to customize)',
99
+ },
100
+ {
101
+ path: path.join(projectDir, '.mcp.json'),
102
+ content: generateClaudeCodeMcpJson(cliPath, policyAbsPath),
103
+ label: '.mcp.json',
104
+ description: 'MCP server registration',
105
+ },
106
+ {
107
+ path: path.join(projectDir, 'CLAUDE.md'),
108
+ content: CLAUDE_MD,
109
+ label: 'CLAUDE.md',
110
+ description: 'agent governance instructions',
111
+ },
112
+ {
113
+ path: path.join(projectDir, '.claude', 'settings.json'),
114
+ content: CLAUDE_SETTINGS_JSON,
115
+ label: '.claude/settings.json',
116
+ description: 'deny built-in file tools (semi-hard enforcement)',
117
+ },
118
+ ];
119
+ }
120
+ export function runInit(integration, opts) {
121
+ const projectDir = process.cwd();
122
+ const cliPath = resolveCliPath();
123
+ // Determine the policy file path
124
+ let policyAbsPath;
125
+ let customPolicy = false;
126
+ if (opts.policy) {
127
+ policyAbsPath = path.resolve(opts.policy);
128
+ customPolicy = true;
129
+ if (!fs.existsSync(policyAbsPath)) {
130
+ throw new Error(`Policy file not found: ${policyAbsPath}`);
131
+ }
132
+ }
133
+ else {
134
+ policyAbsPath = path.join(projectDir, 'policy.yaml');
135
+ }
136
+ // Get the file manifest for this integration
137
+ let files;
138
+ switch (integration) {
139
+ case 'cursor':
140
+ files = cursorFiles(projectDir, policyAbsPath, cliPath);
141
+ break;
142
+ case 'codex':
143
+ files = codexFiles(projectDir, policyAbsPath, cliPath);
144
+ break;
145
+ case 'claude-code':
146
+ files = claudeCodeFiles(projectDir, policyAbsPath, cliPath);
147
+ break;
148
+ default:
149
+ throw new Error(`Unknown integration: ${integration}`);
150
+ }
151
+ // If a custom policy was provided, skip writing the default policy
152
+ if (customPolicy) {
153
+ files = files.filter((f) => f.path !== policyAbsPath);
154
+ }
155
+ // Write files
156
+ const created = [];
157
+ const skipped = [];
158
+ for (const file of files) {
159
+ const written = writeIfNeeded(file, opts.force ?? false);
160
+ if (written) {
161
+ created.push(file);
162
+ }
163
+ else {
164
+ skipped.push(file);
165
+ }
166
+ }
167
+ return { created, skipped };
168
+ }
169
+ // ---------------------------------------------------------------------------
170
+ // CLI command registration
171
+ // ---------------------------------------------------------------------------
172
+ export function registerInitCommand(program) {
173
+ program
174
+ .command('init')
175
+ .description('Set up governance for an AI agent integration')
176
+ .argument('<integration>', 'Integration to set up: cursor, codex, or claude-code')
177
+ .option('--policy <path>', 'Path to an existing policy.yaml (skip generating default)')
178
+ .option('--force', 'Overwrite existing files', false)
179
+ .action((integration, opts) => {
180
+ const validIntegrations = ['cursor', 'codex', 'claude-code'];
181
+ if (!validIntegrations.includes(integration)) {
182
+ console.error(`Unknown integration: "${integration}". Valid options: ${validIntegrations.join(', ')}`);
183
+ process.exit(1);
184
+ }
185
+ try {
186
+ const result = runInit(integration, opts);
187
+ const projectDir = process.cwd();
188
+ console.log('');
189
+ console.log(` Deterministic Agent Control Protocol -- init (${integration})`);
190
+ console.log(` Project: ${projectDir}`);
191
+ console.log('');
192
+ if (result.created.length > 0) {
193
+ console.log(' Created:');
194
+ for (const file of result.created) {
195
+ console.log(` + ${file.label.padEnd(36)} ${file.description}`);
196
+ }
197
+ }
198
+ if (result.skipped.length > 0) {
199
+ console.log('');
200
+ console.log(' Skipped (already exist, use --force to overwrite):');
201
+ for (const file of result.skipped) {
202
+ console.log(` - ${file.label.padEnd(36)} ${file.description}`);
203
+ }
204
+ }
205
+ console.log('');
206
+ if (opts.policy) {
207
+ console.log(` Using custom policy: ${opts.policy}`);
208
+ }
209
+ else {
210
+ console.log(' Next steps:');
211
+ console.log(' 1. Review and customize policy.yaml for your needs');
212
+ }
213
+ switch (integration) {
214
+ case 'cursor':
215
+ console.log(' 2. Restart Cursor to pick up the MCP server');
216
+ break;
217
+ case 'codex':
218
+ console.log(' 2. Run codex to pick up the MCP server');
219
+ break;
220
+ case 'claude-code':
221
+ console.log(' 2. Restart Claude Code to pick up the MCP server');
222
+ break;
223
+ }
224
+ console.log('');
225
+ console.log(' The agent will now route file operations through governance.');
226
+ console.log('');
227
+ }
228
+ catch (err) {
229
+ console.error(`Error: ${err.message}`);
230
+ process.exit(1);
231
+ }
232
+ });
233
+ }
234
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,cAAc,EACd,SAAS,EACT,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAwBxB,8EAA8E;AAC9E,UAAU;AACV,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AAE,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAEhB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC7B,OAAO,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC;YACxE,CAAC;YAED,QAAQ,WAAW,EAAE,CAAC;gBACpB,KAAK,QAAQ;oBACX,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;oBAC/D,MAAM;gBACR,KAAK,OAAO;oBACV,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;oBAC1D,MAAM;gBACR,KAAK,aAAa;oBAChB,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;oBACpE,MAAM;YACV,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAC;YAC9E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,UAAW,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Bundled templates for the `det-acp init` command.
3
+ *
4
+ * Contains default policy, governance rules for each integration,
5
+ * and generator functions for integration-specific config files.
6
+ */
7
+ export declare const DEFAULT_POLICY = "# Deterministic Agent Control Protocol \u2014 Governance Policy\n# Governs what the MCP proxy allows AI agents to do.\n# Customize this file for your project's needs.\n\nversion: \"1.0\"\nname: \"default-governance\"\ndescription: \"Governance policy for AI agent file operations via MCP proxy\"\n\ncapabilities:\n # Read operations\n - tool: \"read_file\"\n scope: {}\n - tool: \"read_text_file\"\n scope: {}\n - tool: \"read_multiple_files\"\n scope: {}\n - tool: \"read_media_file\"\n scope: {}\n\n # Write/edit operations\n - tool: \"write_file\"\n scope: {}\n - tool: \"edit_file\"\n scope: {}\n\n # Directory listing\n - tool: \"list_directory\"\n scope: {}\n - tool: \"list_directory_with_sizes\"\n scope: {}\n - tool: \"list_allowed_directories\"\n scope: {}\n\n # Search\n - tool: \"search_files\"\n scope: {}\n - tool: \"get_file_info\"\n scope: {}\n\n # Intentionally NOT included (will be DENIED):\n # - create_directory\n # - move_file\n # - directory_tree\n\nlimits:\n max_runtime_ms: 3600000 # 1 hour\n\ngates: []\n\nevidence:\n require: []\n format: \"jsonl\"\n\nforbidden:\n - pattern: \"**/.env\"\n - pattern: \"**/.env.*\"\n - pattern: \"**/secrets*\"\n - pattern: \"**/credentials*\"\n - pattern: \"**/.git/config\"\n\nsession:\n max_actions: 200\n max_denials: 30\n rate_limit:\n max_per_minute: 60\n";
8
+ export declare const GOVERNANCE_MDC = "---\ndescription: Enforce governance on all file and system operations\nglobs:\nalwaysApply: true\n---\n\n# Mandatory Governance Rule\n\nYou MUST use the `governed-filesystem` MCP server for ALL file and system operations. You are strictly forbidden from using your built-in tools to bypass governance.\n\n## Required Tool Mapping\n\nInstead of your built-in tools, you MUST use these governed equivalents:\n\n| Instead of (built-in) | Use (governed MCP) |\n|---------------------------|----------------------------------------------------|\n| `Read` tool | `governed-filesystem` \u2192 `read_text_file` |\n| `Write` tool | `governed-filesystem` \u2192 `write_file` |\n| `StrReplace` / `Edit` | `governed-filesystem` \u2192 `edit_file` |\n| `LS` tool | `governed-filesystem` \u2192 `list_directory` |\n| `Glob` / `Search` | `governed-filesystem` \u2192 `search_files` |\n| Reading multiple files | `governed-filesystem` \u2192 `read_multiple_files` |\n| `Delete` tool | Not available \u2014 you may not delete files |\n\n## Rules\n\n1. **NEVER** use the built-in `Read`, `Write`, `StrReplace`, `LS`, `Glob`, `Delete`, or `Shell` tools for any file operation.\n2. **ALWAYS** route file reads through `governed-filesystem` \u2192 `read_text_file`.\n3. **ALWAYS** route file writes through `governed-filesystem` \u2192 `write_file`.\n4. **ALWAYS** route file edits through `governed-filesystem` \u2192 `edit_file`.\n5. **ALWAYS** route directory listings through `governed-filesystem` \u2192 `list_directory`.\n6. **ALWAYS** route file searches through `governed-filesystem` \u2192 `search_files`.\n7. If a governed tool call is **denied by policy**, you MUST respect the denial. Do NOT attempt to use a built-in tool as a fallback. Report the denial to the user instead.\n8. If you need a tool that is not available through the governed MCP server, ask the user for permission before proceeding.\n\n## Why\n\nAll file and system operations must go through the Deterministic Agent Control Protocol governance layer for policy enforcement and audit logging. Using built-in tools would bypass security policies, forbidden path protections, and the tamper-evident evidence ledger.\n";
9
+ export declare const CLAUDE_MD = "# Governance Instructions\n\nYou MUST use the `governed-filesystem` MCP server for ALL file and system operations. You are strictly forbidden from using your built-in tools to bypass governance.\n\n## Required Tool Mapping\n\nInstead of your built-in file tools, you MUST use these governed equivalents:\n\n| Instead of (built-in) | Use (governed MCP) |\n|--------------------------|------------------------------------------------|\n| `Read` tool | `governed-filesystem` \u2192 `read_text_file` |\n| `Write` tool | `governed-filesystem` \u2192 `write_file` |\n| `Edit` tool | `governed-filesystem` \u2192 `edit_file` |\n| `LS` / `Glob` | `governed-filesystem` \u2192 `list_directory` |\n| `Grep` / `Search` | `governed-filesystem` \u2192 `search_files` |\n| Reading multiple files | `governed-filesystem` \u2192 `read_multiple_files` |\n| Deleting files | Not available \u2014 you may not delete files |\n\n## Rules\n\n1. **NEVER** use the built-in `Read`, `Write`, `Edit`, `Grep`, `Glob`, or `Bash` (for file operations) tools when the governed MCP tools are available.\n2. **ALWAYS** route file reads through `governed-filesystem` \u2192 `read_text_file`.\n3. **ALWAYS** route file writes through `governed-filesystem` \u2192 `write_file`.\n4. **ALWAYS** route file edits through `governed-filesystem` \u2192 `edit_file`.\n5. **ALWAYS** route directory listings through `governed-filesystem` \u2192 `list_directory`.\n6. **ALWAYS** route file searches through `governed-filesystem` \u2192 `search_files`.\n7. If a governed tool call is **denied by policy**, you MUST respect the denial. Do NOT attempt to use a built-in tool as a fallback. Report the denial to the user instead.\n8. If you need a tool that is not available through the governed MCP server, ask the user for permission before proceeding.\n\n## Why\n\nAll file and system operations must go through the Deterministic Agent Control Protocol governance layer for policy enforcement and audit logging. Using built-in tools would bypass security policies, forbidden path protections, and the tamper-evident evidence ledger.\n";
10
+ export declare const AGENTS_MD = "# Governance Instructions\n\nYou MUST use the `governed-filesystem` MCP server for ALL file and system operations. You are strictly forbidden from using your built-in tools to bypass governance.\n\n## Required Tool Mapping\n\nInstead of your built-in file tools, you MUST use these governed equivalents:\n\n| Instead of (built-in) | Use (governed MCP) |\n|--------------------------|------------------------------------------------|\n| Reading files | `governed-filesystem` \u2192 `read_text_file` |\n| Writing files | `governed-filesystem` \u2192 `write_file` |\n| Editing files | `governed-filesystem` \u2192 `edit_file` |\n| Listing directories | `governed-filesystem` \u2192 `list_directory` |\n| Searching files | `governed-filesystem` \u2192 `search_files` |\n| Reading multiple files | `governed-filesystem` \u2192 `read_multiple_files` |\n| Deleting files | Not available \u2014 you may not delete files |\n\n## Rules\n\n1. **NEVER** use built-in file read/write/edit tools for any file operation when the governed MCP tools are available.\n2. **ALWAYS** route file operations through the `governed-filesystem` MCP server.\n3. If a governed tool call is **denied by policy**, you MUST respect the denial. Do NOT attempt to use a built-in tool as a fallback. Report the denial to the user instead.\n4. If you need a tool that is not available through the governed MCP server, ask the user for permission before proceeding.\n\n## Why\n\nAll file and system operations must go through the Deterministic Agent Control Protocol governance layer for policy enforcement and audit logging. Using built-in tools would bypass security policies, forbidden path protections, and the tamper-evident evidence ledger.\n";
11
+ export declare const CLAUDE_SETTINGS_JSON = "{\n \"permissions\": {\n \"deny\": [\n \"Read\",\n \"Write\",\n \"Edit\"\n ],\n \"allow\": [\n \"Bash\",\n \"Grep\",\n \"Glob\",\n \"governed-filesystem\"\n ]\n }\n}\n";
12
+ /**
13
+ * Generate .cursor/mcp.json content.
14
+ * Uses the simplified `proxy --policy` mode so no mcp-proxy.yaml is needed.
15
+ */
16
+ export declare function generateCursorMcpJson(cliPath: string, policyAbsPath: string): string;
17
+ /**
18
+ * Generate .mcp.json content for Claude Code.
19
+ * Uses the simplified `proxy --policy` mode so no mcp-proxy.yaml is needed.
20
+ */
21
+ export declare function generateClaudeCodeMcpJson(cliPath: string, policyAbsPath: string): string;
22
+ /**
23
+ * Generate .codex/config.toml content.
24
+ * Uses the simplified `proxy --policy` mode so no mcp-proxy.yaml is needed.
25
+ */
26
+ export declare function generateCodexConfigToml(cliPath: string, policyAbsPath: string): string;
27
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/cli/templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,eAAO,MAAM,cAAc,u3CAkE1B,CAAC;AAMF,eAAO,MAAM,cAAc,0zEAuC1B,CAAC;AAMF,eAAO,MAAM,SAAS,8rEAiCrB,CAAC;AAMF,eAAO,MAAM,SAAS,8zDA6BrB,CAAC;AAMF,eAAO,MAAM,oBAAoB,6NAgBhC,CAAC;AAMF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAUpF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAUxF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAkBtF"}