agentp 0.11.9 → 0.11.10

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 CHANGED
@@ -241,8 +241,12 @@ Non-text Telegram updates (photos, stickers, etc.) are silently ignored.
241
241
  | `/always` | Approve and remember for the session |
242
242
  | `/answer <number>` | Respond to a question asked by the AI (structured multiple-choice) |
243
243
  | `/markdown` | Send the original markdown of the last response as a `.md` file; reply to a message to get that specific response |
244
+ | `/agents list` | List available agents/models |
245
+ | `/agents switch <name>` | Switch the active agent for subsequent messages (synced to server via API) |
244
246
  | `/shutdown [force\|clear]` | (requires `--dev`) Stop tgagentp; `clear` also wipes saved connections |
245
247
 
248
+ > **Note on model/agent switching:** Changing the model in the OpenCode TUI's prompt dropdown is a **local UI action** — it only takes effect server-side after a message is sent *through the TUI*. If you change the model in the TUI and then send a prompt via `agentp` or Telegram, the old model will still be used. Use `/agents switch <name>` from Telegram (or `tgagentp`) to change models — this explicitly calls the API and syncs correctly.
249
+
246
250
  #### TUI Command Passthrough
247
251
 
248
252
  Messages starting with `//` are forwarded to the OpenCode TUI as raw keystrokes (not text sent to the AI):
package/bin/ocmux CHANGED
@@ -309,6 +309,8 @@ function cmdNew(targetDir, longMode, printLogs) {
309
309
  }
310
310
 
311
311
  function doNew(targetDir, longMode, printLogs) {
312
+ // Normalize to real path so tmux window names are consistent regardless of symlinks
313
+ try { targetDir = fs.realpathSync(targetDir); } catch {}
312
314
  ensureSession();
313
315
  const lf = logfileFor(targetDir);
314
316
 
@@ -601,13 +603,26 @@ function main() {
601
603
  console.error("Error: '--print-logs' is only valid with 'serve'.");
602
604
  process.exit(1);
603
605
  }
604
- // Default mode
605
- const sf = findParentStatefile(targetDir);
606
+ // Default mode — find an existing server and switch to it
607
+ let sf = findParentStatefile(targetDir);
606
608
  if (!sf) {
607
609
  console.error(`Error: no opencode server found in ${targetDir} or any of its parents.`);
608
610
  console.error("Run 'ocmux serve' to create a new server.");
609
611
  process.exit(1);
610
612
  }
613
+
614
+ // Skip stale state files whose tmux window no longer exists,
615
+ // and search from the parent directory instead.
616
+ const state = readState(sf);
617
+ if (state && state.window_index != null) {
618
+ const serverDir = path.dirname(sf);
619
+ const actualName = windowNameByIndex(state.window_index);
620
+ if (actualName !== serverDir && windowByDir(serverDir) == null) {
621
+ const parentSf = findParentStatefile(path.dirname(serverDir));
622
+ if (parentSf) sf = parentSf;
623
+ }
624
+ }
625
+
611
626
  ensureSession();
612
627
  cmdSwitch(sf, longMode);
613
628
  }
package/lib/ocmux.js CHANGED
@@ -63,11 +63,16 @@ function tuiPaneId(windowIndex) {
63
63
  }
64
64
 
65
65
  function windowByDir(dir) {
66
+ let realDir;
67
+ try { realDir = fs.realpathSync(dir); } catch { realDir = dir; }
66
68
  const r = _tmux(['list-windows', '-t', SESSION, '-F', '#{window_index}\t#{window_name}']);
67
69
  if (r.status !== 0) return null;
68
70
  for (const line of r.stdout.trim().split('\n').filter(Boolean)) {
69
71
  const [idx, name] = line.split('\t');
70
72
  if (name === dir) return parseInt(idx, 10);
73
+ try {
74
+ if (fs.realpathSync(name) === realDir) return parseInt(idx, 10);
75
+ } catch {}
71
76
  }
72
77
  return null;
73
78
  }
@@ -216,6 +221,7 @@ function activateServer(dir, index, url) {
216
221
  // Delegates to startServer for the actual server creation.
217
222
  // Returns { url, dir } on success, throws on error.
218
223
  function resurrectServer(dir, printLogs) {
224
+ try { dir = fs.realpathSync(dir); } catch {}
219
225
  const sf = path.join(dir, '.ocmux.json');
220
226
  const state = readState(sf);
221
227
 
@@ -249,6 +255,8 @@ function resurrectServer(dir, printLogs) {
249
255
  // Creates a tmux window, starts opencode serve, waits for the URL,
250
256
  // and writes .ocmux.json. Returns { url, dir } on success.
251
257
  function startServer(dir, printLogs) {
258
+ // Normalize to real path so tmux window names are consistent regardless of symlinks
259
+ try { dir = fs.realpathSync(dir); } catch {}
252
260
  ensureSession();
253
261
  const lf = logfileFor(dir);
254
262
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentp",
3
- "version": "0.11.9",
3
+ "version": "0.11.10",
4
4
  "description": "Pipe prompts into a running OpenCode TUI session and stream the final answer",
5
5
  "bin": {
6
6
  "agentp": "bin/agentp",