Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions cmd/lk/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ var simulateAudioCommand = &cli.Command{
Usage: "Drop packets from the simulated user's audio track",
},
&cli.StringFlag{
Name: "to-phone-number",
Usage: "Call this `NUMBER` over SIP and simulate against whoever answers, instead of dispatching an agent. Requires --from-phone-number and --scenarios.",
Name: "to",
Usage: "Call this `NUMBER` (or SIP user) and simulate against whoever answers, instead of dispatching an agent. Requires --from and --scenarios.",
},
&cli.StringFlag{
Name: "from-trunk",
Usage: "Outbound SIP trunk `ID` to place --to-phone-number calls through. Without it, calls go out from a LiveKit phone number.",
Name: "trunk",
Usage: "Outbound SIP trunk `ID` to place --to calls through. Without it, calls go out from a LiveKit phone number.",
},
&cli.StringFlag{
Name: "from-phone-number",
Usage: "Caller `NUMBER` for --to-phone-number calls: a LiveKit phone number the project owns, or a number on --from-trunk",
Name: "from",
Usage: "Caller `NUMBER` for --to calls: a LiveKit phone number the project owns, or a number on --trunk",
},
},
}
Expand Down Expand Up @@ -424,15 +424,15 @@ type simulateConfig struct {
scenarioGroup *livekit.ScenarioGroup
scenariosPath string // path to the --scenarios file (empty when generating from source)
viewModeRunID string // non-empty when `view` opens a pre-existing run
liveAgent bool // --agent-name or --to-phone-number: run against an already-running agent, don't spawn one
liveAgent bool // --agent-name or --to: run against an already-running agent, don't spawn one
warnings []string // config-level warnings surfaced at setup (e.g. ignored flags)

// impairments on the simulated user's audio, set only in SIMULATION_MODE_AUDIO
backgroundNoise bool
lowQualityMicrophone bool
packetLoss bool

// --to-phone-number: dial this number over SIP in place of dispatching agentName
// --to: dial this number over SIP in place of dispatching agentName
sipCallTo string
sipTrunkID string
sipNumber string
Expand Down Expand Up @@ -541,21 +541,21 @@ func runSimulate(ctx context.Context, cmd *cli.Command, simulationMode livekit.S
samples := int32(cmd.Int("samples"))
passRate := cmd.Float("pass-rate")
liveAgentName := cmd.String("agent-name")
var phoneNumber, fromTrunk, fromPhoneNumber string
var callTo, trunkID, callFrom string
if simulationMode == livekit.SimulationMode_SIMULATION_MODE_AUDIO {
phoneNumber = cmd.String("to-phone-number")
fromTrunk = cmd.String("from-trunk")
fromPhoneNumber = cmd.String("from-phone-number")
callTo = cmd.String("to")
trunkID = cmd.String("trunk")
callFrom = cmd.String("from")
}
if fromTrunk != "" && phoneNumber == "" {
return fmt.Errorf("--from-trunk requires --to-phone-number")
if trunkID != "" && callTo == "" {
return fmt.Errorf("--trunk requires --to")
}
if fromPhoneNumber != "" && phoneNumber == "" {
return fmt.Errorf("--from-phone-number requires --to-phone-number")
if callFrom != "" && callTo == "" {
return fmt.Errorf("--from requires --to")
}
// every call needs a caller: the number simulations are placed from
if phoneNumber != "" && fromPhoneNumber == "" {
return fmt.Errorf("--to-phone-number requires --from-phone-number")
if callTo != "" && callFrom == "" {
return fmt.Errorf("--to requires --from")
}

// never auto-discovered: an explicit --scenarios file is the source of
Expand All @@ -582,10 +582,10 @@ func runSimulate(ctx context.Context, cmd *cli.Command, simulationMode livekit.S

// --agent-name (even empty) means: run against an already-running agent,
// don't spawn one. https://docs.livekit.io/agents/server/agent-dispatch/#automatic
if phoneNumber != "" {
if callTo != "" {
// nothing is spawned, so there's no source to generate scenarios from.
if scenariosPath == "" {
return fmt.Errorf("--to-phone-number requires --scenarios (no source to generate scenarios from when calling a number)")
return fmt.Errorf("--to requires --scenarios (no source to generate scenarios from when calling a number)")
}
liveAgent = true
} else if cmd.IsSet("agent-name") {
Expand Down Expand Up @@ -669,9 +669,9 @@ func runSimulate(ctx context.Context, cmd *cli.Command, simulationMode livekit.S
simCfg.backgroundNoise = cmd.Bool("background-noise")
simCfg.lowQualityMicrophone = cmd.Bool("low-quality-microphone")
simCfg.packetLoss = cmd.Bool("packet-loss")
simCfg.sipCallTo = phoneNumber
simCfg.sipTrunkID = fromTrunk
simCfg.sipNumber = fromPhoneNumber
simCfg.sipCallTo = callTo
simCfg.sipTrunkID = trunkID
simCfg.sipNumber = callFrom
}

if !isInteractive() {
Expand Down
14 changes: 8 additions & 6 deletions cmd/lk/sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,14 @@ var (
Usage: "`SIP_TRUNK_ID` to use for the call (overrides json config)",
},
&cli.StringFlag{
Name: "number",
Usage: "`SIP_NUMBER` to use for the call (overrides json config)",
Name: "from",
Aliases: []string{"number"},
Usage: "`SIP_NUMBER` to use for the call (overrides json config)",
},
&cli.StringFlag{
Name: "call",
Usage: "`SIP_CALL_TO` number to use (overrides json config)",
Name: "to",
Aliases: []string{"call"},
Usage: "`SIP_CALL_TO` phone number or SIP user to call (overrides json config)",
},
&cli.StringFlag{
Name: "name",
Expand Down Expand Up @@ -1273,10 +1275,10 @@ func createSIPParticipant(ctx context.Context, cmd *cli.Command) error {
if v := cmd.String("trunk"); v != "" {
req.SipTrunkId = v
}
if v := cmd.String("number"); v != "" {
if v := cmd.String("from"); v != "" {
req.SipNumber = v
}
if v := cmd.String("call"); v != "" {
if v := cmd.String("to"); v != "" {
req.SipCallTo = v
}
if v := cmd.String("room"); v != "" {
Expand Down
Loading