@dmsdc-ai/aigentry-telepty 0.1.0 → 0.1.2
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/.gemini/skills/telepty/SKILL.md +15 -4
- package/cli.js +0 -6
- package/daemon.js +19 -0
- package/package.json +2 -4
- package/mcp.js +0 -97
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# telepty
|
|
2
2
|
|
|
3
3
|
**Description:**
|
|
4
|
-
Help the user interact with the `telepty` daemon, check their current session ID, list active sessions, and inject commands into remote or local PTY sessions.
|
|
4
|
+
Help the user interact with the `telepty` daemon, check their current session ID, list active sessions, and inject commands or JSON events into remote or local PTY sessions. All operations are performed using standard CLI commands or `curl`.
|
|
5
5
|
|
|
6
6
|
**Trigger:**
|
|
7
|
-
When the user asks about their current session ID
|
|
7
|
+
When the user asks about their current session ID, wants to check active sessions, wants to inject a prompt/command into a specific session, wants to send a JSON event via the bus, or wants to update telepty.
|
|
8
8
|
|
|
9
9
|
**Instructions:**
|
|
10
10
|
1. **To check the current session ID:**
|
|
11
11
|
- Execute `run_shell_command` with `echo $TELEPTY_SESSION_ID`.
|
|
12
|
-
- If the value is empty, inform the user that the current shell is *not* running inside a telepty spawned session
|
|
13
|
-
- If it has a value, output it clearly
|
|
12
|
+
- If the value is empty, inform the user that the current shell is *not* running inside a telepty spawned session.
|
|
13
|
+
- If it has a value, output it clearly.
|
|
14
14
|
2. **To list all sessions:**
|
|
15
15
|
- Run `telepty list`.
|
|
16
16
|
3. **To inject a command into another session:**
|
|
@@ -19,3 +19,14 @@ When the user asks about their current session ID (e.g. "내 세션 ID가 뭐야
|
|
|
19
19
|
- For multicasting to multiple specific sessions: Run `telepty multicast <id1>,<id2> "<message or command>"`.
|
|
20
20
|
4. **To update telepty:**
|
|
21
21
|
- Run `telepty update`.
|
|
22
|
+
5. **To publish a JSON event to the Event Bus (/api/bus):**
|
|
23
|
+
- Use `curl` to post directly to the local daemon (it will relay to all active clients).
|
|
24
|
+
- First, get the token: `TOKEN=$(cat ~/.telepty/config.json | grep authToken | cut -d '"' -f 4)`
|
|
25
|
+
- Then run:
|
|
26
|
+
```bash
|
|
27
|
+
curl -X POST http://127.0.0.1:3848/api/bus/publish \
|
|
28
|
+
-H "Content-Type: application/json" \
|
|
29
|
+
-H "x-telepty-token: $TOKEN" \
|
|
30
|
+
-d '{"type": "my_event", "payload": "data"}'
|
|
31
|
+
```
|
|
32
|
+
- (Modify the JSON payload structure according to the user's specific request.)
|
package/cli.js
CHANGED
|
@@ -305,11 +305,6 @@ async function main() {
|
|
|
305
305
|
return;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
if (cmd === 'mcp') {
|
|
309
|
-
require('./mcp.js');
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
308
|
if (cmd === 'daemon') {
|
|
314
309
|
console.log('Starting telepty daemon...');
|
|
315
310
|
require('./daemon.js');
|
|
@@ -502,7 +497,6 @@ Usage:
|
|
|
502
497
|
telepty multicast <id1,id2> "<prompt>" Inject text into multiple specific sessions
|
|
503
498
|
telepty broadcast "<prompt>" Inject text into ALL active sessions
|
|
504
499
|
telepty update Update telepty to the latest version
|
|
505
|
-
telepty mcp Start the MCP stdio server
|
|
506
500
|
`);
|
|
507
501
|
}
|
|
508
502
|
|
package/daemon.js
CHANGED
|
@@ -178,6 +178,25 @@ app.delete('/api/sessions/:id', (req, res) => {
|
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
|
|
181
|
+
app.post('/api/bus/publish', (req, res) => {
|
|
182
|
+
const payload = req.body;
|
|
183
|
+
|
|
184
|
+
if (!payload || typeof payload !== 'object') {
|
|
185
|
+
return res.status(400).json({ error: 'Payload must be a JSON object' });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let deliveredCount = 0;
|
|
189
|
+
|
|
190
|
+
busClients.forEach(client => {
|
|
191
|
+
if (client.readyState === 1) { // WebSocket.OPEN
|
|
192
|
+
client.send(JSON.stringify(payload));
|
|
193
|
+
deliveredCount++;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
res.json({ success: true, delivered: deliveredCount });
|
|
198
|
+
});
|
|
199
|
+
|
|
181
200
|
const server = app.listen(PORT, HOST, () => {
|
|
182
201
|
console.log(`🚀 aigentry-telepty daemon listening on http://${HOST}:${PORT}`);
|
|
183
202
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dmsdc-ai/aigentry-telepty",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"main": "daemon.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"telepty": "cli.js",
|
|
@@ -14,14 +14,12 @@
|
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"description": "",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
18
17
|
"cors": "^2.8.6",
|
|
19
18
|
"express": "^5.2.1",
|
|
20
19
|
"node-pty": "^1.2.0-beta.11",
|
|
21
20
|
"prompts": "^2.4.2",
|
|
22
21
|
"update-notifier": "^5.1.0",
|
|
23
22
|
"uuid": "^13.0.0",
|
|
24
|
-
"ws": "^8.19.0"
|
|
25
|
-
"zod": "^4.3.6"
|
|
23
|
+
"ws": "^8.19.0"
|
|
26
24
|
}
|
|
27
25
|
}
|
package/mcp.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
|
|
2
|
-
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
3
|
-
const { CallToolRequestSchema, ListToolsRequestSchema } = require('@modelcontextprotocol/sdk/types.js');
|
|
4
|
-
const { z } = require('zod');
|
|
5
|
-
const { zodToJsonSchema } = require('zod-to-json-schema');
|
|
6
|
-
const { getConfig } = require('./auth');
|
|
7
|
-
|
|
8
|
-
const config = getConfig();
|
|
9
|
-
const TOKEN = config.authToken;
|
|
10
|
-
|
|
11
|
-
const server = new Server({ name: 'telepty-mcp-server', version: '0.0.1' }, { capabilities: { tools: {} } });
|
|
12
|
-
|
|
13
|
-
const tools = [
|
|
14
|
-
{
|
|
15
|
-
name: 'telepty_list_remote_sessions',
|
|
16
|
-
description: 'List all active AI CLI sessions (PTYs) running on a remote telepty daemon. Used to discover available target session IDs.',
|
|
17
|
-
schema: z.object({ remote_url: z.string().describe('Tailscale IP/Host and port (e.g., 100.100.100.5:3848) of the remote daemon.') })
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: 'telepty_inject_context',
|
|
21
|
-
description: 'Inject a prompt or context into specific active AI CLI sessions on a remote machine. You can specify a single session ID, multiple session IDs, or broadcast to all.',
|
|
22
|
-
schema: z.object({
|
|
23
|
-
remote_url: z.string(),
|
|
24
|
-
session_ids: z.array(z.string()).optional().describe('An array of exact session IDs to inject into. If not provided, it will inject into session_id.'),
|
|
25
|
-
session_id: z.string().optional().describe('Legacy fallback for a single session ID.'),
|
|
26
|
-
broadcast: z.boolean().optional().describe('If true, injects the prompt into ALL active sessions on the remote daemon. Overrides session_ids.'),
|
|
27
|
-
prompt: z.string().describe('Text to inject into stdin.')
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
33
|
-
tools: tools.map(t => {
|
|
34
|
-
const schema = zodToJsonSchema(t.schema);
|
|
35
|
-
delete schema.$schema;
|
|
36
|
-
if (!schema.type) schema.type = 'object';
|
|
37
|
-
return { name: t.name, description: t.description, inputSchema: schema };
|
|
38
|
-
})
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
42
|
-
try {
|
|
43
|
-
const { name, arguments: args } = request.params;
|
|
44
|
-
if (name === 'telepty_list_remote_sessions') {
|
|
45
|
-
const baseUrl = args.remote_url.startsWith('http') ? args.remote_url : `http://${args.remote_url}`;
|
|
46
|
-
const res = await fetch(`${baseUrl}/api/sessions`, { headers: { 'x-telepty-token': TOKEN } });
|
|
47
|
-
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
48
|
-
const sessions = await res.json();
|
|
49
|
-
if (!sessions || sessions.length === 0) return { content: [{ type: 'text', text: `No active sessions found on ${args.remote_url}` }] };
|
|
50
|
-
let text = `Active sessions on ${args.remote_url}:\n\n`;
|
|
51
|
-
sessions.forEach(s => { text += `- ID: ${s.id}\n Command: ${s.command}\n Workspace: ${s.cwd}\n\n`; });
|
|
52
|
-
return { content: [{ type: 'text', text }] };
|
|
53
|
-
}
|
|
54
|
-
if (name === 'telepty_inject_context') {
|
|
55
|
-
const baseUrl = args.remote_url.startsWith('http') ? args.remote_url : `http://${args.remote_url}`;
|
|
56
|
-
|
|
57
|
-
let endpoint = '';
|
|
58
|
-
let body = {};
|
|
59
|
-
|
|
60
|
-
if (args.broadcast) {
|
|
61
|
-
endpoint = `${baseUrl}/api/sessions/broadcast/inject`;
|
|
62
|
-
body = { prompt: args.prompt };
|
|
63
|
-
} else if (args.session_ids && args.session_ids.length > 0) {
|
|
64
|
-
endpoint = `${baseUrl}/api/sessions/multicast/inject`;
|
|
65
|
-
body = { session_ids: args.session_ids, prompt: args.prompt };
|
|
66
|
-
} else if (args.session_id) {
|
|
67
|
-
endpoint = `${baseUrl}/api/sessions/${encodeURIComponent(args.session_id)}/inject`;
|
|
68
|
-
body = { prompt: args.prompt };
|
|
69
|
-
} else {
|
|
70
|
-
throw new Error('You must provide either broadcast: true, session_ids: [...], or session_id: "..."');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const res = await fetch(endpoint, {
|
|
74
|
-
method: 'POST', headers: { 'Content-Type': 'application/json', 'x-telepty-token': TOKEN }, body: JSON.stringify(body)
|
|
75
|
-
});
|
|
76
|
-
const data = await res.json();
|
|
77
|
-
if (!res.ok) throw new Error(data.error || `HTTP ${res.status}`);
|
|
78
|
-
|
|
79
|
-
let msg = `✅ Successfully injected context.`;
|
|
80
|
-
if (args.broadcast) msg += ` (Broadcasted to ${data.results.successful.length} sessions)`;
|
|
81
|
-
else if (args.session_ids) msg += ` (Multicasted to ${data.results.successful.length} sessions)`;
|
|
82
|
-
else msg += ` (Targeted session '${args.session_id}')`;
|
|
83
|
-
|
|
84
|
-
return { content: [{ type: 'text', text: msg }] };
|
|
85
|
-
}
|
|
86
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
87
|
-
} catch (err) {
|
|
88
|
-
return { content: [{ type: 'text', text: `❌ Error: ${err.message}` }], isError: true };
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
async function main() {
|
|
93
|
-
const transport = new StdioServerTransport();
|
|
94
|
-
await server.connect(transport);
|
|
95
|
-
console.error('Telepty MCP Server running on stdio');
|
|
96
|
-
}
|
|
97
|
-
main().catch(console.error);
|