io.go 749 B

123456789101112131415161718192021222324252627
  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.OnClose(func() {
  9. stdio_holder.RemoveListener(r.io_identity, session_id)
  10. })
  11. stdio_holder.OnEvent(r.io_identity, session_id, func(b []byte) {
  12. listener.Emit(b)
  13. })
  14. return listener
  15. }
  16. func (r *LocalPluginRuntime) Write(session_id string, data []byte) {
  17. stdio_holder.Write(r.io_identity, append(data, '\n'))
  18. }
  19. func (r *LocalPluginRuntime) Request(session_id string, data []byte) ([]byte, error) {
  20. return nil, nil
  21. }