worker

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const PreConnectAudioBufferStream = "lk.agent.pre-connect-audio-buffer"

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentServer

type AgentServer struct {
	Options WorkerOptions
	// contains filtered or unexported fields
}

func NewAgentServer

func NewAgentServer(opts WorkerOptions) *AgentServer

func (*AgentServer) ExecuteLocalJob

func (s *AgentServer) ExecuteLocalJob(ctx context.Context, roomName string, participantIdentity string) error

ExecuteLocalJob runs a job locally without connecting to the worker service, useful for the CLI console

func (*AgentServer) GetConsoleSession

func (s *AgentServer) GetConsoleSession() any

GetConsoleSession retrieves the active local console session

func (*AgentServer) RTCSession

func (s *AgentServer) RTCSession(
	entrypoint func(*JobContext) error,
	request func(*JobRequest) error,
	sessionEnd func(*JobContext) error,
)

func (*AgentServer) Run

func (s *AgentServer) Run(ctx context.Context) error

func (*AgentServer) SetConsoleSession

func (s *AgentServer) SetConsoleSession(session any)

SetConsoleSession allows entrypoints to register their session for console interaction

type AudioDecoder

type AudioDecoder interface {
	Decode(data []byte) ([]byte, error)
	Close() error
}

type AudioEncoder

type AudioEncoder interface {
	Encode(pcm []byte) ([]byte, error)
	Close() error
}

type JobAcceptArguments

type JobAcceptArguments struct {
	Name       string
	Identity   string
	Metadata   string
	Attributes map[string]string
}

type JobContext

type JobContext struct {
	Job    *livekit.Job
	Room   *lksdk.Room
	Report *agent.SessionReport
	// contains filtered or unexported fields
}

func NewJobContext

func NewJobContext(job *livekit.Job, url string, apiKey string, apiSecret string) *JobContext

func (*JobContext) AddSIPParticipant

func (c *JobContext) AddSIPParticipant(ctx context.Context, callTo string, trunkID string, identity string, name string) (*livekit.SIPParticipantInfo, error)

AddSIPParticipant adds a SIP participant to the room.

func (*JobContext) Connect

func (c *JobContext) Connect(ctx context.Context, cb *lksdk.RoomCallback) error

func (*JobContext) DeleteRoom

func (c *JobContext) DeleteRoom(ctx context.Context, roomName string) (*livekit.DeleteRoomResponse, error)

DeleteRoom deletes the room and disconnects all participants.

func (*JobContext) Shutdown

func (c *JobContext) Shutdown(reason string)

func (*JobContext) TransferSIPParticipant

func (c *JobContext) TransferSIPParticipant(ctx context.Context, identity string, transferTo string, playDialtone bool) error

TransferSIPParticipant transfers a SIP participant to another number.

type JobRequest

type JobRequest struct {
	Job *livekit.Job
	// contains filtered or unexported fields
}

func (*JobRequest) Accept

func (r *JobRequest) Accept(args JobAcceptArguments) error

func (*JobRequest) Reject

func (r *JobRequest) Reject() error

type PreConnectAudioBuffer

type PreConnectAudioBuffer struct {
	Timestamp time.Time
	Frames    []*model.AudioFrame
}

type PreConnectAudioHandler

type PreConnectAudioHandler struct {
	// contains filtered or unexported fields
}

func NewPreConnectAudioHandler

func NewPreConnectAudioHandler(room *lksdk.Room, timeout time.Duration) *PreConnectAudioHandler

func (*PreConnectAudioHandler) Register

func (h *PreConnectAudioHandler) Register()

func (*PreConnectAudioHandler) WaitForData

func (h *PreConnectAudioHandler) WaitForData(ctx context.Context, trackID string) []*model.AudioFrame

type RecorderIO

type RecorderIO struct {
	Session *agent.AgentSession

	OutPath string
	// contains filtered or unexported fields
}

RecorderIO records a conversation as a stereo WAV file. Left channel = user (input), Right channel = agent (output). Both channels must be fed at the same sample rate (48kHz).

func NewRecorderIO

func NewRecorderIO(session *agent.AgentSession) *RecorderIO

func (*RecorderIO) RecordInput

func (r *RecorderIO) RecordInput(frame *model.AudioFrame)

func (*RecorderIO) RecordOutput

func (r *RecorderIO) RecordOutput(frame *model.AudioFrame)

func (*RecorderIO) Start

func (r *RecorderIO) Start(outputPath string, sampleRate int) error

Start begins recording to a stereo WAV file at the given sample rate.

func (*RecorderIO) Stop

func (r *RecorderIO) Stop() error

Stop signals the record loop to flush and close, then waits for it to finish.

type RoomIO

type RoomIO struct {
	Room         *lksdk.Room
	AgentSession *agent.AgentSession
	Options      RoomOptions
	Recorder     *RecorderIO
	// contains filtered or unexported fields
}

func NewRoomIO

func NewRoomIO(room *lksdk.Room, session *agent.AgentSession, opts RoomOptions) *RoomIO

func (*RoomIO) Close

func (rio *RoomIO) Close() error

func (*RoomIO) GetCallback

func (rio *RoomIO) GetCallback() *lksdk.RoomCallback

func (*RoomIO) PublishAudio

func (rio *RoomIO) PublishAudio(frame *model.AudioFrame) error

func (*RoomIO) Start

func (rio *RoomIO) Start(ctx context.Context) error

type RoomOptions

type RoomOptions struct {
}

type WorkerOptions

type WorkerOptions struct {
	AgentName           string
	WorkerType          WorkerType
	MaxRetry            int
	WSRL                string
	APIKey              string
	APISecret           string
	HTTPProxy           string
	JobMemoryWarnMB     float64
	JobMemoryLimitMB    float64
	NumIdleProcesses    int
	DrainTimeoutSeconds int
}

type WorkerType

type WorkerType string
const (
	WorkerTypeRoom      WorkerType = "room"
	WorkerTypePublisher WorkerType = "publisher"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL