@yu_robotics/remote-cli 1.0.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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +94 -0
  3. package/bin/remote-cli.js +2 -0
  4. package/dist/client/MessageHandler.d.ts +92 -0
  5. package/dist/client/MessageHandler.d.ts.map +1 -0
  6. package/dist/client/MessageHandler.js +496 -0
  7. package/dist/client/MessageHandler.js.map +1 -0
  8. package/dist/client/WebSocketClient.d.ts +109 -0
  9. package/dist/client/WebSocketClient.d.ts.map +1 -0
  10. package/dist/client/WebSocketClient.js +234 -0
  11. package/dist/client/WebSocketClient.js.map +1 -0
  12. package/dist/commands/config.d.ts +35 -0
  13. package/dist/commands/config.d.ts.map +1 -0
  14. package/dist/commands/config.js +195 -0
  15. package/dist/commands/config.js.map +1 -0
  16. package/dist/commands/init.d.ts +25 -0
  17. package/dist/commands/init.d.ts.map +1 -0
  18. package/dist/commands/init.js +112 -0
  19. package/dist/commands/init.js.map +1 -0
  20. package/dist/commands/start.d.ts +20 -0
  21. package/dist/commands/start.d.ts.map +1 -0
  22. package/dist/commands/start.js +108 -0
  23. package/dist/commands/start.js.map +1 -0
  24. package/dist/commands/status.d.ts +37 -0
  25. package/dist/commands/status.d.ts.map +1 -0
  26. package/dist/commands/status.js +71 -0
  27. package/dist/commands/status.js.map +1 -0
  28. package/dist/commands/stop.d.ts +23 -0
  29. package/dist/commands/stop.d.ts.map +1 -0
  30. package/dist/commands/stop.js +52 -0
  31. package/dist/commands/stop.js.map +1 -0
  32. package/dist/config/ConfigManager.d.ts +109 -0
  33. package/dist/config/ConfigManager.d.ts.map +1 -0
  34. package/dist/config/ConfigManager.js +262 -0
  35. package/dist/config/ConfigManager.js.map +1 -0
  36. package/dist/executor/ClaudeExecutor.d.ts +89 -0
  37. package/dist/executor/ClaudeExecutor.d.ts.map +1 -0
  38. package/dist/executor/ClaudeExecutor.js +365 -0
  39. package/dist/executor/ClaudeExecutor.js.map +1 -0
  40. package/dist/executor/ClaudePersistentExecutor.d.ts +175 -0
  41. package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -0
  42. package/dist/executor/ClaudePersistentExecutor.js +958 -0
  43. package/dist/executor/ClaudePersistentExecutor.js.map +1 -0
  44. package/dist/executor/index.d.ts +20 -0
  45. package/dist/executor/index.d.ts.map +1 -0
  46. package/dist/executor/index.js +48 -0
  47. package/dist/executor/index.js.map +1 -0
  48. package/dist/hooks/ClaudeCodeHooks.d.ts +281 -0
  49. package/dist/hooks/ClaudeCodeHooks.d.ts.map +1 -0
  50. package/dist/hooks/ClaudeCodeHooks.js +350 -0
  51. package/dist/hooks/ClaudeCodeHooks.js.map +1 -0
  52. package/dist/hooks/FeishuNotificationAdapter.d.ts +87 -0
  53. package/dist/hooks/FeishuNotificationAdapter.d.ts.map +1 -0
  54. package/dist/hooks/FeishuNotificationAdapter.js +280 -0
  55. package/dist/hooks/FeishuNotificationAdapter.js.map +1 -0
  56. package/dist/hooks/index.d.ts +4 -0
  57. package/dist/hooks/index.d.ts.map +1 -0
  58. package/dist/hooks/index.js +10 -0
  59. package/dist/hooks/index.js.map +1 -0
  60. package/dist/index.d.ts +3 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +333 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/security/DirectoryGuard.d.ts +54 -0
  65. package/dist/security/DirectoryGuard.d.ts.map +1 -0
  66. package/dist/security/DirectoryGuard.js +143 -0
  67. package/dist/security/DirectoryGuard.js.map +1 -0
  68. package/dist/types/config.d.ts +46 -0
  69. package/dist/types/config.d.ts.map +1 -0
  70. package/dist/types/config.js +22 -0
  71. package/dist/types/config.js.map +1 -0
  72. package/dist/types/index.d.ts +110 -0
  73. package/dist/types/index.d.ts.map +1 -0
  74. package/dist/types/index.js +3 -0
  75. package/dist/types/index.js.map +1 -0
  76. package/dist/utils/FeishuMessageFormatter.d.ts +84 -0
  77. package/dist/utils/FeishuMessageFormatter.d.ts.map +1 -0
  78. package/dist/utils/FeishuMessageFormatter.js +395 -0
  79. package/dist/utils/FeishuMessageFormatter.js.map +1 -0
  80. package/dist/utils/stripAnsi.d.ts +21 -0
  81. package/dist/utils/stripAnsi.d.ts.map +1 -0
  82. package/dist/utils/stripAnsi.js +30 -0
  83. package/dist/utils/stripAnsi.js.map +1 -0
  84. package/package.json +63 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 xiaoyu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # @yu_robotics/remote-cli
2
+
3
+ Remote control your [Claude Code](https://claude.ai/code) CLI from anywhere using your mobile phone through Feishu (Lark) messaging.
4
+
5
+ ## Features
6
+
7
+ - **Remote Control**: Control your local development environment from anywhere via mobile
8
+ - **Secure**: Directory whitelisting, command filtering, and device authentication
9
+ - **Mobile-Optimized**: Simplified commands and rich text formatting for Feishu
10
+ - **Claude Code Integration**: Full access to Claude Code's capabilities and context
11
+ - **Persistent Process**: Long-running Claude process with bidirectional streaming (no repeated spawn overhead)
12
+
13
+ ## Prerequisites
14
+
15
+ - **Node.js** >= 18.0.0
16
+ - **Claude Code CLI** installed and configured
17
+ - Access to a Feishu (Lark) bot connected to a [remote-cli-router](https://www.npmjs.com/package/@yu_robotics/remote-cli-router) server
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install -g @yu_robotics/remote-cli
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ### 1. Initialize
28
+
29
+ ```bash
30
+ remote-cli init --server https://your-router-server.com
31
+ ```
32
+
33
+ ### 2. Bind Device in Feishu
34
+
35
+ Send the binding code to the Feishu bot:
36
+
37
+ ```
38
+ /bind ABC-123-XYZ
39
+ ```
40
+
41
+ ### 3. Configure Allowed Directories
42
+
43
+ ```bash
44
+ remote-cli config add-dir ~/projects ~/work
45
+ ```
46
+
47
+ ### 4. Start the Service
48
+
49
+ ```bash
50
+ remote-cli start
51
+ ```
52
+
53
+ ### 5. Send Commands via Feishu
54
+
55
+ ```
56
+ Help me fix TypeScript errors in ~/projects/my-app
57
+ ```
58
+
59
+ ## Commands
60
+
61
+ | Command | Description |
62
+ |---------|-------------|
63
+ | `remote-cli init -s <url>` | Initialize and generate binding code |
64
+ | `remote-cli start` | Start the background service |
65
+ | `remote-cli stop` | Stop the service |
66
+ | `remote-cli status` | Check service status |
67
+ | `remote-cli config show` | View configuration |
68
+ | `remote-cli config add-dir <path>` | Add allowed directory |
69
+
70
+ ## Feishu Bot Commands
71
+
72
+ | Command | Description |
73
+ |---------|-------------|
74
+ | `/cd <path>` | Change working directory |
75
+ | `/status` | Check connection status |
76
+ | `/c` or `/continue` | Continue previous conversation |
77
+ | `/r` or `/resume` | Resume from last session |
78
+ | `/clear` | Clear current session |
79
+ | `/help` | Show help |
80
+
81
+ ## Security
82
+
83
+ - **Directory whitelisting**: Only explicitly allowed directories are accessible
84
+ - **Command filtering**: Dangerous commands are automatically blocked
85
+ - **Device authentication**: Each device has a unique hardware-based ID
86
+ - **Binding codes**: Expire after 5 minutes
87
+
88
+ ## Documentation
89
+
90
+ For full documentation including router server deployment, see the [project README](https://github.com/xiaoyu/remote-cli#readme).
91
+
92
+ ## License
93
+
94
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/index.js');
@@ -0,0 +1,92 @@
1
+ import { WebSocketClient } from './WebSocketClient';
2
+ import { DirectoryGuard } from '../security/DirectoryGuard';
3
+ import { IncomingMessage } from '../types';
4
+ import type { ClaudeExecutor, ClaudePersistentExecutor } from '../executor';
5
+ /**
6
+ * Legacy message type for backward compatibility
7
+ */
8
+ export interface Message {
9
+ type: string;
10
+ messageId?: string;
11
+ content?: string;
12
+ timestamp?: number;
13
+ }
14
+ /**
15
+ * Message Handler
16
+ * Responsible for handling messages from WebSocket and invoking Claude executor
17
+ */
18
+ export declare class MessageHandler {
19
+ private wsClient;
20
+ private executor;
21
+ private directoryGuard;
22
+ private isDestroyed;
23
+ private isExecuting;
24
+ private currentOpenId?;
25
+ private notificationAdapter;
26
+ constructor(wsClient: WebSocketClient, executor: ClaudeExecutor | ClaudePersistentExecutor, directoryGuard: DirectoryGuard);
27
+ /**
28
+ * Handle message (supports new IncomingMessage format)
29
+ * @param message Message object
30
+ */
31
+ handleMessage(message: Message | IncomingMessage): Promise<void>;
32
+ /**
33
+ * Handle command message
34
+ */
35
+ private handleCommandMessage;
36
+ /**
37
+ * Handle abort command
38
+ * Can be executed even when executor is busy
39
+ */
40
+ private handleAbortCommand;
41
+ /**
42
+ * Handle status query
43
+ */
44
+ private handleStatusQuery;
45
+ /**
46
+ * Validate message structure
47
+ */
48
+ private isValidMessage;
49
+ /**
50
+ * Handle built-in commands
51
+ * @returns Returns true if built-in command was handled, otherwise false
52
+ */
53
+ private handleBuiltInCommand;
54
+ /**
55
+ * Expand command shortcuts
56
+ */
57
+ private expandCommandShortcuts;
58
+ /**
59
+ * Execute passthrough slash command using local Claude CLI
60
+ * This allows users to use their custom slash commands
61
+ */
62
+ private executeSlashCommand;
63
+ /**
64
+ * Execute Claude command
65
+ */
66
+ private executeCommand;
67
+ /**
68
+ * Send streaming output chunk
69
+ */
70
+ private sendStreamChunk;
71
+ /**
72
+ * Send tool use event
73
+ */
74
+ private sendToolUse;
75
+ /**
76
+ * Send tool result event
77
+ */
78
+ private sendToolResult;
79
+ /**
80
+ * Send structured content for rich formatting
81
+ */
82
+ private sendStructuredContent;
83
+ /**
84
+ * Send response
85
+ */
86
+ private sendResponse;
87
+ /**
88
+ * Destroy handler
89
+ */
90
+ destroy(): void;
91
+ }
92
+ //# sourceMappingURL=MessageHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageHandler.d.ts","sourceRoot":"","sources":["../../src/client/MessageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAmE,MAAM,UAAU,CAAC;AAC5G,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAI5E;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,QAAQ,CAA4C;IAC5D,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,mBAAmB,CAA4B;gBAGrD,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,cAAc,GAAG,wBAAwB,EACnD,cAAc,EAAE,cAAc;IAWhC;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAyCtE;;OAEG;YACW,oBAAoB;IAmGlC;;;OAGG;YACW,kBAAkB;IAoBhC;;OAEG;YACW,iBAAiB;IAa/B;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;;OAGG;YACW,oBAAoB;IAsFlC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;;OAGG;YACW,mBAAmB;IAgEjC;;OAEG;YACW,cAAc;IA+B5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAgBvB;;OAEG;IACH,OAAO,CAAC,WAAW;IAenB;;OAEG;IACH,OAAO,CAAC,cAAc;IAetB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAe7B;;OAEG;IACH,OAAO,CAAC,YAAY;IAqBpB;;OAEG;IACH,OAAO,IAAI,IAAI;CAKhB"}