Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -62,17 +62,19 @@ actor AgentRPC {
|
||||
func send(
|
||||
text: String,
|
||||
thinking: String?,
|
||||
session: String,
|
||||
sessionKey: String,
|
||||
deliver: Bool,
|
||||
to: String?) async -> (ok: Bool, text: String?, error: String?)
|
||||
to: String?,
|
||||
channel: String? = nil) async -> (ok: Bool, text: String?, error: String?)
|
||||
{
|
||||
do {
|
||||
let params: [String: Any] = [
|
||||
"message": text,
|
||||
"sessionId": session,
|
||||
"sessionKey": sessionKey,
|
||||
"thinking": thinking ?? "default",
|
||||
"deliver": deliver,
|
||||
"to": to ?? "",
|
||||
"channel": channel ?? "",
|
||||
"idempotencyKey": UUID().uuidString,
|
||||
]
|
||||
_ = try await self.controlRequest(method: "agent", params: ControlRequestParams(raw: params))
|
||||
|
||||
@@ -57,9 +57,10 @@ enum ControlRequestHandler {
|
||||
let rpcResult = await AgentRPC.shared.send(
|
||||
text: trimmed,
|
||||
thinking: thinking,
|
||||
session: sessionKey,
|
||||
sessionKey: sessionKey,
|
||||
deliver: deliver,
|
||||
to: to)
|
||||
to: to,
|
||||
channel: nil)
|
||||
return rpcResult.ok
|
||||
? Response(ok: true, message: rpcResult.text ?? "sent")
|
||||
: Response(ok: false, message: rpcResult.error ?? "failed to send")
|
||||
|
||||
@@ -33,10 +33,11 @@ enum VoiceWakeForwarder {
|
||||
}
|
||||
|
||||
struct ForwardOptions: Sendable {
|
||||
var session: String = "main"
|
||||
var sessionKey: String = "main"
|
||||
var thinking: String = "low"
|
||||
var deliver: Bool = true
|
||||
var to: String?
|
||||
var channel: String = "last"
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
@@ -45,12 +46,15 @@ enum VoiceWakeForwarder {
|
||||
options: ForwardOptions = ForwardOptions()) async -> Result<Void, VoiceWakeForwardError>
|
||||
{
|
||||
let payload = Self.prefixedTranscript(transcript)
|
||||
let channel = options.channel.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
|
||||
let deliver = options.deliver && channel != "webchat"
|
||||
let result = await AgentRPC.shared.send(
|
||||
text: payload,
|
||||
thinking: options.thinking,
|
||||
session: options.session,
|
||||
deliver: options.deliver,
|
||||
to: options.to)
|
||||
sessionKey: options.sessionKey,
|
||||
deliver: deliver,
|
||||
to: options.to,
|
||||
channel: channel)
|
||||
|
||||
if result.ok {
|
||||
self.logger.info("voice wake forward ok")
|
||||
|
||||
Reference in New Issue
Block a user