agentspd 1.0.0 → 1.1.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 +77 -294
- package/dist/api.d.ts +66 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +147 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +114 -32
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +58 -41
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +111 -19
- package/dist/commands/openclaw.d.ts +3 -0
- package/dist/commands/openclaw.d.ts.map +1 -0
- package/dist/commands/openclaw.js +1033 -0
- package/dist/commands/policies.d.ts.map +1 -1
- package/dist/commands/policies.js +137 -41
- package/dist/commands/threats.d.ts.map +1 -1
- package/dist/commands/threats.js +75 -29
- package/dist/commands/webhooks.d.ts.map +1 -1
- package/dist/commands/webhooks.js +24 -21
- package/dist/commands/workspaces.d.ts +5 -0
- package/dist/commands/workspaces.d.ts.map +1 -0
- package/dist/commands/workspaces.js +514 -0
- package/dist/config.d.ts +6 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +34 -23
- package/dist/index.js +178 -155
- package/dist/openclaw-api.d.ts +81 -0
- package/dist/openclaw-api.d.ts.map +1 -0
- package/dist/openclaw-api.js +262 -0
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { createAuthCommand,
|
|
5
|
-
import {
|
|
6
|
-
import * as output from
|
|
7
|
-
const VERSION =
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { createAgentsCommand, createAuditCommand, createAuthCommand, createConfigCommand, createInitCommand, createOpenClawCommand, createPoliciesCommand, createPolicyGenerateCommand, createPolicyRefineCommand, createThreatsCommand, createWebhooksCommand, createWorkspacesCommand, } from "./commands/index.js";
|
|
5
|
+
import { getConfig, setConfig } from "./config.js";
|
|
6
|
+
import * as output from "./output.js";
|
|
7
|
+
const VERSION = "1.0.0";
|
|
8
8
|
const BANNER = `
|
|
9
|
-
${chalk.cyan(
|
|
10
|
-
${chalk.cyan(
|
|
11
|
-
${chalk.cyan(
|
|
9
|
+
${chalk.cyan("╔═══════════════════════════════════════════════════════════╗")}
|
|
10
|
+
${chalk.cyan("║")} ${chalk.bold.white("EMOTOS CLI")} - Security Infrastructure for AI Agents ${chalk.cyan("║")}
|
|
11
|
+
${chalk.cyan("╚═══════════════════════════════════════════════════════════╝")}
|
|
12
12
|
`;
|
|
13
13
|
const program = new Command();
|
|
14
14
|
program
|
|
15
|
-
.name(
|
|
16
|
-
.description(
|
|
15
|
+
.name("agentspd")
|
|
16
|
+
.description("Emotos CLI - Security Infrastructure for AI Agents")
|
|
17
17
|
.version(VERSION)
|
|
18
|
-
.option(
|
|
19
|
-
.option(
|
|
20
|
-
.
|
|
21
|
-
.hook('preAction', (thisCommand) => {
|
|
18
|
+
.option("--api-url <url>", "Override API URL")
|
|
19
|
+
.option("--output-format <format>", "Output format (json, yaml, table)")
|
|
20
|
+
.hook("preAction", (thisCommand) => {
|
|
22
21
|
const opts = thisCommand.opts();
|
|
23
22
|
if (opts.apiUrl) {
|
|
24
|
-
setConfig(
|
|
23
|
+
setConfig("apiUrl", opts.apiUrl);
|
|
25
24
|
}
|
|
26
|
-
if (opts.
|
|
27
|
-
setConfig(
|
|
28
|
-
}
|
|
29
|
-
else if (opts.yaml) {
|
|
30
|
-
setConfig('outputFormat', 'yaml');
|
|
25
|
+
if (opts.outputFormat) {
|
|
26
|
+
setConfig("outputFormat", opts.outputFormat);
|
|
31
27
|
}
|
|
32
28
|
});
|
|
33
29
|
// Add subcommands
|
|
@@ -39,72 +35,89 @@ program.addCommand(createAuditCommand());
|
|
|
39
35
|
program.addCommand(createThreatsCommand());
|
|
40
36
|
program.addCommand(createWebhooksCommand());
|
|
41
37
|
program.addCommand(createConfigCommand());
|
|
38
|
+
program.addCommand(createWorkspacesCommand());
|
|
39
|
+
program.addCommand(createOpenClawCommand());
|
|
40
|
+
// Add generate/refine to the policies command
|
|
41
|
+
const policiesCmd = program.commands.find((c) => c.name() === "policies");
|
|
42
|
+
if (policiesCmd) {
|
|
43
|
+
policiesCmd.addCommand(createPolicyGenerateCommand());
|
|
44
|
+
policiesCmd.addCommand(createPolicyRefineCommand());
|
|
45
|
+
}
|
|
42
46
|
// Quick commands (shortcuts)
|
|
43
47
|
program
|
|
44
|
-
.command(
|
|
45
|
-
.description(
|
|
46
|
-
.option(
|
|
48
|
+
.command("login")
|
|
49
|
+
.description("Quick login (alias for auth login)")
|
|
50
|
+
.option("-k, --api-key <key>", "Use API key")
|
|
47
51
|
.action(async (options) => {
|
|
48
52
|
const authCmd = createAuthCommand();
|
|
49
|
-
const loginCmd = authCmd.commands.find((c) => c.name() ===
|
|
53
|
+
const loginCmd = authCmd.commands.find((c) => c.name() === "login");
|
|
50
54
|
if (loginCmd) {
|
|
51
|
-
await loginCmd.parseAsync([
|
|
55
|
+
await loginCmd.parseAsync([
|
|
56
|
+
"",
|
|
57
|
+
"",
|
|
58
|
+
...(options.apiKey ? ["-k", options.apiKey] : []),
|
|
59
|
+
]);
|
|
52
60
|
}
|
|
53
61
|
});
|
|
54
62
|
program
|
|
55
|
-
.command(
|
|
56
|
-
.description(
|
|
63
|
+
.command("status")
|
|
64
|
+
.description("Show authentication and system status")
|
|
57
65
|
.action(async () => {
|
|
58
66
|
const config = getConfig();
|
|
59
|
-
output.heading(
|
|
67
|
+
output.heading("Emotos Status");
|
|
60
68
|
// Auth status
|
|
61
|
-
const authStatus = config.apiKey || config.sessionToken
|
|
69
|
+
const authStatus = config.apiKey || config.sessionToken
|
|
70
|
+
? "Authenticated"
|
|
71
|
+
: "Not authenticated";
|
|
62
72
|
const authColor = config.apiKey || config.sessionToken ? chalk.green : chalk.red;
|
|
63
73
|
output.printKeyValue([
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
74
|
+
["Auth Status", authColor(authStatus)],
|
|
75
|
+
["API URL", config.apiUrl],
|
|
76
|
+
["Organization", config.orgName || "N/A"],
|
|
77
|
+
["User", config.userName || "N/A"],
|
|
78
|
+
["Environment", config.defaultEnvironment],
|
|
69
79
|
]);
|
|
70
80
|
if (!config.apiKey && !config.sessionToken) {
|
|
71
81
|
console.log();
|
|
72
|
-
output.info(
|
|
82
|
+
output.info("Run `agentspd auth login` to authenticate");
|
|
73
83
|
}
|
|
74
84
|
});
|
|
75
85
|
// Help command enhancements
|
|
76
86
|
program
|
|
77
|
-
.command(
|
|
78
|
-
.description(
|
|
87
|
+
.command("docs")
|
|
88
|
+
.description("Open documentation")
|
|
79
89
|
.action(() => {
|
|
90
|
+
const cfg = getConfig();
|
|
91
|
+
const docsUrl = process.env.EMOTOS_DOCS_URL || `${cfg.apiUrl}/docs`;
|
|
92
|
+
const proxyWsUrl = (process.env.EMOTOS_PROXY_URL || cfg.apiUrl).replace(/^http/, "ws");
|
|
80
93
|
console.log(BANNER);
|
|
81
|
-
output.heading(
|
|
82
|
-
console.log(
|
|
83
|
-
console.log(
|
|
94
|
+
output.heading("Documentation");
|
|
95
|
+
console.log(` Full documentation: ${output.link(docsUrl)}`);
|
|
96
|
+
console.log(` API Reference: ${output.link(`${cfg.apiUrl}/docs`)}`);
|
|
84
97
|
console.log();
|
|
85
|
-
output.heading(
|
|
86
|
-
console.log(
|
|
87
|
-
console.log(
|
|
88
|
-
console.log(
|
|
89
|
-
console.log(
|
|
90
|
-
console.log(
|
|
98
|
+
output.heading("Quick Start");
|
|
99
|
+
console.log(` 1. Sign up: ${output.highlight("agentspd auth signup")}`);
|
|
100
|
+
console.log(` 2. Create policy: ${output.highlight("agentspd policies create")}`);
|
|
101
|
+
console.log(` 3. Register agent: ${output.highlight("agentspd agents create")}`);
|
|
102
|
+
console.log(` 4. Issue token: ${output.highlight("agentspd agents token <agent-id>")}`);
|
|
103
|
+
console.log(` 5. Connect to MCP: ${output.highlight(`${proxyWsUrl}/v1/mcp`)}`);
|
|
91
104
|
console.log();
|
|
92
|
-
output.heading(
|
|
93
|
-
console.log(
|
|
94
|
-
console.log(
|
|
95
|
-
console.log(
|
|
105
|
+
output.heading("For Agent Providers");
|
|
106
|
+
console.log(" - Register and manage AI agents");
|
|
107
|
+
console.log(" - Define security policies");
|
|
108
|
+
console.log(" - Monitor agent reputation and behavior");
|
|
96
109
|
console.log();
|
|
97
|
-
output.heading(
|
|
98
|
-
console.log(
|
|
99
|
-
console.log(
|
|
100
|
-
console.log(
|
|
110
|
+
output.heading("For Agent Consumers");
|
|
111
|
+
console.log(" - Vet and approve third-party agents");
|
|
112
|
+
console.log(" - Monitor threats in real-time");
|
|
113
|
+
console.log(" - Review audit logs for compliance");
|
|
101
114
|
});
|
|
102
115
|
program
|
|
103
|
-
.command(
|
|
104
|
-
.alias(
|
|
105
|
-
.description(
|
|
106
|
-
.option(
|
|
107
|
-
.option(
|
|
116
|
+
.command("quickstart")
|
|
117
|
+
.alias("tutorial")
|
|
118
|
+
.description("Interactive quickstart tutorial")
|
|
119
|
+
.option("--provider", "Agent provider tutorial")
|
|
120
|
+
.option("--consumer", "Agent consumer tutorial")
|
|
108
121
|
.action(async (options) => {
|
|
109
122
|
console.log(BANNER);
|
|
110
123
|
if (options.provider) {
|
|
@@ -114,19 +127,25 @@ program
|
|
|
114
127
|
await consumerTutorial();
|
|
115
128
|
}
|
|
116
129
|
else {
|
|
117
|
-
const inquirer = await import(
|
|
130
|
+
const inquirer = await import("inquirer");
|
|
118
131
|
const answers = await inquirer.default.prompt([
|
|
119
132
|
{
|
|
120
|
-
type:
|
|
121
|
-
name:
|
|
122
|
-
message:
|
|
133
|
+
type: "list",
|
|
134
|
+
name: "role",
|
|
135
|
+
message: "Which tutorial would you like to follow?",
|
|
123
136
|
choices: [
|
|
124
|
-
{
|
|
125
|
-
|
|
137
|
+
{
|
|
138
|
+
name: "Agent Provider - Build and deploy secure AI agents",
|
|
139
|
+
value: "provider",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "Agent Consumer - Protect your systems from AI agents",
|
|
143
|
+
value: "consumer",
|
|
144
|
+
},
|
|
126
145
|
],
|
|
127
146
|
},
|
|
128
147
|
]);
|
|
129
|
-
if (answers.role ===
|
|
148
|
+
if (answers.role === "provider") {
|
|
130
149
|
await providerTutorial();
|
|
131
150
|
}
|
|
132
151
|
else {
|
|
@@ -135,42 +154,42 @@ program
|
|
|
135
154
|
}
|
|
136
155
|
});
|
|
137
156
|
async function providerTutorial() {
|
|
138
|
-
output.heading(
|
|
139
|
-
console.log(
|
|
140
|
-
console.log(
|
|
141
|
-
console.log(
|
|
142
|
-
console.log(
|
|
143
|
-
console.log(
|
|
157
|
+
output.heading("Agent Provider Tutorial");
|
|
158
|
+
console.log("This tutorial will guide you through:");
|
|
159
|
+
console.log(" 1. Creating a security policy");
|
|
160
|
+
console.log(" 2. Registering an AI agent");
|
|
161
|
+
console.log(" 3. Issuing identity tokens");
|
|
162
|
+
console.log(" 4. Connecting to the MCP proxy");
|
|
144
163
|
console.log();
|
|
145
|
-
const inquirer = await import(
|
|
164
|
+
const inquirer = await import("inquirer");
|
|
146
165
|
// Step 1: Check authentication
|
|
147
|
-
output.heading(
|
|
166
|
+
output.heading("Step 1: Authentication");
|
|
148
167
|
const config = getConfig();
|
|
149
168
|
if (!config.apiKey && !config.sessionToken) {
|
|
150
|
-
console.log(
|
|
169
|
+
console.log("You need to authenticate first.");
|
|
151
170
|
const answers = await inquirer.default.prompt([
|
|
152
171
|
{
|
|
153
|
-
type:
|
|
154
|
-
name:
|
|
155
|
-
message:
|
|
172
|
+
type: "confirm",
|
|
173
|
+
name: "signup",
|
|
174
|
+
message: "Would you like to create an account now?",
|
|
156
175
|
default: true,
|
|
157
176
|
},
|
|
158
177
|
]);
|
|
159
178
|
if (answers.signup) {
|
|
160
179
|
console.log();
|
|
161
|
-
console.log(
|
|
162
|
-
console.log(
|
|
180
|
+
console.log(`Run: ${output.highlight("agentspd auth signup")}`);
|
|
181
|
+
console.log("Then run this tutorial again.");
|
|
163
182
|
return;
|
|
164
183
|
}
|
|
165
184
|
}
|
|
166
185
|
else {
|
|
167
|
-
output.success(
|
|
186
|
+
output.success("Already authenticated");
|
|
168
187
|
}
|
|
169
188
|
// Step 2: Create a policy
|
|
170
|
-
output.heading(
|
|
171
|
-
console.log(
|
|
189
|
+
output.heading("Step 2: Create a Security Policy");
|
|
190
|
+
console.log("Security policies define what your agents can and cannot do.");
|
|
172
191
|
console.log();
|
|
173
|
-
console.log(
|
|
192
|
+
console.log("Example policy (save as my-policy.yaml):");
|
|
174
193
|
console.log();
|
|
175
194
|
console.log(chalk.gray(`version: "1.0"
|
|
176
195
|
name: "my-agent-policy"
|
|
@@ -193,35 +212,37 @@ prompt_injection:
|
|
|
193
212
|
enabled: true
|
|
194
213
|
action: block`));
|
|
195
214
|
console.log();
|
|
196
|
-
console.log(
|
|
215
|
+
console.log(`Create with: ${output.highlight("agentspd policies create --file my-policy.yaml")}`);
|
|
197
216
|
// Step 3: Register an agent
|
|
198
|
-
output.heading(
|
|
199
|
-
console.log(
|
|
217
|
+
output.heading("Step 3: Register Your Agent");
|
|
218
|
+
console.log("Each AI agent needs a unique identity.");
|
|
200
219
|
console.log();
|
|
201
|
-
console.log(
|
|
220
|
+
console.log(`Create with: ${output.highlight("agentspd agents create --name my-agent --environment development")}`);
|
|
202
221
|
console.log();
|
|
203
|
-
console.log(
|
|
204
|
-
console.log(
|
|
205
|
-
console.log(
|
|
222
|
+
console.log("This returns:");
|
|
223
|
+
console.log(" - Agent ID: unique identifier for your agent");
|
|
224
|
+
console.log(" - API Key: for authenticating API calls");
|
|
206
225
|
console.log();
|
|
207
|
-
output.warn(
|
|
226
|
+
output.warn("Save the API key securely - it will not be shown again!");
|
|
208
227
|
// Step 4: Issue tokens
|
|
209
|
-
output.heading(
|
|
210
|
-
console.log(
|
|
228
|
+
output.heading("Step 4: Issue JWT Tokens");
|
|
229
|
+
console.log("Before connecting to the MCP proxy, issue a short-lived JWT:");
|
|
211
230
|
console.log();
|
|
212
|
-
console.log(
|
|
231
|
+
console.log(`Command: ${output.highlight("agentspd agents token <agent-id> --ttl 3600")}`);
|
|
213
232
|
console.log();
|
|
214
|
-
console.log(
|
|
215
|
-
console.log(
|
|
216
|
-
console.log(
|
|
217
|
-
console.log(
|
|
233
|
+
console.log("The token contains:");
|
|
234
|
+
console.log(" - Agent identity claims");
|
|
235
|
+
console.log(" - Permissions and policy version");
|
|
236
|
+
console.log(" - Reputation score");
|
|
218
237
|
// Step 5: Connect to proxy
|
|
219
|
-
output.heading(
|
|
220
|
-
console.log(
|
|
238
|
+
output.heading("Step 5: Connect to MCP Proxy");
|
|
239
|
+
console.log("Use the JWT token to connect your agent:");
|
|
221
240
|
console.log();
|
|
241
|
+
const cfg = getConfig();
|
|
242
|
+
const proxyWsUrl = (process.env.EMOTOS_PROXY_URL || cfg.apiUrl).replace(/^http/, "ws");
|
|
222
243
|
console.log(chalk.gray(`const WebSocket = require('ws');
|
|
223
244
|
|
|
224
|
-
const ws = new WebSocket('
|
|
245
|
+
const ws = new WebSocket('${proxyWsUrl}/v1/mcp', {
|
|
225
246
|
headers: {
|
|
226
247
|
'Authorization': 'Bearer ' + agentToken
|
|
227
248
|
}
|
|
@@ -235,78 +256,78 @@ ws.on('message', (data) => {
|
|
|
235
256
|
// Handle MCP messages
|
|
236
257
|
});`));
|
|
237
258
|
console.log();
|
|
238
|
-
output.success(
|
|
259
|
+
output.success("Tutorial complete!");
|
|
239
260
|
console.log();
|
|
240
|
-
console.log(
|
|
241
|
-
console.log(
|
|
242
|
-
console.log(
|
|
243
|
-
console.log(
|
|
261
|
+
console.log("Next steps:");
|
|
262
|
+
console.log(` - Monitor your agent: ${output.highlight("agentspd agents monitor <agent-id>")}`);
|
|
263
|
+
console.log(` - Check threats: ${output.highlight("agentspd threats list")}`);
|
|
264
|
+
console.log(` - View audit logs: ${output.highlight("agentspd audit events")}`);
|
|
244
265
|
}
|
|
245
266
|
async function consumerTutorial() {
|
|
246
|
-
output.heading(
|
|
247
|
-
console.log(
|
|
248
|
-
console.log(
|
|
249
|
-
console.log(
|
|
250
|
-
console.log(
|
|
251
|
-
console.log(
|
|
267
|
+
output.heading("Agent Consumer Tutorial");
|
|
268
|
+
console.log("This tutorial will guide you through:");
|
|
269
|
+
console.log(" 1. Setting up threat monitoring");
|
|
270
|
+
console.log(" 2. Configuring webhooks for alerts");
|
|
271
|
+
console.log(" 3. Reviewing audit logs");
|
|
272
|
+
console.log(" 4. Responding to security incidents");
|
|
252
273
|
console.log();
|
|
253
|
-
const inquirer = await import(
|
|
274
|
+
const inquirer = await import("inquirer");
|
|
254
275
|
// Step 1: Check authentication
|
|
255
|
-
output.heading(
|
|
276
|
+
output.heading("Step 1: Authentication");
|
|
256
277
|
const config = getConfig();
|
|
257
278
|
if (!config.apiKey && !config.sessionToken) {
|
|
258
|
-
console.log(
|
|
259
|
-
console.log(
|
|
279
|
+
console.log("You need to authenticate first.");
|
|
280
|
+
console.log(`Run: ${output.highlight("agentspd auth signup")}`);
|
|
260
281
|
return;
|
|
261
282
|
}
|
|
262
|
-
output.success(
|
|
283
|
+
output.success("Already authenticated");
|
|
263
284
|
// Step 2: Configure webhooks
|
|
264
|
-
output.heading(
|
|
265
|
-
console.log(
|
|
285
|
+
output.heading("Step 2: Configure Webhook Alerts");
|
|
286
|
+
console.log("Get real-time alerts when threats are detected:");
|
|
266
287
|
console.log();
|
|
267
|
-
console.log(
|
|
288
|
+
console.log(`Command: ${output.highlight("agentspd webhooks create")}`);
|
|
268
289
|
console.log();
|
|
269
|
-
console.log(
|
|
270
|
-
console.log(
|
|
271
|
-
console.log(
|
|
272
|
-
console.log(
|
|
273
|
-
console.log(
|
|
290
|
+
console.log("Recommended events to subscribe:");
|
|
291
|
+
console.log(" - threat.detected");
|
|
292
|
+
console.log(" - threat.blocked");
|
|
293
|
+
console.log(" - agent.suspended");
|
|
294
|
+
console.log(" - agent.reputation_changed");
|
|
274
295
|
// Step 3: Monitor threats
|
|
275
|
-
output.heading(
|
|
276
|
-
console.log(
|
|
277
|
-
console.log(
|
|
296
|
+
output.heading("Step 3: Monitor Threats");
|
|
297
|
+
console.log("View current threats:");
|
|
298
|
+
console.log(` ${output.highlight("agentspd threats list")}`);
|
|
278
299
|
console.log();
|
|
279
|
-
console.log(
|
|
280
|
-
console.log(
|
|
300
|
+
console.log("Watch threats in real-time:");
|
|
301
|
+
console.log(` ${output.highlight("agentspd threats watch")}`);
|
|
281
302
|
console.log();
|
|
282
|
-
console.log(
|
|
283
|
-
console.log(
|
|
303
|
+
console.log("Filter by severity:");
|
|
304
|
+
console.log(` ${output.highlight("agentspd threats list --severity high")}`);
|
|
284
305
|
// Step 4: Review audit logs
|
|
285
|
-
output.heading(
|
|
286
|
-
console.log(
|
|
287
|
-
console.log(
|
|
306
|
+
output.heading("Step 4: Review Audit Logs");
|
|
307
|
+
console.log("Query audit events for compliance:");
|
|
308
|
+
console.log(` ${output.highlight("agentspd audit events --start 2026-01-01")}`);
|
|
288
309
|
console.log();
|
|
289
|
-
console.log(
|
|
290
|
-
console.log(
|
|
310
|
+
console.log("Export for reports:");
|
|
311
|
+
console.log(` ${output.highlight("agentspd audit export --output audit-report.json")}`);
|
|
291
312
|
// Step 5: Respond to incidents
|
|
292
|
-
output.heading(
|
|
293
|
-
console.log(
|
|
313
|
+
output.heading("Step 5: Respond to Incidents");
|
|
314
|
+
console.log("When a threat is detected:");
|
|
294
315
|
console.log();
|
|
295
|
-
console.log(
|
|
296
|
-
console.log(
|
|
316
|
+
console.log("1. Review the threat details:");
|
|
317
|
+
console.log(` ${output.highlight("agentspd threats list --status detected")}`);
|
|
297
318
|
console.log();
|
|
298
|
-
console.log(
|
|
299
|
-
console.log(
|
|
319
|
+
console.log("2. Revoke compromised agent if needed:");
|
|
320
|
+
console.log(` ${output.highlight("agentspd agents revoke <agent-id>")}`);
|
|
300
321
|
console.log();
|
|
301
|
-
console.log(
|
|
302
|
-
console.log(
|
|
322
|
+
console.log("3. Resolve the threat after investigation:");
|
|
323
|
+
console.log(` ${output.highlight("agentspd threats resolve <threat-id>")}`);
|
|
303
324
|
console.log();
|
|
304
|
-
output.success(
|
|
325
|
+
output.success("Tutorial complete!");
|
|
305
326
|
console.log();
|
|
306
|
-
console.log(
|
|
307
|
-
console.log(
|
|
308
|
-
console.log(
|
|
309
|
-
console.log(
|
|
327
|
+
console.log("Useful commands:");
|
|
328
|
+
console.log(` - View all agents: ${output.highlight("agentspd agents list")}`);
|
|
329
|
+
console.log(` - Get threat stats: ${output.highlight("agentspd threats stats")}`);
|
|
330
|
+
console.log(` - Audit statistics: ${output.highlight("agentspd audit stats")}`);
|
|
310
331
|
}
|
|
311
332
|
// Error handling
|
|
312
333
|
program.exitOverride();
|
|
@@ -315,14 +336,16 @@ try {
|
|
|
315
336
|
}
|
|
316
337
|
catch (err) {
|
|
317
338
|
// Handle Commander.js special exits (help, version, etc.)
|
|
318
|
-
if (err instanceof Error &&
|
|
339
|
+
if (err instanceof Error && "code" in err) {
|
|
319
340
|
const code = err.code;
|
|
320
|
-
if (code ===
|
|
341
|
+
if (code === "commander.help" ||
|
|
342
|
+
code === "commander.helpDisplayed" ||
|
|
343
|
+
code === "commander.version") {
|
|
321
344
|
// Help or version was displayed, exit cleanly
|
|
322
345
|
process.exit(0);
|
|
323
346
|
}
|
|
324
347
|
}
|
|
325
348
|
// Real error
|
|
326
|
-
console.error(chalk.red(
|
|
349
|
+
console.error(chalk.red("Error:"), err instanceof Error ? err.message : err);
|
|
327
350
|
process.exit(1);
|
|
328
351
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight HTTP client for the OpenClaw Gateway API.
|
|
3
|
+
*
|
|
4
|
+
* OpenClaw exposes a single HTTP endpoint that multiplexes tool calls:
|
|
5
|
+
* - POST /tools/invoke — invoke any registered tool
|
|
6
|
+
*
|
|
7
|
+
* Available tools include:
|
|
8
|
+
* - sessions_list — list all active sessions
|
|
9
|
+
* - sessions_history — get transcript for a session
|
|
10
|
+
* - message (send) — send a message to a channel
|
|
11
|
+
*
|
|
12
|
+
* All endpoints share the same auth: Bearer token via `gateway.auth.token`.
|
|
13
|
+
*/
|
|
14
|
+
export interface OpenClawToolResult<T = unknown> {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
result?: T;
|
|
17
|
+
error?: {
|
|
18
|
+
type: string;
|
|
19
|
+
message: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface OpenClawSession {
|
|
23
|
+
key: string;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
kind?: string;
|
|
26
|
+
channel?: string;
|
|
27
|
+
displayName?: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
updatedAt?: number;
|
|
30
|
+
agentId?: string;
|
|
31
|
+
summary?: string;
|
|
32
|
+
createdAt?: string;
|
|
33
|
+
lastActivity?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface OpenClawConnectionStatus {
|
|
36
|
+
connected: boolean;
|
|
37
|
+
latencyMs: number;
|
|
38
|
+
error?: string;
|
|
39
|
+
sessions?: OpenClawSession[];
|
|
40
|
+
}
|
|
41
|
+
export interface OpenClawHookResponse {
|
|
42
|
+
ok: boolean;
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Test connectivity to an OpenClaw Gateway by invoking `sessions_list`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function testConnection(gatewayUrl: string, token: string): Promise<OpenClawConnectionStatus>;
|
|
49
|
+
/**
|
|
50
|
+
* List active sessions on the OpenClaw Gateway.
|
|
51
|
+
*/
|
|
52
|
+
export declare function listSessions(gatewayUrl: string, token: string): Promise<OpenClawSession[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Fetch the transcript / history for a specific OpenClaw session.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getSessionHistory(gatewayUrl: string, token: string, sessionKey: string): Promise<unknown[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Send a message through the OpenClaw Gateway using the `message` tool.
|
|
59
|
+
*
|
|
60
|
+
* The Gateway exposes tool invocation via `POST /tools/invoke`. The
|
|
61
|
+
* `message` tool with `action: "send"` delivers a message to the
|
|
62
|
+
* specified channel (slack, telegram, whatsapp, etc.).
|
|
63
|
+
*
|
|
64
|
+
* The `message` tool always requires a `to` target. When none is
|
|
65
|
+
* explicitly provided we auto-resolve it from the most recently active
|
|
66
|
+
* session that matches the requested channel.
|
|
67
|
+
*/
|
|
68
|
+
export declare function invokeHook(gatewayUrl: string, token: string, options: {
|
|
69
|
+
message: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
sessionKey?: string;
|
|
72
|
+
deliver?: boolean;
|
|
73
|
+
channel?: string;
|
|
74
|
+
to?: string;
|
|
75
|
+
}): Promise<OpenClawHookResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Wake the OpenClaw main session by sending a system-level message
|
|
78
|
+
* through the Gateway's `message` tool.
|
|
79
|
+
*/
|
|
80
|
+
export declare function wakeGateway(gatewayUrl: string, token: string, text: string): Promise<OpenClawHookResponse>;
|
|
81
|
+
//# sourceMappingURL=openclaw-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw-api.d.ts","sourceRoot":"","sources":["../src/openclaw-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,OAAO;IAC9C,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C;AAaD,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACxC,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACpC,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AA+BD;;GAEG;AACH,wBAAsB,cAAc,CACnC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,wBAAwB,CAAC,CAmDnC;AAED;;GAEG;AACH,wBAAsB,YAAY,CACjC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,EAAE,CAAC,CAmB5B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACtC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,EAAE,CAAC,CAiCpB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAC/B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IACR,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ,GACC,OAAO,CAAC,oBAAoB,CAAC,CA8G/B;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAChC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACV,OAAO,CAAC,oBAAoB,CAAC,CAK/B"}
|