@leverageaiapps/locus 1.0.3
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/LICENSE +21 -0
- package/README.md +153 -0
- package/dist/capture.d.ts +3 -0
- package/dist/capture.d.ts.map +1 -0
- package/dist/capture.js +134 -0
- package/dist/capture.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +84 -0
- package/dist/config.js.map +1 -0
- package/dist/context-extractor.d.ts +17 -0
- package/dist/context-extractor.d.ts.map +1 -0
- package/dist/context-extractor.js +118 -0
- package/dist/context-extractor.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/dist/pty.d.ts +20 -0
- package/dist/pty.d.ts.map +1 -0
- package/dist/pty.js +148 -0
- package/dist/pty.js.map +1 -0
- package/dist/relay.d.ts +5 -0
- package/dist/relay.d.ts.map +1 -0
- package/dist/relay.js +131 -0
- package/dist/relay.js.map +1 -0
- package/dist/session.d.ts +6 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +250 -0
- package/dist/session.js.map +1 -0
- package/dist/voice-recognition-modelscope.d.ts +50 -0
- package/dist/voice-recognition-modelscope.d.ts.map +1 -0
- package/dist/voice-recognition-modelscope.js +171 -0
- package/dist/voice-recognition-modelscope.js.map +1 -0
- package/dist/vortex-tunnel.d.ts +9 -0
- package/dist/vortex-tunnel.d.ts.map +1 -0
- package/dist/vortex-tunnel.js +355 -0
- package/dist/vortex-tunnel.js.map +1 -0
- package/dist/web-server.d.ts +6 -0
- package/dist/web-server.d.ts.map +1 -0
- package/dist/web-server.js +2029 -0
- package/dist/web-server.js.map +1 -0
- package/install.sh +329 -0
- package/package.json +67 -0
- package/public/index.html +639 -0
- package/public/js/terminal-asr.js +435 -0
- package/public/js/terminal.js +517 -0
- package/public/js/voice-input.js +422 -0
- package/scripts/postinstall.js +66 -0
- package/scripts/verify-install.js +128 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 LeverageAI Apps
|
|
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,153 @@
|
|
|
1
|
+
# Locus
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@leverageaiapps/locus)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
Forward your terminal to your mobile device. **Code anywhere from your pocket.**
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen" alt="Node.js">
|
|
10
|
+
<img src="https://img.shields.io/badge/platform-macOS%20%7C%20Linux-blue" alt="Platform">
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- 🚀 **Instant Setup** - One command to start forwarding your terminal
|
|
16
|
+
- 📱 **Mobile Access** - Access your terminal from any device with a browser
|
|
17
|
+
- 🎙️ **Voice Input** - Built-in voice recognition for hands-free coding
|
|
18
|
+
- 🔒 **Secure** - PIN-protected sessions with automatic IP blocking
|
|
19
|
+
- 🌐 **No Port Forwarding** - Uses Vortex Gateway for secure tunneling
|
|
20
|
+
- ⚡ **Real-time** - WebSocket-based communication for instant feedback
|
|
21
|
+
- 🎯 **PTY Support** - Full terminal emulation with node-pty
|
|
22
|
+
|
|
23
|
+
## Prerequisites
|
|
24
|
+
|
|
25
|
+
Locus requires Node.js 18 or higher. The Vortex tunnel is built-in and requires no additional dependencies.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g @leverageaiapps/locus
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Verify Installation:**
|
|
34
|
+
```bash
|
|
35
|
+
locus --version
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Start a terminal session
|
|
42
|
+
locus
|
|
43
|
+
|
|
44
|
+
# Start with a specific command
|
|
45
|
+
locus claude
|
|
46
|
+
locus python
|
|
47
|
+
locus vim
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A QR code will appear - scan it with your phone and enter the 6-digit PIN to access your terminal!
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
### Basic Commands
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Start a terminal session
|
|
58
|
+
locus
|
|
59
|
+
|
|
60
|
+
# Start with a custom PIN
|
|
61
|
+
locus --pin 123456
|
|
62
|
+
|
|
63
|
+
# Start with a machine name
|
|
64
|
+
locus --name "My Laptop"
|
|
65
|
+
|
|
66
|
+
# Start a specific command with PIN
|
|
67
|
+
locus claude --pin 123456
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Options
|
|
71
|
+
|
|
72
|
+
| Option | Short | Description |
|
|
73
|
+
|--------|-------|-------------|
|
|
74
|
+
| `--name <name>` | `-n` | Set a custom machine name |
|
|
75
|
+
| `--pin <pin>` | `-p` | Set a custom 6-digit PIN |
|
|
76
|
+
| `--debug-asr` | | Enable verbose ASR logging |
|
|
77
|
+
|
|
78
|
+
### Configuration
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Show current configuration
|
|
82
|
+
locus config --show
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## How It Works
|
|
86
|
+
|
|
87
|
+
1. Run `locus [command]` in your terminal
|
|
88
|
+
2. Locus starts a local web server and creates a Vortex tunnel
|
|
89
|
+
3. A QR code appears with your unique URL
|
|
90
|
+
4. Scan the QR code with your phone
|
|
91
|
+
5. Enter the 6-digit PIN to access your terminal
|
|
92
|
+
6. Your terminal is now accessible from your mobile device!
|
|
93
|
+
|
|
94
|
+
### Exiting
|
|
95
|
+
|
|
96
|
+
To exit Locus, you can:
|
|
97
|
+
- Type `exit` in the terminal (or the command to exit your current program)
|
|
98
|
+
- Press `Ctrl+C` in the terminal where you ran `locus`
|
|
99
|
+
- Close the terminal window
|
|
100
|
+
|
|
101
|
+
When you see **"Terminal session ended."**, the session has been successfully closed.
|
|
102
|
+
|
|
103
|
+
## Security
|
|
104
|
+
|
|
105
|
+
- **PIN Protection**: Each session requires a 6-digit PIN
|
|
106
|
+
- **Rate Limiting**: Max 10 failed login attempts per IP
|
|
107
|
+
- **Auto-blocking**: IPs are temporarily blocked after too many failures
|
|
108
|
+
- **Session Cookies**: Authentication persists for 24 hours
|
|
109
|
+
|
|
110
|
+
## Troubleshooting
|
|
111
|
+
|
|
112
|
+
### Error: posix_spawnp failed
|
|
113
|
+
|
|
114
|
+
Fix permissions on the node-pty spawn-helper:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# macOS ARM (M1/M2/M3)
|
|
118
|
+
chmod +x node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper
|
|
119
|
+
|
|
120
|
+
# macOS Intel
|
|
121
|
+
chmod +x node_modules/node-pty/prebuilds/darwin-x64/spawn-helper
|
|
122
|
+
|
|
123
|
+
# Linux x64
|
|
124
|
+
chmod +x node_modules/node-pty/prebuilds/linux-x64/spawn-helper
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Connection Issues
|
|
128
|
+
|
|
129
|
+
If you encounter connection issues, verify the Vortex gateway is accessible:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
curl -I https://vortex.futuretech.social/health
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Contributing
|
|
136
|
+
|
|
137
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
138
|
+
|
|
139
|
+
1. Fork the repository
|
|
140
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
141
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
142
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
143
|
+
5. Open a Pull Request
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
148
|
+
|
|
149
|
+
## Acknowledgments
|
|
150
|
+
|
|
151
|
+
- [Vortex Gateway](https://github.com/tan-zhuo/Vortex-Gateway) for secure WebSocket tunneling
|
|
152
|
+
- [node-pty](https://github.com/microsoft/node-pty) for PTY support
|
|
153
|
+
- [xterm.js](https://xtermjs.org/) for terminal emulation in the browser
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":"AASA,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAuCvE;AAED,wBAAgB,WAAW,IAAI,IAAI,CASlC"}
|
package/dist/capture.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.startCapture = startCapture;
|
|
40
|
+
exports.stopCapture = stopCapture;
|
|
41
|
+
const axios_1 = __importDefault(require("axios"));
|
|
42
|
+
const readline = __importStar(require("readline"));
|
|
43
|
+
// Buffer for accumulating partial lines
|
|
44
|
+
let lineBuffer = '';
|
|
45
|
+
let debounceTimer = null;
|
|
46
|
+
const DEBOUNCE_MS = 100;
|
|
47
|
+
let rl = null;
|
|
48
|
+
function startCapture(sessionId, serverUrl) {
|
|
49
|
+
// Only set up stdin capture if we're receiving piped input
|
|
50
|
+
if (process.stdin.isTTY) {
|
|
51
|
+
// Running interactively (not piped), don't capture stdin
|
|
52
|
+
console.log(' [Capture] Running in interactive mode');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Create readline interface for stdin (for piped input)
|
|
56
|
+
rl = readline.createInterface({
|
|
57
|
+
input: process.stdin,
|
|
58
|
+
output: process.stdout,
|
|
59
|
+
terminal: false,
|
|
60
|
+
});
|
|
61
|
+
// Listen for lines from Claude Code (piped input)
|
|
62
|
+
rl.on('line', (line) => {
|
|
63
|
+
// Accumulate lines and debounce sending
|
|
64
|
+
lineBuffer += line + '\n';
|
|
65
|
+
if (debounceTimer) {
|
|
66
|
+
clearTimeout(debounceTimer);
|
|
67
|
+
}
|
|
68
|
+
debounceTimer = setTimeout(() => {
|
|
69
|
+
sendMessage(sessionId, serverUrl, lineBuffer.trim());
|
|
70
|
+
lineBuffer = '';
|
|
71
|
+
}, DEBOUNCE_MS);
|
|
72
|
+
});
|
|
73
|
+
rl.on('close', () => {
|
|
74
|
+
// Send any remaining buffer
|
|
75
|
+
if (lineBuffer.trim()) {
|
|
76
|
+
sendMessage(sessionId, serverUrl, lineBuffer.trim());
|
|
77
|
+
}
|
|
78
|
+
console.log(' Input stream closed.');
|
|
79
|
+
});
|
|
80
|
+
console.log(' [Capture] Listening for piped input...');
|
|
81
|
+
}
|
|
82
|
+
function stopCapture() {
|
|
83
|
+
if (rl) {
|
|
84
|
+
rl.close();
|
|
85
|
+
rl = null;
|
|
86
|
+
}
|
|
87
|
+
if (debounceTimer) {
|
|
88
|
+
clearTimeout(debounceTimer);
|
|
89
|
+
debounceTimer = null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function sendMessage(sessionId, serverUrl, text) {
|
|
93
|
+
if (!text)
|
|
94
|
+
return;
|
|
95
|
+
try {
|
|
96
|
+
// Try to parse as Claude Code message format
|
|
97
|
+
const content = parseClaudeCodeMessage(text);
|
|
98
|
+
await axios_1.default.post(`${serverUrl}/api/sessions/${sessionId}/messages`, {
|
|
99
|
+
role: 'agent',
|
|
100
|
+
content,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// Silently fail - we don't want to interrupt the user
|
|
105
|
+
if (process.env.DEBUG) {
|
|
106
|
+
console.error('Failed to send message:', error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Parse Claude Code output into structured format
|
|
111
|
+
function parseClaudeCodeMessage(text) {
|
|
112
|
+
// Check for tool use patterns
|
|
113
|
+
const toolUseMatch = text.match(/^(?:Using|Running|Executing|Calling)\s+(\w+)/i);
|
|
114
|
+
if (toolUseMatch) {
|
|
115
|
+
return {
|
|
116
|
+
type: 'tool-call',
|
|
117
|
+
name: toolUseMatch[1],
|
|
118
|
+
input: { description: text },
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// Check for code blocks
|
|
122
|
+
if (text.includes('```')) {
|
|
123
|
+
return {
|
|
124
|
+
type: 'text',
|
|
125
|
+
text,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// Default to text
|
|
129
|
+
return {
|
|
130
|
+
type: 'text',
|
|
131
|
+
text,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,oCAuCC;AAED,kCASC;AA3DD,kDAA0B;AAC1B,mDAAqC;AAErC,wCAAwC;AACxC,IAAI,UAAU,GAAG,EAAE,CAAC;AACpB,IAAI,aAAa,GAA0B,IAAI,CAAC;AAChD,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,IAAI,EAAE,GAA8B,IAAI,CAAC;AAEzC,SAAgB,YAAY,CAAC,SAAiB,EAAE,SAAiB;IAC7D,2DAA2D;IAC3D,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,yDAAyD;QACzD,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,OAAO;IACX,CAAC;IAED,wDAAwD;IACxD,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,kDAAkD;IAClD,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QACnB,wCAAwC;QACxC,UAAU,IAAI,IAAI,GAAG,IAAI,CAAC;QAE1B,IAAI,aAAa,EAAE,CAAC;YAChB,YAAY,CAAC,aAAa,CAAC,CAAC;QAChC,CAAC;QAED,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;YACrD,UAAU,GAAG,EAAE,CAAC;QACpB,CAAC,EAAE,WAAW,CAAC,CAAC;IACpB,CAAC,CAAC,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AAC,CAAC;IACjF,IAAI,YAAY,EAAE,CAAC;QACf,OAAO;YACH,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;YACrB,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;SAC/B,CAAC;IACN,CAAC;IAED,wBAAwB;IACxB,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;YACH,IAAI,EAAE,MAAM;YACZ,IAAI;SACP,CAAC;IACN,CAAC;IAED,kBAAkB;IAClB,OAAO;QACH,IAAI,EAAE,MAAM;QACZ,IAAI;KACP,CAAC;AACN,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,MAAM;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAgBD,wBAAgB,SAAS,IAAI,MAAM,CAalC;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAexD"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getConfig = getConfig;
|
|
37
|
+
exports.setConfig = setConfig;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const os = __importStar(require("os"));
|
|
41
|
+
const CONFIG_DIR = path.join(os.homedir(), '.codingin');
|
|
42
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
43
|
+
const DEFAULT_CONFIG = {
|
|
44
|
+
serverUrl: process.env.CODINGIN_SERVER_URL || 'https://codingin.futuretech.social',
|
|
45
|
+
machineId: generateMachineId(),
|
|
46
|
+
};
|
|
47
|
+
function generateMachineId() {
|
|
48
|
+
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
49
|
+
let result = '';
|
|
50
|
+
for (let i = 0; i < 16; i++) {
|
|
51
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
function getConfig() {
|
|
56
|
+
try {
|
|
57
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
58
|
+
const data = fs.readFileSync(CONFIG_FILE, 'utf-8');
|
|
59
|
+
return { ...DEFAULT_CONFIG, ...JSON.parse(data) };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error('Error reading config:', error);
|
|
64
|
+
}
|
|
65
|
+
// Create default config
|
|
66
|
+
setConfig(DEFAULT_CONFIG);
|
|
67
|
+
return DEFAULT_CONFIG;
|
|
68
|
+
}
|
|
69
|
+
function setConfig(updates) {
|
|
70
|
+
try {
|
|
71
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
72
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
const current = fs.existsSync(CONFIG_FILE)
|
|
75
|
+
? JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'))
|
|
76
|
+
: DEFAULT_CONFIG;
|
|
77
|
+
const newConfig = { ...current, ...updates };
|
|
78
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(newConfig, null, 2));
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error('Error writing config:', error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,8BAaC;AAED,8BAeC;AAxDD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAEzB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AACxD,MAAM,WAAW,GAAG,IAAI,CAAC,I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C;QAED,MAAM,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;YACtC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACnD,CAAC,CAAC,cAAc,CAAC;QAErB,MAAM,SAAS,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;QAC7C,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ExtractedContext {
|
|
2
|
+
techTerms: string[];
|
|
3
|
+
filePaths: string[];
|
|
4
|
+
recentCommands: string[];
|
|
5
|
+
codeKeywords: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class ContextExtractor {
|
|
8
|
+
private static readonly TECH_PATTERNS;
|
|
9
|
+
private static readonly COMMON_TECH_TERMS;
|
|
10
|
+
static extractFromBuffer(buffer: string[], limit?: number): ExtractedContext;
|
|
11
|
+
static generateHotwords(context: ExtractedContext): Array<{
|
|
12
|
+
word: string;
|
|
13
|
+
boost: number;
|
|
14
|
+
}>;
|
|
15
|
+
static compressContext(buffer: string[], maxTokens?: number): string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=context-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-extractor.d.ts","sourceRoot":"","sources":["../src/context-extractor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,qBAAa,gBAAgB;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAOnC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAQvC;IAEF,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,GAAE,MAAY,GAAG,gBAAgB;IAqDjF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IA+B1F,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM;CA+B5E"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextExtractor = void 0;
|
|
4
|
+
class ContextExtractor {
|
|
5
|
+
static extractFromBuffer(buffer, limit = 100) {
|
|
6
|
+
const recentLines = buffer.slice(-limit).join('\n');
|
|
7
|
+
const techTerms = new Set();
|
|
8
|
+
const filePaths = new Set();
|
|
9
|
+
const commands = new Set();
|
|
10
|
+
const codeKeywords = new Set();
|
|
11
|
+
this.COMMON_TECH_TERMS.forEach(term => techTerms.add(term));
|
|
12
|
+
let match;
|
|
13
|
+
while ((match = this.TECH_PATTERNS.functions.exec(recentLines)) !== null) {
|
|
14
|
+
if (match[2])
|
|
15
|
+
codeKeywords.add(match[2]);
|
|
16
|
+
}
|
|
17
|
+
this.TECH_PATTERNS.imports.lastIndex = 0;
|
|
18
|
+
while ((match = this.TECH_PATTERNS.imports.exec(recentLines)) !== null) {
|
|
19
|
+
if (match[2])
|
|
20
|
+
techTerms.add(match[2]);
|
|
21
|
+
}
|
|
22
|
+
this.TECH_PATTERNS.packages.lastIndex = 0;
|
|
23
|
+
while ((match = this.TECH_PATTERNS.packages.exec(recentLines)) !== null) {
|
|
24
|
+
if (match[3])
|
|
25
|
+
techTerms.add(match[3]);
|
|
26
|
+
}
|
|
27
|
+
this.TECH_PATTERNS.fileExtensions.lastIndex = 0;
|
|
28
|
+
while ((match = this.TECH_PATTERNS.fileExtensions.exec(recentLines)) !== null) {
|
|
29
|
+
if (match[0])
|
|
30
|
+
filePaths.add(match[0]);
|
|
31
|
+
}
|
|
32
|
+
this.TECH_PATTERNS.commands.lastIndex = 0;
|
|
33
|
+
while ((match = this.TECH_PATTERNS.commands.exec(recentLines)) !== null) {
|
|
34
|
+
if (match[1])
|
|
35
|
+
commands.add(match[1]);
|
|
36
|
+
}
|
|
37
|
+
const pathMatches = recentLines.match(/[\.\/]?(?:[\w\-]+\/)+[\w\-\.]+/g);
|
|
38
|
+
if (pathMatches) {
|
|
39
|
+
pathMatches.forEach(path => {
|
|
40
|
+
if (path.length > 3 && path.includes('/')) {
|
|
41
|
+
filePaths.add(path);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
techTerms: Array.from(techTerms).slice(0, 50),
|
|
47
|
+
filePaths: Array.from(filePaths).slice(0, 20),
|
|
48
|
+
recentCommands: Array.from(commands).slice(0, 10),
|
|
49
|
+
codeKeywords: Array.from(codeKeywords).slice(0, 30),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static generateHotwords(context) {
|
|
53
|
+
const hotwords = [];
|
|
54
|
+
context.techTerms.forEach(term => {
|
|
55
|
+
hotwords.push({ word: term, boost: 2.0 });
|
|
56
|
+
});
|
|
57
|
+
context.codeKeywords.forEach(keyword => {
|
|
58
|
+
hotwords.push({ word: keyword, boost: 3.0 });
|
|
59
|
+
});
|
|
60
|
+
context.filePaths.forEach(path => {
|
|
61
|
+
const filename = path.split('/').pop();
|
|
62
|
+
if (filename) {
|
|
63
|
+
hotwords.push({ word: filename, boost: 2.5 });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
context.recentCommands.forEach(cmd => {
|
|
67
|
+
hotwords.push({ word: cmd, boost: 1.5 });
|
|
68
|
+
});
|
|
69
|
+
hotwords.push({ word: 'leverageaiagent', boost: 4.0 });
|
|
70
|
+
hotwords.push({ word: 'Claude', boost: 3.5 });
|
|
71
|
+
hotwords.push({ word: '语音', boost: 3.0 });
|
|
72
|
+
hotwords.push({ word: '识别', boost: 3.0 });
|
|
73
|
+
hotwords.push({ word: '输入', boost: 2.5 });
|
|
74
|
+
return hotwords.slice(0, 100);
|
|
75
|
+
}
|
|
76
|
+
static compressContext(buffer, maxTokens = 200) {
|
|
77
|
+
const context = this.extractFromBuffer(buffer);
|
|
78
|
+
const parts = [];
|
|
79
|
+
if (context.techTerms.length > 0) {
|
|
80
|
+
parts.push(`Tech: ${context.techTerms.slice(0, 10).join(', ')}`);
|
|
81
|
+
}
|
|
82
|
+
if (context.codeKeywords.length > 0) {
|
|
83
|
+
parts.push(`Code: ${context.codeKeywords.slice(0, 10).join(', ')}`);
|
|
84
|
+
}
|
|
85
|
+
if (context.recentCommands.length > 0) {
|
|
86
|
+
parts.push(`Commands: ${context.recentCommands.slice(0, 5).join(', ')}`);
|
|
87
|
+
}
|
|
88
|
+
const recentText = buffer.slice(-10).join(' ').substring(0, 500);
|
|
89
|
+
if (recentText) {
|
|
90
|
+
parts.push(`Recent: ${recentText}`);
|
|
91
|
+
}
|
|
92
|
+
const compressed = parts.join(' | ');
|
|
93
|
+
const words = compressed.split(/\s+/);
|
|
94
|
+
if (words.length > maxTokens) {
|
|
95
|
+
return words.slice(0, maxTokens).join(' ');
|
|
96
|
+
}
|
|
97
|
+
return compressed;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.ContextExtractor = ContextExtractor;
|
|
101
|
+
ContextExtractor.TECH_PATTERNS = {
|
|
102
|
+
functions: /\b(function|const|let|var|class|interface|type|enum)\s+(\w+)/g,
|
|
103
|
+
imports: /\b(import|require|from)\s+['"]([\w\-\/@]+)['"]/g,
|
|
104
|
+
packages: /\b(npm|yarn|pnpm|pip|cargo|go get)\s+(install|add|i)\s+([\w\-@\/]+)/g,
|
|
105
|
+
fileExtensions: /\b\w+\.(ts|tsx|js|jsx|py|rs|go|java|cpp|c|h|hpp|css|html|json|yaml|yml|md)\b/g,
|
|
106
|
+
commands: /\$\s*(\w+)/g,
|
|
107
|
+
chinese: /[\u4e00-\u9fa5]+/g,
|
|
108
|
+
};
|
|
109
|
+
ContextExtractor.COMMON_TECH_TERMS = [
|
|
110
|
+
'React', 'TypeScript', 'JavaScript', 'Python', 'Rust', 'Go',
|
|
111
|
+
'Docker', 'Kubernetes', 'Git', 'GitHub', 'npm', 'yarn',
|
|
112
|
+
'async', 'await', 'promise', 'callback', 'API', 'REST',
|
|
113
|
+
'GraphQL', 'WebSocket', 'HTTP', 'HTTPS', 'TCP', 'UDP',
|
|
114
|
+
'frontend', 'backend', 'database', 'server', 'client',
|
|
115
|
+
'component', 'module', 'package', 'library', 'framework',
|
|
116
|
+
'Claude', 'leverageaiagent', 'terminal', 'console', 'debug',
|
|
117
|
+
];
|
|
118
|
+
//# sourceMappingURL=context-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-extractor.js","sourceRoot":"","sources":["../src/context-extractor.ts"],"names":[],"mappings":";;;AAOA,MAAa,gBAAgB;IAoBzB,MAAM,CAAC,iBAAiB,CAAC,MAAgB,EAAE,QAAgB,GAAG;QAC1D,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEpD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QACpC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,MAAM,YAAY,GAAG,IAAI,GA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ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const commander_1 = require("commander");
|
|
38
|
+
const session_1 = require("./session");
|
|
39
|
+
const config_1 = require("./config");
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
// Read version from package.json
|
|
43
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
44
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
45
|
+
const version = packageJson.version;
|
|
46
|
+
const program = new commander_1.Command();
|
|
47
|
+
program
|
|
48
|
+
.name('locus')
|
|
49
|
+
.description('Locus - Forward your terminal to your mobile device')
|
|
50
|
+
.version(version)
|
|
51
|
+
.argument('[command...]', 'Command to run (default: none, opens terminal only)')
|
|
52
|
+
.option('-n, --name <name>', 'Machine name to display', process.env.HOSTNAME || 'My Computer')
|
|
53
|
+
.option('--pin <pin>', 'Set a 6-digit PIN for web access security (default: no PIN, direct access)')
|
|
54
|
+
.option('--debug-asr', 'Enable verbose ASR (voice recognition) logging')
|
|
55
|
+
.option('-g, --gateway <url>', 'Vortex gateway URL (default: https://vortex.futuretech.social)')
|
|
56
|
+
.allowUnknownOption(true)
|
|
57
|
+
.action(async (command, options) => {
|
|
58
|
+
// PIN is optional - if not provided, no authentication required
|
|
59
|
+
await (0, session_1.startSession)(options.name, options.pin, command, {
|
|
60
|
+
debugAsr: options.debugAsr,
|
|
61
|
+
gatewayUrl: options.gateway
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
program
|
|
65
|
+
.command('config')
|
|
66
|
+
.description('Configure Locus')
|
|
67
|
+
.option('-s, --server <url>', 'Set server URL')
|
|
68
|
+
.option('--show', 'Show current configuration')
|
|
69
|
+
.action((options) => {
|
|
70
|
+
if (options.show) {
|
|
71
|
+
const config = (0, config_1.getConfig)();
|
|
72
|
+
console.log('Current configuration:');
|
|
73
|
+
console.log(` Server URL: ${config.serverUrl}`);
|
|
74
|
+
console.log(` Machine ID: ${config.machineId}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (options.server) {
|
|
78
|
+
(0, config_1.setConfig)({ serverUrl: options.server });
|
|
79
|
+
console.log(`Server URL set to: ${options.server}`);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
program.parse();
|
|
83
|
+
//# sourceMappingURL=index.js.map
|