@dmsdc-ai/aigentry-telepty 0.1.55 → 0.1.57

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.
Files changed (3) hide show
  1. package/cli.js +59 -2
  2. package/daemon.js +16 -7
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -667,9 +667,11 @@ async function main() {
667
667
  process.exit(1);
668
668
  }
669
669
 
670
- // Default session ID = command name
670
+ // Default session ID = {folder}-{cli} (e.g. aigentry-dustcraw-claude)
671
671
  if (!sessionId) {
672
- sessionId = path.basename(command);
672
+ const folder = path.basename(process.cwd());
673
+ const cli = path.basename(command).replace(/\..*$/, '');
674
+ sessionId = `${folder}-${cli}`;
673
675
  }
674
676
 
675
677
  await ensureDaemonRunning({ requiredCapabilities: ['wrapped-sessions'] });
@@ -1151,6 +1153,61 @@ async function main() {
1151
1153
  return;
1152
1154
  }
1153
1155
 
1156
+ if (cmd === 'session' && args[1] === 'start') {
1157
+ // Generate kitty session file and launch
1158
+ const configArg = args.find(a => a.startsWith('--config='));
1159
+ const configPath = configArg ? configArg.split('=').slice(1).join('=') : null;
1160
+ const cliArg = args.find(a => a.startsWith('--cli='));
1161
+ const cli = cliArg ? cliArg.split('=')[1] : 'claude --dangerously-skip-permissions';
1162
+ const projectsDir = args.find(a => a.startsWith('--dir=')) ? args.find(a => a.startsWith('--dir=')).split('=')[1] : process.cwd();
1163
+
1164
+ // Discover project folders (subdirectories with .git)
1165
+ let projects;
1166
+ if (configPath) {
1167
+ projects = JSON.parse(fs.readFileSync(configPath, 'utf8')).projects;
1168
+ } else {
1169
+ projects = fs.readdirSync(projectsDir, { withFileTypes: true })
1170
+ .filter(d => d.isDirectory() && fs.existsSync(path.join(projectsDir, d.name, '.git')))
1171
+ .map(d => ({ name: d.name, cwd: path.join(projectsDir, d.name) }));
1172
+ }
1173
+
1174
+ if (projects.length === 0) {
1175
+ console.error('❌ No git projects found in', projectsDir);
1176
+ process.exit(1);
1177
+ }
1178
+
1179
+ // Generate kitty session file
1180
+ const sessionFile = path.join(os.tmpdir(), `telepty-session-${Date.now()}.conf`);
1181
+ let conf = '# Auto-generated telepty session\n';
1182
+ projects.forEach((p, i) => {
1183
+ const name = p.name;
1184
+ const cwd = p.cwd || path.join(projectsDir, name);
1185
+ const sessionId = `${name}-${cli.split(' ')[0]}`;
1186
+ if (i === 0) {
1187
+ conf += `new_tab ${name}\n`;
1188
+ } else {
1189
+ conf += `\nnew_tab ${name}\n`;
1190
+ }
1191
+ conf += `layout tall\n`;
1192
+ conf += `cd ${cwd}\n`;
1193
+ conf += `title ${name}\n`;
1194
+ conf += `launch --type=window telepty allow --id ${sessionId} ${cli}\n`;
1195
+ });
1196
+
1197
+ fs.writeFileSync(sessionFile, conf);
1198
+ console.log(`✅ Kitty session file: ${sessionFile}`);
1199
+ console.log(` ${projects.length} projects, CLI: ${cli}`);
1200
+ console.log(`\n Launch: kitty --session ${sessionFile}\n`);
1201
+
1202
+ // Auto-launch if --launch flag
1203
+ if (args.includes('--launch')) {
1204
+ const { spawn } = require('child_process');
1205
+ spawn('kitty', ['--session', sessionFile], { detached: true, stdio: 'ignore' }).unref();
1206
+ console.log('🚀 Kitty launched.');
1207
+ }
1208
+ return;
1209
+ }
1210
+
1154
1211
  if (cmd === 'deliberate') {
1155
1212
  await ensureDaemonRunning();
1156
1213
  const subCmd = args[1];
package/daemon.js CHANGED
@@ -589,7 +589,7 @@ function sendViaKitty(sessionId, text) {
589
589
  }
590
590
 
591
591
  try {
592
- // Split text and CR — send-text for content, send-key for Enter
592
+ // Split text and CR — send-text for both (send-key corrupts keyboard protocol)
593
593
  const hasCr = text.endsWith('\r') || text.endsWith('\n');
594
594
  const textOnly = hasCr ? text.slice(0, -1) : text;
595
595
  if (textOnly.length > 0) {
@@ -601,7 +601,7 @@ function sendViaKitty(sessionId, text) {
601
601
  if (hasCr) {
602
602
  // Delay before sending Return — CLI needs time to process text input
603
603
  execSync('sleep 0.5', { timeout: 2000 });
604
- execSync(`kitty @ --to unix:${socket} send-key --match id:${windowId} Return`, {
604
+ execSync(`kitty @ --to unix:${socket} send-text --match id:${windowId} $'\\r'`, {
605
605
  timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
606
606
  });
607
607
  }
@@ -797,7 +797,7 @@ app.post('/api/sessions/:id/inject', (req, res) => {
797
797
  setTimeout(() => {
798
798
  if (wid && sock) {
799
799
  try {
800
- require('child_process').execSync(`kitty @ --to unix:${sock} send-key --match id:${wid} Return`, {
800
+ require('child_process').execSync(`kitty @ --to unix:${sock} send-text --match id:${wid} $'\\r'`, {
801
801
  timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
802
802
  });
803
803
  require('child_process').execSync(`kitty @ --to unix:${sock} set-tab-title --match id:${wid} '⚡ telepty :: ${id}'`, {
@@ -942,14 +942,21 @@ app.delete('/api/sessions/:id', (req, res) => {
942
942
  function busAutoRoute(msg) {
943
943
  const eventType = msg.type || msg.kind;
944
944
  const isRoutable = (eventType === 'turn_request' || eventType === 'deliberation_route_turn') && (msg.target || msg.target_session_id);
945
- if (!isRoutable) return;
945
+ if (!isRoutable) {
946
+ // Log all bus messages for debugging (excluding health checks)
947
+ if (eventType && eventType !== 'session_health') {
948
+ console.log(`[BUS] Event: ${eventType} (not routable)`);
949
+ }
950
+ return;
951
+ }
946
952
 
947
953
  const rawTarget = (msg.target || msg.target_session_id).split('@')[0];
948
- console.log(`[BUS-ROUTE] Received ${eventType}: target=${rawTarget}`);
954
+ const turnId = (msg.payload && msg.payload.turn_id) || null;
955
+ console.log(`[BUS-ROUTE] ${eventType}: target=${rawTarget} turn=${turnId} msg_id=${msg.message_id || 'none'}`);
949
956
  const targetId = resolveSessionAlias(rawTarget);
950
957
  const targetSession = targetId ? sessions[targetId] : null;
951
958
  if (!targetSession) {
952
- console.log(`[BUS-ROUTE] Target ${rawTarget} not found`);
959
+ console.log(`[BUS-ROUTE] Target ${rawTarget} not found among: ${Object.keys(sessions).join(', ')}`);
953
960
  return;
954
961
  }
955
962
 
@@ -970,7 +977,7 @@ function busAutoRoute(msg) {
970
977
  });
971
978
  setTimeout(() => {
972
979
  try {
973
- require('child_process').execSync(`kitty @ --to unix:${sock} send-key --match id:${wid} Return`, {
980
+ require('child_process').execSync(`kitty @ --to unix:${sock} send-text --match id:${wid} $'\\r'`, {
974
981
  timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
975
982
  });
976
983
  } catch {}
@@ -1002,6 +1009,8 @@ function busAutoRoute(msg) {
1002
1009
  source_host: MACHINE_ID,
1003
1010
  target_agent: targetId,
1004
1011
  source_type: 'bus_auto_route',
1012
+ turn_id: (msg.payload && msg.payload.turn_id) || null,
1013
+ original_message_id: msg.message_id || null,
1005
1014
  delivered,
1006
1015
  timestamp: new Date().toISOString()
1007
1016
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmsdc-ai/aigentry-telepty",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "main": "daemon.js",
5
5
  "bin": {
6
6
  "aigentry-telepty": "install.js",