tinyagent 1.0.5
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 +100 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +91 -0
- package/dist/cli.js.map +1 -0
- package/dist/pty-wrapper.py +73 -0
- package/dist/qr-generator.d.ts +2 -0
- package/dist/qr-generator.d.ts.map +1 -0
- package/dist/qr-generator.js +50 -0
- package/dist/qr-generator.js.map +1 -0
- package/dist/shared-types/auth.d.ts +44 -0
- package/dist/shared-types/auth.d.ts.map +1 -0
- package/dist/shared-types/auth.js +3 -0
- package/dist/shared-types/auth.js.map +1 -0
- package/dist/shared-types/constants.d.ts +6 -0
- package/dist/shared-types/constants.d.ts.map +1 -0
- package/dist/shared-types/constants.js +9 -0
- package/dist/shared-types/constants.js.map +1 -0
- package/dist/shared-types/host.d.ts +61 -0
- package/dist/shared-types/host.d.ts.map +1 -0
- package/dist/shared-types/host.js +17 -0
- package/dist/shared-types/host.js.map +1 -0
- package/dist/shared-types/index.d.ts +6 -0
- package/dist/shared-types/index.d.ts.map +1 -0
- package/dist/shared-types/index.js +22 -0
- package/dist/shared-types/index.js.map +1 -0
- package/dist/shared-types/messages.d.ts +106 -0
- package/dist/shared-types/messages.d.ts.map +1 -0
- package/dist/shared-types/messages.js +22 -0
- package/dist/shared-types/messages.js.map +1 -0
- package/dist/shared-types/session.d.ts +21 -0
- package/dist/shared-types/session.d.ts.map +1 -0
- package/dist/shared-types/session.js +3 -0
- package/dist/shared-types/session.js.map +1 -0
- package/dist/shell-client-v2.d.ts +45 -0
- package/dist/shell-client-v2.d.ts.map +1 -0
- package/dist/shell-client-v2.js +685 -0
- package/dist/shell-client-v2.js.map +1 -0
- package/dist/shell-client.d.ts +34 -0
- package/dist/shell-client.d.ts.map +1 -0
- package/dist/shell-client.js +304 -0
- package/dist/shell-client.js.map +1 -0
- package/dist/tunnel-manager.d.ts +6 -0
- package/dist/tunnel-manager.d.ts.map +1 -0
- package/dist/tunnel-manager.js +27 -0
- package/dist/tunnel-manager.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Tinyagent
|
|
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,100 @@
|
|
|
1
|
+
# Tinyagent
|
|
2
|
+
|
|
3
|
+
Connect your local shell to any device - access your dev environment from anywhere.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g tinyagent
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
1. Start tinyagent (auto-generates session ID):
|
|
14
|
+
```bash
|
|
15
|
+
tinyagent
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or specify your own session ID:
|
|
19
|
+
```bash
|
|
20
|
+
tinyagent my-session
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. Scan the QR code with the Tinyagent mobile app OR enter the session ID manually
|
|
24
|
+
|
|
25
|
+
3. Your local terminal is now accessible from your phone!
|
|
26
|
+
|
|
27
|
+
**Bonus**: If you have Claude CLI installed, it will automatically start Claude for you!
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- 🔐 Secure WebSocket connection through relay servers
|
|
32
|
+
- 📱 Full terminal access from mobile devices
|
|
33
|
+
- 🌐 HTTP tunneling - access your local dev servers from anywhere
|
|
34
|
+
- ⌨️ Bidirectional typing - type from computer or phone
|
|
35
|
+
- 📏 Smart terminal resizing based on device
|
|
36
|
+
- 🚀 Zero configuration required
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### Basic connection (auto-generates session ID):
|
|
41
|
+
```bash
|
|
42
|
+
tinyagent
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Connect with specific session ID:
|
|
46
|
+
```bash
|
|
47
|
+
tinyagent my-session
|
|
48
|
+
# or
|
|
49
|
+
tinyagent --session-id my-session
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Use a custom relay server:
|
|
53
|
+
```bash
|
|
54
|
+
tinyagent --relay ws://localhost:8080
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Specify a custom shell:
|
|
58
|
+
```bash
|
|
59
|
+
tinyagent --shell /bin/zsh
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Disable Claude auto-start:
|
|
63
|
+
```bash
|
|
64
|
+
tinyagent --no-claude
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Options:
|
|
68
|
+
- `--session-id <id>` - Specify session ID (alternative to positional argument)
|
|
69
|
+
- `-r, --relay <url>` - Relay server URL (default: wss://relay.tinyagent.app)
|
|
70
|
+
- `-s, --shell <shell>` - Shell to use (default: $SHELL or /bin/bash)
|
|
71
|
+
- `--no-claude` - Do not auto-start Claude CLI
|
|
72
|
+
- `-v, --verbose` - Show detailed debug output
|
|
73
|
+
|
|
74
|
+
## HTTP Tunneling
|
|
75
|
+
|
|
76
|
+
When you have local development servers running (e.g., on port 3000), tinyagent automatically exposes them:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
[HTTP] Exposing ports: 3000
|
|
80
|
+
[HTTP] Access your dev server at:
|
|
81
|
+
https://my-session-3000.tinyagent.app/
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
You can access your local dev server from any browser using this URL.
|
|
85
|
+
|
|
86
|
+
## Security
|
|
87
|
+
|
|
88
|
+
- All connections are routed through relay servers - your machine is never directly exposed
|
|
89
|
+
- Session IDs are private - only those with the ID can connect
|
|
90
|
+
- Connections are encrypted with WSS (WebSocket Secure)
|
|
91
|
+
|
|
92
|
+
## Learn More
|
|
93
|
+
|
|
94
|
+
- Website: https://tinyagent.app
|
|
95
|
+
- Documentation: https://docs.tinyagent.app
|
|
96
|
+
- Mobile App: Available on App Store and Google Play
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const dotenv_1 = require("dotenv");
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const shell_client_v2_1 = require("./shell-client-v2");
|
|
12
|
+
const qr_generator_1 = require("./qr-generator");
|
|
13
|
+
(0, dotenv_1.config)();
|
|
14
|
+
// Function to check if Claude is available and start it
|
|
15
|
+
function checkAndStartClaude(sessionId) {
|
|
16
|
+
try {
|
|
17
|
+
// Check if claude command exists
|
|
18
|
+
(0, child_process_1.execSync)('which claude', { stdio: 'ignore' });
|
|
19
|
+
console.log(chalk_1.default.green('\n✓ Claude detected - starting Claude session...'));
|
|
20
|
+
// Start claude in the background
|
|
21
|
+
const claudeProcess = (0, child_process_1.spawn)('claude', [], {
|
|
22
|
+
detached: true,
|
|
23
|
+
stdio: 'ignore'
|
|
24
|
+
});
|
|
25
|
+
claudeProcess.unref();
|
|
26
|
+
console.log(chalk_1.default.gray('Claude is running in the background'));
|
|
27
|
+
console.log(chalk_1.default.yellow(`\nTip: You can now ask Claude to connect to your shell session "${sessionId}"`));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// Claude not found or failed to start - silently continue
|
|
31
|
+
if (process.env.DEBUG || process.argv.includes('--verbose')) {
|
|
32
|
+
console.log(chalk_1.default.gray('Claude not found or could not be started'));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const program = new commander_1.Command();
|
|
37
|
+
program
|
|
38
|
+
.name('tinyagent')
|
|
39
|
+
.description('Connect your local shell to any device')
|
|
40
|
+
.version('1.0.5')
|
|
41
|
+
.argument('[sessionId]', 'Session ID to connect to (optional, auto-generated if not provided)')
|
|
42
|
+
.option('--session-id <id>', 'Session ID (alternative to positional argument)')
|
|
43
|
+
.option('-r, --relay <url>', 'Relay server URL', process.env.RELAY_URL || 'wss://relay.tinyagent.app')
|
|
44
|
+
.option('-s, --shell <shell>', 'Shell to use', process.env.SHELL || '/bin/bash')
|
|
45
|
+
.option('-c, --command <cmd>', 'Server command to run (e.g., "npm run dev")')
|
|
46
|
+
.option('-p, --port <port>', 'Local server port', '3000')
|
|
47
|
+
.option('--no-tunnel', 'Disable tunnel creation')
|
|
48
|
+
.option('--no-claude', 'Do not auto-start Claude')
|
|
49
|
+
.option('-v, --verbose', 'Show detailed debug output')
|
|
50
|
+
.action(async (sessionIdArg, options) => {
|
|
51
|
+
// Determine session ID from argument or option, or generate one
|
|
52
|
+
let sessionId = sessionIdArg || options.sessionId;
|
|
53
|
+
if (!sessionId) {
|
|
54
|
+
// Generate a random session ID
|
|
55
|
+
sessionId = Math.random().toString(36).substring(2, 15);
|
|
56
|
+
console.log(chalk_1.default.cyan(`Generated session ID: ${sessionId}`));
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
console.log(chalk_1.default.blue(`Connecting to session: ${sessionId}`));
|
|
60
|
+
// Always show QR code for easy mobile connection
|
|
61
|
+
(0, qr_generator_1.generateConnectionQR)(sessionId, options.relay);
|
|
62
|
+
const client = new shell_client_v2_1.ShellClient({
|
|
63
|
+
sessionId,
|
|
64
|
+
relayUrl: options.relay,
|
|
65
|
+
shell: options.shell,
|
|
66
|
+
serverCommand: options.command,
|
|
67
|
+
serverPort: parseInt(options.port),
|
|
68
|
+
createTunnel: options.tunnel
|
|
69
|
+
});
|
|
70
|
+
await client.connect();
|
|
71
|
+
// Auto-start Claude if available and not disabled
|
|
72
|
+
if (!options.noClaude) {
|
|
73
|
+
checkAndStartClaude(sessionId);
|
|
74
|
+
}
|
|
75
|
+
process.on('SIGINT', () => {
|
|
76
|
+
console.log(chalk_1.default.yellow('\nDisconnecting...'));
|
|
77
|
+
client.disconnect();
|
|
78
|
+
process.exit(0);
|
|
79
|
+
});
|
|
80
|
+
process.on('SIGTERM', () => {
|
|
81
|
+
client.disconnect();
|
|
82
|
+
process.exit(0);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.error(chalk_1.default.red(`Error: ${error}`));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
program.parse();
|
|
91
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,mCAAgC;AAChC,iDAAgD;AAChD,uDAAgD;AAEhD,iDAAsD;AAEtD,IAAA,eAAM,GAAE,CAAC;AAET,wDAAwD;AACxD,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,IAAI,CAAC;QACH,iCAAiC;QACjC,IAAA,wBAAQ,EAAC,cAAc,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE9C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC,CAAC;QAE7E,iCAAiC;QACjC,MAAM,aAAa,GAAG,IAAA,qBAAK,EAAC,QAAQ,EAAE,EAAE,EAAE;YACxC,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;QAEH,aAAa,CAAC,KAAK,EAAE,CAAC;QAEtB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,mEAAmE,SAAS,GAAG,CAAC,CAAC,CAAC;IAC7G,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,0DAA0D;QAC1D,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,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0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import sys
|
|
3
|
+
import os
|
|
4
|
+
import pty
|
|
5
|
+
import select
|
|
6
|
+
import termios
|
|
7
|
+
import tty
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
# Get shell from environment or argument
|
|
11
|
+
shell = sys.argv[1] if len(sys.argv) > 1 else os.environ.get('SHELL', '/bin/bash')
|
|
12
|
+
|
|
13
|
+
# Create a pseudo-terminal
|
|
14
|
+
master, slave = pty.openpty()
|
|
15
|
+
|
|
16
|
+
# Fork a child process
|
|
17
|
+
pid = os.fork()
|
|
18
|
+
|
|
19
|
+
if pid == 0:
|
|
20
|
+
# Child process
|
|
21
|
+
os.close(master)
|
|
22
|
+
os.setsid()
|
|
23
|
+
os.dup2(slave, 0)
|
|
24
|
+
os.dup2(slave, 1)
|
|
25
|
+
os.dup2(slave, 2)
|
|
26
|
+
os.close(slave)
|
|
27
|
+
|
|
28
|
+
# Set terminal size
|
|
29
|
+
os.environ['TERM'] = 'xterm-256color'
|
|
30
|
+
os.environ['LINES'] = '30'
|
|
31
|
+
os.environ['COLUMNS'] = '80'
|
|
32
|
+
|
|
33
|
+
# Execute shell
|
|
34
|
+
os.execv(shell, [shell, '-i'])
|
|
35
|
+
else:
|
|
36
|
+
# Parent process
|
|
37
|
+
os.close(slave)
|
|
38
|
+
|
|
39
|
+
# Set master to non-blocking
|
|
40
|
+
import fcntl
|
|
41
|
+
flags = fcntl.fcntl(master, fcntl.F_GETFL)
|
|
42
|
+
fcntl.fcntl(master, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
while True:
|
|
46
|
+
# Select on stdin and master
|
|
47
|
+
r, w, e = select.select([sys.stdin, master], [], [], 0.1)
|
|
48
|
+
|
|
49
|
+
if sys.stdin in r:
|
|
50
|
+
# Read from stdin and write to master
|
|
51
|
+
data = sys.stdin.buffer.read(1024)
|
|
52
|
+
if data:
|
|
53
|
+
os.write(master, data)
|
|
54
|
+
else:
|
|
55
|
+
break
|
|
56
|
+
|
|
57
|
+
if master in r:
|
|
58
|
+
# Read from master and write to stdout
|
|
59
|
+
try:
|
|
60
|
+
data = os.read(master, 1024)
|
|
61
|
+
if data:
|
|
62
|
+
sys.stdout.buffer.write(data)
|
|
63
|
+
sys.stdout.flush()
|
|
64
|
+
else:
|
|
65
|
+
break
|
|
66
|
+
except OSError:
|
|
67
|
+
break
|
|
68
|
+
finally:
|
|
69
|
+
os.close(master)
|
|
70
|
+
os.waitpid(pid, 0)
|
|
71
|
+
|
|
72
|
+
if __name__ == '__main__':
|
|
73
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-generator.d.ts","sourceRoot":"","sources":["../src/qr-generator.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAW9E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.generateConnectionQR = generateConnectionQR;
|
|
37
|
+
// @ts-ignore - qrcode-terminal types not available
|
|
38
|
+
const qrcode = __importStar(require("qrcode-terminal"));
|
|
39
|
+
function generateConnectionQR(sessionId, relayUrl) {
|
|
40
|
+
// Create connection URL
|
|
41
|
+
const connectionUrl = JSON.stringify({
|
|
42
|
+
relayUrl: relayUrl,
|
|
43
|
+
sessionId: sessionId
|
|
44
|
+
});
|
|
45
|
+
console.log('\n📱 Scan this QR code with your mobile app:\n');
|
|
46
|
+
qrcode.generate(connectionUrl, { small: true });
|
|
47
|
+
console.log(`\n🔗 Relay URL: ${relayUrl}`);
|
|
48
|
+
console.log(`📝 Session ID: ${sessionId}\n`);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=qr-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-generator.js","sourceRoot":"","sources":["../src/qr-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oDAWC;AAfD,mDAAmD;AACnD,wDAA0C;AAG1C,SAAgB,oBAAoB,CAAC,SAAiB,EAAE,QAAgB;IACtE,wBAAwB;IACxB,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC;QACnC,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,SAAS;KACrB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAC9D,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,kBAAkB,SAAS,IAAI,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface User {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
createdAt: Date;
|
|
6
|
+
apiKeys: ApiKey[];
|
|
7
|
+
}
|
|
8
|
+
export interface ApiKey {
|
|
9
|
+
id: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
key: string;
|
|
12
|
+
name: string;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
lastUsedAt?: Date;
|
|
15
|
+
scopes: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface AuthTokenPayload {
|
|
18
|
+
userId: string;
|
|
19
|
+
email: string;
|
|
20
|
+
sessionId?: string;
|
|
21
|
+
hostId?: string;
|
|
22
|
+
exp: number;
|
|
23
|
+
}
|
|
24
|
+
export interface LoginRequest {
|
|
25
|
+
email: string;
|
|
26
|
+
password: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SignupRequest {
|
|
29
|
+
email: string;
|
|
30
|
+
password: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AuthResponse {
|
|
34
|
+
token: string;
|
|
35
|
+
refreshToken: string;
|
|
36
|
+
user: User;
|
|
37
|
+
}
|
|
38
|
+
export interface HostAuthRequest {
|
|
39
|
+
registrationToken: string;
|
|
40
|
+
hostId: string;
|
|
41
|
+
timestamp: number;
|
|
42
|
+
signature: string;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/shared-types/auth.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/shared-types/auth.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DEFAULT_PORT = 3000;
|
|
2
|
+
export declare const DEFAULT_RELAY_PORT = 8080;
|
|
3
|
+
export declare const HEARTBEAT_INTERVAL = 30000;
|
|
4
|
+
export declare const SESSION_TIMEOUT = 600000;
|
|
5
|
+
export declare const RECONNECT_DELAY = 5000;
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/shared-types/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AACxC,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RECONNECT_DELAY = exports.SESSION_TIMEOUT = exports.HEARTBEAT_INTERVAL = exports.DEFAULT_RELAY_PORT = exports.DEFAULT_PORT = void 0;
|
|
4
|
+
exports.DEFAULT_PORT = 3000;
|
|
5
|
+
exports.DEFAULT_RELAY_PORT = 8080;
|
|
6
|
+
exports.HEARTBEAT_INTERVAL = 30000; // 30 seconds
|
|
7
|
+
exports.SESSION_TIMEOUT = 600000; // 10 minutes
|
|
8
|
+
exports.RECONNECT_DELAY = 5000; // 5 seconds
|
|
9
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/shared-types/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,IAAI,CAAC;AACpB,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAC1B,QAAA,kBAAkB,GAAG,KAAK,CAAC,CAAC,aAAa;AACzC,QAAA,eAAe,GAAG,MAAM,CAAC,CAAC,aAAa;AACvC,QAAA,eAAe,GAAG,IAAI,CAAC,CAAC,YAAY"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export declare enum HostType {
|
|
2
|
+
USER_OWNED = "USER_OWNED",
|
|
3
|
+
MANAGED = "MANAGED"
|
|
4
|
+
}
|
|
5
|
+
export declare enum HostStatus {
|
|
6
|
+
ONLINE = "ONLINE",
|
|
7
|
+
OFFLINE = "OFFLINE",
|
|
8
|
+
STARTING = "STARTING",
|
|
9
|
+
STOPPING = "STOPPING",
|
|
10
|
+
ERROR = "ERROR"
|
|
11
|
+
}
|
|
12
|
+
export interface Host {
|
|
13
|
+
id: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: HostType;
|
|
17
|
+
status: HostStatus;
|
|
18
|
+
region?: string;
|
|
19
|
+
specs?: HostSpecs;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
lastSeenAt?: Date;
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
export interface HostSpecs {
|
|
25
|
+
cpu: number;
|
|
26
|
+
memory: number;
|
|
27
|
+
storage: number;
|
|
28
|
+
}
|
|
29
|
+
export interface UserOwnedHost extends Host {
|
|
30
|
+
type: HostType.USER_OWNED;
|
|
31
|
+
registrationToken: string;
|
|
32
|
+
publicKey?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ManagedHost extends Host {
|
|
35
|
+
type: HostType.MANAGED;
|
|
36
|
+
containerId?: string;
|
|
37
|
+
region: string;
|
|
38
|
+
specs: HostSpecs;
|
|
39
|
+
}
|
|
40
|
+
export interface HostRegistrationRequest {
|
|
41
|
+
registrationToken: string;
|
|
42
|
+
name: string;
|
|
43
|
+
publicKey?: string;
|
|
44
|
+
specs?: HostSpecs;
|
|
45
|
+
}
|
|
46
|
+
export interface HostConnectionRequest {
|
|
47
|
+
hostId: string;
|
|
48
|
+
sessionId: string;
|
|
49
|
+
userId: string;
|
|
50
|
+
}
|
|
51
|
+
export interface CreateManagedHostRequest {
|
|
52
|
+
name: string;
|
|
53
|
+
region: string;
|
|
54
|
+
specs: HostSpecs;
|
|
55
|
+
userId: string;
|
|
56
|
+
}
|
|
57
|
+
export interface HostListResponse {
|
|
58
|
+
hosts: Host[];
|
|
59
|
+
total: number;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/shared-types/host.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,UAAU,eAAe;IACzB,OAAO,YAAY;CACpB;AAED,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI;IACzC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI;IACvC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HostStatus = exports.HostType = void 0;
|
|
4
|
+
var HostType;
|
|
5
|
+
(function (HostType) {
|
|
6
|
+
HostType["USER_OWNED"] = "USER_OWNED";
|
|
7
|
+
HostType["MANAGED"] = "MANAGED";
|
|
8
|
+
})(HostType || (exports.HostType = HostType = {}));
|
|
9
|
+
var HostStatus;
|
|
10
|
+
(function (HostStatus) {
|
|
11
|
+
HostStatus["ONLINE"] = "ONLINE";
|
|
12
|
+
HostStatus["OFFLINE"] = "OFFLINE";
|
|
13
|
+
HostStatus["STARTING"] = "STARTING";
|
|
14
|
+
HostStatus["STOPPING"] = "STOPPING";
|
|
15
|
+
HostStatus["ERROR"] = "ERROR";
|
|
16
|
+
})(HostStatus || (exports.HostStatus = HostStatus = {}));
|
|
17
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/shared-types/host.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,qCAAyB,CAAA;IACzB,+BAAmB,CAAA;AACrB,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB;AAED,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;IACrB,6BAAe,CAAA;AACjB,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./messages"), exports);
|
|
18
|
+
__exportStar(require("./session"), exports);
|
|
19
|
+
__exportStar(require("./constants"), exports);
|
|
20
|
+
__exportStar(require("./host"), exports);
|
|
21
|
+
__exportStar(require("./auth"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,4CAA0B;AAC1B,8CAA4B;AAC5B,yCAAuB;AACvB,yCAAuB"}
|