ghcc-client 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.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -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,81 @@
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 session_manager_1 = require("./session-manager");
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const crypto_1 = require("crypto");
11
+ const manager = new session_manager_1.SessionManager();
12
+ // Generate unique session name
13
+ function generateSessionName() {
14
+ const id = (0, crypto_1.randomBytes)(4).toString('hex');
15
+ return `ghcc-session-${id}`;
16
+ }
17
+ // Cleanup handler
18
+ let isCleaningUp = false;
19
+ async function cleanup(sessionName) {
20
+ if (isCleaningUp)
21
+ return;
22
+ isCleaningUp = true;
23
+ console.log('\n\n' + chalk_1.default.yellow('🛑 Shutting down...'));
24
+ try {
25
+ await manager.stop({ session: sessionName });
26
+ }
27
+ catch (error) {
28
+ console.error(chalk_1.default.red('Error during cleanup:'), error);
29
+ }
30
+ process.exit(0);
31
+ }
32
+ commander_1.program
33
+ .name('ghcc-client')
34
+ .description('GitHub Copilot CLI Remote Client - Access Copilot from anywhere')
35
+ .version('1.0.0')
36
+ .option('-p, --port <port>', 'Port for remote access (auto-assigned if not specified)')
37
+ .option('--public', 'Enable public access via localtunnel with QR code')
38
+ .allowExcessArguments(false)
39
+ .showHelpAfterError('(use --help for usage information)')
40
+ .action(async (options) => {
41
+ const sessionName = generateSessionName();
42
+ // Setup signal handlers for cleanup
43
+ const cleanupHandler = () => cleanup(sessionName);
44
+ process.on('SIGINT', cleanupHandler);
45
+ process.on('SIGTERM', cleanupHandler);
46
+ try {
47
+ // Start session
48
+ await manager.start({
49
+ port: options.port || undefined,
50
+ session: sessionName,
51
+ public: options.public || false
52
+ });
53
+ // Keep process alive
54
+ console.log(chalk_1.default.gray('\nPress Ctrl+C to stop the session\n'));
55
+ // Block forever until signal
56
+ await new Promise(() => { });
57
+ }
58
+ catch (error) {
59
+ console.error(chalk_1.default.red('Error starting session:'), error);
60
+ await cleanup(sessionName);
61
+ process.exit(1);
62
+ }
63
+ });
64
+ // Show helpful information in --help
65
+ commander_1.program.on('--help', () => {
66
+ console.log('');
67
+ console.log('Usage:');
68
+ console.log(' $ ghcc-client Start local session only');
69
+ console.log(' $ ghcc-client -p 8080 Start on specific port');
70
+ console.log(' $ ghcc-client --public Enable public access with QR code');
71
+ console.log('');
72
+ console.log('Controls:');
73
+ console.log(' Ctrl+C Stop the session and cleanup');
74
+ console.log('');
75
+ console.log('Multiple Sessions:');
76
+ console.log(' Open another terminal and run ghcc-client again to start');
77
+ console.log(' a second session. Each session gets a unique name and port.');
78
+ console.log('');
79
+ });
80
+ commander_1.program.parse();
81
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,uDAAmD;AACnD,kDAA0B;AAC1B,mCAAqC;AAErC,MAAM,OAAO,GAAG,IAAI,gCAAc,EAAE,CAAC;AAErC,+BAA+B;AAC/B,SAAS,mBAAmB;IAC1B,MAAM,EAAE,GAAG,IAAA,oBAAW,EAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,gBAAgB,EAAE,EAAE,CAAC;AAC9B,CAAC;AAED,kBAAkB;AAClB,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,KAAK,UAA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AAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { SessionManager } from './session-manager';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
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
+ exports.SessionManager = void 0;
18
+ var session_manager_1 = require("./session-manager");
19
+ Object.defineProperty(exports, "SessionManager", { enumerable: true, get: function () { return session_manager_1.SessionManager; } });
20
+ __exportStar(require("./types"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,0CAAwB"}
@@ -0,0 +1,21 @@
1
+ import type { StartOptions, StopOptions } from './types';
2
+ export declare class SessionManager {
3
+ private ttydPath;
4
+ constructor();
5
+ private validateSessionName;
6
+ private validatePort;
7
+ private generateSecurePassword;
8
+ private createSecureTempFile;
9
+ private sessionExists;
10
+ private findTtydPid;
11
+ private getTtydPort;
12
+ private findTunnelPid;
13
+ private getTunnelUrl;
14
+ private isPortInUse;
15
+ private findAvailablePort;
16
+ private cleanupOrphanedProcesses;
17
+ start(options: StartOptions): Promise<void>;
18
+ stop(options: StopOptions): Promise<void>;
19
+ showUrls(port: string, session?: string, publicUrl?: string, httpsEnabled?: boolean): void;
20
+ }
21
+ //# sourceMappingURL=session-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../src/session-manager.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKzD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAS;;IAyBzB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,oBAAoB;YAUd,aAAa;YAUb,WAAW;YAaX,WAAW;YAWX,aAAa;YAYb,YAAY;YAcZ,WAAW;YASX,iBAAiB;YAWjB,wBAAwB;IAuHhC,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAiW3C,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAkI/C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,GAAE,OAAe,GAAG,IAAI;CA6BlG"}