@openclaw-cloud/agent-controller 0.1.5 → 0.1.6

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.
@@ -0,0 +1,46 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import type { AgentCommand, AgentResponse } from '../types.js';
4
+
5
+ const WORKSPACE_DIR = process.env.WORKSPACE_DIR ?? '/etc/openclaw/workspace';
6
+
7
+ export async function handleFileDelete(command: AgentCommand): Promise<AgentResponse> {
8
+ const filePath = command.payload.path as string;
9
+
10
+ if (!filePath) {
11
+ return {
12
+ id: command.id,
13
+ type: 'file_delete',
14
+ success: false,
15
+ error: 'Missing "path" in payload',
16
+ };
17
+ }
18
+
19
+ if (filePath.includes('..') || filePath.startsWith('/')) {
20
+ return {
21
+ id: command.id,
22
+ type: 'file_delete',
23
+ success: false,
24
+ error: 'Invalid path: must not contain ".." or start with "/"',
25
+ };
26
+ }
27
+
28
+ const resolvedPath = path.join(WORKSPACE_DIR, filePath);
29
+
30
+ try {
31
+ await fs.unlink(resolvedPath);
32
+ return {
33
+ id: command.id,
34
+ type: 'file_delete',
35
+ success: true,
36
+ data: { path: resolvedPath },
37
+ };
38
+ } catch (err) {
39
+ return {
40
+ id: command.id,
41
+ type: 'file_delete',
42
+ success: false,
43
+ error: err instanceof Error ? err.message : String(err),
44
+ };
45
+ }
46
+ }
package/src/index.ts CHANGED
@@ -20,16 +20,14 @@ export function main(): void {
20
20
  const url = rawUrl.replace(/^http:\/\//, 'ws://').replace(/^https:\/\//, 'wss://') + '/connection/websocket';
21
21
  const token = requireEnv('AGENT_TOKEN');
22
22
  const agentId = requireEnv('AGENT_ID');
23
- const backendUrl = process.env.BACKEND_INTERNAL_URL || '';
23
+ const backendUrl = requireEnv('BACKEND_INTERNAL_URL');
24
24
  const centrifugoInternalUrl = process.env.CENTRIFUGO_INTERNAL_URL || '';
25
25
  const centrifugoApiKey = process.env.CENTRIFUGO_API_KEY || '';
26
26
 
27
27
  console.log(`Starting agent-controller for agent: ${agentId}`);
28
- if (backendUrl) {
29
- console.log(`Backend URL: ${backendUrl} (JWT mode)`);
30
- }
28
+ console.log(`Backend URL: ${backendUrl} (JWT mode)`);
31
29
 
32
- const { client } = createConnection({ url, token, agentId, backendUrl: backendUrl || undefined });
30
+ const { client } = createConnection({ url, token, agentId, backendUrl });
33
31
 
34
32
  // Chat provider via OpenClaw Gateway WS
35
33
  const gatewayWsUrl = process.env.OPENCLAW_GATEWAY_WS || 'ws://localhost:18789';
package/src/types.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  export type CommandType =
8
8
  | 'exec' | 'restart' | 'deploy' | 'config' | 'pair' | 'stop' | 'backup'
9
9
  | 'chat_list_sessions' | 'chat_history' | 'chat_send'
10
- | 'package_install' | 'file_write' | 'onboarding_complete';
10
+ | 'package_install' | 'file_write' | 'file_delete' | 'onboarding_complete';
11
11
 
12
12
  export interface AgentCommand {
13
13
  id: string;