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/dist/index.js CHANGED
@@ -1,33 +1,29 @@
1
1
  #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import chalk from 'chalk';
4
- import { createAuthCommand, createAgentsCommand, createPoliciesCommand, createAuditCommand, createThreatsCommand, createWebhooksCommand, createConfigCommand, createInitCommand, } from './commands/index.js';
5
- import { setConfig, getConfig } from './config.js';
6
- import * as output from './output.js';
7
- const VERSION = '1.0.0';
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('')} ${chalk.bold.white('EMOTOS CLI')} - Security Infrastructure for AI Agents ${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('agentspd')
16
- .description('Emotos CLI - Security Infrastructure for AI Agents')
15
+ .name("agentspd")
16
+ .description("Emotos CLI - Security Infrastructure for AI Agents")
17
17
  .version(VERSION)
18
- .option('--api-url <url>', 'Override API URL')
19
- .option('--json', 'Output in JSON format')
20
- .option('--yaml', 'Output in YAML format')
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('apiUrl', opts.apiUrl);
23
+ setConfig("apiUrl", opts.apiUrl);
25
24
  }
26
- if (opts.json) {
27
- setConfig('outputFormat', 'json');
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('login')
45
- .description('Quick login (alias for auth login)')
46
- .option('-k, --api-key <key>', 'Use API key')
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() === 'login');
53
+ const loginCmd = authCmd.commands.find((c) => c.name() === "login");
50
54
  if (loginCmd) {
51
- await loginCmd.parseAsync(['', '', ...(options.apiKey ? ['-k', options.apiKey] : [])]);
55
+ await loginCmd.parseAsync([
56
+ "",
57
+ "",
58
+ ...(options.apiKey ? ["-k", options.apiKey] : []),
59
+ ]);
52
60
  }
53
61
  });
54
62
  program
55
- .command('status')
56
- .description('Show authentication and system status')
63
+ .command("status")
64
+ .description("Show authentication and system status")
57
65
  .action(async () => {
58
66
  const config = getConfig();
59
- output.heading('Emotos Status');
67
+ output.heading("Emotos Status");
60
68
  // Auth status
61
- const authStatus = config.apiKey || config.sessionToken ? 'Authenticated' : 'Not authenticated';
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
- ['Auth Status', authColor(authStatus)],
65
- ['API URL', config.apiUrl],
66
- ['Organization', config.orgName || 'N/A'],
67
- ['User', config.userName || 'N/A'],
68
- ['Environment', config.defaultEnvironment],
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('Run `agentspd auth login` to authenticate');
82
+ output.info("Run `agentspd auth login` to authenticate");
73
83
  }
74
84
  });
75
85
  // Help command enhancements
76
86
  program
77
- .command('docs')
78
- .description('Open documentation')
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('Documentation');
82
- console.log(' Full documentation: ' + output.link('https://docs.emotos.ai'));
83
- console.log(' API Reference: ' + output.link('https://api.emotos.ai/docs'));
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('Quick Start');
86
- console.log(' 1. Sign up: ' + output.highlight('agentspd auth signup'));
87
- console.log(' 2. Create policy: ' + output.highlight('agentspd policies create'));
88
- console.log(' 3. Register agent: ' + output.highlight('agentspd agents create'));
89
- console.log(' 4. Issue token: ' + output.highlight('agentspd agents token <agent-id>'));
90
- console.log(' 5. Connect to MCP: ' + output.highlight('wss://proxy.emotos.ai/v1/mcp'));
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('For Agent Providers');
93
- console.log(' - Register and manage AI agents');
94
- console.log(' - Define security policies');
95
- console.log(' - Monitor agent reputation and behavior');
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('For Agent Consumers');
98
- console.log(' - Vet and approve third-party agents');
99
- console.log(' - Monitor threats in real-time');
100
- console.log(' - Review audit logs for compliance');
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('quickstart')
104
- .alias('tutorial')
105
- .description('Interactive quickstart tutorial')
106
- .option('--provider', 'Agent provider tutorial')
107
- .option('--consumer', 'Agent consumer tutorial')
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('inquirer');
130
+ const inquirer = await import("inquirer");
118
131
  const answers = await inquirer.default.prompt([
119
132
  {
120
- type: 'list',
121
- name: 'role',
122
- message: 'Which tutorial would you like to follow?',
133
+ type: "list",
134
+ name: "role",
135
+ message: "Which tutorial would you like to follow?",
123
136
  choices: [
124
- { name: 'Agent Provider - Build and deploy secure AI agents', value: 'provider' },
125
- { name: 'Agent Consumer - Protect your systems from AI agents', value: 'consumer' },
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 === 'provider') {
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('Agent Provider Tutorial');
139
- console.log('This tutorial will guide you through:');
140
- console.log(' 1. Creating a security policy');
141
- console.log(' 2. Registering an AI agent');
142
- console.log(' 3. Issuing identity tokens');
143
- console.log(' 4. Connecting to the MCP proxy');
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('inquirer');
164
+ const inquirer = await import("inquirer");
146
165
  // Step 1: Check authentication
147
- output.heading('Step 1: Authentication');
166
+ output.heading("Step 1: Authentication");
148
167
  const config = getConfig();
149
168
  if (!config.apiKey && !config.sessionToken) {
150
- console.log('You need to authenticate first.');
169
+ console.log("You need to authenticate first.");
151
170
  const answers = await inquirer.default.prompt([
152
171
  {
153
- type: 'confirm',
154
- name: 'signup',
155
- message: 'Would you like to create an account now?',
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('Run: ' + output.highlight('agentspd auth signup'));
162
- console.log('Then run this tutorial again.');
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('Already authenticated');
186
+ output.success("Already authenticated");
168
187
  }
169
188
  // Step 2: Create a policy
170
- output.heading('Step 2: Create a Security Policy');
171
- console.log('Security policies define what your agents can and cannot do.');
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('Example policy (save as my-policy.yaml):');
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('Create with: ' + output.highlight('agentspd policies create --file my-policy.yaml'));
215
+ console.log(`Create with: ${output.highlight("agentspd policies create --file my-policy.yaml")}`);
197
216
  // Step 3: Register an agent
198
- output.heading('Step 3: Register Your Agent');
199
- console.log('Each AI agent needs a unique identity.');
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('Create with: ' + output.highlight('agentspd agents create --name my-agent --environment development'));
220
+ console.log(`Create with: ${output.highlight("agentspd agents create --name my-agent --environment development")}`);
202
221
  console.log();
203
- console.log('This returns:');
204
- console.log(' - Agent ID: unique identifier for your agent');
205
- console.log(' - API Key: for authenticating API calls');
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('Save the API key securely - it will not be shown again!');
226
+ output.warn("Save the API key securely - it will not be shown again!");
208
227
  // Step 4: Issue tokens
209
- output.heading('Step 4: Issue JWT Tokens');
210
- console.log('Before connecting to the MCP proxy, issue a short-lived JWT:');
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('Command: ' + output.highlight('agentspd agents token <agent-id> --ttl 3600'));
231
+ console.log(`Command: ${output.highlight("agentspd agents token <agent-id> --ttl 3600")}`);
213
232
  console.log();
214
- console.log('The token contains:');
215
- console.log(' - Agent identity claims');
216
- console.log(' - Permissions and policy version');
217
- console.log(' - Reputation score');
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('Step 5: Connect to MCP Proxy');
220
- console.log('Use the JWT token to connect your agent:');
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('wss://proxy.emotos.ai/v1/mcp', {
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('Tutorial complete!');
259
+ output.success("Tutorial complete!");
239
260
  console.log();
240
- console.log('Next steps:');
241
- console.log(' - Monitor your agent: ' + output.highlight('agentspd agents monitor <agent-id>'));
242
- console.log(' - Check threats: ' + output.highlight('agentspd threats list'));
243
- console.log(' - View audit logs: ' + output.highlight('agentspd audit events'));
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('Agent Consumer Tutorial');
247
- console.log('This tutorial will guide you through:');
248
- console.log(' 1. Setting up threat monitoring');
249
- console.log(' 2. Configuring webhooks for alerts');
250
- console.log(' 3. Reviewing audit logs');
251
- console.log(' 4. Responding to security incidents');
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('inquirer');
274
+ const inquirer = await import("inquirer");
254
275
  // Step 1: Check authentication
255
- output.heading('Step 1: Authentication');
276
+ output.heading("Step 1: Authentication");
256
277
  const config = getConfig();
257
278
  if (!config.apiKey && !config.sessionToken) {
258
- console.log('You need to authenticate first.');
259
- console.log('Run: ' + output.highlight('agentspd auth signup --role consumer'));
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('Already authenticated');
283
+ output.success("Already authenticated");
263
284
  // Step 2: Configure webhooks
264
- output.heading('Step 2: Configure Webhook Alerts');
265
- console.log('Get real-time alerts when threats are detected:');
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('Command: ' + output.highlight('agentspd webhooks create'));
288
+ console.log(`Command: ${output.highlight("agentspd webhooks create")}`);
268
289
  console.log();
269
- console.log('Recommended events to subscribe:');
270
- console.log(' - threat.detected');
271
- console.log(' - threat.blocked');
272
- console.log(' - agent.suspended');
273
- console.log(' - agent.reputation_changed');
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('Step 3: Monitor Threats');
276
- console.log('View current threats:');
277
- console.log(' ' + output.highlight('agentspd threats list'));
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('Watch threats in real-time:');
280
- console.log(' ' + output.highlight('agentspd threats watch'));
300
+ console.log("Watch threats in real-time:");
301
+ console.log(` ${output.highlight("agentspd threats watch")}`);
281
302
  console.log();
282
- console.log('Filter by severity:');
283
- console.log(' ' + output.highlight('agentspd threats list --severity high'));
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('Step 4: Review Audit Logs');
286
- console.log('Query audit events for compliance:');
287
- console.log(' ' + output.highlight('agentspd audit events --start 2026-01-01'));
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('Export for reports:');
290
- console.log(' ' + output.highlight('agentspd audit export --output audit-report.json'));
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('Step 5: Respond to Incidents');
293
- console.log('When a threat is detected:');
313
+ output.heading("Step 5: Respond to Incidents");
314
+ console.log("When a threat is detected:");
294
315
  console.log();
295
- console.log('1. Review the threat details:');
296
- console.log(' ' + output.highlight('agentspd threats list --status detected'));
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('2. Revoke compromised agent if needed:');
299
- console.log(' ' + output.highlight('agentspd agents revoke <agent-id>'));
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('3. Resolve the threat after investigation:');
302
- console.log(' ' + output.highlight('agentspd threats resolve <threat-id>'));
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('Tutorial complete!');
325
+ output.success("Tutorial complete!");
305
326
  console.log();
306
- console.log('Useful commands:');
307
- console.log(' - View all agents: ' + output.highlight('agentspd agents list'));
308
- console.log(' - Get threat stats: ' + output.highlight('agentspd threats stats'));
309
- console.log(' - Audit statistics: ' + output.highlight('agentspd audit stats'));
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 && 'code' in err) {
339
+ if (err instanceof Error && "code" in err) {
319
340
  const code = err.code;
320
- if (code === 'commander.help' || code === 'commander.helpDisplayed' || code === 'commander.version') {
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('Error:'), err instanceof Error ? err.message : err);
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"}