Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding the plugin system and other languages #3097

Closed
bendiksolheim opened this issue Jan 31, 2024 · 2 comments
Closed

Question regarding the plugin system and other languages #3097

bendiksolheim opened this issue Jan 31, 2024 · 2 comments

Comments

@bendiksolheim
Copy link

Hello!

I am currently playing around with the plugin system in Zellij. Not the built-in Rust library, and not Zelligo, but rather trying to make something work with https://www.assemblyscript.org. I have managed to create a valid wasm build which seems to load correctly (load, update and render is called, and output from render is actually rendered), but I am having a hard time making communication work.

I am not at all fluent in Rust or Go, but by reading the code (and reading https://zellij.dev/documentation/plugin-upgrade-0.38.0), it seems to me that messages are passed as protocol buffers over stdout/stdin. I have managed to compile the proto files into classes with a library (https://github.com/gravitational/protobuf-as) which I can only assume works correctly, but I have hit a road block with these errors in the log:

INFO   |zellij_server::plugins::p| 2024-01-31 22:49:43.172 [async-std/runti] [zellij-server/src/plugins/plugin_loader.rs:495]: Loaded plugin 'build/debug.wasm' from cache folder at '/Users/[redacted]/Library/Caches/org.Zellij-Contributors.Zellij' in 2.020833ms
INFO   |zellij_server            | 2024-01-31 22:49:43.175 [async-std/runti] [zellij-server/src/lib.rs:919]: Compiling plugins using Cranelift
DEBUG  |build/debug.wasm         | 2024-01-31 22:49:43.179 [id: 0     ] load (<-- this is me logging from the plugin)
ERROR  |???                      | 2024-01-31 22:49:43.181 [async-std/runti] [zellij-server/src/plugins/zellij_exports.rs:258]: a non-fatal error occured

Caused by:
    0: failed to run plugin command build/debug.wasm (ID 0)
    1: failed to deserialize object from WASI env 'WasiEnv { ... }'
    2: expected value at line 1 column 1

Now, I don’t expect you to fix my problems as this is probably kinda far off your roadmap, but if you have any hints to point me in any direction, I would appreciate it a lot! I am out of ideas to try at this point, and the logs don’t really give me any clues other than telling me that my serialization is off. I am using Zellij 0.39.2 btw.

Thanks!

@imsnif
Copy link
Member

imsnif commented Feb 1, 2024

Hey, cool that you're working on this! I'm happy to answer questions here and there (also feel free to hop on our Discord, there are some plugin and SDK developers hanging out there too).

We serialize data structures into protobuffs, true, but we do this into a JSON array of bytes. So eg. "foo" would be serialized to [102, 111, 111]. I'm guessing this could be the issue here.

EDIT: so, just to be clear, the process should be:

  1. Encode structure to protobuf bytes
  2. Serialize these bytes into a json array over the wire

@bendiksolheim
Copy link
Author

You know what, that was indeed the missing piece! Thanks a lot 😄 I am now prompted to accept permissions, and the permissions are stored across sessions. Next stop: parsing updates. But I believe I have what I need now, so I’ll close this issue. Good point about the Discord, I’ll check it out once I have time, and will probably direct other questions there 😊

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants