io.go 749 B

1234567891011121314151617181920212223242526
  1. package local_manager
  2. import (
  3. "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager/stdio_holder"
  4. "github.com/langgenius/dify-plugin-daemon/internal/types/entities"
  5. )
  6. func (r *LocalPluginRuntime) Listen(session_id string) *entities.BytesIOListener {
  7. listener := entities.NewIOListener[[]byte]()
  8. listener_id := stdio_holder.OnStdioEvent(r.io_identity, func(b []byte) {
  9. listener.Write(b)
  10. })
  11. listener.OnClose(func() {
  12. stdio_holder.RemoveStdioListener(r.io_identity, listener_id)
  13. })
  14. return listener
  15. }
  16. func (r *LocalPluginRuntime) Write(session_id string, data []byte) {
  17. stdio_holder.Write(r.io_identity, data)
  18. }
  19. func (r *LocalPluginRuntime) Request(session_id string, data []byte) ([]byte, error) {
  20. return nil, nil
  21. }