veto-sdk 1.12.0 → 1.14.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.
- package/README.md +72 -5
- package/dist/cli/agent.d.ts +85 -0
- package/dist/cli/agent.d.ts.map +1 -0
- package/dist/cli/agent.js +240 -0
- package/dist/cli/agent.js.map +1 -0
- package/dist/cli/bin.js +195 -8
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/colors.d.ts +50 -0
- package/dist/cli/colors.d.ts.map +1 -0
- package/dist/cli/colors.js +71 -0
- package/dist/cli/colors.js.map +1 -0
- package/dist/cli/diff.d.ts +120 -0
- package/dist/cli/diff.d.ts.map +1 -0
- package/dist/cli/diff.js +950 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/repl-context.d.ts +34 -0
- package/dist/cli/repl-context.d.ts.map +1 -0
- package/dist/cli/repl-context.js +366 -0
- package/dist/cli/repl-context.js.map +1 -0
- package/dist/cli/repl-generate.d.ts +84 -0
- package/dist/cli/repl-generate.d.ts.map +1 -0
- package/dist/cli/repl-generate.js +907 -0
- package/dist/cli/repl-generate.js.map +1 -0
- package/dist/cli/repl.d.ts +47 -0
- package/dist/cli/repl.d.ts.map +1 -0
- package/dist/cli/repl.js +1195 -0
- package/dist/cli/repl.js.map +1 -0
- package/dist/cli/scan.d.ts +60 -0
- package/dist/cli/scan.d.ts.map +1 -0
- package/dist/cli/scan.js +644 -0
- package/dist/cli/scan.js.map +1 -0
- package/dist/core/protect.d.ts.map +1 -1
- package/dist/core/protect.js +2 -118
- package/dist/core/protect.js.map +1 -1
- package/dist/core/tool-pack-heuristics.d.ts +3 -0
- package/dist/core/tool-pack-heuristics.d.ts.map +1 -0
- package/dist/core/tool-pack-heuristics.js +124 -0
- package/dist/core/tool-pack-heuristics.js.map +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -108,7 +108,6 @@ logging:
|
|
|
108
108
|
rules:
|
|
109
109
|
directory: "./rules"
|
|
110
110
|
recursive: true
|
|
111
|
-
|
|
112
111
|
# Local approval callback (for action: require_approval)
|
|
113
112
|
# approval:
|
|
114
113
|
# callbackUrl: "http://localhost:8787/approvals"
|
|
@@ -176,10 +175,78 @@ const csvAudit = veto.exportDecisions("csv");
|
|
|
176
175
|
|
|
177
176
|
## CLI Commands
|
|
178
177
|
|
|
179
|
-
| Command | Description
|
|
180
|
-
| ------------------ |
|
|
181
|
-
| `npx veto
|
|
182
|
-
| `npx veto
|
|
178
|
+
| Command | Description |
|
|
179
|
+
| ------------------ | ----------------------------------------------------- |
|
|
180
|
+
| `npx veto` | Start interactive policy REPL |
|
|
181
|
+
| `npx veto --repl` | Start interactive policy REPL (explicit flag) |
|
|
182
|
+
| `npx veto repl` | Start interactive policy REPL |
|
|
183
|
+
| `npx veto init` | Initialize Veto in current directory |
|
|
184
|
+
| `npx veto learn` | Observe tool calls and generate starter policies |
|
|
185
|
+
| `npx veto compile` | Compile natural-language policy text into YAML |
|
|
186
|
+
| `npx veto test` | Run adversarial policy gap analysis |
|
|
187
|
+
| `npx veto scan` | Audit discovered tools vs loaded rule coverage |
|
|
188
|
+
| `npx veto diff` | Diff policy snapshots and replay deterministic impact |
|
|
189
|
+
| `npx veto version` | Show version |
|
|
190
|
+
|
|
191
|
+
Interactive REPL examples:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Start interactive policy shell
|
|
195
|
+
npx veto
|
|
196
|
+
|
|
197
|
+
# Start interactive policy shell (explicit flag)
|
|
198
|
+
npx veto --repl
|
|
199
|
+
|
|
200
|
+
# Test a call locally (no network)
|
|
201
|
+
/test transfer_funds({"amount": 50000})
|
|
202
|
+
|
|
203
|
+
# Ask a what-if question in plain language
|
|
204
|
+
what would happen if my agent tried to transfer $50,000?
|
|
205
|
+
|
|
206
|
+
# Explain a rule
|
|
207
|
+
/explain fin-block-high-transfers
|
|
208
|
+
|
|
209
|
+
# Run scenario suite
|
|
210
|
+
test my agent against current rules
|
|
211
|
+
|
|
212
|
+
# Export merged rules
|
|
213
|
+
/export
|
|
214
|
+
|
|
215
|
+
# Save generated YAML to a custom file during prompt flow
|
|
216
|
+
# Save to ./veto/rules/transfer-funds-block-25000.yaml? [Y/n/edit/path]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Coverage audit examples:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Human-readable coverage report
|
|
223
|
+
npx veto scan
|
|
224
|
+
|
|
225
|
+
# CI gate: fail when uncovered tools are found
|
|
226
|
+
npx veto scan --fail-uncovered
|
|
227
|
+
|
|
228
|
+
# Include inline YAML snippets for uncovered tools
|
|
229
|
+
npx veto scan --suggest
|
|
230
|
+
|
|
231
|
+
# Machine-readable output for CI pipelines
|
|
232
|
+
npx veto scan --format json
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Policy diff examples:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# Compare working rule file against HEAD (git snapshot)
|
|
239
|
+
npx veto diff financial.yaml
|
|
240
|
+
|
|
241
|
+
# Compare two explicit snapshots (file or directory mode)
|
|
242
|
+
npx veto diff --old ./rules-v1 --new ./rules-v2
|
|
243
|
+
|
|
244
|
+
# Include deterministic replay impact from historical calls
|
|
245
|
+
npx veto diff financial.yaml --log calls.jsonl
|
|
246
|
+
|
|
247
|
+
# Machine-readable structural + impact report
|
|
248
|
+
npx veto diff --old ./rules-v1 --new ./rules-v2 --log calls.jsonl --format json
|
|
249
|
+
```
|
|
183
250
|
|
|
184
251
|
## General Rule YAML Format
|
|
185
252
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-native CLI utilities for Veto.
|
|
3
|
+
*
|
|
4
|
+
* Allows autonomous LLMs to configure Veto without human interaction.
|
|
5
|
+
* All commands return JSON for programmatic parsing and never prompt for input.
|
|
6
|
+
*
|
|
7
|
+
* @module cli/agent
|
|
8
|
+
*/
|
|
9
|
+
import { type InitResult } from './init.js';
|
|
10
|
+
import { type ScanResult } from './scan.js';
|
|
11
|
+
import { type ToolImpact } from './repl.js';
|
|
12
|
+
/**
|
|
13
|
+
* Result of an agent operation.
|
|
14
|
+
*/
|
|
15
|
+
export interface AgentResult<T = unknown> {
|
|
16
|
+
success: boolean;
|
|
17
|
+
data?: T;
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Policy list item.
|
|
22
|
+
*/
|
|
23
|
+
export interface PolicyListItem {
|
|
24
|
+
id: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
action: string;
|
|
28
|
+
tools: string[];
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
file: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Policy add result.
|
|
34
|
+
*/
|
|
35
|
+
export interface PolicyAddResult {
|
|
36
|
+
file: string;
|
|
37
|
+
rules: string[];
|
|
38
|
+
impacts: ToolImpact[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for agent operations.
|
|
42
|
+
*/
|
|
43
|
+
export interface AgentOptions {
|
|
44
|
+
/** Project directory */
|
|
45
|
+
directory?: string;
|
|
46
|
+
/** Output format: json or yaml */
|
|
47
|
+
format?: 'json' | 'yaml';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Initialize Veto in agent mode.
|
|
51
|
+
*
|
|
52
|
+
* @param options - Agent options
|
|
53
|
+
* @returns Result with initialization details
|
|
54
|
+
*/
|
|
55
|
+
export declare function agentInit(options?: AgentOptions): Promise<AgentResult<InitResult>>;
|
|
56
|
+
/**
|
|
57
|
+
* List all policies in the project.
|
|
58
|
+
*
|
|
59
|
+
* @param options - Agent options
|
|
60
|
+
* @returns List of policies
|
|
61
|
+
*/
|
|
62
|
+
export declare function agentPolicyList(options?: AgentOptions): Promise<AgentResult<PolicyListItem[]>>;
|
|
63
|
+
/**
|
|
64
|
+
* Add a new policy from a natural language prompt.
|
|
65
|
+
*
|
|
66
|
+
* @param prompt - Policy description
|
|
67
|
+
* @param options - Agent options
|
|
68
|
+
* @returns Result with policy details
|
|
69
|
+
*/
|
|
70
|
+
export declare function agentPolicyAdd(prompt: string, options?: AgentOptions): Promise<AgentResult<PolicyAddResult>>;
|
|
71
|
+
/**
|
|
72
|
+
* Scan project tools and show coverage.
|
|
73
|
+
*
|
|
74
|
+
* @param options - Agent options
|
|
75
|
+
* @returns Scan result with tool coverage
|
|
76
|
+
*/
|
|
77
|
+
export declare function agentScan(options?: AgentOptions): Promise<AgentResult<ScanResult>>;
|
|
78
|
+
/**
|
|
79
|
+
* Get the current Veto configuration.
|
|
80
|
+
*
|
|
81
|
+
* @param options - Agent options
|
|
82
|
+
* @returns Configuration object
|
|
83
|
+
*/
|
|
84
|
+
export declare function agentConfig(options?: AgentOptions): Promise<AgentResult<Record<string, unknown>>>;
|
|
85
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/cli/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAI/D;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAA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
|
|
2
|
+
* Agent-native CLI utilities for Veto.
|
|
3
|
+
*
|
|
4
|
+
* Allows autonomous LLMs to configure Veto without human interaction.
|
|
5
|
+
* All commands return JSON for programmatic parsing and never prompt for input.
|
|
6
|
+
*
|
|
7
|
+
* @module cli/agent
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
10
|
+
import { join, resolve } from 'node:path';
|
|
11
|
+
import { parse as parseYaml, stringify } from 'yaml';
|
|
12
|
+
import { init } from './init.js';
|
|
13
|
+
import { scan } from './scan.js';
|
|
14
|
+
import { generatePolicyFromPrompt } from './repl-generate.js';
|
|
15
|
+
import { analyzeToolImpact } from './repl.js';
|
|
16
|
+
import { createReplSessionContext } from './repl-context.js';
|
|
17
|
+
/**
|
|
18
|
+
* Initialize Veto in agent mode.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Agent options
|
|
21
|
+
* @returns Result with initialization details
|
|
22
|
+
*/
|
|
23
|
+
export async function agentInit(options = {}) {
|
|
24
|
+
try {
|
|
25
|
+
const result = await init({
|
|
26
|
+
directory: options.directory,
|
|
27
|
+
agent: true,
|
|
28
|
+
yes: true,
|
|
29
|
+
quiet: true,
|
|
30
|
+
});
|
|
31
|
+
if (!options.format || options.format === 'json') {
|
|
32
|
+
const output = { success: result.success, data: result };
|
|
33
|
+
if (result.messages.length > 0) {
|
|
34
|
+
output.messages = result.messages;
|
|
35
|
+
}
|
|
36
|
+
console.log(JSON.stringify(output));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log(stringify({ ...result }));
|
|
40
|
+
}
|
|
41
|
+
return { success: result.success, data: result };
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
45
|
+
if (!options.format || options.format === 'json') {
|
|
46
|
+
console.log(JSON.stringify({ success: false, error: message }));
|
|
47
|
+
}
|
|
48
|
+
return { success: false, error: message };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* List all policies in the project.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Agent options
|
|
55
|
+
* @returns List of policies
|
|
56
|
+
*/
|
|
57
|
+
export async function agentPolicyList(options = {}) {
|
|
58
|
+
try {
|
|
59
|
+
const cwd = resolve(options.directory ?? process.cwd());
|
|
60
|
+
const rulesDir = join(cwd, 'veto', 'rules');
|
|
61
|
+
if (!existsSync(rulesDir)) {
|
|
62
|
+
const result = [];
|
|
63
|
+
if (!options.format || options.format === 'json') {
|
|
64
|
+
console.log(JSON.stringify({ success: true, data: result }));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.log(stringify({ success: true, policies: result }));
|
|
68
|
+
}
|
|
69
|
+
return { success: true, data: result };
|
|
70
|
+
}
|
|
71
|
+
const policies = [];
|
|
72
|
+
const { readdirSync, statSync } = await import('node:fs');
|
|
73
|
+
const files = readdirSync(rulesDir);
|
|
74
|
+
for (const file of files) {
|
|
75
|
+
if (!file.endsWith('.yaml') && !file.endsWith('.yml')) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const filePath = join(rulesDir, file);
|
|
79
|
+
const stat = statSync(filePath);
|
|
80
|
+
if (!stat.isFile()) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
85
|
+
const parsed = parseYaml(content);
|
|
86
|
+
if (parsed?.rules && Array.isArray(parsed.rules)) {
|
|
87
|
+
for (const rule of parsed.rules) {
|
|
88
|
+
policies.push({
|
|
89
|
+
id: rule.id,
|
|
90
|
+
name: rule.name,
|
|
91
|
+
description: rule.description,
|
|
92
|
+
action: rule.action,
|
|
93
|
+
tools: rule.tools ?? [],
|
|
94
|
+
enabled: rule.enabled ?? true,
|
|
95
|
+
file: `veto/rules/${file}`,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Skip invalid files
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!options.format || options.format === 'json') {
|
|
105
|
+
console.log(JSON.stringify({ success: true, data: policies }));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
console.log(stringify({ success: true, policies }));
|
|
109
|
+
}
|
|
110
|
+
return { success: true, data: policies };
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
114
|
+
if (!options.format || options.format === 'json') {
|
|
115
|
+
console.log(JSON.stringify({ success: false, error: message }));
|
|
116
|
+
}
|
|
117
|
+
return { success: false, error: message };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Add a new policy from a natural language prompt.
|
|
122
|
+
*
|
|
123
|
+
* @param prompt - Policy description
|
|
124
|
+
* @param options - Agent options
|
|
125
|
+
* @returns Result with policy details
|
|
126
|
+
*/
|
|
127
|
+
export async function agentPolicyAdd(prompt, options = {}) {
|
|
128
|
+
try {
|
|
129
|
+
const cwd = resolve(options.directory ?? process.cwd());
|
|
130
|
+
const context = await createReplSessionContext(cwd);
|
|
131
|
+
const generated = await generatePolicyFromPrompt({
|
|
132
|
+
prompt,
|
|
133
|
+
projectDir: cwd,
|
|
134
|
+
rulesDirectory: context.rulesDir,
|
|
135
|
+
tools: context.discoveredTools,
|
|
136
|
+
existingRules: context.allRules,
|
|
137
|
+
});
|
|
138
|
+
const parsed = parseYaml(generated.yaml);
|
|
139
|
+
const rules = (parsed.rules ?? []);
|
|
140
|
+
const impacts = analyzeToolImpact(rules, context.discoveredTools);
|
|
141
|
+
// Determine save path
|
|
142
|
+
const ruleId = rules[0]?.id ?? 'policy';
|
|
143
|
+
const safeId = ruleId.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
144
|
+
const savePath = join(cwd, 'veto', 'rules', `${safeId}.yaml`);
|
|
145
|
+
// Ensure directory exists
|
|
146
|
+
mkdirSync(join(cwd, 'veto', 'rules'), { recursive: true });
|
|
147
|
+
// Write the policy
|
|
148
|
+
writeFileSync(savePath, generated.yaml, 'utf-8');
|
|
149
|
+
const result = {
|
|
150
|
+
file: savePath,
|
|
151
|
+
rules: rules.map((r) => r.id),
|
|
152
|
+
impacts,
|
|
153
|
+
};
|
|
154
|
+
if (!options.format || options.format === 'json') {
|
|
155
|
+
console.log(JSON.stringify({ success: true, data: result }));
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
console.log(stringify({ success: true, ...result }));
|
|
159
|
+
}
|
|
160
|
+
return { success: true, data: result };
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
164
|
+
if (!options.format || options.format === 'json') {
|
|
165
|
+
console.log(JSON.stringify({ success: false, error: message }));
|
|
166
|
+
}
|
|
167
|
+
return { success: false, error: message };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Scan project tools and show coverage.
|
|
172
|
+
*
|
|
173
|
+
* @param options - Agent options
|
|
174
|
+
* @returns Scan result with tool coverage
|
|
175
|
+
*/
|
|
176
|
+
export async function agentScan(options = {}) {
|
|
177
|
+
try {
|
|
178
|
+
const result = await scan({
|
|
179
|
+
directory: options.directory,
|
|
180
|
+
quiet: true,
|
|
181
|
+
failUncovered: false,
|
|
182
|
+
suggest: false,
|
|
183
|
+
format: 'json',
|
|
184
|
+
});
|
|
185
|
+
if (!options.format || options.format === 'json') {
|
|
186
|
+
console.log(JSON.stringify({ success: result.success, data: result }));
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
console.log(stringify({ ...result }));
|
|
190
|
+
}
|
|
191
|
+
return { success: result.success, data: result };
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
195
|
+
if (!options.format || options.format === 'json') {
|
|
196
|
+
console.log(JSON.stringify({ success: false, error: message }));
|
|
197
|
+
}
|
|
198
|
+
return { success: false, error: message };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get the current Veto configuration.
|
|
203
|
+
*
|
|
204
|
+
* @param options - Agent options
|
|
205
|
+
* @returns Configuration object
|
|
206
|
+
*/
|
|
207
|
+
export async function agentConfig(options = {}) {
|
|
208
|
+
try {
|
|
209
|
+
const cwd = resolve(options.directory ?? process.cwd());
|
|
210
|
+
const configPath = join(cwd, 'veto', 'veto.config.yaml');
|
|
211
|
+
if (!existsSync(configPath)) {
|
|
212
|
+
const result = { initialized: false };
|
|
213
|
+
if (!options.format || options.format === 'json') {
|
|
214
|
+
console.log(JSON.stringify({ success: true, data: result }));
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
console.log(stringify({ success: true, ...result }));
|
|
218
|
+
}
|
|
219
|
+
return { success: true, data: result };
|
|
220
|
+
}
|
|
221
|
+
const content = readFileSync(configPath, 'utf-8');
|
|
222
|
+
const config = parseYaml(content);
|
|
223
|
+
const result = { initialized: true, ...config };
|
|
224
|
+
if (!options.format || options.format === 'json') {
|
|
225
|
+
console.log(JSON.stringify({ success: true, data: result }));
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
console.log(stringify({ success: true, ...result }));
|
|
229
|
+
}
|
|
230
|
+
return { success: true, data: result };
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
234
|
+
if (!options.format || options.format === 'json') {
|
|
235
|
+
console.log(JSON.stringify({ success: false, error: message }));
|
|
236
|
+
}
|
|
237
|
+
return { success: false, error: message };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/cli/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA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