mirra-cc-bridge 0.1.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/README.md +62 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +213 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/configure.d.ts +13 -0
- package/dist/commands/configure.d.ts.map +1 -0
- package/dist/commands/configure.js +101 -0
- package/dist/commands/configure.js.map +1 -0
- package/dist/commands/hook.d.ts +15 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +181 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/index.d.ts +10 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +19 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/register.d.ts +13 -0
- package/dist/commands/register.d.ts.map +1 -0
- package/dist/commands/register.js +383 -0
- package/dist/commands/register.js.map +1 -0
- package/dist/commands/setup-hooks.d.ts +8 -0
- package/dist/commands/setup-hooks.d.ts.map +1 -0
- package/dist/commands/setup-hooks.js +114 -0
- package/dist/commands/setup-hooks.js.map +1 -0
- package/dist/commands/start.d.ts +16 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +168 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +8 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +156 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +88 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/session-manager.d.ts +72 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +315 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Start command - launch the bridge HTTP server
|
|
4
|
+
*
|
|
5
|
+
* This server receives commands from the Mirra mobile app via the PC resource.
|
|
6
|
+
* It manages Claude Code sessions and creates Flows for reply routing.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.startServer = startServer;
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const express_1 = __importDefault(require("express"));
|
|
15
|
+
const config_1 = require("../config");
|
|
16
|
+
const session_manager_1 = require("../session-manager");
|
|
17
|
+
let sessionManager;
|
|
18
|
+
/**
|
|
19
|
+
* Create the Express app with routes
|
|
20
|
+
*/
|
|
21
|
+
function createApp() {
|
|
22
|
+
const app = (0, express_1.default)();
|
|
23
|
+
app.use(express_1.default.json());
|
|
24
|
+
// Health check
|
|
25
|
+
app.get('/health', (_req, res) => {
|
|
26
|
+
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
|
27
|
+
});
|
|
28
|
+
// List sessions
|
|
29
|
+
app.get('/sessions', (_req, res) => {
|
|
30
|
+
const sessions = sessionManager.listSessions();
|
|
31
|
+
res.json(sessions);
|
|
32
|
+
});
|
|
33
|
+
// Spawn a new session
|
|
34
|
+
app.post('/sessions', async (req, res) => {
|
|
35
|
+
try {
|
|
36
|
+
const body = req.body;
|
|
37
|
+
if (!body.initialPrompt) {
|
|
38
|
+
res.status(400).json({ error: 'initialPrompt is required' });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!body.recipientId) {
|
|
42
|
+
res.status(400).json({ error: 'recipientId is required' });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!body.groupId) {
|
|
46
|
+
res.status(400).json({ error: 'groupId is required for Flow-based routing' });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const config = (0, config_1.loadConfig)();
|
|
50
|
+
const workingDir = body.workingDir || config?.defaultWorkDir || process.cwd();
|
|
51
|
+
const session = await sessionManager.spawnSession({
|
|
52
|
+
workingDir,
|
|
53
|
+
initialPrompt: body.initialPrompt,
|
|
54
|
+
recipientId: body.recipientId,
|
|
55
|
+
groupId: body.groupId,
|
|
56
|
+
});
|
|
57
|
+
const response = {
|
|
58
|
+
id: session.id,
|
|
59
|
+
workingDir: session.workingDir,
|
|
60
|
+
status: session.status,
|
|
61
|
+
createdAt: session.createdAt.toISOString(),
|
|
62
|
+
lastActivity: session.lastActivity.toISOString(),
|
|
63
|
+
flowId: session.flowId,
|
|
64
|
+
};
|
|
65
|
+
res.status(201).json(response);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error(chalk_1.default.red('Error spawning session:'), error.message);
|
|
69
|
+
res.status(500).json({ error: error.message });
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
// Get session details
|
|
73
|
+
app.get('/sessions/:id', (req, res) => {
|
|
74
|
+
const session = sessionManager.getSession(req.params.id);
|
|
75
|
+
if (!session) {
|
|
76
|
+
res.status(404).json({ error: 'Session not found' });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const response = {
|
|
80
|
+
id: session.id,
|
|
81
|
+
workingDir: session.workingDir,
|
|
82
|
+
status: session.status,
|
|
83
|
+
createdAt: session.createdAt.toISOString(),
|
|
84
|
+
lastActivity: session.lastActivity.toISOString(),
|
|
85
|
+
flowId: session.flowId,
|
|
86
|
+
};
|
|
87
|
+
res.json(response);
|
|
88
|
+
});
|
|
89
|
+
// Send input to a session
|
|
90
|
+
app.post('/sessions/:id/input', (req, res) => {
|
|
91
|
+
try {
|
|
92
|
+
const body = req.body;
|
|
93
|
+
if (!body.input) {
|
|
94
|
+
res.status(400).json({ error: 'input is required' });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
sessionManager.sendInput(req.params.id, body.input);
|
|
98
|
+
res.json({ success: true });
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
res.status(404).json({ error: error.message });
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
// Kill a session
|
|
105
|
+
app.delete('/sessions/:id', async (req, res) => {
|
|
106
|
+
try {
|
|
107
|
+
await sessionManager.killSession(req.params.id);
|
|
108
|
+
res.json({ success: true });
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
res.status(404).json({ error: error.message });
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return app;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Start the bridge server
|
|
118
|
+
*/
|
|
119
|
+
async function startServer(options) {
|
|
120
|
+
const port = parseInt(options.port, 10);
|
|
121
|
+
const config = (0, config_1.loadConfig)();
|
|
122
|
+
if (!config?.apiKey) {
|
|
123
|
+
console.error(chalk_1.default.red('Error: API key not configured.'));
|
|
124
|
+
console.log(chalk_1.default.gray('Run `mirra-cc-bridge configure` to set your API key.'));
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
// Initialize session manager with API key and pcResourceId
|
|
128
|
+
sessionManager = new session_manager_1.SessionManager(config.apiKey, config.pcResourceId);
|
|
129
|
+
if (!config.pcResourceId) {
|
|
130
|
+
console.log(chalk_1.default.gray('[!] PC not registered - remote control disabled'));
|
|
131
|
+
console.log(chalk_1.default.gray(' Run `mirra-cc-bridge register` to enable'));
|
|
132
|
+
}
|
|
133
|
+
// Create and start Express app
|
|
134
|
+
const app = createApp();
|
|
135
|
+
const server = app.listen(port, () => {
|
|
136
|
+
console.log(chalk_1.default.green('[+]') + ` Server listening on port ${port}`);
|
|
137
|
+
console.log(chalk_1.default.gray(` http://localhost:${port}`));
|
|
138
|
+
});
|
|
139
|
+
// Save port to config
|
|
140
|
+
(0, config_1.setConfigValue)('server', { port });
|
|
141
|
+
// Handle tunnel if enabled
|
|
142
|
+
if (options.tunnel && config?.pcResourceId) {
|
|
143
|
+
console.log(chalk_1.default.gray('\n[!] Tunnel support not yet implemented'));
|
|
144
|
+
console.log(chalk_1.default.gray(' Use ngrok manually: ngrok http ' + port));
|
|
145
|
+
}
|
|
146
|
+
// Log endpoints
|
|
147
|
+
console.log(chalk_1.default.gray('\nEndpoints:'));
|
|
148
|
+
console.log(chalk_1.default.gray(' GET /health health check'));
|
|
149
|
+
console.log(chalk_1.default.gray(' GET /sessions list sessions'));
|
|
150
|
+
console.log(chalk_1.default.gray(' POST /sessions spawn session'));
|
|
151
|
+
console.log(chalk_1.default.gray(' GET /sessions/:id get session'));
|
|
152
|
+
console.log(chalk_1.default.gray(' POST /sessions/:id/input send input'));
|
|
153
|
+
console.log(chalk_1.default.gray(' DELETE /sessions/:id kill session'));
|
|
154
|
+
console.log(chalk_1.default.green('\n> Bridge running'));
|
|
155
|
+
console.log(chalk_1.default.gray(' Ctrl+C to stop\n'));
|
|
156
|
+
// Handle shutdown
|
|
157
|
+
const shutdown = async () => {
|
|
158
|
+
console.log(chalk_1.default.gray('\n\nShutting down...'));
|
|
159
|
+
await sessionManager.killAllSessions();
|
|
160
|
+
server.close(() => {
|
|
161
|
+
console.log(chalk_1.default.green('[+] Server stopped'));
|
|
162
|
+
process.exit(0);
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
process.on('SIGINT', shutdown);
|
|
166
|
+
process.on('SIGTERM', shutdown);
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAqIH,kCA2DC;AA9LD,kDAA0B;AAC1B,sDAAqD;AACrD,sCAAuD;AACvD,w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C,CAAC,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC,CAAC;IAEjE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAE9C,kBAAkB;IAClB,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;QAC1B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAChD,MAAM,cAAc,CAAC,eAAe,EAAE,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoCH;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAyFhD"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Status command - show bridge status and active sessions
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.showStatus = showStatus;
|
|
43
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
44
|
+
const config_1 = require("../config");
|
|
45
|
+
const fs_1 = require("fs");
|
|
46
|
+
const os_1 = require("os");
|
|
47
|
+
const path_1 = require("path");
|
|
48
|
+
const CLAUDE_SETTINGS_FILE = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json');
|
|
49
|
+
/**
|
|
50
|
+
* Check if Claude Code hooks are configured
|
|
51
|
+
*/
|
|
52
|
+
function checkHooksConfigured() {
|
|
53
|
+
if (!(0, fs_1.existsSync)(CLAUDE_SETTINGS_FILE)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const content = (0, fs_1.readFileSync)(CLAUDE_SETTINGS_FILE, 'utf-8');
|
|
58
|
+
const settings = JSON.parse(content);
|
|
59
|
+
// Check if our hooks are present
|
|
60
|
+
const hasPostMessage = settings.hooks?.PostMessage?.some((h) => h.command?.includes('mirra-cc-bridge'));
|
|
61
|
+
const hasPostToolUse = settings.hooks?.PostToolUse?.some((h) => h.command?.includes('mirra-cc-bridge'));
|
|
62
|
+
return hasPostMessage && hasPostToolUse;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Show bridge status
|
|
70
|
+
*/
|
|
71
|
+
async function showStatus() {
|
|
72
|
+
console.log(chalk_1.default.gray('\n' + '─'.repeat(50)));
|
|
73
|
+
console.log(chalk_1.default.bold(' MIRRA BRIDGE STATUS'));
|
|
74
|
+
console.log(chalk_1.default.gray('─'.repeat(50)));
|
|
75
|
+
const config = (0, config_1.loadConfig)();
|
|
76
|
+
// Configuration status
|
|
77
|
+
console.log(chalk_1.default.gray('\n[config]'));
|
|
78
|
+
if (config?.apiKey) {
|
|
79
|
+
console.log(chalk_1.default.green(' [+] api_key: ') +
|
|
80
|
+
`${config.apiKey.substring(0, 10)}...`);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.log(chalk_1.default.red(' [-] api_key: ') + 'not configured');
|
|
84
|
+
}
|
|
85
|
+
if (config?.userId) {
|
|
86
|
+
console.log(chalk_1.default.green(' [+] user_id: ') + config.userId);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
console.log(chalk_1.default.gray(' [?] user_id: ') + 'not set');
|
|
90
|
+
}
|
|
91
|
+
if (config?.defaultWorkDir) {
|
|
92
|
+
console.log(chalk_1.default.green(' [+] work_dir: ') + config.defaultWorkDir);
|
|
93
|
+
}
|
|
94
|
+
// Hooks status
|
|
95
|
+
console.log(chalk_1.default.gray('\n[hooks]'));
|
|
96
|
+
if (checkHooksConfigured()) {
|
|
97
|
+
console.log(chalk_1.default.green(' [+] claude_code: configured'));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
console.log(chalk_1.default.red(' [-] claude_code: not configured'));
|
|
101
|
+
console.log(chalk_1.default.gray(' run: mirra-cc-bridge setup-hooks'));
|
|
102
|
+
}
|
|
103
|
+
// PC Resource status
|
|
104
|
+
console.log(chalk_1.default.gray('\n[resource]'));
|
|
105
|
+
if (config?.pcResourceId) {
|
|
106
|
+
console.log(chalk_1.default.green(' [+] registered: ') + config.pcResourceId);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
console.log(chalk_1.default.gray(' [?] registered: no'));
|
|
110
|
+
console.log(chalk_1.default.gray(' run: mirra-cc-bridge register'));
|
|
111
|
+
}
|
|
112
|
+
// Server status (check if running by trying to connect)
|
|
113
|
+
console.log(chalk_1.default.gray('\n[server]'));
|
|
114
|
+
const port = config?.server?.port || 3847;
|
|
115
|
+
try {
|
|
116
|
+
const http = await Promise.resolve().then(() => __importStar(require('http')));
|
|
117
|
+
await new Promise((resolve, reject) => {
|
|
118
|
+
const req = http.get(`http://localhost:${port}/health`, (res) => {
|
|
119
|
+
if (res.statusCode === 200) {
|
|
120
|
+
resolve();
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
reject(new Error('Not healthy'));
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
req.on('error', reject);
|
|
127
|
+
req.setTimeout(1000, () => {
|
|
128
|
+
req.destroy();
|
|
129
|
+
reject(new Error('Timeout'));
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
console.log(chalk_1.default.green(' [+] status: ') + `running on port ${port}`);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
console.log(chalk_1.default.gray(' [-] status: ') + 'not running');
|
|
136
|
+
console.log(chalk_1.default.gray(' run: mirra-cc-bridge start'));
|
|
137
|
+
}
|
|
138
|
+
// Overall status
|
|
139
|
+
console.log(chalk_1.default.gray('\n' + '─'.repeat(50)));
|
|
140
|
+
const configured = !!config?.apiKey;
|
|
141
|
+
const hooksOk = checkHooksConfigured();
|
|
142
|
+
if (configured && hooksOk) {
|
|
143
|
+
console.log(chalk_1.default.green('\n> Ready.') + chalk_1.default.gray(' Output will sync to Mirra app.'));
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
console.log(chalk_1.default.yellow('\n> Setup incomplete'));
|
|
147
|
+
if (!configured) {
|
|
148
|
+
console.log(chalk_1.default.gray(' run: mirra-cc-bridge configure'));
|
|
149
|
+
}
|
|
150
|
+
if (!hooksOk) {
|
|
151
|
+
console.log(chalk_1.default.gray(' run: mirra-cc-bridge setup-hooks'));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
console.log('');
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCH,gCAyFC;AA9HD,kDAA0B;AAC1B,sCAAoE;AACpE,2BAA8C;AAC9C,2BAA6B;AAC7B,+BAA4B;AAE5B,MAAM,oBAAoB,GAAG,IAAA,WAAI,EAAC,IAAA,YAAO,GAAE,EAAE,SAAS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,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for Mirra CC Bridge
|
|
3
|
+
*/
|
|
4
|
+
import { BridgeConfig } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Load configuration from file
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadConfig(): BridgeConfig | null;
|
|
9
|
+
/**
|
|
10
|
+
* Save configuration to file
|
|
11
|
+
*/
|
|
12
|
+
export declare function saveConfig(config: BridgeConfig): void;
|
|
13
|
+
/**
|
|
14
|
+
* Get a specific config value
|
|
15
|
+
*/
|
|
16
|
+
export declare function getConfigValue<K extends keyof BridgeConfig>(key: K): BridgeConfig[K] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Set a specific config value
|
|
19
|
+
*/
|
|
20
|
+
export declare function setConfigValue<K extends keyof BridgeConfig>(key: K, value: BridgeConfig[K]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Check if the bridge is configured
|
|
23
|
+
*/
|
|
24
|
+
export declare function isConfigured(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check if Claude Code hooks are configured
|
|
27
|
+
*/
|
|
28
|
+
export declare function hooksConfigured(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Get the config file path
|
|
31
|
+
*/
|
|
32
|
+
export declare function getConfigPath(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the config directory path
|
|
35
|
+
*/
|
|
36
|
+
export declare function getConfigDir(): string;
|
|
37
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC;;GAEG;AACH,wBAAgB,UAAU,IAAI,YAAY,GAAG,IAAI,CAYhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAIrD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,YAAY,EACzD,GAAG,EAAE,CAAC,GACL,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAG7B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,YAAY,EACzD,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GACrB,IAAI,CAIN;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAGtC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAGzC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration management for Mirra CC Bridge
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadConfig = loadConfig;
|
|
7
|
+
exports.saveConfig = saveConfig;
|
|
8
|
+
exports.getConfigValue = getConfigValue;
|
|
9
|
+
exports.setConfigValue = setConfigValue;
|
|
10
|
+
exports.isConfigured = isConfigured;
|
|
11
|
+
exports.hooksConfigured = hooksConfigured;
|
|
12
|
+
exports.getConfigPath = getConfigPath;
|
|
13
|
+
exports.getConfigDir = getConfigDir;
|
|
14
|
+
const os_1 = require("os");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const CONFIG_DIR = (0, path_1.join)((0, os_1.homedir)(), '.mirra');
|
|
18
|
+
const CONFIG_FILE = (0, path_1.join)(CONFIG_DIR, 'cc-bridge.json');
|
|
19
|
+
// Ensure config directory exists
|
|
20
|
+
if (!(0, fs_1.existsSync)(CONFIG_DIR)) {
|
|
21
|
+
(0, fs_1.mkdirSync)(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Load configuration from file
|
|
25
|
+
*/
|
|
26
|
+
function loadConfig() {
|
|
27
|
+
if (!(0, fs_1.existsSync)(CONFIG_FILE)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const content = (0, fs_1.readFileSync)(CONFIG_FILE, 'utf-8');
|
|
32
|
+
return JSON.parse(content);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error('Error loading config:', error);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Save configuration to file
|
|
41
|
+
*/
|
|
42
|
+
function saveConfig(config) {
|
|
43
|
+
(0, fs_1.writeFileSync)(CONFIG_FILE, JSON.stringify(config, null, 2), {
|
|
44
|
+
mode: 0o600, // Read/write for owner only
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get a specific config value
|
|
49
|
+
*/
|
|
50
|
+
function getConfigValue(key) {
|
|
51
|
+
const config = loadConfig();
|
|
52
|
+
return config?.[key];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Set a specific config value
|
|
56
|
+
*/
|
|
57
|
+
function setConfigValue(key, value) {
|
|
58
|
+
const config = loadConfig() || {};
|
|
59
|
+
config[key] = value;
|
|
60
|
+
saveConfig(config);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if the bridge is configured
|
|
64
|
+
*/
|
|
65
|
+
function isConfigured() {
|
|
66
|
+
const config = loadConfig();
|
|
67
|
+
return !!(config?.apiKey);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if Claude Code hooks are configured
|
|
71
|
+
*/
|
|
72
|
+
function hooksConfigured() {
|
|
73
|
+
const config = loadConfig();
|
|
74
|
+
return !!(config?.hooksConfigured);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get the config file path
|
|
78
|
+
*/
|
|
79
|
+
function getConfigPath() {
|
|
80
|
+
return CONFIG_FILE;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the config directory path
|
|
84
|
+
*/
|
|
85
|
+
function getConfigDir() {
|
|
86
|
+
return CONFIG_DIR;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAmBH,gCAYC;AAKD,gCAIC;AAKD,wCAKC;AAKD,wCAOC;AAKD,oCAGC;AAKD,0CAGC;AAKD,sCAEC;AAKD,oCAEC;AAzFD,2BAA6B;AAC7B,2BAAwE;AACxE,+BAA4B;AAG5B,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,IAAA,YAAO,GAAE,EAAE,QAAQ,CAAC,CAAC;AAC7C,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;AAEvD,iCAAiC;AACjC,IAAI,CAAC,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;IAC5B,IAAA,cAAS,EAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU;IACxB,IAAI,CAAC,IAAA,eAAU,EAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiB,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAA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
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './config';
|
|
8
|
+
export { SessionManager } from './session-manager';
|
|
9
|
+
export { configure } from './commands/configure';
|
|
10
|
+
export { setupHooks } from './commands/setup-hooks';
|
|
11
|
+
export { registerPC } from './commands/register';
|
|
12
|
+
export { startServer } from './commands/start';
|
|
13
|
+
export { showStatus } from './commands/status';
|
|
14
|
+
export { handleHook } from './commands/hook';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mirra Claude Code Bridge
|
|
4
|
+
*
|
|
5
|
+
* Bridge Claude Code to your Mirra mobile app for remote coding sessions.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.handleHook = exports.showStatus = exports.startServer = exports.registerPC = exports.setupHooks = exports.configure = exports.SessionManager = void 0;
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
24
|
+
__exportStar(require("./config"), exports);
|
|
25
|
+
var session_manager_1 = require("./session-manager");
|
|
26
|
+
Object.defineProperty(exports, "SessionManager", { enumerable: true, get: function () { return session_manager_1.SessionManager; } });
|
|
27
|
+
// Re-export command functions for programmatic use
|
|
28
|
+
var configure_1 = require("./commands/configure");
|
|
29
|
+
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return configure_1.configure; } });
|
|
30
|
+
var setup_hooks_1 = require("./commands/setup-hooks");
|
|
31
|
+
Object.defineProperty(exports, "setupHooks", { enumerable: true, get: function () { return setup_hooks_1.setupHooks; } });
|
|
32
|
+
var register_1 = require("./commands/register");
|
|
33
|
+
Object.defineProperty(exports, "registerPC", { enumerable: true, get: function () { return register_1.registerPC; } });
|
|
34
|
+
var start_1 = require("./commands/start");
|
|
35
|
+
Object.defineProperty(exports, "startServer", { enumerable: true, get: function () { return start_1.startServer; } });
|
|
36
|
+
var status_1 = require("./commands/status");
|
|
37
|
+
Object.defineProperty(exports, "showStatus", { enumerable: true, get: function () { return status_1.showStatus; } });
|
|
38
|
+
var hook_1 = require("./commands/hook");
|
|
39
|
+
Object.defineProperty(exports, "handleHook", { enumerable: true, get: function () { return hook_1.handleHook; } });
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,2CAAyB;AACzB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAEvB,mDAAmD;AACnD,kDAAiD;AAAxC,sGAAA,SAAS,OAAA;AAClB,sDAAoD;AAA3C,yGAAA,UAAU,OAAA;AACnB,gDAAiD;AAAxC,sGAAA,UAAU,OAAA;AACnB,0CAA+C;AAAtC,oGAAA,WAAW,OAAA;AACpB,4CAA+C;AAAtC,oGAAA,UAAU,OAAA;AACnB,wCAA6C;AAApC,kGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Manager - manages Claude Code terminal sessions
|
|
3
|
+
*
|
|
4
|
+
* Handles the full lifecycle including:
|
|
5
|
+
* - Spawning Claude Code processes
|
|
6
|
+
* - Creating Flow automations for reply routing
|
|
7
|
+
* - Cleaning up Flows when sessions end
|
|
8
|
+
*/
|
|
9
|
+
import { Session, SessionResponse } from './types';
|
|
10
|
+
interface SpawnOptions {
|
|
11
|
+
workingDir: string;
|
|
12
|
+
initialPrompt: string;
|
|
13
|
+
recipientId: string;
|
|
14
|
+
groupId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class SessionManager {
|
|
17
|
+
private sessions;
|
|
18
|
+
private sdk;
|
|
19
|
+
private apiKey;
|
|
20
|
+
private maxSessions;
|
|
21
|
+
private pcResourceId?;
|
|
22
|
+
private routerScriptId?;
|
|
23
|
+
private routerScriptIdPromise?;
|
|
24
|
+
constructor(apiKey: string, pcResourceId?: string);
|
|
25
|
+
/**
|
|
26
|
+
* Get the Claude Code router script ID from the server
|
|
27
|
+
* Caches the result for subsequent calls
|
|
28
|
+
*/
|
|
29
|
+
private getRouterScriptId;
|
|
30
|
+
/**
|
|
31
|
+
* Generate a unique session ID
|
|
32
|
+
*/
|
|
33
|
+
private generateSessionId;
|
|
34
|
+
/**
|
|
35
|
+
* Create a Flow for routing replies back to this session
|
|
36
|
+
*/
|
|
37
|
+
private createSessionFlow;
|
|
38
|
+
/**
|
|
39
|
+
* Delete the Flow for a session
|
|
40
|
+
*/
|
|
41
|
+
private deleteSessionFlow;
|
|
42
|
+
/**
|
|
43
|
+
* Spawn a new Claude Code session
|
|
44
|
+
*/
|
|
45
|
+
spawnSession(options: SpawnOptions): Promise<Session>;
|
|
46
|
+
/**
|
|
47
|
+
* Send input to a session
|
|
48
|
+
*/
|
|
49
|
+
sendInput(sessionId: string, input: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Kill a session
|
|
52
|
+
*/
|
|
53
|
+
killSession(sessionId: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get a session by ID
|
|
56
|
+
*/
|
|
57
|
+
getSession(sessionId: string): Session | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* List all sessions
|
|
60
|
+
*/
|
|
61
|
+
listSessions(): SessionResponse[];
|
|
62
|
+
/**
|
|
63
|
+
* Kill all sessions
|
|
64
|
+
*/
|
|
65
|
+
killAllSessions(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Get count of active sessions
|
|
68
|
+
*/
|
|
69
|
+
getActiveCount(): number;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
72
|
+
//# 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":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAWnD,UAAU,YAAY;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB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