[Feature]: Observability of running ptys
It is currently not possible (or not obvious) to see what's actually going on inside a pty without inquiring about it explicitly to the LLM: "please show me the logs of the pty". When you have your agent going in a loop to tackle some issue, you don't wanna interrupt it just to ask what's happening.
I'm not exactly sure about the best way to solve this observability issue given that plugins can't add new UI elements to OpenCode (to my knowledge), but here is an idea:
Introduce a /pty-show command that just prints the current state of the pseudo terminal. Something like /pty-show <id> <optional:offset>? Commands can be handled directly and insert a plugin-crafted user or assistant message into the session. Not sure if that's possible while running, but I believe it should even work as a queued up message.
Not optimal, but at least it's something to see what that terminal is actually doing
I believe you would be interested in what @MBanucu is building here: https://github.com/shekohex/opencode-pty/pull/13
Ohhh that's fire! 🔥 Nice job
Feel free to mark as Closes #14
@MBanucu I have a question about this. What if I run opencode on a headless server, on a remote VPS. Since your pty server runs on localhost by default (Good) we need a secure way to expose it on all interfaces with secret token in the headers or basic auth. Also get around CORS.
I mainly running opencode on remote workspaces, having access to it through a UI.
Just food for thought, need your opinion here.
https://github.com/shekohex/opencode-pty/issues/14#issuecomment-3841045980 @MBanucu I have a question about this. What if I run opencode on a headless server, on a remote VPS. Since your pty server runs on localhost by default (Good) we need a secure way to expose it on all interfaces with secret token in the headers or basic auth. Also get around CORS.
I mainly running opencode on remote workspaces, having access to it through a UI.
Just food for thought, need your opinion here.
My opinion is:
- I don't like security. Let bad people ruin you. If you get over it, they will suffer more than you and they will learn from you. You will even gain long term (whatever you want), if you let yourself get ruined correctly. If you add security, you lose the potential of getting challenged to get ruined.
- Security attracts thiefs. The more professional the security, the more professional the thieves.
- Security adds bugs.
- Security adds instability.
- Security increases the maintanance work.
- Security reduces flexibility and freedom.
- Security reduces potential.
- Security means risk of getting locked out.
- Security means risk of locking people out who need the feature to do good.
- Security is a bottomless pit. You will get lost in it.
This is security realized by walls and distance. My advice is: remove all security. Get transparent. Get naked. If everyone gets naked, then it will be clear who is the thief. The thief is the one who is not getting naked, because they have stolen things to hide. There is a rule: The bigger the thief, the more security they need. So "good" people harm themselves long term if they think that they need security. Currently the world is in a state where everyone is a thief. Everyone has to hide something. Even the kids. They learn being thief in their psychical base program by society. It is hard to survive in this social world without being thief. But everyone has the chance to improve themselves by letting themselves getting ruined intelligently and correctly.
I don't have a clue of installing and setting up security. There was a time in the development of this feature where the coding agent added security and it lead to all kinds of problems and slowdown of development.
So the conclusion is: If you want security, I can't help you with that. You have to do it probably yourself.
Fair, and I'm not going to argue with that.
However, a last requirement, we don't need this server to automatically start by default. We need a command to start it.
Is that the current behavior?
https://github.com/shekohex/opencode-pty/issues/14#issuecomment-3842396936 Fair, and I'm not going to argue with that.
However, a last requirement, we don't need this server to automatically start by default. We need a command to start it.
Is that the current behavior?
Yes. I measured the performance loss of starting the server and it is around 10 ms. However if I launch the plugin by linking to index.ts locally then there is not much measurable delay of starting opencode. But when using the npm version opencode-pty-test then the startup delay is increased by 1-2 s. But this has nothing to do with starting server.
I am going to change the code to launch the server only when requested by slash command.
There it is:
https://github.com/shekohex/opencode-pty/pull/13/commits/c31e63e225d03d45938b54cffb22966b2080643c
https://github.com/shekohex/opencode-pty/issues/14#issuecomment-3846731488 However if I launch the plugin by linking to index.ts locally then there is not much measurable delay of starting opencode. But when using the npm version opencode-pty-test then the startup delay is increased by 1-2 s.
Fixed: https://github.com/shekohex/opencode-pty/pull/13/commits/d9d5c29486553fa02240258c86c4a761a33df7db, https://github.com/shekohex/opencode-pty/pull/13/commits/3cec91550ce9af6ff8a7f71d4a7d4bb2bdbd0f3e
Awesome, great job.
Please try https://github.com/shekohex/opencode-pty/releases/tag/v0.2.0